effect-atom-svelte-devtools 0.0.0-stage → 0.2.1
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 +122 -2
- package/dist/atom-devtools.svelte +753 -0
- package/dist/atom-devtools.svelte.d.ts +39 -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 +14 -0
- package/dist/index.js +14 -0
- package/dist/internal/format.d.ts +27 -0
- package/dist/internal/format.js +183 -0
- package/dist/internal/graph-view.svelte +134 -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/settings-view.svelte +198 -0
- package/dist/internal/settings-view.svelte.d.ts +16 -0
- package/dist/internal/sheets-view.svelte +453 -0
- package/dist/internal/sheets-view.svelte.d.ts +11 -0
- package/dist/internal/shortcut.d.ts +22 -0
- package/dist/internal/shortcut.js +91 -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,753 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
A panel docked along the bottom of the window that shows the atom registry live: its dependency
|
|
4
|
+
graph, a sheet per atom and a timeline of everything it does. Development only unless you set
|
|
5
|
+
`production`: in a production build without it, or on the server, it renders nothing.
|
|
6
|
+
|
|
7
|
+
It's drawn like the effect-atom-svelte docs: ruled in hairlines, with mono labels, numbered views
|
|
8
|
+
and an amber accent, in the page's own colours where it has them (--background, --foreground,
|
|
9
|
+
--border, --brand and the rest) and the docs' zinc and amber where it doesn't. Drag its top line
|
|
10
|
+
to make it taller or shorter; the page gets room below it for as long as it's open.
|
|
11
|
+
|
|
12
|
+
It follows the registry of the nearest `RegistryProvider`, or the one given as `registry`. When
|
|
13
|
+
the app has several, a picker in the panel switches between them.
|
|
14
|
+
|
|
15
|
+
Render it only in development, behind Vite's `DEV` flag, so a build leaves it out: the README
|
|
16
|
+
shows how. To show it in production too, as the effect-atom-svelte docs do, set `production`.
|
|
17
|
+
-->
|
|
18
|
+
<script lang="ts">
|
|
19
|
+
import { BROWSER, DEV } from "esm-env";
|
|
20
|
+
import type { AtomRegistry } from "effect/reactivity";
|
|
21
|
+
import { getRegistry } from "effect-atom-svelte";
|
|
22
|
+
import { inspect, watchRegistries } from "effect-atom-svelte/inspector";
|
|
23
|
+
import { onMount, tick } from "svelte";
|
|
24
|
+
|
|
25
|
+
import GraphView from "./internal/graph-view.svelte";
|
|
26
|
+
import { Model } from "./internal/model.svelte.js";
|
|
27
|
+
import SettingsView from "./internal/settings-view.svelte";
|
|
28
|
+
import type { Corner } from "./internal/settings-view.svelte";
|
|
29
|
+
import { defaultShortcut, formatShortcut, matchesShortcut, parseShortcut } from "./internal/shortcut.js";
|
|
30
|
+
import SheetsView from "./internal/sheets-view.svelte";
|
|
31
|
+
import TimelineView from "./internal/timeline-view.svelte";
|
|
32
|
+
|
|
33
|
+
interface Props {
|
|
34
|
+
/** The registry to show. Defaults to the nearest `RegistryProvider`'s. */
|
|
35
|
+
readonly registry?: AtomRegistry.AtomRegistry | undefined;
|
|
36
|
+
/** Whether the panel starts open. Defaults to how it was left. */
|
|
37
|
+
readonly open?: boolean | undefined;
|
|
38
|
+
/** Light paper, a dark blueprint, or the page's own (`auto`: a `dark` class on `<html>`, or the system's). */
|
|
39
|
+
readonly theme?: "auto" | "light" | "dark" | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Shows the panel in production builds too, for a site that lets its visitors watch its atoms.
|
|
42
|
+
* Without it the panel renders nothing outside development. In production it follows the
|
|
43
|
+
* nearest provider's registry, or `registry`, with no picker: only development lists the rest.
|
|
44
|
+
*/
|
|
45
|
+
readonly production?: boolean | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* The keyboard shortcut that opens and closes the panel, as "alt+shift+a" (the default) or
|
|
48
|
+
* "ctrl+shift+f2". Whoever uses the panel can change it in its settings.
|
|
49
|
+
*/
|
|
50
|
+
readonly shortcut?: string | undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const {
|
|
54
|
+
registry,
|
|
55
|
+
open: startOpen,
|
|
56
|
+
production = false,
|
|
57
|
+
shortcut: appShortcut = defaultShortcut,
|
|
58
|
+
theme = "auto",
|
|
59
|
+
}: Props = $props();
|
|
60
|
+
|
|
61
|
+
type Tab = "graph" | "sheets" | "timeline" | "settings";
|
|
62
|
+
interface Saved {
|
|
63
|
+
readonly open: boolean;
|
|
64
|
+
readonly tab: Tab;
|
|
65
|
+
readonly plumbing: boolean;
|
|
66
|
+
readonly expanded: boolean;
|
|
67
|
+
readonly height: number;
|
|
68
|
+
readonly shortcut: string;
|
|
69
|
+
readonly corner: Corner;
|
|
70
|
+
readonly opacity: number;
|
|
71
|
+
readonly scale: number;
|
|
72
|
+
}
|
|
73
|
+
const storageKey = "effect-atom-svelte-devtools";
|
|
74
|
+
const load = (): Partial<Saved> => {
|
|
75
|
+
try {
|
|
76
|
+
return JSON.parse(localStorage.getItem(storageKey) ?? "{}") as Partial<Saved>;
|
|
77
|
+
} catch {
|
|
78
|
+
return {};
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// svelte-ignore state_referenced_locally
|
|
83
|
+
const enabled = BROWSER && (DEV || production);
|
|
84
|
+
// The registry in context, read while the component sets up, as context must be.
|
|
85
|
+
// svelte-ignore state_referenced_locally
|
|
86
|
+
const nearest = enabled ? (registry ?? getRegistry()) : undefined;
|
|
87
|
+
|
|
88
|
+
let mounted = $state(false);
|
|
89
|
+
let open = $state(false);
|
|
90
|
+
let tab = $state<Tab>("graph");
|
|
91
|
+
let showPlumbing = $state(false);
|
|
92
|
+
let expanded = $state(false);
|
|
93
|
+
// The dock's height, in pixels, when not enlarged; dragging its top line changes it.
|
|
94
|
+
let height = $state(320);
|
|
95
|
+
// svelte-ignore state_referenced_locally
|
|
96
|
+
let shortcut = $state(appShortcut);
|
|
97
|
+
let corner = $state<Corner>("bottom-right");
|
|
98
|
+
// The launcher's opacity while nothing points at it, and its size.
|
|
99
|
+
let opacity = $state(1);
|
|
100
|
+
let scale = $state(1);
|
|
101
|
+
let innerHeight = $state(800);
|
|
102
|
+
let innerWidth = $state(1200);
|
|
103
|
+
let selected = $state<number>();
|
|
104
|
+
let dark = $state(false);
|
|
105
|
+
let registries = $state.raw<readonly AtomRegistry.AtomRegistry[]>([]);
|
|
106
|
+
let chosen = $state.raw<AtomRegistry.AtomRegistry | undefined>(nearest);
|
|
107
|
+
let model = $state.raw<Model>();
|
|
108
|
+
let dock = $state<HTMLElement>();
|
|
109
|
+
let launcher = $state<HTMLElement>();
|
|
110
|
+
// Opened from the launcher, the dock takes focus; opened as it was left, on load, it doesn't.
|
|
111
|
+
let focusOnOpen = false;
|
|
112
|
+
|
|
113
|
+
onMount(() => {
|
|
114
|
+
if (!enabled) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const saved = load();
|
|
118
|
+
open = startOpen ?? saved.open ?? false;
|
|
119
|
+
tab = saved.tab ?? "graph";
|
|
120
|
+
showPlumbing = saved.plumbing ?? false;
|
|
121
|
+
expanded = saved.expanded ?? false;
|
|
122
|
+
height = saved.height ?? 320;
|
|
123
|
+
shortcut = saved.shortcut ?? appShortcut;
|
|
124
|
+
corner = saved.corner ?? "bottom-right";
|
|
125
|
+
opacity = saved.opacity ?? 1;
|
|
126
|
+
scale = saved.scale ?? 1;
|
|
127
|
+
mounted = true;
|
|
128
|
+
|
|
129
|
+
const stopWatching = watchRegistries((list) => {
|
|
130
|
+
// A registry given as a prop stays in the picker, even one no provider holds.
|
|
131
|
+
registries = registry !== undefined && !list.includes(registry) ? [registry, ...list] : list;
|
|
132
|
+
if (chosen === undefined || !registries.includes(chosen)) {
|
|
133
|
+
chosen = nearest !== undefined && registries.includes(nearest) ? nearest : (registries[0] ?? nearest);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// The page's theme: a `dark` or `light` class on <html>, or the system's.
|
|
138
|
+
const root = document.documentElement;
|
|
139
|
+
const media = matchMedia("(prefers-color-scheme: dark)");
|
|
140
|
+
const readTheme = () => {
|
|
141
|
+
dark =
|
|
142
|
+
theme === "dark" ||
|
|
143
|
+
(theme === "auto" &&
|
|
144
|
+
(root.classList.contains("dark") ||
|
|
145
|
+
(!root.classList.contains("light") && media.matches)));
|
|
146
|
+
};
|
|
147
|
+
readTheme();
|
|
148
|
+
const observer = new MutationObserver(readTheme);
|
|
149
|
+
observer.observe(root, { attributeFilter: ["class"], attributes: true });
|
|
150
|
+
media.addEventListener("change", readTheme);
|
|
151
|
+
return () => {
|
|
152
|
+
stopWatching();
|
|
153
|
+
observer.disconnect();
|
|
154
|
+
media.removeEventListener("change", readTheme);
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// One model per registry shown, following it from the moment it is chosen, open or not, so the
|
|
159
|
+
// timeline has the page's history when the panel opens.
|
|
160
|
+
$effect(() => {
|
|
161
|
+
if (!enabled || chosen === undefined) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const next = new Model(inspect(chosen));
|
|
165
|
+
model = next;
|
|
166
|
+
selected = undefined;
|
|
167
|
+
return next.start();
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
$effect(() => {
|
|
171
|
+
if (!enabled || !mounted) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const saved: Saved = {
|
|
175
|
+
corner,
|
|
176
|
+
expanded,
|
|
177
|
+
height,
|
|
178
|
+
opacity,
|
|
179
|
+
open,
|
|
180
|
+
plumbing: showPlumbing,
|
|
181
|
+
scale,
|
|
182
|
+
shortcut,
|
|
183
|
+
tab,
|
|
184
|
+
};
|
|
185
|
+
try {
|
|
186
|
+
localStorage.setItem(storageKey, JSON.stringify(saved));
|
|
187
|
+
} catch {
|
|
188
|
+
// Storage may be full or turned off; the panel then starts as it starts.
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// How tall the dock is drawn: enlarged, it takes most of the window; otherwise what was dragged,
|
|
193
|
+
// kept between a usable minimum and most of the window.
|
|
194
|
+
const shown = $derived(
|
|
195
|
+
expanded ? Math.round(innerHeight * 0.85) : Math.min(Math.max(height, 160), innerHeight * 0.85)
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
// While open, the page gets room below its end, so the dock never hides the last of it.
|
|
199
|
+
$effect(() => {
|
|
200
|
+
if (!enabled || !open || !mounted) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const { body } = document;
|
|
204
|
+
const before = body.style.paddingBottom;
|
|
205
|
+
body.style.paddingBottom = `${shown}px`;
|
|
206
|
+
return () => {
|
|
207
|
+
body.style.paddingBottom = before;
|
|
208
|
+
};
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
/** Drags the dock's top line: the dock follows the pointer until it's let go. */
|
|
212
|
+
const resize = (event: PointerEvent) => {
|
|
213
|
+
event.preventDefault();
|
|
214
|
+
const handle = event.currentTarget as HTMLElement;
|
|
215
|
+
handle.setPointerCapture(event.pointerId);
|
|
216
|
+
const start = event.clientY;
|
|
217
|
+
const from = shown;
|
|
218
|
+
expanded = false;
|
|
219
|
+
const move = (next: PointerEvent) => {
|
|
220
|
+
height = Math.round(from + start - next.clientY);
|
|
221
|
+
};
|
|
222
|
+
const stop = () => {
|
|
223
|
+
handle.removeEventListener("pointermove", move);
|
|
224
|
+
handle.removeEventListener("pointerup", stop);
|
|
225
|
+
handle.removeEventListener("pointercancel", stop);
|
|
226
|
+
};
|
|
227
|
+
handle.addEventListener("pointermove", move);
|
|
228
|
+
handle.addEventListener("pointerup", stop);
|
|
229
|
+
handle.addEventListener("pointercancel", stop);
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
$effect(() => {
|
|
233
|
+
if (dock !== undefined && focusOnOpen) {
|
|
234
|
+
focusOnOpen = false;
|
|
235
|
+
dock.focus();
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
const openPanel = () => {
|
|
240
|
+
focusOnOpen = true;
|
|
241
|
+
open = true;
|
|
242
|
+
};
|
|
243
|
+
/** Closes the dock; focus inside it goes back to the launcher, rather than to the page's start. */
|
|
244
|
+
const closePanel = async () => {
|
|
245
|
+
const inside = dock?.contains(document.activeElement) ?? false;
|
|
246
|
+
open = false;
|
|
247
|
+
if (inside) {
|
|
248
|
+
await tick();
|
|
249
|
+
launcher?.focus();
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
/** The dock's top line from the keyboard: arrows make it taller or shorter, Home resets it. */
|
|
254
|
+
const resizeByKey = (event: KeyboardEvent) => {
|
|
255
|
+
const step = event.shiftKey ? 96 : 24;
|
|
256
|
+
const by = { ArrowDown: -step, ArrowUp: step }[event.key];
|
|
257
|
+
if (by !== undefined) {
|
|
258
|
+
event.preventDefault();
|
|
259
|
+
expanded = false;
|
|
260
|
+
height = Math.round(shown + by);
|
|
261
|
+
} else if (event.key === "Home") {
|
|
262
|
+
event.preventDefault();
|
|
263
|
+
expanded = false;
|
|
264
|
+
height = 320;
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
const mac = BROWSER && /Mac|iPhone|iPad/u.test(navigator.platform);
|
|
269
|
+
const shortcutLabel = $derived.by(() => {
|
|
270
|
+
const parsed = parseShortcut(shortcut);
|
|
271
|
+
return parsed === undefined ? "no shortcut" : formatShortcut(parsed, mac);
|
|
272
|
+
});
|
|
273
|
+
// As aria-keyshortcuts writes it: "Alt+Shift+A".
|
|
274
|
+
const keyShortcuts = $derived.by(() => {
|
|
275
|
+
const parsed = parseShortcut(shortcut);
|
|
276
|
+
return parsed === undefined ? undefined : formatShortcut(parsed, false).replaceAll(" ", "+").replace("Ctrl", "Control");
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
/** The shortcut, from anywhere on the page: opens the panel, or closes it. */
|
|
280
|
+
const onShortcut = (event: KeyboardEvent) => {
|
|
281
|
+
const parsed = parseShortcut(shortcut);
|
|
282
|
+
if (!enabled || !mounted || parsed === undefined || !matchesShortcut(event, parsed)) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
event.preventDefault();
|
|
286
|
+
if (open) {
|
|
287
|
+
void closePanel();
|
|
288
|
+
} else {
|
|
289
|
+
openPanel();
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
// Dragging the launcher: it follows the pointer, then settles in the corner nearest where it was
|
|
294
|
+
// let go. A press that barely moves is a click.
|
|
295
|
+
let dragAt = $state<{ readonly x: number; readonly y: number }>();
|
|
296
|
+
let dragged = false;
|
|
297
|
+
const drag = (event: PointerEvent) => {
|
|
298
|
+
if (event.button !== 0) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
const button = event.currentTarget as HTMLElement;
|
|
302
|
+
const box = button.getBoundingClientRect();
|
|
303
|
+
const offsetX = event.clientX - box.left;
|
|
304
|
+
const offsetY = event.clientY - box.top;
|
|
305
|
+
const startX = event.clientX;
|
|
306
|
+
const startY = event.clientY;
|
|
307
|
+
dragged = false;
|
|
308
|
+
// No text selection: a selection would make the next press start the browser's own drag of
|
|
309
|
+
// it, which cancels the pointer.
|
|
310
|
+
event.preventDefault();
|
|
311
|
+
// From the press on, so a quick drag that leaves the button still moves it.
|
|
312
|
+
button.setPointerCapture(event.pointerId);
|
|
313
|
+
const move = (next: PointerEvent) => {
|
|
314
|
+
if (!dragged && Math.hypot(next.clientX - startX, next.clientY - startY) < 5) {
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
dragged = true;
|
|
318
|
+
dragAt = { x: next.clientX - offsetX, y: next.clientY - offsetY };
|
|
319
|
+
};
|
|
320
|
+
const stop = (last: PointerEvent) => {
|
|
321
|
+
button.removeEventListener("pointermove", move);
|
|
322
|
+
button.removeEventListener("pointerup", stop);
|
|
323
|
+
button.removeEventListener("pointercancel", stop);
|
|
324
|
+
if (dragged) {
|
|
325
|
+
const top = last.clientY < innerHeight / 2;
|
|
326
|
+
const left = last.clientX < innerWidth / 2;
|
|
327
|
+
corner = `${top ? "top" : "bottom"}-${left ? "left" : "right"}`;
|
|
328
|
+
}
|
|
329
|
+
dragAt = undefined;
|
|
330
|
+
};
|
|
331
|
+
button.addEventListener("pointermove", move);
|
|
332
|
+
button.addEventListener("pointerup", stop);
|
|
333
|
+
button.addEventListener("pointercancel", stop);
|
|
334
|
+
};
|
|
335
|
+
const launch = () => {
|
|
336
|
+
// The click that ends a drag doesn't open the panel.
|
|
337
|
+
if (dragged) {
|
|
338
|
+
dragged = false;
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
openPanel();
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
const pad = (count: number) => String(count).padStart(2, "0");
|
|
345
|
+
|
|
346
|
+
const select = (id: number | undefined) => {
|
|
347
|
+
selected = id;
|
|
348
|
+
tab = "sheets";
|
|
349
|
+
};
|
|
350
|
+
const registryName = (index: number) => (index === 0 ? "registry 1" : `registry ${index + 1}`);
|
|
351
|
+
const tabs: readonly { readonly id: Tab; readonly label: string }[] = [
|
|
352
|
+
{ id: "graph", label: "Graph" },
|
|
353
|
+
{ id: "sheets", label: "Sheets" },
|
|
354
|
+
{ id: "timeline", label: "Timeline" },
|
|
355
|
+
{ id: "settings", label: "Settings" },
|
|
356
|
+
];
|
|
357
|
+
</script>
|
|
358
|
+
|
|
359
|
+
<svelte:window bind:innerHeight bind:innerWidth onkeydown={onShortcut} />
|
|
360
|
+
|
|
361
|
+
{#if enabled && mounted && model}
|
|
362
|
+
<!-- data-atom-devtools: where an app sets the panel's own colours and fonts (README, Theming). -->
|
|
363
|
+
<div class="devtools" class:dark data-atom-devtools>
|
|
364
|
+
{#if open}
|
|
365
|
+
<!-- A region of the page, not a modal: the page stays usable with it open. Escape from anything
|
|
366
|
+
in it closes it. -->
|
|
367
|
+
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
368
|
+
<section
|
|
369
|
+
bind:this={dock}
|
|
370
|
+
style:height="{shown}px"
|
|
371
|
+
aria-label="Atom devtools"
|
|
372
|
+
class="dock"
|
|
373
|
+
onkeydown={(event) => {
|
|
374
|
+
if (event.key === "Escape") {
|
|
375
|
+
void closePanel();
|
|
376
|
+
}
|
|
377
|
+
}}
|
|
378
|
+
tabindex="-1">
|
|
379
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions -->
|
|
380
|
+
<div
|
|
381
|
+
aria-label="Resize the panel"
|
|
382
|
+
aria-orientation="horizontal"
|
|
383
|
+
aria-valuemax={Math.round(innerHeight * 0.85)}
|
|
384
|
+
aria-valuemin={160}
|
|
385
|
+
aria-valuenow={Math.round(shown)}
|
|
386
|
+
class="resize"
|
|
387
|
+
ondblclick={() => (height = 320)}
|
|
388
|
+
onkeydown={resizeByKey}
|
|
389
|
+
onpointerdown={resize}
|
|
390
|
+
role="separator"
|
|
391
|
+
tabindex="0"
|
|
392
|
+
title="Drag to resize; double-click to reset"></div>
|
|
393
|
+
<header class="bar">
|
|
394
|
+
<span class="cell title"><b aria-hidden="true">◎</b> Atoms</span>
|
|
395
|
+
<nav aria-label="Views" class="tabs">
|
|
396
|
+
{#each tabs as item, index (item.id)}
|
|
397
|
+
<button aria-pressed={tab === item.id} class="cell tab" onclick={() => (tab = item.id)} type="button">
|
|
398
|
+
<b>{pad(index + 1)}</b>
|
|
399
|
+
{item.label}
|
|
400
|
+
</button>
|
|
401
|
+
{/each}
|
|
402
|
+
</nav>
|
|
403
|
+
<span class="spacer"></span>
|
|
404
|
+
<span class="cell count">Atoms <b>{pad(model.totals.atoms)}</b></span>
|
|
405
|
+
<span class="cell count">Readers <b>{pad(model.totals.readers)}</b></span>
|
|
406
|
+
<span class="cell count">Updates <b>{pad(model.totals.updates)}</b></span>
|
|
407
|
+
<span class="cell count" class:alert={model.totals.interruptions > 0}>Interrupted <b>{pad(model.totals.interruptions)}</b></span>
|
|
408
|
+
{#if registries.length > 1}
|
|
409
|
+
<label class="cell">
|
|
410
|
+
<span class="sr">Registry</span>
|
|
411
|
+
<select
|
|
412
|
+
class="picker"
|
|
413
|
+
onchange={(event) => (chosen = registries[Number(event.currentTarget.value)])}
|
|
414
|
+
value={String(registries.indexOf(chosen as AtomRegistry.AtomRegistry))}>
|
|
415
|
+
{#each registries as item, index (item)}
|
|
416
|
+
<option value={String(index)}>{registryName(index)}{item === nearest ? " (this one)" : ""}</option>
|
|
417
|
+
{/each}
|
|
418
|
+
</select>
|
|
419
|
+
</label>
|
|
420
|
+
{/if}
|
|
421
|
+
<label class="cell toggle">
|
|
422
|
+
<input bind:checked={showPlumbing} type="checkbox" />
|
|
423
|
+
Plumbing
|
|
424
|
+
</label>
|
|
425
|
+
<button aria-label={expanded ? "Shrink the panel" : "Enlarge the panel"} class="cell icon" onclick={() => (expanded = !expanded)} title={expanded ? "Shrink" : "Enlarge"} type="button">
|
|
426
|
+
<svg aria-hidden="true" height="12" viewBox="0 0 12 12" width="12">
|
|
427
|
+
{#if expanded}
|
|
428
|
+
<path d="M2 5h8M2 7h8" fill="none" stroke="currentColor" stroke-width="1.25" />
|
|
429
|
+
{:else}
|
|
430
|
+
<path d="M2 4l4-3 4 3M2 8l4 3 4-3" fill="none" stroke="currentColor" stroke-width="1.25" />
|
|
431
|
+
{/if}
|
|
432
|
+
</svg>
|
|
433
|
+
</button>
|
|
434
|
+
<button aria-label="Close the panel" class="cell icon" onclick={closePanel} title="Close (Esc)" type="button">
|
|
435
|
+
<svg aria-hidden="true" height="12" viewBox="0 0 12 12" width="12">
|
|
436
|
+
<path d="M2.5 2.5l7 7M9.5 2.5l-7 7" fill="none" stroke="currentColor" stroke-width="1.25" />
|
|
437
|
+
</svg>
|
|
438
|
+
</button>
|
|
439
|
+
</header>
|
|
440
|
+
|
|
441
|
+
{#if model.partial}
|
|
442
|
+
<p class="notice">
|
|
443
|
+
This registry isn't the one effect-atom-svelte's inspector was written for (a newer Effect?), so only atoms added and removed are shown.
|
|
444
|
+
</p>
|
|
445
|
+
{:else if model.unlabelled}
|
|
446
|
+
<p class="notice">
|
|
447
|
+
No atom has a name. Add <code>atomLabels()</code> from <code>effect-atom-svelte-devtools/vite</code> to your Vite config to name them after their variables.
|
|
448
|
+
</p>
|
|
449
|
+
{/if}
|
|
450
|
+
|
|
451
|
+
<div class="body">
|
|
452
|
+
{#if tab === "graph"}
|
|
453
|
+
<div class="scroll">
|
|
454
|
+
<GraphView atoms={model.atoms} onselect={select} {selected} {showPlumbing} />
|
|
455
|
+
</div>
|
|
456
|
+
{:else if tab === "sheets"}
|
|
457
|
+
<SheetsView {model} onselect={select} {selected} {showPlumbing} />
|
|
458
|
+
{:else if tab === "timeline"}
|
|
459
|
+
<TimelineView {model} onselect={select} {showPlumbing} />
|
|
460
|
+
{:else}
|
|
461
|
+
<SettingsView bind:corner bind:opacity bind:scale bind:shortcut defaultShortcut={appShortcut} />
|
|
462
|
+
{/if}
|
|
463
|
+
</div>
|
|
464
|
+
</section>
|
|
465
|
+
{:else}
|
|
466
|
+
<button
|
|
467
|
+
bind:this={launcher}
|
|
468
|
+
style:--launcher-opacity={opacity}
|
|
469
|
+
style:--launcher-scale={scale}
|
|
470
|
+
style:left={dragAt ? `${dragAt.x}px` : undefined}
|
|
471
|
+
style:top={dragAt ? `${dragAt.y}px` : undefined}
|
|
472
|
+
aria-keyshortcuts={keyShortcuts}
|
|
473
|
+
aria-label="Open the atom devtools"
|
|
474
|
+
class={["launcher", corner, dragAt && "dragging"]}
|
|
475
|
+
onclick={launch}
|
|
476
|
+
onpointerdown={drag}
|
|
477
|
+
title="Atom devtools ({shortcutLabel}). Drag to move."
|
|
478
|
+
type="button">
|
|
479
|
+
<b aria-hidden="true">◎</b> Atoms <span class="n">{pad(model.totals.atoms)}</span>
|
|
480
|
+
</button>
|
|
481
|
+
{/if}
|
|
482
|
+
</div>
|
|
483
|
+
{/if}
|
|
484
|
+
|
|
485
|
+
<style>
|
|
486
|
+
/*
|
|
487
|
+
* The docs' design language: zinc and amber, hairlines, mono labels. Each token reads the page's
|
|
488
|
+
* own where it has one (an app built on the docs' or shadcn's tokens), and falls back to the docs'
|
|
489
|
+
* values. The views use the short names; the graph module reads the page's names, so the dock
|
|
490
|
+
* hands those on too (on .dock, a level down, so neither refers to itself).
|
|
491
|
+
*/
|
|
492
|
+
.devtools {
|
|
493
|
+
--paper: var(--background, #fff);
|
|
494
|
+
--ink: var(--foreground, #18181b);
|
|
495
|
+
--muted: var(--muted-foreground, #52525b);
|
|
496
|
+
--subtle: var(--subtle-foreground, #a1a1aa);
|
|
497
|
+
--line: var(--border, #e4e4e7);
|
|
498
|
+
--faint: color-mix(in oklab, var(--ink) 5%, transparent);
|
|
499
|
+
--accent: var(--brand, #d97706);
|
|
500
|
+
--accent-text: var(--brand-text, #b45309);
|
|
501
|
+
--pulse: var(--accent);
|
|
502
|
+
--success: var(--tone-success, #16a34a);
|
|
503
|
+
--alert: var(--tone-failure, #dc2626);
|
|
504
|
+
--mono: var(--font-mono, ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace);
|
|
505
|
+
--serif: var(--font-serif, ui-serif, Georgia, "Times New Roman", serif);
|
|
506
|
+
--radius: 6px;
|
|
507
|
+
color: var(--ink);
|
|
508
|
+
font-family: var(--mono);
|
|
509
|
+
font-size: 13px;
|
|
510
|
+
line-height: 1.4;
|
|
511
|
+
}
|
|
512
|
+
.devtools.dark {
|
|
513
|
+
--paper: var(--background, #09090b);
|
|
514
|
+
--ink: var(--foreground, #fafafa);
|
|
515
|
+
--muted: var(--muted-foreground, #a1a1aa);
|
|
516
|
+
--subtle: var(--subtle-foreground, #71717a);
|
|
517
|
+
--line: var(--border, #27272a);
|
|
518
|
+
--accent: var(--brand, #f59e0b);
|
|
519
|
+
--accent-text: var(--brand-text, #f59e0b);
|
|
520
|
+
--success: var(--tone-success, #22c55e);
|
|
521
|
+
--alert: var(--tone-failure, #ef4444);
|
|
522
|
+
}
|
|
523
|
+
.devtools :global(*) {
|
|
524
|
+
box-sizing: border-box;
|
|
525
|
+
}
|
|
526
|
+
/* The launcher: one ruled cell in the corner, like a cell of the dock's bar. */
|
|
527
|
+
.launcher {
|
|
528
|
+
align-items: center;
|
|
529
|
+
background: var(--paper);
|
|
530
|
+
border: 1px solid var(--line);
|
|
531
|
+
border-radius: var(--radius);
|
|
532
|
+
color: var(--muted);
|
|
533
|
+
cursor: pointer;
|
|
534
|
+
display: inline-flex;
|
|
535
|
+
font-family: var(--mono);
|
|
536
|
+
font-size: calc(10.5px * var(--launcher-scale, 1));
|
|
537
|
+
gap: calc(0.5rem * var(--launcher-scale, 1));
|
|
538
|
+
height: calc(32px * var(--launcher-scale, 1));
|
|
539
|
+
letter-spacing: 0.08em;
|
|
540
|
+
opacity: var(--launcher-opacity, 1);
|
|
541
|
+
padding: 0 calc(0.75rem * var(--launcher-scale, 1));
|
|
542
|
+
position: fixed;
|
|
543
|
+
text-transform: uppercase;
|
|
544
|
+
touch-action: none;
|
|
545
|
+
transition: opacity 0.15s;
|
|
546
|
+
user-select: none;
|
|
547
|
+
z-index: 2147483000;
|
|
548
|
+
}
|
|
549
|
+
.launcher.bottom-right {
|
|
550
|
+
bottom: 16px;
|
|
551
|
+
right: 16px;
|
|
552
|
+
}
|
|
553
|
+
.launcher.bottom-left {
|
|
554
|
+
bottom: 16px;
|
|
555
|
+
left: 16px;
|
|
556
|
+
}
|
|
557
|
+
.launcher.top-right {
|
|
558
|
+
right: 16px;
|
|
559
|
+
top: 16px;
|
|
560
|
+
}
|
|
561
|
+
.launcher.top-left {
|
|
562
|
+
left: 16px;
|
|
563
|
+
top: 16px;
|
|
564
|
+
}
|
|
565
|
+
/* While dragged, it's placed by its left and top alone. */
|
|
566
|
+
.launcher.dragging {
|
|
567
|
+
bottom: auto;
|
|
568
|
+
cursor: grabbing;
|
|
569
|
+
right: auto;
|
|
570
|
+
}
|
|
571
|
+
/* Faded or not, it's opaque while pointed at, focused or dragged. */
|
|
572
|
+
.launcher:hover,
|
|
573
|
+
.launcher:focus-visible,
|
|
574
|
+
.launcher.dragging {
|
|
575
|
+
opacity: 1;
|
|
576
|
+
}
|
|
577
|
+
.launcher:hover {
|
|
578
|
+
border-color: var(--accent);
|
|
579
|
+
color: var(--ink);
|
|
580
|
+
}
|
|
581
|
+
.launcher b {
|
|
582
|
+
color: var(--accent);
|
|
583
|
+
font-weight: 400;
|
|
584
|
+
}
|
|
585
|
+
.launcher .n {
|
|
586
|
+
color: var(--ink);
|
|
587
|
+
font-variant-numeric: tabular-nums;
|
|
588
|
+
}
|
|
589
|
+
/* The dock: across the bottom of the window, ruled off from the page by its top line. */
|
|
590
|
+
.dock {
|
|
591
|
+
--background: var(--paper);
|
|
592
|
+
--foreground: var(--ink);
|
|
593
|
+
--muted-foreground: var(--muted);
|
|
594
|
+
--subtle-foreground: var(--subtle);
|
|
595
|
+
--border: var(--line);
|
|
596
|
+
--brand: var(--accent);
|
|
597
|
+
--brand-text: var(--accent-text);
|
|
598
|
+
--tone-success: var(--success);
|
|
599
|
+
--tone-failure: var(--alert);
|
|
600
|
+
--font-mono: var(--mono);
|
|
601
|
+
--font-serif: var(--serif);
|
|
602
|
+
background: var(--paper);
|
|
603
|
+
border-top: 1px solid var(--line);
|
|
604
|
+
bottom: 0;
|
|
605
|
+
display: flex;
|
|
606
|
+
flex-direction: column;
|
|
607
|
+
left: 0;
|
|
608
|
+
position: fixed;
|
|
609
|
+
right: 0;
|
|
610
|
+
z-index: 2147483000;
|
|
611
|
+
animation: rise 0.2s cubic-bezier(0.2, 0.7, 0.2, 1) both;
|
|
612
|
+
}
|
|
613
|
+
.resize {
|
|
614
|
+
cursor: ns-resize;
|
|
615
|
+
height: 7px;
|
|
616
|
+
left: 0;
|
|
617
|
+
position: absolute;
|
|
618
|
+
right: 0;
|
|
619
|
+
top: -4px;
|
|
620
|
+
z-index: 1;
|
|
621
|
+
}
|
|
622
|
+
.resize:focus-visible {
|
|
623
|
+
box-shadow: inset 0 -2px 0 var(--accent);
|
|
624
|
+
outline: none;
|
|
625
|
+
}
|
|
626
|
+
.dock:focus-visible {
|
|
627
|
+
outline: none;
|
|
628
|
+
}
|
|
629
|
+
.resize:hover {
|
|
630
|
+
box-shadow: inset 0 -1px 0 color-mix(in oklab, var(--accent) 60%, transparent);
|
|
631
|
+
}
|
|
632
|
+
/* The bar: a row of ruled cells, as the docs' site header is. */
|
|
633
|
+
.bar {
|
|
634
|
+
align-items: stretch;
|
|
635
|
+
border-bottom: 1px solid var(--line);
|
|
636
|
+
display: flex;
|
|
637
|
+
flex: none;
|
|
638
|
+
height: 36px;
|
|
639
|
+
overflow-x: auto;
|
|
640
|
+
}
|
|
641
|
+
.cell {
|
|
642
|
+
align-items: center;
|
|
643
|
+
background: none;
|
|
644
|
+
border: 0;
|
|
645
|
+
border-left: 1px solid var(--line);
|
|
646
|
+
color: var(--muted);
|
|
647
|
+
display: inline-flex;
|
|
648
|
+
flex: none;
|
|
649
|
+
font: inherit;
|
|
650
|
+
font-size: 10.5px;
|
|
651
|
+
gap: 0.45rem;
|
|
652
|
+
letter-spacing: 0.08em;
|
|
653
|
+
padding: 0 0.9rem;
|
|
654
|
+
text-transform: uppercase;
|
|
655
|
+
white-space: nowrap;
|
|
656
|
+
}
|
|
657
|
+
.cell b {
|
|
658
|
+
color: var(--accent-text);
|
|
659
|
+
font-weight: 400;
|
|
660
|
+
}
|
|
661
|
+
.title {
|
|
662
|
+
border-left: 0;
|
|
663
|
+
color: var(--ink);
|
|
664
|
+
}
|
|
665
|
+
.tabs {
|
|
666
|
+
display: flex;
|
|
667
|
+
}
|
|
668
|
+
.tab {
|
|
669
|
+
cursor: pointer;
|
|
670
|
+
}
|
|
671
|
+
.tab:hover,
|
|
672
|
+
.icon:hover {
|
|
673
|
+
background: var(--faint);
|
|
674
|
+
color: var(--ink);
|
|
675
|
+
}
|
|
676
|
+
.tab[aria-pressed="true"] {
|
|
677
|
+
box-shadow: inset 0 -2px 0 var(--accent);
|
|
678
|
+
color: var(--ink);
|
|
679
|
+
}
|
|
680
|
+
.spacer {
|
|
681
|
+
border-left: 1px solid var(--line);
|
|
682
|
+
flex: 1;
|
|
683
|
+
}
|
|
684
|
+
.count b {
|
|
685
|
+
color: var(--ink);
|
|
686
|
+
font-variant-numeric: tabular-nums;
|
|
687
|
+
}
|
|
688
|
+
.count.alert b {
|
|
689
|
+
color: var(--alert);
|
|
690
|
+
}
|
|
691
|
+
.picker {
|
|
692
|
+
background: var(--paper);
|
|
693
|
+
border: 1px solid var(--line);
|
|
694
|
+
border-radius: 4px;
|
|
695
|
+
color: var(--ink);
|
|
696
|
+
font: inherit;
|
|
697
|
+
letter-spacing: normal;
|
|
698
|
+
padding: 0.1rem 0.25rem;
|
|
699
|
+
text-transform: none;
|
|
700
|
+
}
|
|
701
|
+
.toggle {
|
|
702
|
+
cursor: pointer;
|
|
703
|
+
}
|
|
704
|
+
.toggle input {
|
|
705
|
+
accent-color: var(--accent);
|
|
706
|
+
margin: 0;
|
|
707
|
+
}
|
|
708
|
+
.icon {
|
|
709
|
+
cursor: pointer;
|
|
710
|
+
justify-content: center;
|
|
711
|
+
padding: 0;
|
|
712
|
+
width: 36px;
|
|
713
|
+
}
|
|
714
|
+
.sr {
|
|
715
|
+
clip-path: inset(50%);
|
|
716
|
+
height: 1px;
|
|
717
|
+
overflow: hidden;
|
|
718
|
+
position: absolute;
|
|
719
|
+
width: 1px;
|
|
720
|
+
}
|
|
721
|
+
.notice {
|
|
722
|
+
border-bottom: 1px solid var(--line);
|
|
723
|
+
color: var(--muted);
|
|
724
|
+
flex: none;
|
|
725
|
+
font-family: var(--serif);
|
|
726
|
+
font-style: italic;
|
|
727
|
+
margin: 0;
|
|
728
|
+
padding: 0.45rem 0.9rem;
|
|
729
|
+
}
|
|
730
|
+
.notice code {
|
|
731
|
+
font-family: var(--mono);
|
|
732
|
+
font-style: normal;
|
|
733
|
+
}
|
|
734
|
+
.body {
|
|
735
|
+
flex: 1;
|
|
736
|
+
min-height: 0;
|
|
737
|
+
}
|
|
738
|
+
.scroll {
|
|
739
|
+
height: 100%;
|
|
740
|
+
overflow: auto;
|
|
741
|
+
}
|
|
742
|
+
@keyframes rise {
|
|
743
|
+
from {
|
|
744
|
+
transform: translateY(12px);
|
|
745
|
+
opacity: 0;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
@media (prefers-reduced-motion: reduce) {
|
|
749
|
+
.dock {
|
|
750
|
+
animation: none;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
</style>
|