@amplitude/rrweb-player 2.0.0-alpha.35 → 2.0.0-alpha.37
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 +0 -174
- package/dist/rrweb-player.cjs +1662 -35
- package/dist/rrweb-player.cjs.map +1 -1
- package/dist/rrweb-player.js +1662 -35
- package/dist/rrweb-player.js.map +1 -1
- package/dist/rrweb-player.umd.cjs +1665 -35
- package/dist/rrweb-player.umd.cjs.map +3 -3
- package/dist/rrweb-player.umd.min.cjs +38 -38
- package/dist/rrweb-player.umd.min.cjs.map +3 -3
- package/package.json +4 -4
|
@@ -3385,7 +3385,7 @@ function if_block(node2, fn, elseif = false) {
|
|
|
3385
3385
|
}
|
|
3386
3386
|
}, flags2);
|
|
3387
3387
|
}
|
|
3388
|
-
function index$
|
|
3388
|
+
function index$2(_, i) {
|
|
3389
3389
|
return i;
|
|
3390
3390
|
}
|
|
3391
3391
|
function pause_effects(state2, to_destroy, controlled_anchor) {
|
|
@@ -4319,9 +4319,251 @@ var NodeType$3 = /* @__PURE__ */ ((NodeType2) => {
|
|
|
4319
4319
|
NodeType2[NodeType2["Comment"] = 5] = "Comment";
|
|
4320
4320
|
return NodeType2;
|
|
4321
4321
|
})(NodeType$3 || {});
|
|
4322
|
+
const testableAccessors$1 = {
|
|
4323
|
+
Node: ["childNodes", "parentNode", "parentElement", "textContent"],
|
|
4324
|
+
ShadowRoot: ["host", "styleSheets"],
|
|
4325
|
+
Element: ["shadowRoot", "querySelector", "querySelectorAll"],
|
|
4326
|
+
MutationObserver: []
|
|
4327
|
+
};
|
|
4328
|
+
const testableMethods$1 = {
|
|
4329
|
+
Node: ["contains", "getRootNode"],
|
|
4330
|
+
ShadowRoot: ["getSelection"],
|
|
4331
|
+
Element: [],
|
|
4332
|
+
MutationObserver: ["constructor"]
|
|
4333
|
+
};
|
|
4334
|
+
const untaintedBasePrototype$1 = {};
|
|
4335
|
+
function angularZoneUnpatchedAlternative$1(key) {
|
|
4336
|
+
var _a22, _b22;
|
|
4337
|
+
const angularUnpatchedVersionSymbol = (_b22 = (_a22 = globalThis == null ? void 0 : globalThis.Zone) == null ? void 0 : _a22.__symbol__) == null ? void 0 : _b22.call(_a22, key);
|
|
4338
|
+
if (angularUnpatchedVersionSymbol && globalThis[angularUnpatchedVersionSymbol]) {
|
|
4339
|
+
return globalThis[angularUnpatchedVersionSymbol];
|
|
4340
|
+
} else {
|
|
4341
|
+
return void 0;
|
|
4342
|
+
}
|
|
4343
|
+
}
|
|
4344
|
+
function getUntaintedPrototype$1(key) {
|
|
4345
|
+
if (untaintedBasePrototype$1[key])
|
|
4346
|
+
return untaintedBasePrototype$1[key];
|
|
4347
|
+
const candidate = angularZoneUnpatchedAlternative$1(key) || globalThis[key];
|
|
4348
|
+
const defaultPrototype = candidate.prototype;
|
|
4349
|
+
const accessorNames = key in testableAccessors$1 ? testableAccessors$1[key] : void 0;
|
|
4350
|
+
const isUntaintedAccessors = Boolean(
|
|
4351
|
+
accessorNames && // @ts-expect-error 2345
|
|
4352
|
+
accessorNames.every(
|
|
4353
|
+
(accessor) => {
|
|
4354
|
+
var _a22, _b22;
|
|
4355
|
+
return Boolean(
|
|
4356
|
+
(_b22 = (_a22 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a22.get) == null ? void 0 : _b22.toString().includes("[native code]")
|
|
4357
|
+
);
|
|
4358
|
+
}
|
|
4359
|
+
)
|
|
4360
|
+
);
|
|
4361
|
+
const methodNames = key in testableMethods$1 ? testableMethods$1[key] : void 0;
|
|
4362
|
+
const isUntaintedMethods = Boolean(
|
|
4363
|
+
methodNames && methodNames.every(
|
|
4364
|
+
// @ts-expect-error 2345
|
|
4365
|
+
(method) => {
|
|
4366
|
+
var _a22;
|
|
4367
|
+
return typeof defaultPrototype[method] === "function" && ((_a22 = defaultPrototype[method]) == null ? void 0 : _a22.toString().includes("[native code]"));
|
|
4368
|
+
}
|
|
4369
|
+
)
|
|
4370
|
+
);
|
|
4371
|
+
if (isUntaintedAccessors && isUntaintedMethods) {
|
|
4372
|
+
untaintedBasePrototype$1[key] = candidate.prototype;
|
|
4373
|
+
return candidate.prototype;
|
|
4374
|
+
}
|
|
4375
|
+
try {
|
|
4376
|
+
const iframeEl = document.createElement("iframe");
|
|
4377
|
+
document.body.appendChild(iframeEl);
|
|
4378
|
+
const win = iframeEl.contentWindow;
|
|
4379
|
+
if (!win) return candidate.prototype;
|
|
4380
|
+
const untaintedObject = win[key].prototype;
|
|
4381
|
+
document.body.removeChild(iframeEl);
|
|
4382
|
+
if (!untaintedObject) return defaultPrototype;
|
|
4383
|
+
return untaintedBasePrototype$1[key] = untaintedObject;
|
|
4384
|
+
} catch (e2) {
|
|
4385
|
+
return defaultPrototype;
|
|
4386
|
+
}
|
|
4387
|
+
}
|
|
4388
|
+
const untaintedAccessorCache$1 = {};
|
|
4389
|
+
function getUntaintedAccessor$1(key, instance, accessor) {
|
|
4390
|
+
var _a22;
|
|
4391
|
+
const cacheKey = `${key}.${String(accessor)}`;
|
|
4392
|
+
if (untaintedAccessorCache$1[cacheKey])
|
|
4393
|
+
return untaintedAccessorCache$1[cacheKey].call(
|
|
4394
|
+
instance
|
|
4395
|
+
);
|
|
4396
|
+
const untaintedPrototype = getUntaintedPrototype$1(key);
|
|
4397
|
+
const untaintedAccessor = (_a22 = Object.getOwnPropertyDescriptor(
|
|
4398
|
+
untaintedPrototype,
|
|
4399
|
+
accessor
|
|
4400
|
+
)) == null ? void 0 : _a22.get;
|
|
4401
|
+
if (!untaintedAccessor) return instance[accessor];
|
|
4402
|
+
untaintedAccessorCache$1[cacheKey] = untaintedAccessor;
|
|
4403
|
+
return untaintedAccessor.call(instance);
|
|
4404
|
+
}
|
|
4405
|
+
const untaintedMethodCache$1 = {};
|
|
4406
|
+
function getUntaintedMethod$1(key, instance, method) {
|
|
4407
|
+
const cacheKey = `${key}.${String(method)}`;
|
|
4408
|
+
if (untaintedMethodCache$1[cacheKey])
|
|
4409
|
+
return untaintedMethodCache$1[cacheKey].bind(
|
|
4410
|
+
instance
|
|
4411
|
+
);
|
|
4412
|
+
const untaintedPrototype = getUntaintedPrototype$1(key);
|
|
4413
|
+
const untaintedMethod = untaintedPrototype[method];
|
|
4414
|
+
if (typeof untaintedMethod !== "function") return instance[method];
|
|
4415
|
+
untaintedMethodCache$1[cacheKey] = untaintedMethod;
|
|
4416
|
+
return untaintedMethod.bind(instance);
|
|
4417
|
+
}
|
|
4418
|
+
function childNodes$1(n2) {
|
|
4419
|
+
return getUntaintedAccessor$1("Node", n2, "childNodes");
|
|
4420
|
+
}
|
|
4421
|
+
function parentNode$1(n2) {
|
|
4422
|
+
return getUntaintedAccessor$1("Node", n2, "parentNode");
|
|
4423
|
+
}
|
|
4424
|
+
function parentElement$1(n2) {
|
|
4425
|
+
return getUntaintedAccessor$1("Node", n2, "parentElement");
|
|
4426
|
+
}
|
|
4427
|
+
function textContent$1(n2) {
|
|
4428
|
+
return getUntaintedAccessor$1("Node", n2, "textContent");
|
|
4429
|
+
}
|
|
4430
|
+
function contains$1(n2, other) {
|
|
4431
|
+
return getUntaintedMethod$1("Node", n2, "contains")(other);
|
|
4432
|
+
}
|
|
4433
|
+
function getRootNode$1(n2) {
|
|
4434
|
+
return getUntaintedMethod$1("Node", n2, "getRootNode")();
|
|
4435
|
+
}
|
|
4436
|
+
function host$1(n2) {
|
|
4437
|
+
if (!n2 || !("host" in n2)) return null;
|
|
4438
|
+
return getUntaintedAccessor$1("ShadowRoot", n2, "host");
|
|
4439
|
+
}
|
|
4440
|
+
function styleSheets$1(n2) {
|
|
4441
|
+
return n2.styleSheets;
|
|
4442
|
+
}
|
|
4443
|
+
function shadowRoot$1(n2) {
|
|
4444
|
+
if (!n2 || !("shadowRoot" in n2)) return null;
|
|
4445
|
+
return getUntaintedAccessor$1("Element", n2, "shadowRoot");
|
|
4446
|
+
}
|
|
4447
|
+
function querySelector$1(n2, selectors) {
|
|
4448
|
+
return getUntaintedAccessor$1("Element", n2, "querySelector")(selectors);
|
|
4449
|
+
}
|
|
4450
|
+
function querySelectorAll$1(n2, selectors) {
|
|
4451
|
+
return getUntaintedAccessor$1("Element", n2, "querySelectorAll")(selectors);
|
|
4452
|
+
}
|
|
4453
|
+
function mutationObserverCtor$1() {
|
|
4454
|
+
return getUntaintedPrototype$1("MutationObserver").constructor;
|
|
4455
|
+
}
|
|
4456
|
+
const index$1 = {
|
|
4457
|
+
childNodes: childNodes$1,
|
|
4458
|
+
parentNode: parentNode$1,
|
|
4459
|
+
parentElement: parentElement$1,
|
|
4460
|
+
textContent: textContent$1,
|
|
4461
|
+
contains: contains$1,
|
|
4462
|
+
getRootNode: getRootNode$1,
|
|
4463
|
+
host: host$1,
|
|
4464
|
+
styleSheets: styleSheets$1,
|
|
4465
|
+
shadowRoot: shadowRoot$1,
|
|
4466
|
+
querySelector: querySelector$1,
|
|
4467
|
+
querySelectorAll: querySelectorAll$1,
|
|
4468
|
+
mutationObserver: mutationObserverCtor$1
|
|
4469
|
+
};
|
|
4322
4470
|
function isElement(n2) {
|
|
4323
4471
|
return n2.nodeType === n2.ELEMENT_NODE;
|
|
4324
4472
|
}
|
|
4473
|
+
function isShadowRoot(n2) {
|
|
4474
|
+
const hostEl = (
|
|
4475
|
+
// anchor and textarea elements also have a `host` property
|
|
4476
|
+
// but only shadow roots have a `mode` property
|
|
4477
|
+
n2 && "host" in n2 && "mode" in n2 && index$1.host(n2) || null
|
|
4478
|
+
);
|
|
4479
|
+
return Boolean(
|
|
4480
|
+
hostEl && "shadowRoot" in hostEl && index$1.shadowRoot(hostEl) === n2
|
|
4481
|
+
);
|
|
4482
|
+
}
|
|
4483
|
+
function isNativeShadowDom(shadowRoot2) {
|
|
4484
|
+
return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
|
|
4485
|
+
}
|
|
4486
|
+
function fixBrowserCompatibilityIssuesInCSS(cssText) {
|
|
4487
|
+
if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
|
|
4488
|
+
cssText = cssText.replace(
|
|
4489
|
+
/\sbackground-clip:\s*text;/g,
|
|
4490
|
+
" -webkit-background-clip: text; background-clip: text;"
|
|
4491
|
+
);
|
|
4492
|
+
}
|
|
4493
|
+
return cssText;
|
|
4494
|
+
}
|
|
4495
|
+
function escapeImportStatement(rule2) {
|
|
4496
|
+
const { cssText } = rule2;
|
|
4497
|
+
if (cssText.split('"').length < 3) return cssText;
|
|
4498
|
+
const statement = ["@import", `url(${JSON.stringify(rule2.href)})`];
|
|
4499
|
+
if (rule2.layerName === "") {
|
|
4500
|
+
statement.push(`layer`);
|
|
4501
|
+
} else if (rule2.layerName) {
|
|
4502
|
+
statement.push(`layer(${rule2.layerName})`);
|
|
4503
|
+
}
|
|
4504
|
+
if (rule2.supportsText) {
|
|
4505
|
+
statement.push(`supports(${rule2.supportsText})`);
|
|
4506
|
+
}
|
|
4507
|
+
if (rule2.media.length) {
|
|
4508
|
+
statement.push(rule2.media.mediaText);
|
|
4509
|
+
}
|
|
4510
|
+
return statement.join(" ") + ";";
|
|
4511
|
+
}
|
|
4512
|
+
function stringifyStylesheet(s2) {
|
|
4513
|
+
try {
|
|
4514
|
+
const rules2 = s2.rules || s2.cssRules;
|
|
4515
|
+
if (!rules2) {
|
|
4516
|
+
return null;
|
|
4517
|
+
}
|
|
4518
|
+
let sheetHref = s2.href;
|
|
4519
|
+
if (!sheetHref && s2.ownerNode && s2.ownerNode.ownerDocument) {
|
|
4520
|
+
sheetHref = s2.ownerNode.ownerDocument.location.href;
|
|
4521
|
+
}
|
|
4522
|
+
const stringifiedRules = Array.from(
|
|
4523
|
+
rules2,
|
|
4524
|
+
(rule2) => stringifyRule(rule2, sheetHref)
|
|
4525
|
+
).join("");
|
|
4526
|
+
return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
|
|
4527
|
+
} catch (error) {
|
|
4528
|
+
return null;
|
|
4529
|
+
}
|
|
4530
|
+
}
|
|
4531
|
+
function stringifyRule(rule2, sheetHref) {
|
|
4532
|
+
if (isCSSImportRule(rule2)) {
|
|
4533
|
+
let importStringified;
|
|
4534
|
+
try {
|
|
4535
|
+
importStringified = // for same-origin stylesheets,
|
|
4536
|
+
// we can access the imported stylesheet rules directly
|
|
4537
|
+
stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
|
|
4538
|
+
escapeImportStatement(rule2);
|
|
4539
|
+
} catch (error) {
|
|
4540
|
+
importStringified = rule2.cssText;
|
|
4541
|
+
}
|
|
4542
|
+
if (rule2.styleSheet.href) {
|
|
4543
|
+
return absolutifyURLs(importStringified, rule2.styleSheet.href);
|
|
4544
|
+
}
|
|
4545
|
+
return importStringified;
|
|
4546
|
+
} else {
|
|
4547
|
+
let ruleStringified = rule2.cssText;
|
|
4548
|
+
if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
|
|
4549
|
+
ruleStringified = fixSafariColons(ruleStringified);
|
|
4550
|
+
}
|
|
4551
|
+
if (sheetHref) {
|
|
4552
|
+
return absolutifyURLs(ruleStringified, sheetHref);
|
|
4553
|
+
}
|
|
4554
|
+
return ruleStringified;
|
|
4555
|
+
}
|
|
4556
|
+
}
|
|
4557
|
+
function fixSafariColons(cssStringified) {
|
|
4558
|
+
const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
|
|
4559
|
+
return cssStringified.replace(regex, "$1\\$2");
|
|
4560
|
+
}
|
|
4561
|
+
function isCSSImportRule(rule2) {
|
|
4562
|
+
return "styleSheet" in rule2;
|
|
4563
|
+
}
|
|
4564
|
+
function isCSSStyleRule(rule2) {
|
|
4565
|
+
return "selectorText" in rule2;
|
|
4566
|
+
}
|
|
4325
4567
|
class Mirror {
|
|
4326
4568
|
constructor() {
|
|
4327
4569
|
__publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
|
|
@@ -4380,9 +4622,52 @@ class Mirror {
|
|
|
4380
4622
|
function createMirror$2() {
|
|
4381
4623
|
return new Mirror();
|
|
4382
4624
|
}
|
|
4625
|
+
function maskInputValue({
|
|
4626
|
+
element,
|
|
4627
|
+
maskInputOptions,
|
|
4628
|
+
tagName,
|
|
4629
|
+
type,
|
|
4630
|
+
value,
|
|
4631
|
+
maskInputFn
|
|
4632
|
+
}) {
|
|
4633
|
+
let text = value || "";
|
|
4634
|
+
const actualType = type && toLowerCase(type);
|
|
4635
|
+
if (maskInputOptions[tagName.toLowerCase()] || actualType && maskInputOptions[actualType]) {
|
|
4636
|
+
if (maskInputFn) {
|
|
4637
|
+
text = maskInputFn(text, element);
|
|
4638
|
+
} else {
|
|
4639
|
+
text = "*".repeat(text.length);
|
|
4640
|
+
}
|
|
4641
|
+
}
|
|
4642
|
+
return text;
|
|
4643
|
+
}
|
|
4383
4644
|
function toLowerCase(str) {
|
|
4384
4645
|
return str.toLowerCase();
|
|
4385
4646
|
}
|
|
4647
|
+
const ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
|
|
4648
|
+
function is2DCanvasBlank(canvas) {
|
|
4649
|
+
const ctx = canvas.getContext("2d");
|
|
4650
|
+
if (!ctx) return true;
|
|
4651
|
+
const chunkSize = 50;
|
|
4652
|
+
for (let x = 0; x < canvas.width; x += chunkSize) {
|
|
4653
|
+
for (let y = 0; y < canvas.height; y += chunkSize) {
|
|
4654
|
+
const getImageData = ctx.getImageData;
|
|
4655
|
+
const originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
|
|
4656
|
+
const pixelBuffer = new Uint32Array(
|
|
4657
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
4658
|
+
originalGetImageData.call(
|
|
4659
|
+
ctx,
|
|
4660
|
+
x,
|
|
4661
|
+
y,
|
|
4662
|
+
Math.min(chunkSize, canvas.width - x),
|
|
4663
|
+
Math.min(chunkSize, canvas.height - y)
|
|
4664
|
+
).data.buffer
|
|
4665
|
+
);
|
|
4666
|
+
if (pixelBuffer.some((pixel) => pixel !== 0)) return false;
|
|
4667
|
+
}
|
|
4668
|
+
}
|
|
4669
|
+
return true;
|
|
4670
|
+
}
|
|
4386
4671
|
function isNodeMetaEqual(a2, b) {
|
|
4387
4672
|
if (!a2 || !b || a2.type !== b.type) return false;
|
|
4388
4673
|
if (a2.type === NodeType$3.Document)
|
|
@@ -4395,6 +4680,1097 @@ function isNodeMetaEqual(a2, b) {
|
|
|
4395
4680
|
return a2.tagName === b.tagName && JSON.stringify(a2.attributes) === JSON.stringify(b.attributes) && a2.isSVG === b.isSVG && a2.needBlock === b.needBlock;
|
|
4396
4681
|
return false;
|
|
4397
4682
|
}
|
|
4683
|
+
function getInputType(element) {
|
|
4684
|
+
const type = element.type;
|
|
4685
|
+
return element.hasAttribute("data-rr-is-password") ? "password" : type ? (
|
|
4686
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
4687
|
+
toLowerCase(type)
|
|
4688
|
+
) : null;
|
|
4689
|
+
}
|
|
4690
|
+
function extractFileExtension(path, baseURL) {
|
|
4691
|
+
var _a4;
|
|
4692
|
+
let url;
|
|
4693
|
+
try {
|
|
4694
|
+
url = new URL(path, baseURL != null ? baseURL : window.location.href);
|
|
4695
|
+
} catch (err) {
|
|
4696
|
+
return null;
|
|
4697
|
+
}
|
|
4698
|
+
const regex = /\.([0-9a-z]+)(?:$)/i;
|
|
4699
|
+
const match = url.pathname.match(regex);
|
|
4700
|
+
return (_a4 = match == null ? void 0 : match[1]) != null ? _a4 : null;
|
|
4701
|
+
}
|
|
4702
|
+
function extractOrigin(url) {
|
|
4703
|
+
let origin = "";
|
|
4704
|
+
if (url.indexOf("//") > -1) {
|
|
4705
|
+
origin = url.split("/").slice(0, 3).join("/");
|
|
4706
|
+
} else {
|
|
4707
|
+
origin = url.split("/")[0];
|
|
4708
|
+
}
|
|
4709
|
+
origin = origin.split("?")[0];
|
|
4710
|
+
return origin;
|
|
4711
|
+
}
|
|
4712
|
+
const URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
|
|
4713
|
+
const URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
|
|
4714
|
+
const URL_WWW_MATCH = /^www\..*/i;
|
|
4715
|
+
const DATA_URI = /^(data:)([^,]*),(.*)/i;
|
|
4716
|
+
function absolutifyURLs(cssText, href) {
|
|
4717
|
+
return (cssText || "").replace(
|
|
4718
|
+
URL_IN_CSS_REF,
|
|
4719
|
+
(origin, quote1, path1, quote2, path2, path3) => {
|
|
4720
|
+
const filePath = path1 || path2 || path3;
|
|
4721
|
+
const maybeQuote = quote1 || quote2 || "";
|
|
4722
|
+
if (!filePath) {
|
|
4723
|
+
return origin;
|
|
4724
|
+
}
|
|
4725
|
+
if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
|
|
4726
|
+
return `url(${maybeQuote}${filePath}${maybeQuote})`;
|
|
4727
|
+
}
|
|
4728
|
+
if (DATA_URI.test(filePath)) {
|
|
4729
|
+
return `url(${maybeQuote}${filePath}${maybeQuote})`;
|
|
4730
|
+
}
|
|
4731
|
+
if (filePath[0] === "/") {
|
|
4732
|
+
return `url(${maybeQuote}${extractOrigin(href) + filePath}${maybeQuote})`;
|
|
4733
|
+
}
|
|
4734
|
+
const stack = href.split("/");
|
|
4735
|
+
const parts = filePath.split("/");
|
|
4736
|
+
stack.pop();
|
|
4737
|
+
for (const part of parts) {
|
|
4738
|
+
if (part === ".") {
|
|
4739
|
+
continue;
|
|
4740
|
+
} else if (part === "..") {
|
|
4741
|
+
stack.pop();
|
|
4742
|
+
} else {
|
|
4743
|
+
stack.push(part);
|
|
4744
|
+
}
|
|
4745
|
+
}
|
|
4746
|
+
return `url(${maybeQuote}${stack.join("/")}${maybeQuote})`;
|
|
4747
|
+
}
|
|
4748
|
+
);
|
|
4749
|
+
}
|
|
4750
|
+
function normalizeCssString(cssText, _testNoPxNorm = false) {
|
|
4751
|
+
if (_testNoPxNorm) {
|
|
4752
|
+
return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
|
|
4753
|
+
} else {
|
|
4754
|
+
return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "").replace(/0px/g, "0");
|
|
4755
|
+
}
|
|
4756
|
+
}
|
|
4757
|
+
function splitCssText(cssText, style, _testNoPxNorm = false) {
|
|
4758
|
+
const childNodes2 = Array.from(style.childNodes);
|
|
4759
|
+
const splits = [];
|
|
4760
|
+
let iterCount = 0;
|
|
4761
|
+
if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
|
|
4762
|
+
let cssTextNorm = normalizeCssString(cssText, _testNoPxNorm);
|
|
4763
|
+
const normFactor = cssTextNorm.length / cssText.length;
|
|
4764
|
+
for (let i2 = 1; i2 < childNodes2.length; i2++) {
|
|
4765
|
+
if (childNodes2[i2].textContent && typeof childNodes2[i2].textContent === "string") {
|
|
4766
|
+
const textContentNorm = normalizeCssString(
|
|
4767
|
+
childNodes2[i2].textContent,
|
|
4768
|
+
_testNoPxNorm
|
|
4769
|
+
);
|
|
4770
|
+
const jLimit = 100;
|
|
4771
|
+
let j = 3;
|
|
4772
|
+
for (; j < textContentNorm.length; j++) {
|
|
4773
|
+
if (
|
|
4774
|
+
// keep consuming css identifiers (to get a decent chunk more quickly)
|
|
4775
|
+
textContentNorm[j].match(/[a-zA-Z0-9]/) || // substring needs to be unique to this section
|
|
4776
|
+
textContentNorm.indexOf(textContentNorm.substring(0, j), 1) !== -1
|
|
4777
|
+
) {
|
|
4778
|
+
continue;
|
|
4779
|
+
}
|
|
4780
|
+
break;
|
|
4781
|
+
}
|
|
4782
|
+
for (; j < textContentNorm.length; j++) {
|
|
4783
|
+
let startSubstring = textContentNorm.substring(0, j);
|
|
4784
|
+
let cssNormSplits = cssTextNorm.split(startSubstring);
|
|
4785
|
+
let splitNorm = -1;
|
|
4786
|
+
if (cssNormSplits.length === 2) {
|
|
4787
|
+
splitNorm = cssNormSplits[0].length;
|
|
4788
|
+
} else if (cssNormSplits.length > 2 && cssNormSplits[0] === "" && childNodes2[i2 - 1].textContent !== "") {
|
|
4789
|
+
splitNorm = cssTextNorm.indexOf(startSubstring, 1);
|
|
4790
|
+
} else if (cssNormSplits.length === 1) {
|
|
4791
|
+
startSubstring = startSubstring.substring(
|
|
4792
|
+
0,
|
|
4793
|
+
startSubstring.length - 1
|
|
4794
|
+
);
|
|
4795
|
+
cssNormSplits = cssTextNorm.split(startSubstring);
|
|
4796
|
+
if (cssNormSplits.length <= 1) {
|
|
4797
|
+
splits.push(cssText);
|
|
4798
|
+
return splits;
|
|
4799
|
+
}
|
|
4800
|
+
j = jLimit + 1;
|
|
4801
|
+
} else if (j === textContentNorm.length - 1) {
|
|
4802
|
+
splitNorm = cssTextNorm.indexOf(startSubstring);
|
|
4803
|
+
}
|
|
4804
|
+
if (cssNormSplits.length >= 2 && j > jLimit) {
|
|
4805
|
+
const prevTextContent = childNodes2[i2 - 1].textContent;
|
|
4806
|
+
if (prevTextContent && typeof prevTextContent === "string") {
|
|
4807
|
+
const prevMinLength = normalizeCssString(prevTextContent).length;
|
|
4808
|
+
splitNorm = cssTextNorm.indexOf(startSubstring, prevMinLength);
|
|
4809
|
+
}
|
|
4810
|
+
if (splitNorm === -1) {
|
|
4811
|
+
splitNorm = cssNormSplits[0].length;
|
|
4812
|
+
}
|
|
4813
|
+
}
|
|
4814
|
+
if (splitNorm !== -1) {
|
|
4815
|
+
let k = Math.floor(splitNorm / normFactor);
|
|
4816
|
+
for (; k > 0 && k < cssText.length; ) {
|
|
4817
|
+
iterCount += 1;
|
|
4818
|
+
if (iterCount > 50 * childNodes2.length) {
|
|
4819
|
+
splits.push(cssText);
|
|
4820
|
+
return splits;
|
|
4821
|
+
}
|
|
4822
|
+
const normPart = normalizeCssString(
|
|
4823
|
+
cssText.substring(0, k),
|
|
4824
|
+
_testNoPxNorm
|
|
4825
|
+
);
|
|
4826
|
+
if (normPart.length === splitNorm) {
|
|
4827
|
+
splits.push(cssText.substring(0, k));
|
|
4828
|
+
cssText = cssText.substring(k);
|
|
4829
|
+
cssTextNorm = cssTextNorm.substring(splitNorm);
|
|
4830
|
+
break;
|
|
4831
|
+
} else if (normPart.length < splitNorm) {
|
|
4832
|
+
k += Math.max(
|
|
4833
|
+
1,
|
|
4834
|
+
Math.floor((splitNorm - normPart.length) / normFactor)
|
|
4835
|
+
);
|
|
4836
|
+
} else {
|
|
4837
|
+
k -= Math.max(
|
|
4838
|
+
1,
|
|
4839
|
+
Math.floor((normPart.length - splitNorm) * normFactor)
|
|
4840
|
+
);
|
|
4841
|
+
}
|
|
4842
|
+
}
|
|
4843
|
+
break;
|
|
4844
|
+
}
|
|
4845
|
+
}
|
|
4846
|
+
}
|
|
4847
|
+
}
|
|
4848
|
+
}
|
|
4849
|
+
splits.push(cssText);
|
|
4850
|
+
return splits;
|
|
4851
|
+
}
|
|
4852
|
+
function markCssSplits(cssText, style) {
|
|
4853
|
+
return splitCssText(cssText, style).join("/* rr_split */");
|
|
4854
|
+
}
|
|
4855
|
+
const _DEFAULT_BLOCKED_ELEMENT_BACKGROUND_COLOR = "lightgrey";
|
|
4856
|
+
let _id = 1;
|
|
4857
|
+
const tagNameRegex = new RegExp("[^a-z0-9-_:]");
|
|
4858
|
+
const IGNORED_NODE = -2;
|
|
4859
|
+
function genId() {
|
|
4860
|
+
return _id++;
|
|
4861
|
+
}
|
|
4862
|
+
function getValidTagName$1(element) {
|
|
4863
|
+
if (element instanceof HTMLFormElement) {
|
|
4864
|
+
return "form";
|
|
4865
|
+
}
|
|
4866
|
+
const processedTagName = toLowerCase(element.tagName);
|
|
4867
|
+
if (tagNameRegex.test(processedTagName)) {
|
|
4868
|
+
return "div";
|
|
4869
|
+
}
|
|
4870
|
+
return processedTagName;
|
|
4871
|
+
}
|
|
4872
|
+
let canvasService;
|
|
4873
|
+
let canvasCtx;
|
|
4874
|
+
const SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
|
|
4875
|
+
const SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
|
|
4876
|
+
function getAbsoluteSrcsetString(doc, attributeValue) {
|
|
4877
|
+
if (attributeValue.trim() === "") {
|
|
4878
|
+
return attributeValue;
|
|
4879
|
+
}
|
|
4880
|
+
let pos = 0;
|
|
4881
|
+
function collectCharacters(regEx) {
|
|
4882
|
+
let chars2;
|
|
4883
|
+
const match = regEx.exec(attributeValue.substring(pos));
|
|
4884
|
+
if (match) {
|
|
4885
|
+
chars2 = match[0];
|
|
4886
|
+
pos += chars2.length;
|
|
4887
|
+
return chars2;
|
|
4888
|
+
}
|
|
4889
|
+
return "";
|
|
4890
|
+
}
|
|
4891
|
+
const output = [];
|
|
4892
|
+
while (true) {
|
|
4893
|
+
collectCharacters(SRCSET_COMMAS_OR_SPACES);
|
|
4894
|
+
if (pos >= attributeValue.length) {
|
|
4895
|
+
break;
|
|
4896
|
+
}
|
|
4897
|
+
let url = collectCharacters(SRCSET_NOT_SPACES);
|
|
4898
|
+
if (url.slice(-1) === ",") {
|
|
4899
|
+
url = absoluteToDoc(doc, url.substring(0, url.length - 1));
|
|
4900
|
+
output.push(url);
|
|
4901
|
+
} else {
|
|
4902
|
+
let descriptorsStr = "";
|
|
4903
|
+
url = absoluteToDoc(doc, url);
|
|
4904
|
+
let inParens = false;
|
|
4905
|
+
while (true) {
|
|
4906
|
+
const c2 = attributeValue.charAt(pos);
|
|
4907
|
+
if (c2 === "") {
|
|
4908
|
+
output.push((url + descriptorsStr).trim());
|
|
4909
|
+
break;
|
|
4910
|
+
} else if (!inParens) {
|
|
4911
|
+
if (c2 === ",") {
|
|
4912
|
+
pos += 1;
|
|
4913
|
+
output.push((url + descriptorsStr).trim());
|
|
4914
|
+
break;
|
|
4915
|
+
} else if (c2 === "(") {
|
|
4916
|
+
inParens = true;
|
|
4917
|
+
}
|
|
4918
|
+
} else {
|
|
4919
|
+
if (c2 === ")") {
|
|
4920
|
+
inParens = false;
|
|
4921
|
+
}
|
|
4922
|
+
}
|
|
4923
|
+
descriptorsStr += c2;
|
|
4924
|
+
pos += 1;
|
|
4925
|
+
}
|
|
4926
|
+
}
|
|
4927
|
+
}
|
|
4928
|
+
return output.join(", ");
|
|
4929
|
+
}
|
|
4930
|
+
const cachedDocument = /* @__PURE__ */ new WeakMap();
|
|
4931
|
+
function absoluteToDoc(doc, attributeValue) {
|
|
4932
|
+
if (!attributeValue || attributeValue.trim() === "") {
|
|
4933
|
+
return attributeValue;
|
|
4934
|
+
}
|
|
4935
|
+
return getHref(doc, attributeValue);
|
|
4936
|
+
}
|
|
4937
|
+
function isSVGElement(el) {
|
|
4938
|
+
return Boolean(el.tagName === "svg" || el.ownerSVGElement);
|
|
4939
|
+
}
|
|
4940
|
+
function getHref(doc, customHref) {
|
|
4941
|
+
let a2 = cachedDocument.get(doc);
|
|
4942
|
+
if (!a2) {
|
|
4943
|
+
a2 = doc.createElement("a");
|
|
4944
|
+
cachedDocument.set(doc, a2);
|
|
4945
|
+
}
|
|
4946
|
+
if (!customHref) {
|
|
4947
|
+
customHref = "";
|
|
4948
|
+
} else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
|
|
4949
|
+
return customHref;
|
|
4950
|
+
}
|
|
4951
|
+
a2.setAttribute("href", customHref);
|
|
4952
|
+
return a2.href;
|
|
4953
|
+
}
|
|
4954
|
+
function transformAttribute(doc, tagName, name, value) {
|
|
4955
|
+
if (!value) {
|
|
4956
|
+
return value;
|
|
4957
|
+
}
|
|
4958
|
+
if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
|
|
4959
|
+
return absoluteToDoc(doc, value);
|
|
4960
|
+
} else if (name === "xlink:href" && value[0] !== "#") {
|
|
4961
|
+
return absoluteToDoc(doc, value);
|
|
4962
|
+
} else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
|
|
4963
|
+
return absoluteToDoc(doc, value);
|
|
4964
|
+
} else if (name === "srcset") {
|
|
4965
|
+
return getAbsoluteSrcsetString(doc, value);
|
|
4966
|
+
} else if (name === "style") {
|
|
4967
|
+
return absolutifyURLs(value, getHref(doc));
|
|
4968
|
+
} else if (tagName === "object" && name === "data") {
|
|
4969
|
+
return absoluteToDoc(doc, value);
|
|
4970
|
+
}
|
|
4971
|
+
return value;
|
|
4972
|
+
}
|
|
4973
|
+
function ignoreAttribute(tagName, name, _value) {
|
|
4974
|
+
return (tagName === "video" || tagName === "audio") && name === "autoplay";
|
|
4975
|
+
}
|
|
4976
|
+
function _isBlockedElement(element, blockClass, blockSelector) {
|
|
4977
|
+
try {
|
|
4978
|
+
if (typeof blockClass === "string") {
|
|
4979
|
+
if (element.classList.contains(blockClass)) {
|
|
4980
|
+
return true;
|
|
4981
|
+
}
|
|
4982
|
+
} else {
|
|
4983
|
+
for (let eIndex = element.classList.length; eIndex--; ) {
|
|
4984
|
+
const className = element.classList[eIndex];
|
|
4985
|
+
if (blockClass.test(className)) {
|
|
4986
|
+
return true;
|
|
4987
|
+
}
|
|
4988
|
+
}
|
|
4989
|
+
}
|
|
4990
|
+
if (blockSelector) {
|
|
4991
|
+
return element.matches(blockSelector);
|
|
4992
|
+
}
|
|
4993
|
+
} catch (e2) {
|
|
4994
|
+
}
|
|
4995
|
+
return false;
|
|
4996
|
+
}
|
|
4997
|
+
function classMatchesRegex(node2, regex, checkAncestors) {
|
|
4998
|
+
if (!node2) return false;
|
|
4999
|
+
if (node2.nodeType !== node2.ELEMENT_NODE) {
|
|
5000
|
+
if (!checkAncestors) return false;
|
|
5001
|
+
return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
|
|
5002
|
+
}
|
|
5003
|
+
for (let eIndex = node2.classList.length; eIndex--; ) {
|
|
5004
|
+
const className = node2.classList[eIndex];
|
|
5005
|
+
if (regex.test(className)) {
|
|
5006
|
+
return true;
|
|
5007
|
+
}
|
|
5008
|
+
}
|
|
5009
|
+
if (!checkAncestors) return false;
|
|
5010
|
+
return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
|
|
5011
|
+
}
|
|
5012
|
+
function needMaskingText(node2, maskTextClass, maskTextSelector, checkAncestors) {
|
|
5013
|
+
let el;
|
|
5014
|
+
if (isElement(node2)) {
|
|
5015
|
+
el = node2;
|
|
5016
|
+
if (!index$1.childNodes(el).length) {
|
|
5017
|
+
return false;
|
|
5018
|
+
}
|
|
5019
|
+
} else if (index$1.parentElement(node2) === null) {
|
|
5020
|
+
return false;
|
|
5021
|
+
} else {
|
|
5022
|
+
el = index$1.parentElement(node2);
|
|
5023
|
+
}
|
|
5024
|
+
try {
|
|
5025
|
+
if (typeof maskTextClass === "string") {
|
|
5026
|
+
if (checkAncestors) {
|
|
5027
|
+
if (el.closest(`.${maskTextClass}`)) return true;
|
|
5028
|
+
} else {
|
|
5029
|
+
if (el.classList.contains(maskTextClass)) return true;
|
|
5030
|
+
}
|
|
5031
|
+
} else {
|
|
5032
|
+
if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
|
|
5033
|
+
}
|
|
5034
|
+
if (maskTextSelector) {
|
|
5035
|
+
if (checkAncestors) {
|
|
5036
|
+
if (el.closest(maskTextSelector)) return true;
|
|
5037
|
+
} else {
|
|
5038
|
+
if (el.matches(maskTextSelector)) return true;
|
|
5039
|
+
}
|
|
5040
|
+
}
|
|
5041
|
+
} catch (e2) {
|
|
5042
|
+
}
|
|
5043
|
+
return false;
|
|
5044
|
+
}
|
|
5045
|
+
function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
|
|
5046
|
+
const win = iframeEl.contentWindow;
|
|
5047
|
+
if (!win) {
|
|
5048
|
+
return;
|
|
5049
|
+
}
|
|
5050
|
+
let fired = false;
|
|
5051
|
+
let readyState;
|
|
5052
|
+
try {
|
|
5053
|
+
readyState = win.document.readyState;
|
|
5054
|
+
} catch (error) {
|
|
5055
|
+
return;
|
|
5056
|
+
}
|
|
5057
|
+
if (readyState !== "complete") {
|
|
5058
|
+
const timer = setTimeout(() => {
|
|
5059
|
+
if (!fired) {
|
|
5060
|
+
listener();
|
|
5061
|
+
fired = true;
|
|
5062
|
+
}
|
|
5063
|
+
}, iframeLoadTimeout);
|
|
5064
|
+
iframeEl.addEventListener("load", () => {
|
|
5065
|
+
clearTimeout(timer);
|
|
5066
|
+
fired = true;
|
|
5067
|
+
listener();
|
|
5068
|
+
});
|
|
5069
|
+
return;
|
|
5070
|
+
}
|
|
5071
|
+
const blankUrl = "about:blank";
|
|
5072
|
+
if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
|
|
5073
|
+
setTimeout(listener, 0);
|
|
5074
|
+
return iframeEl.addEventListener("load", listener);
|
|
5075
|
+
}
|
|
5076
|
+
iframeEl.addEventListener("load", listener);
|
|
5077
|
+
}
|
|
5078
|
+
function onceStylesheetLoaded(link2, listener, styleSheetLoadTimeout) {
|
|
5079
|
+
let fired = false;
|
|
5080
|
+
let styleSheetLoaded;
|
|
5081
|
+
try {
|
|
5082
|
+
styleSheetLoaded = link2.sheet;
|
|
5083
|
+
} catch (error) {
|
|
5084
|
+
return;
|
|
5085
|
+
}
|
|
5086
|
+
if (styleSheetLoaded) return;
|
|
5087
|
+
const timer = setTimeout(() => {
|
|
5088
|
+
if (!fired) {
|
|
5089
|
+
listener();
|
|
5090
|
+
fired = true;
|
|
5091
|
+
}
|
|
5092
|
+
}, styleSheetLoadTimeout);
|
|
5093
|
+
link2.addEventListener("load", () => {
|
|
5094
|
+
clearTimeout(timer);
|
|
5095
|
+
fired = true;
|
|
5096
|
+
listener();
|
|
5097
|
+
});
|
|
5098
|
+
}
|
|
5099
|
+
function serializeNode(n2, options) {
|
|
5100
|
+
const {
|
|
5101
|
+
doc,
|
|
5102
|
+
mirror: mirror2,
|
|
5103
|
+
blockClass,
|
|
5104
|
+
blockSelector,
|
|
5105
|
+
needsMask,
|
|
5106
|
+
inlineStylesheet,
|
|
5107
|
+
maskInputOptions = {},
|
|
5108
|
+
maskTextFn,
|
|
5109
|
+
maskInputFn,
|
|
5110
|
+
maskAttributeFn,
|
|
5111
|
+
dataURLOptions = {},
|
|
5112
|
+
inlineImages,
|
|
5113
|
+
recordCanvas,
|
|
5114
|
+
keepIframeSrcFn,
|
|
5115
|
+
newlyAddedElement = false,
|
|
5116
|
+
cssCaptured = false,
|
|
5117
|
+
applyBackgroundColorToBlockedElements = false
|
|
5118
|
+
} = options;
|
|
5119
|
+
const rootId = getRootId(doc, mirror2);
|
|
5120
|
+
switch (n2.nodeType) {
|
|
5121
|
+
case n2.DOCUMENT_NODE:
|
|
5122
|
+
if (n2.compatMode !== "CSS1Compat") {
|
|
5123
|
+
return {
|
|
5124
|
+
type: NodeType$3.Document,
|
|
5125
|
+
childNodes: [],
|
|
5126
|
+
compatMode: n2.compatMode
|
|
5127
|
+
// probably "BackCompat"
|
|
5128
|
+
};
|
|
5129
|
+
} else {
|
|
5130
|
+
return {
|
|
5131
|
+
type: NodeType$3.Document,
|
|
5132
|
+
childNodes: []
|
|
5133
|
+
};
|
|
5134
|
+
}
|
|
5135
|
+
case n2.DOCUMENT_TYPE_NODE:
|
|
5136
|
+
return {
|
|
5137
|
+
type: NodeType$3.DocumentType,
|
|
5138
|
+
name: n2.name,
|
|
5139
|
+
publicId: n2.publicId,
|
|
5140
|
+
systemId: n2.systemId,
|
|
5141
|
+
rootId
|
|
5142
|
+
};
|
|
5143
|
+
case n2.ELEMENT_NODE:
|
|
5144
|
+
return serializeElementNode(n2, {
|
|
5145
|
+
doc,
|
|
5146
|
+
blockClass,
|
|
5147
|
+
blockSelector,
|
|
5148
|
+
inlineStylesheet,
|
|
5149
|
+
maskInputOptions,
|
|
5150
|
+
maskInputFn,
|
|
5151
|
+
maskAttributeFn,
|
|
5152
|
+
dataURLOptions,
|
|
5153
|
+
inlineImages,
|
|
5154
|
+
recordCanvas,
|
|
5155
|
+
keepIframeSrcFn,
|
|
5156
|
+
newlyAddedElement,
|
|
5157
|
+
rootId,
|
|
5158
|
+
applyBackgroundColorToBlockedElements
|
|
5159
|
+
});
|
|
5160
|
+
case n2.TEXT_NODE:
|
|
5161
|
+
return serializeTextNode(n2, {
|
|
5162
|
+
doc,
|
|
5163
|
+
needsMask,
|
|
5164
|
+
maskTextFn,
|
|
5165
|
+
rootId,
|
|
5166
|
+
cssCaptured
|
|
5167
|
+
});
|
|
5168
|
+
case n2.CDATA_SECTION_NODE:
|
|
5169
|
+
return {
|
|
5170
|
+
type: NodeType$3.CDATA,
|
|
5171
|
+
textContent: "",
|
|
5172
|
+
rootId
|
|
5173
|
+
};
|
|
5174
|
+
case n2.COMMENT_NODE:
|
|
5175
|
+
return {
|
|
5176
|
+
type: NodeType$3.Comment,
|
|
5177
|
+
textContent: index$1.textContent(n2) || "",
|
|
5178
|
+
rootId
|
|
5179
|
+
};
|
|
5180
|
+
default:
|
|
5181
|
+
return false;
|
|
5182
|
+
}
|
|
5183
|
+
}
|
|
5184
|
+
function getRootId(doc, mirror2) {
|
|
5185
|
+
if (!mirror2.hasNode(doc)) return void 0;
|
|
5186
|
+
const docId = mirror2.getId(doc);
|
|
5187
|
+
return docId === 1 ? void 0 : docId;
|
|
5188
|
+
}
|
|
5189
|
+
function serializeTextNode(n2, options) {
|
|
5190
|
+
const { needsMask, maskTextFn, rootId, cssCaptured } = options;
|
|
5191
|
+
const parent = index$1.parentNode(n2);
|
|
5192
|
+
const parentTagName = parent && parent.tagName;
|
|
5193
|
+
let textContent2 = "";
|
|
5194
|
+
const isStyle = parentTagName === "STYLE" ? true : void 0;
|
|
5195
|
+
const isScript = parentTagName === "SCRIPT" ? true : void 0;
|
|
5196
|
+
if (isScript) {
|
|
5197
|
+
textContent2 = "SCRIPT_PLACEHOLDER";
|
|
5198
|
+
} else if (!cssCaptured) {
|
|
5199
|
+
textContent2 = index$1.textContent(n2);
|
|
5200
|
+
if (isStyle && textContent2) {
|
|
5201
|
+
textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
|
|
5202
|
+
}
|
|
5203
|
+
}
|
|
5204
|
+
if (!isStyle && !isScript && textContent2 && needsMask) {
|
|
5205
|
+
textContent2 = maskTextFn ? maskTextFn(textContent2, index$1.parentElement(n2)) : textContent2.replace(/[\S]/g, "*");
|
|
5206
|
+
}
|
|
5207
|
+
return {
|
|
5208
|
+
type: NodeType$3.Text,
|
|
5209
|
+
textContent: textContent2 || "",
|
|
5210
|
+
rootId
|
|
5211
|
+
};
|
|
5212
|
+
}
|
|
5213
|
+
function serializeElementNode(n2, options) {
|
|
5214
|
+
const {
|
|
5215
|
+
doc,
|
|
5216
|
+
blockClass,
|
|
5217
|
+
blockSelector,
|
|
5218
|
+
inlineStylesheet,
|
|
5219
|
+
maskInputOptions = {},
|
|
5220
|
+
maskInputFn,
|
|
5221
|
+
maskAttributeFn,
|
|
5222
|
+
dataURLOptions = {},
|
|
5223
|
+
inlineImages,
|
|
5224
|
+
recordCanvas,
|
|
5225
|
+
keepIframeSrcFn,
|
|
5226
|
+
newlyAddedElement = false,
|
|
5227
|
+
rootId,
|
|
5228
|
+
applyBackgroundColorToBlockedElements = false
|
|
5229
|
+
} = options;
|
|
5230
|
+
const needBlock = _isBlockedElement(n2, blockClass, blockSelector);
|
|
5231
|
+
const tagName = getValidTagName$1(n2);
|
|
5232
|
+
let attributes = {};
|
|
5233
|
+
const len = n2.attributes.length;
|
|
5234
|
+
for (let i2 = 0; i2 < len; i2++) {
|
|
5235
|
+
const attr = n2.attributes[i2];
|
|
5236
|
+
if (!ignoreAttribute(tagName, attr.name, attr.value)) {
|
|
5237
|
+
const transformedValue = transformAttribute(
|
|
5238
|
+
doc,
|
|
5239
|
+
tagName,
|
|
5240
|
+
toLowerCase(attr.name),
|
|
5241
|
+
attr.value
|
|
5242
|
+
);
|
|
5243
|
+
if (maskAttributeFn && transformedValue !== null) {
|
|
5244
|
+
const maskedValue = maskAttributeFn(attr.name, transformedValue, n2);
|
|
5245
|
+
if (maskedValue !== null) {
|
|
5246
|
+
attributes[attr.name] = maskedValue;
|
|
5247
|
+
}
|
|
5248
|
+
} else {
|
|
5249
|
+
attributes[attr.name] = transformedValue;
|
|
5250
|
+
}
|
|
5251
|
+
}
|
|
5252
|
+
}
|
|
5253
|
+
if (tagName === "link" && inlineStylesheet) {
|
|
5254
|
+
const stylesheet = Array.from(doc.styleSheets).find((s2) => {
|
|
5255
|
+
return s2.href === n2.href;
|
|
5256
|
+
});
|
|
5257
|
+
let cssText = null;
|
|
5258
|
+
if (stylesheet) {
|
|
5259
|
+
cssText = stringifyStylesheet(stylesheet);
|
|
5260
|
+
}
|
|
5261
|
+
if (cssText) {
|
|
5262
|
+
delete attributes.rel;
|
|
5263
|
+
delete attributes.href;
|
|
5264
|
+
attributes._cssText = cssText;
|
|
5265
|
+
}
|
|
5266
|
+
}
|
|
5267
|
+
if (tagName === "style" && n2.sheet) {
|
|
5268
|
+
let cssText = stringifyStylesheet(
|
|
5269
|
+
n2.sheet
|
|
5270
|
+
);
|
|
5271
|
+
if (cssText) {
|
|
5272
|
+
if (n2.childNodes.length > 1) {
|
|
5273
|
+
cssText = markCssSplits(cssText, n2);
|
|
5274
|
+
}
|
|
5275
|
+
attributes._cssText = cssText;
|
|
5276
|
+
}
|
|
5277
|
+
}
|
|
5278
|
+
if (tagName === "input" || tagName === "textarea" || tagName === "select") {
|
|
5279
|
+
const value = n2.value;
|
|
5280
|
+
const checked = n2.checked;
|
|
5281
|
+
if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
|
|
5282
|
+
attributes.value = maskInputValue({
|
|
5283
|
+
element: n2,
|
|
5284
|
+
type: getInputType(n2),
|
|
5285
|
+
tagName,
|
|
5286
|
+
value,
|
|
5287
|
+
maskInputOptions,
|
|
5288
|
+
maskInputFn
|
|
5289
|
+
});
|
|
5290
|
+
} else if (checked) {
|
|
5291
|
+
attributes.checked = checked;
|
|
5292
|
+
}
|
|
5293
|
+
}
|
|
5294
|
+
if (tagName === "option") {
|
|
5295
|
+
if (n2.selected && !maskInputOptions["select"]) {
|
|
5296
|
+
attributes.selected = true;
|
|
5297
|
+
} else {
|
|
5298
|
+
delete attributes.selected;
|
|
5299
|
+
}
|
|
5300
|
+
}
|
|
5301
|
+
if (tagName === "dialog" && n2.open) {
|
|
5302
|
+
attributes.rr_open_mode = n2.matches("dialog:modal") ? "modal" : "non-modal";
|
|
5303
|
+
}
|
|
5304
|
+
if (tagName === "canvas" && recordCanvas) {
|
|
5305
|
+
if (n2.__context === "2d") {
|
|
5306
|
+
if (!is2DCanvasBlank(n2)) {
|
|
5307
|
+
attributes.rr_dataURL = n2.toDataURL(
|
|
5308
|
+
dataURLOptions.type,
|
|
5309
|
+
dataURLOptions.quality
|
|
5310
|
+
);
|
|
5311
|
+
}
|
|
5312
|
+
} else if (!("__context" in n2)) {
|
|
5313
|
+
const canvasDataURL = n2.toDataURL(
|
|
5314
|
+
dataURLOptions.type,
|
|
5315
|
+
dataURLOptions.quality
|
|
5316
|
+
);
|
|
5317
|
+
const blankCanvas = doc.createElement("canvas");
|
|
5318
|
+
blankCanvas.width = n2.width;
|
|
5319
|
+
blankCanvas.height = n2.height;
|
|
5320
|
+
const blankCanvasDataURL = blankCanvas.toDataURL(
|
|
5321
|
+
dataURLOptions.type,
|
|
5322
|
+
dataURLOptions.quality
|
|
5323
|
+
);
|
|
5324
|
+
if (canvasDataURL !== blankCanvasDataURL) {
|
|
5325
|
+
attributes.rr_dataURL = canvasDataURL;
|
|
5326
|
+
}
|
|
5327
|
+
}
|
|
5328
|
+
}
|
|
5329
|
+
if (tagName === "img" && inlineImages) {
|
|
5330
|
+
if (!canvasService) {
|
|
5331
|
+
canvasService = doc.createElement("canvas");
|
|
5332
|
+
canvasCtx = canvasService.getContext("2d");
|
|
5333
|
+
}
|
|
5334
|
+
const image = n2;
|
|
5335
|
+
const imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
|
|
5336
|
+
const priorCrossOrigin = image.crossOrigin;
|
|
5337
|
+
const recordInlineImage = () => {
|
|
5338
|
+
image.removeEventListener("load", recordInlineImage);
|
|
5339
|
+
try {
|
|
5340
|
+
canvasService.width = image.naturalWidth;
|
|
5341
|
+
canvasService.height = image.naturalHeight;
|
|
5342
|
+
canvasCtx.drawImage(image, 0, 0);
|
|
5343
|
+
attributes.rr_dataURL = canvasService.toDataURL(
|
|
5344
|
+
dataURLOptions.type,
|
|
5345
|
+
dataURLOptions.quality
|
|
5346
|
+
);
|
|
5347
|
+
} catch (err) {
|
|
5348
|
+
if (image.crossOrigin !== "anonymous") {
|
|
5349
|
+
image.crossOrigin = "anonymous";
|
|
5350
|
+
if (image.complete && image.naturalWidth !== 0)
|
|
5351
|
+
recordInlineImage();
|
|
5352
|
+
else image.addEventListener("load", recordInlineImage);
|
|
5353
|
+
return;
|
|
5354
|
+
} else {
|
|
5355
|
+
console.warn(
|
|
5356
|
+
`Cannot inline img src=${imageSrc}! Error: ${err}`
|
|
5357
|
+
);
|
|
5358
|
+
}
|
|
5359
|
+
}
|
|
5360
|
+
if (image.crossOrigin === "anonymous") {
|
|
5361
|
+
priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
|
|
5362
|
+
}
|
|
5363
|
+
};
|
|
5364
|
+
if (image.complete && image.naturalWidth !== 0) recordInlineImage();
|
|
5365
|
+
else image.addEventListener("load", recordInlineImage);
|
|
5366
|
+
}
|
|
5367
|
+
if (tagName === "audio" || tagName === "video") {
|
|
5368
|
+
const mediaAttributes = attributes;
|
|
5369
|
+
mediaAttributes.rr_mediaState = n2.paused ? "paused" : "played";
|
|
5370
|
+
mediaAttributes.rr_mediaCurrentTime = n2.currentTime;
|
|
5371
|
+
mediaAttributes.rr_mediaPlaybackRate = n2.playbackRate;
|
|
5372
|
+
mediaAttributes.rr_mediaMuted = n2.muted;
|
|
5373
|
+
mediaAttributes.rr_mediaLoop = n2.loop;
|
|
5374
|
+
mediaAttributes.rr_mediaVolume = n2.volume;
|
|
5375
|
+
}
|
|
5376
|
+
if (!newlyAddedElement) {
|
|
5377
|
+
if (n2.scrollLeft) {
|
|
5378
|
+
attributes.rr_scrollLeft = n2.scrollLeft;
|
|
5379
|
+
}
|
|
5380
|
+
if (n2.scrollTop) {
|
|
5381
|
+
attributes.rr_scrollTop = n2.scrollTop;
|
|
5382
|
+
}
|
|
5383
|
+
}
|
|
5384
|
+
if (needBlock) {
|
|
5385
|
+
const { width, height } = n2.getBoundingClientRect();
|
|
5386
|
+
attributes = __spreadValues({
|
|
5387
|
+
class: attributes.class,
|
|
5388
|
+
rr_width: `${width}px`,
|
|
5389
|
+
rr_height: `${height}px`
|
|
5390
|
+
}, applyBackgroundColorToBlockedElements ? { rr_background_color: _DEFAULT_BLOCKED_ELEMENT_BACKGROUND_COLOR } : {});
|
|
5391
|
+
}
|
|
5392
|
+
if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
|
|
5393
|
+
if (!n2.contentDocument) {
|
|
5394
|
+
attributes.rr_src = attributes.src;
|
|
5395
|
+
}
|
|
5396
|
+
delete attributes.src;
|
|
5397
|
+
}
|
|
5398
|
+
let isCustomElement;
|
|
5399
|
+
try {
|
|
5400
|
+
if (customElements.get(tagName)) isCustomElement = true;
|
|
5401
|
+
} catch (e2) {
|
|
5402
|
+
}
|
|
5403
|
+
return {
|
|
5404
|
+
type: NodeType$3.Element,
|
|
5405
|
+
tagName,
|
|
5406
|
+
attributes,
|
|
5407
|
+
childNodes: [],
|
|
5408
|
+
isSVG: isSVGElement(n2) || void 0,
|
|
5409
|
+
needBlock,
|
|
5410
|
+
rootId,
|
|
5411
|
+
isCustom: isCustomElement
|
|
5412
|
+
};
|
|
5413
|
+
}
|
|
5414
|
+
function lowerIfExists(maybeAttr) {
|
|
5415
|
+
if (maybeAttr === void 0 || maybeAttr === null) {
|
|
5416
|
+
return "";
|
|
5417
|
+
} else {
|
|
5418
|
+
return maybeAttr.toLowerCase();
|
|
5419
|
+
}
|
|
5420
|
+
}
|
|
5421
|
+
function slimDOMExcluded(sn, slimDOMOptions) {
|
|
5422
|
+
if (slimDOMOptions.comment && sn.type === NodeType$3.Comment) {
|
|
5423
|
+
return true;
|
|
5424
|
+
} else if (sn.type === NodeType$3.Element) {
|
|
5425
|
+
if (slimDOMOptions.script && // script tag
|
|
5426
|
+
(sn.tagName === "script" || // (module)preload link
|
|
5427
|
+
sn.tagName === "link" && (sn.attributes.rel === "preload" || sn.attributes.rel === "modulepreload") && sn.attributes.as === "script" || // prefetch link
|
|
5428
|
+
sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && extractFileExtension(sn.attributes.href) === "js")) {
|
|
5429
|
+
return true;
|
|
5430
|
+
} else if (slimDOMOptions.headFavicon && (sn.tagName === "link" && sn.attributes.rel === "shortcut icon" || sn.tagName === "meta" && (lowerIfExists(sn.attributes.name).match(
|
|
5431
|
+
/^msapplication-tile(image|color)$/
|
|
5432
|
+
) || lowerIfExists(sn.attributes.name) === "application-name" || lowerIfExists(sn.attributes.rel) === "icon" || lowerIfExists(sn.attributes.rel) === "apple-touch-icon" || lowerIfExists(sn.attributes.rel) === "shortcut icon"))) {
|
|
5433
|
+
return true;
|
|
5434
|
+
} else if (sn.tagName === "meta") {
|
|
5435
|
+
if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
|
|
5436
|
+
return true;
|
|
5437
|
+
} else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
|
|
5438
|
+
lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
|
|
5439
|
+
return true;
|
|
5440
|
+
} else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
|
|
5441
|
+
return true;
|
|
5442
|
+
} else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
|
|
5443
|
+
return true;
|
|
5444
|
+
} else if (slimDOMOptions.headMetaAuthorship && (lowerIfExists(sn.attributes.name) === "author" || lowerIfExists(sn.attributes.name) === "generator" || lowerIfExists(sn.attributes.name) === "framework" || lowerIfExists(sn.attributes.name) === "publisher" || lowerIfExists(sn.attributes.name) === "progid" || lowerIfExists(sn.attributes.property).match(/^article:/) || lowerIfExists(sn.attributes.property).match(/^product:/))) {
|
|
5445
|
+
return true;
|
|
5446
|
+
} else if (slimDOMOptions.headMetaVerification && (lowerIfExists(sn.attributes.name) === "google-site-verification" || lowerIfExists(sn.attributes.name) === "yandex-verification" || lowerIfExists(sn.attributes.name) === "csrf-token" || lowerIfExists(sn.attributes.name) === "p:domain_verify" || lowerIfExists(sn.attributes.name) === "verify-v1" || lowerIfExists(sn.attributes.name) === "verification" || lowerIfExists(sn.attributes.name) === "shopify-checkout-api-token")) {
|
|
5447
|
+
return true;
|
|
5448
|
+
}
|
|
5449
|
+
}
|
|
5450
|
+
}
|
|
5451
|
+
return false;
|
|
5452
|
+
}
|
|
5453
|
+
function serializeNodeWithId(n2, options) {
|
|
5454
|
+
const {
|
|
5455
|
+
doc,
|
|
5456
|
+
mirror: mirror2,
|
|
5457
|
+
blockClass,
|
|
5458
|
+
blockSelector,
|
|
5459
|
+
maskTextClass,
|
|
5460
|
+
maskTextSelector,
|
|
5461
|
+
skipChild = false,
|
|
5462
|
+
inlineStylesheet = true,
|
|
5463
|
+
maskInputOptions = {},
|
|
5464
|
+
maskTextFn,
|
|
5465
|
+
maskInputFn,
|
|
5466
|
+
maskAttributeFn,
|
|
5467
|
+
slimDOMOptions,
|
|
5468
|
+
dataURLOptions = {},
|
|
5469
|
+
inlineImages = false,
|
|
5470
|
+
recordCanvas = false,
|
|
5471
|
+
onSerialize,
|
|
5472
|
+
onIframeLoad,
|
|
5473
|
+
iframeLoadTimeout = 5e3,
|
|
5474
|
+
onStylesheetLoad,
|
|
5475
|
+
stylesheetLoadTimeout = 5e3,
|
|
5476
|
+
keepIframeSrcFn = () => false,
|
|
5477
|
+
newlyAddedElement = false,
|
|
5478
|
+
cssCaptured = false,
|
|
5479
|
+
applyBackgroundColorToBlockedElements = false
|
|
5480
|
+
} = options;
|
|
5481
|
+
let { needsMask } = options;
|
|
5482
|
+
let { preserveWhiteSpace = true } = options;
|
|
5483
|
+
if (!needsMask) {
|
|
5484
|
+
const checkAncestors = needsMask === void 0;
|
|
5485
|
+
needsMask = needMaskingText(
|
|
5486
|
+
n2,
|
|
5487
|
+
maskTextClass,
|
|
5488
|
+
maskTextSelector,
|
|
5489
|
+
checkAncestors
|
|
5490
|
+
);
|
|
5491
|
+
}
|
|
5492
|
+
const _serializedNode = serializeNode(n2, {
|
|
5493
|
+
doc,
|
|
5494
|
+
mirror: mirror2,
|
|
5495
|
+
blockClass,
|
|
5496
|
+
blockSelector,
|
|
5497
|
+
needsMask,
|
|
5498
|
+
inlineStylesheet,
|
|
5499
|
+
maskInputOptions,
|
|
5500
|
+
maskTextFn,
|
|
5501
|
+
maskInputFn,
|
|
5502
|
+
maskAttributeFn,
|
|
5503
|
+
dataURLOptions,
|
|
5504
|
+
inlineImages,
|
|
5505
|
+
recordCanvas,
|
|
5506
|
+
keepIframeSrcFn,
|
|
5507
|
+
newlyAddedElement,
|
|
5508
|
+
cssCaptured,
|
|
5509
|
+
applyBackgroundColorToBlockedElements
|
|
5510
|
+
});
|
|
5511
|
+
if (!_serializedNode) {
|
|
5512
|
+
console.warn(n2, "not serialized");
|
|
5513
|
+
return null;
|
|
5514
|
+
}
|
|
5515
|
+
let id;
|
|
5516
|
+
if (mirror2.hasNode(n2)) {
|
|
5517
|
+
id = mirror2.getId(n2);
|
|
5518
|
+
} else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$3.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
|
|
5519
|
+
id = IGNORED_NODE;
|
|
5520
|
+
} else {
|
|
5521
|
+
id = genId();
|
|
5522
|
+
}
|
|
5523
|
+
const serializedNode = Object.assign(_serializedNode, { id });
|
|
5524
|
+
mirror2.add(n2, serializedNode);
|
|
5525
|
+
if (id === IGNORED_NODE) {
|
|
5526
|
+
return null;
|
|
5527
|
+
}
|
|
5528
|
+
if (onSerialize) {
|
|
5529
|
+
onSerialize(n2);
|
|
5530
|
+
}
|
|
5531
|
+
let recordChild = !skipChild;
|
|
5532
|
+
if (serializedNode.type === NodeType$3.Element) {
|
|
5533
|
+
recordChild = recordChild && !serializedNode.needBlock;
|
|
5534
|
+
delete serializedNode.needBlock;
|
|
5535
|
+
const shadowRootEl = index$1.shadowRoot(n2);
|
|
5536
|
+
if (shadowRootEl && isNativeShadowDom(shadowRootEl))
|
|
5537
|
+
serializedNode.isShadowHost = true;
|
|
5538
|
+
}
|
|
5539
|
+
if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
|
|
5540
|
+
if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
|
|
5541
|
+
preserveWhiteSpace = false;
|
|
5542
|
+
}
|
|
5543
|
+
const bypassOptions = {
|
|
5544
|
+
doc,
|
|
5545
|
+
mirror: mirror2,
|
|
5546
|
+
blockClass,
|
|
5547
|
+
blockSelector,
|
|
5548
|
+
needsMask,
|
|
5549
|
+
maskTextClass,
|
|
5550
|
+
maskTextSelector,
|
|
5551
|
+
skipChild,
|
|
5552
|
+
inlineStylesheet,
|
|
5553
|
+
maskInputOptions,
|
|
5554
|
+
maskTextFn,
|
|
5555
|
+
maskInputFn,
|
|
5556
|
+
maskAttributeFn,
|
|
5557
|
+
slimDOMOptions,
|
|
5558
|
+
dataURLOptions,
|
|
5559
|
+
inlineImages,
|
|
5560
|
+
recordCanvas,
|
|
5561
|
+
preserveWhiteSpace,
|
|
5562
|
+
onSerialize,
|
|
5563
|
+
onIframeLoad,
|
|
5564
|
+
iframeLoadTimeout,
|
|
5565
|
+
onStylesheetLoad,
|
|
5566
|
+
stylesheetLoadTimeout,
|
|
5567
|
+
keepIframeSrcFn,
|
|
5568
|
+
cssCaptured: false,
|
|
5569
|
+
applyBackgroundColorToBlockedElements
|
|
5570
|
+
};
|
|
5571
|
+
if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
|
|
5572
|
+
else {
|
|
5573
|
+
if (serializedNode.type === NodeType$3.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") {
|
|
5574
|
+
bypassOptions.cssCaptured = true;
|
|
5575
|
+
}
|
|
5576
|
+
for (const childN of Array.from(index$1.childNodes(n2))) {
|
|
5577
|
+
const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
5578
|
+
if (serializedChildNode) {
|
|
5579
|
+
serializedNode.childNodes.push(serializedChildNode);
|
|
5580
|
+
}
|
|
5581
|
+
}
|
|
5582
|
+
}
|
|
5583
|
+
let shadowRootEl = null;
|
|
5584
|
+
if (isElement(n2) && (shadowRootEl = index$1.shadowRoot(n2))) {
|
|
5585
|
+
for (const childN of Array.from(index$1.childNodes(shadowRootEl))) {
|
|
5586
|
+
const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
5587
|
+
if (serializedChildNode) {
|
|
5588
|
+
isNativeShadowDom(shadowRootEl) && (serializedChildNode.isShadow = true);
|
|
5589
|
+
serializedNode.childNodes.push(serializedChildNode);
|
|
5590
|
+
}
|
|
5591
|
+
}
|
|
5592
|
+
}
|
|
5593
|
+
}
|
|
5594
|
+
const parent = index$1.parentNode(n2);
|
|
5595
|
+
if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
|
|
5596
|
+
serializedNode.isShadow = true;
|
|
5597
|
+
}
|
|
5598
|
+
if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "iframe") {
|
|
5599
|
+
onceIframeLoaded(
|
|
5600
|
+
n2,
|
|
5601
|
+
() => {
|
|
5602
|
+
const iframeDoc = n2.contentDocument;
|
|
5603
|
+
if (iframeDoc && onIframeLoad) {
|
|
5604
|
+
const serializedIframeNode = serializeNodeWithId(iframeDoc, {
|
|
5605
|
+
doc: iframeDoc,
|
|
5606
|
+
mirror: mirror2,
|
|
5607
|
+
blockClass,
|
|
5608
|
+
blockSelector,
|
|
5609
|
+
needsMask,
|
|
5610
|
+
maskTextClass,
|
|
5611
|
+
maskTextSelector,
|
|
5612
|
+
skipChild: false,
|
|
5613
|
+
inlineStylesheet,
|
|
5614
|
+
maskInputOptions,
|
|
5615
|
+
maskTextFn,
|
|
5616
|
+
maskInputFn,
|
|
5617
|
+
maskAttributeFn,
|
|
5618
|
+
slimDOMOptions,
|
|
5619
|
+
dataURLOptions,
|
|
5620
|
+
inlineImages,
|
|
5621
|
+
recordCanvas,
|
|
5622
|
+
preserveWhiteSpace,
|
|
5623
|
+
onSerialize,
|
|
5624
|
+
onIframeLoad,
|
|
5625
|
+
iframeLoadTimeout,
|
|
5626
|
+
onStylesheetLoad,
|
|
5627
|
+
stylesheetLoadTimeout,
|
|
5628
|
+
keepIframeSrcFn
|
|
5629
|
+
});
|
|
5630
|
+
if (serializedIframeNode) {
|
|
5631
|
+
onIframeLoad(
|
|
5632
|
+
n2,
|
|
5633
|
+
serializedIframeNode
|
|
5634
|
+
);
|
|
5635
|
+
}
|
|
5636
|
+
}
|
|
5637
|
+
},
|
|
5638
|
+
iframeLoadTimeout
|
|
5639
|
+
);
|
|
5640
|
+
}
|
|
5641
|
+
if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "link" && typeof serializedNode.attributes.rel === "string" && (serializedNode.attributes.rel === "stylesheet" || serializedNode.attributes.rel === "preload" && typeof serializedNode.attributes.href === "string" && extractFileExtension(serializedNode.attributes.href) === "css")) {
|
|
5642
|
+
onceStylesheetLoaded(
|
|
5643
|
+
n2,
|
|
5644
|
+
() => {
|
|
5645
|
+
if (onStylesheetLoad) {
|
|
5646
|
+
const serializedLinkNode = serializeNodeWithId(n2, {
|
|
5647
|
+
doc,
|
|
5648
|
+
mirror: mirror2,
|
|
5649
|
+
blockClass,
|
|
5650
|
+
blockSelector,
|
|
5651
|
+
needsMask,
|
|
5652
|
+
maskTextClass,
|
|
5653
|
+
maskTextSelector,
|
|
5654
|
+
skipChild: false,
|
|
5655
|
+
inlineStylesheet,
|
|
5656
|
+
maskInputOptions,
|
|
5657
|
+
maskTextFn,
|
|
5658
|
+
maskInputFn,
|
|
5659
|
+
maskAttributeFn,
|
|
5660
|
+
slimDOMOptions,
|
|
5661
|
+
dataURLOptions,
|
|
5662
|
+
inlineImages,
|
|
5663
|
+
recordCanvas,
|
|
5664
|
+
preserveWhiteSpace,
|
|
5665
|
+
onSerialize,
|
|
5666
|
+
onIframeLoad,
|
|
5667
|
+
iframeLoadTimeout,
|
|
5668
|
+
onStylesheetLoad,
|
|
5669
|
+
stylesheetLoadTimeout,
|
|
5670
|
+
keepIframeSrcFn
|
|
5671
|
+
});
|
|
5672
|
+
if (serializedLinkNode) {
|
|
5673
|
+
onStylesheetLoad(
|
|
5674
|
+
n2,
|
|
5675
|
+
serializedLinkNode
|
|
5676
|
+
);
|
|
5677
|
+
}
|
|
5678
|
+
}
|
|
5679
|
+
},
|
|
5680
|
+
stylesheetLoadTimeout
|
|
5681
|
+
);
|
|
5682
|
+
}
|
|
5683
|
+
return serializedNode;
|
|
5684
|
+
}
|
|
5685
|
+
function snapshot(n2, options) {
|
|
5686
|
+
const {
|
|
5687
|
+
mirror: mirror2 = new Mirror(),
|
|
5688
|
+
blockClass = "rr-block",
|
|
5689
|
+
blockSelector = null,
|
|
5690
|
+
maskTextClass = "rr-mask",
|
|
5691
|
+
maskTextSelector = null,
|
|
5692
|
+
inlineStylesheet = true,
|
|
5693
|
+
inlineImages = false,
|
|
5694
|
+
recordCanvas = false,
|
|
5695
|
+
maskAllInputs = false,
|
|
5696
|
+
maskTextFn,
|
|
5697
|
+
maskInputFn,
|
|
5698
|
+
maskAttributeFn,
|
|
5699
|
+
slimDOM = false,
|
|
5700
|
+
dataURLOptions,
|
|
5701
|
+
preserveWhiteSpace,
|
|
5702
|
+
onSerialize,
|
|
5703
|
+
onIframeLoad,
|
|
5704
|
+
iframeLoadTimeout,
|
|
5705
|
+
onStylesheetLoad,
|
|
5706
|
+
stylesheetLoadTimeout,
|
|
5707
|
+
keepIframeSrcFn = () => false,
|
|
5708
|
+
applyBackgroundColorToBlockedElements = false
|
|
5709
|
+
} = options || {};
|
|
5710
|
+
const maskInputOptions = maskAllInputs === true ? {
|
|
5711
|
+
color: true,
|
|
5712
|
+
date: true,
|
|
5713
|
+
"datetime-local": true,
|
|
5714
|
+
email: true,
|
|
5715
|
+
month: true,
|
|
5716
|
+
number: true,
|
|
5717
|
+
range: true,
|
|
5718
|
+
search: true,
|
|
5719
|
+
tel: true,
|
|
5720
|
+
text: true,
|
|
5721
|
+
time: true,
|
|
5722
|
+
url: true,
|
|
5723
|
+
week: true,
|
|
5724
|
+
textarea: true,
|
|
5725
|
+
select: true,
|
|
5726
|
+
password: true
|
|
5727
|
+
} : maskAllInputs === false ? {
|
|
5728
|
+
password: true
|
|
5729
|
+
} : maskAllInputs;
|
|
5730
|
+
const slimDOMOptions = slimDOM === true || slimDOM === "all" ? (
|
|
5731
|
+
// if true: set of sensible options that should not throw away any information
|
|
5732
|
+
{
|
|
5733
|
+
script: true,
|
|
5734
|
+
comment: true,
|
|
5735
|
+
headFavicon: true,
|
|
5736
|
+
headWhitespace: true,
|
|
5737
|
+
headMetaDescKeywords: slimDOM === "all",
|
|
5738
|
+
// destructive
|
|
5739
|
+
headMetaSocial: true,
|
|
5740
|
+
headMetaRobots: true,
|
|
5741
|
+
headMetaHttpEquiv: true,
|
|
5742
|
+
headMetaAuthorship: true,
|
|
5743
|
+
headMetaVerification: true
|
|
5744
|
+
}
|
|
5745
|
+
) : slimDOM === false ? {} : slimDOM;
|
|
5746
|
+
return serializeNodeWithId(n2, {
|
|
5747
|
+
doc: n2,
|
|
5748
|
+
mirror: mirror2,
|
|
5749
|
+
blockClass,
|
|
5750
|
+
blockSelector,
|
|
5751
|
+
maskTextClass,
|
|
5752
|
+
maskTextSelector,
|
|
5753
|
+
skipChild: false,
|
|
5754
|
+
inlineStylesheet,
|
|
5755
|
+
maskInputOptions,
|
|
5756
|
+
maskTextFn,
|
|
5757
|
+
maskInputFn,
|
|
5758
|
+
maskAttributeFn,
|
|
5759
|
+
slimDOMOptions,
|
|
5760
|
+
dataURLOptions,
|
|
5761
|
+
inlineImages,
|
|
5762
|
+
recordCanvas,
|
|
5763
|
+
preserveWhiteSpace,
|
|
5764
|
+
onSerialize,
|
|
5765
|
+
onIframeLoad,
|
|
5766
|
+
iframeLoadTimeout,
|
|
5767
|
+
onStylesheetLoad,
|
|
5768
|
+
stylesheetLoadTimeout,
|
|
5769
|
+
keepIframeSrcFn,
|
|
5770
|
+
newlyAddedElement: false,
|
|
5771
|
+
applyBackgroundColorToBlockedElements
|
|
5772
|
+
});
|
|
5773
|
+
}
|
|
4398
5774
|
const MEDIA_SELECTOR = /(max|min)-device-(width|height)/;
|
|
4399
5775
|
const MEDIA_SELECTOR_GLOBAL = new RegExp(MEDIA_SELECTOR.source, "g");
|
|
4400
5776
|
const mediaSelectorPlugin = {
|
|
@@ -14068,6 +15444,8 @@ var ReplayerEvents = /* @__PURE__ */ ((ReplayerEvents2) => {
|
|
|
14068
15444
|
ReplayerEvents2["StateChange"] = "state-change";
|
|
14069
15445
|
ReplayerEvents2["PlayBack"] = "play-back";
|
|
14070
15446
|
ReplayerEvents2["Destroy"] = "destroy";
|
|
15447
|
+
ReplayerEvents2["SeekStart"] = "seek-start";
|
|
15448
|
+
ReplayerEvents2["SeekEnd"] = "seek-end";
|
|
14071
15449
|
return ReplayerEvents2;
|
|
14072
15450
|
})(ReplayerEvents || {});
|
|
14073
15451
|
var NodeType = /* @__PURE__ */ ((NodeType2) => {
|
|
@@ -14117,6 +15495,86 @@ try {
|
|
|
14117
15495
|
console.debug("Unable to override Array.from", err);
|
|
14118
15496
|
}
|
|
14119
15497
|
createMirror$2();
|
|
15498
|
+
class SeekCache {
|
|
15499
|
+
constructor(maxEntries = 10) {
|
|
15500
|
+
__publicField2(this, "entries", []);
|
|
15501
|
+
__publicField2(this, "maxEntries");
|
|
15502
|
+
this.maxEntries = maxEntries;
|
|
15503
|
+
}
|
|
15504
|
+
/**
|
|
15505
|
+
* Store a new checkpoint. Entries are kept sorted by timestamp.
|
|
15506
|
+
* When the cache is full the oldest entry is evicted.
|
|
15507
|
+
*/
|
|
15508
|
+
add(timestamp, snapshotNode, initialOffset) {
|
|
15509
|
+
const event2 = {
|
|
15510
|
+
type: EventType$1.FullSnapshot,
|
|
15511
|
+
data: { node: snapshotNode, initialOffset },
|
|
15512
|
+
timestamp
|
|
15513
|
+
};
|
|
15514
|
+
const entry = { timestamp, event: event2 };
|
|
15515
|
+
if (!this.entries.length || this.entries[this.entries.length - 1].timestamp < timestamp) {
|
|
15516
|
+
this.entries.push(entry);
|
|
15517
|
+
} else {
|
|
15518
|
+
let lo = 0;
|
|
15519
|
+
let hi = this.entries.length - 1;
|
|
15520
|
+
while (lo <= hi) {
|
|
15521
|
+
const mid = lo + hi >>> 1;
|
|
15522
|
+
if (this.entries[mid].timestamp <= timestamp) lo = mid + 1;
|
|
15523
|
+
else hi = mid - 1;
|
|
15524
|
+
}
|
|
15525
|
+
if (lo > 0 && this.entries[lo - 1].timestamp === timestamp) {
|
|
15526
|
+
this.entries[lo - 1] = entry;
|
|
15527
|
+
} else {
|
|
15528
|
+
this.entries.splice(lo, 0, entry);
|
|
15529
|
+
}
|
|
15530
|
+
}
|
|
15531
|
+
if (this.entries.length > this.maxEntries) {
|
|
15532
|
+
this.entries.shift();
|
|
15533
|
+
}
|
|
15534
|
+
}
|
|
15535
|
+
/**
|
|
15536
|
+
* Find the best cached checkpoint for seeking to `targetTime`.
|
|
15537
|
+
*
|
|
15538
|
+
* The checkpoint must be:
|
|
15539
|
+
* - at or before `targetTime` (we cannot seek forward past the snapshot)
|
|
15540
|
+
* - strictly after `baselineMetaTimestamp` (ensures the snapshot belongs to
|
|
15541
|
+
* the same recording session / checkout as the current seek)
|
|
15542
|
+
*
|
|
15543
|
+
* Returns `null` on cache miss.
|
|
15544
|
+
*/
|
|
15545
|
+
findBestFor(targetTime, baselineMetaTimestamp) {
|
|
15546
|
+
let lo = 0;
|
|
15547
|
+
let hi = this.entries.length - 1;
|
|
15548
|
+
let best = -1;
|
|
15549
|
+
while (lo <= hi) {
|
|
15550
|
+
const mid = lo + hi >>> 1;
|
|
15551
|
+
if (this.entries[mid].timestamp <= targetTime) {
|
|
15552
|
+
best = mid;
|
|
15553
|
+
lo = mid + 1;
|
|
15554
|
+
} else {
|
|
15555
|
+
hi = mid - 1;
|
|
15556
|
+
}
|
|
15557
|
+
}
|
|
15558
|
+
if (best === -1) return null;
|
|
15559
|
+
for (let i2 = best; i2 >= 0; i2--) {
|
|
15560
|
+
if (this.entries[i2].timestamp > baselineMetaTimestamp) {
|
|
15561
|
+
return this.entries[i2];
|
|
15562
|
+
}
|
|
15563
|
+
}
|
|
15564
|
+
return null;
|
|
15565
|
+
}
|
|
15566
|
+
/** Remove all cached entries (e.g. when a new set of events is loaded). */
|
|
15567
|
+
clear() {
|
|
15568
|
+
this.entries = [];
|
|
15569
|
+
}
|
|
15570
|
+
get size() {
|
|
15571
|
+
return this.entries.length;
|
|
15572
|
+
}
|
|
15573
|
+
/** Expose entries for testing. */
|
|
15574
|
+
getEntries() {
|
|
15575
|
+
return this.entries;
|
|
15576
|
+
}
|
|
15577
|
+
}
|
|
14120
15578
|
function mitt$1(n2) {
|
|
14121
15579
|
return { all: n2 = n2 || /* @__PURE__ */ new Map(), on: function(t2, e2) {
|
|
14122
15580
|
var i2 = n2.get(t2);
|
|
@@ -14589,13 +16047,31 @@ function v(t2) {
|
|
|
14589
16047
|
} };
|
|
14590
16048
|
return c2;
|
|
14591
16049
|
}
|
|
16050
|
+
function isDuplicateEvent(existing, incoming) {
|
|
16051
|
+
if (existing === incoming) {
|
|
16052
|
+
return true;
|
|
16053
|
+
}
|
|
16054
|
+
if (existing.timestamp === incoming.timestamp && existing.type === incoming.type) {
|
|
16055
|
+
return JSON.stringify(existing) === JSON.stringify(incoming);
|
|
16056
|
+
}
|
|
16057
|
+
return false;
|
|
16058
|
+
}
|
|
14592
16059
|
function discardPriorSnapshots(events, baselineTime) {
|
|
14593
|
-
|
|
14594
|
-
|
|
14595
|
-
|
|
14596
|
-
|
|
14597
|
-
|
|
14598
|
-
|
|
16060
|
+
let lo = 0;
|
|
16061
|
+
let hi = events.length - 1;
|
|
16062
|
+
let lastBeforeOrAt = -1;
|
|
16063
|
+
while (lo <= hi) {
|
|
16064
|
+
const mid = lo + hi >>> 1;
|
|
16065
|
+
if (events[mid].timestamp <= baselineTime) {
|
|
16066
|
+
lastBeforeOrAt = mid;
|
|
16067
|
+
lo = mid + 1;
|
|
16068
|
+
} else {
|
|
16069
|
+
hi = mid - 1;
|
|
16070
|
+
}
|
|
16071
|
+
}
|
|
16072
|
+
for (let idx = lastBeforeOrAt; idx >= 0; idx--) {
|
|
16073
|
+
if (events[idx].type === EventType$1.Meta) {
|
|
16074
|
+
return events.slice(idx);
|
|
14599
16075
|
}
|
|
14600
16076
|
}
|
|
14601
16077
|
return events;
|
|
@@ -14682,12 +16158,10 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
|
|
|
14682
16158
|
});
|
|
14683
16159
|
}),
|
|
14684
16160
|
play(ctx) {
|
|
16161
|
+
var _a4;
|
|
14685
16162
|
var _a22;
|
|
14686
16163
|
const { timer, events, baselineTime, lastPlayedEvent } = ctx;
|
|
14687
16164
|
timer.clear();
|
|
14688
|
-
for (const event2 of events) {
|
|
14689
|
-
addDelay(event2, baselineTime);
|
|
14690
|
-
}
|
|
14691
16165
|
const neededEvents = discardPriorSnapshots(events, baselineTime);
|
|
14692
16166
|
let lastPlayedTimestamp = lastPlayedEvent == null ? void 0 : lastPlayedEvent.timestamp;
|
|
14693
16167
|
if ((lastPlayedEvent == null ? void 0 : lastPlayedEvent.type) === EventType$1.IncrementalSnapshot && lastPlayedEvent.data.source === IncrementalSource.MouseMove) {
|
|
@@ -14696,22 +16170,45 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
|
|
|
14696
16170
|
if (baselineTime < (lastPlayedTimestamp || 0)) {
|
|
14697
16171
|
emitter.emit(ReplayerEvents.PlayBack);
|
|
14698
16172
|
}
|
|
14699
|
-
|
|
14700
|
-
|
|
14701
|
-
|
|
14702
|
-
|
|
16173
|
+
let syncEnd = neededEvents.length;
|
|
16174
|
+
{
|
|
16175
|
+
let lo = 0;
|
|
16176
|
+
let hi = neededEvents.length;
|
|
16177
|
+
while (lo < hi) {
|
|
16178
|
+
const mid = lo + hi >>> 1;
|
|
16179
|
+
if (neededEvents[mid].timestamp < baselineTime) lo = mid + 1;
|
|
16180
|
+
else hi = mid;
|
|
14703
16181
|
}
|
|
14704
|
-
|
|
14705
|
-
|
|
14706
|
-
|
|
14707
|
-
|
|
14708
|
-
|
|
14709
|
-
|
|
14710
|
-
|
|
14711
|
-
|
|
14712
|
-
|
|
14713
|
-
|
|
16182
|
+
syncEnd = lo;
|
|
16183
|
+
}
|
|
16184
|
+
let syncStart = 0;
|
|
16185
|
+
if (lastPlayedTimestamp && lastPlayedTimestamp < baselineTime) {
|
|
16186
|
+
let lo = 0;
|
|
16187
|
+
let hi = syncEnd;
|
|
16188
|
+
while (lo < hi) {
|
|
16189
|
+
const mid = lo + hi >>> 1;
|
|
16190
|
+
if (neededEvents[mid].timestamp <= lastPlayedTimestamp)
|
|
16191
|
+
lo = mid + 1;
|
|
16192
|
+
else hi = mid;
|
|
14714
16193
|
}
|
|
16194
|
+
syncStart = lo;
|
|
16195
|
+
if (syncStart < syncEnd && neededEvents[syncStart] === lastPlayedEvent) {
|
|
16196
|
+
syncStart++;
|
|
16197
|
+
}
|
|
16198
|
+
}
|
|
16199
|
+
for (let i2 = syncEnd; i2 < neededEvents.length; i2++) {
|
|
16200
|
+
addDelay(neededEvents[i2], baselineTime);
|
|
16201
|
+
}
|
|
16202
|
+
const syncEvents = neededEvents.slice(syncStart, syncEnd);
|
|
16203
|
+
for (let i2 = syncEnd; i2 < neededEvents.length; i2++) {
|
|
16204
|
+
const event2 = neededEvents[i2];
|
|
16205
|
+
const castFn = getCastFn(event2, false);
|
|
16206
|
+
timer.addAction({
|
|
16207
|
+
doAction: () => {
|
|
16208
|
+
castFn();
|
|
16209
|
+
},
|
|
16210
|
+
delay: (_a4 = event2.delay) != null ? _a4 : 0
|
|
16211
|
+
});
|
|
14715
16212
|
}
|
|
14716
16213
|
applyEventsSynchronously(syncEvents);
|
|
14717
16214
|
emitter.emit(ReplayerEvents.Flush);
|
|
@@ -14735,12 +16232,16 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
|
|
|
14735
16232
|
}
|
|
14736
16233
|
}),
|
|
14737
16234
|
addEvent: o((ctx, machineEvent) => {
|
|
16235
|
+
var _a4;
|
|
14738
16236
|
const { baselineTime, timer, events } = ctx;
|
|
14739
16237
|
if (machineEvent.type === "ADD_EVENT") {
|
|
14740
16238
|
const { event: event2 } = machineEvent.payload;
|
|
14741
16239
|
addDelay(event2, baselineTime);
|
|
14742
16240
|
let end = events.length - 1;
|
|
14743
16241
|
if (!events[end] || events[end].timestamp <= event2.timestamp) {
|
|
16242
|
+
if (events[end] && isDuplicateEvent(events[end], event2)) {
|
|
16243
|
+
return __spreadProps(__spreadValues({}, ctx), { events });
|
|
16244
|
+
}
|
|
14744
16245
|
events.push(event2);
|
|
14745
16246
|
} else {
|
|
14746
16247
|
let insertionIndex = -1;
|
|
@@ -14756,6 +16257,16 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
|
|
|
14756
16257
|
if (insertionIndex === -1) {
|
|
14757
16258
|
insertionIndex = start;
|
|
14758
16259
|
}
|
|
16260
|
+
for (let i2 = insertionIndex - 1; i2 >= 0 && events[i2].timestamp === event2.timestamp; i2--) {
|
|
16261
|
+
if (isDuplicateEvent(events[i2], event2)) {
|
|
16262
|
+
return __spreadProps(__spreadValues({}, ctx), { events });
|
|
16263
|
+
}
|
|
16264
|
+
}
|
|
16265
|
+
for (let i2 = insertionIndex; i2 < events.length && events[i2].timestamp === event2.timestamp; i2++) {
|
|
16266
|
+
if (isDuplicateEvent(events[i2], event2)) {
|
|
16267
|
+
return __spreadProps(__spreadValues({}, ctx), { events });
|
|
16268
|
+
}
|
|
16269
|
+
}
|
|
14759
16270
|
events.splice(insertionIndex, 0, event2);
|
|
14760
16271
|
}
|
|
14761
16272
|
const isSync = event2.timestamp < baselineTime;
|
|
@@ -14767,7 +16278,7 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
|
|
|
14767
16278
|
doAction: () => {
|
|
14768
16279
|
castFn();
|
|
14769
16280
|
},
|
|
14770
|
-
delay: event2.delay
|
|
16281
|
+
delay: (_a4 = event2.delay) != null ? _a4 : 0
|
|
14771
16282
|
});
|
|
14772
16283
|
}
|
|
14773
16284
|
}
|
|
@@ -15289,9 +16800,12 @@ class Replayer {
|
|
|
15289
16800
|
__publicField2(this, "styleMirror", new StyleSheetMirror());
|
|
15290
16801
|
__publicField2(this, "mediaManager");
|
|
15291
16802
|
__publicField2(this, "firstFullSnapshot", null);
|
|
16803
|
+
__publicField2(this, "seekCache");
|
|
15292
16804
|
__publicField2(this, "newDocumentQueue", []);
|
|
15293
16805
|
__publicField2(this, "mousePos", null);
|
|
15294
16806
|
__publicField2(this, "touchActive", null);
|
|
16807
|
+
__publicField2(this, "seekInProgress", false);
|
|
16808
|
+
__publicField2(this, "pendingCaptureTimer", null);
|
|
15295
16809
|
__publicField2(this, "lastMouseDownEvent", null);
|
|
15296
16810
|
__publicField2(this, "lastHoveredRootNode");
|
|
15297
16811
|
__publicField2(this, "lastSelectionData", null);
|
|
@@ -15308,7 +16822,47 @@ class Replayer {
|
|
|
15308
16822
|
}
|
|
15309
16823
|
});
|
|
15310
16824
|
__publicField2(this, "applyEventsSynchronously", (events2) => {
|
|
15311
|
-
|
|
16825
|
+
var _a22;
|
|
16826
|
+
let startIdx = 0;
|
|
16827
|
+
if (this.config.useSeekCache && events2.length > 0) {
|
|
16828
|
+
const fullSnapshotEvt = events2.find(
|
|
16829
|
+
(e2) => e2.type === EventType$1.FullSnapshot
|
|
16830
|
+
);
|
|
16831
|
+
if (fullSnapshotEvt) {
|
|
16832
|
+
const targetTime = events2[events2.length - 1].timestamp;
|
|
16833
|
+
const checkpoint = this.seekCache.findBestFor(
|
|
16834
|
+
targetTime,
|
|
16835
|
+
fullSnapshotEvt.timestamp
|
|
16836
|
+
);
|
|
16837
|
+
if (checkpoint) {
|
|
16838
|
+
const metaEvt = events2.find((e2) => e2.type === EventType$1.Meta);
|
|
16839
|
+
if (metaEvt) {
|
|
16840
|
+
this.getCastFn(metaEvt, true)();
|
|
16841
|
+
}
|
|
16842
|
+
this.mediaManager.reset();
|
|
16843
|
+
this.styleMirror.reset();
|
|
16844
|
+
this.rebuildFullSnapshot(
|
|
16845
|
+
checkpoint.event,
|
|
16846
|
+
/* isSync */
|
|
16847
|
+
true
|
|
16848
|
+
);
|
|
16849
|
+
this.firstFullSnapshot = true;
|
|
16850
|
+
(_a22 = this.iframe.contentWindow) == null ? void 0 : _a22.scrollTo(
|
|
16851
|
+
checkpoint.event.data.initialOffset
|
|
16852
|
+
);
|
|
16853
|
+
let lo = 0;
|
|
16854
|
+
let hi = events2.length;
|
|
16855
|
+
while (lo < hi) {
|
|
16856
|
+
const mid = lo + hi >>> 1;
|
|
16857
|
+
if (events2[mid].timestamp <= checkpoint.timestamp) lo = mid + 1;
|
|
16858
|
+
else hi = mid;
|
|
16859
|
+
}
|
|
16860
|
+
startIdx = lo;
|
|
16861
|
+
}
|
|
16862
|
+
}
|
|
16863
|
+
}
|
|
16864
|
+
for (let i2 = startIdx; i2 < events2.length; i2++) {
|
|
16865
|
+
const event2 = events2[i2];
|
|
15312
16866
|
switch (event2.type) {
|
|
15313
16867
|
case EventType$1.DomContentLoaded:
|
|
15314
16868
|
case EventType$1.Load:
|
|
@@ -15384,7 +16938,7 @@ class Replayer {
|
|
|
15384
16938
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
15385
16939
|
this.nextUserInteractionEvent.delay - event2.delay
|
|
15386
16940
|
);
|
|
15387
|
-
this.
|
|
16941
|
+
this.playInternal(this.getCurrentTime() + skipTime);
|
|
15388
16942
|
this.nextUserInteractionEvent = null;
|
|
15389
16943
|
}
|
|
15390
16944
|
}
|
|
@@ -15440,9 +16994,13 @@ class Replayer {
|
|
|
15440
16994
|
mouseTail: defaultMouseTailConfig,
|
|
15441
16995
|
useVirtualDom: true,
|
|
15442
16996
|
// Virtual-dom optimization is enabled by default.
|
|
16997
|
+
useSeekCache: false,
|
|
16998
|
+
// Opt-in until production-validated; flip to true once confidence is high.
|
|
16999
|
+
seekCacheMaxEntries: 10,
|
|
15443
17000
|
logger: console
|
|
15444
17001
|
};
|
|
15445
17002
|
this.config = Object.assign({}, defaultConfig, config);
|
|
17003
|
+
this.seekCache = new SeekCache(this.config.seekCacheMaxEntries);
|
|
15446
17004
|
this.handleResize = this.handleResize.bind(this);
|
|
15447
17005
|
this.getCastFn = this.getCastFn.bind(this);
|
|
15448
17006
|
this.applyEventsSynchronously = this.applyEventsSynchronously.bind(this);
|
|
@@ -15554,6 +17112,25 @@ class Replayer {
|
|
|
15554
17112
|
this.styleMirror.reset();
|
|
15555
17113
|
this.mediaManager.reset();
|
|
15556
17114
|
});
|
|
17115
|
+
this.emitter.on(ReplayerEvents.Flush, () => {
|
|
17116
|
+
if (this.seekInProgress) {
|
|
17117
|
+
this.seekInProgress = false;
|
|
17118
|
+
const seekEndTimeOffset = this.getTimeOffset();
|
|
17119
|
+
this.emitter.emit(ReplayerEvents.SeekEnd, {
|
|
17120
|
+
timeOffset: seekEndTimeOffset
|
|
17121
|
+
});
|
|
17122
|
+
}
|
|
17123
|
+
if (this.config.useSeekCache) {
|
|
17124
|
+
const captureTimestamp = this.service.state.context.baselineTime;
|
|
17125
|
+
if (this.pendingCaptureTimer !== null) {
|
|
17126
|
+
clearTimeout(this.pendingCaptureTimer);
|
|
17127
|
+
}
|
|
17128
|
+
this.pendingCaptureTimer = setTimeout(() => {
|
|
17129
|
+
this.pendingCaptureTimer = null;
|
|
17130
|
+
this.captureSeekCacheEntry(captureTimestamp);
|
|
17131
|
+
}, 0);
|
|
17132
|
+
}
|
|
17133
|
+
});
|
|
15557
17134
|
const timer = new Timer([], {
|
|
15558
17135
|
speed: this.config.speed
|
|
15559
17136
|
});
|
|
@@ -15712,6 +17289,16 @@ class Replayer {
|
|
|
15712
17289
|
* @param timeOffset - number
|
|
15713
17290
|
*/
|
|
15714
17291
|
play(timeOffset = 0) {
|
|
17292
|
+
this.seekInProgress = true;
|
|
17293
|
+
this.emitter.emit(ReplayerEvents.SeekStart, { timeOffset });
|
|
17294
|
+
this.playInternal(timeOffset);
|
|
17295
|
+
}
|
|
17296
|
+
/**
|
|
17297
|
+
* Internal seek/resume that does NOT emit SeekStart/SeekEnd. Use this for
|
|
17298
|
+
* programmatic jumps that are not initiated by the user (e.g. skipInactive,
|
|
17299
|
+
* stylesheet-load resume) to avoid spurious loading-indicator flicker.
|
|
17300
|
+
*/
|
|
17301
|
+
playInternal(timeOffset = 0) {
|
|
15715
17302
|
var _a22, _b22;
|
|
15716
17303
|
if (this.service.state.matches("paused")) {
|
|
15717
17304
|
this.service.send({ type: "PLAY", payload: { timeOffset } });
|
|
@@ -15780,6 +17367,13 @@ class Replayer {
|
|
|
15780
17367
|
resetCache() {
|
|
15781
17368
|
this.cache = createCache();
|
|
15782
17369
|
}
|
|
17370
|
+
/**
|
|
17371
|
+
* Empties the seek-checkpoint cache. Call this if you load a new set of
|
|
17372
|
+
* events into an existing Replayer instance to avoid stale snapshots.
|
|
17373
|
+
*/
|
|
17374
|
+
resetSeekCache() {
|
|
17375
|
+
this.seekCache.clear();
|
|
17376
|
+
}
|
|
15783
17377
|
setupDom() {
|
|
15784
17378
|
this.wrapper = document.createElement("div");
|
|
15785
17379
|
this.wrapper.classList.add("replayer-wrapper");
|
|
@@ -15810,6 +17404,38 @@ class Replayer {
|
|
|
15810
17404
|
polyfill$1(this.iframe.contentWindow);
|
|
15811
17405
|
}
|
|
15812
17406
|
}
|
|
17407
|
+
/**
|
|
17408
|
+
* Serialize the current iframe DOM into the seek-checkpoint cache so that
|
|
17409
|
+
* future seeks near this timestamp can restore from the cache instead of
|
|
17410
|
+
* replaying all incremental events from the original FullSnapshot.
|
|
17411
|
+
*
|
|
17412
|
+
* This is called asynchronously (via requestIdleCallback / setTimeout) after
|
|
17413
|
+
* each Flush so it does not block the seek operation itself.
|
|
17414
|
+
*/
|
|
17415
|
+
captureSeekCacheEntry(timestamp) {
|
|
17416
|
+
var _a4, _b3;
|
|
17417
|
+
if (!this.iframe.contentDocument) return;
|
|
17418
|
+
if (timestamp <= 0) return;
|
|
17419
|
+
const scratchMirror = createMirror$2();
|
|
17420
|
+
this.mirror.getIds().forEach((id) => {
|
|
17421
|
+
const node2 = this.mirror.getNode(id);
|
|
17422
|
+
if (!node2) return;
|
|
17423
|
+
const meta = this.mirror.getMeta(node2);
|
|
17424
|
+
if (meta) scratchMirror.add(node2, meta);
|
|
17425
|
+
});
|
|
17426
|
+
const snapshotNode = snapshot(this.iframe.contentDocument, {
|
|
17427
|
+
mirror: scratchMirror,
|
|
17428
|
+
blockClass: this.config.blockClass,
|
|
17429
|
+
inlineStylesheet: true
|
|
17430
|
+
});
|
|
17431
|
+
if (!snapshotNode) return;
|
|
17432
|
+
const scrollEl = this.iframe.contentDocument.scrollingElement || this.iframe.contentDocument.documentElement;
|
|
17433
|
+
const initialOffset = {
|
|
17434
|
+
top: (_a4 = scrollEl == null ? void 0 : scrollEl.scrollTop) != null ? _a4 : 0,
|
|
17435
|
+
left: (_b3 = scrollEl == null ? void 0 : scrollEl.scrollLeft) != null ? _b3 : 0
|
|
17436
|
+
};
|
|
17437
|
+
this.seekCache.add(timestamp, snapshotNode, initialOffset);
|
|
17438
|
+
}
|
|
15813
17439
|
rebuildFullSnapshot(event2, isSync = false) {
|
|
15814
17440
|
if (!this.iframe.contentDocument) {
|
|
15815
17441
|
return this.warn("Looks like your replayer has been destroyed.");
|
|
@@ -15957,6 +17583,7 @@ class Replayer {
|
|
|
15957
17583
|
this.collectIframeAndAttachDocument(collectedIframes, builtNode);
|
|
15958
17584
|
const sn = mirror2.getMeta(builtNode);
|
|
15959
17585
|
if ((sn == null ? void 0 : sn.type) === NodeType.Element && (sn == null ? void 0 : sn.tagName.toUpperCase()) === "HTML") {
|
|
17586
|
+
if (!iframeEl.contentDocument) return;
|
|
15960
17587
|
const { documentElement, head } = iframeEl.contentDocument;
|
|
15961
17588
|
this.insertStyleRules(
|
|
15962
17589
|
documentElement,
|
|
@@ -15972,15 +17599,17 @@ class Replayer {
|
|
|
15972
17599
|
});
|
|
15973
17600
|
}
|
|
15974
17601
|
};
|
|
17602
|
+
const iframeDoc = iframeEl.contentDocument;
|
|
17603
|
+
if (!iframeDoc) return;
|
|
15975
17604
|
buildNodeWithSN(mutation.node, {
|
|
15976
|
-
doc:
|
|
17605
|
+
doc: iframeDoc,
|
|
15977
17606
|
mirror: mirror2,
|
|
15978
17607
|
hackCss: true,
|
|
15979
17608
|
skipChild: false,
|
|
15980
17609
|
afterAppend,
|
|
15981
17610
|
cache: this.cache
|
|
15982
17611
|
});
|
|
15983
|
-
afterAppend(
|
|
17612
|
+
afterAppend(iframeDoc, mutation.node.id);
|
|
15984
17613
|
for (const { mutationInQueue, builtNode } of collectedIframes) {
|
|
15985
17614
|
this.attachDocumentToIframe(mutationInQueue, builtNode);
|
|
15986
17615
|
this.newDocumentQueue = this.newDocumentQueue.filter(
|
|
@@ -16028,7 +17657,7 @@ class Replayer {
|
|
|
16028
17657
|
unloadSheets.delete(css);
|
|
16029
17658
|
if (unloadSheets.size === 0 && timer !== -1) {
|
|
16030
17659
|
if (beforeLoadState.matches("playing")) {
|
|
16031
|
-
this.
|
|
17660
|
+
this.playInternal(this.getCurrentTime());
|
|
16032
17661
|
}
|
|
16033
17662
|
this.emitter.emit(ReplayerEvents.LoadStylesheetEnd);
|
|
16034
17663
|
if (timer) {
|
|
@@ -16044,7 +17673,7 @@ class Replayer {
|
|
|
16044
17673
|
this.emitter.emit(ReplayerEvents.LoadStylesheetStart);
|
|
16045
17674
|
timer = setTimeout(() => {
|
|
16046
17675
|
if (beforeLoadState.matches("playing")) {
|
|
16047
|
-
this.
|
|
17676
|
+
this.playInternal(this.getCurrentTime());
|
|
16048
17677
|
}
|
|
16049
17678
|
timer = -1;
|
|
16050
17679
|
unsubscribe();
|
|
@@ -16075,7 +17704,7 @@ class Replayer {
|
|
|
16075
17704
|
const canvas = document.createElement("canvas");
|
|
16076
17705
|
const ctx = canvas.getContext("2d");
|
|
16077
17706
|
const imgd = ctx == null ? void 0 : ctx.createImageData(canvas.width, canvas.height);
|
|
16078
|
-
ctx == null ? void 0 : ctx.putImageData(imgd, 0, 0);
|
|
17707
|
+
if (imgd) ctx == null ? void 0 : ctx.putImageData(imgd, 0, 0);
|
|
16079
17708
|
}
|
|
16080
17709
|
}
|
|
16081
17710
|
async deserializeAndPreloadCanvasEvents(data, event2) {
|
|
@@ -16350,6 +17979,7 @@ class Replayer {
|
|
|
16350
17979
|
applyMutation(d, isSync) {
|
|
16351
17980
|
if (this.config.useVirtualDom && !this.usingVirtualDom && isSync) {
|
|
16352
17981
|
this.usingVirtualDom = true;
|
|
17982
|
+
if (!this.iframe.contentDocument) return;
|
|
16353
17983
|
buildFromDom(this.iframe.contentDocument, this.mirror, this.virtualDom);
|
|
16354
17984
|
if (Object.keys(this.legacy_missingNodeRetryMap).length) {
|
|
16355
17985
|
for (const key in this.legacy_missingNodeRetryMap) {
|
|
@@ -17843,7 +19473,7 @@ function Controller($$anchor, $$props) {
|
|
|
17843
19473
|
let classes;
|
|
17844
19474
|
var div_3 = child(div_2);
|
|
17845
19475
|
var node_1 = sibling(div_3, 2);
|
|
17846
|
-
each(node_1, 1, () => get(inactivePeriods), index$
|
|
19476
|
+
each(node_1, 1, () => get(inactivePeriods), index$2, ($$anchor3, period) => {
|
|
17847
19477
|
var div_4 = root_2();
|
|
17848
19478
|
template_effect(() => {
|
|
17849
19479
|
var _a4, _b3, _c;
|
|
@@ -17854,7 +19484,7 @@ function Controller($$anchor, $$props) {
|
|
|
17854
19484
|
append($$anchor3, div_4);
|
|
17855
19485
|
});
|
|
17856
19486
|
var node_2 = sibling(node_1, 2);
|
|
17857
|
-
each(node_2, 1, () => get(customEvents), index$
|
|
19487
|
+
each(node_2, 1, () => get(customEvents), index$2, ($$anchor3, event2) => {
|
|
17858
19488
|
var div_5 = root_3();
|
|
17859
19489
|
template_effect(() => {
|
|
17860
19490
|
var _a4, _b3;
|
|
@@ -17891,7 +19521,7 @@ function Controller($$anchor, $$props) {
|
|
|
17891
19521
|
}
|
|
17892
19522
|
reset(button);
|
|
17893
19523
|
var node_4 = sibling(button, 2);
|
|
17894
|
-
each(node_4, 1, speedOption, index$
|
|
19524
|
+
each(node_4, 1, speedOption, index$2, ($$anchor3, s2) => {
|
|
17895
19525
|
var button_1 = root_6();
|
|
17896
19526
|
let classes_1;
|
|
17897
19527
|
var text_2 = child(button_1);
|