@graphty/graphty-element 2.6.2 → 3.0.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.
Files changed (163) hide show
  1. package/dist/ai.js +3 -3
  2. package/dist/catalog.js +53 -54
  3. package/dist/chunks/{AiManager-4iQpsJW1.js → AiManager-Bhh0rR_p.js} +706 -655
  4. package/dist/chunks/GraphSession-DPoTaT3b.js +21175 -0
  5. package/dist/chunks/{GraphtyLogger-B_O67a6c.js → GraphtyLogger-BtcBJQPL.js} +1 -1
  6. package/dist/chunks/{VoiceInputAdapter-Cc6mHXTI.js → VoiceInputAdapter-CdLsJ_nG.js} +1 -1
  7. package/dist/chunks/{XRPivotCameraController-BLa89LXn.js → XRPivotCameraController-CiLJ9Gz6.js} +2 -2
  8. package/dist/chunks/algorithms-qij74zEN.js +6811 -0
  9. package/dist/chunks/{capability-check-Am2zliFj.js → capability-check-BbgTejS3.js} +1 -1
  10. package/dist/chunks/definePalette-BYt2Llxs.js +1333 -0
  11. package/dist/chunks/fields-5uVC1Pll.js +4999 -0
  12. package/dist/chunks/{format-detection-BHwrAVzW.js → format-detection-FKaDMshR.js} +1 -1
  13. package/dist/chunks/{index-BkBLbvui.js → index-Cc_6D9hV.js} +6034 -7127
  14. package/dist/chunks/interpolation-Dk206AhZ.js +105 -0
  15. package/dist/chunks/paletteRegistry-De3CGdst.js +357 -0
  16. package/dist/chunks/parse-SVp77JbE.js +669 -0
  17. package/dist/chunks/{pluginRegistry-Bs8bEkz9.js → pluginRegistry-Ddfl6Mv2.js} +27 -24
  18. package/dist/chunks/{registry-BdGvyZou.js → registry-CgMqldp4.js} +1 -1
  19. package/dist/chunks/{DataSource-BL2UzPff.js → sources-BbAJCDIH.js} +279 -108
  20. package/dist/commands.d.ts +128 -19
  21. package/dist/commands.js +49 -1
  22. package/dist/custom-elements.json +1 -1
  23. package/dist/extend.d.ts +10 -2
  24. package/dist/extend.js +64 -57
  25. package/dist/graphty-catalog.json +6 -3
  26. package/dist/graphty.bundle.js +267177 -240648
  27. package/dist/graphty.js +84 -78
  28. package/dist/index.d.ts +4 -0
  29. package/dist/logging.js +2 -2
  30. package/dist/schema.js +70 -71
  31. package/dist/session.d.ts +5 -6
  32. package/dist/session.js +40 -86
  33. package/dist/src/Edge.d.ts +31 -67
  34. package/dist/src/Graph.d.ts +335 -77
  35. package/dist/src/Node.d.ts +36 -3
  36. package/dist/src/NodeBehavior.d.ts +28 -0
  37. package/dist/src/Styles.d.ts +15 -4
  38. package/dist/src/acceleration/AccelerationController.d.ts +8 -0
  39. package/dist/src/acceleration/narrow.d.ts +9 -1
  40. package/dist/src/acceleration/types.d.ts +10 -0
  41. package/dist/src/ai/AiController.d.ts +12 -0
  42. package/dist/src/ai/AiManager.d.ts +7 -0
  43. package/dist/src/ai/commands/AlgorithmCommands.d.ts +1 -1
  44. package/dist/src/ai/commands/LayoutCommands.d.ts +1 -1
  45. package/dist/src/ai/commands/StyleCommands.d.ts +1 -1
  46. package/dist/src/ai/commands/types.d.ts +20 -1
  47. package/dist/src/algorithms/Algorithm.d.ts +21 -4
  48. package/dist/src/algorithms/BFSAlgorithm.d.ts +0 -9
  49. package/dist/src/algorithms/BellmanFordAlgorithm.d.ts +0 -14
  50. package/dist/src/algorithms/DFSAlgorithm.d.ts +1 -1
  51. package/dist/src/algorithms/FloydWarshallAlgorithm.d.ts +5 -0
  52. package/dist/src/algorithms/GirvanNewmanAlgorithm.d.ts +5 -0
  53. package/dist/src/algorithms/LeidenAlgorithm.d.ts +5 -0
  54. package/dist/src/algorithms/PageRankAlgorithm.d.ts +1 -1
  55. package/dist/src/algorithms/StronglyConnectedComponentsAlgorithm.d.ts +1 -1
  56. package/dist/src/algorithms/metrics/fields.d.ts +23 -1
  57. package/dist/src/algorithms/utils/graphUtils.d.ts +13 -1
  58. package/dist/src/catalog/paletteRegistry.d.ts +4 -4
  59. package/dist/src/catalog/registry.d.ts +3 -2
  60. package/dist/src/catalog/types.d.ts +18 -1
  61. package/dist/src/config/GraphStyle.d.ts +1 -1
  62. package/dist/src/config/StyleTemplate.d.ts +2 -2
  63. package/dist/src/config/xr-config-schema.d.ts +4 -4
  64. package/dist/src/data/CSVDataSource.d.ts +77 -22
  65. package/dist/src/data/ErrorAggregator.d.ts +5 -0
  66. package/dist/src/data/GEXFDataSource.d.ts +12 -61
  67. package/dist/src/data/GraphMLDataSource.d.ts +3 -44
  68. package/dist/src/data/GraphStore.d.ts +322 -15
  69. package/dist/src/data/JsonDataSource.d.ts +43 -1
  70. package/dist/src/data/graph-io-import.d.ts +89 -0
  71. package/dist/src/data/graph-io-records.d.ts +64 -0
  72. package/dist/src/data/lane.d.ts +23 -0
  73. package/dist/src/data/positions.d.ts +13 -0
  74. package/dist/src/data/seedPosition.d.ts +16 -0
  75. package/dist/src/errors/GraphtyError.d.ts +3 -1
  76. package/dist/src/errors/codes.d.ts +23 -0
  77. package/dist/src/events.d.ts +12 -0
  78. package/dist/src/graphty-element.d.ts +149 -54
  79. package/dist/src/input/types.d.ts +2 -0
  80. package/dist/src/layout/D3GraphLayoutEngine.d.ts +17 -3
  81. package/dist/src/layout/FixedLayoutEngine.d.ts +20 -4
  82. package/dist/src/layout/KamadaKawaiLayoutEngine.d.ts +6 -0
  83. package/dist/src/layout/LayoutEngine.d.ts +214 -116
  84. package/dist/src/layout/NGraphLayoutEngine.d.ts +10 -3
  85. package/dist/src/layout/SimulationLayoutEngine.d.ts +8 -3
  86. package/dist/src/managers/AlgorithmManager.d.ts +24 -5
  87. package/dist/src/managers/DataManager.d.ts +258 -181
  88. package/dist/src/managers/EventManager.d.ts +5 -2
  89. package/dist/src/managers/GraphContext.d.ts +7 -0
  90. package/dist/src/managers/InputManager.d.ts +11 -0
  91. package/dist/src/managers/LayoutManager.d.ts +129 -50
  92. package/dist/src/managers/RenderManager.d.ts +14 -1
  93. package/dist/src/managers/UpdateManager.d.ts +20 -0
  94. package/dist/src/screenshot/ScreenshotCapture.d.ts +1 -1
  95. package/dist/src/session/GraphSession.d.ts +83 -6
  96. package/dist/src/session/commands/algo.d.ts +169 -0
  97. package/dist/src/session/commands/config.d.ts +45 -0
  98. package/dist/src/session/commands/data.d.ts +178 -0
  99. package/dist/src/session/commands/doors.d.ts +93 -0
  100. package/dist/src/session/commands/index.d.ts +20 -0
  101. package/dist/src/session/commands/layout.d.ts +104 -0
  102. package/dist/src/session/commands/positions.d.ts +30 -0
  103. package/dist/src/session/commands/sets.d.ts +113 -0
  104. package/dist/src/session/commands/style.d.ts +92 -0
  105. package/dist/src/session/commands/view.d.ts +57 -0
  106. package/dist/src/session/commands/visibility.d.ts +41 -0
  107. package/dist/src/session/data.d.ts +131 -4
  108. package/dist/src/session/index.d.ts +1 -1
  109. package/dist/src/session/planning.d.ts +25 -8
  110. package/dist/src/session/project/Dispatcher.d.ts +905 -0
  111. package/dist/src/session/project/History.d.ts +382 -0
  112. package/dist/src/session/project/arrangement.d.ts +247 -0
  113. package/dist/src/session/project/derive.d.ts +132 -0
  114. package/dist/src/session/project/digest.d.ts +33 -0
  115. package/dist/src/session/project/draft.d.ts +194 -0
  116. package/dist/src/session/project/graphOps.d.ts +304 -0
  117. package/dist/src/session/project/ingest.d.ts +364 -0
  118. package/dist/src/session/project/state.d.ts +145 -0
  119. package/dist/src/session/project/strict.d.ts +68 -0
  120. package/dist/src/session/results/RunResult.d.ts +48 -0
  121. package/dist/src/session/results/statistics.d.ts +20 -0
  122. package/dist/src/session/runs/Run.d.ts +80 -4
  123. package/dist/src/session/runs/RunsApi.d.ts +23 -6
  124. package/dist/src/session/runs/types.d.ts +25 -6
  125. package/dist/src/session/scope/ElementMask.d.ts +14 -0
  126. package/dist/src/session/scope/ScopeApi.d.ts +3 -22
  127. package/dist/src/session/scope/spaces.d.ts +29 -0
  128. package/dist/src/session/sealed.d.ts +22 -0
  129. package/dist/src/session/selection/SelectionApi.d.ts +14 -4
  130. package/dist/src/session/sets/SetsApi.d.ts +13 -5
  131. package/dist/src/session/sets/store.d.ts +54 -53
  132. package/dist/src/session/sets/types.d.ts +5 -2
  133. package/dist/src/session/styles/Layer.d.ts +5 -0
  134. package/dist/src/session/styles/StylesApi.d.ts +68 -17
  135. package/dist/src/session/styles/autoApply.d.ts +64 -53
  136. package/dist/src/session/styles/index.d.ts +3 -3
  137. package/dist/src/session/styles/predicate.d.ts +7 -0
  138. package/dist/src/session/styles/repaint.d.ts +16 -1
  139. package/dist/src/session/styles/sources.d.ts +1 -1
  140. package/dist/src/session/types.d.ts +625 -54
  141. package/dist/src/session/visibility/VisibilityApi.d.ts +38 -18
  142. package/dist/src/session/visibility/filter.d.ts +10 -0
  143. package/dist/src/simple/defineAlgorithm.d.ts +28 -0
  144. package/dist/src/simple/defineLayout.d.ts +35 -0
  145. package/dist/src/simple/defineLogDestination.d.ts +31 -0
  146. package/dist/src/simple/definePalette.d.ts +26 -0
  147. package/dist/src/simple/definition.d.ts +106 -0
  148. package/dist/src/simple/options.d.ts +33 -0
  149. package/dist/src/simple/source.d.ts +49 -0
  150. package/dist/src/simple/types.d.ts +366 -0
  151. package/dist/src/simple/view.d.ts +107 -0
  152. package/dist/webgpu.js +2 -2
  153. package/package.json +10 -12
  154. package/dist/chunks/GraphSession-BhuHSXIo.js +0 -12819
  155. package/dist/chunks/GraphStyle-Cwr55SAE.js +0 -65
  156. package/dist/chunks/algorithms-BJ6DQMOe.js +0 -3777
  157. package/dist/chunks/detect-fyuVnlCT.js +0 -88
  158. package/dist/chunks/interpolation-DY-PNpqX.js +0 -43
  159. package/dist/chunks/optionsFromZod-CKMYSwTz.js +0 -3636
  160. package/dist/chunks/paletteRegistry-BCFSwJGK.js +0 -1196
  161. package/dist/chunks/parse-BMTqt4SS.js +0 -3658
  162. package/dist/src/data/csv-variant-detection.d.ts +0 -29
  163. package/dist/src/data/ingest.d.ts +0 -104
@@ -0,0 +1,905 @@
1
+ /**
2
+ * @file The one path every change to project state takes.
3
+ *
4
+ * A command is looked up by its op, its arguments are copied and frozen, and it joins a group: a
5
+ * plain dispatch is a group of its own, and a dispatch through a transaction's `tx` joins that
6
+ * transaction's group. An undoable command writes through the group's draft; an exempt command
7
+ * gets no draft at all. When a group seals, its patch becomes one step in the history. When it
8
+ * fails or is cancelled, its writes are reverted through the same `applyBackward` that undo uses,
9
+ * and nothing is recorded. See design/undo/undo-design.md sections 4 to 6.1.
10
+ *
11
+ * Two lanes. An immediate command executes synchronously inside `dispatch`, so a write is visible
12
+ * to a getter as soon as `dispatch` returns. A queued command takes a slot on the session's queue
13
+ * (through a {@link Scheduler}) and executes when its turn comes; until it has committed it is
14
+ * pending work, listed in `pending` and cancellable.
15
+ *
16
+ * Op-log keys (node and edge ids, or a whole `graph` or `pins` slice) cannot be handed from one
17
+ * open group to another the way value keys are, so a group holds the op-log keys it touched until
18
+ * it seals. A command needing a key an open transaction holds fails at once with
19
+ * `E_HELD_BY_TRANSACTION`; one needing a key any other open group holds waits for it, and runs
20
+ * when that group commits or is dropped when it rolls back.
21
+ *
22
+ * Every change reaches the screen through the derivation lane (`./derive.ts`), and is published
23
+ * in one order (design section 9.3): the state changes and a pass is scheduled; `project` and
24
+ * `history` events fire synchronously; the pass runs; the `derived` events (the per-domain
25
+ * events) fire; the caller's promise settles last. Undo, redo and restore act at call time, and
26
+ * one called from inside a listener runs after the current call has returned.
27
+ */
28
+ import type { OperationCategory } from "../../managers/OperationQueueManager";
29
+ import type { LegacyService, RunService } from "../commands/algo";
30
+ import type { DataService } from "../commands/data";
31
+ import type { LayoutAdvice, LayoutService } from "../commands/layout";
32
+ import type { SetService } from "../commands/sets";
33
+ import type { StyleService } from "../commands/style";
34
+ import type { CameraService } from "../commands/view";
35
+ import type { VisibilityService } from "../commands/visibility";
36
+ import type { ProjectConfig } from "../types";
37
+ import { Arrangement } from "./arrangement";
38
+ import { DerivationLane } from "./derive";
39
+ import { type Draft, type Patch } from "./draft";
40
+ import { GraphOps, TouchedIds } from "./graphOps";
41
+ import { History, type HistoryChangeReason } from "./History";
42
+ import { type ProjectState } from "./state";
43
+ /** The part of a command the dispatcher reads: its op. */
44
+ interface CommandLike {
45
+ readonly op: string;
46
+ }
47
+ /** A key a command writes: a whole slice (`styles`, `graph`) or one key of one (`graph/n1`). */
48
+ type SliceKey = string;
49
+ /**
50
+ * The per-session parts a definition's `execute` reaches, such as the style compiler. Each
51
+ * slice's API sets its own part when it is built.
52
+ */
53
+ interface CommandServices {
54
+ data?: DataService;
55
+ /** The arrangement: where `positions.*` write. Always present. */
56
+ positions?: Arrangement;
57
+ runs?: RunService;
58
+ /** A renderer's: constructs a plugin algorithm that has no descriptor, for `algo.legacy`. */
59
+ legacy?: LegacyService;
60
+ styles?: StyleService;
61
+ visibility?: VisibilityService;
62
+ sets?: SetService;
63
+ camera?: CameraService;
64
+ /** The renderer's layout engine and scene: what `layout.set` and `view.dimension` build. */
65
+ layout?: LayoutService;
66
+ /** Which layout suits the graph held now, for an import that asks for one. */
67
+ layoutAdvice?: LayoutAdvice;
68
+ /** The project settings in effect, with every unset key at its default. */
69
+ config?: () => ProjectConfig;
70
+ }
71
+ /** What the queue hands a queued command when its slot comes up. */
72
+ interface SlotContext {
73
+ /** Where the queue's own progress events are written, when the queue publishes any. */
74
+ readonly progress?: {
75
+ setProgress(percent: number): void;
76
+ setMessage(message: string): void;
77
+ setPhase(phase: string): void;
78
+ };
79
+ /** The queue's id for the slot. */
80
+ readonly id?: string;
81
+ }
82
+ /** How one dispatch is made, beyond the command itself. */
83
+ interface DispatchOptions {
84
+ /** Aborting it withdraws the command: off the queue if it waits, stopped if it runs. */
85
+ readonly signal?: AbortSignal;
86
+ /** A queued command that starts at once, beside the queue, instead of taking a slot. */
87
+ readonly beside?: boolean;
88
+ }
89
+ /** Dispatch one command, as a transaction's scope or a deferred member's origin does. */
90
+ export type DispatchFunction = <C extends CommandLike>(command: Dispatchable<C>, options?: DispatchOptions) => Promise<unknown>;
91
+ /** What an undoable command executes with: the state to read, and the draft that writes it. */
92
+ export interface UndoableContext {
93
+ readonly state: ProjectState;
94
+ readonly services: CommandServices;
95
+ /** The group's draft. Read it when writing, after any await: it can change underneath. */
96
+ readonly draft: Draft;
97
+ /** Fires when the command is cancelled or made obsolete; a queued command stops on it. */
98
+ readonly signal: AbortSignal;
99
+ /** What the queue handed the slot; empty for an immediate command or one started beside it. */
100
+ readonly slot: SlotContext;
101
+ /** Settles, never rejecting, once the command has finished and the pass drawing it has run. */
102
+ readonly done: Promise<void>;
103
+ /**
104
+ * Start work on behalf of this command once its group has been recorded, as deferred members
105
+ * of its step: each merges into the step while it is on top. Registered once per key and
106
+ * group, so a batch of two adding commands starts it once. Dropped when the group rolls back.
107
+ * Its arguments: what the work is, so a second registration of it is ignored, and what starts
108
+ * it through the dispatch it is handed.
109
+ */
110
+ readonly after: (key: string, start: (dispatch: DispatchFunction) => void) => void;
111
+ /**
112
+ * Dispatch into this command's own group, now, whatever the dispatched command's lane: what
113
+ * `algo.legacy` hands the plugin it runs, through the graph facade (design section 4.5). The
114
+ * command writes only keys that are free or this group's own; one another group holds fails.
115
+ */
116
+ readonly inline: DispatchFunction;
117
+ }
118
+ /** What an exempt command executes with. No draft, so it cannot write project state. */
119
+ interface ExemptContext {
120
+ readonly state: ProjectState;
121
+ readonly services: CommandServices;
122
+ }
123
+ /** Which lane a command runs on. */
124
+ type Lane<C extends CommandLike> = {
125
+ readonly kind: "immediate";
126
+ } | {
127
+ readonly kind: "queued";
128
+ /** The queue category, which decides the queue's obsolescence rules for it. */
129
+ readonly category: OperationCategory;
130
+ /** For an op whose commands differ (an add, an update, a removal): each one's category. */
131
+ categoryOf?(command: C): OperationCategory;
132
+ /** Two commands with one key collapse into one slot while the first has not started. */
133
+ coalesce?(command: C): string | null;
134
+ };
135
+ /** What every definition declares, whether or not it is undoable. */
136
+ interface DefinitionBase<C extends CommandLike> {
137
+ readonly op: C["op"];
138
+ /**
139
+ * Takes a before-arrangement when it starts (design section 6.4): it sets coordinates on
140
+ * purpose, or holds its slot while a layout can move the lane (a chunked import).
141
+ */
142
+ readonly moves: boolean;
143
+ /** For an op only some of whose commands take one (`clear` among the data mutations). */
144
+ movesWhen?(command: C): boolean;
145
+ /** The keys it will write, known before it runs. */
146
+ keys(command: C, state: ProjectState): readonly SliceKey[];
147
+ readonly lane: Lane<C>;
148
+ /** Changes what is drawn, so its round trip is checked on a renderer as well. */
149
+ readonly draws?: boolean;
150
+ /**
151
+ * The values of its argument's discriminant (each `style.patch` action, each `data.apply`
152
+ * kind), each of which needs its own round-trip fixture. Absent when it has none.
153
+ */
154
+ readonly variants?: readonly string[];
155
+ /**
156
+ * Argument keys kept as the caller's own objects wherever they appear, never copied or
157
+ * frozen (a style layer's `userData`). Everything else is copied and frozen at dispatch.
158
+ */
159
+ readonly byReference?: readonly string[];
160
+ /**
161
+ * For a compound op (`batch`): the commands it is made of. It runs as a transaction of
162
+ * them, one step, and its own `execute` is never called.
163
+ */
164
+ members?(command: C): {
165
+ readonly label: string;
166
+ readonly steps: readonly CommandLike[];
167
+ };
168
+ /** Settling, whether it commits or fails, closes the baseline window (an import). */
169
+ readonly closesBaseline?: boolean;
170
+ /**
171
+ * Carried out only on a renderer, which registers the service it needs: a headless session
172
+ * refuses it, so its round trip is checked on a renderer only.
173
+ */
174
+ readonly renderer?: boolean;
175
+ }
176
+ /** A command that changes project state: one step, labelled. */
177
+ export interface UndoableDefinition<C extends CommandLike> extends DefinitionBase<C> {
178
+ readonly undo: {
179
+ readonly kind: "undoable";
180
+ /** What the step is called in the history ("Changed colour of Hubs"). */
181
+ label(command: C, state: ProjectState): string;
182
+ /** Steps with equal keys recorded close together become one step. */
183
+ coalesce?(command: C): string | null;
184
+ };
185
+ /** Compute first, write last. */
186
+ execute(command: C, ctx: UndoableContext): unknown;
187
+ }
188
+ /** A command that changes nothing a project file saves, and why. */
189
+ export interface ExemptDefinition<C extends CommandLike> extends DefinitionBase<C> {
190
+ readonly undo: {
191
+ readonly kind: "exempt";
192
+ readonly reason: string;
193
+ };
194
+ execute(command: C, ctx: ExemptContext): unknown;
195
+ }
196
+ /**
197
+ * How one op behaves under undo, and what it does. Write a definition against
198
+ * `UndoableDefinition` or `ExemptDefinition`, so `execute` gets the context of its kind.
199
+ */
200
+ export type CommandDefinition<C extends CommandLike> = UndoableDefinition<C> | ExemptDefinition<C>;
201
+ /**
202
+ * A command, or a function from state to one, called at dispatch. The late form is for doors
203
+ * whose meaning depends on state at that moment; history records the concrete command.
204
+ */
205
+ type Dispatchable<C extends CommandLike = CommandLike> = C | ((state: ProjectState) => C);
206
+ /** The handle a transaction's callback dispatches through; what it dispatches joins the step. */
207
+ export interface TransactionScope {
208
+ dispatch<C extends CommandLike>(command: Dispatchable<C>, options?: DispatchOptions): Promise<unknown>;
209
+ /** Nested transactions flatten into the outermost one: `fn` runs with this same scope. */
210
+ transaction<T>(label: string, fn: TransactionBody<T>, options?: TransactionOptions): Promise<T>;
211
+ }
212
+ type TransactionBody<T> = (tx: TransactionScope, signal: AbortSignal) => T | Promise<T>;
213
+ interface TransactionOptions {
214
+ /** Stamped on the recorded step, e.g. `{ via: "assistant" }`. */
215
+ readonly provenance?: Readonly<Record<string, string>>;
216
+ /** Declared at construction: while the baseline window is open it commits into the baseline. */
217
+ readonly setup?: boolean;
218
+ /**
219
+ * A batch's transaction: its members are known when it opens and it settles by itself, so a
220
+ * command needing a key it holds waits for it instead of being refused.
221
+ */
222
+ readonly compound?: boolean;
223
+ /**
224
+ * Takes its before-arrangement when it opens, not at its first graph write: a node drag, whose
225
+ * pointer moves write the lane before anything is dispatched (design section 5.3).
226
+ */
227
+ readonly moves?: boolean;
228
+ }
229
+ /** What moved live project state. */
230
+ type HistoryCause = "command" | "undo" | "redo" | "restore" | "rollback";
231
+ /** A change to live project state. */
232
+ interface ProjectChange {
233
+ readonly slices: readonly string[];
234
+ readonly cause: HistoryCause;
235
+ }
236
+ /** Why the history, or what the next undo will do, changed. */
237
+ type HistoryReason = HistoryChangeReason | "pending";
238
+ /** Where the dispatcher publishes; the session turns these into its events. */
239
+ interface DispatcherEvents {
240
+ /** `project:changed`: synchronously, as soon as the state has changed. */
241
+ project?: (change: ProjectChange) => void;
242
+ /** `history:changed`: synchronously, after `project`. */
243
+ history?: (reason: HistoryReason) => void;
244
+ /** After the derivation pass: the per-domain events. One per step an undo or restore passes. */
245
+ derived?: (change: ProjectChange) => void;
246
+ /** Every command dispatched, as it arrives, before it runs; the doors test spies here. */
247
+ dispatched?: (command: CommandLike) => void;
248
+ /**
249
+ * After an undo, a redo or a restore that touched node or edge ids: the session selects them
250
+ * (design section 8). Not called when the steps touched none, or {@link TouchedIds.skip}.
251
+ */
252
+ touched?: {
253
+ /** The most ids worth selecting. */
254
+ readonly cap: () => number;
255
+ select(ids: TouchedIds): void;
256
+ };
257
+ }
258
+ /** One slot a queued command holds on the queue. */
259
+ interface ScheduledSlot {
260
+ /** Fires when the queue drops or stops the slot, including when `cancel` is called. */
261
+ readonly signal: AbortSignal;
262
+ /** Give the slot up: removed when it has not started, aborted when it has. */
263
+ cancel(): void;
264
+ }
265
+ /** The queue queued commands take their turn on. */
266
+ export interface Scheduler {
267
+ /**
268
+ * Take a slot. The slot is held from the start of `onTurn` until the promise it returns
269
+ * settles. `onTurn` is never called from inside `enqueue`.
270
+ * @param category - The queue category, for the queue's ordering and obsolescence rules.
271
+ * @param onTurn - Called when the slot comes up.
272
+ * @returns The slot.
273
+ */
274
+ enqueue(category: OperationCategory, onTurn: (context?: SlotContext) => Promise<void>, description?: string): ScheduledSlot;
275
+ }
276
+ /** The part of the element's `OperationQueueManager` a scheduler needs. */
277
+ interface OperationQueue {
278
+ queueOperation(category: OperationCategory, execute: (context: SlotContext) => Promise<void>, options?: {
279
+ description?: string;
280
+ }): string;
281
+ getOperationController(operationId: string): AbortController | undefined;
282
+ cancelOperation(operationId: string): boolean;
283
+ }
284
+ /**
285
+ * The scheduler over the session's `OperationQueueManager`: a queued command takes its turn
286
+ * among the loads, layouts and runs already on it, and the queue's obsolescence rules reach it
287
+ * as a cancellation with reason "obsolete".
288
+ * @param queue - The queue.
289
+ * @returns The scheduler.
290
+ */
291
+ export declare function queueScheduler(queue: OperationQueue): Scheduler;
292
+ /** The part of a session's run queue a scheduler needs. */
293
+ interface RunQueueLike {
294
+ queueOperation(category: "algorithm-run", execute: (context: SlotContext & {
295
+ readonly signal: AbortSignal;
296
+ }) => Promise<void> | void, options?: {
297
+ description?: string;
298
+ }): string;
299
+ cancelOperation(operationId: string): boolean;
300
+ }
301
+ /**
302
+ * The scheduler over a headless session's run queue, which has no categories and no
303
+ * obsolescence: a queued command takes its turn among the runs, in the order it was dispatched.
304
+ * @param queue - The queue.
305
+ * @returns The scheduler.
306
+ */
307
+ export declare function runQueueScheduler(queue: RunQueueLike): Scheduler;
308
+ /** Pending undoable work, as the history lists it. Frozen. */
309
+ interface PendingStep {
310
+ readonly id: string;
311
+ readonly label: string;
312
+ /** ISO 8601 of the dispatch. */
313
+ readonly since: string;
314
+ readonly runIds: readonly string[];
315
+ }
316
+ /** What the next undo will do. */
317
+ type NextUndo = {
318
+ readonly kind: "cancel";
319
+ readonly pending: readonly PendingStep[];
320
+ } | {
321
+ readonly kind: "undo";
322
+ readonly step: HistoryStepView;
323
+ } | null;
324
+ /** A recorded step as the history publishes it. */
325
+ type HistoryStepView = History<Patch>["steps"][number];
326
+ /** What an undo, a redo or a restore did. */
327
+ type HistoryOutcome = {
328
+ readonly kind: "undone" | "redone" | "restored";
329
+ readonly steps: readonly HistoryStepView[];
330
+ } | {
331
+ readonly kind: "cancelled";
332
+ readonly pending: readonly PendingStep[];
333
+ } | {
334
+ readonly kind: "nothing";
335
+ };
336
+ /** Why pending work stopped without committing. */
337
+ type CancelReason = "undo" | "redo" | "cancel" | "obsolete" | "rollback";
338
+ /**
339
+ * Why pending work was cancelled, read from the error its signal was aborted with.
340
+ * @param error - The abort reason.
341
+ * @returns The reason, or undefined when the error is not a cancellation of the dispatcher's.
342
+ */
343
+ export declare function cancelReasonOf(error: unknown): CancelReason | undefined;
344
+ interface DispatcherOptions {
345
+ readonly definitions: readonly CommandDefinition<CommandLike>[];
346
+ /** The baseline; an empty project when absent. */
347
+ readonly state?: ProjectState;
348
+ /** The clock of the coalescing window. */
349
+ readonly now?: () => number;
350
+ /** Where changes are published; replaceable later through `events`. */
351
+ readonly events?: DispatcherEvents;
352
+ /** The queue of queued commands: the session's, through {@link queueScheduler}. */
353
+ readonly scheduler?: Scheduler;
354
+ /**
355
+ * Open the baseline window (design section 3.3): until the first graph write records or the
356
+ * first import settles, what commits becomes the baseline instead of a step. A renderer's
357
+ * session opens it, so what the page declared is not undoable.
358
+ */
359
+ readonly baselineWindow?: boolean;
360
+ }
361
+ /** The one mutation path: groups, drafts, rollback, transactions and pending work. */
362
+ export declare class Dispatcher {
363
+ readonly history: History<Patch>;
364
+ /** Where every change is derived to the picture; hooks register here. */
365
+ readonly lane: DerivationLane;
366
+ /** The listeners; the session sets them. */
367
+ readonly events: DispatcherEvents;
368
+ /** What definitions reach besides state; see {@link CommandServices}. */
369
+ readonly services: CommandServices;
370
+ /** The graph primitives over this dispatcher's `graph` and `pins` slices. */
371
+ readonly graph: GraphOps;
372
+ /** Node coordinates at rest: captures, the `arrangement` and `pins` hooks, rest points. */
373
+ readonly arrangement: Arrangement;
374
+ private readonly store;
375
+ private readonly definitions;
376
+ private readonly scheduler;
377
+ private readonly strict;
378
+ private readonly scopes;
379
+ /** Pending groups: queued, waiting, running, open transactions and deferred members. */
380
+ private readonly open;
381
+ /** Which group holds each op-log key. */
382
+ private readonly holders;
383
+ /** The groups holding any key of each op-log slice. */
384
+ private readonly bySlice;
385
+ /** Jobs waiting on a key another group holds. */
386
+ private readonly waiters;
387
+ private readonly steps;
388
+ /** Orders dispatches, records, undos and hold acquisitions against each other. */
389
+ private tick;
390
+ /** Moves whenever the pending list changes. */
391
+ private changes;
392
+ /** Moves whenever a hold is taken, which can change what the next undo does. */
393
+ private holdChanges;
394
+ private pendingCache;
395
+ private nextCache;
396
+ /** `history` reasons not yet published. */
397
+ private readonly reasons;
398
+ /** Above zero while a listener runs: a history call made then waits for a microtask. */
399
+ private emitting;
400
+ /** The ids the steps passed by the history call under way touched; null outside one. */
401
+ private touching;
402
+ /** What an immediate command threw synchronously, for {@link Dispatcher.dispatchNow}. */
403
+ private syncFailure;
404
+ /** Whether commits still become the baseline rather than steps (design section 3.3). */
405
+ private baselineOpen;
406
+ /** Where an untagged dispatch goes during a call through a group-tagged facade; see {@link Dispatcher.routed}. */
407
+ private route;
408
+ /**
409
+ * Stamped on every step as it is recorded, under the step's own provenance: the renderer
410
+ * stamps `xr` while an immersive session is active (design section 5.3).
411
+ */
412
+ ambientProvenance: (() => Readonly<Record<string, string>>) | null;
413
+ /**
414
+ * Create a dispatcher over a state it alone will write.
415
+ * @param options - The definitions, the baseline, the clock, the change listener and the queue.
416
+ */
417
+ constructor(options: DispatcherOptions);
418
+ /**
419
+ * The live project state. Read-only; only commands write it.
420
+ * @returns The state.
421
+ */
422
+ get state(): ProjectState;
423
+ /**
424
+ * Undoable work dispatched and not yet committed, oldest first: queued commands, commands
425
+ * waiting on a key, open transactions and deferred members. The identical array between
426
+ * changes.
427
+ * @returns The frozen list.
428
+ */
429
+ get pending(): readonly PendingStep[];
430
+ /**
431
+ * What the next {@link Dispatcher.undo} will do: cancel pending work, undo a step, or nothing.
432
+ * @returns The frozen answer, identical between changes.
433
+ */
434
+ get nextUndo(): NextUndo;
435
+ /**
436
+ * Dispatch one command as its own step. An immediate command executes before this returns; a
437
+ * queued one when its turn comes.
438
+ * @param command - The command, or a function from state to one.
439
+ * @param options - Its signal, and whether a queued command starts beside the queue.
440
+ * @returns What `execute` returned; rejects with what it threw, after reverting its writes,
441
+ * or with an `AbortError` when it was cancelled.
442
+ */
443
+ dispatch<C extends CommandLike>(command: Dispatchable<C>, options?: DispatchOptions): Promise<unknown>;
444
+ /**
445
+ * A dispatch that goes where one made now would -- to the transaction or running command a
446
+ * routed verb is inside, or to this dispatcher -- for a verb that dispatches after an await,
447
+ * when the routing, which lasts for the synchronous part of the call only, has ended.
448
+ * @returns The dispatch.
449
+ */
450
+ capturedDispatch(): <C extends CommandLike>(command: Dispatchable<C>) => Promise<unknown>;
451
+ /**
452
+ * Whether no group is open: nothing is executing, and no transaction or queued command is
453
+ * waiting to seal. What a minted id not yet sealed is told apart from one a rollback dropped by.
454
+ * @returns True when none is.
455
+ */
456
+ get idle(): boolean;
457
+ /**
458
+ * Whether a call through a group-tagged facade is on the stack, so a door that would take a
459
+ * turn on the operation queue dispatches at once instead: the queue's slot is the running
460
+ * command's own, and waiting for it would never end.
461
+ * @returns True during such a call.
462
+ */
463
+ get routing(): boolean;
464
+ /**
465
+ * Run `fn` with every untagged dispatch, transaction and immediate dispatch it makes routed
466
+ * to `via`. Membership is by origin: the routing lasts for the synchronous part of `fn` only,
467
+ * which is where a door dispatches, so nothing dispatched from anywhere else joins.
468
+ * @param via - Where the dispatches go: a running command's `inline`.
469
+ * @param fn - The call.
470
+ * @returns What `fn` returned.
471
+ */
472
+ routed<T>(via: DispatchFunction, fn: () => T): T;
473
+ /**
474
+ * Run `fn`, and record every command it dispatches through `tx` as one step once it settles
475
+ * and every non-run command it dispatched has executed. Runs still going then are deferred
476
+ * members: each merges into the step when it commits while the step is on top, and records
477
+ * as its own step otherwise.
478
+ *
479
+ * Membership is by origin: a dispatch made any other way while `fn` runs is its own step. If
480
+ * such a dispatch writes a value key the transaction wrote, it takes the key over, so the
481
+ * transaction's rollback leaves it alone; if it needs an op-log key the transaction holds, it
482
+ * fails at once with `E_HELD_BY_TRANSACTION`. If `fn` throws, or the transaction is aborted,
483
+ * everything it wrote is reverted, its pending members are cancelled, nothing is recorded,
484
+ * and the error is rethrown; until `fn` settles, and after, `tx` dispatches reject with an
485
+ * `AbortError`. After a clean settle they reject with `E_TRANSACTION_CLOSED`. A transaction
486
+ * that wrote nothing records nothing.
487
+ * @param label - The step's label.
488
+ * @param fn - The body. `signal` fires when the transaction is aborted.
489
+ * @param options - The provenance stamped on the step.
490
+ * @returns What `fn` returned.
491
+ */
492
+ transaction<T>(label: string, fn: TransactionBody<T>, options?: TransactionOptions): Promise<T>;
493
+ /**
494
+ * Abort an open transaction: revert what it wrote now, cancel its pending members, fire its
495
+ * signal, and reject it. Its `fn` keeps running until it notices, and every `tx` dispatch
496
+ * meanwhile rejects.
497
+ * @param tx - The transaction's scope.
498
+ */
499
+ abort(tx: TransactionScope): void;
500
+ /**
501
+ * Undo, acting on the first of these that applies (design section 6.1):
502
+ * 0. an open group holding an op-log key the top step touched, or holding graph keys taken
503
+ * since the top step was recorded, is aborted, with its dependents;
504
+ * 1. otherwise the newest pending work dispatched after the top step, or deferred from it, is
505
+ * cancelled, with every later-dispatched pending item that shares a key with it;
506
+ * 2. otherwise the top step is undone. Pending work dispatched before it keeps running.
507
+ *
508
+ * Acts at call time; called from inside a listener, it acts after the current call returns.
509
+ * @returns What was done, once the picture has caught up.
510
+ */
511
+ undo(): Promise<HistoryOutcome>;
512
+ /**
513
+ * Redo, by the rules of {@link Dispatcher.undo} checked against the step being redone: only
514
+ * pending work dispatched after that step was undone is cancelled first.
515
+ * @returns What was done, once the picture has caught up.
516
+ */
517
+ redo(): Promise<HistoryOutcome>;
518
+ /**
519
+ * Move to the state just after a step, or to the baseline, as the equivalent sequence of undos
520
+ * or redos: their cancellation rules apply for each step passed, the state changes all at
521
+ * once. Back to the baseline (null) cancels all pending work and aborts every open
522
+ * transaction.
523
+ * @param id - The step, or null for the baseline.
524
+ * @returns What was done, once the picture has caught up.
525
+ */
526
+ restoreTo(id: string | null): Promise<HistoryOutcome>;
527
+ /**
528
+ * Write the baseline: what `write` sets is the state history starts from, recorded as no step
529
+ * and published as no change. Only before anything has been recorded or is pending.
530
+ * @param write - Writes through a draft of its own.
531
+ */
532
+ seed(write: (draft: Draft) => void): void;
533
+ /**
534
+ * Drop every step, cancelling all pending work and aborting every open transaction: the
535
+ * current state becomes the baseline.
536
+ */
537
+ clear(): void;
538
+ /**
539
+ * The command of the newest pending work queued under a queued coalesce key, until it
540
+ * commits: what a door assigned and its getter reads back while the slot waits.
541
+ * @param key - The queued coalesce key.
542
+ * @returns The command, or undefined when nothing under that key is pending.
543
+ */
544
+ pendingCommand(key: string): CommandLike | undefined;
545
+ /**
546
+ * Do one command now, and throw what it throws, for a synchronous door. A queued command
547
+ * starts beside the queue rather than waiting for a turn, as `skipQueue` always did. Routed
548
+ * into a transaction, an immediate command that is refused throws here too, having reverted
549
+ * only its own writes; the transaction goes on.
550
+ * @param command - The command.
551
+ * @returns What `execute` returned.
552
+ */
553
+ dispatchNow<C extends CommandLike>(command: Dispatchable<C>): unknown;
554
+ /**
555
+ * Cancel one pending item, and every later-dispatched pending item that shares a key with it.
556
+ * @param id - The item's id in `pending`.
557
+ * @returns Every item cancelled; empty when the id is not pending.
558
+ */
559
+ cancel(id: string): readonly PendingStep[];
560
+ /**
561
+ * Whether a job's group takes a before-arrangement as it starts: the job's command moves, or
562
+ * it is a transaction's first graph write.
563
+ * @param job - The job starting.
564
+ * @returns True when it does.
565
+ */
566
+ private takesBefore;
567
+ /**
568
+ * Give a group its before-arrangement: where the lane is now (design section 6.4).
569
+ * @param group - The group.
570
+ */
571
+ private takeBefore;
572
+ /**
573
+ * Act now, or after the current call when called from inside a listener, and settle once the
574
+ * pass that derives the change has run.
575
+ * @param act - The history call.
576
+ * @returns Its outcome.
577
+ */
578
+ private historyCall;
579
+ /**
580
+ * One undo or redo, now.
581
+ * @param direction - Which.
582
+ * @returns What was done.
583
+ */
584
+ private move;
585
+ /**
586
+ * One restore, now.
587
+ * @param id - The step, or null for the baseline.
588
+ * @returns What was done.
589
+ */
590
+ private restore;
591
+ /**
592
+ * A collection for the history call starting, when anyone selects what it touched.
593
+ * @returns The collection, or null.
594
+ */
595
+ private startTouching;
596
+ /**
597
+ * Report what a patch the history just applied touched, during a history call.
598
+ * @param patch - The patch.
599
+ */
600
+ private collect;
601
+ /**
602
+ * Stop collecting, and hand what the history call touched to the session to select once the
603
+ * pass that derives the change has run.
604
+ */
605
+ private selectTouched;
606
+ /**
607
+ * Remember when steps were undone, for the redo rules.
608
+ * @param direction - How they were passed.
609
+ * @param steps - The steps.
610
+ */
611
+ private markUndone;
612
+ /**
613
+ * Publish a change: `project` and the pending `history` reasons now, the `derived` events
614
+ * once the pass has run.
615
+ * @param change - What changed, for `project`.
616
+ * @param derived - The per-domain changes, one per step.
617
+ */
618
+ private emit;
619
+ /**
620
+ * Queue a `history` reason, published at the next emit or in a microtask, whichever is first.
621
+ * @param reason - Why.
622
+ */
623
+ private note;
624
+ /** Publish every queued `history` reason, in order. */
625
+ private flushHistory;
626
+ /**
627
+ * Call a listener. A history call it makes waits; what it throws is rethrown unhandled, so
628
+ * it cannot leave the dispatcher half way through a change.
629
+ * @param listener - The call.
630
+ */
631
+ private notify;
632
+ /**
633
+ * The scope a transaction's `fn` dispatches through.
634
+ * @param group - The transaction's group.
635
+ * @returns The scope.
636
+ */
637
+ private scope;
638
+ /**
639
+ * Resolve and freeze one command and send it down its lane, in its own group or in `tx`'s.
640
+ * @param command - The command, or a function from state to one.
641
+ * @param tx - The transaction it joins, or null for a group of its own.
642
+ * @param options - Its signal, and whether a queued command starts beside the queue.
643
+ * @param origin - For a deferred member, the step it belongs to.
644
+ * @returns What an exempt command returned, or the undoable command's promise.
645
+ */
646
+ private submit;
647
+ /**
648
+ * Run a compound command's members as one transaction, or inside the one dispatching it.
649
+ * Every member is dispatched before any is awaited, so immediate members run now, in order.
650
+ * @param label - The step's label.
651
+ * @param steps - The members.
652
+ * @param tx - The transaction it was dispatched in, or null.
653
+ * @param setup - Whether it was declared at construction.
654
+ * @param beside - Whether its queued members start at once, beside the queue, as a
655
+ * synchronous door's must.
656
+ * @returns Settles when every member has.
657
+ */
658
+ private compound;
659
+ /**
660
+ * Execute one command now in a running job's group, whatever its lane: `UndoableContext.inline`.
661
+ * It seals nothing and rolls back only its own writes when it fails; the group seals when the
662
+ * job that dispatched it does.
663
+ * @param command - The command, or a function from state to one.
664
+ * @param parent - The running job.
665
+ * @returns What an exempt command returned, or the command's promise.
666
+ */
667
+ private inline;
668
+ /**
669
+ * A queued job whose slot is not yet started and whose queued coalesce key is `key`.
670
+ * @param key - The queued coalesce key.
671
+ * @param tx - The transaction dispatching, or null.
672
+ * @returns The job, or undefined.
673
+ */
674
+ private queuedWith;
675
+ /**
676
+ * A queued job's turn has come: start it, or put it on the wait list off the queue.
677
+ * @param job - The job.
678
+ * @param context - What the queue handed the slot.
679
+ * @returns Settles when the slot can be given up.
680
+ */
681
+ private turn;
682
+ /**
683
+ * Start a job whose keys are free; make it wait when another group holds one; fail it when a
684
+ * transaction holds one.
685
+ * @param job - The job.
686
+ * @returns Whether it started, failed or waits.
687
+ */
688
+ private admit;
689
+ /**
690
+ * Execute a job with its keys held. Its result settles through `finish` or `fail`.
691
+ * @param job - The job.
692
+ */
693
+ private start;
694
+ /**
695
+ * A job has executed. A transaction member stays in the transaction's draft; any other group
696
+ * seals. A job cancelled meanwhile is ignored: its late value is discarded.
697
+ * @param job - The job.
698
+ * @param value - What `execute` returned.
699
+ */
700
+ private finish;
701
+ /**
702
+ * A job threw, or could not start. A transaction member reverts its own writes; any other
703
+ * group rolls back.
704
+ * @param job - The job.
705
+ * @param error - Why.
706
+ */
707
+ private fail;
708
+ /**
709
+ * The queue dropped or stopped a job's slot (reason "obsolete"), or its dispatcher withdrew
710
+ * it (reason "cancel"). The job's group rolls back, or for a transaction member only the
711
+ * member's own writes.
712
+ * @param job - The job.
713
+ * @param reason - Why.
714
+ */
715
+ private obsolete;
716
+ /**
717
+ * Wait for every non-run member of a closed transaction, including ones dispatched while
718
+ * waiting.
719
+ * @param group - The transaction's group.
720
+ */
721
+ private drain;
722
+ /**
723
+ * Record a transaction, and give each run still going a group of its own: a deferred member
724
+ * of the transaction's step.
725
+ * @param group - The transaction's group.
726
+ */
727
+ private sealTransaction;
728
+ /**
729
+ * Strict: nothing wrote state around the dispatcher since the last check -- the builder
730
+ * behind the `graph` slice, and every typed array state still keeps (design section 12.1).
731
+ */
732
+ private checkStrict;
733
+ /**
734
+ * Record a group's patch as one step, or nothing when it wrote nothing, then release its
735
+ * holds. A deferred member merges into its transaction's step while that step is on top.
736
+ * @param group - The group.
737
+ * @returns The step the patch is in, or null.
738
+ */
739
+ private seal;
740
+ /**
741
+ * Start the work a sealed group registered with `after`, as deferred members of its step.
742
+ * @param group - The group, sealed.
743
+ * @param step - The step it recorded, or null when it recorded none.
744
+ */
745
+ private startDeferred;
746
+ /**
747
+ * Whether a group's writes become the baseline rather than a step (design section 3.3), and
748
+ * close the baseline window at the first graph write. What the page declared at construction
749
+ * is baseline for as long as nothing has been recorded; anything else is while the window is
750
+ * open and it does not write the graph. The first graph write that is not declared is the
751
+ * first step.
752
+ * @param group - The group sealing.
753
+ * @param slices - The slices it wrote.
754
+ * @returns True when it records no step.
755
+ */
756
+ private intoBaseline;
757
+ /**
758
+ * Revert everything a group still holds, and say so when anything live changed.
759
+ * @param group - The group.
760
+ */
761
+ private rollback;
762
+ /**
763
+ * Live writes were reverted: derive them in restore mode, and say so.
764
+ * @param slices - The slices reverted; nothing happens when empty.
765
+ */
766
+ private reverted;
767
+ /**
768
+ * Cancel a group: stop its members, roll it back, and for a transaction, mark it aborted and
769
+ * fire its signal.
770
+ * @param group - The group.
771
+ * @param reason - What the group's caller rejects with: a plain group's job, or the transaction.
772
+ * @param why - Why a transaction's members were stopped, for their own rejections.
773
+ */
774
+ private cancelGroup;
775
+ /**
776
+ * Stop one job: off the queue, off the wait list, its signal fired, its caller rejected. Its
777
+ * writes are its group's to revert.
778
+ * @param job - The job.
779
+ * @param reason - What its caller's promise rejects with.
780
+ */
781
+ private stop;
782
+ /**
783
+ * A graph-writing job has ended, however it ended. When a pass left its paint to a later one
784
+ * while this was waiting or running (`paintOwed`) and nothing is waiting now, the lane is told,
785
+ * so a pass paints what the run wrote -- even when this one wrote nothing.
786
+ * @param job - The job.
787
+ */
788
+ private graphWriteEnded;
789
+ /**
790
+ * Set by the renderer's `graph` hook when a pass left its whole-graph repaint to a later one
791
+ * because a graph write was waiting (`graphWritesWaiting`); cleared once one is scheduled.
792
+ */
793
+ paintOwed: boolean;
794
+ /**
795
+ * Whether a command that writes the graph is dispatched and not finished. The pass deriving a
796
+ * graph write leaves the whole-graph repaint to a pass once none is, so a run of queued adds
797
+ * -- `addEdge` in a loop -- repaints once rather than once per add; the last such command to
798
+ * end, however it ends, schedules that pass (`paintOwed`).
799
+ * @returns True while one is.
800
+ */
801
+ get graphWritesWaiting(): boolean;
802
+ /**
803
+ * Cancel groups, newest first.
804
+ * @param groups - The groups, in dispatch order.
805
+ * @param reason - Why.
806
+ * @returns Their pending views, in dispatch order.
807
+ */
808
+ private cancelAll;
809
+ /**
810
+ * What an undo or a redo will act on (design section 6.1).
811
+ * @param direction - Which.
812
+ * @param target - The step it would pass; by default the one next to the cursor.
813
+ * @returns The groups to cancel, the step to move over, or null for nothing.
814
+ */
815
+ private plan;
816
+ /**
817
+ * The step next to the cursor.
818
+ * @param direction - Which side: the top done step, or the next undone one.
819
+ * @returns The step, or undefined at the end of the history.
820
+ */
821
+ private adjacent;
822
+ /**
823
+ * The groups to cancel with `roots`: every later-dispatched pending group sharing a key with
824
+ * one of them, transitively.
825
+ * @param roots - The groups being cancelled.
826
+ * @returns Them and their dependents, in dispatch order.
827
+ */
828
+ private cascade;
829
+ /**
830
+ * The group holding one of `keys`, other than `self`.
831
+ * @param keys - Op-log keys.
832
+ * @param self - The group asking, whose own holds do not block it.
833
+ * @returns The holder and the key, or null when every key is free.
834
+ */
835
+ private blocker;
836
+ /**
837
+ * Hold op-log keys for a group until it seals or rolls back.
838
+ * @param group - The group.
839
+ * @param keys - The keys.
840
+ */
841
+ private acquire;
842
+ /**
843
+ * Release a group's holds, and wake what waited on them: on commit it runs, on rollback it is
844
+ * dropped.
845
+ * @param group - The group.
846
+ * @param committed - Whether the group sealed rather than rolled back.
847
+ */
848
+ private release;
849
+ /**
850
+ * A new group, with its draft open.
851
+ * @param label - Its label.
852
+ * @param key - Its history coalesce key.
853
+ * @param provenance - Stamped on its step.
854
+ * @param after - The step it is a deferred member of, or null.
855
+ * @param seq - Its dispatch order.
856
+ * @param tx - Its transaction state, for a transaction's group.
857
+ * @param setup - Declared at construction.
858
+ * @param compound - A batch's transaction.
859
+ * @returns The group.
860
+ */
861
+ private group;
862
+ /**
863
+ * A new job, not yet on any lane.
864
+ * @param command - The concrete command.
865
+ * @param keys - Its declared keys.
866
+ * @param definition - Its definition.
867
+ * @param group - The group it writes into.
868
+ * @param queuedKey - Its queued coalesce key.
869
+ * @param inline - Dispatched inline by a running job of its group.
870
+ * @returns The job.
871
+ */
872
+ private job;
873
+ /**
874
+ * List a group as pending.
875
+ * @param group - The group.
876
+ */
877
+ private enter;
878
+ /**
879
+ * Stop listing a group as pending, and mark it done.
880
+ * @param group - The group.
881
+ */
882
+ private leave;
883
+ /**
884
+ * The pending groups in dispatch order.
885
+ * @returns The groups.
886
+ */
887
+ private ordered;
888
+ /**
889
+ * A group as `pending` lists it.
890
+ * @param group - The group.
891
+ * @returns The frozen view.
892
+ */
893
+ private view;
894
+ /**
895
+ * Run `settle` once the change being made now has been derived. The lane is asked at the end
896
+ * of the current synchronous work, when every write of it has been marked.
897
+ * @param settle - What to run.
898
+ */
899
+ private afterPass;
900
+ /** The pending list changed. */
901
+ private changed;
902
+ /** Forget the record times of steps the history no longer has. */
903
+ private prune;
904
+ }
905
+ export {};