@enhance-eng/enhance 0.1.33 → 0.1.38

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.
@@ -13,6 +13,334 @@ import { TRPCClientError } from "@trpc/client";
13
13
  //#region \0rolldown/runtime.js
14
14
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
15
15
 
16
+ //#endregion
17
+ //#region ../../packages/canvas-format/src/canvas-format.consts.ts
18
+ /** Historical formats stay pinned; an ordinary writer always uses CANVAS_SCENE_VERSION. */
19
+ const LEGACY_CANVAS_FORMATS = {
20
+ unversioned: void 0,
21
+ v1: 1,
22
+ v2: 2,
23
+ v3: 3,
24
+ v4: 4,
25
+ v5: 5,
26
+ v6: 6,
27
+ v7: 7,
28
+ v8: 8,
29
+ v9: 9,
30
+ v10: 10,
31
+ v11: 11,
32
+ v12: 12
33
+ };
34
+ const LEGACY_CANVAS_ADAPTATIONS = {
35
+ [LEGACY_CANVAS_FORMATS.v1]: "layout",
36
+ [LEGACY_CANVAS_FORMATS.v2]: "layout",
37
+ [LEGACY_CANVAS_FORMATS.v3]: "typography",
38
+ [LEGACY_CANVAS_FORMATS.v4]: "typography",
39
+ [LEGACY_CANVAS_FORMATS.v5]: "typography",
40
+ [LEGACY_CANVAS_FORMATS.v6]: "geometry",
41
+ [LEGACY_CANVAS_FORMATS.v7]: "geometry",
42
+ [LEGACY_CANVAS_FORMATS.v8]: "geometry",
43
+ [LEGACY_CANVAS_FORMATS.v9]: "geometry",
44
+ [LEGACY_CANVAS_FORMATS.v10]: "geometry",
45
+ [LEGACY_CANVAS_FORMATS.v11]: "css",
46
+ [LEGACY_CANVAS_FORMATS.v12]: "text-shadow-blend"
47
+ };
48
+
49
+ //#endregion
50
+ //#region ../../packages/canvas-format/src/canvas-css-adaptation.lib.ts
51
+ const isRecord$3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
52
+ const listOf = (value) => Array.isArray(value) ? value : void 0;
53
+ const without = (record, ...keys) => Object.fromEntries(Object.entries(record).filter(([key]) => !keys.includes(key)));
54
+ /** The one owner of a wrapped mask group's identity, shared by the format adapter and Figma paste. */
55
+ const canvasMaskWrapperId = (sourceId) => `${sourceId}~mask`;
56
+ const MASK_MODES = {
57
+ alpha: "alpha",
58
+ luminance: "luminance",
59
+ vector: "outline"
60
+ };
61
+ const maskModeOf = (node) => {
62
+ if (!isRecord$3(node) || !isRecord$3(node["compositing"])) return void 0;
63
+ const mask = node["compositing"]["mask"];
64
+ return typeof mask === "string" ? MASK_MODES[mask] : void 0;
65
+ };
66
+ const unblended$1 = (paint) => isRecord$3(paint) ? without(paint, "blendMode", "blendSource") : paint;
67
+ /** An older border's alignment is a retired mode that never painted; absent means inside. */
68
+ const borderPaints = (stroke) => isRecord$3(stroke) && "paint" in stroke ? {
69
+ ...without(stroke, "paint", "alignment"),
70
+ paints: [stroke["paint"]]
71
+ } : stroke;
72
+ const uniformBlur = (filter) => {
73
+ if (!isRecord$3(filter) || !isRecord$3(filter["progression"])) return filter;
74
+ const start = filter["progression"]["startValue"];
75
+ const value = filter["value"];
76
+ return {
77
+ ...without(filter, "progression"),
78
+ value: typeof start === "number" && typeof value === "number" ? Math.max(start, value) : value
79
+ };
80
+ };
81
+ const imageWithoutAdjustments = (paint) => isRecord$3(paint) && paint["kind"] === "image" ? without(paint, "adjustments") : paint;
82
+ const textShadows = (shadows) => listOf(shadows)?.filter((shadow) => !isRecord$3(shadow) || shadow["kind"] !== "inner").map((shadow) => isRecord$3(shadow) ? {
83
+ ...shadow,
84
+ spread: 0
85
+ } : shadow) ?? shadows;
86
+ const textStroke = (stroke) => {
87
+ if (!isRecord$3(stroke)) return stroke;
88
+ const next = {
89
+ ...stroke,
90
+ paint: unblended$1(stroke["paint"])
91
+ };
92
+ return stroke["alignment"] === "inside" ? {
93
+ ...next,
94
+ alignment: "center"
95
+ } : next;
96
+ };
97
+ const richTextSpan = (child) => {
98
+ if (!isRecord$3(child) || child["kind"] !== "span") return child;
99
+ const next = without(child, "decorationBlendMode");
100
+ const fills = listOf(child["fills"]);
101
+ if (fills !== void 0) next["fills"] = fills.map((paint) => unblended$1(paint));
102
+ if (isRecord$3(child["stroke"])) next["stroke"] = textStroke(child["stroke"]);
103
+ const children = listOf(child["children"]);
104
+ if (children !== void 0) next["children"] = children.map((span) => richTextSpan(span));
105
+ return next;
106
+ };
107
+ /** Text paints cannot blend on their own: one fill under a Normal layer lends the layer its blend. */
108
+ const textFills = (appearance, next) => {
109
+ const fills = listOf(next["fills"]);
110
+ if (fills === void 0) return;
111
+ const [only] = fills;
112
+ const paintBlend = isRecord$3(only) ? only["blendMode"] : void 0;
113
+ if (typeof paintBlend === "string" && fills.length === 1 && (appearance["blendMode"] ?? "normal") === "normal") next["blendMode"] = paintBlend;
114
+ next["fills"] = fills.map((paint) => unblended$1(paint));
115
+ };
116
+ const adaptAppearance = (appearance, isText) => {
117
+ const next = { ...appearance };
118
+ if ("border" in appearance) next["border"] = borderPaints(appearance["border"]);
119
+ if ("outline" in appearance) next["outline"] = borderPaints(appearance["outline"]);
120
+ const fills = listOf(appearance["fills"]);
121
+ if (fills !== void 0) next["fills"] = fills.map((paint) => imageWithoutAdjustments(paint));
122
+ const filters = listOf(appearance["filters"]);
123
+ if (filters !== void 0) next["filters"] = filters.map((filter) => uniformBlur(filter));
124
+ if (!isText) return next;
125
+ if ("shadows" in appearance) next["shadows"] = textShadows(appearance["shadows"]);
126
+ textFills(appearance, next);
127
+ return next;
128
+ };
129
+ const withoutCopiedMaskCss = (node) => {
130
+ const props = node["props"];
131
+ if (!isRecord$3(props) || !isRecord$3(props["paintFallback"])) return { ...node };
132
+ const copied = props["paintFallback"]["mask"];
133
+ if (copied === void 0) return { ...node };
134
+ const fallback = without(props["paintFallback"], "mask");
135
+ const nextProps = Object.keys(fallback).length === 0 ? without(props, "paintFallback") : {
136
+ ...props,
137
+ paintFallback: fallback
138
+ };
139
+ const styles = node["styles"];
140
+ const next = without(node, "props");
141
+ if (isRecord$3(copied) && isRecord$3(styles)) next["styles"] = Object.fromEntries(Object.entries(styles).filter(([key, value]) => copied[key] !== value));
142
+ if (Object.keys(nextProps).length > 0) next["props"] = nextProps;
143
+ return next;
144
+ };
145
+ const isIsolating = (node) => {
146
+ const compositing = node["compositing"];
147
+ if (!isRecord$3(compositing)) return false;
148
+ if (compositing["groupMode"] !== void 0) return compositing["groupMode"] === "isolated";
149
+ return compositing["paintSemantics"] === "web" && (node["component"] === "frame" || node["component"] === "group");
150
+ };
151
+ const adaptTypography = (typography) => {
152
+ const next = { ...typography };
153
+ if ("stroke" in typography) next["stroke"] = textStroke(typography["stroke"]);
154
+ if (isRecord$3(typography["decoration"])) next["decoration"] = without(typography["decoration"], "blendMode");
155
+ return next;
156
+ };
157
+ const adaptNode$1 = (node) => {
158
+ if (!isRecord$3(node)) return node;
159
+ const next = without(withoutCopiedMaskCss(node), "compositing");
160
+ if (isIsolating(node) && isRecord$3(next["styles"])) next["styles"] = {
161
+ ...next["styles"],
162
+ isolation: "isolate"
163
+ };
164
+ const isText = node["component"] === "text";
165
+ if (isRecord$3(node["appearance"])) next["appearance"] = adaptAppearance(node["appearance"], isText);
166
+ if (!isText) return next;
167
+ if (isRecord$3(node["typography"])) next["typography"] = adaptTypography(node["typography"]);
168
+ const props = next["props"];
169
+ const richText = isRecord$3(props) ? listOf(props["richText"]) : void 0;
170
+ if (richText !== void 0 && isRecord$3(props)) next["props"] = {
171
+ ...props,
172
+ richText: richText.map((span) => richTextSpan(span))
173
+ };
174
+ return next;
175
+ };
176
+ const sortKeyOf = (relationship) => isRecord$3(relationship) && typeof relationship["sortKey"] === "string" ? relationship["sortKey"] : "";
177
+ const childrenByParent = (relationships) => {
178
+ const children = /* @__PURE__ */ new Map();
179
+ for (const [id, relationship] of Object.entries(relationships)) {
180
+ if (!isRecord$3(relationship) || typeof relationship["parentId"] !== "string") continue;
181
+ const list = children.get(relationship["parentId"]);
182
+ if (list === void 0) children.set(relationship["parentId"], [id]);
183
+ else list.push(id);
184
+ }
185
+ const order = (id) => sortKeyOf(relationships[id]);
186
+ /** Sort keys order by code unit, as fractional indexes do; a locale compare would reorder them. */
187
+ const byKey = (a, b) => {
188
+ if (order(a) < order(b)) return -1;
189
+ return Number(order(a) > order(b));
190
+ };
191
+ for (const list of children.values()) list.sort(byKey);
192
+ return children;
193
+ };
194
+ const maskGroupNode = (id, sourceId, mode) => ({
195
+ id,
196
+ label: "Mask",
197
+ labelOrigin: "generated",
198
+ component: "group",
199
+ styles: {},
200
+ geometry: {
201
+ kind: "mask",
202
+ maskId: sourceId,
203
+ mode
204
+ }
205
+ });
206
+ /** Wraps each mask source and the layers above it, up to the next mask, in a mask group. */
207
+ const wrapMaskRuns = (original, children, nodes, relationships) => {
208
+ let wrapper = "";
209
+ for (const id of children) {
210
+ const mode = maskModeOf(original[id]);
211
+ if (mode !== void 0) {
212
+ wrapper = canvasMaskWrapperId(id);
213
+ nodes[wrapper] = maskGroupNode(wrapper, id, mode);
214
+ relationships[wrapper] = relationships[id];
215
+ }
216
+ const relationship = relationships[id];
217
+ if (wrapper !== "" && isRecord$3(relationship)) relationships[id] = {
218
+ ...relationship,
219
+ parentId: wrapper
220
+ };
221
+ }
222
+ };
223
+ /** A backmost mask of a plain group makes that group the mask group; every other mask is wrapped. */
224
+ const maskGroups = (original, nodes, relationships) => {
225
+ for (const [parentId, children] of childrenByParent(relationships)) {
226
+ const masks = children.filter((id) => maskModeOf(original[id]) !== void 0);
227
+ const [first] = children;
228
+ const parent = nodes[parentId];
229
+ const mode = maskModeOf(original[first]);
230
+ if (mode !== void 0 && masks.length === 1 && isRecord$3(parent) && parent["component"] === "group" && parent["geometry"] === void 0) nodes[parentId] = {
231
+ ...parent,
232
+ geometry: {
233
+ kind: "mask",
234
+ maskId: first,
235
+ mode
236
+ }
237
+ };
238
+ else wrapMaskRuns(original, children, nodes, relationships);
239
+ }
240
+ };
241
+ /** Rewrites format 11 compositing, and the settings CSS cannot draw, to what the browser paints. */
242
+ const adaptCanvasCss = (document) => {
243
+ const original = document["nodes"];
244
+ if (!isRecord$3(original)) return document;
245
+ const nodes = Object.fromEntries(Object.entries(original).map(([id, node]) => [id, adaptNode$1(node)]));
246
+ if (!isRecord$3(document["relationships"])) return {
247
+ ...document,
248
+ nodes
249
+ };
250
+ const relationships = { ...document["relationships"] };
251
+ maskGroups(original, nodes, relationships);
252
+ return {
253
+ ...document,
254
+ nodes,
255
+ relationships
256
+ };
257
+ };
258
+
259
+ //#endregion
260
+ //#region ../../packages/canvas-format/src/canvas-text-shadow-adaptation.lib.ts
261
+ const isRecord$2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
262
+ const unblended = (shadow) => isRecord$2(shadow) ? Object.fromEntries(Object.entries(shadow).filter(([key]) => key !== "blendMode" && key !== "blendSource")) : shadow;
263
+ const adaptNode = (node) => {
264
+ if (!isRecord$2(node) || node["component"] !== "text" || !isRecord$2(node["appearance"])) return node;
265
+ const shadows = node["appearance"]["shadows"];
266
+ if (!Array.isArray(shadows)) return node;
267
+ return {
268
+ ...node,
269
+ appearance: {
270
+ ...node["appearance"],
271
+ shadows: shadows.map((shadow) => unblended(shadow))
272
+ }
273
+ };
274
+ };
275
+ /**
276
+ * The format 13 step: CSS draws a text shadow as part of the text, so a text shadow keeps its
277
+ * colour, offset, blur and visibility and loses its blend and that blend's source.
278
+ */
279
+ const withoutTextShadowBlends = (document) => {
280
+ const nodes = document["nodes"];
281
+ if (!isRecord$2(nodes)) return document;
282
+ return {
283
+ ...document,
284
+ nodes: Object.fromEntries(Object.entries(nodes).map(([id, node]) => [id, adaptNode(node)]))
285
+ };
286
+ };
287
+
288
+ //#endregion
289
+ //#region ../../packages/canvas-format/src/canvas-format.lib.ts
290
+ const READABLE_FORMATS = /* @__PURE__ */ new Set([...Object.values(LEGACY_CANVAS_FORMATS), 13]);
291
+ const isReadableCanvasFormat = (version) => READABLE_FORMATS.has(version);
292
+ /** Formats whose adaptation rewrites the stored document in place, keeping its geometry. */
293
+ const ADAPTED_IN_PLACE = /* @__PURE__ */ new Set([
294
+ "text-shadow-blend",
295
+ "css",
296
+ "geometry"
297
+ ]);
298
+ const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
299
+ const legacyLayout = (layout) => {
300
+ if (!isRecord$1(layout)) return layout;
301
+ const next = Object.fromEntries(Object.entries(layout).filter(([key]) => key !== "gridTrack"));
302
+ const container = next["container"];
303
+ if (isRecord$1(container)) next["container"] = Object.fromEntries(Object.entries(container).filter(([key]) => key !== "materialized"));
304
+ for (const axis of ["horizontal", "vertical"]) {
305
+ const intent = next[axis];
306
+ if (isRecord$1(intent) && intent["mode"] === "hug") next[axis] = Object.fromEntries(Object.entries(intent).filter(([key]) => key !== "basis"));
307
+ }
308
+ return next;
309
+ };
310
+ const adaptLegacyFormat = (document) => {
311
+ const version = document["version"];
312
+ if (!isReadableCanvasFormat(version)) return null;
313
+ if (version === 13 || !isRecord$1(document["nodes"])) return document;
314
+ const adaptation = Object.entries(LEGACY_CANVAS_ADAPTATIONS).find(([format]) => Number(format) === version)?.[1];
315
+ if (ADAPTED_IN_PLACE.has(adaptation)) return {
316
+ ...document,
317
+ version: 13
318
+ };
319
+ if (Object.values(document["nodes"]).some((node) => isRecord$1(node) && node["geometry"] !== void 0)) return null;
320
+ if (adaptation === "typography") return {
321
+ ...document,
322
+ version: 13
323
+ };
324
+ return {
325
+ ...document,
326
+ version: 13,
327
+ nodes: Object.fromEntries(Object.entries(document["nodes"]).map(([id, node]) => [id, isRecord$1(node) && node["layout"] !== void 0 ? {
328
+ ...node,
329
+ layout: legacyLayout(node["layout"])
330
+ } : node]))
331
+ };
332
+ };
333
+ /**
334
+ * Adapt known formats in memory, retaining malformed content for each boundary's validator. Format
335
+ * 12 already has the CSS model, so it takes only the text shadow step that every older format takes
336
+ * after the CSS adaptation.
337
+ */
338
+ const adaptCanvasDocumentFormat = (document) => {
339
+ const adapted = adaptLegacyFormat(document);
340
+ if (adapted === null || adapted === document) return adapted;
341
+ return withoutTextShadowBlends(document["version"] === LEGACY_CANVAS_FORMATS.v12 ? adapted : adaptCanvasCss(adapted));
342
+ };
343
+
16
344
  //#endregion
17
345
  //#region ../../packages/contract/src/canvas/first-agent-work.schema.ts
18
346
  const firstAgentWorkInputSchema = z.strictObject({});
@@ -51,7 +379,7 @@ const BYTES_PER_KIB$1 = 1024;
51
379
  //#region ../../packages/contract/src/canvas/canvas-thumbnail.schema.ts
52
380
  const THUMBNAIL_WIDTH = 528;
53
381
  const THUMBNAIL_HEIGHT = 312;
54
- /** @justified docs/comments.md#warning Lossless PNG needs more headroom than client JPEG/WebP. */
382
+ /** @justified warning Lossless PNG needs more headroom than client JPEG/WebP. */
55
383
  const THUMBNAIL_MAX_KIB = 1024;
56
384
  const MAX_RELEASE_IDENTITY_LENGTH = 100;
57
385
  const MAX_THUMBNAIL_BYTES = THUMBNAIL_MAX_KIB * BYTES_PER_KIB$1;
@@ -95,17 +423,23 @@ const reportCanvasThumbnailUnavailableOutputSchema = z.object({ recorded: z.lite
95
423
  const CANVAS_ACCESS_STATES = [
96
424
  "invite-only",
97
425
  "link-view",
98
- "link-comment"
426
+ "link-comment",
427
+ "link-edit"
99
428
  ];
100
429
  const canvasAccessStateSchema = z.enum(CANVAS_ACCESS_STATES);
101
430
  const ACCESS_LEVELS = [
102
431
  "owner",
432
+ "can-edit",
103
433
  "can-comment",
104
434
  "can-view"
105
435
  ];
106
436
  const accessLevelSchema = z.enum(ACCESS_LEVELS);
107
- /** The two levels an invite may offer. Only the creator is an owner, and only by creating. */
108
- const grantableAccessLevelSchema = z.enum(["can-comment", "can-view"]);
437
+ /** An invitation grants content access, never ownership. Only the creator is an owner, and only by creating. */
438
+ const grantableAccessLevelSchema = z.enum([
439
+ "can-edit",
440
+ "can-comment",
441
+ "can-view"
442
+ ]);
109
443
  /** What this viewer may do here, resolved server-side so the UI never has to guess. */
110
444
  const viewerCapabilitySchema = z.object({
111
445
  read: z.boolean(),
@@ -114,6 +448,20 @@ const viewerCapabilitySchema = z.object({
114
448
  "sign-in",
115
449
  "no"
116
450
  ]),
451
+ edit: z.enum([
452
+ "yes",
453
+ "sign-in",
454
+ "no"
455
+ ]).default("no"),
456
+ grants: z.array(z.object({
457
+ source: z.enum([
458
+ "direct",
459
+ "team",
460
+ "link"
461
+ ]),
462
+ accessLevel: accessLevelSchema
463
+ })).default([]),
464
+ grantableAccessLevels: z.array(grantableAccessLevelSchema).default([]),
117
465
  share: z.boolean(),
118
466
  manage: z.boolean()
119
467
  });
@@ -162,7 +510,9 @@ const listCanvasesInputSchema = z.object({
162
510
  });
163
511
  const canvasCardBaseSchema = canvasSchema.extend({
164
512
  screenCount: z.number().int().min(0),
165
- hasRecording: z.boolean()
513
+ hasRecording: z.boolean(),
514
+ /** When the person listing last opened it in the web app; `null` if they never have. */
515
+ lastViewedAt: z.iso.datetime().nullable()
166
516
  });
167
517
  const canvasCardSchema = z.union([canvasCardBaseSchema.extend({ thumbnail: canvasThumbnailPreviewSchema }), canvasCardBaseSchema.extend({
168
518
  thumbnail: z.null(),
@@ -204,16 +554,240 @@ const setCanvasAccessOutputSchema = z.object({
204
554
  widened: z.boolean()
205
555
  });
206
556
  const markCanvasViewedInputSchema = z.object({ canvasId: z.uuid() });
207
- /** `null` for a link visitor: a view is recorded on a membership row, and they have none. */
557
+ /**
558
+ * Kept for each person, for a direct or team grant. `null` for a link visitor and for any call
559
+ * from an agent, because only the person's own opens in the web app count.
560
+ */
208
561
  const markCanvasViewedOutputSchema = z.object({ lastViewedAt: z.iso.datetime().nullable() });
209
562
  const restoreCanvasInputSchema = z.object({ canvasId: z.uuid() });
210
563
  const restoreCanvasOutputSchema = z.object({ canvasId: z.uuid() });
211
564
 
565
+ //#endregion
566
+ //#region ../../packages/contract/src/canvas/canvas-css-value.schema.ts
567
+ const unsafeStyleValue = /javascript|vbscript|data\s*:\s*text\/html|expression\s*\(|@import/iu;
568
+ const canvasCssValueSchema = z.string().refine((value) => !unsafeStyleValue.test(value), "unsafe CSS value");
569
+
212
570
  //#endregion
213
571
  //#region ../../packages/contract/src/canvas/canvas-limits.schema.ts
214
572
  const canvasNumberSchema = z.number();
215
573
  const nonNegativeCanvasNumberSchema = z.number().nonnegative();
216
574
 
575
+ //#endregion
576
+ //#region ../../packages/contract/src/canvas/canvas-paint.schema.ts
577
+ const QUARTER_TURN = 90;
578
+ const HALF_TURN = 180;
579
+ const THREE_QUARTER_TURN = 270;
580
+ const boundedNumber$1 = canvasNumberSchema;
581
+ const nonNegativeNumber$2 = nonNegativeCanvasNumberSchema;
582
+ const ratio$1 = z.number().min(0).max(1);
583
+ const itemId$1 = z.string().min(1);
584
+ const canvasColorSchema = z.object({
585
+ space: z.enum(["srgb", "display-p3"]),
586
+ red: ratio$1,
587
+ green: ratio$1,
588
+ blue: ratio$1,
589
+ alpha: ratio$1,
590
+ definitionId: itemId$1.optional()
591
+ });
592
+ const canvasGradientStopSchema = z.object({
593
+ id: itemId$1,
594
+ position: ratio$1,
595
+ color: canvasColorSchema
596
+ });
597
+ const canvasFilterBaseSchema = z.object({
598
+ id: itemId$1,
599
+ visible: z.boolean()
600
+ });
601
+ const canvasBlurFilterSchema = canvasFilterBaseSchema.extend({
602
+ kind: z.literal("blur"),
603
+ value: nonNegativeNumber$2,
604
+ parameter: z.enum(["radius", "standard-deviation"]).optional()
605
+ });
606
+ const canvasFilterKinds = [
607
+ canvasFilterBaseSchema.extend({
608
+ kind: z.literal("brightness"),
609
+ value: nonNegativeNumber$2
610
+ }),
611
+ canvasFilterBaseSchema.extend({
612
+ kind: z.literal("contrast"),
613
+ value: nonNegativeNumber$2
614
+ }),
615
+ canvasFilterBaseSchema.extend({
616
+ kind: z.literal("grayscale"),
617
+ value: ratio$1
618
+ }),
619
+ canvasFilterBaseSchema.extend({
620
+ kind: z.literal("hue-rotate"),
621
+ value: boundedNumber$1
622
+ }),
623
+ canvasFilterBaseSchema.extend({
624
+ kind: z.literal("invert"),
625
+ value: ratio$1
626
+ }),
627
+ canvasFilterBaseSchema.extend({
628
+ kind: z.literal("saturate"),
629
+ value: nonNegativeNumber$2
630
+ }),
631
+ canvasFilterBaseSchema.extend({
632
+ kind: z.literal("sepia"),
633
+ value: ratio$1
634
+ })
635
+ ];
636
+ /** A CSS filter on a layer or on an image fill. */
637
+ const canvasFilterSchema = z.discriminatedUnion("kind", [canvasBlurFilterSchema, ...canvasFilterKinds]);
638
+ /** A CSS backdrop filter; only a background blur can progress across the layer. */
639
+ const canvasBackdropFilterSchema = z.discriminatedUnion("kind", [canvasBlurFilterSchema.extend({
640
+ /** Endpoints use normalized body coordinates; startValue uses the filter's authored unit. */
641
+ progression: z.object({
642
+ startValue: nonNegativeNumber$2,
643
+ start: z.object({
644
+ x: boundedNumber$1,
645
+ y: boundedNumber$1
646
+ }),
647
+ end: z.object({
648
+ x: boundedNumber$1,
649
+ y: boundedNumber$1
650
+ })
651
+ }).optional() }), ...canvasFilterKinds]);
652
+ /** Maps normalized source (u,v) into body (a*u+c*v+e,b*u+d*v+f), before node rotation. */
653
+ const canvasPaintTransformSchema = z.tuple([
654
+ boundedNumber$1,
655
+ boundedNumber$1,
656
+ boundedNumber$1,
657
+ boundedNumber$1,
658
+ boundedNumber$1,
659
+ boundedNumber$1
660
+ ]).refine(([a, b, c, d]) => a * d !== b * c, "paint transform must be invertible");
661
+ const CANVAS_BLEND_MODES = [
662
+ "normal",
663
+ "multiply",
664
+ "screen",
665
+ "overlay",
666
+ "darken",
667
+ "lighten",
668
+ "plus-lighter",
669
+ "color-dodge",
670
+ "color-burn",
671
+ "hard-light",
672
+ "soft-light",
673
+ "difference",
674
+ "exclusion",
675
+ "hue",
676
+ "saturation",
677
+ "color",
678
+ "luminosity"
679
+ ];
680
+ const canvasBlendModeSchema = z.enum(CANVAS_BLEND_MODES);
681
+ const canvasBlendSourceSchema = z.object({
682
+ kind: z.literal("figma"),
683
+ originalMode: z.string(),
684
+ mappedMode: canvasBlendModeSchema,
685
+ sourceGuid: z.string().optional(),
686
+ path: z.array(z.string())
687
+ });
688
+ const canvasPaintBaseSchema = z.object({
689
+ id: itemId$1,
690
+ blendMode: canvasBlendModeSchema.optional(),
691
+ blendSource: canvasBlendSourceSchema.optional(),
692
+ visible: z.boolean(),
693
+ opacity: ratio$1
694
+ });
695
+ const canvasPaintCoreSchema = z.discriminatedUnion("kind", [
696
+ canvasPaintBaseSchema.extend({
697
+ kind: z.literal("solid"),
698
+ color: canvasColorSchema
699
+ }),
700
+ canvasPaintBaseSchema.extend({
701
+ kind: z.literal("linear-gradient"),
702
+ angle: boundedNumber$1,
703
+ transform: canvasPaintTransformSchema.optional(),
704
+ stops: z.array(canvasGradientStopSchema).min(2)
705
+ }),
706
+ canvasPaintBaseSchema.extend({
707
+ kind: z.literal("radial-gradient"),
708
+ center: z.object({
709
+ x: boundedNumber$1,
710
+ y: boundedNumber$1
711
+ }),
712
+ radius: z.object({
713
+ x: nonNegativeNumber$2,
714
+ y: nonNegativeNumber$2
715
+ }),
716
+ transform: canvasPaintTransformSchema.optional(),
717
+ stops: z.array(canvasGradientStopSchema).min(2)
718
+ }),
719
+ canvasPaintBaseSchema.extend({
720
+ kind: z.literal("angular-gradient"),
721
+ /** Maps normalized gradient coordinates into the node body, before node rotation. */
722
+ transform: canvasPaintTransformSchema,
723
+ stops: z.array(canvasGradientStopSchema).min(2)
724
+ }),
725
+ canvasPaintBaseSchema.extend({
726
+ kind: z.literal("diamond-gradient"),
727
+ transform: canvasPaintTransformSchema,
728
+ stops: z.array(canvasGradientStopSchema).min(2)
729
+ }),
730
+ canvasPaintBaseSchema.extend({
731
+ kind: z.literal("image"),
732
+ assetId: z.string().min(1),
733
+ fit: z.enum([
734
+ "fill",
735
+ "cover",
736
+ "fit",
737
+ "crop",
738
+ "tile"
739
+ ]),
740
+ tileScale: boundedNumber$1.positive().optional(),
741
+ tileOrigin: z.enum(["center", "top-left"]).optional(),
742
+ rotation: z.union([
743
+ z.literal(0),
744
+ z.literal(QUARTER_TURN),
745
+ z.literal(HALF_TURN),
746
+ z.literal(THREE_QUARTER_TURN)
747
+ ]).optional(),
748
+ crop: z.object({
749
+ x: ratio$1,
750
+ y: ratio$1,
751
+ width: ratio$1,
752
+ height: ratio$1
753
+ }).optional(),
754
+ transform: canvasPaintTransformSchema.optional(),
755
+ filters: z.array(canvasFilterSchema).optional(),
756
+ /** The image's own pixel size, which cover, fit and tile need to place it outside its layer. */
757
+ naturalSize: z.object({
758
+ width: boundedNumber$1.positive(),
759
+ height: boundedNumber$1.positive()
760
+ }).optional()
761
+ }).refine((paint) => paint.crop === void 0 || paint.transform === void 0, {
762
+ message: "image paint cannot have both a crop rectangle and an affine transform",
763
+ path: ["transform"]
764
+ })
765
+ ]);
766
+ const canvasPaintSchema = z.intersection(canvasPaintCoreSchema, z.object({ alternatives: z.partialRecord(z.enum([
767
+ "solid",
768
+ "linear-gradient",
769
+ "radial-gradient",
770
+ "angular-gradient",
771
+ "diamond-gradient",
772
+ "image"
773
+ ]), canvasPaintCoreSchema).optional() }));
774
+ const canvasColorDefinitionSchema = z.object({
775
+ id: itemId$1,
776
+ name: z.string().trim().min(1),
777
+ value: z.union([canvasColorSchema.omit({ definitionId: true }), z.object({ definitionId: itemId$1 })]),
778
+ source: z.object({
779
+ kind: z.literal("figma"),
780
+ key: itemId$1,
781
+ modeId: itemId$1.optional()
782
+ }).optional()
783
+ });
784
+ const setCanvasArtworkColorOperationSchema = z.object({
785
+ op: z.literal("setArtworkColor"),
786
+ nodeId: z.literal("root"),
787
+ colorId: z.string().min(1),
788
+ definition: canvasColorDefinitionSchema.nullable()
789
+ }).refine((operation) => operation.definition === null || operation.definition.id === operation.colorId, "colour identity must match");
790
+
217
791
  //#endregion
218
792
  //#region ../../packages/contract/src/canvas/canvas-layout.schema.ts
219
793
  const canvasParentSizeBoundSchema = z.object({
@@ -231,7 +805,10 @@ const canvasSizeIntentSchema = z.discriminatedUnion("mode", [
231
805
  mode: z.literal("fixed"),
232
806
  value: nonNegativeCanvasNumberSchema
233
807
  }).strict(),
234
- canvasSizeIntentBoundsSchema.extend({ mode: z.literal("hug") }).strict(),
808
+ canvasSizeIntentBoundsSchema.extend({
809
+ mode: z.literal("hug"),
810
+ implicitExtent: nonNegativeCanvasNumberSchema.optional()
811
+ }).strict(),
235
812
  canvasSizeIntentBoundsSchema.extend({
236
813
  mode: z.literal("fill"),
237
814
  offset: canvasNumberSchema.optional()
@@ -283,9 +860,10 @@ const canvasFlexLayoutSchema = z.object({
283
860
  "space-around",
284
861
  "space-evenly"
285
862
  ]),
286
- gap: nonNegativeCanvasNumberSchema,
287
- rowGap: nonNegativeCanvasNumberSchema.optional(),
288
- columnGap: nonNegativeCanvasNumberSchema.optional(),
863
+ gap: canvasNumberSchema,
864
+ rowGap: canvasNumberSchema.optional(),
865
+ columnGap: canvasNumberSchema.optional(),
866
+ crossGapMode: z.literal("auto").optional(),
289
867
  wrap: z.enum(["nowrap", "wrap"]).optional(),
290
868
  gridColumns: z.number().int().positive().optional(),
291
869
  gridAutoRepeat: canvasGridAutoRepeatSchema.optional(),
@@ -300,6 +878,18 @@ const canvasNodeLayoutSchema = z.object({
300
878
  horizontal: canvasSizeIntentSchema.optional(),
301
879
  vertical: canvasSizeIntentSchema.optional(),
302
880
  position: z.enum(["flow", "absolute"]).optional(),
881
+ retainedIgnore: z.literal(true).optional(),
882
+ gridParticipation: z.literal("unassigned").optional(),
883
+ gridEmptyPlacement: z.literal("manual").optional(),
884
+ gridAutoTrackPolicy: z.object({
885
+ rows: z.literal("extend-last").optional(),
886
+ columns: z.literal("extend-last").optional()
887
+ }).strict().optional(),
888
+ retainedFlexSpacing: z.object({
889
+ gap: z.union([canvasNumberSchema, canvasCssValueSchema.min(1)]),
890
+ counterGap: z.union([canvasNumberSchema, canvasCssValueSchema.min(1)]),
891
+ crossGapMode: z.literal("auto").optional()
892
+ }).strict().optional(),
303
893
  alignSelf: z.enum([
304
894
  "auto",
305
895
  "start",
@@ -323,100 +913,10 @@ const canvasNodeLayoutSchema = z.object({
323
913
 
324
914
  //#endregion
325
915
  //#region ../../packages/contract/src/canvas/canvas-presentation.schema.ts
326
- const QUARTER_TURN = 90;
327
- const HALF_TURN = 180;
328
- const THREE_QUARTER_TURN = 270;
329
916
  const boundedNumber = canvasNumberSchema;
330
917
  const nonNegativeNumber$1 = nonNegativeCanvasNumberSchema;
331
918
  const ratio = z.number().min(0).max(1);
332
919
  const itemId = z.string().min(1);
333
- const canvasColorSchema = z.object({
334
- space: z.enum(["srgb", "display-p3"]),
335
- red: ratio,
336
- green: ratio,
337
- blue: ratio,
338
- alpha: ratio
339
- });
340
- const canvasGradientStopSchema = z.object({
341
- id: itemId,
342
- position: ratio,
343
- color: canvasColorSchema
344
- });
345
- const canvasPointSchema = z.object({
346
- x: ratio,
347
- y: ratio
348
- });
349
- const adjustment = z.number().min(-1).max(1);
350
- const canvasImageAdjustmentsSchema = z.object({
351
- exposure: adjustment.optional(),
352
- contrast: adjustment.optional(),
353
- saturation: adjustment.optional(),
354
- temperature: adjustment.optional(),
355
- tint: adjustment.optional(),
356
- highlights: adjustment.optional(),
357
- shadows: adjustment.optional()
358
- });
359
- /** Maps normalized source (u,v) into body (a*u+c*v+e,b*u+d*v+f), before node rotation. */
360
- const canvasImageTransformSchema = z.tuple([
361
- boundedNumber,
362
- boundedNumber,
363
- boundedNumber,
364
- boundedNumber,
365
- boundedNumber,
366
- boundedNumber
367
- ]).refine(([a, b, c, d]) => a * d !== b * c, "image transform must be invertible");
368
- const canvasPaintBaseSchema = z.object({
369
- id: itemId,
370
- visible: z.boolean(),
371
- opacity: ratio
372
- });
373
- const canvasPaintSchema = z.discriminatedUnion("kind", [
374
- canvasPaintBaseSchema.extend({
375
- kind: z.literal("solid"),
376
- color: canvasColorSchema
377
- }),
378
- canvasPaintBaseSchema.extend({
379
- kind: z.literal("linear-gradient"),
380
- angle: boundedNumber,
381
- stops: z.array(canvasGradientStopSchema).min(2)
382
- }),
383
- canvasPaintBaseSchema.extend({
384
- kind: z.literal("radial-gradient"),
385
- center: canvasPointSchema,
386
- radius: canvasPointSchema,
387
- stops: z.array(canvasGradientStopSchema).min(2)
388
- }),
389
- canvasPaintBaseSchema.extend({
390
- kind: z.literal("image"),
391
- assetId: z.string().min(1),
392
- fit: z.enum([
393
- "fill",
394
- "cover",
395
- "fit",
396
- "crop",
397
- "tile"
398
- ]),
399
- tileScale: boundedNumber.positive().optional(),
400
- tileOrigin: z.enum(["center", "top-left"]).optional(),
401
- rotation: z.union([
402
- z.literal(0),
403
- z.literal(QUARTER_TURN),
404
- z.literal(HALF_TURN),
405
- z.literal(THREE_QUARTER_TURN)
406
- ]).optional(),
407
- crop: z.object({
408
- x: ratio,
409
- y: ratio,
410
- width: ratio,
411
- height: ratio
412
- }).optional(),
413
- transform: canvasImageTransformSchema.optional(),
414
- adjustments: canvasImageAdjustmentsSchema.optional()
415
- }).refine((paint) => paint.crop === void 0 || paint.transform === void 0, {
416
- message: "image paint cannot have both a crop rectangle and an affine transform",
417
- path: ["transform"]
418
- })
419
- ]);
420
920
  const canvasCornerRadiusSchema = z.object({
421
921
  topLeft: nonNegativeNumber$1,
422
922
  topRight: nonNegativeNumber$1,
@@ -424,8 +924,22 @@ const canvasCornerRadiusSchema = z.object({
424
924
  bottomLeft: nonNegativeNumber$1,
425
925
  smoothing: ratio.optional()
426
926
  });
927
+ /** Dash and gap lengths, repeated; an odd list repeats twice as SVG does. Writers store all zeros as none. */
928
+ const canvasDashPatternSchema = z.array(nonNegativeNumber$1).min(1);
929
+ /** none is a butt cap. */
930
+ const canvasDashCapSchema = z.enum([
931
+ "none",
932
+ "round",
933
+ "square"
934
+ ]);
427
935
  const canvasBorderSchema = z.object({
428
936
  visible: z.boolean(),
937
+ /** Absent reserves CSS widths; visible reserves only visible paint, while none separates paint from layout. */
938
+ layoutInclusion: z.enum([
939
+ "always",
940
+ "visible",
941
+ "none"
942
+ ]).optional(),
429
943
  width: z.object({
430
944
  top: nonNegativeNumber$1,
431
945
  right: nonNegativeNumber$1,
@@ -437,7 +951,20 @@ const canvasBorderSchema = z.object({
437
951
  "dashed",
438
952
  "dotted"
439
953
  ]),
440
- paint: canvasPaintSchema
954
+ paints: z.array(canvasPaintSchema),
955
+ dashPattern: canvasDashPatternSchema.optional(),
956
+ dashCap: canvasDashCapSchema.optional(),
957
+ /** Absent paints inside the layer box, as CSS borders do. */
958
+ alignment: z.enum([
959
+ "inside",
960
+ "center",
961
+ "outside"
962
+ ]).optional()
963
+ });
964
+ const retainedBorderSchema = canvasBorderSchema.pick({
965
+ width: true,
966
+ style: true,
967
+ layoutInclusion: true
441
968
  });
442
969
  const canvasOutlineSchema = z.object({
443
970
  visible: z.boolean(),
@@ -448,7 +975,9 @@ const canvasOutlineSchema = z.object({
448
975
  "dashed",
449
976
  "dotted"
450
977
  ]),
451
- paint: canvasPaintSchema
978
+ paints: z.array(canvasPaintSchema),
979
+ dashPattern: canvasDashPatternSchema.optional(),
980
+ dashCap: canvasDashCapSchema.optional()
452
981
  });
453
982
  const canvasShadowSchema = z.object({
454
983
  id: itemId,
@@ -458,93 +987,30 @@ const canvasShadowSchema = z.object({
458
987
  offsetX: boundedNumber,
459
988
  offsetY: boundedNumber,
460
989
  blur: nonNegativeNumber$1,
461
- spread: boundedNumber
462
- });
463
- const canvasFilterBaseSchema = z.object({
464
- id: itemId,
465
- visible: z.boolean()
990
+ spread: boundedNumber,
991
+ blendMode: canvasBlendModeSchema.optional(),
992
+ blendSource: canvasBlendSourceSchema.optional(),
993
+ isShownBehindNode: z.boolean().optional()
466
994
  });
467
- const canvasFilterSchema = z.discriminatedUnion("kind", [
468
- canvasFilterBaseSchema.extend({
469
- kind: z.literal("blur"),
470
- value: nonNegativeNumber$1
471
- }),
472
- canvasFilterBaseSchema.extend({
473
- kind: z.literal("brightness"),
474
- value: nonNegativeNumber$1
475
- }),
476
- canvasFilterBaseSchema.extend({
477
- kind: z.literal("contrast"),
478
- value: nonNegativeNumber$1
479
- }),
480
- canvasFilterBaseSchema.extend({
481
- kind: z.literal("grayscale"),
482
- value: ratio
483
- }),
484
- canvasFilterBaseSchema.extend({
485
- kind: z.literal("hue-rotate"),
486
- value: boundedNumber
487
- }),
488
- canvasFilterBaseSchema.extend({
489
- kind: z.literal("invert"),
490
- value: ratio
491
- }),
492
- canvasFilterBaseSchema.extend({
493
- kind: z.literal("saturate"),
494
- value: nonNegativeNumber$1
495
- }),
496
- canvasFilterBaseSchema.extend({
497
- kind: z.literal("sepia"),
498
- value: ratio
499
- })
500
- ]);
501
- const CANVAS_BLEND_MODES = [
502
- "normal",
503
- "multiply",
504
- "screen",
505
- "overlay",
506
- "darken",
507
- "lighten",
508
- "plus-lighter",
509
- "color-dodge",
510
- "color-burn",
511
- "hard-light",
512
- "soft-light",
513
- "difference",
514
- "exclusion",
515
- "hue",
516
- "saturation",
517
- "color",
518
- "luminosity"
519
- ];
520
- const canvasBlendModeSchema = z.enum(CANVAS_BLEND_MODES);
521
995
  const canvasAppearanceSchema = z.object({
522
996
  opacity: ratio,
523
997
  blendMode: canvasBlendModeSchema,
524
998
  fills: z.array(canvasPaintSchema),
525
999
  border: canvasBorderSchema,
1000
+ retainedBorder: retainedBorderSchema.optional(),
526
1001
  outline: canvasOutlineSchema,
527
1002
  radius: canvasCornerRadiusSchema,
528
1003
  shadows: z.array(canvasShadowSchema),
529
1004
  filters: z.array(canvasFilterSchema),
530
- backdropFilters: z.array(canvasFilterSchema)
1005
+ backdropFilters: z.array(canvasBackdropFilterSchema)
531
1006
  });
532
- const canvasAppearanceValuesSchema = z.object({
533
- opacity: ratio.optional(),
534
- blendMode: canvasBlendModeSchema.optional(),
535
- fills: z.array(canvasPaintSchema).optional(),
536
- border: canvasBorderSchema.optional(),
537
- outline: canvasOutlineSchema.optional(),
538
- radius: canvasCornerRadiusSchema.optional(),
539
- shadows: z.array(canvasShadowSchema).optional(),
540
- filters: z.array(canvasFilterSchema).optional(),
541
- backdropFilters: z.array(canvasFilterSchema).optional()
542
- }).refine((values) => Object.keys(values).length > 0, "appearance values cannot be empty");
1007
+ const canvasAppearanceValuesSchema = canvasAppearanceSchema.partial().refine((values) => Object.keys(values).length > 0, "appearance values cannot be empty");
543
1008
  const CANVAS_APPEARANCE_PROPERTIES = [
544
1009
  "opacity",
545
1010
  "blendMode",
546
1011
  "fills",
547
1012
  "border",
1013
+ "retainedBorder",
548
1014
  "outline",
549
1015
  "radius",
550
1016
  "shadows",
@@ -552,18 +1018,7 @@ const CANVAS_APPEARANCE_PROPERTIES = [
552
1018
  "backdropFilters"
553
1019
  ];
554
1020
  const canvasAppearancePropertySchema = z.enum(CANVAS_APPEARANCE_PROPERTIES);
555
- const canvasAppearancePatchSchema = z.object({
556
- opacity: ratio.optional(),
557
- blendMode: canvasBlendModeSchema.optional(),
558
- fills: z.array(canvasPaintSchema).optional(),
559
- border: canvasBorderSchema.optional(),
560
- outline: canvasOutlineSchema.optional(),
561
- radius: canvasCornerRadiusSchema.optional(),
562
- shadows: z.array(canvasShadowSchema).optional(),
563
- filters: z.array(canvasFilterSchema).optional(),
564
- backdropFilters: z.array(canvasFilterSchema).optional(),
565
- clear: z.array(canvasAppearancePropertySchema).min(1).max(CANVAS_APPEARANCE_PROPERTIES.length).optional()
566
- }).refine((patch) => Object.keys(patch).length > 0, "appearance patch cannot be empty").refine(({ clear, ...values }) => clear === void 0 || clear.every((property) => values[property] === void 0), "appearance patch cannot set and clear the same property");
1021
+ const canvasAppearancePatchSchema = canvasAppearanceSchema.partial().extend({ clear: z.array(canvasAppearancePropertySchema).min(1).max(CANVAS_APPEARANCE_PROPERTIES.length).optional() }).refine((patch) => Object.keys(patch).length > 0, "appearance patch cannot be empty").refine(({ clear, ...values }) => clear === void 0 || clear.every((property) => values[property] === void 0), "appearance patch cannot set and clear the same property");
567
1022
 
568
1023
  //#endregion
569
1024
  //#region ../../packages/contract/src/canvas/canvas-content-styles.schema.ts
@@ -645,6 +1100,7 @@ const canvasTypographySchema = z.object({
645
1100
  "wavy"
646
1101
  ]),
647
1102
  color: canvasColorSchema.optional(),
1103
+ blendMode: canvasBlendModeSchema.optional(),
648
1104
  thickness: z.union([
649
1105
  nonNegativeNumber,
650
1106
  z.object({
@@ -666,11 +1122,8 @@ const canvasTypographySchema = z.object({
666
1122
  stroke: z.object({
667
1123
  width: nonNegativeNumber,
668
1124
  paint: canvasPaintSchema,
669
- alignment: z.enum([
670
- "inside",
671
- "center",
672
- "outside"
673
- ]).optional()
1125
+ /** CSS strokes text on the glyph outline or, painted under the fill, outside it. */
1126
+ alignment: z.enum(["center", "outside"]).optional()
674
1127
  }).optional(),
675
1128
  wrapping: z.enum([
676
1129
  "wrap",
@@ -772,31 +1225,378 @@ const CANVAS_TYPOGRAPHY_CSS_OWNERS = {
772
1225
  "-webkit-text-stroke-width": ["stroke"],
773
1226
  "-webkit-text-stroke-color": ["stroke"],
774
1227
  "--canvas-text-stroke-alignment": ["stroke"],
1228
+ "paint-order": ["stroke"],
775
1229
  "white-space": ["wrapping"],
776
1230
  "text-wrap-style": ["wrapStyle"],
777
1231
  "text-wrap": ["wrapStyle"]
778
1232
  };
779
- const unsafeStyleValue = /javascript|vbscript|data\s*:\s*text\/html|expression\s*\(|@import/iu;
780
1233
  const blockedStyleProperty = /^(?:behavior|-moz-binding)$/iu;
781
1234
  const canvasAdditionalStylePropertySchema = z.string().min(1).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");
782
- const canvasAdditionalStyleValueSchema = z.string().refine((value) => !unsafeStyleValue.test(value), "unsafe CSS value");
783
1235
  const canvasAdditionalStyleSchema = z.object({
784
1236
  id: z.string().min(1),
785
- property: canvasAdditionalStylePropertySchema,
786
- value: canvasAdditionalStyleValueSchema,
787
- enabled: z.boolean()
1237
+ property: canvasAdditionalStylePropertySchema,
1238
+ value: canvasCssValueSchema,
1239
+ enabled: z.boolean()
1240
+ });
1241
+ const canvasAdditionalStylesSchema = z.object({ declarations: z.array(canvasAdditionalStyleSchema) }).refine(({ declarations }) => new Set(declarations.map((declaration) => declaration.id)).size === declarations.length, "additional style ids must be unique");
1242
+
1243
+ //#endregion
1244
+ //#region ../../packages/contract/src/canvas/canvas-additional-style-patch.schema.ts
1245
+ const identifiers = z.array(canvasAdditionalStyleSchema.shape.id).refine((ids) => new Set(ids).size === ids.length, "declaration ids must be unique");
1246
+ const canvasAdditionalStylePatchSchema = z.object({
1247
+ set: z.array(canvasAdditionalStyleSchema).refine((items) => new Set(items.map((item) => item.id)).size === items.length, "declaration ids must be unique").optional(),
1248
+ clear: identifiers.optional(),
1249
+ order: identifiers.optional(),
1250
+ empty: z.enum(["keep", "remove"]).optional()
1251
+ }).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");
1252
+
1253
+ //#endregion
1254
+ //#region ../../packages/contract/src/canvas/canvas-text-links.lib.ts
1255
+ const FORBIDDEN_DOMAIN_CHARACTERS = /* @__PURE__ */ new Set([
1256
+ "#",
1257
+ "%",
1258
+ "/",
1259
+ ":",
1260
+ "<",
1261
+ ">",
1262
+ "?",
1263
+ "@",
1264
+ "[",
1265
+ "\\",
1266
+ "]",
1267
+ "^",
1268
+ "|"
1269
+ ]);
1270
+ const ASCII_SPACE = 32;
1271
+ const ASCII_DELETE = 127;
1272
+ /** Check the decoded host because browser URL parsing can retain host spaces as percent escapes. */
1273
+ const isHttpHostname = (url) => {
1274
+ if (url.hostname.startsWith("[")) return true;
1275
+ const hostname = decodeURIComponent(url.hostname);
1276
+ for (const character of hostname) {
1277
+ const point = character.codePointAt(0) ?? 0;
1278
+ if (point === ASCII_DELETE || point <= ASCII_SPACE || FORBIDDEN_DOMAIN_CHARACTERS.has(character)) return false;
1279
+ }
1280
+ return hostname !== "";
1281
+ };
1282
+ const SAFE_HREF_PROTOCOLS = /* @__PURE__ */ new Set([
1283
+ "http:",
1284
+ "https:",
1285
+ "mailto:",
1286
+ "tel:"
1287
+ ]);
1288
+ const isCanvasRichTextHref = (value) => {
1289
+ const href = value.trim();
1290
+ if (href === "") return false;
1291
+ try {
1292
+ const url = new URL(href, "https://enhance.invalid/");
1293
+ return SAFE_HREF_PROTOCOLS.has(url.protocol) && (!["http:", "https:"].includes(url.protocol) || isHttpHostname(url));
1294
+ } catch {
1295
+ return false;
1296
+ }
1297
+ };
1298
+
1299
+ //#endregion
1300
+ //#region ../../packages/contract/src/canvas/canvas-rich-text.consts.ts
1301
+ const CANVAS_RICH_TEXT_STYLE_PROPERTIES = /* @__PURE__ */ new Set([
1302
+ "alignItems",
1303
+ "backgroundColor",
1304
+ "borderBottom",
1305
+ "borderBottomLeftRadius",
1306
+ "borderBottomRightRadius",
1307
+ "borderLeft",
1308
+ "borderRight",
1309
+ "borderTop",
1310
+ "borderTopLeftRadius",
1311
+ "borderTopRightRadius",
1312
+ "boxShadow",
1313
+ "boxSizing",
1314
+ "color",
1315
+ "columnGap",
1316
+ "display",
1317
+ "flexDirection",
1318
+ "fontFamily",
1319
+ "fontFeatureSettings",
1320
+ "fontOpticalSizing",
1321
+ "fontSize",
1322
+ "fontStretch",
1323
+ "fontStyle",
1324
+ "fontVariant",
1325
+ "fontVariantCaps",
1326
+ "fontVariantLigatures",
1327
+ "fontVariantNumeric",
1328
+ "fontVariantPosition",
1329
+ "fontKerning",
1330
+ "fontVariationSettings",
1331
+ "fontWeight",
1332
+ "justifyContent",
1333
+ "letterSpacing",
1334
+ "lineHeight",
1335
+ "marginBottom",
1336
+ "marginLeft",
1337
+ "marginRight",
1338
+ "marginTop",
1339
+ "opacity",
1340
+ "paddingBottom",
1341
+ "paddingLeft",
1342
+ "paddingRight",
1343
+ "paddingTop",
1344
+ "rowGap",
1345
+ "textDecorationColor",
1346
+ "textDecorationLine",
1347
+ "textDecorationSkipInk",
1348
+ "textDecorationStyle",
1349
+ "textDecorationThickness",
1350
+ "textShadow",
1351
+ "textTransform",
1352
+ "textUnderlineOffset",
1353
+ "verticalAlign",
1354
+ "whiteSpace",
1355
+ "WebkitTextStrokeColor",
1356
+ "WebkitTextStrokeWidth",
1357
+ "--canvas-text-stroke-alignment"
1358
+ ]);
1359
+
1360
+ //#endregion
1361
+ //#region ../../packages/contract/src/canvas/canvas-text-style.schema.ts
1362
+ const MAX_DESCRIPTION$1 = 2e3;
1363
+ const MAX_OVERRIDE_VALUE = 1e3;
1364
+ const canvasTextStyleTypographySchema = canvasTypographySchema.pick({
1365
+ family: true,
1366
+ fallbackFamilies: true,
1367
+ size: true,
1368
+ weight: true,
1369
+ style: true,
1370
+ variations: true,
1371
+ opticalSize: true,
1372
+ features: true,
1373
+ lineHeight: true,
1374
+ letterSpacing: true,
1375
+ transform: true,
1376
+ decoration: true,
1377
+ paragraphSpacing: true,
1378
+ paragraphIndent: true,
1379
+ listSpacing: true,
1380
+ hangingList: true,
1381
+ hangingPunctuation: true,
1382
+ verticalTrim: true,
1383
+ wrapStyle: true
1384
+ }).extend({ decoration: canvasTypographySchema.shape.decoration.omit({ blendMode: true }) }).strict();
1385
+ const CANVAS_TEXT_STYLE_PROPERTIES = canvasTextStyleTypographySchema.keyof().options;
1386
+ const canvasTextStyleSchema = z.object({
1387
+ id: z.string().min(1),
1388
+ name: z.string().trim().min(1),
1389
+ description: z.string().max(MAX_DESCRIPTION$1),
1390
+ sortKey: z.string().min(1).optional(),
1391
+ sourceStyleId: z.string().min(1).optional(),
1392
+ sourceCanvasId: z.uuid().optional(),
1393
+ sourceRevision: z.number().int().positive().optional(),
1394
+ typography: canvasTextStyleTypographySchema.extend({ listStyle: canvasTypographySchema.shape.listStyle }).transform((typography) => {
1395
+ Reflect.deleteProperty(typography, "listStyle");
1396
+ return typography;
1397
+ })
1398
+ }).strict().refine((style) => style.sourceCanvasId === void 0 || style.sourceStyleId !== void 0, {
1399
+ message: "A source canvas belongs to a reference snapshot.",
1400
+ path: ["sourceCanvasId"]
1401
+ }).refine((style) => style.sourceRevision === void 0 || style.sourceCanvasId !== void 0 && style.sourceStyleId !== void 0, {
1402
+ message: "A published revision belongs to a source style and canvas.",
1403
+ path: ["sourceRevision"]
788
1404
  });
789
- const canvasAdditionalStylesSchema = z.object({ declarations: z.array(canvasAdditionalStyleSchema) }).refine(({ declarations }) => new Set(declarations.map((declaration) => declaration.id)).size === declarations.length, "additional style ids must be unique");
1405
+ const canvasTextStyleBindingSchema = z.object({
1406
+ id: canvasTextStyleSchema.shape.id,
1407
+ position: z.enum([
1408
+ "normal",
1409
+ "subscript",
1410
+ "superscript"
1411
+ ]).optional(),
1412
+ overrides: z.partialRecord(z.enum([
1413
+ "fontWeight",
1414
+ "fontStyle",
1415
+ "fontVariationSettings",
1416
+ "fontOpticalSizing",
1417
+ "textDecorationLine",
1418
+ "textDecorationStyle",
1419
+ "textDecorationColor",
1420
+ "textDecorationThickness",
1421
+ "textUnderlineOffset",
1422
+ "textDecorationSkipInk"
1423
+ ]), z.union([z.string().max(MAX_OVERRIDE_VALUE), z.number()])).optional()
1424
+ }).strict();
790
1425
 
791
1426
  //#endregion
792
- //#region ../../packages/contract/src/canvas/canvas-additional-style-patch.schema.ts
793
- const identifiers = z.array(canvasAdditionalStyleSchema.shape.id).refine((ids) => new Set(ids).size === ids.length, "declaration ids must be unique");
794
- const canvasAdditionalStylePatchSchema = z.object({
795
- set: z.array(canvasAdditionalStyleSchema).refine((items) => new Set(items.map((item) => item.id)).size === items.length, "declaration ids must be unique").optional(),
796
- clear: identifiers.optional(),
797
- order: identifiers.optional(),
798
- empty: z.enum(["keep", "remove"]).optional()
799
- }).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");
1427
+ //#region ../../packages/contract/src/canvas/canvas-rich-text.lib.ts
1428
+ const fillsSchema = canvasPaintSchema.array().optional();
1429
+ /** What one rich text run stores besides its text, which the owner list of paint blends reads. */
1430
+ const canvasRichTextRunPaintSchema = z.object({ fills: fillsSchema });
1431
+ const characterFormattingSchema = canvasTextParagraphSchema.pick({
1432
+ paragraphSpacing: true,
1433
+ paragraphIndent: true,
1434
+ listSpacing: true,
1435
+ wrapStyle: true
1436
+ }).extend({
1437
+ hangingPunctuation: canvasTypographySchema.shape.hangingPunctuation,
1438
+ verticalTrim: canvasTypographySchema.shape.verticalTrim,
1439
+ stroke: canvasTypographySchema.shape.stroke.nullable(),
1440
+ decorationBlendMode: canvasTypographySchema.shape.decoration.shape.blendMode,
1441
+ backgroundBlendMode: canvasBlendModeSchema.optional()
1442
+ }).strip();
1443
+ const safeHref = (value) => typeof value === "string" && isCanvasRichTextHref(value) ? value : void 0;
1444
+ const richStylesOf = (value) => {
1445
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
1446
+ const entries = Object.entries(value);
1447
+ if (entries.some(([property, styleValue]) => !CANVAS_RICH_TEXT_STYLE_PROPERTIES.has(property) || typeof styleValue !== "string" && typeof styleValue !== "number")) return null;
1448
+ return Object.fromEntries(entries);
1449
+ };
1450
+ const richMetadataOf = (value) => {
1451
+ const sourcePath = Reflect.get(value, "sourcePath");
1452
+ return {
1453
+ ...Object.fromEntries(Object.entries(value).filter(([key]) => ![
1454
+ "text",
1455
+ "href",
1456
+ "sourcePath",
1457
+ "styles",
1458
+ "fills",
1459
+ "stroke",
1460
+ "decorationBlendMode",
1461
+ "backgroundBlendMode",
1462
+ "paragraph",
1463
+ "paragraphSpacing",
1464
+ "paragraphIndent",
1465
+ "listSpacing",
1466
+ "hangingPunctuation",
1467
+ "verticalTrim",
1468
+ "wrapStyle",
1469
+ "soft",
1470
+ "textStyle"
1471
+ ].includes(key))),
1472
+ ...typeof sourcePath === "string" && { sourcePath }
1473
+ };
1474
+ };
1475
+ const richChildrenOf = (values) => {
1476
+ const result = [];
1477
+ const pending = values.toReversed().map((value) => ({
1478
+ value,
1479
+ target: result
1480
+ }));
1481
+ const ancestors = /* @__PURE__ */ new Set();
1482
+ while (pending.length > 0) {
1483
+ const task = pending.pop();
1484
+ if (task === void 0) continue;
1485
+ if ("done" in task) {
1486
+ ancestors.delete(task.done);
1487
+ continue;
1488
+ }
1489
+ const children = [];
1490
+ const node = richNodeOf(task.value, children);
1491
+ if (node === null) return null;
1492
+ task.target.push(node);
1493
+ if (node.kind !== "span") continue;
1494
+ const value = task.value;
1495
+ if (typeof value !== "object" || value === null || ancestors.has(value)) return null;
1496
+ ancestors.add(value);
1497
+ pending.push({ done: value });
1498
+ const nested = Reflect.get(value, "children");
1499
+ if (!Array.isArray(nested)) return null;
1500
+ const candidates = nested;
1501
+ for (const child of candidates.toReversed()) pending.push({
1502
+ value: child,
1503
+ target: children
1504
+ });
1505
+ }
1506
+ return result;
1507
+ };
1508
+ const richBreakOf = (value) => {
1509
+ const soft = Reflect.get(value, "soft");
1510
+ if (soft !== void 0 && soft !== true) return null;
1511
+ return {
1512
+ ...richMetadataOf(value),
1513
+ kind: "break",
1514
+ ...soft === true && { soft }
1515
+ };
1516
+ };
1517
+ const richNodeOf = (value, children) => {
1518
+ if (typeof value !== "object" || value === null) return null;
1519
+ const kind = Reflect.get(value, "kind");
1520
+ const metadata = richMetadataOf(value);
1521
+ if (kind === "break") return richBreakOf(value);
1522
+ if (kind === "text") {
1523
+ const text = Reflect.get(value, "text");
1524
+ return typeof text === "string" ? {
1525
+ ...metadata,
1526
+ kind,
1527
+ text
1528
+ } : null;
1529
+ }
1530
+ if (kind !== "span") return null;
1531
+ const values = Reflect.get(value, "children");
1532
+ const styles = richStylesOf(Reflect.get(value, "styles"));
1533
+ const fills = fillsSchema.safeParse(Reflect.get(value, "fills"));
1534
+ const paragraph = canvasTextParagraphSchema.optional().safeParse(Reflect.get(value, "paragraph"));
1535
+ const formatting = characterFormattingSchema.safeParse(value);
1536
+ const textStyle = canvasTextStyleBindingSchema.optional().safeParse(Reflect.get(value, "textStyle"));
1537
+ if (styles === null || !fills.success || !paragraph.success || !formatting.success || !textStyle.success || !Array.isArray(values)) return null;
1538
+ const href = safeHref(Reflect.get(value, "href"));
1539
+ return {
1540
+ ...metadata,
1541
+ kind,
1542
+ styles,
1543
+ children,
1544
+ ...textStyle.data !== void 0 && { textStyle: textStyle.data },
1545
+ ...fills.data !== void 0 && { fills: fills.data },
1546
+ ...paragraph.data !== void 0 && { paragraph: paragraph.data },
1547
+ ...Object.fromEntries(Object.entries(formatting.data).filter(([, entry]) => entry !== void 0)),
1548
+ ...href !== void 0 && { href }
1549
+ };
1550
+ };
1551
+ const richTextLeafValue = (node) => node.kind === "text" ? node.text : node.soft === true ? "\u2028" : "\n";
1552
+ const canvasRichTextValueOf = (nodes) => {
1553
+ const pending = nodes.toReversed();
1554
+ const text = [];
1555
+ while (pending.length > 0) {
1556
+ const node = pending.pop();
1557
+ if (node === void 0) break;
1558
+ if (node.kind === "span") for (const child of node.children.toReversed()) pending.push(child);
1559
+ else text.push(richTextLeafValue(node));
1560
+ }
1561
+ return text.join("");
1562
+ };
1563
+ const canvasRichTextOf = (node) => {
1564
+ const props = node.props;
1565
+ if (props === void 0 || !Array.isArray(props["richText"])) return [];
1566
+ const rich = richChildrenOf(props["richText"]);
1567
+ if (rich === null) return [];
1568
+ const text = props["text"];
1569
+ return canvasRichTextValueOf(rich) === text ? rich : [];
1570
+ };
1571
+ const hasCanvasRichTextPaints = (node) => {
1572
+ const pending = [...canvasRichTextOf(node)];
1573
+ while (pending.length > 0) {
1574
+ const run = pending.pop();
1575
+ if (run?.kind !== "span") continue;
1576
+ if (run.fills !== void 0) return true;
1577
+ for (const child of run.children) pending.push(child);
1578
+ }
1579
+ return false;
1580
+ };
1581
+ /** Existing-link edits retain authored formatting, including nested descendants. */
1582
+ const canvasRichTextLinkOf = (runs) => {
1583
+ const destinations = /* @__PURE__ */ new Set();
1584
+ const visit = (nodes, inherited) => {
1585
+ for (const node of nodes) if (node.kind === "span") visit(node.children, node.href ?? inherited);
1586
+ else destinations.add(inherited);
1587
+ };
1588
+ visit(runs);
1589
+ return destinations.size === 1 ? [...destinations][0] ?? null : null;
1590
+ };
1591
+ /**
1592
+ * The style text a run edit clears: the properties it sets, and for a stroke edit the style text
1593
+ * that copies a stroke, since the stroke value owns it.
1594
+ */
1595
+ const canvasRunStylesClearedBy = (command) => [...Object.keys(command.styles), ...command.stroke === void 0 ? [] : [
1596
+ "WebkitTextStrokeWidth",
1597
+ "WebkitTextStrokeColor",
1598
+ "--canvas-text-stroke-alignment"
1599
+ ]];
800
1600
 
801
1601
  //#endregion
802
1602
  //#region ../../packages/contract/src/shared/blob.schema.ts
@@ -1198,98 +1998,51 @@ const canvasAxisStyleProperties = (node, axis, document) => {
1198
1998
  const isVerticalWriting = /^(?:vertical|sideways)-/u.test(canvasWritingModeOf(node, document));
1199
1999
  return [axis === "horizontal" ? "width" : "height", axis === "vertical" === isVerticalWriting ? "inline-size" : "block-size"];
1200
2000
  };
1201
- /** Authored display wins over legacy presets; Grid has no Flex main axis. */
1202
- const canvasLayoutFlowOf = (node) => {
1203
- if (node === void 0) return "freeform";
1204
- const display = canvasAuthoredLayoutValueOf(node, "display");
1205
- if (display !== void 0) {
1206
- if (/^(?:(?:inline|block)\s+|inline-)?grid$/u.test(display)) return "grid";
1207
- if (/^(?:(?:inline|block)\s+|inline-)?flex$/u.test(display)) return "flex";
1208
- return "freeform";
1209
- }
1210
- const container = node.layout?.container;
1211
- if (container === void 0) return "freeform";
1212
- return container.gridColumns !== void 0 || container.gridAutoRepeat !== void 0 ? "grid" : "flex";
1213
- };
1214
- /** Read a Flex main axis in its inherited writing mode without persisting a preset. */
1215
- const canvasLayoutMainAxisOf = (node, document) => {
1216
- if (node === void 0) return void 0;
1217
- if (canvasLayoutFlowOf(node) !== "flex") return void 0;
1218
- const container = node.layout?.container;
1219
- const css = (property) => canvasAuthoredLayoutValueOf(node, property);
1220
- const direction = container?.direction ?? css("flex-direction") ?? "row";
1221
- if (!/^(?:row|column)(?:-reverse)?$/u.test(direction)) return void 0;
1222
- const isVerticalWriting = /^(?:vertical|sideways)-/u.test(canvasWritingModeOf(node, document));
1223
- return direction.startsWith("column") === isVerticalWriting ? "horizontal" : "vertical";
1224
- };
1225
-
1226
- //#endregion
1227
- //#region ../../packages/canvas-format/src/canvas-format.consts.ts
1228
- /** Historical formats stay pinned; an ordinary writer always uses CANVAS_SCENE_VERSION. */
1229
- const LEGACY_CANVAS_FORMATS = {
1230
- unversioned: void 0,
1231
- v1: 1,
1232
- v2: 2,
1233
- v3: 3,
1234
- v4: 4,
1235
- v5: 5,
1236
- v6: 6
1237
- };
1238
- const LEGACY_CANVAS_ADAPTATIONS = {
1239
- [LEGACY_CANVAS_FORMATS.v1]: "layout",
1240
- [LEGACY_CANVAS_FORMATS.v2]: "layout",
1241
- [LEGACY_CANVAS_FORMATS.v3]: "typography",
1242
- [LEGACY_CANVAS_FORMATS.v4]: "typography",
1243
- [LEGACY_CANVAS_FORMATS.v5]: "typography",
1244
- [LEGACY_CANVAS_FORMATS.v6]: "geometry"
1245
- };
1246
-
1247
- //#endregion
1248
- //#region ../../packages/canvas-format/src/canvas-format.lib.ts
1249
- const READABLE_FORMATS = /* @__PURE__ */ new Set([...Object.values(LEGACY_CANVAS_FORMATS), 7]);
1250
- const isReadableCanvasFormat = (version) => READABLE_FORMATS.has(version);
1251
- const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1252
- const legacyLayout = (layout) => {
1253
- if (!isRecord$1(layout)) return layout;
1254
- const next = Object.fromEntries(Object.entries(layout).filter(([key]) => key !== "gridTrack"));
1255
- const container = next["container"];
1256
- if (isRecord$1(container)) next["container"] = Object.fromEntries(Object.entries(container).filter(([key]) => key !== "materialized"));
1257
- for (const axis of ["horizontal", "vertical"]) {
1258
- const intent = next[axis];
1259
- if (isRecord$1(intent) && intent["mode"] === "hug") next[axis] = Object.fromEntries(Object.entries(intent).filter(([key]) => key !== "basis"));
2001
+ /** Authored display wins over legacy presets; Grid has no Flex main axis. */
2002
+ const canvasLayoutFlowOf = (node) => {
2003
+ if (node === void 0) return "freeform";
2004
+ const display = canvasAuthoredLayoutValueOf(node, "display");
2005
+ if (display !== void 0) {
2006
+ if (/^(?:(?:inline|block)\s+|inline-)?grid$/u.test(display)) return "grid";
2007
+ if (/^(?:(?:inline|block)\s+|inline-)?flex$/u.test(display)) return "flex";
2008
+ return "freeform";
1260
2009
  }
1261
- return next;
2010
+ const container = node.layout?.container;
2011
+ if (container === void 0) return "freeform";
2012
+ return container.gridColumns !== void 0 || container.gridAutoRepeat !== void 0 ? "grid" : "flex";
1262
2013
  };
1263
- /** Adapt known formats in memory, retaining malformed content for each boundary's validator. */
1264
- const adaptCanvasDocumentFormat = (document) => {
1265
- const version = document["version"];
1266
- if (!isReadableCanvasFormat(version)) return null;
1267
- if (version === 7 || !isRecord$1(document["nodes"])) return document;
1268
- const adaptation = Object.entries(LEGACY_CANVAS_ADAPTATIONS).find(([format]) => Number(format) === version)?.[1];
1269
- if (adaptation === "geometry") return {
1270
- ...document,
1271
- version: 7
1272
- };
1273
- if (Object.values(document["nodes"]).some((node) => isRecord$1(node) && node["geometry"] !== void 0)) return null;
1274
- if (adaptation === "typography") return {
1275
- ...document,
1276
- version: 7
1277
- };
1278
- return {
1279
- ...document,
1280
- version: 7,
1281
- nodes: Object.fromEntries(Object.entries(document["nodes"]).map(([id, node]) => [id, isRecord$1(node) && node["layout"] !== void 0 ? {
1282
- ...node,
1283
- layout: legacyLayout(node["layout"])
1284
- } : node]))
1285
- };
2014
+ /** Read a Flex main axis in its inherited writing mode without persisting a preset. */
2015
+ const canvasLayoutMainAxisOf = (node, document) => {
2016
+ if (node === void 0) return void 0;
2017
+ if (canvasLayoutFlowOf(node) !== "flex") return void 0;
2018
+ const container = node.layout?.container;
2019
+ const css = (property) => canvasAuthoredLayoutValueOf(node, property);
2020
+ const direction = container?.direction ?? css("flex-direction") ?? "row";
2021
+ if (!/^(?:row|column)(?:-reverse)?$/u.test(direction)) return void 0;
2022
+ const isVerticalWriting = /^(?:vertical|sideways)-/u.test(canvasWritingModeOf(node, document));
2023
+ return direction.startsWith("column") === isVerticalWriting ? "horizontal" : "vertical";
1286
2024
  };
1287
2025
 
2026
+ //#endregion
2027
+ //#region ../../packages/contract/src/canvas/canvas-export-settings.schema.ts
2028
+ const format = z.enum(["png", "jpeg"]);
2029
+ const scale = z.number().positive();
2030
+ const canvasExportSettingsSchema = z.strictObject({
2031
+ format: format.optional(),
2032
+ scale: scale.optional()
2033
+ });
2034
+ const canvasExportSettingsPatchSchema = z.strictObject({
2035
+ format: format.nullable().optional(),
2036
+ scale: scale.nullable().optional()
2037
+ }).refine((patch) => patch.format !== void 0 || patch.scale !== void 0);
2038
+
1288
2039
  //#endregion
1289
2040
  //#region ../../packages/contract/src/canvas/canvas-geometry.schema.ts
1290
2041
  const coordinate = z.number();
1291
2042
  const dimension$1 = coordinate.nonnegative();
1292
- const identity = z.string().min(1).max(200);
2043
+ const MAX_ID_LENGTH = 200;
2044
+ const MIN_POLYGON_POINTS = 3;
2045
+ const identity = z.string().min(1).max(MAX_ID_LENGTH);
1293
2046
  const path = z.string().regex(/^[MmLlHhVvCcSsQqTtAaZzEe\d\s.,+-]*$/u);
1294
2047
  const canvasGeometryBoundsSchema = z.strictObject({
1295
2048
  x: coordinate,
@@ -1306,6 +2059,13 @@ const canvasPathGeometrySchema = z.strictObject({
1306
2059
  height: dimension$1.positive()
1307
2060
  })
1308
2061
  });
2062
+ const canvasPolygonGeometrySchema = z.strictObject({
2063
+ kind: z.literal("polygon"),
2064
+ count: z.number().int().min(MIN_POLYGON_POINTS),
2065
+ innerRatio: z.number().min(0).max(1).optional(),
2066
+ cornerRadius: dimension$1,
2067
+ cornerSmoothing: z.number().min(0).max(1)
2068
+ });
1309
2069
  const canvasBooleanOperationSchema = z.enum([
1310
2070
  "union",
1311
2071
  "subtract",
@@ -1326,16 +2086,24 @@ const canvasBooleanGeometrySchema = z.strictObject({
1326
2086
  });
1327
2087
  const canvasGeometrySchema = z.discriminatedUnion("kind", [
1328
2088
  canvasPathGeometrySchema,
2089
+ canvasPolygonGeometrySchema,
1329
2090
  z.strictObject({
1330
2091
  kind: z.literal("mask"),
1331
- maskId: identity
2092
+ maskId: identity,
2093
+ /** Absent paints as alpha. An outline mask clips to the source's shape only. */
2094
+ mode: z.enum([
2095
+ "alpha",
2096
+ "luminance",
2097
+ "outline"
2098
+ ]).optional()
1332
2099
  }),
1333
2100
  canvasBooleanGeometrySchema
1334
2101
  ]);
1335
2102
 
1336
2103
  //#endregion
1337
2104
  //#region ../../packages/contract/src/canvas/canvas-scene.schema.ts
1338
- const canvasDocumentFormatSchema = z.literal(7, { error: "This editor uses an unsupported document format. Update the editor before changing this canvas." });
2105
+ const CANVAS_COMPOSITING_RETIRED = "Update Enhance: compositing is no longer supported. Use the isolation style or a mask group.";
2106
+ const canvasDocumentFormatSchema = z.literal(13, { error: "This editor uses an unsupported document format. Update the editor before changing this canvas." });
1339
2107
  const canvasPreservedFontAppearanceSchema = z.object({
1340
2108
  signature: z.string().regex(/^[a-f0-9]{16}$/u),
1341
2109
  image: z.string().startsWith("data:image/jpeg;base64,"),
@@ -1361,6 +2129,7 @@ const canvasNodeConstraintsSchema = z.object({
1361
2129
  const canvasNodeLabelOriginSchema = z.enum([
1362
2130
  "source",
1363
2131
  "generated",
2132
+ "content",
1364
2133
  "user"
1365
2134
  ]);
1366
2135
  const canvasSceneNodeSchema = z.looseObject({
@@ -1375,14 +2144,16 @@ const canvasSceneNodeSchema = z.looseObject({
1375
2144
  layout: canvasNodeLayoutSchema.optional(),
1376
2145
  responsive: z.never().optional(),
1377
2146
  appearance: canvasAppearanceValuesSchema.optional(),
2147
+ exportSettings: canvasExportSettingsSchema.optional(),
1378
2148
  typography: canvasAuthoredTypographySchema.optional(),
1379
2149
  additionalStyles: canvasAdditionalStylesSchema.optional(),
1380
2150
  geometry: canvasGeometrySchema.optional(),
2151
+ compositing: z.never({ error: CANVAS_COMPOSITING_RETIRED }).optional(),
1381
2152
  props: z.record(z.string(), z.unknown()).optional(),
1382
2153
  box: canvasSceneBoxSchema.optional()
1383
2154
  });
1384
2155
  const canvasSceneDocumentSchema = z.object({
1385
- version: z.literal(7),
2156
+ version: z.literal(13),
1386
2157
  nodes: z.record(z.string(), canvasSceneNodeSchema),
1387
2158
  relationships: z.record(z.string(), z.object({
1388
2159
  parentId: z.string().min(1),
@@ -1399,7 +2170,7 @@ const canvasReadableSceneDocumentSchema = z.preprocess((value) => {
1399
2170
  return adaptCanvasDocumentFormat(blob);
1400
2171
  }, canvasSceneDocumentSchema);
1401
2172
  const emptyCanvasSceneDocument = () => ({
1402
- version: 7,
2173
+ version: 13,
1403
2174
  nodes: { root: {
1404
2175
  id: "root",
1405
2176
  label: "Canvas",
@@ -1429,8 +2200,37 @@ const canvasConversionIssueSchema = z.object({
1429
2200
  message: z.string().min(1),
1430
2201
  temporaryId: temporaryIdSchema.optional()
1431
2202
  });
2203
+ /** Source features that CSS cannot draw; a conversion writes the closest CSS and counts each. */
2204
+ const CANVAS_UNSUPPORTED_FEATURES = [
2205
+ "text-stroke-inside",
2206
+ "text-stroke-outside-translucent",
2207
+ "text-stroke-paints",
2208
+ "text-inner-shadow",
2209
+ "text-shadow-spread",
2210
+ "text-shadow-blend",
2211
+ "text-background-blur",
2212
+ "progressive-layer-blur",
2213
+ "progressive-background-blur",
2214
+ "blend-plus-darker",
2215
+ "blend-linear-burn",
2216
+ "image-exposure",
2217
+ "image-contrast",
2218
+ "image-saturation",
2219
+ "image-temperature",
2220
+ "image-tint",
2221
+ "image-highlights",
2222
+ "image-shadows",
2223
+ "effect-noise",
2224
+ "effect-texture",
2225
+ "effect-glass"
2226
+ ];
2227
+ const canvasUnsupportedFeatureSchema = z.enum(CANVAS_UNSUPPORTED_FEATURES);
1432
2228
  const canvasConversionReportSchema = z.object({
1433
2229
  nodeCount: z.number().int().positive(),
2230
+ unsupportedFeatures: z.array(z.object({
2231
+ feature: canvasUnsupportedFeatureSchema,
2232
+ count: z.number().int().positive()
2233
+ })).optional(),
1434
2234
  sourceNodeCount: z.number().int().positive().optional(),
1435
2235
  collapsedNodeCount: z.number().int().nonnegative().optional(),
1436
2236
  collapsedWrapperNodeCount: z.number().int().nonnegative().optional(),
@@ -1646,7 +2446,8 @@ const canvasRenderJobBaseSchema = z.object({
1646
2446
  purpose: z.enum([
1647
2447
  "inspection",
1648
2448
  "snapshot",
1649
- "thumbnail"
2449
+ "thumbnail",
2450
+ "export"
1650
2451
  ]),
1651
2452
  phase: canvasRenderPhaseSchema,
1652
2453
  requestedVersion: z.number().int().positive(),
@@ -1701,10 +2502,41 @@ const getCanvasRenderInputSchema = z.object({ jobId: z.uuid() });
1701
2502
  const getCanvasRenderOutputSchema = z.object({ job: canvasRenderJobSchema });
1702
2503
  const cancelCanvasRenderInputSchema = z.object({ jobId: z.uuid() });
1703
2504
  const cancelCanvasRenderOutputSchema = z.object({ job: canvasRenderJobSchema });
2505
+ const canvasRenderSourceSchema = z.discriminatedUnion("status", [z.object({
2506
+ status: z.literal("available"),
2507
+ version: z.number().int().positive(),
2508
+ format: z.literal("enhance-scene-json"),
2509
+ code: z.string(),
2510
+ prototypes: z.array(z.object({
2511
+ nodeId: z.string(),
2512
+ prototypeId: z.uuid(),
2513
+ deploymentId: z.uuid(),
2514
+ capability: z.literal("canvas.read"),
2515
+ canvasPath: z.string(),
2516
+ input: z.object({
2517
+ canvasRef: z.uuid(),
2518
+ view: z.literal("source"),
2519
+ nodeId: z.string()
2520
+ }),
2521
+ guidance: z.string()
2522
+ })),
2523
+ guidance: z.string()
2524
+ }), z.object({
2525
+ status: z.literal("unavailable"),
2526
+ guidance: z.string()
2527
+ })]);
2528
+ /** A person's image export of one layer at the saved revision, drawn by the render worker. */
2529
+ const createCanvasExportInputSchema = z.object({
2530
+ canvasId: z.uuid(),
2531
+ nodeId: z.string().min(1),
2532
+ expectedVersion: z.number().int().positive(),
2533
+ scale: z.number().positive()
2534
+ });
1704
2535
  const downloadCanvasRenderInputSchema = z.object({ jobId: z.uuid() });
1705
2536
  const downloadCanvasRenderOutputSchema = z.object({
1706
2537
  jobId: z.uuid(),
1707
- download: signedDownloadSchema
2538
+ download: signedDownloadSchema,
2539
+ source: canvasRenderSourceSchema.optional()
1708
2540
  });
1709
2541
  const canvasSnapshotRequestSchema = z.strictObject({
1710
2542
  previewJobId: z.uuid(),
@@ -2051,6 +2883,26 @@ const canvasKnownNodeStylePatchSchema = canvasTextStylePatchSchema.extend(canvas
2051
2883
  "flex-grow": layoutStylePatchValue,
2052
2884
  "flex-shrink": layoutStylePatchValue,
2053
2885
  "flex-wrap": layoutStylePatchValue,
2886
+ grid: layoutStylePatchValue,
2887
+ "grid-template": layoutStylePatchValue,
2888
+ "grid-template-columns": layoutStylePatchValue,
2889
+ "grid-template-rows": layoutStylePatchValue,
2890
+ "grid-template-areas": layoutStylePatchValue,
2891
+ "grid-auto-columns": layoutStylePatchValue,
2892
+ "grid-auto-rows": layoutStylePatchValue,
2893
+ "grid-auto-flow": layoutStylePatchValue,
2894
+ "grid-row": layoutStylePatchValue,
2895
+ "grid-column": layoutStylePatchValue,
2896
+ "grid-area": layoutStylePatchValue,
2897
+ "grid-row-start": layoutStylePatchValue,
2898
+ "grid-row-end": layoutStylePatchValue,
2899
+ "grid-column-start": layoutStylePatchValue,
2900
+ "grid-column-end": layoutStylePatchValue,
2901
+ "justify-items": layoutStylePatchValue,
2902
+ "justify-self": layoutStylePatchValue,
2903
+ "place-items": layoutStylePatchValue,
2904
+ "place-self": layoutStylePatchValue,
2905
+ "place-content": layoutStylePatchValue,
2054
2906
  height: layoutStylePatchValue,
2055
2907
  "inline-size": layoutStylePatchValue,
2056
2908
  inset: layoutStylePatchValue,
@@ -2060,6 +2912,7 @@ const canvasKnownNodeStylePatchSchema = canvasTextStylePatchSchema.extend(canvas
2060
2912
  "inset-inline": layoutStylePatchValue,
2061
2913
  "inset-inline-end": layoutStylePatchValue,
2062
2914
  "inset-inline-start": layoutStylePatchValue,
2915
+ isolation: layoutStylePatchValue,
2063
2916
  "justify-content": layoutStylePatchValue,
2064
2917
  left: layoutStylePatchValue,
2065
2918
  margin: layoutStylePatchValue,
@@ -2091,6 +2944,12 @@ const canvasKnownNodeStylePatchSchema = canvasTextStylePatchSchema.extend(canvas
2091
2944
  width: layoutStylePatchValue,
2092
2945
  background: z.string().nullable().optional(),
2093
2946
  "background-color": z.string().nullable().optional(),
2947
+ "background-image": layoutStylePatchValue,
2948
+ "background-size": layoutStylePatchValue,
2949
+ "background-position": layoutStylePatchValue,
2950
+ "background-repeat": layoutStylePatchValue,
2951
+ "background-origin": layoutStylePatchValue,
2952
+ "background-blend-mode": layoutStylePatchValue,
2094
2953
  "box-shadow": z.string().nullable().optional(),
2095
2954
  "column-gap": dimensionalStyleValue.optional(),
2096
2955
  gap: dimensionalStyleValue.optional(),
@@ -2120,7 +2979,8 @@ const canvasTextStepSchema = z.discriminatedUnion("kind", [
2120
2979
  z.object({
2121
2980
  kind: z.literal("retain"),
2122
2981
  count: countSchema$1,
2123
- attributes: attributesSchema.optional()
2982
+ attributes: attributesSchema.optional(),
2983
+ shouldPreserveParagraph: z.boolean().optional()
2124
2984
  }),
2125
2985
  z.object({
2126
2986
  kind: z.literal("delete"),
@@ -2129,7 +2989,8 @@ const canvasTextStepSchema = z.discriminatedUnion("kind", [
2129
2989
  z.object({
2130
2990
  kind: z.literal("insert"),
2131
2991
  text: z.string().min(1).refine((text) => text.isWellFormed()),
2132
- attributes: attributesSchema.optional()
2992
+ attributes: attributesSchema.optional(),
2993
+ shouldPreserveParagraph: z.boolean().optional()
2133
2994
  })
2134
2995
  ]);
2135
2996
  const canvasTextChangeSchema = z.object({
@@ -2182,72 +3043,6 @@ const canvasEditTextOperationSchema = z.object({
2182
3043
  source: canvasTextSourceSchema.optional()
2183
3044
  });
2184
3045
 
2185
- //#endregion
2186
- //#region ../../packages/contract/src/canvas/canvas-text-style.schema.ts
2187
- const MAX_DESCRIPTION$1 = 2e3;
2188
- const MAX_OVERRIDE_VALUE = 1e3;
2189
- const canvasTextStyleTypographySchema = canvasTypographySchema.pick({
2190
- family: true,
2191
- fallbackFamilies: true,
2192
- size: true,
2193
- weight: true,
2194
- style: true,
2195
- variations: true,
2196
- opticalSize: true,
2197
- features: true,
2198
- lineHeight: true,
2199
- letterSpacing: true,
2200
- transform: true,
2201
- decoration: true,
2202
- paragraphSpacing: true,
2203
- paragraphIndent: true,
2204
- listSpacing: true,
2205
- hangingList: true,
2206
- hangingPunctuation: true,
2207
- verticalTrim: true,
2208
- wrapStyle: true
2209
- }).strict();
2210
- const CANVAS_TEXT_STYLE_PROPERTIES = canvasTextStyleTypographySchema.keyof().options;
2211
- const canvasTextStyleSchema = z.object({
2212
- id: z.string().min(1),
2213
- name: z.string().trim().min(1),
2214
- description: z.string().max(MAX_DESCRIPTION$1),
2215
- sortKey: z.string().min(1).optional(),
2216
- sourceStyleId: z.string().min(1).optional(),
2217
- sourceCanvasId: z.uuid().optional(),
2218
- sourceRevision: z.number().int().positive().optional(),
2219
- typography: canvasTextStyleTypographySchema.extend({ listStyle: canvasTypographySchema.shape.listStyle }).transform((typography) => {
2220
- Reflect.deleteProperty(typography, "listStyle");
2221
- return typography;
2222
- })
2223
- }).strict().refine((style) => style.sourceCanvasId === void 0 || style.sourceStyleId !== void 0, {
2224
- message: "A source canvas belongs to a reference snapshot.",
2225
- path: ["sourceCanvasId"]
2226
- }).refine((style) => style.sourceRevision === void 0 || style.sourceCanvasId !== void 0 && style.sourceStyleId !== void 0, {
2227
- message: "A published revision belongs to a source style and canvas.",
2228
- path: ["sourceRevision"]
2229
- });
2230
- const canvasTextStyleBindingSchema = z.object({
2231
- id: canvasTextStyleSchema.shape.id,
2232
- position: z.enum([
2233
- "normal",
2234
- "subscript",
2235
- "superscript"
2236
- ]).optional(),
2237
- overrides: z.partialRecord(z.enum([
2238
- "fontWeight",
2239
- "fontStyle",
2240
- "fontVariationSettings",
2241
- "fontOpticalSizing",
2242
- "textDecorationLine",
2243
- "textDecorationStyle",
2244
- "textDecorationColor",
2245
- "textDecorationThickness",
2246
- "textUnderlineOffset",
2247
- "textDecorationSkipInk"
2248
- ]), z.union([z.string().max(MAX_OVERRIDE_VALUE), z.number()])).optional()
2249
- }).strict();
2250
-
2251
3046
  //#endregion
2252
3047
  //#region ../../packages/contract/src/canvas/text-style-library.schema.ts
2253
3048
  const MAX_DESCRIPTION = 2e3;
@@ -2335,9 +3130,9 @@ const canvasSetStylesOperationSchema = z.object({
2335
3130
  op: z.literal("setStyles"),
2336
3131
  nodeId: nodeIdSchema$3,
2337
3132
  styles: canvasNodeStylePatchSchema,
2338
- clear: z.array(canvasRestorableStylePropertySchema).min(1).max(Object.keys(canvasNodeStylePatchSchema.shape).length).refine((properties) => new Set(properties).size === properties.length).optional()
3133
+ clear: z.array(canvasRestorableStylePropertySchema).min(1).refine((properties) => new Set(properties).size === properties.length).optional()
2339
3134
  }).refine((operation) => (operation.clear ?? []).every((property) => !Object.hasOwn(operation.styles, property)));
2340
- const canvasOperationSchema = z.discriminatedUnion("op", [
3135
+ const currentCanvasOperationSchema = z.discriminatedUnion("op", [
2341
3136
  insertConvertedSubtreeOperationSchema,
2342
3137
  z.object({
2343
3138
  op: z.literal("insertNode"),
@@ -2348,7 +3143,9 @@ const canvasOperationSchema = z.discriminatedUnion("op", [
2348
3143
  nodeId: nodeIdSchema$3,
2349
3144
  documentVersion: z.number().int().nonnegative(),
2350
3145
  versionEntryId: z.uuid().optional()
2351
- }).optional()
3146
+ }).optional(),
3147
+ /** A page copy's base name; the API gives the copy the first free name from it. */
3148
+ pageCopyBase: z.string().refine((base) => base.trim() !== "").optional()
2352
3149
  }),
2353
3150
  placementSchema.extend({
2354
3151
  op: z.literal("insertText"),
@@ -2415,6 +3212,11 @@ const canvasOperationSchema = z.discriminatedUnion("op", [
2415
3212
  constraints: canvasNodeConstraintsSchema.nullable()
2416
3213
  }),
2417
3214
  canvasSetStylesOperationSchema,
3215
+ z.object({
3216
+ op: z.literal("patchExportSettings"),
3217
+ nodeId: nodeIdSchema$3,
3218
+ exportSettings: canvasExportSettingsPatchSchema
3219
+ }),
2418
3220
  z.object({
2419
3221
  op: z.literal("setAppearance"),
2420
3222
  nodeId: nodeIdSchema$3,
@@ -2423,7 +3225,8 @@ const canvasOperationSchema = z.discriminatedUnion("op", [
2423
3225
  z.object({
2424
3226
  op: z.literal("setLayout"),
2425
3227
  nodeId: nodeIdSchema$3,
2426
- layout: z.union([canvasNodeLayoutSchema, z.literal("default")])
3228
+ layout: z.union([canvasNodeLayoutSchema, z.literal("default")]),
3229
+ fields: z.array(canvasNodeLayoutSchema.keyof()).optional()
2427
3230
  }),
2428
3231
  z.object({
2429
3232
  op: z.literal("patchTypography"),
@@ -2445,6 +3248,7 @@ const canvasOperationSchema = z.discriminatedUnion("op", [
2445
3248
  nodeId: nodeIdSchema$3,
2446
3249
  additionalStyles: z.union([canvasAdditionalStylesSchema, z.literal("default")])
2447
3250
  }),
3251
+ setCanvasArtworkColorOperationSchema,
2448
3252
  z.object({
2449
3253
  op: z.literal("setTextStyleLibrary"),
2450
3254
  nodeId: z.literal("root"),
@@ -2488,6 +3292,16 @@ const canvasOperationSchema = z.discriminatedUnion("op", [
2488
3292
  removedText: z.record(nodeIdSchema$3, canvasSceneNodeSchema.pick({ props: true })).optional()
2489
3293
  })
2490
3294
  ]);
3295
+ /** An older client's compositing write is refused with the CSS that replaces it. */
3296
+ const canvasOperationSchema = z.preprocess((value, context) => {
3297
+ if (typeof value !== "object" || value === null || Reflect.get(value, "op") !== "setCompositing") return value;
3298
+ context.issues.push({
3299
+ code: "custom",
3300
+ message: CANVAS_COMPOSITING_RETIRED,
3301
+ input: value
3302
+ });
3303
+ return z.NEVER;
3304
+ }, currentCanvasOperationSchema);
2491
3305
  const createEditableFrameOutputSchema = createEditableFrameResultSchema.extend({
2492
3306
  operation: insertConvertedSubtreeOperationSchema,
2493
3307
  next: z.array(z.string().min(1))
@@ -2503,6 +3317,11 @@ const getCanvasDocumentInputSchema = z.object({
2503
3317
  });
2504
3318
  const documentScreenSchema = z.object({
2505
3319
  screenId: z.uuid(),
3320
+ /**
3321
+ * The change identity the screen was reserved with, or the screen's own identity when it had
3322
+ * none. A capture's layer is named after it.
3323
+ */
3324
+ clientToken: z.uuid(),
2506
3325
  /** Null for a link visitor. Always present on the agent surface. */
2507
3326
  route: z.string().nullable(),
2508
3327
  title: z.string().nullable(),
@@ -2518,7 +3337,7 @@ const documentScreenSchema = z.object({
2518
3337
  sourceUrl: z.string(),
2519
3338
  assets: z.array(z.object({
2520
3339
  url: z.string(),
2521
- contentType: z.string().max(200),
3340
+ contentType: z.string(),
2522
3341
  path: z.string().startsWith("/v1/recording-assets/")
2523
3342
  })),
2524
3343
  missingAssetCount: z.number().int().min(0)
@@ -2533,282 +3352,67 @@ const canvasMutationRevisionSchema = z.object({
2533
3352
  operations: z.array(canvasOperationSchema)
2534
3353
  });
2535
3354
  const getCanvasDocumentOutputSchema = z.object({
2536
- mutations: z.array(canvasMutationRevisionSchema).optional(),
2537
- version: z.number().int().min(1),
2538
- /**
2539
- * The revision the latest restore made, when there has been one. A reader at an older revision
2540
- * has not seen the restore, and the log never reaches back past it.
2541
- */
2542
- restoreFenceVersion: z.number().int().positive().optional(),
2543
- document: canvasDocumentBlobSchema,
2544
- /** The manifest, resolved and signed. This is what makes a cold open one round trip. */
2545
- screens: z.array(documentScreenSchema)
2546
- });
2547
- const saveCanvasDocumentInputSchema = z.object({
2548
- canvasId: z.uuid(),
2549
- baseVersion: z.number().int().min(1),
2550
- document: canvasDocumentBlobSchema.refine((document) => canvasSceneDocumentSchema.safeParse(document).success, "A save requires a valid current-format canvas document."),
2551
- /** Every screen the document names. Replaces the manifest wholesale. */
2552
- screenIds: z.array(z.uuid())
2553
- });
2554
- /**
2555
- * A conflict is an outcome, not an error. `AppError` is `{ code, message, fields? }` and a
2556
- * whole document does not fit in it — and a path that is expected to fire should not go
2557
- * through the error log line and the tRPC error protocol on its way to a merge dialog.
2558
- */
2559
- const saveCanvasDocumentOutputSchema = z.discriminatedUnion("outcome", [z.object({
2560
- outcome: z.literal("saved"),
2561
- version: z.number().int().min(1)
2562
- }), z.object({
2563
- outcome: z.literal("conflict"),
2564
- version: z.number().int().min(1),
2565
- document: canvasDocumentBlobSchema
2566
- })]);
2567
-
2568
- //#endregion
2569
- //#region ../../packages/contract/src/canvas/canvas-font-resources.lib.ts
2570
- const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
2571
- const mapSource = (source, face, map) => {
2572
- if (!isRecord(source) || typeof source["data"] !== "string") return source;
2573
- const data = map(source["data"], face);
2574
- return data === source["data"] ? source : {
2575
- ...source,
2576
- data
2577
- };
2578
- };
2579
- const mapFace = (face, map) => {
2580
- if (!isRecord(face) || !Array.isArray(face["sources"])) return face;
2581
- const held = face["sources"];
2582
- const sources = held.map((source) => mapSource(source, face, map));
2583
- return sources.every((source, index) => source === held[index]) ? face : {
2584
- ...face,
2585
- sources
2586
- };
2587
- };
2588
- const mapCanvasFontSources = (props, map) => {
2589
- if (!Array.isArray(props?.["fontFaces"])) return props;
2590
- const held = props["fontFaces"];
2591
- const fontFaces = held.map((face) => mapFace(face, map));
2592
- return fontFaces.every((face, index) => face === held[index]) ? props : {
2593
- ...props,
2594
- fontFaces
2595
- };
2596
- };
2597
-
2598
- //#endregion
2599
- //#region ../../packages/contract/src/canvas/canvas-rich-text.consts.ts
2600
- const CANVAS_RICH_TEXT_STYLE_PROPERTIES = /* @__PURE__ */ new Set([
2601
- "alignItems",
2602
- "backgroundColor",
2603
- "borderBottom",
2604
- "borderBottomLeftRadius",
2605
- "borderBottomRightRadius",
2606
- "borderLeft",
2607
- "borderRight",
2608
- "borderTop",
2609
- "borderTopLeftRadius",
2610
- "borderTopRightRadius",
2611
- "boxShadow",
2612
- "boxSizing",
2613
- "color",
2614
- "columnGap",
2615
- "display",
2616
- "flexDirection",
2617
- "fontFamily",
2618
- "fontFeatureSettings",
2619
- "fontOpticalSizing",
2620
- "fontSize",
2621
- "fontStretch",
2622
- "fontStyle",
2623
- "fontVariant",
2624
- "fontVariantCaps",
2625
- "fontVariantLigatures",
2626
- "fontVariantNumeric",
2627
- "fontVariantPosition",
2628
- "fontKerning",
2629
- "fontVariationSettings",
2630
- "fontWeight",
2631
- "justifyContent",
2632
- "letterSpacing",
2633
- "lineHeight",
2634
- "marginBottom",
2635
- "marginLeft",
2636
- "marginRight",
2637
- "marginTop",
2638
- "opacity",
2639
- "paddingBottom",
2640
- "paddingLeft",
2641
- "paddingRight",
2642
- "paddingTop",
2643
- "rowGap",
2644
- "textDecorationColor",
2645
- "textDecorationLine",
2646
- "textDecorationSkipInk",
2647
- "textDecorationStyle",
2648
- "textDecorationThickness",
2649
- "textShadow",
2650
- "textTransform",
2651
- "textUnderlineOffset",
2652
- "verticalAlign",
2653
- "whiteSpace",
2654
- "WebkitTextStrokeColor",
2655
- "WebkitTextStrokeWidth",
2656
- "--canvas-text-stroke-alignment"
2657
- ]);
3355
+ mutations: z.array(canvasMutationRevisionSchema).optional(),
3356
+ version: z.number().int().min(1),
3357
+ /**
3358
+ * The revision the latest restore made, when there has been one. A reader at an older revision
3359
+ * has not seen the restore, and the log never reaches back past it.
3360
+ */
3361
+ restoreFenceVersion: z.number().int().positive().optional(),
3362
+ document: canvasDocumentBlobSchema,
3363
+ /** The manifest, resolved and signed. This is what makes a cold open one round trip. */
3364
+ screens: z.array(documentScreenSchema)
3365
+ });
3366
+ const saveCanvasDocumentInputSchema = z.object({
3367
+ canvasId: z.uuid(),
3368
+ baseVersion: z.number().int().min(1),
3369
+ document: canvasDocumentBlobSchema.refine((document) => canvasSceneDocumentSchema.safeParse(document).success, "A save requires a valid current-format canvas document."),
3370
+ /** Every screen the document names. Replaces the manifest wholesale. */
3371
+ screenIds: z.array(z.uuid())
3372
+ });
3373
+ /**
3374
+ * A conflict is an outcome, not an error. `AppError` is `{ code, message, fields? }` and a
3375
+ * whole document does not fit in it — and a path that is expected to fire should not go
3376
+ * through the error log line and the tRPC error protocol on its way to a merge dialog.
3377
+ */
3378
+ const saveCanvasDocumentOutputSchema = z.discriminatedUnion("outcome", [z.object({
3379
+ outcome: z.literal("saved"),
3380
+ version: z.number().int().min(1)
3381
+ }), z.object({
3382
+ outcome: z.literal("conflict"),
3383
+ version: z.number().int().min(1),
3384
+ document: canvasDocumentBlobSchema
3385
+ })]);
2658
3386
 
2659
3387
  //#endregion
2660
- //#region ../../packages/contract/src/canvas/canvas-rich-text.lib.ts
2661
- const fillsSchema = canvasPaintSchema.array().optional();
2662
- const characterFormattingSchema = canvasTextParagraphSchema.pick({
2663
- paragraphSpacing: true,
2664
- paragraphIndent: true,
2665
- listSpacing: true,
2666
- wrapStyle: true
2667
- }).extend({
2668
- hangingPunctuation: canvasTypographySchema.shape.hangingPunctuation,
2669
- verticalTrim: canvasTypographySchema.shape.verticalTrim
2670
- }).strip();
2671
- const SAFE_HREF_PROTOCOLS = /* @__PURE__ */ new Set([
2672
- "http:",
2673
- "https:",
2674
- "mailto:",
2675
- "tel:"
2676
- ]);
2677
- const isCanvasRichTextHref = (value) => {
2678
- const href = value.trim();
2679
- if (href === "") return false;
2680
- try {
2681
- const protocol = new URL(href, "https://enhance.invalid/").protocol;
2682
- return SAFE_HREF_PROTOCOLS.has(protocol);
2683
- } catch {
2684
- return false;
2685
- }
2686
- };
2687
- const safeHref = (value) => typeof value === "string" && isCanvasRichTextHref(value) ? value : void 0;
2688
- const richStylesOf = (value) => {
2689
- if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
2690
- const entries = Object.entries(value);
2691
- if (entries.some(([property, styleValue]) => !CANVAS_RICH_TEXT_STYLE_PROPERTIES.has(property) || typeof styleValue !== "string" && typeof styleValue !== "number")) return null;
2692
- return Object.fromEntries(entries);
2693
- };
2694
- const richMetadataOf = (value) => {
2695
- const sourcePath = Reflect.get(value, "sourcePath");
2696
- return {
2697
- ...Object.fromEntries(Object.entries(value).filter(([key]) => ![
2698
- "text",
2699
- "href",
2700
- "sourcePath",
2701
- "styles",
2702
- "fills",
2703
- "paragraph",
2704
- "paragraphSpacing",
2705
- "paragraphIndent",
2706
- "listSpacing",
2707
- "hangingPunctuation",
2708
- "verticalTrim",
2709
- "wrapStyle",
2710
- "soft",
2711
- "textStyle"
2712
- ].includes(key))),
2713
- ...typeof sourcePath === "string" && { sourcePath }
3388
+ //#region ../../packages/contract/src/canvas/canvas-font-resources.lib.ts
3389
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3390
+ const mapSource = (source, face, map) => {
3391
+ if (!isRecord(source) || typeof source["data"] !== "string") return source;
3392
+ const data = map(source["data"], face);
3393
+ return data === source["data"] ? source : {
3394
+ ...source,
3395
+ data
2714
3396
  };
2715
3397
  };
2716
- const richChildrenOf = (values) => {
2717
- const result = [];
2718
- const pending = values.toReversed().map((value) => ({
2719
- value,
2720
- target: result
2721
- }));
2722
- const ancestors = /* @__PURE__ */ new Set();
2723
- while (pending.length > 0) {
2724
- const task = pending.pop();
2725
- if (task === void 0) continue;
2726
- if ("done" in task) {
2727
- ancestors.delete(task.done);
2728
- continue;
2729
- }
2730
- const children = [];
2731
- const node = richNodeOf(task.value, children);
2732
- if (node === null) return null;
2733
- task.target.push(node);
2734
- if (node.kind !== "span") continue;
2735
- const value = task.value;
2736
- if (typeof value !== "object" || value === null || ancestors.has(value)) return null;
2737
- ancestors.add(value);
2738
- pending.push({ done: value });
2739
- const nested = Reflect.get(value, "children");
2740
- if (!Array.isArray(nested)) return null;
2741
- const candidates = nested;
2742
- for (const child of candidates.toReversed()) pending.push({
2743
- value: child,
2744
- target: children
2745
- });
2746
- }
2747
- return result;
2748
- };
2749
- const richBreakOf = (value) => {
2750
- const soft = Reflect.get(value, "soft");
2751
- if (soft !== void 0 && soft !== true) return null;
2752
- return {
2753
- ...richMetadataOf(value),
2754
- kind: "break",
2755
- ...soft === true && { soft }
3398
+ const mapFace = (face, map) => {
3399
+ if (!isRecord(face) || !Array.isArray(face["sources"])) return face;
3400
+ const held = face["sources"];
3401
+ const sources = held.map((source) => mapSource(source, face, map));
3402
+ return sources.every((source, index) => source === held[index]) ? face : {
3403
+ ...face,
3404
+ sources
2756
3405
  };
2757
3406
  };
2758
- const richNodeOf = (value, children) => {
2759
- if (typeof value !== "object" || value === null) return null;
2760
- const kind = Reflect.get(value, "kind");
2761
- const metadata = richMetadataOf(value);
2762
- if (kind === "break") return richBreakOf(value);
2763
- if (kind === "text") {
2764
- const text = Reflect.get(value, "text");
2765
- return typeof text === "string" ? {
2766
- ...metadata,
2767
- kind,
2768
- text
2769
- } : null;
2770
- }
2771
- if (kind !== "span") return null;
2772
- const values = Reflect.get(value, "children");
2773
- const styles = richStylesOf(Reflect.get(value, "styles"));
2774
- const fills = fillsSchema.safeParse(Reflect.get(value, "fills"));
2775
- const paragraph = canvasTextParagraphSchema.optional().safeParse(Reflect.get(value, "paragraph"));
2776
- const formatting = characterFormattingSchema.safeParse(value);
2777
- const textStyle = canvasTextStyleBindingSchema.optional().safeParse(Reflect.get(value, "textStyle"));
2778
- if (styles === null || !fills.success || !paragraph.success || !formatting.success || !textStyle.success || !Array.isArray(values)) return null;
2779
- const href = safeHref(Reflect.get(value, "href"));
2780
- return {
2781
- ...metadata,
2782
- kind,
2783
- styles,
2784
- children,
2785
- ...textStyle.data !== void 0 && { textStyle: textStyle.data },
2786
- ...fills.data !== void 0 && { fills: fills.data },
2787
- ...paragraph.data !== void 0 && { paragraph: paragraph.data },
2788
- ...Object.fromEntries(Object.entries(formatting.data).filter(([, entry]) => entry !== void 0)),
2789
- ...href !== void 0 && { href }
3407
+ const mapCanvasFontSources = (props, map) => {
3408
+ if (!Array.isArray(props?.["fontFaces"])) return props;
3409
+ const held = props["fontFaces"];
3410
+ const fontFaces = held.map((face) => mapFace(face, map));
3411
+ return fontFaces.every((face, index) => face === held[index]) ? props : {
3412
+ ...props,
3413
+ fontFaces
2790
3414
  };
2791
3415
  };
2792
- const richTextLeafValue = (node) => node.kind === "text" ? node.text : node.soft === true ? "\u2028" : "\n";
2793
- const canvasRichTextValueOf = (nodes) => {
2794
- const pending = nodes.toReversed();
2795
- const text = [];
2796
- while (pending.length > 0) {
2797
- const node = pending.pop();
2798
- if (node === void 0) break;
2799
- if (node.kind === "span") for (const child of node.children.toReversed()) pending.push(child);
2800
- else text.push(richTextLeafValue(node));
2801
- }
2802
- return text.join("");
2803
- };
2804
- const canvasRichTextOf = (node) => {
2805
- const props = node.props;
2806
- if (props === void 0 || !Array.isArray(props["richText"])) return [];
2807
- const rich = richChildrenOf(props["richText"]);
2808
- if (rich === null) return [];
2809
- const text = props["text"];
2810
- return canvasRichTextValueOf(rich) === text ? rich : [];
2811
- };
2812
3416
 
2813
3417
  //#endregion
2814
3418
  //#region ../../packages/contract/src/canvas/canvas-text-content.lib.ts
@@ -2904,6 +3508,7 @@ const inspectCanvasNodeOutputSchema = z.object({
2904
3508
  styles: z.record(z.string(), z.union([z.string(), z.number()])),
2905
3509
  layout: canvasNodeLayoutSchema.optional(),
2906
3510
  appearance: canvasAppearanceValuesSchema.optional(),
3511
+ geometry: canvasGeometrySchema.optional(),
2907
3512
  typography: canvasAuthoredTypographySchema.optional(),
2908
3513
  additionalStyles: canvasAdditionalStylesSchema.optional(),
2909
3514
  props: z.record(z.string(), z.unknown()),
@@ -2942,14 +3547,26 @@ const releasedSpacing = (held, prefix, properties) => {
2942
3547
  for (const side of SIDES) if (properties.has(`${prefix}-${side}`)) Reflect.deleteProperty(next, side);
2943
3548
  return next;
2944
3549
  };
3550
+ const releasedGridPolicy = (held, properties) => {
3551
+ const layout = { ...held };
3552
+ if (properties.has("display") || properties.has("grid-auto-flow")) Reflect.deleteProperty(layout, "gridEmptyPlacement");
3553
+ if (layout.gridAutoTrackPolicy === void 0) return layout;
3554
+ const policy = { ...layout.gridAutoTrackPolicy };
3555
+ for (const axis of ["columns", "rows"]) if (properties.has("display") || properties.has(`grid-auto-${axis}`) || properties.has(`grid-template-${axis}`)) Reflect.deleteProperty(policy, axis);
3556
+ if (Object.keys(policy).length === 0) Reflect.deleteProperty(layout, "gridAutoTrackPolicy");
3557
+ else layout.gridAutoTrackPolicy = policy;
3558
+ return layout;
3559
+ };
2945
3560
  /** A shorthand can release several named controls; a longhand releases only itself. */
2946
- const releasedFields = (held, changed) => {
3561
+ const canvasLayoutReleasedFields = (held, changed) => {
2947
3562
  const properties = new Set([...changed].flatMap((property) => canvasCssPropertyScope(property)));
2948
- const layout = { ...held };
3563
+ const layout = releasedGridPolicy(held, properties);
2949
3564
  for (const [key, property] of CANVAS_LAYOUT_CSS_FIELDS) if (properties.has(property)) Reflect.deleteProperty(layout, key);
2950
3565
  if (layout.margin !== void 0) layout.margin = releasedSpacing(layout.margin, "margin", properties);
2951
3566
  if (layout.container === void 0) return layout;
2952
3567
  const container = { ...layout.container };
3568
+ const crossProperty = container.direction === "column" ? "column-gap" : "row-gap";
3569
+ if (properties.has(crossProperty) || properties.has("display")) Reflect.deleteProperty(container, "crossGapMode");
2953
3570
  if ((properties.has("row-gap") || properties.has("column-gap")) && container.gap !== void 0) {
2954
3571
  container.rowGap ??= container.gap;
2955
3572
  container.columnGap ??= container.gap;
@@ -2977,13 +3594,18 @@ const axisWithoutCssBounds = (intent, properties, changed) => {
2977
3594
  /** Editors hand CSS control back property by property; absent presets stay absent. */
2978
3595
  const canvasLayoutWithoutCssProperties = (held, changed, axes) => {
2979
3596
  const properties = new Set([...changed].flatMap((property) => canvasCssPropertyScope(property)));
2980
- const layout = releasedFields(held, properties);
3597
+ const layout = canvasLayoutReleasedFields(held, properties);
3598
+ if (properties.has("display")) Reflect.deleteProperty(layout, "retainedFlexSpacing");
2981
3599
  if ([
2982
3600
  "overflow",
2983
3601
  "overflow-x",
2984
3602
  "overflow-y"
2985
3603
  ].some((property) => properties.has(property))) Reflect.deleteProperty(layout, "clipContent");
2986
- if (properties.has("position")) Reflect.deleteProperty(layout, "position");
3604
+ if (properties.has("position")) {
3605
+ Reflect.deleteProperty(layout, "position");
3606
+ Reflect.deleteProperty(layout, "retainedIgnore");
3607
+ Reflect.deleteProperty(layout, "gridParticipation");
3608
+ }
2987
3609
  if (properties.has("transform")) for (const key of [
2988
3610
  "rotation",
2989
3611
  "flipHorizontal",
@@ -3092,6 +3714,7 @@ const GROUP_KIND = "group";
3092
3714
  const RECTANGLE_KIND = "rectangle";
3093
3715
  const IMAGE_KIND = "image";
3094
3716
  const SVG_KIND = "svg";
3717
+ const BOOLEAN_KIND = "boolean";
3095
3718
  const RECORDING_KIND = "recording";
3096
3719
  const PROTOTYPE_KIND = "prototype";
3097
3720
  const TEXT_KIND = "text";
@@ -3230,6 +3853,7 @@ const DESCRIPTOR_BY_KIND = Object.fromEntries([
3230
3853
  "position",
3231
3854
  "layout",
3232
3855
  "blending",
3856
+ "filters",
3233
3857
  "additionalStyles",
3234
3858
  "export"
3235
3859
  ]
@@ -3289,6 +3913,25 @@ const DESCRIPTOR_BY_KIND = Object.fromEntries([
3289
3913
  },
3290
3914
  propertySections: SVG_PROPERTY_SECTIONS
3291
3915
  },
3916
+ {
3917
+ objectKind: BOOLEAN_KIND,
3918
+ label: "Boolean",
3919
+ category: "container",
3920
+ capabilities: {
3921
+ canSelect: true,
3922
+ canContainChildren: true,
3923
+ canEditProperties: true,
3924
+ commentAnchor: "node"
3925
+ },
3926
+ capture: { preservesVectorData: true },
3927
+ selectionBehavior: { hitTarget: "frame" },
3928
+ resizeBehavior: {
3929
+ mode: "scale",
3930
+ preservesAspect: false,
3931
+ canLockAspectRatio: true
3932
+ },
3933
+ propertySections: SVG_PROPERTY_SECTIONS
3934
+ },
3292
3935
  {
3293
3936
  objectKind: RECORDING_KIND,
3294
3937
  label: "Recording",
@@ -3576,6 +4219,36 @@ const agentClientMetadata = (value) => {
3576
4219
  return { path: transport.success ? transport.data.path : "direct_cli" };
3577
4220
  };
3578
4221
 
4222
+ //#endregion
4223
+ //#region ../../packages/contract/src/canvas/canvas-realtime-view.schema.ts
4224
+ /** The follow colours: the 500 shade of twelve approved colours, never the focus orange. */
4225
+ const followColourSchema = z.enum([
4226
+ "green",
4227
+ "blue",
4228
+ "indigo",
4229
+ "amber",
4230
+ "lime",
4231
+ "teal",
4232
+ "cyan",
4233
+ "sky",
4234
+ "violet",
4235
+ "purple",
4236
+ "fuchsia",
4237
+ "pink"
4238
+ ]);
4239
+ const canvasViewKeySchema = z.string().regex(/^[0-9a-f]{32}$/);
4240
+ /** The fields the room adds to a room identity for one open view. */
4241
+ const canvasRoomViewSchema = z.object({
4242
+ viewKey: canvasViewKeySchema.optional(),
4243
+ admissionOrder: z.number().int().nonnegative().optional(),
4244
+ followColour: followColourSchema.optional()
4245
+ });
4246
+ /** The page a presence value belongs to (null when not known), and the view it follows. */
4247
+ const canvasPresenceViewSchema = z.object({
4248
+ pageId: z.string().min(1).nullable().optional(),
4249
+ followingViewKey: canvasViewKeySchema.nullable().optional()
4250
+ });
4251
+
3579
4252
  //#endregion
3580
4253
  //#region ../../packages/contract/src/canvas/canvas-realtime.schema.ts
3581
4254
  const CANVAS_REALTIME_PROTOCOL = "enhance3.canvas.v1";
@@ -3586,7 +4259,6 @@ const MAX_CANVAS_PRESENCE_DETAIL_BYTES = 16384;
3586
4259
  const MAX_CANVAS_SELECTION_CHUNK_IDS = 1e3;
3587
4260
  const MAX_CANVAS_SELECTION_CHUNK_BYTES = 49152;
3588
4261
  const MAX_ACTIVITY_TARGETS = 100;
3589
- const MAX_REALTIME_TICKET_LENGTH = 4096;
3590
4262
  const MAX_ERROR_MESSAGE_LENGTH = 200;
3591
4263
  const MAX_CURSOR_CHAT_LENGTH = 140;
3592
4264
  const canvasActorColourSchema = z.enum([
@@ -3599,7 +4271,7 @@ const canvasActorColourSchema = z.enum([
3599
4271
  "red",
3600
4272
  "orange"
3601
4273
  ]);
3602
- const personRoomActorSchema = z.object({
4274
+ const personRoomIdentitySchema = z.object({
3603
4275
  kind: z.literal("person"),
3604
4276
  connectionId: z.uuid(),
3605
4277
  personId: z.uuid(),
@@ -3608,12 +4280,14 @@ const personRoomActorSchema = z.object({
3608
4280
  avatarUrl: z.string().max(MAX_URL_LENGTH).nullable().optional(),
3609
4281
  colour: canvasActorColourSchema
3610
4282
  });
4283
+ const personRoomActorSchema = personRoomIdentitySchema.extend(canvasRoomViewSchema.shape);
3611
4284
  const guestRoomActorSchema = z.object({
3612
4285
  kind: z.literal("guest"),
3613
4286
  connectionId: z.uuid(),
3614
4287
  displayName: z.string().min(1).max(MAX_DISPLAY_NAME_LENGTH),
3615
4288
  initials: z.string().min(1).max(MAX_INITIALS_LENGTH),
3616
- colour: canvasActorColourSchema
4289
+ colour: canvasActorColourSchema,
4290
+ ...canvasRoomViewSchema.shape
3617
4291
  });
3618
4292
  const canvasRoomActorSchema = z.discriminatedUnion("kind", [personRoomActorSchema, guestRoomActorSchema]);
3619
4293
  const agentMutationActorSchema = z.object({
@@ -3625,7 +4299,7 @@ const agentMutationActorSchema = z.object({
3625
4299
  agentAttribution: agentClientPropertiesSchema.optional(),
3626
4300
  colour: canvasActorColourSchema
3627
4301
  });
3628
- const canvasMutationActorSchema = z.discriminatedUnion("kind", [personRoomActorSchema.omit({
4302
+ const canvasMutationActorSchema = z.discriminatedUnion("kind", [personRoomIdentitySchema.omit({
3629
4303
  connectionId: true,
3630
4304
  avatarUrl: true
3631
4305
  }), agentMutationActorSchema]);
@@ -3659,7 +4333,8 @@ const canvasPresencePatchSchema = z.object({
3659
4333
  selectionSummary: selectionSummarySchema.nullable().optional(),
3660
4334
  visibleWorldBox: visibleWorldBoxSchema.optional(),
3661
4335
  gesture: gesturePreviewSchema.nullable().optional(),
3662
- cursorChat: z.string().max(140).nullable().optional()
4336
+ cursorChat: z.string().max(140).nullable().optional(),
4337
+ ...canvasPresenceViewSchema.shape
3663
4338
  }).refine((patch) => Object.keys(patch).length > 0, "presence patch cannot be empty");
3664
4339
  const canvasPresenceSchema = z.object({
3665
4340
  actor: canvasRoomActorSchema,
@@ -3676,6 +4351,8 @@ const canvasPresenceSchema = z.object({
3676
4351
  visibleWorldBox: visibleWorldBoxSchema.nullable(),
3677
4352
  gesture: gesturePreviewSchema.nullable(),
3678
4353
  cursorChat: z.string().max(140).nullable().default(null),
4354
+ ...canvasPresenceViewSchema.shape,
4355
+ followOrder: z.number().int().nonnegative().optional(),
3679
4356
  expiresAt: z.iso.datetime()
3680
4357
  });
3681
4358
  const canvasAgentActivityPhaseSchema = z.enum([
@@ -3694,16 +4371,6 @@ const canvasAgentActivitySchema = z.object({
3694
4371
  bounds: visibleWorldBoxSchema.nullable(),
3695
4372
  expiresAt: z.iso.datetime()
3696
4373
  });
3697
- const canvasRealtimeTicketInputSchema = z.object({
3698
- canvasId: z.uuid(),
3699
- protocols: z.array(z.literal(CANVAS_REALTIME_PROTOCOL)).min(1).max(1)
3700
- });
3701
- const canvasRealtimeTicketOutputSchema = z.object({
3702
- endpoint: z.url(),
3703
- ticket: z.string().min(1).max(MAX_REALTIME_TICKET_LENGTH),
3704
- protocol: z.literal(CANVAS_REALTIME_PROTOCOL),
3705
- expiresAt: z.iso.datetime()
3706
- });
3707
4374
  const beginCanvasActivityInputSchema = z.object({
3708
4375
  canvasId: z.uuid(),
3709
4376
  phase: canvasAgentActivityPhaseSchema,
@@ -3726,11 +4393,27 @@ const serverEnvelopeBase = {
3726
4393
  seq: z.number().int().nonnegative()
3727
4394
  };
3728
4395
  const canvasRealtimeServerEnvelopeSchema = z.discriminatedUnion("type", [
4396
+ z.object({
4397
+ ...serverEnvelopeBase,
4398
+ type: z.literal("access.changed"),
4399
+ payload: z.object({})
4400
+ }),
4401
+ z.object({
4402
+ ...serverEnvelopeBase,
4403
+ type: z.literal("comments.changed"),
4404
+ payload: z.object({ threadId: z.uuid() })
4405
+ }),
4406
+ z.object({
4407
+ ...serverEnvelopeBase,
4408
+ type: z.literal("resources.changed"),
4409
+ payload: z.object({})
4410
+ }),
3729
4411
  z.object({
3730
4412
  ...serverEnvelopeBase,
3731
4413
  type: z.literal("room.snapshot"),
3732
4414
  payload: z.object({
3733
4415
  connectionId: z.uuid(),
4416
+ viewKey: canvasRoomViewSchema.shape.viewKey,
3734
4417
  peers: z.array(canvasPresenceSchema),
3735
4418
  activities: z.array(canvasAgentActivitySchema),
3736
4419
  documentVersion: z.number().int().positive()
@@ -3837,6 +4520,21 @@ const canvasRealtimeClientEnvelopeSchema = z.discriminatedUnion("type", [
3837
4520
  })
3838
4521
  ]).refine((envelope) => envelope.type !== "selection.chunk" || envelope.payload.offset + envelope.payload.nodeIds.length <= envelope.payload.total && new TextEncoder().encode(JSON.stringify(envelope)).byteLength <= 49152);
3839
4522
 
4523
+ //#endregion
4524
+ //#region ../../packages/contract/src/canvas/canvas-realtime-ticket.schema.ts
4525
+ const MAX_REALTIME_TICKET_LENGTH = 4096;
4526
+ const canvasRealtimeTicketInputSchema = z.object({
4527
+ canvasId: z.uuid(),
4528
+ protocols: z.array(z.literal(CANVAS_REALTIME_PROTOCOL)).min(1).max(1),
4529
+ viewId: z.uuid().optional()
4530
+ });
4531
+ const canvasRealtimeTicketOutputSchema = z.object({
4532
+ endpoint: z.url(),
4533
+ ticket: z.string().min(1).max(MAX_REALTIME_TICKET_LENGTH),
4534
+ protocol: z.literal(CANVAS_REALTIME_PROTOCOL),
4535
+ expiresAt: z.iso.datetime()
4536
+ });
4537
+
3840
4538
  //#endregion
3841
4539
  //#region ../../packages/contract/src/canvas/canvas-reference.lib.ts
3842
4540
  const canvasIdSchema = z.uuid();
@@ -4019,7 +4717,8 @@ const exposeCanvasRenderOutputSchema = z.discriminatedUnion("purpose", [
4019
4717
  purpose: z.enum([
4020
4718
  "inspection",
4021
4719
  "snapshot",
4022
- "thumbnail"
4720
+ "thumbnail",
4721
+ "export"
4023
4722
  ]),
4024
4723
  scale: z.number().positive(),
4025
4724
  maxOutputPixels: canvasRenderPixelLimitSchema.optional(),
@@ -4073,7 +4772,8 @@ const claimRenderWorkOutputSchema = z.discriminatedUnion("purpose", [
4073
4772
  purpose: z.enum([
4074
4773
  "inspection",
4075
4774
  "snapshot",
4076
- "thumbnail"
4775
+ "thumbnail",
4776
+ "export"
4077
4777
  ]),
4078
4778
  target: canvasRenderTargetSchema,
4079
4779
  sourceState: canvasRenderSourceStateSchema.optional(),
@@ -4251,6 +4951,7 @@ const canvasCaptureSchema = z.object({
4251
4951
  }),
4252
4952
  atMs: z.number(),
4253
4953
  screenId: z.string().nullable().default(null),
4954
+ sourceNodeId: z.string().optional(),
4254
4955
  provenance: canvasCaptureProvenanceSchema.optional()
4255
4956
  });
4256
4957
  const canvasConversionMetadataSchema = z.object({
@@ -4514,6 +5215,7 @@ const STYLE_PROPERTIES = new Set(CANVAS_TEXT_STYLE_PROPERTIES);
4514
5215
  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())] : []));
4515
5216
  const canvasTextBindingWithFormatting = (binding, styles, shouldOverride = false, options = {}) => {
4516
5217
  if (binding === null || options.paragraphSpacing !== void 0 || options.paragraphIndent !== void 0 || options.listSpacing !== void 0 || options.hangingPunctuation !== void 0 || options.verticalTrim !== void 0 || options.wrapStyle !== void 0) return null;
5218
+ if (Object.keys(styles).every((key) => !STYLE_CSS.has(key)) && (options.position === void 0 || options.position === binding.position)) return binding;
4517
5219
  if (shouldOverride) {
4518
5220
  const parsed = canvasTextStyleBindingSchema.safeParse({
4519
5221
  ...binding,
@@ -4527,14 +5229,24 @@ const canvasTextBindingWithFormatting = (binding, styles, shouldOverride = false
4527
5229
  }
4528
5230
  return Object.keys(styles).some((key) => STYLE_CSS.has(key)) ? null : binding;
4529
5231
  };
4530
- const formatMetadata = (command) => ({
5232
+ const textRunFormattingOf = (command) => ({
4531
5233
  ...command.paragraphSpacing !== void 0 && { paragraphSpacing: command.paragraphSpacing },
4532
5234
  ...command.paragraphIndent !== void 0 && { paragraphIndent: command.paragraphIndent },
4533
5235
  ...command.listSpacing !== void 0 && { listSpacing: command.listSpacing },
4534
5236
  ...command.hangingPunctuation !== void 0 && { hangingPunctuation: command.hangingPunctuation },
4535
5237
  ...command.verticalTrim !== void 0 && { verticalTrim: command.verticalTrim },
4536
- ...command.wrapStyle !== void 0 && { wrapStyle: command.wrapStyle }
4537
- });
5238
+ ...command.wrapStyle !== void 0 && { wrapStyle: command.wrapStyle },
5239
+ ...command.stroke !== void 0 && { stroke: command.stroke },
5240
+ ...command.decorationBlendMode !== void 0 && { decorationBlendMode: command.decorationBlendMode },
5241
+ ...command.backgroundBlendMode !== void 0 && { backgroundBlendMode: command.backgroundBlendMode }
5242
+ });
5243
+ /** A run that loses its address loses the styles the link added with it. */
5244
+ const withoutLink = (span) => {
5245
+ if (span.href !== void 0) {
5246
+ for (const [property, value] of Object.entries(LINK_STYLES)) if (span.styles[property] === value) Reflect.deleteProperty(span.styles, property);
5247
+ }
5248
+ Reflect.deleteProperty(span, "href");
5249
+ };
4538
5250
  const clearedOverrides = (nodes, command) => nodes.flatMap((node) => {
4539
5251
  if (node.kind !== "span") return [node];
4540
5252
  const next = {
@@ -4543,7 +5255,7 @@ const clearedOverrides = (nodes, command) => nodes.flatMap((node) => {
4543
5255
  children: clearedOverrides(node.children, command)
4544
5256
  };
4545
5257
  if (command.type === "format") {
4546
- const metadataKeys = Object.keys(formatMetadata(command));
5258
+ const metadataKeys = Object.keys(textRunFormattingOf(command));
4547
5259
  for (const key of metadataKeys) Reflect.deleteProperty(next, key);
4548
5260
  const binding = canvasTextBindingWithFormatting(next.textStyle ?? null, command.styles, command.shouldOverrideTextStyle, {
4549
5261
  paragraphSpacing: command.paragraphSpacing,
@@ -4560,11 +5272,11 @@ const clearedOverrides = (nodes, command) => nodes.flatMap((node) => {
4560
5272
  Reflect.deleteProperty(next, "textStyle");
4561
5273
  return [next];
4562
5274
  }
4563
- if (command.type === "link") Reflect.deleteProperty(next, "href");
5275
+ if (command.type === "link") withoutLink(next);
4564
5276
  else if (command.type === "paint") {
4565
5277
  Reflect.deleteProperty(next, "fills");
4566
5278
  Reflect.deleteProperty(next.styles, "color");
4567
- } else for (const property of Object.keys(command.styles)) Reflect.deleteProperty(next.styles, property);
5279
+ } else for (const property of canvasRunStylesClearedBy(command)) Reflect.deleteProperty(next.styles, property);
4568
5280
  const metadata = Object.keys(next).filter((key) => ![
4569
5281
  "kind",
4570
5282
  "children",
@@ -4572,16 +5284,16 @@ const clearedOverrides = (nodes, command) => nodes.flatMap((node) => {
4572
5284
  ].includes(key));
4573
5285
  return Object.keys(next.styles).length === 0 && metadata.length === 0 ? next.children : [next];
4574
5286
  });
4575
- /** Decorations paint using their own element's metrics and currentColor, unlike inherited type. */
4576
- const decoratedRuns = (nodes, styles) => nodes.map((node) => {
5287
+ /** Leading and decoration must share the glyph's font; outer spans add a second line-box strut. A link span keeps only its own styles, so removing the link leaves the person's. */
5288
+ const metricRuns = (nodes, styles) => nodes.map((node) => {
4577
5289
  if (node.kind !== "span") return {
4578
5290
  kind: "span",
4579
5291
  styles,
4580
5292
  children: [node]
4581
5293
  };
4582
- return node.children.some((child) => child.kind === "span") ? {
5294
+ return node.href !== void 0 || node.children.some((child) => child.kind === "span") ? {
4583
5295
  ...node,
4584
- children: decoratedRuns(node.children, styles)
5296
+ children: metricRuns(node.children, styles)
4585
5297
  } : {
4586
5298
  ...node,
4587
5299
  styles: {
@@ -4590,7 +5302,19 @@ const decoratedRuns = (nodes, styles) => nodes.map((node) => {
4590
5302
  }
4591
5303
  };
4592
5304
  });
5305
+ const linkedRuns = (nodes, command) => {
5306
+ const existing = canvasRichTextLinkOf(nodes);
5307
+ if (command.href !== null && command.href === existing) return nodes;
5308
+ const children = clearedOverrides(nodes, command);
5309
+ return command.href === null ? children : [{
5310
+ kind: "span",
5311
+ styles: LINK_STYLES,
5312
+ href: command.href,
5313
+ children
5314
+ }];
5315
+ };
4593
5316
  const formattedRuns = (nodes, command) => {
5317
+ if (command.type === "link") return linkedRuns(nodes, command);
4594
5318
  const children = clearedOverrides(nodes, command);
4595
5319
  if (command.type === "text-style") return command.binding === null ? children : [{
4596
5320
  kind: "span",
@@ -4599,12 +5323,12 @@ const formattedRuns = (nodes, command) => {
4599
5323
  children
4600
5324
  }];
4601
5325
  if (command.type === "format") {
4602
- const formatted = command.styles["textDecorationLine"] === void 0 ? [{
5326
+ const formatted = command.styles["textDecorationLine"] === void 0 && command.styles["lineHeight"] === void 0 ? [{
4603
5327
  kind: "span",
4604
5328
  styles: command.styles,
4605
5329
  children
4606
- }] : decoratedRuns(children, command.styles);
4607
- const metadata = formatMetadata(command);
5330
+ }] : metricRuns(children, command.styles);
5331
+ const metadata = textRunFormattingOf(command);
4608
5332
  return Object.keys(metadata).length === 0 ? formatted : [{
4609
5333
  kind: "span",
4610
5334
  styles: {},
@@ -4612,15 +5336,6 @@ const formattedRuns = (nodes, command) => {
4612
5336
  children: formatted
4613
5337
  }];
4614
5338
  }
4615
- if (command.type === "link") {
4616
- if (command.href === null) return children;
4617
- return [{
4618
- kind: "span",
4619
- styles: LINK_STYLES,
4620
- href: command.href,
4621
- children
4622
- }];
4623
- }
4624
5339
  if (command.fills === null) return children;
4625
5340
  return [{
4626
5341
  kind: "span",
@@ -4643,6 +5358,15 @@ const isValidTextRange = (text, range) => {
4643
5358
  const boundaries = boundariesOf(text);
4644
5359
  return range.start <= range.end && boundaries.has(range.start) && boundaries.has(range.end);
4645
5360
  };
5361
+ const isValidTextCharacterRange = (text, range) => {
5362
+ const boundaries = /* @__PURE__ */ new Set([0]);
5363
+ let offset = 0;
5364
+ for (const character of text) {
5365
+ offset += character.length;
5366
+ boundaries.add(offset);
5367
+ }
5368
+ return range.start <= range.end && boundaries.has(range.start) && boundaries.has(range.end);
5369
+ };
4646
5370
  const lengthOf = (node) => node.kind === "text" ? node.text.length : node.kind === "break" ? 1 : canvasRichTextValueOf(node.children).length;
4647
5371
  const sliceRuns = (nodes, start, end) => {
4648
5372
  let position = 0;
@@ -4663,7 +5387,7 @@ const sliceRuns = (nodes, start, end) => {
4663
5387
  }] : [node];
4664
5388
  });
4665
5389
  };
4666
- const metadataOf = (node) => JSON.stringify(Object.fromEntries(Object.entries(node).filter(([key]) => !["children", "text"].includes(key))));
5390
+ const metadataOf = (node) => JSON.stringify(Object.fromEntries(Object.entries(node).filter(([key]) => !["children", "text"].includes(key))), (_key, value) => typeof value === "object" && value !== null && !Array.isArray(value) ? Object.fromEntries(Object.entries(value).toSorted(([a], [b]) => a.localeCompare(b, "en"))) : value);
4667
5391
  const isParagraphEnd = (node) => node.kind === "span" && node.paragraph !== void 0 && canvasRichTextValueOf(node.children).endsWith("\n");
4668
5392
  const joinRuns = (nodes) => {
4669
5393
  const joined = [];
@@ -4697,19 +5421,34 @@ const insertedText = (text, source) => text.split(/([\n\u{2028}])/u).flatMap((pa
4697
5421
  kind: "text",
4698
5422
  text: part
4699
5423
  }]);
4700
- const insertedRuns = (nodes, offset, text, shouldKeepEmpty = false) => {
4701
- if (text === "" && !shouldKeepEmpty) return [];
4702
- let position = 0;
4703
- for (const node of nodes) {
4704
- const length = lengthOf(node);
4705
- if (offset < position + length || node === nodes.at(-1)) return node.kind === "span" ? [{
4706
- ...node,
4707
- children: insertedRuns(node.children, offset - position, text, shouldKeepEmpty)
4708
- }] : insertedText(text, node);
4709
- position += length;
4710
- }
4711
- return insertedText(text);
5424
+ /** Before the caret, or after it at the start of the text and of a paragraph; a selection keeps its first character. */
5425
+ const typedCharacterOf = (text, range) => range.start !== range.end || range.start === 0 || text.charAt(range.start - 1) === "\n" ? range.start : range.start - 1;
5426
+ const withText = (nodes, text) => nodes.flatMap((node) => node.kind === "span" ? [{
5427
+ ...node,
5428
+ children: withText(node.children, text)
5429
+ }] : insertedText(text, node));
5430
+ const lastRunWith = (nodes, text) => {
5431
+ const last = nodes.at(-1);
5432
+ return last?.kind === "span" ? [{
5433
+ ...last,
5434
+ children: lastRunWith(last.children, text)
5435
+ }] : insertedText(text, last);
5436
+ };
5437
+ /**
5438
+ * The one-character runs whose formatting typed text takes. Typing at a link's edge stays
5439
+ * outside the link; empty text and an empty last paragraph have no character, so the last run
5440
+ * stands in.
5441
+ */
5442
+ const canvasTextTypedFormatting = (runs, range) => {
5443
+ const index = typedCharacterOf(canvasRichTextValueOf(runs), range);
5444
+ const character = sliceRuns(runs, index, index + 1);
5445
+ const formatting = character.length > 0 ? character : lastRunWith(runs, " ");
5446
+ return range.start === range.end && canvasRichTextLinkOf(sliceRuns(runs, range.start - 1, range.start)) !== canvasRichTextLinkOf(sliceRuns(runs, range.start, range.start + 1)) ? formattedRuns(formatting, {
5447
+ type: "link",
5448
+ href: null
5449
+ }) : formatting;
4712
5450
  };
5451
+ const insertedRuns = (nodes, range, text, shouldKeepEmpty = false) => text === "" && !shouldKeepEmpty ? [] : withText(canvasTextTypedFormatting(nodes, range), text);
4713
5452
  const canvasTextReplacementRange = (before, text, range) => {
4714
5453
  const replacementEnd = text.length - before.length + (range?.end ?? 0);
4715
5454
  if (range !== void 0 && isValidTextRange(before, range) && isValidTextRange(text, {
@@ -4815,18 +5554,20 @@ const paragraphProps = (node, range, command) => {
4815
5554
  return props;
4816
5555
  };
4817
5556
  const replacementRuns = (runs, range, command) => {
5557
+ if (command.richText !== void 0) {
5558
+ const rich = canvasRichTextOf({ props: {
5559
+ text: command.text,
5560
+ richText: command.richText
5561
+ } });
5562
+ if (rich.length > 0) return rich;
5563
+ }
4818
5564
  const shouldKeepEmpty = range.start === 0 && range.end === canvasRichTextValueOf(runs).length;
4819
- let next = insertedRuns(runs, range.start, command.text, shouldKeepEmpty);
5565
+ let next = insertedRuns(runs, range, command.text, shouldKeepEmpty);
4820
5566
  if (command.text === "") return next;
4821
- if (Object.keys(command.styles ?? {}).length > 0 || command.paragraphSpacing !== void 0 || command.paragraphIndent !== void 0 || command.listSpacing !== void 0 || command.hangingPunctuation !== void 0 || command.wrapStyle !== void 0 || command.verticalTrim !== void 0) next = formattedRuns(next, {
5567
+ if (Object.keys(command.styles ?? {}).length > 0 || Object.keys(textRunFormattingOf(command)).length > 0) next = formattedRuns(next, {
4822
5568
  type: "format",
4823
5569
  styles: command.styles ?? {},
4824
- paragraphSpacing: command.paragraphSpacing,
4825
- paragraphIndent: command.paragraphIndent,
4826
- listSpacing: command.listSpacing,
4827
- hangingPunctuation: command.hangingPunctuation,
4828
- verticalTrim: command.verticalTrim,
4829
- wrapStyle: command.wrapStyle
5570
+ ...textRunFormattingOf(command)
4830
5571
  });
4831
5572
  if (command.fills !== void 0) next = formattedRuns(next, {
4832
5573
  type: "paint",
@@ -4841,7 +5582,7 @@ const replacementRuns = (runs, range, command) => {
4841
5582
  /** Commands write the existing text/run pair atomically and retain unrelated source metadata. */
4842
5583
  const canvasTextPropsWithCommand = (node, range, command) => {
4843
5584
  const text = textOf(node) ?? "";
4844
- if (!isValidTextRange(text, range)) return node.props ?? {};
5585
+ if (!(command.type === "paint" ? isValidTextCharacterRange(text, range) : isValidTextRange(text, range))) return node.props ?? {};
4845
5586
  if (command.type === "paragraph" || command.type === "list-indent") return paragraphProps(node, range, command);
4846
5587
  if (command.type !== "replace" && range.start === range.end && (text !== "" || command.type !== "text-style" && command.type !== "format")) return node.props ?? {};
4847
5588
  if (command.type === "link" && command.href !== null && !isCanvasRichTextHref(command.href)) return node.props ?? {};
@@ -4861,7 +5602,7 @@ const canvasTextPropsWithCommand = (node, range, command) => {
4861
5602
  };
4862
5603
  Reflect.deleteProperty(props, "links");
4863
5604
  Reflect.deleteProperty(props, "richText");
4864
- if (command.type !== "replace" || command.fills !== void 0 || command.textStyle !== void 0 || command.paragraphSpacing !== void 0 || command.paragraphIndent !== void 0 || command.listSpacing !== void 0 || command.hangingPunctuation !== void 0 || command.wrapStyle !== void 0 || command.verticalTrim !== void 0 || Object.keys(command.styles ?? {}).length > 0 || canvasRichTextOf(node).length > 0 || text === "" && Array.isArray(node.props?.["richText"]) && node.props["richText"].length === 0 || textLinksOf(node).length > 0) props["richText"] = next;
5605
+ if (command.type !== "replace" || command.richText !== void 0 || command.fills !== void 0 || command.stroke !== void 0 || command.textStyle !== void 0 || Object.keys(textRunFormattingOf(command)).length > 0 || Object.keys(command.styles ?? {}).length > 0 || canvasRichTextOf(node).length > 0 || text === "" && Array.isArray(node.props?.["richText"]) && node.props["richText"].length === 0 || textLinksOf(node).length > 0) props["richText"] = next;
4865
5606
  return props;
4866
5607
  };
4867
5608
  /** A browser input is one replacement, expanded to whole graphemes before touching runs. */
@@ -4885,6 +5626,7 @@ const orderedJsonValue = (_key, value) => typeof value === "object" && value !==
4885
5626
  const isSame = (left, right) => left === right || JSON.stringify(left, orderedJsonValue) === JSON.stringify(right, orderedJsonValue);
4886
5627
  const canvasTextAttributePatch = (before, after) => Object.fromEntries([.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])].flatMap((key) => isSame(before[key], after[key]) ? [] : [[key, after[key] ?? null]]));
4887
5628
  const chunkText = (node) => node.kind === "text" ? node.text : node.soft === true ? "\u2028" : "\n";
5629
+ const hasMultilineParagraph = (node, ancestors) => node.kind === "text" && /\n[\s\S]/u.test(node.text) && ancestors.some((ancestor) => ancestor["paragraph"] !== void 0);
4888
5630
  const collectChunks = (nodes) => {
4889
5631
  const chunks = [];
4890
5632
  let endAttributes = {};
@@ -4924,10 +5666,12 @@ const collectChunks = (nodes) => {
4924
5666
  ...inherited,
4925
5667
  [TEXT_STRUCTURE]: [...ancestors, metadata]
4926
5668
  };
5669
+ const shouldPreserveParagraph = hasMultilineParagraph(node, ancestors);
4927
5670
  const text = chunkText(node);
4928
5671
  if (text !== "") chunks.push({
4929
5672
  text,
4930
- attributes
5673
+ attributes,
5674
+ ...shouldPreserveParagraph && { shouldPreserveParagraph }
4931
5675
  });
4932
5676
  endAttributes = attributes;
4933
5677
  }
@@ -4943,12 +5687,13 @@ const canvasTextContentOf = (node) => {
4943
5687
  const paragraph = canvasTextParagraphFormattingAt(runs, (textOf(node) ?? "").length);
4944
5688
  return {
4945
5689
  chunks: result.chunks.flatMap((chunk, index, all) => {
5690
+ if (chunk.shouldPreserveParagraph === true) return [chunk];
4946
5691
  const prior = all[index - 1];
4947
- if (prior !== void 0 && isSame(prior.attributes, chunk.attributes)) return [];
5692
+ if (prior !== void 0 && prior.shouldPreserveParagraph === chunk.shouldPreserveParagraph && isSame(prior.attributes, chunk.attributes)) return [];
4948
5693
  let text = chunk.text;
4949
5694
  for (let next = index + 1; next < all.length; next += 1) {
4950
5695
  const following = all[next];
4951
- if (following === void 0 || !isSame(chunk.attributes, following.attributes)) break;
5696
+ if (following === void 0 || following.shouldPreserveParagraph !== chunk.shouldPreserveParagraph || !isSame(chunk.attributes, following.attributes)) break;
4952
5697
  text += following.text;
4953
5698
  }
4954
5699
  return [{
@@ -4980,7 +5725,7 @@ const sliceCanvasTextChunks = (chunks, start, end) => {
4980
5725
 
4981
5726
  //#endregion
4982
5727
  //#region ../../packages/contract/src/canvas/canvas-text-change.lib.ts
4983
- const appendCanvasTextStep = (input, step) => {
5728
+ const appendCanvasTextStep = (input, step, shouldShareParagraph = false) => {
4984
5729
  if ((step.kind === "insert" ? step.text.length : step.count) === 0) return;
4985
5730
  const steps = input;
4986
5731
  const previous = steps.at(-1);
@@ -4991,14 +5736,14 @@ const appendCanvasTextStep = (input, step) => {
4991
5736
  };
4992
5737
  return;
4993
5738
  }
4994
- if (previous?.kind === "retain" && step.kind === "retain" && JSON.stringify(previous.attributes ?? {}) === JSON.stringify(step.attributes ?? {})) {
5739
+ if (previous?.kind === "retain" && step.kind === "retain" && (shouldShareParagraph || step.shouldPreserveParagraph !== true) && previous.shouldPreserveParagraph === step.shouldPreserveParagraph && JSON.stringify(previous.attributes ?? {}) === JSON.stringify(step.attributes ?? {})) {
4995
5740
  steps[steps.length - 1] = {
4996
5741
  ...step,
4997
5742
  count: previous.count + step.count
4998
5743
  };
4999
5744
  return;
5000
5745
  }
5001
- if (previous?.kind === "insert" && step.kind === "insert" && JSON.stringify(previous.attributes ?? {}) === JSON.stringify(step.attributes ?? {})) {
5746
+ if (previous?.kind === "insert" && step.kind === "insert" && (shouldShareParagraph || step.shouldPreserveParagraph !== true) && previous.shouldPreserveParagraph === step.shouldPreserveParagraph && JSON.stringify(previous.attributes ?? {}) === JSON.stringify(step.attributes ?? {})) {
5002
5747
  steps[steps.length - 1] = {
5003
5748
  ...step,
5004
5749
  text: previous.text + step.text
@@ -5016,10 +5761,12 @@ const retainFormatting = (steps, before, after) => {
5016
5761
  const following = sliceCanvasTextChunks(after, offset, offset + chunk.text.length);
5017
5762
  for (const next of following) {
5018
5763
  const attributes = canvasTextAttributePatch(chunk.attributes, next.attributes);
5764
+ const shouldPreserveParagraph = next.shouldPreserveParagraph === true;
5019
5765
  appendCanvasTextStep(steps, {
5020
5766
  kind: "retain",
5021
5767
  count: next.text.length,
5022
- ...Object.keys(attributes).length > 0 && { attributes }
5768
+ ...Object.keys(attributes).length > 0 && { attributes },
5769
+ ...(chunk.shouldPreserveParagraph === true !== shouldPreserveParagraph || shouldPreserveParagraph && Object.hasOwn(attributes, "$structure")) && { shouldPreserveParagraph }
5023
5770
  });
5024
5771
  }
5025
5772
  offset += chunk.text.length;
@@ -5134,6 +5881,7 @@ const canvasVersionEntrySchema = z.object({
5134
5881
  actor: canvasVersionActorSchema,
5135
5882
  sourceVersionEntryId: z.uuid().nullable(),
5136
5883
  expiresAt: z.iso.datetime().nullable(),
5884
+ checkpointAt: z.iso.datetime(),
5137
5885
  createdAt: z.iso.datetime(),
5138
5886
  updatedAt: z.iso.datetime(),
5139
5887
  screenCount: z.number().int().min(0)
@@ -5355,7 +6103,7 @@ const acceptInviteInputSchema = z.object({ token: inviteTokenSchema });
5355
6103
  const previewInviteInputSchema = z.object({ token: inviteTokenSchema });
5356
6104
  const acceptInviteOutputSchema = z.object({
5357
6105
  canvasId: z.uuid(),
5358
- accessLevel: grantableAccessLevelSchema
6106
+ accessLevel: accessLevelSchema
5359
6107
  });
5360
6108
 
5361
6109
  //#endregion
@@ -5378,6 +6126,7 @@ const participantSchema = z.object({
5378
6126
  "in-progress",
5379
6127
  "done"
5380
6128
  ]).nullable(),
6129
+ /** Always `null`: view times stay on their owner's dashboard. Kept because published plugins require it. */
5381
6130
  lastViewedAt: z.iso.datetime().nullable()
5382
6131
  });
5383
6132
  const listParticipantsInputSchema = z.object({ canvasId: z.uuid() });
@@ -5404,7 +6153,7 @@ const setReviewStateInputSchema = z.object({
5404
6153
  ])
5405
6154
  });
5406
6155
  /**
5407
- * @justified docs/comments.md#warning
6156
+ * @justified warning
5408
6157
  * `null` means nothing was recorded, which is the honest answer for a link visitor: review
5409
6158
  * state lives on a membership row and they have none. Echoing the requested state back would
5410
6159
  * read as stored and disagree with the next read.
@@ -5413,13 +6162,14 @@ const setReviewStateOutputSchema = z.object({ reviewState: setReviewStateInputSc
5413
6162
 
5414
6163
  //#endregion
5415
6164
  //#region ../../packages/contract/src/capture/capture.schema.ts
6165
+ /** The longest journey, step, variant or label a capture may carry. */
5416
6166
  const CAPTURE_KEY_LENGTH = 160;
5417
6167
  const CAPTURE_METADATA_LENGTH = 200;
5418
6168
  const CAPTURE_ISSUE_LENGTH = 500;
5419
6169
  const CAPTURE_FAILURE_LENGTH = 1e3;
5420
6170
  const CAPTURE_UPLOAD_BATCH_SIZE = 400;
5421
6171
  const CAPTURE_FORMAT_VERSION = 1;
5422
- const key = z.string().trim().min(1).max(CAPTURE_KEY_LENGTH);
6172
+ const key = z.string().trim().min(1).max(160);
5423
6173
  const digest$1 = z.string().regex(/^[a-f0-9]{64}$/u);
5424
6174
  const dimension = z.number().int().positive();
5425
6175
  const captureKeySchema = z.strictObject({
@@ -5433,6 +6183,30 @@ const captureBlobSchema = z.strictObject({
5433
6183
  bytes: z.number().int().positive(),
5434
6184
  mediaType: z.string().min(1).max(CAPTURE_METADATA_LENGTH)
5435
6185
  });
6186
+ const captureDestinationSchema = z.strictObject({ organisationId: z.uuid().optional() });
6187
+ const captureContextSchema = z.strictObject({
6188
+ key: z.string().min(1),
6189
+ label: z.string().min(1),
6190
+ url: z.url().optional(),
6191
+ sequence: z.number().int().nonnegative(),
6192
+ attempt: z.number().int().nonnegative().default(0)
6193
+ });
6194
+ const captureBaselineSelectionSchema = z.union([z.strictObject({ runId: z.uuid() }), z.strictObject({
6195
+ reference: z.string().min(1),
6196
+ revision: z.string().min(1).optional()
6197
+ })]);
6198
+ const captureReviewMetadataSchema = z.strictObject({
6199
+ destination: captureDestinationSchema,
6200
+ context: captureContextSchema.optional(),
6201
+ revision: z.string().min(1).optional(),
6202
+ baselineRunId: z.uuid().nullable(),
6203
+ compareTo: captureBaselineSelectionSchema.optional()
6204
+ });
6205
+ const captureVerdictSchema = z.enum([
6206
+ "awaiting-review",
6207
+ "approved",
6208
+ "changes-requested"
6209
+ ]);
5436
6210
  const captureArtifactSchema = z.strictObject({
5437
6211
  format: z.literal("enhance-capture"),
5438
6212
  version: z.literal(1),
@@ -5440,6 +6214,7 @@ const captureArtifactSchema = z.strictObject({
5440
6214
  label: key,
5441
6215
  journeyLabel: key,
5442
6216
  order: z.number().int().nonnegative(),
6217
+ page: z.string().min(1).optional(),
5443
6218
  viewport: z.strictObject({
5444
6219
  width: dimension,
5445
6220
  height: dimension,
@@ -5512,7 +6287,8 @@ const captureRunDescriptorSchema = z.strictObject({
5512
6287
  generation: z.number().int().nonnegative(),
5513
6288
  participants: z.array(key).min(1),
5514
6289
  expiresAt: z.iso.datetime(),
5515
- formatVersion: z.literal(1)
6290
+ formatVersion: z.literal(1),
6291
+ review: captureReviewMetadataSchema.optional()
5516
6292
  });
5517
6293
  const captureAttemptSchema = z.strictObject({
5518
6294
  participant: key,
@@ -5526,6 +6302,11 @@ const captureAttemptSchema = z.strictObject({
5526
6302
  "interrupted",
5527
6303
  "timedOut"
5528
6304
  ]),
6305
+ title: z.string().min(1).optional(),
6306
+ location: z.strictObject({
6307
+ file: z.string().min(1),
6308
+ line: z.number().int()
6309
+ }).optional(),
5529
6310
  captures: z.array(captureArtifactSchema)
5530
6311
  });
5531
6312
  const captureManifestSchema = z.strictObject({
@@ -5560,11 +6341,25 @@ const captureReceiptSchema = z.strictObject({
5560
6341
  }))
5561
6342
  });
5562
6343
  const beginCaptureRunInputSchema = z.strictObject({
5563
- canvasId: z.uuid(),
6344
+ canvasId: z.uuid().optional(),
6345
+ destination: captureDestinationSchema.optional(),
6346
+ title: z.string().trim().min(1).optional(),
6347
+ context: captureContextSchema.optional(),
6348
+ revision: z.string().min(1).optional(),
6349
+ compareTo: captureBaselineSelectionSchema.optional(),
5564
6350
  source: key.default("default"),
5565
6351
  runKey: key,
5566
6352
  participants: z.array(key).min(1).default(["local"]),
5567
6353
  formatVersion: z.literal(1).default(1)
6354
+ }).superRefine((input, ctx) => {
6355
+ if (input.canvasId === void 0 === (input.destination === void 0)) ctx.addIssue({
6356
+ code: "custom",
6357
+ message: "Choose either a canvas or a destination for this run."
6358
+ });
6359
+ if (input.canvasId !== void 0 && (input.context !== void 0 || input.compareTo !== void 0)) ctx.addIssue({
6360
+ code: "custom",
6361
+ message: "Run review requires a destination."
6362
+ });
5568
6363
  });
5569
6364
  const beginCaptureRunOutputSchema = z.strictObject({ run: captureRunDescriptorSchema });
5570
6365
  const getCaptureRunInputSchema = z.strictObject({ runId: z.uuid() });
@@ -5580,6 +6375,7 @@ const getCaptureRunOutputSchema = z.strictObject({
5580
6375
  run: captureRunDescriptorSchema,
5581
6376
  state: captureRunStateSchema,
5582
6377
  receipt: captureReceiptSchema.nullable(),
6378
+ verdict: captureVerdictSchema.optional(),
5583
6379
  failure: z.strictObject({
5584
6380
  code: key,
5585
6381
  message: z.string().max(CAPTURE_FAILURE_LENGTH)
@@ -5597,7 +6393,31 @@ const reserveCaptureBlobsOutputSchema = z.strictObject({ uploads: z.array(z.stri
5597
6393
  expiresAt: z.iso.datetime()
5598
6394
  }).nullable()
5599
6395
  })).max(CAPTURE_UPLOAD_BATCH_SIZE) });
5600
- const sealCaptureRunInputSchema = z.strictObject({ manifest: captureManifestSchema });
6396
+
6397
+ //#endregion
6398
+ //#region ../../packages/contract/src/capture/capture-name.lib.ts
6399
+ const CODE_LENGTH = 8;
6400
+ const FNV_OFFSET = 2166136261;
6401
+ const FNV_PRIME = 16777619;
6402
+ const HEX = 16;
6403
+ /** FNV-1a: a short code that is the same for the same text on every run and every platform. */
6404
+ const shortCode = (text) => {
6405
+ let hash = FNV_OFFSET;
6406
+ for (const character of text) {
6407
+ hash ^= character.codePointAt(0) ?? 0;
6408
+ hash = Math.imul(hash, FNV_PRIME) >>> 0;
6409
+ }
6410
+ return hash.toString(HEX).padStart(CODE_LENGTH, "0");
6411
+ };
6412
+ /**
6413
+ * A name within the key limit. A longer one keeps its start and gains a code made from the whole
6414
+ * name, so two long names that share a start stay apart and the same name always shortens the same way.
6415
+ */
6416
+ const fitCaptureName = (name) => {
6417
+ const trimmed = name.trim();
6418
+ if (trimmed.length <= 160) return trimmed;
6419
+ return `${trimmed.slice(0, 160 - CODE_LENGTH - 1).trimEnd()} ${shortCode(trimmed)}`;
6420
+ };
5601
6421
 
5602
6422
  //#endregion
5603
6423
  //#region ../../packages/contract/src/comment/comment.schema.ts
@@ -5734,6 +6554,8 @@ const commentMessageSchema = z.object({
5734
6554
  messageId: z.uuid(),
5735
6555
  seq: z.number().int().min(1),
5736
6556
  body: z.string().min(1),
6557
+ /** A deleted message keeps its place in the sequence, so pages still meet; readers hide it. */
6558
+ isDeleted: z.boolean(),
5737
6559
  author: commentAuthorSchema,
5738
6560
  createdAt: z.iso.datetime(),
5739
6561
  /** A comment that changed after somebody read it should say so. */
@@ -6483,7 +7305,7 @@ const ROOT_FIXTURE_NODE_ID = "root";
6483
7305
  const SORT_KEY_DIGITS = 4;
6484
7306
  const sortKeyAt = (seat) => `a${String(seat).padStart(SORT_KEY_DIGITS, "0")}`;
6485
7307
  const emptyFixtureDocument = () => ({
6486
- version: 7,
7308
+ version: 13,
6487
7309
  nodes: { [ROOT_FIXTURE_NODE_ID]: {
6488
7310
  id: ROOT_FIXTURE_NODE_ID,
6489
7311
  label: "Canvas",
@@ -6529,6 +7351,11 @@ const organisationRoleSchema = z.enum([
6529
7351
  "admin",
6530
7352
  "member"
6531
7353
  ]);
7354
+ const organisationContentAccessSchema = z.enum([
7355
+ "can-view",
7356
+ "can-comment",
7357
+ "can-edit"
7358
+ ]);
6532
7359
  /** One team a person is in, as the switcher lists it. */
6533
7360
  const organisationSchema = z.object({
6534
7361
  id: z.uuid(),
@@ -6561,6 +7388,7 @@ const memberSchema = z.object({
6561
7388
  initials: z.string().max(4),
6562
7389
  avatarUrl: z.string().max(MAX_URL_LENGTH).nullable().optional(),
6563
7390
  email: z.string().max(254).nullable(),
7391
+ contentAccess: organisationContentAccessSchema.default("can-comment"),
6564
7392
  role: organisationRoleSchema
6565
7393
  });
6566
7394
  const listMembersInputSchema = z.object({ organisationId: z.uuid() });
@@ -6568,7 +7396,8 @@ const listMembersOutputSchema = cappedSchema(memberSchema);
6568
7396
  const addMemberInputSchema = z.object({
6569
7397
  organisationId: z.uuid(),
6570
7398
  email: z.email().trim().toLowerCase().max(254),
6571
- role: z.enum(["admin", "member"]).default("member")
7399
+ role: z.enum(["admin", "member"]).default("member"),
7400
+ contentAccess: organisationContentAccessSchema.default("can-comment")
6572
7401
  });
6573
7402
  const addMemberOutputSchema = z.object({ personId: z.uuid() });
6574
7403
  const setMemberRoleInputSchema = z.object({
@@ -6580,6 +7409,15 @@ const setMemberRoleOutputSchema = setMemberRoleInputSchema.pick({
6580
7409
  personId: true,
6581
7410
  role: true
6582
7411
  });
7412
+ const setMemberContentAccessInputSchema = z.object({
7413
+ organisationId: z.uuid(),
7414
+ personId: z.uuid(),
7415
+ contentAccess: organisationContentAccessSchema
7416
+ });
7417
+ const setMemberContentAccessOutputSchema = setMemberContentAccessInputSchema.pick({
7418
+ personId: true,
7419
+ contentAccess: true
7420
+ });
6583
7421
  const removeMemberInputSchema = z.object({
6584
7422
  organisationId: z.uuid(),
6585
7423
  personId: z.uuid()
@@ -6596,6 +7434,7 @@ const transferOrganisationOwnershipOutputSchema = z.object({ ownerPersonId: z.uu
6596
7434
  const teamInviteSchema = z.object({
6597
7435
  inviteId: z.uuid(),
6598
7436
  email: z.string().max(254).pipe(z.email()),
7437
+ contentAccess: organisationContentAccessSchema.default("can-comment"),
6599
7438
  role: z.enum(["admin", "member"]),
6600
7439
  sendCount: z.number().int().min(1),
6601
7440
  lastSentAt: z.iso.datetime(),
@@ -6611,7 +7450,8 @@ const teamInviteSchema = z.object({
6611
7450
  const createTeamInviteInputSchema = z.object({
6612
7451
  organisationId: z.uuid(),
6613
7452
  email: z.string().trim().toLowerCase().max(254).pipe(z.email()),
6614
- role: z.enum(["admin", "member"]).default("member")
7453
+ role: z.enum(["admin", "member"]).default("member"),
7454
+ contentAccess: organisationContentAccessSchema.default("can-comment")
6615
7455
  });
6616
7456
  const createTeamInviteOutputSchema = z.discriminatedUnion("kind", [z.object({
6617
7457
  kind: z.literal("member"),
@@ -6635,6 +7475,7 @@ const teamInvitePreviewSchema = z.object({
6635
7475
  teamName: z.string().min(1).max(120),
6636
7476
  invitedBy: z.string().min(1).max(120),
6637
7477
  email: z.string().max(254).pipe(z.email()),
7478
+ contentAccess: organisationContentAccessSchema.default("can-comment"),
6638
7479
  role: z.enum(["admin", "member"]),
6639
7480
  expiresAt: z.iso.datetime(),
6640
7481
  state: z.enum(["pending", "accepted"]),
@@ -6807,13 +7648,13 @@ const recentRecipientsOutputSchema = searchRecipientsOutputSchema.extend({});
6807
7648
  //#endregion
6808
7649
  //#region ../../packages/contract/src/person/session-handoff.lib.ts
6809
7650
  /**
6810
- * @justified docs/comments.md#intent
7651
+ * @justified intent
6811
7652
  * How the web page keeps an extension's session in step, and why it is not the page bridge.
6812
7653
  *
6813
7654
  * The recorder's bridge is a channel any page shares with a content script, so nothing on it
6814
7655
  * is trusted beyond its shape. This one is the opposite: it carries a credential, it is posted
6815
7656
  * at our own origin, and the only listener is a content script this extension put on our own
6816
- * app. A different trust story wants a different door — see docs/features/auth.md.
7657
+ * app. A different trust story wants a different door.
6817
7658
  */
6818
7659
  const SESSION_HANDOFF = "enhance3:session-handoff";
6819
7660
  const sessionHandoffSchema = z.union([z.object({
@@ -6832,11 +7673,11 @@ const sessionHandoffSchema = z.union([z.object({
6832
7673
  const PROTOTYPE_ARTIFACT_PROTOCOL_VERSION = 1;
6833
7674
  const PROTOTYPE_ARTIFACT_FORMAT = "zip";
6834
7675
  const PROTOTYPE_ARTIFACT_MANIFEST_PATH = "__enhance/manifest.json";
6835
- const SHA256_HEX_LENGTH = 64;
7676
+ const SHA256_HEX_LENGTH$1 = 64;
6836
7677
  const CONTENT_TYPE_LENGTH = 200;
6837
7678
  const LAST_C0_CONTROL = 31;
6838
7679
  const DELETE_CONTROL = 127;
6839
- const sha256Schema = z.string().length(SHA256_HEX_LENGTH).refine((value) => {
7680
+ const sha256Schema = z.string().length(SHA256_HEX_LENGTH$1).refine((value) => {
6840
7681
  for (const character of value) if (!/[\da-f]/u.test(character)) return false;
6841
7682
  return true;
6842
7683
  });
@@ -7207,6 +8048,7 @@ const prototypeBridgeNavigationRequestSchema = z$1.object({
7207
8048
  const prototypeBridgeNavigationStateSchema = z$1.object({
7208
8049
  protocol: z$1.literal(1),
7209
8050
  type: z$1.literal("enhance.prototype.navigation"),
8051
+ path: z$1.optional(z$1.string()),
7210
8052
  canGoBack: z$1.boolean(),
7211
8053
  canGoForward: z$1.boolean(),
7212
8054
  isNavigating: z$1._default(z$1.boolean(), false)
@@ -7243,7 +8085,6 @@ const MAX_DURATION_MS$2 = 6e4;
7243
8085
  const MAX_POINTER_SLOP = 50;
7244
8086
  const MIN_SINGLE_AXIS_RATIO = .25;
7245
8087
  const MAX_AXIS_RATIO = 4;
7246
- const MAX_RETAINED_FRAMES = 10;
7247
8088
  const MAX_REASON_LENGTH = 120;
7248
8089
  const MAX_MOMENTUM_TAIL_SPEED = 1e3;
7249
8090
  const MAX_OPENING_SAMPLE_PX = 16;
@@ -7256,9 +8097,7 @@ const defaults = {
7256
8097
  momentumTailSpeed: 100,
7257
8098
  axisRatio: 1.25,
7258
8099
  openingSamplePx: 4,
7259
- openingWindowMs: 35,
7260
- retainedFrames: 3,
7261
- retentionGraceMs: 6e4
8100
+ openingWindowMs: 35
7262
8101
  };
7263
8102
  /** The shipped input behaviour. The policies are fixed; the protocol carries them so a host and an
7264
8103
  * app built from different releases still agree. */
@@ -7271,9 +8110,7 @@ const prototypeInputSettingsSchema = z$1.object({
7271
8110
  wheelQuietMs: z$1._default(duration, defaults.wheelQuietMs),
7272
8111
  pointerSlopPx: z$1._default(z$1.number().check(z$1.minimum(0), z$1.maximum(MAX_POINTER_SLOP)), defaults.pointerSlopPx),
7273
8112
  singleAxisRatio: z$1._default(z$1.number().check(z$1.minimum(MIN_SINGLE_AXIS_RATIO), z$1.maximum(MAX_AXIS_RATIO)), defaults.singleAxisRatio),
7274
- axisRatio: z$1._default(z$1.number().check(z$1.minimum(1), z$1.maximum(MAX_AXIS_RATIO)), defaults.axisRatio),
7275
- retainedFrames: z$1._default(z$1.int().check(z$1.minimum(0), z$1.maximum(MAX_RETAINED_FRAMES)), defaults.retainedFrames),
7276
- retentionGraceMs: z$1._default(duration, defaults.retentionGraceMs)
8113
+ axisRatio: z$1._default(z$1.number().check(z$1.minimum(1), z$1.maximum(MAX_AXIS_RATIO)), defaults.axisRatio)
7277
8114
  });
7278
8115
  const DEFAULT_PROTOTYPE_INPUT_SETTINGS = prototypeInputSettingsSchema.parse({});
7279
8116
  const message = z$1.object({ inputVersion: z$1.literal(2) });
@@ -7327,6 +8164,10 @@ const prototypeInputPanSchema = z$1.extend(message, {
7327
8164
  "cancel"
7328
8165
  ]),
7329
8166
  pointerId: z$1.int().check(z$1.nonnegative()),
8167
+ clientPoint: z$1.optional(z$1.object({
8168
+ x: z$1.number(),
8169
+ y: z$1.number()
8170
+ })),
7330
8171
  screenX: z$1.number(),
7331
8172
  screenY: z$1.number(),
7332
8173
  anchorX: z$1.number().check(z$1.minimum(0), z$1.maximum(1)),
@@ -7367,12 +8208,21 @@ const prototypeInputReadySchema = z$1.extend(message, {
7367
8208
  type: z$1.literal("enhance.prototype.input-ready"),
7368
8209
  build: z$1.string().check(z$1.maxLength(MAX_REASON_LENGTH))
7369
8210
  });
8211
+ const prototypeInputContextMenuSchema = z$1.extend(message, {
8212
+ type: z$1.literal("enhance.prototype.context-menu"),
8213
+ anchorX: z$1.number().check(z$1.minimum(0), z$1.maximum(1)),
8214
+ anchorY: z$1.number().check(z$1.minimum(0), z$1.maximum(1)),
8215
+ keyboard: z$1.boolean(),
8216
+ ctrlKey: z$1.boolean(),
8217
+ metaKey: z$1.boolean()
8218
+ });
7370
8219
  /** Everything an app posts to its host, parsed once by message type. */
7371
8220
  const prototypeInputMessageSchema = z$1.discriminatedUnion("type", [
7372
8221
  prototypeInputWheelSchema,
7373
8222
  prototypeInputActivitySchema,
7374
8223
  prototypeInputReadySchema,
7375
- prototypeInputPanSchema
8224
+ prototypeInputPanSchema,
8225
+ prototypeInputContextMenuSchema
7376
8226
  ]);
7377
8227
 
7378
8228
  //#endregion
@@ -7398,12 +8248,12 @@ const recordingAssetPath = (assetBundleId, urlHash) => `${RECORDING_ASSET_PATH_P
7398
8248
  //#endregion
7399
8249
  //#region ../../packages/contract/src/recording/popover-state.lib.ts
7400
8250
  /**
7401
- * @justified docs/comments.md#clarification
8251
+ * @justified clarification
7402
8252
  * Added to the serialised copy: native popover state has no corresponding HTML attribute.
7403
8253
  */
7404
8254
  const OPEN_POPOVER_ATTRIBUTE = "data-enhance-popover-open";
7405
8255
  /**
7406
- * @justified docs/comments.md#intent
8256
+ * @justified intent
7407
8257
  * A scriptless captured screen still draws the popover even though it cannot call showPopover.
7408
8258
  */
7409
8259
  const OPEN_POPOVER_RULE = `[${OPEN_POPOVER_ATTRIBUTE}] { display: block !important; }`;
@@ -7424,7 +8274,7 @@ const MAX_SAMPLE_RATE_HZ = 192e3;
7424
8274
  /** How many gaps are worth naming individually before the count is the whole answer. */
7425
8275
  const MAX_REPORTED_MISSING = 64;
7426
8276
  /**
7427
- * @justified docs/comments.md#warning
8277
+ * @justified warning
7428
8278
  * Null is a real outcome here, not a failure.
7429
8279
  *
7430
8280
  * A walkthrough recorded without a microphone — refused, none plugged in, or held by something
@@ -7457,7 +8307,7 @@ const startRecordingOutputSchema = z.object({
7457
8307
  audioUpload: signedUploadSchema.nullable()
7458
8308
  });
7459
8309
  /**
7460
- * @justified docs/comments.md#warning
8310
+ * @justified warning
7461
8311
  * A chunk is a byte range of one stream, not a list of events.
7462
8312
  *
7463
8313
  * The stream is newline-delimited JSON: one event per line. `JSON.stringify` escapes a newline
@@ -7569,7 +8419,7 @@ const recordingSummarySchema = z.object({
7569
8419
  startedAt: z.iso.datetime()
7570
8420
  });
7571
8421
  /**
7572
- * @justified docs/comments.md#intent
8422
+ * @justified intent
7573
8423
  * The files the recorded page loaded, reserved in one call and confirmed in one more.
7574
8424
  *
7575
8425
  * rrweb inlines a page's CSS and leaves fonts and images pointing at the live web, so a replay
@@ -7710,6 +8560,7 @@ const createScreenInputSchema = z.object({
7710
8560
  * same `atMs` after a re-record is a different screen and gets a new token.
7711
8561
  */
7712
8562
  clientToken: z.uuid(),
8563
+ isRecordingMark: z.boolean().default(true),
7713
8564
  provenance: z.object({
7714
8565
  sourceRecordingId: z.uuid(),
7715
8566
  atMs: z.number().int().min(0)
@@ -7793,6 +8644,17 @@ const clientConversionInputSchema = z.object({
7793
8644
  reason: z.enum([
7794
8645
  "none",
7795
8646
  "pending-changes",
8647
+ "editor-busy",
8648
+ "editor-stale",
8649
+ "editor-read-only",
8650
+ "source-missing",
8651
+ "editor-changed",
8652
+ "cancelled",
8653
+ "source-invalid-box",
8654
+ "source-loading",
8655
+ "source-unavailable",
8656
+ "source-unreadable",
8657
+ "source-changed",
7796
8658
  "source-unsettled",
7797
8659
  "captured-fonts-unavailable",
7798
8660
  "conversion-failed"
@@ -7808,6 +8670,12 @@ const MAX_DURATION_MS$1 = 18e5;
7808
8670
  const MAX_COUNT = 1e6;
7809
8671
  const MAX_BYTES = 1073741824;
7810
8672
  const MAX_PROTOTYPE_OPEN_ATTEMPTS = 16;
8673
+ /** How the read of a canvas's unsaved browser copy ended when the canvas opened. */
8674
+ const browserCopyCheckSchema = z.enum([
8675
+ "answered",
8676
+ "skipped",
8677
+ "none"
8678
+ ]);
7811
8679
  const durationSchema$1 = z.number().int().min(0).max(MAX_DURATION_MS$1);
7812
8680
  const countSchema = z.number().int().min(0).max(MAX_COUNT);
7813
8681
  const base$1 = {
@@ -7849,6 +8717,7 @@ const clientPerformanceInputSchema = z.discriminatedUnion("name", [
7849
8717
  "sources",
7850
8718
  "replays"
7851
8719
  ]),
8720
+ browserCopyCheck: browserCopyCheckSchema.optional(),
7852
8721
  durationMs: durationSchema$1,
7853
8722
  shellMs: durationSchema$1,
7854
8723
  projectionMs: durationSchema$1,
@@ -7876,7 +8745,12 @@ const clientPerformanceInputSchema = z.discriminatedUnion("name", [
7876
8745
  "drag",
7877
8746
  "edit"
7878
8747
  ]),
7879
- outcome: z.enum(["smooth", "janky"]),
8748
+ outcome: z.enum([
8749
+ "smooth",
8750
+ "janky",
8751
+ "refused"
8752
+ ]),
8753
+ pendingCandidateCount: countSchema.optional(),
7880
8754
  durationMs: durationSchema$1,
7881
8755
  frameCount: countSchema,
7882
8756
  slowFrameCount: countSchema,
@@ -7980,9 +8854,19 @@ const clientRenderFailureDetailsSchema = z.strictObject({
7980
8854
  "resize-observer-loop",
7981
8855
  "unexpected-error",
7982
8856
  "application-empty",
7983
- "startup-stalled"
8857
+ "startup-stalled",
8858
+ "export-incomplete",
8859
+ "clipboard-unavailable",
8860
+ "clipboard-image-pending",
8861
+ "clipboard-image-unavailable"
8862
+ ]),
8863
+ controlId: z.enum([
8864
+ "canvas-stacking",
8865
+ "canvas-export",
8866
+ "styles-copy",
8867
+ "styles-paste",
8868
+ "unknown"
7984
8869
  ]),
7985
- controlId: z.enum(["canvas-stacking", "unknown"]),
7986
8870
  outcome: z.enum([
7987
8871
  "failed",
7988
8872
  "displayed",
@@ -8013,10 +8897,6 @@ const clientRenderFailureOutputSchema = z.object({ accepted: z.literal(true) });
8013
8897
 
8014
8898
  //#endregion
8015
8899
  //#region ../../packages/contract/src/shared/client-save.schema.ts
8016
- const MAX_REPORTED_CHANGES = 1e3;
8017
- const MAX_REPORTED_ATTEMPTS = 1e3;
8018
- /** A week. */
8019
- const MAX_REPORTED_DURATION_MS = 6048e5;
8020
8900
  /** Why the sync owner could not merge pending text the ordinary way. Never document content. */
8021
8901
  const CLIENT_SAVE_ISSUES = [
8022
8902
  "text-layer-missing",
@@ -8041,7 +8921,8 @@ const CANVAS_SYNC_REPORTS = [
8041
8921
  "replan",
8042
8922
  "deleted-target",
8043
8923
  "whole-value-text",
8044
- "retrying"
8924
+ "retrying",
8925
+ "recovery"
8045
8926
  ];
8046
8927
  const CANVAS_SYNC_DETAILS = [
8047
8928
  ...CLIENT_SAVE_ISSUES,
@@ -8050,8 +8931,38 @@ const CANVAS_SYNC_DETAILS = [
8050
8931
  "repeated-server-error",
8051
8932
  "mutation-id-reused",
8052
8933
  "base-ahead",
8053
- "upload-not-kept"
8934
+ "upload-not-kept",
8935
+ "preview-conflict",
8936
+ "competing-edits",
8937
+ "invalid-reconciliation",
8938
+ "invalid-recovery-plan",
8939
+ "history-restored",
8940
+ "local-changes",
8941
+ "no-edit-access",
8942
+ "saved-canvas-unavailable",
8943
+ "image-unreadable",
8944
+ "storage-refused",
8945
+ "unknown-baseline",
8946
+ "invalid-text-source",
8947
+ "session-expired"
8948
+ ];
8949
+ /** The save status the person sees when a recovery report is sent. */
8950
+ const CANVAS_SYNC_REPORT_STATUSES = [
8951
+ "saved",
8952
+ "saving",
8953
+ "review",
8954
+ "retrying",
8955
+ "upload",
8956
+ "reconnecting",
8957
+ "offline",
8958
+ "not-kept",
8959
+ "view-only",
8960
+ "sign-in",
8961
+ "gone",
8962
+ "restored"
8054
8963
  ];
8964
+ /** Whether a recovery state began in this visit or was reopened from the browser copy. */
8965
+ const CANVAS_SYNC_EPISODES = ["new", "reopened"];
8055
8966
  const clientSaveIncidentInputSchema = z.strictObject({
8056
8967
  canvasId: z.uuid(),
8057
8968
  releaseIdentity: z.string().min(1).max(100),
@@ -8059,9 +8970,12 @@ const clientSaveIncidentInputSchema = z.strictObject({
8059
8970
  detail: z.enum(CANVAS_SYNC_DETAILS).optional(),
8060
8971
  mutationId: z.uuid().optional(),
8061
8972
  version: z.number().int().nonnegative(),
8062
- attempts: z.number().int().min(0).max(MAX_REPORTED_ATTEMPTS),
8063
- durationMs: z.number().int().min(0).max(MAX_REPORTED_DURATION_MS),
8064
- pendingChanges: z.number().int().min(0).max(MAX_REPORTED_CHANGES)
8973
+ attempts: z.number().int().nonnegative(),
8974
+ durationMs: z.number().int().nonnegative(),
8975
+ pendingChanges: z.number().int().nonnegative(),
8976
+ reason: z.enum(CANVAS_SYNC_DETAILS).optional(),
8977
+ status: z.enum(CANVAS_SYNC_REPORT_STATUSES).optional(),
8978
+ episode: z.enum(CANVAS_SYNC_EPISODES).optional()
8065
8979
  });
8066
8980
  const clientSaveIncidentOutputSchema = z.object({ accepted: z.literal(true) });
8067
8981
 
@@ -8448,6 +9362,106 @@ var PartialBatchError = class extends CliError {
8448
9362
  }
8449
9363
  };
8450
9364
 
9365
+ //#endregion
9366
+ //#region ../../packages/contract/src/capture/capture-comparison.schema.ts
9367
+ const COMMIT_LENGTH = 200;
9368
+ const captureComparisonInputSchema = z.strictObject({
9369
+ canvasId: z.uuid(),
9370
+ frameId: z.string().min(1),
9371
+ captureId: z.uuid()
9372
+ });
9373
+ const preview$1 = z.strictObject({
9374
+ captureId: z.uuid(),
9375
+ capturedAt: z.iso.datetime(),
9376
+ commit: z.string().max(COMMIT_LENGTH).optional(),
9377
+ url: z.string().min(1),
9378
+ width: z.number().positive(),
9379
+ height: z.number().positive(),
9380
+ pixelRatio: z.number().positive()
9381
+ });
9382
+ const captureComparisonSchema = z.strictObject({
9383
+ frameId: z.string(),
9384
+ before: preview$1,
9385
+ after: preview$1
9386
+ });
9387
+
9388
+ //#endregion
9389
+ //#region ../../packages/contract/src/capture/capture-manifest-input.lib.ts
9390
+ const NAMED_KEY_FIELDS = [
9391
+ "journey",
9392
+ "step",
9393
+ "variant"
9394
+ ];
9395
+ const NAMED_FIELDS = ["label", "journeyLabel"];
9396
+ const fitted = (value) => typeof value === "string" ? fitCaptureName(value) : value;
9397
+ /** A capture whose names a test author wrote too long is shortened, never refused. */
9398
+ const fitCaptureNames = (raw) => {
9399
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return raw;
9400
+ const capture = { ...raw };
9401
+ for (const field of NAMED_FIELDS) capture[field] = fitted(capture[field]);
9402
+ const captureKey = capture["key"];
9403
+ if (typeof captureKey === "object" && captureKey !== null && !Array.isArray(captureKey)) {
9404
+ const named = { ...captureKey };
9405
+ for (const field of NAMED_KEY_FIELDS) named[field] = fitted(named[field]);
9406
+ capture["key"] = named;
9407
+ }
9408
+ return capture;
9409
+ };
9410
+ /**
9411
+ * A manifest checked in outline, then capture by capture: one capture that fails its own checks
9412
+ * is left out, and the rest of the run still publishes.
9413
+ */
9414
+ const lenientCaptureManifestSchema = captureManifestSchema.extend({ attempts: z.array(captureAttemptSchema.extend({ captures: z.array(z.unknown()) })) }).transform((manifest) => ({
9415
+ ...manifest,
9416
+ attempts: manifest.attempts.map((attempt) => ({
9417
+ ...attempt,
9418
+ captures: attempt.captures.flatMap((capture) => {
9419
+ const parsed = captureArtifactSchema.safeParse(fitCaptureNames(capture));
9420
+ return parsed.success ? [parsed.data] : [];
9421
+ })
9422
+ }))
9423
+ }));
9424
+ const sealCaptureRunInputSchema = z.strictObject({ manifest: lenientCaptureManifestSchema });
9425
+
9426
+ //#endregion
9427
+ //#region ../../packages/contract/src/capture/capture-review.schema.ts
9428
+ const captureReviewInputSchema = z.strictObject({ canvasId: z.uuid() });
9429
+ const setCaptureVerdictInputSchema = captureReviewInputSchema.extend({ verdict: captureVerdictSchema });
9430
+ const captureReferenceInputSchema = z.strictObject({
9431
+ canvasId: z.uuid(),
9432
+ name: z.string().min(1)
9433
+ });
9434
+ const captureReferenceSchema = z.strictObject({
9435
+ runId: z.uuid(),
9436
+ revision: z.string(),
9437
+ version: z.number().int().positive()
9438
+ });
9439
+ const updateCaptureReferenceInputSchema = captureReferenceInputSchema.extend({
9440
+ expectedVersion: z.number().int().nonnegative(),
9441
+ revision: z.string().min(1)
9442
+ });
9443
+ const captureReviewSchema = z.strictObject({
9444
+ current: getCaptureRunOutputSchema,
9445
+ latest: captureRunDescriptorSchema,
9446
+ related: z.array(z.strictObject({
9447
+ run: captureRunDescriptorSchema,
9448
+ verdict: captureVerdictSchema
9449
+ })),
9450
+ changes: z.array(z.strictObject({
9451
+ key: captureKeySchema,
9452
+ frameId: z.string(),
9453
+ label: z.string(),
9454
+ journeyLabel: z.string(),
9455
+ page: z.string().optional(),
9456
+ change: z.enum([
9457
+ "new",
9458
+ "changed",
9459
+ "unchanged",
9460
+ "uncompared"
9461
+ ])
9462
+ }))
9463
+ });
9464
+
8451
9465
  //#endregion
8452
9466
  //#region src/application/canvas-reference.use-case.ts
8453
9467
  const hasCanvasReferenceScope = (reference) => reference.pageId !== void 0 || reference.nodeIds.length > 0;
@@ -8863,11 +9877,12 @@ const canvasEditableReadOutputSchema = z.strictObject({
8863
9877
  ...readResult,
8864
9878
  view: z.literal("editable"),
8865
9879
  complete: z.literal(true),
8866
- projectionVersion: z.literal(1),
9880
+ projectionVersion: z.literal(2),
8867
9881
  snapshotToken: cursor,
8868
9882
  rootNodeId: nodeId$1,
8869
9883
  html: z.string(),
8870
- opaqueNodeIds: z.array(nodeId$1)
9884
+ opaqueNodeIds: z.array(nodeId$1),
9885
+ sealedReasons: z.record(nodeId$1, z.string())
8871
9886
  });
8872
9887
  const canvasOutlineReadOutputSchema = z.strictObject({
8873
9888
  ...readResult,
@@ -8922,6 +9937,7 @@ const canvasRemoveCapabilityInputSchema = canvasRemoveInputSchema.omit({ clientT
8922
9937
  //#endregion
8923
9938
  //#region src/application/canvas-render-file.schema.ts
8924
9939
  const canvasRenderFileSchema = z.object({
9940
+ source: canvasRenderSourceSchema.optional(),
8925
9941
  jobId: z.uuid(),
8926
9942
  operation: z.object({
8927
9943
  kind: z.literal("canvas-render"),
@@ -9652,6 +10668,7 @@ const operationStatusOutputSchema = z.union([
9652
10668
  ...page,
9653
10669
  entries: z.array(renderStatusEntrySchema).max(MAX_STATUS_ENTRIES)
9654
10670
  }),
10671
+ source: canvasRenderSourceSchema.optional(),
9655
10672
  pixelsDelivered: z.boolean(),
9656
10673
  imageContentIndex: z.number().int().nonnegative().optional(),
9657
10674
  warnings: z.array(z.string())
@@ -10239,6 +11256,7 @@ const CANVAS_PROTOTYPE_CAPABILITY_SPECS = [{
10239
11256
  //#endregion
10240
11257
  //#region src/infrastructure/capability-example.mapper.ts
10241
11258
  const jsonRecordSchema$2 = z.record(z.string(), z.unknown());
11259
+ const SHA256_HEX_LENGTH = 64;
10242
11260
  const recordFrom$3 = (value) => {
10243
11261
  const parsed = jsonRecordSchema$2.safeParse(value);
10244
11262
  return parsed.success ? parsed.data : null;
@@ -10248,7 +11266,9 @@ const stringExample = (schema) => {
10248
11266
  if (schema["format"] === "email") return "agent@example.test";
10249
11267
  if (schema["format"] === "date-time") return "2026-08-10T00:00:00.000Z";
10250
11268
  if (schema["format"] === "uri" || schema["format"] === "url") return "https://example.test/path";
10251
- if ((typeof schema["pattern"] === "string" ? schema["pattern"] : "").includes("development")) return "development";
11269
+ const pattern = typeof schema["pattern"] === "string" ? schema["pattern"] : "";
11270
+ if (pattern === "^[a-f0-9]{64}$") return "a".repeat(SHA256_HEX_LENGTH);
11271
+ if (pattern.includes("development")) return "development";
10252
11272
  const minimum = typeof schema["minLength"] === "number" ? schema["minLength"] : 1;
10253
11273
  return "x".repeat(Math.max(1, minimum));
10254
11274
  };
@@ -10312,6 +11332,7 @@ const CANVAS_VERSION_OPTION_DESCRIPTIONS = {
10312
11332
  //#endregion
10313
11333
  //#region src/infrastructure/procedure-descriptions.consts.ts
10314
11334
  const PROCEDURE_DESCRIPTIONS = {
11335
+ "captureRun.review": "Read a captured run’s baseline, changed screens, whole-canvas verdict, and related runs.",
10315
11336
  ...CANVAS_VERSION_PROCEDURE_DESCRIPTIONS,
10316
11337
  "canvas.createEditableFrame": "Insert one validated primitive subtree beside its source screen as an atomic canvas edit.",
10317
11338
  "canvas.create": "Create a canvas and return the id required by canvas-scoped commands.",
@@ -10327,7 +11348,6 @@ const PROCEDURE_DESCRIPTIONS = {
10327
11348
  "canvas.duplicate": "Copy a canvas and its document into the selected shelf.",
10328
11349
  "canvas.deletePermanently": "Permanently delete a canvas already in the recoverable bin.",
10329
11350
  "canvas.restore": "Restore a canvas from the recoverable bin.",
10330
- "canvas.markViewed": "Record that the authenticated person has viewed a canvas.",
10331
11351
  "canvas.list": "Find canvas ids by collection, title, access, review state, or deletion state.",
10332
11352
  "canvas.rename": "Rename a canvas owned by the authenticated person.",
10333
11353
  "canvas.setReviewState": "Change the authenticated person’s review state on a canvas.",
@@ -10354,13 +11374,14 @@ const PROCEDURE_DESCRIPTIONS = {
10354
11374
  "comment.react": "Set or remove one emoji reaction on a comment message.",
10355
11375
  "comment.edit": "Replace the body of a comment message authored by this person.",
10356
11376
  "comment.move": "Move a comment thread anchor to a new canvas location.",
10357
- "comment.delete": "Delete an entire comment thread, or tombstone one message when its id is set.",
11377
+ "comment.delete": "Delete a comment thread you started, or tombstone one of your own replies when its id is set. Deleting the first message deletes the thread.",
10358
11378
  "organisation.list": "List teams the authenticated person belongs to.",
10359
11379
  "organisation.create": "Create a team and make the authenticated person its owner.",
10360
11380
  "organisation.update": "Rename a team managed by the authenticated person.",
10361
11381
  "organisation.delete": "Delete a team and rehome every canvas to its creator’s personal shelf.",
10362
11382
  "organisation.people.list": "List the people and roles in a team.",
10363
11383
  "organisation.people.add": "Add an existing account by email; use organisation invites create when no account exists.",
11384
+ "organisation.people.setContentAccess": "Change team content access independently of the member’s administrative role.",
10364
11385
  "organisation.people.setRole": "Change a team member between administrator and member.",
10365
11386
  "organisation.people.remove": "Remove a person from a team without deleting their account.",
10366
11387
  "organisation.people.transferOwnership": "Transfer team ownership to another current member.",
@@ -10407,7 +11428,7 @@ const OPTION_DESCRIPTIONS = {
10407
11428
  "canvas.makeEditable --placement": "Place the editable conversion adjacent to its source; retain the captured original.",
10408
11429
  "canvas.remove --root-node-ids": "Explicit roots to remove with their descendants, within the supplied scope and observed version.",
10409
11430
  "canvas.updateHtml --snapshot-token": "Opaque snapshot token from a complete editable read. Retain it for the identical retry; reread after a conflict.",
10410
- "canvas.updateHtml --html": "Complete edited HTML for that snapshot, preserving retained IDs and opaque placeholders. Follow the canvas HTML version 1 reference.",
11431
+ "canvas.updateHtml --html": "Complete edited HTML for that snapshot, preserving retained IDs and opaque placeholders. Follow the canvas HTML version 2 reference.",
10411
11432
  "canvas.updateHtml --remove-node-ids": "Explicit retained roots intentionally deleted from the HTML. Omission alone never authorizes removal.",
10412
11433
  "operation.status --operation": "Exact durable operation reference returned by a prior call, including its kind and identity fields.",
10413
11434
  "operation.status --include-image": "Include available render image evidence when true; this does not start another render.",
@@ -10434,7 +11455,7 @@ const OPTION_DESCRIPTIONS = {
10434
11455
  "--collection": "Canvas shelf: `own` (default), `everything`, or a team UUID from `organisation list`.",
10435
11456
  "--scope": "Within the shelf, return `all`, only `mine`, or only canvases `shared` with me.",
10436
11457
  "--deleted": "Set true to search the recoverable canvas bin instead of active canvases.",
10437
- "--access-state": "Filter or set link reach: invite-only, link-view, or link-comment.",
11458
+ "--access-state": "Filter or set link reach: invite-only, link-view, link-comment, or link-edit.",
10438
11459
  "--has-unresolved": "Set true to return only canvases with unresolved comment threads.",
10439
11460
  "--base-version": "Document version returned by `enhance canvas document get`.",
10440
11461
  "--document-format-version": "Supported canvas schema version for this writer, not the saved revision in baseVersion. Update the client if its format is no longer supported.",
@@ -10445,7 +11466,8 @@ const OPTION_DESCRIPTIONS = {
10445
11466
  "--bounds": "Optional world-space activity bounds as x, y, width, and height JSON.",
10446
11467
  "--activity-id": "Active agent-work lease id returned by canvas realtime activity begin.",
10447
11468
  "--role": "Team role to grant: admin or member.",
10448
- "--access-level": "Participant access to grant: can-comment or can-view.",
11469
+ "--content-access": "Team content access to grant independently of its administrative role: can-edit, can-comment, or can-view.",
11470
+ "--access-level": "Participant access to grant: can-edit, can-comment, or can-view.",
10449
11471
  "--expires-at": "ISO date-time when the token expires, or the literal null for no expiry.",
10450
11472
  "--etag": "ETag returned by the signed upload PUT, with surrounding quotes removed.",
10451
11473
  "--index": "Zero-based chunk index expected by the current recording upload.",
@@ -10536,6 +11558,7 @@ const OPTION_DESCRIPTIONS = {
10536
11558
  "recordingAsset.reserve --assets": "One or more JSON objects shaped `{\"url\":\"https://…\",\"contentType\":\"image/png\",\"byteSize\":123}`.",
10537
11559
  "recordingAsset.confirm --arrived": "One or more JSON objects shaped `{\"url\":\"https://…\",\"etag\":\"…\",\"byteSize\":123}`.",
10538
11560
  "screen.create --client-token": "Client-minted capture UUID; reuse it when retrying the same screen reservation.",
11561
+ "screen.create --is-recording-mark": "Defaults to true for recording marks. Use false for an explicit canvas capture that retains recording provenance without adding a recording mark.",
10539
11562
  "screen.create --provenance": "Required origin JSON `{\"sourceRecordingId\":\"UUID\",\"atMs\":0}`, or the literal null.",
10540
11563
  "screen.create --route": "Required original page route, or the literal null.",
10541
11564
  "screen.create --page-title": "Required captured page title, or the literal null.",
@@ -10719,6 +11742,11 @@ const FONT_ASSET_POLICY = {
10719
11742
  reason: "Font upload and transfer lifecycle belongs to document authoring transactions.",
10720
11743
  owner: "product"
10721
11744
  };
11745
+ const EDITOR_EXPORT_POLICY = {
11746
+ exposure: "internal",
11747
+ reason: "Image export is the editor's download for a signed-in person; agents use canvas_render.",
11748
+ owner: "product"
11749
+ };
10722
11750
  const RENDER_LIFECYCLE_POLICY = {
10723
11751
  exposure: "internal",
10724
11752
  reason: "Render creation, polling and cancellation belong to higher-level render capabilities.",
@@ -10739,37 +11767,26 @@ const PROFILE_DRAFT_POLICY = {
10739
11767
  owner: "product",
10740
11768
  reason: "Profile upload and atomic Save belong to the Settings draft lifecycle."
10741
11769
  };
11770
+ const CAPTURE_PIPELINE_POLICY = {
11771
+ exposure: "internal",
11772
+ owner: "product",
11773
+ reason: "Capture reservation, publication and baseline promotion belong to explicit SDK pipeline callers."
11774
+ };
10742
11775
  const PROCEDURE_CAPABILITY_POLICIES = {
10743
- "captureRun.begin": {
10744
- exposure: "internal",
10745
- owner: "product",
10746
- reason: "The SDK reserves capture baselines before tests execute."
10747
- },
10748
- "captureRun.get": {
10749
- exposure: "internal",
10750
- owner: "product",
10751
- reason: "SDK publication owns run and receipt recovery."
10752
- },
10753
- "captureRun.reserveAssets": {
10754
- exposure: "internal",
10755
- owner: "product",
10756
- reason: "The SDK verifies and uploads immutable capture artifacts."
10757
- },
10758
- "captureRun.seal": {
10759
- exposure: "internal",
10760
- owner: "product",
10761
- reason: "The SDK seals complete successful attempts before publication."
10762
- },
10763
- "captureRun.publish": {
10764
- exposure: "internal",
10765
- owner: "product",
10766
- reason: "Capture publication is composed by the SDK and captures publish command."
10767
- },
10768
- "captureRun.cancel": {
11776
+ "captureRun.review": SHARED_CAPABILITY_POLICY,
11777
+ "captureRun.decide": {
10769
11778
  exposure: "internal",
10770
11779
  owner: "product",
10771
- reason: "The SDK owns capture run cancellation."
11780
+ reason: "Whole-run decisions belong to canvas review and explicit SDK callers."
10772
11781
  },
11782
+ "captureRun.reference": CAPTURE_PIPELINE_POLICY,
11783
+ "captureRun.promote": CAPTURE_PIPELINE_POLICY,
11784
+ "captureRun.begin": CAPTURE_PIPELINE_POLICY,
11785
+ "captureRun.get": CAPTURE_PIPELINE_POLICY,
11786
+ "captureRun.reserveAssets": CAPTURE_PIPELINE_POLICY,
11787
+ "captureRun.seal": CAPTURE_PIPELINE_POLICY,
11788
+ "captureRun.publish": CAPTURE_PIPELINE_POLICY,
11789
+ "captureRun.cancel": CAPTURE_PIPELINE_POLICY,
10773
11790
  "captureRun.comparison": {
10774
11791
  exposure: "internal",
10775
11792
  owner: "product",
@@ -10779,6 +11796,11 @@ const PROCEDURE_CAPABILITY_POLICIES = {
10779
11796
  "person.completeProfilePhoto": PROFILE_DRAFT_POLICY,
10780
11797
  "person.abandonProfilePhoto": PROFILE_DRAFT_POLICY,
10781
11798
  "person.updateProfile": PROFILE_DRAFT_POLICY,
11799
+ "canvas.markViewed": {
11800
+ exposure: "internal",
11801
+ reason: "Opens count only from the product UI.",
11802
+ owner: "product"
11803
+ },
10782
11804
  "feedback.submit": {
10783
11805
  exposure: "internal",
10784
11806
  reason: "Dashboard feedback requires a deliberate human submission.",
@@ -10850,6 +11872,9 @@ const PROCEDURE_CAPABILITY_POLICIES = {
10850
11872
  owner: "product"
10851
11873
  },
10852
11874
  "canvas.render.get": RENDER_LIFECYCLE_POLICY,
11875
+ "canvas.render.export": EDITOR_EXPORT_POLICY,
11876
+ "canvas.render.getExport": EDITOR_EXPORT_POLICY,
11877
+ "canvas.render.downloadExport": EDITOR_EXPORT_POLICY,
10853
11878
  "canvas.render.snapshot": {
10854
11879
  exposure: "internal",
10855
11880
  reason: "Render snapshot creation is owned by higher-level render capabilities.",
@@ -10976,7 +12001,6 @@ const SHARED_CAPABILITY_PROCEDURES = /* @__PURE__ */ new Set([
10976
12001
  "canvas.invites.resend",
10977
12002
  "canvas.invites.revoke",
10978
12003
  "canvas.list",
10979
- "canvas.markViewed",
10980
12004
  "canvas.move",
10981
12005
  "canvas.node",
10982
12006
  "canvas.participants.list",
@@ -11023,6 +12047,7 @@ const SHARED_CAPABILITY_PROCEDURES = /* @__PURE__ */ new Set([
11023
12047
  "organisation.people.add",
11024
12048
  "organisation.people.list",
11025
12049
  "organisation.people.remove",
12050
+ "organisation.people.setContentAccess",
11026
12051
  "organisation.people.setRole",
11027
12052
  "organisation.people.transferOwnership",
11028
12053
  "organisation.update",
@@ -11418,7 +12443,7 @@ const fieldMessage = (issue) => {
11418
12443
  return `Check ${label.toLowerCase()} and try again.`;
11419
12444
  };
11420
12445
  /**
11421
- * @justified docs/comments.md#warning
12446
+ * @justified warning
11422
12447
  * A schema failure, flattened to `{ path: reason }`.
11423
12448
  *
11424
12449
  * Without this the caller receives a serialised issue list crammed into `message` — a JSON blob
@@ -11436,7 +12461,7 @@ const fieldsOf$2 = (cause) => {
11436
12461
  };
11437
12462
  };
11438
12463
  /**
11439
- * @justified docs/comments.md#warning
12464
+ * @justified warning
11440
12465
  * Rebuilt field by field rather than passed through, and INTERNAL loses its message.
11441
12466
  *
11442
12467
  * Two separate reasons for the two halves. Rebuilt, because tRPC turns a thrown `cause` into an
@@ -11490,7 +12515,6 @@ const toTrpcError = (error) => new TRPCError({
11490
12515
  message: error.message,
11491
12516
  cause: error
11492
12517
  });
11493
- const TOO_LARGE = appError("BAD_REQUEST", "this change is too large to save", { reason: REQUEST_TOO_LARGE });
11494
12518
 
11495
12519
  //#endregion
11496
12520
  //#region ../api/src/shared/trpc/idempotency.procedure.ts
@@ -11585,7 +12609,7 @@ const failureOf = (error) => {
11585
12609
  };
11586
12610
  };
11587
12611
  /**
11588
- * @justified docs/comments.md#amplification
12612
+ * @justified amplification
11589
12613
  * The canonical line: one per procedure call, and the whole of the profile.
11590
12614
  *
11591
12615
  * `queryCount` is on it deliberately. An N+1 is invisible in a latency graph until it is a
@@ -11642,7 +12666,7 @@ const renderGrantScope = trpcMiddleware(async ({ ctx, path, next }) => {
11642
12666
  return next();
11643
12667
  });
11644
12668
  /**
11645
- * @justified docs/comments.md#intent
12669
+ * @justified intent
11646
12670
  * A credential that was presented and failed is refused here, for every procedure, before any
11647
12671
  * reach check can answer. Read as anonymous, it turned an expired session into "no such canvas"
11648
12672
  * on a private canvas and into a quietly public read on a shared one.
@@ -11711,6 +12735,17 @@ const withAccess = trpcMiddleware(async ({ ctx, getRawInput, next }) => {
11711
12735
  } });
11712
12736
  });
11713
12737
  const canvasReaderProcedure = baseProcedure.use(withAccess);
12738
+ const canvasPersonReaderProcedure = canvasReaderProcedure.use(async ({ ctx, next }) => {
12739
+ if (ctx.viewer.kind === "anonymous" || ctx.viewer.kind === "render") throw toTrpcError(appError$1("UNAUTHORIZED", "this call needs a signed-in person"));
12740
+ return next({ ctx: {
12741
+ ...ctx,
12742
+ viewer: ctx.viewer
12743
+ } });
12744
+ });
12745
+ const canvasEditorProcedure = canvasPersonReaderProcedure.use(async ({ ctx, next }) => {
12746
+ if (!ctx.canvasAccess.canEdit) throw toTrpcError(appError$1("FORBIDDEN", "this canvas is read-only for you"));
12747
+ return next();
12748
+ });
11714
12749
  const canvasHistoryReaderProcedure = canvasReaderProcedure.use(async ({ ctx, next }) => {
11715
12750
  if (!ctx.canvasAccess.canSeeRoutes || ctx.viewer.kind === "anonymous" || ctx.viewer.kind === "render") throw toTrpcError(appError$1("NOT_FOUND", "no such canvas"));
11716
12751
  return next({ ctx: {
@@ -11722,7 +12757,7 @@ const canvasHistoryReaderProcedure = canvasReaderProcedure.use(async ({ ctx, nex
11722
12757
  const agentCanvasReaderProcedure = agentProcedure.use(withAccess);
11723
12758
  /** Agent-token editing authority, kept separate from browser sessions and read-only agent reach. */
11724
12759
  const agentCanvasEditorProcedure = agentCanvasReaderProcedure.use(async ({ ctx, next }) => {
11725
- if (!ctx.canvasAccess.canComment) throw toTrpcError(appError$1("FORBIDDEN", "this canvas is read-only for you"));
12760
+ if (!ctx.canvasAccess.canEdit) throw toTrpcError(appError$1("FORBIDDEN", "this canvas is read-only for you"));
11726
12761
  return next({ ctx: {
11727
12762
  ...ctx,
11728
12763
  viewer: ctx.viewer
@@ -11836,6 +12871,9 @@ const toCanvasContract = (view) => ({
11836
12871
  viewerCan: {
11837
12872
  read: view.reach.canRead,
11838
12873
  comment: view.reach.canComment ? "yes" : view.reach.commentNeedsSignIn ? "sign-in" : "no",
12874
+ edit: view.reach.canEdit ? "yes" : view.reach.editNeedsSignIn ? "sign-in" : "no",
12875
+ grants: [...view.reach.grants],
12876
+ grantableAccessLevels: [...view.reach.grantableAccessLevels],
11839
12877
  share: view.reach.canShare,
11840
12878
  manage: view.reach.canManage
11841
12879
  },
@@ -11851,7 +12889,8 @@ const toCanvasCardContract = (view) => {
11851
12889
  const base = {
11852
12890
  ...toCanvasContract(view),
11853
12891
  screenCount: view.screenCount,
11854
- hasRecording: view.hasRecording
12892
+ hasRecording: view.hasRecording,
12893
+ lastViewedAt: view.lastViewedAt?.toISOString() ?? null
11855
12894
  };
11856
12895
  return view.thumbnail === null ? {
11857
12896
  ...base,
@@ -11880,6 +12919,7 @@ const toCanvasSceneNodeContract = (node) => canvasSceneNodeSchema.parse({
11880
12919
  styles: { ...node.styles },
11881
12920
  ...node.layout !== void 0 && { layout: node.layout },
11882
12921
  ...node.appearance !== void 0 && { appearance: node.appearance },
12922
+ ...node.geometry !== void 0 && { geometry: node.geometry },
11883
12923
  ...node.typography !== void 0 && { typography: node.typography },
11884
12924
  ...node.additionalStyles !== void 0 && { additionalStyles: node.additionalStyles },
11885
12925
  ...node.props !== void 0 && { props: { ...node.props } },
@@ -11888,7 +12928,7 @@ const toCanvasSceneNodeContract = (node) => canvasSceneNodeSchema.parse({
11888
12928
 
11889
12929
  //#endregion
11890
12930
  //#region ../api/src/canvas/infrastructure/canvas.router.ts
11891
- const applyOperations = (handlers) => canvasCommenterProcedure.input(applyCanvasOperationsInputSchema).output(applyCanvasOperationsOutputSchema).mutation(async ({ input, ctx }) => {
12931
+ const applyOperations = (handlers) => canvasEditorProcedure.input(applyCanvasOperationsInputSchema).output(applyCanvasOperationsOutputSchema).mutation(async ({ input, ctx }) => {
11892
12932
  const applied = orThrow(await handlers.applyOperations.execute({
11893
12933
  ...input,
11894
12934
  personId: ctx.viewer.personId,
@@ -11906,7 +12946,7 @@ const applyOperations = (handlers) => canvasCommenterProcedure.input(applyCanvas
11906
12946
  next: [`enhance canvas tree --canvas ${applied.canvasId}`, ...renderNext]
11907
12947
  };
11908
12948
  });
11909
- const createEditableFrame = (handlers) => canvasCommenterProcedure.meta({ description: "Atomically insert a validated editable frame subtree beside an existing screen." }).input(createEditableFrameInputSchema).output(createEditableFrameOutputSchema).mutation(async ({ input, ctx }) => {
12949
+ const createEditableFrame = (handlers) => canvasEditorProcedure.meta({ description: "Atomically insert a validated editable frame subtree beside an existing screen." }).input(createEditableFrameInputSchema).output(createEditableFrameOutputSchema).mutation(async ({ input, ctx }) => {
11910
12950
  const created = orThrow(await handlers.createEditableFrame.execute({
11911
12951
  ...input,
11912
12952
  destination: { kind: "adjacent" },
@@ -11964,7 +13004,10 @@ const get$3 = (handlers) => canvasReaderProcedure.input(getCanvasInputSchema).ou
11964
13004
  return toCanvasContract(view);
11965
13005
  });
11966
13006
  const setAccess = (handlers) => canvasOwnerProcedure.input(setCanvasAccessInputSchema).output(setCanvasAccessOutputSchema).mutation(async ({ input, ctx }) => {
11967
- const result = orThrow(await handlers.setAccess.execute(input));
13007
+ const result = orThrow(await handlers.setAccess.execute({
13008
+ ...input,
13009
+ personId: ctx.viewer.personId
13010
+ }));
11968
13011
  ctx.telemetry.emit("AccessStateChanged", {
11969
13012
  canvasId: input.canvasId,
11970
13013
  fromState: ctx.canvasAccess.accessState,
@@ -11982,7 +13025,7 @@ const setAccess = (handlers) => canvasOwnerProcedure.input(setCanvasAccessInputS
11982
13025
  };
11983
13026
  });
11984
13027
  const markViewed = (handlers) => canvasReaderProcedure.input(markCanvasViewedInputSchema).output(markCanvasViewedOutputSchema).mutation(async ({ input, ctx }) => {
11985
- if (ctx.viewer.kind === "anonymous" || ctx.viewer.kind === "render") return { lastViewedAt: null };
13028
+ if (ctx.viewer.kind !== "person") return { lastViewedAt: null };
11986
13029
  return { lastViewedAt: orThrow(await handlers.markViewed.execute({
11987
13030
  canvasId: input.canvasId,
11988
13031
  personId: ctx.viewer.personId
@@ -12008,7 +13051,10 @@ const createCanvasRouter = (handlers) => trpcRouter({
12008
13051
  }),
12009
13052
  rename: canvasOwnerProcedure.input(renameCanvasInputSchema).output(canvasSchema).mutation(async ({ input, ctx }) => {
12010
13053
  return toCanvasContract({
12011
- canvas: orThrow(await handlers.rename.execute(input)),
13054
+ canvas: orThrow(await handlers.rename.execute({
13055
+ ...input,
13056
+ personId: ctx.viewer.personId
13057
+ })),
12012
13058
  accessLevel: ctx.canvasAccess.accessLevel,
12013
13059
  reach: ctx.canvasAccess,
12014
13060
  unresolvedCount: 0
@@ -12593,7 +13639,7 @@ const createCanvasChatRouter = (handlers) => trpcRouter({
12593
13639
  //#endregion
12594
13640
  //#region ../api/src/canvas/infrastructure/canvas-document.router.ts
12595
13641
  /**
12596
- * @justified docs/comments.md#intent
13642
+ * @justified intent
12597
13643
  * The cold open and the save: the only two procedures in this surface that carry the
12598
13644
  * document itself.
12599
13645
  *
@@ -12620,6 +13666,7 @@ const getDocument = (handlers) => canvasReaderProcedure.input(getCanvasDocumentI
12620
13666
  document: result.document.document,
12621
13667
  screens: result.screens.map((screen) => ({
12622
13668
  screenId: screen.screenId,
13669
+ clientToken: screen.clientToken,
12623
13670
  route: screen.route,
12624
13671
  title: screen.title,
12625
13672
  viewport: screen.viewport,
@@ -12637,7 +13684,7 @@ const getDocument = (handlers) => canvasReaderProcedure.input(getCanvasDocumentI
12637
13684
  }))
12638
13685
  };
12639
13686
  });
12640
- const saveDocument = (handlers) => canvasCommenterProcedure.input(saveCanvasDocumentInputSchema).output(saveCanvasDocumentOutputSchema).mutation(async ({ input, ctx }) => {
13687
+ const saveDocument = (handlers) => canvasEditorProcedure.input(saveCanvasDocumentInputSchema).output(saveCanvasDocumentOutputSchema).mutation(async ({ input, ctx }) => {
12641
13688
  const result = orThrow(await handlers.saveDocument.execute({
12642
13689
  canvasId: input.canvasId,
12643
13690
  personId: ctx.viewer.personId,
@@ -12671,7 +13718,7 @@ const createCanvasDocumentRouter = (handlers) => trpcRouter({
12671
13718
  //#endregion
12672
13719
  //#region ../api/src/canvas/infrastructure/canvas-font.router.ts
12673
13720
  const createCanvasFontRouter = (handlers) => trpcRouter({
12674
- copyFonts: canvasCommenterProcedure.meta({ description: "Copy readable file fonts into this canvas before publishing pasted content." }).input(copyCanvasFontsInputSchema).output(copyCanvasFontsOutputSchema).mutation(async ({ input, ctx }) => {
13721
+ copyFonts: canvasEditorProcedure.meta({ description: "Copy readable file fonts into this canvas before publishing pasted content." }).input(copyCanvasFontsInputSchema).output(copyCanvasFontsOutputSchema).mutation(async ({ input, ctx }) => {
12675
13722
  return { resources: orThrow(await handlers.fonts.copy({
12676
13723
  ...input,
12677
13724
  viewer: ctx.viewer
@@ -12680,7 +13727,7 @@ const createCanvasFontRouter = (handlers) => trpcRouter({
12680
13727
  path: canvasFontAssetPath(input.canvasId, source.sha256)
12681
13728
  })) };
12682
13729
  }),
12683
- reserveFont: canvasCommenterProcedure.meta({ description: "Reserve a file-scoped font upload pinned to its SHA-256 digest." }).input(reserveCanvasFontInputSchema).output(reserveCanvasFontOutputSchema).mutation(async ({ input }) => {
13730
+ reserveFont: canvasEditorProcedure.meta({ description: "Reserve a file-scoped font upload pinned to its SHA-256 digest." }).input(reserveCanvasFontInputSchema).output(reserveCanvasFontOutputSchema).mutation(async ({ input }) => {
12684
13731
  const upload = orThrow(await handlers.fonts.reserve(input));
12685
13732
  return {
12686
13733
  path: canvasFontAssetPath(input.canvasId, input.sha256),
@@ -12690,7 +13737,7 @@ const createCanvasFontRouter = (handlers) => trpcRouter({
12690
13737
  }
12691
13738
  };
12692
13739
  }),
12693
- completeFont: canvasCommenterProcedure.meta({ description: "Verify that the exact font bytes have arrived before using the resource." }).input(completeCanvasFontInputSchema).output(completeCanvasFontOutputSchema).mutation(async ({ input }) => {
13740
+ completeFont: canvasEditorProcedure.meta({ description: "Verify that the exact font bytes have arrived before using the resource." }).input(completeCanvasFontInputSchema).output(completeCanvasFontOutputSchema).mutation(async ({ input }) => {
12694
13741
  orThrow(await handlers.fonts.complete(input));
12695
13742
  return { path: canvasFontAssetPath(input.canvasId, input.sha256) };
12696
13743
  })
@@ -12698,7 +13745,7 @@ const createCanvasFontRouter = (handlers) => trpcRouter({
12698
13745
 
12699
13746
  //#endregion
12700
13747
  //#region ../api/src/canvas/infrastructure/canvas-image.router.ts
12701
- const createCanvasImageRouter = (handlers) => trpcRouter({ reserveImage: canvasCommenterProcedure.meta({ description: "Reserve storage and upload instructions for one canvas image." }).input(reserveCanvasImageInputSchema).output(reserveCanvasImageOutputSchema).mutation(async ({ input }) => {
13748
+ const createCanvasImageRouter = (handlers) => trpcRouter({ reserveImage: canvasEditorProcedure.meta({ description: "Reserve storage and upload instructions for one canvas image." }).input(reserveCanvasImageInputSchema).output(reserveCanvasImageOutputSchema).mutation(async ({ input }) => {
12702
13749
  const reserved = orThrow(await handlers.reserveImage.execute(input));
12703
13750
  return {
12704
13751
  ...reserved,
@@ -12876,6 +13923,7 @@ const createCanvasInspectionRouter = (handlers, webOrigin) => ({
12876
13923
  styles: found.node.styles,
12877
13924
  ...found.node.layout !== void 0 && { layout: found.node.layout },
12878
13925
  ...found.node.appearance !== void 0 && { appearance: found.node.appearance },
13926
+ ...found.node.geometry !== void 0 && { geometry: found.node.geometry },
12879
13927
  ...found.node.typography !== void 0 && { typography: found.node.typography },
12880
13928
  ...found.node.additionalStyles !== void 0 && { additionalStyles: found.node.additionalStyles },
12881
13929
  props: found.node.props ?? {},
@@ -12970,9 +14018,15 @@ const createCanvasInviteRouter = (handlers, shouldExposeTokens = false) => trpcR
12970
14018
  truncated: false
12971
14019
  };
12972
14020
  }),
12973
- revoke: canvasOwnerProcedure.input(revokeInviteInputSchema).output(revokeInviteInputSchema.pick({ inviteId: true })).mutation(async ({ input }) => orThrow(await handlers.revokeInvite.execute(input))),
12974
- resend: canvasOwnerProcedure.input(resendInviteInputSchema).output(createInviteOutputSchema).mutation(async ({ input }) => {
12975
- const result = orThrow(await handlers.resendInvite.execute(input));
14021
+ revoke: canvasOwnerProcedure.input(revokeInviteInputSchema).output(revokeInviteInputSchema.pick({ inviteId: true })).mutation(async ({ input, ctx }) => orThrow(await handlers.revokeInvite.execute({
14022
+ ...input,
14023
+ personId: ctx.viewer.personId
14024
+ }))),
14025
+ resend: canvasOwnerProcedure.input(resendInviteInputSchema).output(createInviteOutputSchema).mutation(async ({ input, ctx }) => {
14026
+ const result = orThrow(await handlers.resendInvite.execute({
14027
+ ...input,
14028
+ personId: ctx.viewer.personId
14029
+ }));
12976
14030
  return {
12977
14031
  invite: toInviteContract(result.invite, /* @__PURE__ */ new Date()),
12978
14032
  ...shouldExposeTokens && { acceptToken: result.token }
@@ -13020,10 +14074,12 @@ const createCanvasLifecycleRouter = (handlers) => trpcRouter({
13020
14074
 
13021
14075
  //#endregion
13022
14076
  //#region ../api/src/canvas/infrastructure/canvas-mutation.router.ts
13023
- const createCanvasMutationRouter = (handler) => trpcRouter({ get: canvasCommenterProcedure.input(getCanvasMutationInputSchema).output(getCanvasMutationOutputSchema).query(async ({ input, ctx }) => {
14077
+ const createCanvasMutationRouter = (handler) => trpcRouter({ get: canvasPersonReaderProcedure.input(getCanvasMutationInputSchema.partial({ fingerprint: true })).output(getCanvasMutationOutputSchema).query(async ({ input, ctx }) => {
14078
+ if (input.fingerprint === void 0 && ctx.viewer.kind !== "person") throw toTrpcError(appError$1("BAD_REQUEST", "A request fingerprint is required."));
13024
14079
  const commit = orThrow(await handler.execute({
13025
14080
  ...input,
13026
- personId: ctx.viewer.personId
14081
+ personId: ctx.viewer.personId,
14082
+ ...input.fingerprint === void 0 && { actorKind: "person" }
13027
14083
  }));
13028
14084
  if (commit === null) return { state: "not-found" };
13029
14085
  return {
@@ -13047,7 +14103,6 @@ const createCanvasMutationRouter = (handler) => trpcRouter({ get: canvasCommente
13047
14103
 
13048
14104
  //#endregion
13049
14105
  //#region ../api/src/canvas/infrastructure/canvas-mutation-recovery.router.ts
13050
- const MAX_TURN_MUTATIONS = 1e3;
13051
14106
  const receiptSchema$1 = applyCanvasOperationsOutputSchema.pick({
13052
14107
  canvasId: true,
13053
14108
  mutationId: true,
@@ -13058,9 +14113,9 @@ const receiptSchema$1 = applyCanvasOperationsOutputSchema.pick({
13058
14113
  removedNodeIds: true
13059
14114
  }).extend({ review: canvasMutationReviewSchema });
13060
14115
  const createCanvasMutationRecoveryRouter = (handlers) => trpcRouter({
13061
- revertMutations: canvasCommenterProcedure.input(z.object({
14116
+ revertMutations: canvasEditorProcedure.input(z.object({
13062
14117
  canvasId: z.uuid(),
13063
- mutationIds: z.array(z.uuid()).min(1).max(MAX_TURN_MUTATIONS),
14118
+ mutationIds: z.array(z.uuid()).min(1),
13064
14119
  reversalId: z.uuid()
13065
14120
  })).output(applyCanvasOperationsOutputSchema).mutation(async ({ input, ctx }) => {
13066
14121
  const result = orThrow(await handlers.mutationRecovery.undo({
@@ -13076,7 +14131,7 @@ const createCanvasMutationRecoveryRouter = (handlers) => trpcRouter({
13076
14131
  next: []
13077
14132
  };
13078
14133
  }),
13079
- mutationReceipt: canvasCommenterProcedure.input(z.object({
14134
+ mutationReceipt: canvasPersonReaderProcedure.input(z.object({
13080
14135
  canvasId: z.uuid(),
13081
14136
  mutationId: z.uuid()
13082
14137
  })).output(receiptSchema$1.nullable()).query(async ({ input, ctx }) => {
@@ -13097,7 +14152,7 @@ const createCanvasMutationRecoveryRouter = (handlers) => trpcRouter({
13097
14152
 
13098
14153
  //#endregion
13099
14154
  //#region ../api/src/canvas/infrastructure/participant-contract.mapper.ts
13100
- /** Domain to wire. */
14155
+ /** Domain to wire. The member list carries no view times, so each person's stay their own. */
13101
14156
  const toParticipantContract = (row) => ({
13102
14157
  personId: row.personId,
13103
14158
  email: row.email,
@@ -13107,7 +14162,7 @@ const toParticipantContract = (row) => ({
13107
14162
  accessLevel: row.accessLevel,
13108
14163
  isPending: row.isPending,
13109
14164
  reviewState: row.reviewState,
13110
- lastViewedAt: row.lastViewedAt?.toISOString() ?? null
14165
+ lastViewedAt: null
13111
14166
  });
13112
14167
 
13113
14168
  //#endregion
@@ -13126,14 +14181,20 @@ const createCanvasParticipantRouter = (handlers) => trpcRouter({
13126
14181
  setAccess: canvasOwnerProcedure.input(setParticipantAccessInputSchema).output(setParticipantAccessInputSchema.pick({
13127
14182
  personId: true,
13128
14183
  accessLevel: true
13129
- })).mutation(async ({ input }) => {
13130
- orThrow(await handlers.setParticipantAccess.execute(input));
14184
+ })).mutation(async ({ input, ctx }) => {
14185
+ orThrow(await handlers.setParticipantAccess.execute({
14186
+ ...input,
14187
+ actorPersonId: ctx.viewer.personId
14188
+ }));
13131
14189
  return {
13132
14190
  personId: input.personId,
13133
14191
  accessLevel: input.accessLevel
13134
14192
  };
13135
14193
  }),
13136
- revoke: canvasOwnerProcedure.input(revokeParticipantInputSchema).output(revokeParticipantOutputSchema).mutation(async ({ input }) => orThrow(await handlers.revokeParticipant.execute(input)))
14194
+ revoke: canvasOwnerProcedure.input(revokeParticipantInputSchema).output(revokeParticipantOutputSchema).mutation(async ({ input, ctx }) => orThrow(await handlers.revokeParticipant.execute({
14195
+ ...input,
14196
+ actorPersonId: ctx.viewer.personId
14197
+ })))
13137
14198
  });
13138
14199
 
13139
14200
  //#endregion
@@ -13229,14 +14290,14 @@ const agentActor = (viewer) => {
13229
14290
  tokenId: viewer.tokenId
13230
14291
  };
13231
14292
  };
13232
- const assertActivityAccess = (phase, canComment) => {
13233
- if (canComment || phase === "reading" || phase === "rendering") return;
14293
+ const assertActivityAccess = (phase, canEdit) => {
14294
+ if (canEdit || phase === "reading" || phase === "rendering") return;
13234
14295
  throw toTrpcError(appError("FORBIDDEN", "this canvas is read-only for you"));
13235
14296
  };
13236
14297
  const createCanvasActivityRouter = (activity) => trpcRouter({
13237
14298
  begin: agentCanvasReaderProcedure.input(beginCanvasActivityInputSchema).output(beginCanvasActivityOutputSchema).mutation(async ({ input, ctx }) => {
13238
14299
  if (ctx.viewer.kind !== "agent") throw new TypeError("agent identity was not narrowed");
13239
- assertActivityAccess(input.phase, ctx.canvasAccess.canComment);
14300
+ assertActivityAccess(input.phase, ctx.canvasAccess.canEdit);
13240
14301
  const started = orThrow(await activity.begin({
13241
14302
  ...input,
13242
14303
  actor: agentActor(ctx.viewer)
@@ -13249,7 +14310,7 @@ const createCanvasActivityRouter = (activity) => trpcRouter({
13249
14310
  }),
13250
14311
  renew: agentCanvasReaderProcedure.input(renewCanvasActivityInputSchema).output(beginCanvasActivityOutputSchema).mutation(async ({ input, ctx }) => {
13251
14312
  if (ctx.viewer.kind !== "agent") throw new TypeError("agent identity was not narrowed");
13252
- assertActivityAccess(input.phase, ctx.canvasAccess.canComment);
14313
+ assertActivityAccess(input.phase, ctx.canvasAccess.canEdit);
13253
14314
  const renewed = orThrow(await activity.renew({
13254
14315
  ...input,
13255
14316
  actor: agentActor(ctx.viewer)
@@ -13273,7 +14334,8 @@ const createCanvasRealtimeRouter = (handlers, endpoint) => trpcRouter({
13273
14334
  ticket: canvasReaderProcedure.input(canvasRealtimeTicketInputSchema).output(canvasRealtimeTicketOutputSchema).mutation(async ({ input, ctx }) => {
13274
14335
  const issued = orThrow(await handlers.issueRealtimeTicket.execute({
13275
14336
  canvasId: input.canvasId,
13276
- viewer: ctx.viewer
14337
+ viewer: ctx.viewer,
14338
+ viewId: input.viewId
13277
14339
  }));
13278
14340
  return {
13279
14341
  endpoint,
@@ -13390,12 +14452,14 @@ const toCanvasVersionContractEntry = (entry) => ({
13390
14452
  actor: entry.actor,
13391
14453
  sourceVersionEntryId: entry.sourceVersionEntryId,
13392
14454
  expiresAt: entry.expiresAt?.toISOString() ?? null,
14455
+ checkpointAt: entry.checkpointAt.toISOString(),
13393
14456
  createdAt: entry.createdAt.toISOString(),
13394
14457
  updatedAt: entry.updatedAt.toISOString(),
13395
14458
  screenCount: entry.screenCount
13396
14459
  });
13397
14460
  const toCanvasVersionContractScreen = (screen) => ({
13398
14461
  screenId: screen.screenId,
14462
+ clientToken: screen.clientToken,
13399
14463
  route: screen.route,
13400
14464
  title: screen.title,
13401
14465
  viewport: screen.viewport,
@@ -13450,14 +14514,14 @@ const get$2 = (handlers) => canvasHistoryReaderProcedure.input(getCanvasVersionI
13450
14514
  screens: result.screens.map((screen) => toCanvasVersionContractScreen(screen))
13451
14515
  };
13452
14516
  });
13453
- const name = (handlers) => canvasCommenterProcedure.input(nameCanvasVersionInputSchema).output(canvasVersionMutationOutputSchema).mutation(async ({ input, ctx }) => {
14517
+ const name = (handlers) => canvasEditorProcedure.input(nameCanvasVersionInputSchema).output(canvasVersionMutationOutputSchema).mutation(async ({ input, ctx }) => {
13454
14518
  return { entry: toCanvasVersionContractEntry(orThrow(await handlers.versions.name({
13455
14519
  ...input,
13456
14520
  actor: toCanvasVersionActor(ctx.viewer),
13457
14521
  canManageAllMetadata: ctx.canvasAccess.canManage
13458
14522
  }))) };
13459
14523
  });
13460
- const updateMetadata = (handlers) => canvasCommenterProcedure.input(updateCanvasVersionMetadataInputSchema).output(canvasVersionMutationOutputSchema).mutation(async ({ input, ctx }) => {
14524
+ const updateMetadata = (handlers) => canvasEditorProcedure.input(updateCanvasVersionMetadataInputSchema).output(canvasVersionMutationOutputSchema).mutation(async ({ input, ctx }) => {
13461
14525
  return { entry: toCanvasVersionContractEntry(orThrow(await handlers.versions.name({
13462
14526
  canvasId: input.canvasId,
13463
14527
  target: {
@@ -13470,14 +14534,14 @@ const updateMetadata = (handlers) => canvasCommenterProcedure.input(updateCanvas
13470
14534
  canManageAllMetadata: ctx.canvasAccess.canManage
13471
14535
  }))) };
13472
14536
  });
13473
- const removeName = (handlers) => canvasCommenterProcedure.input(removeCanvasVersionNameInputSchema).output(canvasVersionMutationOutputSchema).mutation(async ({ input, ctx }) => {
14537
+ const removeName = (handlers) => canvasEditorProcedure.input(removeCanvasVersionNameInputSchema).output(canvasVersionMutationOutputSchema).mutation(async ({ input, ctx }) => {
13474
14538
  return { entry: toCanvasVersionContractEntry(orThrow(await handlers.versions.removeName({
13475
14539
  ...input,
13476
14540
  requesterPersonId: ctx.viewer.personId,
13477
14541
  canManageAllMetadata: ctx.canvasAccess.canManage
13478
14542
  }))) };
13479
14543
  });
13480
- const restore = (handlers) => canvasCommenterProcedure.input(restoreCanvasVersionInputSchema).output(restoreCanvasVersionOutputSchema).mutation(async ({ input, ctx }) => {
14544
+ const restore = (handlers) => canvasEditorProcedure.input(restoreCanvasVersionInputSchema).output(restoreCanvasVersionOutputSchema).mutation(async ({ input, ctx }) => {
13481
14545
  if (ctx.viewer.kind !== "person") throw toTrpcError(appError("FORBIDDEN", "an agent cannot restore canvas history"));
13482
14546
  const restored = orThrow(await handlers.versions.restore({
13483
14547
  ...input,
@@ -13507,29 +14571,6 @@ const createCanvasVersionRouter = (handlers) => trpcRouter({
13507
14571
  duplicate: duplicate(handlers)
13508
14572
  });
13509
14573
 
13510
- //#endregion
13511
- //#region ../../packages/contract/src/capture/capture-comparison.schema.ts
13512
- const COMMIT_LENGTH = 200;
13513
- const captureComparisonInputSchema = z.strictObject({
13514
- canvasId: z.uuid(),
13515
- frameId: z.string().min(1),
13516
- captureId: z.uuid()
13517
- });
13518
- const preview$1 = z.strictObject({
13519
- captureId: z.uuid(),
13520
- capturedAt: z.iso.datetime(),
13521
- commit: z.string().max(COMMIT_LENGTH).optional(),
13522
- url: z.string().min(1),
13523
- width: z.number().positive(),
13524
- height: z.number().positive(),
13525
- pixelRatio: z.number().positive()
13526
- });
13527
- const captureComparisonSchema = z.strictObject({
13528
- frameId: z.string(),
13529
- before: preview$1,
13530
- after: preview$1
13531
- });
13532
-
13533
14574
  //#endregion
13534
14575
  //#region ../api/src/canvas/infrastructure/capture-run.router.ts
13535
14576
  const actorOf$1 = (viewer) => {
@@ -13540,8 +14581,18 @@ const actorOf$1 = (viewer) => {
13540
14581
  tokenId: actor.tokenId
13541
14582
  };
13542
14583
  };
14584
+ const reviewProcedures = (review, comparison) => ({
14585
+ comparison: canvasHistoryReaderProcedure.input(captureComparisonInputSchema).output(captureComparisonSchema.nullable()).query(async ({ input }) => orThrow(await comparison(input))),
14586
+ review: canvasHistoryReaderProcedure.input(captureReviewInputSchema).output(captureReviewSchema.nullable()).query(async ({ input, ctx }) => captureReviewSchema.nullable().parse(orThrow(await review.read(input.canvasId, ctx.viewer)))),
14587
+ decide: canvasEditorProcedure.input(setCaptureVerdictInputSchema).output(z.object({ accepted: z.literal(true) })).mutation(async ({ input, ctx }) => {
14588
+ orThrow(await review.decide(input.canvasId, input.verdict, ctx.viewer.personId));
14589
+ return { accepted: true };
14590
+ }),
14591
+ reference: agentCanvasEditorProcedure.input(captureReferenceInputSchema).output(captureReferenceSchema.nullable()).query(async ({ input }) => orThrow(await review.reference(input.canvasId, input.name))),
14592
+ promote: agentCanvasEditorProcedure.input(updateCaptureReferenceInputSchema).output(captureReferenceSchema).mutation(async ({ input, ctx }) => orThrow(await review.promote(input, actorOf$1(ctx.viewer).mutation.personId)))
14593
+ });
13543
14594
  const createCaptureRunRouter = (capture) => trpcRouter({
13544
- comparison: canvasHistoryReaderProcedure.input(captureComparisonInputSchema).output(captureComparisonSchema.nullable()).query(async ({ input }) => orThrow(await capture.comparison(input))),
14595
+ ...reviewProcedures(capture.review, capture.comparison),
13545
14596
  begin: agentProcedure.input(beginCaptureRunInputSchema).output(beginCaptureRunOutputSchema).mutation(async ({ input, ctx }) => ({ run: beginCaptureRunOutputSchema.shape.run.parse(orThrow(await capture.begin(input, actorOf$1(ctx.viewer))).run) })),
13546
14597
  get: agentProcedure.input(getCaptureRunInputSchema).output(getCaptureRunOutputSchema).query(async ({ input, ctx }) => getCaptureRunOutputSchema.parse(orThrow(await capture.get(input.runId, actorOf$1(ctx.viewer))))),
13547
14598
  reserveAssets: agentProcedure.input(reserveCaptureBlobsInputSchema).output(reserveCaptureBlobsOutputSchema).mutation(async ({ input, ctx }) => reserveCaptureBlobsOutputSchema.parse(orThrow(await capture.reserve(input, actorOf$1(ctx.viewer))))),
@@ -13775,7 +14826,7 @@ const toCanvasConversionJob = (job) => {
13775
14826
  //#endregion
13776
14827
  //#region ../api/src/canvas/infrastructure/render.router.ts
13777
14828
  const actorOf = (viewer) => toAgentCanvasRequestActor(viewer) ?? orThrow((0, import_index_cjs.err)(appError("UNAUTHORIZED", "this call needs an agent token")));
13778
- const presentRender = (job) => toCanvasRenderJob(job) ?? orThrow((0, import_index_cjs.err)(appError("INTERNAL", "render outcome is incomplete")));
14829
+ const presentRender$1 = (job) => toCanvasRenderJob(job) ?? orThrow((0, import_index_cjs.err)(appError("INTERNAL", "render outcome is incomplete")));
13779
14830
  const presentConversion = (job) => toCanvasConversionJob(job) ?? orThrow((0, import_index_cjs.err)(appError("INTERNAL", "primitive import outcome is incomplete")));
13780
14831
  const requirePurpose = (job, purpose) => job.purpose !== "preparation" && purpose === "conversion" === (job.purpose === "conversion") ? job : orThrow((0, import_index_cjs.err)(appError("NOT_FOUND", `no such ${purpose}`)));
13781
14832
  const createRender = (handlers) => agentCanvasReaderProcedure.input(createCanvasRenderInputSchema).output(createCanvasRenderOutputSchema).mutation(async ({ input, ctx }) => {
@@ -13794,7 +14845,7 @@ const createRender = (handlers) => agentCanvasReaderProcedure.input(createCanvas
13794
14845
  idempotencyKey: ctx.idempotencyKey
13795
14846
  }));
13796
14847
  return {
13797
- job: presentRender(made.job),
14848
+ job: presentRender$1(made.job),
13798
14849
  alreadyExists: made.alreadyExists
13799
14850
  };
13800
14851
  });
@@ -13803,7 +14854,7 @@ const getRender = (handlers) => agentProcedure.input(getCanvasRenderInputSchema)
13803
14854
  jobId: input.jobId,
13804
14855
  actor: actorOf(ctx.viewer)
13805
14856
  }));
13806
- return { job: presentRender(requirePurpose(job, "render")) };
14857
+ return { job: presentRender$1(requirePurpose(job, "render")) };
13807
14858
  });
13808
14859
  const createSnapshot = (handlers) => agentCanvasEditorProcedure.input(createRecordingSnapshotInputSchema).output(createRecordingSnapshotOutputSchema).mutation(async ({ input, ctx }) => {
13809
14860
  const actor = actorOf(ctx.viewer);
@@ -13829,7 +14880,7 @@ const createSnapshot = (handlers) => agentCanvasEditorProcedure.input(createReco
13829
14880
  idempotencyKey: ctx.idempotencyKey
13830
14881
  }));
13831
14882
  return {
13832
- job: presentRender(made.job),
14883
+ job: presentRender$1(made.job),
13833
14884
  alreadyExists: made.alreadyExists
13834
14885
  };
13835
14886
  });
@@ -13891,7 +14942,7 @@ const cancelRender = (handlers) => agentProcedure.input(cancelCanvasRenderInputS
13891
14942
  actor
13892
14943
  }));
13893
14944
  requirePurpose(current, "render");
13894
- return { job: presentRender(orThrow(await handlers.cancel.execute({
14945
+ return { job: presentRender$1(orThrow(await handlers.cancel.execute({
13895
14946
  jobId: input.jobId,
13896
14947
  actor
13897
14948
  }))) };
@@ -13903,6 +14954,10 @@ const downloadRender = (handlers) => agentProcedure.input(downloadCanvasRenderIn
13903
14954
  }));
13904
14955
  return {
13905
14956
  jobId: input.jobId,
14957
+ source: download.source.status === "available" ? {
14958
+ ...download.source,
14959
+ prototypes: [...download.source.prototypes]
14960
+ } : download.source,
13906
14961
  download: {
13907
14962
  url: download.url,
13908
14963
  expiresAt: download.expiresAt.toISOString(),
@@ -13921,6 +14976,68 @@ const createRenderRouter = (handlers) => trpcRouter({
13921
14976
  download: downloadRender(handlers)
13922
14977
  });
13923
14978
 
14979
+ //#endregion
14980
+ //#region ../api/src/canvas/infrastructure/render-export.router.ts
14981
+ const presentRender = (job) => toCanvasRenderJob(job) ?? orThrow((0, import_index_cjs.err)(appError("INTERNAL", "render outcome is incomplete")));
14982
+ /** A person's own exports, which carry no agent token. */
14983
+ const personActorOf = (viewer) => ({
14984
+ personId: viewer.personId,
14985
+ tokenId: null
14986
+ });
14987
+ const createExport = (handlers) => canvasPersonReaderProcedure.meta({ description: "Export one layer as an image at the saved canvas revision." }).input(createCanvasExportInputSchema).output(createCanvasRenderOutputSchema).mutation(async ({ input, ctx }) => {
14988
+ const made = orThrow(await handlers.create.execute({
14989
+ canvasId: input.canvasId,
14990
+ purpose: "export",
14991
+ expectedVersion: input.expectedVersion,
14992
+ target: {
14993
+ kind: "node",
14994
+ nodeId: input.nodeId
14995
+ },
14996
+ sourceState: null,
14997
+ scale: input.scale,
14998
+ requesterPersonId: ctx.viewer.personId,
14999
+ requesterTokenId: null,
15000
+ idempotencyKey: null
15001
+ }));
15002
+ return {
15003
+ job: presentRender(made.job),
15004
+ alreadyExists: made.alreadyExists
15005
+ };
15006
+ });
15007
+ const requireExport = (job) => job.purpose === "export" ? job : orThrow((0, import_index_cjs.err)(appError("NOT_FOUND", "no such export")));
15008
+ const getExport = (handlers) => personProcedure.input(getCanvasRenderInputSchema).output(getCanvasRenderOutputSchema).query(async ({ input, ctx }) => {
15009
+ const job = orThrow(await handlers.get.execute({
15010
+ jobId: input.jobId,
15011
+ actor: personActorOf(ctx.viewer)
15012
+ }));
15013
+ return { job: presentRender(requireExport(job)) };
15014
+ });
15015
+ const downloadExport = (handlers) => personProcedure.input(downloadCanvasRenderInputSchema).output(downloadCanvasRenderOutputSchema).query(async ({ input, ctx }) => {
15016
+ const actor = personActorOf(ctx.viewer);
15017
+ requireExport(orThrow(await handlers.get.execute({
15018
+ jobId: input.jobId,
15019
+ actor
15020
+ })));
15021
+ const download = orThrow(await handlers.download.execute({
15022
+ jobId: input.jobId,
15023
+ actor
15024
+ }));
15025
+ return {
15026
+ jobId: input.jobId,
15027
+ download: {
15028
+ url: download.url,
15029
+ expiresAt: download.expiresAt.toISOString(),
15030
+ bytes: download.bytes
15031
+ }
15032
+ };
15033
+ });
15034
+ /** The editor's image export: a person's own render jobs, polled and downloaded by them. */
15035
+ const createRenderExportRouter = (handlers) => trpcRouter({
15036
+ export: createExport(handlers),
15037
+ getExport: getExport(handlers),
15038
+ downloadExport: downloadExport(handlers)
15039
+ });
15040
+
13924
15041
  //#endregion
13925
15042
  //#region ../api/src/canvas/infrastructure/render-exposure.router.ts
13926
15043
  const createRenderExposureRouter = (handlers) => trpcRouter({ exposure: renderProcedure.input(exposeCanvasRenderInputSchema).output(exposeCanvasRenderOutputSchema).query(async ({ input, ctx }) => {
@@ -14096,6 +15213,7 @@ const toCommentMessageContract = (message, directory) => ({
14096
15213
  messageId: message.id,
14097
15214
  seq: message.seq,
14098
15215
  body: message.deletedAt === null ? message.body : "(deleted)",
15216
+ isDeleted: message.deletedAt !== null,
14099
15217
  author: toAuthorContract(message, directory),
14100
15218
  createdAt: message.createdAt.toISOString(),
14101
15219
  editedAt: message.editedAt?.toISOString() ?? null,
@@ -14178,7 +15296,7 @@ const authorFrom = (viewer) => ({
14178
15296
  initials: viewer.initials
14179
15297
  });
14180
15298
  /**
14181
- * @justified docs/comments.md#warning
15299
+ * @justified warning
14182
15300
  * What is worth writing down about an anchor: whether it names a source file, which is the
14183
15301
  * only thing that makes a thread actionable, and how deep its selector reaches.
14184
15302
  *
@@ -14207,7 +15325,7 @@ const start$1 = (handlers) => canvasCommenterProcedure.input(startCommentInputSc
14207
15325
  body: input.body,
14208
15326
  mentionedPersonIds: input.mentionedPersonIds,
14209
15327
  author: authorFrom(ctx.viewer),
14210
- mintMembership: ctx.canvasAccess.accessLevel === null
15328
+ mintMembership: ctx.canvasAccess.accessLevel === null && ctx.canvasAccess.accessState === "link-comment"
14211
15329
  }));
14212
15330
  ctx.telemetry.emit("CommentThreadStarted", {
14213
15331
  canvasId: input.canvasId,
@@ -14260,8 +15378,7 @@ const createCommentRouter = (handlers) => trpcRouter({
14260
15378
  move: canvasCommenterProcedure.input(moveCommentInputSchema).output(commentThreadSchema).mutation(async ({ input }) => nameCommentThread(handlers.directory, orThrow(await handlers.move.execute(input)))),
14261
15379
  delete: canvasCommenterProcedure.input(deleteCommentInputSchema).output(deleteCommentOutputSchema).mutation(async ({ input, ctx }) => orThrow(await handlers.remove.execute({
14262
15380
  ...input,
14263
- personId: ctx.viewer.personId,
14264
- canManage: ctx.canvasAccess.canManage
15381
+ personId: ctx.viewer.personId
14265
15382
  })))
14266
15383
  });
14267
15384
 
@@ -14339,6 +15456,7 @@ const inviteContract = (invite, at) => ({
14339
15456
  inviteId: invite.id,
14340
15457
  email: invite.email,
14341
15458
  role: invite.role,
15459
+ contentAccess: invite.contentAccess,
14342
15460
  sendCount: invite.sendCount,
14343
15461
  lastSentAt: invite.lastSentAt.toISOString(),
14344
15462
  expiresAt: invite.expiresAt.toISOString(),
@@ -14408,12 +15526,17 @@ const add = (handlers) => personProcedure.input(addMemberInputSchema).output(add
14408
15526
  organisationId: input.organisationId,
14409
15527
  personId: ctx.viewer.personId,
14410
15528
  email: input.email,
14411
- role: input.role
15529
+ role: input.role,
15530
+ contentAccess: input.contentAccess
14412
15531
  })));
14413
15532
  const setRole = (handlers) => personProcedure.input(setMemberRoleInputSchema).output(setMemberRoleOutputSchema).mutation(async ({ input, ctx }) => orThrow(await handlers.setMemberRole.execute({
14414
15533
  ...input,
14415
15534
  actorPersonId: ctx.viewer.personId
14416
15535
  })));
15536
+ const setContentAccess = (handlers) => personProcedure.input(setMemberContentAccessInputSchema).output(setMemberContentAccessOutputSchema).mutation(async ({ input, ctx }) => orThrow(await handlers.setMemberContentAccess.execute({
15537
+ ...input,
15538
+ actorPersonId: ctx.viewer.personId
15539
+ })));
14417
15540
  const remove = (handlers) => personProcedure.input(removeMemberInputSchema).output(removeMemberOutputSchema).mutation(async ({ input, ctx }) => orThrow(await handlers.removeMember.execute({
14418
15541
  ...input,
14419
15542
  actorPersonId: ctx.viewer.personId
@@ -14427,6 +15550,7 @@ const createOrganisationPeopleRouter = (handlers) => trpcRouter({
14427
15550
  list: list(handlers),
14428
15551
  add: add(handlers),
14429
15552
  setRole: setRole(handlers),
15553
+ setContentAccess: setContentAccess(handlers),
14430
15554
  remove: remove(handlers),
14431
15555
  transferOwnership: transferOwnership(handlers)
14432
15556
  });
@@ -14744,7 +15868,7 @@ const artifactCapabilitiesProcedure = (handlers) => personProcedure.input(getPro
14744
15868
  },
14745
15869
  attachmentProtocolVersion: 1
14746
15870
  }));
14747
- const createArtifactProcedure = (handlers) => canvasCommenterProcedure.input(createPrototypeArtifactInputSchema).output(createPrototypeArtifactOutputSchema).mutation(async ({ input, ctx }) => {
15871
+ const createArtifactProcedure = (handlers) => canvasEditorProcedure.input(createPrototypeArtifactInputSchema).output(createPrototypeArtifactOutputSchema).mutation(async ({ input, ctx }) => {
14748
15872
  const created = orThrow(await handlers.artifactPublishing.create({
14749
15873
  ...input,
14750
15874
  prototypeId: input.prototypeId ?? null,
@@ -14771,7 +15895,7 @@ const createArtifactProcedure = (handlers) => canvasCommenterProcedure.input(cre
14771
15895
  }
14772
15896
  };
14773
15897
  });
14774
- const submitArtifactProcedure = (handlers) => canvasCommenterProcedure.input(submitPrototypeArtifactInputSchema).output(submitPrototypeArtifactOutputSchema).mutation(async ({ input, ctx }) => {
15898
+ const submitArtifactProcedure = (handlers) => canvasEditorProcedure.input(submitPrototypeArtifactInputSchema).output(submitPrototypeArtifactOutputSchema).mutation(async ({ input, ctx }) => {
14775
15899
  const deployment = orThrow(await handlers.artifactPublishing.submit({
14776
15900
  ...input,
14777
15901
  personId: toPrototypePublisher(ctx.viewer).personId
@@ -14781,7 +15905,7 @@ const submitArtifactProcedure = (handlers) => canvasCommenterProcedure.input(sub
14781
15905
  state: deployment.state
14782
15906
  };
14783
15907
  });
14784
- const artifactStatusProcedure = (handlers) => canvasCommenterProcedure.input(getPrototypePublishStatusInputSchema).output(getPrototypePublishStatusOutputSchema).query(async ({ input, ctx }) => {
15908
+ const artifactStatusProcedure = (handlers) => canvasEditorProcedure.input(getPrototypePublishStatusInputSchema).output(getPrototypePublishStatusOutputSchema).query(async ({ input, ctx }) => {
14785
15909
  const status = orThrow(await handlers.artifactPublishing.status({
14786
15910
  ...input,
14787
15911
  personId: toPrototypePublisher(ctx.viewer).personId
@@ -14811,7 +15935,7 @@ const artifactStatusProcedure = (handlers) => canvasCommenterProcedure.input(get
14811
15935
  }
14812
15936
  };
14813
15937
  });
14814
- const attachArtifactProcedure = (handlers) => canvasCommenterProcedure.input(attachPrototypeArtifactInputSchema).output(attachPrototypeArtifactOutputSchema).mutation(async ({ input, ctx }) => {
15938
+ const attachArtifactProcedure = (handlers) => canvasEditorProcedure.input(attachPrototypeArtifactInputSchema).output(attachPrototypeArtifactOutputSchema).mutation(async ({ input, ctx }) => {
14815
15939
  const publisher = toPrototypePublisher(ctx.viewer);
14816
15940
  const completed = orThrow(await handlers.upload.complete({
14817
15941
  ...input,
@@ -15012,7 +16136,10 @@ const createRecordingRouter = (handlers) => trpcRouter({
15012
16136
  truncated: false
15013
16137
  };
15014
16138
  }),
15015
- delete: canvasOwnerProcedure.input(deleteRecordingInputSchema).output(deleteRecordingOutputSchema).mutation(async ({ input }) => orThrow(await handlers.remove.execute(input)))
16139
+ delete: canvasOwnerProcedure.input(deleteRecordingInputSchema).output(deleteRecordingOutputSchema).mutation(async ({ input, ctx }) => orThrow(await handlers.remove.execute({
16140
+ ...input,
16141
+ personId: ctx.viewer.personId
16142
+ })))
15016
16143
  });
15017
16144
 
15018
16145
  //#endregion
@@ -15094,7 +16221,7 @@ const recordingRepairRoutes = (handlers) => ({
15094
16221
  //#endregion
15095
16222
  //#region ../api/src/screen/infrastructure/screen.router.ts
15096
16223
  /**
15097
- * @justified docs/comments.md#intent
16224
+ * @justified intent
15098
16225
  * Translates a transport call into a command. No rules, no persistence.
15099
16226
  *
15100
16227
  * There is no `get` and no `list`: a procedure taking a bare `screenId` would have to answer
@@ -15301,7 +16428,7 @@ const toCanvasAssetUploadContract = (asset) => ({
15301
16428
  //#endregion
15302
16429
  //#region ../api/src/canvas/infrastructure/canvas-asset.router.ts
15303
16430
  const createCanvasAssetRouter = (handlers) => trpcRouter({
15304
- reserve: canvasCommenterProcedure.meta({ description: "Reserve an actor-owned, checksum-bound image or font import. Identical retries refresh upload access; changed content requires a new token." }).input(reserveCanvasAssetInputSchema).output(reserveCanvasAssetOutputSchema).mutation(async ({ input, ctx }) => {
16431
+ reserve: canvasEditorProcedure.meta({ description: "Reserve an actor-owned, checksum-bound image or font import. Identical retries refresh upload access; changed content requires a new token." }).input(reserveCanvasAssetInputSchema).output(reserveCanvasAssetOutputSchema).mutation(async ({ input, ctx }) => {
15305
16432
  const { asset, upload } = orThrow(await handlers.assets.reserve({
15306
16433
  ...input,
15307
16434
  personId: ctx.viewer.personId
@@ -15314,7 +16441,7 @@ const createCanvasAssetRouter = (handlers) => trpcRouter({
15314
16441
  }
15315
16442
  };
15316
16443
  }),
15317
- complete: canvasCommenterProcedure.meta({ description: "Verify uploaded asset bytes and format, and persist resource readiness. Does not place content or change the canvas document." }).input(canvasAssetUploadIdentitySchema).output(canvasAssetUploadOutputSchema).mutation(async ({ input, ctx }) => toCanvasAssetUploadContract(orThrow(await handlers.assets.complete({
16444
+ complete: canvasEditorProcedure.meta({ description: "Verify uploaded asset bytes and format, and persist resource readiness. Does not place content or change the canvas document." }).input(canvasAssetUploadIdentitySchema).output(canvasAssetUploadOutputSchema).mutation(async ({ input, ctx }) => toCanvasAssetUploadContract(orThrow(await handlers.assets.complete({
15318
16445
  ...input,
15319
16446
  personId: ctx.viewer.personId
15320
16447
  })))),
@@ -15361,7 +16488,8 @@ const canvasRouter = (handlers, options) => trpcRouter({
15361
16488
  render: trpcRouter({
15362
16489
  ...createRenderRouter(handlers.render)._def.record,
15363
16490
  preparation: createCanvasPreparationRouter(handlers.render),
15364
- ...createRenderExposureRouter(handlers.render)._def.record
16491
+ ...createRenderExposureRouter(handlers.render)._def.record,
16492
+ ...createRenderExportRouter(handlers.render)._def.record
15365
16493
  }),
15366
16494
  thumbnail: createCanvasThumbnailRouter(),
15367
16495
  participants: createCanvasParticipantRouter(handlers.canvas),
@@ -15408,6 +16536,12 @@ const unavailable = { execute: () => {
15408
16536
  } };
15409
16537
  const handlers = {
15410
16538
  capture: {
16539
+ review: {
16540
+ read: unavailable.execute,
16541
+ decide: unavailable.execute,
16542
+ reference: unavailable.execute,
16543
+ promote: unavailable.execute
16544
+ },
15411
16545
  begin: unavailable.execute,
15412
16546
  get: unavailable.execute,
15413
16547
  reserve: unavailable.execute,
@@ -15425,6 +16559,7 @@ const handlers = {
15425
16559
  update: unavailable,
15426
16560
  remove: unavailable,
15427
16561
  setMemberRole: unavailable,
16562
+ setMemberContentAccess: unavailable,
15428
16563
  removeMember: unavailable,
15429
16564
  transferOwnership: unavailable,
15430
16565
  createInvite: unavailable,
@@ -16167,4 +17302,4 @@ const withCommandInFailure = (value, commandName) => ({
16167
17302
  });
16168
17303
 
16169
17304
  //#endregion
16170
- export { canvasRenderPendingSchema as $, canvasRenderTargetSchema as $n, createOrganisationOutputSchema as $t, operationStatusOutputSchema as A, canvasReferencePageOf as An, PartialBatchError as At, canvasCaptureCapabilityInputSchema as B, applyCanvasOperationsOutputSchema as Bn, PROTOTYPE_ARTIFACT_MANIFEST_PATH as Bt, canvasSnapshotToken as C, canvasTextPropsWithContent as Cn, canvasEditsSchema as Ct, canvasConversionStatusSchema as D, canvasPrototypePropsSchema as Dn, fromCanvasReference as Dt, resolveCanvasSnapshot as E, canvasConversionMetadataSchema as En, canvasReferenceRenderTarget as Et, canvasArrangeInputSchema as F, agentClientMetadata as Fn, createScreenOutputSchema as Ft, canvasRenderCapabilityInputSchema as G, getCanvasDocumentOutputSchema as Gn, getPrototypePublishStatusOutputSchema as Gt, canvasCaptureOutputSchema as H, canvasLayoutWithoutCssProperties as Hn, createPrototypeArtifactOutputSchema as Ht, canvasDuplicateCapabilityInputSchema as I, createCanvasPreparationOutputSchema as In, appendRecordingChunkOutputSchema as It, prototypePublishCapabilityInputSchema as J, canvasNodeStylePatchSchema as Jn, submitPrototypeArtifactOutputSchema as Jt, canvasWriteHtmlCapabilityInputSchema as K, saveCanvasDocumentOutputSchema as Kn, prototypeArtifactManifestSchema as Kt, canvasDuplicateInputSchema as L, getCanvasPreparationOutputSchema as Ln, completeRecordingOutputSchema as Lt, canvasAssetImportInputSchema as M, beginCanvasActivityOutputSchema as Mn, transcriptOutputSchema as Mt, canvasAssetImportOutputSchema as N, canvasAgentActivityPhaseSchema as Nn, appErrorSchema as Nt, operationStatusImageSchema as O, canvasRecordingPropsSchema as On, hasCanvasReferenceScope as Ot, canvasArrangeCapabilityInputSchema as P, AGENT_CLIENT_HEADER as Pn, completeScreenOutputSchema as Pt, canvasRenderBatchResultSchema as Q, canvasRenderStateSchema as Qn, createAgentTokenOutputSchema as Qt, canvasPreparationOutputSchema as R, PAGE_KIND as Rn, getRecordingOutputSchema as Rt, canvasExchangeDigest as S, canvasTextChangeBetween as Sn, canvasEditCapabilityInputSchema as St, encodeCanvasExchangeToken as T, canvasCaptureSchema as Tn, canvasReferenceNodeIds as Tt, canvasApplyCapabilityInputSchema as U, textOf as Un, foldPrototypeArtifactPath as Ut, canvasCaptureInputSchema as V, getCanvasMutationOutputSchema as Vn, attachPrototypeArtifactOutputSchema as Vt, canvasReadCapabilityInputSchema as W, mapCanvasFontSources as Wn, getPrototypeArtifactCapabilitiesOutputSchema as Wt, transcriptReadCapabilityInputSchema as X, getCanvasConversionOutputSchema as Xn, MCP_AUTH_SCOPE as Xt, recordingSnapshotCapabilityInputSchema as Y, createCanvasConversionOutputSchema as Yn, getMeOutputSchema as Yt, canvasRenderBatchRequestSchema as Z, canvasRenderSourceStateSchema as Zn, cliAuthConfigurationSchema as Zt, PROCEDURE_DESCRIPTIONS as _, screenElementsCommentTargetSchema as _n, canvasImageAssetIdentityFromPath as _r, canvasFindOutputSchema as _t, toFailurePayload as a, commentMessageSchema as an, canvasReadableSceneDocumentSchema as ar, canvasRemoveInputSchema as at, canvasPrototypeIntentSchema as b, applyCanvasTypographyPatch as bn, createCanvasOutputSchema as br, canvasMakeEditableCapabilityInputSchema as bt, toPresentedCapabilities as c, domLocatorSchema as cn, canvasAuthoredStyleDeclarations as cr, canvasReadOutputSchema as ct, ProcessExitError as d, listCommentsInputSchema as dn, canvasLayoutPriorityDeclarations as dr, canvasTranscriptCursorSchema as dt, listOrganisationsOutputSchema as en, canvasWorldBoundsSchema as er, canvasRenderScopedInputSchema as et, createCapabilityCatalogAdapter as f, listCommentsOutputSchema as fn, canvasCssValue as fr, canvasResourcesCursorSchema as ft, OPTION_DESCRIPTIONS as g, screenElementCommentTargetSchema as gn, canvasFontAssetIdentityFromPath as gr, canvasFindInputSchema as gt, toCapabilityDefinition as h, screenAreaCommentTargetSchema as hn, reserveCanvasAssetOutputSchema as hr, canvasFindCursorSchema as ht, toExitCode as i, commentCanvasContextSchema as in, getCanvasRenderOutputSchema as ir, canvasRemoveCapabilityInputSchema as it, canvasAssetImportCapabilityInputSchema as j, resolveCanvasReference as jn, CliError as jt, operationStatusInputSchema as k, DEFAULT_CANVAS_REFERENCE_PAGE_ID as kn, parseCanvasReference as kt, toSharedCapabilities as l, elementAnchorSchema as ln, canvasAxisStyleProperties as lr, canvasUpdateHtmlCapabilityInputSchema as lt, createCapabilityPolicyAdapter as m, replyCommentOutputSchema as mn, reserveCanvasAssetInputSchema as mr, canvasCreateToolOutputSchema as mt, withCommandName as n, withFixtureScreen as nn, createRecordingSnapshotOutputSchema as nr, canvasRenderRequestSchema as nt, toMcpFailurePayload as o, commentResolverSchema as on, canvasSceneDocumentSchema as or, canvasOutlineCursorSchema as ot, createRouterShapeAdapter as p, replyCommentInputSchema as pn, canvasAssetUploadOutputSchema as pr, canvasCreateToolInputSchema as pt, commentAttentionCapabilityInputSchema as q, canvasOperationSchema as qn, prototypeArtifactPathSchema as qt, toCanvasAuthoringResult as r, commentAuthorSchema as rn, downloadCanvasRenderOutputSchema as rr, canvasRenderFileSchema as rt, toRemoteError as s, commentThreadSchema as sn, canvasAuthoredLayoutValueOf as sr, canvasReadInputSchema as st, withCommandInFailure as t, emptyFixtureDocument as tn, createCanvasRenderOutputSchema as tr, canvasRenderScopedToolInputSchema as tt, createMcpCapabilityDiscoveryAdapter as u, getCommentOutputSchema as un, canvasLayoutMainAxisOf as ur, canvasUpdateHtmlInputSchema as ut, canvasPrototypeCapabilityInputSchema as v, screenTextCommentTargetSchema as vn, canvasAdditionalStyleSchema as vr, canvasInsertHtmlCapabilityInputSchema as vt, decodeCanvasExchangeToken as w, canvasTextRunsOf as wn, assertCanvasReferenceNodes as wt, canvasPrototypeOutputSchema as x, canvasCssTypographyOwners as xn, listCanvasesOutputSchema as xr, canvasMakeEditableInputSchema as xt, canvasPrototypeInputSchema as y, startCommentInputSchema as yn, canvasSchema as yr, canvasInsertHtmlInputSchema as yt, canvasWriteReceiptSchema as z, applyCanvasOperationsInputSchema as zn, startRecordingOutputSchema as zt };
17305
+ export { canvasRenderPendingSchema as $, canvasNodeStylePatchSchema as $n, createOrganisationOutputSchema as $t, operationStatusOutputSchema as A, canvasReferencePageOf as An, canvasBlendModeSchema as Ar, PartialBatchError as At, canvasCaptureCapabilityInputSchema as B, IMAGE_KIND as Bn, PROTOTYPE_ARTIFACT_MANIFEST_PATH as Bt, canvasSnapshotToken as C, canvasTextPropsWithContent as Cn, canvasImageAssetIdentityFromPath as Cr, canvasEditsSchema as Ct, canvasConversionStatusSchema as D, canvasPrototypePropsSchema as Dn, CANVAS_RICH_TEXT_STYLE_PROPERTIES as Dr, fromCanvasReference as Dt, resolveCanvasSnapshot as E, canvasConversionMetadataSchema as En, hasCanvasRichTextPaints as Er, canvasReferenceRenderTarget as Et, canvasArrangeInputSchema as F, agentClientMetadata as Fn, createScreenOutputSchema as Ft, canvasRenderCapabilityInputSchema as G, applyCanvasOperationsOutputSchema as Gn, getPrototypePublishStatusOutputSchema as Gt, canvasCaptureOutputSchema as H, RECTANGLE_KIND as Hn, createPrototypeArtifactOutputSchema as Ht, canvasDuplicateCapabilityInputSchema as I, createCanvasPreparationOutputSchema as In, appendRecordingChunkOutputSchema as It, prototypePublishCapabilityInputSchema as J, textOf as Jn, submitPrototypeArtifactOutputSchema as Jt, canvasWriteHtmlCapabilityInputSchema as K, getCanvasMutationOutputSchema as Kn, prototypeArtifactManifestSchema as Kt, canvasDuplicateInputSchema as L, getCanvasPreparationOutputSchema as Ln, completeRecordingOutputSchema as Lt, canvasAssetImportInputSchema as M, beginCanvasActivityOutputSchema as Mn, canvasSchema as Mr, transcriptOutputSchema as Mt, canvasAssetImportOutputSchema as N, canvasAgentActivityPhaseSchema as Nn, createCanvasOutputSchema as Nr, appErrorSchema as Nt, operationStatusImageSchema as O, canvasRecordingPropsSchema as On, canvasAdditionalStyleSchema as Or, hasCanvasReferenceScope as Ot, canvasArrangeCapabilityInputSchema as P, AGENT_CLIENT_HEADER as Pn, listCanvasesOutputSchema as Pr, completeScreenOutputSchema as Pt, canvasRenderBatchResultSchema as Q, canvasOperationSchema as Qn, createAgentTokenOutputSchema as Qt, canvasPreparationOutputSchema as R, FRAME_KIND as Rn, getRecordingOutputSchema as Rt, canvasExchangeDigest as S, canvasTextChangeBetween as Sn, canvasFontAssetIdentityFromPath as Sr, canvasEditCapabilityInputSchema as St, encodeCanvasExchangeToken as T, canvasCaptureSchema as Tn, canvasRichTextValueOf as Tr, canvasReferenceNodeIds as Tt, canvasApplyCapabilityInputSchema as U, TEXT_KIND as Un, foldPrototypeArtifactPath as Ut, canvasCaptureInputSchema as V, PAGE_KIND as Vn, attachPrototypeArtifactOutputSchema as Vt, canvasReadCapabilityInputSchema as W, applyCanvasOperationsInputSchema as Wn, getPrototypeArtifactCapabilitiesOutputSchema as Wt, transcriptReadCapabilityInputSchema as X, getCanvasDocumentOutputSchema as Xn, MCP_AUTH_SCOPE as Xt, recordingSnapshotCapabilityInputSchema as Y, mapCanvasFontSources as Yn, getMeOutputSchema as Yt, canvasRenderBatchRequestSchema as Z, saveCanvasDocumentOutputSchema as Zn, cliAuthConfigurationSchema as Zt, PROCEDURE_DESCRIPTIONS as _, screenElementsCommentTargetSchema as _n, canvasCssTokens as _r, canvasFindOutputSchema as _t, toFailurePayload as a, commentMessageSchema as an, canvasWorldBoundsSchema as ar, canvasRemoveInputSchema as at, canvasPrototypeIntentSchema as b, applyCanvasTypographyPatch as bn, reserveCanvasAssetInputSchema as br, canvasMakeEditableCapabilityInputSchema as bt, toPresentedCapabilities as c, domLocatorSchema as cn, downloadCanvasRenderOutputSchema as cr, canvasReadOutputSchema as ct, ProcessExitError as d, listCommentsInputSchema as dn, canvasSceneDocumentSchema as dr, canvasTranscriptCursorSchema as dt, listOrganisationsOutputSchema as en, createCanvasConversionOutputSchema as er, canvasRenderScopedInputSchema as et, createCapabilityCatalogAdapter as f, listCommentsOutputSchema as fn, canvasAuthoredLayoutValueOf as fr, canvasResourcesCursorSchema as ft, OPTION_DESCRIPTIONS as g, screenElementCommentTargetSchema as gn, canvasLayoutPriorityDeclarations as gr, canvasFindInputSchema as gt, toCapabilityDefinition as h, screenAreaCommentTargetSchema as hn, canvasLayoutMainAxisOf as hr, canvasFindCursorSchema as ht, toExitCode as i, commentCanvasContextSchema as in, canvasRenderTargetSchema as ir, canvasRemoveCapabilityInputSchema as it, canvasAssetImportCapabilityInputSchema as j, resolveCanvasReference as jn, canvasPaintSchema as jr, CliError as jt, operationStatusInputSchema as k, DEFAULT_CANVAS_REFERENCE_PAGE_ID as kn, CANVAS_BLEND_MODES as kr, parseCanvasReference as kt, toSharedCapabilities as l, elementAnchorSchema as ln, getCanvasRenderOutputSchema as lr, canvasUpdateHtmlCapabilityInputSchema as lt, createCapabilityPolicyAdapter as m, replyCommentOutputSchema as mn, canvasAxisStyleProperties as mr, canvasCreateToolOutputSchema as mt, withCommandName as n, withFixtureScreen as nn, canvasRenderSourceStateSchema as nr, canvasRenderRequestSchema as nt, toMcpFailurePayload as o, commentResolverSchema as on, createCanvasRenderOutputSchema as or, canvasOutlineCursorSchema as ot, createRouterShapeAdapter as p, replyCommentInputSchema as pn, canvasAuthoredStyleDeclarations as pr, canvasCreateToolInputSchema as pt, commentAttentionCapabilityInputSchema as q, canvasLayoutWithoutCssProperties as qn, prototypeArtifactPathSchema as qt, toCanvasAuthoringResult as r, commentAuthorSchema as rn, canvasRenderStateSchema as rr, canvasRenderFileSchema as rt, toRemoteError as s, commentThreadSchema as sn, createRecordingSnapshotOutputSchema as sr, canvasReadInputSchema as st, withCommandInFailure as t, emptyFixtureDocument as tn, getCanvasConversionOutputSchema as tr, canvasRenderScopedToolInputSchema as tt, createMcpCapabilityDiscoveryAdapter as u, getCommentOutputSchema as un, canvasReadableSceneDocumentSchema as ur, canvasUpdateHtmlInputSchema as ut, canvasPrototypeCapabilityInputSchema as v, screenTextCommentTargetSchema as vn, canvasCssValue as vr, canvasInsertHtmlCapabilityInputSchema as vt, decodeCanvasExchangeToken as w, canvasTextRunsOf as wn, canvasRichTextOf as wr, assertCanvasReferenceNodes as wt, canvasPrototypeOutputSchema as x, canvasCssTypographyOwners as xn, reserveCanvasAssetOutputSchema as xr, canvasMakeEditableInputSchema as xt, canvasPrototypeInputSchema as y, startCommentInputSchema as yn, canvasAssetUploadOutputSchema as yr, canvasInsertHtmlInputSchema as yt, canvasWriteReceiptSchema as z, GROUP_KIND as zn, startRecordingOutputSchema as zt };