@posthog/rrweb-snapshot 0.0.55 → 0.0.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1593 +0,0 @@
1
- (function (g, f) {if ("object" == typeof exports && "object" == typeof module) {module.exports = f();} else if ("function" == typeof define && define.amd) {define("rrwebSnapshotRecord", [], f);} else if ("object" == typeof exports) {exports["rrwebSnapshotRecord"] = f();} else {g["rrwebSnapshotRecord"] = f();}}(typeof self !== 'undefined' ? self : typeof globalThis !== 'undefined' ? globalThis : this, () => {var exports = {};var module = { exports };
2
- "use strict";
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __commonJS = (cb, mod) => function __require() {
5
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
6
- };
7
-
8
- // dist/types-BjupQhwp.cjs
9
- var require_types_BjupQhwp = __commonJS({
10
- "dist/types-BjupQhwp.cjs"(exports2) {
11
- "use strict";
12
- var __defProp = Object.defineProperty;
13
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
15
- var NodeType$1 = /* @__PURE__ */ ((NodeType2) => {
16
- NodeType2[NodeType2["Document"] = 0] = "Document";
17
- NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
18
- NodeType2[NodeType2["Element"] = 2] = "Element";
19
- NodeType2[NodeType2["Text"] = 3] = "Text";
20
- NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
21
- NodeType2[NodeType2["Comment"] = 5] = "Comment";
22
- return NodeType2;
23
- })(NodeType$1 || {});
24
- var testableAccessors = {
25
- Node: ["childNodes", "parentNode", "parentElement", "textContent"],
26
- ShadowRoot: ["host", "styleSheets"],
27
- Element: ["shadowRoot"],
28
- MutationObserver: []
29
- };
30
- var testableMethods = {
31
- Node: ["contains", "getRootNode"],
32
- ShadowRoot: ["getSelection"],
33
- Element: ["querySelector", "querySelectorAll"],
34
- MutationObserver: ["constructor"]
35
- };
36
- var untaintedBasePrototype = {};
37
- function angularZoneUnpatchedAlternative(key) {
38
- var _a, _b;
39
- const angularUnpatchedVersionSymbol = (_b = (_a = globalThis == null ? void 0 : globalThis.Zone) == null ? void 0 : _a.__symbol__) == null ? void 0 : _b.call(_a, key);
40
- if (angularUnpatchedVersionSymbol && globalThis[angularUnpatchedVersionSymbol]) {
41
- return globalThis[angularUnpatchedVersionSymbol];
42
- } else {
43
- return void 0;
44
- }
45
- }
46
- function getUntaintedPrototype(key) {
47
- if (untaintedBasePrototype[key])
48
- return untaintedBasePrototype[key];
49
- const candidate = angularZoneUnpatchedAlternative(key) || globalThis[key];
50
- const defaultPrototype = candidate.prototype;
51
- const accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
52
- const isUntaintedAccessors = Boolean(
53
- accessorNames && // @ts-expect-error 2345
54
- accessorNames.every(
55
- (accessor) => {
56
- var _a, _b;
57
- return Boolean(
58
- (_b = (_a = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a.get) == null ? void 0 : _b.toString().includes("[native code]")
59
- );
60
- }
61
- )
62
- );
63
- const methodNames = key in testableMethods ? testableMethods[key] : void 0;
64
- const isUntaintedMethods = Boolean(
65
- methodNames && methodNames.every(
66
- // @ts-expect-error 2345
67
- (method) => {
68
- var _a;
69
- return typeof defaultPrototype[method] === "function" && ((_a = defaultPrototype[method]) == null ? void 0 : _a.toString().includes("[native code]"));
70
- }
71
- )
72
- );
73
- if (isUntaintedAccessors && isUntaintedMethods) {
74
- untaintedBasePrototype[key] = candidate.prototype;
75
- return candidate.prototype;
76
- }
77
- const iframeEl = document.createElement("iframe");
78
- try {
79
- document.body.appendChild(iframeEl);
80
- const win = iframeEl.contentWindow;
81
- if (!win) return candidate.prototype;
82
- const untaintedObject = win[key].prototype;
83
- if (!untaintedObject) return defaultPrototype;
84
- return untaintedBasePrototype[key] = untaintedObject;
85
- } catch (e) {
86
- return defaultPrototype;
87
- } finally {
88
- if (iframeEl.parentNode) {
89
- document.body.removeChild(iframeEl);
90
- }
91
- }
92
- }
93
- var untaintedAccessorCache = {};
94
- function getUntaintedAccessor(key, instance, accessor) {
95
- var _a;
96
- const cacheKey = `${key}.${String(accessor)}`;
97
- if (untaintedAccessorCache[cacheKey])
98
- return untaintedAccessorCache[cacheKey].call(
99
- instance
100
- );
101
- const untaintedPrototype = getUntaintedPrototype(key);
102
- const untaintedAccessor = (_a = Object.getOwnPropertyDescriptor(
103
- untaintedPrototype,
104
- accessor
105
- )) == null ? void 0 : _a.get;
106
- if (!untaintedAccessor) return instance[accessor];
107
- untaintedAccessorCache[cacheKey] = untaintedAccessor;
108
- return untaintedAccessor.call(instance);
109
- }
110
- var untaintedMethodCache = {};
111
- function getUntaintedMethod(key, instance, method) {
112
- const cacheKey = `${key}.${String(method)}`;
113
- if (untaintedMethodCache[cacheKey])
114
- return untaintedMethodCache[cacheKey].bind(
115
- instance
116
- );
117
- const untaintedPrototype = getUntaintedPrototype(key);
118
- const untaintedMethod = untaintedPrototype[method];
119
- if (typeof untaintedMethod !== "function") return instance[method];
120
- untaintedMethodCache[cacheKey] = untaintedMethod;
121
- return untaintedMethod.bind(instance);
122
- }
123
- function childNodes(n) {
124
- return getUntaintedAccessor("Node", n, "childNodes");
125
- }
126
- function parentNode(n) {
127
- return getUntaintedAccessor("Node", n, "parentNode");
128
- }
129
- function parentElement(n) {
130
- return getUntaintedAccessor("Node", n, "parentElement");
131
- }
132
- function textContent(n) {
133
- return getUntaintedAccessor("Node", n, "textContent");
134
- }
135
- function contains(n, other) {
136
- return getUntaintedMethod("Node", n, "contains")(other);
137
- }
138
- function getRootNode(n) {
139
- return getUntaintedMethod("Node", n, "getRootNode")();
140
- }
141
- function host(n) {
142
- if (!n || !("host" in n)) return null;
143
- return getUntaintedAccessor("ShadowRoot", n, "host");
144
- }
145
- function styleSheets(n) {
146
- return n.styleSheets;
147
- }
148
- function shadowRoot(n) {
149
- if (!n || !("shadowRoot" in n)) return null;
150
- return getUntaintedAccessor("Element", n, "shadowRoot");
151
- }
152
- function querySelector(n, selectors) {
153
- return getUntaintedMethod("Element", n, "querySelector")(selectors);
154
- }
155
- function querySelectorAll(n, selectors) {
156
- return getUntaintedMethod("Element", n, "querySelectorAll")(selectors);
157
- }
158
- function mutationObserverCtor() {
159
- return getUntaintedPrototype("MutationObserver").constructor;
160
- }
161
- function patch(source, name, replacement) {
162
- try {
163
- if (!(name in source)) {
164
- return () => {
165
- };
166
- }
167
- const original = source[name];
168
- const wrapped = replacement(original);
169
- if (typeof wrapped === "function") {
170
- wrapped.prototype = wrapped.prototype || {};
171
- Object.defineProperties(wrapped, {
172
- __rrweb_original__: {
173
- enumerable: false,
174
- value: original
175
- }
176
- });
177
- }
178
- source[name] = wrapped;
179
- return () => {
180
- source[name] = original;
181
- };
182
- } catch (e) {
183
- return () => {
184
- };
185
- }
186
- }
187
- var index = {
188
- childNodes,
189
- parentNode,
190
- parentElement,
191
- textContent,
192
- contains,
193
- getRootNode,
194
- host,
195
- styleSheets,
196
- shadowRoot,
197
- querySelector,
198
- querySelectorAll,
199
- mutationObserver: mutationObserverCtor,
200
- patch
201
- };
202
- function isElement(n) {
203
- return n.nodeType === n.ELEMENT_NODE;
204
- }
205
- function isShadowRoot(n) {
206
- const hostEl = (
207
- // anchor and textarea elements also have a `host` property
208
- // but only shadow roots have a `mode` property
209
- n && "host" in n && "mode" in n && index.host(n) || null
210
- );
211
- return Boolean(
212
- hostEl && "shadowRoot" in hostEl && index.shadowRoot(hostEl) === n
213
- );
214
- }
215
- function isNativeShadowDom(shadowRoot2) {
216
- return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
217
- }
218
- function fixBrowserCompatibilityIssuesInCSS(cssText) {
219
- if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
220
- cssText = cssText.replace(
221
- /\sbackground-clip:\s*text;/g,
222
- " -webkit-background-clip: text; background-clip: text;"
223
- );
224
- }
225
- return cssText;
226
- }
227
- function escapeImportStatement(rule) {
228
- const { cssText } = rule;
229
- if (cssText.split('"').length < 3) return cssText;
230
- const statement = ["@import", `url(${JSON.stringify(rule.href)})`];
231
- if (rule.layerName === "") {
232
- statement.push(`layer`);
233
- } else if (rule.layerName) {
234
- statement.push(`layer(${rule.layerName})`);
235
- }
236
- if (rule.supportsText) {
237
- statement.push(`supports(${rule.supportsText})`);
238
- }
239
- if (rule.media.length) {
240
- statement.push(rule.media.mediaText);
241
- }
242
- return statement.join(" ") + ";";
243
- }
244
- function stringifyStylesheet(s) {
245
- try {
246
- const rules = s.rules || s.cssRules;
247
- if (!rules) {
248
- return null;
249
- }
250
- let sheetHref = s.href;
251
- if (!sheetHref && s.ownerNode) {
252
- sheetHref = s.ownerNode.baseURI;
253
- }
254
- const stringifiedRules = Array.from(
255
- rules,
256
- (rule) => stringifyRule(rule, sheetHref)
257
- ).join("");
258
- return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
259
- } catch (error) {
260
- return null;
261
- }
262
- }
263
- function stringifyRule(rule, sheetHref) {
264
- var _a;
265
- if (isCSSImportRule(rule)) {
266
- let importStringified;
267
- try {
268
- importStringified = // for same-origin stylesheets,
269
- // we can access the imported stylesheet rules directly
270
- stringifyStylesheet(rule.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
271
- escapeImportStatement(rule);
272
- } catch (error) {
273
- importStringified = rule.cssText;
274
- }
275
- try {
276
- if (importStringified && ((_a = rule.styleSheet) == null ? void 0 : _a.href)) {
277
- return absolutifyURLs(importStringified, rule.styleSheet.href);
278
- }
279
- } catch (e) {
280
- }
281
- return importStringified;
282
- } else {
283
- let ruleStringified = rule.cssText;
284
- if (isCSSStyleRule(rule) && rule.selectorText.includes(":")) {
285
- ruleStringified = fixSafariColons(ruleStringified);
286
- }
287
- if (sheetHref) {
288
- return absolutifyURLs(ruleStringified, sheetHref);
289
- }
290
- return ruleStringified;
291
- }
292
- }
293
- function fixSafariColons(cssStringified) {
294
- const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
295
- return cssStringified.replace(regex, "$1\\$2");
296
- }
297
- function isCSSImportRule(rule) {
298
- return "styleSheet" in rule;
299
- }
300
- function isCSSStyleRule(rule) {
301
- return "selectorText" in rule;
302
- }
303
- var Mirror = class {
304
- constructor() {
305
- __publicField(this, "idNodeMap", /* @__PURE__ */ new Map());
306
- __publicField(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
307
- }
308
- getId(n) {
309
- var _a;
310
- if (!n) return -1;
311
- const id = (_a = this.getMeta(n)) == null ? void 0 : _a.id;
312
- return id != null ? id : -1;
313
- }
314
- getNode(id) {
315
- return this.idNodeMap.get(id) || null;
316
- }
317
- getIds() {
318
- return Array.from(this.idNodeMap.keys());
319
- }
320
- getMeta(n) {
321
- return this.nodeMetaMap.get(n) || null;
322
- }
323
- // removes the node from idNodeMap
324
- // doesn't remove the node from nodeMetaMap
325
- removeNodeFromMap(n) {
326
- const id = this.getId(n);
327
- this.idNodeMap.delete(id);
328
- if (n.childNodes) {
329
- n.childNodes.forEach(
330
- (childNode) => this.removeNodeFromMap(childNode)
331
- );
332
- }
333
- if (isElement(n)) {
334
- const shadowRootEl = index.shadowRoot(n);
335
- if (shadowRootEl) {
336
- this.removeNodeFromMap(shadowRootEl);
337
- }
338
- if (n.nodeName === "IFRAME" && n.contentDocument) {
339
- this.removeNodeFromMap(
340
- n.contentDocument
341
- );
342
- }
343
- }
344
- }
345
- has(id) {
346
- return this.idNodeMap.has(id);
347
- }
348
- hasNode(node) {
349
- return this.nodeMetaMap.has(node);
350
- }
351
- add(n, meta) {
352
- const id = meta.id;
353
- this.idNodeMap.set(id, n);
354
- this.nodeMetaMap.set(n, meta);
355
- }
356
- replace(id, n) {
357
- const oldNode = this.getNode(id);
358
- if (oldNode) {
359
- const meta = this.nodeMetaMap.get(oldNode);
360
- if (meta) this.nodeMetaMap.set(n, meta);
361
- }
362
- this.idNodeMap.set(id, n);
363
- }
364
- reset() {
365
- this.idNodeMap = /* @__PURE__ */ new Map();
366
- this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
367
- }
368
- };
369
- function createMirror() {
370
- return new Mirror();
371
- }
372
- function maskInputValue({
373
- element,
374
- maskInputOptions,
375
- tagName,
376
- type,
377
- value,
378
- maskInputFn
379
- }) {
380
- let text = value || "";
381
- const actualType = type && toLowerCase(type);
382
- if (maskInputOptions[tagName.toLowerCase()] || actualType && maskInputOptions[actualType]) {
383
- if (maskInputFn) {
384
- text = maskInputFn(text, element);
385
- } else {
386
- text = "*".repeat(text.length);
387
- }
388
- }
389
- return text;
390
- }
391
- function toLowerCase(str) {
392
- return str.toLowerCase();
393
- }
394
- var ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
395
- function is2DCanvasBlank(canvas) {
396
- const ctx = canvas.getContext("2d");
397
- if (!ctx) return true;
398
- const chunkSize = 50;
399
- for (let x = 0; x < canvas.width; x += chunkSize) {
400
- for (let y = 0; y < canvas.height; y += chunkSize) {
401
- const getImageData = ctx.getImageData;
402
- const originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
403
- const pixelBuffer = new Uint32Array(
404
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
405
- originalGetImageData.call(
406
- ctx,
407
- x,
408
- y,
409
- Math.min(chunkSize, canvas.width - x),
410
- Math.min(chunkSize, canvas.height - y)
411
- ).data.buffer
412
- );
413
- if (pixelBuffer.some((pixel) => pixel !== 0)) return false;
414
- }
415
- }
416
- return true;
417
- }
418
- function isNodeMetaEqual(a, b) {
419
- if (!a || !b || a.type !== b.type) return false;
420
- if (a.type === NodeType$1.Document)
421
- return a.compatMode === b.compatMode;
422
- else if (a.type === NodeType$1.DocumentType)
423
- return a.name === b.name && a.publicId === b.publicId && a.systemId === b.systemId;
424
- else if (a.type === NodeType$1.Comment || a.type === NodeType$1.Text || a.type === NodeType$1.CDATA)
425
- return a.textContent === b.textContent;
426
- else if (a.type === NodeType$1.Element)
427
- return a.tagName === b.tagName && JSON.stringify(a.attributes) === JSON.stringify(b.attributes) && a.isSVG === b.isSVG && a.needBlock === b.needBlock;
428
- return false;
429
- }
430
- function getInputType(element) {
431
- const type = element.type;
432
- return element.hasAttribute("data-rr-is-password") ? "password" : type ? (
433
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
434
- toLowerCase(type)
435
- ) : null;
436
- }
437
- function extractFileExtension(path, baseURL) {
438
- var _a;
439
- let url;
440
- try {
441
- url = new URL(path, baseURL != null ? baseURL : window.location.href);
442
- } catch (err) {
443
- return null;
444
- }
445
- const regex = /\.([0-9a-z]+)(?:$)/i;
446
- const match = url.pathname.match(regex);
447
- return (_a = match == null ? void 0 : match[1]) != null ? _a : null;
448
- }
449
- function extractOrigin(url) {
450
- let origin = "";
451
- if (url.indexOf("//") > -1) {
452
- origin = url.split("/").slice(0, 3).join("/");
453
- } else {
454
- origin = url.split("/")[0];
455
- }
456
- origin = origin.split("?")[0];
457
- return origin;
458
- }
459
- var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
460
- var URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
461
- var URL_WWW_MATCH = /^www\..*/i;
462
- var DATA_URI = /^(data:)([^,]*),(.*)/i;
463
- function absolutifyURLs(cssText, href) {
464
- return (cssText || "").replace(
465
- URL_IN_CSS_REF,
466
- (origin, quote1, path1, quote2, path2, path3) => {
467
- const filePath = path1 || path2 || path3;
468
- const maybeQuote = quote1 || quote2 || "";
469
- if (!filePath) {
470
- return origin;
471
- }
472
- if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
473
- return `url(${maybeQuote}${filePath}${maybeQuote})`;
474
- }
475
- if (DATA_URI.test(filePath)) {
476
- return `url(${maybeQuote}${filePath}${maybeQuote})`;
477
- }
478
- if (filePath[0] === "/") {
479
- return `url(${maybeQuote}${extractOrigin(href) + filePath}${maybeQuote})`;
480
- }
481
- const stack = href.split("/");
482
- const parts = filePath.split("/");
483
- stack.pop();
484
- for (const part of parts) {
485
- if (part === ".") {
486
- continue;
487
- } else if (part === "..") {
488
- stack.pop();
489
- } else {
490
- stack.push(part);
491
- }
492
- }
493
- return `url(${maybeQuote}${stack.join("/")}${maybeQuote})`;
494
- }
495
- );
496
- }
497
- var STRIPED_PLACEHOLDER_SVG = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogIDxkZWZzPgogICAgPHBhdHRlcm4gaWQ9InN0cmlwZXMiIHBhdHRlcm5Vbml0cz0idXNlclNwYWNlT25Vc2UiIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+CiAgICAgIDxyZWN0IHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iYmxhY2siLz4KICAgICAgPHBhdGggZD0iTTggMEgxNkwwIDE2VjhMOCAwWiIgZmlsbD0iIzJEMkQyRCIvPgogICAgICA8cGF0aCBkPSJNMTYgOFYxNkg4TDE2IDhaIiBmaWxsPSIjMkQyRDJEIi8+CiAgICA8L3BhdHRlcm4+CiAgPC9kZWZzPgogIDxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjc3RyaXBlcykiLz4KPC9zdmc+Cg==";
498
- var MAX_IMAGE_DIMENSION_FOR_RECOMPRESSION = 4096;
499
- function recompressBase64Image(img, dataURL, type, quality) {
500
- if (!img.complete || img.naturalWidth === 0) {
501
- return dataURL;
502
- }
503
- if (img.naturalWidth > MAX_IMAGE_DIMENSION_FOR_RECOMPRESSION || img.naturalHeight > MAX_IMAGE_DIMENSION_FOR_RECOMPRESSION) {
504
- return dataURL;
505
- }
506
- try {
507
- const canvas = document.createElement("canvas");
508
- canvas.width = img.naturalWidth;
509
- canvas.height = img.naturalHeight;
510
- const ctx = canvas.getContext("2d");
511
- if (!ctx) {
512
- return dataURL;
513
- }
514
- ctx.drawImage(img, 0, 0);
515
- const recompressed = canvas.toDataURL(type || "image/webp", quality != null ? quality : 0.4);
516
- return recompressed;
517
- } catch (err) {
518
- return dataURL;
519
- }
520
- }
521
- function checkDataURLSize(dataURL, maxLength) {
522
- if (!maxLength || dataURL.length <= maxLength) {
523
- return dataURL;
524
- }
525
- return STRIPED_PLACEHOLDER_SVG;
526
- }
527
- var NodeType = /* @__PURE__ */ ((NodeType2) => {
528
- NodeType2[NodeType2["Document"] = 0] = "Document";
529
- NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
530
- NodeType2[NodeType2["Element"] = 2] = "Element";
531
- NodeType2[NodeType2["Text"] = 3] = "Text";
532
- NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
533
- NodeType2[NodeType2["Comment"] = 5] = "Comment";
534
- return NodeType2;
535
- })(NodeType || {});
536
- exports2.Mirror = Mirror;
537
- exports2.NodeType = NodeType;
538
- exports2.NodeType$1 = NodeType$1;
539
- exports2.absolutifyURLs = absolutifyURLs;
540
- exports2.checkDataURLSize = checkDataURLSize;
541
- exports2.createMirror = createMirror;
542
- exports2.escapeImportStatement = escapeImportStatement;
543
- exports2.extractFileExtension = extractFileExtension;
544
- exports2.fixSafariColons = fixSafariColons;
545
- exports2.getInputType = getInputType;
546
- exports2.index = index;
547
- exports2.is2DCanvasBlank = is2DCanvasBlank;
548
- exports2.isCSSImportRule = isCSSImportRule;
549
- exports2.isCSSStyleRule = isCSSStyleRule;
550
- exports2.isElement = isElement;
551
- exports2.isNativeShadowDom = isNativeShadowDom;
552
- exports2.isNodeMetaEqual = isNodeMetaEqual;
553
- exports2.isShadowRoot = isShadowRoot;
554
- exports2.maskInputValue = maskInputValue;
555
- exports2.recompressBase64Image = recompressBase64Image;
556
- exports2.stringifyRule = stringifyRule;
557
- exports2.stringifyStylesheet = stringifyStylesheet;
558
- exports2.toLowerCase = toLowerCase;
559
- }
560
- });
561
-
562
- // dist/record-Rc5ocxPN.cjs
563
- var types = require_types_BjupQhwp();
564
- var _id = 1;
565
- var tagNameRegex = new RegExp("[^a-z0-9-_:]");
566
- var IGNORED_NODE = -2;
567
- function genId() {
568
- return _id++;
569
- }
570
- function getValidTagName(element) {
571
- if (element instanceof HTMLFormElement) {
572
- return "form";
573
- }
574
- const processedTagName = types.toLowerCase(element.tagName);
575
- if (tagNameRegex.test(processedTagName)) {
576
- return "div";
577
- }
578
- return processedTagName;
579
- }
580
- var canvasService;
581
- var canvasCtx;
582
- var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
583
- var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
584
- function getAbsoluteSrcsetString(doc, attributeValue) {
585
- if (attributeValue.trim() === "") {
586
- return attributeValue;
587
- }
588
- let pos = 0;
589
- function collectCharacters(regEx) {
590
- let chars;
591
- const match = regEx.exec(attributeValue.substring(pos));
592
- if (match) {
593
- chars = match[0];
594
- pos += chars.length;
595
- return chars;
596
- }
597
- return "";
598
- }
599
- const output = [];
600
- while (true) {
601
- collectCharacters(SRCSET_COMMAS_OR_SPACES);
602
- if (pos >= attributeValue.length) {
603
- break;
604
- }
605
- let url = collectCharacters(SRCSET_NOT_SPACES);
606
- if (url.slice(-1) === ",") {
607
- url = absoluteToDoc(doc, url.substring(0, url.length - 1));
608
- output.push(url);
609
- } else {
610
- let descriptorsStr = "";
611
- url = absoluteToDoc(doc, url);
612
- let inParens = false;
613
- while (true) {
614
- const c = attributeValue.charAt(pos);
615
- if (c === "") {
616
- output.push((url + descriptorsStr).trim());
617
- break;
618
- } else if (!inParens) {
619
- if (c === ",") {
620
- pos += 1;
621
- output.push((url + descriptorsStr).trim());
622
- break;
623
- } else if (c === "(") {
624
- inParens = true;
625
- }
626
- } else {
627
- if (c === ")") {
628
- inParens = false;
629
- }
630
- }
631
- descriptorsStr += c;
632
- pos += 1;
633
- }
634
- }
635
- }
636
- return output.join(", ");
637
- }
638
- var cachedDocument = /* @__PURE__ */ new WeakMap();
639
- function absoluteToDoc(doc, attributeValue) {
640
- if (!attributeValue || attributeValue.trim() === "") {
641
- return attributeValue;
642
- }
643
- return getHref(doc, attributeValue);
644
- }
645
- function isSVGElement(el) {
646
- return Boolean(el.tagName === "svg" || el.ownerSVGElement);
647
- }
648
- function getHref(doc, customHref) {
649
- let a = cachedDocument.get(doc);
650
- if (!a) {
651
- a = doc.createElement("a");
652
- cachedDocument.set(doc, a);
653
- }
654
- if (!customHref) {
655
- customHref = "";
656
- } else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
657
- return customHref;
658
- }
659
- a.setAttribute("href", customHref);
660
- return a.href;
661
- }
662
- function transformAttribute(doc, tagName, name, value, element, dataURLOptions) {
663
- if (!value) {
664
- return value;
665
- }
666
- if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
667
- const transformedValue = absoluteToDoc(doc, value);
668
- if (tagName === "img" && transformedValue.startsWith("data:") && element) {
669
- const img = element;
670
- let processedDataURL = transformedValue;
671
- if ((dataURLOptions == null ? void 0 : dataURLOptions.type) || (dataURLOptions == null ? void 0 : dataURLOptions.quality) !== void 0) {
672
- processedDataURL = types.recompressBase64Image(
673
- img,
674
- transformedValue,
675
- dataURLOptions.type,
676
- dataURLOptions.quality
677
- );
678
- }
679
- if (dataURLOptions == null ? void 0 : dataURLOptions.maxBase64ImageLength) {
680
- processedDataURL = types.checkDataURLSize(
681
- processedDataURL,
682
- dataURLOptions.maxBase64ImageLength
683
- );
684
- }
685
- return processedDataURL;
686
- }
687
- return transformedValue;
688
- } else if (name === "xlink:href" && value[0] !== "#") {
689
- return absoluteToDoc(doc, value);
690
- } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
691
- return absoluteToDoc(doc, value);
692
- } else if (name === "srcset") {
693
- return getAbsoluteSrcsetString(doc, value);
694
- } else if (name === "style") {
695
- return types.absolutifyURLs(value, getHref(doc));
696
- } else if (tagName === "object" && name === "data") {
697
- return absoluteToDoc(doc, value);
698
- }
699
- return value;
700
- }
701
- function ignoreAttribute(tagName, name, _value) {
702
- return (tagName === "video" || tagName === "audio") && name === "autoplay";
703
- }
704
- function _isBlockedElement(element, blockClass, blockSelector) {
705
- try {
706
- if (typeof blockClass === "string") {
707
- if (element.classList.contains(blockClass)) {
708
- return true;
709
- }
710
- } else {
711
- for (let eIndex = element.classList.length; eIndex--; ) {
712
- const className = element.classList[eIndex];
713
- if (blockClass.test(className)) {
714
- return true;
715
- }
716
- }
717
- }
718
- if (blockSelector) {
719
- return element.matches(blockSelector);
720
- }
721
- } catch (e) {
722
- }
723
- return false;
724
- }
725
- function classMatchesRegex(node, regex, checkAncestors) {
726
- if (!node) return false;
727
- if (node.nodeType !== node.ELEMENT_NODE) {
728
- if (!checkAncestors) return false;
729
- return classMatchesRegex(types.index.parentNode(node), regex, checkAncestors);
730
- }
731
- for (let eIndex = node.classList.length; eIndex--; ) {
732
- const className = node.classList[eIndex];
733
- if (regex.test(className)) {
734
- return true;
735
- }
736
- }
737
- if (!checkAncestors) return false;
738
- return classMatchesRegex(types.index.parentNode(node), regex, checkAncestors);
739
- }
740
- function needMaskingText(node, maskTextClass, maskTextSelector, checkAncestors) {
741
- let el;
742
- if (types.isElement(node)) {
743
- el = node;
744
- if (!types.index.childNodes(el).length) {
745
- return false;
746
- }
747
- } else if (types.index.parentElement(node) === null) {
748
- return false;
749
- } else {
750
- el = types.index.parentElement(node);
751
- }
752
- try {
753
- if (typeof maskTextClass === "string") {
754
- if (checkAncestors) {
755
- if (el.closest(`.${maskTextClass}`)) return true;
756
- } else {
757
- if (el.classList.contains(maskTextClass)) return true;
758
- }
759
- } else {
760
- if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
761
- }
762
- if (maskTextSelector) {
763
- if (checkAncestors) {
764
- if (el.closest(maskTextSelector)) return true;
765
- } else {
766
- if (el.matches(maskTextSelector)) return true;
767
- }
768
- }
769
- } catch (e) {
770
- }
771
- return false;
772
- }
773
- function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
774
- const win = iframeEl.contentWindow;
775
- if (!win) {
776
- return;
777
- }
778
- let fired = false;
779
- let readyState;
780
- try {
781
- readyState = win.document.readyState;
782
- } catch (error) {
783
- return;
784
- }
785
- if (readyState !== "complete") {
786
- const timer = setTimeout(() => {
787
- if (!fired) {
788
- listener();
789
- fired = true;
790
- }
791
- }, iframeLoadTimeout);
792
- iframeEl.addEventListener("load", () => {
793
- clearTimeout(timer);
794
- fired = true;
795
- listener();
796
- });
797
- return;
798
- }
799
- const blankUrl = "about:blank";
800
- if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
801
- setTimeout(listener, 0);
802
- return iframeEl.addEventListener("load", listener);
803
- }
804
- iframeEl.addEventListener("load", listener);
805
- }
806
- function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
807
- let fired = false;
808
- let styleSheetLoaded;
809
- try {
810
- styleSheetLoaded = link.sheet;
811
- } catch (error) {
812
- return;
813
- }
814
- if (styleSheetLoaded) return;
815
- const timer = setTimeout(() => {
816
- if (!fired) {
817
- listener();
818
- fired = true;
819
- }
820
- }, styleSheetLoadTimeout);
821
- link.addEventListener("load", () => {
822
- clearTimeout(timer);
823
- fired = true;
824
- listener();
825
- });
826
- }
827
- function serializeNode(n, options) {
828
- const {
829
- doc,
830
- mirror,
831
- blockClass,
832
- blockSelector,
833
- needsMask,
834
- inlineStylesheet,
835
- maskInputOptions = {},
836
- maskTextFn,
837
- maskInputFn,
838
- dataURLOptions = {},
839
- inlineImages,
840
- recordCanvas,
841
- keepIframeSrcFn,
842
- newlyAddedElement = false
843
- } = options;
844
- const rootId = getRootId(doc, mirror);
845
- switch (n.nodeType) {
846
- case n.DOCUMENT_NODE:
847
- if (n.compatMode !== "CSS1Compat") {
848
- return {
849
- type: types.NodeType$1.Document,
850
- childNodes: [],
851
- compatMode: n.compatMode
852
- // probably "BackCompat"
853
- };
854
- } else {
855
- return {
856
- type: types.NodeType$1.Document,
857
- childNodes: []
858
- };
859
- }
860
- case n.DOCUMENT_TYPE_NODE:
861
- return {
862
- type: types.NodeType$1.DocumentType,
863
- name: n.name,
864
- publicId: n.publicId,
865
- systemId: n.systemId,
866
- rootId
867
- };
868
- case n.ELEMENT_NODE:
869
- return serializeElementNode(n, {
870
- doc,
871
- blockClass,
872
- blockSelector,
873
- inlineStylesheet,
874
- maskInputOptions,
875
- maskInputFn,
876
- dataURLOptions,
877
- inlineImages,
878
- recordCanvas,
879
- keepIframeSrcFn,
880
- newlyAddedElement,
881
- rootId
882
- });
883
- case n.TEXT_NODE:
884
- return serializeTextNode(n, {
885
- doc,
886
- needsMask,
887
- maskTextFn,
888
- rootId
889
- });
890
- case n.CDATA_SECTION_NODE:
891
- return {
892
- type: types.NodeType$1.CDATA,
893
- textContent: "",
894
- rootId
895
- };
896
- case n.COMMENT_NODE:
897
- return {
898
- type: types.NodeType$1.Comment,
899
- textContent: types.index.textContent(n) || "",
900
- rootId
901
- };
902
- default:
903
- return false;
904
- }
905
- }
906
- function getRootId(doc, mirror) {
907
- if (!mirror.hasNode(doc)) return void 0;
908
- const docId = mirror.getId(doc);
909
- return docId === 1 ? void 0 : docId;
910
- }
911
- function serializeTextNode(n, options) {
912
- var _a;
913
- const { needsMask, maskTextFn, rootId } = options;
914
- const parent = types.index.parentNode(n);
915
- const parentTagName = parent && parent.tagName;
916
- let text = types.index.textContent(n);
917
- const isStyle = parentTagName === "STYLE" ? true : void 0;
918
- const isScript = parentTagName === "SCRIPT" ? true : void 0;
919
- if (isStyle && text) {
920
- try {
921
- if (n.nextSibling || n.previousSibling) {
922
- } else if ((_a = parent.sheet) == null ? void 0 : _a.cssRules) {
923
- text = types.stringifyStylesheet(parent.sheet);
924
- }
925
- } catch (err) {
926
- console.warn(
927
- `Cannot get CSS styles from text's parentNode. Error: ${err}`,
928
- n
929
- );
930
- }
931
- text = types.absolutifyURLs(text, getHref(options.doc));
932
- }
933
- if (isScript) {
934
- text = "SCRIPT_PLACEHOLDER";
935
- }
936
- if (!isStyle && !isScript && text && needsMask) {
937
- text = maskTextFn ? maskTextFn(text, types.index.parentElement(n)) : text.replace(/[\S]/g, "*");
938
- }
939
- return {
940
- type: types.NodeType$1.Text,
941
- textContent: text || "",
942
- isStyle,
943
- rootId
944
- };
945
- }
946
- function findStylesheet(doc, href) {
947
- return Array.from(doc.styleSheets).find((s) => s.href === href);
948
- }
949
- function hrefFrom(n) {
950
- return n.href;
951
- }
952
- function serializeElementNode(n, options) {
953
- var _a, _b;
954
- const {
955
- doc,
956
- blockClass,
957
- blockSelector,
958
- inlineStylesheet,
959
- maskInputOptions = {},
960
- maskInputFn,
961
- dataURLOptions = {},
962
- inlineImages,
963
- recordCanvas,
964
- keepIframeSrcFn,
965
- newlyAddedElement = false,
966
- rootId
967
- } = options;
968
- const needBlock = _isBlockedElement(n, blockClass, blockSelector);
969
- const tagName = getValidTagName(n);
970
- let attributes = {};
971
- const len = n.attributes.length;
972
- for (let i = 0; i < len; i++) {
973
- const attr = n.attributes[i];
974
- if (!ignoreAttribute(tagName, attr.name, attr.value)) {
975
- attributes[attr.name] = transformAttribute(
976
- doc,
977
- tagName,
978
- types.toLowerCase(attr.name),
979
- attr.value,
980
- n,
981
- dataURLOptions
982
- );
983
- }
984
- }
985
- if (tagName === "link" && inlineStylesheet) {
986
- const href = hrefFrom(n);
987
- if (href) {
988
- let stylesheet = findStylesheet(doc, href);
989
- if (!stylesheet && href.includes(".css")) {
990
- const rootDomain = window.location.origin;
991
- const stylesheetPath = href.replace(window.location.href, "");
992
- const potentialStylesheetHref = rootDomain + "/" + stylesheetPath;
993
- stylesheet = findStylesheet(doc, potentialStylesheetHref);
994
- }
995
- let cssText = null;
996
- if (stylesheet) {
997
- cssText = types.stringifyStylesheet(stylesheet);
998
- }
999
- if (cssText) {
1000
- delete attributes.rel;
1001
- delete attributes.href;
1002
- attributes._cssText = cssText;
1003
- }
1004
- }
1005
- }
1006
- if (tagName === "style" && n.sheet && // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element
1007
- !(n.innerText || types.index.textContent(n) || "").trim().length) {
1008
- const cssText = types.stringifyStylesheet(
1009
- n.sheet
1010
- );
1011
- if (cssText) {
1012
- attributes._cssText = cssText;
1013
- }
1014
- }
1015
- if (tagName === "input" || tagName === "textarea" || tagName === "select") {
1016
- const value = n.value;
1017
- const checked = n.checked;
1018
- if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
1019
- attributes.value = types.maskInputValue({
1020
- element: n,
1021
- type: types.getInputType(n),
1022
- tagName,
1023
- value,
1024
- maskInputOptions,
1025
- maskInputFn
1026
- });
1027
- } else if (checked) {
1028
- attributes.checked = checked;
1029
- }
1030
- }
1031
- if (tagName === "option") {
1032
- if (n.selected && !maskInputOptions["select"]) {
1033
- attributes.selected = true;
1034
- } else {
1035
- delete attributes.selected;
1036
- }
1037
- }
1038
- if (tagName === "dialog" && n.open) {
1039
- try {
1040
- attributes.rr_open_mode = n.matches("dialog:modal") ? "modal" : "non-modal";
1041
- } catch (e) {
1042
- attributes.rr_open_mode = "modal";
1043
- attributes.ph_rr_could_not_detect_modal = true;
1044
- }
1045
- }
1046
- if (tagName === "canvas" && recordCanvas) {
1047
- if (n.__context === "2d") {
1048
- if (!types.is2DCanvasBlank(n)) {
1049
- attributes.rr_dataURL = n.toDataURL(
1050
- dataURLOptions.type,
1051
- dataURLOptions.quality
1052
- );
1053
- }
1054
- } else if (!("__context" in n)) {
1055
- const canvasDataURL = n.toDataURL(
1056
- dataURLOptions.type,
1057
- dataURLOptions.quality
1058
- );
1059
- const blankCanvas = doc.createElement("canvas");
1060
- blankCanvas.width = n.width;
1061
- blankCanvas.height = n.height;
1062
- const blankCanvasDataURL = blankCanvas.toDataURL(
1063
- dataURLOptions.type,
1064
- dataURLOptions.quality
1065
- );
1066
- if (canvasDataURL !== blankCanvasDataURL) {
1067
- attributes.rr_dataURL = canvasDataURL;
1068
- }
1069
- }
1070
- }
1071
- if (tagName === "img" && inlineImages) {
1072
- if (!canvasService) {
1073
- canvasService = doc.createElement("canvas");
1074
- canvasCtx = canvasService.getContext("2d");
1075
- }
1076
- const image = n;
1077
- const imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
1078
- const priorCrossOrigin = image.crossOrigin;
1079
- const recordInlineImage = () => {
1080
- image.removeEventListener("load", recordInlineImage);
1081
- try {
1082
- canvasService.width = image.naturalWidth;
1083
- canvasService.height = image.naturalHeight;
1084
- canvasCtx.drawImage(image, 0, 0);
1085
- attributes.rr_dataURL = canvasService.toDataURL(
1086
- dataURLOptions.type,
1087
- dataURLOptions.quality
1088
- );
1089
- } catch (err) {
1090
- if (image.crossOrigin !== "anonymous") {
1091
- image.crossOrigin = "anonymous";
1092
- if (image.complete && image.naturalWidth !== 0)
1093
- recordInlineImage();
1094
- else image.addEventListener("load", recordInlineImage);
1095
- return;
1096
- } else {
1097
- console.warn(
1098
- `Cannot inline img src=${imageSrc}! Error: ${err}`
1099
- );
1100
- }
1101
- }
1102
- if (image.crossOrigin === "anonymous") {
1103
- priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
1104
- }
1105
- };
1106
- if (image.complete && image.naturalWidth !== 0) recordInlineImage();
1107
- else image.addEventListener("load", recordInlineImage);
1108
- }
1109
- if (tagName === "audio" || tagName === "video") {
1110
- const mediaAttributes = attributes;
1111
- mediaAttributes.rr_mediaState = n.paused ? "paused" : "played";
1112
- mediaAttributes.rr_mediaCurrentTime = n.currentTime;
1113
- mediaAttributes.rr_mediaPlaybackRate = n.playbackRate;
1114
- mediaAttributes.rr_mediaMuted = n.muted;
1115
- mediaAttributes.rr_mediaLoop = n.loop;
1116
- mediaAttributes.rr_mediaVolume = n.volume;
1117
- }
1118
- if (!newlyAddedElement) {
1119
- if (n.scrollLeft) {
1120
- attributes.rr_scrollLeft = n.scrollLeft;
1121
- }
1122
- if (n.scrollTop) {
1123
- attributes.rr_scrollTop = n.scrollTop;
1124
- }
1125
- }
1126
- if (needBlock) {
1127
- const { width, height, left, top } = n.getBoundingClientRect();
1128
- attributes = {
1129
- class: attributes.class,
1130
- rr_width: `${width}px`,
1131
- rr_height: `${height}px`,
1132
- rr_left: `${Math.floor(left + (((_a = doc.defaultView) == null ? void 0 : _a.scrollX) || 0))}px`,
1133
- rr_top: `${Math.floor(top + (((_b = doc.defaultView) == null ? void 0 : _b.scrollY) || 0))}px`
1134
- };
1135
- }
1136
- if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
1137
- if (!n.contentDocument) {
1138
- attributes.rr_src = attributes.src;
1139
- }
1140
- delete attributes.src;
1141
- }
1142
- let isCustomElement;
1143
- try {
1144
- if (customElements.get(tagName)) isCustomElement = true;
1145
- } catch (e) {
1146
- }
1147
- return {
1148
- type: types.NodeType$1.Element,
1149
- tagName,
1150
- attributes,
1151
- childNodes: [],
1152
- isSVG: isSVGElement(n) || void 0,
1153
- needBlock,
1154
- rootId,
1155
- isCustom: isCustomElement
1156
- };
1157
- }
1158
- function lowerIfExists(maybeAttr) {
1159
- if (maybeAttr === void 0 || maybeAttr === null) {
1160
- return "";
1161
- } else {
1162
- return maybeAttr.toLowerCase();
1163
- }
1164
- }
1165
- function slimDOMExcluded(sn, slimDOMOptions) {
1166
- if (slimDOMOptions.comment && sn.type === types.NodeType$1.Comment) {
1167
- return true;
1168
- } else if (sn.type === types.NodeType$1.Element) {
1169
- if (slimDOMOptions.script && // script tag
1170
- (sn.tagName === "script" || // (module)preload link
1171
- sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
1172
- sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && types.extractFileExtension(sn.attributes.href) === "js")) {
1173
- return true;
1174
- } else if (slimDOMOptions.headFavicon && (sn.tagName === "link" && sn.attributes.rel === "shortcut icon" || sn.tagName === "meta" && (lowerIfExists(sn.attributes.name).match(
1175
- /^msapplication-tile(image|color)$/
1176
- ) || lowerIfExists(sn.attributes.name) === "application-name" || ["icon", "apple-touch-icon", "shortcut icon"].includes(
1177
- lowerIfExists(sn.attributes.rel)
1178
- )))) {
1179
- return true;
1180
- } else if (sn.tagName === "meta") {
1181
- if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
1182
- return true;
1183
- } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
1184
- lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
1185
- return true;
1186
- } else if (slimDOMOptions.headMetaRobots && ["robots", "googlebot", "bingbot"].includes(
1187
- lowerIfExists(sn.attributes.name)
1188
- )) {
1189
- return true;
1190
- } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
1191
- return true;
1192
- } else if (slimDOMOptions.headMetaAuthorship && (["author", "generator", "framework", "publisher", "progid"].includes(
1193
- lowerIfExists(sn.attributes.name)
1194
- ) || lowerIfExists(sn.attributes.property).match(/^article:/) || lowerIfExists(sn.attributes.property).match(/^product:/))) {
1195
- return true;
1196
- } else if (slimDOMOptions.headMetaVerification && [
1197
- "google-site-verification",
1198
- "yandex-verification",
1199
- "csrf-token",
1200
- "p:domain_verify",
1201
- "verify-v1",
1202
- "verification",
1203
- "shopify-checkout-api-token"
1204
- ].includes(lowerIfExists(sn.attributes.name))) {
1205
- return true;
1206
- }
1207
- }
1208
- }
1209
- return false;
1210
- }
1211
- var DEFAULT_MAX_DEPTH = 50;
1212
- var _maxDepthWarned = false;
1213
- var _maxDepthReached = false;
1214
- function wasMaxDepthReached() {
1215
- return _maxDepthReached;
1216
- }
1217
- function resetMaxDepthState() {
1218
- _maxDepthReached = false;
1219
- _maxDepthWarned = false;
1220
- }
1221
- function serializeNodeWithId(n, options) {
1222
- const {
1223
- doc,
1224
- mirror,
1225
- blockClass,
1226
- blockSelector,
1227
- maskTextClass,
1228
- maskTextSelector,
1229
- skipChild = false,
1230
- inlineStylesheet = true,
1231
- maskInputOptions = {},
1232
- maskTextFn,
1233
- maskInputFn,
1234
- slimDOMOptions,
1235
- dataURLOptions = {},
1236
- inlineImages = false,
1237
- recordCanvas = false,
1238
- onSerialize,
1239
- onIframeLoad,
1240
- iframeLoadTimeout = 5e3,
1241
- onStylesheetLoad,
1242
- stylesheetLoadTimeout = 5e3,
1243
- keepIframeSrcFn = () => false,
1244
- newlyAddedElement = false,
1245
- depth = 0,
1246
- maxDepth = DEFAULT_MAX_DEPTH
1247
- } = options;
1248
- let { needsMask } = options;
1249
- let { preserveWhiteSpace = true } = options;
1250
- if (depth >= maxDepth) {
1251
- _maxDepthReached = true;
1252
- if (!_maxDepthWarned) {
1253
- _maxDepthWarned = true;
1254
- console.warn(
1255
- `[rrweb-snapshot] DOM tree depth exceeded max depth of ${maxDepth}. Children beyond this depth will not be recorded. This may indicate deeply nested DOM structures.`
1256
- );
1257
- }
1258
- return null;
1259
- }
1260
- if (!needsMask) {
1261
- const checkAncestors = needsMask === void 0;
1262
- needsMask = needMaskingText(
1263
- n,
1264
- maskTextClass,
1265
- maskTextSelector,
1266
- checkAncestors
1267
- );
1268
- }
1269
- const _serializedNode = serializeNode(n, {
1270
- doc,
1271
- mirror,
1272
- blockClass,
1273
- blockSelector,
1274
- needsMask,
1275
- inlineStylesheet,
1276
- maskInputOptions,
1277
- maskTextFn,
1278
- maskInputFn,
1279
- dataURLOptions,
1280
- inlineImages,
1281
- recordCanvas,
1282
- keepIframeSrcFn,
1283
- newlyAddedElement
1284
- });
1285
- if (!_serializedNode) {
1286
- console.warn(n, "not serialized");
1287
- return null;
1288
- }
1289
- let id;
1290
- if (mirror.hasNode(n)) {
1291
- id = mirror.getId(n);
1292
- } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === types.NodeType$1.Text && !_serializedNode.isStyle && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
1293
- id = IGNORED_NODE;
1294
- } else {
1295
- id = genId();
1296
- }
1297
- const serializedNode = Object.assign(_serializedNode, { id });
1298
- mirror.add(n, serializedNode);
1299
- if (id === IGNORED_NODE) {
1300
- return null;
1301
- }
1302
- if (onSerialize) {
1303
- onSerialize(n);
1304
- }
1305
- let recordChild = !skipChild;
1306
- if (serializedNode.type === types.NodeType$1.Element) {
1307
- recordChild = recordChild && !serializedNode.needBlock;
1308
- delete serializedNode.needBlock;
1309
- const shadowRootEl = types.index.shadowRoot(n);
1310
- if (shadowRootEl && types.isNativeShadowDom(shadowRootEl))
1311
- serializedNode.isShadowHost = true;
1312
- }
1313
- if ((serializedNode.type === types.NodeType$1.Document || serializedNode.type === types.NodeType$1.Element) && recordChild) {
1314
- if (slimDOMOptions.headWhitespace && serializedNode.type === types.NodeType$1.Element && serializedNode.tagName === "head") {
1315
- preserveWhiteSpace = false;
1316
- }
1317
- const bypassOptions = {
1318
- doc,
1319
- mirror,
1320
- blockClass,
1321
- blockSelector,
1322
- needsMask,
1323
- maskTextClass,
1324
- maskTextSelector,
1325
- skipChild,
1326
- inlineStylesheet,
1327
- maskInputOptions,
1328
- maskTextFn,
1329
- maskInputFn,
1330
- slimDOMOptions,
1331
- dataURLOptions,
1332
- inlineImages,
1333
- recordCanvas,
1334
- preserveWhiteSpace,
1335
- onSerialize,
1336
- onIframeLoad,
1337
- iframeLoadTimeout,
1338
- onStylesheetLoad,
1339
- stylesheetLoadTimeout,
1340
- keepIframeSrcFn,
1341
- depth: depth + 1,
1342
- maxDepth
1343
- };
1344
- if (serializedNode.type === types.NodeType$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1345
- else {
1346
- for (const childN of Array.from(types.index.childNodes(n))) {
1347
- const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
1348
- if (serializedChildNode) {
1349
- serializedNode.childNodes.push(serializedChildNode);
1350
- }
1351
- }
1352
- }
1353
- let shadowRootEl = null;
1354
- if (types.isElement(n) && (shadowRootEl = types.index.shadowRoot(n))) {
1355
- for (const childN of Array.from(types.index.childNodes(shadowRootEl))) {
1356
- const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
1357
- if (serializedChildNode) {
1358
- types.isNativeShadowDom(shadowRootEl) && (serializedChildNode.isShadow = true);
1359
- serializedNode.childNodes.push(serializedChildNode);
1360
- }
1361
- }
1362
- }
1363
- }
1364
- const parent = types.index.parentNode(n);
1365
- if (parent && types.isShadowRoot(parent) && types.isNativeShadowDom(parent)) {
1366
- serializedNode.isShadow = true;
1367
- }
1368
- if (serializedNode.type === types.NodeType$1.Element && serializedNode.tagName === "iframe") {
1369
- onceIframeLoaded(
1370
- n,
1371
- () => {
1372
- const iframeDoc = n.contentDocument;
1373
- if (iframeDoc && onIframeLoad) {
1374
- const serializedIframeNode = serializeNodeWithId(iframeDoc, {
1375
- doc: iframeDoc,
1376
- mirror,
1377
- blockClass,
1378
- blockSelector,
1379
- needsMask,
1380
- maskTextClass,
1381
- maskTextSelector,
1382
- skipChild: false,
1383
- inlineStylesheet,
1384
- maskInputOptions,
1385
- maskTextFn,
1386
- maskInputFn,
1387
- slimDOMOptions,
1388
- dataURLOptions,
1389
- inlineImages,
1390
- recordCanvas,
1391
- preserveWhiteSpace,
1392
- onSerialize,
1393
- onIframeLoad,
1394
- iframeLoadTimeout,
1395
- onStylesheetLoad,
1396
- stylesheetLoadTimeout,
1397
- keepIframeSrcFn,
1398
- depth: depth + 1,
1399
- maxDepth
1400
- });
1401
- if (serializedIframeNode) {
1402
- onIframeLoad(
1403
- n,
1404
- serializedIframeNode
1405
- );
1406
- }
1407
- }
1408
- },
1409
- iframeLoadTimeout
1410
- );
1411
- }
1412
- if (serializedNode.type === types.NodeType$1.Element && serializedNode.tagName === "link" && typeof serializedNode.attributes.rel === "string" && (serializedNode.attributes.rel === "stylesheet" || serializedNode.attributes.rel === "preload" && typeof serializedNode.attributes.href === "string" && types.extractFileExtension(serializedNode.attributes.href) === "css")) {
1413
- onceStylesheetLoaded(
1414
- n,
1415
- () => {
1416
- if (onStylesheetLoad) {
1417
- const serializedLinkNode = serializeNodeWithId(n, {
1418
- doc,
1419
- mirror,
1420
- blockClass,
1421
- blockSelector,
1422
- needsMask,
1423
- maskTextClass,
1424
- maskTextSelector,
1425
- skipChild: false,
1426
- inlineStylesheet,
1427
- maskInputOptions,
1428
- maskTextFn,
1429
- maskInputFn,
1430
- slimDOMOptions,
1431
- dataURLOptions,
1432
- inlineImages,
1433
- recordCanvas,
1434
- preserveWhiteSpace,
1435
- onSerialize,
1436
- onIframeLoad,
1437
- iframeLoadTimeout,
1438
- onStylesheetLoad,
1439
- stylesheetLoadTimeout,
1440
- keepIframeSrcFn,
1441
- depth,
1442
- maxDepth
1443
- });
1444
- if (serializedLinkNode) {
1445
- onStylesheetLoad(
1446
- n,
1447
- serializedLinkNode
1448
- );
1449
- }
1450
- }
1451
- },
1452
- stylesheetLoadTimeout
1453
- );
1454
- }
1455
- return serializedNode;
1456
- }
1457
- function slimDOMDefaults(slimDOM) {
1458
- if (slimDOM === true || slimDOM === "all") {
1459
- return {
1460
- script: true,
1461
- comment: true,
1462
- headFavicon: true,
1463
- headWhitespace: true,
1464
- headMetaSocial: true,
1465
- headMetaRobots: true,
1466
- headMetaHttpEquiv: true,
1467
- headMetaVerification: true,
1468
- headMetaAuthorship: slimDOM === "all",
1469
- headMetaDescKeywords: slimDOM === "all",
1470
- headTitleMutations: slimDOM === "all"
1471
- };
1472
- }
1473
- if (slimDOM === false) {
1474
- return {};
1475
- }
1476
- return slimDOM;
1477
- }
1478
- function snapshot(n, options) {
1479
- const {
1480
- mirror = new types.Mirror(),
1481
- blockClass = "rr-block",
1482
- blockSelector = null,
1483
- maskTextClass = "rr-mask",
1484
- maskTextSelector = null,
1485
- inlineStylesheet = true,
1486
- inlineImages = false,
1487
- recordCanvas = false,
1488
- maskAllInputs = false,
1489
- maskTextFn,
1490
- maskInputFn,
1491
- slimDOM = false,
1492
- dataURLOptions,
1493
- preserveWhiteSpace,
1494
- onSerialize,
1495
- onIframeLoad,
1496
- iframeLoadTimeout,
1497
- onStylesheetLoad,
1498
- stylesheetLoadTimeout,
1499
- keepIframeSrcFn = () => false,
1500
- maxDepth
1501
- } = options || {};
1502
- const maskInputOptions = maskAllInputs === true ? {
1503
- color: true,
1504
- date: true,
1505
- "datetime-local": true,
1506
- email: true,
1507
- month: true,
1508
- number: true,
1509
- range: true,
1510
- search: true,
1511
- tel: true,
1512
- text: true,
1513
- time: true,
1514
- url: true,
1515
- week: true,
1516
- textarea: true,
1517
- select: true,
1518
- password: true
1519
- } : maskAllInputs === false ? {
1520
- password: true
1521
- } : maskAllInputs;
1522
- const slimDOMOptions = slimDOMDefaults(slimDOM);
1523
- return serializeNodeWithId(n, {
1524
- doc: n,
1525
- mirror,
1526
- blockClass,
1527
- blockSelector,
1528
- maskTextClass,
1529
- maskTextSelector,
1530
- skipChild: false,
1531
- inlineStylesheet,
1532
- maskInputOptions,
1533
- maskTextFn,
1534
- maskInputFn,
1535
- slimDOMOptions,
1536
- dataURLOptions,
1537
- inlineImages,
1538
- recordCanvas,
1539
- preserveWhiteSpace,
1540
- onSerialize,
1541
- onIframeLoad,
1542
- iframeLoadTimeout,
1543
- onStylesheetLoad,
1544
- stylesheetLoadTimeout,
1545
- keepIframeSrcFn,
1546
- newlyAddedElement: false,
1547
- maxDepth
1548
- });
1549
- }
1550
- function visitSnapshot(node, onVisit) {
1551
- function walk(current) {
1552
- onVisit(current);
1553
- if (current.type === types.NodeType$1.Document || current.type === types.NodeType$1.Element) {
1554
- current.childNodes.forEach(walk);
1555
- }
1556
- }
1557
- walk(node);
1558
- }
1559
- function cleanupSnapshot() {
1560
- _id = 1;
1561
- }
1562
- exports.DEFAULT_MAX_DEPTH = DEFAULT_MAX_DEPTH;
1563
- exports.IGNORED_NODE = IGNORED_NODE;
1564
- exports.classMatchesRegex = classMatchesRegex;
1565
- exports.cleanupSnapshot = cleanupSnapshot;
1566
- exports.genId = genId;
1567
- exports.ignoreAttribute = ignoreAttribute;
1568
- exports.needMaskingText = needMaskingText;
1569
- exports.resetMaxDepthState = resetMaxDepthState;
1570
- exports.serializeNodeWithId = serializeNodeWithId;
1571
- exports.slimDOMDefaults = slimDOMDefaults;
1572
- exports.snapshot = snapshot;
1573
- exports.transformAttribute = transformAttribute;
1574
- exports.visitSnapshot = visitSnapshot;
1575
- exports.wasMaxDepthReached = wasMaxDepthReached;
1576
- ;if (typeof module.exports == "object" && typeof exports == "object") {
1577
- var __cp = (to, from, except, desc) => {
1578
- if ((from && typeof from === "object") || typeof from === "function") {
1579
- for (let key of Object.getOwnPropertyNames(from)) {
1580
- if (!Object.prototype.hasOwnProperty.call(to, key) && key !== except)
1581
- Object.defineProperty(to, key, {
1582
- get: () => from[key],
1583
- enumerable: !(desc = Object.getOwnPropertyDescriptor(from, key)) || desc.enumerable,
1584
- });
1585
- }
1586
- }
1587
- return to;
1588
- };
1589
- module.exports = __cp(module.exports, exports);
1590
- }
1591
- return module.exports;
1592
- }))
1593
- //# sourceMappingURL=record-Rc5ocxPN.umd.cjs.map