@graphty/graphty-element 2.6.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai.js +3 -3
- package/dist/catalog.js +53 -54
- package/dist/chunks/{AiManager-4iQpsJW1.js → AiManager-Bhh0rR_p.js} +706 -655
- package/dist/chunks/GraphSession-DPoTaT3b.js +21175 -0
- package/dist/chunks/{GraphtyLogger-B_O67a6c.js → GraphtyLogger-BtcBJQPL.js} +1 -1
- package/dist/chunks/{VoiceInputAdapter-Cc6mHXTI.js → VoiceInputAdapter-CdLsJ_nG.js} +1 -1
- package/dist/chunks/{XRPivotCameraController-BLa89LXn.js → XRPivotCameraController-CiLJ9Gz6.js} +2 -2
- package/dist/chunks/algorithms-qij74zEN.js +6811 -0
- package/dist/chunks/{capability-check-Am2zliFj.js → capability-check-BbgTejS3.js} +1 -1
- package/dist/chunks/definePalette-BYt2Llxs.js +1333 -0
- package/dist/chunks/fields-5uVC1Pll.js +4999 -0
- package/dist/chunks/{format-detection-BHwrAVzW.js → format-detection-FKaDMshR.js} +1 -1
- package/dist/chunks/{index-BkBLbvui.js → index-Cc_6D9hV.js} +6034 -7127
- package/dist/chunks/interpolation-Dk206AhZ.js +105 -0
- package/dist/chunks/paletteRegistry-De3CGdst.js +357 -0
- package/dist/chunks/parse-SVp77JbE.js +669 -0
- package/dist/chunks/{pluginRegistry-Bs8bEkz9.js → pluginRegistry-Ddfl6Mv2.js} +27 -24
- package/dist/chunks/{registry-BdGvyZou.js → registry-CgMqldp4.js} +1 -1
- package/dist/chunks/{DataSource-BL2UzPff.js → sources-BbAJCDIH.js} +279 -108
- package/dist/commands.d.ts +128 -19
- package/dist/commands.js +49 -1
- package/dist/custom-elements.json +1 -1
- package/dist/extend.d.ts +10 -2
- package/dist/extend.js +64 -57
- package/dist/graphty-catalog.json +6 -3
- package/dist/graphty.bundle.js +267177 -240648
- package/dist/graphty.js +84 -78
- package/dist/index.d.ts +4 -0
- package/dist/logging.js +2 -2
- package/dist/schema.js +70 -71
- package/dist/session.d.ts +5 -6
- package/dist/session.js +40 -86
- package/dist/src/Edge.d.ts +31 -67
- package/dist/src/Graph.d.ts +335 -77
- package/dist/src/Node.d.ts +36 -3
- package/dist/src/NodeBehavior.d.ts +28 -0
- package/dist/src/Styles.d.ts +15 -4
- package/dist/src/acceleration/AccelerationController.d.ts +8 -0
- package/dist/src/acceleration/narrow.d.ts +9 -1
- package/dist/src/acceleration/types.d.ts +10 -0
- package/dist/src/ai/AiController.d.ts +12 -0
- package/dist/src/ai/AiManager.d.ts +7 -0
- package/dist/src/ai/commands/AlgorithmCommands.d.ts +1 -1
- package/dist/src/ai/commands/LayoutCommands.d.ts +1 -1
- package/dist/src/ai/commands/StyleCommands.d.ts +1 -1
- package/dist/src/ai/commands/types.d.ts +20 -1
- package/dist/src/algorithms/Algorithm.d.ts +21 -4
- package/dist/src/algorithms/BFSAlgorithm.d.ts +0 -9
- package/dist/src/algorithms/BellmanFordAlgorithm.d.ts +0 -14
- package/dist/src/algorithms/DFSAlgorithm.d.ts +1 -1
- package/dist/src/algorithms/FloydWarshallAlgorithm.d.ts +5 -0
- package/dist/src/algorithms/GirvanNewmanAlgorithm.d.ts +5 -0
- package/dist/src/algorithms/LeidenAlgorithm.d.ts +5 -0
- package/dist/src/algorithms/PageRankAlgorithm.d.ts +1 -1
- package/dist/src/algorithms/StronglyConnectedComponentsAlgorithm.d.ts +1 -1
- package/dist/src/algorithms/metrics/fields.d.ts +23 -1
- package/dist/src/algorithms/utils/graphUtils.d.ts +13 -1
- package/dist/src/catalog/paletteRegistry.d.ts +4 -4
- package/dist/src/catalog/registry.d.ts +3 -2
- package/dist/src/catalog/types.d.ts +18 -1
- package/dist/src/config/GraphStyle.d.ts +1 -1
- package/dist/src/config/StyleTemplate.d.ts +2 -2
- package/dist/src/config/xr-config-schema.d.ts +4 -4
- package/dist/src/data/CSVDataSource.d.ts +77 -22
- package/dist/src/data/ErrorAggregator.d.ts +5 -0
- package/dist/src/data/GEXFDataSource.d.ts +12 -61
- package/dist/src/data/GraphMLDataSource.d.ts +3 -44
- package/dist/src/data/GraphStore.d.ts +322 -15
- package/dist/src/data/JsonDataSource.d.ts +43 -1
- package/dist/src/data/graph-io-import.d.ts +89 -0
- package/dist/src/data/graph-io-records.d.ts +64 -0
- package/dist/src/data/lane.d.ts +23 -0
- package/dist/src/data/positions.d.ts +13 -0
- package/dist/src/data/seedPosition.d.ts +16 -0
- package/dist/src/errors/GraphtyError.d.ts +3 -1
- package/dist/src/errors/codes.d.ts +23 -0
- package/dist/src/events.d.ts +12 -0
- package/dist/src/graphty-element.d.ts +149 -54
- package/dist/src/input/types.d.ts +2 -0
- package/dist/src/layout/D3GraphLayoutEngine.d.ts +17 -3
- package/dist/src/layout/FixedLayoutEngine.d.ts +20 -4
- package/dist/src/layout/KamadaKawaiLayoutEngine.d.ts +6 -0
- package/dist/src/layout/LayoutEngine.d.ts +214 -116
- package/dist/src/layout/NGraphLayoutEngine.d.ts +10 -3
- package/dist/src/layout/SimulationLayoutEngine.d.ts +8 -3
- package/dist/src/managers/AlgorithmManager.d.ts +24 -5
- package/dist/src/managers/DataManager.d.ts +258 -181
- package/dist/src/managers/EventManager.d.ts +5 -2
- package/dist/src/managers/GraphContext.d.ts +7 -0
- package/dist/src/managers/InputManager.d.ts +11 -0
- package/dist/src/managers/LayoutManager.d.ts +129 -50
- package/dist/src/managers/RenderManager.d.ts +14 -1
- package/dist/src/managers/UpdateManager.d.ts +20 -0
- package/dist/src/screenshot/ScreenshotCapture.d.ts +1 -1
- package/dist/src/session/GraphSession.d.ts +83 -6
- package/dist/src/session/commands/algo.d.ts +169 -0
- package/dist/src/session/commands/config.d.ts +45 -0
- package/dist/src/session/commands/data.d.ts +178 -0
- package/dist/src/session/commands/doors.d.ts +93 -0
- package/dist/src/session/commands/index.d.ts +20 -0
- package/dist/src/session/commands/layout.d.ts +104 -0
- package/dist/src/session/commands/positions.d.ts +30 -0
- package/dist/src/session/commands/sets.d.ts +113 -0
- package/dist/src/session/commands/style.d.ts +92 -0
- package/dist/src/session/commands/view.d.ts +57 -0
- package/dist/src/session/commands/visibility.d.ts +41 -0
- package/dist/src/session/data.d.ts +131 -4
- package/dist/src/session/index.d.ts +1 -1
- package/dist/src/session/planning.d.ts +25 -8
- package/dist/src/session/project/Dispatcher.d.ts +905 -0
- package/dist/src/session/project/History.d.ts +382 -0
- package/dist/src/session/project/arrangement.d.ts +247 -0
- package/dist/src/session/project/derive.d.ts +132 -0
- package/dist/src/session/project/digest.d.ts +33 -0
- package/dist/src/session/project/draft.d.ts +194 -0
- package/dist/src/session/project/graphOps.d.ts +304 -0
- package/dist/src/session/project/ingest.d.ts +364 -0
- package/dist/src/session/project/state.d.ts +145 -0
- package/dist/src/session/project/strict.d.ts +68 -0
- package/dist/src/session/results/RunResult.d.ts +48 -0
- package/dist/src/session/results/statistics.d.ts +20 -0
- package/dist/src/session/runs/Run.d.ts +80 -4
- package/dist/src/session/runs/RunsApi.d.ts +23 -6
- package/dist/src/session/runs/types.d.ts +25 -6
- package/dist/src/session/scope/ElementMask.d.ts +14 -0
- package/dist/src/session/scope/ScopeApi.d.ts +3 -22
- package/dist/src/session/scope/spaces.d.ts +29 -0
- package/dist/src/session/sealed.d.ts +22 -0
- package/dist/src/session/selection/SelectionApi.d.ts +14 -4
- package/dist/src/session/sets/SetsApi.d.ts +13 -5
- package/dist/src/session/sets/store.d.ts +54 -53
- package/dist/src/session/sets/types.d.ts +5 -2
- package/dist/src/session/styles/Layer.d.ts +5 -0
- package/dist/src/session/styles/StylesApi.d.ts +68 -17
- package/dist/src/session/styles/autoApply.d.ts +64 -53
- package/dist/src/session/styles/index.d.ts +3 -3
- package/dist/src/session/styles/predicate.d.ts +7 -0
- package/dist/src/session/styles/repaint.d.ts +16 -1
- package/dist/src/session/styles/sources.d.ts +1 -1
- package/dist/src/session/types.d.ts +625 -54
- package/dist/src/session/visibility/VisibilityApi.d.ts +38 -18
- package/dist/src/session/visibility/filter.d.ts +10 -0
- package/dist/src/simple/defineAlgorithm.d.ts +28 -0
- package/dist/src/simple/defineLayout.d.ts +35 -0
- package/dist/src/simple/defineLogDestination.d.ts +31 -0
- package/dist/src/simple/definePalette.d.ts +26 -0
- package/dist/src/simple/definition.d.ts +106 -0
- package/dist/src/simple/options.d.ts +33 -0
- package/dist/src/simple/source.d.ts +49 -0
- package/dist/src/simple/types.d.ts +366 -0
- package/dist/src/simple/view.d.ts +107 -0
- package/dist/webgpu.js +2 -2
- package/package.json +10 -12
- package/dist/chunks/GraphSession-BhuHSXIo.js +0 -12819
- package/dist/chunks/GraphStyle-Cwr55SAE.js +0 -65
- package/dist/chunks/algorithms-BJ6DQMOe.js +0 -3777
- package/dist/chunks/detect-fyuVnlCT.js +0 -88
- package/dist/chunks/interpolation-DY-PNpqX.js +0 -43
- package/dist/chunks/optionsFromZod-CKMYSwTz.js +0 -3636
- package/dist/chunks/paletteRegistry-BCFSwJGK.js +0 -1196
- package/dist/chunks/parse-BMTqt4SS.js +0 -3658
- package/dist/src/data/csv-variant-detection.d.ts +0 -29
- package/dist/src/data/ingest.d.ts +0 -104
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Ingest: how records become the graph, with no renderer anywhere in reach.
|
|
3
|
+
*
|
|
4
|
+
* Id and endpoint extraction, the repeated-edge policy, weight resolution, the direction a file
|
|
5
|
+
* declares, the import report and the chunked load all live here. What happens to a record once
|
|
6
|
+
* the graph holds it -- a mesh, a place in the layout engine, an event -- is the host's business,
|
|
7
|
+
* reached through {@link IngestHost}. `DataManager` is the element's host and keeps only that
|
|
8
|
+
* render half; a headless session can be another.
|
|
9
|
+
*
|
|
10
|
+
* Nothing here reaches Babylon.js, Lit or the DOM: `test/packaging/node-safe-entries.test.ts`
|
|
11
|
+
* checks it.
|
|
12
|
+
*/
|
|
13
|
+
import { type DuplicatePolicy } from "@graphty/graph-format";
|
|
14
|
+
import type { EdgeId } from "../../catalog/types";
|
|
15
|
+
import type { ErrorAggregator } from "../../data/ErrorAggregator";
|
|
16
|
+
import type { GraphStore } from "../../data/GraphStore";
|
|
17
|
+
import { type ImportReport } from "../../data/report";
|
|
18
|
+
import type { NodeIdType } from "../../Node";
|
|
19
|
+
import type { Styles } from "../../Styles";
|
|
20
|
+
import { type DataImportCommand, type DataMutation } from "../commands/data";
|
|
21
|
+
import type { GraphWriter } from "./graphOps";
|
|
22
|
+
/**
|
|
23
|
+
* Whether a value may be used as a graph-format node id.
|
|
24
|
+
*
|
|
25
|
+
* graph-format accepts a string or a FINITE number and throws `E_INVALID_ID` for anything else
|
|
26
|
+
* (`graph-format/src/ids/node-id-map.ts`). The element is looser: a node id is whatever the
|
|
27
|
+
* configured JMESPath expression returns, which is `null` for a record that does not carry the
|
|
28
|
+
* key at all, and the element has always let such a record through and rendered it. So the id is
|
|
29
|
+
* CHECKED here rather than thrown on -- an unusable id leaves the render object exactly as it is
|
|
30
|
+
* today and keeps it out of the store, which is the one place the id has to be real.
|
|
31
|
+
* @param id - the extracted id
|
|
32
|
+
* @returns true when graph-format will accept it
|
|
33
|
+
*/
|
|
34
|
+
export declare function isStorableId(id: unknown): id is string | number;
|
|
35
|
+
/**
|
|
36
|
+
* Resolve an edge weight: the configured path, then the legacy "value" key, then 1.
|
|
37
|
+
*
|
|
38
|
+
* The second probe exists because the conversion this replaced hard-coded a `value` weight key, so
|
|
39
|
+
* every weighted dataset, fixture and story in this repository carries `value` and nothing carries
|
|
40
|
+
* `weight`. Reading only the configured path would silently re-read all of them as unweighted.
|
|
41
|
+
* The probe is removed once nothing ships a `value` key.
|
|
42
|
+
* @param record - the raw edge record
|
|
43
|
+
* @param path - `config.data.knownFields.edgeWeightPath`; null means "do not look"
|
|
44
|
+
* @returns the weight and which probe produced it
|
|
45
|
+
*/
|
|
46
|
+
export declare function resolveEdgeWeight(record: Record<string | number, unknown>, path: string | null): {
|
|
47
|
+
weight: number;
|
|
48
|
+
source: "path" | "legacy" | "default";
|
|
49
|
+
};
|
|
50
|
+
/** What a caller may say about one `addEdges` call that the configuration does not already say. */
|
|
51
|
+
export interface AddEdgesOptions {
|
|
52
|
+
/** The JMESPath expression naming the source endpoint, overriding the configured one. */
|
|
53
|
+
readonly source?: string;
|
|
54
|
+
/** The JMESPath expression naming the target endpoint, overriding the configured one. */
|
|
55
|
+
readonly target?: string;
|
|
56
|
+
/**
|
|
57
|
+
* What to do with a record naming an ordered pair the graph already holds, overriding
|
|
58
|
+
* `data.knownFields.repeatedEdges` for this call alone.
|
|
59
|
+
*
|
|
60
|
+
* The expand-a-node path passes `"first"`, because "fetch the neighbourhood of this node" is a
|
|
61
|
+
* request that legitimately re-supplies edges the graph already has, and the element knows
|
|
62
|
+
* that about its own call site.
|
|
63
|
+
*/
|
|
64
|
+
readonly repeated?: DuplicatePolicy;
|
|
65
|
+
}
|
|
66
|
+
/** An edge the graph already holds, as the host hands it back; the host may carry more. */
|
|
67
|
+
interface KnownEdge {
|
|
68
|
+
/** The edge's index in the builder. */
|
|
69
|
+
readonly edgeIndex: number;
|
|
70
|
+
}
|
|
71
|
+
/** One edge record the store has just taken. */
|
|
72
|
+
export interface StoredEdge {
|
|
73
|
+
/** The raw edge record. */
|
|
74
|
+
readonly record: Record<string | number, unknown>;
|
|
75
|
+
/** The source endpoint id, resolved once for the batch. */
|
|
76
|
+
readonly sourceId: NodeIdType;
|
|
77
|
+
/** The target endpoint id, resolved once for the batch. */
|
|
78
|
+
readonly targetId: NodeIdType;
|
|
79
|
+
/** The edge's index in the builder. */
|
|
80
|
+
readonly edgeIndex: number;
|
|
81
|
+
/** The counter the store stamped into this edge's id column. */
|
|
82
|
+
readonly edgeId: number;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* What ingest needs from whoever draws the graph.
|
|
86
|
+
*
|
|
87
|
+
* Every question about an edge the graph already holds comes here because the host is what knows
|
|
88
|
+
* both halves of it: an edge with a render object and an edge still waiting for its endpoints. A
|
|
89
|
+
* repeat policy has to be able to reach both -- a `sum` that ignored a waiting edge would lose a
|
|
90
|
+
* weight, and a `first` that ignored it would create the second edge it exists to prevent.
|
|
91
|
+
* @template K - the host's own description of an existing edge
|
|
92
|
+
*/
|
|
93
|
+
export interface IngestHost<K extends KnownEdge> {
|
|
94
|
+
/** The store records are written into; asked each time, because clearing replaces it. */
|
|
95
|
+
store(): GraphStore;
|
|
96
|
+
/** The data configuration; asked each time, because the element edits it in place. */
|
|
97
|
+
dataConfig(): Styles["config"]["data"];
|
|
98
|
+
/** Whether a node with this id is already held, so a re-supplied node is skipped. */
|
|
99
|
+
hasNode(id: NodeIdType): boolean;
|
|
100
|
+
/** How many nodes are held, for the ceiling. */
|
|
101
|
+
nodeCount(): number;
|
|
102
|
+
/** Every edge between one ordered pair, oldest first. */
|
|
103
|
+
edgesBetween(sourceId: NodeIdType, targetId: NodeIdType): readonly K[];
|
|
104
|
+
/** The edge occupying one store row, or null. */
|
|
105
|
+
edgeAt(edgeIndex: number): K | null;
|
|
106
|
+
/** Replace the attributes an existing edge carries (the `last` repeat policy). */
|
|
107
|
+
replaceEdgeRecord(known: K, record: Record<string | number, unknown>): void;
|
|
108
|
+
/** A node the store has just taken; `index` is `INVALID_INDEX` for an id it will not hold. */
|
|
109
|
+
nodeStored(id: NodeIdType, record: Record<string | number, unknown>, index: number): void;
|
|
110
|
+
/** An edge the store has just taken. */
|
|
111
|
+
edgeStored(edge: StoredEdge): void;
|
|
112
|
+
/** Rows have been removed from the store; whatever draws them goes. */
|
|
113
|
+
rowsRemoved(nodes: readonly NodeIdType[], edges: readonly EdgeId[]): void;
|
|
114
|
+
/** The graph has been emptied. */
|
|
115
|
+
cleared(): void;
|
|
116
|
+
/** A non-empty batch of node records has been ingested. */
|
|
117
|
+
nodesArrived(count: number): void;
|
|
118
|
+
/** A non-empty batch of edge records has been ingested. */
|
|
119
|
+
edgesArrived(count: number): void;
|
|
120
|
+
/** A chunk of a load has been ingested. */
|
|
121
|
+
loadProgress(progress: LoadProgress): void;
|
|
122
|
+
/** A load finished and its source counted errors along the way. */
|
|
123
|
+
loadErrors(format: string, errors: ErrorAggregator): void;
|
|
124
|
+
/** A load finished. */
|
|
125
|
+
loadComplete(format: string, report: ImportReport, progress: LoadProgress, duration: number, errors: number): void;
|
|
126
|
+
/** A load failed after `progress.chunks` chunks. */
|
|
127
|
+
loadFailed(format: string, error: Error, progress: LoadProgress): void;
|
|
128
|
+
}
|
|
129
|
+
/** How far a load has got. */
|
|
130
|
+
interface LoadProgress {
|
|
131
|
+
/** The data source being read. */
|
|
132
|
+
readonly format: string;
|
|
133
|
+
/** The file size the caller passed, when it passed one. */
|
|
134
|
+
readonly fileSize: number | undefined;
|
|
135
|
+
/** Node RECORDS the source has handed over so far. */
|
|
136
|
+
readonly nodeRecords: number;
|
|
137
|
+
/** Edge RECORDS the source has handed over so far. */
|
|
138
|
+
readonly edgeRecords: number;
|
|
139
|
+
/** Chunks ingested so far. */
|
|
140
|
+
readonly chunks: number;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Turns node and edge records, and whole data sources, into the graph a host holds.
|
|
144
|
+
*
|
|
145
|
+
* One per graph. It keeps what outlives a single call: the record identifiers already seen, the
|
|
146
|
+
* last import report, and -- while a load is in progress -- the load's tally and the endpoint
|
|
147
|
+
* spelling its first edge chunk settled on.
|
|
148
|
+
* @template K - the host's own description of an existing edge
|
|
149
|
+
*/
|
|
150
|
+
export declare class Ingest<K extends KnownEdge> {
|
|
151
|
+
private readonly host;
|
|
152
|
+
private readonly logger;
|
|
153
|
+
/**
|
|
154
|
+
* The store edge index each record identifier has already produced, when
|
|
155
|
+
* `knownFields.edgeIdPath` names one. Empty when it does not, which is the default.
|
|
156
|
+
*/
|
|
157
|
+
private edgesByRecordId;
|
|
158
|
+
/**
|
|
159
|
+
* The endpoint expressions the load in progress resolved, so a chunked load probes ONCE.
|
|
160
|
+
*
|
|
161
|
+
* A file that spells one chunk's edges `source`/`target` and the next chunk's `from`/`to` is a
|
|
162
|
+
* broken file, and letting each chunk decide for itself makes the answer both unreportable and
|
|
163
|
+
* dependent on how the file happened to be split.
|
|
164
|
+
*/
|
|
165
|
+
private loadEndpoints;
|
|
166
|
+
/** The tally the load in progress is counting into, or null outside a load. */
|
|
167
|
+
private loadTally;
|
|
168
|
+
/**
|
|
169
|
+
* Whether a load from a data source is still streaming records in.
|
|
170
|
+
* @returns true between a load's first chunk and its end
|
|
171
|
+
*/
|
|
172
|
+
get loading(): boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Start with no records seen and no report.
|
|
175
|
+
* @param host - what draws the graph, and knows which edges it already holds
|
|
176
|
+
*/
|
|
177
|
+
constructor(host: IngestHost<K>);
|
|
178
|
+
/** Forget everything about the graph that was: called when the host discards its store. */
|
|
179
|
+
reset(): void;
|
|
180
|
+
/**
|
|
181
|
+
* Carry out one `data.apply` mutation.
|
|
182
|
+
* @param mutation - The mutation.
|
|
183
|
+
* @param writer - The command's writer.
|
|
184
|
+
* @param resolve - The id a row is held under, for an id the caller may have spelled
|
|
185
|
+
* differently; the id as given by default.
|
|
186
|
+
*/
|
|
187
|
+
apply(mutation: DataMutation, writer: GraphWriter, resolve?: (target: "node" | "edge", id: NodeIdType) => NodeIdType): void;
|
|
188
|
+
/**
|
|
189
|
+
* Carry out one `data.import`: empty the graph first unless it merges, record where the rows
|
|
190
|
+
* came from, and load them. A source missing its name or its options is recorded and nothing
|
|
191
|
+
* is loaded.
|
|
192
|
+
* @param command - The import.
|
|
193
|
+
* @param writer - The command's writer.
|
|
194
|
+
* @param signal - Fires when the import is cancelled; it stops before the next chunk.
|
|
195
|
+
* @returns Settles once the last chunk is written.
|
|
196
|
+
*/
|
|
197
|
+
importSource(command: DataImportCommand, writer: GraphWriter, signal?: AbortSignal): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Adds multiple nodes to the graph
|
|
200
|
+
* @param nodes - Array of node data objects
|
|
201
|
+
* @param idPath - JMESPath expression to extract node ID from data, or undefined for the
|
|
202
|
+
* configured one
|
|
203
|
+
* @param writer - the graph primitives to write through
|
|
204
|
+
*/
|
|
205
|
+
addNodes(nodes: readonly Record<string | number, unknown>[], idPath: string | undefined, writer: GraphWriter): void;
|
|
206
|
+
/**
|
|
207
|
+
* Add edge records to the graph, resolving their endpoints once for the whole batch.
|
|
208
|
+
*
|
|
209
|
+
* THREE THINGS HAPPEN HERE THAT USED TO HAPPEN ELSEWHERE OR NOT AT ALL.
|
|
210
|
+
*
|
|
211
|
+
* The endpoint spelling is decided once per batch and reported, rather than read from two
|
|
212
|
+
* configured paths whose defaults disagreed with every guide the element ships. A batch whose
|
|
213
|
+
* records answer none of the accepted spellings throws instead of quietly producing a graph
|
|
214
|
+
* with nodes and no edges.
|
|
215
|
+
*
|
|
216
|
+
* A record naming an ordered pair the graph already holds is handed to the repeat policy,
|
|
217
|
+
* which by default KEEPS it as a second edge. It used to be dropped before the store could
|
|
218
|
+
* see it, which is why `statistics().repeatedEdgeCount` has always been zero.
|
|
219
|
+
*
|
|
220
|
+
* A record whose endpoint ids graph-format will not store is REJECTED and counted, rather than
|
|
221
|
+
* becoming a render object with no store row -- which is how an edge ended up permanently
|
|
222
|
+
* visible and unfilterable.
|
|
223
|
+
* @param edges - Array of edge data objects
|
|
224
|
+
* @param options - the endpoint expressions and the repeat policy for this call
|
|
225
|
+
* @param writer - the graph primitives to write through
|
|
226
|
+
* @throws A `GraphtyError` with `E_EDGE_ENDPOINTS_UNRESOLVED` when no spelling answers, and
|
|
227
|
+
* with `E_DUPLICATE_EDGE` under the `"error"` repeat policy.
|
|
228
|
+
*/
|
|
229
|
+
addEdges(edges: readonly Record<string | number, unknown>[], options: AddEdgesOptions | undefined, writer: GraphWriter): void;
|
|
230
|
+
/**
|
|
231
|
+
* Refuse a replacement node set the renderer cannot hold, before the caller removes anything:
|
|
232
|
+
* the node half of {@link Ingest.refuseReplacement}, counted against an emptied graph.
|
|
233
|
+
* @param nodes - the nodes the graph should hold afterwards
|
|
234
|
+
* @param idPath - where a record's id is; the configured node id path when unset
|
|
235
|
+
* @throws A `GraphtyError` with `E_TOO_LARGE` when the new set is past the ceiling.
|
|
236
|
+
*/
|
|
237
|
+
refuseNodeReplacement(nodes: readonly Record<string | number, unknown>[], idPath?: string): void;
|
|
238
|
+
/**
|
|
239
|
+
* Refuse a replacement edge set the renderer cannot hold, before the caller removes anything.
|
|
240
|
+
*
|
|
241
|
+
* Removing first and letting `addEdges` refuse would leave a host that assigned too many edges
|
|
242
|
+
* with its old edges gone and none of the new ones held, which is neither the graph it had nor
|
|
243
|
+
* the one it asked for. The new batch is counted against an emptied graph, since the old edges
|
|
244
|
+
* are what it replaces; a pending edge, whose endpoints have not arrived, survives the replace.
|
|
245
|
+
* @param edges - the edges the graph should hold afterwards
|
|
246
|
+
* @param replaced - how many held edges the replacement removes
|
|
247
|
+
* @param options - the endpoint expressions and the repeat policy for this call
|
|
248
|
+
* @throws A `GraphtyError` with `E_TOO_LARGE` when the new set is past the ceiling.
|
|
249
|
+
*/
|
|
250
|
+
refuseReplacement(edges: Record<string | number, unknown>[], replaced: number, options?: AddEdgesOptions): void;
|
|
251
|
+
/**
|
|
252
|
+
* The endpoint expressions this batch is read with, resolved once per load rather than once
|
|
253
|
+
* per batch when a load is in progress.
|
|
254
|
+
* @param edges - the batch's records
|
|
255
|
+
* @param options - the caller's overrides, if any
|
|
256
|
+
* @returns the expressions
|
|
257
|
+
*/
|
|
258
|
+
private endpointsFor;
|
|
259
|
+
/**
|
|
260
|
+
* The edge a record repeats, or null when it repeats none.
|
|
261
|
+
* @param sourceId - the source endpoint id
|
|
262
|
+
* @param targetId - the target endpoint id
|
|
263
|
+
* @param recordId - the value of `knownFields.edgeIdPath`, when one is configured
|
|
264
|
+
* @returns the existing edge, or null
|
|
265
|
+
*/
|
|
266
|
+
private knownEdgeFor;
|
|
267
|
+
/**
|
|
268
|
+
* Apply the repeat policy to one record that names an edge the graph already holds.
|
|
269
|
+
* @param known - the edge already present
|
|
270
|
+
* @param record - the repeating record
|
|
271
|
+
* @param weight - the repeating record's resolved weight
|
|
272
|
+
* @param policy - what to do about it
|
|
273
|
+
* @param sourceId - the source endpoint id, for the error message
|
|
274
|
+
* @param targetId - the target endpoint id, for the error message
|
|
275
|
+
* @param tally - the load's counters
|
|
276
|
+
* @param writer - the graph primitives to write through
|
|
277
|
+
* @returns true when the repeat has been dealt with and must not become an edge of its own
|
|
278
|
+
* @throws A `GraphtyError` with `E_DUPLICATE_EDGE` under the `"error"` policy.
|
|
279
|
+
*/
|
|
280
|
+
private mergeRepeat;
|
|
281
|
+
/**
|
|
282
|
+
* How many edges a batch would add, by the same tests the ingest loop applies.
|
|
283
|
+
*
|
|
284
|
+
* A record whose endpoint ids graph-format will not store adds nothing (the loop rejects it).
|
|
285
|
+
* Under the `keep` policy every other record is an edge. Under a folding policy a record that
|
|
286
|
+
* repeats an edge the graph holds, or a record earlier in the same batch, folds into it and
|
|
287
|
+
* adds nothing; a repeat is named the way `knownEdgeFor` names it, by record id when one is
|
|
288
|
+
* configured and stored, else by the ordered endpoint pair.
|
|
289
|
+
* @param edges - the batch
|
|
290
|
+
* @param endpoints - the batch's endpoint expressions
|
|
291
|
+
* @param policy - the repeat policy the batch is under
|
|
292
|
+
* @param replacing - true when every held edge is about to be removed, so none of them can be
|
|
293
|
+
* repeated
|
|
294
|
+
* @returns the number of edges the batch would add
|
|
295
|
+
*/
|
|
296
|
+
private edgesAdded;
|
|
297
|
+
/**
|
|
298
|
+
* Adopt the direction a file declared, and say out loud when the element could not.
|
|
299
|
+
*
|
|
300
|
+
* The element reports the direction its DATA declares, so that a file which says it is
|
|
301
|
+
* undirected is not counted, measured or offered algorithms as though it were a digraph. What
|
|
302
|
+
* it must never do is overrule the consumer: `data.directed` set to a boolean settles the
|
|
303
|
+
* question and locks the builder, and this reports that rather than fighting it.
|
|
304
|
+
* @param type - the data source type, for the log line
|
|
305
|
+
* @param declaration - what the file said, or null when it said nothing
|
|
306
|
+
* @param writer - the graph primitives to write through
|
|
307
|
+
* @returns true once the question is settled and need not be asked again this import; false
|
|
308
|
+
* while the source has still declared nothing
|
|
309
|
+
*/
|
|
310
|
+
private applyDeclaredDirection;
|
|
311
|
+
/**
|
|
312
|
+
* Loads data from a registered data source
|
|
313
|
+
* @param type - Data source type identifier
|
|
314
|
+
* @param opts - Options to pass to the data source
|
|
315
|
+
* @param writer - the graph primitives to write through
|
|
316
|
+
* @param signal - Fires when the load is cancelled; it stops at once, even while the source
|
|
317
|
+
* is still waiting for its next chunk
|
|
318
|
+
* @param replacing - Whether the load replaces the graph, so reading only part of the file
|
|
319
|
+
* is a failure
|
|
320
|
+
*/
|
|
321
|
+
addDataFromSource(type: string, opts: object, writer: GraphWriter, signal?: AbortSignal, replacing?: boolean): Promise<void>;
|
|
322
|
+
/**
|
|
323
|
+
* Freeze one load's counters into the report a consumer reads, and keep it for `lastImport`.
|
|
324
|
+
* @param format - the data source that read the file
|
|
325
|
+
* @param tally - what the load counted
|
|
326
|
+
* @param writer - the graph primitives to write through
|
|
327
|
+
* @returns the report
|
|
328
|
+
*/
|
|
329
|
+
private sealLoad;
|
|
330
|
+
/**
|
|
331
|
+
* What the graph HOLDS right now, as the report and the session's own counts both mean it.
|
|
332
|
+
*
|
|
333
|
+
* Read off the builder rather than off the host's render objects, and that is the whole
|
|
334
|
+
* point: an edge endpoint the file never declared as a node is created by the builder, so it
|
|
335
|
+
* is in the graph and in `session.status.counts.nodes` while having no render `Node`. Counting
|
|
336
|
+
* the render objects made the report say two nodes for a load the session reported three for
|
|
337
|
+
* -- one load, two numbers, disagreeing, which is the defect this report exists to end rather
|
|
338
|
+
* than to repeat one level down.
|
|
339
|
+
* @returns the node and edge counts the graph holds
|
|
340
|
+
*/
|
|
341
|
+
private heldCounts;
|
|
342
|
+
/**
|
|
343
|
+
* Refuse to grow past what the renderer can draw, instead of freezing the tab.
|
|
344
|
+
*
|
|
345
|
+
* WHY A REFUSAL AND NOT A DEGRADED DRAW. The design says that above the render ceiling the
|
|
346
|
+
* element draws a smaller render set, and above `edgesDrawn` it hides edges until the view
|
|
347
|
+
* narrows. Neither exists yet. What exists is a renderer that, past these counts, exhausts
|
|
348
|
+
* the renderer process and produces no further frame -- measured for issue #405 at 18,000
|
|
349
|
+
* nodes / 180,000 edges on an RTX 4070 SUPER, where the renderer process reached 4.7 GB and
|
|
350
|
+
* died while 17,000 / 170,000 loaded in 17 s. Until the degraded draw lands, the honest
|
|
351
|
+
* behaviour at the ceiling is a coded error the consumer can show, so `DEFAULT_LIMITS` is
|
|
352
|
+
* the number the element enforces rather than a number it merely publishes.
|
|
353
|
+
*
|
|
354
|
+
* `E_TOO_LARGE` is the code because the ceiling is a hard limit of this renderer, and the
|
|
355
|
+
* caller's remedy is the one that code names: load a subset.
|
|
356
|
+
* @param of - what is being counted
|
|
357
|
+
* @param held - how many the graph holds already
|
|
358
|
+
* @param adding - how many this call would add
|
|
359
|
+
* @param limit - the most the renderer can draw
|
|
360
|
+
* @throws A `GraphtyError` with `E_TOO_LARGE` when `held + adding` is past the limit
|
|
361
|
+
*/
|
|
362
|
+
private refuseAboveCeiling;
|
|
363
|
+
}
|
|
364
|
+
export {};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Project state: the fixed list of slices that make up a project, and nothing else.
|
|
3
|
+
*
|
|
4
|
+
* Everything a project file would save lives in one of the ten slices below, and a change to a
|
|
5
|
+
* slice is undoable. Anything outside them (camera, hover, selection, a run still computing) is
|
|
6
|
+
* exempt. See design/undo/undo-design.md section 3.
|
|
7
|
+
*
|
|
8
|
+
* The only writer of this state is a `Draft` (`./draft.ts`). The maps are typed read-only here so
|
|
9
|
+
* that no other module can write them; the draft module holds the mutable handles.
|
|
10
|
+
*
|
|
11
|
+
* Nothing here reaches Babylon.js, Lit or the DOM: the session entry point will reach it.
|
|
12
|
+
*/
|
|
13
|
+
import type { CameraState } from "../../camera/types";
|
|
14
|
+
import type { EdgeId, LayoutId, NodeId, RunId, Scope, SetId } from "../../catalog/types";
|
|
15
|
+
import type { AlgorithmRunCommand } from "../planning";
|
|
16
|
+
import type { RunResult } from "../results/types";
|
|
17
|
+
import type { RunRecord } from "../runs/types";
|
|
18
|
+
import type { HeldCaptures } from "../sets/captures";
|
|
19
|
+
import type { ElementSet } from "../sets/types";
|
|
20
|
+
import type { CompiledLayer } from "../styles/Layer";
|
|
21
|
+
import type { RuleTree, TimeWindow } from "../visibility/filter";
|
|
22
|
+
/** One node or edge record as the graph holds it: the attributes it arrived with. */
|
|
23
|
+
export type GraphRecord = Readonly<Record<string | number, unknown>>;
|
|
24
|
+
/**
|
|
25
|
+
* The `graph` slice: an op-log. The topology (rows, endpoints, weights and the builder's columns)
|
|
26
|
+
* lives in the session's `GraphStore`; the slice holds what is keyed by id beside it. Only the
|
|
27
|
+
* graph primitives (`./graphOps.ts`) write it. See design/undo/undo-design.md section 3.4.
|
|
28
|
+
*/
|
|
29
|
+
export interface GraphSlice {
|
|
30
|
+
/** Names one exact row order. Never reissued (see {@link Counter}). */
|
|
31
|
+
readonly token: number;
|
|
32
|
+
/** Names one dataset's coordinate space. Never reissued. */
|
|
33
|
+
readonly epoch: number;
|
|
34
|
+
/** Node records by node id. */
|
|
35
|
+
readonly nodes: ReadonlyMap<NodeId, GraphRecord>;
|
|
36
|
+
/** Edge records by the element-assigned edge id. */
|
|
37
|
+
readonly edges: ReadonlyMap<EdgeId, GraphRecord>;
|
|
38
|
+
/** Graph-level values by name: the import report, graph-level results. */
|
|
39
|
+
readonly values: ReadonlyMap<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* An empty `graph` slice.
|
|
43
|
+
* @param token - Its graph token.
|
|
44
|
+
* @param epoch - Its graph epoch.
|
|
45
|
+
* @returns The slice, frozen; its maps are its own.
|
|
46
|
+
*/
|
|
47
|
+
export declare function emptyGraphSlice(token?: number, epoch?: number): GraphSlice;
|
|
48
|
+
/** The `layout` slice: which layout draws the graph, with what, and in how many dimensions. */
|
|
49
|
+
export interface LayoutChoice {
|
|
50
|
+
/** The catalogue id. */
|
|
51
|
+
readonly id: LayoutId;
|
|
52
|
+
/** The registered engine that draws it; several engines can draw one id. */
|
|
53
|
+
readonly engine: string;
|
|
54
|
+
/** The options it was chosen with. */
|
|
55
|
+
readonly options: Readonly<Record<string, unknown>>;
|
|
56
|
+
/** The one home of the dimension. */
|
|
57
|
+
readonly dimension: "2d" | "3d";
|
|
58
|
+
/**
|
|
59
|
+
* What the layout runs over, canonical, carried from one choice to the next; absent for the
|
|
60
|
+
* whole graph. A scope that resolves to nothing leaves the layout over the whole graph.
|
|
61
|
+
*/
|
|
62
|
+
readonly scope?: Scope;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The `arrangement` slice: node coordinates at rest, copied out of the positions lane. Immutable
|
|
66
|
+
* once taken; see `./arrangement.ts`.
|
|
67
|
+
*/
|
|
68
|
+
export interface ArrangementCapture {
|
|
69
|
+
/** The node ids of the snapshot the coordinates belong to, in row order. */
|
|
70
|
+
readonly ids: readonly NodeId[];
|
|
71
|
+
/** The graph token of that snapshot. */
|
|
72
|
+
readonly token: number;
|
|
73
|
+
/** The graph epoch the coordinates were taken in. */
|
|
74
|
+
readonly epoch: number;
|
|
75
|
+
/** The coordinates, stride 3. */
|
|
76
|
+
readonly coords: Float32Array;
|
|
77
|
+
}
|
|
78
|
+
/** One finished run, as the `runs` slice keeps it. */
|
|
79
|
+
export interface RunEntry {
|
|
80
|
+
/** The command that produced it; the dedupe identity is computed from this. */
|
|
81
|
+
readonly command: AlgorithmRunCommand;
|
|
82
|
+
/** Its run record. */
|
|
83
|
+
readonly record: RunRecord;
|
|
84
|
+
/** Its result, held by reference: a published result is already frozen. */
|
|
85
|
+
readonly result: RunResult;
|
|
86
|
+
/**
|
|
87
|
+
* The token of the execution that produced `result` (design/sets 5.2), minted by a counter no
|
|
88
|
+
* undo rewinds. Absent for a result published by an executor outside the runs API.
|
|
89
|
+
*/
|
|
90
|
+
readonly execution?: string;
|
|
91
|
+
/**
|
|
92
|
+
* What live references held of earlier executions' items when a re-run replaced them
|
|
93
|
+
* (design/sets 5.2), so a layer restored by undo paints from them. Absent when none.
|
|
94
|
+
*/
|
|
95
|
+
readonly held?: HeldCaptures;
|
|
96
|
+
/** Whether auto-apply has painted it. */
|
|
97
|
+
readonly painted: boolean;
|
|
98
|
+
/** Whether its id was derived rather than author-assigned. */
|
|
99
|
+
readonly derived: boolean;
|
|
100
|
+
/** Whether the graph changed while it computed. */
|
|
101
|
+
readonly stale: boolean;
|
|
102
|
+
}
|
|
103
|
+
/** The `visibility` slice. The masks are derived from it, not state. */
|
|
104
|
+
export interface VisibilityState {
|
|
105
|
+
readonly filter: RuleTree | null;
|
|
106
|
+
readonly window: TimeWindow | null;
|
|
107
|
+
readonly showContext: boolean;
|
|
108
|
+
}
|
|
109
|
+
/** The whole project, as readers see it. */
|
|
110
|
+
export interface ProjectState {
|
|
111
|
+
readonly graph: GraphSlice;
|
|
112
|
+
/** The pinned node ids. An op-log slice, written by the graph primitives. */
|
|
113
|
+
readonly pins: ReadonlySet<NodeId>;
|
|
114
|
+
/** One key per leaf of `ProjectConfig`, by dotted path. */
|
|
115
|
+
readonly config: ReadonlyMap<string, unknown>;
|
|
116
|
+
/** Null until a layout is chosen. */
|
|
117
|
+
readonly layout: LayoutChoice | null;
|
|
118
|
+
/** The capture the lane was last sealed into or restored from; null until the first. */
|
|
119
|
+
readonly arrangement: ArrangementCapture | null;
|
|
120
|
+
readonly runs: ReadonlyMap<RunId, RunEntry>;
|
|
121
|
+
/** The frozen, compiled layer stack, index 0 the bottom. */
|
|
122
|
+
readonly styles: readonly CompiledLayer[];
|
|
123
|
+
readonly visibility: VisibilityState;
|
|
124
|
+
/** The kept sets, by id: deep-frozen records. */
|
|
125
|
+
readonly sets: ReadonlyMap<SetId, ElementSet>;
|
|
126
|
+
/** Saved camera views, by name. */
|
|
127
|
+
readonly views: ReadonlyMap<string, CameraState>;
|
|
128
|
+
}
|
|
129
|
+
/** A counter that only ever increases, so a value it issued never names two different things. */
|
|
130
|
+
interface Counter {
|
|
131
|
+
/** @returns A value this counter has never returned before. */
|
|
132
|
+
next(): number;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Make a never-reissuing counter.
|
|
136
|
+
* @returns A counter whose first value is 1.
|
|
137
|
+
*/
|
|
138
|
+
export declare function createCounter(): Counter;
|
|
139
|
+
/**
|
|
140
|
+
* The state a session starts from: its baseline. History begins after it.
|
|
141
|
+
* @param init - Slices that start with something other than their empty value.
|
|
142
|
+
* @returns A fresh state. The slice maps are owned by it; pass copies if you keep yours.
|
|
143
|
+
*/
|
|
144
|
+
export declare function createProjectState(init?: Partial<ProjectState>): ProjectState;
|
|
145
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Strict state: extra checks that project state is only ever changed through the
|
|
3
|
+
* dispatcher, switched on in the element's own tests and by anyone who wants them.
|
|
4
|
+
*
|
|
5
|
+
* The switch is the global `globalThis.__GRAPHTY_STRICT_STATE__ = true`, set before a session is
|
|
6
|
+
* created. A global rather than an environment variable, because browsers have no `process` and
|
|
7
|
+
* the published bundle must not touch it. In Node, `GRAPHTY_STRICT_STATE=1` works too; it is
|
|
8
|
+
* read through `globalThis.process`, so where there is none nothing throws. See
|
|
9
|
+
* design/undo/undo-design.md section 12.1.
|
|
10
|
+
*/
|
|
11
|
+
import { GraphtyError } from "../../errors/GraphtyError";
|
|
12
|
+
/**
|
|
13
|
+
* Whether strict state is on. Read once per store, when it is created.
|
|
14
|
+
* @returns True when the global or, in Node, the environment variable asks for it.
|
|
15
|
+
*/
|
|
16
|
+
export declare function strictStateEnabled(): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The error a failed strict check throws: a broken invariant, so a bug in the element.
|
|
19
|
+
* @param what - What was found, as a sentence fragment.
|
|
20
|
+
* @returns The error, to throw.
|
|
21
|
+
*/
|
|
22
|
+
export declare function strictViolation(what: string): GraphtyError;
|
|
23
|
+
/**
|
|
24
|
+
* Strict: an op-log key (a node or edge id, or a whole `graph` or `pins` slice) being acquired by
|
|
25
|
+
* one open group must not already be held by another, because an op-log cannot hand a key over.
|
|
26
|
+
* @param key - The key being acquired.
|
|
27
|
+
* @param holder - The label of the other open group holding it, or null when none does.
|
|
28
|
+
*/
|
|
29
|
+
export declare function checkSoleHolder(key: string, holder: string | null): void;
|
|
30
|
+
/**
|
|
31
|
+
* Strict: a command dispatched inline through a group-tagged facade touches only keys that are
|
|
32
|
+
* free or held by its own group (design section 4.5).
|
|
33
|
+
* @param op - The inline command's op.
|
|
34
|
+
* @param key - The op-log key another group holds.
|
|
35
|
+
* @param holder - The label of that group.
|
|
36
|
+
*/
|
|
37
|
+
export declare function checkInlineKey(op: string, key: string, holder: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Strict: note a typed array state has just come to keep. Typed arrays cannot be frozen, so its
|
|
40
|
+
* bytes are summed now, and a later check that finds them changed names what holds it. Nothing
|
|
41
|
+
* happens when strict state is off, or for an array already noted.
|
|
42
|
+
* @param array - The array.
|
|
43
|
+
* @param what - What holds it, as a noun phrase naming the slice.
|
|
44
|
+
* @param holder - The object whose state keeps it (a store, an arrangement), whose dispatcher
|
|
45
|
+
* checks it at each dispatch; absent, every dispatch checks it.
|
|
46
|
+
*/
|
|
47
|
+
export declare function retainArray(array: ArrayBufferView, what: string, holder?: object): void;
|
|
48
|
+
/**
|
|
49
|
+
* Strict: check the retained arrays still alive: the ones the given holders' state keeps, as each
|
|
50
|
+
* dispatch does, or every one, as the test setup does after each test.
|
|
51
|
+
* @param holders - The holders whose arrays to check, beside the shared ones; every array when
|
|
52
|
+
* absent.
|
|
53
|
+
*/
|
|
54
|
+
export declare function verifyRetainedArrays(holders?: readonly (object | null)[]): void;
|
|
55
|
+
/**
|
|
56
|
+
* Strict: the graph store's builder was changed by something other than the graph primitives.
|
|
57
|
+
* @param count - How many mutations nobody accounted for.
|
|
58
|
+
* @returns The error, to throw.
|
|
59
|
+
*/
|
|
60
|
+
export declare function builderDrift(count: number): GraphtyError;
|
|
61
|
+
/**
|
|
62
|
+
* Hand an error the element caught and carried on past -- the render loop's catch, a lane hook
|
|
63
|
+
* that reports and goes on -- to whoever is watching: the element's own tests install
|
|
64
|
+
* `globalThis.__GRAPHTY_CAUGHT__` and fail the test it happened in. Nothing is installed in
|
|
65
|
+
* production, so this does nothing there.
|
|
66
|
+
* @param error - What was caught.
|
|
67
|
+
*/
|
|
68
|
+
export declare function reportCaught(error: unknown): void;
|
|
@@ -85,6 +85,26 @@ export interface RunResultInit {
|
|
|
85
85
|
/** The plain-language generator, when one is installed. */
|
|
86
86
|
readonly reading?: ResultReadingGenerator;
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Where each element of one half sits: position to id, and id to position. A graph-format node id
|
|
90
|
+
* map is one, which is what lets a result share the snapshot's instead of building its own.
|
|
91
|
+
*/
|
|
92
|
+
interface ResultIdIndex {
|
|
93
|
+
/** How many elements it holds. */
|
|
94
|
+
readonly size: number;
|
|
95
|
+
/**
|
|
96
|
+
* The id at a position.
|
|
97
|
+
* @param position - The position, from 0 to `size - 1`.
|
|
98
|
+
* @returns The id.
|
|
99
|
+
*/
|
|
100
|
+
idOf(position: number): NodeId;
|
|
101
|
+
/**
|
|
102
|
+
* The position of an id, by SameValueZero.
|
|
103
|
+
* @param id - The id.
|
|
104
|
+
* @returns The position, or a number outside `[0, size)` when it holds no such id.
|
|
105
|
+
*/
|
|
106
|
+
indexOf(id: NodeId): number;
|
|
107
|
+
}
|
|
88
108
|
/**
|
|
89
109
|
* Build the result a run publishes.
|
|
90
110
|
*
|
|
@@ -97,4 +117,32 @@ export interface RunResultInit {
|
|
|
97
117
|
* @returns The result, immutable.
|
|
98
118
|
*/
|
|
99
119
|
export declare function createRunResult(init: RunResultInit): RunResult;
|
|
120
|
+
/** One id index a result reads through, as the undo history charges for it. */
|
|
121
|
+
interface RetainedIndex {
|
|
122
|
+
/** The index object: charged once however many results share it. */
|
|
123
|
+
readonly index: object;
|
|
124
|
+
/** The graph token of the snapshot it belongs to, or null when the result owns it. */
|
|
125
|
+
readonly token: number | null;
|
|
126
|
+
/** What it costs, estimated. */
|
|
127
|
+
readonly bytes: number;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* What a result retains: its columns and caches, and the id indexes it reads through. The
|
|
131
|
+
* indexes are apart because whether one costs anything depends on what else is alive: one shared
|
|
132
|
+
* with the resident snapshot costs nothing extra (design/undo/undo-design.md section 7).
|
|
133
|
+
* @param result - The result; one this module did not build retains nothing it can see.
|
|
134
|
+
* @returns The bytes and the indexes.
|
|
135
|
+
*/
|
|
136
|
+
export declare function retentionOf(result: RunResult): {
|
|
137
|
+
readonly bytes: number;
|
|
138
|
+
readonly indexes: readonly RetainedIndex[];
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Let a result read its nodes through a snapshot's id index, dropping its own, when the two hold
|
|
142
|
+
* the same ids in the same order. Nothing observable changes.
|
|
143
|
+
* @param result - The result.
|
|
144
|
+
* @param index - The snapshot's node id index.
|
|
145
|
+
* @param token - The graph token of that snapshot.
|
|
146
|
+
*/
|
|
147
|
+
export declare function shareNodeIndex(result: RunResult, index: ResultIdIndex, token: number): void;
|
|
100
148
|
export {};
|
|
@@ -182,6 +182,26 @@ export interface RankableEntry {
|
|
|
182
182
|
* @returns The ranking, best first. Entries with no finite value are left out.
|
|
183
183
|
*/
|
|
184
184
|
export declare function rankEntries(entries: readonly RankableEntry[]): readonly RankingEntry[];
|
|
185
|
+
/**
|
|
186
|
+
* The order {@link rankEntries} ranks in, as positions: best first, ties in printed-id order,
|
|
187
|
+
* elements with no finite value left out. Four bytes per ranked element, so a result can keep one
|
|
188
|
+
* per field instead of an object per element.
|
|
189
|
+
* @param length - How many positions there are.
|
|
190
|
+
* @param valueAt - The value at a position.
|
|
191
|
+
* @param idAt - The id at a position.
|
|
192
|
+
* @returns The ranked positions, best first.
|
|
193
|
+
*/
|
|
194
|
+
export declare function rankOrder(length: number, valueAt: (position: number) => number, idAt: (position: number) => NodeId): Uint32Array;
|
|
195
|
+
/**
|
|
196
|
+
* The first entries of a ranking, built from its order. Ties share a rank: the next distinct
|
|
197
|
+
* value takes the rank its place implies, so ranks run 1, 2, 2, 4.
|
|
198
|
+
* @param order - The ranked positions, from {@link rankOrder}.
|
|
199
|
+
* @param count - How many entries to build, at most `order.length`.
|
|
200
|
+
* @param valueAt - The value at a position.
|
|
201
|
+
* @param idAt - The id at a position.
|
|
202
|
+
* @returns The entries, best first, frozen.
|
|
203
|
+
*/
|
|
204
|
+
export declare function rankedPrefix(order: Uint32Array, count: number, valueAt: (position: number) => number, idAt: (position: number) => NodeId): readonly RankingEntry[];
|
|
185
205
|
/**
|
|
186
206
|
* The top `n` of a ranking, cut only between tie groups. See {@link TopRanking} for the policy.
|
|
187
207
|
* @param ranking - The ranking, best first, with tied entries sharing a rank.
|