@doki-land/davinci 0.0.0-stage → 0.3.17

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,214 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ /** 2D point / vector (x, y). */
4
+ export interface Point2D {
5
+ readonly x: number;
6
+ readonly y: number;
7
+ }
8
+ /** Affine 2D transform matrix (3x3, column-major compact form).
9
+ *
10
+ * ```text
11
+ * | a c tx |
12
+ * | b d ty |
13
+ * | 0 0 1 |
14
+ * ```
15
+ *
16
+ * Standard affine transforms (translate, scale, rotate, skew) compose via
17
+ * {@link multiplyTransform}.
18
+ */
19
+ export interface Affine2D {
20
+ readonly a: number;
21
+ readonly b: number;
22
+ readonly c: number;
23
+ readonly d: number;
24
+ readonly tx: number;
25
+ readonly ty: number;
26
+ }
27
+ /** A segment of a path — one of the SVG/Cubic-like command primitives. */
28
+ export type PathCommand = {
29
+ readonly kind: "move";
30
+ readonly to: Point2D;
31
+ } | {
32
+ readonly kind: "line";
33
+ readonly to: Point2D;
34
+ } | {
35
+ readonly kind: "cubic";
36
+ readonly cp1: Point2D;
37
+ readonly cp2: Point2D;
38
+ readonly to: Point2D;
39
+ } | {
40
+ readonly kind: "quadratic";
41
+ readonly cp: Point2D;
42
+ readonly to: Point2D;
43
+ } | {
44
+ readonly kind: "arc";
45
+ readonly rx: number;
46
+ readonly ry: number;
47
+ readonly xRot: number;
48
+ readonly largeArc: boolean;
49
+ readonly sweep: boolean;
50
+ readonly to: Point2D;
51
+ } | {
52
+ readonly kind: "close";
53
+ };
54
+ /** A simple path = sequence of commands, optionally closed. */
55
+ export interface Path {
56
+ readonly commands: ReadonlyArray<PathCommand>;
57
+ }
58
+ /** Canonical sRGB color with alpha (0–1 each). */
59
+ export interface RGBA {
60
+ readonly r: number;
61
+ readonly g: number;
62
+ readonly b: number;
63
+ readonly a: number;
64
+ }
65
+ /** Axis-aligned rectangle (x, y is top-left, w/h non-negative). */
66
+ export interface Rect {
67
+ readonly x: number;
68
+ readonly y: number;
69
+ readonly w: number;
70
+ readonly h: number;
71
+ }
72
+ /** Semantic alias — used by Scene packages for clarity. */
73
+ export type BoundsRect = Rect;
74
+ declare const SCENE_VERSION = "/v0";
75
+ export type SceneVersion = typeof SCENE_VERSION;
76
+ /** Final stroke style (resolved). */
77
+ export interface DisplayStroke {
78
+ readonly color: RGBA;
79
+ readonly width: number;
80
+ readonly dash?: ReadonlyArray<number>;
81
+ }
82
+ /** Final fill style (resolved). */
83
+ export interface DisplayFill {
84
+ readonly color: RGBA;
85
+ }
86
+ /** A resolved node — everything is final; no upstream semantics leak through. */
87
+ export interface DisplayNodeBase {
88
+ /** Fully composed transform (local * parent chain). */
89
+ readonly worldTransform: Affine2D;
90
+ /** Inherited-and-intersected clip rect (if any). */
91
+ readonly worldClip?: BoundsRect;
92
+ /** Final axis-aligned bounds in world space. */
93
+ readonly bounds: BoundsRect;
94
+ /** Stable domain id — present only when the host resolved with
95
+ * `preserveNodeIds`, so interactive hosts can bind DOM elements back to
96
+ * semantic identity. Renderers never depend on it. */
97
+ readonly id?: string;
98
+ }
99
+ export interface DisplayGroup extends DisplayNodeBase {
100
+ readonly kind: "group";
101
+ readonly children: ReadonlyArray<DisplayNode>;
102
+ }
103
+ export interface DisplayPath extends DisplayNodeBase {
104
+ readonly kind: "path";
105
+ readonly path: Path;
106
+ readonly stroke?: DisplayStroke;
107
+ readonly fill?: DisplayFill;
108
+ }
109
+ export interface DisplayRect extends DisplayNodeBase {
110
+ readonly kind: "rect";
111
+ readonly x: number;
112
+ readonly y: number;
113
+ readonly w: number;
114
+ readonly h: number;
115
+ readonly rx: number;
116
+ readonly ry: number;
117
+ readonly stroke?: DisplayStroke;
118
+ readonly fill?: DisplayFill;
119
+ }
120
+ export interface DisplayEllipse extends DisplayNodeBase {
121
+ readonly kind: "ellipse";
122
+ readonly cx: number;
123
+ readonly cy: number;
124
+ readonly rx: number;
125
+ readonly ry: number;
126
+ readonly stroke?: DisplayStroke;
127
+ readonly fill?: DisplayFill;
128
+ }
129
+ export interface DisplayImage extends DisplayNodeBase {
130
+ readonly kind: "image";
131
+ readonly resourceRef: string;
132
+ readonly x: number;
133
+ readonly y: number;
134
+ readonly w: number;
135
+ readonly h: number;
136
+ }
137
+ export interface DisplayText extends DisplayNodeBase {
138
+ readonly kind: "text";
139
+ readonly text: string;
140
+ /** CSS font string — host-formatted from FontSpec. */
141
+ readonly fontCss: string;
142
+ readonly anchor: {
143
+ x: number;
144
+ y: number;
145
+ };
146
+ readonly color: RGBA;
147
+ }
148
+ export type DisplayNode = DisplayGroup | DisplayPath | DisplayRect | DisplayEllipse | DisplayImage | DisplayText;
149
+ /** The root of a display scene. Always a group. */
150
+ export interface DisplayScene {
151
+ /** Contract namespace this scene was resolved under (`/v0` before 1.0.0). */
152
+ readonly version: SceneVersion;
153
+ readonly root: DisplayGroup;
154
+ /** Optional background color. */
155
+ readonly background?: RGBA;
156
+ /** Logical canvas dimensions. */
157
+ readonly width: number;
158
+ readonly height: number;
159
+ }
160
+ /** A matched pair across two scenes. */
161
+ export interface SceneMatch {
162
+ readonly id: string;
163
+ readonly from: DisplayNode | null;
164
+ readonly to: DisplayNode | null;
165
+ }
166
+ /** Match nodes between two scenes by node id (stable identity). */
167
+ export declare function matchScenes(prev: DisplayScene | null, next: DisplayScene): ReadonlyArray<SceneMatch>;
168
+ /** Easing function — t ∈ [0, 1] → t ∈ [0, 1]. */
169
+ export type EasingFn = (t: number) => number;
170
+ /** Preset easing names. */
171
+ export type EasingPreset = "linear" | "ease" | "ease-in" | "ease-out" | "ease-in-out";
172
+ /** Animatable property. */
173
+ export type AnimatableProp = "x" | "y" | "w" | "h" | "cx" | "cy" | "rx" | "ry" | "opacity" | "color" | "transform";
174
+ /** One property animation segment. */
175
+ export interface PropertyAnim {
176
+ readonly prop: AnimatableProp;
177
+ readonly from: number | RGBA;
178
+ readonly to: number | RGBA;
179
+ readonly durationMs: number;
180
+ readonly easing: EasingPreset | EasingFn;
181
+ }
182
+ /** A full transition plan for one node id. */
183
+ export interface TransitionPlan {
184
+ readonly id: string;
185
+ readonly kind: "enter" | "exit" | "update" | "no-op";
186
+ /** Total duration ms (0 if enter with no from). */
187
+ readonly durationMs: number;
188
+ readonly properties: ReadonlyArray<PropertyAnim>;
189
+ }
190
+ /** Build transition plans from scene match results. */
191
+ export declare function planTransition(from: DisplayNode | null, to: DisplayNode | null, id: string): TransitionPlan;
192
+ /** Interruption — a running transition can be cancelled and replaced. */
193
+ export interface InterruptConfig {
194
+ /** When true, cancels the old transition immediately. */
195
+ readonly cancel: boolean;
196
+ /** When true, starts the new transition from the current rendered state. */
197
+ readonly fromCurrentFrame: boolean;
198
+ }
199
+ /** A running timeline — tracks elapsed time and transition plans. */
200
+ export interface Timeline {
201
+ readonly plans: ReadonlyArray<TransitionPlan>;
202
+ /** Start time (monotonic seconds). */
203
+ readonly startedAt: number;
204
+ /** Whether the timeline has ended. */
205
+ readonly done: boolean;
206
+ }
207
+ /** Create a timeline from a set of transition plans. */
208
+ export declare function createTimeline(plans: ReadonlyArray<TransitionPlan>, startedAt?: number): Timeline;
209
+ /** Sample the timeline at a given time. Returns per-node progress values ∈ [0, 1]. */
210
+ export declare function sample(timeline: Timeline, timeSec: number): ReadonlyMap<string, number>;
211
+ /** Default interruption — cancel and start from current frame. */
212
+ export declare const DEFAULT_INTERRUPT: InterruptConfig;
213
+
214
+ export {};
package/dist/motion.js ADDED
@@ -0,0 +1,72 @@
1
+ // ../davinci-motion/dist/correspondence.js
2
+ function matchScenes(prev, next) {
3
+ const prevMap = /* @__PURE__ */ new Map();
4
+ if (prev)
5
+ collectIds(prev.root, prevMap);
6
+ const nextMap = /* @__PURE__ */ new Map();
7
+ collectIds(next.root, nextMap);
8
+ const matches = [];
9
+ const seen = /* @__PURE__ */ new Set();
10
+ for (const [id, node] of nextMap) {
11
+ matches.push({ id, from: prevMap.get(id) ?? null, to: node });
12
+ seen.add(id);
13
+ }
14
+ for (const [id, node] of prevMap) {
15
+ if (!seen.has(id))
16
+ matches.push({ id, from: node, to: null });
17
+ }
18
+ return matches;
19
+ }
20
+ function collectIds(node, out) {
21
+ if (node.id) {
22
+ out.set(node.id, node);
23
+ }
24
+ if (node.kind === "group") {
25
+ for (const c of node.children)
26
+ collectIds(c, out);
27
+ }
28
+ }
29
+
30
+ // ../davinci-motion/dist/transition.js
31
+ function planTransition(from, to, id) {
32
+ const properties = [];
33
+ if (from === null && to !== null) {
34
+ return { id, kind: "enter", durationMs: 250, properties };
35
+ }
36
+ if (from !== null && to === null) {
37
+ return { id, kind: "exit", durationMs: 250, properties };
38
+ }
39
+ if (from === null && to === null) {
40
+ return { id, kind: "no-op", durationMs: 0, properties };
41
+ }
42
+ return { id, kind: "update", durationMs: 250, properties };
43
+ }
44
+
45
+ // ../davinci-motion/dist/timeline.js
46
+ function createTimeline(plans, startedAt = 0) {
47
+ return {
48
+ plans,
49
+ startedAt,
50
+ done: plans.length === 0
51
+ };
52
+ }
53
+ function sample(timeline, timeSec) {
54
+ const progress = /* @__PURE__ */ new Map();
55
+ for (const p of timeline.plans) {
56
+ const elapsed = (timeSec - timeline.startedAt) * 1e3;
57
+ if (p.durationMs <= 0) {
58
+ progress.set(p.id, 1);
59
+ } else {
60
+ progress.set(p.id, Math.min(1, Math.max(0, elapsed / p.durationMs)));
61
+ }
62
+ }
63
+ return progress;
64
+ }
65
+ var DEFAULT_INTERRUPT = { cancel: true, fromCurrentFrame: true };
66
+ export {
67
+ DEFAULT_INTERRUPT,
68
+ createTimeline,
69
+ matchScenes,
70
+ planTransition,
71
+ sample
72
+ };
@@ -0,0 +1,129 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ /** Selection — stable ids of selected nodes. */
4
+ export interface SelectionState {
5
+ readonly nodeIds: ReadonlySet<string>;
6
+ }
7
+ /** Viewport transform — pan + zoom. */
8
+ export interface ViewportState {
9
+ /** Scale factor (1 = 100%). */
10
+ readonly scale: number;
11
+ /** Translation offset in logical pixels. */
12
+ readonly tx: number;
13
+ readonly ty: number;
14
+ }
15
+ /** Brush / filter rectangle (optional). */
16
+ export interface BrushState {
17
+ readonly active: boolean;
18
+ readonly rect?: {
19
+ x: number;
20
+ y: number;
21
+ w: number;
22
+ h: number;
23
+ };
24
+ }
25
+ /** Playback / animation state (time in seconds). */
26
+ export interface TimeState {
27
+ /** Current elapsed time in seconds. */
28
+ readonly now: number;
29
+ /** Paused state. */
30
+ readonly paused: boolean;
31
+ }
32
+ /** Container dimensions — set by host on resize. */
33
+ export interface ContainerState {
34
+ readonly w: number;
35
+ readonly h: number;
36
+ }
37
+ /** Unified runtime state bag. Flat for reducer ergonomics. */
38
+ export interface RuntimeState {
39
+ /** Currently hovered node id (or null). */
40
+ readonly hoveredId: string | null;
41
+ /** Currently focused node id (or null). */
42
+ readonly focusedId: string | null;
43
+ /** Currently pressed node id (or null). */
44
+ readonly pressedId: string | null;
45
+ /** Disabled node ids. */
46
+ readonly disabledIds: ReadonlySet<string>;
47
+ readonly selection: SelectionState;
48
+ readonly viewport: ViewportState;
49
+ readonly brush: BrushState;
50
+ readonly time: TimeState;
51
+ readonly container: ContainerState;
52
+ }
53
+ /** Default initial runtime state. */
54
+ export declare function initialState(w: number, h: number): RuntimeState;
55
+ /** Pointer button. */
56
+ export type PointerButton = "primary" | "secondary" | "tertiary";
57
+ /** Normalized pointer event — single origin, no DOM. */
58
+ export interface NormalizedPointerEvent {
59
+ readonly kind: "pointer";
60
+ readonly type: "down" | "up" | "move" | "enter" | "leave";
61
+ readonly x: number;
62
+ readonly y: number;
63
+ readonly button?: PointerButton;
64
+ readonly shift?: boolean;
65
+ readonly alt?: boolean;
66
+ readonly ctrl?: boolean;
67
+ }
68
+ /** Normalized keyboard event. */
69
+ export interface NormalizedKeyboardEvent {
70
+ readonly kind: "keyboard";
71
+ readonly type: "down" | "up";
72
+ readonly key: string;
73
+ readonly shift?: boolean;
74
+ readonly alt?: boolean;
75
+ readonly ctrl?: boolean;
76
+ }
77
+ export type NormalizedEvent = NormalizedPointerEvent | NormalizedKeyboardEvent;
78
+ /** Abstract Action (user intent, NOT raw event). */
79
+ export type Action = {
80
+ readonly kind: "hover";
81
+ readonly nodeId: string | null;
82
+ } | {
83
+ readonly kind: "select-toggle";
84
+ readonly nodeId: string;
85
+ readonly additive?: boolean;
86
+ } | {
87
+ readonly kind: "selection-set";
88
+ readonly nodeIds: readonly string[];
89
+ } | {
90
+ readonly kind: "clear-selection";
91
+ } | {
92
+ readonly kind: "viewport-pan";
93
+ readonly dx: number;
94
+ readonly dy: number;
95
+ } | {
96
+ readonly kind: "viewport-zoom";
97
+ readonly delta: number;
98
+ } | {
99
+ readonly kind: "container-resize";
100
+ readonly w: number;
101
+ readonly h: number;
102
+ } | {
103
+ readonly kind: "time-set";
104
+ readonly now: number;
105
+ } | {
106
+ readonly kind: "time-toggle-pause";
107
+ };
108
+ /** Reducer — pure, returns new state. */
109
+ export declare function reduce(state: RuntimeState, action: Action): RuntimeState;
110
+ /** Dispatch a pointer event — hit test target → produce Action.
111
+ * Host provides hitTest function (overload point for domain-specific targetting). */
112
+ export declare function dispatchPointer(state: RuntimeState, ev: NormalizedPointerEvent, hitTest: (x: number, y: number) => string | null): Action | null;
113
+ /** Invalidation category. */
114
+ export type InvalidationCategory = "overlay" | "style" | "viewport" | "measurement" | "layout" | "data" | "motion";
115
+ /** A set of nodes grouped by invalidation category. */
116
+ export interface InvalidationSet {
117
+ /** Categories to re-run. */
118
+ readonly categories: ReadonlySet<InvalidationCategory>;
119
+ /** Optional explicit node ids (if empty, category applies to all nodes). */
120
+ readonly nodeIds?: ReadonlySet<string>;
121
+ }
122
+ /** Empty invalidation set — nothing to recompile. */
123
+ export declare const EMPTY_INVALIDATION: InvalidationSet;
124
+ /** Union two invalidation sets. */
125
+ export declare function unionInvalidation(a: InvalidationSet, b: InvalidationSet): InvalidationSet;
126
+ /** Derive invalidation from an action. */
127
+ export declare function deriveInvalidation(action: Action): InvalidationSet;
128
+
129
+ export {};
@@ -0,0 +1,101 @@
1
+ // ../davinci-runtime/dist/state.js
2
+ function initialState(w, h) {
3
+ return {
4
+ hoveredId: null,
5
+ focusedId: null,
6
+ pressedId: null,
7
+ disabledIds: /* @__PURE__ */ new Set(),
8
+ selection: { nodeIds: /* @__PURE__ */ new Set() },
9
+ viewport: { scale: 1, tx: 0, ty: 0 },
10
+ brush: { active: false },
11
+ time: { now: 0, paused: true },
12
+ container: { w, h }
13
+ };
14
+ }
15
+
16
+ // ../davinci-runtime/dist/event.js
17
+ function reduce(state, action) {
18
+ switch (action.kind) {
19
+ case "hover":
20
+ return { ...state, hoveredId: action.nodeId };
21
+ case "select-toggle": {
22
+ const ids = new Set(state.selection.nodeIds);
23
+ if (ids.has(action.nodeId))
24
+ ids.delete(action.nodeId);
25
+ else
26
+ ids.add(action.nodeId);
27
+ return { ...state, selection: { nodeIds: ids } };
28
+ }
29
+ case "selection-set":
30
+ return { ...state, selection: { nodeIds: new Set(action.nodeIds) } };
31
+ case "clear-selection":
32
+ return { ...state, selection: { nodeIds: /* @__PURE__ */ new Set() } };
33
+ case "viewport-pan":
34
+ return { ...state, viewport: { ...state.viewport, tx: state.viewport.tx + action.dx, ty: state.viewport.ty + action.dy } };
35
+ case "viewport-zoom": {
36
+ const nextScale = Math.max(0.1, Math.min(10, state.viewport.scale * (1 + action.delta)));
37
+ return { ...state, viewport: { ...state.viewport, scale: nextScale } };
38
+ }
39
+ case "container-resize":
40
+ return { ...state, container: { w: action.w, h: action.h } };
41
+ case "time-set":
42
+ return { ...state, time: { ...state.time, now: action.now } };
43
+ case "time-toggle-pause":
44
+ return { ...state, time: { ...state.time, paused: !state.time.paused } };
45
+ }
46
+ }
47
+ function dispatchPointer(state, ev, hitTest) {
48
+ switch (ev.type) {
49
+ case "move":
50
+ return { kind: "hover", nodeId: hitTest(ev.x, ev.y) };
51
+ case "down": {
52
+ const target = hitTest(ev.x, ev.y);
53
+ if (target)
54
+ return { kind: "select-toggle", nodeId: target, additive: ev.shift };
55
+ return { kind: "clear-selection" };
56
+ }
57
+ case "leave":
58
+ return { kind: "hover", nodeId: null };
59
+ default:
60
+ return null;
61
+ }
62
+ }
63
+
64
+ // ../davinci-runtime/dist/invalidation.js
65
+ var EMPTY_INVALIDATION = { categories: /* @__PURE__ */ new Set() };
66
+ function unionInvalidation(a, b) {
67
+ const cats = /* @__PURE__ */ new Set([...a.categories, ...b.categories]);
68
+ const mergedIds = /* @__PURE__ */ new Set();
69
+ if (a.nodeIds)
70
+ for (const id of a.nodeIds)
71
+ mergedIds.add(id);
72
+ if (b.nodeIds)
73
+ for (const id of b.nodeIds)
74
+ mergedIds.add(id);
75
+ return { categories: cats, nodeIds: mergedIds.size > 0 ? mergedIds : void 0 };
76
+ }
77
+ function deriveInvalidation(action) {
78
+ switch (action.kind) {
79
+ case "hover":
80
+ case "select-toggle":
81
+ case "selection-set":
82
+ case "clear-selection":
83
+ return { categories: /* @__PURE__ */ new Set(["overlay"]) };
84
+ case "viewport-pan":
85
+ case "viewport-zoom":
86
+ return { categories: /* @__PURE__ */ new Set(["viewport", "overlay"]) };
87
+ case "container-resize":
88
+ return { categories: /* @__PURE__ */ new Set(["measurement", "layout"]) };
89
+ case "time-set":
90
+ case "time-toggle-pause":
91
+ return { categories: /* @__PURE__ */ new Set(["motion"]) };
92
+ }
93
+ }
94
+ export {
95
+ EMPTY_INVALIDATION,
96
+ deriveInvalidation,
97
+ dispatchPointer,
98
+ initialState,
99
+ reduce,
100
+ unionInvalidation
101
+ };
@@ -0,0 +1,180 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ /** 2D point / vector (x, y). */
4
+ export interface Point2D {
5
+ readonly x: number;
6
+ readonly y: number;
7
+ }
8
+ /** Affine 2D transform matrix (3x3, column-major compact form).
9
+ *
10
+ * ```text
11
+ * | a c tx |
12
+ * | b d ty |
13
+ * | 0 0 1 |
14
+ * ```
15
+ *
16
+ * Standard affine transforms (translate, scale, rotate, skew) compose via
17
+ * {@link multiplyTransform}.
18
+ */
19
+ export interface Affine2D {
20
+ readonly a: number;
21
+ readonly b: number;
22
+ readonly c: number;
23
+ readonly d: number;
24
+ readonly tx: number;
25
+ readonly ty: number;
26
+ }
27
+ /** A segment of a path — one of the SVG/Cubic-like command primitives. */
28
+ export type PathCommand = {
29
+ readonly kind: "move";
30
+ readonly to: Point2D;
31
+ } | {
32
+ readonly kind: "line";
33
+ readonly to: Point2D;
34
+ } | {
35
+ readonly kind: "cubic";
36
+ readonly cp1: Point2D;
37
+ readonly cp2: Point2D;
38
+ readonly to: Point2D;
39
+ } | {
40
+ readonly kind: "quadratic";
41
+ readonly cp: Point2D;
42
+ readonly to: Point2D;
43
+ } | {
44
+ readonly kind: "arc";
45
+ readonly rx: number;
46
+ readonly ry: number;
47
+ readonly xRot: number;
48
+ readonly largeArc: boolean;
49
+ readonly sweep: boolean;
50
+ readonly to: Point2D;
51
+ } | {
52
+ readonly kind: "close";
53
+ };
54
+ /** A simple path = sequence of commands, optionally closed. */
55
+ export interface Path {
56
+ readonly commands: ReadonlyArray<PathCommand>;
57
+ }
58
+ /** Canonical sRGB color with alpha (0–1 each). */
59
+ export interface RGBA {
60
+ readonly r: number;
61
+ readonly g: number;
62
+ readonly b: number;
63
+ readonly a: number;
64
+ }
65
+ /** Axis-aligned rectangle (x, y is top-left, w/h non-negative). */
66
+ export interface Rect {
67
+ readonly x: number;
68
+ readonly y: number;
69
+ readonly w: number;
70
+ readonly h: number;
71
+ }
72
+ /** Semantic alias — used by Scene packages for clarity. */
73
+ export type BoundsRect = Rect;
74
+ declare const SCENE_VERSION = "/v0";
75
+ export type SceneVersion = typeof SCENE_VERSION;
76
+ /** Final stroke style (resolved). */
77
+ export interface DisplayStroke {
78
+ readonly color: RGBA;
79
+ readonly width: number;
80
+ readonly dash?: ReadonlyArray<number>;
81
+ }
82
+ /** Final fill style (resolved). */
83
+ export interface DisplayFill {
84
+ readonly color: RGBA;
85
+ }
86
+ /** A resolved node — everything is final; no upstream semantics leak through. */
87
+ export interface DisplayNodeBase {
88
+ /** Fully composed transform (local * parent chain). */
89
+ readonly worldTransform: Affine2D;
90
+ /** Inherited-and-intersected clip rect (if any). */
91
+ readonly worldClip?: BoundsRect;
92
+ /** Final axis-aligned bounds in world space. */
93
+ readonly bounds: BoundsRect;
94
+ /** Stable domain id — present only when the host resolved with
95
+ * `preserveNodeIds`, so interactive hosts can bind DOM elements back to
96
+ * semantic identity. Renderers never depend on it. */
97
+ readonly id?: string;
98
+ }
99
+ export interface DisplayGroup extends DisplayNodeBase {
100
+ readonly kind: "group";
101
+ readonly children: ReadonlyArray<DisplayNode>;
102
+ }
103
+ export interface DisplayPath extends DisplayNodeBase {
104
+ readonly kind: "path";
105
+ readonly path: Path;
106
+ readonly stroke?: DisplayStroke;
107
+ readonly fill?: DisplayFill;
108
+ }
109
+ export interface DisplayRect extends DisplayNodeBase {
110
+ readonly kind: "rect";
111
+ readonly x: number;
112
+ readonly y: number;
113
+ readonly w: number;
114
+ readonly h: number;
115
+ readonly rx: number;
116
+ readonly ry: number;
117
+ readonly stroke?: DisplayStroke;
118
+ readonly fill?: DisplayFill;
119
+ }
120
+ export interface DisplayEllipse extends DisplayNodeBase {
121
+ readonly kind: "ellipse";
122
+ readonly cx: number;
123
+ readonly cy: number;
124
+ readonly rx: number;
125
+ readonly ry: number;
126
+ readonly stroke?: DisplayStroke;
127
+ readonly fill?: DisplayFill;
128
+ }
129
+ export interface DisplayImage extends DisplayNodeBase {
130
+ readonly kind: "image";
131
+ readonly resourceRef: string;
132
+ readonly x: number;
133
+ readonly y: number;
134
+ readonly w: number;
135
+ readonly h: number;
136
+ }
137
+ export interface DisplayText extends DisplayNodeBase {
138
+ readonly kind: "text";
139
+ readonly text: string;
140
+ /** CSS font string — host-formatted from FontSpec. */
141
+ readonly fontCss: string;
142
+ readonly anchor: {
143
+ x: number;
144
+ y: number;
145
+ };
146
+ readonly color: RGBA;
147
+ }
148
+ export type DisplayNode = DisplayGroup | DisplayPath | DisplayRect | DisplayEllipse | DisplayImage | DisplayText;
149
+ /** The root of a display scene. Always a group. */
150
+ export interface DisplayScene {
151
+ /** Contract namespace this scene was resolved under (`/v0` before 1.0.0). */
152
+ readonly version: SceneVersion;
153
+ readonly root: DisplayGroup;
154
+ /** Optional background color. */
155
+ readonly background?: RGBA;
156
+ /** Logical canvas dimensions. */
157
+ readonly width: number;
158
+ readonly height: number;
159
+ }
160
+ /** Render options for the SVG target. */
161
+ export interface RenderSvgOptions {
162
+ /** Prefix prepended to every generated resource id (`clip-…`).
163
+ * Hosts embedding several scenes in one document must pass an
164
+ * instance-unique prefix so ids never collide across charts.
165
+ * The default is empty, keeping ids local to a standalone document. */
166
+ readonly resourceIdPrefix?: string;
167
+ }
168
+ /** Resolve the resource-id prefix for one rendered scene.
169
+ *
170
+ * Contract: the prefix must be regenerated deterministically from the
171
+ * declarative inputs of the component, never from a per-process counter —
172
+ * SSR and client hydration of the same inputs then agree on every id. When
173
+ * the host needs absolute uniqueness (several identical scenes in one
174
+ * document), it passes an explicit prefix; `renderSvg` still validates the
175
+ * safe-token shape at the boundary. */
176
+ export declare function resolveResourceIdPrefix(family: string, identity: unknown, explicit?: string | null): string;
177
+ /** Serialize a resolved DisplayScene to an SVG document string. */
178
+ export declare function renderSvg(scene: DisplayScene, options?: RenderSvgOptions): string;
179
+
180
+ export {};