@appsurify-testmap/rrweb 2.0.0-alpha.41 → 2.1.0-alpha.1

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/dist/rrweb.cjs CHANGED
@@ -144,6 +144,32 @@ function querySelectorAll$1(n2, selectors) {
144
144
  function mutationObserverCtor$1() {
145
145
  return getUntaintedPrototype$1("MutationObserver").constructor;
146
146
  }
147
+ function patch$1(source, name, replacement) {
148
+ try {
149
+ if (!(name in source)) {
150
+ return () => {
151
+ };
152
+ }
153
+ const original = source[name];
154
+ const wrapped = replacement(original);
155
+ if (typeof wrapped === "function") {
156
+ wrapped.prototype = wrapped.prototype || {};
157
+ Object.defineProperties(wrapped, {
158
+ __rrweb_original__: {
159
+ enumerable: false,
160
+ value: original
161
+ }
162
+ });
163
+ }
164
+ source[name] = wrapped;
165
+ return () => {
166
+ source[name] = original;
167
+ };
168
+ } catch {
169
+ return () => {
170
+ };
171
+ }
172
+ }
147
173
  const index$1 = {
148
174
  childNodes: childNodes$1,
149
175
  parentNode: parentNode$1,
@@ -156,8 +182,12 @@ const index$1 = {
156
182
  shadowRoot: shadowRoot$1,
157
183
  querySelector: querySelector$1,
158
184
  querySelectorAll: querySelectorAll$1,
159
- mutationObserver: mutationObserverCtor$1
185
+ mutationObserver: mutationObserverCtor$1,
186
+ patch: patch$1
160
187
  };
188
+ function isElement(n2) {
189
+ return n2.nodeType === n2.ELEMENT_NODE;
190
+ }
161
191
  function isShadowRoot(n2) {
162
192
  const hostEl = (
163
193
  // anchor and textarea elements also have a `host` property
@@ -434,19 +464,27 @@ function absolutifyURLs(cssText, href) {
434
464
  }
435
465
  );
436
466
  }
437
- function normalizeCssString(cssText) {
438
- return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
467
+ function normalizeCssString(cssText, _testNoPxNorm = false) {
468
+ if (_testNoPxNorm) {
469
+ return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
470
+ } else {
471
+ return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "").replace(/0px/g, "0");
472
+ }
439
473
  }
440
- function splitCssText(cssText, style) {
474
+ function splitCssText(cssText, style, _testNoPxNorm = false) {
441
475
  const childNodes2 = Array.from(style.childNodes);
442
476
  const splits = [];
443
- let iterLimit = 0;
477
+ let iterCount = 0;
444
478
  if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
445
- let cssTextNorm = normalizeCssString(cssText);
479
+ let cssTextNorm = normalizeCssString(cssText, _testNoPxNorm);
446
480
  const normFactor = cssTextNorm.length / cssText.length;
447
481
  for (let i2 = 1; i2 < childNodes2.length; i2++) {
448
482
  if (childNodes2[i2].textContent && typeof childNodes2[i2].textContent === "string") {
449
- const textContentNorm = normalizeCssString(childNodes2[i2].textContent);
483
+ const textContentNorm = normalizeCssString(
484
+ childNodes2[i2].textContent,
485
+ _testNoPxNorm
486
+ );
487
+ const jLimit = 100;
450
488
  let j = 3;
451
489
  for (; j < textContentNorm.length; j++) {
452
490
  if (
@@ -459,23 +497,49 @@ function splitCssText(cssText, style) {
459
497
  break;
460
498
  }
461
499
  for (; j < textContentNorm.length; j++) {
462
- const bit = textContentNorm.substring(0, j);
463
- const bits = cssTextNorm.split(bit);
500
+ let startSubstring = textContentNorm.substring(0, j);
501
+ let cssNormSplits = cssTextNorm.split(startSubstring);
464
502
  let splitNorm = -1;
465
- if (bits.length === 2) {
466
- splitNorm = cssTextNorm.indexOf(bit);
467
- } else if (bits.length > 2 && bits[0] === "" && childNodes2[i2 - 1].textContent !== "") {
468
- splitNorm = cssTextNorm.indexOf(bit, 1);
503
+ if (cssNormSplits.length === 2) {
504
+ splitNorm = cssNormSplits[0].length;
505
+ } else if (cssNormSplits.length > 2 && cssNormSplits[0] === "" && childNodes2[i2 - 1].textContent !== "") {
506
+ splitNorm = cssTextNorm.indexOf(startSubstring, 1);
507
+ } else if (cssNormSplits.length === 1) {
508
+ startSubstring = startSubstring.substring(
509
+ 0,
510
+ startSubstring.length - 1
511
+ );
512
+ cssNormSplits = cssTextNorm.split(startSubstring);
513
+ if (cssNormSplits.length <= 1) {
514
+ splits.push(cssText);
515
+ return splits;
516
+ }
517
+ j = jLimit + 1;
518
+ } else if (j === textContentNorm.length - 1) {
519
+ splitNorm = cssTextNorm.indexOf(startSubstring);
520
+ }
521
+ if (cssNormSplits.length >= 2 && j > jLimit) {
522
+ const prevTextContent = childNodes2[i2 - 1].textContent;
523
+ if (prevTextContent && typeof prevTextContent === "string") {
524
+ const prevMinLength = normalizeCssString(prevTextContent).length;
525
+ splitNorm = cssTextNorm.indexOf(startSubstring, prevMinLength);
526
+ }
527
+ if (splitNorm === -1) {
528
+ splitNorm = cssNormSplits[0].length;
529
+ }
469
530
  }
470
531
  if (splitNorm !== -1) {
471
532
  let k = Math.floor(splitNorm / normFactor);
472
533
  for (; k > 0 && k < cssText.length; ) {
473
- iterLimit += 1;
474
- if (iterLimit > 50 * childNodes2.length) {
534
+ iterCount += 1;
535
+ if (iterCount > 50 * childNodes2.length) {
475
536
  splits.push(cssText);
476
537
  return splits;
477
538
  }
478
- const normPart = normalizeCssString(cssText.substring(0, k));
539
+ const normPart = normalizeCssString(
540
+ cssText.substring(0, k),
541
+ _testNoPxNorm
542
+ );
479
543
  if (normPart.length === splitNorm) {
480
544
  splits.push(cssText.substring(0, k));
481
545
  cssText = cssText.substring(k);
@@ -571,9 +635,6 @@ function getXPath(node2) {
571
635
  }
572
636
  return "";
573
637
  }
574
- function isElement(n2) {
575
- return n2.nodeType === n2.ELEMENT_NODE;
576
- }
577
638
  function isTextVisible(n2) {
578
639
  var _a2;
579
640
  const parent = index$1.parentNode(n2);
@@ -594,10 +655,10 @@ function isElementVisible(n2) {
594
655
  const style = win ? win.getComputedStyle(n2) : null;
595
656
  const isStyleVisible = style != null && style.display !== "none" && style.visibility !== "hidden" && parseFloat(style.opacity) !== 0;
596
657
  const rect = n2.getBoundingClientRect();
597
- const result2 = isStyleVisible && isRectVisible(rect, win);
658
+ const result2 = isStyleVisible && isRectVisible(rect);
598
659
  return result2;
599
660
  }
600
- function isRectVisible(rect, win) {
661
+ function isRectVisible(rect, win = window) {
601
662
  var _a2, _b, _c, _d;
602
663
  const height = (win == null ? void 0 : win.innerHeight) ?? ((_b = (_a2 = win == null ? void 0 : win.document) == null ? void 0 : _a2.documentElement) == null ? void 0 : _b.clientHeight) ?? 0;
603
664
  const width = (win == null ? void 0 : win.innerWidth) ?? ((_d = (_c = win == null ? void 0 : win.document) == null ? void 0 : _c.documentElement) == null ? void 0 : _d.clientWidth) ?? 0;
@@ -641,7 +702,7 @@ const interactiveTags = [
641
702
  "video",
642
703
  "audio"
643
704
  ];
644
- const inlineEventAttributes = [
705
+ const inlineEventAttributes$1 = [
645
706
  "onclick",
646
707
  "ondblclick",
647
708
  "onmousedown",
@@ -666,27 +727,20 @@ const inlineEventAttributes = [
666
727
  "ontouchcancel"
667
728
  ];
668
729
  const interactiveElementsRegistry$1 = /* @__PURE__ */ new WeakSet();
669
- if (typeof Element !== "undefined" && typeof EventTarget !== "undefined") {
670
- const originalAddEventListener = EventTarget.prototype.addEventListener;
671
- EventTarget.prototype.addEventListener = function(type, listener, options) {
672
- originalAddEventListener.call(this, type, listener, options);
673
- if (this instanceof Element) {
674
- const eventType = type.toLowerCase();
675
- if (interactiveEvents$1.includes(eventType)) {
676
- interactiveElementsRegistry$1.add(this);
677
- }
730
+ const originalAddEventListener$1 = EventTarget.prototype.addEventListener;
731
+ EventTarget.prototype.addEventListener = function(type, listener, options) {
732
+ originalAddEventListener$1.call(this, type, listener, options);
733
+ if (this instanceof Element) {
734
+ const eventType = type.toLowerCase();
735
+ if (interactiveEvents$1.includes(eventType)) {
736
+ interactiveElementsRegistry$1.add(this);
678
737
  }
679
- };
680
- }
681
- if (typeof Element !== "undefined" && typeof EventTarget !== "undefined") {
682
- const originalRemoveEventListener = EventTarget.prototype.removeEventListener;
683
- EventTarget.prototype.removeEventListener = function(type, listener, options) {
684
- originalRemoveEventListener.call(this, type, listener, options);
685
- if (this instanceof Element) {
686
- type.toLowerCase();
687
- }
688
- };
689
- }
738
+ }
739
+ };
740
+ const originalRemoveEventListener$1 = EventTarget.prototype.removeEventListener;
741
+ EventTarget.prototype.removeEventListener = function(type, listener, options) {
742
+ originalRemoveEventListener$1.call(this, type, listener, options);
743
+ };
690
744
  function hasEventListeners(n2) {
691
745
  return n2 instanceof Element && interactiveElementsRegistry$1.has(n2);
692
746
  }
@@ -706,33 +760,20 @@ function isElementInteractive(n2) {
706
760
  }
707
761
  return false;
708
762
  }
709
- function inspectInlineEventHandlers(doc) {
710
- if (!doc || typeof doc.querySelectorAll !== "function") return;
711
- const allElements = doc.querySelectorAll("*");
763
+ function inspectInlineEventHandlers$1() {
764
+ const allElements = document.querySelectorAll("*");
712
765
  allElements.forEach((el) => {
713
- inlineEventAttributes.forEach((attr) => {
766
+ inlineEventAttributes$1.forEach((attr) => {
714
767
  if (el.hasAttribute(attr)) {
715
768
  interactiveElementsRegistry$1.add(el);
716
769
  }
717
770
  });
718
771
  });
719
772
  }
720
- function scheduleInlineEventInspection(doc) {
721
- if (!doc || typeof doc.addEventListener !== "function" || typeof doc.querySelectorAll !== "function") {
722
- return;
723
- }
724
- try {
725
- if (doc.readyState === "complete" || doc.readyState === "interactive") {
726
- inspectInlineEventHandlers(doc);
727
- } else {
728
- doc.addEventListener("DOMContentLoaded", () => inspectInlineEventHandlers(doc), {
729
- once: true,
730
- capture: false
731
- });
732
- }
733
- } catch (e2) {
734
- console.warn("[inlineEventInspection] Failed to inspect document:", e2);
735
- }
773
+ if (document.readyState === "complete" || document.readyState === "interactive") {
774
+ inspectInlineEventHandlers$1();
775
+ } else {
776
+ document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers$1);
736
777
  }
737
778
  let _id = 1;
738
779
  const tagNameRegex = new RegExp("[^a-z0-9-_:]");
@@ -1026,6 +1067,7 @@ function serializeNode(n2, options) {
1026
1067
  childNodes: [],
1027
1068
  xPath,
1028
1069
  compatMode: n2.compatMode
1070
+ // probably "BackCompat"
1029
1071
  };
1030
1072
  } else {
1031
1073
  return {
@@ -1320,7 +1362,7 @@ function slimDOMExcluded(sn, slimDOMOptions) {
1320
1362
  } else if (sn.type === NodeType$3.Element) {
1321
1363
  if (slimDOMOptions.script && // script tag
1322
1364
  (sn.tagName === "script" || // (module)preload link
1323
- sn.tagName === "link" && (sn.attributes.rel === "preload" || sn.attributes.rel === "modulepreload") && sn.attributes.as === "script" || // prefetch link
1365
+ sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
1324
1366
  sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && extractFileExtension(sn.attributes.href) === "js")) {
1325
1367
  return true;
1326
1368
  } else if (slimDOMOptions.headFavicon && (sn.tagName === "link" && sn.attributes.rel === "shortcut icon" || sn.tagName === "meta" && (lowerIfExists(sn.attributes.name).match(
@@ -1582,7 +1624,7 @@ function snapshot(n2, options) {
1582
1624
  blockSelector = null,
1583
1625
  maskTextClass = "rr-mask",
1584
1626
  maskTextSelector = null,
1585
- ignoreAttribute = "rr-ignore-attr",
1627
+ ignoreAttribute = "rr-ignore",
1586
1628
  inlineStylesheet = true,
1587
1629
  inlineImages = false,
1588
1630
  recordCanvas = false,
@@ -1599,7 +1641,7 @@ function snapshot(n2, options) {
1599
1641
  stylesheetLoadTimeout,
1600
1642
  keepIframeSrcFn = () => false
1601
1643
  } = options || {};
1602
- scheduleInlineEventInspection(n2);
1644
+ console.debug(`${Date.now()} [rrweb-snapshot] snapshot:options:`, options);
1603
1645
  const maskInputOptions = maskAllInputs === true ? {
1604
1646
  color: true,
1605
1647
  date: true,
@@ -5296,11 +5338,16 @@ function getTagName(n2) {
5296
5338
  function adaptCssForReplay(cssText, cache) {
5297
5339
  const cachedStyle = cache == null ? void 0 : cache.stylesWithHoverClass.get(cssText);
5298
5340
  if (cachedStyle) return cachedStyle;
5299
- const ast = postcss$1$1([
5300
- mediaSelectorPlugin,
5301
- pseudoClassPlugin
5302
- ]).process(cssText);
5303
- const result2 = ast.css;
5341
+ let result2 = cssText;
5342
+ try {
5343
+ const ast = postcss$1$1([
5344
+ mediaSelectorPlugin,
5345
+ pseudoClassPlugin
5346
+ ]).process(cssText);
5347
+ result2 = ast.css;
5348
+ } catch (error) {
5349
+ console.warn("Failed to adapt css for replay", error);
5350
+ }
5304
5351
  cache == null ? void 0 : cache.stylesWithHoverClass.set(cssText, result2);
5305
5352
  return result2;
5306
5353
  }
@@ -5321,11 +5368,39 @@ function applyCssSplits(n2, cssText, hackCss, cache) {
5321
5368
  while (cssTextSplits.length > 1 && cssTextSplits.length > childTextNodes.length) {
5322
5369
  cssTextSplits.splice(-2, 2, cssTextSplits.slice(-2).join(""));
5323
5370
  }
5371
+ let adaptedCss = "";
5372
+ if (hackCss) {
5373
+ adaptedCss = adaptCssForReplay(cssTextSplits.join(""), cache);
5374
+ }
5375
+ let startIndex = 0;
5324
5376
  for (let i2 = 0; i2 < childTextNodes.length; i2++) {
5377
+ if (i2 === cssTextSplits.length) {
5378
+ break;
5379
+ }
5325
5380
  const childTextNode = childTextNodes[i2];
5326
- const cssTextSection = cssTextSplits[i2];
5327
- if (childTextNode && cssTextSection) {
5328
- childTextNode.textContent = hackCss ? adaptCssForReplay(cssTextSection, cache) : cssTextSection;
5381
+ if (!hackCss) {
5382
+ childTextNode.textContent = cssTextSplits[i2];
5383
+ } else if (i2 < cssTextSplits.length - 1) {
5384
+ let endIndex = startIndex;
5385
+ let endSearch = cssTextSplits[i2 + 1].length;
5386
+ endSearch = Math.min(endSearch, 30);
5387
+ let found = false;
5388
+ for (; endSearch > 2; endSearch--) {
5389
+ const searchBit = cssTextSplits[i2 + 1].substring(0, endSearch);
5390
+ const searchIndex = adaptedCss.substring(startIndex).indexOf(searchBit);
5391
+ found = searchIndex !== -1;
5392
+ if (found) {
5393
+ endIndex += searchIndex;
5394
+ break;
5395
+ }
5396
+ }
5397
+ if (!found) {
5398
+ endIndex += cssTextSplits[i2].length;
5399
+ }
5400
+ childTextNode.textContent = adaptedCss.substring(startIndex, endIndex);
5401
+ startIndex = endIndex;
5402
+ } else {
5403
+ childTextNode.textContent = adaptedCss.substring(startIndex);
5329
5404
  }
5330
5405
  }
5331
5406
  }
@@ -5409,8 +5484,8 @@ function buildNode(n2, options) {
5409
5484
  } else if (tagName === "meta" && n2.attributes["http-equiv"] === "Content-Security-Policy" && name === "content") {
5410
5485
  node2.setAttribute("csp-content", value.toString());
5411
5486
  continue;
5412
- } else if (tagName === "link" && (n2.attributes.rel === "preload" || n2.attributes.rel === "modulepreload") && n2.attributes.as === "script") {
5413
- } else if (tagName === "link" && n2.attributes.rel === "prefetch" && typeof n2.attributes.href === "string" && n2.attributes.href.endsWith(".js")) {
5487
+ } else if (tagName === "link" && (n2.attributes.rel === "preload" && n2.attributes.as === "script" || n2.attributes.rel === "modulepreload")) {
5488
+ } else if (tagName === "link" && n2.attributes.rel === "prefetch" && typeof n2.attributes.href === "string" && extractFileExtension(n2.attributes.href) === "js") {
5414
5489
  } else if (tagName === "img" && n2.attributes.srcset && n2.attributes.rr_dataURL) {
5415
5490
  node2.setAttribute(
5416
5491
  "rrweb-original-srcset",
@@ -5719,27 +5794,59 @@ const interactiveEvents = [
5719
5794
  "touchend",
5720
5795
  "touchcancel"
5721
5796
  ];
5797
+ const inlineEventAttributes = [
5798
+ "onclick",
5799
+ "ondblclick",
5800
+ "onmousedown",
5801
+ "onmouseup",
5802
+ "onmouseover",
5803
+ "onmouseout",
5804
+ "onmousemove",
5805
+ "onfocus",
5806
+ "onblur",
5807
+ "onkeydown",
5808
+ "onkeypress",
5809
+ "onkeyup",
5810
+ "onchange",
5811
+ "oninput",
5812
+ "onsubmit",
5813
+ "onreset",
5814
+ "onselect",
5815
+ "oncontextmenu",
5816
+ "ontouchstart",
5817
+ "ontouchmove",
5818
+ "ontouchend",
5819
+ "ontouchcancel"
5820
+ ];
5722
5821
  const interactiveElementsRegistry = /* @__PURE__ */ new WeakSet();
5723
- if (typeof Element !== "undefined" && typeof EventTarget !== "undefined") {
5724
- const originalAddEventListener = EventTarget.prototype.addEventListener;
5725
- EventTarget.prototype.addEventListener = function(type, listener, options) {
5726
- originalAddEventListener.call(this, type, listener, options);
5727
- if (this instanceof Element) {
5728
- const eventType = type.toLowerCase();
5729
- if (interactiveEvents.includes(eventType)) {
5730
- interactiveElementsRegistry.add(this);
5731
- }
5822
+ const originalAddEventListener = EventTarget.prototype.addEventListener;
5823
+ EventTarget.prototype.addEventListener = function(type, listener, options) {
5824
+ originalAddEventListener.call(this, type, listener, options);
5825
+ if (this instanceof Element) {
5826
+ const eventType = type.toLowerCase();
5827
+ if (interactiveEvents.includes(eventType)) {
5828
+ interactiveElementsRegistry.add(this);
5732
5829
  }
5733
- };
5830
+ }
5831
+ };
5832
+ const originalRemoveEventListener = EventTarget.prototype.removeEventListener;
5833
+ EventTarget.prototype.removeEventListener = function(type, listener, options) {
5834
+ originalRemoveEventListener.call(this, type, listener, options);
5835
+ };
5836
+ function inspectInlineEventHandlers() {
5837
+ const allElements = document.querySelectorAll("*");
5838
+ allElements.forEach((el) => {
5839
+ inlineEventAttributes.forEach((attr) => {
5840
+ if (el.hasAttribute(attr)) {
5841
+ interactiveElementsRegistry.add(el);
5842
+ }
5843
+ });
5844
+ });
5734
5845
  }
5735
- if (typeof Element !== "undefined" && typeof EventTarget !== "undefined") {
5736
- const originalRemoveEventListener = EventTarget.prototype.removeEventListener;
5737
- EventTarget.prototype.removeEventListener = function(type, listener, options) {
5738
- originalRemoveEventListener.call(this, type, listener, options);
5739
- if (this instanceof Element) {
5740
- type.toLowerCase();
5741
- }
5742
- };
5846
+ if (document.readyState === "complete" || document.readyState === "interactive") {
5847
+ inspectInlineEventHandlers();
5848
+ } else {
5849
+ document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers);
5743
5850
  }
5744
5851
  function getDefaultExportFromCjs(x2) {
5745
5852
  return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
@@ -10691,6 +10798,32 @@ function querySelectorAll(n2, selectors) {
10691
10798
  function mutationObserverCtor() {
10692
10799
  return getUntaintedPrototype("MutationObserver").constructor;
10693
10800
  }
10801
+ function patch(source, name, replacement) {
10802
+ try {
10803
+ if (!(name in source)) {
10804
+ return () => {
10805
+ };
10806
+ }
10807
+ const original = source[name];
10808
+ const wrapped = replacement(original);
10809
+ if (typeof wrapped === "function") {
10810
+ wrapped.prototype = wrapped.prototype || {};
10811
+ Object.defineProperties(wrapped, {
10812
+ __rrweb_original__: {
10813
+ enumerable: false,
10814
+ value: original
10815
+ }
10816
+ });
10817
+ }
10818
+ source[name] = wrapped;
10819
+ return () => {
10820
+ source[name] = original;
10821
+ };
10822
+ } catch {
10823
+ return () => {
10824
+ };
10825
+ }
10826
+ }
10694
10827
  const index = {
10695
10828
  childNodes,
10696
10829
  parentNode,
@@ -10703,7 +10836,8 @@ const index = {
10703
10836
  shadowRoot,
10704
10837
  querySelector,
10705
10838
  querySelectorAll,
10706
- mutationObserver: mutationObserverCtor
10839
+ mutationObserver: mutationObserverCtor,
10840
+ patch
10707
10841
  };
10708
10842
  function on(type, fn, target = document) {
10709
10843
  const options = { capture: true, passive: true };
@@ -10786,32 +10920,6 @@ function hookSetter(target, key, d, isRevoked, win = window) {
10786
10920
  );
10787
10921
  return () => hookSetter(target, key, original || {}, true);
10788
10922
  }
10789
- function patch(source, name, replacement) {
10790
- try {
10791
- if (!(name in source)) {
10792
- return () => {
10793
- };
10794
- }
10795
- const original = source[name];
10796
- const wrapped = replacement(original);
10797
- if (typeof wrapped === "function") {
10798
- wrapped.prototype = wrapped.prototype || {};
10799
- Object.defineProperties(wrapped, {
10800
- __rrweb_original__: {
10801
- enumerable: false,
10802
- value: original
10803
- }
10804
- });
10805
- }
10806
- source[name] = wrapped;
10807
- return () => {
10808
- source[name] = original;
10809
- };
10810
- } catch {
10811
- return () => {
10812
- };
10813
- }
10814
- }
10815
10923
  let nowTimestamp = Date.now;
10816
10924
  if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
10817
10925
  nowTimestamp = () => (/* @__PURE__ */ new Date()).getTime();
@@ -11099,7 +11207,6 @@ const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
11099
11207
  return nowTimestamp;
11100
11208
  },
11101
11209
  on,
11102
- patch,
11103
11210
  polyfill: polyfill$1,
11104
11211
  queueToResolveTrees,
11105
11212
  shadowHostInDom,
@@ -11141,13 +11248,14 @@ var MouseInteractions = /* @__PURE__ */ ((MouseInteractions2) => {
11141
11248
  MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
11142
11249
  MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
11143
11250
  MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
11144
- MouseInteractions2[MouseInteractions2["DblClick"] = 3] = "DblClick";
11145
- MouseInteractions2[MouseInteractions2["Focus"] = 4] = "Focus";
11146
- MouseInteractions2[MouseInteractions2["Blur"] = 5] = "Blur";
11147
- MouseInteractions2[MouseInteractions2["TouchStart"] = 6] = "TouchStart";
11148
- MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 7] = "TouchMove_Departed";
11149
- MouseInteractions2[MouseInteractions2["TouchEnd"] = 8] = "TouchEnd";
11150
- MouseInteractions2[MouseInteractions2["TouchCancel"] = 9] = "TouchCancel";
11251
+ MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
11252
+ MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
11253
+ MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
11254
+ MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
11255
+ MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
11256
+ MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
11257
+ MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
11258
+ MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
11151
11259
  return MouseInteractions2;
11152
11260
  })(MouseInteractions || {});
11153
11261
  var PointerTypes = /* @__PURE__ */ ((PointerTypes2) => {
@@ -11544,10 +11652,18 @@ class MutationBuffer {
11544
11652
  this.attributes.push(item);
11545
11653
  this.attributeMap.set(textarea, item);
11546
11654
  }
11547
- item.attributes.value = Array.from(
11655
+ const value = Array.from(
11548
11656
  index.childNodes(textarea),
11549
11657
  (cn) => index.textContent(cn) || ""
11550
11658
  ).join("");
11659
+ item.attributes.value = maskInputValue({
11660
+ element: textarea,
11661
+ maskInputOptions: this.maskInputOptions,
11662
+ tagName: textarea.tagName,
11663
+ type: getInputType(textarea),
11664
+ value,
11665
+ maskInputFn: this.maskInputFn
11666
+ });
11551
11667
  });
11552
11668
  __publicField(this, "processMutation", (m) => {
11553
11669
  if (isIgnored(m.target, this.mirror, this.slimDOMOptions)) {
@@ -13971,7 +14087,6 @@ try {
13971
14087
  }
13972
14088
  const mirror = createMirror$2();
13973
14089
  function record(options = {}) {
13974
- var _a2;
13975
14090
  const {
13976
14091
  emit,
13977
14092
  checkoutEveryNms,
@@ -13981,7 +14096,7 @@ function record(options = {}) {
13981
14096
  blockSelector = null,
13982
14097
  ignoreClass = "rr-ignore",
13983
14098
  ignoreSelector = null,
13984
- ignoreAttribute = "rr-ignore-attribute",
14099
+ ignoreAttribute = "rr-ignore",
13985
14100
  maskTextClass = "rr-mask",
13986
14101
  maskTextSelector = null,
13987
14102
  inlineStylesheet = true,
@@ -14007,24 +14122,13 @@ function record(options = {}) {
14007
14122
  ignoreCSSAttributes = /* @__PURE__ */ new Set([]),
14008
14123
  errorHandler: errorHandler2
14009
14124
  } = options;
14010
- const win = options.customWindow || window;
14011
- const doc = options.customDocument || document;
14012
- try {
14013
- if (Array.from([1], (x2) => x2 * 2)[0] !== 2) {
14014
- const cleanFrame = doc.createElement("iframe");
14015
- doc.body.appendChild(cleanFrame);
14016
- Array.from = ((_a2 = cleanFrame.contentWindow) == null ? void 0 : _a2.Array.from) || Array.from;
14017
- doc.body.removeChild(cleanFrame);
14018
- }
14019
- } catch (err) {
14020
- console.debug("Unable to override Array.from", err);
14021
- }
14125
+ console.debug(`${Date.now()} [rrweb] record:options:`, options);
14022
14126
  registerErrorHandler(errorHandler2);
14023
- const inEmittingFrame = recordCrossOriginIframes ? win.parent === win : true;
14127
+ const inEmittingFrame = recordCrossOriginIframes ? window.parent === window : true;
14024
14128
  let passEmitsToParent = false;
14025
14129
  if (!inEmittingFrame) {
14026
14130
  try {
14027
- if (win.parent.document) {
14131
+ if (window.parent.document) {
14028
14132
  passEmitsToParent = false;
14029
14133
  }
14030
14134
  } catch (e2) {
@@ -14091,10 +14195,10 @@ function record(options = {}) {
14091
14195
  return e2;
14092
14196
  };
14093
14197
  wrappedEmit = (r2, isCheckout) => {
14094
- var _a3;
14198
+ var _a2;
14095
14199
  const e2 = r2;
14096
14200
  e2.timestamp = nowTimestamp();
14097
- if (((_a3 = mutationBuffers[0]) == null ? void 0 : _a3.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
14201
+ if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
14098
14202
  mutationBuffers.forEach((buf) => buf.unfreeze());
14099
14203
  }
14100
14204
  if (inEmittingFrame) {
@@ -14103,10 +14207,10 @@ function record(options = {}) {
14103
14207
  const message = {
14104
14208
  type: "rrweb",
14105
14209
  event: eventProcessor(e2),
14106
- origin: win.location.origin,
14210
+ origin: window.location.origin,
14107
14211
  isCheckout
14108
14212
  };
14109
- win.parent.postMessage(message, "*");
14213
+ window.parent.postMessage(message, "*");
14110
14214
  }
14111
14215
  if (e2.type === EventType.FullSnapshot) {
14112
14216
  lastFullSnapshotEvent = e2;
@@ -14177,7 +14281,7 @@ function record(options = {}) {
14177
14281
  canvasManager = new CanvasManager({
14178
14282
  recordCanvas,
14179
14283
  mutationCb: wrappedCanvasMutationEmit,
14180
- win,
14284
+ win: window,
14181
14285
  blockClass,
14182
14286
  blockSelector,
14183
14287
  mirror,
@@ -14218,9 +14322,9 @@ function record(options = {}) {
14218
14322
  {
14219
14323
  type: EventType.Meta,
14220
14324
  data: {
14221
- href: win.location.href,
14222
- width: getWindowWidth(win),
14223
- height: getWindowHeight(win)
14325
+ href: window.location.href,
14326
+ width: getWindowWidth(),
14327
+ height: getWindowHeight()
14224
14328
  }
14225
14329
  },
14226
14330
  isCheckout
@@ -14228,12 +14332,13 @@ function record(options = {}) {
14228
14332
  stylesheetManager.reset();
14229
14333
  shadowDomManager.init();
14230
14334
  mutationBuffers.forEach((buf) => buf.lock());
14231
- const node2 = snapshot(doc, {
14335
+ const node2 = snapshot(document, {
14232
14336
  mirror,
14233
14337
  blockClass,
14234
14338
  blockSelector,
14235
14339
  maskTextClass,
14236
14340
  maskTextSelector,
14341
+ ignoreAttribute,
14237
14342
  inlineStylesheet,
14238
14343
  maskAllInputs: maskInputOptions,
14239
14344
  maskTextFn,
@@ -14250,7 +14355,7 @@ function record(options = {}) {
14250
14355
  stylesheetManager.trackLinkElement(n2);
14251
14356
  }
14252
14357
  if (hasShadowRoot(n2)) {
14253
- shadowDomManager.addShadowRoot(index.shadowRoot(n2), doc);
14358
+ shadowDomManager.addShadowRoot(index.shadowRoot(n2), document);
14254
14359
  }
14255
14360
  },
14256
14361
  onIframeLoad: (iframe, childSn) => {
@@ -14270,22 +14375,22 @@ function record(options = {}) {
14270
14375
  type: EventType.FullSnapshot,
14271
14376
  data: {
14272
14377
  node: node2,
14273
- initialOffset: getWindowScroll(win)
14378
+ initialOffset: getWindowScroll(window)
14274
14379
  }
14275
14380
  },
14276
14381
  isCheckout
14277
14382
  );
14278
14383
  mutationBuffers.forEach((buf) => buf.unlock());
14279
- if (doc.adoptedStyleSheets && doc.adoptedStyleSheets.length > 0)
14384
+ if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0)
14280
14385
  stylesheetManager.adoptStyleSheets(
14281
- doc.adoptedStyleSheets,
14282
- mirror.getId(doc)
14386
+ document.adoptedStyleSheets,
14387
+ mirror.getId(document)
14283
14388
  );
14284
14389
  };
14285
14390
  try {
14286
14391
  const handlers = [];
14287
- const observe = (doc2) => {
14288
- var _a3;
14392
+ const observe = (doc) => {
14393
+ var _a2;
14289
14394
  return callbackWrapper(initObservers)(
14290
14395
  {
14291
14396
  mutationCb: wrappedMutationEmit,
@@ -14388,7 +14493,7 @@ function record(options = {}) {
14388
14493
  inlineImages,
14389
14494
  userTriggeredOnInput,
14390
14495
  collectFonts,
14391
- doc: doc2,
14496
+ doc,
14392
14497
  maskInputFn,
14393
14498
  maskTextFn,
14394
14499
  keepIframeSrcFn,
@@ -14402,7 +14507,7 @@ function record(options = {}) {
14402
14507
  processedNodeManager,
14403
14508
  canvasManager,
14404
14509
  ignoreCSSAttributes,
14405
- plugins: ((_a3 = plugins == null ? void 0 : plugins.filter((p) => p.observer)) == null ? void 0 : _a3.map((p) => ({
14510
+ plugins: ((_a2 = plugins == null ? void 0 : plugins.filter((p) => p.observer)) == null ? void 0 : _a2.map((p) => ({
14406
14511
  observer: p.observer,
14407
14512
  options: p.options,
14408
14513
  callback: (payload) => wrappedEmit({
@@ -14426,10 +14531,10 @@ function record(options = {}) {
14426
14531
  });
14427
14532
  const init = () => {
14428
14533
  takeFullSnapshot$1();
14429
- handlers.push(observe(doc));
14534
+ handlers.push(observe(document));
14430
14535
  recording = true;
14431
14536
  };
14432
- if (doc.readyState === "interactive" || doc.readyState === "complete") {
14537
+ if (document.readyState === "interactive" || document.readyState === "complete") {
14433
14538
  init();
14434
14539
  } else {
14435
14540
  handlers.push(
@@ -14451,7 +14556,7 @@ function record(options = {}) {
14451
14556
  });
14452
14557
  if (recordAfter === "load") init();
14453
14558
  },
14454
- win
14559
+ window
14455
14560
  )
14456
14561
  );
14457
14562
  }