effect-atom-svelte-devtools 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +86 -2
- package/dist/atom-devtools.svelte +585 -0
- package/dist/atom-devtools.svelte.d.ts +28 -0
- package/dist/graph/atom-graph.svelte +244 -0
- package/dist/graph/atom-graph.svelte.d.ts +38 -0
- package/dist/graph/frame-graph.svelte +408 -0
- package/dist/graph/frame-graph.svelte.d.ts +52 -0
- package/dist/graph/index.d.ts +5 -0
- package/dist/graph/index.js +7 -0
- package/dist/graph/layout.d.ts +65 -0
- package/dist/graph/layout.js +531 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +13 -0
- package/dist/internal/format.d.ts +20 -0
- package/dist/internal/format.js +138 -0
- package/dist/internal/graph-view.svelte +127 -0
- package/dist/internal/graph-view.svelte.d.ts +10 -0
- package/dist/internal/label.d.ts +35 -0
- package/dist/internal/label.js +139 -0
- package/dist/internal/model.svelte.d.ts +75 -0
- package/dist/internal/model.svelte.js +286 -0
- package/dist/internal/names.d.ts +29 -0
- package/dist/internal/names.js +55 -0
- package/dist/internal/sheets-view.svelte +446 -0
- package/dist/internal/sheets-view.svelte.d.ts +11 -0
- package/dist/internal/timeline-view.svelte +291 -0
- package/dist/internal/timeline-view.svelte.d.ts +9 -0
- package/dist/internal/transform.d.ts +17 -0
- package/dist/internal/transform.js +401 -0
- package/dist/vite.d.ts +52 -0
- package/dist/vite.js +97 -0
- package/package.json +78 -4
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Every computation, update, interruption and finalizer, newest first, with why each computation
|
|
3
|
+
ran: to answer "why did this refetch?" and "why was this interrupted?".
|
|
4
|
+
-->
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import type { Model, TimelineEntry } from "./model.svelte.js";
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
readonly model: Model;
|
|
10
|
+
readonly showPlumbing: boolean;
|
|
11
|
+
readonly onselect: (id: number) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const { model, showPlumbing, onselect }: Props = $props();
|
|
15
|
+
|
|
16
|
+
type Kind = "computed" | "updated" | "interrupted" | "finalized" | "readers" | "added";
|
|
17
|
+
const kinds: Record<TimelineEntry["tag"], Kind> = {
|
|
18
|
+
Built: "computed",
|
|
19
|
+
Finalized: "finalized",
|
|
20
|
+
Interrupted: "interrupted",
|
|
21
|
+
NodeAdded: "added",
|
|
22
|
+
NodeRemoved: "added",
|
|
23
|
+
ReadersChanged: "readers",
|
|
24
|
+
Updated: "updated",
|
|
25
|
+
};
|
|
26
|
+
const labels: Record<Kind, string> = {
|
|
27
|
+
added: "added, removed",
|
|
28
|
+
computed: "computed",
|
|
29
|
+
finalized: "finalized",
|
|
30
|
+
interrupted: "interrupted",
|
|
31
|
+
readers: "readers",
|
|
32
|
+
updated: "updated",
|
|
33
|
+
};
|
|
34
|
+
const verbs: Record<TimelineEntry["tag"], string> = {
|
|
35
|
+
Built: "computed",
|
|
36
|
+
Finalized: "finalized",
|
|
37
|
+
Interrupted: "interrupted",
|
|
38
|
+
NodeAdded: "added",
|
|
39
|
+
NodeRemoved: "removed",
|
|
40
|
+
ReadersChanged: "readers",
|
|
41
|
+
Updated: "updated",
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
let shownKinds = $state<Record<Kind, boolean>>({
|
|
45
|
+
added: true,
|
|
46
|
+
computed: true,
|
|
47
|
+
finalized: true,
|
|
48
|
+
interrupted: true,
|
|
49
|
+
readers: false,
|
|
50
|
+
updated: true,
|
|
51
|
+
});
|
|
52
|
+
let search = $state("");
|
|
53
|
+
// An atom picked from the list: its rows only.
|
|
54
|
+
let only = $state<number>();
|
|
55
|
+
|
|
56
|
+
const byId = $derived(new Map(model.atoms.map((view) => [view.id, view])));
|
|
57
|
+
const nameOf = (id: number) => byId.get(id)?.name ?? `atom #${id}`;
|
|
58
|
+
const shownRows = 400;
|
|
59
|
+
const rows = $derived.by(() => {
|
|
60
|
+
const query = search.trim().toLowerCase();
|
|
61
|
+
const matching: TimelineEntry[] = [];
|
|
62
|
+
for (let index = model.timeline.length - 1; index >= 0 && matching.length < shownRows; index -= 1) {
|
|
63
|
+
const entry = model.timeline[index];
|
|
64
|
+
if (entry === undefined || !shownKinds[kinds[entry.tag]]) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (only !== undefined && entry.atom !== only && !entry.related.includes(only)) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (!showPlumbing && byId.get(entry.atom)?.plumbing && only === undefined) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (query !== "" && !nameOf(entry.atom).toLowerCase().includes(query)) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
matching.push(entry);
|
|
77
|
+
}
|
|
78
|
+
return matching;
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const start = $derived(model.timeline[0]?.time ?? 0);
|
|
82
|
+
const time = (entry: TimelineEntry) => `+${((entry.time - start) / 1000).toFixed(3)}`;
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<div class="timeline">
|
|
86
|
+
<div class="toolbar">
|
|
87
|
+
<input aria-label="Filter by atom name" bind:value={search} placeholder="atom name" type="search" />
|
|
88
|
+
{#each Object.keys(labels) as Kind[] as kind (kind)}
|
|
89
|
+
<label class="kind">
|
|
90
|
+
<input bind:checked={shownKinds[kind]} type="checkbox" />
|
|
91
|
+
{labels[kind]}
|
|
92
|
+
</label>
|
|
93
|
+
{/each}
|
|
94
|
+
<span class="spacer"></span>
|
|
95
|
+
{#if only !== undefined}
|
|
96
|
+
<button class="tool" onclick={() => (only = undefined)} type="button">
|
|
97
|
+
only {nameOf(only)} ✕
|
|
98
|
+
</button>
|
|
99
|
+
{/if}
|
|
100
|
+
<button class="tool" aria-pressed={model.paused} onclick={() => (model.paused = !model.paused)} type="button">
|
|
101
|
+
{model.paused ? "resume" : "pause"}
|
|
102
|
+
</button>
|
|
103
|
+
<button class="tool" onclick={() => model.clearTimeline()} type="button">clear</button>
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
{#if rows.length === 0}
|
|
107
|
+
<p class="empty">Nothing yet. Use the page: every computation and update lands here.</p>
|
|
108
|
+
{:else}
|
|
109
|
+
<ol class="rows">
|
|
110
|
+
{#each rows as entry (entry.seq)}
|
|
111
|
+
<li class="row {kinds[entry.tag]}" class:alert={entry.tag === "Interrupted"}>
|
|
112
|
+
<span class="when">{time(entry)}</span>
|
|
113
|
+
<span class="what">{verbs[entry.tag]}</span>
|
|
114
|
+
<button class="atom" class:plumbing={byId.get(entry.atom)?.plumbing} onclick={() => (only = entry.atom)} ondblclick={() => onselect(entry.atom)} title="Click: only this atom's rows. Double-click: its sheet." type="button">
|
|
115
|
+
{nameOf(entry.atom)}
|
|
116
|
+
</button>
|
|
117
|
+
<span class="detail">
|
|
118
|
+
{#if entry.tag === "Built" && entry.related.length > 0}
|
|
119
|
+
because
|
|
120
|
+
{#each entry.related as id, index (id)}{#if index > 0},{/if}
|
|
121
|
+
<button class="atom inline" onclick={() => (only = id)} type="button">{nameOf(id)}</button>{/each}
|
|
122
|
+
changed
|
|
123
|
+
{:else if entry.tag === "Built"}
|
|
124
|
+
{entry.detail === "first read" ? "first read" : `because it was ${entry.detail}`}
|
|
125
|
+
{:else}
|
|
126
|
+
{entry.detail}
|
|
127
|
+
{/if}
|
|
128
|
+
{#if entry.source}<span class="source">{entry.source}</span>{/if}
|
|
129
|
+
</span>
|
|
130
|
+
</li>
|
|
131
|
+
{/each}
|
|
132
|
+
</ol>
|
|
133
|
+
{/if}
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
<style>
|
|
137
|
+
.timeline {
|
|
138
|
+
display: flex;
|
|
139
|
+
flex-direction: column;
|
|
140
|
+
height: 100%;
|
|
141
|
+
min-height: 0;
|
|
142
|
+
}
|
|
143
|
+
.toolbar {
|
|
144
|
+
align-items: center;
|
|
145
|
+
border-bottom: 1px solid var(--line);
|
|
146
|
+
display: flex;
|
|
147
|
+
flex-wrap: wrap;
|
|
148
|
+
font-family: var(--mono);
|
|
149
|
+
font-size: 0.68rem;
|
|
150
|
+
gap: 0.4rem 0.8rem;
|
|
151
|
+
padding: 0.45rem 0.75rem;
|
|
152
|
+
}
|
|
153
|
+
.toolbar input[type="search"] {
|
|
154
|
+
background: var(--paper);
|
|
155
|
+
border: 1px solid var(--line);
|
|
156
|
+
border-radius: 4px;
|
|
157
|
+
color: var(--ink);
|
|
158
|
+
font: inherit;
|
|
159
|
+
padding: 0.25rem 0.5rem;
|
|
160
|
+
width: 10rem;
|
|
161
|
+
}
|
|
162
|
+
.toolbar input[type="search"]:focus {
|
|
163
|
+
border-color: var(--accent);
|
|
164
|
+
outline: none;
|
|
165
|
+
}
|
|
166
|
+
.kind {
|
|
167
|
+
align-items: center;
|
|
168
|
+
border: 1px solid var(--line);
|
|
169
|
+
border-radius: 999px;
|
|
170
|
+
color: var(--muted);
|
|
171
|
+
cursor: pointer;
|
|
172
|
+
display: inline-flex;
|
|
173
|
+
gap: 0.35rem;
|
|
174
|
+
letter-spacing: 0.04em;
|
|
175
|
+
padding: 0.1rem 0.55rem 0.1rem 0.4rem;
|
|
176
|
+
}
|
|
177
|
+
.kind:has(input:checked) {
|
|
178
|
+
color: var(--ink);
|
|
179
|
+
}
|
|
180
|
+
.kind input {
|
|
181
|
+
accent-color: var(--accent);
|
|
182
|
+
margin: 0;
|
|
183
|
+
}
|
|
184
|
+
.spacer {
|
|
185
|
+
flex: 1;
|
|
186
|
+
}
|
|
187
|
+
.tool {
|
|
188
|
+
background: none;
|
|
189
|
+
border: 1px solid var(--line);
|
|
190
|
+
border-radius: 4px;
|
|
191
|
+
color: var(--ink);
|
|
192
|
+
cursor: pointer;
|
|
193
|
+
font: inherit;
|
|
194
|
+
letter-spacing: 0.04em;
|
|
195
|
+
padding: 0.2rem 0.6rem;
|
|
196
|
+
}
|
|
197
|
+
.tool:hover {
|
|
198
|
+
border-color: var(--accent);
|
|
199
|
+
}
|
|
200
|
+
.tool[aria-pressed="true"] {
|
|
201
|
+
background: color-mix(in oklab, var(--accent) 12%, transparent);
|
|
202
|
+
border-color: var(--accent);
|
|
203
|
+
}
|
|
204
|
+
.empty {
|
|
205
|
+
color: var(--muted);
|
|
206
|
+
font-family: var(--serif);
|
|
207
|
+
font-style: italic;
|
|
208
|
+
margin: 0;
|
|
209
|
+
padding: 2rem;
|
|
210
|
+
}
|
|
211
|
+
.rows {
|
|
212
|
+
flex: 1;
|
|
213
|
+
list-style: none;
|
|
214
|
+
margin: 0;
|
|
215
|
+
min-height: 0;
|
|
216
|
+
overflow: auto;
|
|
217
|
+
padding: 0.25rem 0;
|
|
218
|
+
}
|
|
219
|
+
.row {
|
|
220
|
+
align-items: baseline;
|
|
221
|
+
border-left: 2px solid transparent;
|
|
222
|
+
display: grid;
|
|
223
|
+
font-size: 0.74rem;
|
|
224
|
+
gap: 0.75rem;
|
|
225
|
+
grid-template-columns: 4.5rem 6rem minmax(6rem, 13rem) minmax(0, 1fr);
|
|
226
|
+
padding: 0.12rem 0.75rem;
|
|
227
|
+
}
|
|
228
|
+
.row:hover {
|
|
229
|
+
background: var(--faint);
|
|
230
|
+
}
|
|
231
|
+
.row.computed {
|
|
232
|
+
border-left-color: var(--subtle);
|
|
233
|
+
}
|
|
234
|
+
.row.updated {
|
|
235
|
+
border-left-color: var(--pulse);
|
|
236
|
+
}
|
|
237
|
+
.row.alert {
|
|
238
|
+
border-left-color: var(--alert);
|
|
239
|
+
}
|
|
240
|
+
.row.alert .what,
|
|
241
|
+
.row.alert .detail {
|
|
242
|
+
color: var(--alert);
|
|
243
|
+
}
|
|
244
|
+
.when {
|
|
245
|
+
color: var(--muted);
|
|
246
|
+
font-family: var(--mono);
|
|
247
|
+
font-variant-numeric: tabular-nums;
|
|
248
|
+
}
|
|
249
|
+
.what {
|
|
250
|
+
color: var(--muted);
|
|
251
|
+
font-family: var(--mono);
|
|
252
|
+
}
|
|
253
|
+
.atom {
|
|
254
|
+
background: none;
|
|
255
|
+
border: 0;
|
|
256
|
+
color: var(--ink);
|
|
257
|
+
cursor: pointer;
|
|
258
|
+
font: inherit;
|
|
259
|
+
font-family: var(--mono);
|
|
260
|
+
overflow: hidden;
|
|
261
|
+
padding: 0;
|
|
262
|
+
text-align: left;
|
|
263
|
+
text-overflow: ellipsis;
|
|
264
|
+
white-space: nowrap;
|
|
265
|
+
}
|
|
266
|
+
.atom.plumbing {
|
|
267
|
+
color: var(--muted);
|
|
268
|
+
}
|
|
269
|
+
.atom.inline {
|
|
270
|
+
font-style: normal;
|
|
271
|
+
text-decoration: underline dotted var(--muted);
|
|
272
|
+
text-underline-offset: 3px;
|
|
273
|
+
}
|
|
274
|
+
.detail {
|
|
275
|
+
font-family: var(--serif);
|
|
276
|
+
font-style: italic;
|
|
277
|
+
overflow: hidden;
|
|
278
|
+
text-overflow: ellipsis;
|
|
279
|
+
white-space: nowrap;
|
|
280
|
+
}
|
|
281
|
+
.source {
|
|
282
|
+
border: 1px solid var(--line);
|
|
283
|
+
border-radius: 4px;
|
|
284
|
+
color: var(--muted);
|
|
285
|
+
font-family: var(--mono);
|
|
286
|
+
font-size: 0.6rem;
|
|
287
|
+
font-style: normal;
|
|
288
|
+
margin-left: 0.5rem;
|
|
289
|
+
padding: 0 0.3rem;
|
|
290
|
+
}
|
|
291
|
+
</style>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Model } from "./model.svelte.ts";
|
|
2
|
+
interface Props {
|
|
3
|
+
readonly model: Model;
|
|
4
|
+
readonly showPlumbing: boolean;
|
|
5
|
+
readonly onselect: (id: number) => void;
|
|
6
|
+
}
|
|
7
|
+
declare const TimelineView: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type TimelineView = ReturnType<typeof TimelineView>;
|
|
9
|
+
export default TimelineView;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import MagicString from "magic-string";
|
|
2
|
+
/** The id the transformed code imports `label` from; the plugin resolves it to ./label.ts. */
|
|
3
|
+
export declare const labelModule = "virtual:effect-atom-svelte-devtools/label";
|
|
4
|
+
/** A component's name from its file, as Svelte names it: `counter-list.svelte` is `CounterList`. */
|
|
5
|
+
export declare const componentName: (file: string) => string;
|
|
6
|
+
/**
|
|
7
|
+
* Labels the atoms declared in a module or a component's scripts, and names the component at the
|
|
8
|
+
* top of its instance script, for the inspector scopes its hooks report to. Returns the new code and
|
|
9
|
+
* its source map, or `undefined` when there is nothing to do or the code doesn't parse (a component
|
|
10
|
+
* whose script needs a preprocessor, say), which leaves the file as it is.
|
|
11
|
+
*/
|
|
12
|
+
export declare const labelAtoms: (code: string, file: string, root: string, { keep }?: {
|
|
13
|
+
readonly keep?: boolean;
|
|
14
|
+
}) => {
|
|
15
|
+
code: string;
|
|
16
|
+
map: ReturnType<MagicString["generateMap"]>;
|
|
17
|
+
} | undefined;
|