@neta-art/cohub-cli 10.29.0 → 10.31.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.
Files changed (87) hide show
  1. package/dist/board-gpu/page.js +3011 -133
  2. package/dist/bootstrap.js +2 -4
  3. package/dist/build.json +1 -1
  4. package/dist/chunks/FilterPipe.js +145 -269
  5. package/dist/chunks/about.js +2 -3
  6. package/dist/chunks/app-realtime.js +113 -115
  7. package/dist/chunks/app-realtime2.js +1 -2
  8. package/dist/chunks/app-ref.js +4 -5
  9. package/dist/chunks/apps.js +8 -14
  10. package/dist/chunks/auth.js +1 -2
  11. package/dist/chunks/avatar.js +2 -4
  12. package/dist/chunks/binary-pins.js +1 -2
  13. package/dist/chunks/board-export-resources.js +55 -12
  14. package/dist/chunks/board-export.js +26 -21
  15. package/dist/chunks/board-export2.js +1 -2
  16. package/dist/chunks/board-kernel.js +2672 -1623
  17. package/dist/chunks/board-kernel2.js +2 -2
  18. package/dist/chunks/board-model.js +970 -0
  19. package/dist/chunks/board-profile.js +4 -5
  20. package/dist/chunks/board-simulate.js +6 -6
  21. package/dist/chunks/board-time.js +1 -2
  22. package/dist/chunks/boards.js +547 -23
  23. package/dist/chunks/browserAll.js +18 -35
  24. package/dist/chunks/channels.js +1 -2
  25. package/dist/chunks/client.js +637 -713
  26. package/dist/chunks/command-input.js +1 -2
  27. package/dist/chunks/commander.js +16 -22
  28. package/dist/chunks/cron-jobs.js +2 -3
  29. package/dist/chunks/daemon.js +18 -4
  30. package/dist/chunks/daemon2.js +1 -2
  31. package/dist/chunks/desktop.js +2 -3
  32. package/dist/chunks/endpoint-options.js +1 -2
  33. package/dist/chunks/env-proxy.js +4 -5
  34. package/dist/chunks/environment.js +2 -4
  35. package/dist/chunks/feedback.js +3 -4
  36. package/dist/chunks/generations.js +3 -4
  37. package/dist/chunks/host.js +1 -2
  38. package/dist/chunks/http-put.js +1 -2
  39. package/dist/chunks/id.js +77 -928
  40. package/dist/chunks/init.js +7 -12
  41. package/dist/chunks/install.js +142 -138
  42. package/dist/chunks/launch.js +4 -6
  43. package/dist/chunks/lexer.js +226 -66
  44. package/dist/chunks/local-media.js +1 -2
  45. package/dist/chunks/me.js +1 -2
  46. package/dist/chunks/media.js +1 -2
  47. package/dist/chunks/{themes.js → model-clips.js} +395 -43
  48. package/dist/chunks/models.js +3 -5
  49. package/dist/chunks/operands.js +1 -2
  50. package/dist/chunks/package-paths.js +1 -2
  51. package/dist/chunks/policy.js +1 -2
  52. package/dist/chunks/preferences.js +1 -2
  53. package/dist/chunks/profile.js +2 -3
  54. package/dist/chunks/prompts.js +1 -2
  55. package/dist/chunks/public.js +1 -2
  56. package/dist/chunks/public2.js +3 -4
  57. package/dist/chunks/references.js +3 -3
  58. package/dist/chunks/referrals.js +1 -2
  59. package/dist/chunks/rolldown-runtime.js +2 -3
  60. package/dist/chunks/rooms-connect.js +1 -2
  61. package/dist/chunks/rooms-connect2.js +1 -2
  62. package/dist/chunks/rooms-rtc.js +4 -6
  63. package/dist/chunks/rooms.js +2 -3
  64. package/dist/chunks/run.js +2 -3
  65. package/dist/chunks/runtime.js +6 -12
  66. package/dist/chunks/runtime2.js +2 -3
  67. package/dist/chunks/runtimes.js +1 -2
  68. package/dist/chunks/safe-remote-image.js +1 -2
  69. package/dist/chunks/schemas.js +58 -43
  70. package/dist/chunks/search.js +3 -3
  71. package/dist/chunks/self-update.js +4 -5
  72. package/dist/chunks/serve.js +11 -25
  73. package/dist/chunks/session-status.js +1 -2
  74. package/dist/chunks/skills.js +1 -2
  75. package/dist/chunks/spaces.js +26 -45
  76. package/dist/chunks/src.js +5 -9
  77. package/dist/chunks/supervisor.js +16 -28
  78. package/dist/chunks/supervisor2.js +1 -2
  79. package/dist/chunks/tasks.js +1 -2
  80. package/dist/chunks/user-lists.js +1 -2
  81. package/dist/chunks/version.js +1 -2
  82. package/dist/chunks/version2.js +1 -2
  83. package/dist/chunks/version3.js +3 -4
  84. package/dist/chunks/web.js +1 -2
  85. package/dist/runtime/native/pi-extension.js +1 -2
  86. package/dist/runtime/worker.js +2 -3
  87. package/package.json +11 -10
@@ -0,0 +1,970 @@
1
+ import { _ as union, a as array, c as discriminatedUnion, d as literal, f as number, g as tuple, h as string, l as json, m as record, n as _enum, p as object, s as boolean, v as unknown } from "./schemas.js";
2
+ // ../protocol/dist/board-constants.js
3
+ const BOARD_TEXT_FONT_FAMILY = "Geist Variable";
4
+ const BOARD_ARROW_STROKE_SIZE = 2.5;
5
+ const BOARD_PAGE_SIZE = {
6
+ width: 960,
7
+ height: 540
8
+ };
9
+ const BOARD_CAMERA_VIEWPORT = {
10
+ width: 1600,
11
+ height: 900
12
+ };
13
+ const BOARD_TEXT_SCALE = {
14
+ title: 56,
15
+ heading: 40,
16
+ body: 24,
17
+ caption: 16
18
+ };
19
+ const BOARD_DEFAULT_ITEM_SIZE = {
20
+ width: 240,
21
+ height: 160
22
+ };
23
+ const BOARD_DEFAULT_SIZES = {
24
+ frame: {
25
+ width: 480,
26
+ height: 320
27
+ },
28
+ shape: {
29
+ width: 200,
30
+ height: 140
31
+ },
32
+ image: {
33
+ width: 480,
34
+ height: 270
35
+ },
36
+ video: {
37
+ width: 480,
38
+ height: 270
39
+ },
40
+ audio: {
41
+ width: 320,
42
+ height: 112
43
+ },
44
+ file: {
45
+ width: 260,
46
+ height: 132
47
+ },
48
+ task: {
49
+ width: 480,
50
+ height: 270
51
+ },
52
+ session: {
53
+ width: 320,
54
+ height: 176
55
+ },
56
+ effect: {
57
+ width: 240,
58
+ height: 240
59
+ },
60
+ custom: {
61
+ width: 480,
62
+ height: 320
63
+ }
64
+ };
65
+ function boardDefaultSize(type) {
66
+ return { ...Object.hasOwn(BOARD_DEFAULT_SIZES, type) ? BOARD_DEFAULT_SIZES[type] : BOARD_DEFAULT_ITEM_SIZE };
67
+ }
68
+ function clampBoardStrokeSize(size) {
69
+ if (!Number.isFinite(size)) return BOARD_ARROW_STROKE_SIZE;
70
+ return Math.min(64, Math.max(1, size));
71
+ }
72
+ const BOARD_FONT_STACK = "\"Geist Variable\", \"Geist\", \"Noto Sans CJK SC\", \"Noto Sans SC\", \"PingFang SC\", \"Microsoft YaHei\", system-ui, -apple-system, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Noto Color Emoji\", \"Noto Sans Math\", \"Noto Sans Symbols 2\", \"DejaVu Sans\", \"FreeSans\", \"FreeSerif\", sans-serif";
73
+ const BOARD_MONO_FONT_STACK = "\"Geist Mono Variable\", \"Geist Mono\", \"Fira Code\", ui-monospace, \"Noto Sans Mono CJK SC\", \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Noto Color Emoji\", \"Noto Sans Math\", \"DejaVu Sans\", \"FreeSans\", \"FreeSerif\", monospace";
74
+ // ../protocol/dist/board-url.js
75
+ const BOARD_REMOTE_URL_MAX_LENGTH = 4096;
76
+ function parseIpv4(host) {
77
+ const parts = host.split(".").map(Number);
78
+ return parts.length === 4 && parts.every((part) => Number.isInteger(part) && part >= 0 && part <= 255) ? parts : null;
79
+ }
80
+ function isBlockedIpv4(host) {
81
+ const parts = parseIpv4(host);
82
+ if (!parts) return false;
83
+ const [first, second, third] = parts;
84
+ if (first === 0 || first === 10 || first === 127) return true;
85
+ if (first === 100 && second >= 64 && second <= 127) return true;
86
+ if (first === 169 && second === 254) return true;
87
+ if (first === 172 && second >= 16 && second <= 31) return true;
88
+ if (first === 192 && second === 168) return true;
89
+ if (first === 192 && second === 0 && (third === 0 || third === 2)) return true;
90
+ if (first === 192 && second === 88 && third === 99) return true;
91
+ if (first === 198 && (second === 18 || second === 19)) return true;
92
+ if (first === 198 && second === 51 && third === 100) return true;
93
+ if (first === 203 && second === 0 && third === 113) return true;
94
+ return first >= 224;
95
+ }
96
+ function expandIpv6(host) {
97
+ const [head, tail, extra] = host.toLowerCase().split("::");
98
+ if (extra !== void 0) return null;
99
+ const headParts = head ? head.split(":").filter(Boolean) : [];
100
+ const tailParts = tail ? tail.split(":").filter(Boolean) : [];
101
+ const missing = 8 - headParts.length - tailParts.length;
102
+ if (missing < 0 || tail === void 0 && missing !== 0) return null;
103
+ const parts = [
104
+ ...headParts,
105
+ ...Array.from({ length: missing }, () => "0"),
106
+ ...tailParts
107
+ ];
108
+ if (parts.length !== 8 || parts.some((part) => !/^[0-9a-f]{1,4}$/.test(part))) return null;
109
+ return parts.map((part) => part.padStart(4, "0"));
110
+ }
111
+ function isBlockedIpv6(host) {
112
+ const parts = expandIpv6(host);
113
+ if (!parts) return true;
114
+ if (parts.every((part) => part === "0000")) return true;
115
+ if (parts.slice(0, 7).every((part) => part === "0000") && parts[7] === "0001") return true;
116
+ if (parts.slice(0, 5).every((part) => part === "0000") && parts[5] === "ffff") {
117
+ const high = Number.parseInt(parts[6] ?? "0", 16);
118
+ const low = Number.parseInt(parts[7] ?? "0", 16);
119
+ return isBlockedIpv4(`${high >> 8}.${high & 255}.${low >> 8}.${low & 255}`);
120
+ }
121
+ if (parts.slice(0, 6).every((part) => part === "0000")) return true;
122
+ const first = Number.parseInt(parts[0] ?? "0", 16);
123
+ if ((first & 65024) === 64512) return true;
124
+ if ((first & 65472) === 65152 || (first & 65472) === 65216) return true;
125
+ if ((first & 65280) === 65280) return true;
126
+ return parts[0] === "2001" && parts[1] === "0db8";
127
+ }
128
+ function isPublicBoardRemoteAddress(value) {
129
+ const address = value.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.$/, "");
130
+ if (parseIpv4(address)) return !isBlockedIpv4(address);
131
+ return address.includes(":") && !isBlockedIpv6(address);
132
+ }
133
+ function isBlockedHost(hostname) {
134
+ const host = hostname.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.$/, "");
135
+ if (host === "localhost" || host.endsWith(".localhost") || host.endsWith(".local") || host.endsWith(".internal")) return true;
136
+ if (parseIpv4(host) || host.includes(":")) return !isPublicBoardRemoteAddress(host);
137
+ return false;
138
+ }
139
+ /**
140
+ * Normalize a browser-loadable public HTTP(S) URL. This blocks explicit local
141
+ * addresses; any future server-side fetcher must additionally validate DNS
142
+ * resolution to defend against rebinding.
143
+ */
144
+ function normalizeBoardRemoteUrl(value) {
145
+ if (typeof value !== "string") return void 0;
146
+ const input = value.trim();
147
+ if (!input || input.length > 4096) return void 0;
148
+ try {
149
+ const url = new URL(input);
150
+ if (url.protocol !== "https:" && url.protocol !== "http:") return void 0;
151
+ if (url.username || url.password || isBlockedHost(url.hostname)) return;
152
+ const normalized = url.toString();
153
+ return normalized.length <= 4096 ? normalized : void 0;
154
+ } catch {
155
+ return;
156
+ }
157
+ }
158
+ string().max(BOARD_REMOTE_URL_MAX_LENGTH).refine((value) => normalizeBoardRemoteUrl(value) !== void 0, { message: "URL must be a public HTTP(S) URL without credentials" });
159
+ const BOARD_CAMERA_TARGET = "camera";
160
+ const BoardKeySchema = string().min(1).max(160).regex(/^[^\s/]+$/, "ids must not contain whitespace or '/'");
161
+ const BoardIdSchema = BoardKeySchema.refine((value) => value !== BOARD_CAMERA_TARGET, "\"camera\" is reserved");
162
+ const finite = number().finite();
163
+ const nonNegative = finite.nonnegative();
164
+ const ratio = finite.min(0).max(1);
165
+ const BoardVec2Schema = object({
166
+ x: finite,
167
+ y: finite
168
+ }).strict();
169
+ const BoardSizeSchema = object({
170
+ width: finite.positive(),
171
+ height: finite.positive()
172
+ }).strict();
173
+ const BOARD_COLOR_TOKENS = [
174
+ "brand",
175
+ "neutral",
176
+ "black",
177
+ "white",
178
+ "blue",
179
+ "green",
180
+ "amber",
181
+ "violet",
182
+ "rose"
183
+ ];
184
+ 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(" "));
185
+ function isBoardColorString(value) {
186
+ const color = value.trim().toLowerCase();
187
+ 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);
188
+ }
189
+ const colorString = string().max(120).refine(isBoardColorString, "expected a palette token or a CSS color");
190
+ const BoardColorSchema = union([colorString, object({
191
+ light: colorString,
192
+ dark: colorString
193
+ }).strict()]).describe("Palette token (follows the theme), CSS color, or { light, dark }.");
194
+ const BOARD_DASHES = [
195
+ "solid",
196
+ "dashed",
197
+ "dotted"
198
+ ];
199
+ const BOARD_BLEND_MODES = [
200
+ "normal",
201
+ "multiply",
202
+ "screen",
203
+ "add"
204
+ ];
205
+ const BoardFilterSchema = object({
206
+ blur: finite.min(0).max(256).optional().describe("Blur radius in board units, as CSS blur()."),
207
+ brightness: finite.min(0).max(10).optional().describe("1 keeps the color, 0 is black."),
208
+ contrast: finite.min(0).max(10).optional().describe("1 keeps the color, 0 is flat gray."),
209
+ saturate: finite.min(0).max(10).optional().describe("1 keeps the color, 0 is gray, above 1 is vivid."),
210
+ hue: finite.min(-3600).max(3600).optional().describe("Hue rotation in degrees."),
211
+ grayscale: ratio.optional(),
212
+ sepia: ratio.optional(),
213
+ invert: ratio.optional()
214
+ }).strict().describe("CSS filters, applied in this order. On a frame, filter, shadow and blend treat the frame and its contents as one layer.");
215
+ const BOARD_SHADOW_DEFAULTS = {
216
+ opacity: .35,
217
+ blur: 16,
218
+ x: 0,
219
+ y: 8
220
+ };
221
+ const BoardShadowSchema = object({
222
+ color: BoardColorSchema.optional().describe("Defaults to black."),
223
+ opacity: ratio.optional().describe("Defaults to 0.35."),
224
+ blur: finite.min(0).max(256).optional().describe("Softness in board units, as CSS drop-shadow(); defaults to 16."),
225
+ x: finite.min(-1024).max(1024).optional(),
226
+ y: finite.min(-1024).max(1024).optional().describe("Defaults to 8.")
227
+ }).strict().describe("A drop shadow following the item's visible shape; with no offset and a bright color it glows.");
228
+ const BoardStyleSchema = object({
229
+ fill: BoardColorSchema.optional(),
230
+ fillOpacity: ratio.optional().describe("Fill opacity, independent of the item's opacity."),
231
+ stroke: BoardColorSchema.optional(),
232
+ strokeWidth: finite.min(0).max(64).optional(),
233
+ dash: _enum(BOARD_DASHES).optional(),
234
+ radius: nonNegative.optional().describe("Corner radius in board units."),
235
+ trim: ratio.optional().describe("Fraction of the outline drawn; animate 0 → 1 to draw it in."),
236
+ filter: BoardFilterSchema.optional(),
237
+ shadow: BoardShadowSchema.optional(),
238
+ blend: _enum(BOARD_BLEND_MODES).optional().describe("How the item mixes with what is under it.")
239
+ }).strict();
240
+ function isSafeBoardSourcePath(value) {
241
+ return value.length > 0 && value.length <= 4096 && !value.startsWith("/") && !/^[a-z][a-z\d+.-]*:/i.test(value.trimStart()) && !value.includes("\\") && value.split("/").every((part) => part.length > 0 && part !== "." && part !== "..");
242
+ }
243
+ const srcSchema = string().refine(isSafeBoardSourcePath, "src must be a relative Space file path");
244
+ function parseBoardMediaSource(src) {
245
+ if (isSafeBoardSourcePath(src)) return {
246
+ kind: "file",
247
+ value: src
248
+ };
249
+ return normalizeBoardRemoteUrl(src) ? {
250
+ kind: "url",
251
+ value: src
252
+ } : null;
253
+ }
254
+ const BoardMediaSourceSchema = string().max(4096).refine((src) => parseBoardMediaSource(src) !== null, "src must be a public HTTP(S) URL or relative Space file path").describe("Prefer a public HTTP(S) URL; a Space path relative to the workspace root also works.");
255
+ const BoardScriptSchema = object({
256
+ src: srcSchema.refine((path) => /\.m?js$/.test(path), "script src must be a .js or .mjs module").describe("A .js or .mjs Space file."),
257
+ params: record(string(), json()).default({}).describe("Values the module reads as params."),
258
+ targets: record(string().min(1).max(80), BoardIdSchema).default({}).describe("Named items the module can reach, as ctx.targets."),
259
+ seed: string().min(1).max(160).optional().describe("Seed for ctx.random() and shaders; defaults to the owner's id."),
260
+ enabled: boolean().default(true)
261
+ }).strict().describe("A JavaScript module attached to an item or the Board; `cohub boards schema script` lists its API.");
262
+ const BOARD_DEPTH_BENDS = [
263
+ "none",
264
+ "wave",
265
+ "cloth",
266
+ "curl",
267
+ "custom"
268
+ ];
269
+ const BoardDepthSchema = object({
270
+ lift: finite.default(0).describe("Height above the Board toward the viewer, in board units; a lifted item looks nearer and larger and casts a shadow."),
271
+ tilt: object({
272
+ x: finite.default(0),
273
+ y: finite.default(0)
274
+ }).strict().prefault({}).describe("Degrees the item leans about its own axes through its origin: x tips the top edge away, y the right edge; 180 turns it over."),
275
+ spin: finite.default(0).describe("Degrees the item turns within its leaned plane, after tilt; rotation turns it on the Board."),
276
+ bend: object({
277
+ kind: _enum(BOARD_DEPTH_BENDS).default("none").describe("wave ripples like a flag held at its left edge; cloth drapes and flutters around its origin; curl turns it like a page from its right edge; custom runs the bend GLSL its script module exports."),
278
+ amount: finite.default(0).describe("0 is flat, 1 a full bend."),
279
+ phase: finite.default(0).describe("Moves a wave or cloth along; one cycle every 2π. Animate it for motion.")
280
+ }).strict().prefault({}),
281
+ shade: ratio.default(.5).describe("How much the surface darkens as it turns from the light."),
282
+ shadow: ratio.default(1).describe("Strength of the shadow it casts on the Board while lifted."),
283
+ back: BoardIdSchema.optional().describe("An item drawn on the back face, shown once the item turns over; without it the back shows the front mirrored and dimmed.")
284
+ }).strict().describe("Takes the item off the Board into perspective, drawn as a live picture that rises, leans, turns and bends. A frame carries its children; depth inside a lifted frame stays part of its picture.");
285
+ const numberOr = (value, fallback) => typeof value === "number" && Number.isFinite(value) ? value : fallback;
286
+ function resolveBoardDepth(value) {
287
+ if (!value || typeof value !== "object") return null;
288
+ const raw = value;
289
+ const tilt = raw.tilt && typeof raw.tilt === "object" ? raw.tilt : {};
290
+ const bend = raw.bend && typeof raw.bend === "object" ? raw.bend : {};
291
+ const kind = BOARD_DEPTH_BENDS.includes(bend.kind) ? bend.kind : "none";
292
+ return {
293
+ lift: numberOr(raw.lift, 0),
294
+ tilt: {
295
+ x: numberOr(tilt.x, 0),
296
+ y: numberOr(tilt.y, 0)
297
+ },
298
+ spin: numberOr(raw.spin, 0),
299
+ bend: {
300
+ kind,
301
+ amount: numberOr(bend.amount, 0),
302
+ phase: numberOr(bend.phase, 0)
303
+ },
304
+ shade: Math.min(1, Math.max(0, numberOr(raw.shade, .5))),
305
+ shadow: Math.min(1, Math.max(0, numberOr(raw.shadow, 1))),
306
+ ...typeof raw.back === "string" && raw.back ? { back: raw.back } : {}
307
+ };
308
+ }
309
+ function isBoardDepthActive(depth) {
310
+ return !!depth && (depth.lift !== 0 || depth.tilt.x % 360 !== 0 || depth.tilt.y % 360 !== 0 || depth.spin % 360 !== 0 || depth.bend.kind !== "none" && depth.bend.amount !== 0);
311
+ }
312
+ const BoardAttachSchema = object({
313
+ item: BoardIdSchema.describe("The item to follow; position becomes an offset from its origin, so the item moves with it."),
314
+ node: string().min(1).max(240).optional().describe("A named node of a 3D model object, such as a hand bone (props.snapshot.nodes lists them): the item rides on it in 3D as the model moves and animates.")
315
+ }).strict().describe("Follows another item instead of sitting in a frame; on a 3D model object it can ride one of the model's nodes.");
316
+ const itemEnvelope = {
317
+ script: BoardScriptSchema.optional(),
318
+ parent: BoardIdSchema.optional().describe("A frame id; position becomes relative to the frame, and the item moves with it."),
319
+ attach: BoardAttachSchema.optional(),
320
+ z: finite.optional().describe("Order among siblings; new items go on top."),
321
+ position: BoardVec2Schema.default({
322
+ x: 0,
323
+ y: 0
324
+ }),
325
+ rotation: finite.default(0),
326
+ scale: union([finite, BoardVec2Schema]).default(1),
327
+ origin: BoardVec2Schema.default({
328
+ x: .5,
329
+ y: .5
330
+ }).describe("Rotation and scale origin as fractions of the size."),
331
+ opacity: ratio.default(1),
332
+ visible: boolean().optional().describe("false hides the item and its children; key it on a timeline to show the item only for a span."),
333
+ style: BoardStyleSchema.default({}),
334
+ depth: BoardDepthSchema.optional(),
335
+ locked: boolean().optional(),
336
+ autoplay: boolean().optional().describe("true shows live content as the Board opens: an app runs, a video loops muted, a 3D model renders. Ignored for other items and for a video whose props.time follows a timeline."),
337
+ metadata: record(string(), unknown()).optional()
338
+ };
339
+ const boxed = (size) => ({
340
+ ...itemEnvelope,
341
+ size: BoardSizeSchema.default({ ...size })
342
+ });
343
+ const unsized = { ...itemEnvelope };
344
+ const fontSize = finite.min(2).max(512);
345
+ const BOARD_TEXT_ALIGNS = [
346
+ "left",
347
+ "center",
348
+ "right"
349
+ ];
350
+ const BOARD_TEXT_REVEAL_UNITS = [
351
+ "char",
352
+ "word",
353
+ "line"
354
+ ];
355
+ const BOARD_TEXT_REVEAL_MOTIONS = [
356
+ "cut",
357
+ "fade",
358
+ "rise"
359
+ ];
360
+ const BOARD_SHAPE_GEOMETRIES = [
361
+ "rectangle",
362
+ "rounded",
363
+ "ellipse",
364
+ "diamond",
365
+ "triangle",
366
+ "path"
367
+ ];
368
+ const BoardFrameItemSchema = object({
369
+ ...boxed(BOARD_DEFAULT_SIZES.frame),
370
+ type: literal("frame"),
371
+ props: object({
372
+ label: string().max(280).default(""),
373
+ decoration: _enum(["frame", "none"]).optional().describe("none hides the title, border and background: an invisible group whose tracks move every child; with a label it is also a page viewers step to."),
374
+ clip: boolean().default(true).describe("Hide children outside the frame.")
375
+ }).strict().prefault({})
376
+ }).strict();
377
+ const BoardTextItemSchema = object({
378
+ ...unsized,
379
+ type: literal("text"),
380
+ props: object({
381
+ text: string().default(""),
382
+ fontSize: fontSize.default(24),
383
+ fontWeight: finite.min(100).max(900).default(500),
384
+ font: string().min(1).max(120).default("sans").describe("sans, serif, mono, or a font family name."),
385
+ align: _enum(BOARD_TEXT_ALIGNS).default("left"),
386
+ lineHeight: finite.min(.5).max(4).default(4 / 3),
387
+ width: finite.positive().optional().describe("Wrap width; the height follows the text."),
388
+ reveal: ratio.default(1).describe("Fraction of the text shown; animate 0 → 1 to type it."),
389
+ revealBy: _enum(BOARD_TEXT_REVEAL_UNITS).optional().describe("What reveal counts: char (default), word or line."),
390
+ revealMotion: _enum(BOARD_TEXT_REVEAL_MOTIONS).optional().describe("How each unit appears: cut (default), fade or rise."),
391
+ caret: boolean().default(false).describe("Blink a caret while the text is being revealed.")
392
+ }).strict().prefault({})
393
+ }).strict();
394
+ const BoardShapeItemSchema = object({
395
+ ...boxed(BOARD_DEFAULT_SIZES.shape),
396
+ type: literal("shape"),
397
+ props: object({
398
+ geometry: _enum(BOARD_SHAPE_GEOMETRIES).default("rectangle"),
399
+ path: string().min(1).max(2e5).optional().describe("SVG path data for path geometry, fitted to the item size."),
400
+ text: string().default(""),
401
+ fontSize: fontSize.default(20),
402
+ align: _enum(BOARD_TEXT_ALIGNS).default("center")
403
+ }).strict().refine((props) => props.geometry !== "path" || Boolean(props.path), {
404
+ message: "path geometry requires props.path",
405
+ path: ["path"]
406
+ }).prefault({})
407
+ }).strict();
408
+ const BoardDrawPointSchema = object({
409
+ x: finite,
410
+ y: finite,
411
+ p: ratio.default(.5).describe("Pen pressure.")
412
+ }).strict();
413
+ const BoardDrawItemSchema = object({
414
+ ...unsized,
415
+ type: literal("draw"),
416
+ props: object({ points: array(BoardDrawPointSchema).min(1).max(1e5).describe("Stroke points relative to position; the size follows them.") }).strict()
417
+ }).strict();
418
+ const BoardArrowAnchorSchema = union([
419
+ literal("auto"),
420
+ object({
421
+ side: _enum([
422
+ "top",
423
+ "right",
424
+ "bottom",
425
+ "left"
426
+ ]),
427
+ offset: ratio.default(.5)
428
+ }).strict(),
429
+ object({
430
+ x: ratio,
431
+ y: ratio
432
+ }).strict()
433
+ ]);
434
+ const BoardArrowBindingSchema = object({
435
+ item: BoardIdSchema,
436
+ anchor: BoardArrowAnchorSchema.default("auto").describe("auto uses the side facing the other end; or a side with an offset, or a point as fractions of the item."),
437
+ port: string().min(1).max(120).optional()
438
+ }).strict();
439
+ const BoardArrowEndSchema = union([BoardVec2Schema, BoardArrowBindingSchema]).describe("A point relative to position, or { item } to follow that item.");
440
+ const BOARD_ARROW_ROUTES = [
441
+ "straight",
442
+ "curve",
443
+ "orthogonal"
444
+ ];
445
+ const BoardArrowItemSchema = object({
446
+ ...unsized,
447
+ type: literal("arrow"),
448
+ props: object({
449
+ start: BoardArrowEndSchema,
450
+ end: BoardArrowEndSchema,
451
+ route: _enum(BOARD_ARROW_ROUTES).default("straight"),
452
+ bend: finite.min(-.85).max(.85).default(0).describe("Sideways curve as a fraction of the length; the sign picks the side."),
453
+ waypoints: array(BoardVec2Schema).max(64).default([]).describe("Points the route passes through."),
454
+ arrowStart: boolean().default(false),
455
+ arrowEnd: boolean().default(true),
456
+ label: string().max(280).default(""),
457
+ fontSize: fontSize.default(14),
458
+ relation: string().max(64).regex(/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/, "relation must be a lowercase slug").optional().describe("What the arrow means, as a slug such as triggers or depends-on.")
459
+ }).strict()
460
+ }).strict();
461
+ const fileProps = {
462
+ src: BoardMediaSourceSchema,
463
+ snapshot: object({
464
+ title: string().optional(),
465
+ mimeType: string().optional(),
466
+ size: nonNegative.optional(),
467
+ mtimeMs: nonNegative.optional(),
468
+ naturalWidth: finite.positive().optional(),
469
+ naturalHeight: finite.positive().optional(),
470
+ durationMs: nonNegative.optional(),
471
+ excerpt: string().optional(),
472
+ coverPath: string().optional(),
473
+ coverUrl: string().optional(),
474
+ clips: array(object({
475
+ name: string().min(1).max(240),
476
+ durationMs: nonNegative
477
+ }).strict()).max(64).optional().describe("A 3D model's animation clips in file order, with their lengths."),
478
+ nodes: array(string().min(1).max(240)).max(256).optional().describe("A 3D model's named nodes in file order, for attach.node.")
479
+ }).strict().describe("Cached facts for an instant preview; filled in when the media loads.").optional()
480
+ };
481
+ const BoardModelViewSchema = object({
482
+ yaw: finite.describe("Degrees around the model; 0 faces its front, 90 its right side."),
483
+ pitch: finite.min(-90).max(90).describe("Degrees above the model; 90 looks straight down."),
484
+ zoom: finite.positive().max(100).describe("1 fits the whole model; 2 is twice as close."),
485
+ target: tuple([
486
+ finite,
487
+ finite,
488
+ finite
489
+ ]).optional().describe("Pivot offset from the model's centre, in model radii.")
490
+ }).strict();
491
+ const BoardModelSettingsSchema = object({
492
+ view: BoardModelViewSchema.optional().describe("Camera for the card's still and where the model turns back to; the default three-quarter view without it."),
493
+ animation: string().min(1).max(240).optional().describe("Animation clip that plays; the model's first without it. Changing it crossfades over fade."),
494
+ time: nonNegative.optional().describe("Position in the clip in milliseconds, for a timeline or a script to drive; without it an autoplay model plays the clip on the Board clock."),
495
+ loop: boolean().optional().describe("false plays the clip once and holds its last pose; it loops by default."),
496
+ fade: finite.min(0).max(1e4).optional().describe(`Crossfade in milliseconds when the clip changes; 250 by default, 0 cuts.`),
497
+ display: _enum(["card", "object"]).optional().describe("card (default) shows a still in a card; object rests the model itself on the Board, facing the viewer as view shows it, fitted to the item's box, lit, shadowed and drawn among lifted items.")
498
+ }).strict().describe("How a 3D model file shows; ignored for other files.");
499
+ const BoardMediaOriginSchema = object({
500
+ taskRunId: string().min(1).max(160),
501
+ artifactId: string().min(1).max(240)
502
+ }).strict().describe("The generation run and result this media came from.");
503
+ const mediaProps = {
504
+ ...fileProps,
505
+ origin: BoardMediaOriginSchema.optional()
506
+ };
507
+ const timedFileProps = {
508
+ ...mediaProps,
509
+ time: nonNegative.optional().describe("Playback position in milliseconds; animate props.time to play it on a timeline. It sounds while its time moves forward."),
510
+ volume: ratio.optional().describe("Loudness from 0 to 1; defaults to 1. Animate it to fade.")
511
+ };
512
+ const BoardCropSchema = object({
513
+ x: ratio,
514
+ y: ratio,
515
+ w: ratio,
516
+ h: ratio
517
+ }).strict().describe("Region shown, as fractions of the image. Without it the whole image fits inside size.");
518
+ const BoardImageItemSchema = object({
519
+ ...boxed(BOARD_DEFAULT_SIZES.image),
520
+ type: literal("image"),
521
+ props: object({
522
+ ...mediaProps,
523
+ crop: BoardCropSchema.optional()
524
+ }).strict()
525
+ }).strict();
526
+ const BoardVideoItemSchema = object({
527
+ ...boxed(BOARD_DEFAULT_SIZES.video),
528
+ type: literal("video"),
529
+ props: object(timedFileProps).strict()
530
+ }).strict();
531
+ const BoardAudioItemSchema = object({
532
+ ...boxed(BOARD_DEFAULT_SIZES.audio),
533
+ type: literal("audio"),
534
+ props: object(timedFileProps).strict()
535
+ }).strict();
536
+ const BoardFileItemSchema = object({
537
+ ...boxed(BOARD_DEFAULT_SIZES.file),
538
+ type: literal("file"),
539
+ props: object({
540
+ ...fileProps,
541
+ model: BoardModelSettingsSchema.optional()
542
+ }).strict()
543
+ }).strict();
544
+ const httpsUrl = string().max(4096).url();
545
+ const artifactBase = {
546
+ id: string().min(1).max(240),
547
+ title: string().max(240).optional(),
548
+ url: httpsUrl,
549
+ mimeType: string().max(160).optional()
550
+ };
551
+ const BoardTaskArtifactSchema = discriminatedUnion("type", [
552
+ object({
553
+ ...artifactBase,
554
+ type: literal("image"),
555
+ naturalWidth: finite.positive().optional(),
556
+ naturalHeight: finite.positive().optional()
557
+ }).strict(),
558
+ object({
559
+ ...artifactBase,
560
+ type: literal("video"),
561
+ previewUrl: httpsUrl.optional(),
562
+ durationMs: number().int().positive().optional(),
563
+ naturalWidth: finite.positive().optional(),
564
+ naturalHeight: finite.positive().optional()
565
+ }).strict(),
566
+ object({
567
+ ...artifactBase,
568
+ type: literal("audio"),
569
+ previewUrl: httpsUrl.optional(),
570
+ durationMs: number().int().positive().optional()
571
+ }).strict(),
572
+ object({
573
+ id: string().min(1).max(240),
574
+ type: literal("text"),
575
+ title: string().max(240).optional(),
576
+ textExcerpt: string().min(1).max(480)
577
+ }).strict()
578
+ ]);
579
+ const BoardTaskSnapshotSchema = object({
580
+ taskType: string().min(1).max(120),
581
+ status: _enum([
582
+ "pending",
583
+ "running",
584
+ "completed",
585
+ "failed"
586
+ ]),
587
+ title: string().min(1).max(240),
588
+ model: string().max(160).optional(),
589
+ promptExcerpt: string().max(480).optional(),
590
+ errorExcerpt: string().max(240).optional(),
591
+ artifactCount: number().int().nonnegative(),
592
+ artifacts: array(BoardTaskArtifactSchema).max(6).default([]),
593
+ startedAt: string().max(64).optional(),
594
+ updatedAt: string().optional()
595
+ }).strict();
596
+ const BoardTaskItemSchema = object({
597
+ ...boxed(BOARD_DEFAULT_SIZES.task),
598
+ type: literal("task"),
599
+ props: object({
600
+ taskRunId: string().min(1).max(160).describe("The generation run shown; the server keeps the card's status and results up to date."),
601
+ snapshot: BoardTaskSnapshotSchema.describe("Maintained by the server; omit it.")
602
+ }).strict()
603
+ }).strict();
604
+ const BoardSessionSnapshotSchema = object({
605
+ title: string().max(255).default(""),
606
+ excerpt: string().max(480).optional().describe("The latest message as plain text."),
607
+ source: string().max(120).optional().describe("Where the chat runs: web, cli or a channel."),
608
+ issue: _enum(["failed", "lost"]).optional().describe("How the last run ended when it did not finish."),
609
+ errorExcerpt: string().max(240).optional(),
610
+ activityAt: string().max(64).optional()
611
+ }).strict();
612
+ const BoardSessionItemSchema = object({
613
+ ...boxed(BOARD_DEFAULT_SIZES.session),
614
+ type: literal("session"),
615
+ props: object({
616
+ sessionId: string().min(1).max(160).describe("The chat shown; the server keeps its title, latest message and status up to date."),
617
+ snapshot: BoardSessionSnapshotSchema.describe("Maintained by the server; omit it.")
618
+ }).strict()
619
+ }).strict();
620
+ const BOARD_EFFECT_KINDS = [
621
+ "particles",
622
+ "trail",
623
+ "impact",
624
+ "flash",
625
+ "glow"
626
+ ];
627
+ const BOARD_PARTICLE_SHAPES = [
628
+ "circle",
629
+ "square",
630
+ "star",
631
+ "heart",
632
+ "spark"
633
+ ];
634
+ const BOARD_EFFECT_KIND_INFO = {
635
+ particles: {
636
+ description: "Continuous particles emitted inside the effect frame.",
637
+ parameters: {
638
+ rate: "Particles per second.",
639
+ life: "Particle lifetime in milliseconds.",
640
+ particleSize: "Particle size in board units.",
641
+ speed: "Particle speed in board units per second.",
642
+ direction: "Emission direction in degrees.",
643
+ spread: "Emission spread in degrees.",
644
+ gravity: "Acceleration in board units per second squared.",
645
+ intensity: "Opacity and size multiplier.",
646
+ seed: "Stable seed for repeatable particle motion.",
647
+ shape: "circle, square, star, heart or spark.",
648
+ colors: "Up to eight colors the particles pick from."
649
+ }
650
+ },
651
+ trail: {
652
+ description: "A fading trail following another item.",
653
+ parameters: {
654
+ follow: "ID of the item to follow.",
655
+ life: "Trail lifetime in milliseconds.",
656
+ particleSize: "Trail width in board units.",
657
+ intensity: "Opacity multiplier."
658
+ }
659
+ },
660
+ impact: {
661
+ description: "A repeating radial burst centered in the effect frame.",
662
+ parameters: {
663
+ rate: "Particles per burst.",
664
+ life: "Time between bursts in milliseconds.",
665
+ particleSize: "Particle and ring size in board units.",
666
+ speed: "Particle speed in board units per second.",
667
+ direction: "Burst direction in degrees.",
668
+ spread: "Burst spread in degrees.",
669
+ gravity: "Acceleration in board units per second squared.",
670
+ intensity: "Opacity multiplier.",
671
+ seed: "Stable seed for repeatable bursts.",
672
+ shape: "circle, square, star, heart or spark.",
673
+ colors: "Up to eight colors the particles pick from."
674
+ }
675
+ },
676
+ flash: {
677
+ description: "A repeating full-frame flash.",
678
+ parameters: {
679
+ life: "Time between flashes in milliseconds.",
680
+ intensity: "Flash opacity multiplier."
681
+ }
682
+ },
683
+ glow: {
684
+ description: "A pulsing set of concentric rings.",
685
+ parameters: {
686
+ life: "Pulse period in milliseconds.",
687
+ intensity: "Glow opacity multiplier."
688
+ }
689
+ }
690
+ };
691
+ const BoardEffectItemSchema = object({
692
+ ...boxed(BOARD_DEFAULT_SIZES.effect),
693
+ type: literal("effect"),
694
+ props: object({
695
+ kind: _enum(BOARD_EFFECT_KINDS),
696
+ rate: nonNegative.max(2e4).default(40),
697
+ life: finite.positive().max(6e4).default(1200),
698
+ particleSize: finite.positive().max(512).default(6),
699
+ speed: nonNegative.max(1e4).default(120),
700
+ direction: finite.default(-90),
701
+ spread: finite.min(0).max(360).default(360),
702
+ gravity: finite.default(0),
703
+ intensity: nonNegative.max(10).default(1),
704
+ follow: BoardIdSchema.optional().describe("trail: the item to follow."),
705
+ seed: string().min(1).max(160).optional().describe("Makes procedural motion repeatable."),
706
+ shape: _enum(BOARD_PARTICLE_SHAPES).optional().describe("particles and impact: circle by default; square and star tumble, spark streaks along its motion."),
707
+ colors: array(BoardColorSchema).min(1).max(8).optional().describe("particles and impact: each particle picks one; defaults to style.fill.")
708
+ }).strict()
709
+ }).strict();
710
+ const BoardCustomItemSchema = object({
711
+ ...boxed(BOARD_DEFAULT_SIZES.custom),
712
+ type: literal("custom"),
713
+ script: BoardScriptSchema,
714
+ props: object({}).strict().default({})
715
+ }).strict();
716
+ const BOARD_EXTENSION_TYPE_PATTERN = /^[a-z][a-z0-9]*(?:\.[a-z0-9-]+)+$/;
717
+ const BoardItemPreviewSchema = object({
718
+ title: string().max(500).optional(),
719
+ excerpt: string().max(2e3).optional(),
720
+ cover: BoardMediaSourceSchema.optional().describe("An image for the card."),
721
+ src: BoardMediaSourceSchema.optional().describe("The file or page the card stands for.")
722
+ }).strict().describe("How a client without this type's renderer shows the card, and what it refers to. The type's own client keeps it current.");
723
+ const BoardExtensionItemSchema = object({
724
+ ...boxed(BOARD_DEFAULT_ITEM_SIZE),
725
+ type: string().regex(BOARD_EXTENSION_TYPE_PATTERN),
726
+ props: record(string(), unknown()).default({}),
727
+ preview: BoardItemPreviewSchema.optional()
728
+ }).strict();
729
+ const BOARD_ITEM_SCHEMAS = {
730
+ frame: BoardFrameItemSchema,
731
+ text: BoardTextItemSchema,
732
+ shape: BoardShapeItemSchema,
733
+ draw: BoardDrawItemSchema,
734
+ arrow: BoardArrowItemSchema,
735
+ image: BoardImageItemSchema,
736
+ video: BoardVideoItemSchema,
737
+ audio: BoardAudioItemSchema,
738
+ file: BoardFileItemSchema,
739
+ task: BoardTaskItemSchema,
740
+ session: BoardSessionItemSchema,
741
+ effect: BoardEffectItemSchema,
742
+ custom: BoardCustomItemSchema
743
+ };
744
+ const BOARD_ITEM_TYPES = Object.keys(BOARD_ITEM_SCHEMAS);
745
+ function isBuiltinItemType(type) {
746
+ return Object.hasOwn(BOARD_ITEM_SCHEMAS, type);
747
+ }
748
+ function isBuiltinItem(item) {
749
+ return isBuiltinItemType(item.type);
750
+ }
751
+ function boardItemPreview(item) {
752
+ return isBuiltinItem(item) ? null : item.preview ?? null;
753
+ }
754
+ const BOARD_DERIVED_SIZE_TYPES = [
755
+ "text",
756
+ "draw",
757
+ "arrow"
758
+ ];
759
+ function hasAuthoredSize(type) {
760
+ return !BOARD_DERIVED_SIZE_TYPES.includes(type);
761
+ }
762
+ function boardItemSchema(type) {
763
+ if (isBuiltinItemType(type)) return BOARD_ITEM_SCHEMAS[type];
764
+ return BOARD_EXTENSION_TYPE_PATTERN.test(type) ? BoardExtensionItemSchema : null;
765
+ }
766
+ function issuesToDiagnostics(error, path) {
767
+ return error.issues.map((issue) => {
768
+ return {
769
+ severity: "error",
770
+ code: "INVALID_ITEM",
771
+ path: [path, ...issue.path.map(String)].filter(Boolean).join("."),
772
+ message: issue.code === "unrecognized_keys" ? `unknown ${issue.keys.length === 1 ? "property" : "properties"} ${issue.keys.join(", ")}` : issue.message
773
+ };
774
+ });
775
+ }
776
+ const keepAllBoardFields = () => true;
777
+ function keepBoardFieldsOf(value) {
778
+ return (path, key) => Object.hasOwn(fieldAt(value, path) ?? {}, key);
779
+ }
780
+ function fieldAt(value, path) {
781
+ let cursor = value;
782
+ for (const segment of path) cursor = cursor && typeof cursor === "object" ? cursor[segment] : void 0;
783
+ return cursor && typeof cursor === "object" ? cursor : null;
784
+ }
785
+ function withoutFields(value, path, keys) {
786
+ if (!value || typeof value !== "object") return value;
787
+ const copy = Array.isArray(value) ? [...value] : { ...value };
788
+ if (path.length === 0) for (const key of keys) delete copy[key];
789
+ else copy[path[0]] = withoutFields(copy[path[0]], path.slice(1), keys);
790
+ return copy;
791
+ }
792
+ function parseKeepingBoardFields(schema, value, keep) {
793
+ const kept = [];
794
+ let candidate = value;
795
+ for (;;) {
796
+ const result = schema.safeParse(candidate);
797
+ if (result.success) {
798
+ for (const field of kept) {
799
+ const target = fieldAt(result.data, field.path);
800
+ if (target) target[field.key] = field.value;
801
+ }
802
+ return result;
803
+ }
804
+ if (!keep) return result;
805
+ let stripped = false;
806
+ for (const issue of result.error.issues) {
807
+ if (issue.code !== "unrecognized_keys") continue;
808
+ const keys = issue.keys.filter((key) => key !== "__proto__" && keep(issue.path, key));
809
+ if (!keys.length) continue;
810
+ const source = fieldAt(candidate, issue.path);
811
+ for (const key of keys) kept.push({
812
+ path: issue.path,
813
+ key,
814
+ value: source?.[key]
815
+ });
816
+ candidate = withoutFields(candidate, issue.path, keys);
817
+ stripped = true;
818
+ }
819
+ if (!stripped) return result;
820
+ }
821
+ }
822
+ function parseBoardItem(value, path = "item", keep) {
823
+ const type = value && typeof value === "object" && !Array.isArray(value) ? value.type : void 0;
824
+ if (typeof type !== "string") return {
825
+ ok: false,
826
+ diagnostics: [{
827
+ severity: "error",
828
+ code: "INVALID_ITEM",
829
+ path: `${path}.type`,
830
+ message: "type is required"
831
+ }]
832
+ };
833
+ const schema = boardItemSchema(type);
834
+ if (!schema) return {
835
+ ok: false,
836
+ diagnostics: [{
837
+ severity: "error",
838
+ code: "INVALID_ITEM",
839
+ path: `${path}.type`,
840
+ message: `unknown type ${type}; expected ${BOARD_ITEM_TYPES.join(", ")} or a namespaced extension type`
841
+ }]
842
+ };
843
+ const parsed = parseKeepingBoardFields(schema, value, keep);
844
+ return parsed.success ? {
845
+ ok: true,
846
+ item: parsed.data
847
+ } : {
848
+ ok: false,
849
+ diagnostics: issuesToDiagnostics(parsed.error, path)
850
+ };
851
+ }
852
+ const CSS_EASE_KEYWORDS = /* @__PURE__ */ new Set([
853
+ "linear",
854
+ "ease",
855
+ "ease-in",
856
+ "ease-out",
857
+ "ease-in-out",
858
+ "step-start",
859
+ "step-end"
860
+ ]);
861
+ function isBoardEase(value) {
862
+ const ease = value.trim();
863
+ if (CSS_EASE_KEYWORDS.has(ease)) return true;
864
+ const bezier = /^cubic-bezier\(\s*([^,()]+),\s*([^,()]+),\s*([^,()]+),\s*([^,()]+)\)$/.exec(ease);
865
+ if (bezier) {
866
+ const [x1, , x2] = bezier.slice(1).map(Number);
867
+ return bezier.slice(1).every((part) => Number.isFinite(Number(part))) && x1 >= 0 && x1 <= 1 && x2 >= 0 && x2 <= 1;
868
+ }
869
+ return /^steps\(\s*[1-9]\d*\s*(?:,\s*(?:start|end|jump-start|jump-end|jump-none|jump-both)\s*)?\)$/.test(ease);
870
+ }
871
+ const BoardEaseSchema = string().max(120).refine(isBoardEase, "expected a CSS easing: linear, ease-in-out, cubic-bezier(…) or steps(…)");
872
+ const BoardKeyframeSchema = object({
873
+ at: nonNegative.describe("Time in milliseconds."),
874
+ value: unknown(),
875
+ ease: BoardEaseSchema.optional().describe("Easing into this keyframe: a CSS keyword, cubic-bezier() or steps(); defaults to linear.")
876
+ }).strict();
877
+ const BoardTrackSchema = object({
878
+ target: string().min(1).max(160).describe("An item id, camera, a Board script id, or another animation id (its time property nests that timeline)."),
879
+ property: string().min(1).max(200).describe("JSON path in the target, e.g. position, opacity, style.fill, props.text; params.<name> for a Board script."),
880
+ keyframes: array(BoardKeyframeSchema).min(1).max(1e5).describe("Ordered by at. The value holds before the first and after the last keyframe."),
881
+ composite: _enum(["replace", "add"]).default("replace").describe("replace: the latest-started track wins. add: positions and rotations add; scale and opacity multiply."),
882
+ interpolation: _enum([
883
+ "auto",
884
+ "step",
885
+ "spline"
886
+ ]).default("auto").describe("auto blends numbers, vectors and colors and steps other values; spline smooths position paths."),
887
+ orient: boolean().optional().describe("Rotate the item along its path.")
888
+ }).strict().superRefine((track, context) => {
889
+ for (let index = 1; index < track.keyframes.length; index += 1) if ((track.keyframes[index]?.at ?? 0) < (track.keyframes[index - 1]?.at ?? 0)) context.addIssue({
890
+ code: "custom",
891
+ message: "keyframes must be ordered by at",
892
+ path: [
893
+ "keyframes",
894
+ index,
895
+ "at"
896
+ ]
897
+ });
898
+ });
899
+ const BoardMarkerSchema = object({
900
+ at: nonNegative,
901
+ label: string().max(280).optional(),
902
+ pause: boolean().optional().describe("Hold shared playback here until next.")
903
+ }).strict();
904
+ const BoardAnimationHeaderSchema = object({
905
+ name: string().max(280).optional(),
906
+ duration: finite.positive().max(864e5).describe("Milliseconds; a new animation without it ends at its last keyframe."),
907
+ play: _enum([
908
+ "manual",
909
+ "auto",
910
+ "always"
911
+ ]).default("manual").describe("manual: only shared playback starts it. auto: plays when the Board opens. always: loops continuously."),
912
+ delay: nonNegative.default(0),
913
+ loop: boolean().default(false),
914
+ end: _enum(["hold", "reset"]).default("hold").describe("hold keeps the last frame; reset returns to the start."),
915
+ markers: array(BoardMarkerSchema).max(1e4).default([]).describe("Labeled points on this timeline; a nested animation's markers do not carry over."),
916
+ viewport: object({
917
+ width: number().int().positive().max(8192),
918
+ height: number().int().positive().max(8192)
919
+ }).strict().optional().describe(`Screen pixels the camera tracks are framed for, ${BOARD_CAMERA_VIEWPORT.width}x${BOARD_CAMERA_VIEWPORT.height} by default. Every screen and export shows that framing, scaled to fit.`)
920
+ }).strict();
921
+ BoardAnimationHeaderSchema.extend({ tracks: record(BoardKeySchema, BoardTrackSchema).default({}) }).strict();
922
+ const BOARD_ENTER_PRESETS = [
923
+ "fade-in",
924
+ "rise",
925
+ "drop",
926
+ "pop",
927
+ "deal"
928
+ ];
929
+ const BoardBackgroundSchema = object({
930
+ color: BoardColorSchema.optional(),
931
+ pattern: _enum([
932
+ "none",
933
+ "dots",
934
+ "grid"
935
+ ]).optional().describe("Spaced by grid.size; omit to follow the theme."),
936
+ image: object({
937
+ src: BoardMediaSourceSchema,
938
+ fit: _enum([
939
+ "cover",
940
+ "contain",
941
+ "repeat"
942
+ ]).default("cover").describe("cover and contain fill the view; repeat tiles the Board at one board unit per image pixel."),
943
+ opacity: ratio.optional()
944
+ }).strict().optional()
945
+ }).strict().describe("Layers drawn under every item: color, then image, then pattern. Without a color or image the theme's backdrop shows.");
946
+ const BoardAtmosphereSchema = object({
947
+ vignette: ratio.optional().describe("Darkens the edges of the view."),
948
+ grain: ratio.optional().describe("Film grain over the view.")
949
+ }).strict().describe("Screen effects over every item, for viewers and exports alike.");
950
+ const BoardSettingsSchema = object({
951
+ title: string().min(1).max(255).optional(),
952
+ background: BoardBackgroundSchema.default({}),
953
+ grid: object({
954
+ size: finite.min(4).max(512).default(24).describe("Pattern spacing and snap step, in board units."),
955
+ snap: boolean().default(false).describe("Snap moved and resized items to the grid.")
956
+ }).strict().optional(),
957
+ atmosphere: BoardAtmosphereSchema.optional(),
958
+ enter: object({
959
+ preset: _enum(BOARD_ENTER_PRESETS),
960
+ duration: finite.positive().max(1e4).optional()
961
+ }).strict().optional().describe("Motion for items as they are added."),
962
+ scripts: record(BoardIdSchema, BoardScriptSchema).refine((scripts) => Object.keys(scripts).length <= 32, `A Board takes at most 32 scripts of its own.`).optional().describe("Modules attached to the Board itself, by id: every item is in their scope and they draw over the whole view. Ids are shared with items and animations.")
963
+ }).strict();
964
+ const patchObject = record(string(), unknown());
965
+ const BoardPatchSchema = object({
966
+ board: patchObject.nullable().optional(),
967
+ items: record(BoardIdSchema, patchObject.nullable()).optional(),
968
+ animations: record(BoardIdSchema, patchObject.and(object({ tracks: record(BoardKeySchema, patchObject.nullable()).optional() })).nullable()).optional()
969
+ }).strict();
970
+ export { parseBoardMediaSource as A, BOARD_PAGE_SIZE as B, hasAuthoredSize as C, keepAllBoardFields as D, isSafeBoardSourcePath as E, BOARD_ARROW_STROKE_SIZE as F, BOARD_TEXT_SCALE as H, BOARD_CAMERA_VIEWPORT as I, BOARD_DEFAULT_SIZES as L, resolveBoardDepth as M, isPublicBoardRemoteAddress as N, keepBoardFieldsOf as O, normalizeBoardRemoteUrl as P, BOARD_FONT_STACK as R, boardItemSchema as S, isBuiltinItemType as T, boardDefaultSize as U, BOARD_TEXT_FONT_FAMILY as V, clampBoardStrokeSize as W, BoardScriptSchema as _, BOARD_EXTENSION_TYPE_PATTERN as a, BoardVec2Schema as b, BOARD_SHADOW_DEFAULTS as c, BoardColorSchema as d, BoardDepthSchema as f, BoardPatchSchema as g, BoardKeySchema as h, BOARD_EFFECT_KIND_INFO as i, parseKeepingBoardFields as j, parseBoardItem as k, BOARD_SHAPE_GEOMETRIES as l, BoardIdSchema as m, BOARD_COLOR_TOKENS as n, BOARD_ITEM_SCHEMAS as o, BoardExtensionItemSchema as p, BOARD_EFFECT_KINDS as r, BOARD_ITEM_TYPES as s, BOARD_CAMERA_TARGET as t, BoardAnimationHeaderSchema as u, BoardSettingsSchema as v, isBoardDepthActive as w, boardItemPreview as x, BoardTrackSchema as y, BOARD_MONO_FONT_STACK as z };