@appsurify-testmap/rrweb-snapshot 2.0.0-alpha.23 → 2.0.0-alpha.24
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/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/rrweb-snapshot.cjs +179 -93
- package/dist/rrweb-snapshot.cjs.map +1 -1
- package/dist/rrweb-snapshot.js +179 -93
- package/dist/rrweb-snapshot.js.map +1 -1
- package/dist/rrweb-snapshot.umd.cjs +179 -93
- package/dist/rrweb-snapshot.umd.cjs.map +3 -3
- package/dist/rrweb-snapshot.umd.min.cjs +16 -16
- package/dist/rrweb-snapshot.umd.min.cjs.map +3 -3
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -72,6 +72,8 @@ export declare function isCSSStyleRule(rule: CSSRule): rule is CSSStyleRule;
|
|
|
72
72
|
|
|
73
73
|
export declare function isElement(n: Node): n is Element;
|
|
74
74
|
|
|
75
|
+
export declare function isElementInteractive(n: Node): boolean;
|
|
76
|
+
|
|
75
77
|
export declare function isElementVisible(n: Element): boolean;
|
|
76
78
|
|
|
77
79
|
export declare function isNativeShadowDom(shadowRoot: ShadowRoot): boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -72,6 +72,8 @@ export declare function isCSSStyleRule(rule: CSSRule): rule is CSSStyleRule;
|
|
|
72
72
|
|
|
73
73
|
export declare function isElement(n: Node): n is Element;
|
|
74
74
|
|
|
75
|
+
export declare function isElementInteractive(n: Node): boolean;
|
|
76
|
+
|
|
75
77
|
export declare function isElementVisible(n: Element): boolean;
|
|
76
78
|
|
|
77
79
|
export declare function isNativeShadowDom(shadowRoot: ShadowRoot): boolean;
|
package/dist/rrweb-snapshot.cjs
CHANGED
|
@@ -3,6 +3,46 @@ 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 || {});
|
|
6
46
|
var NodeType = /* @__PURE__ */ ((NodeType2) => {
|
|
7
47
|
NodeType2[NodeType2["Document"] = 0] = "Document";
|
|
8
48
|
NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
|
|
@@ -154,99 +194,6 @@ const index = {
|
|
|
154
194
|
querySelectorAll,
|
|
155
195
|
mutationObserver: mutationObserverCtor
|
|
156
196
|
};
|
|
157
|
-
function getXPath(node2) {
|
|
158
|
-
if (node2.nodeType === Node.DOCUMENT_NODE) {
|
|
159
|
-
return "/";
|
|
160
|
-
}
|
|
161
|
-
if (node2.nodeType === Node.DOCUMENT_TYPE_NODE) {
|
|
162
|
-
return "/html/doctype";
|
|
163
|
-
}
|
|
164
|
-
if (node2.nodeType === Node.ELEMENT_NODE) {
|
|
165
|
-
const element = node2;
|
|
166
|
-
if (element.id) {
|
|
167
|
-
return `//*[@id="${element.id}"]`;
|
|
168
|
-
}
|
|
169
|
-
if (element.tagName && element.tagName.toLowerCase() === "html") {
|
|
170
|
-
return "/html";
|
|
171
|
-
}
|
|
172
|
-
if (element === document.head) {
|
|
173
|
-
return "/html/head";
|
|
174
|
-
}
|
|
175
|
-
if (element === document.body) {
|
|
176
|
-
return "/html/body";
|
|
177
|
-
}
|
|
178
|
-
const parentNode2 = element.parentNode;
|
|
179
|
-
if (!parentNode2 || !(parentNode2 instanceof Element)) {
|
|
180
|
-
return "";
|
|
181
|
-
}
|
|
182
|
-
const siblings = Array.from(parentNode2.children).filter(
|
|
183
|
-
(sibling) => sibling.tagName === element.tagName
|
|
184
|
-
);
|
|
185
|
-
const index2 = siblings.length > 1 ? `[${siblings.indexOf(element) + 1}]` : "";
|
|
186
|
-
return `${getXPath(parentNode2)}/${element.tagName.toLowerCase()}${index2}`;
|
|
187
|
-
}
|
|
188
|
-
if (node2.nodeType === Node.TEXT_NODE) {
|
|
189
|
-
const parent = node2.parentNode;
|
|
190
|
-
if (!parent) {
|
|
191
|
-
return "";
|
|
192
|
-
}
|
|
193
|
-
const textSiblings = Array.from(parent.childNodes).filter(
|
|
194
|
-
(sibling) => sibling.nodeType === Node.TEXT_NODE
|
|
195
|
-
);
|
|
196
|
-
const index2 = textSiblings.length > 1 ? `[${textSiblings.indexOf(node2) + 1}]` : "";
|
|
197
|
-
return `${getXPath(parent)}/text()${index2}`;
|
|
198
|
-
}
|
|
199
|
-
if (node2.nodeType === Node.CDATA_SECTION_NODE) {
|
|
200
|
-
const parent = node2.parentNode;
|
|
201
|
-
if (!parent) {
|
|
202
|
-
return "";
|
|
203
|
-
}
|
|
204
|
-
const cdataSiblings = Array.from(parent.childNodes).filter(
|
|
205
|
-
(sibling) => sibling.nodeType === Node.CDATA_SECTION_NODE
|
|
206
|
-
);
|
|
207
|
-
const index2 = cdataSiblings.length > 1 ? `[${cdataSiblings.indexOf(node2) + 1}]` : "";
|
|
208
|
-
return `${getXPath(parent)}/text()${index2}`;
|
|
209
|
-
}
|
|
210
|
-
if (node2.nodeType === Node.COMMENT_NODE) {
|
|
211
|
-
const parent = node2.parentNode;
|
|
212
|
-
if (!parent) {
|
|
213
|
-
return "";
|
|
214
|
-
}
|
|
215
|
-
const commentSiblings = Array.from(parent.childNodes).filter(
|
|
216
|
-
(sibling) => sibling.nodeType === Node.COMMENT_NODE
|
|
217
|
-
);
|
|
218
|
-
const index2 = commentSiblings.length > 1 ? `[${commentSiblings.indexOf(node2) + 1}]` : "";
|
|
219
|
-
return `${getXPath(parent)}/comment()${index2}`;
|
|
220
|
-
}
|
|
221
|
-
return "";
|
|
222
|
-
}
|
|
223
|
-
function isElement(n) {
|
|
224
|
-
return n.nodeType === n.ELEMENT_NODE;
|
|
225
|
-
}
|
|
226
|
-
function isTextVisible(n) {
|
|
227
|
-
var _a;
|
|
228
|
-
const parent = index.parentNode(n);
|
|
229
|
-
const parentElement2 = parent && parent;
|
|
230
|
-
if (!parentElement2) {
|
|
231
|
-
return false;
|
|
232
|
-
}
|
|
233
|
-
const isParentVisible = isElementVisible(parentElement2);
|
|
234
|
-
if (!isParentVisible) {
|
|
235
|
-
return false;
|
|
236
|
-
}
|
|
237
|
-
const textContent2 = (_a = n.textContent) == null ? void 0 : _a.trim();
|
|
238
|
-
return textContent2 !== "";
|
|
239
|
-
}
|
|
240
|
-
function isElementVisible(n) {
|
|
241
|
-
return isStyleVisible(n) && isRectVisible(n.getBoundingClientRect());
|
|
242
|
-
}
|
|
243
|
-
function isStyleVisible(n) {
|
|
244
|
-
const style = window.getComputedStyle(n);
|
|
245
|
-
return style.display !== "none" && style.visibility !== "hidden" && parseFloat(style.opacity) !== 0;
|
|
246
|
-
}
|
|
247
|
-
function isRectVisible(rect) {
|
|
248
|
-
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);
|
|
249
|
-
}
|
|
250
197
|
function isShadowRoot(n) {
|
|
251
198
|
const hostEl = (
|
|
252
199
|
// anchor and textarea elements also have a `host` property
|
|
@@ -594,6 +541,140 @@ function splitCssText(cssText, style) {
|
|
|
594
541
|
function markCssSplits(cssText, style) {
|
|
595
542
|
return splitCssText(cssText, style).join("/* rr_split */");
|
|
596
543
|
}
|
|
544
|
+
function getXPath(node2) {
|
|
545
|
+
if (node2.nodeType === Node.DOCUMENT_NODE) {
|
|
546
|
+
return "/";
|
|
547
|
+
}
|
|
548
|
+
if (node2.nodeType === Node.DOCUMENT_TYPE_NODE) {
|
|
549
|
+
return "/html/doctype";
|
|
550
|
+
}
|
|
551
|
+
if (node2.nodeType === Node.ELEMENT_NODE) {
|
|
552
|
+
const element = node2;
|
|
553
|
+
if (element.id) {
|
|
554
|
+
return `//*[@id="${element.id}"]`;
|
|
555
|
+
}
|
|
556
|
+
if (element.tagName && element.tagName.toLowerCase() === "html") {
|
|
557
|
+
return "/html";
|
|
558
|
+
}
|
|
559
|
+
if (element === document.head) {
|
|
560
|
+
return "/html/head";
|
|
561
|
+
}
|
|
562
|
+
if (element === document.body) {
|
|
563
|
+
return "/html/body";
|
|
564
|
+
}
|
|
565
|
+
const parentNode2 = element.parentNode;
|
|
566
|
+
if (!parentNode2 || !(parentNode2 instanceof Element)) {
|
|
567
|
+
return "";
|
|
568
|
+
}
|
|
569
|
+
const siblings = Array.from(parentNode2.children).filter(
|
|
570
|
+
(sibling) => sibling.tagName === element.tagName
|
|
571
|
+
);
|
|
572
|
+
const index2 = siblings.length > 1 ? `[${siblings.indexOf(element) + 1}]` : "";
|
|
573
|
+
return `${getXPath(parentNode2)}/${element.tagName.toLowerCase()}${index2}`;
|
|
574
|
+
}
|
|
575
|
+
if (node2.nodeType === Node.TEXT_NODE) {
|
|
576
|
+
const parent = node2.parentNode;
|
|
577
|
+
if (!parent) {
|
|
578
|
+
return "";
|
|
579
|
+
}
|
|
580
|
+
const textSiblings = Array.from(parent.childNodes).filter(
|
|
581
|
+
(sibling) => sibling.nodeType === Node.TEXT_NODE
|
|
582
|
+
);
|
|
583
|
+
const index2 = textSiblings.length > 1 ? `[${textSiblings.indexOf(node2) + 1}]` : "";
|
|
584
|
+
return `${getXPath(parent)}/text()${index2}`;
|
|
585
|
+
}
|
|
586
|
+
if (node2.nodeType === Node.CDATA_SECTION_NODE) {
|
|
587
|
+
const parent = node2.parentNode;
|
|
588
|
+
if (!parent) {
|
|
589
|
+
return "";
|
|
590
|
+
}
|
|
591
|
+
const cdataSiblings = Array.from(parent.childNodes).filter(
|
|
592
|
+
(sibling) => sibling.nodeType === Node.CDATA_SECTION_NODE
|
|
593
|
+
);
|
|
594
|
+
const index2 = cdataSiblings.length > 1 ? `[${cdataSiblings.indexOf(node2) + 1}]` : "";
|
|
595
|
+
return `${getXPath(parent)}/text()${index2}`;
|
|
596
|
+
}
|
|
597
|
+
if (node2.nodeType === Node.COMMENT_NODE) {
|
|
598
|
+
const parent = node2.parentNode;
|
|
599
|
+
if (!parent) {
|
|
600
|
+
return "";
|
|
601
|
+
}
|
|
602
|
+
const commentSiblings = Array.from(parent.childNodes).filter(
|
|
603
|
+
(sibling) => sibling.nodeType === Node.COMMENT_NODE
|
|
604
|
+
);
|
|
605
|
+
const index2 = commentSiblings.length > 1 ? `[${commentSiblings.indexOf(node2) + 1}]` : "";
|
|
606
|
+
return `${getXPath(parent)}/comment()${index2}`;
|
|
607
|
+
}
|
|
608
|
+
return "";
|
|
609
|
+
}
|
|
610
|
+
function isElement(n) {
|
|
611
|
+
return n.nodeType === n.ELEMENT_NODE;
|
|
612
|
+
}
|
|
613
|
+
function isTextVisible(n) {
|
|
614
|
+
var _a;
|
|
615
|
+
const parent = index.parentNode(n);
|
|
616
|
+
const parentElement2 = parent && parent;
|
|
617
|
+
if (!parentElement2) {
|
|
618
|
+
return false;
|
|
619
|
+
}
|
|
620
|
+
const isParentVisible = isElementVisible(parentElement2);
|
|
621
|
+
if (!isParentVisible) {
|
|
622
|
+
return false;
|
|
623
|
+
}
|
|
624
|
+
const textContent2 = (_a = n.textContent) == null ? void 0 : _a.trim();
|
|
625
|
+
return textContent2 !== "";
|
|
626
|
+
}
|
|
627
|
+
function isElementVisible(n) {
|
|
628
|
+
return isStyleVisible(n) && isRectVisible(n.getBoundingClientRect());
|
|
629
|
+
}
|
|
630
|
+
function isStyleVisible(n) {
|
|
631
|
+
const style = window.getComputedStyle(n);
|
|
632
|
+
return style.display !== "none" && style.visibility !== "hidden" && parseFloat(style.opacity) !== 0;
|
|
633
|
+
}
|
|
634
|
+
function isRectVisible(rect) {
|
|
635
|
+
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
|
+
}
|
|
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
|
+
}
|
|
643
|
+
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
|
+
});
|
|
654
|
+
}
|
|
655
|
+
function isElementInteractive(n) {
|
|
656
|
+
var _a;
|
|
657
|
+
const allowedTags = getInteractiveTags();
|
|
658
|
+
if (n.nodeType === Node.ELEMENT_NODE) {
|
|
659
|
+
const element = n;
|
|
660
|
+
const tagName = element.tagName.toLowerCase();
|
|
661
|
+
if (!allowedTags.includes(tagName)) {
|
|
662
|
+
return false;
|
|
663
|
+
}
|
|
664
|
+
const hasTabIndex = element.hasAttribute("tabindex") && element.getAttribute("tabindex") !== "-1";
|
|
665
|
+
const hasRoleInteractive = ["button", "link", "checkbox", "switch", "menuitem"].includes(
|
|
666
|
+
element.getAttribute("role") || ""
|
|
667
|
+
);
|
|
668
|
+
const result2 = hasEventListeners(element) || hasTabIndex || hasRoleInteractive || element instanceof HTMLAnchorElement && element.hasAttribute("href") || element instanceof HTMLButtonElement && !element.disabled;
|
|
669
|
+
return result2;
|
|
670
|
+
}
|
|
671
|
+
if (n.nodeType === Node.TEXT_NODE) {
|
|
672
|
+
const textNode = n;
|
|
673
|
+
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);
|
|
675
|
+
}
|
|
676
|
+
return false;
|
|
677
|
+
}
|
|
597
678
|
let _id = 1;
|
|
598
679
|
const tagNameRegex = new RegExp("[^a-z0-9-_:]");
|
|
599
680
|
const IGNORED_NODE = -2;
|
|
@@ -949,11 +1030,13 @@ function serializeTextNode(n, options) {
|
|
|
949
1030
|
textContent2 = maskTextFn ? maskTextFn(textContent2, index.parentElement(n)) : textContent2.replace(/[\S]/g, "*");
|
|
950
1031
|
}
|
|
951
1032
|
const isVisible = isTextVisible(n);
|
|
1033
|
+
const isInteractive = isElementInteractive(n);
|
|
952
1034
|
return {
|
|
953
1035
|
type: NodeType.Text,
|
|
954
1036
|
textContent: textContent2 || "",
|
|
955
1037
|
rootId,
|
|
956
1038
|
isVisible,
|
|
1039
|
+
isInteractive,
|
|
957
1040
|
xPath
|
|
958
1041
|
};
|
|
959
1042
|
}
|
|
@@ -1139,6 +1222,7 @@ function serializeElementNode(n, options) {
|
|
|
1139
1222
|
} catch (e) {
|
|
1140
1223
|
}
|
|
1141
1224
|
const isVisible = isElementVisible(n);
|
|
1225
|
+
const isInteractive = isElementInteractive(n);
|
|
1142
1226
|
return {
|
|
1143
1227
|
type: NodeType.Element,
|
|
1144
1228
|
tagName,
|
|
@@ -1149,6 +1233,7 @@ function serializeElementNode(n, options) {
|
|
|
1149
1233
|
rootId,
|
|
1150
1234
|
isCustom: isCustomElement,
|
|
1151
1235
|
isVisible,
|
|
1236
|
+
isInteractive,
|
|
1152
1237
|
xPath
|
|
1153
1238
|
};
|
|
1154
1239
|
}
|
|
@@ -5499,6 +5584,7 @@ exports.is2DCanvasBlank = is2DCanvasBlank;
|
|
|
5499
5584
|
exports.isCSSImportRule = isCSSImportRule;
|
|
5500
5585
|
exports.isCSSStyleRule = isCSSStyleRule;
|
|
5501
5586
|
exports.isElement = isElement;
|
|
5587
|
+
exports.isElementInteractive = isElementInteractive;
|
|
5502
5588
|
exports.isElementVisible = isElementVisible;
|
|
5503
5589
|
exports.isNativeShadowDom = isNativeShadowDom;
|
|
5504
5590
|
exports.isNodeMetaEqual = isNodeMetaEqual;
|