@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.
- package/dist/ai.js +3 -3
- package/dist/catalog.js +53 -54
- package/dist/chunks/{AiManager-4iQpsJW1.js → AiManager-Bhh0rR_p.js} +706 -655
- package/dist/chunks/GraphSession-DPoTaT3b.js +21175 -0
- package/dist/chunks/{GraphtyLogger-B_O67a6c.js → GraphtyLogger-BtcBJQPL.js} +1 -1
- package/dist/chunks/{VoiceInputAdapter-Cc6mHXTI.js → VoiceInputAdapter-CdLsJ_nG.js} +1 -1
- package/dist/chunks/{XRPivotCameraController-BLa89LXn.js → XRPivotCameraController-CiLJ9Gz6.js} +2 -2
- package/dist/chunks/algorithms-qij74zEN.js +6811 -0
- package/dist/chunks/{capability-check-Am2zliFj.js → capability-check-BbgTejS3.js} +1 -1
- package/dist/chunks/definePalette-BYt2Llxs.js +1333 -0
- package/dist/chunks/fields-5uVC1Pll.js +4999 -0
- package/dist/chunks/{format-detection-BHwrAVzW.js → format-detection-FKaDMshR.js} +1 -1
- package/dist/chunks/{index-BkBLbvui.js → index-Cc_6D9hV.js} +6034 -7127
- package/dist/chunks/interpolation-Dk206AhZ.js +105 -0
- package/dist/chunks/paletteRegistry-De3CGdst.js +357 -0
- package/dist/chunks/parse-SVp77JbE.js +669 -0
- package/dist/chunks/{pluginRegistry-Bs8bEkz9.js → pluginRegistry-Ddfl6Mv2.js} +27 -24
- package/dist/chunks/{registry-BdGvyZou.js → registry-CgMqldp4.js} +1 -1
- package/dist/chunks/{DataSource-BL2UzPff.js → sources-BbAJCDIH.js} +279 -108
- package/dist/commands.d.ts +128 -19
- package/dist/commands.js +49 -1
- package/dist/custom-elements.json +1 -1
- package/dist/extend.d.ts +10 -2
- package/dist/extend.js +64 -57
- package/dist/graphty-catalog.json +6 -3
- package/dist/graphty.bundle.js +267177 -240648
- package/dist/graphty.js +84 -78
- package/dist/index.d.ts +4 -0
- package/dist/logging.js +2 -2
- package/dist/schema.js +70 -71
- package/dist/session.d.ts +5 -6
- package/dist/session.js +40 -86
- package/dist/src/Edge.d.ts +31 -67
- package/dist/src/Graph.d.ts +335 -77
- package/dist/src/Node.d.ts +36 -3
- package/dist/src/NodeBehavior.d.ts +28 -0
- package/dist/src/Styles.d.ts +15 -4
- package/dist/src/acceleration/AccelerationController.d.ts +8 -0
- package/dist/src/acceleration/narrow.d.ts +9 -1
- package/dist/src/acceleration/types.d.ts +10 -0
- package/dist/src/ai/AiController.d.ts +12 -0
- package/dist/src/ai/AiManager.d.ts +7 -0
- package/dist/src/ai/commands/AlgorithmCommands.d.ts +1 -1
- package/dist/src/ai/commands/LayoutCommands.d.ts +1 -1
- package/dist/src/ai/commands/StyleCommands.d.ts +1 -1
- package/dist/src/ai/commands/types.d.ts +20 -1
- package/dist/src/algorithms/Algorithm.d.ts +21 -4
- package/dist/src/algorithms/BFSAlgorithm.d.ts +0 -9
- package/dist/src/algorithms/BellmanFordAlgorithm.d.ts +0 -14
- package/dist/src/algorithms/DFSAlgorithm.d.ts +1 -1
- package/dist/src/algorithms/FloydWarshallAlgorithm.d.ts +5 -0
- package/dist/src/algorithms/GirvanNewmanAlgorithm.d.ts +5 -0
- package/dist/src/algorithms/LeidenAlgorithm.d.ts +5 -0
- package/dist/src/algorithms/PageRankAlgorithm.d.ts +1 -1
- package/dist/src/algorithms/StronglyConnectedComponentsAlgorithm.d.ts +1 -1
- package/dist/src/algorithms/metrics/fields.d.ts +23 -1
- package/dist/src/algorithms/utils/graphUtils.d.ts +13 -1
- package/dist/src/catalog/paletteRegistry.d.ts +4 -4
- package/dist/src/catalog/registry.d.ts +3 -2
- package/dist/src/catalog/types.d.ts +18 -1
- package/dist/src/config/GraphStyle.d.ts +1 -1
- package/dist/src/config/StyleTemplate.d.ts +2 -2
- package/dist/src/config/xr-config-schema.d.ts +4 -4
- package/dist/src/data/CSVDataSource.d.ts +77 -22
- package/dist/src/data/ErrorAggregator.d.ts +5 -0
- package/dist/src/data/GEXFDataSource.d.ts +12 -61
- package/dist/src/data/GraphMLDataSource.d.ts +3 -44
- package/dist/src/data/GraphStore.d.ts +322 -15
- package/dist/src/data/JsonDataSource.d.ts +43 -1
- package/dist/src/data/graph-io-import.d.ts +89 -0
- package/dist/src/data/graph-io-records.d.ts +64 -0
- package/dist/src/data/lane.d.ts +23 -0
- package/dist/src/data/positions.d.ts +13 -0
- package/dist/src/data/seedPosition.d.ts +16 -0
- package/dist/src/errors/GraphtyError.d.ts +3 -1
- package/dist/src/errors/codes.d.ts +23 -0
- package/dist/src/events.d.ts +12 -0
- package/dist/src/graphty-element.d.ts +149 -54
- package/dist/src/input/types.d.ts +2 -0
- package/dist/src/layout/D3GraphLayoutEngine.d.ts +17 -3
- package/dist/src/layout/FixedLayoutEngine.d.ts +20 -4
- package/dist/src/layout/KamadaKawaiLayoutEngine.d.ts +6 -0
- package/dist/src/layout/LayoutEngine.d.ts +214 -116
- package/dist/src/layout/NGraphLayoutEngine.d.ts +10 -3
- package/dist/src/layout/SimulationLayoutEngine.d.ts +8 -3
- package/dist/src/managers/AlgorithmManager.d.ts +24 -5
- package/dist/src/managers/DataManager.d.ts +258 -181
- package/dist/src/managers/EventManager.d.ts +5 -2
- package/dist/src/managers/GraphContext.d.ts +7 -0
- package/dist/src/managers/InputManager.d.ts +11 -0
- package/dist/src/managers/LayoutManager.d.ts +129 -50
- package/dist/src/managers/RenderManager.d.ts +14 -1
- package/dist/src/managers/UpdateManager.d.ts +20 -0
- package/dist/src/screenshot/ScreenshotCapture.d.ts +1 -1
- package/dist/src/session/GraphSession.d.ts +83 -6
- package/dist/src/session/commands/algo.d.ts +169 -0
- package/dist/src/session/commands/config.d.ts +45 -0
- package/dist/src/session/commands/data.d.ts +178 -0
- package/dist/src/session/commands/doors.d.ts +93 -0
- package/dist/src/session/commands/index.d.ts +20 -0
- package/dist/src/session/commands/layout.d.ts +104 -0
- package/dist/src/session/commands/positions.d.ts +30 -0
- package/dist/src/session/commands/sets.d.ts +113 -0
- package/dist/src/session/commands/style.d.ts +92 -0
- package/dist/src/session/commands/view.d.ts +57 -0
- package/dist/src/session/commands/visibility.d.ts +41 -0
- package/dist/src/session/data.d.ts +131 -4
- package/dist/src/session/index.d.ts +1 -1
- package/dist/src/session/planning.d.ts +25 -8
- package/dist/src/session/project/Dispatcher.d.ts +905 -0
- package/dist/src/session/project/History.d.ts +382 -0
- package/dist/src/session/project/arrangement.d.ts +247 -0
- package/dist/src/session/project/derive.d.ts +132 -0
- package/dist/src/session/project/digest.d.ts +33 -0
- package/dist/src/session/project/draft.d.ts +194 -0
- package/dist/src/session/project/graphOps.d.ts +304 -0
- package/dist/src/session/project/ingest.d.ts +364 -0
- package/dist/src/session/project/state.d.ts +145 -0
- package/dist/src/session/project/strict.d.ts +68 -0
- package/dist/src/session/results/RunResult.d.ts +48 -0
- package/dist/src/session/results/statistics.d.ts +20 -0
- package/dist/src/session/runs/Run.d.ts +80 -4
- package/dist/src/session/runs/RunsApi.d.ts +23 -6
- package/dist/src/session/runs/types.d.ts +25 -6
- package/dist/src/session/scope/ElementMask.d.ts +14 -0
- package/dist/src/session/scope/ScopeApi.d.ts +3 -22
- package/dist/src/session/scope/spaces.d.ts +29 -0
- package/dist/src/session/sealed.d.ts +22 -0
- package/dist/src/session/selection/SelectionApi.d.ts +14 -4
- package/dist/src/session/sets/SetsApi.d.ts +13 -5
- package/dist/src/session/sets/store.d.ts +54 -53
- package/dist/src/session/sets/types.d.ts +5 -2
- package/dist/src/session/styles/Layer.d.ts +5 -0
- package/dist/src/session/styles/StylesApi.d.ts +68 -17
- package/dist/src/session/styles/autoApply.d.ts +64 -53
- package/dist/src/session/styles/index.d.ts +3 -3
- package/dist/src/session/styles/predicate.d.ts +7 -0
- package/dist/src/session/styles/repaint.d.ts +16 -1
- package/dist/src/session/styles/sources.d.ts +1 -1
- package/dist/src/session/types.d.ts +625 -54
- package/dist/src/session/visibility/VisibilityApi.d.ts +38 -18
- package/dist/src/session/visibility/filter.d.ts +10 -0
- package/dist/src/simple/defineAlgorithm.d.ts +28 -0
- package/dist/src/simple/defineLayout.d.ts +35 -0
- package/dist/src/simple/defineLogDestination.d.ts +31 -0
- package/dist/src/simple/definePalette.d.ts +26 -0
- package/dist/src/simple/definition.d.ts +106 -0
- package/dist/src/simple/options.d.ts +33 -0
- package/dist/src/simple/source.d.ts +49 -0
- package/dist/src/simple/types.d.ts +366 -0
- package/dist/src/simple/view.d.ts +107 -0
- package/dist/webgpu.js +2 -2
- package/package.json +10 -12
- package/dist/chunks/GraphSession-BhuHSXIo.js +0 -12819
- package/dist/chunks/GraphStyle-Cwr55SAE.js +0 -65
- package/dist/chunks/algorithms-BJ6DQMOe.js +0 -3777
- package/dist/chunks/detect-fyuVnlCT.js +0 -88
- package/dist/chunks/interpolation-DY-PNpqX.js +0 -43
- package/dist/chunks/optionsFromZod-CKMYSwTz.js +0 -3636
- package/dist/chunks/paletteRegistry-BCFSwJGK.js +0 -1196
- package/dist/chunks/parse-BMTqt4SS.js +0 -3658
- package/dist/src/data/csv-variant-detection.d.ts +0 -29
- package/dist/src/data/ingest.d.ts +0 -104
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The run ops: `algo.run`, `algo.legacy` and `algo.remove`.
|
|
3
|
+
*
|
|
4
|
+
* `algo.run` takes a slot on the queue under `algorithm-run`, computes, and then, in one
|
|
5
|
+
* synchronous commit tail, writes the finished run into the `runs` slice together with the style
|
|
6
|
+
* layers it paints: its first-completion layers, and the suggested layers it was asked to apply.
|
|
7
|
+
* So a run, its result, its layers and its legend are one step, and undoing it keeps the result
|
|
8
|
+
* in history instead of recomputing it. A run cancelled before it commits, whether by undo, by
|
|
9
|
+
* the queue or by its own `cancel()`, writes nothing.
|
|
10
|
+
*
|
|
11
|
+
* `algo.remove` takes a run out of the `runs` slice and removes the layers bound to it, in one
|
|
12
|
+
* draft, so one undo brings both back.
|
|
13
|
+
*
|
|
14
|
+
* `algo.legacy` runs a plugin algorithm that declares no catalogue descriptor, and so has no run:
|
|
15
|
+
* it writes onto node and edge records and `graphResults` as it goes, and may call the graph's
|
|
16
|
+
* own doors. It is one step all the same. The plugin is handed a facade of the graph whose doors
|
|
17
|
+
* dispatch into the command's own group ({@link legacyFacade}), and while it runs the records it
|
|
18
|
+
* reads are copy-on-write views ({@link LegacyWrites}) whose written paths become one attribute
|
|
19
|
+
* write when it finishes. See design/undo/undo-design.md sections 4.5 and 4.9.
|
|
20
|
+
*
|
|
21
|
+
* What a run computes, and which handle a consumer holds for it, is the runs API's work: it
|
|
22
|
+
* registers the {@link RunService} these ops call. See design/undo/undo-design.md sections 4.7,
|
|
23
|
+
* 4.8 and 6.3.
|
|
24
|
+
*/
|
|
25
|
+
import type { RunId } from "../../catalog/types";
|
|
26
|
+
import type { AlgorithmRunCommand } from "../planning";
|
|
27
|
+
import type { Dispatcher, DispatchFunction, UndoableContext, UndoableDefinition } from "../project/Dispatcher";
|
|
28
|
+
import { type Draft } from "../project/draft";
|
|
29
|
+
import type { RowUpdate } from "../types";
|
|
30
|
+
/** `algo.remove`: take a finished run, and every layer bound to it, out of the project. */
|
|
31
|
+
export interface AlgoRemoveCommand {
|
|
32
|
+
readonly op: "algo.remove";
|
|
33
|
+
/** The run. */
|
|
34
|
+
readonly runId: RunId;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* `algo.legacy`: run a plugin algorithm that declares no catalogue descriptor, addressed the 1.10
|
|
38
|
+
* way, as one step with everything it writes.
|
|
39
|
+
*/
|
|
40
|
+
export interface AlgoLegacyCommand {
|
|
41
|
+
readonly op: "algo.legacy";
|
|
42
|
+
/** The registry namespace. */
|
|
43
|
+
readonly namespace: string;
|
|
44
|
+
/** The registry type. */
|
|
45
|
+
readonly type: string;
|
|
46
|
+
/** What the plugin is constructed with. */
|
|
47
|
+
readonly options?: Readonly<Record<string, unknown>>;
|
|
48
|
+
/** Also apply the layers its finished runs suggest, in the same step. */
|
|
49
|
+
readonly applySuggestedStyles?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/** How a renderer carries out `algo.legacy`: it constructs the plugin, which needs a `Graph`. */
|
|
52
|
+
export interface LegacyService {
|
|
53
|
+
/**
|
|
54
|
+
* Construct the plugin with a facade of the graph, run it, and write what it wrote.
|
|
55
|
+
* @param command - The command.
|
|
56
|
+
* @param ctx - The command's context; `ctx.inline` is what the facade dispatches through.
|
|
57
|
+
* @returns Settles once everything it wrote is in the command's draft.
|
|
58
|
+
*/
|
|
59
|
+
run(command: AlgoLegacyCommand, ctx: UndoableContext): Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
/** How a session carries out the run ops; registered by its runs API. */
|
|
62
|
+
export interface RunService {
|
|
63
|
+
/**
|
|
64
|
+
* Compute a run, then write it and the layers it paints through the command's draft.
|
|
65
|
+
* @param command - The run.
|
|
66
|
+
* @param ctx - The command's context: its draft, its signal and its slot.
|
|
67
|
+
* @returns Settles once the run is written; rejects when it failed or was cancelled first.
|
|
68
|
+
*/
|
|
69
|
+
run(command: AlgorithmRunCommand, ctx: UndoableContext): Promise<unknown>;
|
|
70
|
+
/**
|
|
71
|
+
* Remove a run and the layers bound to it through `draft`, and stop it if it is still going.
|
|
72
|
+
* @param command - The removal.
|
|
73
|
+
* @param draft - The command's draft.
|
|
74
|
+
* @returns What went with it.
|
|
75
|
+
*/
|
|
76
|
+
remove(command: AlgoRemoveCommand, draft: Draft): unknown;
|
|
77
|
+
}
|
|
78
|
+
/** The run ops' definitions. */
|
|
79
|
+
export declare const ALGO_DEFINITIONS: readonly [UndoableDefinition<AlgorithmRunCommand>, UndoableDefinition<AlgoLegacyCommand>, UndoableDefinition<AlgoRemoveCommand>];
|
|
80
|
+
/** What a record belongs to: a node, an edge, or the graph's own values. */
|
|
81
|
+
type WriteTarget = "node" | "edge" | "graph";
|
|
82
|
+
/**
|
|
83
|
+
* The copy-on-write records of one `algo.legacy` command: reads pass through to the record the
|
|
84
|
+
* graph holds, and the first write under a top-level key copies that key's subtree with
|
|
85
|
+
* `structuredClone` and writes the copy. The record itself is never touched, so a write that is
|
|
86
|
+
* never committed (the command failed or was undone while the plugin ran) changes nothing.
|
|
87
|
+
*
|
|
88
|
+
* One view per record, cached for the command's duration, so a record read twice allocates once.
|
|
89
|
+
*/
|
|
90
|
+
export declare class LegacyWrites {
|
|
91
|
+
#private;
|
|
92
|
+
readonly owner: object;
|
|
93
|
+
readonly owns: (element: object) => boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Open no scope yet: {@link openLegacyScope} does.
|
|
96
|
+
* @param owner - What the scope is looked up by: the session's dispatcher.
|
|
97
|
+
* @param owns - Whether a node or edge render object is one of this graph's.
|
|
98
|
+
*/
|
|
99
|
+
constructor(owner: object, owns: (element: object) => boolean);
|
|
100
|
+
/**
|
|
101
|
+
* The copy-on-write view of one record.
|
|
102
|
+
* @param target - Node, edge, or the graph's values.
|
|
103
|
+
* @param id - The node or edge id; ignored for the graph.
|
|
104
|
+
* @param record - The record the graph holds.
|
|
105
|
+
* @returns The view.
|
|
106
|
+
*/
|
|
107
|
+
view(target: WriteTarget, id: string | number, record: object): object;
|
|
108
|
+
/**
|
|
109
|
+
* The copy-on-write view of the graph's values, the same object each time.
|
|
110
|
+
* @param values - The graph's values as the graph holds them.
|
|
111
|
+
* @returns The view, by name.
|
|
112
|
+
*/
|
|
113
|
+
graph(values: ReadonlyMap<string, unknown>): Record<string, unknown>;
|
|
114
|
+
/**
|
|
115
|
+
* Whether the command has ended.
|
|
116
|
+
* @returns True once {@link LegacyWrites.close} ran.
|
|
117
|
+
*/
|
|
118
|
+
get closed(): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* End the command: a view kept past it throws on the next write, and a copied subtree handed
|
|
121
|
+
* out while it ran is frozen, so a write to that throws too.
|
|
122
|
+
*/
|
|
123
|
+
close(): void;
|
|
124
|
+
/**
|
|
125
|
+
* What was written, as the rows and graph values a draft takes.
|
|
126
|
+
* @returns The written top-level keys of each record, and of the graph's values.
|
|
127
|
+
*/
|
|
128
|
+
writes(): {
|
|
129
|
+
readonly nodes: RowUpdate<string | number>[];
|
|
130
|
+
readonly edges: RowUpdate<string | number>[];
|
|
131
|
+
readonly graph: Readonly<Record<string, unknown>> | null;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The scope open for a dispatcher.
|
|
136
|
+
* @param owner - The dispatcher.
|
|
137
|
+
* @returns The scope, or undefined when no `algo.legacy` of its graph is running.
|
|
138
|
+
*/
|
|
139
|
+
export declare function legacyScopeOf(owner: Dispatcher | null): LegacyWrites | undefined;
|
|
140
|
+
/** A prototype whose `data` getter is swapped while a scope is open. */
|
|
141
|
+
interface DataPrototype {
|
|
142
|
+
readonly prototype: object;
|
|
143
|
+
readonly target: "node" | "edge";
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Open a copy-on-write scope: until it is closed, reading `data` on a node or edge of this graph
|
|
147
|
+
* hands back a copy-on-write view. The getters are swapped on the prototypes, not branched on
|
|
148
|
+
* every read, and put back when the last scope closes.
|
|
149
|
+
* @param scope - The scope.
|
|
150
|
+
* @param prototypes - The render object prototypes whose `data` getter reads a record.
|
|
151
|
+
* @returns Closes it.
|
|
152
|
+
*/
|
|
153
|
+
export declare function openLegacyScope(scope: LegacyWrites, prototypes: readonly DataPrototype[]): () => void;
|
|
154
|
+
/**
|
|
155
|
+
* A group-tagged facade of `root`: the same members, but every call made through it, and through
|
|
156
|
+
* every object it hands back, runs with the dispatcher routed to `inline`, so a door reached
|
|
157
|
+
* through it dispatches into the running command's own group instead of a step of its own. The
|
|
158
|
+
* routing lasts for the synchronous part of each call only, which is where every door dispatches,
|
|
159
|
+
* so a dispatch made anywhere else while the plugin runs is still a step of its own.
|
|
160
|
+
*
|
|
161
|
+
* Calls are made on the real objects, with any facade among the arguments unwrapped, so private
|
|
162
|
+
* fields and identity checks see the originals.
|
|
163
|
+
* @param root - The graph.
|
|
164
|
+
* @param dispatcher - Its session's dispatcher.
|
|
165
|
+
* @param inline - Dispatches into the running command's group.
|
|
166
|
+
* @returns The facade.
|
|
167
|
+
*/
|
|
168
|
+
export declare function legacyFacade<T extends object>(root: T, dispatcher: Dispatcher, inline: DispatchFunction): T;
|
|
169
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file `config.set`: change project settings, one undoable step per call.
|
|
3
|
+
*
|
|
4
|
+
* The project settings are the keys of the `config` slice, one key per leaf, named by its dotted
|
|
5
|
+
* path: every leaf of the zod `DataConfig` schema under `data.` (the id, label, weight and time
|
|
6
|
+
* paths, the repeated-edge policy, the position scale, the id coercion, the on-load algorithms and
|
|
7
|
+
* the direction), whether the on-load algorithms run, the background, the selection style, and
|
|
8
|
+
* three layout-behaviour keys. The `DataConfig` leaves are read from the schema when this module
|
|
9
|
+
* loads, so a field added there joins the slice without an edit here.
|
|
10
|
+
*
|
|
11
|
+
* The slice holds only what has been set, as the caller gave it; a key that is absent reads as
|
|
12
|
+
* its default. Setting a key to `undefined` removes it, which returns it to its default.
|
|
13
|
+
* Everything else a graph is configured with -- the camera distance, the view mode, the
|
|
14
|
+
* interaction and throughput preferences -- is not saved in a project file, is not a key here,
|
|
15
|
+
* and `config.set` refuses it. See design/undo/undo-design.md sections 3.1, 3.2 and 10.1.
|
|
16
|
+
*/
|
|
17
|
+
import { z } from "zod/v4";
|
|
18
|
+
import type { UndoableDefinition } from "../project/Dispatcher";
|
|
19
|
+
import type { ProjectConfig, ProjectConfigPatch, SessionDataConfig } from "../types";
|
|
20
|
+
/** `config.set`: write project settings. */
|
|
21
|
+
export interface ConfigSetCommand {
|
|
22
|
+
readonly op: "config.set";
|
|
23
|
+
readonly values: ProjectConfigPatch;
|
|
24
|
+
}
|
|
25
|
+
/** Which part of the project settings a key belongs to: the discriminant of `config.set`. */
|
|
26
|
+
type ConfigGroup = "data" | "runAlgorithmsOnLoad" | "background" | "selectionStyle" | "layoutBehavior";
|
|
27
|
+
/** One key of the `config` slice. */
|
|
28
|
+
interface ConfigKey {
|
|
29
|
+
readonly group: ConfigGroup;
|
|
30
|
+
/** Validates a value set, and reads a stored value (or `undefined`) as the setting. */
|
|
31
|
+
readonly schema: z.ZodType;
|
|
32
|
+
}
|
|
33
|
+
/** Every key of the `config` slice, with its group and schema. */
|
|
34
|
+
export declare const CONFIG_KEYS: ReadonlyMap<string, ConfigKey>;
|
|
35
|
+
/**
|
|
36
|
+
* The project settings a slice holds, with every absent key at its default.
|
|
37
|
+
* @param slice - The `config` slice.
|
|
38
|
+
* @param base - The data configuration an absent `data.` key reads from: the element's defaults,
|
|
39
|
+
* or what a headless session was built with.
|
|
40
|
+
* @returns The settings, frozen.
|
|
41
|
+
*/
|
|
42
|
+
export declare function readProjectConfig(slice: ReadonlyMap<string, unknown>, base: SessionDataConfig): ProjectConfig;
|
|
43
|
+
/** The config op's definition. */
|
|
44
|
+
export declare const CONFIG_DEFINITIONS: readonly [UndoableDefinition<ConfigSetCommand>];
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The data ops, each one undoable step:
|
|
3
|
+
*
|
|
4
|
+
* - `data.apply`: one change to the graph's rows or records. The kinds that grow or patch the
|
|
5
|
+
* graph, `add-nodes`, `add-edges`, `set-attributes` and `update-rows`, and the removals and
|
|
6
|
+
* `clear`: `remove-nodes`, `remove-edges`, `clear`.
|
|
7
|
+
* - `data.import`: a load through a registered data source, replacing the graph or adding to it.
|
|
8
|
+
* - `data.expand`: the neighbourhood a double-click fetched, added as one step. The fetched
|
|
9
|
+
* records are in the command, so redo never fetches again.
|
|
10
|
+
*
|
|
11
|
+
* Each reads its records through ingest (id and endpoint extraction, the repeated-edge policy,
|
|
12
|
+
* weights) and writes through the graph primitives in its draft, which record the resolved values,
|
|
13
|
+
* so undo and redo never pass through ingest, a data source or a fetcher again. See
|
|
14
|
+
* design/undo/undo-design.md sections 3.3, 3.4, 4.7 and 11.1.
|
|
15
|
+
*
|
|
16
|
+
* `data.apply` and `data.import` take their turn on the queue, so an add is ordered against the
|
|
17
|
+
* loads, layouts and runs dispatched before it, and one still waiting is pending work that undo
|
|
18
|
+
* cancels. A synchronous door starts its `data.apply` beside the queue instead. `data.import`
|
|
19
|
+
* holds the whole graph while it reads. `data.expand` runs on the immediate lane: the write is
|
|
20
|
+
* visible as soon as `dispatch` returns.
|
|
21
|
+
*/
|
|
22
|
+
import type { DuplicatePolicy } from "@graphty/graph-format";
|
|
23
|
+
import type { EdgeId, NodeId } from "../../catalog/types";
|
|
24
|
+
import type { UndoableContext, UndoableDefinition } from "../project/Dispatcher";
|
|
25
|
+
import type { Draft } from "../project/draft";
|
|
26
|
+
import type { NodeRecordInput, RowUpdate } from "../types";
|
|
27
|
+
import type { BatchCommand } from "./index";
|
|
28
|
+
/** A record to add; its id, or its endpoints, are read through the configured paths. */
|
|
29
|
+
type RecordInput = NodeRecordInput;
|
|
30
|
+
/** One change `data.apply` makes. */
|
|
31
|
+
export type DataMutation = {
|
|
32
|
+
readonly kind: "add-nodes";
|
|
33
|
+
readonly records: readonly RecordInput[];
|
|
34
|
+
/** The id path for this call, overriding `data.knownFields.nodeIdPath`. */
|
|
35
|
+
readonly idPath?: string;
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: "add-edges";
|
|
38
|
+
readonly records: readonly RecordInput[];
|
|
39
|
+
/** The source endpoint path for this call. */
|
|
40
|
+
readonly source?: string;
|
|
41
|
+
/** The target endpoint path for this call. */
|
|
42
|
+
readonly target?: string;
|
|
43
|
+
/** The repeated-edge policy for this call. */
|
|
44
|
+
readonly repeated?: DuplicatePolicy;
|
|
45
|
+
} | {
|
|
46
|
+
/** The same values on many rows: "set type to hub on these nodes". */
|
|
47
|
+
readonly kind: "set-attributes";
|
|
48
|
+
readonly target: "node" | "edge";
|
|
49
|
+
readonly ids: readonly (NodeId | EdgeId)[];
|
|
50
|
+
readonly values: Readonly<Record<string, unknown>>;
|
|
51
|
+
} | {
|
|
52
|
+
/** Values of its own for each row. */
|
|
53
|
+
readonly kind: "update-rows";
|
|
54
|
+
readonly target: "node" | "edge";
|
|
55
|
+
readonly rows: readonly RowUpdate<NodeId | EdgeId>[];
|
|
56
|
+
} | {
|
|
57
|
+
/** Remove nodes, and every edge attached to one. */
|
|
58
|
+
readonly kind: "remove-nodes";
|
|
59
|
+
readonly ids: readonly NodeId[];
|
|
60
|
+
} | {
|
|
61
|
+
/** Remove edges, by the element-assigned edge id. */
|
|
62
|
+
readonly kind: "remove-edges";
|
|
63
|
+
readonly ids: readonly EdgeId[];
|
|
64
|
+
} | {
|
|
65
|
+
/** Remove every node, edge, record and graph-level value. */
|
|
66
|
+
readonly kind: "clear";
|
|
67
|
+
};
|
|
68
|
+
/** `data.apply`. */
|
|
69
|
+
interface DataApplyCommand {
|
|
70
|
+
readonly op: "data.apply";
|
|
71
|
+
readonly mutation: DataMutation;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Where a load comes from: a registered data source's name and its options. The element's
|
|
75
|
+
* `dataSource` / `dataSourceConfig` pair may be half assigned, so either may be absent; a source
|
|
76
|
+
* missing either is recorded and nothing is loaded.
|
|
77
|
+
*/
|
|
78
|
+
export interface ImportSource {
|
|
79
|
+
readonly type?: string;
|
|
80
|
+
readonly config?: Readonly<Record<string, unknown>>;
|
|
81
|
+
/** What the reader calls the data; see `DataSourceInput.name`. */
|
|
82
|
+
readonly name?: string;
|
|
83
|
+
/** The file's size in bytes, when a file was read. */
|
|
84
|
+
readonly size?: number;
|
|
85
|
+
}
|
|
86
|
+
/** `data.import`. */
|
|
87
|
+
export interface DataImportCommand {
|
|
88
|
+
readonly op: "data.import";
|
|
89
|
+
readonly source: ImportSource;
|
|
90
|
+
/** `"replace"` (the default) empties the graph first, in the same step; `"merge"` adds to it. */
|
|
91
|
+
readonly mode?: "replace" | "merge";
|
|
92
|
+
/** `"recommended"` also chooses a layout for what was loaded, in the same step. */
|
|
93
|
+
readonly layout?: "recommended" | "keep";
|
|
94
|
+
/** Declared at construction: while the baseline window is open it becomes the baseline. */
|
|
95
|
+
readonly setup?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Imports with the same key coalesce while the first waits its turn: the element's two
|
|
98
|
+
* properties assigned one after the other are one load.
|
|
99
|
+
*/
|
|
100
|
+
readonly coalesce?: string;
|
|
101
|
+
}
|
|
102
|
+
/** `data.expand`: what a double-click on `seed` fetched, captured so redo does not fetch again. */
|
|
103
|
+
interface DataExpandCommand {
|
|
104
|
+
readonly op: "data.expand";
|
|
105
|
+
readonly seed: NodeId;
|
|
106
|
+
readonly nodes: readonly RecordInput[];
|
|
107
|
+
readonly edges: readonly RecordInput[];
|
|
108
|
+
/** The expression naming each edge's source, resolved once for the fetched edges. */
|
|
109
|
+
readonly source?: string;
|
|
110
|
+
/** The expression naming each edge's target. */
|
|
111
|
+
readonly target?: string;
|
|
112
|
+
}
|
|
113
|
+
/** Every data op. */
|
|
114
|
+
export type DataCommand = DataApplyCommand | DataImportCommand | DataExpandCommand;
|
|
115
|
+
/** How a session applies a data mutation: its ingest and its store. Set by whoever owns them. */
|
|
116
|
+
export interface DataService {
|
|
117
|
+
/**
|
|
118
|
+
* Apply one mutation, writing through the graph primitives in `draft`.
|
|
119
|
+
* @param mutation - The mutation.
|
|
120
|
+
* @param draft - The command's draft.
|
|
121
|
+
* @param after - Starts work once the command's step is recorded, as its deferred members:
|
|
122
|
+
* the on-load runs of a command that adds rows.
|
|
123
|
+
*/
|
|
124
|
+
apply(mutation: DataMutation, draft: Draft, after?: UndoableContext["after"]): void;
|
|
125
|
+
/**
|
|
126
|
+
* Carry out one import, writing through the graph primitives in `draft`.
|
|
127
|
+
* @param command - The import.
|
|
128
|
+
* @param draft - The command's draft.
|
|
129
|
+
* @param signal - Fires when the import is cancelled; it stops before the next chunk.
|
|
130
|
+
* @param after - Starts work once the import's step is recorded, as its deferred members.
|
|
131
|
+
* @returns Settles once the last chunk is written.
|
|
132
|
+
*/
|
|
133
|
+
import(command: DataImportCommand, draft: Draft, signal: AbortSignal, after?: UndoableContext["after"]): Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* Set graph-level values through `draft`: what a plugin algorithm wrote to `graphResults`.
|
|
136
|
+
* A renderer's only; a headless session runs no plugin.
|
|
137
|
+
* @param values - The values by name.
|
|
138
|
+
* @param draft - The command's draft.
|
|
139
|
+
*/
|
|
140
|
+
values?(values: Readonly<Record<string, unknown>>, draft: Draft): void;
|
|
141
|
+
}
|
|
142
|
+
/** The graph value naming where the graph was last loaded from. */
|
|
143
|
+
export declare const SOURCE_VALUE = "source";
|
|
144
|
+
/**
|
|
145
|
+
* A source as the graph keeps it: without the inline text or the file, which the loaded rows
|
|
146
|
+
* already hold and which history must not keep alive.
|
|
147
|
+
* @param source - The source.
|
|
148
|
+
* @returns The descriptor.
|
|
149
|
+
*/
|
|
150
|
+
export declare function describeSource(source: ImportSource): ImportSource;
|
|
151
|
+
/** How new edges are read: the endpoint expressions and the repeated-edge policy. */
|
|
152
|
+
interface EdgeReadOptions {
|
|
153
|
+
readonly source?: string;
|
|
154
|
+
readonly target?: string;
|
|
155
|
+
readonly repeated?: DuplicatePolicy;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The step replacing the graph's edges: remove the edges it holds, add the new ones.
|
|
159
|
+
* @param held - The ids of the edges it holds, read when the step is about to run.
|
|
160
|
+
* @param records - The edges it should hold afterwards.
|
|
161
|
+
* @param options - Endpoint expressions and the repeated-edge policy for the new edges.
|
|
162
|
+
* @param setup - Declared at construction.
|
|
163
|
+
* @returns The command.
|
|
164
|
+
*/
|
|
165
|
+
export declare function replaceEdgesCommand(held: readonly EdgeId[], records: readonly RecordInput[], options?: EdgeReadOptions, setup?: boolean): BatchCommand;
|
|
166
|
+
/**
|
|
167
|
+
* The step replacing the graph's nodes: remove the nodes it holds that the new records do not
|
|
168
|
+
* name, with their edges, and add the new ones. A node named again keeps its row and its edges.
|
|
169
|
+
* @param held - The ids of the nodes it holds, read when the step is about to run.
|
|
170
|
+
* @param records - The nodes it should hold afterwards.
|
|
171
|
+
* @param idPath - Where a record's id is, `data.knownFields.nodeIdPath`.
|
|
172
|
+
* @param setup - Declared at construction.
|
|
173
|
+
* @returns The command.
|
|
174
|
+
*/
|
|
175
|
+
export declare function replaceNodesCommand(held: readonly NodeId[], records: readonly RecordInput[], idPath: string, setup?: boolean): BatchCommand;
|
|
176
|
+
/** The data ops' definitions. */
|
|
177
|
+
export declare const DATA_DEFINITIONS: readonly [UndoableDefinition<DataApplyCommand>, UndoableDefinition<DataImportCommand>, UndoableDefinition<DataExpandCommand>];
|
|
178
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The door list: every public member of graphty-element that could change it, and what
|
|
3
|
+
* each one does about undo.
|
|
4
|
+
*
|
|
5
|
+
* A door is a public method, accessor or field. Each is classified as one of:
|
|
6
|
+
*
|
|
7
|
+
* - `readOnly`: it changes nothing;
|
|
8
|
+
* - `exempt`, with the reason: it changes something no project file saves (the camera, the
|
|
9
|
+
* selection, work in flight, a machine preference);
|
|
10
|
+
* - `dispatches`: it dispatches the command in its row, and nothing else;
|
|
11
|
+
* - `partial`: it dispatches, but one call of it is not yet one step, until the issue it names
|
|
12
|
+
* is fixed;
|
|
13
|
+
* - `knownGap`: it changes project state without the dispatcher, until the issue it names is
|
|
14
|
+
* fixed. With an `op` it will dispatch that op; without one it is a public escape (a writable
|
|
15
|
+
* field, a live array) that the issue narrows.
|
|
16
|
+
*
|
|
17
|
+
* The roots are the element, `Graph`, `Node`, `Edge`, the session and each of its parts, the
|
|
18
|
+
* `Run` handle, the style layer, every manager, and every type a public member of one of them
|
|
19
|
+
* hands back that has methods. `test/session/history/door-surface.test.ts` walks the declared
|
|
20
|
+
* types of the roots with the TypeScript compiler and fails on any public member this list does
|
|
21
|
+
* not classify, and on any handle type that is not a root, so nothing public can ship without a
|
|
22
|
+
* decision about undo. `test/session/history/doors.test.ts` (the session's rows) and
|
|
23
|
+
* `test/browser/doors.test.ts` (the renderer's rows) call every row that dispatches or will
|
|
24
|
+
* dispatch, with a spy on the dispatcher, and hold the rule: no `knownGap` or `partial` row may
|
|
25
|
+
* remain, and a `knownGap` door must dispatch nothing. A row of either kind names the GitHub
|
|
26
|
+
* issue that tracks it, so a gap that has to land for a while is still on record.
|
|
27
|
+
*
|
|
28
|
+
* No entry point exports this module.
|
|
29
|
+
*/
|
|
30
|
+
/** How the doors tests call a door. */
|
|
31
|
+
export type DoorCall = {
|
|
32
|
+
readonly kind: "call";
|
|
33
|
+
/** The arguments, or a function building them where they cannot be plain data. */
|
|
34
|
+
readonly args: readonly unknown[] | (() => readonly unknown[]);
|
|
35
|
+
/**
|
|
36
|
+
* For a door that does nothing in the doors test's default state: sets up the state it
|
|
37
|
+
* acts on before the spy is attached, and returns what puts it back afterwards.
|
|
38
|
+
*/
|
|
39
|
+
readonly around?: (target: object) => Promise<() => Promise<unknown>>;
|
|
40
|
+
} | {
|
|
41
|
+
readonly kind: "set";
|
|
42
|
+
readonly value: unknown;
|
|
43
|
+
};
|
|
44
|
+
/** What one door does about undo. */
|
|
45
|
+
export type Door = {
|
|
46
|
+
readonly kind: "readOnly";
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: "exempt";
|
|
49
|
+
readonly reason: string;
|
|
50
|
+
} | {
|
|
51
|
+
readonly kind: "dispatches";
|
|
52
|
+
readonly op: string;
|
|
53
|
+
readonly call: DoorCall;
|
|
54
|
+
/** The commands the call must dispatch, in order. */
|
|
55
|
+
readonly expect: readonly unknown[];
|
|
56
|
+
} | {
|
|
57
|
+
readonly kind: "partial";
|
|
58
|
+
/** The GitHub issue tracking it. */
|
|
59
|
+
readonly issue: number;
|
|
60
|
+
readonly reason: string;
|
|
61
|
+
readonly op: string;
|
|
62
|
+
readonly call: DoorCall;
|
|
63
|
+
readonly expect: readonly unknown[];
|
|
64
|
+
} | {
|
|
65
|
+
readonly kind: "knownGap";
|
|
66
|
+
/** The GitHub issue tracking it. */
|
|
67
|
+
readonly issue: number;
|
|
68
|
+
/** The op it will dispatch once ported; absent for an escape the issue narrows. */
|
|
69
|
+
readonly op?: string;
|
|
70
|
+
/** How to call it; present exactly when `op` is. */
|
|
71
|
+
readonly call?: DoorCall;
|
|
72
|
+
};
|
|
73
|
+
/** A type whose public members are doors. */
|
|
74
|
+
export interface DoorRoot {
|
|
75
|
+
/** The declared name of the class or interface. */
|
|
76
|
+
readonly name: string;
|
|
77
|
+
/** The file declaring it, relative to the package root. */
|
|
78
|
+
readonly file: string;
|
|
79
|
+
/** Which doors test calls its rows: the Node one on a session, or the browser one on a `Graph`. */
|
|
80
|
+
readonly half: "session" | "renderer";
|
|
81
|
+
/** One row per public member. */
|
|
82
|
+
readonly doors?: Readonly<Record<string, Door>>;
|
|
83
|
+
/** For a type every member of which has the same answer: that answer. */
|
|
84
|
+
readonly whole?: Door;
|
|
85
|
+
}
|
|
86
|
+
/** Every root, and the door of every public member. */
|
|
87
|
+
export declare const DOOR_ROOTS: readonly DoorRoot[];
|
|
88
|
+
/**
|
|
89
|
+
* The ops a gesture the element handles itself dispatches, with no public member of its own: the
|
|
90
|
+
* gesture is the door. Each names where it is handled; the browser test of that gesture checks
|
|
91
|
+
* that it dispatches the op.
|
|
92
|
+
*/
|
|
93
|
+
export declare const GESTURE_DOORS: Readonly<Record<string, string>>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The definition of every op in the vocabulary: how it behaves under undo, which keys it
|
|
3
|
+
* writes, which lane it runs on, and what it does. The dispatcher is built from this list, and
|
|
4
|
+
* `COMMANDS` in `commands.ts` publishes the undo half of it; the vocabulary test checks that the
|
|
5
|
+
* two agree op for op. See design/undo/undo-design.md sections 4.1 and 10.5.
|
|
6
|
+
*/
|
|
7
|
+
import type { SessionCommand } from "../planning";
|
|
8
|
+
import type { CommandDefinition } from "../project/Dispatcher";
|
|
9
|
+
/** `batch`: commands that are one step, as data. A serialisable transaction. */
|
|
10
|
+
export interface BatchCommand {
|
|
11
|
+
readonly op: "batch";
|
|
12
|
+
/** The commands, dispatched in order; each takes its own lane. */
|
|
13
|
+
readonly steps: readonly SessionCommand[];
|
|
14
|
+
/** What the step is called; the first member's name by default. */
|
|
15
|
+
readonly label?: string;
|
|
16
|
+
/** Declared at construction: while the baseline window is open it becomes the baseline. */
|
|
17
|
+
readonly setup?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Every op's definition, one per op. */
|
|
20
|
+
export declare const DEFINITIONS: readonly CommandDefinition<SessionCommand>[];
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The layout ops: which layout draws the graph and in how many dimensions, and the two
|
|
3
|
+
* exempt controls beside them.
|
|
4
|
+
*
|
|
5
|
+
* - `layout.set`: choose the layout (a catalogue id, the engine that draws it, its options, and
|
|
6
|
+
* optionally what it runs over). One undoable step.
|
|
7
|
+
* - `layout.scope`: change what layouts run over, keeping the layout. One undoable step, written
|
|
8
|
+
* at once so a layout still waiting for its turn carries it; the `layout` hook restarts the
|
|
9
|
+
* running layout over it. Never refused for a scope that resolves to nothing.
|
|
10
|
+
* - `view.dimension`: draw in 2D or 3D. One undoable step. The dimension lives in the `layout`
|
|
11
|
+
* slice and nowhere else: the merged `Styles.config` computes `graph.viewMode` and `graph.twoD`
|
|
12
|
+
* from it, and the renderer's `layout` hook writes `scene.metadata.twoD` from it.
|
|
13
|
+
* - `layout.transport`: play or pause the layout. Exempt: coordinates while a layout moves are
|
|
14
|
+
* in-flight computation, and where it comes to rest is sealed into the top step.
|
|
15
|
+
* - `view.immersive`: enter or leave VR or AR. Exempt: a device session, not the document.
|
|
16
|
+
*
|
|
17
|
+
* `layout.set` and `view.dimension` are slot-holding writers (design/undo/undo-design.md section
|
|
18
|
+
* 4.7): they take the arrangement they began from, write the slice, then have the renderer build
|
|
19
|
+
* the engine and spend its pre-steps inside their slot. Cancelled or made obsolete while the
|
|
20
|
+
* pre-steps run, they publish nothing, and the rollback puts the previous layout and the previous
|
|
21
|
+
* coordinates back. See design sections 3.2, 4.7, 6.4 and 11.4.
|
|
22
|
+
*/
|
|
23
|
+
import type { LayoutId, Scope } from "../../catalog/types";
|
|
24
|
+
import type { ExemptDefinition, UndoableDefinition } from "../project/Dispatcher";
|
|
25
|
+
import type { LayoutChoice } from "../project/state";
|
|
26
|
+
/** `layout.set`: choose the layout that draws the graph. */
|
|
27
|
+
export interface LayoutSetCommand {
|
|
28
|
+
readonly op: "layout.set";
|
|
29
|
+
/** The catalogue id, such as `"force"`. A registered engine name is read as the id it serves. */
|
|
30
|
+
readonly id: LayoutId;
|
|
31
|
+
/** The engine that draws it, such as `"d3"`; the catalogue's default engine for `id` when absent. */
|
|
32
|
+
readonly engine?: string;
|
|
33
|
+
/** The engine's options. */
|
|
34
|
+
readonly options?: Readonly<Record<string, unknown>>;
|
|
35
|
+
/**
|
|
36
|
+
* What it runs over, canonical: absent keeps the scope the slice holds, `"graph"` clears it.
|
|
37
|
+
* A scope named here is refused when the engine cannot hold nodes still or nothing is in it.
|
|
38
|
+
*/
|
|
39
|
+
readonly scope?: Scope;
|
|
40
|
+
/** Choices with the same key coalesce while the first waits its turn (the element's property pair). */
|
|
41
|
+
readonly coalesce?: string;
|
|
42
|
+
/** Declared at construction: while the baseline window is open it becomes the baseline. */
|
|
43
|
+
readonly setup?: boolean;
|
|
44
|
+
}
|
|
45
|
+
/** `layout.scope`: change what layouts run over; `"graph"` for the whole graph. */
|
|
46
|
+
interface LayoutScopeCommand {
|
|
47
|
+
readonly op: "layout.scope";
|
|
48
|
+
/** The scope, canonical. */
|
|
49
|
+
readonly scope: Scope;
|
|
50
|
+
}
|
|
51
|
+
/** `view.dimension`: draw the graph in two or three dimensions. */
|
|
52
|
+
interface ViewDimensionCommand {
|
|
53
|
+
readonly op: "view.dimension";
|
|
54
|
+
readonly dimension: "2d" | "3d";
|
|
55
|
+
/** Declared at construction: while the baseline window is open it becomes the baseline. */
|
|
56
|
+
readonly setup?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/** `layout.transport`: let the layout move, or hold it still. */
|
|
59
|
+
interface LayoutTransportCommand {
|
|
60
|
+
readonly op: "layout.transport";
|
|
61
|
+
readonly action: "play" | "pause";
|
|
62
|
+
}
|
|
63
|
+
/** `view.immersive`: enter VR or AR, or leave it with `null`. */
|
|
64
|
+
interface ViewImmersiveCommand {
|
|
65
|
+
readonly op: "view.immersive";
|
|
66
|
+
readonly mode: "vr" | "ar" | null;
|
|
67
|
+
}
|
|
68
|
+
/** Every layout op. */
|
|
69
|
+
export type LayoutCommand = LayoutSetCommand | LayoutScopeCommand | ViewDimensionCommand | LayoutTransportCommand | ViewImmersiveCommand;
|
|
70
|
+
/** The renderer's layout, as the layout ops reach it. A session that draws nothing has none. */
|
|
71
|
+
export interface LayoutService {
|
|
72
|
+
/**
|
|
73
|
+
* Build or reconfigure the engine for a choice just written, and spend its pre-steps, inside
|
|
74
|
+
* the command's slot: the `layout` hook, run inline.
|
|
75
|
+
* @param choice - The choice, as the slice now holds it.
|
|
76
|
+
* @param signal - Fires when the command is cancelled or made obsolete; the pre-steps then
|
|
77
|
+
* stop without publishing anything.
|
|
78
|
+
* @param explicitScope - Whether the command named the scope, the only case in which a scope
|
|
79
|
+
* the engine cannot hold, or that holds nothing, is refused.
|
|
80
|
+
* @returns Settles once the pre-steps have landed.
|
|
81
|
+
*/
|
|
82
|
+
apply(choice: LayoutChoice, signal: AbortSignal, explicitScope: boolean): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Play or pause the layout.
|
|
85
|
+
* @param action - Which.
|
|
86
|
+
*/
|
|
87
|
+
transport(action: "play" | "pause"): void;
|
|
88
|
+
/**
|
|
89
|
+
* Enter or leave an immersive session.
|
|
90
|
+
* @param mode - VR, AR, or null to leave.
|
|
91
|
+
* @returns Settles once the device session has started or ended; rejects when it cannot.
|
|
92
|
+
*/
|
|
93
|
+
immersive(mode: "vr" | "ar" | null): Promise<void>;
|
|
94
|
+
}
|
|
95
|
+
/** Which layout suits the graph the session holds now: what `data.import` with a recommended layout asks. */
|
|
96
|
+
export type LayoutAdvice = () => {
|
|
97
|
+
readonly id: LayoutId;
|
|
98
|
+
readonly engine: string;
|
|
99
|
+
} | undefined;
|
|
100
|
+
/** The layout a graph is drawn with before one is chosen: the element's own default. */
|
|
101
|
+
export declare const DEFAULT_LAYOUT: LayoutChoice;
|
|
102
|
+
/** The layout ops' definitions. */
|
|
103
|
+
export declare const LAYOUT_DEFINITIONS: readonly [UndoableDefinition<LayoutSetCommand>, UndoableDefinition<LayoutScopeCommand>, UndoableDefinition<ViewDimensionCommand>, ExemptDefinition<LayoutTransportCommand>, ExemptDefinition<ViewImmersiveCommand>];
|
|
104
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The positions ops, each one undoable step on the immediate lane:
|
|
3
|
+
*
|
|
4
|
+
* - `positions.set`: place nodes at coordinates. It records the rows it wrote as a row patch, or,
|
|
5
|
+
* over more than a third of the rows, a capture; calls made one after another within the
|
|
6
|
+
* coalescing window are one step.
|
|
7
|
+
* - `positions.pin`: pin nodes where they are, or release them. The pinned ids are the `pins`
|
|
8
|
+
* slice; the lane's pin bytes and the layout engine follow it.
|
|
9
|
+
*
|
|
10
|
+
* See design/undo/undo-design.md sections 6.4 and 10.5.
|
|
11
|
+
*/
|
|
12
|
+
import type { NodeId } from "../../catalog/types";
|
|
13
|
+
import type { UndoableDefinition } from "../project/Dispatcher";
|
|
14
|
+
import type { PositionEntry } from "../types";
|
|
15
|
+
/** `positions.set`: place nodes at coordinates. */
|
|
16
|
+
interface PositionsSetCommand {
|
|
17
|
+
readonly op: "positions.set";
|
|
18
|
+
readonly entries: readonly PositionEntry[];
|
|
19
|
+
}
|
|
20
|
+
/** `positions.pin`: pin nodes, or release them. */
|
|
21
|
+
interface PositionsPinCommand {
|
|
22
|
+
readonly op: "positions.pin";
|
|
23
|
+
readonly ids: readonly NodeId[];
|
|
24
|
+
readonly pinned: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** Every positions op. */
|
|
27
|
+
export type PositionsCommand = PositionsSetCommand | PositionsPinCommand;
|
|
28
|
+
/** The positions ops' definitions. */
|
|
29
|
+
export declare const POSITIONS_DEFINITIONS: readonly [UndoableDefinition<PositionsSetCommand>, UndoableDefinition<PositionsPinCommand>];
|
|
30
|
+
export {};
|