@neta-art/cohub 8.23.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/board/animation.d.ts +57 -181
- package/dist/board/animation.js +374 -220
- package/dist/board/core/arrow-geometry.d.ts +33 -18
- package/dist/board/core/arrow-geometry.js +283 -52
- package/dist/board/core/draw-geometry.d.ts +22 -36
- package/dist/board/core/draw-geometry.js +148 -85
- package/dist/board/core/export-assets.d.ts +3 -6
- package/dist/board/core/export-assets.js +0 -2
- package/dist/board/core/export-plan.d.ts +12 -63
- package/dist/board/core/export-plan.js +55 -94
- package/dist/board/core/palette.d.ts +4 -21
- package/dist/board/core/palette.js +8 -13
- package/dist/board/core/scene.d.ts +33 -0
- package/dist/board/core/scene.js +302 -0
- package/dist/board/core/shape-definition.d.ts +12 -24
- package/dist/board/core/shape-definition.js +0 -19
- package/dist/board/core/shape-types.d.ts +6 -120
- package/dist/board/core/shape-types.js +5 -5
- package/dist/board/core/text-metrics.d.ts +8 -11
- package/dist/board/core/text-metrics.js +5 -34
- package/dist/board/core/tool-styles.d.ts +6 -16
- package/dist/board/core/tool-styles.js +17 -25
- package/dist/board/export/index.d.ts +10 -17
- package/dist/board/export/index.js +22 -21
- package/dist/board/export/scene.d.ts +10 -16
- package/dist/board/export/scene.js +17 -30
- package/dist/board/geometry.d.ts +27 -56
- package/dist/board/geometry.js +7 -67
- package/dist/board/headless/index.d.ts +7 -27
- package/dist/board/headless/index.js +20 -19
- package/dist/board/headless/sketch.d.ts +19 -0
- package/dist/board/headless/sketch.js +146 -0
- package/dist/board/image-key.d.ts +2 -12
- package/dist/board/image-key.js +3 -13
- package/dist/board/index.d.ts +18 -20
- package/dist/board/index.js +17 -17
- package/dist/board/media-playback.d.ts +3 -6
- package/dist/board/media-playback.js +6 -6
- package/dist/board/presets.d.ts +150 -0
- package/dist/board/presets.js +226 -0
- package/dist/board/render/board-background.d.ts +5 -3
- package/dist/board/render/board-background.js +8 -7
- package/dist/board/render/clip.d.ts +14 -0
- package/dist/board/render/clip.js +47 -0
- package/dist/board/render/index.d.ts +8 -5
- package/dist/board/render/index.js +7 -4
- package/dist/board/render/media-interaction.d.ts +4 -5
- package/dist/board/render/media-interaction.js +1 -2
- package/dist/board/render/palette.d.ts +6 -2
- package/dist/board/render/palette.js +7 -1
- package/dist/board/render/renderers/arrow-card-renderer.js +69 -71
- package/dist/board/render/renderers/audio-card-renderer.js +3 -3
- package/dist/board/render/renderers/base-card-renderer.d.ts +6 -17
- package/dist/board/render/renderers/base-card-renderer.js +1 -24
- package/dist/board/render/renderers/board-renderer-registry.d.ts +20 -50
- package/dist/board/render/renderers/board-renderer-registry.js +6 -7
- package/dist/board/render/renderers/draw-card-renderer.js +89 -56
- package/dist/board/render/renderers/effect-card-renderer.d.ts +6 -0
- package/dist/board/render/renderers/effect-card-renderer.js +197 -0
- package/dist/board/render/renderers/far-plate.d.ts +4 -21
- package/dist/board/render/renderers/far-plate.js +15 -34
- package/dist/board/render/renderers/file-card-renderer.d.ts +4 -25
- package/dist/board/render/renderers/file-card-renderer.js +8 -58
- package/dist/board/render/renderers/frame-card-renderer.js +28 -28
- package/dist/board/render/renderers/image-card-renderer.d.ts +4 -3
- package/dist/board/render/renderers/image-card-renderer.js +0 -9
- package/dist/board/render/renderers/shape-card-renderer.d.ts +9 -0
- package/dist/board/render/renderers/shape-card-renderer.js +240 -0
- package/dist/board/render/renderers/sketch-card-renderer.d.ts +5 -0
- package/dist/board/render/renderers/sketch-card-renderer.js +98 -0
- package/dist/board/render/renderers/task-card-renderer.d.ts +0 -1
- package/dist/board/render/renderers/task-card-renderer.js +14 -16
- package/dist/board/render/renderers/text-card-renderer.d.ts +1 -3
- package/dist/board/render/renderers/text-card-renderer.js +56 -46
- package/dist/board/render/renderers/unknown-card-renderer.js +4 -10
- package/dist/board/render/renderers/video-card-renderer.d.ts +4 -2
- package/dist/board/render/renderers/video-card-renderer.js +2 -1
- package/dist/board/render/sketch-host.d.ts +14 -0
- package/dist/board/render/sketch-host.js +216 -0
- package/dist/board/render/stroke.d.ts +12 -0
- package/dist/board/render/stroke.js +90 -0
- package/dist/board/render/text-measurement.d.ts +6 -26
- package/dist/board/render/text-measurement.js +11 -30
- package/dist/board/replay.d.ts +6 -31
- package/dist/board/replay.js +45 -203
- package/dist/board/runtime/board-player.d.ts +24 -0
- package/dist/board/runtime/board-player.js +161 -0
- package/dist/board/task.d.ts +2 -10
- package/dist/board/task.js +1 -10
- package/dist/chunks/environment.d.ts +2296 -3864
- package/dist/chunks/host-bridge.d.ts +253 -0
- package/dist/chunks/http.d.ts +238 -58
- package/dist/chunks/http.js +1061 -1034
- package/dist/chunks/transport.js +113 -59
- package/dist/chunks/websocket.d.ts +1 -1
- package/dist/chunks/websocket.js +1 -1
- package/dist/host-bridge.d.ts +54 -0
- package/dist/host-bridge.js +322 -0
- package/dist/http.d.ts +3 -3
- package/dist/index.d.ts +76 -193
- package/dist/index.js +2037 -1191
- package/dist/protocol/dist/board-constants.d.ts +1 -29
- package/dist/protocol/dist/board-constants.js +2 -115
- package/dist/protocol/dist/board-layout.d.ts +59 -0
- package/dist/protocol/dist/board-layout.js +482 -0
- package/dist/protocol/dist/board-model.d.ts +2052 -0
- package/dist/protocol/dist/board-model.js +592 -0
- package/dist/protocol/dist/board-patch.d.ts +86 -0
- package/dist/protocol/dist/board-patch.js +734 -0
- package/dist/protocol/dist/board-schema.d.ts +33 -0
- package/dist/protocol/dist/board-schema.js +59 -0
- package/dist/protocol/dist/board-upgrade.d.ts +1 -0
- package/dist/protocol/dist/board-url.d.ts +1 -3
- package/dist/protocol/dist/board-url.js +2 -2
- package/dist/protocol/dist/board.d.ts +37 -232
- package/dist/protocol/dist/board.js +62 -160
- package/dist/protocol/dist/display/actions.d.ts +1 -0
- package/dist/protocol/dist/display/index.d.ts +2 -0
- package/dist/protocol/dist/index.d.ts +11 -12
- package/dist/protocol/dist/model/metrics.d.ts +2 -0
- package/dist/protocol/dist/model/session.d.ts +2 -1
- package/dist/protocol/dist/realtime/types.d.ts +2 -2
- package/dist/protocol/dist/runtime/index.d.ts +1 -0
- package/dist/space-picker.d.ts +1 -0
- package/dist/space-picker.js +1 -0
- package/dist/types.d.ts +2 -5
- package/package.json +9 -1
- package/dist/board/core/connections.d.ts +0 -108
- package/dist/board/core/connections.js +0 -455
- package/dist/board/mutation.d.ts +0 -6
- package/dist/board/mutation.js +0 -14
- package/dist/board/render/connection-layer.d.ts +0 -53
- package/dist/board/render/connection-layer.js +0 -375
- package/dist/board/render/renderers/geo-card-renderer.d.ts +0 -5
- package/dist/board/render/renderers/geo-card-renderer.js +0 -127
- package/dist/board/semantic-document.d.ts +0 -37
- package/dist/board/semantic-document.js +0 -288
- package/dist/board/semantic-mutation.d.ts +0 -10
- package/dist/board/semantic-mutation.js +0 -209
- package/dist/protocol/dist/board-animation.js +0 -34
- package/dist/protocol/dist/board-authoring.d.ts +0 -1326
- package/dist/protocol/dist/board-authoring.js +0 -302
- package/dist/protocol/dist/board-capability-registry.d.ts +0 -2
- package/dist/protocol/dist/board-capability-registry.js +0 -123
- package/dist/protocol/dist/board-codec.d.ts +0 -3
- package/dist/protocol/dist/board-codec.js +0 -383
- package/dist/protocol/dist/board-composition.d.ts +0 -383
- package/dist/protocol/dist/board-composition.js +0 -310
- package/dist/protocol/dist/board-connection.d.ts +0 -317
- package/dist/protocol/dist/board-connection.js +0 -219
- package/dist/protocol/dist/board-document.d.ts +0 -1566
- package/dist/protocol/dist/board-document.js +0 -456
- package/dist/protocol/dist/board-effect.d.ts +0 -96
- package/dist/protocol/dist/board-effect.js +0 -54
- package/dist/protocol/dist/board-geometry.d.ts +0 -15
- package/dist/protocol/dist/board-geometry.js +0 -137
- package/dist/protocol/dist/board-node.d.ts +0 -8
- package/dist/protocol/dist/board-node.js +0 -252
- /package/dist/protocol/dist/{board-animation.d.ts → host-bridge.d.ts} +0 -0
|
@@ -0,0 +1,592 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region ../protocol/dist/board-model.js
|
|
3
|
+
const BOARD_ID_MAX_LENGTH = 160;
|
|
4
|
+
const BOARD_CAMERA_TARGET = "camera";
|
|
5
|
+
const BoardIdSchema = z.string().min(1).max(160).regex(/^[^\s/]+$/, "ids must not contain whitespace or '/'").refine((value) => value !== BOARD_CAMERA_TARGET, "\"camera\" is reserved");
|
|
6
|
+
const finite = z.number().finite();
|
|
7
|
+
const nonNegative = finite.nonnegative();
|
|
8
|
+
const ratio = finite.min(0).max(1);
|
|
9
|
+
const BoardVec2Schema = z.object({
|
|
10
|
+
x: finite,
|
|
11
|
+
y: finite
|
|
12
|
+
}).strict();
|
|
13
|
+
const BoardSizeSchema = z.object({
|
|
14
|
+
width: finite.positive(),
|
|
15
|
+
height: finite.positive()
|
|
16
|
+
}).strict();
|
|
17
|
+
const BOARD_COLOR_TOKENS = [
|
|
18
|
+
"brand",
|
|
19
|
+
"neutral",
|
|
20
|
+
"black",
|
|
21
|
+
"white",
|
|
22
|
+
"blue",
|
|
23
|
+
"green",
|
|
24
|
+
"amber",
|
|
25
|
+
"violet",
|
|
26
|
+
"rose"
|
|
27
|
+
];
|
|
28
|
+
const CSS_NAMED_COLORS = new Set("transparent aliceblue antiquewhite aqua aquamarine azure beige bisque blanchedalmond blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray grey greenyellow honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat whitesmoke yellow yellowgreen".split(" "));
|
|
29
|
+
function isBoardColorString(value) {
|
|
30
|
+
const color = value.trim().toLowerCase();
|
|
31
|
+
return BOARD_COLOR_TOKENS.includes(color) || CSS_NAMED_COLORS.has(color) || /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(color) || /^(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\([^()]*\)$/.test(color);
|
|
32
|
+
}
|
|
33
|
+
const colorString = z.string().max(120).refine(isBoardColorString, "expected a palette token or a CSS color");
|
|
34
|
+
const BoardColorSchema = z.union([colorString, z.object({
|
|
35
|
+
light: colorString,
|
|
36
|
+
dark: colorString
|
|
37
|
+
}).strict()]);
|
|
38
|
+
const BOARD_DASHES = [
|
|
39
|
+
"solid",
|
|
40
|
+
"dashed",
|
|
41
|
+
"dotted"
|
|
42
|
+
];
|
|
43
|
+
const BoardStyleSchema = z.object({
|
|
44
|
+
fill: BoardColorSchema.optional(),
|
|
45
|
+
fillOpacity: ratio.optional(),
|
|
46
|
+
stroke: BoardColorSchema.optional(),
|
|
47
|
+
strokeWidth: finite.min(0).max(64).optional(),
|
|
48
|
+
dash: z.enum(BOARD_DASHES).optional(),
|
|
49
|
+
radius: nonNegative.optional(),
|
|
50
|
+
trim: ratio.optional()
|
|
51
|
+
}).strict();
|
|
52
|
+
function isSafeBoardSourcePath(value) {
|
|
53
|
+
return value.length > 0 && value.length <= 4096 && !value.startsWith("/") && !value.includes("\\") && value.split("/").every((part) => part.length > 0 && part !== "." && part !== "..");
|
|
54
|
+
}
|
|
55
|
+
const srcSchema = z.string().refine(isSafeBoardSourcePath, "src must be a relative Space file path");
|
|
56
|
+
const itemEnvelope = {
|
|
57
|
+
parent: BoardIdSchema.optional(),
|
|
58
|
+
z: finite.optional(),
|
|
59
|
+
position: BoardVec2Schema.default({
|
|
60
|
+
x: 0,
|
|
61
|
+
y: 0
|
|
62
|
+
}),
|
|
63
|
+
rotation: finite.default(0),
|
|
64
|
+
scale: z.union([finite, BoardVec2Schema]).default(1),
|
|
65
|
+
origin: BoardVec2Schema.default({
|
|
66
|
+
x: .5,
|
|
67
|
+
y: .5
|
|
68
|
+
}),
|
|
69
|
+
opacity: ratio.default(1),
|
|
70
|
+
style: BoardStyleSchema.default({}),
|
|
71
|
+
locked: z.boolean().optional(),
|
|
72
|
+
metadata: z.record(z.string(), z.unknown()).optional()
|
|
73
|
+
};
|
|
74
|
+
const boxed = (width, height) => ({
|
|
75
|
+
...itemEnvelope,
|
|
76
|
+
size: BoardSizeSchema.default({
|
|
77
|
+
width,
|
|
78
|
+
height
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
const unsized = { ...itemEnvelope };
|
|
82
|
+
const fontSize = finite.min(2).max(512);
|
|
83
|
+
const BOARD_TEXT_ALIGNS = [
|
|
84
|
+
"left",
|
|
85
|
+
"center",
|
|
86
|
+
"right"
|
|
87
|
+
];
|
|
88
|
+
const BOARD_SHAPE_GEOMETRIES = [
|
|
89
|
+
"rectangle",
|
|
90
|
+
"rounded",
|
|
91
|
+
"ellipse",
|
|
92
|
+
"diamond",
|
|
93
|
+
"triangle",
|
|
94
|
+
"path"
|
|
95
|
+
];
|
|
96
|
+
const BoardFrameItemSchema = z.object({
|
|
97
|
+
...boxed(480, 320),
|
|
98
|
+
type: z.literal("frame"),
|
|
99
|
+
props: z.object({
|
|
100
|
+
label: z.string().max(280).default(""),
|
|
101
|
+
clip: z.boolean().default(true)
|
|
102
|
+
}).strict().prefault({})
|
|
103
|
+
}).strict();
|
|
104
|
+
const BoardTextItemSchema = z.object({
|
|
105
|
+
...unsized,
|
|
106
|
+
type: z.literal("text"),
|
|
107
|
+
props: z.object({
|
|
108
|
+
text: z.string().default(""),
|
|
109
|
+
fontSize: fontSize.default(24),
|
|
110
|
+
fontWeight: finite.min(100).max(900).default(500),
|
|
111
|
+
font: z.string().min(1).max(120).default("sans"),
|
|
112
|
+
align: z.enum(BOARD_TEXT_ALIGNS).default("left"),
|
|
113
|
+
lineHeight: finite.min(.5).max(4).default(4 / 3),
|
|
114
|
+
width: finite.positive().optional(),
|
|
115
|
+
reveal: ratio.default(1),
|
|
116
|
+
caret: z.boolean().default(false)
|
|
117
|
+
}).strict().prefault({})
|
|
118
|
+
}).strict();
|
|
119
|
+
const BoardShapeItemSchema = z.object({
|
|
120
|
+
...boxed(240, 160),
|
|
121
|
+
type: z.literal("shape"),
|
|
122
|
+
props: z.object({
|
|
123
|
+
geometry: z.enum(BOARD_SHAPE_GEOMETRIES).default("rectangle"),
|
|
124
|
+
path: z.string().min(1).max(2e5).optional(),
|
|
125
|
+
text: z.string().default(""),
|
|
126
|
+
fontSize: fontSize.default(20),
|
|
127
|
+
align: z.enum(BOARD_TEXT_ALIGNS).default("center")
|
|
128
|
+
}).strict().refine((props) => props.geometry !== "path" || Boolean(props.path), {
|
|
129
|
+
message: "path geometry requires props.path",
|
|
130
|
+
path: ["path"]
|
|
131
|
+
}).prefault({})
|
|
132
|
+
}).strict();
|
|
133
|
+
const BoardDrawPointSchema = z.object({
|
|
134
|
+
x: finite,
|
|
135
|
+
y: finite,
|
|
136
|
+
p: ratio.default(.5)
|
|
137
|
+
}).strict();
|
|
138
|
+
const BoardDrawItemSchema = z.object({
|
|
139
|
+
...unsized,
|
|
140
|
+
type: z.literal("draw"),
|
|
141
|
+
props: z.object({ points: z.array(BoardDrawPointSchema).min(1).max(1e5) }).strict()
|
|
142
|
+
}).strict();
|
|
143
|
+
const BOARD_ANCHOR_SIDES = [
|
|
144
|
+
"top",
|
|
145
|
+
"right",
|
|
146
|
+
"bottom",
|
|
147
|
+
"left"
|
|
148
|
+
];
|
|
149
|
+
const BoardArrowAnchorSchema = z.union([
|
|
150
|
+
z.literal("auto"),
|
|
151
|
+
z.object({
|
|
152
|
+
side: z.enum(BOARD_ANCHOR_SIDES),
|
|
153
|
+
offset: ratio.default(.5)
|
|
154
|
+
}).strict(),
|
|
155
|
+
z.object({
|
|
156
|
+
x: ratio,
|
|
157
|
+
y: ratio
|
|
158
|
+
}).strict()
|
|
159
|
+
]);
|
|
160
|
+
const BoardArrowBindingSchema = z.object({
|
|
161
|
+
item: BoardIdSchema,
|
|
162
|
+
anchor: BoardArrowAnchorSchema.default("auto"),
|
|
163
|
+
port: z.string().min(1).max(120).optional()
|
|
164
|
+
}).strict();
|
|
165
|
+
const BoardArrowEndSchema = z.union([BoardVec2Schema, BoardArrowBindingSchema]);
|
|
166
|
+
const BOARD_ARROW_ROUTES = [
|
|
167
|
+
"straight",
|
|
168
|
+
"curve",
|
|
169
|
+
"orthogonal"
|
|
170
|
+
];
|
|
171
|
+
const BoardArrowItemSchema = z.object({
|
|
172
|
+
...unsized,
|
|
173
|
+
type: z.literal("arrow"),
|
|
174
|
+
props: z.object({
|
|
175
|
+
start: BoardArrowEndSchema,
|
|
176
|
+
end: BoardArrowEndSchema,
|
|
177
|
+
route: z.enum(BOARD_ARROW_ROUTES).default("straight"),
|
|
178
|
+
bend: finite.min(-.85).max(.85).default(0),
|
|
179
|
+
waypoints: z.array(BoardVec2Schema).max(64).default([]),
|
|
180
|
+
arrowStart: z.boolean().default(false),
|
|
181
|
+
arrowEnd: z.boolean().default(true),
|
|
182
|
+
label: z.string().max(280).default(""),
|
|
183
|
+
fontSize: fontSize.default(14),
|
|
184
|
+
relation: z.string().max(64).regex(/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/, "relation must be a lowercase slug").optional()
|
|
185
|
+
}).strict()
|
|
186
|
+
}).strict();
|
|
187
|
+
const BoardMediaSnapshotSchema = z.object({
|
|
188
|
+
title: z.string().optional(),
|
|
189
|
+
mimeType: z.string().optional(),
|
|
190
|
+
size: nonNegative.optional(),
|
|
191
|
+
mtimeMs: nonNegative.optional(),
|
|
192
|
+
naturalWidth: finite.positive().optional(),
|
|
193
|
+
naturalHeight: finite.positive().optional(),
|
|
194
|
+
durationMs: nonNegative.optional(),
|
|
195
|
+
excerpt: z.string().optional(),
|
|
196
|
+
coverPath: z.string().optional(),
|
|
197
|
+
coverUrl: z.string().optional()
|
|
198
|
+
}).strict();
|
|
199
|
+
const fileProps = {
|
|
200
|
+
src: srcSchema,
|
|
201
|
+
snapshot: BoardMediaSnapshotSchema.optional()
|
|
202
|
+
};
|
|
203
|
+
const timedFileProps = {
|
|
204
|
+
...fileProps,
|
|
205
|
+
time: nonNegative.optional()
|
|
206
|
+
};
|
|
207
|
+
const BoardCropSchema = z.object({
|
|
208
|
+
x: ratio,
|
|
209
|
+
y: ratio,
|
|
210
|
+
w: ratio,
|
|
211
|
+
h: ratio
|
|
212
|
+
}).strict();
|
|
213
|
+
const BoardImageItemSchema = z.object({
|
|
214
|
+
...boxed(640, 360),
|
|
215
|
+
type: z.literal("image"),
|
|
216
|
+
props: z.object({
|
|
217
|
+
...fileProps,
|
|
218
|
+
crop: BoardCropSchema.optional()
|
|
219
|
+
}).strict()
|
|
220
|
+
}).strict();
|
|
221
|
+
const BoardVideoItemSchema = z.object({
|
|
222
|
+
...boxed(640, 360),
|
|
223
|
+
type: z.literal("video"),
|
|
224
|
+
props: z.object(timedFileProps).strict()
|
|
225
|
+
}).strict();
|
|
226
|
+
const BoardAudioItemSchema = z.object({
|
|
227
|
+
...boxed(480, 96),
|
|
228
|
+
type: z.literal("audio"),
|
|
229
|
+
props: z.object(timedFileProps).strict()
|
|
230
|
+
}).strict();
|
|
231
|
+
const BoardFileItemSchema = z.object({
|
|
232
|
+
...boxed(360, 220),
|
|
233
|
+
type: z.literal("file"),
|
|
234
|
+
props: z.object(fileProps).strict()
|
|
235
|
+
}).strict();
|
|
236
|
+
const BOARD_TASK_ARTIFACT_LIMIT = 6;
|
|
237
|
+
const httpsUrl = z.string().max(4096).url();
|
|
238
|
+
const artifactBase = {
|
|
239
|
+
id: z.string().min(1).max(240),
|
|
240
|
+
title: z.string().max(240).optional(),
|
|
241
|
+
url: httpsUrl,
|
|
242
|
+
mimeType: z.string().max(160).optional()
|
|
243
|
+
};
|
|
244
|
+
const BoardTaskArtifactSchema = z.discriminatedUnion("type", [
|
|
245
|
+
z.object({
|
|
246
|
+
...artifactBase,
|
|
247
|
+
type: z.literal("image"),
|
|
248
|
+
naturalWidth: finite.positive().optional(),
|
|
249
|
+
naturalHeight: finite.positive().optional()
|
|
250
|
+
}).strict(),
|
|
251
|
+
z.object({
|
|
252
|
+
...artifactBase,
|
|
253
|
+
type: z.literal("video"),
|
|
254
|
+
previewUrl: httpsUrl.optional(),
|
|
255
|
+
durationMs: z.number().int().positive().optional(),
|
|
256
|
+
naturalWidth: finite.positive().optional(),
|
|
257
|
+
naturalHeight: finite.positive().optional()
|
|
258
|
+
}).strict(),
|
|
259
|
+
z.object({
|
|
260
|
+
...artifactBase,
|
|
261
|
+
type: z.literal("audio"),
|
|
262
|
+
previewUrl: httpsUrl.optional(),
|
|
263
|
+
durationMs: z.number().int().positive().optional()
|
|
264
|
+
}).strict(),
|
|
265
|
+
z.object({
|
|
266
|
+
id: z.string().min(1).max(240),
|
|
267
|
+
type: z.literal("text"),
|
|
268
|
+
title: z.string().max(240).optional(),
|
|
269
|
+
textExcerpt: z.string().min(1).max(480)
|
|
270
|
+
}).strict()
|
|
271
|
+
]);
|
|
272
|
+
const BoardTaskSnapshotSchema = z.object({
|
|
273
|
+
taskType: z.string().min(1).max(120),
|
|
274
|
+
status: z.enum([
|
|
275
|
+
"pending",
|
|
276
|
+
"running",
|
|
277
|
+
"completed",
|
|
278
|
+
"failed"
|
|
279
|
+
]),
|
|
280
|
+
title: z.string().min(1).max(240),
|
|
281
|
+
model: z.string().max(160).optional(),
|
|
282
|
+
promptExcerpt: z.string().max(480).optional(),
|
|
283
|
+
artifactCount: z.number().int().nonnegative(),
|
|
284
|
+
artifacts: z.array(BoardTaskArtifactSchema).max(6).default([]),
|
|
285
|
+
updatedAt: z.string().optional()
|
|
286
|
+
}).strict();
|
|
287
|
+
const BoardTaskItemSchema = z.object({
|
|
288
|
+
...boxed(420, 240),
|
|
289
|
+
type: z.literal("task"),
|
|
290
|
+
props: z.object({
|
|
291
|
+
taskRunId: z.string().min(1).max(160),
|
|
292
|
+
snapshot: BoardTaskSnapshotSchema
|
|
293
|
+
}).strict()
|
|
294
|
+
}).strict();
|
|
295
|
+
const BOARD_EFFECT_KINDS = [
|
|
296
|
+
"particles",
|
|
297
|
+
"trail",
|
|
298
|
+
"impact",
|
|
299
|
+
"flash",
|
|
300
|
+
"glow"
|
|
301
|
+
];
|
|
302
|
+
const BOARD_EFFECT_KIND_INFO = {
|
|
303
|
+
particles: {
|
|
304
|
+
description: "Continuous particles emitted inside the effect frame.",
|
|
305
|
+
parameters: {
|
|
306
|
+
rate: "Particles per second.",
|
|
307
|
+
life: "Particle lifetime in milliseconds.",
|
|
308
|
+
particleSize: "Particle size in board units.",
|
|
309
|
+
speed: "Particle speed in board units per second.",
|
|
310
|
+
direction: "Emission direction in degrees.",
|
|
311
|
+
spread: "Emission spread in degrees.",
|
|
312
|
+
gravity: "Acceleration in board units per second squared.",
|
|
313
|
+
intensity: "Opacity and size multiplier.",
|
|
314
|
+
seed: "Stable seed for repeatable particle motion."
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
trail: {
|
|
318
|
+
description: "A fading trail following another item.",
|
|
319
|
+
parameters: {
|
|
320
|
+
follow: "ID of the item to follow.",
|
|
321
|
+
life: "Trail lifetime in milliseconds.",
|
|
322
|
+
particleSize: "Trail width in board units.",
|
|
323
|
+
intensity: "Opacity multiplier."
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
impact: {
|
|
327
|
+
description: "A repeating radial burst centered in the effect frame.",
|
|
328
|
+
parameters: {
|
|
329
|
+
rate: "Particles per burst.",
|
|
330
|
+
life: "Time between bursts in milliseconds.",
|
|
331
|
+
particleSize: "Particle and ring size in board units.",
|
|
332
|
+
speed: "Particle speed in board units per second.",
|
|
333
|
+
direction: "Burst direction in degrees.",
|
|
334
|
+
spread: "Burst spread in degrees.",
|
|
335
|
+
gravity: "Acceleration in board units per second squared.",
|
|
336
|
+
intensity: "Opacity multiplier.",
|
|
337
|
+
seed: "Stable seed for repeatable bursts."
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
flash: {
|
|
341
|
+
description: "A repeating full-frame flash.",
|
|
342
|
+
parameters: {
|
|
343
|
+
life: "Time between flashes in milliseconds.",
|
|
344
|
+
intensity: "Flash opacity multiplier."
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
glow: {
|
|
348
|
+
description: "A pulsing set of concentric rings.",
|
|
349
|
+
parameters: {
|
|
350
|
+
life: "Pulse period in milliseconds.",
|
|
351
|
+
intensity: "Glow opacity multiplier."
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
const BoardEffectItemSchema = z.object({
|
|
356
|
+
...boxed(240, 240),
|
|
357
|
+
type: z.literal("effect"),
|
|
358
|
+
props: z.object({
|
|
359
|
+
kind: z.enum(BOARD_EFFECT_KINDS),
|
|
360
|
+
rate: nonNegative.max(2e4).default(40),
|
|
361
|
+
life: finite.positive().max(6e4).default(1200),
|
|
362
|
+
particleSize: finite.positive().max(512).default(6),
|
|
363
|
+
speed: nonNegative.max(1e4).default(120),
|
|
364
|
+
direction: finite.default(-90),
|
|
365
|
+
spread: finite.min(0).max(360).default(360),
|
|
366
|
+
gravity: finite.default(0),
|
|
367
|
+
intensity: nonNegative.max(10).default(1),
|
|
368
|
+
follow: BoardIdSchema.optional(),
|
|
369
|
+
seed: z.string().min(1).max(160).optional()
|
|
370
|
+
}).strict()
|
|
371
|
+
}).strict();
|
|
372
|
+
const BoardSketchItemSchema = z.object({
|
|
373
|
+
...boxed(480, 320),
|
|
374
|
+
type: z.literal("sketch"),
|
|
375
|
+
props: z.object({
|
|
376
|
+
src: srcSchema.refine((path) => /\.m?js$/.test(path), "sketch src must be a .js or .mjs module"),
|
|
377
|
+
params: z.record(z.string(), z.unknown()).default({}),
|
|
378
|
+
seed: z.string().min(1).max(160).optional()
|
|
379
|
+
}).strict()
|
|
380
|
+
}).strict();
|
|
381
|
+
const BOARD_EXTENSION_TYPE_PATTERN = /^[a-z][a-z0-9]*(?:\.[a-z0-9-]+)+$/;
|
|
382
|
+
const BoardExtensionItemSchema = z.object({
|
|
383
|
+
...itemEnvelope,
|
|
384
|
+
size: BoardSizeSchema.default({
|
|
385
|
+
width: 240,
|
|
386
|
+
height: 160
|
|
387
|
+
}),
|
|
388
|
+
type: z.string().regex(BOARD_EXTENSION_TYPE_PATTERN),
|
|
389
|
+
props: z.record(z.string(), z.unknown()).default({})
|
|
390
|
+
}).strict();
|
|
391
|
+
const BOARD_ITEM_SCHEMAS = {
|
|
392
|
+
frame: BoardFrameItemSchema,
|
|
393
|
+
text: BoardTextItemSchema,
|
|
394
|
+
shape: BoardShapeItemSchema,
|
|
395
|
+
draw: BoardDrawItemSchema,
|
|
396
|
+
arrow: BoardArrowItemSchema,
|
|
397
|
+
image: BoardImageItemSchema,
|
|
398
|
+
video: BoardVideoItemSchema,
|
|
399
|
+
audio: BoardAudioItemSchema,
|
|
400
|
+
file: BoardFileItemSchema,
|
|
401
|
+
task: BoardTaskItemSchema,
|
|
402
|
+
effect: BoardEffectItemSchema,
|
|
403
|
+
sketch: BoardSketchItemSchema
|
|
404
|
+
};
|
|
405
|
+
const BOARD_ITEM_TYPES = Object.keys(BOARD_ITEM_SCHEMAS);
|
|
406
|
+
function isBuiltinItemType(type) {
|
|
407
|
+
return Object.hasOwn(BOARD_ITEM_SCHEMAS, type);
|
|
408
|
+
}
|
|
409
|
+
function isBuiltinItem(item) {
|
|
410
|
+
return isBuiltinItemType(item.type);
|
|
411
|
+
}
|
|
412
|
+
function isFileBackedItem(item) {
|
|
413
|
+
return item.type === "image" || item.type === "video" || item.type === "audio" || item.type === "file";
|
|
414
|
+
}
|
|
415
|
+
function isMediaItem(item) {
|
|
416
|
+
return item.type === "image" || item.type === "video" || item.type === "audio";
|
|
417
|
+
}
|
|
418
|
+
const BOARD_DERIVED_SIZE_TYPES = [
|
|
419
|
+
"text",
|
|
420
|
+
"draw",
|
|
421
|
+
"arrow"
|
|
422
|
+
];
|
|
423
|
+
function hasAuthoredSize(type) {
|
|
424
|
+
return !BOARD_DERIVED_SIZE_TYPES.includes(type);
|
|
425
|
+
}
|
|
426
|
+
function boardItemSchema(type) {
|
|
427
|
+
if (isBuiltinItemType(type)) return BOARD_ITEM_SCHEMAS[type];
|
|
428
|
+
return BOARD_EXTENSION_TYPE_PATTERN.test(type) ? BoardExtensionItemSchema : null;
|
|
429
|
+
}
|
|
430
|
+
function issuesToDiagnostics(error, path) {
|
|
431
|
+
return error.issues.map((issue) => {
|
|
432
|
+
return {
|
|
433
|
+
severity: "error",
|
|
434
|
+
code: "INVALID_ITEM",
|
|
435
|
+
path: [path, ...issue.path.map(String)].filter(Boolean).join("."),
|
|
436
|
+
message: issue.code === "unrecognized_keys" ? `unknown ${issue.keys.length === 1 ? "property" : "properties"} ${issue.keys.join(", ")}` : issue.message
|
|
437
|
+
};
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
function parseBoardItem(value, path = "item") {
|
|
441
|
+
const type = value && typeof value === "object" && !Array.isArray(value) ? value.type : void 0;
|
|
442
|
+
if (typeof type !== "string") return {
|
|
443
|
+
ok: false,
|
|
444
|
+
diagnostics: [{
|
|
445
|
+
severity: "error",
|
|
446
|
+
code: "INVALID_ITEM",
|
|
447
|
+
path: `${path}.type`,
|
|
448
|
+
message: "type is required"
|
|
449
|
+
}]
|
|
450
|
+
};
|
|
451
|
+
const schema = boardItemSchema(type);
|
|
452
|
+
if (!schema) return {
|
|
453
|
+
ok: false,
|
|
454
|
+
diagnostics: [{
|
|
455
|
+
severity: "error",
|
|
456
|
+
code: "INVALID_ITEM",
|
|
457
|
+
path: `${path}.type`,
|
|
458
|
+
message: `unknown type ${type}; expected ${BOARD_ITEM_TYPES.join(", ")} or a namespaced extension type`
|
|
459
|
+
}]
|
|
460
|
+
};
|
|
461
|
+
const parsed = schema.safeParse(value);
|
|
462
|
+
return parsed.success ? {
|
|
463
|
+
ok: true,
|
|
464
|
+
item: parsed.data
|
|
465
|
+
} : {
|
|
466
|
+
ok: false,
|
|
467
|
+
diagnostics: issuesToDiagnostics(parsed.error, path)
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
const CSS_EASE_KEYWORDS = /* @__PURE__ */ new Set([
|
|
471
|
+
"linear",
|
|
472
|
+
"ease",
|
|
473
|
+
"ease-in",
|
|
474
|
+
"ease-out",
|
|
475
|
+
"ease-in-out",
|
|
476
|
+
"step-start",
|
|
477
|
+
"step-end"
|
|
478
|
+
]);
|
|
479
|
+
function isBoardEase(value) {
|
|
480
|
+
const ease = value.trim();
|
|
481
|
+
if (CSS_EASE_KEYWORDS.has(ease)) return true;
|
|
482
|
+
const bezier = /^cubic-bezier\(\s*([^,()]+),\s*([^,()]+),\s*([^,()]+),\s*([^,()]+)\)$/.exec(ease);
|
|
483
|
+
if (bezier) {
|
|
484
|
+
const [x1, , x2] = bezier.slice(1).map(Number);
|
|
485
|
+
return bezier.slice(1).every((part) => Number.isFinite(Number(part))) && x1 >= 0 && x1 <= 1 && x2 >= 0 && x2 <= 1;
|
|
486
|
+
}
|
|
487
|
+
return /^steps\(\s*[1-9]\d*\s*(?:,\s*(?:start|end|jump-start|jump-end|jump-none|jump-both)\s*)?\)$/.test(ease);
|
|
488
|
+
}
|
|
489
|
+
const BoardEaseSchema = z.string().max(120).refine(isBoardEase, "expected a CSS easing: linear, ease-in-out, cubic-bezier(…) or steps(…)");
|
|
490
|
+
const BoardKeyframeSchema = z.object({
|
|
491
|
+
at: nonNegative,
|
|
492
|
+
value: z.unknown(),
|
|
493
|
+
ease: BoardEaseSchema.optional()
|
|
494
|
+
}).strict();
|
|
495
|
+
const BoardTrackSchema = z.object({
|
|
496
|
+
target: z.string().min(1).max(160),
|
|
497
|
+
property: z.string().min(1).max(200),
|
|
498
|
+
keyframes: z.array(BoardKeyframeSchema).min(1).max(1e5),
|
|
499
|
+
composite: z.enum(["replace", "add"]).default("replace"),
|
|
500
|
+
interpolation: z.enum([
|
|
501
|
+
"auto",
|
|
502
|
+
"step",
|
|
503
|
+
"spline"
|
|
504
|
+
]).default("auto"),
|
|
505
|
+
orient: z.boolean().optional()
|
|
506
|
+
}).strict().superRefine((track, context) => {
|
|
507
|
+
for (let index = 1; index < track.keyframes.length; index += 1) if ((track.keyframes[index]?.at ?? 0) < (track.keyframes[index - 1]?.at ?? 0)) context.addIssue({
|
|
508
|
+
code: "custom",
|
|
509
|
+
message: "keyframes must be ordered by at",
|
|
510
|
+
path: [
|
|
511
|
+
"keyframes",
|
|
512
|
+
index,
|
|
513
|
+
"at"
|
|
514
|
+
]
|
|
515
|
+
});
|
|
516
|
+
});
|
|
517
|
+
const BoardMarkerSchema = z.object({
|
|
518
|
+
at: nonNegative,
|
|
519
|
+
label: z.string().max(280).optional(),
|
|
520
|
+
pause: z.boolean().optional()
|
|
521
|
+
}).strict();
|
|
522
|
+
const BOARD_PLAY_MODES = [
|
|
523
|
+
"manual",
|
|
524
|
+
"auto",
|
|
525
|
+
"always"
|
|
526
|
+
];
|
|
527
|
+
const BoardAnimationHeaderSchema = z.object({
|
|
528
|
+
name: z.string().max(280).optional(),
|
|
529
|
+
duration: finite.positive().max(864e5),
|
|
530
|
+
play: z.enum(BOARD_PLAY_MODES).default("manual"),
|
|
531
|
+
delay: nonNegative.default(0),
|
|
532
|
+
loop: z.boolean().default(false),
|
|
533
|
+
end: z.enum(["hold", "reset"]).default("hold"),
|
|
534
|
+
markers: z.array(BoardMarkerSchema).max(1e4).default([])
|
|
535
|
+
}).strict();
|
|
536
|
+
const BoardAnimationSchema = BoardAnimationHeaderSchema.extend({ tracks: z.record(BoardIdSchema, BoardTrackSchema).default({}) }).strict();
|
|
537
|
+
const BOARD_ENTER_PRESETS = [
|
|
538
|
+
"fade-in",
|
|
539
|
+
"rise",
|
|
540
|
+
"drop",
|
|
541
|
+
"pop",
|
|
542
|
+
"deal"
|
|
543
|
+
];
|
|
544
|
+
const BoardBackgroundSchema = z.object({
|
|
545
|
+
kind: z.enum([
|
|
546
|
+
"solid",
|
|
547
|
+
"dots",
|
|
548
|
+
"grid",
|
|
549
|
+
"image"
|
|
550
|
+
]).default("dots"),
|
|
551
|
+
color: BoardColorSchema.optional(),
|
|
552
|
+
imageUrl: z.string().url().max(4096).optional(),
|
|
553
|
+
fit: z.enum([
|
|
554
|
+
"cover",
|
|
555
|
+
"contain",
|
|
556
|
+
"repeat"
|
|
557
|
+
]).optional(),
|
|
558
|
+
opacity: ratio.optional()
|
|
559
|
+
}).strict();
|
|
560
|
+
const BOARD_GRID_MIN_SIZE = 4;
|
|
561
|
+
const BOARD_GRID_MAX_SIZE = 512;
|
|
562
|
+
const BOARD_GRID_DEFAULT_SIZE = 24;
|
|
563
|
+
const BoardSettingsSchema = z.object({
|
|
564
|
+
title: z.string().min(1).max(255).optional(),
|
|
565
|
+
background: BoardBackgroundSchema.default({ kind: "dots" }),
|
|
566
|
+
grid: z.object({
|
|
567
|
+
visible: z.boolean().default(false),
|
|
568
|
+
size: finite.min(4).max(512).default(24)
|
|
569
|
+
}).strict().optional(),
|
|
570
|
+
enter: z.object({
|
|
571
|
+
preset: z.enum(BOARD_ENTER_PRESETS),
|
|
572
|
+
duration: finite.positive().max(1e4).optional()
|
|
573
|
+
}).strict().optional()
|
|
574
|
+
}).strict();
|
|
575
|
+
function emptyBoardDocument() {
|
|
576
|
+
return {
|
|
577
|
+
board: BoardSettingsSchema.parse({}),
|
|
578
|
+
items: {},
|
|
579
|
+
animations: {}
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
const patchObject = z.record(z.string(), z.unknown());
|
|
583
|
+
const BoardPatchSchema = z.object({
|
|
584
|
+
board: patchObject.nullable().optional(),
|
|
585
|
+
items: z.record(BoardIdSchema, patchObject.nullable()).optional(),
|
|
586
|
+
animations: z.record(BoardIdSchema, patchObject.and(z.object({ tracks: z.record(BoardIdSchema, patchObject.nullable()).optional() })).nullable()).optional()
|
|
587
|
+
}).strict();
|
|
588
|
+
function isEmptyBoardDelta(delta) {
|
|
589
|
+
return !delta.board && Object.keys(delta.items ?? {}).length === 0 && Object.keys(delta.animations ?? {}).length === 0 && Object.keys(delta.tracks ?? {}).length === 0;
|
|
590
|
+
}
|
|
591
|
+
//#endregion
|
|
592
|
+
export { BOARD_ANCHOR_SIDES, BOARD_ARROW_ROUTES, BOARD_CAMERA_TARGET, BOARD_COLOR_TOKENS, BOARD_DASHES, BOARD_DERIVED_SIZE_TYPES, BOARD_EFFECT_KINDS, BOARD_EFFECT_KIND_INFO, BOARD_ENTER_PRESETS, BOARD_EXTENSION_TYPE_PATTERN, BOARD_GRID_DEFAULT_SIZE, BOARD_GRID_MAX_SIZE, BOARD_GRID_MIN_SIZE, BOARD_ID_MAX_LENGTH, BOARD_ITEM_SCHEMAS, BOARD_ITEM_TYPES, BOARD_PLAY_MODES, BOARD_SHAPE_GEOMETRIES, BOARD_TASK_ARTIFACT_LIMIT, BOARD_TEXT_ALIGNS, BoardAnimationHeaderSchema, BoardAnimationSchema, BoardArrowAnchorSchema, BoardArrowBindingSchema, BoardArrowEndSchema, BoardArrowItemSchema, BoardAudioItemSchema, BoardBackgroundSchema, BoardColorSchema, BoardCropSchema, BoardDrawItemSchema, BoardDrawPointSchema, BoardEaseSchema, BoardEffectItemSchema, BoardExtensionItemSchema, BoardFileItemSchema, BoardFrameItemSchema, BoardIdSchema, BoardImageItemSchema, BoardKeyframeSchema, BoardMarkerSchema, BoardMediaSnapshotSchema, BoardPatchSchema, BoardSettingsSchema, BoardShapeItemSchema, BoardSizeSchema, BoardSketchItemSchema, BoardStyleSchema, BoardTaskArtifactSchema, BoardTaskItemSchema, BoardTaskSnapshotSchema, BoardTextItemSchema, BoardTrackSchema, BoardVec2Schema, BoardVideoItemSchema, boardItemSchema, emptyBoardDocument, hasAuthoredSize, isBoardColorString, isBoardEase, isBuiltinItem, isBuiltinItemType, isEmptyBoardDelta, isFileBackedItem, isMediaItem, isSafeBoardSourcePath, parseBoardItem };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { BoardAnimationHeader, BoardDelta, BoardDiagnostic, BoardDocument, BoardItem, BoardPatch, BoardSettings, BoardTrack, BoardVec2 } from "./board-model.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region ../protocol/dist/board-patch.d.ts
|
|
4
|
+
declare function mergePatch(target: unknown, patch: unknown): unknown;
|
|
5
|
+
declare function diffMergePatch(before: unknown, after: unknown): unknown;
|
|
6
|
+
type BoardValueKind = "number" | "vec2" | "scale" | "color" | "discrete";
|
|
7
|
+
type BoardPropertySpec = {
|
|
8
|
+
kind: BoardValueKind;
|
|
9
|
+
schema: z.ZodType;
|
|
10
|
+
multiplicative?: boolean;
|
|
11
|
+
};
|
|
12
|
+
declare function resolveBoardProperty(targetType: string, property: string): {
|
|
13
|
+
ok: true;
|
|
14
|
+
spec: BoardPropertySpec;
|
|
15
|
+
} | {
|
|
16
|
+
ok: false;
|
|
17
|
+
message: string;
|
|
18
|
+
};
|
|
19
|
+
declare function listBoardProperties(targetType: string): Array<{
|
|
20
|
+
property: string;
|
|
21
|
+
kind: BoardValueKind;
|
|
22
|
+
}>;
|
|
23
|
+
type BoardState = {
|
|
24
|
+
settings(): BoardSettings;
|
|
25
|
+
item(id: string): BoardItem | undefined;
|
|
26
|
+
animation(id: string): BoardAnimationHeader | undefined;
|
|
27
|
+
track(animationId: string, trackId: string): BoardTrack | undefined;
|
|
28
|
+
trackIds(animationId: string): string[];
|
|
29
|
+
children(id: string): string[];
|
|
30
|
+
binders(id: string): string[];
|
|
31
|
+
trackRefs(id: string): Array<{
|
|
32
|
+
animation: string;
|
|
33
|
+
track: string;
|
|
34
|
+
}>;
|
|
35
|
+
maxZ(parent: string | undefined): number;
|
|
36
|
+
};
|
|
37
|
+
declare function trackReferences(track: BoardTrack): string[];
|
|
38
|
+
declare function pruneBoardTrack(track: BoardTrack, deleted: ReadonlySet<string>): BoardTrack | null;
|
|
39
|
+
declare function boardPatchTouches(patch: BoardPatch): {
|
|
40
|
+
items: string[];
|
|
41
|
+
animations: string[];
|
|
42
|
+
tracks: Array<{
|
|
43
|
+
animation: string;
|
|
44
|
+
track: string;
|
|
45
|
+
}>;
|
|
46
|
+
deletedItems: string[];
|
|
47
|
+
deletedAnimations: string[];
|
|
48
|
+
parents: string[];
|
|
49
|
+
references: string[];
|
|
50
|
+
};
|
|
51
|
+
type BoardApplyOptions = {
|
|
52
|
+
cascade?: boolean;
|
|
53
|
+
resolveArrowEnd?: (arrowId: string, which: "start" | "end") => BoardVec2;
|
|
54
|
+
};
|
|
55
|
+
type BoardPatchResult = {
|
|
56
|
+
ok: true;
|
|
57
|
+
before: BoardDelta;
|
|
58
|
+
after: BoardDelta;
|
|
59
|
+
diagnostics: BoardDiagnostic[];
|
|
60
|
+
} | {
|
|
61
|
+
ok: false;
|
|
62
|
+
diagnostics: BoardDiagnostic[];
|
|
63
|
+
};
|
|
64
|
+
declare function applyBoardPatch(state: BoardState, input: BoardPatch, options?: BoardApplyOptions): BoardPatchResult;
|
|
65
|
+
declare function createDocumentState(document: BoardDocument): BoardState;
|
|
66
|
+
declare function applyBoardDelta(document: BoardDocument, delta: BoardDelta): BoardDocument;
|
|
67
|
+
declare function applyBoardPatchToDocument(document: BoardDocument, patch: BoardPatch, options?: BoardApplyOptions): {
|
|
68
|
+
ok: true;
|
|
69
|
+
document: BoardDocument;
|
|
70
|
+
before: BoardDelta;
|
|
71
|
+
after: BoardDelta;
|
|
72
|
+
} | {
|
|
73
|
+
ok: false;
|
|
74
|
+
diagnostics: BoardDiagnostic[];
|
|
75
|
+
};
|
|
76
|
+
declare function diffBoardDocuments(before: BoardDocument, after: BoardDocument): BoardPatch;
|
|
77
|
+
declare function isEmptyBoardPatch(patch: BoardPatch): boolean;
|
|
78
|
+
declare function parseBoardDocument(input: unknown): {
|
|
79
|
+
ok: true;
|
|
80
|
+
document: BoardDocument;
|
|
81
|
+
} | {
|
|
82
|
+
ok: false;
|
|
83
|
+
diagnostics: BoardDiagnostic[];
|
|
84
|
+
};
|
|
85
|
+
//#endregion
|
|
86
|
+
export { BoardApplyOptions, BoardPatchResult, BoardPropertySpec, BoardState, BoardValueKind, applyBoardDelta, applyBoardPatch, applyBoardPatchToDocument, boardPatchTouches, createDocumentState, diffBoardDocuments, diffMergePatch, isEmptyBoardPatch, listBoardProperties, mergePatch, parseBoardDocument, pruneBoardTrack, resolveBoardProperty, trackReferences };
|