@graphty/graphty-element 2.5.1 → 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
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file What a definition depends on, and whether a chain of references loops
|
|
3
|
+
* (design/sets/sets-design.md sections 4.3 and 5.2).
|
|
4
|
+
*
|
|
5
|
+
* Dependencies are DERIVED from a definition, never stored. The walk:
|
|
6
|
+
*
|
|
7
|
+
* | Found | Dependency |
|
|
8
|
+
* |---------------------------------------------------------|-------------------------------------|
|
|
9
|
+
* | a `member` leaf `{ set: id }` | that set (follows it) |
|
|
10
|
+
* | a `member` leaf `"visible"`, `"selection"`, `"search"` | the visibility filter, the selection, the search |
|
|
11
|
+
* | a `member` leaf `"largest-component"`; `component`, `degree`, `neighborhood` | topology (the snapshot) |
|
|
12
|
+
* | a path `results.<run>.<field>` a query or `threshold` reads | that run (follows its current execution) |
|
|
13
|
+
* | an `item` leaf without `run` | that result (follows its current run) |
|
|
14
|
+
* | an `item` leaf with `run` | that run of the result (holds it) |
|
|
15
|
+
* | any other path a query, `range`, `categories` or `threshold` reads | that top-level attribute field |
|
|
16
|
+
*
|
|
17
|
+
* A query's paths come from the compiled expression, which has no projections or wildcards, so
|
|
18
|
+
* every path is static. The visibility filter and the selection are nodes of this graph: that is
|
|
19
|
+
* what lets a door refuse a filter that reads `"visible"` through a kept set, and a set that
|
|
20
|
+
* reaches itself through the filter.
|
|
21
|
+
*
|
|
22
|
+
* The walk reads definitions this element could not validate (a loaded record holding an unknown
|
|
23
|
+
* leaf) as far as it can: a reference it recognises inside one still counts, so a stored set naming
|
|
24
|
+
* `"search"` is still caught.
|
|
25
|
+
*
|
|
26
|
+
* Nothing here reaches Babylon.js, Lit or the DOM.
|
|
27
|
+
*/
|
|
28
|
+
import type { Path, Query, ResultItem, RuleTree, RunId, Scope, SetDefinition, SetId } from "../../catalog/types";
|
|
29
|
+
import { GraphtyError } from "../../errors/GraphtyError";
|
|
30
|
+
/** One thing a definition reads. */
|
|
31
|
+
type Dependency = {
|
|
32
|
+
readonly kind: "set";
|
|
33
|
+
readonly id: SetId;
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: "visible";
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: "selection";
|
|
38
|
+
} | {
|
|
39
|
+
readonly kind: "search";
|
|
40
|
+
} | {
|
|
41
|
+
readonly kind: "topology";
|
|
42
|
+
}
|
|
43
|
+
/** `execution` present: the reference holds that execution; absent: it follows the run. */
|
|
44
|
+
| {
|
|
45
|
+
readonly kind: "run";
|
|
46
|
+
readonly run: RunId;
|
|
47
|
+
readonly execution?: string;
|
|
48
|
+
} | {
|
|
49
|
+
readonly kind: "attribute";
|
|
50
|
+
readonly field: string;
|
|
51
|
+
};
|
|
52
|
+
/** A step of a reference chain: a set id, or one of the live keywords `"visible"`, `"selection"`, `"search"`. */
|
|
53
|
+
export type ChainStep = string;
|
|
54
|
+
/** Where the walk reads what a reference names. */
|
|
55
|
+
export interface DependencySources {
|
|
56
|
+
/**
|
|
57
|
+
* What a `{ set: id }` names: a kept set's definition or a saved scope's specification.
|
|
58
|
+
* @param id - The id.
|
|
59
|
+
* @returns The definition or scope, or undefined when nothing holds the id.
|
|
60
|
+
*/
|
|
61
|
+
readonly referent: (id: SetId) => SetDefinition | Scope | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* The visibility filter in force, which is what `"visible"` depends on.
|
|
64
|
+
* @returns The filter, or null.
|
|
65
|
+
*/
|
|
66
|
+
readonly visibility?: () => RuleTree | null;
|
|
67
|
+
/**
|
|
68
|
+
* The paths a query's compiled expression reads. Absent: a query's paths are not listed.
|
|
69
|
+
* @param where - The query.
|
|
70
|
+
* @returns The paths.
|
|
71
|
+
*/
|
|
72
|
+
readonly pathsOf?: (where: Query) => readonly Path[];
|
|
73
|
+
/**
|
|
74
|
+
* The shape of a run's current result, which says whether an item's field is a partition
|
|
75
|
+
* group. Absent, or undefined for a run: nothing is known, and nothing is refused on it.
|
|
76
|
+
* @param run - The run.
|
|
77
|
+
* @returns The result shape.
|
|
78
|
+
*/
|
|
79
|
+
readonly shapeOf?: (run: RunId) => string | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Which halves carry a value path, `results.<run>.<field>` or `data.<field>`, so a rule read
|
|
82
|
+
* `induced` over an edge field is refused. Absent: nothing is known.
|
|
83
|
+
* @param path - The path.
|
|
84
|
+
* @returns `"node"`, `"edge"` or both.
|
|
85
|
+
*/
|
|
86
|
+
readonly fieldKinds?: (path: Path) => readonly string[];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* What one path reads: a run's results, or a top-level attribute field.
|
|
90
|
+
* @param path - The path.
|
|
91
|
+
* @returns The run or the field.
|
|
92
|
+
*/
|
|
93
|
+
export declare function dependencyOf(path: Path): {
|
|
94
|
+
run: RunId;
|
|
95
|
+
} | {
|
|
96
|
+
field: string;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* What one definition, scope or rule tree reads directly, one of each, in the order met.
|
|
100
|
+
* @param value - A set definition, a scope, or a rule tree (the visibility filter).
|
|
101
|
+
* @param pathsOf - The paths a query reads; absent, queries list nothing.
|
|
102
|
+
* @returns The dependencies.
|
|
103
|
+
*/
|
|
104
|
+
export declare function dependenciesOf(value: SetDefinition | Scope | RuleTree, pathsOf?: (where: Query) => readonly Path[]): readonly Dependency[];
|
|
105
|
+
/**
|
|
106
|
+
* The chain by which a definition written to set `id` would reach `id` itself, through `scope`
|
|
107
|
+
* leaves, saved scopes and the visibility filter.
|
|
108
|
+
* @param id - The set being written.
|
|
109
|
+
* @param definition - Its new definition.
|
|
110
|
+
* @param sources - Where references are looked up.
|
|
111
|
+
* @returns The chain, ending with `id`, or null when there is no cycle.
|
|
112
|
+
*/
|
|
113
|
+
export declare function setCycle(id: SetId, definition: SetDefinition, sources: DependencySources): ChainStep[] | null;
|
|
114
|
+
/**
|
|
115
|
+
* The chain by which a visibility filter would read `"visible"` or `"search"`: what it computes.
|
|
116
|
+
* @param filter - The filter, or a scope inside one.
|
|
117
|
+
* @param sources - Where references are looked up.
|
|
118
|
+
* @returns The chain, ending with `"visible"` or `"search"`, or null.
|
|
119
|
+
*/
|
|
120
|
+
export declare function visibilityCycle(filter: RuleTree | Scope, sources: DependencySources): ChainStep[] | null;
|
|
121
|
+
/**
|
|
122
|
+
* The chain by which a kept rule would read the live selection. Not followed through
|
|
123
|
+
* `"visible"`: a set may follow the visible graph whatever the filter reads.
|
|
124
|
+
* @param definition - The definition.
|
|
125
|
+
* @param sources - Where references are looked up.
|
|
126
|
+
* @returns The chain, ending with `"selection"`, or null.
|
|
127
|
+
*/
|
|
128
|
+
export declare function selectionChain(definition: SetDefinition, sources: DependencySources): ChainStep[] | null;
|
|
129
|
+
/**
|
|
130
|
+
* How the set an id names reads, following saved scopes; undefined when nothing holds the id or
|
|
131
|
+
* the chain loops.
|
|
132
|
+
* @param sources - Where references are looked up.
|
|
133
|
+
* @returns The lookup.
|
|
134
|
+
*/
|
|
135
|
+
export declare function referentReading(sources: DependencySources): (id: SetId) => string | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* The first `item` leaf that follows a partition group across re-runs (the `group` field of a
|
|
138
|
+
* `community` result), in the value itself and the definitions it carries inline. A group number
|
|
139
|
+
* means nothing across re-runs, so such an item must hold its execution.
|
|
140
|
+
* @param value - A definition, a scope, or a rule tree.
|
|
141
|
+
* @param sources - Where a run's result shape is read; without `shapeOf` nothing is found.
|
|
142
|
+
* @returns The item, or null.
|
|
143
|
+
*/
|
|
144
|
+
export declare function followedGroup(value: SetDefinition | Scope | RuleTree, sources: DependencySources): ResultItem | null;
|
|
145
|
+
/**
|
|
146
|
+
* The refusal of an item that follows a partition group.
|
|
147
|
+
* @param item - The item.
|
|
148
|
+
* @returns The error to throw.
|
|
149
|
+
*/
|
|
150
|
+
export declare function followsGroup(item: ResultItem): GraphtyError;
|
|
151
|
+
/**
|
|
152
|
+
* Refuse a value that names a set id never issued in this session, at a write door. A removed
|
|
153
|
+
* set's id was issued, so it is accepted and reads as detached; only a typo, or an id from
|
|
154
|
+
* another session, is refused -- which would otherwise hide everything in a filter or paint
|
|
155
|
+
* nothing in a layer without a word.
|
|
156
|
+
* @param value - A set definition, a scope, a rule tree, or a selector's scope.
|
|
157
|
+
* @param ids - Which ids exist: the live records, and every id ever issued.
|
|
158
|
+
* @param ids.get - A live record by id.
|
|
159
|
+
* @param ids.register - Every id ever issued and committed.
|
|
160
|
+
* @param self - The id being written, which a definition may not name but is not unknown.
|
|
161
|
+
* @throws `E_BAD_COMMAND` with `details.reason` `"unknown-set"`.
|
|
162
|
+
*/
|
|
163
|
+
export declare function assertIssued(value: SetDefinition | Scope | RuleTree, ids: {
|
|
164
|
+
get(id: SetId): unknown;
|
|
165
|
+
register(): ReadonlySet<SetId>;
|
|
166
|
+
}, self?: SetId): void;
|
|
167
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The live scopes style layers name (design/sets/sets-design.md section 11). Internal.
|
|
3
|
+
*
|
|
4
|
+
* A `{match:"member"}` layer tests one bit per element against its scope's live bitmap. Layers
|
|
5
|
+
* naming the same scope share one live entry, keyed by the scope's canonical form. An entry starts
|
|
6
|
+
* watching the first time a pass reads it: it subscribes to the session's change notifier with
|
|
7
|
+
* the scope's input signature, and holds the resolution it last took, pinned in the resolution
|
|
8
|
+
* cache so budget pressure never evicts what is on screen.
|
|
9
|
+
*
|
|
10
|
+
* When the scope moves on the same snapshot, the elements to repaint are exactly the old bitmap
|
|
11
|
+
* XOR the new one. Across a freeze the two bitmaps index different rows, so the old members are
|
|
12
|
+
* carried to the new rows by id, once per snapshot, and the repaint is the carried bitmap XOR the
|
|
13
|
+
* new resolution, on the scheduler's frame: a freeze that leaves the members alone repaints
|
|
14
|
+
* nothing. Until the frame the entry keeps its paint through the same carry, so a whole-graph pass
|
|
15
|
+
* that runs before it paints what was painted before.
|
|
16
|
+
*
|
|
17
|
+
* A scope that cannot be resolved -- a removed set, a cycle -- paints nothing, and the pass goes
|
|
18
|
+
* on. Nothing here throws into a pass.
|
|
19
|
+
*
|
|
20
|
+
* Nothing here reaches Babylon.js, Lit or the DOM.
|
|
21
|
+
*/
|
|
22
|
+
import { type GraphSnapshot } from "@graphty/graph-format";
|
|
23
|
+
import type { Scope } from "../../catalog/types";
|
|
24
|
+
import type { LiveScope } from "../styles/predicate";
|
|
25
|
+
import type { ElementIndices } from "../styles/repaint";
|
|
26
|
+
import type { SetWatch } from "./notify";
|
|
27
|
+
import type { Resolution } from "./resolve";
|
|
28
|
+
/** What one entry holds: its resolution, or null for a scope that paints nothing. */
|
|
29
|
+
interface Held {
|
|
30
|
+
readonly resolution: Resolution | null;
|
|
31
|
+
/** The snapshot it was resolved against. */
|
|
32
|
+
readonly graph: GraphSnapshot;
|
|
33
|
+
readonly problem?: string;
|
|
34
|
+
}
|
|
35
|
+
/** Everything the live scopes read from their session. */
|
|
36
|
+
interface LayerScopeSources {
|
|
37
|
+
/**
|
|
38
|
+
* The snapshot the session holds now.
|
|
39
|
+
* @returns The snapshot.
|
|
40
|
+
*/
|
|
41
|
+
snapshot(): GraphSnapshot;
|
|
42
|
+
/**
|
|
43
|
+
* Resolve a scope through the cache.
|
|
44
|
+
* @param scope - The scope.
|
|
45
|
+
* @returns The resolution and the snapshot it covers; throws a `GraphtyError` when it cannot.
|
|
46
|
+
*/
|
|
47
|
+
resolve(scope: Scope): {
|
|
48
|
+
readonly resolution: Resolution;
|
|
49
|
+
readonly graph: GraphSnapshot;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* The scope's input signature now.
|
|
53
|
+
* @param scope - The scope.
|
|
54
|
+
* @returns The signature, or null when its inputs cannot be enumerated.
|
|
55
|
+
*/
|
|
56
|
+
signature(scope: Scope): string | null;
|
|
57
|
+
/**
|
|
58
|
+
* Watch through the session's notifier.
|
|
59
|
+
* @param watch - The watch.
|
|
60
|
+
* @returns Stops watching.
|
|
61
|
+
*/
|
|
62
|
+
subscribe(watch: SetWatch<Held>): () => void;
|
|
63
|
+
/**
|
|
64
|
+
* Pin the scope's current cache entry.
|
|
65
|
+
* @param scope - The scope.
|
|
66
|
+
* @returns Releases the pin.
|
|
67
|
+
*/
|
|
68
|
+
pin(scope: Scope): () => void;
|
|
69
|
+
/**
|
|
70
|
+
* Repaint elements whose membership moved.
|
|
71
|
+
* @param dirty - The indices, per half.
|
|
72
|
+
* @returns Settles when the repaint has finished, or nothing when it is not awaitable.
|
|
73
|
+
*/
|
|
74
|
+
repaint(dirty: ElementIndices): Promise<unknown> | undefined;
|
|
75
|
+
}
|
|
76
|
+
/** The live scopes of one session's style layers. */
|
|
77
|
+
export declare class LayerScopes {
|
|
78
|
+
#private;
|
|
79
|
+
/**
|
|
80
|
+
* Build over a session. Whole-graph repaints the entries ask for are coalesced: while one is
|
|
81
|
+
* running, every further request becomes one more pass after it, over the graph as it then
|
|
82
|
+
* stands. After a freeze each live set asks for one as its resolution arrives, frame by frame,
|
|
83
|
+
* so ten live sets would otherwise cost ten whole-graph passes.
|
|
84
|
+
* @param sources - The session.
|
|
85
|
+
*/
|
|
86
|
+
constructor(sources: LayerScopeSources);
|
|
87
|
+
/**
|
|
88
|
+
* The live membership of a scope, shared by every layer naming it.
|
|
89
|
+
* @param scope - The scope, already checked.
|
|
90
|
+
* @returns Its live membership.
|
|
91
|
+
*/
|
|
92
|
+
live(scope: Scope): LiveScope;
|
|
93
|
+
/**
|
|
94
|
+
* Keep only the entries the stack names; the rest stop watching and release their pins.
|
|
95
|
+
* @param scopes - The scopes the stack's layers name.
|
|
96
|
+
*/
|
|
97
|
+
keep(scopes: Iterable<Scope>): void;
|
|
98
|
+
/** Stop every entry. */
|
|
99
|
+
dispose(): void;
|
|
100
|
+
}
|
|
101
|
+
export {};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Change notification and the re-resolution scheduler (design/sets/sets-design.md sections
|
|
3
|
+
* 6.2 and 11). Internal.
|
|
4
|
+
*
|
|
5
|
+
* A live user of a set -- a style layer, the visibility filter -- WATCHES it: it hands in the input
|
|
6
|
+
* signature of everything it reads (`./signature`), how to resolve it, and where the new
|
|
7
|
+
* resolution goes. Six hooks tell the notifier that an input moved:
|
|
8
|
+
*
|
|
9
|
+
* - the sets store's committed diff (`SetsStore.onCommit`), before any `set:changed`;
|
|
10
|
+
* - a selection change and a visibility change, before their public events;
|
|
11
|
+
* - a run moving its result: queued for a re-run (the result is cleared), finished, or removed;
|
|
12
|
+
* - an attribute write after load (`Graph.updateNodes`), announced once per batch on the store
|
|
13
|
+
* owner's input tick;
|
|
14
|
+
* - a snapshot replacement, announced on the same tick once a freeze has been delivered.
|
|
15
|
+
*
|
|
16
|
+
* Ingest writes attributes too, but announces nothing: it also touches the store, and the freeze
|
|
17
|
+
* that follows re-queues every watch. Announcing it would make a watch resolve mid-load and force
|
|
18
|
+
* a freeze per ingested chunk.
|
|
19
|
+
*
|
|
20
|
+
* On the SAME snapshot a notification is synchronous: every watch whose signature moved resolves
|
|
21
|
+
* at once and is handed the new resolution with the inputs that moved, so a layer can repaint the
|
|
22
|
+
* XOR of old and new before any public event fires. A watch whose signature did not move is not
|
|
23
|
+
* asked to resolve.
|
|
24
|
+
*
|
|
25
|
+
* A SNAPSHOT REPLACEMENT is not: every freeze moves every signature (the serial is in all of them),
|
|
26
|
+
* and re-resolving every live set in one turn would hold the thread. Each watch is queued and the
|
|
27
|
+
* queue is worked frame by frame within a per-frame work budget, counted in the elements each
|
|
28
|
+
* resolution walks as the watch estimates them, never timed. A watch keeps its previous resolution
|
|
29
|
+
* until its new one is ready. A second freeze mid-way adds nothing twice: a watch still queued is
|
|
30
|
+
* resolved once, against the newest snapshot, and a watch already done is queued again and
|
|
31
|
+
* resolved only if its signature moved again.
|
|
32
|
+
*
|
|
33
|
+
* Nothing here reaches Babylon.js, Lit or the DOM.
|
|
34
|
+
*/
|
|
35
|
+
import type { RunId, SetId } from "../../catalog/types";
|
|
36
|
+
/** One input that moved, as a watch is told. OPEN UNION. */
|
|
37
|
+
export type MovedInput = {
|
|
38
|
+
readonly kind: "sets";
|
|
39
|
+
readonly ids: readonly SetId[];
|
|
40
|
+
} | {
|
|
41
|
+
readonly kind: "selection";
|
|
42
|
+
} | {
|
|
43
|
+
readonly kind: "visibility";
|
|
44
|
+
} | {
|
|
45
|
+
readonly kind: "run";
|
|
46
|
+
readonly run: RunId;
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: "attributes";
|
|
49
|
+
readonly element: "node" | "edge";
|
|
50
|
+
readonly fields: readonly string[];
|
|
51
|
+
} | {
|
|
52
|
+
readonly kind: "snapshot";
|
|
53
|
+
readonly serial: number;
|
|
54
|
+
};
|
|
55
|
+
/** One live user of a set. */
|
|
56
|
+
export interface SetWatch<R> {
|
|
57
|
+
/**
|
|
58
|
+
* The input signature of everything it reads now.
|
|
59
|
+
* @returns the signature, or null when its inputs cannot be enumerated (always re-resolved)
|
|
60
|
+
*/
|
|
61
|
+
signature(): string | null;
|
|
62
|
+
/**
|
|
63
|
+
* Resolve now, against the current snapshot and inputs.
|
|
64
|
+
* @returns the new resolution
|
|
65
|
+
*/
|
|
66
|
+
resolve(): R;
|
|
67
|
+
/**
|
|
68
|
+
* Take a new resolution.
|
|
69
|
+
* @param resolution - what {@link SetWatch.resolve} returned
|
|
70
|
+
* @param moved - every input reported since its previous resolution, oldest first
|
|
71
|
+
*/
|
|
72
|
+
ready(resolution: R, moved: readonly MovedInput[]): void;
|
|
73
|
+
/**
|
|
74
|
+
* What one resolution costs against the per-frame budget.
|
|
75
|
+
* @returns the elements it walks, estimated
|
|
76
|
+
*/
|
|
77
|
+
cost(): number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Asks for one call on the next frame.
|
|
81
|
+
* @param callback - what to call
|
|
82
|
+
* @returns cancels the request
|
|
83
|
+
*/
|
|
84
|
+
type FrameSource = (callback: () => void) => () => void;
|
|
85
|
+
/** The notifier and scheduler of one session. */
|
|
86
|
+
export declare class SetsNotifier {
|
|
87
|
+
#private;
|
|
88
|
+
/**
|
|
89
|
+
* Start with nothing watched and nothing queued.
|
|
90
|
+
* @param options - the frame source and the per-frame budget, for tests
|
|
91
|
+
* @param options.frames - asks for the next frame; a timer by default
|
|
92
|
+
* @param options.budget - elements resolved per frame
|
|
93
|
+
*/
|
|
94
|
+
constructor(options?: {
|
|
95
|
+
frames?: FrameSource;
|
|
96
|
+
budget?: number;
|
|
97
|
+
});
|
|
98
|
+
/**
|
|
99
|
+
* Watch a set. Its current resolution is the caller's; the signature it stands for is read now.
|
|
100
|
+
* @param watch - the watch
|
|
101
|
+
* @returns stops watching, and drops it from the queue
|
|
102
|
+
*/
|
|
103
|
+
subscribe<R>(watch: SetWatch<R>): () => void;
|
|
104
|
+
/**
|
|
105
|
+
* Report that one input moved.
|
|
106
|
+
* @param input - what moved
|
|
107
|
+
*/
|
|
108
|
+
notify(input: MovedInput): void;
|
|
109
|
+
/**
|
|
110
|
+
* Use another frame source from now on (the element's render loop).
|
|
111
|
+
* @param frames - the source
|
|
112
|
+
*/
|
|
113
|
+
useFrames(frames: FrameSource): void;
|
|
114
|
+
/**
|
|
115
|
+
* Watches waiting for a frame.
|
|
116
|
+
* @returns how many
|
|
117
|
+
*/
|
|
118
|
+
get pending(): number;
|
|
119
|
+
/** Cancel the queued work and drop every watch. */
|
|
120
|
+
dispose(): void;
|
|
121
|
+
}
|
|
122
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Offered sets and Memberships (design/sets/sets-design.md sections 8.2 and 15.2).
|
|
3
|
+
*
|
|
4
|
+
* A finished run's result OFFERS sets by its shape, never by its algorithm, so every registered
|
|
5
|
+
* algorithm gets them: one per group of a partition, one per level, one per category, one for a
|
|
6
|
+
* node or edge set, one for a path. An offer is a rule over one held item; using it as a scope
|
|
7
|
+
* writes nothing.
|
|
8
|
+
*
|
|
9
|
+
* Counting is split by what it reads. Node counts of an offer read `induced` need only the
|
|
10
|
+
* result's values, one pass over the nodes, cached per execution and snapshot. Everything that
|
|
11
|
+
* needs the edge list -- the edges of every item, and the nodes of an item read `listed`, which
|
|
12
|
+
* include its edges' endpoints -- comes from ONE pass over the edges, cached the same way and run
|
|
13
|
+
* by the first resolution of an offer, never by `offers`.
|
|
14
|
+
*
|
|
15
|
+
* MEMBERSHIPS answer "what holds this element" without resolving what they need not: a cached
|
|
16
|
+
* resolution is tested when there is one, a fixed set of nodes alone is a binary search of them, a
|
|
17
|
+
* rule of element-local leaves is compiled and tested at the one index, and anything else is
|
|
18
|
+
* resolved once through the cache.
|
|
19
|
+
*
|
|
20
|
+
* Node-safe.
|
|
21
|
+
*/
|
|
22
|
+
import type { EdgeId, NodeId, RunId } from "../../catalog/types";
|
|
23
|
+
import type { RunResult } from "../results/types";
|
|
24
|
+
import type { FilterRunResult } from "../visibility/filter";
|
|
25
|
+
import { type ResolveContext } from "./resolve";
|
|
26
|
+
import type { ElementSet, Memberships, SetOffer } from "./types";
|
|
27
|
+
/** Counts the offers tests read. */
|
|
28
|
+
export declare const offerCounters: {
|
|
29
|
+
nodeScans: number;
|
|
30
|
+
edgePasses: number;
|
|
31
|
+
};
|
|
32
|
+
/** One run as offers read it. */
|
|
33
|
+
interface OfferRun {
|
|
34
|
+
readonly id: RunId;
|
|
35
|
+
readonly label: string;
|
|
36
|
+
/** Its current result, or undefined before it has one. */
|
|
37
|
+
readonly result: RunResult | undefined;
|
|
38
|
+
}
|
|
39
|
+
/** What offers and Memberships read from the session. */
|
|
40
|
+
interface OfferSources {
|
|
41
|
+
/**
|
|
42
|
+
* A run.
|
|
43
|
+
* @param id - Its id.
|
|
44
|
+
* @returns The run, or undefined when the session holds none.
|
|
45
|
+
*/
|
|
46
|
+
run(id: RunId): OfferRun | undefined;
|
|
47
|
+
/** Every run, in the session's order. */
|
|
48
|
+
runs(): readonly OfferRun[];
|
|
49
|
+
/**
|
|
50
|
+
* A run's current result by dense index, with its execution token.
|
|
51
|
+
* @param id - The run.
|
|
52
|
+
* @returns The values, or undefined when it has no result.
|
|
53
|
+
*/
|
|
54
|
+
values(id: RunId): FilterRunResult | undefined;
|
|
55
|
+
/** What a resolution reads now: the snapshot, the cache, the readers. */
|
|
56
|
+
context(): ResolveContext;
|
|
57
|
+
/** The kept sets, in listing order. */
|
|
58
|
+
sets(): readonly ElementSet[];
|
|
59
|
+
}
|
|
60
|
+
/** Offers and Memberships over one session. */
|
|
61
|
+
export interface Offering {
|
|
62
|
+
/**
|
|
63
|
+
* The offers of a run's result, largest first.
|
|
64
|
+
* @param run - The run.
|
|
65
|
+
* @param limit - The most to return.
|
|
66
|
+
* @returns The offers and how many were left out.
|
|
67
|
+
* @throws `E_UNKNOWN_RUN` for a run the session does not hold.
|
|
68
|
+
*/
|
|
69
|
+
offers(run: RunId, limit?: number): {
|
|
70
|
+
readonly offers: readonly SetOffer[];
|
|
71
|
+
readonly more: number;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Run a run's edge-count pass over the current snapshot unless it is cached. The first
|
|
75
|
+
* resolution of an offer calls this.
|
|
76
|
+
* @param run - The run.
|
|
77
|
+
*/
|
|
78
|
+
countEdges(run: RunId): void;
|
|
79
|
+
/**
|
|
80
|
+
* A path offer's node order: the `order` value of a node index.
|
|
81
|
+
* @param run - The run.
|
|
82
|
+
* @returns A reader of the value, or undefined when the run has no result.
|
|
83
|
+
*/
|
|
84
|
+
orderOf(run: RunId): ((index: number) => unknown) | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* What holds one element.
|
|
87
|
+
* @param element - The node or edge.
|
|
88
|
+
* @returns The memberships.
|
|
89
|
+
* @throws `E_BAD_COMMAND` for an element the graph does not hold.
|
|
90
|
+
*/
|
|
91
|
+
memberships(element: {
|
|
92
|
+
readonly node: NodeId;
|
|
93
|
+
} | {
|
|
94
|
+
readonly edge: EdgeId;
|
|
95
|
+
}): Memberships;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Build offers and Memberships over a session.
|
|
99
|
+
* @param sources - What they read.
|
|
100
|
+
* @returns The offering.
|
|
101
|
+
*/
|
|
102
|
+
export declare function createOffering(sources: OfferSources): Offering;
|
|
103
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Path resolution (design/sets/sets-design.md section 4.4).
|
|
3
|
+
*
|
|
4
|
+
* A path set resolves to its distinct nodes and the edges its steps name, read `listed`. A step
|
|
5
|
+
* that names an edge or a group of edges contributes the ones bound in the snapshot (through the
|
|
6
|
+
* binding table, as a fixed set's edge members do); a `null` step, or a path with no `edges`,
|
|
7
|
+
* contributes every edge between its pair. Under `directed: true` only edges running from
|
|
8
|
+
* `nodes[i]` to `nodes[i + 1]` count. A step with no edge left counts missing. Nothing throws.
|
|
9
|
+
*
|
|
10
|
+
* Nothing here reaches Babylon.js, Lit or the DOM.
|
|
11
|
+
*/
|
|
12
|
+
import type { PathKind, SetDefinition } from "../../catalog/types";
|
|
13
|
+
import { type EdgeSeeds, type Resolution, type ResolveContext } from "./resolve";
|
|
14
|
+
/** A path definition. */
|
|
15
|
+
type PathDefinition = Extract<SetDefinition, {
|
|
16
|
+
kind: "path";
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* What a path covers in the context snapshot.
|
|
20
|
+
* @param definition - A canonical path definition.
|
|
21
|
+
* @param context - What the resolution reads.
|
|
22
|
+
* @param seeds - The set's seeds, for a kept set.
|
|
23
|
+
* @returns The resolution: `missingNodes` counts distinct walk nodes the graph does not hold,
|
|
24
|
+
* `missingEdges` the steps with no edge, `ambiguousEdges` the named members two edges carry.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolvePath(definition: PathDefinition, context: ResolveContext, seeds?: EdgeSeeds): Resolution;
|
|
27
|
+
/**
|
|
28
|
+
* What kind of walk a path is (design 4.4). Each step is one logical edge, keyed on the group of
|
|
29
|
+
* edges it names, or on its end pair for a `null` step (unordered unless `directed`). `trail`: no
|
|
30
|
+
* logical edge repeats; `simple`: no node repeats; `cycle`: a closed trail of at least one step
|
|
31
|
+
* whose only repeated node is the first, equal to the last; `walk`: anything else. The most
|
|
32
|
+
* specific kind is returned. Derived from the definition alone: never resolves.
|
|
33
|
+
* @param definition - A canonical path definition.
|
|
34
|
+
* @returns The kind.
|
|
35
|
+
*/
|
|
36
|
+
export declare function pathKind(definition: PathDefinition): PathKind;
|
|
37
|
+
export {};
|