@ai-gui/plugin-bigscreen 0.36.3 → 0.37.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/index.d.cts CHANGED
@@ -79,7 +79,92 @@ interface GlobePanel extends PanelBase {
79
79
  }>;
80
80
  rotate?: boolean;
81
81
  }
82
- type Panel = KpiPanel | GaugePanel | RankPanel | ChartPanel | Chart3dPanel | GlobePanel;
82
+ /** One swim-lane of a timeline: a source, an outlet, a system — whatever the rows stand for. */
83
+ interface TimelineLane {
84
+ id: string;
85
+ /** The name written down the left. At most 40 characters. */
86
+ name: string;
87
+ /** The lane's colour, as a hex string. Default: from the palette, by lane order. */
88
+ color?: string;
89
+ }
90
+ /** One point on a timeline. `id` is only needed for a lane an item is linked from or to. */
91
+ interface TimelineItem {
92
+ id?: string;
93
+ /** The `id` of the lane the point sits on. */
94
+ lane: string;
95
+ /** When it happened, as ISO 8601. */
96
+ at: string;
97
+ /** The one line beside the point. At most 120 characters. */
98
+ label: string;
99
+ /** What the tooltip adds. At most 400 characters. */
100
+ detail?: string;
101
+ /** Opened on click, unless the host took the click. `http` or `https` only. */
102
+ url?: string;
103
+ /** How big the point is drawn, relative to the other points. */
104
+ value?: number;
105
+ }
106
+ /**
107
+ * A line drawn between two points.
108
+ *
109
+ * `contradicts` is the one this panel exists for: two claims that cannot both be true, drawn in
110
+ * the palette's danger red across the lanes that made them.
111
+ */
112
+ interface TimelineLink {
113
+ from: string;
114
+ to: string;
115
+ /** Default `follows`. */
116
+ kind?: "contradicts" | "follows" | "same";
117
+ }
118
+ /** Lanes down the side, time across, one point per thing that happened, links between them. */
119
+ interface TimelinePanel extends PanelBase {
120
+ kind: "timeline";
121
+ lanes: TimelineLane[];
122
+ items: TimelineItem[];
123
+ links?: TimelineLink[];
124
+ /** The window drawn, as ISO 8601. Default: the items' own range with 5% on each side. */
125
+ from?: string;
126
+ to?: string;
127
+ }
128
+ /** One entity in a knowledge graph. */
129
+ interface Graph3dNode {
130
+ id: string;
131
+ /** At most 80 characters. */
132
+ name: string;
133
+ /** What kind of thing it is; the colour follows from this. At most 32 characters. */
134
+ type?: string;
135
+ /** How big it is drawn. Default: its degree. */
136
+ value?: number;
137
+ }
138
+ /** One typed edge. Both ends must be node ids. */
139
+ interface Graph3dEdge {
140
+ from: string;
141
+ to: string;
142
+ /** At most 32 characters. */
143
+ type?: string;
144
+ }
145
+ /**
146
+ * Entities and typed edges as a knowledge graph.
147
+ *
148
+ * `orbit`, the default, is a real three-dimensional model: the entities are laid out in space by
149
+ * a spring-electrical simulation and the camera turns around them. `flat` is echarts-gl's own
150
+ * `graphGL` — force-atlas2 on the GPU, drawn on a plane with an orthographic camera — which draws
151
+ * more nodes at once and is the mode to reach for when a graph is big enough that the third
152
+ * dimension costs more than it shows.
153
+ */
154
+ interface Graph3dPanel extends PanelBase {
155
+ kind: "graph3d";
156
+ nodes: Graph3dNode[];
157
+ edges: Graph3dEdge[];
158
+ /** Type name to hex colour, overriding the palette's own assignment. At most 32 entries. */
159
+ types?: Record<string, string>;
160
+ /** The id of the node to highlight and always label. */
161
+ focus?: string;
162
+ /** How it is drawn: a turning 3D model, or the flat GPU layout. Default "orbit". */
163
+ mode?: "orbit" | "flat";
164
+ /** Whether the graph moves at all — settling, and turning. Default true. */
165
+ rotate?: boolean;
166
+ }
167
+ type Panel = KpiPanel | GaugePanel | RankPanel | ChartPanel | Chart3dPanel | GlobePanel | TimelinePanel | Graph3dPanel;
83
168
  type PanelKind = Panel["kind"];
84
169
  interface ScreenDefinition {
85
170
  title?: string;
@@ -91,6 +176,82 @@ interface ScreenDefinition {
91
176
  columns: number;
92
177
  panels: Panel[];
93
178
  }
179
+ /**
180
+ * The bit of GeoJSON a globe needs: WGS84 rings, in longitude/latitude order.
181
+ *
182
+ * Deliberately not the whole of RFC 7946. Only the two polygon geometries are drawn, and
183
+ * everything else on a feature is ignored, so a host can hand over `world-atlas` straight out of
184
+ * `topojson-client` without a type assertion and without this package taking a GeoJSON
185
+ * dependency.
186
+ */
187
+ type GlobeGeometry = {
188
+ type: "Polygon";
189
+ coordinates: number[][][];
190
+ } | {
191
+ type: "MultiPolygon";
192
+ coordinates: number[][][][];
193
+ } | {
194
+ type: string;
195
+ coordinates?: unknown;
196
+ };
197
+ interface GlobeFeatureCollection {
198
+ type: "FeatureCollection";
199
+ features: Array<{
200
+ type?: string;
201
+ geometry?: GlobeGeometry | null;
202
+ properties?: Record<string, unknown> | null;
203
+ }>;
204
+ }
205
+ /**
206
+ * What the host wants the planet to look like.
207
+ *
208
+ * The fence says where the events are; this says what they are drawn on, and it is host
209
+ * configuration rather than a panel field on purpose: a texture is a URL, and a URL a model
210
+ * wrote is a request a page would be making on the model's say-so.
211
+ *
212
+ * Precedence is `baseTexture`, then `countries`, then the painted graticule the plugin has
213
+ * always drawn — so a host that sets none of this gets exactly the globe it got before.
214
+ */
215
+ interface GlobeSkin {
216
+ /** An equirectangular (2:1) day texture, as a URL or a data URL the host serves itself. */
217
+ baseTexture?: string;
218
+ /** An equirectangular height map, for bump shading. Optional. */
219
+ heightTexture?: string;
220
+ /** Country outlines to rasterise onto a 2:1 canvas when there is no `baseTexture`. */
221
+ countries?: GlobeFeatureCollection;
222
+ /** Fill for land. Default: from the palette. */
223
+ land?: string;
224
+ /** Fill for sea. Default: from the palette. */
225
+ ocean?: string;
226
+ /** Stroke for country borders. Default: from the palette. */
227
+ border?: string;
228
+ /** How the sphere is lit. Default "lambert" once a skin is given. */
229
+ shading?: "color" | "lambert" | "realistic";
230
+ /** The glow around the rim. Default true. */
231
+ atmosphere?: boolean;
232
+ /**
233
+ * The sun.
234
+ *
235
+ * `time` is what echarts-gl puts the main light at, so the terminator falls where the sun
236
+ * actually is; the default is now.
237
+ */
238
+ light?: {
239
+ intensity?: number;
240
+ time?: Date | string;
241
+ };
242
+ }
243
+ /**
244
+ * What the host wants to happen when a reader clicks something.
245
+ *
246
+ * A timeline item carries a `url`, and without a handler the plugin opens it in a new tab. A host
247
+ * that has its own idea of what a claim is — a drawer, a route, a second panel — passes
248
+ * `onItemClick` and takes the click instead, `url` and all. There is no default for a graph node:
249
+ * a node is not a link, so a host that wants a click to mean something has to say so.
250
+ */
251
+ interface BigscreenEvents {
252
+ onItemClick?: (item: TimelineItem) => void;
253
+ onNodeClick?: (node: Graph3dNode) => void;
254
+ }
94
255
  interface BigscreenOptions {
95
256
  /** Refuse a screen with more panels than this. Default 24. */
96
257
  maxPanels?: number;
@@ -100,6 +261,10 @@ interface BigscreenOptions {
100
261
  animate?: boolean;
101
262
  /** Host override for the palette; a screen's own `theme` wins when set in the fence. */
102
263
  theme?: ScreenTheme;
264
+ /** Host override for what a globe panel's planet looks like. Unset draws the graticule. */
265
+ globe?: GlobeSkin;
266
+ /** What a click on a timeline item or a graph node does. */
267
+ events?: BigscreenEvents;
103
268
  }
104
269
  interface BigscreenError {
105
270
  code: "invalid-json" | "invalid-definition" | "too-large";
@@ -129,6 +294,31 @@ declare function bigscreenPromptSpec(locale?: string): string;
129
294
 
130
295
  //#endregion
131
296
  //#region src/parse.d.ts
297
+ /**
298
+ * Every limit the parser enforces, named.
299
+ *
300
+ * Exported because a limit the parser checks and nothing states is a trap: the prompt spec has to
301
+ * name the same numbers, and a host building a fence of its own needs to know where the cliff is.
302
+ * Overrunning any of them voids the whole block, so they are all deliberately generous — generous
303
+ * enough that the biggest of them are not reachable under the default 64 KiB source cap: five
304
+ * thousand edges is around a hundred kilobytes of JSON, so a host that really wants a graph that
305
+ * size has to raise `maxSourceBytes` as well.
306
+ */
307
+ declare const MAX_POINTS = 5000;
308
+ declare const MAX_ITEMS = 50;
309
+ declare const MAX_ARCS = 300;
310
+ declare const MAX_LANES = 24;
311
+ declare const MAX_TIMELINE_ITEMS = 500;
312
+ declare const MAX_LINKS = 500;
313
+ declare const MAX_NODES = 2000;
314
+ declare const MAX_EDGES = 5000;
315
+ declare const MAX_TYPES = 32;
316
+ declare const MAX_LANE_NAME = 40;
317
+ declare const MAX_ITEM_LABEL = 120;
318
+ declare const MAX_ITEM_DETAIL = 400;
319
+ declare const MAX_URL = 400;
320
+ declare const MAX_NODE_NAME = 80;
321
+ declare const MAX_TYPE_NAME = 32;
132
322
  /** Validate one `bigscreen` fence, or explain why it cannot be shown. */
133
323
  declare function parseBigscreen(source: string, options?: {
134
324
  maxPanels?: number;
@@ -182,10 +372,447 @@ declare function chart3dOption(panel: Chart3dPanel, c: Palette, animate: boolean
182
372
  *
183
373
  * ECharts' globe wants a texture, and the usual one is an image fetched from somewhere — which a
184
374
  * page must not do on a model's say-so. So the texture is painted here: a deep sphere with a
185
- * graticule, which is what a data wall's globe looks like anyway. Arcs get a moving trail.
375
+ * graticule, which is what a data wall's globe looks like anyway. A host that wants a real earth
376
+ * says so in `BigscreenOptions.globe` and `earth.ts` takes over; this stays the fallback.
377
+ */
378
+ declare function globeTexture(c: Palette, theme: "dark" | "light"): string | undefined;
379
+ /**
380
+ * The sphere itself, with and without a host-supplied earth.
381
+ *
382
+ * Without one, everything below the `skin` branch is the globe this plugin has always drawn: a
383
+ * flat-lit ball with a graticule on it, every point labelled. A wire grid needs no sun — there is
384
+ * nothing on it a shadow would tell you about — and `shading: "color"` with the light turned down
385
+ * is what keeps it evenly readable while it turns.
386
+ *
387
+ * With one, the ball is a planet: lambert (or the host's choice) so the terminator falls where the
388
+ * sun actually is, an atmosphere at the rim, and labels only on the points worth reading from
389
+ * across a room. `postEffect` stays off — bloom and depth of field on one of six panels is a
390
+ * frame budget spent on the wrong thing.
186
391
  */
392
+ declare function globeOption(panel: GlobePanel, c: Palette, animate: boolean, texture: string | undefined, skin?: GlobeSkin): EChartsCoreOption;
187
393
 
188
- declare function globeOption(panel: GlobePanel, c: Palette, animate: boolean, texture: string | undefined): EChartsCoreOption;
394
+ //#endregion
395
+ //#region src/earth.d.ts
396
+ /** The three colours a painted world is made of, defaulted from the screen's palette. */
397
+ interface EarthColours {
398
+ ocean: string;
399
+ land: string;
400
+ border: string;
401
+ }
402
+ declare function earthColours(c: Palette, theme: ScreenTheme, skin?: GlobeSkin): EarthColours;
403
+ /**
404
+ * Rasterise a world onto a 2:1 canvas and hand it over as a data URL.
405
+ *
406
+ * A data URL rather than the canvas element: that is the path echarts-gl treats as an image to
407
+ * decode, and it involves no request. A canvas element handed to `baseTexture` is a white ball.
408
+ *
409
+ * Rings are filled even-odd so that a country drawn as an outer ring plus holes — Lesotho inside
410
+ * South Africa, the lakes inside Canada — comes out with the holes in it whichever way round the
411
+ * source wound them.
412
+ */
413
+ declare function countriesTexture(countries: GlobeFeatureCollection, colours: EarthColours): string | undefined;
414
+ /**
415
+ * The texture a globe panel wears, by the host's precedence.
416
+ *
417
+ * `baseTexture` wins because a host that has a photograph has already decided; `countries` is
418
+ * next because outlines a host bundled are still the host's map; and with neither there is the
419
+ * graticule, which is what this plugin has always drawn and what every consumer that never heard
420
+ * of a `globe` option keeps getting.
421
+ */
422
+ declare function earthTexture(c: Palette, theme: ScreenTheme, skin?: GlobeSkin): string | undefined;
423
+
424
+ //#endregion
425
+ //#region src/timeline.d.ts
426
+ /**
427
+ * A timeline of claims, one lane per source.
428
+ *
429
+ * The panel exists for the line nobody else draws: two outlets said things that cannot both be
430
+ * true, and the red segment between their two points is the whole point of the picture. So the
431
+ * lanes stay in the order they were given (a reader compares row against row, and a chart that
432
+ * reorders them silently answers a different question), time runs across, and every claim is one
433
+ * point that can be clicked back to the page it came from.
434
+ *
435
+ * Pure: the option is a function of the panel and the palette, so it can be tested without a
436
+ * canvas and so the same claims draw the same picture on every screen.
437
+ */
438
+ /** How many claims carry a written label; the rest are on the tooltip. */
439
+ declare const TIMELINE_LABELS = 12;
440
+ /**
441
+ * The window drawn, in epoch milliseconds.
442
+ *
443
+ * The panel's own `from` and `to` win where they are given. Otherwise it is the claims' own range
444
+ * with 5% on each side, because a point exactly on the axis reads as clipped rather than as first.
445
+ * A single claim has no range to take a fraction of, so it gets an hour either way — enough for
446
+ * the point to sit somewhere rather than in the middle of nothing.
447
+ */
448
+ declare function timelineWindow(panel: TimelinePanel): [number, number];
449
+ /**
450
+ * Which claims have room for a label, as indexes into `panel.items`.
451
+ *
452
+ * A label is drawn beside its point, on its own lane, so what decides whether it can be read is
453
+ * the empty time on either side of it within that lane — not how important the claim is and not
454
+ * what order it was written in. Twelve labels on a wall panel is about where a reader stops
455
+ * reading them anyway, and the rest are one hover away.
456
+ */
457
+ declare function spacedItems(panel: TimelinePanel, max?: number): Set<number>;
458
+ /**
459
+ * How tall a timeline of this many lanes has to be.
460
+ *
461
+ * 320 is the default panel, and it holds a handful of lanes comfortably. Past that the lanes get
462
+ * a floor of 28 pixels each: below that the points of two neighbouring outlets touch, and a
463
+ * contradiction drawn between them stops being a line between two rows.
464
+ */
465
+ declare function timelineHeight(lanes: number): number;
466
+ declare function timelineOption(panel: TimelinePanel, c: Palette, animate: boolean): EChartsCoreOption;
467
+
468
+ //#endregion
469
+ //#region src/graph3d.d.ts
470
+ /**
471
+ * The vocabulary every knowledge graph panel is drawn in, and the flat mode's own option.
472
+ *
473
+ * A type's colour, a node's degree, the legend in the corner and the tooltip are the same in both
474
+ * modes and live here. `orbit.ts` — the default — turns the entities into a model in space;
475
+ * `graph3dOption` below is `flat`, echarts-gl's `graphGL`: force-atlas2 on the GPU, drawn on a
476
+ * plane with an orthographic camera. It draws more nodes at once than the model does, which is
477
+ * the reason it is still here.
478
+ *
479
+ * Pure: the option is a function of the panel and the palette.
480
+ */
481
+ /** How many entities carry a written label. The rest are one hover away. */
482
+ declare const GRAPH_LABELS = 20;
483
+ /**
484
+ * How the layout is run.
485
+ *
486
+ * `steps` is iterations per frame and `maxSteps` is where the layout stops. Settling takes
487
+ * `maxSteps / steps` frames — 125 of them, a shade over two seconds at sixty frames a second,
488
+ * which is long enough to watch a graph of five hundred entities pull itself apart and short
489
+ * enough that nobody waits for it. When nothing is meant to move, the same thousand iterations
490
+ * are spent four frames deep and the reader gets the settled graph instead of the settling.
491
+ *
492
+ * (echarts-gl 2.x bounds the layout with `maxSteps`; there is no convergence threshold to set.)
493
+ */
494
+ declare const GRAPH_SETTLE_STEPS = 8;
495
+ declare const GRAPH_MAX_STEPS = 1000;
496
+ /** How many types the corner legend lists before it would start covering the graph. */
497
+ declare const GRAPH_LEGEND_ROWS = 12;
498
+ /**
499
+ * The colour of a type.
500
+ *
501
+ * Hashed rather than handed out in order of appearance, because two graph panels on one wall must
502
+ * colour `outlet` the same way, and the order the types happen to appear in is different in each
503
+ * of them. A hash means two types can land on the same colour, which is what the legend in the
504
+ * corner is for; a panel that cares says so in `types`.
505
+ *
506
+ * Only the first seven series colours are in the ring. The eighth is a second cyan a shade off
507
+ * the accent, and two types a reader cannot tell apart is worse than two types sharing a colour
508
+ * the legend admits to sharing.
509
+ *
510
+ * A node with no type gets the muted colour: it is not a category, so it does not get one of the
511
+ * colours the categories are being told apart by.
512
+ */
513
+ declare function typeColour(type: string | undefined, c: Palette, overrides?: Record<string, string>): string;
514
+ /** How many edges touch each node. Both ends count, so a self-edge counts twice. */
515
+ declare function degrees(panel: Graph3dPanel): Map<string, number>;
516
+ interface GraphLegendEntry {
517
+ label: string;
518
+ colour: string;
519
+ shape: "node" | "edge";
520
+ }
521
+ /**
522
+ * The key drawn in the panel's corner: every type that appears, once, in its own colour.
523
+ *
524
+ * Nodes first, then edges, each in the order it first appears — which is the order the model
525
+ * wrote them in, and therefore the order it was thinking in. An untyped graph gets no legend at
526
+ * all rather than an empty box.
527
+ */
528
+ declare function graphLegend(panel: Graph3dPanel, c: Palette): GraphLegendEntry[];
529
+ /**
530
+ * What an entity or an edge says on hover, in both modes.
531
+ *
532
+ * Escaped by hand: ECharts renders a formatter's return as HTML and every name here was written
533
+ * by a model. An edge is told apart by `dataType` in the flat series and by carrying its own
534
+ * `coords` in the orbit one, which is the only thing the two series disagree about.
535
+ */
536
+ declare function graphTooltip(params: {
537
+ dataType?: string;
538
+ data?: unknown;
539
+ }): string;
540
+ /**
541
+ * The `flat` mode: `graphGL`, laid out by force-atlas2 on the GPU.
542
+ *
543
+ * Unchanged since it was written, byte for byte, and pinned by a test that says so — a panel that
544
+ * asked for this mode asked for exactly this picture. The 3D model is `graphOrbitOption`, which
545
+ * takes positions rather than computing them, because it is stepped in front of the reader.
546
+ */
547
+ declare function graph3dOption(panel: Graph3dPanel, c: Palette, animate: boolean): EChartsCoreOption;
548
+
549
+ //#endregion
550
+ //#region src/layout3d.d.ts
551
+ /**
552
+ * A spring–electrical layout in three dimensions.
553
+ *
554
+ * Fruchterman–Reingold's forces, one dimension further: every pair of entities pushes apart with
555
+ * `k²/d`, every edge pulls its ends together with `d²/k`, a weak spring holds the whole thing to
556
+ * the origin, and a falling temperature caps how far a node may move in one step so the graph
557
+ * cools into a shape instead of oscillating around one.
558
+ *
559
+ * Written here rather than taken from a dependency for two reasons. The panel needs positions in
560
+ * three dimensions and echarts-gl's own layouts are two-dimensional; and the layout has to be
561
+ * *steppable* — a few steps per animation frame — so the reader watches the graph pull itself
562
+ * apart rather than being handed a settled picture. A library that runs to convergence behind a
563
+ * promise cannot do that.
564
+ *
565
+ * Deterministic on purpose: the starting positions are a hash of the node ids on a sphere, so the
566
+ * same knowledge graph draws the same picture twice running, and a screenshot test means
567
+ * something. Nothing here calls `Math.random`.
568
+ *
569
+ * Complexity is O(n²) per step, which is why `layoutSteps` spends fewer steps on a bigger graph.
570
+ */
571
+ /** The distance an edge settles at: the unit everything else here is measured in. */
572
+ declare const LAYOUT_SPRING = 1;
573
+ /**
574
+ * The pull to the origin, per unit of distance from it.
575
+ *
576
+ * Without it a knowledge graph with two unconnected components is unbounded: nothing attracts
577
+ * them to each other, the repulsion between them is never opposed, and one of them leaves the
578
+ * panel and keeps going.
579
+ */
580
+ declare const LAYOUT_GRAVITY = 0.08;
581
+ /**
582
+ * FNV-1a.
583
+ *
584
+ * The one hash in this package: the same function that decides a type's colour decides where a
585
+ * node starts, so both are a function of the name and of nothing else.
586
+ */
587
+ declare function hash(value: string): number;
588
+ declare function layoutSteps(n: number): number;
589
+ /**
590
+ * How many steps are spent per animation frame while the graph settles in front of the reader.
591
+ *
592
+ * Small enough to leave the frame time for drawing, and large enough that a six-entity graph —
593
+ * which is given three hundred steps — is finished in well under a second rather than in five.
594
+ * At a few hundred entities a single step already costs most of a frame, so it drops to one and
595
+ * the graph settles at whatever pace the machine can manage.
596
+ */
597
+ declare function layoutChunk(n: number): number;
598
+ /**
599
+ * The radius a graph of `n` entities settles inside, which is also where it is started.
600
+ *
601
+ * A cube root, not a square root. Inside a ball of charge the repulsion at radius `r` comes only
602
+ * from what is enclosed — `n(r/R)³` of it, over `r²` — so balancing it against a gravity of `g·r`
603
+ * gives `R = k·∛(n/g)`. Guessing `sqrt` instead put a two-thousand-entity graph's starting sphere
604
+ * five times too wide, and the first half of its forty steps went on collapsing rather than on
605
+ * laying anything out.
606
+ */
607
+ declare function layoutRadius(n: number): number;
608
+ type Vec3 = readonly [number, number, number];
609
+ /**
610
+ * Where every node starts, as `[x, y, z]` per node in the order the ids were given.
611
+ *
612
+ * A node the caller remembers keeps exactly the position it had, which is what stops a graph that
613
+ * gained three entities from reshuffling the twenty that were already there. Everything else is
614
+ * placed on a sphere by the hash of its id — a Fibonacci-like spiral from two independent hashes,
615
+ * so ids that are one character apart do not end up next to each other — scaled to the cloud the
616
+ * remembered nodes already occupy, or to the graph's own settling radius when there is nothing to
617
+ * remember.
618
+ */
619
+ declare function seedPositions(ids: readonly string[], seed?: ReadonlyMap<string, Vec3>): Float32Array;
620
+ interface Layout {
621
+ /** Run `count` more steps, or one. Steps past `steps` do nothing. */
622
+ step(count?: number): void;
623
+ /**
624
+ * The current positions, as `[x, y, z]` per node in the order the nodes were given.
625
+ *
626
+ * The live buffer, not a copy: the render loop reads it every frame and must not allocate.
627
+ * A caller keeping the positions past the next `step` has to copy them itself.
628
+ */
629
+ positions(): Float32Array;
630
+ /** Whether the layout has spent all its steps. */
631
+ readonly done: boolean;
632
+ /** How many steps it will spend in total. */
633
+ readonly steps: number;
634
+ /** How many it has spent. */
635
+ readonly taken: number;
636
+ }
637
+ /**
638
+ * A layout over `nodes` and `edges`, ready to be stepped.
639
+ *
640
+ * `seed` is the positions the same graph settled into last time, by node id; the ids it does not
641
+ * mention are placed by their hash. An edge naming a node that is not there is skipped rather
642
+ * than refused — the parser has already rejected those, and a layout is not the place to raise.
643
+ */
644
+ declare function createLayout(nodes: readonly Graph3dNode[], edges: readonly Graph3dEdge[], seed?: ReadonlyMap<string, Vec3>): Layout;
645
+
646
+ //#endregion
647
+ //#region src/orbit.d.ts
648
+ /**
649
+ * The knowledge graph as a model you look at, rather than a picture you look down on.
650
+ *
651
+ * `layout3d.ts` puts the entities in space; this puts a camera in there with them. A `grid3D`
652
+ * holds the coordinate system, a `scatter3D` draws the entities and a `line3D` draws the edges,
653
+ * and the box the three of them share is deliberately invisible: a knowledge graph has no axes
654
+ * to read, and the only thing an axis would add is furniture.
655
+ *
656
+ * Pure: the option is a function of the panel, the palette and the positions. The positions come
657
+ * from outside because the layout is stepped — the mount loop hands the same builder a slightly
658
+ * different set of coordinates every frame while the graph settles.
659
+ */
660
+ /**
661
+ * The half-width of the space the graph is drawn in, in the box's own units.
662
+ *
663
+ * Everything about the camera — the distance it sits at, how big a node reads at that distance —
664
+ * is a constant, so the graph has to be scaled to it rather than the other way round. The layout
665
+ * works in units of its own spring length and a graph of two thousand is naturally four times
666
+ * wider than a graph of six; `orbitScale` divides that difference out, and this is what is left.
667
+ */
668
+ declare const ORBIT_EXTENT = 50;
669
+ /** The cube the coordinate system is drawn in. Equal on all three sides, or the shape is a lie. */
670
+ declare const ORBIT_BOX = 140;
671
+ /**
672
+ * The camera: how far out it sits, how fast it goes round, and the field of view it does it with.
673
+ *
674
+ * The distance is not a matter of taste. The graph is fitted to the box, so its furthest entity
675
+ * sits half a box from the middle — and as the camera turns, that entity comes round to the near
676
+ * side, where the perspective divide is over a distance of `ORBIT_DISTANCE - ORBIT_BOX / 2`
677
+ * rather than `ORBIT_DISTANCE`. A camera framed for the middle therefore crops the graph twice a
678
+ * revolution, which is exactly what it did at 180: an entity and its edge walked off the bottom
679
+ * of the panel and back. So the distance is set from the near face, with room left over for the
680
+ * labels, which stick out further than the entities they belong to.
681
+ *
682
+ * echarts-gl's grid3D camera has a vertical field of view of 50 degrees and is not configurable
683
+ * through `viewControl`, so it is written down here rather than passed.
684
+ */
685
+ declare const ORBIT_FOV = 50;
686
+ declare const ORBIT_DISTANCE = 260;
687
+ /** Where the layout has to be moved to, and what it has to be multiplied by, to fill the box. */
688
+ interface OrbitFrame {
689
+ centre: [number, number, number];
690
+ scale: number;
691
+ }
692
+ /**
693
+ * The graph's own bounding box, as the transform that puts it in the middle of the panel.
694
+ *
695
+ * Its box, not its bounding sphere, and its centre, not the origin. A settled graph is rarely a
696
+ * ball: the eight-entity example comes out about 72 units wide, 26 tall and 40 deep, centred six
697
+ * units left of where it started. Scaling that by its largest radius left it filling a fifth of
698
+ * the panel and sitting off to one side — correct, and unreadable. Fitting the longest of the
699
+ * three spans instead fills the frame in whichever direction the graph is actually long, and
700
+ * because every other span is shorter by definition, nothing lands outside the box.
701
+ */
702
+ declare function orbitFrame(positions: Float32Array): OrbitFrame;
703
+ /** One entity, as `scatter3D` reads it. */
704
+ interface OrbitNode {
705
+ id: string;
706
+ name: string;
707
+ /** `[x, y, z, size]`: the first three place it, the fourth is what `symbolSize` reads. */
708
+ value: [number, number, number, number];
709
+ itemStyle: {
710
+ color: string;
711
+ opacity: number;
712
+ };
713
+ /** Whether the name is written beside it. The rest are one hover away. */
714
+ labelled: boolean;
715
+ /** Carried for the tooltip and the host's click; `type` is taken by ECharts. */
716
+ nodeType: string | undefined;
717
+ degree: number;
718
+ node: Graph3dNode;
719
+ }
720
+ /**
721
+ * One vertex of the single polyline every edge is drawn on.
722
+ *
723
+ * echarts-gl has no series that draws many separate lines in a `grid3D`: `lines3D` lays out only
724
+ * on a globe, a geo3D or a mapbox, and on a cartesian3D it throws for want of a layout. `line3D`
725
+ * does work there, but it is one polyline through every point it is given — so the edges are
726
+ * strung together into one, and the joins between them are made to disappear by giving both their
727
+ * ends an opacity of zero. Four vertices per edge: the start twice and the end twice, transparent
728
+ * on the outside and the edge's own colour on the inside.
729
+ *
730
+ * A(0) -> A(c) -> B(c) -> B(0) -> A'(0) -> A'(c) -> ...
731
+ * \_____________/ the edge \__ the join, transparent at
732
+ * both ends and so invisible
733
+ *
734
+ * The doubled points are what the shader's own `position == positionPrev` branch is for, so they
735
+ * cost two degenerate quads and no artefacts.
736
+ *
737
+ * `lineStyle`, not `itemStyle`: `line3D` declares `visualStyleAccessPath: "lineStyle"`, so a
738
+ * colour written under `itemStyle` is read by nothing and every edge quietly comes out in the
739
+ * series' one colour — with the joins between them drawn in it too, which turns a knowledge graph
740
+ * into a ball of wool.
741
+ */
742
+ interface OrbitEdgePoint {
743
+ value: [number, number, number];
744
+ lineStyle: {
745
+ color: string;
746
+ opacity: number;
747
+ };
748
+ }
749
+ /** How many vertices one edge contributes to that polyline. */
750
+ declare const EDGE_VERTICES = 4;
751
+ interface OrbitData {
752
+ nodes: OrbitNode[];
753
+ edges: OrbitEdgePoint[];
754
+ }
755
+ /**
756
+ * The two series' data, from the panel and wherever the layout has got to.
757
+ *
758
+ * Built as one thing because the edges have to agree with the nodes: an edge is drawn between two
759
+ * points, not between two ids, so a frame that moved the nodes and left the edges behind would
760
+ * detach every line from both its ends.
761
+ */
762
+ declare function graphOrbitData(panel: Graph3dPanel, c: Palette, positions: Float32Array): OrbitData;
763
+ /**
764
+ * The whole scene.
765
+ *
766
+ * `animate` is the host's word and `panel.rotate` is the fence's; either one saying no stops the
767
+ * camera. ECharts' own animation is off throughout — on each series as well as at the root,
768
+ * because echarts-gl's vertex animation asks the *series* whether it may animate and does not
769
+ * fall back to the screen's answer. While the graph settles this option's data is replaced every
770
+ * frame, and an animated transition would spend that frame interpolating towards positions the
771
+ * next frame has already superseded.
772
+ */
773
+ declare function graphOrbitOption(panel: Graph3dPanel, c: Palette, animate: boolean, positions: Float32Array): EChartsCoreOption;
774
+
775
+ //#endregion
776
+ //#region src/positions.d.ts
777
+ /**
778
+ * Where each graph settled last time it was drawn.
779
+ *
780
+ * A streamed answer re-renders the same fence as the model writes it: a graph of twenty entities
781
+ * becomes the same graph of twenty-three, and the reconciler tears the panel down and mounts a
782
+ * new one. Without a memory the new layout starts from the hash again, every node lands somewhere
783
+ * else, and the reader — who was reading it — watches the picture they had just understood
784
+ * dissolve because three names arrived.
785
+ *
786
+ * So the positions are kept by node id, under a key that deliberately does *not* depend on the
787
+ * node set: the ids that are still there resume exactly where they were, and only the new ones
788
+ * have to find a place. It is module-level state, which is what makes it survive the remount; it
789
+ * is bounded so a long conversation full of graphs cannot grow it without limit, and it is
790
+ * forgettable so tests do not leak into each other.
791
+ */
792
+ /** How many graphs are remembered at once. Beyond this the least recently used one is dropped. */
793
+ declare const REMEMBERED_GRAPHS = 8;
794
+ /**
795
+ * What identifies a graph across a re-render.
796
+ *
797
+ * The title, because that is the one thing a model rewriting its own fence keeps stable while the
798
+ * entities underneath it change. A panel with no title falls back to its first entity, which is
799
+ * the next most stable thing there is — a graph usually keeps the entity it was drawn around.
800
+ * The prefix keeps a panel titled `kyiv` from colliding with an untitled one whose first node is
801
+ * `kyiv`.
802
+ */
803
+ declare function graphKey(panel: Graph3dPanel): string;
804
+ /** The positions this graph settled into last time, by node id, or nothing. */
805
+ declare function recallPositions(key: string): ReadonlyMap<string, Vec3> | undefined;
806
+ /**
807
+ * Remember where a graph settled.
808
+ *
809
+ * The positions are copied out of the buffer rather than kept by reference: `Layout.positions()`
810
+ * hands back the live array, and a layout that is still running would otherwise have this
811
+ * remember whatever it became several frames later.
812
+ */
813
+ declare function rememberPositions(key: string, ids: readonly string[], positions: Float32Array): void;
814
+ /** Drop every remembered graph. For tests, and for a host tearing a page down. */
815
+ declare function forgetPositions(): void;
189
816
 
190
817
  //#endregion
191
818
  //#region src/index.d.ts
@@ -202,4 +829,4 @@ declare const bigscreenCss: string;
202
829
  declare function bigscreen(options?: BigscreenOptions): AIGuiPlugin;
203
830
 
204
831
  //#endregion
205
- export { BigscreenError, BigscreenOptions, BigscreenResult, Chart3dPanel, ChartPanel, GaugePanel, GlobePanel, KpiPanel, Panel, PanelKind, RankPanel, ScreenDefinition, ScreenTheme, bigscreen, bigscreenCss, bigscreenPromptSpec, chart3dOption, chartOption, formatNumber, gaugeColour, gaugeOption, globeOption, palette, parseBigscreen, withAlpha };
832
+ export { BigscreenError, BigscreenEvents, BigscreenOptions, BigscreenResult, Chart3dPanel, ChartPanel, EDGE_VERTICES, EarthColours, GRAPH_LABELS, GRAPH_LEGEND_ROWS, GRAPH_MAX_STEPS, GRAPH_SETTLE_STEPS, GaugePanel, GlobeFeatureCollection, GlobeGeometry, GlobePanel, GlobeSkin, Graph3dEdge, Graph3dNode, Graph3dPanel, GraphLegendEntry, KpiPanel, LAYOUT_GRAVITY, LAYOUT_SPRING, Layout, MAX_ARCS, MAX_EDGES, MAX_ITEMS, MAX_ITEM_DETAIL, MAX_ITEM_LABEL, MAX_LANES, MAX_LANE_NAME, MAX_LINKS, MAX_NODES, MAX_NODE_NAME, MAX_POINTS, MAX_TIMELINE_ITEMS, MAX_TYPES, MAX_TYPE_NAME, MAX_URL, ORBIT_BOX, ORBIT_DISTANCE, ORBIT_EXTENT, ORBIT_FOV, OrbitData, OrbitEdgePoint, OrbitFrame, OrbitNode, Panel, PanelKind, REMEMBERED_GRAPHS, RankPanel, ScreenDefinition, ScreenTheme, TIMELINE_LABELS, TimelineItem, TimelineLane, TimelineLink, TimelinePanel, Vec3, bigscreen, bigscreenCss, bigscreenPromptSpec, chart3dOption, chartOption, countriesTexture, createLayout, degrees, earthColours, earthTexture, forgetPositions, formatNumber, gaugeColour, gaugeOption, globeOption, globeTexture, graph3dOption, graphKey, graphLegend, graphOrbitData, graphOrbitOption, graphTooltip, hash, layoutChunk, layoutRadius, layoutSteps, orbitFrame, palette, parseBigscreen, recallPositions, rememberPositions, seedPositions, spacedItems, timelineHeight, timelineOption, timelineWindow, typeColour, withAlpha };