@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
|
@@ -37,8 +37,10 @@ var __enhance_capture_kernel__ = (function(exports) {
|
|
|
37
37
|
};
|
|
38
38
|
//#endregion
|
|
39
39
|
//#region ../canvas-format/src/canvas-edit-support.lib.ts
|
|
40
|
-
/** Why the API refused
|
|
40
|
+
/** Why the API refused a request or one of its operations, as a fixed value. Never its words. */
|
|
41
41
|
const CANVAS_REFUSAL_CODES = [
|
|
42
|
+
"input-invalid",
|
|
43
|
+
"request-too-large",
|
|
42
44
|
"appearance-unsupported-component",
|
|
43
45
|
"styles-unsupported-component",
|
|
44
46
|
"text-shadow-blend-unsupported",
|
|
@@ -347,6 +349,16 @@ var __enhance_capture_kernel__ = (function(exports) {
|
|
|
347
349
|
if (document["version"] === LEGACY_CANVAS_FORMATS.v13 || document["version"] === LEGACY_CANVAS_FORMATS.v14) return adapted;
|
|
348
350
|
return withoutTextShadowBlends(document["version"] === LEGACY_CANVAS_FORMATS.v12 ? adapted : adaptCanvasCss(adapted));
|
|
349
351
|
};
|
|
352
|
+
const isSafeInteger = (value) => Number.isSafeInteger(value);
|
|
353
|
+
/** A format below 1 names no adaptation, so the walk below refuses it. */
|
|
354
|
+
const canvasWriterFormat = (version) => {
|
|
355
|
+
if (!isSafeInteger(version)) return "refused";
|
|
356
|
+
if (version > 15) return "ahead";
|
|
357
|
+
if (version === 15) return "current";
|
|
358
|
+
const adaptations = new Map(Object.entries(LEGACY_CANVAS_ADAPTATIONS).map(([format, kind]) => [Number(format), kind]));
|
|
359
|
+
for (let format = version; format < 15; format += 1) if (adaptations.get(format) !== "format-number") return "refused";
|
|
360
|
+
return "number-only";
|
|
361
|
+
};
|
|
350
362
|
//#endregion
|
|
351
363
|
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js
|
|
352
364
|
var _a$1;
|
|
@@ -483,7 +495,7 @@ var __enhance_capture_kernel__ = (function(exports) {
|
|
|
483
495
|
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
484
496
|
}
|
|
485
497
|
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
|
|
486
|
-
function isObject$
|
|
498
|
+
function isObject$6(data) {
|
|
487
499
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
488
500
|
}
|
|
489
501
|
const allowsEval = /* @__PURE__*/ cached(() => {
|
|
@@ -497,12 +509,12 @@ var __enhance_capture_kernel__ = (function(exports) {
|
|
|
497
509
|
}
|
|
498
510
|
});
|
|
499
511
|
function isPlainObject(o) {
|
|
500
|
-
if (isObject$
|
|
512
|
+
if (isObject$6(o) === false) return false;
|
|
501
513
|
const ctor = o.constructor;
|
|
502
514
|
if (ctor === void 0) return true;
|
|
503
515
|
if (typeof ctor !== "function") return true;
|
|
504
516
|
const prot = ctor.prototype;
|
|
505
|
-
if (isObject$
|
|
517
|
+
if (isObject$6(prot) === false) return false;
|
|
506
518
|
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
|
|
507
519
|
return true;
|
|
508
520
|
}
|
|
@@ -1940,7 +1952,7 @@ var __enhance_capture_kernel__ = (function(exports) {
|
|
|
1940
1952
|
}
|
|
1941
1953
|
return propValues;
|
|
1942
1954
|
});
|
|
1943
|
-
const isObject = isObject$
|
|
1955
|
+
const isObject = isObject$6;
|
|
1944
1956
|
const catchall = def.catchall;
|
|
1945
1957
|
let value;
|
|
1946
1958
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -2069,7 +2081,7 @@ var __enhance_capture_kernel__ = (function(exports) {
|
|
|
2069
2081
|
return (payload, ctx) => fn(shape, payload, ctx);
|
|
2070
2082
|
};
|
|
2071
2083
|
let fastpass;
|
|
2072
|
-
const isObject = isObject$
|
|
2084
|
+
const isObject = isObject$6;
|
|
2073
2085
|
const jit = !globalConfig.jitless;
|
|
2074
2086
|
const fastEnabled = jit && allowsEval.value;
|
|
2075
2087
|
const catchall = def.catchall;
|
|
@@ -2181,7 +2193,7 @@ var __enhance_capture_kernel__ = (function(exports) {
|
|
|
2181
2193
|
});
|
|
2182
2194
|
inst._zod.parse = (payload, ctx) => {
|
|
2183
2195
|
const input = payload.value;
|
|
2184
|
-
if (!isObject$
|
|
2196
|
+
if (!isObject$6(input)) {
|
|
2185
2197
|
payload.issues.push({
|
|
2186
2198
|
code: "invalid_type",
|
|
2187
2199
|
expected: "object",
|
|
@@ -4920,6 +4932,86 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4920
4932
|
function number$1(params) {
|
|
4921
4933
|
return /* @__PURE__ */ _coercedNumber(ZodNumber, params);
|
|
4922
4934
|
}
|
|
4935
|
+
const objectPictureSizeSchema = _enum$1(["quarter", "sixteenth"]);
|
|
4936
|
+
/** One stored picture of one top layer. */
|
|
4937
|
+
const canvasObjectPictureSchema = strictObject({
|
|
4938
|
+
objectId: string$1().min(1),
|
|
4939
|
+
size: objectPictureSizeSchema,
|
|
4940
|
+
/** Where the picture's bytes are; what it answers with never changes. */
|
|
4941
|
+
url: string$1().min(1),
|
|
4942
|
+
width: number$2().int().positive(),
|
|
4943
|
+
height: number$2().int().positive(),
|
|
4944
|
+
/** The canvas version the picture was drawn at. */
|
|
4945
|
+
drawnVersion: number$2().int().nonnegative(),
|
|
4946
|
+
/** Whether the top layer is unchanged since the picture was drawn. */
|
|
4947
|
+
isCurrent: boolean$1(),
|
|
4948
|
+
/**
|
|
4949
|
+
* The font size, in pixels, that set the most characters of the top layer's texts when it was
|
|
4950
|
+
* drawn; left out where it held no text, or for a picture drawn before sizes were kept.
|
|
4951
|
+
*/
|
|
4952
|
+
textSize: number$2().positive().optional()
|
|
4953
|
+
});
|
|
4954
|
+
strictObject({
|
|
4955
|
+
canvasId: uuid$1(),
|
|
4956
|
+
/** Only pictures drawn after this version; every picture when left out. */
|
|
4957
|
+
sinceVersion: number$2().int().nonnegative().optional()
|
|
4958
|
+
});
|
|
4959
|
+
object$1({ pictures: array$1(canvasObjectPictureSchema) });
|
|
4960
|
+
strictObject({
|
|
4961
|
+
canvasId: uuid$1(),
|
|
4962
|
+
objectIds: array$1(string$1().min(1)).min(1).max(200)
|
|
4963
|
+
});
|
|
4964
|
+
object$1({ scheduled: number$2().int().nonnegative() });
|
|
4965
|
+
const MAX_PICTURE_STORAGE_KEY_LENGTH = 500;
|
|
4966
|
+
const MAX_PICTURE_FAILURE_LENGTH = 500;
|
|
4967
|
+
/** One top layer a picture job is to draw, with when it was last put on the list. */
|
|
4968
|
+
const objectPictureWorkObjectSchema = object$1({
|
|
4969
|
+
objectId: string$1().min(1),
|
|
4970
|
+
wantedAt: datetime()
|
|
4971
|
+
});
|
|
4972
|
+
/** One picture a job drew and uploaded, in pixels of the stored picture. */
|
|
4973
|
+
const drawnObjectPictureSchema = object$1({
|
|
4974
|
+
size: objectPictureSizeSchema,
|
|
4975
|
+
width: number$2().int().positive(),
|
|
4976
|
+
height: number$2().int().positive(),
|
|
4977
|
+
bytes: number$2().int().positive(),
|
|
4978
|
+
storageKey: string$1().min(1).max(MAX_PICTURE_STORAGE_KEY_LENGTH),
|
|
4979
|
+
/** The text size of the top layer the page drew, as the list of pictures gives it. */
|
|
4980
|
+
textSize: number$2().positive().optional()
|
|
4981
|
+
});
|
|
4982
|
+
object$1({
|
|
4983
|
+
jobId: uuid$1(),
|
|
4984
|
+
loadedVersion: number$2().int().positive(),
|
|
4985
|
+
drawn: array$1(objectPictureWorkObjectSchema.extend({ pictures: array$1(drawnObjectPictureSchema).length(2) })).max(20),
|
|
4986
|
+
failed: array$1(object$1({
|
|
4987
|
+
objectId: string$1().min(1),
|
|
4988
|
+
message: string$1().min(1).max(MAX_PICTURE_FAILURE_LENGTH)
|
|
4989
|
+
})).max(20)
|
|
4990
|
+
});
|
|
4991
|
+
const coordinate$1 = number$2();
|
|
4992
|
+
const extent = number$2().nonnegative();
|
|
4993
|
+
/** A box in page coordinates. */
|
|
4994
|
+
const canvasOutlineBoxSchema = strictObject({
|
|
4995
|
+
x: coordinate$1,
|
|
4996
|
+
y: coordinate$1,
|
|
4997
|
+
width: extent,
|
|
4998
|
+
height: extent
|
|
4999
|
+
});
|
|
5000
|
+
/** What a browser measured of one top layer: its own box, and how far its descendants paint. */
|
|
5001
|
+
const canvasOutlineMeasurementSchema = strictObject({
|
|
5002
|
+
objectId: string$1().min(1),
|
|
5003
|
+
box: canvasOutlineBoxSchema,
|
|
5004
|
+
reach: canvasOutlineBoxSchema
|
|
5005
|
+
});
|
|
5006
|
+
strictObject({
|
|
5007
|
+
canvasId: uuid$1(),
|
|
5008
|
+
/** The revision of the document the browser had laid out when it measured. */
|
|
5009
|
+
version: number$2().int().positive(),
|
|
5010
|
+
measurements: array$1(canvasOutlineMeasurementSchema).min(1).max(200)
|
|
5011
|
+
});
|
|
5012
|
+
object$1({ stored: number$2().int().nonnegative() });
|
|
5013
|
+
strictObject({ canvasId: uuid$1() });
|
|
5014
|
+
object$1({ measurements: array$1(canvasOutlineMeasurementSchema.extend({ measuredVersion: number$2().int().nonnegative() })) });
|
|
4923
5015
|
strictObject({});
|
|
4924
5016
|
object$1({ firstAgentWorkAt: datetime().nullable() });
|
|
4925
5017
|
/** Cursor pagination, defined once so no endpoint invents its own page shape. */
|
|
@@ -5028,13 +5120,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5028
5120
|
createdAt: datetime(),
|
|
5029
5121
|
lastActivityAt: datetime()
|
|
5030
5122
|
});
|
|
5123
|
+
/**
|
|
5124
|
+
* A canvas with its full web address, which only the API can write: it is built from the web
|
|
5125
|
+
* address of the API's own environment, so a reader never joins an id to a host.
|
|
5126
|
+
*/
|
|
5127
|
+
const linkedCanvasSchema = canvasSchema.extend({ url: url() });
|
|
5031
5128
|
object$1({
|
|
5032
5129
|
title: string$1().trim().min(1),
|
|
5033
5130
|
/** The team to file it under, or null for the maker's own. Refused for one you are not on. */
|
|
5034
5131
|
organisationId: uuid$1().nullable().default(null),
|
|
5035
5132
|
sourceUrl: string$1().nullable().default(null)
|
|
5036
5133
|
});
|
|
5037
|
-
|
|
5134
|
+
linkedCanvasSchema.extend({ version: number$2().int().positive() });
|
|
5038
5135
|
object$1({ canvasId: uuid$1() });
|
|
5039
5136
|
object$1({
|
|
5040
5137
|
collection: union$1([
|
|
@@ -5053,7 +5150,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5053
5150
|
]).default("all"),
|
|
5054
5151
|
hasUnresolved: boolean$1().default(false)
|
|
5055
5152
|
});
|
|
5056
|
-
const canvasCardBaseSchema =
|
|
5153
|
+
const canvasCardBaseSchema = linkedCanvasSchema.extend({
|
|
5057
5154
|
screenCount: number$2().int().min(0),
|
|
5058
5155
|
hasRecording: boolean$1(),
|
|
5059
5156
|
/** When the person listing last opened it in the web app; `null` if they never have. */
|
|
@@ -5493,6 +5590,11 @@ progression: object$1({
|
|
|
5493
5590
|
clipContent: boolean$1().optional(),
|
|
5494
5591
|
baselineSource: canvasBaselineSourceSchema.optional(),
|
|
5495
5592
|
scrollbarGutter: canvasScrollbarGutterSchema.optional(),
|
|
5593
|
+
/**
|
|
5594
|
+
* The frame holds an embedded document. Chromium sizes that document's viewport in whole
|
|
5595
|
+
* pixels, rounding the frame's content box up, so what the frame holds resolves against that.
|
|
5596
|
+
*/
|
|
5597
|
+
embeddedDocument: literal$1(true).optional(),
|
|
5496
5598
|
container: canvasFlexLayoutSchema.partial().extend({ padding: canvasFlexPaddingSchema.partial().optional() }).optional()
|
|
5497
5599
|
}).strict();
|
|
5498
5600
|
//#endregion
|
|
@@ -5563,7 +5665,9 @@ progression: object$1({
|
|
|
5563
5665
|
]),
|
|
5564
5666
|
paints: array$1(canvasPaintSchema),
|
|
5565
5667
|
dashPattern: canvasDashPatternSchema.optional(),
|
|
5566
|
-
dashCap: canvasDashCapSchema.optional()
|
|
5668
|
+
dashCap: canvasDashCapSchema.optional(),
|
|
5669
|
+
/** Captured CSS dashes, which the browser draws, as for a border. */
|
|
5670
|
+
dashOrigin: literal$1("css").optional()
|
|
5567
5671
|
});
|
|
5568
5672
|
const canvasShadowSchema = object$1({
|
|
5569
5673
|
id: itemId,
|
|
@@ -6037,13 +6141,13 @@ progression: object$1({
|
|
|
6037
6141
|
}).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.");
|
|
6038
6142
|
//#endregion
|
|
6039
6143
|
//#region ../contract/src/canvas/canvas-css-values.lib.ts
|
|
6040
|
-
const SIDES = [
|
|
6144
|
+
const SIDES$1 = [
|
|
6041
6145
|
"top",
|
|
6042
6146
|
"right",
|
|
6043
6147
|
"bottom",
|
|
6044
6148
|
"left"
|
|
6045
6149
|
];
|
|
6046
|
-
SIDES.map((side) => `padding-${side}`), SIDES.map((side) => `margin-${side}`);
|
|
6150
|
+
SIDES$1.map((side) => `padding-${side}`), SIDES$1.map((side) => `margin-${side}`);
|
|
6047
6151
|
//#endregion
|
|
6048
6152
|
//#region ../contract/src/canvas/canvas-export-settings.schema.ts
|
|
6049
6153
|
const format = _enum$1(["png", "jpeg"]);
|
|
@@ -6122,7 +6226,34 @@ progression: object$1({
|
|
|
6122
6226
|
//#endregion
|
|
6123
6227
|
//#region ../contract/src/canvas/canvas-scene.schema.ts
|
|
6124
6228
|
const CANVAS_COMPOSITING_RETIRED = "Update Enhance: compositing is no longer supported. Use the isolation style or a mask group.";
|
|
6125
|
-
const
|
|
6229
|
+
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.";
|
|
6230
|
+
const CANVAS_FORMAT_SERVER_UPDATING = "Enhance is being updated. Try again in a minute.";
|
|
6231
|
+
/** Marks an issue whose message was written for whoever sent the request, so the API keeps it. */
|
|
6232
|
+
const FOR_CALLER = { forCaller: true };
|
|
6233
|
+
/**
|
|
6234
|
+
* The format a writer was built for, as a plain whole number so tool schemas can describe it. Which
|
|
6235
|
+
* writes that format may make is `refuseUnsafeWriterFormat`'s call.
|
|
6236
|
+
*/
|
|
6237
|
+
const canvasDocumentFormatSchema = number$2({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).int({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).positive({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).meta({
|
|
6238
|
+
description: `The document format this client writes. The current format is ${String(15)}.`,
|
|
6239
|
+
examples: [15]
|
|
6240
|
+
});
|
|
6241
|
+
/**
|
|
6242
|
+
* Refuses a write its client's format could get wrong. A client whose format differs from the
|
|
6243
|
+
* current one only in its number may still name changes, but a whole value it sends may lack
|
|
6244
|
+
* fields added since, so that needs the current format.
|
|
6245
|
+
*/
|
|
6246
|
+
const refuseUnsafeWriterFormat = (documentFormatVersion, writes, context) => {
|
|
6247
|
+
const writer = canvasWriterFormat(documentFormatVersion);
|
|
6248
|
+
if (writer === "current" || writer === "number-only" && writes === "names") return;
|
|
6249
|
+
context.addIssue({
|
|
6250
|
+
code: "custom",
|
|
6251
|
+
path: ["documentFormatVersion"],
|
|
6252
|
+
message: writer === "ahead" ? CANVAS_FORMAT_SERVER_UPDATING : CANVAS_FORMAT_UPDATE_REQUIRED,
|
|
6253
|
+
params: FOR_CALLER,
|
|
6254
|
+
input: documentFormatVersion
|
|
6255
|
+
});
|
|
6256
|
+
};
|
|
6126
6257
|
object$1({
|
|
6127
6258
|
signature: string$1().regex(/^[a-f0-9]{16}$/u),
|
|
6128
6259
|
/** The captured picture of the page's text, inline as written or as its canvas image store path. */
|
|
@@ -6239,7 +6370,8 @@ progression: object$1({
|
|
|
6239
6370
|
"image-shadows",
|
|
6240
6371
|
"effect-noise",
|
|
6241
6372
|
"effect-texture",
|
|
6242
|
-
"effect-glass"
|
|
6373
|
+
"effect-glass",
|
|
6374
|
+
"mask-source"
|
|
6243
6375
|
]);
|
|
6244
6376
|
const canvasConversionReportSchema = object$1({
|
|
6245
6377
|
nodeCount: number$2().int().positive(),
|
|
@@ -6284,7 +6416,8 @@ progression: object$1({
|
|
|
6284
6416
|
/** A capture that lands as a new editable frame on a page, with no screen layer. */
|
|
6285
6417
|
const editableFrameCaptureSchema = object$1({
|
|
6286
6418
|
screenId: string$1().min(1),
|
|
6287
|
-
pageId: string$1().min(1)
|
|
6419
|
+
pageId: string$1().min(1),
|
|
6420
|
+
pictureNodeId: string$1().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.")
|
|
6288
6421
|
});
|
|
6289
6422
|
const editableFrameInputBase = {
|
|
6290
6423
|
canvasId: uuid$1(),
|
|
@@ -6299,7 +6432,9 @@ progression: object$1({
|
|
|
6299
6432
|
}), strictObject({
|
|
6300
6433
|
...editableFrameInputBase,
|
|
6301
6434
|
capture: editableFrameCaptureSchema.describe("The stored page a new capture lands from, and the page its frame goes on.")
|
|
6302
|
-
})])
|
|
6435
|
+
})]).superRefine((input, context) => {
|
|
6436
|
+
refuseUnsafeWriterFormat(input.documentFormatVersion, "whole", context);
|
|
6437
|
+
});
|
|
6303
6438
|
const createEditableFrameResultSchema = object$1({
|
|
6304
6439
|
canvasId: uuid$1(),
|
|
6305
6440
|
mutationId: uuid$1(),
|
|
@@ -6362,7 +6497,8 @@ progression: object$1({
|
|
|
6362
6497
|
"LOCAL_FONT_FALLBACK",
|
|
6363
6498
|
"SOURCE_FALLBACK",
|
|
6364
6499
|
"SCALE_REDUCED",
|
|
6365
|
-
"LAYOUT_FALLBACK"
|
|
6500
|
+
"LAYOUT_FALLBACK",
|
|
6501
|
+
"DRAWN_APPROXIMATELY"
|
|
6366
6502
|
];
|
|
6367
6503
|
//#endregion
|
|
6368
6504
|
//#region ../contract/src/canvas/canvas-render.schema.ts
|
|
@@ -6604,7 +6740,12 @@ progression: object$1({
|
|
|
6604
6740
|
}),
|
|
6605
6741
|
object$1({
|
|
6606
6742
|
kind: literal$1("replace"),
|
|
6607
|
-
targetNodeId: string$1().min(1)
|
|
6743
|
+
targetNodeId: string$1().min(1),
|
|
6744
|
+
/**
|
|
6745
|
+
* A capture's swap: the target must still be the capture's picture. When another browser has
|
|
6746
|
+
* already made it editable, the swap is refused as `capture-already-landed`.
|
|
6747
|
+
*/
|
|
6748
|
+
onlyPicture: literal$1(true).optional()
|
|
6608
6749
|
})
|
|
6609
6750
|
]);
|
|
6610
6751
|
const canvasConversionRequestSchema = object$1({
|
|
@@ -7336,7 +7477,7 @@ progression: object$1({
|
|
|
7336
7477
|
removedText: record(nodeIdSchema$3, canvasSceneNodeSchema.pick({ props: true })).optional()
|
|
7337
7478
|
})
|
|
7338
7479
|
]);
|
|
7339
|
-
|
|
7480
|
+
currentCanvasOperationSchema.options;
|
|
7340
7481
|
/** Each operation's name, for records that may state which kind failed and nothing else. */
|
|
7341
7482
|
const CANVAS_OPERATION_NAMES = currentCanvasOperationSchema.options.map((option) => option.shape.op.value);
|
|
7342
7483
|
const canvasOperationSchema = preprocess((value, context) => {
|
|
@@ -7390,13 +7531,16 @@ progression: object$1({
|
|
|
7390
7531
|
/** Null while the blob has not landed. The client draws an empty frame with its label. */
|
|
7391
7532
|
download: signedDownloadSchema.nullable()
|
|
7392
7533
|
});
|
|
7534
|
+
const canvasMutationRevisionSchema = object$1({
|
|
7535
|
+
mutationId: uuid$1(),
|
|
7536
|
+
previousVersion: number$2().int().positive(),
|
|
7537
|
+
version: number$2().int().positive(),
|
|
7538
|
+
operations: array$1(canvasOperationSchema)
|
|
7539
|
+
});
|
|
7393
7540
|
object$1({
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
version: number$2().int().positive(),
|
|
7398
|
-
operations: array$1(canvasOperationSchema)
|
|
7399
|
-
})).optional(),
|
|
7541
|
+
/** The canvas's web address. An API older than the field answers without it. */
|
|
7542
|
+
url: url().optional(),
|
|
7543
|
+
mutations: array$1(canvasMutationRevisionSchema).optional(),
|
|
7400
7544
|
version: number$2().int().min(1),
|
|
7401
7545
|
/**
|
|
7402
7546
|
* The revision the latest restore made, when there has been one. A reader at an older revision
|
|
@@ -7428,6 +7572,143 @@ progression: object$1({
|
|
|
7428
7572
|
document: canvasDocumentBlobSchema
|
|
7429
7573
|
})]);
|
|
7430
7574
|
//#endregion
|
|
7575
|
+
//#region ../contract/src/canvas/canvas-document-parts.schema.ts
|
|
7576
|
+
/** One answer stops taking top layers once it holds this many layers, unless it is asked for more. */
|
|
7577
|
+
const CANVAS_PART_LAYER_LIMIT = 5e3;
|
|
7578
|
+
/** The most layers a read of parts may ask one answer to hold before it stops. */
|
|
7579
|
+
const CANVAS_PART_LAYER_LIMIT_MAX = 1e5;
|
|
7580
|
+
/** The most identifiers one read of parts may name in each list. */
|
|
7581
|
+
const CANVAS_PART_NAMED_LIMIT = 2e3;
|
|
7582
|
+
strictObject({ canvasId: uuid$1() });
|
|
7583
|
+
/** The font files a layer inside a top layer declares, without the rest of the layer. */
|
|
7584
|
+
const canvasFontDeclarationSchema = object$1({
|
|
7585
|
+
layerId: string$1(),
|
|
7586
|
+
/** The child of the root that holds the layer. */
|
|
7587
|
+
topLayerId: string$1(),
|
|
7588
|
+
fontFaces: array$1(unknown())
|
|
7589
|
+
});
|
|
7590
|
+
object$1({
|
|
7591
|
+
version: number$2().int().min(1),
|
|
7592
|
+
restoreFenceVersion: number$2().int().positive().optional(),
|
|
7593
|
+
/** The root and each child of the root, pages among them, and every removed-layer id. */
|
|
7594
|
+
document: canvasDocumentBlobSchema,
|
|
7595
|
+
screens: array$1(documentScreenSchema),
|
|
7596
|
+
/** Whether the canvas holds more than `LARGE_PAGE_LAYERS` layers, every page counted. */
|
|
7597
|
+
isLarge: boolean$1(),
|
|
7598
|
+
fontDeclarations: array$1(canvasFontDeclarationSchema)
|
|
7599
|
+
});
|
|
7600
|
+
const namedIds = array$1(string$1().min(1)).max(CANVAS_PART_NAMED_LIMIT);
|
|
7601
|
+
strictObject({
|
|
7602
|
+
canvasId: uuid$1(),
|
|
7603
|
+
/** Children of the root, answered in this order. */
|
|
7604
|
+
topLayerIds: namedIds.optional(),
|
|
7605
|
+
/** Layers anywhere; each is answered with the whole top layer that holds it. */
|
|
7606
|
+
layerIds: namedIds.optional(),
|
|
7607
|
+
/**
|
|
7608
|
+
* The layers after which the answer takes no further top layer. An editor raises it on a very
|
|
7609
|
+
* large canvas, so the whole canvas arrives in a bounded number of answers.
|
|
7610
|
+
*/
|
|
7611
|
+
maxLayers: number$2().int().min(CANVAS_PART_LAYER_LIMIT).max(CANVAS_PART_LAYER_LIMIT_MAX).default(CANVAS_PART_LAYER_LIMIT)
|
|
7612
|
+
}).refine(({ topLayerIds = [], layerIds = [] }) => topLayerIds.length + layerIds.length > 0, "A read of parts names at least one layer.");
|
|
7613
|
+
object$1({
|
|
7614
|
+
/** The revision every layer of the answer was read at. */
|
|
7615
|
+
version: number$2().int().min(1),
|
|
7616
|
+
/** Each answered top layer's own record and every layer inside it: no root, no removed ids. */
|
|
7617
|
+
document: canvasDocumentBlobSchema,
|
|
7618
|
+
/** The top layers answered, in the order asked. */
|
|
7619
|
+
read: array$1(string$1()),
|
|
7620
|
+
/** The top layers left out because the answer was full, in the order asked. */
|
|
7621
|
+
notReached: array$1(string$1()),
|
|
7622
|
+
/** The named identifiers that are no top layer of the canvas, or are inside none. */
|
|
7623
|
+
absent: array$1(string$1())
|
|
7624
|
+
});
|
|
7625
|
+
//#endregion
|
|
7626
|
+
//#region ../contract/src/canvas/canvas-first-letter.lib.ts
|
|
7627
|
+
/** Custom CSS on a text layer that styles its first letter, one declaration per property. */
|
|
7628
|
+
const CANVAS_FIRST_LETTER_PREFIX = "--canvas-first-letter-";
|
|
7629
|
+
const SIDES = [
|
|
7630
|
+
"top",
|
|
7631
|
+
"right",
|
|
7632
|
+
"bottom",
|
|
7633
|
+
"left"
|
|
7634
|
+
];
|
|
7635
|
+
/**
|
|
7636
|
+
* The properties a first letter takes (CSS Pseudo-Elements 4, `::first-letter`), each with the
|
|
7637
|
+
* value it has when a layer does not declare it: its block's for a property that inherits, the
|
|
7638
|
+
* initial value for one that does not.
|
|
7639
|
+
*/
|
|
7640
|
+
const CANVAS_FIRST_LETTER_PROPERTIES = {
|
|
7641
|
+
...Object.fromEntries([
|
|
7642
|
+
"color",
|
|
7643
|
+
"font-family",
|
|
7644
|
+
"font-size",
|
|
7645
|
+
"font-stretch",
|
|
7646
|
+
"font-style",
|
|
7647
|
+
"font-weight",
|
|
7648
|
+
"font-variant-caps",
|
|
7649
|
+
"font-variant-ligatures",
|
|
7650
|
+
"font-variant-numeric",
|
|
7651
|
+
"font-feature-settings",
|
|
7652
|
+
"font-variation-settings",
|
|
7653
|
+
"font-kerning",
|
|
7654
|
+
"letter-spacing",
|
|
7655
|
+
"line-height",
|
|
7656
|
+
"text-shadow",
|
|
7657
|
+
"text-transform",
|
|
7658
|
+
"word-spacing",
|
|
7659
|
+
"-webkit-text-fill-color",
|
|
7660
|
+
"-webkit-text-stroke-color",
|
|
7661
|
+
"-webkit-text-stroke-width"
|
|
7662
|
+
].map((property) => [property, "inherit"])),
|
|
7663
|
+
...Object.fromEntries([
|
|
7664
|
+
"float",
|
|
7665
|
+
"vertical-align",
|
|
7666
|
+
"initial-letter",
|
|
7667
|
+
"opacity",
|
|
7668
|
+
"background-color",
|
|
7669
|
+
"background-image",
|
|
7670
|
+
"box-shadow",
|
|
7671
|
+
"text-decoration-line",
|
|
7672
|
+
"text-decoration-style",
|
|
7673
|
+
"text-decoration-color",
|
|
7674
|
+
"text-decoration-thickness",
|
|
7675
|
+
...SIDES.flatMap((side) => [
|
|
7676
|
+
`margin-${side}`,
|
|
7677
|
+
`padding-${side}`,
|
|
7678
|
+
`border-${side}-style`,
|
|
7679
|
+
`border-${side}-width`,
|
|
7680
|
+
`border-${side}-color`
|
|
7681
|
+
]),
|
|
7682
|
+
...[
|
|
7683
|
+
"top-left",
|
|
7684
|
+
"top-right",
|
|
7685
|
+
"bottom-right",
|
|
7686
|
+
"bottom-left"
|
|
7687
|
+
].map((corner) => `border-${corner}-radius`)
|
|
7688
|
+
].map((property) => [property, "initial"]))
|
|
7689
|
+
};
|
|
7690
|
+
`${Object.entries(CANVAS_FIRST_LETTER_PROPERTIES).map(([property, fallback]) => `${property}:var(${CANVAS_FIRST_LETTER_PREFIX}${property},${fallback})`).join(";")}`;
|
|
7691
|
+
//#endregion
|
|
7692
|
+
//#region ../contract/src/canvas/canvas-font-family.lib.ts
|
|
7693
|
+
const GENERIC_FAMILIES = /* @__PURE__ */ new Set([
|
|
7694
|
+
"-apple-system",
|
|
7695
|
+
"blinkmacsystemfont",
|
|
7696
|
+
"cursive",
|
|
7697
|
+
"emoji",
|
|
7698
|
+
"fantasy",
|
|
7699
|
+
"fangsong",
|
|
7700
|
+
"math",
|
|
7701
|
+
"monospace",
|
|
7702
|
+
"sans-serif",
|
|
7703
|
+
"serif",
|
|
7704
|
+
"system-ui",
|
|
7705
|
+
"ui-monospace",
|
|
7706
|
+
"ui-rounded",
|
|
7707
|
+
"ui-sans-serif",
|
|
7708
|
+
"ui-serif"
|
|
7709
|
+
]);
|
|
7710
|
+
const isCanvasGenericFontFamily = (family) => GENERIC_FAMILIES.has(family.toLowerCase());
|
|
7711
|
+
//#endregion
|
|
7431
7712
|
//#region ../contract/src/canvas/canvas-text-content.lib.ts
|
|
7432
7713
|
const textLinkSchema = object$1({
|
|
7433
7714
|
start: number$2().int().nonnegative(),
|
|
@@ -7459,13 +7740,30 @@ progression: object$1({
|
|
|
7459
7740
|
"export",
|
|
7460
7741
|
"source"
|
|
7461
7742
|
]);
|
|
7743
|
+
//#endregion
|
|
7744
|
+
//#region ../contract/src/canvas/canvas-inspection.schema.ts
|
|
7745
|
+
const MAX_RENDER_MESSAGE_LENGTH = 500;
|
|
7746
|
+
const MAX_RENDER_KIND_LENGTH = 100;
|
|
7747
|
+
/**
|
|
7748
|
+
* What a layer's box is: `placed` where the canvas draws the layer, `placed-before-transform` where
|
|
7749
|
+
* it draws the layer before the layer's own transform, `recorded` a size kept from when the layer
|
|
7750
|
+
* was made, for a layer the browser lays out.
|
|
7751
|
+
*/
|
|
7752
|
+
const canvasBoxSourceSchema = _enum$1([
|
|
7753
|
+
"placed",
|
|
7754
|
+
"placed-before-transform",
|
|
7755
|
+
"recorded"
|
|
7756
|
+
]);
|
|
7757
|
+
/** Present only on a read that holds a `recorded` box. */
|
|
7758
|
+
const boxNoteSchema = string$1().min(1).optional();
|
|
7462
7759
|
const canvasInspectNodeSummarySchema = object$1({
|
|
7463
7760
|
id: string$1().min(1),
|
|
7464
|
-
label: string$1().max(
|
|
7465
|
-
kind: string$1().min(1).max(
|
|
7761
|
+
label: string$1().max(MAX_RENDER_MESSAGE_LENGTH),
|
|
7762
|
+
kind: string$1().min(1).max(MAX_RENDER_KIND_LENGTH),
|
|
7466
7763
|
parentId: string$1().min(1).nullable(),
|
|
7467
7764
|
childCount: number$2().int().min(0),
|
|
7468
7765
|
box: canvasSceneBoxSchema.nullable(),
|
|
7766
|
+
boxSource: canvasBoxSourceSchema.optional(),
|
|
7469
7767
|
propertySections: array$1(canvasPropertySectionSchema)
|
|
7470
7768
|
});
|
|
7471
7769
|
object$1({ canvasId: uuid$1() });
|
|
@@ -7478,13 +7776,15 @@ progression: object$1({
|
|
|
7478
7776
|
rootChildCount: number$2().int().min(0),
|
|
7479
7777
|
bounds: canvasSceneBoxSchema.nullable(),
|
|
7480
7778
|
kinds: record(string$1(), number$2().int().min(0)),
|
|
7779
|
+
boxNote: boxNoteSchema,
|
|
7481
7780
|
next: array$1(string$1().min(1))
|
|
7482
7781
|
});
|
|
7483
7782
|
object$1({ canvasId: uuid$1() });
|
|
7484
7783
|
object$1({
|
|
7485
7784
|
canvasId: uuid$1(),
|
|
7486
7785
|
version: number$2().int().positive(),
|
|
7487
|
-
nodes: array$1(canvasInspectNodeSummarySchema)
|
|
7786
|
+
nodes: array$1(canvasInspectNodeSummarySchema),
|
|
7787
|
+
boxNote: boxNoteSchema
|
|
7488
7788
|
});
|
|
7489
7789
|
object$1({
|
|
7490
7790
|
canvasId: uuid$1(),
|
|
@@ -7503,9 +7803,49 @@ progression: object$1({
|
|
|
7503
7803
|
props: record(string$1(), unknown()),
|
|
7504
7804
|
children: array$1(string$1().min(1))
|
|
7505
7805
|
}),
|
|
7806
|
+
boxNote: boxNoteSchema,
|
|
7506
7807
|
next: array$1(string$1().min(1))
|
|
7507
7808
|
});
|
|
7508
7809
|
//#endregion
|
|
7810
|
+
//#region ../contract/src/canvas/canvas-operation-writes.schema.ts
|
|
7811
|
+
/**
|
|
7812
|
+
* What each operation writes. `names` sets one plain value, places, removes, or merges a patch, so
|
|
7813
|
+
* values its client never knew stay as stored. `whole` brings a whole layer or replaces a whole
|
|
7814
|
+
* group of values, which a client that read the canvas in an older format may have stripped.
|
|
7815
|
+
*/
|
|
7816
|
+
const CANVAS_OPERATION_WRITES = {
|
|
7817
|
+
insertConvertedSubtree: "whole",
|
|
7818
|
+
insertNode: "whole",
|
|
7819
|
+
insertText: "names",
|
|
7820
|
+
insertPrototype: "names",
|
|
7821
|
+
setPrototypeDeployment: "names",
|
|
7822
|
+
editText: "names",
|
|
7823
|
+
setText: "names",
|
|
7824
|
+
setBox: "names",
|
|
7825
|
+
setLabel: "names",
|
|
7826
|
+
setContainerKind: "names",
|
|
7827
|
+
setVisibility: "names",
|
|
7828
|
+
setLocked: "names",
|
|
7829
|
+
setConstraints: "names",
|
|
7830
|
+
setStyles: "names",
|
|
7831
|
+
patchExportSettings: "names",
|
|
7832
|
+
setAppearance: "names",
|
|
7833
|
+
setLayout: "whole",
|
|
7834
|
+
patchTypography: "names",
|
|
7835
|
+
setTypography: "whole",
|
|
7836
|
+
patchAdditionalStyles: "names",
|
|
7837
|
+
setAdditionalStyles: "whole",
|
|
7838
|
+
setArtworkColor: "whole",
|
|
7839
|
+
setTextStyleLibrary: "whole",
|
|
7840
|
+
patchFontLibrary: "names",
|
|
7841
|
+
setTextStyle: "whole",
|
|
7842
|
+
setGeometry: "whole",
|
|
7843
|
+
setProps: "whole",
|
|
7844
|
+
setParentage: "names",
|
|
7845
|
+
move: "names",
|
|
7846
|
+
remove: "names"
|
|
7847
|
+
};
|
|
7848
|
+
//#endregion
|
|
7509
7849
|
//#region ../contract/src/canvas/canvas-mutation.schema.ts
|
|
7510
7850
|
const nodeIdSchema$2 = canvasSceneNodeSchema.shape.id;
|
|
7511
7851
|
const writableBoxSchema = canvasSceneBoxSchema.extend({
|
|
@@ -7513,6 +7853,8 @@ progression: object$1({
|
|
|
7513
7853
|
height: number$2().positive()
|
|
7514
7854
|
});
|
|
7515
7855
|
const copiedNodeIdsSchema = record(nodeIdSchema$2, nodeIdSchema$2);
|
|
7856
|
+
/** A receipt stored before boxes said what they are holds none, so the source stays optional. */
|
|
7857
|
+
const canvasReceiptBoxSchema = canvasSceneBoxSchema.extend({ boxSource: canvasBoxSourceSchema.optional() });
|
|
7516
7858
|
const canvasMutationRequestContextSchema = strictObject({
|
|
7517
7859
|
fingerprint: string$1().regex(/^[a-f0-9]{64}$/u),
|
|
7518
7860
|
revisionPolicy: _enum$1(["strict", "rebase"]),
|
|
@@ -7526,6 +7868,8 @@ progression: object$1({
|
|
|
7526
7868
|
operations: array$1(canvasOperationSchema).min(1),
|
|
7527
7869
|
requestContext: canvasMutationRequestContextSchema.optional(),
|
|
7528
7870
|
writeScope: canvasWriteScopeSchema.optional()
|
|
7871
|
+
}).superRefine((input, context) => {
|
|
7872
|
+
refuseUnsafeWriterFormat(input.documentFormatVersion, input.operations.every((operation) => CANVAS_OPERATION_WRITES[operation.op] === "names") ? "names" : "whole", context);
|
|
7529
7873
|
});
|
|
7530
7874
|
const applyCanvasOperationsOutputSchema = object$1({
|
|
7531
7875
|
canvasId: uuid$1(),
|
|
@@ -7536,7 +7880,7 @@ progression: object$1({
|
|
|
7536
7880
|
insertedNodeIds: array$1(nodeIdSchema$2),
|
|
7537
7881
|
changedNodeIds: array$1(nodeIdSchema$2),
|
|
7538
7882
|
removedNodeIds: array$1(nodeIdSchema$2),
|
|
7539
|
-
boxes: record(nodeIdSchema$2,
|
|
7883
|
+
boxes: record(nodeIdSchema$2, canvasReceiptBoxSchema),
|
|
7540
7884
|
affectedBounds: writableBoxSchema.nullable(),
|
|
7541
7885
|
copiedNodeIds: copiedNodeIdsSchema.optional(),
|
|
7542
7886
|
next: array$1(string$1().min(1))
|
|
@@ -7548,7 +7892,8 @@ progression: object$1({
|
|
|
7548
7892
|
});
|
|
7549
7893
|
discriminatedUnion$1("state", [strictObject({ state: literal$1("not-found") }), strictObject({
|
|
7550
7894
|
state: literal$1("committed"),
|
|
7551
|
-
|
|
7895
|
+
/** `url` is the canvas's web address. An API older than the field answers without it. */
|
|
7896
|
+
result: applyCanvasOperationsOutputSchema.extend({ url: url().optional() })
|
|
7552
7897
|
})]);
|
|
7553
7898
|
//#endregion
|
|
7554
7899
|
//#region ../contract/src/canvas/canvas-mutation-review.schema.ts
|
|
@@ -7951,8 +8296,10 @@ progression: object$1({
|
|
|
7951
8296
|
sources: array$1(strictObject({
|
|
7952
8297
|
screenId: uuid$1(),
|
|
7953
8298
|
captureId: uuid$1(),
|
|
7954
|
-
|
|
7955
|
-
|
|
8299
|
+
/** What the frame is called. Absent, the frame takes the stored page's own title. */
|
|
8300
|
+
label: string$1().min(1).optional()
|
|
8301
|
+
})).min(1),
|
|
8302
|
+
landing: literal$1("editable-frame").optional().describe("Lands the page as an ordinary editable frame. Without it, the layers belong to a capture run.")
|
|
7956
8303
|
}),
|
|
7957
8304
|
canvasArrangePreparationSchema,
|
|
7958
8305
|
canvasDuplicatePreparationSchema,
|
|
@@ -8033,7 +8380,11 @@ progression: object$1({
|
|
|
8033
8380
|
job.extend({
|
|
8034
8381
|
state: literal$1("succeeded"),
|
|
8035
8382
|
phase: literal$1("complete"),
|
|
8036
|
-
result: canvasPreparationPlanSchema.extend({
|
|
8383
|
+
result: canvasPreparationPlanSchema.extend({
|
|
8384
|
+
loadedVersion: number$2().int().positive(),
|
|
8385
|
+
/** Where a screen compile fell back, such as a font it replaced; absent when it had none. */
|
|
8386
|
+
warnings: array$1(canvasRenderWarningSchema).optional()
|
|
8387
|
+
}),
|
|
8037
8388
|
failure: _null()
|
|
8038
8389
|
}),
|
|
8039
8390
|
job.extend({
|
|
@@ -8422,7 +8773,8 @@ progression: object$1({
|
|
|
8422
8773
|
"inspection",
|
|
8423
8774
|
"snapshot",
|
|
8424
8775
|
"thumbnail",
|
|
8425
|
-
"export"
|
|
8776
|
+
"export",
|
|
8777
|
+
"object-pictures"
|
|
8426
8778
|
]),
|
|
8427
8779
|
scale: number$2().positive(),
|
|
8428
8780
|
maxOutputPixels: canvasRenderPixelLimitSchema.optional(),
|
|
@@ -8493,6 +8845,16 @@ progression: object$1({
|
|
|
8493
8845
|
sourceState: _undefined().optional(),
|
|
8494
8846
|
conversion: canvasConversionRequestSchema,
|
|
8495
8847
|
scale: literal$1(1)
|
|
8848
|
+
}),
|
|
8849
|
+
claimRenderWorkBaseSchema.extend({
|
|
8850
|
+
purpose: literal$1("object-pictures"),
|
|
8851
|
+
target: canvasRenderTargetSchema,
|
|
8852
|
+
sourceState: _undefined().optional(),
|
|
8853
|
+
scale: number$2().positive(),
|
|
8854
|
+
maxOutputPixels: canvasRenderPixelLimitSchema.optional(),
|
|
8855
|
+
/** The top layers to draw, in order; each picture is stored under the prefix. */
|
|
8856
|
+
objects: array$1(objectPictureWorkObjectSchema).max(20),
|
|
8857
|
+
outputPrefix: string$1().min(1).max(MAX_STORAGE_KEY_LENGTH)
|
|
8496
8858
|
})
|
|
8497
8859
|
]);
|
|
8498
8860
|
object$1({
|
|
@@ -8639,6 +9001,7 @@ progression: object$1({
|
|
|
8639
9001
|
nodes: array$1(canvasInspectNodeSummarySchema),
|
|
8640
9002
|
contextRootId: nodeIdSchema.nullable(),
|
|
8641
9003
|
visibleWorldBox: canvasWorldBoundsSchema.nullable(),
|
|
9004
|
+
boxNote: string$1().min(1).optional(),
|
|
8642
9005
|
next: array$1(string$1().min(1)).max(MAX_SELECTION_COMMANDS)
|
|
8643
9006
|
});
|
|
8644
9007
|
//#endregion
|
|
@@ -8647,6 +9010,17 @@ progression: object$1({
|
|
|
8647
9010
|
kind: literal$1("recording"),
|
|
8648
9011
|
recordingId: string$1()
|
|
8649
9012
|
})]);
|
|
9013
|
+
/**
|
|
9014
|
+
* The mark on a captured page's picture while it becomes editable. Every capture lands as this
|
|
9015
|
+
* picture first; whoever converts it replaces the same layer with the editable frame, through the
|
|
9016
|
+
* one swap (`insertConvertedSubtree` with destination `replace` and `onlyPicture`). A conversion
|
|
9017
|
+
* that fails writes `failed` with a short reason, so every viewer sees the failure rather than a
|
|
9018
|
+
* spinner that never ends; Try again writes `converting` again.
|
|
9019
|
+
*/
|
|
9020
|
+
const captureLandingSchema = discriminatedUnion$1("state", [object$1({ state: literal$1("converting") }), object$1({
|
|
9021
|
+
state: literal$1("failed"),
|
|
9022
|
+
reason: string$1().min(1).max(200)
|
|
9023
|
+
})]);
|
|
8650
9024
|
object$1({
|
|
8651
9025
|
html: string$1().optional(),
|
|
8652
9026
|
viewport: object$1({
|
|
@@ -8656,7 +9030,8 @@ progression: object$1({
|
|
|
8656
9030
|
atMs: number$2(),
|
|
8657
9031
|
screenId: string$1().nullable().default(null),
|
|
8658
9032
|
sourceNodeId: string$1().optional(),
|
|
8659
|
-
provenance: canvasCaptureProvenanceSchema.optional()
|
|
9033
|
+
provenance: canvasCaptureProvenanceSchema.optional(),
|
|
9034
|
+
landing: captureLandingSchema.optional()
|
|
8660
9035
|
});
|
|
8661
9036
|
object$1({
|
|
8662
9037
|
provenance: canvasCaptureProvenanceSchema.optional(),
|
|
@@ -8784,12 +9159,16 @@ progression: object$1({
|
|
|
8784
9159
|
versionId: uuid$1()
|
|
8785
9160
|
});
|
|
8786
9161
|
object$1({ entry: canvasVersionEntrySchema });
|
|
9162
|
+
/** A restore or a duplicate copies a version the API holds, so it only names what to change. */
|
|
9163
|
+
const refuseUnsafeVersionCopy = (input, context) => {
|
|
9164
|
+
refuseUnsafeWriterFormat(input.documentFormatVersion, "names", context);
|
|
9165
|
+
};
|
|
8787
9166
|
object$1({
|
|
8788
9167
|
canvasId: uuid$1(),
|
|
8789
9168
|
documentFormatVersion: canvasDocumentFormatSchema,
|
|
8790
9169
|
versionId: uuid$1(),
|
|
8791
9170
|
expectedVersion: number$2().int().positive()
|
|
8792
|
-
});
|
|
9171
|
+
}).superRefine(refuseUnsafeVersionCopy);
|
|
8793
9172
|
object$1({
|
|
8794
9173
|
canvasId: uuid$1(),
|
|
8795
9174
|
version: number$2().int().positive(),
|
|
@@ -8803,7 +9182,7 @@ progression: object$1({
|
|
|
8803
9182
|
versionId: uuid$1(),
|
|
8804
9183
|
organisationId: union$1([uuid$1(), literal$1("personal")]),
|
|
8805
9184
|
title: string$1().trim().min(1).optional()
|
|
8806
|
-
});
|
|
9185
|
+
}).superRefine(refuseUnsafeVersionCopy);
|
|
8807
9186
|
object$1({
|
|
8808
9187
|
canvasId: uuid$1(),
|
|
8809
9188
|
title: string$1().min(1),
|
|
@@ -9345,9 +9724,9 @@ progression: object$1({
|
|
|
9345
9724
|
//#region ../contract/src/recording/frozen-screen.lib.ts
|
|
9346
9725
|
const META_EVENT = 4;
|
|
9347
9726
|
const FULL_SNAPSHOT$2 = 2;
|
|
9348
|
-
const isObject$
|
|
9349
|
-
const isTimedEvent = (value, type) => isObject$
|
|
9350
|
-
const isAnyTimedEvent = (value) => isObject$
|
|
9727
|
+
const isObject$5 = (value) => typeof value === "object" && value !== null;
|
|
9728
|
+
const isTimedEvent = (value, type) => isObject$5(value) && Reflect.get(value, "type") === type && typeof Reflect.get(value, "timestamp") === "number";
|
|
9729
|
+
const isAnyTimedEvent = (value) => isObject$5(value) && typeof Reflect.get(value, "type") === "number" && typeof Reflect.get(value, "timestamp") === "number";
|
|
9351
9730
|
/**
|
|
9352
9731
|
* The durable form of one marked moment. It deliberately contains rrweb's serialized tree,
|
|
9353
9732
|
* not HTML: reparsing `outerHTML` normalises the live DOM and can split working nested controls
|
|
@@ -9376,6 +9755,16 @@ progression: object$1({
|
|
|
9376
9755
|
};
|
|
9377
9756
|
return JSON.stringify(artifact);
|
|
9378
9757
|
};
|
|
9758
|
+
object$1({ canvasId: uuid$1() });
|
|
9759
|
+
object$1({
|
|
9760
|
+
/** The only credential a page receives: it stores captures and does nothing else. */
|
|
9761
|
+
pass: string$1().min(1),
|
|
9762
|
+
expiresAt: datetime(),
|
|
9763
|
+
/** Where the capture script is published, for the snippet to load. */
|
|
9764
|
+
scriptUrl: url(),
|
|
9765
|
+
/** Where the page stores its capture: the API as the page reaches it. */
|
|
9766
|
+
apiUrl: url()
|
|
9767
|
+
});
|
|
9379
9768
|
//#endregion
|
|
9380
9769
|
//#region ../contract/src/comment/comment.schema.ts
|
|
9381
9770
|
/** How many replies a thread hands back in one go before `hasMoreMessages` takes over. */
|
|
@@ -10669,6 +11058,12 @@ progression: object$1({
|
|
|
10669
11058
|
version: number$2().int().positive()
|
|
10670
11059
|
})]).optional()
|
|
10671
11060
|
});
|
|
11061
|
+
object$1({ bytes: number$2().int().positive().max(Number.MAX_SAFE_INTEGER) });
|
|
11062
|
+
object$1({
|
|
11063
|
+
id: uuid$1(),
|
|
11064
|
+
upload: signedUploadSchema
|
|
11065
|
+
});
|
|
11066
|
+
object$1({ id: uuid$1() });
|
|
10672
11067
|
const MAX_PROTOTYPE_CONTENT_TYPE_LENGTH = 200;
|
|
10673
11068
|
const prototypePathSchema = string$1().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" });
|
|
10674
11069
|
const prototypeFileSchema = object$1({
|
|
@@ -10799,6 +11194,30 @@ progression: object$1({
|
|
|
10799
11194
|
(/* @__PURE__ */ string()).check(/* @__PURE__ */ _maxLength(MAX_REASON_LENGTH));
|
|
10800
11195
|
(/* @__PURE__ */ number()).check(/* @__PURE__ */ _gte(0), /* @__PURE__ */ _lte(1)), (/* @__PURE__ */ number()).check(/* @__PURE__ */ _gte(0), /* @__PURE__ */ _lte(1));
|
|
10801
11196
|
//#endregion
|
|
11197
|
+
//#region ../contract/src/recording/canvas-context-kinds.lib.ts
|
|
11198
|
+
/**
|
|
11199
|
+
* Which drawing context each canvas holds, noted from the page's start. An empty read of a WebGL
|
|
11200
|
+
* canvas can hide a picture already given to the screen; an empty read of a 2D canvas, or of one
|
|
11201
|
+
* no script gave a context, is the truth. Only a watcher that runs before the page's scripts can
|
|
11202
|
+
* know which is which, because asking an untouched canvas for a context creates one.
|
|
11203
|
+
*/
|
|
11204
|
+
const KINDS_KEY = Symbol.for("enhance.canvasContextKinds");
|
|
11205
|
+
const isContextKinds = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "get") === "function";
|
|
11206
|
+
const kindsIn = (scope) => {
|
|
11207
|
+
const kinds = Reflect.get(scope, KINDS_KEY);
|
|
11208
|
+
return isContextKinds(kinds) ? kinds : null;
|
|
11209
|
+
};
|
|
11210
|
+
/** What the watcher in a canvas's own window knows of it; `unknown` when nothing watched it. */
|
|
11211
|
+
const canvasContextKnowledgeOf = (canvas) => {
|
|
11212
|
+
if (typeof canvas !== "object" || canvas === null) return "unknown";
|
|
11213
|
+
const owner = Reflect.get(canvas, "ownerDocument");
|
|
11214
|
+
const view = typeof owner === "object" && owner !== null ? Reflect.get(owner, "defaultView") : null;
|
|
11215
|
+
const kinds = typeof view === "object" && view !== null ? kindsIn(view) : null;
|
|
11216
|
+
return kinds === null ? "unknown" : kinds.get(canvas) ?? "none";
|
|
11217
|
+
};
|
|
11218
|
+
/** An empty read of a canvas in one of these states is the canvas's real picture. */
|
|
11219
|
+
const isEmptyReadTruthful = (knowledge) => knowledge === "none" || knowledge === "2d";
|
|
11220
|
+
//#endregion
|
|
10802
11221
|
//#region ../contract/src/recording/inline-data-asset.lib.ts
|
|
10803
11222
|
const INLINE_IMAGE = /^data:(image\/(?:avif|gif|jpeg|png|webp));base64,([a-z0-9+/]+={0,2})$/iu;
|
|
10804
11223
|
const HASH_RADIX = 16;
|
|
@@ -10842,11 +11261,175 @@ progression: object$1({
|
|
|
10842
11261
|
};
|
|
10843
11262
|
};
|
|
10844
11263
|
//#endregion
|
|
11264
|
+
//#region ../contract/src/recording/captured-media.lib.ts
|
|
11265
|
+
/**
|
|
11266
|
+
* What a capture saw a video, `object` or `embed` show, written on its copy: `picture` (the
|
|
11267
|
+
* picture is in the element's own picture attribute), `empty` (it showed nothing) or
|
|
11268
|
+
* `unreadable` (with a reason). A copy without it was made before captures read media.
|
|
11269
|
+
*/
|
|
11270
|
+
const CAPTURED_MEDIA_ATTRIBUTE = "data-enhance-media";
|
|
11271
|
+
const CAPTURED_MEDIA_REASON_ATTRIBUTE = "data-enhance-media-reason";
|
|
11272
|
+
/** The attribute each media element shows its picture through, without a live source. */
|
|
11273
|
+
const MEDIA_PICTURE_ATTRIBUTES = {
|
|
11274
|
+
embed: "src",
|
|
11275
|
+
object: "data",
|
|
11276
|
+
video: "poster"
|
|
11277
|
+
};
|
|
11278
|
+
const MEDIA_REASONS = {
|
|
11279
|
+
crossSite: "This video comes from another site that does not allow its frames to be copied.",
|
|
11280
|
+
protected: "This video is protected, so its frame cannot be copied.",
|
|
11281
|
+
embeddedPage: "This is an embedded web page or plugin, which Enhance does not draw.",
|
|
11282
|
+
notStored: "The picture this element showed could not be stored with the page."
|
|
11283
|
+
};
|
|
11284
|
+
const ELEMENT$5 = 2;
|
|
11285
|
+
const HAVE_CURRENT_DATA = 2;
|
|
11286
|
+
const isObject$4 = (value) => typeof value === "object" && value !== null;
|
|
11287
|
+
const localNameOf = (element) => String(Reflect.get(element, "localName") ?? "");
|
|
11288
|
+
const attributeOf = (element, name) => {
|
|
11289
|
+
const read = Reflect.get(element, "getAttribute");
|
|
11290
|
+
if (typeof read !== "function") return "";
|
|
11291
|
+
const value = Reflect.apply(read, element, [name]);
|
|
11292
|
+
return typeof value === "string" ? value.trim() : "";
|
|
11293
|
+
};
|
|
11294
|
+
const stringOf = (element, name) => {
|
|
11295
|
+
const value = Reflect.get(element, name);
|
|
11296
|
+
return typeof value === "string" ? value : "";
|
|
11297
|
+
};
|
|
11298
|
+
const numberOf = (element, name) => {
|
|
11299
|
+
const value = Number(Reflect.get(element, name));
|
|
11300
|
+
return Number.isFinite(value) ? value : 0;
|
|
11301
|
+
};
|
|
11302
|
+
const picture = (source) => ({
|
|
11303
|
+
kind: "picture",
|
|
11304
|
+
source
|
|
11305
|
+
});
|
|
11306
|
+
const unreadable = (reason) => ({
|
|
11307
|
+
kind: "unreadable",
|
|
11308
|
+
reason
|
|
11309
|
+
});
|
|
11310
|
+
const call = (target, name, args) => {
|
|
11311
|
+
const method = Reflect.get(target, name);
|
|
11312
|
+
return typeof method === "function" ? Reflect.apply(method, target, args) : void 0;
|
|
11313
|
+
};
|
|
11314
|
+
const isSecurityError = (error) => isObject$4(error) && Reflect.get(error, "name") === "SecurityError";
|
|
11315
|
+
/** The current frame, drawn at the video's own size, or why it could not be read. */
|
|
11316
|
+
const frameOf = (video) => {
|
|
11317
|
+
try {
|
|
11318
|
+
const owner = Reflect.get(video, "ownerDocument");
|
|
11319
|
+
const canvas = isObject$4(owner) ? call(owner, "createElement", ["canvas"]) : null;
|
|
11320
|
+
if (!isObject$4(canvas)) return unreadable(MEDIA_REASONS.notStored);
|
|
11321
|
+
Reflect.set(canvas, "width", numberOf(video, "videoWidth"));
|
|
11322
|
+
Reflect.set(canvas, "height", numberOf(video, "videoHeight"));
|
|
11323
|
+
const context = call(canvas, "getContext", ["2d"]);
|
|
11324
|
+
if (!isObject$4(context)) return unreadable(MEDIA_REASONS.notStored);
|
|
11325
|
+
call(context, "drawImage", [
|
|
11326
|
+
video,
|
|
11327
|
+
0,
|
|
11328
|
+
0
|
|
11329
|
+
]);
|
|
11330
|
+
const encoded = String(call(canvas, "toDataURL", ["image/png"]));
|
|
11331
|
+
return inlineDataAssetReference(encoded)?.contentType === "image/png" ? picture(encoded) : unreadable(MEDIA_REASONS.notStored);
|
|
11332
|
+
} catch (error) {
|
|
11333
|
+
return unreadable(isSecurityError(error) ? MEDIA_REASONS.crossSite : MEDIA_REASONS.notStored);
|
|
11334
|
+
}
|
|
11335
|
+
};
|
|
11336
|
+
/**
|
|
11337
|
+
* A video shows its poster until it has played or been moved to another time, and while it has
|
|
11338
|
+
* no frame; otherwise its current frame.
|
|
11339
|
+
*/
|
|
11340
|
+
const videoMediaOf = (video) => {
|
|
11341
|
+
const keys = Reflect.get(video, "mediaKeys");
|
|
11342
|
+
if (keys !== null && keys !== void 0) return unreadable(MEDIA_REASONS.protected);
|
|
11343
|
+
const poster = attributeOf(video, "poster") === "" ? "" : stringOf(video, "poster");
|
|
11344
|
+
const hasFrame = numberOf(video, "readyState") >= HAVE_CURRENT_DATA && numberOf(video, "videoWidth") > 0 && numberOf(video, "videoHeight") > 0;
|
|
11345
|
+
const played = Reflect.get(video, "played");
|
|
11346
|
+
const hasPlayed = isObject$4(played) && Number(Reflect.get(played, "length")) > 0;
|
|
11347
|
+
const hasMoved = numberOf(video, "currentTime") > 0 || Reflect.get(video, "seeking") === true;
|
|
11348
|
+
if (poster !== "" && (!hasFrame || !hasPlayed && !hasMoved)) return picture(poster);
|
|
11349
|
+
if (!hasFrame) return { kind: "empty" };
|
|
11350
|
+
return frameOf(video);
|
|
11351
|
+
};
|
|
11352
|
+
const contentDocumentOf = (element) => {
|
|
11353
|
+
try {
|
|
11354
|
+
const owned = Reflect.get(element, "contentDocument");
|
|
11355
|
+
if (owned !== void 0) return owned;
|
|
11356
|
+
const read = Reflect.get(element, "getSVGDocument");
|
|
11357
|
+
return typeof read === "function" ? Reflect.apply(read, element, []) : null;
|
|
11358
|
+
} catch {
|
|
11359
|
+
return null;
|
|
11360
|
+
}
|
|
11361
|
+
};
|
|
11362
|
+
/** What an `object` or `embed` shows: an image or SVG file by its address, or a web page. */
|
|
11363
|
+
const embeddedMediaOf = (element, attribute) => {
|
|
11364
|
+
if (attributeOf(element, attribute) === "") return localNameOf(element) === "object" ? null : { kind: "empty" };
|
|
11365
|
+
const document = contentDocumentOf(element);
|
|
11366
|
+
const root = isObject$4(document) ? Reflect.get(document, "documentElement") : null;
|
|
11367
|
+
if (isObject$4(root) && localNameOf(root) !== "svg") return unreadable(MEDIA_REASONS.embeddedPage);
|
|
11368
|
+
return picture(stringOf(element, attribute));
|
|
11369
|
+
};
|
|
11370
|
+
/** What a live media element showed, or null when it is not one or needs no answer. */
|
|
11371
|
+
const capturedMediaOf = (element) => {
|
|
11372
|
+
if (!isObject$4(element)) return null;
|
|
11373
|
+
switch (localNameOf(element)) {
|
|
11374
|
+
case "video": return videoMediaOf(element);
|
|
11375
|
+
case "object": return embeddedMediaOf(element, "data");
|
|
11376
|
+
case "embed": return embeddedMediaOf(element, "src");
|
|
11377
|
+
default: return null;
|
|
11378
|
+
}
|
|
11379
|
+
};
|
|
11380
|
+
/** Attributes that make a media element play or load from the live page. */
|
|
11381
|
+
const isLiveSourceAttribute = (name, tagName) => name.startsWith("rr_media") || name === "autoplay" || tagName === "video" && name === "src" || (tagName === "object" || tagName === "embed") && (name === "type" || name === "typemustmatch");
|
|
11382
|
+
const withoutLiveSources = (attributes, tagName) => Object.fromEntries(Object.entries(attributes).filter(([name]) => !isLiveSourceAttribute(name, tagName)));
|
|
11383
|
+
/** A media element's attributes with what it showed written on them and its live sources gone. */
|
|
11384
|
+
const capturedMediaAttributes = (tagName, attributes, media) => {
|
|
11385
|
+
const attribute = MEDIA_PICTURE_ATTRIBUTES[tagName];
|
|
11386
|
+
if (attribute === void 0) return attributes;
|
|
11387
|
+
if (media.kind === "unreadable") return {
|
|
11388
|
+
...attributes,
|
|
11389
|
+
[CAPTURED_MEDIA_ATTRIBUTE]: "unreadable",
|
|
11390
|
+
[CAPTURED_MEDIA_REASON_ATTRIBUTE]: media.reason
|
|
11391
|
+
};
|
|
11392
|
+
const rest = Object.fromEntries(Object.entries(withoutLiveSources(attributes, tagName)).filter(([name]) => name !== attribute));
|
|
11393
|
+
return media.kind === "picture" ? {
|
|
11394
|
+
...rest,
|
|
11395
|
+
[attribute]: media.source,
|
|
11396
|
+
[CAPTURED_MEDIA_ATTRIBUTE]: "picture"
|
|
11397
|
+
} : {
|
|
11398
|
+
...rest,
|
|
11399
|
+
[CAPTURED_MEDIA_ATTRIBUTE]: "empty"
|
|
11400
|
+
};
|
|
11401
|
+
};
|
|
11402
|
+
/** The copy of a media element with what it showed written on it and its live sources gone. */
|
|
11403
|
+
const withCapturedMediaAnswer = (node, media) => {
|
|
11404
|
+
const tagName = node.tagName ?? "";
|
|
11405
|
+
if (MEDIA_PICTURE_ATTRIBUTES[tagName] === void 0) return node;
|
|
11406
|
+
const attributes = capturedMediaAttributes(tagName, node.attributes ?? {}, media);
|
|
11407
|
+
return media.kind === "unreadable" ? {
|
|
11408
|
+
...node,
|
|
11409
|
+
attributes
|
|
11410
|
+
} : {
|
|
11411
|
+
...node,
|
|
11412
|
+
attributes,
|
|
11413
|
+
childNodes: []
|
|
11414
|
+
};
|
|
11415
|
+
};
|
|
11416
|
+
/** Writes what each live media element in a snapshot showed onto its copy. */
|
|
11417
|
+
const withCapturedMedia = (node, nodeForId) => {
|
|
11418
|
+
const media = node.type === ELEMENT$5 && node.tagName !== void 0 && MEDIA_PICTURE_ATTRIBUTES[node.tagName] !== void 0 && typeof node.id === "number" ? capturedMediaOf(nodeForId(node.id)) : null;
|
|
11419
|
+
if (media !== null) return withCapturedMediaAnswer(node, media);
|
|
11420
|
+
const children = node.childNodes;
|
|
11421
|
+
if (children === void 0) return node;
|
|
11422
|
+
return {
|
|
11423
|
+
...node,
|
|
11424
|
+
childNodes: children.map((child) => withCapturedMedia(child, nodeForId))
|
|
11425
|
+
};
|
|
11426
|
+
};
|
|
11427
|
+
//#endregion
|
|
10845
11428
|
//#region ../contract/src/recording/captured-canvas.lib.ts
|
|
10846
11429
|
const CAPTURED_CANVAS_SOURCE_ATTRIBUTE = "data-enhance-canvas-source";
|
|
10847
11430
|
const RR_CANVAS_DATA_URL_ATTRIBUTE = "rr_dataURL";
|
|
10848
|
-
const ELEMENT$
|
|
10849
|
-
const isObject$
|
|
11431
|
+
const ELEMENT$4 = 2;
|
|
11432
|
+
const isObject$3 = (value) => typeof value === "object" && value !== null;
|
|
10850
11433
|
const isLosslessInlineCanvas = (value) => inlineDataAssetReference(value)?.contentType === "image/png";
|
|
10851
11434
|
/** A canvas source produced by capture, either before or after recording-asset externalisation. */
|
|
10852
11435
|
const isCapturedCanvasSource = (value) => typeof value === "string" && (isLosslessInlineCanvas(value) || value.startsWith("/v1/recording-assets/"));
|
|
@@ -10868,12 +11451,12 @@ progression: object$1({
|
|
|
10868
11451
|
};
|
|
10869
11452
|
const blankCanvasPng = (value) => {
|
|
10870
11453
|
const owner = Reflect.get(value, "ownerDocument");
|
|
10871
|
-
if (!isObject$
|
|
11454
|
+
if (!isObject$3(owner)) return null;
|
|
10872
11455
|
const create = Reflect.get(owner, "createElement");
|
|
10873
11456
|
if (typeof create !== "function") return null;
|
|
10874
11457
|
try {
|
|
10875
11458
|
const blank = Reflect.apply(create, owner, ["canvas"]);
|
|
10876
|
-
if (!isObject$
|
|
11459
|
+
if (!isObject$3(blank)) return null;
|
|
10877
11460
|
Reflect.set(blank, "width", Reflect.get(value, "width"));
|
|
10878
11461
|
Reflect.set(blank, "height", Reflect.get(value, "height"));
|
|
10879
11462
|
return encodedPng(blank);
|
|
@@ -10881,20 +11464,27 @@ progression: object$1({
|
|
|
10881
11464
|
return null;
|
|
10882
11465
|
}
|
|
10883
11466
|
};
|
|
10884
|
-
const
|
|
10885
|
-
|
|
11467
|
+
const CANVAS_REASONS = {
|
|
11468
|
+
crossSite: "This canvas shows a picture from another site, so its pixels cannot be copied.",
|
|
11469
|
+
unknownKind: "This canvas was empty or drawn with WebGL, and the capture could not tell which. Load the capture script before the page's own scripts to keep it.",
|
|
11470
|
+
webgl: "This canvas is drawn with WebGL, whose picture cannot be read once it is on screen."
|
|
11471
|
+
};
|
|
11472
|
+
const canvasRead = (value) => {
|
|
11473
|
+
if (!isObject$3(value)) return null;
|
|
10886
11474
|
const source = encodedPng(value);
|
|
10887
|
-
if (source === null
|
|
10888
|
-
|
|
11475
|
+
if (source === null) return { reason: CANVAS_REASONS.crossSite };
|
|
11476
|
+
const knowledge = canvasContextKnowledgeOf(value);
|
|
11477
|
+
if (source === blankCanvasPng(value) && !isEmptyReadTruthful(knowledge)) return { reason: knowledge === "unknown" ? CANVAS_REASONS.unknownKind : CANVAS_REASONS.webgl };
|
|
11478
|
+
return { source };
|
|
10889
11479
|
};
|
|
10890
|
-
/** Adds readable backing-store pixels
|
|
11480
|
+
/** Adds readable backing-store pixels, or why they could not be read, to each canvas. */
|
|
10891
11481
|
const withReadableCanvasPixels = (node, nodeForId) => {
|
|
10892
|
-
const
|
|
11482
|
+
const read = node.type === ELEMENT$4 && node.tagName === "canvas" && typeof node.id === "number" ? canvasRead(nodeForId(node.id)) : null;
|
|
10893
11483
|
const childNodes = node.childNodes?.map((child) => withReadableCanvasPixels(child, nodeForId));
|
|
10894
|
-
if (
|
|
10895
|
-
const attributes =
|
|
11484
|
+
if (read === null && childNodes === void 0) return node;
|
|
11485
|
+
const attributes = read === null ? void 0 : {
|
|
10896
11486
|
...node.attributes,
|
|
10897
|
-
[RR_CANVAS_DATA_URL_ATTRIBUTE]: source
|
|
11487
|
+
..."source" in read ? { [RR_CANVAS_DATA_URL_ATTRIBUTE]: read.source } : { [CAPTURED_MEDIA_REASON_ATTRIBUTE]: read.reason }
|
|
10898
11488
|
};
|
|
10899
11489
|
return {
|
|
10900
11490
|
...node,
|
|
@@ -10910,6 +11500,12 @@ progression: object$1({
|
|
|
10910
11500
|
//#region ../contract/src/recording/captured-font-evidence.lib.ts
|
|
10911
11501
|
const CAPTURED_LOADED_FONTS_ATTRIBUTE = "data-enhance-loaded-captured-fonts";
|
|
10912
11502
|
const CAPTURED_UNAVAILABLE_FONTS_ATTRIBUTE = "data-enhance-unavailable-captured-fonts";
|
|
11503
|
+
/**
|
|
11504
|
+
* Font families the page names but declares no face for, which the capturing browser could draw:
|
|
11505
|
+
* fonts installed on that machine. The converting machine may lack them, and that says nothing of
|
|
11506
|
+
* what the person saw.
|
|
11507
|
+
*/
|
|
11508
|
+
const CAPTURED_DRAWABLE_FONTS_ATTRIBUTE = "data-enhance-drawable-captured-fonts";
|
|
10913
11509
|
const loadedCapturedFontFamilies = (fonts) => {
|
|
10914
11510
|
if (typeof fonts !== "object" || fonts === null) return [];
|
|
10915
11511
|
const forEach = Reflect.get(fonts, "forEach");
|
|
@@ -10923,8 +11519,109 @@ progression: object$1({
|
|
|
10923
11519
|
return [...found];
|
|
10924
11520
|
};
|
|
10925
11521
|
//#endregion
|
|
11522
|
+
//#region ../contract/src/recording/missing-replay-asset.lib.ts
|
|
11523
|
+
const MISSING_ASSET_PREFIX = "data:application/x.enhance-missing-asset,";
|
|
11524
|
+
const missingReplayAssetSourceIn = (url) => {
|
|
11525
|
+
if (!url.startsWith(MISSING_ASSET_PREFIX)) return null;
|
|
11526
|
+
try {
|
|
11527
|
+
const source = decodeURIComponent(url.slice(41));
|
|
11528
|
+
return ["http:", "https:"].includes(new URL(source).protocol) ? source : null;
|
|
11529
|
+
} catch {
|
|
11530
|
+
return null;
|
|
11531
|
+
}
|
|
11532
|
+
};
|
|
11533
|
+
//#endregion
|
|
11534
|
+
//#region ../contract/src/recording/captured-media-replay.lib.ts
|
|
11535
|
+
/** The attribute through which a captured media element shows its picture, if it has one. */
|
|
11536
|
+
const capturedMediaPictureAttribute = (tagName, attributes) => {
|
|
11537
|
+
const attribute = MEDIA_PICTURE_ATTRIBUTES[tagName];
|
|
11538
|
+
return attribute !== void 0 && attributes["data-enhance-media"] === "picture" ? attribute : null;
|
|
11539
|
+
};
|
|
11540
|
+
/**
|
|
11541
|
+
* Whether a captured media element shows its own content (a picture or nothing), and why not when
|
|
11542
|
+
* it does not. `undefined` means the capture gave no answer.
|
|
11543
|
+
*/
|
|
11544
|
+
const capturedMediaShown = (tagName, attributes) => {
|
|
11545
|
+
const answer = attributes[CAPTURED_MEDIA_ATTRIBUTE];
|
|
11546
|
+
if (answer === "empty") return { isShown: true };
|
|
11547
|
+
if (answer === "unreadable") {
|
|
11548
|
+
const reason = attributes[CAPTURED_MEDIA_REASON_ATTRIBUTE];
|
|
11549
|
+
return {
|
|
11550
|
+
isShown: false,
|
|
11551
|
+
reason: typeof reason === "string" ? reason : null
|
|
11552
|
+
};
|
|
11553
|
+
}
|
|
11554
|
+
const attribute = capturedMediaPictureAttribute(tagName, attributes);
|
|
11555
|
+
if (attribute === null) return void 0;
|
|
11556
|
+
const source = attributes[attribute];
|
|
11557
|
+
return typeof source === "string" && source !== "" && missingReplayAssetSourceIn(source) === null ? { isShown: true } : {
|
|
11558
|
+
isShown: false,
|
|
11559
|
+
reason: MEDIA_REASONS.notStored
|
|
11560
|
+
};
|
|
11561
|
+
};
|
|
11562
|
+
/** Whether a video, object or embed is drawn as its own content rather than a placeholder. */
|
|
11563
|
+
const isCapturedMediaShown = (tagName, attributes) => {
|
|
11564
|
+
const shown = capturedMediaShown(tagName, attributes);
|
|
11565
|
+
if (shown !== void 0) return shown.isShown;
|
|
11566
|
+
const data = attributes["data"];
|
|
11567
|
+
return tagName === "object" && attributes["rr_width"] === void 0 && (typeof data !== "string" || data.trim() === "");
|
|
11568
|
+
};
|
|
11569
|
+
/** A media placeholder keeps the capture's reason, or names a picture the store did not keep. */
|
|
11570
|
+
const withCapturedMediaReason = (tagName, captured, attributes) => {
|
|
11571
|
+
const shown = capturedMediaShown(tagName, captured);
|
|
11572
|
+
return shown === void 0 || shown.isShown || shown.reason === null ? attributes : {
|
|
11573
|
+
...attributes,
|
|
11574
|
+
[CAPTURED_MEDIA_REASON_ATTRIBUTE]: shown.reason
|
|
11575
|
+
};
|
|
11576
|
+
};
|
|
11577
|
+
//#endregion
|
|
11578
|
+
//#region ../contract/src/recording/cdata-text.lib.ts
|
|
11579
|
+
const TEXT = 3;
|
|
11580
|
+
const CDATA = 4;
|
|
11581
|
+
/** What rrweb stores for the text of any script, so a page's script is never recorded. */
|
|
11582
|
+
const SCRIPT_PLACEHOLDER = "SCRIPT_PLACEHOLDER";
|
|
11583
|
+
const isObject$2 = (value) => typeof value === "object" && value !== null;
|
|
11584
|
+
/** An XML page names its elements in lower case and an HTML page in upper case. */
|
|
11585
|
+
const parentNameOf = (section) => {
|
|
11586
|
+
const parent = section["parentNode"];
|
|
11587
|
+
const name = isObject$2(parent) ? parent["nodeName"] : null;
|
|
11588
|
+
return typeof name === "string" ? name.toLowerCase() : "";
|
|
11589
|
+
};
|
|
11590
|
+
const baseUrlOf = (section) => {
|
|
11591
|
+
const owner = section["ownerDocument"];
|
|
11592
|
+
const base = isObject$2(owner) ? owner["baseURI"] : null;
|
|
11593
|
+
return typeof base === "string" ? base : "";
|
|
11594
|
+
};
|
|
11595
|
+
const sectionText = (section, absoluteCss) => {
|
|
11596
|
+
if (!isObject$2(section) || typeof section["data"] !== "string") return "";
|
|
11597
|
+
const parent = parentNameOf(section);
|
|
11598
|
+
if (parent === "script") return SCRIPT_PLACEHOLDER;
|
|
11599
|
+
return parent === "style" ? absoluteCss(section["data"], baseUrlOf(section)) : section["data"];
|
|
11600
|
+
};
|
|
11601
|
+
/**
|
|
11602
|
+
* Stores each CDATA section as the text it holds. rrweb records a section empty, and its replay
|
|
11603
|
+
* cannot rebuild one, because only an XML document may hold a CDATA section and a replay is HTML.
|
|
11604
|
+
*/
|
|
11605
|
+
const withCdataAsText = (node, nodeForId, absoluteCss) => {
|
|
11606
|
+
if (node.type === CDATA) {
|
|
11607
|
+
const section = typeof node.id === "number" ? nodeForId(node.id) : null;
|
|
11608
|
+
return {
|
|
11609
|
+
...node,
|
|
11610
|
+
type: TEXT,
|
|
11611
|
+
textContent: sectionText(section, absoluteCss)
|
|
11612
|
+
};
|
|
11613
|
+
}
|
|
11614
|
+
const children = node.childNodes;
|
|
11615
|
+
if (children === void 0) return node;
|
|
11616
|
+
const childNodes = children.map((child) => withCdataAsText(child, nodeForId, absoluteCss));
|
|
11617
|
+
return childNodes.every((child, index) => child === children[index]) ? node : {
|
|
11618
|
+
...node,
|
|
11619
|
+
childNodes
|
|
11620
|
+
};
|
|
11621
|
+
};
|
|
11622
|
+
//#endregion
|
|
10926
11623
|
//#region ../contract/src/recording/full-page-screen.lib.ts
|
|
10927
|
-
const PERCENT = 100;
|
|
11624
|
+
const PERCENT$1 = 100;
|
|
10928
11625
|
const CSS_TOKEN = /\/\*[\s\S]*?\*\/|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|url\((?:\\.|[^)])*\)|@media\b([^{}]+)\{|(?:--|-?[a-z_\u{80}-\u{10FFFF}]|\\(?:[\da-f]{1,6}\s?|[^\da-f\r\n\f]))[\w\u{80}-\u{10FFFF}-]*|(-?(?:\d*\.)?\d+(?:e[+-]?\d+)?)([sld]?v(?:min|max|[hwib]))\b/giu;
|
|
10929
11626
|
const viewportUnit = (unit, options) => {
|
|
10930
11627
|
if (unit.endsWith("min")) return Math.min(options.width, options.height);
|
|
@@ -10935,8 +11632,14 @@ progression: object$1({
|
|
|
10935
11632
|
const fullPageScreenCss = (css, options) => css.replaceAll(CSS_TOKEN, (token, media, amount, unit) => {
|
|
10936
11633
|
if (media !== void 0) return `@media ${options.matchesMedia(media) ? "all" : "not all"}{`;
|
|
10937
11634
|
if (amount === void 0) return token;
|
|
10938
|
-
return `${String(Number(amount) * viewportUnit(String(unit).toLowerCase(), options) / PERCENT)}px`;
|
|
11635
|
+
return `${String(Number(amount) * viewportUnit(String(unit).toLowerCase(), options) / PERCENT$1)}px`;
|
|
10939
11636
|
});
|
|
11637
|
+
/** The root keeps the sizes the live window gave it; only its clipping is opened. */
|
|
11638
|
+
const addedRulesOf = (node, options) => {
|
|
11639
|
+
const override = node.id === void 0 ? void 0 : options.overrides.get(node.id);
|
|
11640
|
+
const isRoot = node.tagName === "html" || node.tagName === "body";
|
|
11641
|
+
return [...override === void 0 ? [] : [override], ...isRoot ? ["overflow:visible!important"] : []];
|
|
11642
|
+
};
|
|
10940
11643
|
const fullPageAttributes = (node, options) => {
|
|
10941
11644
|
const attributes = node.attributes === void 0 ? void 0 : { ...node.attributes };
|
|
10942
11645
|
if (attributes !== void 0) {
|
|
@@ -10944,14 +11647,10 @@ progression: object$1({
|
|
|
10944
11647
|
const value = attributes[key];
|
|
10945
11648
|
if (typeof value === "string") attributes[key] = fullPageScreenCss(value, options);
|
|
10946
11649
|
}
|
|
10947
|
-
const override = node.id === void 0 ? void 0 : options.overrides.get(node.id);
|
|
10948
11650
|
const inlineStyle = typeof attributes["style"] === "string" ? attributes["style"] : "";
|
|
10949
|
-
|
|
10950
|
-
|
|
10951
|
-
attributes["
|
|
10952
|
-
}
|
|
10953
|
-
if (node.tagName === "html" || node.tagName === "body") {
|
|
10954
|
-
attributes["style"] = `${inlineStyle};height:auto!important;min-height:100%!important;max-height:none!important;overflow:visible!important`;
|
|
11651
|
+
const rules = addedRulesOf(node, options);
|
|
11652
|
+
if (rules.length > 0) {
|
|
11653
|
+
attributes["style"] = [inlineStyle, ...rules].join(";");
|
|
10955
11654
|
attributes["rr_scrollTop"] = 0;
|
|
10956
11655
|
}
|
|
10957
11656
|
}
|
|
@@ -10994,41 +11693,292 @@ progression: object$1({
|
|
|
10994
11693
|
};
|
|
10995
11694
|
};
|
|
10996
11695
|
//#endregion
|
|
10997
|
-
//#region ../contract/src/recording/
|
|
10998
|
-
|
|
10999
|
-
const
|
|
11000
|
-
|
|
11001
|
-
|
|
11002
|
-
|
|
11003
|
-
|
|
11004
|
-
|
|
11005
|
-
return null;
|
|
11006
|
-
}
|
|
11696
|
+
//#region ../contract/src/recording/unsupported-frame-label.lib.ts
|
|
11697
|
+
/** What stands in for an embedded page the capture could not keep, or null when it is kept. */
|
|
11698
|
+
const iframeSurfaceLabel = (attributes) => {
|
|
11699
|
+
const recordedSource = attributes["rr_src"];
|
|
11700
|
+
const isExplicitlyHidden = attributes["aria-hidden"] === "true" || attributes["width"] === "0" && attributes["height"] === "0";
|
|
11701
|
+
if (typeof recordedSource === "string" && !isExplicitlyHidden) return attributes["data-enhance-frame-unloaded"] === "" ? "Embedded content not loaded" : "Embedded content not supported";
|
|
11702
|
+
const source = attributes["src"] ?? attributes["srcdoc"];
|
|
11703
|
+
return typeof source === "string" && source.startsWith("blob:") ? "Embedded content not supported" : null;
|
|
11007
11704
|
};
|
|
11705
|
+
[`[data-enhance-unsupported]:not([data-enhance-unsupported-hidden]):not([style*="display: none"]) {
|
|
11706
|
+
align-items: center !important;
|
|
11707
|
+
background-color: #f7f7f8 !important;
|
|
11708
|
+
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;
|
|
11709
|
+
border: 1px solid #c7c7cc !important;
|
|
11710
|
+
box-sizing: border-box !important;
|
|
11711
|
+
color: #4f4f55 !important;
|
|
11712
|
+
display: flex !important;
|
|
11713
|
+
font: 500 14px/1.4 Inter, ui-sans-serif, system-ui, sans-serif !important;
|
|
11714
|
+
justify-content: center !important;
|
|
11715
|
+
overflow: hidden !important;
|
|
11716
|
+
text-align: center !important;
|
|
11717
|
+
}`, `[data-enhance-unsupported-hidden], [data-enhance-unsupported][style*="display: none"] {
|
|
11718
|
+
display: none !important;
|
|
11719
|
+
}`].join("\n");
|
|
11008
11720
|
//#endregion
|
|
11009
|
-
//#region ../contract/src/recording/
|
|
11721
|
+
//#region ../contract/src/recording/unsupported-surfaces.lib.ts
|
|
11722
|
+
const ELEMENT$3 = 2;
|
|
11010
11723
|
const FULL_SNAPSHOT$1 = 2;
|
|
11011
11724
|
const INCREMENTAL_SNAPSHOT$1 = 3;
|
|
11725
|
+
const MUTATION = 0;
|
|
11726
|
+
const OMIT_RECORDER_HOST = Symbol("omit-recorder-host");
|
|
11727
|
+
const isObject$1 = (value) => typeof value === "object" && value !== null;
|
|
11012
11728
|
const isUnknownArray$1 = (value) => Array.isArray(value);
|
|
11013
|
-
const
|
|
11014
|
-
const
|
|
11015
|
-
if (
|
|
11016
|
-
return
|
|
11017
|
-
|
|
11018
|
-
|
|
11019
|
-
|
|
11020
|
-
|
|
11021
|
-
|
|
11022
|
-
|
|
11023
|
-
|
|
11024
|
-
|
|
11025
|
-
|
|
11026
|
-
|
|
11729
|
+
const isSnapshotNode$1 = (value) => isObject$1(value) && typeof value["type"] === "number";
|
|
11730
|
+
const withoutRecorderHost = (node) => {
|
|
11731
|
+
if (node.type === ELEMENT$3 && node.tagName === "enhance3-recorder") return null;
|
|
11732
|
+
if (node.childNodes === void 0) return node;
|
|
11733
|
+
return {
|
|
11734
|
+
...node,
|
|
11735
|
+
childNodes: node.childNodes.flatMap((child) => {
|
|
11736
|
+
const kept = withoutRecorderHost(child);
|
|
11737
|
+
return kept === null ? [] : [kept];
|
|
11738
|
+
})
|
|
11739
|
+
};
|
|
11740
|
+
};
|
|
11741
|
+
const unsupportedSurfaceLabel = (tagName, attributes) => {
|
|
11742
|
+
switch (tagName) {
|
|
11743
|
+
case "canvas": return capturedCanvasSourceIn(attributes) === null ? "Canvas not supported" : null;
|
|
11744
|
+
case "video": return isCapturedMediaShown("video", attributes) ? null : "Video not supported";
|
|
11745
|
+
case "audio": return attributes["controls"] === void 0 && typeof attributes["rr_width"] !== "string" ? null : "Audio not supported";
|
|
11746
|
+
case "object":
|
|
11747
|
+
case "embed": return isCapturedMediaShown(tagName, attributes) ? null : "Embedded content not supported";
|
|
11748
|
+
case "img":
|
|
11749
|
+
case "image": {
|
|
11750
|
+
const source = attributes["src"] ?? attributes["href"] ?? attributes["xlink:href"];
|
|
11751
|
+
return typeof source === "string" && source.startsWith("blob:") ? "Image not supported" : null;
|
|
11752
|
+
}
|
|
11753
|
+
case "iframe": return iframeSurfaceLabel(attributes);
|
|
11754
|
+
case void 0: return null;
|
|
11755
|
+
default: return null;
|
|
11756
|
+
}
|
|
11757
|
+
};
|
|
11758
|
+
const labelFor = (node) => {
|
|
11759
|
+
if (node.type !== ELEMENT$3) return null;
|
|
11760
|
+
const attributes = node.attributes ?? {};
|
|
11761
|
+
const placeholder = attributes["data-enhance-unsupported"];
|
|
11762
|
+
if (typeof placeholder === "string" && node.tagName === "div") return placeholder;
|
|
11763
|
+
if (node.tagName === "iframe" && attributes["data-enhance-frame-unloaded"] === "") return iframeSurfaceLabel(attributes);
|
|
11764
|
+
const className = attributes["class"];
|
|
11765
|
+
const wasUnsupported = typeof className === "string" && className.split(/\s+/u).includes("enhance3-unsupported-surface");
|
|
11766
|
+
const wasBlocked = typeof attributes["rr_width"] === "string" && typeof attributes["rr_height"] === "string";
|
|
11767
|
+
if ((wasUnsupported || wasBlocked) && node.tagName === "iframe") return "Embedded content not supported";
|
|
11768
|
+
if ((wasUnsupported || wasBlocked) && (node.tagName === "img" || node.tagName === "image")) return "Image not supported";
|
|
11769
|
+
return unsupportedSurfaceLabel(node.tagName, attributes);
|
|
11770
|
+
};
|
|
11771
|
+
const placeholderAttributes = (attributes) => Object.fromEntries(Object.entries(attributes).flatMap(([name, value]) => {
|
|
11772
|
+
if (name.startsWith("rr_media")) return [];
|
|
11773
|
+
if (name !== "class" || typeof value !== "string") return [[name, value]];
|
|
11774
|
+
const cleaned = value.split(/\s+/u).filter((part) => part.length > 0 && part !== "enhance3-unsupported-surface").join(" ");
|
|
11775
|
+
return cleaned.length === 0 ? [] : [[name, cleaned]];
|
|
11776
|
+
}));
|
|
11777
|
+
const withoutFrameNavigation = (attributes) => Object.fromEntries(Object.entries(attributes).filter(([name]) => name !== "src" && name !== "rr_src" && name !== "srcdoc"));
|
|
11778
|
+
const wasDisplayNone = (attributes) => {
|
|
11779
|
+
const style = attributes["style"];
|
|
11780
|
+
return typeof style === "string" && /(?:^|;)\s*display\s*:\s*none(?:\s*!important)?\s*(?:;|$)/iu.test(style);
|
|
11781
|
+
};
|
|
11782
|
+
const wasZeroSizedBlock = (attributes) => {
|
|
11783
|
+
const width = attributes["rr_width"];
|
|
11784
|
+
const height = attributes["rr_height"];
|
|
11785
|
+
return typeof width === "string" && typeof height === "string" && Number(width.replace(/px$/u, "")) === 0 && Number(height.replace(/px$/u, "")) === 0;
|
|
11786
|
+
};
|
|
11787
|
+
const isExplicitlyHiddenFrame = (attributes) => attributes["aria-hidden"] === "true" || attributes["width"] === "0" && attributes["height"] === "0";
|
|
11788
|
+
const isUncapturedNavigatedFrame = (node) => {
|
|
11789
|
+
if (node.tagName !== "iframe") return false;
|
|
11790
|
+
const attributes = node.attributes ?? {};
|
|
11791
|
+
if (isExplicitlyHiddenFrame(attributes)) return false;
|
|
11792
|
+
const source = attributes["src"];
|
|
11793
|
+
if (!(typeof attributes["srcdoc"] !== "string" && typeof source === "string" && source !== "" && source !== "about:blank")) return false;
|
|
11794
|
+
return node.childNodes?.some((child) => child.type === 0) !== true;
|
|
11795
|
+
};
|
|
11796
|
+
/**
|
|
11797
|
+
* The same rrweb node, except a non-serialisable surface becomes an ordinary div. rrweb's block
|
|
11798
|
+
* selector supplies `rr_width` and `rr_height`; keeping them makes the replacement occupy the
|
|
11799
|
+
* exact rectangle the original did without keeping pixels that cannot become primitives later.
|
|
11800
|
+
*/
|
|
11801
|
+
const replaceUnsupportedSurfaces = (node, onUnsupported) => {
|
|
11802
|
+
const label = labelFor(node) ?? (isUncapturedNavigatedFrame(node) ? "Embedded content not supported" : null);
|
|
11803
|
+
if (label !== null) {
|
|
11804
|
+
onUnsupported?.(label);
|
|
11805
|
+
const attributes = withCapturedMediaReason(node.tagName ?? "", node.attributes ?? {}, placeholderAttributes(node.attributes ?? {}));
|
|
11806
|
+
if (node.tagName === "iframe") return {
|
|
11807
|
+
...node,
|
|
11808
|
+
attributes: {
|
|
11809
|
+
...withoutFrameNavigation(attributes),
|
|
11810
|
+
"aria-hidden": "true",
|
|
11811
|
+
"data-enhance-unsupported": label,
|
|
11812
|
+
...(wasDisplayNone(attributes) || wasZeroSizedBlock(attributes)) && { "data-enhance-unsupported-hidden": "" },
|
|
11813
|
+
role: "img"
|
|
11814
|
+
},
|
|
11815
|
+
childNodes: []
|
|
11816
|
+
};
|
|
11817
|
+
return {
|
|
11818
|
+
...node,
|
|
11819
|
+
tagName: "div",
|
|
11820
|
+
attributes: {
|
|
11821
|
+
...attributes,
|
|
11822
|
+
"aria-hidden": "true",
|
|
11823
|
+
"data-enhance-unsupported": label,
|
|
11824
|
+
role: "img"
|
|
11825
|
+
},
|
|
11826
|
+
childNodes: []
|
|
11827
|
+
};
|
|
11828
|
+
}
|
|
11829
|
+
if (node.type === ELEMENT$3 && node.tagName === "script") return {
|
|
11830
|
+
...node,
|
|
11831
|
+
childNodes: []
|
|
11832
|
+
};
|
|
11833
|
+
return node.childNodes === void 0 ? node : {
|
|
11834
|
+
...node,
|
|
11835
|
+
childNodes: node.childNodes.map((child) => replaceUnsupportedSurfaces(child, onUnsupported))
|
|
11836
|
+
};
|
|
11837
|
+
};
|
|
11838
|
+
const replaceFullSnapshot = (event, onUnsupported) => {
|
|
11839
|
+
const data = event["data"];
|
|
11840
|
+
if (!isObject$1(data)) return event;
|
|
11841
|
+
const node = data["node"];
|
|
11842
|
+
if (!isSnapshotNode$1(node)) return event;
|
|
11843
|
+
const prepared = withoutRecorderHost(replaceUnsupportedSurfaces(node, onUnsupported));
|
|
11844
|
+
if (prepared === null) return event;
|
|
11845
|
+
return {
|
|
11846
|
+
...event,
|
|
11847
|
+
data: {
|
|
11848
|
+
...data,
|
|
11849
|
+
node: prepared
|
|
11850
|
+
}
|
|
11851
|
+
};
|
|
11852
|
+
};
|
|
11853
|
+
const replaceAddedNode = (add, onUnsupported) => {
|
|
11854
|
+
if (!isObject$1(add)) return add;
|
|
11855
|
+
const node = add["node"];
|
|
11856
|
+
if (!isSnapshotNode$1(node)) return add;
|
|
11857
|
+
const prepared = withoutRecorderHost(replaceUnsupportedSurfaces(node, onUnsupported));
|
|
11858
|
+
return prepared === null ? OMIT_RECORDER_HOST : {
|
|
11859
|
+
...add,
|
|
11860
|
+
node: prepared
|
|
11861
|
+
};
|
|
11862
|
+
};
|
|
11863
|
+
const replaceMutation = (event, onUnsupported) => {
|
|
11864
|
+
const data = event["data"];
|
|
11865
|
+
if (!isObject$1(data) || data["source"] !== MUTATION) return event;
|
|
11866
|
+
const adds = data["adds"];
|
|
11867
|
+
if (!isUnknownArray$1(adds)) return event;
|
|
11868
|
+
return {
|
|
11869
|
+
...event,
|
|
11870
|
+
data: {
|
|
11871
|
+
...data,
|
|
11872
|
+
adds: adds.flatMap((add) => {
|
|
11873
|
+
const prepared = replaceAddedNode(add, onUnsupported);
|
|
11874
|
+
return prepared === OMIT_RECORDER_HOST ? [] : [prepared];
|
|
11875
|
+
})
|
|
11876
|
+
}
|
|
11877
|
+
};
|
|
11878
|
+
};
|
|
11879
|
+
/** @justified intent Keep fallbacks honest and omit recorder-owned UI. */
|
|
11880
|
+
const replaceUnsupportedSurfacesInEvent = (event, onUnsupported) => {
|
|
11881
|
+
if (!isObject$1(event)) return event;
|
|
11882
|
+
if (event["type"] === FULL_SNAPSHOT$1) return replaceFullSnapshot(event, onUnsupported);
|
|
11883
|
+
if (event["type"] === INCREMENTAL_SNAPSHOT$1) return replaceMutation(event, onUnsupported);
|
|
11884
|
+
return event;
|
|
11885
|
+
};
|
|
11886
|
+
//#endregion
|
|
11887
|
+
//#region ../contract/src/recording/measured-placeholders.lib.ts
|
|
11888
|
+
const ELEMENT$2 = 2;
|
|
11889
|
+
const isObject = (value) => typeof value === "object" && value !== null;
|
|
11890
|
+
/**
|
|
11891
|
+
* Whether the placeholder can take this axis from the element's own styles: a percentage or a
|
|
11892
|
+
* `calc()` applies to the placeholder as it did to the element, and follows its container. Any
|
|
11893
|
+
* other size came from the element's attributes or from the browser's default size for it, which
|
|
11894
|
+
* an ordinary box does not have, or is a length that the measurement repeats.
|
|
11895
|
+
*/
|
|
11896
|
+
const isSizedByStyles = (live, property) => {
|
|
11897
|
+
const styleMap = Reflect.get(live, "computedStyleMap");
|
|
11898
|
+
if (typeof styleMap !== "function") return false;
|
|
11899
|
+
try {
|
|
11900
|
+
const map = Reflect.apply(styleMap, live, []);
|
|
11901
|
+
if (!isObject(map)) return false;
|
|
11902
|
+
const read = Reflect.get(map, "get");
|
|
11903
|
+
if (typeof read !== "function") return false;
|
|
11904
|
+
const value = Reflect.apply(read, map, [property]);
|
|
11905
|
+
if (!isObject(value)) return false;
|
|
11906
|
+
const unit = Reflect.get(value, "unit");
|
|
11907
|
+
if (typeof unit === "string") return unit === "percent";
|
|
11908
|
+
return typeof Reflect.get(value, "operator") === "string";
|
|
11909
|
+
} catch {
|
|
11910
|
+
return false;
|
|
11911
|
+
}
|
|
11912
|
+
};
|
|
11913
|
+
const measuredBox = (live) => {
|
|
11914
|
+
if (!isObject(live)) return null;
|
|
11915
|
+
const measure = Reflect.get(live, "getBoundingClientRect");
|
|
11916
|
+
if (typeof measure !== "function") return null;
|
|
11917
|
+
const box = Reflect.apply(measure, live, []);
|
|
11918
|
+
if (!isObject(box)) return null;
|
|
11919
|
+
const width = Reflect.get(box, "width");
|
|
11920
|
+
const height = Reflect.get(box, "height");
|
|
11921
|
+
return typeof width === "number" && typeof height === "number" ? {
|
|
11922
|
+
width,
|
|
11923
|
+
height
|
|
11924
|
+
} : null;
|
|
11925
|
+
};
|
|
11926
|
+
/**
|
|
11927
|
+
* The size of a surface the capture turns into a placeholder, measured where it stands. A
|
|
11928
|
+
* placeholder is an ordinary box, so a surface sized by its attributes or by the browser's default
|
|
11929
|
+
* size would otherwise have no size. The replay applies `rr_width` and `rr_height` as the box's
|
|
11930
|
+
* width and height, as it does for a surface the recorder blocks. An embedded page keeps its own
|
|
11931
|
+
* element and so its size; an audio player is blocked, and so measured, already.
|
|
11932
|
+
*/
|
|
11933
|
+
const placeholderSizeOf = (node, live) => {
|
|
11934
|
+
const attributes = node.attributes ?? {};
|
|
11935
|
+
if (node.type !== ELEMENT$2 || node.tagName === void 0 || ["iframe", "audio"].includes(node.tagName) || typeof attributes["rr_width"] === "string" || unsupportedSurfaceLabel(node.tagName, attributes) === null) return {};
|
|
11936
|
+
const box = measuredBox(live);
|
|
11937
|
+
if (box === null || !isObject(live)) return {};
|
|
11938
|
+
return {
|
|
11939
|
+
...!isSizedByStyles(live, "width") && { rr_width: `${String(box.width)}px` },
|
|
11940
|
+
...!isSizedByStyles(live, "height") && { rr_height: `${String(box.height)}px` }
|
|
11941
|
+
};
|
|
11942
|
+
};
|
|
11943
|
+
/** The snapshot with the measured size of each surface that will become a placeholder. */
|
|
11944
|
+
const withMeasuredPlaceholders = (node, nodeForId) => {
|
|
11945
|
+
const size = typeof node.id === "number" ? placeholderSizeOf(node, nodeForId(node.id)) : {};
|
|
11946
|
+
const childNodes = node.childNodes?.map((child) => withMeasuredPlaceholders(child, nodeForId));
|
|
11947
|
+
const isSized = Object.keys(size).length > 0;
|
|
11948
|
+
if (!isSized && childNodes === void 0) return node;
|
|
11949
|
+
return {
|
|
11950
|
+
...node,
|
|
11951
|
+
...isSized && { attributes: {
|
|
11952
|
+
...node.attributes,
|
|
11953
|
+
...size
|
|
11954
|
+
} },
|
|
11955
|
+
...childNodes !== void 0 && { childNodes }
|
|
11956
|
+
};
|
|
11957
|
+
};
|
|
11958
|
+
//#endregion
|
|
11959
|
+
//#region ../contract/src/recording/page-asset-event-shapes.lib.ts
|
|
11960
|
+
const FULL_SNAPSHOT = 2;
|
|
11961
|
+
const INCREMENTAL_SNAPSHOT = 3;
|
|
11962
|
+
const isUnknownArray = (value) => Array.isArray(value);
|
|
11963
|
+
const recordIn$1 = (value) => typeof value === "object" && value !== null ? { ...value } : null;
|
|
11964
|
+
const unknownArrayIn = (value) => {
|
|
11965
|
+
if (!isUnknownArray(value)) return [];
|
|
11966
|
+
return [...value];
|
|
11967
|
+
};
|
|
11968
|
+
const isSnapshotNode = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "type") === "number";
|
|
11969
|
+
const snapshotNodeIn = (value) => isSnapshotNode(value) ? value : null;
|
|
11970
|
+
const eventPartIn = (event, type) => {
|
|
11971
|
+
const outer = recordIn$1(event);
|
|
11972
|
+
if (outer === null || Reflect.get(outer, "type") !== type) return null;
|
|
11973
|
+
const data = recordIn$1(Reflect.get(outer, "data"));
|
|
11974
|
+
return data === null ? null : {
|
|
11975
|
+
original: event,
|
|
11976
|
+
event: outer,
|
|
11027
11977
|
data
|
|
11028
11978
|
};
|
|
11029
11979
|
};
|
|
11030
11980
|
const fullSnapshotInEvent = (event) => {
|
|
11031
|
-
const part = eventPartIn(event, FULL_SNAPSHOT
|
|
11981
|
+
const part = eventPartIn(event, FULL_SNAPSHOT);
|
|
11032
11982
|
if (part === null) return null;
|
|
11033
11983
|
const node = snapshotNodeIn(Reflect.get(part.data, "node"));
|
|
11034
11984
|
return node === null ? null : {
|
|
@@ -11037,7 +11987,7 @@ progression: object$1({
|
|
|
11037
11987
|
};
|
|
11038
11988
|
};
|
|
11039
11989
|
const incrementalIn = (event) => {
|
|
11040
|
-
const part = eventPartIn(event, INCREMENTAL_SNAPSHOT
|
|
11990
|
+
const part = eventPartIn(event, INCREMENTAL_SNAPSHOT);
|
|
11041
11991
|
if (part === null) return null;
|
|
11042
11992
|
const source = Reflect.get(part.data, "source");
|
|
11043
11993
|
return typeof source === "number" ? {
|
|
@@ -11240,6 +12190,7 @@ progression: object$1({
|
|
|
11240
12190
|
const isSourceSet = name === "srcset" || name === "imagesrcset";
|
|
11241
12191
|
if (attributes[UNSUPPORTED_PLACEHOLDER] !== void 0 && (isSourceSet || PLAIN_URL_ATTRIBUTES.has(name))) return [];
|
|
11242
12192
|
if (isSourceSet) return srcsetReferences(value);
|
|
12193
|
+
if (capturedMediaPictureAttribute(tagName, attributes) === name) return whole(value);
|
|
11243
12194
|
if (tagName === "canvas" && (name === "rr_dataURL" || name === "data-enhance-canvas-source")) return whole(value);
|
|
11244
12195
|
if (PLAIN_URL_ATTRIBUTES.has(name)) return INERT_SOURCE_TAGS.has(tagName) ? [] : whole(value);
|
|
11245
12196
|
if (name === "href" || name === "xlink:href") {
|
|
@@ -11860,259 +12811,72 @@ missingAssetCount: number$2().int().min(0) });
|
|
|
11860
12811
|
/** The first byte here is mid-event and needs the preceding range. */
|
|
11861
12812
|
continues: boolean$1()
|
|
11862
12813
|
});
|
|
11863
|
-
const recordingChunkManifestSchema = discriminatedUnion$1("state", [recordingChunkManifestBaseSchema.extend({
|
|
11864
|
-
state: literal$1("available"),
|
|
11865
|
-
download: signedDownloadSchema
|
|
11866
|
-
}), recordingChunkManifestBaseSchema.extend({ state: literal$1("missing") })]);
|
|
11867
|
-
const recordingAudioManifestBaseSchema = object$1({
|
|
11868
|
-
seq: number$2().int().min(0),
|
|
11869
|
-
firstMs: number$2().int().min(0),
|
|
11870
|
-
lastMs: number$2().int().min(0),
|
|
11871
|
-
epoch: number$2().int().min(0),
|
|
11872
|
-
startsEpoch: boolean$1()
|
|
11873
|
-
});
|
|
11874
|
-
const recordingAudioManifestSchema = discriminatedUnion$1("state", [recordingAudioManifestBaseSchema.extend({
|
|
11875
|
-
state: literal$1("available"),
|
|
11876
|
-
download: signedDownloadSchema
|
|
11877
|
-
}), recordingAudioManifestBaseSchema.extend({ state: literal$1("missing") })]);
|
|
11878
|
-
object$1({
|
|
11879
|
-
recordingId: uuid$1(),
|
|
11880
|
-
durationMs: number$2().int().min(0),
|
|
11881
|
-
viewport: viewportSchema,
|
|
11882
|
-
/** The page it was taken from. A replay resolves its mirrored assets against this. */
|
|
11883
|
-
sourceUrl: string$1(),
|
|
11884
|
-
interrupted: boolean$1(),
|
|
11885
|
-
integrity: recordingIntegritySchema,
|
|
11886
|
-
chunks: array$1(recordingChunkManifestSchema),
|
|
11887
|
-
/** Null when the walkthrough has no voice on it, which the player draws differently. */
|
|
11888
|
-
audio: object$1({
|
|
11889
|
-
mimeType: string$1(),
|
|
11890
|
-
chunks: array$1(recordingAudioManifestSchema)
|
|
11891
|
-
}).nullable(),
|
|
11892
|
-
/** Our copy of what the page loaded, by the address the page used. Empty is a real answer. */
|
|
11893
|
-
assets: array$1(object$1({
|
|
11894
|
-
url: string$1(),
|
|
11895
|
-
contentType: string$1(),
|
|
11896
|
-
/** Stable identity; it can safely live in cached rrweb events and frozen screens. */
|
|
11897
|
-
path: string$1().startsWith("/v1/recording-assets/")
|
|
11898
|
-
})),
|
|
11899
|
-
/** How much of the page we could not fetch. A replay says so rather than rendering short. */
|
|
11900
|
-
missingAssetCount: number$2().int().min(0),
|
|
11901
|
-
missingAssetUrls: array$1(string$1()).optional()
|
|
11902
|
-
});
|
|
11903
|
-
const refreshRecordingUploadInputSchema = object$1({
|
|
11904
|
-
recordingId: uuid$1(),
|
|
11905
|
-
track: recordingTrackSchema,
|
|
11906
|
-
index: number$2().int().min(0)
|
|
11907
|
-
});
|
|
11908
|
-
object$1({ upload: signedUploadSchema });
|
|
11909
|
-
refreshRecordingUploadInputSchema.extend({ etag: string$1().min(1).max(200) });
|
|
11910
|
-
object$1({ integrity: recordingIntegritySchema });
|
|
11911
|
-
object$1({ canvasId: uuid$1() });
|
|
11912
|
-
cappedSchema(recordingSummarySchema).extend({
|
|
11913
|
-
/** Completed recordings left out because their facts are missing; the API logs each by ID. */
|
|
11914
|
-
unreadableCount: number$2().int().min(0) });
|
|
11915
|
-
object$1({ recordingId: uuid$1() });
|
|
11916
|
-
object$1({
|
|
11917
|
-
recordingId: uuid$1(),
|
|
11918
|
-
discarded: literal$1(true)
|
|
11919
|
-
});
|
|
11920
|
-
object$1({
|
|
11921
|
-
canvasId: uuid$1(),
|
|
11922
|
-
recordingId: uuid$1()
|
|
11923
|
-
});
|
|
11924
|
-
object$1({
|
|
11925
|
-
recordingId: uuid$1(),
|
|
11926
|
-
/** Screens survive with their provenance nulled. That is what makes iteration safe. */
|
|
11927
|
-
detachedScreenCount: number$2().int().min(0)
|
|
11928
|
-
});
|
|
11929
|
-
[`[data-enhance-unsupported]:not([data-enhance-unsupported-hidden]):not([style*="display: none"]) {
|
|
11930
|
-
align-items: center !important;
|
|
11931
|
-
background-color: #f7f7f8 !important;
|
|
11932
|
-
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;
|
|
11933
|
-
border: 1px solid #c7c7cc !important;
|
|
11934
|
-
box-sizing: border-box !important;
|
|
11935
|
-
color: #4f4f55 !important;
|
|
11936
|
-
display: flex !important;
|
|
11937
|
-
font: 500 14px/1.4 Inter, ui-sans-serif, system-ui, sans-serif !important;
|
|
11938
|
-
justify-content: center !important;
|
|
11939
|
-
overflow: hidden !important;
|
|
11940
|
-
text-align: center !important;
|
|
11941
|
-
}`, `[data-enhance-unsupported-hidden], [data-enhance-unsupported][style*="display: none"] {
|
|
11942
|
-
display: none !important;
|
|
11943
|
-
}`].join("\n");
|
|
11944
|
-
//#endregion
|
|
11945
|
-
//#region ../contract/src/recording/unsupported-surfaces.lib.ts
|
|
11946
|
-
const ELEMENT = 2;
|
|
11947
|
-
const FULL_SNAPSHOT = 2;
|
|
11948
|
-
const INCREMENTAL_SNAPSHOT = 3;
|
|
11949
|
-
const MUTATION = 0;
|
|
11950
|
-
const OMIT_RECORDER_HOST = Symbol("omit-recorder-host");
|
|
11951
|
-
const isObject = (value) => typeof value === "object" && value !== null;
|
|
11952
|
-
const isUnknownArray = (value) => Array.isArray(value);
|
|
11953
|
-
const isSnapshotNode = (value) => isObject(value) && typeof value["type"] === "number";
|
|
11954
|
-
const withoutRecorderHost = (node) => {
|
|
11955
|
-
if (node.type === ELEMENT && node.tagName === "enhance3-recorder") return null;
|
|
11956
|
-
if (node.childNodes === void 0) return node;
|
|
11957
|
-
return {
|
|
11958
|
-
...node,
|
|
11959
|
-
childNodes: node.childNodes.flatMap((child) => {
|
|
11960
|
-
const kept = withoutRecorderHost(child);
|
|
11961
|
-
return kept === null ? [] : [kept];
|
|
11962
|
-
})
|
|
11963
|
-
};
|
|
11964
|
-
};
|
|
11965
|
-
const iframeSurfaceLabel = (attributes) => {
|
|
11966
|
-
const recordedSource = attributes["rr_src"];
|
|
11967
|
-
const isExplicitlyHidden = attributes["aria-hidden"] === "true" || attributes["width"] === "0" && attributes["height"] === "0";
|
|
11968
|
-
if (typeof recordedSource === "string" && !isExplicitlyHidden) return attributes["data-enhance-frame-unloaded"] === "" ? "Embedded content not loaded" : "Embedded content not supported";
|
|
11969
|
-
const source = attributes["src"] ?? attributes["srcdoc"];
|
|
11970
|
-
return typeof source === "string" && source.startsWith("blob:") ? "Embedded content not supported" : null;
|
|
11971
|
-
};
|
|
11972
|
-
const unsupportedSurfaceLabel = (tagName, attributes) => {
|
|
11973
|
-
switch (tagName) {
|
|
11974
|
-
case "canvas": return capturedCanvasSourceIn(attributes) === null ? "Canvas not supported" : null;
|
|
11975
|
-
case "video": return "Video not supported";
|
|
11976
|
-
case "object":
|
|
11977
|
-
case "embed": return "Embedded content not supported";
|
|
11978
|
-
case "img":
|
|
11979
|
-
case "image": {
|
|
11980
|
-
const source = attributes["src"] ?? attributes["href"] ?? attributes["xlink:href"];
|
|
11981
|
-
return typeof source === "string" && source.startsWith("blob:") ? "Image not supported" : null;
|
|
11982
|
-
}
|
|
11983
|
-
case "iframe": return iframeSurfaceLabel(attributes);
|
|
11984
|
-
case void 0: return null;
|
|
11985
|
-
default: return null;
|
|
11986
|
-
}
|
|
11987
|
-
};
|
|
11988
|
-
const labelFor = (node) => {
|
|
11989
|
-
if (node.type !== ELEMENT) return null;
|
|
11990
|
-
const attributes = node.attributes ?? {};
|
|
11991
|
-
const placeholder = attributes["data-enhance-unsupported"];
|
|
11992
|
-
if (typeof placeholder === "string" && node.tagName === "div") return placeholder;
|
|
11993
|
-
if (node.tagName === "iframe" && attributes["data-enhance-frame-unloaded"] === "") return iframeSurfaceLabel(attributes);
|
|
11994
|
-
const className = attributes["class"];
|
|
11995
|
-
const wasUnsupported = typeof className === "string" && className.split(/\s+/u).includes("enhance3-unsupported-surface");
|
|
11996
|
-
const wasBlocked = typeof attributes["rr_width"] === "string" && typeof attributes["rr_height"] === "string";
|
|
11997
|
-
if ((wasUnsupported || wasBlocked) && node.tagName === "iframe") return "Embedded content not supported";
|
|
11998
|
-
if ((wasUnsupported || wasBlocked) && (node.tagName === "img" || node.tagName === "image")) return "Image not supported";
|
|
11999
|
-
return unsupportedSurfaceLabel(node.tagName, attributes);
|
|
12000
|
-
};
|
|
12001
|
-
const placeholderAttributes = (attributes) => Object.fromEntries(Object.entries(attributes).flatMap(([name, value]) => {
|
|
12002
|
-
if (name.startsWith("rr_media")) return [];
|
|
12003
|
-
if (name !== "class" || typeof value !== "string") return [[name, value]];
|
|
12004
|
-
const cleaned = value.split(/\s+/u).filter((part) => part.length > 0 && part !== "enhance3-unsupported-surface").join(" ");
|
|
12005
|
-
return cleaned.length === 0 ? [] : [[name, cleaned]];
|
|
12006
|
-
}));
|
|
12007
|
-
const withoutFrameNavigation = (attributes) => Object.fromEntries(Object.entries(attributes).filter(([name]) => name !== "src" && name !== "rr_src" && name !== "srcdoc"));
|
|
12008
|
-
const wasDisplayNone = (attributes) => {
|
|
12009
|
-
const style = attributes["style"];
|
|
12010
|
-
return typeof style === "string" && /(?:^|;)\s*display\s*:\s*none(?:\s*!important)?\s*(?:;|$)/iu.test(style);
|
|
12011
|
-
};
|
|
12012
|
-
const wasZeroSizedBlock = (attributes) => {
|
|
12013
|
-
const width = attributes["rr_width"];
|
|
12014
|
-
const height = attributes["rr_height"];
|
|
12015
|
-
return typeof width === "string" && typeof height === "string" && Number(width.replace(/px$/u, "")) === 0 && Number(height.replace(/px$/u, "")) === 0;
|
|
12016
|
-
};
|
|
12017
|
-
const isExplicitlyHiddenFrame = (attributes) => attributes["aria-hidden"] === "true" || attributes["width"] === "0" && attributes["height"] === "0";
|
|
12018
|
-
const isUncapturedNavigatedFrame = (node) => {
|
|
12019
|
-
if (node.tagName !== "iframe") return false;
|
|
12020
|
-
const attributes = node.attributes ?? {};
|
|
12021
|
-
if (isExplicitlyHiddenFrame(attributes)) return false;
|
|
12022
|
-
const source = attributes["src"];
|
|
12023
|
-
if (!(typeof attributes["srcdoc"] !== "string" && typeof source === "string" && source !== "" && source !== "about:blank")) return false;
|
|
12024
|
-
return node.childNodes?.some((child) => child.type === 0) !== true;
|
|
12025
|
-
};
|
|
12026
|
-
/**
|
|
12027
|
-
* The same rrweb node, except a non-serialisable surface becomes an ordinary div. rrweb's block
|
|
12028
|
-
* selector supplies `rr_width` and `rr_height`; keeping them makes the replacement occupy the
|
|
12029
|
-
* exact rectangle the original did without keeping pixels that cannot become primitives later.
|
|
12030
|
-
*/
|
|
12031
|
-
const replaceUnsupportedSurfaces = (node, onUnsupported) => {
|
|
12032
|
-
const label = labelFor(node) ?? (isUncapturedNavigatedFrame(node) ? "Embedded content not supported" : null);
|
|
12033
|
-
if (label !== null) {
|
|
12034
|
-
onUnsupported?.(label);
|
|
12035
|
-
const attributes = placeholderAttributes(node.attributes ?? {});
|
|
12036
|
-
if (node.tagName === "iframe") return {
|
|
12037
|
-
...node,
|
|
12038
|
-
attributes: {
|
|
12039
|
-
...withoutFrameNavigation(attributes),
|
|
12040
|
-
"aria-hidden": "true",
|
|
12041
|
-
"data-enhance-unsupported": label,
|
|
12042
|
-
...(wasDisplayNone(attributes) || wasZeroSizedBlock(attributes)) && { "data-enhance-unsupported-hidden": "" },
|
|
12043
|
-
role: "img"
|
|
12044
|
-
},
|
|
12045
|
-
childNodes: []
|
|
12046
|
-
};
|
|
12047
|
-
return {
|
|
12048
|
-
...node,
|
|
12049
|
-
tagName: "div",
|
|
12050
|
-
attributes: {
|
|
12051
|
-
...attributes,
|
|
12052
|
-
"aria-hidden": "true",
|
|
12053
|
-
"data-enhance-unsupported": label,
|
|
12054
|
-
role: "img"
|
|
12055
|
-
},
|
|
12056
|
-
childNodes: []
|
|
12057
|
-
};
|
|
12058
|
-
}
|
|
12059
|
-
if (node.type === ELEMENT && node.tagName === "script") return {
|
|
12060
|
-
...node,
|
|
12061
|
-
childNodes: []
|
|
12062
|
-
};
|
|
12063
|
-
return node.childNodes === void 0 ? node : {
|
|
12064
|
-
...node,
|
|
12065
|
-
childNodes: node.childNodes.map((child) => replaceUnsupportedSurfaces(child, onUnsupported))
|
|
12066
|
-
};
|
|
12067
|
-
};
|
|
12068
|
-
const replaceFullSnapshot = (event, onUnsupported) => {
|
|
12069
|
-
const data = event["data"];
|
|
12070
|
-
if (!isObject(data)) return event;
|
|
12071
|
-
const node = data["node"];
|
|
12072
|
-
if (!isSnapshotNode(node)) return event;
|
|
12073
|
-
const prepared = withoutRecorderHost(replaceUnsupportedSurfaces(node, onUnsupported));
|
|
12074
|
-
if (prepared === null) return event;
|
|
12075
|
-
return {
|
|
12076
|
-
...event,
|
|
12077
|
-
data: {
|
|
12078
|
-
...data,
|
|
12079
|
-
node: prepared
|
|
12080
|
-
}
|
|
12081
|
-
};
|
|
12082
|
-
};
|
|
12083
|
-
const replaceAddedNode = (add, onUnsupported) => {
|
|
12084
|
-
if (!isObject(add)) return add;
|
|
12085
|
-
const node = add["node"];
|
|
12086
|
-
if (!isSnapshotNode(node)) return add;
|
|
12087
|
-
const prepared = withoutRecorderHost(replaceUnsupportedSurfaces(node, onUnsupported));
|
|
12088
|
-
return prepared === null ? OMIT_RECORDER_HOST : {
|
|
12089
|
-
...add,
|
|
12090
|
-
node: prepared
|
|
12091
|
-
};
|
|
12092
|
-
};
|
|
12093
|
-
const replaceMutation = (event, onUnsupported) => {
|
|
12094
|
-
const data = event["data"];
|
|
12095
|
-
if (!isObject(data) || data["source"] !== MUTATION) return event;
|
|
12096
|
-
const adds = data["adds"];
|
|
12097
|
-
if (!isUnknownArray(adds)) return event;
|
|
12098
|
-
return {
|
|
12099
|
-
...event,
|
|
12100
|
-
data: {
|
|
12101
|
-
...data,
|
|
12102
|
-
adds: adds.flatMap((add) => {
|
|
12103
|
-
const prepared = replaceAddedNode(add, onUnsupported);
|
|
12104
|
-
return prepared === OMIT_RECORDER_HOST ? [] : [prepared];
|
|
12105
|
-
})
|
|
12106
|
-
}
|
|
12107
|
-
};
|
|
12108
|
-
};
|
|
12109
|
-
/** @justified intent Keep fallbacks honest and omit recorder-owned UI. */
|
|
12110
|
-
const replaceUnsupportedSurfacesInEvent = (event, onUnsupported) => {
|
|
12111
|
-
if (!isObject(event)) return event;
|
|
12112
|
-
if (event["type"] === FULL_SNAPSHOT) return replaceFullSnapshot(event, onUnsupported);
|
|
12113
|
-
if (event["type"] === INCREMENTAL_SNAPSHOT) return replaceMutation(event, onUnsupported);
|
|
12114
|
-
return event;
|
|
12115
|
-
};
|
|
12814
|
+
const recordingChunkManifestSchema = discriminatedUnion$1("state", [recordingChunkManifestBaseSchema.extend({
|
|
12815
|
+
state: literal$1("available"),
|
|
12816
|
+
download: signedDownloadSchema
|
|
12817
|
+
}), recordingChunkManifestBaseSchema.extend({ state: literal$1("missing") })]);
|
|
12818
|
+
const recordingAudioManifestBaseSchema = object$1({
|
|
12819
|
+
seq: number$2().int().min(0),
|
|
12820
|
+
firstMs: number$2().int().min(0),
|
|
12821
|
+
lastMs: number$2().int().min(0),
|
|
12822
|
+
epoch: number$2().int().min(0),
|
|
12823
|
+
startsEpoch: boolean$1()
|
|
12824
|
+
});
|
|
12825
|
+
const recordingAudioManifestSchema = discriminatedUnion$1("state", [recordingAudioManifestBaseSchema.extend({
|
|
12826
|
+
state: literal$1("available"),
|
|
12827
|
+
download: signedDownloadSchema
|
|
12828
|
+
}), recordingAudioManifestBaseSchema.extend({ state: literal$1("missing") })]);
|
|
12829
|
+
object$1({
|
|
12830
|
+
recordingId: uuid$1(),
|
|
12831
|
+
durationMs: number$2().int().min(0),
|
|
12832
|
+
viewport: viewportSchema,
|
|
12833
|
+
/** The page it was taken from. A replay resolves its mirrored assets against this. */
|
|
12834
|
+
sourceUrl: string$1(),
|
|
12835
|
+
interrupted: boolean$1(),
|
|
12836
|
+
integrity: recordingIntegritySchema,
|
|
12837
|
+
chunks: array$1(recordingChunkManifestSchema),
|
|
12838
|
+
/** Null when the walkthrough has no voice on it, which the player draws differently. */
|
|
12839
|
+
audio: object$1({
|
|
12840
|
+
mimeType: string$1(),
|
|
12841
|
+
chunks: array$1(recordingAudioManifestSchema)
|
|
12842
|
+
}).nullable(),
|
|
12843
|
+
/** Our copy of what the page loaded, by the address the page used. Empty is a real answer. */
|
|
12844
|
+
assets: array$1(object$1({
|
|
12845
|
+
url: string$1(),
|
|
12846
|
+
contentType: string$1(),
|
|
12847
|
+
/** Stable identity; it can safely live in cached rrweb events and frozen screens. */
|
|
12848
|
+
path: string$1().startsWith("/v1/recording-assets/")
|
|
12849
|
+
})),
|
|
12850
|
+
/** How much of the page we could not fetch. A replay says so rather than rendering short. */
|
|
12851
|
+
missingAssetCount: number$2().int().min(0),
|
|
12852
|
+
missingAssetUrls: array$1(string$1()).optional()
|
|
12853
|
+
});
|
|
12854
|
+
const refreshRecordingUploadInputSchema = object$1({
|
|
12855
|
+
recordingId: uuid$1(),
|
|
12856
|
+
track: recordingTrackSchema,
|
|
12857
|
+
index: number$2().int().min(0)
|
|
12858
|
+
});
|
|
12859
|
+
object$1({ upload: signedUploadSchema });
|
|
12860
|
+
refreshRecordingUploadInputSchema.extend({ etag: string$1().min(1).max(200) });
|
|
12861
|
+
object$1({ integrity: recordingIntegritySchema });
|
|
12862
|
+
object$1({ canvasId: uuid$1() });
|
|
12863
|
+
cappedSchema(recordingSummarySchema).extend({
|
|
12864
|
+
/** Completed recordings left out because their facts are missing; the API logs each by ID. */
|
|
12865
|
+
unreadableCount: number$2().int().min(0) });
|
|
12866
|
+
object$1({ recordingId: uuid$1() });
|
|
12867
|
+
object$1({
|
|
12868
|
+
recordingId: uuid$1(),
|
|
12869
|
+
discarded: literal$1(true)
|
|
12870
|
+
});
|
|
12871
|
+
object$1({
|
|
12872
|
+
canvasId: uuid$1(),
|
|
12873
|
+
recordingId: uuid$1()
|
|
12874
|
+
});
|
|
12875
|
+
object$1({
|
|
12876
|
+
recordingId: uuid$1(),
|
|
12877
|
+
/** Screens survive with their provenance nulled. That is what makes iteration safe. */
|
|
12878
|
+
detachedScreenCount: number$2().int().min(0)
|
|
12879
|
+
});
|
|
12116
12880
|
object$1({
|
|
12117
12881
|
/**
|
|
12118
12882
|
* Client-minted, once per capture attempt. A retry is the same screen; a re-capture at the
|
|
@@ -12435,6 +13199,7 @@ unreadableCount: number$2().int().min(0) });
|
|
|
12435
13199
|
"clipboard-unavailable",
|
|
12436
13200
|
"clipboard-image-pending",
|
|
12437
13201
|
"clipboard-image-unavailable",
|
|
13202
|
+
"paste-content-refused",
|
|
12438
13203
|
"edit-target-unsupported",
|
|
12439
13204
|
"edit-result-invalid",
|
|
12440
13205
|
"react-hook-order",
|
|
@@ -12472,6 +13237,7 @@ unreadableCount: number$2().int().min(0) });
|
|
|
12472
13237
|
subsystem: _enum$1([
|
|
12473
13238
|
"menu",
|
|
12474
13239
|
"menu-picture",
|
|
13240
|
+
"arrival-cue",
|
|
12475
13241
|
"unknown"
|
|
12476
13242
|
]).optional(),
|
|
12477
13243
|
repeats: count$1.optional(),
|
|
@@ -12546,7 +13312,18 @@ unreadableCount: number$2().int().min(0) });
|
|
|
12546
13312
|
"whole-value-text",
|
|
12547
13313
|
"retrying",
|
|
12548
13314
|
"recovery",
|
|
12549
|
-
"trace"
|
|
13315
|
+
"trace",
|
|
13316
|
+
"update-required"
|
|
13317
|
+
];
|
|
13318
|
+
/** How a failed document read was answered, on the report of one worth a look. */
|
|
13319
|
+
const CANVAS_SYNC_READ_OUTCOMES = [
|
|
13320
|
+
"transient",
|
|
13321
|
+
"no-edit-access",
|
|
13322
|
+
"restored",
|
|
13323
|
+
"replan",
|
|
13324
|
+
"refused",
|
|
13325
|
+
"update-required",
|
|
13326
|
+
"fault"
|
|
12550
13327
|
];
|
|
12551
13328
|
const CANVAS_SYNC_DETAILS = [
|
|
12552
13329
|
...CLIENT_SAVE_ISSUES,
|
|
@@ -12583,7 +13360,8 @@ unreadableCount: number$2().int().min(0) });
|
|
|
12583
13360
|
"view-only",
|
|
12584
13361
|
"sign-in",
|
|
12585
13362
|
"gone",
|
|
12586
|
-
"restored"
|
|
13363
|
+
"restored",
|
|
13364
|
+
"update-required"
|
|
12587
13365
|
];
|
|
12588
13366
|
/** Whether a recovery state began in this visit or was reopened from the browser copy. */
|
|
12589
13367
|
const CANVAS_SYNC_EPISODES = ["new", "reopened"];
|
|
@@ -12625,6 +13403,7 @@ unreadableCount: number$2().int().min(0) });
|
|
|
12625
13403
|
"refused",
|
|
12626
13404
|
"copy-refused",
|
|
12627
13405
|
"copy-preview",
|
|
13406
|
+
"update-required",
|
|
12628
13407
|
"unknown"
|
|
12629
13408
|
];
|
|
12630
13409
|
const CANVAS_SAVE_SEVERITIES = [
|
|
@@ -12648,7 +13427,8 @@ unreadableCount: number$2().int().min(0) });
|
|
|
12648
13427
|
"retry-upload",
|
|
12649
13428
|
"choose-file",
|
|
12650
13429
|
"remove-screen",
|
|
12651
|
-
"go-to-canvases"
|
|
13430
|
+
"go-to-canvases",
|
|
13431
|
+
"reload"
|
|
12652
13432
|
];
|
|
12653
13433
|
const CANVAS_SAVE_OUTCOMES = [
|
|
12654
13434
|
"saved",
|
|
@@ -12742,6 +13522,7 @@ unreadableCount: number$2().int().min(0) });
|
|
|
12742
13522
|
durationMs: number$2().int().nonnegative(),
|
|
12743
13523
|
pendingChanges: number$2().int().nonnegative(),
|
|
12744
13524
|
reason: _enum$1(CANVAS_SYNC_DETAILS).optional(),
|
|
13525
|
+
readOutcome: _enum$1(CANVAS_SYNC_READ_OUTCOMES).optional(),
|
|
12745
13526
|
status: _enum$1(CANVAS_SYNC_REPORT_STATUSES).optional(),
|
|
12746
13527
|
episode: _enum$1(CANVAS_SYNC_EPISODES).optional(),
|
|
12747
13528
|
trace: canvasSaveTraceSchema.optional()
|
|
@@ -12995,6 +13776,419 @@ unreadableCount: number$2().int().min(0) });
|
|
|
12995
13776
|
})
|
|
12996
13777
|
]);
|
|
12997
13778
|
//#endregion
|
|
13779
|
+
//#region ../capture-browser/src/captured-local-fonts.lib.ts
|
|
13780
|
+
const LOCAL_FONT_ADDRESS = "https://local-fonts.invalid/";
|
|
13781
|
+
const addressOf = (postscriptName) => `${LOCAL_FONT_ADDRESS}${encodeURIComponent(postscriptName)}`;
|
|
13782
|
+
/** Whether an address is one a capture gave an installed font, which no server answers. */
|
|
13783
|
+
const isLocalFontAddress = (url) => url.startsWith(LOCAL_FONT_ADDRESS);
|
|
13784
|
+
/** The CSS weight each style name of an installed face stands for; the first match wins. */
|
|
13785
|
+
const WEIGHT_NAMES = {
|
|
13786
|
+
"100": /thin|hairline/iu,
|
|
13787
|
+
"200": /extra\s*light|ultra\s*light/iu,
|
|
13788
|
+
"600": /semi\s*bold|demi\s*bold/iu,
|
|
13789
|
+
"800": /extra\s*bold|ultra\s*bold/iu,
|
|
13790
|
+
"900": /black|heavy/iu,
|
|
13791
|
+
"300": /light/iu,
|
|
13792
|
+
"500": /medium/iu,
|
|
13793
|
+
"700": /bold/iu
|
|
13794
|
+
};
|
|
13795
|
+
const WEIGHT_ORDER = [
|
|
13796
|
+
"100",
|
|
13797
|
+
"200",
|
|
13798
|
+
"600",
|
|
13799
|
+
"800",
|
|
13800
|
+
"900",
|
|
13801
|
+
"300",
|
|
13802
|
+
"500",
|
|
13803
|
+
"700"
|
|
13804
|
+
];
|
|
13805
|
+
const REGULAR_WEIGHT = 400;
|
|
13806
|
+
const OPENTYPE_CFF = "OTTO";
|
|
13807
|
+
const SIGNATURE_LENGTH = 4;
|
|
13808
|
+
const weightOf = (style) => Number(WEIGHT_ORDER.find((weight) => WEIGHT_NAMES[weight]?.test(style) === true) ?? REGULAR_WEIGHT);
|
|
13809
|
+
const isFontData = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "family") === "string" && typeof Reflect.get(value, "style") === "string" && typeof Reflect.get(value, "postscriptName") === "string" && typeof Reflect.get(value, "blob") === "function";
|
|
13810
|
+
const localFontAccessOf = async (view) => {
|
|
13811
|
+
if (typeof Reflect.get(view, "queryLocalFonts") !== "function") return "none";
|
|
13812
|
+
try {
|
|
13813
|
+
const permissions = Reflect.get(view.navigator, "permissions");
|
|
13814
|
+
const query = typeof permissions === "object" && permissions !== null ? Reflect.get(permissions, "query") : void 0;
|
|
13815
|
+
if (typeof query !== "function") return "none";
|
|
13816
|
+
const status = await Reflect.apply(query, permissions, [{ name: "local-fonts" }]);
|
|
13817
|
+
const state = typeof status === "object" && status !== null ? Reflect.get(status, "state") : void 0;
|
|
13818
|
+
if (state === "granted") return "read";
|
|
13819
|
+
if (state !== "prompt") return "none";
|
|
13820
|
+
return view.navigator.webdriver ? "automated" : "read";
|
|
13821
|
+
} catch {
|
|
13822
|
+
return "none";
|
|
13823
|
+
}
|
|
13824
|
+
};
|
|
13825
|
+
const installedFonts = async (view) => {
|
|
13826
|
+
const query = Reflect.get(view, "queryLocalFonts");
|
|
13827
|
+
if (typeof query !== "function" || await localFontAccessOf(view) !== "read") return [];
|
|
13828
|
+
try {
|
|
13829
|
+
const fonts = await Reflect.apply(query, view, []);
|
|
13830
|
+
return Array.isArray(fonts) ? fonts.filter((font) => isFontData(font)) : [];
|
|
13831
|
+
} catch {
|
|
13832
|
+
return [];
|
|
13833
|
+
}
|
|
13834
|
+
};
|
|
13835
|
+
const typedFontOf = async (body) => {
|
|
13836
|
+
const signature = await body.slice(0, SIGNATURE_LENGTH).text();
|
|
13837
|
+
return new Blob([body], { type: signature === OPENTYPE_CFF ? "font/otf" : "font/ttf" });
|
|
13838
|
+
};
|
|
13839
|
+
/**
|
|
13840
|
+
* Reads the files of the installed fonts a page's text uses, where the browser offers them and the
|
|
13841
|
+
* page already may read them. The stored page then carries the fonts the person saw, so the server
|
|
13842
|
+
* measures with them and everyone who opens the canvas sees them.
|
|
13843
|
+
*/
|
|
13844
|
+
const readLocalFontFaces = async (document, families) => {
|
|
13845
|
+
const view = document.defaultView;
|
|
13846
|
+
if (view === null || families.length === 0) return [];
|
|
13847
|
+
const wanted = new Set(families.map((family) => family.toLowerCase()));
|
|
13848
|
+
const fonts = (await installedFonts(view)).filter((font) => wanted.has(font.family.toLowerCase()));
|
|
13849
|
+
return Promise.all(fonts.map(async (font) => ({
|
|
13850
|
+
family: font.family,
|
|
13851
|
+
weight: weightOf(font.style),
|
|
13852
|
+
style: /italic|oblique/iu.test(font.style) ? "italic" : "normal",
|
|
13853
|
+
body: await typedFontOf(await font.blob()),
|
|
13854
|
+
url: addressOf(font.postscriptName)
|
|
13855
|
+
})));
|
|
13856
|
+
};
|
|
13857
|
+
/**
|
|
13858
|
+
* Reads the one installed font an address names, for a path that reads a page's files outside the
|
|
13859
|
+
* page and so holds no faces when it meets the address.
|
|
13860
|
+
*/
|
|
13861
|
+
const readLocalFontFile = async (document, url) => {
|
|
13862
|
+
const view = document.defaultView;
|
|
13863
|
+
if (view === null || !isLocalFontAddress(url)) return void 0;
|
|
13864
|
+
const font = (await installedFonts(view)).find((candidate) => addressOf(candidate.postscriptName) === url);
|
|
13865
|
+
if (font === void 0) return void 0;
|
|
13866
|
+
const body = await typedFontOf(await font.blob());
|
|
13867
|
+
return {
|
|
13868
|
+
contentType: body.type,
|
|
13869
|
+
body
|
|
13870
|
+
};
|
|
13871
|
+
};
|
|
13872
|
+
const fontFaceRule = (face) => `@font-face{font-family:${JSON.stringify(face.family)};font-weight:${String(face.weight)};font-style:${face.style};src:url(${JSON.stringify(face.url)})}`;
|
|
13873
|
+
const ELEMENT = 2;
|
|
13874
|
+
const highestIdIn$1 = (node) => Math.max(node.id ?? 0, ...(node.childNodes ?? []).map((child) => highestIdIn$1(child)));
|
|
13875
|
+
const namesIn = (value) => {
|
|
13876
|
+
try {
|
|
13877
|
+
const parsed = JSON.parse(String(value));
|
|
13878
|
+
return Array.isArray(parsed) ? parsed.filter((name) => typeof name === "string") : [];
|
|
13879
|
+
} catch {
|
|
13880
|
+
return [];
|
|
13881
|
+
}
|
|
13882
|
+
};
|
|
13883
|
+
const fieldOf = (value, key) => typeof value === "object" && value !== null ? Reflect.get(value, key) : void 0;
|
|
13884
|
+
/** The installed families the capture recorded the browser could draw, read from its snapshot. */
|
|
13885
|
+
const drawableFontsRecordedIn = (snapshot) => {
|
|
13886
|
+
const children = fieldOf(fieldOf(fieldOf(snapshot, "data"), "node"), "childNodes");
|
|
13887
|
+
const html = Array.isArray(children) ? children.find((child) => fieldOf(child, "tagName") === "html") : void 0;
|
|
13888
|
+
return namesIn(fieldOf(fieldOf(html, "attributes"), CAPTURED_DRAWABLE_FONTS_ATTRIBUTE));
|
|
13889
|
+
};
|
|
13890
|
+
/**
|
|
13891
|
+
* Adds the installed fonts to a page snapshot as faces the page declares and loaded, which is what
|
|
13892
|
+
* they now are for whoever opens the stored page.
|
|
13893
|
+
*/
|
|
13894
|
+
const withLocalFontFaces = (snapshot, faces) => {
|
|
13895
|
+
if (typeof snapshot !== "object" || snapshot === null || faces.length === 0) return snapshot;
|
|
13896
|
+
const copy = structuredClone(snapshot);
|
|
13897
|
+
const root = copy.data?.node;
|
|
13898
|
+
const html = root?.childNodes?.find((child) => child.tagName === "html");
|
|
13899
|
+
const head = html?.childNodes?.find((child) => child.tagName === "head");
|
|
13900
|
+
if (root === void 0 || head === void 0 || html?.attributes === void 0) return snapshot;
|
|
13901
|
+
head.childNodes = [...head.childNodes ?? [], {
|
|
13902
|
+
type: ELEMENT,
|
|
13903
|
+
id: highestIdIn$1(root) + 1,
|
|
13904
|
+
tagName: "style",
|
|
13905
|
+
attributes: {
|
|
13906
|
+
"data-enhance-local-fonts": "",
|
|
13907
|
+
_cssText: faces.map((face) => fontFaceRule(face)).join("\n")
|
|
13908
|
+
},
|
|
13909
|
+
childNodes: []
|
|
13910
|
+
}];
|
|
13911
|
+
const families = new Set(faces.map((face) => face.family.toLowerCase()));
|
|
13912
|
+
html.attributes[CAPTURED_LOADED_FONTS_ATTRIBUTE] = JSON.stringify([.../* @__PURE__ */ new Set([...namesIn(html.attributes[CAPTURED_LOADED_FONTS_ATTRIBUTE]), ...faces.map((face) => face.family)])]);
|
|
13913
|
+
html.attributes[CAPTURED_DRAWABLE_FONTS_ATTRIBUTE] = JSON.stringify(namesIn(html.attributes[CAPTURED_DRAWABLE_FONTS_ATTRIBUTE]).filter((name) => !families.has(name.toLowerCase())));
|
|
13914
|
+
return copy;
|
|
13915
|
+
};
|
|
13916
|
+
//#endregion
|
|
13917
|
+
//#region ../capture-browser/src/full-page-window-placed.lib.ts
|
|
13918
|
+
const PERCENT = 100;
|
|
13919
|
+
/** Each makes its element the box that absolute and fixed descendants are placed against. */
|
|
13920
|
+
const CONTAINING_PROPERTIES = [
|
|
13921
|
+
"transform",
|
|
13922
|
+
"perspective",
|
|
13923
|
+
"filter",
|
|
13924
|
+
"backdropFilter"
|
|
13925
|
+
];
|
|
13926
|
+
const CONTAINING_CONTAINMENT = /\b(?:layout|paint|strict|content)\b/u;
|
|
13927
|
+
const CONTAINING_WILL_CHANGE = /\b(?:transform|perspective|filter)\b/u;
|
|
13928
|
+
const containsPlacedDescendants = (style) => style.position !== "static" || CONTAINING_PROPERTIES.some((property) => {
|
|
13929
|
+
const value = Reflect.get(style, property);
|
|
13930
|
+
return typeof value === "string" && value !== "" && value !== "none";
|
|
13931
|
+
}) || CONTAINING_CONTAINMENT.test(style.contain) || CONTAINING_WILL_CHANGE.test(style.willChange);
|
|
13932
|
+
/** Fixed, or absolute with no ancestor to be placed against: the window places it. */
|
|
13933
|
+
const isPlacedAgainstWindow = (element, style, view) => {
|
|
13934
|
+
if (style.position === "fixed") return true;
|
|
13935
|
+
if (style.position !== "absolute") return false;
|
|
13936
|
+
for (let parent = element.parentElement; parent !== null; parent = parent.parentElement) if (containsPlacedDescendants(view.getComputedStyle(parent))) return false;
|
|
13937
|
+
return true;
|
|
13938
|
+
};
|
|
13939
|
+
const computedValuesOf = (element) => {
|
|
13940
|
+
const read = Reflect.get(element, "computedStyleMap");
|
|
13941
|
+
if (typeof read !== "function") return void 0;
|
|
13942
|
+
const values = Reflect.apply(read, element, []);
|
|
13943
|
+
if (typeof values !== "object" || values === null) return void 0;
|
|
13944
|
+
const get = Reflect.get(values, "get");
|
|
13945
|
+
if (typeof get !== "function") return void 0;
|
|
13946
|
+
return (property) => {
|
|
13947
|
+
const value = Reflect.apply(get, values, [property]);
|
|
13948
|
+
const text = typeof value === "object" && value !== null ? Reflect.get(value, "toString") : void 0;
|
|
13949
|
+
const written = typeof text === "function" ? Reflect.apply(text, value, []) : void 0;
|
|
13950
|
+
return typeof written === "string" ? written : void 0;
|
|
13951
|
+
};
|
|
13952
|
+
};
|
|
13953
|
+
const isAutomatic = (value) => value === void 0 || value === "auto";
|
|
13954
|
+
const PERCENTAGE = /^(-?(?:\d*\.)?\d+)%$/u;
|
|
13955
|
+
/** A plain percentage of the window's height, in pixels. Anything else is left as written. */
|
|
13956
|
+
const percentageOfWindow = (value, window) => {
|
|
13957
|
+
const amount = value === void 0 ? null : PERCENTAGE.exec(value);
|
|
13958
|
+
return amount === null ? void 0 : `${String(Number(amount[1]) * window.height / PERCENT)}px`;
|
|
13959
|
+
};
|
|
13960
|
+
/**
|
|
13961
|
+
* Whether the element's height came from the window: from a top and bottom set together, or from a
|
|
13962
|
+
* percentage. A browser that cannot report computed values is taken to mean yes, which keeps the
|
|
13963
|
+
* picture right and makes a box that hugged its content a box of fixed height.
|
|
13964
|
+
*/
|
|
13965
|
+
const heightCameFromWindow = (read) => {
|
|
13966
|
+
if (read === void 0) return true;
|
|
13967
|
+
const height = read("height");
|
|
13968
|
+
if (height?.includes("%") === true) return true;
|
|
13969
|
+
return isAutomatic(height) && !isAutomatic(read("top")) && !isAutomatic(read("bottom"));
|
|
13970
|
+
};
|
|
13971
|
+
/**
|
|
13972
|
+
* The rules that keep a box placed against the window where and as tall as the live window made
|
|
13973
|
+
* it, once the stored page is laid out in a window as tall as the page.
|
|
13974
|
+
*/
|
|
13975
|
+
const windowPlacedRules = (element, style, window, view) => {
|
|
13976
|
+
if (!style.top.endsWith("px") || !isPlacedAgainstWindow(element, style, view)) return [];
|
|
13977
|
+
const read = computedValuesOf(element);
|
|
13978
|
+
const limits = ["min-height", "max-height"].flatMap((property) => {
|
|
13979
|
+
const pixels = percentageOfWindow(read?.(property), window);
|
|
13980
|
+
return pixels === void 0 ? [] : [`${property}:${pixels}!important`];
|
|
13981
|
+
});
|
|
13982
|
+
return [
|
|
13983
|
+
`top:${style.top}!important;bottom:auto!important;margin-top:${style.marginTop}!important;margin-bottom:${style.marginBottom}!important`,
|
|
13984
|
+
...heightCameFromWindow(read) && style.height.endsWith("px") ? [`height:${style.height}!important`] : [],
|
|
13985
|
+
...limits
|
|
13986
|
+
];
|
|
13987
|
+
};
|
|
13988
|
+
//#endregion
|
|
13989
|
+
//#region ../capture-browser/src/full-page-capture.lib.ts
|
|
13990
|
+
const PRIMARY_SCROLL_WIDTH_RATIO = .7;
|
|
13991
|
+
const PRIMARY_SCROLL_HEIGHT_RATIO = .5;
|
|
13992
|
+
const hasViewportPixels = (element, width, height) => [...element.getClientRects()].some((box) => box.width > 0 && box.height > 0 && box.right > 0 && box.bottom > 0 && box.left < width && box.top < height) || [...element.children].some((child) => hasViewportPixels(child, width, height)) || element.shadowRoot !== null && [...element.shadowRoot.children].some((child) => hasViewportPixels(child, width, height));
|
|
13993
|
+
/**
|
|
13994
|
+
* The window scrolls the document, and a body whose overflow the root does not set hands its own
|
|
13995
|
+
* to the window. Neither is a scroller inside the page, so neither is opened.
|
|
13996
|
+
*/
|
|
13997
|
+
const scrollsTheWindow = (element, view) => {
|
|
13998
|
+
const document = element.ownerDocument;
|
|
13999
|
+
if (element === document.documentElement) return true;
|
|
14000
|
+
if (element !== document.body) return false;
|
|
14001
|
+
const root = view.getComputedStyle(document.documentElement);
|
|
14002
|
+
return root.overflowX === "visible" && root.overflowY === "visible";
|
|
14003
|
+
};
|
|
14004
|
+
const isPrimaryScroller = (element, style, window, view) => element.clientWidth >= window.width * PRIMARY_SCROLL_WIDTH_RATIO && element.clientHeight >= window.height * PRIMARY_SCROLL_HEIGHT_RATIO && element.scrollHeight > element.clientHeight + 1 && [
|
|
14005
|
+
"auto",
|
|
14006
|
+
"scroll",
|
|
14007
|
+
"hidden"
|
|
14008
|
+
].includes(style.overflowY) && !scrollsTheWindow(element, view);
|
|
14009
|
+
/** A box around an opened scroller may grow to hold it, and never shrinks below its live height. */
|
|
14010
|
+
const growRule = (style) => [
|
|
14011
|
+
"height:auto!important",
|
|
14012
|
+
...style.height.endsWith("px") ? [`min-height:${style.height}!important`] : [],
|
|
14013
|
+
"max-height:none!important",
|
|
14014
|
+
"overflow-y:visible!important"
|
|
14015
|
+
].join(";");
|
|
14016
|
+
const ancestorsOf = (element) => {
|
|
14017
|
+
const ancestors = [];
|
|
14018
|
+
for (let parent = element.parentElement; parent !== null; parent = parent.parentElement) ancestors.push(parent);
|
|
14019
|
+
return ancestors;
|
|
14020
|
+
};
|
|
14021
|
+
/**
|
|
14022
|
+
* What scrolls a sticky element: the window, or a scroller the capture opens. A scroller left as
|
|
14023
|
+
* it is still scrolls it, so the element needs nothing.
|
|
14024
|
+
*/
|
|
14025
|
+
const scrollPortOf = (element, view, opened) => {
|
|
14026
|
+
for (let parent = element.parentElement; parent !== null; parent = parent.parentElement) {
|
|
14027
|
+
if (opened.includes(parent)) return parent;
|
|
14028
|
+
if (scrollsTheWindow(parent, view)) continue;
|
|
14029
|
+
if (view.getComputedStyle(parent).overflowY !== "visible") return void 0;
|
|
14030
|
+
}
|
|
14031
|
+
return "window";
|
|
14032
|
+
};
|
|
14033
|
+
/**
|
|
14034
|
+
* A box stuck to the bottom of what scrolls it stays where it was held: that bottom is now the
|
|
14035
|
+
* bottom of the whole page, so the box's own offset from it grows by the difference.
|
|
14036
|
+
*/
|
|
14037
|
+
const stuckRulesOf = (stuck, page) => [...stuck].flatMap(([element, bottom]) => {
|
|
14038
|
+
const port = scrollPortOf(element, page.view, page.opened);
|
|
14039
|
+
if (port === void 0) return [];
|
|
14040
|
+
const heldAt = port === "window" ? page.window.height : port.getBoundingClientRect().bottom + page.scrolled;
|
|
14041
|
+
return [[element, `bottom:${String(bottom + page.fullHeight - heldAt)}px!important`]];
|
|
14042
|
+
});
|
|
14043
|
+
const windowRulesOf = (document, view, window, captured) => {
|
|
14044
|
+
const rulesOf = /* @__PURE__ */ new Map();
|
|
14045
|
+
const add = (element, rules) => {
|
|
14046
|
+
if (rules.length > 0) rulesOf.set(element, [...rulesOf.get(element) ?? [], ...rules]);
|
|
14047
|
+
};
|
|
14048
|
+
const scrolled = document.scrollingElement?.scrollTop ?? 0;
|
|
14049
|
+
const opened = [];
|
|
14050
|
+
const stuck = /* @__PURE__ */ new Map();
|
|
14051
|
+
let fullHeight = Math.max(window.height, document.documentElement.scrollHeight, document.body.scrollHeight);
|
|
14052
|
+
const elements = [...document.querySelectorAll("*")].filter((element) => captured(element));
|
|
14053
|
+
for (const element of elements) {
|
|
14054
|
+
const style = view.getComputedStyle(element);
|
|
14055
|
+
add(element, windowPlacedRules(element, style, window, view));
|
|
14056
|
+
if (style.position === "fixed" && !hasViewportPixels(element, window.width, window.height)) add(element, ["display:none!important"]);
|
|
14057
|
+
if (style.position === "sticky" && style.bottom.endsWith("px")) stuck.set(element, Number(style.bottom.slice(0, -2)));
|
|
14058
|
+
if (!isPrimaryScroller(element, style, window, view)) continue;
|
|
14059
|
+
const extent = element.scrollHeight;
|
|
14060
|
+
fullHeight = Math.max(fullHeight, Math.ceil(element.getBoundingClientRect().top + scrolled + extent));
|
|
14061
|
+
add(element, [`height:${String(extent)}px!important;max-height:none!important;overflow-y:visible!important`]);
|
|
14062
|
+
opened.push(element);
|
|
14063
|
+
}
|
|
14064
|
+
const stuckRules = stuckRulesOf(stuck, {
|
|
14065
|
+
view,
|
|
14066
|
+
opened,
|
|
14067
|
+
fullHeight,
|
|
14068
|
+
scrolled,
|
|
14069
|
+
window
|
|
14070
|
+
});
|
|
14071
|
+
for (const [element, rule] of stuckRules) add(element, [rule]);
|
|
14072
|
+
const around = new Set(opened.flatMap((element) => ancestorsOf(element)));
|
|
14073
|
+
for (const element of around) if (!opened.includes(element)) add(element, [growRule(view.getComputedStyle(element))]);
|
|
14074
|
+
const root = document.documentElement;
|
|
14075
|
+
if (opened.length === 0 && fullHeight > window.height && Math.abs(root.getBoundingClientRect().height - window.height) < 1) add(root, [`height:${String(window.height)}px!important`]);
|
|
14076
|
+
return {
|
|
14077
|
+
rulesOf,
|
|
14078
|
+
fullHeight
|
|
14079
|
+
};
|
|
14080
|
+
};
|
|
14081
|
+
/** What a stylesheet takes from the live window: its size, and the answer to a media condition. */
|
|
14082
|
+
const liveWindowOf = (document) => {
|
|
14083
|
+
const view = document.defaultView;
|
|
14084
|
+
const sized = document.compatMode === "BackCompat" ? document.body : document.documentElement;
|
|
14085
|
+
return {
|
|
14086
|
+
width: sized.clientWidth,
|
|
14087
|
+
height: sized.clientHeight,
|
|
14088
|
+
matchesMedia: (condition) => view?.matchMedia(condition).matches ?? false
|
|
14089
|
+
};
|
|
14090
|
+
};
|
|
14091
|
+
/**
|
|
14092
|
+
* Freezes a stylesheet's text with the live window's values, as a whole-page capture freezes the
|
|
14093
|
+
* CSS it carries. For a path that reads stylesheet files outside the page.
|
|
14094
|
+
*/
|
|
14095
|
+
const fullPageStylesheetFreeze = (document) => {
|
|
14096
|
+
const options = {
|
|
14097
|
+
...liveWindowOf(document),
|
|
14098
|
+
overrides: /* @__PURE__ */ new Map()
|
|
14099
|
+
};
|
|
14100
|
+
return (css) => fullPageScreenCss(css, options);
|
|
14101
|
+
};
|
|
14102
|
+
const ROOT_RULE = "overflow:visible!important";
|
|
14103
|
+
/**
|
|
14104
|
+
* Puts the rules a whole-page capture stores on the live page, so a picture taken beyond the
|
|
14105
|
+
* window shows what the stored page shows, and answers with how to take them off again. The
|
|
14106
|
+
* window keeps its size, so nothing sized by it moves.
|
|
14107
|
+
*/
|
|
14108
|
+
const applyFullPageRules = (document) => {
|
|
14109
|
+
const view = document.defaultView;
|
|
14110
|
+
const window = liveWindowOf(document);
|
|
14111
|
+
if (view === null) return {
|
|
14112
|
+
height: window.height,
|
|
14113
|
+
restore: () => {}
|
|
14114
|
+
};
|
|
14115
|
+
const { rulesOf, fullHeight } = windowRulesOf(document, view, window, () => true);
|
|
14116
|
+
const rules = new Map(rulesOf);
|
|
14117
|
+
for (const root of [document.documentElement, document.body]) {
|
|
14118
|
+
const style = view.getComputedStyle(root);
|
|
14119
|
+
if (style.overflowX !== "visible" || style.overflowY !== "visible") rules.set(root, [...rules.get(root) ?? [], ROOT_RULE]);
|
|
14120
|
+
}
|
|
14121
|
+
const written = Array.from(rules, ([element, added]) => {
|
|
14122
|
+
const style = element.getAttribute("style");
|
|
14123
|
+
element.setAttribute("style", [style ?? "", ...added].join(";"));
|
|
14124
|
+
return [element, style];
|
|
14125
|
+
});
|
|
14126
|
+
return {
|
|
14127
|
+
height: fullHeight,
|
|
14128
|
+
restore: () => {
|
|
14129
|
+
for (const [element, style] of written) {
|
|
14130
|
+
element.toggleAttribute("style", style !== null);
|
|
14131
|
+
if (style !== null) element.setAttribute("style", style);
|
|
14132
|
+
}
|
|
14133
|
+
}
|
|
14134
|
+
};
|
|
14135
|
+
};
|
|
14136
|
+
const fullPageCaptureLayout = (document, idForNode) => {
|
|
14137
|
+
const live = liveWindowOf(document);
|
|
14138
|
+
const { width, height } = live;
|
|
14139
|
+
const view = document.defaultView;
|
|
14140
|
+
const { rulesOf, fullHeight } = view === null ? {
|
|
14141
|
+
rulesOf: /* @__PURE__ */ new Map(),
|
|
14142
|
+
fullHeight: Math.max(height, document.documentElement.scrollHeight, document.body.scrollHeight)
|
|
14143
|
+
} : windowRulesOf(document, view, {
|
|
14144
|
+
width,
|
|
14145
|
+
height
|
|
14146
|
+
}, (element) => idForNode(element) >= 0);
|
|
14147
|
+
const overrides = new Map(Array.from(rulesOf, ([element, rules]) => [idForNode(element), rules.join(";")]));
|
|
14148
|
+
return {
|
|
14149
|
+
options: {
|
|
14150
|
+
...live,
|
|
14151
|
+
overrides
|
|
14152
|
+
},
|
|
14153
|
+
viewport: {
|
|
14154
|
+
width,
|
|
14155
|
+
height: fullHeight
|
|
14156
|
+
}
|
|
14157
|
+
};
|
|
14158
|
+
};
|
|
14159
|
+
//#endregion
|
|
14160
|
+
//#region ../capture-browser/src/capture-kernel-calls.lib.ts
|
|
14161
|
+
/** Where the page keeps the way back from the picture's rules, between two calls from Node. */
|
|
14162
|
+
const RESTORE = Symbol.for("enhance.capture.restore-picture-rules");
|
|
14163
|
+
const CHUNK = 32768;
|
|
14164
|
+
const base64Of = async (body) => {
|
|
14165
|
+
const bytes = new Uint8Array(await body.arrayBuffer());
|
|
14166
|
+
let binary = "";
|
|
14167
|
+
for (let start = 0; start < bytes.length; start += CHUNK) binary += String.fromCodePoint(...bytes.subarray(start, start + CHUNK));
|
|
14168
|
+
return btoa(binary);
|
|
14169
|
+
};
|
|
14170
|
+
/** One installed font's file, in a form that crosses from the page to Node. */
|
|
14171
|
+
const localFontFileBase64 = async (document, url) => {
|
|
14172
|
+
const file = await readLocalFontFile(document, url);
|
|
14173
|
+
return file === void 0 ? null : {
|
|
14174
|
+
contentType: file.contentType,
|
|
14175
|
+
base64: await base64Of(file.body)
|
|
14176
|
+
};
|
|
14177
|
+
};
|
|
14178
|
+
/**
|
|
14179
|
+
* Puts the stored page's rules on the live page for a picture. The picture is taken from Node, so
|
|
14180
|
+
* the way back waits on the page between this call and `closeAfterPicture`.
|
|
14181
|
+
*/
|
|
14182
|
+
const openForPicture = (document) => {
|
|
14183
|
+
closeAfterPicture();
|
|
14184
|
+
Reflect.set(globalThis, RESTORE, applyFullPageRules(document).restore);
|
|
14185
|
+
};
|
|
14186
|
+
const closeAfterPicture = () => {
|
|
14187
|
+
const restore = Reflect.get(globalThis, RESTORE);
|
|
14188
|
+
Reflect.deleteProperty(globalThis, RESTORE);
|
|
14189
|
+
if (typeof restore === "function") Reflect.apply(restore, void 0, []);
|
|
14190
|
+
};
|
|
14191
|
+
//#endregion
|
|
12998
14192
|
//#region ../capture-browser/src/cssom-style-correction.lib.ts
|
|
12999
14193
|
const EMPTY_DECLARATION = /(?<=[{;])\s*([-\w]+)\s*:\s*;/dgu;
|
|
13000
14194
|
const erasedProperties = (cssText) => {
|
|
@@ -13093,48 +14287,6 @@ unreadableCount: number$2().int().min(0) });
|
|
|
13093
14287
|
return serialized;
|
|
13094
14288
|
};
|
|
13095
14289
|
//#endregion
|
|
13096
|
-
//#region ../capture-browser/src/full-page-capture.lib.ts
|
|
13097
|
-
const PRIMARY_SCROLL_WIDTH_RATIO = .7;
|
|
13098
|
-
const PRIMARY_SCROLL_HEIGHT_RATIO = .5;
|
|
13099
|
-
const hasViewportPixels = (element, width, height) => [...element.getClientRects()].some((box) => box.width > 0 && box.height > 0 && box.right > 0 && box.bottom > 0 && box.left < width && box.top < height) || [...element.children].some((child) => hasViewportPixels(child, width, height)) || element.shadowRoot !== null && [...element.shadowRoot.children].some((child) => hasViewportPixels(child, width, height));
|
|
13100
|
-
const fixedPositionRules = (element, style, width, height) => [`top:${style.top}!important;bottom:auto!important;margin-top:${style.marginTop}!important;margin-bottom:${style.marginBottom}!important`, ...hasViewportPixels(element, width, height) ? [] : ["display:none!important"]];
|
|
13101
|
-
const fullPageCaptureLayout = (document, idForNode) => {
|
|
13102
|
-
const width = document.documentElement.clientWidth;
|
|
13103
|
-
const height = document.documentElement.clientHeight;
|
|
13104
|
-
const view = document.defaultView;
|
|
13105
|
-
let fullHeight = Math.max(height, document.documentElement.scrollHeight, document.body.scrollHeight);
|
|
13106
|
-
const overrides = /* @__PURE__ */ new Map();
|
|
13107
|
-
if (view !== null) for (const element of document.querySelectorAll("*")) {
|
|
13108
|
-
const id = idForNode(element);
|
|
13109
|
-
if (id < 0) continue;
|
|
13110
|
-
const style = view.getComputedStyle(element);
|
|
13111
|
-
const rules = [];
|
|
13112
|
-
if (style.position === "fixed") rules.push(...fixedPositionRules(element, style, width, height));
|
|
13113
|
-
if (element.clientWidth >= width * PRIMARY_SCROLL_WIDTH_RATIO && element.clientHeight >= height * PRIMARY_SCROLL_HEIGHT_RATIO && element.scrollHeight > element.clientHeight + 1 && [
|
|
13114
|
-
"auto",
|
|
13115
|
-
"scroll",
|
|
13116
|
-
"hidden"
|
|
13117
|
-
].includes(style.overflowY)) {
|
|
13118
|
-
const extent = element.scrollHeight;
|
|
13119
|
-
fullHeight = Math.max(fullHeight, Math.ceil(element.getBoundingClientRect().top + (document.scrollingElement?.scrollTop ?? 0) + extent));
|
|
13120
|
-
rules.push(`height:${String(extent)}px!important;max-height:none!important;overflow-y:visible!important`);
|
|
13121
|
-
}
|
|
13122
|
-
overrides.set(id, rules.join(";"));
|
|
13123
|
-
}
|
|
13124
|
-
return {
|
|
13125
|
-
options: {
|
|
13126
|
-
width,
|
|
13127
|
-
height,
|
|
13128
|
-
overrides: new Map([...overrides].filter(([, rule]) => rule !== "")),
|
|
13129
|
-
matchesMedia: (condition) => view?.matchMedia(condition).matches ?? false
|
|
13130
|
-
},
|
|
13131
|
-
viewport: {
|
|
13132
|
-
width,
|
|
13133
|
-
height: fullHeight
|
|
13134
|
-
}
|
|
13135
|
-
};
|
|
13136
|
-
};
|
|
13137
|
-
//#endregion
|
|
13138
14290
|
//#region ../capture-browser/src/marked-snapshot-tree.lib.ts
|
|
13139
14291
|
const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13140
14292
|
const childEntries = (record) => Object.entries(record).filter(([key]) => key !== "attributes");
|
|
@@ -17478,6 +18630,79 @@ unreadableCount: number$2().int().min(0) });
|
|
|
17478
18630
|
postcss.Root;
|
|
17479
18631
|
postcss.Node;
|
|
17480
18632
|
//#endregion
|
|
18633
|
+
//#region ../capture-browser/src/captured-drawable-fonts.lib.ts
|
|
18634
|
+
const PROBE_TEXT = "mmmmmmmmmmlli1WQ@#";
|
|
18635
|
+
const PROBE_SIZE = "72px";
|
|
18636
|
+
const FALLBACKS = [
|
|
18637
|
+
"monospace",
|
|
18638
|
+
"serif",
|
|
18639
|
+
"sans-serif"
|
|
18640
|
+
];
|
|
18641
|
+
const unquoted = (family) => family.trim().replace(/^(['"])(.*)\1$/u, "$2");
|
|
18642
|
+
/** The families a computed font stack names, in order. */
|
|
18643
|
+
const familiesOf = (stack) => stack.split(",").map((family) => unquoted(family)).filter((family) => family !== "");
|
|
18644
|
+
const declaredFamiliesOf = (document) => {
|
|
18645
|
+
const declared = /* @__PURE__ */ new Set();
|
|
18646
|
+
const fonts = Reflect.get(document, "fonts");
|
|
18647
|
+
const forEach = typeof fonts === "object" && fonts !== null ? Reflect.get(fonts, "forEach") : null;
|
|
18648
|
+
if (typeof forEach !== "function") return declared;
|
|
18649
|
+
Reflect.apply(forEach, fonts, [(face) => {
|
|
18650
|
+
const family = typeof face === "object" && face !== null ? Reflect.get(face, "family") : null;
|
|
18651
|
+
if (typeof family === "string") declared.add(unquoted(family).toLowerCase());
|
|
18652
|
+
}]);
|
|
18653
|
+
return declared;
|
|
18654
|
+
};
|
|
18655
|
+
/** The width of the probe string in a font, measured on a canvas of its own. */
|
|
18656
|
+
const probeWidth = (document, font) => {
|
|
18657
|
+
const context = document.createElement("canvas").getContext("2d");
|
|
18658
|
+
if (context === null) return null;
|
|
18659
|
+
context.font = font;
|
|
18660
|
+
return context.measureText(PROBE_TEXT).width;
|
|
18661
|
+
};
|
|
18662
|
+
/** A generic family is a keyword, and quoting it would ask for an installed font of that name. */
|
|
18663
|
+
const probeNameOf = (family) => isCanvasGenericFontFamily(family) ? family : `"${family.replaceAll("\"", String.raw`\"`)}"`;
|
|
18664
|
+
/**
|
|
18665
|
+
* Whether the browser draws a family: a string measured in it differs in width from the same
|
|
18666
|
+
* string in at least one generic family. The long-standing way to tell an installed font in a page.
|
|
18667
|
+
* A generic family the browser does not know, as `ui-monospace` is to Chrome, measures as the
|
|
18668
|
+
* fallback each time, so it is one the browser cannot draw.
|
|
18669
|
+
*/
|
|
18670
|
+
const canDrawFontFamily = (document, family) => FALLBACKS.some((fallback) => {
|
|
18671
|
+
const plain = probeWidth(document, `${PROBE_SIZE} ${fallback}`);
|
|
18672
|
+
const named = probeWidth(document, `${PROBE_SIZE} ${probeNameOf(family)}, ${fallback}`);
|
|
18673
|
+
return plain !== null && named !== null && named !== plain;
|
|
18674
|
+
});
|
|
18675
|
+
/**
|
|
18676
|
+
* The installed families the page's text is drawn in: for each element, the first family in its
|
|
18677
|
+
* stack that the browser can draw, when the page supplies no face for it and it is no generic
|
|
18678
|
+
* family. A later family is a last resort, as the emoji fonts that end Tailwind's default stack
|
|
18679
|
+
* are, and is neither sent nor asked for. The converting machine may lack what is found here.
|
|
18680
|
+
*/
|
|
18681
|
+
const drawableUndeclaredFamilies = (document, blockSelector = ":not(*)") => {
|
|
18682
|
+
const view = document.defaultView;
|
|
18683
|
+
if (view === null) return [];
|
|
18684
|
+
const declared = declaredFamiliesOf(document);
|
|
18685
|
+
const drawable = /* @__PURE__ */ new Map();
|
|
18686
|
+
const isDrawn = (family) => {
|
|
18687
|
+
const key = family.toLowerCase();
|
|
18688
|
+
const wasDrawn = drawable.get(key);
|
|
18689
|
+
if (wasDrawn !== void 0) return wasDrawn;
|
|
18690
|
+
const isDrawable = declared.has(key) || canDrawFontFamily(document, family);
|
|
18691
|
+
drawable.set(key, isDrawable);
|
|
18692
|
+
return isDrawable;
|
|
18693
|
+
};
|
|
18694
|
+
const firstOf = /* @__PURE__ */ new Map();
|
|
18695
|
+
const used = /* @__PURE__ */ new Set();
|
|
18696
|
+
for (const element of document.querySelectorAll("*")) {
|
|
18697
|
+
if (element.closest(blockSelector) !== null) continue;
|
|
18698
|
+
const stack = view.getComputedStyle(element).fontFamily;
|
|
18699
|
+
if (!firstOf.has(stack)) firstOf.set(stack, familiesOf(stack).find((family) => isDrawn(family)));
|
|
18700
|
+
const first = firstOf.get(stack);
|
|
18701
|
+
if (first !== void 0 && !isCanvasGenericFontFamily(first) && !declared.has(first.toLowerCase())) used.add(first);
|
|
18702
|
+
}
|
|
18703
|
+
return [...used];
|
|
18704
|
+
};
|
|
18705
|
+
//#endregion
|
|
17481
18706
|
//#region ../capture-browser/src/captured-font-evidence.lib.ts
|
|
17482
18707
|
/** The families with a face the page tried and could not load, and no face it did load. */
|
|
17483
18708
|
const unavailableFontFamilies = (fonts, loaded) => {
|
|
@@ -17494,15 +18719,17 @@ unreadableCount: number$2().int().min(0) });
|
|
|
17494
18719
|
return [...failed];
|
|
17495
18720
|
};
|
|
17496
18721
|
/**
|
|
17497
|
-
* Keeps the page's font evidence: the families it loaded, which a replay may not rebuild,
|
|
17498
|
-
*
|
|
18722
|
+
* Keeps the page's font evidence: the families it loaded, which a replay may not rebuild, those it
|
|
18723
|
+
* could not, so a conversion does not count them as fonts the capture lost, and the installed
|
|
18724
|
+
* families it could draw, which the converting machine may not have.
|
|
17499
18725
|
*/
|
|
17500
|
-
const markCapturedFontEvidence = (node, document) => {
|
|
18726
|
+
const markCapturedFontEvidence = (node, document, blockSelector) => {
|
|
17501
18727
|
const html = node?.childNodes?.find((child) => child.tagName === "html");
|
|
17502
18728
|
if (html?.attributes === void 0) return;
|
|
17503
18729
|
const loaded = loadedCapturedFontFamilies(document.fonts);
|
|
17504
18730
|
Reflect.set(html.attributes, CAPTURED_LOADED_FONTS_ATTRIBUTE, JSON.stringify(loaded));
|
|
17505
18731
|
Reflect.set(html.attributes, CAPTURED_UNAVAILABLE_FONTS_ATTRIBUTE, JSON.stringify(unavailableFontFamilies(document.fonts, new Set(loaded))));
|
|
18732
|
+
Reflect.set(html.attributes, CAPTURED_DRAWABLE_FONTS_ATTRIBUTE, JSON.stringify(drawableUndeclaredFamilies(document, blockSelector)));
|
|
17506
18733
|
};
|
|
17507
18734
|
//#endregion
|
|
17508
18735
|
//#region ../capture-browser/src/snapshot-document.lib.ts
|
|
@@ -17577,8 +18804,10 @@ unreadableCount: number$2().int().min(0) });
|
|
|
17577
18804
|
...options.blockSelector !== void 0 && { blockSelector: options.blockSelector },
|
|
17578
18805
|
onSerialize: options.onSerialize
|
|
17579
18806
|
});
|
|
17580
|
-
markCapturedFontEvidence(node, document);
|
|
17581
|
-
|
|
18807
|
+
markCapturedFontEvidence(node, document, options.blockSelector);
|
|
18808
|
+
if (node === null) return null;
|
|
18809
|
+
const nodeForId = (id) => mirror.getNode(id);
|
|
18810
|
+
return withMeasuredPlaceholders(withCapturedMedia(withReadableCanvasPixels(withCdataAsText(node, nodeForId, absolutifyURLs), nodeForId), nodeForId), nodeForId);
|
|
17582
18811
|
};
|
|
17583
18812
|
const isBlocked = (node, selector) => {
|
|
17584
18813
|
const matches = Reflect.get(node, "matches");
|
|
@@ -17821,15 +19050,52 @@ unreadableCount: number$2().int().min(0) });
|
|
|
17821
19050
|
};
|
|
17822
19051
|
//#endregion
|
|
17823
19052
|
//#region ../capture-browser/src/root-style-hint.lib.ts
|
|
19053
|
+
const NAMES_A_FILE = "url(";
|
|
19054
|
+
/** A page may not read a stylesheet from another origin, and the browser throws if it tries. */
|
|
19055
|
+
const rulesOf = (sheet) => {
|
|
19056
|
+
try {
|
|
19057
|
+
return [...sheet.cssRules];
|
|
19058
|
+
} catch {
|
|
19059
|
+
return [];
|
|
19060
|
+
}
|
|
19061
|
+
};
|
|
19062
|
+
const rememberDeclaredAddresses = (style, base, found) => {
|
|
19063
|
+
for (const property of style) {
|
|
19064
|
+
if (!property.startsWith("--")) continue;
|
|
19065
|
+
const written = assetUrlsInCss(style.getPropertyValue(property));
|
|
19066
|
+
for (const reference of written) {
|
|
19067
|
+
const [address = ""] = reference.split("#", 1);
|
|
19068
|
+
const absolute = URL.parse(address) === null ? URL.parse(address, base) : null;
|
|
19069
|
+
if (address !== "" && absolute !== null) found.set(address, absolute.href);
|
|
19070
|
+
}
|
|
19071
|
+
}
|
|
19072
|
+
};
|
|
19073
|
+
const rememberAddressesInRules = (rules, base, found, pageBase) => {
|
|
19074
|
+
for (const rule of rules) {
|
|
19075
|
+
if (rule.style !== void 0) rememberDeclaredAddresses(rule.style, base, found);
|
|
19076
|
+
if (rule.cssRules !== void 0) rememberAddressesInRules([...rule.cssRules], base, found, pageBase);
|
|
19077
|
+
if (rule.styleSheet !== void 0 && rule.styleSheet !== null) rememberAddressesInRules(rulesOf(rule.styleSheet), rule.styleSheet.href ?? pageBase, found, pageBase);
|
|
19078
|
+
}
|
|
19079
|
+
};
|
|
19080
|
+
/** Each relative address written in a custom property, as the stylesheet declaring it means it. */
|
|
19081
|
+
const addressesDeclaredInStylesheets = (document) => {
|
|
19082
|
+
const found = /* @__PURE__ */ new Map();
|
|
19083
|
+
for (const sheet of document.styleSheets) rememberAddressesInRules(rulesOf(sheet), sheet.href ?? document.baseURI, found, document.baseURI);
|
|
19084
|
+
return found;
|
|
19085
|
+
};
|
|
19086
|
+
/**
|
|
19087
|
+
* @justified intent
|
|
19088
|
+
* A custom property's computed value keeps `url()` as the stylesheet wrote it, and the browser
|
|
19089
|
+
* resolves it against that stylesheet. Pinned on the root element it would resolve against the
|
|
19090
|
+
* page instead, so an address in `/assets/index.css` would name a file that does not exist.
|
|
19091
|
+
*/
|
|
17824
19092
|
const captureRootStyle = (document) => {
|
|
17825
19093
|
const pinned = document.createElement("div").style;
|
|
17826
19094
|
const computed = document.defaultView?.getComputedStyle(document.documentElement);
|
|
17827
19095
|
if (computed === void 0) return "";
|
|
17828
|
-
|
|
17829
|
-
|
|
17830
|
-
|
|
17831
|
-
if (value !== "") pinned.setProperty(property, value);
|
|
17832
|
-
}
|
|
19096
|
+
const properties = [...computed].filter((property) => property.startsWith("--")).map((property) => [property, computed.getPropertyValue(property)]).filter(([, value]) => value !== "");
|
|
19097
|
+
const addresses = properties.some(([, value]) => value.includes(NAMES_A_FILE)) ? addressesDeclaredInStylesheets(document) : /* @__PURE__ */ new Map();
|
|
19098
|
+
for (const [property, value] of properties) pinned.setProperty(property, value.includes(NAMES_A_FILE) ? rewriteCssAssetUrls(value, addresses, document.baseURI) : value);
|
|
17833
19099
|
return pinned.cssText;
|
|
17834
19100
|
};
|
|
17835
19101
|
const withRootStyle = (attributes, rootStyle) => {
|
|
@@ -18167,7 +19433,7 @@ unreadableCount: number$2().int().min(0) });
|
|
|
18167
19433
|
/** Captures synchronously, then permits resource retention before the same snapshot is frozen. */
|
|
18168
19434
|
const prepareBrowserScreen = (document, options) => {
|
|
18169
19435
|
const marked = captureMarkedSnapshot(document, options.atMs ?? 0, {
|
|
18170
|
-
blockSelector: options.blockSelector ?? "
|
|
19436
|
+
blockSelector: options.blockSelector ?? "audio[controls]",
|
|
18171
19437
|
fullPage: options.extent === "full-page",
|
|
18172
19438
|
...options.inlineStylesheet !== void 0 && { inlineStylesheet: options.inlineStylesheet }
|
|
18173
19439
|
});
|
|
@@ -18195,15 +19461,69 @@ unreadableCount: number$2().int().min(0) });
|
|
|
18195
19461
|
}
|
|
18196
19462
|
}
|
|
18197
19463
|
});
|
|
19464
|
+
const fullPage = marked.fullPage;
|
|
19465
|
+
const freezeStylesheet = fullPage === null ? null : (css) => fullPageScreenCss(css, fullPage.options);
|
|
18198
19466
|
return {
|
|
18199
19467
|
documents: marked.documents,
|
|
18200
19468
|
nodeForId: marked.nodeForId,
|
|
18201
|
-
finish
|
|
19469
|
+
finish,
|
|
19470
|
+
freezeStylesheet,
|
|
19471
|
+
drawableFonts: drawableFontsRecordedIn(marked.snapshot)
|
|
18202
19472
|
};
|
|
18203
19473
|
};
|
|
18204
19474
|
const captureBrowserScreen = (document, options) => prepareBrowserScreen(document, options).finish();
|
|
18205
19475
|
//#endregion
|
|
19476
|
+
//#region ../capture-browser/src/capture-page.lib.ts
|
|
19477
|
+
/** What a program driving the browser can do so the page's installed fonts travel with it. */
|
|
19478
|
+
const LOCAL_FONTS_NOT_GRANTED = {
|
|
19479
|
+
code: "local-fonts-not-granted",
|
|
19480
|
+
message: "This page uses fonts installed on this machine, and they were not sent. Grant the page the \"local-fonts\" permission and capture again to include them: in Playwright, await context.grantPermissions([\"local-fonts\"])."
|
|
19481
|
+
};
|
|
19482
|
+
const frozenWith = async (document, options, readFonts) => {
|
|
19483
|
+
let fonts = [];
|
|
19484
|
+
const prepared = prepareBrowserScreen(document, {
|
|
19485
|
+
...options,
|
|
19486
|
+
beforeFreeze: (hinted) => {
|
|
19487
|
+
const added = options.beforeFreeze?.(hinted) ?? hinted;
|
|
19488
|
+
return {
|
|
19489
|
+
...added,
|
|
19490
|
+
snapshot: withLocalFontFaces(added.snapshot, fonts)
|
|
19491
|
+
};
|
|
19492
|
+
}
|
|
19493
|
+
});
|
|
19494
|
+
fonts = await readFonts(prepared.drawableFonts);
|
|
19495
|
+
return {
|
|
19496
|
+
screen: prepared.finish(),
|
|
19497
|
+
fonts,
|
|
19498
|
+
freezeStylesheet: prepared.freezeStylesheet
|
|
19499
|
+
};
|
|
19500
|
+
};
|
|
19501
|
+
/** Reads the installed fonts in the page, and says when a program must grant that first. */
|
|
19502
|
+
const frozenInPage = async (document, options) => {
|
|
19503
|
+
const noted = { isGrantMissing: false };
|
|
19504
|
+
const frozen = await frozenWith(document, options, async (families) => {
|
|
19505
|
+
noted.isGrantMissing = families.length > 0 && document.defaultView !== null && await localFontAccessOf(document.defaultView) === "automated";
|
|
19506
|
+
return readLocalFontFaces(document, families);
|
|
19507
|
+
});
|
|
19508
|
+
return noted.isGrantMissing ? {
|
|
19509
|
+
...frozen,
|
|
19510
|
+
screen: {
|
|
19511
|
+
...frozen.screen,
|
|
19512
|
+
issues: [...frozen.screen.issues, LOCAL_FONTS_NOT_GRANTED]
|
|
19513
|
+
}
|
|
19514
|
+
} : frozen;
|
|
19515
|
+
};
|
|
19516
|
+
async function freezeCapturedPage(document, options) {
|
|
19517
|
+
const { readFonts, ...freeze } = options;
|
|
19518
|
+
return readFonts === void 0 ? frozenInPage(document, freeze) : frozenWith(document, freeze, readFonts);
|
|
19519
|
+
}
|
|
19520
|
+
//#endregion
|
|
18206
19521
|
exports.captureBrowserScreen = captureBrowserScreen;
|
|
19522
|
+
exports.closeAfterPicture = closeAfterPicture;
|
|
19523
|
+
exports.freezeCapturedPage = freezeCapturedPage;
|
|
18207
19524
|
exports.fullPageCaptureLayout = fullPageCaptureLayout;
|
|
19525
|
+
exports.fullPageStylesheetFreeze = fullPageStylesheetFreeze;
|
|
19526
|
+
exports.localFontFileBase64 = localFontFileBase64;
|
|
19527
|
+
exports.openForPicture = openForPicture;
|
|
18208
19528
|
return exports;
|
|
18209
19529
|
})({});
|