@enhance-eng/enhance 0.1.17 → 0.1.21

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.
@@ -211,296 +211,10 @@ const restoreCanvasInputSchema = z.object({ canvasId: z.uuid() });
211
211
  const restoreCanvasOutputSchema = z.object({ canvasId: z.uuid() });
212
212
 
213
213
  //#endregion
214
- //#region ../../packages/contract/src/canvas/canvas-css-values.lib.ts
215
- const UNITLESS_PROPERTIES = /* @__PURE__ */ new Set([
216
- "aspect-ratio",
217
- "-webkit-line-clamp",
218
- "line-clamp",
219
- "flex-grow",
220
- "flex-shrink",
221
- "font-weight",
222
- "opacity",
223
- "order",
224
- "z-index",
225
- "grid-area",
226
- "grid-row",
227
- "grid-column",
228
- "grid-row-start",
229
- "grid-row-end",
230
- "grid-column-start",
231
- "grid-column-end"
232
- ]);
233
- const canvasCssValue = (property, value) => typeof value === "number" && !UNITLESS_PROPERTIES.has(property.toLowerCase()) ? `${String(value)}px` : String(value);
234
- const SIDES$1 = [
235
- "top",
236
- "right",
237
- "bottom",
238
- "left"
239
- ];
240
- const LEFT_SIDE_INDEX = 3;
241
- const GRID_TEMPLATE_PROPERTIES = [
242
- "grid-template-rows",
243
- "grid-template-columns",
244
- "grid-template-areas"
245
- ];
246
- const SHORTHANDS = {
247
- gap: ["row-gap", "column-gap"],
248
- padding: SIDES$1.map((side) => `padding-${side}`),
249
- margin: SIDES$1.map((side) => `margin-${side}`),
250
- flex: [
251
- "flex-grow",
252
- "flex-shrink",
253
- "flex-basis"
254
- ],
255
- "flex-flow": ["flex-direction", "flex-wrap"],
256
- "place-content": ["align-content", "justify-content"],
257
- "place-items": ["align-items", "justify-items"],
258
- "place-self": ["align-self", "justify-self"],
259
- "grid-template": GRID_TEMPLATE_PROPERTIES,
260
- grid: [
261
- ...GRID_TEMPLATE_PROPERTIES,
262
- "grid-auto-rows",
263
- "grid-auto-columns",
264
- "grid-auto-flow"
265
- ],
266
- "grid-row": ["grid-row-start", "grid-row-end"],
267
- "grid-column": ["grid-column-start", "grid-column-end"],
268
- "grid-area": [
269
- "grid-row-start",
270
- "grid-column-start",
271
- "grid-row-end",
272
- "grid-column-end"
273
- ]
274
- };
275
- /** Related declarations stay authored; a longhand edit must not discard the rest of a shorthand. */
276
- const canvasCssPropertyScope = (property) => SHORTHANDS[property.toLowerCase()] ?? [property.toLowerCase()];
277
- const componentStateAfter = (state, character) => {
278
- if (state.isEscaped) return {
279
- ...state,
280
- isEscaped: false
281
- };
282
- if (character === "\\") return {
283
- ...state,
284
- isEscaped: true
285
- };
286
- if (state.quote !== "") return {
287
- ...state,
288
- quote: state.quote === character ? "" : state.quote
289
- };
290
- if (["\"", "'"].includes(character)) return {
291
- ...state,
292
- quote: character
293
- };
294
- const delta = [
295
- "(",
296
- "[",
297
- "{"
298
- ].includes(character) ? 1 : [
299
- ")",
300
- "]",
301
- "}"
302
- ].includes(character) ? -1 : 0;
303
- return {
304
- ...state,
305
- depth: state.depth + delta
306
- };
307
- };
308
- /** Split only at CSS component boundaries, keeping functions, line names and strings intact. */
309
- const canvasCssTokens = (value, separator = "space") => {
310
- const tokens = [];
311
- let token = "";
312
- let state = {
313
- depth: 0,
314
- quote: "",
315
- isEscaped: false
316
- };
317
- for (const character of value) {
318
- const canSplit = state.depth === 0 && state.quote === "" && !state.isEscaped;
319
- state = componentStateAfter(state, character);
320
- if (canSplit && (separator === "space" ? /\s/u.test(character) : character === separator)) {
321
- if (separator !== "space" || token !== "") tokens.push(token.trim());
322
- token = "";
323
- } else token += character;
324
- }
325
- if (separator !== "space" || token !== "") tokens.push(token.trim());
326
- return tokens;
327
- };
328
- const omittedGridLine = (value) => /^(?:--|-?[_a-z\u{80}-\u{FFFF}])[-\w\u{80}-\u{FFFF}]*$/iu.test(value) && !/^(?:auto|span|initial|unset)$/iu.test(value) ? value : "auto";
329
- const gridPlacementValue = (property, value, index) => {
330
- const parts = canvasCssTokens(value, "/");
331
- const first = parts[0] ?? value;
332
- if (property !== "grid-area") return parts[index] ?? omittedGridLine(first);
333
- const column = parts[1] ?? omittedGridLine(first);
334
- return [
335
- first,
336
- column,
337
- parts[2] ?? omittedGridLine(first),
338
- parts[3] ?? omittedGridLine(column)
339
- ][index] ?? value;
340
- };
341
- const implicitGridValues = (row, column, hasAutoRows) => {
342
- const tokens = canvasCssTokens(hasAutoRows ? row : column);
343
- const size = tokens.filter((token) => !/^(?:auto-flow|dense)$/iu.test(token)).join(" ");
344
- const flow = `${hasAutoRows ? "row" : "column"}${tokens.some((token) => /^dense$/iu.test(token)) ? " dense" : ""}`;
345
- return [
346
- hasAutoRows ? "none" : row,
347
- hasAutoRows ? column : "none",
348
- "none",
349
- hasAutoRows && size !== "" ? size : "auto",
350
- !hasAutoRows && size !== "" ? size : "auto",
351
- flow
352
- ];
353
- };
354
- const gridTemplateValue = (property, value, index) => {
355
- if (/^(?:none|initial|unset)$/iu.test(value)) return [
356
- "none",
357
- "none",
358
- "none",
359
- "auto",
360
- "auto",
361
- "row"
362
- ][index] ?? value;
363
- const parts = canvasCssTokens(value, "/");
364
- const row = parts[0] ?? value;
365
- const column = parts[1];
366
- if (row === "" || column === "" || parts.length > 2) return value;
367
- const hasAutoRows = canvasCssTokens(row).some((token) => token.toLowerCase() === "auto-flow");
368
- const hasAutoColumns = column !== void 0 && canvasCssTokens(column).some((token) => token.toLowerCase() === "auto-flow");
369
- if (property === "grid" && column !== void 0 && hasAutoRows !== hasAutoColumns) return implicitGridValues(row, column, hasAutoRows)[index] ?? value;
370
- if (hasAutoRows || hasAutoColumns) return value;
371
- const hasAreas = /["']/u.test(row);
372
- if (column === void 0 && !hasAreas) return value;
373
- return [
374
- hasAreas ? value : row,
375
- column ?? "none",
376
- hasAreas ? row : "none",
377
- "auto",
378
- "auto",
379
- "row"
380
- ][index] ?? value;
381
- };
382
- const flexValues = (tokens) => {
383
- const numbers = [];
384
- let basis = "0%";
385
- for (const token of tokens) if (/^(?:\d+(?:\.\d*)?|\.\d+)$/u.test(token) && numbers.length < 2) numbers.push(token);
386
- else basis = token;
387
- return [
388
- numbers[0] ?? "1",
389
- numbers[1] ?? "1",
390
- basis
391
- ];
392
- };
393
- const canvasCssShorthandValue = (property, value, index) => {
394
- if (/(?:var|env)\(|^(?:inherit|revert(?:-layer)?)$/iu.test(value)) return value;
395
- if (/^grid-(?:area|row|column)$/u.test(property)) return gridPlacementValue(property, value, index);
396
- if (property === "grid-template" || property === "grid") return gridTemplateValue(property, value, index);
397
- const tokens = canvasCssTokens(value);
398
- if (property === "flex-flow") return index === 0 ? tokens.find((token) => /^(?:row|column)(?:-reverse)?$/u.test(token)) ?? "row" : tokens.find((token) => /^(?:nowrap|wrap|wrap-reverse)$/u.test(token)) ?? "nowrap";
399
- if (property === "flex") {
400
- if (value === "none") return [
401
- "0",
402
- "0",
403
- "auto"
404
- ][index] ?? value;
405
- if (value === "initial") return [
406
- "0",
407
- "1",
408
- "auto"
409
- ][index] ?? value;
410
- return flexValues(tokens)[index] ?? value;
411
- }
412
- return tokens[index] ?? (index === LEFT_SIDE_INDEX ? tokens[1] : void 0) ?? tokens[0] ?? value;
413
- };
414
-
415
- //#endregion
416
- //#region ../../packages/contract/src/canvas/canvas-authored-css.lib.ts
417
- const canvasAdditionalStyleDeclarations = (node) => {
418
- if (node.additionalStyles === void 0) return {};
419
- return Object.fromEntries(node.additionalStyles.declarations.filter((declaration) => declaration.enabled).map((declaration) => [declaration.property, declaration.value]));
420
- };
421
- /** Additional-style controls exclusively own every property they expose, including when off. */
422
- const canvasAuthoredStyleDeclarations = (node) => {
423
- const controlledProperties = new Set(node.additionalStyles?.declarations.map((declaration) => declaration.property.toLowerCase()));
424
- return {
425
- ...Object.fromEntries(Object.entries(node.styles).filter(([property]) => !controlledProperties.has(property.toLowerCase()))),
426
- ...canvasAdditionalStyleDeclarations(node)
427
- };
428
- };
429
- const hasCanvasCssPriority = (value) => /!important\s*$/iu.test(String(value));
430
- const cssValue = (value, shouldPreserveCase) => {
431
- const source = String(value).replace(/\s*!important\s*$/iu, "").trim();
432
- return shouldPreserveCase || source.includes("(") ? source : source.toLowerCase();
433
- };
434
- /** Read supported authored longhands without measuring or rewriting unresolved CSS expressions. */
435
- const canvasAuthoredLayoutValueOf = (node, property) => {
436
- let result = null;
437
- let isImportant = false;
438
- const declarations = Object.entries(canvasAuthoredStyleDeclarations(node));
439
- for (const [key, raw] of declarations) {
440
- const scope = canvasCssPropertyScope(key);
441
- const index = scope.indexOf(property);
442
- if (index === -1) continue;
443
- const isPriority = hasCanvasCssPriority(raw);
444
- if (isImportant && !isPriority) continue;
445
- const value = cssValue(raw, /^grid(?:-|$)/iu.test(key));
446
- result = scope.length === 1 ? value : canvasCssShorthandValue(key.toLowerCase(), value, index);
447
- isImportant = isPriority;
448
- }
449
- return result ?? void 0;
450
- };
451
- /** Named controls override only their own longhand, even beside an important shorthand. */
452
- const canvasLayoutPriorityDeclarations = (node, declarations) => {
453
- const important = new Set(Object.entries(canvasAuthoredStyleDeclarations(node)).filter(([, value]) => hasCanvasCssPriority(value)).flatMap(([property]) => canvasCssPropertyScope(property)));
454
- return Object.fromEntries(Object.entries(declarations).map(([property, value]) => [property, canvasCssPropertyScope(property).some((owned) => important.has(owned)) && !hasCanvasCssPriority(value) ? `${canvasCssValue(property, value)} !important` : value]));
455
- };
456
- const canvasWritingModeOf = (node, document) => {
457
- const visited = /* @__PURE__ */ new Set();
458
- let current = node;
459
- while (current !== void 0 && !visited.has(current.id)) {
460
- visited.add(current.id);
461
- const value = canvasAuthoredLayoutValueOf(current, "writing-mode");
462
- if (value !== void 0 && value !== "inherit" && value !== "unset") return value;
463
- if (document === void 0) break;
464
- const parentId = document.relationships[current.id]?.parentId;
465
- if (parentId === void 0) break;
466
- current = document.nodes[parentId];
467
- }
468
- return "horizontal-tb";
469
- };
470
- const canvasAxisStyleProperties = (node, axis, document) => {
471
- const isVerticalWriting = /^(?:vertical|sideways)-/u.test(canvasWritingModeOf(node, document));
472
- return [axis === "horizontal" ? "width" : "height", axis === "vertical" === isVerticalWriting ? "inline-size" : "block-size"];
473
- };
474
- /** Authored display wins over legacy presets; Grid has no Flex main axis. */
475
- const canvasLayoutFlowOf = (node) => {
476
- if (node === void 0) return "freeform";
477
- const display = canvasAuthoredLayoutValueOf(node, "display");
478
- if (display !== void 0) {
479
- if (/^(?:(?:inline|block)\s+|inline-)?grid$/u.test(display)) return "grid";
480
- if (/^(?:(?:inline|block)\s+|inline-)?flex$/u.test(display)) return "flex";
481
- return "freeform";
482
- }
483
- const container = node.layout?.container;
484
- if (container === void 0) return "freeform";
485
- return container.gridColumns !== void 0 || container.gridAutoRepeat !== void 0 ? "grid" : "flex";
486
- };
487
- /** Read a Flex main axis in its inherited writing mode without persisting a preset. */
488
- const canvasLayoutMainAxisOf = (node, document) => {
489
- if (node === void 0) return void 0;
490
- if (canvasLayoutFlowOf(node) !== "flex") return void 0;
491
- const container = node.layout?.container;
492
- const css = (property) => canvasAuthoredLayoutValueOf(node, property);
493
- const direction = container?.direction ?? css("flex-direction") ?? "row";
494
- if (!/^(?:row|column)(?:-reverse)?$/u.test(direction)) return void 0;
495
- const isVerticalWriting = /^(?:vertical|sideways)-/u.test(canvasWritingModeOf(node, document));
496
- return direction.startsWith("column") === isVerticalWriting ? "horizontal" : "vertical";
497
- };
498
-
499
- //#endregion
500
- //#region ../../packages/contract/src/canvas/canvas-limits.schema.ts
501
- const MAX_CANVAS_VALUE = 1e5;
502
- const boundedCanvasNumberSchema = z.number().min(-1e5).max(MAX_CANVAS_VALUE);
503
- const nonNegativeCanvasNumberSchema = z.number().nonnegative().max(MAX_CANVAS_VALUE);
214
+ //#region ../../packages/contract/src/canvas/canvas-limits.schema.ts
215
+ const MAX_CANVAS_VALUE = 1e5;
216
+ const boundedCanvasNumberSchema = z.number().min(-1e5).max(MAX_CANVAS_VALUE);
217
+ const nonNegativeCanvasNumberSchema = z.number().nonnegative().max(MAX_CANVAS_VALUE);
504
218
 
505
219
  //#endregion
506
220
  //#region ../../packages/contract/src/canvas/canvas-layout.schema.ts
@@ -612,6 +326,9 @@ const canvasNodeLayoutSchema = z.object({
612
326
  //#endregion
613
327
  //#region ../../packages/contract/src/canvas/canvas-presentation.schema.ts
614
328
  const MAX_ITEM_ID_LENGTH$1 = 200;
329
+ const QUARTER_TURN = 90;
330
+ const HALF_TURN = 180;
331
+ const THREE_QUARTER_TURN = 270;
615
332
  const boundedNumber$1 = boundedCanvasNumberSchema;
616
333
  const nonNegativeNumber$1 = nonNegativeCanvasNumberSchema;
617
334
  const ratio = z.number().min(0).max(1);
@@ -632,6 +349,25 @@ const canvasPointSchema = z.object({
632
349
  x: ratio,
633
350
  y: ratio
634
351
  });
352
+ const adjustment = z.number().min(-1).max(1);
353
+ const canvasImageAdjustmentsSchema = z.object({
354
+ exposure: adjustment.optional(),
355
+ contrast: adjustment.optional(),
356
+ saturation: adjustment.optional(),
357
+ temperature: adjustment.optional(),
358
+ tint: adjustment.optional(),
359
+ highlights: adjustment.optional(),
360
+ shadows: adjustment.optional()
361
+ });
362
+ /** Maps normalized source (u,v) into body (a*u+c*v+e,b*u+d*v+f), before node rotation. */
363
+ const canvasImageTransformSchema = z.tuple([
364
+ boundedNumber$1,
365
+ boundedNumber$1,
366
+ boundedNumber$1,
367
+ boundedNumber$1,
368
+ boundedNumber$1,
369
+ boundedNumber$1
370
+ ]).refine(([a, b, c, d]) => a * d !== b * c, "image transform must be invertible");
635
371
  const canvasPaintBaseSchema = z.object({
636
372
  id: itemId,
637
373
  visible: z.boolean(),
@@ -658,16 +394,30 @@ const canvasPaintSchema = z.discriminatedUnion("kind", [
658
394
  assetId: z.string().min(1).max(500),
659
395
  fit: z.enum([
660
396
  "fill",
397
+ "cover",
661
398
  "fit",
662
399
  "crop",
663
400
  "tile"
664
401
  ]),
402
+ tileScale: boundedNumber$1.positive().optional(),
403
+ tileOrigin: z.enum(["center", "top-left"]).optional(),
404
+ rotation: z.union([
405
+ z.literal(0),
406
+ z.literal(QUARTER_TURN),
407
+ z.literal(HALF_TURN),
408
+ z.literal(THREE_QUARTER_TURN)
409
+ ]).optional(),
665
410
  crop: z.object({
666
411
  x: ratio,
667
412
  y: ratio,
668
413
  width: ratio,
669
414
  height: ratio
670
- }).optional()
415
+ }).optional(),
416
+ transform: canvasImageTransformSchema.optional(),
417
+ adjustments: canvasImageAdjustmentsSchema.optional()
418
+ }).refine((paint) => paint.crop === void 0 || paint.transform === void 0, {
419
+ message: "image paint cannot have both a crop rectangle and an affine transform",
420
+ path: ["transform"]
671
421
  })
672
422
  ]);
673
423
  const canvasCornerRadiusSchema = z.object({
@@ -690,12 +440,7 @@ const canvasBorderSchema = z.object({
690
440
  "dashed",
691
441
  "dotted"
692
442
  ]),
693
- paint: canvasPaintSchema,
694
- alignment: z.enum([
695
- "inside",
696
- "center",
697
- "outside"
698
- ])
443
+ paint: canvasPaintSchema
699
444
  });
700
445
  const canvasOutlineSchema = z.object({
701
446
  visible: z.boolean(),
@@ -827,38 +572,70 @@ const canvasAppearancePatchSchema = z.object({
827
572
  //#region ../../packages/contract/src/canvas/canvas-content-styles.schema.ts
828
573
  const MAX_CANVAS_FONT_FAMILIES = 20;
829
574
  const MAX_CANVAS_FONT_WEIGHT = 1e3;
575
+ const MAX_FONT_AXES = 64;
576
+ const MAX_CANVAS_LIST_LEVEL = 16;
577
+ const MAX_FONT_FEATURES = 128;
578
+ const MAX_FONT_FEATURE_VALUE = 65535;
830
579
  const MAX_ITEM_ID_LENGTH = 200;
831
580
  const MAX_CANVAS_FONT_FAMILY_LENGTH = 500;
832
581
  const MAX_CANVAS_ADDITIONAL_STYLE_VALUE_LENGTH = 1e4;
833
582
  const MAX_CANVAS_ADDITIONAL_STYLES = 128;
834
583
  const boundedNumber = z.number().min(-MAX_CANVAS_VALUE).max(MAX_CANVAS_VALUE);
835
584
  const nonNegativeNumber = z.number().nonnegative().max(MAX_CANVAS_VALUE);
585
+ const fontFeatureTag = z.string().regex(/^[\u{20}-\u{7E}]{4}$/u);
586
+ const fontAxisTag = fontFeatureTag.refine((tag) => !["wght", "opsz"].includes(tag));
836
587
  const canvasTypographySchema = z.object({
837
588
  family: z.string().min(1).max(500),
838
589
  fallbackFamilies: z.array(z.string().min(1).max(500)).max(20),
839
590
  size: nonNegativeNumber,
840
- weight: z.number().int().min(1).max(MAX_CANVAS_FONT_WEIGHT),
591
+ weight: z.number().min(1).max(MAX_CANVAS_FONT_WEIGHT),
592
+ variations: z.record(fontAxisTag, boundedNumber).refine((axes) => Object.keys(axes).length <= MAX_FONT_AXES).optional(),
593
+ features: z.record(fontFeatureTag, z.number().int().nonnegative().max(MAX_FONT_FEATURE_VALUE)).refine((features) => Object.keys(features).length <= MAX_FONT_FEATURES).optional(),
594
+ opticalSize: z.discriminatedUnion("mode", [
595
+ z.object({ mode: z.literal("auto") }),
596
+ z.object({ mode: z.literal("font-default") }),
597
+ z.object({
598
+ mode: z.literal("fixed"),
599
+ value: boundedNumber
600
+ })
601
+ ]).optional(),
841
602
  style: z.enum([
842
603
  "normal",
843
604
  "italic",
844
605
  "oblique"
845
606
  ]),
846
- lineHeight: z.discriminatedUnion("mode", [z.object({ mode: z.literal("normal") }), z.object({
847
- mode: z.literal("fixed"),
848
- value: nonNegativeNumber
607
+ lineHeight: z.discriminatedUnion("mode", [
608
+ z.object({ mode: z.literal("normal") }),
609
+ z.object({
610
+ mode: z.literal("fixed"),
611
+ value: nonNegativeNumber
612
+ }),
613
+ z.object({
614
+ mode: z.literal("percent"),
615
+ value: nonNegativeNumber
616
+ })
617
+ ]),
618
+ letterSpacing: z.union([boundedNumber, z.object({
619
+ mode: z.literal("percent"),
620
+ value: boundedNumber
849
621
  })]),
850
- letterSpacing: boundedNumber,
851
622
  align: z.enum([
852
623
  "left",
853
624
  "center",
854
625
  "right",
855
626
  "justify"
856
627
  ]),
628
+ direction: z.enum([
629
+ "auto",
630
+ "ltr",
631
+ "rtl"
632
+ ]).optional(),
857
633
  verticalAlign: z.enum([
858
634
  "top",
859
635
  "middle",
860
636
  "bottom"
861
637
  ]),
638
+ verticalTrim: z.enum(["none", "cap-height"]).optional(),
862
639
  transform: z.enum([
863
640
  "none",
864
641
  "uppercase",
@@ -879,11 +656,32 @@ const canvasTypographySchema = z.object({
879
656
  "wavy"
880
657
  ]),
881
658
  color: canvasColorSchema.optional(),
882
- thickness: nonNegativeNumber.optional()
659
+ thickness: z.union([
660
+ nonNegativeNumber,
661
+ z.object({
662
+ mode: z.literal("percent"),
663
+ value: nonNegativeNumber
664
+ }),
665
+ z.object({ mode: z.literal("font-default") })
666
+ ]).optional(),
667
+ offset: z.union([boundedNumber, z.object({
668
+ mode: z.literal("percent"),
669
+ value: boundedNumber
670
+ })]).optional(),
671
+ skipInk: z.enum([
672
+ "auto",
673
+ "none",
674
+ "all"
675
+ ]).optional()
883
676
  }),
884
677
  stroke: z.object({
885
678
  width: nonNegativeNumber,
886
- paint: canvasPaintSchema
679
+ paint: canvasPaintSchema,
680
+ alignment: z.enum([
681
+ "inside",
682
+ "center",
683
+ "outside"
684
+ ]).optional()
887
685
  }).optional(),
888
686
  wrapping: z.enum([
889
687
  "wrap",
@@ -893,6 +691,21 @@ const canvasTypographySchema = z.object({
893
691
  "pre-wrap",
894
692
  "break-spaces"
895
693
  ]),
694
+ wrapStyle: z.enum([
695
+ "auto",
696
+ "pretty",
697
+ "balance"
698
+ ]).optional(),
699
+ paragraphSpacing: nonNegativeNumber.optional(),
700
+ paragraphIndent: nonNegativeNumber.optional(),
701
+ listStyle: z.enum([
702
+ "none",
703
+ "bulleted",
704
+ "numbered"
705
+ ]).optional(),
706
+ listSpacing: nonNegativeNumber.optional(),
707
+ hangingList: z.boolean().optional(),
708
+ hangingPunctuation: z.boolean().optional(),
896
709
  truncation: z.object({
897
710
  mode: z.enum(["none", "ellipsis"]),
898
711
  maxLines: z.number().int().min(1).max(MAX_CANVAS_VALUE).nullable()
@@ -904,6 +717,76 @@ const canvasTypographySchema = z.object({
904
717
  left: boundedNumber
905
718
  }).optional()
906
719
  });
720
+ const canvasTextParagraphSchema = canvasTypographySchema.pick({
721
+ align: true,
722
+ direction: true,
723
+ wrapStyle: true,
724
+ paragraphSpacing: true,
725
+ paragraphIndent: true,
726
+ listStyle: true,
727
+ listSpacing: true,
728
+ hangingList: true
729
+ }).partial().extend({
730
+ listLevel: z.number().int().min(1).max(16).optional(),
731
+ listStart: z.number().int().min(1).max(MAX_CANVAS_VALUE).optional()
732
+ }).strict();
733
+ const canvasAuthoredTypographySchema = canvasTypographySchema.partial().strict();
734
+ const CANVAS_TYPOGRAPHY_PROPERTIES = canvasTypographySchema.keyof().options;
735
+ const canvasTypographyPatchSchema = canvasAuthoredTypographySchema.extend({
736
+ featureChanges: z.object({
737
+ set: canvasTypographySchema.shape.features,
738
+ clear: z.array(fontFeatureTag).max(MAX_FONT_FEATURES).optional(),
739
+ removeIfEmpty: z.boolean().optional()
740
+ }).strict().optional(),
741
+ variationChanges: z.object({
742
+ set: canvasTypographySchema.shape.variations,
743
+ clear: z.array(fontAxisTag).max(MAX_FONT_AXES).optional(),
744
+ removeIfEmpty: z.boolean().optional()
745
+ }).strict().optional(),
746
+ clear: z.array(canvasTypographySchema.keyof()).max(CANVAS_TYPOGRAPHY_PROPERTIES.length).optional()
747
+ }).refine((patch) => patch.clear?.every((property) => patch[property] === void 0) ?? true, "a typography property cannot be set and cleared in the same patch").refine((patch) => ["features", "variations"].every((property) => {
748
+ const change = patch[property === "features" ? "featureChanges" : "variationChanges"];
749
+ return change === void 0 || patch[property] === void 0 && patch.clear?.includes(property) !== true && (change.clear?.every((tag) => change.set?.[tag] === void 0) ?? true);
750
+ }), "font settings cannot be replaced and patched, or set and cleared, together");
751
+ const CANVAS_TYPOGRAPHY_CSS_OWNERS = {
752
+ "font-family": ["family", "fallbackFamilies"],
753
+ "font-size": ["size"],
754
+ "font-weight": ["weight"],
755
+ "font-variation-settings": [
756
+ "weight",
757
+ "variations",
758
+ "opticalSize"
759
+ ],
760
+ "font-optical-sizing": ["opticalSize"],
761
+ "font-feature-settings": ["features"],
762
+ "font-style": ["style"],
763
+ "line-height": ["lineHeight"],
764
+ "letter-spacing": ["letterSpacing"],
765
+ "text-align": ["align"],
766
+ direction: ["direction"],
767
+ "unicode-bidi": ["direction"],
768
+ "text-indent": ["paragraphIndent"],
769
+ "hanging-punctuation": ["hangingPunctuation"],
770
+ "align-content": ["verticalAlign"],
771
+ "text-box": ["verticalTrim"],
772
+ "text-box-trim": ["verticalTrim"],
773
+ "text-box-edge": ["verticalTrim"],
774
+ "text-transform": ["transform"],
775
+ "text-decoration": ["decoration"],
776
+ "text-decoration-line": ["decoration"],
777
+ "text-decoration-style": ["decoration"],
778
+ "text-decoration-color": ["decoration"],
779
+ "text-decoration-thickness": ["decoration"],
780
+ "text-underline-offset": ["decoration"],
781
+ "text-decoration-skip-ink": ["decoration"],
782
+ "-webkit-text-stroke": ["stroke"],
783
+ "-webkit-text-stroke-width": ["stroke"],
784
+ "-webkit-text-stroke-color": ["stroke"],
785
+ "--canvas-text-stroke-alignment": ["stroke"],
786
+ "white-space": ["wrapping"],
787
+ "text-wrap-style": ["wrapStyle"],
788
+ "text-wrap": ["wrapStyle"]
789
+ };
907
790
  const unsafeStyleValue = /javascript|vbscript|data\s*:\s*text\/html|expression\s*\(|@import/iu;
908
791
  const blockedStyleProperty = /^(?:behavior|-moz-binding)$/iu;
909
792
  const canvasAdditionalStylePropertySchema = z.string().min(1).max(MAX_ITEM_ID_LENGTH).regex(/^(?:--[\w-]+|-(?:webkit|moz|ms|o)-[a-z][a-z\d-]*|[a-z][a-z\d-]*)$/iu).refine((property) => !blockedStyleProperty.test(property), "unsafe CSS property");
@@ -917,195 +800,787 @@ const canvasAdditionalStyleSchema = z.object({
917
800
  const canvasAdditionalStylesSchema = z.object({ declarations: z.array(canvasAdditionalStyleSchema).max(128) }).refine(({ declarations }) => new Set(declarations.map((declaration) => declaration.id)).size === declarations.length, "additional style ids must be unique");
918
801
 
919
802
  //#endregion
920
- //#region ../../packages/contract/src/canvas/canvas-scene.schema.ts
921
- const MAX_SCENE_NODE_ID_LENGTH = 200;
922
- const MAX_SCENE_LABEL_LENGTH = 500;
923
- const MAX_SCENE_COMPONENT_LENGTH = 100;
924
- const MAX_SCENE_SORT_KEY_LENGTH = 500;
925
- const CANVAS_SCENE_VERSION = 3;
926
- const canvasDocumentFormatSchema = z.literal(3, { error: "This editor uses an unsupported document format. Update the editor before changing this canvas." });
927
- const canvasSceneBoxSchema = z.object({
928
- x: z.number(),
929
- y: z.number(),
930
- width: z.number().nonnegative(),
931
- height: z.number().nonnegative()
932
- });
933
- const canvasConstraintSchema = z.enum([
934
- "start",
935
- "center",
936
- "end",
937
- "stretch",
938
- "scale"
939
- ]);
940
- const canvasNodeConstraintsSchema = z.object({
941
- x: canvasConstraintSchema,
942
- y: canvasConstraintSchema
943
- });
944
- const canvasNodeLabelOriginSchema = z.enum([
945
- "source",
946
- "generated",
947
- "user"
803
+ //#region ../../packages/contract/src/canvas/canvas-additional-style-patch.schema.ts
804
+ const identifiers = z.array(canvasAdditionalStyleSchema.shape.id).max(128).refine((ids) => new Set(ids).size === ids.length, "declaration ids must be unique");
805
+ const canvasAdditionalStylePatchSchema = z.object({
806
+ set: z.array(canvasAdditionalStyleSchema).max(128).refine((items) => new Set(items.map((item) => item.id)).size === items.length, "declaration ids must be unique").optional(),
807
+ clear: identifiers.optional(),
808
+ order: identifiers.optional(),
809
+ empty: z.enum(["keep", "remove"]).optional()
810
+ }).strict().refine((patch) => patch.set?.every((item) => patch.clear?.includes(item.id) !== true) ?? true, "a declaration cannot be set and cleared in the same patch");
811
+
812
+ //#endregion
813
+ //#region ../../packages/contract/src/canvas/canvas-css-values.lib.ts
814
+ const UNITLESS_PROPERTIES = /* @__PURE__ */ new Set([
815
+ "aspect-ratio",
816
+ "-webkit-line-clamp",
817
+ "line-clamp",
818
+ "flex-grow",
819
+ "flex-shrink",
820
+ "font-weight",
821
+ "opacity",
822
+ "order",
823
+ "z-index",
824
+ "grid-area",
825
+ "grid-row",
826
+ "grid-column",
827
+ "grid-row-start",
828
+ "grid-row-end",
829
+ "grid-column-start",
830
+ "grid-column-end"
948
831
  ]);
949
- const canvasSceneNodeSchema = z.looseObject({
950
- id: z.string().min(1).max(MAX_SCENE_NODE_ID_LENGTH),
951
- label: z.string().max(MAX_SCENE_LABEL_LENGTH),
952
- component: z.string().min(1).max(MAX_SCENE_COMPONENT_LENGTH),
953
- labelOrigin: canvasNodeLabelOriginSchema.optional(),
954
- visible: z.boolean().optional(),
955
- locked: z.boolean().optional(),
956
- constraints: canvasNodeConstraintsSchema.optional(),
957
- styles: z.record(z.string(), z.union([z.string(), z.number()])),
958
- layout: canvasNodeLayoutSchema.optional(),
959
- responsive: z.never().optional(),
960
- appearance: canvasAppearanceValuesSchema.optional(),
961
- typography: canvasTypographySchema.optional(),
962
- additionalStyles: canvasAdditionalStylesSchema.optional(),
963
- props: z.record(z.string(), z.unknown()).optional(),
964
- box: canvasSceneBoxSchema.optional()
965
- });
966
- const canvasSceneDocumentSchema = z.object({
967
- version: z.literal(3),
968
- nodes: z.record(z.string(), canvasSceneNodeSchema),
969
- relationships: z.record(z.string(), z.object({
970
- parentId: z.string().min(1).max(MAX_SCENE_NODE_ID_LENGTH),
971
- sortKey: z.string().min(1).max(MAX_SCENE_SORT_KEY_LENGTH)
972
- })),
973
- tombstones: z.record(z.string(), z.literal(true)).default({})
974
- });
975
- const legacyRecordSchema = z.record(z.string(), z.unknown());
976
- const legacyNode = (node) => {
977
- const layout = legacyRecordSchema.safeParse(node["layout"]).data;
978
- if (layout === void 0) return node;
979
- const next = Object.fromEntries(Object.entries(layout).filter(([key]) => key !== "gridTrack"));
980
- const container = legacyRecordSchema.safeParse(next["container"]).data;
981
- if (container !== void 0) next["container"] = Object.fromEntries(Object.entries(container).filter(([key]) => key !== "materialized"));
982
- for (const axis of ["horizontal", "vertical"]) {
983
- const intent = legacyRecordSchema.safeParse(next[axis]).data;
984
- if (intent?.["mode"] === "hug") next[axis] = Object.fromEntries(Object.entries(intent).filter(([key]) => key !== "basis"));
985
- }
832
+ const canvasCssValue = (property, value) => typeof value === "number" && !UNITLESS_PROPERTIES.has(property.toLowerCase()) ? `${String(value)}px` : String(value);
833
+ const SIDES$1 = [
834
+ "top",
835
+ "right",
836
+ "bottom",
837
+ "left"
838
+ ];
839
+ const LEFT_SIDE_INDEX = 3;
840
+ const GRID_TEMPLATE_PROPERTIES = [
841
+ "grid-template-rows",
842
+ "grid-template-columns",
843
+ "grid-template-areas"
844
+ ];
845
+ const SHORTHANDS = {
846
+ gap: ["row-gap", "column-gap"],
847
+ "text-wrap": ["text-wrap-mode", "text-wrap-style"],
848
+ padding: SIDES$1.map((side) => `padding-${side}`),
849
+ margin: SIDES$1.map((side) => `margin-${side}`),
850
+ flex: [
851
+ "flex-grow",
852
+ "flex-shrink",
853
+ "flex-basis"
854
+ ],
855
+ "flex-flow": ["flex-direction", "flex-wrap"],
856
+ "place-content": ["align-content", "justify-content"],
857
+ "place-items": ["align-items", "justify-items"],
858
+ "place-self": ["align-self", "justify-self"],
859
+ "grid-template": GRID_TEMPLATE_PROPERTIES,
860
+ grid: [
861
+ ...GRID_TEMPLATE_PROPERTIES,
862
+ "grid-auto-rows",
863
+ "grid-auto-columns",
864
+ "grid-auto-flow"
865
+ ],
866
+ "grid-row": ["grid-row-start", "grid-row-end"],
867
+ "grid-column": ["grid-column-start", "grid-column-end"],
868
+ "grid-area": [
869
+ "grid-row-start",
870
+ "grid-column-start",
871
+ "grid-row-end",
872
+ "grid-column-end"
873
+ ]
874
+ };
875
+ /** Related declarations stay authored; a longhand edit must not discard the rest of a shorthand. */
876
+ const canvasCssPropertyScope = (property) => SHORTHANDS[property.toLowerCase()] ?? [property.toLowerCase()];
877
+ const componentStateAfter = (state, character) => {
878
+ if (state.isEscaped) return {
879
+ ...state,
880
+ isEscaped: false
881
+ };
882
+ if (character === "\\") return {
883
+ ...state,
884
+ isEscaped: true
885
+ };
886
+ if (state.quote !== "") return {
887
+ ...state,
888
+ quote: state.quote === character ? "" : state.quote
889
+ };
890
+ if (["\"", "'"].includes(character)) return {
891
+ ...state,
892
+ quote: character
893
+ };
894
+ const delta = [
895
+ "(",
896
+ "[",
897
+ "{"
898
+ ].includes(character) ? 1 : [
899
+ ")",
900
+ "]",
901
+ "}"
902
+ ].includes(character) ? -1 : 0;
986
903
  return {
987
- ...node,
988
- layout: next
904
+ ...state,
905
+ depth: state.depth + delta
989
906
  };
990
907
  };
991
- const legacyDocument = (blob) => {
992
- if (Object.keys(blob).length === 0) return emptyCanvasSceneDocument();
993
- const nodes = z.record(z.string(), legacyRecordSchema).safeParse(blob["nodes"]).data;
994
- if (nodes === void 0) return blob;
995
- return {
996
- ...blob,
997
- version: 3,
998
- nodes: Object.fromEntries(Object.entries(nodes).map(([id, node]) => [id, legacyNode(node)]))
908
+ /** Split only at CSS component boundaries, keeping functions, line names and strings intact. */
909
+ const canvasCssTokens = (value, separator = "space") => {
910
+ const tokens = [];
911
+ let token = "";
912
+ let state = {
913
+ depth: 0,
914
+ quote: "",
915
+ isEscaped: false
999
916
  };
917
+ for (const character of value) {
918
+ const canSplit = state.depth === 0 && state.quote === "" && !state.isEscaped;
919
+ state = componentStateAfter(state, character);
920
+ if (canSplit && (separator === "space" ? /\s/u.test(character) : character === separator)) {
921
+ if (separator !== "space" || token !== "") tokens.push(token.trim());
922
+ token = "";
923
+ } else token += character;
924
+ }
925
+ if (separator !== "space" || token !== "") tokens.push(token.trim());
926
+ return tokens;
927
+ };
928
+ const omittedGridLine = (value) => /^(?:--|-?[_a-z\u{80}-\u{FFFF}])[-\w\u{80}-\u{FFFF}]*$/iu.test(value) && !/^(?:auto|span|initial|unset)$/iu.test(value) ? value : "auto";
929
+ const gridPlacementValue = (property, value, index) => {
930
+ const parts = canvasCssTokens(value, "/");
931
+ const first = parts[0] ?? value;
932
+ if (property !== "grid-area") return parts[index] ?? omittedGridLine(first);
933
+ const column = parts[1] ?? omittedGridLine(first);
934
+ return [
935
+ first,
936
+ column,
937
+ parts[2] ?? omittedGridLine(first),
938
+ parts[3] ?? omittedGridLine(column)
939
+ ][index] ?? value;
940
+ };
941
+ const implicitGridValues = (row, column, hasAutoRows) => {
942
+ const tokens = canvasCssTokens(hasAutoRows ? row : column);
943
+ const size = tokens.filter((token) => !/^(?:auto-flow|dense)$/iu.test(token)).join(" ");
944
+ const flow = `${hasAutoRows ? "row" : "column"}${tokens.some((token) => /^dense$/iu.test(token)) ? " dense" : ""}`;
945
+ return [
946
+ hasAutoRows ? "none" : row,
947
+ hasAutoRows ? column : "none",
948
+ "none",
949
+ hasAutoRows && size !== "" ? size : "auto",
950
+ !hasAutoRows && size !== "" ? size : "auto",
951
+ flow
952
+ ];
953
+ };
954
+ const gridTemplateValue = (property, value, index) => {
955
+ if (/^(?:none|initial|unset)$/iu.test(value)) return [
956
+ "none",
957
+ "none",
958
+ "none",
959
+ "auto",
960
+ "auto",
961
+ "row"
962
+ ][index] ?? value;
963
+ const parts = canvasCssTokens(value, "/");
964
+ const row = parts[0] ?? value;
965
+ const column = parts[1];
966
+ if (row === "" || column === "" || parts.length > 2) return value;
967
+ const hasAutoRows = canvasCssTokens(row).some((token) => token.toLowerCase() === "auto-flow");
968
+ const hasAutoColumns = column !== void 0 && canvasCssTokens(column).some((token) => token.toLowerCase() === "auto-flow");
969
+ if (property === "grid" && column !== void 0 && hasAutoRows !== hasAutoColumns) return implicitGridValues(row, column, hasAutoRows)[index] ?? value;
970
+ if (hasAutoRows || hasAutoColumns) return value;
971
+ const hasAreas = /["']/u.test(row);
972
+ if (column === void 0 && !hasAreas) return value;
973
+ return [
974
+ hasAreas ? value : row,
975
+ column ?? "none",
976
+ hasAreas ? row : "none",
977
+ "auto",
978
+ "auto",
979
+ "row"
980
+ ][index] ?? value;
981
+ };
982
+ const flexValues = (tokens) => {
983
+ const numbers = [];
984
+ let basis = "0%";
985
+ for (const token of tokens) if (/^(?:\d+(?:\.\d*)?|\.\d+)$/u.test(token) && numbers.length < 2) numbers.push(token);
986
+ else basis = token;
987
+ return [
988
+ numbers[0] ?? "1",
989
+ numbers[1] ?? "1",
990
+ basis
991
+ ];
992
+ };
993
+ const canvasCssShorthandValue = (property, value, index) => {
994
+ if (/(?:var|env)\(|^(?:inherit|revert(?:-layer)?)$/iu.test(value)) return value;
995
+ if (/^grid-(?:area|row|column)$/u.test(property)) return gridPlacementValue(property, value, index);
996
+ if (property === "grid-template" || property === "grid") return gridTemplateValue(property, value, index);
997
+ const tokens = canvasCssTokens(value);
998
+ if (property === "text-wrap") return index === 0 ? tokens.find((token) => /^(?:wrap|nowrap)$/u.test(token)) ?? "wrap" : tokens.find((token) => /^(?:auto|balance|pretty|stable)$/u.test(token)) ?? "auto";
999
+ if (property === "flex-flow") return index === 0 ? tokens.find((token) => /^(?:row|column)(?:-reverse)?$/u.test(token)) ?? "row" : tokens.find((token) => /^(?:nowrap|wrap|wrap-reverse)$/u.test(token)) ?? "nowrap";
1000
+ if (property === "flex") {
1001
+ if (value === "none") return [
1002
+ "0",
1003
+ "0",
1004
+ "auto"
1005
+ ][index] ?? value;
1006
+ if (value === "initial") return [
1007
+ "0",
1008
+ "1",
1009
+ "auto"
1010
+ ][index] ?? value;
1011
+ return flexValues(tokens)[index] ?? value;
1012
+ }
1013
+ return tokens[index] ?? (index === LEFT_SIDE_INDEX ? tokens[1] : void 0) ?? tokens[0] ?? value;
1000
1014
  };
1001
- /** Known old scenes are adapted in memory; only an explicit mutation persists the new format. */
1002
- const canvasReadableSceneDocumentSchema = z.preprocess((value) => {
1003
- const blob = legacyRecordSchema.safeParse(value).data;
1004
- if (blob === void 0) return value;
1005
- const version = blob["version"];
1006
- return (/* @__PURE__ */ new Set([
1007
- void 0,
1008
- 1,
1009
- 2
1010
- ])).has(version) ? legacyDocument(blob) : blob;
1011
- }, canvasSceneDocumentSchema);
1012
- const emptyCanvasSceneDocument = () => ({
1013
- version: 3,
1014
- nodes: { root: {
1015
- id: "root",
1016
- label: "Canvas",
1017
- component: "root",
1018
- labelOrigin: "generated",
1019
- visible: true,
1020
- locked: false,
1021
- styles: {}
1022
- } },
1023
- relationships: {},
1024
- tombstones: {}
1025
- });
1026
1015
 
1027
1016
  //#endregion
1028
- //#region ../../packages/contract/src/canvas/canvas-conversion-draft.schema.ts
1029
- const MAX_CANVAS_CONVERSION_NODES = 3e4;
1030
- const MAX_CANVAS_CONVERSION_SOURCE_NODES = 5e4;
1031
- const MAX_CANVAS_CONVERSION_ID_LENGTH = 200;
1032
- const MAX_CANVAS_CONVERSION_TEXT_LENGTH = 500;
1033
- const MAX_CANVAS_HTML_SOURCE_LENGTH = 262144;
1034
- const temporaryIdSchema = z.string().min(1).max(200);
1035
- const canvasConversionIssueSchema = z.object({
1036
- code: z.enum([
1037
- "asset-unavailable",
1038
- "content-omitted",
1039
- "cross-origin-frame",
1040
- "nodes-truncated",
1041
- "responsive-behavior-not-editable",
1042
- "style-degraded",
1043
- "unsupported-surface"
1044
- ]),
1045
- message: z.string().min(1).max(500),
1046
- temporaryId: temporaryIdSchema.optional()
1047
- });
1048
- const canvasConversionReportSchema = z.object({
1049
- nodeCount: z.number().int().positive().max(MAX_CANVAS_CONVERSION_NODES),
1050
- sourceNodeCount: z.number().int().positive().max(MAX_CANVAS_CONVERSION_SOURCE_NODES).optional(),
1051
- collapsedNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES).optional(),
1052
- collapsedWrapperNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES).optional(),
1053
- collapsedNeutralWrapperNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES).optional(),
1054
- collapsedTransferredWrapperNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES).optional(),
1055
- layoutContainerCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_NODES).optional(),
1056
- removedLeafNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES).optional(),
1057
- retainedSemanticOwnerNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES).optional(),
1058
- truncatedNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES * 2).optional(),
1059
- addedLayoutNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES).optional(),
1060
- issues: z.array(canvasConversionIssueSchema).max(MAX_CANVAS_CONVERSION_SOURCE_NODES)
1061
- }).refine(({ collapsedNeutralWrapperNodeCount, collapsedTransferredWrapperNodeCount, collapsedWrapperNodeCount }) => collapsedWrapperNodeCount === void 0 || collapsedNeutralWrapperNodeCount === void 0 || collapsedTransferredWrapperNodeCount === void 0 || collapsedNeutralWrapperNodeCount + collapsedTransferredWrapperNodeCount === collapsedWrapperNodeCount, "wrapper collapse proof classes must explain the collapsed wrapper count").refine(({ collapsedNodeCount, collapsedWrapperNodeCount, removedLeafNodeCount }) => collapsedNodeCount === void 0 || collapsedWrapperNodeCount === void 0 || removedLeafNodeCount === void 0 || collapsedWrapperNodeCount + removedLeafNodeCount === collapsedNodeCount, "collapsed node kinds must explain the total collapsed node count").refine(({ addedLayoutNodeCount, collapsedNodeCount, nodeCount, sourceNodeCount, truncatedNodeCount }) => sourceNodeCount === void 0 || collapsedNodeCount === void 0 || sourceNodeCount + (addedLayoutNodeCount ?? 0) - nodeCount === collapsedNodeCount + (truncatedNodeCount ?? 0), "added, collapsed and truncated node counts must explain the source to editable difference").refine(({ layoutContainerCount, nodeCount }) => layoutContainerCount === void 0 || layoutContainerCount <= nodeCount, "layout container count cannot exceed editable node count");
1062
- const canvasSubtreeDraftNodeSchema = canvasSceneNodeSchema.omit({ id: true }).extend({ temporaryId: temporaryIdSchema });
1063
- const canvasSubtreeDraftRelationshipSchema = z.object({
1064
- temporaryId: temporaryIdSchema,
1065
- parentTemporaryId: temporaryIdSchema,
1066
- sortKey: z.string().min(1).max(500)
1067
- });
1068
- const canvasSubtreeDraftSchema = z.object({
1069
- version: z.literal(1),
1070
- rootTemporaryId: temporaryIdSchema,
1071
- nodes: z.array(canvasSubtreeDraftNodeSchema).min(1).max(MAX_CANVAS_CONVERSION_NODES),
1072
- relationships: z.array(canvasSubtreeDraftRelationshipSchema).max(MAX_CANVAS_CONVERSION_NODES - 1),
1073
- report: canvasConversionReportSchema
1074
- });
1075
- const createEditableFrameInputSchema = z.object({
1076
- canvasId: z.uuid(),
1077
- documentFormatVersion: canvasDocumentFormatSchema,
1078
- mutationId: z.uuid(),
1079
- baseVersion: z.number().int().positive(),
1080
- screenNodeId: z.string().min(1).max(200),
1081
- draft: canvasSubtreeDraftSchema
1082
- });
1083
- const createEditableFrameResultSchema = z.object({
1084
- canvasId: z.uuid(),
1085
- mutationId: z.uuid(),
1086
- previousVersion: z.number().int().positive(),
1087
- version: z.number().int().positive(),
1088
- rootNodeId: z.string().min(1).max(200),
1089
- idMap: z.record(temporaryIdSchema, z.string().min(1).max(200)),
1090
- insertedNodeIds: z.array(z.string().min(1).max(200)),
1091
- removedNodeIds: z.array(z.string().min(1).max(200)),
1092
- boxes: z.record(z.string().min(1).max(200), canvasSceneBoxSchema),
1093
- affectedBounds: canvasSceneBoxSchema
1094
- });
1017
+ //#region ../../packages/contract/src/canvas/canvas-authored-css.lib.ts
1018
+ const canvasAdditionalStyleDeclarations = (node) => {
1019
+ if (node.additionalStyles === void 0) return {};
1020
+ return Object.fromEntries(node.additionalStyles.declarations.filter((declaration) => declaration.enabled).map((declaration) => [declaration.property, declaration.value]));
1021
+ };
1022
+ /** Additional-style controls exclusively own every property they expose, including when off. */
1023
+ const canvasAuthoredStyleDeclarations = (node) => {
1024
+ const controlledProperties = new Set(node.additionalStyles?.declarations.map((declaration) => declaration.property.toLowerCase()));
1025
+ return {
1026
+ ...Object.fromEntries(Object.entries(node.styles).filter(([property]) => !controlledProperties.has(property.toLowerCase()))),
1027
+ ...canvasAdditionalStyleDeclarations(node)
1028
+ };
1029
+ };
1030
+ const hasCanvasCssPriority = (value) => /!important\s*$/iu.test(String(value));
1031
+ const cssValue = (value, shouldPreserveCase) => {
1032
+ const source = String(value).replace(/\s*!important\s*$/iu, "").trim();
1033
+ return shouldPreserveCase || source.includes("(") ? source : source.toLowerCase();
1034
+ };
1035
+ /** Read supported authored longhands without measuring or rewriting unresolved CSS expressions. */
1036
+ const canvasAuthoredLayoutValueOf = (node, property) => {
1037
+ let result = null;
1038
+ let isImportant = false;
1039
+ const declarations = Object.entries(canvasAuthoredStyleDeclarations(node));
1040
+ for (const [key, raw] of declarations) {
1041
+ const scope = canvasCssPropertyScope(key);
1042
+ const index = scope.indexOf(property);
1043
+ if (index === -1) continue;
1044
+ const isPriority = hasCanvasCssPriority(raw);
1045
+ if (isImportant && !isPriority) continue;
1046
+ const value = cssValue(raw, /^grid(?:-|$)/iu.test(key));
1047
+ result = scope.length === 1 ? value : canvasCssShorthandValue(key.toLowerCase(), value, index);
1048
+ isImportant = isPriority;
1049
+ }
1050
+ return result ?? void 0;
1051
+ };
1052
+ /** Named controls override only their own longhand, even beside an important shorthand. */
1053
+ const canvasLayoutPriorityDeclarations = (node, declarations) => {
1054
+ const important = new Set(Object.entries(canvasAuthoredStyleDeclarations(node)).filter(([, value]) => hasCanvasCssPriority(value)).flatMap(([property]) => canvasCssPropertyScope(property)));
1055
+ return Object.fromEntries(Object.entries(declarations).map(([property, value]) => [property, canvasCssPropertyScope(property).some((owned) => important.has(owned)) && !hasCanvasCssPriority(value) ? `${canvasCssValue(property, value)} !important` : value]));
1056
+ };
1057
+ const canvasWritingModeOf = (node, document) => {
1058
+ const visited = /* @__PURE__ */ new Set();
1059
+ let current = node;
1060
+ while (current !== void 0 && !visited.has(current.id)) {
1061
+ visited.add(current.id);
1062
+ const value = canvasAuthoredLayoutValueOf(current, "writing-mode");
1063
+ if (value !== void 0 && value !== "inherit" && value !== "unset") return value;
1064
+ if (document === void 0) break;
1065
+ const parentId = document.relationships[current.id]?.parentId;
1066
+ if (parentId === void 0) break;
1067
+ current = document.nodes[parentId];
1068
+ }
1069
+ return "horizontal-tb";
1070
+ };
1071
+ const canvasAxisStyleProperties = (node, axis, document) => {
1072
+ const isVerticalWriting = /^(?:vertical|sideways)-/u.test(canvasWritingModeOf(node, document));
1073
+ return [axis === "horizontal" ? "width" : "height", axis === "vertical" === isVerticalWriting ? "inline-size" : "block-size"];
1074
+ };
1075
+ /** Authored display wins over legacy presets; Grid has no Flex main axis. */
1076
+ const canvasLayoutFlowOf = (node) => {
1077
+ if (node === void 0) return "freeform";
1078
+ const display = canvasAuthoredLayoutValueOf(node, "display");
1079
+ if (display !== void 0) {
1080
+ if (/^(?:(?:inline|block)\s+|inline-)?grid$/u.test(display)) return "grid";
1081
+ if (/^(?:(?:inline|block)\s+|inline-)?flex$/u.test(display)) return "flex";
1082
+ return "freeform";
1083
+ }
1084
+ const container = node.layout?.container;
1085
+ if (container === void 0) return "freeform";
1086
+ return container.gridColumns !== void 0 || container.gridAutoRepeat !== void 0 ? "grid" : "flex";
1087
+ };
1088
+ /** Read a Flex main axis in its inherited writing mode without persisting a preset. */
1089
+ const canvasLayoutMainAxisOf = (node, document) => {
1090
+ if (node === void 0) return void 0;
1091
+ if (canvasLayoutFlowOf(node) !== "flex") return void 0;
1092
+ const container = node.layout?.container;
1093
+ const css = (property) => canvasAuthoredLayoutValueOf(node, property);
1094
+ const direction = container?.direction ?? css("flex-direction") ?? "row";
1095
+ if (!/^(?:row|column)(?:-reverse)?$/u.test(direction)) return void 0;
1096
+ const isVerticalWriting = /^(?:vertical|sideways)-/u.test(canvasWritingModeOf(node, document));
1097
+ return direction.startsWith("column") === isVerticalWriting ? "horizontal" : "vertical";
1098
+ };
1095
1099
 
1096
1100
  //#endregion
1097
- //#region ../../packages/contract/src/shared/blob.schema.ts
1098
- /**
1099
- * The two-phase upload, seen from the client. The bytes never pass through the API: it hands
1100
- * back a URL S3 will accept, and the client PUTs to it directly.
1101
- */
1102
- const signedUploadSchema = z.object({
1103
- url: z.url(),
1104
- expiresAt: z.iso.datetime(),
1105
- /** Signed into the URL, so a client that omits one gets a 403 from S3, not from us. */
1106
- headers: z.record(z.string(), z.string())
1107
- });
1108
- const signedDownloadSchema = z.object({
1101
+ //#region ../../packages/contract/src/canvas/canvas-text-style.schema.ts
1102
+ const MAX_STYLE_ID = 200;
1103
+ const MAX_DESCRIPTION$1 = 2e3;
1104
+ const MAX_OVERRIDE_VALUE = 1e3;
1105
+ const canvasTextStyleTypographySchema = canvasTypographySchema.pick({
1106
+ family: true,
1107
+ fallbackFamilies: true,
1108
+ size: true,
1109
+ weight: true,
1110
+ style: true,
1111
+ variations: true,
1112
+ opticalSize: true,
1113
+ features: true,
1114
+ lineHeight: true,
1115
+ letterSpacing: true,
1116
+ transform: true,
1117
+ decoration: true,
1118
+ paragraphSpacing: true,
1119
+ paragraphIndent: true,
1120
+ listSpacing: true,
1121
+ hangingList: true,
1122
+ hangingPunctuation: true,
1123
+ verticalTrim: true,
1124
+ wrapStyle: true
1125
+ }).strict();
1126
+ const CANVAS_TEXT_STYLE_PROPERTIES = canvasTextStyleTypographySchema.keyof().options;
1127
+ const canvasTextStyleSchema = z.object({
1128
+ id: z.string().min(1).max(MAX_STYLE_ID),
1129
+ name: z.string().trim().min(1).max(MAX_STYLE_ID),
1130
+ description: z.string().max(MAX_DESCRIPTION$1),
1131
+ sortKey: z.string().min(1).max(MAX_STYLE_ID).optional(),
1132
+ sourceStyleId: z.string().min(1).max(MAX_STYLE_ID).optional(),
1133
+ sourceCanvasId: z.uuid().optional(),
1134
+ sourceRevision: z.number().int().positive().optional(),
1135
+ typography: canvasTextStyleTypographySchema.extend({ listStyle: canvasTypographySchema.shape.listStyle }).transform((typography) => {
1136
+ Reflect.deleteProperty(typography, "listStyle");
1137
+ return typography;
1138
+ })
1139
+ }).strict().refine((style) => style.sourceCanvasId === void 0 || style.sourceStyleId !== void 0, {
1140
+ message: "A source canvas belongs to a reference snapshot.",
1141
+ path: ["sourceCanvasId"]
1142
+ }).refine((style) => style.sourceRevision === void 0 || style.sourceCanvasId !== void 0 && style.sourceStyleId !== void 0, {
1143
+ message: "A published revision belongs to a source style and canvas.",
1144
+ path: ["sourceRevision"]
1145
+ });
1146
+ const canvasTextStyleBindingSchema = z.object({
1147
+ id: canvasTextStyleSchema.shape.id,
1148
+ position: z.enum([
1149
+ "normal",
1150
+ "subscript",
1151
+ "superscript"
1152
+ ]).optional(),
1153
+ overrides: z.partialRecord(z.enum([
1154
+ "fontWeight",
1155
+ "fontStyle",
1156
+ "fontVariationSettings",
1157
+ "fontOpticalSizing",
1158
+ "textDecorationLine",
1159
+ "textDecorationStyle",
1160
+ "textDecorationColor",
1161
+ "textDecorationThickness",
1162
+ "textUnderlineOffset",
1163
+ "textDecorationSkipInk"
1164
+ ]), z.union([z.string().max(MAX_OVERRIDE_VALUE), z.number()])).optional()
1165
+ }).strict();
1166
+
1167
+ //#endregion
1168
+ //#region ../../packages/contract/src/canvas/canvas-rich-text.lib.ts
1169
+ const ALLOWED_STYLE_PROPERTIES = /* @__PURE__ */ new Set([
1170
+ "alignItems",
1171
+ "backgroundColor",
1172
+ "borderBottom",
1173
+ "borderBottomLeftRadius",
1174
+ "borderBottomRightRadius",
1175
+ "borderLeft",
1176
+ "borderRight",
1177
+ "borderTop",
1178
+ "borderTopLeftRadius",
1179
+ "borderTopRightRadius",
1180
+ "boxShadow",
1181
+ "boxSizing",
1182
+ "color",
1183
+ "columnGap",
1184
+ "display",
1185
+ "flexDirection",
1186
+ "fontFamily",
1187
+ "fontFeatureSettings",
1188
+ "fontOpticalSizing",
1189
+ "fontSize",
1190
+ "fontStretch",
1191
+ "fontStyle",
1192
+ "fontVariant",
1193
+ "fontVariantCaps",
1194
+ "fontVariantLigatures",
1195
+ "fontVariantNumeric",
1196
+ "fontVariantPosition",
1197
+ "fontKerning",
1198
+ "fontVariationSettings",
1199
+ "fontWeight",
1200
+ "justifyContent",
1201
+ "letterSpacing",
1202
+ "lineHeight",
1203
+ "marginBottom",
1204
+ "marginLeft",
1205
+ "marginRight",
1206
+ "marginTop",
1207
+ "opacity",
1208
+ "paddingBottom",
1209
+ "paddingLeft",
1210
+ "paddingRight",
1211
+ "paddingTop",
1212
+ "rowGap",
1213
+ "textDecorationColor",
1214
+ "textDecorationLine",
1215
+ "textDecorationSkipInk",
1216
+ "textDecorationStyle",
1217
+ "textDecorationThickness",
1218
+ "textShadow",
1219
+ "textTransform",
1220
+ "textUnderlineOffset",
1221
+ "verticalAlign",
1222
+ "whiteSpace",
1223
+ "WebkitTextStrokeColor",
1224
+ "WebkitTextStrokeWidth",
1225
+ "--canvas-text-stroke-alignment"
1226
+ ]);
1227
+ const fillsSchema = canvasPaintSchema.array().max(32).optional();
1228
+ const characterFormattingSchema = canvasTextParagraphSchema.pick({
1229
+ paragraphSpacing: true,
1230
+ paragraphIndent: true,
1231
+ listSpacing: true,
1232
+ wrapStyle: true
1233
+ }).extend({
1234
+ hangingPunctuation: canvasTypographySchema.shape.hangingPunctuation,
1235
+ verticalTrim: canvasTypographySchema.shape.verticalTrim
1236
+ }).strip();
1237
+ const SAFE_HREF_PROTOCOLS = /* @__PURE__ */ new Set([
1238
+ "http:",
1239
+ "https:",
1240
+ "mailto:",
1241
+ "tel:"
1242
+ ]);
1243
+ const isCanvasRichTextHref = (value) => {
1244
+ const href = value.trim();
1245
+ if (href === "") return false;
1246
+ try {
1247
+ const protocol = new URL(href, "https://enhance.invalid/").protocol;
1248
+ return SAFE_HREF_PROTOCOLS.has(protocol);
1249
+ } catch {
1250
+ return false;
1251
+ }
1252
+ };
1253
+ const safeHref = (value) => typeof value === "string" && isCanvasRichTextHref(value) ? value : void 0;
1254
+ const richStylesOf = (value) => {
1255
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
1256
+ const entries = Object.entries(value);
1257
+ if (entries.some(([property, styleValue]) => !ALLOWED_STYLE_PROPERTIES.has(property) || typeof styleValue !== "string" && typeof styleValue !== "number")) return null;
1258
+ return Object.fromEntries(entries);
1259
+ };
1260
+ const richMetadataOf = (value) => {
1261
+ const sourcePath = Reflect.get(value, "sourcePath");
1262
+ return {
1263
+ ...Object.fromEntries(Object.entries(value).filter(([key]) => ![
1264
+ "text",
1265
+ "href",
1266
+ "sourcePath",
1267
+ "styles",
1268
+ "fills",
1269
+ "paragraph",
1270
+ "paragraphSpacing",
1271
+ "paragraphIndent",
1272
+ "listSpacing",
1273
+ "hangingPunctuation",
1274
+ "verticalTrim",
1275
+ "wrapStyle",
1276
+ "soft",
1277
+ "textStyle"
1278
+ ].includes(key))),
1279
+ ...typeof sourcePath === "string" && { sourcePath }
1280
+ };
1281
+ };
1282
+ const richChildrenOf = (values) => {
1283
+ const children = [];
1284
+ for (const candidate of values) {
1285
+ const child = richNodeOf(candidate);
1286
+ if (child === null) return null;
1287
+ children.push(child);
1288
+ }
1289
+ return children;
1290
+ };
1291
+ const richBreakOf = (value) => {
1292
+ const soft = Reflect.get(value, "soft");
1293
+ if (soft !== void 0 && soft !== true) return null;
1294
+ return {
1295
+ ...richMetadataOf(value),
1296
+ kind: "break",
1297
+ ...soft === true && { soft }
1298
+ };
1299
+ };
1300
+ const richNodeOf = (value) => {
1301
+ if (typeof value !== "object" || value === null) return null;
1302
+ const kind = Reflect.get(value, "kind");
1303
+ const metadata = richMetadataOf(value);
1304
+ if (kind === "break") return richBreakOf(value);
1305
+ if (kind === "text") {
1306
+ const text = Reflect.get(value, "text");
1307
+ return typeof text === "string" ? {
1308
+ ...metadata,
1309
+ kind,
1310
+ text
1311
+ } : null;
1312
+ }
1313
+ if (kind !== "span") return null;
1314
+ const values = Reflect.get(value, "children");
1315
+ const styles = richStylesOf(Reflect.get(value, "styles"));
1316
+ const fills = fillsSchema.safeParse(Reflect.get(value, "fills"));
1317
+ const paragraph = canvasTextParagraphSchema.optional().safeParse(Reflect.get(value, "paragraph"));
1318
+ const formatting = characterFormattingSchema.safeParse(value);
1319
+ const textStyle = canvasTextStyleBindingSchema.optional().safeParse(Reflect.get(value, "textStyle"));
1320
+ if (styles === null || !fills.success || !paragraph.success || !formatting.success || !textStyle.success || !Array.isArray(values)) return null;
1321
+ const children = richChildrenOf(values);
1322
+ if (children === null) return null;
1323
+ const href = safeHref(Reflect.get(value, "href"));
1324
+ return {
1325
+ ...metadata,
1326
+ kind,
1327
+ styles,
1328
+ children,
1329
+ ...textStyle.data !== void 0 && { textStyle: textStyle.data },
1330
+ ...fills.data !== void 0 && { fills: fills.data },
1331
+ ...paragraph.data !== void 0 && { paragraph: paragraph.data },
1332
+ ...Object.fromEntries(Object.entries(formatting.data).filter(([, entry]) => entry !== void 0)),
1333
+ ...href !== void 0 && { href }
1334
+ };
1335
+ };
1336
+ const canvasRichTextValueOf = (nodes) => nodes.map((node) => node.kind === "break" ? node.soft === true ? "\u2028" : "\n" : node.kind === "text" ? node.text : canvasRichTextValueOf(node.children)).join("");
1337
+ const canvasRichTextOf = (node) => {
1338
+ const props = node.props;
1339
+ if (props === void 0 || !Array.isArray(props["richText"])) return [];
1340
+ const value = props["richText"];
1341
+ const rich = [];
1342
+ for (const candidate of value) {
1343
+ const child = richNodeOf(candidate);
1344
+ if (child === null) return [];
1345
+ rich.push(child);
1346
+ }
1347
+ const text = props["text"];
1348
+ return canvasRichTextValueOf(rich) === text ? rich : [];
1349
+ };
1350
+
1351
+ //#endregion
1352
+ //#region ../../packages/contract/src/canvas/canvas-scene.schema.ts
1353
+ const COMPLETE_TYPOGRAPHY_FORMAT = 3;
1354
+ const LEGACY_CANVAS_FORMAT_4 = 4;
1355
+ const MAX_SCENE_NODE_ID_LENGTH = 200;
1356
+ const MAX_SCENE_LABEL_LENGTH = 500;
1357
+ const MAX_SCENE_COMPONENT_LENGTH = 100;
1358
+ const MAX_SCENE_SORT_KEY_LENGTH = 500;
1359
+ const CANVAS_SCENE_VERSION = 5;
1360
+ const canvasDocumentFormatSchema = z.literal(5, { error: "This editor uses an unsupported document format. Update the editor before changing this canvas." });
1361
+ const MAX_PRESERVED_FONT_APPEARANCE_BYTES = 2e6;
1362
+ const MAX_PRESERVED_FONT_FAMILY_LENGTH = 256;
1363
+ const MAX_PRESERVED_FONT_FAMILIES = 256;
1364
+ const canvasPreservedFontAppearanceSchema = z.object({
1365
+ signature: z.string().regex(/^[a-f0-9]{16}$/u),
1366
+ image: z.string().startsWith("data:image/jpeg;base64,").max(MAX_PRESERVED_FONT_APPEARANCE_BYTES),
1367
+ families: z.array(z.string().min(1).max(MAX_PRESERVED_FONT_FAMILY_LENGTH)).min(1).max(MAX_PRESERVED_FONT_FAMILIES)
1368
+ });
1369
+ const canvasSceneBoxSchema = z.object({
1370
+ x: z.number(),
1371
+ y: z.number(),
1372
+ width: z.number().nonnegative(),
1373
+ height: z.number().nonnegative()
1374
+ });
1375
+ const canvasConstraintSchema = z.enum([
1376
+ "start",
1377
+ "center",
1378
+ "end",
1379
+ "stretch",
1380
+ "scale"
1381
+ ]);
1382
+ const canvasNodeConstraintsSchema = z.object({
1383
+ x: canvasConstraintSchema,
1384
+ y: canvasConstraintSchema
1385
+ });
1386
+ const canvasNodeLabelOriginSchema = z.enum([
1387
+ "source",
1388
+ "generated",
1389
+ "user"
1390
+ ]);
1391
+ const canvasSceneNodeSchema = z.looseObject({
1392
+ id: z.string().min(1).max(MAX_SCENE_NODE_ID_LENGTH),
1393
+ label: z.string().max(MAX_SCENE_LABEL_LENGTH),
1394
+ component: z.string().min(1).max(MAX_SCENE_COMPONENT_LENGTH),
1395
+ labelOrigin: canvasNodeLabelOriginSchema.optional(),
1396
+ visible: z.boolean().optional(),
1397
+ locked: z.boolean().optional(),
1398
+ constraints: canvasNodeConstraintsSchema.optional(),
1399
+ styles: z.record(z.string(), z.union([z.string(), z.number()])),
1400
+ layout: canvasNodeLayoutSchema.optional(),
1401
+ responsive: z.never().optional(),
1402
+ appearance: canvasAppearanceValuesSchema.optional(),
1403
+ typography: canvasAuthoredTypographySchema.optional(),
1404
+ additionalStyles: canvasAdditionalStylesSchema.optional(),
1405
+ props: z.record(z.string(), z.unknown()).optional(),
1406
+ box: canvasSceneBoxSchema.optional()
1407
+ });
1408
+ const canvasSceneDocumentSchema = z.object({
1409
+ version: z.literal(5),
1410
+ nodes: z.record(z.string(), canvasSceneNodeSchema),
1411
+ relationships: z.record(z.string(), z.object({
1412
+ parentId: z.string().min(1).max(MAX_SCENE_NODE_ID_LENGTH),
1413
+ sortKey: z.string().min(1).max(MAX_SCENE_SORT_KEY_LENGTH)
1414
+ })),
1415
+ tombstones: z.record(z.string(), z.literal(true)).default({})
1416
+ });
1417
+ const legacyRecordSchema = z.record(z.string(), z.unknown());
1418
+ const legacyNode = (node) => {
1419
+ const layout = legacyRecordSchema.safeParse(node["layout"]).data;
1420
+ if (layout === void 0) return node;
1421
+ const next = Object.fromEntries(Object.entries(layout).filter(([key]) => key !== "gridTrack"));
1422
+ const container = legacyRecordSchema.safeParse(next["container"]).data;
1423
+ if (container !== void 0) next["container"] = Object.fromEntries(Object.entries(container).filter(([key]) => key !== "materialized"));
1424
+ for (const axis of ["horizontal", "vertical"]) {
1425
+ const intent = legacyRecordSchema.safeParse(next[axis]).data;
1426
+ if (intent?.["mode"] === "hug") next[axis] = Object.fromEntries(Object.entries(intent).filter(([key]) => key !== "basis"));
1427
+ }
1428
+ return {
1429
+ ...node,
1430
+ layout: next
1431
+ };
1432
+ };
1433
+ const legacyDocument = (blob) => {
1434
+ if (Object.keys(blob).length === 0) return emptyCanvasSceneDocument();
1435
+ if (blob["version"] === COMPLETE_TYPOGRAPHY_FORMAT || blob["version"] === LEGACY_CANVAS_FORMAT_4) return {
1436
+ ...blob,
1437
+ version: 5
1438
+ };
1439
+ const nodes = z.record(z.string(), legacyRecordSchema).safeParse(blob["nodes"]).data;
1440
+ if (nodes === void 0) return blob;
1441
+ return {
1442
+ ...blob,
1443
+ version: 5,
1444
+ nodes: Object.fromEntries(Object.entries(nodes).map(([id, node]) => [id, legacyNode(node)]))
1445
+ };
1446
+ };
1447
+ /** Known old scenes are adapted in memory; only an explicit mutation persists the new format. */
1448
+ const canvasReadableSceneDocumentSchema = z.preprocess((value) => {
1449
+ const blob = legacyRecordSchema.safeParse(value).data;
1450
+ if (blob === void 0) return value;
1451
+ const version = blob["version"];
1452
+ return (/* @__PURE__ */ new Set([
1453
+ void 0,
1454
+ 1,
1455
+ 2,
1456
+ COMPLETE_TYPOGRAPHY_FORMAT,
1457
+ LEGACY_CANVAS_FORMAT_4
1458
+ ])).has(version) ? legacyDocument(blob) : blob;
1459
+ }, canvasSceneDocumentSchema);
1460
+ const emptyCanvasSceneDocument = () => ({
1461
+ version: 5,
1462
+ nodes: { root: {
1463
+ id: "root",
1464
+ label: "Canvas",
1465
+ component: "root",
1466
+ labelOrigin: "generated",
1467
+ visible: true,
1468
+ locked: false,
1469
+ styles: {}
1470
+ } },
1471
+ relationships: {},
1472
+ tombstones: {}
1473
+ });
1474
+
1475
+ //#endregion
1476
+ //#region ../../packages/contract/src/canvas/canvas-text-content.lib.ts
1477
+ const textLinkSchema = z.object({
1478
+ start: z.number().int().nonnegative(),
1479
+ end: z.number().int().positive(),
1480
+ href: z.url().refine((href) => ["http:", "https:"].includes(new URL(href).protocol))
1481
+ });
1482
+ const textSchema = z.object({
1483
+ text: z.string(),
1484
+ links: z.array(textLinkSchema).optional()
1485
+ });
1486
+ const compareTextLinks = (left, right) => {
1487
+ const byStart = left.start - right.start;
1488
+ return byStart === 0 ? left.end - right.end : byStart;
1489
+ };
1490
+ const textOf = (node) => textSchema.safeParse(node.props).data?.text ?? null;
1491
+ const textLinksOf = (node) => {
1492
+ const parsed = textSchema.safeParse(node.props).data;
1493
+ if (parsed === void 0) return [];
1494
+ const links = parsed.links;
1495
+ if (links === void 0) return [];
1496
+ const validLinks = links.filter(({ start, end }) => start < end && end <= parsed.text.length).toSorted(compareTextLinks);
1497
+ const nonOverlapping = [];
1498
+ for (const link of validLinks) if ((nonOverlapping.at(-1)?.end ?? 0) <= link.start) nonOverlapping.push(link);
1499
+ return nonOverlapping;
1500
+ };
1501
+
1502
+ //#endregion
1503
+ //#region ../../packages/contract/src/canvas/canvas-conversion-draft.schema.ts
1504
+ const MAX_CANVAS_CONVERSION_NODES = 3e4;
1505
+ const MAX_CANVAS_CONVERSION_SOURCE_NODES = 5e4;
1506
+ const MAX_CANVAS_CONVERSION_ID_LENGTH = 200;
1507
+ const MAX_CANVAS_CONVERSION_TEXT_LENGTH = 500;
1508
+ const MAX_CANVAS_HTML_SOURCE_LENGTH = 262144;
1509
+ const temporaryIdSchema = z.string().min(1).max(200);
1510
+ const canvasConversionIssueSchema = z.object({
1511
+ code: z.enum([
1512
+ "asset-unavailable",
1513
+ "content-omitted",
1514
+ "cross-origin-frame",
1515
+ "nodes-truncated",
1516
+ "responsive-behavior-not-editable",
1517
+ "style-degraded",
1518
+ "unsupported-surface"
1519
+ ]),
1520
+ message: z.string().min(1).max(500),
1521
+ temporaryId: temporaryIdSchema.optional()
1522
+ });
1523
+ const canvasConversionReportSchema = z.object({
1524
+ nodeCount: z.number().int().positive().max(MAX_CANVAS_CONVERSION_NODES),
1525
+ sourceNodeCount: z.number().int().positive().max(MAX_CANVAS_CONVERSION_SOURCE_NODES).optional(),
1526
+ collapsedNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES).optional(),
1527
+ collapsedWrapperNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES).optional(),
1528
+ collapsedNeutralWrapperNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES).optional(),
1529
+ collapsedTransferredWrapperNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES).optional(),
1530
+ layoutContainerCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_NODES).optional(),
1531
+ removedLeafNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES).optional(),
1532
+ retainedSemanticOwnerNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES).optional(),
1533
+ truncatedNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES * 2).optional(),
1534
+ addedLayoutNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES).optional(),
1535
+ issues: z.array(canvasConversionIssueSchema).max(MAX_CANVAS_CONVERSION_SOURCE_NODES)
1536
+ }).refine(({ collapsedNeutralWrapperNodeCount, collapsedTransferredWrapperNodeCount, collapsedWrapperNodeCount }) => collapsedWrapperNodeCount === void 0 || collapsedNeutralWrapperNodeCount === void 0 || collapsedTransferredWrapperNodeCount === void 0 || collapsedNeutralWrapperNodeCount + collapsedTransferredWrapperNodeCount === collapsedWrapperNodeCount, "wrapper collapse proof classes must explain the collapsed wrapper count").refine(({ collapsedNodeCount, collapsedWrapperNodeCount, removedLeafNodeCount }) => collapsedNodeCount === void 0 || collapsedWrapperNodeCount === void 0 || removedLeafNodeCount === void 0 || collapsedWrapperNodeCount + removedLeafNodeCount === collapsedNodeCount, "collapsed node kinds must explain the total collapsed node count").refine(({ addedLayoutNodeCount, collapsedNodeCount, nodeCount, sourceNodeCount, truncatedNodeCount }) => sourceNodeCount === void 0 || collapsedNodeCount === void 0 || sourceNodeCount + (addedLayoutNodeCount ?? 0) - nodeCount === collapsedNodeCount + (truncatedNodeCount ?? 0), "added, collapsed and truncated node counts must explain the source to editable difference").refine(({ layoutContainerCount, nodeCount }) => layoutContainerCount === void 0 || layoutContainerCount <= nodeCount, "layout container count cannot exceed editable node count");
1537
+ const canvasSubtreeDraftNodeSchema = canvasSceneNodeSchema.omit({ id: true }).extend({ temporaryId: temporaryIdSchema });
1538
+ const canvasSubtreeDraftRelationshipSchema = z.object({
1539
+ temporaryId: temporaryIdSchema,
1540
+ parentTemporaryId: temporaryIdSchema,
1541
+ sortKey: z.string().min(1).max(500)
1542
+ });
1543
+ const canvasSubtreeDraftSchema = z.object({
1544
+ version: z.literal(1),
1545
+ rootTemporaryId: temporaryIdSchema,
1546
+ nodes: z.array(canvasSubtreeDraftNodeSchema).min(1).max(MAX_CANVAS_CONVERSION_NODES),
1547
+ relationships: z.array(canvasSubtreeDraftRelationshipSchema).max(MAX_CANVAS_CONVERSION_NODES - 1),
1548
+ report: canvasConversionReportSchema
1549
+ });
1550
+ const createEditableFrameInputSchema = z.object({
1551
+ canvasId: z.uuid(),
1552
+ documentFormatVersion: canvasDocumentFormatSchema,
1553
+ mutationId: z.uuid(),
1554
+ baseVersion: z.number().int().positive(),
1555
+ screenNodeId: z.string().min(1).max(200),
1556
+ draft: canvasSubtreeDraftSchema
1557
+ });
1558
+ const createEditableFrameResultSchema = z.object({
1559
+ canvasId: z.uuid(),
1560
+ mutationId: z.uuid(),
1561
+ previousVersion: z.number().int().positive(),
1562
+ version: z.number().int().positive(),
1563
+ rootNodeId: z.string().min(1).max(200),
1564
+ idMap: z.record(temporaryIdSchema, z.string().min(1).max(200)),
1565
+ insertedNodeIds: z.array(z.string().min(1).max(200)),
1566
+ removedNodeIds: z.array(z.string().min(1).max(200)),
1567
+ boxes: z.record(z.string().min(1).max(200), canvasSceneBoxSchema),
1568
+ affectedBounds: canvasSceneBoxSchema
1569
+ });
1570
+
1571
+ //#endregion
1572
+ //#region ../../packages/contract/src/shared/blob.schema.ts
1573
+ /**
1574
+ * The two-phase upload, seen from the client. The bytes never pass through the API: it hands
1575
+ * back a URL S3 will accept, and the client PUTs to it directly.
1576
+ */
1577
+ const signedUploadSchema = z.object({
1578
+ url: z.url(),
1579
+ expiresAt: z.iso.datetime(),
1580
+ /** Signed into the URL, so a client that omits one gets a 403 from S3, not from us. */
1581
+ headers: z.record(z.string(), z.string())
1582
+ });
1583
+ const signedDownloadSchema = z.object({
1109
1584
  url: z.url(),
1110
1585
  expiresAt: z.iso.datetime(),
1111
1586
  bytes: z.number().int().min(0)
@@ -1169,7 +1644,7 @@ const RENDER_MAX_OUTPUT_BYTES = RENDER_MAX_OUTPUT_MIB * BYTES_PER_MIB$2;
1169
1644
  const RENDER_MAX_SNAPSHOT_BYTES = RENDER_MAX_SNAPSHOT_MIB * BYTES_PER_MIB$2;
1170
1645
  const RENDER_MAX_WORLD_EDGE = 1e5;
1171
1646
  const RENDER_MIN_SCALE = .1;
1172
- const MAX_NODE_ID_LENGTH$6 = 200;
1647
+ const MAX_NODE_ID_LENGTH$7 = 200;
1173
1648
  const MAX_RENDER_MESSAGE_LENGTH$1 = 500;
1174
1649
  const canvasWorldBoundsSchema = z.object({
1175
1650
  x: z.number(),
@@ -1181,7 +1656,7 @@ const canvasRenderTargetSchema = z.discriminatedUnion("kind", [
1181
1656
  z.object({ kind: z.literal("content") }),
1182
1657
  z.object({
1183
1658
  kind: z.literal("node"),
1184
- nodeId: z.string().min(1).max(MAX_NODE_ID_LENGTH$6)
1659
+ nodeId: z.string().min(1).max(MAX_NODE_ID_LENGTH$7)
1185
1660
  }),
1186
1661
  z.object({
1187
1662
  kind: z.literal("bounds"),
@@ -1203,7 +1678,7 @@ const canvasRenderSnapshotResultSchema = z.object({
1203
1678
  recordingId: z.uuid(),
1204
1679
  atMs: z.number().int().nonnegative(),
1205
1680
  screenId: z.uuid(),
1206
- screenNodeId: z.string().min(1).max(MAX_NODE_ID_LENGTH$6),
1681
+ screenNodeId: z.string().min(1).max(MAX_NODE_ID_LENGTH$7),
1207
1682
  viewport: z.object({
1208
1683
  width: z.number().int().positive(),
1209
1684
  height: z.number().int().positive()
@@ -1230,14 +1705,14 @@ const canvasRenderWarningCodeSchema = z.enum(RENDER_WARNING_CODES);
1230
1705
  const canvasRenderWarningSchema = z.object({
1231
1706
  code: canvasRenderWarningCodeSchema,
1232
1707
  message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH$1),
1233
- sourceId: z.string().min(1).max(MAX_NODE_ID_LENGTH$6).nullable()
1708
+ sourceId: z.string().min(1).max(MAX_NODE_ID_LENGTH$7).nullable()
1234
1709
  });
1235
1710
  const canvasRenderFailureSchema = z.object({
1236
1711
  reason: canvasRenderFailureReasonSchema,
1237
1712
  phase: canvasRenderPhaseSchema,
1238
1713
  message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH$1),
1239
1714
  retryable: z.boolean(),
1240
- sourceId: z.string().min(1).max(MAX_NODE_ID_LENGTH$6).nullable()
1715
+ sourceId: z.string().min(1).max(MAX_NODE_ID_LENGTH$7).nullable()
1241
1716
  });
1242
1717
  const canvasRenderTimingSchema = z.object({
1243
1718
  phase: canvasRenderPhaseSchema,
@@ -1457,215 +1932,867 @@ const conversionRouteStateSchema = z.discriminatedUnion("state", [
1457
1932
  ]);
1458
1933
 
1459
1934
  //#endregion
1460
- //#region ../../packages/contract/src/canvas/canvas-document.schema.ts
1461
- /** More screens than one canvas has ever held, and a bound on one save's work. */
1462
- const MAX_SCREENS_PER_DOCUMENT = 2e3;
1463
- /** Reads retain unsupported documents; the write boundary validates the current scene format. */
1464
- const canvasDocumentBlobSchema = z.record(z.string(), z.unknown());
1465
- const getCanvasDocumentInputSchema = z.object({ canvasId: z.uuid() });
1466
- const documentScreenSchema = z.object({
1467
- screenId: z.uuid(),
1468
- /** Null for a link visitor. Always present on the agent surface. */
1469
- route: z.string().max(MAX_URL_LENGTH).nullable(),
1470
- title: z.string().max(200).nullable(),
1471
- viewport: z.object({
1472
- width: z.number().int().positive(),
1473
- height: z.number().int().positive()
1474
- }),
1475
- atMs: z.number().int().min(0).nullable(),
1476
- sourceRecordingId: z.uuid().nullable(),
1477
- /** Durable rendering dependency, deliberately independent of recording provenance. */
1478
- assetBundle: z.object({
1479
- assetBundleId: z.uuid(),
1480
- sourceUrl: z.string().max(MAX_URL_LENGTH),
1481
- assets: z.array(z.object({
1482
- url: z.string().max(MAX_URL_LENGTH),
1483
- contentType: z.string().max(200),
1484
- path: z.string().startsWith("/v1/recording-assets/")
1485
- })),
1486
- missingAssetCount: z.number().int().min(0)
1487
- }).nullable(),
1488
- /** Null while the blob has not landed. The client draws an empty frame with its label. */
1489
- download: signedDownloadSchema.nullable()
1935
+ //#region ../../packages/contract/src/canvas/canvas-font-library.schema.ts
1936
+ const MAX_CANVAS_FONT_IMPORT_FILES = 100;
1937
+ const MAX_RESOURCE_ID_LENGTH = 300;
1938
+ const canvasFontLibraryPatchSchema = z.object({
1939
+ add: z.array(z.object({ resourceId: z.string().min(1).max(MAX_RESOURCE_ID_LENGTH) }).catchall(z.unknown())).max(100),
1940
+ remove: z.array(z.string().min(1).max(MAX_RESOURCE_ID_LENGTH)).max(100)
1941
+ });
1942
+
1943
+ //#endregion
1944
+ //#region ../../packages/contract/src/canvas/canvas-decoration-style-patch.schema.ts
1945
+ const dimensionalStyleValue$1 = z.union([z.string(), boundedCanvasNumberSchema]);
1946
+ const layoutStylePatchValue$1 = z.union([canvasAdditionalStyleSchema.shape.value, boundedCanvasNumberSchema]).nullable().optional();
1947
+ const canvasDecorationStylePatchSchema = z.strictObject({
1948
+ border: layoutStylePatchValue$1,
1949
+ "border-block": layoutStylePatchValue$1,
1950
+ "border-block-color": layoutStylePatchValue$1,
1951
+ "border-block-style": layoutStylePatchValue$1,
1952
+ "border-block-width": layoutStylePatchValue$1,
1953
+ "border-block-end": layoutStylePatchValue$1,
1954
+ "border-block-end-color": layoutStylePatchValue$1,
1955
+ "border-block-end-style": layoutStylePatchValue$1,
1956
+ "border-block-end-width": layoutStylePatchValue$1,
1957
+ "border-block-start": layoutStylePatchValue$1,
1958
+ "border-block-start-color": layoutStylePatchValue$1,
1959
+ "border-block-start-style": layoutStylePatchValue$1,
1960
+ "border-block-start-width": layoutStylePatchValue$1,
1961
+ "border-bottom": layoutStylePatchValue$1,
1962
+ "border-bottom-color": layoutStylePatchValue$1,
1963
+ "border-bottom-style": layoutStylePatchValue$1,
1964
+ "border-bottom-left-radius": dimensionalStyleValue$1.optional(),
1965
+ "border-bottom-right-radius": dimensionalStyleValue$1.optional(),
1966
+ "border-bottom-width": dimensionalStyleValue$1.optional(),
1967
+ "border-color": z.string().nullable().optional(),
1968
+ "border-image": layoutStylePatchValue$1,
1969
+ "border-image-source": layoutStylePatchValue$1,
1970
+ "border-image-slice": layoutStylePatchValue$1,
1971
+ "border-image-width": layoutStylePatchValue$1,
1972
+ "border-image-outset": layoutStylePatchValue$1,
1973
+ "border-image-repeat": layoutStylePatchValue$1,
1974
+ "border-inline": layoutStylePatchValue$1,
1975
+ "border-inline-color": layoutStylePatchValue$1,
1976
+ "border-inline-style": layoutStylePatchValue$1,
1977
+ "border-inline-width": layoutStylePatchValue$1,
1978
+ "border-inline-end": layoutStylePatchValue$1,
1979
+ "border-inline-end-color": layoutStylePatchValue$1,
1980
+ "border-inline-end-style": layoutStylePatchValue$1,
1981
+ "border-inline-end-width": layoutStylePatchValue$1,
1982
+ "border-inline-start": layoutStylePatchValue$1,
1983
+ "border-inline-start-color": layoutStylePatchValue$1,
1984
+ "border-inline-start-style": layoutStylePatchValue$1,
1985
+ "border-inline-start-width": layoutStylePatchValue$1,
1986
+ "border-left": layoutStylePatchValue$1,
1987
+ "border-left-color": layoutStylePatchValue$1,
1988
+ "border-left-style": layoutStylePatchValue$1,
1989
+ "border-left-width": dimensionalStyleValue$1.optional(),
1990
+ "border-radius": dimensionalStyleValue$1.nullable().optional(),
1991
+ "border-right": layoutStylePatchValue$1,
1992
+ "border-right-color": layoutStylePatchValue$1,
1993
+ "border-right-style": layoutStylePatchValue$1,
1994
+ "border-right-width": dimensionalStyleValue$1.optional(),
1995
+ "border-style": layoutStylePatchValue$1,
1996
+ "border-top": layoutStylePatchValue$1,
1997
+ "border-top-color": layoutStylePatchValue$1,
1998
+ "border-top-style": layoutStylePatchValue$1,
1999
+ "border-top-left-radius": dimensionalStyleValue$1.optional(),
2000
+ "border-top-right-radius": dimensionalStyleValue$1.optional(),
2001
+ "border-top-width": dimensionalStyleValue$1.optional(),
2002
+ "border-width": dimensionalStyleValue$1.nullable().optional(),
2003
+ outline: layoutStylePatchValue$1,
2004
+ "outline-color": layoutStylePatchValue$1,
2005
+ "outline-style": layoutStylePatchValue$1,
2006
+ "outline-offset": dimensionalStyleValue$1.optional(),
2007
+ "outline-width": dimensionalStyleValue$1.optional()
1490
2008
  });
1491
- const getCanvasDocumentOutputSchema = z.object({
1492
- version: z.number().int().min(1),
1493
- document: canvasDocumentBlobSchema,
1494
- /** The manifest, resolved and signed. This is what makes a cold open one round trip. */
1495
- screens: z.array(documentScreenSchema)
2009
+
2010
+ //#endregion
2011
+ //#region ../../packages/contract/src/canvas/canvas-operation-styles.schema.ts
2012
+ const TEXT_SIZE_SMALL = 16;
2013
+ const TEXT_SIZE_MEDIUM = 24;
2014
+ const TEXT_SIZE_LARGE = 40;
2015
+ const TEXT_SIZE_HUGE = 64;
2016
+ const TEXT_SIZE_MEGA = 96;
2017
+ const MIN_LETTER_SPACING = -100;
2018
+ const MAX_LETTER_SPACING = 100;
2019
+ const MAX_LINE_HEIGHT = 1e4;
2020
+ const nonNegativePixelLengthSchema = z.string().regex(/^(?:\d+(?:\.\d+)?|\.\d+)px$/u);
2021
+ const signedPixelLengthSchema = z.string().regex(/^-?(?:\d+(?:\.\d+)?|\.\d+)px$/u);
2022
+ const textStyleValues = {
2023
+ color: z.union([z.enum([
2024
+ "var(--note-ink)",
2025
+ "var(--note-slate)",
2026
+ "var(--note-red)",
2027
+ "var(--note-orange)",
2028
+ "var(--note-amber)",
2029
+ "var(--note-green)",
2030
+ "var(--note-teal)",
2031
+ "var(--note-blue)",
2032
+ "var(--note-violet)",
2033
+ "var(--note-magenta)"
2034
+ ]), z.string().regex(/^#[\da-f]{6}$/iu)]),
2035
+ "font-family": z.enum(["var(--sans)", "var(--mono)"]),
2036
+ "font-size": z.union([
2037
+ z.literal(TEXT_SIZE_SMALL),
2038
+ z.literal(TEXT_SIZE_MEDIUM),
2039
+ z.literal(TEXT_SIZE_LARGE),
2040
+ z.literal(TEXT_SIZE_HUGE),
2041
+ z.literal(TEXT_SIZE_MEGA)
2042
+ ]),
2043
+ "font-weight": z.enum(["400", "700"]),
2044
+ "font-style": z.enum([
2045
+ "normal",
2046
+ "italic",
2047
+ "oblique"
2048
+ ]),
2049
+ "letter-spacing": z.number().min(MIN_LETTER_SPACING).max(MAX_LETTER_SPACING),
2050
+ "line-height": z.union([z.number().positive().max(MAX_LINE_HEIGHT), z.string().regex(/^(?:\d+(?:\.\d+)?(?:px|em|rem|%)?|normal)$/u)]),
2051
+ "text-align": z.enum([
2052
+ "left",
2053
+ "center",
2054
+ "right"
2055
+ ]),
2056
+ "white-space": z.enum([
2057
+ "normal",
2058
+ "nowrap",
2059
+ "pre",
2060
+ "pre-wrap",
2061
+ "pre-line",
2062
+ "break-spaces"
2063
+ ])
2064
+ };
2065
+ const canvasTextStylesSchema = z.strictObject({
2066
+ color: textStyleValues.color.optional(),
2067
+ "font-family": textStyleValues["font-family"].optional(),
2068
+ "font-size": textStyleValues["font-size"].optional(),
2069
+ "font-weight": textStyleValues["font-weight"].optional(),
2070
+ "font-style": textStyleValues["font-style"].optional(),
2071
+ "letter-spacing": textStyleValues["letter-spacing"].optional(),
2072
+ "line-height": textStyleValues["line-height"].optional(),
2073
+ "text-align": textStyleValues["text-align"].optional(),
2074
+ "white-space": textStyleValues["white-space"].optional()
1496
2075
  });
1497
- const saveCanvasDocumentInputSchema = z.object({
1498
- canvasId: z.uuid(),
1499
- baseVersion: z.number().int().min(1),
1500
- document: canvasDocumentBlobSchema.refine((document) => canvasSceneDocumentSchema.safeParse(document).success, "A save requires a valid current-format canvas document."),
1501
- /** Every screen the document names. Replaces the manifest wholesale. */
1502
- screenIds: z.array(z.uuid()).max(MAX_SCREENS_PER_DOCUMENT)
2076
+ const restorableTextStyleValue = z.union([canvasAdditionalStyleSchema.shape.value, boundedCanvasNumberSchema]).nullable().optional();
2077
+ const canvasTextStylePatchSchema = z.strictObject({
2078
+ "text-decoration": restorableTextStyleValue,
2079
+ "text-decoration-line": restorableTextStyleValue,
2080
+ "text-decoration-style": restorableTextStyleValue,
2081
+ "text-decoration-color": restorableTextStyleValue,
2082
+ "text-decoration-thickness": restorableTextStyleValue,
2083
+ "text-underline-offset": restorableTextStyleValue,
2084
+ "text-decoration-skip-ink": restorableTextStyleValue,
2085
+ color: textStyleValues.color.nullable().optional(),
2086
+ "font-family": canvasAdditionalStyleSchema.shape.value.nullable().optional(),
2087
+ "font-size": z.union([nonNegativeCanvasNumberSchema, nonNegativePixelLengthSchema]).nullable().optional(),
2088
+ "font-weight": z.union([
2089
+ canvasTypographySchema.shape.weight,
2090
+ z.enum([
2091
+ "normal",
2092
+ "bold",
2093
+ "bolder",
2094
+ "lighter"
2095
+ ]),
2096
+ z.string().regex(/^\d+(?:\.\d+)?$/u).refine((value) => canvasTypographySchema.shape.weight.safeParse(Number(value)).success)
2097
+ ]).nullable().optional(),
2098
+ "font-optical-sizing": z.enum(["auto", "none"]).nullable().optional(),
2099
+ "font-variation-settings": canvasAdditionalStyleSchema.shape.value.nullable().optional(),
2100
+ "font-feature-settings": canvasAdditionalStyleSchema.shape.value.nullable().optional(),
2101
+ "text-wrap": canvasAdditionalStyleSchema.shape.value.nullable().optional(),
2102
+ "text-wrap-mode": canvasAdditionalStyleSchema.shape.value.nullable().optional(),
2103
+ "text-wrap-style": canvasAdditionalStyleSchema.shape.value.nullable().optional(),
2104
+ "text-box": canvasAdditionalStyleSchema.shape.value.nullable().optional(),
2105
+ "text-box-trim": canvasAdditionalStyleSchema.shape.value.nullable().optional(),
2106
+ "text-box-edge": canvasAdditionalStyleSchema.shape.value.nullable().optional(),
2107
+ "font-style": textStyleValues["font-style"].nullable().optional(),
2108
+ "font-stretch": z.union([z.enum([
2109
+ "normal",
2110
+ "ultra-condensed",
2111
+ "extra-condensed",
2112
+ "condensed",
2113
+ "semi-condensed",
2114
+ "semi-expanded",
2115
+ "expanded",
2116
+ "extra-expanded",
2117
+ "ultra-expanded"
2118
+ ]), z.string().regex(/^\d+(?:\.\d+)?%$/u)]).nullable().optional(),
2119
+ "letter-spacing": z.union([
2120
+ boundedCanvasNumberSchema,
2121
+ signedPixelLengthSchema,
2122
+ z.literal("normal")
2123
+ ]).nullable().optional(),
2124
+ "line-height": textStyleValues["line-height"].nullable().optional(),
2125
+ "text-align": textStyleValues["text-align"].nullable().optional(),
2126
+ "text-indent": z.union([boundedCanvasNumberSchema, signedPixelLengthSchema]).nullable().optional(),
2127
+ "white-space": textStyleValues["white-space"].nullable().optional(),
2128
+ "word-spacing": z.union([
2129
+ boundedCanvasNumberSchema,
2130
+ signedPixelLengthSchema,
2131
+ z.literal("normal")
2132
+ ]).nullable().optional()
1503
2133
  });
1504
- /**
1505
- * A conflict is an outcome, not an error. `AppError` is `{ code, message, fields? }` and a
1506
- * whole document does not fit in it — and a path that is expected to fire should not go
1507
- * through the error log line and the tRPC error protocol on its way to a merge dialog.
1508
- */
1509
- const saveCanvasDocumentOutputSchema = z.discriminatedUnion("outcome", [z.object({
1510
- outcome: z.literal("saved"),
1511
- version: z.number().int().min(1)
1512
- }), z.object({
1513
- outcome: z.literal("conflict"),
1514
- version: z.number().int().min(1),
1515
- document: canvasDocumentBlobSchema
1516
- })]);
2134
+ const overflowStyleValue = canvasAdditionalStyleSchema.shape.value;
2135
+ const dimensionalStyleValue = z.union([z.string(), boundedCanvasNumberSchema]);
2136
+ const layoutStylePatchValue = z.union([canvasAdditionalStyleSchema.shape.value, boundedCanvasNumberSchema]).nullable().optional();
2137
+ const canvasKnownNodeStylePatchSchema = canvasTextStylePatchSchema.extend(canvasDecorationStylePatchSchema.shape).extend({
2138
+ "align-content": layoutStylePatchValue,
2139
+ "align-items": layoutStylePatchValue,
2140
+ "align-self": layoutStylePatchValue,
2141
+ "aspect-ratio": layoutStylePatchValue,
2142
+ "block-size": layoutStylePatchValue,
2143
+ bottom: layoutStylePatchValue,
2144
+ "box-sizing": layoutStylePatchValue,
2145
+ display: layoutStylePatchValue,
2146
+ flex: layoutStylePatchValue,
2147
+ "flex-basis": layoutStylePatchValue,
2148
+ "flex-direction": layoutStylePatchValue,
2149
+ "flex-grow": layoutStylePatchValue,
2150
+ "flex-shrink": layoutStylePatchValue,
2151
+ "flex-wrap": layoutStylePatchValue,
2152
+ height: layoutStylePatchValue,
2153
+ "inline-size": layoutStylePatchValue,
2154
+ inset: layoutStylePatchValue,
2155
+ "inset-block": layoutStylePatchValue,
2156
+ "inset-block-end": layoutStylePatchValue,
2157
+ "inset-block-start": layoutStylePatchValue,
2158
+ "inset-inline": layoutStylePatchValue,
2159
+ "inset-inline-end": layoutStylePatchValue,
2160
+ "inset-inline-start": layoutStylePatchValue,
2161
+ "justify-content": layoutStylePatchValue,
2162
+ left: layoutStylePatchValue,
2163
+ margin: layoutStylePatchValue,
2164
+ "margin-block": layoutStylePatchValue,
2165
+ "margin-block-end": layoutStylePatchValue,
2166
+ "margin-block-start": layoutStylePatchValue,
2167
+ "margin-inline": layoutStylePatchValue,
2168
+ "margin-inline-end": layoutStylePatchValue,
2169
+ "margin-inline-start": layoutStylePatchValue,
2170
+ "max-block-size": layoutStylePatchValue,
2171
+ "max-height": layoutStylePatchValue,
2172
+ "max-inline-size": layoutStylePatchValue,
2173
+ "max-width": layoutStylePatchValue,
2174
+ "min-block-size": layoutStylePatchValue,
2175
+ "min-height": layoutStylePatchValue,
2176
+ "min-inline-size": layoutStylePatchValue,
2177
+ "min-width": layoutStylePatchValue,
2178
+ order: layoutStylePatchValue,
2179
+ padding: layoutStylePatchValue,
2180
+ "padding-block": layoutStylePatchValue,
2181
+ "padding-block-end": layoutStylePatchValue,
2182
+ "padding-block-start": layoutStylePatchValue,
2183
+ "padding-inline": layoutStylePatchValue,
2184
+ "padding-inline-end": layoutStylePatchValue,
2185
+ "padding-inline-start": layoutStylePatchValue,
2186
+ position: layoutStylePatchValue,
2187
+ right: layoutStylePatchValue,
2188
+ top: layoutStylePatchValue,
2189
+ width: layoutStylePatchValue,
2190
+ background: z.string().nullable().optional(),
2191
+ "background-color": z.string().nullable().optional(),
2192
+ "box-shadow": z.string().nullable().optional(),
2193
+ "column-gap": dimensionalStyleValue.optional(),
2194
+ gap: dimensionalStyleValue.optional(),
2195
+ "margin-bottom": dimensionalStyleValue.optional(),
2196
+ "margin-left": dimensionalStyleValue.optional(),
2197
+ "margin-right": dimensionalStyleValue.optional(),
2198
+ "margin-top": dimensionalStyleValue.optional(),
2199
+ opacity: z.union([z.string(), z.number()]).nullable().optional(),
2200
+ overflow: overflowStyleValue.nullable().optional(),
2201
+ "overflow-x": overflowStyleValue.nullable().optional(),
2202
+ "overflow-y": overflowStyleValue.nullable().optional(),
2203
+ "padding-bottom": dimensionalStyleValue.optional(),
2204
+ "padding-left": dimensionalStyleValue.optional(),
2205
+ "padding-right": dimensionalStyleValue.optional(),
2206
+ "padding-top": dimensionalStyleValue.optional(),
2207
+ "row-gap": dimensionalStyleValue.optional(),
2208
+ "stroke-width": dimensionalStyleValue.optional()
2209
+ });
2210
+ const canvasRestorableStylePropertySchema = z.union([canvasKnownNodeStylePatchSchema.keyof(), canvasAdditionalStyleSchema.shape.property.refine((property) => property.startsWith("--"))]);
2211
+ const canvasNodeStylePatchSchema = canvasKnownNodeStylePatchSchema.catchall(layoutStylePatchValue).refine((styles) => Object.keys(styles).every((property) => canvasRestorableStylePropertySchema.safeParse(property).success));
1517
2212
 
1518
2213
  //#endregion
1519
- //#region ../../packages/contract/src/canvas/canvas-image-asset.schema.ts
1520
- const CANVAS_IMAGE_CONTENT_TYPES = [
1521
- "image/avif",
1522
- "image/gif",
1523
- "image/jpeg",
1524
- "image/png",
1525
- "image/webp"
1526
- ];
1527
- const BYTES_PER_KIBIBYTE = 1024;
1528
- const KIBIBYTES_PER_MEBIBYTE = 1024;
1529
- const MAX_CANVAS_IMAGE_MEBIBYTES = 20;
1530
- const MAX_CANVAS_IMAGE_BYTES = MAX_CANVAS_IMAGE_MEBIBYTES * BYTES_PER_KIBIBYTE * KIBIBYTES_PER_MEBIBYTE;
1531
- const reserveCanvasImageInputSchema = z.object({
2214
+ //#region ../../packages/contract/src/canvas/canvas-text-change.schema.ts
2215
+ const MAX_CANVAS_TEXT_LENGTH = 1e5;
2216
+ const MAX_CANVAS_TEXT_ACTION_ID_LENGTH = 200;
2217
+ const MAX_TEXT_ATTRIBUTES = 128;
2218
+ const attributesSchema = z.record(z.string().max(200), z.unknown()).refine((attributes) => Object.keys(attributes).length <= MAX_TEXT_ATTRIBUTES);
2219
+ const countSchema$1 = z.number().int().positive().max(MAX_CANVAS_TEXT_LENGTH);
2220
+ const canvasTextStepSchema = z.discriminatedUnion("kind", [
2221
+ z.object({
2222
+ kind: z.literal("retain"),
2223
+ count: countSchema$1,
2224
+ attributes: attributesSchema.optional()
2225
+ }),
2226
+ z.object({
2227
+ kind: z.literal("delete"),
2228
+ count: countSchema$1
2229
+ }),
2230
+ z.object({
2231
+ kind: z.literal("insert"),
2232
+ text: z.string().min(1).max(MAX_CANVAS_TEXT_LENGTH).refine((text) => text.isWellFormed()),
2233
+ attributes: attributesSchema.optional()
2234
+ })
2235
+ ]);
2236
+ const canvasTextChangeSchema = z.object({
2237
+ baseLength: z.number().int().nonnegative().max(MAX_CANVAS_TEXT_LENGTH),
2238
+ representation: z.enum([
2239
+ "plain",
2240
+ "rich",
2241
+ "links"
2242
+ ]).optional(),
2243
+ steps: z.array(canvasTextStepSchema).max(MAX_CANVAS_TEXT_LENGTH),
2244
+ endAttributes: attributesSchema.optional(),
2245
+ properties: attributesSchema.refine((properties) => [
2246
+ "text",
2247
+ "richText",
2248
+ "links"
2249
+ ].every((key) => !Object.hasOwn(properties, key))).optional()
2250
+ }).superRefine((change, context) => {
2251
+ let consumed = 0;
2252
+ let produced = 0;
2253
+ for (const step of change.steps) {
2254
+ if (step.kind !== "insert") consumed += step.count;
2255
+ if (step.kind !== "delete") produced += step.kind === "insert" ? step.text.length : step.count;
2256
+ }
2257
+ if (consumed !== change.baseLength || produced > 1e5) context.addIssue({
2258
+ code: "custom",
2259
+ message: "text change must consume its exact base and fit the text limit"
2260
+ });
2261
+ });
2262
+ const canvasTextHistoryTargetSchema = z.object({
2263
+ actionId: z.string().min(1).max(200),
2264
+ baseVersion: z.number().int().nonnegative(),
2265
+ isActive: z.boolean()
2266
+ });
2267
+ const MAX_TEXT_SOURCE_ACTIONS = 4e3;
2268
+ const canvasTextSourceSchema = z.object({
2269
+ baseVersion: z.number().int().nonnegative(),
2270
+ after: z.array(z.string().min(1).max(200)).max(MAX_TEXT_SOURCE_ACTIONS),
2271
+ change: canvasTextChangeSchema
2272
+ });
2273
+ const canvasTextRevisionSchema = z.object({
2274
+ actionId: z.string().min(1).max(200),
2275
+ baseVersion: z.number().int().nonnegative(),
2276
+ originalChange: canvasTextChangeSchema,
2277
+ inverse: canvasTextChangeSchema,
2278
+ history: canvasTextHistoryTargetSchema.optional(),
2279
+ source: canvasTextSourceSchema.optional()
2280
+ });
2281
+ const canvasEditTextOperationSchema = z.object({
2282
+ op: z.literal("editText"),
2283
+ nodeId: z.string().min(1).max(200),
2284
+ change: canvasTextChangeSchema,
2285
+ actionId: z.string().min(1).max(200).optional(),
2286
+ revision: canvasTextRevisionSchema.optional(),
2287
+ history: canvasTextHistoryTargetSchema.optional(),
2288
+ source: canvasTextSourceSchema.optional()
2289
+ });
2290
+
2291
+ //#endregion
2292
+ //#region ../../packages/contract/src/canvas/text-style-library.schema.ts
2293
+ const MAX_STYLES = 1e3;
2294
+ const MAX_DESCRIPTION = 2e3;
2295
+ const MAX_TITLE = 200;
2296
+ const MAX_PAGE = 50;
2297
+ const DEFAULT_PAGE = 20;
2298
+ const enabledTextStyleLibrarySchema = z.object({ title: z.string().trim().min(1).max(MAX_TITLE) }).strict();
2299
+ const styleIds = z.array(canvasTextStyleSchema.shape.id).max(MAX_STYLES);
2300
+ const textStyleLibraryIdentitySchema = z.object({ canvasId: z.uuid() });
2301
+ const publishedTextStyleSchema = z.object({
2302
+ definition: canvasTextStyleSchema.refine((style) => style.sourceStyleId === void 0),
2303
+ revision: z.number().int().positive(),
2304
+ fontFaces: z.array(z.record(z.string(), z.unknown()))
2305
+ });
2306
+ const textStyleLibraryPayloadSchema = z.object({ styles: z.array(publishedTextStyleSchema).max(MAX_STYLES).refine((styles) => new Set(styles.map((style) => style.definition.id)).size === styles.length) });
2307
+ const textStyleLibrarySchema = textStyleLibraryIdentitySchema.extend({
2308
+ revision: z.number().int().positive(),
2309
+ documentVersion: z.number().int().positive(),
2310
+ description: z.string().max(MAX_DESCRIPTION),
2311
+ publishedAt: z.iso.datetime(),
2312
+ ...textStyleLibraryPayloadSchema.shape
2313
+ });
2314
+ const publishTextStyleLibraryInputSchema = textStyleLibraryIdentitySchema.extend({
2315
+ mutationId: z.uuid(),
2316
+ expectedRevision: z.number().int().nonnegative(),
2317
+ documentVersion: z.number().int().positive(),
2318
+ publish: styleIds,
2319
+ remove: styleIds,
2320
+ description: z.string().trim().max(MAX_DESCRIPTION)
2321
+ }).strict().refine((input) => {
2322
+ const ids = [...input.publish, ...input.remove];
2323
+ return ids.length > 0 && ids.length <= MAX_STYLES && new Set(ids).size === ids.length;
2324
+ }, { message: "Select each changed style once." });
2325
+ const libraryCursorSchema = z.object({
1532
2326
  canvasId: z.uuid(),
1533
- contentType: z.enum(CANVAS_IMAGE_CONTENT_TYPES),
1534
- bytes: z.number().int().positive().max(MAX_CANVAS_IMAGE_BYTES)
2327
+ title: z.string().max(MAX_TITLE)
1535
2328
  });
1536
- const reserveCanvasImageOutputSchema = z.object({
1537
- assetId: z.uuid(),
1538
- path: z.string().startsWith("/v1/canvas-assets/"),
1539
- upload: signedUploadSchema
2329
+ const listTextStyleLibrariesInputSchema = z.object({
2330
+ search: z.string().trim().max(MAX_TITLE).default(""),
2331
+ cursor: libraryCursorSchema.nullable().default(null),
2332
+ limit: z.number().int().min(1).max(MAX_PAGE).default(DEFAULT_PAGE)
2333
+ });
2334
+ const textStyleLibrarySummarySchema = z.object({
2335
+ canvasId: z.uuid(),
2336
+ title: z.string(),
2337
+ organisationId: z.uuid().nullable(),
2338
+ revision: z.number().int().positive(),
2339
+ styleCount: z.number().int().positive(),
2340
+ publishedAt: z.iso.datetime()
2341
+ });
2342
+ const listTextStyleLibrariesOutputSchema = z.object({
2343
+ items: z.array(textStyleLibrarySummarySchema).max(MAX_PAGE),
2344
+ nextCursor: libraryCursorSchema.nullable()
1540
2345
  });
1541
- const canvasImageAssetPath = (canvasId, assetId) => `/v1/canvas-assets/${encodeURIComponent(canvasId)}/${encodeURIComponent(assetId)}`;
1542
2346
 
1543
2347
  //#endregion
1544
- //#region ../../packages/contract/src/canvas/canvas-property-section.schema.ts
1545
- const CANVAS_PROPERTY_SECTIONS = [
1546
- "position",
1547
- "layout",
1548
- "clip",
1549
- "cornerRadius",
1550
- "blending",
1551
- "typography",
1552
- "nativeControl",
1553
- "textDecoration",
1554
- "fill",
1555
- "outline",
1556
- "textStroke",
1557
- "border",
1558
- "outerShadow",
1559
- "innerShadow",
1560
- "filters",
1561
- "additionalStyles",
1562
- "vector",
1563
- "export",
1564
- "source"
1565
- ];
1566
- const canvasPropertySectionSchema = z.enum(CANVAS_PROPERTY_SECTIONS);
1567
-
1568
- //#endregion
1569
- //#region ../../packages/contract/src/canvas/canvas-inspection.schema.ts
1570
- const MAX_NODE_ID_LENGTH$5 = 200;
1571
- const MAX_RENDER_MESSAGE_LENGTH = 500;
1572
- const MAX_RENDER_KIND_LENGTH = 100;
1573
- const canvasInspectNodeSummarySchema = z.object({
1574
- id: z.string().min(1).max(MAX_NODE_ID_LENGTH$5),
1575
- label: z.string().max(MAX_RENDER_MESSAGE_LENGTH),
1576
- kind: z.string().min(1).max(MAX_RENDER_KIND_LENGTH),
1577
- parentId: z.string().min(1).max(MAX_NODE_ID_LENGTH$5).nullable(),
1578
- childCount: z.number().int().min(0),
1579
- box: canvasWorldBoundsSchema.nullable(),
1580
- propertySections: z.array(canvasPropertySectionSchema)
2348
+ //#region ../../packages/contract/src/canvas/canvas-operation.schema.ts
2349
+ const convertedSubtreeRelationshipSchema = z.object({
2350
+ parentId: z.string().min(1).max(200),
2351
+ sortKey: z.string().min(1).max(500)
1581
2352
  });
1582
- const inspectCanvasInputSchema = z.object({ canvasId: z.uuid() });
1583
- const inspectCanvasOutputSchema = z.object({
1584
- canvasId: z.uuid(),
1585
- openUrl: z.url(),
1586
- title: z.string().min(1),
1587
- version: z.number().int().positive(),
1588
- nodeCount: z.number().int().min(0),
1589
- rootChildCount: z.number().int().min(0),
1590
- bounds: canvasWorldBoundsSchema.nullable(),
1591
- kinds: z.record(z.string(), z.number().int().min(0)),
1592
- next: z.array(z.string().min(1))
2353
+ const insertConvertedSubtreeOperationSchema = z.object({
2354
+ op: z.literal("insertConvertedSubtree"),
2355
+ destination: canvasConversionDestinationSchema,
2356
+ sourceNodeId: z.string().min(1).max(200).optional(),
2357
+ rootNodeId: z.string().min(1).max(200),
2358
+ nodes: z.record(z.string().min(1).max(200), canvasSceneNodeSchema).refine((nodes) => Object.keys(nodes).length <= MAX_CANVAS_CONVERSION_NODES),
2359
+ relationships: z.record(z.string().min(1).max(200), convertedSubtreeRelationshipSchema).refine((relationships) => Object.keys(relationships).length < MAX_CANVAS_CONVERSION_NODES)
1593
2360
  });
1594
- const inspectCanvasTreeInputSchema = z.object({ canvasId: z.uuid() });
1595
- const inspectCanvasTreeOutputSchema = z.object({
1596
- canvasId: z.uuid(),
1597
- version: z.number().int().positive(),
1598
- nodes: z.array(canvasInspectNodeSummarySchema)
2361
+ const MAX_NODE_ID_LENGTH$6 = 200;
2362
+ const MAX_LABEL_LENGTH$1 = 500;
2363
+ const MAX_TEXT_LENGTH$1 = 1e5;
2364
+ const MAX_CANVAS_OPERATIONS = 1e3;
2365
+ const nodeIdSchema$1 = z.string().min(1).max(MAX_NODE_ID_LENGTH$6);
2366
+ const sortKeySchema = z.string().min(1).max(MAX_LABEL_LENGTH$1);
2367
+ const writableBoxSchema = canvasSceneBoxSchema.extend({
2368
+ width: z.number().positive(),
2369
+ height: z.number().positive()
1599
2370
  });
1600
- const inspectCanvasNodeInputSchema = z.object({
2371
+ const placementSchema = z.object({
2372
+ parentId: nodeIdSchema$1,
2373
+ afterId: nodeIdSchema$1.optional()
2374
+ });
2375
+ const parentageSchema = z.object({
2376
+ parentId: nodeIdSchema$1,
2377
+ sortKey: sortKeySchema
2378
+ });
2379
+ const canvasSetStylesOperationSchema = z.object({
2380
+ op: z.literal("setStyles"),
2381
+ nodeId: nodeIdSchema$1,
2382
+ styles: canvasNodeStylePatchSchema,
2383
+ clear: z.array(canvasRestorableStylePropertySchema).min(1).max(Object.keys(canvasNodeStylePatchSchema.shape).length).refine((properties) => new Set(properties).size === properties.length).optional()
2384
+ }).refine((operation) => (operation.clear ?? []).every((property) => !Object.hasOwn(operation.styles, property)));
2385
+ const canvasOperationSchema = z.discriminatedUnion("op", [
2386
+ insertConvertedSubtreeOperationSchema,
2387
+ z.object({
2388
+ op: z.literal("insertNode"),
2389
+ node: canvasSceneNodeSchema,
2390
+ parentage: parentageSchema
2391
+ }),
2392
+ placementSchema.extend({
2393
+ op: z.literal("insertText"),
2394
+ nodeId: nodeIdSchema$1,
2395
+ label: z.string().max(MAX_LABEL_LENGTH$1).default("Text"),
2396
+ text: z.string().max(MAX_TEXT_LENGTH$1),
2397
+ box: writableBoxSchema,
2398
+ styles: canvasTextStylesSchema.default({})
2399
+ }),
2400
+ placementSchema.extend({
2401
+ op: z.literal("insertPrototype"),
2402
+ nodeId: nodeIdSchema$1,
2403
+ label: z.string().max(MAX_LABEL_LENGTH$1).default("Prototype"),
2404
+ prototypeId: z.uuid(),
2405
+ deploymentId: z.uuid(),
2406
+ box: writableBoxSchema,
2407
+ canvasPageId: nodeIdSchema$1.optional()
2408
+ }),
2409
+ z.object({
2410
+ op: z.literal("setPrototypeDeployment"),
2411
+ nodeId: nodeIdSchema$1,
2412
+ prototypeId: z.uuid(),
2413
+ deploymentId: z.uuid()
2414
+ }),
2415
+ canvasEditTextOperationSchema,
2416
+ z.object({
2417
+ op: z.literal("setText"),
2418
+ nodeId: nodeIdSchema$1,
2419
+ text: z.string().max(MAX_TEXT_LENGTH$1)
2420
+ }),
2421
+ z.object({
2422
+ op: z.literal("setBox"),
2423
+ nodeId: nodeIdSchema$1,
2424
+ box: z.union([canvasSceneBoxSchema, z.literal("default")])
2425
+ }),
2426
+ z.object({
2427
+ op: z.literal("setLabel"),
2428
+ nodeId: nodeIdSchema$1,
2429
+ label: z.string().trim().min(1).max(MAX_LABEL_LENGTH$1),
2430
+ labelOrigin: canvasNodeLabelOriginSchema.nullable().optional()
2431
+ }),
2432
+ z.object({
2433
+ op: z.literal("setContainerKind"),
2434
+ nodeId: nodeIdSchema$1,
2435
+ component: z.enum(["frame", "group"])
2436
+ }),
2437
+ z.object({
2438
+ op: z.literal("setVisibility"),
2439
+ nodeId: nodeIdSchema$1,
2440
+ visible: z.boolean().nullable()
2441
+ }),
2442
+ z.object({
2443
+ op: z.literal("setLocked"),
2444
+ nodeId: nodeIdSchema$1,
2445
+ locked: z.boolean().nullable()
2446
+ }),
2447
+ z.object({
2448
+ op: z.literal("setConstraints"),
2449
+ nodeId: nodeIdSchema$1,
2450
+ constraints: canvasNodeConstraintsSchema
2451
+ }),
2452
+ canvasSetStylesOperationSchema,
2453
+ z.object({
2454
+ op: z.literal("setAppearance"),
2455
+ nodeId: nodeIdSchema$1,
2456
+ appearance: canvasAppearancePatchSchema
2457
+ }),
2458
+ z.object({
2459
+ op: z.literal("setLayout"),
2460
+ nodeId: nodeIdSchema$1,
2461
+ layout: z.union([canvasNodeLayoutSchema, z.literal("default")])
2462
+ }),
2463
+ z.object({
2464
+ op: z.literal("patchTypography"),
2465
+ nodeId: nodeIdSchema$1,
2466
+ typography: canvasTypographyPatchSchema
2467
+ }),
2468
+ z.object({
2469
+ op: z.literal("setTypography"),
2470
+ nodeId: nodeIdSchema$1,
2471
+ typography: z.union([canvasAuthoredTypographySchema, z.literal("default")])
2472
+ }),
2473
+ z.object({
2474
+ op: z.literal("patchAdditionalStyles"),
2475
+ nodeId: nodeIdSchema$1,
2476
+ additionalStyles: canvasAdditionalStylePatchSchema
2477
+ }),
2478
+ z.object({
2479
+ op: z.literal("setAdditionalStyles"),
2480
+ nodeId: nodeIdSchema$1,
2481
+ additionalStyles: z.union([canvasAdditionalStylesSchema, z.literal("default")])
2482
+ }),
2483
+ z.object({
2484
+ op: z.literal("setTextStyleLibrary"),
2485
+ nodeId: z.literal("root"),
2486
+ sourceCanvasId: z.uuid(),
2487
+ library: enabledTextStyleLibrarySchema.nullable()
2488
+ }),
2489
+ z.object({
2490
+ op: z.literal("patchFontLibrary"),
2491
+ nodeId: z.literal("root"),
2492
+ fonts: canvasFontLibraryPatchSchema
2493
+ }),
2494
+ z.object({
2495
+ op: z.literal("setTextStyle"),
2496
+ nodeId: z.literal("root"),
2497
+ styleId: canvasTextStyleSchema.shape.id,
2498
+ textStyle: canvasTextStyleSchema.nullable()
2499
+ }).refine((operation) => operation.textStyle === null || operation.textStyle.id === operation.styleId, "text style identity must match"),
2500
+ z.object({
2501
+ op: z.literal("setProps"),
2502
+ nodeId: nodeIdSchema$1,
2503
+ props: z.union([z.record(z.string(), z.unknown()), z.literal("default")])
2504
+ }),
2505
+ z.object({
2506
+ op: z.literal("setParentage"),
2507
+ nodeId: nodeIdSchema$1,
2508
+ parentage: parentageSchema
2509
+ }),
2510
+ placementSchema.extend({
2511
+ op: z.literal("move"),
2512
+ nodeId: nodeIdSchema$1
2513
+ }),
2514
+ z.object({
2515
+ op: z.literal("remove"),
2516
+ nodeId: nodeIdSchema$1,
2517
+ removedText: z.record(nodeIdSchema$1, canvasSceneNodeSchema.pick({ props: true })).optional()
2518
+ })
2519
+ ]);
2520
+ const applyCanvasOperationsInputSchema = z.object({
1601
2521
  canvasId: z.uuid(),
1602
- nodeId: z.string().min(1).max(MAX_NODE_ID_LENGTH$5)
2522
+ mutationId: z.uuid(),
2523
+ documentFormatVersion: canvasDocumentFormatSchema,
2524
+ baseVersion: z.number().int().positive(),
2525
+ operations: z.array(canvasOperationSchema).min(1).max(MAX_CANVAS_OPERATIONS)
1603
2526
  });
1604
- const inspectCanvasNodeOutputSchema = z.object({
2527
+ const applyCanvasOperationsOutputSchema = z.object({
1605
2528
  canvasId: z.uuid(),
2529
+ mutationId: z.uuid(),
2530
+ previousVersion: z.number().int().positive(),
1606
2531
  version: z.number().int().positive(),
1607
- node: canvasInspectNodeSummarySchema.extend({
1608
- styles: z.record(z.string(), z.union([z.string(), z.number()])),
1609
- layout: canvasNodeLayoutSchema.optional(),
1610
- appearance: canvasAppearanceValuesSchema.optional(),
1611
- typography: canvasTypographySchema.optional(),
1612
- additionalStyles: canvasAdditionalStylesSchema.optional(),
1613
- props: z.record(z.string(), z.unknown()),
1614
- children: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$5))
1615
- }),
2532
+ operations: z.array(canvasOperationSchema),
2533
+ insertedNodeIds: z.array(nodeIdSchema$1),
2534
+ changedNodeIds: z.array(nodeIdSchema$1),
2535
+ removedNodeIds: z.array(nodeIdSchema$1),
2536
+ boxes: z.record(nodeIdSchema$1, canvasSceneBoxSchema),
2537
+ affectedBounds: writableBoxSchema.nullable(),
2538
+ next: z.array(z.string().min(1))
2539
+ });
2540
+ const createEditableFrameOutputSchema = createEditableFrameResultSchema.extend({
2541
+ operation: insertConvertedSubtreeOperationSchema,
1616
2542
  next: z.array(z.string().min(1))
1617
2543
  });
1618
2544
 
1619
2545
  //#endregion
1620
- //#region ../../packages/contract/src/canvas/canvas-layout-ownership.lib.ts
1621
- const CANVAS_LAYOUT_CSS_FIELDS = [
1622
- ["alignSelf", "align-self"],
1623
- ["order", "order"],
1624
- ["flexGrow", "flex-grow"],
1625
- ["flexShrink", "flex-shrink"],
1626
- ["flexBasis", "flex-basis"],
1627
- ["aspectRatio", "aspect-ratio"]
1628
- ];
1629
- const CANVAS_CONTAINER_CSS_FIELDS = [
1630
- ["direction", "flex-direction"],
1631
- ["wrap", "flex-wrap"],
1632
- ["alignItems", "align-items"],
1633
- ["alignContent", "align-content"],
1634
- ["justifyContent", "justify-content"],
1635
- ["rowGap", "row-gap"],
1636
- ["columnGap", "column-gap"]
1637
- ];
1638
- const SIDES = [
1639
- "top",
1640
- "right",
1641
- "bottom",
1642
- "left"
1643
- ];
1644
- const releasedSpacing = (held, prefix, properties) => {
1645
- const next = { ...held };
1646
- for (const side of SIDES) if (properties.has(`${prefix}-${side}`)) Reflect.deleteProperty(next, side);
1647
- return next;
1648
- };
1649
- /** A shorthand can release several named controls; a longhand releases only itself. */
1650
- const releasedFields = (held, changed) => {
1651
- const properties = new Set([...changed].flatMap((property) => canvasCssPropertyScope(property)));
1652
- const layout = { ...held };
1653
- for (const [key, property] of CANVAS_LAYOUT_CSS_FIELDS) if (properties.has(property)) Reflect.deleteProperty(layout, key);
1654
- if (layout.margin !== void 0) layout.margin = releasedSpacing(layout.margin, "margin", properties);
1655
- if (layout.container === void 0) return layout;
1656
- const container = { ...layout.container };
1657
- if ((properties.has("row-gap") || properties.has("column-gap")) && container.gap !== void 0) {
1658
- container.rowGap ??= container.gap;
1659
- container.columnGap ??= container.gap;
1660
- Reflect.deleteProperty(container, "gap");
1661
- }
1662
- for (const [key, property] of CANVAS_CONTAINER_CSS_FIELDS) if (properties.has(property)) Reflect.deleteProperty(container, key);
1663
- if (container.padding !== void 0) container.padding = releasedSpacing(container.padding, "padding", properties);
1664
- if (properties.has("grid-template-columns")) {
1665
- Reflect.deleteProperty(container, "gridColumns");
1666
- Reflect.deleteProperty(container, "gridAutoRepeat");
1667
- }
1668
- layout.container = container;
2546
+ //#region ../../packages/contract/src/canvas/canvas-document.schema.ts
2547
+ /** More screens than one canvas has ever held, and a bound on one save's work. */
2548
+ const MAX_SCREENS_PER_DOCUMENT = 2e3;
2549
+ /** Reads retain unsupported documents; the write boundary validates the current scene format. */
2550
+ const canvasDocumentBlobSchema = z.record(z.string(), z.unknown());
2551
+ const getCanvasDocumentInputSchema = z.object({
2552
+ canvasId: z.uuid(),
2553
+ afterVersion: z.number().int().positive().optional()
2554
+ });
2555
+ const documentScreenSchema = z.object({
2556
+ screenId: z.uuid(),
2557
+ /** Null for a link visitor. Always present on the agent surface. */
2558
+ route: z.string().max(MAX_URL_LENGTH).nullable(),
2559
+ title: z.string().max(200).nullable(),
2560
+ viewport: z.object({
2561
+ width: z.number().int().positive(),
2562
+ height: z.number().int().positive()
2563
+ }),
2564
+ atMs: z.number().int().min(0).nullable(),
2565
+ sourceRecordingId: z.uuid().nullable(),
2566
+ /** Durable rendering dependency, deliberately independent of recording provenance. */
2567
+ assetBundle: z.object({
2568
+ assetBundleId: z.uuid(),
2569
+ sourceUrl: z.string().max(MAX_URL_LENGTH),
2570
+ assets: z.array(z.object({
2571
+ url: z.string().max(MAX_URL_LENGTH),
2572
+ contentType: z.string().max(200),
2573
+ path: z.string().startsWith("/v1/recording-assets/")
2574
+ })),
2575
+ missingAssetCount: z.number().int().min(0)
2576
+ }).nullable(),
2577
+ /** Null while the blob has not landed. The client draws an empty frame with its label. */
2578
+ download: signedDownloadSchema.nullable()
2579
+ });
2580
+ const canvasMutationRevisionSchema = z.object({
2581
+ mutationId: z.uuid(),
2582
+ previousVersion: z.number().int().positive(),
2583
+ version: z.number().int().positive(),
2584
+ operations: z.array(canvasOperationSchema)
2585
+ });
2586
+ const getCanvasDocumentOutputSchema = z.object({
2587
+ mutations: z.array(canvasMutationRevisionSchema).optional(),
2588
+ version: z.number().int().min(1),
2589
+ document: canvasDocumentBlobSchema,
2590
+ /** The manifest, resolved and signed. This is what makes a cold open one round trip. */
2591
+ screens: z.array(documentScreenSchema)
2592
+ });
2593
+ const saveCanvasDocumentInputSchema = z.object({
2594
+ canvasId: z.uuid(),
2595
+ baseVersion: z.number().int().min(1),
2596
+ document: canvasDocumentBlobSchema.refine((document) => canvasSceneDocumentSchema.safeParse(document).success, "A save requires a valid current-format canvas document."),
2597
+ /** Every screen the document names. Replaces the manifest wholesale. */
2598
+ screenIds: z.array(z.uuid()).max(MAX_SCREENS_PER_DOCUMENT)
2599
+ });
2600
+ /**
2601
+ * A conflict is an outcome, not an error. `AppError` is `{ code, message, fields? }` and a
2602
+ * whole document does not fit in it — and a path that is expected to fire should not go
2603
+ * through the error log line and the tRPC error protocol on its way to a merge dialog.
2604
+ */
2605
+ const saveCanvasDocumentOutputSchema = z.discriminatedUnion("outcome", [z.object({
2606
+ outcome: z.literal("saved"),
2607
+ version: z.number().int().min(1)
2608
+ }), z.object({
2609
+ outcome: z.literal("conflict"),
2610
+ version: z.number().int().min(1),
2611
+ document: canvasDocumentBlobSchema
2612
+ })]);
2613
+
2614
+ //#endregion
2615
+ //#region ../../packages/contract/src/canvas/canvas-image-asset.schema.ts
2616
+ const CANVAS_ASSET_PATH_PREFIX = "/v1/canvas-assets/";
2617
+ const CANVAS_IMAGE_CONTENT_TYPES = [
2618
+ "image/avif",
2619
+ "image/gif",
2620
+ "image/jpeg",
2621
+ "image/png",
2622
+ "image/webp"
2623
+ ];
2624
+ const BYTES_PER_KIBIBYTE$1 = 1024;
2625
+ const KIBIBYTES_PER_MEBIBYTE$1 = 1024;
2626
+ const MAX_CANVAS_IMAGE_MEBIBYTES = 20;
2627
+ const MAX_CANVAS_IMAGE_BYTES = MAX_CANVAS_IMAGE_MEBIBYTES * BYTES_PER_KIBIBYTE$1 * KIBIBYTES_PER_MEBIBYTE$1;
2628
+ const reserveCanvasImageInputSchema = z.object({
2629
+ canvasId: z.uuid(),
2630
+ contentType: z.enum(CANVAS_IMAGE_CONTENT_TYPES),
2631
+ bytes: z.number().int().positive().max(MAX_CANVAS_IMAGE_BYTES)
2632
+ });
2633
+ const reserveCanvasImageOutputSchema = z.object({
2634
+ assetId: z.uuid(),
2635
+ path: z.string().startsWith("/v1/canvas-assets/"),
2636
+ upload: signedUploadSchema
2637
+ });
2638
+ const canvasImageAssetPath = (canvasId, assetId) => `${CANVAS_ASSET_PATH_PREFIX}${encodeURIComponent(canvasId)}/${encodeURIComponent(assetId)}`;
2639
+
2640
+ //#endregion
2641
+ //#region ../../packages/contract/src/canvas/canvas-font-asset.schema.ts
2642
+ const BYTES_PER_KIBIBYTE = 1024;
2643
+ const KIBIBYTES_PER_MEBIBYTE = 1024;
2644
+ const MAX_FONT_MEBIBYTES = 20;
2645
+ const MAX_CANVAS_FONT_BYTES = MAX_FONT_MEBIBYTES * BYTES_PER_KIBIBYTE * KIBIBYTES_PER_MEBIBYTE;
2646
+ const CANVAS_FONT_CONTENT_TYPES = [
2647
+ "font/ttf",
2648
+ "font/otf",
2649
+ "font/woff",
2650
+ "font/woff2"
2651
+ ];
2652
+ const canvasFontAssetIdentitySchema = z.object({
2653
+ canvasId: z.uuid(),
2654
+ sha256: z.string().regex(/^[a-f0-9]{64}$/u)
2655
+ });
2656
+ const completeCanvasFontInputSchema = canvasFontAssetIdentitySchema.extend({ bytes: z.number().int().positive().max(MAX_CANVAS_FONT_BYTES) });
2657
+ const reserveCanvasFontInputSchema = completeCanvasFontInputSchema.extend({ contentType: z.enum(CANVAS_FONT_CONTENT_TYPES) });
2658
+ const completeCanvasFontOutputSchema = z.object({ path: z.string().startsWith("/v1/canvas-assets/") });
2659
+ const reserveCanvasFontOutputSchema = completeCanvasFontOutputSchema.extend({ upload: signedUploadSchema });
2660
+ const canvasFontAssetPath = (canvasId, sha256) => `${CANVAS_ASSET_PATH_PREFIX}${encodeURIComponent(canvasId)}/fonts/${encodeURIComponent(sha256)}`;
2661
+ const copyCanvasFontsInputSchema = z.object({
2662
+ canvasId: z.uuid(),
2663
+ sources: z.array(canvasFontAssetIdentitySchema).min(1).max(100)
2664
+ });
2665
+ const copyCanvasFontsOutputSchema = z.object({ resources: z.array(z.object({
2666
+ source: canvasFontAssetIdentitySchema,
2667
+ path: z.string()
2668
+ })) });
2669
+
2670
+ //#endregion
2671
+ //#region ../../packages/contract/src/canvas/canvas-property-section.schema.ts
2672
+ const CANVAS_PROPERTY_SECTIONS = [
2673
+ "position",
2674
+ "layout",
2675
+ "clip",
2676
+ "cornerRadius",
2677
+ "blending",
2678
+ "typography",
2679
+ "nativeControl",
2680
+ "textDecoration",
2681
+ "fill",
2682
+ "outline",
2683
+ "textStroke",
2684
+ "border",
2685
+ "outerShadow",
2686
+ "innerShadow",
2687
+ "filters",
2688
+ "additionalStyles",
2689
+ "vector",
2690
+ "export",
2691
+ "source"
2692
+ ];
2693
+ const canvasPropertySectionSchema = z.enum(CANVAS_PROPERTY_SECTIONS);
2694
+
2695
+ //#endregion
2696
+ //#region ../../packages/contract/src/canvas/canvas-inspection.schema.ts
2697
+ const MAX_NODE_ID_LENGTH$5 = 200;
2698
+ const MAX_RENDER_MESSAGE_LENGTH = 500;
2699
+ const MAX_RENDER_KIND_LENGTH = 100;
2700
+ const canvasInspectNodeSummarySchema = z.object({
2701
+ id: z.string().min(1).max(MAX_NODE_ID_LENGTH$5),
2702
+ label: z.string().max(MAX_RENDER_MESSAGE_LENGTH),
2703
+ kind: z.string().min(1).max(MAX_RENDER_KIND_LENGTH),
2704
+ parentId: z.string().min(1).max(MAX_NODE_ID_LENGTH$5).nullable(),
2705
+ childCount: z.number().int().min(0),
2706
+ box: canvasWorldBoundsSchema.nullable(),
2707
+ propertySections: z.array(canvasPropertySectionSchema)
2708
+ });
2709
+ const inspectCanvasInputSchema = z.object({ canvasId: z.uuid() });
2710
+ const inspectCanvasOutputSchema = z.object({
2711
+ canvasId: z.uuid(),
2712
+ openUrl: z.url(),
2713
+ title: z.string().min(1),
2714
+ version: z.number().int().positive(),
2715
+ nodeCount: z.number().int().min(0),
2716
+ rootChildCount: z.number().int().min(0),
2717
+ bounds: canvasWorldBoundsSchema.nullable(),
2718
+ kinds: z.record(z.string(), z.number().int().min(0)),
2719
+ next: z.array(z.string().min(1))
2720
+ });
2721
+ const inspectCanvasTreeInputSchema = z.object({ canvasId: z.uuid() });
2722
+ const inspectCanvasTreeOutputSchema = z.object({
2723
+ canvasId: z.uuid(),
2724
+ version: z.number().int().positive(),
2725
+ nodes: z.array(canvasInspectNodeSummarySchema)
2726
+ });
2727
+ const inspectCanvasNodeInputSchema = z.object({
2728
+ canvasId: z.uuid(),
2729
+ nodeId: z.string().min(1).max(MAX_NODE_ID_LENGTH$5)
2730
+ });
2731
+ const inspectCanvasNodeOutputSchema = z.object({
2732
+ canvasId: z.uuid(),
2733
+ version: z.number().int().positive(),
2734
+ node: canvasInspectNodeSummarySchema.extend({
2735
+ styles: z.record(z.string(), z.union([z.string(), z.number()])),
2736
+ layout: canvasNodeLayoutSchema.optional(),
2737
+ appearance: canvasAppearanceValuesSchema.optional(),
2738
+ typography: canvasAuthoredTypographySchema.optional(),
2739
+ additionalStyles: canvasAdditionalStylesSchema.optional(),
2740
+ props: z.record(z.string(), z.unknown()),
2741
+ children: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$5))
2742
+ }),
2743
+ next: z.array(z.string().min(1))
2744
+ });
2745
+
2746
+ //#endregion
2747
+ //#region ../../packages/contract/src/canvas/canvas-layout-ownership.lib.ts
2748
+ const CANVAS_LAYOUT_CSS_FIELDS = [
2749
+ ["alignSelf", "align-self"],
2750
+ ["order", "order"],
2751
+ ["flexGrow", "flex-grow"],
2752
+ ["flexShrink", "flex-shrink"],
2753
+ ["flexBasis", "flex-basis"],
2754
+ ["aspectRatio", "aspect-ratio"]
2755
+ ];
2756
+ const CANVAS_CONTAINER_CSS_FIELDS = [
2757
+ ["direction", "flex-direction"],
2758
+ ["wrap", "flex-wrap"],
2759
+ ["alignItems", "align-items"],
2760
+ ["alignContent", "align-content"],
2761
+ ["justifyContent", "justify-content"],
2762
+ ["rowGap", "row-gap"],
2763
+ ["columnGap", "column-gap"]
2764
+ ];
2765
+ const SIDES = [
2766
+ "top",
2767
+ "right",
2768
+ "bottom",
2769
+ "left"
2770
+ ];
2771
+ const releasedSpacing = (held, prefix, properties) => {
2772
+ const next = { ...held };
2773
+ for (const side of SIDES) if (properties.has(`${prefix}-${side}`)) Reflect.deleteProperty(next, side);
2774
+ return next;
2775
+ };
2776
+ /** A shorthand can release several named controls; a longhand releases only itself. */
2777
+ const releasedFields = (held, changed) => {
2778
+ const properties = new Set([...changed].flatMap((property) => canvasCssPropertyScope(property)));
2779
+ const layout = { ...held };
2780
+ for (const [key, property] of CANVAS_LAYOUT_CSS_FIELDS) if (properties.has(property)) Reflect.deleteProperty(layout, key);
2781
+ if (layout.margin !== void 0) layout.margin = releasedSpacing(layout.margin, "margin", properties);
2782
+ if (layout.container === void 0) return layout;
2783
+ const container = { ...layout.container };
2784
+ if ((properties.has("row-gap") || properties.has("column-gap")) && container.gap !== void 0) {
2785
+ container.rowGap ??= container.gap;
2786
+ container.columnGap ??= container.gap;
2787
+ Reflect.deleteProperty(container, "gap");
2788
+ }
2789
+ for (const [key, property] of CANVAS_CONTAINER_CSS_FIELDS) if (properties.has(property)) Reflect.deleteProperty(container, key);
2790
+ if (container.padding !== void 0) container.padding = releasedSpacing(container.padding, "padding", properties);
2791
+ if (properties.has("grid-template-columns")) {
2792
+ Reflect.deleteProperty(container, "gridColumns");
2793
+ Reflect.deleteProperty(container, "gridAutoRepeat");
2794
+ }
2795
+ layout.container = container;
1669
2796
  return layout;
1670
2797
  };
1671
2798
  const axisWithoutCssBounds = (intent, properties, changed) => {
@@ -1901,433 +3028,75 @@ const DESCRIPTOR_BY_KIND = Object.fromEntries([
1901
3028
  selectionBehavior: { hitTarget: "frame" },
1902
3029
  resizeBehavior: {
1903
3030
  mode: "scale",
1904
- preservesAspect: true,
1905
- canLockAspectRatio: true
1906
- },
1907
- propertySections: SVG_PROPERTY_SECTIONS
1908
- },
1909
- {
1910
- objectKind: RECORDING_KIND,
1911
- label: "Recording",
1912
- category: "media",
1913
- capabilities: {
1914
- canSelect: true,
1915
- canContainChildren: false,
1916
- canEditProperties: false
1917
- },
1918
- capture: { preservesAssets: true },
1919
- selectionBehavior: { hitTarget: "frame" },
1920
- resizeBehavior: {
1921
- mode: "scale",
1922
- preservesAspect: true,
1923
- canLockAspectRatio: true
1924
- },
1925
- propertySections: []
1926
- },
1927
- {
1928
- objectKind: TEXT_KIND,
1929
- label: "Text",
1930
- category: "primitive",
1931
- capabilities: {
1932
- canSelect: true,
1933
- canContainChildren: false,
1934
- canEditProperties: true,
1935
- commentAnchor: "node"
1936
- },
1937
- selectionBehavior: { hitTarget: "text" },
1938
- resizeBehavior: {
1939
- mode: "reflow",
1940
- preservesAspect: false,
1941
- canLockAspectRatio: false
1942
- },
1943
- propertySections: [
1944
- "position",
1945
- "layout",
1946
- "typography",
1947
- "nativeControl",
1948
- "textDecoration",
1949
- "textStroke",
1950
- "blending",
1951
- "fill",
1952
- "outerShadow",
1953
- "filters",
1954
- "additionalStyles",
1955
- "export"
1956
- ]
1957
- }
1958
- ].map((descriptor) => [descriptor.objectKind, descriptor]));
1959
- const canvasObjectKindDescriptor = (objectKind) => DESCRIPTOR_BY_KIND[objectKind] ?? null;
1960
- const canvasPropertySectionsForKind = (objectKind) => canvasObjectKindDescriptor(objectKind)?.propertySections ?? [];
1961
-
1962
- //#endregion
1963
- //#region ../../packages/contract/src/canvas/canvas-operation-styles.schema.ts
1964
- const TEXT_SIZE_SMALL = 16;
1965
- const TEXT_SIZE_MEDIUM = 24;
1966
- const TEXT_SIZE_LARGE = 40;
1967
- const TEXT_SIZE_HUGE = 64;
1968
- const TEXT_SIZE_MEGA = 96;
1969
- const MIN_LETTER_SPACING = -100;
1970
- const MAX_LETTER_SPACING = 100;
1971
- const MAX_LINE_HEIGHT = 1e4;
1972
- const nonNegativePixelLengthSchema = z.string().regex(/^(?:\d+(?:\.\d+)?|\.\d+)px$/u);
1973
- const signedPixelLengthSchema = z.string().regex(/^-?(?:\d+(?:\.\d+)?|\.\d+)px$/u);
1974
- const textStyleValues = {
1975
- color: z.union([z.enum([
1976
- "var(--note-ink)",
1977
- "var(--note-slate)",
1978
- "var(--note-red)",
1979
- "var(--note-orange)",
1980
- "var(--note-amber)",
1981
- "var(--note-green)",
1982
- "var(--note-teal)",
1983
- "var(--note-blue)",
1984
- "var(--note-violet)",
1985
- "var(--note-magenta)"
1986
- ]), z.string().regex(/^#[\da-f]{6}$/iu)]),
1987
- "font-family": z.enum(["var(--sans)", "var(--mono)"]),
1988
- "font-size": z.union([
1989
- z.literal(TEXT_SIZE_SMALL),
1990
- z.literal(TEXT_SIZE_MEDIUM),
1991
- z.literal(TEXT_SIZE_LARGE),
1992
- z.literal(TEXT_SIZE_HUGE),
1993
- z.literal(TEXT_SIZE_MEGA)
1994
- ]),
1995
- "font-weight": z.enum(["400", "700"]),
1996
- "font-style": z.enum([
1997
- "normal",
1998
- "italic",
1999
- "oblique"
2000
- ]),
2001
- "letter-spacing": z.number().min(MIN_LETTER_SPACING).max(MAX_LETTER_SPACING),
2002
- "line-height": z.union([z.number().positive().max(MAX_LINE_HEIGHT), z.string().regex(/^(?:\d+(?:\.\d+)?(?:px|em|rem|%)?|normal)$/u)]),
2003
- "text-align": z.enum([
2004
- "left",
2005
- "center",
2006
- "right"
2007
- ]),
2008
- "white-space": z.enum([
2009
- "normal",
2010
- "nowrap",
2011
- "pre",
2012
- "pre-wrap",
2013
- "pre-line",
2014
- "break-spaces"
2015
- ])
2016
- };
2017
- const canvasTextStylesSchema = z.strictObject({
2018
- color: textStyleValues.color.optional(),
2019
- "font-family": textStyleValues["font-family"].optional(),
2020
- "font-size": textStyleValues["font-size"].optional(),
2021
- "font-weight": textStyleValues["font-weight"].optional(),
2022
- "font-style": textStyleValues["font-style"].optional(),
2023
- "letter-spacing": textStyleValues["letter-spacing"].optional(),
2024
- "line-height": textStyleValues["line-height"].optional(),
2025
- "text-align": textStyleValues["text-align"].optional(),
2026
- "white-space": textStyleValues["white-space"].optional()
2027
- });
2028
- const canvasTextStylePatchSchema = z.strictObject({
2029
- color: textStyleValues.color.nullable().optional(),
2030
- "font-family": textStyleValues["font-family"].nullable().optional(),
2031
- "font-size": z.union([nonNegativeCanvasNumberSchema, nonNegativePixelLengthSchema]).nullable().optional(),
2032
- "font-weight": z.string().regex(/^(?:[1-9]\d{0,2}|1000)$/u).nullable().optional(),
2033
- "font-style": textStyleValues["font-style"].nullable().optional(),
2034
- "font-stretch": z.union([z.enum([
2035
- "normal",
2036
- "ultra-condensed",
2037
- "extra-condensed",
2038
- "condensed",
2039
- "semi-condensed",
2040
- "semi-expanded",
2041
- "expanded",
2042
- "extra-expanded",
2043
- "ultra-expanded"
2044
- ]), z.string().regex(/^\d+(?:\.\d+)?%$/u)]).nullable().optional(),
2045
- "letter-spacing": z.union([
2046
- boundedCanvasNumberSchema,
2047
- signedPixelLengthSchema,
2048
- z.literal("normal")
2049
- ]).nullable().optional(),
2050
- "line-height": textStyleValues["line-height"].nullable().optional(),
2051
- "text-align": textStyleValues["text-align"].nullable().optional(),
2052
- "text-indent": z.union([boundedCanvasNumberSchema, signedPixelLengthSchema]).nullable().optional(),
2053
- "white-space": textStyleValues["white-space"].nullable().optional(),
2054
- "word-spacing": z.union([
2055
- boundedCanvasNumberSchema,
2056
- signedPixelLengthSchema,
2057
- z.literal("normal")
2058
- ]).nullable().optional()
2059
- });
2060
- const overflowStyleValue = canvasAdditionalStyleSchema.shape.value;
2061
- const dimensionalStyleValue = z.union([z.string(), boundedCanvasNumberSchema]);
2062
- const layoutStylePatchValue = z.union([canvasAdditionalStyleSchema.shape.value, boundedCanvasNumberSchema]).nullable().optional();
2063
- const canvasNodeStylePatchSchema = canvasTextStylePatchSchema.extend({
2064
- "align-content": layoutStylePatchValue,
2065
- "align-items": layoutStylePatchValue,
2066
- "align-self": layoutStylePatchValue,
2067
- "aspect-ratio": layoutStylePatchValue,
2068
- "block-size": layoutStylePatchValue,
2069
- bottom: layoutStylePatchValue,
2070
- "box-sizing": layoutStylePatchValue,
2071
- display: layoutStylePatchValue,
2072
- flex: layoutStylePatchValue,
2073
- "flex-basis": layoutStylePatchValue,
2074
- "flex-direction": layoutStylePatchValue,
2075
- "flex-grow": layoutStylePatchValue,
2076
- "flex-shrink": layoutStylePatchValue,
2077
- "flex-wrap": layoutStylePatchValue,
2078
- height: layoutStylePatchValue,
2079
- "inline-size": layoutStylePatchValue,
2080
- inset: layoutStylePatchValue,
2081
- "inset-block": layoutStylePatchValue,
2082
- "inset-block-end": layoutStylePatchValue,
2083
- "inset-block-start": layoutStylePatchValue,
2084
- "inset-inline": layoutStylePatchValue,
2085
- "inset-inline-end": layoutStylePatchValue,
2086
- "inset-inline-start": layoutStylePatchValue,
2087
- "justify-content": layoutStylePatchValue,
2088
- left: layoutStylePatchValue,
2089
- margin: layoutStylePatchValue,
2090
- "margin-block": layoutStylePatchValue,
2091
- "margin-block-end": layoutStylePatchValue,
2092
- "margin-block-start": layoutStylePatchValue,
2093
- "margin-inline": layoutStylePatchValue,
2094
- "margin-inline-end": layoutStylePatchValue,
2095
- "margin-inline-start": layoutStylePatchValue,
2096
- "max-block-size": layoutStylePatchValue,
2097
- "max-height": layoutStylePatchValue,
2098
- "max-inline-size": layoutStylePatchValue,
2099
- "max-width": layoutStylePatchValue,
2100
- "min-block-size": layoutStylePatchValue,
2101
- "min-height": layoutStylePatchValue,
2102
- "min-inline-size": layoutStylePatchValue,
2103
- "min-width": layoutStylePatchValue,
2104
- order: layoutStylePatchValue,
2105
- padding: layoutStylePatchValue,
2106
- "padding-block": layoutStylePatchValue,
2107
- "padding-block-end": layoutStylePatchValue,
2108
- "padding-block-start": layoutStylePatchValue,
2109
- "padding-inline": layoutStylePatchValue,
2110
- "padding-inline-end": layoutStylePatchValue,
2111
- "padding-inline-start": layoutStylePatchValue,
2112
- position: layoutStylePatchValue,
2113
- right: layoutStylePatchValue,
2114
- top: layoutStylePatchValue,
2115
- width: layoutStylePatchValue,
2116
- background: z.string().nullable().optional(),
2117
- "background-color": z.string().nullable().optional(),
2118
- "border-bottom-left-radius": dimensionalStyleValue.optional(),
2119
- "border-bottom-right-radius": dimensionalStyleValue.optional(),
2120
- "border-bottom-width": dimensionalStyleValue.optional(),
2121
- "border-color": z.string().nullable().optional(),
2122
- "border-left-width": dimensionalStyleValue.optional(),
2123
- "border-radius": dimensionalStyleValue.nullable().optional(),
2124
- "border-right-width": dimensionalStyleValue.optional(),
2125
- "border-style": z.enum([
2126
- "none",
2127
- "solid",
2128
- "dashed",
2129
- "dotted"
2130
- ]).nullable().optional(),
2131
- "border-top-left-radius": dimensionalStyleValue.optional(),
2132
- "border-top-right-radius": dimensionalStyleValue.optional(),
2133
- "border-top-width": dimensionalStyleValue.optional(),
2134
- "border-width": dimensionalStyleValue.nullable().optional(),
2135
- "box-shadow": z.string().nullable().optional(),
2136
- "column-gap": dimensionalStyleValue.optional(),
2137
- gap: dimensionalStyleValue.optional(),
2138
- "margin-bottom": dimensionalStyleValue.optional(),
2139
- "margin-left": dimensionalStyleValue.optional(),
2140
- "margin-right": dimensionalStyleValue.optional(),
2141
- "margin-top": dimensionalStyleValue.optional(),
2142
- opacity: z.union([z.string(), z.number()]).nullable().optional(),
2143
- "outline-offset": dimensionalStyleValue.optional(),
2144
- "outline-width": dimensionalStyleValue.optional(),
2145
- overflow: overflowStyleValue.nullable().optional(),
2146
- "overflow-x": overflowStyleValue.nullable().optional(),
2147
- "overflow-y": overflowStyleValue.nullable().optional(),
2148
- "padding-bottom": dimensionalStyleValue.optional(),
2149
- "padding-left": dimensionalStyleValue.optional(),
2150
- "padding-right": dimensionalStyleValue.optional(),
2151
- "padding-top": dimensionalStyleValue.optional(),
2152
- "row-gap": dimensionalStyleValue.optional(),
2153
- "stroke-width": dimensionalStyleValue.optional()
2154
- });
2155
-
2156
- //#endregion
2157
- //#region ../../packages/contract/src/canvas/canvas-operation.schema.ts
2158
- const convertedSubtreeRelationshipSchema = z.object({
2159
- parentId: z.string().min(1).max(200),
2160
- sortKey: z.string().min(1).max(500)
2161
- });
2162
- const insertConvertedSubtreeOperationSchema = z.object({
2163
- op: z.literal("insertConvertedSubtree"),
2164
- destination: canvasConversionDestinationSchema,
2165
- sourceNodeId: z.string().min(1).max(200).optional(),
2166
- rootNodeId: z.string().min(1).max(200),
2167
- nodes: z.record(z.string().min(1).max(200), canvasSceneNodeSchema).refine((nodes) => Object.keys(nodes).length <= MAX_CANVAS_CONVERSION_NODES),
2168
- relationships: z.record(z.string().min(1).max(200), convertedSubtreeRelationshipSchema).refine((relationships) => Object.keys(relationships).length < MAX_CANVAS_CONVERSION_NODES)
2169
- });
2170
- const MAX_NODE_ID_LENGTH$4 = 200;
2171
- const MAX_LABEL_LENGTH$1 = 500;
2172
- const MAX_TEXT_LENGTH$1 = 1e5;
2173
- const MAX_CANVAS_OPERATIONS = 1e3;
2174
- const nodeIdSchema$1 = z.string().min(1).max(MAX_NODE_ID_LENGTH$4);
2175
- const sortKeySchema = z.string().min(1).max(MAX_LABEL_LENGTH$1);
2176
- const writableBoxSchema = canvasSceneBoxSchema.extend({
2177
- width: z.number().positive(),
2178
- height: z.number().positive()
2179
- });
2180
- const placementSchema = z.object({
2181
- parentId: nodeIdSchema$1,
2182
- afterId: nodeIdSchema$1.optional()
2183
- });
2184
- const parentageSchema = z.object({
2185
- parentId: nodeIdSchema$1,
2186
- sortKey: sortKeySchema
2187
- });
2188
- const canvasSetStylesOperationSchema = z.object({
2189
- op: z.literal("setStyles"),
2190
- nodeId: nodeIdSchema$1,
2191
- styles: canvasNodeStylePatchSchema,
2192
- clear: z.array(canvasNodeStylePatchSchema.keyof()).min(1).max(Object.keys(canvasNodeStylePatchSchema.shape).length).refine((properties) => new Set(properties).size === properties.length).optional()
2193
- }).refine((operation) => (operation.clear ?? []).every((property) => !Object.hasOwn(operation.styles, property)));
2194
- const canvasOperationSchema = z.discriminatedUnion("op", [
2195
- insertConvertedSubtreeOperationSchema,
2196
- z.object({
2197
- op: z.literal("insertNode"),
2198
- node: canvasSceneNodeSchema,
2199
- parentage: parentageSchema
2200
- }),
2201
- placementSchema.extend({
2202
- op: z.literal("insertText"),
2203
- nodeId: nodeIdSchema$1,
2204
- label: z.string().max(MAX_LABEL_LENGTH$1).default("Text"),
2205
- text: z.string().max(MAX_TEXT_LENGTH$1),
2206
- box: writableBoxSchema,
2207
- styles: canvasTextStylesSchema.default({})
2208
- }),
2209
- placementSchema.extend({
2210
- op: z.literal("insertPrototype"),
2211
- nodeId: nodeIdSchema$1,
2212
- label: z.string().max(MAX_LABEL_LENGTH$1).default("Prototype"),
2213
- prototypeId: z.uuid(),
2214
- deploymentId: z.uuid(),
2215
- box: writableBoxSchema,
2216
- canvasPageId: nodeIdSchema$1.optional()
2217
- }),
2218
- z.object({
2219
- op: z.literal("setPrototypeDeployment"),
2220
- nodeId: nodeIdSchema$1,
2221
- prototypeId: z.uuid(),
2222
- deploymentId: z.uuid()
2223
- }),
2224
- z.object({
2225
- op: z.literal("setText"),
2226
- nodeId: nodeIdSchema$1,
2227
- text: z.string().max(MAX_TEXT_LENGTH$1)
2228
- }),
2229
- z.object({
2230
- op: z.literal("setBox"),
2231
- nodeId: nodeIdSchema$1,
2232
- box: z.union([canvasSceneBoxSchema, z.literal("default")])
2233
- }),
2234
- z.object({
2235
- op: z.literal("setLabel"),
2236
- nodeId: nodeIdSchema$1,
2237
- label: z.string().trim().min(1).max(MAX_LABEL_LENGTH$1),
2238
- labelOrigin: canvasNodeLabelOriginSchema.nullable().optional()
2239
- }),
2240
- z.object({
2241
- op: z.literal("setContainerKind"),
2242
- nodeId: nodeIdSchema$1,
2243
- component: z.enum(["frame", "group"])
2244
- }),
2245
- z.object({
2246
- op: z.literal("setVisibility"),
2247
- nodeId: nodeIdSchema$1,
2248
- visible: z.boolean().nullable()
2249
- }),
2250
- z.object({
2251
- op: z.literal("setLocked"),
2252
- nodeId: nodeIdSchema$1,
2253
- locked: z.boolean().nullable()
2254
- }),
2255
- z.object({
2256
- op: z.literal("setConstraints"),
2257
- nodeId: nodeIdSchema$1,
2258
- constraints: canvasNodeConstraintsSchema
2259
- }),
2260
- canvasSetStylesOperationSchema,
2261
- z.object({
2262
- op: z.literal("setAppearance"),
2263
- nodeId: nodeIdSchema$1,
2264
- appearance: canvasAppearancePatchSchema
2265
- }),
2266
- z.object({
2267
- op: z.literal("setLayout"),
2268
- nodeId: nodeIdSchema$1,
2269
- layout: z.union([canvasNodeLayoutSchema, z.literal("default")])
2270
- }),
2271
- z.object({
2272
- op: z.literal("setTypography"),
2273
- nodeId: nodeIdSchema$1,
2274
- typography: z.union([canvasTypographySchema, z.literal("default")])
2275
- }),
2276
- z.object({
2277
- op: z.literal("setAdditionalStyles"),
2278
- nodeId: nodeIdSchema$1,
2279
- additionalStyles: z.union([canvasAdditionalStylesSchema, z.literal("default")])
2280
- }),
2281
- z.object({
2282
- op: z.literal("setProps"),
2283
- nodeId: nodeIdSchema$1,
2284
- props: z.union([z.record(z.string(), z.unknown()), z.literal("default")])
2285
- }),
2286
- z.object({
2287
- op: z.literal("setParentage"),
2288
- nodeId: nodeIdSchema$1,
2289
- parentage: parentageSchema
2290
- }),
2291
- placementSchema.extend({
2292
- op: z.literal("move"),
2293
- nodeId: nodeIdSchema$1
2294
- }),
2295
- z.object({
2296
- op: z.literal("remove"),
2297
- nodeId: nodeIdSchema$1
2298
- })
2299
- ]);
2300
- const applyCanvasOperationsInputSchema = z.object({
2301
- canvasId: z.uuid(),
2302
- mutationId: z.uuid(),
2303
- documentFormatVersion: canvasDocumentFormatSchema,
2304
- baseVersion: z.number().int().positive(),
2305
- operations: z.array(canvasOperationSchema).min(1).max(MAX_CANVAS_OPERATIONS)
2306
- });
2307
- const applyCanvasOperationsOutputSchema = z.object({
2308
- canvasId: z.uuid(),
2309
- mutationId: z.uuid(),
2310
- previousVersion: z.number().int().positive(),
2311
- version: z.number().int().positive(),
2312
- insertedNodeIds: z.array(nodeIdSchema$1),
2313
- changedNodeIds: z.array(nodeIdSchema$1),
2314
- removedNodeIds: z.array(nodeIdSchema$1),
2315
- boxes: z.record(nodeIdSchema$1, canvasSceneBoxSchema),
2316
- affectedBounds: writableBoxSchema.nullable(),
2317
- next: z.array(z.string().min(1))
2318
- });
2319
- const createEditableFrameOutputSchema = createEditableFrameResultSchema.extend({
2320
- operation: insertConvertedSubtreeOperationSchema,
2321
- next: z.array(z.string().min(1))
2322
- });
3031
+ preservesAspect: true,
3032
+ canLockAspectRatio: true
3033
+ },
3034
+ propertySections: SVG_PROPERTY_SECTIONS
3035
+ },
3036
+ {
3037
+ objectKind: RECORDING_KIND,
3038
+ label: "Recording",
3039
+ category: "media",
3040
+ capabilities: {
3041
+ canSelect: true,
3042
+ canContainChildren: false,
3043
+ canEditProperties: false
3044
+ },
3045
+ capture: { preservesAssets: true },
3046
+ selectionBehavior: { hitTarget: "frame" },
3047
+ resizeBehavior: {
3048
+ mode: "scale",
3049
+ preservesAspect: true,
3050
+ canLockAspectRatio: true
3051
+ },
3052
+ propertySections: []
3053
+ },
3054
+ {
3055
+ objectKind: TEXT_KIND,
3056
+ label: "Text",
3057
+ category: "primitive",
3058
+ capabilities: {
3059
+ canSelect: true,
3060
+ canContainChildren: false,
3061
+ canEditProperties: true,
3062
+ commentAnchor: "node"
3063
+ },
3064
+ selectionBehavior: { hitTarget: "text" },
3065
+ resizeBehavior: {
3066
+ mode: "reflow",
3067
+ preservesAspect: false,
3068
+ canLockAspectRatio: false
3069
+ },
3070
+ propertySections: [
3071
+ "position",
3072
+ "layout",
3073
+ "typography",
3074
+ "nativeControl",
3075
+ "textDecoration",
3076
+ "textStroke",
3077
+ "blending",
3078
+ "fill",
3079
+ "outerShadow",
3080
+ "filters",
3081
+ "additionalStyles",
3082
+ "export"
3083
+ ]
3084
+ }
3085
+ ].map((descriptor) => [descriptor.objectKind, descriptor]));
3086
+ const canvasObjectKindDescriptor = (objectKind) => DESCRIPTOR_BY_KIND[objectKind] ?? null;
3087
+ const canvasPropertySectionsForKind = (objectKind) => canvasObjectKindDescriptor(objectKind)?.propertySections ?? [];
2323
3088
 
2324
3089
  //#endregion
2325
3090
  //#region ../../packages/contract/src/canvas/canvas-realtime.schema.ts
2326
3091
  const CANVAS_REALTIME_PROTOCOL = "enhance3.canvas.v1";
2327
3092
  const MAX_DISPLAY_NAME_LENGTH = 100;
2328
3093
  const MAX_INITIALS_LENGTH = 8;
2329
- const MAX_NODE_ID_LENGTH$3 = 200;
2330
- const MAX_SELECTION_SIZE = 100;
3094
+ const MAX_NODE_ID_LENGTH$4 = 200;
3095
+ const MAX_CANVAS_PRESENCE_IDS = 100;
3096
+ const MAX_CANVAS_PRESENCE_DETAIL_BYTES = 16384;
3097
+ const MAX_CANVAS_SELECTION_IDS = 3e4;
3098
+ const MAX_CANVAS_SELECTION_CHUNK_IDS = 1e3;
3099
+ const MAX_CANVAS_SELECTION_CHUNK_BYTES = 49152;
2331
3100
  const MAX_ACTIVITY_TARGETS = 100;
2332
3101
  const MAX_REALTIME_TICKET_LENGTH = 4096;
2333
3102
  const MAX_ERROR_MESSAGE_LENGTH = 200;
@@ -2375,10 +3144,15 @@ const visibleWorldBoxSchema = canvasSceneBoxSchema.extend({
2375
3144
  width: z.number().positive(),
2376
3145
  height: z.number().positive()
2377
3146
  });
3147
+ const selectionSummarySchema = z.object({
3148
+ count: z.number().int().positive(),
3149
+ bounds: visibleWorldBoxSchema.nullable()
3150
+ });
2378
3151
  const gesturePreviewSchema = z.object({
2379
3152
  kind: z.enum(["drag", "resize"]),
2380
3153
  baseVersion: z.number().int().positive(),
2381
- boxes: z.record(z.string().min(1).max(MAX_NODE_ID_LENGTH$3), visibleWorldBoxSchema)
3154
+ boxes: z.record(z.string().min(1).max(MAX_NODE_ID_LENGTH$4), visibleWorldBoxSchema).refine((boxes) => Object.keys(boxes).length <= 100 && new TextEncoder().encode(JSON.stringify(boxes)).byteLength <= 16384),
3155
+ summary: selectionSummarySchema.optional()
2382
3156
  });
2383
3157
  const canvasPresencePatchSchema = z.object({
2384
3158
  cursor: cursorSchema.nullable().optional(),
@@ -2388,7 +3162,8 @@ const canvasPresencePatchSchema = z.object({
2388
3162
  "keyboard"
2389
3163
  ]).optional(),
2390
3164
  focused: z.boolean().optional(),
2391
- selectedNodeIds: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$3)).max(MAX_SELECTION_SIZE).optional(),
3165
+ selectedNodeIds: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$4)).max(100).refine((ids) => new TextEncoder().encode(JSON.stringify(ids)).byteLength <= MAX_CANVAS_PRESENCE_DETAIL_BYTES).optional(),
3166
+ selectionSummary: selectionSummarySchema.nullable().optional(),
2392
3167
  visibleWorldBox: visibleWorldBoxSchema.optional(),
2393
3168
  gesture: gesturePreviewSchema.nullable().optional(),
2394
3169
  cursorChat: z.string().max(140).nullable().optional()
@@ -2403,7 +3178,8 @@ const canvasPresenceSchema = z.object({
2403
3178
  "keyboard"
2404
3179
  ]),
2405
3180
  focused: z.boolean(),
2406
- selectedNodeIds: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$3)).max(MAX_SELECTION_SIZE),
3181
+ selectedNodeIds: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$4)).max(100).refine((ids) => new TextEncoder().encode(JSON.stringify(ids)).byteLength <= MAX_CANVAS_PRESENCE_DETAIL_BYTES),
3182
+ selectionSummary: selectionSummarySchema.nullable().optional(),
2407
3183
  visibleWorldBox: visibleWorldBoxSchema.nullable(),
2408
3184
  gesture: gesturePreviewSchema.nullable(),
2409
3185
  cursorChat: z.string().max(140).nullable().default(null),
@@ -2421,7 +3197,7 @@ const canvasAgentActivitySchema = z.object({
2421
3197
  canvasId: z.uuid(),
2422
3198
  actor: agentMutationActorSchema,
2423
3199
  phase: canvasAgentActivityPhaseSchema,
2424
- nodeIds: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$3)).max(MAX_ACTIVITY_TARGETS),
3200
+ nodeIds: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$4)).max(MAX_ACTIVITY_TARGETS),
2425
3201
  bounds: visibleWorldBoxSchema.nullable(),
2426
3202
  expiresAt: z.iso.datetime()
2427
3203
  });
@@ -2438,7 +3214,7 @@ const canvasRealtimeTicketOutputSchema = z.object({
2438
3214
  const beginCanvasActivityInputSchema = z.object({
2439
3215
  canvasId: z.uuid(),
2440
3216
  phase: canvasAgentActivityPhaseSchema,
2441
- nodeIds: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$3)).max(MAX_ACTIVITY_TARGETS).default([]),
3217
+ nodeIds: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$4)).max(MAX_ACTIVITY_TARGETS).default([]),
2442
3218
  bounds: visibleWorldBoxSchema.nullable().default(null)
2443
3219
  });
2444
3220
  const beginCanvasActivityOutputSchema = z.object({
@@ -2452,17 +3228,6 @@ const endCanvasActivityInputSchema = z.object({
2452
3228
  activityId: z.uuid()
2453
3229
  });
2454
3230
  const endCanvasActivityOutputSchema = z.object({ ended: z.literal(true) });
2455
- const canvasRealtimeClientEnvelopeSchema = z.discriminatedUnion("type", [z.object({
2456
- v: z.literal(1),
2457
- type: z.literal("presence.patch"),
2458
- seq: z.number().int().nonnegative(),
2459
- payload: canvasPresencePatchSchema
2460
- }), z.object({
2461
- v: z.literal(1),
2462
- type: z.literal("room.pong"),
2463
- seq: z.number().int().nonnegative(),
2464
- payload: z.object({ pingId: z.uuid() })
2465
- })]);
2466
3231
  const serverEnvelopeBase = {
2467
3232
  v: z.literal(1),
2468
3233
  seq: z.number().int().nonnegative()
@@ -2545,6 +3310,41 @@ const canvasRealtimeServerEnvelopeSchema = z.discriminatedUnion("type", [
2545
3310
  })
2546
3311
  ]);
2547
3312
 
3313
+ //#endregion
3314
+ //#region ../../packages/contract/src/canvas/canvas-realtime-client.schema.ts
3315
+ const MAX_NODE_ID_LENGTH$3 = 200;
3316
+ const canvasRealtimeClientEnvelopeSchema = z.discriminatedUnion("type", [
3317
+ z.object({
3318
+ v: z.literal(1),
3319
+ type: z.literal("presence.patch"),
3320
+ seq: z.number().int().nonnegative(),
3321
+ payload: canvasPresencePatchSchema
3322
+ }),
3323
+ z.object({
3324
+ v: z.literal(1),
3325
+ type: z.literal("selection.chunk"),
3326
+ seq: z.number().int().nonnegative(),
3327
+ payload: z.object({
3328
+ transferId: z.uuid(),
3329
+ offset: z.number().int().nonnegative().max(MAX_CANVAS_SELECTION_IDS - 1),
3330
+ total: z.number().int().positive().max(MAX_CANVAS_SELECTION_IDS),
3331
+ nodeIds: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$3)).min(1).max(MAX_CANVAS_SELECTION_CHUNK_IDS)
3332
+ })
3333
+ }),
3334
+ z.object({
3335
+ v: z.literal(1),
3336
+ type: z.literal("selection.unavailable"),
3337
+ seq: z.number().int().nonnegative(),
3338
+ payload: z.object({ count: z.number().int().min(MAX_CANVAS_SELECTION_IDS + 1) })
3339
+ }),
3340
+ z.object({
3341
+ v: z.literal(1),
3342
+ type: z.literal("room.pong"),
3343
+ seq: z.number().int().nonnegative(),
3344
+ payload: z.object({ pingId: z.uuid() })
3345
+ })
3346
+ ]).refine((envelope) => envelope.type !== "selection.chunk" || new TextEncoder().encode(JSON.stringify(envelope)).byteLength <= 49152);
3347
+
2548
3348
  //#endregion
2549
3349
  //#region ../../packages/contract/src/canvas/canvas-render-exposure.schema.ts
2550
3350
  const MAX_NODE_ID_LENGTH$2 = 200;
@@ -2744,7 +3544,9 @@ const readCanvasSelectionOutputSchema = z.object({
2744
3544
  "selected",
2745
3545
  "none",
2746
3546
  "offline",
2747
- "stale"
3547
+ "stale",
3548
+ "updating",
3549
+ "unsupported"
2748
3550
  ]),
2749
3551
  documentVersion: z.number().int().positive(),
2750
3552
  selectionRevision: z.number().int().positive().nullable(),
@@ -2757,6 +3559,81 @@ const readCanvasSelectionOutputSchema = z.object({
2757
3559
  next: z.array(z.string().min(1)).max(MAX_SELECTION_COMMANDS)
2758
3560
  });
2759
3561
 
3562
+ //#endregion
3563
+ //#region ../../packages/contract/src/canvas/canvas-text-run-format.lib.ts
3564
+ const LINK_STYLES = {
3565
+ color: "inherit",
3566
+ textDecorationLine: "underline",
3567
+ textDecorationThickness: "0.08em",
3568
+ textUnderlineOffset: "0.14em"
3569
+ };
3570
+ const STYLE_PROPERTIES = new Set(CANVAS_TEXT_STYLE_PROPERTIES);
3571
+ const STYLE_CSS = new Set(Object.entries(CANVAS_TYPOGRAPHY_CSS_OWNERS).flatMap(([css, owners]) => owners.some((owner) => STYLE_PROPERTIES.has(owner)) ? [css.replaceAll(/-([a-z])/gu, (_, letter) => letter.toUpperCase())] : []));
3572
+
3573
+ //#endregion
3574
+ //#region ../../packages/contract/src/canvas/canvas-text-commands.lib.ts
3575
+ /** Legacy link annotations join the same run tree when their contents are first edited. */
3576
+ const canvasTextRunsOf = (node) => {
3577
+ const rich = canvasRichTextOf(node);
3578
+ if (rich.length > 0) return rich;
3579
+ const text = textOf(node) ?? "";
3580
+ const runs = [];
3581
+ let position = 0;
3582
+ for (const link of textLinksOf(node)) {
3583
+ if (position < link.start) runs.push({
3584
+ kind: "text",
3585
+ text: text.slice(position, link.start)
3586
+ });
3587
+ runs.push({
3588
+ kind: "span",
3589
+ href: link.href,
3590
+ styles: LINK_STYLES,
3591
+ children: [{
3592
+ kind: "text",
3593
+ text: text.slice(link.start, link.end)
3594
+ }]
3595
+ });
3596
+ position = link.end;
3597
+ }
3598
+ if (position < text.length) runs.push({
3599
+ kind: "text",
3600
+ text: text.slice(position)
3601
+ });
3602
+ return runs;
3603
+ };
3604
+
3605
+ //#endregion
3606
+ //#region ../../packages/contract/src/canvas/canvas-text-style-consumers.lib.ts
3607
+ const ownedProperties = new Set(CANVAS_TEXT_STYLE_PROPERTIES);
3608
+ const ownedCss = new Set(Object.entries(CANVAS_TYPOGRAPHY_CSS_OWNERS).flatMap(([css, owners]) => owners.some((property) => ownedProperties.has(property)) ? [css] : []));
3609
+
3610
+ //#endregion
3611
+ //#region ../../packages/contract/src/canvas/canvas-typography-ownership.lib.ts
3612
+ const FONT_SETTINGS = [["features", "featureChanges"], ["variations", "variationChanges"]];
3613
+ const applyCanvasTypographyPatch = (before, patch) => {
3614
+ const next = { ...before };
3615
+ for (const property of CANVAS_TYPOGRAPHY_PROPERTIES) {
3616
+ const value = patch[property];
3617
+ if (value !== void 0) Reflect.set(next, property, value);
3618
+ }
3619
+ for (const [property, key] of FONT_SETTINGS) {
3620
+ const change = patch[key];
3621
+ if (change === void 0) continue;
3622
+ const settings = {
3623
+ ...before?.[property],
3624
+ ...change.set
3625
+ };
3626
+ const cleared = change.clear ?? [];
3627
+ for (const tag of cleared) Reflect.deleteProperty(settings, tag);
3628
+ if (change.removeIfEmpty === true && Object.keys(settings).length === 0) Reflect.deleteProperty(next, property);
3629
+ else next[property] = settings;
3630
+ }
3631
+ const cleared = patch.clear ?? [];
3632
+ for (const property of cleared) Reflect.deleteProperty(next, property);
3633
+ return Object.keys(next).length === 0 ? null : next;
3634
+ };
3635
+ const canvasCssTypographyOwners = (changed) => [...new Set(Object.entries(CANVAS_TYPOGRAPHY_CSS_OWNERS).flatMap(([css, properties]) => changed.has(css) ? properties : []))];
3636
+
2760
3637
  //#endregion
2761
3638
  //#region ../../packages/contract/src/canvas/canvas-version.schema.ts
2762
3639
  const CANVAS_VERSION_DESCRIPTION_MAX_LENGTH = 1e3;
@@ -2890,6 +3767,82 @@ const duplicateCanvasVersionOutputSchema = z.object({
2890
3767
  version: z.literal(1)
2891
3768
  });
2892
3769
 
3770
+ //#endregion
3771
+ //#region ../../packages/contract/src/canvas/font-catalog.schema.ts
3772
+ const MAX_FONT_NAME_LENGTH = 200;
3773
+ const MAX_WEIGHT = 1e3;
3774
+ const MAX_STRETCH_PERCENT = 1e3;
3775
+ const isNumericRange = (value, maximum) => {
3776
+ const values = value.split(" ").map((part) => Number(part.replace("%", "")));
3777
+ return values.every((part) => part > 0 && part <= maximum) && (values.length === 1 || (values[0] ?? 0) <= (values[1] ?? 0));
3778
+ };
3779
+ const digestSchema = z.string().regex(/^[a-f0-9]{64}$/u);
3780
+ const fontNameSchema = z.string().trim().min(1).max(MAX_FONT_NAME_LENGTH);
3781
+ const fontCatalogScopeSchema = z.object({ organisationId: z.uuid().nullable() });
3782
+ const fontCatalogMetadataSchema = z.object({
3783
+ family: z.string().regex(/^uploaded-font-[a-f0-9]{64}(?:-[a-f0-9]{12})?$/u),
3784
+ familyName: fontNameSchema,
3785
+ subfamilyName: fontNameSchema,
3786
+ version: fontNameSchema,
3787
+ weight: z.string().regex(/^\d+(?:\.\d+)?(?: \d+(?:\.\d+)?)?$/u).refine((value) => isNumericRange(value, MAX_WEIGHT)),
3788
+ style: z.enum([
3789
+ "normal",
3790
+ "italic",
3791
+ "oblique"
3792
+ ]),
3793
+ stretch: z.union([z.enum([
3794
+ "normal",
3795
+ "ultra-condensed",
3796
+ "extra-condensed",
3797
+ "condensed",
3798
+ "semi-condensed",
3799
+ "semi-expanded",
3800
+ "expanded",
3801
+ "extra-expanded",
3802
+ "ultra-expanded"
3803
+ ]), z.string().regex(/^\d+(?:\.\d+)?%(?: \d+(?:\.\d+)?%)?$/u).refine((value) => isNumericRange(value, MAX_STRETCH_PERCENT))]),
3804
+ format: z.enum([
3805
+ "truetype",
3806
+ "opentype",
3807
+ "woff",
3808
+ "woff2"
3809
+ ])
3810
+ });
3811
+ const fontCatalogIdentitySchema = z.object({
3812
+ kind: z.enum(["personal", "team"]),
3813
+ ownerId: z.uuid(),
3814
+ sha256: digestSchema
3815
+ });
3816
+ const reserveFontCatalogInputSchema = fontCatalogScopeSchema.extend({
3817
+ sha256: digestSchema,
3818
+ bytes: z.number().int().positive().max(MAX_CANVAS_FONT_BYTES),
3819
+ contentType: z.enum(CANVAS_FONT_CONTENT_TYPES)
3820
+ });
3821
+ const reserveFontCatalogOutputSchema = z.object({ upload: signedUploadSchema });
3822
+ const completeFontCatalogInputSchema = reserveFontCatalogInputSchema.extend({
3823
+ metadata: fontCatalogMetadataSchema,
3824
+ hasSharingRights: z.literal(true)
3825
+ });
3826
+ const fontCatalogEntrySchema = fontCatalogIdentitySchema.extend({
3827
+ bytes: z.number().int().positive().max(MAX_CANVAS_FONT_BYTES),
3828
+ metadata: fontCatalogMetadataSchema,
3829
+ createdAt: z.iso.datetime(),
3830
+ path: z.string().startsWith("/v1/font-catalog/")
3831
+ });
3832
+ const listFontCatalogOutputSchema = z.object({
3833
+ entries: z.array(fontCatalogEntrySchema),
3834
+ canManage: z.boolean()
3835
+ });
3836
+ const removeFontCatalogInputSchema = fontCatalogScopeSchema.extend({ sha256: digestSchema });
3837
+ const importFontCatalogInputSchema = fontCatalogScopeSchema.extend({
3838
+ canvasId: z.uuid(),
3839
+ sha256: z.array(digestSchema).min(1).max(100)
3840
+ });
3841
+ const importFontCatalogOutputSchema = z.object({ resources: z.array(z.object({
3842
+ entry: fontCatalogEntrySchema,
3843
+ path: z.string().startsWith("/v1/canvas-assets/")
3844
+ })) });
3845
+
2893
3846
  //#endregion
2894
3847
  //#region ../../packages/contract/src/canvas/invite.schema.ts
2895
3848
  const inviteSchema = z.object({
@@ -3226,7 +4179,7 @@ const ROOT_FIXTURE_NODE_ID = "root";
3226
4179
  const SORT_KEY_DIGITS = 4;
3227
4180
  const sortKeyAt = (seat) => `a${String(seat).padStart(SORT_KEY_DIGITS, "0")}`;
3228
4181
  const emptyFixtureDocument = () => ({
3229
- version: 3,
4182
+ version: 5,
3230
4183
  nodes: { [ROOT_FIXTURE_NODE_ID]: {
3231
4184
  id: ROOT_FIXTURE_NODE_ID,
3232
4185
  label: "Canvas",
@@ -3775,7 +4728,25 @@ const PROTOTYPE_VIEWPORT_SELECTOR = `[${PROTOTYPE_VIEWPORT_ATTRIBUTE}]`;
3775
4728
  const prototypeBridgeCaptureRequestSchema = z.object({
3776
4729
  protocol: z.literal(1),
3777
4730
  type: z.literal("enhance.prototype.capture"),
3778
- requestId: z.uuid()
4731
+ requestId: z.uuid(),
4732
+ connectionId: z.uuid().optional(),
4733
+ documentId: z.uuid().optional()
4734
+ });
4735
+ const prototypeBridgeConnectRequestSchema = z.object({
4736
+ protocol: z.literal(1),
4737
+ type: z.literal("enhance.prototype.connect"),
4738
+ connectionId: z.uuid()
4739
+ });
4740
+ const prototypeBridgeConnectedSchema = prototypeBridgeConnectRequestSchema.extend({
4741
+ type: z.literal("enhance.prototype.connected"),
4742
+ documentId: z.uuid(),
4743
+ capabilities: z.array(z.string()),
4744
+ release: z.string().min(1)
4745
+ });
4746
+ const prototypeBridgeUnloadingSchema = z.object({
4747
+ protocol: z.literal(1),
4748
+ type: z.literal("enhance.prototype.unloading"),
4749
+ documentId: z.uuid()
3779
4750
  });
3780
4751
  const prototypeBridgeReadySchema = z.object({
3781
4752
  protocol: z.literal(1),
@@ -3820,14 +4791,17 @@ const capturedPrototypeScreenSchema = z.object({
3820
4791
  const prototypeBridgeCaptureResponseBaseSchema = z.object({
3821
4792
  protocol: z.literal(1),
3822
4793
  type: z.literal("enhance.prototype.captured"),
3823
- requestId: z.uuid()
4794
+ requestId: z.uuid(),
4795
+ connectionId: z.uuid().optional(),
4796
+ documentId: z.uuid().optional()
3824
4797
  });
3825
4798
  const prototypeBridgeCaptureResponseSchema = z.discriminatedUnion("outcome", [prototypeBridgeCaptureResponseBaseSchema.extend({
3826
4799
  outcome: z.literal("captured"),
3827
4800
  screen: capturedPrototypeScreenSchema
3828
4801
  }), prototypeBridgeCaptureResponseBaseSchema.extend({
3829
4802
  outcome: z.literal("failed"),
3830
- error: z.string().min(1)
4803
+ error: z.string().min(1),
4804
+ code: z.enum(["capture-failed", "capture-busy"]).optional()
3831
4805
  })]);
3832
4806
 
3833
4807
  //#endregion
@@ -4252,6 +5226,32 @@ const appError$1 = (code, message, fields) => fields === void 0 ? {
4252
5226
  fields
4253
5227
  };
4254
5228
 
5229
+ //#endregion
5230
+ //#region ../../packages/contract/src/shared/client-conversion.schema.ts
5231
+ const MAX_CLIENT_CONVERSION_DURATION_MS = 18e5;
5232
+ const MAX_SOURCE_NODE_ID_LENGTH = 200;
5233
+ const clientConversionInputSchema = z.object({
5234
+ canvasId: z.uuid(),
5235
+ attemptId: z.uuid(),
5236
+ sourceNodeId: z.string().min(1).max(MAX_SOURCE_NODE_ID_LENGTH),
5237
+ releaseIdentity: z.string().min(1).max(100),
5238
+ outcome: z.enum([
5239
+ "started",
5240
+ "succeeded",
5241
+ "blocked",
5242
+ "failed"
5243
+ ]),
5244
+ reason: z.enum([
5245
+ "none",
5246
+ "pending-changes",
5247
+ "source-unsettled",
5248
+ "captured-fonts-unavailable",
5249
+ "conversion-failed"
5250
+ ]),
5251
+ durationMs: z.number().int().min(0).max(MAX_CLIENT_CONVERSION_DURATION_MS)
5252
+ });
5253
+ const clientConversionOutputSchema = z.object({ accepted: z.literal(true) });
5254
+
4255
5255
  //#endregion
4256
5256
  //#region ../../packages/contract/src/shared/client-performance.schema.ts
4257
5257
  const MAX_CAPABILITY_VERSION$1 = 16;
@@ -4357,6 +5357,23 @@ const clientPerformanceInputSchema = z.discriminatedUnion("name", [
4357
5357
  ]);
4358
5358
  const clientPerformanceOutputSchema = z.object({ accepted: z.literal(true) });
4359
5359
 
5360
+ //#endregion
5361
+ //#region ../../packages/contract/src/shared/client-render-failure.schema.ts
5362
+ const incidentFields = {
5363
+ incidentId: z.uuid(),
5364
+ releaseIdentity: z.string().min(1).max(100),
5365
+ reason: z.enum(["render-loop", "render-error"])
5366
+ };
5367
+ const clientRenderFailureInputSchema = z.discriminatedUnion("surface", [z.object({
5368
+ ...incidentFields,
5369
+ surface: z.literal("canvas"),
5370
+ canvasId: z.uuid()
5371
+ }), z.object({
5372
+ ...incidentFields,
5373
+ surface: z.literal("application")
5374
+ })]);
5375
+ const clientRenderFailureOutputSchema = z.object({ accepted: z.literal(true) });
5376
+
4360
5377
  //#endregion
4361
5378
  //#region ../../packages/contract/src/shared/extension-bridge.schema.ts
4362
5379
  const EXTENSION_BRIDGE_PROBE = "enhance3:extension-probe";
@@ -4730,6 +5747,7 @@ const operationScope = (operation, document) => {
4730
5747
  }
4731
5748
  case "setPrototypeDeployment":
4732
5749
  case "setText":
5750
+ case "editText":
4733
5751
  case "setBox":
4734
5752
  case "setLabel":
4735
5753
  case "setContainerKind":
@@ -4739,7 +5757,12 @@ const operationScope = (operation, document) => {
4739
5757
  case "setStyles":
4740
5758
  case "setAppearance":
4741
5759
  case "setLayout":
5760
+ case "patchTypography":
4742
5761
  case "setTypography":
5762
+ case "patchFontLibrary":
5763
+ case "setTextStyleLibrary":
5764
+ case "setTextStyle":
5765
+ case "patchAdditionalStyles":
4743
5766
  case "setAdditionalStyles":
4744
5767
  case "setProps":
4745
5768
  case "remove": return {
@@ -4917,6 +5940,11 @@ const CANVAS_CAPABILITY_SPECS = [
4917
5940
  mutationId: CAPABILITY_UUID_EXAMPLE,
4918
5941
  previousVersion: 1,
4919
5942
  version: 2,
5943
+ operations: [{
5944
+ op: "setText",
5945
+ nodeId: "text_title",
5946
+ text: "Today"
5947
+ }],
4920
5948
  insertedNodeIds: [],
4921
5949
  changedNodeIds: ["text_title"],
4922
5950
  removedNodeIds: [],
@@ -4954,6 +5982,11 @@ const CANVAS_CAPABILITY_SPECS = [
4954
5982
  mutationId: CAPABILITY_UUID_EXAMPLE,
4955
5983
  previousVersion: 1,
4956
5984
  version: 2,
5985
+ operations: [{
5986
+ op: "setText",
5987
+ nodeId: "text_title",
5988
+ text: "Ready"
5989
+ }],
4957
5990
  insertedNodeIds: [],
4958
5991
  changedNodeIds: ["text_title"],
4959
5992
  removedNodeIds: [],
@@ -5252,6 +6285,9 @@ const PROCEDURE_DESCRIPTIONS = {
5252
6285
  "screen.complete": "Confirm a captured page after its bytes have been uploaded.",
5253
6286
  "screen.delete": "Delete an unattached captured page owned by this person."
5254
6287
  };
6288
+
6289
+ //#endregion
6290
+ //#region src/infrastructure/procedure-options.consts.ts
5255
6291
  const OPTION_DESCRIPTIONS = {
5256
6292
  ...CANVAS_VERSION_OPTION_DESCRIPTIONS,
5257
6293
  "--canvas-id": "Canvas id, from `enhance canvas list`.",
@@ -5335,7 +6371,14 @@ const OPTION_DESCRIPTIONS = {
5335
6371
  "canvas.move --organisation-id": "Destination team UUID from `enhance organisation list`, or the literal `personal`.",
5336
6372
  "canvas.duplicate --organisation-id": "Destination team UUID from `enhance organisation list`, or the literal `personal`.",
5337
6373
  "canvas.deletePermanently --confirmation": "Exact canvas title returned by `enhance canvas list --deleted true`.",
6374
+ "canvas.textStyleLibrary.list --search": "Match published library titles in your teams and files shared with you.",
6375
+ "canvas.textStyleLibrary.publish --expected-revision": "Current published library revision; use 0 for its first publication.",
6376
+ "canvas.textStyleLibrary.publish --document-version": "Saved source document version containing the selected style definitions.",
6377
+ "canvas.textStyleLibrary.publish --publish": "Local text style ids to add or update in this publication, as a JSON array.",
6378
+ "canvas.textStyleLibrary.publish --remove": "Published text style ids to remove from the library, as a JSON array.",
6379
+ "canvas.textStyleLibrary.publish --description": "Release notes describing these library changes for consuming files.",
5338
6380
  "canvas.document.save --base-version": "Current version from `canvas document get`; a stale value exits 5 with CONFLICT.",
6381
+ "canvas.document.get --after-version": "Saved revision to request subsequent retained mutations from, excluding that revision. Verify a contiguous chain before rebasing; missing history or a restore requires the current document.",
5339
6382
  "canvas.document.save --document": "Complete opaque JSON object; preserve fields you did not intend to change.",
5340
6383
  "canvas.document.save --screen-ids": "Complete replacement manifest of screen UUIDs; omit to detach every screen.",
5341
6384
  "canvas.participants.setAccess --person-id": "Participant person id from `enhance canvas participants list`.",
@@ -5510,11 +6553,26 @@ const toCapabilityDefinition = (input) => {
5510
6553
 
5511
6554
  //#endregion
5512
6555
  //#region src/infrastructure/capability-policy.consts.ts
6556
+ const FONT_ASSET_POLICY = {
6557
+ exposure: "internal",
6558
+ reason: "Font upload and transfer lifecycle belongs to document authoring transactions.",
6559
+ owner: "product"
6560
+ };
6561
+ const RENDER_LIFECYCLE_POLICY = {
6562
+ exposure: "internal",
6563
+ reason: "Render creation, polling and cancellation belong to higher-level render capabilities.",
6564
+ owner: "product"
6565
+ };
5513
6566
  const SHARED_CAPABILITY_POLICY = {
5514
6567
  exposure: "shared",
5515
6568
  reason: "Authenticated product operation supported equally by CLI and MCP.",
5516
6569
  owner: "product"
5517
6570
  };
6571
+ const PRODUCT_TELEMETRY_POLICY = {
6572
+ exposure: "internal",
6573
+ reason: "Product telemetry is not an agent capability.",
6574
+ owner: "product"
6575
+ };
5518
6576
  const PROCEDURE_CAPABILITY_POLICIES = {
5519
6577
  "canvas.applyOperations": {
5520
6578
  exposure: "internal",
@@ -5531,16 +6589,16 @@ const PROCEDURE_CAPABILITY_POLICIES = {
5531
6589
  reason: "Signed image upload reservation is wrapped by file-safe authoring.",
5532
6590
  owner: "product"
5533
6591
  },
5534
- "canvas.render.cancel": {
5535
- exposure: "internal",
5536
- reason: "Render lifecycle detail is owned by higher-level render capabilities.",
5537
- owner: "product"
5538
- },
5539
- "canvas.render.create": {
5540
- exposure: "internal",
5541
- reason: "Render lifecycle detail is owned by higher-level render capabilities.",
5542
- owner: "product"
5543
- },
6592
+ "canvas.copyFonts": FONT_ASSET_POLICY,
6593
+ "canvas.reserveFont": FONT_ASSET_POLICY,
6594
+ "canvas.completeFont": FONT_ASSET_POLICY,
6595
+ "canvas.fontCatalog.list": FONT_ASSET_POLICY,
6596
+ "canvas.fontCatalog.reserve": FONT_ASSET_POLICY,
6597
+ "canvas.fontCatalog.complete": FONT_ASSET_POLICY,
6598
+ "canvas.fontCatalog.remove": FONT_ASSET_POLICY,
6599
+ "canvas.fontCatalog.import": FONT_ASSET_POLICY,
6600
+ "canvas.render.cancel": RENDER_LIFECYCLE_POLICY,
6601
+ "canvas.render.create": RENDER_LIFECYCLE_POLICY,
5544
6602
  "canvas.render.download": {
5545
6603
  exposure: "internal",
5546
6604
  reason: "Signed downloads must be written through a protected artifact adapter.",
@@ -5551,11 +6609,7 @@ const PROCEDURE_CAPABILITY_POLICIES = {
5551
6609
  reason: "Signed render exposure is a transport implementation detail.",
5552
6610
  owner: "product"
5553
6611
  },
5554
- "canvas.render.get": {
5555
- exposure: "internal",
5556
- reason: "Render polling is owned by higher-level render capabilities.",
5557
- owner: "product"
5558
- },
6612
+ "canvas.render.get": RENDER_LIFECYCLE_POLICY,
5559
6613
  "canvas.render.snapshot": {
5560
6614
  exposure: "internal",
5561
6615
  reason: "Render snapshot creation is owned by higher-level render capabilities.",
@@ -5651,16 +6705,10 @@ const PROCEDURE_CAPABILITY_POLICIES = {
5651
6705
  reason: "Prototype upload lifecycle is wrapped by prototype publish.",
5652
6706
  owner: "product"
5653
6707
  },
5654
- "telemetry.lifecycle": {
5655
- exposure: "internal",
5656
- reason: "Product telemetry is not an agent capability.",
5657
- owner: "product"
5658
- },
5659
- "telemetry.performance": {
5660
- exposure: "internal",
5661
- reason: "Product telemetry is not an agent capability.",
5662
- owner: "product"
5663
- },
6708
+ "telemetry.conversion": PRODUCT_TELEMETRY_POLICY,
6709
+ "telemetry.renderFailure": PRODUCT_TELEMETRY_POLICY,
6710
+ "telemetry.lifecycle": PRODUCT_TELEMETRY_POLICY,
6711
+ "telemetry.performance": PRODUCT_TELEMETRY_POLICY,
5664
6712
  "transcript.get": {
5665
6713
  exposure: "internal",
5666
6714
  reason: "Transcript storage details are wrapped by transcript get.",
@@ -5786,6 +6834,9 @@ const SHARED_CAPABILITY_PROCEDURES = /* @__PURE__ */ new Set([
5786
6834
  "canvas.selection",
5787
6835
  "canvas.setAccess",
5788
6836
  "canvas.setReviewState",
6837
+ "canvas.textStyleLibrary.get",
6838
+ "canvas.textStyleLibrary.list",
6839
+ "canvas.textStyleLibrary.publish",
5789
6840
  "canvas.tree",
5790
6841
  "canvas.version.get",
5791
6842
  "canvas.version.list",
@@ -6496,6 +7547,7 @@ const applyOperations = (handlers) => canvasCommenterProcedure.input(applyCanvas
6496
7547
  const renderNext = applied.affectedBounds === null ? [] : [`enhance canvas render --canvas ${applied.canvasId} --bounds '${JSON.stringify(applied.affectedBounds)}' --expected-version ${String(applied.version)}`];
6497
7548
  return {
6498
7549
  ...applied,
7550
+ operations: applied.operations.map((operation) => canvasOperationSchema.parse(operation)),
6499
7551
  insertedNodeIds: [...applied.insertedNodeIds],
6500
7552
  changedNodeIds: [...applied.changedNodeIds],
6501
7553
  removedNodeIds: [...applied.removedNodeIds],
@@ -6629,9 +7681,16 @@ const createCanvasRouter = (handlers) => trpcRouter({
6629
7681
  const getDocument = (handlers) => canvasReaderProcedure.input(getCanvasDocumentInputSchema).output(getCanvasDocumentOutputSchema).query(async ({ input, ctx }) => {
6630
7682
  const result = orThrow(await handlers.getDocument.execute({
6631
7683
  canvasId: input.canvasId,
7684
+ afterVersion: input.afterVersion,
6632
7685
  withRoutes: ctx.canvasAccess.canSeeRoutes
6633
7686
  }));
6634
7687
  return {
7688
+ ...result.mutations !== void 0 && { mutations: result.mutations.map((commit) => ({
7689
+ mutationId: commit.mutationId,
7690
+ previousVersion: commit.previousVersion,
7691
+ version: commit.version,
7692
+ operations: commit.operations.map((operation) => canvasOperationSchema.parse(operation))
7693
+ })) },
6635
7694
  version: result.document.version,
6636
7695
  document: result.document.document,
6637
7696
  screens: result.screens.map((screen) => ({
@@ -6684,6 +7743,35 @@ const createCanvasDocumentRouter = (handlers) => trpcRouter({
6684
7743
  save: saveDocument(handlers)
6685
7744
  });
6686
7745
 
7746
+ //#endregion
7747
+ //#region ../api/src/canvas/infrastructure/canvas-font.router.ts
7748
+ const createCanvasFontRouter = (handlers) => trpcRouter({
7749
+ copyFonts: canvasCommenterProcedure.meta({ description: "Copy readable file fonts into this canvas before publishing pasted content." }).input(copyCanvasFontsInputSchema).output(copyCanvasFontsOutputSchema).mutation(async ({ input, ctx }) => {
7750
+ orThrow(await handlers.fonts.copy({
7751
+ ...input,
7752
+ viewer: ctx.viewer
7753
+ }));
7754
+ return { resources: input.sources.map((source) => ({
7755
+ source,
7756
+ path: canvasFontAssetPath(input.canvasId, source.sha256)
7757
+ })) };
7758
+ }),
7759
+ reserveFont: canvasCommenterProcedure.meta({ description: "Reserve a file-scoped font upload pinned to its SHA-256 digest." }).input(reserveCanvasFontInputSchema).output(reserveCanvasFontOutputSchema).mutation(async ({ input }) => {
7760
+ const upload = orThrow(await handlers.fonts.reserve(input));
7761
+ return {
7762
+ path: canvasFontAssetPath(input.canvasId, input.sha256),
7763
+ upload: {
7764
+ ...upload,
7765
+ expiresAt: upload.expiresAt.toISOString()
7766
+ }
7767
+ };
7768
+ }),
7769
+ completeFont: canvasCommenterProcedure.meta({ description: "Verify that the exact font bytes have arrived before using the resource." }).input(completeCanvasFontInputSchema).output(completeCanvasFontOutputSchema).mutation(async ({ input }) => {
7770
+ orThrow(await handlers.fonts.complete(input));
7771
+ return { path: canvasFontAssetPath(input.canvasId, input.sha256) };
7772
+ })
7773
+ });
7774
+
6687
7775
  //#endregion
6688
7776
  //#region ../api/src/canvas/infrastructure/canvas-image.router.ts
6689
7777
  const createCanvasImageRouter = (handlers) => trpcRouter({ reserveImage: canvasCommenterProcedure.meta({ description: "Reserve storage and upload instructions for one canvas image." }).input(reserveCanvasImageInputSchema).output(reserveCanvasImageOutputSchema).mutation(async ({ input }) => {
@@ -7641,7 +8729,8 @@ const nextCommands = (canvasId, version, nodeIds) => [
7641
8729
  ].slice(0, MAX_NEXT_COMMANDS);
7642
8730
  const toCanvasSelection = (canvasId, source, selection) => toCanvasInspection(source.document).map((projected) => {
7643
8731
  const summaries = new Map(projected.nodes.map((node) => [node.id, node]));
7644
- const selectedNodeIds = selection?.selectedNodeIds ?? [];
8732
+ const pendingStatus = selection?.status === "updating" || selection?.status === "unsupported" ? selection.status : null;
8733
+ const selectedNodeIds = pendingStatus === null ? selection?.selectedNodeIds ?? [] : [];
7645
8734
  const nodes = selectedNodeIds.flatMap((nodeId) => {
7646
8735
  const node = summaries.get(nodeId);
7647
8736
  return node === void 0 ? [] : [node];
@@ -7650,7 +8739,7 @@ const toCanvasSelection = (canvasId, source, selection) => toCanvasInspection(so
7650
8739
  const missingNodeIds = selectedNodeIds.filter((nodeId) => !found.has(nodeId));
7651
8740
  return {
7652
8741
  canvasId,
7653
- status: selection === null ? "offline" : selectedNodeIds.length === 0 ? "none" : nodes.length === 0 ? "stale" : "selected",
8742
+ status: pendingStatus ?? (selection === null ? "offline" : selectedNodeIds.length === 0 ? "none" : nodes.length === 0 ? "stale" : "selected"),
7654
8743
  documentVersion: source.version,
7655
8744
  selectionRevision: selection?.selectionRevision ?? null,
7656
8745
  selectionChangedAt: selection?.selectionChangedAt?.toISOString() ?? null,
@@ -7866,6 +8955,56 @@ const createCanvasVersionRouter = (handlers) => trpcRouter({
7866
8955
  duplicate: duplicate(handlers)
7867
8956
  });
7868
8957
 
8958
+ //#endregion
8959
+ //#region ../api/src/canvas/infrastructure/font-catalog.router.ts
8960
+ const entryView = (entry) => ({
8961
+ ...entry,
8962
+ createdAt: entry.createdAt.toISOString(),
8963
+ path: `/v1/font-catalog/${entry.kind}/${entry.ownerId}/${entry.sha256}`
8964
+ });
8965
+ const createFontCatalogRouter = ({ fontCatalog }) => trpcRouter({
8966
+ list: personProcedure.meta({ description: "List fonts uploaded by you or shared with your team." }).input(fontCatalogScopeSchema).output(listFontCatalogOutputSchema).query(async ({ input, ctx }) => {
8967
+ const result = orThrow(await fontCatalog.list({
8968
+ ...input,
8969
+ personId: ctx.viewer.personId
8970
+ }));
8971
+ return {
8972
+ ...result,
8973
+ entries: result.entries.map((entry) => entryView(entry))
8974
+ };
8975
+ }),
8976
+ reserve: personProcedure.meta({ description: "Reserve an immutable personal or team font upload." }).input(reserveFontCatalogInputSchema).output(reserveFontCatalogOutputSchema).mutation(async ({ input, ctx }) => {
8977
+ const upload = orThrow(await fontCatalog.reserve({
8978
+ ...input,
8979
+ personId: ctx.viewer.personId
8980
+ }));
8981
+ return { upload: {
8982
+ ...upload,
8983
+ expiresAt: upload.expiresAt.toISOString()
8984
+ } };
8985
+ }),
8986
+ complete: personProcedure.meta({ description: "Publish a verified font version with acknowledged sharing rights." }).input(completeFontCatalogInputSchema).output(fontCatalogEntrySchema).mutation(async ({ input, ctx }) => entryView(orThrow(await fontCatalog.complete({
8987
+ ...input,
8988
+ personId: ctx.viewer.personId
8989
+ })))),
8990
+ remove: personProcedure.meta({ description: "Remove a library entry while retaining existing file font copies." }).input(removeFontCatalogInputSchema).output(z.object({ removed: z.literal(true) })).mutation(async ({ input, ctx }) => {
8991
+ orThrow(await fontCatalog.remove({
8992
+ ...input,
8993
+ personId: ctx.viewer.personId
8994
+ }));
8995
+ return { removed: true };
8996
+ }),
8997
+ import: personProcedure.meta({ description: "Copy selected library font versions into an editable file." }).input(importFontCatalogInputSchema).output(importFontCatalogOutputSchema).mutation(async ({ input, ctx }) => {
8998
+ return { resources: orThrow(await fontCatalog.import({
8999
+ ...input,
9000
+ personId: ctx.viewer.personId
9001
+ })).map((entry) => ({
9002
+ entry: entryView(entry),
9003
+ path: canvasFontAssetPath(input.canvasId, entry.sha256)
9004
+ })) };
9005
+ })
9006
+ });
9007
+
7869
9008
  //#endregion
7870
9009
  //#region ../api/src/canvas/domain/render-result.value-object.ts
7871
9010
  const isRenderConversionResult = (result) => "rootNodeId" in result;
@@ -8204,6 +9343,39 @@ const createRenderExposureRouter = (handlers) => trpcRouter({ exposure: renderPr
8204
9343
  };
8205
9344
  }) });
8206
9345
 
9346
+ //#endregion
9347
+ //#region ../api/src/canvas/infrastructure/text-style-library.router.ts
9348
+ const view = (publication) => textStyleLibrarySchema.parse({
9349
+ ...publication,
9350
+ publishedAt: publication.publishedAt.toISOString()
9351
+ });
9352
+ const createTextStyleLibraryRouter = ({ textStyleLibrary }) => trpcRouter({
9353
+ list: personProcedure.meta({ description: "Find published text style libraries in your teams and files shared with you." }).input(listTextStyleLibrariesInputSchema).output(listTextStyleLibrariesOutputSchema).query(async ({ input, ctx }) => {
9354
+ const page = orThrow(await textStyleLibrary.list({
9355
+ ...input,
9356
+ personId: ctx.viewer.personId
9357
+ }));
9358
+ return {
9359
+ ...page,
9360
+ items: page.items.map((item) => ({
9361
+ ...item,
9362
+ publishedAt: item.publishedAt.toISOString()
9363
+ }))
9364
+ };
9365
+ }),
9366
+ get: personProcedure.meta({ description: "Read the last published text styles from an accessible source file." }).input(textStyleLibraryIdentitySchema).output(textStyleLibrarySchema.nullable()).query(async ({ input, ctx }) => {
9367
+ const publication = orThrow(await textStyleLibrary.get({
9368
+ ...input,
9369
+ personId: ctx.viewer.personId
9370
+ }));
9371
+ return publication === null ? null : view(publication);
9372
+ }),
9373
+ publish: personProcedure.meta({ description: "Publish selected text style changes without exposing unfinished edits or updating consumer files." }).input(publishTextStyleLibraryInputSchema).output(textStyleLibrarySchema).mutation(async ({ input, ctx }) => view(orThrow(await textStyleLibrary.publish({
9374
+ ...input,
9375
+ personId: ctx.viewer.personId
9376
+ }))))
9377
+ });
9378
+
8207
9379
  //#endregion
8208
9380
  //#region ../api/src/shared/lib/units.consts.ts
8209
9381
  /**
@@ -9260,6 +10432,18 @@ const createScreenRouter = (handlers) => trpcRouter({
9260
10432
  })))
9261
10433
  });
9262
10434
 
10435
+ //#endregion
10436
+ //#region ../api/src/shared/observability/client-conversion-telemetry.router.ts
10437
+ const clientConversionTelemetryRoute = () => baseProcedure.input(clientConversionInputSchema).output(clientConversionOutputSchema).mutation(({ input, ctx }) => {
10438
+ const fields = {
10439
+ ...input,
10440
+ event: "EditableConversionReported"
10441
+ };
10442
+ if (input.outcome === "blocked" || input.outcome === "failed") ctx.logger.warn(fields, "event");
10443
+ else ctx.logger.info(fields, "event");
10444
+ return { accepted: true };
10445
+ });
10446
+
9263
10447
  //#endregion
9264
10448
  //#region ../api/src/shared/observability/client-performance-telemetry.router.ts
9265
10449
  const fieldsOf$1 = (input) => {
@@ -9288,6 +10472,16 @@ const clientPerformanceTelemetryRoute = () => baseProcedure.input(clientPerforma
9288
10472
  return { accepted: true };
9289
10473
  });
9290
10474
 
10475
+ //#endregion
10476
+ //#region ../api/src/shared/observability/client-render-failure.router.ts
10477
+ const clientRenderFailureRoute = () => baseProcedure.input(clientRenderFailureInputSchema).output(clientRenderFailureOutputSchema).mutation(({ input, ctx }) => {
10478
+ ctx.logger.error({
10479
+ ...input,
10480
+ event: "EditorRenderFailed"
10481
+ }, "event");
10482
+ return { accepted: true };
10483
+ });
10484
+
9291
10485
  //#endregion
9292
10486
  //#region ../api/src/shared/observability/extension-telemetry.router.ts
9293
10487
  const isFailure = (input) => {
@@ -9354,6 +10548,9 @@ const createAppRouter = (handlers, options = DEFAULT_ROUTER_OPTIONS) => trpcRout
9354
10548
  canvas: trpcRouter({
9355
10549
  ...createCanvasRouter(handlers.canvas)._def.record,
9356
10550
  ...createCanvasImageRouter(handlers.canvas)._def.record,
10551
+ ...createCanvasFontRouter(handlers.canvas)._def.record,
10552
+ fontCatalog: createFontCatalogRouter(handlers.canvas),
10553
+ textStyleLibrary: createTextStyleLibraryRouter(handlers.canvas),
9357
10554
  ...createCanvasLifecycleRouter(handlers.canvas)._def.record,
9358
10555
  ...createCanvasInspectionRouter(handlers.render, options.webOrigin),
9359
10556
  selection: createCanvasSelectionRoute(handlers.canvas.selection, handlers.render.readCanvas),
@@ -9385,7 +10582,9 @@ const createAppRouter = (handlers, options = DEFAULT_ROUTER_OPTIONS) => trpcRout
9385
10582
  transcript: createTranscriptRouter(handlers.transcript),
9386
10583
  telemetry: trpcRouter({
9387
10584
  ...createExtensionTelemetryRouter()._def.record,
9388
- performance: clientPerformanceTelemetryRoute()
10585
+ performance: clientPerformanceTelemetryRoute(),
10586
+ conversion: clientConversionTelemetryRoute(),
10587
+ renderFailure: clientRenderFailureRoute()
9389
10588
  })
9390
10589
  });
9391
10590
 
@@ -9438,6 +10637,26 @@ const handlers = {
9438
10637
  getDocument: unavailable,
9439
10638
  saveDocument: unavailable,
9440
10639
  reserveImage: unavailable,
10640
+ fonts: {
10641
+ copy: unavailable.execute,
10642
+ importResource: unavailable.execute,
10643
+ reserve: unavailable.execute,
10644
+ complete: unavailable.execute,
10645
+ deliver: unavailable.execute
10646
+ },
10647
+ fontCatalog: {
10648
+ list: unavailable.execute,
10649
+ reserve: unavailable.execute,
10650
+ complete: unavailable.execute,
10651
+ remove: unavailable.execute,
10652
+ import: unavailable.execute,
10653
+ deliver: unavailable.execute
10654
+ },
10655
+ textStyleLibrary: {
10656
+ get: unavailable.execute,
10657
+ list: unavailable.execute,
10658
+ publish: unavailable.execute
10659
+ },
9441
10660
  listParticipants: unavailable,
9442
10661
  setParticipantAccess: unavailable,
9443
10662
  revokeParticipant: unavailable,
@@ -9554,6 +10773,15 @@ const IMPORT_SOURCE_EXAMPLE = {
9554
10773
  targetNodeId: "root"
9555
10774
  }
9556
10775
  };
10776
+ const LIBRARY_PUBLISH_EXAMPLE = {
10777
+ canvasId: CAPABILITY_UUID_EXAMPLE,
10778
+ mutationId: CAPABILITY_UUID_EXAMPLE,
10779
+ expectedRevision: 0,
10780
+ documentVersion: 1,
10781
+ publish: ["body"],
10782
+ remove: [],
10783
+ description: "Publish the Body text style."
10784
+ };
9557
10785
  const recordFrom$1 = (value, label) => {
9558
10786
  const parsed = jsonRecordSchema.safeParse(value);
9559
10787
  if (!parsed.success) throw new TypeError(`${label} is not an object`);
@@ -9608,6 +10836,7 @@ const createCapabilityCatalogAdapter = () => {
9608
10836
  policy: procedurePolicy,
9609
10837
  cliPath: procedurePolicy.exposure === "shared" ? id.replaceAll(".", " ") : null,
9610
10838
  ...id === "canvas.render.importSource" && { inputExample: IMPORT_SOURCE_EXAMPLE },
10839
+ ...id === "canvas.textStyleLibrary.publish" && { inputExample: LIBRARY_PUBLISH_EXAMPLE },
9611
10840
  ...id === "canvas.document.save" && { inputExample: {
9612
10841
  canvasId: "00000000-0000-4000-8000-000000000010",
9613
10842
  baseVersion: 1,
@@ -9990,4 +11219,4 @@ const withCommandInFailure = (value, commandName) => ({
9990
11219
  });
9991
11220
 
9992
11221
  //#endregion
9993
- export { createOrganisationOutputSchema as $, parseCanvasReference as A, canvasSchema as At, PROTOTYPE_ARTIFACT_MANIFEST_PATH as B, transcriptReadCapabilityInputSchema as C, canvasAdditionalStyleSchema as Ct, assertCanvasReferenceOperations as D, canvasAxisStyleProperties as Dt, assertCanvasReferenceNodes as E, canvasAuthoredStyleDeclarations as Et, completeScreenOutputSchema as F, getPrototypePublishStatusOutputSchema as G, createPrototypeArtifactOutputSchema as H, createScreenOutputSchema as I, submitPrototypeArtifactOutputSchema as J, prototypeArtifactManifestSchema as K, appendRecordingChunkOutputSchema as L, CliError as M, transcriptOutputSchema as N, canvasReferenceNodeIds as O, canvasLayoutMainAxisOf as Ot, appErrorSchema as P, createAgentTokenOutputSchema as Q, completeRecordingOutputSchema as R, recordingSnapshotCapabilityInputSchema as S, canvasReadableSceneDocumentSchema as St, canvasEditsSchema as T, canvasAuthoredLayoutValueOf as Tt, foldPrototypeArtifactPath as U, attachPrototypeArtifactOutputSchema as V, getPrototypeArtifactCapabilitiesOutputSchema as W, MCP_AUTH_SCOPE as X, getMeOutputSchema as Y, cliAuthConfigurationSchema as Z, canvasApplyCapabilityInputSchema as _, canvasWorldBoundsSchema as _t, toExitCode as a, applyCanvasOperationsInputSchema as at, commentAttentionCapabilityInputSchema as b, downloadCanvasRenderOutputSchema as bt, toSharedCapabilities as c, canvasNodeStylePatchSchema as ct, createCapabilityCatalogAdapter as d, saveCanvasDocumentOutputSchema as dt, emptyFixtureDocument as et, createRouterShapeAdapter as f, createCanvasConversionOutputSchema as ft, PROCEDURE_DESCRIPTIONS as g, canvasRenderTargetSchema as gt, OPTION_DESCRIPTIONS as h, canvasRenderSourceStateSchema as ht, toCanvasAuthoringResult as i, MAX_CANVAS_OPERATIONS as it, PartialBatchError as j, fromCanvasReference as k, canvasLayoutPriorityDeclarations as kt, createMcpCapabilityDiscoveryAdapter as l, canvasLayoutWithoutCssProperties as lt, toCapabilityDefinition as m, RENDER_MIN_SCALE as mt, withCommandName as n, beginCanvasActivityOutputSchema as nt, toFailurePayload as o, applyCanvasOperationsOutputSchema as ot, createCapabilityPolicyAdapter as p, getCanvasConversionOutputSchema as pt, prototypeArtifactPathSchema as q, canvasRenderResultSchema as r, canvasAgentActivityPhaseSchema as rt, toPresentedCapabilities as s, canvasOperationSchema as st, withCommandInFailure as t, withFixtureScreen as tt, ProcessExitError as u, getCanvasDocumentOutputSchema as ut, canvasRenderCapabilityInputSchema as v, createCanvasRenderOutputSchema as vt, canvasEditCapabilityInputSchema as w, canvasTypographySchema as wt, prototypePublishCapabilityInputSchema as x, getCanvasRenderOutputSchema as xt, canvasWriteHtmlCapabilityInputSchema as y, createRecordingSnapshotOutputSchema as yt, startRecordingOutputSchema as z };
11222
+ export { createOrganisationOutputSchema as $, parseCanvasReference as A, canvasLayoutPriorityDeclarations as At, PROTOTYPE_ARTIFACT_MANIFEST_PATH as B, transcriptReadCapabilityInputSchema as C, downloadCanvasRenderOutputSchema as Ct, assertCanvasReferenceOperations as D, canvasAuthoredStyleDeclarations as Dt, assertCanvasReferenceNodes as E, canvasAuthoredLayoutValueOf as Et, completeScreenOutputSchema as F, getPrototypePublishStatusOutputSchema as G, createPrototypeArtifactOutputSchema as H, createScreenOutputSchema as I, submitPrototypeArtifactOutputSchema as J, prototypeArtifactManifestSchema as K, appendRecordingChunkOutputSchema as L, CliError as M, canvasSchema as Mt, transcriptOutputSchema as N, canvasReferenceNodeIds as O, canvasAxisStyleProperties as Ot, appErrorSchema as P, createAgentTokenOutputSchema as Q, completeRecordingOutputSchema as R, recordingSnapshotCapabilityInputSchema as S, createRecordingSnapshotOutputSchema as St, canvasEditsSchema as T, canvasReadableSceneDocumentSchema as Tt, foldPrototypeArtifactPath as U, attachPrototypeArtifactOutputSchema as V, getPrototypeArtifactCapabilitiesOutputSchema as W, MCP_AUTH_SCOPE as X, getMeOutputSchema as Y, cliAuthConfigurationSchema as Z, canvasApplyCapabilityInputSchema as _, RENDER_MIN_SCALE as _t, toExitCode as a, beginCanvasActivityOutputSchema as at, commentAttentionCapabilityInputSchema as b, canvasWorldBoundsSchema as bt, toSharedCapabilities as c, getCanvasDocumentOutputSchema as ct, createCapabilityCatalogAdapter as d, applyCanvasOperationsInputSchema as dt, emptyFixtureDocument as et, createRouterShapeAdapter as f, applyCanvasOperationsOutputSchema as ft, PROCEDURE_DESCRIPTIONS as g, getCanvasConversionOutputSchema as gt, OPTION_DESCRIPTIONS as h, createCanvasConversionOutputSchema as ht, toCanvasAuthoringResult as i, canvasTextRunsOf as it, PartialBatchError as j, canvasAdditionalStyleSchema as jt, fromCanvasReference as k, canvasLayoutMainAxisOf as kt, createMcpCapabilityDiscoveryAdapter as l, saveCanvasDocumentOutputSchema as lt, toCapabilityDefinition as m, canvasNodeStylePatchSchema as mt, withCommandName as n, applyCanvasTypographyPatch as nt, toFailurePayload as o, canvasAgentActivityPhaseSchema as ot, createCapabilityPolicyAdapter as p, canvasOperationSchema as pt, prototypeArtifactPathSchema as q, canvasRenderResultSchema as r, canvasCssTypographyOwners as rt, toPresentedCapabilities as s, canvasLayoutWithoutCssProperties as st, withCommandInFailure as t, withFixtureScreen as tt, ProcessExitError as u, MAX_CANVAS_OPERATIONS as ut, canvasRenderCapabilityInputSchema as v, canvasRenderSourceStateSchema as vt, canvasEditCapabilityInputSchema as w, getCanvasRenderOutputSchema as wt, prototypePublishCapabilityInputSchema as x, createCanvasRenderOutputSchema as xt, canvasWriteHtmlCapabilityInputSchema as y, canvasRenderTargetSchema as yt, startRecordingOutputSchema as z };