@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,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The derivation lane: how every change to project state reaches the screen.
|
|
3
|
+
*
|
|
4
|
+
* Each slice registers hooks, `hook(rendered, target, dirty)`: from the state the picture last
|
|
5
|
+
* showed, to the state it must show, with the keys of that slice changed since. Forward commits,
|
|
6
|
+
* undo, redo, restore and rollback all mark keys dirty the same way (the project store reports
|
|
7
|
+
* every write), so restoring state restores the picture by construction.
|
|
8
|
+
*
|
|
9
|
+
* Every change schedules one pass as a microtask, so a burst of synchronous changes (a held
|
|
10
|
+
* Ctrl+Z, a restore across thirty steps) costs one pass that sees the net change. A change that
|
|
11
|
+
* arrives while a pass is running waits for the next one. Hooks run in a fixed order: `graph`,
|
|
12
|
+
* `layout`, `pins`, `arrangement`, then the rest, so the layout engine exists before pins are
|
|
13
|
+
* applied to it and the arrangement is loaded last. See design/undo/undo-design.md section 9.
|
|
14
|
+
*
|
|
15
|
+
* The lane runs apart from the operation queue, whose obsolescence rules cancel work and whose
|
|
16
|
+
* batch sort reorders it. Nothing here reaches Babylon.js, Lit or the DOM: the renderer registers
|
|
17
|
+
* its hooks on the session's lane.
|
|
18
|
+
*/
|
|
19
|
+
import type { ProjectState } from "./state";
|
|
20
|
+
/** A slice of project state, as the lane marks and derives it. */
|
|
21
|
+
type DerivedSlice = keyof ProjectState;
|
|
22
|
+
/**
|
|
23
|
+
* Brings one slice of the picture from `rendered` to `target`. `dirty` holds the keys changed
|
|
24
|
+
* since the last pass ("" for a whole-value slice); a key may be dirty with no net change, so a
|
|
25
|
+
* hook compares the two states. It may return a promise; the pass waits for it.
|
|
26
|
+
*/
|
|
27
|
+
type DeriveHook = (rendered: ProjectState, target: ProjectState, dirty: ReadonlySet<string>) => unknown;
|
|
28
|
+
interface LaneOptions {
|
|
29
|
+
/** Told when a hook throws; the pass goes on. By default the error is rethrown unhandled. */
|
|
30
|
+
readonly onError?: (error: unknown) => void;
|
|
31
|
+
}
|
|
32
|
+
/** The lane: `rendered` state, dirty keys per slice, one pass per burst of changes. */
|
|
33
|
+
export declare class DerivationLane {
|
|
34
|
+
private readonly state;
|
|
35
|
+
private readonly onError;
|
|
36
|
+
private readonly hooks;
|
|
37
|
+
private dirty;
|
|
38
|
+
/** How many writes each slice has had, whoever wrote it. */
|
|
39
|
+
private readonly counts;
|
|
40
|
+
private shown;
|
|
41
|
+
/** The pass that will take the changes made since the running one started. */
|
|
42
|
+
private next;
|
|
43
|
+
private current;
|
|
44
|
+
private restoringFlag;
|
|
45
|
+
private restoreCause;
|
|
46
|
+
/** Moves on every restore, so a pass clears the flag only for restores made before it began. */
|
|
47
|
+
private restores;
|
|
48
|
+
/**
|
|
49
|
+
* Strict state's invariant check, run at the end of a pass that leaves nothing more to derive,
|
|
50
|
+
* with live state; what it throws goes where hook errors go. Null outside strict state.
|
|
51
|
+
*/
|
|
52
|
+
afterPass: ((target: ProjectState) => void) | null;
|
|
53
|
+
/** What the running pass, or the last one, catches up with. */
|
|
54
|
+
private passCauseValue;
|
|
55
|
+
/**
|
|
56
|
+
* Create a lane over live state. The picture is taken to show that state already.
|
|
57
|
+
* @param state - The live state, which the lane reads and never writes.
|
|
58
|
+
* @param options - Where hook errors go.
|
|
59
|
+
*/
|
|
60
|
+
constructor(state: ProjectState, options?: LaneOptions);
|
|
61
|
+
/**
|
|
62
|
+
* The state the picture shows: the target of the last finished pass.
|
|
63
|
+
* @returns A frozen copy.
|
|
64
|
+
*/
|
|
65
|
+
get rendered(): ProjectState;
|
|
66
|
+
/**
|
|
67
|
+
* True from an undo, redo, restore or rollback until the `arrangement` hook of the pass that
|
|
68
|
+
* derives it has run. While it is set, hooks feed the layout without stepping or starting it.
|
|
69
|
+
* @returns The flag.
|
|
70
|
+
*/
|
|
71
|
+
get restoring(): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Add a hook for one slice. Hooks of one slice run in the order registered.
|
|
74
|
+
* @param slice - The slice.
|
|
75
|
+
* @param hook - The hook.
|
|
76
|
+
* @returns A function that removes it.
|
|
77
|
+
*/
|
|
78
|
+
register(slice: DerivedSlice, hook: DeriveHook): () => void;
|
|
79
|
+
/**
|
|
80
|
+
* How many writes a slice has had so far: a cache key that moves at once on every write,
|
|
81
|
+
* before the pass that derives it.
|
|
82
|
+
* @param slice - The slice.
|
|
83
|
+
* @returns The count.
|
|
84
|
+
*/
|
|
85
|
+
writes(slice: DerivedSlice): number;
|
|
86
|
+
/**
|
|
87
|
+
* Mark a key of a slice changed, and schedule a pass.
|
|
88
|
+
* @param slice - The slice.
|
|
89
|
+
* @param key - The key; "" for a whole-value slice.
|
|
90
|
+
*/
|
|
91
|
+
touch(slice: DerivedSlice, key: string): void;
|
|
92
|
+
/**
|
|
93
|
+
* Take live state as what the picture shows, with nothing left to derive: the baseline is
|
|
94
|
+
* drawn by the renderer's first draw, not by a pass.
|
|
95
|
+
*/
|
|
96
|
+
adoptBaseline(): void;
|
|
97
|
+
/**
|
|
98
|
+
* What the pass being derived is catching up with: `"command"` for a forward change, or the
|
|
99
|
+
* history call or rollback that set the restoring flag.
|
|
100
|
+
* @returns The cause.
|
|
101
|
+
*/
|
|
102
|
+
get cause(): "command" | "undo" | "redo" | "restore" | "rollback";
|
|
103
|
+
/**
|
|
104
|
+
* What the pass running now catches up with, for the whole of the pass: `cause` turns back to
|
|
105
|
+
* `"command"` once the `arrangement` hook has run, which hooks after it still need to know.
|
|
106
|
+
* @returns The cause the pass started with.
|
|
107
|
+
*/
|
|
108
|
+
get passCause(): "command" | "undo" | "redo" | "restore" | "rollback";
|
|
109
|
+
/**
|
|
110
|
+
* Set the restoring flag until the next pass has run its `arrangement` hook.
|
|
111
|
+
* @param cause - What is restoring: an undo, a redo, a restore or a rollback.
|
|
112
|
+
*/
|
|
113
|
+
restore(cause?: "undo" | "redo" | "restore" | "rollback"): void;
|
|
114
|
+
/**
|
|
115
|
+
* Settles when the picture has caught up with every change made so far.
|
|
116
|
+
* @returns The promise of the pass that takes the latest change; resolved at once when none
|
|
117
|
+
* is scheduled or running.
|
|
118
|
+
*/
|
|
119
|
+
settled(): Promise<void>;
|
|
120
|
+
/** Make sure a pass will take the changes made so far. */
|
|
121
|
+
private schedule;
|
|
122
|
+
/** Run passes until nothing is dirty. */
|
|
123
|
+
private drain;
|
|
124
|
+
/**
|
|
125
|
+
* Call one hook, reporting what it throws.
|
|
126
|
+
* @param hook - The hook.
|
|
127
|
+
* @param target - The state the pass derives to.
|
|
128
|
+
* @param keys - The slice's dirty keys.
|
|
129
|
+
*/
|
|
130
|
+
private call;
|
|
131
|
+
}
|
|
132
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The canonical state digest: one string that is equal for two states exactly when they
|
|
3
|
+
* hold the same project. The round-trip and random-sequence tests compare it before and after
|
|
4
|
+
* undo and redo.
|
|
5
|
+
*
|
|
6
|
+
* Canonical means order-free where order carries no meaning: map and set entries are sorted, and
|
|
7
|
+
* object keys are sorted. Functions (a compiled selector's predicate) are left out, because they
|
|
8
|
+
* are derived from data that is hashed.
|
|
9
|
+
*
|
|
10
|
+
* The graph part hashes the `graph` slice (the records by id and the graph-level values), and,
|
|
11
|
+
* given the snapshot, the rows behind it: node ids in row order, edges in row order
|
|
12
|
+
* with their endpoints and weights, and every column of the snapshot's tables except the two the
|
|
13
|
+
* positions lane lends it. With `arrangement`, those two are hashed as well: the coordinates and
|
|
14
|
+
* pin bytes the lane holds now, which is the arrangement undo and redo restore. The `arrangement`
|
|
15
|
+
* slice itself is not hashed: it names the last capture, a record of how the lane got there.
|
|
16
|
+
*/
|
|
17
|
+
import type { GraphSnapshot } from "@graphty/graph-format";
|
|
18
|
+
import type { ProjectState } from "./state";
|
|
19
|
+
/** Which optional parts a digest includes. */
|
|
20
|
+
interface DigestOptions {
|
|
21
|
+
/** Hash the positions lane too: its coordinates and pin bytes. Needs `snapshot`. */
|
|
22
|
+
readonly arrangement?: boolean;
|
|
23
|
+
/** The snapshot of the graph the state holds, whose rows are hashed with the slice. */
|
|
24
|
+
readonly snapshot?: GraphSnapshot;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The canonical digest of a project state.
|
|
28
|
+
* @param state - The state.
|
|
29
|
+
* @param options - Which optional parts to include.
|
|
30
|
+
* @returns A digest, equal for equal states.
|
|
31
|
+
*/
|
|
32
|
+
export declare function stateDigest(state: ProjectState, options?: DigestOptions): string;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The only writer of project state: drafts, the patches they seal into, and applying a
|
|
3
|
+
* patch forward or backward.
|
|
4
|
+
*
|
|
5
|
+
* A draft writes through to live state as it goes and records, for each key it writes, the key's
|
|
6
|
+
* value just before its first write (its prior) and the value it last wrote (its next). Undo puts
|
|
7
|
+
* the priors back and redo puts the nexts back, as the identical objects.
|
|
8
|
+
*
|
|
9
|
+
* Two drafts can be open at once. When one writes a key the other has already written, the key
|
|
10
|
+
* is handed over: the later writer takes the earlier one's prior as its own, and the earlier one
|
|
11
|
+
* drops the key. So each key is in exactly one open draft, a rollback never undoes somebody
|
|
12
|
+
* else's later write, and undoing every step still returns to the state before all of them. See
|
|
13
|
+
* design/undo/undo-design.md section 4.3, "Value slices hand the key over".
|
|
14
|
+
*
|
|
15
|
+
* This module covers the value slices. The op-log slices (`graph`, `pins`) have writers of their
|
|
16
|
+
* own (`./graphOps.ts`), which write live state themselves and hand the draft an {@link OpLogEntry}
|
|
17
|
+
* saying how to put the write back and do it again; the draft keeps those entries in order, and
|
|
18
|
+
* undo, redo and rollback run them. The coordinates a `positions.set` writes are kept as a row
|
|
19
|
+
* patch beside them (`./arrangement.ts`); the history, not the draft, restores them.
|
|
20
|
+
*/
|
|
21
|
+
import type { CameraState } from "../../camera/types";
|
|
22
|
+
import type { RunId, SetId } from "../../catalog/types";
|
|
23
|
+
import type { ElementSet } from "../sets/types";
|
|
24
|
+
import type { CompiledLayer } from "../styles/Layer";
|
|
25
|
+
import { type RowPatch } from "./arrangement";
|
|
26
|
+
import type { TouchedIds } from "./graphOps";
|
|
27
|
+
import type { LayoutChoice, ProjectState, RunEntry, VisibilityState } from "./state";
|
|
28
|
+
/** Stands for "the key had no value": a map key that was not there. */
|
|
29
|
+
export declare const ABSENT: unique symbol;
|
|
30
|
+
/** The slices a draft writes by value. */
|
|
31
|
+
type ValueSlice = "config" | "layout" | "runs" | "styles" | "visibility" | "sets" | "views";
|
|
32
|
+
/** One key a patch wrote: what it held before, and what the patch left in it. */
|
|
33
|
+
interface PatchEntry {
|
|
34
|
+
readonly slice: ValueSlice;
|
|
35
|
+
/** The key within the slice; "" for the whole-value slices `styles` and `layout`. */
|
|
36
|
+
readonly key: string;
|
|
37
|
+
readonly prior: unknown;
|
|
38
|
+
readonly next: unknown;
|
|
39
|
+
}
|
|
40
|
+
/** A slice a patch can touch, by value, as an op-log, or as coordinates. */
|
|
41
|
+
export type Slice = ValueSlice | "graph" | "pins" | "arrangement";
|
|
42
|
+
/**
|
|
43
|
+
* One write to an op-log slice, recorded by the primitive that made it: live state already holds
|
|
44
|
+
* the write, and this says how to undo and redo it on resolved values. An entry may still grow
|
|
45
|
+
* while its draft is open (a chunked writer appends rows to it); it is never changed once sealed.
|
|
46
|
+
*/
|
|
47
|
+
export interface OpLogEntry {
|
|
48
|
+
readonly slice: "graph" | "pins";
|
|
49
|
+
/** Put the write back. `rollback` is true when the group never recorded it. */
|
|
50
|
+
undo(rollback: boolean): void;
|
|
51
|
+
/** Write it again, exactly as it was written. */
|
|
52
|
+
redo(): void;
|
|
53
|
+
/** What it retains, approximately, in bytes. */
|
|
54
|
+
bytes(): number;
|
|
55
|
+
/**
|
|
56
|
+
* Report the node and edge ids it wrote, for the selection after an undo or a redo.
|
|
57
|
+
* @param into - Where to report them.
|
|
58
|
+
*/
|
|
59
|
+
touched(into: TouchedIds): void;
|
|
60
|
+
}
|
|
61
|
+
/** What a sealed draft recorded. Frozen. */
|
|
62
|
+
export interface Patch {
|
|
63
|
+
readonly entries: readonly PatchEntry[];
|
|
64
|
+
/** The op-log writes, in the order they were made. */
|
|
65
|
+
readonly log: readonly OpLogEntry[];
|
|
66
|
+
/** The rows `positions.set` wrote, or null. */
|
|
67
|
+
readonly rows: RowPatch | null;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Whether a patch recorded anything.
|
|
71
|
+
* @param patch - The patch.
|
|
72
|
+
* @returns True when it wrote a value key or an op-log entry.
|
|
73
|
+
*/
|
|
74
|
+
export declare function isEmptyPatch(patch: Patch): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* A patch without the value entries that wrote what was there already, so a command that set
|
|
77
|
+
* something to its current value records no step.
|
|
78
|
+
* @param patch - The patch.
|
|
79
|
+
* @returns It, or a copy without those entries.
|
|
80
|
+
*/
|
|
81
|
+
export declare function withoutNoOps(patch: Patch): Patch;
|
|
82
|
+
/**
|
|
83
|
+
* What a patch retains, for the history's byte budget.
|
|
84
|
+
* @param patch - The patch.
|
|
85
|
+
* @returns Bytes; value entries are held by reference and count nothing here.
|
|
86
|
+
*/
|
|
87
|
+
export declare function patchBytes(patch: Patch): number;
|
|
88
|
+
/**
|
|
89
|
+
* Report the node and edge ids a patch touched: its op-log writes, the rows `positions.set` wrote,
|
|
90
|
+
* and the node members of a fixed set it wrote or removed. Value slices name no element.
|
|
91
|
+
* @param patch - The patch.
|
|
92
|
+
* @param into - Where to report them.
|
|
93
|
+
*/
|
|
94
|
+
export declare function touchedBy(patch: Patch, into: TouchedIds): void;
|
|
95
|
+
/**
|
|
96
|
+
* What the run results and the kept sets a patch holds retain, counted once across the history:
|
|
97
|
+
* each result's columns and caches, each id index that is not the resident snapshot's, and each
|
|
98
|
+
* set record (design/undo/undo-design.md section 7).
|
|
99
|
+
* @param patch - The patch.
|
|
100
|
+
* @param token - The resident snapshot's graph token.
|
|
101
|
+
* @param seen - Results and indexes already counted against an older step.
|
|
102
|
+
* @returns Bytes.
|
|
103
|
+
*/
|
|
104
|
+
export declare function patchCharge(patch: Patch, token: number, seen: WeakSet<object>): number;
|
|
105
|
+
/** Writes one key of a keyed slice. */
|
|
106
|
+
interface KeyedWriter<K extends string, V> {
|
|
107
|
+
set(key: K, value: V): void;
|
|
108
|
+
delete(key: K): void;
|
|
109
|
+
}
|
|
110
|
+
/** An open draft: typed writers per value slice, and nothing else. */
|
|
111
|
+
export interface Draft {
|
|
112
|
+
styles: readonly CompiledLayer[];
|
|
113
|
+
layout: LayoutChoice | null;
|
|
114
|
+
readonly config: KeyedWriter<string, unknown>;
|
|
115
|
+
readonly runs: KeyedWriter<RunId, RunEntry>;
|
|
116
|
+
readonly sets: KeyedWriter<SetId, ElementSet>;
|
|
117
|
+
readonly views: KeyedWriter<string, CameraState>;
|
|
118
|
+
readonly visibility: {
|
|
119
|
+
set<K extends keyof VisibilityState>(key: K, value: VisibilityState[K]): void;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Keep an op-log write, made to live state already, so undo, redo and rollback can reach it.
|
|
123
|
+
* @param entry - How to put it back and do it again.
|
|
124
|
+
*/
|
|
125
|
+
log(entry: OpLogEntry): void;
|
|
126
|
+
/**
|
|
127
|
+
* Keep rows `positions.set` wrote to the lane already, merged with any the draft holds.
|
|
128
|
+
* @param rows - The rows, with their prior and new values.
|
|
129
|
+
*/
|
|
130
|
+
arrange(rows: RowPatch): void;
|
|
131
|
+
/** Close the draft and hand back what it recorded. */
|
|
132
|
+
seal(): Patch;
|
|
133
|
+
/**
|
|
134
|
+
* Close the draft and put back every key it still holds, through `applyBackward`.
|
|
135
|
+
* @returns What was reverted; no entries when nothing live changed.
|
|
136
|
+
*/
|
|
137
|
+
rollback(): Patch;
|
|
138
|
+
/**
|
|
139
|
+
* Remember what the draft holds now.
|
|
140
|
+
* @returns A function that puts back every key written since, releases the keys first written
|
|
141
|
+
* since, and returns the slices it changed. Keys handed to another draft since are theirs.
|
|
142
|
+
*/
|
|
143
|
+
checkpoint(): () => readonly Slice[];
|
|
144
|
+
}
|
|
145
|
+
/** Project state plus the drafts that write it. */
|
|
146
|
+
export interface ProjectStore {
|
|
147
|
+
readonly state: ProjectState;
|
|
148
|
+
open(): Draft;
|
|
149
|
+
/** Redo: write every key's `next`. */
|
|
150
|
+
applyForward(patch: Patch): void;
|
|
151
|
+
/** Undo: write every key's `prior`. */
|
|
152
|
+
applyBackward(patch: Patch): void;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Wrap a state as a store. The store is the state's only writer from here on.
|
|
156
|
+
* @param initial - The state; its maps must be the store's alone (see `createProjectState`).
|
|
157
|
+
* @param onWrite - Told of every key written to live state, whoever wrote it: a draft, undo,
|
|
158
|
+
* redo or a rollback. The derivation lane marks the key dirty.
|
|
159
|
+
* @returns The store.
|
|
160
|
+
*/
|
|
161
|
+
export declare function createProjectStore(initial: ProjectState, onWrite?: (slice: ValueSlice, key: string) => void): ProjectStore;
|
|
162
|
+
/**
|
|
163
|
+
* One patch doing what `older` and then `newer` did: each key keeps its first prior and takes
|
|
164
|
+
* its last written value. How a coalesced step absorbs the next edit.
|
|
165
|
+
* @param older - The patch recorded first.
|
|
166
|
+
* @param newer - The patch recorded after it.
|
|
167
|
+
* @returns The merged patch, frozen.
|
|
168
|
+
*/
|
|
169
|
+
export declare function mergePatches(older: Patch, newer: Patch): Patch;
|
|
170
|
+
/**
|
|
171
|
+
* Freeze an object and everything reachable from it, in place.
|
|
172
|
+
* @param value - The value.
|
|
173
|
+
* @returns The same value.
|
|
174
|
+
*/
|
|
175
|
+
export declare function deepFreeze<T>(value: T): T;
|
|
176
|
+
/**
|
|
177
|
+
* A node or edge record as the `graph` slice keeps it: deep-frozen. Plain objects and arrays not
|
|
178
|
+
* frozen yet are copied as they are frozen, so the caller's own object is never frozen under it;
|
|
179
|
+
* anything else is copied with `structuredClone`. A value already frozen is kept as it is, which
|
|
180
|
+
* is what makes patching one key of a large record cost that key and not the record.
|
|
181
|
+
* @param value - The record, or a value inside one.
|
|
182
|
+
* @returns The frozen value.
|
|
183
|
+
*/
|
|
184
|
+
export declare function frozenRecord<T>(value: T): T;
|
|
185
|
+
/**
|
|
186
|
+
* Copy a command argument that will be stored, and deep-freeze the copy, so a caller mutating
|
|
187
|
+
* its own object afterwards changes nothing in state.
|
|
188
|
+
* @param value - The argument, as the caller handed it in.
|
|
189
|
+
* @param byReference - Keys whose values are kept as the caller's own objects, wherever they
|
|
190
|
+
* appear, neither copied nor frozen (a style layer's `userData`).
|
|
191
|
+
* @returns A frozen copy.
|
|
192
|
+
*/
|
|
193
|
+
export declare function deepFreezeArgs<T>(value: T, byReference?: readonly string[]): T;
|
|
194
|
+
export {};
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The graph primitives: the only writers of the `graph` slice and of the builder behind it.
|
|
3
|
+
*
|
|
4
|
+
* The `pins` slice is an op-log too, written here: a pin or a release, and the pins a removal
|
|
5
|
+
* takes with the rows it removes, so undoing the removal pins them again.
|
|
6
|
+
*
|
|
7
|
+
* A primitive writes live state at once and records, beside the write, the resolved values its
|
|
8
|
+
* inverse needs: the ids it added, the prior records of what it patched, an edge's endpoints,
|
|
9
|
+
* weight and element-assigned id. Undo and redo write those values straight back into the builder
|
|
10
|
+
* and the slice. They never go through ingest, so a change of the id path, the repeated-edge policy
|
|
11
|
+
* or the weight path made after the write does not change what redo writes. See
|
|
12
|
+
* design/undo/undo-design.md section 3.4, "The `graph` slice is an op-log".
|
|
13
|
+
*
|
|
14
|
+
* A {@link GraphWriter} is what ingest writes through. One bound to a command's draft records one
|
|
15
|
+
* op-log entry per writer. A writer with no draft is a write outside the dispatcher: strict state
|
|
16
|
+
* throws, and production logs it once. Only a data manager built without a session, which has no
|
|
17
|
+
* history to bypass, writes with no draft.
|
|
18
|
+
*
|
|
19
|
+
* Nothing here reaches Babylon.js, Lit or the DOM.
|
|
20
|
+
*/
|
|
21
|
+
import { type GraphSnapshot } from "@graphty/graph-format";
|
|
22
|
+
import type { EdgeId, NodeId } from "../../catalog/types";
|
|
23
|
+
import type { GraphStore } from "../../data/GraphStore";
|
|
24
|
+
import { type Draft, type OpLogEntry } from "./draft";
|
|
25
|
+
import { type GraphRecord, type GraphSlice } from "./state";
|
|
26
|
+
/** Which kind of element a record belongs to. */
|
|
27
|
+
type RecordTarget = "node" | "edge";
|
|
28
|
+
/** What became of a file's declared direction when it reached the builder. */
|
|
29
|
+
export type DirectionOutcome = "applied" | "unchanged" | "config-wins" | "edges-present";
|
|
30
|
+
/** Where the graph slice lives, and who hears of a write to it. */
|
|
31
|
+
interface GraphHome {
|
|
32
|
+
/** The slice now. */
|
|
33
|
+
read(): GraphSlice;
|
|
34
|
+
/** Replace the slice object (its maps are shared): how a new token lands. */
|
|
35
|
+
write(slice: GraphSlice): void;
|
|
36
|
+
/** A key of the slice changed; the derivation lane marks it. */
|
|
37
|
+
touch(key: string): void;
|
|
38
|
+
/** The `pins` slice now. */
|
|
39
|
+
pins(): Set<NodeId>;
|
|
40
|
+
/** A node's pin changed; the derivation lane marks it. */
|
|
41
|
+
touchPin(id: NodeId): void;
|
|
42
|
+
/** Whether strict state is on for this home. */
|
|
43
|
+
readonly strict: boolean;
|
|
44
|
+
/** Whether a history lives here: false for a data manager built without a session. */
|
|
45
|
+
readonly session: boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The lane key of a node's record and row.
|
|
49
|
+
* @param id - The node id.
|
|
50
|
+
* @returns The key; JSON, so 1 and "1" stay two keys.
|
|
51
|
+
*/
|
|
52
|
+
export declare const nodeKey: (id: NodeId) => string;
|
|
53
|
+
/**
|
|
54
|
+
* The node id a lane key names.
|
|
55
|
+
* @param key - A key {@link nodeKey} made.
|
|
56
|
+
* @returns The id.
|
|
57
|
+
*/
|
|
58
|
+
export declare const nodeOfKey: (key: string) => NodeId;
|
|
59
|
+
/**
|
|
60
|
+
* The lane key of an edge's record and row.
|
|
61
|
+
* @param id - The edge id.
|
|
62
|
+
* @returns The key.
|
|
63
|
+
*/
|
|
64
|
+
export declare const edgeKey: (id: EdgeId) => string;
|
|
65
|
+
/** The lane key marking that node rows were added: a forward pass starts the layout and frames. */
|
|
66
|
+
export declare const NODES_ADDED = "rows:nodes";
|
|
67
|
+
/** The lane key marking that edge rows were added: a forward pass starts the layout. */
|
|
68
|
+
export declare const EDGES_ADDED = "rows:edges";
|
|
69
|
+
/**
|
|
70
|
+
* The key touched with any write that changes the graph's rows, weights or direction rather than
|
|
71
|
+
* only its records' attributes: what tells a hook that a record edit is all a pass has to follow.
|
|
72
|
+
*/
|
|
73
|
+
export declare const ROWS_MOVED = "rows:moved";
|
|
74
|
+
/**
|
|
75
|
+
* What a snapshot holds, estimated from its storage: the adjacency arrays, every column's arrays,
|
|
76
|
+
* and an id slot and a map entry per node. Arrays a snapshot derives on first access are not
|
|
77
|
+
* counted until something asks for them.
|
|
78
|
+
* @param snapshot - The snapshot.
|
|
79
|
+
* @returns Bytes.
|
|
80
|
+
*/
|
|
81
|
+
export declare function snapshotBytes(snapshot: GraphSnapshot): number;
|
|
82
|
+
/** The three maps of the `graph` slice. */
|
|
83
|
+
interface GraphMaps {
|
|
84
|
+
readonly nodes: ReadonlyMap<NodeId, GraphRecord>;
|
|
85
|
+
readonly edges: ReadonlyMap<EdgeId, GraphRecord>;
|
|
86
|
+
readonly values: ReadonlyMap<string, unknown>;
|
|
87
|
+
}
|
|
88
|
+
/** What a removal took out, by id. */
|
|
89
|
+
interface Removed {
|
|
90
|
+
readonly nodes: readonly NodeId[];
|
|
91
|
+
readonly edges: readonly EdgeId[];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* What ingest writes through: one command's writes.
|
|
95
|
+
*
|
|
96
|
+
* Every method writes live state before it returns, so a getter reads the write at once.
|
|
97
|
+
*/
|
|
98
|
+
export interface GraphWriter {
|
|
99
|
+
/** The store written, for reads. */
|
|
100
|
+
readonly store: GraphStore;
|
|
101
|
+
/**
|
|
102
|
+
* Add a node row and its record, or give a row the builder already holds (an endpoint an edge
|
|
103
|
+
* created) its record.
|
|
104
|
+
* @param id - The extracted id; one graph-format will not store keeps its record and gets no row.
|
|
105
|
+
* @param record - The record.
|
|
106
|
+
* @param seed - The file coordinate, in file units, or null.
|
|
107
|
+
* @returns The row, INVALID_INDEX for an id with none, and whether the builder already held it.
|
|
108
|
+
*/
|
|
109
|
+
addNode(id: NodeId, record: GraphRecord, seed: readonly [number, number, number] | null): {
|
|
110
|
+
index: number;
|
|
111
|
+
merged: boolean;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Add an edge row with a fresh element-assigned id, and its record.
|
|
115
|
+
* @param source - The resolved source id.
|
|
116
|
+
* @param target - The resolved target id.
|
|
117
|
+
* @param weight - The resolved weight.
|
|
118
|
+
* @param record - The record.
|
|
119
|
+
* @param fileId - The file's own id for the edge, read at `edgeIdPath`, when it has one.
|
|
120
|
+
* @returns The row and the id; INVALID_INDEX for both when either endpoint cannot be stored.
|
|
121
|
+
*/
|
|
122
|
+
addEdge(source: unknown, target: unknown, weight: number, record: GraphRecord, fileId?: string | number): {
|
|
123
|
+
index: number;
|
|
124
|
+
edgeId: number;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Fold a repeated edge record into the edge it repeats: a new weight, and for the `last`
|
|
128
|
+
* policy its record too.
|
|
129
|
+
* @param edgeIndex - The row of the edge that survives.
|
|
130
|
+
* @param weight - Its new weight.
|
|
131
|
+
* @param record - Its new record, or null to keep the one it has.
|
|
132
|
+
*/
|
|
133
|
+
mergeEdge(edgeIndex: number, weight: number, record: GraphRecord | null): void;
|
|
134
|
+
/**
|
|
135
|
+
* Patch one record: the named keys take the new values, the rest are kept.
|
|
136
|
+
* @param target - Node or edge.
|
|
137
|
+
* @param id - Its id.
|
|
138
|
+
* @param values - The new values.
|
|
139
|
+
* @returns False when the graph holds no such element.
|
|
140
|
+
*/
|
|
141
|
+
setAttributes(target: RecordTarget, id: NodeId, values: GraphRecord): boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Set graph-level values: the import report, graph-level results.
|
|
144
|
+
* @param values - The values by name.
|
|
145
|
+
*/
|
|
146
|
+
setGraphValues(values: Readonly<Record<string, unknown>>): void;
|
|
147
|
+
/**
|
|
148
|
+
* Give the builder the direction a file declared, without overruling the consumer.
|
|
149
|
+
* @param directed - The declared direction.
|
|
150
|
+
* @param statedBy - The text that declared it.
|
|
151
|
+
* @returns What happened.
|
|
152
|
+
*/
|
|
153
|
+
setDirected(directed: boolean, statedBy: string): DirectionOutcome;
|
|
154
|
+
/**
|
|
155
|
+
* Remove nodes and every edge attached to them, keeping everything their undo needs.
|
|
156
|
+
* @param ids - The node ids; one the graph does not hold is skipped.
|
|
157
|
+
* @returns What was removed.
|
|
158
|
+
*/
|
|
159
|
+
removeNodes(ids: readonly NodeId[]): Removed;
|
|
160
|
+
/**
|
|
161
|
+
* Remove edges, keeping everything their undo needs.
|
|
162
|
+
* @param ids - The edge ids; one the graph does not hold is skipped.
|
|
163
|
+
* @returns What was removed.
|
|
164
|
+
*/
|
|
165
|
+
removeEdges(ids: readonly EdgeId[]): Removed;
|
|
166
|
+
/** Empty the graph: every row, record and graph-level value. */
|
|
167
|
+
clear(): void;
|
|
168
|
+
}
|
|
169
|
+
/** The graph primitives of one session (or of one data manager with no session). */
|
|
170
|
+
export declare class GraphOps {
|
|
171
|
+
private readonly home;
|
|
172
|
+
private readonly tokens;
|
|
173
|
+
private readonly epochs;
|
|
174
|
+
private warned;
|
|
175
|
+
/** The store the last writer wrote, which strict state checks for writes made around it. */
|
|
176
|
+
private store;
|
|
177
|
+
/**
|
|
178
|
+
* Primitives over a slice held somewhere else, a session's project state.
|
|
179
|
+
* @param home - Where the slice lives and who hears of writes.
|
|
180
|
+
*/
|
|
181
|
+
constructor(home: GraphHome);
|
|
182
|
+
/**
|
|
183
|
+
* Primitives with nothing to record into: a data manager built without a session. There is
|
|
184
|
+
* no history for a write to bypass, so every write is accepted and recorded nowhere.
|
|
185
|
+
* @returns The primitives, over a slice of their own.
|
|
186
|
+
*/
|
|
187
|
+
static standalone(): GraphOps;
|
|
188
|
+
/**
|
|
189
|
+
* The slice now.
|
|
190
|
+
* @returns The `graph` slice.
|
|
191
|
+
*/
|
|
192
|
+
get slice(): GraphSlice;
|
|
193
|
+
/**
|
|
194
|
+
* A writer whose writes are recorded in a command's draft, or, handed no draft, a write
|
|
195
|
+
* outside the dispatcher: refused under strict state, logged once otherwise.
|
|
196
|
+
* @param draft - The command's draft, or null.
|
|
197
|
+
* @param store - The store to write.
|
|
198
|
+
* @returns The writer.
|
|
199
|
+
*/
|
|
200
|
+
writer(draft: Draft | null, store: GraphStore): GraphWriter;
|
|
201
|
+
/**
|
|
202
|
+
* Strict: throw when the builder of the store last written was mutated outside the graph
|
|
203
|
+
* primitives, or its resident snapshot's arrays were written in place. The dispatcher asks at
|
|
204
|
+
* each dispatch and each commit.
|
|
205
|
+
*/
|
|
206
|
+
checkStore(): void;
|
|
207
|
+
/**
|
|
208
|
+
* Take a token never issued before and make it the slice's.
|
|
209
|
+
* @returns The token.
|
|
210
|
+
*/
|
|
211
|
+
retoken(): number;
|
|
212
|
+
/**
|
|
213
|
+
* Put a recorded token back: undo and redo restore the rows it names exactly.
|
|
214
|
+
* @param token - The token.
|
|
215
|
+
*/
|
|
216
|
+
restoreToken(token: number): void;
|
|
217
|
+
/**
|
|
218
|
+
* Take an epoch never issued before and make it the slice's: the graph is a new dataset, whose
|
|
219
|
+
* coordinates are never mapped from another's.
|
|
220
|
+
* @returns The epoch.
|
|
221
|
+
*/
|
|
222
|
+
newEpoch(): number;
|
|
223
|
+
/**
|
|
224
|
+
* Put a recorded epoch back.
|
|
225
|
+
* @param epoch - The epoch.
|
|
226
|
+
*/
|
|
227
|
+
restoreEpoch(epoch: number): void;
|
|
228
|
+
/**
|
|
229
|
+
* Mark a key dirty on the lane.
|
|
230
|
+
* @param key - The key.
|
|
231
|
+
*/
|
|
232
|
+
touch(key: string): void;
|
|
233
|
+
/**
|
|
234
|
+
* Pin or release nodes in the `pins` slice, recording the change in `draft`.
|
|
235
|
+
* @param draft - The command's draft, or null for a write with no history to record into.
|
|
236
|
+
* @param ids - The nodes.
|
|
237
|
+
* @param pinned - Pin, or release.
|
|
238
|
+
* @returns The ids whose pin changed.
|
|
239
|
+
*/
|
|
240
|
+
setPinned(draft: Draft | null, ids: readonly NodeId[], pinned: boolean): NodeId[];
|
|
241
|
+
/**
|
|
242
|
+
* The `pins` slice, for the entries that write it.
|
|
243
|
+
* @returns The set.
|
|
244
|
+
*/
|
|
245
|
+
pins(): Set<NodeId>;
|
|
246
|
+
/**
|
|
247
|
+
* Mark a node's pin dirty on the lane.
|
|
248
|
+
* @param id - The node.
|
|
249
|
+
*/
|
|
250
|
+
touchPin(id: NodeId): void;
|
|
251
|
+
/**
|
|
252
|
+
* Swap the slice's three maps, keeping the token.
|
|
253
|
+
* @param maps - The maps to hold from now on.
|
|
254
|
+
*/
|
|
255
|
+
swapMaps(maps: GraphMaps): void;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* The node and edge ids the steps an undo, a redo or a restore passed touched, which the session
|
|
259
|
+
* then selects (design/undo/undo-design.md section 8). Collection stops, and nothing is selected,
|
|
260
|
+
* once a replace or a clear passes or more ids than the limit are touched: selecting everything
|
|
261
|
+
* says nothing, and a selection built only to be truncated says less.
|
|
262
|
+
*/
|
|
263
|
+
export declare class TouchedIds {
|
|
264
|
+
private readonly limit;
|
|
265
|
+
readonly nodes: Set<NodeId>;
|
|
266
|
+
readonly edges: Set<string>;
|
|
267
|
+
/** Whether to leave the selection as it is. */
|
|
268
|
+
skip: boolean;
|
|
269
|
+
/**
|
|
270
|
+
* An empty collection.
|
|
271
|
+
* @param limit - The most ids worth selecting: the selection cap.
|
|
272
|
+
*/
|
|
273
|
+
constructor(limit: number);
|
|
274
|
+
/**
|
|
275
|
+
* A node was touched.
|
|
276
|
+
* @param id - The node.
|
|
277
|
+
*/
|
|
278
|
+
node(id: NodeId): void;
|
|
279
|
+
/**
|
|
280
|
+
* An edge was touched.
|
|
281
|
+
* @param id - The edge.
|
|
282
|
+
*/
|
|
283
|
+
edge(id: EdgeId): void;
|
|
284
|
+
/** Everything was touched: a replace or a clear. Select nothing. */
|
|
285
|
+
all(): void;
|
|
286
|
+
/** Give up once past the limit. */
|
|
287
|
+
private check;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Whether undoing a patch puts removed nodes back. Their rows come back at the coordinates they
|
|
291
|
+
* had when they were removed, which is not the arrangement below the step when the layout had
|
|
292
|
+
* moved them since the last rest point.
|
|
293
|
+
* @param log - The patch's op-log writes.
|
|
294
|
+
* @returns True when one of them removed a node.
|
|
295
|
+
*/
|
|
296
|
+
export declare function restoresNodes(log: readonly OpLogEntry[]): boolean;
|
|
297
|
+
/**
|
|
298
|
+
* Whether an op log added or removed nodes or edges, or changed an edge's weight: what sets a
|
|
299
|
+
* running layout moving. A record or value edit does not.
|
|
300
|
+
* @param log - The op log.
|
|
301
|
+
* @returns True when it changed the graph's shape.
|
|
302
|
+
*/
|
|
303
|
+
export declare function reshapes(log: readonly OpLogEntry[]): boolean;
|
|
304
|
+
export {};
|