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