@neta-art/cohub 8.24.0 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/board/animation.d.ts +57 -181
- package/dist/board/animation.js +374 -220
- package/dist/board/core/arrow-geometry.d.ts +33 -18
- package/dist/board/core/arrow-geometry.js +283 -52
- package/dist/board/core/draw-geometry.d.ts +22 -36
- package/dist/board/core/draw-geometry.js +148 -85
- package/dist/board/core/export-assets.d.ts +3 -6
- package/dist/board/core/export-assets.js +0 -2
- package/dist/board/core/export-plan.d.ts +12 -63
- package/dist/board/core/export-plan.js +55 -94
- package/dist/board/core/palette.d.ts +4 -21
- package/dist/board/core/palette.js +8 -13
- package/dist/board/core/scene.d.ts +33 -0
- package/dist/board/core/scene.js +302 -0
- package/dist/board/core/shape-definition.d.ts +12 -24
- package/dist/board/core/shape-definition.js +0 -19
- package/dist/board/core/shape-types.d.ts +6 -120
- package/dist/board/core/shape-types.js +5 -5
- package/dist/board/core/text-metrics.d.ts +8 -11
- package/dist/board/core/text-metrics.js +5 -34
- package/dist/board/core/tool-styles.d.ts +6 -16
- package/dist/board/core/tool-styles.js +17 -25
- package/dist/board/export/index.d.ts +10 -17
- package/dist/board/export/index.js +22 -21
- package/dist/board/export/scene.d.ts +10 -16
- package/dist/board/export/scene.js +17 -30
- package/dist/board/geometry.d.ts +27 -56
- package/dist/board/geometry.js +7 -67
- package/dist/board/headless/index.d.ts +6 -27
- package/dist/board/headless/index.js +4 -19
- package/dist/board/headless/sketch.d.ts +19 -0
- package/dist/board/headless/sketch.js +146 -0
- package/dist/board/image-key.d.ts +2 -12
- package/dist/board/image-key.js +3 -13
- package/dist/board/index.d.ts +18 -20
- package/dist/board/index.js +17 -17
- package/dist/board/media-playback.d.ts +3 -6
- package/dist/board/media-playback.js +6 -6
- package/dist/board/presets.d.ts +150 -0
- package/dist/board/presets.js +226 -0
- package/dist/board/render/board-background.d.ts +5 -3
- package/dist/board/render/board-background.js +8 -7
- package/dist/board/render/clip.d.ts +14 -0
- package/dist/board/render/clip.js +47 -0
- package/dist/board/render/index.d.ts +8 -5
- package/dist/board/render/index.js +7 -4
- package/dist/board/render/media-interaction.d.ts +4 -5
- package/dist/board/render/media-interaction.js +1 -2
- package/dist/board/render/palette.d.ts +6 -2
- package/dist/board/render/palette.js +7 -1
- package/dist/board/render/renderers/arrow-card-renderer.js +69 -71
- package/dist/board/render/renderers/audio-card-renderer.js +3 -3
- package/dist/board/render/renderers/base-card-renderer.d.ts +6 -17
- package/dist/board/render/renderers/base-card-renderer.js +1 -24
- package/dist/board/render/renderers/board-renderer-registry.d.ts +20 -50
- package/dist/board/render/renderers/board-renderer-registry.js +6 -7
- package/dist/board/render/renderers/draw-card-renderer.js +89 -56
- package/dist/board/render/renderers/effect-card-renderer.d.ts +6 -0
- package/dist/board/render/renderers/effect-card-renderer.js +197 -0
- package/dist/board/render/renderers/far-plate.d.ts +4 -21
- package/dist/board/render/renderers/far-plate.js +15 -34
- package/dist/board/render/renderers/file-card-renderer.d.ts +4 -25
- package/dist/board/render/renderers/file-card-renderer.js +8 -58
- package/dist/board/render/renderers/frame-card-renderer.js +28 -28
- package/dist/board/render/renderers/image-card-renderer.d.ts +4 -3
- package/dist/board/render/renderers/image-card-renderer.js +0 -9
- package/dist/board/render/renderers/shape-card-renderer.d.ts +9 -0
- package/dist/board/render/renderers/shape-card-renderer.js +240 -0
- package/dist/board/render/renderers/sketch-card-renderer.d.ts +5 -0
- package/dist/board/render/renderers/sketch-card-renderer.js +98 -0
- package/dist/board/render/renderers/task-card-renderer.d.ts +0 -1
- package/dist/board/render/renderers/task-card-renderer.js +14 -16
- package/dist/board/render/renderers/text-card-renderer.d.ts +1 -3
- package/dist/board/render/renderers/text-card-renderer.js +56 -46
- package/dist/board/render/renderers/unknown-card-renderer.js +4 -10
- package/dist/board/render/renderers/video-card-renderer.d.ts +4 -2
- package/dist/board/render/renderers/video-card-renderer.js +2 -1
- package/dist/board/render/sketch-host.d.ts +14 -0
- package/dist/board/render/sketch-host.js +216 -0
- package/dist/board/render/stroke.d.ts +12 -0
- package/dist/board/render/stroke.js +90 -0
- package/dist/board/render/text-measurement.d.ts +6 -26
- package/dist/board/render/text-measurement.js +11 -30
- package/dist/board/replay.d.ts +6 -31
- package/dist/board/replay.js +45 -203
- package/dist/board/runtime/board-player.d.ts +24 -0
- package/dist/board/runtime/board-player.js +161 -0
- package/dist/board/task.d.ts +2 -10
- package/dist/board/task.js +1 -10
- package/dist/chunks/environment.d.ts +2292 -3864
- package/dist/chunks/host-bridge.d.ts +253 -0
- package/dist/chunks/http.d.ts +233 -58
- package/dist/chunks/http.js +1046 -1028
- package/dist/chunks/transport.js +113 -59
- package/dist/chunks/websocket.d.ts +1 -1
- package/dist/chunks/websocket.js +1 -1
- package/dist/host-bridge.d.ts +54 -0
- package/dist/host-bridge.js +322 -0
- package/dist/http.d.ts +3 -3
- package/dist/index.d.ts +74 -191
- package/dist/index.js +2032 -1186
- package/dist/protocol/dist/board-constants.d.ts +1 -29
- package/dist/protocol/dist/board-constants.js +2 -115
- package/dist/protocol/dist/board-layout.d.ts +59 -0
- package/dist/protocol/dist/board-layout.js +482 -0
- package/dist/protocol/dist/board-model.d.ts +2052 -0
- package/dist/protocol/dist/board-model.js +592 -0
- package/dist/protocol/dist/board-patch.d.ts +86 -0
- package/dist/protocol/dist/board-patch.js +734 -0
- package/dist/protocol/dist/board-schema.d.ts +33 -0
- package/dist/protocol/dist/board-schema.js +59 -0
- package/dist/protocol/dist/board-upgrade.d.ts +1 -0
- package/dist/protocol/dist/board-url.d.ts +1 -3
- package/dist/protocol/dist/board-url.js +2 -2
- package/dist/protocol/dist/board.d.ts +37 -232
- package/dist/protocol/dist/board.js +62 -160
- package/dist/protocol/dist/display/actions.d.ts +1 -0
- package/dist/protocol/dist/display/index.d.ts +2 -0
- package/dist/protocol/dist/index.d.ts +11 -12
- package/dist/protocol/dist/model/metrics.d.ts +2 -0
- package/dist/protocol/dist/model/session.d.ts +2 -1
- package/dist/protocol/dist/realtime/types.d.ts +2 -2
- package/dist/protocol/dist/runtime/index.d.ts +1 -0
- package/dist/space-picker.d.ts +1 -0
- package/dist/space-picker.js +1 -0
- package/dist/types.d.ts +2 -5
- package/package.json +15 -7
- package/dist/board/core/connections.d.ts +0 -108
- package/dist/board/core/connections.js +0 -455
- package/dist/board/mutation.d.ts +0 -6
- package/dist/board/mutation.js +0 -14
- package/dist/board/render/connection-layer.d.ts +0 -53
- package/dist/board/render/connection-layer.js +0 -375
- package/dist/board/render/renderers/geo-card-renderer.d.ts +0 -5
- package/dist/board/render/renderers/geo-card-renderer.js +0 -127
- package/dist/board/semantic-document.d.ts +0 -37
- package/dist/board/semantic-document.js +0 -288
- package/dist/board/semantic-mutation.d.ts +0 -10
- package/dist/board/semantic-mutation.js +0 -209
- package/dist/protocol/dist/board-animation.js +0 -34
- package/dist/protocol/dist/board-authoring.d.ts +0 -1326
- package/dist/protocol/dist/board-authoring.js +0 -302
- package/dist/protocol/dist/board-capability-registry.d.ts +0 -2
- package/dist/protocol/dist/board-capability-registry.js +0 -123
- package/dist/protocol/dist/board-codec.d.ts +0 -3
- package/dist/protocol/dist/board-codec.js +0 -383
- package/dist/protocol/dist/board-composition.d.ts +0 -383
- package/dist/protocol/dist/board-composition.js +0 -310
- package/dist/protocol/dist/board-connection.d.ts +0 -317
- package/dist/protocol/dist/board-connection.js +0 -219
- package/dist/protocol/dist/board-document.d.ts +0 -1566
- package/dist/protocol/dist/board-document.js +0 -456
- package/dist/protocol/dist/board-effect.d.ts +0 -96
- package/dist/protocol/dist/board-effect.js +0 -54
- package/dist/protocol/dist/board-geometry.d.ts +0 -15
- package/dist/protocol/dist/board-geometry.js +0 -137
- package/dist/protocol/dist/board-node.d.ts +0 -8
- package/dist/protocol/dist/board-node.js +0 -252
- /package/dist/protocol/dist/{board-animation.d.ts → host-bridge.d.ts} +0 -0
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
import "./board-constants.js";
|
|
2
|
-
import { BoardConnectionPatchSchema, BoardConnectionSchema } from "./board-connection.js";
|
|
3
|
-
import { BoardCompositionInputSchema } from "./board-composition.js";
|
|
4
|
-
import { BoardEffectInputSchema } from "./board-effect.js";
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
//#region ../protocol/dist/board-authoring.js
|
|
7
|
-
const BOARD_AUTHORING_COLOR_IDS = [
|
|
8
|
-
"brand",
|
|
9
|
-
"neutral",
|
|
10
|
-
"black",
|
|
11
|
-
"white",
|
|
12
|
-
"blue",
|
|
13
|
-
"green",
|
|
14
|
-
"amber",
|
|
15
|
-
"violet",
|
|
16
|
-
"rose"
|
|
17
|
-
];
|
|
18
|
-
const BOARD_AUTHORING_GEO_KINDS = [
|
|
19
|
-
"rectangle",
|
|
20
|
-
"rounded",
|
|
21
|
-
"ellipse",
|
|
22
|
-
"diamond",
|
|
23
|
-
"triangle"
|
|
24
|
-
];
|
|
25
|
-
const idSchema = z.string().min(1).max(160);
|
|
26
|
-
const jsonObjectSchema = z.record(z.string(), z.unknown());
|
|
27
|
-
const finiteSchema = z.number().finite();
|
|
28
|
-
const extensionTypeSchema = z.string().regex(/^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)+$/).max(160);
|
|
29
|
-
const BoardAuthoringPositionSchema = z.object({
|
|
30
|
-
x: finiteSchema,
|
|
31
|
-
y: finiteSchema
|
|
32
|
-
}).strict();
|
|
33
|
-
const BoardAuthoringSizeSchema = z.object({
|
|
34
|
-
width: finiteSchema.positive(),
|
|
35
|
-
height: finiteSchema.positive()
|
|
36
|
-
}).strict();
|
|
37
|
-
const BoardAuthoringPositionPatchSchema = z.object({
|
|
38
|
-
x: finiteSchema.optional(),
|
|
39
|
-
y: finiteSchema.optional()
|
|
40
|
-
}).strict();
|
|
41
|
-
const pointSchema = z.object({
|
|
42
|
-
x: finiteSchema,
|
|
43
|
-
y: finiteSchema,
|
|
44
|
-
p: finiteSchema.min(0).max(1).default(.5)
|
|
45
|
-
}).strict();
|
|
46
|
-
const worldPointSchema = z.object({
|
|
47
|
-
x: finiteSchema,
|
|
48
|
-
y: finiteSchema
|
|
49
|
-
}).strict();
|
|
50
|
-
const cropSchema = z.object({
|
|
51
|
-
x: finiteSchema.min(0).max(1),
|
|
52
|
-
y: finiteSchema.min(0).max(1),
|
|
53
|
-
w: finiteSchema.min(0).max(1),
|
|
54
|
-
h: finiteSchema.min(0).max(1)
|
|
55
|
-
}).strict();
|
|
56
|
-
const BoardItemStyleSchema = z.object({
|
|
57
|
-
color: z.enum(BOARD_AUTHORING_COLOR_IDS).optional(),
|
|
58
|
-
strokeWidth: finiteSchema.min(1).max(64).optional(),
|
|
59
|
-
fillOpacity: finiteSchema.min(0).max(1).optional()
|
|
60
|
-
}).strict();
|
|
61
|
-
const sourceSnapshotSchema = z.record(z.string(), z.unknown());
|
|
62
|
-
function isSafeBoardSourcePath(value) {
|
|
63
|
-
return value.length > 0 && value.length <= 4096 && !value.startsWith("/") && !value.startsWith("\\") && !value.includes("\\") && value.split("/").every((part) => part.length > 0 && part !== "." && part !== "..");
|
|
64
|
-
}
|
|
65
|
-
const BoardItemSourceSchema = z.object({
|
|
66
|
-
kind: z.literal("space-file"),
|
|
67
|
-
path: z.string().refine(isSafeBoardSourcePath, "source path must be a safe relative Board file path"),
|
|
68
|
-
snapshot: sourceSnapshotSchema.optional()
|
|
69
|
-
}).strict();
|
|
70
|
-
const sizedBaseFields = {
|
|
71
|
-
id: idSchema,
|
|
72
|
-
position: BoardAuthoringPositionSchema.default({
|
|
73
|
-
x: 0,
|
|
74
|
-
y: 0
|
|
75
|
-
}),
|
|
76
|
-
rotation: finiteSchema.default(0),
|
|
77
|
-
parentId: idSchema.nullable().optional(),
|
|
78
|
-
locked: z.boolean().optional(),
|
|
79
|
-
metadata: jsonObjectSchema.optional(),
|
|
80
|
-
size: BoardAuthoringSizeSchema.optional()
|
|
81
|
-
};
|
|
82
|
-
const styledBaseFields = {
|
|
83
|
-
...sizedBaseFields,
|
|
84
|
-
style: BoardItemStyleSchema.optional()
|
|
85
|
-
};
|
|
86
|
-
const { position: _positionField, size: _sizeField, ...strokeBaseFields } = sizedBaseFields;
|
|
87
|
-
const strokeStyledBaseFields = {
|
|
88
|
-
...strokeBaseFields,
|
|
89
|
-
rotation: z.literal(0).default(0),
|
|
90
|
-
style: BoardItemStyleSchema.optional()
|
|
91
|
-
};
|
|
92
|
-
const BoardTextAuthoringItemSchema = z.object({
|
|
93
|
-
...styledBaseFields,
|
|
94
|
-
type: z.literal("text"),
|
|
95
|
-
props: z.object({
|
|
96
|
-
text: z.string().default(""),
|
|
97
|
-
fontSize: finiteSchema.min(2).max(512).default(24)
|
|
98
|
-
}).strict()
|
|
99
|
-
}).strict();
|
|
100
|
-
const BoardGeoAuthoringItemSchema = z.object({
|
|
101
|
-
...styledBaseFields,
|
|
102
|
-
type: z.literal("geo"),
|
|
103
|
-
props: z.object({
|
|
104
|
-
shape: z.enum(BOARD_AUTHORING_GEO_KINDS).default("rectangle"),
|
|
105
|
-
text: z.string().default("")
|
|
106
|
-
}).strict()
|
|
107
|
-
}).strict();
|
|
108
|
-
const BoardDrawAuthoringItemSchema = z.object({
|
|
109
|
-
...strokeStyledBaseFields,
|
|
110
|
-
type: z.literal("draw"),
|
|
111
|
-
props: z.object({ points: z.array(pointSchema).min(1) }).strict()
|
|
112
|
-
}).strict();
|
|
113
|
-
const BoardArrowAuthoringItemSchema = z.object({
|
|
114
|
-
...strokeStyledBaseFields,
|
|
115
|
-
type: z.literal("arrow"),
|
|
116
|
-
props: z.object({
|
|
117
|
-
start: worldPointSchema,
|
|
118
|
-
end: worldPointSchema,
|
|
119
|
-
bend: finiteSchema.min(-.85).max(.85).default(0),
|
|
120
|
-
arrowStart: z.boolean().default(false),
|
|
121
|
-
arrowEnd: z.boolean().default(true),
|
|
122
|
-
label: z.string().default("")
|
|
123
|
-
}).strict()
|
|
124
|
-
}).strict();
|
|
125
|
-
const BoardFrameAuthoringItemSchema = z.object({
|
|
126
|
-
...styledBaseFields,
|
|
127
|
-
type: z.literal("frame"),
|
|
128
|
-
props: z.object({ label: z.string().default("Frame") }).strict()
|
|
129
|
-
}).strict();
|
|
130
|
-
const fileBackedFields = {
|
|
131
|
-
...sizedBaseFields,
|
|
132
|
-
style: z.object({}).strict().optional(),
|
|
133
|
-
source: BoardItemSourceSchema
|
|
134
|
-
};
|
|
135
|
-
const BoardImageAuthoringItemSchema = z.object({
|
|
136
|
-
...fileBackedFields,
|
|
137
|
-
type: z.literal("image"),
|
|
138
|
-
props: z.object({ crop: cropSchema.optional() }).strict()
|
|
139
|
-
}).strict();
|
|
140
|
-
const BoardVideoAuthoringItemSchema = z.object({
|
|
141
|
-
...fileBackedFields,
|
|
142
|
-
type: z.literal("video"),
|
|
143
|
-
props: z.object({}).strict()
|
|
144
|
-
}).strict();
|
|
145
|
-
const BoardAudioAuthoringItemSchema = z.object({
|
|
146
|
-
...fileBackedFields,
|
|
147
|
-
type: z.literal("audio"),
|
|
148
|
-
props: z.object({}).strict()
|
|
149
|
-
}).strict();
|
|
150
|
-
const BoardFileAuthoringItemSchema = z.object({
|
|
151
|
-
...fileBackedFields,
|
|
152
|
-
type: z.literal("file"),
|
|
153
|
-
props: z.object({}).strict()
|
|
154
|
-
}).strict();
|
|
155
|
-
const BoardTaskAuthoringItemSchema = z.object({
|
|
156
|
-
...sizedBaseFields,
|
|
157
|
-
type: z.literal("task"),
|
|
158
|
-
props: z.object({
|
|
159
|
-
taskRunId: z.string().min(1),
|
|
160
|
-
snapshot: z.record(z.string(), z.unknown())
|
|
161
|
-
}).strict(),
|
|
162
|
-
style: z.object({}).strict().optional()
|
|
163
|
-
}).strict();
|
|
164
|
-
const builtinItemSchemas = [
|
|
165
|
-
BoardTextAuthoringItemSchema,
|
|
166
|
-
BoardGeoAuthoringItemSchema,
|
|
167
|
-
BoardDrawAuthoringItemSchema,
|
|
168
|
-
BoardArrowAuthoringItemSchema,
|
|
169
|
-
BoardFrameAuthoringItemSchema,
|
|
170
|
-
BoardImageAuthoringItemSchema,
|
|
171
|
-
BoardVideoAuthoringItemSchema,
|
|
172
|
-
BoardAudioAuthoringItemSchema,
|
|
173
|
-
BoardFileAuthoringItemSchema,
|
|
174
|
-
BoardTaskAuthoringItemSchema
|
|
175
|
-
];
|
|
176
|
-
const BoardBuiltinAuthoringItemSchema = z.discriminatedUnion("type", builtinItemSchemas);
|
|
177
|
-
const BoardExtensionAuthoringItemSchema = z.object({
|
|
178
|
-
...sizedBaseFields,
|
|
179
|
-
type: extensionTypeSchema,
|
|
180
|
-
kindVersion: z.number().int().positive(),
|
|
181
|
-
props: jsonObjectSchema,
|
|
182
|
-
style: jsonObjectSchema.optional(),
|
|
183
|
-
source: z.object({
|
|
184
|
-
kind: z.string().min(1).max(80),
|
|
185
|
-
ref: z.string().min(1).max(4096),
|
|
186
|
-
snapshot: jsonObjectSchema.optional()
|
|
187
|
-
}).strict().optional()
|
|
188
|
-
}).strict();
|
|
189
|
-
const BoardAuthoringItemSchema = z.union([BoardBuiltinAuthoringItemSchema, BoardExtensionAuthoringItemSchema]);
|
|
190
|
-
/** JSON Merge Patch semantics, constrained to the stable Item envelope. */
|
|
191
|
-
const BoardItemPatchSchema = z.object({
|
|
192
|
-
position: BoardAuthoringPositionPatchSchema.optional(),
|
|
193
|
-
size: BoardAuthoringSizeSchema.nullable().optional(),
|
|
194
|
-
rotation: finiteSchema.optional(),
|
|
195
|
-
parentId: idSchema.nullable().optional(),
|
|
196
|
-
locked: z.boolean().nullable().optional(),
|
|
197
|
-
props: jsonObjectSchema.optional(),
|
|
198
|
-
style: jsonObjectSchema.nullable().optional(),
|
|
199
|
-
source: jsonObjectSchema.nullable().optional(),
|
|
200
|
-
metadata: jsonObjectSchema.nullable().optional()
|
|
201
|
-
}).strict().refine((patch) => Object.keys(patch).length > 0, "item patch is empty");
|
|
202
|
-
const BoardConnectionInputSchema = BoardConnectionSchema;
|
|
203
|
-
const stripServerFields = (value) => {
|
|
204
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
205
|
-
const { boardId: _boardId, revision: _revision, ...input } = value;
|
|
206
|
-
return input;
|
|
207
|
-
};
|
|
208
|
-
const BoardEffectCommandInputSchema = z.preprocess(stripServerFields, BoardEffectInputSchema);
|
|
209
|
-
const BoardCompositionCommandInputSchema = z.preprocess(stripServerFields, BoardCompositionInputSchema);
|
|
210
|
-
const BoardSemanticCommandSchema = z.discriminatedUnion("type", [
|
|
211
|
-
z.object({
|
|
212
|
-
type: z.literal("board.patch"),
|
|
213
|
-
patch: z.object({
|
|
214
|
-
title: z.string().min(1).max(255).optional(),
|
|
215
|
-
metadata: jsonObjectSchema.nullable().optional(),
|
|
216
|
-
metadataPatch: jsonObjectSchema.optional()
|
|
217
|
-
}).strict().refine((patch) => Object.keys(patch).length > 0, "board patch is empty")
|
|
218
|
-
}).strict(),
|
|
219
|
-
z.object({
|
|
220
|
-
type: z.literal("item.create"),
|
|
221
|
-
item: BoardAuthoringItemSchema
|
|
222
|
-
}).strict(),
|
|
223
|
-
z.object({
|
|
224
|
-
type: z.literal("item.patch"),
|
|
225
|
-
itemId: idSchema,
|
|
226
|
-
patch: BoardItemPatchSchema
|
|
227
|
-
}).strict(),
|
|
228
|
-
z.object({
|
|
229
|
-
type: z.literal("item.replace"),
|
|
230
|
-
itemId: idSchema,
|
|
231
|
-
item: BoardAuthoringItemSchema
|
|
232
|
-
}).strict(),
|
|
233
|
-
z.object({
|
|
234
|
-
type: z.literal("item.delete"),
|
|
235
|
-
itemId: idSchema,
|
|
236
|
-
cascade: z.boolean().default(false)
|
|
237
|
-
}).strict(),
|
|
238
|
-
z.object({
|
|
239
|
-
type: z.literal("item.reorder"),
|
|
240
|
-
itemId: idSchema,
|
|
241
|
-
index: z.number().int().nonnegative()
|
|
242
|
-
}).strict(),
|
|
243
|
-
z.object({
|
|
244
|
-
type: z.literal("connection.create"),
|
|
245
|
-
connection: BoardConnectionInputSchema
|
|
246
|
-
}).strict(),
|
|
247
|
-
z.object({
|
|
248
|
-
type: z.literal("connection.patch"),
|
|
249
|
-
connectionId: idSchema,
|
|
250
|
-
patch: BoardConnectionPatchSchema
|
|
251
|
-
}).strict(),
|
|
252
|
-
z.object({
|
|
253
|
-
type: z.literal("connection.delete"),
|
|
254
|
-
connectionId: idSchema
|
|
255
|
-
}).strict(),
|
|
256
|
-
z.object({
|
|
257
|
-
type: z.literal("effect.apply"),
|
|
258
|
-
effect: BoardEffectCommandInputSchema
|
|
259
|
-
}).strict(),
|
|
260
|
-
z.object({
|
|
261
|
-
type: z.literal("effect.delete"),
|
|
262
|
-
effectId: idSchema
|
|
263
|
-
}).strict(),
|
|
264
|
-
z.object({
|
|
265
|
-
type: z.literal("composition.apply"),
|
|
266
|
-
composition: BoardCompositionCommandInputSchema
|
|
267
|
-
}).strict(),
|
|
268
|
-
z.object({
|
|
269
|
-
type: z.literal("composition.delete"),
|
|
270
|
-
compositionId: idSchema
|
|
271
|
-
}).strict()
|
|
272
|
-
]);
|
|
273
|
-
const BoardSemanticMutationSchema = z.object({
|
|
274
|
-
mutationId: idSchema,
|
|
275
|
-
baseVersion: z.number().int().nonnegative(),
|
|
276
|
-
clientId: idSchema.optional(),
|
|
277
|
-
undoGroupId: idSchema.optional(),
|
|
278
|
-
/** Validate (including server-side reference checks) without writing. */
|
|
279
|
-
dryRun: z.boolean().default(false),
|
|
280
|
-
commands: z.array(BoardSemanticCommandSchema).min(1).max(5e4)
|
|
281
|
-
}).strict();
|
|
282
|
-
z.object({
|
|
283
|
-
include: z.array(z.enum([
|
|
284
|
-
"items",
|
|
285
|
-
"connections",
|
|
286
|
-
"effects",
|
|
287
|
-
"compositions",
|
|
288
|
-
"playback"
|
|
289
|
-
])).optional(),
|
|
290
|
-
itemIds: z.array(idSchema).max(5e4).optional(),
|
|
291
|
-
connectionIds: z.array(idSchema).max(5e4).optional(),
|
|
292
|
-
effectIds: z.array(idSchema).max(5e4).optional(),
|
|
293
|
-
compositionIds: z.array(idSchema).max(5e4).optional(),
|
|
294
|
-
viewport: z.object({
|
|
295
|
-
x: finiteSchema,
|
|
296
|
-
y: finiteSchema,
|
|
297
|
-
width: finiteSchema.positive(),
|
|
298
|
-
height: finiteSchema.positive()
|
|
299
|
-
}).optional()
|
|
300
|
-
}).strict();
|
|
301
|
-
//#endregion
|
|
302
|
-
export { BOARD_AUTHORING_COLOR_IDS, BOARD_AUTHORING_GEO_KINDS, BoardArrowAuthoringItemSchema, BoardAudioAuthoringItemSchema, BoardAuthoringItemSchema, BoardBuiltinAuthoringItemSchema, BoardDrawAuthoringItemSchema, BoardExtensionAuthoringItemSchema, BoardFileAuthoringItemSchema, BoardFrameAuthoringItemSchema, BoardGeoAuthoringItemSchema, BoardImageAuthoringItemSchema, BoardItemPatchSchema, BoardItemSourceSchema, BoardItemStyleSchema, BoardSemanticCommandSchema, BoardSemanticMutationSchema, BoardTaskAuthoringItemSchema, BoardTextAuthoringItemSchema, BoardVideoAuthoringItemSchema, isSafeBoardSourcePath };
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { BOARD_BUILTIN_CAPABILITIES, BOARD_BUILTIN_CLIP_KINDS, BOARD_BUILTIN_EFFECT_KINDS, DEFAULT_BOARD_RENDER_LIMITS } from "./board-constants.js";
|
|
2
|
-
import { BoardCameraFocusParamsSchema } from "./board.js";
|
|
3
|
-
import { BoardDealParamsSchema } from "./board-animation.js";
|
|
4
|
-
//#region ../protocol/dist/board-capability-registry.js
|
|
5
|
-
const CLIPS = new Set(BOARD_BUILTIN_CLIP_KINDS);
|
|
6
|
-
const EFFECTS = new Set(BOARD_BUILTIN_EFFECT_KINDS);
|
|
7
|
-
const BUILTIN_VERSIONS = new Set(BOARD_BUILTIN_CAPABILITIES.map((c) => `${c.kind}:${c.id}@${c.version}`));
|
|
8
|
-
/**
|
|
9
|
-
* True when a built-in renderer exists for exactly this kind@version. A known
|
|
10
|
-
* kind at an unknown version is not built-in: it must not pass as one.
|
|
11
|
-
*/
|
|
12
|
-
function isBuiltinBoardCapability(kind, id, version) {
|
|
13
|
-
return BUILTIN_VERSIONS.has(`${kind}:${id}@${version}`);
|
|
14
|
-
}
|
|
15
|
-
const record = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
16
|
-
const finite = (value) => typeof value === "number" && Number.isFinite(value);
|
|
17
|
-
function validateBuiltinBoardClip(clip, path = "clip") {
|
|
18
|
-
if (!CLIPS.has(clip.kind)) return [];
|
|
19
|
-
const errors = [];
|
|
20
|
-
const error = (message, suffix, coordinateSpace, code = "INVALID_BOARD_CLIP") => {
|
|
21
|
-
errors.push({
|
|
22
|
-
severity: "error",
|
|
23
|
-
code,
|
|
24
|
-
message,
|
|
25
|
-
path: `${path}.${suffix}`,
|
|
26
|
-
...coordinateSpace ? { coordinateSpace } : {}
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
if ((clip.kind.startsWith("motion.") || clip.kind.startsWith("draw.") || clip.kind === "text.reveal" || clip.kind === "effects.trail") && clip.target.type !== "item") error(`${clip.kind} must target an item`, "target");
|
|
30
|
-
if (clip.kind.startsWith("camera.") && clip.target.type !== "camera") error(`${clip.kind} must target the camera`, "target");
|
|
31
|
-
if (clip.kind === "motion.path") {
|
|
32
|
-
const points = clip.params.points;
|
|
33
|
-
if (!Array.isArray(points) || points.length < 2 || points.length > 1e4) error("motion path must contain 2 to 10000 world-offset points", "params.points", "world-offset");
|
|
34
|
-
else for (const [index, point] of points.entries()) if (!record(point) || !finite(point.x) || !finite(point.y)) error("motion path point must contain finite x and y", `params.points.${index}`, "world-offset");
|
|
35
|
-
}
|
|
36
|
-
if (clip.kind === "effects.particles") {
|
|
37
|
-
const count = clip.params.count;
|
|
38
|
-
if (!Number.isSafeInteger(count) || count < 1 || count > DEFAULT_BOARD_RENDER_LIMITS.particles) error(`particle count must be an integer from 1 to ${DEFAULT_BOARD_RENDER_LIMITS.particles}`, "params.count", void 0, "INVALID_PARTICLE_COUNT");
|
|
39
|
-
const bounds = clip.params.bounds;
|
|
40
|
-
if (!record(bounds) || !finite(bounds.x) || !finite(bounds.y) || !finite(bounds.width) || !finite(bounds.height) || bounds.width <= 0 || bounds.height <= 0) error("particles require positive finite world bounds", "params.bounds", "world", "PARTICLE_BOUNDS_REQUIRED");
|
|
41
|
-
}
|
|
42
|
-
if (clip.kind === "camera.focus") {
|
|
43
|
-
const parsed = BoardCameraFocusParamsSchema.safeParse(clip.params);
|
|
44
|
-
if (!parsed.success) error(parsed.error.issues[0]?.message ?? "invalid camera focus", "params", "world");
|
|
45
|
-
}
|
|
46
|
-
return errors;
|
|
47
|
-
}
|
|
48
|
-
function validateBuiltinBoardEffect(effect, path = "effect") {
|
|
49
|
-
const diagnostics = [];
|
|
50
|
-
if (effect.lifecycle === "on-enter") {
|
|
51
|
-
if (effect.target.type !== "item") diagnostics.push({
|
|
52
|
-
severity: "error",
|
|
53
|
-
code: "INVALID_BOARD_EFFECT",
|
|
54
|
-
message: "on-enter effects must target an item",
|
|
55
|
-
path: `${path}.target`
|
|
56
|
-
});
|
|
57
|
-
if (effect.timeOrigin !== "activation") diagnostics.push({
|
|
58
|
-
severity: "error",
|
|
59
|
-
code: "INVALID_BOARD_EFFECT",
|
|
60
|
-
message: "on-enter effects must use activation time",
|
|
61
|
-
path: `${path}.timeOrigin`
|
|
62
|
-
});
|
|
63
|
-
} else if (EFFECTS.has(effect.kind) && effect.target.type !== "item") diagnostics.push({
|
|
64
|
-
severity: "error",
|
|
65
|
-
code: "INVALID_BOARD_EFFECT",
|
|
66
|
-
message: `${effect.kind} must target an item`,
|
|
67
|
-
path: `${path}.target`
|
|
68
|
-
});
|
|
69
|
-
if (effect.kind === "effects.deal" && effect.kindVersion === 1) {
|
|
70
|
-
if (effect.lifecycle !== "on-enter") diagnostics.push({
|
|
71
|
-
severity: "error",
|
|
72
|
-
code: "INVALID_BOARD_EFFECT",
|
|
73
|
-
message: "effects.deal must use the on-enter lifecycle",
|
|
74
|
-
path: `${path}.lifecycle`
|
|
75
|
-
});
|
|
76
|
-
const parsed = BoardDealParamsSchema.safeParse(effect.params);
|
|
77
|
-
if (!parsed.success) diagnostics.push({
|
|
78
|
-
severity: "error",
|
|
79
|
-
code: "INVALID_BOARD_EFFECT",
|
|
80
|
-
message: parsed.error.issues[0]?.message ?? "invalid effects.deal parameters",
|
|
81
|
-
path: `${path}.params`
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
return diagnostics;
|
|
85
|
-
}
|
|
86
|
-
function estimateBuiltinBoardEffectCost(effect) {
|
|
87
|
-
return isBuiltinBoardCapability("effect", effect.kind, effect.kindVersion) ? { drawCalls: 1 } : {};
|
|
88
|
-
}
|
|
89
|
-
function estimateBuiltinBoardClipCost(clip) {
|
|
90
|
-
switch (clip.kind) {
|
|
91
|
-
case "effects.particles": {
|
|
92
|
-
const count = Number.isSafeInteger(clip.params.count) ? Math.max(0, clip.params.count) : 0;
|
|
93
|
-
return {
|
|
94
|
-
particles: count,
|
|
95
|
-
vertices: count * 4,
|
|
96
|
-
dynamicVertices: count * 4,
|
|
97
|
-
drawCalls: 1,
|
|
98
|
-
bufferBytes: count * 48,
|
|
99
|
-
simulationSteps: count
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
case "effects.trail": return {
|
|
103
|
-
vertices: 32,
|
|
104
|
-
dynamicVertices: 32,
|
|
105
|
-
drawCalls: 1,
|
|
106
|
-
bufferBytes: 1024,
|
|
107
|
-
simulationSteps: 16
|
|
108
|
-
};
|
|
109
|
-
case "effects.impact":
|
|
110
|
-
case "effects.flash": return {
|
|
111
|
-
vertices: 64,
|
|
112
|
-
drawCalls: 1
|
|
113
|
-
};
|
|
114
|
-
case "draw.reveal": return {
|
|
115
|
-
drawCalls: 1,
|
|
116
|
-
dynamicVertices: 1
|
|
117
|
-
};
|
|
118
|
-
case "motion.path": return { simulationSteps: Array.isArray(clip.params.points) ? clip.params.points.length : 0 };
|
|
119
|
-
default: return {};
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
//#endregion
|
|
123
|
-
export { estimateBuiltinBoardClipCost, estimateBuiltinBoardEffectCost, isBuiltinBoardCapability, validateBuiltinBoardClip, validateBuiltinBoardEffect };
|