@graphty/graphty-element 2.5.2 → 2.6.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.d.ts +16 -0
- package/dist/catalog.js +34 -32
- package/dist/chunks/{AiManager-CrbvKdEK.js → AiManager-4iQpsJW1.js} +4 -4
- package/dist/chunks/{DataSource-qU-nLhXN.js → DataSource-BL2UzPff.js} +2 -2
- package/dist/chunks/GraphSession-BhuHSXIo.js +12819 -0
- package/dist/chunks/{GraphtyLogger-DOTwCiMR.js → GraphtyLogger-B_O67a6c.js} +1 -1
- package/dist/chunks/{VoiceInputAdapter-D4NrRL_1.js → VoiceInputAdapter-Cc6mHXTI.js} +1 -1
- package/dist/chunks/{XRPivotCameraController-Uqa47vmo.js → XRPivotCameraController-BLa89LXn.js} +2 -2
- package/dist/chunks/{algorithms-D-ab-Auu.js → algorithms-BJ6DQMOe.js} +931 -781
- package/dist/chunks/{capability-check-Vw3IcqiE.js → capability-check-Am2zliFj.js} +1 -1
- package/dist/chunks/{detect-B4Qrw976.js → detect-fyuVnlCT.js} +1 -1
- package/dist/chunks/{format-detection-r2IfNFXO.js → format-detection-BHwrAVzW.js} +1 -1
- package/dist/chunks/{index-J9MgLio9.js → index-BkBLbvui.js} +2691 -2434
- package/dist/chunks/optionsFromZod-CKMYSwTz.js +3636 -0
- package/dist/chunks/{paletteRegistry-Kt-6CeoN.js → paletteRegistry-BCFSwJGK.js} +224 -189
- package/dist/chunks/parse-BMTqt4SS.js +3658 -0
- package/dist/chunks/{types-C_c53VgR.js → types-DFchv4Ny.js} +4 -1
- package/dist/custom-elements.json +1 -1
- package/dist/extend.d.ts +10 -8
- package/dist/extend.js +6 -6
- package/dist/graphty-catalog.json +75 -38
- package/dist/graphty.bundle.js +55368 -48970
- package/dist/graphty.js +19 -19
- package/dist/index.d.ts +1 -1
- package/dist/logging.js +2 -2
- package/dist/schema.d.ts +15 -1
- package/dist/schema.js +1 -1
- package/dist/session.d.ts +30 -7
- package/dist/session.js +40 -37
- package/dist/src/Graph.d.ts +35 -7
- package/dist/src/acceleration/types.d.ts +79 -43
- package/dist/src/algorithms/Algorithm.d.ts +52 -4
- package/dist/src/algorithms/BFSAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/BellmanFordAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/BetweennessCentralityAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/BipartiteMatchingAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/ClosenessCentralityAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/ConnectedComponentsAlgorithm.d.ts +4 -1
- package/dist/src/algorithms/DFSAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/DegreeAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/DijkstraAlgorithm.d.ts +6 -0
- package/dist/src/algorithms/EigenvectorCentralityAlgorithm.d.ts +2 -0
- package/dist/src/algorithms/FloydWarshallAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/GirvanNewmanAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/HITSAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/KCoreAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/KatzCentralityAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/KruskalAlgorithm.d.ts +4 -1
- package/dist/src/algorithms/LabelPropagationAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/LeidenAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/LinkPredictionAlgorithm.d.ts +4 -1
- package/dist/src/algorithms/LouvainAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/MaxFlowAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/MinCutAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/PageRankAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/PrimAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/StronglyConnectedComponentsAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/input/ScopedInput.d.ts +185 -0
- package/dist/src/algorithms/input/derivedInputs.d.ts +199 -0
- package/dist/src/algorithms/input/maskBack.d.ts +37 -0
- package/dist/src/algorithms/metrics/MetricAlgorithm.d.ts +3 -3
- package/dist/src/algorithms/results/DeclaredAlgorithm.d.ts +4 -3
- package/dist/src/algorithms/results/types.d.ts +28 -6
- package/dist/src/algorithms/utils/communityUtils.d.ts +0 -48
- package/dist/src/algorithms/utils/graphUtils.d.ts +2 -68
- package/dist/src/algorithms/utils/snapshotGraph.d.ts +3 -1
- package/dist/src/catalog/algorithms.d.ts +3 -0
- package/dist/src/catalog/layouts.d.ts +2 -0
- package/dist/src/catalog/sets/canonical.d.ts +68 -0
- package/dist/src/catalog/sets/hash.d.ts +126 -0
- package/dist/src/catalog/sets/parse.d.ts +115 -0
- package/dist/src/catalog/types.d.ts +329 -8
- package/dist/src/data/GraphStore.d.ts +73 -1
- package/dist/src/data/edgeIdentity.d.ts +202 -1
- package/dist/src/data/ingest.d.ts +3 -1
- package/dist/src/data/report.d.ts +20 -0
- package/dist/src/graphty-element.d.ts +42 -6
- package/dist/src/layout/D3GraphLayoutEngine.d.ts +11 -0
- package/dist/src/layout/LayoutEngine.d.ts +56 -0
- package/dist/src/layout/NGraphLayoutEngine.d.ts +10 -0
- package/dist/src/layout/SimulationLayoutEngine.d.ts +11 -0
- package/dist/src/managers/AlgorithmManager.d.ts +8 -0
- package/dist/src/managers/DataManager.d.ts +11 -0
- package/dist/src/managers/LayoutManager.d.ts +126 -2
- package/dist/src/managers/StatsManager.d.ts +1 -0
- package/dist/src/session/GraphSession.d.ts +48 -0
- package/dist/src/session/attributes.d.ts +121 -1
- package/dist/src/session/cost/estimate.d.ts +20 -0
- package/dist/src/session/cost/index.d.ts +1 -1
- package/dist/src/session/planning.d.ts +32 -2
- package/dist/src/session/query.d.ts +7 -0
- package/dist/src/session/results/ResultsApi.d.ts +14 -1
- package/dist/src/session/runs/Run.d.ts +65 -4
- package/dist/src/session/runs/RunsApi.d.ts +58 -2
- package/dist/src/session/runs/runId.d.ts +55 -6
- package/dist/src/session/runs/types.d.ts +36 -8
- package/dist/src/session/scope/ElementMask.d.ts +14 -1
- package/dist/src/session/scope/ScopeApi.d.ts +160 -31
- package/dist/src/session/scope/index.d.ts +1 -1
- package/dist/src/session/selection/SelectionApi.d.ts +15 -10
- package/dist/src/session/selection/index.d.ts +1 -1
- package/dist/src/session/selection/targets.d.ts +6 -7
- package/dist/src/session/sets/SetsApi.d.ts +110 -0
- package/dist/src/session/sets/algebra.d.ts +124 -0
- package/dist/src/session/sets/cache.d.ts +197 -0
- package/dist/src/session/sets/captures.d.ts +83 -0
- package/dist/src/session/sets/dependencies.d.ts +167 -0
- package/dist/src/session/sets/layers.d.ts +101 -0
- package/dist/src/session/sets/notify.d.ts +122 -0
- package/dist/src/session/sets/offers.d.ts +103 -0
- package/dist/src/session/sets/path.d.ts +37 -0
- package/dist/src/session/sets/prepare.d.ts +209 -0
- package/dist/src/session/sets/resolve.d.ts +311 -0
- package/dist/src/session/sets/signature.d.ts +77 -0
- package/dist/src/session/sets/status.d.ts +98 -0
- package/dist/src/session/sets/store.d.ts +196 -0
- package/dist/src/session/sets/types.d.ts +386 -0
- package/dist/src/session/styles/Layer.d.ts +9 -2
- package/dist/src/session/styles/StylesApi.d.ts +5 -2
- package/dist/src/session/styles/explain.d.ts +5 -2
- package/dist/src/session/styles/predicate.d.ts +41 -2
- package/dist/src/session/styles/repaint.d.ts +19 -0
- package/dist/src/session/styles/selector.d.ts +16 -5
- package/dist/src/session/types.d.ts +18 -0
- package/dist/src/session/visibility/VisibilityApi.d.ts +47 -3
- package/dist/src/session/visibility/filter.d.ts +86 -51
- package/dist/src/session/visibility/index.d.ts +1 -1
- package/dist/src/testing/fakeAccelerator.d.ts +5 -0
- package/dist/src/utils/queue-migration.d.ts +17 -0
- package/package.json +15 -9
- package/dist/chunks/GraphSession-DuAhRgCd.js +0 -8622
- package/dist/chunks/optionsFromZod-B9RncoTX.js +0 -2578
- package/dist/chunks/scales-CJCRwi2J.js +0 -3220
- package/dist/src/algorithms/utils/index.d.ts +0 -6
|
@@ -18,10 +18,12 @@
|
|
|
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 } from "../../catalog/types";
|
|
21
|
+
import { type AlgorithmDescriptor, type LayerId, type RunId, type Scope, type ScopeInput, type SetId } from "../../catalog/types";
|
|
22
|
+
import type { HeldCaptures } from "../sets/captures";
|
|
22
23
|
import type { AutoApplyPolicy } from "../styles/autoApply";
|
|
23
24
|
import { type RunExecutor, type RunQueueContext } from "./Run";
|
|
24
|
-
import { type
|
|
25
|
+
import { type LiveKeyword } from "./runId";
|
|
26
|
+
import { type Caveats, type EngineVersions, type ResolvedScope, type RunChange, type RunsApi, type RunScopeFacts } from "./types";
|
|
25
27
|
/**
|
|
26
28
|
* The element's operation queue, as a run needs it.
|
|
27
29
|
*
|
|
@@ -104,12 +106,40 @@ export interface RunsApiOptions {
|
|
|
104
106
|
* @returns What it resolves to now.
|
|
105
107
|
*/
|
|
106
108
|
readonly resolveScope: (spec: Scope) => ResolvedScope;
|
|
109
|
+
/**
|
|
110
|
+
* What a run records about the set a scope names: its revision and its edge reading. Absent
|
|
111
|
+
* records neither.
|
|
112
|
+
* @param spec - The scope.
|
|
113
|
+
* @returns The facts.
|
|
114
|
+
*/
|
|
115
|
+
readonly scopeFacts?: (spec: Scope) => RunScopeFacts;
|
|
116
|
+
/**
|
|
117
|
+
* The name of a kept set, for a run label.
|
|
118
|
+
* @param id - The set.
|
|
119
|
+
* @returns The name, or undefined when no set has the id.
|
|
120
|
+
*/
|
|
121
|
+
readonly setName?: (id: SetId) => string | undefined;
|
|
107
122
|
/** The thing that actually runs an algorithm. */
|
|
108
123
|
readonly execute: RunExecutor;
|
|
109
124
|
/** Which versions are producing the numbers. */
|
|
110
125
|
readonly engine: EngineVersions;
|
|
111
126
|
/** What a call that names no scope gets. Defaults to the visible graph. */
|
|
112
127
|
readonly defaultScope?: Scope;
|
|
128
|
+
/**
|
|
129
|
+
* A write door's check of the scope a call names: session edge ids to stable members, set ids
|
|
130
|
+
* checked as issued. Absent, the scope is taken as given.
|
|
131
|
+
* @param spec - The scope as given.
|
|
132
|
+
* @returns The scope to record.
|
|
133
|
+
*/
|
|
134
|
+
readonly admitScope?: (spec: ScopeInput) => Scope;
|
|
135
|
+
/**
|
|
136
|
+
* The definition a live scope keyword stands for now, which a derived run id hashes in its
|
|
137
|
+
* place: the visibility filter and window for `"visible"`, the selected nodes for
|
|
138
|
+
* `"selection"`. Absent, the keyword itself is hashed.
|
|
139
|
+
* @param keyword - The keyword.
|
|
140
|
+
* @returns Plain data that changes exactly when the keyword's definition does.
|
|
141
|
+
*/
|
|
142
|
+
readonly liveScope?: (keyword: LiveKeyword) => unknown;
|
|
113
143
|
/** The caveats a run starts from, before the work refines them. */
|
|
114
144
|
readonly defaultCaveats?: Caveats;
|
|
115
145
|
/** The style layers that read runs, once there are any. */
|
|
@@ -133,6 +163,18 @@ export interface RunsApiOptions {
|
|
|
133
163
|
* @param change - The run's record, and which moment it reached.
|
|
134
164
|
*/
|
|
135
165
|
readonly onChange?: (change: RunChange) => void;
|
|
166
|
+
/** Called once per execution token minted, which is what advances the session input tick. */
|
|
167
|
+
readonly onExecution?: () => void;
|
|
168
|
+
/** Called when a run is removed, and with it its result (design/sets 11). */
|
|
169
|
+
readonly onRemoved?: (id: RunId) => void;
|
|
170
|
+
/**
|
|
171
|
+
* Capture what live references hold of a run's result before a re-run replaces it
|
|
172
|
+
* (design/sets 5.2). Absent: nothing is captured.
|
|
173
|
+
* @param run - The run about to re-execute in place, its result still in place.
|
|
174
|
+
* @param prior - The captures it keeps now.
|
|
175
|
+
* @returns The captures it keeps from now on.
|
|
176
|
+
*/
|
|
177
|
+
readonly captureHeld?: (run: RunId, prior: HeldCaptures) => HeldCaptures;
|
|
136
178
|
}
|
|
137
179
|
/** The runs API, plus the two things a session needs and a consumer never calls. */
|
|
138
180
|
export interface SessionRunsApi extends RunsApi {
|
|
@@ -147,9 +189,23 @@ export interface SessionRunsApi extends RunsApi {
|
|
|
147
189
|
* @returns True when the element derived the id.
|
|
148
190
|
*/
|
|
149
191
|
isDerivedId(id: RunId): boolean;
|
|
192
|
+
/**
|
|
193
|
+
* What a run keeps of earlier executions' items that live references hold (design/sets 5.2).
|
|
194
|
+
* @param id - The run id.
|
|
195
|
+
* @returns The captures; empty for a run this session does not hold.
|
|
196
|
+
*/
|
|
197
|
+
heldOf(id: RunId): HeldCaptures;
|
|
150
198
|
/** Cancel everything still running and forget every run this session held. */
|
|
151
199
|
dispose(): void;
|
|
152
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* Build one session's execution-token minter: a nonce drawn once, then a counter shared by every
|
|
203
|
+
* run the session holds, never a per-run count. `startedAt` was rejected as an identity because
|
|
204
|
+
* two executions in one millisecond compare equal.
|
|
205
|
+
* @param onMint - called after every mint
|
|
206
|
+
* @returns the minter; each call returns `<nonce>.<counter>`, opaque to every reader
|
|
207
|
+
*/
|
|
208
|
+
export declare function createExecutionMinter(onMint?: () => void): () => string;
|
|
153
209
|
/**
|
|
154
210
|
* Build the runs API over an existing operation queue.
|
|
155
211
|
* @param options - The queue, the catalogue, the scope resolver and the thing that does the work.
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file Run identity: what makes two calls the same run, and what makes them different ones.
|
|
3
3
|
*
|
|
4
|
-
* A run id is not a slot number. It is either author-assigned through `as:` or derived from
|
|
5
|
-
* the run
|
|
6
|
-
*
|
|
7
|
-
* template resolves to a different run depending on the order things
|
|
8
|
-
* changing that afterwards is a behavioural break in everything already
|
|
4
|
+
* A run id is not a slot number. It is either author-assigned through `as:` or derived from the
|
|
5
|
+
* RESULT the run answers -- the algorithm key, whether it is exact or sampled, and the scope it
|
|
6
|
+
* reads with the live keywords frozen. An id minted from an execution counter would mean a saved
|
|
7
|
+
* style layer, recipe or template resolves to a different run depending on the order things
|
|
8
|
+
* happened to execute, and changing that afterwards is a behavioural break in everything already
|
|
9
|
+
* persisted.
|
|
10
|
+
*
|
|
11
|
+
* The derived id is the RESULT's id ({@link ResultId}): parameters and the seed are not part of
|
|
12
|
+
* it, so tuning a resolution or a damping factor re-runs the same result and every layer bound to
|
|
13
|
+
* it repaints, instead of growing a second result and a second layer. The keywords `"visible"` and
|
|
14
|
+
* `"selection"` are replaced by the definition in force before hashing -- the visibility filter
|
|
15
|
+
* and time window, the selected nodes -- so the same unscoped call under a different filter is a
|
|
16
|
+
* different result, never a re-execution of the first one over a different graph.
|
|
9
17
|
*
|
|
10
18
|
* Two rules do the work here:
|
|
11
19
|
*
|
|
@@ -19,7 +27,7 @@
|
|
|
19
27
|
*
|
|
20
28
|
* Nothing here reaches Babylon.js, Lit or the DOM: it is string arithmetic over plain data.
|
|
21
29
|
*/
|
|
22
|
-
import type { AlgorithmKey, EdgeId, NodeId, OptionDescriptor, RunId, Scope } from "../../catalog/types";
|
|
30
|
+
import type { AlgorithmKey, EdgeId, NodeId, OptionDescriptor, ResultId, RunId, Scope } from "../../catalog/types";
|
|
23
31
|
/**
|
|
24
32
|
* A short, stable digest of a string, made of characters a run id may carry.
|
|
25
33
|
*
|
|
@@ -103,6 +111,47 @@ export declare function canonicalIdentity(identity: RunIdentity): string;
|
|
|
103
111
|
* @returns The id, which always matches the run-id pattern.
|
|
104
112
|
*/
|
|
105
113
|
export declare function deriveRunId(identity: RunIdentity): RunId;
|
|
114
|
+
/** The live scope keywords, whose members change without the scope's spelling changing. */
|
|
115
|
+
export type LiveKeyword = "visible" | "selection";
|
|
116
|
+
/**
|
|
117
|
+
* A scope with every live keyword replaced by the definition in force, for hashing only: the
|
|
118
|
+
* scope itself, and the `of` of every `member` leaf inside an inline definition.
|
|
119
|
+
* @param scope - The scope a run was asked for.
|
|
120
|
+
* @param live - The definition each live keyword stands for now.
|
|
121
|
+
* @returns The frozen scope, plain data.
|
|
122
|
+
*/
|
|
123
|
+
export declare function freezeScope(scope: Scope, live: (keyword: LiveKeyword) => unknown): unknown;
|
|
124
|
+
/**
|
|
125
|
+
* The selected nodes as a frozen scope names them: sorted, so the same selection made in another
|
|
126
|
+
* order is the same result.
|
|
127
|
+
* @param nodes - The selected node ids.
|
|
128
|
+
* @returns The ids, sorted.
|
|
129
|
+
*/
|
|
130
|
+
export declare function frozenSelection(nodes: Iterable<NodeId>): NodeId[];
|
|
131
|
+
/** What names a result: everything that makes two calls one result, and nothing a re-run may tune. */
|
|
132
|
+
export interface ResultIdentity {
|
|
133
|
+
/** Which algorithm ran. */
|
|
134
|
+
readonly algorithm: AlgorithmKey;
|
|
135
|
+
/** The scope, frozen by {@link freezeScope}. */
|
|
136
|
+
readonly scope: unknown;
|
|
137
|
+
/** The sample size that was asked for, or null: a sampled result is never an exact one. */
|
|
138
|
+
readonly sample: number | null;
|
|
139
|
+
/** Whether approximation was refused, or null when the caller did not say. */
|
|
140
|
+
readonly exact: boolean | null;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The id a result gets when its author did not name it: derived from what the result IS, never
|
|
144
|
+
* from its parameters, its seed or when it ran.
|
|
145
|
+
* @param identity - What the result is.
|
|
146
|
+
* @returns The id, which always matches the run-id pattern.
|
|
147
|
+
*/
|
|
148
|
+
export declare function deriveResultId(identity: ResultIdentity): ResultId;
|
|
149
|
+
/**
|
|
150
|
+
* The canonical text of a result identity, which is what two runs under one id are compared by.
|
|
151
|
+
* @param identity - The identity.
|
|
152
|
+
* @returns Its canonical text.
|
|
153
|
+
*/
|
|
154
|
+
export declare function canonicalResultIdentity(identity: ResultIdentity): string;
|
|
106
155
|
/**
|
|
107
156
|
* Check an author-assigned id against the pattern every run id keeps.
|
|
108
157
|
*
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* lands, rather than being stubbed with a placeholder type: `command`, the journalled command a
|
|
16
16
|
* run was started from, which arrives with the command union.
|
|
17
17
|
*/
|
|
18
|
-
import type { AlgorithmKey, EdgeId, FieldDescriptor, LayerId, NodeId, ResultShape, RunId, Scope } from "../../catalog/types";
|
|
18
|
+
import type { AlgorithmKey, EdgeId, EdgeReading, FieldDescriptor, LayerId, NodeId, ResultShape, RunId, Scope, ScopeInput, SetId } from "../../catalog/types";
|
|
19
19
|
import type { GraphtyError } from "../../errors/GraphtyError";
|
|
20
20
|
import type { ResultSummary, RunResult } from "../results/types";
|
|
21
21
|
import type { StyleSuggestion } from "../styles/derive";
|
|
@@ -190,15 +190,19 @@ export interface Caveats {
|
|
|
190
190
|
* meantime.
|
|
191
191
|
*/
|
|
192
192
|
export interface ResolvedScope {
|
|
193
|
-
/** The nodes in scope. */
|
|
193
|
+
/** The nodes in scope. Lazy: built on the first read, then the same set on every read. */
|
|
194
194
|
readonly nodes: ReadonlySet<NodeId>;
|
|
195
|
-
/** The edges in scope. */
|
|
195
|
+
/** The edges in scope. Lazy: built on the first read, then the same set on every read. */
|
|
196
196
|
readonly edges: ReadonlySet<EdgeId>;
|
|
197
197
|
/** How many nodes are in scope. */
|
|
198
198
|
readonly nodeCount: number;
|
|
199
199
|
/** How many edges are in scope. */
|
|
200
200
|
readonly edgeCount: number;
|
|
201
|
-
/**
|
|
201
|
+
/**
|
|
202
|
+
* Equal digests mean equal scopes, which is how staleness is derived rather than tracked.
|
|
203
|
+
* Versioned: `d1:` and 16 hex digits, comparable only within one session and store. Computed
|
|
204
|
+
* on first read.
|
|
205
|
+
*/
|
|
202
206
|
readonly digest: string;
|
|
203
207
|
/** What was asked for, before it was resolved. */
|
|
204
208
|
readonly spec: Scope;
|
|
@@ -215,7 +219,21 @@ export interface RunScopeRecord {
|
|
|
215
219
|
readonly edges: number;
|
|
216
220
|
/** The digest the staleness comparison reads. */
|
|
217
221
|
readonly digest: string;
|
|
222
|
+
/**
|
|
223
|
+
* The kept set a `{ set }` scope named, and its revision when the run resolved it, so a reader
|
|
224
|
+
* can tell whether the set has been redefined since. Absent for every other scope.
|
|
225
|
+
*/
|
|
226
|
+
readonly set?: {
|
|
227
|
+
/** The kept set's id. */
|
|
228
|
+
readonly id: SetId;
|
|
229
|
+
/** The set's revision when the run resolved it. */
|
|
230
|
+
readonly revision: string;
|
|
231
|
+
};
|
|
232
|
+
/** Which edges came with the scope's nodes. OPEN UNION, as {@link EdgeReading}. */
|
|
233
|
+
readonly reading?: EdgeReading;
|
|
218
234
|
}
|
|
235
|
+
/** What a run records about the set its scope named, beside the resolution. */
|
|
236
|
+
export type RunScopeFacts = Pick<RunScopeRecord, "set" | "reading">;
|
|
219
237
|
/** Which versions of which packages produced a result. */
|
|
220
238
|
export interface EngineVersions {
|
|
221
239
|
/** The graphty-element version. */
|
|
@@ -271,8 +289,11 @@ export interface RunOptions {
|
|
|
271
289
|
* saved document that referenced one would resolve differently against a different session.
|
|
272
290
|
*/
|
|
273
291
|
export interface StartOptions extends RunOptions {
|
|
274
|
-
/**
|
|
275
|
-
|
|
292
|
+
/**
|
|
293
|
+
* What the run may look at. Defaults to the visible graph. An inline `{ define }` may name
|
|
294
|
+
* edges by session edge id; the run records their stable form.
|
|
295
|
+
*/
|
|
296
|
+
readonly scope?: ScopeInput;
|
|
276
297
|
/** The seed for a randomised or sampled method, so a run can be reproduced. */
|
|
277
298
|
readonly seed?: number;
|
|
278
299
|
/**
|
|
@@ -319,8 +340,8 @@ export interface RunSpec {
|
|
|
319
340
|
readonly algorithm: AlgorithmKey;
|
|
320
341
|
/** Its parameters. */
|
|
321
342
|
readonly params?: Readonly<Record<string, unknown>>;
|
|
322
|
-
/** What it may look at. */
|
|
323
|
-
readonly scope?:
|
|
343
|
+
/** What it may look at, as {@link StartOptions.scope}. */
|
|
344
|
+
readonly scope?: ScopeInput;
|
|
324
345
|
/** The seed for a randomised or sampled method. */
|
|
325
346
|
readonly seed?: number;
|
|
326
347
|
/** The id to give the run. */
|
|
@@ -546,10 +567,17 @@ export interface RunRemoval {
|
|
|
546
567
|
export interface RunsApi {
|
|
547
568
|
/**
|
|
548
569
|
* Start one algorithm.
|
|
570
|
+
*
|
|
571
|
+
* The scope is resolved when the call is made, and again when the work starts: a set it names
|
|
572
|
+
* that is redefined while the run waits in the queue is run over as redefined, and the run
|
|
573
|
+
* records the revision it used (`record.scope.set.revision`).
|
|
549
574
|
* @param algorithm - Which algorithm to run.
|
|
550
575
|
* @param params - Its parameters.
|
|
551
576
|
* @param options - The scope, the seed, the id and the rest.
|
|
552
577
|
* @returns The run, which is awaitable and watchable straight away.
|
|
578
|
+
* @throws `E_SCOPE_EMPTY` when a scope other than `"graph"` or `"visible"` holds no nodes (a
|
|
579
|
+
* run that finds it empty only when its work starts fails with the same code);
|
|
580
|
+
* `E_BAD_COMMAND` for a malformed scope or a set id never issued.
|
|
553
581
|
*/
|
|
554
582
|
start(algorithm: AlgorithmKey, params?: Readonly<Record<string, unknown>>, options?: StartOptions): Run;
|
|
555
583
|
/**
|
|
@@ -77,6 +77,8 @@ export declare class ElementMask<TId> {
|
|
|
77
77
|
private members;
|
|
78
78
|
/** Bumped whenever a mutation actually changed the membership. */
|
|
79
79
|
private revision;
|
|
80
|
+
/** Told of every version bump. */
|
|
81
|
+
private readonly onVersion;
|
|
80
82
|
/** The last id array handed out, or null before the first materialisation. */
|
|
81
83
|
private cachedIds;
|
|
82
84
|
/** The revision `cachedIds` was materialised at. */
|
|
@@ -90,9 +92,13 @@ export declare class ElementMask<TId> {
|
|
|
90
92
|
* builds a fresh object per call costs a re-materialisation per read. It never costs
|
|
91
93
|
* correctness -- the contents are compared before a new array is handed out.
|
|
92
94
|
* @param capacity - Rows to reserve before the first growth; a non-negative integer.
|
|
95
|
+
* @param onVersion - Called on every version bump; a session mask passes its input tick's
|
|
96
|
+
* advance here, so the tick moves whenever the mask does (design/sets 6.2).
|
|
93
97
|
* @throws A `RangeError` when `capacity` is not a non-negative integer.
|
|
94
98
|
*/
|
|
95
|
-
constructor(readSpace: () => MaskIdSpace<TId>, capacity?: number);
|
|
99
|
+
constructor(readSpace: () => MaskIdSpace<TId>, capacity?: number, onVersion?: () => void);
|
|
100
|
+
/** Move the version on, and tell whoever asked to be told. */
|
|
101
|
+
private bump;
|
|
96
102
|
/**
|
|
97
103
|
* Rows the backing array can hold without reallocating.
|
|
98
104
|
* @returns The current capacity in rows.
|
|
@@ -229,6 +235,13 @@ export declare class ElementMask<TId> {
|
|
|
229
235
|
* @returns A fresh `Uint8Array` of length {@link ElementMask.count}.
|
|
230
236
|
*/
|
|
231
237
|
bytes(): U8;
|
|
238
|
+
/**
|
|
239
|
+
* The membership as a packed bitmap in graph-format's mask layout (ceil(length / 32) words,
|
|
240
|
+
* LSB-first): one pass of byte reads. A row at or past the live count is not a member.
|
|
241
|
+
* @param length - How many indices the bitmap covers, normally the snapshot's element count.
|
|
242
|
+
* @returns A fresh bitmap.
|
|
243
|
+
*/
|
|
244
|
+
pack(length: number): U32;
|
|
232
245
|
/**
|
|
233
246
|
* The ids in the set, materialised lazily and handed back frozen.
|
|
234
247
|
*
|
|
@@ -24,21 +24,18 @@
|
|
|
24
24
|
* Nothing here reaches Babylon.js, Lit or the DOM.
|
|
25
25
|
*/
|
|
26
26
|
import { type GraphSnapshot } from "@graphty/graph-format";
|
|
27
|
-
import type { EdgeId, NodeId, Query, Scope, ScopeId } from "../../catalog/types";
|
|
27
|
+
import type { EdgeId, EdgeMember, EdgeReading, NodeId, Path, Query, ResultItem, RunId, Scope, ScopeId, ScopeInput } from "../../catalog/types";
|
|
28
|
+
import type { AttributeRevisions, InputTick } from "../attributes";
|
|
28
29
|
import type { ResolvedScope } from "../runs/types";
|
|
29
|
-
import {
|
|
30
|
+
import { SetsCache } from "../sets/cache";
|
|
31
|
+
import { type Capture } from "../sets/captures";
|
|
32
|
+
import { type ComponentLabels, type Resolution, type ResolveContext } from "../sets/resolve";
|
|
33
|
+
import type { SetsApi } from "../sets/types";
|
|
34
|
+
import type { FilterSources, FilterValueSource, ScopeLeaf } from "../visibility/filter";
|
|
35
|
+
import type { ElementMask, MaskIdSpace } from "./ElementMask";
|
|
36
|
+
export type { ComponentLabels } from "../sets/resolve";
|
|
30
37
|
/** How many edges {@link ScopeApi.count} looks at when it is allowed to answer approximately. */
|
|
31
38
|
export declare const DEFAULT_SCOPE_SAMPLE = 10000;
|
|
32
|
-
/**
|
|
33
|
-
* The digest a resolved scope carries: equal digests mean the same elements.
|
|
34
|
-
*
|
|
35
|
-
* Two 32-bit lanes rather than one, because a single 32-bit digest starts colliding at a few
|
|
36
|
-
* tens of thousands of distinct scopes, and a collision here reports a stale run as fresh.
|
|
37
|
-
* @param nodes - The node ids in the scope, in any order.
|
|
38
|
-
* @param edges - The edge ids in the scope, in any order.
|
|
39
|
-
* @returns The digest: sixteen lower-case hexadecimal characters.
|
|
40
|
-
*/
|
|
41
|
-
export declare function membershipDigest(nodes: readonly NodeId[], edges: readonly EdgeId[]): string;
|
|
42
39
|
/**
|
|
43
40
|
* One snapshot's node identity space, for a mask over its nodes.
|
|
44
41
|
* @param snapshot - The snapshot to read.
|
|
@@ -83,13 +80,6 @@ export interface ScopeSelectionSource {
|
|
|
83
80
|
*/
|
|
84
81
|
nodes(): ElementMask<NodeId>;
|
|
85
82
|
}
|
|
86
|
-
/** Which connected component each node belongs to. */
|
|
87
|
-
export interface ComponentLabels {
|
|
88
|
-
/** One component number per dense node index. */
|
|
89
|
-
readonly labels: ArrayLike<number>;
|
|
90
|
-
/** How many components there are, so the labels are `[0, count)`. */
|
|
91
|
-
readonly count: number;
|
|
92
|
-
}
|
|
93
83
|
/**
|
|
94
84
|
* Where the resolver reads everything it does not compute itself.
|
|
95
85
|
*
|
|
@@ -104,6 +94,8 @@ export interface ScopeSources {
|
|
|
104
94
|
* @returns The current snapshot.
|
|
105
95
|
*/
|
|
106
96
|
snapshot(): GraphSnapshot;
|
|
97
|
+
/** The store instance every resolution is tagged with. Absent tags them with null. */
|
|
98
|
+
readonly store?: object;
|
|
107
99
|
/** What is visible. Absent means nothing hides anything, so `visible` is the whole graph. */
|
|
108
100
|
readonly visibility?: ScopeVisibilitySource;
|
|
109
101
|
/** What is selected. Absent refuses the `selection` scope. */
|
|
@@ -122,6 +114,57 @@ export interface ScopeSources {
|
|
|
122
114
|
* @returns The matching node ids; ones the graph no longer holds are ignored.
|
|
123
115
|
*/
|
|
124
116
|
readonly match?: (where: Query) => Iterable<NodeId>;
|
|
117
|
+
/**
|
|
118
|
+
* The paths a predicate's compiled expression reads. With {@link revisions} and
|
|
119
|
+
* {@link executionOf}, what lets a `{ where }` answer be cached: absent, it is resolved on
|
|
120
|
+
* every read.
|
|
121
|
+
* @param where - The predicate.
|
|
122
|
+
* @returns The paths.
|
|
123
|
+
*/
|
|
124
|
+
readonly pathsOf?: (where: Query) => readonly Path[];
|
|
125
|
+
/** The node attribute revisions a predicate's cached answer is keyed on. */
|
|
126
|
+
readonly revisions?: AttributeRevisions;
|
|
127
|
+
/** The edge attribute revisions a rule's `edges` leaf is keyed on. */
|
|
128
|
+
readonly edgeRevisions?: AttributeRevisions;
|
|
129
|
+
/**
|
|
130
|
+
* The execution token of a run's current result, which a predicate over its results is keyed
|
|
131
|
+
* on.
|
|
132
|
+
* @param run - The run.
|
|
133
|
+
* @returns The token, or undefined when the run has no result.
|
|
134
|
+
*/
|
|
135
|
+
readonly executionOf?: (run: RunId) => string | undefined;
|
|
136
|
+
/** The session input tick; saving or removing a scope advances it. */
|
|
137
|
+
readonly tick?: InputTick;
|
|
138
|
+
/** The resolution cache. A private one when absent. */
|
|
139
|
+
readonly cache?: SetsCache;
|
|
140
|
+
/** The kept sets `{ set }` and a rule's `member` leaf may name, beside the saved scopes. */
|
|
141
|
+
readonly sets?: SetsApi;
|
|
142
|
+
/** The edges a predicate matches. Absent refuses a rule's `edges` leaf. */
|
|
143
|
+
readonly matchEdges?: (where: Query) => Iterable<EdgeId>;
|
|
144
|
+
/** Attribute values. Absent refuses a rule's `range` and `categories` leaves. */
|
|
145
|
+
readonly values?: FilterValueSource;
|
|
146
|
+
/** A run's current result. Absent refuses a rule's `item` leaf and a `threshold` over `results.*`. */
|
|
147
|
+
readonly result?: FilterSources["result"];
|
|
148
|
+
/**
|
|
149
|
+
* What a held item's re-run captured (design/sets 5.2). Absent: nothing was captured.
|
|
150
|
+
* @param item - The item, with its execution.
|
|
151
|
+
* @returns The capture, or undefined.
|
|
152
|
+
*/
|
|
153
|
+
readonly captured?: (item: ResultItem) => Capture | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* A session edge's stable identity, so an inline `{ define }` may name edges by session id.
|
|
156
|
+
* Absent refuses a session edge id inside `{ define }`.
|
|
157
|
+
* @param id - The session edge id.
|
|
158
|
+
* @returns The member, or undefined when the graph holds no such edge.
|
|
159
|
+
*/
|
|
160
|
+
readonly edgeMember?: (id: EdgeId) => EdgeMember | undefined;
|
|
161
|
+
/**
|
|
162
|
+
* Which halves carry a value path, so an `induced` rule over an edge field resolves to nothing
|
|
163
|
+
* as its status says. Absent: such a leaf is not known to speak edges.
|
|
164
|
+
* @param path - The path.
|
|
165
|
+
* @returns `"node"`, `"edge"`, or both.
|
|
166
|
+
*/
|
|
167
|
+
readonly fieldKinds?: (path: Path) => readonly string[];
|
|
125
168
|
}
|
|
126
169
|
/** One scope somebody saved under a name. */
|
|
127
170
|
export interface SavedScope {
|
|
@@ -148,6 +191,10 @@ export interface ScopeCount {
|
|
|
148
191
|
readonly exact: boolean;
|
|
149
192
|
/** How many edges were looked at, when the answer was estimated from a sample. */
|
|
150
193
|
readonly sampled?: number;
|
|
194
|
+
/** For a kept fixed or path set: the node ids it names that the graph does not hold. */
|
|
195
|
+
readonly missingNodes?: number;
|
|
196
|
+
/** For a kept fixed or path set: the edge members (a path's steps) no edge of the graph matches. */
|
|
197
|
+
readonly missingEdges?: number;
|
|
151
198
|
}
|
|
152
199
|
/** What {@link ScopeApi.count} accepts. */
|
|
153
200
|
export interface ScopeCountOptions {
|
|
@@ -163,29 +210,36 @@ export interface ScopeApi {
|
|
|
163
210
|
* @param spec - What to resolve.
|
|
164
211
|
* @returns The resolved scope.
|
|
165
212
|
*/
|
|
166
|
-
resolve(spec:
|
|
213
|
+
resolve(spec: ScopeInput): Promise<ResolvedScope>;
|
|
167
214
|
/**
|
|
168
215
|
* How many elements a specification covers, without materialising them.
|
|
169
216
|
* @param spec - What to count.
|
|
170
217
|
* @param options - Whether an estimate is acceptable, and how big a sample to take.
|
|
171
218
|
* @returns The counts, saying whether the edge count was exact.
|
|
172
219
|
*/
|
|
173
|
-
count(spec:
|
|
220
|
+
count(spec: ScopeInput, options?: ScopeCountOptions): Promise<ScopeCount>;
|
|
174
221
|
/**
|
|
175
222
|
* Keep a specification under a name, so `{ set: id }` can name it later.
|
|
176
|
-
*
|
|
223
|
+
*
|
|
224
|
+
* It is kept as a set, created from `user`: `{ where }` as a rule, `{ nodes }` as a fixed
|
|
225
|
+
* set, `{ define }` as its definition, `"graph"`, `"largest-component"` and `{ set }` as a
|
|
226
|
+
* rule naming them. `"selection"` and `"visible"` are kept as their current members.
|
|
227
|
+
* @deprecated Use {@link SetsApi.create | session.sets.create}, which takes a definition.
|
|
228
|
+
* @param name - The name, unique among kept sets.
|
|
177
229
|
* @param spec - The specification to keep.
|
|
178
|
-
* @returns The minted id.
|
|
230
|
+
* @returns The minted id, never one issued before.
|
|
179
231
|
*/
|
|
180
232
|
save(name: string, spec: Scope): ScopeId;
|
|
181
233
|
/**
|
|
182
|
-
* Every
|
|
183
|
-
* @
|
|
234
|
+
* Every kept set, as the specification it holds and whether it still refers to anything.
|
|
235
|
+
* @deprecated Use {@link SetsApi.list | session.sets.list}, which returns the definitions.
|
|
236
|
+
* @returns The kept sets, in the order they were created.
|
|
184
237
|
*/
|
|
185
238
|
list(): readonly SavedScope[];
|
|
186
239
|
/**
|
|
187
|
-
*
|
|
188
|
-
* @
|
|
240
|
+
* Remove a kept set. Anything that named it becomes unbound rather than silently empty.
|
|
241
|
+
* @deprecated Use {@link SetsApi.remove | session.sets.remove}.
|
|
242
|
+
* @param id - The id to remove.
|
|
189
243
|
*/
|
|
190
244
|
remove(id: ScopeId): void;
|
|
191
245
|
}
|
|
@@ -197,20 +251,95 @@ export interface ScopeApi {
|
|
|
197
251
|
* the synchronous answer, and everything under here is synchronous anyway.
|
|
198
252
|
*/
|
|
199
253
|
export interface ScopeResolver extends ScopeApi {
|
|
254
|
+
/**
|
|
255
|
+
* A write position's scope in canonical form: session edge ids inside `{ define }` replaced by
|
|
256
|
+
* their stable members, the definition validated.
|
|
257
|
+
* @param spec - The scope as given.
|
|
258
|
+
* @returns The canonical scope.
|
|
259
|
+
* @throws `E_BAD_COMMAND` when it is not a scope.
|
|
260
|
+
*/
|
|
261
|
+
canonical(spec: ScopeInput): Scope;
|
|
262
|
+
/**
|
|
263
|
+
* What a write door stores, before it validates it: session edge ids inside any nested inline
|
|
264
|
+
* definition replaced by their stable members, and every `{ set }` it names checked as issued
|
|
265
|
+
* in this session (a removed set's id is accepted and reads as detached).
|
|
266
|
+
* @param value - A scope, a rule tree or a set definition, as given.
|
|
267
|
+
* @returns The value, stable; the same object when it held no session edge id.
|
|
268
|
+
* @throws `E_BAD_COMMAND` for a session edge id the graph lacks, or a set id never issued.
|
|
269
|
+
*/
|
|
270
|
+
admit<T>(value: T): T;
|
|
200
271
|
/**
|
|
201
272
|
* The elements a specification covers, answered without a promise.
|
|
202
273
|
* @param spec - What to resolve.
|
|
203
274
|
* @returns The resolved scope.
|
|
204
275
|
*/
|
|
205
276
|
resolveNow(spec: Scope): ResolvedScope;
|
|
277
|
+
/**
|
|
278
|
+
* The node ids a specification covers, read from its node bitmap: no id `Set` is built.
|
|
279
|
+
* @param spec - What to resolve.
|
|
280
|
+
* @returns The ids, in dense index order.
|
|
281
|
+
*/
|
|
282
|
+
nodeIdsOf(spec: Scope): readonly NodeId[];
|
|
283
|
+
/**
|
|
284
|
+
* What a rule's `member` leaf speaks, for a pass: never throws, and a reference that cannot be
|
|
285
|
+
* resolved (a cycle, a missing set) speaks nothing.
|
|
286
|
+
* @param spec - The referenced set.
|
|
287
|
+
* @returns The leaf.
|
|
288
|
+
*/
|
|
289
|
+
leafOf(spec: Scope): ScopeLeaf;
|
|
290
|
+
/**
|
|
291
|
+
* A specification's bitmaps, through the resolution cache, with the snapshot they cover.
|
|
292
|
+
* @param spec - What to resolve.
|
|
293
|
+
* @returns The resolution and its snapshot.
|
|
294
|
+
*/
|
|
295
|
+
resolutionOf(spec: Scope): {
|
|
296
|
+
readonly resolution: Resolution;
|
|
297
|
+
readonly graph: GraphSnapshot;
|
|
298
|
+
};
|
|
299
|
+
/**
|
|
300
|
+
* How a specification reads, following a `{ set }` to its definition.
|
|
301
|
+
* @param spec - The specification.
|
|
302
|
+
* @returns The reading.
|
|
303
|
+
*/
|
|
304
|
+
readingOf(spec: Scope): EdgeReading;
|
|
305
|
+
/** The kept sets `save`, `list` and `remove` delegate to. */
|
|
306
|
+
readonly sets: SetsApi;
|
|
307
|
+
/**
|
|
308
|
+
* What a resolution reads now, for an internal reader that resolves through the cache itself.
|
|
309
|
+
* @returns The context over the current snapshot.
|
|
310
|
+
*/
|
|
311
|
+
contextNow(): ResolveContext;
|
|
206
312
|
}
|
|
313
|
+
/** A resolution and the snapshot it covers. */
|
|
314
|
+
interface Membership {
|
|
315
|
+
readonly resolution: Resolution;
|
|
316
|
+
readonly graph: GraphSnapshot;
|
|
317
|
+
}
|
|
318
|
+
/** What stands behind a resolved scope: its bitmaps, and how to resolve the same spec again now. */
|
|
319
|
+
interface ScopeBehind extends Membership {
|
|
320
|
+
/** How the scope reads its edges. */
|
|
321
|
+
readonly reading: EdgeReading;
|
|
322
|
+
/**
|
|
323
|
+
* The same specification resolved against the graph as it stands now.
|
|
324
|
+
* @returns The resolution and its snapshot.
|
|
325
|
+
*/
|
|
326
|
+
now(): Membership;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* The bitmaps behind a resolved scope, and the snapshot they cover. Internal: a run hands its
|
|
330
|
+
* algorithm these rather than the id sets.
|
|
331
|
+
* @param scope - A resolved scope.
|
|
332
|
+
* @returns What stands behind it, or undefined for a scope no resolver dressed.
|
|
333
|
+
*/
|
|
334
|
+
export declare function resolutionBehind(scope: ResolvedScope): ScopeBehind | undefined;
|
|
207
335
|
/**
|
|
208
336
|
* Build the scope resolver one session uses.
|
|
209
337
|
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
338
|
+
* Each specification is resolved through the session's resolution cache
|
|
339
|
+
* (`session/sets/cache.ts`), keyed by its input signature: exactly the inputs it reads -- the
|
|
340
|
+
* snapshot, a mask version, a saved scope's record, the attribute revisions and run results a
|
|
341
|
+
* predicate reads. The reader that asks most often is the staleness check on a finished run, and
|
|
342
|
+
* the digest is memoised on the resolution, so a staleness read over unchanged inputs sums nothing.
|
|
214
343
|
* @param sources - Where to read the graph and the capabilities a narrowing scope needs.
|
|
215
344
|
* @returns The resolver.
|
|
216
345
|
*/
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
* Nothing in this module's import graph reaches Babylon.js, Lit or the DOM.
|
|
12
12
|
*/
|
|
13
13
|
export { DEFAULT_MASK_CAPACITY, ElementMask, type MaskIdSpace } from "./ElementMask";
|
|
14
|
-
export { type ComponentLabels, createScopeApi, DEFAULT_SCOPE_SAMPLE, edgeSpaceOf,
|
|
14
|
+
export { type ComponentLabels, createScopeApi, DEFAULT_SCOPE_SAMPLE, edgeSpaceOf, nodeSpaceOf, type SavedScope, type ScopeApi, type ScopeCount, type ScopeCountOptions, type ScopeResolver, type ScopeSelectionSource, type ScopeSources, type ScopeVisibilitySource, } from "./ScopeApi";
|
|
@@ -40,10 +40,10 @@ import { type SessionRecordSource } from "../types";
|
|
|
40
40
|
import { type SelectionMatch, type SelectionSearchHit, type SelectionTarget, type SelectionTextMode } from "./targets";
|
|
41
41
|
/** The most elements one selection holds before it is truncated, when nothing says otherwise. */
|
|
42
42
|
export declare const DEFAULT_SELECTION_CAP = 5000;
|
|
43
|
-
/** What a
|
|
44
|
-
export type
|
|
43
|
+
/** What a selection change does with the elements a target named. */
|
|
44
|
+
export type SelectionOp = "replace" | "add" | "remove" | "toggle" | "intersect";
|
|
45
45
|
/** Every set operation, for a caller that wants to check one before passing it on. */
|
|
46
|
-
export declare const SET_OPS: readonly
|
|
46
|
+
export declare const SET_OPS: readonly SelectionOp[];
|
|
47
47
|
/**
|
|
48
48
|
* Who asked for a selection change.
|
|
49
49
|
*
|
|
@@ -181,20 +181,23 @@ export interface SelectionApi {
|
|
|
181
181
|
* does.
|
|
182
182
|
* @returns What changed.
|
|
183
183
|
*/
|
|
184
|
-
apply(target: SelectionTarget, op?:
|
|
184
|
+
apply(target: SelectionTarget, op?: SelectionOp): Promise<SelectionDelta>;
|
|
185
185
|
/**
|
|
186
186
|
* Empty the selection.
|
|
187
187
|
* @returns What changed.
|
|
188
188
|
*/
|
|
189
189
|
clear(): SelectionDelta;
|
|
190
190
|
/**
|
|
191
|
-
* Keep this selection under a name,
|
|
191
|
+
* Keep this selection under a name, as a kept set created from the selection, so it can be
|
|
192
|
+
* named as `{ set: id }` later.
|
|
192
193
|
*
|
|
193
|
-
* The
|
|
194
|
-
*
|
|
195
|
-
*
|
|
194
|
+
* The kept set holds the selected nodes and the selected edges. With nodes selected it reads
|
|
195
|
+
* `induced`: every edge between its nodes comes with it, and the selected edges are kept
|
|
196
|
+
* beside them. With edges alone it reads `listed`: those edges and their endpoints.
|
|
197
|
+
* @deprecated Use {@link SetsApi.createFrom | session.sets.createFrom("selection")}, which keeps
|
|
198
|
+
* the same members and also takes a reading; this verb keeps working.
|
|
196
199
|
* @param name - The name to save it under.
|
|
197
|
-
* @returns The minted
|
|
200
|
+
* @returns The minted set id.
|
|
198
201
|
*/
|
|
199
202
|
promote(name: string): ScopeId;
|
|
200
203
|
/**
|
|
@@ -220,7 +223,7 @@ export interface SelectionOwner extends SelectionApi {
|
|
|
220
223
|
* @param cause - Who asked; the API itself when absent.
|
|
221
224
|
* @returns What changed.
|
|
222
225
|
*/
|
|
223
|
-
applyNow(target: SelectionTarget, op?:
|
|
226
|
+
applyNow(target: SelectionTarget, op?: SelectionOp, cause?: SelectionCause): SelectionDelta;
|
|
224
227
|
/**
|
|
225
228
|
* The node mask itself, for the scope resolver's `selection` source.
|
|
226
229
|
* @returns The live mask, which the caller must not mutate.
|
|
@@ -294,6 +297,8 @@ export interface SelectionSources {
|
|
|
294
297
|
* @param delta - What joined, what left, what the selection holds now, and who asked.
|
|
295
298
|
*/
|
|
296
299
|
readonly onChange?: (delta: SelectionDelta) => void;
|
|
300
|
+
/** Called on every version bump of either mask, which is what advances the session input tick. */
|
|
301
|
+
readonly onMaskVersion?: () => void;
|
|
297
302
|
}
|
|
298
303
|
/**
|
|
299
304
|
* Build the selection one session owns.
|
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
*
|
|
14
14
|
* Nothing in this module's import graph reaches Babylon.js, Lit or the DOM.
|
|
15
15
|
*/
|
|
16
|
-
export { createSelectionApi, DEFAULT_SELECTION_CAP, type SelectionApi, type SelectionAttributeStatistics, type SelectionCause, type SelectionDelta, type SelectionOwner, type SelectionSources, type SelectionStatistics, SET_OPS,
|
|
16
|
+
export { createSelectionApi, DEFAULT_SELECTION_CAP, type SelectionApi, type SelectionAttributeStatistics, type SelectionCause, type SelectionDelta, type SelectionOp, type SelectionOwner, type SelectionSources, type SelectionStatistics, SET_OPS, } from "./SelectionApi";
|
|
17
17
|
export { type ElementIdTarget, type NeighborhoodTarget, resolveTarget, type SelectionDirection, type SelectionMatch, type SelectionSearchHit, type SelectionTarget, type SelectionTextMode, type TargetContext, type TargetMembers, } from "./targets";
|