@enhance-eng/sdk 0.1.160 → 0.1.165

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.
@@ -1,10 +1,10 @@
1
1
  import { z } from "zod";
2
2
  import { z as z$1 } from "zod/mini";
3
- import { link, mkdir, open, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
3
+ import { createReadStream } from "node:fs";
4
4
  import nodePath from "node:path";
5
+ import { link, mkdir, open, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
5
6
  import { createHash } from "node:crypto";
6
7
  import { channel } from "node:diagnostics_channel";
7
- import { createReadStream } from "node:fs";
8
8
  import { pipeline } from "node:stream/promises";
9
9
  const CAPTURE_METADATA_LENGTH = 200;
10
10
  const CAPTURE_FAILURE_LENGTH = 1e3;
@@ -821,9 +821,24 @@ const writeCaptureJson = async (path, value) => {
821
821
  await writeFile(temporary, JSON.stringify(value), { mode: 384 });
822
822
  await rename(temporary, path);
823
823
  };
824
+ const manifestJson = (path, content) => {
825
+ try {
826
+ return JSON.parse(content);
827
+ } catch (error) {
828
+ throw captureError("artifact", `The capture manifest ${path} is not JSON: ${error instanceof Error ? error.message : "it could not be parsed"}.`);
829
+ }
830
+ };
831
+ /**
832
+ * The manifest at `path`. One that is not JSON, or not a capture manifest, throws an artifact
833
+ * error naming the file and the first problem in it, which a caller can report as bad input.
834
+ */
824
835
  const readCaptureManifest = async (path) => {
825
- const raw = JSON.parse(await readFile(path, "utf8"));
826
- return lenientCaptureManifestSchema.parse(raw);
836
+ const content = await readFile(path, "utf8");
837
+ const parsed = lenientCaptureManifestSchema.safeParse(manifestJson(path, content));
838
+ if (parsed.success) return parsed.data;
839
+ const [problem] = parsed.error.issues;
840
+ const field = problem?.path.join(".") ?? "";
841
+ throw captureError("artifact", `The capture manifest ${path} is not valid: ${field === "" ? "" : `${field}: `}${problem?.message ?? "it is not a capture manifest"}`);
827
842
  };
828
843
  //#endregion
829
844
  //#region ../canvas-format/src/canvas-format.consts.ts
@@ -863,8 +878,10 @@ const LEGACY_CANVAS_ADAPTATIONS = {
863
878
  };
864
879
  //#endregion
865
880
  //#region ../canvas-format/src/canvas-edit-support.lib.ts
866
- /** Why the API refused an operation, as a fixed value. Never the words of the refusal. */
881
+ /** Why the API refused a request or one of its operations, as a fixed value. Never its words. */
867
882
  const CANVAS_REFUSAL_CODES = [
883
+ "input-invalid",
884
+ "request-too-large",
868
885
  "appearance-unsupported-component",
869
886
  "styles-unsupported-component",
870
887
  "text-shadow-blend-unsupported",
@@ -1173,6 +1190,96 @@ const adaptCanvasDocumentFormat = (document) => {
1173
1190
  if (document["version"] === LEGACY_CANVAS_FORMATS.v13 || document["version"] === LEGACY_CANVAS_FORMATS.v14) return adapted;
1174
1191
  return withoutTextShadowBlends(document["version"] === LEGACY_CANVAS_FORMATS.v12 ? adapted : adaptCanvasCss(adapted));
1175
1192
  };
1193
+ const isSafeInteger = (value) => Number.isSafeInteger(value);
1194
+ /** A format below 1 names no adaptation, so the walk below refuses it. */
1195
+ const canvasWriterFormat = (version) => {
1196
+ if (!isSafeInteger(version)) return "refused";
1197
+ if (version > 15) return "ahead";
1198
+ if (version === 15) return "current";
1199
+ const adaptations = new Map(Object.entries(LEGACY_CANVAS_ADAPTATIONS).map(([format, kind]) => [Number(format), kind]));
1200
+ for (let format = version; format < 15; format += 1) if (adaptations.get(format) !== "format-number") return "refused";
1201
+ return "number-only";
1202
+ };
1203
+ const objectPictureSizeSchema = z.enum(["quarter", "sixteenth"]);
1204
+ /** One stored picture of one top layer. */
1205
+ const canvasObjectPictureSchema = z.strictObject({
1206
+ objectId: z.string().min(1),
1207
+ size: objectPictureSizeSchema,
1208
+ /** Where the picture's bytes are; what it answers with never changes. */
1209
+ url: z.string().min(1),
1210
+ width: z.number().int().positive(),
1211
+ height: z.number().int().positive(),
1212
+ /** The canvas version the picture was drawn at. */
1213
+ drawnVersion: z.number().int().nonnegative(),
1214
+ /** Whether the top layer is unchanged since the picture was drawn. */
1215
+ isCurrent: z.boolean(),
1216
+ /**
1217
+ * The font size, in pixels, that set the most characters of the top layer's texts when it was
1218
+ * drawn; left out where it held no text, or for a picture drawn before sizes were kept.
1219
+ */
1220
+ textSize: z.number().positive().optional()
1221
+ });
1222
+ z.strictObject({
1223
+ canvasId: z.uuid(),
1224
+ /** Only pictures drawn after this version; every picture when left out. */
1225
+ sinceVersion: z.number().int().nonnegative().optional()
1226
+ });
1227
+ z.object({ pictures: z.array(canvasObjectPictureSchema) });
1228
+ z.strictObject({
1229
+ canvasId: z.uuid(),
1230
+ objectIds: z.array(z.string().min(1)).min(1).max(200)
1231
+ });
1232
+ z.object({ scheduled: z.number().int().nonnegative() });
1233
+ const MAX_PICTURE_STORAGE_KEY_LENGTH = 500;
1234
+ const MAX_PICTURE_FAILURE_LENGTH = 500;
1235
+ /** One top layer a picture job is to draw, with when it was last put on the list. */
1236
+ const objectPictureWorkObjectSchema = z.object({
1237
+ objectId: z.string().min(1),
1238
+ wantedAt: z.iso.datetime()
1239
+ });
1240
+ /** One picture a job drew and uploaded, in pixels of the stored picture. */
1241
+ const drawnObjectPictureSchema = z.object({
1242
+ size: objectPictureSizeSchema,
1243
+ width: z.number().int().positive(),
1244
+ height: z.number().int().positive(),
1245
+ bytes: z.number().int().positive(),
1246
+ storageKey: z.string().min(1).max(MAX_PICTURE_STORAGE_KEY_LENGTH),
1247
+ /** The text size of the top layer the page drew, as the list of pictures gives it. */
1248
+ textSize: z.number().positive().optional()
1249
+ });
1250
+ z.object({
1251
+ jobId: z.uuid(),
1252
+ loadedVersion: z.number().int().positive(),
1253
+ drawn: z.array(objectPictureWorkObjectSchema.extend({ pictures: z.array(drawnObjectPictureSchema).length(2) })).max(20),
1254
+ failed: z.array(z.object({
1255
+ objectId: z.string().min(1),
1256
+ message: z.string().min(1).max(MAX_PICTURE_FAILURE_LENGTH)
1257
+ })).max(20)
1258
+ });
1259
+ const coordinate$1 = z.number();
1260
+ const extent = z.number().nonnegative();
1261
+ /** A box in page coordinates. */
1262
+ const canvasOutlineBoxSchema = z.strictObject({
1263
+ x: coordinate$1,
1264
+ y: coordinate$1,
1265
+ width: extent,
1266
+ height: extent
1267
+ });
1268
+ /** What a browser measured of one top layer: its own box, and how far its descendants paint. */
1269
+ const canvasOutlineMeasurementSchema = z.strictObject({
1270
+ objectId: z.string().min(1),
1271
+ box: canvasOutlineBoxSchema,
1272
+ reach: canvasOutlineBoxSchema
1273
+ });
1274
+ z.strictObject({
1275
+ canvasId: z.uuid(),
1276
+ /** The revision of the document the browser had laid out when it measured. */
1277
+ version: z.number().int().positive(),
1278
+ measurements: z.array(canvasOutlineMeasurementSchema).min(1).max(200)
1279
+ });
1280
+ z.object({ stored: z.number().int().nonnegative() });
1281
+ z.strictObject({ canvasId: z.uuid() });
1282
+ z.object({ measurements: z.array(canvasOutlineMeasurementSchema.extend({ measuredVersion: z.number().int().nonnegative() })) });
1176
1283
  z.strictObject({});
1177
1284
  z.object({ firstAgentWorkAt: z.iso.datetime().nullable() });
1178
1285
  /** Cursor pagination, defined once so no endpoint invents its own page shape. */
@@ -1281,13 +1388,18 @@ const canvasSchema = z.object({
1281
1388
  createdAt: z.iso.datetime(),
1282
1389
  lastActivityAt: z.iso.datetime()
1283
1390
  });
1391
+ /**
1392
+ * A canvas with its full web address, which only the API can write: it is built from the web
1393
+ * address of the API's own environment, so a reader never joins an id to a host.
1394
+ */
1395
+ const linkedCanvasSchema = canvasSchema.extend({ url: z.url() });
1284
1396
  z.object({
1285
1397
  title: z.string().trim().min(1),
1286
1398
  /** The team to file it under, or null for the maker's own. Refused for one you are not on. */
1287
1399
  organisationId: z.uuid().nullable().default(null),
1288
1400
  sourceUrl: z.string().nullable().default(null)
1289
1401
  });
1290
- canvasSchema.extend({ version: z.number().int().positive() });
1402
+ linkedCanvasSchema.extend({ version: z.number().int().positive() });
1291
1403
  z.object({ canvasId: z.uuid() });
1292
1404
  /**
1293
1405
  * Which collection to draw: your own, a team's by id, or everything you can reach. One field
@@ -1311,7 +1423,7 @@ z.object({
1311
1423
  ]).default("all"),
1312
1424
  hasUnresolved: z.boolean().default(false)
1313
1425
  });
1314
- const canvasCardBaseSchema = canvasSchema.extend({
1426
+ const canvasCardBaseSchema = linkedCanvasSchema.extend({
1315
1427
  screenCount: z.number().int().min(0),
1316
1428
  hasRecording: z.boolean(),
1317
1429
  /** When the person listing last opened it in the web app; `null` if they never have. */
@@ -1751,6 +1863,11 @@ const canvasNodeLayoutSchema = z.object({
1751
1863
  clipContent: z.boolean().optional(),
1752
1864
  baselineSource: canvasBaselineSourceSchema.optional(),
1753
1865
  scrollbarGutter: canvasScrollbarGutterSchema.optional(),
1866
+ /**
1867
+ * The frame holds an embedded document. Chromium sizes that document's viewport in whole
1868
+ * pixels, rounding the frame's content box up, so what the frame holds resolves against that.
1869
+ */
1870
+ embeddedDocument: z.literal(true).optional(),
1754
1871
  container: canvasFlexLayoutSchema.partial().extend({ padding: canvasFlexPaddingSchema.partial().optional() }).optional()
1755
1872
  }).strict();
1756
1873
  //#endregion
@@ -1821,7 +1938,9 @@ const canvasOutlineSchema = z.object({
1821
1938
  ]),
1822
1939
  paints: z.array(canvasPaintSchema),
1823
1940
  dashPattern: canvasDashPatternSchema.optional(),
1824
- dashCap: canvasDashCapSchema.optional()
1941
+ dashCap: canvasDashCapSchema.optional(),
1942
+ /** Captured CSS dashes, which the browser draws, as for a border. */
1943
+ dashOrigin: z.literal("css").optional()
1825
1944
  });
1826
1945
  const canvasShadowSchema = z.object({
1827
1946
  id: itemId,
@@ -2298,13 +2417,13 @@ z.strictObject({
2298
2417
  }).refine((asset) => asset.state === "ready" === (asset.metadata !== null), "Readiness must match verified metadata.").refine((asset) => asset.metadata === null || asset.metadata.kind === asset.kind, "Metadata must describe the reserved asset kind.").refine((asset) => isStoredContentType(asset.kind, asset.contentType), "Content type must match the asset kind.").refine((asset) => asset.path === (asset.kind === "image" ? canvasImageAssetPath(asset.canvasId, asset.assetId) : canvasFontAssetPath(asset.canvasId, asset.sha256)), "The resource path must match its native identity.").safeExtend({ upload: signedUploadSchema.nullable() }).refine((asset) => asset.state === "awaiting_upload" === (asset.upload !== null), "Only pending uploads receive upload access.");
2299
2418
  //#endregion
2300
2419
  //#region ../contract/src/canvas/canvas-css-values.lib.ts
2301
- const SIDES = [
2420
+ const SIDES$1 = [
2302
2421
  "top",
2303
2422
  "right",
2304
2423
  "bottom",
2305
2424
  "left"
2306
2425
  ];
2307
- SIDES.map((side) => `padding-${side}`), SIDES.map((side) => `margin-${side}`);
2426
+ SIDES$1.map((side) => `padding-${side}`), SIDES$1.map((side) => `margin-${side}`);
2308
2427
  //#endregion
2309
2428
  //#region ../contract/src/canvas/canvas-export-settings.schema.ts
2310
2429
  const format = z.enum(["png", "jpeg"]);
@@ -2383,7 +2502,34 @@ const canvasGeometrySchema = z.discriminatedUnion("kind", [
2383
2502
  //#endregion
2384
2503
  //#region ../contract/src/canvas/canvas-scene.schema.ts
2385
2504
  const CANVAS_COMPOSITING_RETIRED = "Update Enhance: compositing is no longer supported. Use the isolation style or a mask group.";
2386
- const canvasDocumentFormatSchema = z.literal(15, { error: "This editor uses an unsupported document format. Update the editor before changing this canvas." });
2505
+ const CANVAS_FORMAT_UPDATE_REQUIRED = "This change needs a newer version of Enhance. Refresh the editor, or update the Enhance plugin or command-line tool, then try again.";
2506
+ const CANVAS_FORMAT_SERVER_UPDATING = "Enhance is being updated. Try again in a minute.";
2507
+ /** Marks an issue whose message was written for whoever sent the request, so the API keeps it. */
2508
+ const FOR_CALLER = { forCaller: true };
2509
+ /**
2510
+ * The format a writer was built for, as a plain whole number so tool schemas can describe it. Which
2511
+ * writes that format may make is `refuseUnsafeWriterFormat`'s call.
2512
+ */
2513
+ const canvasDocumentFormatSchema = z.number({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).int({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).positive({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).meta({
2514
+ description: `The document format this client writes. The current format is ${String(15)}.`,
2515
+ examples: [15]
2516
+ });
2517
+ /**
2518
+ * Refuses a write its client's format could get wrong. A client whose format differs from the
2519
+ * current one only in its number may still name changes, but a whole value it sends may lack
2520
+ * fields added since, so that needs the current format.
2521
+ */
2522
+ const refuseUnsafeWriterFormat = (documentFormatVersion, writes, context) => {
2523
+ const writer = canvasWriterFormat(documentFormatVersion);
2524
+ if (writer === "current" || writer === "number-only" && writes === "names") return;
2525
+ context.addIssue({
2526
+ code: "custom",
2527
+ path: ["documentFormatVersion"],
2528
+ message: writer === "ahead" ? CANVAS_FORMAT_SERVER_UPDATING : CANVAS_FORMAT_UPDATE_REQUIRED,
2529
+ params: FOR_CALLER,
2530
+ input: documentFormatVersion
2531
+ });
2532
+ };
2387
2533
  z.object({
2388
2534
  signature: z.string().regex(/^[a-f0-9]{16}$/u),
2389
2535
  /** The captured picture of the page's text, inline as written or as its canvas image store path. */
@@ -2500,7 +2646,8 @@ const canvasUnsupportedFeatureSchema = z.enum([
2500
2646
  "image-shadows",
2501
2647
  "effect-noise",
2502
2648
  "effect-texture",
2503
- "effect-glass"
2649
+ "effect-glass",
2650
+ "mask-source"
2504
2651
  ]);
2505
2652
  const canvasConversionReportSchema = z.object({
2506
2653
  nodeCount: z.number().int().positive(),
@@ -2542,13 +2689,27 @@ const canvasSubtreeDraftSchema = z.object({
2542
2689
  nodeCount: draft.nodes.length
2543
2690
  }
2544
2691
  }));
2545
- z.object({
2692
+ /** A capture that lands as a new editable frame on a page, with no screen layer. */
2693
+ const editableFrameCaptureSchema = z.object({
2694
+ screenId: z.string().min(1),
2695
+ pageId: z.string().min(1),
2696
+ pictureNodeId: z.string().min(1).optional().describe("The capture's picture, which the frame replaces in place and whose id it keeps. Refused as capture-already-landed once the picture is a frame.")
2697
+ });
2698
+ const editableFrameInputBase = {
2546
2699
  canvasId: z.uuid(),
2547
2700
  documentFormatVersion: canvasDocumentFormatSchema,
2548
2701
  mutationId: z.uuid(),
2549
2702
  baseVersion: z.number().int().positive(),
2550
- screenNodeId: z.string().min(1),
2551
2703
  draft: canvasSubtreeDraftSchema
2704
+ };
2705
+ z.union([z.strictObject({
2706
+ ...editableFrameInputBase,
2707
+ screenNodeId: z.string().min(1).describe("The screen layer to convert beside itself.")
2708
+ }), z.strictObject({
2709
+ ...editableFrameInputBase,
2710
+ capture: editableFrameCaptureSchema.describe("The stored page a new capture lands from, and the page its frame goes on.")
2711
+ })]).superRefine((input, context) => {
2712
+ refuseUnsafeWriterFormat(input.documentFormatVersion, "whole", context);
2552
2713
  });
2553
2714
  const createEditableFrameResultSchema = z.object({
2554
2715
  canvasId: z.uuid(),
@@ -2612,7 +2773,8 @@ const RENDER_WARNING_CODES = [
2612
2773
  "LOCAL_FONT_FALLBACK",
2613
2774
  "SOURCE_FALLBACK",
2614
2775
  "SCALE_REDUCED",
2615
- "LAYOUT_FALLBACK"
2776
+ "LAYOUT_FALLBACK",
2777
+ "DRAWN_APPROXIMATELY"
2616
2778
  ];
2617
2779
  //#endregion
2618
2780
  //#region ../contract/src/canvas/canvas-render.schema.ts
@@ -2654,7 +2816,10 @@ const canvasRenderSnapshotResultSchema = z.object({
2654
2816
  recordingId: z.uuid(),
2655
2817
  atMs: z.number().int().nonnegative(),
2656
2818
  screenId: z.uuid(),
2657
- screenNodeId: z.string().min(1),
2819
+ /** Null when the snapshot asked for a place only, so no screen layer was added. */
2820
+ screenNodeId: z.string().min(1).nullable(),
2821
+ /** The page the place is on. */
2822
+ pageId: z.string().min(1).optional(),
2658
2823
  viewport: z.object({
2659
2824
  width: z.number().int().positive(),
2660
2825
  height: z.number().int().positive()
@@ -2819,7 +2984,11 @@ const canvasSnapshotRequestSchema = z.strictObject({
2819
2984
  pageId: z.string().min(1).optional(),
2820
2985
  nodeIds: z.array(z.string().min(1))
2821
2986
  }),
2822
- placement: z.strictObject({ kind: z.literal("below-source") })
2987
+ /**
2988
+ * Below the walkthrough: as a screen layer, which installed CLIs ask for, or as a place only,
2989
+ * where the agent's CLI lands an editable frame.
2990
+ */
2991
+ placement: z.strictObject({ kind: z.enum(["below-source", "editable-below-source"]) })
2823
2992
  });
2824
2993
  z.object({
2825
2994
  canvasId: z.uuid(),
@@ -2848,7 +3017,12 @@ const canvasConversionDestinationSchema = z.discriminatedUnion("kind", [
2848
3017
  }),
2849
3018
  z.object({
2850
3019
  kind: z.literal("replace"),
2851
- targetNodeId: z.string().min(1)
3020
+ targetNodeId: z.string().min(1),
3021
+ /**
3022
+ * A capture's swap: the target must still be the capture's picture. When another browser has
3023
+ * already made it editable, the swap is refused as `capture-already-landed`.
3024
+ */
3025
+ onlyPicture: z.literal(true).optional()
2852
3026
  })
2853
3027
  ]);
2854
3028
  const canvasConversionSourceSchema = z.discriminatedUnion("kind", [z.object({
@@ -3086,6 +3260,21 @@ const canvasTextStylesSchema = z.strictObject({
3086
3260
  "text-align": textStyleValues["text-align"].optional(),
3087
3261
  "white-space": textStyleValues["white-space"].optional()
3088
3262
  });
3263
+ /** Every alignment a browser computes, which conversion stores and Undo must be able to put back. */
3264
+ const storedTextAlignSchema = z.enum([
3265
+ "start",
3266
+ "end",
3267
+ "left",
3268
+ "right",
3269
+ "center",
3270
+ "justify",
3271
+ "justify-all",
3272
+ "match-parent",
3273
+ "-webkit-left",
3274
+ "-webkit-right",
3275
+ "-webkit-center"
3276
+ ]);
3277
+ const storedFontStyleSchema = z.union([textStyleValues["font-style"], z.string().regex(/^oblique -?(?:\d+(?:\.\d+)?|\.\d+)deg$/u)]);
3089
3278
  const restorableTextStyleValue = z.union([canvasAdditionalStyleSchema.shape.value, canvasNumberSchema]).nullable().optional();
3090
3279
  const canvasTextStylePatchSchema = z.strictObject({
3091
3280
  "text-decoration": restorableTextStyleValue,
@@ -3108,7 +3297,7 @@ const canvasTextStylePatchSchema = z.strictObject({
3108
3297
  "text-box": canvasAdditionalStyleSchema.shape.value.nullable().optional(),
3109
3298
  "text-box-trim": canvasAdditionalStyleSchema.shape.value.nullable().optional(),
3110
3299
  "text-box-edge": canvasAdditionalStyleSchema.shape.value.nullable().optional(),
3111
- "font-style": textStyleValues["font-style"].nullable().optional(),
3300
+ "font-style": storedFontStyleSchema.nullable().optional(),
3112
3301
  "font-stretch": z.union([z.enum([
3113
3302
  "normal",
3114
3303
  "ultra-condensed",
@@ -3126,14 +3315,22 @@ const canvasTextStylePatchSchema = z.strictObject({
3126
3315
  z.literal("normal")
3127
3316
  ]).nullable().optional(),
3128
3317
  "line-height": textStyleValues["line-height"].nullable().optional(),
3129
- "text-align": textStyleValues["text-align"].nullable().optional(),
3318
+ "text-align": storedTextAlignSchema.nullable().optional(),
3130
3319
  "text-indent": z.union([canvasNumberSchema, signedPixelLengthSchema]).nullable().optional(),
3131
3320
  "white-space": textStyleValues["white-space"].nullable().optional(),
3132
3321
  "word-spacing": z.union([
3133
3322
  canvasNumberSchema,
3134
3323
  signedPixelLengthSchema,
3135
3324
  z.literal("normal")
3136
- ]).nullable().optional()
3325
+ ]).nullable().optional(),
3326
+ direction: restorableTextStyleValue,
3327
+ "unicode-bidi": restorableTextStyleValue,
3328
+ "hanging-punctuation": restorableTextStyleValue,
3329
+ "text-transform": restorableTextStyleValue,
3330
+ "-webkit-text-stroke": restorableTextStyleValue,
3331
+ "-webkit-text-stroke-width": restorableTextStyleValue,
3332
+ "-webkit-text-stroke-color": restorableTextStyleValue,
3333
+ "paint-order": restorableTextStyleValue
3137
3334
  });
3138
3335
  const overflowStyleValue = canvasAdditionalStyleSchema.shape.value;
3139
3336
  const dimensionalStyleValue = z.union([z.string(), canvasNumberSchema]);
@@ -3560,7 +3757,7 @@ const currentCanvasOperationSchema = z.discriminatedUnion("op", [
3560
3757
  removedText: z.record(nodeIdSchema$3, canvasSceneNodeSchema.pick({ props: true })).optional()
3561
3758
  })
3562
3759
  ]);
3563
- /** An older client's compositing write is refused with the CSS that replaces it. */
3760
+ currentCanvasOperationSchema.options;
3564
3761
  /** Each operation's name, for records that may state which kind failed and nothing else. */
3565
3762
  const CANVAS_OPERATION_NAMES = currentCanvasOperationSchema.options.map((option) => option.shape.op.value);
3566
3763
  const canvasOperationSchema = z.preprocess((value, context) => {
@@ -3621,6 +3818,8 @@ const canvasMutationRevisionSchema = z.object({
3621
3818
  operations: z.array(canvasOperationSchema)
3622
3819
  });
3623
3820
  z.object({
3821
+ /** The canvas's web address. An API older than the field answers without it. */
3822
+ url: z.url().optional(),
3624
3823
  mutations: z.array(canvasMutationRevisionSchema).optional(),
3625
3824
  version: z.number().int().min(1),
3626
3825
  /**
@@ -3653,6 +3852,123 @@ z.discriminatedUnion("outcome", [z.object({
3653
3852
  document: canvasDocumentBlobSchema
3654
3853
  })]);
3655
3854
  //#endregion
3855
+ //#region ../contract/src/canvas/canvas-document-parts.schema.ts
3856
+ /** One answer stops taking top layers once it holds this many layers, unless it is asked for more. */
3857
+ const CANVAS_PART_LAYER_LIMIT = 5e3;
3858
+ /** The most layers a read of parts may ask one answer to hold before it stops. */
3859
+ const CANVAS_PART_LAYER_LIMIT_MAX = 1e5;
3860
+ /** The most identifiers one read of parts may name in each list. */
3861
+ const CANVAS_PART_NAMED_LIMIT = 2e3;
3862
+ z.strictObject({ canvasId: z.uuid() });
3863
+ /** The font files a layer inside a top layer declares, without the rest of the layer. */
3864
+ const canvasFontDeclarationSchema = z.object({
3865
+ layerId: z.string(),
3866
+ /** The child of the root that holds the layer. */
3867
+ topLayerId: z.string(),
3868
+ fontFaces: z.array(z.unknown())
3869
+ });
3870
+ z.object({
3871
+ version: z.number().int().min(1),
3872
+ restoreFenceVersion: z.number().int().positive().optional(),
3873
+ /** The root and each child of the root, pages among them, and every removed-layer id. */
3874
+ document: canvasDocumentBlobSchema,
3875
+ screens: z.array(documentScreenSchema),
3876
+ /** Whether the canvas holds more than `LARGE_PAGE_LAYERS` layers, every page counted. */
3877
+ isLarge: z.boolean(),
3878
+ fontDeclarations: z.array(canvasFontDeclarationSchema)
3879
+ });
3880
+ const namedIds = z.array(z.string().min(1)).max(CANVAS_PART_NAMED_LIMIT);
3881
+ z.strictObject({
3882
+ canvasId: z.uuid(),
3883
+ /** Children of the root, answered in this order. */
3884
+ topLayerIds: namedIds.optional(),
3885
+ /** Layers anywhere; each is answered with the whole top layer that holds it. */
3886
+ layerIds: namedIds.optional(),
3887
+ /**
3888
+ * The layers after which the answer takes no further top layer. An editor raises it on a very
3889
+ * large canvas, so the whole canvas arrives in a bounded number of answers.
3890
+ */
3891
+ maxLayers: z.number().int().min(CANVAS_PART_LAYER_LIMIT).max(CANVAS_PART_LAYER_LIMIT_MAX).default(CANVAS_PART_LAYER_LIMIT)
3892
+ }).refine(({ topLayerIds = [], layerIds = [] }) => topLayerIds.length + layerIds.length > 0, "A read of parts names at least one layer.");
3893
+ z.object({
3894
+ /** The revision every layer of the answer was read at. */
3895
+ version: z.number().int().min(1),
3896
+ /** Each answered top layer's own record and every layer inside it: no root, no removed ids. */
3897
+ document: canvasDocumentBlobSchema,
3898
+ /** The top layers answered, in the order asked. */
3899
+ read: z.array(z.string()),
3900
+ /** The top layers left out because the answer was full, in the order asked. */
3901
+ notReached: z.array(z.string()),
3902
+ /** The named identifiers that are no top layer of the canvas, or are inside none. */
3903
+ absent: z.array(z.string())
3904
+ });
3905
+ //#endregion
3906
+ //#region ../contract/src/canvas/canvas-first-letter.lib.ts
3907
+ /** Custom CSS on a text layer that styles its first letter, one declaration per property. */
3908
+ const CANVAS_FIRST_LETTER_PREFIX = "--canvas-first-letter-";
3909
+ const SIDES = [
3910
+ "top",
3911
+ "right",
3912
+ "bottom",
3913
+ "left"
3914
+ ];
3915
+ /**
3916
+ * The properties a first letter takes (CSS Pseudo-Elements 4, `::first-letter`), each with the
3917
+ * value it has when a layer does not declare it: its block's for a property that inherits, the
3918
+ * initial value for one that does not.
3919
+ */
3920
+ const CANVAS_FIRST_LETTER_PROPERTIES = {
3921
+ ...Object.fromEntries([
3922
+ "color",
3923
+ "font-family",
3924
+ "font-size",
3925
+ "font-stretch",
3926
+ "font-style",
3927
+ "font-weight",
3928
+ "font-variant-caps",
3929
+ "font-variant-ligatures",
3930
+ "font-variant-numeric",
3931
+ "font-feature-settings",
3932
+ "font-variation-settings",
3933
+ "font-kerning",
3934
+ "letter-spacing",
3935
+ "line-height",
3936
+ "text-shadow",
3937
+ "text-transform",
3938
+ "word-spacing",
3939
+ "-webkit-text-fill-color",
3940
+ "-webkit-text-stroke-color",
3941
+ "-webkit-text-stroke-width"
3942
+ ].map((property) => [property, "inherit"])),
3943
+ ...Object.fromEntries([
3944
+ "float",
3945
+ "vertical-align",
3946
+ "initial-letter",
3947
+ "opacity",
3948
+ "background-color",
3949
+ "background-image",
3950
+ "box-shadow",
3951
+ "text-decoration-line",
3952
+ "text-decoration-style",
3953
+ "text-decoration-color",
3954
+ "text-decoration-thickness",
3955
+ ...SIDES.flatMap((side) => [
3956
+ `margin-${side}`,
3957
+ `padding-${side}`,
3958
+ `border-${side}-style`,
3959
+ `border-${side}-width`,
3960
+ `border-${side}-color`
3961
+ ]),
3962
+ ...[
3963
+ "top-left",
3964
+ "top-right",
3965
+ "bottom-right",
3966
+ "bottom-left"
3967
+ ].map((corner) => `border-${corner}-radius`)
3968
+ ].map((property) => [property, "initial"]))
3969
+ };
3970
+ `${Object.entries(CANVAS_FIRST_LETTER_PROPERTIES).map(([property, fallback]) => `${property}:var(${CANVAS_FIRST_LETTER_PREFIX}${property},${fallback})`).join(";")}`;
3971
+ //#endregion
3656
3972
  //#region ../contract/src/canvas/canvas-text-content.lib.ts
3657
3973
  const textLinkSchema = z.object({
3658
3974
  start: z.number().int().nonnegative(),
@@ -3684,13 +4000,30 @@ const canvasPropertySectionSchema = z.enum([
3684
4000
  "export",
3685
4001
  "source"
3686
4002
  ]);
4003
+ //#endregion
4004
+ //#region ../contract/src/canvas/canvas-inspection.schema.ts
4005
+ const MAX_RENDER_MESSAGE_LENGTH = 500;
4006
+ const MAX_RENDER_KIND_LENGTH = 100;
4007
+ /**
4008
+ * What a layer's box is: `placed` where the canvas draws the layer, `placed-before-transform` where
4009
+ * it draws the layer before the layer's own transform, `recorded` a size kept from when the layer
4010
+ * was made, for a layer the browser lays out.
4011
+ */
4012
+ const canvasBoxSourceSchema = z.enum([
4013
+ "placed",
4014
+ "placed-before-transform",
4015
+ "recorded"
4016
+ ]);
4017
+ /** Present only on a read that holds a `recorded` box. */
4018
+ const boxNoteSchema = z.string().min(1).optional();
3687
4019
  const canvasInspectNodeSummarySchema = z.object({
3688
4020
  id: z.string().min(1),
3689
- label: z.string().max(500),
3690
- kind: z.string().min(1).max(100),
4021
+ label: z.string().max(MAX_RENDER_MESSAGE_LENGTH),
4022
+ kind: z.string().min(1).max(MAX_RENDER_KIND_LENGTH),
3691
4023
  parentId: z.string().min(1).nullable(),
3692
4024
  childCount: z.number().int().min(0),
3693
4025
  box: canvasSceneBoxSchema.nullable(),
4026
+ boxSource: canvasBoxSourceSchema.optional(),
3694
4027
  propertySections: z.array(canvasPropertySectionSchema)
3695
4028
  });
3696
4029
  z.object({ canvasId: z.uuid() });
@@ -3703,13 +4036,15 @@ z.object({
3703
4036
  rootChildCount: z.number().int().min(0),
3704
4037
  bounds: canvasSceneBoxSchema.nullable(),
3705
4038
  kinds: z.record(z.string(), z.number().int().min(0)),
4039
+ boxNote: boxNoteSchema,
3706
4040
  next: z.array(z.string().min(1))
3707
4041
  });
3708
4042
  z.object({ canvasId: z.uuid() });
3709
4043
  z.object({
3710
4044
  canvasId: z.uuid(),
3711
4045
  version: z.number().int().positive(),
3712
- nodes: z.array(canvasInspectNodeSummarySchema)
4046
+ nodes: z.array(canvasInspectNodeSummarySchema),
4047
+ boxNote: boxNoteSchema
3713
4048
  });
3714
4049
  z.object({
3715
4050
  canvasId: z.uuid(),
@@ -3728,9 +4063,49 @@ z.object({
3728
4063
  props: z.record(z.string(), z.unknown()),
3729
4064
  children: z.array(z.string().min(1))
3730
4065
  }),
4066
+ boxNote: boxNoteSchema,
3731
4067
  next: z.array(z.string().min(1))
3732
4068
  });
3733
4069
  //#endregion
4070
+ //#region ../contract/src/canvas/canvas-operation-writes.schema.ts
4071
+ /**
4072
+ * What each operation writes. `names` sets one plain value, places, removes, or merges a patch, so
4073
+ * values its client never knew stay as stored. `whole` brings a whole layer or replaces a whole
4074
+ * group of values, which a client that read the canvas in an older format may have stripped.
4075
+ */
4076
+ const CANVAS_OPERATION_WRITES = {
4077
+ insertConvertedSubtree: "whole",
4078
+ insertNode: "whole",
4079
+ insertText: "names",
4080
+ insertPrototype: "names",
4081
+ setPrototypeDeployment: "names",
4082
+ editText: "names",
4083
+ setText: "names",
4084
+ setBox: "names",
4085
+ setLabel: "names",
4086
+ setContainerKind: "names",
4087
+ setVisibility: "names",
4088
+ setLocked: "names",
4089
+ setConstraints: "names",
4090
+ setStyles: "names",
4091
+ patchExportSettings: "names",
4092
+ setAppearance: "names",
4093
+ setLayout: "whole",
4094
+ patchTypography: "names",
4095
+ setTypography: "whole",
4096
+ patchAdditionalStyles: "names",
4097
+ setAdditionalStyles: "whole",
4098
+ setArtworkColor: "whole",
4099
+ setTextStyleLibrary: "whole",
4100
+ patchFontLibrary: "names",
4101
+ setTextStyle: "whole",
4102
+ setGeometry: "whole",
4103
+ setProps: "whole",
4104
+ setParentage: "names",
4105
+ move: "names",
4106
+ remove: "names"
4107
+ };
4108
+ //#endregion
3734
4109
  //#region ../contract/src/canvas/canvas-mutation.schema.ts
3735
4110
  const nodeIdSchema$2 = canvasSceneNodeSchema.shape.id;
3736
4111
  const writableBoxSchema = canvasSceneBoxSchema.extend({
@@ -3738,6 +4113,8 @@ const writableBoxSchema = canvasSceneBoxSchema.extend({
3738
4113
  height: z.number().positive()
3739
4114
  });
3740
4115
  const copiedNodeIdsSchema = z.record(nodeIdSchema$2, nodeIdSchema$2);
4116
+ /** A receipt stored before boxes said what they are holds none, so the source stays optional. */
4117
+ const canvasReceiptBoxSchema = canvasSceneBoxSchema.extend({ boxSource: canvasBoxSourceSchema.optional() });
3741
4118
  const canvasMutationRequestContextSchema = z.strictObject({
3742
4119
  fingerprint: z.string().regex(/^[a-f0-9]{64}$/u),
3743
4120
  revisionPolicy: z.enum(["strict", "rebase"]),
@@ -3751,6 +4128,8 @@ z.object({
3751
4128
  operations: z.array(canvasOperationSchema).min(1),
3752
4129
  requestContext: canvasMutationRequestContextSchema.optional(),
3753
4130
  writeScope: canvasWriteScopeSchema.optional()
4131
+ }).superRefine((input, context) => {
4132
+ refuseUnsafeWriterFormat(input.documentFormatVersion, input.operations.every((operation) => CANVAS_OPERATION_WRITES[operation.op] === "names") ? "names" : "whole", context);
3754
4133
  });
3755
4134
  const applyCanvasOperationsOutputSchema = z.object({
3756
4135
  canvasId: z.uuid(),
@@ -3761,7 +4140,7 @@ const applyCanvasOperationsOutputSchema = z.object({
3761
4140
  insertedNodeIds: z.array(nodeIdSchema$2),
3762
4141
  changedNodeIds: z.array(nodeIdSchema$2),
3763
4142
  removedNodeIds: z.array(nodeIdSchema$2),
3764
- boxes: z.record(nodeIdSchema$2, canvasSceneBoxSchema),
4143
+ boxes: z.record(nodeIdSchema$2, canvasReceiptBoxSchema),
3765
4144
  affectedBounds: writableBoxSchema.nullable(),
3766
4145
  copiedNodeIds: copiedNodeIdsSchema.optional(),
3767
4146
  next: z.array(z.string().min(1))
@@ -3773,7 +4152,8 @@ z.strictObject({
3773
4152
  });
3774
4153
  z.discriminatedUnion("state", [z.strictObject({ state: z.literal("not-found") }), z.strictObject({
3775
4154
  state: z.literal("committed"),
3776
- result: applyCanvasOperationsOutputSchema
4155
+ /** `url` is the canvas's web address. An API older than the field answers without it. */
4156
+ result: applyCanvasOperationsOutputSchema.extend({ url: z.url().optional() })
3777
4157
  })]);
3778
4158
  //#endregion
3779
4159
  //#region ../contract/src/canvas/canvas-mutation-review.schema.ts
@@ -4176,8 +4556,10 @@ const canvasPreparationRequestSchema = z.discriminatedUnion("kind", [
4176
4556
  sources: z.array(z.strictObject({
4177
4557
  screenId: z.uuid(),
4178
4558
  captureId: z.uuid(),
4179
- label: z.string().min(1)
4180
- })).min(1)
4559
+ /** What the frame is called. Absent, the frame takes the stored page's own title. */
4560
+ label: z.string().min(1).optional()
4561
+ })).min(1),
4562
+ landing: z.literal("editable-frame").optional().describe("Lands the page as an ordinary editable frame. Without it, the layers belong to a capture run.")
4181
4563
  }),
4182
4564
  canvasArrangePreparationSchema,
4183
4565
  canvasDuplicatePreparationSchema,
@@ -4258,7 +4640,11 @@ const canvasPreparationJobSchema = z.discriminatedUnion("state", [
4258
4640
  job.extend({
4259
4641
  state: z.literal("succeeded"),
4260
4642
  phase: z.literal("complete"),
4261
- result: canvasPreparationPlanSchema.extend({ loadedVersion: z.number().int().positive() }),
4643
+ result: canvasPreparationPlanSchema.extend({
4644
+ loadedVersion: z.number().int().positive(),
4645
+ /** Where a screen compile fell back, such as a font it replaced; absent when it had none. */
4646
+ warnings: z.array(canvasRenderWarningSchema).optional()
4647
+ }),
4262
4648
  failure: z.null()
4263
4649
  }),
4264
4650
  job.extend({
@@ -4651,7 +5037,8 @@ z.discriminatedUnion("purpose", [
4651
5037
  "inspection",
4652
5038
  "snapshot",
4653
5039
  "thumbnail",
4654
- "export"
5040
+ "export",
5041
+ "object-pictures"
4655
5042
  ]),
4656
5043
  scale: z.number().positive(),
4657
5044
  maxOutputPixels: canvasRenderPixelLimitSchema.optional(),
@@ -4722,6 +5109,16 @@ z.discriminatedUnion("purpose", [
4722
5109
  sourceState: z.undefined().optional(),
4723
5110
  conversion: canvasConversionRequestSchema,
4724
5111
  scale: z.literal(1)
5112
+ }),
5113
+ claimRenderWorkBaseSchema.extend({
5114
+ purpose: z.literal("object-pictures"),
5115
+ target: canvasRenderTargetSchema,
5116
+ sourceState: z.undefined().optional(),
5117
+ scale: z.number().positive(),
5118
+ maxOutputPixels: canvasRenderPixelLimitSchema.optional(),
5119
+ /** The top layers to draw, in order; each picture is stored under the prefix. */
5120
+ objects: z.array(objectPictureWorkObjectSchema).max(20),
5121
+ outputPrefix: z.string().min(1).max(MAX_STORAGE_KEY_LENGTH)
4725
5122
  })
4726
5123
  ]);
4727
5124
  z.object({
@@ -4868,6 +5265,7 @@ z.object({
4868
5265
  nodes: z.array(canvasInspectNodeSummarySchema),
4869
5266
  contextRootId: nodeIdSchema.nullable(),
4870
5267
  visibleWorldBox: canvasWorldBoundsSchema.nullable(),
5268
+ boxNote: z.string().min(1).optional(),
4871
5269
  next: z.array(z.string().min(1)).max(MAX_SELECTION_COMMANDS)
4872
5270
  });
4873
5271
  //#endregion
@@ -4876,6 +5274,17 @@ const canvasCaptureProvenanceSchema = z.discriminatedUnion("kind", [z.object({
4876
5274
  kind: z.literal("recording"),
4877
5275
  recordingId: z.string()
4878
5276
  })]);
5277
+ /**
5278
+ * The mark on a captured page's picture while it becomes editable. Every capture lands as this
5279
+ * picture first; whoever converts it replaces the same layer with the editable frame, through the
5280
+ * one swap (`insertConvertedSubtree` with destination `replace` and `onlyPicture`). A conversion
5281
+ * that fails writes `failed` with a short reason, so every viewer sees the failure rather than a
5282
+ * spinner that never ends; Try again writes `converting` again.
5283
+ */
5284
+ const captureLandingSchema = z.discriminatedUnion("state", [z.object({ state: z.literal("converting") }), z.object({
5285
+ state: z.literal("failed"),
5286
+ reason: z.string().min(1).max(200)
5287
+ })]);
4879
5288
  z.object({
4880
5289
  html: z.string().optional(),
4881
5290
  viewport: z.object({
@@ -4885,7 +5294,8 @@ z.object({
4885
5294
  atMs: z.number(),
4886
5295
  screenId: z.string().nullable().default(null),
4887
5296
  sourceNodeId: z.string().optional(),
4888
- provenance: canvasCaptureProvenanceSchema.optional()
5297
+ provenance: canvasCaptureProvenanceSchema.optional(),
5298
+ landing: captureLandingSchema.optional()
4889
5299
  });
4890
5300
  z.object({
4891
5301
  provenance: canvasCaptureProvenanceSchema.optional(),
@@ -5015,12 +5425,16 @@ z.object({
5015
5425
  versionId: z.uuid()
5016
5426
  });
5017
5427
  z.object({ entry: canvasVersionEntrySchema });
5428
+ /** A restore or a duplicate copies a version the API holds, so it only names what to change. */
5429
+ const refuseUnsafeVersionCopy = (input, context) => {
5430
+ refuseUnsafeWriterFormat(input.documentFormatVersion, "names", context);
5431
+ };
5018
5432
  z.object({
5019
5433
  canvasId: z.uuid(),
5020
5434
  documentFormatVersion: canvasDocumentFormatSchema,
5021
5435
  versionId: z.uuid(),
5022
5436
  expectedVersion: z.number().int().positive()
5023
- });
5437
+ }).superRefine(refuseUnsafeVersionCopy);
5024
5438
  z.object({
5025
5439
  canvasId: z.uuid(),
5026
5440
  version: z.number().int().positive(),
@@ -5034,7 +5448,7 @@ z.object({
5034
5448
  versionId: z.uuid(),
5035
5449
  organisationId: z.union([z.uuid(), z.literal("personal")]),
5036
5450
  title: z.string().trim().min(1).optional()
5037
- });
5451
+ }).superRefine(refuseUnsafeVersionCopy);
5038
5452
  z.object({
5039
5453
  canvasId: z.uuid(),
5040
5454
  title: z.string().min(1),
@@ -5223,6 +5637,16 @@ const setReviewStateInputSchema = z.object({
5223
5637
  ])
5224
5638
  });
5225
5639
  z.object({ reviewState: setReviewStateInputSchema.shape.reviewState.nullable() });
5640
+ z.object({ canvasId: z.uuid() });
5641
+ z.object({
5642
+ /** The only credential a page receives: it stores captures and does nothing else. */
5643
+ pass: z.string().min(1),
5644
+ expiresAt: z.iso.datetime(),
5645
+ /** Where the capture script is published, for the snippet to load. */
5646
+ scriptUrl: z.url(),
5647
+ /** Where the page stores its capture: the API as the page reaches it. */
5648
+ apiUrl: z.url()
5649
+ });
5226
5650
  //#endregion
5227
5651
  //#region ../contract/src/comment/comment.schema.ts
5228
5652
  /** How many replies a thread hands back in one go before `hasMoreMessages` takes over. */
@@ -6524,6 +6948,12 @@ z.object({
6524
6948
  version: z.number().int().positive()
6525
6949
  })]).optional()
6526
6950
  });
6951
+ z.object({ bytes: z.number().int().positive().max(Number.MAX_SAFE_INTEGER) });
6952
+ z.object({
6953
+ id: z.uuid(),
6954
+ upload: signedUploadSchema
6955
+ });
6956
+ z.object({ id: z.uuid() });
6527
6957
  const MAX_PROTOTYPE_CONTENT_TYPE_LENGTH = 200;
6528
6958
  const prototypePathSchema = z.string().min(1).refine((value) => !value.startsWith("/") && !value.endsWith("/") && !value.includes("\\") && !value.includes("\0") && value.split("/").every((part) => part !== "" && part !== "." && part !== ".."), { message: "prototype paths must be portable relative file paths" });
6529
6959
  const prototypeFileSchema = z.object({
@@ -6661,6 +7091,7 @@ z$1.extend(prototypeBridgeConnectRequestSchema, {
6661
7091
  capabilities: z$1.array(z$1.string()),
6662
7092
  release: z$1.string().check(z$1.minLength(1))
6663
7093
  });
7094
+ z$1.extend(prototypeBridgeConnectRequestSchema, { type: z$1.literal("enhance.prototype.capture-blocked") });
6664
7095
  z$1.object({
6665
7096
  protocol: z$1.literal(1),
6666
7097
  type: z$1.literal("enhance.prototype.unloading"),
@@ -6957,6 +7388,21 @@ const missingReplayAssetSourceIn = (url) => {
6957
7388
  return null;
6958
7389
  }
6959
7390
  };
7391
+ [`[data-enhance-unsupported]:not([data-enhance-unsupported-hidden]):not([style*="display: none"]) {
7392
+ align-items: center !important;
7393
+ background-color: #f7f7f8 !important;
7394
+ background-image: linear-gradient(to top right, transparent calc(50% - 1px), #a8a8b0 50%, transparent calc(50% + 1px)), linear-gradient(to bottom right, transparent calc(50% - 1px), #a8a8b0 50%, transparent calc(50% + 1px)) !important;
7395
+ border: 1px solid #c7c7cc !important;
7396
+ box-sizing: border-box !important;
7397
+ color: #4f4f55 !important;
7398
+ display: flex !important;
7399
+ font: 500 14px/1.4 Inter, ui-sans-serif, system-ui, sans-serif !important;
7400
+ justify-content: center !important;
7401
+ overflow: hidden !important;
7402
+ text-align: center !important;
7403
+ }`, `[data-enhance-unsupported-hidden], [data-enhance-unsupported][style*="display: none"] {
7404
+ display: none !important;
7405
+ }`].join("\n");
6960
7406
  //#endregion
6961
7407
  //#region ../contract/src/recording/page-asset-references.lib.ts
6962
7408
  /**
@@ -7279,21 +7725,6 @@ z.object({
7279
7725
  /** Screens survive with their provenance nulled. That is what makes iteration safe. */
7280
7726
  detachedScreenCount: z.number().int().min(0)
7281
7727
  });
7282
- [`[data-enhance-unsupported]:not([data-enhance-unsupported-hidden]):not([style*="display: none"]) {
7283
- align-items: center !important;
7284
- background-color: #f7f7f8 !important;
7285
- background-image: linear-gradient(to top right, transparent calc(50% - 1px), #a8a8b0 50%, transparent calc(50% + 1px)), linear-gradient(to bottom right, transparent calc(50% - 1px), #a8a8b0 50%, transparent calc(50% + 1px)) !important;
7286
- border: 1px solid #c7c7cc !important;
7287
- box-sizing: border-box !important;
7288
- color: #4f4f55 !important;
7289
- display: flex !important;
7290
- font: 500 14px/1.4 Inter, ui-sans-serif, system-ui, sans-serif !important;
7291
- justify-content: center !important;
7292
- overflow: hidden !important;
7293
- text-align: center !important;
7294
- }`, `[data-enhance-unsupported-hidden], [data-enhance-unsupported][style*="display: none"] {
7295
- display: none !important;
7296
- }`].join("\n");
7297
7728
  z.object({
7298
7729
  /**
7299
7730
  * Client-minted, once per capture attempt. A retry is the same screen; a re-capture at the
@@ -7317,6 +7748,8 @@ z.object({
7317
7748
  });
7318
7749
  z.object({
7319
7750
  screenId: z.uuid(),
7751
+ /** Where the screen's files are stored; a capture names its stored copies by it. */
7752
+ assetBundleId: z.uuid().nullable(),
7320
7753
  /** Re-issued on every call, because the usual reason for a retry is an expired presign. */
7321
7754
  upload: signedUploadSchema,
7322
7755
  alreadyExists: z.boolean(),
@@ -7603,7 +8036,9 @@ const clientRenderFailureDetailsSchema = z.strictObject({
7603
8036
  "clipboard-unavailable",
7604
8037
  "clipboard-image-pending",
7605
8038
  "clipboard-image-unavailable",
8039
+ "paste-content-refused",
7606
8040
  "edit-target-unsupported",
8041
+ "edit-result-invalid",
7607
8042
  "react-hook-order",
7608
8043
  "menu-rows-unsupported"
7609
8044
  ]),
@@ -7639,6 +8074,7 @@ const clientRenderFailureDetailsSchema = z.strictObject({
7639
8074
  subsystem: z.enum([
7640
8075
  "menu",
7641
8076
  "menu-picture",
8077
+ "arrival-cue",
7642
8078
  "unknown"
7643
8079
  ]).optional(),
7644
8080
  repeats: count$1.optional(),
@@ -7713,7 +8149,18 @@ const CANVAS_SYNC_REPORTS = [
7713
8149
  "whole-value-text",
7714
8150
  "retrying",
7715
8151
  "recovery",
7716
- "trace"
8152
+ "trace",
8153
+ "update-required"
8154
+ ];
8155
+ /** How a failed document read was answered, on the report of one worth a look. */
8156
+ const CANVAS_SYNC_READ_OUTCOMES = [
8157
+ "transient",
8158
+ "no-edit-access",
8159
+ "restored",
8160
+ "replan",
8161
+ "refused",
8162
+ "update-required",
8163
+ "fault"
7717
8164
  ];
7718
8165
  const CANVAS_SYNC_DETAILS = [
7719
8166
  ...CLIENT_SAVE_ISSUES,
@@ -7750,7 +8197,8 @@ const CANVAS_SYNC_REPORT_STATUSES = [
7750
8197
  "view-only",
7751
8198
  "sign-in",
7752
8199
  "gone",
7753
- "restored"
8200
+ "restored",
8201
+ "update-required"
7754
8202
  ];
7755
8203
  /** Whether a recovery state began in this visit or was reopened from the browser copy. */
7756
8204
  const CANVAS_SYNC_EPISODES = ["new", "reopened"];
@@ -7792,6 +8240,7 @@ const CANVAS_SAVE_NOTICE_CAUSES = [
7792
8240
  "refused",
7793
8241
  "copy-refused",
7794
8242
  "copy-preview",
8243
+ "update-required",
7795
8244
  "unknown"
7796
8245
  ];
7797
8246
  const CANVAS_SAVE_SEVERITIES = [
@@ -7815,7 +8264,8 @@ const CANVAS_SAVE_ACTIONS = [
7815
8264
  "retry-upload",
7816
8265
  "choose-file",
7817
8266
  "remove-screen",
7818
- "go-to-canvases"
8267
+ "go-to-canvases",
8268
+ "reload"
7819
8269
  ];
7820
8270
  const CANVAS_SAVE_OUTCOMES = [
7821
8271
  "saved",
@@ -7909,6 +8359,7 @@ z.strictObject({
7909
8359
  durationMs: z.number().int().nonnegative(),
7910
8360
  pendingChanges: z.number().int().nonnegative(),
7911
8361
  reason: z.enum(CANVAS_SYNC_DETAILS).optional(),
8362
+ readOutcome: z.enum(CANVAS_SYNC_READ_OUTCOMES).optional(),
7912
8363
  status: z.enum(CANVAS_SYNC_REPORT_STATUSES).optional(),
7913
8364
  episode: z.enum(CANVAS_SYNC_EPISODES).optional(),
7914
8365
  trace: canvasSaveTraceSchema.optional()
@@ -7919,7 +8370,8 @@ z.object({
7919
8370
  "delivered",
7920
8371
  "failed",
7921
8372
  "disabled",
7922
- "no-identity"
8373
+ "no-identity",
8374
+ "expired"
7923
8375
  ]).optional()
7924
8376
  });
7925
8377
  z.discriminatedUnion("type", [z.object({ type: z.literal("enhance3:extension-probe") }).strict(), z.object({ type: z.literal("enhance3:extension-present") }).strict()]);
@@ -8139,8 +8591,8 @@ var StorageRequestError = class extends Error {
8139
8591
  //#region ../contract/src/shared/request-outcome.lib.ts
8140
8592
  const listed = (allowed, value) => typeof value === "string" && allowed.includes(value) ? value : null;
8141
8593
  const refusalOf = (error) => {
8142
- const { refusalCode, operation, component } = error.fields ?? {};
8143
- if (refusalCode === void 0 && operation === void 0 && component === void 0) return void 0;
8594
+ const { refusalCode, operation, component, operationIndex } = error.fields ?? {};
8595
+ if (refusalCode === void 0 && operation === void 0 && component === void 0 && operationIndex === void 0) return void 0;
8144
8596
  const code = CANVAS_SAVE_REFUSAL_CODES.find((value) => value === refusalCode);
8145
8597
  return {
8146
8598
  refusalCode: refusalCode === void 0 ? "unclassified" : code ?? "unknown",
@@ -8152,6 +8604,15 @@ const refusalOf = (error) => {
8152
8604
  const MUTATION_ID_REUSED = "mutation-id-reused";
8153
8605
  /** `fields.reason` on a 413, whether the server's envelope or a proxy's bare status says so. */
8154
8606
  const REQUEST_TOO_LARGE = "request-too-large";
8607
+ const tooLarge = {
8608
+ kind: "refused",
8609
+ reason: REQUEST_TOO_LARGE,
8610
+ refusal: {
8611
+ refusalCode: REQUEST_TOO_LARGE,
8612
+ operation: "unknown",
8613
+ component: "unknown"
8614
+ }
8615
+ };
8155
8616
  const HTTP_UNAUTHORIZED = 401;
8156
8617
  const HTTP_FORBIDDEN = 403;
8157
8618
  const HTTP_NOT_FOUND = 404;
@@ -8186,17 +8647,15 @@ const conflictOutcome = (error) => {
8186
8647
  reason: error.message
8187
8648
  };
8188
8649
  };
8189
- /** The server names the two refusals a client must tell apart; any other is the message. */
8650
+ /** The server names the refusals a client must tell apart; any other is the message. */
8190
8651
  const badRequestOutcome = (error) => {
8191
8652
  const reason = error.fields?.["reason"];
8192
8653
  if (reason === "mutation-id-reused") return {
8193
8654
  kind: "fault",
8194
8655
  detail: MUTATION_ID_REUSED
8195
8656
  };
8196
- if (reason === "request-too-large") return {
8197
- kind: "refused",
8198
- reason: REQUEST_TOO_LARGE
8199
- };
8657
+ if (reason === "request-too-large") return tooLarge;
8658
+ if (error.fields?.["documentFormatVersion"] === "This change needs a newer version of Enhance. Refresh the editor, or update the Enhance plugin or command-line tool, then try again.") return { kind: "update-required" };
8200
8659
  const refusal = refusalOf(error);
8201
8660
  return {
8202
8661
  kind: "refused",
@@ -8228,10 +8687,7 @@ const statusOutcome = (status, retryAfterMs) => {
8228
8687
  };
8229
8688
  if (status === HTTP_FORBIDDEN) return { kind: "no-edit-access" };
8230
8689
  if (status === HTTP_NOT_FOUND) return { kind: "gone" };
8231
- if (status === HTTP_TOO_LARGE) return {
8232
- kind: "refused",
8233
- reason: REQUEST_TOO_LARGE
8234
- };
8690
+ if (status === HTTP_TOO_LARGE) return tooLarge;
8235
8691
  if (status === HTTP_TIMEOUT || status === HTTP_TOO_MANY_REQUESTS || status === HTTP_CLIENT_CLOSED || status >= HTTP_SERVER_ERROR) return {
8236
8692
  kind: "transient",
8237
8693
  retryAfterMs