sketchmark 2.1.1 → 2.1.2

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.
Files changed (41) hide show
  1. package/package.json +1 -1
  2. package/dist/src/builders/index.d.ts +0 -64
  3. package/dist/src/builders/index.js +0 -212
  4. package/dist/src/compounds.d.ts +0 -13
  5. package/dist/src/compounds.js +0 -118
  6. package/dist/src/deck.d.ts +0 -4
  7. package/dist/src/deck.js +0 -91
  8. package/dist/src/export/index.d.ts +0 -8
  9. package/dist/src/export/index.js +0 -15
  10. package/dist/src/kernel.d.ts +0 -8
  11. package/dist/src/kernel.js +0 -68
  12. package/dist/src/motion.d.ts +0 -4
  13. package/dist/src/motion.js +0 -262
  14. package/dist/src/patch.d.ts +0 -5
  15. package/dist/src/patch.js +0 -72
  16. package/dist/src/player/index.d.ts +0 -68
  17. package/dist/src/player/index.js +0 -600
  18. package/dist/src/project.d.ts +0 -11
  19. package/dist/src/project.js +0 -107
  20. package/dist/src/render/raw-three.d.ts +0 -7
  21. package/dist/src/render/raw-three.js +0 -17
  22. package/dist/src/render/three-html.d.ts +0 -2
  23. package/dist/src/render/three-html.js +0 -257
  24. package/dist/src/render/three-preview-svg.d.ts +0 -3
  25. package/dist/src/render/three-preview-svg.js +0 -102
  26. package/dist/src/scenes.d.ts +0 -4
  27. package/dist/src/scenes.js +0 -26
  28. package/dist/src/sequences.d.ts +0 -43
  29. package/dist/src/sequences.js +0 -109
  30. package/dist/src/shapes/builtins.d.ts +0 -2
  31. package/dist/src/shapes/builtins.js +0 -393
  32. package/dist/src/shapes/common.d.ts +0 -9
  33. package/dist/src/shapes/common.js +0 -76
  34. package/dist/src/shapes/geometry.d.ts +0 -22
  35. package/dist/src/shapes/geometry.js +0 -166
  36. package/dist/src/shapes/index.d.ts +0 -2
  37. package/dist/src/shapes/index.js +0 -18
  38. package/dist/src/shapes/registry.d.ts +0 -8
  39. package/dist/src/shapes/registry.js +0 -31
  40. package/dist/src/shapes/types.d.ts +0 -32
  41. package/dist/src/shapes/types.js +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sketchmark",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "Render kernel for Sketchmark visual documents.",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -1,64 +0,0 @@
1
- import type { ArcElement, CircleElement, CurveElement, EllipseElement, Endpoint, GroupElement, LineElement, PointElement, PolygonElement, PolylineElement, RectElement, TextElement, VisualDocument, VisualElement } from "../types";
2
- export type ElementInput = VisualElement | VisualElement[];
3
- export declare function scene(input: Omit<VisualDocument, "version"> & {
4
- version?: 1;
5
- }): VisualDocument;
6
- export declare function rect(input: Omit<RectElement, "type">): RectElement;
7
- export declare function circle(input: Omit<CircleElement, "type">): CircleElement;
8
- export declare function ellipse(input: Omit<EllipseElement, "type">): EllipseElement;
9
- export declare function point(input: Omit<PointElement, "type">): PointElement;
10
- export declare function polyline(input: Omit<PolylineElement, "type">): PolylineElement;
11
- export declare function polygon(input: Omit<PolygonElement, "type">): PolygonElement;
12
- export declare function text(input: Omit<TextElement, "type">): TextElement;
13
- export declare function line(input: Omit<LineElement, "type">): LineElement;
14
- export declare function arrow(input: Omit<LineElement, "type">): LineElement;
15
- export declare function arc(input: Omit<ArcElement, "type">): ArcElement;
16
- export declare function curve(input: Omit<CurveElement, "type">): CurveElement;
17
- export declare function group(input: Omit<GroupElement, "type">): GroupElement;
18
- export interface NodeOptions {
19
- id: string;
20
- label: string;
21
- x: number;
22
- y: number;
23
- width: number;
24
- height: number;
25
- radius?: number;
26
- fill?: string;
27
- stroke?: string;
28
- strokeWidth?: number;
29
- fontSize?: number;
30
- textFill?: string;
31
- }
32
- export declare function node(options: NodeOptions): [RectElement, TextElement];
33
- export interface FlowOptions {
34
- id: string;
35
- from: Endpoint;
36
- to: Endpoint;
37
- stroke?: string;
38
- strokeWidth?: number;
39
- label?: string;
40
- labelX?: number;
41
- labelY?: number;
42
- }
43
- export declare function flow(options: FlowOptions): VisualElement[];
44
- export interface CalloutOptions {
45
- id: string;
46
- text: string;
47
- x: number;
48
- y: number;
49
- width: number;
50
- height: number;
51
- target: Endpoint;
52
- fill?: string;
53
- textFill?: string;
54
- stroke?: string;
55
- }
56
- export declare function callout(options: CalloutOptions): VisualElement[];
57
- export interface StackOptions {
58
- x: number;
59
- y: number;
60
- gap?: number;
61
- children: ElementInput[];
62
- }
63
- export declare function row(options: StackOptions): VisualElement[];
64
- export declare function column(options: StackOptions): VisualElement[];
@@ -1,212 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.scene = scene;
4
- exports.rect = rect;
5
- exports.circle = circle;
6
- exports.ellipse = ellipse;
7
- exports.point = point;
8
- exports.polyline = polyline;
9
- exports.polygon = polygon;
10
- exports.text = text;
11
- exports.line = line;
12
- exports.arrow = arrow;
13
- exports.arc = arc;
14
- exports.curve = curve;
15
- exports.group = group;
16
- exports.node = node;
17
- exports.flow = flow;
18
- exports.callout = callout;
19
- exports.row = row;
20
- exports.column = column;
21
- const utils_1 = require("../utils");
22
- function scene(input) {
23
- return { version: 1, ...input };
24
- }
25
- function rect(input) {
26
- return { type: "rect", ...input };
27
- }
28
- function circle(input) {
29
- return { type: "circle", ...input };
30
- }
31
- function ellipse(input) {
32
- return { type: "ellipse", ...input };
33
- }
34
- function point(input) {
35
- return { type: "point", ...input };
36
- }
37
- function polyline(input) {
38
- return { type: "polyline", ...input };
39
- }
40
- function polygon(input) {
41
- return { type: "polygon", ...input };
42
- }
43
- function text(input) {
44
- return { type: "text", ...input };
45
- }
46
- function line(input) {
47
- return { type: "line", ...input };
48
- }
49
- function arrow(input) {
50
- return { type: "arrow", ...input };
51
- }
52
- function arc(input) {
53
- return { type: "arc", ...input };
54
- }
55
- function curve(input) {
56
- return { type: "curve", ...input };
57
- }
58
- function group(input) {
59
- return { type: "group", ...input };
60
- }
61
- function node(options) {
62
- return [
63
- rect({
64
- id: `${options.id}_box`,
65
- x: options.x,
66
- y: options.y,
67
- width: options.width,
68
- height: options.height,
69
- radius: options.radius ?? 12,
70
- fill: options.fill ?? "#ffffff",
71
- stroke: options.stroke ?? "#2563eb",
72
- strokeWidth: options.strokeWidth ?? 2
73
- }),
74
- text({
75
- id: `${options.id}_label`,
76
- text: options.label,
77
- x: options.x + options.width / 2,
78
- y: options.y + options.height / 2,
79
- align: "center",
80
- valign: "middle",
81
- fontSize: options.fontSize ?? 18,
82
- fill: options.textFill ?? "#111827"
83
- })
84
- ];
85
- }
86
- function flow(options) {
87
- const out = [
88
- arrow({
89
- id: options.id,
90
- from: options.from,
91
- to: options.to,
92
- stroke: options.stroke ?? "#2563eb",
93
- strokeWidth: options.strokeWidth ?? 2
94
- })
95
- ];
96
- if (options.label) {
97
- if (typeof options.labelX !== "number" || typeof options.labelY !== "number") {
98
- throw new Error("flow label requires explicit labelX and labelY. The builder does not infer label positions.");
99
- }
100
- out.push(text({
101
- id: `${options.id}_label`,
102
- text: options.label,
103
- x: options.labelX,
104
- y: options.labelY,
105
- align: "center",
106
- valign: "middle",
107
- fontSize: 14,
108
- fill: options.stroke ?? "#2563eb"
109
- }));
110
- }
111
- return out;
112
- }
113
- function callout(options) {
114
- const boxId = `${options.id}_box`;
115
- return [
116
- rect({
117
- id: boxId,
118
- x: options.x,
119
- y: options.y,
120
- width: options.width,
121
- height: options.height,
122
- radius: 8,
123
- fill: options.fill ?? "#111827",
124
- stroke: options.stroke ?? "none"
125
- }),
126
- text({
127
- id: `${options.id}_text`,
128
- text: options.text,
129
- x: options.x + options.width / 2,
130
- y: options.y + options.height / 2,
131
- align: "center",
132
- valign: "middle",
133
- fontSize: 15,
134
- fill: options.textFill ?? "#ffffff"
135
- }),
136
- arrow({
137
- id: `${options.id}_arrow`,
138
- from: { target: boxId, anchor: (0, utils_1.anchorSpec)("bottom") },
139
- to: options.target,
140
- stroke: options.stroke ?? "#ef4444",
141
- strokeWidth: 2
142
- })
143
- ];
144
- }
145
- function row(options) {
146
- return stack(options, "row");
147
- }
148
- function column(options) {
149
- return stack(options, "column");
150
- }
151
- function stack(options, direction) {
152
- const gap = options.gap ?? 0;
153
- let cursorX = options.x;
154
- let cursorY = options.y;
155
- const out = [];
156
- for (const childInput of options.children) {
157
- const child = Array.isArray(childInput) ? childInput : [childInput];
158
- const bounds = boundsFor(child);
159
- if (!bounds)
160
- throw new Error(`${direction} children must have explicit geometry. No auto measurement is performed.`);
161
- const dx = cursorX - bounds.x;
162
- const dy = cursorY - bounds.y;
163
- const moved = child.map((element) => translateElement(element, dx, dy));
164
- out.push(...moved);
165
- if (direction === "row")
166
- cursorX += bounds.width + gap;
167
- else
168
- cursorY += bounds.height + gap;
169
- }
170
- return out;
171
- }
172
- function boundsFor(elements) {
173
- const boxes = elements.map((element) => (0, utils_1.elementBox)(element)).filter(Boolean);
174
- if (!boxes.length)
175
- return undefined;
176
- const left = Math.min(...boxes.map((box) => box.x));
177
- const top = Math.min(...boxes.map((box) => box.y));
178
- const right = Math.max(...boxes.map((box) => box.x + box.width));
179
- const bottom = Math.max(...boxes.map((box) => box.y + box.height));
180
- return { x: left, y: top, width: right - left, height: bottom - top };
181
- }
182
- function translateElement(element, dx, dy) {
183
- const next = (0, utils_1.clone)(element);
184
- if ("x" in next && typeof next.x === "number")
185
- next.x += dx;
186
- if ("y" in next && typeof next.y === "number")
187
- next.y += dy;
188
- if ("cx" in next && typeof next.cx === "number")
189
- next.cx += dx;
190
- if ("cy" in next && typeof next.cy === "number")
191
- next.cy += dy;
192
- if ((next.type === "line" || next.type === "arrow" || next.type === "curve") && Array.isArray(next.from) && Array.isArray(next.to)) {
193
- next.from = [Number(next.from[0]) + dx, Number(next.from[1]) + dy];
194
- next.to = [Number(next.to[0]) + dx, Number(next.to[1]) + dy];
195
- }
196
- if (next.type === "arc") {
197
- next.cx += dx;
198
- next.cy += dy;
199
- }
200
- if (next.type === "curve") {
201
- next.control1 = [next.control1[0] + dx, next.control1[1] + dy];
202
- if (next.control2)
203
- next.control2 = [next.control2[0] + dx, next.control2[1] + dy];
204
- }
205
- if ((next.type === "polyline" || next.type === "polygon") && Array.isArray(next.points)) {
206
- next.points = next.points.map((point) => [point[0] + dx, point[1] + dy]);
207
- }
208
- if (next.type === "group" && Array.isArray(next.children)) {
209
- next.children = next.children.map((child) => translateElement(child, dx, dy));
210
- }
211
- return next;
212
- }
@@ -1,13 +0,0 @@
1
- import type { VisualDocument } from "./types";
2
- type LooseElement = Record<string, unknown> & {
3
- type?: string;
4
- children?: LooseElement[];
5
- };
6
- type LooseDocument = Omit<VisualDocument, "elements" | "scenes"> & {
7
- elements?: LooseElement[];
8
- scenes?: Record<string, Record<string, unknown> & {
9
- elements?: LooseElement[];
10
- }>;
11
- };
12
- export declare function compileCompounds(input: LooseDocument): VisualDocument;
13
- export {};
@@ -1,118 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compileCompounds = compileCompounds;
4
- const builders_1 = require("./builders");
5
- const utils_1 = require("./utils");
6
- function compileCompounds(input) {
7
- const document = (0, utils_1.clone)(input);
8
- const elements = compileElementList(document.elements ?? []);
9
- const scenes = {};
10
- for (const [sceneId, scene] of Object.entries(document.scenes ?? {})) {
11
- scenes[sceneId] = {
12
- ...scene,
13
- elements: compileElementList(scene.elements ?? [])
14
- };
15
- }
16
- return {
17
- ...document,
18
- elements,
19
- ...(Object.keys(scenes).length ? { scenes } : {})
20
- };
21
- }
22
- function compileElementList(elements) {
23
- return elements.flatMap((element) => compileElement(element));
24
- }
25
- function compileElement(element) {
26
- switch (element.type) {
27
- case "node":
28
- return (0, builders_1.node)({
29
- id: stringProp(element, "id"),
30
- label: stringProp(element, "label"),
31
- x: numberProp(element, "x"),
32
- y: numberProp(element, "y"),
33
- width: numberProp(element, "width"),
34
- height: numberProp(element, "height"),
35
- radius: optionalNumber(element, "radius"),
36
- fill: optionalString(element, "fill"),
37
- stroke: optionalString(element, "stroke"),
38
- strokeWidth: optionalNumber(element, "strokeWidth"),
39
- fontSize: optionalNumber(element, "fontSize"),
40
- textFill: optionalString(element, "textFill")
41
- });
42
- case "flow":
43
- return (0, builders_1.flow)({
44
- id: stringProp(element, "id"),
45
- from: element.from,
46
- to: element.to,
47
- stroke: optionalString(element, "stroke"),
48
- strokeWidth: optionalNumber(element, "strokeWidth"),
49
- label: optionalString(element, "label"),
50
- labelX: optionalNumber(element, "labelX"),
51
- labelY: optionalNumber(element, "labelY")
52
- });
53
- case "packet":
54
- return [
55
- (0, builders_1.packet)({
56
- id: stringProp(element, "id"),
57
- on: stringProp(element, "on"),
58
- radius: optionalNumber(element, "radius"),
59
- fill: optionalString(element, "fill"),
60
- progress: element.progress
61
- })
62
- ];
63
- case "callout":
64
- return (0, builders_1.callout)({
65
- id: stringProp(element, "id"),
66
- text: stringProp(element, "text"),
67
- x: numberProp(element, "x"),
68
- y: numberProp(element, "y"),
69
- width: numberProp(element, "width"),
70
- height: numberProp(element, "height"),
71
- target: element.target,
72
- fill: optionalString(element, "fill"),
73
- textFill: optionalString(element, "textFill"),
74
- stroke: optionalString(element, "stroke")
75
- });
76
- case "row":
77
- return (0, builders_1.row)({
78
- x: numberProp(element, "x"),
79
- y: numberProp(element, "y"),
80
- gap: optionalNumber(element, "gap"),
81
- children: (element.children ?? []).map((child) => compileElement(child))
82
- });
83
- case "column":
84
- return (0, builders_1.column)({
85
- x: numberProp(element, "x"),
86
- y: numberProp(element, "y"),
87
- gap: optionalNumber(element, "gap"),
88
- children: (element.children ?? []).map((child) => compileElement(child))
89
- });
90
- default: {
91
- const next = (0, utils_1.clone)(element);
92
- if (next.type === "group" && Array.isArray(next.children)) {
93
- next.children = compileElementList(next.children);
94
- }
95
- return [next];
96
- }
97
- }
98
- }
99
- function stringProp(element, key) {
100
- const value = element[key];
101
- if (typeof value !== "string" || !value)
102
- throw new Error(`Compound '${element.type}' requires string '${key}'.`);
103
- return value;
104
- }
105
- function optionalString(element, key) {
106
- const value = element[key];
107
- return typeof value === "string" ? value : undefined;
108
- }
109
- function numberProp(element, key) {
110
- const value = element[key];
111
- if (typeof value !== "number" || !Number.isFinite(value))
112
- throw new Error(`Compound '${element.type}' requires number '${key}'.`);
113
- return value;
114
- }
115
- function optionalNumber(element, key) {
116
- const value = element[key];
117
- return typeof value === "number" && Number.isFinite(value) ? value : undefined;
118
- }
@@ -1,4 +0,0 @@
1
- import type { ResolvedVisualDocument, VisualDocument } from "./types";
2
- export declare function documentForDeckStep(document: VisualDocument, sceneId: string, stepIndex: number): VisualDocument;
3
- export declare function resolvedFrameForDeckStep(document: VisualDocument, sceneId: string, stepIndex: number, time?: number): ResolvedVisualDocument;
4
- export declare function renderDeckToHtml(document: VisualDocument, sceneId: string): string;
package/dist/src/deck.js DELETED
@@ -1,91 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.documentForDeckStep = documentForDeckStep;
4
- exports.resolvedFrameForDeckStep = resolvedFrameForDeckStep;
5
- exports.renderDeckToHtml = renderDeckToHtml;
6
- const scenes_1 = require("./scenes");
7
- const normalize_1 = require("./normalize");
8
- const utils_1 = require("./utils");
9
- const svg_1 = require("./render/svg");
10
- function documentForDeckStep(document, sceneId, stepIndex) {
11
- const scene = document.scenes?.[sceneId];
12
- if (!scene)
13
- throw new Error(`Unknown scene '${sceneId}'.`);
14
- const frame = (0, scenes_1.documentForScene)(document, sceneId);
15
- const activeSteps = (scene.steps ?? []).slice(0, Math.max(0, stepIndex + 1));
16
- if (!activeSteps.length)
17
- return frame;
18
- const hidden = new Set();
19
- const shown = new Set();
20
- for (const step of activeSteps) {
21
- for (const id of step.hide ?? [])
22
- hidden.add(id);
23
- for (const id of step.show ?? []) {
24
- hidden.delete(id);
25
- shown.add(id);
26
- }
27
- }
28
- frame.elements = applyDeckVisibility(frame.elements ?? [], hidden, shown);
29
- return frame;
30
- }
31
- function resolvedFrameForDeckStep(document, sceneId, stepIndex, time = 0) {
32
- return (0, normalize_1.resolveVisualFrame)(documentForDeckStep(document, sceneId, stepIndex), time);
33
- }
34
- function renderDeckToHtml(document, sceneId) {
35
- const scene = document.scenes?.[sceneId];
36
- if (!scene)
37
- throw new Error(`Unknown scene '${sceneId}'.`);
38
- const steps = scene.steps ?? [];
39
- const frameCount = Math.max(1, steps.length + 1);
40
- const frames = Array.from({ length: frameCount }, (_, index) => {
41
- const stepIndex = index - 1;
42
- const frame = stepIndex < 0 ? (0, scenes_1.documentForScene)(document, sceneId) : documentForDeckStep(document, sceneId, stepIndex);
43
- return (0, svg_1.renderToSvg)(frame);
44
- });
45
- const labels = ["Base", ...steps.map((step) => step.id)];
46
- return `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${escapeHtml(sceneId)} Deck</title><style>
47
- html,body{margin:0;width:100%;height:100%;background:#111827;color:#e5e7eb;font-family:Inter,Arial,sans-serif}
48
- body{display:grid;grid-template-rows:1fr auto}
49
- main{display:grid;place-items:center;padding:24px}
50
- #stage svg{max-width:min(100vw,${document.canvas.width}px);max-height:calc(100vh - 112px);background:white;box-shadow:0 20px 50px rgba(0,0,0,.35)}
51
- footer{display:flex;align-items:center;gap:12px;padding:12px 16px;background:#020617;border-top:1px solid #1f2937}
52
- button{border:0;border-radius:6px;padding:8px 12px;background:#2563eb;color:#fff;font-weight:700}
53
- button:disabled{opacity:.45}
54
- code{color:#93c5fd}
55
- </style></head><body><main><div id="stage"></div></main><footer><button id="prev">Prev</button><button id="next">Next</button><span id="count"></span><code id="label"></code></footer><script>
56
- const frames=${JSON.stringify(frames)};
57
- const labels=${JSON.stringify(labels)};
58
- let index=0;
59
- const stage=document.getElementById("stage");
60
- const prev=document.getElementById("prev");
61
- const next=document.getElementById("next");
62
- const count=document.getElementById("count");
63
- const label=document.getElementById("label");
64
- function show(){
65
- stage.innerHTML=frames[index];
66
- prev.disabled=index===0;
67
- next.disabled=index===frames.length-1;
68
- count.textContent=(index+1)+" / "+frames.length;
69
- label.textContent=labels[index] || "";
70
- }
71
- prev.addEventListener("click",()=>{ index=Math.max(0,index-1); show(); });
72
- next.addEventListener("click",()=>{ index=Math.min(frames.length-1,index+1); show(); });
73
- window.addEventListener("keydown",(event)=>{ if(event.key==="ArrowRight") next.click(); if(event.key==="ArrowLeft") prev.click(); });
74
- show();
75
- </script></body></html>`;
76
- }
77
- function applyDeckVisibility(elements, hidden, shown) {
78
- return elements.map((element) => {
79
- const next = (0, utils_1.clone)(element);
80
- if (next.id && hidden.has(next.id))
81
- next.opacity = 0;
82
- if (next.id && shown.has(next.id) && next.opacity === 0)
83
- next.opacity = 1;
84
- if (next.type === "group" && Array.isArray(next.children))
85
- next.children = applyDeckVisibility(next.children, hidden, shown);
86
- return next;
87
- });
88
- }
89
- function escapeHtml(value) {
90
- return String(value).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
91
- }
@@ -1,8 +0,0 @@
1
- import type { ExportOptions, VisualDocument } from "../types";
2
- export interface ExportResult {
3
- format: string;
4
- content: string;
5
- mimeType: string;
6
- warnings?: string[];
7
- }
8
- export declare function exportVisual(document: VisualDocument, options?: ExportOptions): ExportResult;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.exportVisual = exportVisual;
4
- const html_1 = require("../render/html");
5
- const svg_1 = require("../render/svg");
6
- function exportVisual(document, options = {}) {
7
- const format = options.format ?? "svg";
8
- if (format === "svg") {
9
- return { format, content: (0, svg_1.renderToSvg)(document, options), mimeType: "image/svg+xml" };
10
- }
11
- if (format === "html") {
12
- return { format, content: (0, html_1.renderToHtml)(document, options), mimeType: "text/html" };
13
- }
14
- throw new Error(`${format.toUpperCase()} export is reserved for the advanced renderer/export adapter. The primitive JSON core currently exports svg and html directly.`);
15
- }
@@ -1,8 +0,0 @@
1
- import type { KernelVisualDocument, ResolvedVisualDocument, ValidationResult, VisualDocument } from "./types";
2
- import { type NormalizeOptions } from "./normalize";
3
- export interface LowerOptions extends NormalizeOptions {
4
- }
5
- export declare function lowerVisualDocument(document: VisualDocument, options?: LowerOptions): KernelVisualDocument;
6
- export declare function resolveKernelFrame(document: VisualDocument, time?: number): KernelVisualDocument;
7
- export declare function lowerResolvedVisualDocument(document: ResolvedVisualDocument): KernelVisualDocument;
8
- export declare function validateKernelVisualDocument(document: KernelVisualDocument): ValidationResult;
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.lowerVisualDocument = lowerVisualDocument;
4
- exports.resolveKernelFrame = resolveKernelFrame;
5
- exports.lowerResolvedVisualDocument = lowerResolvedVisualDocument;
6
- exports.validateKernelVisualDocument = validateKernelVisualDocument;
7
- const normalize_1 = require("./normalize");
8
- const utils_1 = require("./utils");
9
- const shapes_1 = require("./shapes");
10
- const KERNEL_2D_TYPES = new Set(["group", "path", "text", "image", "point"]);
11
- const KERNEL_3D_TYPES = new Set(["group3d", "mesh3d", "line3d", "text3d", "point3d", "light"]);
12
- function lowerVisualDocument(document, options = {}) {
13
- return lowerResolvedVisualDocument((0, normalize_1.normalizeVisualDocument)(document, options));
14
- }
15
- function resolveKernelFrame(document, time = 0) {
16
- return lowerResolvedVisualDocument((0, normalize_1.resolveVisualFrame)(document, time));
17
- }
18
- function lowerResolvedVisualDocument(document) {
19
- return {
20
- version: document.version,
21
- canvas: (0, utils_1.clone)(document.canvas),
22
- imports: cloneOptional(document.imports),
23
- assets: cloneOptional(document.assets),
24
- exports: cloneOptional(document.exports),
25
- elements: lowerElements(document.elements ?? [])
26
- };
27
- }
28
- function validateKernelVisualDocument(document) {
29
- const issues = [];
30
- const visit = (element, path) => {
31
- if (!KERNEL_2D_TYPES.has(element.type) && !KERNEL_3D_TYPES.has(element.type)) {
32
- issues.push({ path, code: "unsupported_kernel_type", message: `Kernel element type '${element.type}' is not supported.` });
33
- return;
34
- }
35
- if (element.type === "path" && typeof element.d !== "string") {
36
- issues.push({ path, code: "missing_kernel_path", message: "Kernel path requires string 'd'." });
37
- }
38
- if (element.type === "text" && (!isFiniteNumber(element.x) || !isFiniteNumber(element.y))) {
39
- issues.push({ path, code: "missing_kernel_text_position", message: "Kernel text requires numeric x and y." });
40
- }
41
- if (element.type === "image" && (!isFiniteNumber(element.x) || !isFiniteNumber(element.y) || !isFiniteNumber(element.width) || !isFiniteNumber(element.height))) {
42
- issues.push({ path, code: "missing_kernel_image_box", message: "Kernel image requires numeric x, y, width, and height." });
43
- }
44
- if (element.type === "point" && (!isFiniteNumber(element.x) || !isFiniteNumber(element.y))) {
45
- issues.push({ path, code: "missing_kernel_point", message: "Kernel point requires numeric x and y." });
46
- }
47
- if (element.type === "mesh3d" && (!Array.isArray(element.vertices) || !Array.isArray(element.indices))) {
48
- issues.push({ path, code: "missing_kernel_mesh", message: "Kernel mesh3d requires vertices and indices." });
49
- }
50
- if ((element.type === "group" || element.type === "group3d") && Array.isArray(element.children)) {
51
- element.children.forEach((child, index) => visit(child, `${path}/children/${index}`));
52
- }
53
- };
54
- (document.elements ?? []).forEach((element, index) => visit(element, `/elements/${index}`));
55
- return { ok: issues.length === 0, issues, warnings: [] };
56
- }
57
- function lowerElements(elements) {
58
- return elements.flatMap((element) => lowerElement(element));
59
- }
60
- function lowerElement(element) {
61
- return (0, shapes_1.lowerAuthoringElement)(element, { lowerElements });
62
- }
63
- function cloneOptional(value) {
64
- return value === undefined ? undefined : (0, utils_1.clone)(value);
65
- }
66
- function isFiniteNumber(value) {
67
- return typeof value === "number" && Number.isFinite(value);
68
- }
@@ -1,4 +0,0 @@
1
- import type { MotionDriver, MotionExpressionInput, MotionValue, VisualDocument, VisualElement } from "./types";
2
- export declare function applyMotionDrivers(document: VisualDocument, time: number): VisualDocument;
3
- export declare function evaluateDriver(driver: MotionDriver, elements: VisualElement[], time: number): MotionValue | undefined;
4
- export declare function evaluateExpression(input: MotionExpressionInput, elements: VisualElement[], time: number): MotionValue;