@graphty/graphty-element 2.6.1 → 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
@@ -2,6 +2,7 @@ import type { Scene } from "@babylonjs/core";
2
2
  import type { AccelerationController } from "../acceleration";
3
3
  import type { XRConfig } from "../config/XRConfig";
4
4
  import type { MeshCache } from "../meshes/MeshCache";
5
+ import type { GraphSession } from "../session/types";
5
6
  import type { Styles } from "../Styles";
6
7
  import type { XRSessionManager } from "../xr/XRSessionManager";
7
8
  import type { DataManager } from "./DataManager";
@@ -36,6 +37,12 @@ export interface GraphContext {
36
37
  * Get the DataManager for node/edge operations
37
38
  */
38
39
  getDataManager(): DataManager;
40
+ /**
41
+ * Get the session whose state this graph draws, when there is one: what a node's own doors
42
+ * dispatch through.
43
+ * @returns The session, or undefined for a context built without one.
44
+ */
45
+ getSession?(): GraphSession;
39
46
  /**
40
47
  * Get the LayoutManager for layout operations
41
48
  */
@@ -36,6 +36,17 @@ export interface InputManagerConfig {
36
36
  */
37
37
  recordInput?: boolean;
38
38
  playbackFile?: string;
39
+ /**
40
+ * Whether Mod+Z undoes and Shift+Mod+Z or Mod+Y redoes, through {@link InputManagerConfig.history}.
41
+ * On by default. A handled key has its default prevented, so a host binding the same keys
42
+ * skips events with `defaultPrevented` set.
43
+ */
44
+ historyKeys?: boolean;
45
+ /** What the history keys call: the graph's session. */
46
+ history?: {
47
+ undo(): unknown;
48
+ redo(): unknown;
49
+ };
39
50
  }
40
51
  /**
41
52
  * Manages all user input for the graph
@@ -5,6 +5,7 @@ import type { Edge } from "../Edge";
5
5
  import { LayoutEngine } from "../layout/LayoutEngine";
6
6
  import { type SimulationEngineOptions } from "../layout/SimulationLayoutEngine";
7
7
  import type { Node, NodeIdType } from "../Node";
8
+ import type { LayoutChoice } from "../session/project/state";
8
9
  import type { Styles } from "../Styles";
9
10
  import type { DataManager } from "./DataManager";
10
11
  import type { EventManager } from "./EventManager";
@@ -33,6 +34,25 @@ import type { Manager } from "./interfaces";
33
34
  * @throws A `ZodError` when an option is outside the range its published schema declares.
34
35
  */
35
36
  export declare function resolveSimulationOptions(type: SimulationType, options: Record<string, unknown>, behavior: GraphLayoutBehavior): SimulationEngineOptions;
37
+ /**
38
+ * The element's own reach into a layout manager, past its public surface: `Graph` registers the
39
+ * `layout` hook, and a standalone manager test builds or installs an engine outside the `layout`
40
+ * slice. No entry point exports it; a consumer chooses a layout with `session.layout.set`.
41
+ */
42
+ export declare const layoutManagerInternals: {
43
+ /** The `layout` hook; see `LayoutManager.apply`. */
44
+ apply(manager: LayoutManager, choice: LayoutChoice, options: {
45
+ readonly restoring: boolean;
46
+ readonly signal?: AbortSignal;
47
+ readonly explicitScope?: boolean;
48
+ }): Promise<void>;
49
+ /** Build an engine outside the `layout` slice; see `LayoutManager.setLayout`. */
50
+ setLayout(manager: LayoutManager, type: string, opts?: object, scope?: ScopeInput): Promise<void>;
51
+ /** Take the members a scoped layout built over an empty graph owes; see `LayoutManager.takeOwedMembers`. */
52
+ takeOwedMembers(manager: LayoutManager): void;
53
+ /** Install an engine, or none, as a standalone test's stand-in for a build. */
54
+ setEngine(manager: LayoutManager, engine: LayoutEngine | undefined): void;
55
+ };
36
56
  /**
37
57
  * What a layout manager reads of the session to scope a layout. `Graph` hands its session's in.
38
58
  */
@@ -63,10 +83,17 @@ interface LayoutScopeSource {
63
83
  * Coordinates layout updates and transitions
64
84
  */
65
85
  export declare class LayoutManager implements Manager {
86
+ #private;
66
87
  private eventManager;
67
88
  private dataManager;
68
89
  private styles;
69
- layoutEngine?: LayoutEngine;
90
+ /** The engine drawing the graph, built by the `layout` hook. */
91
+ private engine?;
92
+ /**
93
+ * The engine drawing the graph, read-only: choose a layout with `session.layout.set`.
94
+ * @returns The engine, or undefined before the first build.
95
+ */
96
+ get layoutEngine(): LayoutEngine | undefined;
70
97
  private _running;
71
98
  /**
72
99
  * Set while a CONSUMER has paused the layout, through {@link LayoutManager.setPaused}. Nothing
@@ -81,12 +108,27 @@ export declare class LayoutManager implements Manager {
81
108
  * {@link LayoutManager.runPreStepsOnceThereIsSomethingToStep}.
82
109
  */
83
110
  private preStepsOwed;
111
+ /**
112
+ * Set when a scoped layout was built over a graph with nothing in it: its members are taken
113
+ * again when the first node arrives, which is when the layout really starts. A scope captured
114
+ * over an empty graph holds nothing it names, so it would hold every node that arrives.
115
+ */
116
+ private membersOwed;
84
117
  /**
85
118
  * The dimension the running engine was built for, so a view mode that already matches it
86
- * does not rebuild the layout. See {@link LayoutManager.updateLayoutDimension}.
119
+ * does not rebuild the layout. See {@link LayoutManager.apply}.
87
120
  */
88
121
  private engineDimension?;
89
122
  private logger;
123
+ /** Told when the layout comes to rest: it settled, was paused, or finished placing. */
124
+ onRest: (() => void) | null;
125
+ /**
126
+ * Whether undo, redo or a restore is on its way to the position array. While it is, a new
127
+ * snapshot or accelerator reloads the engine without starting it, so nothing moves the
128
+ * arrangement being restored.
129
+ * @returns True while one is.
130
+ */
131
+ restoring: () => boolean;
90
132
  /** Where a scope is canonicalised and resolved, once `Graph` has a session to hand in. */
91
133
  private scopeSource;
92
134
  /**
@@ -101,6 +143,18 @@ export declare class LayoutManager implements Manager {
101
143
  * outside it is held, including one that arrives later.
102
144
  */
103
145
  private members;
146
+ /**
147
+ * Strict state: something asked to step the layout while the lane was restoring, which only a
148
+ * forward change may. Refused either way; strict state reports it, because the caller is
149
+ * running outside the derivation lane's order.
150
+ * @param what - What asked.
151
+ */
152
+ private reportRestoringStep;
153
+ /**
154
+ * Whether a layout is being built now, spending its own pre-steps.
155
+ * @returns True while one is.
156
+ */
157
+ get building(): boolean;
104
158
  /**
105
159
  * Gets the running state of the layout
106
160
  * @returns True if layout is running, false otherwise
@@ -170,13 +224,6 @@ export declare class LayoutManager implements Manager {
170
224
  * @param event - The freeze, carrying the snapshot every consumer must switch to.
171
225
  */
172
226
  private onSnapshotReplaced;
173
- /**
174
- * Forget the cleared graph: stop the engine and build a fresh one of the same type with the
175
- * consumer's own options, so the next load lays out from scratch instead of inheriting the old
176
- * engine's bodies and its settled state. A failure is already reported on the error channel
177
- * by `_setLayoutInternal`, which also leaves the old engine in place.
178
- */
179
- private reset;
180
227
  /**
181
228
  * Report a failure that happened to a layout already running, on the element's error channel.
182
229
  * @param error - Whatever was thrown.
@@ -201,8 +248,7 @@ export declare class LayoutManager implements Manager {
201
248
  * Used by operations that are already queued to prevent nested queueing
202
249
  * @param layout - A registered engine name, or a catalogue layout id
203
250
  * @param opts - Layout-specific options
204
- * @param explicitScope - Whether the carried scope was named in this call, which is the only
205
- * case in which a scope the engine cannot use, or cannot resolve, is refused
251
+ * @param how - The dimension, whether this is a restore, and whether the build is still wanted.
206
252
  */
207
253
  private _setLayoutInternal;
208
254
  /**
@@ -221,10 +267,26 @@ export declare class LayoutManager implements Manager {
221
267
  * BEFORE IT PINS, because `D3GraphLayoutEngine.pin` copies the node's CURRENT simulated
222
268
  * position into the fixed-position fields: a bare pin replayed into a fresh engine would nail
223
269
  * the node to d3's arbitrary starting coordinates instead of where the reader put it.
270
+ *
271
+ * A 2D ENGINE GETS THE PIN ON THE PLANE. A node pinned in 3D keeps its Z in the position
272
+ * array, and a 2D engine handed that Z keeps it: the node is drawn where the orthographic
273
+ * camera hides the Z, but each of its edges is a flat quad whose length is the 3D distance, so
274
+ * every edge of the pinned node ran past it into empty space. Clicking a node pins it
275
+ * (`pinOnDrag`), so selecting a node and switching to 2D was enough. The X and Y are kept.
224
276
  * @param engine - the engine that is about to become current
225
277
  * @param nodes - every node in the graph, which is what was just added to that engine
226
278
  */
227
279
  private replayPins;
280
+ /**
281
+ * A stored position as the current engine can hold it: on the Z = 0 plane for a 2D engine.
282
+ * See `replayPins`; a node held out of a scoped layout carries its Z into 2D the same way.
283
+ * @param at - The position read from the array.
284
+ * @param at.x - Its X, kept.
285
+ * @param at.y - Its Y, kept.
286
+ * @param at.z - Its Z, kept by a 3D engine only.
287
+ * @returns The position to hand the engine.
288
+ */
289
+ private onEnginePlane;
228
290
  /**
229
291
  * Log a layout failure, tell the consumer about it, and say what to throw.
230
292
  *
@@ -255,7 +317,54 @@ export declare class LayoutManager implements Manager {
255
317
  * @throws A `GraphtyError` with `E_UNSUPPORTED` for a scope on an engine that is not scoped,
256
318
  * or `E_BAD_COMMAND` for a scope that is malformed or names a removed set.
257
319
  */
258
- setLayout(type: string, opts?: object, scope?: ScopeInput): Promise<void>;
320
+ private setLayout;
321
+ /**
322
+ * Whether the engine is built, or being built, for exactly this value of the `layout` slice.
323
+ * Compared by identity: a `layout.set` writes a new value even for the same layout, which is
324
+ * how asking for the same layout again runs it again.
325
+ * @param choice - The value.
326
+ * @returns True when nothing needs building for it.
327
+ */
328
+ isCurrent(choice: LayoutChoice): boolean;
329
+ /**
330
+ * The `layout` hook: bring the engine to a value of the `layout` slice. A new layout or new
331
+ * options build a new engine; a new dimension rebuilds the engine only when the layout draws
332
+ * differently in two dimensions than in three. Builds run one at a time.
333
+ * @param choice - The value.
334
+ * @param options - How: `restoring` for undo, redo, a restore or a rollback (no pre-steps,
335
+ * nothing published, left at rest); `signal` stops the build, publishing nothing, when
336
+ * the command that asked for it is cancelled or overtaken.
337
+ * @param options.restoring - Whether this is a restore.
338
+ * @param options.signal - The asking command's signal.
339
+ * @param options.explicitScope - Whether the asking command named the scope.
340
+ * @returns Settles once the engine is built and its pre-steps have landed.
341
+ */
342
+ private apply;
343
+ /**
344
+ * Build what {@link LayoutManager.apply} asked for, when it differs from what is built.
345
+ * @param choice - The value.
346
+ * @param options - How.
347
+ * @param options.restoring - Whether this is a restore.
348
+ * @param options.signal - The asking command's signal.
349
+ * @param options.explicitScope - Whether the asking command named the scope.
350
+ * @param generation - The arrangement generation it was asked for under.
351
+ */
352
+ private build;
353
+ /**
354
+ * Hand the engine the coordinates the `arrangement` hook has just written. After a restore,
355
+ * the pre-steps of any build still computing from the coordinates it held before are dropped.
356
+ *
357
+ * A 2D ENGINE THEN PUTS EVERY NODE BACK ON THE PLANE, for the reason `replayPins` does: a Z
358
+ * written while the view is 2D -- a script's `positions.set`, a restore -- is hidden by the
359
+ * camera but drawn by the node's edges. The engine publishes the flattened row like any move.
360
+ * @param restoring - Whether undo, redo, a restore or a rollback wrote them.
361
+ */
362
+ loadArrangement(restoring: boolean): void;
363
+ /**
364
+ * The dimension the current engine was built for.
365
+ * @returns 2 or 3, or undefined before any engine is built.
366
+ */
367
+ get dimension(): 2 | 3 | undefined;
259
368
  /**
260
369
  * Hand the manager the session it resolves scopes through.
261
370
  * @param source - The session's canonicaliser and resolver.
@@ -268,21 +377,6 @@ export declare class LayoutManager implements Manager {
268
377
  * @internal
269
378
  */
270
379
  get scope(): Scope | undefined;
271
- /**
272
- * Change the carried scope without starting a layout. The next layout, and
273
- * {@link LayoutManager.rescope}, run over it. It never refuses a scope that cannot be resolved:
274
- * a carried scope that means nothing is inactive.
275
- * @param scope - The scope; undefined or `"graph"` for the whole graph.
276
- * @throws A `GraphtyError` with `E_BAD_COMMAND` when it is not a scope.
277
- * @internal
278
- */
279
- carryScope(scope: ScopeInput | undefined): void;
280
- /**
281
- * Restart the running layout, with its options, over the carried scope.
282
- * @returns A promise that resolves once the layout has restarted; at once when none is set.
283
- * @internal
284
- */
285
- rescope(): Promise<void>;
286
380
  /**
287
381
  * The layout as a user of the sets it names, for "Used by": present only while a layout
288
382
  * is actually holding nodes for its scope.
@@ -350,7 +444,9 @@ export declare class LayoutManager implements Manager {
350
444
  * awaited one chunk at a time, the chunk being the largest batch the GPU package takes, and
351
445
  * every other engine keeps the plain loop, whose `step()` returns having done the work.
352
446
  * @param engine - the engine to settle.
353
- * @returns A promise that resolves once every pre-step has been taken and published.
447
+ * @param live - Asked after every await: false once the build that spends them is cancelled or
448
+ * overtaken, or the arrangement was restored since, and then nothing is published.
449
+ * @returns True once every pre-step has been taken and published; false when stopped.
354
450
  */
355
451
  private spendPreSteps;
356
452
  /**
@@ -374,6 +470,11 @@ export declare class LayoutManager implements Manager {
374
470
  * guarantees for one is that every owed iteration is computed rather than coalesced away.
375
471
  */
376
472
  private runPreStepsOnceThereIsSomethingToStep;
473
+ /**
474
+ * Take the members a scoped layout built over an empty graph owes, once nodes have arrived:
475
+ * the layout starts now, over the nodes its scope names among them.
476
+ */
477
+ private takeOwedMembers;
377
478
  /**
378
479
  * Step the layout engine forward
379
480
  */
@@ -421,28 +522,6 @@ export declare class LayoutManager implements Manager {
421
522
  * @returns Current layout type identifier or undefined if no layout is set
422
523
  */
423
524
  get layoutType(): string | undefined;
424
- /**
425
- * Update layout dimension when 2D/3D mode changes
426
- * @param twoD - Whether to use 2D mode
427
- */
428
- updateLayoutDimension(twoD: boolean): Promise<void>;
429
- /**
430
- * Apply layout from style template if specified
431
- * @param layoutType - Layout type identifier from template
432
- * @param layoutOptions - Layout options from template
433
- */
434
- applyTemplateLayout(layoutType?: string, layoutOptions?: object): Promise<void>;
435
- /**
436
- * What the consumer last asked this layout for, with the element's own dimension options left
437
- * out. It is what a 2D/3D rebuild starts from, and what a template's options are compared to.
438
- */
439
- private currentLayoutOptions?;
440
- /**
441
- * Check if layout options have changed
442
- * @param newOptions - New layout options to compare
443
- * @returns True if options have changed, false otherwise
444
- */
445
- private hasOptionsChanged;
446
525
  /**
447
526
  * Get layout statistics
448
527
  * @returns Object containing layout statistics
@@ -1,5 +1,6 @@
1
1
  import { Engine, Scene, TransformNode, WebGPUEngine } from "@babylonjs/core";
2
2
  import { CameraManager } from "../cameras/CameraManager";
3
+ import type { GraphBackgroundConfig } from "../config/GraphStyle";
3
4
  import type { EventManager } from "./EventManager";
4
5
  import type { Manager } from "./interfaces";
5
6
  /**
@@ -25,6 +26,8 @@ export declare class RenderManager implements Manager {
25
26
  /** How many callers currently hold the frames back; see {@link holdFrames}. */
26
27
  private frameHolds;
27
28
  private resizeHandler;
29
+ /** The one skybox dome, and the image it shows; null while the background is a colour. */
30
+ private dome;
28
31
  /**
29
32
  * Stands in for Babylon's own pointer handling, which calls preventDefault and then
30
33
  * `canvas.focus()` on every pointer down and up. That focus call scrolls the host page to the
@@ -75,11 +78,21 @@ export declare class RenderManager implements Manager {
75
78
  * @returns Releases this hold.
76
79
  */
77
80
  holdFrames(): () => void;
81
+ /**
82
+ * Draw the graph against a background: a clear colour, or a photo-dome skybox.
83
+ *
84
+ * The scene holds at most one dome. A colour disposes it; a different skybox replaces it; the
85
+ * skybox already shown is left alone, so drawing the same background again (a redo, a repeat)
86
+ * builds nothing.
87
+ * @param background - The background, parsed.
88
+ * @param onSkyboxLoaded - Called with the image once a new skybox's texture has arrived.
89
+ */
90
+ applyBackground(background: GraphBackgroundConfig, onSkyboxLoaded: (url: string) => void): void;
78
91
  /**
79
92
  * Update the background color
80
93
  * @param color - Hex color string (e.g., "#FFFFFF")
81
94
  */
82
- setBackgroundColor(color: string): void;
95
+ private setBackgroundColor;
83
96
  /**
84
97
  * Get current render statistics
85
98
  * @returns Current FPS and active mesh count
@@ -303,6 +303,19 @@ export declare class UpdateManager implements Manager {
303
303
  * @returns True when the last drawn frame drew the finished picture.
304
304
  */
305
305
  get frameIsStable(): boolean;
306
+ /**
307
+ * Say that meshes were built outside a pass that moves anything, so the finished picture has
308
+ * to be earned again.
309
+ *
310
+ * A new mesh can bring a shader variant nothing has compiled, or a texture still loading, and
311
+ * a frame skips a mesh that is not ready. Most doors that build meshes also move something -- a
312
+ * load starts the layout, a forward dimension change frames the camera -- and that clears the
313
+ * finished flags on the next pass. An undo of a dimension change moves nothing, because the
314
+ * layout stays at rest and the camera is the reader's; nor does a skybox. Without this the
315
+ * last finished frame would still be called final while the new meshes are drawn as nothing:
316
+ * an empty canvas after undoing 2D to 3D, and the old background after setting a skybox.
317
+ */
318
+ meshesAdded(): void;
306
319
  /**
307
320
  * What is still keeping the picture from being final, in a consumer's words.
308
321
  *
@@ -396,6 +409,13 @@ export declare class UpdateManager implements Manager {
396
409
  * no placed nodes has not settled, it has not started.
397
410
  */
398
411
  private largestMove;
412
+ /**
413
+ * Move every node and edge to where the position array has it now, without stepping the
414
+ * layout: how a restored arrangement reaches the picture while the layout is at rest.
415
+ * @param moved - Whether any coordinate was written; when none was, the nodes are placed and
416
+ * the edges, whose endpoints are where they were, are left as they are drawn.
417
+ */
418
+ redrawArrangement(moved?: boolean): void;
399
419
  /**
400
420
  * Update all nodes.
401
421
  */
@@ -1,5 +1,5 @@
1
1
  import { type Engine, type Scene, type WebGPUEngine } from "@babylonjs/core";
2
- import type { Graph } from "../Graph.js";
2
+ import { type Graph } from "../Graph.js";
3
3
  import type { ScreenshotOptions, ScreenshotResult } from "./types.js";
4
4
  /**
5
5
  * Handles screenshot capture for graph visualizations using Babylon.js rendering engine.
@@ -11,11 +11,87 @@
11
11
  * entry point's import graph and fails if a renderer appears in it.
12
12
  */
13
13
  import type { RuleTree, Scope } from "../catalog/types";
14
+ import type { ElementPositions } from "../data/positions";
14
15
  import { type InputCounters } from "./attributes";
16
+ import { Dispatcher, type Scheduler } from "./project/Dispatcher";
17
+ import { type SessionRunsApi } from "./runs";
15
18
  import { type ScopeResolver } from "./scope";
16
19
  import { SetsNotifier } from "./sets/notify";
17
20
  import type { SetsApi, SetUser } from "./sets/types";
18
- import type { CreateGraphSessionOptions, ElementSession, GraphSession } from "./types";
21
+ import type { CreateGraphSessionOptions, ElementSession, GraphSession, SessionDataConfig, SessionGraphStore, SessionRecordSource } from "./types";
22
+ /**
23
+ * A store with its coordinate lane writable: what the arrangement hook restores coordinates and
24
+ * pins into. The element's data manager is one; a consumer only ever sees the read-only form.
25
+ * @internal
26
+ */
27
+ export interface LaneStore extends Omit<SessionGraphStore, "positions"> {
28
+ /** The lane itself. */
29
+ readonly positions: ElementPositions;
30
+ /** Whether structural changes wait for the next read of the graph; see `GraphStore.deferring`. */
31
+ readonly deferring?: boolean;
32
+ /** Whether the next read of the graph would freeze a snapshot; see `GraphStore.stale`. */
33
+ readonly stale?: boolean;
34
+ /**
35
+ * The attribute revisions and input tick of whoever builds the stores (design/sets 6.2): the
36
+ * data manager's, the same across a Clear. Absent, the store's own.
37
+ */
38
+ readonly inputs?: InputCounters;
39
+ }
40
+ /**
41
+ * What the element's own session takes beyond {@link CreateGraphSessionOptions}: the data
42
+ * manager's store, whose only writer is the dispatcher, a record source, and a data configuration
43
+ * read live. No entry point exports it.
44
+ * @internal
45
+ */
46
+ export interface ElementSessionOptions extends Omit<CreateGraphSessionOptions, "config"> {
47
+ /** The store to read. When absent the session builds one of its own and disposes it. */
48
+ readonly store?: LaneStore;
49
+ /** Where to read the attributes a record arrived with, for rows the graph slice lacks. */
50
+ readonly records?: SessionRecordSource;
51
+ /** The configuration; `data` may be a function, read on every use. */
52
+ readonly config?: Omit<NonNullable<CreateGraphSessionOptions["config"]>, "data"> & {
53
+ readonly data?: SessionDataConfig | (() => SessionDataConfig);
54
+ };
55
+ }
56
+ /**
57
+ * What the element's own tests hand a session besides its options: the clock of the coalescing
58
+ * window and the queue queued commands take their turn on, so a random sequence can drive both.
59
+ */
60
+ interface SessionInternals {
61
+ readonly now?: () => number;
62
+ readonly scheduler?: Scheduler;
63
+ /** Open the baseline window: what the page declared at construction is not undoable. */
64
+ readonly baselineWindow?: boolean;
65
+ }
66
+ /**
67
+ * The runs API behind a session, with `startVia`: how the renderer starts the on-load runs as
68
+ * deferred members of the command that added the rows. Not published.
69
+ * @param session - A session this module built.
70
+ * @returns Its runs API.
71
+ */
72
+ export declare function sessionRunsOf(session: GraphSession): SessionRunsApi;
73
+ /**
74
+ * Hand a session's repaint after a data change to the renderer drawing it, which repaints once
75
+ * it has reconciled its own objects. Only the element calls it, before registering its own
76
+ * `graph` hook; without it a session repaints by itself.
77
+ * @param session - A session this module built.
78
+ */
79
+ export declare function handGraphPaintToRenderer(session: GraphSession): void;
80
+ /**
81
+ * The coordinate lane behind a session, writable: what a layout engine writes every frame, and
82
+ * what a test standing in for one writes. Not published; a consumer places nodes through
83
+ * `session.positions.set`.
84
+ * @param session - A session this module built.
85
+ * @returns Its lane.
86
+ */
87
+ export declare function laneOf(session: GraphSession): ElementPositions;
88
+ /**
89
+ * The dispatcher behind a session. Not published: the element's own tests spy on it and read the
90
+ * project state it holds.
91
+ * @param session - A session this module built.
92
+ * @returns Its dispatcher.
93
+ */
94
+ export declare function dispatcherOf(session: GraphSession): Dispatcher;
19
95
  /**
20
96
  * Build a graph session.
21
97
  *
@@ -23,10 +99,10 @@ import type { CreateGraphSessionOptions, ElementSession, GraphSession } from "./
23
99
  * accelerator, disposed with it. That is the headless case -- a CI job, a Node test, a check on
24
100
  * a server -- and it needs no canvas, no GPU and no DOM.
25
101
  *
26
- * Handed a store, it reads that one instead and disposes nothing that arrived from outside. That
27
- * is how a rendered graph gets a session: the element's data manager already owns one store for
28
- * the life of the graph, and a second one would be a second, disagreeing copy.
29
- * @param options - the store, the record source, the configuration and the accelerator, each
102
+ * The session is the only writer of its graph and settings, which is what makes every change an
103
+ * undoable step: data arrives through `session.data.import`, `addNodes` and `addEdges`, and
104
+ * settings through `session.config.set`.
105
+ * @param options - the starting configuration, the accelerator and how runs execute, each
30
106
  * optional
31
107
  * @returns the session
32
108
  * @example
@@ -47,9 +123,10 @@ export declare function createGraphSession(options?: CreateGraphSessionOptions):
47
123
  * the difference is a shape one, and it exists because a renderer tests one element at a time
48
124
  * where a consumer reads a list of ids.
49
125
  * @param options - The store, the record source, the configuration and the accelerator.
126
+ * @param internals - The history clock and queue, which only the element's own tests replace.
50
127
  * @returns The session.
51
128
  */
52
- export declare function createElementSession(options?: CreateGraphSessionOptions): ElementSession;
129
+ export declare function createElementSession(options?: ElementSessionOptions, internals?: SessionInternals): ElementSession;
53
130
  /** What names a set from outside the session, for `usedBy`. */
54
131
  type SetsUsersProvider = () => Iterable<{
55
132
  readonly user: SetUser;