@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.
@@ -560,7 +560,7 @@ function getXPath(node2) {
560
560
  return "/html/body";
561
561
  }
562
562
  const parentNode2 = element.parentNode;
563
- if (!parentNode2 || !(parentNode2 instanceof Element)) {
563
+ if (!parentNode2) {
564
564
  return "";
565
565
  }
566
566
  const siblings = Array.from(parentNode2.children).filter(
@@ -622,14 +622,21 @@ function isTextVisible(n2) {
622
622
  return textContent2 !== "";
623
623
  }
624
624
  function isElementVisible(n2) {
625
- return isStyleVisible(n2) && isRectVisible(n2.getBoundingClientRect());
626
- }
627
- function isStyleVisible(n2) {
628
- const style = window.getComputedStyle(n2);
629
- return style.display !== "none" && style.visibility !== "hidden" && parseFloat(style.opacity) !== 0;
630
- }
631
- function isRectVisible(rect) {
632
- 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);
625
+ var _a3;
626
+ var _a2;
627
+ const win = (_a3 = (_a2 = n2.ownerDocument) == null ? void 0 : _a2.defaultView) != null ? _a3 : null;
628
+ const style = win ? win.getComputedStyle(n2) : null;
629
+ const isStyleVisible = style != null && style.display !== "none" && style.visibility !== "hidden" && parseFloat(style.opacity) !== 0;
630
+ const rect = n2.getBoundingClientRect();
631
+ const result2 = isStyleVisible && isRectVisible(rect, win);
632
+ return result2;
633
+ }
634
+ function isRectVisible(rect, win) {
635
+ var _a3, _b2, _c2, _d2;
636
+ var _a2, _b, _c, _d;
637
+ 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;
638
+ 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;
639
+ return rect.width > 0 && rect.height > 0 && rect.top >= 0 && rect.left >= 0 && rect.bottom <= height && rect.right <= width;
633
640
  }
634
641
  const interactiveEvents$1 = [
635
642
  "change",
@@ -669,7 +676,7 @@ const interactiveTags = [
669
676
  "video",
670
677
  "audio"
671
678
  ];
672
- const inlineEventAttributes$1 = [
679
+ const inlineEventAttributes = [
673
680
  "onclick",
674
681
  "ondblclick",
675
682
  "onmousedown",
@@ -712,7 +719,6 @@ function hasEventListeners(n2) {
712
719
  return n2 instanceof Element && interactiveElementsRegistry$1.has(n2);
713
720
  }
714
721
  function isElementInteractive(n2) {
715
- var _a2;
716
722
  if (n2.nodeType === Node.ELEMENT_NODE) {
717
723
  const element = n2;
718
724
  const tagName = element.tagName.toLowerCase();
@@ -726,30 +732,35 @@ function isElementInteractive(n2) {
726
732
  const result2 = hasEventListeners(element) || hasTabIndex || hasRoleInteractive || element instanceof HTMLAnchorElement && element.hasAttribute("href") || element instanceof HTMLButtonElement && !element.disabled;
727
733
  return result2;
728
734
  }
729
- if (n2.nodeType === Node.TEXT_NODE) {
730
- const textNode = n2;
731
- const parentElement2 = textNode.parentElement;
732
- if (parentElement2 !== null && interactiveTags.includes(parentElement2.tagName.toLowerCase())) {
733
- return true;
734
- }
735
- return parentElement2 !== null && isElementVisible(parentElement2) && ((_a2 = textNode.textContent) == null ? void 0 : _a2.trim().length) !== 0 && isElementInteractive(parentElement2);
736
- }
737
735
  return false;
738
736
  }
739
- function inspectInlineEventHandlers$1() {
740
- const allElements = document.querySelectorAll("*");
737
+ function inspectInlineEventHandlers(doc) {
738
+ if (!doc || typeof doc.querySelectorAll !== "function") return;
739
+ const allElements = doc.querySelectorAll("*");
741
740
  allElements.forEach((el) => {
742
- inlineEventAttributes$1.forEach((attr) => {
741
+ inlineEventAttributes.forEach((attr) => {
743
742
  if (el.hasAttribute(attr)) {
744
743
  interactiveElementsRegistry$1.add(el);
745
744
  }
746
745
  });
747
746
  });
748
747
  }
749
- if (document.readyState === "complete" || document.readyState === "interactive") {
750
- inspectInlineEventHandlers$1();
751
- } else {
752
- document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers$1);
748
+ function scheduleInlineEventInspection(doc) {
749
+ if (!doc || typeof doc.addEventListener !== "function" || typeof doc.querySelectorAll !== "function") {
750
+ return;
751
+ }
752
+ try {
753
+ if (doc.readyState === "complete" || doc.readyState === "interactive") {
754
+ inspectInlineEventHandlers(doc);
755
+ } else {
756
+ doc.addEventListener("DOMContentLoaded", () => inspectInlineEventHandlers(doc), {
757
+ once: true,
758
+ capture: false
759
+ });
760
+ }
761
+ } catch (e2) {
762
+ console.warn("[inlineEventInspection] Failed to inspect document:", e2);
763
+ }
753
764
  }
754
765
  let _id = 1;
755
766
  const tagNameRegex = new RegExp("[^a-z0-9-_:]");
@@ -868,9 +879,29 @@ function transformAttribute(doc, tagName, name, value) {
868
879
  }
869
880
  return value;
870
881
  }
871
- function ignoreAttribute(tagName, name, _value) {
882
+ function isIgnoreAttribute(tagName, name, _value) {
872
883
  return (tagName === "video" || tagName === "audio") && name === "autoplay";
873
884
  }
885
+ function cleanAttributes(doc, element, ignoreAttribute) {
886
+ const tagName = getValidTagName$1(element);
887
+ const attributes = {};
888
+ const len = element.attributes.length;
889
+ for (let i2 = 0; i2 < len; i2++) {
890
+ const attr = element.attributes[i2];
891
+ const name = attr.name;
892
+ const value = attr.value;
893
+ const shouldIgnoreByName = typeof ignoreAttribute === "string" ? name === ignoreAttribute : ignoreAttribute.test(name);
894
+ if (!shouldIgnoreByName && !isIgnoreAttribute(tagName, name)) {
895
+ attributes[name] = transformAttribute(
896
+ doc,
897
+ tagName,
898
+ toLowerCase(name),
899
+ value
900
+ );
901
+ }
902
+ }
903
+ return attributes;
904
+ }
874
905
  function _isBlockedElement(element, blockClass, blockSelector) {
875
906
  try {
876
907
  if (typeof blockClass === "string") {
@@ -1000,6 +1031,7 @@ function serializeNode(n2, options) {
1000
1031
  mirror: mirror2,
1001
1032
  blockClass,
1002
1033
  blockSelector,
1034
+ ignoreAttribute,
1003
1035
  needsMask,
1004
1036
  inlineStylesheet,
1005
1037
  maskInputOptions = {},
@@ -1044,6 +1076,7 @@ function serializeNode(n2, options) {
1044
1076
  doc,
1045
1077
  blockClass,
1046
1078
  blockSelector,
1079
+ ignoreAttribute,
1047
1080
  inlineStylesheet,
1048
1081
  maskInputOptions,
1049
1082
  maskInputFn,
@@ -1121,6 +1154,7 @@ function serializeElementNode(n2, options) {
1121
1154
  doc,
1122
1155
  blockClass,
1123
1156
  blockSelector,
1157
+ ignoreAttribute,
1124
1158
  inlineStylesheet,
1125
1159
  maskInputOptions = {},
1126
1160
  maskInputFn,
@@ -1134,19 +1168,7 @@ function serializeElementNode(n2, options) {
1134
1168
  } = options;
1135
1169
  const needBlock = _isBlockedElement(n2, blockClass, blockSelector);
1136
1170
  const tagName = getValidTagName$1(n2);
1137
- let attributes = {};
1138
- const len = n2.attributes.length;
1139
- for (let i2 = 0; i2 < len; i2++) {
1140
- const attr = n2.attributes[i2];
1141
- if (!ignoreAttribute(tagName, attr.name, attr.value)) {
1142
- attributes[attr.name] = transformAttribute(
1143
- doc,
1144
- tagName,
1145
- toLowerCase(attr.name),
1146
- attr.value
1147
- );
1148
- }
1149
- }
1171
+ let attributes = cleanAttributes(doc, n2, ignoreAttribute);
1150
1172
  if (tagName === "link" && inlineStylesheet) {
1151
1173
  const stylesheet = Array.from(doc.styleSheets).find((s2) => {
1152
1174
  return s2.href === n2.href;
@@ -1360,6 +1382,7 @@ function serializeNodeWithId(n2, options) {
1360
1382
  blockSelector,
1361
1383
  maskTextClass,
1362
1384
  maskTextSelector,
1385
+ ignoreAttribute,
1363
1386
  skipChild = false,
1364
1387
  inlineStylesheet = true,
1365
1388
  maskInputOptions = {},
@@ -1394,6 +1417,7 @@ function serializeNodeWithId(n2, options) {
1394
1417
  mirror: mirror2,
1395
1418
  blockClass,
1396
1419
  blockSelector,
1420
+ ignoreAttribute,
1397
1421
  needsMask,
1398
1422
  inlineStylesheet,
1399
1423
  maskInputOptions,
@@ -1446,6 +1470,7 @@ function serializeNodeWithId(n2, options) {
1446
1470
  needsMask,
1447
1471
  maskTextClass,
1448
1472
  maskTextSelector,
1473
+ ignoreAttribute,
1449
1474
  skipChild,
1450
1475
  inlineStylesheet,
1451
1476
  maskInputOptions,
@@ -1505,6 +1530,7 @@ function serializeNodeWithId(n2, options) {
1505
1530
  needsMask,
1506
1531
  maskTextClass,
1507
1532
  maskTextSelector,
1533
+ ignoreAttribute,
1508
1534
  skipChild: false,
1509
1535
  inlineStylesheet,
1510
1536
  maskInputOptions,
@@ -1546,6 +1572,7 @@ function serializeNodeWithId(n2, options) {
1546
1572
  needsMask,
1547
1573
  maskTextClass,
1548
1574
  maskTextSelector,
1575
+ ignoreAttribute,
1549
1576
  skipChild: false,
1550
1577
  inlineStylesheet,
1551
1578
  maskInputOptions,
@@ -1583,6 +1610,7 @@ function snapshot(n2, options) {
1583
1610
  blockSelector = null,
1584
1611
  maskTextClass = "rr-mask",
1585
1612
  maskTextSelector = null,
1613
+ ignoreAttribute = "rr-ignore-attr",
1586
1614
  inlineStylesheet = true,
1587
1615
  inlineImages = false,
1588
1616
  recordCanvas = false,
@@ -1599,6 +1627,7 @@ function snapshot(n2, options) {
1599
1627
  stylesheetLoadTimeout,
1600
1628
  keepIframeSrcFn = () => false
1601
1629
  } = options || {};
1630
+ scheduleInlineEventInspection(n2);
1602
1631
  const maskInputOptions = maskAllInputs === true ? {
1603
1632
  color: true,
1604
1633
  date: true,
@@ -1642,6 +1671,7 @@ function snapshot(n2, options) {
1642
1671
  blockSelector,
1643
1672
  maskTextClass,
1644
1673
  maskTextSelector,
1674
+ ignoreAttribute,
1645
1675
  skipChild: false,
1646
1676
  inlineStylesheet,
1647
1677
  maskInputOptions,
@@ -5242,30 +5272,6 @@ const interactiveEvents = [
5242
5272
  "touchend",
5243
5273
  "touchcancel"
5244
5274
  ];
5245
- const inlineEventAttributes = [
5246
- "onclick",
5247
- "ondblclick",
5248
- "onmousedown",
5249
- "onmouseup",
5250
- "onmouseover",
5251
- "onmouseout",
5252
- "onmousemove",
5253
- "onfocus",
5254
- "onblur",
5255
- "onkeydown",
5256
- "onkeypress",
5257
- "onkeyup",
5258
- "onchange",
5259
- "oninput",
5260
- "onsubmit",
5261
- "onreset",
5262
- "onselect",
5263
- "oncontextmenu",
5264
- "ontouchstart",
5265
- "ontouchmove",
5266
- "ontouchend",
5267
- "ontouchcancel"
5268
- ];
5269
5275
  const interactiveElementsRegistry = /* @__PURE__ */ new WeakSet();
5270
5276
  const originalAddEventListener = EventTarget.prototype.addEventListener;
5271
5277
  EventTarget.prototype.addEventListener = function(type, listener, options) {
@@ -5281,21 +5287,6 @@ const originalRemoveEventListener = EventTarget.prototype.removeEventListener;
5281
5287
  EventTarget.prototype.removeEventListener = function(type, listener, options) {
5282
5288
  originalRemoveEventListener.call(this, type, listener, options);
5283
5289
  };
5284
- function inspectInlineEventHandlers() {
5285
- const allElements = document.querySelectorAll("*");
5286
- allElements.forEach((el) => {
5287
- inlineEventAttributes.forEach((attr) => {
5288
- if (el.hasAttribute(attr)) {
5289
- interactiveElementsRegistry.add(el);
5290
- }
5291
- });
5292
- });
5293
- }
5294
- if (document.readyState === "complete" || document.readyState === "interactive") {
5295
- inspectInlineEventHandlers();
5296
- } else {
5297
- document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers);
5298
- }
5299
5290
  function getDefaultExportFromCjs(x2) {
5300
5291
  return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
5301
5292
  }
@@ -9159,7 +9150,7 @@ let nowTimestamp = Date.now;
9159
9150
  if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
9160
9151
  nowTimestamp = () => (/* @__PURE__ */ new Date()).getTime();
9161
9152
  }
9162
- function getWindowScroll(win) {
9153
+ function getWindowScroll(win = window) {
9163
9154
  var _a2, _b, _c, _d;
9164
9155
  const doc = win.document;
9165
9156
  return {
@@ -9167,11 +9158,13 @@ function getWindowScroll(win) {
9167
9158
  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
9168
9159
  };
9169
9160
  }
9170
- function getWindowHeight() {
9171
- return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
9161
+ function getWindowHeight(win = window) {
9162
+ const doc = win.document;
9163
+ return win.innerHeight || doc.documentElement && doc.documentElement.clientHeight || doc.body && doc.body.clientHeight || 0;
9172
9164
  }
9173
- function getWindowWidth() {
9174
- return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
9165
+ function getWindowWidth(win = window) {
9166
+ const doc = win.document;
9167
+ return win.innerWidth || doc.documentElement && doc.documentElement.clientWidth || doc.body && doc.body.clientWidth || 0;
9175
9168
  }
9176
9169
  function closestElementOfNode(node2) {
9177
9170
  if (!node2) {
@@ -9491,6 +9484,7 @@ class MutationBuffer {
9491
9484
  __publicField(this, "blockSelector");
9492
9485
  __publicField(this, "maskTextClass");
9493
9486
  __publicField(this, "maskTextSelector");
9487
+ __publicField(this, "ignoreAttribute");
9494
9488
  __publicField(this, "inlineStylesheet");
9495
9489
  __publicField(this, "maskInputOptions");
9496
9490
  __publicField(this, "maskTextFn");
@@ -9554,6 +9548,7 @@ class MutationBuffer {
9554
9548
  blockSelector: this.blockSelector,
9555
9549
  maskTextClass: this.maskTextClass,
9556
9550
  maskTextSelector: this.maskTextSelector,
9551
+ ignoreAttribute: this.ignoreAttribute || "",
9557
9552
  skipChild: true,
9558
9553
  newlyAddedElement: true,
9559
9554
  inlineStylesheet: this.inlineStylesheet,
@@ -9782,7 +9777,7 @@ class MutationBuffer {
9782
9777
  if (attributeName === "type" && target.tagName === "INPUT" && (m.oldValue || "").toLowerCase() === "password") {
9783
9778
  target.setAttribute("data-rr-is-password", "true");
9784
9779
  }
9785
- if (!ignoreAttribute(target.tagName, attributeName)) {
9780
+ if (!isIgnoreAttribute(target.tagName, attributeName)) {
9786
9781
  item.attributes[attributeName] = transformAttribute(
9787
9782
  this.doc,
9788
9783
  toLowerCase(target.tagName),
@@ -9901,6 +9896,7 @@ class MutationBuffer {
9901
9896
  "blockSelector",
9902
9897
  "maskTextClass",
9903
9898
  "maskTextSelector",
9899
+ "ignoreAttribute",
9904
9900
  "inlineStylesheet",
9905
9901
  "maskInputOptions",
9906
9902
  "maskTextFn",
@@ -12126,6 +12122,7 @@ function record(options = {}) {
12126
12122
  blockSelector = null,
12127
12123
  ignoreClass = "rr-ignore",
12128
12124
  ignoreSelector = null,
12125
+ ignoreAttribute = "rr-ignore-attribute",
12129
12126
  maskTextClass = "rr-mask",
12130
12127
  maskTextSelector = null,
12131
12128
  inlineStylesheet = true,
@@ -12317,7 +12314,7 @@ function record(options = {}) {
12317
12314
  canvasManager = new CanvasManager({
12318
12315
  recordCanvas,
12319
12316
  mutationCb: wrappedCanvasMutationEmit,
12320
- win: window,
12317
+ win,
12321
12318
  blockClass,
12322
12319
  blockSelector,
12323
12320
  mirror,
@@ -12332,6 +12329,7 @@ function record(options = {}) {
12332
12329
  blockSelector,
12333
12330
  maskTextClass,
12334
12331
  maskTextSelector,
12332
+ ignoreAttribute,
12335
12333
  inlineStylesheet,
12336
12334
  maskInputOptions,
12337
12335
  dataURLOptions,
@@ -12358,8 +12356,8 @@ function record(options = {}) {
12358
12356
  type: EventType.Meta,
12359
12357
  data: {
12360
12358
  href: win.location.href,
12361
- width: getWindowWidth(),
12362
- height: getWindowHeight()
12359
+ width: getWindowWidth(win),
12360
+ height: getWindowHeight(win)
12363
12361
  }
12364
12362
  },
12365
12363
  isCheckout
@@ -12367,7 +12365,7 @@ function record(options = {}) {
12367
12365
  stylesheetManager.reset();
12368
12366
  shadowDomManager.init();
12369
12367
  mutationBuffers.forEach((buf) => buf.lock());
12370
- const node2 = snapshot(document, {
12368
+ const node2 = snapshot(doc, {
12371
12369
  mirror,
12372
12370
  blockClass,
12373
12371
  blockSelector,
@@ -12389,7 +12387,7 @@ function record(options = {}) {
12389
12387
  stylesheetManager.trackLinkElement(n2);
12390
12388
  }
12391
12389
  if (hasShadowRoot(n2)) {
12392
- shadowDomManager.addShadowRoot(index.shadowRoot(n2), document);
12390
+ shadowDomManager.addShadowRoot(index.shadowRoot(n2), doc);
12393
12391
  }
12394
12392
  },
12395
12393
  onIframeLoad: (iframe, childSn) => {
@@ -12409,7 +12407,7 @@ function record(options = {}) {
12409
12407
  type: EventType.FullSnapshot,
12410
12408
  data: {
12411
12409
  node: node2,
12412
- initialOffset: getWindowScroll(window)
12410
+ initialOffset: getWindowScroll(win)
12413
12411
  }
12414
12412
  },
12415
12413
  isCheckout
@@ -12508,6 +12506,7 @@ function record(options = {}) {
12508
12506
  ignoreSelector,
12509
12507
  maskTextClass,
12510
12508
  maskTextSelector,
12509
+ ignoreAttribute,
12511
12510
  maskInputOptions,
12512
12511
  inlineStylesheet,
12513
12512
  sampling,
@@ -12554,7 +12553,7 @@ function record(options = {}) {
12554
12553
  });
12555
12554
  const init = () => {
12556
12555
  takeFullSnapshot$1();
12557
- handlers.push(observe(document));
12556
+ handlers.push(observe(doc));
12558
12557
  recording = true;
12559
12558
  };
12560
12559
  if (doc.readyState === "interactive" || doc.readyState === "complete") {
@@ -12579,7 +12578,7 @@ function record(options = {}) {
12579
12578
  });
12580
12579
  if (recordAfter === "load") init();
12581
12580
  },
12582
- window
12581
+ win
12583
12582
  )
12584
12583
  );
12585
12584
  }