@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
|
@@ -48,20 +48,20 @@ var NodeType$1$1 = /* @__PURE__ */ ((NodeType2) => {
|
|
|
48
48
|
NodeType2[NodeType2["Comment"] = 5] = "Comment";
|
|
49
49
|
return NodeType2;
|
|
50
50
|
})(NodeType$1$1 || {});
|
|
51
|
-
const testableAccessors$
|
|
51
|
+
const testableAccessors$2 = {
|
|
52
52
|
Node: ["childNodes", "parentNode", "parentElement", "textContent"],
|
|
53
53
|
ShadowRoot: ["host", "styleSheets"],
|
|
54
54
|
Element: ["shadowRoot", "querySelector", "querySelectorAll"],
|
|
55
55
|
MutationObserver: []
|
|
56
56
|
};
|
|
57
|
-
const testableMethods$
|
|
57
|
+
const testableMethods$2 = {
|
|
58
58
|
Node: ["contains", "getRootNode"],
|
|
59
59
|
ShadowRoot: ["getSelection"],
|
|
60
60
|
Element: [],
|
|
61
61
|
MutationObserver: ["constructor"]
|
|
62
62
|
};
|
|
63
|
-
const untaintedBasePrototype$
|
|
64
|
-
function angularZoneUnpatchedAlternative$
|
|
63
|
+
const untaintedBasePrototype$2 = {};
|
|
64
|
+
function angularZoneUnpatchedAlternative$2(key) {
|
|
65
65
|
var _a2, _b;
|
|
66
66
|
const angularUnpatchedVersionSymbol = (_b = (_a2 = globalThis == null ? void 0 : globalThis.Zone) == null ? void 0 : _a2.__symbol__) == null ? void 0 : _b.call(_a2, key);
|
|
67
67
|
if (angularUnpatchedVersionSymbol && globalThis[angularUnpatchedVersionSymbol]) {
|
|
@@ -70,12 +70,12 @@ function angularZoneUnpatchedAlternative$1(key) {
|
|
|
70
70
|
return void 0;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
function getUntaintedPrototype$
|
|
74
|
-
if (untaintedBasePrototype$
|
|
75
|
-
return untaintedBasePrototype$
|
|
76
|
-
const candidate = angularZoneUnpatchedAlternative$
|
|
73
|
+
function getUntaintedPrototype$2(key) {
|
|
74
|
+
if (untaintedBasePrototype$2[key])
|
|
75
|
+
return untaintedBasePrototype$2[key];
|
|
76
|
+
const candidate = angularZoneUnpatchedAlternative$2(key) || globalThis[key];
|
|
77
77
|
const defaultPrototype = candidate.prototype;
|
|
78
|
-
const accessorNames = key in testableAccessors$
|
|
78
|
+
const accessorNames = key in testableAccessors$2 ? testableAccessors$2[key] : void 0;
|
|
79
79
|
const isUntaintedAccessors = Boolean(
|
|
80
80
|
accessorNames && // @ts-expect-error 2345
|
|
81
81
|
accessorNames.every(
|
|
@@ -87,7 +87,7 @@ function getUntaintedPrototype$1(key) {
|
|
|
87
87
|
}
|
|
88
88
|
)
|
|
89
89
|
);
|
|
90
|
-
const methodNames = key in testableMethods$
|
|
90
|
+
const methodNames = key in testableMethods$2 ? testableMethods$2[key] : void 0;
|
|
91
91
|
const isUntaintedMethods = Boolean(
|
|
92
92
|
methodNames && methodNames.every(
|
|
93
93
|
// @ts-expect-error 2345
|
|
@@ -98,7 +98,7 @@ function getUntaintedPrototype$1(key) {
|
|
|
98
98
|
)
|
|
99
99
|
);
|
|
100
100
|
if (isUntaintedAccessors && isUntaintedMethods) {
|
|
101
|
-
untaintedBasePrototype$
|
|
101
|
+
untaintedBasePrototype$2[key] = candidate.prototype;
|
|
102
102
|
return candidate.prototype;
|
|
103
103
|
}
|
|
104
104
|
try {
|
|
@@ -109,80 +109,80 @@ function getUntaintedPrototype$1(key) {
|
|
|
109
109
|
const untaintedObject = win[key].prototype;
|
|
110
110
|
document.body.removeChild(iframeEl);
|
|
111
111
|
if (!untaintedObject) return defaultPrototype;
|
|
112
|
-
return untaintedBasePrototype$
|
|
112
|
+
return untaintedBasePrototype$2[key] = untaintedObject;
|
|
113
113
|
} catch (e) {
|
|
114
114
|
return defaultPrototype;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
const untaintedAccessorCache$
|
|
118
|
-
function getUntaintedAccessor$
|
|
117
|
+
const untaintedAccessorCache$2 = {};
|
|
118
|
+
function getUntaintedAccessor$2(key, instance, accessor) {
|
|
119
119
|
var _a2;
|
|
120
120
|
const cacheKey = `${key}.${String(accessor)}`;
|
|
121
|
-
if (untaintedAccessorCache$
|
|
122
|
-
return untaintedAccessorCache$
|
|
121
|
+
if (untaintedAccessorCache$2[cacheKey])
|
|
122
|
+
return untaintedAccessorCache$2[cacheKey].call(
|
|
123
123
|
instance
|
|
124
124
|
);
|
|
125
|
-
const untaintedPrototype = getUntaintedPrototype$
|
|
125
|
+
const untaintedPrototype = getUntaintedPrototype$2(key);
|
|
126
126
|
const untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(
|
|
127
127
|
untaintedPrototype,
|
|
128
128
|
accessor
|
|
129
129
|
)) == null ? void 0 : _a2.get;
|
|
130
130
|
if (!untaintedAccessor) return instance[accessor];
|
|
131
|
-
untaintedAccessorCache$
|
|
131
|
+
untaintedAccessorCache$2[cacheKey] = untaintedAccessor;
|
|
132
132
|
return untaintedAccessor.call(instance);
|
|
133
133
|
}
|
|
134
|
-
const untaintedMethodCache$
|
|
135
|
-
function getUntaintedMethod$
|
|
134
|
+
const untaintedMethodCache$2 = {};
|
|
135
|
+
function getUntaintedMethod$2(key, instance, method) {
|
|
136
136
|
const cacheKey = `${key}.${String(method)}`;
|
|
137
|
-
if (untaintedMethodCache$
|
|
138
|
-
return untaintedMethodCache$
|
|
137
|
+
if (untaintedMethodCache$2[cacheKey])
|
|
138
|
+
return untaintedMethodCache$2[cacheKey].bind(
|
|
139
139
|
instance
|
|
140
140
|
);
|
|
141
|
-
const untaintedPrototype = getUntaintedPrototype$
|
|
141
|
+
const untaintedPrototype = getUntaintedPrototype$2(key);
|
|
142
142
|
const untaintedMethod = untaintedPrototype[method];
|
|
143
143
|
if (typeof untaintedMethod !== "function") return instance[method];
|
|
144
|
-
untaintedMethodCache$
|
|
144
|
+
untaintedMethodCache$2[cacheKey] = untaintedMethod;
|
|
145
145
|
return untaintedMethod.bind(instance);
|
|
146
146
|
}
|
|
147
|
-
function childNodes$
|
|
148
|
-
return getUntaintedAccessor$
|
|
147
|
+
function childNodes$2(n2) {
|
|
148
|
+
return getUntaintedAccessor$2("Node", n2, "childNodes");
|
|
149
149
|
}
|
|
150
|
-
function parentNode$
|
|
151
|
-
return getUntaintedAccessor$
|
|
150
|
+
function parentNode$2(n2) {
|
|
151
|
+
return getUntaintedAccessor$2("Node", n2, "parentNode");
|
|
152
152
|
}
|
|
153
|
-
function parentElement$
|
|
154
|
-
return getUntaintedAccessor$
|
|
153
|
+
function parentElement$2(n2) {
|
|
154
|
+
return getUntaintedAccessor$2("Node", n2, "parentElement");
|
|
155
155
|
}
|
|
156
|
-
function textContent$
|
|
157
|
-
return getUntaintedAccessor$
|
|
156
|
+
function textContent$2(n2) {
|
|
157
|
+
return getUntaintedAccessor$2("Node", n2, "textContent");
|
|
158
158
|
}
|
|
159
|
-
function contains$
|
|
160
|
-
return getUntaintedMethod$
|
|
159
|
+
function contains$2(n2, other) {
|
|
160
|
+
return getUntaintedMethod$2("Node", n2, "contains")(other);
|
|
161
161
|
}
|
|
162
|
-
function getRootNode$
|
|
163
|
-
return getUntaintedMethod$
|
|
162
|
+
function getRootNode$2(n2) {
|
|
163
|
+
return getUntaintedMethod$2("Node", n2, "getRootNode")();
|
|
164
164
|
}
|
|
165
|
-
function host$
|
|
165
|
+
function host$2(n2) {
|
|
166
166
|
if (!n2 || !("host" in n2)) return null;
|
|
167
|
-
return getUntaintedAccessor$
|
|
167
|
+
return getUntaintedAccessor$2("ShadowRoot", n2, "host");
|
|
168
168
|
}
|
|
169
|
-
function styleSheets$
|
|
169
|
+
function styleSheets$2(n2) {
|
|
170
170
|
return n2.styleSheets;
|
|
171
171
|
}
|
|
172
|
-
function shadowRoot$
|
|
172
|
+
function shadowRoot$2(n2) {
|
|
173
173
|
if (!n2 || !("shadowRoot" in n2)) return null;
|
|
174
|
-
return getUntaintedAccessor$
|
|
174
|
+
return getUntaintedAccessor$2("Element", n2, "shadowRoot");
|
|
175
175
|
}
|
|
176
|
-
function querySelector$
|
|
177
|
-
return getUntaintedAccessor$
|
|
176
|
+
function querySelector$2(n2, selectors) {
|
|
177
|
+
return getUntaintedAccessor$2("Element", n2, "querySelector")(selectors);
|
|
178
178
|
}
|
|
179
|
-
function querySelectorAll$
|
|
180
|
-
return getUntaintedAccessor$
|
|
179
|
+
function querySelectorAll$2(n2, selectors) {
|
|
180
|
+
return getUntaintedAccessor$2("Element", n2, "querySelectorAll")(selectors);
|
|
181
181
|
}
|
|
182
|
-
function mutationObserverCtor$
|
|
183
|
-
return getUntaintedPrototype$
|
|
182
|
+
function mutationObserverCtor$2() {
|
|
183
|
+
return getUntaintedPrototype$2("MutationObserver").constructor;
|
|
184
184
|
}
|
|
185
|
-
function patch$
|
|
185
|
+
function patch$2(source, name, replacement) {
|
|
186
186
|
try {
|
|
187
187
|
if (!(name in source)) {
|
|
188
188
|
return () => {
|
|
@@ -208,32 +208,32 @@ function patch$1(source, name, replacement) {
|
|
|
208
208
|
};
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
const index$
|
|
212
|
-
childNodes: childNodes$
|
|
213
|
-
parentNode: parentNode$
|
|
214
|
-
parentElement: parentElement$
|
|
215
|
-
textContent: textContent$
|
|
216
|
-
contains: contains$
|
|
217
|
-
getRootNode: getRootNode$
|
|
218
|
-
host: host$
|
|
219
|
-
styleSheets: styleSheets$
|
|
220
|
-
shadowRoot: shadowRoot$
|
|
221
|
-
querySelector: querySelector$
|
|
222
|
-
querySelectorAll: querySelectorAll$
|
|
223
|
-
mutationObserver: mutationObserverCtor$
|
|
224
|
-
patch: patch$
|
|
211
|
+
const index$2 = {
|
|
212
|
+
childNodes: childNodes$2,
|
|
213
|
+
parentNode: parentNode$2,
|
|
214
|
+
parentElement: parentElement$2,
|
|
215
|
+
textContent: textContent$2,
|
|
216
|
+
contains: contains$2,
|
|
217
|
+
getRootNode: getRootNode$2,
|
|
218
|
+
host: host$2,
|
|
219
|
+
styleSheets: styleSheets$2,
|
|
220
|
+
shadowRoot: shadowRoot$2,
|
|
221
|
+
querySelector: querySelector$2,
|
|
222
|
+
querySelectorAll: querySelectorAll$2,
|
|
223
|
+
mutationObserver: mutationObserverCtor$2,
|
|
224
|
+
patch: patch$2
|
|
225
225
|
};
|
|
226
|
-
function isElement(n2) {
|
|
226
|
+
function isElement$1(n2) {
|
|
227
227
|
return n2.nodeType === n2.ELEMENT_NODE;
|
|
228
228
|
}
|
|
229
229
|
function isShadowRoot(n2) {
|
|
230
230
|
const hostEl = (
|
|
231
231
|
// anchor and textarea elements also have a `host` property
|
|
232
232
|
// but only shadow roots have a `mode` property
|
|
233
|
-
n2 && "host" in n2 && "mode" in n2 && index$
|
|
233
|
+
n2 && "host" in n2 && "mode" in n2 && index$2.host(n2) || null
|
|
234
234
|
);
|
|
235
235
|
return Boolean(
|
|
236
|
-
hostEl && "shadowRoot" in hostEl && index$
|
|
236
|
+
hostEl && "shadowRoot" in hostEl && index$2.shadowRoot(hostEl) === n2
|
|
237
237
|
);
|
|
238
238
|
}
|
|
239
239
|
function isNativeShadowDom(shadowRoot2) {
|
|
@@ -354,6 +354,17 @@ class Mirror {
|
|
|
354
354
|
(childNode) => this.removeNodeFromMap(childNode)
|
|
355
355
|
);
|
|
356
356
|
}
|
|
357
|
+
if (isElement$1(n2)) {
|
|
358
|
+
const shadowRootEl = index$2.shadowRoot(n2);
|
|
359
|
+
if (shadowRootEl) {
|
|
360
|
+
this.removeNodeFromMap(shadowRootEl);
|
|
361
|
+
}
|
|
362
|
+
if (n2.nodeName === "IFRAME" && n2.contentDocument) {
|
|
363
|
+
this.removeNodeFromMap(
|
|
364
|
+
n2.contentDocument
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
357
368
|
}
|
|
358
369
|
has(id) {
|
|
359
370
|
return this.idNodeMap.has(id);
|
|
@@ -690,7 +701,7 @@ function classMatchesRegex(node2, regex, checkAncestors) {
|
|
|
690
701
|
if (!node2) return false;
|
|
691
702
|
if (node2.nodeType !== node2.ELEMENT_NODE) {
|
|
692
703
|
if (!checkAncestors) return false;
|
|
693
|
-
return classMatchesRegex(index$
|
|
704
|
+
return classMatchesRegex(index$2.parentNode(node2), regex, checkAncestors);
|
|
694
705
|
}
|
|
695
706
|
for (let eIndex = node2.classList.length; eIndex--; ) {
|
|
696
707
|
const className = node2.classList[eIndex];
|
|
@@ -699,19 +710,19 @@ function classMatchesRegex(node2, regex, checkAncestors) {
|
|
|
699
710
|
}
|
|
700
711
|
}
|
|
701
712
|
if (!checkAncestors) return false;
|
|
702
|
-
return classMatchesRegex(index$
|
|
713
|
+
return classMatchesRegex(index$2.parentNode(node2), regex, checkAncestors);
|
|
703
714
|
}
|
|
704
715
|
function needMaskingText(node2, maskTextClass, maskTextSelector, checkAncestors) {
|
|
705
716
|
let el;
|
|
706
|
-
if (isElement(node2)) {
|
|
717
|
+
if (isElement$1(node2)) {
|
|
707
718
|
el = node2;
|
|
708
|
-
if (!index$
|
|
719
|
+
if (!index$2.childNodes(el).length) {
|
|
709
720
|
return false;
|
|
710
721
|
}
|
|
711
|
-
} else if (index$
|
|
722
|
+
} else if (index$2.parentElement(node2) === null) {
|
|
712
723
|
return false;
|
|
713
724
|
} else {
|
|
714
|
-
el = index$
|
|
725
|
+
el = index$2.parentElement(node2);
|
|
715
726
|
}
|
|
716
727
|
try {
|
|
717
728
|
if (typeof maskTextClass === "string") {
|
|
@@ -860,7 +871,7 @@ function serializeNode(n2, options) {
|
|
|
860
871
|
case n2.COMMENT_NODE:
|
|
861
872
|
return {
|
|
862
873
|
type: NodeType$1$1.Comment,
|
|
863
|
-
textContent: index$
|
|
874
|
+
textContent: index$2.textContent(n2) || "",
|
|
864
875
|
rootId
|
|
865
876
|
};
|
|
866
877
|
default:
|
|
@@ -875,9 +886,9 @@ function getRootId(doc, mirror2) {
|
|
|
875
886
|
function serializeTextNode(n2, options) {
|
|
876
887
|
var _a2;
|
|
877
888
|
const { needsMask, maskTextFn, rootId } = options;
|
|
878
|
-
const parent = index$
|
|
889
|
+
const parent = index$2.parentNode(n2);
|
|
879
890
|
const parentTagName = parent && parent.tagName;
|
|
880
|
-
let text = index$
|
|
891
|
+
let text = index$2.textContent(n2);
|
|
881
892
|
const isStyle = parentTagName === "STYLE" ? true : void 0;
|
|
882
893
|
const isScript = parentTagName === "SCRIPT" ? true : void 0;
|
|
883
894
|
if (isStyle && text) {
|
|
@@ -898,7 +909,7 @@ function serializeTextNode(n2, options) {
|
|
|
898
909
|
text = "SCRIPT_PLACEHOLDER";
|
|
899
910
|
}
|
|
900
911
|
if (!isStyle && !isScript && text && needsMask) {
|
|
901
|
-
text = maskTextFn ? maskTextFn(text, index$
|
|
912
|
+
text = maskTextFn ? maskTextFn(text, index$2.parentElement(n2)) : text.replace(/[\S]/g, "*");
|
|
902
913
|
}
|
|
903
914
|
return {
|
|
904
915
|
type: NodeType$1$1.Text,
|
|
@@ -968,7 +979,7 @@ function serializeElementNode(n2, options) {
|
|
|
968
979
|
}
|
|
969
980
|
}
|
|
970
981
|
if (tagName === "style" && n2.sheet && // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element
|
|
971
|
-
!(n2.innerText || index$
|
|
982
|
+
!(n2.innerText || index$2.textContent(n2) || "").trim().length) {
|
|
972
983
|
const cssText = stringifyStylesheet(
|
|
973
984
|
n2.sheet
|
|
974
985
|
);
|
|
@@ -1234,7 +1245,7 @@ function serializeNodeWithId(n2, options) {
|
|
|
1234
1245
|
if (serializedNode.type === NodeType$1$1.Element) {
|
|
1235
1246
|
recordChild = recordChild && !serializedNode.needBlock;
|
|
1236
1247
|
delete serializedNode.needBlock;
|
|
1237
|
-
const shadowRootEl = index$
|
|
1248
|
+
const shadowRootEl = index$2.shadowRoot(n2);
|
|
1238
1249
|
if (shadowRootEl && isNativeShadowDom(shadowRootEl))
|
|
1239
1250
|
serializedNode.isShadowHost = true;
|
|
1240
1251
|
}
|
|
@@ -1269,7 +1280,7 @@ function serializeNodeWithId(n2, options) {
|
|
|
1269
1280
|
};
|
|
1270
1281
|
if (serializedNode.type === NodeType$1$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
|
|
1271
1282
|
else {
|
|
1272
|
-
for (const childN of Array.from(index$
|
|
1283
|
+
for (const childN of Array.from(index$2.childNodes(n2))) {
|
|
1273
1284
|
const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
1274
1285
|
if (serializedChildNode) {
|
|
1275
1286
|
serializedNode.childNodes.push(serializedChildNode);
|
|
@@ -1277,8 +1288,8 @@ function serializeNodeWithId(n2, options) {
|
|
|
1277
1288
|
}
|
|
1278
1289
|
}
|
|
1279
1290
|
let shadowRootEl = null;
|
|
1280
|
-
if (isElement(n2) && (shadowRootEl = index$
|
|
1281
|
-
for (const childN of Array.from(index$
|
|
1291
|
+
if (isElement$1(n2) && (shadowRootEl = index$2.shadowRoot(n2))) {
|
|
1292
|
+
for (const childN of Array.from(index$2.childNodes(shadowRootEl))) {
|
|
1282
1293
|
const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
1283
1294
|
if (serializedChildNode) {
|
|
1284
1295
|
isNativeShadowDom(shadowRootEl) && (serializedChildNode.isShadow = true);
|
|
@@ -1287,7 +1298,7 @@ function serializeNodeWithId(n2, options) {
|
|
|
1287
1298
|
}
|
|
1288
1299
|
}
|
|
1289
1300
|
}
|
|
1290
|
-
const parent = index$
|
|
1301
|
+
const parent = index$2.parentNode(n2);
|
|
1291
1302
|
if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
|
|
1292
1303
|
serializedNode.isShadow = true;
|
|
1293
1304
|
}
|