effect-atom-svelte-devtools 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/atom-devtools.svelte +151 -40
- package/dist/atom-devtools.svelte.d.ts +2 -1
- package/dist/graph/atom-graph.svelte +37 -9
- package/dist/graph/frame-graph.svelte +45 -37
- package/dist/graph/frame-graph.svelte.d.ts +1 -24
- package/dist/graph/graph-types.d.ts +28 -0
- package/dist/graph/graph-types.js +2 -0
- package/dist/graph/index.d.ts +1 -1
- package/dist/graph/layout.d.ts +5 -2
- package/dist/graph/layout.js +5 -4
- package/dist/internal/format.js +14 -7
- package/dist/internal/graph-view.svelte +23 -16
- package/dist/internal/label.js +40 -17
- package/dist/internal/model.svelte.js +39 -29
- package/dist/internal/names.js +4 -1
- package/dist/internal/settings-view.svelte +35 -8
- package/dist/internal/sheets-view.svelte +112 -36
- package/dist/internal/shortcut.js +6 -5
- package/dist/internal/timeline-view.svelte +71 -23
- package/dist/internal/transform.js +112 -82
- package/dist/vite.js +1 -1
- package/package.json +9 -8
|
@@ -26,17 +26,22 @@
|
|
|
26
26
|
model.atoms
|
|
27
27
|
.filter(
|
|
28
28
|
(view) =>
|
|
29
|
-
|
|
30
|
-
(showPlumbing || !view.plumbing
|
|
29
|
+
view.id === selected ||
|
|
30
|
+
(view.live && (showPlumbing || !view.plumbing))
|
|
31
31
|
)
|
|
32
32
|
.toSorted(
|
|
33
33
|
(a, b) =>
|
|
34
|
-
Number(a.plumbing) - Number(b.plumbing) ||
|
|
34
|
+
Number(a.plumbing) - Number(b.plumbing) ||
|
|
35
|
+
a.name.localeCompare(b.name)
|
|
35
36
|
)
|
|
36
37
|
);
|
|
37
|
-
const current = $derived(
|
|
38
|
+
const current = $derived(
|
|
39
|
+
selected === undefined ? undefined : byId.get(selected)
|
|
40
|
+
);
|
|
38
41
|
const number = $derived(
|
|
39
|
-
current === undefined
|
|
42
|
+
current === undefined
|
|
43
|
+
? 0
|
|
44
|
+
: sheets.findIndex((view) => view.id === current.id) + 1
|
|
40
45
|
);
|
|
41
46
|
const recent = $derived(
|
|
42
47
|
current === undefined
|
|
@@ -55,7 +60,9 @@
|
|
|
55
60
|
if (view.idleTTL === undefined || view.idleTTL === 0) {
|
|
56
61
|
return "none";
|
|
57
62
|
}
|
|
58
|
-
return view.idleTTL >= 1000
|
|
63
|
+
return view.idleTTL >= 1000
|
|
64
|
+
? `${view.idleTTL / 1000} s`
|
|
65
|
+
: `${view.idleTTL} ms`;
|
|
59
66
|
};
|
|
60
67
|
const time = (entry: TimelineEntry) => `${(entry.time / 1000).toFixed(3)} s`;
|
|
61
68
|
const verbs: Record<TimelineEntry["tag"], string> = {
|
|
@@ -68,24 +75,43 @@
|
|
|
68
75
|
Updated: "updated",
|
|
69
76
|
};
|
|
70
77
|
const states = $derived(
|
|
71
|
-
Object.entries(model.totals.states).toSorted(([a], [b]) =>
|
|
78
|
+
Object.entries(model.totals.states).toSorted(([a], [b]) =>
|
|
79
|
+
a.localeCompare(b)
|
|
80
|
+
)
|
|
72
81
|
);
|
|
73
82
|
</script>
|
|
74
83
|
|
|
75
84
|
{#snippet link(id: number)}
|
|
76
85
|
{@const view = byId.get(id)}
|
|
77
|
-
<button
|
|
86
|
+
<button
|
|
87
|
+
class="link"
|
|
88
|
+
class:plumbing={view?.plumbing}
|
|
89
|
+
onclick={() => onselect(id)}
|
|
90
|
+
type="button"
|
|
91
|
+
>
|
|
78
92
|
{view?.name ?? `atom #${id}`}
|
|
79
93
|
</button>
|
|
80
94
|
{/snippet}
|
|
81
95
|
|
|
82
96
|
<div class="set">
|
|
83
97
|
<nav aria-label="Sheets" class="index">
|
|
84
|
-
<button
|
|
98
|
+
<button
|
|
99
|
+
class="entry"
|
|
100
|
+
class:current={current === undefined}
|
|
101
|
+
onclick={() => onselect(undefined)}
|
|
102
|
+
type="button"
|
|
103
|
+
>
|
|
85
104
|
<span class="no">00</span> Cover sheet
|
|
86
105
|
</button>
|
|
87
106
|
{#each sheets as view, index (view.id)}
|
|
88
|
-
<button
|
|
107
|
+
<button
|
|
108
|
+
class="entry"
|
|
109
|
+
class:current={current?.id === view.id}
|
|
110
|
+
class:plumbing={view.plumbing}
|
|
111
|
+
class:gone={!view.live}
|
|
112
|
+
onclick={() => onselect(view.id)}
|
|
113
|
+
type="button"
|
|
114
|
+
>
|
|
89
115
|
<span class="no">{pad(index + 1)}</span>
|
|
90
116
|
{view.name}
|
|
91
117
|
</button>
|
|
@@ -99,40 +125,66 @@
|
|
|
99
125
|
<span>COVER · THE REGISTRY</span>
|
|
100
126
|
</header>
|
|
101
127
|
<div class="totals">
|
|
102
|
-
<div class="total"
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
<div class="total"
|
|
106
|
-
|
|
107
|
-
|
|
128
|
+
<div class="total">
|
|
129
|
+
<b>{pad(model.totals.atoms)}</b><span>atoms</span>
|
|
130
|
+
</div>
|
|
131
|
+
<div class="total">
|
|
132
|
+
<b>{pad(model.totals.readers)}</b><span>readers</span>
|
|
133
|
+
</div>
|
|
134
|
+
<div class="total">
|
|
135
|
+
<b>{pad(model.totals.builds)}</b><span>computations</span>
|
|
136
|
+
</div>
|
|
137
|
+
<div class="total">
|
|
138
|
+
<b>{pad(model.totals.updates)}</b><span>updates</span>
|
|
139
|
+
</div>
|
|
140
|
+
<div class="total">
|
|
141
|
+
<b>{pad(model.totals.interruptions)}</b><span>interruptions</span>
|
|
142
|
+
</div>
|
|
143
|
+
<div class="total">
|
|
144
|
+
<b>{pad(model.totals.finalizers)}</b><span>finalizers run</span>
|
|
145
|
+
</div>
|
|
108
146
|
</div>
|
|
109
147
|
<section class="block">
|
|
110
148
|
<h3 class="key">VALUES</h3>
|
|
111
149
|
<p class="states">
|
|
112
150
|
{#each states as [state, count] (state)}
|
|
113
|
-
<span
|
|
151
|
+
<span
|
|
152
|
+
><b>{count}</b> {state === "Value" ? "plain values" : state}</span
|
|
153
|
+
>
|
|
114
154
|
{/each}
|
|
115
155
|
</p>
|
|
116
156
|
<p class="caption">
|
|
117
|
-
{model.totals.plumbing} of the {model.totals.atoms} atoms are plumbing:
|
|
118
|
-
mutation or a store rather than declared by the app.
|
|
119
|
-
|
|
120
|
-
|
|
157
|
+
{model.totals.plumbing} of the {model.totals.atoms} atoms are plumbing:
|
|
158
|
+
made by a runtime, a mutation or a store rather than declared by the app.
|
|
159
|
+
They have no label, and the sheets and graph {showPlumbing
|
|
160
|
+
? "show them, last"
|
|
161
|
+
: "leave them out"}. Counts of computations and updates start when
|
|
162
|
+
the panel does.
|
|
121
163
|
</p>
|
|
122
164
|
</section>
|
|
123
165
|
{:else}
|
|
124
166
|
<header class="strip">
|
|
125
167
|
<span><b>SHEET {pad(number)}</b> OF {pad(sheets.length)}</span>
|
|
126
|
-
<span
|
|
168
|
+
<span
|
|
169
|
+
>{current.live
|
|
170
|
+
? current.plumbing
|
|
171
|
+
? "PLUMBING"
|
|
172
|
+
: "ATOM"
|
|
173
|
+
: "REMOVED"}</span
|
|
174
|
+
>
|
|
127
175
|
</header>
|
|
128
176
|
|
|
129
|
-
<section class="block
|
|
177
|
+
<section class="value block">
|
|
130
178
|
<h3 class="key">
|
|
131
179
|
VALUE{#if current.state._tag !== "Value"}<span
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
180
|
+
class="badge"
|
|
181
|
+
class:failure={current.state._tag === "Failure" &&
|
|
182
|
+
!current.state.waiting}
|
|
183
|
+
class:success={current.state._tag === "Success" &&
|
|
184
|
+
!current.state.waiting}
|
|
185
|
+
class:waiting={current.state.waiting}
|
|
186
|
+
>{stateText(current.state)}</span
|
|
187
|
+
>{/if}
|
|
136
188
|
</h3>
|
|
137
189
|
{#if current.hasValue}
|
|
138
190
|
<pre>{detail(current.value)}</pre>
|
|
@@ -148,7 +200,9 @@
|
|
|
148
200
|
<p class="caption">Nothing: it is a source.</p>
|
|
149
201
|
{:else}
|
|
150
202
|
<ul>
|
|
151
|
-
{#each current.parents as id (id)}<li>
|
|
203
|
+
{#each current.parents as id (id)}<li>
|
|
204
|
+
{@render link(id)}
|
|
205
|
+
</li>{/each}
|
|
152
206
|
</ul>
|
|
153
207
|
{/if}
|
|
154
208
|
</section>
|
|
@@ -158,14 +212,19 @@
|
|
|
158
212
|
<p class="caption">No atom reads it.</p>
|
|
159
213
|
{:else}
|
|
160
214
|
<ul>
|
|
161
|
-
{#each current.children as id (id)}<li>
|
|
215
|
+
{#each current.children as id (id)}<li>
|
|
216
|
+
{@render link(id)}
|
|
217
|
+
</li>{/each}
|
|
162
218
|
</ul>
|
|
163
219
|
{/if}
|
|
164
220
|
</section>
|
|
165
221
|
</div>
|
|
166
222
|
|
|
167
223
|
<section class="block">
|
|
168
|
-
<h3 class="key">
|
|
224
|
+
<h3 class="key">
|
|
225
|
+
LATELY · {current.builds} COMPUTATIONS, {current.updates} UPDATES, {current.interruptions}
|
|
226
|
+
INTERRUPTIONS
|
|
227
|
+
</h3>
|
|
169
228
|
{#if recent.length === 0}
|
|
170
229
|
<p class="caption">Nothing since the panel started.</p>
|
|
171
230
|
{:else}
|
|
@@ -174,7 +233,10 @@
|
|
|
174
233
|
<li class:alert={entry.tag === "Interrupted"}>
|
|
175
234
|
<span class="when">{time(entry)}</span>
|
|
176
235
|
<span class="what">{verbs[entry.tag]}</span>
|
|
177
|
-
<span class="detail"
|
|
236
|
+
<span class="detail"
|
|
237
|
+
>{entry.detail}{#if entry.source}
|
|
238
|
+
({entry.source}){/if}</span
|
|
239
|
+
>
|
|
178
240
|
</li>
|
|
179
241
|
{/each}
|
|
180
242
|
</ol>
|
|
@@ -189,7 +251,12 @@
|
|
|
189
251
|
{@const place = current.identity.place}
|
|
190
252
|
<!-- Only the dev server can open a file in the editor. -->
|
|
191
253
|
{#if DEV}
|
|
192
|
-
<button
|
|
254
|
+
<button
|
|
255
|
+
class="link"
|
|
256
|
+
onclick={() => void openInEditor(place)}
|
|
257
|
+
title="Open {place.file}:{place.line} in the editor"
|
|
258
|
+
type="button">{shortPlace(place)}</button
|
|
259
|
+
>
|
|
193
260
|
{:else}
|
|
194
261
|
<span title="{place.file}:{place.line}">{shortPlace(place)}</span>
|
|
195
262
|
{/if}
|
|
@@ -197,11 +264,17 @@
|
|
|
197
264
|
—
|
|
198
265
|
{/if}
|
|
199
266
|
</div>
|
|
200
|
-
<div class="cell"
|
|
267
|
+
<div class="cell">
|
|
268
|
+
<span class="key">KEEP-ALIVE</span>{current.keepAlive ? "yes" : "no"}
|
|
269
|
+
</div>
|
|
201
270
|
<div class="cell"><span class="key">IDLE TTL</span>{ttl(current)}</div>
|
|
202
|
-
<div class="cell"
|
|
271
|
+
<div class="cell">
|
|
272
|
+
<span class="key">READERS</span>{current.readers}
|
|
273
|
+
</div>
|
|
203
274
|
{#if current.identity.key && current.identity.key !== current.name}
|
|
204
|
-
<div class="cell wide"
|
|
275
|
+
<div class="cell wide">
|
|
276
|
+
<span class="key">KEY</span>{current.identity.key}
|
|
277
|
+
</div>
|
|
205
278
|
{/if}
|
|
206
279
|
</footer>
|
|
207
280
|
{/if}
|
|
@@ -387,7 +460,10 @@
|
|
|
387
460
|
.title-block {
|
|
388
461
|
border-top: 1px solid var(--line);
|
|
389
462
|
display: grid;
|
|
390
|
-
grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.6fr) repeat(
|
|
463
|
+
grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.6fr) repeat(
|
|
464
|
+
3,
|
|
465
|
+
minmax(0, 1fr)
|
|
466
|
+
);
|
|
391
467
|
margin-top: auto;
|
|
392
468
|
}
|
|
393
469
|
.cell {
|
|
@@ -75,11 +75,12 @@ export const formatShortcut = (shortcut, mac) => [
|
|
|
75
75
|
* Whether a key press is the shortcut, with exactly its modifiers. The code is compared without
|
|
76
76
|
* case: the settings save it in lower case, and a code such as `ArrowUp` doesn't read back as it was.
|
|
77
77
|
*/
|
|
78
|
-
export const matchesShortcut = (event, shortcut) =>
|
|
79
|
-
event.altKey
|
|
80
|
-
|
|
81
|
-
event.
|
|
82
|
-
|
|
78
|
+
export const matchesShortcut = (event, shortcut) => {
|
|
79
|
+
const pressed = [event.altKey, event.ctrlKey, event.metaKey, event.shiftKey];
|
|
80
|
+
const held = [shortcut.alt, shortcut.ctrl, shortcut.meta, shortcut.shift];
|
|
81
|
+
return (event.code.toLowerCase() === shortcut.code.toLowerCase() &&
|
|
82
|
+
pressed.every((down, index) => down === held[index]));
|
|
83
|
+
};
|
|
83
84
|
/**
|
|
84
85
|
* The shortcut a key press makes, when recording a new one: `undefined` for a modifier on its own,
|
|
85
86
|
* and for a key without Ctrl, Alt or Meta (other than a function key), which would catch typing.
|
|
@@ -13,7 +13,13 @@
|
|
|
13
13
|
|
|
14
14
|
const { model, showPlumbing, onselect }: Props = $props();
|
|
15
15
|
|
|
16
|
-
type Kind =
|
|
16
|
+
type Kind =
|
|
17
|
+
| "computed"
|
|
18
|
+
| "updated"
|
|
19
|
+
| "interrupted"
|
|
20
|
+
| "finalized"
|
|
21
|
+
| "readers"
|
|
22
|
+
| "added";
|
|
17
23
|
const kinds: Record<TimelineEntry["tag"], Kind> = {
|
|
18
24
|
Built: "computed",
|
|
19
25
|
Finalized: "finalized",
|
|
@@ -61,35 +67,52 @@
|
|
|
61
67
|
const byId = $derived(new Map(model.atoms.map((view) => [view.id, view])));
|
|
62
68
|
const nameOf = (id: number) => byId.get(id)?.name ?? `atom #${id}`;
|
|
63
69
|
const shownRows = 400;
|
|
70
|
+
/** Whether the timeline lists the entry, given the kinds shown, the atom picked and the search. */
|
|
71
|
+
const shows = (entry: TimelineEntry, query: string) => {
|
|
72
|
+
if (!shownKinds[kinds[entry.tag]]) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
if (
|
|
76
|
+
only !== undefined &&
|
|
77
|
+
entry.atom !== only &&
|
|
78
|
+
!entry.related.includes(only)
|
|
79
|
+
) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
if (!showPlumbing && byId.get(entry.atom)?.plumbing && only === undefined) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return query === "" || nameOf(entry.atom).toLowerCase().includes(query);
|
|
86
|
+
};
|
|
64
87
|
const rows = $derived.by(() => {
|
|
65
88
|
const query = search.trim().toLowerCase();
|
|
66
89
|
const matching: TimelineEntry[] = [];
|
|
67
|
-
for (
|
|
90
|
+
for (
|
|
91
|
+
let index = model.timeline.length - 1;
|
|
92
|
+
index >= 0 && matching.length < shownRows;
|
|
93
|
+
index -= 1
|
|
94
|
+
) {
|
|
68
95
|
const entry = model.timeline[index];
|
|
69
|
-
if (entry
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
if (only !== undefined && entry.atom !== only && !entry.related.includes(only)) {
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
if (!showPlumbing && byId.get(entry.atom)?.plumbing && only === undefined) {
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
if (query !== "" && !nameOf(entry.atom).toLowerCase().includes(query)) {
|
|
79
|
-
continue;
|
|
96
|
+
if (entry !== undefined && shows(entry, query)) {
|
|
97
|
+
matching.push(entry);
|
|
80
98
|
}
|
|
81
|
-
matching.push(entry);
|
|
82
99
|
}
|
|
83
100
|
return matching;
|
|
84
101
|
});
|
|
85
102
|
|
|
86
103
|
const start = $derived(model.timeline[0]?.time ?? 0);
|
|
87
|
-
const time = (entry: TimelineEntry) =>
|
|
104
|
+
const time = (entry: TimelineEntry) =>
|
|
105
|
+
`+${((entry.time - start) / 1000).toFixed(3)}`;
|
|
88
106
|
</script>
|
|
89
107
|
|
|
90
108
|
<div class="timeline">
|
|
91
109
|
<div class="toolbar">
|
|
92
|
-
<input
|
|
110
|
+
<input
|
|
111
|
+
aria-label="Filter by atom name"
|
|
112
|
+
bind:value={search}
|
|
113
|
+
placeholder="atom name"
|
|
114
|
+
type="search"
|
|
115
|
+
/>
|
|
93
116
|
{#each Object.keys(labels) as Kind[] as kind (kind)}
|
|
94
117
|
<label class="kind">
|
|
95
118
|
<input bind:checked={shownKinds[kind]} type="checkbox" />
|
|
@@ -102,31 +125,56 @@
|
|
|
102
125
|
only {nameOf(only)} ✕
|
|
103
126
|
</button>
|
|
104
127
|
{/if}
|
|
105
|
-
<button
|
|
128
|
+
<button
|
|
129
|
+
class="tool"
|
|
130
|
+
aria-pressed={model.paused}
|
|
131
|
+
onclick={() => (model.paused = !model.paused)}
|
|
132
|
+
type="button"
|
|
133
|
+
>
|
|
106
134
|
{model.paused ? "resume" : "pause"}
|
|
107
135
|
</button>
|
|
108
|
-
<button class="tool" onclick={() => model.clearTimeline()} type="button"
|
|
136
|
+
<button class="tool" onclick={() => model.clearTimeline()} type="button"
|
|
137
|
+
>clear</button
|
|
138
|
+
>
|
|
109
139
|
</div>
|
|
110
140
|
|
|
111
141
|
{#if rows.length === 0}
|
|
112
|
-
<p class="empty">
|
|
142
|
+
<p class="empty">
|
|
143
|
+
Nothing yet. Use the page: every computation and update lands here.
|
|
144
|
+
</p>
|
|
113
145
|
{:else}
|
|
114
146
|
<ol class="rows">
|
|
115
147
|
{#each rows as entry (entry.seq)}
|
|
116
|
-
<li
|
|
148
|
+
<li
|
|
149
|
+
class="row {kinds[entry.tag]}"
|
|
150
|
+
class:alert={entry.tag === "Interrupted"}
|
|
151
|
+
>
|
|
117
152
|
<span class="when">{time(entry)}</span>
|
|
118
153
|
<span class="what">{verbs[entry.tag]}</span>
|
|
119
|
-
<button
|
|
154
|
+
<button
|
|
155
|
+
class="atom"
|
|
156
|
+
class:plumbing={byId.get(entry.atom)?.plumbing}
|
|
157
|
+
onclick={() => pick(entry.atom)}
|
|
158
|
+
ondblclick={() => onselect(entry.atom)}
|
|
159
|
+
title="Click: only this atom's rows. Double-click: its sheet."
|
|
160
|
+
type="button"
|
|
161
|
+
>
|
|
120
162
|
{nameOf(entry.atom)}
|
|
121
163
|
</button>
|
|
122
164
|
<span class="detail">
|
|
123
165
|
{#if entry.tag === "Built" && entry.related.length > 0}
|
|
124
166
|
because
|
|
125
167
|
{#each entry.related as id, index (id)}{#if index > 0},{/if}
|
|
126
|
-
<button
|
|
168
|
+
<button
|
|
169
|
+
class="atom inline"
|
|
170
|
+
onclick={() => pick(id)}
|
|
171
|
+
type="button">{nameOf(id)}</button
|
|
172
|
+
>{/each}
|
|
127
173
|
changed
|
|
128
174
|
{:else if entry.tag === "Built"}
|
|
129
|
-
{entry.detail === "first read"
|
|
175
|
+
{entry.detail === "first read"
|
|
176
|
+
? "first read"
|
|
177
|
+
: `because it was ${entry.detail}`}
|
|
130
178
|
{:else}
|
|
131
179
|
{entry.detail}
|
|
132
180
|
{/if}
|