@enhance-eng/sdk 0.1.160 → 0.1.165
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/browser/kernel.iife.js +1781 -399
- package/dist/{capture-client.client-Dztj8uko.mjs → capture-client.client-C_8yINru.mjs} +3 -3
- package/dist/{capture-context.lib-Brfs-7h6.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-Ea2ntT4R.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-qRMMj0yg.mjs → stall-watch.lib-JRTp4jPK.mjs} +520 -64
- package/package.json +1 -1
- package/dist/environment.config-BorTlECV.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(),
|
|
@@ -6281,13 +6413,27 @@ progression: object$1({
|
|
|
6281
6413
|
nodeCount: draft.nodes.length
|
|
6282
6414
|
}
|
|
6283
6415
|
}));
|
|
6284
|
-
|
|
6416
|
+
/** A capture that lands as a new editable frame on a page, with no screen layer. */
|
|
6417
|
+
const editableFrameCaptureSchema = object$1({
|
|
6418
|
+
screenId: 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.")
|
|
6421
|
+
});
|
|
6422
|
+
const editableFrameInputBase = {
|
|
6285
6423
|
canvasId: uuid$1(),
|
|
6286
6424
|
documentFormatVersion: canvasDocumentFormatSchema,
|
|
6287
6425
|
mutationId: uuid$1(),
|
|
6288
6426
|
baseVersion: number$2().int().positive(),
|
|
6289
|
-
screenNodeId: string$1().min(1),
|
|
6290
6427
|
draft: canvasSubtreeDraftSchema
|
|
6428
|
+
};
|
|
6429
|
+
union$1([strictObject({
|
|
6430
|
+
...editableFrameInputBase,
|
|
6431
|
+
screenNodeId: string$1().min(1).describe("The screen layer to convert beside itself.")
|
|
6432
|
+
}), strictObject({
|
|
6433
|
+
...editableFrameInputBase,
|
|
6434
|
+
capture: editableFrameCaptureSchema.describe("The stored page a new capture lands from, and the page its frame goes on.")
|
|
6435
|
+
})]).superRefine((input, context) => {
|
|
6436
|
+
refuseUnsafeWriterFormat(input.documentFormatVersion, "whole", context);
|
|
6291
6437
|
});
|
|
6292
6438
|
const createEditableFrameResultSchema = object$1({
|
|
6293
6439
|
canvasId: uuid$1(),
|
|
@@ -6351,7 +6497,8 @@ progression: object$1({
|
|
|
6351
6497
|
"LOCAL_FONT_FALLBACK",
|
|
6352
6498
|
"SOURCE_FALLBACK",
|
|
6353
6499
|
"SCALE_REDUCED",
|
|
6354
|
-
"LAYOUT_FALLBACK"
|
|
6500
|
+
"LAYOUT_FALLBACK",
|
|
6501
|
+
"DRAWN_APPROXIMATELY"
|
|
6355
6502
|
];
|
|
6356
6503
|
//#endregion
|
|
6357
6504
|
//#region ../contract/src/canvas/canvas-render.schema.ts
|
|
@@ -6393,7 +6540,10 @@ progression: object$1({
|
|
|
6393
6540
|
recordingId: uuid$1(),
|
|
6394
6541
|
atMs: number$2().int().nonnegative(),
|
|
6395
6542
|
screenId: uuid$1(),
|
|
6396
|
-
|
|
6543
|
+
/** Null when the snapshot asked for a place only, so no screen layer was added. */
|
|
6544
|
+
screenNodeId: string$1().min(1).nullable(),
|
|
6545
|
+
/** The page the place is on. */
|
|
6546
|
+
pageId: string$1().min(1).optional(),
|
|
6397
6547
|
viewport: object$1({
|
|
6398
6548
|
width: number$2().int().positive(),
|
|
6399
6549
|
height: number$2().int().positive()
|
|
@@ -6557,7 +6707,11 @@ progression: object$1({
|
|
|
6557
6707
|
pageId: string$1().min(1).optional(),
|
|
6558
6708
|
nodeIds: array$1(string$1().min(1))
|
|
6559
6709
|
}),
|
|
6560
|
-
|
|
6710
|
+
/**
|
|
6711
|
+
* Below the walkthrough: as a screen layer, which installed CLIs ask for, or as a place only,
|
|
6712
|
+
* where the agent's CLI lands an editable frame.
|
|
6713
|
+
*/
|
|
6714
|
+
placement: strictObject({ kind: _enum$1(["below-source", "editable-below-source"]) })
|
|
6561
6715
|
});
|
|
6562
6716
|
object$1({
|
|
6563
6717
|
canvasId: uuid$1(),
|
|
@@ -6586,7 +6740,12 @@ progression: object$1({
|
|
|
6586
6740
|
}),
|
|
6587
6741
|
object$1({
|
|
6588
6742
|
kind: literal$1("replace"),
|
|
6589
|
-
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()
|
|
6590
6749
|
})
|
|
6591
6750
|
]);
|
|
6592
6751
|
const canvasConversionRequestSchema = object$1({
|
|
@@ -6823,6 +6982,21 @@ progression: object$1({
|
|
|
6823
6982
|
"text-align": textStyleValues["text-align"].optional(),
|
|
6824
6983
|
"white-space": textStyleValues["white-space"].optional()
|
|
6825
6984
|
});
|
|
6985
|
+
/** Every alignment a browser computes, which conversion stores and Undo must be able to put back. */
|
|
6986
|
+
const storedTextAlignSchema = _enum$1([
|
|
6987
|
+
"start",
|
|
6988
|
+
"end",
|
|
6989
|
+
"left",
|
|
6990
|
+
"right",
|
|
6991
|
+
"center",
|
|
6992
|
+
"justify",
|
|
6993
|
+
"justify-all",
|
|
6994
|
+
"match-parent",
|
|
6995
|
+
"-webkit-left",
|
|
6996
|
+
"-webkit-right",
|
|
6997
|
+
"-webkit-center"
|
|
6998
|
+
]);
|
|
6999
|
+
const storedFontStyleSchema = union$1([textStyleValues["font-style"], string$1().regex(/^oblique -?(?:\d+(?:\.\d+)?|\.\d+)deg$/u)]);
|
|
6826
7000
|
const restorableTextStyleValue = union$1([canvasAdditionalStyleSchema.shape.value, canvasNumberSchema]).nullable().optional();
|
|
6827
7001
|
const canvasTextStylePatchSchema = strictObject({
|
|
6828
7002
|
"text-decoration": restorableTextStyleValue,
|
|
@@ -6845,7 +7019,7 @@ progression: object$1({
|
|
|
6845
7019
|
"text-box": canvasAdditionalStyleSchema.shape.value.nullable().optional(),
|
|
6846
7020
|
"text-box-trim": canvasAdditionalStyleSchema.shape.value.nullable().optional(),
|
|
6847
7021
|
"text-box-edge": canvasAdditionalStyleSchema.shape.value.nullable().optional(),
|
|
6848
|
-
"font-style":
|
|
7022
|
+
"font-style": storedFontStyleSchema.nullable().optional(),
|
|
6849
7023
|
"font-stretch": union$1([_enum$1([
|
|
6850
7024
|
"normal",
|
|
6851
7025
|
"ultra-condensed",
|
|
@@ -6863,14 +7037,22 @@ progression: object$1({
|
|
|
6863
7037
|
literal$1("normal")
|
|
6864
7038
|
]).nullable().optional(),
|
|
6865
7039
|
"line-height": textStyleValues["line-height"].nullable().optional(),
|
|
6866
|
-
"text-align":
|
|
7040
|
+
"text-align": storedTextAlignSchema.nullable().optional(),
|
|
6867
7041
|
"text-indent": union$1([canvasNumberSchema, signedPixelLengthSchema]).nullable().optional(),
|
|
6868
7042
|
"white-space": textStyleValues["white-space"].nullable().optional(),
|
|
6869
7043
|
"word-spacing": union$1([
|
|
6870
7044
|
canvasNumberSchema,
|
|
6871
7045
|
signedPixelLengthSchema,
|
|
6872
7046
|
literal$1("normal")
|
|
6873
|
-
]).nullable().optional()
|
|
7047
|
+
]).nullable().optional(),
|
|
7048
|
+
direction: restorableTextStyleValue,
|
|
7049
|
+
"unicode-bidi": restorableTextStyleValue,
|
|
7050
|
+
"hanging-punctuation": restorableTextStyleValue,
|
|
7051
|
+
"text-transform": restorableTextStyleValue,
|
|
7052
|
+
"-webkit-text-stroke": restorableTextStyleValue,
|
|
7053
|
+
"-webkit-text-stroke-width": restorableTextStyleValue,
|
|
7054
|
+
"-webkit-text-stroke-color": restorableTextStyleValue,
|
|
7055
|
+
"paint-order": restorableTextStyleValue
|
|
6874
7056
|
});
|
|
6875
7057
|
const overflowStyleValue = canvasAdditionalStyleSchema.shape.value;
|
|
6876
7058
|
const dimensionalStyleValue = union$1([string$1(), canvasNumberSchema]);
|
|
@@ -7295,7 +7477,7 @@ progression: object$1({
|
|
|
7295
7477
|
removedText: record(nodeIdSchema$3, canvasSceneNodeSchema.pick({ props: true })).optional()
|
|
7296
7478
|
})
|
|
7297
7479
|
]);
|
|
7298
|
-
|
|
7480
|
+
currentCanvasOperationSchema.options;
|
|
7299
7481
|
/** Each operation's name, for records that may state which kind failed and nothing else. */
|
|
7300
7482
|
const CANVAS_OPERATION_NAMES = currentCanvasOperationSchema.options.map((option) => option.shape.op.value);
|
|
7301
7483
|
const canvasOperationSchema = preprocess((value, context) => {
|
|
@@ -7349,13 +7531,16 @@ progression: object$1({
|
|
|
7349
7531
|
/** Null while the blob has not landed. The client draws an empty frame with its label. */
|
|
7350
7532
|
download: signedDownloadSchema.nullable()
|
|
7351
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
|
+
});
|
|
7352
7540
|
object$1({
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
version: number$2().int().positive(),
|
|
7357
|
-
operations: array$1(canvasOperationSchema)
|
|
7358
|
-
})).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(),
|
|
7359
7544
|
version: number$2().int().min(1),
|
|
7360
7545
|
/**
|
|
7361
7546
|
* The revision the latest restore made, when there has been one. A reader at an older revision
|
|
@@ -7387,6 +7572,143 @@ progression: object$1({
|
|
|
7387
7572
|
document: canvasDocumentBlobSchema
|
|
7388
7573
|
})]);
|
|
7389
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
|
|
7390
7712
|
//#region ../contract/src/canvas/canvas-text-content.lib.ts
|
|
7391
7713
|
const textLinkSchema = object$1({
|
|
7392
7714
|
start: number$2().int().nonnegative(),
|
|
@@ -7418,13 +7740,30 @@ progression: object$1({
|
|
|
7418
7740
|
"export",
|
|
7419
7741
|
"source"
|
|
7420
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();
|
|
7421
7759
|
const canvasInspectNodeSummarySchema = object$1({
|
|
7422
7760
|
id: string$1().min(1),
|
|
7423
|
-
label: string$1().max(
|
|
7424
|
-
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),
|
|
7425
7763
|
parentId: string$1().min(1).nullable(),
|
|
7426
7764
|
childCount: number$2().int().min(0),
|
|
7427
7765
|
box: canvasSceneBoxSchema.nullable(),
|
|
7766
|
+
boxSource: canvasBoxSourceSchema.optional(),
|
|
7428
7767
|
propertySections: array$1(canvasPropertySectionSchema)
|
|
7429
7768
|
});
|
|
7430
7769
|
object$1({ canvasId: uuid$1() });
|
|
@@ -7437,13 +7776,15 @@ progression: object$1({
|
|
|
7437
7776
|
rootChildCount: number$2().int().min(0),
|
|
7438
7777
|
bounds: canvasSceneBoxSchema.nullable(),
|
|
7439
7778
|
kinds: record(string$1(), number$2().int().min(0)),
|
|
7779
|
+
boxNote: boxNoteSchema,
|
|
7440
7780
|
next: array$1(string$1().min(1))
|
|
7441
7781
|
});
|
|
7442
7782
|
object$1({ canvasId: uuid$1() });
|
|
7443
7783
|
object$1({
|
|
7444
7784
|
canvasId: uuid$1(),
|
|
7445
7785
|
version: number$2().int().positive(),
|
|
7446
|
-
nodes: array$1(canvasInspectNodeSummarySchema)
|
|
7786
|
+
nodes: array$1(canvasInspectNodeSummarySchema),
|
|
7787
|
+
boxNote: boxNoteSchema
|
|
7447
7788
|
});
|
|
7448
7789
|
object$1({
|
|
7449
7790
|
canvasId: uuid$1(),
|
|
@@ -7462,9 +7803,49 @@ progression: object$1({
|
|
|
7462
7803
|
props: record(string$1(), unknown()),
|
|
7463
7804
|
children: array$1(string$1().min(1))
|
|
7464
7805
|
}),
|
|
7806
|
+
boxNote: boxNoteSchema,
|
|
7465
7807
|
next: array$1(string$1().min(1))
|
|
7466
7808
|
});
|
|
7467
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
|
|
7468
7849
|
//#region ../contract/src/canvas/canvas-mutation.schema.ts
|
|
7469
7850
|
const nodeIdSchema$2 = canvasSceneNodeSchema.shape.id;
|
|
7470
7851
|
const writableBoxSchema = canvasSceneBoxSchema.extend({
|
|
@@ -7472,6 +7853,8 @@ progression: object$1({
|
|
|
7472
7853
|
height: number$2().positive()
|
|
7473
7854
|
});
|
|
7474
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() });
|
|
7475
7858
|
const canvasMutationRequestContextSchema = strictObject({
|
|
7476
7859
|
fingerprint: string$1().regex(/^[a-f0-9]{64}$/u),
|
|
7477
7860
|
revisionPolicy: _enum$1(["strict", "rebase"]),
|
|
@@ -7485,6 +7868,8 @@ progression: object$1({
|
|
|
7485
7868
|
operations: array$1(canvasOperationSchema).min(1),
|
|
7486
7869
|
requestContext: canvasMutationRequestContextSchema.optional(),
|
|
7487
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);
|
|
7488
7873
|
});
|
|
7489
7874
|
const applyCanvasOperationsOutputSchema = object$1({
|
|
7490
7875
|
canvasId: uuid$1(),
|
|
@@ -7495,7 +7880,7 @@ progression: object$1({
|
|
|
7495
7880
|
insertedNodeIds: array$1(nodeIdSchema$2),
|
|
7496
7881
|
changedNodeIds: array$1(nodeIdSchema$2),
|
|
7497
7882
|
removedNodeIds: array$1(nodeIdSchema$2),
|
|
7498
|
-
boxes: record(nodeIdSchema$2,
|
|
7883
|
+
boxes: record(nodeIdSchema$2, canvasReceiptBoxSchema),
|
|
7499
7884
|
affectedBounds: writableBoxSchema.nullable(),
|
|
7500
7885
|
copiedNodeIds: copiedNodeIdsSchema.optional(),
|
|
7501
7886
|
next: array$1(string$1().min(1))
|
|
@@ -7507,7 +7892,8 @@ progression: object$1({
|
|
|
7507
7892
|
});
|
|
7508
7893
|
discriminatedUnion$1("state", [strictObject({ state: literal$1("not-found") }), strictObject({
|
|
7509
7894
|
state: literal$1("committed"),
|
|
7510
|
-
|
|
7895
|
+
/** `url` is the canvas's web address. An API older than the field answers without it. */
|
|
7896
|
+
result: applyCanvasOperationsOutputSchema.extend({ url: url().optional() })
|
|
7511
7897
|
})]);
|
|
7512
7898
|
//#endregion
|
|
7513
7899
|
//#region ../contract/src/canvas/canvas-mutation-review.schema.ts
|
|
@@ -7910,8 +8296,10 @@ progression: object$1({
|
|
|
7910
8296
|
sources: array$1(strictObject({
|
|
7911
8297
|
screenId: uuid$1(),
|
|
7912
8298
|
captureId: uuid$1(),
|
|
7913
|
-
|
|
7914
|
-
|
|
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.")
|
|
7915
8303
|
}),
|
|
7916
8304
|
canvasArrangePreparationSchema,
|
|
7917
8305
|
canvasDuplicatePreparationSchema,
|
|
@@ -7992,7 +8380,11 @@ progression: object$1({
|
|
|
7992
8380
|
job.extend({
|
|
7993
8381
|
state: literal$1("succeeded"),
|
|
7994
8382
|
phase: literal$1("complete"),
|
|
7995
|
-
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
|
+
}),
|
|
7996
8388
|
failure: _null()
|
|
7997
8389
|
}),
|
|
7998
8390
|
job.extend({
|
|
@@ -8381,7 +8773,8 @@ progression: object$1({
|
|
|
8381
8773
|
"inspection",
|
|
8382
8774
|
"snapshot",
|
|
8383
8775
|
"thumbnail",
|
|
8384
|
-
"export"
|
|
8776
|
+
"export",
|
|
8777
|
+
"object-pictures"
|
|
8385
8778
|
]),
|
|
8386
8779
|
scale: number$2().positive(),
|
|
8387
8780
|
maxOutputPixels: canvasRenderPixelLimitSchema.optional(),
|
|
@@ -8452,6 +8845,16 @@ progression: object$1({
|
|
|
8452
8845
|
sourceState: _undefined().optional(),
|
|
8453
8846
|
conversion: canvasConversionRequestSchema,
|
|
8454
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)
|
|
8455
8858
|
})
|
|
8456
8859
|
]);
|
|
8457
8860
|
object$1({
|
|
@@ -8598,6 +9001,7 @@ progression: object$1({
|
|
|
8598
9001
|
nodes: array$1(canvasInspectNodeSummarySchema),
|
|
8599
9002
|
contextRootId: nodeIdSchema.nullable(),
|
|
8600
9003
|
visibleWorldBox: canvasWorldBoundsSchema.nullable(),
|
|
9004
|
+
boxNote: string$1().min(1).optional(),
|
|
8601
9005
|
next: array$1(string$1().min(1)).max(MAX_SELECTION_COMMANDS)
|
|
8602
9006
|
});
|
|
8603
9007
|
//#endregion
|
|
@@ -8606,6 +9010,17 @@ progression: object$1({
|
|
|
8606
9010
|
kind: literal$1("recording"),
|
|
8607
9011
|
recordingId: string$1()
|
|
8608
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
|
+
})]);
|
|
8609
9024
|
object$1({
|
|
8610
9025
|
html: string$1().optional(),
|
|
8611
9026
|
viewport: object$1({
|
|
@@ -8615,7 +9030,8 @@ progression: object$1({
|
|
|
8615
9030
|
atMs: number$2(),
|
|
8616
9031
|
screenId: string$1().nullable().default(null),
|
|
8617
9032
|
sourceNodeId: string$1().optional(),
|
|
8618
|
-
provenance: canvasCaptureProvenanceSchema.optional()
|
|
9033
|
+
provenance: canvasCaptureProvenanceSchema.optional(),
|
|
9034
|
+
landing: captureLandingSchema.optional()
|
|
8619
9035
|
});
|
|
8620
9036
|
object$1({
|
|
8621
9037
|
provenance: canvasCaptureProvenanceSchema.optional(),
|
|
@@ -8743,12 +9159,16 @@ progression: object$1({
|
|
|
8743
9159
|
versionId: uuid$1()
|
|
8744
9160
|
});
|
|
8745
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
|
+
};
|
|
8746
9166
|
object$1({
|
|
8747
9167
|
canvasId: uuid$1(),
|
|
8748
9168
|
documentFormatVersion: canvasDocumentFormatSchema,
|
|
8749
9169
|
versionId: uuid$1(),
|
|
8750
9170
|
expectedVersion: number$2().int().positive()
|
|
8751
|
-
});
|
|
9171
|
+
}).superRefine(refuseUnsafeVersionCopy);
|
|
8752
9172
|
object$1({
|
|
8753
9173
|
canvasId: uuid$1(),
|
|
8754
9174
|
version: number$2().int().positive(),
|
|
@@ -8762,7 +9182,7 @@ progression: object$1({
|
|
|
8762
9182
|
versionId: uuid$1(),
|
|
8763
9183
|
organisationId: union$1([uuid$1(), literal$1("personal")]),
|
|
8764
9184
|
title: string$1().trim().min(1).optional()
|
|
8765
|
-
});
|
|
9185
|
+
}).superRefine(refuseUnsafeVersionCopy);
|
|
8766
9186
|
object$1({
|
|
8767
9187
|
canvasId: uuid$1(),
|
|
8768
9188
|
title: string$1().min(1),
|
|
@@ -9304,9 +9724,9 @@ progression: object$1({
|
|
|
9304
9724
|
//#region ../contract/src/recording/frozen-screen.lib.ts
|
|
9305
9725
|
const META_EVENT = 4;
|
|
9306
9726
|
const FULL_SNAPSHOT$2 = 2;
|
|
9307
|
-
const isObject$
|
|
9308
|
-
const isTimedEvent = (value, type) => isObject$
|
|
9309
|
-
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";
|
|
9310
9730
|
/**
|
|
9311
9731
|
* The durable form of one marked moment. It deliberately contains rrweb's serialized tree,
|
|
9312
9732
|
* not HTML: reparsing `outerHTML` normalises the live DOM and can split working nested controls
|
|
@@ -9335,6 +9755,16 @@ progression: object$1({
|
|
|
9335
9755
|
};
|
|
9336
9756
|
return JSON.stringify(artifact);
|
|
9337
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
|
+
});
|
|
9338
9768
|
//#endregion
|
|
9339
9769
|
//#region ../contract/src/comment/comment.schema.ts
|
|
9340
9770
|
/** How many replies a thread hands back in one go before `hasMoreMessages` takes over. */
|
|
@@ -10628,6 +11058,12 @@ progression: object$1({
|
|
|
10628
11058
|
version: number$2().int().positive()
|
|
10629
11059
|
})]).optional()
|
|
10630
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() });
|
|
10631
11067
|
const MAX_PROTOTYPE_CONTENT_TYPE_LENGTH = 200;
|
|
10632
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" });
|
|
10633
11069
|
const prototypeFileSchema = object$1({
|
|
@@ -10758,6 +11194,30 @@ progression: object$1({
|
|
|
10758
11194
|
(/* @__PURE__ */ string()).check(/* @__PURE__ */ _maxLength(MAX_REASON_LENGTH));
|
|
10759
11195
|
(/* @__PURE__ */ number()).check(/* @__PURE__ */ _gte(0), /* @__PURE__ */ _lte(1)), (/* @__PURE__ */ number()).check(/* @__PURE__ */ _gte(0), /* @__PURE__ */ _lte(1));
|
|
10760
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
|
|
10761
11221
|
//#region ../contract/src/recording/inline-data-asset.lib.ts
|
|
10762
11222
|
const INLINE_IMAGE = /^data:(image\/(?:avif|gif|jpeg|png|webp));base64,([a-z0-9+/]+={0,2})$/iu;
|
|
10763
11223
|
const HASH_RADIX = 16;
|
|
@@ -10801,11 +11261,175 @@ progression: object$1({
|
|
|
10801
11261
|
};
|
|
10802
11262
|
};
|
|
10803
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
|
|
10804
11428
|
//#region ../contract/src/recording/captured-canvas.lib.ts
|
|
10805
11429
|
const CAPTURED_CANVAS_SOURCE_ATTRIBUTE = "data-enhance-canvas-source";
|
|
10806
11430
|
const RR_CANVAS_DATA_URL_ATTRIBUTE = "rr_dataURL";
|
|
10807
|
-
const ELEMENT$
|
|
10808
|
-
const isObject$
|
|
11431
|
+
const ELEMENT$4 = 2;
|
|
11432
|
+
const isObject$3 = (value) => typeof value === "object" && value !== null;
|
|
10809
11433
|
const isLosslessInlineCanvas = (value) => inlineDataAssetReference(value)?.contentType === "image/png";
|
|
10810
11434
|
/** A canvas source produced by capture, either before or after recording-asset externalisation. */
|
|
10811
11435
|
const isCapturedCanvasSource = (value) => typeof value === "string" && (isLosslessInlineCanvas(value) || value.startsWith("/v1/recording-assets/"));
|
|
@@ -10827,12 +11451,12 @@ progression: object$1({
|
|
|
10827
11451
|
};
|
|
10828
11452
|
const blankCanvasPng = (value) => {
|
|
10829
11453
|
const owner = Reflect.get(value, "ownerDocument");
|
|
10830
|
-
if (!isObject$
|
|
11454
|
+
if (!isObject$3(owner)) return null;
|
|
10831
11455
|
const create = Reflect.get(owner, "createElement");
|
|
10832
11456
|
if (typeof create !== "function") return null;
|
|
10833
11457
|
try {
|
|
10834
11458
|
const blank = Reflect.apply(create, owner, ["canvas"]);
|
|
10835
|
-
if (!isObject$
|
|
11459
|
+
if (!isObject$3(blank)) return null;
|
|
10836
11460
|
Reflect.set(blank, "width", Reflect.get(value, "width"));
|
|
10837
11461
|
Reflect.set(blank, "height", Reflect.get(value, "height"));
|
|
10838
11462
|
return encodedPng(blank);
|
|
@@ -10840,20 +11464,27 @@ progression: object$1({
|
|
|
10840
11464
|
return null;
|
|
10841
11465
|
}
|
|
10842
11466
|
};
|
|
10843
|
-
const
|
|
10844
|
-
|
|
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;
|
|
10845
11474
|
const source = encodedPng(value);
|
|
10846
|
-
if (source === null
|
|
10847
|
-
|
|
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 };
|
|
10848
11479
|
};
|
|
10849
|
-
/** Adds readable backing-store pixels
|
|
11480
|
+
/** Adds readable backing-store pixels, or why they could not be read, to each canvas. */
|
|
10850
11481
|
const withReadableCanvasPixels = (node, nodeForId) => {
|
|
10851
|
-
const
|
|
11482
|
+
const read = node.type === ELEMENT$4 && node.tagName === "canvas" && typeof node.id === "number" ? canvasRead(nodeForId(node.id)) : null;
|
|
10852
11483
|
const childNodes = node.childNodes?.map((child) => withReadableCanvasPixels(child, nodeForId));
|
|
10853
|
-
if (
|
|
10854
|
-
const attributes =
|
|
11484
|
+
if (read === null && childNodes === void 0) return node;
|
|
11485
|
+
const attributes = read === null ? void 0 : {
|
|
10855
11486
|
...node.attributes,
|
|
10856
|
-
[RR_CANVAS_DATA_URL_ATTRIBUTE]: source
|
|
11487
|
+
..."source" in read ? { [RR_CANVAS_DATA_URL_ATTRIBUTE]: read.source } : { [CAPTURED_MEDIA_REASON_ATTRIBUTE]: read.reason }
|
|
10857
11488
|
};
|
|
10858
11489
|
return {
|
|
10859
11490
|
...node,
|
|
@@ -10862,9 +11493,19 @@ progression: object$1({
|
|
|
10862
11493
|
};
|
|
10863
11494
|
};
|
|
10864
11495
|
//#endregion
|
|
11496
|
+
//#region ../contract/src/recording/captured-color-scheme.lib.ts
|
|
11497
|
+
const CAPTURED_COLOR_SCHEME_ATTRIBUTE = "data-enhance-captured-color-scheme";
|
|
11498
|
+
const capturedColorSchemeIn = (value) => value === "light" || value === "dark" ? value : null;
|
|
11499
|
+
//#endregion
|
|
10865
11500
|
//#region ../contract/src/recording/captured-font-evidence.lib.ts
|
|
10866
11501
|
const CAPTURED_LOADED_FONTS_ATTRIBUTE = "data-enhance-loaded-captured-fonts";
|
|
10867
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";
|
|
10868
11509
|
const loadedCapturedFontFamilies = (fonts) => {
|
|
10869
11510
|
if (typeof fonts !== "object" || fonts === null) return [];
|
|
10870
11511
|
const forEach = Reflect.get(fonts, "forEach");
|
|
@@ -10878,8 +11519,109 @@ progression: object$1({
|
|
|
10878
11519
|
return [...found];
|
|
10879
11520
|
};
|
|
10880
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
|
|
10881
11623
|
//#region ../contract/src/recording/full-page-screen.lib.ts
|
|
10882
|
-
const PERCENT = 100;
|
|
11624
|
+
const PERCENT$1 = 100;
|
|
10883
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;
|
|
10884
11626
|
const viewportUnit = (unit, options) => {
|
|
10885
11627
|
if (unit.endsWith("min")) return Math.min(options.width, options.height);
|
|
@@ -10890,8 +11632,14 @@ progression: object$1({
|
|
|
10890
11632
|
const fullPageScreenCss = (css, options) => css.replaceAll(CSS_TOKEN, (token, media, amount, unit) => {
|
|
10891
11633
|
if (media !== void 0) return `@media ${options.matchesMedia(media) ? "all" : "not all"}{`;
|
|
10892
11634
|
if (amount === void 0) return token;
|
|
10893
|
-
return `${String(Number(amount) * viewportUnit(String(unit).toLowerCase(), options) / PERCENT)}px`;
|
|
11635
|
+
return `${String(Number(amount) * viewportUnit(String(unit).toLowerCase(), options) / PERCENT$1)}px`;
|
|
10894
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
|
+
};
|
|
10895
11643
|
const fullPageAttributes = (node, options) => {
|
|
10896
11644
|
const attributes = node.attributes === void 0 ? void 0 : { ...node.attributes };
|
|
10897
11645
|
if (attributes !== void 0) {
|
|
@@ -10899,14 +11647,10 @@ progression: object$1({
|
|
|
10899
11647
|
const value = attributes[key];
|
|
10900
11648
|
if (typeof value === "string") attributes[key] = fullPageScreenCss(value, options);
|
|
10901
11649
|
}
|
|
10902
|
-
const override = node.id === void 0 ? void 0 : options.overrides.get(node.id);
|
|
10903
11650
|
const inlineStyle = typeof attributes["style"] === "string" ? attributes["style"] : "";
|
|
10904
|
-
|
|
10905
|
-
|
|
10906
|
-
attributes["
|
|
10907
|
-
}
|
|
10908
|
-
if (node.tagName === "html" || node.tagName === "body") {
|
|
10909
|
-
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(";");
|
|
10910
11654
|
attributes["rr_scrollTop"] = 0;
|
|
10911
11655
|
}
|
|
10912
11656
|
}
|
|
@@ -10949,29 +11693,280 @@ progression: object$1({
|
|
|
10949
11693
|
};
|
|
10950
11694
|
};
|
|
10951
11695
|
//#endregion
|
|
10952
|
-
//#region ../contract/src/recording/
|
|
10953
|
-
|
|
10954
|
-
const
|
|
10955
|
-
|
|
10956
|
-
|
|
10957
|
-
|
|
10958
|
-
|
|
10959
|
-
|
|
10960
|
-
return null;
|
|
10961
|
-
}
|
|
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;
|
|
10962
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");
|
|
10963
11720
|
//#endregion
|
|
10964
|
-
//#region ../contract/src/recording/
|
|
11721
|
+
//#region ../contract/src/recording/unsupported-surfaces.lib.ts
|
|
11722
|
+
const ELEMENT$3 = 2;
|
|
10965
11723
|
const FULL_SNAPSHOT$1 = 2;
|
|
10966
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;
|
|
10967
11728
|
const isUnknownArray$1 = (value) => Array.isArray(value);
|
|
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);
|
|
10968
11963
|
const recordIn$1 = (value) => typeof value === "object" && value !== null ? { ...value } : null;
|
|
10969
11964
|
const unknownArrayIn = (value) => {
|
|
10970
|
-
if (!isUnknownArray
|
|
11965
|
+
if (!isUnknownArray(value)) return [];
|
|
10971
11966
|
return [...value];
|
|
10972
11967
|
};
|
|
10973
|
-
const isSnapshotNode
|
|
10974
|
-
const snapshotNodeIn = (value) => isSnapshotNode
|
|
11968
|
+
const isSnapshotNode = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "type") === "number";
|
|
11969
|
+
const snapshotNodeIn = (value) => isSnapshotNode(value) ? value : null;
|
|
10975
11970
|
const eventPartIn = (event, type) => {
|
|
10976
11971
|
const outer = recordIn$1(event);
|
|
10977
11972
|
if (outer === null || Reflect.get(outer, "type") !== type) return null;
|
|
@@ -10983,7 +11978,7 @@ progression: object$1({
|
|
|
10983
11978
|
};
|
|
10984
11979
|
};
|
|
10985
11980
|
const fullSnapshotInEvent = (event) => {
|
|
10986
|
-
const part = eventPartIn(event, FULL_SNAPSHOT
|
|
11981
|
+
const part = eventPartIn(event, FULL_SNAPSHOT);
|
|
10987
11982
|
if (part === null) return null;
|
|
10988
11983
|
const node = snapshotNodeIn(Reflect.get(part.data, "node"));
|
|
10989
11984
|
return node === null ? null : {
|
|
@@ -10992,7 +11987,7 @@ progression: object$1({
|
|
|
10992
11987
|
};
|
|
10993
11988
|
};
|
|
10994
11989
|
const incrementalIn = (event) => {
|
|
10995
|
-
const part = eventPartIn(event, INCREMENTAL_SNAPSHOT
|
|
11990
|
+
const part = eventPartIn(event, INCREMENTAL_SNAPSHOT);
|
|
10996
11991
|
if (part === null) return null;
|
|
10997
11992
|
const source = Reflect.get(part.data, "source");
|
|
10998
11993
|
return typeof source === "number" ? {
|
|
@@ -11195,6 +12190,7 @@ progression: object$1({
|
|
|
11195
12190
|
const isSourceSet = name === "srcset" || name === "imagesrcset";
|
|
11196
12191
|
if (attributes[UNSUPPORTED_PLACEHOLDER] !== void 0 && (isSourceSet || PLAIN_URL_ATTRIBUTES.has(name))) return [];
|
|
11197
12192
|
if (isSourceSet) return srcsetReferences(value);
|
|
12193
|
+
if (capturedMediaPictureAttribute(tagName, attributes) === name) return whole(value);
|
|
11198
12194
|
if (tagName === "canvas" && (name === "rr_dataURL" || name === "data-enhance-canvas-source")) return whole(value);
|
|
11199
12195
|
if (PLAIN_URL_ATTRIBUTES.has(name)) return INERT_SOURCE_TAGS.has(tagName) ? [] : whole(value);
|
|
11200
12196
|
if (name === "href" || name === "xlink:href") {
|
|
@@ -11820,254 +12816,67 @@ missingAssetCount: number$2().int().min(0) });
|
|
|
11820
12816
|
download: signedDownloadSchema
|
|
11821
12817
|
}), recordingChunkManifestBaseSchema.extend({ state: literal$1("missing") })]);
|
|
11822
12818
|
const recordingAudioManifestBaseSchema = object$1({
|
|
11823
|
-
seq: number$2().int().min(0),
|
|
11824
|
-
firstMs: number$2().int().min(0),
|
|
11825
|
-
lastMs: number$2().int().min(0),
|
|
11826
|
-
epoch: number$2().int().min(0),
|
|
11827
|
-
startsEpoch: boolean$1()
|
|
11828
|
-
});
|
|
11829
|
-
const recordingAudioManifestSchema = discriminatedUnion$1("state", [recordingAudioManifestBaseSchema.extend({
|
|
11830
|
-
state: literal$1("available"),
|
|
11831
|
-
download: signedDownloadSchema
|
|
11832
|
-
}), recordingAudioManifestBaseSchema.extend({ state: literal$1("missing") })]);
|
|
11833
|
-
object$1({
|
|
11834
|
-
recordingId: uuid$1(),
|
|
11835
|
-
durationMs: number$2().int().min(0),
|
|
11836
|
-
viewport: viewportSchema,
|
|
11837
|
-
/** The page it was taken from. A replay resolves its mirrored assets against this. */
|
|
11838
|
-
sourceUrl: string$1(),
|
|
11839
|
-
interrupted: boolean$1(),
|
|
11840
|
-
integrity: recordingIntegritySchema,
|
|
11841
|
-
chunks: array$1(recordingChunkManifestSchema),
|
|
11842
|
-
/** Null when the walkthrough has no voice on it, which the player draws differently. */
|
|
11843
|
-
audio: object$1({
|
|
11844
|
-
mimeType: string$1(),
|
|
11845
|
-
chunks: array$1(recordingAudioManifestSchema)
|
|
11846
|
-
}).nullable(),
|
|
11847
|
-
/** Our copy of what the page loaded, by the address the page used. Empty is a real answer. */
|
|
11848
|
-
assets: array$1(object$1({
|
|
11849
|
-
url: string$1(),
|
|
11850
|
-
contentType: string$1(),
|
|
11851
|
-
/** Stable identity; it can safely live in cached rrweb events and frozen screens. */
|
|
11852
|
-
path: string$1().startsWith("/v1/recording-assets/")
|
|
11853
|
-
})),
|
|
11854
|
-
/** How much of the page we could not fetch. A replay says so rather than rendering short. */
|
|
11855
|
-
missingAssetCount: number$2().int().min(0),
|
|
11856
|
-
missingAssetUrls: array$1(string$1()).optional()
|
|
11857
|
-
});
|
|
11858
|
-
const refreshRecordingUploadInputSchema = object$1({
|
|
11859
|
-
recordingId: uuid$1(),
|
|
11860
|
-
track: recordingTrackSchema,
|
|
11861
|
-
index: number$2().int().min(0)
|
|
11862
|
-
});
|
|
11863
|
-
object$1({ upload: signedUploadSchema });
|
|
11864
|
-
refreshRecordingUploadInputSchema.extend({ etag: string$1().min(1).max(200) });
|
|
11865
|
-
object$1({ integrity: recordingIntegritySchema });
|
|
11866
|
-
object$1({ canvasId: uuid$1() });
|
|
11867
|
-
cappedSchema(recordingSummarySchema).extend({
|
|
11868
|
-
/** Completed recordings left out because their facts are missing; the API logs each by ID. */
|
|
11869
|
-
unreadableCount: number$2().int().min(0) });
|
|
11870
|
-
object$1({ recordingId: uuid$1() });
|
|
11871
|
-
object$1({
|
|
11872
|
-
recordingId: uuid$1(),
|
|
11873
|
-
discarded: literal$1(true)
|
|
11874
|
-
});
|
|
11875
|
-
object$1({
|
|
11876
|
-
canvasId: uuid$1(),
|
|
11877
|
-
recordingId: uuid$1()
|
|
11878
|
-
});
|
|
11879
|
-
object$1({
|
|
11880
|
-
recordingId: uuid$1(),
|
|
11881
|
-
/** Screens survive with their provenance nulled. That is what makes iteration safe. */
|
|
11882
|
-
detachedScreenCount: number$2().int().min(0)
|
|
11883
|
-
});
|
|
11884
|
-
[`[data-enhance-unsupported]:not([data-enhance-unsupported-hidden]):not([style*="display: none"]) {
|
|
11885
|
-
align-items: center !important;
|
|
11886
|
-
background-color: #f7f7f8 !important;
|
|
11887
|
-
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;
|
|
11888
|
-
border: 1px solid #c7c7cc !important;
|
|
11889
|
-
box-sizing: border-box !important;
|
|
11890
|
-
color: #4f4f55 !important;
|
|
11891
|
-
display: flex !important;
|
|
11892
|
-
font: 500 14px/1.4 Inter, ui-sans-serif, system-ui, sans-serif !important;
|
|
11893
|
-
justify-content: center !important;
|
|
11894
|
-
overflow: hidden !important;
|
|
11895
|
-
text-align: center !important;
|
|
11896
|
-
}`, `[data-enhance-unsupported-hidden], [data-enhance-unsupported][style*="display: none"] {
|
|
11897
|
-
display: none !important;
|
|
11898
|
-
}`].join("\n");
|
|
11899
|
-
//#endregion
|
|
11900
|
-
//#region ../contract/src/recording/unsupported-surfaces.lib.ts
|
|
11901
|
-
const ELEMENT = 2;
|
|
11902
|
-
const FULL_SNAPSHOT = 2;
|
|
11903
|
-
const INCREMENTAL_SNAPSHOT = 3;
|
|
11904
|
-
const MUTATION = 0;
|
|
11905
|
-
const OMIT_RECORDER_HOST = Symbol("omit-recorder-host");
|
|
11906
|
-
const isObject = (value) => typeof value === "object" && value !== null;
|
|
11907
|
-
const isUnknownArray = (value) => Array.isArray(value);
|
|
11908
|
-
const isSnapshotNode = (value) => isObject(value) && typeof value["type"] === "number";
|
|
11909
|
-
const withoutRecorderHost = (node) => {
|
|
11910
|
-
if (node.type === ELEMENT && node.tagName === "enhance3-recorder") return null;
|
|
11911
|
-
if (node.childNodes === void 0) return node;
|
|
11912
|
-
return {
|
|
11913
|
-
...node,
|
|
11914
|
-
childNodes: node.childNodes.flatMap((child) => {
|
|
11915
|
-
const kept = withoutRecorderHost(child);
|
|
11916
|
-
return kept === null ? [] : [kept];
|
|
11917
|
-
})
|
|
11918
|
-
};
|
|
11919
|
-
};
|
|
11920
|
-
const iframeSurfaceLabel = (attributes) => {
|
|
11921
|
-
const recordedSource = attributes["rr_src"];
|
|
11922
|
-
const isExplicitlyHidden = attributes["aria-hidden"] === "true" || attributes["width"] === "0" && attributes["height"] === "0";
|
|
11923
|
-
if (typeof recordedSource === "string" && !isExplicitlyHidden) return attributes["data-enhance-frame-unloaded"] === "" ? "Embedded content not loaded" : "Embedded content not supported";
|
|
11924
|
-
const source = attributes["src"] ?? attributes["srcdoc"];
|
|
11925
|
-
return typeof source === "string" && source.startsWith("blob:") ? "Embedded content not supported" : null;
|
|
11926
|
-
};
|
|
11927
|
-
const unsupportedSurfaceLabel = (tagName, attributes) => {
|
|
11928
|
-
switch (tagName) {
|
|
11929
|
-
case "canvas": return capturedCanvasSourceIn(attributes) === null ? "Canvas not supported" : null;
|
|
11930
|
-
case "video": return "Video not supported";
|
|
11931
|
-
case "object":
|
|
11932
|
-
case "embed": return "Embedded content not supported";
|
|
11933
|
-
case "img":
|
|
11934
|
-
case "image": {
|
|
11935
|
-
const source = attributes["src"] ?? attributes["href"] ?? attributes["xlink:href"];
|
|
11936
|
-
return typeof source === "string" && source.startsWith("blob:") ? "Image not supported" : null;
|
|
11937
|
-
}
|
|
11938
|
-
case "iframe": return iframeSurfaceLabel(attributes);
|
|
11939
|
-
case void 0: return null;
|
|
11940
|
-
default: return null;
|
|
11941
|
-
}
|
|
11942
|
-
};
|
|
11943
|
-
const labelFor = (node) => {
|
|
11944
|
-
if (node.type !== ELEMENT) return null;
|
|
11945
|
-
const attributes = node.attributes ?? {};
|
|
11946
|
-
const placeholder = attributes["data-enhance-unsupported"];
|
|
11947
|
-
if (typeof placeholder === "string" && node.tagName === "div") return placeholder;
|
|
11948
|
-
if (node.tagName === "iframe" && attributes["data-enhance-frame-unloaded"] === "") return iframeSurfaceLabel(attributes);
|
|
11949
|
-
const className = attributes["class"];
|
|
11950
|
-
const wasUnsupported = typeof className === "string" && className.split(/\s+/u).includes("enhance3-unsupported-surface");
|
|
11951
|
-
const wasBlocked = typeof attributes["rr_width"] === "string" && typeof attributes["rr_height"] === "string";
|
|
11952
|
-
if ((wasUnsupported || wasBlocked) && node.tagName === "iframe") return "Embedded content not supported";
|
|
11953
|
-
if ((wasUnsupported || wasBlocked) && (node.tagName === "img" || node.tagName === "image")) return "Image not supported";
|
|
11954
|
-
return unsupportedSurfaceLabel(node.tagName, attributes);
|
|
11955
|
-
};
|
|
11956
|
-
const placeholderAttributes = (attributes) => Object.fromEntries(Object.entries(attributes).flatMap(([name, value]) => {
|
|
11957
|
-
if (name.startsWith("rr_media")) return [];
|
|
11958
|
-
if (name !== "class" || typeof value !== "string") return [[name, value]];
|
|
11959
|
-
const cleaned = value.split(/\s+/u).filter((part) => part.length > 0 && part !== "enhance3-unsupported-surface").join(" ");
|
|
11960
|
-
return cleaned.length === 0 ? [] : [[name, cleaned]];
|
|
11961
|
-
}));
|
|
11962
|
-
const withoutFrameNavigation = (attributes) => Object.fromEntries(Object.entries(attributes).filter(([name]) => name !== "src" && name !== "rr_src" && name !== "srcdoc"));
|
|
11963
|
-
const wasDisplayNone = (attributes) => {
|
|
11964
|
-
const style = attributes["style"];
|
|
11965
|
-
return typeof style === "string" && /(?:^|;)\s*display\s*:\s*none(?:\s*!important)?\s*(?:;|$)/iu.test(style);
|
|
11966
|
-
};
|
|
11967
|
-
const wasZeroSizedBlock = (attributes) => {
|
|
11968
|
-
const width = attributes["rr_width"];
|
|
11969
|
-
const height = attributes["rr_height"];
|
|
11970
|
-
return typeof width === "string" && typeof height === "string" && Number(width.replace(/px$/u, "")) === 0 && Number(height.replace(/px$/u, "")) === 0;
|
|
11971
|
-
};
|
|
11972
|
-
const isExplicitlyHiddenFrame = (attributes) => attributes["aria-hidden"] === "true" || attributes["width"] === "0" && attributes["height"] === "0";
|
|
11973
|
-
const isUncapturedNavigatedFrame = (node) => {
|
|
11974
|
-
if (node.tagName !== "iframe") return false;
|
|
11975
|
-
const attributes = node.attributes ?? {};
|
|
11976
|
-
if (isExplicitlyHiddenFrame(attributes)) return false;
|
|
11977
|
-
const source = attributes["src"];
|
|
11978
|
-
if (!(typeof attributes["srcdoc"] !== "string" && typeof source === "string" && source !== "" && source !== "about:blank")) return false;
|
|
11979
|
-
return node.childNodes?.some((child) => child.type === 0) !== true;
|
|
11980
|
-
};
|
|
11981
|
-
/**
|
|
11982
|
-
* The same rrweb node, except a non-serialisable surface becomes an ordinary div. rrweb's block
|
|
11983
|
-
* selector supplies `rr_width` and `rr_height`; keeping them makes the replacement occupy the
|
|
11984
|
-
* exact rectangle the original did without keeping pixels that cannot become primitives later.
|
|
11985
|
-
*/
|
|
11986
|
-
const replaceUnsupportedSurfaces = (node, onUnsupported) => {
|
|
11987
|
-
const label = labelFor(node) ?? (isUncapturedNavigatedFrame(node) ? "Embedded content not supported" : null);
|
|
11988
|
-
if (label !== null) {
|
|
11989
|
-
onUnsupported?.(label);
|
|
11990
|
-
const attributes = placeholderAttributes(node.attributes ?? {});
|
|
11991
|
-
if (node.tagName === "iframe") return {
|
|
11992
|
-
...node,
|
|
11993
|
-
attributes: {
|
|
11994
|
-
...withoutFrameNavigation(attributes),
|
|
11995
|
-
"aria-hidden": "true",
|
|
11996
|
-
"data-enhance-unsupported": label,
|
|
11997
|
-
...(wasDisplayNone(attributes) || wasZeroSizedBlock(attributes)) && { "data-enhance-unsupported-hidden": "" },
|
|
11998
|
-
role: "img"
|
|
11999
|
-
},
|
|
12000
|
-
childNodes: []
|
|
12001
|
-
};
|
|
12002
|
-
return {
|
|
12003
|
-
...node,
|
|
12004
|
-
tagName: "div",
|
|
12005
|
-
attributes: {
|
|
12006
|
-
...attributes,
|
|
12007
|
-
"aria-hidden": "true",
|
|
12008
|
-
"data-enhance-unsupported": label,
|
|
12009
|
-
role: "img"
|
|
12010
|
-
},
|
|
12011
|
-
childNodes: []
|
|
12012
|
-
};
|
|
12013
|
-
}
|
|
12014
|
-
if (node.type === ELEMENT && node.tagName === "script") return {
|
|
12015
|
-
...node,
|
|
12016
|
-
childNodes: []
|
|
12017
|
-
};
|
|
12018
|
-
return node.childNodes === void 0 ? node : {
|
|
12019
|
-
...node,
|
|
12020
|
-
childNodes: node.childNodes.map((child) => replaceUnsupportedSurfaces(child, onUnsupported))
|
|
12021
|
-
};
|
|
12022
|
-
};
|
|
12023
|
-
const replaceFullSnapshot = (event, onUnsupported) => {
|
|
12024
|
-
const data = event["data"];
|
|
12025
|
-
if (!isObject(data)) return event;
|
|
12026
|
-
const node = data["node"];
|
|
12027
|
-
if (!isSnapshotNode(node)) return event;
|
|
12028
|
-
const prepared = withoutRecorderHost(replaceUnsupportedSurfaces(node, onUnsupported));
|
|
12029
|
-
if (prepared === null) return event;
|
|
12030
|
-
return {
|
|
12031
|
-
...event,
|
|
12032
|
-
data: {
|
|
12033
|
-
...data,
|
|
12034
|
-
node: prepared
|
|
12035
|
-
}
|
|
12036
|
-
};
|
|
12037
|
-
};
|
|
12038
|
-
const replaceAddedNode = (add, onUnsupported) => {
|
|
12039
|
-
if (!isObject(add)) return add;
|
|
12040
|
-
const node = add["node"];
|
|
12041
|
-
if (!isSnapshotNode(node)) return add;
|
|
12042
|
-
const prepared = withoutRecorderHost(replaceUnsupportedSurfaces(node, onUnsupported));
|
|
12043
|
-
return prepared === null ? OMIT_RECORDER_HOST : {
|
|
12044
|
-
...add,
|
|
12045
|
-
node: prepared
|
|
12046
|
-
};
|
|
12047
|
-
};
|
|
12048
|
-
const replaceMutation = (event, onUnsupported) => {
|
|
12049
|
-
const data = event["data"];
|
|
12050
|
-
if (!isObject(data) || data["source"] !== MUTATION) return event;
|
|
12051
|
-
const adds = data["adds"];
|
|
12052
|
-
if (!isUnknownArray(adds)) return event;
|
|
12053
|
-
return {
|
|
12054
|
-
...event,
|
|
12055
|
-
data: {
|
|
12056
|
-
...data,
|
|
12057
|
-
adds: adds.flatMap((add) => {
|
|
12058
|
-
const prepared = replaceAddedNode(add, onUnsupported);
|
|
12059
|
-
return prepared === OMIT_RECORDER_HOST ? [] : [prepared];
|
|
12060
|
-
})
|
|
12061
|
-
}
|
|
12062
|
-
};
|
|
12063
|
-
};
|
|
12064
|
-
/** @justified intent Keep fallbacks honest and omit recorder-owned UI. */
|
|
12065
|
-
const replaceUnsupportedSurfacesInEvent = (event, onUnsupported) => {
|
|
12066
|
-
if (!isObject(event)) return event;
|
|
12067
|
-
if (event["type"] === FULL_SNAPSHOT) return replaceFullSnapshot(event, onUnsupported);
|
|
12068
|
-
if (event["type"] === INCREMENTAL_SNAPSHOT) return replaceMutation(event, onUnsupported);
|
|
12069
|
-
return event;
|
|
12070
|
-
};
|
|
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
|
+
});
|
|
12071
12880
|
object$1({
|
|
12072
12881
|
/**
|
|
12073
12882
|
* Client-minted, once per capture attempt. A retry is the same screen; a re-capture at the
|
|
@@ -12091,6 +12900,8 @@ unreadableCount: number$2().int().min(0) });
|
|
|
12091
12900
|
});
|
|
12092
12901
|
object$1({
|
|
12093
12902
|
screenId: uuid$1(),
|
|
12903
|
+
/** Where the screen's files are stored; a capture names its stored copies by it. */
|
|
12904
|
+
assetBundleId: uuid$1().nullable(),
|
|
12094
12905
|
/** Re-issued on every call, because the usual reason for a retry is an expired presign. */
|
|
12095
12906
|
upload: signedUploadSchema,
|
|
12096
12907
|
alreadyExists: boolean$1(),
|
|
@@ -12388,7 +13199,9 @@ unreadableCount: number$2().int().min(0) });
|
|
|
12388
13199
|
"clipboard-unavailable",
|
|
12389
13200
|
"clipboard-image-pending",
|
|
12390
13201
|
"clipboard-image-unavailable",
|
|
13202
|
+
"paste-content-refused",
|
|
12391
13203
|
"edit-target-unsupported",
|
|
13204
|
+
"edit-result-invalid",
|
|
12392
13205
|
"react-hook-order",
|
|
12393
13206
|
"menu-rows-unsupported"
|
|
12394
13207
|
]),
|
|
@@ -12424,6 +13237,7 @@ unreadableCount: number$2().int().min(0) });
|
|
|
12424
13237
|
subsystem: _enum$1([
|
|
12425
13238
|
"menu",
|
|
12426
13239
|
"menu-picture",
|
|
13240
|
+
"arrival-cue",
|
|
12427
13241
|
"unknown"
|
|
12428
13242
|
]).optional(),
|
|
12429
13243
|
repeats: count$1.optional(),
|
|
@@ -12498,7 +13312,18 @@ unreadableCount: number$2().int().min(0) });
|
|
|
12498
13312
|
"whole-value-text",
|
|
12499
13313
|
"retrying",
|
|
12500
13314
|
"recovery",
|
|
12501
|
-
"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"
|
|
12502
13327
|
];
|
|
12503
13328
|
const CANVAS_SYNC_DETAILS = [
|
|
12504
13329
|
...CLIENT_SAVE_ISSUES,
|
|
@@ -12535,7 +13360,8 @@ unreadableCount: number$2().int().min(0) });
|
|
|
12535
13360
|
"view-only",
|
|
12536
13361
|
"sign-in",
|
|
12537
13362
|
"gone",
|
|
12538
|
-
"restored"
|
|
13363
|
+
"restored",
|
|
13364
|
+
"update-required"
|
|
12539
13365
|
];
|
|
12540
13366
|
/** Whether a recovery state began in this visit or was reopened from the browser copy. */
|
|
12541
13367
|
const CANVAS_SYNC_EPISODES = ["new", "reopened"];
|
|
@@ -12577,6 +13403,7 @@ unreadableCount: number$2().int().min(0) });
|
|
|
12577
13403
|
"refused",
|
|
12578
13404
|
"copy-refused",
|
|
12579
13405
|
"copy-preview",
|
|
13406
|
+
"update-required",
|
|
12580
13407
|
"unknown"
|
|
12581
13408
|
];
|
|
12582
13409
|
const CANVAS_SAVE_SEVERITIES = [
|
|
@@ -12600,7 +13427,8 @@ unreadableCount: number$2().int().min(0) });
|
|
|
12600
13427
|
"retry-upload",
|
|
12601
13428
|
"choose-file",
|
|
12602
13429
|
"remove-screen",
|
|
12603
|
-
"go-to-canvases"
|
|
13430
|
+
"go-to-canvases",
|
|
13431
|
+
"reload"
|
|
12604
13432
|
];
|
|
12605
13433
|
const CANVAS_SAVE_OUTCOMES = [
|
|
12606
13434
|
"saved",
|
|
@@ -12694,6 +13522,7 @@ unreadableCount: number$2().int().min(0) });
|
|
|
12694
13522
|
durationMs: number$2().int().nonnegative(),
|
|
12695
13523
|
pendingChanges: number$2().int().nonnegative(),
|
|
12696
13524
|
reason: _enum$1(CANVAS_SYNC_DETAILS).optional(),
|
|
13525
|
+
readOutcome: _enum$1(CANVAS_SYNC_READ_OUTCOMES).optional(),
|
|
12697
13526
|
status: _enum$1(CANVAS_SYNC_REPORT_STATUSES).optional(),
|
|
12698
13527
|
episode: _enum$1(CANVAS_SYNC_EPISODES).optional(),
|
|
12699
13528
|
trace: canvasSaveTraceSchema.optional()
|
|
@@ -12704,7 +13533,8 @@ unreadableCount: number$2().int().min(0) });
|
|
|
12704
13533
|
"delivered",
|
|
12705
13534
|
"failed",
|
|
12706
13535
|
"disabled",
|
|
12707
|
-
"no-identity"
|
|
13536
|
+
"no-identity",
|
|
13537
|
+
"expired"
|
|
12708
13538
|
]).optional()
|
|
12709
13539
|
});
|
|
12710
13540
|
discriminatedUnion$1("type", [object$1({ type: literal$1("enhance3:extension-probe") }).strict(), object$1({ type: literal$1("enhance3:extension-present") }).strict()]);
|
|
@@ -12946,6 +13776,419 @@ unreadableCount: number$2().int().min(0) });
|
|
|
12946
13776
|
})
|
|
12947
13777
|
]);
|
|
12948
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
|
|
12949
14192
|
//#region ../capture-browser/src/cssom-style-correction.lib.ts
|
|
12950
14193
|
const EMPTY_DECLARATION = /(?<=[{;])\s*([-\w]+)\s*:\s*;/dgu;
|
|
12951
14194
|
const erasedProperties = (cssText) => {
|
|
@@ -13044,48 +14287,6 @@ unreadableCount: number$2().int().min(0) });
|
|
|
13044
14287
|
return serialized;
|
|
13045
14288
|
};
|
|
13046
14289
|
//#endregion
|
|
13047
|
-
//#region ../capture-browser/src/full-page-capture.lib.ts
|
|
13048
|
-
const PRIMARY_SCROLL_WIDTH_RATIO = .7;
|
|
13049
|
-
const PRIMARY_SCROLL_HEIGHT_RATIO = .5;
|
|
13050
|
-
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));
|
|
13051
|
-
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"]];
|
|
13052
|
-
const fullPageCaptureLayout = (document, idForNode) => {
|
|
13053
|
-
const width = document.documentElement.clientWidth;
|
|
13054
|
-
const height = document.documentElement.clientHeight;
|
|
13055
|
-
const view = document.defaultView;
|
|
13056
|
-
let fullHeight = Math.max(height, document.documentElement.scrollHeight, document.body.scrollHeight);
|
|
13057
|
-
const overrides = /* @__PURE__ */ new Map();
|
|
13058
|
-
if (view !== null) for (const element of document.querySelectorAll("*")) {
|
|
13059
|
-
const id = idForNode(element);
|
|
13060
|
-
if (id < 0) continue;
|
|
13061
|
-
const style = view.getComputedStyle(element);
|
|
13062
|
-
const rules = [];
|
|
13063
|
-
if (style.position === "fixed") rules.push(...fixedPositionRules(element, style, width, height));
|
|
13064
|
-
if (element.clientWidth >= width * PRIMARY_SCROLL_WIDTH_RATIO && element.clientHeight >= height * PRIMARY_SCROLL_HEIGHT_RATIO && element.scrollHeight > element.clientHeight + 1 && [
|
|
13065
|
-
"auto",
|
|
13066
|
-
"scroll",
|
|
13067
|
-
"hidden"
|
|
13068
|
-
].includes(style.overflowY)) {
|
|
13069
|
-
const extent = element.scrollHeight;
|
|
13070
|
-
fullHeight = Math.max(fullHeight, Math.ceil(element.getBoundingClientRect().top + (document.scrollingElement?.scrollTop ?? 0) + extent));
|
|
13071
|
-
rules.push(`height:${String(extent)}px!important;max-height:none!important;overflow-y:visible!important`);
|
|
13072
|
-
}
|
|
13073
|
-
overrides.set(id, rules.join(";"));
|
|
13074
|
-
}
|
|
13075
|
-
return {
|
|
13076
|
-
options: {
|
|
13077
|
-
width,
|
|
13078
|
-
height,
|
|
13079
|
-
overrides: new Map([...overrides].filter(([, rule]) => rule !== "")),
|
|
13080
|
-
matchesMedia: (condition) => view?.matchMedia(condition).matches ?? false
|
|
13081
|
-
},
|
|
13082
|
-
viewport: {
|
|
13083
|
-
width,
|
|
13084
|
-
height: fullHeight
|
|
13085
|
-
}
|
|
13086
|
-
};
|
|
13087
|
-
};
|
|
13088
|
-
//#endregion
|
|
13089
14290
|
//#region ../capture-browser/src/marked-snapshot-tree.lib.ts
|
|
13090
14291
|
const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13091
14292
|
const childEntries = (record) => Object.entries(record).filter(([key]) => key !== "attributes");
|
|
@@ -17429,6 +18630,79 @@ unreadableCount: number$2().int().min(0) });
|
|
|
17429
18630
|
postcss.Root;
|
|
17430
18631
|
postcss.Node;
|
|
17431
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
|
|
17432
18706
|
//#region ../capture-browser/src/captured-font-evidence.lib.ts
|
|
17433
18707
|
/** The families with a face the page tried and could not load, and no face it did load. */
|
|
17434
18708
|
const unavailableFontFamilies = (fonts, loaded) => {
|
|
@@ -17445,15 +18719,17 @@ unreadableCount: number$2().int().min(0) });
|
|
|
17445
18719
|
return [...failed];
|
|
17446
18720
|
};
|
|
17447
18721
|
/**
|
|
17448
|
-
* Keeps the page's font evidence: the families it loaded, which a replay may not rebuild,
|
|
17449
|
-
*
|
|
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.
|
|
17450
18725
|
*/
|
|
17451
|
-
const markCapturedFontEvidence = (node, document) => {
|
|
18726
|
+
const markCapturedFontEvidence = (node, document, blockSelector) => {
|
|
17452
18727
|
const html = node?.childNodes?.find((child) => child.tagName === "html");
|
|
17453
18728
|
if (html?.attributes === void 0) return;
|
|
17454
18729
|
const loaded = loadedCapturedFontFamilies(document.fonts);
|
|
17455
18730
|
Reflect.set(html.attributes, CAPTURED_LOADED_FONTS_ATTRIBUTE, JSON.stringify(loaded));
|
|
17456
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)));
|
|
17457
18733
|
};
|
|
17458
18734
|
//#endregion
|
|
17459
18735
|
//#region ../capture-browser/src/snapshot-document.lib.ts
|
|
@@ -17528,8 +18804,10 @@ unreadableCount: number$2().int().min(0) });
|
|
|
17528
18804
|
...options.blockSelector !== void 0 && { blockSelector: options.blockSelector },
|
|
17529
18805
|
onSerialize: options.onSerialize
|
|
17530
18806
|
});
|
|
17531
|
-
markCapturedFontEvidence(node, document);
|
|
17532
|
-
|
|
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);
|
|
17533
18811
|
};
|
|
17534
18812
|
const isBlocked = (node, selector) => {
|
|
17535
18813
|
const matches = Reflect.get(node, "matches");
|
|
@@ -17772,15 +19050,52 @@ unreadableCount: number$2().int().min(0) });
|
|
|
17772
19050
|
};
|
|
17773
19051
|
//#endregion
|
|
17774
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
|
+
*/
|
|
17775
19092
|
const captureRootStyle = (document) => {
|
|
17776
19093
|
const pinned = document.createElement("div").style;
|
|
17777
19094
|
const computed = document.defaultView?.getComputedStyle(document.documentElement);
|
|
17778
19095
|
if (computed === void 0) return "";
|
|
17779
|
-
|
|
17780
|
-
|
|
17781
|
-
|
|
17782
|
-
if (value !== "") pinned.setProperty(property, value);
|
|
17783
|
-
}
|
|
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);
|
|
17784
19099
|
return pinned.cssText;
|
|
17785
19100
|
};
|
|
17786
19101
|
const withRootStyle = (attributes, rootStyle) => {
|
|
@@ -17791,6 +19106,24 @@ unreadableCount: number$2().int().min(0) });
|
|
|
17791
19106
|
style: `${typeof style === "string" ? style : ""};${rootStyle}`
|
|
17792
19107
|
};
|
|
17793
19108
|
};
|
|
19109
|
+
/**
|
|
19110
|
+
* The scheme the page showed. A replay's `matchMedia` answers for its viewer, so a capture from one
|
|
19111
|
+
* keeps the replay's fact. A document with no media queries to ask records no scheme, and its
|
|
19112
|
+
* screen behaves as a screen captured before schemes were recorded: it follows its viewer.
|
|
19113
|
+
*/
|
|
19114
|
+
const captureColorScheme = (document) => {
|
|
19115
|
+
const recorded = capturedColorSchemeIn(document.documentElement.getAttribute(CAPTURED_COLOR_SCHEME_ATTRIBUTE));
|
|
19116
|
+
if (recorded !== null) return recorded;
|
|
19117
|
+
const view = document.defaultView;
|
|
19118
|
+
const matchMedia = view === null ? void 0 : Reflect.get(view, "matchMedia");
|
|
19119
|
+
if (view === null || typeof matchMedia !== "function") return void 0;
|
|
19120
|
+
const query = Reflect.apply(matchMedia, view, ["(prefers-color-scheme: dark)"]);
|
|
19121
|
+
return typeof query === "object" && query !== null && Reflect.get(query, "matches") === true ? "dark" : "light";
|
|
19122
|
+
};
|
|
19123
|
+
const withColorScheme = (attributes, colorScheme) => colorScheme === void 0 ? attributes : {
|
|
19124
|
+
...attributes,
|
|
19125
|
+
[CAPTURED_COLOR_SCHEME_ATTRIBUTE]: colorScheme
|
|
19126
|
+
};
|
|
17794
19127
|
//#endregion
|
|
17795
19128
|
//#region ../capture-browser/src/shadow-adopted-stylesheets.lib.ts
|
|
17796
19129
|
/** @justified clarification This must follow rrweb's host traversal order. */
|
|
@@ -17818,7 +19151,6 @@ unreadableCount: number$2().int().min(0) });
|
|
|
17818
19151
|
}));
|
|
17819
19152
|
//#endregion
|
|
17820
19153
|
//#region ../capture-browser/src/stylesheet-snapshot-hint.lib.ts
|
|
17821
|
-
const COLOR_SCHEME_MEDIA = /\bprefers-color-scheme\s*:/iu;
|
|
17822
19154
|
const stylesheetSnapshotKey = (url) => {
|
|
17823
19155
|
const location = Reflect.get(globalThis, "location");
|
|
17824
19156
|
const href = typeof location === "object" && location !== null ? Reflect.get(location, "href") : void 0;
|
|
@@ -17827,12 +19159,6 @@ unreadableCount: number$2().int().min(0) });
|
|
|
17827
19159
|
const leaf = parsed.pathname.slice(parsed.pathname.lastIndexOf("/") + 1);
|
|
17828
19160
|
return `${parsed.origin}/${leaf}${parsed.search}`;
|
|
17829
19161
|
};
|
|
17830
|
-
const freezeColorSchemeMedia = (rules, isMatching) => [...rules].map((rule) => {
|
|
17831
|
-
const condition = rule.conditionText;
|
|
17832
|
-
if (typeof condition !== "string" || !COLOR_SCHEME_MEDIA.test(condition) || rule.cssRules === void 0) return rule.cssText;
|
|
17833
|
-
if (!isMatching(condition)) return "";
|
|
17834
|
-
return freezeColorSchemeMedia(rule.cssRules, isMatching);
|
|
17835
|
-
}).join("\n");
|
|
17836
19162
|
const EMPTY_SERIALIZED_DECLARATION = /[{;]\s*[-\w]+\s*:\s*;/u;
|
|
17837
19163
|
const canRoundTripSerializedCss = (cssText) => !EMPTY_SERIALIZED_DECLARATION.test(cssText);
|
|
17838
19164
|
/** @justified clarification Chromium can erase a valid custom-property shorthand. */
|
|
@@ -17840,7 +19166,7 @@ unreadableCount: number$2().int().min(0) });
|
|
|
17840
19166
|
if (!canRoundTripSerializedCss(rule.cssText)) return false;
|
|
17841
19167
|
return rule.cssRules === void 0 || canRoundTripCssRules(rule.cssRules);
|
|
17842
19168
|
});
|
|
17843
|
-
const serializedCssText = (rules, baseHref) => rewriteCssAssetUrls(
|
|
19169
|
+
const serializedCssText = (rules, baseHref) => rewriteCssAssetUrls([...rules].map((rule) => rule.cssText).join("\n"), /* @__PURE__ */ new Map(), baseHref);
|
|
17844
19170
|
const linkedStylesheetCssText = (sheet, baseHref) => {
|
|
17845
19171
|
try {
|
|
17846
19172
|
const rules = sheet?.cssRules;
|
|
@@ -17909,12 +19235,14 @@ unreadableCount: number$2().int().min(0) });
|
|
|
17909
19235
|
};
|
|
17910
19236
|
const captureSnapshotHints = (document = globalThis.document) => {
|
|
17911
19237
|
const stylesheets = capturedStylesheets(document);
|
|
19238
|
+
const colorScheme = captureColorScheme(document);
|
|
17912
19239
|
return {
|
|
17913
19240
|
adoptedStyleSheets: capturedAdoptedStyleSheets(document, document.baseURI),
|
|
17914
19241
|
inlinedStylesheets: stylesheets.inlined,
|
|
17915
19242
|
shadowAdoptedStyleSheets: captureShadowAdoptedStyleSheets(document, capturedAdoptedStyleSheets),
|
|
17916
19243
|
stylesheets: stylesheets.byKey,
|
|
17917
|
-
rootStyle: captureRootStyle(document)
|
|
19244
|
+
rootStyle: captureRootStyle(document),
|
|
19245
|
+
...colorScheme !== void 0 && { colorScheme }
|
|
17918
19246
|
};
|
|
17919
19247
|
};
|
|
17920
19248
|
//#endregion
|
|
@@ -17951,7 +19279,7 @@ unreadableCount: number$2().int().min(0) });
|
|
|
17951
19279
|
};
|
|
17952
19280
|
const hintAttributes = (node, attributes, context) => {
|
|
17953
19281
|
if (attributes === null) return null;
|
|
17954
|
-
const hinted = node["tagName"] === "link" ? hintLinkAttributes(attributes, context.hints, context.stylesheetUses, context.inlinedStylesheets.take) : node["tagName"] === "html" ? withRootStyle(attributes, context.hints.rootStyle) : attributes;
|
|
19282
|
+
const hinted = node["tagName"] === "link" ? hintLinkAttributes(attributes, context.hints, context.stylesheetUses, context.inlinedStylesheets.take) : node["tagName"] === "html" ? withColorScheme(withRootStyle(attributes, context.hints.rootStyle), context.hints.colorScheme) : attributes;
|
|
17955
19283
|
const id = node["id"];
|
|
17956
19284
|
const corrected = typeof id === "number" ? withPresentationStyle(hinted, context.cssomStyleCorrections.get(id)) : hinted;
|
|
17957
19285
|
const presented = typeof id === "number" ? withPresentationStyle(corrected, context.presentationStyles.get(id)) : corrected;
|
|
@@ -18105,7 +19433,7 @@ unreadableCount: number$2().int().min(0) });
|
|
|
18105
19433
|
/** Captures synchronously, then permits resource retention before the same snapshot is frozen. */
|
|
18106
19434
|
const prepareBrowserScreen = (document, options) => {
|
|
18107
19435
|
const marked = captureMarkedSnapshot(document, options.atMs ?? 0, {
|
|
18108
|
-
blockSelector: options.blockSelector ?? "
|
|
19436
|
+
blockSelector: options.blockSelector ?? "audio[controls]",
|
|
18109
19437
|
fullPage: options.extent === "full-page",
|
|
18110
19438
|
...options.inlineStylesheet !== void 0 && { inlineStylesheet: options.inlineStylesheet }
|
|
18111
19439
|
});
|
|
@@ -18133,15 +19461,69 @@ unreadableCount: number$2().int().min(0) });
|
|
|
18133
19461
|
}
|
|
18134
19462
|
}
|
|
18135
19463
|
});
|
|
19464
|
+
const fullPage = marked.fullPage;
|
|
19465
|
+
const freezeStylesheet = fullPage === null ? null : (css) => fullPageScreenCss(css, fullPage.options);
|
|
18136
19466
|
return {
|
|
18137
19467
|
documents: marked.documents,
|
|
18138
19468
|
nodeForId: marked.nodeForId,
|
|
18139
|
-
finish
|
|
19469
|
+
finish,
|
|
19470
|
+
freezeStylesheet,
|
|
19471
|
+
drawableFonts: drawableFontsRecordedIn(marked.snapshot)
|
|
18140
19472
|
};
|
|
18141
19473
|
};
|
|
18142
19474
|
const captureBrowserScreen = (document, options) => prepareBrowserScreen(document, options).finish();
|
|
18143
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
|
|
18144
19521
|
exports.captureBrowserScreen = captureBrowserScreen;
|
|
19522
|
+
exports.closeAfterPicture = closeAfterPicture;
|
|
19523
|
+
exports.freezeCapturedPage = freezeCapturedPage;
|
|
18145
19524
|
exports.fullPageCaptureLayout = fullPageCaptureLayout;
|
|
19525
|
+
exports.fullPageStylesheetFreeze = fullPageStylesheetFreeze;
|
|
19526
|
+
exports.localFontFileBase64 = localFontFileBase64;
|
|
19527
|
+
exports.openForPicture = openForPicture;
|
|
18146
19528
|
return exports;
|
|
18147
19529
|
})({});
|