@posthog/rrweb-snapshot 0.0.54 → 0.0.55

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.
Files changed (41) hide show
  1. package/dist/record-BhFABPFv.js +1016 -0
  2. package/dist/record-BhFABPFv.js.map +1 -0
  3. package/dist/record-Rc5ocxPN.cjs +1015 -0
  4. package/dist/record-Rc5ocxPN.cjs.map +1 -0
  5. package/dist/record-Rc5ocxPN.umd.cjs +1593 -0
  6. package/dist/record-Rc5ocxPN.umd.cjs.map +7 -0
  7. package/dist/record-Rc5ocxPN.umd.min.cjs +20 -0
  8. package/dist/record-Rc5ocxPN.umd.min.cjs.map +7 -0
  9. package/dist/record.cjs +13 -1012
  10. package/dist/record.cjs.map +1 -1
  11. package/dist/record.d.cts +273 -5
  12. package/dist/record.d.ts +273 -5
  13. package/dist/record.js +29 -1029
  14. package/dist/record.js.map +1 -1
  15. package/dist/record.umd.cjs +976 -955
  16. package/dist/record.umd.cjs.map +3 -3
  17. package/dist/record.umd.min.cjs +1 -1
  18. package/dist/record.umd.min.cjs.map +4 -4
  19. package/dist/replay.d.cts +219 -5
  20. package/dist/replay.d.ts +219 -5
  21. package/dist/rrweb-snapshot.cjs +1 -1
  22. package/dist/rrweb-snapshot.d.cts +299 -1
  23. package/dist/rrweb-snapshot.d.ts +299 -1
  24. package/dist/rrweb-snapshot.js +26 -26
  25. package/dist/rrweb-snapshot.umd.cjs +4 -26
  26. package/dist/rrweb-snapshot.umd.cjs.map +2 -2
  27. package/dist/rrweb-snapshot.umd.min.cjs +10 -10
  28. package/dist/rrweb-snapshot.umd.min.cjs.map +2 -2
  29. package/package.json +3 -3
  30. package/dist/css.d.cts +0 -5
  31. package/dist/css.d.ts +0 -5
  32. package/dist/index.d.cts +0 -6
  33. package/dist/index.d.ts +0 -6
  34. package/dist/rebuild.d.cts +0 -23
  35. package/dist/rebuild.d.ts +0 -23
  36. package/dist/snapshot.d.cts +0 -71
  37. package/dist/snapshot.d.ts +0 -71
  38. package/dist/types.d.cts +0 -103
  39. package/dist/types.d.ts +0 -103
  40. package/dist/utils.d.cts +0 -51
  41. package/dist/utils.d.ts +0 -51
package/dist/record.js CHANGED
@@ -1,1038 +1,38 @@
1
- import { M as Mirror, q as NodeType, u as index, b as isNativeShadowDom, i as isElement, a as isShadowRoot, n as extractFileExtension, r as recompressBase64Image, p as checkDataURLSize, o as absolutifyURLs, s as stringifyStylesheet, t as toLowerCase, m as maskInputValue, l as getInputType, j as is2DCanvasBlank } from "./types-D1TQIdgp.js";
2
- import { N, h, e, f, d, g, k, c } from "./types-D1TQIdgp.js";
3
- let _id = 1;
4
- const tagNameRegex = new RegExp("[^a-z0-9-_:]");
5
- const IGNORED_NODE = -2;
6
- function genId() {
7
- return _id++;
8
- }
9
- function getValidTagName(element) {
10
- if (element instanceof HTMLFormElement) {
11
- return "form";
12
- }
13
- const processedTagName = toLowerCase(element.tagName);
14
- if (tagNameRegex.test(processedTagName)) {
15
- return "div";
16
- }
17
- return processedTagName;
18
- }
19
- let canvasService;
20
- let canvasCtx;
21
- const SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
22
- const SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
23
- function getAbsoluteSrcsetString(doc, attributeValue) {
24
- if (attributeValue.trim() === "") {
25
- return attributeValue;
26
- }
27
- let pos = 0;
28
- function collectCharacters(regEx) {
29
- let chars;
30
- const match = regEx.exec(attributeValue.substring(pos));
31
- if (match) {
32
- chars = match[0];
33
- pos += chars.length;
34
- return chars;
35
- }
36
- return "";
37
- }
38
- const output = [];
39
- while (true) {
40
- collectCharacters(SRCSET_COMMAS_OR_SPACES);
41
- if (pos >= attributeValue.length) {
42
- break;
43
- }
44
- let url = collectCharacters(SRCSET_NOT_SPACES);
45
- if (url.slice(-1) === ",") {
46
- url = absoluteToDoc(doc, url.substring(0, url.length - 1));
47
- output.push(url);
48
- } else {
49
- let descriptorsStr = "";
50
- url = absoluteToDoc(doc, url);
51
- let inParens = false;
52
- while (true) {
53
- const c2 = attributeValue.charAt(pos);
54
- if (c2 === "") {
55
- output.push((url + descriptorsStr).trim());
56
- break;
57
- } else if (!inParens) {
58
- if (c2 === ",") {
59
- pos += 1;
60
- output.push((url + descriptorsStr).trim());
61
- break;
62
- } else if (c2 === "(") {
63
- inParens = true;
64
- }
65
- } else {
66
- if (c2 === ")") {
67
- inParens = false;
68
- }
69
- }
70
- descriptorsStr += c2;
71
- pos += 1;
72
- }
73
- }
74
- }
75
- return output.join(", ");
76
- }
77
- const cachedDocument = /* @__PURE__ */ new WeakMap();
78
- function absoluteToDoc(doc, attributeValue) {
79
- if (!attributeValue || attributeValue.trim() === "") {
80
- return attributeValue;
81
- }
82
- return getHref(doc, attributeValue);
83
- }
84
- function isSVGElement(el) {
85
- return Boolean(el.tagName === "svg" || el.ownerSVGElement);
86
- }
87
- function getHref(doc, customHref) {
88
- let a = cachedDocument.get(doc);
89
- if (!a) {
90
- a = doc.createElement("a");
91
- cachedDocument.set(doc, a);
92
- }
93
- if (!customHref) {
94
- customHref = "";
95
- } else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
96
- return customHref;
97
- }
98
- a.setAttribute("href", customHref);
99
- return a.href;
100
- }
101
- function transformAttribute(doc, tagName, name, value, element, dataURLOptions) {
102
- if (!value) {
103
- return value;
104
- }
105
- if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
106
- const transformedValue = absoluteToDoc(doc, value);
107
- if (tagName === "img" && transformedValue.startsWith("data:") && element) {
108
- const img = element;
109
- let processedDataURL = transformedValue;
110
- if ((dataURLOptions == null ? void 0 : dataURLOptions.type) || (dataURLOptions == null ? void 0 : dataURLOptions.quality) !== void 0) {
111
- processedDataURL = recompressBase64Image(
112
- img,
113
- transformedValue,
114
- dataURLOptions.type,
115
- dataURLOptions.quality
116
- );
117
- }
118
- if (dataURLOptions == null ? void 0 : dataURLOptions.maxBase64ImageLength) {
119
- processedDataURL = checkDataURLSize(
120
- processedDataURL,
121
- dataURLOptions.maxBase64ImageLength
122
- );
123
- }
124
- return processedDataURL;
125
- }
126
- return transformedValue;
127
- } else if (name === "xlink:href" && value[0] !== "#") {
128
- return absoluteToDoc(doc, value);
129
- } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
130
- return absoluteToDoc(doc, value);
131
- } else if (name === "srcset") {
132
- return getAbsoluteSrcsetString(doc, value);
133
- } else if (name === "style") {
134
- return absolutifyURLs(value, getHref(doc));
135
- } else if (tagName === "object" && name === "data") {
136
- return absoluteToDoc(doc, value);
137
- }
138
- return value;
139
- }
140
- function ignoreAttribute(tagName, name, _value) {
141
- return (tagName === "video" || tagName === "audio") && name === "autoplay";
142
- }
143
- function _isBlockedElement(element, blockClass, blockSelector) {
144
- try {
145
- if (typeof blockClass === "string") {
146
- if (element.classList.contains(blockClass)) {
147
- return true;
148
- }
149
- } else {
150
- for (let eIndex = element.classList.length; eIndex--; ) {
151
- const className = element.classList[eIndex];
152
- if (blockClass.test(className)) {
153
- return true;
154
- }
155
- }
156
- }
157
- if (blockSelector) {
158
- return element.matches(blockSelector);
159
- }
160
- } catch (e2) {
161
- }
162
- return false;
163
- }
164
- function classMatchesRegex(node, regex, checkAncestors) {
165
- if (!node) return false;
166
- if (node.nodeType !== node.ELEMENT_NODE) {
167
- if (!checkAncestors) return false;
168
- return classMatchesRegex(index.parentNode(node), regex, checkAncestors);
169
- }
170
- for (let eIndex = node.classList.length; eIndex--; ) {
171
- const className = node.classList[eIndex];
172
- if (regex.test(className)) {
173
- return true;
174
- }
175
- }
176
- if (!checkAncestors) return false;
177
- return classMatchesRegex(index.parentNode(node), regex, checkAncestors);
178
- }
179
- function needMaskingText(node, maskTextClass, maskTextSelector, checkAncestors) {
180
- let el;
181
- if (isElement(node)) {
182
- el = node;
183
- if (!index.childNodes(el).length) {
184
- return false;
185
- }
186
- } else if (index.parentElement(node) === null) {
187
- return false;
188
- } else {
189
- el = index.parentElement(node);
190
- }
191
- try {
192
- if (typeof maskTextClass === "string") {
193
- if (checkAncestors) {
194
- if (el.closest(`.${maskTextClass}`)) return true;
195
- } else {
196
- if (el.classList.contains(maskTextClass)) return true;
197
- }
198
- } else {
199
- if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
200
- }
201
- if (maskTextSelector) {
202
- if (checkAncestors) {
203
- if (el.closest(maskTextSelector)) return true;
204
- } else {
205
- if (el.matches(maskTextSelector)) return true;
206
- }
207
- }
208
- } catch (e2) {
209
- }
210
- return false;
211
- }
212
- function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
213
- const win = iframeEl.contentWindow;
214
- if (!win) {
215
- return;
216
- }
217
- let fired = false;
218
- let readyState;
219
- try {
220
- readyState = win.document.readyState;
221
- } catch (error) {
222
- return;
223
- }
224
- if (readyState !== "complete") {
225
- const timer = setTimeout(() => {
226
- if (!fired) {
227
- listener();
228
- fired = true;
229
- }
230
- }, iframeLoadTimeout);
231
- iframeEl.addEventListener("load", () => {
232
- clearTimeout(timer);
233
- fired = true;
234
- listener();
235
- });
236
- return;
237
- }
238
- const blankUrl = "about:blank";
239
- if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
240
- setTimeout(listener, 0);
241
- return iframeEl.addEventListener("load", listener);
242
- }
243
- iframeEl.addEventListener("load", listener);
244
- }
245
- function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
246
- let fired = false;
247
- let styleSheetLoaded;
248
- try {
249
- styleSheetLoaded = link.sheet;
250
- } catch (error) {
251
- return;
252
- }
253
- if (styleSheetLoaded) return;
254
- const timer = setTimeout(() => {
255
- if (!fired) {
256
- listener();
257
- fired = true;
258
- }
259
- }, styleSheetLoadTimeout);
260
- link.addEventListener("load", () => {
261
- clearTimeout(timer);
262
- fired = true;
263
- listener();
264
- });
265
- }
266
- function serializeNode(n, options) {
267
- const {
268
- doc,
269
- mirror,
270
- blockClass,
271
- blockSelector,
272
- needsMask,
273
- inlineStylesheet,
274
- maskInputOptions = {},
275
- maskTextFn,
276
- maskInputFn,
277
- dataURLOptions = {},
278
- inlineImages,
279
- recordCanvas,
280
- keepIframeSrcFn,
281
- newlyAddedElement = false
282
- } = options;
283
- const rootId = getRootId(doc, mirror);
284
- switch (n.nodeType) {
285
- case n.DOCUMENT_NODE:
286
- if (n.compatMode !== "CSS1Compat") {
287
- return {
288
- type: NodeType.Document,
289
- childNodes: [],
290
- compatMode: n.compatMode
291
- // probably "BackCompat"
292
- };
293
- } else {
294
- return {
295
- type: NodeType.Document,
296
- childNodes: []
297
- };
298
- }
299
- case n.DOCUMENT_TYPE_NODE:
300
- return {
301
- type: NodeType.DocumentType,
302
- name: n.name,
303
- publicId: n.publicId,
304
- systemId: n.systemId,
305
- rootId
306
- };
307
- case n.ELEMENT_NODE:
308
- return serializeElementNode(n, {
309
- doc,
310
- blockClass,
311
- blockSelector,
312
- inlineStylesheet,
313
- maskInputOptions,
314
- maskInputFn,
315
- dataURLOptions,
316
- inlineImages,
317
- recordCanvas,
318
- keepIframeSrcFn,
319
- newlyAddedElement,
320
- rootId
321
- });
322
- case n.TEXT_NODE:
323
- return serializeTextNode(n, {
324
- doc,
325
- needsMask,
326
- maskTextFn,
327
- rootId
328
- });
329
- case n.CDATA_SECTION_NODE:
330
- return {
331
- type: NodeType.CDATA,
332
- textContent: "",
333
- rootId
334
- };
335
- case n.COMMENT_NODE:
336
- return {
337
- type: NodeType.Comment,
338
- textContent: index.textContent(n) || "",
339
- rootId
340
- };
341
- default:
342
- return false;
343
- }
344
- }
345
- function getRootId(doc, mirror) {
346
- if (!mirror.hasNode(doc)) return void 0;
347
- const docId = mirror.getId(doc);
348
- return docId === 1 ? void 0 : docId;
349
- }
350
- function serializeTextNode(n, options) {
351
- var _a;
352
- const { needsMask, maskTextFn, rootId } = options;
353
- const parent = index.parentNode(n);
354
- const parentTagName = parent && parent.tagName;
355
- let text = index.textContent(n);
356
- const isStyle = parentTagName === "STYLE" ? true : void 0;
357
- const isScript = parentTagName === "SCRIPT" ? true : void 0;
358
- if (isStyle && text) {
359
- try {
360
- if (n.nextSibling || n.previousSibling) {
361
- } else if ((_a = parent.sheet) == null ? void 0 : _a.cssRules) {
362
- text = stringifyStylesheet(parent.sheet);
363
- }
364
- } catch (err) {
365
- console.warn(
366
- `Cannot get CSS styles from text's parentNode. Error: ${err}`,
367
- n
368
- );
369
- }
370
- text = absolutifyURLs(text, getHref(options.doc));
371
- }
372
- if (isScript) {
373
- text = "SCRIPT_PLACEHOLDER";
374
- }
375
- if (!isStyle && !isScript && text && needsMask) {
376
- text = maskTextFn ? maskTextFn(text, index.parentElement(n)) : text.replace(/[\S]/g, "*");
377
- }
378
- return {
379
- type: NodeType.Text,
380
- textContent: text || "",
381
- isStyle,
382
- rootId
383
- };
384
- }
385
- function findStylesheet(doc, href) {
386
- return Array.from(doc.styleSheets).find((s) => s.href === href);
387
- }
388
- function hrefFrom(n) {
389
- return n.href;
390
- }
391
- function serializeElementNode(n, options) {
392
- var _a, _b;
393
- const {
394
- doc,
395
- blockClass,
396
- blockSelector,
397
- inlineStylesheet,
398
- maskInputOptions = {},
399
- maskInputFn,
400
- dataURLOptions = {},
401
- inlineImages,
402
- recordCanvas,
403
- keepIframeSrcFn,
404
- newlyAddedElement = false,
405
- rootId
406
- } = options;
407
- const needBlock = _isBlockedElement(n, blockClass, blockSelector);
408
- const tagName = getValidTagName(n);
409
- let attributes = {};
410
- const len = n.attributes.length;
411
- for (let i = 0; i < len; i++) {
412
- const attr = n.attributes[i];
413
- if (!ignoreAttribute(tagName, attr.name, attr.value)) {
414
- attributes[attr.name] = transformAttribute(
415
- doc,
416
- tagName,
417
- toLowerCase(attr.name),
418
- attr.value,
419
- n,
420
- dataURLOptions
421
- );
422
- }
423
- }
424
- if (tagName === "link" && inlineStylesheet) {
425
- const href = hrefFrom(n);
426
- if (href) {
427
- let stylesheet = findStylesheet(doc, href);
428
- if (!stylesheet && href.includes(".css")) {
429
- const rootDomain = window.location.origin;
430
- const stylesheetPath = href.replace(window.location.href, "");
431
- const potentialStylesheetHref = rootDomain + "/" + stylesheetPath;
432
- stylesheet = findStylesheet(doc, potentialStylesheetHref);
433
- }
434
- let cssText = null;
435
- if (stylesheet) {
436
- cssText = stringifyStylesheet(stylesheet);
437
- }
438
- if (cssText) {
439
- delete attributes.rel;
440
- delete attributes.href;
441
- attributes._cssText = cssText;
442
- }
443
- }
444
- }
445
- if (tagName === "style" && n.sheet && // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element
446
- !(n.innerText || index.textContent(n) || "").trim().length) {
447
- const cssText = stringifyStylesheet(
448
- n.sheet
449
- );
450
- if (cssText) {
451
- attributes._cssText = cssText;
452
- }
453
- }
454
- if (tagName === "input" || tagName === "textarea" || tagName === "select") {
455
- const value = n.value;
456
- const checked = n.checked;
457
- if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
458
- attributes.value = maskInputValue({
459
- element: n,
460
- type: getInputType(n),
461
- tagName,
462
- value,
463
- maskInputOptions,
464
- maskInputFn
465
- });
466
- } else if (checked) {
467
- attributes.checked = checked;
468
- }
469
- }
470
- if (tagName === "option") {
471
- if (n.selected && !maskInputOptions["select"]) {
472
- attributes.selected = true;
473
- } else {
474
- delete attributes.selected;
475
- }
476
- }
477
- if (tagName === "dialog" && n.open) {
478
- try {
479
- attributes.rr_open_mode = n.matches("dialog:modal") ? "modal" : "non-modal";
480
- } catch {
481
- attributes.rr_open_mode = "modal";
482
- attributes.ph_rr_could_not_detect_modal = true;
483
- }
484
- }
485
- if (tagName === "canvas" && recordCanvas) {
486
- if (n.__context === "2d") {
487
- if (!is2DCanvasBlank(n)) {
488
- attributes.rr_dataURL = n.toDataURL(
489
- dataURLOptions.type,
490
- dataURLOptions.quality
491
- );
492
- }
493
- } else if (!("__context" in n)) {
494
- const canvasDataURL = n.toDataURL(
495
- dataURLOptions.type,
496
- dataURLOptions.quality
497
- );
498
- const blankCanvas = doc.createElement("canvas");
499
- blankCanvas.width = n.width;
500
- blankCanvas.height = n.height;
501
- const blankCanvasDataURL = blankCanvas.toDataURL(
502
- dataURLOptions.type,
503
- dataURLOptions.quality
504
- );
505
- if (canvasDataURL !== blankCanvasDataURL) {
506
- attributes.rr_dataURL = canvasDataURL;
507
- }
508
- }
509
- }
510
- if (tagName === "img" && inlineImages) {
511
- if (!canvasService) {
512
- canvasService = doc.createElement("canvas");
513
- canvasCtx = canvasService.getContext("2d");
514
- }
515
- const image = n;
516
- const imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
517
- const priorCrossOrigin = image.crossOrigin;
518
- const recordInlineImage = () => {
519
- image.removeEventListener("load", recordInlineImage);
520
- try {
521
- canvasService.width = image.naturalWidth;
522
- canvasService.height = image.naturalHeight;
523
- canvasCtx.drawImage(image, 0, 0);
524
- attributes.rr_dataURL = canvasService.toDataURL(
525
- dataURLOptions.type,
526
- dataURLOptions.quality
527
- );
528
- } catch (err) {
529
- if (image.crossOrigin !== "anonymous") {
530
- image.crossOrigin = "anonymous";
531
- if (image.complete && image.naturalWidth !== 0)
532
- recordInlineImage();
533
- else image.addEventListener("load", recordInlineImage);
534
- return;
535
- } else {
536
- console.warn(
537
- `Cannot inline img src=${imageSrc}! Error: ${err}`
538
- );
539
- }
540
- }
541
- if (image.crossOrigin === "anonymous") {
542
- priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
543
- }
544
- };
545
- if (image.complete && image.naturalWidth !== 0) recordInlineImage();
546
- else image.addEventListener("load", recordInlineImage);
547
- }
548
- if (tagName === "audio" || tagName === "video") {
549
- const mediaAttributes = attributes;
550
- mediaAttributes.rr_mediaState = n.paused ? "paused" : "played";
551
- mediaAttributes.rr_mediaCurrentTime = n.currentTime;
552
- mediaAttributes.rr_mediaPlaybackRate = n.playbackRate;
553
- mediaAttributes.rr_mediaMuted = n.muted;
554
- mediaAttributes.rr_mediaLoop = n.loop;
555
- mediaAttributes.rr_mediaVolume = n.volume;
556
- }
557
- if (!newlyAddedElement) {
558
- if (n.scrollLeft) {
559
- attributes.rr_scrollLeft = n.scrollLeft;
560
- }
561
- if (n.scrollTop) {
562
- attributes.rr_scrollTop = n.scrollTop;
563
- }
564
- }
565
- if (needBlock) {
566
- const { width, height, left, top } = n.getBoundingClientRect();
567
- attributes = {
568
- class: attributes.class,
569
- rr_width: `${width}px`,
570
- rr_height: `${height}px`,
571
- rr_left: `${Math.floor(left + (((_a = doc.defaultView) == null ? void 0 : _a.scrollX) || 0))}px`,
572
- rr_top: `${Math.floor(top + (((_b = doc.defaultView) == null ? void 0 : _b.scrollY) || 0))}px`
573
- };
574
- }
575
- if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
576
- if (!n.contentDocument) {
577
- attributes.rr_src = attributes.src;
578
- }
579
- delete attributes.src;
580
- }
581
- let isCustomElement;
582
- try {
583
- if (customElements.get(tagName)) isCustomElement = true;
584
- } catch (e2) {
585
- }
586
- return {
587
- type: NodeType.Element,
588
- tagName,
589
- attributes,
590
- childNodes: [],
591
- isSVG: isSVGElement(n) || void 0,
592
- needBlock,
593
- rootId,
594
- isCustom: isCustomElement
595
- };
596
- }
597
- function lowerIfExists(maybeAttr) {
598
- if (maybeAttr === void 0 || maybeAttr === null) {
599
- return "";
600
- } else {
601
- return maybeAttr.toLowerCase();
602
- }
603
- }
604
- function slimDOMExcluded(sn, slimDOMOptions) {
605
- if (slimDOMOptions.comment && sn.type === NodeType.Comment) {
606
- return true;
607
- } else if (sn.type === NodeType.Element) {
608
- if (slimDOMOptions.script && // script tag
609
- (sn.tagName === "script" || // (module)preload link
610
- sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
611
- sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && extractFileExtension(sn.attributes.href) === "js")) {
612
- return true;
613
- } else if (slimDOMOptions.headFavicon && (sn.tagName === "link" && sn.attributes.rel === "shortcut icon" || sn.tagName === "meta" && (lowerIfExists(sn.attributes.name).match(
614
- /^msapplication-tile(image|color)$/
615
- ) || lowerIfExists(sn.attributes.name) === "application-name" || ["icon", "apple-touch-icon", "shortcut icon"].includes(
616
- lowerIfExists(sn.attributes.rel)
617
- )))) {
618
- return true;
619
- } else if (sn.tagName === "meta") {
620
- if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
621
- return true;
622
- } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
623
- lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
624
- return true;
625
- } else if (slimDOMOptions.headMetaRobots && ["robots", "googlebot", "bingbot"].includes(
626
- lowerIfExists(sn.attributes.name)
627
- )) {
628
- return true;
629
- } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
630
- return true;
631
- } else if (slimDOMOptions.headMetaAuthorship && (["author", "generator", "framework", "publisher", "progid"].includes(
632
- lowerIfExists(sn.attributes.name)
633
- ) || lowerIfExists(sn.attributes.property).match(/^article:/) || lowerIfExists(sn.attributes.property).match(/^product:/))) {
634
- return true;
635
- } else if (slimDOMOptions.headMetaVerification && [
636
- "google-site-verification",
637
- "yandex-verification",
638
- "csrf-token",
639
- "p:domain_verify",
640
- "verify-v1",
641
- "verification",
642
- "shopify-checkout-api-token"
643
- ].includes(lowerIfExists(sn.attributes.name))) {
644
- return true;
645
- }
646
- }
647
- }
648
- return false;
649
- }
650
- const DEFAULT_MAX_DEPTH = 50;
651
- let _maxDepthWarned = false;
652
- let _maxDepthReached = false;
653
- function wasMaxDepthReached() {
654
- return _maxDepthReached;
655
- }
656
- function resetMaxDepthState() {
657
- _maxDepthReached = false;
658
- _maxDepthWarned = false;
659
- }
660
- function serializeNodeWithId(n, options) {
661
- const {
662
- doc,
663
- mirror,
664
- blockClass,
665
- blockSelector,
666
- maskTextClass,
667
- maskTextSelector,
668
- skipChild = false,
669
- inlineStylesheet = true,
670
- maskInputOptions = {},
671
- maskTextFn,
672
- maskInputFn,
673
- slimDOMOptions,
674
- dataURLOptions = {},
675
- inlineImages = false,
676
- recordCanvas = false,
677
- onSerialize,
678
- onIframeLoad,
679
- iframeLoadTimeout = 5e3,
680
- onStylesheetLoad,
681
- stylesheetLoadTimeout = 5e3,
682
- keepIframeSrcFn = () => false,
683
- newlyAddedElement = false,
684
- depth = 0,
685
- maxDepth = DEFAULT_MAX_DEPTH
686
- } = options;
687
- let { needsMask } = options;
688
- let { preserveWhiteSpace = true } = options;
689
- if (depth >= maxDepth) {
690
- _maxDepthReached = true;
691
- if (!_maxDepthWarned) {
692
- _maxDepthWarned = true;
693
- console.warn(
694
- `[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.`
695
- );
696
- }
697
- return null;
698
- }
699
- if (!needsMask) {
700
- const checkAncestors = needsMask === void 0;
701
- needsMask = needMaskingText(
702
- n,
703
- maskTextClass,
704
- maskTextSelector,
705
- checkAncestors
706
- );
707
- }
708
- const _serializedNode = serializeNode(n, {
709
- doc,
710
- mirror,
711
- blockClass,
712
- blockSelector,
713
- needsMask,
714
- inlineStylesheet,
715
- maskInputOptions,
716
- maskTextFn,
717
- maskInputFn,
718
- dataURLOptions,
719
- inlineImages,
720
- recordCanvas,
721
- keepIframeSrcFn,
722
- newlyAddedElement
723
- });
724
- if (!_serializedNode) {
725
- console.warn(n, "not serialized");
726
- return null;
727
- }
728
- let id;
729
- if (mirror.hasNode(n)) {
730
- id = mirror.getId(n);
731
- } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType.Text && !_serializedNode.isStyle && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
732
- id = IGNORED_NODE;
733
- } else {
734
- id = genId();
735
- }
736
- const serializedNode = Object.assign(_serializedNode, { id });
737
- mirror.add(n, serializedNode);
738
- if (id === IGNORED_NODE) {
739
- return null;
740
- }
741
- if (onSerialize) {
742
- onSerialize(n);
743
- }
744
- let recordChild = !skipChild;
745
- if (serializedNode.type === NodeType.Element) {
746
- recordChild = recordChild && !serializedNode.needBlock;
747
- delete serializedNode.needBlock;
748
- const shadowRootEl = index.shadowRoot(n);
749
- if (shadowRootEl && isNativeShadowDom(shadowRootEl))
750
- serializedNode.isShadowHost = true;
751
- }
752
- if ((serializedNode.type === NodeType.Document || serializedNode.type === NodeType.Element) && recordChild) {
753
- if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType.Element && serializedNode.tagName === "head") {
754
- preserveWhiteSpace = false;
755
- }
756
- const bypassOptions = {
757
- doc,
758
- mirror,
759
- blockClass,
760
- blockSelector,
761
- needsMask,
762
- maskTextClass,
763
- maskTextSelector,
764
- skipChild,
765
- inlineStylesheet,
766
- maskInputOptions,
767
- maskTextFn,
768
- maskInputFn,
769
- slimDOMOptions,
770
- dataURLOptions,
771
- inlineImages,
772
- recordCanvas,
773
- preserveWhiteSpace,
774
- onSerialize,
775
- onIframeLoad,
776
- iframeLoadTimeout,
777
- onStylesheetLoad,
778
- stylesheetLoadTimeout,
779
- keepIframeSrcFn,
780
- depth: depth + 1,
781
- maxDepth
782
- };
783
- if (serializedNode.type === NodeType.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
784
- else {
785
- for (const childN of Array.from(index.childNodes(n))) {
786
- const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
787
- if (serializedChildNode) {
788
- serializedNode.childNodes.push(serializedChildNode);
789
- }
790
- }
791
- }
792
- let shadowRootEl = null;
793
- if (isElement(n) && (shadowRootEl = index.shadowRoot(n))) {
794
- for (const childN of Array.from(index.childNodes(shadowRootEl))) {
795
- const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
796
- if (serializedChildNode) {
797
- isNativeShadowDom(shadowRootEl) && (serializedChildNode.isShadow = true);
798
- serializedNode.childNodes.push(serializedChildNode);
799
- }
800
- }
801
- }
802
- }
803
- const parent = index.parentNode(n);
804
- if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
805
- serializedNode.isShadow = true;
806
- }
807
- if (serializedNode.type === NodeType.Element && serializedNode.tagName === "iframe") {
808
- onceIframeLoaded(
809
- n,
810
- () => {
811
- const iframeDoc = n.contentDocument;
812
- if (iframeDoc && onIframeLoad) {
813
- const serializedIframeNode = serializeNodeWithId(iframeDoc, {
814
- doc: iframeDoc,
815
- mirror,
816
- blockClass,
817
- blockSelector,
818
- needsMask,
819
- maskTextClass,
820
- maskTextSelector,
821
- skipChild: false,
822
- inlineStylesheet,
823
- maskInputOptions,
824
- maskTextFn,
825
- maskInputFn,
826
- slimDOMOptions,
827
- dataURLOptions,
828
- inlineImages,
829
- recordCanvas,
830
- preserveWhiteSpace,
831
- onSerialize,
832
- onIframeLoad,
833
- iframeLoadTimeout,
834
- onStylesheetLoad,
835
- stylesheetLoadTimeout,
836
- keepIframeSrcFn,
837
- depth: depth + 1,
838
- maxDepth
839
- });
840
- if (serializedIframeNode) {
841
- onIframeLoad(
842
- n,
843
- serializedIframeNode
844
- );
845
- }
846
- }
847
- },
848
- iframeLoadTimeout
849
- );
850
- }
851
- if (serializedNode.type === NodeType.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")) {
852
- onceStylesheetLoaded(
853
- n,
854
- () => {
855
- if (onStylesheetLoad) {
856
- const serializedLinkNode = serializeNodeWithId(n, {
857
- doc,
858
- mirror,
859
- blockClass,
860
- blockSelector,
861
- needsMask,
862
- maskTextClass,
863
- maskTextSelector,
864
- skipChild: false,
865
- inlineStylesheet,
866
- maskInputOptions,
867
- maskTextFn,
868
- maskInputFn,
869
- slimDOMOptions,
870
- dataURLOptions,
871
- inlineImages,
872
- recordCanvas,
873
- preserveWhiteSpace,
874
- onSerialize,
875
- onIframeLoad,
876
- iframeLoadTimeout,
877
- onStylesheetLoad,
878
- stylesheetLoadTimeout,
879
- keepIframeSrcFn,
880
- depth,
881
- maxDepth
882
- });
883
- if (serializedLinkNode) {
884
- onStylesheetLoad(
885
- n,
886
- serializedLinkNode
887
- );
888
- }
889
- }
890
- },
891
- stylesheetLoadTimeout
892
- );
893
- }
894
- return serializedNode;
895
- }
896
- function slimDOMDefaults(slimDOM) {
897
- if (slimDOM === true || slimDOM === "all") {
898
- return {
899
- script: true,
900
- comment: true,
901
- headFavicon: true,
902
- headWhitespace: true,
903
- headMetaSocial: true,
904
- headMetaRobots: true,
905
- headMetaHttpEquiv: true,
906
- headMetaVerification: true,
907
- headMetaAuthorship: slimDOM === "all",
908
- headMetaDescKeywords: slimDOM === "all",
909
- headTitleMutations: slimDOM === "all"
910
- };
911
- }
912
- if (slimDOM === false) {
913
- return {};
914
- }
915
- return slimDOM;
916
- }
917
- function snapshot(n, options) {
918
- const {
919
- mirror = new Mirror(),
920
- blockClass = "rr-block",
921
- blockSelector = null,
922
- maskTextClass = "rr-mask",
923
- maskTextSelector = null,
924
- inlineStylesheet = true,
925
- inlineImages = false,
926
- recordCanvas = false,
927
- maskAllInputs = false,
928
- maskTextFn,
929
- maskInputFn,
930
- slimDOM = false,
931
- dataURLOptions,
932
- preserveWhiteSpace,
933
- onSerialize,
934
- onIframeLoad,
935
- iframeLoadTimeout,
936
- onStylesheetLoad,
937
- stylesheetLoadTimeout,
938
- keepIframeSrcFn = () => false,
939
- maxDepth
940
- } = options || {};
941
- const maskInputOptions = maskAllInputs === true ? {
942
- color: true,
943
- date: true,
944
- "datetime-local": true,
945
- email: true,
946
- month: true,
947
- number: true,
948
- range: true,
949
- search: true,
950
- tel: true,
951
- text: true,
952
- time: true,
953
- url: true,
954
- week: true,
955
- textarea: true,
956
- select: true,
957
- password: true
958
- } : maskAllInputs === false ? {
959
- password: true
960
- } : maskAllInputs;
961
- const slimDOMOptions = slimDOMDefaults(slimDOM);
962
- return serializeNodeWithId(n, {
963
- doc: n,
964
- mirror,
965
- blockClass,
966
- blockSelector,
967
- maskTextClass,
968
- maskTextSelector,
969
- skipChild: false,
970
- inlineStylesheet,
971
- maskInputOptions,
972
- maskTextFn,
973
- maskInputFn,
974
- slimDOMOptions,
975
- dataURLOptions,
976
- inlineImages,
977
- recordCanvas,
978
- preserveWhiteSpace,
979
- onSerialize,
980
- onIframeLoad,
981
- iframeLoadTimeout,
982
- onStylesheetLoad,
983
- stylesheetLoadTimeout,
984
- keepIframeSrcFn,
985
- newlyAddedElement: false,
986
- maxDepth
987
- });
988
- }
989
- function visitSnapshot(node, onVisit) {
990
- function walk(current) {
991
- onVisit(current);
992
- if (current.type === NodeType.Document || current.type === NodeType.Element) {
993
- current.childNodes.forEach(walk);
994
- }
995
- }
996
- walk(node);
997
- }
998
- function cleanupSnapshot() {
999
- _id = 1;
1000
- }
1
+ import { D, I, b, c, g, i, n, a, s, t, v, w } from "./record-BhFABPFv.js";
2
+ import { M, N, o, p, h, e, n as n2, f, l, j, d, g as g2, i as i2, b as b2, k, a as a2, m, r, c as c2, s as s2, t as t2 } from "./types-D1TQIdgp.js";
1001
3
  export {
1002
- DEFAULT_MAX_DEPTH,
1003
- IGNORED_NODE,
1004
- Mirror,
4
+ D as DEFAULT_MAX_DEPTH,
5
+ I as IGNORED_NODE,
6
+ M as Mirror,
1005
7
  N as NodeType,
1006
- absolutifyURLs,
1007
- checkDataURLSize,
1008
- classMatchesRegex,
1009
- cleanupSnapshot,
8
+ o as absolutifyURLs,
9
+ p as checkDataURLSize,
10
+ b as classMatchesRegex,
11
+ c as cleanupSnapshot,
1010
12
  h as createMirror,
1011
13
  e as escapeImportStatement,
1012
- extractFileExtension,
14
+ n2 as extractFileExtension,
1013
15
  f as fixSafariColons,
1014
- genId,
1015
- getInputType,
1016
- ignoreAttribute,
1017
- is2DCanvasBlank,
16
+ g as genId,
17
+ l as getInputType,
18
+ i as ignoreAttribute,
19
+ j as is2DCanvasBlank,
1018
20
  d as isCSSImportRule,
1019
- g as isCSSStyleRule,
1020
- isElement,
1021
- isNativeShadowDom,
21
+ g2 as isCSSStyleRule,
22
+ i2 as isElement,
23
+ b2 as isNativeShadowDom,
1022
24
  k as isNodeMetaEqual,
1023
- isShadowRoot,
1024
- maskInputValue,
1025
- needMaskingText,
1026
- recompressBase64Image,
1027
- resetMaxDepthState,
1028
- serializeNodeWithId,
1029
- slimDOMDefaults,
1030
- snapshot,
1031
- c as stringifyRule,
1032
- stringifyStylesheet,
1033
- toLowerCase,
1034
- transformAttribute,
1035
- visitSnapshot,
1036
- wasMaxDepthReached
25
+ a2 as isShadowRoot,
26
+ m as maskInputValue,
27
+ n as needMaskingText,
28
+ r as recompressBase64Image,
29
+ a as serializeNodeWithId,
30
+ s as snapshot,
31
+ c2 as stringifyRule,
32
+ s2 as stringifyStylesheet,
33
+ t2 as toLowerCase,
34
+ t as transformAttribute,
35
+ v as visitSnapshot,
36
+ w as wasMaxDepthReached
1037
37
  };
1038
38
  //# sourceMappingURL=record.js.map