@enhance-eng/enhance 0.1.37 → 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({});
@@ -182,7 +510,9 @@ const listCanvasesInputSchema = z.object({
182
510
  });
183
511
  const canvasCardBaseSchema = canvasSchema.extend({
184
512
  screenCount: z.number().int().min(0),
185
- 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()
186
516
  });
187
517
  const canvasCardSchema = z.union([canvasCardBaseSchema.extend({ thumbnail: canvasThumbnailPreviewSchema }), canvasCardBaseSchema.extend({
188
518
  thumbnail: z.null(),
@@ -224,7 +554,10 @@ const setCanvasAccessOutputSchema = z.object({
224
554
  widened: z.boolean()
225
555
  });
226
556
  const markCanvasViewedInputSchema = z.object({ canvasId: z.uuid() });
227
- /** `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
+ */
228
561
  const markCanvasViewedOutputSchema = z.object({ lastViewedAt: z.iso.datetime().nullable() });
229
562
  const restoreCanvasInputSchema = z.object({ canvasId: z.uuid() });
230
563
  const restoreCanvasOutputSchema = z.object({ canvasId: z.uuid() });
@@ -261,16 +594,61 @@ const canvasGradientStopSchema = z.object({
261
594
  position: ratio$1,
262
595
  color: canvasColorSchema
263
596
  });
264
- const adjustment = z.number().min(-1).max(1);
265
- const canvasImageAdjustmentsSchema = z.object({
266
- exposure: adjustment.optional(),
267
- contrast: adjustment.optional(),
268
- saturation: adjustment.optional(),
269
- temperature: adjustment.optional(),
270
- tint: adjustment.optional(),
271
- highlights: adjustment.optional(),
272
- shadows: adjustment.optional()
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()
273
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]);
274
652
  /** Maps normalized source (u,v) into body (a*u+c*v+e,b*u+d*v+f), before node rotation. */
275
653
  const canvasPaintTransformSchema = z.tuple([
276
654
  boundedNumber$1,
@@ -374,7 +752,12 @@ const canvasPaintCoreSchema = z.discriminatedUnion("kind", [
374
752
  height: ratio$1
375
753
  }).optional(),
376
754
  transform: canvasPaintTransformSchema.optional(),
377
- adjustments: canvasImageAdjustmentsSchema.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()
378
761
  }).refine((paint) => paint.crop === void 0 || paint.transform === void 0, {
379
762
  message: "image paint cannot have both a crop rectangle and an affine transform",
380
763
  path: ["transform"]
@@ -541,6 +924,14 @@ const canvasCornerRadiusSchema = z.object({
541
924
  bottomLeft: nonNegativeNumber$1,
542
925
  smoothing: ratio.optional()
543
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
+ ]);
544
935
  const canvasBorderSchema = z.object({
545
936
  visible: z.boolean(),
546
937
  /** Absent reserves CSS widths; visible reserves only visible paint, while none separates paint from layout. */
@@ -560,7 +951,15 @@ const canvasBorderSchema = z.object({
560
951
  "dashed",
561
952
  "dotted"
562
953
  ]),
563
- 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()
564
963
  });
565
964
  const retainedBorderSchema = canvasBorderSchema.pick({
566
965
  width: true,
@@ -576,7 +975,9 @@ const canvasOutlineSchema = z.object({
576
975
  "dashed",
577
976
  "dotted"
578
977
  ]),
579
- paint: canvasPaintSchema
978
+ paints: z.array(canvasPaintSchema),
979
+ dashPattern: canvasDashPatternSchema.optional(),
980
+ dashCap: canvasDashCapSchema.optional()
580
981
  });
581
982
  const canvasShadowSchema = z.object({
582
983
  id: itemId,
@@ -591,57 +992,6 @@ const canvasShadowSchema = z.object({
591
992
  blendSource: canvasBlendSourceSchema.optional(),
592
993
  isShownBehindNode: z.boolean().optional()
593
994
  });
594
- const canvasFilterBaseSchema = z.object({
595
- id: itemId,
596
- visible: z.boolean()
597
- });
598
- const canvasFilterSchema = z.discriminatedUnion("kind", [
599
- canvasFilterBaseSchema.extend({
600
- kind: z.literal("blur"),
601
- value: nonNegativeNumber$1,
602
- parameter: z.enum(["radius", "standard-deviation"]).optional(),
603
- /** Endpoints use normalized body coordinates; startValue uses the filter's authored unit. */
604
- progression: z.object({
605
- startValue: nonNegativeNumber$1,
606
- start: z.object({
607
- x: boundedNumber,
608
- y: boundedNumber
609
- }),
610
- end: z.object({
611
- x: boundedNumber,
612
- y: boundedNumber
613
- })
614
- }).optional()
615
- }),
616
- canvasFilterBaseSchema.extend({
617
- kind: z.literal("brightness"),
618
- value: nonNegativeNumber$1
619
- }),
620
- canvasFilterBaseSchema.extend({
621
- kind: z.literal("contrast"),
622
- value: nonNegativeNumber$1
623
- }),
624
- canvasFilterBaseSchema.extend({
625
- kind: z.literal("grayscale"),
626
- value: ratio
627
- }),
628
- canvasFilterBaseSchema.extend({
629
- kind: z.literal("hue-rotate"),
630
- value: boundedNumber
631
- }),
632
- canvasFilterBaseSchema.extend({
633
- kind: z.literal("invert"),
634
- value: ratio
635
- }),
636
- canvasFilterBaseSchema.extend({
637
- kind: z.literal("saturate"),
638
- value: nonNegativeNumber$1
639
- }),
640
- canvasFilterBaseSchema.extend({
641
- kind: z.literal("sepia"),
642
- value: ratio
643
- })
644
- ]);
645
995
  const canvasAppearanceSchema = z.object({
646
996
  opacity: ratio,
647
997
  blendMode: canvasBlendModeSchema,
@@ -652,7 +1002,7 @@ const canvasAppearanceSchema = z.object({
652
1002
  radius: canvasCornerRadiusSchema,
653
1003
  shadows: z.array(canvasShadowSchema),
654
1004
  filters: z.array(canvasFilterSchema),
655
- backdropFilters: z.array(canvasFilterSchema)
1005
+ backdropFilters: z.array(canvasBackdropFilterSchema)
656
1006
  });
657
1007
  const canvasAppearanceValuesSchema = canvasAppearanceSchema.partial().refine((values) => Object.keys(values).length > 0, "appearance values cannot be empty");
658
1008
  const CANVAS_APPEARANCE_PROPERTIES = [
@@ -772,11 +1122,8 @@ const canvasTypographySchema = z.object({
772
1122
  stroke: z.object({
773
1123
  width: nonNegativeNumber,
774
1124
  paint: canvasPaintSchema,
775
- alignment: z.enum([
776
- "inside",
777
- "center",
778
- "outside"
779
- ]).optional()
1125
+ /** CSS strokes text on the glyph outline or, painted under the fill, outside it. */
1126
+ alignment: z.enum(["center", "outside"]).optional()
780
1127
  }).optional(),
781
1128
  wrapping: z.enum([
782
1129
  "wrap",
@@ -878,6 +1225,7 @@ const CANVAS_TYPOGRAPHY_CSS_OWNERS = {
878
1225
  "-webkit-text-stroke-width": ["stroke"],
879
1226
  "-webkit-text-stroke-color": ["stroke"],
880
1227
  "--canvas-text-stroke-alignment": ["stroke"],
1228
+ "paint-order": ["stroke"],
881
1229
  "white-space": ["wrapping"],
882
1230
  "text-wrap-style": ["wrapStyle"],
883
1231
  "text-wrap": ["wrapStyle"]
@@ -1078,6 +1426,8 @@ const canvasTextStyleBindingSchema = z.object({
1078
1426
  //#endregion
1079
1427
  //#region ../../packages/contract/src/canvas/canvas-rich-text.lib.ts
1080
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 });
1081
1431
  const characterFormattingSchema = canvasTextParagraphSchema.pick({
1082
1432
  paragraphSpacing: true,
1083
1433
  paragraphIndent: true,
@@ -1218,6 +1568,16 @@ const canvasRichTextOf = (node) => {
1218
1568
  const text = props["text"];
1219
1569
  return canvasRichTextValueOf(rich) === text ? rich : [];
1220
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
+ };
1221
1581
  /** Existing-link edits retain authored formatting, including nested descendants. */
1222
1582
  const canvasRichTextLinkOf = (runs) => {
1223
1583
  const destinations = /* @__PURE__ */ new Set();
@@ -1228,6 +1588,15 @@ const canvasRichTextLinkOf = (runs) => {
1228
1588
  visit(runs);
1229
1589
  return destinations.size === 1 ? [...destinations][0] ?? null : null;
1230
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
+ ]];
1231
1600
 
1232
1601
  //#endregion
1233
1602
  //#region ../../packages/contract/src/shared/blob.schema.ts
@@ -1654,89 +2023,6 @@ const canvasLayoutMainAxisOf = (node, document) => {
1654
2023
  return direction.startsWith("column") === isVerticalWriting ? "horizontal" : "vertical";
1655
2024
  };
1656
2025
 
1657
- //#endregion
1658
- //#region ../../packages/contract/src/canvas/canvas-compositing.schema.ts
1659
- const canvasCompositingSchema = z.strictObject({
1660
- groupMode: z.enum(["pass-through", "isolated"]).optional(),
1661
- mask: z.enum([
1662
- "alpha",
1663
- "luminance",
1664
- "vector"
1665
- ]).optional(),
1666
- /** Absence retains the stored document's legacy paint and isolation behavior. */
1667
- paintSemantics: z.literal("web").optional()
1668
- }).refine((value) => value.groupMode !== void 0 || value.mask !== void 0 || value.paintSemantics !== void 0, "compositing intent cannot be empty");
1669
-
1670
- //#endregion
1671
- //#region ../../packages/canvas-format/src/canvas-format.consts.ts
1672
- /** Historical formats stay pinned; an ordinary writer always uses CANVAS_SCENE_VERSION. */
1673
- const LEGACY_CANVAS_FORMATS = {
1674
- unversioned: void 0,
1675
- v1: 1,
1676
- v2: 2,
1677
- v3: 3,
1678
- v4: 4,
1679
- v5: 5,
1680
- v6: 6,
1681
- v7: 7,
1682
- v8: 8,
1683
- v9: 9,
1684
- v10: 10
1685
- };
1686
- const LEGACY_CANVAS_ADAPTATIONS = {
1687
- [LEGACY_CANVAS_FORMATS.v1]: "layout",
1688
- [LEGACY_CANVAS_FORMATS.v2]: "layout",
1689
- [LEGACY_CANVAS_FORMATS.v3]: "typography",
1690
- [LEGACY_CANVAS_FORMATS.v4]: "typography",
1691
- [LEGACY_CANVAS_FORMATS.v5]: "typography",
1692
- [LEGACY_CANVAS_FORMATS.v6]: "geometry",
1693
- [LEGACY_CANVAS_FORMATS.v7]: "geometry",
1694
- [LEGACY_CANVAS_FORMATS.v8]: "geometry",
1695
- [LEGACY_CANVAS_FORMATS.v9]: "geometry",
1696
- [LEGACY_CANVAS_FORMATS.v10]: "geometry"
1697
- };
1698
-
1699
- //#endregion
1700
- //#region ../../packages/canvas-format/src/canvas-format.lib.ts
1701
- const READABLE_FORMATS = /* @__PURE__ */ new Set([...Object.values(LEGACY_CANVAS_FORMATS), 11]);
1702
- const isReadableCanvasFormat = (version) => READABLE_FORMATS.has(version);
1703
- const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1704
- const legacyLayout = (layout) => {
1705
- if (!isRecord$1(layout)) return layout;
1706
- const next = Object.fromEntries(Object.entries(layout).filter(([key]) => key !== "gridTrack"));
1707
- const container = next["container"];
1708
- if (isRecord$1(container)) next["container"] = Object.fromEntries(Object.entries(container).filter(([key]) => key !== "materialized"));
1709
- for (const axis of ["horizontal", "vertical"]) {
1710
- const intent = next[axis];
1711
- if (isRecord$1(intent) && intent["mode"] === "hug") next[axis] = Object.fromEntries(Object.entries(intent).filter(([key]) => key !== "basis"));
1712
- }
1713
- return next;
1714
- };
1715
- /** Adapt known formats in memory, retaining malformed content for each boundary's validator. */
1716
- const adaptCanvasDocumentFormat = (document) => {
1717
- const version = document["version"];
1718
- if (!isReadableCanvasFormat(version)) return null;
1719
- if (version === 11 || !isRecord$1(document["nodes"])) return document;
1720
- const adaptation = Object.entries(LEGACY_CANVAS_ADAPTATIONS).find(([format]) => Number(format) === version)?.[1];
1721
- if (adaptation === "geometry") return {
1722
- ...document,
1723
- version: 11
1724
- };
1725
- if (Object.values(document["nodes"]).some((node) => isRecord$1(node) && node["geometry"] !== void 0)) return null;
1726
- if (adaptation === "typography") return {
1727
- ...document,
1728
- version: 11
1729
- };
1730
- return {
1731
- ...document,
1732
- version: 11,
1733
- nodes: Object.fromEntries(Object.entries(document["nodes"]).map(([id, node]) => [id, isRecord$1(node) && node["layout"] !== void 0 ? {
1734
- ...node,
1735
- layout: legacyLayout(node["layout"])
1736
- } : node]))
1737
- };
1738
- };
1739
-
1740
2026
  //#endregion
1741
2027
  //#region ../../packages/contract/src/canvas/canvas-export-settings.schema.ts
1742
2028
  const format = z.enum(["png", "jpeg"]);
@@ -1803,14 +2089,21 @@ const canvasGeometrySchema = z.discriminatedUnion("kind", [
1803
2089
  canvasPolygonGeometrySchema,
1804
2090
  z.strictObject({
1805
2091
  kind: z.literal("mask"),
1806
- 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()
1807
2099
  }),
1808
2100
  canvasBooleanGeometrySchema
1809
2101
  ]);
1810
2102
 
1811
2103
  //#endregion
1812
2104
  //#region ../../packages/contract/src/canvas/canvas-scene.schema.ts
1813
- const canvasDocumentFormatSchema = z.literal(11, { 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." });
1814
2107
  const canvasPreservedFontAppearanceSchema = z.object({
1815
2108
  signature: z.string().regex(/^[a-f0-9]{16}$/u),
1816
2109
  image: z.string().startsWith("data:image/jpeg;base64,"),
@@ -1855,12 +2148,12 @@ const canvasSceneNodeSchema = z.looseObject({
1855
2148
  typography: canvasAuthoredTypographySchema.optional(),
1856
2149
  additionalStyles: canvasAdditionalStylesSchema.optional(),
1857
2150
  geometry: canvasGeometrySchema.optional(),
1858
- compositing: canvasCompositingSchema.optional(),
2151
+ compositing: z.never({ error: CANVAS_COMPOSITING_RETIRED }).optional(),
1859
2152
  props: z.record(z.string(), z.unknown()).optional(),
1860
2153
  box: canvasSceneBoxSchema.optional()
1861
2154
  });
1862
2155
  const canvasSceneDocumentSchema = z.object({
1863
- version: z.literal(11),
2156
+ version: z.literal(13),
1864
2157
  nodes: z.record(z.string(), canvasSceneNodeSchema),
1865
2158
  relationships: z.record(z.string(), z.object({
1866
2159
  parentId: z.string().min(1),
@@ -1877,7 +2170,7 @@ const canvasReadableSceneDocumentSchema = z.preprocess((value) => {
1877
2170
  return adaptCanvasDocumentFormat(blob);
1878
2171
  }, canvasSceneDocumentSchema);
1879
2172
  const emptyCanvasSceneDocument = () => ({
1880
- version: 11,
2173
+ version: 13,
1881
2174
  nodes: { root: {
1882
2175
  id: "root",
1883
2176
  label: "Canvas",
@@ -1907,8 +2200,37 @@ const canvasConversionIssueSchema = z.object({
1907
2200
  message: z.string().min(1),
1908
2201
  temporaryId: temporaryIdSchema.optional()
1909
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);
1910
2228
  const canvasConversionReportSchema = z.object({
1911
2229
  nodeCount: z.number().int().positive(),
2230
+ unsupportedFeatures: z.array(z.object({
2231
+ feature: canvasUnsupportedFeatureSchema,
2232
+ count: z.number().int().positive()
2233
+ })).optional(),
1912
2234
  sourceNodeCount: z.number().int().positive().optional(),
1913
2235
  collapsedNodeCount: z.number().int().nonnegative().optional(),
1914
2236
  collapsedWrapperNodeCount: z.number().int().nonnegative().optional(),
@@ -2124,7 +2446,8 @@ const canvasRenderJobBaseSchema = z.object({
2124
2446
  purpose: z.enum([
2125
2447
  "inspection",
2126
2448
  "snapshot",
2127
- "thumbnail"
2449
+ "thumbnail",
2450
+ "export"
2128
2451
  ]),
2129
2452
  phase: canvasRenderPhaseSchema,
2130
2453
  requestedVersion: z.number().int().positive(),
@@ -2202,6 +2525,13 @@ const canvasRenderSourceSchema = z.discriminatedUnion("status", [z.object({
2202
2525
  status: z.literal("unavailable"),
2203
2526
  guidance: z.string()
2204
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
+ });
2205
2535
  const downloadCanvasRenderInputSchema = z.object({ jobId: z.uuid() });
2206
2536
  const downloadCanvasRenderOutputSchema = z.object({
2207
2537
  jobId: z.uuid(),
@@ -2582,6 +2912,7 @@ const canvasKnownNodeStylePatchSchema = canvasTextStylePatchSchema.extend(canvas
2582
2912
  "inset-inline": layoutStylePatchValue,
2583
2913
  "inset-inline-end": layoutStylePatchValue,
2584
2914
  "inset-inline-start": layoutStylePatchValue,
2915
+ isolation: layoutStylePatchValue,
2585
2916
  "justify-content": layoutStylePatchValue,
2586
2917
  left: layoutStylePatchValue,
2587
2918
  margin: layoutStylePatchValue,
@@ -2801,7 +3132,7 @@ const canvasSetStylesOperationSchema = z.object({
2801
3132
  styles: canvasNodeStylePatchSchema,
2802
3133
  clear: z.array(canvasRestorableStylePropertySchema).min(1).refine((properties) => new Set(properties).size === properties.length).optional()
2803
3134
  }).refine((operation) => (operation.clear ?? []).every((property) => !Object.hasOwn(operation.styles, property)));
2804
- const canvasOperationSchema = z.discriminatedUnion("op", [
3135
+ const currentCanvasOperationSchema = z.discriminatedUnion("op", [
2805
3136
  insertConvertedSubtreeOperationSchema,
2806
3137
  z.object({
2807
3138
  op: z.literal("insertNode"),
@@ -2812,7 +3143,9 @@ const canvasOperationSchema = z.discriminatedUnion("op", [
2812
3143
  nodeId: nodeIdSchema$3,
2813
3144
  documentVersion: z.number().int().nonnegative(),
2814
3145
  versionEntryId: z.uuid().optional()
2815
- }).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()
2816
3149
  }),
2817
3150
  placementSchema.extend({
2818
3151
  op: z.literal("insertText"),
@@ -2939,11 +3272,6 @@ const canvasOperationSchema = z.discriminatedUnion("op", [
2939
3272
  nodeId: nodeIdSchema$3,
2940
3273
  geometry: z.union([canvasGeometrySchema, z.literal("default")])
2941
3274
  }),
2942
- z.object({
2943
- op: z.literal("setCompositing"),
2944
- nodeId: nodeIdSchema$3,
2945
- compositing: z.union([canvasCompositingSchema, z.literal("default")])
2946
- }),
2947
3275
  z.object({
2948
3276
  op: z.literal("setProps"),
2949
3277
  nodeId: nodeIdSchema$3,
@@ -2964,6 +3292,16 @@ const canvasOperationSchema = z.discriminatedUnion("op", [
2964
3292
  removedText: z.record(nodeIdSchema$3, canvasSceneNodeSchema.pick({ props: true })).optional()
2965
3293
  })
2966
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);
2967
3305
  const createEditableFrameOutputSchema = createEditableFrameResultSchema.extend({
2968
3306
  operation: insertConvertedSubtreeOperationSchema,
2969
3307
  next: z.array(z.string().min(1))
@@ -2979,6 +3317,11 @@ const getCanvasDocumentInputSchema = z.object({
2979
3317
  });
2980
3318
  const documentScreenSchema = z.object({
2981
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(),
2982
3325
  /** Null for a link visitor. Always present on the agent surface. */
2983
3326
  route: z.string().nullable(),
2984
3327
  title: z.string().nullable(),
@@ -3165,7 +3508,6 @@ const inspectCanvasNodeOutputSchema = z.object({
3165
3508
  styles: z.record(z.string(), z.union([z.string(), z.number()])),
3166
3509
  layout: canvasNodeLayoutSchema.optional(),
3167
3510
  appearance: canvasAppearanceValuesSchema.optional(),
3168
- compositing: canvasCompositingSchema.optional(),
3169
3511
  geometry: canvasGeometrySchema.optional(),
3170
3512
  typography: canvasAuthoredTypographySchema.optional(),
3171
3513
  additionalStyles: canvasAdditionalStylesSchema.optional(),
@@ -3216,7 +3558,7 @@ const releasedGridPolicy = (held, properties) => {
3216
3558
  return layout;
3217
3559
  };
3218
3560
  /** A shorthand can release several named controls; a longhand releases only itself. */
3219
- const releasedFields = (held, changed) => {
3561
+ const canvasLayoutReleasedFields = (held, changed) => {
3220
3562
  const properties = new Set([...changed].flatMap((property) => canvasCssPropertyScope(property)));
3221
3563
  const layout = releasedGridPolicy(held, properties);
3222
3564
  for (const [key, property] of CANVAS_LAYOUT_CSS_FIELDS) if (properties.has(property)) Reflect.deleteProperty(layout, key);
@@ -3252,7 +3594,7 @@ const axisWithoutCssBounds = (intent, properties, changed) => {
3252
3594
  /** Editors hand CSS control back property by property; absent presets stay absent. */
3253
3595
  const canvasLayoutWithoutCssProperties = (held, changed, axes) => {
3254
3596
  const properties = new Set([...changed].flatMap((property) => canvasCssPropertyScope(property)));
3255
- const layout = releasedFields(held, properties);
3597
+ const layout = canvasLayoutReleasedFields(held, properties);
3256
3598
  if (properties.has("display")) Reflect.deleteProperty(layout, "retainedFlexSpacing");
3257
3599
  if ([
3258
3600
  "overflow",
@@ -3643,80 +3985,6 @@ const DESCRIPTOR_BY_KIND = Object.fromEntries([
3643
3985
  const canvasObjectKindDescriptor = (objectKind) => DESCRIPTOR_BY_KIND[objectKind] ?? null;
3644
3986
  const canvasPropertySectionsForKind = (objectKind) => canvasObjectKindDescriptor(objectKind)?.propertySections ?? [];
3645
3987
 
3646
- //#endregion
3647
- //#region ../../packages/contract/src/canvas/canvas-reference-scope.lib.ts
3648
- const ROOT_ID = "root";
3649
- const DEFAULT_CANVAS_REFERENCE_PAGE_ID = "canvas-page-default";
3650
- const rootIdsOf = (document) => Object.entries(document.relationships).filter(([, relationship]) => relationship.parentId === ROOT_ID).toSorted(([firstId, first], [secondId, second]) => first.sortKey === second.sortKey ? firstId.localeCompare(secondId) : first.sortKey < second.sortKey ? -1 : 1).map(([id]) => id);
3651
- const canvasReferencePageIds = (document) => {
3652
- const pages = rootIdsOf(document).filter((id) => document.nodes[id]?.component === PAGE_KIND);
3653
- return pages.length > 0 ? pages : [DEFAULT_CANVAS_REFERENCE_PAGE_ID];
3654
- };
3655
- const canvasReferencePageOf = (document, nodeId) => {
3656
- const visited = /* @__PURE__ */ new Set();
3657
- let currentId = nodeId;
3658
- while (currentId !== void 0 && !visited.has(currentId)) {
3659
- visited.add(currentId);
3660
- const node = document.nodes[currentId];
3661
- if (node === void 0 || node.component === "page") return null;
3662
- const parentId = document.relationships[currentId]?.parentId;
3663
- if (parentId === ROOT_ID) {
3664
- const assigned = node.props?.["canvasPageId"];
3665
- return typeof assigned === "string" ? assigned : DEFAULT_CANVAS_REFERENCE_PAGE_ID;
3666
- }
3667
- currentId = parentId;
3668
- }
3669
- return null;
3670
- };
3671
- const descendantsOf = (document, rootIds) => {
3672
- const children = /* @__PURE__ */ new Map();
3673
- for (const [id, relation] of Object.entries(document.relationships)) {
3674
- const siblings = children.get(relation.parentId) ?? [];
3675
- siblings.push(id);
3676
- children.set(relation.parentId, siblings);
3677
- }
3678
- const result = /* @__PURE__ */ new Set();
3679
- const pending = [...rootIds];
3680
- while (pending.length > 0) {
3681
- const id = pending.pop();
3682
- if (id === void 0 || result.has(id) || document.nodes[id] === void 0) continue;
3683
- result.add(id);
3684
- pending.push(...children.get(id) ?? []);
3685
- }
3686
- return result;
3687
- };
3688
- const resolveCanvasReference = (reference, document) => {
3689
- const pages = canvasReferencePageIds(document);
3690
- if (reference.pageId !== void 0 && !pages.includes(reference.pageId)) return {
3691
- ok: false,
3692
- reason: "page"
3693
- };
3694
- const selectionPages = reference.nodeIds.map((id) => canvasReferencePageOf(document, id));
3695
- if (selectionPages.some((pageId) => pageId === null || !pages.includes(pageId))) return {
3696
- ok: false,
3697
- reason: "selection"
3698
- };
3699
- if (reference.pageId !== void 0 && selectionPages.some((pageId) => pageId !== reference.pageId)) return {
3700
- ok: false,
3701
- reason: "inconsistent-page"
3702
- };
3703
- if (new Set(selectionPages).size > 1) return {
3704
- ok: false,
3705
- reason: "mixed-pages"
3706
- };
3707
- const pageId = reference.pageId ?? selectionPages[0] ?? null;
3708
- const rootNodeIds = reference.nodeIds.length > 0 ? [...new Set(reference.nodeIds)] : rootIdsOf(document).filter((id) => {
3709
- const ownedPage = canvasReferencePageOf(document, id);
3710
- return ownedPage !== null && (pageId === null || ownedPage === pageId);
3711
- });
3712
- return {
3713
- ok: true,
3714
- pageId,
3715
- rootNodeIds,
3716
- nodeIds: descendantsOf(document, rootNodeIds)
3717
- };
3718
- };
3719
-
3720
3988
  //#endregion
3721
3989
  //#region ../../packages/contract/src/canvas/canvas-preparation.schema.ts
3722
3990
  const nodeId$5 = canvasSceneNodeSchema.shape.id;
@@ -3951,6 +4219,36 @@ const agentClientMetadata = (value) => {
3951
4219
  return { path: transport.success ? transport.data.path : "direct_cli" };
3952
4220
  };
3953
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
+
3954
4252
  //#endregion
3955
4253
  //#region ../../packages/contract/src/canvas/canvas-realtime.schema.ts
3956
4254
  const CANVAS_REALTIME_PROTOCOL = "enhance3.canvas.v1";
@@ -3961,7 +4259,6 @@ const MAX_CANVAS_PRESENCE_DETAIL_BYTES = 16384;
3961
4259
  const MAX_CANVAS_SELECTION_CHUNK_IDS = 1e3;
3962
4260
  const MAX_CANVAS_SELECTION_CHUNK_BYTES = 49152;
3963
4261
  const MAX_ACTIVITY_TARGETS = 100;
3964
- const MAX_REALTIME_TICKET_LENGTH = 4096;
3965
4262
  const MAX_ERROR_MESSAGE_LENGTH = 200;
3966
4263
  const MAX_CURSOR_CHAT_LENGTH = 140;
3967
4264
  const canvasActorColourSchema = z.enum([
@@ -3974,7 +4271,7 @@ const canvasActorColourSchema = z.enum([
3974
4271
  "red",
3975
4272
  "orange"
3976
4273
  ]);
3977
- const personRoomActorSchema = z.object({
4274
+ const personRoomIdentitySchema = z.object({
3978
4275
  kind: z.literal("person"),
3979
4276
  connectionId: z.uuid(),
3980
4277
  personId: z.uuid(),
@@ -3983,12 +4280,14 @@ const personRoomActorSchema = z.object({
3983
4280
  avatarUrl: z.string().max(MAX_URL_LENGTH).nullable().optional(),
3984
4281
  colour: canvasActorColourSchema
3985
4282
  });
4283
+ const personRoomActorSchema = personRoomIdentitySchema.extend(canvasRoomViewSchema.shape);
3986
4284
  const guestRoomActorSchema = z.object({
3987
4285
  kind: z.literal("guest"),
3988
4286
  connectionId: z.uuid(),
3989
4287
  displayName: z.string().min(1).max(MAX_DISPLAY_NAME_LENGTH),
3990
4288
  initials: z.string().min(1).max(MAX_INITIALS_LENGTH),
3991
- colour: canvasActorColourSchema
4289
+ colour: canvasActorColourSchema,
4290
+ ...canvasRoomViewSchema.shape
3992
4291
  });
3993
4292
  const canvasRoomActorSchema = z.discriminatedUnion("kind", [personRoomActorSchema, guestRoomActorSchema]);
3994
4293
  const agentMutationActorSchema = z.object({
@@ -4000,7 +4299,7 @@ const agentMutationActorSchema = z.object({
4000
4299
  agentAttribution: agentClientPropertiesSchema.optional(),
4001
4300
  colour: canvasActorColourSchema
4002
4301
  });
4003
- const canvasMutationActorSchema = z.discriminatedUnion("kind", [personRoomActorSchema.omit({
4302
+ const canvasMutationActorSchema = z.discriminatedUnion("kind", [personRoomIdentitySchema.omit({
4004
4303
  connectionId: true,
4005
4304
  avatarUrl: true
4006
4305
  }), agentMutationActorSchema]);
@@ -4034,7 +4333,8 @@ const canvasPresencePatchSchema = z.object({
4034
4333
  selectionSummary: selectionSummarySchema.nullable().optional(),
4035
4334
  visibleWorldBox: visibleWorldBoxSchema.optional(),
4036
4335
  gesture: gesturePreviewSchema.nullable().optional(),
4037
- cursorChat: z.string().max(140).nullable().optional()
4336
+ cursorChat: z.string().max(140).nullable().optional(),
4337
+ ...canvasPresenceViewSchema.shape
4038
4338
  }).refine((patch) => Object.keys(patch).length > 0, "presence patch cannot be empty");
4039
4339
  const canvasPresenceSchema = z.object({
4040
4340
  actor: canvasRoomActorSchema,
@@ -4051,6 +4351,8 @@ const canvasPresenceSchema = z.object({
4051
4351
  visibleWorldBox: visibleWorldBoxSchema.nullable(),
4052
4352
  gesture: gesturePreviewSchema.nullable(),
4053
4353
  cursorChat: z.string().max(140).nullable().default(null),
4354
+ ...canvasPresenceViewSchema.shape,
4355
+ followOrder: z.number().int().nonnegative().optional(),
4054
4356
  expiresAt: z.iso.datetime()
4055
4357
  });
4056
4358
  const canvasAgentActivityPhaseSchema = z.enum([
@@ -4069,16 +4371,6 @@ const canvasAgentActivitySchema = z.object({
4069
4371
  bounds: visibleWorldBoxSchema.nullable(),
4070
4372
  expiresAt: z.iso.datetime()
4071
4373
  });
4072
- const canvasRealtimeTicketInputSchema = z.object({
4073
- canvasId: z.uuid(),
4074
- protocols: z.array(z.literal(CANVAS_REALTIME_PROTOCOL)).min(1).max(1)
4075
- });
4076
- const canvasRealtimeTicketOutputSchema = z.object({
4077
- endpoint: z.url(),
4078
- ticket: z.string().min(1).max(MAX_REALTIME_TICKET_LENGTH),
4079
- protocol: z.literal(CANVAS_REALTIME_PROTOCOL),
4080
- expiresAt: z.iso.datetime()
4081
- });
4082
4374
  const beginCanvasActivityInputSchema = z.object({
4083
4375
  canvasId: z.uuid(),
4084
4376
  phase: canvasAgentActivityPhaseSchema,
@@ -4121,6 +4413,7 @@ const canvasRealtimeServerEnvelopeSchema = z.discriminatedUnion("type", [
4121
4413
  type: z.literal("room.snapshot"),
4122
4414
  payload: z.object({
4123
4415
  connectionId: z.uuid(),
4416
+ viewKey: canvasRoomViewSchema.shape.viewKey,
4124
4417
  peers: z.array(canvasPresenceSchema),
4125
4418
  activities: z.array(canvasAgentActivitySchema),
4126
4419
  documentVersion: z.number().int().positive()
@@ -4227,6 +4520,21 @@ const canvasRealtimeClientEnvelopeSchema = z.discriminatedUnion("type", [
4227
4520
  })
4228
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);
4229
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
+
4230
4538
  //#endregion
4231
4539
  //#region ../../packages/contract/src/canvas/canvas-reference.lib.ts
4232
4540
  const canvasIdSchema = z.uuid();
@@ -4282,33 +4590,107 @@ const readCanvasReference = (reference) => {
4282
4590
  const selected = selectedIdsSchema.safeParse(prototypes.length > 0 ? prototypes : selection);
4283
4591
  if (!selected.success) return {
4284
4592
  ok: false,
4285
- reason: "selection"
4593
+ reason: "selection"
4594
+ };
4595
+ return {
4596
+ ok: true,
4597
+ value: {
4598
+ canvasId: id.data,
4599
+ ...pageId !== void 0 && { pageId },
4600
+ nodeIds: [...new Set(selected.data)]
4601
+ }
4602
+ };
4603
+ };
4604
+ const buildCanvasReference = (origin, reference) => {
4605
+ if (!URL.canParse(origin) || !["https:", "http:"].includes(new URL(origin).protocol)) return {
4606
+ ok: false,
4607
+ reason: "reference"
4608
+ };
4609
+ const url = new URL(`/c/${encodeURIComponent(reference.canvasId)}`, new URL(origin).origin);
4610
+ if (reference.pageId !== void 0) url.searchParams.set("page", reference.pageId);
4611
+ const hash = new URLSearchParams();
4612
+ const nodeIds = new Set(reference.nodeIds);
4613
+ for (const id of nodeIds) hash.append("selection", id);
4614
+ url.hash = hash.toString();
4615
+ const read = readCanvasReference(url.href);
4616
+ return read.ok ? {
4617
+ ok: true,
4618
+ url: url.href
4619
+ } : read;
4620
+ };
4621
+
4622
+ //#endregion
4623
+ //#region ../../packages/contract/src/canvas/canvas-reference-scope.lib.ts
4624
+ const ROOT_ID = "root";
4625
+ const DEFAULT_CANVAS_REFERENCE_PAGE_ID = "canvas-page-default";
4626
+ const rootIdsOf = (document) => Object.entries(document.relationships).filter(([, relationship]) => relationship.parentId === ROOT_ID).toSorted(([firstId, first], [secondId, second]) => first.sortKey === second.sortKey ? firstId.localeCompare(secondId) : first.sortKey < second.sortKey ? -1 : 1).map(([id]) => id);
4627
+ const canvasReferencePageIds = (document) => {
4628
+ const pages = rootIdsOf(document).filter((id) => document.nodes[id]?.component === PAGE_KIND);
4629
+ return pages.length > 0 ? pages : [DEFAULT_CANVAS_REFERENCE_PAGE_ID];
4630
+ };
4631
+ const canvasReferencePageOf = (document, nodeId) => {
4632
+ const visited = /* @__PURE__ */ new Set();
4633
+ let currentId = nodeId;
4634
+ while (currentId !== void 0 && !visited.has(currentId)) {
4635
+ visited.add(currentId);
4636
+ const node = document.nodes[currentId];
4637
+ if (node === void 0 || node.component === "page") return null;
4638
+ const parentId = document.relationships[currentId]?.parentId;
4639
+ if (parentId === ROOT_ID) {
4640
+ const assigned = node.props?.["canvasPageId"];
4641
+ return typeof assigned === "string" ? assigned : DEFAULT_CANVAS_REFERENCE_PAGE_ID;
4642
+ }
4643
+ currentId = parentId;
4644
+ }
4645
+ return null;
4646
+ };
4647
+ const descendantsOf = (document, rootIds) => {
4648
+ const children = /* @__PURE__ */ new Map();
4649
+ for (const [id, relation] of Object.entries(document.relationships)) {
4650
+ const siblings = children.get(relation.parentId) ?? [];
4651
+ siblings.push(id);
4652
+ children.set(relation.parentId, siblings);
4653
+ }
4654
+ const result = /* @__PURE__ */ new Set();
4655
+ const pending = [...rootIds];
4656
+ while (pending.length > 0) {
4657
+ const id = pending.pop();
4658
+ if (id === void 0 || result.has(id) || document.nodes[id] === void 0) continue;
4659
+ result.add(id);
4660
+ pending.push(...children.get(id) ?? []);
4661
+ }
4662
+ return result;
4663
+ };
4664
+ const resolveCanvasReference = (reference, document) => {
4665
+ const pages = canvasReferencePageIds(document);
4666
+ if (reference.pageId !== void 0 && !pages.includes(reference.pageId)) return {
4667
+ ok: false,
4668
+ reason: "page"
4669
+ };
4670
+ const selectionPages = reference.nodeIds.map((id) => canvasReferencePageOf(document, id));
4671
+ if (selectionPages.some((pageId) => pageId === null || !pages.includes(pageId))) return {
4672
+ ok: false,
4673
+ reason: "selection"
4674
+ };
4675
+ if (reference.pageId !== void 0 && selectionPages.some((pageId) => pageId !== reference.pageId)) return {
4676
+ ok: false,
4677
+ reason: "inconsistent-page"
4678
+ };
4679
+ if (new Set(selectionPages).size > 1) return {
4680
+ ok: false,
4681
+ reason: "mixed-pages"
4286
4682
  };
4683
+ const pageId = reference.pageId ?? selectionPages[0] ?? null;
4684
+ const rootNodeIds = reference.nodeIds.length > 0 ? [...new Set(reference.nodeIds)] : rootIdsOf(document).filter((id) => {
4685
+ const ownedPage = canvasReferencePageOf(document, id);
4686
+ return ownedPage !== null && (pageId === null || ownedPage === pageId);
4687
+ });
4287
4688
  return {
4288
4689
  ok: true,
4289
- value: {
4290
- canvasId: id.data,
4291
- ...pageId !== void 0 && { pageId },
4292
- nodeIds: [...new Set(selected.data)]
4293
- }
4294
- };
4295
- };
4296
- const buildCanvasReference = (origin, reference) => {
4297
- if (!URL.canParse(origin) || !["https:", "http:"].includes(new URL(origin).protocol)) return {
4298
- ok: false,
4299
- reason: "reference"
4690
+ pageId,
4691
+ rootNodeIds,
4692
+ nodeIds: descendantsOf(document, rootNodeIds)
4300
4693
  };
4301
- const url = new URL(`/c/${encodeURIComponent(reference.canvasId)}`, new URL(origin).origin);
4302
- if (reference.pageId !== void 0) url.searchParams.set("page", reference.pageId);
4303
- const hash = new URLSearchParams();
4304
- const nodeIds = new Set(reference.nodeIds);
4305
- for (const id of nodeIds) hash.append("selection", id);
4306
- url.hash = hash.toString();
4307
- const read = readCanvasReference(url.href);
4308
- return read.ok ? {
4309
- ok: true,
4310
- url: url.href
4311
- } : read;
4312
4694
  };
4313
4695
 
4314
4696
  //#endregion
@@ -4335,7 +4717,8 @@ const exposeCanvasRenderOutputSchema = z.discriminatedUnion("purpose", [
4335
4717
  purpose: z.enum([
4336
4718
  "inspection",
4337
4719
  "snapshot",
4338
- "thumbnail"
4720
+ "thumbnail",
4721
+ "export"
4339
4722
  ]),
4340
4723
  scale: z.number().positive(),
4341
4724
  maxOutputPixels: canvasRenderPixelLimitSchema.optional(),
@@ -4389,7 +4772,8 @@ const claimRenderWorkOutputSchema = z.discriminatedUnion("purpose", [
4389
4772
  purpose: z.enum([
4390
4773
  "inspection",
4391
4774
  "snapshot",
4392
- "thumbnail"
4775
+ "thumbnail",
4776
+ "export"
4393
4777
  ]),
4394
4778
  target: canvasRenderTargetSchema,
4395
4779
  sourceState: canvasRenderSourceStateSchema.optional(),
@@ -4856,6 +5240,13 @@ const textRunFormattingOf = (command) => ({
4856
5240
  ...command.decorationBlendMode !== void 0 && { decorationBlendMode: command.decorationBlendMode },
4857
5241
  ...command.backgroundBlendMode !== void 0 && { backgroundBlendMode: command.backgroundBlendMode }
4858
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
+ };
4859
5250
  const clearedOverrides = (nodes, command) => nodes.flatMap((node) => {
4860
5251
  if (node.kind !== "span") return [node];
4861
5252
  const next = {
@@ -4881,11 +5272,11 @@ const clearedOverrides = (nodes, command) => nodes.flatMap((node) => {
4881
5272
  Reflect.deleteProperty(next, "textStyle");
4882
5273
  return [next];
4883
5274
  }
4884
- if (command.type === "link") Reflect.deleteProperty(next, "href");
5275
+ if (command.type === "link") withoutLink(next);
4885
5276
  else if (command.type === "paint") {
4886
5277
  Reflect.deleteProperty(next, "fills");
4887
5278
  Reflect.deleteProperty(next.styles, "color");
4888
- } 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);
4889
5280
  const metadata = Object.keys(next).filter((key) => ![
4890
5281
  "kind",
4891
5282
  "children",
@@ -4893,14 +5284,14 @@ const clearedOverrides = (nodes, command) => nodes.flatMap((node) => {
4893
5284
  ].includes(key));
4894
5285
  return Object.keys(next.styles).length === 0 && metadata.length === 0 ? next.children : [next];
4895
5286
  });
4896
- /** Leading and decoration must share the glyph's font; outer spans add a second line-box strut. */
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. */
4897
5288
  const metricRuns = (nodes, styles) => nodes.map((node) => {
4898
5289
  if (node.kind !== "span") return {
4899
5290
  kind: "span",
4900
5291
  styles,
4901
5292
  children: [node]
4902
5293
  };
4903
- return node.children.some((child) => child.kind === "span") ? {
5294
+ return node.href !== void 0 || node.children.some((child) => child.kind === "span") ? {
4904
5295
  ...node,
4905
5296
  children: metricRuns(node.children, styles)
4906
5297
  } : {
@@ -4917,7 +5308,7 @@ const linkedRuns = (nodes, command) => {
4917
5308
  const children = clearedOverrides(nodes, command);
4918
5309
  return command.href === null ? children : [{
4919
5310
  kind: "span",
4920
- styles: existing === null ? LINK_STYLES : {},
5311
+ styles: LINK_STYLES,
4921
5312
  href: command.href,
4922
5313
  children
4923
5314
  }];
@@ -5030,19 +5421,34 @@ const insertedText = (text, source) => text.split(/([\n\u{2028}])/u).flatMap((pa
5030
5421
  kind: "text",
5031
5422
  text: part
5032
5423
  }]);
5033
- const insertedRuns = (nodes, offset, text, shouldKeepEmpty = false) => {
5034
- if (text === "" && !shouldKeepEmpty) return [];
5035
- let position = 0;
5036
- for (const node of nodes) {
5037
- const length = lengthOf(node);
5038
- if (offset < position + length || node === nodes.at(-1)) return node.kind === "span" ? [{
5039
- ...node,
5040
- children: insertedRuns(node.children, offset - position, text, shouldKeepEmpty)
5041
- }] : insertedText(text, node);
5042
- position += length;
5043
- }
5044
- 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;
5045
5450
  };
5451
+ const insertedRuns = (nodes, range, text, shouldKeepEmpty = false) => text === "" && !shouldKeepEmpty ? [] : withText(canvasTextTypedFormatting(nodes, range), text);
5046
5452
  const canvasTextReplacementRange = (before, text, range) => {
5047
5453
  const replacementEnd = text.length - before.length + (range?.end ?? 0);
5048
5454
  if (range !== void 0 && isValidTextRange(before, range) && isValidTextRange(text, {
@@ -5156,13 +5562,8 @@ const replacementRuns = (runs, range, command) => {
5156
5562
  if (rich.length > 0) return rich;
5157
5563
  }
5158
5564
  const shouldKeepEmpty = range.start === 0 && range.end === canvasRichTextValueOf(runs).length;
5159
- let next = insertedRuns(runs, range.start, command.text, shouldKeepEmpty);
5565
+ let next = insertedRuns(runs, range, command.text, shouldKeepEmpty);
5160
5566
  if (command.text === "") return next;
5161
- const link = canvasRichTextLinkOf(sliceRuns(runs, range.start, range.start + 1));
5162
- if (link !== null && range.start === range.end && canvasRichTextLinkOf(sliceRuns(runs, range.start - 1, range.start)) !== link) next = formattedRuns(next, {
5163
- type: "link",
5164
- href: null
5165
- });
5166
5567
  if (Object.keys(command.styles ?? {}).length > 0 || Object.keys(textRunFormattingOf(command)).length > 0) next = formattedRuns(next, {
5167
5568
  type: "format",
5168
5569
  styles: command.styles ?? {},
@@ -5725,6 +6126,7 @@ const participantSchema = z.object({
5725
6126
  "in-progress",
5726
6127
  "done"
5727
6128
  ]).nullable(),
6129
+ /** Always `null`: view times stay on their owner's dashboard. Kept because published plugins require it. */
5728
6130
  lastViewedAt: z.iso.datetime().nullable()
5729
6131
  });
5730
6132
  const listParticipantsInputSchema = z.object({ canvasId: z.uuid() });
@@ -5760,13 +6162,14 @@ const setReviewStateOutputSchema = z.object({ reviewState: setReviewStateInputSc
5760
6162
 
5761
6163
  //#endregion
5762
6164
  //#region ../../packages/contract/src/capture/capture.schema.ts
6165
+ /** The longest journey, step, variant or label a capture may carry. */
5763
6166
  const CAPTURE_KEY_LENGTH = 160;
5764
6167
  const CAPTURE_METADATA_LENGTH = 200;
5765
6168
  const CAPTURE_ISSUE_LENGTH = 500;
5766
6169
  const CAPTURE_FAILURE_LENGTH = 1e3;
5767
6170
  const CAPTURE_UPLOAD_BATCH_SIZE = 400;
5768
6171
  const CAPTURE_FORMAT_VERSION = 1;
5769
- const key = z.string().trim().min(1).max(CAPTURE_KEY_LENGTH);
6172
+ const key = z.string().trim().min(1).max(160);
5770
6173
  const digest$1 = z.string().regex(/^[a-f0-9]{64}$/u);
5771
6174
  const dimension = z.number().int().positive();
5772
6175
  const captureKeySchema = z.strictObject({
@@ -5899,6 +6302,11 @@ const captureAttemptSchema = z.strictObject({
5899
6302
  "interrupted",
5900
6303
  "timedOut"
5901
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(),
5902
6310
  captures: z.array(captureArtifactSchema)
5903
6311
  });
5904
6312
  const captureManifestSchema = z.strictObject({
@@ -5985,7 +6393,31 @@ const reserveCaptureBlobsOutputSchema = z.strictObject({ uploads: z.array(z.stri
5985
6393
  expiresAt: z.iso.datetime()
5986
6394
  }).nullable()
5987
6395
  })).max(CAPTURE_UPLOAD_BATCH_SIZE) });
5988
- 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
+ };
5989
6421
 
5990
6422
  //#endregion
5991
6423
  //#region ../../packages/contract/src/comment/comment.schema.ts
@@ -6122,6 +6554,8 @@ const commentMessageSchema = z.object({
6122
6554
  messageId: z.uuid(),
6123
6555
  seq: z.number().int().min(1),
6124
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(),
6125
6559
  author: commentAuthorSchema,
6126
6560
  createdAt: z.iso.datetime(),
6127
6561
  /** A comment that changed after somebody read it should say so. */
@@ -6871,7 +7305,7 @@ const ROOT_FIXTURE_NODE_ID = "root";
6871
7305
  const SORT_KEY_DIGITS = 4;
6872
7306
  const sortKeyAt = (seat) => `a${String(seat).padStart(SORT_KEY_DIGITS, "0")}`;
6873
7307
  const emptyFixtureDocument = () => ({
6874
- version: 11,
7308
+ version: 13,
6875
7309
  nodes: { [ROOT_FIXTURE_NODE_ID]: {
6876
7310
  id: ROOT_FIXTURE_NODE_ID,
6877
7311
  label: "Canvas",
@@ -8210,6 +8644,17 @@ const clientConversionInputSchema = z.object({
8210
8644
  reason: z.enum([
8211
8645
  "none",
8212
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",
8213
8658
  "source-unsettled",
8214
8659
  "captured-fonts-unavailable",
8215
8660
  "conversion-failed"
@@ -8225,6 +8670,12 @@ const MAX_DURATION_MS$1 = 18e5;
8225
8670
  const MAX_COUNT = 1e6;
8226
8671
  const MAX_BYTES = 1073741824;
8227
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
+ ]);
8228
8679
  const durationSchema$1 = z.number().int().min(0).max(MAX_DURATION_MS$1);
8229
8680
  const countSchema = z.number().int().min(0).max(MAX_COUNT);
8230
8681
  const base$1 = {
@@ -8266,6 +8717,7 @@ const clientPerformanceInputSchema = z.discriminatedUnion("name", [
8266
8717
  "sources",
8267
8718
  "replays"
8268
8719
  ]),
8720
+ browserCopyCheck: browserCopyCheckSchema.optional(),
8269
8721
  durationMs: durationSchema$1,
8270
8722
  shellMs: durationSchema$1,
8271
8723
  projectionMs: durationSchema$1,
@@ -8293,7 +8745,12 @@ const clientPerformanceInputSchema = z.discriminatedUnion("name", [
8293
8745
  "drag",
8294
8746
  "edit"
8295
8747
  ]),
8296
- outcome: z.enum(["smooth", "janky"]),
8748
+ outcome: z.enum([
8749
+ "smooth",
8750
+ "janky",
8751
+ "refused"
8752
+ ]),
8753
+ pendingCandidateCount: countSchema.optional(),
8297
8754
  durationMs: durationSchema$1,
8298
8755
  frameCount: countSchema,
8299
8756
  slowFrameCount: countSchema,
@@ -8464,7 +8921,8 @@ const CANVAS_SYNC_REPORTS = [
8464
8921
  "replan",
8465
8922
  "deleted-target",
8466
8923
  "whole-value-text",
8467
- "retrying"
8924
+ "retrying",
8925
+ "recovery"
8468
8926
  ];
8469
8927
  const CANVAS_SYNC_DETAILS = [
8470
8928
  ...CLIENT_SAVE_ISSUES,
@@ -8473,8 +8931,38 @@ const CANVAS_SYNC_DETAILS = [
8473
8931
  "repeated-server-error",
8474
8932
  "mutation-id-reused",
8475
8933
  "base-ahead",
8476
- "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"
8477
8963
  ];
8964
+ /** Whether a recovery state began in this visit or was reopened from the browser copy. */
8965
+ const CANVAS_SYNC_EPISODES = ["new", "reopened"];
8478
8966
  const clientSaveIncidentInputSchema = z.strictObject({
8479
8967
  canvasId: z.uuid(),
8480
8968
  releaseIdentity: z.string().min(1).max(100),
@@ -8484,7 +8972,10 @@ const clientSaveIncidentInputSchema = z.strictObject({
8484
8972
  version: z.number().int().nonnegative(),
8485
8973
  attempts: z.number().int().nonnegative(),
8486
8974
  durationMs: z.number().int().nonnegative(),
8487
- pendingChanges: 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()
8488
8979
  });
8489
8980
  const clientSaveIncidentOutputSchema = z.object({ accepted: z.literal(true) });
8490
8981
 
@@ -8871,6 +9362,106 @@ var PartialBatchError = class extends CliError {
8871
9362
  }
8872
9363
  };
8873
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
+
8874
9465
  //#endregion
8875
9466
  //#region src/application/canvas-reference.use-case.ts
8876
9467
  const hasCanvasReferenceScope = (reference) => reference.pageId !== void 0 || reference.nodeIds.length > 0;
@@ -9286,11 +9877,12 @@ const canvasEditableReadOutputSchema = z.strictObject({
9286
9877
  ...readResult,
9287
9878
  view: z.literal("editable"),
9288
9879
  complete: z.literal(true),
9289
- projectionVersion: z.literal(1),
9880
+ projectionVersion: z.literal(2),
9290
9881
  snapshotToken: cursor,
9291
9882
  rootNodeId: nodeId$1,
9292
9883
  html: z.string(),
9293
- opaqueNodeIds: z.array(nodeId$1)
9884
+ opaqueNodeIds: z.array(nodeId$1),
9885
+ sealedReasons: z.record(nodeId$1, z.string())
9294
9886
  });
9295
9887
  const canvasOutlineReadOutputSchema = z.strictObject({
9296
9888
  ...readResult,
@@ -10756,7 +11348,6 @@ const PROCEDURE_DESCRIPTIONS = {
10756
11348
  "canvas.duplicate": "Copy a canvas and its document into the selected shelf.",
10757
11349
  "canvas.deletePermanently": "Permanently delete a canvas already in the recoverable bin.",
10758
11350
  "canvas.restore": "Restore a canvas from the recoverable bin.",
10759
- "canvas.markViewed": "Record that the authenticated person has viewed a canvas.",
10760
11351
  "canvas.list": "Find canvas ids by collection, title, access, review state, or deletion state.",
10761
11352
  "canvas.rename": "Rename a canvas owned by the authenticated person.",
10762
11353
  "canvas.setReviewState": "Change the authenticated person’s review state on a canvas.",
@@ -10783,7 +11374,7 @@ const PROCEDURE_DESCRIPTIONS = {
10783
11374
  "comment.react": "Set or remove one emoji reaction on a comment message.",
10784
11375
  "comment.edit": "Replace the body of a comment message authored by this person.",
10785
11376
  "comment.move": "Move a comment thread anchor to a new canvas location.",
10786
- "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.",
10787
11378
  "organisation.list": "List teams the authenticated person belongs to.",
10788
11379
  "organisation.create": "Create a team and make the authenticated person its owner.",
10789
11380
  "organisation.update": "Rename a team managed by the authenticated person.",
@@ -10837,7 +11428,7 @@ const OPTION_DESCRIPTIONS = {
10837
11428
  "canvas.makeEditable --placement": "Place the editable conversion adjacent to its source; retain the captured original.",
10838
11429
  "canvas.remove --root-node-ids": "Explicit roots to remove with their descendants, within the supplied scope and observed version.",
10839
11430
  "canvas.updateHtml --snapshot-token": "Opaque snapshot token from a complete editable read. Retain it for the identical retry; reread after a conflict.",
10840
- "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.",
10841
11432
  "canvas.updateHtml --remove-node-ids": "Explicit retained roots intentionally deleted from the HTML. Omission alone never authorizes removal.",
10842
11433
  "operation.status --operation": "Exact durable operation reference returned by a prior call, including its kind and identity fields.",
10843
11434
  "operation.status --include-image": "Include available render image evidence when true; this does not start another render.",
@@ -11151,6 +11742,11 @@ const FONT_ASSET_POLICY = {
11151
11742
  reason: "Font upload and transfer lifecycle belongs to document authoring transactions.",
11152
11743
  owner: "product"
11153
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
+ };
11154
11750
  const RENDER_LIFECYCLE_POLICY = {
11155
11751
  exposure: "internal",
11156
11752
  reason: "Render creation, polling and cancellation belong to higher-level render capabilities.",
@@ -11200,6 +11796,11 @@ const PROCEDURE_CAPABILITY_POLICIES = {
11200
11796
  "person.completeProfilePhoto": PROFILE_DRAFT_POLICY,
11201
11797
  "person.abandonProfilePhoto": PROFILE_DRAFT_POLICY,
11202
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
+ },
11203
11804
  "feedback.submit": {
11204
11805
  exposure: "internal",
11205
11806
  reason: "Dashboard feedback requires a deliberate human submission.",
@@ -11271,6 +11872,9 @@ const PROCEDURE_CAPABILITY_POLICIES = {
11271
11872
  owner: "product"
11272
11873
  },
11273
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,
11274
11878
  "canvas.render.snapshot": {
11275
11879
  exposure: "internal",
11276
11880
  reason: "Render snapshot creation is owned by higher-level render capabilities.",
@@ -11397,7 +12001,6 @@ const SHARED_CAPABILITY_PROCEDURES = /* @__PURE__ */ new Set([
11397
12001
  "canvas.invites.resend",
11398
12002
  "canvas.invites.revoke",
11399
12003
  "canvas.list",
11400
- "canvas.markViewed",
11401
12004
  "canvas.move",
11402
12005
  "canvas.node",
11403
12006
  "canvas.participants.list",
@@ -12286,7 +12889,8 @@ const toCanvasCardContract = (view) => {
12286
12889
  const base = {
12287
12890
  ...toCanvasContract(view),
12288
12891
  screenCount: view.screenCount,
12289
- hasRecording: view.hasRecording
12892
+ hasRecording: view.hasRecording,
12893
+ lastViewedAt: view.lastViewedAt?.toISOString() ?? null
12290
12894
  };
12291
12895
  return view.thumbnail === null ? {
12292
12896
  ...base,
@@ -12316,7 +12920,6 @@ const toCanvasSceneNodeContract = (node) => canvasSceneNodeSchema.parse({
12316
12920
  ...node.layout !== void 0 && { layout: node.layout },
12317
12921
  ...node.appearance !== void 0 && { appearance: node.appearance },
12318
12922
  ...node.geometry !== void 0 && { geometry: node.geometry },
12319
- ...node.compositing !== void 0 && { compositing: node.compositing },
12320
12923
  ...node.typography !== void 0 && { typography: node.typography },
12321
12924
  ...node.additionalStyles !== void 0 && { additionalStyles: node.additionalStyles },
12322
12925
  ...node.props !== void 0 && { props: { ...node.props } },
@@ -12422,7 +13025,7 @@ const setAccess = (handlers) => canvasOwnerProcedure.input(setCanvasAccessInputS
12422
13025
  };
12423
13026
  });
12424
13027
  const markViewed = (handlers) => canvasReaderProcedure.input(markCanvasViewedInputSchema).output(markCanvasViewedOutputSchema).mutation(async ({ input, ctx }) => {
12425
- if (ctx.viewer.kind === "anonymous" || ctx.viewer.kind === "render") return { lastViewedAt: null };
13028
+ if (ctx.viewer.kind !== "person") return { lastViewedAt: null };
12426
13029
  return { lastViewedAt: orThrow(await handlers.markViewed.execute({
12427
13030
  canvasId: input.canvasId,
12428
13031
  personId: ctx.viewer.personId
@@ -13063,6 +13666,7 @@ const getDocument = (handlers) => canvasReaderProcedure.input(getCanvasDocumentI
13063
13666
  document: result.document.document,
13064
13667
  screens: result.screens.map((screen) => ({
13065
13668
  screenId: screen.screenId,
13669
+ clientToken: screen.clientToken,
13066
13670
  route: screen.route,
13067
13671
  title: screen.title,
13068
13672
  viewport: screen.viewport,
@@ -13320,7 +13924,6 @@ const createCanvasInspectionRouter = (handlers, webOrigin) => ({
13320
13924
  ...found.node.layout !== void 0 && { layout: found.node.layout },
13321
13925
  ...found.node.appearance !== void 0 && { appearance: found.node.appearance },
13322
13926
  ...found.node.geometry !== void 0 && { geometry: found.node.geometry },
13323
- ...found.node.compositing !== void 0 && { compositing: found.node.compositing },
13324
13927
  ...found.node.typography !== void 0 && { typography: found.node.typography },
13325
13928
  ...found.node.additionalStyles !== void 0 && { additionalStyles: found.node.additionalStyles },
13326
13929
  props: found.node.props ?? {},
@@ -13549,7 +14152,7 @@ const createCanvasMutationRecoveryRouter = (handlers) => trpcRouter({
13549
14152
 
13550
14153
  //#endregion
13551
14154
  //#region ../api/src/canvas/infrastructure/participant-contract.mapper.ts
13552
- /** Domain to wire. */
14155
+ /** Domain to wire. The member list carries no view times, so each person's stay their own. */
13553
14156
  const toParticipantContract = (row) => ({
13554
14157
  personId: row.personId,
13555
14158
  email: row.email,
@@ -13559,7 +14162,7 @@ const toParticipantContract = (row) => ({
13559
14162
  accessLevel: row.accessLevel,
13560
14163
  isPending: row.isPending,
13561
14164
  reviewState: row.reviewState,
13562
- lastViewedAt: row.lastViewedAt?.toISOString() ?? null
14165
+ lastViewedAt: null
13563
14166
  });
13564
14167
 
13565
14168
  //#endregion
@@ -13731,7 +14334,8 @@ const createCanvasRealtimeRouter = (handlers, endpoint) => trpcRouter({
13731
14334
  ticket: canvasReaderProcedure.input(canvasRealtimeTicketInputSchema).output(canvasRealtimeTicketOutputSchema).mutation(async ({ input, ctx }) => {
13732
14335
  const issued = orThrow(await handlers.issueRealtimeTicket.execute({
13733
14336
  canvasId: input.canvasId,
13734
- viewer: ctx.viewer
14337
+ viewer: ctx.viewer,
14338
+ viewId: input.viewId
13735
14339
  }));
13736
14340
  return {
13737
14341
  endpoint,
@@ -13855,6 +14459,7 @@ const toCanvasVersionContractEntry = (entry) => ({
13855
14459
  });
13856
14460
  const toCanvasVersionContractScreen = (screen) => ({
13857
14461
  screenId: screen.screenId,
14462
+ clientToken: screen.clientToken,
13858
14463
  route: screen.route,
13859
14464
  title: screen.title,
13860
14465
  viewport: screen.viewport,
@@ -13966,68 +14571,6 @@ const createCanvasVersionRouter = (handlers) => trpcRouter({
13966
14571
  duplicate: duplicate(handlers)
13967
14572
  });
13968
14573
 
13969
- //#endregion
13970
- //#region ../../packages/contract/src/capture/capture-comparison.schema.ts
13971
- const COMMIT_LENGTH = 200;
13972
- const captureComparisonInputSchema = z.strictObject({
13973
- canvasId: z.uuid(),
13974
- frameId: z.string().min(1),
13975
- captureId: z.uuid()
13976
- });
13977
- const preview$1 = z.strictObject({
13978
- captureId: z.uuid(),
13979
- capturedAt: z.iso.datetime(),
13980
- commit: z.string().max(COMMIT_LENGTH).optional(),
13981
- url: z.string().min(1),
13982
- width: z.number().positive(),
13983
- height: z.number().positive(),
13984
- pixelRatio: z.number().positive()
13985
- });
13986
- const captureComparisonSchema = z.strictObject({
13987
- frameId: z.string(),
13988
- before: preview$1,
13989
- after: preview$1
13990
- });
13991
-
13992
- //#endregion
13993
- //#region ../../packages/contract/src/capture/capture-review.schema.ts
13994
- const captureReviewInputSchema = z.strictObject({ canvasId: z.uuid() });
13995
- const setCaptureVerdictInputSchema = captureReviewInputSchema.extend({ verdict: captureVerdictSchema });
13996
- const captureReferenceInputSchema = z.strictObject({
13997
- canvasId: z.uuid(),
13998
- name: z.string().min(1)
13999
- });
14000
- const captureReferenceSchema = z.strictObject({
14001
- runId: z.uuid(),
14002
- revision: z.string(),
14003
- version: z.number().int().positive()
14004
- });
14005
- const updateCaptureReferenceInputSchema = captureReferenceInputSchema.extend({
14006
- expectedVersion: z.number().int().nonnegative(),
14007
- revision: z.string().min(1)
14008
- });
14009
- const captureReviewSchema = z.strictObject({
14010
- current: getCaptureRunOutputSchema,
14011
- latest: captureRunDescriptorSchema,
14012
- related: z.array(z.strictObject({
14013
- run: captureRunDescriptorSchema,
14014
- verdict: captureVerdictSchema
14015
- })),
14016
- changes: z.array(z.strictObject({
14017
- key: captureKeySchema,
14018
- frameId: z.string(),
14019
- label: z.string(),
14020
- journeyLabel: z.string(),
14021
- page: z.string().optional(),
14022
- change: z.enum([
14023
- "new",
14024
- "changed",
14025
- "unchanged",
14026
- "uncompared"
14027
- ])
14028
- }))
14029
- });
14030
-
14031
14574
  //#endregion
14032
14575
  //#region ../api/src/canvas/infrastructure/capture-run.router.ts
14033
14576
  const actorOf$1 = (viewer) => {
@@ -14283,7 +14826,7 @@ const toCanvasConversionJob = (job) => {
14283
14826
  //#endregion
14284
14827
  //#region ../api/src/canvas/infrastructure/render.router.ts
14285
14828
  const actorOf = (viewer) => toAgentCanvasRequestActor(viewer) ?? orThrow((0, import_index_cjs.err)(appError("UNAUTHORIZED", "this call needs an agent token")));
14286
- 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")));
14287
14830
  const presentConversion = (job) => toCanvasConversionJob(job) ?? orThrow((0, import_index_cjs.err)(appError("INTERNAL", "primitive import outcome is incomplete")));
14288
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}`)));
14289
14832
  const createRender = (handlers) => agentCanvasReaderProcedure.input(createCanvasRenderInputSchema).output(createCanvasRenderOutputSchema).mutation(async ({ input, ctx }) => {
@@ -14302,7 +14845,7 @@ const createRender = (handlers) => agentCanvasReaderProcedure.input(createCanvas
14302
14845
  idempotencyKey: ctx.idempotencyKey
14303
14846
  }));
14304
14847
  return {
14305
- job: presentRender(made.job),
14848
+ job: presentRender$1(made.job),
14306
14849
  alreadyExists: made.alreadyExists
14307
14850
  };
14308
14851
  });
@@ -14311,7 +14854,7 @@ const getRender = (handlers) => agentProcedure.input(getCanvasRenderInputSchema)
14311
14854
  jobId: input.jobId,
14312
14855
  actor: actorOf(ctx.viewer)
14313
14856
  }));
14314
- return { job: presentRender(requirePurpose(job, "render")) };
14857
+ return { job: presentRender$1(requirePurpose(job, "render")) };
14315
14858
  });
14316
14859
  const createSnapshot = (handlers) => agentCanvasEditorProcedure.input(createRecordingSnapshotInputSchema).output(createRecordingSnapshotOutputSchema).mutation(async ({ input, ctx }) => {
14317
14860
  const actor = actorOf(ctx.viewer);
@@ -14337,7 +14880,7 @@ const createSnapshot = (handlers) => agentCanvasEditorProcedure.input(createReco
14337
14880
  idempotencyKey: ctx.idempotencyKey
14338
14881
  }));
14339
14882
  return {
14340
- job: presentRender(made.job),
14883
+ job: presentRender$1(made.job),
14341
14884
  alreadyExists: made.alreadyExists
14342
14885
  };
14343
14886
  });
@@ -14399,7 +14942,7 @@ const cancelRender = (handlers) => agentProcedure.input(cancelCanvasRenderInputS
14399
14942
  actor
14400
14943
  }));
14401
14944
  requirePurpose(current, "render");
14402
- return { job: presentRender(orThrow(await handlers.cancel.execute({
14945
+ return { job: presentRender$1(orThrow(await handlers.cancel.execute({
14403
14946
  jobId: input.jobId,
14404
14947
  actor
14405
14948
  }))) };
@@ -14433,6 +14976,68 @@ const createRenderRouter = (handlers) => trpcRouter({
14433
14976
  download: downloadRender(handlers)
14434
14977
  });
14435
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
+
14436
15041
  //#endregion
14437
15042
  //#region ../api/src/canvas/infrastructure/render-exposure.router.ts
14438
15043
  const createRenderExposureRouter = (handlers) => trpcRouter({ exposure: renderProcedure.input(exposeCanvasRenderInputSchema).output(exposeCanvasRenderOutputSchema).query(async ({ input, ctx }) => {
@@ -14608,6 +15213,7 @@ const toCommentMessageContract = (message, directory) => ({
14608
15213
  messageId: message.id,
14609
15214
  seq: message.seq,
14610
15215
  body: message.deletedAt === null ? message.body : "(deleted)",
15216
+ isDeleted: message.deletedAt !== null,
14611
15217
  author: toAuthorContract(message, directory),
14612
15218
  createdAt: message.createdAt.toISOString(),
14613
15219
  editedAt: message.editedAt?.toISOString() ?? null,
@@ -14772,8 +15378,7 @@ const createCommentRouter = (handlers) => trpcRouter({
14772
15378
  move: canvasCommenterProcedure.input(moveCommentInputSchema).output(commentThreadSchema).mutation(async ({ input }) => nameCommentThread(handlers.directory, orThrow(await handlers.move.execute(input)))),
14773
15379
  delete: canvasCommenterProcedure.input(deleteCommentInputSchema).output(deleteCommentOutputSchema).mutation(async ({ input, ctx }) => orThrow(await handlers.remove.execute({
14774
15380
  ...input,
14775
- personId: ctx.viewer.personId,
14776
- canManage: ctx.canvasAccess.canManage
15381
+ personId: ctx.viewer.personId
14777
15382
  })))
14778
15383
  });
14779
15384
 
@@ -15883,7 +16488,8 @@ const canvasRouter = (handlers, options) => trpcRouter({
15883
16488
  render: trpcRouter({
15884
16489
  ...createRenderRouter(handlers.render)._def.record,
15885
16490
  preparation: createCanvasPreparationRouter(handlers.render),
15886
- ...createRenderExposureRouter(handlers.render)._def.record
16491
+ ...createRenderExposureRouter(handlers.render)._def.record,
16492
+ ...createRenderExportRouter(handlers.render)._def.record
15887
16493
  }),
15888
16494
  thumbnail: createCanvasThumbnailRouter(),
15889
16495
  participants: createCanvasParticipantRouter(handlers.canvas),
@@ -16696,4 +17302,4 @@ const withCommandInFailure = (value, commandName) => ({
16696
17302
  });
16697
17303
 
16698
17304
  //#endregion
16699
- export { canvasRenderPendingSchema as $, canvasRenderTargetSchema as $n, createOrganisationOutputSchema as $t, operationStatusOutputSchema as A, canvasAgentActivityPhaseSchema 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, DEFAULT_CANVAS_REFERENCE_PAGE_ID 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, canvasReferencePageOf 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, resolveCanvasReference as Ln, completeRecordingOutputSchema as Lt, canvasAssetImportInputSchema as M, agentClientMetadata as Mn, transcriptOutputSchema as Mt, canvasAssetImportOutputSchema as N, createCanvasPreparationOutputSchema as Nn, appErrorSchema as Nt, operationStatusImageSchema as O, canvasRecordingPropsSchema as On, hasCanvasReferenceScope as Ot, canvasArrangeCapabilityInputSchema as P, getCanvasPreparationOutputSchema 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, AGENT_CLIENT_HEADER as jn, CliError as jt, operationStatusInputSchema as k, beginCanvasActivityOutputSchema 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 };