mixpanel-browser 2.50.0 → 2.51.0
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/.github/workflows/tests.yml +9 -10
- package/dist/mixpanel-js-wrapper.js +1 -1
- package/dist/mixpanel-js-wrapper.min.js +1 -1
- package/dist/mixpanel-jslib-snippet.min.js +1 -1
- package/dist/mixpanel-jslib-snippet.min.test.js +1 -1
- package/dist/mixpanel-recorder.js +1371 -812
- package/dist/mixpanel-recorder.min.js +24 -10
- package/dist/mixpanel.amd.js +71 -91
- package/dist/mixpanel.cjs.js +71 -91
- package/dist/mixpanel.globals.js +71 -91
- package/dist/mixpanel.min.js +89 -89
- package/dist/mixpanel.umd.js +71 -91
- package/package.json +2 -2
- package/src/config.js +1 -1
- package/src/loaders/mixpanel-jslib-snippet.js +1 -1
- package/src/mixpanel-core.js +56 -47
- package/src/mixpanel-persistence.js +14 -43
- package/src/recorder/index.js +4 -1
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
return n.nodeType === n.ELEMENT_NODE;
|
|
16
16
|
}
|
|
17
17
|
function isShadowRoot(n) {
|
|
18
|
-
|
|
18
|
+
const host = n === null || n === void 0 ? void 0 : n.host;
|
|
19
19
|
return Boolean((host === null || host === void 0 ? void 0 : host.shadowRoot) === n);
|
|
20
20
|
}
|
|
21
21
|
function isNativeShadowDom(shadowRoot) {
|
|
@@ -28,98 +28,125 @@
|
|
|
28
28
|
}
|
|
29
29
|
return cssText;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function escapeImportStatement(rule) {
|
|
32
|
+
const { cssText } = rule;
|
|
33
|
+
if (cssText.split('"').length < 3)
|
|
34
|
+
return cssText;
|
|
35
|
+
const statement = ['@import', `url(${JSON.stringify(rule.href)})`];
|
|
36
|
+
if (rule.layerName === '') {
|
|
37
|
+
statement.push(`layer`);
|
|
38
|
+
}
|
|
39
|
+
else if (rule.layerName) {
|
|
40
|
+
statement.push(`layer(${rule.layerName})`);
|
|
41
|
+
}
|
|
42
|
+
if (rule.supportsText) {
|
|
43
|
+
statement.push(`supports(${rule.supportsText})`);
|
|
44
|
+
}
|
|
45
|
+
if (rule.media.length) {
|
|
46
|
+
statement.push(rule.media.mediaText);
|
|
47
|
+
}
|
|
48
|
+
return statement.join(' ') + ';';
|
|
49
|
+
}
|
|
50
|
+
function stringifyStylesheet(s) {
|
|
32
51
|
try {
|
|
33
|
-
|
|
52
|
+
const rules = s.rules || s.cssRules;
|
|
34
53
|
return rules
|
|
35
|
-
? fixBrowserCompatibilityIssuesInCSS(Array.from(rules).
|
|
54
|
+
? fixBrowserCompatibilityIssuesInCSS(Array.from(rules, stringifyRule).join(''))
|
|
36
55
|
: null;
|
|
37
56
|
}
|
|
38
57
|
catch (error) {
|
|
39
58
|
return null;
|
|
40
59
|
}
|
|
41
60
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
61
|
+
function stringifyRule(rule) {
|
|
62
|
+
let importStringified;
|
|
44
63
|
if (isCSSImportRule(rule)) {
|
|
45
64
|
try {
|
|
46
|
-
|
|
65
|
+
importStringified =
|
|
66
|
+
stringifyStylesheet(rule.styleSheet) ||
|
|
67
|
+
escapeImportStatement(rule);
|
|
47
68
|
}
|
|
48
|
-
catch (
|
|
69
|
+
catch (error) {
|
|
49
70
|
}
|
|
50
71
|
}
|
|
51
|
-
|
|
72
|
+
else if (isCSSStyleRule(rule) && rule.selectorText.includes(':')) {
|
|
73
|
+
return fixSafariColons(rule.cssText);
|
|
74
|
+
}
|
|
75
|
+
return importStringified || rule.cssText;
|
|
76
|
+
}
|
|
77
|
+
function fixSafariColons(cssStringified) {
|
|
78
|
+
const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
|
|
79
|
+
return cssStringified.replace(regex, '$1\\$2');
|
|
52
80
|
}
|
|
53
81
|
function isCSSImportRule(rule) {
|
|
54
82
|
return 'styleSheet' in rule;
|
|
55
83
|
}
|
|
56
|
-
|
|
57
|
-
|
|
84
|
+
function isCSSStyleRule(rule) {
|
|
85
|
+
return 'selectorText' in rule;
|
|
86
|
+
}
|
|
87
|
+
class Mirror {
|
|
88
|
+
constructor() {
|
|
58
89
|
this.idNodeMap = new Map();
|
|
59
90
|
this.nodeMetaMap = new WeakMap();
|
|
60
91
|
}
|
|
61
|
-
|
|
92
|
+
getId(n) {
|
|
62
93
|
var _a;
|
|
63
94
|
if (!n)
|
|
64
95
|
return -1;
|
|
65
|
-
|
|
96
|
+
const id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id;
|
|
66
97
|
return id !== null && id !== void 0 ? id : -1;
|
|
67
|
-
}
|
|
68
|
-
|
|
98
|
+
}
|
|
99
|
+
getNode(id) {
|
|
69
100
|
return this.idNodeMap.get(id) || null;
|
|
70
|
-
}
|
|
71
|
-
|
|
101
|
+
}
|
|
102
|
+
getIds() {
|
|
72
103
|
return Array.from(this.idNodeMap.keys());
|
|
73
|
-
}
|
|
74
|
-
|
|
104
|
+
}
|
|
105
|
+
getMeta(n) {
|
|
75
106
|
return this.nodeMetaMap.get(n) || null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
this.idNodeMap["delete"](id);
|
|
107
|
+
}
|
|
108
|
+
removeNodeFromMap(n) {
|
|
109
|
+
const id = this.getId(n);
|
|
110
|
+
this.idNodeMap.delete(id);
|
|
81
111
|
if (n.childNodes) {
|
|
82
|
-
n.childNodes.forEach(
|
|
83
|
-
return _this.removeNodeFromMap(childNode);
|
|
84
|
-
});
|
|
112
|
+
n.childNodes.forEach((childNode) => this.removeNodeFromMap(childNode));
|
|
85
113
|
}
|
|
86
|
-
}
|
|
87
|
-
|
|
114
|
+
}
|
|
115
|
+
has(id) {
|
|
88
116
|
return this.idNodeMap.has(id);
|
|
89
|
-
}
|
|
90
|
-
|
|
117
|
+
}
|
|
118
|
+
hasNode(node) {
|
|
91
119
|
return this.nodeMetaMap.has(node);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
120
|
+
}
|
|
121
|
+
add(n, meta) {
|
|
122
|
+
const id = meta.id;
|
|
95
123
|
this.idNodeMap.set(id, n);
|
|
96
124
|
this.nodeMetaMap.set(n, meta);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
125
|
+
}
|
|
126
|
+
replace(id, n) {
|
|
127
|
+
const oldNode = this.getNode(id);
|
|
100
128
|
if (oldNode) {
|
|
101
|
-
|
|
129
|
+
const meta = this.nodeMetaMap.get(oldNode);
|
|
102
130
|
if (meta)
|
|
103
131
|
this.nodeMetaMap.set(n, meta);
|
|
104
132
|
}
|
|
105
133
|
this.idNodeMap.set(id, n);
|
|
106
|
-
}
|
|
107
|
-
|
|
134
|
+
}
|
|
135
|
+
reset() {
|
|
108
136
|
this.idNodeMap = new Map();
|
|
109
137
|
this.nodeMetaMap = new WeakMap();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
}());
|
|
138
|
+
}
|
|
139
|
+
}
|
|
113
140
|
function createMirror() {
|
|
114
141
|
return new Mirror();
|
|
115
142
|
}
|
|
116
|
-
function maskInputValue(
|
|
117
|
-
|
|
118
|
-
|
|
143
|
+
function maskInputValue({ element, maskInputOptions, tagName, type, value, maskInputFn, }) {
|
|
144
|
+
let text = value || '';
|
|
145
|
+
const actualType = type && toLowerCase(type);
|
|
119
146
|
if (maskInputOptions[tagName.toLowerCase()] ||
|
|
120
|
-
maskInputOptions[
|
|
147
|
+
(actualType && maskInputOptions[actualType])) {
|
|
121
148
|
if (maskInputFn) {
|
|
122
|
-
text = maskInputFn(text);
|
|
149
|
+
text = maskInputFn(text, element);
|
|
123
150
|
}
|
|
124
151
|
else {
|
|
125
152
|
text = '*'.repeat(text.length);
|
|
@@ -127,29 +154,54 @@
|
|
|
127
154
|
}
|
|
128
155
|
return text;
|
|
129
156
|
}
|
|
130
|
-
|
|
157
|
+
function toLowerCase(str) {
|
|
158
|
+
return str.toLowerCase();
|
|
159
|
+
}
|
|
160
|
+
const ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';
|
|
131
161
|
function is2DCanvasBlank(canvas) {
|
|
132
|
-
|
|
162
|
+
const ctx = canvas.getContext('2d');
|
|
133
163
|
if (!ctx)
|
|
134
164
|
return true;
|
|
135
|
-
|
|
136
|
-
for (
|
|
137
|
-
for (
|
|
138
|
-
|
|
139
|
-
|
|
165
|
+
const chunkSize = 50;
|
|
166
|
+
for (let x = 0; x < canvas.width; x += chunkSize) {
|
|
167
|
+
for (let y = 0; y < canvas.height; y += chunkSize) {
|
|
168
|
+
const getImageData = ctx.getImageData;
|
|
169
|
+
const originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData
|
|
140
170
|
? getImageData[ORIGINAL_ATTRIBUTE_NAME]
|
|
141
171
|
: getImageData;
|
|
142
|
-
|
|
143
|
-
if (pixelBuffer.some(
|
|
172
|
+
const pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);
|
|
173
|
+
if (pixelBuffer.some((pixel) => pixel !== 0))
|
|
144
174
|
return false;
|
|
145
175
|
}
|
|
146
176
|
}
|
|
147
177
|
return true;
|
|
178
|
+
}
|
|
179
|
+
function getInputType(element) {
|
|
180
|
+
const type = element.type;
|
|
181
|
+
return element.hasAttribute('data-rr-is-password')
|
|
182
|
+
? 'password'
|
|
183
|
+
: type
|
|
184
|
+
?
|
|
185
|
+
toLowerCase(type)
|
|
186
|
+
: null;
|
|
187
|
+
}
|
|
188
|
+
function extractFileExtension(path, baseURL) {
|
|
189
|
+
var _a;
|
|
190
|
+
let url;
|
|
191
|
+
try {
|
|
192
|
+
url = new URL(path, baseURL !== null && baseURL !== void 0 ? baseURL : window.location.href);
|
|
193
|
+
}
|
|
194
|
+
catch (err) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
const regex = /\.([0-9a-z]+)(?:$)/i;
|
|
198
|
+
const match = url.pathname.match(regex);
|
|
199
|
+
return (_a = match === null || match === void 0 ? void 0 : match[1]) !== null && _a !== void 0 ? _a : null;
|
|
148
200
|
}
|
|
149
201
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
202
|
+
let _id = 1;
|
|
203
|
+
const tagNameRegex = new RegExp('[^a-z0-9-_:]');
|
|
204
|
+
const IGNORED_NODE = -2;
|
|
153
205
|
function genId() {
|
|
154
206
|
return _id++;
|
|
155
207
|
}
|
|
@@ -157,21 +209,14 @@
|
|
|
157
209
|
if (element instanceof HTMLFormElement) {
|
|
158
210
|
return 'form';
|
|
159
211
|
}
|
|
160
|
-
|
|
212
|
+
const processedTagName = toLowerCase(element.tagName);
|
|
161
213
|
if (tagNameRegex.test(processedTagName)) {
|
|
162
214
|
return 'div';
|
|
163
215
|
}
|
|
164
216
|
return processedTagName;
|
|
165
217
|
}
|
|
166
|
-
function stringifyStyleSheet(sheet) {
|
|
167
|
-
return sheet.cssRules
|
|
168
|
-
? Array.from(sheet.cssRules)
|
|
169
|
-
.map(function (rule) { return rule.cssText || ''; })
|
|
170
|
-
.join('')
|
|
171
|
-
: '';
|
|
172
|
-
}
|
|
173
218
|
function extractOrigin(url) {
|
|
174
|
-
|
|
219
|
+
let origin = '';
|
|
175
220
|
if (url.indexOf('//') > -1) {
|
|
176
221
|
origin = url.split('/').slice(0, 3).join('/');
|
|
177
222
|
}
|
|
@@ -181,32 +226,32 @@
|
|
|
181
226
|
origin = origin.split('?')[0];
|
|
182
227
|
return origin;
|
|
183
228
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
229
|
+
let canvasService;
|
|
230
|
+
let canvasCtx;
|
|
231
|
+
const URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
|
|
232
|
+
const URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
|
|
233
|
+
const URL_WWW_MATCH = /^www\..*/i;
|
|
234
|
+
const DATA_URI = /^(data:)([^,]*),(.*)/i;
|
|
189
235
|
function absoluteToStylesheet(cssText, href) {
|
|
190
|
-
return (cssText || '').replace(URL_IN_CSS_REF,
|
|
191
|
-
|
|
192
|
-
|
|
236
|
+
return (cssText || '').replace(URL_IN_CSS_REF, (origin, quote1, path1, quote2, path2, path3) => {
|
|
237
|
+
const filePath = path1 || path2 || path3;
|
|
238
|
+
const maybeQuote = quote1 || quote2 || '';
|
|
193
239
|
if (!filePath) {
|
|
194
240
|
return origin;
|
|
195
241
|
}
|
|
196
|
-
if (
|
|
197
|
-
return
|
|
242
|
+
if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
|
|
243
|
+
return `url(${maybeQuote}${filePath}${maybeQuote})`;
|
|
198
244
|
}
|
|
199
245
|
if (DATA_URI.test(filePath)) {
|
|
200
|
-
return
|
|
246
|
+
return `url(${maybeQuote}${filePath}${maybeQuote})`;
|
|
201
247
|
}
|
|
202
248
|
if (filePath[0] === '/') {
|
|
203
|
-
return
|
|
249
|
+
return `url(${maybeQuote}${extractOrigin(href) + filePath}${maybeQuote})`;
|
|
204
250
|
}
|
|
205
|
-
|
|
206
|
-
|
|
251
|
+
const stack = href.split('/');
|
|
252
|
+
const parts = filePath.split('/');
|
|
207
253
|
stack.pop();
|
|
208
|
-
for (
|
|
209
|
-
var part = parts_1[_i];
|
|
254
|
+
for (const part of parts) {
|
|
210
255
|
if (part === '.') {
|
|
211
256
|
continue;
|
|
212
257
|
}
|
|
@@ -217,19 +262,19 @@
|
|
|
217
262
|
stack.push(part);
|
|
218
263
|
}
|
|
219
264
|
}
|
|
220
|
-
return
|
|
265
|
+
return `url(${maybeQuote}${stack.join('/')}${maybeQuote})`;
|
|
221
266
|
});
|
|
222
267
|
}
|
|
223
|
-
|
|
224
|
-
|
|
268
|
+
const SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
|
|
269
|
+
const SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
|
|
225
270
|
function getAbsoluteSrcsetString(doc, attributeValue) {
|
|
226
271
|
if (attributeValue.trim() === '') {
|
|
227
272
|
return attributeValue;
|
|
228
273
|
}
|
|
229
|
-
|
|
274
|
+
let pos = 0;
|
|
230
275
|
function collectCharacters(regEx) {
|
|
231
|
-
|
|
232
|
-
|
|
276
|
+
let chars;
|
|
277
|
+
const match = regEx.exec(attributeValue.substring(pos));
|
|
233
278
|
if (match) {
|
|
234
279
|
chars = match[0];
|
|
235
280
|
pos += chars.length;
|
|
@@ -237,23 +282,23 @@
|
|
|
237
282
|
}
|
|
238
283
|
return '';
|
|
239
284
|
}
|
|
240
|
-
|
|
285
|
+
const output = [];
|
|
241
286
|
while (true) {
|
|
242
287
|
collectCharacters(SRCSET_COMMAS_OR_SPACES);
|
|
243
288
|
if (pos >= attributeValue.length) {
|
|
244
289
|
break;
|
|
245
290
|
}
|
|
246
|
-
|
|
291
|
+
let url = collectCharacters(SRCSET_NOT_SPACES);
|
|
247
292
|
if (url.slice(-1) === ',') {
|
|
248
293
|
url = absoluteToDoc(doc, url.substring(0, url.length - 1));
|
|
249
294
|
output.push(url);
|
|
250
295
|
}
|
|
251
296
|
else {
|
|
252
|
-
|
|
297
|
+
let descriptorsStr = '';
|
|
253
298
|
url = absoluteToDoc(doc, url);
|
|
254
|
-
|
|
299
|
+
let inParens = false;
|
|
255
300
|
while (true) {
|
|
256
|
-
|
|
301
|
+
const c = attributeValue.charAt(pos);
|
|
257
302
|
if (c === '') {
|
|
258
303
|
output.push((url + descriptorsStr).trim());
|
|
259
304
|
break;
|
|
@@ -284,7 +329,7 @@
|
|
|
284
329
|
if (!attributeValue || attributeValue.trim() === '') {
|
|
285
330
|
return attributeValue;
|
|
286
331
|
}
|
|
287
|
-
|
|
332
|
+
const a = doc.createElement('a');
|
|
288
333
|
a.href = attributeValue;
|
|
289
334
|
return a.href;
|
|
290
335
|
}
|
|
@@ -292,52 +337,59 @@
|
|
|
292
337
|
return Boolean(el.tagName === 'svg' || el.ownerSVGElement);
|
|
293
338
|
}
|
|
294
339
|
function getHref() {
|
|
295
|
-
|
|
340
|
+
const a = document.createElement('a');
|
|
296
341
|
a.href = '';
|
|
297
342
|
return a.href;
|
|
298
343
|
}
|
|
299
344
|
function transformAttribute(doc, tagName, name, value) {
|
|
345
|
+
if (!value) {
|
|
346
|
+
return value;
|
|
347
|
+
}
|
|
300
348
|
if (name === 'src' ||
|
|
301
|
-
(name === 'href' &&
|
|
349
|
+
(name === 'href' && !(tagName === 'use' && value[0] === '#'))) {
|
|
302
350
|
return absoluteToDoc(doc, value);
|
|
303
351
|
}
|
|
304
|
-
else if (name === 'xlink:href' && value
|
|
352
|
+
else if (name === 'xlink:href' && value[0] !== '#') {
|
|
305
353
|
return absoluteToDoc(doc, value);
|
|
306
354
|
}
|
|
307
355
|
else if (name === 'background' &&
|
|
308
|
-
value &&
|
|
309
356
|
(tagName === 'table' || tagName === 'td' || tagName === 'th')) {
|
|
310
357
|
return absoluteToDoc(doc, value);
|
|
311
358
|
}
|
|
312
|
-
else if (name === 'srcset'
|
|
359
|
+
else if (name === 'srcset') {
|
|
313
360
|
return getAbsoluteSrcsetString(doc, value);
|
|
314
361
|
}
|
|
315
|
-
else if (name === 'style'
|
|
362
|
+
else if (name === 'style') {
|
|
316
363
|
return absoluteToStylesheet(value, getHref());
|
|
317
364
|
}
|
|
318
|
-
else if (tagName === 'object' && name === 'data'
|
|
365
|
+
else if (tagName === 'object' && name === 'data') {
|
|
319
366
|
return absoluteToDoc(doc, value);
|
|
320
367
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
368
|
+
return value;
|
|
369
|
+
}
|
|
370
|
+
function ignoreAttribute(tagName, name, _value) {
|
|
371
|
+
return (tagName === 'video' || tagName === 'audio') && name === 'autoplay';
|
|
324
372
|
}
|
|
325
373
|
function _isBlockedElement(element, blockClass, blockSelector) {
|
|
326
|
-
|
|
327
|
-
if (
|
|
328
|
-
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
for (var eIndex = element.classList.length; eIndex--;) {
|
|
333
|
-
var className = element.classList[eIndex];
|
|
334
|
-
if (blockClass.test(className)) {
|
|
374
|
+
try {
|
|
375
|
+
if (typeof blockClass === 'string') {
|
|
376
|
+
if (element.classList.contains(blockClass)) {
|
|
335
377
|
return true;
|
|
336
378
|
}
|
|
337
379
|
}
|
|
380
|
+
else {
|
|
381
|
+
for (let eIndex = element.classList.length; eIndex--;) {
|
|
382
|
+
const className = element.classList[eIndex];
|
|
383
|
+
if (blockClass.test(className)) {
|
|
384
|
+
return true;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if (blockSelector) {
|
|
389
|
+
return element.matches(blockSelector);
|
|
390
|
+
}
|
|
338
391
|
}
|
|
339
|
-
|
|
340
|
-
return element.matches(blockSelector);
|
|
392
|
+
catch (e) {
|
|
341
393
|
}
|
|
342
394
|
return false;
|
|
343
395
|
}
|
|
@@ -349,8 +401,8 @@
|
|
|
349
401
|
return false;
|
|
350
402
|
return classMatchesRegex(node.parentNode, regex, checkAncestors);
|
|
351
403
|
}
|
|
352
|
-
for (
|
|
353
|
-
|
|
404
|
+
for (let eIndex = node.classList.length; eIndex--;) {
|
|
405
|
+
const className = node.classList[eIndex];
|
|
354
406
|
if (regex.test(className)) {
|
|
355
407
|
return true;
|
|
356
408
|
}
|
|
@@ -359,37 +411,49 @@
|
|
|
359
411
|
return false;
|
|
360
412
|
return classMatchesRegex(node.parentNode, regex, checkAncestors);
|
|
361
413
|
}
|
|
362
|
-
function needMaskingText(node, maskTextClass, maskTextSelector) {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
if (
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
414
|
+
function needMaskingText(node, maskTextClass, maskTextSelector, checkAncestors) {
|
|
415
|
+
try {
|
|
416
|
+
const el = node.nodeType === node.ELEMENT_NODE
|
|
417
|
+
? node
|
|
418
|
+
: node.parentElement;
|
|
419
|
+
if (el === null)
|
|
420
|
+
return false;
|
|
421
|
+
if (typeof maskTextClass === 'string') {
|
|
422
|
+
if (checkAncestors) {
|
|
423
|
+
if (el.closest(`.${maskTextClass}`))
|
|
424
|
+
return true;
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
if (el.classList.contains(maskTextClass))
|
|
428
|
+
return true;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
if (classMatchesRegex(el, maskTextClass, checkAncestors))
|
|
433
|
+
return true;
|
|
434
|
+
}
|
|
435
|
+
if (maskTextSelector) {
|
|
436
|
+
if (checkAncestors) {
|
|
437
|
+
if (el.closest(maskTextSelector))
|
|
438
|
+
return true;
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
if (el.matches(maskTextSelector))
|
|
442
|
+
return true;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
377
445
|
}
|
|
378
|
-
|
|
379
|
-
if (el.matches(maskTextSelector))
|
|
380
|
-
return true;
|
|
381
|
-
if (el.closest(maskTextSelector))
|
|
382
|
-
return true;
|
|
446
|
+
catch (e) {
|
|
383
447
|
}
|
|
384
448
|
return false;
|
|
385
449
|
}
|
|
386
450
|
function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
|
|
387
|
-
|
|
451
|
+
const win = iframeEl.contentWindow;
|
|
388
452
|
if (!win) {
|
|
389
453
|
return;
|
|
390
454
|
}
|
|
391
|
-
|
|
392
|
-
|
|
455
|
+
let fired = false;
|
|
456
|
+
let readyState;
|
|
393
457
|
try {
|
|
394
458
|
readyState = win.document.readyState;
|
|
395
459
|
}
|
|
@@ -397,20 +461,20 @@
|
|
|
397
461
|
return;
|
|
398
462
|
}
|
|
399
463
|
if (readyState !== 'complete') {
|
|
400
|
-
|
|
464
|
+
const timer = setTimeout(() => {
|
|
401
465
|
if (!fired) {
|
|
402
466
|
listener();
|
|
403
467
|
fired = true;
|
|
404
468
|
}
|
|
405
469
|
}, iframeLoadTimeout);
|
|
406
|
-
iframeEl.addEventListener('load',
|
|
407
|
-
clearTimeout(
|
|
470
|
+
iframeEl.addEventListener('load', () => {
|
|
471
|
+
clearTimeout(timer);
|
|
408
472
|
fired = true;
|
|
409
473
|
listener();
|
|
410
474
|
});
|
|
411
475
|
return;
|
|
412
476
|
}
|
|
413
|
-
|
|
477
|
+
const blankUrl = 'about:blank';
|
|
414
478
|
if (win.location.href !== blankUrl ||
|
|
415
479
|
iframeEl.src === blankUrl ||
|
|
416
480
|
iframeEl.src === '') {
|
|
@@ -420,8 +484,8 @@
|
|
|
420
484
|
iframeEl.addEventListener('load', listener);
|
|
421
485
|
}
|
|
422
486
|
function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
|
|
423
|
-
|
|
424
|
-
|
|
487
|
+
let fired = false;
|
|
488
|
+
let styleSheetLoaded;
|
|
425
489
|
try {
|
|
426
490
|
styleSheetLoaded = link.sheet;
|
|
427
491
|
}
|
|
@@ -430,34 +494,34 @@
|
|
|
430
494
|
}
|
|
431
495
|
if (styleSheetLoaded)
|
|
432
496
|
return;
|
|
433
|
-
|
|
497
|
+
const timer = setTimeout(() => {
|
|
434
498
|
if (!fired) {
|
|
435
499
|
listener();
|
|
436
500
|
fired = true;
|
|
437
501
|
}
|
|
438
502
|
}, styleSheetLoadTimeout);
|
|
439
|
-
link.addEventListener('load',
|
|
503
|
+
link.addEventListener('load', () => {
|
|
440
504
|
clearTimeout(timer);
|
|
441
505
|
fired = true;
|
|
442
506
|
listener();
|
|
443
507
|
});
|
|
444
508
|
}
|
|
445
509
|
function serializeNode(n, options) {
|
|
446
|
-
|
|
447
|
-
|
|
510
|
+
const { doc, mirror, blockClass, blockSelector, needsMask, inlineStylesheet, maskInputOptions = {}, maskTextFn, maskInputFn, dataURLOptions = {}, inlineImages, recordCanvas, keepIframeSrcFn, newlyAddedElement = false, } = options;
|
|
511
|
+
const rootId = getRootId(doc, mirror);
|
|
448
512
|
switch (n.nodeType) {
|
|
449
513
|
case n.DOCUMENT_NODE:
|
|
450
514
|
if (n.compatMode !== 'CSS1Compat') {
|
|
451
515
|
return {
|
|
452
516
|
type: NodeType.Document,
|
|
453
517
|
childNodes: [],
|
|
454
|
-
compatMode: n.compatMode
|
|
518
|
+
compatMode: n.compatMode,
|
|
455
519
|
};
|
|
456
520
|
}
|
|
457
521
|
else {
|
|
458
522
|
return {
|
|
459
523
|
type: NodeType.Document,
|
|
460
|
-
childNodes: []
|
|
524
|
+
childNodes: [],
|
|
461
525
|
};
|
|
462
526
|
}
|
|
463
527
|
case n.DOCUMENT_TYPE_NODE:
|
|
@@ -466,41 +530,40 @@
|
|
|
466
530
|
name: n.name,
|
|
467
531
|
publicId: n.publicId,
|
|
468
532
|
systemId: n.systemId,
|
|
469
|
-
rootId
|
|
533
|
+
rootId,
|
|
470
534
|
};
|
|
471
535
|
case n.ELEMENT_NODE:
|
|
472
536
|
return serializeElementNode(n, {
|
|
473
|
-
doc
|
|
474
|
-
blockClass
|
|
475
|
-
blockSelector
|
|
476
|
-
inlineStylesheet
|
|
477
|
-
maskInputOptions
|
|
478
|
-
maskInputFn
|
|
479
|
-
dataURLOptions
|
|
480
|
-
inlineImages
|
|
481
|
-
recordCanvas
|
|
482
|
-
keepIframeSrcFn
|
|
483
|
-
newlyAddedElement
|
|
484
|
-
rootId
|
|
537
|
+
doc,
|
|
538
|
+
blockClass,
|
|
539
|
+
blockSelector,
|
|
540
|
+
inlineStylesheet,
|
|
541
|
+
maskInputOptions,
|
|
542
|
+
maskInputFn,
|
|
543
|
+
dataURLOptions,
|
|
544
|
+
inlineImages,
|
|
545
|
+
recordCanvas,
|
|
546
|
+
keepIframeSrcFn,
|
|
547
|
+
newlyAddedElement,
|
|
548
|
+
rootId,
|
|
485
549
|
});
|
|
486
550
|
case n.TEXT_NODE:
|
|
487
551
|
return serializeTextNode(n, {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
rootId: rootId
|
|
552
|
+
needsMask,
|
|
553
|
+
maskTextFn,
|
|
554
|
+
rootId,
|
|
492
555
|
});
|
|
493
556
|
case n.CDATA_SECTION_NODE:
|
|
494
557
|
return {
|
|
495
558
|
type: NodeType.CDATA,
|
|
496
559
|
textContent: '',
|
|
497
|
-
rootId
|
|
560
|
+
rootId,
|
|
498
561
|
};
|
|
499
562
|
case n.COMMENT_NODE:
|
|
500
563
|
return {
|
|
501
564
|
type: NodeType.Comment,
|
|
502
565
|
textContent: n.textContent || '',
|
|
503
|
-
rootId
|
|
566
|
+
rootId,
|
|
504
567
|
};
|
|
505
568
|
default:
|
|
506
569
|
return false;
|
|
@@ -509,64 +572,63 @@
|
|
|
509
572
|
function getRootId(doc, mirror) {
|
|
510
573
|
if (!mirror.hasNode(doc))
|
|
511
574
|
return undefined;
|
|
512
|
-
|
|
575
|
+
const docId = mirror.getId(doc);
|
|
513
576
|
return docId === 1 ? undefined : docId;
|
|
514
577
|
}
|
|
515
578
|
function serializeTextNode(n, options) {
|
|
516
579
|
var _a;
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
580
|
+
const { needsMask, maskTextFn, rootId } = options;
|
|
581
|
+
const parentTagName = n.parentNode && n.parentNode.tagName;
|
|
582
|
+
let textContent = n.textContent;
|
|
583
|
+
const isStyle = parentTagName === 'STYLE' ? true : undefined;
|
|
584
|
+
const isScript = parentTagName === 'SCRIPT' ? true : undefined;
|
|
522
585
|
if (isStyle && textContent) {
|
|
523
586
|
try {
|
|
524
587
|
if (n.nextSibling || n.previousSibling) {
|
|
525
588
|
}
|
|
526
589
|
else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {
|
|
527
|
-
textContent =
|
|
590
|
+
textContent = stringifyStylesheet(n.parentNode.sheet);
|
|
528
591
|
}
|
|
529
592
|
}
|
|
530
593
|
catch (err) {
|
|
531
|
-
console.warn(
|
|
594
|
+
console.warn(`Cannot get CSS styles from text's parentNode. Error: ${err}`, n);
|
|
532
595
|
}
|
|
533
596
|
textContent = absoluteToStylesheet(textContent, getHref());
|
|
534
597
|
}
|
|
535
598
|
if (isScript) {
|
|
536
599
|
textContent = 'SCRIPT_PLACEHOLDER';
|
|
537
600
|
}
|
|
538
|
-
if (!isStyle &&
|
|
539
|
-
!isScript &&
|
|
540
|
-
textContent &&
|
|
541
|
-
needMaskingText(n, maskTextClass, maskTextSelector)) {
|
|
601
|
+
if (!isStyle && !isScript && textContent && needsMask) {
|
|
542
602
|
textContent = maskTextFn
|
|
543
|
-
? maskTextFn(textContent)
|
|
603
|
+
? maskTextFn(textContent, n.parentElement)
|
|
544
604
|
: textContent.replace(/[\S]/g, '*');
|
|
545
605
|
}
|
|
546
606
|
return {
|
|
547
607
|
type: NodeType.Text,
|
|
548
608
|
textContent: textContent || '',
|
|
549
|
-
isStyle
|
|
550
|
-
rootId
|
|
609
|
+
isStyle,
|
|
610
|
+
rootId,
|
|
551
611
|
};
|
|
552
612
|
}
|
|
553
613
|
function serializeElementNode(n, options) {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
for (
|
|
560
|
-
|
|
561
|
-
|
|
614
|
+
const { doc, blockClass, blockSelector, inlineStylesheet, maskInputOptions = {}, maskInputFn, dataURLOptions = {}, inlineImages, recordCanvas, keepIframeSrcFn, newlyAddedElement = false, rootId, } = options;
|
|
615
|
+
const needBlock = _isBlockedElement(n, blockClass, blockSelector);
|
|
616
|
+
const tagName = getValidTagName(n);
|
|
617
|
+
let attributes = {};
|
|
618
|
+
const len = n.attributes.length;
|
|
619
|
+
for (let i = 0; i < len; i++) {
|
|
620
|
+
const attr = n.attributes[i];
|
|
621
|
+
if (!ignoreAttribute(tagName, attr.name, attr.value)) {
|
|
622
|
+
attributes[attr.name] = transformAttribute(doc, tagName, toLowerCase(attr.name), attr.value);
|
|
623
|
+
}
|
|
562
624
|
}
|
|
563
625
|
if (tagName === 'link' && inlineStylesheet) {
|
|
564
|
-
|
|
626
|
+
const stylesheet = Array.from(doc.styleSheets).find((s) => {
|
|
565
627
|
return s.href === n.href;
|
|
566
628
|
});
|
|
567
|
-
|
|
629
|
+
let cssText = null;
|
|
568
630
|
if (stylesheet) {
|
|
569
|
-
cssText =
|
|
631
|
+
cssText = stringifyStylesheet(stylesheet);
|
|
570
632
|
}
|
|
571
633
|
if (cssText) {
|
|
572
634
|
delete attributes.rel;
|
|
@@ -577,25 +639,26 @@
|
|
|
577
639
|
if (tagName === 'style' &&
|
|
578
640
|
n.sheet &&
|
|
579
641
|
!(n.innerText || n.textContent || '').trim().length) {
|
|
580
|
-
|
|
642
|
+
const cssText = stringifyStylesheet(n.sheet);
|
|
581
643
|
if (cssText) {
|
|
582
644
|
attributes._cssText = absoluteToStylesheet(cssText, getHref());
|
|
583
645
|
}
|
|
584
646
|
}
|
|
585
647
|
if (tagName === 'input' || tagName === 'textarea' || tagName === 'select') {
|
|
586
|
-
|
|
587
|
-
|
|
648
|
+
const value = n.value;
|
|
649
|
+
const checked = n.checked;
|
|
588
650
|
if (attributes.type !== 'radio' &&
|
|
589
651
|
attributes.type !== 'checkbox' &&
|
|
590
652
|
attributes.type !== 'submit' &&
|
|
591
653
|
attributes.type !== 'button' &&
|
|
592
654
|
value) {
|
|
593
655
|
attributes.value = maskInputValue({
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
656
|
+
element: n,
|
|
657
|
+
type: getInputType(n),
|
|
658
|
+
tagName,
|
|
659
|
+
value,
|
|
660
|
+
maskInputOptions,
|
|
661
|
+
maskInputFn,
|
|
599
662
|
});
|
|
600
663
|
}
|
|
601
664
|
else if (checked) {
|
|
@@ -617,11 +680,11 @@
|
|
|
617
680
|
}
|
|
618
681
|
}
|
|
619
682
|
else if (!('__context' in n)) {
|
|
620
|
-
|
|
621
|
-
|
|
683
|
+
const canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
684
|
+
const blankCanvas = document.createElement('canvas');
|
|
622
685
|
blankCanvas.width = n.width;
|
|
623
686
|
blankCanvas.height = n.height;
|
|
624
|
-
|
|
687
|
+
const blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
625
688
|
if (canvasDataURL !== blankCanvasDataURL) {
|
|
626
689
|
attributes.rr_dataURL = canvasDataURL;
|
|
627
690
|
}
|
|
@@ -632,33 +695,39 @@
|
|
|
632
695
|
canvasService = doc.createElement('canvas');
|
|
633
696
|
canvasCtx = canvasService.getContext('2d');
|
|
634
697
|
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
698
|
+
const image = n;
|
|
699
|
+
const oldValue = image.crossOrigin;
|
|
700
|
+
image.crossOrigin = 'anonymous';
|
|
701
|
+
const recordInlineImage = () => {
|
|
702
|
+
image.removeEventListener('load', recordInlineImage);
|
|
639
703
|
try {
|
|
640
|
-
canvasService.width =
|
|
641
|
-
canvasService.height =
|
|
642
|
-
canvasCtx.drawImage(
|
|
704
|
+
canvasService.width = image.naturalWidth;
|
|
705
|
+
canvasService.height = image.naturalHeight;
|
|
706
|
+
canvasCtx.drawImage(image, 0, 0);
|
|
643
707
|
attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
644
708
|
}
|
|
645
709
|
catch (err) {
|
|
646
|
-
console.warn(
|
|
710
|
+
console.warn(`Cannot inline img src=${image.currentSrc}! Error: ${err}`);
|
|
647
711
|
}
|
|
648
|
-
|
|
649
|
-
? (attributes.crossOrigin =
|
|
650
|
-
:
|
|
712
|
+
oldValue
|
|
713
|
+
? (attributes.crossOrigin = oldValue)
|
|
714
|
+
: image.removeAttribute('crossorigin');
|
|
651
715
|
};
|
|
652
|
-
if (
|
|
716
|
+
if (image.complete && image.naturalWidth !== 0)
|
|
653
717
|
recordInlineImage();
|
|
654
718
|
else
|
|
655
|
-
|
|
719
|
+
image.addEventListener('load', recordInlineImage);
|
|
656
720
|
}
|
|
657
721
|
if (tagName === 'audio' || tagName === 'video') {
|
|
658
|
-
|
|
722
|
+
const mediaAttributes = attributes;
|
|
723
|
+
mediaAttributes.rr_mediaState = n.paused
|
|
659
724
|
? 'paused'
|
|
660
725
|
: 'played';
|
|
661
|
-
|
|
726
|
+
mediaAttributes.rr_mediaCurrentTime = n.currentTime;
|
|
727
|
+
mediaAttributes.rr_mediaPlaybackRate = n.playbackRate;
|
|
728
|
+
mediaAttributes.rr_mediaMuted = n.muted;
|
|
729
|
+
mediaAttributes.rr_mediaLoop = n.loop;
|
|
730
|
+
mediaAttributes.rr_mediaVolume = n.volume;
|
|
662
731
|
}
|
|
663
732
|
if (!newlyAddedElement) {
|
|
664
733
|
if (n.scrollLeft) {
|
|
@@ -669,11 +738,11 @@
|
|
|
669
738
|
}
|
|
670
739
|
}
|
|
671
740
|
if (needBlock) {
|
|
672
|
-
|
|
741
|
+
const { width, height } = n.getBoundingClientRect();
|
|
673
742
|
attributes = {
|
|
674
|
-
|
|
675
|
-
rr_width:
|
|
676
|
-
rr_height:
|
|
743
|
+
class: attributes.class,
|
|
744
|
+
rr_width: `${width}px`,
|
|
745
|
+
rr_height: `${height}px`,
|
|
677
746
|
};
|
|
678
747
|
}
|
|
679
748
|
if (tagName === 'iframe' && !keepIframeSrcFn(attributes.src)) {
|
|
@@ -682,18 +751,26 @@
|
|
|
682
751
|
}
|
|
683
752
|
delete attributes.src;
|
|
684
753
|
}
|
|
754
|
+
let isCustomElement;
|
|
755
|
+
try {
|
|
756
|
+
if (customElements.get(tagName))
|
|
757
|
+
isCustomElement = true;
|
|
758
|
+
}
|
|
759
|
+
catch (e) {
|
|
760
|
+
}
|
|
685
761
|
return {
|
|
686
762
|
type: NodeType.Element,
|
|
687
|
-
tagName
|
|
688
|
-
attributes
|
|
763
|
+
tagName,
|
|
764
|
+
attributes,
|
|
689
765
|
childNodes: [],
|
|
690
766
|
isSVG: isSVGElement(n) || undefined,
|
|
691
|
-
needBlock
|
|
692
|
-
rootId
|
|
767
|
+
needBlock,
|
|
768
|
+
rootId,
|
|
769
|
+
isCustom: isCustomElement,
|
|
693
770
|
};
|
|
694
771
|
}
|
|
695
772
|
function lowerIfExists(maybeAttr) {
|
|
696
|
-
if (maybeAttr === undefined) {
|
|
773
|
+
if (maybeAttr === undefined || maybeAttr === null) {
|
|
697
774
|
return '';
|
|
698
775
|
}
|
|
699
776
|
else {
|
|
@@ -708,12 +785,13 @@
|
|
|
708
785
|
if (slimDOMOptions.script &&
|
|
709
786
|
(sn.tagName === 'script' ||
|
|
710
787
|
(sn.tagName === 'link' &&
|
|
711
|
-
sn.attributes.rel === 'preload'
|
|
788
|
+
(sn.attributes.rel === 'preload' ||
|
|
789
|
+
sn.attributes.rel === 'modulepreload') &&
|
|
712
790
|
sn.attributes.as === 'script') ||
|
|
713
791
|
(sn.tagName === 'link' &&
|
|
714
792
|
sn.attributes.rel === 'prefetch' &&
|
|
715
793
|
typeof sn.attributes.href === 'string' &&
|
|
716
|
-
sn.attributes.href
|
|
794
|
+
extractFileExtension(sn.attributes.href) === 'js'))) {
|
|
717
795
|
return true;
|
|
718
796
|
}
|
|
719
797
|
else if (slimDOMOptions.headFavicon &&
|
|
@@ -772,30 +850,35 @@
|
|
|
772
850
|
return false;
|
|
773
851
|
}
|
|
774
852
|
function serializeNodeWithId(n, options) {
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
853
|
+
const { doc, mirror, blockClass, blockSelector, maskTextClass, maskTextSelector, skipChild = false, inlineStylesheet = true, maskInputOptions = {}, maskTextFn, maskInputFn, slimDOMOptions, dataURLOptions = {}, inlineImages = false, recordCanvas = false, onSerialize, onIframeLoad, iframeLoadTimeout = 5000, onStylesheetLoad, stylesheetLoadTimeout = 5000, keepIframeSrcFn = () => false, newlyAddedElement = false, } = options;
|
|
854
|
+
let { needsMask } = options;
|
|
855
|
+
let { preserveWhiteSpace = true } = options;
|
|
856
|
+
if (!needsMask &&
|
|
857
|
+
n.childNodes) {
|
|
858
|
+
const checkAncestors = needsMask === undefined;
|
|
859
|
+
needsMask = needMaskingText(n, maskTextClass, maskTextSelector, checkAncestors);
|
|
860
|
+
}
|
|
861
|
+
const _serializedNode = serializeNode(n, {
|
|
862
|
+
doc,
|
|
863
|
+
mirror,
|
|
864
|
+
blockClass,
|
|
865
|
+
blockSelector,
|
|
866
|
+
needsMask,
|
|
867
|
+
inlineStylesheet,
|
|
868
|
+
maskInputOptions,
|
|
869
|
+
maskTextFn,
|
|
870
|
+
maskInputFn,
|
|
871
|
+
dataURLOptions,
|
|
872
|
+
inlineImages,
|
|
873
|
+
recordCanvas,
|
|
874
|
+
keepIframeSrcFn,
|
|
875
|
+
newlyAddedElement,
|
|
793
876
|
});
|
|
794
877
|
if (!_serializedNode) {
|
|
795
878
|
console.warn(n, 'not serialized');
|
|
796
879
|
return null;
|
|
797
880
|
}
|
|
798
|
-
|
|
881
|
+
let id;
|
|
799
882
|
if (mirror.hasNode(n)) {
|
|
800
883
|
id = mirror.getId(n);
|
|
801
884
|
}
|
|
@@ -809,7 +892,7 @@
|
|
|
809
892
|
else {
|
|
810
893
|
id = genId();
|
|
811
894
|
}
|
|
812
|
-
|
|
895
|
+
const serializedNode = Object.assign(_serializedNode, { id });
|
|
813
896
|
mirror.add(n, serializedNode);
|
|
814
897
|
if (id === IGNORED_NODE) {
|
|
815
898
|
return null;
|
|
@@ -817,11 +900,11 @@
|
|
|
817
900
|
if (onSerialize) {
|
|
818
901
|
onSerialize(n);
|
|
819
902
|
}
|
|
820
|
-
|
|
903
|
+
let recordChild = !skipChild;
|
|
821
904
|
if (serializedNode.type === NodeType.Element) {
|
|
822
905
|
recordChild = recordChild && !serializedNode.needBlock;
|
|
823
906
|
delete serializedNode.needBlock;
|
|
824
|
-
|
|
907
|
+
const shadowRoot = n.shadowRoot;
|
|
825
908
|
if (shadowRoot && isNativeShadowDom(shadowRoot))
|
|
826
909
|
serializedNode.isShadowHost = true;
|
|
827
910
|
}
|
|
@@ -833,41 +916,45 @@
|
|
|
833
916
|
serializedNode.tagName === 'head') {
|
|
834
917
|
preserveWhiteSpace = false;
|
|
835
918
|
}
|
|
836
|
-
|
|
837
|
-
doc
|
|
838
|
-
mirror
|
|
839
|
-
blockClass
|
|
840
|
-
blockSelector
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
919
|
+
const bypassOptions = {
|
|
920
|
+
doc,
|
|
921
|
+
mirror,
|
|
922
|
+
blockClass,
|
|
923
|
+
blockSelector,
|
|
924
|
+
needsMask,
|
|
925
|
+
maskTextClass,
|
|
926
|
+
maskTextSelector,
|
|
927
|
+
skipChild,
|
|
928
|
+
inlineStylesheet,
|
|
929
|
+
maskInputOptions,
|
|
930
|
+
maskTextFn,
|
|
931
|
+
maskInputFn,
|
|
932
|
+
slimDOMOptions,
|
|
933
|
+
dataURLOptions,
|
|
934
|
+
inlineImages,
|
|
935
|
+
recordCanvas,
|
|
936
|
+
preserveWhiteSpace,
|
|
937
|
+
onSerialize,
|
|
938
|
+
onIframeLoad,
|
|
939
|
+
iframeLoadTimeout,
|
|
940
|
+
onStylesheetLoad,
|
|
941
|
+
stylesheetLoadTimeout,
|
|
942
|
+
keepIframeSrcFn,
|
|
859
943
|
};
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
944
|
+
if (serializedNode.type === NodeType.Element &&
|
|
945
|
+
serializedNode.tagName === 'textarea' &&
|
|
946
|
+
serializedNode.attributes.value !== undefined) ;
|
|
947
|
+
else {
|
|
948
|
+
for (const childN of Array.from(n.childNodes)) {
|
|
949
|
+
const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
950
|
+
if (serializedChildNode) {
|
|
951
|
+
serializedNode.childNodes.push(serializedChildNode);
|
|
952
|
+
}
|
|
865
953
|
}
|
|
866
954
|
}
|
|
867
955
|
if (isElement(n) && n.shadowRoot) {
|
|
868
|
-
for (
|
|
869
|
-
|
|
870
|
-
var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
956
|
+
for (const childN of Array.from(n.shadowRoot.childNodes)) {
|
|
957
|
+
const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
871
958
|
if (serializedChildNode) {
|
|
872
959
|
isNativeShadowDom(n.shadowRoot) &&
|
|
873
960
|
(serializedChildNode.isShadow = true);
|
|
@@ -883,32 +970,33 @@
|
|
|
883
970
|
}
|
|
884
971
|
if (serializedNode.type === NodeType.Element &&
|
|
885
972
|
serializedNode.tagName === 'iframe') {
|
|
886
|
-
onceIframeLoaded(n,
|
|
887
|
-
|
|
973
|
+
onceIframeLoaded(n, () => {
|
|
974
|
+
const iframeDoc = n.contentDocument;
|
|
888
975
|
if (iframeDoc && onIframeLoad) {
|
|
889
|
-
|
|
976
|
+
const serializedIframeNode = serializeNodeWithId(iframeDoc, {
|
|
890
977
|
doc: iframeDoc,
|
|
891
|
-
mirror
|
|
892
|
-
blockClass
|
|
893
|
-
blockSelector
|
|
894
|
-
|
|
895
|
-
|
|
978
|
+
mirror,
|
|
979
|
+
blockClass,
|
|
980
|
+
blockSelector,
|
|
981
|
+
needsMask,
|
|
982
|
+
maskTextClass,
|
|
983
|
+
maskTextSelector,
|
|
896
984
|
skipChild: false,
|
|
897
|
-
inlineStylesheet
|
|
898
|
-
maskInputOptions
|
|
899
|
-
maskTextFn
|
|
900
|
-
maskInputFn
|
|
901
|
-
slimDOMOptions
|
|
902
|
-
dataURLOptions
|
|
903
|
-
inlineImages
|
|
904
|
-
recordCanvas
|
|
905
|
-
preserveWhiteSpace
|
|
906
|
-
onSerialize
|
|
907
|
-
onIframeLoad
|
|
908
|
-
iframeLoadTimeout
|
|
909
|
-
onStylesheetLoad
|
|
910
|
-
stylesheetLoadTimeout
|
|
911
|
-
keepIframeSrcFn
|
|
985
|
+
inlineStylesheet,
|
|
986
|
+
maskInputOptions,
|
|
987
|
+
maskTextFn,
|
|
988
|
+
maskInputFn,
|
|
989
|
+
slimDOMOptions,
|
|
990
|
+
dataURLOptions,
|
|
991
|
+
inlineImages,
|
|
992
|
+
recordCanvas,
|
|
993
|
+
preserveWhiteSpace,
|
|
994
|
+
onSerialize,
|
|
995
|
+
onIframeLoad,
|
|
996
|
+
iframeLoadTimeout,
|
|
997
|
+
onStylesheetLoad,
|
|
998
|
+
stylesheetLoadTimeout,
|
|
999
|
+
keepIframeSrcFn,
|
|
912
1000
|
});
|
|
913
1001
|
if (serializedIframeNode) {
|
|
914
1002
|
onIframeLoad(n, serializedIframeNode);
|
|
@@ -918,32 +1006,37 @@
|
|
|
918
1006
|
}
|
|
919
1007
|
if (serializedNode.type === NodeType.Element &&
|
|
920
1008
|
serializedNode.tagName === 'link' &&
|
|
921
|
-
serializedNode.attributes.rel === '
|
|
922
|
-
|
|
1009
|
+
typeof serializedNode.attributes.rel === 'string' &&
|
|
1010
|
+
(serializedNode.attributes.rel === 'stylesheet' ||
|
|
1011
|
+
(serializedNode.attributes.rel === 'preload' &&
|
|
1012
|
+
typeof serializedNode.attributes.href === 'string' &&
|
|
1013
|
+
extractFileExtension(serializedNode.attributes.href) === 'css'))) {
|
|
1014
|
+
onceStylesheetLoaded(n, () => {
|
|
923
1015
|
if (onStylesheetLoad) {
|
|
924
|
-
|
|
925
|
-
doc
|
|
926
|
-
mirror
|
|
927
|
-
blockClass
|
|
928
|
-
blockSelector
|
|
929
|
-
|
|
930
|
-
|
|
1016
|
+
const serializedLinkNode = serializeNodeWithId(n, {
|
|
1017
|
+
doc,
|
|
1018
|
+
mirror,
|
|
1019
|
+
blockClass,
|
|
1020
|
+
blockSelector,
|
|
1021
|
+
needsMask,
|
|
1022
|
+
maskTextClass,
|
|
1023
|
+
maskTextSelector,
|
|
931
1024
|
skipChild: false,
|
|
932
|
-
inlineStylesheet
|
|
933
|
-
maskInputOptions
|
|
934
|
-
maskTextFn
|
|
935
|
-
maskInputFn
|
|
936
|
-
slimDOMOptions
|
|
937
|
-
dataURLOptions
|
|
938
|
-
inlineImages
|
|
939
|
-
recordCanvas
|
|
940
|
-
preserveWhiteSpace
|
|
941
|
-
onSerialize
|
|
942
|
-
onIframeLoad
|
|
943
|
-
iframeLoadTimeout
|
|
944
|
-
onStylesheetLoad
|
|
945
|
-
stylesheetLoadTimeout
|
|
946
|
-
keepIframeSrcFn
|
|
1025
|
+
inlineStylesheet,
|
|
1026
|
+
maskInputOptions,
|
|
1027
|
+
maskTextFn,
|
|
1028
|
+
maskInputFn,
|
|
1029
|
+
slimDOMOptions,
|
|
1030
|
+
dataURLOptions,
|
|
1031
|
+
inlineImages,
|
|
1032
|
+
recordCanvas,
|
|
1033
|
+
preserveWhiteSpace,
|
|
1034
|
+
onSerialize,
|
|
1035
|
+
onIframeLoad,
|
|
1036
|
+
iframeLoadTimeout,
|
|
1037
|
+
onStylesheetLoad,
|
|
1038
|
+
stylesheetLoadTimeout,
|
|
1039
|
+
keepIframeSrcFn,
|
|
947
1040
|
});
|
|
948
1041
|
if (serializedLinkNode) {
|
|
949
1042
|
onStylesheetLoad(n, serializedLinkNode);
|
|
@@ -954,8 +1047,8 @@
|
|
|
954
1047
|
return serializedNode;
|
|
955
1048
|
}
|
|
956
1049
|
function snapshot(n, options) {
|
|
957
|
-
|
|
958
|
-
|
|
1050
|
+
const { mirror = new Mirror(), blockClass = 'rr-block', blockSelector = null, maskTextClass = 'rr-mask', maskTextSelector = null, inlineStylesheet = true, inlineImages = false, recordCanvas = false, maskAllInputs = false, maskTextFn, maskInputFn, slimDOM = false, dataURLOptions, preserveWhiteSpace, onSerialize, onIframeLoad, iframeLoadTimeout, onStylesheetLoad, stylesheetLoadTimeout, keepIframeSrcFn = () => false, } = options || {};
|
|
1051
|
+
const maskInputOptions = maskAllInputs === true
|
|
959
1052
|
? {
|
|
960
1053
|
color: true,
|
|
961
1054
|
date: true,
|
|
@@ -972,14 +1065,14 @@
|
|
|
972
1065
|
week: true,
|
|
973
1066
|
textarea: true,
|
|
974
1067
|
select: true,
|
|
975
|
-
password: true
|
|
1068
|
+
password: true,
|
|
976
1069
|
}
|
|
977
1070
|
: maskAllInputs === false
|
|
978
1071
|
? {
|
|
979
|
-
password: true
|
|
1072
|
+
password: true,
|
|
980
1073
|
}
|
|
981
1074
|
: maskAllInputs;
|
|
982
|
-
|
|
1075
|
+
const slimDOMOptions = slimDOM === true || slimDOM === 'all'
|
|
983
1076
|
?
|
|
984
1077
|
{
|
|
985
1078
|
script: true,
|
|
@@ -991,35 +1084,35 @@
|
|
|
991
1084
|
headMetaRobots: true,
|
|
992
1085
|
headMetaHttpEquiv: true,
|
|
993
1086
|
headMetaAuthorship: true,
|
|
994
|
-
headMetaVerification: true
|
|
1087
|
+
headMetaVerification: true,
|
|
995
1088
|
}
|
|
996
1089
|
: slimDOM === false
|
|
997
1090
|
? {}
|
|
998
1091
|
: slimDOM;
|
|
999
1092
|
return serializeNodeWithId(n, {
|
|
1000
1093
|
doc: n,
|
|
1001
|
-
mirror
|
|
1002
|
-
blockClass
|
|
1003
|
-
blockSelector
|
|
1004
|
-
maskTextClass
|
|
1005
|
-
maskTextSelector
|
|
1094
|
+
mirror,
|
|
1095
|
+
blockClass,
|
|
1096
|
+
blockSelector,
|
|
1097
|
+
maskTextClass,
|
|
1098
|
+
maskTextSelector,
|
|
1006
1099
|
skipChild: false,
|
|
1007
|
-
inlineStylesheet
|
|
1008
|
-
maskInputOptions
|
|
1009
|
-
maskTextFn
|
|
1010
|
-
maskInputFn
|
|
1011
|
-
slimDOMOptions
|
|
1012
|
-
dataURLOptions
|
|
1013
|
-
inlineImages
|
|
1014
|
-
recordCanvas
|
|
1015
|
-
preserveWhiteSpace
|
|
1016
|
-
onSerialize
|
|
1017
|
-
onIframeLoad
|
|
1018
|
-
iframeLoadTimeout
|
|
1019
|
-
onStylesheetLoad
|
|
1020
|
-
stylesheetLoadTimeout
|
|
1021
|
-
keepIframeSrcFn
|
|
1022
|
-
newlyAddedElement: false
|
|
1100
|
+
inlineStylesheet,
|
|
1101
|
+
maskInputOptions,
|
|
1102
|
+
maskTextFn,
|
|
1103
|
+
maskInputFn,
|
|
1104
|
+
slimDOMOptions,
|
|
1105
|
+
dataURLOptions,
|
|
1106
|
+
inlineImages,
|
|
1107
|
+
recordCanvas,
|
|
1108
|
+
preserveWhiteSpace,
|
|
1109
|
+
onSerialize,
|
|
1110
|
+
onIframeLoad,
|
|
1111
|
+
iframeLoadTimeout,
|
|
1112
|
+
onStylesheetLoad,
|
|
1113
|
+
stylesheetLoadTimeout,
|
|
1114
|
+
keepIframeSrcFn,
|
|
1115
|
+
newlyAddedElement: false,
|
|
1023
1116
|
});
|
|
1024
1117
|
}
|
|
1025
1118
|
|
|
@@ -1134,6 +1227,32 @@
|
|
|
1134
1227
|
};
|
|
1135
1228
|
}
|
|
1136
1229
|
}
|
|
1230
|
+
let nowTimestamp = Date.now;
|
|
1231
|
+
if (!(/[1-9][0-9]{12}/.test(Date.now().toString()))) {
|
|
1232
|
+
nowTimestamp = () => new Date().getTime();
|
|
1233
|
+
}
|
|
1234
|
+
function getWindowScroll(win) {
|
|
1235
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1236
|
+
const doc = win.document;
|
|
1237
|
+
return {
|
|
1238
|
+
left: doc.scrollingElement
|
|
1239
|
+
? doc.scrollingElement.scrollLeft
|
|
1240
|
+
: win.pageXOffset !== undefined
|
|
1241
|
+
? win.pageXOffset
|
|
1242
|
+
: (doc === null || doc === void 0 ? void 0 : doc.documentElement.scrollLeft) ||
|
|
1243
|
+
((_b = (_a = doc === null || doc === void 0 ? void 0 : doc.body) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.scrollLeft) ||
|
|
1244
|
+
((_c = doc === null || doc === void 0 ? void 0 : doc.body) === null || _c === void 0 ? void 0 : _c.scrollLeft) ||
|
|
1245
|
+
0,
|
|
1246
|
+
top: doc.scrollingElement
|
|
1247
|
+
? doc.scrollingElement.scrollTop
|
|
1248
|
+
: win.pageYOffset !== undefined
|
|
1249
|
+
? win.pageYOffset
|
|
1250
|
+
: (doc === null || doc === void 0 ? void 0 : doc.documentElement.scrollTop) ||
|
|
1251
|
+
((_e = (_d = doc === null || doc === void 0 ? void 0 : doc.body) === null || _d === void 0 ? void 0 : _d.parentElement) === null || _e === void 0 ? void 0 : _e.scrollTop) ||
|
|
1252
|
+
((_f = doc === null || doc === void 0 ? void 0 : doc.body) === null || _f === void 0 ? void 0 : _f.scrollTop) ||
|
|
1253
|
+
0,
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1137
1256
|
function getWindowHeight() {
|
|
1138
1257
|
return (window.innerHeight ||
|
|
1139
1258
|
(document.documentElement && document.documentElement.clientHeight) ||
|
|
@@ -1144,27 +1263,39 @@
|
|
|
1144
1263
|
(document.documentElement && document.documentElement.clientWidth) ||
|
|
1145
1264
|
(document.body && document.body.clientWidth));
|
|
1146
1265
|
}
|
|
1147
|
-
function
|
|
1266
|
+
function closestElementOfNode(node) {
|
|
1148
1267
|
if (!node) {
|
|
1149
|
-
return
|
|
1268
|
+
return null;
|
|
1150
1269
|
}
|
|
1151
1270
|
const el = node.nodeType === node.ELEMENT_NODE
|
|
1152
1271
|
? node
|
|
1153
1272
|
: node.parentElement;
|
|
1154
|
-
|
|
1273
|
+
return el;
|
|
1274
|
+
}
|
|
1275
|
+
function isBlocked(node, blockClass, blockSelector, checkAncestors) {
|
|
1276
|
+
if (!node) {
|
|
1155
1277
|
return false;
|
|
1156
|
-
if (typeof blockClass === 'string') {
|
|
1157
|
-
if (el.classList.contains(blockClass))
|
|
1158
|
-
return true;
|
|
1159
|
-
if (checkAncestors && el.closest('.' + blockClass) !== null)
|
|
1160
|
-
return true;
|
|
1161
1278
|
}
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1279
|
+
const el = closestElementOfNode(node);
|
|
1280
|
+
if (!el) {
|
|
1281
|
+
return false;
|
|
1282
|
+
}
|
|
1283
|
+
try {
|
|
1284
|
+
if (typeof blockClass === 'string') {
|
|
1285
|
+
if (el.classList.contains(blockClass))
|
|
1286
|
+
return true;
|
|
1287
|
+
if (checkAncestors && el.closest('.' + blockClass) !== null)
|
|
1288
|
+
return true;
|
|
1289
|
+
}
|
|
1290
|
+
else {
|
|
1291
|
+
if (classMatchesRegex(el, blockClass, checkAncestors))
|
|
1292
|
+
return true;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
catch (e) {
|
|
1165
1296
|
}
|
|
1166
1297
|
if (blockSelector) {
|
|
1167
|
-
if (
|
|
1298
|
+
if (el.matches(blockSelector))
|
|
1168
1299
|
return true;
|
|
1169
1300
|
if (checkAncestors && el.closest(blockSelector) !== null)
|
|
1170
1301
|
return true;
|
|
@@ -1194,7 +1325,7 @@
|
|
|
1194
1325
|
}
|
|
1195
1326
|
return isAncestorRemoved(target.parentNode, mirror);
|
|
1196
1327
|
}
|
|
1197
|
-
function
|
|
1328
|
+
function legacy_isTouchEvent(event) {
|
|
1198
1329
|
return Boolean(event.changedTouches);
|
|
1199
1330
|
}
|
|
1200
1331
|
function polyfill(win = window) {
|
|
@@ -1271,6 +1402,34 @@
|
|
|
1271
1402
|
generateId() {
|
|
1272
1403
|
return this.id++;
|
|
1273
1404
|
}
|
|
1405
|
+
}
|
|
1406
|
+
function getShadowHost(n) {
|
|
1407
|
+
var _a, _b;
|
|
1408
|
+
let shadowHost = null;
|
|
1409
|
+
if (((_b = (_a = n.getRootNode) === null || _a === void 0 ? void 0 : _a.call(n)) === null || _b === void 0 ? void 0 : _b.nodeType) === Node.DOCUMENT_FRAGMENT_NODE &&
|
|
1410
|
+
n.getRootNode().host)
|
|
1411
|
+
shadowHost = n.getRootNode().host;
|
|
1412
|
+
return shadowHost;
|
|
1413
|
+
}
|
|
1414
|
+
function getRootShadowHost(n) {
|
|
1415
|
+
let rootShadowHost = n;
|
|
1416
|
+
let shadowHost;
|
|
1417
|
+
while ((shadowHost = getShadowHost(rootShadowHost)))
|
|
1418
|
+
rootShadowHost = shadowHost;
|
|
1419
|
+
return rootShadowHost;
|
|
1420
|
+
}
|
|
1421
|
+
function shadowHostInDom(n) {
|
|
1422
|
+
const doc = n.ownerDocument;
|
|
1423
|
+
if (!doc)
|
|
1424
|
+
return false;
|
|
1425
|
+
const shadowHost = getRootShadowHost(n);
|
|
1426
|
+
return doc.contains(shadowHost);
|
|
1427
|
+
}
|
|
1428
|
+
function inDom(n) {
|
|
1429
|
+
const doc = n.ownerDocument;
|
|
1430
|
+
if (!doc)
|
|
1431
|
+
return false;
|
|
1432
|
+
return doc.contains(n) || shadowHostInDom(n);
|
|
1274
1433
|
}
|
|
1275
1434
|
|
|
1276
1435
|
var EventType = /* @__PURE__ */ ((EventType2) => {
|
|
@@ -1300,6 +1459,7 @@
|
|
|
1300
1459
|
IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
|
|
1301
1460
|
IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
|
|
1302
1461
|
IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
|
|
1462
|
+
IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
|
|
1303
1463
|
return IncrementalSource2;
|
|
1304
1464
|
})(IncrementalSource || {});
|
|
1305
1465
|
var MouseInteractions = /* @__PURE__ */ ((MouseInteractions2) => {
|
|
@@ -1316,6 +1476,12 @@
|
|
|
1316
1476
|
MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
|
|
1317
1477
|
return MouseInteractions2;
|
|
1318
1478
|
})(MouseInteractions || {});
|
|
1479
|
+
var PointerTypes = /* @__PURE__ */ ((PointerTypes2) => {
|
|
1480
|
+
PointerTypes2[PointerTypes2["Mouse"] = 0] = "Mouse";
|
|
1481
|
+
PointerTypes2[PointerTypes2["Pen"] = 1] = "Pen";
|
|
1482
|
+
PointerTypes2[PointerTypes2["Touch"] = 2] = "Touch";
|
|
1483
|
+
return PointerTypes2;
|
|
1484
|
+
})(PointerTypes || {});
|
|
1319
1485
|
var CanvasContext = /* @__PURE__ */ ((CanvasContext2) => {
|
|
1320
1486
|
CanvasContext2[CanvasContext2["2D"] = 0] = "2D";
|
|
1321
1487
|
CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL";
|
|
@@ -1330,6 +1496,7 @@
|
|
|
1330
1496
|
constructor() {
|
|
1331
1497
|
this.length = 0;
|
|
1332
1498
|
this.head = null;
|
|
1499
|
+
this.tail = null;
|
|
1333
1500
|
}
|
|
1334
1501
|
get(position) {
|
|
1335
1502
|
if (position >= this.length) {
|
|
@@ -1375,6 +1542,9 @@
|
|
|
1375
1542
|
node.next = this.head;
|
|
1376
1543
|
this.head = node;
|
|
1377
1544
|
}
|
|
1545
|
+
if (node.next === null) {
|
|
1546
|
+
this.tail = node;
|
|
1547
|
+
}
|
|
1378
1548
|
this.length++;
|
|
1379
1549
|
}
|
|
1380
1550
|
removeNode(n) {
|
|
@@ -1387,12 +1557,18 @@
|
|
|
1387
1557
|
if (this.head) {
|
|
1388
1558
|
this.head.previous = null;
|
|
1389
1559
|
}
|
|
1560
|
+
else {
|
|
1561
|
+
this.tail = null;
|
|
1562
|
+
}
|
|
1390
1563
|
}
|
|
1391
1564
|
else {
|
|
1392
1565
|
current.previous.next = current.next;
|
|
1393
1566
|
if (current.next) {
|
|
1394
1567
|
current.next.previous = current.previous;
|
|
1395
1568
|
}
|
|
1569
|
+
else {
|
|
1570
|
+
this.tail = current.previous;
|
|
1571
|
+
}
|
|
1396
1572
|
}
|
|
1397
1573
|
if (n.__ln) {
|
|
1398
1574
|
delete n.__ln;
|
|
@@ -1407,6 +1583,7 @@
|
|
|
1407
1583
|
this.locked = false;
|
|
1408
1584
|
this.texts = [];
|
|
1409
1585
|
this.attributes = [];
|
|
1586
|
+
this.attributeMap = new WeakMap();
|
|
1410
1587
|
this.removes = [];
|
|
1411
1588
|
this.mapRemoves = [];
|
|
1412
1589
|
this.movedMap = {};
|
|
@@ -1422,6 +1599,7 @@
|
|
|
1422
1599
|
return;
|
|
1423
1600
|
}
|
|
1424
1601
|
const adds = [];
|
|
1602
|
+
const addedIds = new Set();
|
|
1425
1603
|
const addList = new DoubleLinkedList();
|
|
1426
1604
|
const getNextId = (n) => {
|
|
1427
1605
|
let ns = n;
|
|
@@ -1433,23 +1611,13 @@
|
|
|
1433
1611
|
return nextId;
|
|
1434
1612
|
};
|
|
1435
1613
|
const pushAdd = (n) => {
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
n.getRootNode().host)
|
|
1440
|
-
shadowHost = n.getRootNode().host;
|
|
1441
|
-
let rootShadowHost = shadowHost;
|
|
1442
|
-
while (((_d = (_c = rootShadowHost === null || rootShadowHost === void 0 ? void 0 : rootShadowHost.getRootNode) === null || _c === void 0 ? void 0 : _c.call(rootShadowHost)) === null || _d === void 0 ? void 0 : _d.nodeType) ===
|
|
1443
|
-
Node.DOCUMENT_FRAGMENT_NODE &&
|
|
1444
|
-
rootShadowHost.getRootNode().host)
|
|
1445
|
-
rootShadowHost = rootShadowHost.getRootNode().host;
|
|
1446
|
-
const notInDoc = !this.doc.contains(n) &&
|
|
1447
|
-
(!rootShadowHost || !this.doc.contains(rootShadowHost));
|
|
1448
|
-
if (!n.parentNode || notInDoc) {
|
|
1614
|
+
if (!n.parentNode ||
|
|
1615
|
+
!inDom(n) ||
|
|
1616
|
+
n.parentNode.tagName === 'TEXTAREA') {
|
|
1449
1617
|
return;
|
|
1450
1618
|
}
|
|
1451
1619
|
const parentId = isShadowRoot(n.parentNode)
|
|
1452
|
-
? this.mirror.getId(
|
|
1620
|
+
? this.mirror.getId(getShadowHost(n))
|
|
1453
1621
|
: this.mirror.getId(n.parentNode);
|
|
1454
1622
|
const nextId = getNextId(n);
|
|
1455
1623
|
if (parentId === -1 || nextId === -1) {
|
|
@@ -1497,19 +1665,20 @@
|
|
|
1497
1665
|
nextId,
|
|
1498
1666
|
node: sn,
|
|
1499
1667
|
});
|
|
1668
|
+
addedIds.add(sn.id);
|
|
1500
1669
|
}
|
|
1501
1670
|
};
|
|
1502
1671
|
while (this.mapRemoves.length) {
|
|
1503
1672
|
this.mirror.removeNodeFromMap(this.mapRemoves.shift());
|
|
1504
1673
|
}
|
|
1505
|
-
for (const n of
|
|
1674
|
+
for (const n of this.movedSet) {
|
|
1506
1675
|
if (isParentRemoved(this.removes, n, this.mirror) &&
|
|
1507
1676
|
!this.movedSet.has(n.parentNode)) {
|
|
1508
1677
|
continue;
|
|
1509
1678
|
}
|
|
1510
1679
|
pushAdd(n);
|
|
1511
1680
|
}
|
|
1512
|
-
for (const n of
|
|
1681
|
+
for (const n of this.addedSet) {
|
|
1513
1682
|
if (!isAncestorInSet(this.droppedSet, n) &&
|
|
1514
1683
|
!isParentRemoved(this.removes, n, this.mirror)) {
|
|
1515
1684
|
pushAdd(n);
|
|
@@ -1532,8 +1701,10 @@
|
|
|
1532
1701
|
}
|
|
1533
1702
|
}
|
|
1534
1703
|
if (!node) {
|
|
1535
|
-
|
|
1536
|
-
|
|
1704
|
+
let tailNode = addList.tail;
|
|
1705
|
+
while (tailNode) {
|
|
1706
|
+
const _node = tailNode;
|
|
1707
|
+
tailNode = tailNode.previous;
|
|
1537
1708
|
if (_node) {
|
|
1538
1709
|
const parentId = this.mirror.getId(_node.value.parentNode);
|
|
1539
1710
|
const nextId = getNextId(_node.value);
|
|
@@ -1572,16 +1743,38 @@
|
|
|
1572
1743
|
}
|
|
1573
1744
|
const payload = {
|
|
1574
1745
|
texts: this.texts
|
|
1575
|
-
.map((text) =>
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1746
|
+
.map((text) => {
|
|
1747
|
+
const n = text.node;
|
|
1748
|
+
if (n.parentNode &&
|
|
1749
|
+
n.parentNode.tagName === 'TEXTAREA') {
|
|
1750
|
+
this.genTextAreaValueMutation(n.parentNode);
|
|
1751
|
+
}
|
|
1752
|
+
return {
|
|
1753
|
+
id: this.mirror.getId(n),
|
|
1754
|
+
value: text.value,
|
|
1755
|
+
};
|
|
1756
|
+
})
|
|
1757
|
+
.filter((text) => !addedIds.has(text.id))
|
|
1579
1758
|
.filter((text) => this.mirror.has(text.id)),
|
|
1580
1759
|
attributes: this.attributes
|
|
1581
|
-
.map((attribute) =>
|
|
1582
|
-
|
|
1583
|
-
attributes
|
|
1584
|
-
|
|
1760
|
+
.map((attribute) => {
|
|
1761
|
+
const { attributes } = attribute;
|
|
1762
|
+
if (typeof attributes.style === 'string') {
|
|
1763
|
+
const diffAsStr = JSON.stringify(attribute.styleDiff);
|
|
1764
|
+
const unchangedAsStr = JSON.stringify(attribute._unchangedStyles);
|
|
1765
|
+
if (diffAsStr.length < attributes.style.length) {
|
|
1766
|
+
if ((diffAsStr + unchangedAsStr).split('var(').length ===
|
|
1767
|
+
attributes.style.split('var(').length) {
|
|
1768
|
+
attributes.style = attribute.styleDiff;
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
return {
|
|
1773
|
+
id: this.mirror.getId(attribute.node),
|
|
1774
|
+
attributes: attributes,
|
|
1775
|
+
};
|
|
1776
|
+
})
|
|
1777
|
+
.filter((attribute) => !addedIds.has(attribute.id))
|
|
1585
1778
|
.filter((attribute) => this.mirror.has(attribute.id)),
|
|
1586
1779
|
removes: this.removes,
|
|
1587
1780
|
adds,
|
|
@@ -1594,6 +1787,7 @@
|
|
|
1594
1787
|
}
|
|
1595
1788
|
this.texts = [];
|
|
1596
1789
|
this.attributes = [];
|
|
1790
|
+
this.attributeMap = new WeakMap();
|
|
1597
1791
|
this.removes = [];
|
|
1598
1792
|
this.addedSet = new Set();
|
|
1599
1793
|
this.movedSet = new Set();
|
|
@@ -1601,6 +1795,20 @@
|
|
|
1601
1795
|
this.movedMap = {};
|
|
1602
1796
|
this.mutationCb(payload);
|
|
1603
1797
|
};
|
|
1798
|
+
this.genTextAreaValueMutation = (textarea) => {
|
|
1799
|
+
let item = this.attributeMap.get(textarea);
|
|
1800
|
+
if (!item) {
|
|
1801
|
+
item = {
|
|
1802
|
+
node: textarea,
|
|
1803
|
+
attributes: {},
|
|
1804
|
+
styleDiff: {},
|
|
1805
|
+
_unchangedStyles: {},
|
|
1806
|
+
};
|
|
1807
|
+
this.attributes.push(item);
|
|
1808
|
+
this.attributeMap.set(textarea, item);
|
|
1809
|
+
}
|
|
1810
|
+
item.attributes.value = Array.from(textarea.childNodes, (cn) => cn.textContent || '').join('');
|
|
1811
|
+
};
|
|
1604
1812
|
this.processMutation = (m) => {
|
|
1605
1813
|
if (isIgnored(m.target, this.mirror)) {
|
|
1606
1814
|
return;
|
|
@@ -1611,9 +1819,9 @@
|
|
|
1611
1819
|
if (!isBlocked(m.target, this.blockClass, this.blockSelector, false) &&
|
|
1612
1820
|
value !== m.oldValue) {
|
|
1613
1821
|
this.texts.push({
|
|
1614
|
-
value: needMaskingText(m.target, this.maskTextClass, this.maskTextSelector) && value
|
|
1822
|
+
value: needMaskingText(m.target, this.maskTextClass, this.maskTextSelector, true) && value
|
|
1615
1823
|
? this.maskTextFn
|
|
1616
|
-
? this.maskTextFn(value)
|
|
1824
|
+
? this.maskTextFn(value, closestElementOfNode(m.target))
|
|
1617
1825
|
: value.replace(/[\S]/g, '*')
|
|
1618
1826
|
: value,
|
|
1619
1827
|
node: m.target,
|
|
@@ -1623,12 +1831,15 @@
|
|
|
1623
1831
|
}
|
|
1624
1832
|
case 'attributes': {
|
|
1625
1833
|
const target = m.target;
|
|
1626
|
-
let
|
|
1627
|
-
|
|
1834
|
+
let attributeName = m.attributeName;
|
|
1835
|
+
let value = m.target.getAttribute(attributeName);
|
|
1836
|
+
if (attributeName === 'value') {
|
|
1837
|
+
const type = getInputType(target);
|
|
1628
1838
|
value = maskInputValue({
|
|
1839
|
+
element: target,
|
|
1629
1840
|
maskInputOptions: this.maskInputOptions,
|
|
1630
|
-
tagName:
|
|
1631
|
-
type
|
|
1841
|
+
tagName: target.tagName,
|
|
1842
|
+
type,
|
|
1632
1843
|
value,
|
|
1633
1844
|
maskInputFn: this.maskInputFn,
|
|
1634
1845
|
});
|
|
@@ -1637,12 +1848,12 @@
|
|
|
1637
1848
|
value === m.oldValue) {
|
|
1638
1849
|
return;
|
|
1639
1850
|
}
|
|
1640
|
-
let item = this.
|
|
1851
|
+
let item = this.attributeMap.get(m.target);
|
|
1641
1852
|
if (target.tagName === 'IFRAME' &&
|
|
1642
|
-
|
|
1853
|
+
attributeName === 'src' &&
|
|
1643
1854
|
!this.keepIframeSrcFn(value)) {
|
|
1644
1855
|
if (!target.contentDocument) {
|
|
1645
|
-
|
|
1856
|
+
attributeName = 'rr_src';
|
|
1646
1857
|
}
|
|
1647
1858
|
else {
|
|
1648
1859
|
return;
|
|
@@ -1652,46 +1863,65 @@
|
|
|
1652
1863
|
item = {
|
|
1653
1864
|
node: m.target,
|
|
1654
1865
|
attributes: {},
|
|
1866
|
+
styleDiff: {},
|
|
1867
|
+
_unchangedStyles: {},
|
|
1655
1868
|
};
|
|
1656
1869
|
this.attributes.push(item);
|
|
1870
|
+
this.attributeMap.set(m.target, item);
|
|
1657
1871
|
}
|
|
1658
|
-
if (
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1872
|
+
if (attributeName === 'type' &&
|
|
1873
|
+
target.tagName === 'INPUT' &&
|
|
1874
|
+
(m.oldValue || '').toLowerCase() === 'password') {
|
|
1875
|
+
target.setAttribute('data-rr-is-password', 'true');
|
|
1876
|
+
}
|
|
1877
|
+
if (!ignoreAttribute(target.tagName, attributeName)) {
|
|
1878
|
+
item.attributes[attributeName] = transformAttribute(this.doc, toLowerCase(target.tagName), toLowerCase(attributeName), value);
|
|
1879
|
+
if (attributeName === 'style') {
|
|
1880
|
+
if (!this.unattachedDoc) {
|
|
1881
|
+
try {
|
|
1882
|
+
this.unattachedDoc =
|
|
1883
|
+
document.implementation.createHTMLDocument();
|
|
1884
|
+
}
|
|
1885
|
+
catch (e) {
|
|
1886
|
+
this.unattachedDoc = this.doc;
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
const old = this.unattachedDoc.createElement('span');
|
|
1890
|
+
if (m.oldValue) {
|
|
1891
|
+
old.setAttribute('style', m.oldValue);
|
|
1892
|
+
}
|
|
1893
|
+
for (const pname of Array.from(target.style)) {
|
|
1894
|
+
const newValue = target.style.getPropertyValue(pname);
|
|
1895
|
+
const newPriority = target.style.getPropertyPriority(pname);
|
|
1896
|
+
if (newValue !== old.style.getPropertyValue(pname) ||
|
|
1897
|
+
newPriority !== old.style.getPropertyPriority(pname)) {
|
|
1898
|
+
if (newPriority === '') {
|
|
1899
|
+
item.styleDiff[pname] = newValue;
|
|
1900
|
+
}
|
|
1901
|
+
else {
|
|
1902
|
+
item.styleDiff[pname] = [newValue, newPriority];
|
|
1903
|
+
}
|
|
1675
1904
|
}
|
|
1676
1905
|
else {
|
|
1677
|
-
|
|
1906
|
+
item._unchangedStyles[pname] = [newValue, newPriority];
|
|
1678
1907
|
}
|
|
1679
1908
|
}
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1909
|
+
for (const pname of Array.from(old.style)) {
|
|
1910
|
+
if (target.style.getPropertyValue(pname) === '') {
|
|
1911
|
+
item.styleDiff[pname] = false;
|
|
1912
|
+
}
|
|
1684
1913
|
}
|
|
1685
1914
|
}
|
|
1686
1915
|
}
|
|
1687
|
-
else {
|
|
1688
|
-
item.attributes[m.attributeName] = transformAttribute(this.doc, target.tagName, m.attributeName, value);
|
|
1689
|
-
}
|
|
1690
1916
|
break;
|
|
1691
1917
|
}
|
|
1692
1918
|
case 'childList': {
|
|
1693
1919
|
if (isBlocked(m.target, this.blockClass, this.blockSelector, true))
|
|
1694
1920
|
return;
|
|
1921
|
+
if (m.target.tagName === 'TEXTAREA') {
|
|
1922
|
+
this.genTextAreaValueMutation(m.target);
|
|
1923
|
+
return;
|
|
1924
|
+
}
|
|
1695
1925
|
m.addedNodes.forEach((n) => this.genAdds(n, m.target));
|
|
1696
1926
|
m.removedNodes.forEach((n) => {
|
|
1697
1927
|
const nodeId = this.mirror.getId(n);
|
|
@@ -1729,6 +1959,10 @@
|
|
|
1729
1959
|
}
|
|
1730
1960
|
};
|
|
1731
1961
|
this.genAdds = (n, target) => {
|
|
1962
|
+
if (this.processedNodeManager.inOtherBuffer(n, this))
|
|
1963
|
+
return;
|
|
1964
|
+
if (this.addedSet.has(n) || this.movedSet.has(n))
|
|
1965
|
+
return;
|
|
1732
1966
|
if (this.mirror.hasNode(n)) {
|
|
1733
1967
|
if (isIgnored(n, this.mirror)) {
|
|
1734
1968
|
return;
|
|
@@ -1746,8 +1980,15 @@
|
|
|
1746
1980
|
this.addedSet.add(n);
|
|
1747
1981
|
this.droppedSet.delete(n);
|
|
1748
1982
|
}
|
|
1749
|
-
if (!isBlocked(n, this.blockClass, this.blockSelector, false))
|
|
1983
|
+
if (!isBlocked(n, this.blockClass, this.blockSelector, false)) {
|
|
1750
1984
|
n.childNodes.forEach((childN) => this.genAdds(childN));
|
|
1985
|
+
if (hasShadowRoot(n)) {
|
|
1986
|
+
n.shadowRoot.childNodes.forEach((childN) => {
|
|
1987
|
+
this.processedNodeManager.add(childN, this);
|
|
1988
|
+
this.genAdds(childN, n);
|
|
1989
|
+
});
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1751
1992
|
};
|
|
1752
1993
|
}
|
|
1753
1994
|
init(options) {
|
|
@@ -1772,6 +2013,7 @@
|
|
|
1772
2013
|
'stylesheetManager',
|
|
1773
2014
|
'shadowDomManager',
|
|
1774
2015
|
'canvasManager',
|
|
2016
|
+
'processedNodeManager',
|
|
1775
2017
|
].forEach((key) => {
|
|
1776
2018
|
this[key] = options[key];
|
|
1777
2019
|
});
|
|
@@ -1838,11 +2080,32 @@
|
|
|
1838
2080
|
return _isAncestorInSet(set, parentNode);
|
|
1839
2081
|
}
|
|
1840
2082
|
|
|
2083
|
+
let errorHandler;
|
|
2084
|
+
function registerErrorHandler(handler) {
|
|
2085
|
+
errorHandler = handler;
|
|
2086
|
+
}
|
|
2087
|
+
function unregisterErrorHandler() {
|
|
2088
|
+
errorHandler = undefined;
|
|
2089
|
+
}
|
|
2090
|
+
const callbackWrapper = (cb) => {
|
|
2091
|
+
if (!errorHandler) {
|
|
2092
|
+
return cb;
|
|
2093
|
+
}
|
|
2094
|
+
const rrwebWrapped = ((...rest) => {
|
|
2095
|
+
try {
|
|
2096
|
+
return cb(...rest);
|
|
2097
|
+
}
|
|
2098
|
+
catch (error) {
|
|
2099
|
+
if (errorHandler && errorHandler(error) === true) {
|
|
2100
|
+
return;
|
|
2101
|
+
}
|
|
2102
|
+
throw error;
|
|
2103
|
+
}
|
|
2104
|
+
});
|
|
2105
|
+
return rrwebWrapped;
|
|
2106
|
+
};
|
|
2107
|
+
|
|
1841
2108
|
const mutationBuffers = [];
|
|
1842
|
-
const isCSSGroupingRuleSupported = typeof CSSGroupingRule !== 'undefined';
|
|
1843
|
-
const isCSSMediaRuleSupported = typeof CSSMediaRule !== 'undefined';
|
|
1844
|
-
const isCSSSupportsRuleSupported = typeof CSSSupportsRule !== 'undefined';
|
|
1845
|
-
const isCSSConditionRuleSupported = typeof CSSConditionRule !== 'undefined';
|
|
1846
2109
|
function getEventTarget(event) {
|
|
1847
2110
|
try {
|
|
1848
2111
|
if ('composedPath' in event) {
|
|
@@ -1854,11 +2117,10 @@
|
|
|
1854
2117
|
else if ('path' in event && event.path.length) {
|
|
1855
2118
|
return event.path[0];
|
|
1856
2119
|
}
|
|
1857
|
-
return event.target;
|
|
1858
2120
|
}
|
|
1859
2121
|
catch (_a) {
|
|
1860
|
-
return event.target;
|
|
1861
2122
|
}
|
|
2123
|
+
return event && event.target;
|
|
1862
2124
|
}
|
|
1863
2125
|
function initMutationObserver(options, rootEl) {
|
|
1864
2126
|
var _a, _b;
|
|
@@ -1872,7 +2134,7 @@
|
|
|
1872
2134
|
window[angularZoneSymbol]) {
|
|
1873
2135
|
mutationObserverCtor = window[angularZoneSymbol];
|
|
1874
2136
|
}
|
|
1875
|
-
const observer = new mutationObserverCtor(mutationBuffer.processMutations.bind(mutationBuffer));
|
|
2137
|
+
const observer = new mutationObserverCtor(callbackWrapper(mutationBuffer.processMutations.bind(mutationBuffer)));
|
|
1876
2138
|
observer.observe(rootEl, {
|
|
1877
2139
|
attributes: true,
|
|
1878
2140
|
attributeOldValue: true,
|
|
@@ -1894,7 +2156,7 @@
|
|
|
1894
2156
|
: 500;
|
|
1895
2157
|
let positions = [];
|
|
1896
2158
|
let timeBaseline;
|
|
1897
|
-
const wrappedCb = throttle((source) => {
|
|
2159
|
+
const wrappedCb = throttle(callbackWrapper((source) => {
|
|
1898
2160
|
const totalOffset = Date.now() - timeBaseline;
|
|
1899
2161
|
mousemoveCb(positions.map((p) => {
|
|
1900
2162
|
p.timeOffset -= totalOffset;
|
|
@@ -1902,37 +2164,37 @@
|
|
|
1902
2164
|
}), source);
|
|
1903
2165
|
positions = [];
|
|
1904
2166
|
timeBaseline = null;
|
|
1905
|
-
}, callbackThreshold);
|
|
1906
|
-
const updatePosition = throttle((evt) => {
|
|
2167
|
+
}), callbackThreshold);
|
|
2168
|
+
const updatePosition = callbackWrapper(throttle(callbackWrapper((evt) => {
|
|
1907
2169
|
const target = getEventTarget(evt);
|
|
1908
|
-
const { clientX, clientY } =
|
|
2170
|
+
const { clientX, clientY } = legacy_isTouchEvent(evt)
|
|
1909
2171
|
? evt.changedTouches[0]
|
|
1910
2172
|
: evt;
|
|
1911
2173
|
if (!timeBaseline) {
|
|
1912
|
-
timeBaseline =
|
|
2174
|
+
timeBaseline = nowTimestamp();
|
|
1913
2175
|
}
|
|
1914
2176
|
positions.push({
|
|
1915
2177
|
x: clientX,
|
|
1916
2178
|
y: clientY,
|
|
1917
2179
|
id: mirror.getId(target),
|
|
1918
|
-
timeOffset:
|
|
2180
|
+
timeOffset: nowTimestamp() - timeBaseline,
|
|
1919
2181
|
});
|
|
1920
2182
|
wrappedCb(typeof DragEvent !== 'undefined' && evt instanceof DragEvent
|
|
1921
2183
|
? IncrementalSource.Drag
|
|
1922
2184
|
: evt instanceof MouseEvent
|
|
1923
2185
|
? IncrementalSource.MouseMove
|
|
1924
2186
|
: IncrementalSource.TouchMove);
|
|
1925
|
-
}, threshold, {
|
|
2187
|
+
}), threshold, {
|
|
1926
2188
|
trailing: false,
|
|
1927
|
-
});
|
|
2189
|
+
}));
|
|
1928
2190
|
const handlers = [
|
|
1929
2191
|
on('mousemove', updatePosition, doc),
|
|
1930
2192
|
on('touchmove', updatePosition, doc),
|
|
1931
2193
|
on('drag', updatePosition, doc),
|
|
1932
2194
|
];
|
|
1933
|
-
return () => {
|
|
2195
|
+
return callbackWrapper(() => {
|
|
1934
2196
|
handlers.forEach((h) => h());
|
|
1935
|
-
};
|
|
2197
|
+
});
|
|
1936
2198
|
}
|
|
1937
2199
|
function initMouseInteractionObserver({ mouseInteractionCb, doc, mirror, blockClass, blockSelector, sampling, }) {
|
|
1938
2200
|
if (sampling.mouseInteraction === false) {
|
|
@@ -1944,24 +2206,60 @@
|
|
|
1944
2206
|
? {}
|
|
1945
2207
|
: sampling.mouseInteraction;
|
|
1946
2208
|
const handlers = [];
|
|
2209
|
+
let currentPointerType = null;
|
|
1947
2210
|
const getHandler = (eventKey) => {
|
|
1948
2211
|
return (event) => {
|
|
1949
2212
|
const target = getEventTarget(event);
|
|
1950
2213
|
if (isBlocked(target, blockClass, blockSelector, true)) {
|
|
1951
2214
|
return;
|
|
1952
2215
|
}
|
|
1953
|
-
|
|
2216
|
+
let pointerType = null;
|
|
2217
|
+
let thisEventKey = eventKey;
|
|
2218
|
+
if ('pointerType' in event) {
|
|
2219
|
+
switch (event.pointerType) {
|
|
2220
|
+
case 'mouse':
|
|
2221
|
+
pointerType = PointerTypes.Mouse;
|
|
2222
|
+
break;
|
|
2223
|
+
case 'touch':
|
|
2224
|
+
pointerType = PointerTypes.Touch;
|
|
2225
|
+
break;
|
|
2226
|
+
case 'pen':
|
|
2227
|
+
pointerType = PointerTypes.Pen;
|
|
2228
|
+
break;
|
|
2229
|
+
}
|
|
2230
|
+
if (pointerType === PointerTypes.Touch) {
|
|
2231
|
+
if (MouseInteractions[eventKey] === MouseInteractions.MouseDown) {
|
|
2232
|
+
thisEventKey = 'TouchStart';
|
|
2233
|
+
}
|
|
2234
|
+
else if (MouseInteractions[eventKey] === MouseInteractions.MouseUp) {
|
|
2235
|
+
thisEventKey = 'TouchEnd';
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
else if (pointerType === PointerTypes.Pen) ;
|
|
2239
|
+
}
|
|
2240
|
+
else if (legacy_isTouchEvent(event)) {
|
|
2241
|
+
pointerType = PointerTypes.Touch;
|
|
2242
|
+
}
|
|
2243
|
+
if (pointerType !== null) {
|
|
2244
|
+
currentPointerType = pointerType;
|
|
2245
|
+
if ((thisEventKey.startsWith('Touch') &&
|
|
2246
|
+
pointerType === PointerTypes.Touch) ||
|
|
2247
|
+
(thisEventKey.startsWith('Mouse') &&
|
|
2248
|
+
pointerType === PointerTypes.Mouse)) {
|
|
2249
|
+
pointerType = null;
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
else if (MouseInteractions[eventKey] === MouseInteractions.Click) {
|
|
2253
|
+
pointerType = currentPointerType;
|
|
2254
|
+
currentPointerType = null;
|
|
2255
|
+
}
|
|
2256
|
+
const e = legacy_isTouchEvent(event) ? event.changedTouches[0] : event;
|
|
1954
2257
|
if (!e) {
|
|
1955
2258
|
return;
|
|
1956
2259
|
}
|
|
1957
2260
|
const id = mirror.getId(target);
|
|
1958
2261
|
const { clientX, clientY } = e;
|
|
1959
|
-
mouseInteractionCb({
|
|
1960
|
-
type: MouseInteractions[eventKey],
|
|
1961
|
-
id,
|
|
1962
|
-
x: clientX,
|
|
1963
|
-
y: clientY,
|
|
1964
|
-
});
|
|
2262
|
+
callbackWrapper(mouseInteractionCb)(Object.assign({ type: MouseInteractions[thisEventKey], id, x: clientX, y: clientY }, (pointerType !== null && { pointerType })));
|
|
1965
2263
|
};
|
|
1966
2264
|
};
|
|
1967
2265
|
Object.keys(MouseInteractions)
|
|
@@ -1969,27 +2267,39 @@
|
|
|
1969
2267
|
!key.endsWith('_Departed') &&
|
|
1970
2268
|
disableMap[key] !== false)
|
|
1971
2269
|
.forEach((eventKey) => {
|
|
1972
|
-
|
|
2270
|
+
let eventName = toLowerCase(eventKey);
|
|
1973
2271
|
const handler = getHandler(eventKey);
|
|
2272
|
+
if (window.PointerEvent) {
|
|
2273
|
+
switch (MouseInteractions[eventKey]) {
|
|
2274
|
+
case MouseInteractions.MouseDown:
|
|
2275
|
+
case MouseInteractions.MouseUp:
|
|
2276
|
+
eventName = eventName.replace('mouse', 'pointer');
|
|
2277
|
+
break;
|
|
2278
|
+
case MouseInteractions.TouchStart:
|
|
2279
|
+
case MouseInteractions.TouchEnd:
|
|
2280
|
+
return;
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
1974
2283
|
handlers.push(on(eventName, handler, doc));
|
|
1975
2284
|
});
|
|
1976
|
-
return () => {
|
|
2285
|
+
return callbackWrapper(() => {
|
|
1977
2286
|
handlers.forEach((h) => h());
|
|
1978
|
-
};
|
|
2287
|
+
});
|
|
1979
2288
|
}
|
|
1980
2289
|
function initScrollObserver({ scrollCb, doc, mirror, blockClass, blockSelector, sampling, }) {
|
|
1981
|
-
const updatePosition = throttle((evt) => {
|
|
2290
|
+
const updatePosition = callbackWrapper(throttle(callbackWrapper((evt) => {
|
|
1982
2291
|
const target = getEventTarget(evt);
|
|
1983
|
-
if (!target ||
|
|
2292
|
+
if (!target ||
|
|
2293
|
+
isBlocked(target, blockClass, blockSelector, true)) {
|
|
1984
2294
|
return;
|
|
1985
2295
|
}
|
|
1986
2296
|
const id = mirror.getId(target);
|
|
1987
|
-
if (target === doc) {
|
|
1988
|
-
const
|
|
2297
|
+
if (target === doc && doc.defaultView) {
|
|
2298
|
+
const scrollLeftTop = getWindowScroll(doc.defaultView);
|
|
1989
2299
|
scrollCb({
|
|
1990
2300
|
id,
|
|
1991
|
-
x:
|
|
1992
|
-
y:
|
|
2301
|
+
x: scrollLeftTop.left,
|
|
2302
|
+
y: scrollLeftTop.top,
|
|
1993
2303
|
});
|
|
1994
2304
|
}
|
|
1995
2305
|
else {
|
|
@@ -1999,13 +2309,13 @@
|
|
|
1999
2309
|
y: target.scrollTop,
|
|
2000
2310
|
});
|
|
2001
2311
|
}
|
|
2002
|
-
}, sampling.scroll || 100);
|
|
2312
|
+
}), sampling.scroll || 100));
|
|
2003
2313
|
return on('scroll', updatePosition, doc);
|
|
2004
2314
|
}
|
|
2005
|
-
function initViewportResizeObserver({ viewportResizeCb, }) {
|
|
2315
|
+
function initViewportResizeObserver({ viewportResizeCb }, { win }) {
|
|
2006
2316
|
let lastH = -1;
|
|
2007
2317
|
let lastW = -1;
|
|
2008
|
-
const updateDimension = throttle(() => {
|
|
2318
|
+
const updateDimension = callbackWrapper(throttle(callbackWrapper(() => {
|
|
2009
2319
|
const height = getWindowHeight();
|
|
2010
2320
|
const width = getWindowWidth();
|
|
2011
2321
|
if (lastH !== height || lastW !== width) {
|
|
@@ -2016,60 +2326,59 @@
|
|
|
2016
2326
|
lastH = height;
|
|
2017
2327
|
lastW = width;
|
|
2018
2328
|
}
|
|
2019
|
-
}, 200);
|
|
2020
|
-
return on('resize', updateDimension,
|
|
2021
|
-
}
|
|
2022
|
-
function wrapEventWithUserTriggeredFlag(v, enable) {
|
|
2023
|
-
const value = Object.assign({}, v);
|
|
2024
|
-
if (!enable)
|
|
2025
|
-
delete value.userTriggered;
|
|
2026
|
-
return value;
|
|
2329
|
+
}), 200));
|
|
2330
|
+
return on('resize', updateDimension, win);
|
|
2027
2331
|
}
|
|
2028
2332
|
const INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT'];
|
|
2029
2333
|
const lastInputValueMap = new WeakMap();
|
|
2030
|
-
function initInputObserver({ inputCb, doc, mirror, blockClass, blockSelector, ignoreClass, maskInputOptions, maskInputFn, sampling, userTriggeredOnInput, }) {
|
|
2334
|
+
function initInputObserver({ inputCb, doc, mirror, blockClass, blockSelector, ignoreClass, ignoreSelector, maskInputOptions, maskInputFn, sampling, userTriggeredOnInput, }) {
|
|
2031
2335
|
function eventHandler(event) {
|
|
2032
2336
|
let target = getEventTarget(event);
|
|
2033
2337
|
const userTriggered = event.isTrusted;
|
|
2034
|
-
|
|
2338
|
+
const tagName = target && target.tagName;
|
|
2339
|
+
if (target && tagName === 'OPTION') {
|
|
2035
2340
|
target = target.parentElement;
|
|
2341
|
+
}
|
|
2036
2342
|
if (!target ||
|
|
2037
|
-
!
|
|
2038
|
-
INPUT_TAGS.indexOf(
|
|
2343
|
+
!tagName ||
|
|
2344
|
+
INPUT_TAGS.indexOf(tagName) < 0 ||
|
|
2039
2345
|
isBlocked(target, blockClass, blockSelector, true)) {
|
|
2040
2346
|
return;
|
|
2041
2347
|
}
|
|
2042
|
-
|
|
2043
|
-
|
|
2348
|
+
if (target.classList.contains(ignoreClass) ||
|
|
2349
|
+
(ignoreSelector && target.matches(ignoreSelector))) {
|
|
2044
2350
|
return;
|
|
2045
2351
|
}
|
|
2046
2352
|
let text = target.value;
|
|
2047
2353
|
let isChecked = false;
|
|
2354
|
+
const type = getInputType(target) || '';
|
|
2048
2355
|
if (type === 'radio' || type === 'checkbox') {
|
|
2049
2356
|
isChecked = target.checked;
|
|
2050
2357
|
}
|
|
2051
|
-
else if (maskInputOptions[
|
|
2358
|
+
else if (maskInputOptions[tagName.toLowerCase()] ||
|
|
2052
2359
|
maskInputOptions[type]) {
|
|
2053
2360
|
text = maskInputValue({
|
|
2361
|
+
element: target,
|
|
2054
2362
|
maskInputOptions,
|
|
2055
|
-
tagName
|
|
2363
|
+
tagName,
|
|
2056
2364
|
type,
|
|
2057
2365
|
value: text,
|
|
2058
2366
|
maskInputFn,
|
|
2059
2367
|
});
|
|
2060
2368
|
}
|
|
2061
|
-
cbWithDedup(target,
|
|
2369
|
+
cbWithDedup(target, userTriggeredOnInput
|
|
2370
|
+
? { text, isChecked, userTriggered }
|
|
2371
|
+
: { text, isChecked });
|
|
2062
2372
|
const name = target.name;
|
|
2063
2373
|
if (type === 'radio' && name && isChecked) {
|
|
2064
2374
|
doc
|
|
2065
2375
|
.querySelectorAll(`input[type="radio"][name="${name}"]`)
|
|
2066
2376
|
.forEach((el) => {
|
|
2067
2377
|
if (el !== target) {
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
isChecked: !isChecked,
|
|
2071
|
-
|
|
2072
|
-
}, userTriggeredOnInput));
|
|
2378
|
+
const text = el.value;
|
|
2379
|
+
cbWithDedup(el, userTriggeredOnInput
|
|
2380
|
+
? { text, isChecked: !isChecked, userTriggered: false }
|
|
2381
|
+
: { text, isChecked: !isChecked });
|
|
2073
2382
|
}
|
|
2074
2383
|
});
|
|
2075
2384
|
}
|
|
@@ -2081,11 +2390,11 @@
|
|
|
2081
2390
|
lastInputValue.isChecked !== v.isChecked) {
|
|
2082
2391
|
lastInputValueMap.set(target, v);
|
|
2083
2392
|
const id = mirror.getId(target);
|
|
2084
|
-
inputCb(Object.assign(Object.assign({}, v), { id }));
|
|
2393
|
+
callbackWrapper(inputCb)(Object.assign(Object.assign({}, v), { id }));
|
|
2085
2394
|
}
|
|
2086
2395
|
}
|
|
2087
2396
|
const events = sampling.input === 'last' ? ['change'] : ['input', 'change'];
|
|
2088
|
-
const handlers = events.map((eventName) => on(eventName, eventHandler, doc));
|
|
2397
|
+
const handlers = events.map((eventName) => on(eventName, callbackWrapper(eventHandler), doc));
|
|
2089
2398
|
const currentWindow = doc.defaultView;
|
|
2090
2399
|
if (!currentWindow) {
|
|
2091
2400
|
return () => {
|
|
@@ -2104,24 +2413,27 @@
|
|
|
2104
2413
|
if (propertyDescriptor && propertyDescriptor.set) {
|
|
2105
2414
|
handlers.push(...hookProperties.map((p) => hookSetter(p[0], p[1], {
|
|
2106
2415
|
set() {
|
|
2107
|
-
eventHandler({
|
|
2416
|
+
callbackWrapper(eventHandler)({
|
|
2417
|
+
target: this,
|
|
2418
|
+
isTrusted: false,
|
|
2419
|
+
});
|
|
2108
2420
|
},
|
|
2109
2421
|
}, false, currentWindow)));
|
|
2110
2422
|
}
|
|
2111
|
-
return () => {
|
|
2423
|
+
return callbackWrapper(() => {
|
|
2112
2424
|
handlers.forEach((h) => h());
|
|
2113
|
-
};
|
|
2425
|
+
});
|
|
2114
2426
|
}
|
|
2115
2427
|
function getNestedCSSRulePositions(rule) {
|
|
2116
2428
|
const positions = [];
|
|
2117
2429
|
function recurse(childRule, pos) {
|
|
2118
|
-
if ((
|
|
2430
|
+
if ((hasNestedCSSRule('CSSGroupingRule') &&
|
|
2119
2431
|
childRule.parentRule instanceof CSSGroupingRule) ||
|
|
2120
|
-
(
|
|
2432
|
+
(hasNestedCSSRule('CSSMediaRule') &&
|
|
2121
2433
|
childRule.parentRule instanceof CSSMediaRule) ||
|
|
2122
|
-
(
|
|
2434
|
+
(hasNestedCSSRule('CSSSupportsRule') &&
|
|
2123
2435
|
childRule.parentRule instanceof CSSSupportsRule) ||
|
|
2124
|
-
(
|
|
2436
|
+
(hasNestedCSSRule('CSSConditionRule') &&
|
|
2125
2437
|
childRule.parentRule instanceof CSSConditionRule)) {
|
|
2126
2438
|
const rules = Array.from(childRule.parentRule.cssRules);
|
|
2127
2439
|
const index = rules.indexOf(childRule);
|
|
@@ -2150,72 +2462,88 @@
|
|
|
2150
2462
|
};
|
|
2151
2463
|
}
|
|
2152
2464
|
function initStyleSheetObserver({ styleSheetRuleCb, mirror, stylesheetManager }, { win }) {
|
|
2465
|
+
if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {
|
|
2466
|
+
return () => {
|
|
2467
|
+
};
|
|
2468
|
+
}
|
|
2153
2469
|
const insertRule = win.CSSStyleSheet.prototype.insertRule;
|
|
2154
|
-
win.CSSStyleSheet.prototype.insertRule =
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
id,
|
|
2159
|
-
styleId,
|
|
2160
|
-
adds: [{ rule, index }],
|
|
2161
|
-
});
|
|
2162
|
-
}
|
|
2163
|
-
return insertRule.apply(this, [rule, index]);
|
|
2164
|
-
};
|
|
2165
|
-
const deleteRule = win.CSSStyleSheet.prototype.deleteRule;
|
|
2166
|
-
win.CSSStyleSheet.prototype.deleteRule = function (index) {
|
|
2167
|
-
const { id, styleId } = getIdAndStyleId(this, mirror, stylesheetManager.styleMirror);
|
|
2168
|
-
if ((id && id !== -1) || (styleId && styleId !== -1)) {
|
|
2169
|
-
styleSheetRuleCb({
|
|
2170
|
-
id,
|
|
2171
|
-
styleId,
|
|
2172
|
-
removes: [{ index }],
|
|
2173
|
-
});
|
|
2174
|
-
}
|
|
2175
|
-
return deleteRule.apply(this, [index]);
|
|
2176
|
-
};
|
|
2177
|
-
let replace;
|
|
2178
|
-
if (win.CSSStyleSheet.prototype.replace) {
|
|
2179
|
-
replace = win.CSSStyleSheet.prototype.replace;
|
|
2180
|
-
win.CSSStyleSheet.prototype.replace = function (text) {
|
|
2181
|
-
const { id, styleId } = getIdAndStyleId(this, mirror, stylesheetManager.styleMirror);
|
|
2470
|
+
win.CSSStyleSheet.prototype.insertRule = new Proxy(insertRule, {
|
|
2471
|
+
apply: callbackWrapper((target, thisArg, argumentsList) => {
|
|
2472
|
+
const [rule, index] = argumentsList;
|
|
2473
|
+
const { id, styleId } = getIdAndStyleId(thisArg, mirror, stylesheetManager.styleMirror);
|
|
2182
2474
|
if ((id && id !== -1) || (styleId && styleId !== -1)) {
|
|
2183
2475
|
styleSheetRuleCb({
|
|
2184
2476
|
id,
|
|
2185
2477
|
styleId,
|
|
2186
|
-
|
|
2478
|
+
adds: [{ rule, index }],
|
|
2187
2479
|
});
|
|
2188
2480
|
}
|
|
2189
|
-
return
|
|
2190
|
-
}
|
|
2191
|
-
}
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
const { id, styleId } = getIdAndStyleId(
|
|
2481
|
+
return target.apply(thisArg, argumentsList);
|
|
2482
|
+
}),
|
|
2483
|
+
});
|
|
2484
|
+
const deleteRule = win.CSSStyleSheet.prototype.deleteRule;
|
|
2485
|
+
win.CSSStyleSheet.prototype.deleteRule = new Proxy(deleteRule, {
|
|
2486
|
+
apply: callbackWrapper((target, thisArg, argumentsList) => {
|
|
2487
|
+
const [index] = argumentsList;
|
|
2488
|
+
const { id, styleId } = getIdAndStyleId(thisArg, mirror, stylesheetManager.styleMirror);
|
|
2197
2489
|
if ((id && id !== -1) || (styleId && styleId !== -1)) {
|
|
2198
2490
|
styleSheetRuleCb({
|
|
2199
2491
|
id,
|
|
2200
2492
|
styleId,
|
|
2201
|
-
|
|
2493
|
+
removes: [{ index }],
|
|
2202
2494
|
});
|
|
2203
2495
|
}
|
|
2204
|
-
return
|
|
2205
|
-
}
|
|
2496
|
+
return target.apply(thisArg, argumentsList);
|
|
2497
|
+
}),
|
|
2498
|
+
});
|
|
2499
|
+
let replace;
|
|
2500
|
+
if (win.CSSStyleSheet.prototype.replace) {
|
|
2501
|
+
replace = win.CSSStyleSheet.prototype.replace;
|
|
2502
|
+
win.CSSStyleSheet.prototype.replace = new Proxy(replace, {
|
|
2503
|
+
apply: callbackWrapper((target, thisArg, argumentsList) => {
|
|
2504
|
+
const [text] = argumentsList;
|
|
2505
|
+
const { id, styleId } = getIdAndStyleId(thisArg, mirror, stylesheetManager.styleMirror);
|
|
2506
|
+
if ((id && id !== -1) || (styleId && styleId !== -1)) {
|
|
2507
|
+
styleSheetRuleCb({
|
|
2508
|
+
id,
|
|
2509
|
+
styleId,
|
|
2510
|
+
replace: text,
|
|
2511
|
+
});
|
|
2512
|
+
}
|
|
2513
|
+
return target.apply(thisArg, argumentsList);
|
|
2514
|
+
}),
|
|
2515
|
+
});
|
|
2516
|
+
}
|
|
2517
|
+
let replaceSync;
|
|
2518
|
+
if (win.CSSStyleSheet.prototype.replaceSync) {
|
|
2519
|
+
replaceSync = win.CSSStyleSheet.prototype.replaceSync;
|
|
2520
|
+
win.CSSStyleSheet.prototype.replaceSync = new Proxy(replaceSync, {
|
|
2521
|
+
apply: callbackWrapper((target, thisArg, argumentsList) => {
|
|
2522
|
+
const [text] = argumentsList;
|
|
2523
|
+
const { id, styleId } = getIdAndStyleId(thisArg, mirror, stylesheetManager.styleMirror);
|
|
2524
|
+
if ((id && id !== -1) || (styleId && styleId !== -1)) {
|
|
2525
|
+
styleSheetRuleCb({
|
|
2526
|
+
id,
|
|
2527
|
+
styleId,
|
|
2528
|
+
replaceSync: text,
|
|
2529
|
+
});
|
|
2530
|
+
}
|
|
2531
|
+
return target.apply(thisArg, argumentsList);
|
|
2532
|
+
}),
|
|
2533
|
+
});
|
|
2206
2534
|
}
|
|
2207
2535
|
const supportedNestedCSSRuleTypes = {};
|
|
2208
|
-
if (
|
|
2536
|
+
if (canMonkeyPatchNestedCSSRule('CSSGroupingRule')) {
|
|
2209
2537
|
supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;
|
|
2210
2538
|
}
|
|
2211
2539
|
else {
|
|
2212
|
-
if (
|
|
2540
|
+
if (canMonkeyPatchNestedCSSRule('CSSMediaRule')) {
|
|
2213
2541
|
supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;
|
|
2214
2542
|
}
|
|
2215
|
-
if (
|
|
2543
|
+
if (canMonkeyPatchNestedCSSRule('CSSConditionRule')) {
|
|
2216
2544
|
supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;
|
|
2217
2545
|
}
|
|
2218
|
-
if (
|
|
2546
|
+
if (canMonkeyPatchNestedCSSRule('CSSSupportsRule')) {
|
|
2219
2547
|
supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;
|
|
2220
2548
|
}
|
|
2221
2549
|
}
|
|
@@ -2225,40 +2553,46 @@
|
|
|
2225
2553
|
insertRule: type.prototype.insertRule,
|
|
2226
2554
|
deleteRule: type.prototype.deleteRule,
|
|
2227
2555
|
};
|
|
2228
|
-
type.prototype.insertRule =
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
index
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2556
|
+
type.prototype.insertRule = new Proxy(unmodifiedFunctions[typeKey].insertRule, {
|
|
2557
|
+
apply: callbackWrapper((target, thisArg, argumentsList) => {
|
|
2558
|
+
const [rule, index] = argumentsList;
|
|
2559
|
+
const { id, styleId } = getIdAndStyleId(thisArg.parentStyleSheet, mirror, stylesheetManager.styleMirror);
|
|
2560
|
+
if ((id && id !== -1) || (styleId && styleId !== -1)) {
|
|
2561
|
+
styleSheetRuleCb({
|
|
2562
|
+
id,
|
|
2563
|
+
styleId,
|
|
2564
|
+
adds: [
|
|
2565
|
+
{
|
|
2566
|
+
rule,
|
|
2567
|
+
index: [
|
|
2568
|
+
...getNestedCSSRulePositions(thisArg),
|
|
2569
|
+
index || 0,
|
|
2570
|
+
],
|
|
2571
|
+
},
|
|
2572
|
+
],
|
|
2573
|
+
});
|
|
2574
|
+
}
|
|
2575
|
+
return target.apply(thisArg, argumentsList);
|
|
2576
|
+
}),
|
|
2577
|
+
});
|
|
2578
|
+
type.prototype.deleteRule = new Proxy(unmodifiedFunctions[typeKey].deleteRule, {
|
|
2579
|
+
apply: callbackWrapper((target, thisArg, argumentsList) => {
|
|
2580
|
+
const [index] = argumentsList;
|
|
2581
|
+
const { id, styleId } = getIdAndStyleId(thisArg.parentStyleSheet, mirror, stylesheetManager.styleMirror);
|
|
2582
|
+
if ((id && id !== -1) || (styleId && styleId !== -1)) {
|
|
2583
|
+
styleSheetRuleCb({
|
|
2584
|
+
id,
|
|
2585
|
+
styleId,
|
|
2586
|
+
removes: [
|
|
2587
|
+
{ index: [...getNestedCSSRulePositions(thisArg), index] },
|
|
2588
|
+
],
|
|
2589
|
+
});
|
|
2590
|
+
}
|
|
2591
|
+
return target.apply(thisArg, argumentsList);
|
|
2592
|
+
}),
|
|
2593
|
+
});
|
|
2260
2594
|
});
|
|
2261
|
-
return () => {
|
|
2595
|
+
return callbackWrapper(() => {
|
|
2262
2596
|
win.CSSStyleSheet.prototype.insertRule = insertRule;
|
|
2263
2597
|
win.CSSStyleSheet.prototype.deleteRule = deleteRule;
|
|
2264
2598
|
replace && (win.CSSStyleSheet.prototype.replace = replace);
|
|
@@ -2267,7 +2601,7 @@
|
|
|
2267
2601
|
type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;
|
|
2268
2602
|
type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;
|
|
2269
2603
|
});
|
|
2270
|
-
};
|
|
2604
|
+
});
|
|
2271
2605
|
}
|
|
2272
2606
|
function initAdoptedStyleSheetObserver({ mirror, stylesheetManager, }, host) {
|
|
2273
2607
|
var _a, _b, _c;
|
|
@@ -2279,7 +2613,9 @@
|
|
|
2279
2613
|
const patchTarget = host.nodeName === '#document'
|
|
2280
2614
|
? (_a = host.defaultView) === null || _a === void 0 ? void 0 : _a.Document
|
|
2281
2615
|
: (_c = (_b = host.ownerDocument) === null || _b === void 0 ? void 0 : _b.defaultView) === null || _c === void 0 ? void 0 : _c.ShadowRoot;
|
|
2282
|
-
const originalPropertyDescriptor =
|
|
2616
|
+
const originalPropertyDescriptor = (patchTarget === null || patchTarget === void 0 ? void 0 : patchTarget.prototype)
|
|
2617
|
+
? Object.getOwnPropertyDescriptor(patchTarget === null || patchTarget === void 0 ? void 0 : patchTarget.prototype, 'adoptedStyleSheets')
|
|
2618
|
+
: undefined;
|
|
2283
2619
|
if (hostId === null ||
|
|
2284
2620
|
hostId === -1 ||
|
|
2285
2621
|
!patchTarget ||
|
|
@@ -2306,69 +2642,75 @@
|
|
|
2306
2642
|
return result;
|
|
2307
2643
|
},
|
|
2308
2644
|
});
|
|
2309
|
-
return () => {
|
|
2645
|
+
return callbackWrapper(() => {
|
|
2310
2646
|
Object.defineProperty(host, 'adoptedStyleSheets', {
|
|
2311
2647
|
configurable: originalPropertyDescriptor.configurable,
|
|
2312
2648
|
enumerable: originalPropertyDescriptor.enumerable,
|
|
2313
2649
|
get: originalPropertyDescriptor.get,
|
|
2314
2650
|
set: originalPropertyDescriptor.set,
|
|
2315
2651
|
});
|
|
2316
|
-
};
|
|
2652
|
+
});
|
|
2317
2653
|
}
|
|
2318
2654
|
function initStyleDeclarationObserver({ styleDeclarationCb, mirror, ignoreCSSAttributes, stylesheetManager, }, { win }) {
|
|
2319
2655
|
const setProperty = win.CSSStyleDeclaration.prototype.setProperty;
|
|
2320
|
-
win.CSSStyleDeclaration.prototype.setProperty =
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2656
|
+
win.CSSStyleDeclaration.prototype.setProperty = new Proxy(setProperty, {
|
|
2657
|
+
apply: callbackWrapper((target, thisArg, argumentsList) => {
|
|
2658
|
+
var _a;
|
|
2659
|
+
const [property, value, priority] = argumentsList;
|
|
2660
|
+
if (ignoreCSSAttributes.has(property)) {
|
|
2661
|
+
return setProperty.apply(thisArg, [property, value, priority]);
|
|
2662
|
+
}
|
|
2663
|
+
const { id, styleId } = getIdAndStyleId((_a = thisArg.parentRule) === null || _a === void 0 ? void 0 : _a.parentStyleSheet, mirror, stylesheetManager.styleMirror);
|
|
2664
|
+
if ((id && id !== -1) || (styleId && styleId !== -1)) {
|
|
2665
|
+
styleDeclarationCb({
|
|
2666
|
+
id,
|
|
2667
|
+
styleId,
|
|
2668
|
+
set: {
|
|
2669
|
+
property,
|
|
2670
|
+
value,
|
|
2671
|
+
priority,
|
|
2672
|
+
},
|
|
2673
|
+
index: getNestedCSSRulePositions(thisArg.parentRule),
|
|
2674
|
+
});
|
|
2675
|
+
}
|
|
2676
|
+
return target.apply(thisArg, argumentsList);
|
|
2677
|
+
}),
|
|
2678
|
+
});
|
|
2340
2679
|
const removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;
|
|
2341
|
-
win.CSSStyleDeclaration.prototype.removeProperty =
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2680
|
+
win.CSSStyleDeclaration.prototype.removeProperty = new Proxy(removeProperty, {
|
|
2681
|
+
apply: callbackWrapper((target, thisArg, argumentsList) => {
|
|
2682
|
+
var _a;
|
|
2683
|
+
const [property] = argumentsList;
|
|
2684
|
+
if (ignoreCSSAttributes.has(property)) {
|
|
2685
|
+
return removeProperty.apply(thisArg, [property]);
|
|
2686
|
+
}
|
|
2687
|
+
const { id, styleId } = getIdAndStyleId((_a = thisArg.parentRule) === null || _a === void 0 ? void 0 : _a.parentStyleSheet, mirror, stylesheetManager.styleMirror);
|
|
2688
|
+
if ((id && id !== -1) || (styleId && styleId !== -1)) {
|
|
2689
|
+
styleDeclarationCb({
|
|
2690
|
+
id,
|
|
2691
|
+
styleId,
|
|
2692
|
+
remove: {
|
|
2693
|
+
property,
|
|
2694
|
+
},
|
|
2695
|
+
index: getNestedCSSRulePositions(thisArg.parentRule),
|
|
2696
|
+
});
|
|
2697
|
+
}
|
|
2698
|
+
return target.apply(thisArg, argumentsList);
|
|
2699
|
+
}),
|
|
2700
|
+
});
|
|
2701
|
+
return callbackWrapper(() => {
|
|
2360
2702
|
win.CSSStyleDeclaration.prototype.setProperty = setProperty;
|
|
2361
2703
|
win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;
|
|
2362
|
-
};
|
|
2704
|
+
});
|
|
2363
2705
|
}
|
|
2364
|
-
function initMediaInteractionObserver({ mediaInteractionCb, blockClass, blockSelector, mirror, sampling, }) {
|
|
2365
|
-
const handler = (type) => throttle((event) => {
|
|
2706
|
+
function initMediaInteractionObserver({ mediaInteractionCb, blockClass, blockSelector, mirror, sampling, doc, }) {
|
|
2707
|
+
const handler = callbackWrapper((type) => throttle(callbackWrapper((event) => {
|
|
2366
2708
|
const target = getEventTarget(event);
|
|
2367
2709
|
if (!target ||
|
|
2368
2710
|
isBlocked(target, blockClass, blockSelector, true)) {
|
|
2369
2711
|
return;
|
|
2370
2712
|
}
|
|
2371
|
-
const { currentTime, volume, muted, playbackRate, } = target;
|
|
2713
|
+
const { currentTime, volume, muted, playbackRate, loop } = target;
|
|
2372
2714
|
mediaInteractionCb({
|
|
2373
2715
|
type,
|
|
2374
2716
|
id: mirror.getId(target),
|
|
@@ -2376,18 +2718,19 @@
|
|
|
2376
2718
|
volume,
|
|
2377
2719
|
muted,
|
|
2378
2720
|
playbackRate,
|
|
2721
|
+
loop,
|
|
2379
2722
|
});
|
|
2380
|
-
}, sampling.media || 500);
|
|
2723
|
+
}), sampling.media || 500));
|
|
2381
2724
|
const handlers = [
|
|
2382
|
-
on('play', handler(0)),
|
|
2383
|
-
on('pause', handler(1)),
|
|
2384
|
-
on('seeked', handler(2)),
|
|
2385
|
-
on('volumechange', handler(3)),
|
|
2386
|
-
on('ratechange', handler(4)),
|
|
2725
|
+
on('play', handler(0), doc),
|
|
2726
|
+
on('pause', handler(1), doc),
|
|
2727
|
+
on('seeked', handler(2), doc),
|
|
2728
|
+
on('volumechange', handler(3), doc),
|
|
2729
|
+
on('ratechange', handler(4), doc),
|
|
2387
2730
|
];
|
|
2388
|
-
return () => {
|
|
2731
|
+
return callbackWrapper(() => {
|
|
2389
2732
|
handlers.forEach((h) => h());
|
|
2390
|
-
};
|
|
2733
|
+
});
|
|
2391
2734
|
}
|
|
2392
2735
|
function initFontObserver({ fontCb, doc }) {
|
|
2393
2736
|
const win = doc.defaultView;
|
|
@@ -2412,13 +2755,13 @@
|
|
|
2412
2755
|
};
|
|
2413
2756
|
const restoreHandler = patch(doc.fonts, 'add', function (original) {
|
|
2414
2757
|
return function (fontFace) {
|
|
2415
|
-
setTimeout(() => {
|
|
2758
|
+
setTimeout(callbackWrapper(() => {
|
|
2416
2759
|
const p = fontMap.get(fontFace);
|
|
2417
2760
|
if (p) {
|
|
2418
2761
|
fontCb(p);
|
|
2419
2762
|
fontMap.delete(fontFace);
|
|
2420
2763
|
}
|
|
2421
|
-
}, 0);
|
|
2764
|
+
}), 0);
|
|
2422
2765
|
return original.apply(this, [fontFace]);
|
|
2423
2766
|
};
|
|
2424
2767
|
});
|
|
@@ -2426,14 +2769,14 @@
|
|
|
2426
2769
|
win.FontFace = originalFontFace;
|
|
2427
2770
|
});
|
|
2428
2771
|
handlers.push(restoreHandler);
|
|
2429
|
-
return () => {
|
|
2772
|
+
return callbackWrapper(() => {
|
|
2430
2773
|
handlers.forEach((h) => h());
|
|
2431
|
-
};
|
|
2774
|
+
});
|
|
2432
2775
|
}
|
|
2433
2776
|
function initSelectionObserver(param) {
|
|
2434
2777
|
const { doc, mirror, blockClass, blockSelector, selectionCb } = param;
|
|
2435
2778
|
let collapsed = true;
|
|
2436
|
-
const updateSelection = () => {
|
|
2779
|
+
const updateSelection = callbackWrapper(() => {
|
|
2437
2780
|
const selection = doc.getSelection();
|
|
2438
2781
|
if (!selection || (collapsed && (selection === null || selection === void 0 ? void 0 : selection.isCollapsed)))
|
|
2439
2782
|
return;
|
|
@@ -2455,12 +2798,33 @@
|
|
|
2455
2798
|
});
|
|
2456
2799
|
}
|
|
2457
2800
|
selectionCb({ ranges });
|
|
2458
|
-
};
|
|
2801
|
+
});
|
|
2459
2802
|
updateSelection();
|
|
2460
2803
|
return on('selectionchange', updateSelection);
|
|
2461
2804
|
}
|
|
2805
|
+
function initCustomElementObserver({ doc, customElementCb, }) {
|
|
2806
|
+
const win = doc.defaultView;
|
|
2807
|
+
if (!win || !win.customElements)
|
|
2808
|
+
return () => { };
|
|
2809
|
+
const restoreHandler = patch(win.customElements, 'define', function (original) {
|
|
2810
|
+
return function (name, constructor, options) {
|
|
2811
|
+
try {
|
|
2812
|
+
customElementCb({
|
|
2813
|
+
define: {
|
|
2814
|
+
name,
|
|
2815
|
+
},
|
|
2816
|
+
});
|
|
2817
|
+
}
|
|
2818
|
+
catch (e) {
|
|
2819
|
+
console.warn(`Custom element callback failed for ${name}`);
|
|
2820
|
+
}
|
|
2821
|
+
return original.apply(this, [name, constructor, options]);
|
|
2822
|
+
};
|
|
2823
|
+
});
|
|
2824
|
+
return restoreHandler;
|
|
2825
|
+
}
|
|
2462
2826
|
function mergeHooks(o, hooks) {
|
|
2463
|
-
const { mutationCb, mousemoveCb, mouseInteractionCb, scrollCb, viewportResizeCb, inputCb, mediaInteractionCb, styleSheetRuleCb, styleDeclarationCb, canvasMutationCb, fontCb, selectionCb, } = o;
|
|
2827
|
+
const { mutationCb, mousemoveCb, mouseInteractionCb, scrollCb, viewportResizeCb, inputCb, mediaInteractionCb, styleSheetRuleCb, styleDeclarationCb, canvasMutationCb, fontCb, selectionCb, customElementCb, } = o;
|
|
2464
2828
|
o.mutationCb = (...p) => {
|
|
2465
2829
|
if (hooks.mutation) {
|
|
2466
2830
|
hooks.mutation(...p);
|
|
@@ -2533,6 +2897,12 @@
|
|
|
2533
2897
|
}
|
|
2534
2898
|
selectionCb(...p);
|
|
2535
2899
|
};
|
|
2900
|
+
o.customElementCb = (...c) => {
|
|
2901
|
+
if (hooks.customElement) {
|
|
2902
|
+
hooks.customElement(...c);
|
|
2903
|
+
}
|
|
2904
|
+
customElementCb(...c);
|
|
2905
|
+
};
|
|
2536
2906
|
}
|
|
2537
2907
|
function initObservers(o, hooks = {}) {
|
|
2538
2908
|
const currentWindow = o.doc.defaultView;
|
|
@@ -2541,30 +2911,41 @@
|
|
|
2541
2911
|
};
|
|
2542
2912
|
}
|
|
2543
2913
|
mergeHooks(o, hooks);
|
|
2544
|
-
|
|
2914
|
+
let mutationObserver;
|
|
2915
|
+
if (o.recordDOM) {
|
|
2916
|
+
mutationObserver = initMutationObserver(o, o.doc);
|
|
2917
|
+
}
|
|
2545
2918
|
const mousemoveHandler = initMoveObserver(o);
|
|
2546
2919
|
const mouseInteractionHandler = initMouseInteractionObserver(o);
|
|
2547
2920
|
const scrollHandler = initScrollObserver(o);
|
|
2548
|
-
const viewportResizeHandler = initViewportResizeObserver(o
|
|
2549
|
-
const inputHandler = initInputObserver(o);
|
|
2550
|
-
const mediaInteractionHandler = initMediaInteractionObserver(o);
|
|
2551
|
-
const styleSheetObserver = initStyleSheetObserver(o, { win: currentWindow });
|
|
2552
|
-
const adoptedStyleSheetObserver = initAdoptedStyleSheetObserver(o, o.doc);
|
|
2553
|
-
const styleDeclarationObserver = initStyleDeclarationObserver(o, {
|
|
2921
|
+
const viewportResizeHandler = initViewportResizeObserver(o, {
|
|
2554
2922
|
win: currentWindow,
|
|
2555
2923
|
});
|
|
2556
|
-
const
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2924
|
+
const inputHandler = initInputObserver(o);
|
|
2925
|
+
const mediaInteractionHandler = initMediaInteractionObserver(o);
|
|
2926
|
+
let styleSheetObserver = () => { };
|
|
2927
|
+
let adoptedStyleSheetObserver = () => { };
|
|
2928
|
+
let styleDeclarationObserver = () => { };
|
|
2929
|
+
let fontObserver = () => { };
|
|
2930
|
+
if (o.recordDOM) {
|
|
2931
|
+
styleSheetObserver = initStyleSheetObserver(o, { win: currentWindow });
|
|
2932
|
+
adoptedStyleSheetObserver = initAdoptedStyleSheetObserver(o, o.doc);
|
|
2933
|
+
styleDeclarationObserver = initStyleDeclarationObserver(o, {
|
|
2934
|
+
win: currentWindow,
|
|
2935
|
+
});
|
|
2936
|
+
if (o.collectFonts) {
|
|
2937
|
+
fontObserver = initFontObserver(o);
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2560
2940
|
const selectionObserver = initSelectionObserver(o);
|
|
2941
|
+
const customElementObserver = initCustomElementObserver(o);
|
|
2561
2942
|
const pluginHandlers = [];
|
|
2562
2943
|
for (const plugin of o.plugins) {
|
|
2563
2944
|
pluginHandlers.push(plugin.observer(plugin.callback, currentWindow, plugin.options));
|
|
2564
2945
|
}
|
|
2565
|
-
return () => {
|
|
2946
|
+
return callbackWrapper(() => {
|
|
2566
2947
|
mutationBuffers.forEach((b) => b.reset());
|
|
2567
|
-
mutationObserver.disconnect();
|
|
2948
|
+
mutationObserver === null || mutationObserver === void 0 ? void 0 : mutationObserver.disconnect();
|
|
2568
2949
|
mousemoveHandler();
|
|
2569
2950
|
mouseInteractionHandler();
|
|
2570
2951
|
scrollHandler();
|
|
@@ -2576,8 +2957,18 @@
|
|
|
2576
2957
|
styleDeclarationObserver();
|
|
2577
2958
|
fontObserver();
|
|
2578
2959
|
selectionObserver();
|
|
2960
|
+
customElementObserver();
|
|
2579
2961
|
pluginHandlers.forEach((h) => h());
|
|
2580
|
-
};
|
|
2962
|
+
});
|
|
2963
|
+
}
|
|
2964
|
+
function hasNestedCSSRule(prop) {
|
|
2965
|
+
return typeof window[prop] !== 'undefined';
|
|
2966
|
+
}
|
|
2967
|
+
function canMonkeyPatchNestedCSSRule(prop) {
|
|
2968
|
+
return Boolean(typeof window[prop] !== 'undefined' &&
|
|
2969
|
+
window[prop].prototype &&
|
|
2970
|
+
'insertRule' in window[prop].prototype &&
|
|
2971
|
+
'deleteRule' in window[prop].prototype);
|
|
2581
2972
|
}
|
|
2582
2973
|
|
|
2583
2974
|
class CrossOriginIframeMirror {
|
|
@@ -2647,6 +3038,7 @@
|
|
|
2647
3038
|
this.iframes = new WeakMap();
|
|
2648
3039
|
this.crossOriginIframeMap = new WeakMap();
|
|
2649
3040
|
this.crossOriginIframeMirror = new CrossOriginIframeMirror(genId);
|
|
3041
|
+
this.crossOriginIframeRootIdMap = new WeakMap();
|
|
2650
3042
|
this.mutationCb = options.mutationCb;
|
|
2651
3043
|
this.wrappedEmit = options.wrappedEmit;
|
|
2652
3044
|
this.stylesheetManager = options.stylesheetManager;
|
|
@@ -2687,17 +3079,19 @@
|
|
|
2687
3079
|
this.stylesheetManager.adoptStyleSheets(iframeEl.contentDocument.adoptedStyleSheets, this.mirror.getId(iframeEl.contentDocument));
|
|
2688
3080
|
}
|
|
2689
3081
|
handleMessage(message) {
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
3082
|
+
const crossOriginMessageEvent = message;
|
|
3083
|
+
if (crossOriginMessageEvent.data.type !== 'rrweb' ||
|
|
3084
|
+
crossOriginMessageEvent.origin !== crossOriginMessageEvent.data.origin)
|
|
3085
|
+
return;
|
|
3086
|
+
const iframeSourceWindow = message.source;
|
|
3087
|
+
if (!iframeSourceWindow)
|
|
3088
|
+
return;
|
|
3089
|
+
const iframeEl = this.crossOriginIframeMap.get(message.source);
|
|
3090
|
+
if (!iframeEl)
|
|
3091
|
+
return;
|
|
3092
|
+
const transformedEvent = this.transformCrossOriginEvent(iframeEl, crossOriginMessageEvent.data.event);
|
|
3093
|
+
if (transformedEvent)
|
|
3094
|
+
this.wrappedEmit(transformedEvent, crossOriginMessageEvent.data.isCheckout);
|
|
2701
3095
|
}
|
|
2702
3096
|
transformCrossOriginEvent(iframeEl, e) {
|
|
2703
3097
|
var _a;
|
|
@@ -2706,6 +3100,9 @@
|
|
|
2706
3100
|
this.crossOriginIframeMirror.reset(iframeEl);
|
|
2707
3101
|
this.crossOriginIframeStyleMirror.reset(iframeEl);
|
|
2708
3102
|
this.replaceIdOnNode(e.data.node, iframeEl);
|
|
3103
|
+
const rootId = e.data.node.id;
|
|
3104
|
+
this.crossOriginIframeRootIdMap.set(iframeEl, rootId);
|
|
3105
|
+
this.patchRootIdOnNode(e.data.node, rootId);
|
|
2709
3106
|
return {
|
|
2710
3107
|
timestamp: e.timestamp,
|
|
2711
3108
|
type: EventType.IncrementalSnapshot,
|
|
@@ -2747,6 +3144,8 @@
|
|
|
2747
3144
|
'previousId',
|
|
2748
3145
|
]);
|
|
2749
3146
|
this.replaceIdOnNode(n.node, iframeEl);
|
|
3147
|
+
const rootId = this.crossOriginIframeRootIdMap.get(iframeEl);
|
|
3148
|
+
rootId && this.patchRootIdOnNode(n.node, rootId);
|
|
2750
3149
|
});
|
|
2751
3150
|
e.data.removes.forEach((n) => {
|
|
2752
3151
|
this.replaceIds(n, iframeEl, ['parentId', 'id']);
|
|
@@ -2804,6 +3203,7 @@
|
|
|
2804
3203
|
}
|
|
2805
3204
|
}
|
|
2806
3205
|
}
|
|
3206
|
+
return false;
|
|
2807
3207
|
}
|
|
2808
3208
|
replace(iframeMirror, obj, iframeEl, keys) {
|
|
2809
3209
|
for (const key of keys) {
|
|
@@ -2825,32 +3225,37 @@
|
|
|
2825
3225
|
return this.replace(this.crossOriginIframeStyleMirror, obj, iframeEl, keys);
|
|
2826
3226
|
}
|
|
2827
3227
|
replaceIdOnNode(node, iframeEl) {
|
|
2828
|
-
this.replaceIds(node, iframeEl, ['id']);
|
|
3228
|
+
this.replaceIds(node, iframeEl, ['id', 'rootId']);
|
|
2829
3229
|
if ('childNodes' in node) {
|
|
2830
3230
|
node.childNodes.forEach((child) => {
|
|
2831
3231
|
this.replaceIdOnNode(child, iframeEl);
|
|
2832
3232
|
});
|
|
2833
3233
|
}
|
|
2834
3234
|
}
|
|
3235
|
+
patchRootIdOnNode(node, rootId) {
|
|
3236
|
+
if (node.type !== NodeType.Document && !node.rootId)
|
|
3237
|
+
node.rootId = rootId;
|
|
3238
|
+
if ('childNodes' in node) {
|
|
3239
|
+
node.childNodes.forEach((child) => {
|
|
3240
|
+
this.patchRootIdOnNode(child, rootId);
|
|
3241
|
+
});
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
2835
3244
|
}
|
|
2836
3245
|
|
|
2837
3246
|
class ShadowDomManager {
|
|
2838
3247
|
constructor(options) {
|
|
2839
3248
|
this.shadowDoms = new WeakSet();
|
|
2840
|
-
this.
|
|
3249
|
+
this.restoreHandlers = [];
|
|
2841
3250
|
this.mutationCb = options.mutationCb;
|
|
2842
3251
|
this.scrollCb = options.scrollCb;
|
|
2843
3252
|
this.bypassOptions = options.bypassOptions;
|
|
2844
3253
|
this.mirror = options.mirror;
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
manager.addShadowRoot(this.shadowRoot, this.ownerDocument);
|
|
2851
|
-
return shadowRoot;
|
|
2852
|
-
};
|
|
2853
|
-
}));
|
|
3254
|
+
this.init();
|
|
3255
|
+
}
|
|
3256
|
+
init() {
|
|
3257
|
+
this.reset();
|
|
3258
|
+
this.patchAttachShadow(Element, document);
|
|
2854
3259
|
}
|
|
2855
3260
|
addShadowRoot(shadowRoot, doc) {
|
|
2856
3261
|
if (!isNativeShadowDom(shadowRoot))
|
|
@@ -2858,33 +3263,44 @@
|
|
|
2858
3263
|
if (this.shadowDoms.has(shadowRoot))
|
|
2859
3264
|
return;
|
|
2860
3265
|
this.shadowDoms.add(shadowRoot);
|
|
2861
|
-
initMutationObserver(Object.assign(Object.assign({}, this.bypassOptions), { doc, mutationCb: this.mutationCb, mirror: this.mirror, shadowDomManager: this }), shadowRoot);
|
|
2862
|
-
|
|
3266
|
+
const observer = initMutationObserver(Object.assign(Object.assign({}, this.bypassOptions), { doc, mutationCb: this.mutationCb, mirror: this.mirror, shadowDomManager: this }), shadowRoot);
|
|
3267
|
+
this.restoreHandlers.push(() => observer.disconnect());
|
|
3268
|
+
this.restoreHandlers.push(initScrollObserver(Object.assign(Object.assign({}, this.bypassOptions), { scrollCb: this.scrollCb, doc: shadowRoot, mirror: this.mirror })));
|
|
2863
3269
|
setTimeout(() => {
|
|
2864
3270
|
if (shadowRoot.adoptedStyleSheets &&
|
|
2865
3271
|
shadowRoot.adoptedStyleSheets.length > 0)
|
|
2866
3272
|
this.bypassOptions.stylesheetManager.adoptStyleSheets(shadowRoot.adoptedStyleSheets, this.mirror.getId(shadowRoot.host));
|
|
2867
|
-
initAdoptedStyleSheetObserver({
|
|
3273
|
+
this.restoreHandlers.push(initAdoptedStyleSheetObserver({
|
|
2868
3274
|
mirror: this.mirror,
|
|
2869
3275
|
stylesheetManager: this.bypassOptions.stylesheetManager,
|
|
2870
|
-
}, shadowRoot);
|
|
3276
|
+
}, shadowRoot));
|
|
2871
3277
|
}, 0);
|
|
2872
3278
|
}
|
|
2873
3279
|
observeAttachShadow(iframeElement) {
|
|
2874
|
-
if (iframeElement.contentWindow)
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
3280
|
+
if (!iframeElement.contentWindow || !iframeElement.contentDocument)
|
|
3281
|
+
return;
|
|
3282
|
+
this.patchAttachShadow(iframeElement.contentWindow.Element, iframeElement.contentDocument);
|
|
3283
|
+
}
|
|
3284
|
+
patchAttachShadow(element, doc) {
|
|
3285
|
+
const manager = this;
|
|
3286
|
+
this.restoreHandlers.push(patch(element.prototype, 'attachShadow', function (original) {
|
|
3287
|
+
return function (option) {
|
|
3288
|
+
const shadowRoot = original.call(this, option);
|
|
3289
|
+
if (this.shadowRoot && inDom(this))
|
|
3290
|
+
manager.addShadowRoot(this.shadowRoot, doc);
|
|
3291
|
+
return shadowRoot;
|
|
3292
|
+
};
|
|
3293
|
+
}));
|
|
2885
3294
|
}
|
|
2886
3295
|
reset() {
|
|
2887
|
-
this.
|
|
3296
|
+
this.restoreHandlers.forEach((handler) => {
|
|
3297
|
+
try {
|
|
3298
|
+
handler();
|
|
3299
|
+
}
|
|
3300
|
+
catch (e) {
|
|
3301
|
+
}
|
|
3302
|
+
});
|
|
3303
|
+
this.restoreHandlers = [];
|
|
2888
3304
|
this.shadowDoms = new WeakSet();
|
|
2889
3305
|
}
|
|
2890
3306
|
}
|
|
@@ -3054,7 +3470,7 @@
|
|
|
3054
3470
|
return value;
|
|
3055
3471
|
}
|
|
3056
3472
|
const serializeArgs = (args, win, ctx) => {
|
|
3057
|
-
return
|
|
3473
|
+
return args.map((arg) => serializeArg(arg, win, ctx));
|
|
3058
3474
|
};
|
|
3059
3475
|
const isInstanceOfWebGLObject = (value, win) => {
|
|
3060
3476
|
const webGLConstructorNames = [
|
|
@@ -3086,7 +3502,7 @@
|
|
|
3086
3502
|
return function (...args) {
|
|
3087
3503
|
if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
|
|
3088
3504
|
setTimeout(() => {
|
|
3089
|
-
const recordArgs = serializeArgs(
|
|
3505
|
+
const recordArgs = serializeArgs(args, win, this);
|
|
3090
3506
|
cb(this.canvas, {
|
|
3091
3507
|
type: CanvasContext['2D'],
|
|
3092
3508
|
property: prop,
|
|
@@ -3118,14 +3534,32 @@
|
|
|
3118
3534
|
};
|
|
3119
3535
|
}
|
|
3120
3536
|
|
|
3121
|
-
function
|
|
3537
|
+
function getNormalizedContextName(contextType) {
|
|
3538
|
+
return contextType === 'experimental-webgl' ? 'webgl' : contextType;
|
|
3539
|
+
}
|
|
3540
|
+
function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDrawingBufferToTrue) {
|
|
3122
3541
|
const handlers = [];
|
|
3123
3542
|
try {
|
|
3124
3543
|
const restoreHandler = patch(win.HTMLCanvasElement.prototype, 'getContext', function (original) {
|
|
3125
3544
|
return function (contextType, ...args) {
|
|
3126
3545
|
if (!isBlocked(this, blockClass, blockSelector, true)) {
|
|
3546
|
+
const ctxName = getNormalizedContextName(contextType);
|
|
3127
3547
|
if (!('__context' in this))
|
|
3128
|
-
this.__context =
|
|
3548
|
+
this.__context = ctxName;
|
|
3549
|
+
if (setPreserveDrawingBufferToTrue &&
|
|
3550
|
+
['webgl', 'webgl2'].includes(ctxName)) {
|
|
3551
|
+
if (args[0] && typeof args[0] === 'object') {
|
|
3552
|
+
const contextAttributes = args[0];
|
|
3553
|
+
if (!contextAttributes.preserveDrawingBuffer) {
|
|
3554
|
+
contextAttributes.preserveDrawingBuffer = true;
|
|
3555
|
+
}
|
|
3556
|
+
}
|
|
3557
|
+
else {
|
|
3558
|
+
args.splice(0, 1, {
|
|
3559
|
+
preserveDrawingBuffer: true,
|
|
3560
|
+
});
|
|
3561
|
+
}
|
|
3562
|
+
}
|
|
3129
3563
|
}
|
|
3130
3564
|
return original.apply(this, [contextType, ...args]);
|
|
3131
3565
|
};
|
|
@@ -3160,8 +3594,9 @@
|
|
|
3160
3594
|
return function (...args) {
|
|
3161
3595
|
const result = original.apply(this, args);
|
|
3162
3596
|
saveWebGLVar(result, win, this);
|
|
3163
|
-
if (
|
|
3164
|
-
|
|
3597
|
+
if ('tagName' in this.canvas &&
|
|
3598
|
+
!isBlocked(this.canvas, blockClass, blockSelector, true)) {
|
|
3599
|
+
const recordArgs = serializeArgs(args, win, this);
|
|
3165
3600
|
const mutation = {
|
|
3166
3601
|
type,
|
|
3167
3602
|
property: prop,
|
|
@@ -3201,77 +3636,170 @@
|
|
|
3201
3636
|
};
|
|
3202
3637
|
}
|
|
3203
3638
|
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
try {
|
|
3207
|
-
var WorkerThreads =
|
|
3208
|
-
typeof module !== 'undefined' && typeof module.require === 'function' && module.require('worker_threads') ||
|
|
3209
|
-
typeof __non_webpack_require__ === 'function' && __non_webpack_require__('worker_threads') ||
|
|
3210
|
-
typeof require === 'function' && require('worker_threads');
|
|
3211
|
-
WorkerClass = WorkerThreads.Worker;
|
|
3212
|
-
} catch(e) {} // eslint-disable-line
|
|
3213
|
-
|
|
3214
|
-
function decodeBase64$1(base64, enableUnicode) {
|
|
3215
|
-
return Buffer.from(base64, 'base64').toString(enableUnicode ? 'utf16' : 'utf8');
|
|
3216
|
-
}
|
|
3217
|
-
|
|
3218
|
-
function createBase64WorkerFactory$2(base64, sourcemapArg, enableUnicodeArg) {
|
|
3639
|
+
function funcToSource(fn, sourcemapArg) {
|
|
3219
3640
|
var sourcemap = sourcemapArg === undefined ? null : sourcemapArg;
|
|
3220
|
-
var
|
|
3221
|
-
var
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
function decodeBase64(base64, enableUnicode) {
|
|
3230
|
-
var binaryString = atob(base64);
|
|
3231
|
-
if (enableUnicode) {
|
|
3232
|
-
var binaryView = new Uint8Array(binaryString.length);
|
|
3233
|
-
for (var i = 0, n = binaryString.length; i < n; ++i) {
|
|
3234
|
-
binaryView[i] = binaryString.charCodeAt(i);
|
|
3235
|
-
}
|
|
3236
|
-
return String.fromCharCode.apply(null, new Uint16Array(binaryView.buffer));
|
|
3641
|
+
var source = fn.toString();
|
|
3642
|
+
var lines = source.split('\n');
|
|
3643
|
+
lines.pop();
|
|
3644
|
+
lines.shift();
|
|
3645
|
+
var blankPrefixLength = lines[0].search(/\S/);
|
|
3646
|
+
var regex = /(['"])__worker_loader_strict__(['"])/g;
|
|
3647
|
+
for (var i = 0, n = lines.length; i < n; ++i) {
|
|
3648
|
+
lines[i] = lines[i].substring(blankPrefixLength).replace(regex, '$1use strict$2') + '\n';
|
|
3237
3649
|
}
|
|
3238
|
-
|
|
3650
|
+
if (sourcemap) {
|
|
3651
|
+
lines.push('\/\/# sourceMappingURL=' + sourcemap + '\n');
|
|
3652
|
+
}
|
|
3653
|
+
return lines;
|
|
3239
3654
|
}
|
|
3240
3655
|
|
|
3241
|
-
function createURL(
|
|
3242
|
-
var
|
|
3243
|
-
var
|
|
3244
|
-
var source = decodeBase64(base64, enableUnicode);
|
|
3245
|
-
var start = source.indexOf('\n', 10) + 1;
|
|
3246
|
-
var body = source.substring(start) + (sourcemap ? '\/\/# sourceMappingURL=' + sourcemap : '');
|
|
3247
|
-
var blob = new Blob([body], { type: 'application/javascript' });
|
|
3656
|
+
function createURL(fn, sourcemapArg) {
|
|
3657
|
+
var lines = funcToSource(fn, sourcemapArg);
|
|
3658
|
+
var blob = new Blob(lines, { type: 'application/javascript' });
|
|
3248
3659
|
return URL.createObjectURL(blob);
|
|
3249
3660
|
}
|
|
3250
3661
|
|
|
3251
|
-
function
|
|
3662
|
+
function createInlineWorkerFactory(fn, sourcemapArg) {
|
|
3252
3663
|
var url;
|
|
3253
3664
|
return function WorkerFactory(options) {
|
|
3254
|
-
url = url || createURL(
|
|
3665
|
+
url = url || createURL(fn, sourcemapArg);
|
|
3255
3666
|
return new Worker(url, options);
|
|
3256
3667
|
};
|
|
3257
3668
|
}
|
|
3258
3669
|
|
|
3259
|
-
var
|
|
3670
|
+
var WorkerFactory = createInlineWorkerFactory(/* rollup-plugin-web-worker-loader */function () {
|
|
3671
|
+
(function () {
|
|
3672
|
+
'__worker_loader_strict__';
|
|
3260
3673
|
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3674
|
+
/*! *****************************************************************************
|
|
3675
|
+
Copyright (c) Microsoft Corporation.
|
|
3676
|
+
|
|
3677
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
3678
|
+
purpose with or without fee is hereby granted.
|
|
3679
|
+
|
|
3680
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
3681
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
3682
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
3683
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
3684
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
3685
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
3686
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
3687
|
+
***************************************************************************** */
|
|
3688
|
+
|
|
3689
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
3690
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3691
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
3692
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
3693
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
3694
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
3695
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
3696
|
+
});
|
|
3697
|
+
}
|
|
3264
3698
|
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3699
|
+
/*
|
|
3700
|
+
* base64-arraybuffer 1.0.1 <https://github.com/niklasvh/base64-arraybuffer>
|
|
3701
|
+
* Copyright (c) 2021 Niklas von Hertzen <https://hertzen.com>
|
|
3702
|
+
* Released under MIT License
|
|
3703
|
+
*/
|
|
3704
|
+
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
3705
|
+
// Use a lookup table to find the index.
|
|
3706
|
+
var lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);
|
|
3707
|
+
for (var i = 0; i < chars.length; i++) {
|
|
3708
|
+
lookup[chars.charCodeAt(i)] = i;
|
|
3268
3709
|
}
|
|
3269
|
-
|
|
3270
|
-
|
|
3710
|
+
var encode = function (arraybuffer) {
|
|
3711
|
+
var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = '';
|
|
3712
|
+
for (i = 0; i < len; i += 3) {
|
|
3713
|
+
base64 += chars[bytes[i] >> 2];
|
|
3714
|
+
base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
|
|
3715
|
+
base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
|
|
3716
|
+
base64 += chars[bytes[i + 2] & 63];
|
|
3717
|
+
}
|
|
3718
|
+
if (len % 3 === 2) {
|
|
3719
|
+
base64 = base64.substring(0, base64.length - 1) + '=';
|
|
3720
|
+
}
|
|
3721
|
+
else if (len % 3 === 1) {
|
|
3722
|
+
base64 = base64.substring(0, base64.length - 2) + '==';
|
|
3723
|
+
}
|
|
3724
|
+
return base64;
|
|
3725
|
+
};
|
|
3271
3726
|
|
|
3272
|
-
|
|
3727
|
+
const lastBlobMap = new Map();
|
|
3728
|
+
const transparentBlobMap = new Map();
|
|
3729
|
+
function getTransparentBlobFor(width, height, dataURLOptions) {
|
|
3730
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3731
|
+
const id = `${width}-${height}`;
|
|
3732
|
+
if ('OffscreenCanvas' in globalThis) {
|
|
3733
|
+
if (transparentBlobMap.has(id))
|
|
3734
|
+
return transparentBlobMap.get(id);
|
|
3735
|
+
const offscreen = new OffscreenCanvas(width, height);
|
|
3736
|
+
offscreen.getContext('2d');
|
|
3737
|
+
const blob = yield offscreen.convertToBlob(dataURLOptions);
|
|
3738
|
+
const arrayBuffer = yield blob.arrayBuffer();
|
|
3739
|
+
const base64 = encode(arrayBuffer);
|
|
3740
|
+
transparentBlobMap.set(id, base64);
|
|
3741
|
+
return base64;
|
|
3742
|
+
}
|
|
3743
|
+
else {
|
|
3744
|
+
return '';
|
|
3745
|
+
}
|
|
3746
|
+
});
|
|
3747
|
+
}
|
|
3748
|
+
const worker = self;
|
|
3749
|
+
worker.onmessage = function (e) {
|
|
3750
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3751
|
+
if ('OffscreenCanvas' in globalThis) {
|
|
3752
|
+
const { id, bitmap, width, height, dataURLOptions } = e.data;
|
|
3753
|
+
const transparentBase64 = getTransparentBlobFor(width, height, dataURLOptions);
|
|
3754
|
+
const offscreen = new OffscreenCanvas(width, height);
|
|
3755
|
+
const ctx = offscreen.getContext('2d');
|
|
3756
|
+
ctx.drawImage(bitmap, 0, 0);
|
|
3757
|
+
bitmap.close();
|
|
3758
|
+
const blob = yield offscreen.convertToBlob(dataURLOptions);
|
|
3759
|
+
const type = blob.type;
|
|
3760
|
+
const arrayBuffer = yield blob.arrayBuffer();
|
|
3761
|
+
const base64 = encode(arrayBuffer);
|
|
3762
|
+
if (!lastBlobMap.has(id) && (yield transparentBase64) === base64) {
|
|
3763
|
+
lastBlobMap.set(id, base64);
|
|
3764
|
+
return worker.postMessage({ id });
|
|
3765
|
+
}
|
|
3766
|
+
if (lastBlobMap.get(id) === base64)
|
|
3767
|
+
return worker.postMessage({ id });
|
|
3768
|
+
worker.postMessage({
|
|
3769
|
+
id,
|
|
3770
|
+
type,
|
|
3771
|
+
base64,
|
|
3772
|
+
width,
|
|
3773
|
+
height,
|
|
3774
|
+
});
|
|
3775
|
+
lastBlobMap.set(id, base64);
|
|
3776
|
+
}
|
|
3777
|
+
else {
|
|
3778
|
+
return worker.postMessage({ id: e.data.id });
|
|
3779
|
+
}
|
|
3780
|
+
});
|
|
3781
|
+
};
|
|
3782
|
+
|
|
3783
|
+
})();
|
|
3784
|
+
}, null);
|
|
3273
3785
|
|
|
3274
3786
|
class CanvasManager {
|
|
3787
|
+
reset() {
|
|
3788
|
+
this.pendingCanvasMutations.clear();
|
|
3789
|
+
this.resetObservers && this.resetObservers();
|
|
3790
|
+
}
|
|
3791
|
+
freeze() {
|
|
3792
|
+
this.frozen = true;
|
|
3793
|
+
}
|
|
3794
|
+
unfreeze() {
|
|
3795
|
+
this.frozen = false;
|
|
3796
|
+
}
|
|
3797
|
+
lock() {
|
|
3798
|
+
this.locked = true;
|
|
3799
|
+
}
|
|
3800
|
+
unlock() {
|
|
3801
|
+
this.locked = false;
|
|
3802
|
+
}
|
|
3275
3803
|
constructor(options) {
|
|
3276
3804
|
this.pendingCanvasMutations = new Map();
|
|
3277
3805
|
this.rafStamps = { latestId: 0, invokeId: null };
|
|
@@ -3297,24 +3825,8 @@
|
|
|
3297
3825
|
dataURLOptions,
|
|
3298
3826
|
});
|
|
3299
3827
|
}
|
|
3300
|
-
reset() {
|
|
3301
|
-
this.pendingCanvasMutations.clear();
|
|
3302
|
-
this.resetObservers && this.resetObservers();
|
|
3303
|
-
}
|
|
3304
|
-
freeze() {
|
|
3305
|
-
this.frozen = true;
|
|
3306
|
-
}
|
|
3307
|
-
unfreeze() {
|
|
3308
|
-
this.frozen = false;
|
|
3309
|
-
}
|
|
3310
|
-
lock() {
|
|
3311
|
-
this.locked = true;
|
|
3312
|
-
}
|
|
3313
|
-
unlock() {
|
|
3314
|
-
this.locked = false;
|
|
3315
|
-
}
|
|
3316
3828
|
initCanvasFPSObserver(fps, win, blockClass, blockSelector, options) {
|
|
3317
|
-
const canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector);
|
|
3829
|
+
const canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, true);
|
|
3318
3830
|
const snapshotInProgressMap = new Map();
|
|
3319
3831
|
const worker = new WorkerFactory();
|
|
3320
3832
|
worker.onmessage = (e) => {
|
|
@@ -3376,11 +3888,13 @@
|
|
|
3376
3888
|
const id = this.mirror.getId(canvas);
|
|
3377
3889
|
if (snapshotInProgressMap.get(id))
|
|
3378
3890
|
return;
|
|
3891
|
+
if (canvas.width === 0 || canvas.height === 0)
|
|
3892
|
+
return;
|
|
3379
3893
|
snapshotInProgressMap.set(id, true);
|
|
3380
3894
|
if (['webgl', 'webgl2'].includes(canvas.__context)) {
|
|
3381
3895
|
const context = canvas.getContext(canvas.__context);
|
|
3382
3896
|
if (((_a = context === null || context === void 0 ? void 0 : context.getContextAttributes()) === null || _a === void 0 ? void 0 : _a.preserveDrawingBuffer) === false) {
|
|
3383
|
-
context
|
|
3897
|
+
context.clear(context.COLOR_BUFFER_BIT);
|
|
3384
3898
|
}
|
|
3385
3899
|
}
|
|
3386
3900
|
const bitmap = yield createImageBitmap(canvas);
|
|
@@ -3403,7 +3917,7 @@
|
|
|
3403
3917
|
initCanvasMutationObserver(win, blockClass, blockSelector) {
|
|
3404
3918
|
this.startRAFTimestamping();
|
|
3405
3919
|
this.startPendingCanvasMutationFlusher();
|
|
3406
|
-
const canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector);
|
|
3920
|
+
const canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, false);
|
|
3407
3921
|
const canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
|
|
3408
3922
|
const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector, this.mirror);
|
|
3409
3923
|
this.resetObservers = () => {
|
|
@@ -3487,15 +4001,12 @@
|
|
|
3487
4001
|
let styleId;
|
|
3488
4002
|
if (!this.styleMirror.has(sheet)) {
|
|
3489
4003
|
styleId = this.styleMirror.add(sheet);
|
|
3490
|
-
const rules = Array.from(sheet.rules || CSSRule);
|
|
3491
4004
|
styles.push({
|
|
3492
4005
|
styleId,
|
|
3493
|
-
rules:
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
};
|
|
3498
|
-
}),
|
|
4006
|
+
rules: Array.from(sheet.rules || CSSRule, (r, index) => ({
|
|
4007
|
+
rule: stringifyRule(r),
|
|
4008
|
+
index,
|
|
4009
|
+
})),
|
|
3499
4010
|
});
|
|
3500
4011
|
}
|
|
3501
4012
|
else
|
|
@@ -3514,8 +4025,36 @@
|
|
|
3514
4025
|
}
|
|
3515
4026
|
}
|
|
3516
4027
|
|
|
4028
|
+
class ProcessedNodeManager {
|
|
4029
|
+
constructor() {
|
|
4030
|
+
this.nodeMap = new WeakMap();
|
|
4031
|
+
this.loop = true;
|
|
4032
|
+
this.periodicallyClear();
|
|
4033
|
+
}
|
|
4034
|
+
periodicallyClear() {
|
|
4035
|
+
requestAnimationFrame(() => {
|
|
4036
|
+
this.clear();
|
|
4037
|
+
if (this.loop)
|
|
4038
|
+
this.periodicallyClear();
|
|
4039
|
+
});
|
|
4040
|
+
}
|
|
4041
|
+
inOtherBuffer(node, thisBuffer) {
|
|
4042
|
+
const buffers = this.nodeMap.get(node);
|
|
4043
|
+
return (buffers && Array.from(buffers).some((buffer) => buffer !== thisBuffer));
|
|
4044
|
+
}
|
|
4045
|
+
add(node, buffer) {
|
|
4046
|
+
this.nodeMap.set(node, (this.nodeMap.get(node) || new Set()).add(buffer));
|
|
4047
|
+
}
|
|
4048
|
+
clear() {
|
|
4049
|
+
this.nodeMap = new WeakMap();
|
|
4050
|
+
}
|
|
4051
|
+
destroy() {
|
|
4052
|
+
this.loop = false;
|
|
4053
|
+
}
|
|
4054
|
+
}
|
|
4055
|
+
|
|
3517
4056
|
function wrapEvent(e) {
|
|
3518
|
-
return Object.assign(Object.assign({}, e), { timestamp:
|
|
4057
|
+
return Object.assign(Object.assign({}, e), { timestamp: nowTimestamp() });
|
|
3519
4058
|
}
|
|
3520
4059
|
let wrappedEmit;
|
|
3521
4060
|
let takeFullSnapshot;
|
|
@@ -3523,15 +4062,19 @@
|
|
|
3523
4062
|
let recording = false;
|
|
3524
4063
|
const mirror = createMirror();
|
|
3525
4064
|
function record(options = {}) {
|
|
3526
|
-
const { emit, checkoutEveryNms, checkoutEveryNth, blockClass = 'rr-block', blockSelector = null, ignoreClass = 'rr-ignore', maskTextClass = 'rr-mask', maskTextSelector = null, inlineStylesheet = true, maskAllInputs, maskInputOptions: _maskInputOptions, slimDOMOptions: _slimDOMOptions, maskInputFn, maskTextFn, hooks, packFn, sampling = {}, dataURLOptions = {}, mousemoveWait,
|
|
4065
|
+
const { emit, checkoutEveryNms, checkoutEveryNth, blockClass = 'rr-block', blockSelector = null, ignoreClass = 'rr-ignore', ignoreSelector = null, maskTextClass = 'rr-mask', maskTextSelector = null, inlineStylesheet = true, maskAllInputs, maskInputOptions: _maskInputOptions, slimDOMOptions: _slimDOMOptions, maskInputFn, maskTextFn, hooks, packFn, sampling = {}, dataURLOptions = {}, mousemoveWait, recordDOM = true, recordCanvas = false, recordCrossOriginIframes = false, recordAfter = options.recordAfter === 'DOMContentLoaded'
|
|
4066
|
+
? options.recordAfter
|
|
4067
|
+
: 'load', userTriggeredOnInput = false, collectFonts = false, inlineImages = false, plugins, keepIframeSrcFn = () => false, ignoreCSSAttributes = new Set([]), errorHandler, } = options;
|
|
4068
|
+
registerErrorHandler(errorHandler);
|
|
3527
4069
|
const inEmittingFrame = recordCrossOriginIframes
|
|
3528
4070
|
? window.parent === window
|
|
3529
4071
|
: true;
|
|
3530
4072
|
let passEmitsToParent = false;
|
|
3531
4073
|
if (!inEmittingFrame) {
|
|
3532
4074
|
try {
|
|
3533
|
-
window.parent.document
|
|
3534
|
-
|
|
4075
|
+
if (window.parent.document) {
|
|
4076
|
+
passEmitsToParent = false;
|
|
4077
|
+
}
|
|
3535
4078
|
}
|
|
3536
4079
|
catch (e) {
|
|
3537
4080
|
passEmitsToParent = true;
|
|
@@ -3591,7 +4134,8 @@
|
|
|
3591
4134
|
e = plugin.eventProcessor(e);
|
|
3592
4135
|
}
|
|
3593
4136
|
}
|
|
3594
|
-
if (packFn
|
|
4137
|
+
if (packFn &&
|
|
4138
|
+
!passEmitsToParent) {
|
|
3595
4139
|
e = packFn(e);
|
|
3596
4140
|
}
|
|
3597
4141
|
return e;
|
|
@@ -3611,6 +4155,7 @@
|
|
|
3611
4155
|
const message = {
|
|
3612
4156
|
type: 'rrweb',
|
|
3613
4157
|
event: eventProcessor(e),
|
|
4158
|
+
origin: window.location.origin,
|
|
3614
4159
|
isCheckout,
|
|
3615
4160
|
};
|
|
3616
4161
|
window.parent.postMessage(message, '*');
|
|
@@ -3670,6 +4215,7 @@
|
|
|
3670
4215
|
crossOriginIframeStyleMirror: iframeManager.crossOriginIframeStyleMirror,
|
|
3671
4216
|
});
|
|
3672
4217
|
}
|
|
4218
|
+
const processedNodeManager = new ProcessedNodeManager();
|
|
3673
4219
|
canvasManager = new CanvasManager({
|
|
3674
4220
|
recordCanvas,
|
|
3675
4221
|
mutationCb: wrappedCanvasMutationEmit,
|
|
@@ -3701,11 +4247,14 @@
|
|
|
3701
4247
|
stylesheetManager,
|
|
3702
4248
|
canvasManager,
|
|
3703
4249
|
keepIframeSrcFn,
|
|
4250
|
+
processedNodeManager,
|
|
3704
4251
|
},
|
|
3705
4252
|
mirror,
|
|
3706
4253
|
});
|
|
3707
4254
|
takeFullSnapshot = (isCheckout = false) => {
|
|
3708
|
-
|
|
4255
|
+
if (!recordDOM) {
|
|
4256
|
+
return;
|
|
4257
|
+
}
|
|
3709
4258
|
wrappedEmit(wrapEvent({
|
|
3710
4259
|
type: EventType.Meta,
|
|
3711
4260
|
data: {
|
|
@@ -3715,6 +4264,7 @@
|
|
|
3715
4264
|
},
|
|
3716
4265
|
}), isCheckout);
|
|
3717
4266
|
stylesheetManager.reset();
|
|
4267
|
+
shadowDomManager.init();
|
|
3718
4268
|
mutationBuffers.forEach((buf) => buf.lock());
|
|
3719
4269
|
const node = snapshot(document, {
|
|
3720
4270
|
mirror,
|
|
@@ -3756,37 +4306,18 @@
|
|
|
3756
4306
|
type: EventType.FullSnapshot,
|
|
3757
4307
|
data: {
|
|
3758
4308
|
node,
|
|
3759
|
-
initialOffset:
|
|
3760
|
-
left: window.pageXOffset !== undefined
|
|
3761
|
-
? window.pageXOffset
|
|
3762
|
-
: (document === null || document === void 0 ? void 0 : document.documentElement.scrollLeft) ||
|
|
3763
|
-
((_b = (_a = document === null || document === void 0 ? void 0 : document.body) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.scrollLeft) ||
|
|
3764
|
-
((_c = document === null || document === void 0 ? void 0 : document.body) === null || _c === void 0 ? void 0 : _c.scrollLeft) ||
|
|
3765
|
-
0,
|
|
3766
|
-
top: window.pageYOffset !== undefined
|
|
3767
|
-
? window.pageYOffset
|
|
3768
|
-
: (document === null || document === void 0 ? void 0 : document.documentElement.scrollTop) ||
|
|
3769
|
-
((_e = (_d = document === null || document === void 0 ? void 0 : document.body) === null || _d === void 0 ? void 0 : _d.parentElement) === null || _e === void 0 ? void 0 : _e.scrollTop) ||
|
|
3770
|
-
((_f = document === null || document === void 0 ? void 0 : document.body) === null || _f === void 0 ? void 0 : _f.scrollTop) ||
|
|
3771
|
-
0,
|
|
3772
|
-
},
|
|
4309
|
+
initialOffset: getWindowScroll(window),
|
|
3773
4310
|
},
|
|
3774
|
-
}));
|
|
4311
|
+
}), isCheckout);
|
|
3775
4312
|
mutationBuffers.forEach((buf) => buf.unlock());
|
|
3776
4313
|
if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0)
|
|
3777
4314
|
stylesheetManager.adoptStyleSheets(document.adoptedStyleSheets, mirror.getId(document));
|
|
3778
4315
|
};
|
|
3779
4316
|
try {
|
|
3780
4317
|
const handlers = [];
|
|
3781
|
-
handlers.push(on('DOMContentLoaded', () => {
|
|
3782
|
-
wrappedEmit(wrapEvent({
|
|
3783
|
-
type: EventType.DomContentLoaded,
|
|
3784
|
-
data: {},
|
|
3785
|
-
}));
|
|
3786
|
-
}));
|
|
3787
4318
|
const observe = (doc) => {
|
|
3788
4319
|
var _a;
|
|
3789
|
-
return initObservers({
|
|
4320
|
+
return callbackWrapper(initObservers)({
|
|
3790
4321
|
mutationCb: wrappedMutationEmit,
|
|
3791
4322
|
mousemoveCb: (positions, source) => wrappedEmit(wrapEvent({
|
|
3792
4323
|
type: EventType.IncrementalSnapshot,
|
|
@@ -3831,13 +4362,21 @@
|
|
|
3831
4362
|
data: Object.assign({ source: IncrementalSource.Selection }, p),
|
|
3832
4363
|
}));
|
|
3833
4364
|
},
|
|
4365
|
+
customElementCb: (c) => {
|
|
4366
|
+
wrappedEmit(wrapEvent({
|
|
4367
|
+
type: EventType.IncrementalSnapshot,
|
|
4368
|
+
data: Object.assign({ source: IncrementalSource.CustomElement }, c),
|
|
4369
|
+
}));
|
|
4370
|
+
},
|
|
3834
4371
|
blockClass,
|
|
3835
4372
|
ignoreClass,
|
|
4373
|
+
ignoreSelector,
|
|
3836
4374
|
maskTextClass,
|
|
3837
4375
|
maskTextSelector,
|
|
3838
4376
|
maskInputOptions,
|
|
3839
4377
|
inlineStylesheet,
|
|
3840
4378
|
sampling,
|
|
4379
|
+
recordDOM,
|
|
3841
4380
|
recordCanvas,
|
|
3842
4381
|
inlineImages,
|
|
3843
4382
|
userTriggeredOnInput,
|
|
@@ -3853,6 +4392,7 @@
|
|
|
3853
4392
|
iframeManager,
|
|
3854
4393
|
stylesheetManager,
|
|
3855
4394
|
shadowDomManager,
|
|
4395
|
+
processedNodeManager,
|
|
3856
4396
|
canvasManager,
|
|
3857
4397
|
ignoreCSSAttributes,
|
|
3858
4398
|
plugins: ((_a = plugins === null || plugins === void 0 ? void 0 : plugins.filter((p) => p.observer)) === null || _a === void 0 ? void 0 : _a.map((p) => ({
|
|
@@ -3869,7 +4409,12 @@
|
|
|
3869
4409
|
}, hooks);
|
|
3870
4410
|
};
|
|
3871
4411
|
iframeManager.addLoadListener((iframeEl) => {
|
|
3872
|
-
|
|
4412
|
+
try {
|
|
4413
|
+
handlers.push(observe(iframeEl.contentDocument));
|
|
4414
|
+
}
|
|
4415
|
+
catch (error) {
|
|
4416
|
+
console.warn(error);
|
|
4417
|
+
}
|
|
3873
4418
|
});
|
|
3874
4419
|
const init = () => {
|
|
3875
4420
|
takeFullSnapshot();
|
|
@@ -3881,17 +4426,28 @@
|
|
|
3881
4426
|
init();
|
|
3882
4427
|
}
|
|
3883
4428
|
else {
|
|
4429
|
+
handlers.push(on('DOMContentLoaded', () => {
|
|
4430
|
+
wrappedEmit(wrapEvent({
|
|
4431
|
+
type: EventType.DomContentLoaded,
|
|
4432
|
+
data: {},
|
|
4433
|
+
}));
|
|
4434
|
+
if (recordAfter === 'DOMContentLoaded')
|
|
4435
|
+
init();
|
|
4436
|
+
}));
|
|
3884
4437
|
handlers.push(on('load', () => {
|
|
3885
4438
|
wrappedEmit(wrapEvent({
|
|
3886
4439
|
type: EventType.Load,
|
|
3887
4440
|
data: {},
|
|
3888
4441
|
}));
|
|
3889
|
-
|
|
4442
|
+
if (recordAfter === 'load')
|
|
4443
|
+
init();
|
|
3890
4444
|
}, window));
|
|
3891
4445
|
}
|
|
3892
4446
|
return () => {
|
|
3893
4447
|
handlers.forEach((h) => h());
|
|
4448
|
+
processedNodeManager.destroy();
|
|
3894
4449
|
recording = false;
|
|
4450
|
+
unregisterErrorHandler();
|
|
3895
4451
|
};
|
|
3896
4452
|
}
|
|
3897
4453
|
catch (error) {
|
|
@@ -3923,7 +4479,7 @@
|
|
|
3923
4479
|
|
|
3924
4480
|
var Config = {
|
|
3925
4481
|
DEBUG: false,
|
|
3926
|
-
LIB_VERSION: '2.
|
|
4482
|
+
LIB_VERSION: '2.51.0'
|
|
3927
4483
|
};
|
|
3928
4484
|
|
|
3929
4485
|
/* eslint camelcase: "off", eqeqeq: "off" */
|
|
@@ -5851,7 +6407,10 @@
|
|
|
5851
6407
|
resetIdleTimeout();
|
|
5852
6408
|
}, this),
|
|
5853
6409
|
'maskAllInputs': true,
|
|
5854
|
-
'maskTextSelector': this.get_config('record_mask_text_selector')
|
|
6410
|
+
'maskTextSelector': this.get_config('record_mask_text_selector'),
|
|
6411
|
+
'blockSelector': this.get_config('record_block_selector'),
|
|
6412
|
+
'maskTextClass': this.get_config('record_mask_text_class'),
|
|
6413
|
+
'blockClass': this.get_config('record_block_class'),
|
|
5855
6414
|
});
|
|
5856
6415
|
|
|
5857
6416
|
resetIdleTimeout();
|