@graphty/graphty-element 2.6.2 → 3.0.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 (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,113 @@
1
+ /**
2
+ * @file The kept-set ops: `set.create`, `set.rename`, `set.redefine`, `set.members`, `set.remove`
3
+ * and `set.restore`. Each is one undoable step on the `sets` slice, keyed `sets/<id>`, on the
4
+ * immediate lane, so the slice is written before the dispatch returns.
5
+ *
6
+ * The bodies are the pure prepare functions of `session/sets/prepare.ts`, reached through the
7
+ * session's set service, which also refuses a rule the doors cannot keep (a cycle, the live
8
+ * selection). A prepare that finds nothing to change writes nothing, so no step is recorded.
9
+ *
10
+ * `set.create` as a consumer sends it carries a definition and a name only. The element's own
11
+ * doors mint the id and the order before they dispatch, and say what the set was created from,
12
+ * so the recorded command carries all three; a redo replays the recorded patch and never mints.
13
+ * The register of issued ids, the order high-water mark, the tombstones and the edge seeds sit
14
+ * beside the slice and are never rewound (design/sets/undo-integration.md section 1).
15
+ *
16
+ * See design/undo/undo-design.md section 11.3.
17
+ */
18
+ import type { SetCreatedFrom, SetDefinitionInput, SetId } from "../../catalog/types";
19
+ import type { UndoableDefinition } from "../project/Dispatcher";
20
+ import type { ElementSet, SetMemberDelta } from "../sets/types";
21
+ /** `set.create`: keep a definition as a new set. */
22
+ interface SetCreateCommand {
23
+ readonly op: "set.create";
24
+ /** What the set holds: a fixed list, a rule or a path. Edges may be named by session id. */
25
+ readonly definition: SetDefinitionInput;
26
+ /** Its name; "Set N" (the smallest free N) when absent. */
27
+ readonly name?: string;
28
+ }
29
+ /**
30
+ * `set.create` as the element's own doors dispatch it: the id and the order already minted, and
31
+ * what the set was created from. A consumer may not send these (design/sets 15.3, decision 2).
32
+ */
33
+ export interface MintedSetCreateCommand extends SetCreateCommand {
34
+ readonly id: SetId;
35
+ readonly order: number;
36
+ readonly createdFrom: SetCreatedFrom;
37
+ }
38
+ /** `set.rename`: give a set another name. */
39
+ interface SetRenameCommand {
40
+ readonly op: "set.rename";
41
+ readonly id: SetId;
42
+ readonly name: string;
43
+ }
44
+ /** `set.redefine`: change what a set holds, keeping its id, name and order. */
45
+ interface SetRedefineCommand {
46
+ readonly op: "set.redefine";
47
+ readonly id: SetId;
48
+ readonly definition: SetDefinitionInput;
49
+ }
50
+ /** `set.members`: add members to a fixed set, or take them out. */
51
+ interface SetMembersCommand {
52
+ readonly op: "set.members";
53
+ readonly id: SetId;
54
+ readonly add?: SetMemberDelta;
55
+ readonly remove?: SetMemberDelta;
56
+ }
57
+ /** `set.remove`: forget a set. What names it becomes detached rather than silently empty. */
58
+ interface SetRemoveCommand {
59
+ readonly op: "set.remove";
60
+ readonly id: SetId;
61
+ }
62
+ /** `set.restore`: bring a removed set back, with the record it had when it was removed. */
63
+ interface SetRestoreCommand {
64
+ readonly op: "set.restore";
65
+ readonly id: SetId;
66
+ }
67
+ /** Every kept-set op. */
68
+ export type SetCommand = SetCreateCommand | SetRenameCommand | SetRedefineCommand | SetMembersCommand | SetRemoveCommand | SetRestoreCommand;
69
+ /**
70
+ * The session's sets, as the set ops reach them: each call checks one command against the sets
71
+ * held now and returns what to write, throwing a refusal before anything is written. Built by
72
+ * `createSetsApi`.
73
+ */
74
+ export interface SetService {
75
+ /**
76
+ * @param command - The create; minted by a door, or a consumer's, which is minted here.
77
+ * @returns The record to write.
78
+ */
79
+ create(command: SetCreateCommand | MintedSetCreateCommand): ElementSet;
80
+ /**
81
+ * @param command - The rename.
82
+ * @returns The record to write, or null when the name is the one it has.
83
+ */
84
+ rename(command: SetRenameCommand): ElementSet | null;
85
+ /**
86
+ * @param command - The redefinition.
87
+ * @returns The record to write, or null when the definition is canonically the same.
88
+ */
89
+ redefine(command: SetRedefineCommand): ElementSet | null;
90
+ /**
91
+ * @param command - The member edit.
92
+ * @returns The record to write, or null when nothing would change.
93
+ */
94
+ members(command: SetMembersCommand): ElementSet | null;
95
+ /**
96
+ * @param command - The removal.
97
+ * @returns The id to delete.
98
+ */
99
+ remove(command: SetRemoveCommand): SetId;
100
+ /**
101
+ * @param command - The restore.
102
+ * @returns The record to put back.
103
+ */
104
+ restore(command: SetRestoreCommand): ElementSet;
105
+ /**
106
+ * Keep a record's id in the issued-id register: called once the step that wrote it is recorded.
107
+ * @param id - The id.
108
+ */
109
+ issue(id: SetId): void;
110
+ }
111
+ /** The kept-set ops' definitions. */
112
+ export declare const SET_DEFINITIONS: readonly [UndoableDefinition<SetCreateCommand>, UndoableDefinition<SetRenameCommand>, UndoableDefinition<SetRedefineCommand>, UndoableDefinition<SetMembersCommand>, UndoableDefinition<SetRemoveCommand>, UndoableDefinition<SetRestoreCommand>];
113
+ export {};
@@ -0,0 +1,92 @@
1
+ /**
2
+ * @file The style ops: `style.patch`, `style.encode` and `style.template`. Every edit to the
3
+ * style stack is one of them, and each is one undoable step.
4
+ *
5
+ * All three run on the immediate lane: the new stack is written when the command is dispatched,
6
+ * so `styles.list()` shows it as soon as the verb returns, and the repaint follows on the
7
+ * derivation lane. The stack is one frozen array of compiled layers (the `styles` slice), so a
8
+ * step keeps the stack before and after by reference, and undo puts the identical, already
9
+ * compiled layers back. See design/undo/undo-design.md sections 3.4, 5.2 and 11.3.
10
+ *
11
+ * What an edit does to the stack is worked out by the session's style compiler (the
12
+ * {@link StyleService} its styles API registers), because compiling a layer needs the session's
13
+ * columns and scales. This module says how each op behaves under undo.
14
+ */
15
+ import type { Channel, LayerId, LayerSpec, RunId, StyleDocument } from "../../catalog/types";
16
+ import type { UndoableDefinition } from "../project/Dispatcher";
17
+ import type { Draft } from "../project/draft";
18
+ import type { EncodingSpec } from "../styles/EncodingSpec";
19
+ import type { ExplainTarget } from "../styles/explain";
20
+ import type { LayerPosition } from "../styles/Layer";
21
+ import type { HighlightSpec } from "../styles/StylesApi";
22
+ /** `style.patch`: one change to the stack, said the way the styles verb that made it says it. */
23
+ export type StylePatchCommand = {
24
+ readonly op: "style.patch";
25
+ readonly action: "add";
26
+ readonly spec: LayerSpec;
27
+ /** Which neighbour to sit next to; the top of the stack when absent. */
28
+ readonly at?: LayerPosition;
29
+ } | {
30
+ readonly op: "style.patch";
31
+ readonly action: "update";
32
+ readonly id: LayerId;
33
+ /** Applied over the layer's specification one key deep; `undefined` clears a key. */
34
+ readonly patch: Partial<LayerSpec>;
35
+ } | {
36
+ readonly op: "style.patch";
37
+ readonly action: "remove";
38
+ readonly id: LayerId;
39
+ } | {
40
+ readonly op: "style.patch";
41
+ readonly action: "move";
42
+ readonly id: LayerId;
43
+ /** The layer to sit immediately below, or null for the top of the stack. */
44
+ readonly before: LayerId | null;
45
+ } | {
46
+ readonly op: "style.patch";
47
+ readonly action: "removeBySource";
48
+ /** The layers the sweep matched when it was dispatched. */
49
+ readonly ids: readonly LayerId[];
50
+ } | {
51
+ readonly op: "style.patch";
52
+ readonly action: "highlight";
53
+ readonly spec: Omit<HighlightSpec, "run"> & {
54
+ readonly run: RunId;
55
+ };
56
+ } | {
57
+ readonly op: "style.patch";
58
+ readonly action: "resolveToStatic";
59
+ readonly id: LayerId;
60
+ readonly channel: Channel;
61
+ readonly at?: ExplainTarget;
62
+ };
63
+ /** `style.encode`: paint a run's measurement onto a channel. */
64
+ export interface StyleEncodeCommand {
65
+ readonly op: "style.encode";
66
+ readonly spec: Omit<EncodingSpec, "run"> & {
67
+ readonly run: RunId;
68
+ };
69
+ }
70
+ /** `style.template`: add the layers of a style document. */
71
+ interface StyleTemplateCommand {
72
+ readonly op: "style.template";
73
+ readonly document: StyleDocument;
74
+ /** Recorded as the template on every layer that names no source of its own. */
75
+ readonly templateId?: string;
76
+ }
77
+ /** Every style op. */
78
+ export type StyleCommand = StylePatchCommand | StyleEncodeCommand | StyleTemplateCommand;
79
+ /** The session's style compiler, as the style ops reach it. */
80
+ export interface StyleService {
81
+ /**
82
+ * Work out the stack a command produces and write it through the draft. Throws a
83
+ * `GraphtyError` to refuse, before anything is written.
84
+ * @param command - The command.
85
+ * @param draft - The draft of the command's step.
86
+ * @returns What the verb resolves with.
87
+ */
88
+ execute(command: StyleCommand, draft: Draft): unknown;
89
+ }
90
+ /** The style ops' definitions. */
91
+ export declare const STYLE_DEFINITIONS: readonly [UndoableDefinition<StylePatchCommand>, UndoableDefinition<StyleEncodeCommand>, UndoableDefinition<StyleTemplateCommand>];
92
+ export {};
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @file The saved-view ops: `view.save` keeps camera states under names, `view.remove` forgets
3
+ * them, and `view.camera` moves the camera.
4
+ *
5
+ * Saved views are the `views` slice of project state, so saving and removing them are undoable
6
+ * steps on the immediate lane. Where the camera is looking is view state, not saved in a project
7
+ * file, so `view.camera` is exempt: it changes no slice, and a renderer carries it out. See
8
+ * design/undo/undo-design.md sections 3.1, 3.2, 10.5 and 11.4.
9
+ */
10
+ import type { CameraState, Vec3 } from "../../camera/types";
11
+ import type { ExemptDefinition, UndoableDefinition } from "../project/Dispatcher";
12
+ /** One view to save: a name and the camera state it holds. */
13
+ interface SavedView {
14
+ readonly name: string;
15
+ readonly camera: CameraState;
16
+ }
17
+ /** `view.save`: keep camera states under names, replacing any view already under one. */
18
+ interface ViewSaveCommand {
19
+ readonly op: "view.save";
20
+ readonly views: readonly SavedView[];
21
+ }
22
+ /** `view.remove`: forget saved views. */
23
+ interface ViewRemoveCommand {
24
+ readonly op: "view.remove";
25
+ readonly names: readonly string[];
26
+ }
27
+ /** `view.camera`: move the camera to a named view, or to a position and target. */
28
+ interface ViewCameraCommand {
29
+ readonly op: "view.camera";
30
+ /** A camera view or a saved view, by name. Wins over `position` and `target`. */
31
+ readonly preset?: string;
32
+ readonly position?: Vec3;
33
+ readonly target?: Vec3;
34
+ /** Animate the move instead of jumping. */
35
+ readonly animate?: boolean;
36
+ }
37
+ /** Every view op. */
38
+ export type ViewCommand = ViewSaveCommand | ViewRemoveCommand | ViewCameraCommand;
39
+ /** The renderer's camera, as `view.camera` reaches it. */
40
+ export interface CameraService {
41
+ /**
42
+ * Move the camera.
43
+ * @param command - Where to.
44
+ * @returns Settles once the camera has arrived.
45
+ */
46
+ move(command: ViewCameraCommand): Promise<void>;
47
+ }
48
+ /**
49
+ * Refuse a view name a camera view already answers to, or no name at all.
50
+ * @param name - The name being claimed.
51
+ * @throws A `GraphtyError` with `E_PROTECTED` for a camera view's name, `E_BAD_COMMAND` for an
52
+ * empty one.
53
+ */
54
+ export declare function assertViewName(name: string): void;
55
+ /** The view ops' definitions. */
56
+ export declare const VIEW_DEFINITIONS: readonly [UndoableDefinition<ViewSaveCommand>, UndoableDefinition<ViewRemoveCommand>, ExemptDefinition<ViewCameraCommand>];
57
+ export {};
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @file The visibility ops: `visibility.set` (the filter), `visibility.window` (the time window)
3
+ * and `visibility.context` (whether hidden nodes are drawn faintly). Each is one undoable step.
4
+ *
5
+ * All three run on the immediate lane: the value is written to the `visibility` slice when the
6
+ * command is dispatched, and the masks are evaluated on the derivation lane against whatever the
7
+ * slice holds when the pass runs, so a filter superseded before then is never evaluated. The
8
+ * masks are not state; they are derived from these three values and the graph. See
9
+ * design/undo/undo-design.md sections 3.4, 9.2 and 11.3.
10
+ */
11
+ import type { UndoableDefinition } from "../project/Dispatcher";
12
+ import { type RuleTree, type TimeWindow } from "../visibility/filter";
13
+ /** `visibility.set`: apply a filter, or clear it with null. */
14
+ interface VisibilitySetCommand {
15
+ readonly op: "visibility.set";
16
+ readonly filter: RuleTree | null;
17
+ }
18
+ /** `visibility.window`: apply a time window, or clear it with null. */
19
+ interface VisibilityWindowCommand {
20
+ readonly op: "visibility.window";
21
+ readonly window: TimeWindow | null;
22
+ }
23
+ /** `visibility.context`: draw hidden nodes faintly, or not at all. */
24
+ interface VisibilityContextCommand {
25
+ readonly op: "visibility.context";
26
+ readonly show: boolean;
27
+ }
28
+ /** Every visibility op. */
29
+ export type VisibilityCommand = VisibilitySetCommand | VisibilityWindowCommand | VisibilityContextCommand;
30
+ /** The session's visibility model, as the visibility ops reach it. */
31
+ export interface VisibilityService {
32
+ /**
33
+ * Refuse a filter or a window the session could not evaluate, before anything is written.
34
+ * @param filter - The filter, or null.
35
+ * @param window - The window, or null.
36
+ */
37
+ check(filter: RuleTree | null, window: TimeWindow | null): void;
38
+ }
39
+ /** The visibility ops' definitions. */
40
+ export declare const VISIBILITY_DEFINITIONS: readonly [UndoableDefinition<VisibilitySetCommand>, UndoableDefinition<VisibilityWindowCommand>, UndoableDefinition<VisibilityContextCommand>];
41
+ export {};
@@ -7,10 +7,27 @@
7
7
  * replaced only when the graph actually changes. The first reader after a change pays; everyone
8
8
  * else in the same revision reads a field.
9
9
  */
10
+ import "../data/index";
10
11
  import { type DerivedGraph, type GraphSnapshot, type NodeId } from "@graphty/graph-format";
11
12
  import type { AttributeDescriptor, EdgeId } from "../catalog/types";
13
+ import type { GraphStore } from "../data/GraphStore";
12
14
  import type { ImportReport } from "../data/report";
13
- import type { EdgeRecord, GraphStatistics, NodeRecord, SessionDataApi, SessionDataConfig, SessionGraphStore, SessionRecordSource } from "./types";
15
+ import { type DataImportCommand, type DataMutation, type DataService } from "./commands/data";
16
+ import type { Dispatcher } from "./project/Dispatcher";
17
+ import type { GraphSlice } from "./project/state";
18
+ import type { DataSourceDescriptor, DataSourceInput, EdgeRecord, EdgeRecordInput, GraphStatistics, ImportOptions, NodeRecord, NodeRecordInput, RowUpdate, SessionAttributes, SessionDataApi, SessionDataConfig, SessionGraphStore, SessionRecordSource } from "./types";
19
+ /** What the data surface writes through, and where it reads what the graph holds beside rows. */
20
+ interface DataWrites {
21
+ /** Dispatch `data.apply`. */
22
+ dispatch(mutation: DataMutation): Promise<unknown>;
23
+ /**
24
+ * Where a `data.import` made now would go -- the session, or the transaction a routed verb
25
+ * runs in -- held for a verb that dispatches it after an await.
26
+ */
27
+ importer(): (command: DataImportCommand) => Promise<unknown>;
28
+ /** The `graph` slice now. */
29
+ slice(): GraphSlice;
30
+ }
14
31
  /**
15
32
  * The session's view of the graph data.
16
33
  *
@@ -20,9 +37,13 @@ import type { EdgeRecord, GraphStatistics, NodeRecord, SessionDataApi, SessionDa
20
37
  * no longer exists.
21
38
  */
22
39
  export declare class SessionData implements SessionDataApi {
40
+ /** The store, read-only: its snapshot is a consumer's, and its coordinates cannot be written. */
23
41
  readonly store: SessionGraphStore;
42
+ /** The store itself, which the session's own readers read. */
43
+ private readonly graphStore;
24
44
  private readonly records;
25
45
  private readonly readConfig;
46
+ private readonly writes;
26
47
  private derived;
27
48
  private disposed;
28
49
  /**
@@ -32,11 +53,62 @@ export declare class SessionData implements SessionDataApi {
32
53
  * element holds none
33
54
  * @param readConfig - reads the data configuration, live: the element replaces that object
34
55
  * when a style template is applied, so it is read on demand rather than captured
56
+ * @param writes - the dispatcher to write through, and the slice beside the rows
57
+ */
58
+ constructor(store: SessionGraphStore, records: SessionRecordSource | null, readConfig: () => SessionDataConfig, writes: DataWrites);
59
+ /**
60
+ * Add node records, as one undoable step.
61
+ * @param records - the records; each id is read through `data.knownFields.nodeIdPath`
62
+ * @returns settles once they are in the graph and drawn
63
+ */
64
+ addNodes(records: readonly NodeRecordInput[]): Promise<void>;
65
+ /**
66
+ * Add edge records, as one undoable step.
67
+ * @param records - the records; endpoints are read through the configured edge id paths
68
+ * @returns settles once they are in the graph and drawn
69
+ */
70
+ addEdges(records: readonly EdgeRecordInput[]): Promise<void>;
71
+ /**
72
+ * Change attributes of existing nodes, as one undoable step.
73
+ * @param rows - the new values per node
74
+ * @returns settles once the change is drawn
75
+ */
76
+ updateNodes(rows: readonly RowUpdate<NodeId>[]): Promise<void>;
77
+ /**
78
+ * Change attributes of existing edges, as one undoable step.
79
+ * @param rows - the new values per edge id
80
+ * @returns settles once the change is drawn
81
+ */
82
+ updateEdges(rows: readonly RowUpdate<EdgeId>[]): Promise<void>;
83
+ /**
84
+ * Remove nodes, and every edge attached to one, as one undoable step.
85
+ * @param ids - the node ids; one the graph does not hold is skipped
86
+ * @returns settles once they are gone from the graph and the picture
87
+ */
88
+ removeNodes(ids: readonly NodeId[]): Promise<void>;
89
+ /**
90
+ * Remove edges, as one undoable step.
91
+ * @param ids - the element-assigned edge ids; one the graph does not hold is skipped
92
+ * @returns settles once they are gone from the graph and the picture
93
+ */
94
+ removeEdges(ids: readonly EdgeId[]): Promise<void>;
95
+ /**
96
+ * Remove every node, edge, record and graph-level value, as one undoable step.
97
+ * @returns settles once the graph and the picture are empty
98
+ */
99
+ clear(): Promise<void>;
100
+ /**
101
+ * Load a file, a URL or inline text through a registered data source, as one undoable step.
102
+ * @param source - The data source's name and its options.
103
+ * @param options - Whether to replace the graph (the default) or add to it.
104
+ * @returns Settles once the last chunk is in the graph; rejects, recording nothing, when the
105
+ * load fails.
35
106
  */
36
- constructor(store: SessionGraphStore, records: SessionRecordSource | null, readConfig: () => SessionDataConfig);
107
+ import(source: DataSourceInput, options?: ImportOptions): Promise<void>;
37
108
  /**
38
- * The current snapshot, freezing first when records have arrived since the last freeze.
39
- * @returns the immutable snapshot
109
+ * The current snapshot, freezing first when records have arrived since the last freeze, with
110
+ * copies of its coordinate and pin columns.
111
+ * @returns the sealed snapshot
40
112
  * @throws A `GraphtyError` with `E_DISPOSED` when the session has been disposed.
41
113
  */
42
114
  snapshot(): GraphSnapshot;
@@ -47,6 +119,11 @@ export declare class SessionData implements SessionDataApi {
47
119
  * @throws A `GraphtyError` with `E_DISPOSED` when the session has been disposed.
48
120
  */
49
121
  undirected(snapshot?: GraphSnapshot): DerivedGraph;
122
+ /**
123
+ * The store's own snapshot, for the readers here that never hand it out.
124
+ * @returns the resident snapshot
125
+ */
126
+ private current;
50
127
  /**
51
128
  * One node, by id.
52
129
  * @param id - the node id, compared without coercion
@@ -61,6 +138,24 @@ export declare class SessionData implements SessionDataApi {
61
138
  * @throws A `GraphtyError` with `E_DISPOSED` when the session has been disposed.
62
139
  */
63
140
  edge(id: EdgeId): EdgeRecord | undefined;
141
+ /**
142
+ * Every node, in the graph's order.
143
+ * @returns the records, deep-frozen
144
+ * @throws A `GraphtyError` with `E_DISPOSED` when the session has been disposed.
145
+ */
146
+ nodes(): readonly NodeRecord[];
147
+ /**
148
+ * Every edge, in the graph's order.
149
+ * @returns the records, deep-frozen
150
+ * @throws A `GraphtyError` with `E_DISPOSED` when the session has been disposed.
151
+ */
152
+ edges(): readonly EdgeRecord[];
153
+ /**
154
+ * Where the graph was loaded from, as the `graph` slice keeps it, so undo and redo move it.
155
+ * @returns the source, or null when no import loaded the graph
156
+ * @throws A `GraphtyError` with `E_DISPOSED` when the session has been disposed.
157
+ */
158
+ source(): DataSourceDescriptor | null;
64
159
  /**
65
160
  * What the last load did.
66
161
  * @returns the report, or null when nothing has been loaded into this graph
@@ -110,3 +205,35 @@ export declare class SessionData implements SessionDataApi {
110
205
  */
111
206
  private requireLive;
112
207
  }
208
+ /**
209
+ * Where a session reads the attributes a record carries: the `graph` slice, which every write
210
+ * through the graph primitives fills, and then a host's own source for rows it wrote some other way.
211
+ *
212
+ * An edge's record is handed back without the keys the last import read its endpoints from, when
213
+ * those are plain keys, so a consumer deriving columns from the keys does not show `src` beside the
214
+ * canonical `source`.
215
+ * @param slice - Reads the `graph` slice.
216
+ * @param snapshot - Reads the current snapshot, to name an edge row by its id.
217
+ * @param lastImport - Reads the last import report.
218
+ * @param fallback - The host's own source, if it has one.
219
+ * @returns The source.
220
+ */
221
+ export declare function sliceRecords(slice: () => GraphSlice, snapshot: () => GraphSnapshot, lastImport: () => ImportReport | null, fallback: SessionRecordSource | null): SessionRecordSource;
222
+ /**
223
+ * The graph's records in row order: what the element's `nodeData` and `edgeData` read. A node
224
+ * record whose id the graph could not store, and so has no row, follows the rows.
225
+ * @param slice - The `graph` slice.
226
+ * @param snapshot - The snapshot of the same graph.
227
+ * @param target - Nodes or edges.
228
+ * @returns The records, frozen.
229
+ */
230
+ export declare function recordsInRowOrder(slice: GraphSlice, snapshot: GraphSnapshot, target: "node" | "edge"): readonly SessionAttributes[];
231
+ /**
232
+ * The data service of a session that owns its store: ingest over that store, with nothing to draw.
233
+ * @param store - The store.
234
+ * @param dispatcher - The session's dispatcher.
235
+ * @param readConfig - Reads the data configuration.
236
+ * @returns The service.
237
+ */
238
+ export declare function headlessDataService(store: GraphStore, dispatcher: Dispatcher, readConfig: () => SessionDataConfig): DataService;
239
+ export {};
@@ -16,5 +16,5 @@ export type { DefaultableLimits } from "./limits";
16
16
  export { DEFAULT_LIMITS } from "./limits";
17
17
  export type { AlgorithmRunCommand, Plan, PlanBlock, PlanEffect, SessionCommand } from "./planning";
18
18
  export { isAlgorithmRunCommand } from "./planning";
19
- export type { ComponentStatistics, CreateGraphSessionOptions, EdgeRecord, ElementSession, GraphSession, GraphStatistics, NodeRecord, SessionAttributes, SessionCatalogApi, SessionConfig, SessionDataApi, SessionDataConfig, SessionEventMap, SessionGraphStore, SessionRecordSource, SessionRunsOptions, SessionStatus, StyleProblem, } from "./types";
19
+ export type { CommandOutcome, CommandOutcomeMap, ComponentStatistics, CreateGraphSessionOptions, DataSourceDescriptor, DataSourceInput, EdgeRecord, EdgeRecordInput, ElementSession, GraphSession, GraphStatistics, HistoryCause, HistoryOutcome, HistoryStep, HistoryStepId, ImportOptions, NodeRecord, NodeRecordInput, PendingId, PendingStep, PositionEntry, ProjectConfig, ProjectConfigPatch, ProjectSlice, ReadonlyElementPositions, RowUpdate, SessionAttributes, SessionCatalogApi, SessionConfig, SessionDataApi, SessionDataConfig, SessionEventMap, SessionGraphStore, SessionHistory, SessionLayout, SessionPositions, SessionRunsOptions, SessionStatus, SessionViews, StyleProblem, TransactionOptions, TransactionScope, } from "./types";
20
20
  export { COMPONENT_SIZE_CAP } from "./types";
@@ -17,18 +17,26 @@
17
17
  */
18
18
  import type { AlgorithmDescriptor, AlgorithmKey, FieldDescriptor, RunId, Scope, SetId } from "../catalog/types";
19
19
  import type { GraphtyErrorCode } from "../errors";
20
+ import type { AlgoLegacyCommand, AlgoRemoveCommand } from "./commands/algo";
21
+ import type { ConfigSetCommand } from "./commands/config";
22
+ import type { DataCommand } from "./commands/data";
23
+ import type { BatchCommand } from "./commands/index";
24
+ import type { LayoutCommand } from "./commands/layout";
25
+ import type { PositionsCommand } from "./commands/positions";
26
+ import type { SetCommand } from "./commands/sets";
27
+ import type { StyleCommand } from "./commands/style";
28
+ import type { ViewCommand } from "./commands/view";
29
+ import type { VisibilityCommand } from "./commands/visibility";
20
30
  import { type CostEstimate, type CostGateLimits, type CostMeasurement, type MachineCalibration, type ScopeCandidate } from "./cost";
21
31
  import type { Caveats, ResolvedScope } from "./runs";
22
32
  import type { GraphStatistics } from "./types";
23
33
  /**
24
34
  * Start one algorithm, as data.
25
35
  *
26
- * Every verb on a session is meant to be expressible as one of these, so that "do this" and
27
- * "record that you did this" are the same artifact -- what a recipe replays, what a journal
28
- * stores, what an agent's tool call carries. One verb is expressible today, and the union below
29
- * has one member rather than a placeholder: a command that does not exist is discovered by
30
- * autocomplete finding nothing, which costs a consumer one keystroke, where a stub that compiles
31
- * and then throws costs them an afternoon.
36
+ * Every verb on a session is expressible as a command, so that "do this" and "record that you
37
+ * did this" are the same artifact -- what `session.execute` runs, what a transaction groups into
38
+ * one undoable step, and what an agent's tool call carries. This is the one that starts a run;
39
+ * {@link SessionCommand} is the union of all of them.
32
40
  */
33
41
  export interface AlgorithmRunCommand {
34
42
  /** Which verb this is. */
@@ -47,9 +55,18 @@ export interface AlgorithmRunCommand {
47
55
  readonly exact?: boolean;
48
56
  /** The id to give the run. Required for anything that will be saved. */
49
57
  readonly as?: RunId;
58
+ /**
59
+ * Also apply the layers the run suggests, on top of the stack, in the same step as the run:
60
+ * one undo takes the run and those layers away together.
61
+ */
62
+ readonly applySuggestedStyles?: boolean;
50
63
  }
51
- /** Everything a session can be asked to do, as data. */
52
- export type SessionCommand = AlgorithmRunCommand;
64
+ /**
65
+ * Everything a session can be asked to do, as data: the union of every op in the vocabulary
66
+ * (`COMMANDS` in `@graphty/graphty-element/commands`). It widens as ops are added, so a `switch`
67
+ * over `op` should keep a default branch.
68
+ */
69
+ export type SessionCommand = AlgorithmRunCommand | AlgoLegacyCommand | AlgoRemoveCommand | DataCommand | StyleCommand | VisibilityCommand | SetCommand | ViewCommand | ConfigSetCommand | PositionsCommand | LayoutCommand | BatchCommand;
53
70
  /**
54
71
  * Tell whether a value is the command that starts an algorithm.
55
72
  * @param value - The value to test.