@appsurify-testmap/rrweb 2.0.0-alpha.35 → 2.0.0-alpha.40

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.
@@ -572,7 +572,7 @@ function getXPath(node2) {
572
572
  return "/html/body";
573
573
  }
574
574
  const parentNode2 = element.parentNode;
575
- if (!parentNode2 || !(parentNode2 instanceof Element)) {
575
+ if (!parentNode2) {
576
576
  return "";
577
577
  }
578
578
  const siblings = Array.from(parentNode2.children).filter(
@@ -634,14 +634,21 @@ function isTextVisible(n2) {
634
634
  return textContent2 !== "";
635
635
  }
636
636
  function isElementVisible(n2) {
637
- return isStyleVisible(n2) && isRectVisible(n2.getBoundingClientRect());
638
- }
639
- function isStyleVisible(n2) {
640
- const style = window.getComputedStyle(n2);
641
- return style.display !== "none" && style.visibility !== "hidden" && parseFloat(style.opacity) !== 0;
637
+ var _a3;
638
+ var _a2;
639
+ const win = (_a3 = (_a2 = n2.ownerDocument) == null ? void 0 : _a2.defaultView) != null ? _a3 : null;
640
+ const style = win ? win.getComputedStyle(n2) : null;
641
+ const isStyleVisible = style != null && style.display !== "none" && style.visibility !== "hidden" && parseFloat(style.opacity) !== 0;
642
+ const rect = n2.getBoundingClientRect();
643
+ const result2 = isStyleVisible && isRectVisible(rect, win);
644
+ return result2;
642
645
  }
643
- function isRectVisible(rect) {
644
- return rect.width > 0 && rect.height > 0 && rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
646
+ function isRectVisible(rect, win) {
647
+ var _a3, _b2, _c2, _d2;
648
+ var _a2, _b, _c, _d;
649
+ const height = (_b2 = (_a3 = win == null ? void 0 : win.innerHeight) != null ? _a3 : (_b = (_a2 = win == null ? void 0 : win.document) == null ? void 0 : _a2.documentElement) == null ? void 0 : _b.clientHeight) != null ? _b2 : 0;
650
+ const width = (_d2 = (_c2 = win == null ? void 0 : win.innerWidth) != null ? _c2 : (_d = (_c = win == null ? void 0 : win.document) == null ? void 0 : _c.documentElement) == null ? void 0 : _d.clientWidth) != null ? _d2 : 0;
651
+ return rect.width > 0 && rect.height > 0 && rect.top >= 0 && rect.left >= 0 && rect.bottom <= height && rect.right <= width;
645
652
  }
646
653
  const interactiveEvents$1 = [
647
654
  "change",
@@ -681,7 +688,7 @@ const interactiveTags = [
681
688
  "video",
682
689
  "audio"
683
690
  ];
684
- const inlineEventAttributes$1 = [
691
+ const inlineEventAttributes = [
685
692
  "onclick",
686
693
  "ondblclick",
687
694
  "onmousedown",
@@ -724,7 +731,6 @@ function hasEventListeners(n2) {
724
731
  return n2 instanceof Element && interactiveElementsRegistry$1.has(n2);
725
732
  }
726
733
  function isElementInteractive(n2) {
727
- var _a2;
728
734
  if (n2.nodeType === Node.ELEMENT_NODE) {
729
735
  const element = n2;
730
736
  const tagName = element.tagName.toLowerCase();
@@ -738,30 +744,35 @@ function isElementInteractive(n2) {
738
744
  const result2 = hasEventListeners(element) || hasTabIndex || hasRoleInteractive || element instanceof HTMLAnchorElement && element.hasAttribute("href") || element instanceof HTMLButtonElement && !element.disabled;
739
745
  return result2;
740
746
  }
741
- if (n2.nodeType === Node.TEXT_NODE) {
742
- const textNode = n2;
743
- const parentElement2 = textNode.parentElement;
744
- if (parentElement2 !== null && interactiveTags.includes(parentElement2.tagName.toLowerCase())) {
745
- return true;
746
- }
747
- return parentElement2 !== null && isElementVisible(parentElement2) && ((_a2 = textNode.textContent) == null ? void 0 : _a2.trim().length) !== 0 && isElementInteractive(parentElement2);
748
- }
749
747
  return false;
750
748
  }
751
- function inspectInlineEventHandlers$1() {
752
- const allElements = document.querySelectorAll("*");
749
+ function inspectInlineEventHandlers(doc) {
750
+ if (!doc || typeof doc.querySelectorAll !== "function") return;
751
+ const allElements = doc.querySelectorAll("*");
753
752
  allElements.forEach((el) => {
754
- inlineEventAttributes$1.forEach((attr) => {
753
+ inlineEventAttributes.forEach((attr) => {
755
754
  if (el.hasAttribute(attr)) {
756
755
  interactiveElementsRegistry$1.add(el);
757
756
  }
758
757
  });
759
758
  });
760
759
  }
761
- if (document.readyState === "complete" || document.readyState === "interactive") {
762
- inspectInlineEventHandlers$1();
763
- } else {
764
- document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers$1);
760
+ function scheduleInlineEventInspection(doc) {
761
+ if (!doc || typeof doc.addEventListener !== "function" || typeof doc.querySelectorAll !== "function") {
762
+ return;
763
+ }
764
+ try {
765
+ if (doc.readyState === "complete" || doc.readyState === "interactive") {
766
+ inspectInlineEventHandlers(doc);
767
+ } else {
768
+ doc.addEventListener("DOMContentLoaded", () => inspectInlineEventHandlers(doc), {
769
+ once: true,
770
+ capture: false
771
+ });
772
+ }
773
+ } catch (e2) {
774
+ console.warn("[inlineEventInspection] Failed to inspect document:", e2);
775
+ }
765
776
  }
766
777
  let _id = 1;
767
778
  const tagNameRegex = new RegExp("[^a-z0-9-_:]");
@@ -880,9 +891,29 @@ function transformAttribute(doc, tagName, name, value) {
880
891
  }
881
892
  return value;
882
893
  }
883
- function ignoreAttribute(tagName, name, _value) {
894
+ function isIgnoreAttribute(tagName, name, _value) {
884
895
  return (tagName === "video" || tagName === "audio") && name === "autoplay";
885
896
  }
897
+ function cleanAttributes(doc, element, ignoreAttribute) {
898
+ const tagName = getValidTagName$1(element);
899
+ const attributes = {};
900
+ const len = element.attributes.length;
901
+ for (let i2 = 0; i2 < len; i2++) {
902
+ const attr = element.attributes[i2];
903
+ const name = attr.name;
904
+ const value = attr.value;
905
+ const shouldIgnoreByName = typeof ignoreAttribute === "string" ? name === ignoreAttribute : ignoreAttribute.test(name);
906
+ if (!shouldIgnoreByName && !isIgnoreAttribute(tagName, name)) {
907
+ attributes[name] = transformAttribute(
908
+ doc,
909
+ tagName,
910
+ toLowerCase(name),
911
+ value
912
+ );
913
+ }
914
+ }
915
+ return attributes;
916
+ }
886
917
  function _isBlockedElement(element, blockClass, blockSelector) {
887
918
  try {
888
919
  if (typeof blockClass === "string") {
@@ -1012,6 +1043,7 @@ function serializeNode(n2, options) {
1012
1043
  mirror: mirror2,
1013
1044
  blockClass,
1014
1045
  blockSelector,
1046
+ ignoreAttribute,
1015
1047
  needsMask,
1016
1048
  inlineStylesheet,
1017
1049
  maskInputOptions = {},
@@ -1056,6 +1088,7 @@ function serializeNode(n2, options) {
1056
1088
  doc,
1057
1089
  blockClass,
1058
1090
  blockSelector,
1091
+ ignoreAttribute,
1059
1092
  inlineStylesheet,
1060
1093
  maskInputOptions,
1061
1094
  maskInputFn,
@@ -1133,6 +1166,7 @@ function serializeElementNode(n2, options) {
1133
1166
  doc,
1134
1167
  blockClass,
1135
1168
  blockSelector,
1169
+ ignoreAttribute,
1136
1170
  inlineStylesheet,
1137
1171
  maskInputOptions = {},
1138
1172
  maskInputFn,
@@ -1146,19 +1180,7 @@ function serializeElementNode(n2, options) {
1146
1180
  } = options;
1147
1181
  const needBlock = _isBlockedElement(n2, blockClass, blockSelector);
1148
1182
  const tagName = getValidTagName$1(n2);
1149
- let attributes = {};
1150
- const len = n2.attributes.length;
1151
- for (let i2 = 0; i2 < len; i2++) {
1152
- const attr = n2.attributes[i2];
1153
- if (!ignoreAttribute(tagName, attr.name, attr.value)) {
1154
- attributes[attr.name] = transformAttribute(
1155
- doc,
1156
- tagName,
1157
- toLowerCase(attr.name),
1158
- attr.value
1159
- );
1160
- }
1161
- }
1183
+ let attributes = cleanAttributes(doc, n2, ignoreAttribute);
1162
1184
  if (tagName === "link" && inlineStylesheet) {
1163
1185
  const stylesheet = Array.from(doc.styleSheets).find((s2) => {
1164
1186
  return s2.href === n2.href;
@@ -1372,6 +1394,7 @@ function serializeNodeWithId(n2, options) {
1372
1394
  blockSelector,
1373
1395
  maskTextClass,
1374
1396
  maskTextSelector,
1397
+ ignoreAttribute,
1375
1398
  skipChild = false,
1376
1399
  inlineStylesheet = true,
1377
1400
  maskInputOptions = {},
@@ -1406,6 +1429,7 @@ function serializeNodeWithId(n2, options) {
1406
1429
  mirror: mirror2,
1407
1430
  blockClass,
1408
1431
  blockSelector,
1432
+ ignoreAttribute,
1409
1433
  needsMask,
1410
1434
  inlineStylesheet,
1411
1435
  maskInputOptions,
@@ -1458,6 +1482,7 @@ function serializeNodeWithId(n2, options) {
1458
1482
  needsMask,
1459
1483
  maskTextClass,
1460
1484
  maskTextSelector,
1485
+ ignoreAttribute,
1461
1486
  skipChild,
1462
1487
  inlineStylesheet,
1463
1488
  maskInputOptions,
@@ -1517,6 +1542,7 @@ function serializeNodeWithId(n2, options) {
1517
1542
  needsMask,
1518
1543
  maskTextClass,
1519
1544
  maskTextSelector,
1545
+ ignoreAttribute,
1520
1546
  skipChild: false,
1521
1547
  inlineStylesheet,
1522
1548
  maskInputOptions,
@@ -1558,6 +1584,7 @@ function serializeNodeWithId(n2, options) {
1558
1584
  needsMask,
1559
1585
  maskTextClass,
1560
1586
  maskTextSelector,
1587
+ ignoreAttribute,
1561
1588
  skipChild: false,
1562
1589
  inlineStylesheet,
1563
1590
  maskInputOptions,
@@ -1595,6 +1622,7 @@ function snapshot(n2, options) {
1595
1622
  blockSelector = null,
1596
1623
  maskTextClass = "rr-mask",
1597
1624
  maskTextSelector = null,
1625
+ ignoreAttribute = "rr-ignore-attr",
1598
1626
  inlineStylesheet = true,
1599
1627
  inlineImages = false,
1600
1628
  recordCanvas = false,
@@ -1611,6 +1639,7 @@ function snapshot(n2, options) {
1611
1639
  stylesheetLoadTimeout,
1612
1640
  keepIframeSrcFn = () => false
1613
1641
  } = options || {};
1642
+ scheduleInlineEventInspection(n2);
1614
1643
  const maskInputOptions = maskAllInputs === true ? {
1615
1644
  color: true,
1616
1645
  date: true,
@@ -1654,6 +1683,7 @@ function snapshot(n2, options) {
1654
1683
  blockSelector,
1655
1684
  maskTextClass,
1656
1685
  maskTextSelector,
1686
+ ignoreAttribute,
1657
1687
  skipChild: false,
1658
1688
  inlineStylesheet,
1659
1689
  maskInputOptions,
@@ -5733,30 +5763,6 @@ const interactiveEvents = [
5733
5763
  "touchend",
5734
5764
  "touchcancel"
5735
5765
  ];
5736
- const inlineEventAttributes = [
5737
- "onclick",
5738
- "ondblclick",
5739
- "onmousedown",
5740
- "onmouseup",
5741
- "onmouseover",
5742
- "onmouseout",
5743
- "onmousemove",
5744
- "onfocus",
5745
- "onblur",
5746
- "onkeydown",
5747
- "onkeypress",
5748
- "onkeyup",
5749
- "onchange",
5750
- "oninput",
5751
- "onsubmit",
5752
- "onreset",
5753
- "onselect",
5754
- "oncontextmenu",
5755
- "ontouchstart",
5756
- "ontouchmove",
5757
- "ontouchend",
5758
- "ontouchcancel"
5759
- ];
5760
5766
  const interactiveElementsRegistry = /* @__PURE__ */ new WeakSet();
5761
5767
  const originalAddEventListener = EventTarget.prototype.addEventListener;
5762
5768
  EventTarget.prototype.addEventListener = function(type, listener, options) {
@@ -5772,21 +5778,6 @@ const originalRemoveEventListener = EventTarget.prototype.removeEventListener;
5772
5778
  EventTarget.prototype.removeEventListener = function(type, listener, options) {
5773
5779
  originalRemoveEventListener.call(this, type, listener, options);
5774
5780
  };
5775
- function inspectInlineEventHandlers() {
5776
- const allElements = document.querySelectorAll("*");
5777
- allElements.forEach((el) => {
5778
- inlineEventAttributes.forEach((attr) => {
5779
- if (el.hasAttribute(attr)) {
5780
- interactiveElementsRegistry.add(el);
5781
- }
5782
- });
5783
- });
5784
- }
5785
- if (document.readyState === "complete" || document.readyState === "interactive") {
5786
- inspectInlineEventHandlers();
5787
- } else {
5788
- document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers);
5789
- }
5790
5781
  function getDefaultExportFromCjs(x2) {
5791
5782
  return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
5792
5783
  }
@@ -10866,7 +10857,7 @@ let nowTimestamp = Date.now;
10866
10857
  if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
10867
10858
  nowTimestamp = () => (/* @__PURE__ */ new Date()).getTime();
10868
10859
  }
10869
- function getWindowScroll(win) {
10860
+ function getWindowScroll(win = window) {
10870
10861
  var _a2, _b, _c, _d;
10871
10862
  const doc = win.document;
10872
10863
  return {
@@ -10874,11 +10865,13 @@ function getWindowScroll(win) {
10874
10865
  top: doc.scrollingElement ? doc.scrollingElement.scrollTop : win.pageYOffset !== void 0 ? win.pageYOffset : (doc == null ? void 0 : doc.documentElement.scrollTop) || (doc == null ? void 0 : doc.body) && ((_c = index.parentElement(doc.body)) == null ? void 0 : _c.scrollTop) || ((_d = doc == null ? void 0 : doc.body) == null ? void 0 : _d.scrollTop) || 0
10875
10866
  };
10876
10867
  }
10877
- function getWindowHeight() {
10878
- return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
10868
+ function getWindowHeight(win = window) {
10869
+ const doc = win.document;
10870
+ return win.innerHeight || doc.documentElement && doc.documentElement.clientHeight || doc.body && doc.body.clientHeight || 0;
10879
10871
  }
10880
- function getWindowWidth() {
10881
- return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
10872
+ function getWindowWidth(win = window) {
10873
+ const doc = win.document;
10874
+ return win.innerWidth || doc.documentElement && doc.documentElement.clientWidth || doc.body && doc.body.clientWidth || 0;
10882
10875
  }
10883
10876
  function closestElementOfNode(node2) {
10884
10877
  if (!node2) {
@@ -11348,6 +11341,7 @@ class MutationBuffer {
11348
11341
  __publicField(this, "blockSelector");
11349
11342
  __publicField(this, "maskTextClass");
11350
11343
  __publicField(this, "maskTextSelector");
11344
+ __publicField(this, "ignoreAttribute");
11351
11345
  __publicField(this, "inlineStylesheet");
11352
11346
  __publicField(this, "maskInputOptions");
11353
11347
  __publicField(this, "maskTextFn");
@@ -11411,6 +11405,7 @@ class MutationBuffer {
11411
11405
  blockSelector: this.blockSelector,
11412
11406
  maskTextClass: this.maskTextClass,
11413
11407
  maskTextSelector: this.maskTextSelector,
11408
+ ignoreAttribute: this.ignoreAttribute || "",
11414
11409
  skipChild: true,
11415
11410
  newlyAddedElement: true,
11416
11411
  inlineStylesheet: this.inlineStylesheet,
@@ -11639,7 +11634,7 @@ class MutationBuffer {
11639
11634
  if (attributeName === "type" && target.tagName === "INPUT" && (m.oldValue || "").toLowerCase() === "password") {
11640
11635
  target.setAttribute("data-rr-is-password", "true");
11641
11636
  }
11642
- if (!ignoreAttribute(target.tagName, attributeName)) {
11637
+ if (!isIgnoreAttribute(target.tagName, attributeName)) {
11643
11638
  item.attributes[attributeName] = transformAttribute(
11644
11639
  this.doc,
11645
11640
  toLowerCase(target.tagName),
@@ -11758,6 +11753,7 @@ class MutationBuffer {
11758
11753
  "blockSelector",
11759
11754
  "maskTextClass",
11760
11755
  "maskTextSelector",
11756
+ "ignoreAttribute",
11761
11757
  "inlineStylesheet",
11762
11758
  "maskInputOptions",
11763
11759
  "maskTextFn",
@@ -14003,6 +13999,7 @@ function record(options = {}) {
14003
13999
  blockSelector = null,
14004
14000
  ignoreClass = "rr-ignore",
14005
14001
  ignoreSelector = null,
14002
+ ignoreAttribute = "rr-ignore-attribute",
14006
14003
  maskTextClass = "rr-mask",
14007
14004
  maskTextSelector = null,
14008
14005
  inlineStylesheet = true,
@@ -14194,7 +14191,7 @@ function record(options = {}) {
14194
14191
  canvasManager = new CanvasManager({
14195
14192
  recordCanvas,
14196
14193
  mutationCb: wrappedCanvasMutationEmit,
14197
- win: window,
14194
+ win,
14198
14195
  blockClass,
14199
14196
  blockSelector,
14200
14197
  mirror,
@@ -14209,6 +14206,7 @@ function record(options = {}) {
14209
14206
  blockSelector,
14210
14207
  maskTextClass,
14211
14208
  maskTextSelector,
14209
+ ignoreAttribute,
14212
14210
  inlineStylesheet,
14213
14211
  maskInputOptions,
14214
14212
  dataURLOptions,
@@ -14235,8 +14233,8 @@ function record(options = {}) {
14235
14233
  type: EventType.Meta,
14236
14234
  data: {
14237
14235
  href: win.location.href,
14238
- width: getWindowWidth(),
14239
- height: getWindowHeight()
14236
+ width: getWindowWidth(win),
14237
+ height: getWindowHeight(win)
14240
14238
  }
14241
14239
  },
14242
14240
  isCheckout
@@ -14244,7 +14242,7 @@ function record(options = {}) {
14244
14242
  stylesheetManager.reset();
14245
14243
  shadowDomManager.init();
14246
14244
  mutationBuffers.forEach((buf) => buf.lock());
14247
- const node2 = snapshot(document, {
14245
+ const node2 = snapshot(doc, {
14248
14246
  mirror,
14249
14247
  blockClass,
14250
14248
  blockSelector,
@@ -14266,7 +14264,7 @@ function record(options = {}) {
14266
14264
  stylesheetManager.trackLinkElement(n2);
14267
14265
  }
14268
14266
  if (hasShadowRoot(n2)) {
14269
- shadowDomManager.addShadowRoot(index.shadowRoot(n2), document);
14267
+ shadowDomManager.addShadowRoot(index.shadowRoot(n2), doc);
14270
14268
  }
14271
14269
  },
14272
14270
  onIframeLoad: (iframe, childSn) => {
@@ -14286,7 +14284,7 @@ function record(options = {}) {
14286
14284
  type: EventType.FullSnapshot,
14287
14285
  data: {
14288
14286
  node: node2,
14289
- initialOffset: getWindowScroll(window)
14287
+ initialOffset: getWindowScroll(win)
14290
14288
  }
14291
14289
  },
14292
14290
  isCheckout
@@ -14385,6 +14383,7 @@ function record(options = {}) {
14385
14383
  ignoreSelector,
14386
14384
  maskTextClass,
14387
14385
  maskTextSelector,
14386
+ ignoreAttribute,
14388
14387
  maskInputOptions,
14389
14388
  inlineStylesheet,
14390
14389
  sampling,
@@ -14431,7 +14430,7 @@ function record(options = {}) {
14431
14430
  });
14432
14431
  const init = () => {
14433
14432
  takeFullSnapshot$1();
14434
- handlers.push(observe(document));
14433
+ handlers.push(observe(doc));
14435
14434
  recording = true;
14436
14435
  };
14437
14436
  if (doc.readyState === "interactive" || doc.readyState === "complete") {
@@ -14456,7 +14455,7 @@ function record(options = {}) {
14456
14455
  });
14457
14456
  if (recordAfter === "load") init();
14458
14457
  },
14459
- window
14458
+ win
14460
14459
  )
14461
14460
  );
14462
14461
  }