@neta-art/cohub-cli 10.24.0 → 10.25.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/bin/cohub.js +4 -1
- package/dist/board-gpu/page.js +1566 -71230
- package/dist/bootstrap.js +67 -27
- package/dist/build.json +1 -1
- package/dist/{board-kernel/FilterPipe.js → chunks/Geometry.js} +10447 -10469
- package/dist/chunks/about.js +102 -0
- package/dist/chunks/app-realtime.js +2216 -0
- package/dist/chunks/app-realtime2.js +2 -0
- package/dist/chunks/app-ref.js +88 -0
- package/dist/chunks/apps.js +1423 -0
- package/dist/chunks/auth.js +175 -0
- package/dist/chunks/avatar.js +146 -0
- package/dist/chunks/board-export-resources.js +232 -0
- package/dist/chunks/board-export.js +874 -0
- package/dist/chunks/board-export2.js +2 -0
- package/dist/{board-kernel.js → chunks/board-kernel.js} +18032 -28512
- package/dist/chunks/board-kernel2.js +4 -0
- package/dist/chunks/board-profile.js +69 -0
- package/dist/chunks/board-simulate.js +315 -0
- package/dist/chunks/board-time.js +34 -0
- package/dist/chunks/boards.js +1943 -0
- package/dist/{board-kernel → chunks}/browserAll.js +9 -8
- package/dist/chunks/channels.js +64 -0
- package/dist/chunks/client.js +12606 -0
- package/dist/chunks/command-input.js +17 -0
- package/dist/chunks/commander.js +2962 -0
- package/dist/chunks/cron-jobs.js +163 -0
- package/dist/chunks/daemon.js +545 -0
- package/dist/chunks/daemon2.js +2 -0
- package/dist/chunks/desktop.js +172 -0
- package/dist/chunks/endpoint-options.js +26 -0
- package/dist/chunks/env-proxy.js +35 -0
- package/dist/chunks/environment.js +154 -0
- package/dist/chunks/feedback.js +120 -0
- package/dist/chunks/generations.js +379 -0
- package/dist/chunks/host.js +9 -0
- package/dist/chunks/http-put.js +131 -0
- package/dist/chunks/id.js +2416 -0
- package/dist/{board-kernel → chunks}/init.js +1 -1
- package/dist/chunks/install.js +11959 -0
- package/dist/chunks/launch.js +374 -0
- package/dist/chunks/local-media.js +47 -0
- package/dist/chunks/me.js +134 -0
- package/dist/chunks/media.js +315 -0
- package/dist/chunks/models.js +242 -0
- package/dist/chunks/operands.js +46 -0
- package/dist/chunks/package-paths.js +13 -0
- package/dist/chunks/policy.js +221 -0
- package/dist/chunks/preferences.js +29 -0
- package/dist/chunks/profile.js +64 -0
- package/dist/chunks/prompts.js +41 -0
- package/dist/chunks/public.js +2 -0
- package/dist/chunks/public2.js +244 -0
- package/dist/chunks/references.js +197 -0
- package/dist/chunks/referrals.js +90 -0
- package/dist/chunks/rolldown-runtime.js +26 -0
- package/dist/chunks/rooms-connect.js +2 -0
- package/dist/chunks/rooms-connect2.js +151 -0
- package/dist/chunks/rooms-rtc.js +309 -0
- package/dist/chunks/rooms.js +211 -0
- package/dist/chunks/run.js +220 -0
- package/dist/chunks/runtime.js +638 -0
- package/dist/chunks/runtime2.js +286 -0
- package/dist/chunks/runtimes.js +48 -0
- package/dist/chunks/safe-remote-image.js +198 -0
- package/dist/chunks/schemas.js +6017 -0
- package/dist/chunks/search.js +113 -0
- package/dist/chunks/self-update.js +238 -0
- package/dist/chunks/serve.js +1246 -0
- package/dist/chunks/session-status.js +24 -0
- package/dist/chunks/skills.js +35 -0
- package/dist/chunks/spaces.js +5080 -0
- package/dist/chunks/src.js +405 -0
- package/dist/chunks/supervisor.js +2511 -0
- package/dist/chunks/supervisor2.js +2 -0
- package/dist/chunks/tasks.js +82 -0
- package/dist/chunks/themes.js +2898 -0
- package/dist/chunks/version.js +2 -0
- package/dist/chunks/version2.js +22 -0
- package/dist/chunks/version3.js +18 -0
- package/dist/chunks/web.js +7 -0
- package/dist/{board-kernel → chunks}/webworkerAll.js +1 -1
- package/dist/runtime/native/pi-extension.js +174 -166
- package/dist/runtime/worker.js +27 -16
- package/package.json +8 -9
- package/dist/about.d.ts +0 -2
- package/dist/about.js +0 -71
- package/dist/app-download.d.ts +0 -11
- package/dist/app-download.js +0 -252
- package/dist/app-ref.d.ts +0 -5
- package/dist/app-ref.js +0 -8
- package/dist/app-target.d.ts +0 -26
- package/dist/app-target.js +0 -55
- package/dist/auth.d.ts +0 -45
- package/dist/auth.js +0 -307
- package/dist/avatar.d.ts +0 -55
- package/dist/avatar.js +0 -104
- package/dist/board-command-support.d.ts +0 -6
- package/dist/board-command-support.js +0 -88
- package/dist/board-export-resources.d.ts +0 -12
- package/dist/board-export-resources.js +0 -51
- package/dist/board-export.d.ts +0 -110
- package/dist/board-export.js +0 -592
- package/dist/board-fonts.d.ts +0 -11
- package/dist/board-fonts.js +0 -10
- package/dist/board-gpu/daemon.d.ts +0 -11
- package/dist/board-gpu/daemon.js +0 -295
- package/dist/board-gpu/index.d.ts +0 -33
- package/dist/board-gpu/index.js +0 -189
- package/dist/board-gpu/protocol.d.ts +0 -77
- package/dist/board-gpu/protocol.js +0 -1
- package/dist/board-kernel.d.ts +0 -5
- package/dist/board-media-export.d.ts +0 -17
- package/dist/board-media-export.js +0 -164
- package/dist/board-media.d.ts +0 -5
- package/dist/board-media.js +0 -66
- package/dist/board-profile.d.ts +0 -21
- package/dist/board-profile.js +0 -67
- package/dist/board-simulate.d.ts +0 -67
- package/dist/board-simulate.js +0 -259
- package/dist/board-time.d.ts +0 -3
- package/dist/board-time.js +0 -34
- package/dist/bootstrap.d.ts +0 -2
- package/dist/client.d.ts +0 -5
- package/dist/client.js +0 -24
- package/dist/command-input.d.ts +0 -4
- package/dist/command-input.js +0 -16
- package/dist/commands/app-commerce.d.ts +0 -2
- package/dist/commands/app-commerce.js +0 -228
- package/dist/commands/app-domains.d.ts +0 -2
- package/dist/commands/app-domains.js +0 -133
- package/dist/commands/apps.d.ts +0 -4
- package/dist/commands/apps.js +0 -827
- package/dist/commands/auth.d.ts +0 -2
- package/dist/commands/auth.js +0 -186
- package/dist/commands/boards/authoring.d.ts +0 -2
- package/dist/commands/boards/authoring.js +0 -166
- package/dist/commands/boards/examples.d.ts +0 -10
- package/dist/commands/boards/examples.js +0 -118
- package/dist/commands/boards.d.ts +0 -13
- package/dist/commands/boards.js +0 -836
- package/dist/commands/channels.d.ts +0 -2
- package/dist/commands/channels.js +0 -74
- package/dist/commands/cron-jobs.d.ts +0 -2
- package/dist/commands/cron-jobs.js +0 -155
- package/dist/commands/decision.d.ts +0 -4
- package/dist/commands/decision.js +0 -113
- package/dist/commands/desktop.d.ts +0 -10
- package/dist/commands/desktop.js +0 -233
- package/dist/commands/feedback.d.ts +0 -2
- package/dist/commands/feedback.js +0 -131
- package/dist/commands/generations.d.ts +0 -2
- package/dist/commands/generations.js +0 -427
- package/dist/commands/host.d.ts +0 -2
- package/dist/commands/host.js +0 -11
- package/dist/commands/me.d.ts +0 -2
- package/dist/commands/me.js +0 -121
- package/dist/commands/models.d.ts +0 -28
- package/dist/commands/models.js +0 -271
- package/dist/commands/profile.d.ts +0 -2
- package/dist/commands/profile.js +0 -81
- package/dist/commands/prompts.d.ts +0 -2
- package/dist/commands/prompts.js +0 -37
- package/dist/commands/public.d.ts +0 -20
- package/dist/commands/public.js +0 -291
- package/dist/commands/references.d.ts +0 -2
- package/dist/commands/references.js +0 -193
- package/dist/commands/referrals.d.ts +0 -2
- package/dist/commands/referrals.js +0 -88
- package/dist/commands/rooms-connect.d.ts +0 -17
- package/dist/commands/rooms-connect.js +0 -140
- package/dist/commands/rooms-rtc-binary.d.ts +0 -2
- package/dist/commands/rooms-rtc-binary.js +0 -107
- package/dist/commands/rooms-rtc.d.ts +0 -21
- package/dist/commands/rooms-rtc.js +0 -171
- package/dist/commands/rooms.d.ts +0 -3
- package/dist/commands/rooms.js +0 -277
- package/dist/commands/run.d.ts +0 -13
- package/dist/commands/run.js +0 -246
- package/dist/commands/runtime.d.ts +0 -3
- package/dist/commands/runtime.js +0 -320
- package/dist/commands/sandboxd-binary.d.ts +0 -11
- package/dist/commands/sandboxd-binary.js +0 -238
- package/dist/commands/search.d.ts +0 -2
- package/dist/commands/search.js +0 -114
- package/dist/commands/session-access.d.ts +0 -2
- package/dist/commands/session-access.js +0 -70
- package/dist/commands/skills.d.ts +0 -2
- package/dist/commands/skills.js +0 -34
- package/dist/commands/space-activity.d.ts +0 -26
- package/dist/commands/space-activity.js +0 -147
- package/dist/commands/space-commerce.d.ts +0 -2
- package/dist/commands/space-commerce.js +0 -514
- package/dist/commands/space-displays.d.ts +0 -2
- package/dist/commands/space-displays.js +0 -620
- package/dist/commands/space-files.d.ts +0 -5
- package/dist/commands/space-files.js +0 -215
- package/dist/commands/space-invitations.d.ts +0 -29
- package/dist/commands/space-invitations.js +0 -189
- package/dist/commands/space-turns.d.ts +0 -49
- package/dist/commands/space-turns.js +0 -205
- package/dist/commands/space-wallet.d.ts +0 -2
- package/dist/commands/space-wallet.js +0 -141
- package/dist/commands/space-webhooks.d.ts +0 -7
- package/dist/commands/space-webhooks.js +0 -73
- package/dist/commands/spaces.d.ts +0 -25
- package/dist/commands/spaces.js +0 -2170
- package/dist/commands/tasks.d.ts +0 -8
- package/dist/commands/tasks.js +0 -80
- package/dist/commands/version.d.ts +0 -2
- package/dist/commands/version.js +0 -21
- package/dist/endpoint-options.d.ts +0 -4
- package/dist/endpoint-options.js +0 -26
- package/dist/env-proxy.d.ts +0 -5
- package/dist/env-proxy.js +0 -20
- package/dist/help-path.d.ts +0 -18
- package/dist/help-path.js +0 -223
- package/dist/host/auth.d.ts +0 -20
- package/dist/host/auth.js +0 -119
- package/dist/host/login-env.d.ts +0 -1
- package/dist/host/login-env.js +0 -31
- package/dist/host/runtime.d.ts +0 -35
- package/dist/host/runtime.js +0 -395
- package/dist/host/runtimes.d.ts +0 -9
- package/dist/host/runtimes.js +0 -42
- package/dist/host/serve.d.ts +0 -2
- package/dist/host/serve.js +0 -117
- package/dist/host/workspaces.d.ts +0 -2
- package/dist/host/workspaces.js +0 -18
- package/dist/http-put.d.ts +0 -25
- package/dist/http-put.js +0 -132
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -129
- package/dist/launcher.d.ts +0 -4
- package/dist/launcher.js +0 -38
- package/dist/local-media.d.ts +0 -2
- package/dist/local-media.js +0 -30
- package/dist/network-error.d.ts +0 -3
- package/dist/network-error.js +0 -22
- package/dist/output.d.ts +0 -46
- package/dist/output.js +0 -244
- package/dist/runtime/archive-store.d.ts +0 -54
- package/dist/runtime/archive-store.js +0 -379
- package/dist/runtime/cli-path.d.ts +0 -5
- package/dist/runtime/cli-path.js +0 -27
- package/dist/runtime/codex-usage.d.ts +0 -7
- package/dist/runtime/codex-usage.js +0 -11
- package/dist/runtime/connection.d.ts +0 -42
- package/dist/runtime/connection.js +0 -789
- package/dist/runtime/diagnostics.d.ts +0 -107
- package/dist/runtime/diagnostics.js +0 -392
- package/dist/runtime/harnesses/chained-projection.d.ts +0 -40
- package/dist/runtime/harnesses/chained-projection.js +0 -95
- package/dist/runtime/harnesses/chained-transcript.d.ts +0 -24
- package/dist/runtime/harnesses/chained-transcript.js +0 -62
- package/dist/runtime/harnesses/claude-approval.d.ts +0 -34
- package/dist/runtime/harnesses/claude-approval.js +0 -124
- package/dist/runtime/harnesses/claude-transcript.d.ts +0 -8
- package/dist/runtime/harnesses/claude-transcript.js +0 -138
- package/dist/runtime/harnesses/claude.d.ts +0 -8
- package/dist/runtime/harnesses/claude.js +0 -225
- package/dist/runtime/harnesses/codex-approval.d.ts +0 -25
- package/dist/runtime/harnesses/codex-approval.js +0 -69
- package/dist/runtime/harnesses/codex.d.ts +0 -4
- package/dist/runtime/harnesses/codex.js +0 -269
- package/dist/runtime/harnesses/cursor-transcript.d.ts +0 -37
- package/dist/runtime/harnesses/cursor-transcript.js +0 -183
- package/dist/runtime/harnesses/cursor.d.ts +0 -24
- package/dist/runtime/harnesses/cursor.js +0 -620
- package/dist/runtime/harnesses/index.d.ts +0 -16
- package/dist/runtime/harnesses/index.js +0 -73
- package/dist/runtime/harnesses/pi.d.ts +0 -4
- package/dist/runtime/harnesses/pi.js +0 -247
- package/dist/runtime/harnesses/process.d.ts +0 -31
- package/dist/runtime/harnesses/process.js +0 -75
- package/dist/runtime/harnesses/stream-json.d.ts +0 -48
- package/dist/runtime/harnesses/stream-json.js +0 -336
- package/dist/runtime/harnesses/types.d.ts +0 -117
- package/dist/runtime/harnesses/types.js +0 -1
- package/dist/runtime/harnesses/workbuddy-transcript.d.ts +0 -8
- package/dist/runtime/harnesses/workbuddy-transcript.js +0 -127
- package/dist/runtime/harnesses/workbuddy.d.ts +0 -21
- package/dist/runtime/harnesses/workbuddy.js +0 -123
- package/dist/runtime/instance.d.ts +0 -20
- package/dist/runtime/instance.js +0 -247
- package/dist/runtime/json-rpc.d.ts +0 -53
- package/dist/runtime/json-rpc.js +0 -212
- package/dist/runtime/launch.d.ts +0 -25
- package/dist/runtime/launch.js +0 -247
- package/dist/runtime/local-workspace.d.ts +0 -15
- package/dist/runtime/local-workspace.js +0 -52
- package/dist/runtime/model-catalog.d.ts +0 -12
- package/dist/runtime/model-catalog.js +0 -84
- package/dist/runtime/native/adapters.d.ts +0 -15
- package/dist/runtime/native/adapters.js +0 -11
- package/dist/runtime/native/approvals.d.ts +0 -18
- package/dist/runtime/native/approvals.js +0 -54
- package/dist/runtime/native/archive.d.ts +0 -19
- package/dist/runtime/native/archive.js +0 -142
- package/dist/runtime/native/attach.d.ts +0 -36
- package/dist/runtime/native/attach.js +0 -128
- package/dist/runtime/native/codex-link.d.ts +0 -60
- package/dist/runtime/native/codex-link.js +0 -322
- package/dist/runtime/native/config.d.ts +0 -16
- package/dist/runtime/native/config.js +0 -24
- package/dist/runtime/native/daemon.d.ts +0 -92
- package/dist/runtime/native/daemon.js +0 -380
- package/dist/runtime/native/execution.d.ts +0 -26
- package/dist/runtime/native/execution.js +0 -34
- package/dist/runtime/native/identity.d.ts +0 -9
- package/dist/runtime/native/identity.js +0 -15
- package/dist/runtime/native/ingest.d.ts +0 -263
- package/dist/runtime/native/ingest.js +0 -884
- package/dist/runtime/native/install.d.ts +0 -9
- package/dist/runtime/native/install.js +0 -113
- package/dist/runtime/native/paths.d.ts +0 -2
- package/dist/runtime/native/paths.js +0 -7
- package/dist/runtime/native/pi-extension.d.ts +0 -36
- package/dist/runtime/native/pi-link.d.ts +0 -69
- package/dist/runtime/native/pi-link.js +0 -269
- package/dist/runtime/native/results.d.ts +0 -41
- package/dist/runtime/native/results.js +0 -128
- package/dist/runtime/native/sessions.d.ts +0 -45
- package/dist/runtime/native/sessions.js +0 -87
- package/dist/runtime/native/transcript.d.ts +0 -89
- package/dist/runtime/native/transcript.js +0 -656
- package/dist/runtime/native/translate.d.ts +0 -46
- package/dist/runtime/native/translate.js +0 -299
- package/dist/runtime/native/transport.d.ts +0 -7
- package/dist/runtime/native/transport.js +0 -16
- package/dist/runtime/native/version.d.ts +0 -5
- package/dist/runtime/native/version.js +0 -21
- package/dist/runtime/preferences.d.ts +0 -7
- package/dist/runtime/preferences.js +0 -22
- package/dist/runtime/presentation.d.ts +0 -32
- package/dist/runtime/presentation.js +0 -124
- package/dist/runtime/process-group.d.ts +0 -5
- package/dist/runtime/process-group.js +0 -161
- package/dist/runtime/projection-store.d.ts +0 -27
- package/dist/runtime/projection-store.js +0 -30
- package/dist/runtime/space-binding.d.ts +0 -48
- package/dist/runtime/space-binding.js +0 -342
- package/dist/runtime/supervisor.d.ts +0 -19
- package/dist/runtime/supervisor.js +0 -441
- package/dist/runtime/turn-projection.d.ts +0 -41
- package/dist/runtime/turn-projection.js +0 -120
- package/dist/runtime/worker.d.ts +0 -1
- package/dist/safe-remote-image.d.ts +0 -36
- package/dist/safe-remote-image.js +0 -191
- package/dist/self-update.d.ts +0 -7
- package/dist/self-update.js +0 -202
- package/dist/session-status.d.ts +0 -10
- package/dist/session-status.js +0 -25
- package/dist/space-files/limit.d.ts +0 -2
- package/dist/space-files/limit.js +0 -16
- package/dist/space-files/operands.d.ts +0 -17
- package/dist/space-files/operands.js +0 -33
- package/dist/space-files/transfer.d.ts +0 -53
- package/dist/space-files/transfer.js +0 -297
- package/dist/space-files/upload.d.ts +0 -17
- package/dist/space-files/upload.js +0 -76
- package/dist/space.d.ts +0 -44
- package/dist/space.js +0 -192
- package/dist/version.d.ts +0 -2
- package/dist/version.js +0 -17
- package/dist/web.d.ts +0 -1
- package/dist/web.js +0 -4
- /package/dist/{board-kernel → chunks}/lexer.js +0 -0
|
@@ -0,0 +1,2416 @@
|
|
|
1
|
+
import { _ as union, a as array, c as discriminatedUnion, d as literal, f as number, 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
|
+
//#region ../protocol/src/board-constants.ts
|
|
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_TEXT_SCALE = {
|
|
10
|
+
title: 56,
|
|
11
|
+
heading: 40,
|
|
12
|
+
body: 24,
|
|
13
|
+
caption: 16
|
|
14
|
+
};
|
|
15
|
+
const BOARD_DEFAULT_ITEM_SIZE = {
|
|
16
|
+
width: 240,
|
|
17
|
+
height: 160
|
|
18
|
+
};
|
|
19
|
+
const BOARD_DEFAULT_SIZES = {
|
|
20
|
+
frame: {
|
|
21
|
+
width: 480,
|
|
22
|
+
height: 320
|
|
23
|
+
},
|
|
24
|
+
shape: {
|
|
25
|
+
width: 200,
|
|
26
|
+
height: 140
|
|
27
|
+
},
|
|
28
|
+
image: {
|
|
29
|
+
width: 480,
|
|
30
|
+
height: 270
|
|
31
|
+
},
|
|
32
|
+
video: {
|
|
33
|
+
width: 480,
|
|
34
|
+
height: 270
|
|
35
|
+
},
|
|
36
|
+
audio: {
|
|
37
|
+
width: 320,
|
|
38
|
+
height: 112
|
|
39
|
+
},
|
|
40
|
+
file: {
|
|
41
|
+
width: 260,
|
|
42
|
+
height: 132
|
|
43
|
+
},
|
|
44
|
+
task: {
|
|
45
|
+
width: 480,
|
|
46
|
+
height: 270
|
|
47
|
+
},
|
|
48
|
+
session: {
|
|
49
|
+
width: 320,
|
|
50
|
+
height: 176
|
|
51
|
+
},
|
|
52
|
+
effect: {
|
|
53
|
+
width: 240,
|
|
54
|
+
height: 240
|
|
55
|
+
},
|
|
56
|
+
custom: {
|
|
57
|
+
width: 480,
|
|
58
|
+
height: 320
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
function boardDefaultSize(type) {
|
|
62
|
+
return { ...Object.hasOwn(BOARD_DEFAULT_SIZES, type) ? BOARD_DEFAULT_SIZES[type] : BOARD_DEFAULT_ITEM_SIZE };
|
|
63
|
+
}
|
|
64
|
+
function clampBoardStrokeSize(size) {
|
|
65
|
+
if (!Number.isFinite(size)) return BOARD_ARROW_STROKE_SIZE;
|
|
66
|
+
return Math.min(64, Math.max(1, size));
|
|
67
|
+
}
|
|
68
|
+
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";
|
|
69
|
+
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";
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region ../protocol/src/board-url.ts
|
|
72
|
+
const BOARD_REMOTE_URL_MAX_LENGTH = 4096;
|
|
73
|
+
function parseIpv4(host) {
|
|
74
|
+
const parts = host.split(".").map(Number);
|
|
75
|
+
return parts.length === 4 && parts.every((part) => Number.isInteger(part) && part >= 0 && part <= 255) ? parts : null;
|
|
76
|
+
}
|
|
77
|
+
function isBlockedIpv4(host) {
|
|
78
|
+
const parts = parseIpv4(host);
|
|
79
|
+
if (!parts) return false;
|
|
80
|
+
const [first, second, third] = parts;
|
|
81
|
+
if (first === 0 || first === 10 || first === 127) return true;
|
|
82
|
+
if (first === 100 && second >= 64 && second <= 127) return true;
|
|
83
|
+
if (first === 169 && second === 254) return true;
|
|
84
|
+
if (first === 172 && second >= 16 && second <= 31) return true;
|
|
85
|
+
if (first === 192 && second === 168) return true;
|
|
86
|
+
if (first === 192 && second === 0 && (third === 0 || third === 2)) return true;
|
|
87
|
+
if (first === 192 && second === 88 && third === 99) return true;
|
|
88
|
+
if (first === 198 && (second === 18 || second === 19)) return true;
|
|
89
|
+
if (first === 198 && second === 51 && third === 100) return true;
|
|
90
|
+
if (first === 203 && second === 0 && third === 113) return true;
|
|
91
|
+
return first >= 224;
|
|
92
|
+
}
|
|
93
|
+
function expandIpv6(host) {
|
|
94
|
+
const [head, tail, extra] = host.toLowerCase().split("::");
|
|
95
|
+
if (extra !== void 0) return null;
|
|
96
|
+
const headParts = head ? head.split(":").filter(Boolean) : [];
|
|
97
|
+
const tailParts = tail ? tail.split(":").filter(Boolean) : [];
|
|
98
|
+
const missing = 8 - headParts.length - tailParts.length;
|
|
99
|
+
if (missing < 0 || tail === void 0 && missing !== 0) return null;
|
|
100
|
+
const parts = [
|
|
101
|
+
...headParts,
|
|
102
|
+
...Array.from({ length: missing }, () => "0"),
|
|
103
|
+
...tailParts
|
|
104
|
+
];
|
|
105
|
+
if (parts.length !== 8 || parts.some((part) => !/^[0-9a-f]{1,4}$/.test(part))) return null;
|
|
106
|
+
return parts.map((part) => part.padStart(4, "0"));
|
|
107
|
+
}
|
|
108
|
+
function isBlockedIpv6(host) {
|
|
109
|
+
const parts = expandIpv6(host);
|
|
110
|
+
if (!parts) return true;
|
|
111
|
+
if (parts.every((part) => part === "0000")) return true;
|
|
112
|
+
if (parts.slice(0, 7).every((part) => part === "0000") && parts[7] === "0001") return true;
|
|
113
|
+
if (parts.slice(0, 5).every((part) => part === "0000") && parts[5] === "ffff") {
|
|
114
|
+
const high = Number.parseInt(parts[6] ?? "0", 16);
|
|
115
|
+
const low = Number.parseInt(parts[7] ?? "0", 16);
|
|
116
|
+
return isBlockedIpv4(`${high >> 8}.${high & 255}.${low >> 8}.${low & 255}`);
|
|
117
|
+
}
|
|
118
|
+
if (parts.slice(0, 6).every((part) => part === "0000")) return true;
|
|
119
|
+
const first = Number.parseInt(parts[0] ?? "0", 16);
|
|
120
|
+
if ((first & 65024) === 64512) return true;
|
|
121
|
+
if ((first & 65472) === 65152 || (first & 65472) === 65216) return true;
|
|
122
|
+
if ((first & 65280) === 65280) return true;
|
|
123
|
+
return parts[0] === "2001" && parts[1] === "0db8";
|
|
124
|
+
}
|
|
125
|
+
function isPublicBoardRemoteAddress(value) {
|
|
126
|
+
const address = value.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.$/, "");
|
|
127
|
+
if (parseIpv4(address)) return !isBlockedIpv4(address);
|
|
128
|
+
return address.includes(":") && !isBlockedIpv6(address);
|
|
129
|
+
}
|
|
130
|
+
function isBlockedHost(hostname) {
|
|
131
|
+
const host = hostname.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.$/, "");
|
|
132
|
+
if (host === "localhost" || host.endsWith(".localhost") || host.endsWith(".local") || host.endsWith(".internal")) return true;
|
|
133
|
+
if (parseIpv4(host) || host.includes(":")) return !isPublicBoardRemoteAddress(host);
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Normalize a browser-loadable public HTTP(S) URL. This blocks explicit local
|
|
138
|
+
* addresses; any future server-side fetcher must additionally validate DNS
|
|
139
|
+
* resolution to defend against rebinding.
|
|
140
|
+
*/
|
|
141
|
+
function normalizeBoardRemoteUrl(value) {
|
|
142
|
+
if (typeof value !== "string") return void 0;
|
|
143
|
+
const input = value.trim();
|
|
144
|
+
if (!input || input.length > 4096) return void 0;
|
|
145
|
+
try {
|
|
146
|
+
const url = new URL(input);
|
|
147
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") return void 0;
|
|
148
|
+
if (url.username || url.password || isBlockedHost(url.hostname)) return;
|
|
149
|
+
const normalized = url.toString();
|
|
150
|
+
return normalized.length <= 4096 ? normalized : void 0;
|
|
151
|
+
} catch {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
string().max(BOARD_REMOTE_URL_MAX_LENGTH).refine((value) => normalizeBoardRemoteUrl(value) !== void 0, { message: "URL must be a public HTTP(S) URL without credentials" });
|
|
156
|
+
const BOARD_CAMERA_TARGET = "camera";
|
|
157
|
+
const BoardKeySchema = string().min(1).max(160).regex(/^[^\s/]+$/, "ids must not contain whitespace or '/'");
|
|
158
|
+
const BoardIdSchema = BoardKeySchema.refine((value) => value !== BOARD_CAMERA_TARGET, "\"camera\" is reserved");
|
|
159
|
+
const finite = number().finite();
|
|
160
|
+
const nonNegative = finite.nonnegative();
|
|
161
|
+
const ratio = finite.min(0).max(1);
|
|
162
|
+
const BoardVec2Schema = object({
|
|
163
|
+
x: finite,
|
|
164
|
+
y: finite
|
|
165
|
+
}).strict();
|
|
166
|
+
const BoardSizeSchema = object({
|
|
167
|
+
width: finite.positive(),
|
|
168
|
+
height: finite.positive()
|
|
169
|
+
}).strict();
|
|
170
|
+
const BOARD_COLOR_TOKENS = [
|
|
171
|
+
"brand",
|
|
172
|
+
"neutral",
|
|
173
|
+
"black",
|
|
174
|
+
"white",
|
|
175
|
+
"blue",
|
|
176
|
+
"green",
|
|
177
|
+
"amber",
|
|
178
|
+
"violet",
|
|
179
|
+
"rose"
|
|
180
|
+
];
|
|
181
|
+
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(" "));
|
|
182
|
+
function isBoardColorString(value) {
|
|
183
|
+
const color = value.trim().toLowerCase();
|
|
184
|
+
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);
|
|
185
|
+
}
|
|
186
|
+
const colorString = string().max(120).refine(isBoardColorString, "expected a palette token or a CSS color");
|
|
187
|
+
const BoardColorSchema = union([colorString, object({
|
|
188
|
+
light: colorString,
|
|
189
|
+
dark: colorString
|
|
190
|
+
}).strict()]).describe("Palette token (follows the theme), CSS color, or { light, dark }.");
|
|
191
|
+
const BOARD_DASHES = [
|
|
192
|
+
"solid",
|
|
193
|
+
"dashed",
|
|
194
|
+
"dotted"
|
|
195
|
+
];
|
|
196
|
+
const BOARD_BLEND_MODES = [
|
|
197
|
+
"normal",
|
|
198
|
+
"multiply",
|
|
199
|
+
"screen",
|
|
200
|
+
"add"
|
|
201
|
+
];
|
|
202
|
+
const BoardFilterSchema = object({
|
|
203
|
+
blur: finite.min(0).max(256).optional().describe("Blur radius in board units, as CSS blur()."),
|
|
204
|
+
brightness: finite.min(0).max(10).optional().describe("1 keeps the color, 0 is black."),
|
|
205
|
+
contrast: finite.min(0).max(10).optional().describe("1 keeps the color, 0 is flat gray."),
|
|
206
|
+
saturate: finite.min(0).max(10).optional().describe("1 keeps the color, 0 is gray, above 1 is vivid."),
|
|
207
|
+
hue: finite.min(-3600).max(3600).optional().describe("Hue rotation in degrees."),
|
|
208
|
+
grayscale: ratio.optional(),
|
|
209
|
+
sepia: ratio.optional(),
|
|
210
|
+
invert: ratio.optional()
|
|
211
|
+
}).strict().describe("CSS filters, applied in this order. On a frame, filter, shadow and blend treat the frame and its contents as one layer.");
|
|
212
|
+
const BOARD_SHADOW_DEFAULTS = {
|
|
213
|
+
opacity: .35,
|
|
214
|
+
blur: 16,
|
|
215
|
+
x: 0,
|
|
216
|
+
y: 8
|
|
217
|
+
};
|
|
218
|
+
const BoardShadowSchema = object({
|
|
219
|
+
color: BoardColorSchema.optional().describe("Defaults to black."),
|
|
220
|
+
opacity: ratio.optional().describe("Defaults to 0.35."),
|
|
221
|
+
blur: finite.min(0).max(256).optional().describe("Softness in board units, as CSS drop-shadow(); defaults to 16."),
|
|
222
|
+
x: finite.min(-1024).max(1024).optional(),
|
|
223
|
+
y: finite.min(-1024).max(1024).optional().describe("Defaults to 8.")
|
|
224
|
+
}).strict().describe("A drop shadow following the item's visible shape; with no offset and a bright color it glows.");
|
|
225
|
+
const BoardStyleSchema = object({
|
|
226
|
+
fill: BoardColorSchema.optional(),
|
|
227
|
+
fillOpacity: ratio.optional().describe("Fill opacity, independent of the item's opacity."),
|
|
228
|
+
stroke: BoardColorSchema.optional(),
|
|
229
|
+
strokeWidth: finite.min(0).max(64).optional(),
|
|
230
|
+
dash: _enum(BOARD_DASHES).optional(),
|
|
231
|
+
radius: nonNegative.optional().describe("Corner radius in board units."),
|
|
232
|
+
trim: ratio.optional().describe("Fraction of the outline drawn; animate 0 → 1 to draw it in."),
|
|
233
|
+
filter: BoardFilterSchema.optional(),
|
|
234
|
+
shadow: BoardShadowSchema.optional(),
|
|
235
|
+
blend: _enum(BOARD_BLEND_MODES).optional().describe("How the item mixes with what is under it.")
|
|
236
|
+
}).strict();
|
|
237
|
+
function isSafeBoardSourcePath(value) {
|
|
238
|
+
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 !== "..");
|
|
239
|
+
}
|
|
240
|
+
const srcSchema = string().refine(isSafeBoardSourcePath, "src must be a relative Space file path");
|
|
241
|
+
function parseBoardMediaSource(src) {
|
|
242
|
+
if (isSafeBoardSourcePath(src)) return {
|
|
243
|
+
kind: "file",
|
|
244
|
+
value: src
|
|
245
|
+
};
|
|
246
|
+
return normalizeBoardRemoteUrl(src) ? {
|
|
247
|
+
kind: "url",
|
|
248
|
+
value: src
|
|
249
|
+
} : null;
|
|
250
|
+
}
|
|
251
|
+
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.");
|
|
252
|
+
const BoardScriptSchema = object({
|
|
253
|
+
src: srcSchema.refine((path) => /\.m?js$/.test(path), "script src must be a .js or .mjs module").describe("A .js or .mjs Space file."),
|
|
254
|
+
params: record(string(), json()).default({}).describe("Values the module reads as params."),
|
|
255
|
+
targets: record(string().min(1).max(80), BoardIdSchema).default({}).describe("Named items the module can reach, as ctx.targets."),
|
|
256
|
+
seed: string().min(1).max(160).optional().describe("Seed for ctx.random() and shaders; defaults to the owner's id."),
|
|
257
|
+
enabled: boolean().default(true)
|
|
258
|
+
}).strict().describe("A JavaScript module attached to an item or the Board; `cohub boards schema script` lists its API.");
|
|
259
|
+
const itemEnvelope = {
|
|
260
|
+
script: BoardScriptSchema.optional(),
|
|
261
|
+
parent: BoardIdSchema.optional().describe("A frame id; position becomes relative to the frame, and the item moves with it."),
|
|
262
|
+
z: finite.optional().describe("Order among siblings; new items go on top."),
|
|
263
|
+
position: BoardVec2Schema.default({
|
|
264
|
+
x: 0,
|
|
265
|
+
y: 0
|
|
266
|
+
}),
|
|
267
|
+
rotation: finite.default(0),
|
|
268
|
+
scale: union([finite, BoardVec2Schema]).default(1),
|
|
269
|
+
origin: BoardVec2Schema.default({
|
|
270
|
+
x: .5,
|
|
271
|
+
y: .5
|
|
272
|
+
}).describe("Rotation and scale origin as fractions of the size."),
|
|
273
|
+
opacity: ratio.default(1),
|
|
274
|
+
visible: boolean().optional().describe("false hides the item and its children; key it on a timeline to show the item only for a span."),
|
|
275
|
+
style: BoardStyleSchema.default({}),
|
|
276
|
+
locked: boolean().optional(),
|
|
277
|
+
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."),
|
|
278
|
+
metadata: record(string(), unknown()).optional()
|
|
279
|
+
};
|
|
280
|
+
const boxed = (size) => ({
|
|
281
|
+
...itemEnvelope,
|
|
282
|
+
size: BoardSizeSchema.default({ ...size })
|
|
283
|
+
});
|
|
284
|
+
const unsized = { ...itemEnvelope };
|
|
285
|
+
const fontSize = finite.min(2).max(512);
|
|
286
|
+
const BOARD_TEXT_ALIGNS = [
|
|
287
|
+
"left",
|
|
288
|
+
"center",
|
|
289
|
+
"right"
|
|
290
|
+
];
|
|
291
|
+
const BOARD_TEXT_REVEAL_UNITS = [
|
|
292
|
+
"char",
|
|
293
|
+
"word",
|
|
294
|
+
"line"
|
|
295
|
+
];
|
|
296
|
+
const BOARD_TEXT_REVEAL_MOTIONS = [
|
|
297
|
+
"cut",
|
|
298
|
+
"fade",
|
|
299
|
+
"rise"
|
|
300
|
+
];
|
|
301
|
+
const BOARD_SHAPE_GEOMETRIES = [
|
|
302
|
+
"rectangle",
|
|
303
|
+
"rounded",
|
|
304
|
+
"ellipse",
|
|
305
|
+
"diamond",
|
|
306
|
+
"triangle",
|
|
307
|
+
"path"
|
|
308
|
+
];
|
|
309
|
+
const BoardFrameItemSchema = object({
|
|
310
|
+
...boxed(BOARD_DEFAULT_SIZES.frame),
|
|
311
|
+
type: literal("frame"),
|
|
312
|
+
props: object({
|
|
313
|
+
label: string().max(280).default(""),
|
|
314
|
+
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."),
|
|
315
|
+
clip: boolean().default(true).describe("Hide children outside the frame.")
|
|
316
|
+
}).strict().prefault({})
|
|
317
|
+
}).strict();
|
|
318
|
+
const BoardTextItemSchema = object({
|
|
319
|
+
...unsized,
|
|
320
|
+
type: literal("text"),
|
|
321
|
+
props: object({
|
|
322
|
+
text: string().default(""),
|
|
323
|
+
fontSize: fontSize.default(24),
|
|
324
|
+
fontWeight: finite.min(100).max(900).default(500),
|
|
325
|
+
font: string().min(1).max(120).default("sans").describe("sans, serif, mono, or a font family name."),
|
|
326
|
+
align: _enum(BOARD_TEXT_ALIGNS).default("left"),
|
|
327
|
+
lineHeight: finite.min(.5).max(4).default(4 / 3),
|
|
328
|
+
width: finite.positive().optional().describe("Wrap width; the height follows the text."),
|
|
329
|
+
reveal: ratio.default(1).describe("Fraction of the text shown; animate 0 → 1 to type it."),
|
|
330
|
+
revealBy: _enum(BOARD_TEXT_REVEAL_UNITS).optional().describe("What reveal counts: char (default), word or line."),
|
|
331
|
+
revealMotion: _enum(BOARD_TEXT_REVEAL_MOTIONS).optional().describe("How each unit appears: cut (default), fade or rise."),
|
|
332
|
+
caret: boolean().default(false).describe("Blink a caret while the text is being revealed.")
|
|
333
|
+
}).strict().prefault({})
|
|
334
|
+
}).strict();
|
|
335
|
+
const BoardShapeItemSchema = object({
|
|
336
|
+
...boxed(BOARD_DEFAULT_SIZES.shape),
|
|
337
|
+
type: literal("shape"),
|
|
338
|
+
props: object({
|
|
339
|
+
geometry: _enum(BOARD_SHAPE_GEOMETRIES).default("rectangle"),
|
|
340
|
+
path: string().min(1).max(2e5).optional().describe("SVG path data for path geometry, fitted to the item size."),
|
|
341
|
+
text: string().default(""),
|
|
342
|
+
fontSize: fontSize.default(20),
|
|
343
|
+
align: _enum(BOARD_TEXT_ALIGNS).default("center")
|
|
344
|
+
}).strict().refine((props) => props.geometry !== "path" || Boolean(props.path), {
|
|
345
|
+
message: "path geometry requires props.path",
|
|
346
|
+
path: ["path"]
|
|
347
|
+
}).prefault({})
|
|
348
|
+
}).strict();
|
|
349
|
+
const BoardDrawPointSchema = object({
|
|
350
|
+
x: finite,
|
|
351
|
+
y: finite,
|
|
352
|
+
p: ratio.default(.5).describe("Pen pressure.")
|
|
353
|
+
}).strict();
|
|
354
|
+
const BoardDrawItemSchema = object({
|
|
355
|
+
...unsized,
|
|
356
|
+
type: literal("draw"),
|
|
357
|
+
props: object({ points: array(BoardDrawPointSchema).min(1).max(1e5).describe("Stroke points relative to position; the size follows them.") }).strict()
|
|
358
|
+
}).strict();
|
|
359
|
+
const BoardArrowAnchorSchema = union([
|
|
360
|
+
literal("auto"),
|
|
361
|
+
object({
|
|
362
|
+
side: _enum([
|
|
363
|
+
"top",
|
|
364
|
+
"right",
|
|
365
|
+
"bottom",
|
|
366
|
+
"left"
|
|
367
|
+
]),
|
|
368
|
+
offset: ratio.default(.5)
|
|
369
|
+
}).strict(),
|
|
370
|
+
object({
|
|
371
|
+
x: ratio,
|
|
372
|
+
y: ratio
|
|
373
|
+
}).strict()
|
|
374
|
+
]);
|
|
375
|
+
const BoardArrowBindingSchema = object({
|
|
376
|
+
item: BoardIdSchema,
|
|
377
|
+
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."),
|
|
378
|
+
port: string().min(1).max(120).optional()
|
|
379
|
+
}).strict();
|
|
380
|
+
const BoardArrowEndSchema = union([BoardVec2Schema, BoardArrowBindingSchema]).describe("A point relative to position, or { item } to follow that item.");
|
|
381
|
+
const BOARD_ARROW_ROUTES = [
|
|
382
|
+
"straight",
|
|
383
|
+
"curve",
|
|
384
|
+
"orthogonal"
|
|
385
|
+
];
|
|
386
|
+
const BoardArrowItemSchema = object({
|
|
387
|
+
...unsized,
|
|
388
|
+
type: literal("arrow"),
|
|
389
|
+
props: object({
|
|
390
|
+
start: BoardArrowEndSchema,
|
|
391
|
+
end: BoardArrowEndSchema,
|
|
392
|
+
route: _enum(BOARD_ARROW_ROUTES).default("straight"),
|
|
393
|
+
bend: finite.min(-.85).max(.85).default(0).describe("Sideways curve as a fraction of the length; the sign picks the side."),
|
|
394
|
+
waypoints: array(BoardVec2Schema).max(64).default([]).describe("Points the route passes through."),
|
|
395
|
+
arrowStart: boolean().default(false),
|
|
396
|
+
arrowEnd: boolean().default(true),
|
|
397
|
+
label: string().max(280).default(""),
|
|
398
|
+
fontSize: fontSize.default(14),
|
|
399
|
+
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.")
|
|
400
|
+
}).strict()
|
|
401
|
+
}).strict();
|
|
402
|
+
const fileProps = {
|
|
403
|
+
src: BoardMediaSourceSchema,
|
|
404
|
+
snapshot: object({
|
|
405
|
+
title: string().optional(),
|
|
406
|
+
mimeType: string().optional(),
|
|
407
|
+
size: nonNegative.optional(),
|
|
408
|
+
mtimeMs: nonNegative.optional(),
|
|
409
|
+
naturalWidth: finite.positive().optional(),
|
|
410
|
+
naturalHeight: finite.positive().optional(),
|
|
411
|
+
durationMs: nonNegative.optional(),
|
|
412
|
+
excerpt: string().optional(),
|
|
413
|
+
coverPath: string().optional(),
|
|
414
|
+
coverUrl: string().optional()
|
|
415
|
+
}).strict().describe("Cached facts for an instant preview; filled in when the media loads.").optional()
|
|
416
|
+
};
|
|
417
|
+
const BoardMediaOriginSchema = object({
|
|
418
|
+
taskRunId: string().min(1).max(160),
|
|
419
|
+
artifactId: string().min(1).max(240)
|
|
420
|
+
}).strict().describe("The generation run and result this media came from.");
|
|
421
|
+
const mediaProps = {
|
|
422
|
+
...fileProps,
|
|
423
|
+
origin: BoardMediaOriginSchema.optional()
|
|
424
|
+
};
|
|
425
|
+
const timedFileProps = {
|
|
426
|
+
...mediaProps,
|
|
427
|
+
time: nonNegative.optional().describe("Playback position in milliseconds; animate props.time to play it on a timeline. It sounds while its time moves forward."),
|
|
428
|
+
volume: ratio.optional().describe("Loudness from 0 to 1; defaults to 1. Animate it to fade.")
|
|
429
|
+
};
|
|
430
|
+
const BoardCropSchema = object({
|
|
431
|
+
x: ratio,
|
|
432
|
+
y: ratio,
|
|
433
|
+
w: ratio,
|
|
434
|
+
h: ratio
|
|
435
|
+
}).strict().describe("Region shown, as fractions of the image. Without it the whole image fits inside size.");
|
|
436
|
+
const BoardImageItemSchema = object({
|
|
437
|
+
...boxed(BOARD_DEFAULT_SIZES.image),
|
|
438
|
+
type: literal("image"),
|
|
439
|
+
props: object({
|
|
440
|
+
...mediaProps,
|
|
441
|
+
crop: BoardCropSchema.optional()
|
|
442
|
+
}).strict()
|
|
443
|
+
}).strict();
|
|
444
|
+
const BoardVideoItemSchema = object({
|
|
445
|
+
...boxed(BOARD_DEFAULT_SIZES.video),
|
|
446
|
+
type: literal("video"),
|
|
447
|
+
props: object(timedFileProps).strict()
|
|
448
|
+
}).strict();
|
|
449
|
+
const BoardAudioItemSchema = object({
|
|
450
|
+
...boxed(BOARD_DEFAULT_SIZES.audio),
|
|
451
|
+
type: literal("audio"),
|
|
452
|
+
props: object(timedFileProps).strict()
|
|
453
|
+
}).strict();
|
|
454
|
+
const BoardFileItemSchema = object({
|
|
455
|
+
...boxed(BOARD_DEFAULT_SIZES.file),
|
|
456
|
+
type: literal("file"),
|
|
457
|
+
props: object(fileProps).strict()
|
|
458
|
+
}).strict();
|
|
459
|
+
const httpsUrl = string().max(4096).url();
|
|
460
|
+
const artifactBase = {
|
|
461
|
+
id: string().min(1).max(240),
|
|
462
|
+
title: string().max(240).optional(),
|
|
463
|
+
url: httpsUrl,
|
|
464
|
+
mimeType: string().max(160).optional()
|
|
465
|
+
};
|
|
466
|
+
const BoardTaskArtifactSchema = discriminatedUnion("type", [
|
|
467
|
+
object({
|
|
468
|
+
...artifactBase,
|
|
469
|
+
type: literal("image"),
|
|
470
|
+
naturalWidth: finite.positive().optional(),
|
|
471
|
+
naturalHeight: finite.positive().optional()
|
|
472
|
+
}).strict(),
|
|
473
|
+
object({
|
|
474
|
+
...artifactBase,
|
|
475
|
+
type: literal("video"),
|
|
476
|
+
previewUrl: httpsUrl.optional(),
|
|
477
|
+
durationMs: number().int().positive().optional(),
|
|
478
|
+
naturalWidth: finite.positive().optional(),
|
|
479
|
+
naturalHeight: finite.positive().optional()
|
|
480
|
+
}).strict(),
|
|
481
|
+
object({
|
|
482
|
+
...artifactBase,
|
|
483
|
+
type: literal("audio"),
|
|
484
|
+
previewUrl: httpsUrl.optional(),
|
|
485
|
+
durationMs: number().int().positive().optional()
|
|
486
|
+
}).strict(),
|
|
487
|
+
object({
|
|
488
|
+
id: string().min(1).max(240),
|
|
489
|
+
type: literal("text"),
|
|
490
|
+
title: string().max(240).optional(),
|
|
491
|
+
textExcerpt: string().min(1).max(480)
|
|
492
|
+
}).strict()
|
|
493
|
+
]);
|
|
494
|
+
const BoardTaskSnapshotSchema = object({
|
|
495
|
+
taskType: string().min(1).max(120),
|
|
496
|
+
status: _enum([
|
|
497
|
+
"pending",
|
|
498
|
+
"running",
|
|
499
|
+
"completed",
|
|
500
|
+
"failed"
|
|
501
|
+
]),
|
|
502
|
+
title: string().min(1).max(240),
|
|
503
|
+
model: string().max(160).optional(),
|
|
504
|
+
promptExcerpt: string().max(480).optional(),
|
|
505
|
+
errorExcerpt: string().max(240).optional(),
|
|
506
|
+
artifactCount: number().int().nonnegative(),
|
|
507
|
+
artifacts: array(BoardTaskArtifactSchema).max(6).default([]),
|
|
508
|
+
startedAt: string().max(64).optional(),
|
|
509
|
+
updatedAt: string().optional()
|
|
510
|
+
}).strict();
|
|
511
|
+
const BoardTaskItemSchema = object({
|
|
512
|
+
...boxed(BOARD_DEFAULT_SIZES.task),
|
|
513
|
+
type: literal("task"),
|
|
514
|
+
props: object({
|
|
515
|
+
taskRunId: string().min(1).max(160).describe("The generation run shown; the server keeps the card's status and results up to date."),
|
|
516
|
+
snapshot: BoardTaskSnapshotSchema.describe("Maintained by the server; omit it.")
|
|
517
|
+
}).strict()
|
|
518
|
+
}).strict();
|
|
519
|
+
const BoardSessionSnapshotSchema = object({
|
|
520
|
+
title: string().max(255).default(""),
|
|
521
|
+
excerpt: string().max(480).optional().describe("The latest message as plain text."),
|
|
522
|
+
source: string().max(120).optional().describe("Where the chat runs: web, cli or a channel."),
|
|
523
|
+
issue: _enum(["failed", "lost"]).optional().describe("How the last run ended when it did not finish."),
|
|
524
|
+
errorExcerpt: string().max(240).optional(),
|
|
525
|
+
activityAt: string().max(64).optional()
|
|
526
|
+
}).strict();
|
|
527
|
+
const BoardSessionItemSchema = object({
|
|
528
|
+
...boxed(BOARD_DEFAULT_SIZES.session),
|
|
529
|
+
type: literal("session"),
|
|
530
|
+
props: object({
|
|
531
|
+
sessionId: string().min(1).max(160).describe("The chat shown; the server keeps its title, latest message and status up to date."),
|
|
532
|
+
snapshot: BoardSessionSnapshotSchema.describe("Maintained by the server; omit it.")
|
|
533
|
+
}).strict()
|
|
534
|
+
}).strict();
|
|
535
|
+
const BOARD_EFFECT_KINDS = [
|
|
536
|
+
"particles",
|
|
537
|
+
"trail",
|
|
538
|
+
"impact",
|
|
539
|
+
"flash",
|
|
540
|
+
"glow"
|
|
541
|
+
];
|
|
542
|
+
const BOARD_PARTICLE_SHAPES = [
|
|
543
|
+
"circle",
|
|
544
|
+
"square",
|
|
545
|
+
"star",
|
|
546
|
+
"heart",
|
|
547
|
+
"spark"
|
|
548
|
+
];
|
|
549
|
+
const BOARD_EFFECT_KIND_INFO = {
|
|
550
|
+
particles: {
|
|
551
|
+
description: "Continuous particles emitted inside the effect frame.",
|
|
552
|
+
parameters: {
|
|
553
|
+
rate: "Particles per second.",
|
|
554
|
+
life: "Particle lifetime in milliseconds.",
|
|
555
|
+
particleSize: "Particle size in board units.",
|
|
556
|
+
speed: "Particle speed in board units per second.",
|
|
557
|
+
direction: "Emission direction in degrees.",
|
|
558
|
+
spread: "Emission spread in degrees.",
|
|
559
|
+
gravity: "Acceleration in board units per second squared.",
|
|
560
|
+
intensity: "Opacity and size multiplier.",
|
|
561
|
+
seed: "Stable seed for repeatable particle motion.",
|
|
562
|
+
shape: "circle, square, star, heart or spark.",
|
|
563
|
+
colors: "Up to eight colors the particles pick from."
|
|
564
|
+
}
|
|
565
|
+
},
|
|
566
|
+
trail: {
|
|
567
|
+
description: "A fading trail following another item.",
|
|
568
|
+
parameters: {
|
|
569
|
+
follow: "ID of the item to follow.",
|
|
570
|
+
life: "Trail lifetime in milliseconds.",
|
|
571
|
+
particleSize: "Trail width in board units.",
|
|
572
|
+
intensity: "Opacity multiplier."
|
|
573
|
+
}
|
|
574
|
+
},
|
|
575
|
+
impact: {
|
|
576
|
+
description: "A repeating radial burst centered in the effect frame.",
|
|
577
|
+
parameters: {
|
|
578
|
+
rate: "Particles per burst.",
|
|
579
|
+
life: "Time between bursts in milliseconds.",
|
|
580
|
+
particleSize: "Particle and ring size in board units.",
|
|
581
|
+
speed: "Particle speed in board units per second.",
|
|
582
|
+
direction: "Burst direction in degrees.",
|
|
583
|
+
spread: "Burst spread in degrees.",
|
|
584
|
+
gravity: "Acceleration in board units per second squared.",
|
|
585
|
+
intensity: "Opacity multiplier.",
|
|
586
|
+
seed: "Stable seed for repeatable bursts.",
|
|
587
|
+
shape: "circle, square, star, heart or spark.",
|
|
588
|
+
colors: "Up to eight colors the particles pick from."
|
|
589
|
+
}
|
|
590
|
+
},
|
|
591
|
+
flash: {
|
|
592
|
+
description: "A repeating full-frame flash.",
|
|
593
|
+
parameters: {
|
|
594
|
+
life: "Time between flashes in milliseconds.",
|
|
595
|
+
intensity: "Flash opacity multiplier."
|
|
596
|
+
}
|
|
597
|
+
},
|
|
598
|
+
glow: {
|
|
599
|
+
description: "A pulsing set of concentric rings.",
|
|
600
|
+
parameters: {
|
|
601
|
+
life: "Pulse period in milliseconds.",
|
|
602
|
+
intensity: "Glow opacity multiplier."
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
const BoardEffectItemSchema = object({
|
|
607
|
+
...boxed(BOARD_DEFAULT_SIZES.effect),
|
|
608
|
+
type: literal("effect"),
|
|
609
|
+
props: object({
|
|
610
|
+
kind: _enum(BOARD_EFFECT_KINDS),
|
|
611
|
+
rate: nonNegative.max(2e4).default(40),
|
|
612
|
+
life: finite.positive().max(6e4).default(1200),
|
|
613
|
+
particleSize: finite.positive().max(512).default(6),
|
|
614
|
+
speed: nonNegative.max(1e4).default(120),
|
|
615
|
+
direction: finite.default(-90),
|
|
616
|
+
spread: finite.min(0).max(360).default(360),
|
|
617
|
+
gravity: finite.default(0),
|
|
618
|
+
intensity: nonNegative.max(10).default(1),
|
|
619
|
+
follow: BoardIdSchema.optional().describe("trail: the item to follow."),
|
|
620
|
+
seed: string().min(1).max(160).optional().describe("Makes procedural motion repeatable."),
|
|
621
|
+
shape: _enum(BOARD_PARTICLE_SHAPES).optional().describe("particles and impact: circle by default; square and star tumble, spark streaks along its motion."),
|
|
622
|
+
colors: array(BoardColorSchema).min(1).max(8).optional().describe("particles and impact: each particle picks one; defaults to style.fill.")
|
|
623
|
+
}).strict()
|
|
624
|
+
}).strict();
|
|
625
|
+
const BoardCustomItemSchema = object({
|
|
626
|
+
...boxed(BOARD_DEFAULT_SIZES.custom),
|
|
627
|
+
type: literal("custom"),
|
|
628
|
+
script: BoardScriptSchema,
|
|
629
|
+
props: object({}).strict().default({})
|
|
630
|
+
}).strict();
|
|
631
|
+
const BOARD_EXTENSION_TYPE_PATTERN = /^[a-z][a-z0-9]*(?:\.[a-z0-9-]+)+$/;
|
|
632
|
+
const BoardItemPreviewSchema = object({
|
|
633
|
+
title: string().max(500).optional(),
|
|
634
|
+
excerpt: string().max(2e3).optional(),
|
|
635
|
+
cover: BoardMediaSourceSchema.optional().describe("An image for the card."),
|
|
636
|
+
src: BoardMediaSourceSchema.optional().describe("The file or page the card stands for.")
|
|
637
|
+
}).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.");
|
|
638
|
+
const BoardExtensionItemSchema = object({
|
|
639
|
+
...boxed(BOARD_DEFAULT_ITEM_SIZE),
|
|
640
|
+
type: string().regex(BOARD_EXTENSION_TYPE_PATTERN),
|
|
641
|
+
props: record(string(), unknown()).default({}),
|
|
642
|
+
preview: BoardItemPreviewSchema.optional()
|
|
643
|
+
}).strict();
|
|
644
|
+
const BOARD_ITEM_SCHEMAS = {
|
|
645
|
+
frame: BoardFrameItemSchema,
|
|
646
|
+
text: BoardTextItemSchema,
|
|
647
|
+
shape: BoardShapeItemSchema,
|
|
648
|
+
draw: BoardDrawItemSchema,
|
|
649
|
+
arrow: BoardArrowItemSchema,
|
|
650
|
+
image: BoardImageItemSchema,
|
|
651
|
+
video: BoardVideoItemSchema,
|
|
652
|
+
audio: BoardAudioItemSchema,
|
|
653
|
+
file: BoardFileItemSchema,
|
|
654
|
+
task: BoardTaskItemSchema,
|
|
655
|
+
session: BoardSessionItemSchema,
|
|
656
|
+
effect: BoardEffectItemSchema,
|
|
657
|
+
custom: BoardCustomItemSchema
|
|
658
|
+
};
|
|
659
|
+
const BOARD_ITEM_TYPES = Object.keys(BOARD_ITEM_SCHEMAS);
|
|
660
|
+
function isBuiltinItemType(type) {
|
|
661
|
+
return Object.hasOwn(BOARD_ITEM_SCHEMAS, type);
|
|
662
|
+
}
|
|
663
|
+
function isBuiltinItem(item) {
|
|
664
|
+
return isBuiltinItemType(item.type);
|
|
665
|
+
}
|
|
666
|
+
function boardItemPreview(item) {
|
|
667
|
+
return isBuiltinItem(item) ? null : item.preview ?? null;
|
|
668
|
+
}
|
|
669
|
+
const BOARD_DERIVED_SIZE_TYPES = [
|
|
670
|
+
"text",
|
|
671
|
+
"draw",
|
|
672
|
+
"arrow"
|
|
673
|
+
];
|
|
674
|
+
function hasAuthoredSize(type) {
|
|
675
|
+
return !BOARD_DERIVED_SIZE_TYPES.includes(type);
|
|
676
|
+
}
|
|
677
|
+
function boardItemSchema(type) {
|
|
678
|
+
if (isBuiltinItemType(type)) return BOARD_ITEM_SCHEMAS[type];
|
|
679
|
+
return BOARD_EXTENSION_TYPE_PATTERN.test(type) ? BoardExtensionItemSchema : null;
|
|
680
|
+
}
|
|
681
|
+
function issuesToDiagnostics(error, path) {
|
|
682
|
+
return error.issues.map((issue) => {
|
|
683
|
+
return {
|
|
684
|
+
severity: "error",
|
|
685
|
+
code: "INVALID_ITEM",
|
|
686
|
+
path: [path, ...issue.path.map(String)].filter(Boolean).join("."),
|
|
687
|
+
message: issue.code === "unrecognized_keys" ? `unknown ${issue.keys.length === 1 ? "property" : "properties"} ${issue.keys.join(", ")}` : issue.message
|
|
688
|
+
};
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
const keepAllBoardFields = () => true;
|
|
692
|
+
function keepBoardFieldsOf(value) {
|
|
693
|
+
return (path, key) => Object.hasOwn(fieldAt(value, path) ?? {}, key);
|
|
694
|
+
}
|
|
695
|
+
function fieldAt(value, path) {
|
|
696
|
+
let cursor = value;
|
|
697
|
+
for (const segment of path) cursor = cursor && typeof cursor === "object" ? cursor[segment] : void 0;
|
|
698
|
+
return cursor && typeof cursor === "object" ? cursor : null;
|
|
699
|
+
}
|
|
700
|
+
function withoutFields(value, path, keys) {
|
|
701
|
+
if (!value || typeof value !== "object") return value;
|
|
702
|
+
const copy = Array.isArray(value) ? [...value] : { ...value };
|
|
703
|
+
if (path.length === 0) for (const key of keys) delete copy[key];
|
|
704
|
+
else copy[path[0]] = withoutFields(copy[path[0]], path.slice(1), keys);
|
|
705
|
+
return copy;
|
|
706
|
+
}
|
|
707
|
+
function parseKeepingBoardFields(schema, value, keep) {
|
|
708
|
+
const kept = [];
|
|
709
|
+
let candidate = value;
|
|
710
|
+
for (;;) {
|
|
711
|
+
const result = schema.safeParse(candidate);
|
|
712
|
+
if (result.success) {
|
|
713
|
+
for (const field of kept) {
|
|
714
|
+
const target = fieldAt(result.data, field.path);
|
|
715
|
+
if (target) target[field.key] = field.value;
|
|
716
|
+
}
|
|
717
|
+
return result;
|
|
718
|
+
}
|
|
719
|
+
if (!keep) return result;
|
|
720
|
+
let stripped = false;
|
|
721
|
+
for (const issue of result.error.issues) {
|
|
722
|
+
if (issue.code !== "unrecognized_keys") continue;
|
|
723
|
+
const keys = issue.keys.filter((key) => key !== "__proto__" && keep(issue.path, key));
|
|
724
|
+
if (!keys.length) continue;
|
|
725
|
+
const source = fieldAt(candidate, issue.path);
|
|
726
|
+
for (const key of keys) kept.push({
|
|
727
|
+
path: issue.path,
|
|
728
|
+
key,
|
|
729
|
+
value: source?.[key]
|
|
730
|
+
});
|
|
731
|
+
candidate = withoutFields(candidate, issue.path, keys);
|
|
732
|
+
stripped = true;
|
|
733
|
+
}
|
|
734
|
+
if (!stripped) return result;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
function parseBoardItem(value, path = "item", keep) {
|
|
738
|
+
const type = value && typeof value === "object" && !Array.isArray(value) ? value.type : void 0;
|
|
739
|
+
if (typeof type !== "string") return {
|
|
740
|
+
ok: false,
|
|
741
|
+
diagnostics: [{
|
|
742
|
+
severity: "error",
|
|
743
|
+
code: "INVALID_ITEM",
|
|
744
|
+
path: `${path}.type`,
|
|
745
|
+
message: "type is required"
|
|
746
|
+
}]
|
|
747
|
+
};
|
|
748
|
+
const schema = boardItemSchema(type);
|
|
749
|
+
if (!schema) return {
|
|
750
|
+
ok: false,
|
|
751
|
+
diagnostics: [{
|
|
752
|
+
severity: "error",
|
|
753
|
+
code: "INVALID_ITEM",
|
|
754
|
+
path: `${path}.type`,
|
|
755
|
+
message: `unknown type ${type}; expected ${BOARD_ITEM_TYPES.join(", ")} or a namespaced extension type`
|
|
756
|
+
}]
|
|
757
|
+
};
|
|
758
|
+
const parsed = parseKeepingBoardFields(schema, value, keep);
|
|
759
|
+
return parsed.success ? {
|
|
760
|
+
ok: true,
|
|
761
|
+
item: parsed.data
|
|
762
|
+
} : {
|
|
763
|
+
ok: false,
|
|
764
|
+
diagnostics: issuesToDiagnostics(parsed.error, path)
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
const CSS_EASE_KEYWORDS = /* @__PURE__ */ new Set([
|
|
768
|
+
"linear",
|
|
769
|
+
"ease",
|
|
770
|
+
"ease-in",
|
|
771
|
+
"ease-out",
|
|
772
|
+
"ease-in-out",
|
|
773
|
+
"step-start",
|
|
774
|
+
"step-end"
|
|
775
|
+
]);
|
|
776
|
+
function isBoardEase(value) {
|
|
777
|
+
const ease = value.trim();
|
|
778
|
+
if (CSS_EASE_KEYWORDS.has(ease)) return true;
|
|
779
|
+
const bezier = /^cubic-bezier\(\s*([^,()]+),\s*([^,()]+),\s*([^,()]+),\s*([^,()]+)\)$/.exec(ease);
|
|
780
|
+
if (bezier) {
|
|
781
|
+
const [x1, , x2] = bezier.slice(1).map(Number);
|
|
782
|
+
return bezier.slice(1).every((part) => Number.isFinite(Number(part))) && x1 >= 0 && x1 <= 1 && x2 >= 0 && x2 <= 1;
|
|
783
|
+
}
|
|
784
|
+
return /^steps\(\s*[1-9]\d*\s*(?:,\s*(?:start|end|jump-start|jump-end|jump-none|jump-both)\s*)?\)$/.test(ease);
|
|
785
|
+
}
|
|
786
|
+
const BoardEaseSchema = string().max(120).refine(isBoardEase, "expected a CSS easing: linear, ease-in-out, cubic-bezier(…) or steps(…)");
|
|
787
|
+
const BoardKeyframeSchema = object({
|
|
788
|
+
at: nonNegative.describe("Time in milliseconds."),
|
|
789
|
+
value: unknown(),
|
|
790
|
+
ease: BoardEaseSchema.optional().describe("Easing into this keyframe: a CSS keyword, cubic-bezier() or steps(); defaults to linear.")
|
|
791
|
+
}).strict();
|
|
792
|
+
const BoardTrackSchema = object({
|
|
793
|
+
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)."),
|
|
794
|
+
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."),
|
|
795
|
+
keyframes: array(BoardKeyframeSchema).min(1).max(1e5).describe("Ordered by at. The value holds before the first and after the last keyframe."),
|
|
796
|
+
composite: _enum(["replace", "add"]).default("replace").describe("replace: the latest-started track wins. add: positions and rotations add; scale and opacity multiply."),
|
|
797
|
+
interpolation: _enum([
|
|
798
|
+
"auto",
|
|
799
|
+
"step",
|
|
800
|
+
"spline"
|
|
801
|
+
]).default("auto").describe("auto blends numbers, vectors and colors and steps other values; spline smooths position paths."),
|
|
802
|
+
orient: boolean().optional().describe("Rotate the item along its path.")
|
|
803
|
+
}).strict().superRefine((track, context) => {
|
|
804
|
+
for (let index = 1; index < track.keyframes.length; index += 1) if ((track.keyframes[index]?.at ?? 0) < (track.keyframes[index - 1]?.at ?? 0)) context.addIssue({
|
|
805
|
+
code: "custom",
|
|
806
|
+
message: "keyframes must be ordered by at",
|
|
807
|
+
path: [
|
|
808
|
+
"keyframes",
|
|
809
|
+
index,
|
|
810
|
+
"at"
|
|
811
|
+
]
|
|
812
|
+
});
|
|
813
|
+
});
|
|
814
|
+
const BoardMarkerSchema = object({
|
|
815
|
+
at: nonNegative,
|
|
816
|
+
label: string().max(280).optional(),
|
|
817
|
+
pause: boolean().optional().describe("Hold shared playback here until next.")
|
|
818
|
+
}).strict();
|
|
819
|
+
const BoardAnimationHeaderSchema = object({
|
|
820
|
+
name: string().max(280).optional(),
|
|
821
|
+
duration: finite.positive().max(864e5).describe("Milliseconds; a new animation without it ends at its last keyframe."),
|
|
822
|
+
play: _enum([
|
|
823
|
+
"manual",
|
|
824
|
+
"auto",
|
|
825
|
+
"always"
|
|
826
|
+
]).default("manual").describe("manual: only shared playback starts it. auto: plays when the Board opens. always: loops continuously."),
|
|
827
|
+
delay: nonNegative.default(0),
|
|
828
|
+
loop: boolean().default(false),
|
|
829
|
+
end: _enum(["hold", "reset"]).default("hold").describe("hold keeps the last frame; reset returns to the start."),
|
|
830
|
+
markers: array(BoardMarkerSchema).max(1e4).default([]).describe("Labeled points on this timeline; a nested animation's markers do not carry over.")
|
|
831
|
+
}).strict();
|
|
832
|
+
BoardAnimationHeaderSchema.extend({ tracks: record(BoardKeySchema, BoardTrackSchema).default({}) }).strict();
|
|
833
|
+
const BOARD_ENTER_PRESETS = [
|
|
834
|
+
"fade-in",
|
|
835
|
+
"rise",
|
|
836
|
+
"drop",
|
|
837
|
+
"pop",
|
|
838
|
+
"deal"
|
|
839
|
+
];
|
|
840
|
+
const BoardBackgroundSchema = object({
|
|
841
|
+
color: BoardColorSchema.optional(),
|
|
842
|
+
pattern: _enum([
|
|
843
|
+
"none",
|
|
844
|
+
"dots",
|
|
845
|
+
"grid"
|
|
846
|
+
]).optional().describe("Spaced by grid.size; omit to follow the theme."),
|
|
847
|
+
image: object({
|
|
848
|
+
src: BoardMediaSourceSchema,
|
|
849
|
+
fit: _enum([
|
|
850
|
+
"cover",
|
|
851
|
+
"contain",
|
|
852
|
+
"repeat"
|
|
853
|
+
]).default("cover").describe("cover and contain fill the view; repeat tiles the Board at one board unit per image pixel."),
|
|
854
|
+
opacity: ratio.optional()
|
|
855
|
+
}).strict().optional()
|
|
856
|
+
}).strict().describe("Layers drawn under every item: color, then image, then pattern. Without a color or image the theme's backdrop shows.");
|
|
857
|
+
const BoardAtmosphereSchema = object({
|
|
858
|
+
vignette: ratio.optional().describe("Darkens the edges of the view."),
|
|
859
|
+
grain: ratio.optional().describe("Film grain over the view.")
|
|
860
|
+
}).strict().describe("Screen effects over every item, for viewers and exports alike.");
|
|
861
|
+
const BoardSettingsSchema = object({
|
|
862
|
+
title: string().min(1).max(255).optional(),
|
|
863
|
+
background: BoardBackgroundSchema.default({}),
|
|
864
|
+
grid: object({
|
|
865
|
+
size: finite.min(4).max(512).default(24).describe("Pattern spacing and snap step, in board units."),
|
|
866
|
+
snap: boolean().default(false).describe("Snap moved and resized items to the grid.")
|
|
867
|
+
}).strict().optional(),
|
|
868
|
+
atmosphere: BoardAtmosphereSchema.optional(),
|
|
869
|
+
enter: object({
|
|
870
|
+
preset: _enum(BOARD_ENTER_PRESETS),
|
|
871
|
+
duration: finite.positive().max(1e4).optional()
|
|
872
|
+
}).strict().optional().describe("Motion for items as they are added."),
|
|
873
|
+
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.")
|
|
874
|
+
}).strict();
|
|
875
|
+
const patchObject = record(string(), unknown());
|
|
876
|
+
const BoardPatchSchema = object({
|
|
877
|
+
board: patchObject.nullable().optional(),
|
|
878
|
+
items: record(BoardIdSchema, patchObject.nullable()).optional(),
|
|
879
|
+
animations: record(BoardIdSchema, patchObject.and(object({ tracks: record(BoardKeySchema, patchObject.nullable()).optional() })).nullable()).optional()
|
|
880
|
+
}).strict();
|
|
881
|
+
//#endregion
|
|
882
|
+
//#region ../protocol/src/board.ts
|
|
883
|
+
const BOARD_EXTENSION = ".board";
|
|
884
|
+
const BOARD_MIME_TYPE = "application/json";
|
|
885
|
+
const BOARD_MANIFEST_KIND = "cohub.board.manifest";
|
|
886
|
+
const BOARD_CLIPBOARD_KIND = "cohub.board.clipboard";
|
|
887
|
+
const BoardManifestSchema = object({
|
|
888
|
+
kind: literal(BOARD_MANIFEST_KIND),
|
|
889
|
+
version: literal(1),
|
|
890
|
+
boardId: string().uuid(),
|
|
891
|
+
title: string().min(1).max(255)
|
|
892
|
+
});
|
|
893
|
+
var InvalidBoardFileError = class extends Error {
|
|
894
|
+
code = "INVALID_BOARD_FILE";
|
|
895
|
+
constructor(message = "Board file is invalid") {
|
|
896
|
+
super(message);
|
|
897
|
+
this.name = "InvalidBoardFileError";
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
function parseBoardManifest(input) {
|
|
901
|
+
let value = input;
|
|
902
|
+
if (typeof input === "string") try {
|
|
903
|
+
value = JSON.parse(input);
|
|
904
|
+
} catch {
|
|
905
|
+
throw new InvalidBoardFileError("Board file must contain valid JSON");
|
|
906
|
+
}
|
|
907
|
+
const parsed = BoardManifestSchema.safeParse(value);
|
|
908
|
+
if (!parsed.success) throw new InvalidBoardFileError("Board file must contain a valid boardId");
|
|
909
|
+
return parsed.data;
|
|
910
|
+
}
|
|
911
|
+
function isBoardPath(path) {
|
|
912
|
+
return path.toLowerCase().endsWith(BOARD_EXTENSION);
|
|
913
|
+
}
|
|
914
|
+
const BOARD_READ_SECTIONS = ["items", "animations"];
|
|
915
|
+
const rectSchema = object({
|
|
916
|
+
x: number().finite(),
|
|
917
|
+
y: number().finite(),
|
|
918
|
+
width: number().finite().positive(),
|
|
919
|
+
height: number().finite().positive()
|
|
920
|
+
}).strict();
|
|
921
|
+
object({
|
|
922
|
+
only: array(_enum(BOARD_READ_SECTIONS)).optional(),
|
|
923
|
+
rect: rectSchema.optional(),
|
|
924
|
+
within: BoardIdSchema.optional(),
|
|
925
|
+
items: array(string().min(1)).max(5e4).optional(),
|
|
926
|
+
animations: array(string().min(1)).max(1e4).optional(),
|
|
927
|
+
limit: number().int().min(1).max(5e4).optional(),
|
|
928
|
+
cursor: string().min(1).optional(),
|
|
929
|
+
since: number().int().nonnegative().optional()
|
|
930
|
+
}).strict().refine((read) => !(read.cursor && (read.rect || read.within)), {
|
|
931
|
+
path: ["cursor"],
|
|
932
|
+
message: "cursor pages by id, so it cannot be combined with rect or within"
|
|
933
|
+
}).refine((read) => read.since === void 0 || Object.entries(read).every(([key, value]) => key === "since" || value === void 0), {
|
|
934
|
+
path: ["since"],
|
|
935
|
+
message: "since syncs the whole Board, so it cannot be combined with other read options"
|
|
936
|
+
});
|
|
937
|
+
object({
|
|
938
|
+
patch: BoardPatchSchema,
|
|
939
|
+
replace: boolean().default(false),
|
|
940
|
+
cascade: boolean().default(false),
|
|
941
|
+
dryRun: boolean().default(false),
|
|
942
|
+
baseVersion: number().int().nonnegative().optional(),
|
|
943
|
+
mutationId: string().min(1).max(160).optional(),
|
|
944
|
+
clientId: string().min(1).max(160).optional()
|
|
945
|
+
}).strict();
|
|
946
|
+
object({
|
|
947
|
+
path: string().min(1),
|
|
948
|
+
title: string().min(1).max(255).optional(),
|
|
949
|
+
document: BoardPatchSchema.optional(),
|
|
950
|
+
mutationId: string().max(160).optional()
|
|
951
|
+
}).strict();
|
|
952
|
+
object({
|
|
953
|
+
before: number().int().positive().optional(),
|
|
954
|
+
limit: number().int().min(1).max(500).default(200)
|
|
955
|
+
}).strict();
|
|
956
|
+
const commandId = string().min(1).max(160);
|
|
957
|
+
discriminatedUnion("type", [
|
|
958
|
+
object({
|
|
959
|
+
commandId,
|
|
960
|
+
type: literal("play"),
|
|
961
|
+
animationId: string().min(1),
|
|
962
|
+
position: number().finite().nonnegative().optional(),
|
|
963
|
+
timeScale: number().finite().positive().max(4).optional(),
|
|
964
|
+
seed: string().min(1).max(160).optional()
|
|
965
|
+
}).strict(),
|
|
966
|
+
object({
|
|
967
|
+
commandId,
|
|
968
|
+
type: literal("pause")
|
|
969
|
+
}).strict(),
|
|
970
|
+
object({
|
|
971
|
+
commandId,
|
|
972
|
+
type: literal("resume")
|
|
973
|
+
}).strict(),
|
|
974
|
+
object({
|
|
975
|
+
commandId,
|
|
976
|
+
type: literal("seek"),
|
|
977
|
+
position: number().finite().nonnegative()
|
|
978
|
+
}).strict(),
|
|
979
|
+
object({
|
|
980
|
+
commandId,
|
|
981
|
+
type: literal("next")
|
|
982
|
+
}).strict(),
|
|
983
|
+
object({
|
|
984
|
+
commandId,
|
|
985
|
+
type: literal("stop")
|
|
986
|
+
}).strict()
|
|
987
|
+
]);
|
|
988
|
+
//#endregion
|
|
989
|
+
//#region ../protocol/src/board-json.ts
|
|
990
|
+
/** Structural equality for JSON-shaped semantic values. */
|
|
991
|
+
function boardJsonEquals(a, b) {
|
|
992
|
+
if (a === b) return true;
|
|
993
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return Number.isNaN(a) && Number.isNaN(b);
|
|
994
|
+
const aArray = Array.isArray(a);
|
|
995
|
+
const bArray = Array.isArray(b);
|
|
996
|
+
if (aArray !== bArray) return false;
|
|
997
|
+
if (aArray && bArray) return a.length === b.length && a.every((value, index) => boardJsonEquals(value, b[index]));
|
|
998
|
+
const aRecord = a;
|
|
999
|
+
const bRecord = b;
|
|
1000
|
+
const keys = Object.keys(aRecord);
|
|
1001
|
+
return keys.length === Object.keys(bRecord).length && keys.every((key) => Object.hasOwn(bRecord, key) && boardJsonEquals(aRecord[key], bRecord[key]));
|
|
1002
|
+
}
|
|
1003
|
+
//#endregion
|
|
1004
|
+
//#region ../protocol/src/board-task.ts
|
|
1005
|
+
function artifactScore(artifact) {
|
|
1006
|
+
const kind = {
|
|
1007
|
+
text: 1,
|
|
1008
|
+
image: 2,
|
|
1009
|
+
audio: 3,
|
|
1010
|
+
video: 4
|
|
1011
|
+
}[artifact.type];
|
|
1012
|
+
if (artifact.type === "text") return [kind, artifact.textExcerpt.length];
|
|
1013
|
+
if (artifact.type === "image") return [kind, (artifact.naturalWidth ?? 0) * (artifact.naturalHeight ?? 0)];
|
|
1014
|
+
return [
|
|
1015
|
+
kind,
|
|
1016
|
+
artifact.previewUrl ? 1 : 0,
|
|
1017
|
+
artifact.durationMs ? 1 : 0,
|
|
1018
|
+
artifact.durationMs ?? 0
|
|
1019
|
+
];
|
|
1020
|
+
}
|
|
1021
|
+
function compareArtifacts(a, b) {
|
|
1022
|
+
const left = artifactScore(a);
|
|
1023
|
+
const right = artifactScore(b);
|
|
1024
|
+
for (let index = 0; index < Math.max(left.length, right.length); index += 1) {
|
|
1025
|
+
const difference = (right[index] ?? 0) - (left[index] ?? 0);
|
|
1026
|
+
if (difference !== 0) return difference;
|
|
1027
|
+
}
|
|
1028
|
+
return 0;
|
|
1029
|
+
}
|
|
1030
|
+
function featuredTaskArtifact(artifacts) {
|
|
1031
|
+
let featured;
|
|
1032
|
+
for (const artifact of artifacts) if (!featured || compareArtifacts(artifact, featured) < 0) featured = artifact;
|
|
1033
|
+
return featured;
|
|
1034
|
+
}
|
|
1035
|
+
function taskArtifactPreviewUrl(artifact) {
|
|
1036
|
+
if (artifact?.type === "image") return artifact.url;
|
|
1037
|
+
if (artifact?.type === "video" || artifact?.type === "audio") return artifact.previewUrl;
|
|
1038
|
+
}
|
|
1039
|
+
//#endregion
|
|
1040
|
+
//#region ../protocol/src/board-layout.ts
|
|
1041
|
+
const IDENTITY_MATRIX = [
|
|
1042
|
+
1,
|
|
1043
|
+
0,
|
|
1044
|
+
0,
|
|
1045
|
+
1,
|
|
1046
|
+
0,
|
|
1047
|
+
0
|
|
1048
|
+
];
|
|
1049
|
+
function multiplyMatrix(parent, child) {
|
|
1050
|
+
const [a1, b1, c1, d1, tx1, ty1] = parent;
|
|
1051
|
+
const [a2, b2, c2, d2, tx2, ty2] = child;
|
|
1052
|
+
return [
|
|
1053
|
+
a1 * a2 + c1 * b2,
|
|
1054
|
+
b1 * a2 + d1 * b2,
|
|
1055
|
+
a1 * c2 + c1 * d2,
|
|
1056
|
+
b1 * c2 + d1 * d2,
|
|
1057
|
+
a1 * tx2 + c1 * ty2 + tx1,
|
|
1058
|
+
b1 * tx2 + d1 * ty2 + ty1
|
|
1059
|
+
];
|
|
1060
|
+
}
|
|
1061
|
+
function invertMatrix(matrix) {
|
|
1062
|
+
const [a, b, c, d, tx, ty] = matrix;
|
|
1063
|
+
const det = a * d - b * c || 1e-12;
|
|
1064
|
+
return [
|
|
1065
|
+
d / det,
|
|
1066
|
+
-b / det,
|
|
1067
|
+
-c / det,
|
|
1068
|
+
a / det,
|
|
1069
|
+
(c * ty - d * tx) / det,
|
|
1070
|
+
(b * tx - a * ty) / det
|
|
1071
|
+
];
|
|
1072
|
+
}
|
|
1073
|
+
function applyMatrix(matrix, point) {
|
|
1074
|
+
const [a, b, c, d, tx, ty] = matrix;
|
|
1075
|
+
return {
|
|
1076
|
+
x: a * point.x + c * point.y + tx,
|
|
1077
|
+
y: b * point.x + d * point.y + ty
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
function matrixRotation([a, b, c, d]) {
|
|
1081
|
+
const mirrored = a * d - b * c < 0;
|
|
1082
|
+
return {
|
|
1083
|
+
rotation: Math.atan2(mirrored ? -b : b, mirrored ? -a : a) * 180 / Math.PI,
|
|
1084
|
+
mirrored
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
function scaleVector(scale) {
|
|
1088
|
+
return typeof scale === "number" ? {
|
|
1089
|
+
x: scale,
|
|
1090
|
+
y: scale
|
|
1091
|
+
} : scale;
|
|
1092
|
+
}
|
|
1093
|
+
let textLayouter;
|
|
1094
|
+
function setBoardTextLayouter(layouter) {
|
|
1095
|
+
textLayouter = layouter;
|
|
1096
|
+
textSizeCache.clear();
|
|
1097
|
+
}
|
|
1098
|
+
function isWideCharacter(code) {
|
|
1099
|
+
return code >= 4352 && code <= 4447 || code >= 11904 && code <= 42191 || code >= 44032 && code <= 55203 || code >= 63744 && code <= 64255 || code >= 65072 && code <= 65103 || code >= 65280 && code <= 65376 || code >= 65504 && code <= 65510 || code >= 127744 && code <= 129791 || code >= 131072 && code <= 262141;
|
|
1100
|
+
}
|
|
1101
|
+
function estimateTextWidth(text, fontSize) {
|
|
1102
|
+
let ems = 0;
|
|
1103
|
+
for (const character of text) {
|
|
1104
|
+
const code = character.codePointAt(0) ?? 0;
|
|
1105
|
+
if (character === " ") ems += .28;
|
|
1106
|
+
else if (isWideCharacter(code)) ems += 1;
|
|
1107
|
+
else if (/[il.,:;'|!]/.test(character)) ems += .3;
|
|
1108
|
+
else if (/[mwMW@]/.test(character)) ems += .85;
|
|
1109
|
+
else if (/[A-Z0-9]/.test(character)) ems += .64;
|
|
1110
|
+
else ems += .55;
|
|
1111
|
+
}
|
|
1112
|
+
return ems * fontSize;
|
|
1113
|
+
}
|
|
1114
|
+
function estimateLines(text, { fontSize }, maxWidth) {
|
|
1115
|
+
const measure = (line) => estimateTextWidth(line, fontSize);
|
|
1116
|
+
const paragraphs = text.split("\n");
|
|
1117
|
+
const lines = maxWidth ? paragraphs.flatMap((paragraph) => wrapParagraph(paragraph, maxWidth, measure)) : paragraphs;
|
|
1118
|
+
return {
|
|
1119
|
+
lines,
|
|
1120
|
+
width: lines.reduce((max, line) => Math.max(max, measure(line)), 0)
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
function wrapParagraph(paragraph, width, measure) {
|
|
1124
|
+
if (!paragraph) return [""];
|
|
1125
|
+
const tokens = paragraph.match(/[\u1100-\u115f\u2e80-\ua4cf\uac00-\ud7a3\uf900-\ufaff\uff00-\uff60]|[^\s\u1100-\u115f\u2e80-\ua4cf\uac00-\ud7a3\uf900-\ufaff\uff00-\uff60]+|\s+/g) ?? [paragraph];
|
|
1126
|
+
const lines = [];
|
|
1127
|
+
let line = "";
|
|
1128
|
+
for (const token of tokens) {
|
|
1129
|
+
const candidate = line + token;
|
|
1130
|
+
if (!line || measure(candidate.trimEnd()) <= width) {
|
|
1131
|
+
line = candidate;
|
|
1132
|
+
continue;
|
|
1133
|
+
}
|
|
1134
|
+
lines.push(line.trimEnd());
|
|
1135
|
+
line = /^\s+$/.test(token) ? "" : token;
|
|
1136
|
+
}
|
|
1137
|
+
lines.push(line.trimEnd());
|
|
1138
|
+
return lines;
|
|
1139
|
+
}
|
|
1140
|
+
const textSizeCache = /* @__PURE__ */ new Map();
|
|
1141
|
+
const TEXT_CACHE_LIMIT = 4096;
|
|
1142
|
+
function clampBoardFontSize(fontSize) {
|
|
1143
|
+
return Math.min(512, Math.max(2, fontSize));
|
|
1144
|
+
}
|
|
1145
|
+
function layoutBoardText(props) {
|
|
1146
|
+
const fontSize = clampBoardFontSize(props.fontSize ?? 24);
|
|
1147
|
+
const key = `${fontSize}|${props.fontWeight}|${props.font}|${props.lineHeight}|${props.width ?? ""}|${props.text}`;
|
|
1148
|
+
const cached = textSizeCache.get(key);
|
|
1149
|
+
if (cached) return cached;
|
|
1150
|
+
const font = {
|
|
1151
|
+
fontSize,
|
|
1152
|
+
fontWeight: props.fontWeight ?? 500,
|
|
1153
|
+
font: props.font ?? "sans"
|
|
1154
|
+
};
|
|
1155
|
+
const { lines, width } = (textLayouter ?? estimateLines)(props.text || "", font, props.width || void 0);
|
|
1156
|
+
const lineHeight = fontSize * (props.lineHeight ?? 4 / 3);
|
|
1157
|
+
const layout = {
|
|
1158
|
+
width: Math.max(props.width ?? 0, width, fontSize * .5),
|
|
1159
|
+
height: Math.max(1, lines.length) * lineHeight,
|
|
1160
|
+
lines,
|
|
1161
|
+
lineHeight
|
|
1162
|
+
};
|
|
1163
|
+
if (textSizeCache.size >= TEXT_CACHE_LIMIT) textSizeCache.clear();
|
|
1164
|
+
textSizeCache.set(key, layout);
|
|
1165
|
+
return layout;
|
|
1166
|
+
}
|
|
1167
|
+
function fitBoardMediaSize(natural, edge) {
|
|
1168
|
+
const { width, height } = natural;
|
|
1169
|
+
if (![
|
|
1170
|
+
width,
|
|
1171
|
+
height,
|
|
1172
|
+
edge
|
|
1173
|
+
].every((value) => Number.isFinite(value) && value > 0)) return null;
|
|
1174
|
+
const scale = edge / Math.max(width, height);
|
|
1175
|
+
return {
|
|
1176
|
+
width: Math.max(1, Math.round(width * scale)),
|
|
1177
|
+
height: Math.max(1, Math.round(height * scale))
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
/** Fits media items to their natural aspect ratio using the shared Board rule. */
|
|
1181
|
+
function adoptBoardNaturalSize(item, natural) {
|
|
1182
|
+
const dimensions = {
|
|
1183
|
+
naturalWidth: natural.width,
|
|
1184
|
+
naturalHeight: natural.height
|
|
1185
|
+
};
|
|
1186
|
+
if (item.type === "task") {
|
|
1187
|
+
const artifact = featuredTaskArtifact(item.props.snapshot.artifacts);
|
|
1188
|
+
if (artifact?.type !== "image" && artifact?.type !== "video" || artifact.naturalWidth && artifact.naturalHeight) return null;
|
|
1189
|
+
const size = fitBoardMediaSize(natural, Math.max(item.size.width, item.size.height));
|
|
1190
|
+
if (!size) return null;
|
|
1191
|
+
const artifacts = item.props.snapshot.artifacts.map((entry) => entry.id === artifact.id ? {
|
|
1192
|
+
...entry,
|
|
1193
|
+
...dimensions
|
|
1194
|
+
} : entry);
|
|
1195
|
+
return {
|
|
1196
|
+
...item,
|
|
1197
|
+
size,
|
|
1198
|
+
props: {
|
|
1199
|
+
...item.props,
|
|
1200
|
+
snapshot: {
|
|
1201
|
+
...item.props.snapshot,
|
|
1202
|
+
artifacts
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
};
|
|
1206
|
+
}
|
|
1207
|
+
if (item.type !== "image" && item.type !== "video") return null;
|
|
1208
|
+
if (item.props.snapshot?.naturalWidth && item.props.snapshot.naturalHeight) return null;
|
|
1209
|
+
const size = fitBoardMediaSize(natural, Math.max(item.size.width, item.size.height));
|
|
1210
|
+
if (!size) return null;
|
|
1211
|
+
const position = {
|
|
1212
|
+
x: item.position.x + (item.size.width - size.width) / 2,
|
|
1213
|
+
y: item.position.y + (item.size.height - size.height) / 2
|
|
1214
|
+
};
|
|
1215
|
+
return {
|
|
1216
|
+
...item,
|
|
1217
|
+
position,
|
|
1218
|
+
size,
|
|
1219
|
+
props: {
|
|
1220
|
+
...item.props,
|
|
1221
|
+
snapshot: {
|
|
1222
|
+
...item.props.snapshot,
|
|
1223
|
+
...dimensions
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1228
|
+
function drawSampleRadius(strokeWidth, pressure) {
|
|
1229
|
+
const clamped = Math.min(1, Math.max(0, pressure));
|
|
1230
|
+
return Math.max(.5, strokeWidth / 2 * (.5 + clamped));
|
|
1231
|
+
}
|
|
1232
|
+
function drawPointsBounds(points, strokeWidth) {
|
|
1233
|
+
if (points.length === 0) return {
|
|
1234
|
+
x: 0,
|
|
1235
|
+
y: 0,
|
|
1236
|
+
width: 1,
|
|
1237
|
+
height: 1
|
|
1238
|
+
};
|
|
1239
|
+
let minX = Number.POSITIVE_INFINITY;
|
|
1240
|
+
let minY = Number.POSITIVE_INFINITY;
|
|
1241
|
+
let maxX = Number.NEGATIVE_INFINITY;
|
|
1242
|
+
let maxY = Number.NEGATIVE_INFINITY;
|
|
1243
|
+
for (const point of points) {
|
|
1244
|
+
const radius = drawSampleRadius(strokeWidth, point.p);
|
|
1245
|
+
minX = Math.min(minX, point.x - radius);
|
|
1246
|
+
minY = Math.min(minY, point.y - radius);
|
|
1247
|
+
maxX = Math.max(maxX, point.x + radius);
|
|
1248
|
+
maxY = Math.max(maxY, point.y + radius);
|
|
1249
|
+
}
|
|
1250
|
+
return {
|
|
1251
|
+
x: minX,
|
|
1252
|
+
y: minY,
|
|
1253
|
+
width: Math.max(1, maxX - minX),
|
|
1254
|
+
height: Math.max(1, maxY - minY)
|
|
1255
|
+
};
|
|
1256
|
+
}
|
|
1257
|
+
function pointsRect(points) {
|
|
1258
|
+
let minX = Number.POSITIVE_INFINITY;
|
|
1259
|
+
let minY = Number.POSITIVE_INFINITY;
|
|
1260
|
+
let maxX = Number.NEGATIVE_INFINITY;
|
|
1261
|
+
let maxY = Number.NEGATIVE_INFINITY;
|
|
1262
|
+
for (const point of points) {
|
|
1263
|
+
minX = Math.min(minX, point.x);
|
|
1264
|
+
minY = Math.min(minY, point.y);
|
|
1265
|
+
maxX = Math.max(maxX, point.x);
|
|
1266
|
+
maxY = Math.max(maxY, point.y);
|
|
1267
|
+
}
|
|
1268
|
+
if (!Number.isFinite(minX)) return {
|
|
1269
|
+
x: 0,
|
|
1270
|
+
y: 0,
|
|
1271
|
+
width: 1,
|
|
1272
|
+
height: 1
|
|
1273
|
+
};
|
|
1274
|
+
return {
|
|
1275
|
+
x: minX,
|
|
1276
|
+
y: minY,
|
|
1277
|
+
width: Math.max(1, maxX - minX),
|
|
1278
|
+
height: Math.max(1, maxY - minY)
|
|
1279
|
+
};
|
|
1280
|
+
}
|
|
1281
|
+
function isArrowBinding(end) {
|
|
1282
|
+
return typeof end.item === "string";
|
|
1283
|
+
}
|
|
1284
|
+
function arrowBindings(item) {
|
|
1285
|
+
if (item.type !== "arrow") return [];
|
|
1286
|
+
const props = item.props;
|
|
1287
|
+
const ids = [props.start, props.end].filter(isArrowBinding).map((end) => end.item);
|
|
1288
|
+
return [...new Set(ids)];
|
|
1289
|
+
}
|
|
1290
|
+
function bendControl(start, end, bend) {
|
|
1291
|
+
const mid = {
|
|
1292
|
+
x: (start.x + end.x) / 2,
|
|
1293
|
+
y: (start.y + end.y) / 2
|
|
1294
|
+
};
|
|
1295
|
+
if (!bend) return mid;
|
|
1296
|
+
const dx = end.x - start.x;
|
|
1297
|
+
const dy = end.y - start.y;
|
|
1298
|
+
const length = Math.hypot(dx, dy) || 1;
|
|
1299
|
+
const offset = bend * length;
|
|
1300
|
+
return {
|
|
1301
|
+
x: mid.x + -dy / length * offset,
|
|
1302
|
+
y: mid.y + dx / length * offset
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1305
|
+
const MAX_DEPTH = 64;
|
|
1306
|
+
function createBoardLayout(initialLookup, dependents) {
|
|
1307
|
+
let lookup = initialLookup;
|
|
1308
|
+
const boxes = /* @__PURE__ */ new Map();
|
|
1309
|
+
const matrices = /* @__PURE__ */ new Map();
|
|
1310
|
+
const bounds = /* @__PURE__ */ new Map();
|
|
1311
|
+
function matrixOf(id, depth = 0) {
|
|
1312
|
+
const cached = matrices.get(id);
|
|
1313
|
+
if (cached) return cached;
|
|
1314
|
+
const item = lookup(id);
|
|
1315
|
+
if (!item) return IDENTITY_MATRIX;
|
|
1316
|
+
const matrix = multiplyMatrix(item.parent && depth < MAX_DEPTH && lookup(item.parent) ? matrixOf(item.parent, depth + 1) : IDENTITY_MATRIX, localMatrixOf(id));
|
|
1317
|
+
matrices.set(id, matrix);
|
|
1318
|
+
return matrix;
|
|
1319
|
+
}
|
|
1320
|
+
function localMatrixOf(id) {
|
|
1321
|
+
const item = lookup(id);
|
|
1322
|
+
if (!item) return IDENTITY_MATRIX;
|
|
1323
|
+
if (item.type === "arrow") return translate(item.position);
|
|
1324
|
+
const box = boxOf(id);
|
|
1325
|
+
const scale = scaleVector(item.scale);
|
|
1326
|
+
const radians = item.rotation * Math.PI / 180;
|
|
1327
|
+
const cos = Math.cos(radians);
|
|
1328
|
+
const sin = Math.sin(radians);
|
|
1329
|
+
const ox = box.x + item.origin.x * box.width;
|
|
1330
|
+
const oy = box.y + item.origin.y * box.height;
|
|
1331
|
+
const a = cos * scale.x;
|
|
1332
|
+
const b = sin * scale.x;
|
|
1333
|
+
const c = -sin * scale.y;
|
|
1334
|
+
const d = cos * scale.y;
|
|
1335
|
+
return [
|
|
1336
|
+
a,
|
|
1337
|
+
b,
|
|
1338
|
+
c,
|
|
1339
|
+
d,
|
|
1340
|
+
item.position.x + ox - (a * ox + c * oy),
|
|
1341
|
+
item.position.y + oy - (b * ox + d * oy)
|
|
1342
|
+
];
|
|
1343
|
+
}
|
|
1344
|
+
function boxOf(id, depth = 0) {
|
|
1345
|
+
const cached = boxes.get(id);
|
|
1346
|
+
if (cached) return cached;
|
|
1347
|
+
const item = lookup(id);
|
|
1348
|
+
let box;
|
|
1349
|
+
if (!item) box = {
|
|
1350
|
+
x: 0,
|
|
1351
|
+
y: 0,
|
|
1352
|
+
width: 1,
|
|
1353
|
+
height: 1
|
|
1354
|
+
};
|
|
1355
|
+
else if ("size" in item && item.size) box = {
|
|
1356
|
+
x: 0,
|
|
1357
|
+
y: 0,
|
|
1358
|
+
width: item.size.width,
|
|
1359
|
+
height: item.size.height
|
|
1360
|
+
};
|
|
1361
|
+
else if (item.type === "text") {
|
|
1362
|
+
const layout = layoutBoardText(item.props);
|
|
1363
|
+
box = {
|
|
1364
|
+
x: 0,
|
|
1365
|
+
y: 0,
|
|
1366
|
+
width: layout.width,
|
|
1367
|
+
height: layout.height
|
|
1368
|
+
};
|
|
1369
|
+
} else if (item.type === "draw") box = drawPointsBounds(item.props.points, item.style.strokeWidth ?? 4);
|
|
1370
|
+
else if (item.type === "arrow") {
|
|
1371
|
+
const props = item.props;
|
|
1372
|
+
const toLocal = invertMatrix(multiplyMatrix(parentOf(item, depth), translate(item.position)));
|
|
1373
|
+
const start = isArrowBinding(props.start) ? applyMatrix(toLocal, resolveBoundEnd(item, props.start, props.end, depth)) : props.start;
|
|
1374
|
+
const end = isArrowBinding(props.end) ? applyMatrix(toLocal, resolveBoundEnd(item, props.end, props.start, depth)) : props.end;
|
|
1375
|
+
const points = [
|
|
1376
|
+
start,
|
|
1377
|
+
end,
|
|
1378
|
+
...props.waypoints
|
|
1379
|
+
];
|
|
1380
|
+
if (props.bend) points.push(bendControl(start, end, props.bend));
|
|
1381
|
+
const rect = pointsRect(points);
|
|
1382
|
+
const pad = Math.max(8, (item.style.strokeWidth ?? 2.5) * 2);
|
|
1383
|
+
box = {
|
|
1384
|
+
x: rect.x - pad,
|
|
1385
|
+
y: rect.y - pad,
|
|
1386
|
+
width: rect.width + pad * 2,
|
|
1387
|
+
height: rect.height + pad * 2
|
|
1388
|
+
};
|
|
1389
|
+
} else box = {
|
|
1390
|
+
x: 0,
|
|
1391
|
+
y: 0,
|
|
1392
|
+
...boardDefaultSize(item.type)
|
|
1393
|
+
};
|
|
1394
|
+
boxes.set(id, box);
|
|
1395
|
+
return box;
|
|
1396
|
+
}
|
|
1397
|
+
function parentOf(item, depth) {
|
|
1398
|
+
return item.parent && depth < MAX_DEPTH && lookup(item.parent) ? matrixOf(item.parent, depth + 1) : IDENTITY_MATRIX;
|
|
1399
|
+
}
|
|
1400
|
+
function resolveBoundEnd(arrow, end, other, depth) {
|
|
1401
|
+
const target = lookup(end.item);
|
|
1402
|
+
const arrowSpace = multiplyMatrix(parentOf(arrow, depth), translate(arrow.position));
|
|
1403
|
+
if (!target || target.type === "arrow" || depth >= MAX_DEPTH) return applyMatrix(arrowSpace, {
|
|
1404
|
+
x: 0,
|
|
1405
|
+
y: 0
|
|
1406
|
+
});
|
|
1407
|
+
const frame = frameOf(end.item, depth + 1);
|
|
1408
|
+
const toward = isArrowBinding(other) ? lookup(other.item) && lookup(other.item)?.type !== "arrow" ? center(frameOf(other.item, depth + 1)) : center(frame) : applyMatrix(arrowSpace, other);
|
|
1409
|
+
return anchorPoint(frame, end.anchor, toward);
|
|
1410
|
+
}
|
|
1411
|
+
function frameOf(id, depth = 0) {
|
|
1412
|
+
boxOf(id, depth);
|
|
1413
|
+
const box = boxes.get(id);
|
|
1414
|
+
const matrix = matrixOf(id, depth);
|
|
1415
|
+
const [a, b, c, d] = matrix;
|
|
1416
|
+
const centerPoint = applyMatrix(matrix, {
|
|
1417
|
+
x: box.x + box.width / 2,
|
|
1418
|
+
y: box.y + box.height / 2
|
|
1419
|
+
});
|
|
1420
|
+
const width = box.width * Math.hypot(a, b);
|
|
1421
|
+
const height = box.height * Math.hypot(c, d);
|
|
1422
|
+
const { rotation, mirrored } = matrixRotation(matrix);
|
|
1423
|
+
return {
|
|
1424
|
+
x: centerPoint.x - width / 2,
|
|
1425
|
+
y: centerPoint.y - height / 2,
|
|
1426
|
+
width,
|
|
1427
|
+
height,
|
|
1428
|
+
rotation,
|
|
1429
|
+
...mirrored ? { mirrored } : {}
|
|
1430
|
+
};
|
|
1431
|
+
}
|
|
1432
|
+
function boundsOf(id) {
|
|
1433
|
+
const cached = bounds.get(id);
|
|
1434
|
+
if (cached) return cached;
|
|
1435
|
+
const box = boxOf(id);
|
|
1436
|
+
const matrix = matrixOf(id);
|
|
1437
|
+
const rect = pointsRect([
|
|
1438
|
+
applyMatrix(matrix, {
|
|
1439
|
+
x: box.x,
|
|
1440
|
+
y: box.y
|
|
1441
|
+
}),
|
|
1442
|
+
applyMatrix(matrix, {
|
|
1443
|
+
x: box.x + box.width,
|
|
1444
|
+
y: box.y
|
|
1445
|
+
}),
|
|
1446
|
+
applyMatrix(matrix, {
|
|
1447
|
+
x: box.x + box.width,
|
|
1448
|
+
y: box.y + box.height
|
|
1449
|
+
}),
|
|
1450
|
+
applyMatrix(matrix, {
|
|
1451
|
+
x: box.x,
|
|
1452
|
+
y: box.y + box.height
|
|
1453
|
+
})
|
|
1454
|
+
]);
|
|
1455
|
+
bounds.set(id, rect);
|
|
1456
|
+
return rect;
|
|
1457
|
+
}
|
|
1458
|
+
function setLookup(nextLookup) {
|
|
1459
|
+
lookup = nextLookup;
|
|
1460
|
+
}
|
|
1461
|
+
function invalidate(ids) {
|
|
1462
|
+
if (!ids) {
|
|
1463
|
+
boxes.clear();
|
|
1464
|
+
matrices.clear();
|
|
1465
|
+
bounds.clear();
|
|
1466
|
+
return;
|
|
1467
|
+
}
|
|
1468
|
+
const queue = [...ids];
|
|
1469
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1470
|
+
while (queue.length) {
|
|
1471
|
+
const id = queue.pop();
|
|
1472
|
+
if (seen.has(id)) continue;
|
|
1473
|
+
seen.add(id);
|
|
1474
|
+
boxes.delete(id);
|
|
1475
|
+
matrices.delete(id);
|
|
1476
|
+
bounds.delete(id);
|
|
1477
|
+
if (dependents) for (const next of dependents(id)) queue.push(next);
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
return {
|
|
1481
|
+
has: (id) => lookup(id) !== void 0,
|
|
1482
|
+
box: (id) => boxOf(id),
|
|
1483
|
+
matrix: (id) => matrixOf(id),
|
|
1484
|
+
localMatrix: (id) => localMatrixOf(id),
|
|
1485
|
+
parentMatrix: (id) => {
|
|
1486
|
+
const item = lookup(id);
|
|
1487
|
+
return item ? parentOf(item, 0) : IDENTITY_MATRIX;
|
|
1488
|
+
},
|
|
1489
|
+
bounds: boundsOf,
|
|
1490
|
+
frame: (id) => frameOf(id),
|
|
1491
|
+
arrowEnd: (id, which) => {
|
|
1492
|
+
const item = lookup(id);
|
|
1493
|
+
if (item?.type !== "arrow") return {
|
|
1494
|
+
x: 0,
|
|
1495
|
+
y: 0
|
|
1496
|
+
};
|
|
1497
|
+
const arrow = item;
|
|
1498
|
+
const [end, other] = which === "start" ? [arrow.props.start, arrow.props.end] : [arrow.props.end, arrow.props.start];
|
|
1499
|
+
return isArrowBinding(end) ? resolveBoundEnd(arrow, end, other, 0) : applyMatrix(matrixOf(id), end);
|
|
1500
|
+
},
|
|
1501
|
+
invalidate,
|
|
1502
|
+
setLookup
|
|
1503
|
+
};
|
|
1504
|
+
}
|
|
1505
|
+
function translate(point) {
|
|
1506
|
+
return [
|
|
1507
|
+
1,
|
|
1508
|
+
0,
|
|
1509
|
+
0,
|
|
1510
|
+
1,
|
|
1511
|
+
point.x,
|
|
1512
|
+
point.y
|
|
1513
|
+
];
|
|
1514
|
+
}
|
|
1515
|
+
function center(frame) {
|
|
1516
|
+
return {
|
|
1517
|
+
x: frame.x + frame.width / 2,
|
|
1518
|
+
y: frame.y + frame.height / 2
|
|
1519
|
+
};
|
|
1520
|
+
}
|
|
1521
|
+
function rotateAround(point, pivot, degrees) {
|
|
1522
|
+
if (!degrees) return point;
|
|
1523
|
+
const radians = degrees * Math.PI / 180;
|
|
1524
|
+
const cos = Math.cos(radians);
|
|
1525
|
+
const sin = Math.sin(radians);
|
|
1526
|
+
const dx = point.x - pivot.x;
|
|
1527
|
+
const dy = point.y - pivot.y;
|
|
1528
|
+
return {
|
|
1529
|
+
x: pivot.x + dx * cos - dy * sin,
|
|
1530
|
+
y: pivot.y + dx * sin + dy * cos
|
|
1531
|
+
};
|
|
1532
|
+
}
|
|
1533
|
+
function framePoint(frame, nx, ny) {
|
|
1534
|
+
return rotateAround({
|
|
1535
|
+
x: frame.x + nx * frame.width,
|
|
1536
|
+
y: frame.y + ny * frame.height
|
|
1537
|
+
}, center(frame), frame.rotation);
|
|
1538
|
+
}
|
|
1539
|
+
function autoAnchorSide(frame, toward) {
|
|
1540
|
+
const local = rotateAround(toward, center(frame), -frame.rotation);
|
|
1541
|
+
const c = center(frame);
|
|
1542
|
+
const dx = (local.x - c.x) / Math.max(frame.width / 2, 1e-4);
|
|
1543
|
+
const dy = (local.y - c.y) / Math.max(frame.height / 2, 1e-4);
|
|
1544
|
+
if (Math.abs(dx) >= Math.abs(dy)) return dx >= 0 ? "right" : "left";
|
|
1545
|
+
return dy >= 0 ? "bottom" : "top";
|
|
1546
|
+
}
|
|
1547
|
+
function sideAnchor(side, offset) {
|
|
1548
|
+
switch (side) {
|
|
1549
|
+
case "top": return {
|
|
1550
|
+
x: offset,
|
|
1551
|
+
y: 0
|
|
1552
|
+
};
|
|
1553
|
+
case "bottom": return {
|
|
1554
|
+
x: offset,
|
|
1555
|
+
y: 1
|
|
1556
|
+
};
|
|
1557
|
+
case "left": return {
|
|
1558
|
+
x: 0,
|
|
1559
|
+
y: offset
|
|
1560
|
+
};
|
|
1561
|
+
default: return {
|
|
1562
|
+
x: 1,
|
|
1563
|
+
y: offset
|
|
1564
|
+
};
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
function anchorPoint(frame, anchor, toward) {
|
|
1568
|
+
if (anchor === "auto") {
|
|
1569
|
+
const normalized = sideAnchor(autoAnchorSide(frame, toward), .5);
|
|
1570
|
+
return framePoint(frame, normalized.x, normalized.y);
|
|
1571
|
+
}
|
|
1572
|
+
if ("side" in anchor) {
|
|
1573
|
+
const normalized = sideAnchor(anchor.side, anchor.offset);
|
|
1574
|
+
return framePoint(frame, normalized.x, normalized.y);
|
|
1575
|
+
}
|
|
1576
|
+
return framePoint(frame, anchor.x, anchor.y);
|
|
1577
|
+
}
|
|
1578
|
+
//#endregion
|
|
1579
|
+
//#region ../protocol/src/board-patch.ts
|
|
1580
|
+
function slot(map, key) {
|
|
1581
|
+
let value = map[key];
|
|
1582
|
+
if (!value) {
|
|
1583
|
+
value = {};
|
|
1584
|
+
map[key] = value;
|
|
1585
|
+
}
|
|
1586
|
+
return value;
|
|
1587
|
+
}
|
|
1588
|
+
function emptyDelta() {
|
|
1589
|
+
return {
|
|
1590
|
+
items: {},
|
|
1591
|
+
animations: {},
|
|
1592
|
+
tracks: {}
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
function withoutEmpty(value) {
|
|
1596
|
+
for (const [key, entry] of Object.entries(value)) if (entry === void 0 || isRecord(entry) && Object.keys(entry).length === 0) delete value[key];
|
|
1597
|
+
return value;
|
|
1598
|
+
}
|
|
1599
|
+
function isRecord(value) {
|
|
1600
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
1601
|
+
}
|
|
1602
|
+
function mergePatch(target, patch) {
|
|
1603
|
+
if (!isRecord(patch)) return patch;
|
|
1604
|
+
const result = isRecord(target) ? { ...target } : {};
|
|
1605
|
+
for (const [key, value] of Object.entries(patch)) if (value === null) delete result[key];
|
|
1606
|
+
else result[key] = mergePatch(result[key], value);
|
|
1607
|
+
return result;
|
|
1608
|
+
}
|
|
1609
|
+
function diffMergePatch(before, after) {
|
|
1610
|
+
if (boardJsonEquals(before, after)) return void 0;
|
|
1611
|
+
if (after === void 0) return null;
|
|
1612
|
+
if (!isRecord(before) || !isRecord(after)) return after;
|
|
1613
|
+
const patch = {};
|
|
1614
|
+
for (const key of /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])) {
|
|
1615
|
+
const value = diffMergePatch(before[key], after[key]);
|
|
1616
|
+
if (value !== void 0) patch[key] = value;
|
|
1617
|
+
}
|
|
1618
|
+
return patch;
|
|
1619
|
+
}
|
|
1620
|
+
function def(schema) {
|
|
1621
|
+
return schema._zod.def;
|
|
1622
|
+
}
|
|
1623
|
+
function unwrap(schema) {
|
|
1624
|
+
let current = schema;
|
|
1625
|
+
for (let guard = 0; guard < 16; guard += 1) {
|
|
1626
|
+
const d = def(current);
|
|
1627
|
+
if (d.type === "optional" || d.type === "default" || d.type === "nullable" || d.type === "readonly" || d.type === "prefault") current = d.innerType;
|
|
1628
|
+
else if (d.type === "pipe") current = d.in;
|
|
1629
|
+
else return current;
|
|
1630
|
+
}
|
|
1631
|
+
return current;
|
|
1632
|
+
}
|
|
1633
|
+
function unwrapObjectShape(schema) {
|
|
1634
|
+
const d = def(unwrap(schema));
|
|
1635
|
+
return d.type === "object" ? d.shape : null;
|
|
1636
|
+
}
|
|
1637
|
+
function schemaAtPath(schema, path) {
|
|
1638
|
+
let current = schema;
|
|
1639
|
+
for (const segment of path) {
|
|
1640
|
+
const d = def(unwrap(current));
|
|
1641
|
+
if (d.type === "object") {
|
|
1642
|
+
const shape = d.shape;
|
|
1643
|
+
if (!Object.hasOwn(shape, segment)) return null;
|
|
1644
|
+
current = shape[segment];
|
|
1645
|
+
} else if (d.type === "record") current = d.valueType;
|
|
1646
|
+
else if (d.type === "union") {
|
|
1647
|
+
const branch = d.options.find((option) => unwrapObjectShape(option)?.[segment]);
|
|
1648
|
+
if (!branch) return null;
|
|
1649
|
+
current = unwrapObjectShape(branch)[segment];
|
|
1650
|
+
} else return null;
|
|
1651
|
+
}
|
|
1652
|
+
return current;
|
|
1653
|
+
}
|
|
1654
|
+
const NOT_ANIMATABLE = /* @__PURE__ */ new Set([
|
|
1655
|
+
"type",
|
|
1656
|
+
"parent",
|
|
1657
|
+
"z",
|
|
1658
|
+
"locked",
|
|
1659
|
+
"autoplay",
|
|
1660
|
+
"metadata",
|
|
1661
|
+
"script"
|
|
1662
|
+
]);
|
|
1663
|
+
const CAMERA_PROPERTIES = {
|
|
1664
|
+
focus: {
|
|
1665
|
+
kind: "discrete",
|
|
1666
|
+
schema: union([string().min(1), object({
|
|
1667
|
+
x: number().finite(),
|
|
1668
|
+
y: number().finite(),
|
|
1669
|
+
width: number().finite().positive(),
|
|
1670
|
+
height: number().finite().positive()
|
|
1671
|
+
}).strict()]).describe("Item id or world-space rect to fit with 48 px padding; holds until the next focus keyframe.")
|
|
1672
|
+
},
|
|
1673
|
+
zoom: {
|
|
1674
|
+
kind: "number",
|
|
1675
|
+
schema: number().finite().positive().describe("Pixels per world unit; overrides the zoom computed by focus."),
|
|
1676
|
+
multiplicative: true
|
|
1677
|
+
},
|
|
1678
|
+
center: {
|
|
1679
|
+
kind: "vec2",
|
|
1680
|
+
schema: BoardVec2Schema.describe("World-space viewport center; overrides focus positioning using the resolved zoom.")
|
|
1681
|
+
},
|
|
1682
|
+
shake: {
|
|
1683
|
+
kind: "number",
|
|
1684
|
+
schema: number().finite().nonnegative().describe("Shake amplitude in screen pixels, applied after focus, zoom and center.")
|
|
1685
|
+
}
|
|
1686
|
+
};
|
|
1687
|
+
const ANIMATION_PROPERTIES = { time: {
|
|
1688
|
+
kind: "number",
|
|
1689
|
+
schema: number().finite().nonnegative()
|
|
1690
|
+
} };
|
|
1691
|
+
const SCRIPT_PARAMETER = {
|
|
1692
|
+
kind: "discrete",
|
|
1693
|
+
schema: json().describe("Numbers blend and colors mix between keyframes; other values step.")
|
|
1694
|
+
};
|
|
1695
|
+
function kindOf(schema, path) {
|
|
1696
|
+
const leaf = path[path.length - 1];
|
|
1697
|
+
if (path.length === 1 && leaf === "scale") return "scale";
|
|
1698
|
+
if (schema === BoardColorSchema || unwrap(schema) === BoardColorSchema) return "color";
|
|
1699
|
+
if (def(unwrap(schema)).type === "number") return "number";
|
|
1700
|
+
const shape = unwrapObjectShape(schema);
|
|
1701
|
+
if (shape && Object.keys(shape).length === 2 && "x" in shape && "y" in shape) return "vec2";
|
|
1702
|
+
return "discrete";
|
|
1703
|
+
}
|
|
1704
|
+
function resolveBoardProperty(targetType, property) {
|
|
1705
|
+
if (targetType === "camera") {
|
|
1706
|
+
const spec = CAMERA_PROPERTIES[property];
|
|
1707
|
+
return spec ? {
|
|
1708
|
+
ok: true,
|
|
1709
|
+
spec
|
|
1710
|
+
} : {
|
|
1711
|
+
ok: false,
|
|
1712
|
+
message: `camera has no property ${property}; expected ${Object.keys(CAMERA_PROPERTIES).join(", ")}`
|
|
1713
|
+
};
|
|
1714
|
+
}
|
|
1715
|
+
if (targetType === "animation") {
|
|
1716
|
+
const spec = ANIMATION_PROPERTIES[property];
|
|
1717
|
+
return spec ? {
|
|
1718
|
+
ok: true,
|
|
1719
|
+
spec
|
|
1720
|
+
} : {
|
|
1721
|
+
ok: false,
|
|
1722
|
+
message: `animations are driven through time`
|
|
1723
|
+
};
|
|
1724
|
+
}
|
|
1725
|
+
if (targetType === "script") return /^params\.[^.]+$/.test(property) ? {
|
|
1726
|
+
ok: true,
|
|
1727
|
+
spec: SCRIPT_PARAMETER
|
|
1728
|
+
} : {
|
|
1729
|
+
ok: false,
|
|
1730
|
+
message: `Board scripts animate params.<name>, not ${property}`
|
|
1731
|
+
};
|
|
1732
|
+
if (/^script\.params\.[^.]+$/.test(property)) return {
|
|
1733
|
+
ok: true,
|
|
1734
|
+
spec: SCRIPT_PARAMETER
|
|
1735
|
+
};
|
|
1736
|
+
const path = property.split(".");
|
|
1737
|
+
if (path.some((segment) => !segment) || NOT_ANIMATABLE.has(path[0])) return {
|
|
1738
|
+
ok: false,
|
|
1739
|
+
message: `${property} cannot be animated`
|
|
1740
|
+
};
|
|
1741
|
+
const schema = boardItemSchema(targetType);
|
|
1742
|
+
if (!schema) return {
|
|
1743
|
+
ok: false,
|
|
1744
|
+
message: `unknown item type ${targetType}`
|
|
1745
|
+
};
|
|
1746
|
+
if (!isBuiltinItemType(targetType) && path[0] === "props") return {
|
|
1747
|
+
ok: true,
|
|
1748
|
+
spec: {
|
|
1749
|
+
kind: "discrete",
|
|
1750
|
+
schema: unknown()
|
|
1751
|
+
}
|
|
1752
|
+
};
|
|
1753
|
+
const leaf = schemaAtPath(schema, path);
|
|
1754
|
+
if (!leaf) return {
|
|
1755
|
+
ok: false,
|
|
1756
|
+
message: `${targetType} has no property ${property}`
|
|
1757
|
+
};
|
|
1758
|
+
const kind = kindOf(leaf, path);
|
|
1759
|
+
return {
|
|
1760
|
+
ok: true,
|
|
1761
|
+
spec: {
|
|
1762
|
+
kind,
|
|
1763
|
+
schema: unwrap(leaf),
|
|
1764
|
+
...property === "opacity" || kind === "scale" ? { multiplicative: true } : {}
|
|
1765
|
+
}
|
|
1766
|
+
};
|
|
1767
|
+
}
|
|
1768
|
+
function listBoardProperties(targetType) {
|
|
1769
|
+
if (targetType === "camera") return Object.entries(CAMERA_PROPERTIES).map(([property, spec]) => ({
|
|
1770
|
+
property,
|
|
1771
|
+
kind: spec.kind
|
|
1772
|
+
}));
|
|
1773
|
+
if (targetType === "animation") return [{
|
|
1774
|
+
property: "time",
|
|
1775
|
+
kind: "number"
|
|
1776
|
+
}];
|
|
1777
|
+
const schema = boardItemSchema(targetType);
|
|
1778
|
+
const shape = schema ? unwrapObjectShape(schema) : null;
|
|
1779
|
+
const result = [];
|
|
1780
|
+
const visit = (field, path) => {
|
|
1781
|
+
const kind = kindOf(field, path);
|
|
1782
|
+
if (kind !== "discrete") {
|
|
1783
|
+
result.push({
|
|
1784
|
+
property: path.join("."),
|
|
1785
|
+
kind
|
|
1786
|
+
});
|
|
1787
|
+
if (kind === "vec2" || kind === "scale") return;
|
|
1788
|
+
}
|
|
1789
|
+
const nested = unwrapObjectShape(field);
|
|
1790
|
+
if (nested && kind !== "color") for (const [key, child] of Object.entries(nested)) visit(child, [...path, key]);
|
|
1791
|
+
else if (kind === "discrete") result.push({
|
|
1792
|
+
property: path.join("."),
|
|
1793
|
+
kind
|
|
1794
|
+
});
|
|
1795
|
+
};
|
|
1796
|
+
for (const [key, field] of Object.entries(shape ?? {})) {
|
|
1797
|
+
if (NOT_ANIMATABLE.has(key) || key === "type") continue;
|
|
1798
|
+
visit(field, [key]);
|
|
1799
|
+
}
|
|
1800
|
+
return result;
|
|
1801
|
+
}
|
|
1802
|
+
function lastKeyframeAt(trackPatches) {
|
|
1803
|
+
let end = 0;
|
|
1804
|
+
for (const track of trackPatches) {
|
|
1805
|
+
const keyframes = track?.keyframes;
|
|
1806
|
+
if (!Array.isArray(keyframes)) continue;
|
|
1807
|
+
for (const keyframe of keyframes) {
|
|
1808
|
+
const at = keyframe?.at;
|
|
1809
|
+
if (typeof at === "number" && Number.isFinite(at)) end = Math.max(end, at);
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
return end > 0 ? end : void 0;
|
|
1813
|
+
}
|
|
1814
|
+
function trackReferences(track) {
|
|
1815
|
+
const refs = /* @__PURE__ */ new Set([track.target]);
|
|
1816
|
+
if (track.target === "camera" && track.property === "focus") {
|
|
1817
|
+
for (const keyframe of track.keyframes) if (typeof keyframe.value === "string") refs.add(keyframe.value);
|
|
1818
|
+
}
|
|
1819
|
+
refs.delete(BOARD_CAMERA_TARGET);
|
|
1820
|
+
return [...refs];
|
|
1821
|
+
}
|
|
1822
|
+
function pruneBoardTrack(track, deleted) {
|
|
1823
|
+
if (deleted.has(track.target)) return null;
|
|
1824
|
+
if (track.target !== "camera" || track.property !== "focus") return track;
|
|
1825
|
+
const keyframes = track.keyframes.filter((entry) => typeof entry.value !== "string" || !deleted.has(entry.value));
|
|
1826
|
+
if (keyframes.length === track.keyframes.length) return track;
|
|
1827
|
+
return keyframes.length ? {
|
|
1828
|
+
...track,
|
|
1829
|
+
keyframes
|
|
1830
|
+
} : null;
|
|
1831
|
+
}
|
|
1832
|
+
function error(path, code, message) {
|
|
1833
|
+
return {
|
|
1834
|
+
severity: "error",
|
|
1835
|
+
code,
|
|
1836
|
+
path,
|
|
1837
|
+
message
|
|
1838
|
+
};
|
|
1839
|
+
}
|
|
1840
|
+
function stripId(value) {
|
|
1841
|
+
if (!("id" in value)) return value;
|
|
1842
|
+
const { id: _id, ...rest } = value;
|
|
1843
|
+
return rest;
|
|
1844
|
+
}
|
|
1845
|
+
function applyBoardPatch(state, input, options = {}) {
|
|
1846
|
+
const parsedPatch = BoardPatchSchema.safeParse(input);
|
|
1847
|
+
if (!parsedPatch.success) return {
|
|
1848
|
+
ok: false,
|
|
1849
|
+
diagnostics: parsedPatch.error.issues.map((issue) => error(issue.path.map(String).join("."), "INVALID_PATCH", issue.message))
|
|
1850
|
+
};
|
|
1851
|
+
const patch = parsedPatch.data;
|
|
1852
|
+
const diagnostics = [];
|
|
1853
|
+
const keep = (existing) => options.keepUnknown ? keepAllBoardFields : existing ? keepBoardFieldsOf(existing) : void 0;
|
|
1854
|
+
const nextItems = /* @__PURE__ */ new Map();
|
|
1855
|
+
const nextAnimations = /* @__PURE__ */ new Map();
|
|
1856
|
+
const nextTracks = /* @__PURE__ */ new Map();
|
|
1857
|
+
let nextSettings;
|
|
1858
|
+
const item = (id) => nextItems.has(id) ? nextItems.get(id) ?? void 0 : state.item(id);
|
|
1859
|
+
const animation = (id) => nextAnimations.has(id) ? nextAnimations.get(id) ?? void 0 : state.animation(id);
|
|
1860
|
+
const setTrack = (animationId, trackId, value) => {
|
|
1861
|
+
const tracks = nextTracks.get(animationId) ?? /* @__PURE__ */ new Map();
|
|
1862
|
+
tracks.set(trackId, value);
|
|
1863
|
+
nextTracks.set(animationId, tracks);
|
|
1864
|
+
};
|
|
1865
|
+
const track = (animationId, trackId) => {
|
|
1866
|
+
const pending = nextTracks.get(animationId);
|
|
1867
|
+
if (pending?.has(trackId)) return pending.get(trackId) ?? void 0;
|
|
1868
|
+
return state.track(animationId, trackId);
|
|
1869
|
+
};
|
|
1870
|
+
if (patch.board !== void 0) {
|
|
1871
|
+
const merged = patch.board === null ? {} : mergePatch(state.settings(), patch.board);
|
|
1872
|
+
const parsed = parseKeepingBoardFields(BoardSettingsSchema, merged, keep(state.settings()));
|
|
1873
|
+
if (parsed.success) nextSettings = parsed.data;
|
|
1874
|
+
else for (const issue of parsed.error.issues) diagnostics.push(error(["board", ...issue.path.map(String)].join("."), "INVALID_BOARD", issue.message));
|
|
1875
|
+
}
|
|
1876
|
+
const zByParent = /* @__PURE__ */ new Map();
|
|
1877
|
+
for (const [id, value] of Object.entries(patch.items ?? {})) {
|
|
1878
|
+
if (value === null) {
|
|
1879
|
+
if (state.item(id)) nextItems.set(id, null);
|
|
1880
|
+
continue;
|
|
1881
|
+
}
|
|
1882
|
+
const current = state.item(id);
|
|
1883
|
+
const body = stripId(value);
|
|
1884
|
+
const replacing = !current || typeof body.type === "string" && body.type !== current.type;
|
|
1885
|
+
const candidate = replacing ? { ...body } : mergePatch(current, body);
|
|
1886
|
+
if (candidate.z === void 0) {
|
|
1887
|
+
const parent = typeof candidate.parent === "string" ? candidate.parent : void 0;
|
|
1888
|
+
const key = parent ?? "";
|
|
1889
|
+
const top = zByParent.get(key) ?? state.maxZ(parent);
|
|
1890
|
+
candidate.z = current?.z ?? top + 1;
|
|
1891
|
+
if (!current) zByParent.set(key, top + 1);
|
|
1892
|
+
}
|
|
1893
|
+
const parsed = parseBoardItem(candidate, `items.${id}`, keep(replacing ? void 0 : current));
|
|
1894
|
+
if (!parsed.ok) {
|
|
1895
|
+
diagnostics.push(...parsed.diagnostics);
|
|
1896
|
+
continue;
|
|
1897
|
+
}
|
|
1898
|
+
if (current && boardJsonEquals(current, parsed.item)) continue;
|
|
1899
|
+
nextItems.set(id, parsed.item);
|
|
1900
|
+
}
|
|
1901
|
+
for (const [id, value] of Object.entries(patch.animations ?? {})) {
|
|
1902
|
+
if (value === null) {
|
|
1903
|
+
if (!state.animation(id)) continue;
|
|
1904
|
+
nextAnimations.set(id, null);
|
|
1905
|
+
for (const trackId of state.trackIds(id)) setTrack(id, trackId, null);
|
|
1906
|
+
continue;
|
|
1907
|
+
}
|
|
1908
|
+
const { tracks, ...headerPatch } = stripId(value);
|
|
1909
|
+
if (state.item(id) || nextItems.get(id)) {
|
|
1910
|
+
diagnostics.push(error(`animations.${id}`, "ID_CONFLICT", `${id} is already an item id`));
|
|
1911
|
+
continue;
|
|
1912
|
+
}
|
|
1913
|
+
const current = state.animation(id);
|
|
1914
|
+
if (!current || Object.keys(headerPatch).length > 0) {
|
|
1915
|
+
const header = current ? mergePatch(current, headerPatch) : {
|
|
1916
|
+
...headerPatch,
|
|
1917
|
+
...headerPatch.duration === void 0 ? { duration: lastKeyframeAt([...Object.values(tracks ?? {}), ...state.trackIds(id).map((trackId) => state.track(id, trackId))]) } : {}
|
|
1918
|
+
};
|
|
1919
|
+
const parsed = parseKeepingBoardFields(BoardAnimationHeaderSchema, header, keep(current));
|
|
1920
|
+
if (!parsed.success) {
|
|
1921
|
+
for (const issue of parsed.error.issues) diagnostics.push(error([
|
|
1922
|
+
"animations",
|
|
1923
|
+
id,
|
|
1924
|
+
...issue.path.map(String)
|
|
1925
|
+
].join("."), "INVALID_ANIMATION", issue.message));
|
|
1926
|
+
continue;
|
|
1927
|
+
}
|
|
1928
|
+
if (!current || !boardJsonEquals(current, parsed.data)) nextAnimations.set(id, parsed.data);
|
|
1929
|
+
}
|
|
1930
|
+
for (const [trackId, trackPatch] of Object.entries(tracks ?? {})) {
|
|
1931
|
+
const existing = state.track(id, trackId);
|
|
1932
|
+
if (trackPatch === null) {
|
|
1933
|
+
if (existing) setTrack(id, trackId, null);
|
|
1934
|
+
continue;
|
|
1935
|
+
}
|
|
1936
|
+
const parsed = parseKeepingBoardFields(BoardTrackSchema, existing ? mergePatch(existing, trackPatch) : trackPatch, keep(existing));
|
|
1937
|
+
if (!parsed.success) {
|
|
1938
|
+
for (const issue of parsed.error.issues) diagnostics.push(error([
|
|
1939
|
+
"animations",
|
|
1940
|
+
id,
|
|
1941
|
+
"tracks",
|
|
1942
|
+
trackId,
|
|
1943
|
+
...issue.path.map(String)
|
|
1944
|
+
].join("."), "INVALID_TRACK", issue.message));
|
|
1945
|
+
continue;
|
|
1946
|
+
}
|
|
1947
|
+
if (!existing || !boardJsonEquals(existing, parsed.data)) setTrack(id, trackId, parsed.data);
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
for (const id of nextItems.keys()) if (nextItems.get(id) && animation(id)) diagnostics.push(error(`items.${id}`, "ID_CONFLICT", `${id} is already an animation id`));
|
|
1951
|
+
const scripts = (nextSettings ?? state.settings()).scripts ?? {};
|
|
1952
|
+
const script = (id) => Object.hasOwn(scripts, id);
|
|
1953
|
+
for (const id of Object.keys(scripts)) {
|
|
1954
|
+
const taken = item(id) ? "an item" : animation(id) ? "an animation" : null;
|
|
1955
|
+
if (!taken) continue;
|
|
1956
|
+
const path = nextItems.get(id) ? `items.${id}` : nextAnimations.get(id) ? `animations.${id}` : `board.scripts.${id}`;
|
|
1957
|
+
diagnostics.push(error(path, "ID_CONFLICT", path.startsWith("board") ? `${id} is already ${taken} id` : `${id} is already a Board script id`));
|
|
1958
|
+
}
|
|
1959
|
+
if (diagnostics.length) return {
|
|
1960
|
+
ok: false,
|
|
1961
|
+
diagnostics
|
|
1962
|
+
};
|
|
1963
|
+
const deletedItems = [...nextItems].filter(([, value]) => value === null).map(([id]) => id);
|
|
1964
|
+
const deletionLayout = createBoardLayout((id) => item(id) ?? state.item(id));
|
|
1965
|
+
const pendingDeletes = [...deletedItems];
|
|
1966
|
+
while (pendingDeletes.length) {
|
|
1967
|
+
const id = pendingDeletes.pop();
|
|
1968
|
+
for (const child of state.children(id)) {
|
|
1969
|
+
if (nextItems.has(child) && nextItems.get(child)?.parent !== id) continue;
|
|
1970
|
+
if (options.cascade) {
|
|
1971
|
+
if (nextItems.get(child) !== null) {
|
|
1972
|
+
nextItems.set(child, null);
|
|
1973
|
+
pendingDeletes.push(child);
|
|
1974
|
+
}
|
|
1975
|
+
} else diagnostics.push(error(`items.${id}`, "ITEM_REFERENCED", `${id} still has child ${child}; delete it too or use cascade`));
|
|
1976
|
+
}
|
|
1977
|
+
for (const arrowId of state.binders(id)) {
|
|
1978
|
+
const arrow = item(arrowId);
|
|
1979
|
+
if (arrow?.type !== "arrow") continue;
|
|
1980
|
+
const props = { ...arrow.props };
|
|
1981
|
+
for (const which of ["start", "end"]) {
|
|
1982
|
+
const end = props[which];
|
|
1983
|
+
if (!isArrowBinding(end) || end.item !== id) continue;
|
|
1984
|
+
const world = options.resolveArrowEnd?.(arrowId, which) ?? deletionLayout.arrowEnd(arrowId, which);
|
|
1985
|
+
props[which] = applyMatrix(invertMatrix(deletionLayout.matrix(arrowId)), world);
|
|
1986
|
+
}
|
|
1987
|
+
nextItems.set(arrowId, {
|
|
1988
|
+
...arrow,
|
|
1989
|
+
props
|
|
1990
|
+
});
|
|
1991
|
+
}
|
|
1992
|
+
for (const ref of state.trackRefs(id)) {
|
|
1993
|
+
const current = track(ref.animation, ref.track);
|
|
1994
|
+
if (!current || !trackReferences(current).includes(id)) continue;
|
|
1995
|
+
if (options.cascade) setTrack(ref.animation, ref.track, pruneBoardTrack(current, /* @__PURE__ */ new Set([id])));
|
|
1996
|
+
else diagnostics.push(error(`items.${id}`, "ITEM_REFERENCED", `${id} is animated by ${ref.animation}.${ref.track}; delete the track or use cascade`));
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
for (const id of Object.keys(state.settings().scripts ?? {})) {
|
|
2000
|
+
if (script(id)) continue;
|
|
2001
|
+
for (const ref of state.trackRefs(id)) {
|
|
2002
|
+
if (track(ref.animation, ref.track)?.target !== id) continue;
|
|
2003
|
+
if (options.cascade) setTrack(ref.animation, ref.track, null);
|
|
2004
|
+
else diagnostics.push(error(`board.scripts.${id}`, "SCRIPT_REFERENCED", `${id} is animated by ${ref.animation}.${ref.track}; delete the track or use cascade`));
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
for (const [id, value] of nextAnimations) {
|
|
2008
|
+
if (value !== null) continue;
|
|
2009
|
+
for (const ref of state.trackRefs(id)) {
|
|
2010
|
+
if (ref.animation === id || track(ref.animation, ref.track) === void 0) continue;
|
|
2011
|
+
if (options.cascade) setTrack(ref.animation, ref.track, null);
|
|
2012
|
+
else diagnostics.push(error(`animations.${id}`, "ANIMATION_REFERENCED", `${id} is nested in ${ref.animation}.${ref.track}; delete the track or use cascade`));
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
const validationState = {
|
|
2016
|
+
...state,
|
|
2017
|
+
trackIds: (id) => [.../* @__PURE__ */ new Set([...state.trackIds(id), ...nextTracks.get(id)?.keys() ?? []])]
|
|
2018
|
+
};
|
|
2019
|
+
const validationItems = new Map(nextItems);
|
|
2020
|
+
const descendants = [];
|
|
2021
|
+
for (const [id, value] of nextItems) if (value && value.parent !== state.item(id)?.parent) descendants.push(...state.children(id));
|
|
2022
|
+
const seenDescendants = /* @__PURE__ */ new Set();
|
|
2023
|
+
while (descendants.length) {
|
|
2024
|
+
const id = descendants.pop();
|
|
2025
|
+
if (seenDescendants.has(id)) continue;
|
|
2026
|
+
seenDescendants.add(id);
|
|
2027
|
+
validationItems.set(id, item(id) ?? null);
|
|
2028
|
+
descendants.push(...state.children(id));
|
|
2029
|
+
}
|
|
2030
|
+
for (const [id, value] of validationItems) {
|
|
2031
|
+
if (!value) continue;
|
|
2032
|
+
if (value.parent !== void 0) {
|
|
2033
|
+
const parent = item(value.parent);
|
|
2034
|
+
if (!parent) diagnostics.push(error(`items.${id}.parent`, "PARENT_NOT_FOUND", `parent ${value.parent} does not exist`));
|
|
2035
|
+
else if (parent.type !== "frame") diagnostics.push(error(`items.${id}.parent`, "INVALID_PARENT", `parent ${value.parent} is a ${parent.type}; only frames contain items`));
|
|
2036
|
+
else {
|
|
2037
|
+
let cursor = value.parent;
|
|
2038
|
+
for (let depth = 0; cursor; depth += 1) {
|
|
2039
|
+
if (depth >= 64) {
|
|
2040
|
+
diagnostics.push(error(`items.${id}.parent`, "PARENT_DEPTH", "parent hierarchy exceeds 64 levels"));
|
|
2041
|
+
break;
|
|
2042
|
+
}
|
|
2043
|
+
if (cursor === id) {
|
|
2044
|
+
diagnostics.push(error(`items.${id}.parent`, "PARENT_CYCLE", `${id} cannot be inside itself`));
|
|
2045
|
+
break;
|
|
2046
|
+
}
|
|
2047
|
+
cursor = item(cursor)?.parent;
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
for (const bound of arrowBindings(value)) {
|
|
2052
|
+
const target = item(bound);
|
|
2053
|
+
if (!target) diagnostics.push(error(`items.${id}.props`, "BINDING_NOT_FOUND", `bound item ${bound} does not exist`));
|
|
2054
|
+
else if (bound === id || target.type === "arrow") diagnostics.push(error(`items.${id}.props`, "INVALID_BINDING", "arrows bind to items other than arrows"));
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
for (const [id, value] of nextItems) {
|
|
2058
|
+
if (!value || !state.item(id) || state.item(id)?.type === value.type) continue;
|
|
2059
|
+
if (value.type !== "frame") {
|
|
2060
|
+
for (const child of state.children(id)) if (item(child)?.parent === id) diagnostics.push(error(`items.${child}.parent`, "INVALID_PARENT", `${id} is not a frame`));
|
|
2061
|
+
}
|
|
2062
|
+
if (value.type === "arrow") for (const binder of state.binders(id)) {
|
|
2063
|
+
const arrow = item(binder);
|
|
2064
|
+
if (arrow && arrowBindings(arrow).includes(id)) diagnostics.push(error(`items.${binder}.props`, "INVALID_BINDING", "arrows cannot bind to arrows"));
|
|
2065
|
+
}
|
|
2066
|
+
for (const ref of state.trackRefs(id)) {
|
|
2067
|
+
const current = track(ref.animation, ref.track);
|
|
2068
|
+
if (current) diagnostics.push(...validateTrack(`animations.${ref.animation}.tracks.${ref.track}`, ref.animation, current, item, animation, track, script, validationState, options.keepUnknown));
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
for (const [animationId, tracks] of nextTracks) {
|
|
2072
|
+
if (!animation(animationId)) {
|
|
2073
|
+
for (const [trackId, value] of tracks) if (value) diagnostics.push(error(`animations.${animationId}.tracks.${trackId}`, "ANIMATION_NOT_FOUND", `animation ${animationId} does not exist`));
|
|
2074
|
+
continue;
|
|
2075
|
+
}
|
|
2076
|
+
for (const [trackId, value] of tracks) {
|
|
2077
|
+
if (!value) continue;
|
|
2078
|
+
const stored = options.keepUnknown || state.track(animationId, trackId)?.property === value.property;
|
|
2079
|
+
diagnostics.push(...validateTrack(`animations.${animationId}.tracks.${trackId}`, animationId, value, item, animation, track, script, validationState, stored));
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
if (diagnostics.length) return {
|
|
2083
|
+
ok: false,
|
|
2084
|
+
diagnostics
|
|
2085
|
+
};
|
|
2086
|
+
const before = emptyDelta();
|
|
2087
|
+
const after = emptyDelta();
|
|
2088
|
+
if (nextSettings && !boardJsonEquals(nextSettings, state.settings())) {
|
|
2089
|
+
before.board = state.settings();
|
|
2090
|
+
after.board = nextSettings;
|
|
2091
|
+
}
|
|
2092
|
+
for (const [id, value] of nextItems) {
|
|
2093
|
+
const previous = state.item(id) ?? null;
|
|
2094
|
+
if (boardJsonEquals(previous, value)) continue;
|
|
2095
|
+
before.items[id] = previous;
|
|
2096
|
+
after.items[id] = value;
|
|
2097
|
+
}
|
|
2098
|
+
for (const [id, value] of nextAnimations) {
|
|
2099
|
+
before.animations[id] = state.animation(id) ?? null;
|
|
2100
|
+
after.animations[id] = value;
|
|
2101
|
+
}
|
|
2102
|
+
for (const [animationId, tracks] of nextTracks) for (const [trackId, value] of tracks) {
|
|
2103
|
+
const previous = state.track(animationId, trackId) ?? null;
|
|
2104
|
+
if (boardJsonEquals(previous, value)) continue;
|
|
2105
|
+
slot(before.tracks, animationId)[trackId] = previous;
|
|
2106
|
+
slot(after.tracks, animationId)[trackId] = value;
|
|
2107
|
+
}
|
|
2108
|
+
return {
|
|
2109
|
+
ok: true,
|
|
2110
|
+
before: withoutEmpty(before),
|
|
2111
|
+
after: withoutEmpty(after),
|
|
2112
|
+
diagnostics: []
|
|
2113
|
+
};
|
|
2114
|
+
}
|
|
2115
|
+
function validateTrack(path, animationId, value, item, animation, track, script, state, keepUnknownProperty = false) {
|
|
2116
|
+
const diagnostics = [];
|
|
2117
|
+
let targetType;
|
|
2118
|
+
if (value.target === "camera") targetType = BOARD_CAMERA_TARGET;
|
|
2119
|
+
else if (item(value.target)) targetType = item(value.target).type;
|
|
2120
|
+
else if (animation(value.target)) {
|
|
2121
|
+
targetType = "animation";
|
|
2122
|
+
if (value.target === animationId || nestsInto(value.target, animationId, animation, track, state)) return [error(`${path}.target`, "ANIMATION_CYCLE", `${animationId} cannot contain itself through ${value.target}`)];
|
|
2123
|
+
} else if (script(value.target)) targetType = "script";
|
|
2124
|
+
else return [error(`${path}.target`, "TARGET_NOT_FOUND", `target ${value.target} is not an item, animation, Board script or camera`)];
|
|
2125
|
+
if (!keepUnknownProperty && value.property.startsWith("script.") && !item(value.target)?.script) return [error(`${path}.property`, "INVALID_PROPERTY", `${value.target} has no script to animate`)];
|
|
2126
|
+
const resolved = resolveBoardProperty(targetType, value.property);
|
|
2127
|
+
if (!resolved.ok) return keepUnknownProperty ? [] : [error(`${path}.property`, "INVALID_PROPERTY", resolved.message)];
|
|
2128
|
+
for (const [index, keyframe] of value.keyframes.entries()) {
|
|
2129
|
+
const parsed = resolved.spec.schema.safeParse(keyframe.value);
|
|
2130
|
+
if (!parsed.success) {
|
|
2131
|
+
diagnostics.push(error(`${path}.keyframes.${index}.value`, "INVALID_KEYFRAME", parsed.error.issues[0]?.message ?? "invalid value"));
|
|
2132
|
+
continue;
|
|
2133
|
+
}
|
|
2134
|
+
if (value.property === "focus" && typeof keyframe.value === "string" && !item(keyframe.value)) diagnostics.push(error(`${path}.keyframes.${index}.value`, "TARGET_NOT_FOUND", `focus item ${keyframe.value} does not exist`));
|
|
2135
|
+
}
|
|
2136
|
+
if (value.interpolation === "spline" && resolved.spec.kind !== "vec2") diagnostics.push(error(`${path}.interpolation`, "INVALID_TRACK", "spline interpolation needs a position-like property"));
|
|
2137
|
+
return diagnostics;
|
|
2138
|
+
}
|
|
2139
|
+
function nestsInto(from, into, animation, track, state) {
|
|
2140
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2141
|
+
const stack = [from];
|
|
2142
|
+
while (stack.length) {
|
|
2143
|
+
const current = stack.pop();
|
|
2144
|
+
if (current === into) return true;
|
|
2145
|
+
if (seen.has(current) || !animation(current)) continue;
|
|
2146
|
+
seen.add(current);
|
|
2147
|
+
for (const trackId of state.trackIds(current)) {
|
|
2148
|
+
const value = track(current, trackId);
|
|
2149
|
+
if (value && value.property === "time" && animation(value.target)) stack.push(value.target);
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
return false;
|
|
2153
|
+
}
|
|
2154
|
+
function createDocumentState(document) {
|
|
2155
|
+
let children = null;
|
|
2156
|
+
let binders = null;
|
|
2157
|
+
let refs = null;
|
|
2158
|
+
const index = () => {
|
|
2159
|
+
if (children) return;
|
|
2160
|
+
children = /* @__PURE__ */ new Map();
|
|
2161
|
+
binders = /* @__PURE__ */ new Map();
|
|
2162
|
+
refs = /* @__PURE__ */ new Map();
|
|
2163
|
+
for (const [id, value] of Object.entries(document.items)) {
|
|
2164
|
+
if (value.parent) children.set(value.parent, [...children.get(value.parent) ?? [], id]);
|
|
2165
|
+
for (const bound of arrowBindings(value)) binders.set(bound, [...binders.get(bound) ?? [], id]);
|
|
2166
|
+
}
|
|
2167
|
+
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) ?? [], {
|
|
2168
|
+
animation: animationId,
|
|
2169
|
+
track: trackId
|
|
2170
|
+
}]);
|
|
2171
|
+
};
|
|
2172
|
+
return {
|
|
2173
|
+
settings: () => document.board,
|
|
2174
|
+
item: (id) => document.items[id],
|
|
2175
|
+
animation: (id) => {
|
|
2176
|
+
const value = document.animations[id];
|
|
2177
|
+
if (!value) return void 0;
|
|
2178
|
+
const { tracks: _tracks, ...header } = value;
|
|
2179
|
+
return header;
|
|
2180
|
+
},
|
|
2181
|
+
track: (animationId, trackId) => document.animations[animationId]?.tracks[trackId],
|
|
2182
|
+
trackIds: (animationId) => Object.keys(document.animations[animationId]?.tracks ?? {}),
|
|
2183
|
+
children: (id) => {
|
|
2184
|
+
index();
|
|
2185
|
+
return children?.get(id) ?? [];
|
|
2186
|
+
},
|
|
2187
|
+
binders: (id) => {
|
|
2188
|
+
index();
|
|
2189
|
+
return binders?.get(id) ?? [];
|
|
2190
|
+
},
|
|
2191
|
+
trackRefs: (id) => {
|
|
2192
|
+
index();
|
|
2193
|
+
return refs?.get(id) ?? [];
|
|
2194
|
+
},
|
|
2195
|
+
maxZ: (parent) => {
|
|
2196
|
+
let max = 0;
|
|
2197
|
+
for (const value of Object.values(document.items)) if (value.parent === parent && (value.z ?? 0) > max) max = value.z ?? 0;
|
|
2198
|
+
return max;
|
|
2199
|
+
}
|
|
2200
|
+
};
|
|
2201
|
+
}
|
|
2202
|
+
function applyBoardDelta(document, delta) {
|
|
2203
|
+
const items = delta.items ? { ...document.items } : document.items;
|
|
2204
|
+
for (const [id, value] of Object.entries(delta.items ?? {})) if (value) items[id] = value;
|
|
2205
|
+
else delete items[id];
|
|
2206
|
+
const animations = delta.animations || delta.tracks ? { ...document.animations } : document.animations;
|
|
2207
|
+
for (const [id, value] of Object.entries(delta.animations ?? {})) if (value) animations[id] = {
|
|
2208
|
+
...value,
|
|
2209
|
+
tracks: animations[id]?.tracks ?? {}
|
|
2210
|
+
};
|
|
2211
|
+
else delete animations[id];
|
|
2212
|
+
for (const [animationId, tracks] of Object.entries(delta.tracks ?? {})) {
|
|
2213
|
+
const current = animations[animationId];
|
|
2214
|
+
if (!current) continue;
|
|
2215
|
+
const nextTracks = { ...current.tracks };
|
|
2216
|
+
for (const [trackId, value] of Object.entries(tracks)) if (value) nextTracks[trackId] = value;
|
|
2217
|
+
else delete nextTracks[trackId];
|
|
2218
|
+
animations[animationId] = {
|
|
2219
|
+
...current,
|
|
2220
|
+
tracks: nextTracks
|
|
2221
|
+
};
|
|
2222
|
+
}
|
|
2223
|
+
return {
|
|
2224
|
+
board: delta.board ?? document.board,
|
|
2225
|
+
items,
|
|
2226
|
+
animations
|
|
2227
|
+
};
|
|
2228
|
+
}
|
|
2229
|
+
function applyBoardPatchToDocument(document, patch, options = {}) {
|
|
2230
|
+
const result = applyBoardPatch(createDocumentState(document), patch, options);
|
|
2231
|
+
return result.ok ? {
|
|
2232
|
+
ok: true,
|
|
2233
|
+
document: applyBoardDelta(document, result.after),
|
|
2234
|
+
before: result.before,
|
|
2235
|
+
after: result.after
|
|
2236
|
+
} : result;
|
|
2237
|
+
}
|
|
2238
|
+
function parseBoardDocument(input, options = {}) {
|
|
2239
|
+
if (!isRecord(input)) return {
|
|
2240
|
+
ok: false,
|
|
2241
|
+
diagnostics: [error("", "INVALID_DOCUMENT", "expected an object")]
|
|
2242
|
+
};
|
|
2243
|
+
const result = applyBoardPatchToDocument({
|
|
2244
|
+
board: BoardSettingsSchema.parse({}),
|
|
2245
|
+
items: {},
|
|
2246
|
+
animations: {}
|
|
2247
|
+
}, {
|
|
2248
|
+
...isRecord(input.board) ? { board: input.board } : {},
|
|
2249
|
+
...isRecord(input.items) ? { items: input.items } : {},
|
|
2250
|
+
...isRecord(input.animations) ? { animations: input.animations } : {}
|
|
2251
|
+
}, options);
|
|
2252
|
+
return result.ok ? {
|
|
2253
|
+
ok: true,
|
|
2254
|
+
document: result.document
|
|
2255
|
+
} : result;
|
|
2256
|
+
}
|
|
2257
|
+
//#endregion
|
|
2258
|
+
//#region ../protocol/src/fs/mime.ts
|
|
2259
|
+
const MIME_BY_EXTENSION = {
|
|
2260
|
+
".txt": "text/plain",
|
|
2261
|
+
".md": "text/markdown",
|
|
2262
|
+
".markdown": "text/markdown",
|
|
2263
|
+
".json": "application/json",
|
|
2264
|
+
".jsonl": "application/x-ndjson",
|
|
2265
|
+
".csv": "text/csv",
|
|
2266
|
+
[BOARD_EXTENSION]: BOARD_MIME_TYPE,
|
|
2267
|
+
".js": "text/javascript",
|
|
2268
|
+
".mjs": "text/javascript",
|
|
2269
|
+
".cjs": "text/javascript",
|
|
2270
|
+
".ts": "text/typescript",
|
|
2271
|
+
".tsx": "text/tsx",
|
|
2272
|
+
".jsx": "text/jsx",
|
|
2273
|
+
".svelte": "text/x-svelte",
|
|
2274
|
+
".css": "text/css",
|
|
2275
|
+
".scss": "text/x-scss",
|
|
2276
|
+
".html": "text/html",
|
|
2277
|
+
".htm": "text/html",
|
|
2278
|
+
".xml": "application/xml",
|
|
2279
|
+
".yaml": "application/yaml",
|
|
2280
|
+
".yml": "application/yaml",
|
|
2281
|
+
".toml": "application/toml",
|
|
2282
|
+
".ini": "text/plain",
|
|
2283
|
+
".env": "text/plain",
|
|
2284
|
+
".sh": "text/x-shellscript",
|
|
2285
|
+
".bash": "text/x-shellscript",
|
|
2286
|
+
".py": "text/x-python",
|
|
2287
|
+
".go": "text/x-go",
|
|
2288
|
+
".rs": "text/x-rust",
|
|
2289
|
+
".java": "text/x-java-source",
|
|
2290
|
+
".c": "text/x-c",
|
|
2291
|
+
".h": "text/x-c",
|
|
2292
|
+
".cpp": "text/x-c++src",
|
|
2293
|
+
".hpp": "text/x-c++hdr",
|
|
2294
|
+
".sql": "application/sql",
|
|
2295
|
+
".svg": "image/svg+xml",
|
|
2296
|
+
".png": "image/png",
|
|
2297
|
+
".jpg": "image/jpeg",
|
|
2298
|
+
".jpeg": "image/jpeg",
|
|
2299
|
+
".gif": "image/gif",
|
|
2300
|
+
".webp": "image/webp",
|
|
2301
|
+
".avif": "image/avif",
|
|
2302
|
+
".bmp": "image/bmp",
|
|
2303
|
+
".ico": "image/x-icon",
|
|
2304
|
+
".mp4": "video/mp4",
|
|
2305
|
+
".webm": "video/webm",
|
|
2306
|
+
".mov": "video/quicktime",
|
|
2307
|
+
".m4v": "video/x-m4v",
|
|
2308
|
+
".ogv": "video/ogg",
|
|
2309
|
+
".avi": "video/x-msvideo",
|
|
2310
|
+
".mp3": "audio/mpeg",
|
|
2311
|
+
".wav": "audio/wav",
|
|
2312
|
+
".ogg": "audio/ogg",
|
|
2313
|
+
".m4a": "audio/mp4",
|
|
2314
|
+
".aac": "audio/aac",
|
|
2315
|
+
".flac": "audio/flac",
|
|
2316
|
+
".opus": "audio/ogg",
|
|
2317
|
+
".glb": "model/gltf-binary",
|
|
2318
|
+
".gltf": "model/gltf+json",
|
|
2319
|
+
".stl": "model/stl",
|
|
2320
|
+
".obj": "model/obj",
|
|
2321
|
+
".3mf": "model/3mf",
|
|
2322
|
+
".usdz": "model/vnd.usdz+zip",
|
|
2323
|
+
".mtl": "text/plain",
|
|
2324
|
+
".pdf": "application/pdf",
|
|
2325
|
+
".wasm": "application/wasm",
|
|
2326
|
+
".woff": "font/woff",
|
|
2327
|
+
".woff2": "font/woff2",
|
|
2328
|
+
".zip": "application/zip",
|
|
2329
|
+
".gz": "application/gzip",
|
|
2330
|
+
".tar": "application/x-tar",
|
|
2331
|
+
".rar": "application/vnd.rar",
|
|
2332
|
+
".7z": "application/x-7z-compressed",
|
|
2333
|
+
".exe": "application/x-msdownload",
|
|
2334
|
+
".dmg": "application/x-apple-diskimage",
|
|
2335
|
+
".deb": "application/vnd.debian.binary-package",
|
|
2336
|
+
".rpm": "application/x-rpm"
|
|
2337
|
+
};
|
|
2338
|
+
const MIME_BY_FILENAME = {
|
|
2339
|
+
dockerfile: "text/x-dockerfile",
|
|
2340
|
+
makefile: "text/x-makefile"
|
|
2341
|
+
};
|
|
2342
|
+
function mimeTypeForPath(path) {
|
|
2343
|
+
const name = (path.split(/[\\/]/).pop() ?? "").toLowerCase();
|
|
2344
|
+
const byName = Object.hasOwn(MIME_BY_FILENAME, name) ? MIME_BY_FILENAME[name] : void 0;
|
|
2345
|
+
if (byName) return byName;
|
|
2346
|
+
const dot = name.lastIndexOf(".");
|
|
2347
|
+
const byExtension = dot > 0 ? MIME_BY_EXTENSION[name.slice(dot)] : void 0;
|
|
2348
|
+
if (byExtension) return byExtension;
|
|
2349
|
+
return name.startsWith(".") ? "text/plain" : null;
|
|
2350
|
+
}
|
|
2351
|
+
function normalizeMime(mimeType) {
|
|
2352
|
+
if (!mimeType) return null;
|
|
2353
|
+
return mimeType.split(";")[0]?.trim().toLowerCase() || null;
|
|
2354
|
+
}
|
|
2355
|
+
const TEXT_APPLICATION_MIMES = /* @__PURE__ */ new Set([
|
|
2356
|
+
"application/json",
|
|
2357
|
+
"application/csv",
|
|
2358
|
+
"application/xml",
|
|
2359
|
+
"application/yaml",
|
|
2360
|
+
"application/toml",
|
|
2361
|
+
"application/sql",
|
|
2362
|
+
"application/x-ndjson"
|
|
2363
|
+
]);
|
|
2364
|
+
function isTextMime(mimeType) {
|
|
2365
|
+
const mime = normalizeMime(mimeType);
|
|
2366
|
+
return Boolean(mime && (mime.startsWith("text/") || TEXT_APPLICATION_MIMES.has(mime)));
|
|
2367
|
+
}
|
|
2368
|
+
function isModelMime(mimeType) {
|
|
2369
|
+
return normalizeMime(mimeType)?.startsWith("model/") ?? false;
|
|
2370
|
+
}
|
|
2371
|
+
const MODEL_FORMAT_BY_MIME = {
|
|
2372
|
+
"model/gltf-binary": "glb",
|
|
2373
|
+
"model/gltf+json": "gltf",
|
|
2374
|
+
"model/stl": "stl",
|
|
2375
|
+
"model/obj": "obj"
|
|
2376
|
+
};
|
|
2377
|
+
function modelFormatForPath(path, mimeType) {
|
|
2378
|
+
const format = (mime) => {
|
|
2379
|
+
const key = normalizeMime(mime);
|
|
2380
|
+
return key && Object.hasOwn(MODEL_FORMAT_BY_MIME, key) ? MODEL_FORMAT_BY_MIME[key] : void 0;
|
|
2381
|
+
};
|
|
2382
|
+
return format(mimeTypeForPath(path)) ?? format(mimeType) ?? null;
|
|
2383
|
+
}
|
|
2384
|
+
//#endregion
|
|
2385
|
+
//#region ../sdk/src/board/model/json.ts
|
|
2386
|
+
function sameJson(a, b) {
|
|
2387
|
+
if (a === b) return true;
|
|
2388
|
+
if (!a || !b || typeof a !== "object" || typeof b !== "object") return false;
|
|
2389
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
2390
|
+
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;
|
|
2391
|
+
for (let index = 0; index < a.length; index += 1) if (!sameJson(a[index], b[index])) return false;
|
|
2392
|
+
return true;
|
|
2393
|
+
}
|
|
2394
|
+
const left = a;
|
|
2395
|
+
const right = b;
|
|
2396
|
+
let members = 0;
|
|
2397
|
+
for (const key of Object.keys(left)) {
|
|
2398
|
+
if (left[key] === void 0) continue;
|
|
2399
|
+
members += 1;
|
|
2400
|
+
if (!sameJson(left[key], right[key])) return false;
|
|
2401
|
+
}
|
|
2402
|
+
for (const key of Object.keys(right)) if (right[key] !== void 0) members -= 1;
|
|
2403
|
+
return members === 0;
|
|
2404
|
+
}
|
|
2405
|
+
//#endregion
|
|
2406
|
+
//#region ../sdk/src/board/model/items/id.ts
|
|
2407
|
+
function createBoardEntityId() {
|
|
2408
|
+
const cryptoRef = globalThis.crypto;
|
|
2409
|
+
if (cryptoRef && typeof cryptoRef.randomUUID === "function") return cryptoRef.randomUUID();
|
|
2410
|
+
return `c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
2411
|
+
}
|
|
2412
|
+
function createBoardItemId() {
|
|
2413
|
+
return `item_${createBoardEntityId()}`;
|
|
2414
|
+
}
|
|
2415
|
+
//#endregion
|
|
2416
|
+
export { BoardAnimationHeaderSchema as $, invertMatrix as A, taskArtifactPreviewUrl as B, clampBoardFontSize as C, 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, clampBoardStrokeSize 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_MONO_FONT_STACK as _t, isTextMime as a, BoardSettingsSchema as at, arrowBindings as b, BOARD_TEXT_SCALE 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_FONT_STACK as gt, pruneBoardTrack as h, BOARD_DEFAULT_SIZES 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_PAGE_SIZE as vt, createBoardLayout as w, autoAnchorSide as x, boardDefaultSize as xt, applyMatrix as y, BOARD_TEXT_FONT_FAMILY as yt, featuredTaskArtifact as z };
|