@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.
- package/dist/board-gpu/page.js +3011 -133
- package/dist/bootstrap.js +2 -4
- package/dist/build.json +1 -1
- package/dist/chunks/FilterPipe.js +145 -269
- package/dist/chunks/about.js +2 -3
- package/dist/chunks/app-realtime.js +113 -115
- package/dist/chunks/app-realtime2.js +1 -2
- package/dist/chunks/app-ref.js +4 -5
- package/dist/chunks/apps.js +8 -14
- package/dist/chunks/auth.js +1 -2
- package/dist/chunks/avatar.js +2 -4
- package/dist/chunks/binary-pins.js +1 -2
- package/dist/chunks/board-export-resources.js +55 -12
- package/dist/chunks/board-export.js +26 -21
- package/dist/chunks/board-export2.js +1 -2
- package/dist/chunks/board-kernel.js +2672 -1623
- package/dist/chunks/board-kernel2.js +2 -2
- package/dist/chunks/board-model.js +970 -0
- package/dist/chunks/board-profile.js +4 -5
- package/dist/chunks/board-simulate.js +6 -6
- package/dist/chunks/board-time.js +1 -2
- package/dist/chunks/boards.js +547 -23
- package/dist/chunks/browserAll.js +18 -35
- package/dist/chunks/channels.js +1 -2
- package/dist/chunks/client.js +637 -713
- package/dist/chunks/command-input.js +1 -2
- package/dist/chunks/commander.js +16 -22
- package/dist/chunks/cron-jobs.js +2 -3
- package/dist/chunks/daemon.js +18 -4
- package/dist/chunks/daemon2.js +1 -2
- package/dist/chunks/desktop.js +2 -3
- package/dist/chunks/endpoint-options.js +1 -2
- package/dist/chunks/env-proxy.js +4 -5
- package/dist/chunks/environment.js +2 -4
- package/dist/chunks/feedback.js +3 -4
- package/dist/chunks/generations.js +3 -4
- package/dist/chunks/host.js +1 -2
- package/dist/chunks/http-put.js +1 -2
- package/dist/chunks/id.js +77 -928
- package/dist/chunks/init.js +7 -12
- package/dist/chunks/install.js +142 -138
- package/dist/chunks/launch.js +4 -6
- package/dist/chunks/lexer.js +226 -66
- package/dist/chunks/local-media.js +1 -2
- package/dist/chunks/me.js +1 -2
- package/dist/chunks/media.js +1 -2
- package/dist/chunks/{themes.js → model-clips.js} +395 -43
- package/dist/chunks/models.js +3 -5
- package/dist/chunks/operands.js +1 -2
- package/dist/chunks/package-paths.js +1 -2
- package/dist/chunks/policy.js +1 -2
- package/dist/chunks/preferences.js +1 -2
- package/dist/chunks/profile.js +2 -3
- package/dist/chunks/prompts.js +1 -2
- package/dist/chunks/public.js +1 -2
- package/dist/chunks/public2.js +3 -4
- package/dist/chunks/references.js +3 -3
- package/dist/chunks/referrals.js +1 -2
- package/dist/chunks/rolldown-runtime.js +2 -3
- package/dist/chunks/rooms-connect.js +1 -2
- package/dist/chunks/rooms-connect2.js +1 -2
- package/dist/chunks/rooms-rtc.js +4 -6
- package/dist/chunks/rooms.js +2 -3
- package/dist/chunks/run.js +2 -3
- package/dist/chunks/runtime.js +6 -12
- package/dist/chunks/runtime2.js +2 -3
- package/dist/chunks/runtimes.js +1 -2
- package/dist/chunks/safe-remote-image.js +1 -2
- package/dist/chunks/schemas.js +58 -43
- package/dist/chunks/search.js +3 -3
- package/dist/chunks/self-update.js +4 -5
- package/dist/chunks/serve.js +11 -25
- package/dist/chunks/session-status.js +1 -2
- package/dist/chunks/skills.js +1 -2
- package/dist/chunks/spaces.js +26 -45
- package/dist/chunks/src.js +5 -9
- package/dist/chunks/supervisor.js +16 -28
- package/dist/chunks/supervisor2.js +1 -2
- package/dist/chunks/tasks.js +1 -2
- package/dist/chunks/user-lists.js +1 -2
- package/dist/chunks/version.js +1 -2
- package/dist/chunks/version2.js +1 -2
- package/dist/chunks/version3.js +3 -4
- package/dist/chunks/web.js +1 -2
- package/dist/runtime/native/pi-extension.js +1 -2
- package/dist/runtime/worker.js +2 -3
- package/package.json +11 -10
package/dist/chunks/id.js
CHANGED
|
@@ -1,910 +1,6 @@
|
|
|
1
|
-
import { _ as union, a as array, c as discriminatedUnion, d as literal, f as number,
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
//#endregion
|
|
75
|
-
//#region ../protocol/src/board-url.ts
|
|
76
|
-
const BOARD_REMOTE_URL_MAX_LENGTH = 4096;
|
|
77
|
-
function parseIpv4(host) {
|
|
78
|
-
const parts = host.split(".").map(Number);
|
|
79
|
-
return parts.length === 4 && parts.every((part) => Number.isInteger(part) && part >= 0 && part <= 255) ? parts : null;
|
|
80
|
-
}
|
|
81
|
-
function isBlockedIpv4(host) {
|
|
82
|
-
const parts = parseIpv4(host);
|
|
83
|
-
if (!parts) return false;
|
|
84
|
-
const [first, second, third] = parts;
|
|
85
|
-
if (first === 0 || first === 10 || first === 127) return true;
|
|
86
|
-
if (first === 100 && second >= 64 && second <= 127) return true;
|
|
87
|
-
if (first === 169 && second === 254) return true;
|
|
88
|
-
if (first === 172 && second >= 16 && second <= 31) return true;
|
|
89
|
-
if (first === 192 && second === 168) return true;
|
|
90
|
-
if (first === 192 && second === 0 && (third === 0 || third === 2)) return true;
|
|
91
|
-
if (first === 192 && second === 88 && third === 99) return true;
|
|
92
|
-
if (first === 198 && (second === 18 || second === 19)) return true;
|
|
93
|
-
if (first === 198 && second === 51 && third === 100) return true;
|
|
94
|
-
if (first === 203 && second === 0 && third === 113) return true;
|
|
95
|
-
return first >= 224;
|
|
96
|
-
}
|
|
97
|
-
function expandIpv6(host) {
|
|
98
|
-
const [head, tail, extra] = host.toLowerCase().split("::");
|
|
99
|
-
if (extra !== void 0) return null;
|
|
100
|
-
const headParts = head ? head.split(":").filter(Boolean) : [];
|
|
101
|
-
const tailParts = tail ? tail.split(":").filter(Boolean) : [];
|
|
102
|
-
const missing = 8 - headParts.length - tailParts.length;
|
|
103
|
-
if (missing < 0 || tail === void 0 && missing !== 0) return null;
|
|
104
|
-
const parts = [
|
|
105
|
-
...headParts,
|
|
106
|
-
...Array.from({ length: missing }, () => "0"),
|
|
107
|
-
...tailParts
|
|
108
|
-
];
|
|
109
|
-
if (parts.length !== 8 || parts.some((part) => !/^[0-9a-f]{1,4}$/.test(part))) return null;
|
|
110
|
-
return parts.map((part) => part.padStart(4, "0"));
|
|
111
|
-
}
|
|
112
|
-
function isBlockedIpv6(host) {
|
|
113
|
-
const parts = expandIpv6(host);
|
|
114
|
-
if (!parts) return true;
|
|
115
|
-
if (parts.every((part) => part === "0000")) return true;
|
|
116
|
-
if (parts.slice(0, 7).every((part) => part === "0000") && parts[7] === "0001") return true;
|
|
117
|
-
if (parts.slice(0, 5).every((part) => part === "0000") && parts[5] === "ffff") {
|
|
118
|
-
const high = Number.parseInt(parts[6] ?? "0", 16);
|
|
119
|
-
const low = Number.parseInt(parts[7] ?? "0", 16);
|
|
120
|
-
return isBlockedIpv4(`${high >> 8}.${high & 255}.${low >> 8}.${low & 255}`);
|
|
121
|
-
}
|
|
122
|
-
if (parts.slice(0, 6).every((part) => part === "0000")) return true;
|
|
123
|
-
const first = Number.parseInt(parts[0] ?? "0", 16);
|
|
124
|
-
if ((first & 65024) === 64512) return true;
|
|
125
|
-
if ((first & 65472) === 65152 || (first & 65472) === 65216) return true;
|
|
126
|
-
if ((first & 65280) === 65280) return true;
|
|
127
|
-
return parts[0] === "2001" && parts[1] === "0db8";
|
|
128
|
-
}
|
|
129
|
-
function isPublicBoardRemoteAddress(value) {
|
|
130
|
-
const address = value.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.$/, "");
|
|
131
|
-
if (parseIpv4(address)) return !isBlockedIpv4(address);
|
|
132
|
-
return address.includes(":") && !isBlockedIpv6(address);
|
|
133
|
-
}
|
|
134
|
-
function isBlockedHost(hostname) {
|
|
135
|
-
const host = hostname.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.$/, "");
|
|
136
|
-
if (host === "localhost" || host.endsWith(".localhost") || host.endsWith(".local") || host.endsWith(".internal")) return true;
|
|
137
|
-
if (parseIpv4(host) || host.includes(":")) return !isPublicBoardRemoteAddress(host);
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Normalize a browser-loadable public HTTP(S) URL. This blocks explicit local
|
|
142
|
-
* addresses; any future server-side fetcher must additionally validate DNS
|
|
143
|
-
* resolution to defend against rebinding.
|
|
144
|
-
*/
|
|
145
|
-
function normalizeBoardRemoteUrl(value) {
|
|
146
|
-
if (typeof value !== "string") return void 0;
|
|
147
|
-
const input = value.trim();
|
|
148
|
-
if (!input || input.length > 4096) return void 0;
|
|
149
|
-
try {
|
|
150
|
-
const url = new URL(input);
|
|
151
|
-
if (url.protocol !== "https:" && url.protocol !== "http:") return void 0;
|
|
152
|
-
if (url.username || url.password || isBlockedHost(url.hostname)) return;
|
|
153
|
-
const normalized = url.toString();
|
|
154
|
-
return normalized.length <= 4096 ? normalized : void 0;
|
|
155
|
-
} catch {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
string().max(BOARD_REMOTE_URL_MAX_LENGTH).refine((value) => normalizeBoardRemoteUrl(value) !== void 0, { message: "URL must be a public HTTP(S) URL without credentials" });
|
|
160
|
-
const BOARD_CAMERA_TARGET = "camera";
|
|
161
|
-
const BoardKeySchema = string().min(1).max(160).regex(/^[^\s/]+$/, "ids must not contain whitespace or '/'");
|
|
162
|
-
const BoardIdSchema = BoardKeySchema.refine((value) => value !== BOARD_CAMERA_TARGET, "\"camera\" is reserved");
|
|
163
|
-
const finite = number().finite();
|
|
164
|
-
const nonNegative = finite.nonnegative();
|
|
165
|
-
const ratio = finite.min(0).max(1);
|
|
166
|
-
const BoardVec2Schema = object({
|
|
167
|
-
x: finite,
|
|
168
|
-
y: finite
|
|
169
|
-
}).strict();
|
|
170
|
-
const BoardSizeSchema = object({
|
|
171
|
-
width: finite.positive(),
|
|
172
|
-
height: finite.positive()
|
|
173
|
-
}).strict();
|
|
174
|
-
const BOARD_COLOR_TOKENS = [
|
|
175
|
-
"brand",
|
|
176
|
-
"neutral",
|
|
177
|
-
"black",
|
|
178
|
-
"white",
|
|
179
|
-
"blue",
|
|
180
|
-
"green",
|
|
181
|
-
"amber",
|
|
182
|
-
"violet",
|
|
183
|
-
"rose"
|
|
184
|
-
];
|
|
185
|
-
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(" "));
|
|
186
|
-
function isBoardColorString(value) {
|
|
187
|
-
const color = value.trim().toLowerCase();
|
|
188
|
-
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);
|
|
189
|
-
}
|
|
190
|
-
const colorString = string().max(120).refine(isBoardColorString, "expected a palette token or a CSS color");
|
|
191
|
-
const BoardColorSchema = union([colorString, object({
|
|
192
|
-
light: colorString,
|
|
193
|
-
dark: colorString
|
|
194
|
-
}).strict()]).describe("Palette token (follows the theme), CSS color, or { light, dark }.");
|
|
195
|
-
const BOARD_DASHES = [
|
|
196
|
-
"solid",
|
|
197
|
-
"dashed",
|
|
198
|
-
"dotted"
|
|
199
|
-
];
|
|
200
|
-
const BOARD_BLEND_MODES = [
|
|
201
|
-
"normal",
|
|
202
|
-
"multiply",
|
|
203
|
-
"screen",
|
|
204
|
-
"add"
|
|
205
|
-
];
|
|
206
|
-
const BoardFilterSchema = object({
|
|
207
|
-
blur: finite.min(0).max(256).optional().describe("Blur radius in board units, as CSS blur()."),
|
|
208
|
-
brightness: finite.min(0).max(10).optional().describe("1 keeps the color, 0 is black."),
|
|
209
|
-
contrast: finite.min(0).max(10).optional().describe("1 keeps the color, 0 is flat gray."),
|
|
210
|
-
saturate: finite.min(0).max(10).optional().describe("1 keeps the color, 0 is gray, above 1 is vivid."),
|
|
211
|
-
hue: finite.min(-3600).max(3600).optional().describe("Hue rotation in degrees."),
|
|
212
|
-
grayscale: ratio.optional(),
|
|
213
|
-
sepia: ratio.optional(),
|
|
214
|
-
invert: ratio.optional()
|
|
215
|
-
}).strict().describe("CSS filters, applied in this order. On a frame, filter, shadow and blend treat the frame and its contents as one layer.");
|
|
216
|
-
const BOARD_SHADOW_DEFAULTS = {
|
|
217
|
-
opacity: .35,
|
|
218
|
-
blur: 16,
|
|
219
|
-
x: 0,
|
|
220
|
-
y: 8
|
|
221
|
-
};
|
|
222
|
-
const BoardShadowSchema = object({
|
|
223
|
-
color: BoardColorSchema.optional().describe("Defaults to black."),
|
|
224
|
-
opacity: ratio.optional().describe("Defaults to 0.35."),
|
|
225
|
-
blur: finite.min(0).max(256).optional().describe("Softness in board units, as CSS drop-shadow(); defaults to 16."),
|
|
226
|
-
x: finite.min(-1024).max(1024).optional(),
|
|
227
|
-
y: finite.min(-1024).max(1024).optional().describe("Defaults to 8.")
|
|
228
|
-
}).strict().describe("A drop shadow following the item's visible shape; with no offset and a bright color it glows.");
|
|
229
|
-
const BoardStyleSchema = object({
|
|
230
|
-
fill: BoardColorSchema.optional(),
|
|
231
|
-
fillOpacity: ratio.optional().describe("Fill opacity, independent of the item's opacity."),
|
|
232
|
-
stroke: BoardColorSchema.optional(),
|
|
233
|
-
strokeWidth: finite.min(0).max(64).optional(),
|
|
234
|
-
dash: _enum(BOARD_DASHES).optional(),
|
|
235
|
-
radius: nonNegative.optional().describe("Corner radius in board units."),
|
|
236
|
-
trim: ratio.optional().describe("Fraction of the outline drawn; animate 0 → 1 to draw it in."),
|
|
237
|
-
filter: BoardFilterSchema.optional(),
|
|
238
|
-
shadow: BoardShadowSchema.optional(),
|
|
239
|
-
blend: _enum(BOARD_BLEND_MODES).optional().describe("How the item mixes with what is under it.")
|
|
240
|
-
}).strict();
|
|
241
|
-
function isSafeBoardSourcePath(value) {
|
|
242
|
-
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 !== "..");
|
|
243
|
-
}
|
|
244
|
-
const srcSchema = string().refine(isSafeBoardSourcePath, "src must be a relative Space file path");
|
|
245
|
-
function parseBoardMediaSource(src) {
|
|
246
|
-
if (isSafeBoardSourcePath(src)) return {
|
|
247
|
-
kind: "file",
|
|
248
|
-
value: src
|
|
249
|
-
};
|
|
250
|
-
return normalizeBoardRemoteUrl(src) ? {
|
|
251
|
-
kind: "url",
|
|
252
|
-
value: src
|
|
253
|
-
} : null;
|
|
254
|
-
}
|
|
255
|
-
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.");
|
|
256
|
-
const BoardScriptSchema = object({
|
|
257
|
-
src: srcSchema.refine((path) => /\.m?js$/.test(path), "script src must be a .js or .mjs module").describe("A .js or .mjs Space file."),
|
|
258
|
-
params: record(string(), json()).default({}).describe("Values the module reads as params."),
|
|
259
|
-
targets: record(string().min(1).max(80), BoardIdSchema).default({}).describe("Named items the module can reach, as ctx.targets."),
|
|
260
|
-
seed: string().min(1).max(160).optional().describe("Seed for ctx.random() and shaders; defaults to the owner's id."),
|
|
261
|
-
enabled: boolean().default(true)
|
|
262
|
-
}).strict().describe("A JavaScript module attached to an item or the Board; `cohub boards schema script` lists its API.");
|
|
263
|
-
const itemEnvelope = {
|
|
264
|
-
script: BoardScriptSchema.optional(),
|
|
265
|
-
parent: BoardIdSchema.optional().describe("A frame id; position becomes relative to the frame, and the item moves with it."),
|
|
266
|
-
z: finite.optional().describe("Order among siblings; new items go on top."),
|
|
267
|
-
position: BoardVec2Schema.default({
|
|
268
|
-
x: 0,
|
|
269
|
-
y: 0
|
|
270
|
-
}),
|
|
271
|
-
rotation: finite.default(0),
|
|
272
|
-
scale: union([finite, BoardVec2Schema]).default(1),
|
|
273
|
-
origin: BoardVec2Schema.default({
|
|
274
|
-
x: .5,
|
|
275
|
-
y: .5
|
|
276
|
-
}).describe("Rotation and scale origin as fractions of the size."),
|
|
277
|
-
opacity: ratio.default(1),
|
|
278
|
-
visible: boolean().optional().describe("false hides the item and its children; key it on a timeline to show the item only for a span."),
|
|
279
|
-
style: BoardStyleSchema.default({}),
|
|
280
|
-
locked: boolean().optional(),
|
|
281
|
-
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."),
|
|
282
|
-
metadata: record(string(), unknown()).optional()
|
|
283
|
-
};
|
|
284
|
-
const boxed = (size) => ({
|
|
285
|
-
...itemEnvelope,
|
|
286
|
-
size: BoardSizeSchema.default({ ...size })
|
|
287
|
-
});
|
|
288
|
-
const unsized = { ...itemEnvelope };
|
|
289
|
-
const fontSize = finite.min(2).max(512);
|
|
290
|
-
const BOARD_TEXT_ALIGNS = [
|
|
291
|
-
"left",
|
|
292
|
-
"center",
|
|
293
|
-
"right"
|
|
294
|
-
];
|
|
295
|
-
const BOARD_TEXT_REVEAL_UNITS = [
|
|
296
|
-
"char",
|
|
297
|
-
"word",
|
|
298
|
-
"line"
|
|
299
|
-
];
|
|
300
|
-
const BOARD_TEXT_REVEAL_MOTIONS = [
|
|
301
|
-
"cut",
|
|
302
|
-
"fade",
|
|
303
|
-
"rise"
|
|
304
|
-
];
|
|
305
|
-
const BOARD_SHAPE_GEOMETRIES = [
|
|
306
|
-
"rectangle",
|
|
307
|
-
"rounded",
|
|
308
|
-
"ellipse",
|
|
309
|
-
"diamond",
|
|
310
|
-
"triangle",
|
|
311
|
-
"path"
|
|
312
|
-
];
|
|
313
|
-
const BoardFrameItemSchema = object({
|
|
314
|
-
...boxed(BOARD_DEFAULT_SIZES.frame),
|
|
315
|
-
type: literal("frame"),
|
|
316
|
-
props: object({
|
|
317
|
-
label: string().max(280).default(""),
|
|
318
|
-
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."),
|
|
319
|
-
clip: boolean().default(true).describe("Hide children outside the frame.")
|
|
320
|
-
}).strict().prefault({})
|
|
321
|
-
}).strict();
|
|
322
|
-
const BoardTextItemSchema = object({
|
|
323
|
-
...unsized,
|
|
324
|
-
type: literal("text"),
|
|
325
|
-
props: object({
|
|
326
|
-
text: string().default(""),
|
|
327
|
-
fontSize: fontSize.default(24),
|
|
328
|
-
fontWeight: finite.min(100).max(900).default(500),
|
|
329
|
-
font: string().min(1).max(120).default("sans").describe("sans, serif, mono, or a font family name."),
|
|
330
|
-
align: _enum(BOARD_TEXT_ALIGNS).default("left"),
|
|
331
|
-
lineHeight: finite.min(.5).max(4).default(4 / 3),
|
|
332
|
-
width: finite.positive().optional().describe("Wrap width; the height follows the text."),
|
|
333
|
-
reveal: ratio.default(1).describe("Fraction of the text shown; animate 0 → 1 to type it."),
|
|
334
|
-
revealBy: _enum(BOARD_TEXT_REVEAL_UNITS).optional().describe("What reveal counts: char (default), word or line."),
|
|
335
|
-
revealMotion: _enum(BOARD_TEXT_REVEAL_MOTIONS).optional().describe("How each unit appears: cut (default), fade or rise."),
|
|
336
|
-
caret: boolean().default(false).describe("Blink a caret while the text is being revealed.")
|
|
337
|
-
}).strict().prefault({})
|
|
338
|
-
}).strict();
|
|
339
|
-
const BoardShapeItemSchema = object({
|
|
340
|
-
...boxed(BOARD_DEFAULT_SIZES.shape),
|
|
341
|
-
type: literal("shape"),
|
|
342
|
-
props: object({
|
|
343
|
-
geometry: _enum(BOARD_SHAPE_GEOMETRIES).default("rectangle"),
|
|
344
|
-
path: string().min(1).max(2e5).optional().describe("SVG path data for path geometry, fitted to the item size."),
|
|
345
|
-
text: string().default(""),
|
|
346
|
-
fontSize: fontSize.default(20),
|
|
347
|
-
align: _enum(BOARD_TEXT_ALIGNS).default("center")
|
|
348
|
-
}).strict().refine((props) => props.geometry !== "path" || Boolean(props.path), {
|
|
349
|
-
message: "path geometry requires props.path",
|
|
350
|
-
path: ["path"]
|
|
351
|
-
}).prefault({})
|
|
352
|
-
}).strict();
|
|
353
|
-
const BoardDrawPointSchema = object({
|
|
354
|
-
x: finite,
|
|
355
|
-
y: finite,
|
|
356
|
-
p: ratio.default(.5).describe("Pen pressure.")
|
|
357
|
-
}).strict();
|
|
358
|
-
const BoardDrawItemSchema = object({
|
|
359
|
-
...unsized,
|
|
360
|
-
type: literal("draw"),
|
|
361
|
-
props: object({ points: array(BoardDrawPointSchema).min(1).max(1e5).describe("Stroke points relative to position; the size follows them.") }).strict()
|
|
362
|
-
}).strict();
|
|
363
|
-
const BoardArrowAnchorSchema = union([
|
|
364
|
-
literal("auto"),
|
|
365
|
-
object({
|
|
366
|
-
side: _enum([
|
|
367
|
-
"top",
|
|
368
|
-
"right",
|
|
369
|
-
"bottom",
|
|
370
|
-
"left"
|
|
371
|
-
]),
|
|
372
|
-
offset: ratio.default(.5)
|
|
373
|
-
}).strict(),
|
|
374
|
-
object({
|
|
375
|
-
x: ratio,
|
|
376
|
-
y: ratio
|
|
377
|
-
}).strict()
|
|
378
|
-
]);
|
|
379
|
-
const BoardArrowBindingSchema = object({
|
|
380
|
-
item: BoardIdSchema,
|
|
381
|
-
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."),
|
|
382
|
-
port: string().min(1).max(120).optional()
|
|
383
|
-
}).strict();
|
|
384
|
-
const BoardArrowEndSchema = union([BoardVec2Schema, BoardArrowBindingSchema]).describe("A point relative to position, or { item } to follow that item.");
|
|
385
|
-
const BOARD_ARROW_ROUTES = [
|
|
386
|
-
"straight",
|
|
387
|
-
"curve",
|
|
388
|
-
"orthogonal"
|
|
389
|
-
];
|
|
390
|
-
const BoardArrowItemSchema = object({
|
|
391
|
-
...unsized,
|
|
392
|
-
type: literal("arrow"),
|
|
393
|
-
props: object({
|
|
394
|
-
start: BoardArrowEndSchema,
|
|
395
|
-
end: BoardArrowEndSchema,
|
|
396
|
-
route: _enum(BOARD_ARROW_ROUTES).default("straight"),
|
|
397
|
-
bend: finite.min(-.85).max(.85).default(0).describe("Sideways curve as a fraction of the length; the sign picks the side."),
|
|
398
|
-
waypoints: array(BoardVec2Schema).max(64).default([]).describe("Points the route passes through."),
|
|
399
|
-
arrowStart: boolean().default(false),
|
|
400
|
-
arrowEnd: boolean().default(true),
|
|
401
|
-
label: string().max(280).default(""),
|
|
402
|
-
fontSize: fontSize.default(14),
|
|
403
|
-
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.")
|
|
404
|
-
}).strict()
|
|
405
|
-
}).strict();
|
|
406
|
-
const fileProps = {
|
|
407
|
-
src: BoardMediaSourceSchema,
|
|
408
|
-
snapshot: object({
|
|
409
|
-
title: string().optional(),
|
|
410
|
-
mimeType: string().optional(),
|
|
411
|
-
size: nonNegative.optional(),
|
|
412
|
-
mtimeMs: nonNegative.optional(),
|
|
413
|
-
naturalWidth: finite.positive().optional(),
|
|
414
|
-
naturalHeight: finite.positive().optional(),
|
|
415
|
-
durationMs: nonNegative.optional(),
|
|
416
|
-
excerpt: string().optional(),
|
|
417
|
-
coverPath: string().optional(),
|
|
418
|
-
coverUrl: string().optional()
|
|
419
|
-
}).strict().describe("Cached facts for an instant preview; filled in when the media loads.").optional()
|
|
420
|
-
};
|
|
421
|
-
const BoardModelViewSchema = object({
|
|
422
|
-
yaw: finite.describe("Degrees around the model; 0 faces its front, 90 its right side."),
|
|
423
|
-
pitch: finite.min(-90).max(90).describe("Degrees above the model; 90 looks straight down."),
|
|
424
|
-
zoom: finite.positive().max(100).describe("1 fits the whole model; 2 is twice as close."),
|
|
425
|
-
target: tuple([
|
|
426
|
-
finite,
|
|
427
|
-
finite,
|
|
428
|
-
finite
|
|
429
|
-
]).optional().describe("Pivot offset from the model's centre, in model radii.")
|
|
430
|
-
}).strict();
|
|
431
|
-
const BoardModelSettingsSchema = object({
|
|
432
|
-
view: BoardModelViewSchema.optional().describe("Camera for the card's still and where the model turns back to; the default three-quarter view without it."),
|
|
433
|
-
animation: string().min(1).max(240).optional().describe("Animation clip that plays; the model's first without it.")
|
|
434
|
-
}).strict().describe("How a 3D model file shows; ignored for other files.");
|
|
435
|
-
const BoardMediaOriginSchema = object({
|
|
436
|
-
taskRunId: string().min(1).max(160),
|
|
437
|
-
artifactId: string().min(1).max(240)
|
|
438
|
-
}).strict().describe("The generation run and result this media came from.");
|
|
439
|
-
const mediaProps = {
|
|
440
|
-
...fileProps,
|
|
441
|
-
origin: BoardMediaOriginSchema.optional()
|
|
442
|
-
};
|
|
443
|
-
const timedFileProps = {
|
|
444
|
-
...mediaProps,
|
|
445
|
-
time: nonNegative.optional().describe("Playback position in milliseconds; animate props.time to play it on a timeline. It sounds while its time moves forward."),
|
|
446
|
-
volume: ratio.optional().describe("Loudness from 0 to 1; defaults to 1. Animate it to fade.")
|
|
447
|
-
};
|
|
448
|
-
const BoardCropSchema = object({
|
|
449
|
-
x: ratio,
|
|
450
|
-
y: ratio,
|
|
451
|
-
w: ratio,
|
|
452
|
-
h: ratio
|
|
453
|
-
}).strict().describe("Region shown, as fractions of the image. Without it the whole image fits inside size.");
|
|
454
|
-
const BoardImageItemSchema = object({
|
|
455
|
-
...boxed(BOARD_DEFAULT_SIZES.image),
|
|
456
|
-
type: literal("image"),
|
|
457
|
-
props: object({
|
|
458
|
-
...mediaProps,
|
|
459
|
-
crop: BoardCropSchema.optional()
|
|
460
|
-
}).strict()
|
|
461
|
-
}).strict();
|
|
462
|
-
const BoardVideoItemSchema = object({
|
|
463
|
-
...boxed(BOARD_DEFAULT_SIZES.video),
|
|
464
|
-
type: literal("video"),
|
|
465
|
-
props: object(timedFileProps).strict()
|
|
466
|
-
}).strict();
|
|
467
|
-
const BoardAudioItemSchema = object({
|
|
468
|
-
...boxed(BOARD_DEFAULT_SIZES.audio),
|
|
469
|
-
type: literal("audio"),
|
|
470
|
-
props: object(timedFileProps).strict()
|
|
471
|
-
}).strict();
|
|
472
|
-
const BoardFileItemSchema = object({
|
|
473
|
-
...boxed(BOARD_DEFAULT_SIZES.file),
|
|
474
|
-
type: literal("file"),
|
|
475
|
-
props: object({
|
|
476
|
-
...fileProps,
|
|
477
|
-
model: BoardModelSettingsSchema.optional()
|
|
478
|
-
}).strict()
|
|
479
|
-
}).strict();
|
|
480
|
-
const httpsUrl = string().max(4096).url();
|
|
481
|
-
const artifactBase = {
|
|
482
|
-
id: string().min(1).max(240),
|
|
483
|
-
title: string().max(240).optional(),
|
|
484
|
-
url: httpsUrl,
|
|
485
|
-
mimeType: string().max(160).optional()
|
|
486
|
-
};
|
|
487
|
-
const BoardTaskArtifactSchema = discriminatedUnion("type", [
|
|
488
|
-
object({
|
|
489
|
-
...artifactBase,
|
|
490
|
-
type: literal("image"),
|
|
491
|
-
naturalWidth: finite.positive().optional(),
|
|
492
|
-
naturalHeight: finite.positive().optional()
|
|
493
|
-
}).strict(),
|
|
494
|
-
object({
|
|
495
|
-
...artifactBase,
|
|
496
|
-
type: literal("video"),
|
|
497
|
-
previewUrl: httpsUrl.optional(),
|
|
498
|
-
durationMs: number().int().positive().optional(),
|
|
499
|
-
naturalWidth: finite.positive().optional(),
|
|
500
|
-
naturalHeight: finite.positive().optional()
|
|
501
|
-
}).strict(),
|
|
502
|
-
object({
|
|
503
|
-
...artifactBase,
|
|
504
|
-
type: literal("audio"),
|
|
505
|
-
previewUrl: httpsUrl.optional(),
|
|
506
|
-
durationMs: number().int().positive().optional()
|
|
507
|
-
}).strict(),
|
|
508
|
-
object({
|
|
509
|
-
id: string().min(1).max(240),
|
|
510
|
-
type: literal("text"),
|
|
511
|
-
title: string().max(240).optional(),
|
|
512
|
-
textExcerpt: string().min(1).max(480)
|
|
513
|
-
}).strict()
|
|
514
|
-
]);
|
|
515
|
-
const BoardTaskSnapshotSchema = object({
|
|
516
|
-
taskType: string().min(1).max(120),
|
|
517
|
-
status: _enum([
|
|
518
|
-
"pending",
|
|
519
|
-
"running",
|
|
520
|
-
"completed",
|
|
521
|
-
"failed"
|
|
522
|
-
]),
|
|
523
|
-
title: string().min(1).max(240),
|
|
524
|
-
model: string().max(160).optional(),
|
|
525
|
-
promptExcerpt: string().max(480).optional(),
|
|
526
|
-
errorExcerpt: string().max(240).optional(),
|
|
527
|
-
artifactCount: number().int().nonnegative(),
|
|
528
|
-
artifacts: array(BoardTaskArtifactSchema).max(6).default([]),
|
|
529
|
-
startedAt: string().max(64).optional(),
|
|
530
|
-
updatedAt: string().optional()
|
|
531
|
-
}).strict();
|
|
532
|
-
const BoardTaskItemSchema = object({
|
|
533
|
-
...boxed(BOARD_DEFAULT_SIZES.task),
|
|
534
|
-
type: literal("task"),
|
|
535
|
-
props: object({
|
|
536
|
-
taskRunId: string().min(1).max(160).describe("The generation run shown; the server keeps the card's status and results up to date."),
|
|
537
|
-
snapshot: BoardTaskSnapshotSchema.describe("Maintained by the server; omit it.")
|
|
538
|
-
}).strict()
|
|
539
|
-
}).strict();
|
|
540
|
-
const BoardSessionSnapshotSchema = object({
|
|
541
|
-
title: string().max(255).default(""),
|
|
542
|
-
excerpt: string().max(480).optional().describe("The latest message as plain text."),
|
|
543
|
-
source: string().max(120).optional().describe("Where the chat runs: web, cli or a channel."),
|
|
544
|
-
issue: _enum(["failed", "lost"]).optional().describe("How the last run ended when it did not finish."),
|
|
545
|
-
errorExcerpt: string().max(240).optional(),
|
|
546
|
-
activityAt: string().max(64).optional()
|
|
547
|
-
}).strict();
|
|
548
|
-
const BoardSessionItemSchema = object({
|
|
549
|
-
...boxed(BOARD_DEFAULT_SIZES.session),
|
|
550
|
-
type: literal("session"),
|
|
551
|
-
props: object({
|
|
552
|
-
sessionId: string().min(1).max(160).describe("The chat shown; the server keeps its title, latest message and status up to date."),
|
|
553
|
-
snapshot: BoardSessionSnapshotSchema.describe("Maintained by the server; omit it.")
|
|
554
|
-
}).strict()
|
|
555
|
-
}).strict();
|
|
556
|
-
const BOARD_EFFECT_KINDS = [
|
|
557
|
-
"particles",
|
|
558
|
-
"trail",
|
|
559
|
-
"impact",
|
|
560
|
-
"flash",
|
|
561
|
-
"glow"
|
|
562
|
-
];
|
|
563
|
-
const BOARD_PARTICLE_SHAPES = [
|
|
564
|
-
"circle",
|
|
565
|
-
"square",
|
|
566
|
-
"star",
|
|
567
|
-
"heart",
|
|
568
|
-
"spark"
|
|
569
|
-
];
|
|
570
|
-
const BOARD_EFFECT_KIND_INFO = {
|
|
571
|
-
particles: {
|
|
572
|
-
description: "Continuous particles emitted inside the effect frame.",
|
|
573
|
-
parameters: {
|
|
574
|
-
rate: "Particles per second.",
|
|
575
|
-
life: "Particle lifetime in milliseconds.",
|
|
576
|
-
particleSize: "Particle size in board units.",
|
|
577
|
-
speed: "Particle speed in board units per second.",
|
|
578
|
-
direction: "Emission direction in degrees.",
|
|
579
|
-
spread: "Emission spread in degrees.",
|
|
580
|
-
gravity: "Acceleration in board units per second squared.",
|
|
581
|
-
intensity: "Opacity and size multiplier.",
|
|
582
|
-
seed: "Stable seed for repeatable particle motion.",
|
|
583
|
-
shape: "circle, square, star, heart or spark.",
|
|
584
|
-
colors: "Up to eight colors the particles pick from."
|
|
585
|
-
}
|
|
586
|
-
},
|
|
587
|
-
trail: {
|
|
588
|
-
description: "A fading trail following another item.",
|
|
589
|
-
parameters: {
|
|
590
|
-
follow: "ID of the item to follow.",
|
|
591
|
-
life: "Trail lifetime in milliseconds.",
|
|
592
|
-
particleSize: "Trail width in board units.",
|
|
593
|
-
intensity: "Opacity multiplier."
|
|
594
|
-
}
|
|
595
|
-
},
|
|
596
|
-
impact: {
|
|
597
|
-
description: "A repeating radial burst centered in the effect frame.",
|
|
598
|
-
parameters: {
|
|
599
|
-
rate: "Particles per burst.",
|
|
600
|
-
life: "Time between bursts in milliseconds.",
|
|
601
|
-
particleSize: "Particle and ring size in board units.",
|
|
602
|
-
speed: "Particle speed in board units per second.",
|
|
603
|
-
direction: "Burst direction in degrees.",
|
|
604
|
-
spread: "Burst spread in degrees.",
|
|
605
|
-
gravity: "Acceleration in board units per second squared.",
|
|
606
|
-
intensity: "Opacity multiplier.",
|
|
607
|
-
seed: "Stable seed for repeatable bursts.",
|
|
608
|
-
shape: "circle, square, star, heart or spark.",
|
|
609
|
-
colors: "Up to eight colors the particles pick from."
|
|
610
|
-
}
|
|
611
|
-
},
|
|
612
|
-
flash: {
|
|
613
|
-
description: "A repeating full-frame flash.",
|
|
614
|
-
parameters: {
|
|
615
|
-
life: "Time between flashes in milliseconds.",
|
|
616
|
-
intensity: "Flash opacity multiplier."
|
|
617
|
-
}
|
|
618
|
-
},
|
|
619
|
-
glow: {
|
|
620
|
-
description: "A pulsing set of concentric rings.",
|
|
621
|
-
parameters: {
|
|
622
|
-
life: "Pulse period in milliseconds.",
|
|
623
|
-
intensity: "Glow opacity multiplier."
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
};
|
|
627
|
-
const BoardEffectItemSchema = object({
|
|
628
|
-
...boxed(BOARD_DEFAULT_SIZES.effect),
|
|
629
|
-
type: literal("effect"),
|
|
630
|
-
props: object({
|
|
631
|
-
kind: _enum(BOARD_EFFECT_KINDS),
|
|
632
|
-
rate: nonNegative.max(2e4).default(40),
|
|
633
|
-
life: finite.positive().max(6e4).default(1200),
|
|
634
|
-
particleSize: finite.positive().max(512).default(6),
|
|
635
|
-
speed: nonNegative.max(1e4).default(120),
|
|
636
|
-
direction: finite.default(-90),
|
|
637
|
-
spread: finite.min(0).max(360).default(360),
|
|
638
|
-
gravity: finite.default(0),
|
|
639
|
-
intensity: nonNegative.max(10).default(1),
|
|
640
|
-
follow: BoardIdSchema.optional().describe("trail: the item to follow."),
|
|
641
|
-
seed: string().min(1).max(160).optional().describe("Makes procedural motion repeatable."),
|
|
642
|
-
shape: _enum(BOARD_PARTICLE_SHAPES).optional().describe("particles and impact: circle by default; square and star tumble, spark streaks along its motion."),
|
|
643
|
-
colors: array(BoardColorSchema).min(1).max(8).optional().describe("particles and impact: each particle picks one; defaults to style.fill.")
|
|
644
|
-
}).strict()
|
|
645
|
-
}).strict();
|
|
646
|
-
const BoardCustomItemSchema = object({
|
|
647
|
-
...boxed(BOARD_DEFAULT_SIZES.custom),
|
|
648
|
-
type: literal("custom"),
|
|
649
|
-
script: BoardScriptSchema,
|
|
650
|
-
props: object({}).strict().default({})
|
|
651
|
-
}).strict();
|
|
652
|
-
const BOARD_EXTENSION_TYPE_PATTERN = /^[a-z][a-z0-9]*(?:\.[a-z0-9-]+)+$/;
|
|
653
|
-
const BoardItemPreviewSchema = object({
|
|
654
|
-
title: string().max(500).optional(),
|
|
655
|
-
excerpt: string().max(2e3).optional(),
|
|
656
|
-
cover: BoardMediaSourceSchema.optional().describe("An image for the card."),
|
|
657
|
-
src: BoardMediaSourceSchema.optional().describe("The file or page the card stands for.")
|
|
658
|
-
}).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.");
|
|
659
|
-
const BoardExtensionItemSchema = object({
|
|
660
|
-
...boxed(BOARD_DEFAULT_ITEM_SIZE),
|
|
661
|
-
type: string().regex(BOARD_EXTENSION_TYPE_PATTERN),
|
|
662
|
-
props: record(string(), unknown()).default({}),
|
|
663
|
-
preview: BoardItemPreviewSchema.optional()
|
|
664
|
-
}).strict();
|
|
665
|
-
const BOARD_ITEM_SCHEMAS = {
|
|
666
|
-
frame: BoardFrameItemSchema,
|
|
667
|
-
text: BoardTextItemSchema,
|
|
668
|
-
shape: BoardShapeItemSchema,
|
|
669
|
-
draw: BoardDrawItemSchema,
|
|
670
|
-
arrow: BoardArrowItemSchema,
|
|
671
|
-
image: BoardImageItemSchema,
|
|
672
|
-
video: BoardVideoItemSchema,
|
|
673
|
-
audio: BoardAudioItemSchema,
|
|
674
|
-
file: BoardFileItemSchema,
|
|
675
|
-
task: BoardTaskItemSchema,
|
|
676
|
-
session: BoardSessionItemSchema,
|
|
677
|
-
effect: BoardEffectItemSchema,
|
|
678
|
-
custom: BoardCustomItemSchema
|
|
679
|
-
};
|
|
680
|
-
const BOARD_ITEM_TYPES = Object.keys(BOARD_ITEM_SCHEMAS);
|
|
681
|
-
function isBuiltinItemType(type) {
|
|
682
|
-
return Object.hasOwn(BOARD_ITEM_SCHEMAS, type);
|
|
683
|
-
}
|
|
684
|
-
function isBuiltinItem(item) {
|
|
685
|
-
return isBuiltinItemType(item.type);
|
|
686
|
-
}
|
|
687
|
-
function boardItemPreview(item) {
|
|
688
|
-
return isBuiltinItem(item) ? null : item.preview ?? null;
|
|
689
|
-
}
|
|
690
|
-
const BOARD_DERIVED_SIZE_TYPES = [
|
|
691
|
-
"text",
|
|
692
|
-
"draw",
|
|
693
|
-
"arrow"
|
|
694
|
-
];
|
|
695
|
-
function hasAuthoredSize(type) {
|
|
696
|
-
return !BOARD_DERIVED_SIZE_TYPES.includes(type);
|
|
697
|
-
}
|
|
698
|
-
function boardItemSchema(type) {
|
|
699
|
-
if (isBuiltinItemType(type)) return BOARD_ITEM_SCHEMAS[type];
|
|
700
|
-
return BOARD_EXTENSION_TYPE_PATTERN.test(type) ? BoardExtensionItemSchema : null;
|
|
701
|
-
}
|
|
702
|
-
function issuesToDiagnostics(error, path) {
|
|
703
|
-
return error.issues.map((issue) => {
|
|
704
|
-
return {
|
|
705
|
-
severity: "error",
|
|
706
|
-
code: "INVALID_ITEM",
|
|
707
|
-
path: [path, ...issue.path.map(String)].filter(Boolean).join("."),
|
|
708
|
-
message: issue.code === "unrecognized_keys" ? `unknown ${issue.keys.length === 1 ? "property" : "properties"} ${issue.keys.join(", ")}` : issue.message
|
|
709
|
-
};
|
|
710
|
-
});
|
|
711
|
-
}
|
|
712
|
-
const keepAllBoardFields = () => true;
|
|
713
|
-
function keepBoardFieldsOf(value) {
|
|
714
|
-
return (path, key) => Object.hasOwn(fieldAt(value, path) ?? {}, key);
|
|
715
|
-
}
|
|
716
|
-
function fieldAt(value, path) {
|
|
717
|
-
let cursor = value;
|
|
718
|
-
for (const segment of path) cursor = cursor && typeof cursor === "object" ? cursor[segment] : void 0;
|
|
719
|
-
return cursor && typeof cursor === "object" ? cursor : null;
|
|
720
|
-
}
|
|
721
|
-
function withoutFields(value, path, keys) {
|
|
722
|
-
if (!value || typeof value !== "object") return value;
|
|
723
|
-
const copy = Array.isArray(value) ? [...value] : { ...value };
|
|
724
|
-
if (path.length === 0) for (const key of keys) delete copy[key];
|
|
725
|
-
else copy[path[0]] = withoutFields(copy[path[0]], path.slice(1), keys);
|
|
726
|
-
return copy;
|
|
727
|
-
}
|
|
728
|
-
function parseKeepingBoardFields(schema, value, keep) {
|
|
729
|
-
const kept = [];
|
|
730
|
-
let candidate = value;
|
|
731
|
-
for (;;) {
|
|
732
|
-
const result = schema.safeParse(candidate);
|
|
733
|
-
if (result.success) {
|
|
734
|
-
for (const field of kept) {
|
|
735
|
-
const target = fieldAt(result.data, field.path);
|
|
736
|
-
if (target) target[field.key] = field.value;
|
|
737
|
-
}
|
|
738
|
-
return result;
|
|
739
|
-
}
|
|
740
|
-
if (!keep) return result;
|
|
741
|
-
let stripped = false;
|
|
742
|
-
for (const issue of result.error.issues) {
|
|
743
|
-
if (issue.code !== "unrecognized_keys") continue;
|
|
744
|
-
const keys = issue.keys.filter((key) => key !== "__proto__" && keep(issue.path, key));
|
|
745
|
-
if (!keys.length) continue;
|
|
746
|
-
const source = fieldAt(candidate, issue.path);
|
|
747
|
-
for (const key of keys) kept.push({
|
|
748
|
-
path: issue.path,
|
|
749
|
-
key,
|
|
750
|
-
value: source?.[key]
|
|
751
|
-
});
|
|
752
|
-
candidate = withoutFields(candidate, issue.path, keys);
|
|
753
|
-
stripped = true;
|
|
754
|
-
}
|
|
755
|
-
if (!stripped) return result;
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
function parseBoardItem(value, path = "item", keep) {
|
|
759
|
-
const type = value && typeof value === "object" && !Array.isArray(value) ? value.type : void 0;
|
|
760
|
-
if (typeof type !== "string") return {
|
|
761
|
-
ok: false,
|
|
762
|
-
diagnostics: [{
|
|
763
|
-
severity: "error",
|
|
764
|
-
code: "INVALID_ITEM",
|
|
765
|
-
path: `${path}.type`,
|
|
766
|
-
message: "type is required"
|
|
767
|
-
}]
|
|
768
|
-
};
|
|
769
|
-
const schema = boardItemSchema(type);
|
|
770
|
-
if (!schema) return {
|
|
771
|
-
ok: false,
|
|
772
|
-
diagnostics: [{
|
|
773
|
-
severity: "error",
|
|
774
|
-
code: "INVALID_ITEM",
|
|
775
|
-
path: `${path}.type`,
|
|
776
|
-
message: `unknown type ${type}; expected ${BOARD_ITEM_TYPES.join(", ")} or a namespaced extension type`
|
|
777
|
-
}]
|
|
778
|
-
};
|
|
779
|
-
const parsed = parseKeepingBoardFields(schema, value, keep);
|
|
780
|
-
return parsed.success ? {
|
|
781
|
-
ok: true,
|
|
782
|
-
item: parsed.data
|
|
783
|
-
} : {
|
|
784
|
-
ok: false,
|
|
785
|
-
diagnostics: issuesToDiagnostics(parsed.error, path)
|
|
786
|
-
};
|
|
787
|
-
}
|
|
788
|
-
const CSS_EASE_KEYWORDS = /* @__PURE__ */ new Set([
|
|
789
|
-
"linear",
|
|
790
|
-
"ease",
|
|
791
|
-
"ease-in",
|
|
792
|
-
"ease-out",
|
|
793
|
-
"ease-in-out",
|
|
794
|
-
"step-start",
|
|
795
|
-
"step-end"
|
|
796
|
-
]);
|
|
797
|
-
function isBoardEase(value) {
|
|
798
|
-
const ease = value.trim();
|
|
799
|
-
if (CSS_EASE_KEYWORDS.has(ease)) return true;
|
|
800
|
-
const bezier = /^cubic-bezier\(\s*([^,()]+),\s*([^,()]+),\s*([^,()]+),\s*([^,()]+)\)$/.exec(ease);
|
|
801
|
-
if (bezier) {
|
|
802
|
-
const [x1, , x2] = bezier.slice(1).map(Number);
|
|
803
|
-
return bezier.slice(1).every((part) => Number.isFinite(Number(part))) && x1 >= 0 && x1 <= 1 && x2 >= 0 && x2 <= 1;
|
|
804
|
-
}
|
|
805
|
-
return /^steps\(\s*[1-9]\d*\s*(?:,\s*(?:start|end|jump-start|jump-end|jump-none|jump-both)\s*)?\)$/.test(ease);
|
|
806
|
-
}
|
|
807
|
-
const BoardEaseSchema = string().max(120).refine(isBoardEase, "expected a CSS easing: linear, ease-in-out, cubic-bezier(…) or steps(…)");
|
|
808
|
-
const BoardKeyframeSchema = object({
|
|
809
|
-
at: nonNegative.describe("Time in milliseconds."),
|
|
810
|
-
value: unknown(),
|
|
811
|
-
ease: BoardEaseSchema.optional().describe("Easing into this keyframe: a CSS keyword, cubic-bezier() or steps(); defaults to linear.")
|
|
812
|
-
}).strict();
|
|
813
|
-
const BoardTrackSchema = object({
|
|
814
|
-
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)."),
|
|
815
|
-
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."),
|
|
816
|
-
keyframes: array(BoardKeyframeSchema).min(1).max(1e5).describe("Ordered by at. The value holds before the first and after the last keyframe."),
|
|
817
|
-
composite: _enum(["replace", "add"]).default("replace").describe("replace: the latest-started track wins. add: positions and rotations add; scale and opacity multiply."),
|
|
818
|
-
interpolation: _enum([
|
|
819
|
-
"auto",
|
|
820
|
-
"step",
|
|
821
|
-
"spline"
|
|
822
|
-
]).default("auto").describe("auto blends numbers, vectors and colors and steps other values; spline smooths position paths."),
|
|
823
|
-
orient: boolean().optional().describe("Rotate the item along its path.")
|
|
824
|
-
}).strict().superRefine((track, context) => {
|
|
825
|
-
for (let index = 1; index < track.keyframes.length; index += 1) if ((track.keyframes[index]?.at ?? 0) < (track.keyframes[index - 1]?.at ?? 0)) context.addIssue({
|
|
826
|
-
code: "custom",
|
|
827
|
-
message: "keyframes must be ordered by at",
|
|
828
|
-
path: [
|
|
829
|
-
"keyframes",
|
|
830
|
-
index,
|
|
831
|
-
"at"
|
|
832
|
-
]
|
|
833
|
-
});
|
|
834
|
-
});
|
|
835
|
-
const BoardMarkerSchema = object({
|
|
836
|
-
at: nonNegative,
|
|
837
|
-
label: string().max(280).optional(),
|
|
838
|
-
pause: boolean().optional().describe("Hold shared playback here until next.")
|
|
839
|
-
}).strict();
|
|
840
|
-
const BoardAnimationHeaderSchema = object({
|
|
841
|
-
name: string().max(280).optional(),
|
|
842
|
-
duration: finite.positive().max(864e5).describe("Milliseconds; a new animation without it ends at its last keyframe."),
|
|
843
|
-
play: _enum([
|
|
844
|
-
"manual",
|
|
845
|
-
"auto",
|
|
846
|
-
"always"
|
|
847
|
-
]).default("manual").describe("manual: only shared playback starts it. auto: plays when the Board opens. always: loops continuously."),
|
|
848
|
-
delay: nonNegative.default(0),
|
|
849
|
-
loop: boolean().default(false),
|
|
850
|
-
end: _enum(["hold", "reset"]).default("hold").describe("hold keeps the last frame; reset returns to the start."),
|
|
851
|
-
markers: array(BoardMarkerSchema).max(1e4).default([]).describe("Labeled points on this timeline; a nested animation's markers do not carry over."),
|
|
852
|
-
viewport: object({
|
|
853
|
-
width: number().int().positive().max(8192),
|
|
854
|
-
height: number().int().positive().max(8192)
|
|
855
|
-
}).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.`)
|
|
856
|
-
}).strict();
|
|
857
|
-
BoardAnimationHeaderSchema.extend({ tracks: record(BoardKeySchema, BoardTrackSchema).default({}) }).strict();
|
|
858
|
-
const BOARD_ENTER_PRESETS = [
|
|
859
|
-
"fade-in",
|
|
860
|
-
"rise",
|
|
861
|
-
"drop",
|
|
862
|
-
"pop",
|
|
863
|
-
"deal"
|
|
864
|
-
];
|
|
865
|
-
const BoardBackgroundSchema = object({
|
|
866
|
-
color: BoardColorSchema.optional(),
|
|
867
|
-
pattern: _enum([
|
|
868
|
-
"none",
|
|
869
|
-
"dots",
|
|
870
|
-
"grid"
|
|
871
|
-
]).optional().describe("Spaced by grid.size; omit to follow the theme."),
|
|
872
|
-
image: object({
|
|
873
|
-
src: BoardMediaSourceSchema,
|
|
874
|
-
fit: _enum([
|
|
875
|
-
"cover",
|
|
876
|
-
"contain",
|
|
877
|
-
"repeat"
|
|
878
|
-
]).default("cover").describe("cover and contain fill the view; repeat tiles the Board at one board unit per image pixel."),
|
|
879
|
-
opacity: ratio.optional()
|
|
880
|
-
}).strict().optional()
|
|
881
|
-
}).strict().describe("Layers drawn under every item: color, then image, then pattern. Without a color or image the theme's backdrop shows.");
|
|
882
|
-
const BoardAtmosphereSchema = object({
|
|
883
|
-
vignette: ratio.optional().describe("Darkens the edges of the view."),
|
|
884
|
-
grain: ratio.optional().describe("Film grain over the view.")
|
|
885
|
-
}).strict().describe("Screen effects over every item, for viewers and exports alike.");
|
|
886
|
-
const BoardSettingsSchema = object({
|
|
887
|
-
title: string().min(1).max(255).optional(),
|
|
888
|
-
background: BoardBackgroundSchema.default({}),
|
|
889
|
-
grid: object({
|
|
890
|
-
size: finite.min(4).max(512).default(24).describe("Pattern spacing and snap step, in board units."),
|
|
891
|
-
snap: boolean().default(false).describe("Snap moved and resized items to the grid.")
|
|
892
|
-
}).strict().optional(),
|
|
893
|
-
atmosphere: BoardAtmosphereSchema.optional(),
|
|
894
|
-
enter: object({
|
|
895
|
-
preset: _enum(BOARD_ENTER_PRESETS),
|
|
896
|
-
duration: finite.positive().max(1e4).optional()
|
|
897
|
-
}).strict().optional().describe("Motion for items as they are added."),
|
|
898
|
-
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.")
|
|
899
|
-
}).strict();
|
|
900
|
-
const patchObject = record(string(), unknown());
|
|
901
|
-
const BoardPatchSchema = object({
|
|
902
|
-
board: patchObject.nullable().optional(),
|
|
903
|
-
items: record(BoardIdSchema, patchObject.nullable()).optional(),
|
|
904
|
-
animations: record(BoardIdSchema, patchObject.and(object({ tracks: record(BoardKeySchema, patchObject.nullable()).optional() })).nullable()).optional()
|
|
905
|
-
}).strict();
|
|
906
|
-
//#endregion
|
|
907
|
-
//#region ../protocol/src/board.ts
|
|
1
|
+
import { _ as union, a as array, c as discriminatedUnion, d as literal, f as number, h as string, l as json, n as _enum, p as object, s as boolean, v as unknown } from "./schemas.js";
|
|
2
|
+
import { D as keepAllBoardFields, O as keepBoardFieldsOf, S as boardItemSchema, T as isBuiltinItemType, U as boardDefaultSize, b as BoardVec2Schema, d as BoardColorSchema, g as BoardPatchSchema, j as parseKeepingBoardFields, k as parseBoardItem, m as BoardIdSchema, t as BOARD_CAMERA_TARGET, u as BoardAnimationHeaderSchema, v as BoardSettingsSchema, y as BoardTrackSchema } from "./board-model.js";
|
|
3
|
+
// ../protocol/dist/board.js
|
|
908
4
|
const BOARD_EXTENSION = ".board";
|
|
909
5
|
const BOARD_MIME_TYPE = "application/json";
|
|
910
6
|
const BOARD_MANIFEST_KIND = "cohub.board.manifest";
|
|
@@ -1010,8 +106,7 @@ discriminatedUnion("type", [
|
|
|
1010
106
|
type: literal("stop")
|
|
1011
107
|
}).strict()
|
|
1012
108
|
]);
|
|
1013
|
-
|
|
1014
|
-
//#region ../protocol/src/board-json.ts
|
|
109
|
+
// ../protocol/dist/board-json.js
|
|
1015
110
|
/** Structural equality for JSON-shaped semantic values. */
|
|
1016
111
|
function boardJsonEquals(a, b) {
|
|
1017
112
|
if (a === b) return true;
|
|
@@ -1025,8 +120,7 @@ function boardJsonEquals(a, b) {
|
|
|
1025
120
|
const keys = Object.keys(aRecord);
|
|
1026
121
|
return keys.length === Object.keys(bRecord).length && keys.every((key) => Object.hasOwn(bRecord, key) && boardJsonEquals(aRecord[key], bRecord[key]));
|
|
1027
122
|
}
|
|
1028
|
-
|
|
1029
|
-
//#region ../protocol/src/board-task.ts
|
|
123
|
+
// ../protocol/dist/board-task.js
|
|
1030
124
|
function artifactScore(artifact) {
|
|
1031
125
|
const kind = {
|
|
1032
126
|
text: 1,
|
|
@@ -1061,8 +155,7 @@ function taskArtifactPreviewUrl(artifact) {
|
|
|
1061
155
|
if (artifact?.type === "image") return artifact.url;
|
|
1062
156
|
if (artifact?.type === "video" || artifact?.type === "audio") return artifact.previewUrl;
|
|
1063
157
|
}
|
|
1064
|
-
|
|
1065
|
-
//#region ../protocol/src/board-layout.ts
|
|
158
|
+
// ../protocol/dist/board-layout.js
|
|
1066
159
|
const IDENTITY_MATRIX = [
|
|
1067
160
|
1,
|
|
1068
161
|
0,
|
|
@@ -1312,6 +405,11 @@ function arrowBindings(item) {
|
|
|
1312
405
|
const ids = [props.start, props.end].filter(isArrowBinding).map((end) => end.item);
|
|
1313
406
|
return [...new Set(ids)];
|
|
1314
407
|
}
|
|
408
|
+
function itemBindings(item) {
|
|
409
|
+
const bound = arrowBindings(item);
|
|
410
|
+
const attached = item.attach?.item;
|
|
411
|
+
return attached && !bound.includes(attached) ? [...bound, attached] : bound;
|
|
412
|
+
}
|
|
1315
413
|
function bendControl(start, end, bend) {
|
|
1316
414
|
const mid = {
|
|
1317
415
|
x: (start.x + end.x) / 2,
|
|
@@ -1338,7 +436,7 @@ function createBoardLayout(initialLookup, dependents) {
|
|
|
1338
436
|
if (cached) return cached;
|
|
1339
437
|
const item = lookup(id);
|
|
1340
438
|
if (!item) return IDENTITY_MATRIX;
|
|
1341
|
-
const matrix = multiplyMatrix(
|
|
439
|
+
const matrix = multiplyMatrix(parentOf(item, depth), localMatrixOf(id));
|
|
1342
440
|
matrices.set(id, matrix);
|
|
1343
441
|
return matrix;
|
|
1344
442
|
}
|
|
@@ -1420,7 +518,18 @@ function createBoardLayout(initialLookup, dependents) {
|
|
|
1420
518
|
return box;
|
|
1421
519
|
}
|
|
1422
520
|
function parentOf(item, depth) {
|
|
1423
|
-
|
|
521
|
+
if (depth >= MAX_DEPTH) return IDENTITY_MATRIX;
|
|
522
|
+
const attached = item.attach && lookup(item.attach.item) ? item.attach.item : null;
|
|
523
|
+
if (attached) return translate(originOf(attached, depth + 1));
|
|
524
|
+
return item.parent && lookup(item.parent) ? matrixOf(item.parent, depth + 1) : IDENTITY_MATRIX;
|
|
525
|
+
}
|
|
526
|
+
function originOf(id, depth) {
|
|
527
|
+
const item = lookup(id);
|
|
528
|
+
const box = boxOf(id, depth);
|
|
529
|
+
return applyMatrix(matrixOf(id, depth), {
|
|
530
|
+
x: box.x + item.origin.x * box.width,
|
|
531
|
+
y: box.y + item.origin.y * box.height
|
|
532
|
+
});
|
|
1424
533
|
}
|
|
1425
534
|
function resolveBoundEnd(arrow, end, other, depth) {
|
|
1426
535
|
const target = lookup(end.item);
|
|
@@ -1600,8 +709,7 @@ function anchorPoint(frame, anchor, toward) {
|
|
|
1600
709
|
}
|
|
1601
710
|
return framePoint(frame, anchor.x, anchor.y);
|
|
1602
711
|
}
|
|
1603
|
-
|
|
1604
|
-
//#region ../protocol/src/board-patch.ts
|
|
712
|
+
// ../protocol/dist/board-patch.js
|
|
1605
713
|
function slot(map, key) {
|
|
1606
714
|
let value = map[key];
|
|
1607
715
|
if (!value) {
|
|
@@ -1679,6 +787,7 @@ function schemaAtPath(schema, path) {
|
|
|
1679
787
|
const NOT_ANIMATABLE = /* @__PURE__ */ new Set([
|
|
1680
788
|
"type",
|
|
1681
789
|
"parent",
|
|
790
|
+
"attach",
|
|
1682
791
|
"z",
|
|
1683
792
|
"locked",
|
|
1684
793
|
"autoplay",
|
|
@@ -1707,6 +816,14 @@ const CAMERA_PROPERTIES = {
|
|
|
1707
816
|
shake: {
|
|
1708
817
|
kind: "number",
|
|
1709
818
|
schema: number().finite().nonnegative().describe("Shake amplitude in screen pixels, applied after focus, zoom and center.")
|
|
819
|
+
},
|
|
820
|
+
pitch: {
|
|
821
|
+
kind: "number",
|
|
822
|
+
schema: number().finite().min(0).max(60).describe(`Degrees the eye tips from straight down toward the horizon, 0 to 60, about the middle of the view, which keeps its zoom.`)
|
|
823
|
+
},
|
|
824
|
+
bearing: {
|
|
825
|
+
kind: "number",
|
|
826
|
+
schema: number().finite().describe("Degrees the view turns clockwise like a map's bearing, about the middle of the view; 90 puts the Board's +x at the top.")
|
|
1710
827
|
}
|
|
1711
828
|
};
|
|
1712
829
|
const ANIMATION_PROPERTIES = { time: {
|
|
@@ -2026,6 +1143,14 @@ function applyBoardPatch(state, input, options = {}) {
|
|
|
2026
1143
|
}
|
|
2027
1144
|
for (const arrowId of state.binders(id)) {
|
|
2028
1145
|
const arrow = item(arrowId);
|
|
1146
|
+
if (arrow?.attach?.item === id) {
|
|
1147
|
+
const { attach: _attach, ...free } = arrow;
|
|
1148
|
+
nextItems.set(arrowId, {
|
|
1149
|
+
...free,
|
|
1150
|
+
position: applyMatrix(deletionLayout.parentMatrix(arrowId), arrow.position)
|
|
1151
|
+
});
|
|
1152
|
+
continue;
|
|
1153
|
+
}
|
|
2029
1154
|
if (arrow?.type !== "arrow") continue;
|
|
2030
1155
|
const props = { ...arrow.props };
|
|
2031
1156
|
for (const which of ["start", "end"]) {
|
|
@@ -2067,15 +1192,19 @@ function applyBoardPatch(state, input, options = {}) {
|
|
|
2067
1192
|
trackIds: (id) => [.../* @__PURE__ */ new Set([...state.trackIds(id), ...nextTracks.get(id)?.keys() ?? []])]
|
|
2068
1193
|
};
|
|
2069
1194
|
const validationItems = new Map(nextItems);
|
|
1195
|
+
const carried = (id) => [...state.children(id), ...state.binders(id).filter((binder) => item(binder)?.attach?.item === id)];
|
|
2070
1196
|
const descendants = [];
|
|
2071
|
-
for (const [id, value] of nextItems)
|
|
1197
|
+
for (const [id, value] of nextItems) {
|
|
1198
|
+
const before = state.item(id);
|
|
1199
|
+
if (value && (value.parent !== before?.parent || !boardJsonEquals(value.attach, before?.attach))) descendants.push(...carried(id));
|
|
1200
|
+
}
|
|
2072
1201
|
const seenDescendants = /* @__PURE__ */ new Set();
|
|
2073
1202
|
while (descendants.length) {
|
|
2074
1203
|
const id = descendants.pop();
|
|
2075
1204
|
if (seenDescendants.has(id)) continue;
|
|
2076
1205
|
seenDescendants.add(id);
|
|
2077
1206
|
validationItems.set(id, item(id) ?? null);
|
|
2078
|
-
descendants.push(...
|
|
1207
|
+
descendants.push(...carried(id));
|
|
2079
1208
|
}
|
|
2080
1209
|
for (const [id, value] of validationItems) {
|
|
2081
1210
|
if (!value) continue;
|
|
@@ -2103,6 +1232,7 @@ function applyBoardPatch(state, input, options = {}) {
|
|
|
2103
1232
|
if (!target) diagnostics.push(error(`items.${id}.props`, "BINDING_NOT_FOUND", `bound item ${bound} does not exist`));
|
|
2104
1233
|
else if (bound === id || target.type === "arrow") diagnostics.push(error(`items.${id}.props`, "INVALID_BINDING", "arrows bind to items other than arrows"));
|
|
2105
1234
|
}
|
|
1235
|
+
diagnostics.push(...validateAttach(id, value, item, state));
|
|
2106
1236
|
}
|
|
2107
1237
|
for (const [id, value] of nextItems) {
|
|
2108
1238
|
if (!value || !state.item(id) || state.item(id)?.type === value.type) continue;
|
|
@@ -2112,6 +1242,7 @@ function applyBoardPatch(state, input, options = {}) {
|
|
|
2112
1242
|
if (value.type === "arrow") for (const binder of state.binders(id)) {
|
|
2113
1243
|
const arrow = item(binder);
|
|
2114
1244
|
if (arrow && arrowBindings(arrow).includes(id)) diagnostics.push(error(`items.${binder}.props`, "INVALID_BINDING", "arrows cannot bind to arrows"));
|
|
1245
|
+
if (arrow?.attach?.item === id) diagnostics.push(error(`items.${binder}.attach`, "INVALID_ATTACH", "items cannot attach to arrows"));
|
|
2115
1246
|
}
|
|
2116
1247
|
for (const ref of state.trackRefs(id)) {
|
|
2117
1248
|
const current = track(ref.animation, ref.track);
|
|
@@ -2162,6 +1293,28 @@ function applyBoardPatch(state, input, options = {}) {
|
|
|
2162
1293
|
diagnostics: warnings
|
|
2163
1294
|
};
|
|
2164
1295
|
}
|
|
1296
|
+
function validateAttach(id, value, item, state) {
|
|
1297
|
+
const diagnostics = [];
|
|
1298
|
+
const attach = value.attach;
|
|
1299
|
+
if (attach) {
|
|
1300
|
+
const path = `items.${id}.attach`;
|
|
1301
|
+
const target = item(attach.item);
|
|
1302
|
+
if (!target) diagnostics.push(error(path, "ATTACH_NOT_FOUND", `attach target ${attach.item} does not exist`));
|
|
1303
|
+
else if (value.type === "arrow" || target.type === "arrow") diagnostics.push(error(path, "INVALID_ATTACH", "arrows bind their ends instead of attaching"));
|
|
1304
|
+
else if (target.attach) diagnostics.push(error(path, "INVALID_ATTACH", `${attach.item} follows ${target.attach.item}; attach to that item instead`));
|
|
1305
|
+
if (value.parent !== void 0) diagnostics.push(error(path, "INVALID_ATTACH", "an attached item follows its target instead of a frame; remove parent"));
|
|
1306
|
+
for (const follower of state.binders(id)) if (item(follower)?.attach?.item === id) diagnostics.push(error(`items.${follower}.attach`, "INVALID_ATTACH", `${id} follows ${attach.item}; attach to that item instead`));
|
|
1307
|
+
}
|
|
1308
|
+
let attached = Boolean(attach);
|
|
1309
|
+
let cursor = attach?.item ?? value.parent;
|
|
1310
|
+
for (let depth = 0; cursor && cursor !== id && depth < 64; depth += 1) {
|
|
1311
|
+
const next = item(cursor);
|
|
1312
|
+
attached ||= Boolean(next?.attach);
|
|
1313
|
+
cursor = next?.attach?.item ?? next?.parent;
|
|
1314
|
+
}
|
|
1315
|
+
if (cursor && attached) diagnostics.push(error(`items.${id}.${attach ? "attach" : "parent"}`, "INVALID_ATTACH", cursor === id ? `${id} cannot follow itself through attach and frames` : "attach and frames place an item more than 64 levels deep"));
|
|
1316
|
+
return diagnostics;
|
|
1317
|
+
}
|
|
2165
1318
|
function validateTrack(path, animationId, value, item, animation, track, script, state, keepUnknownProperty = false) {
|
|
2166
1319
|
const diagnostics = [];
|
|
2167
1320
|
let targetType;
|
|
@@ -2212,7 +1365,7 @@ function createDocumentState(document) {
|
|
|
2212
1365
|
refs = /* @__PURE__ */ new Map();
|
|
2213
1366
|
for (const [id, value] of Object.entries(document.items)) {
|
|
2214
1367
|
if (value.parent) children.set(value.parent, [...children.get(value.parent) ?? [], id]);
|
|
2215
|
-
for (const bound of
|
|
1368
|
+
for (const bound of itemBindings(value)) binders.set(bound, [...binders.get(bound) ?? [], id]);
|
|
2216
1369
|
}
|
|
2217
1370
|
for (const [animationId, value] of Object.entries(document.animations)) for (const [trackId, track] of Object.entries(value.tracks)) for (const ref of trackReferences(track)) refs.set(ref, [...refs.get(ref) ?? [], {
|
|
2218
1371
|
animation: animationId,
|
|
@@ -2304,8 +1457,7 @@ function parseBoardDocument(input, options = {}) {
|
|
|
2304
1457
|
document: result.document
|
|
2305
1458
|
} : result;
|
|
2306
1459
|
}
|
|
2307
|
-
|
|
2308
|
-
//#region ../protocol/src/fs/mime.ts
|
|
1460
|
+
// ../protocol/dist/fs/mime.js
|
|
2309
1461
|
const MIME_BY_EXTENSION = {
|
|
2310
1462
|
".txt": "text/plain",
|
|
2311
1463
|
".md": "text/markdown",
|
|
@@ -2430,8 +1582,7 @@ function modelFormatForPath(path, mimeType) {
|
|
|
2430
1582
|
};
|
|
2431
1583
|
return format(mimeTypeForPath(path)) ?? format(mimeType) ?? null;
|
|
2432
1584
|
}
|
|
2433
|
-
|
|
2434
|
-
//#region ../sdk/src/board/model/json.ts
|
|
1585
|
+
// ../sdk/src/board/model/json.ts
|
|
2435
1586
|
function sameJson(a, b) {
|
|
2436
1587
|
if (a === b) return true;
|
|
2437
1588
|
if (!a || !b || typeof a !== "object" || typeof b !== "object") return false;
|
|
@@ -2451,8 +1602,7 @@ function sameJson(a, b) {
|
|
|
2451
1602
|
for (const key of Object.keys(right)) if (right[key] !== void 0) members -= 1;
|
|
2452
1603
|
return members === 0;
|
|
2453
1604
|
}
|
|
2454
|
-
|
|
2455
|
-
//#region ../sdk/src/board/model/items/id.ts
|
|
1605
|
+
// ../sdk/src/board/model/items/id.ts
|
|
2456
1606
|
function createBoardEntityId() {
|
|
2457
1607
|
const cryptoRef = globalThis.crypto;
|
|
2458
1608
|
if (cryptoRef && typeof cryptoRef.randomUUID === "function") return cryptoRef.randomUUID();
|
|
@@ -2461,5 +1611,4 @@ function createBoardEntityId() {
|
|
|
2461
1611
|
function createBoardItemId() {
|
|
2462
1612
|
return `item_${createBoardEntityId()}`;
|
|
2463
1613
|
}
|
|
2464
|
-
|
|
2465
|
-
export { BoardAnimationHeaderSchema as $, invertMatrix as A, taskArtifactPreviewUrl as B, clampBoardFontSize as C, clampBoardStrokeSize as Ct, estimateTextWidth as D, drawSampleRadius as E, pointsRect as F, BOARD_COLOR_TOKENS as G, isBoardPath as H, scaleVector as I, BOARD_EXTENSION_TYPE_PATTERN as J, BOARD_EFFECT_KINDS as K, setBoardTextLayouter as L, layoutBoardText as M, matrixRotation as N, fitBoardMediaSize as O, multiplyMatrix as P, BOARD_SHAPE_GEOMETRIES as Q, sideAnchor as R, bendControl as S, boardDefaultSize as St, drawPointsBounds as T, parseBoardManifest as U, BOARD_CLIPBOARD_KIND as V, BOARD_CAMERA_TARGET as W, BOARD_ITEM_TYPES as X, BOARD_ITEM_SCHEMAS as Y, BOARD_SHADOW_DEFAULTS as Z, IDENTITY_MATRIX as _, BOARD_FONT_STACK as _t, isTextMime as a, BoardSettingsSchema as at, arrowBindings as b, BOARD_TEXT_FONT_FAMILY as bt, normalizeMime as c, hasAuthoredSize as ct, diffMergePatch as d, parseBoardMediaSource as dt, BoardColorSchema as et, listBoardProperties as f, isPublicBoardRemoteAddress as ft, resolveBoardProperty as g, BOARD_DEFAULT_SIZES as gt, pruneBoardTrack as h, BOARD_CAMERA_VIEWPORT as ht, isModelMime as i, BoardScriptSchema as it, isArrowBinding as j, framePoint as k, applyBoardDelta as l, isBuiltinItemType as lt, parseBoardDocument as m, BOARD_ARROW_STROKE_SIZE as mt, createBoardItemId as n, BoardIdSchema as nt, mimeTypeForPath as o, BoardTrackSchema as ot, mergePatch as p, normalizeBoardRemoteUrl as pt, BOARD_EFFECT_KIND_INFO as q, sameJson as r, BoardKeySchema as rt, modelFormatForPath as s, boardItemPreview as st, createBoardEntityId as t, BoardExtensionItemSchema as tt, applyBoardPatchToDocument as u, parseBoardItem as ut, adoptBoardNaturalSize as v, BOARD_MONO_FONT_STACK as vt, createBoardLayout as w, autoAnchorSide as x, BOARD_TEXT_SCALE as xt, applyMatrix as y, BOARD_PAGE_SIZE as yt, featuredTaskArtifact as z };
|
|
1614
|
+
export { invertMatrix as A, featuredTaskArtifact as B, clampBoardFontSize as C, estimateTextWidth as D, drawSampleRadius as E, multiplyMatrix as F, BOARD_CLIPBOARD_KIND as H, pointsRect as I, scaleVector as L, itemBindings as M, layoutBoardText as N, fitBoardMediaSize as O, matrixRotation as P, setBoardTextLayouter as R, bendControl as S, drawPointsBounds as T, isBoardPath as U, taskArtifactPreviewUrl as V, parseBoardManifest as W, IDENTITY_MATRIX as _, isTextMime as a, arrowBindings as b, normalizeMime as c, diffMergePatch as d, listBoardProperties as f, resolveBoardProperty as g, pruneBoardTrack as h, isModelMime as i, isArrowBinding as j, framePoint as k, applyBoardDelta as l, parseBoardDocument as m, createBoardItemId as n, mimeTypeForPath as o, mergePatch as p, sameJson as r, modelFormatForPath as s, createBoardEntityId as t, applyBoardPatchToDocument as u, adoptBoardNaturalSize as v, createBoardLayout as w, autoAnchorSide as x, applyMatrix as y, sideAnchor as z };
|