@enhance-eng/sdk 0.1.161 → 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.
- package/README.md +5 -2
- package/dist/browser/kernel.iife.js +1719 -399
- package/dist/{capture-client.client-BM_NxOqy.mjs → capture-client.client-C_8yINru.mjs} +3 -3
- package/dist/{capture-context.lib-LXUORfkL.mjs → capture-context.lib-D4OEonRp.mjs} +2 -2
- package/dist/client.mjs +1 -1
- package/dist/environment.config-Ctm1VHM9.mjs +83 -0
- package/dist/index.mjs +2 -2
- package/dist/{package-BFIjCgBc.mjs → package-C-PfWfSh.mjs} +1 -1
- package/dist/playwright/index.mjs +175 -70
- package/dist/playwright/reporter.mjs +4 -4
- package/dist/{stall-watch.lib-DgIzqC3b.mjs → stall-watch.lib-JRTp4jPK.mjs} +468 -58
- package/package.json +3 -3
- package/dist/environment.config-BlBA4N5X.mjs +0 -34
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { z as z$1 } from "zod/mini";
|
|
3
|
-
import {
|
|
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
|
|
826
|
-
|
|
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
|
|
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
|
-
|
|
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 =
|
|
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
|
|
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(),
|
|
@@ -2545,7 +2692,8 @@ const canvasSubtreeDraftSchema = z.object({
|
|
|
2545
2692
|
/** A capture that lands as a new editable frame on a page, with no screen layer. */
|
|
2546
2693
|
const editableFrameCaptureSchema = z.object({
|
|
2547
2694
|
screenId: z.string().min(1),
|
|
2548
|
-
pageId: 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.")
|
|
2549
2697
|
});
|
|
2550
2698
|
const editableFrameInputBase = {
|
|
2551
2699
|
canvasId: z.uuid(),
|
|
@@ -2560,7 +2708,9 @@ z.union([z.strictObject({
|
|
|
2560
2708
|
}), z.strictObject({
|
|
2561
2709
|
...editableFrameInputBase,
|
|
2562
2710
|
capture: editableFrameCaptureSchema.describe("The stored page a new capture lands from, and the page its frame goes on.")
|
|
2563
|
-
})])
|
|
2711
|
+
})]).superRefine((input, context) => {
|
|
2712
|
+
refuseUnsafeWriterFormat(input.documentFormatVersion, "whole", context);
|
|
2713
|
+
});
|
|
2564
2714
|
const createEditableFrameResultSchema = z.object({
|
|
2565
2715
|
canvasId: z.uuid(),
|
|
2566
2716
|
mutationId: z.uuid(),
|
|
@@ -2623,7 +2773,8 @@ const RENDER_WARNING_CODES = [
|
|
|
2623
2773
|
"LOCAL_FONT_FALLBACK",
|
|
2624
2774
|
"SOURCE_FALLBACK",
|
|
2625
2775
|
"SCALE_REDUCED",
|
|
2626
|
-
"LAYOUT_FALLBACK"
|
|
2776
|
+
"LAYOUT_FALLBACK",
|
|
2777
|
+
"DRAWN_APPROXIMATELY"
|
|
2627
2778
|
];
|
|
2628
2779
|
//#endregion
|
|
2629
2780
|
//#region ../contract/src/canvas/canvas-render.schema.ts
|
|
@@ -2866,7 +3017,12 @@ const canvasConversionDestinationSchema = z.discriminatedUnion("kind", [
|
|
|
2866
3017
|
}),
|
|
2867
3018
|
z.object({
|
|
2868
3019
|
kind: z.literal("replace"),
|
|
2869
|
-
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()
|
|
2870
3026
|
})
|
|
2871
3027
|
]);
|
|
2872
3028
|
const canvasConversionSourceSchema = z.discriminatedUnion("kind", [z.object({
|
|
@@ -3601,7 +3757,7 @@ const currentCanvasOperationSchema = z.discriminatedUnion("op", [
|
|
|
3601
3757
|
removedText: z.record(nodeIdSchema$3, canvasSceneNodeSchema.pick({ props: true })).optional()
|
|
3602
3758
|
})
|
|
3603
3759
|
]);
|
|
3604
|
-
|
|
3760
|
+
currentCanvasOperationSchema.options;
|
|
3605
3761
|
/** Each operation's name, for records that may state which kind failed and nothing else. */
|
|
3606
3762
|
const CANVAS_OPERATION_NAMES = currentCanvasOperationSchema.options.map((option) => option.shape.op.value);
|
|
3607
3763
|
const canvasOperationSchema = z.preprocess((value, context) => {
|
|
@@ -3662,6 +3818,8 @@ const canvasMutationRevisionSchema = z.object({
|
|
|
3662
3818
|
operations: z.array(canvasOperationSchema)
|
|
3663
3819
|
});
|
|
3664
3820
|
z.object({
|
|
3821
|
+
/** The canvas's web address. An API older than the field answers without it. */
|
|
3822
|
+
url: z.url().optional(),
|
|
3665
3823
|
mutations: z.array(canvasMutationRevisionSchema).optional(),
|
|
3666
3824
|
version: z.number().int().min(1),
|
|
3667
3825
|
/**
|
|
@@ -3694,6 +3852,123 @@ z.discriminatedUnion("outcome", [z.object({
|
|
|
3694
3852
|
document: canvasDocumentBlobSchema
|
|
3695
3853
|
})]);
|
|
3696
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
|
|
3697
3972
|
//#region ../contract/src/canvas/canvas-text-content.lib.ts
|
|
3698
3973
|
const textLinkSchema = z.object({
|
|
3699
3974
|
start: z.number().int().nonnegative(),
|
|
@@ -3725,13 +4000,30 @@ const canvasPropertySectionSchema = z.enum([
|
|
|
3725
4000
|
"export",
|
|
3726
4001
|
"source"
|
|
3727
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();
|
|
3728
4019
|
const canvasInspectNodeSummarySchema = z.object({
|
|
3729
4020
|
id: z.string().min(1),
|
|
3730
|
-
label: z.string().max(
|
|
3731
|
-
kind: z.string().min(1).max(
|
|
4021
|
+
label: z.string().max(MAX_RENDER_MESSAGE_LENGTH),
|
|
4022
|
+
kind: z.string().min(1).max(MAX_RENDER_KIND_LENGTH),
|
|
3732
4023
|
parentId: z.string().min(1).nullable(),
|
|
3733
4024
|
childCount: z.number().int().min(0),
|
|
3734
4025
|
box: canvasSceneBoxSchema.nullable(),
|
|
4026
|
+
boxSource: canvasBoxSourceSchema.optional(),
|
|
3735
4027
|
propertySections: z.array(canvasPropertySectionSchema)
|
|
3736
4028
|
});
|
|
3737
4029
|
z.object({ canvasId: z.uuid() });
|
|
@@ -3744,13 +4036,15 @@ z.object({
|
|
|
3744
4036
|
rootChildCount: z.number().int().min(0),
|
|
3745
4037
|
bounds: canvasSceneBoxSchema.nullable(),
|
|
3746
4038
|
kinds: z.record(z.string(), z.number().int().min(0)),
|
|
4039
|
+
boxNote: boxNoteSchema,
|
|
3747
4040
|
next: z.array(z.string().min(1))
|
|
3748
4041
|
});
|
|
3749
4042
|
z.object({ canvasId: z.uuid() });
|
|
3750
4043
|
z.object({
|
|
3751
4044
|
canvasId: z.uuid(),
|
|
3752
4045
|
version: z.number().int().positive(),
|
|
3753
|
-
nodes: z.array(canvasInspectNodeSummarySchema)
|
|
4046
|
+
nodes: z.array(canvasInspectNodeSummarySchema),
|
|
4047
|
+
boxNote: boxNoteSchema
|
|
3754
4048
|
});
|
|
3755
4049
|
z.object({
|
|
3756
4050
|
canvasId: z.uuid(),
|
|
@@ -3769,9 +4063,49 @@ z.object({
|
|
|
3769
4063
|
props: z.record(z.string(), z.unknown()),
|
|
3770
4064
|
children: z.array(z.string().min(1))
|
|
3771
4065
|
}),
|
|
4066
|
+
boxNote: boxNoteSchema,
|
|
3772
4067
|
next: z.array(z.string().min(1))
|
|
3773
4068
|
});
|
|
3774
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
|
|
3775
4109
|
//#region ../contract/src/canvas/canvas-mutation.schema.ts
|
|
3776
4110
|
const nodeIdSchema$2 = canvasSceneNodeSchema.shape.id;
|
|
3777
4111
|
const writableBoxSchema = canvasSceneBoxSchema.extend({
|
|
@@ -3779,6 +4113,8 @@ const writableBoxSchema = canvasSceneBoxSchema.extend({
|
|
|
3779
4113
|
height: z.number().positive()
|
|
3780
4114
|
});
|
|
3781
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() });
|
|
3782
4118
|
const canvasMutationRequestContextSchema = z.strictObject({
|
|
3783
4119
|
fingerprint: z.string().regex(/^[a-f0-9]{64}$/u),
|
|
3784
4120
|
revisionPolicy: z.enum(["strict", "rebase"]),
|
|
@@ -3792,6 +4128,8 @@ z.object({
|
|
|
3792
4128
|
operations: z.array(canvasOperationSchema).min(1),
|
|
3793
4129
|
requestContext: canvasMutationRequestContextSchema.optional(),
|
|
3794
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);
|
|
3795
4133
|
});
|
|
3796
4134
|
const applyCanvasOperationsOutputSchema = z.object({
|
|
3797
4135
|
canvasId: z.uuid(),
|
|
@@ -3802,7 +4140,7 @@ const applyCanvasOperationsOutputSchema = z.object({
|
|
|
3802
4140
|
insertedNodeIds: z.array(nodeIdSchema$2),
|
|
3803
4141
|
changedNodeIds: z.array(nodeIdSchema$2),
|
|
3804
4142
|
removedNodeIds: z.array(nodeIdSchema$2),
|
|
3805
|
-
boxes: z.record(nodeIdSchema$2,
|
|
4143
|
+
boxes: z.record(nodeIdSchema$2, canvasReceiptBoxSchema),
|
|
3806
4144
|
affectedBounds: writableBoxSchema.nullable(),
|
|
3807
4145
|
copiedNodeIds: copiedNodeIdsSchema.optional(),
|
|
3808
4146
|
next: z.array(z.string().min(1))
|
|
@@ -3814,7 +4152,8 @@ z.strictObject({
|
|
|
3814
4152
|
});
|
|
3815
4153
|
z.discriminatedUnion("state", [z.strictObject({ state: z.literal("not-found") }), z.strictObject({
|
|
3816
4154
|
state: z.literal("committed"),
|
|
3817
|
-
|
|
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() })
|
|
3818
4157
|
})]);
|
|
3819
4158
|
//#endregion
|
|
3820
4159
|
//#region ../contract/src/canvas/canvas-mutation-review.schema.ts
|
|
@@ -4217,8 +4556,10 @@ const canvasPreparationRequestSchema = z.discriminatedUnion("kind", [
|
|
|
4217
4556
|
sources: z.array(z.strictObject({
|
|
4218
4557
|
screenId: z.uuid(),
|
|
4219
4558
|
captureId: z.uuid(),
|
|
4220
|
-
|
|
4221
|
-
|
|
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.")
|
|
4222
4563
|
}),
|
|
4223
4564
|
canvasArrangePreparationSchema,
|
|
4224
4565
|
canvasDuplicatePreparationSchema,
|
|
@@ -4299,7 +4640,11 @@ const canvasPreparationJobSchema = z.discriminatedUnion("state", [
|
|
|
4299
4640
|
job.extend({
|
|
4300
4641
|
state: z.literal("succeeded"),
|
|
4301
4642
|
phase: z.literal("complete"),
|
|
4302
|
-
result: canvasPreparationPlanSchema.extend({
|
|
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
|
+
}),
|
|
4303
4648
|
failure: z.null()
|
|
4304
4649
|
}),
|
|
4305
4650
|
job.extend({
|
|
@@ -4692,7 +5037,8 @@ z.discriminatedUnion("purpose", [
|
|
|
4692
5037
|
"inspection",
|
|
4693
5038
|
"snapshot",
|
|
4694
5039
|
"thumbnail",
|
|
4695
|
-
"export"
|
|
5040
|
+
"export",
|
|
5041
|
+
"object-pictures"
|
|
4696
5042
|
]),
|
|
4697
5043
|
scale: z.number().positive(),
|
|
4698
5044
|
maxOutputPixels: canvasRenderPixelLimitSchema.optional(),
|
|
@@ -4763,6 +5109,16 @@ z.discriminatedUnion("purpose", [
|
|
|
4763
5109
|
sourceState: z.undefined().optional(),
|
|
4764
5110
|
conversion: canvasConversionRequestSchema,
|
|
4765
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)
|
|
4766
5122
|
})
|
|
4767
5123
|
]);
|
|
4768
5124
|
z.object({
|
|
@@ -4909,6 +5265,7 @@ z.object({
|
|
|
4909
5265
|
nodes: z.array(canvasInspectNodeSummarySchema),
|
|
4910
5266
|
contextRootId: nodeIdSchema.nullable(),
|
|
4911
5267
|
visibleWorldBox: canvasWorldBoundsSchema.nullable(),
|
|
5268
|
+
boxNote: z.string().min(1).optional(),
|
|
4912
5269
|
next: z.array(z.string().min(1)).max(MAX_SELECTION_COMMANDS)
|
|
4913
5270
|
});
|
|
4914
5271
|
//#endregion
|
|
@@ -4917,6 +5274,17 @@ const canvasCaptureProvenanceSchema = z.discriminatedUnion("kind", [z.object({
|
|
|
4917
5274
|
kind: z.literal("recording"),
|
|
4918
5275
|
recordingId: z.string()
|
|
4919
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
|
+
})]);
|
|
4920
5288
|
z.object({
|
|
4921
5289
|
html: z.string().optional(),
|
|
4922
5290
|
viewport: z.object({
|
|
@@ -4926,7 +5294,8 @@ z.object({
|
|
|
4926
5294
|
atMs: z.number(),
|
|
4927
5295
|
screenId: z.string().nullable().default(null),
|
|
4928
5296
|
sourceNodeId: z.string().optional(),
|
|
4929
|
-
provenance: canvasCaptureProvenanceSchema.optional()
|
|
5297
|
+
provenance: canvasCaptureProvenanceSchema.optional(),
|
|
5298
|
+
landing: captureLandingSchema.optional()
|
|
4930
5299
|
});
|
|
4931
5300
|
z.object({
|
|
4932
5301
|
provenance: canvasCaptureProvenanceSchema.optional(),
|
|
@@ -5056,12 +5425,16 @@ z.object({
|
|
|
5056
5425
|
versionId: z.uuid()
|
|
5057
5426
|
});
|
|
5058
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
|
+
};
|
|
5059
5432
|
z.object({
|
|
5060
5433
|
canvasId: z.uuid(),
|
|
5061
5434
|
documentFormatVersion: canvasDocumentFormatSchema,
|
|
5062
5435
|
versionId: z.uuid(),
|
|
5063
5436
|
expectedVersion: z.number().int().positive()
|
|
5064
|
-
});
|
|
5437
|
+
}).superRefine(refuseUnsafeVersionCopy);
|
|
5065
5438
|
z.object({
|
|
5066
5439
|
canvasId: z.uuid(),
|
|
5067
5440
|
version: z.number().int().positive(),
|
|
@@ -5075,7 +5448,7 @@ z.object({
|
|
|
5075
5448
|
versionId: z.uuid(),
|
|
5076
5449
|
organisationId: z.union([z.uuid(), z.literal("personal")]),
|
|
5077
5450
|
title: z.string().trim().min(1).optional()
|
|
5078
|
-
});
|
|
5451
|
+
}).superRefine(refuseUnsafeVersionCopy);
|
|
5079
5452
|
z.object({
|
|
5080
5453
|
canvasId: z.uuid(),
|
|
5081
5454
|
title: z.string().min(1),
|
|
@@ -5264,6 +5637,16 @@ const setReviewStateInputSchema = z.object({
|
|
|
5264
5637
|
])
|
|
5265
5638
|
});
|
|
5266
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
|
+
});
|
|
5267
5650
|
//#endregion
|
|
5268
5651
|
//#region ../contract/src/comment/comment.schema.ts
|
|
5269
5652
|
/** How many replies a thread hands back in one go before `hasMoreMessages` takes over. */
|
|
@@ -6565,6 +6948,12 @@ z.object({
|
|
|
6565
6948
|
version: z.number().int().positive()
|
|
6566
6949
|
})]).optional()
|
|
6567
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() });
|
|
6568
6957
|
const MAX_PROTOTYPE_CONTENT_TYPE_LENGTH = 200;
|
|
6569
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" });
|
|
6570
6959
|
const prototypeFileSchema = z.object({
|
|
@@ -6999,6 +7388,21 @@ const missingReplayAssetSourceIn = (url) => {
|
|
|
6999
7388
|
return null;
|
|
7000
7389
|
}
|
|
7001
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");
|
|
7002
7406
|
//#endregion
|
|
7003
7407
|
//#region ../contract/src/recording/page-asset-references.lib.ts
|
|
7004
7408
|
/**
|
|
@@ -7321,21 +7725,6 @@ z.object({
|
|
|
7321
7725
|
/** Screens survive with their provenance nulled. That is what makes iteration safe. */
|
|
7322
7726
|
detachedScreenCount: z.number().int().min(0)
|
|
7323
7727
|
});
|
|
7324
|
-
[`[data-enhance-unsupported]:not([data-enhance-unsupported-hidden]):not([style*="display: none"]) {
|
|
7325
|
-
align-items: center !important;
|
|
7326
|
-
background-color: #f7f7f8 !important;
|
|
7327
|
-
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;
|
|
7328
|
-
border: 1px solid #c7c7cc !important;
|
|
7329
|
-
box-sizing: border-box !important;
|
|
7330
|
-
color: #4f4f55 !important;
|
|
7331
|
-
display: flex !important;
|
|
7332
|
-
font: 500 14px/1.4 Inter, ui-sans-serif, system-ui, sans-serif !important;
|
|
7333
|
-
justify-content: center !important;
|
|
7334
|
-
overflow: hidden !important;
|
|
7335
|
-
text-align: center !important;
|
|
7336
|
-
}`, `[data-enhance-unsupported-hidden], [data-enhance-unsupported][style*="display: none"] {
|
|
7337
|
-
display: none !important;
|
|
7338
|
-
}`].join("\n");
|
|
7339
7728
|
z.object({
|
|
7340
7729
|
/**
|
|
7341
7730
|
* Client-minted, once per capture attempt. A retry is the same screen; a re-capture at the
|
|
@@ -7647,6 +8036,7 @@ const clientRenderFailureDetailsSchema = z.strictObject({
|
|
|
7647
8036
|
"clipboard-unavailable",
|
|
7648
8037
|
"clipboard-image-pending",
|
|
7649
8038
|
"clipboard-image-unavailable",
|
|
8039
|
+
"paste-content-refused",
|
|
7650
8040
|
"edit-target-unsupported",
|
|
7651
8041
|
"edit-result-invalid",
|
|
7652
8042
|
"react-hook-order",
|
|
@@ -7684,6 +8074,7 @@ const clientRenderFailureDetailsSchema = z.strictObject({
|
|
|
7684
8074
|
subsystem: z.enum([
|
|
7685
8075
|
"menu",
|
|
7686
8076
|
"menu-picture",
|
|
8077
|
+
"arrival-cue",
|
|
7687
8078
|
"unknown"
|
|
7688
8079
|
]).optional(),
|
|
7689
8080
|
repeats: count$1.optional(),
|
|
@@ -7758,7 +8149,18 @@ const CANVAS_SYNC_REPORTS = [
|
|
|
7758
8149
|
"whole-value-text",
|
|
7759
8150
|
"retrying",
|
|
7760
8151
|
"recovery",
|
|
7761
|
-
"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"
|
|
7762
8164
|
];
|
|
7763
8165
|
const CANVAS_SYNC_DETAILS = [
|
|
7764
8166
|
...CLIENT_SAVE_ISSUES,
|
|
@@ -7795,7 +8197,8 @@ const CANVAS_SYNC_REPORT_STATUSES = [
|
|
|
7795
8197
|
"view-only",
|
|
7796
8198
|
"sign-in",
|
|
7797
8199
|
"gone",
|
|
7798
|
-
"restored"
|
|
8200
|
+
"restored",
|
|
8201
|
+
"update-required"
|
|
7799
8202
|
];
|
|
7800
8203
|
/** Whether a recovery state began in this visit or was reopened from the browser copy. */
|
|
7801
8204
|
const CANVAS_SYNC_EPISODES = ["new", "reopened"];
|
|
@@ -7837,6 +8240,7 @@ const CANVAS_SAVE_NOTICE_CAUSES = [
|
|
|
7837
8240
|
"refused",
|
|
7838
8241
|
"copy-refused",
|
|
7839
8242
|
"copy-preview",
|
|
8243
|
+
"update-required",
|
|
7840
8244
|
"unknown"
|
|
7841
8245
|
];
|
|
7842
8246
|
const CANVAS_SAVE_SEVERITIES = [
|
|
@@ -7860,7 +8264,8 @@ const CANVAS_SAVE_ACTIONS = [
|
|
|
7860
8264
|
"retry-upload",
|
|
7861
8265
|
"choose-file",
|
|
7862
8266
|
"remove-screen",
|
|
7863
|
-
"go-to-canvases"
|
|
8267
|
+
"go-to-canvases",
|
|
8268
|
+
"reload"
|
|
7864
8269
|
];
|
|
7865
8270
|
const CANVAS_SAVE_OUTCOMES = [
|
|
7866
8271
|
"saved",
|
|
@@ -7954,6 +8359,7 @@ z.strictObject({
|
|
|
7954
8359
|
durationMs: z.number().int().nonnegative(),
|
|
7955
8360
|
pendingChanges: z.number().int().nonnegative(),
|
|
7956
8361
|
reason: z.enum(CANVAS_SYNC_DETAILS).optional(),
|
|
8362
|
+
readOutcome: z.enum(CANVAS_SYNC_READ_OUTCOMES).optional(),
|
|
7957
8363
|
status: z.enum(CANVAS_SYNC_REPORT_STATUSES).optional(),
|
|
7958
8364
|
episode: z.enum(CANVAS_SYNC_EPISODES).optional(),
|
|
7959
8365
|
trace: canvasSaveTraceSchema.optional()
|
|
@@ -8185,8 +8591,8 @@ var StorageRequestError = class extends Error {
|
|
|
8185
8591
|
//#region ../contract/src/shared/request-outcome.lib.ts
|
|
8186
8592
|
const listed = (allowed, value) => typeof value === "string" && allowed.includes(value) ? value : null;
|
|
8187
8593
|
const refusalOf = (error) => {
|
|
8188
|
-
const { refusalCode, operation, component } = error.fields ?? {};
|
|
8189
|
-
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;
|
|
8190
8596
|
const code = CANVAS_SAVE_REFUSAL_CODES.find((value) => value === refusalCode);
|
|
8191
8597
|
return {
|
|
8192
8598
|
refusalCode: refusalCode === void 0 ? "unclassified" : code ?? "unknown",
|
|
@@ -8198,6 +8604,15 @@ const refusalOf = (error) => {
|
|
|
8198
8604
|
const MUTATION_ID_REUSED = "mutation-id-reused";
|
|
8199
8605
|
/** `fields.reason` on a 413, whether the server's envelope or a proxy's bare status says so. */
|
|
8200
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
|
+
};
|
|
8201
8616
|
const HTTP_UNAUTHORIZED = 401;
|
|
8202
8617
|
const HTTP_FORBIDDEN = 403;
|
|
8203
8618
|
const HTTP_NOT_FOUND = 404;
|
|
@@ -8232,17 +8647,15 @@ const conflictOutcome = (error) => {
|
|
|
8232
8647
|
reason: error.message
|
|
8233
8648
|
};
|
|
8234
8649
|
};
|
|
8235
|
-
/** The server names the
|
|
8650
|
+
/** The server names the refusals a client must tell apart; any other is the message. */
|
|
8236
8651
|
const badRequestOutcome = (error) => {
|
|
8237
8652
|
const reason = error.fields?.["reason"];
|
|
8238
8653
|
if (reason === "mutation-id-reused") return {
|
|
8239
8654
|
kind: "fault",
|
|
8240
8655
|
detail: MUTATION_ID_REUSED
|
|
8241
8656
|
};
|
|
8242
|
-
if (reason === "request-too-large") return
|
|
8243
|
-
|
|
8244
|
-
reason: REQUEST_TOO_LARGE
|
|
8245
|
-
};
|
|
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" };
|
|
8246
8659
|
const refusal = refusalOf(error);
|
|
8247
8660
|
return {
|
|
8248
8661
|
kind: "refused",
|
|
@@ -8274,10 +8687,7 @@ const statusOutcome = (status, retryAfterMs) => {
|
|
|
8274
8687
|
};
|
|
8275
8688
|
if (status === HTTP_FORBIDDEN) return { kind: "no-edit-access" };
|
|
8276
8689
|
if (status === HTTP_NOT_FOUND) return { kind: "gone" };
|
|
8277
|
-
if (status === HTTP_TOO_LARGE) return
|
|
8278
|
-
kind: "refused",
|
|
8279
|
-
reason: REQUEST_TOO_LARGE
|
|
8280
|
-
};
|
|
8690
|
+
if (status === HTTP_TOO_LARGE) return tooLarge;
|
|
8281
8691
|
if (status === HTTP_TIMEOUT || status === HTTP_TOO_MANY_REQUESTS || status === HTTP_CLIENT_CLOSED || status >= HTTP_SERVER_ERROR) return {
|
|
8282
8692
|
kind: "transient",
|
|
8283
8693
|
retryAfterMs
|