@invana/canvas-core 0.0.12

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.
@@ -0,0 +1,2770 @@
1
+ /**
2
+ * Flush scheduling for the **non-reactive** data stores ({@link DataStore} /
3
+ * {@link LayerData}). A write marks a dirty delta and *arms* a deferred flush; the
4
+ * mode decides **when** that flush fires. The store never notifies per write — it
5
+ * coalesces a whole batch into **one** flush (see `docs/canvas-store-data-event-flow.md` §2).
6
+ */
7
+ /** When a coalesced data flush fires. */
8
+ type FlushMode =
9
+ /** Next animation frame (browser). Falls back to `microtask` where no rAF exists (node/tests). */
10
+ 'frame'
11
+ /** End of the current JS task — the kernel default (no DOM assumption, deterministic). */
12
+ | 'microtask'
13
+ /** Never auto-fires; the owner (e.g. the engine's single rAF loop) calls `flush()`. */
14
+ | 'manual';
15
+ /**
16
+ * Arm a deferred flush per `mode`, returning a **cancel** function (a no-op once the
17
+ * callback has run or for modes that can't be cancelled). `'manual'` arms nothing.
18
+ */
19
+ declare function scheduleFlush(mode: FlushMode, cb: () => void): () => void;
20
+
21
+ /**
22
+ * `SpecStore` — the durable **visual description** of one layer's elements.
23
+ *
24
+ * A spec says *what to draw* (`{ kind: 'circle', radius, fill, plane }`) and
25
+ * contains no drawing code. Layers resolve style + templates into specs and
26
+ * publish them here; renderers subscribe and project. That inversion is the
27
+ * point: two backends reading one description cannot disagree about intent, and
28
+ * the description is serialisable, diffable and testable without a GPU.
29
+ *
30
+ * **Generic over `T`, though it no longer has to be.** The vocabulary now sits
31
+ * beside this file (`./index`), so this store *could* name its own element types.
32
+ * It stays generic deliberately: nothing needs the narrowing, and a concrete
33
+ * signature would ripple through `SpecProjector` and `GraphLayer` for no new
34
+ * capability. The engine instantiates it as
35
+ * `SpecStore<BaseShapeSpec | BaseConnectorSpec>`.
36
+ *
37
+ * **What does *not* live here:** positions. Those stay in {@link LayerData}'s
38
+ * typed arrays on the machine-rate path — a drag frame moves nodes without
39
+ * touching a single spec. And transient visuals (lasso, brush, drag ghosts) never
40
+ * enter the store at all; they are drawn through the renderer's overlay device,
41
+ * so gesture noise stays out of history, undo and saved files.
42
+ *
43
+ * Writes mark a dirty delta and arm a coalesced flush — the same contract as
44
+ * {@link LayerData}, so both channels settle in the same frame.
45
+ *
46
+ * See `docs/renderer-split-design.md` §2 (specs as state) and §4.2b (the channel).
47
+ */
48
+
49
+ /**
50
+ * One coalesced batch of spec changes. Ids only — the receiver reads the specs
51
+ * it cares about, so a flush stays O(dirty) regardless of collection size.
52
+ */
53
+ interface SpecFlush {
54
+ readonly added: readonly string[];
55
+ readonly changed: readonly string[];
56
+ readonly removed: readonly string[];
57
+ /** Monotonic, per store. Lets a consumer detect a missed batch. */
58
+ readonly version: number;
59
+ }
60
+ declare class SpecStore<T extends object = object> {
61
+ private readonly specs;
62
+ private readonly added;
63
+ private readonly changed;
64
+ private readonly removed;
65
+ private readonly listeners;
66
+ private version;
67
+ private scheduled;
68
+ private flushMode;
69
+ private cancel;
70
+ get(id: string): T | undefined;
71
+ has(id: string): boolean;
72
+ get size(): number;
73
+ ids(): IterableIterator<string>;
74
+ entries(): IterableIterator<[string, T]>;
75
+ /** Publish (or replace) the spec for `id`. */
76
+ set(id: string, spec: T): void;
77
+ /**
78
+ * Shallow-merge `partial` over the stored spec. Returns `false` when `id` is
79
+ * unknown, so a caller can fall back to {@link set} with a full spec.
80
+ */
81
+ patch(id: string, partial: Partial<T>): boolean;
82
+ delete(id: string): void;
83
+ /** Drop every spec. Emits one flush listing all ids as removed. */
84
+ clear(): void;
85
+ onFlush(listener: (e: SpecFlush) => void): () => void;
86
+ /**
87
+ * Choose **when** a coalesced flush fires. `'manual'` disarms auto-flush so the
88
+ * engine's single rAF drives it — which is how the renderer stays on one clock.
89
+ */
90
+ setFlushMode(mode: FlushMode): void;
91
+ /** Emit the pending delta, if any. Safe to call when nothing is dirty. */
92
+ flush(): void;
93
+ private schedule;
94
+ }
95
+
96
+ /** A typed listener for one event payload. */
97
+ type Listener<P> = (payload: P) => void;
98
+ /**
99
+ * A string-keyed event map (`{ eventType: payload }`) — the conventional generic
100
+ * bound for scoped {@link EventEmitter}s (layer / behaviour / domain-store event
101
+ * channels). `EventEmitter`/`SourceEmitter` accept any `object`; this is the
102
+ * portable shape most maps use.
103
+ */
104
+ type EventMap = Record<string, unknown>;
105
+ /**
106
+ * A small typed event emitter over an event map `M` (`{ eventType: payload }`).
107
+ * Renderer-free; the base for {@link SourceEmitter} and the building block under
108
+ * {@link CanvasEventBus}.
109
+ */
110
+ declare class EventEmitter<M extends object> {
111
+ private readonly map;
112
+ /** Subscribe; returns an unsubscribe. */
113
+ on<K extends keyof M>(type: K, listener: Listener<M[K]>): () => void;
114
+ /** Subscribe for a single emission. */
115
+ once<K extends keyof M>(type: K, listener: Listener<M[K]>): () => void;
116
+ /** Unsubscribe a listener. */
117
+ off<K extends keyof M>(type: K, listener: Listener<M[K]>): void;
118
+ /** Emit to all listeners of `type` (snapshot, so handlers may unsubscribe). */
119
+ emit<K extends keyof M>(type: K, payload: M[K]): void;
120
+ removeAllListeners(): void;
121
+ listenerCount<K extends keyof M>(type: K): number;
122
+ }
123
+
124
+ /**
125
+ * Shared **geometry vocabulary** for the kernel — `Point` / `Vec2` / `Size` /
126
+ * `Rect` / `CameraTransform`. Relocated from the engine so the renderer-free
127
+ * kernel (node positions, the abstract camera, bounds, derived group geometry)
128
+ * and every adapter speak the same coordinate types **without importing a drawing
129
+ * library**. The pixi renderer (`@invana/canvas`) maps these onto its own
130
+ * `Container`/`Viewport` transforms.
131
+ */
132
+ /**
133
+ * These four are the **single** definition in the repo. The spec vocabulary
134
+ * (`../specs/geometry`) re-exports them rather than declaring its own — before
135
+ * `specs/` moved into the kernel there were two `Rect`s with different mutability,
136
+ * which is exactly the confusion this consolidation removes. Fields are `readonly`:
137
+ * coordinates are computed and replaced wholesale, never patched in place.
138
+ */
139
+ /** A 2-D point in world space. */
140
+ interface Point {
141
+ readonly x: number;
142
+ readonly y: number;
143
+ }
144
+ /** A 2-D vector (direction / delta). Structurally identical to {@link Point}. */
145
+ interface Vec2 {
146
+ readonly x: number;
147
+ readonly y: number;
148
+ }
149
+ /** Width × height extent. */
150
+ interface Size {
151
+ readonly width: number;
152
+ readonly height: number;
153
+ }
154
+ /** Axis-aligned bounding box. */
155
+ interface Rect {
156
+ readonly x: number;
157
+ readonly y: number;
158
+ readonly width: number;
159
+ readonly height: number;
160
+ }
161
+ /**
162
+ * The **abstract camera transform** (C2) — renderer-agnostic: where world `(0,0)`
163
+ * sits in the view (`x`/`y`) plus a uniform `zoom`. Never a `pixi-viewport`
164
+ * handle; the renderer projects this onto its own viewport.
165
+ */
166
+ interface CameraTransform {
167
+ x: number;
168
+ y: number;
169
+ zoom: number;
170
+ }
171
+
172
+ /**
173
+ * Pure geometry — points, rectangles, polylines, paths, and the router / pathStyle
174
+ * function contracts that operate on them. No drawing library appears here.
175
+ *
176
+ * Part of the pixi-free spec vocabulary — see `docs/renderer-split-design.md`.
177
+ */
178
+
179
+ /** Endpoint anchor a router consumes — point + optional outgoing tangent. */
180
+ interface Endpoint {
181
+ readonly x: number;
182
+ readonly y: number;
183
+ readonly tangent?: Vec2;
184
+ }
185
+ /**
186
+ * Flat ordered list of points. Output of a `Router`; input to a `PathStyle`.
187
+ * Also used as the densified form of a `Path` for hit-testing
188
+ * (`samplePath(path)`).
189
+ */
190
+ type Polyline = ReadonlyArray<Point>;
191
+ /**
192
+ * One step of a `Path`. Mirrors SVG path commands one-for-one:
193
+ * - `M` move to absolute (x, y) — must be the first command of any Path.
194
+ * - `L` line to (x, y) from the current point.
195
+ * - `Q` quadratic Bézier with one control point.
196
+ * - `C` cubic Bézier with two control points.
197
+ *
198
+ * No relative variants, no arcs, no shorthand — pathStyles emit one of these
199
+ * four. Connector renders by walking the path and dispatching to Pixi's
200
+ * `moveTo` / `lineTo` / `quadraticCurveTo` / `bezierCurveTo`.
201
+ */
202
+ type PathCommand = {
203
+ readonly kind: 'M';
204
+ readonly x: number;
205
+ readonly y: number;
206
+ } | {
207
+ readonly kind: 'L';
208
+ readonly x: number;
209
+ readonly y: number;
210
+ } | {
211
+ readonly kind: 'Q';
212
+ readonly cx: number;
213
+ readonly cy: number;
214
+ readonly x: number;
215
+ readonly y: number;
216
+ } | {
217
+ readonly kind: 'C';
218
+ readonly c1x: number;
219
+ readonly c1y: number;
220
+ readonly c2x: number;
221
+ readonly c2y: number;
222
+ readonly x: number;
223
+ readonly y: number;
224
+ };
225
+ type Path = ReadonlyArray<PathCommand>;
226
+ /**
227
+ * Read-only scene context handed to routers that need awareness of other
228
+ * shapes — primarily for obstacle-avoidance routing (`manhattan` and
229
+ * friends). Simple geometric routers (`straight`, `orth`) ignore it.
230
+ *
231
+ * `obstacles` are world-space `Rect`s the router should not cross. Each
232
+ * obstacle may also expose `containsInflated` for pixel-accurate silhouette
233
+ * testing (e.g. circles route around their tangent, not their AABB).
234
+ * The renderer auto-collects these from `shapeInstances` (excluding the
235
+ * source/target shapes); callers can override or opt out via
236
+ * `routerOpts.obstacles`.
237
+ */
238
+ interface RouterCtx {
239
+ readonly obstacles: ReadonlyArray<Obstacle>;
240
+ }
241
+ /**
242
+ * Obstacle handed to obstacle-aware routers. `Obstacle extends Rect` so any
243
+ * `Rect[]` is assignable; the optional `containsInflated` callback unlocks
244
+ * silhouette-tight routing for non-rect shapes (circles, polygons, paths).
245
+ */
246
+ interface Obstacle extends Rect {
247
+ /**
248
+ * Optional silhouette obstacle-test in world coordinates. Returns `true`
249
+ * when `(worldX, worldY)` lies inside the obstacle's silhouette OR within
250
+ * `inflate` world units of it.
251
+ *
252
+ * Routers use this for pixel-accurate marking — when present, the grid
253
+ * blocks only cells that pass this test (in addition to the cheap AABB
254
+ * pre-filter). When absent, the inflated AABB is the source of truth.
255
+ *
256
+ * Shapes opt in by overriding `IShape.obstacleTest`.
257
+ */
258
+ readonly containsInflated?: (worldX: number, worldY: number, inflate: number) => boolean;
259
+ }
260
+ /**
261
+ * Router: a pure function `(source, target, waypoints?, opts?, ctx?) → Polyline`.
262
+ *
263
+ * Routers decide path **topology** — where bends sit. They emit a flat
264
+ * polyline (Point[]); the visual style of segments between bend points is
265
+ * decided by the downstream `PathStyle`. Routers never touch pixi.
266
+ *
267
+ * `waypoints` are intermediate user-supplied points the router should respect.
268
+ * Built-in `straight` passes them through verbatim; topological routers
269
+ * (orth, manhattan, …) anchor stair / corner segments to them.
270
+ *
271
+ * `ctx` is optional — only obstacle-aware routers consume it. The renderer
272
+ * always passes a `RouterCtx`; routers that ignore it lose nothing.
273
+ */
274
+ type IRouter = (source: Endpoint, target: Endpoint, waypoints?: ReadonlyArray<Point>, opts?: Record<string, unknown>, ctx?: RouterCtx) => Polyline;
275
+ /**
276
+ * Anchor-resolved endpoints handed to a pathStyle alongside the polyline.
277
+ *
278
+ * Tangent-aware pathStyles (`bump-horizontal`, …) read `source.tangent` /
279
+ * `target.tangent` to place their Bézier handles along each shape's outward
280
+ * surface normal, so the curve leaves and arrives flush with the silhouette
281
+ * instead of in a hard-coded direction. Tangent-agnostic pathStyles (`normal`,
282
+ * `rounded`, …) simply ignore the argument — it's optional and additive.
283
+ */
284
+ interface PathStyleEndpoints {
285
+ readonly source: Endpoint;
286
+ readonly target: Endpoint;
287
+ }
288
+ /**
289
+ * PathStyle: a pure function `(polyline, opts?, endpoints?) → Path`.
290
+ *
291
+ * PathStyles decide visual **style** — how segments between polyline points
292
+ * are drawn (sharp, rounded fillets, bezier-smoothed, single bezier A→B).
293
+ * They never see the connector spec or shape context; pure geometric
294
+ * transform.
295
+ *
296
+ * `endpoints` carries the anchor-resolved source/target (with `tangent`) so
297
+ * tangent-aware styles can align Bézier handles with each shape's outward
298
+ * normal. Optional — styles that don't need it ignore the argument and a
299
+ * direct unit-test invocation (`bumpHorizontal(polyline)`) keeps working.
300
+ *
301
+ * Built-ins: `normal` (sharp), `rounded` (quadratic fillets at corners),
302
+ * `smooth` (Catmull-Rom → cubic), `bezier` (single cubic with auto controls).
303
+ */
304
+ type IPathStyle = (polyline: Polyline, opts?: Record<string, unknown>, endpoints?: PathStyleEndpoints) => Path;
305
+ /**
306
+ * Anchor positions for inset content layers (`glyph`, `svg`, `svg-url`).
307
+ * Defaults to `'center'`. Use `'top-right'` etc. for corner-badge
308
+ * composition.
309
+ */
310
+ /**
311
+ * Stable key of a connector spec with paint removed — geometry only.
312
+ *
313
+ * Two specs with the same key route to the same path, so a caller can skip a
314
+ * re-route when only `stroke` changed. Pure: it reads the spec and nothing
315
+ * else, which is why it lives here rather than on a renderer.
316
+ */
317
+ declare function connectorGeometryKey(spec: object): string;
318
+
319
+ /**
320
+ * Fill, stroke and paint-override vocabulary. Values are plain numbers and enums —
321
+ * a colour is `0xRRGGBB`, never a backend colour object.
322
+ *
323
+ * Part of the pixi-free spec vocabulary — see `docs/renderer-split-design.md`.
324
+ */
325
+ type InsetAnchor = 'center' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
326
+ /**
327
+ * One layer of a shape's fill. Layers split by role:
328
+ *
329
+ * - **Silhouette fillers** (`solid`, `image`) — paint into the silhouette
330
+ * via Pixi's `g.fill()`. Multiple silhouette layers stack via alpha;
331
+ * each is re-traced before painting. Image fills always render the
332
+ * texture cover-fitted to the silhouette (uniform scale, may crop) —
333
+ * the engine intentionally does not expose CSS-style `background-size`
334
+ * / `background-repeat` knobs on raster fills.
335
+ * - **Inset content** (`glyph`, `svg`, `svg-url`) — mounted as Container
336
+ * children of the shape's `gfx`. Sized by `sizeRatio` (fraction of the
337
+ * smaller bounds dimension) and positioned by `anchor` (default
338
+ * `'center'`).
339
+ *
340
+ * The engine has no dedicated "icon" kind — icon-library specifics (Font
341
+ * Awesome glyphs, Lucide SVGs, Fluent icons, …) are produced by developer
342
+ * code and dropped into a `glyph` or `svg` layer directly.
343
+ */
344
+ type ShapeFillLayer = {
345
+ readonly kind: 'solid';
346
+ readonly color: number;
347
+ readonly alpha?: number;
348
+ } | {
349
+ /**
350
+ * Raster image painted into the host silhouette.
351
+ *
352
+ * Two orthogonal knobs control sizing:
353
+ *
354
+ * - `fit` (default `'cover'`) — how the texture's aspect maps to
355
+ * the silhouette's AABB. `'cover'` scales by `max(...)`, fully
356
+ * covers, may crop on the cross-axis. `'contain'` scales by
357
+ * `min(...)`, fully fits, leaves the cross-axis margin
358
+ * transparent (the underlying fill layer reads through; the
359
+ * engine pins the texture sampler to `clamp-to-edge` so the
360
+ * margin doesn't tile).
361
+ *
362
+ * - `padding` (default `0`) — pixel inset on the silhouette
363
+ * *before* fit math runs. The silhouette itself is re-traced at
364
+ * that inset for this layer only, so the gap between the
365
+ * full-size silhouette and the inset silhouette is painted by
366
+ * layers underneath (typically a `solid` `bgFill`). Use this
367
+ * when the host silhouette is more restrictive than its AABB
368
+ * (circle, polygon, star, arc) and the texture corners would
369
+ * otherwise clip against the curve.
370
+ *
371
+ * Tile patterns, repeat modes, and inset-Sprite badge placement
372
+ * aren't on the engine surface — stack a `glyph` / `svg` /
373
+ * `svg-url` layer for icon-shaped content.
374
+ */
375
+ readonly kind: 'image';
376
+ readonly url: string;
377
+ readonly alpha?: number;
378
+ readonly fit?: 'cover' | 'contain';
379
+ readonly padding?: number;
380
+ } | {
381
+ /** Font-rendered character (icon-font codepoint, Unicode symbol, emoji). */
382
+ readonly kind: 'glyph';
383
+ readonly char: string;
384
+ /** Required for icon-font glyphs; optional for system-font Unicode. */
385
+ readonly fontFamily?: string;
386
+ /**
387
+ * Font weight (CSS value, e.g. `400`, `900`, `'bold'`). Required for
388
+ * icon fonts that pack different glyph sets per weight.
389
+ */
390
+ readonly fontWeight?: number | string;
391
+ readonly fontStyle?: 'normal' | 'italic';
392
+ /** Glyph color. Default `0xffffff`. */
393
+ readonly color?: number;
394
+ readonly alpha?: number;
395
+ /** Size as fraction of the shape's smaller bounds dimension. Default `0.6`. */
396
+ readonly sizeRatio?: number;
397
+ /** Anchor relative to the shape's bounds. Default `'center'`. */
398
+ readonly anchor?: InsetAnchor;
399
+ } | {
400
+ /** SVG path-d. Multiple subpaths (`M...M...`) are supported. */
401
+ readonly kind: 'svg';
402
+ readonly pathD: string;
403
+ /** Viewport the path was authored in. Default `{ width: 24, height: 24 }`. */
404
+ readonly viewBox?: {
405
+ readonly width: number;
406
+ readonly height: number;
407
+ };
408
+ /** Stroke width when rendering. Default `2`. */
409
+ readonly strokeWidth?: number;
410
+ readonly color?: number;
411
+ readonly alpha?: number;
412
+ readonly sizeRatio?: number;
413
+ readonly anchor?: InsetAnchor;
414
+ } | {
415
+ /**
416
+ * Vector SVG icon fetched from a URL. The engine fetches the SVG,
417
+ * extracts every drawing primitive (`path` / `ellipse` / `circle` /
418
+ * `rect` / `line` / `polyline` / `polygon`) into a single concatenated
419
+ * `pathD`, and renders it as a Pixi Graphics path. Fetched lazily on
420
+ * first use; the resulting `pathD` is cached globally per URL.
421
+ *
422
+ * Use this when a consumer wants to point at their own remote SVG
423
+ * (logo, custom diagram, sample artwork). For curated icon-library
424
+ * usage, prefer an icon-font glyph via `kind: 'glyph'` — the
425
+ * library is icon-vendor-agnostic and intentionally has no
426
+ * vendor-specific fetch glue.
427
+ */
428
+ readonly kind: 'svg-url';
429
+ readonly url: string;
430
+ readonly viewBox?: {
431
+ readonly width: number;
432
+ readonly height: number;
433
+ };
434
+ readonly strokeWidth?: number;
435
+ readonly color?: number;
436
+ readonly alpha?: number;
437
+ readonly sizeRatio?: number;
438
+ readonly anchor?: InsetAnchor;
439
+ };
440
+ /**
441
+ * A shape's fill. Either a single layer, an array of layers (painted
442
+ * bottom-up — first array entry sits underneath), or the `number` shorthand
443
+ * for a solid color.
444
+ */
445
+ type ShapeFill = number | ShapeFillLayer | ReadonlyArray<ShapeFillLayer>;
446
+ /**
447
+ * The **inset-content** half of {@link ShapeFillLayer} — the layer kinds a
448
+ * backend mounts *inside* the silhouette as a child rather than painting
449
+ * *into* it. Named here (not only where it is mounted) because it is part of
450
+ * the vocabulary: a `CompositePart` of kind `'icon'` carries one, so the spec
451
+ * types must be able to reference it without reaching into a renderer.
452
+ */
453
+ type InsetFillLayer = Extract<ShapeFillLayer, {
454
+ kind: 'glyph' | 'svg' | 'svg-url';
455
+ }>;
456
+ /**
457
+ * Does this fill paint the **silhouette** — i.e. would a backend emit a fill
458
+ * for it? True for the `number` shorthand and for any `solid` / `image` layer;
459
+ * false for `undefined` and for a fill made only of inset content
460
+ * ({@link InsetFillLayer}), which mounts a child instead of filling.
461
+ *
462
+ * Load-bearing for hit-testing: a shape with no silhouette fill is **hollow**
463
+ * — only its stroke band answers a containment test, exactly as pixi's
464
+ * `Graphics.containsPoint` behaves (it consults a `fill` instruction that was
465
+ * never emitted). See `containsSpec` in `specs/shapeGeometry/`.
466
+ */
467
+ declare function hasSilhouetteFill(fill: ShapeFill | undefined): boolean;
468
+ interface ShapeStroke {
469
+ readonly color: number;
470
+ readonly alpha?: number;
471
+ readonly width?: number;
472
+ /** Default `'center'`. */
473
+ readonly alignment?: 'inside' | 'center' | 'outside';
474
+ readonly dashArray?: readonly [number, number];
475
+ readonly dashOffset?: number;
476
+ readonly cap?: 'butt' | 'round' | 'square';
477
+ readonly join?: 'miter' | 'round' | 'bevel';
478
+ }
479
+ /**
480
+ * Decoration entry-point override on `IShape.paintInto`. When supplied, the
481
+ * shape ignores `spec.fill` / `spec.stroke` and paints with these values
482
+ * instead. Decorations like glow widen `strokeWidth` and reduce `alpha` to
483
+ * paint a halo; decorations like marching-ants supply `dashArray` /
484
+ * `dashOffset` to render a dashed silhouette; decorations like ring/halo
485
+ * with non-zero `inset` ask the shape to trace a parallel-offset version of
486
+ * its own silhouette.
487
+ */
488
+ interface ShapePaintStyle {
489
+ readonly color?: number;
490
+ readonly alpha?: number;
491
+ readonly strokeWidth?: number;
492
+ /**
493
+ * Stroke alignment relative to the silhouette. Default `'outside'` —
494
+ * decorations almost always want their geometry painted outside the
495
+ * host body (halo, glow, ring), so the inner band doesn't eat into the
496
+ * fill. Override per-call when a decoration genuinely wants to bleed
497
+ * inward (e.g. an "inset border" effect).
498
+ */
499
+ readonly alignment?: 'inside' | 'center' | 'outside';
500
+ /** Default `false` — decorations almost always stroke without filling. */
501
+ readonly fill?: boolean;
502
+ readonly dashArray?: readonly [number, number];
503
+ readonly dashOffset?: number;
504
+ /** Positive = inside the silhouette, negative = outside. Default `0`. */
505
+ readonly inset?: number;
506
+ }
507
+ /** Mirror of `ShapePaintStyle` for connectors. No `inset` (connectors are 1D). */
508
+ interface ConnectorPaintStyle {
509
+ readonly color?: number;
510
+ readonly alpha?: number;
511
+ readonly strokeWidth?: number;
512
+ readonly dashArray?: readonly [number, number];
513
+ readonly dashOffset?: number;
514
+ readonly cap?: 'butt' | 'round' | 'square';
515
+ readonly join?: 'miter' | 'round' | 'bevel';
516
+ /**
517
+ * When `true`, markers paint with `color` / `alpha` instead of their own
518
+ * spec colors. Glow / halo decorations use this so the decoration covers
519
+ * path + markers as a unified silhouette; marching-ants leaves it
520
+ * undefined so markers stay normal-colored over the dashed line.
521
+ */
522
+ readonly tintMarkers?: boolean;
523
+ /**
524
+ * When `true`, `paintInto` paints only the body (no source / target
525
+ * markers). Useful for decorations that handle markers separately or
526
+ * want to leave them untouched. `markerHalo` is preferred for glow /
527
+ * halo coverage; reach for `skipMarkers` only when even outlined
528
+ * markers would be wrong.
529
+ */
530
+ readonly skipMarkers?: boolean;
531
+ /**
532
+ * When `true`, markers paint as **outlines** at `style.strokeWidth`
533
+ * (using `style.color` / `style.alpha`) instead of as filled silhouettes.
534
+ * Marker geometry continues to size off the host connector's spec
535
+ * stroke width — the halo width affects only the outline stroke, never
536
+ * the marker's tip-to-base / wing-spread dimensions. Combined with the
537
+ * widening-stroke / decreasing-alpha pattern of a glow decoration,
538
+ * this produces a halo around the marker that matches the body halo.
539
+ */
540
+ readonly markerHalo?: boolean;
541
+ }
542
+
543
+ /**
544
+ * Paint stripes. `plane` picks the stripe, `zIndex` orders within it.
545
+ *
546
+ * Part of the pixi-free spec vocabulary — see `docs/renderer-split-design.md`.
547
+ */
548
+ type PlaneName = 'backdrop' | 'content';
549
+
550
+ /**
551
+ * Label content and styling. Describes text; renders none of it.
552
+ *
553
+ * Part of the pixi-free spec vocabulary — see `docs/renderer-split-design.md`.
554
+ */
555
+ interface HtmlTagStyle {
556
+ readonly fontFamily?: string;
557
+ readonly fontSize?: number | string;
558
+ readonly fontWeight?: number | string;
559
+ readonly fontStyle?: 'normal' | 'italic' | 'oblique';
560
+ readonly fill?: number | string;
561
+ readonly letterSpacing?: number;
562
+ readonly textDecoration?: string;
563
+ }
564
+ /**
565
+ * The visible content of a `LabelDecoration`. Two variants:
566
+ *
567
+ * - `'text'` — plain Pixi `Text`. Single style, fast, comfortable up to a few
568
+ * thousand visible labels. Supports wrap / maxLines / ellipsis via Pixi's
569
+ * built-in word-wrap plus a truncation pass.
570
+ * - `'html-text'` — Pixi `HTMLText`. Inline tags (`<b>`, `<i>`, custom tags
571
+ * via `tagStyles`) and CSS overrides. Each instance rasterises HTML to a
572
+ * canvas, so this kind is suitable for tens to a couple hundred visible
573
+ * labels — not for graph-wide use.
574
+ *
575
+ * `bitmap-text` (Pixi `BitmapText`) is planned as a third kind for very-high-
576
+ * density graphs; not in v0.
577
+ */
578
+ type LabelContent = {
579
+ readonly kind: 'text';
580
+ readonly text: string;
581
+ readonly fontFamily?: string;
582
+ readonly fontSize?: number;
583
+ readonly fontWeight?: number | string;
584
+ readonly fontStyle?: 'normal' | 'italic';
585
+ readonly fontVariant?: 'normal' | 'small-caps';
586
+ readonly letterSpacing?: number;
587
+ readonly lineHeight?: number;
588
+ /** Fill colour as hex. Default `0x111827` (near-black). */
589
+ readonly fill?: number;
590
+ readonly stroke?: {
591
+ color: number;
592
+ width: number;
593
+ };
594
+ /** Drop shadow on text glyphs (distinct from background pill shadow). */
595
+ readonly shadow?: {
596
+ color: number;
597
+ blur?: number;
598
+ offsetX?: number;
599
+ offsetY?: number;
600
+ alpha?: number;
601
+ };
602
+ readonly alpha?: number;
603
+ /** Horizontal alignment when wrap produces multiple lines. */
604
+ readonly align?: 'left' | 'center' | 'right';
605
+ } | {
606
+ readonly kind: 'html-text';
607
+ readonly html: string;
608
+ /** Base style applied when no tag override matches. */
609
+ readonly defaultFontFamily?: string;
610
+ readonly defaultFontSize?: number;
611
+ readonly defaultFill?: number | string;
612
+ readonly defaultFontWeight?: number | string;
613
+ /**
614
+ * Fixed render width for `HTMLText`. Required for word-wrap; Pixi
615
+ * `HTMLText` needs an explicit width to know when to break lines.
616
+ */
617
+ readonly width?: number;
618
+ /**
619
+ * Per-tag style overrides (e.g. `{ b: { fontWeight: 700 }, hl: { fill: '#facc15' } }`).
620
+ * Custom tags are supported — Pixi forwards them to its tag stylesheet.
621
+ */
622
+ readonly tagStyles?: Readonly<Record<string, HtmlTagStyle>>;
623
+ /**
624
+ * Raw CSS rules injected as a `<style>` block before the HTML body —
625
+ * useful for loading icon fonts or `@font-face` declarations referenced
626
+ * by the inline HTML.
627
+ */
628
+ readonly cssOverrides?: ReadonlyArray<string>;
629
+ readonly alpha?: number;
630
+ };
631
+ /** Background pill drawn behind a label's text. Optional. */
632
+ interface LabelBackground {
633
+ readonly fill?: number;
634
+ readonly fillAlpha?: number;
635
+ readonly stroke?: number;
636
+ readonly strokeAlpha?: number;
637
+ readonly strokeWidth?: number;
638
+ /** Uniform radius or per-corner [tl, tr, br, bl]. */
639
+ readonly radius?: number | readonly [number, number, number, number];
640
+ /** Uniform padding, [v,h], or [t,r,b,l]. */
641
+ readonly padding?: number | readonly [number, number] | readonly [number, number, number, number];
642
+ readonly shadow?: {
643
+ color: number;
644
+ blur?: number;
645
+ offsetX?: number;
646
+ offsetY?: number;
647
+ alpha?: number;
648
+ };
649
+ }
650
+ /** Wrap / overflow controls. Applies to both plain text and HTML text. */
651
+ interface LabelWrap {
652
+ /** Pixel cap on render width. Triggers word-wrap when set. */
653
+ readonly maxWidth?: number;
654
+ /**
655
+ * Pixel cap on render height. Combined with the text's `lineHeight` (read
656
+ * from `LabelContent.lineHeight` or derived from `fontSize`) to derive an
657
+ * effective `maxLines = floor(maxHeight / lineHeight)`. If both `maxHeight`
658
+ * and `maxLines` are set, the smaller (more restrictive) wins.
659
+ */
660
+ readonly maxHeight?: number;
661
+ /** Cap on rendered lines; lines past this are dropped (after `overflow`). */
662
+ readonly maxLines?: number;
663
+ /** Enable wrap explicitly; auto-true when `maxWidth` is set. */
664
+ readonly wordWrap?: boolean;
665
+ /** Truncation policy for content past `maxLines`. Default `'ellipsis'`. */
666
+ readonly overflow?: 'clip' | 'ellipsis';
667
+ }
668
+ /** Per-label LOD — hides the label outside the zoom range. */
669
+ interface LabelVisibility {
670
+ readonly minZoom?: number;
671
+ readonly maxZoom?: number;
672
+ }
673
+ /**
674
+ * Common style block shared by shape- and connector-anchored labels.
675
+ * Placement / offset / rotation specifics live on the host-specific spec.
676
+ */
677
+ interface LabelStyleCommon {
678
+ readonly content: LabelContent;
679
+ readonly background?: LabelBackground;
680
+ readonly wrap?: LabelWrap;
681
+ /** Screen-space offset in pixels applied *after* any auto-rotation. */
682
+ readonly offset?: {
683
+ readonly x?: number;
684
+ readonly y?: number;
685
+ };
686
+ readonly alpha?: number;
687
+ /** Per-label zoom-band LOD; the decoration mounts/unmounts on threshold. */
688
+ readonly visibility?: LabelVisibility;
689
+ /** Cursor on hover when the label container has hit-testing enabled. */
690
+ readonly cursor?: string;
691
+ /** Pointer events enabled on the label container. Default `false`. */
692
+ readonly interactive?: boolean;
693
+ /**
694
+ * Read by `LabelCollisionBehaviour` only — the primitive ignores these.
695
+ * `priority` higher wins ties when collision hides overlap. `collisionGroup`
696
+ * partitions the collision graph (labels in different groups never compete).
697
+ * `forceShow: true` bypasses collision entirely.
698
+ */
699
+ readonly priority?: number;
700
+ readonly collisionGroup?: string;
701
+ readonly forceShow?: boolean;
702
+ /**
703
+ * Floor used by the shrink → truncate → hide fit cascade when an
704
+ * `inside-*` placement requires the label to stay inside the host shape.
705
+ * Below this size, the cascade moves on to truncation (ellipsis) and
706
+ * finally hide. Default `9` (px). Ignored for non-`inside-*` placements.
707
+ */
708
+ readonly minFontSize?: number;
709
+ }
710
+ /**
711
+ * Placement options for a shape-anchored label.
712
+ *
713
+ * Two semantic groups distinguished by the `inside-` prefix:
714
+ *
715
+ * - **Anchor-only placements** — `'center'` plus the 8 outside sides /
716
+ * corners (`'top'`, `'top-right'`, ..., `'top-left'`). The label is
717
+ * positioned at the anchor and sized freely per `LabelWrap`; it may
718
+ * extend past the host shape's bounds.
719
+ * - **Inside placements** (`'inside-*'`) — carry a *containment contract*:
720
+ * the label must stay inside the host shape's inner box. The decoration
721
+ * runs a shrink → truncate → hide fit cascade against the per-placement
722
+ * inner box to enforce this. Use these for sunburst wedges, treemap
723
+ * cells, pack circles — anywhere the label must not overflow.
724
+ *
725
+ * `'center'` and `'inside-center'` share the geometric anchor (shape
726
+ * centre) but differ in containment: `'center'` may overflow, `'inside-center'`
727
+ * may not. They are distinct values, not aliases.
728
+ */
729
+ type ShapeLabelPlacement = 'center' | 'top' | 'top-right' | 'right' | 'bottom-right' | 'bottom' | 'bottom-left' | 'left' | 'top-left' | 'inside-top' | 'inside-top-right' | 'inside-right' | 'inside-bottom-right' | 'inside-bottom' | 'inside-bottom-left' | 'inside-left' | 'inside-top-left' | 'inside-center';
730
+ /** Style payload passed to `setDecoration(id, 'label', { kind: 'label', style })`. */
731
+ interface ShapeLabelStyle extends LabelStyleCommon {
732
+ /** Default `'bottom'`. */
733
+ readonly placement?: ShapeLabelPlacement;
734
+ /** Manual rotation in radians (rare — outside-side labels read upright). */
735
+ readonly rotation?: number;
736
+ }
737
+ /**
738
+ * Placement along a connector path. `'start' | 'center' | 'end'` map to t=0,
739
+ * t=0.5, t=1; numeric `t` is treated literally and clamped to [0, 1].
740
+ */
741
+ type ConnectorLabelPlacement = 'start' | 'center' | 'end' | number;
742
+ /** Style payload for connector labels. */
743
+ interface ConnectorLabelStyle extends LabelStyleCommon {
744
+ /** Default `'center'`. */
745
+ readonly placement?: ConnectorLabelPlacement;
746
+ /**
747
+ * Distance to shift along the path tangent, in pixels. Positive = toward
748
+ * target; negative = toward source. Use this for "pad 24px from source".
749
+ */
750
+ readonly pathOffset?: number;
751
+ /** Rotate the label so its baseline follows the path tangent. Default `true`. */
752
+ readonly autoRotate?: boolean;
753
+ /**
754
+ * When `autoRotate` is on, flip the label by π if the tangent angle lies in
755
+ * (π/2, 3π/2) — keeps reading direction upright. Default `true`.
756
+ */
757
+ readonly keepUpright?: boolean;
758
+ }
759
+
760
+ /**
761
+ * Decoration and effect *descriptions* — what to attach and how it should look.
762
+ * The classes that implement them are renderer-side.
763
+ *
764
+ * Part of the pixi-free spec vocabulary — see `docs/renderer-split-design.md`.
765
+ */
766
+ type EffectTarget = 'transform' | 'style';
767
+ /**
768
+ * Per-frame transform contribution from a `target: 'transform'` effect. Each
769
+ * field is optional and contributes additively (translations + rotation) or
770
+ * multiplicatively (scale) when the renderer aggregates across all transform
771
+ * effects attached to the same host. Omitted fields contribute the identity
772
+ * (0 for additive, 1 for multiplicative).
773
+ *
774
+ * Coordinates are in the host shape's parent space (the renderer's world
775
+ * container) so deltas read like "wiggle the shape 3px right" regardless of
776
+ * the host's internal local origin.
777
+ */
778
+ interface TransformDelta {
779
+ readonly dx?: number;
780
+ readonly dy?: number;
781
+ /** Rotation delta in radians. */
782
+ readonly dRot?: number;
783
+ /** Horizontal scale multiplier. Identity = 1. */
784
+ readonly sx?: number;
785
+ /** Vertical scale multiplier. Identity = 1. */
786
+ readonly sy?: number;
787
+ }
788
+ /**
789
+ * Per-frame style override from a `target: 'style'` effect. Channels are
790
+ * merged across effects with last-writer-wins per channel (insertion order in
791
+ * the host's effect map). Pixi's tint multiplies the underlying fill, so a
792
+ * `tint` of `0xffffff` is the identity.
793
+ */
794
+ interface StyleOverride {
795
+ /** Pixi tint (multiplicative). Identity = `0xffffff`. */
796
+ readonly tint?: number;
797
+ /** Multiplier on the host's current alpha. Identity = 1. */
798
+ readonly alpha?: number;
799
+ }
800
+ /**
801
+ * Information a shape effect receives in `mount` / `update`. No `surface`
802
+ * field — effects don't draw, they modulate. The renderer applies the
803
+ * effect's `readTransform` / `readStyle` output onto the host gfx each frame.
804
+ */
805
+ type EffectTargetKind = 'shape' | 'connector' | 'both';
806
+ interface RegisterEffectOptions {
807
+ readonly target: EffectTargetKind;
808
+ }
809
+ /** Caller-side payload for `setEffect(id, slot, ...)`. */
810
+ interface EffectSpec<TStyle = unknown> {
811
+ readonly kind: string;
812
+ readonly style: TStyle;
813
+ }
814
+ /**
815
+ * Constructor type for shapes registered via `registerShape`. Optionally
816
+ * exposes a `static paintInto` so the shape can also serve as a connector
817
+ * marker. Shapes without `paintInto` cannot be used as markers.
818
+ */
819
+ type DecorationTarget = 'shape' | 'connector' | 'both';
820
+ interface RegisterDecorationOptions {
821
+ readonly target: DecorationTarget;
822
+ }
823
+ /** Caller-side payload for `setDecoration(id, slot, ...)`. */
824
+ interface DecorationSpec<TStyle = unknown> {
825
+ readonly kind: string;
826
+ readonly style: TStyle;
827
+ }
828
+
829
+ /**
830
+ * Decoration and effect **styles** — what a decoration should look like.
831
+ *
832
+ * A style is a description (`{ color, width, alpha }`); the class that renders
833
+ * it is backend-bound and lives with the renderer. Splitting them is what lets
834
+ * `@invana/graph` build decoration specs without depending on a drawing
835
+ * backend — otherwise the type system would recreate the very layering
836
+ * inversion the renderer split exists to remove.
837
+ *
838
+ * Part of the pixi-free spec vocabulary — see `docs/renderer-split-design.md`.
839
+ */
840
+ /**
841
+ * How the underlying host connector should be treated during reveal.
842
+ *
843
+ * - `'hide'` — the host's gfx is set invisible while the decoration is
844
+ * active; the decoration owns the only visible line. On one-shot
845
+ * completion (with `holdAtFull`) the host is restored to visible and the
846
+ * decoration clears its own gfx, so markers + native stroke take over.
847
+ * - `'overlay'` — the host stays visible; the decoration paints a brighter
848
+ * "progress" segment on top. Best for laser-sweep / data-flow visuals on
849
+ * infinite loops.
850
+ */
851
+ type RevealHostStroke = 'hide' | 'overlay';
852
+ /**
853
+ * Visual style of a `SelectionFrameDecoration` — the dashed AABB outline
854
+ * plus a configurable subset of round drag handles. One decoration
855
+ * replaces the 4–8 separate `ResizeHandleDecoration` mounts the resize
856
+ * behaviour used to issue, so callers only manage one slot per host.
857
+ *
858
+ * The decoration is pure-visual: it paints itself and exposes per-handle
859
+ * hit geometry via {@link SelectionFrameDecoration.getLocalHandleHits}.
860
+ * Hit-test math lives in the behaviour, matching the `ToggleDecoration`
861
+ * / `ResizeHandleDecoration` contract.
862
+ */
863
+ /**
864
+ * Border line style. `'solid'` paints a continuous outline; `'dashed'` and
865
+ * `'dotted'` paint a regular gap pattern via Pixi's dashed stroke. Both
866
+ * dash variants pick sensible default dash/gap lengths — supply
867
+ * {@link SelectionFrameDecorationStyle.dashArray} to override them
868
+ * verbatim.
869
+ */
870
+ type SelectionFrameBorderStyle = 'solid' | 'dashed' | 'dotted';
871
+ /**
872
+ * Visual kind of a drag handle. Circles read as "round nub"; squares are
873
+ * the classic CAD/Figma look. Both kinds use the same hit geometry (a
874
+ * disk of radius `handleRadius + HIT_PADDING_PX`) so the resize behaviour
875
+ * doesn't need to branch on shape.
876
+ */
877
+ type SelectionFrameHandleShape = 'circle' | 'square';
878
+ /** Named easings accepted by the reveal style payload. */
879
+ type RevealEasingName = 'linear' | 'easeOutCubic' | 'easeInOutCubic' | 'easeInOutSine';
880
+ /**
881
+ * Direction the reveal grows along the connector path.
882
+ *
883
+ * - `'source-to-target'` — segment grows from the source endpoint toward the
884
+ * target endpoint.
885
+ * - `'target-to-source'` — segment grows from the target endpoint toward the
886
+ * source endpoint.
887
+ */
888
+ type RevealDirection = 'source-to-target' | 'target-to-source';
889
+ /**
890
+ * Repeat semantics for the reveal animation.
891
+ *
892
+ * - `false` — one-shot. Reveal runs once, then either settles fully drawn
893
+ * (`holdAtFull: true`) or clears.
894
+ * - `true` — infinite loop. Reveal restarts from 0 each cycle.
895
+ * - `number` — finite cycle count (must be `>= 1`).
896
+ */
897
+ type RevealRepeat = boolean | number;
898
+ /**
899
+ * Static ring that traces the host silhouette at a fixed outward offset.
900
+ *
901
+ * Geometry: one `paintInto` call with a negative inset, so the ring sits
902
+ * cleanly *outside* the body — independent from the host's own stroke.
903
+ * Multiple rings (e.g. inner + outer) compose by attaching multiple Ring
904
+ * decorations with different `gap` values; this class itself paints one
905
+ * band per instance.
906
+ *
907
+ * Works on every shape that implements `paintInto` (everything extending
908
+ * `ShapeBase`). On shape kinds without `paintInto` (e.g. plain text) the
909
+ * decoration silently clears — same fallback as `GlowDecoration`.
910
+ */
911
+ interface RingDecorationStyle {
912
+ readonly color: number;
913
+ /** Ring stroke thickness, px. Default `2`. */
914
+ readonly width?: number;
915
+ /**
916
+ * Gap between the host silhouette and the ring's inner edge, px.
917
+ * Default `4`. Zero hugs the body; larger values produce a detached ring.
918
+ */
919
+ readonly gap?: number;
920
+ /** Ring alpha, `[0, 1]`. Default `1`. */
921
+ readonly alpha?: number;
922
+ /** Dashed ring — `[dashLength, gapLength]` in px. Default solid. */
923
+ readonly dashArray?: readonly [number, number];
924
+ }
925
+ /**
926
+ * Halo / outer glow. Repaints the host's silhouette N times with widening
927
+ * stroke and quadratic alpha falloff, producing a soft glow that hugs
928
+ * whatever silhouette the host paints. Works on every shape that
929
+ * implements `paintInto` (everything extending `ShapeBase`).
930
+ *
931
+ * Static by default. Supply `pulse` to animate brightness sinusoidally —
932
+ * the renderer will register `tick` and advance the phase each frame.
933
+ */
934
+ interface GlowDecorationStyle {
935
+ readonly color: number;
936
+ /**
937
+ * Outermost feather layer's stroke width, px. The outermost stroke
938
+ * extends this many pixels past the host silhouette (`paintInto`'s
939
+ * default alignment is `'outside'`), so the visual outer reach of the
940
+ * glow matches this value. Inner layers taper linearly to `1` px.
941
+ * Default `12`.
942
+ *
943
+ * Not a circle radius — the glow traces whatever silhouette the host
944
+ * draws (rect / polygon / star / ...). The name reflects the underlying
945
+ * stroke geometry, not the shape kind.
946
+ */
947
+ readonly strokeWidth?: number;
948
+ /** Number of feather layers (more = smoother + more expensive). Default `6`. */
949
+ readonly layers?: number;
950
+ /** Innermost (brightest) layer alpha. Default `0.55`. */
951
+ readonly innerAlpha?: number;
952
+ /**
953
+ * Optional brightness pulse. When omitted, the glow is static. When set,
954
+ * the decoration alpha-multiplies between `1` and `1 - amplitude` on a
955
+ * sinusoidal cycle of `periodMs` milliseconds.
956
+ */
957
+ readonly pulse?: {
958
+ /** Cycle length in ms. Default `1200`. */
959
+ readonly periodMs?: number;
960
+ /** How far below full brightness the dim phase reaches, `[0, 1]`. Default `0.5`. */
961
+ readonly amplitude?: number;
962
+ };
963
+ }
964
+ /**
965
+ * Concentric rings that expand outward from the host's silhouette and fade
966
+ * as they grow. A canonical "attention" decoration — pings, notifications,
967
+ * "new arrival" indicators, sonar effects.
968
+ *
969
+ * Each ring traces the host silhouette via `paintInto` with a growing
970
+ * `inset` (negative = outside) and shrinking alpha. Multiple concurrent
971
+ * rings are scheduled by phase-offset across one period — so a `rings: 3`
972
+ * decoration always shows three rings at different stages of expansion,
973
+ * giving a steady visual rhythm.
974
+ */
975
+ interface PulseRingDecorationStyle {
976
+ readonly color: number;
977
+ /** Peak expansion distance from the host silhouette, px. Default `24`. */
978
+ readonly maxRadius?: number;
979
+ /** Cycle length in ms. Default `1400`. */
980
+ readonly periodMs?: number;
981
+ /** Number of concurrent rings (phase-distributed). Default `2`. */
982
+ readonly rings?: number;
983
+ /** Stroke width of each ring, px. Default `2`. */
984
+ readonly strokeWidth?: number;
985
+ /** Initial (full-brightness) alpha at radius 0. Default `0.7`. */
986
+ readonly innerAlpha?: number;
987
+ }
988
+ /**
989
+ * Classic "marching ants" selection outline. Strokes the host silhouette
990
+ * with a dashed border whose `dashOffset` advances each frame, producing
991
+ * the characteristic crawling-along-the-edge animation seen in selection
992
+ * marquees (Photoshop, Figma, etc.).
993
+ *
994
+ * Geometry is delegated to `host.shape.paintInto` with `dashArray` /
995
+ * `dashOffset` overrides — the shape primitive itself does the
996
+ * silhouette tessellation. Works on every shape that implements
997
+ * `paintInto` (anything extending `ShapeBase`).
998
+ */
999
+ interface MarchingAntsDecorationStyle {
1000
+ readonly color: number;
1001
+ /** Stroke width in px. Default `1.5`. */
1002
+ readonly strokeWidth?: number;
1003
+ /** Dash length in px. Default `6`. */
1004
+ readonly dashLength?: number;
1005
+ /** Gap length in px. Default `4`. */
1006
+ readonly gapLength?: number;
1007
+ /**
1008
+ * March speed in px/sec along the perimeter. Default `24`.
1009
+ * Negative values reverse the march direction.
1010
+ */
1011
+ readonly speedPxPerSec?: number;
1012
+ /**
1013
+ * Distance from the host silhouette. Positive = inside, negative =
1014
+ * outside. Default `0` (on the silhouette itself).
1015
+ */
1016
+ readonly inset?: number;
1017
+ /** Overall decoration alpha. Default `1`. */
1018
+ readonly alpha?: number;
1019
+ }
1020
+ /**
1021
+ * Liquid fill — paints a fluid level inside the host's silhouette, with a
1022
+ * vertical gradient and an optional wavy surface. Achieved without a "fill
1023
+ * provider" hook on shapes: the decoration paints a fluid polygon into its
1024
+ * own Graphics and masks the whole thing with the host silhouette via
1025
+ * `host.shape.paintInto({ fill: true })`.
1026
+ *
1027
+ * **Stroke compatibility.** When the host shape's stroke alignment is
1028
+ * `'outside'`, the stroke sits outside the silhouette and the mask leaves it
1029
+ * fully visible. For `'center'` / `'inside'`, the liquid covers the inside
1030
+ * portion of the stroke. Prefer `'outside'` for tank / pill diagrams.
1031
+ *
1032
+ * **Animation.** When `wave` is omitted the surface is a flat horizontal
1033
+ * line and `tick` returns `false` — the renderer retires the decoration
1034
+ * from its animation set, so still-water mode costs zero per frame after
1035
+ * `mount`. Supply `wave` to animate the meniscus.
1036
+ */
1037
+ interface LiquidFillDecorationStyle {
1038
+ /** Surface height as a fraction of host bounds height. `0` empty, `1` full. Default `0.6`. */
1039
+ readonly fillLevel?: number;
1040
+ /** Gradient colour at the surface. Default light blue (`0x9bbedb`). */
1041
+ readonly colorTop?: number;
1042
+ /** Gradient colour at the bottom. Default dark blue (`0x2d4d6e`). */
1043
+ readonly colorBottom?: number;
1044
+ /** Overall opacity of the fluid. Default `1`. */
1045
+ readonly alpha?: number;
1046
+ /**
1047
+ * Wave configuration. Omit (or pass `undefined`) for a flat still surface.
1048
+ * Provide for an animated meniscus — phase advances every frame.
1049
+ */
1050
+ readonly wave?: {
1051
+ /** Peak vertical displacement of the surface, px. Default `3`. */
1052
+ readonly amplitude?: number;
1053
+ /** Distance between wave crests, px. Default `80`. */
1054
+ readonly wavelength?: number;
1055
+ /** Time for one full phase cycle, ms. Default `1800`. */
1056
+ readonly periodMs?: number;
1057
+ /** Sample points per wavelength. Higher = smoother + more expensive. Default `12`. */
1058
+ readonly resolution?: number;
1059
+ };
1060
+ /**
1061
+ * Optional thin highlight band stroked along the surface (gloss / meniscus
1062
+ * effect). Opt-in: omit the field to skip drawing the highlight entirely.
1063
+ */
1064
+ readonly surfaceHighlight?: {
1065
+ /** Default `0xffffff`. */
1066
+ readonly color?: number;
1067
+ /** Default `0.35`. */
1068
+ readonly alpha?: number;
1069
+ /** Stroke width in px. Default `3`. */
1070
+ readonly thickness?: number;
1071
+ };
1072
+ }
1073
+ /**
1074
+ * Visual style of a `ToggleDecoration` — the small `+` / `−` button used to
1075
+ * collapse / expand compound groups, and by extension any "open this" /
1076
+ * "close this" affordance a domain layer wants to put on a shape.
1077
+ *
1078
+ * The decoration is pure-visual: it paints itself, exposes a shape-local
1079
+ * hit-geometry (`getLocalHitGeometry`), and emits no events. Domain
1080
+ * behaviours (e.g. `CollapseExpandBehaviour` in `@invana/graph`) read the
1081
+ * geometry and do the click-distance math against the host's
1082
+ * `shape:pointerdown` payload — keeps the decoration domain-free and
1083
+ * sidesteps Pixi event-bubbling through the shape gfx.
1084
+ */
1085
+ interface ToggleDecorationStyle {
1086
+ /**
1087
+ * Which glyph the button shows. Domain layers flip this through
1088
+ * `setDecoration` whenever the underlying collapsed-state changes.
1089
+ * Default `'plus'`.
1090
+ */
1091
+ readonly state?: 'plus' | 'minus';
1092
+ /** Where on the host AABB the toggle sits. Default `'bottom'`. */
1093
+ readonly placement?: TogglePlacement;
1094
+ /** Button outer radius, px. Default `10`. */
1095
+ readonly radius?: number;
1096
+ /** Button fill colour. Default `0xffffff` (white). */
1097
+ readonly bgFill?: number;
1098
+ /** Button fill alpha. Default `1`. */
1099
+ readonly bgAlpha?: number;
1100
+ /** Button outline colour. Default `0x6b7fff` (theme blue). */
1101
+ readonly strokeColor?: number;
1102
+ /** Button outline width, px. Default `1.5`. */
1103
+ readonly strokeWidth?: number;
1104
+ /** Glyph stroke colour. Default = `strokeColor`. */
1105
+ readonly glyphColor?: number;
1106
+ /** Glyph stroke width, px. Default `1.5`. */
1107
+ readonly glyphWidth?: number;
1108
+ /**
1109
+ * Extra offset applied after placement resolution, in shape-local px.
1110
+ * Use to nudge the toggle off a default placement without writing a
1111
+ * custom placement (e.g. push a `bottom-right` toggle further out
1112
+ * past a thick stroke).
1113
+ */
1114
+ readonly offsetX?: number;
1115
+ readonly offsetY?: number;
1116
+ /**
1117
+ * Override the keyword-based `placement` resolution with raw shape-local
1118
+ * coordinates. When set, `placement`, `offsetX`, and `offsetY` are all
1119
+ * ignored — the toggle's centre is placed at exactly `(x, y)` in the
1120
+ * host shape's local frame (centre-relative for centred shapes like
1121
+ * `CircleShape`, top-left-relative for `RectShape`).
1122
+ *
1123
+ * Use when none of the 12 named placements lands where you want it
1124
+ * (e.g. floating the toggle along a diagonal, or matching a specific
1125
+ * UI mock that doesn't snap to AABB anchors).
1126
+ */
1127
+ readonly position?: {
1128
+ readonly x: number;
1129
+ readonly y: number;
1130
+ };
1131
+ }
1132
+ /**
1133
+ * Placement of a `ToggleDecoration` relative to the host shape's AABB.
1134
+ *
1135
+ * - Cardinal sides (`top` / `right` / `bottom` / `left`) sit centred on the
1136
+ * midpoint of that side.
1137
+ * - Corners (`top-left` / ... / `bottom-right`) sit on the corner itself.
1138
+ * - `inside-*` variants mirror the cardinal sides but pull inward by
1139
+ * `radius + 4 px` so the toggle nests inside the silhouette (useful for
1140
+ * circle groups where an outside toggle would float well past the rim).
1141
+ *
1142
+ * The toggle's gfx is positioned by its centre, so it half-overlaps the
1143
+ * silhouette edge in the outside variants — a touch-friendly hit target
1144
+ * that visually reads as "attached to the host".
1145
+ */
1146
+ type TogglePlacement = 'top' | 'right' | 'bottom' | 'left' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'inside-top' | 'inside-right' | 'inside-bottom' | 'inside-left';
1147
+ /**
1148
+ * Shape-local hit geometry exposed by a `ToggleDecoration` instance. The
1149
+ * `cx` / `cy` coordinates are in the host shape's local frame (i.e. add
1150
+ * the host's spec `x` / `y` to convert to world). `radius` is the touch
1151
+ * radius — typically a touch larger than the visual radius so the button
1152
+ * stays easy to hit on coarse pointers.
1153
+ *
1154
+ * Domain behaviours read this and check `Math.hypot(worldX − host.x − cx,
1155
+ * worldY − host.y − cy) ≤ radius` in their `shape:pointerdown` handler.
1156
+ */
1157
+ interface ToggleHitGeometry {
1158
+ readonly cx: number;
1159
+ readonly cy: number;
1160
+ readonly radius: number;
1161
+ }
1162
+ interface ResizeHandleDecorationStyle {
1163
+ /** Which AABB position the handle sits on. Default `'bottom-right'`. */
1164
+ readonly placement?: ResizeHandlePlacement;
1165
+ /** Side length of the square handle, px. Default `8`. */
1166
+ readonly size?: number;
1167
+ /** Handle fill colour. Default `0xffffff`. */
1168
+ readonly bgFill?: number;
1169
+ readonly bgAlpha?: number;
1170
+ /** Handle outline colour. Default `0x6b7fff`. */
1171
+ readonly strokeColor?: number;
1172
+ /** Handle outline width. Default `1.5`. */
1173
+ readonly strokeWidth?: number;
1174
+ /** Optional CSS-style cursor hint for the host renderer's hit pipeline. */
1175
+ readonly cursor?: string;
1176
+ /** Visible only when truthy. Domain behaviours flip this on hover/select. Default `true`. */
1177
+ readonly visible?: boolean;
1178
+ /**
1179
+ * Override the keyword-based `placement` resolution with raw shape-local
1180
+ * coordinates. When set, `placement` is ignored — the handle's centre is
1181
+ * placed at exactly `(x, y)` in the host shape's local frame. The
1182
+ * reported hit geometry's `placement` field still reflects the
1183
+ * configured `placement` (or `'bottom-right'` if omitted) so consumers
1184
+ * that switch on it for resize-direction math still work.
1185
+ */
1186
+ readonly position?: {
1187
+ readonly x: number;
1188
+ readonly y: number;
1189
+ };
1190
+ }
1191
+ /**
1192
+ * Where on the host AABB a `ResizeHandleDecoration` sits. The eight cardinal
1193
+ * + corner positions cover every rectangular drag axis (horizontal / vertical
1194
+ * sides, diagonal corners). For radially-symmetric hosts (circle groups) use
1195
+ * any side — domain behaviours typically map all four sides to the same
1196
+ * radius-scaling drag.
1197
+ */
1198
+ type ResizeHandlePlacement = 'top' | 'right' | 'bottom' | 'left' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
1199
+ interface SelectionFrameDecorationStyle {
1200
+ /** Border line colour. Default `0x6b7fff` (theme blue). */
1201
+ readonly borderColor?: number;
1202
+ /** Border line width, px. Default `1.5`. */
1203
+ readonly borderWidth?: number;
1204
+ /**
1205
+ * `'solid'` | `'dashed'` | `'dotted'`. Default `'dotted'` — reads as a
1206
+ * helper / annotation rather than the host's actual outline. When
1207
+ * {@link dashArray} is supplied it wins over this preset.
1208
+ */
1209
+ readonly borderStyle?: SelectionFrameBorderStyle;
1210
+ /**
1211
+ * Custom dash pattern `[dashLength, gapLength]` in px. Overrides
1212
+ * {@link borderStyle} entirely when set — use when the presets don't
1213
+ * land where you want them.
1214
+ */
1215
+ readonly dashArray?: readonly [number, number];
1216
+ /** Border alpha. Default `0.6` — ghosts the frame so the host silhouette reads as the real thing. */
1217
+ readonly borderAlpha?: number;
1218
+ /**
1219
+ * Outward inset between the host AABB and the dashed frame. Lets the
1220
+ * frame visually "wrap" the host without touching the silhouette.
1221
+ * Default `4`.
1222
+ */
1223
+ readonly padding?: number;
1224
+ /** `'circle'` (default) paints round nubs; `'square'` paints squares. */
1225
+ readonly handleShape?: SelectionFrameHandleShape;
1226
+ /**
1227
+ * Half-extent of the handle in px. For circle handles this is the
1228
+ * outer radius; for square handles it's half the side length, so the
1229
+ * visible size matches a circle of the same value. Default `5`.
1230
+ */
1231
+ readonly handleRadius?: number;
1232
+ /**
1233
+ * Corner radius for square handles only. Default `1.5` for a subtly
1234
+ * rounded look; pass `0` for hard corners. Ignored when
1235
+ * `handleShape: 'circle'`.
1236
+ */
1237
+ readonly handleCornerRadius?: number;
1238
+ /** Handle fill colour. Default `0xffffff`. */
1239
+ readonly handleFill?: number;
1240
+ /** Handle fill alpha. Default `1`. */
1241
+ readonly handleFillAlpha?: number;
1242
+ /** Handle outline colour. Default = `borderColor`. */
1243
+ readonly handleStrokeColor?: number;
1244
+ /** Handle outline width in px. Default `1.5`. Pass `0` for no outline. */
1245
+ readonly handleStrokeWidth?: number;
1246
+ /** Handle outline alpha. Default `1`. */
1247
+ readonly handleStrokeAlpha?: number;
1248
+ /**
1249
+ * Which handles to render. Default = all eight. Pass a smaller array to
1250
+ * suppress edge midpoints (`['top-left', 'top-right', 'bottom-left',
1251
+ * 'bottom-right']`) or limit to a single axis (`['right']` for the
1252
+ * radial circle case).
1253
+ */
1254
+ readonly handles?: ReadonlyArray<SelectionFramePlacement>;
1255
+ /** Visible only when truthy. Default `true`. */
1256
+ readonly visible?: boolean;
1257
+ }
1258
+ /**
1259
+ * One of the eight standard transform-frame anchors: corner (`top-left`,
1260
+ * `top-right`, `bottom-left`, `bottom-right`) or edge-midpoint (`top`,
1261
+ * `right`, `bottom`, `left`).
1262
+ *
1263
+ * Re-using `ResizeHandlePlacement`'s vocabulary so any behaviour that
1264
+ * already does direction-aware drag math (corner → diagonal resize,
1265
+ * `top` / `bottom` → vertical, `left` / `right` → horizontal) keeps
1266
+ * working without translation.
1267
+ */
1268
+ type SelectionFramePlacement = 'top' | 'right' | 'bottom' | 'left' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
1269
+ /**
1270
+ * Per-handle hit geometry returned by {@link SelectionFrameDecoration.getLocalHandleHits}.
1271
+ * `cx` / `cy` are in the host shape's local frame (add the host's spec
1272
+ * `x` / `y` to convert to world). `radius` is the touch radius (visual
1273
+ * radius + a small floor for coarse pointers).
1274
+ */
1275
+ interface SelectionFrameHandleHit {
1276
+ readonly placement: SelectionFramePlacement;
1277
+ readonly cx: number;
1278
+ readonly cy: number;
1279
+ readonly radius: number;
1280
+ }
1281
+ /**
1282
+ * Static halo-style ring painted underneath a connector's path — a single
1283
+ * thick stroke tracing the host's routed geometry, behind the host stroke.
1284
+ *
1285
+ * Connectors are 1-D (no `inset`), so a true detached parallel-offset ring
1286
+ * would need separately routed geometry. This decoration takes the simpler
1287
+ * "single wider stroke" route: paint one band of `width` px behind the
1288
+ * host, optionally dashed, with `markerHalo` so the host's end markers
1289
+ * land inside the same band. Composes with `width` < host stroke for a
1290
+ * subtle outline or `width` > host stroke for a "highlighted edge" feel.
1291
+ *
1292
+ * For a thicker / softer feathered halo, use `GlowConnectorDecoration`
1293
+ * instead — it stacks multiple layers with alpha falloff.
1294
+ */
1295
+ interface RingConnectorDecorationStyle {
1296
+ readonly color: number;
1297
+ /** Halo band thickness in px. Default `6`. */
1298
+ readonly width?: number;
1299
+ /** Halo alpha, `[0, 1]`. Default `0.6`. */
1300
+ readonly alpha?: number;
1301
+ /** Dashed band — `[dashLength, gapLength]` in px. Default solid. */
1302
+ readonly dashArray?: readonly [number, number];
1303
+ }
1304
+ /**
1305
+ * Soft halo around the routed path of a connector. Repaints the path N
1306
+ * times with widening stroke and quadratic alpha falloff, producing a
1307
+ * glow that hugs whatever curve the path resolves to. Works on every
1308
+ * router / pathStyle because geometry is delegated to
1309
+ * `host.connector.paintInto`.
1310
+ *
1311
+ * Static by default. Supply `pulse` to animate brightness sinusoidally —
1312
+ * geometry is only repainted on `repaint`; per-frame work touches
1313
+ * `this.gfx.alpha` and nothing else, so the pulse is essentially free.
1314
+ */
1315
+ interface GlowConnectorDecorationStyle {
1316
+ readonly color: number;
1317
+ /** Outermost glow extent in px (widest stroke). Default `12`. */
1318
+ readonly radius?: number;
1319
+ /** Number of feather layers (more = smoother + more expensive). Default `6`. */
1320
+ readonly layers?: number;
1321
+ /** Innermost (brightest) layer alpha. Default `0.55`. */
1322
+ readonly innerAlpha?: number;
1323
+ /**
1324
+ * Optional brightness pulse. When omitted, the glow is static. When set,
1325
+ * the decoration alpha-multiplies between `1` and `1 - amplitude` on a
1326
+ * sinusoidal cycle of `periodMs` milliseconds.
1327
+ */
1328
+ readonly pulse?: {
1329
+ /** Cycle length in ms. Default `1200`. */
1330
+ readonly periodMs?: number;
1331
+ /** How far below full brightness the dim phase reaches, `[0, 1]`. Default `0.5`. */
1332
+ readonly amplitude?: number;
1333
+ };
1334
+ }
1335
+ /**
1336
+ * Connector variant of marching-ants. Strokes the connector's routed path
1337
+ * with a dashed line whose `dashOffset` advances each frame, producing
1338
+ * a flowing/marching pattern along the line — useful for highlighting an
1339
+ * active edge, a route under consideration, a data flow, etc.
1340
+ *
1341
+ * Geometry is delegated to `host.connector.paintInto` with `dashArray` /
1342
+ * `dashOffset` overrides; the connector primitive samples the routed
1343
+ * path and emits dashes via the shared `dashedStroke` helper. Works on
1344
+ * every router / pathStyle (straight, orth, bezier, smooth — all produce
1345
+ * a `Path`).
1346
+ */
1347
+ interface MarchingAntsConnectorDecorationStyle {
1348
+ readonly color: number;
1349
+ /** Stroke width in px. Default `1.5`. */
1350
+ readonly strokeWidth?: number;
1351
+ /** Dash length in px. Default `6`. */
1352
+ readonly dashLength?: number;
1353
+ /** Gap length in px. Default `4`. */
1354
+ readonly gapLength?: number;
1355
+ /**
1356
+ * March speed in px/sec along the path. Default `24`.
1357
+ * Negative values reverse the march direction.
1358
+ */
1359
+ readonly speedPxPerSec?: number;
1360
+ /** Overall decoration alpha. Default `1`. */
1361
+ readonly alpha?: number;
1362
+ readonly cap?: 'butt' | 'round' | 'square';
1363
+ readonly join?: 'miter' | 'round' | 'bevel';
1364
+ }
1365
+ /**
1366
+ * Connector analogue of `PulseRingDecoration`. Each frame, every ring
1367
+ * strokes the host's body + markers at a width that grows outward over
1368
+ * one period and fades as it grows — so the wave inherits the connector's
1369
+ * silhouette (line shape, bends, arrowhead) instead of being a circular
1370
+ * pulse at a single point. Multiple concurrent rings are phase-
1371
+ * distributed across one period for a steady rhythm.
1372
+ *
1373
+ * Geometry is delegated to `connector.paintInto` with a widening
1374
+ * `strokeWidth` and `tintMarkers + markerHalo` (so the markers outline at
1375
+ * the ring's width, not scale up). The host's normal paint sits on top
1376
+ * (zIndex = 0; this decoration's slot z is typically < 0 for "behind"
1377
+ * rings, ≥ 0 for "above" rings — pick a slot name accordingly).
1378
+ */
1379
+ interface RippleConnectorDecorationStyle {
1380
+ readonly color: number;
1381
+ /**
1382
+ * Peak halo extent in px (half-width). Each ring's stroke widens from
1383
+ * `0` to `2 × maxRadius` over one period, so the silhouette appears to
1384
+ * push outward by up to `maxRadius` on each side. Default `16`.
1385
+ */
1386
+ readonly maxRadius?: number;
1387
+ /** Cycle length in ms. Default `1400`. */
1388
+ readonly periodMs?: number;
1389
+ /** Number of concurrent rings (phase-distributed). Default `2`. */
1390
+ readonly rings?: number;
1391
+ /** Initial (full-brightness) alpha at radius 0. Default `0.7`. */
1392
+ readonly innerAlpha?: number;
1393
+ }
1394
+ /**
1395
+ * Connector decoration that animates a single marker travelling along the
1396
+ * routed path of its host. Useful for visualising direction, data flow, or
1397
+ * an active "in-flight" state on an edge. Works on every router / pathStyle
1398
+ * because it consumes the resolved `Path` via `samplePath`.
1399
+ *
1400
+ * The marker's silhouette is drawn once into `markerGfx`; only its position
1401
+ * and rotation are updated each frame. Position is derived from a
1402
+ * cumulative arc-length table rebuilt on `repaint` (host or style change),
1403
+ * so per-frame work is a binary search + interpolation.
1404
+ */
1405
+ interface FlyMarkerConnectorDecorationStyle {
1406
+ readonly color: number;
1407
+ /** Marker silhouette. Default `'circle'`. */
1408
+ readonly markerKind?: 'circle' | 'arrow' | 'square';
1409
+ /** Marker size in px (diameter / arrow length / square side). Default `8`. */
1410
+ readonly size?: number;
1411
+ /**
1412
+ * Travel speed along the path in px/sec. Negative values reverse direction.
1413
+ * Default `80`.
1414
+ */
1415
+ readonly speedPxPerSec?: number;
1416
+ /**
1417
+ * When `true` (default) the marker wraps back to the start after reaching
1418
+ * the end (or vice versa for negative speed). When `false` the marker
1419
+ * stops at the end of the path until the decoration is removed.
1420
+ */
1421
+ readonly loop?: boolean;
1422
+ /** Initial position along the path in `[0, 1]`. Default `0`. */
1423
+ readonly phase?: number;
1424
+ /**
1425
+ * Rotate the marker so its local +x axis points along the local tangent.
1426
+ * Default `true` for `'arrow'`, `false` for `'circle'` and `'square'`.
1427
+ */
1428
+ readonly orientToPath?: boolean;
1429
+ /** Overall decoration alpha. Default `1`. */
1430
+ readonly alpha?: number;
1431
+ }
1432
+ /**
1433
+ * Connector decoration that animates `count` markers travelling along the
1434
+ * routed path at the same speed, evenly spread in phase. Useful for
1435
+ * visualising sustained flow / throughput on an edge (e.g. data streaming,
1436
+ * traffic).
1437
+ *
1438
+ * Same engine as `FlyMarkerConnectorDecoration` extended to N markers; one
1439
+ * arc-length table is built per repaint and shared across all particles.
1440
+ */
1441
+ interface FlowParticlesConnectorDecorationStyle {
1442
+ readonly color: number;
1443
+ /** Marker silhouette. Default `'circle'`. */
1444
+ readonly markerKind?: 'circle' | 'arrow' | 'square';
1445
+ /** Number of particles. Clamped to `>= 1`. Default `5`. */
1446
+ readonly count?: number;
1447
+ /** Marker size in px. Default `6`. */
1448
+ readonly size?: number;
1449
+ /**
1450
+ * Travel speed along the path in px/sec. Negative values reverse direction.
1451
+ * Default `60`.
1452
+ */
1453
+ readonly speedPxPerSec?: number;
1454
+ /**
1455
+ * When `true` (default) particles wrap back to the start after reaching
1456
+ * the end. Setting this to `false` makes all particles stall at the end
1457
+ * once they arrive — usually only useful with `count: 1`.
1458
+ */
1459
+ readonly loop?: boolean;
1460
+ /** Phase offset applied to every particle in `[0, 1]`. Default `0`. */
1461
+ readonly phase?: number;
1462
+ /**
1463
+ * Rotate each marker so its local +x axis points along the local tangent.
1464
+ * Default `true` for `'arrow'`, `false` for `'circle'` and `'square'`.
1465
+ */
1466
+ readonly orientToPath?: boolean;
1467
+ /** Overall decoration alpha. Default `1`. */
1468
+ readonly alpha?: number;
1469
+ }
1470
+ /**
1471
+ * Connector decoration that progressively reveals the routed path from one
1472
+ * endpoint to the other — as if the line were being drawn in real time.
1473
+ * Useful as an entrance animation for new edges, a directional "data-flow"
1474
+ * pulse, or a laser-sweep effect for active routes.
1475
+ *
1476
+ * Implementation: the host `Path` is densified into a polyline on mount
1477
+ * (via `samplePath`); per-frame the decoration computes a cumulative-arc-
1478
+ * length cutoff from the driving `Tween` and emits a `lineTo` walk plus a
1479
+ * single `stroke()` for the revealed segment. Curves stay smooth because
1480
+ * the polyline already uses the engine-wide sampling step counts.
1481
+ *
1482
+ * Markers are intentionally not painted by this decoration. When
1483
+ * `hostStroke: 'hide'` and the animation completes with `holdAtFull: true`,
1484
+ * the host connector's gfx is re-shown so its native stroke + markers
1485
+ * take over the final display. For infinite loops the host stays hidden
1486
+ * for the lifetime of the decoration.
1487
+ */
1488
+ interface RevealConnectorDecorationStyle {
1489
+ /** Duration of one full source→target sweep in ms. Default `2000`. */
1490
+ readonly durationMs?: number;
1491
+ /** `false` = one-shot (default), `true` = infinite, or a positive integer cycle count. */
1492
+ readonly repeat?: RevealRepeat;
1493
+ /** Easing curve. Default `'linear'` — constant "pen speed" feels most natural for a drawing reveal. */
1494
+ readonly easing?: RevealEasingName;
1495
+ /** Sweep direction. Default `'source-to-target'`. */
1496
+ readonly direction?: RevealDirection;
1497
+ /** Treatment of the underlying host connector stroke. Default `'hide'`. */
1498
+ readonly hostStroke?: RevealHostStroke;
1499
+ /**
1500
+ * When `repeat` is `false`, hold the fully-drawn state after the cycle
1501
+ * completes (handing off to the host stroke when `hostStroke: 'hide'`).
1502
+ * Ignored for infinite / finite-repeat modes. Default `true`.
1503
+ */
1504
+ readonly holdAtFull?: boolean;
1505
+ /** Wait this many ms after mount before starting the reveal. Default `0`. */
1506
+ readonly delayMs?: number;
1507
+ }
1508
+
1509
+ /**
1510
+ * Shape specs — the description of a thing to draw, per shape kind.
1511
+ *
1512
+ * Part of the pixi-free spec vocabulary — see `docs/renderer-split-design.md`.
1513
+ */
1514
+
1515
+ interface BaseShapeSpec {
1516
+ readonly kind: string;
1517
+ readonly x: number;
1518
+ readonly y: number;
1519
+ readonly fill?: ShapeFill;
1520
+ readonly stroke?: ShapeStroke;
1521
+ /**
1522
+ * Which paint stripe this shape renders into. Default `'content'` — with
1523
+ * every shape above every connector, the renderer's long-standing
1524
+ * "nodes above edges" convention.
1525
+ *
1526
+ * `'backdrop'` moves the shape **below the connectors**, for scenery rather
1527
+ * than content: a group frame, a swimlane band, a region wash. Purely visual —
1528
+ * hit resolution still reads {@link zIndex} recorded at insert, so a backdrop
1529
+ * shape is picked exactly as it was before.
1530
+ */
1531
+ readonly plane?: PlaneName;
1532
+ /** Default `0`. Higher = on top. Used for hit-test resolution. */
1533
+ readonly zIndex?: number;
1534
+ readonly alpha?: number;
1535
+ readonly visible?: boolean;
1536
+ /**
1537
+ * Container-level rotation in radians, applied around the shape's
1538
+ * top-left local origin. Composes with effect-driven transform deltas
1539
+ * — the effect aggregator writes `(spec.rotation ?? 0) + dRot` per frame
1540
+ * so connector-hosted badges with `autoRotate: true` keep rotating
1541
+ * smoothly even while a `shake` / `breathing` effect runs on top.
1542
+ *
1543
+ * For per-shape geometric rotation (the visible rotation of a regular
1544
+ * polygon's vertices, a star's points, etc.), use the kind-specific
1545
+ * `rotation` field on those shape specs — that one rotates the *geometry*
1546
+ * before it's drawn; this one rotates the *container* after.
1547
+ */
1548
+ readonly rotation?: number;
1549
+ }
1550
+ interface CircleSpec extends BaseShapeSpec {
1551
+ readonly kind: 'circle';
1552
+ readonly radius: number;
1553
+ }
1554
+ /**
1555
+ * Filled / stroked ellipse, centred at `(x, y)` with independent horizontal /
1556
+ * vertical radii. A circle is the `radiusX === radiusY` special case; prefer
1557
+ * {@link CircleSpec} there (cheaper, uniform).
1558
+ */
1559
+ interface EllipseSpec extends BaseShapeSpec {
1560
+ readonly kind: 'ellipse';
1561
+ readonly radiusX: number;
1562
+ readonly radiusY: number;
1563
+ }
1564
+ interface RectSpec extends BaseShapeSpec {
1565
+ readonly kind: 'rect';
1566
+ readonly width: number;
1567
+ readonly height: number;
1568
+ readonly cornerRadius?: number;
1569
+ }
1570
+ /**
1571
+ * Where a {@link TabbedRectSpec}'s tab sits along the body's top edge.
1572
+ * `'left'` / `'right'` measure {@link TabbedRectSpec.tabOffset} in from that
1573
+ * side; `'center'` ignores the offset and splits the remainder evenly.
1574
+ */
1575
+ type TabAlign = 'left' | 'center' | 'right';
1576
+ /**
1577
+ * Rectangle carrying a smaller raised **tab** on its top edge, traced as one
1578
+ * continuous silhouette — the "folder" outline. Fill and stroke run around
1579
+ * body and tab together, so it reads as a single object rather than a rect
1580
+ * with a badge stuck on it.
1581
+ *
1582
+ * Anchored at the **top-left of the full AABB**, i.e. the top-left of the
1583
+ * tab band — so `(spec.x, spec.y)` is the topmost point of the silhouette,
1584
+ * `height` describes the *body* only, and `bounds().height` is
1585
+ * `tabHeight + height`. The body spans `y ∈ [tabHeight, tabHeight + height]`
1586
+ * across the full `width`; the tab spans `tabHeight` above it, inset
1587
+ * horizontally per {@link tabAlign} / {@link tabOffset}.
1588
+ *
1589
+ * A tab as wide as the body degenerates to a plain rect of the combined
1590
+ * height; that's a valid (if pointless) spec, not an error. `height: 0` is
1591
+ * the other degenerate end and a useful one — see {@link TabbedRectSpec.height}.
1592
+ */
1593
+ interface TabbedRectSpec extends BaseShapeSpec {
1594
+ readonly kind: 'tabbed-rect';
1595
+ /** Width of the body — also the AABB width; the tab never exceeds it. */
1596
+ readonly width: number;
1597
+ /**
1598
+ * Height of the **body alone**, excluding {@link tabHeight}.
1599
+ *
1600
+ * `0` (or less) draws the **tab by itself** — a closed folder. The tab's
1601
+ * base becomes an exterior edge (so it takes a fillet and loses the fold
1602
+ * line), the tab is free to lean even when flush with the body's former
1603
+ * edges, and `bounds().height` is just `tabHeight`. Anything anchored to
1604
+ * the silhouette (labels, edges, decorations) follows the tab.
1605
+ */
1606
+ readonly height: number;
1607
+ /**
1608
+ * Width of the raised tab, measured at its base. Clamped to {@link width}
1609
+ * while a body is present; on a bodyless folder (`height <= 0`) the tab is
1610
+ * the whole silhouette, so it sizes freely and *becomes* the AABB width.
1611
+ *
1612
+ * Omit to leave it unresolved — it then falls back to `width` (a full-width
1613
+ * tab), and `ShapeCtor.fitToContent` sizes it to the title the caller
1614
+ * measures. Set it to pin the tab and opt out of that fitting.
1615
+ */
1616
+ readonly tabWidth?: number;
1617
+ /**
1618
+ * Horizontal breathing room between the tab's content and each of its ends,
1619
+ * used when `ShapeCtor.fitToContent` sizes the tab. Default `10`. Ignored
1620
+ * when {@link tabWidth} is pinned.
1621
+ */
1622
+ readonly tabPadding?: number;
1623
+ /** Height of the raised tab, added above the body. */
1624
+ readonly tabHeight: number;
1625
+ /** Fillet applied to the body's outer corners. Default `0` (sharp). */
1626
+ readonly cornerRadius?: number;
1627
+ /**
1628
+ * Fillet applied to the tab's two top corners. Defaults to
1629
+ * {@link cornerRadius} so a uniformly-rounded folder needs one field.
1630
+ * The two re-entrant "shoulder" corners where the tab meets the body
1631
+ * always stay sharp — rounding them reads as a dent, not a fold.
1632
+ */
1633
+ readonly tabCornerRadius?: number;
1634
+ /** Which side the tab hugs. Default `'left'`. */
1635
+ readonly tabAlign?: TabAlign;
1636
+ /**
1637
+ * Distance from the {@link tabAlign} edge to the tab. Default `0` — the
1638
+ * tab is flush with that side, which merges its outer edge into the
1639
+ * body's and produces the classic folder profile. Ignored when
1640
+ * `tabAlign: 'center'`.
1641
+ */
1642
+ readonly tabOffset?: number;
1643
+ /**
1644
+ * Horizontal run of the tab's **angled** side, in px. Default `0` (a
1645
+ * square tab). A non-zero value tapers the tab inward toward its top,
1646
+ * which is what separates a folder tab from a box parked on a rectangle.
1647
+ *
1648
+ * The lean is always on the side facing the rest of the frame — the right
1649
+ * edge for `tabAlign: 'left'`, the left edge for `'right'`, and both for
1650
+ * `'center'`. A side flush with the body's own edge can't lean, since the
1651
+ * two edges have merged.
1652
+ *
1653
+ * {@link tabWidth} measures the tab at its **base**, so the skew eats into
1654
+ * the top edge rather than widening the footprint. Clamped so the slants
1655
+ * can never consume more than half the tab.
1656
+ */
1657
+ readonly tabSkew?: number;
1658
+ /**
1659
+ * Draw the tab's bottom border — the fold line across the tab's base where
1660
+ * it meets the body. Default `true`; set `false` for an open profile where
1661
+ * the tab flows into the body with no seam.
1662
+ *
1663
+ * It's interior geometry, painted only on the shape's own pass: a
1664
+ * decoration borrowing this silhouette (glow, halo, marching ants) traces
1665
+ * the outline alone. It's also skipped when the spec carries no stroke —
1666
+ * it's a border, with no colour of its own to fall back on.
1667
+ */
1668
+ readonly tabDivider?: boolean;
1669
+ }
1670
+ /**
1671
+ * Free-form polygon. `vertices` are centre-relative — the silhouette is
1672
+ * traced around the origin, then translated to `(x, y)`. Closed implicitly:
1673
+ * the last vertex connects back to the first. Use this for arbitrary
1674
+ * outlines (arrows, blobs, callouts). For regular n-gons or stars prefer
1675
+ * `RegularPolygonSpec` / `StarSpec` — they're cheaper to author.
1676
+ */
1677
+ interface PolygonSpec extends BaseShapeSpec {
1678
+ readonly kind: 'polygon';
1679
+ readonly vertices: ReadonlyArray<Point>;
1680
+ }
1681
+ /**
1682
+ * Regular n-gon centred at `(x, y)` with circum-radius `radius`. Covers
1683
+ * triangle (`sides: 3`), pentagon, hexagon (pointy-top by default — pass
1684
+ * `rotation: Math.PI / 6` for flat-top), octagon, etc. `rotation` is in
1685
+ * radians; positive rotates counter-clockwise in screen space.
1686
+ */
1687
+ interface RegularPolygonSpec extends BaseShapeSpec {
1688
+ readonly kind: 'regular-polygon';
1689
+ readonly sides: number;
1690
+ readonly radius: number;
1691
+ readonly rotation?: number;
1692
+ }
1693
+ /**
1694
+ * Annular sector centred at `(x, y)` between radii `innerR`/`outerR` and
1695
+ * angles `startAngle`/`endAngle` (radians). Angle convention: `0` is along
1696
+ * `+x` (3 o'clock); increasing values sweep clockwise on screen.
1697
+ *
1698
+ * Special cases:
1699
+ * - `innerR === 0` → pie slice.
1700
+ * - `endAngle - startAngle >= 2π` and `innerR > 0` → full annulus (ring).
1701
+ * - `endAngle - startAngle >= 2π` and `innerR === 0` → full disc (prefer
1702
+ * `CircleSpec` for that case).
1703
+ *
1704
+ * The natural fit for sunburst / partition layouts where each node is an
1705
+ * arc-shaped region rather than a positioned dot. Pair with
1706
+ * `D3HierarchyLayout({ mode: 'sunburst' })`, which writes the four arc
1707
+ * parameters per node.
1708
+ */
1709
+ interface ArcSpec extends BaseShapeSpec {
1710
+ readonly kind: 'arc';
1711
+ readonly innerR: number;
1712
+ readonly outerR: number;
1713
+ readonly startAngle: number;
1714
+ readonly endAngle: number;
1715
+ }
1716
+ /**
1717
+ * Star centred at `(x, y)`, with `points` outer points alternating between
1718
+ * `outerRadius` and `innerRadius`. Classic 5-point star uses
1719
+ * `points: 5, outerRadius: r, innerRadius: r * 0.4`. `rotation` is in
1720
+ * radians; positive rotates counter-clockwise.
1721
+ */
1722
+ interface StarSpec extends BaseShapeSpec {
1723
+ readonly kind: 'star';
1724
+ readonly points: number;
1725
+ readonly innerRadius: number;
1726
+ readonly outerRadius: number;
1727
+ readonly rotation?: number;
1728
+ }
1729
+ /**
1730
+ * A marker spec is any registered shape spec **without** `x` / `y` — the
1731
+ * connector positions and orients the marker at the polyline endpoint.
1732
+ * Reuses the shape registry: there is no separate marker registry. The
1733
+ * shape's class must expose a static `paintInto` (see `ShapeCtor`).
1734
+ */
1735
+ type MarkerShapeSpec = Omit<BaseShapeSpec, 'x' | 'y'> & {
1736
+ readonly kind: string;
1737
+ };
1738
+ /**
1739
+ * Anchor selection for a `kind: 'shape'` connector endpoint. Resolves the
1740
+ * shape id to a concrete world-space `(x, y)` point on the shape — center of
1741
+ * the bounding box (`'center'`, default), perimeter intersection toward the
1742
+ * other endpoint (`'boundary'`), or any registered custom anchor.
1743
+ *
1744
+ * String shorthand picks an anchor by name with default opts; the object
1745
+ * form passes opts to the anchor function.
1746
+ */
1747
+ /**
1748
+ * Free-form polyline or filled outline. Points are centre-relative, like
1749
+ * {@link PolygonSpec}, but the run is **open by default** — set `closed` to
1750
+ * join the last point back to the first.
1751
+ *
1752
+ * This is the vocabulary for shapes whose geometry is *computed* rather than
1753
+ * parameterised: density-contour bands, bubble-set hulls, region outlines. It
1754
+ * exists so those features can be described as data instead of drawn with a
1755
+ * backend drawing API — see `docs/renderer-split-design.md` §3.
1756
+ */
1757
+ interface PathSpec extends BaseShapeSpec {
1758
+ readonly kind: 'path';
1759
+ /** Centre-relative points, in order. Fewer than 2 renders nothing. */
1760
+ readonly points: readonly Point[];
1761
+ /** Join the last point back to the first. Default `false`. */
1762
+ readonly closed?: boolean;
1763
+ /**
1764
+ * Treat `points` as **off-curve control points** of a closed quadratic spline
1765
+ * through segment midpoints, rather than as straight segments. The result is
1766
+ * C¹ continuous, so marching-squares stair-stepping renders as a smooth
1767
+ * contour without pre-smoothing the data.
1768
+ *
1769
+ * Implies `closed`. Default `false`.
1770
+ */
1771
+ readonly smooth?: boolean;
1772
+ }
1773
+ /** Solid stroke for a {@link CompositePart}. */
1774
+ interface CompositePartStroke {
1775
+ readonly color: number;
1776
+ readonly width?: number;
1777
+ readonly alpha?: number;
1778
+ }
1779
+ /** Solid fill + optional stroke shared by the geometric part kinds. */
1780
+ interface CompositePartFill {
1781
+ readonly fill?: number;
1782
+ readonly fillAlpha?: number;
1783
+ readonly stroke?: CompositePartStroke;
1784
+ }
1785
+ /**
1786
+ * A child element of a composite shape, positioned at a coordinate relative to
1787
+ * the composite's top-left origin.
1788
+ *
1789
+ * - `'rect'` / `'circle'` / `'line'` — geometry traced into the shared body.
1790
+ * Fill/stroke are solid colours (the simple sugar fields here); for gradient /
1791
+ * image / dashed paint, compose dedicated shapes instead.
1792
+ * - `'label'` — a text block. `anchor` picks which horizontal edge of the
1793
+ * measured block lands at `x` (default left); `maxWidth` enables word-wrap,
1794
+ * `maxLines` + `overflow` drive ellipsis.
1795
+ * - `'icon'` — a small vector inset (icon-font `glyph` / `svg` / `svg-url`)
1796
+ * mounted into a `size × size` box at `(x, y)`, reusing the engine's
1797
+ * {@link InsetFillLayer} vocabulary. An optional `background` traces a chip
1798
+ * (e.g. a coloured rounded square) behind the glyph — the type-tag look.
1799
+ *
1800
+ * `rect` / `circle` / `icon` parts may carry a `hitId` to become an addressable
1801
+ * **sub-part**: the renderer reports the topmost `hitId` under a point and turns
1802
+ * it into `shape:partover` / `shape:partout` events (e.g. per-row hover on a
1803
+ * table card). A transparent full-row `rect` with a `hitId` is the idiomatic way
1804
+ * to make a whole row hoverable.
1805
+ */
1806
+ type CompositePart = ({
1807
+ readonly part: 'rect';
1808
+ readonly x: number;
1809
+ readonly y: number;
1810
+ readonly width: number;
1811
+ readonly height: number;
1812
+ readonly cornerRadius?: number;
1813
+ /** Marks this rect as an addressable sub-part for sub-part hit-testing. */
1814
+ readonly hitId?: string;
1815
+ } & CompositePartFill) | ({
1816
+ readonly part: 'circle';
1817
+ readonly x: number;
1818
+ readonly y: number;
1819
+ readonly radius: number;
1820
+ /** Marks this circle as an addressable sub-part for sub-part hit-testing. */
1821
+ readonly hitId?: string;
1822
+ } & CompositePartFill) | {
1823
+ readonly part: 'line';
1824
+ readonly x: number;
1825
+ readonly y: number;
1826
+ readonly x2: number;
1827
+ readonly y2: number;
1828
+ readonly stroke: CompositePartStroke;
1829
+ } | {
1830
+ readonly part: 'label';
1831
+ readonly x: number;
1832
+ readonly y: number;
1833
+ readonly text: string;
1834
+ /** Horizontal anchor of the text block at `(x, y)`. Default `'left'`. */
1835
+ readonly anchor?: 'left' | 'center' | 'right';
1836
+ readonly fontSize?: number;
1837
+ readonly fontWeight?: number | string;
1838
+ readonly fontStyle?: 'normal' | 'italic';
1839
+ readonly fontVariant?: 'normal' | 'small-caps';
1840
+ readonly fill?: number;
1841
+ readonly lineHeight?: number;
1842
+ readonly align?: 'left' | 'center' | 'right';
1843
+ readonly maxWidth?: number;
1844
+ readonly maxLines?: number;
1845
+ readonly overflow?: 'clip' | 'ellipsis';
1846
+ } | {
1847
+ readonly part: 'icon';
1848
+ readonly x: number;
1849
+ readonly y: number;
1850
+ /** Side of the square box the icon is mounted into; the glyph scales to fit. */
1851
+ readonly size: number;
1852
+ /** Icon content — the engine's inset vocabulary (glyph / svg / svg-url). */
1853
+ readonly icon: InsetFillLayer;
1854
+ /** Optional chip traced behind the glyph (the coloured type-tag square). */
1855
+ readonly background?: {
1856
+ readonly fill: number;
1857
+ readonly fillAlpha?: number;
1858
+ readonly cornerRadius?: number;
1859
+ };
1860
+ /** Marks this icon's box as an addressable sub-part for sub-part hit-testing. */
1861
+ readonly hitId?: string;
1862
+ };
1863
+ /**
1864
+ * The composite's **root** (background) shape — an ordinary shape spec the
1865
+ * composite borrows for its silhouette. The composite declares no geometry of
1866
+ * its own: a card can be a rect, circle, polygon, etc. just by changing this.
1867
+ * `x`/`y` are ignored — the composite centres the root in its `width × height`
1868
+ * box.
1869
+ */
1870
+ type CompositeRootSpec = RectSpec | CircleSpec | EllipseSpec | PolygonSpec | RegularPolygonSpec | StarSpec | ArcSpec;
1871
+ /**
1872
+ * Spec for a composite shape. The body is a {@link CompositeSpec.root} shape
1873
+ * sized to the `width × height` box (default: a rounded rect from
1874
+ * `cornerRadius` / the inherited `fill` / `stroke`). `parts` declares ordered
1875
+ * child geometry + labels at coordinates relative to the composite's top-left
1876
+ * origin.
1877
+ */
1878
+ interface CompositeSpec extends BaseShapeSpec {
1879
+ readonly kind: 'composite';
1880
+ readonly width: number;
1881
+ readonly height: number;
1882
+ /** Corner radius for the *default* rounded-rect root. Ignored when {@link root} is set. */
1883
+ readonly cornerRadius?: number;
1884
+ /**
1885
+ * Background silhouette of the card — any ordinary shape spec (rect / circle /
1886
+ * polygon / regular-polygon / star / arc). Omit for a rounded rectangle built
1887
+ * from `cornerRadius` + the inherited `fill` / `stroke`. The composite centres
1888
+ * it in the box and delegates fill, stroke, hit-testing and decorations to it.
1889
+ */
1890
+ readonly root?: CompositeRootSpec;
1891
+ /** Ordered child parts; geometry traced into the body, labels mounted as text. */
1892
+ readonly parts: readonly CompositePart[];
1893
+ /**
1894
+ * Clip the child `parts` (and labels / icons) to the root silhouette. When
1895
+ * `true`, a part that runs to the card edge — a left accent bar, a full-width
1896
+ * header — **follows the rounded corners** instead of poking past them (a
1897
+ * `rect` is square geometry and can't round a corner on its own). Off by
1898
+ * default; decorations (hover ring / halo) are never clipped.
1899
+ */
1900
+ readonly clip?: boolean;
1901
+ }
1902
+ /**
1903
+ * Every built-in shape spec. A discriminated union on `kind`, so the pure
1904
+ * geometry functions in `specs/shapeGeometry/` can narrow without a cast.
1905
+ *
1906
+ * Not closed: `registerShape` admits third-party kinds the engine has never
1907
+ * heard of, which is why the geometry dispatchers accept a `BaseShapeSpec` and
1908
+ * answer `undefined` for a kind they don't know.
1909
+ */
1910
+ type ShapeSpec = CircleSpec | EllipseSpec | RectSpec | TabbedRectSpec | PolygonSpec | RegularPolygonSpec | StarSpec | ArcSpec | PathSpec | CompositeSpec;
1911
+
1912
+ /**
1913
+ * Badge descriptions — small shapes pinned to a host element.
1914
+ *
1915
+ * Pixi-free by construction: a badge says *what* to pin and *where*, never how
1916
+ * it is drawn. Lives in the spec vocabulary so domain packages can describe
1917
+ * badges without depending on a drawing backend.
1918
+ *
1919
+ */
1920
+
1921
+ /**
1922
+ * Anchor point on a host shape's axis-aligned bounding box.
1923
+ *
1924
+ * - The eight named values address the corners (`top-left`, …,
1925
+ * `bottom-right`) and edge midpoints (`top` / `bottom` / `left` /
1926
+ * `right`).
1927
+ * - The `{ x, y }` variant is a **raw world-space point** that bypasses the
1928
+ * host AABB entirely. Use it when the badge needs to anchor at a position
1929
+ * that has no relation to the host's bounds (e.g. an interaction-driven
1930
+ * custom anchor); the badge re-anchors against this point the same way
1931
+ * named placements re-anchor against the host bounds.
1932
+ */
1933
+ type BadgePlacement = NamedBadgePlacement | {
1934
+ readonly x: number;
1935
+ readonly y: number;
1936
+ };
1937
+ /**
1938
+ * The eight named anchor points on a host AABB — corners and edge midpoints.
1939
+ * The named-only subset of {@link BadgePlacement}; used by
1940
+ * {@link BadgeOptions.origin} (which never accepts a raw point) and by
1941
+ * internal mirror-math that only makes sense for the named cases.
1942
+ */
1943
+ type NamedBadgePlacement = 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
1944
+ /**
1945
+ * Anchor point along a connector host's routed path.
1946
+ *
1947
+ * - `'start'` / `'end'` — anchored *near* the source / target endpoint with
1948
+ * automatic clearance: the badge is shifted tangentially by its own
1949
+ * half-extent so it kisses the endpoint shape's silhouette from outside
1950
+ * rather than half-overlapping it. Use these when you want a badge
1951
+ * visually associated with an endpoint (count chip, status icon).
1952
+ * - `'middle'` — exact arc-length midpoint (`t = 0.5`).
1953
+ * - A `number` in `[0, 1]` — raw arc-length `t`. **No clearance is
1954
+ * applied** — `placement: 1` literally anchors at the silhouette point,
1955
+ * the "raw" counterpart to `'end'`. Values outside `[0, 1]` are clamped.
1956
+ *
1957
+ * `'middle'` (not `'center'`) avoids the term clash with
1958
+ * {@link BadgeOptions.origin} where `'center'` means "centre the badge on
1959
+ * its own AABB". For loop edges (`pathType: 'loop-*'`), `'middle'`
1960
+ * naturally lands on the loop apex because the path passes through it at
1961
+ * `t ≈ 0.5`.
1962
+ */
1963
+ type ConnectorBadgePlacement = 'start' | 'middle' | 'end' | number;
1964
+ /**
1965
+ * Shape spec accepted by `BadgeOptions.shape` — every `BaseShapeSpec` field
1966
+ * except `x` / `y` (placement supplies those), plus an open index for the
1967
+ * kind-specific fields each shape adds (`radius` on `CircleSpec`, `width` /
1968
+ * `height` / `cornerRadius` on `RectSpec`, future shape extras).
1969
+ *
1970
+ * The renderer doesn't validate kind-specific fields here — that happens
1971
+ * inside the registered shape's constructor. Keeping this type open avoids
1972
+ * enumerating every shape kind in the badge type surface.
1973
+ */
1974
+ type BadgeShapeSpec = Omit<BaseShapeSpec, 'x' | 'y'> & {
1975
+ readonly [extraField: string]: unknown;
1976
+ };
1977
+ /**
1978
+ * Options for `PrimitivesRenderer.setBadge`. The `shape` field carries the
1979
+ * full shape spec (any kind + fill + stroke + kind-specific fields);
1980
+ * placement is interpreted differently depending on the host kind (shape
1981
+ * AABB vs. connector path) — see {@link placement}.
1982
+ *
1983
+ * The path-only fields ({@link pathOffset}, {@link autoRotate},
1984
+ * {@link keepUpright}) are ignored when the host is a shape.
1985
+ */
1986
+ interface BadgeOptions {
1987
+ /** The badge plate as a shape spec, sans `x` / `y` (placement provides position). */
1988
+ readonly shape: BadgeShapeSpec;
1989
+ /**
1990
+ * Where the badge attaches to its host.
1991
+ *
1992
+ * - **Shape host** — one of {@link BadgePlacement}: a named AABB anchor
1993
+ * (corner / edge midpoint) or a raw `{x, y}` world point.
1994
+ * - **Connector host** — one of {@link ConnectorBadgePlacement}: `'start'`,
1995
+ * `'middle'`, `'end'`, or an arc-length `t ∈ [0, 1]`.
1996
+ *
1997
+ * The host kind is resolved at `setBadge` time from the `hostId`; mismatches
1998
+ * (a named-AABB placement on a connector host, or `'middle'` on a shape
1999
+ * host) throw with a clear error.
2000
+ */
2001
+ readonly placement: BadgePlacement | ConnectorBadgePlacement;
2002
+ /** Pixel offset applied after origin resolution. Default `0` for both. */
2003
+ readonly offsetX?: number;
2004
+ readonly offsetY?: number;
2005
+ /**
2006
+ * **Connector hosts only.** Shift the path-anchor along the local tangent
2007
+ * direction (positive = forward toward `'end'`, negative = backward toward
2008
+ * `'start'`). Useful for nudging a `'middle'`-anchored badge sideways
2009
+ * along the line without changing its `t`. Ignored on shape hosts.
2010
+ */
2011
+ readonly pathOffset?: number;
2012
+ /**
2013
+ * **Connector hosts only.** When `true`, the badge's `rotation` follows
2014
+ * the path tangent at the anchor point — i.e. the badge tilts to read
2015
+ * along the line. Default `false`. Ignored on shape hosts.
2016
+ */
2017
+ readonly autoRotate?: boolean;
2018
+ /**
2019
+ * **Connector hosts only.** When {@link autoRotate} is `true`, flip the
2020
+ * badge by 180° if the tangent points "downwards" so its top edge always
2021
+ * faces the viewer (text remains readable on every edge orientation).
2022
+ * Default `true`. Ignored on shape hosts.
2023
+ */
2024
+ readonly keepUpright?: boolean;
2025
+ /**
2026
+ * Which point of the badge's own AABB lands at the host anchor.
2027
+ *
2028
+ * - **`undefined`** (default): mirror of `placement`. The badge sits fully
2029
+ * outside the host edge — e.g. `placement: 'top-right'` puts the badge's
2030
+ * bottom-left corner at the host's top-right corner. (When `placement`
2031
+ * is a raw `{x, y}` point with no inherent mirror, the default falls
2032
+ * back to `'center'`.)
2033
+ * - **`'center'`**: the badge centres on the anchor and half-overhangs
2034
+ * the host edge (the gray "A" pattern in the reference design).
2035
+ * - **A named `BadgePlacement`**: any of the eight points on the badge.
2036
+ * The raw `{x, y}` variant of `BadgePlacement` is not valid here —
2037
+ * origin is always a named point on the badge.
2038
+ */
2039
+ readonly origin?: NamedBadgePlacement | 'center';
2040
+ /**
2041
+ * Decorations applied to the badge shape, keyed by slot. Internally each
2042
+ * entry becomes a `setDecoration(badgeId, slot, spec)` call, so any
2043
+ * registered decoration kind (glow, ring, marching-ants, …) works.
2044
+ */
2045
+ readonly decorations?: Readonly<Record<string, DecorationSpec>>;
2046
+ /**
2047
+ * Effects applied to the badge shape, keyed by slot. Internally each entry
2048
+ * becomes a `setEffect(badgeId, slot, spec)` call, so any registered shape
2049
+ * effect (`shake`, `breathing`, …) modulates the badge's transform / style
2050
+ * the same way it would a free-standing shape.
2051
+ *
2052
+ * Lifecycle parity with `decorations`: replacing the badge via `setBadge`
2053
+ * disposes prior effects; removing the host disposes the badge and all its
2054
+ * effects.
2055
+ */
2056
+ readonly effects?: Readonly<Record<string, EffectSpec>>;
2057
+ }
2058
+
2059
+ /**
2060
+ * Connector specs, endpoints and the anchor contract.
2061
+ *
2062
+ * Part of the pixi-free spec vocabulary — see `docs/renderer-split-design.md`.
2063
+ */
2064
+
2065
+ type AnchorSpec = string | {
2066
+ readonly name: string;
2067
+ readonly opts?: Readonly<Record<string, unknown>>;
2068
+ };
2069
+ type ConnectorEndpointSpec = {
2070
+ readonly kind: 'point';
2071
+ readonly x: number;
2072
+ readonly y: number;
2073
+ readonly tangent?: Vec2;
2074
+ } | {
2075
+ readonly kind: 'shape';
2076
+ readonly shapeId: string;
2077
+ readonly anchor?: AnchorSpec;
2078
+ /**
2079
+ * Outward offset applied AFTER the anchor resolves. The anchor's
2080
+ * returned `tangent` is treated as the outward direction; the endpoint
2081
+ * moves by `tangent * padding` world units before reaching the router.
2082
+ *
2083
+ * Use cases:
2084
+ * - Halo / glow decoration extends beyond the silhouette → set
2085
+ * `padding` to the halo's outer radius so the connector visibly
2086
+ * starts at the halo's edge, not at the shape's tight boundary.
2087
+ * - Visual breathing room around tightly packed shapes.
2088
+ *
2089
+ * No-op when the chosen anchor returns no tangent (e.g. `center`).
2090
+ * Negative values pull the endpoint INWARD; default `0`.
2091
+ */
2092
+ readonly padding?: number;
2093
+ };
2094
+ /**
2095
+ * Read-only view of a shape that an anchor function consumes. The renderer
2096
+ * builds one of these for the referenced shape id and hands it to the
2097
+ * registered anchor. Anchors operate against this — they never see the live
2098
+ * `ShapeInstance` or `Pixi` objects.
2099
+ *
2100
+ * **Origin vs centre.** `origin` is the shape's spec position `(spec.x,
2101
+ * spec.y)` — this is the top-left for `RectShape`, the centre for
2102
+ * `CircleShape`, and shape-dependent for others. `center` is the geometric
2103
+ * centre of the bounding box in world space, computed by the renderer from
2104
+ * `origin` + `bounds`. Anchors should reference `center` (not `origin`) so
2105
+ * their behaviour is uniform across shape kinds.
2106
+ */
2107
+ interface AnchorShapeRef {
2108
+ /** World-space origin of the shape (`(spec.x, spec.y)`). */
2109
+ readonly origin: Point;
2110
+ /** Local-space axis-aligned bounding box (relative to `origin`). */
2111
+ readonly bounds: Rect;
2112
+ /** World-space geometric centre of the shape's bounding box. */
2113
+ readonly center: Point;
2114
+ /**
2115
+ * Optional analytical boundary-intersection in shape-local coordinates,
2116
+ * relative to the shape's geometric **centre** (not its `origin`).
2117
+ * Anchors fall back to a default centred-AABB ray-exit when this is
2118
+ * absent. `localFromCenter` is the other endpoint's offset from the
2119
+ * shape's centre.
2120
+ */
2121
+ boundaryIntersect?(localFromCenter: Point): Point | null;
2122
+ }
2123
+ interface AnchorCtx {
2124
+ getShape(id: string): AnchorShapeRef | undefined;
2125
+ }
2126
+ /**
2127
+ * Anchor: a pure function that resolves a `kind: 'shape'` endpoint to a
2128
+ * concrete world-space point on the referenced shape.
2129
+ *
2130
+ * - `endpoint` carries the shape id and any per-call opts.
2131
+ * - `fromPoint` is the OTHER endpoint's first-pass world point — used by
2132
+ * `boundary` to project a ray toward it. Anchors that don't need it
2133
+ * (`center`) ignore it.
2134
+ * - The returned `Endpoint` may include an outward `tangent` hint; routers
2135
+ * that respect it (`orthogonal`, `er`, …) prefer it over heuristics.
2136
+ */
2137
+ type IAnchor = (endpoint: {
2138
+ readonly shapeId: string;
2139
+ readonly opts?: Readonly<Record<string, unknown>>;
2140
+ }, fromPoint: Point, ctx: AnchorCtx) => Endpoint;
2141
+ interface BaseConnectorSpec {
2142
+ readonly kind: string;
2143
+ readonly source: ConnectorEndpointSpec;
2144
+ readonly target: ConnectorEndpointSpec;
2145
+ /** Intermediate user-supplied points the router must respect. Optional. */
2146
+ readonly waypoints?: ReadonlyArray<Point>;
2147
+ /** Registered router kind. Default `'straight'`. */
2148
+ readonly router?: string;
2149
+ /** Per-router options forwarded to the router fn's `opts` parameter. */
2150
+ readonly routerOpts?: Readonly<Record<string, unknown>>;
2151
+ /** Registered pathStyle kind. Default `'normal'`. */
2152
+ readonly pathStyle?: string;
2153
+ /** Per-pathStyle options forwarded to the pathStyle fn's `opts` parameter. */
2154
+ readonly pathStyleOpts?: Readonly<Record<string, unknown>>;
2155
+ /** Optional shape spec painted at the source endpoint, oriented along the path tangent. */
2156
+ readonly sourceMarker?: MarkerShapeSpec;
2157
+ /** Optional shape spec painted at the target endpoint, oriented along the path tangent. */
2158
+ readonly targetMarker?: MarkerShapeSpec;
2159
+ readonly stroke?: ShapeStroke;
2160
+ readonly zIndex?: number;
2161
+ readonly alpha?: number;
2162
+ readonly visible?: boolean;
2163
+ }
2164
+
2165
+ /**
2166
+ * Hit-test result shape.
2167
+ *
2168
+ * Part of the pixi-free spec vocabulary — see `docs/renderer-split-design.md`.
2169
+ */
2170
+ interface HitResult {
2171
+ readonly kind: 'shape' | 'connector';
2172
+ readonly id: string;
2173
+ /** Optional sub-region (e.g. a connector handle, a shape sub-part). */
2174
+ readonly subId?: string;
2175
+ }
2176
+
2177
+ /**
2178
+ * Renderer-reported statistics. Fields are advisory and backend-specific.
2179
+ *
2180
+ * Part of the pixi-free spec vocabulary — see `docs/renderer-split-design.md`.
2181
+ */
2182
+ interface RenderStats {
2183
+ readonly shapes: number;
2184
+ readonly connectors: number;
2185
+ readonly animatedDecorations: number;
2186
+ }
2187
+
2188
+ /**
2189
+ * Polygon maths shared by every spec kind whose silhouette is (or densifies
2190
+ * to) a closed vertex ring — `polygon`, `regular-polygon`, `star`,
2191
+ * `tabbed-rect`, `path`, and the sampled `arc` fallback.
2192
+ *
2193
+ * Pure functions over plain `{x, y}` arrays in shape-local space. No drawing
2194
+ * library, and nothing from `primitives/` — this file is what lets picking and
2195
+ * bounds be answered with no GPU (see `docs/renderer-split-design.md` §4.5,
2196
+ * "what stays engine-side").
2197
+ *
2198
+ * Convention: all vertex arrays here are **centre-relative** — the silhouette
2199
+ * is traced around the origin so that `boundaryIntersect` (which receives
2200
+ * centre-relative input) works without an extra translation step. The one
2201
+ * exception is `tabbed-rect`, whose outline is AABB-origin-relative; it says so
2202
+ * at its own call sites.
2203
+ */
2204
+
2205
+ /** Tight axis-aligned bounding box around the vertex list. */
2206
+ declare function polygonBounds(vertices: ReadonlyArray<Point>): Rect;
2207
+ /**
2208
+ * Even-odd ray-cast point-in-polygon test. Handles convex and concave
2209
+ * silhouettes. Treats the polygon as closed (last vertex implicitly
2210
+ * connects to first).
2211
+ */
2212
+ declare function pointInPolygon(localX: number, localY: number, vertices: ReadonlyArray<Point>): boolean;
2213
+ /** Squared distance from `(px, py)` to the segment `(x1, y1) → (x2, y2)`. */
2214
+ declare function distanceToSegmentSq(px: number, py: number, x1: number, y1: number, x2: number, y2: number): number;
2215
+ /**
2216
+ * Squared distance from `(x, y)` to the nearest **edge** of a vertex ring.
2217
+ * `closed` includes the wrap-around edge (last → first); an open run omits it,
2218
+ * which is what a `path` spec with `closed: false` draws.
2219
+ */
2220
+ declare function distanceToOutlineSq(x: number, y: number, vertices: ReadonlyArray<Point>, closed?: boolean): number;
2221
+ /**
2222
+ * Containment against a vertex ring **grown (or shrunk) by `pad`**.
2223
+ *
2224
+ * - `pad > 0` — inside the ring *or* within `pad` of its outline. This is the
2225
+ * region a centred stroke of half-width `pad` covers, and it is exactly the
2226
+ * union pixi's `Graphics.containsPoint` reports for a filled + stroked
2227
+ * polygon (`Polygon.contains` ∪ `Polygon.strokeContains`).
2228
+ * - `pad < 0` — inside the ring *and* further than `|pad|` from its outline:
2229
+ * the silhouette eroded inward, used to punch the hole out of a
2230
+ * fill-less shape so only its stroke band answers `true`.
2231
+ *
2232
+ * The offset is a true distance offset (round joins at convex corners), not a
2233
+ * miter offset, so a spike's tip grows by `pad` rather than by `pad / sin(θ/2)`
2234
+ * — the same approximation pixi makes.
2235
+ */
2236
+ declare function polygonContainsInflated(x: number, y: number, vertices: ReadonlyArray<Point>, pad?: number, closed?: boolean): boolean;
2237
+ /**
2238
+ * Parallel-offset a closed polygon by `distance` along each edge's inward
2239
+ * normal. Positive `distance` shrinks (inset); negative grows (outset).
2240
+ *
2241
+ * Each vertex is moved along the **bisector** of its two adjacent edge
2242
+ * normals, scaled so the perpendicular offset along the edges equals
2243
+ * `distance`. Sufficient for convex and mildly concave silhouettes — the
2244
+ * regular-polygon and star convenience kinds always produce well-behaved
2245
+ * shapes, free-form polygon insets are best-effort and may self-intersect at
2246
+ * extreme concavities.
2247
+ */
2248
+ declare function offsetPolygon(vertices: ReadonlyArray<Point>, distance: number): Point[];
2249
+ /**
2250
+ * Vertices of a regular polygon with `sides` sides and circum-radius
2251
+ * `radius`, centred at the origin. `rotationRad` is added to the base angle.
2252
+ *
2253
+ * Base placement: first vertex at angle `-π/2 + rotationRad` (straight up).
2254
+ * So with `rotation = 0`: triangle (sides=3) points up, pentagon points up,
2255
+ * hexagon has a vertex at the top (pointy-top). For a flat-top hexagon, pass
2256
+ * `rotation = Math.PI / 6`.
2257
+ */
2258
+ declare function regularPolygonVertices(sides: number, radius: number, rotationRad: number): Point[];
2259
+ /**
2260
+ * Vertices of a star with `points` outer points, alternating outer
2261
+ * (`outerRadius`) and inner (`innerRadius`) vertices around the origin.
2262
+ * `rotationRad` is added to the base angle.
2263
+ *
2264
+ * Base placement: first outer vertex at angle `-π/2 + rotationRad` (up).
2265
+ */
2266
+ declare function starVertices(points: number, innerRadius: number, outerRadius: number, rotationRad: number): Point[];
2267
+ /**
2268
+ * Ray from the origin toward `localFromCenter`, intersected with the polygon
2269
+ * silhouette. Returns the farthest hit (i.e. where the ray exits the
2270
+ * polygon) as a centre-relative point, or `null` if the ray doesn't cross
2271
+ * any edge.
2272
+ *
2273
+ * Used by `boundaryIntersect` to snap connector anchors to the exact
2274
+ * perimeter of polygonal shapes.
2275
+ */
2276
+ declare function rayPolygonIntersection(localFromCenter: Point, vertices: ReadonlyArray<Point>): Point | null;
2277
+ /**
2278
+ * One vertex of a {@link roundedPolygonOutline} input ring: a corner point
2279
+ * plus the fillet radius to apply there. `r <= 0` keeps the corner sharp.
2280
+ */
2281
+ interface RoundedCorner extends Point {
2282
+ readonly r: number;
2283
+ }
2284
+ /**
2285
+ * Densify a closed corner ring into a polyline, replacing each corner that
2286
+ * carries `r > 0` with a tangent circular fillet.
2287
+ *
2288
+ * Works for **convex and concave** corners alike — the fillet centre is
2289
+ * placed along the corner's interior bisector, which flips side with the
2290
+ * corner's turn direction automatically. That's what lets a silhouette with
2291
+ * re-entrant corners (a folder's tab shoulder, a callout's notch) round its
2292
+ * outer corners while leaving the re-entrant ones sharp.
2293
+ *
2294
+ * The requested radius is clamped so a fillet can never consume more than
2295
+ * half of either adjacent edge, so authored radii larger than the geometry
2296
+ * degrade gracefully instead of self-intersecting. Arcs are sampled at
2297
+ * roughly one vertex per 2 px of arc length (min 2 segments), matching the
2298
+ * density the rounded-rect outline sampler uses.
2299
+ *
2300
+ * Output winds in the same direction as the input ring, starting at the
2301
+ * first corner (or the start of its fillet when it has one).
2302
+ */
2303
+ declare function roundedPolygonOutline(corners: ReadonlyArray<RoundedCorner>): Point[];
2304
+
2305
+ /**
2306
+ * The `tabbed-rect` (manila folder) silhouette, as pure maths.
2307
+ *
2308
+ * Every edge coordinate the outline, fold line, label box, bounds and hit test
2309
+ * are built from is resolved here, from the spec alone. It lives in `specs/`
2310
+ * rather than beside the renderer because the folder's footprint is a genuine
2311
+ * property of the *description* — a layout asking how big a container frame is,
2312
+ * an SVG export tracing it, and a headless hit-test all need the same answer
2313
+ * without a GPU (`docs/renderer-split-design.md` §4.5).
2314
+ *
2315
+ * Coordinates are **AABB-origin-relative**: `(0, 0)` is the top-left of the
2316
+ * full silhouette, which is the tab band's top-left when the tab is flush left.
2317
+ */
2318
+
2319
+ /** A tabbed-rect spec with its world position removed — geometry only. */
2320
+ type TabbedRectGeometrySpec = Omit<TabbedRectSpec, 'x' | 'y'>;
2321
+ /**
2322
+ * Every edge coordinate the silhouette, fold line and label box are built
2323
+ * from, resolved once against `inset`. `null` when the inset has collapsed the
2324
+ * geometry to nothing.
2325
+ *
2326
+ * The inset is applied analytically per edge rather than via a polygon offset:
2327
+ * the re-entrant shoulder corners make a bisector offset unstable, and all but
2328
+ * the slanted edges are axis-aligned, so the exact answer is one addition.
2329
+ */
2330
+ interface TabbedRectGeometry {
2331
+ left: number;
2332
+ right: number;
2333
+ bottom: number;
2334
+ /** Top of the tab — the silhouette's topmost edge. */
2335
+ tabTop: number;
2336
+ /** Where the tab meets the body; the fold line's y. */
2337
+ shoulder: number;
2338
+ /** Tab extent at its **base**, where it meets the body. */
2339
+ tabLeft: number;
2340
+ tabRight: number;
2341
+ /** Tab extent at its **top**, narrowed by the slant on whichever side leans. */
2342
+ tabTopLeft: number;
2343
+ tabTopRight: number;
2344
+ flushLeft: boolean;
2345
+ flushRight: boolean;
2346
+ /**
2347
+ * `true` when `spec.height <= 0` and the silhouette is the tab alone — the
2348
+ * closed folder. `left` / `right` / `bottom` describe the tab, and there is
2349
+ * no fold line. See {@link bodylessGeometryOf}.
2350
+ */
2351
+ bodyless: boolean;
2352
+ }
2353
+ /**
2354
+ * Resolved tab width: the declared {@link TabbedRectSpec.tabWidth}, falling
2355
+ * back to the body's width when it's left unset (a full-width tab).
2356
+ *
2357
+ * Clamped to the body while there is one — a tab can't outgrow the rectangle
2358
+ * it sits on. A bodyless folder's tab *is* the silhouette, so it sizes freely.
2359
+ */
2360
+ declare function tabbedRectTabWidth(spec: TabbedRectGeometrySpec): number;
2361
+ /**
2362
+ * AABB of the folder.
2363
+ *
2364
+ * Bodyless (`height <= 0`): the tab *is* the silhouette, so it's also the
2365
+ * footprint — the declared body width describes a rectangle that isn't being
2366
+ * drawn. Everything positioned against the AABB (the label box, decorations,
2367
+ * edge anchors) therefore lands on the tab.
2368
+ */
2369
+ declare function tabbedRectBounds(spec: TabbedRectGeometrySpec): Rect;
2370
+ /**
2371
+ * The folder, closed: body gone, tab kept. `width` is deliberately left alone —
2372
+ * {@link tabbedRectBounds} already reports the tab as the footprint once the
2373
+ * body is gone, so rewriting it would double-apply.
2374
+ */
2375
+ declare function collapsedTabbedRect(_spec: TabbedRectGeometrySpec): Partial<TabbedRectSpec>;
2376
+ /**
2377
+ * Size the tab to the content it carries — the title.
2378
+ *
2379
+ * The taper eats into the tab's top edge, so the slant's run is added on top of
2380
+ * the text budget; otherwise leaning the tab would push the title into the
2381
+ * taper. A centred tab leans on both sides.
2382
+ *
2383
+ * The clamp to `width` applies **only while there's a body**: a tab can't
2384
+ * outgrow the rectangle it sits on, but a closed folder is nothing *but* its
2385
+ * tab, so it sizes to the whole title rather than ellipsising it. Returns
2386
+ * nothing when {@link TabbedRectSpec.tabWidth} is pinned.
2387
+ */
2388
+ declare function fitTabbedRectToContent(spec: TabbedRectGeometrySpec, content: {
2389
+ readonly width: number;
2390
+ readonly height: number;
2391
+ }): Partial<TabbedRectSpec>;
2392
+ /** Uniform scale of every length the folder carries. */
2393
+ declare function scaleTabbedRect(spec: TabbedRectGeometrySpec, factor: number): Partial<TabbedRectSpec>;
2394
+ /**
2395
+ * Trace the folder silhouette into a polyline, inset by `inset` on every side.
2396
+ * Winds clockwise from the tab's top-left corner.
2397
+ *
2398
+ * The two re-entrant shoulders stay sharp; the convex corners take a fillet.
2399
+ * Rounding a shoulder reads as a dent rather than a fold.
2400
+ */
2401
+ declare function tabbedRectOutline(spec: TabbedRectGeometrySpec, inset?: number): Point[];
2402
+ /**
2403
+ * The tab's bottom border — the fold where the tab meets the body — as a
2404
+ * two-point segment, or `undefined` when `tabDivider` is off or the geometry
2405
+ * has collapsed. Spans the tab's **base**, so with a flush tab it starts on the
2406
+ * body's own edge and the two borders meet cleanly.
2407
+ */
2408
+ declare function tabbedRectFoldLine(spec: TabbedRectGeometrySpec, inset?: number): [Point, Point] | undefined;
2409
+ /**
2410
+ * The tab's **upright** box — its full-height portion, with the slant excluded
2411
+ * on whichever side is angled. This is where the folder's own label belongs:
2412
+ * the body interior belongs to whatever the frame contains, so a title centred
2413
+ * against this box stays put no matter how large the body grows.
2414
+ */
2415
+ declare function tabbedRectTabBox(spec: TabbedRectGeometrySpec, inset?: number): Rect | undefined;
2416
+ /** Resolve every edge coordinate of the folder against `inset`. */
2417
+ declare function tabbedRectGeometry(spec: TabbedRectGeometrySpec, inset: number): TabbedRectGeometry | null;
2418
+
2419
+ /**
2420
+ * Per-kind spec measurement: **bounds**, **uniform scale**, **collapse** and
2421
+ * **fit-to-content**, as pure functions of the spec.
2422
+ *
2423
+ * These four used to live as `static` methods on the renderer-side shape
2424
+ * classes. They are not drawing — they are properties of the description, and
2425
+ * a layout, an exporter or a headless test needs them with no GPU in the
2426
+ * process. The shape classes now delegate here, so there is one implementation
2427
+ * per kind (`docs/renderer-split-design.md` §9, P4).
2428
+ *
2429
+ * Every function takes the spec **without** `x` / `y`: bounds are local, so the
2430
+ * world position is the caller's business.
2431
+ */
2432
+
2433
+ /** A spec of kind `K` with its world position removed — geometry only. */
2434
+ type LocalSpec<T> = Omit<T, 'x' | 'y'>;
2435
+ declare function boundsOfCircle(spec: LocalSpec<CircleSpec>): Rect;
2436
+ declare function scaleCircle(spec: LocalSpec<CircleSpec>, factor: number): Partial<CircleSpec>;
2437
+ declare function boundsOfEllipse(spec: LocalSpec<EllipseSpec>): Rect;
2438
+ declare function scaleEllipse(spec: LocalSpec<EllipseSpec>, factor: number): Partial<EllipseSpec>;
2439
+ /** Anchored top-left, so the local box starts at the origin. */
2440
+ declare function boundsOfRect(spec: LocalSpec<RectSpec>): Rect;
2441
+ declare function scaleRect(spec: LocalSpec<RectSpec>, factor: number): Partial<RectSpec>;
2442
+ declare function boundsOfPolygon(spec: LocalSpec<PolygonSpec>): Rect;
2443
+ declare function scalePolygon(spec: LocalSpec<PolygonSpec>, factor: number): Partial<PolygonSpec>;
2444
+ /** The n-gon's vertices at its authored size, centred on the origin. */
2445
+ declare function verticesOfRegularPolygon(spec: LocalSpec<RegularPolygonSpec>): Point[];
2446
+ declare function boundsOfRegularPolygon(spec: LocalSpec<RegularPolygonSpec>): Rect;
2447
+ declare function scaleRegularPolygon(spec: LocalSpec<RegularPolygonSpec>, factor: number): Partial<RegularPolygonSpec>;
2448
+ /** The star's alternating outer / inner vertices, centred on the origin. */
2449
+ declare function verticesOfStar(spec: LocalSpec<StarSpec>): Point[];
2450
+ declare function boundsOfStar(spec: LocalSpec<StarSpec>): Rect;
2451
+ declare function scaleStar(spec: LocalSpec<StarSpec>, factor: number): Partial<StarSpec>;
2452
+ /**
2453
+ * Axis-aligned bounding box for an annular sector. The extreme points are
2454
+ * either on the four sector corners (a0/inner, a0/outer, a1/inner, a1/outer)
2455
+ * or at the cardinal angles (0, π/2, π, 3π/2) on the outer radius if those
2456
+ * angles fall inside the sweep — those produce the (±outerR, 0) / (0, ±outerR)
2457
+ * extents.
2458
+ */
2459
+ declare function boundsOfArc(spec: LocalSpec<ArcSpec>): Rect;
2460
+ declare function scaleArc(spec: LocalSpec<ArcSpec>, factor: number): Partial<ArcSpec>;
2461
+ declare function boundsOfPath(spec: LocalSpec<PathSpec>): Rect;
2462
+ declare function scalePath(spec: LocalSpec<PathSpec>, factor: number): Partial<PathSpec>;
2463
+ /**
2464
+ * The composite's silhouette fills its declared box (like a rect), whatever
2465
+ * root shape it borrows — the root is centred and sized to that box. Layouts
2466
+ * (ELK et al.) read node dimensions through this; without it every card falls
2467
+ * back to the layout's default size and they overlap.
2468
+ */
2469
+ declare function boundsOfComposite(spec: Pick<CompositeSpec, 'width' | 'height'>): Rect;
2470
+ /**
2471
+ * The composite's effective root spec: the explicit
2472
+ * {@link CompositeSpec.root}, or the default rounded rect built from
2473
+ * `cornerRadius` + the inherited `fill` / `stroke`.
2474
+ */
2475
+ declare function resolveCompositeRoot(spec: CompositeSpec): CompositeRootSpec;
2476
+ /** Local bounds of whichever shape a composite borrows for its silhouette. */
2477
+ declare function boundsOfCompositeRoot(root: CompositeRootSpec): Rect;
2478
+ /**
2479
+ * Translation from the composite's top-left origin to the borrowed root's own
2480
+ * local origin — the offset that centres the root in the `width × height` box.
2481
+ *
2482
+ * Origin-agnostic by construction: it works off the root's *bounding-box*
2483
+ * centre, so a rect (top-left origin) and a circle (centred origin) both land
2484
+ * in the middle of the card. The renderer applies exactly this before tracing
2485
+ * the root, which is why hit-testing has to apply it too.
2486
+ */
2487
+ declare function compositeRootOffset(spec: CompositeSpec): Point;
2488
+
2489
+ /**
2490
+ * Pure geometric containment, per spec kind — the engine's hit-test narrow
2491
+ * phase with no GPU in it.
2492
+ *
2493
+ * ## Why this exists
2494
+ *
2495
+ * Picking used to ask the backend: `bodyGfx.containsPoint(...)`, i.e. pixi
2496
+ * walked the instructions it had recorded while painting. That made the answer
2497
+ * depend on a display object existing, so picking could not be tested headlessly
2498
+ * and would have left the engine with the renderer under the P6 extraction
2499
+ * (`docs/renderer-split-design.md` §5 — "geometry answers must not require the
2500
+ * backend"). Here the answer comes from the spec alone, so every backend agrees
2501
+ * by construction.
2502
+ *
2503
+ * ## Matching pixi
2504
+ *
2505
+ * `Graphics.containsPoint` is a **union over painted instructions**: a `fill`
2506
+ * instruction answers `shape.contains`, a `stroke` instruction answers
2507
+ * `shape.strokeContains`. Two consequences are reproduced here deliberately:
2508
+ *
2509
+ * 1. **A shape with no silhouette fill is hollow.** No fill was painted, so only
2510
+ * the stroke band answers `true` — clicking the middle of an outline-only
2511
+ * contour misses it, exactly as it does today.
2512
+ * 2. **The stroke widens the region by its alignment split**: `'center'`
2513
+ * (default) puts half the width outside and half inside, `'outside'` puts all
2514
+ * of it outside, `'inside'` all of it inside. That mirrors pixi's
2515
+ * `outerWidth = (1 - alignment) * width`.
2516
+ *
2517
+ * Coordinates are **shape-local** — `(0, 0)` is the shape's own origin (centre
2518
+ * for circle / ellipse / polygon / star / arc, top-left for rect / tabbed-rect /
2519
+ * composite), i.e. the caller has already subtracted `spec.x` / `spec.y` and
2520
+ * divided out any renderer-applied scale.
2521
+ */
2522
+
2523
+ /**
2524
+ * How far a stroke pushes the hit region past the silhouette (`outer`) and how
2525
+ * far it reaches back inside it (`inner`).
2526
+ *
2527
+ * Mirrors pixi's split: `outer = (1 - alignment) * width`, `inner = width -
2528
+ * outer`, with the engine's `'inside' | 'center' | 'outside'` mapping to
2529
+ * pixi's `1 | 0.5 | 0` alignment. A missing or non-positive width paints
2530
+ * nothing, so it widens nothing.
2531
+ */
2532
+ declare function strokeBandOf(stroke: ShapeStroke | undefined): {
2533
+ outer: number;
2534
+ inner: number;
2535
+ };
2536
+ declare function containsCircle(spec: LocalSpec<CircleSpec>, localX: number, localY: number, pad?: number): boolean;
2537
+ declare function containsEllipse(spec: LocalSpec<EllipseSpec>, localX: number, localY: number, pad?: number): boolean;
2538
+ declare function containsRect(spec: LocalSpec<RectSpec>, localX: number, localY: number, pad?: number): boolean;
2539
+ declare function containsPolygon(spec: LocalSpec<PolygonSpec>, localX: number, localY: number, pad?: number): boolean;
2540
+ declare function containsRegularPolygon(spec: LocalSpec<RegularPolygonSpec>, localX: number, localY: number, pad?: number): boolean;
2541
+ declare function containsStar(spec: LocalSpec<StarSpec>, localX: number, localY: number, pad?: number): boolean;
2542
+ declare function containsTabbedRect(spec: LocalSpec<TabbedRectSpec>, localX: number, localY: number, pad?: number): boolean;
2543
+ /**
2544
+ * An open path is tested against its **run**, not a phantom closed area: only a
2545
+ * `closed` (or `smooth`, which implies closed) path has an interior, matching
2546
+ * the paint path, which fills only when closed. So an unfilled contour line
2547
+ * answers `true` along its stroke and nowhere else.
2548
+ *
2549
+ * `smooth` paths are approximated by the control polygon rather than the
2550
+ * quadratic spline it generates. The spline passes through the segment
2551
+ * midpoints and bulges toward each control point, so the two differ by at most
2552
+ * half a segment's sagitta — a fraction of a pixel at contour densities.
2553
+ */
2554
+ declare function containsPath(spec: LocalSpec<PathSpec>, localX: number, localY: number, pad?: number): boolean;
2555
+ /**
2556
+ * Annular sector, tested analytically rather than against a sampled outline:
2557
+ * radius inside `[innerR, outerR]` and angle inside the sweep, each relaxed by
2558
+ * `pad`. Outside the sweep the nearest point of the sector lies on one of the
2559
+ * two straight radial edges, so the padded test falls back to a distance check
2560
+ * against those two segments.
2561
+ */
2562
+ declare function containsArc(spec: LocalSpec<ArcSpec>, localX: number, localY: number, pad?: number): boolean;
2563
+ /**
2564
+ * A composite is its **root silhouette** (centred in the card box) plus every
2565
+ * geometric part painted on top of it. Parts are included because they are
2566
+ * painted into the same `Graphics` the backend hit-tests today: a part that
2567
+ * pokes outside the root — an accent bar on an unclipped card — is clickable,
2568
+ * and stays clickable here.
2569
+ *
2570
+ * `label` parts are excluded: they are mounted as text children, not painted
2571
+ * into the body, so they never contributed a hit region.
2572
+ */
2573
+ declare function containsComposite(spec: CompositeSpec, localX: number, localY: number, pad?: number): boolean;
2574
+ /**
2575
+ * Does `(localX, localY)` fall inside the region this spec paints?
2576
+ *
2577
+ * `strokeTolerance` overrides the widening the spec's own stroke would imply
2578
+ * (both inward and outward). Omit it and the band is derived from
2579
+ * `spec.stroke` — width and alignment — which is what the renderer wants: the
2580
+ * hit region then tracks whatever the shape actually draws.
2581
+ *
2582
+ * Returns `undefined` for a kind this module doesn't know. That is not a
2583
+ * failure: `registerShape` admits third-party kinds, and the caller falls back
2584
+ * to asking the instance (`IShape.getHitArea`). Distinguishing "not contained"
2585
+ * from "cannot answer" is the whole point of the `boolean | undefined` return.
2586
+ */
2587
+ declare function containsSpec(spec: BaseShapeSpec, localX: number, localY: number, strokeTolerance?: number): boolean | undefined;
2588
+
2589
+ /**
2590
+ * Spec geometry — bounds, scale, collapse, fit and containment, computed from a
2591
+ * spec and nothing else.
2592
+ *
2593
+ * This is the half of the old shape classes that was never really drawing: the
2594
+ * `static boundsOf` / `scaleSpec` / `collapsedOf` / `fitToContent` methods, plus
2595
+ * the new `contains`. They live here so a layout can size a node, an exporter
2596
+ * can trace a silhouette and a test can pick a shape with no backend mounted —
2597
+ * and so they stay in `@invana/canvas` when the pixi renderer is extracted
2598
+ * (`docs/renderer-split-design.md` §9, P4).
2599
+ *
2600
+ * The renderer-side shape classes now delegate to these functions; the maths
2601
+ * exists once.
2602
+ */
2603
+
2604
+ /**
2605
+ * Local bounds of any built-in spec kind, or `undefined` for a kind this module
2606
+ * doesn't know.
2607
+ *
2608
+ * `undefined` is a real answer, not a failure: `registerShape` admits
2609
+ * third-party kinds, so callers that must cover those ask the registry (which
2610
+ * consults the class's `static boundsOf`) and fall back to a default box.
2611
+ */
2612
+ declare function boundsOfSpec(spec: BaseShapeSpec): Rect | undefined;
2613
+ /**
2614
+ * Uniformly scale a spec's geometry by `factor`, as a partial patch to merge
2615
+ * onto it. Paint is untouched — only lengths.
2616
+ *
2617
+ * The contract: `boundsOfSpec(scaleSpec(spec, k)).width === boundsOfSpec(spec).width * k`
2618
+ * (likewise height). `undefined` for kinds with no meaningful uniform scale
2619
+ * (`composite` sizes off its box and its parts, so scaling it needs the layer's
2620
+ * intent, not a geometric rule).
2621
+ */
2622
+ declare function scaleSpec(spec: BaseShapeSpec, factor: number): Record<string, unknown> | undefined;
2623
+ /**
2624
+ * The spec "as small as it goes" — what a collapsed container renders as.
2625
+ * Purely geometric: the kind decides what collapsing means to it. `undefined`
2626
+ * when the kind has no collapsed form, and callers then keep the spec as is.
2627
+ */
2628
+ declare function collapsedSpec(spec: BaseShapeSpec): Record<string, unknown> | undefined;
2629
+ /**
2630
+ * Size the spec's geometry to a measured block of content (a title, a label).
2631
+ * The caller measures — text metrics belong to the backend — and the kind turns
2632
+ * that size into geometry. `undefined` when the kind doesn't size to content.
2633
+ */
2634
+ declare function fitSpecToContent(spec: BaseShapeSpec, content: {
2635
+ readonly width: number;
2636
+ readonly height: number;
2637
+ }): Record<string, unknown> | undefined;
2638
+
2639
+ /**
2640
+ * Element-level pointer events — what a drawing backend reports about the
2641
+ * shapes and connectors it holds.
2642
+ *
2643
+ * Part of the pixi-free spec vocabulary: every payload is plain data in world
2644
+ * coordinates, so a domain behaviour subscribes to these without knowing which
2645
+ * backend produced them. Canvas-wide input (`input:camera:*`) lives on the
2646
+ * kernel bus instead; this is the element-scoped channel.
2647
+ */
2648
+
2649
+ interface ElementEventMap extends EventMap {
2650
+ 'shape:pointerover': {
2651
+ id: string;
2652
+ worldX: number;
2653
+ worldY: number;
2654
+ };
2655
+ 'shape:pointerout': {
2656
+ id: string;
2657
+ worldX: number;
2658
+ worldY: number;
2659
+ };
2660
+ 'shape:pointerdown': {
2661
+ id: string;
2662
+ worldX: number;
2663
+ worldY: number;
2664
+ button: number;
2665
+ pointerId: number;
2666
+ };
2667
+ 'shape:pointerup': {
2668
+ id: string;
2669
+ worldX: number;
2670
+ worldY: number;
2671
+ button: number;
2672
+ pointerId: number;
2673
+ };
2674
+ /** Left-button click. Right-button → `shape:contextmenu`. */
2675
+ 'shape:click': {
2676
+ id: string;
2677
+ worldX: number;
2678
+ worldY: number;
2679
+ button: number;
2680
+ };
2681
+ 'shape:doubleclick': {
2682
+ id: string;
2683
+ worldX: number;
2684
+ worldY: number;
2685
+ button: number;
2686
+ };
2687
+ 'shape:contextmenu': {
2688
+ id: string;
2689
+ worldX: number;
2690
+ worldY: number;
2691
+ };
2692
+ /**
2693
+ * Sub-part pointer transitions — fired only for shapes that implement
2694
+ * {@link IShape.hitTestPart} (e.g. a composite card with `hitId`-tagged
2695
+ * parts). `partId` is the id the shape returned for the point under the
2696
+ * cursor. `partover` fires on entering a part; `partout` on leaving it (to
2697
+ * another part of the same shape, or off the shape entirely).
2698
+ */
2699
+ 'shape:partover': {
2700
+ id: string;
2701
+ partId: string;
2702
+ worldX: number;
2703
+ worldY: number;
2704
+ };
2705
+ 'shape:partout': {
2706
+ id: string;
2707
+ partId: string;
2708
+ };
2709
+ /**
2710
+ * Right-click over a hittable sub-part. Emitted *instead of*
2711
+ * `shape:contextmenu` when the cursor is over a `hitId`-tagged part, so a
2712
+ * consumer can show a part-scoped menu (e.g. a field row) and reserve the
2713
+ * shape-level menu for the rest of the card.
2714
+ */
2715
+ 'shape:partcontextmenu': {
2716
+ id: string;
2717
+ partId: string;
2718
+ worldX: number;
2719
+ worldY: number;
2720
+ };
2721
+ 'connector:pointerover': {
2722
+ id: string;
2723
+ worldX: number;
2724
+ worldY: number;
2725
+ };
2726
+ 'connector:pointerout': {
2727
+ id: string;
2728
+ worldX: number;
2729
+ worldY: number;
2730
+ };
2731
+ 'connector:pointerdown': {
2732
+ id: string;
2733
+ worldX: number;
2734
+ worldY: number;
2735
+ button: number;
2736
+ pointerId: number;
2737
+ };
2738
+ 'connector:pointerup': {
2739
+ id: string;
2740
+ worldX: number;
2741
+ worldY: number;
2742
+ button: number;
2743
+ pointerId: number;
2744
+ };
2745
+ /** Left-button click. Right-button → `connector:contextmenu`. */
2746
+ 'connector:click': {
2747
+ id: string;
2748
+ worldX: number;
2749
+ worldY: number;
2750
+ button: number;
2751
+ };
2752
+ 'connector:doubleclick': {
2753
+ id: string;
2754
+ worldX: number;
2755
+ worldY: number;
2756
+ button: number;
2757
+ };
2758
+ 'connector:contextmenu': {
2759
+ id: string;
2760
+ worldX: number;
2761
+ worldY: number;
2762
+ };
2763
+ /** Right-button release on empty canvas — no shape/connector was hit. */
2764
+ 'background:contextmenu': {
2765
+ worldX: number;
2766
+ worldY: number;
2767
+ };
2768
+ }
2769
+
2770
+ export { type InsetFillLayer as $, type AnchorCtx as A, type BaseShapeSpec as B, type CameraTransform as C, type DecorationSpec as D, type EffectSpec as E, type FlushMode as F, type ConnectorLabelPlacement as G, type HitResult as H, type IAnchor as I, type ConnectorLabelStyle as J, type ConnectorPaintStyle as K, type Listener as L, type DecorationTarget as M, type EffectTarget as N, type EffectTargetKind as O, type Point as P, type EllipseSpec as Q, type Rect as R, type SpecFlush as S, type Endpoint as T, type FlowParticlesConnectorDecorationStyle as U, type Vec2 as V, type FlyMarkerConnectorDecorationStyle as W, type GlowConnectorDecorationStyle as X, type GlowDecorationStyle as Y, type HtmlTagStyle as Z, type InsetAnchor as _, SpecStore as a, boundsOfRegularPolygon as a$, type LabelBackground as a0, type LabelStyleCommon as a1, type LabelVisibility as a2, type LiquidFillDecorationStyle as a3, type LocalSpec as a4, type MarchingAntsConnectorDecorationStyle as a5, type MarchingAntsDecorationStyle as a6, type MarkerShapeSpec as a7, type NamedBadgePlacement as a8, type Obstacle as a9, type SelectionFrameHandleHit as aA, type SelectionFrameHandleShape as aB, type SelectionFramePlacement as aC, type ShapeFillLayer as aD, type ShapeLabelPlacement as aE, type ShapeLabelStyle as aF, type ShapePaintStyle as aG, type ShapeSpec as aH, type Size as aI, type StarSpec as aJ, type StyleOverride as aK, type TabAlign as aL, type TabbedRectGeometry as aM, type TabbedRectGeometrySpec as aN, type TabbedRectSpec as aO, type ToggleDecorationStyle as aP, type ToggleHitGeometry as aQ, type TogglePlacement as aR, type TransformDelta as aS, boundsOfArc as aT, boundsOfCircle as aU, boundsOfComposite as aV, boundsOfCompositeRoot as aW, boundsOfEllipse as aX, boundsOfPath as aY, boundsOfPolygon as aZ, boundsOfRect as a_, type PathCommand as aa, type PathSpec as ab, type PathStyleEndpoints as ac, type PlaneName as ad, type PolygonSpec as ae, type Polyline as af, type PulseRingDecorationStyle as ag, type RectSpec as ah, type RegisterDecorationOptions as ai, type RegisterEffectOptions as aj, type RegularPolygonSpec as ak, type RenderStats as al, type ResizeHandleDecorationStyle as am, type ResizeHandlePlacement as an, type RevealConnectorDecorationStyle as ao, type RevealDirection as ap, type RevealEasingName as aq, type RevealHostStroke as ar, type RevealRepeat as as, type RingConnectorDecorationStyle as at, type RingDecorationStyle as au, type RippleConnectorDecorationStyle as av, type RoundedCorner as aw, type RouterCtx as ax, type SelectionFrameBorderStyle as ay, type SelectionFrameDecorationStyle as az, type BaseConnectorSpec as b, boundsOfSpec as b0, boundsOfStar as b1, collapsedSpec as b2, collapsedTabbedRect as b3, compositeRootOffset as b4, connectorGeometryKey as b5, containsArc as b6, containsCircle as b7, containsComposite as b8, containsEllipse as b9, scaleRegularPolygon as bA, scaleSpec as bB, scaleStar as bC, scaleTabbedRect as bD, scheduleFlush as bE, starVertices as bF, strokeBandOf as bG, tabbedRectBounds as bH, tabbedRectFoldLine as bI, tabbedRectGeometry as bJ, tabbedRectOutline as bK, tabbedRectTabBox as bL, tabbedRectTabWidth as bM, verticesOfRegularPolygon as bN, verticesOfStar as bO, containsPath as ba, containsPolygon as bb, containsRect as bc, containsRegularPolygon as bd, containsSpec as be, containsStar as bf, containsTabbedRect as bg, distanceToOutlineSq as bh, distanceToSegmentSq as bi, fitSpecToContent as bj, fitTabbedRectToContent as bk, hasSilhouetteFill as bl, offsetPolygon as bm, pointInPolygon as bn, polygonBounds as bo, polygonContainsInflated as bp, rayPolygonIntersection as bq, regularPolygonVertices as br, resolveCompositeRoot as bs, roundedPolygonOutline as bt, scaleArc as bu, scaleCircle as bv, scaleEllipse as bw, scalePath as bx, scalePolygon as by, scaleRect as bz, type BadgeOptions as c, type LabelContent as d, type LabelWrap as e, EventEmitter as f, type ElementEventMap as g, type EventMap as h, type IRouter as i, type IPathStyle as j, type Path as k, type BadgePlacement as l, type ShapeFill as m, type ShapeStroke as n, type AnchorShapeRef as o, type AnchorSpec as p, type ArcSpec as q, type BadgeShapeSpec as r, type CircleSpec as s, type CompositePart as t, type CompositePartFill as u, type CompositePartStroke as v, type CompositeRootSpec as w, type CompositeSpec as x, type ConnectorBadgePlacement as y, type ConnectorEndpointSpec as z };