@appsurify-testmap/rrweb-snapshot 2.0.0-alpha.30 → 2.0.0-alpha.32

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.
@@ -3,46 +3,6 @@ var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
- var InteractiveEvent = /* @__PURE__ */ ((InteractiveEvent2) => {
7
- InteractiveEvent2[InteractiveEvent2["Change"] = 0] = "Change";
8
- InteractiveEvent2[InteractiveEvent2["Submit"] = 1] = "Submit";
9
- InteractiveEvent2[InteractiveEvent2["DragStart"] = 2] = "DragStart";
10
- InteractiveEvent2[InteractiveEvent2["Drop"] = 3] = "Drop";
11
- InteractiveEvent2[InteractiveEvent2["PointerDown"] = 4] = "PointerDown";
12
- InteractiveEvent2[InteractiveEvent2["PointerUp"] = 5] = "PointerUp";
13
- InteractiveEvent2[InteractiveEvent2["Input"] = 6] = "Input";
14
- InteractiveEvent2[InteractiveEvent2["KeyDown"] = 7] = "KeyDown";
15
- InteractiveEvent2[InteractiveEvent2["KeyUp"] = 8] = "KeyUp";
16
- InteractiveEvent2[InteractiveEvent2["KeyPress"] = 9] = "KeyPress";
17
- InteractiveEvent2[InteractiveEvent2["MouseEnter"] = 10] = "MouseEnter";
18
- InteractiveEvent2[InteractiveEvent2["MouseLeave"] = 11] = "MouseLeave";
19
- InteractiveEvent2[InteractiveEvent2["MouseUp"] = 12] = "MouseUp";
20
- InteractiveEvent2[InteractiveEvent2["MouseDown"] = 13] = "MouseDown";
21
- InteractiveEvent2[InteractiveEvent2["Click"] = 14] = "Click";
22
- InteractiveEvent2[InteractiveEvent2["ContextMenu"] = 15] = "ContextMenu";
23
- InteractiveEvent2[InteractiveEvent2["DblClick"] = 16] = "DblClick";
24
- InteractiveEvent2[InteractiveEvent2["Focus"] = 17] = "Focus";
25
- InteractiveEvent2[InteractiveEvent2["Blur"] = 18] = "Blur";
26
- InteractiveEvent2[InteractiveEvent2["TouchStart"] = 19] = "TouchStart";
27
- InteractiveEvent2[InteractiveEvent2["TouchMove"] = 20] = "TouchMove";
28
- InteractiveEvent2[InteractiveEvent2["TouchEnd"] = 21] = "TouchEnd";
29
- InteractiveEvent2[InteractiveEvent2["TouchCancel"] = 22] = "TouchCancel";
30
- return InteractiveEvent2;
31
- })(InteractiveEvent || {});
32
- var interactiveTag = /* @__PURE__ */ ((interactiveTag2) => {
33
- interactiveTag2[interactiveTag2["Input"] = 0] = "Input";
34
- interactiveTag2[interactiveTag2["Button"] = 1] = "Button";
35
- interactiveTag2[interactiveTag2["A"] = 2] = "A";
36
- interactiveTag2[interactiveTag2["Select"] = 3] = "Select";
37
- interactiveTag2[interactiveTag2["Textarea"] = 4] = "Textarea";
38
- interactiveTag2[interactiveTag2["Label"] = 5] = "Label";
39
- interactiveTag2[interactiveTag2["Details"] = 6] = "Details";
40
- interactiveTag2[interactiveTag2["Summary"] = 7] = "Summary";
41
- interactiveTag2[interactiveTag2["Dialog"] = 8] = "Dialog";
42
- interactiveTag2[interactiveTag2["Video"] = 9] = "Video";
43
- interactiveTag2[interactiveTag2["Audio"] = 10] = "Audio";
44
- return interactiveTag2;
45
- })(interactiveTag || {});
46
6
  var NodeType = /* @__PURE__ */ ((NodeType2) => {
47
7
  NodeType2[NodeType2["Document"] = 0] = "Document";
48
8
  NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
@@ -634,32 +594,93 @@ function isStyleVisible(n) {
634
594
  function isRectVisible(rect) {
635
595
  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);
636
596
  }
637
- function getInteractiveEvents() {
638
- return Object.keys(InteractiveEvent).filter((key) => isNaN(Number(key))).map((key) => key.toLowerCase().replace(/_/g, "-"));
639
- }
640
- function getInteractiveTags() {
641
- return Object.keys(interactiveTag).filter((key) => isNaN(Number(key))).map((key) => key.toLowerCase().replace(/_/g, "-"));
642
- }
597
+ const interactiveEvents = [
598
+ "change",
599
+ "submit",
600
+ "dragstart",
601
+ "drop",
602
+ "pointerdown",
603
+ "pointerup",
604
+ "input",
605
+ "keydown",
606
+ "keyup",
607
+ "keypress",
608
+ "mouseenter",
609
+ "mouseleave",
610
+ "mouseup",
611
+ "mousedown",
612
+ "click",
613
+ "contextmenu",
614
+ "dblclick",
615
+ "focus",
616
+ "blur",
617
+ "touchstart",
618
+ "touchmove",
619
+ "touchend",
620
+ "touchcancel"
621
+ ];
622
+ const interactiveTags = [
623
+ "a",
624
+ "button",
625
+ "input",
626
+ "select",
627
+ "textarea",
628
+ "label",
629
+ "details",
630
+ "summary",
631
+ "dialog",
632
+ "video",
633
+ "audio"
634
+ ];
635
+ const inlineEventAttributes = [
636
+ "onclick",
637
+ "ondblclick",
638
+ "onmousedown",
639
+ "onmouseup",
640
+ "onmouseover",
641
+ "onmouseout",
642
+ "onmousemove",
643
+ "onfocus",
644
+ "onblur",
645
+ "onkeydown",
646
+ "onkeypress",
647
+ "onkeyup",
648
+ "onchange",
649
+ "oninput",
650
+ "onsubmit",
651
+ "onreset",
652
+ "onselect",
653
+ "oncontextmenu",
654
+ "ontouchstart",
655
+ "ontouchmove",
656
+ "ontouchend",
657
+ "ontouchcancel"
658
+ ];
659
+ const interactiveElementsRegistry = /* @__PURE__ */ new WeakSet();
660
+ const originalAddEventListener = EventTarget.prototype.addEventListener;
661
+ EventTarget.prototype.addEventListener = function(type, listener, options) {
662
+ originalAddEventListener.call(this, type, listener, options);
663
+ if (this instanceof Element) {
664
+ const eventType = type.toLowerCase();
665
+ if (interactiveEvents.includes(eventType)) {
666
+ interactiveElementsRegistry.add(this);
667
+ }
668
+ }
669
+ };
670
+ const originalRemoveEventListener = EventTarget.prototype.removeEventListener;
671
+ EventTarget.prototype.removeEventListener = function(type, listener, options) {
672
+ originalRemoveEventListener.call(this, type, listener, options);
673
+ };
643
674
  function hasEventListeners(n) {
644
- return getInteractiveEvents().some((eventType) => {
645
- let hasListener = false;
646
- const testListener = () => {
647
- hasListener = true;
648
- };
649
- n.addEventListener(eventType, testListener);
650
- n.dispatchEvent(new Event(eventType));
651
- n.removeEventListener(eventType, testListener);
652
- return hasListener;
653
- });
675
+ return n instanceof Element && interactiveElementsRegistry.has(n);
654
676
  }
655
677
  function isElementInteractive(n) {
656
678
  var _a;
657
- const allowedTags = getInteractiveTags();
658
679
  if (n.nodeType === Node.ELEMENT_NODE) {
659
680
  const element = n;
660
681
  const tagName = element.tagName.toLowerCase();
661
- if (!allowedTags.includes(tagName)) {
662
- return false;
682
+ if (interactiveTags.includes(tagName)) {
683
+ return true;
663
684
  }
664
685
  const hasTabIndex = element.hasAttribute("tabindex") && element.getAttribute("tabindex") !== "-1";
665
686
  const hasRoleInteractive = ["button", "link", "checkbox", "switch", "menuitem"].includes(
@@ -671,10 +692,28 @@ function isElementInteractive(n) {
671
692
  if (n.nodeType === Node.TEXT_NODE) {
672
693
  const textNode = n;
673
694
  const parentElement2 = textNode.parentElement;
674
- return parentElement2 !== null && allowedTags.includes(parentElement2.tagName.toLowerCase()) && isElementVisible(parentElement2) && ((_a = textNode.textContent) == null ? void 0 : _a.trim().length) !== 0 && isElementInteractive(parentElement2);
695
+ if (parentElement2 !== null && interactiveTags.includes(parentElement2.tagName.toLowerCase())) {
696
+ return true;
697
+ }
698
+ return parentElement2 !== null && isElementVisible(parentElement2) && ((_a = textNode.textContent) == null ? void 0 : _a.trim().length) !== 0 && isElementInteractive(parentElement2);
675
699
  }
676
700
  return false;
677
701
  }
702
+ function inspectInlineEventHandlers() {
703
+ const allElements = document.querySelectorAll("*");
704
+ allElements.forEach((el) => {
705
+ inlineEventAttributes.forEach((attr) => {
706
+ if (el.hasAttribute(attr)) {
707
+ interactiveElementsRegistry.add(el);
708
+ }
709
+ });
710
+ });
711
+ }
712
+ if (document.readyState === "complete" || document.readyState === "interactive") {
713
+ inspectInlineEventHandlers();
714
+ } else {
715
+ document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers);
716
+ }
678
717
  let _id = 1;
679
718
  const tagNameRegex = new RegExp("[^a-z0-9-_:]");
680
719
  const IGNORED_NODE = -2;