@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
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
*/
|
|
26
26
|
import type { AlgorithmKey, FieldDescriptor, ResultShape, RunId } from "../../catalog/types";
|
|
27
27
|
import { GraphtyError } from "../../errors";
|
|
28
|
+
import type { RunEntry } from "../project/state";
|
|
28
29
|
import type { ResultSummary, RunResult } from "../results/types";
|
|
29
30
|
import type { HeldCaptures } from "../sets/captures";
|
|
30
31
|
import { type StyleSuggestion } from "../styles/derive";
|
|
@@ -62,8 +63,19 @@ export interface RunQueueContext {
|
|
|
62
63
|
/** The queue's operation id, which is not the run id. */
|
|
63
64
|
readonly id: string;
|
|
64
65
|
}
|
|
65
|
-
/**
|
|
66
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Write a finished run into project state: its entry in the `runs` slice and the layers it
|
|
68
|
+
* paints, in the step of the command that ran it. Throws to refuse, before anything is written.
|
|
69
|
+
* @param run - The run, finished and not yet settled: its record reads "succeeded".
|
|
70
|
+
* @returns Settles once the step is recorded and drawn, which is when the run's promise resolves.
|
|
71
|
+
*/
|
|
72
|
+
type RunCommit = (run: ManagedRun) => Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* A run's work, as the queue takes it.
|
|
75
|
+
* @param context - What the queue hands the operation.
|
|
76
|
+
* @param commit - For a run that is project state, how it writes itself when it finishes.
|
|
77
|
+
*/
|
|
78
|
+
export type RunBody = (context: RunQueueContext, commit?: RunCommit) => Promise<void>;
|
|
67
79
|
/** A handle on work that has been handed to the queue. */
|
|
68
80
|
export interface RunTicket {
|
|
69
81
|
/** Stop the work, whether it has started or is still waiting its turn. */
|
|
@@ -227,6 +239,15 @@ export interface RunSurroundings {
|
|
|
227
239
|
* @param phase - Which moment.
|
|
228
240
|
*/
|
|
229
241
|
notify?(phase: RunPhase): void;
|
|
242
|
+
/**
|
|
243
|
+
* The entry the `runs` slice holds for this run, for a run that is project state.
|
|
244
|
+
*
|
|
245
|
+
* Present, the run's result and record are read from the entry whenever no execution of it
|
|
246
|
+
* is under way, so an undo or a redo that swaps the entry changes what the same handle
|
|
247
|
+
* reports. Absent (a batch, a style edit), the handle reports its own last execution.
|
|
248
|
+
* @returns The entry, or undefined when the slice holds none.
|
|
249
|
+
*/
|
|
250
|
+
entry?(): RunEntry | undefined;
|
|
230
251
|
/**
|
|
231
252
|
* Mint the token that identifies one execution of this run (design/sets 5.2): a session nonce
|
|
232
253
|
* plus a session-wide counter. Called once when the work starts. Optional for the same reason
|
|
@@ -292,6 +313,10 @@ export declare class ManagedRun<T = RunResult> implements Run<T> {
|
|
|
292
313
|
private detachSignal;
|
|
293
314
|
private queueSink;
|
|
294
315
|
private settledFlag;
|
|
316
|
+
/** Whether the latest execution wrote the run into project state. */
|
|
317
|
+
private committed;
|
|
318
|
+
/** How many executions this handle has started. */
|
|
319
|
+
private generationValue;
|
|
295
320
|
/** Why a cancel is being honoured, when the run publishes what it has instead of rejecting. */
|
|
296
321
|
private cancelReason;
|
|
297
322
|
/**
|
|
@@ -325,6 +350,22 @@ export declare class ManagedRun<T = RunResult> implements Run<T> {
|
|
|
325
350
|
* @returns The status.
|
|
326
351
|
*/
|
|
327
352
|
get status(): RunStatus;
|
|
353
|
+
/**
|
|
354
|
+
* How many executions this run has started: its own first, and one per re-run.
|
|
355
|
+
* @returns The count.
|
|
356
|
+
*/
|
|
357
|
+
get generation(): number;
|
|
358
|
+
/**
|
|
359
|
+
* Whether an execution is waiting or working.
|
|
360
|
+
* @returns True while queued or running.
|
|
361
|
+
*/
|
|
362
|
+
private get live();
|
|
363
|
+
/**
|
|
364
|
+
* The record the `runs` slice holds for this run, when that is what the handle reports: the
|
|
365
|
+
* run is project state, nothing is executing, and the latest execution was recorded.
|
|
366
|
+
* @returns The held record, or undefined.
|
|
367
|
+
*/
|
|
368
|
+
private heldRecord;
|
|
328
369
|
/**
|
|
329
370
|
* How far along the run is.
|
|
330
371
|
* @returns The progress.
|
|
@@ -383,18 +424,34 @@ export declare class ManagedRun<T = RunResult> implements Run<T> {
|
|
|
383
424
|
* @returns The result, or undefined until the run succeeds.
|
|
384
425
|
*/
|
|
385
426
|
get result(): T | undefined;
|
|
427
|
+
/**
|
|
428
|
+
* The result the latest execution produced, before it is recorded: what a commit writes.
|
|
429
|
+
* @returns The result, or undefined when the execution produced none.
|
|
430
|
+
*/
|
|
431
|
+
get computed(): T | undefined;
|
|
386
432
|
/**
|
|
387
433
|
* The execution token of the current result: undefined until a result exists, and for a run
|
|
388
434
|
* whose surroundings mint none. Internal: not on the published `Run` interface.
|
|
389
435
|
* @returns The token.
|
|
390
436
|
*/
|
|
391
437
|
get resultExecution(): string | undefined;
|
|
438
|
+
/**
|
|
439
|
+
* The token of the execution that produced {@link ManagedRun.computed}, before it is recorded:
|
|
440
|
+
* what a commit writes with it.
|
|
441
|
+
* @returns The token.
|
|
442
|
+
*/
|
|
443
|
+
get computedExecution(): string | undefined;
|
|
392
444
|
/**
|
|
393
445
|
* The members of earlier executions' items that live references hold, by execution and item
|
|
394
446
|
* key. Internal: not on the published `Run` interface.
|
|
395
447
|
* @returns The captures.
|
|
396
448
|
*/
|
|
397
449
|
get held(): HeldCaptures;
|
|
450
|
+
/**
|
|
451
|
+
* The captures the latest execution holds, before it is recorded: what a commit writes.
|
|
452
|
+
* @returns The captures.
|
|
453
|
+
*/
|
|
454
|
+
get computedHeld(): HeldCaptures;
|
|
398
455
|
/**
|
|
399
456
|
* Why the run failed.
|
|
400
457
|
* @returns The error, or undefined when it did not.
|
|
@@ -436,6 +493,13 @@ export declare class ManagedRun<T = RunResult> implements Run<T> {
|
|
|
436
493
|
* @returns This run, restarted.
|
|
437
494
|
*/
|
|
438
495
|
rerun(): Run<T>;
|
|
496
|
+
/**
|
|
497
|
+
* Keep the run's promise from settling until other work done on its behalf has: a step that
|
|
498
|
+
* applies the layers of a run that did not need computing again. The promise settles as it
|
|
499
|
+
* would have, whatever that work does.
|
|
500
|
+
* @param work - The work.
|
|
501
|
+
*/
|
|
502
|
+
settleAfter(work: PromiseLike<unknown>): void;
|
|
439
503
|
/**
|
|
440
504
|
* Run the same result again with other parameters or another seed, keeping its id, so every
|
|
441
505
|
* style layer and reference bound to the result repaints from the new values. Work still
|
|
@@ -460,6 +524,7 @@ export declare class ManagedRun<T = RunResult> implements Run<T> {
|
|
|
460
524
|
/**
|
|
461
525
|
* The work, as the queue runs it.
|
|
462
526
|
* @param context - What the queue hands the operation.
|
|
527
|
+
* @param commit - For a run that is project state, how it writes itself once it finishes.
|
|
463
528
|
*/
|
|
464
529
|
private body;
|
|
465
530
|
/**
|
|
@@ -478,6 +543,13 @@ export declare class ManagedRun<T = RunResult> implements Run<T> {
|
|
|
478
543
|
* @param timeBox - The time box's signal, so an expired box becomes a partial result.
|
|
479
544
|
*/
|
|
480
545
|
private succeed;
|
|
546
|
+
/**
|
|
547
|
+
* Take in what the work produced: the result, its caveats and fields, and the final status.
|
|
548
|
+
* The promise is left for whoever settles it.
|
|
549
|
+
* @param outcome - What the work produced.
|
|
550
|
+
* @param timeBox - The time box's signal, so an expired box becomes a partial result.
|
|
551
|
+
*/
|
|
552
|
+
private finishWork;
|
|
481
553
|
/**
|
|
482
554
|
* Record a piece of work that threw.
|
|
483
555
|
* @param error - What it threw.
|
|
@@ -540,6 +612,10 @@ export declare class ManagedRun<T = RunResult> implements Run<T> {
|
|
|
540
612
|
* @param action - Resolve or reject.
|
|
541
613
|
*/
|
|
542
614
|
private settle;
|
|
543
|
-
/**
|
|
544
|
-
|
|
615
|
+
/**
|
|
616
|
+
* Open a new execution under the same id. What the last one produced -- its result, fields,
|
|
617
|
+
* caveats and timings -- stays readable until this one finishes: a re-run keeps what it had.
|
|
618
|
+
*/
|
|
619
|
+
private beginExecution;
|
|
545
620
|
}
|
|
621
|
+
export {};
|
|
@@ -18,12 +18,13 @@
|
|
|
18
18
|
* structural view of `OperationQueueManager` narrow enough that the session never imports the
|
|
19
19
|
* renderer's manager to talk to it.
|
|
20
20
|
*/
|
|
21
|
-
import { type AlgorithmDescriptor, type LayerId, type RunId, type Scope, type ScopeInput, type SetId } from "../../catalog/types";
|
|
21
|
+
import { type AlgorithmDescriptor, type AlgorithmKey, type LayerId, type RunId, type Scope, type ScopeInput, type SetId } from "../../catalog/types";
|
|
22
|
+
import { Dispatcher, type DispatchFunction } from "../project/Dispatcher";
|
|
22
23
|
import type { HeldCaptures } from "../sets/captures";
|
|
23
|
-
import type
|
|
24
|
+
import { type AutoApplyPolicy } from "../styles/autoApply";
|
|
24
25
|
import { type RunExecutor, type RunQueueContext } from "./Run";
|
|
25
26
|
import { type LiveKeyword } from "./runId";
|
|
26
|
-
import { type Caveats, type EngineVersions, type ResolvedScope, type RunChange, type RunsApi, type RunScopeFacts } from "./types";
|
|
27
|
+
import { type Caveats, type EngineVersions, type ResolvedScope, type Run, type RunChange, type RunsApi, type RunScopeFacts, type StartOptions } from "./types";
|
|
27
28
|
/**
|
|
28
29
|
* The element's operation queue, as a run needs it.
|
|
29
30
|
*
|
|
@@ -89,10 +90,11 @@ interface RunLayerBindings {
|
|
|
89
90
|
*/
|
|
90
91
|
bindings(runId: RunId): readonly LayerId[];
|
|
91
92
|
/**
|
|
92
|
-
* Remove layers, because the run they read is going away.
|
|
93
|
+
* Remove layers, because the run they read is going away. Used only by a runs API whose
|
|
94
|
+
* dispatcher has no style stack registered; a session removes them in the removal's own step.
|
|
93
95
|
* @param layerIds - The layers to remove.
|
|
94
96
|
*/
|
|
95
|
-
remove(layerIds: readonly LayerId[]): void;
|
|
97
|
+
remove?(layerIds: readonly LayerId[]): void;
|
|
96
98
|
}
|
|
97
99
|
/** Everything the runs API is built from. */
|
|
98
100
|
export interface RunsApiOptions {
|
|
@@ -163,6 +165,11 @@ export interface RunsApiOptions {
|
|
|
163
165
|
* @param change - The run's record, and which moment it reached.
|
|
164
166
|
*/
|
|
165
167
|
readonly onChange?: (change: RunChange) => void;
|
|
168
|
+
/**
|
|
169
|
+
* The dispatcher whose `runs` slice holds the finished runs and whose history records them.
|
|
170
|
+
* A session hands in its own; absent, the runs API keeps a private one over its queue.
|
|
171
|
+
*/
|
|
172
|
+
readonly dispatcher?: Dispatcher;
|
|
166
173
|
/** Called once per execution token minted, which is what advances the session input tick. */
|
|
167
174
|
readonly onExecution?: () => void;
|
|
168
175
|
/** Called when a run is removed, and with it its result (design/sets 11). */
|
|
@@ -176,7 +183,7 @@ export interface RunsApiOptions {
|
|
|
176
183
|
*/
|
|
177
184
|
readonly captureHeld?: (run: RunId, prior: HeldCaptures) => HeldCaptures;
|
|
178
185
|
}
|
|
179
|
-
/** The runs API, plus the
|
|
186
|
+
/** The runs API, plus the things a session needs and a consumer never calls. */
|
|
180
187
|
export interface SessionRunsApi extends RunsApi {
|
|
181
188
|
/**
|
|
182
189
|
* Whether the element minted this run's id rather than the author naming it with `as:`.
|
|
@@ -189,6 +196,16 @@ export interface SessionRunsApi extends RunsApi {
|
|
|
189
196
|
* @returns True when the element derived the id.
|
|
190
197
|
*/
|
|
191
198
|
isDerivedId(id: RunId): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Start one algorithm through a dispatch of the caller's: a transaction's, so the run joins
|
|
201
|
+
* its step, or the one a command hands its deferred members.
|
|
202
|
+
* @param dispatch - Where the run's command is dispatched.
|
|
203
|
+
* @param algorithm - Which algorithm to run.
|
|
204
|
+
* @param params - Its parameters.
|
|
205
|
+
* @param options - The scope, the seed, the id and the rest.
|
|
206
|
+
* @returns The run.
|
|
207
|
+
*/
|
|
208
|
+
startVia(dispatch: DispatchFunction, algorithm: AlgorithmKey, params?: Readonly<Record<string, unknown>>, options?: StartOptions): Run;
|
|
192
209
|
/**
|
|
193
210
|
* What a run keeps of earlier executions' items that live references hold (design/sets 5.2).
|
|
194
211
|
* @param id - The run id.
|
|
@@ -46,8 +46,11 @@ export declare function isRunId(value: unknown): value is RunId;
|
|
|
46
46
|
* "canceled" and "failed" are separate because a consumer treats them differently: a cancel is
|
|
47
47
|
* something a person did and needs no apology, a failure is something the consumer has to
|
|
48
48
|
* report. A time-boxed run that stopped early is neither -- it SUCCEEDS with `partial` set.
|
|
49
|
+
*
|
|
50
|
+
* "removed" is a finished run that undo has taken out of the project, or that `runs.remove`
|
|
51
|
+
* took away: its handle reports no result until a redo brings the run back.
|
|
49
52
|
*/
|
|
50
|
-
export declare const RUN_STATUSES: readonly ["queued", "running", "succeeded", "failed", "canceled"];
|
|
53
|
+
export declare const RUN_STATUSES: readonly ["queued", "running", "succeeded", "failed", "canceled", "removed"];
|
|
51
54
|
/** Where a run is in its life. */
|
|
52
55
|
export type RunStatus = (typeof RUN_STATUSES)[number];
|
|
53
56
|
/** The statuses a run never leaves once it reaches them. */
|
|
@@ -65,14 +68,15 @@ export declare function isRunStatus(value: unknown): value is RunStatus;
|
|
|
65
68
|
*/
|
|
66
69
|
export declare function isTerminalRunStatus(status: RunStatus): boolean;
|
|
67
70
|
/**
|
|
68
|
-
* The
|
|
71
|
+
* The moments a watcher is told about: the four of a run's own life, and the two of history.
|
|
69
72
|
*
|
|
70
73
|
* Coarser than {@link RunStatus} on purpose: a status bar draws the same thing for a run that
|
|
71
74
|
* failed and one that was cancelled -- it stops showing progress and reads the record -- so the
|
|
72
75
|
* distinction belongs in the record the notification carries rather than in the notification's
|
|
73
|
-
* own name.
|
|
76
|
+
* own name. "removed" and "restored" are an undo, a redo or a restore taking a finished run out
|
|
77
|
+
* of the project and putting it back; nothing was computed for either.
|
|
74
78
|
*/
|
|
75
|
-
export declare const RUN_PHASES: readonly ["queued", "start", "progress", "end"];
|
|
79
|
+
export declare const RUN_PHASES: readonly ["queued", "start", "progress", "end", "removed", "restored"];
|
|
76
80
|
/** Which moment in a run's life a notification is about. */
|
|
77
81
|
export type RunPhase = (typeof RUN_PHASES)[number];
|
|
78
82
|
/**
|
|
@@ -87,6 +91,13 @@ export interface RunChange {
|
|
|
87
91
|
readonly run: RunRecord;
|
|
88
92
|
/** Which moment this is. */
|
|
89
93
|
readonly phase: RunPhase;
|
|
94
|
+
/** What moved it: a command for the run's own life, or an undo, a redo or a restore. */
|
|
95
|
+
readonly cause: "command" | "undo" | "redo" | "restore" | "rollback";
|
|
96
|
+
/**
|
|
97
|
+
* How many times this run id has been executed, so a watcher keyed on the id can tell an old
|
|
98
|
+
* execution's `end` from a new one's.
|
|
99
|
+
*/
|
|
100
|
+
readonly generation: number;
|
|
90
101
|
}
|
|
91
102
|
/**
|
|
92
103
|
* How far a run has got.
|
|
@@ -315,6 +326,11 @@ export interface StartOptions extends RunOptions {
|
|
|
315
326
|
readonly exact?: boolean;
|
|
316
327
|
/** Ask for the approximate method at a chosen sample size. */
|
|
317
328
|
readonly sample?: number;
|
|
329
|
+
/**
|
|
330
|
+
* Also apply the layers the run suggests, on top of the stack, in the same step as the run,
|
|
331
|
+
* so one undo takes the run and those layers away together.
|
|
332
|
+
*/
|
|
333
|
+
readonly applySuggestedStyles?: boolean;
|
|
318
334
|
}
|
|
319
335
|
/**
|
|
320
336
|
* What a run paints when it first completes.
|
|
@@ -487,7 +503,9 @@ export interface Run<T = RunResult> extends PromiseLike<T> {
|
|
|
487
503
|
/** What qualifies the numbers. */
|
|
488
504
|
readonly caveats: Caveats;
|
|
489
505
|
/**
|
|
490
|
-
* The result, once there is one. Awaiting the run is the other way to get it.
|
|
506
|
+
* The result, once there is one. Awaiting the run is the other way to get it. Undefined
|
|
507
|
+
* again once undo has taken the run out of the project (`status` "removed"); a redo brings the
|
|
508
|
+
* same result object back.
|
|
491
509
|
*
|
|
492
510
|
* Spelled `?: T | undefined` rather than `?: T` because the implementation answers with a
|
|
493
511
|
* getter, and under a consumer's `exactOptionalPropertyTypes` a getter that can return
|
|
@@ -513,7 +531,8 @@ export interface Run<T = RunResult> extends PromiseLike<T> {
|
|
|
513
531
|
*
|
|
514
532
|
* The new run keeps the SAME id, so every style layer, legend and saved reference bound to
|
|
515
533
|
* it survives. That is what "re-run from a layer" needs, and it is why a binding never
|
|
516
|
-
* dangles after a re-run.
|
|
534
|
+
* dangles after a re-run. The last result stays readable until the new one is recorded, and
|
|
535
|
+
* undoing the re-run puts the previous result back without computing it again.
|
|
517
536
|
* @returns The run, which is this one restarted rather than a second entry.
|
|
518
537
|
*/
|
|
519
538
|
rerun(): Run<T>;
|
|
@@ -235,6 +235,20 @@ export declare class ElementMask<TId> {
|
|
|
235
235
|
* @returns A fresh `Uint8Array` of length {@link ElementMask.count}.
|
|
236
236
|
*/
|
|
237
237
|
bytes(): U8;
|
|
238
|
+
/**
|
|
239
|
+
* Replace the whole membership with bytes {@link ElementMask.bytes} handed out earlier: one
|
|
240
|
+
* per row, and the row count becomes their length. The revision moves, as it does for a
|
|
241
|
+
* remap, because the membership was rewritten wholesale.
|
|
242
|
+
* @param bytes - One byte per row, `1` for a member.
|
|
243
|
+
*/
|
|
244
|
+
load(bytes: U8): void;
|
|
245
|
+
/**
|
|
246
|
+
* A copy of this mask that refuses every write: the same rows, members and revision, so a
|
|
247
|
+
* reader keyed on `version` still sees the same number, but nothing done to the copy can
|
|
248
|
+
* reach this mask.
|
|
249
|
+
* @returns The copy.
|
|
250
|
+
*/
|
|
251
|
+
readOnlyCopy(): ElementMask<TId>;
|
|
238
252
|
/**
|
|
239
253
|
* The membership as a packed bitmap in graph-format's mask layout (ceil(length / 32) words,
|
|
240
254
|
* LSB-first): one pass of byte reads. A row at or past the live count is not a member.
|
|
@@ -32,31 +32,12 @@ import { type Capture } from "../sets/captures";
|
|
|
32
32
|
import { type ComponentLabels, type Resolution, type ResolveContext } from "../sets/resolve";
|
|
33
33
|
import type { SetsApi } from "../sets/types";
|
|
34
34
|
import type { FilterSources, FilterValueSource, ScopeLeaf } from "../visibility/filter";
|
|
35
|
-
import type { ElementMask
|
|
35
|
+
import type { ElementMask } from "./ElementMask";
|
|
36
|
+
import { edgeSpaceOf, nodeSpaceOf } from "./spaces";
|
|
36
37
|
export type { ComponentLabels } from "../sets/resolve";
|
|
37
38
|
/** How many edges {@link ScopeApi.count} looks at when it is allowed to answer approximately. */
|
|
38
39
|
export declare const DEFAULT_SCOPE_SAMPLE = 10000;
|
|
39
|
-
|
|
40
|
-
* One snapshot's node identity space, for a mask over its nodes.
|
|
41
|
-
* @param snapshot - The snapshot to read.
|
|
42
|
-
* @returns The space, which is the snapshot's own id map.
|
|
43
|
-
*/
|
|
44
|
-
export declare function nodeSpaceOf(snapshot: GraphSnapshot): MaskIdSpace<NodeId>;
|
|
45
|
-
/**
|
|
46
|
-
* One snapshot's edge identity space, for a mask over its edges.
|
|
47
|
-
*
|
|
48
|
-
* It READS the element-assigned counter the store stamped into every edge's `graphty.edgeId`
|
|
49
|
-
* column rather than minting an id out of the endpoints, and that is the whole difference. A
|
|
50
|
-
* minted pair string could not name two edges between one pair -- so under parallel edges only the
|
|
51
|
-
* last of a repeated pair was addressable at all -- and it collided for any node id containing a
|
|
52
|
-
* colon.
|
|
53
|
-
*
|
|
54
|
-
* The reverse lookup is `snapshot.edgeIndexOf`, a lazily built index graph-format already owns
|
|
55
|
-
* over the same column, so there is no hand-built map here to fall out of step with it.
|
|
56
|
-
* @param snapshot - The snapshot to read.
|
|
57
|
-
* @returns The space.
|
|
58
|
-
*/
|
|
59
|
-
export declare function edgeSpaceOf(snapshot: GraphSnapshot): MaskIdSpace<EdgeId>;
|
|
40
|
+
export { edgeSpaceOf, nodeSpaceOf };
|
|
60
41
|
/** The visible data scope: what filters and the time window have left showing. */
|
|
61
42
|
export interface ScopeVisibilitySource {
|
|
62
43
|
/**
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file A snapshot's node and edge identity spaces, for masks over its rows. Kept apart from the
|
|
3
|
+
* scope resolver so a reader of ids (the simple tier's graph view, the style selector source) does
|
|
4
|
+
* not load the resolver and, through its sets, the session's dispatcher.
|
|
5
|
+
*/
|
|
6
|
+
import { type GraphSnapshot } from "@graphty/graph-format";
|
|
7
|
+
import type { EdgeId, NodeId } from "../../catalog/types";
|
|
8
|
+
import type { MaskIdSpace } from "./ElementMask";
|
|
9
|
+
/**
|
|
10
|
+
* One snapshot's node identity space, for a mask over its nodes.
|
|
11
|
+
* @param snapshot - The snapshot to read.
|
|
12
|
+
* @returns The space, which is the snapshot's own id map.
|
|
13
|
+
*/
|
|
14
|
+
export declare function nodeSpaceOf(snapshot: GraphSnapshot): MaskIdSpace<NodeId>;
|
|
15
|
+
/**
|
|
16
|
+
* One snapshot's edge identity space, for a mask over its edges.
|
|
17
|
+
*
|
|
18
|
+
* It READS the element-assigned counter the store stamped into every edge's `graphty.edgeId`
|
|
19
|
+
* column rather than minting an id out of the endpoints, and that is the whole difference. A
|
|
20
|
+
* minted pair string could not name two edges between one pair -- so under parallel edges only the
|
|
21
|
+
* last of a repeated pair was addressable at all -- and it collided for any node id containing a
|
|
22
|
+
* colon.
|
|
23
|
+
*
|
|
24
|
+
* The reverse lookup is `snapshot.edgeIndexOf`, a lazily built index graph-format already owns
|
|
25
|
+
* over the same column, so there is no hand-built map here to fall out of step with it.
|
|
26
|
+
* @param snapshot - The snapshot to read.
|
|
27
|
+
* @returns The space.
|
|
28
|
+
*/
|
|
29
|
+
export declare function edgeSpaceOf(snapshot: GraphSnapshot): MaskIdSpace<EdgeId>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file A set a consumer cannot write to, for every set the session hands out.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* A set that cannot be written to.
|
|
6
|
+
*
|
|
7
|
+
* `Object.freeze` alone does NOT stop `Set.prototype.add`: a frozen set that silently accepts an
|
|
8
|
+
* `add()` would hand a consumer a mutation the session never saw -- project state changed with no
|
|
9
|
+
* step, or a cached answer changed for every later reader. So the three mutators are replaced on
|
|
10
|
+
* the instance before it is frozen, and a caller that reaches for one is told rather than ignored.
|
|
11
|
+
* @param values - What to put in it.
|
|
12
|
+
* @param hint - What to call instead, said in the error.
|
|
13
|
+
* @returns The sealed set.
|
|
14
|
+
*/
|
|
15
|
+
export declare function sealedSet<T>(values: Iterable<T>, hint: string): ReadonlySet<T>;
|
|
16
|
+
/**
|
|
17
|
+
* A read-only view of a map: every read, and no writer, not even through a cast. For a map the
|
|
18
|
+
* element keeps and hands out, where a writer would change what it holds behind every step.
|
|
19
|
+
* @param map - The map, which its owner goes on writing.
|
|
20
|
+
* @returns The view.
|
|
21
|
+
*/
|
|
22
|
+
export declare function readonlyMapView<K, V>(map: ReadonlyMap<K, V>): ReadonlyMap<K, V>;
|
|
@@ -47,11 +47,12 @@ export declare const SET_OPS: readonly SelectionOp[];
|
|
|
47
47
|
/**
|
|
48
48
|
* Who asked for a selection change.
|
|
49
49
|
*
|
|
50
|
-
* A consumer reacts differently to
|
|
51
|
-
*
|
|
52
|
-
*
|
|
50
|
+
* A consumer reacts differently to each: a change a person made with the mouse should move the
|
|
51
|
+
* camera and open the inspector, and the identical change made by a script replaying a saved
|
|
52
|
+
* document should do neither. `history` is an undo, a redo or a restore selecting the elements
|
|
53
|
+
* it changed.
|
|
53
54
|
*/
|
|
54
|
-
export type SelectionCause = "user" | "api" | "command";
|
|
55
|
+
export type SelectionCause = "user" | "api" | "command" | "history";
|
|
55
56
|
/** What one mutation changed. */
|
|
56
57
|
export interface SelectionDelta {
|
|
57
58
|
/**
|
|
@@ -224,6 +225,15 @@ export interface SelectionOwner extends SelectionApi {
|
|
|
224
225
|
* @returns What changed.
|
|
225
226
|
*/
|
|
226
227
|
applyNow(target: SelectionTarget, op?: SelectionOp, cause?: SelectionCause): SelectionDelta;
|
|
228
|
+
/**
|
|
229
|
+
* Change the selection at the next read instead of now, so a change made while the graph has
|
|
230
|
+
* edits not yet frozen does not freeze it: how an undo selects what it changed without paying
|
|
231
|
+
* for a rebuild nobody asked for. A later call replaces one still waiting.
|
|
232
|
+
* @param target - What to select.
|
|
233
|
+
* @param op - What to do with it.
|
|
234
|
+
* @param cause - Who asked.
|
|
235
|
+
*/
|
|
236
|
+
applyAtNextRead(target: SelectionTarget, op: SelectionOp, cause: SelectionCause): void;
|
|
227
237
|
/**
|
|
228
238
|
* The node mask itself, for the scope resolver's `selection` source.
|
|
229
239
|
* @returns The live mask, which the caller must not mutate.
|
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
* @file The synchronous doors of `session.sets`: the reads that only look at records and the
|
|
3
3
|
* writes that resolve nothing (design/sets/sets-design.md sections 13.2, 13.3, 15.2).
|
|
4
4
|
*
|
|
5
|
-
* Each write door
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Each write door dispatches one `set.*` command through the session's dispatcher, so every write
|
|
6
|
+
* is one undoable step (design/sets/undo-integration.md section 2). A create's door mints the id
|
|
7
|
+
* and the order first, and says what the set was created from. The command's body, which this
|
|
8
|
+
* module hands the dispatcher as its set service, does the one thing a pure `prepare` cannot -- it
|
|
9
|
+
* reaches the graph to turn a session edge id into the edge's stable identity -- then prepares the
|
|
10
|
+
* operation and refuses a rule the doors cannot keep. A no-op writes nothing and records nothing.
|
|
9
11
|
*
|
|
10
12
|
* Built by the session and published on it as `session.sets`.
|
|
11
13
|
*/
|
|
12
14
|
import { type GraphSnapshot } from "@graphty/graph-format";
|
|
13
15
|
import type { EdgeId, EdgeMember, RuleTree, RunId, Scope, SetCreatedFrom, SetDefinitionInput, SetId } from "../../catalog/types";
|
|
16
|
+
import type { Dispatcher } from "../project/Dispatcher";
|
|
14
17
|
import type { SessionAttributes } from "../types";
|
|
15
18
|
import { type Materialiser } from "./algebra";
|
|
16
19
|
import { type DependencySources } from "./dependencies";
|
|
@@ -20,6 +23,11 @@ import { SetsStore } from "./store";
|
|
|
20
23
|
import type { SetsApi, SetUser } from "./types";
|
|
21
24
|
/** What the doors read from the rest of the session. */
|
|
22
25
|
interface SetsDependencies {
|
|
26
|
+
/**
|
|
27
|
+
* The dispatcher whose `sets` slice holds the records and whose history records every write.
|
|
28
|
+
* A session hands in its own; absent, the sets keep a dispatcher of their own.
|
|
29
|
+
*/
|
|
30
|
+
readonly dispatcher?: Dispatcher;
|
|
23
31
|
/**
|
|
24
32
|
* A session edge's stable identity.
|
|
25
33
|
* @param id - The session edge id.
|
|
@@ -103,7 +111,7 @@ export declare function setsStoreOf(api: SetsApi): SetsStore;
|
|
|
103
111
|
/**
|
|
104
112
|
* Build the synchronous doors over a store.
|
|
105
113
|
* @param dependencies - Where session edge ids are looked up.
|
|
106
|
-
* @param store - The
|
|
114
|
+
* @param store - The kept sets; over the dispatcher handed in, or one of their own, when absent.
|
|
107
115
|
* @returns The doors.
|
|
108
116
|
*/
|
|
109
117
|
export declare function createSetsApi(dependencies: SetsDependencies, store?: SetsStore): SetsApi;
|