@posthog/rrweb-record 0.0.37 → 0.0.38
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/rrweb-record.cjs +92 -81
- package/dist/rrweb-record.cjs.map +1 -1
- package/dist/rrweb-record.js +92 -81
- package/dist/rrweb-record.js.map +1 -1
- package/dist/rrweb-record.umd.cjs +92 -81
- package/dist/rrweb-record.umd.cjs.map +2 -2
- package/dist/rrweb-record.umd.min.cjs +17 -17
- package/dist/rrweb-record.umd.min.cjs.map +3 -3
- package/package.json +4 -4
package/dist/rrweb-record.cjs
CHANGED
|
@@ -16,20 +16,20 @@ var NodeType$1$1 = /* @__PURE__ */ ((NodeType2) => {
|
|
|
16
16
|
NodeType2[NodeType2["Comment"] = 5] = "Comment";
|
|
17
17
|
return NodeType2;
|
|
18
18
|
})(NodeType$1$1 || {});
|
|
19
|
-
const testableAccessors$
|
|
19
|
+
const testableAccessors$2 = {
|
|
20
20
|
Node: ["childNodes", "parentNode", "parentElement", "textContent"],
|
|
21
21
|
ShadowRoot: ["host", "styleSheets"],
|
|
22
22
|
Element: ["shadowRoot", "querySelector", "querySelectorAll"],
|
|
23
23
|
MutationObserver: []
|
|
24
24
|
};
|
|
25
|
-
const testableMethods$
|
|
25
|
+
const testableMethods$2 = {
|
|
26
26
|
Node: ["contains", "getRootNode"],
|
|
27
27
|
ShadowRoot: ["getSelection"],
|
|
28
28
|
Element: [],
|
|
29
29
|
MutationObserver: ["constructor"]
|
|
30
30
|
};
|
|
31
|
-
const untaintedBasePrototype$
|
|
32
|
-
function angularZoneUnpatchedAlternative$
|
|
31
|
+
const untaintedBasePrototype$2 = {};
|
|
32
|
+
function angularZoneUnpatchedAlternative$2(key) {
|
|
33
33
|
var _a2, _b;
|
|
34
34
|
const angularUnpatchedVersionSymbol = (_b = (_a2 = globalThis == null ? void 0 : globalThis.Zone) == null ? void 0 : _a2.__symbol__) == null ? void 0 : _b.call(_a2, key);
|
|
35
35
|
if (angularUnpatchedVersionSymbol && globalThis[angularUnpatchedVersionSymbol]) {
|
|
@@ -38,12 +38,12 @@ function angularZoneUnpatchedAlternative$1(key) {
|
|
|
38
38
|
return void 0;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
function getUntaintedPrototype$
|
|
42
|
-
if (untaintedBasePrototype$
|
|
43
|
-
return untaintedBasePrototype$
|
|
44
|
-
const candidate = angularZoneUnpatchedAlternative$
|
|
41
|
+
function getUntaintedPrototype$2(key) {
|
|
42
|
+
if (untaintedBasePrototype$2[key])
|
|
43
|
+
return untaintedBasePrototype$2[key];
|
|
44
|
+
const candidate = angularZoneUnpatchedAlternative$2(key) || globalThis[key];
|
|
45
45
|
const defaultPrototype = candidate.prototype;
|
|
46
|
-
const accessorNames = key in testableAccessors$
|
|
46
|
+
const accessorNames = key in testableAccessors$2 ? testableAccessors$2[key] : void 0;
|
|
47
47
|
const isUntaintedAccessors = Boolean(
|
|
48
48
|
accessorNames && // @ts-expect-error 2345
|
|
49
49
|
accessorNames.every(
|
|
@@ -55,7 +55,7 @@ function getUntaintedPrototype$1(key) {
|
|
|
55
55
|
}
|
|
56
56
|
)
|
|
57
57
|
);
|
|
58
|
-
const methodNames = key in testableMethods$
|
|
58
|
+
const methodNames = key in testableMethods$2 ? testableMethods$2[key] : void 0;
|
|
59
59
|
const isUntaintedMethods = Boolean(
|
|
60
60
|
methodNames && methodNames.every(
|
|
61
61
|
// @ts-expect-error 2345
|
|
@@ -66,7 +66,7 @@ function getUntaintedPrototype$1(key) {
|
|
|
66
66
|
)
|
|
67
67
|
);
|
|
68
68
|
if (isUntaintedAccessors && isUntaintedMethods) {
|
|
69
|
-
untaintedBasePrototype$
|
|
69
|
+
untaintedBasePrototype$2[key] = candidate.prototype;
|
|
70
70
|
return candidate.prototype;
|
|
71
71
|
}
|
|
72
72
|
try {
|
|
@@ -77,80 +77,80 @@ function getUntaintedPrototype$1(key) {
|
|
|
77
77
|
const untaintedObject = win[key].prototype;
|
|
78
78
|
document.body.removeChild(iframeEl);
|
|
79
79
|
if (!untaintedObject) return defaultPrototype;
|
|
80
|
-
return untaintedBasePrototype$
|
|
80
|
+
return untaintedBasePrototype$2[key] = untaintedObject;
|
|
81
81
|
} catch {
|
|
82
82
|
return defaultPrototype;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
const untaintedAccessorCache$
|
|
86
|
-
function getUntaintedAccessor$
|
|
85
|
+
const untaintedAccessorCache$2 = {};
|
|
86
|
+
function getUntaintedAccessor$2(key, instance, accessor) {
|
|
87
87
|
var _a2;
|
|
88
88
|
const cacheKey = `${key}.${String(accessor)}`;
|
|
89
|
-
if (untaintedAccessorCache$
|
|
90
|
-
return untaintedAccessorCache$
|
|
89
|
+
if (untaintedAccessorCache$2[cacheKey])
|
|
90
|
+
return untaintedAccessorCache$2[cacheKey].call(
|
|
91
91
|
instance
|
|
92
92
|
);
|
|
93
|
-
const untaintedPrototype = getUntaintedPrototype$
|
|
93
|
+
const untaintedPrototype = getUntaintedPrototype$2(key);
|
|
94
94
|
const untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(
|
|
95
95
|
untaintedPrototype,
|
|
96
96
|
accessor
|
|
97
97
|
)) == null ? void 0 : _a2.get;
|
|
98
98
|
if (!untaintedAccessor) return instance[accessor];
|
|
99
|
-
untaintedAccessorCache$
|
|
99
|
+
untaintedAccessorCache$2[cacheKey] = untaintedAccessor;
|
|
100
100
|
return untaintedAccessor.call(instance);
|
|
101
101
|
}
|
|
102
|
-
const untaintedMethodCache$
|
|
103
|
-
function getUntaintedMethod$
|
|
102
|
+
const untaintedMethodCache$2 = {};
|
|
103
|
+
function getUntaintedMethod$2(key, instance, method) {
|
|
104
104
|
const cacheKey = `${key}.${String(method)}`;
|
|
105
|
-
if (untaintedMethodCache$
|
|
106
|
-
return untaintedMethodCache$
|
|
105
|
+
if (untaintedMethodCache$2[cacheKey])
|
|
106
|
+
return untaintedMethodCache$2[cacheKey].bind(
|
|
107
107
|
instance
|
|
108
108
|
);
|
|
109
|
-
const untaintedPrototype = getUntaintedPrototype$
|
|
109
|
+
const untaintedPrototype = getUntaintedPrototype$2(key);
|
|
110
110
|
const untaintedMethod = untaintedPrototype[method];
|
|
111
111
|
if (typeof untaintedMethod !== "function") return instance[method];
|
|
112
|
-
untaintedMethodCache$
|
|
112
|
+
untaintedMethodCache$2[cacheKey] = untaintedMethod;
|
|
113
113
|
return untaintedMethod.bind(instance);
|
|
114
114
|
}
|
|
115
|
-
function childNodes$
|
|
116
|
-
return getUntaintedAccessor$
|
|
115
|
+
function childNodes$2(n2) {
|
|
116
|
+
return getUntaintedAccessor$2("Node", n2, "childNodes");
|
|
117
117
|
}
|
|
118
|
-
function parentNode$
|
|
119
|
-
return getUntaintedAccessor$
|
|
118
|
+
function parentNode$2(n2) {
|
|
119
|
+
return getUntaintedAccessor$2("Node", n2, "parentNode");
|
|
120
120
|
}
|
|
121
|
-
function parentElement$
|
|
122
|
-
return getUntaintedAccessor$
|
|
121
|
+
function parentElement$2(n2) {
|
|
122
|
+
return getUntaintedAccessor$2("Node", n2, "parentElement");
|
|
123
123
|
}
|
|
124
|
-
function textContent$
|
|
125
|
-
return getUntaintedAccessor$
|
|
124
|
+
function textContent$2(n2) {
|
|
125
|
+
return getUntaintedAccessor$2("Node", n2, "textContent");
|
|
126
126
|
}
|
|
127
|
-
function contains$
|
|
128
|
-
return getUntaintedMethod$
|
|
127
|
+
function contains$2(n2, other) {
|
|
128
|
+
return getUntaintedMethod$2("Node", n2, "contains")(other);
|
|
129
129
|
}
|
|
130
|
-
function getRootNode$
|
|
131
|
-
return getUntaintedMethod$
|
|
130
|
+
function getRootNode$2(n2) {
|
|
131
|
+
return getUntaintedMethod$2("Node", n2, "getRootNode")();
|
|
132
132
|
}
|
|
133
|
-
function host$
|
|
133
|
+
function host$2(n2) {
|
|
134
134
|
if (!n2 || !("host" in n2)) return null;
|
|
135
|
-
return getUntaintedAccessor$
|
|
135
|
+
return getUntaintedAccessor$2("ShadowRoot", n2, "host");
|
|
136
136
|
}
|
|
137
|
-
function styleSheets$
|
|
137
|
+
function styleSheets$2(n2) {
|
|
138
138
|
return n2.styleSheets;
|
|
139
139
|
}
|
|
140
|
-
function shadowRoot$
|
|
140
|
+
function shadowRoot$2(n2) {
|
|
141
141
|
if (!n2 || !("shadowRoot" in n2)) return null;
|
|
142
|
-
return getUntaintedAccessor$
|
|
142
|
+
return getUntaintedAccessor$2("Element", n2, "shadowRoot");
|
|
143
143
|
}
|
|
144
|
-
function querySelector$
|
|
145
|
-
return getUntaintedAccessor$
|
|
144
|
+
function querySelector$2(n2, selectors) {
|
|
145
|
+
return getUntaintedAccessor$2("Element", n2, "querySelector")(selectors);
|
|
146
146
|
}
|
|
147
|
-
function querySelectorAll$
|
|
148
|
-
return getUntaintedAccessor$
|
|
147
|
+
function querySelectorAll$2(n2, selectors) {
|
|
148
|
+
return getUntaintedAccessor$2("Element", n2, "querySelectorAll")(selectors);
|
|
149
149
|
}
|
|
150
|
-
function mutationObserverCtor$
|
|
151
|
-
return getUntaintedPrototype$
|
|
150
|
+
function mutationObserverCtor$2() {
|
|
151
|
+
return getUntaintedPrototype$2("MutationObserver").constructor;
|
|
152
152
|
}
|
|
153
|
-
function patch$
|
|
153
|
+
function patch$2(source, name, replacement) {
|
|
154
154
|
try {
|
|
155
155
|
if (!(name in source)) {
|
|
156
156
|
return () => {
|
|
@@ -176,32 +176,32 @@ function patch$1(source, name, replacement) {
|
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
const index$
|
|
180
|
-
childNodes: childNodes$
|
|
181
|
-
parentNode: parentNode$
|
|
182
|
-
parentElement: parentElement$
|
|
183
|
-
textContent: textContent$
|
|
184
|
-
contains: contains$
|
|
185
|
-
getRootNode: getRootNode$
|
|
186
|
-
host: host$
|
|
187
|
-
styleSheets: styleSheets$
|
|
188
|
-
shadowRoot: shadowRoot$
|
|
189
|
-
querySelector: querySelector$
|
|
190
|
-
querySelectorAll: querySelectorAll$
|
|
191
|
-
mutationObserver: mutationObserverCtor$
|
|
192
|
-
patch: patch$
|
|
179
|
+
const index$2 = {
|
|
180
|
+
childNodes: childNodes$2,
|
|
181
|
+
parentNode: parentNode$2,
|
|
182
|
+
parentElement: parentElement$2,
|
|
183
|
+
textContent: textContent$2,
|
|
184
|
+
contains: contains$2,
|
|
185
|
+
getRootNode: getRootNode$2,
|
|
186
|
+
host: host$2,
|
|
187
|
+
styleSheets: styleSheets$2,
|
|
188
|
+
shadowRoot: shadowRoot$2,
|
|
189
|
+
querySelector: querySelector$2,
|
|
190
|
+
querySelectorAll: querySelectorAll$2,
|
|
191
|
+
mutationObserver: mutationObserverCtor$2,
|
|
192
|
+
patch: patch$2
|
|
193
193
|
};
|
|
194
|
-
function isElement(n2) {
|
|
194
|
+
function isElement$1(n2) {
|
|
195
195
|
return n2.nodeType === n2.ELEMENT_NODE;
|
|
196
196
|
}
|
|
197
197
|
function isShadowRoot(n2) {
|
|
198
198
|
const hostEl = (
|
|
199
199
|
// anchor and textarea elements also have a `host` property
|
|
200
200
|
// but only shadow roots have a `mode` property
|
|
201
|
-
n2 && "host" in n2 && "mode" in n2 && index$
|
|
201
|
+
n2 && "host" in n2 && "mode" in n2 && index$2.host(n2) || null
|
|
202
202
|
);
|
|
203
203
|
return Boolean(
|
|
204
|
-
hostEl && "shadowRoot" in hostEl && index$
|
|
204
|
+
hostEl && "shadowRoot" in hostEl && index$2.shadowRoot(hostEl) === n2
|
|
205
205
|
);
|
|
206
206
|
}
|
|
207
207
|
function isNativeShadowDom(shadowRoot2) {
|
|
@@ -322,6 +322,17 @@ class Mirror {
|
|
|
322
322
|
(childNode) => this.removeNodeFromMap(childNode)
|
|
323
323
|
);
|
|
324
324
|
}
|
|
325
|
+
if (isElement$1(n2)) {
|
|
326
|
+
const shadowRootEl = index$2.shadowRoot(n2);
|
|
327
|
+
if (shadowRootEl) {
|
|
328
|
+
this.removeNodeFromMap(shadowRootEl);
|
|
329
|
+
}
|
|
330
|
+
if (n2.nodeName === "IFRAME" && n2.contentDocument) {
|
|
331
|
+
this.removeNodeFromMap(
|
|
332
|
+
n2.contentDocument
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
325
336
|
}
|
|
326
337
|
has(id) {
|
|
327
338
|
return this.idNodeMap.has(id);
|
|
@@ -657,7 +668,7 @@ function classMatchesRegex(node2, regex, checkAncestors) {
|
|
|
657
668
|
if (!node2) return false;
|
|
658
669
|
if (node2.nodeType !== node2.ELEMENT_NODE) {
|
|
659
670
|
if (!checkAncestors) return false;
|
|
660
|
-
return classMatchesRegex(index$
|
|
671
|
+
return classMatchesRegex(index$2.parentNode(node2), regex, checkAncestors);
|
|
661
672
|
}
|
|
662
673
|
for (let eIndex = node2.classList.length; eIndex--; ) {
|
|
663
674
|
const className = node2.classList[eIndex];
|
|
@@ -666,19 +677,19 @@ function classMatchesRegex(node2, regex, checkAncestors) {
|
|
|
666
677
|
}
|
|
667
678
|
}
|
|
668
679
|
if (!checkAncestors) return false;
|
|
669
|
-
return classMatchesRegex(index$
|
|
680
|
+
return classMatchesRegex(index$2.parentNode(node2), regex, checkAncestors);
|
|
670
681
|
}
|
|
671
682
|
function needMaskingText(node2, maskTextClass, maskTextSelector, checkAncestors) {
|
|
672
683
|
let el;
|
|
673
|
-
if (isElement(node2)) {
|
|
684
|
+
if (isElement$1(node2)) {
|
|
674
685
|
el = node2;
|
|
675
|
-
if (!index$
|
|
686
|
+
if (!index$2.childNodes(el).length) {
|
|
676
687
|
return false;
|
|
677
688
|
}
|
|
678
|
-
} else if (index$
|
|
689
|
+
} else if (index$2.parentElement(node2) === null) {
|
|
679
690
|
return false;
|
|
680
691
|
} else {
|
|
681
|
-
el = index$
|
|
692
|
+
el = index$2.parentElement(node2);
|
|
682
693
|
}
|
|
683
694
|
try {
|
|
684
695
|
if (typeof maskTextClass === "string") {
|
|
@@ -827,7 +838,7 @@ function serializeNode(n2, options) {
|
|
|
827
838
|
case n2.COMMENT_NODE:
|
|
828
839
|
return {
|
|
829
840
|
type: NodeType$1$1.Comment,
|
|
830
|
-
textContent: index$
|
|
841
|
+
textContent: index$2.textContent(n2) || "",
|
|
831
842
|
rootId
|
|
832
843
|
};
|
|
833
844
|
default:
|
|
@@ -842,9 +853,9 @@ function getRootId(doc, mirror2) {
|
|
|
842
853
|
function serializeTextNode(n2, options) {
|
|
843
854
|
var _a2;
|
|
844
855
|
const { needsMask, maskTextFn, rootId } = options;
|
|
845
|
-
const parent = index$
|
|
856
|
+
const parent = index$2.parentNode(n2);
|
|
846
857
|
const parentTagName = parent && parent.tagName;
|
|
847
|
-
let text = index$
|
|
858
|
+
let text = index$2.textContent(n2);
|
|
848
859
|
const isStyle = parentTagName === "STYLE" ? true : void 0;
|
|
849
860
|
const isScript = parentTagName === "SCRIPT" ? true : void 0;
|
|
850
861
|
if (isStyle && text) {
|
|
@@ -865,7 +876,7 @@ function serializeTextNode(n2, options) {
|
|
|
865
876
|
text = "SCRIPT_PLACEHOLDER";
|
|
866
877
|
}
|
|
867
878
|
if (!isStyle && !isScript && text && needsMask) {
|
|
868
|
-
text = maskTextFn ? maskTextFn(text, index$
|
|
879
|
+
text = maskTextFn ? maskTextFn(text, index$2.parentElement(n2)) : text.replace(/[\S]/g, "*");
|
|
869
880
|
}
|
|
870
881
|
return {
|
|
871
882
|
type: NodeType$1$1.Text,
|
|
@@ -935,7 +946,7 @@ function serializeElementNode(n2, options) {
|
|
|
935
946
|
}
|
|
936
947
|
}
|
|
937
948
|
if (tagName === "style" && n2.sheet && // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element
|
|
938
|
-
!(n2.innerText || index$
|
|
949
|
+
!(n2.innerText || index$2.textContent(n2) || "").trim().length) {
|
|
939
950
|
const cssText = stringifyStylesheet(
|
|
940
951
|
n2.sheet
|
|
941
952
|
);
|
|
@@ -1201,7 +1212,7 @@ function serializeNodeWithId(n2, options) {
|
|
|
1201
1212
|
if (serializedNode.type === NodeType$1$1.Element) {
|
|
1202
1213
|
recordChild = recordChild && !serializedNode.needBlock;
|
|
1203
1214
|
delete serializedNode.needBlock;
|
|
1204
|
-
const shadowRootEl = index$
|
|
1215
|
+
const shadowRootEl = index$2.shadowRoot(n2);
|
|
1205
1216
|
if (shadowRootEl && isNativeShadowDom(shadowRootEl))
|
|
1206
1217
|
serializedNode.isShadowHost = true;
|
|
1207
1218
|
}
|
|
@@ -1236,7 +1247,7 @@ function serializeNodeWithId(n2, options) {
|
|
|
1236
1247
|
};
|
|
1237
1248
|
if (serializedNode.type === NodeType$1$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
|
|
1238
1249
|
else {
|
|
1239
|
-
for (const childN of Array.from(index$
|
|
1250
|
+
for (const childN of Array.from(index$2.childNodes(n2))) {
|
|
1240
1251
|
const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
1241
1252
|
if (serializedChildNode) {
|
|
1242
1253
|
serializedNode.childNodes.push(serializedChildNode);
|
|
@@ -1244,8 +1255,8 @@ function serializeNodeWithId(n2, options) {
|
|
|
1244
1255
|
}
|
|
1245
1256
|
}
|
|
1246
1257
|
let shadowRootEl = null;
|
|
1247
|
-
if (isElement(n2) && (shadowRootEl = index$
|
|
1248
|
-
for (const childN of Array.from(index$
|
|
1258
|
+
if (isElement$1(n2) && (shadowRootEl = index$2.shadowRoot(n2))) {
|
|
1259
|
+
for (const childN of Array.from(index$2.childNodes(shadowRootEl))) {
|
|
1249
1260
|
const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
1250
1261
|
if (serializedChildNode) {
|
|
1251
1262
|
isNativeShadowDom(shadowRootEl) && (serializedChildNode.isShadow = true);
|
|
@@ -1254,7 +1265,7 @@ function serializeNodeWithId(n2, options) {
|
|
|
1254
1265
|
}
|
|
1255
1266
|
}
|
|
1256
1267
|
}
|
|
1257
|
-
const parent = index$
|
|
1268
|
+
const parent = index$2.parentNode(n2);
|
|
1258
1269
|
if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
|
|
1259
1270
|
serializedNode.isShadow = true;
|
|
1260
1271
|
}
|