@appsurify-testmap/rrweb-record 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.
@@ -515,7 +515,7 @@ function getXPath(node2) {
515
515
  return "/html/body";
516
516
  }
517
517
  const parentNode2 = element.parentNode;
518
- if (!parentNode2 || !(parentNode2 instanceof Element)) {
518
+ if (!parentNode2) {
519
519
  return "";
520
520
  }
521
521
  const siblings = Array.from(parentNode2.children).filter(
@@ -577,14 +577,19 @@ function isTextVisible(n2) {
577
577
  return textContent2 !== "";
578
578
  }
579
579
  function isElementVisible(n2) {
580
- return isStyleVisible(n2) && isRectVisible(n2.getBoundingClientRect());
581
- }
582
- function isStyleVisible(n2) {
583
- const style = window.getComputedStyle(n2);
584
- return style.display !== "none" && style.visibility !== "hidden" && parseFloat(style.opacity) !== 0;
585
- }
586
- function isRectVisible(rect) {
587
- 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);
580
+ var _a2;
581
+ const win = ((_a2 = n2.ownerDocument) == null ? void 0 : _a2.defaultView) ?? null;
582
+ const style = win ? win.getComputedStyle(n2) : null;
583
+ const isStyleVisible = style != null && style.display !== "none" && style.visibility !== "hidden" && parseFloat(style.opacity) !== 0;
584
+ const rect = n2.getBoundingClientRect();
585
+ const result2 = isStyleVisible && isRectVisible(rect, win);
586
+ return result2;
587
+ }
588
+ function isRectVisible(rect, win) {
589
+ var _a2, _b, _c, _d;
590
+ 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;
591
+ 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;
592
+ return rect.width > 0 && rect.height > 0 && rect.top >= 0 && rect.left >= 0 && rect.bottom <= height && rect.right <= width;
588
593
  }
589
594
  const interactiveEvents$1 = [
590
595
  "change",
@@ -624,7 +629,7 @@ const interactiveTags = [
624
629
  "video",
625
630
  "audio"
626
631
  ];
627
- const inlineEventAttributes$1 = [
632
+ const inlineEventAttributes = [
628
633
  "onclick",
629
634
  "ondblclick",
630
635
  "onmousedown",
@@ -667,7 +672,6 @@ function hasEventListeners(n2) {
667
672
  return n2 instanceof Element && interactiveElementsRegistry$1.has(n2);
668
673
  }
669
674
  function isElementInteractive(n2) {
670
- var _a2;
671
675
  if (n2.nodeType === Node.ELEMENT_NODE) {
672
676
  const element = n2;
673
677
  const tagName = element.tagName.toLowerCase();
@@ -681,30 +685,35 @@ function isElementInteractive(n2) {
681
685
  const result2 = hasEventListeners(element) || hasTabIndex || hasRoleInteractive || element instanceof HTMLAnchorElement && element.hasAttribute("href") || element instanceof HTMLButtonElement && !element.disabled;
682
686
  return result2;
683
687
  }
684
- if (n2.nodeType === Node.TEXT_NODE) {
685
- const textNode = n2;
686
- const parentElement2 = textNode.parentElement;
687
- if (parentElement2 !== null && interactiveTags.includes(parentElement2.tagName.toLowerCase())) {
688
- return true;
689
- }
690
- return parentElement2 !== null && isElementVisible(parentElement2) && ((_a2 = textNode.textContent) == null ? void 0 : _a2.trim().length) !== 0 && isElementInteractive(parentElement2);
691
- }
692
688
  return false;
693
689
  }
694
- function inspectInlineEventHandlers$1() {
695
- const allElements = document.querySelectorAll("*");
690
+ function inspectInlineEventHandlers(doc) {
691
+ if (!doc || typeof doc.querySelectorAll !== "function") return;
692
+ const allElements = doc.querySelectorAll("*");
696
693
  allElements.forEach((el) => {
697
- inlineEventAttributes$1.forEach((attr) => {
694
+ inlineEventAttributes.forEach((attr) => {
698
695
  if (el.hasAttribute(attr)) {
699
696
  interactiveElementsRegistry$1.add(el);
700
697
  }
701
698
  });
702
699
  });
703
700
  }
704
- if (document.readyState === "complete" || document.readyState === "interactive") {
705
- inspectInlineEventHandlers$1();
706
- } else {
707
- document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers$1);
701
+ function scheduleInlineEventInspection(doc) {
702
+ if (!doc || typeof doc.addEventListener !== "function" || typeof doc.querySelectorAll !== "function") {
703
+ return;
704
+ }
705
+ try {
706
+ if (doc.readyState === "complete" || doc.readyState === "interactive") {
707
+ inspectInlineEventHandlers(doc);
708
+ } else {
709
+ doc.addEventListener("DOMContentLoaded", () => inspectInlineEventHandlers(doc), {
710
+ once: true,
711
+ capture: false
712
+ });
713
+ }
714
+ } catch (e2) {
715
+ console.warn("[inlineEventInspection] Failed to inspect document:", e2);
716
+ }
708
717
  }
709
718
  let _id = 1;
710
719
  const tagNameRegex = new RegExp("[^a-z0-9-_:]");
@@ -823,9 +832,29 @@ function transformAttribute(doc, tagName, name, value) {
823
832
  }
824
833
  return value;
825
834
  }
826
- function ignoreAttribute(tagName, name, _value) {
835
+ function isIgnoreAttribute(tagName, name, _value) {
827
836
  return (tagName === "video" || tagName === "audio") && name === "autoplay";
828
837
  }
838
+ function cleanAttributes(doc, element, ignoreAttribute) {
839
+ const tagName = getValidTagName$1(element);
840
+ const attributes = {};
841
+ const len = element.attributes.length;
842
+ for (let i2 = 0; i2 < len; i2++) {
843
+ const attr = element.attributes[i2];
844
+ const name = attr.name;
845
+ const value = attr.value;
846
+ const shouldIgnoreByName = typeof ignoreAttribute === "string" ? name === ignoreAttribute : ignoreAttribute.test(name);
847
+ if (!shouldIgnoreByName && !isIgnoreAttribute(tagName, name)) {
848
+ attributes[name] = transformAttribute(
849
+ doc,
850
+ tagName,
851
+ toLowerCase(name),
852
+ value
853
+ );
854
+ }
855
+ }
856
+ return attributes;
857
+ }
829
858
  function _isBlockedElement(element, blockClass, blockSelector) {
830
859
  try {
831
860
  if (typeof blockClass === "string") {
@@ -955,6 +984,7 @@ function serializeNode(n2, options) {
955
984
  mirror: mirror2,
956
985
  blockClass,
957
986
  blockSelector,
987
+ ignoreAttribute,
958
988
  needsMask,
959
989
  inlineStylesheet,
960
990
  maskInputOptions = {},
@@ -999,6 +1029,7 @@ function serializeNode(n2, options) {
999
1029
  doc,
1000
1030
  blockClass,
1001
1031
  blockSelector,
1032
+ ignoreAttribute,
1002
1033
  inlineStylesheet,
1003
1034
  maskInputOptions,
1004
1035
  maskInputFn,
@@ -1076,6 +1107,7 @@ function serializeElementNode(n2, options) {
1076
1107
  doc,
1077
1108
  blockClass,
1078
1109
  blockSelector,
1110
+ ignoreAttribute,
1079
1111
  inlineStylesheet,
1080
1112
  maskInputOptions = {},
1081
1113
  maskInputFn,
@@ -1089,19 +1121,7 @@ function serializeElementNode(n2, options) {
1089
1121
  } = options;
1090
1122
  const needBlock = _isBlockedElement(n2, blockClass, blockSelector);
1091
1123
  const tagName = getValidTagName$1(n2);
1092
- let attributes = {};
1093
- const len = n2.attributes.length;
1094
- for (let i2 = 0; i2 < len; i2++) {
1095
- const attr = n2.attributes[i2];
1096
- if (!ignoreAttribute(tagName, attr.name, attr.value)) {
1097
- attributes[attr.name] = transformAttribute(
1098
- doc,
1099
- tagName,
1100
- toLowerCase(attr.name),
1101
- attr.value
1102
- );
1103
- }
1104
- }
1124
+ let attributes = cleanAttributes(doc, n2, ignoreAttribute);
1105
1125
  if (tagName === "link" && inlineStylesheet) {
1106
1126
  const stylesheet = Array.from(doc.styleSheets).find((s2) => {
1107
1127
  return s2.href === n2.href;
@@ -1315,6 +1335,7 @@ function serializeNodeWithId(n2, options) {
1315
1335
  blockSelector,
1316
1336
  maskTextClass,
1317
1337
  maskTextSelector,
1338
+ ignoreAttribute,
1318
1339
  skipChild = false,
1319
1340
  inlineStylesheet = true,
1320
1341
  maskInputOptions = {},
@@ -1349,6 +1370,7 @@ function serializeNodeWithId(n2, options) {
1349
1370
  mirror: mirror2,
1350
1371
  blockClass,
1351
1372
  blockSelector,
1373
+ ignoreAttribute,
1352
1374
  needsMask,
1353
1375
  inlineStylesheet,
1354
1376
  maskInputOptions,
@@ -1401,6 +1423,7 @@ function serializeNodeWithId(n2, options) {
1401
1423
  needsMask,
1402
1424
  maskTextClass,
1403
1425
  maskTextSelector,
1426
+ ignoreAttribute,
1404
1427
  skipChild,
1405
1428
  inlineStylesheet,
1406
1429
  maskInputOptions,
@@ -1460,6 +1483,7 @@ function serializeNodeWithId(n2, options) {
1460
1483
  needsMask,
1461
1484
  maskTextClass,
1462
1485
  maskTextSelector,
1486
+ ignoreAttribute,
1463
1487
  skipChild: false,
1464
1488
  inlineStylesheet,
1465
1489
  maskInputOptions,
@@ -1501,6 +1525,7 @@ function serializeNodeWithId(n2, options) {
1501
1525
  needsMask,
1502
1526
  maskTextClass,
1503
1527
  maskTextSelector,
1528
+ ignoreAttribute,
1504
1529
  skipChild: false,
1505
1530
  inlineStylesheet,
1506
1531
  maskInputOptions,
@@ -1538,6 +1563,7 @@ function snapshot(n2, options) {
1538
1563
  blockSelector = null,
1539
1564
  maskTextClass = "rr-mask",
1540
1565
  maskTextSelector = null,
1566
+ ignoreAttribute = "rr-ignore-attr",
1541
1567
  inlineStylesheet = true,
1542
1568
  inlineImages = false,
1543
1569
  recordCanvas = false,
@@ -1554,6 +1580,7 @@ function snapshot(n2, options) {
1554
1580
  stylesheetLoadTimeout,
1555
1581
  keepIframeSrcFn = () => false
1556
1582
  } = options || {};
1583
+ scheduleInlineEventInspection(n2);
1557
1584
  const maskInputOptions = maskAllInputs === true ? {
1558
1585
  color: true,
1559
1586
  date: true,
@@ -1597,6 +1624,7 @@ function snapshot(n2, options) {
1597
1624
  blockSelector,
1598
1625
  maskTextClass,
1599
1626
  maskTextSelector,
1627
+ ignoreAttribute,
1600
1628
  skipChild: false,
1601
1629
  inlineStylesheet,
1602
1630
  maskInputOptions,
@@ -5193,30 +5221,6 @@ const interactiveEvents = [
5193
5221
  "touchend",
5194
5222
  "touchcancel"
5195
5223
  ];
5196
- const inlineEventAttributes = [
5197
- "onclick",
5198
- "ondblclick",
5199
- "onmousedown",
5200
- "onmouseup",
5201
- "onmouseover",
5202
- "onmouseout",
5203
- "onmousemove",
5204
- "onfocus",
5205
- "onblur",
5206
- "onkeydown",
5207
- "onkeypress",
5208
- "onkeyup",
5209
- "onchange",
5210
- "oninput",
5211
- "onsubmit",
5212
- "onreset",
5213
- "onselect",
5214
- "oncontextmenu",
5215
- "ontouchstart",
5216
- "ontouchmove",
5217
- "ontouchend",
5218
- "ontouchcancel"
5219
- ];
5220
5224
  const interactiveElementsRegistry = /* @__PURE__ */ new WeakSet();
5221
5225
  const originalAddEventListener = EventTarget.prototype.addEventListener;
5222
5226
  EventTarget.prototype.addEventListener = function(type, listener, options) {
@@ -5232,21 +5236,6 @@ const originalRemoveEventListener = EventTarget.prototype.removeEventListener;
5232
5236
  EventTarget.prototype.removeEventListener = function(type, listener, options) {
5233
5237
  originalRemoveEventListener.call(this, type, listener, options);
5234
5238
  };
5235
- function inspectInlineEventHandlers() {
5236
- const allElements = document.querySelectorAll("*");
5237
- allElements.forEach((el) => {
5238
- inlineEventAttributes.forEach((attr) => {
5239
- if (el.hasAttribute(attr)) {
5240
- interactiveElementsRegistry.add(el);
5241
- }
5242
- });
5243
- });
5244
- }
5245
- if (document.readyState === "complete" || document.readyState === "interactive") {
5246
- inspectInlineEventHandlers();
5247
- } else {
5248
- document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers);
5249
- }
5250
5239
  function getDefaultExportFromCjs(x2) {
5251
5240
  return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
5252
5241
  }
@@ -9106,7 +9095,7 @@ let nowTimestamp = Date.now;
9106
9095
  if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
9107
9096
  nowTimestamp = () => (/* @__PURE__ */ new Date()).getTime();
9108
9097
  }
9109
- function getWindowScroll(win) {
9098
+ function getWindowScroll(win = window) {
9110
9099
  var _a2, _b, _c, _d;
9111
9100
  const doc = win.document;
9112
9101
  return {
@@ -9114,11 +9103,13 @@ function getWindowScroll(win) {
9114
9103
  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
9115
9104
  };
9116
9105
  }
9117
- function getWindowHeight() {
9118
- return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
9106
+ function getWindowHeight(win = window) {
9107
+ const doc = win.document;
9108
+ return win.innerHeight || doc.documentElement && doc.documentElement.clientHeight || doc.body && doc.body.clientHeight || 0;
9119
9109
  }
9120
- function getWindowWidth() {
9121
- return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
9110
+ function getWindowWidth(win = window) {
9111
+ const doc = win.document;
9112
+ return win.innerWidth || doc.documentElement && doc.documentElement.clientWidth || doc.body && doc.body.clientWidth || 0;
9122
9113
  }
9123
9114
  function closestElementOfNode(node2) {
9124
9115
  if (!node2) {
@@ -9437,6 +9428,7 @@ class MutationBuffer {
9437
9428
  __publicField(this, "blockSelector");
9438
9429
  __publicField(this, "maskTextClass");
9439
9430
  __publicField(this, "maskTextSelector");
9431
+ __publicField(this, "ignoreAttribute");
9440
9432
  __publicField(this, "inlineStylesheet");
9441
9433
  __publicField(this, "maskInputOptions");
9442
9434
  __publicField(this, "maskTextFn");
@@ -9500,6 +9492,7 @@ class MutationBuffer {
9500
9492
  blockSelector: this.blockSelector,
9501
9493
  maskTextClass: this.maskTextClass,
9502
9494
  maskTextSelector: this.maskTextSelector,
9495
+ ignoreAttribute: this.ignoreAttribute || "",
9503
9496
  skipChild: true,
9504
9497
  newlyAddedElement: true,
9505
9498
  inlineStylesheet: this.inlineStylesheet,
@@ -9728,7 +9721,7 @@ class MutationBuffer {
9728
9721
  if (attributeName === "type" && target.tagName === "INPUT" && (m.oldValue || "").toLowerCase() === "password") {
9729
9722
  target.setAttribute("data-rr-is-password", "true");
9730
9723
  }
9731
- if (!ignoreAttribute(target.tagName, attributeName)) {
9724
+ if (!isIgnoreAttribute(target.tagName, attributeName)) {
9732
9725
  item.attributes[attributeName] = transformAttribute(
9733
9726
  this.doc,
9734
9727
  toLowerCase(target.tagName),
@@ -9847,6 +9840,7 @@ class MutationBuffer {
9847
9840
  "blockSelector",
9848
9841
  "maskTextClass",
9849
9842
  "maskTextSelector",
9843
+ "ignoreAttribute",
9850
9844
  "inlineStylesheet",
9851
9845
  "maskInputOptions",
9852
9846
  "maskTextFn",
@@ -12076,6 +12070,7 @@ function record(options = {}) {
12076
12070
  blockSelector = null,
12077
12071
  ignoreClass = "rr-ignore",
12078
12072
  ignoreSelector = null,
12073
+ ignoreAttribute = "rr-ignore-attribute",
12079
12074
  maskTextClass = "rr-mask",
12080
12075
  maskTextSelector = null,
12081
12076
  inlineStylesheet = true,
@@ -12271,7 +12266,7 @@ function record(options = {}) {
12271
12266
  canvasManager = new CanvasManager({
12272
12267
  recordCanvas,
12273
12268
  mutationCb: wrappedCanvasMutationEmit,
12274
- win: window,
12269
+ win,
12275
12270
  blockClass,
12276
12271
  blockSelector,
12277
12272
  mirror,
@@ -12286,6 +12281,7 @@ function record(options = {}) {
12286
12281
  blockSelector,
12287
12282
  maskTextClass,
12288
12283
  maskTextSelector,
12284
+ ignoreAttribute,
12289
12285
  inlineStylesheet,
12290
12286
  maskInputOptions,
12291
12287
  dataURLOptions,
@@ -12312,8 +12308,8 @@ function record(options = {}) {
12312
12308
  type: EventType.Meta,
12313
12309
  data: {
12314
12310
  href: win.location.href,
12315
- width: getWindowWidth(),
12316
- height: getWindowHeight()
12311
+ width: getWindowWidth(win),
12312
+ height: getWindowHeight(win)
12317
12313
  }
12318
12314
  },
12319
12315
  isCheckout
@@ -12321,7 +12317,7 @@ function record(options = {}) {
12321
12317
  stylesheetManager.reset();
12322
12318
  shadowDomManager.init();
12323
12319
  mutationBuffers.forEach((buf) => buf.lock());
12324
- const node2 = snapshot(document, {
12320
+ const node2 = snapshot(doc, {
12325
12321
  mirror,
12326
12322
  blockClass,
12327
12323
  blockSelector,
@@ -12343,7 +12339,7 @@ function record(options = {}) {
12343
12339
  stylesheetManager.trackLinkElement(n2);
12344
12340
  }
12345
12341
  if (hasShadowRoot(n2)) {
12346
- shadowDomManager.addShadowRoot(index.shadowRoot(n2), document);
12342
+ shadowDomManager.addShadowRoot(index.shadowRoot(n2), doc);
12347
12343
  }
12348
12344
  },
12349
12345
  onIframeLoad: (iframe, childSn) => {
@@ -12363,7 +12359,7 @@ function record(options = {}) {
12363
12359
  type: EventType.FullSnapshot,
12364
12360
  data: {
12365
12361
  node: node2,
12366
- initialOffset: getWindowScroll(window)
12362
+ initialOffset: getWindowScroll(win)
12367
12363
  }
12368
12364
  },
12369
12365
  isCheckout
@@ -12472,6 +12468,7 @@ function record(options = {}) {
12472
12468
  ignoreSelector,
12473
12469
  maskTextClass,
12474
12470
  maskTextSelector,
12471
+ ignoreAttribute,
12475
12472
  maskInputOptions,
12476
12473
  inlineStylesheet,
12477
12474
  sampling,
@@ -12518,7 +12515,7 @@ function record(options = {}) {
12518
12515
  });
12519
12516
  const init = () => {
12520
12517
  takeFullSnapshot$1();
12521
- handlers.push(observe(document));
12518
+ handlers.push(observe(doc));
12522
12519
  recording = true;
12523
12520
  };
12524
12521
  if (doc.readyState === "interactive" || doc.readyState === "complete") {
@@ -12543,7 +12540,7 @@ function record(options = {}) {
12543
12540
  });
12544
12541
  if (recordAfter === "load") init();
12545
12542
  },
12546
- window
12543
+ win
12547
12544
  )
12548
12545
  );
12549
12546
  }