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.
Files changed (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +122 -2
  3. package/dist/atom-devtools.svelte +753 -0
  4. package/dist/atom-devtools.svelte.d.ts +39 -0
  5. package/dist/graph/atom-graph.svelte +244 -0
  6. package/dist/graph/atom-graph.svelte.d.ts +38 -0
  7. package/dist/graph/frame-graph.svelte +408 -0
  8. package/dist/graph/frame-graph.svelte.d.ts +52 -0
  9. package/dist/graph/index.d.ts +5 -0
  10. package/dist/graph/index.js +7 -0
  11. package/dist/graph/layout.d.ts +65 -0
  12. package/dist/graph/layout.js +531 -0
  13. package/dist/index.d.ts +14 -0
  14. package/dist/index.js +14 -0
  15. package/dist/internal/format.d.ts +27 -0
  16. package/dist/internal/format.js +183 -0
  17. package/dist/internal/graph-view.svelte +134 -0
  18. package/dist/internal/graph-view.svelte.d.ts +10 -0
  19. package/dist/internal/label.d.ts +35 -0
  20. package/dist/internal/label.js +139 -0
  21. package/dist/internal/model.svelte.d.ts +75 -0
  22. package/dist/internal/model.svelte.js +286 -0
  23. package/dist/internal/names.d.ts +29 -0
  24. package/dist/internal/names.js +55 -0
  25. package/dist/internal/settings-view.svelte +198 -0
  26. package/dist/internal/settings-view.svelte.d.ts +16 -0
  27. package/dist/internal/sheets-view.svelte +453 -0
  28. package/dist/internal/sheets-view.svelte.d.ts +11 -0
  29. package/dist/internal/shortcut.d.ts +22 -0
  30. package/dist/internal/shortcut.js +91 -0
  31. package/dist/internal/timeline-view.svelte +291 -0
  32. package/dist/internal/timeline-view.svelte.d.ts +9 -0
  33. package/dist/internal/transform.d.ts +17 -0
  34. package/dist/internal/transform.js +401 -0
  35. package/dist/vite.d.ts +52 -0
  36. package/dist/vite.js +97 -0
  37. package/package.json +78 -4
@@ -0,0 +1,183 @@
1
+ // How the panel shows an atom's value: a one-line preview, and the whole of it on its sheet.
2
+ import { Cause } from "effect";
3
+ import { AsyncResult } from "effect/reactivity";
4
+ export const valueState = (value) => AsyncResult.isAsyncResult(value)
5
+ ? { _tag: value._tag, waiting: value.waiting }
6
+ : { _tag: "Value" };
7
+ /** A short description of the state: `Success, waiting`. */
8
+ export const stateText = (state) => {
9
+ if (state._tag === "Value") {
10
+ return "";
11
+ }
12
+ return state.waiting ? `${state._tag}, waiting` : state._tag;
13
+ };
14
+ const hasToJSON = (value) => typeof value.toJSON === "function";
15
+ // How much of a value is written out: deeper or longer parts are cut short.
16
+ const maxDepth = 5;
17
+ const maxItems = 50;
18
+ const plainResult = (result, inner) => {
19
+ switch (result._tag) {
20
+ case "Initial": {
21
+ return { _tag: "Initial", waiting: result.waiting };
22
+ }
23
+ case "Success": {
24
+ return {
25
+ _tag: "Success",
26
+ value: inner(result.value),
27
+ waiting: result.waiting,
28
+ };
29
+ }
30
+ default: {
31
+ return {
32
+ _tag: "Failure",
33
+ cause: Cause.pretty(result.cause),
34
+ waiting: result.waiting,
35
+ };
36
+ }
37
+ }
38
+ };
39
+ const plainObject = (value, inner) => {
40
+ if (AsyncResult.isAsyncResult(value)) {
41
+ return plainResult(value, inner);
42
+ }
43
+ if (value instanceof Date) {
44
+ return value.toISOString();
45
+ }
46
+ if (value instanceof Error) {
47
+ return `${value.name}: ${value.message}`;
48
+ }
49
+ if (value instanceof Map) {
50
+ return Object.fromEntries([...value]
51
+ .slice(0, maxItems)
52
+ .map(([key, entry]) => [String(key), inner(entry)]));
53
+ }
54
+ if (value instanceof Set) {
55
+ return [...value].slice(0, maxItems).map(inner);
56
+ }
57
+ if (Array.isArray(value)) {
58
+ const items = value.slice(0, maxItems).map(inner);
59
+ return value.length > maxItems
60
+ ? [...items, `… ${value.length - maxItems} more`]
61
+ : items;
62
+ }
63
+ if (hasToJSON(value)) {
64
+ const json = value.toJSON();
65
+ if (json !== value) {
66
+ return inner(json);
67
+ }
68
+ }
69
+ return Object.fromEntries(Object.entries(value)
70
+ .slice(0, maxItems)
71
+ .map(([key, entry]) => [key, inner(entry)]));
72
+ };
73
+ /**
74
+ * Turns a value into plain data to print: an `AsyncResult` as its tag and contents, a failure's
75
+ * cause pretty-printed, Effect's data types through their own `toJSON`, maps and sets as entries,
76
+ * and anything too deep, too long or circular cut short.
77
+ */
78
+ export const plain = (value, depth = 0, seen = new Set()) => {
79
+ switch (typeof value) {
80
+ case "function": {
81
+ return `ƒ ${value.name || "anonymous"}`;
82
+ }
83
+ case "bigint": {
84
+ return `${value}n`;
85
+ }
86
+ case "symbol": {
87
+ return value.toString();
88
+ }
89
+ case "object": {
90
+ break;
91
+ }
92
+ default: {
93
+ return value;
94
+ }
95
+ }
96
+ if (value === null) {
97
+ return value;
98
+ }
99
+ if (seen.has(value)) {
100
+ return "[circular]";
101
+ }
102
+ if (depth > maxDepth) {
103
+ return "…";
104
+ }
105
+ seen.add(value);
106
+ try {
107
+ return plainObject(value, (inner) => plain(inner, depth + 1, seen));
108
+ }
109
+ catch {
110
+ return "[unreadable]";
111
+ }
112
+ finally {
113
+ seen.delete(value);
114
+ }
115
+ };
116
+ const json = (data, indent) => typeof data === "string"
117
+ ? JSON.stringify(data)
118
+ : (JSON.stringify(data, undefined, indent) ?? String(data));
119
+ /** The value written out in full, for its sheet. */
120
+ export const detail = (value) => json(plain(value), 2);
121
+ /** An error's name: a tagged error's `_tag`, an `Error`'s `name`, or the value as a string. */
122
+ const errorName = (error) => {
123
+ if (typeof error === "object" && error !== null) {
124
+ if ("_tag" in error && typeof error._tag === "string") {
125
+ return error._tag;
126
+ }
127
+ if (error instanceof Error) {
128
+ return error.name;
129
+ }
130
+ }
131
+ return String(error);
132
+ };
133
+ /** An error with its fields, as `CityNotFound { city: "Atlantis" }`, or its message if it has one. */
134
+ const errorText = (error) => {
135
+ const name = errorName(error);
136
+ if (typeof error !== "object" || error === null) {
137
+ return name;
138
+ }
139
+ if ("message" in error &&
140
+ typeof error.message === "string" &&
141
+ error.message !== "") {
142
+ return `${name}: ${error.message}`;
143
+ }
144
+ const fields = Object.entries(error).filter(([key]) => key !== "_tag");
145
+ const body = fields.map(([key, field]) => `${key}: ${json(plain(field))}`);
146
+ return body.length > 0 ? `${name} { ${body.join(", ")} }` : name;
147
+ };
148
+ /**
149
+ * What a failure failed with, from its first reason: a typed error by its name (`CityNotFound`),
150
+ * or with its fields when `full`; a defect as `defect: TypeError`; an interruption as
151
+ * `interrupted`.
152
+ */
153
+ export const failureText = (cause, full = false) => {
154
+ const [reason] = cause.reasons;
155
+ if (reason === undefined) {
156
+ return "empty cause";
157
+ }
158
+ if (Cause.isFailReason(reason)) {
159
+ return full ? errorText(reason.error) : errorName(reason.error);
160
+ }
161
+ if (Cause.isDieReason(reason)) {
162
+ return `defect: ${full ? errorText(reason.defect) : errorName(reason.defect)}`;
163
+ }
164
+ return "interrupted";
165
+ };
166
+ /** An `AsyncResult` on one line: its value, through `inner`, or what it failed with. */
167
+ const resultText = (result, inner) => {
168
+ let text = "Initial";
169
+ if (result._tag === "Success") {
170
+ text = inner(result.value);
171
+ }
172
+ else if (result._tag === "Failure") {
173
+ text = failureText(result.cause, true);
174
+ }
175
+ return result.waiting ? `${text}, waiting` : text;
176
+ };
177
+ /** The value on one line, cut to `length` characters. */
178
+ export const preview = (value, length = 48) => {
179
+ const text = AsyncResult.isAsyncResult(value)
180
+ ? resultText(value, (inner) => preview(inner, length))
181
+ : json(plain(value));
182
+ return text.length > length ? `${text.slice(0, length - 1)}…` : text;
183
+ };
@@ -0,0 +1,134 @@
1
+ <!--
2
+ The registry's live dependency graph, drawn by the graph module as the docs' examples draw theirs
3
+ (../graph): atoms on tracks, a ring in green or red as a value succeeds or fails, a cross when an
4
+ effect is interrupted or an atom removed. Clicking an atom opens its sheet.
5
+ -->
6
+ <script lang="ts">
7
+ import { AtomGraph, toneOf } from "../graph/index.js";
8
+ import type { GraphAtom, GraphInput } from "../graph/index.js";
9
+ import { AsyncResult } from "effect/reactivity";
10
+
11
+ import { failureText, preview, stateText } from "./format.js";
12
+ import type { AtomView } from "./model.svelte.js";
13
+ import { lingerFor } from "./model.svelte.js";
14
+
15
+ interface Props {
16
+ readonly atoms: readonly AtomView[];
17
+ readonly showPlumbing: boolean;
18
+ readonly selected: number | undefined;
19
+ readonly onselect: (id: number) => void;
20
+ }
21
+
22
+ const { atoms, onselect, selected, showPlumbing }: Props = $props();
23
+
24
+ let graph = $state<AtomGraph>();
25
+
26
+ const shown = (view: AtomView) =>
27
+ (showPlumbing || !view.plumbing) &&
28
+ (view.live ||
29
+ (view.removedAt !== undefined && performance.now() - view.removedAt < lingerFor));
30
+
31
+ /** Why the registry holds an atom nothing reads. */
32
+ const heldBecause = (view: AtomView) => {
33
+ if (view.keepAlive) {
34
+ return "kept alive";
35
+ }
36
+ return view.idleTTL ? "idle" : "no readers";
37
+ };
38
+
39
+ /** Live and read, live but held with nothing reading it, or removed a moment ago. */
40
+ const statusOf = (view: AtomView): GraphAtom["status"] => {
41
+ if (!view.live) {
42
+ return "removed";
43
+ }
44
+ return view.readers > 0 || view.children.length > 0 ? "live" : "held";
45
+ };
46
+
47
+ /** Its state and a short preview of its value; why it's still held; or that it's gone. */
48
+ const note = (view: AtomView) => {
49
+ if (!view.live) {
50
+ return "removed · finalizers ran";
51
+ }
52
+ const state = stateText(view.state);
53
+ let value = view.hasValue ? preview(view.value, 26) : "";
54
+ // A failure shows what it failed with, by name: its fields are on its sheet.
55
+ if (AsyncResult.isAsyncResult(view.value) && AsyncResult.isFailure(view.value)) {
56
+ value = failureText(view.value.cause);
57
+ }
58
+ const withValue = state === "" || view.state._tag === "Success" || view.state._tag === "Failure";
59
+ const parts = [state, withValue ? value : ""];
60
+ if (view.readers === 0 && view.children.length === 0) {
61
+ parts.push(heldBecause(view));
62
+ }
63
+ return parts.filter((part) => part !== "").join(" · ");
64
+ };
65
+
66
+ const input = $derived.by((): GraphInput => {
67
+ const byId = new Map(atoms.map((view) => [view.id, view]));
68
+ const visible = atoms.filter(shown);
69
+ const ids = new Set(visible.map((view) => view.id));
70
+ // Through any plumbing that's hidden, to the nearest atoms upstream that are shown.
71
+ const parentsOf = (view: AtomView) => {
72
+ const found = new Set<number>();
73
+ const walk = (from: readonly number[], steps: number) => {
74
+ for (const id of from) {
75
+ if (ids.has(id)) {
76
+ found.add(id);
77
+ } else if (steps < 6) {
78
+ walk(byId.get(id)?.parents ?? [], steps + 1);
79
+ }
80
+ }
81
+ };
82
+ walk(view.parents, 0);
83
+ return found;
84
+ };
85
+ return {
86
+ atoms: visible.map(
87
+ (view): GraphAtom => ({
88
+ id: view.id,
89
+ label: view.name,
90
+ note: note(view),
91
+ read: view.readers > 0,
92
+ status: statusOf(view),
93
+ })
94
+ ),
95
+ links: visible.flatMap((view) => [...parentsOf(view)].map((from) => ({ from, to: view.id }))),
96
+ };
97
+ });
98
+
99
+ // How many updates and interruptions each atom had at the last frame: only later ones animate,
100
+ // so opening the panel doesn't set every atom off at once.
101
+ const updates = new Map<number, number>();
102
+ const interruptions = new Map<number, number>();
103
+ $effect(() => {
104
+ for (const view of atoms) {
105
+ const before = updates.get(view.id);
106
+ if (before !== undefined && view.updates > before) {
107
+ const waiting = view.state._tag !== "Value" && view.state.waiting;
108
+ graph?.pulse(view.id, toneOf(view.state._tag, waiting));
109
+ }
110
+ updates.set(view.id, view.updates);
111
+ const interrupted = interruptions.get(view.id);
112
+ if (interrupted !== undefined && view.interruptions > interrupted) {
113
+ graph?.interrupt(view.id);
114
+ }
115
+ interruptions.set(view.id, view.interruptions);
116
+ }
117
+ });
118
+ </script>
119
+
120
+ <div class="graph-view">
121
+ <AtomGraph
122
+ bind:this={graph}
123
+ empty="No atoms in this registry yet. Read one and it appears here."
124
+ graph={input}
125
+ {onselect}
126
+ {selected}
127
+ />
128
+ </div>
129
+
130
+ <style>
131
+ .graph-view {
132
+ padding: 0.25rem 0.5rem 1rem;
133
+ }
134
+ </style>
@@ -0,0 +1,10 @@
1
+ import type { AtomView } from "./model.svelte.ts";
2
+ interface Props {
3
+ readonly atoms: readonly AtomView[];
4
+ readonly showPlumbing: boolean;
5
+ readonly selected: number | undefined;
6
+ readonly onselect: (id: number) => void;
7
+ }
8
+ declare const GraphView: import("svelte").Component<Props, {}, "">;
9
+ type GraphView = ReturnType<typeof GraphView>;
10
+ export default GraphView;
@@ -0,0 +1,35 @@
1
+ import { Atom } from "effect/reactivity";
2
+ import type { AtomRegistry } from "effect/reactivity";
3
+ /**
4
+ * Names the component being set up, for the inspector scopes its hooks report to: the plugin calls
5
+ * it at the top of each component's instance script.
6
+ */
7
+ export declare const component: (name: string, file: string) => void;
8
+ /**
9
+ * After a hot reload re-runs a module, gives the state atom it declared, in each registry, the
10
+ * value the atom it replaces holds: the one declared before under the same `key` (file and name),
11
+ * if its declaration's `source` is the same. An edited declaration starts from its new value.
12
+ */
13
+ export declare const keepAcrossReloads: (atom: Atom.Atom<unknown>, key: string, source: string, inRegistries?: () => readonly AtomRegistry.AtomRegistry[]) => void;
14
+ /** What the plugin knows about a declaration besides its name and place. */
15
+ interface LabelOptions {
16
+ /** The value is an `Atom.family`: label its members. */
17
+ readonly family?: boolean;
18
+ /** A state atom a module declares, and a hash of its declaration: keep its value across reloads. */
19
+ readonly keep?: string;
20
+ /** Declared inside a function, so a factory's call names it better. */
21
+ readonly local?: boolean;
22
+ }
23
+ /**
24
+ * Labels `value` with `text` and the place it was declared, `at` (`/src/lib/todos.ts:12:14`), if
25
+ * it is an atom, and returns it. For an `Atom.family`, returns a family that labels each member
26
+ * with its argument, as `todoAtom(3)`.
27
+ */
28
+ export declare const label: <T>(value: T, text: string, at: string, options?: LabelOptions) => T;
29
+ /**
30
+ * Wraps a call to an atom factory, `f` (`mapDraftAtom`), so its result, if it is an atom, is named
31
+ * after the call and its arguments: `mapDraftAtom({"doc":1})`. Every call's result is named, so
32
+ * two atoms made for equal keys get the same name; an atom returned again keeps the name it has.
33
+ */
34
+ export declare const call: <F>(f: F, name: string, at: string) => F;
35
+ export {};
@@ -0,0 +1,139 @@
1
+ // What code transformed by the atomLabels Vite plugin calls: the plugin wraps the value of each
2
+ // declaration it labels in `label(value, name, at, options)`, and names each component with
3
+ // `component(name, file)`. The plugin serves this module to the app as is.
4
+ //
5
+ // Only atoms are labelled; anything else passes through untouched, which is what lets the plugin
6
+ // wrap calls without knowing what they return.
7
+ import { nameComponent, registries } from "effect-atom-svelte/inspector";
8
+ import { Atom } from "effect/reactivity";
9
+ /**
10
+ * Names the component being set up, for the inspector scopes its hooks report to: the plugin calls
11
+ * it at the top of each component's instance script.
12
+ */
13
+ export const component = (name, file) => {
14
+ nameComponent(name, file);
15
+ };
16
+ // The kind of each label this module set, to tell which a later one may replace.
17
+ const kinds = new WeakMap();
18
+ // The labels of its own each kind may replace: the more specific name wins. A factory's call,
19
+ // which carries the key, wins over a name made inside the factory; a family's member over both.
20
+ const replaces = {
21
+ call: ["local"],
22
+ declaration: ["local"],
23
+ family: ["local", "call"],
24
+ local: [],
25
+ };
26
+ /**
27
+ * Names an atom in place, keeping its identity: `Atom.withLabel` returns a copy, which would leave
28
+ * any atom that captured the original pointing at an unlabelled one.
29
+ *
30
+ * A label the code gave itself wins. The one `Atom.serializable` falls back to, its key (such as
31
+ * `AtomRpc:listTodos:home-todos` for an RPC query), gives way to the variable's name. Of this
32
+ * module's own labels, a more specific kind replaces a less specific one (`replaces`).
33
+ */
34
+ const setLabel = (atom, text, at, kind) => {
35
+ const current = atom.label;
36
+ const key = Atom.isSerializable(atom)
37
+ ? atom[Atom.SerializableTypeId].key
38
+ : undefined;
39
+ const previous = kinds.get(atom);
40
+ const free = current === undefined || current[0] === key;
41
+ if (!free && !(previous !== undefined && replaces[kind].includes(previous))) {
42
+ return;
43
+ }
44
+ try {
45
+ // The second element is a stack frame, as Effect's own labels hold.
46
+ atom.label = [text, `at ${text} (${at})`];
47
+ kinds.set(atom, kind);
48
+ }
49
+ catch {
50
+ // A frozen atom keeps the label it has.
51
+ }
52
+ };
53
+ /** A family member's argument, short enough for a label. */
54
+ const formatArg = (arg) => {
55
+ let text;
56
+ try {
57
+ text =
58
+ typeof arg === "string"
59
+ ? JSON.stringify(arg)
60
+ : (JSON.stringify(arg) ?? String(arg));
61
+ }
62
+ catch {
63
+ text = String(arg);
64
+ }
65
+ return text.length > 40 ? `${text.slice(0, 39)}…` : text;
66
+ };
67
+ // The last atom declared under each name in each file, with a hash of its declaration.
68
+ const kept = new Map();
69
+ // How long the carried-over value is held for the reloaded components to read it: the registry
70
+ // removes an atom nobody reads on its next tick.
71
+ const holdFor = 1000;
72
+ /**
73
+ * After a hot reload re-runs a module, gives the state atom it declared, in each registry, the
74
+ * value the atom it replaces holds: the one declared before under the same `key` (file and name),
75
+ * if its declaration's `source` is the same. An edited declaration starts from its new value.
76
+ */
77
+ export const keepAcrossReloads = (atom, key, source, inRegistries = registries) => {
78
+ const previous = kept.get(key);
79
+ kept.set(key, { atom: new WeakRef(atom), source });
80
+ const replaced = previous?.atom.deref();
81
+ if (replaced === undefined ||
82
+ replaced === atom ||
83
+ previous?.source !== source ||
84
+ !Atom.isWritable(atom)) {
85
+ return;
86
+ }
87
+ for (const registry of inRegistries()) {
88
+ const node = registry.getNodes().get(replaced);
89
+ if (node?.currentState() !== "valid") {
90
+ continue;
91
+ }
92
+ const release = registry.mount(atom);
93
+ registry.set(atom, node.value());
94
+ setTimeout(release, holdFor);
95
+ }
96
+ };
97
+ /**
98
+ * Labels `value` with `text` and the place it was declared, `at` (`/src/lib/todos.ts:12:14`), if
99
+ * it is an atom, and returns it. For an `Atom.family`, returns a family that labels each member
100
+ * with its argument, as `todoAtom(3)`.
101
+ */
102
+ export const label = (value, text, at, options = {}) => {
103
+ if (Atom.isAtom(value)) {
104
+ setLabel(value, text, at, options.local ? "local" : "declaration");
105
+ if (options.keep !== undefined) {
106
+ keepAcrossReloads(value, `${at.replace(/:\d+:\d+$/u, "")}#${text}`, options.keep);
107
+ }
108
+ }
109
+ else if (options.family && typeof value === "function") {
110
+ const members = value;
111
+ return ((arg) => {
112
+ const member = members(arg);
113
+ if (Atom.isAtom(member)) {
114
+ setLabel(member, `${text}(${formatArg(arg)})`, at, "family");
115
+ }
116
+ return member;
117
+ });
118
+ }
119
+ return value;
120
+ };
121
+ /**
122
+ * Wraps a call to an atom factory, `f` (`mapDraftAtom`), so its result, if it is an atom, is named
123
+ * after the call and its arguments: `mapDraftAtom({"doc":1})`. Every call's result is named, so
124
+ * two atoms made for equal keys get the same name; an atom returned again keeps the name it has.
125
+ */
126
+ export const call = (f, name, at) => {
127
+ if (typeof f !== "function") {
128
+ // Calling it fails as the code would have without the plugin.
129
+ return f;
130
+ }
131
+ const factory = f;
132
+ return ((...args) => {
133
+ const result = factory(...args);
134
+ if (Atom.isAtom(result)) {
135
+ setLabel(result, `${name}(${args.map(formatArg).join(", ")})`, at, "call");
136
+ }
137
+ return result;
138
+ });
139
+ };
@@ -0,0 +1,75 @@
1
+ import type { Event, Inspector, UpdateSource } from "effect-atom-svelte/inspector";
2
+ import type { Atom, AtomRegistry } from "effect/reactivity";
3
+ import type { ValueState } from "./format.ts";
4
+ import type { Identity } from "./names.ts";
5
+ /** An atom as the views show it, at one moment. */
6
+ export interface AtomView {
7
+ readonly id: number;
8
+ readonly atom: Atom.Atom<unknown>;
9
+ /** Its label, or a stand-in for an atom without one. */
10
+ readonly name: string;
11
+ readonly identity: Identity;
12
+ /** Made by a library or runtime rather than declared by the app: it has no label. */
13
+ readonly plumbing: boolean;
14
+ readonly keepAlive: boolean;
15
+ readonly idleTTL: number | undefined;
16
+ /** In the registry now; otherwise removed at `removedAt`. */
17
+ readonly live: boolean;
18
+ readonly removedAt: number | undefined;
19
+ readonly readers: number;
20
+ /** The atoms it read in its last computation. */
21
+ readonly parents: readonly number[];
22
+ /** The atoms that read it. */
23
+ readonly children: readonly number[];
24
+ readonly value: unknown;
25
+ readonly hasValue: boolean;
26
+ readonly state: ValueState;
27
+ readonly updates: number;
28
+ readonly builds: number;
29
+ readonly interruptions: number;
30
+ readonly interruptedAt: number | undefined;
31
+ }
32
+ /** One line of the timeline. */
33
+ export interface TimelineEntry {
34
+ readonly seq: number;
35
+ readonly time: number;
36
+ readonly tag: Event["_tag"];
37
+ readonly atom: number;
38
+ /** What happened, in a few words: `todosAtom changed`, `→ 3`. */
39
+ readonly detail: string;
40
+ /** The atoms the detail names, such as the parents that changed. */
41
+ readonly related: readonly number[];
42
+ readonly source: UpdateSource | undefined;
43
+ }
44
+ /** Counts for the whole registry, for the cover sheet and the launcher. */
45
+ export interface Totals {
46
+ readonly atoms: number;
47
+ readonly plumbing: number;
48
+ readonly readers: number;
49
+ readonly builds: number;
50
+ readonly updates: number;
51
+ readonly interruptions: number;
52
+ readonly finalizers: number;
53
+ readonly states: Readonly<Record<string, number>>;
54
+ }
55
+ /** How long a removed atom stays in the graph, crossed out, before it goes. */
56
+ export declare const lingerFor = 5000;
57
+ export declare class Model {
58
+ #private;
59
+ /** Every atom the registry holds, and those removed a moment ago. */
60
+ atoms: readonly AtomView[];
61
+ timeline: readonly TimelineEntry[];
62
+ totals: Totals;
63
+ /** No atom has a label: the atomLabels plugin isn't installed. */
64
+ unlabelled: boolean;
65
+ /** The registry isn't the implementation the inspector knows, so most events are missing. */
66
+ partial: boolean;
67
+ constructor(inspector: Inspector);
68
+ get registry(): AtomRegistry.AtomRegistry;
69
+ /** Starts following the registry; returns the function that stops. */
70
+ start(): () => void;
71
+ /** Stops updating the timeline the views see, so it can be read; events are still recorded. */
72
+ set paused(paused: boolean);
73
+ get paused(): boolean;
74
+ clearTimeline(): void;
75
+ }