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,408 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
A dependency graph drawn on a hairline frame's own lines: the docs site's landing page and example
|
|
4
|
+
graphs, and the devtools panel's graph (both through atom-graph.svelte when live).
|
|
5
|
+
|
|
6
|
+
It reads the page's design tokens where it has them (--foreground, --background, --brand and
|
|
7
|
+
the rest, as in the docs site's app.css), and falls back to a neutral light palette where not. Place it at the top-left of the frame
|
|
8
|
+
(or of one ruled line); x is a fraction of its width, y is pixels down from its top. Lit edges are
|
|
9
|
+
drawn in the accent, in order, the first time the graph scrolls into view.
|
|
10
|
+
|
|
11
|
+
Every edge is a run of 1px borders, and every node sits on a 1px anchor, placed at the same CSS
|
|
12
|
+
coordinate as the frame line under it. At a fractional display scale (150%, say) the browser
|
|
13
|
+
rounds a 1px line to whole device pixels; drawn the same way from the same coordinate, the graph
|
|
14
|
+
rounds the same way, so it stays on its line. Edges must be horizontal or vertical.
|
|
15
|
+
-->
|
|
16
|
+
<script module lang="ts">
|
|
17
|
+
export type Kind = "effect" | "atom" | "component" | "junction" | "gone";
|
|
18
|
+
|
|
19
|
+
export interface GraphNode {
|
|
20
|
+
readonly x: number;
|
|
21
|
+
readonly y: number;
|
|
22
|
+
readonly kind: Kind;
|
|
23
|
+
readonly label?: string | undefined;
|
|
24
|
+
readonly note?: string | undefined;
|
|
25
|
+
/** Which side of the node its label sits: north-east (the default), south-east, and so on. */
|
|
26
|
+
readonly side?: "ne" | "se" | "nw" | "sw" | undefined;
|
|
27
|
+
/** The step at which it appears, with the edge that reaches it. */
|
|
28
|
+
readonly step?: number | undefined;
|
|
29
|
+
/** Names the node, for a live graph to find it again (`data-node`) and pulse it. */
|
|
30
|
+
readonly id?: string | undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface GraphEdge {
|
|
34
|
+
readonly points: readonly (readonly [x: number, y: number])[];
|
|
35
|
+
readonly lit?: boolean | undefined;
|
|
36
|
+
readonly dashed?: boolean | undefined;
|
|
37
|
+
readonly step?: number | undefined;
|
|
38
|
+
/** The node it leads to (`data-to`), so a live graph can light the edges into a node. */
|
|
39
|
+
readonly to?: string | undefined;
|
|
40
|
+
/** Keeps an edge's element across redraws of a live graph. */
|
|
41
|
+
readonly id?: string | undefined;
|
|
42
|
+
}
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<script lang="ts">
|
|
46
|
+
/**
|
|
47
|
+
* Where the frame's lines start, from the graph's box: `left` is the left edge of the line at
|
|
48
|
+
* x = 0, `right` that of the line at x = 1 less the box's width, and `top` is added to every y.
|
|
49
|
+
*/
|
|
50
|
+
const {
|
|
51
|
+
edges,
|
|
52
|
+
interactive = false,
|
|
53
|
+
nodes,
|
|
54
|
+
origin = { left: 0, right: -1, top: 0 },
|
|
55
|
+
}: {
|
|
56
|
+
edges: readonly GraphEdge[];
|
|
57
|
+
/** Whether atoms take clicks (atom-graph.svelte selects them); the rest stays inert. */
|
|
58
|
+
interactive?: boolean;
|
|
59
|
+
nodes: readonly GraphNode[];
|
|
60
|
+
origin?: { readonly left: number; readonly right: number; readonly top: number };
|
|
61
|
+
} = $props();
|
|
62
|
+
|
|
63
|
+
// contentRect keeps fractions of a pixel, which clientWidth would round away.
|
|
64
|
+
let rect = $state<DOMRectReadOnly>();
|
|
65
|
+
const width = $derived(rect?.width ?? 0);
|
|
66
|
+
let drawn = $state(false);
|
|
67
|
+
|
|
68
|
+
const draw = (element: HTMLElement) => {
|
|
69
|
+
const observer = new IntersectionObserver(
|
|
70
|
+
([entry]) => {
|
|
71
|
+
if (entry?.isIntersecting) {
|
|
72
|
+
drawn = true;
|
|
73
|
+
observer.disconnect();
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{ rootMargin: "0px 0px -20% 0px" }
|
|
77
|
+
);
|
|
78
|
+
observer.observe(element);
|
|
79
|
+
return () => observer.disconnect();
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const px = (x: number) => {
|
|
83
|
+
if (x === 0) {
|
|
84
|
+
return origin.left;
|
|
85
|
+
}
|
|
86
|
+
return x === 1 ? width + origin.right : x * width;
|
|
87
|
+
};
|
|
88
|
+
const py = (y: number) => y + origin.top;
|
|
89
|
+
|
|
90
|
+
interface Segment {
|
|
91
|
+
readonly left: number;
|
|
92
|
+
readonly top: number;
|
|
93
|
+
readonly length: number;
|
|
94
|
+
readonly vertical: boolean;
|
|
95
|
+
/** Drawn from its far end: right to left, or bottom to top. */
|
|
96
|
+
readonly reversed: boolean;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** An edge's runs, each covering both of its end pixels so runs meet without a gap. */
|
|
100
|
+
const segments = (edge: GraphEdge): Segment[] =>
|
|
101
|
+
edge.points.slice(1).map(([x, y], index) => {
|
|
102
|
+
const [fromX, fromY] = edge.points[index] ?? [x, y];
|
|
103
|
+
const [x1, y1, x2, y2] = [px(fromX), py(fromY), px(x), py(y)];
|
|
104
|
+
const vertical = x1 === x2;
|
|
105
|
+
return {
|
|
106
|
+
left: Math.min(x1, x2),
|
|
107
|
+
length: (vertical ? Math.abs(y2 - y1) : Math.abs(x2 - x1)) + 1,
|
|
108
|
+
reversed: vertical ? y2 < y1 : x2 < x1,
|
|
109
|
+
top: Math.min(y1, y2),
|
|
110
|
+
vertical,
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
</script>
|
|
114
|
+
|
|
115
|
+
<div
|
|
116
|
+
{@attach draw}
|
|
117
|
+
aria-hidden="true"
|
|
118
|
+
bind:contentRect={rect}
|
|
119
|
+
class="graph"
|
|
120
|
+
class:drawn
|
|
121
|
+
class:interactive
|
|
122
|
+
>
|
|
123
|
+
{#if width}
|
|
124
|
+
{#each edges as edge, index (edge.id ?? index)}
|
|
125
|
+
{#each segments(edge) as segment, part (part)}
|
|
126
|
+
<span
|
|
127
|
+
data-to={edge.to}
|
|
128
|
+
style:--step={edge.step ?? 0}
|
|
129
|
+
style:--part={part}
|
|
130
|
+
style:left="{segment.left}px"
|
|
131
|
+
style:top="{segment.top}px"
|
|
132
|
+
style:width={segment.vertical ? undefined : `${segment.length}px`}
|
|
133
|
+
style:height={segment.vertical ? `${segment.length}px` : undefined}
|
|
134
|
+
class={[
|
|
135
|
+
"edge",
|
|
136
|
+
segment.vertical ? "vertical" : "horizontal",
|
|
137
|
+
segment.reversed && "reversed",
|
|
138
|
+
edge.lit && "lit",
|
|
139
|
+
edge.dashed && "dashed",
|
|
140
|
+
]}
|
|
141
|
+
></span>
|
|
142
|
+
{/each}
|
|
143
|
+
{/each}
|
|
144
|
+
{/if}
|
|
145
|
+
{#each nodes as node, index (node.id ?? index)}
|
|
146
|
+
<span
|
|
147
|
+
data-node={node.id}
|
|
148
|
+
style:--step={node.step ?? 0}
|
|
149
|
+
style:left="{px(node.x)}px"
|
|
150
|
+
style:top="{py(node.y)}px"
|
|
151
|
+
class="node {node.kind} {node.side ?? 'ne'}"
|
|
152
|
+
>
|
|
153
|
+
<i></i>
|
|
154
|
+
<b class="ring"></b>
|
|
155
|
+
{#if node.label}
|
|
156
|
+
<span class="label">
|
|
157
|
+
{node.label}
|
|
158
|
+
{#if node.note}<em>{node.note}</em>{/if}
|
|
159
|
+
</span>
|
|
160
|
+
{/if}
|
|
161
|
+
</span>
|
|
162
|
+
{/each}
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
<style>
|
|
166
|
+
.graph {
|
|
167
|
+
height: 0;
|
|
168
|
+
inset: 0 0 auto;
|
|
169
|
+
pointer-events: none;
|
|
170
|
+
position: absolute;
|
|
171
|
+
z-index: 2;
|
|
172
|
+
}
|
|
173
|
+
/* A run of an edge: a 1px border, like the frame's own lines. */
|
|
174
|
+
/* Solid, mixed with what's behind the graph: a translucent line brightens where two runs overlap. */
|
|
175
|
+
.edge {
|
|
176
|
+
--edge: color-mix(in oklab, var(--foreground, #18181b) 30%, var(--graph-background, var(--background, #fff)));
|
|
177
|
+
position: absolute;
|
|
178
|
+
}
|
|
179
|
+
.edge.horizontal {
|
|
180
|
+
border-top: 1px solid var(--edge);
|
|
181
|
+
height: 0;
|
|
182
|
+
transform-origin: left;
|
|
183
|
+
}
|
|
184
|
+
.edge.vertical {
|
|
185
|
+
border-left: 1px solid var(--edge);
|
|
186
|
+
transform-origin: top;
|
|
187
|
+
width: 0;
|
|
188
|
+
}
|
|
189
|
+
.edge.horizontal.reversed {
|
|
190
|
+
transform-origin: right;
|
|
191
|
+
}
|
|
192
|
+
.edge.vertical.reversed {
|
|
193
|
+
transform-origin: bottom;
|
|
194
|
+
}
|
|
195
|
+
.edge.dashed {
|
|
196
|
+
border-style: dashed;
|
|
197
|
+
}
|
|
198
|
+
.edge.lit {
|
|
199
|
+
--edge: var(--brand, #d97706);
|
|
200
|
+
}
|
|
201
|
+
/* A node's anchor is the 1px square of line it sits on; its mark is centred on that square. */
|
|
202
|
+
.interactive .node.atom,
|
|
203
|
+
.interactive .node.gone {
|
|
204
|
+
cursor: pointer;
|
|
205
|
+
pointer-events: auto;
|
|
206
|
+
}
|
|
207
|
+
.node:global(.selected) i {
|
|
208
|
+
box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand, #d97706) 40%, transparent);
|
|
209
|
+
}
|
|
210
|
+
/* Above every edge, so labels and marks are never crossed. */
|
|
211
|
+
.node {
|
|
212
|
+
height: 1px;
|
|
213
|
+
position: absolute;
|
|
214
|
+
width: 1px;
|
|
215
|
+
z-index: 2;
|
|
216
|
+
}
|
|
217
|
+
/* Centring a mark on a 1px line takes an odd size and whole-pixel borders: a 9px mark then sits
|
|
218
|
+
exactly 4px either side of the line, so every edge of it falls on the same fraction of a device
|
|
219
|
+
pixel as the line's own edges, at any display scale (at 150% nothing lands on whole device
|
|
220
|
+
pixels, and a mark that didn't share the line's fraction would blur unevenly and look off). */
|
|
221
|
+
.node i {
|
|
222
|
+
--size: 9px;
|
|
223
|
+
background: var(--background, #fff);
|
|
224
|
+
border: 1px solid var(--subtle-foreground, #a1a1aa);
|
|
225
|
+
height: var(--size);
|
|
226
|
+
left: calc((1px - var(--size)) / 2);
|
|
227
|
+
position: absolute;
|
|
228
|
+
top: calc((1px - var(--size)) / 2);
|
|
229
|
+
width: var(--size);
|
|
230
|
+
}
|
|
231
|
+
/* A square turned on its corner: 7px across its sides is about 10px across its corners. */
|
|
232
|
+
.node.effect i {
|
|
233
|
+
--size: 7px;
|
|
234
|
+
background: var(--foreground, #18181b);
|
|
235
|
+
border-color: var(--foreground, #18181b);
|
|
236
|
+
rotate: 45deg;
|
|
237
|
+
}
|
|
238
|
+
.node.atom i {
|
|
239
|
+
border-color: var(--brand, #d97706);
|
|
240
|
+
border-radius: 50%;
|
|
241
|
+
border-width: 2px;
|
|
242
|
+
box-shadow: 0 0 0 3px var(--background, #fff);
|
|
243
|
+
}
|
|
244
|
+
.node.component i {
|
|
245
|
+
border-color: var(--foreground, #18181b);
|
|
246
|
+
border-radius: 1.5px;
|
|
247
|
+
}
|
|
248
|
+
.node.junction i {
|
|
249
|
+
--size: 5px;
|
|
250
|
+
background: var(--brand, #d97706);
|
|
251
|
+
border: 0;
|
|
252
|
+
border-radius: 50%;
|
|
253
|
+
}
|
|
254
|
+
.node.gone i {
|
|
255
|
+
background:
|
|
256
|
+
linear-gradient(45deg, transparent 45%, var(--brand-text, #b45309) 45% 55%, transparent 55%),
|
|
257
|
+
linear-gradient(-45deg, transparent 45%, var(--brand-text, #b45309) 45% 55%, transparent 55%);
|
|
258
|
+
border: 0;
|
|
259
|
+
}
|
|
260
|
+
/* Backed with what's behind the graph (--graph-background), so a label hides the lines under it. */
|
|
261
|
+
.label {
|
|
262
|
+
background: var(--graph-background, var(--background, #fff));
|
|
263
|
+
color: var(--foreground, #18181b);
|
|
264
|
+
font-family: var(--font-mono, ui-monospace, "SF Mono", Menlo, Consolas, monospace);
|
|
265
|
+
font-size: 0.7rem;
|
|
266
|
+
line-height: 1.3;
|
|
267
|
+
padding: 0 0.3rem;
|
|
268
|
+
position: absolute;
|
|
269
|
+
white-space: nowrap;
|
|
270
|
+
}
|
|
271
|
+
.label em {
|
|
272
|
+
color: var(--muted-foreground, #52525b);
|
|
273
|
+
display: block;
|
|
274
|
+
font-family: var(--font-serif, ui-serif, Georgia, serif);
|
|
275
|
+
font-size: 0.72rem;
|
|
276
|
+
font-style: italic;
|
|
277
|
+
}
|
|
278
|
+
.ne .label {
|
|
279
|
+
bottom: 0.45rem;
|
|
280
|
+
left: 0.45rem;
|
|
281
|
+
}
|
|
282
|
+
.se .label {
|
|
283
|
+
left: 0.45rem;
|
|
284
|
+
top: 0.45rem;
|
|
285
|
+
}
|
|
286
|
+
.nw .label {
|
|
287
|
+
bottom: 0.45rem;
|
|
288
|
+
right: 0.45rem;
|
|
289
|
+
text-align: right;
|
|
290
|
+
}
|
|
291
|
+
.sw .label {
|
|
292
|
+
right: 0.45rem;
|
|
293
|
+
text-align: right;
|
|
294
|
+
top: 0.45rem;
|
|
295
|
+
}
|
|
296
|
+
/* Drawn once, in order, when first seen: each lit edge, then the node it reaches. */
|
|
297
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
298
|
+
.edge.lit.horizontal {
|
|
299
|
+
scale: 0 1;
|
|
300
|
+
}
|
|
301
|
+
.edge.lit.vertical {
|
|
302
|
+
scale: 1 0;
|
|
303
|
+
}
|
|
304
|
+
.drawn .edge.lit {
|
|
305
|
+
animation: draw 0.7s cubic-bezier(0.4, 0, 0.2, 1) both;
|
|
306
|
+
animation-delay: calc(var(--step) * 0.45s + var(--part) * 0.15s + 0.2s);
|
|
307
|
+
}
|
|
308
|
+
.node {
|
|
309
|
+
opacity: 0;
|
|
310
|
+
}
|
|
311
|
+
.drawn .node {
|
|
312
|
+
animation: appear 0.4s ease-out both;
|
|
313
|
+
animation-delay: calc(var(--step) * 0.45s + 0.2s);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
@keyframes draw {
|
|
317
|
+
to {
|
|
318
|
+
scale: 1;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
/*
|
|
322
|
+
* A live graph's events (example-graph.svelte adds and removes these classes): a value updated
|
|
323
|
+
* (the node rings, and the edges into it flash), or an atom interrupted (a cross over its node).
|
|
324
|
+
*/
|
|
325
|
+
/* A live graph sets data-tone on a node and its edges as an update arrives (example-graph). */
|
|
326
|
+
.node,
|
|
327
|
+
.edge {
|
|
328
|
+
--pulse: var(--brand, #d97706);
|
|
329
|
+
}
|
|
330
|
+
.node:global([data-tone="success"]),
|
|
331
|
+
.edge:global([data-tone="success"]) {
|
|
332
|
+
--pulse: var(--tone-success, #16a34a);
|
|
333
|
+
}
|
|
334
|
+
.node:global([data-tone="failure"]),
|
|
335
|
+
.edge:global([data-tone="failure"]) {
|
|
336
|
+
--pulse: var(--tone-failure, #dc2626);
|
|
337
|
+
}
|
|
338
|
+
.node:global(.pulse) i {
|
|
339
|
+
animation: mark 0.9s ease-out;
|
|
340
|
+
}
|
|
341
|
+
@keyframes mark {
|
|
342
|
+
from {
|
|
343
|
+
background: var(--pulse);
|
|
344
|
+
border-color: var(--pulse);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
.ring {
|
|
348
|
+
opacity: 0;
|
|
349
|
+
pointer-events: none;
|
|
350
|
+
border: 1.5px solid var(--pulse);
|
|
351
|
+
border-radius: 50%;
|
|
352
|
+
height: 9px;
|
|
353
|
+
left: -4px;
|
|
354
|
+
position: absolute;
|
|
355
|
+
top: -4px;
|
|
356
|
+
width: 9px;
|
|
357
|
+
}
|
|
358
|
+
.node:global(.pulse) .ring {
|
|
359
|
+
animation: ring 0.9s ease-out both;
|
|
360
|
+
}
|
|
361
|
+
.edge:global(.flash) {
|
|
362
|
+
animation: flash 0.9s ease-out both;
|
|
363
|
+
}
|
|
364
|
+
.node:global(.interrupted) i {
|
|
365
|
+
animation: interrupted 1.6s ease-out both;
|
|
366
|
+
}
|
|
367
|
+
@keyframes ring {
|
|
368
|
+
from {
|
|
369
|
+
opacity: 1;
|
|
370
|
+
scale: 1;
|
|
371
|
+
}
|
|
372
|
+
to {
|
|
373
|
+
opacity: 0;
|
|
374
|
+
scale: 3;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
@keyframes flash {
|
|
378
|
+
from {
|
|
379
|
+
border-color: var(--pulse);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
@keyframes interrupted {
|
|
383
|
+
0%,
|
|
384
|
+
60% {
|
|
385
|
+
background:
|
|
386
|
+
linear-gradient(45deg, transparent 42%, var(--brand-text, #b45309) 42% 58%, transparent 58%),
|
|
387
|
+
linear-gradient(-45deg, transparent 42%, var(--brand-text, #b45309) 42% 58%, transparent 58%);
|
|
388
|
+
border-color: var(--brand-text, #b45309);
|
|
389
|
+
scale: 1.4;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
@media (prefers-reduced-motion: reduce) {
|
|
393
|
+
.node:global(.pulse) .ring,
|
|
394
|
+
.edge:global(.flash),
|
|
395
|
+
.node:global(.interrupted) i {
|
|
396
|
+
animation-duration: 0.01s;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
@keyframes appear {
|
|
400
|
+
from {
|
|
401
|
+
opacity: 0;
|
|
402
|
+
transform: translateY(2px);
|
|
403
|
+
}
|
|
404
|
+
to {
|
|
405
|
+
opacity: 1;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
</style>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export type Kind = "effect" | "atom" | "component" | "junction" | "gone";
|
|
2
|
+
export interface GraphNode {
|
|
3
|
+
readonly x: number;
|
|
4
|
+
readonly y: number;
|
|
5
|
+
readonly kind: Kind;
|
|
6
|
+
readonly label?: string | undefined;
|
|
7
|
+
readonly note?: string | undefined;
|
|
8
|
+
/** Which side of the node its label sits: north-east (the default), south-east, and so on. */
|
|
9
|
+
readonly side?: "ne" | "se" | "nw" | "sw" | undefined;
|
|
10
|
+
/** The step at which it appears, with the edge that reaches it. */
|
|
11
|
+
readonly step?: number | undefined;
|
|
12
|
+
/** Names the node, for a live graph to find it again (`data-node`) and pulse it. */
|
|
13
|
+
readonly id?: string | undefined;
|
|
14
|
+
}
|
|
15
|
+
export interface GraphEdge {
|
|
16
|
+
readonly points: readonly (readonly [x: number, y: number])[];
|
|
17
|
+
readonly lit?: boolean | undefined;
|
|
18
|
+
readonly dashed?: boolean | undefined;
|
|
19
|
+
readonly step?: number | undefined;
|
|
20
|
+
/** The node it leads to (`data-to`), so a live graph can light the edges into a node. */
|
|
21
|
+
readonly to?: string | undefined;
|
|
22
|
+
/** Keeps an edge's element across redraws of a live graph. */
|
|
23
|
+
readonly id?: string | undefined;
|
|
24
|
+
}
|
|
25
|
+
type $$ComponentProps = {
|
|
26
|
+
edges: readonly GraphEdge[];
|
|
27
|
+
/** Whether atoms take clicks (atom-graph.svelte selects them); the rest stays inert. */
|
|
28
|
+
interactive?: boolean;
|
|
29
|
+
nodes: readonly GraphNode[];
|
|
30
|
+
origin?: {
|
|
31
|
+
readonly left: number;
|
|
32
|
+
readonly right: number;
|
|
33
|
+
readonly top: number;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* A dependency graph drawn on a hairline frame's own lines: the docs site's landing page and example
|
|
38
|
+
* graphs, and the devtools panel's graph (both through atom-graph.svelte when live).
|
|
39
|
+
*
|
|
40
|
+
* It reads the page's design tokens where it has them (--foreground, --background, --brand and
|
|
41
|
+
* the rest, as in the docs site's app.css), and falls back to a neutral light palette where not. Place it at the top-left of the frame
|
|
42
|
+
* (or of one ruled line); x is a fraction of its width, y is pixels down from its top. Lit edges are
|
|
43
|
+
* drawn in the accent, in order, the first time the graph scrolls into view.
|
|
44
|
+
*
|
|
45
|
+
* Every edge is a run of 1px borders, and every node sits on a 1px anchor, placed at the same CSS
|
|
46
|
+
* coordinate as the frame line under it. At a fractional display scale (150%, say) the browser
|
|
47
|
+
* rounds a 1px line to whole device pixels; drawn the same way from the same coordinate, the graph
|
|
48
|
+
* rounds the same way, so it stays on its line. Edges must be horizontal or vertical.
|
|
49
|
+
*/
|
|
50
|
+
declare const FrameGraph: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
51
|
+
type FrameGraph = ReturnType<typeof FrameGraph>;
|
|
52
|
+
export default FrameGraph;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as AtomGraph } from "./atom-graph.svelte";
|
|
2
|
+
export { default as FrameGraph } from "./frame-graph.svelte";
|
|
3
|
+
export type { GraphEdge, GraphNode, Kind } from "./frame-graph.svelte";
|
|
4
|
+
export { layoutGraph, toneOf } from "./layout.ts";
|
|
5
|
+
export type { GraphAtom, GraphDot, GraphInput, GraphLayout, GraphLink, GraphReader, } from "./layout.ts";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// The dependency graph the devtools panel and the docs site draw: a layout (`layoutGraph`), the
|
|
2
|
+
// renderer that draws one on a frame's lines (`FrameGraph`), and a live graph that lays out and
|
|
3
|
+
// animates atoms as they change (`AtomGraph`). Plain Svelte with no dependencies, so it can be used
|
|
4
|
+
// in production as well as in development.
|
|
5
|
+
export { default as AtomGraph } from "./atom-graph.svelte";
|
|
6
|
+
export { default as FrameGraph } from "./frame-graph.svelte";
|
|
7
|
+
export { layoutGraph, toneOf } from "./layout.js";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { GraphEdge, GraphNode } from "./frame-graph.svelte";
|
|
2
|
+
/** An atom to draw. */
|
|
3
|
+
export interface GraphAtom {
|
|
4
|
+
/** Stable for the atom, and in the order it was first seen: the layout keeps that order. */
|
|
5
|
+
readonly id: number;
|
|
6
|
+
readonly label: string | undefined;
|
|
7
|
+
/** The line under its name: its result, or why it's still held. */
|
|
8
|
+
readonly note?: string | undefined;
|
|
9
|
+
/** Still held but read by nothing in view (`held`), or just removed (`removed`, drawn crossed). */
|
|
10
|
+
readonly status?: "live" | "held" | "removed" | undefined;
|
|
11
|
+
/** Read by something, when there are no component readers to say so (the devtools panel). */
|
|
12
|
+
readonly read?: boolean | undefined;
|
|
13
|
+
}
|
|
14
|
+
/** That `to` reads `from`. */
|
|
15
|
+
export interface GraphLink {
|
|
16
|
+
readonly from: number;
|
|
17
|
+
readonly to: number;
|
|
18
|
+
}
|
|
19
|
+
/** A component's use of an atom: `read`, `mount`, `subscribe` or `write`. */
|
|
20
|
+
export interface GraphReader {
|
|
21
|
+
readonly atom: number;
|
|
22
|
+
readonly kind: string;
|
|
23
|
+
/** The component, as its file is called (`die.svelte`). */
|
|
24
|
+
readonly name: string;
|
|
25
|
+
/** Tells two instances of one component apart. */
|
|
26
|
+
readonly instance?: number | undefined;
|
|
27
|
+
}
|
|
28
|
+
export interface GraphInput {
|
|
29
|
+
readonly atoms: readonly GraphAtom[];
|
|
30
|
+
readonly links: readonly GraphLink[];
|
|
31
|
+
readonly readers?: readonly GraphReader[] | undefined;
|
|
32
|
+
}
|
|
33
|
+
/** A family's or factory's atom, drawn as a dot on its group's row. */
|
|
34
|
+
export interface GraphDot {
|
|
35
|
+
readonly id: number;
|
|
36
|
+
/** Its key, short: an object's values (`1 · en`) or the argument as written. */
|
|
37
|
+
readonly key: string;
|
|
38
|
+
/** Its full name, for its title. */
|
|
39
|
+
readonly label: string;
|
|
40
|
+
/** A second atom for a key the group already has. */
|
|
41
|
+
readonly repeat: boolean;
|
|
42
|
+
readonly read: boolean;
|
|
43
|
+
readonly removed: boolean;
|
|
44
|
+
readonly x: number;
|
|
45
|
+
readonly y: number;
|
|
46
|
+
}
|
|
47
|
+
export interface GraphLayout {
|
|
48
|
+
readonly nodes: readonly GraphNode[];
|
|
49
|
+
readonly edges: readonly GraphEdge[];
|
|
50
|
+
readonly dots: readonly {
|
|
51
|
+
readonly dots: readonly GraphDot[];
|
|
52
|
+
readonly keys: boolean;
|
|
53
|
+
}[];
|
|
54
|
+
readonly height: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The tone a value's pulse takes: green for a Success, red for a Failure, and the accent for a
|
|
58
|
+
* plain value or a result still waiting for the next.
|
|
59
|
+
*/
|
|
60
|
+
export declare const toneOf: (state: string | undefined, waiting?: boolean) => "success" | "failure" | "";
|
|
61
|
+
/**
|
|
62
|
+
* Lays a graph out for a box `width` pixels wide (only the gaps at crossings and the dots' spacing
|
|
63
|
+
* depend on it: x is a fraction of the width, y is in pixels). Undefined when there's nothing to draw.
|
|
64
|
+
*/
|
|
65
|
+
export declare const layoutGraph: (input: GraphInput, width: number) => GraphLayout | undefined;
|