Skip to content

Commit 13758b2

Browse files
committed
lint
1 parent e33687c commit 13758b2

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

src/lib/runtime.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const background = {
1111
},
1212
};
1313

14-
const nodes = new Map<null | number, DebugNode>();
14+
const nodes = {} as { [key: string]: DebugNode };
1515

1616
function resolveEventBubble(node: any) {
1717
if (!node.detail || !node.detail.listeners) return;
@@ -42,58 +42,66 @@ port.onMessage.addListener(({ type, payload }) => {
4242
case 'bridge::ext/clear': {
4343
selected.set(undefined);
4444
hovered.set(undefined);
45-
return root.set([]);
45+
root.set([]);
46+
break;
4647
}
4748

4849
case 'bridge::ext/inspect': {
49-
if (typeof payload === 'string') return;
50-
const current = nodes.get(payload.node.id);
51-
return selected.set(current);
50+
if (typeof payload === 'string') break;
51+
const current = nodes[payload.node.id];
52+
selected.set(current);
53+
break;
5254
}
5355

5456
case 'bridge::courier/node->add': {
5557
const { node, target, anchor } = payload as {
5658
node: DebugNode;
57-
target: null | number;
58-
anchor: null | number;
59+
target: string;
60+
anchor: string;
5961
};
6062

6163
node.children = [];
6264
node.expanded = false;
6365
node.invalidate = () => {};
6466
resolveEventBubble(node);
6567

66-
const parent = nodes.get(target);
67-
nodes.set(node.id, node);
68-
if (!parent) return root.update((n) => [...n, node]);
68+
const parent = nodes[target];
69+
nodes[node.id] = node;
70+
if (!parent) {
71+
root.update((n) => [...n, node]);
72+
break;
73+
}
6974

7075
const index = parent.children.findIndex((n) => n.id === anchor);
7176
if (index === -1) parent.children.push(node);
7277
else parent.children.splice(index, 0, node);
7378

74-
return (node.parent = parent).invalidate();
79+
(node.parent = parent).invalidate();
80+
break;
7581
}
7682

7783
case 'bridge::courier/node->remove': {
7884
const node = payload.node as SvelteBlockDetail;
79-
const current = nodes.get(node.id);
80-
if (current) nodes.delete(current.id);
81-
if (!current?.parent) return;
85+
const current = nodes[node.id];
86+
if (current) delete nodes[current.id];
87+
if (!current?.parent) break;
8288

8389
const index = current.parent.children.findIndex((o) => o.id === current.id);
8490
current.parent.children.splice(index, 1);
85-
return current.parent.invalidate();
91+
current.parent.invalidate();
92+
break;
8693
}
8794

8895
case 'bridge::courier/node->update': {
8996
const node = payload.node as SvelteBlockDetail;
90-
const current = nodes.get(node.id);
91-
if (!current) return;
97+
const current = nodes[node.id];
98+
if (!current) break;
9299
Object.assign(current, payload.node);
93100
resolveEventBubble(current);
94101

95102
selected.update((o) => o);
96-
return current.invalidate();
103+
current.invalidate();
104+
break;
97105
}
98106

99107
// case 'bridge::courier/profile->update': {

0 commit comments

Comments
 (0)