@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
|
@@ -38,14 +38,23 @@
|
|
|
38
38
|
* setting this same window and summarising what it left visible, and playback is a cursor over
|
|
39
39
|
* that list calling `setWindow` per step. Nothing about the masks needs to change for either.
|
|
40
40
|
*
|
|
41
|
+
* THE FILTER, THE WINDOW AND THE CONTEXT FLAG ARE PROJECT STATE; THE MASKS ARE NOT. The three
|
|
42
|
+
* values live in the session's `visibility` slice and change only through the `visibility.*`
|
|
43
|
+
* commands, so each change is one undoable step. The masks are derived from them and the graph,
|
|
44
|
+
* and are brought up to date on the derivation lane or on the next read, whichever is first.
|
|
45
|
+
* Undoing to a filter step whose masks were kept (a mask copy) puts the kept bytes back instead of
|
|
46
|
+
* evaluating the filter again. See design/undo/undo-design.md section 3.4.
|
|
47
|
+
*
|
|
41
48
|
* Nothing here reaches Babylon.js, Lit or the DOM.
|
|
42
49
|
*/
|
|
43
50
|
import { type GraphSnapshot } from "@graphty/graph-format";
|
|
44
51
|
import type { EdgeId, NodeId, Path, Scope } from "../../catalog/types";
|
|
45
|
-
import {
|
|
52
|
+
import { Dispatcher } from "../project/Dispatcher";
|
|
53
|
+
import { type EngineVersions, type ResolvedScope, type Run, type RunOptions } from "../runs";
|
|
46
54
|
import { type ScopeVisibilitySource } from "../scope/index";
|
|
47
55
|
import { type DependencySources } from "../sets/dependencies";
|
|
48
56
|
import type { SetWatch } from "../sets/notify";
|
|
57
|
+
import type { HistoryCause } from "../types";
|
|
49
58
|
import { type FilterSources, type RuleTree, type TimeWindow } from "./filter";
|
|
50
59
|
/**
|
|
51
60
|
* How much of the graph is showing, which is what a status bar reads.
|
|
@@ -101,6 +110,8 @@ export interface FilterResult {
|
|
|
101
110
|
export interface VisibilityChange extends FilterResult {
|
|
102
111
|
/** What produced this change. */
|
|
103
112
|
readonly filterKind: string;
|
|
113
|
+
/** Whether an edit, an undo, a redo, a restore or a rolled-back transaction made it. */
|
|
114
|
+
readonly cause: HistoryCause;
|
|
104
115
|
}
|
|
105
116
|
/** Hiding part of the graph, and saying how much is left. */
|
|
106
117
|
export interface VisibilityApi {
|
|
@@ -151,17 +162,20 @@ export interface VisibilityApi {
|
|
|
151
162
|
/**
|
|
152
163
|
* Apply a filter, or clear it with null.
|
|
153
164
|
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
165
|
+
* One undoable step: the filter is recorded at once (`filter` reads it as soon as this
|
|
166
|
+
* returns), and the masks are evaluated on the next pass against whatever filter is in force
|
|
167
|
+
* then, so a slider dragged through sixty values evaluates the last one, not all sixty, and
|
|
168
|
+
* the drag is one step. The run settles once that pass has run, with the counts it left.
|
|
169
|
+
*
|
|
170
|
+
* A signal already aborted when this is called writes nothing. A `cancel()` or an abort after
|
|
171
|
+
* the call does NOT take the filter back -- it has been recorded, and may have merged into a
|
|
172
|
+
* larger step -- so `session.undo()` is the way back.
|
|
158
173
|
*
|
|
159
174
|
* The time window is untouched. The two compose.
|
|
160
175
|
*
|
|
161
|
-
* Of the run options, `signal` and `onProgress` are honoured; `queue` is not,
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
* showing" without doing it.
|
|
176
|
+
* Of the run options, `signal` and `onProgress` are honoured; `queue` is not, and `dryRun` is
|
|
177
|
+
* REFUSED rather than ignored -- `plan({ op: "visibility.set", filter })` is the call that
|
|
178
|
+
* answers "what would this leave showing" without doing it.
|
|
165
179
|
* @param filter - What to keep, or null to stop filtering.
|
|
166
180
|
* @param options - A signal to cancel with, and a progress handler.
|
|
167
181
|
* @returns The run, which resolves with the counts.
|
|
@@ -169,7 +183,8 @@ export interface VisibilityApi {
|
|
|
169
183
|
*/
|
|
170
184
|
set(filter: RuleTree | null, options?: RunOptions): Run<FilterResult>;
|
|
171
185
|
/**
|
|
172
|
-
* Apply a time window, or clear it with null
|
|
186
|
+
* Apply a time window, or clear it with null: one undoable step, on the same terms as
|
|
187
|
+
* {@link VisibilityApi.set}.
|
|
173
188
|
*
|
|
174
189
|
* The SAME masks as {@link VisibilityApi.set}, produced the same way, composed with whatever
|
|
175
190
|
* filter is in force. Moving the window never re-layouts, rebuilds or removes data, which is
|
|
@@ -188,7 +203,8 @@ export interface VisibilityApi {
|
|
|
188
203
|
* hid. The flag is owned here because it is part of what "visible" means to a consumer, and
|
|
189
204
|
* it is honoured by the renderer, which draws the hidden nodes as a low-alpha point layer.
|
|
190
205
|
* Turning it on changes NOTHING about the masks: a context node is still hidden, still
|
|
191
|
-
* outside every run's default scope, and still absent from `nodes`.
|
|
206
|
+
* outside every run's default scope, and still absent from `nodes`. Changing it is one
|
|
207
|
+
* undoable step.
|
|
192
208
|
*/
|
|
193
209
|
showContext: boolean;
|
|
194
210
|
}
|
|
@@ -201,7 +217,10 @@ export interface VisibilityApi {
|
|
|
201
217
|
* anything.
|
|
202
218
|
*/
|
|
203
219
|
export interface SessionVisibilityApi extends VisibilityApi {
|
|
204
|
-
/**
|
|
220
|
+
/**
|
|
221
|
+
* The masks, for the scope resolver and the renderer: read-only copies carrying the live
|
|
222
|
+
* masks' `version`, one per membership, so nothing holding one can change what is visible.
|
|
223
|
+
*/
|
|
205
224
|
readonly masks: ScopeVisibilitySource;
|
|
206
225
|
}
|
|
207
226
|
/** Everything the visibility model is built from. */
|
|
@@ -217,11 +236,10 @@ export interface VisibilitySources extends FilterSources {
|
|
|
217
236
|
*/
|
|
218
237
|
snapshot(): GraphSnapshot;
|
|
219
238
|
/**
|
|
220
|
-
* The
|
|
221
|
-
*
|
|
222
|
-
* the element's own operation queue so that a filter does not interleave with a load.
|
|
239
|
+
* The dispatcher whose `visibility` slice holds the filter, the window and the context flag.
|
|
240
|
+
* Absent, the model makes one of its own.
|
|
223
241
|
*/
|
|
224
|
-
readonly
|
|
242
|
+
readonly dispatcher?: Dispatcher;
|
|
225
243
|
/**
|
|
226
244
|
* Resolve a scope specification, so a pass can record what it looked at.
|
|
227
245
|
*
|
|
@@ -234,7 +252,9 @@ export interface VisibilitySources extends FilterSources {
|
|
|
234
252
|
/** Which versions are producing the numbers. Defaults to the element's own. */
|
|
235
253
|
readonly engine?: EngineVersions;
|
|
236
254
|
/**
|
|
237
|
-
* Called whenever what is visible changes, so a host can mirror it onto an event
|
|
255
|
+
* Called whenever what is visible changes, so a host can mirror it onto an event: once the
|
|
256
|
+
* pass deriving the change has run, one call per edit, and one per step an undo, a redo or a
|
|
257
|
+
* restore passes.
|
|
238
258
|
*
|
|
239
259
|
* One hook for every producer -- a filter, a window and the context flag all arrive here --
|
|
240
260
|
* because a status bar reading "showing X of Y" has to update for all three and must not
|
|
@@ -291,7 +311,7 @@ interface FilterWatchSources {
|
|
|
291
311
|
* what makes the mask version a usable cache key for everything downstream: a new mask object
|
|
292
312
|
* would start its revision at zero, and a reader keyed on it could not tell a fresh empty mask
|
|
293
313
|
* from the one it had already seen.
|
|
294
|
-
* @param sources - The snapshot, the
|
|
314
|
+
* @param sources - The snapshot, the dispatcher, and the capabilities a filter needs.
|
|
295
315
|
* @returns The visibility model, including the masks the scope resolver reads.
|
|
296
316
|
*/
|
|
297
317
|
export declare function createVisibilityApi(sources: VisibilitySources): SessionVisibilityApi;
|
|
@@ -219,6 +219,16 @@ export interface CompiledVisibility {
|
|
|
219
219
|
* @throws A `GraphtyError` when either is malformed.
|
|
220
220
|
*/
|
|
221
221
|
export declare function assertVisibility(filter: RuleTree | null, window: TimeWindow | null, dependencies?: DependencySources): void;
|
|
222
|
+
/**
|
|
223
|
+
* Refuse a filter or a window this session could not evaluate, without evaluating it: the checks
|
|
224
|
+
* {@link compileVisibility} makes before it walks anything, so a filter is refused before it is
|
|
225
|
+
* recorded rather than on every later evaluation.
|
|
226
|
+
* @param filter - The filter, or null for none.
|
|
227
|
+
* @param window - The time window, or null for none.
|
|
228
|
+
* @param sources - What this session can evaluate with.
|
|
229
|
+
* @throws A `GraphtyError` when either is malformed or needs a capability this session lacks.
|
|
230
|
+
*/
|
|
231
|
+
export declare function assertEvaluable(filter: RuleTree | null, window: TimeWindow | null, sources: FilterSources): void;
|
|
222
232
|
/** One filter's two halves, before they are folded together. */
|
|
223
233
|
export interface CompiledHalves {
|
|
224
234
|
/** The node test, or null when this filter says nothing about nodes. */
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file `defineAlgorithm`: the simple tier's algorithm verb.
|
|
3
|
+
*
|
|
4
|
+
* One plain definition -- an id, options in short form, and ONE function (`node`, `edge`, `nodes`
|
|
5
|
+
* or `groups`) -- becomes an ordinary `DeclaredAlgorithm` subclass registered through
|
|
6
|
+
* `DeclaredAlgorithm.register`. Everything the element does for an advanced algorithm (the
|
|
7
|
+
* catalogue entry, option validation, the run record, derived rankings and styles, progress,
|
|
8
|
+
* cancellation, the cost estimate) it therefore does for this one, and parity holds by
|
|
9
|
+
* construction.
|
|
10
|
+
*
|
|
11
|
+
* What the element fills in: the descriptor (key, names, category "custom", shape and fields from
|
|
12
|
+
* the function), the loop over the nodes or edges with progress, yielding and cancellation, the
|
|
13
|
+
* id mapping, the output, unmeasured values, caveats and the cost model.
|
|
14
|
+
*/
|
|
15
|
+
import type { RegisterOptions } from "../catalog/pluginRegistry";
|
|
16
|
+
import type { AlgorithmDefinition, OptionsShorthand } from "./types";
|
|
17
|
+
/** A definition with no options, the default of the verb's generic. */
|
|
18
|
+
type NoOptions = Readonly<Record<never, never>>;
|
|
19
|
+
/**
|
|
20
|
+
* Register an algorithm from a plain definition object.
|
|
21
|
+
* @param definition - The id, the options in short form and ONE of `node`, `edge`, `nodes` or
|
|
22
|
+
* `groups`.
|
|
23
|
+
* @param options - Whether a different algorithm under an id already taken throws instead of
|
|
24
|
+
* replacing it.
|
|
25
|
+
* @throws A GraphtyError E_BAD_COMMAND for a malformed definition, before anything is registered.
|
|
26
|
+
*/
|
|
27
|
+
export declare function defineAlgorithm<const O extends OptionsShorthand = NoOptions>(definition: AlgorithmDefinition<O>, options?: RegisterOptions): void;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file `defineLayout`: the simple tier's layout verb.
|
|
3
|
+
*
|
|
4
|
+
* A definition is an id, options in short form and `place(graph, context)`, which returns a map
|
|
5
|
+
* from node id to `[x, y]` or `[x, y, z]` in scene units. `defineLayout` checks the definition,
|
|
6
|
+
* fills in every catalogue member, and files an ordinary layout engine through the one layout
|
|
7
|
+
* registration there is, `LayoutEngine.register` -- so a simple layout IS an advanced one once
|
|
8
|
+
* registered: same catalogue entry shape, same option checks, same registry, same `setLayout`.
|
|
9
|
+
*
|
|
10
|
+
* What the element does for the author, so the definition never has to:
|
|
11
|
+
* - hands `place` the graph view over the whole graph and checks "attribute" and "node" options
|
|
12
|
+
* against it first, so a misspelt column is refused with the columns the nodes do carry;
|
|
13
|
+
* - positions are scene units, with no hidden multiplier; a 2D position in a 3D view gets z = 0 and
|
|
14
|
+
* a 3D position in a 2D view loses its z;
|
|
15
|
+
* - a node left out of the map, or given null or a non-finite number, is left unplaced;
|
|
16
|
+
* - a pinned or held node stays where it is (the element's position array refuses the write), and
|
|
17
|
+
* `context.fixed(id)` says where it is;
|
|
18
|
+
* - `context.random()` is seeded; `random: true` declares a "seed" option and draws one when the
|
|
19
|
+
* reader gives none;
|
|
20
|
+
* - `context.progress()` yields to the page and rejects once the layout is replaced;
|
|
21
|
+
* - a throw from `place` is `E_EXTENSION_FAILED`, and a map keyed by the wrong kind of id is
|
|
22
|
+
* refused instead of silently placing nothing.
|
|
23
|
+
*/
|
|
24
|
+
import type { RegisterOptions } from "../catalog/pluginRegistry";
|
|
25
|
+
import type { LayoutDefinition, OptionsShorthand } from "./types";
|
|
26
|
+
/** A definition with no options, the default of the verb's generic. */
|
|
27
|
+
type NoOptions = Readonly<Record<never, never>>;
|
|
28
|
+
/**
|
|
29
|
+
* Register a layout from a plain definition object.
|
|
30
|
+
* @param definition - The id, the options in short form, and `place`.
|
|
31
|
+
* @param options - How to register it; `strict` refuses replacing a different layout under the id.
|
|
32
|
+
* @throws A GraphtyError E_BAD_COMMAND for a malformed definition, before anything is registered.
|
|
33
|
+
*/
|
|
34
|
+
export declare function defineLayout<const O extends OptionsShorthand = NoOptions>(definition: LayoutDefinition<O>, options?: RegisterOptions): void;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file `defineLogDestination`: the simple tier's log destination verb.
|
|
3
|
+
*
|
|
4
|
+
* It builds an ordinary `LogSinkRegistration` -- a descriptor derived from the definition and a
|
|
5
|
+
* `create` that returns a `Sink` -- and hands it to `registerLogSink`, the advanced tier's own
|
|
6
|
+
* verb, so the registry cannot tell which tier produced it. Then it attaches one sink under the
|
|
7
|
+
* id, unless the definition says `attach: false`.
|
|
8
|
+
*
|
|
9
|
+
* WHAT THE WRAPPED SINK ADDS. The author's `write` receives a `PlainLogRecord` (the level as a
|
|
10
|
+
* word, the category as one dotted string, the error as plain data). A `write` that returns a
|
|
11
|
+
* promise is queued: records go out one at a time and in order, a rejection or a `Response`
|
|
12
|
+
* whose `ok` is false is retried after 1, 2 and 4 seconds (never a 4xx other than 408 or 429),
|
|
13
|
+
* at most 1000 records wait, `flush` awaits the queue and `dispose` drains it with a timeout.
|
|
14
|
+
* A `write` that returns nothing is called synchronously, exactly as an advanced sink is.
|
|
15
|
+
*
|
|
16
|
+
* THE DELIVERY RULE IS EVERY DESTINATION'S: the destination sits behind the same global gate as
|
|
17
|
+
* every other sink, so while logging is off (the default) it receives nothing.
|
|
18
|
+
* `GraphtyLogger.addSink` and advanced sinks are unchanged: the queue lives in this wrapper only.
|
|
19
|
+
*/
|
|
20
|
+
import type { RegisterOptions } from "../catalog/pluginRegistry";
|
|
21
|
+
import type { LogDestinationDefinition } from "./types";
|
|
22
|
+
/**
|
|
23
|
+
* Register a log destination from a plain definition object, and attach it unless it says
|
|
24
|
+
* `attach: false`.
|
|
25
|
+
* @param definition - The id, the level and categories it takes, and `write`.
|
|
26
|
+
* @param options - Whether a collision with an existing registration throws instead of replacing.
|
|
27
|
+
* @returns A function that detaches the destination.
|
|
28
|
+
* @throws A GraphtyError `E_BAD_COMMAND` naming the member at fault, or `E_DUPLICATE_PLUGIN` for
|
|
29
|
+
* an id the element keeps for its own destinations.
|
|
30
|
+
*/
|
|
31
|
+
export declare function defineLogDestination(definition: LogDestinationDefinition, options?: RegisterOptions): () => void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file `definePalette`: the simple tier's palette verb.
|
|
3
|
+
*
|
|
4
|
+
* It builds an ordinary palette registration and hands it to `registerPalette`, so there is one
|
|
5
|
+
* validation path and one registry: a palette defined here and the same palette registered
|
|
6
|
+
* through the advanced tier are the same catalogue entry. What the element fills in is the plain
|
|
7
|
+
* name (from `name`, else the id in sentence case); `registerPalette` already derives the
|
|
8
|
+
* capacity, normalises every colour to six-digit hex and turns a missing colour-vision claim into
|
|
9
|
+
* no claim.
|
|
10
|
+
*
|
|
11
|
+
* The checks made HERE, before `registerPalette` sees the definition, are the ones whose message
|
|
12
|
+
* a beginner needs worded for the call they wrote: every refusal starts `definePalette("id"): `,
|
|
13
|
+
* and a `var(...)` colour or an empty string (a design token read before its stylesheet loaded)
|
|
14
|
+
* is refused with the line that reads the token first.
|
|
15
|
+
*/
|
|
16
|
+
import type { RegisterOptions } from "../catalog/pluginRegistry";
|
|
17
|
+
import type { PaletteDefinition } from "./types";
|
|
18
|
+
/**
|
|
19
|
+
* Register a palette from a kind and a list of colours.
|
|
20
|
+
* @param definition - The id, the kind, the colours, and optionally a name, a description and a
|
|
21
|
+
* colour-vision claim.
|
|
22
|
+
* @param options - Whether a collision with an existing registration throws instead of replacing.
|
|
23
|
+
* @throws A `GraphtyError` with `E_BAD_COMMAND` naming the member at fault, or with
|
|
24
|
+
* `E_DUPLICATE_PLUGIN` when the id is one of the element's own palettes.
|
|
25
|
+
*/
|
|
26
|
+
export declare function definePalette(definition: PaletteDefinition, options?: RegisterOptions): void;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file What every `define*` function of the simple tier shares: checking the definition object
|
|
3
|
+
* before anything is registered, the names the element derives from an id, and the errors a
|
|
4
|
+
* beginner reads (design/extensions/simple-tier.md sections 2.1 and 2.4).
|
|
5
|
+
*
|
|
6
|
+
* A person following the guide reads the first line of an error and searches for it, so every
|
|
7
|
+
* message here starts with the call and the id (`defineLayout("acme-tiers"): ...`) or the id and
|
|
8
|
+
* the member at fault (`acme-tiers: place() threw for node 42 ...`), says what was expected in
|
|
9
|
+
* the words of the definition the author wrote, and names no internal concept.
|
|
10
|
+
*
|
|
11
|
+
* Nothing here reaches Babylon.js, Lit or the DOM.
|
|
12
|
+
*/
|
|
13
|
+
import { GraphtyError, type GraphtyErrorSource } from "../errors";
|
|
14
|
+
/** The four verbs of the simple tier graphty-element builds. */
|
|
15
|
+
export type SimpleVerb = "defineAlgorithm" | "defineLayout" | "definePalette" | "defineLogDestination";
|
|
16
|
+
/**
|
|
17
|
+
* A value as a message describes it: what the author actually passed.
|
|
18
|
+
* @param value - The value.
|
|
19
|
+
* @returns A few words, such as `undefined`, `the number 3` or `a function`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function describeValue(value: unknown): string;
|
|
22
|
+
/**
|
|
23
|
+
* The refusal of a malformed definition: `E_BAD_COMMAND`, thrown by the `define*` call itself.
|
|
24
|
+
* @param verb - The call, such as "defineLayout".
|
|
25
|
+
* @param id - The definition's id, when it has a usable one.
|
|
26
|
+
* @param field - The member at fault, such as "place" or "options.tier".
|
|
27
|
+
* @param message - What was expected and what was given, as a sentence.
|
|
28
|
+
* @returns The error.
|
|
29
|
+
*/
|
|
30
|
+
export declare function badDefinition(verb: SimpleVerb, id: string | undefined, field: string, message: string): GraphtyError;
|
|
31
|
+
/** A definition that has passed the shared checks: an object with a usable id. */
|
|
32
|
+
type CheckedDefinition = Readonly<Record<string, unknown>> & {
|
|
33
|
+
readonly id: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Check what every definition shares: it is an object, and its id is a usable permanent id.
|
|
37
|
+
* The optional `name`, `description` and `version`, when present, must be strings.
|
|
38
|
+
* @param verb - The call.
|
|
39
|
+
* @param definition - What the author passed.
|
|
40
|
+
* @returns The definition, narrowed.
|
|
41
|
+
*/
|
|
42
|
+
export declare function checkDefinition(verb: SimpleVerb, definition: unknown): CheckedDefinition;
|
|
43
|
+
/**
|
|
44
|
+
* Refuse a member that is not a function.
|
|
45
|
+
* @param verb - The call.
|
|
46
|
+
* @param definition - The checked definition.
|
|
47
|
+
* @param field - The member.
|
|
48
|
+
*/
|
|
49
|
+
export declare function requireFunction(verb: SimpleVerb, definition: CheckedDefinition, field: string): void;
|
|
50
|
+
/**
|
|
51
|
+
* Refuse a member that is present and not one of a list of values.
|
|
52
|
+
* @param verb - The call.
|
|
53
|
+
* @param definition - The checked definition.
|
|
54
|
+
* @param field - The member.
|
|
55
|
+
* @param allowed - The values it may take.
|
|
56
|
+
*/
|
|
57
|
+
export declare function optionalOneOf(verb: SimpleVerb, definition: CheckedDefinition, field: string, allowed: readonly (string | number | boolean)[]): void;
|
|
58
|
+
/**
|
|
59
|
+
* A key or an id in sentence case, for a name nobody wrote: "tierAttribute" reads "Tier
|
|
60
|
+
* attribute", "acme-hop-reach" reads "Acme hop reach".
|
|
61
|
+
* @param key - The key or id.
|
|
62
|
+
* @returns The words.
|
|
63
|
+
*/
|
|
64
|
+
export declare function sentenceCase(key: string): string;
|
|
65
|
+
/**
|
|
66
|
+
* What pickers show for a definition: its `name`, or its id in sentence case.
|
|
67
|
+
* @param definition - The checked definition.
|
|
68
|
+
* @returns The name.
|
|
69
|
+
*/
|
|
70
|
+
export declare function displayName(definition: CheckedDefinition): string;
|
|
71
|
+
/** Who was running when the author's own function threw. */
|
|
72
|
+
interface AuthorCall {
|
|
73
|
+
/** The extension's id. */
|
|
74
|
+
readonly id: string;
|
|
75
|
+
/** The member of the definition that was called, such as "edge" or "place". */
|
|
76
|
+
readonly member: string;
|
|
77
|
+
/** What it was called for, worded for the message: `node 42`, `edge "17"`. Optional. */
|
|
78
|
+
readonly subject?: string;
|
|
79
|
+
/** Which area of the element the failure belongs to. */
|
|
80
|
+
readonly source: GraphtyErrorSource;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The error a throw from the author's own function becomes: `E_EXTENSION_FAILED`, never
|
|
84
|
+
* `E_INTERNAL`, which would tell the reader to file an issue against graphty-element.
|
|
85
|
+
* @param call - Who was running.
|
|
86
|
+
* @param cause - What the function threw.
|
|
87
|
+
* @returns The error, carrying the original as `cause`.
|
|
88
|
+
*/
|
|
89
|
+
export declare function extensionFailed(call: AuthorCall, cause: unknown): GraphtyError;
|
|
90
|
+
/**
|
|
91
|
+
* Call the author's function, turning a throw into `E_EXTENSION_FAILED`. A `GraphtyError` passes
|
|
92
|
+
* through unchanged: it is already coded, and it may be the element's own refusal raised from
|
|
93
|
+
* inside the call (a path nothing carries, a directed accessor on an undirected view).
|
|
94
|
+
* @param call - Who is running.
|
|
95
|
+
* @param work - The call.
|
|
96
|
+
* @returns What the function returned.
|
|
97
|
+
*/
|
|
98
|
+
export declare function callAuthor<T>(call: AuthorCall, work: () => T): T;
|
|
99
|
+
/**
|
|
100
|
+
* {@link callAuthor} for a function that may return a promise.
|
|
101
|
+
* @param call - Who is running.
|
|
102
|
+
* @param work - The call.
|
|
103
|
+
* @returns What the function returned, awaited.
|
|
104
|
+
*/
|
|
105
|
+
export declare function callAuthorAsync<T>(call: AuthorCall, work: () => T | Promise<T>): Promise<T>;
|
|
106
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Options in short form, and the checks a run or a layout makes on them before the author's
|
|
3
|
+
* code runs (design/extensions/simple-tier.md section 2.2).
|
|
4
|
+
*
|
|
5
|
+
* `options: { tier: { type: "attribute", default: "tier" }, spacing: 2 }` is expanded into the
|
|
6
|
+
* ordinary `OptionDescriptor[]` every advanced extension declares, so the reader's form, the
|
|
7
|
+
* validation, the defaults and the catalogue entry work exactly as for a built-in.
|
|
8
|
+
*
|
|
9
|
+
* Nothing here reaches Babylon.js, Lit or the DOM.
|
|
10
|
+
*/
|
|
11
|
+
import { type OptionDescriptor } from "../catalog/types";
|
|
12
|
+
import { type GraphtyErrorSource } from "../errors";
|
|
13
|
+
import { type SimpleVerb } from "./definition";
|
|
14
|
+
import type { GraphView } from "./types";
|
|
15
|
+
/**
|
|
16
|
+
* Expand a definition's `options` into option descriptors, refusing a malformed entry.
|
|
17
|
+
* @param verb - The call, for the refusal.
|
|
18
|
+
* @param id - The definition's id.
|
|
19
|
+
* @param options - What the definition carried under `options`.
|
|
20
|
+
* @returns The descriptors, in key order.
|
|
21
|
+
*/
|
|
22
|
+
export declare function expandOptions(verb: SimpleVerb, id: string, options: unknown): OptionDescriptor[];
|
|
23
|
+
/**
|
|
24
|
+
* Check the resolved options of one run or layout against the graph before the author's code
|
|
25
|
+
* runs: an "attribute" option must name an attribute some element carries, and a "node-id" or
|
|
26
|
+
* "node-set" option must name nodes the graph has. An unbound option (undefined) is not checked.
|
|
27
|
+
* @param view - The graph view the code will read.
|
|
28
|
+
* @param id - The extension's id.
|
|
29
|
+
* @param descriptors - The declared options.
|
|
30
|
+
* @param values - The resolved values.
|
|
31
|
+
* @param source - Which area of the element a refusal names.
|
|
32
|
+
*/
|
|
33
|
+
export declare function checkViewOptions(view: GraphView, id: string, descriptors: readonly OptionDescriptor[], values: Readonly<Record<string, unknown>>, source?: GraphtyErrorSource): void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file What a simple-tier graph view is built from: the current snapshot, and the one reader a
|
|
3
|
+
* style selector reads values through.
|
|
4
|
+
*
|
|
5
|
+
* `node.attr(path)` promises to resolve a path "exactly as a style selector resolves it"
|
|
6
|
+
* (design/extensions/simple-tier.md section 2.3 rule 3). The only way to keep that promise is to
|
|
7
|
+
* read through the same code, so this builds the view's reader with `createSelectorSource` -- the
|
|
8
|
+
* factory the session's style stack, query engine and selection all read through -- over the
|
|
9
|
+
* session's own records and results. A `results.<run>.<field>` path therefore reads a finished
|
|
10
|
+
* run's published values exactly as a style layer bound to it does.
|
|
11
|
+
*
|
|
12
|
+
* Nothing here reaches Babylon.js, Lit or the DOM.
|
|
13
|
+
*/
|
|
14
|
+
import type { GraphSnapshot } from "@graphty/graph-format";
|
|
15
|
+
import type { GraphSession } from "../session/types";
|
|
16
|
+
/** Which kind of element a path is read on. */
|
|
17
|
+
export type ViewTarget = "node" | "edge";
|
|
18
|
+
/** Everything a graph view reads. */
|
|
19
|
+
export interface ViewSource {
|
|
20
|
+
/** The graph, frozen: the view is built once over it and never follows a later freeze. */
|
|
21
|
+
readonly snapshot: GraphSnapshot;
|
|
22
|
+
/**
|
|
23
|
+
* One node's value at a path.
|
|
24
|
+
* @param row - The node's row in `snapshot`.
|
|
25
|
+
* @param path - The path, as a style selector spells it.
|
|
26
|
+
* @returns The value, or undefined when the node carries none.
|
|
27
|
+
*/
|
|
28
|
+
nodeValue(row: number, path: string): unknown;
|
|
29
|
+
/**
|
|
30
|
+
* One edge's value at a path.
|
|
31
|
+
* @param row - The edge's row in `snapshot`.
|
|
32
|
+
* @param path - The path.
|
|
33
|
+
* @returns The value, or undefined when the edge carries none.
|
|
34
|
+
*/
|
|
35
|
+
edgeValue(row: number, path: string): unknown;
|
|
36
|
+
/**
|
|
37
|
+
* The attribute names one kind of element carries, for a refusal that lists them. Optional: a
|
|
38
|
+
* refusal without it says only what was not found.
|
|
39
|
+
* @param target - Nodes or edges.
|
|
40
|
+
* @returns The names, in a stable order.
|
|
41
|
+
*/
|
|
42
|
+
attributeNames?(target: ViewTarget): readonly string[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The view source over a session's graph as it stands now.
|
|
46
|
+
* @param session - The session: an element's (`graph.getSession()`) or a headless one.
|
|
47
|
+
* @returns The source, pinned to the current snapshot.
|
|
48
|
+
*/
|
|
49
|
+
export declare function viewSourceOf(session: GraphSession): ViewSource;
|