@sentry/replay 7.36.0 → 7.37.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/README.md +8 -29
- package/cjs/index.js +1177 -1385
- package/cjs/index.js.map +1 -1
- package/esm/index.js +1177 -1385
- package/esm/index.js.map +1 -1
- package/package.json +5 -5
- package/types/coreHandlers/handleGlobalEvent.d.ts +2 -2
- package/types/coreHandlers/handleGlobalEvent.d.ts.map +1 -1
- package/types/replay.d.ts.map +1 -1
- package/types/util/addEvent.d.ts.map +1 -1
- package/types/util/isRrwebError.d.ts +2 -2
- package/types/util/isRrwebError.d.ts.map +1 -1
package/cjs/index.js
CHANGED
|
@@ -35,83 +35,6 @@ const ERROR_CHECKOUT_TIME = 60000;
|
|
|
35
35
|
const RETRY_BASE_INTERVAL = 5000;
|
|
36
36
|
const RETRY_MAX_COUNT = 3;
|
|
37
37
|
|
|
38
|
-
/*! *****************************************************************************
|
|
39
|
-
Copyright (c) Microsoft Corporation.
|
|
40
|
-
|
|
41
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
42
|
-
purpose with or without fee is hereby granted.
|
|
43
|
-
|
|
44
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
45
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
46
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
47
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
48
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
49
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
50
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
51
|
-
***************************************************************************** */
|
|
52
|
-
|
|
53
|
-
var __assign = function() {
|
|
54
|
-
__assign = Object.assign || function __assign(t) {
|
|
55
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
56
|
-
s = arguments[i];
|
|
57
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
58
|
-
}
|
|
59
|
-
return t;
|
|
60
|
-
};
|
|
61
|
-
return __assign.apply(this, arguments);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
function __rest(s, e) {
|
|
65
|
-
var t = {};
|
|
66
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
67
|
-
t[p] = s[p];
|
|
68
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
69
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
70
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
71
|
-
t[p[i]] = s[p[i]];
|
|
72
|
-
}
|
|
73
|
-
return t;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function __values(o) {
|
|
77
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
78
|
-
if (m) return m.call(o);
|
|
79
|
-
if (o && typeof o.length === "number") return {
|
|
80
|
-
next: function () {
|
|
81
|
-
if (o && i >= o.length) o = void 0;
|
|
82
|
-
return { value: o && o[i++], done: !o };
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function __read(o, n) {
|
|
89
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
90
|
-
if (!m) return o;
|
|
91
|
-
var i = m.call(o), r, ar = [], e;
|
|
92
|
-
try {
|
|
93
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
94
|
-
}
|
|
95
|
-
catch (error) { e = { error: error }; }
|
|
96
|
-
finally {
|
|
97
|
-
try {
|
|
98
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
99
|
-
}
|
|
100
|
-
finally { if (e) throw e.error; }
|
|
101
|
-
}
|
|
102
|
-
return ar;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function __spreadArray(to, from, pack) {
|
|
106
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
107
|
-
if (ar || !(i in from)) {
|
|
108
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
109
|
-
ar[i] = from[i];
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
113
|
-
}
|
|
114
|
-
|
|
115
38
|
var NodeType;
|
|
116
39
|
(function (NodeType) {
|
|
117
40
|
NodeType[NodeType["Document"] = 0] = "Document";
|
|
@@ -126,13 +49,11 @@ function isElement(n) {
|
|
|
126
49
|
return n.nodeType === n.ELEMENT_NODE;
|
|
127
50
|
}
|
|
128
51
|
function isShadowRoot(n) {
|
|
129
|
-
|
|
130
|
-
var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;
|
|
52
|
+
const host = n === null || n === void 0 ? void 0 : n.host;
|
|
131
53
|
return Boolean(host && host.shadowRoot && host.shadowRoot === n);
|
|
132
54
|
}
|
|
133
|
-
function maskInputValue(
|
|
134
|
-
|
|
135
|
-
var text = value || '';
|
|
55
|
+
function maskInputValue({ input, maskInputSelector, unmaskInputSelector, maskInputOptions, tagName, type, value, maskInputFn, }) {
|
|
56
|
+
let text = value || '';
|
|
136
57
|
if (unmaskInputSelector && input.matches(unmaskInputSelector)) {
|
|
137
58
|
return text;
|
|
138
59
|
}
|
|
@@ -148,29 +69,29 @@ function maskInputValue(_a) {
|
|
|
148
69
|
}
|
|
149
70
|
return text;
|
|
150
71
|
}
|
|
151
|
-
|
|
72
|
+
const ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';
|
|
152
73
|
function is2DCanvasBlank(canvas) {
|
|
153
|
-
|
|
74
|
+
const ctx = canvas.getContext('2d');
|
|
154
75
|
if (!ctx)
|
|
155
76
|
return true;
|
|
156
|
-
|
|
157
|
-
for (
|
|
158
|
-
for (
|
|
159
|
-
|
|
160
|
-
|
|
77
|
+
const chunkSize = 50;
|
|
78
|
+
for (let x = 0; x < canvas.width; x += chunkSize) {
|
|
79
|
+
for (let y = 0; y < canvas.height; y += chunkSize) {
|
|
80
|
+
const getImageData = ctx.getImageData;
|
|
81
|
+
const originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData
|
|
161
82
|
? getImageData[ORIGINAL_ATTRIBUTE_NAME]
|
|
162
83
|
: getImageData;
|
|
163
|
-
|
|
164
|
-
if (pixelBuffer.some(
|
|
84
|
+
const pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);
|
|
85
|
+
if (pixelBuffer.some((pixel) => pixel !== 0))
|
|
165
86
|
return false;
|
|
166
87
|
}
|
|
167
88
|
}
|
|
168
89
|
return true;
|
|
169
90
|
}
|
|
170
91
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
92
|
+
let _id = 1;
|
|
93
|
+
const tagNameRegex = new RegExp('[^a-z0-9-_:]');
|
|
94
|
+
const IGNORED_NODE = -2;
|
|
174
95
|
function genId() {
|
|
175
96
|
return _id++;
|
|
176
97
|
}
|
|
@@ -178,7 +99,7 @@ function getValidTagName(element) {
|
|
|
178
99
|
if (element instanceof HTMLFormElement) {
|
|
179
100
|
return 'form';
|
|
180
101
|
}
|
|
181
|
-
|
|
102
|
+
const processedTagName = element.tagName.toLowerCase().trim();
|
|
182
103
|
if (tagNameRegex.test(processedTagName)) {
|
|
183
104
|
return 'div';
|
|
184
105
|
}
|
|
@@ -186,7 +107,7 @@ function getValidTagName(element) {
|
|
|
186
107
|
}
|
|
187
108
|
function getCssRulesString(s) {
|
|
188
109
|
try {
|
|
189
|
-
|
|
110
|
+
const rules = s.rules || s.cssRules;
|
|
190
111
|
return rules ? Array.from(rules).map(getCssRuleString).join('') : null;
|
|
191
112
|
}
|
|
192
113
|
catch (error) {
|
|
@@ -194,7 +115,7 @@ function getCssRulesString(s) {
|
|
|
194
115
|
}
|
|
195
116
|
}
|
|
196
117
|
function getCssRuleString(rule) {
|
|
197
|
-
|
|
118
|
+
let cssStringified = rule.cssText;
|
|
198
119
|
if (isCSSImportRule(rule)) {
|
|
199
120
|
try {
|
|
200
121
|
cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;
|
|
@@ -210,12 +131,12 @@ function isCSSImportRule(rule) {
|
|
|
210
131
|
function stringifyStyleSheet(sheet) {
|
|
211
132
|
return sheet.cssRules
|
|
212
133
|
? Array.from(sheet.cssRules)
|
|
213
|
-
.map(
|
|
134
|
+
.map((rule) => rule.cssText || '')
|
|
214
135
|
.join('')
|
|
215
136
|
: '';
|
|
216
137
|
}
|
|
217
138
|
function extractOrigin(url) {
|
|
218
|
-
|
|
139
|
+
let origin = '';
|
|
219
140
|
if (url.indexOf('//') > -1) {
|
|
220
141
|
origin = url.split('/').slice(0, 3).join('/');
|
|
221
142
|
}
|
|
@@ -225,32 +146,31 @@ function extractOrigin(url) {
|
|
|
225
146
|
origin = origin.split('?')[0];
|
|
226
147
|
return origin;
|
|
227
148
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
149
|
+
let canvasService;
|
|
150
|
+
let canvasCtx;
|
|
151
|
+
const URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
|
|
152
|
+
const RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/;
|
|
153
|
+
const DATA_URI = /^(data:)([^,]*),(.*)/i;
|
|
233
154
|
function absoluteToStylesheet(cssText, href) {
|
|
234
|
-
return (cssText || '').replace(URL_IN_CSS_REF,
|
|
235
|
-
|
|
236
|
-
|
|
155
|
+
return (cssText || '').replace(URL_IN_CSS_REF, (origin, quote1, path1, quote2, path2, path3) => {
|
|
156
|
+
const filePath = path1 || path2 || path3;
|
|
157
|
+
const maybeQuote = quote1 || quote2 || '';
|
|
237
158
|
if (!filePath) {
|
|
238
159
|
return origin;
|
|
239
160
|
}
|
|
240
161
|
if (!RELATIVE_PATH.test(filePath)) {
|
|
241
|
-
return
|
|
162
|
+
return `url(${maybeQuote}${filePath}${maybeQuote})`;
|
|
242
163
|
}
|
|
243
164
|
if (DATA_URI.test(filePath)) {
|
|
244
|
-
return
|
|
165
|
+
return `url(${maybeQuote}${filePath}${maybeQuote})`;
|
|
245
166
|
}
|
|
246
167
|
if (filePath[0] === '/') {
|
|
247
|
-
return
|
|
168
|
+
return `url(${maybeQuote}${extractOrigin(href) + filePath}${maybeQuote})`;
|
|
248
169
|
}
|
|
249
|
-
|
|
250
|
-
|
|
170
|
+
const stack = href.split('/');
|
|
171
|
+
const parts = filePath.split('/');
|
|
251
172
|
stack.pop();
|
|
252
|
-
for (
|
|
253
|
-
var part = parts_1[_i];
|
|
173
|
+
for (const part of parts) {
|
|
254
174
|
if (part === '.') {
|
|
255
175
|
continue;
|
|
256
176
|
}
|
|
@@ -261,19 +181,19 @@ function absoluteToStylesheet(cssText, href) {
|
|
|
261
181
|
stack.push(part);
|
|
262
182
|
}
|
|
263
183
|
}
|
|
264
|
-
return
|
|
184
|
+
return `url(${maybeQuote}${stack.join('/')}${maybeQuote})`;
|
|
265
185
|
});
|
|
266
186
|
}
|
|
267
|
-
|
|
268
|
-
|
|
187
|
+
const SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
|
|
188
|
+
const SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
|
|
269
189
|
function getAbsoluteSrcsetString(doc, attributeValue) {
|
|
270
190
|
if (attributeValue.trim() === '') {
|
|
271
191
|
return attributeValue;
|
|
272
192
|
}
|
|
273
|
-
|
|
193
|
+
let pos = 0;
|
|
274
194
|
function collectCharacters(regEx) {
|
|
275
|
-
|
|
276
|
-
|
|
195
|
+
let chars;
|
|
196
|
+
let match = regEx.exec(attributeValue.substring(pos));
|
|
277
197
|
if (match) {
|
|
278
198
|
chars = match[0];
|
|
279
199
|
pos += chars.length;
|
|
@@ -281,23 +201,23 @@ function getAbsoluteSrcsetString(doc, attributeValue) {
|
|
|
281
201
|
}
|
|
282
202
|
return '';
|
|
283
203
|
}
|
|
284
|
-
|
|
204
|
+
let output = [];
|
|
285
205
|
while (true) {
|
|
286
206
|
collectCharacters(SRCSET_COMMAS_OR_SPACES);
|
|
287
207
|
if (pos >= attributeValue.length) {
|
|
288
208
|
break;
|
|
289
209
|
}
|
|
290
|
-
|
|
210
|
+
let url = collectCharacters(SRCSET_NOT_SPACES);
|
|
291
211
|
if (url.slice(-1) === ',') {
|
|
292
212
|
url = absoluteToDoc(doc, url.substring(0, url.length - 1));
|
|
293
213
|
output.push(url);
|
|
294
214
|
}
|
|
295
215
|
else {
|
|
296
|
-
|
|
216
|
+
let descriptorsStr = '';
|
|
297
217
|
url = absoluteToDoc(doc, url);
|
|
298
|
-
|
|
218
|
+
let inParens = false;
|
|
299
219
|
while (true) {
|
|
300
|
-
|
|
220
|
+
let c = attributeValue.charAt(pos);
|
|
301
221
|
if (c === '') {
|
|
302
222
|
output.push((url + descriptorsStr).trim());
|
|
303
223
|
break;
|
|
@@ -328,7 +248,7 @@ function absoluteToDoc(doc, attributeValue) {
|
|
|
328
248
|
if (!attributeValue || attributeValue.trim() === '') {
|
|
329
249
|
return attributeValue;
|
|
330
250
|
}
|
|
331
|
-
|
|
251
|
+
const a = doc.createElement('a');
|
|
332
252
|
a.href = attributeValue;
|
|
333
253
|
return a.href;
|
|
334
254
|
}
|
|
@@ -336,7 +256,7 @@ function isSVGElement(el) {
|
|
|
336
256
|
return Boolean(el.tagName === 'svg' || el.ownerSVGElement);
|
|
337
257
|
}
|
|
338
258
|
function getHref() {
|
|
339
|
-
|
|
259
|
+
const a = document.createElement('a');
|
|
340
260
|
a.href = '';
|
|
341
261
|
return a.href;
|
|
342
262
|
}
|
|
@@ -375,8 +295,8 @@ function _isBlockedElement(element, blockClass, blockSelector, unblockSelector)
|
|
|
375
295
|
}
|
|
376
296
|
}
|
|
377
297
|
else {
|
|
378
|
-
for (
|
|
379
|
-
|
|
298
|
+
for (let eIndex = 0; eIndex < element.classList.length; eIndex++) {
|
|
299
|
+
const className = element.classList[eIndex];
|
|
380
300
|
if (blockClass.test(className)) {
|
|
381
301
|
return true;
|
|
382
302
|
}
|
|
@@ -404,8 +324,8 @@ function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelect
|
|
|
404
324
|
}
|
|
405
325
|
}
|
|
406
326
|
else {
|
|
407
|
-
for (
|
|
408
|
-
|
|
327
|
+
for (let eIndex = 0; eIndex < node.classList.length; eIndex++) {
|
|
328
|
+
const className = node.classList[eIndex];
|
|
409
329
|
if (maskTextClass.test(className)) {
|
|
410
330
|
return true;
|
|
411
331
|
}
|
|
@@ -424,12 +344,12 @@ function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelect
|
|
|
424
344
|
return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);
|
|
425
345
|
}
|
|
426
346
|
function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
|
|
427
|
-
|
|
347
|
+
const win = iframeEl.contentWindow;
|
|
428
348
|
if (!win) {
|
|
429
349
|
return;
|
|
430
350
|
}
|
|
431
|
-
|
|
432
|
-
|
|
351
|
+
let fired = false;
|
|
352
|
+
let readyState;
|
|
433
353
|
try {
|
|
434
354
|
readyState = win.document.readyState;
|
|
435
355
|
}
|
|
@@ -437,20 +357,20 @@ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
|
|
|
437
357
|
return;
|
|
438
358
|
}
|
|
439
359
|
if (readyState !== 'complete') {
|
|
440
|
-
|
|
360
|
+
const timer = setTimeout(() => {
|
|
441
361
|
if (!fired) {
|
|
442
362
|
listener();
|
|
443
363
|
fired = true;
|
|
444
364
|
}
|
|
445
365
|
}, iframeLoadTimeout);
|
|
446
|
-
iframeEl.addEventListener('load',
|
|
447
|
-
clearTimeout(
|
|
366
|
+
iframeEl.addEventListener('load', () => {
|
|
367
|
+
clearTimeout(timer);
|
|
448
368
|
fired = true;
|
|
449
369
|
listener();
|
|
450
370
|
});
|
|
451
371
|
return;
|
|
452
372
|
}
|
|
453
|
-
|
|
373
|
+
const blankUrl = 'about:blank';
|
|
454
374
|
if (win.location.href !== blankUrl ||
|
|
455
375
|
iframeEl.src === blankUrl ||
|
|
456
376
|
iframeEl.src === '') {
|
|
@@ -461,10 +381,10 @@ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
|
|
|
461
381
|
}
|
|
462
382
|
function serializeNode(n, options) {
|
|
463
383
|
var _a;
|
|
464
|
-
|
|
465
|
-
|
|
384
|
+
const { doc, blockClass, blockSelector, unblockSelector, maskTextClass, maskTextSelector, unmaskTextSelector, inlineStylesheet, maskInputSelector, unmaskInputSelector, maskInputOptions = {}, maskTextFn, maskInputFn, dataURLOptions = {}, inlineImages, recordCanvas, keepIframeSrcFn, } = options;
|
|
385
|
+
let rootId;
|
|
466
386
|
if (doc.__sn) {
|
|
467
|
-
|
|
387
|
+
const docId = doc.__sn.id;
|
|
468
388
|
rootId = docId === 1 ? undefined : docId;
|
|
469
389
|
}
|
|
470
390
|
switch (n.nodeType) {
|
|
@@ -474,14 +394,14 @@ function serializeNode(n, options) {
|
|
|
474
394
|
type: NodeType.Document,
|
|
475
395
|
childNodes: [],
|
|
476
396
|
compatMode: n.compatMode,
|
|
477
|
-
rootId
|
|
397
|
+
rootId,
|
|
478
398
|
};
|
|
479
399
|
}
|
|
480
400
|
else {
|
|
481
401
|
return {
|
|
482
402
|
type: NodeType.Document,
|
|
483
403
|
childNodes: [],
|
|
484
|
-
rootId
|
|
404
|
+
rootId,
|
|
485
405
|
};
|
|
486
406
|
}
|
|
487
407
|
case n.DOCUMENT_TYPE_NODE:
|
|
@@ -490,28 +410,27 @@ function serializeNode(n, options) {
|
|
|
490
410
|
name: n.name,
|
|
491
411
|
publicId: n.publicId,
|
|
492
412
|
systemId: n.systemId,
|
|
493
|
-
rootId
|
|
413
|
+
rootId,
|
|
494
414
|
};
|
|
495
415
|
case n.ELEMENT_NODE:
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
for (
|
|
500
|
-
|
|
501
|
-
attributes_1[name_1] = transformAttribute(doc, tagName, name_1, value);
|
|
416
|
+
const needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector);
|
|
417
|
+
const tagName = getValidTagName(n);
|
|
418
|
+
let attributes = {};
|
|
419
|
+
for (const { name, value } of Array.from(n.attributes)) {
|
|
420
|
+
attributes[name] = transformAttribute(doc, tagName, name, value);
|
|
502
421
|
}
|
|
503
422
|
if (tagName === 'link' && inlineStylesheet) {
|
|
504
|
-
|
|
423
|
+
const stylesheet = Array.from(doc.styleSheets).find((s) => {
|
|
505
424
|
return s.href === n.href;
|
|
506
425
|
});
|
|
507
|
-
|
|
426
|
+
let cssText = null;
|
|
508
427
|
if (stylesheet) {
|
|
509
428
|
cssText = getCssRulesString(stylesheet);
|
|
510
429
|
}
|
|
511
430
|
if (cssText) {
|
|
512
|
-
delete
|
|
513
|
-
delete
|
|
514
|
-
|
|
431
|
+
delete attributes.rel;
|
|
432
|
+
delete attributes.href;
|
|
433
|
+
attributes._cssText = absoluteToStylesheet(cssText, stylesheet.href);
|
|
515
434
|
}
|
|
516
435
|
}
|
|
517
436
|
if (tagName === 'style' &&
|
|
@@ -519,57 +438,57 @@ function serializeNode(n, options) {
|
|
|
519
438
|
!(n.innerText ||
|
|
520
439
|
n.textContent ||
|
|
521
440
|
'').trim().length) {
|
|
522
|
-
|
|
441
|
+
const cssText = getCssRulesString(n.sheet);
|
|
523
442
|
if (cssText) {
|
|
524
|
-
|
|
443
|
+
attributes._cssText = absoluteToStylesheet(cssText, getHref());
|
|
525
444
|
}
|
|
526
445
|
}
|
|
527
446
|
if (tagName === 'input' ||
|
|
528
447
|
tagName === 'textarea' ||
|
|
529
448
|
tagName === 'select') {
|
|
530
|
-
|
|
531
|
-
if (
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
449
|
+
const value = n.value;
|
|
450
|
+
if (attributes.type !== 'radio' &&
|
|
451
|
+
attributes.type !== 'checkbox' &&
|
|
452
|
+
attributes.type !== 'submit' &&
|
|
453
|
+
attributes.type !== 'button' &&
|
|
535
454
|
value) {
|
|
536
|
-
|
|
455
|
+
attributes.value = maskInputValue({
|
|
537
456
|
input: n,
|
|
538
|
-
type:
|
|
539
|
-
tagName
|
|
540
|
-
value
|
|
541
|
-
maskInputSelector
|
|
542
|
-
unmaskInputSelector
|
|
543
|
-
maskInputOptions
|
|
544
|
-
maskInputFn
|
|
457
|
+
type: attributes.type,
|
|
458
|
+
tagName,
|
|
459
|
+
value,
|
|
460
|
+
maskInputSelector,
|
|
461
|
+
unmaskInputSelector,
|
|
462
|
+
maskInputOptions,
|
|
463
|
+
maskInputFn,
|
|
545
464
|
});
|
|
546
465
|
}
|
|
547
466
|
else if (n.checked) {
|
|
548
|
-
|
|
467
|
+
attributes.checked = n.checked;
|
|
549
468
|
}
|
|
550
469
|
}
|
|
551
470
|
if (tagName === 'option') {
|
|
552
471
|
if (n.selected && !maskInputOptions['select']) {
|
|
553
|
-
|
|
472
|
+
attributes.selected = true;
|
|
554
473
|
}
|
|
555
474
|
else {
|
|
556
|
-
delete
|
|
475
|
+
delete attributes.selected;
|
|
557
476
|
}
|
|
558
477
|
}
|
|
559
478
|
if (tagName === 'canvas' && recordCanvas) {
|
|
560
479
|
if (n.__context === '2d') {
|
|
561
480
|
if (!is2DCanvasBlank(n)) {
|
|
562
|
-
|
|
481
|
+
attributes.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
563
482
|
}
|
|
564
483
|
}
|
|
565
484
|
else if (!('__context' in n)) {
|
|
566
|
-
|
|
567
|
-
|
|
485
|
+
const canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
486
|
+
const blankCanvas = document.createElement('canvas');
|
|
568
487
|
blankCanvas.width = n.width;
|
|
569
488
|
blankCanvas.height = n.height;
|
|
570
|
-
|
|
489
|
+
const blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
571
490
|
if (canvasDataURL !== blankCanvasDataURL) {
|
|
572
|
-
|
|
491
|
+
attributes.rr_dataURL = canvasDataURL;
|
|
573
492
|
}
|
|
574
493
|
}
|
|
575
494
|
}
|
|
@@ -578,68 +497,68 @@ function serializeNode(n, options) {
|
|
|
578
497
|
canvasService = doc.createElement('canvas');
|
|
579
498
|
canvasCtx = canvasService.getContext('2d');
|
|
580
499
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
500
|
+
const image = n;
|
|
501
|
+
const oldValue = image.crossOrigin;
|
|
502
|
+
image.crossOrigin = 'anonymous';
|
|
503
|
+
const recordInlineImage = () => {
|
|
585
504
|
try {
|
|
586
|
-
canvasService.width =
|
|
587
|
-
canvasService.height =
|
|
588
|
-
canvasCtx.drawImage(
|
|
589
|
-
|
|
505
|
+
canvasService.width = image.naturalWidth;
|
|
506
|
+
canvasService.height = image.naturalHeight;
|
|
507
|
+
canvasCtx.drawImage(image, 0, 0);
|
|
508
|
+
attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
590
509
|
}
|
|
591
510
|
catch (err) {
|
|
592
|
-
console.warn(
|
|
511
|
+
console.warn(`Cannot inline img src=${image.currentSrc}! Error: ${err}`);
|
|
593
512
|
}
|
|
594
|
-
|
|
595
|
-
? (
|
|
596
|
-
: delete
|
|
513
|
+
oldValue
|
|
514
|
+
? (attributes.crossOrigin = oldValue)
|
|
515
|
+
: delete attributes.crossOrigin;
|
|
597
516
|
};
|
|
598
|
-
if (
|
|
517
|
+
if (image.complete && image.naturalWidth !== 0)
|
|
599
518
|
recordInlineImage();
|
|
600
519
|
else
|
|
601
|
-
|
|
520
|
+
image.onload = recordInlineImage;
|
|
602
521
|
}
|
|
603
522
|
if (tagName === 'audio' || tagName === 'video') {
|
|
604
|
-
|
|
523
|
+
attributes.rr_mediaState = n.paused
|
|
605
524
|
? 'paused'
|
|
606
525
|
: 'played';
|
|
607
|
-
|
|
526
|
+
attributes.rr_mediaCurrentTime = n.currentTime;
|
|
608
527
|
}
|
|
609
528
|
if (n.scrollLeft) {
|
|
610
|
-
|
|
529
|
+
attributes.rr_scrollLeft = n.scrollLeft;
|
|
611
530
|
}
|
|
612
531
|
if (n.scrollTop) {
|
|
613
|
-
|
|
532
|
+
attributes.rr_scrollTop = n.scrollTop;
|
|
614
533
|
}
|
|
615
534
|
if (needBlock) {
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
rr_width: width
|
|
620
|
-
rr_height: height
|
|
535
|
+
const { width, height } = n.getBoundingClientRect();
|
|
536
|
+
attributes = {
|
|
537
|
+
class: attributes.class,
|
|
538
|
+
rr_width: `${width}px`,
|
|
539
|
+
rr_height: `${height}px`,
|
|
621
540
|
};
|
|
622
541
|
}
|
|
623
|
-
if (tagName === 'iframe' && !keepIframeSrcFn(
|
|
542
|
+
if (tagName === 'iframe' && !keepIframeSrcFn(attributes.src)) {
|
|
624
543
|
if (!n.contentDocument) {
|
|
625
|
-
|
|
544
|
+
attributes.rr_src = attributes.src;
|
|
626
545
|
}
|
|
627
|
-
delete
|
|
546
|
+
delete attributes.src;
|
|
628
547
|
}
|
|
629
548
|
return {
|
|
630
549
|
type: NodeType.Element,
|
|
631
|
-
tagName
|
|
632
|
-
attributes
|
|
550
|
+
tagName,
|
|
551
|
+
attributes,
|
|
633
552
|
childNodes: [],
|
|
634
553
|
isSVG: isSVGElement(n) || undefined,
|
|
635
|
-
needBlock
|
|
636
|
-
rootId
|
|
554
|
+
needBlock,
|
|
555
|
+
rootId,
|
|
637
556
|
};
|
|
638
557
|
case n.TEXT_NODE:
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
558
|
+
const parentTagName = n.parentNode && n.parentNode.tagName;
|
|
559
|
+
let textContent = n.textContent;
|
|
560
|
+
const isStyle = parentTagName === 'STYLE' ? true : undefined;
|
|
561
|
+
const isScript = parentTagName === 'SCRIPT' ? true : undefined;
|
|
643
562
|
if (isStyle && textContent) {
|
|
644
563
|
try {
|
|
645
564
|
if (n.nextSibling || n.previousSibling) {
|
|
@@ -649,7 +568,7 @@ function serializeNode(n, options) {
|
|
|
649
568
|
}
|
|
650
569
|
}
|
|
651
570
|
catch (err) {
|
|
652
|
-
console.warn(
|
|
571
|
+
console.warn(`Cannot get CSS styles from text's parentNode. Error: ${err}`, n);
|
|
653
572
|
}
|
|
654
573
|
textContent = absoluteToStylesheet(textContent, getHref());
|
|
655
574
|
}
|
|
@@ -667,20 +586,20 @@ function serializeNode(n, options) {
|
|
|
667
586
|
return {
|
|
668
587
|
type: NodeType.Text,
|
|
669
588
|
textContent: textContent || '',
|
|
670
|
-
isStyle
|
|
671
|
-
rootId
|
|
589
|
+
isStyle,
|
|
590
|
+
rootId,
|
|
672
591
|
};
|
|
673
592
|
case n.CDATA_SECTION_NODE:
|
|
674
593
|
return {
|
|
675
594
|
type: NodeType.CDATA,
|
|
676
595
|
textContent: '',
|
|
677
|
-
rootId
|
|
596
|
+
rootId,
|
|
678
597
|
};
|
|
679
598
|
case n.COMMENT_NODE:
|
|
680
599
|
return {
|
|
681
600
|
type: NodeType.Comment,
|
|
682
601
|
textContent: n.textContent || '',
|
|
683
|
-
rootId
|
|
602
|
+
rootId,
|
|
684
603
|
};
|
|
685
604
|
default:
|
|
686
605
|
return false;
|
|
@@ -766,32 +685,32 @@ function slimDOMExcluded(sn, slimDOMOptions) {
|
|
|
766
685
|
return false;
|
|
767
686
|
}
|
|
768
687
|
function serializeNodeWithId(n, options) {
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
doc
|
|
773
|
-
blockClass
|
|
774
|
-
blockSelector
|
|
775
|
-
unblockSelector
|
|
776
|
-
maskTextClass
|
|
777
|
-
maskTextSelector
|
|
778
|
-
unmaskTextSelector
|
|
779
|
-
inlineStylesheet
|
|
780
|
-
maskInputSelector
|
|
781
|
-
unmaskInputSelector
|
|
782
|
-
maskInputOptions
|
|
783
|
-
maskTextFn
|
|
784
|
-
maskInputFn
|
|
785
|
-
dataURLOptions
|
|
786
|
-
inlineImages
|
|
787
|
-
recordCanvas
|
|
788
|
-
keepIframeSrcFn
|
|
688
|
+
const { doc, map, blockClass, blockSelector, unblockSelector, maskTextClass, maskTextSelector, unmaskTextSelector, skipChild = false, inlineStylesheet = true, maskInputSelector, unmaskInputSelector, maskInputOptions = {}, maskTextFn, maskInputFn, slimDOMOptions, dataURLOptions = {}, inlineImages = false, recordCanvas = false, onSerialize, onIframeLoad, iframeLoadTimeout = 5000, keepIframeSrcFn = () => false, } = options;
|
|
689
|
+
let { preserveWhiteSpace = true } = options;
|
|
690
|
+
const _serializedNode = serializeNode(n, {
|
|
691
|
+
doc,
|
|
692
|
+
blockClass,
|
|
693
|
+
blockSelector,
|
|
694
|
+
unblockSelector,
|
|
695
|
+
maskTextClass,
|
|
696
|
+
maskTextSelector,
|
|
697
|
+
unmaskTextSelector,
|
|
698
|
+
inlineStylesheet,
|
|
699
|
+
maskInputSelector,
|
|
700
|
+
unmaskInputSelector,
|
|
701
|
+
maskInputOptions,
|
|
702
|
+
maskTextFn,
|
|
703
|
+
maskInputFn,
|
|
704
|
+
dataURLOptions,
|
|
705
|
+
inlineImages,
|
|
706
|
+
recordCanvas,
|
|
707
|
+
keepIframeSrcFn,
|
|
789
708
|
});
|
|
790
709
|
if (!_serializedNode) {
|
|
791
710
|
console.warn(n, 'not serialized');
|
|
792
711
|
return null;
|
|
793
712
|
}
|
|
794
|
-
|
|
713
|
+
let id;
|
|
795
714
|
if ('__sn' in n) {
|
|
796
715
|
id = n.__sn.id;
|
|
797
716
|
}
|
|
@@ -805,7 +724,7 @@ function serializeNodeWithId(n, options) {
|
|
|
805
724
|
else {
|
|
806
725
|
id = genId();
|
|
807
726
|
}
|
|
808
|
-
|
|
727
|
+
const serializedNode = Object.assign(_serializedNode, { id });
|
|
809
728
|
n.__sn = serializedNode;
|
|
810
729
|
if (id === IGNORED_NODE) {
|
|
811
730
|
return null;
|
|
@@ -814,7 +733,7 @@ function serializeNodeWithId(n, options) {
|
|
|
814
733
|
if (onSerialize) {
|
|
815
734
|
onSerialize(n);
|
|
816
735
|
}
|
|
817
|
-
|
|
736
|
+
let recordChild = !skipChild;
|
|
818
737
|
if (serializedNode.type === NodeType.Element) {
|
|
819
738
|
recordChild = recordChild && !serializedNode.needBlock;
|
|
820
739
|
delete serializedNode.needBlock;
|
|
@@ -829,43 +748,41 @@ function serializeNodeWithId(n, options) {
|
|
|
829
748
|
_serializedNode.tagName === 'head') {
|
|
830
749
|
preserveWhiteSpace = false;
|
|
831
750
|
}
|
|
832
|
-
|
|
833
|
-
doc
|
|
834
|
-
map
|
|
835
|
-
blockClass
|
|
836
|
-
blockSelector
|
|
837
|
-
unblockSelector
|
|
838
|
-
maskTextClass
|
|
839
|
-
maskTextSelector
|
|
840
|
-
unmaskTextSelector
|
|
841
|
-
skipChild
|
|
842
|
-
inlineStylesheet
|
|
843
|
-
maskInputSelector
|
|
844
|
-
unmaskInputSelector
|
|
845
|
-
maskInputOptions
|
|
846
|
-
maskTextFn
|
|
847
|
-
maskInputFn
|
|
848
|
-
slimDOMOptions
|
|
849
|
-
dataURLOptions
|
|
850
|
-
inlineImages
|
|
851
|
-
recordCanvas
|
|
852
|
-
preserveWhiteSpace
|
|
853
|
-
onSerialize
|
|
854
|
-
onIframeLoad
|
|
855
|
-
iframeLoadTimeout
|
|
856
|
-
keepIframeSrcFn
|
|
751
|
+
const bypassOptions = {
|
|
752
|
+
doc,
|
|
753
|
+
map,
|
|
754
|
+
blockClass,
|
|
755
|
+
blockSelector,
|
|
756
|
+
unblockSelector,
|
|
757
|
+
maskTextClass,
|
|
758
|
+
maskTextSelector,
|
|
759
|
+
unmaskTextSelector,
|
|
760
|
+
skipChild,
|
|
761
|
+
inlineStylesheet,
|
|
762
|
+
maskInputSelector,
|
|
763
|
+
unmaskInputSelector,
|
|
764
|
+
maskInputOptions,
|
|
765
|
+
maskTextFn,
|
|
766
|
+
maskInputFn,
|
|
767
|
+
slimDOMOptions,
|
|
768
|
+
dataURLOptions,
|
|
769
|
+
inlineImages,
|
|
770
|
+
recordCanvas,
|
|
771
|
+
preserveWhiteSpace,
|
|
772
|
+
onSerialize,
|
|
773
|
+
onIframeLoad,
|
|
774
|
+
iframeLoadTimeout,
|
|
775
|
+
keepIframeSrcFn,
|
|
857
776
|
};
|
|
858
|
-
for (
|
|
859
|
-
|
|
860
|
-
var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
777
|
+
for (const childN of Array.from(n.childNodes)) {
|
|
778
|
+
const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
861
779
|
if (serializedChildNode) {
|
|
862
780
|
serializedNode.childNodes.push(serializedChildNode);
|
|
863
781
|
}
|
|
864
782
|
}
|
|
865
783
|
if (isElement(n) && n.shadowRoot) {
|
|
866
|
-
for (
|
|
867
|
-
|
|
868
|
-
var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
784
|
+
for (const childN of Array.from(n.shadowRoot.childNodes)) {
|
|
785
|
+
const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
869
786
|
if (serializedChildNode) {
|
|
870
787
|
serializedChildNode.isShadow = true;
|
|
871
788
|
serializedNode.childNodes.push(serializedChildNode);
|
|
@@ -878,34 +795,34 @@ function serializeNodeWithId(n, options) {
|
|
|
878
795
|
}
|
|
879
796
|
if (serializedNode.type === NodeType.Element &&
|
|
880
797
|
serializedNode.tagName === 'iframe') {
|
|
881
|
-
onceIframeLoaded(n,
|
|
882
|
-
|
|
798
|
+
onceIframeLoaded(n, () => {
|
|
799
|
+
const iframeDoc = n.contentDocument;
|
|
883
800
|
if (iframeDoc && onIframeLoad) {
|
|
884
|
-
|
|
801
|
+
const serializedIframeNode = serializeNodeWithId(iframeDoc, {
|
|
885
802
|
doc: iframeDoc,
|
|
886
|
-
map
|
|
887
|
-
blockClass
|
|
888
|
-
blockSelector
|
|
889
|
-
unblockSelector
|
|
890
|
-
maskTextClass
|
|
891
|
-
maskTextSelector
|
|
892
|
-
unmaskTextSelector
|
|
803
|
+
map,
|
|
804
|
+
blockClass,
|
|
805
|
+
blockSelector,
|
|
806
|
+
unblockSelector,
|
|
807
|
+
maskTextClass,
|
|
808
|
+
maskTextSelector,
|
|
809
|
+
unmaskTextSelector,
|
|
893
810
|
skipChild: false,
|
|
894
|
-
inlineStylesheet
|
|
895
|
-
maskInputSelector
|
|
896
|
-
unmaskInputSelector
|
|
897
|
-
maskInputOptions
|
|
898
|
-
maskTextFn
|
|
899
|
-
maskInputFn
|
|
900
|
-
slimDOMOptions
|
|
901
|
-
dataURLOptions
|
|
902
|
-
inlineImages
|
|
903
|
-
recordCanvas
|
|
904
|
-
preserveWhiteSpace
|
|
905
|
-
onSerialize
|
|
906
|
-
onIframeLoad
|
|
907
|
-
iframeLoadTimeout
|
|
908
|
-
keepIframeSrcFn
|
|
811
|
+
inlineStylesheet,
|
|
812
|
+
maskInputSelector,
|
|
813
|
+
unmaskInputSelector,
|
|
814
|
+
maskInputOptions,
|
|
815
|
+
maskTextFn,
|
|
816
|
+
maskInputFn,
|
|
817
|
+
slimDOMOptions,
|
|
818
|
+
dataURLOptions,
|
|
819
|
+
inlineImages,
|
|
820
|
+
recordCanvas,
|
|
821
|
+
preserveWhiteSpace,
|
|
822
|
+
onSerialize,
|
|
823
|
+
onIframeLoad,
|
|
824
|
+
iframeLoadTimeout,
|
|
825
|
+
keepIframeSrcFn,
|
|
909
826
|
});
|
|
910
827
|
if (serializedIframeNode) {
|
|
911
828
|
onIframeLoad(n, serializedIframeNode);
|
|
@@ -916,9 +833,9 @@ function serializeNodeWithId(n, options) {
|
|
|
916
833
|
return serializedNode;
|
|
917
834
|
}
|
|
918
835
|
function snapshot(n, options) {
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
836
|
+
const { blockClass = 'rr-block', blockSelector = null, unblockSelector = null, maskTextClass = 'rr-mask', maskTextSelector = null, unmaskTextSelector = null, inlineStylesheet = true, inlineImages = false, recordCanvas = false, maskInputSelector = null, unmaskInputSelector = null, maskAllInputs = false, maskTextFn, maskInputFn, slimDOM = false, dataURLOptions, preserveWhiteSpace, onSerialize, onIframeLoad, iframeLoadTimeout, keepIframeSrcFn = () => false, } = options || {};
|
|
837
|
+
const idNodeMap = {};
|
|
838
|
+
const maskInputOptions = maskAllInputs === true
|
|
922
839
|
? {
|
|
923
840
|
color: true,
|
|
924
841
|
date: true,
|
|
@@ -935,14 +852,14 @@ function snapshot(n, options) {
|
|
|
935
852
|
week: true,
|
|
936
853
|
textarea: true,
|
|
937
854
|
select: true,
|
|
938
|
-
password: true
|
|
855
|
+
password: true,
|
|
939
856
|
}
|
|
940
857
|
: maskAllInputs === false
|
|
941
858
|
? {
|
|
942
|
-
password: true
|
|
859
|
+
password: true,
|
|
943
860
|
}
|
|
944
861
|
: maskAllInputs;
|
|
945
|
-
|
|
862
|
+
const slimDOMOptions = slimDOM === true || slimDOM === 'all'
|
|
946
863
|
?
|
|
947
864
|
{
|
|
948
865
|
script: true,
|
|
@@ -954,7 +871,7 @@ function snapshot(n, options) {
|
|
|
954
871
|
headMetaRobots: true,
|
|
955
872
|
headMetaHttpEquiv: true,
|
|
956
873
|
headMetaAuthorship: true,
|
|
957
|
-
headMetaVerification: true
|
|
874
|
+
headMetaVerification: true,
|
|
958
875
|
}
|
|
959
876
|
: slimDOM === false
|
|
960
877
|
? {}
|
|
@@ -963,28 +880,28 @@ function snapshot(n, options) {
|
|
|
963
880
|
serializeNodeWithId(n, {
|
|
964
881
|
doc: n,
|
|
965
882
|
map: idNodeMap,
|
|
966
|
-
blockClass
|
|
967
|
-
blockSelector
|
|
968
|
-
unblockSelector
|
|
969
|
-
maskTextClass
|
|
970
|
-
maskTextSelector
|
|
971
|
-
unmaskTextSelector
|
|
883
|
+
blockClass,
|
|
884
|
+
blockSelector,
|
|
885
|
+
unblockSelector,
|
|
886
|
+
maskTextClass,
|
|
887
|
+
maskTextSelector,
|
|
888
|
+
unmaskTextSelector,
|
|
972
889
|
skipChild: false,
|
|
973
|
-
inlineStylesheet
|
|
974
|
-
maskInputSelector
|
|
975
|
-
unmaskInputSelector
|
|
976
|
-
maskInputOptions
|
|
977
|
-
maskTextFn
|
|
978
|
-
maskInputFn
|
|
979
|
-
slimDOMOptions
|
|
980
|
-
dataURLOptions
|
|
981
|
-
inlineImages
|
|
982
|
-
recordCanvas
|
|
983
|
-
preserveWhiteSpace
|
|
984
|
-
onSerialize
|
|
985
|
-
onIframeLoad
|
|
986
|
-
iframeLoadTimeout
|
|
987
|
-
keepIframeSrcFn
|
|
890
|
+
inlineStylesheet,
|
|
891
|
+
maskInputSelector,
|
|
892
|
+
unmaskInputSelector,
|
|
893
|
+
maskInputOptions,
|
|
894
|
+
maskTextFn,
|
|
895
|
+
maskInputFn,
|
|
896
|
+
slimDOMOptions,
|
|
897
|
+
dataURLOptions,
|
|
898
|
+
inlineImages,
|
|
899
|
+
recordCanvas,
|
|
900
|
+
preserveWhiteSpace,
|
|
901
|
+
onSerialize,
|
|
902
|
+
onIframeLoad,
|
|
903
|
+
iframeLoadTimeout,
|
|
904
|
+
keepIframeSrcFn,
|
|
988
905
|
}),
|
|
989
906
|
idNodeMap,
|
|
990
907
|
];
|
|
@@ -1064,71 +981,67 @@ var ReplayerEvents;
|
|
|
1064
981
|
ReplayerEvents["PlayBack"] = "play-back";
|
|
1065
982
|
})(ReplayerEvents || (ReplayerEvents = {}));
|
|
1066
983
|
|
|
1067
|
-
function on(type, fn, target) {
|
|
1068
|
-
|
|
1069
|
-
var options = { capture: true, passive: true };
|
|
984
|
+
function on(type, fn, target = document) {
|
|
985
|
+
const options = { capture: true, passive: true };
|
|
1070
986
|
target.addEventListener(type, fn, options);
|
|
1071
|
-
return
|
|
987
|
+
return () => target.removeEventListener(type, fn, options);
|
|
1072
988
|
}
|
|
1073
989
|
function createMirror() {
|
|
1074
990
|
return {
|
|
1075
991
|
map: {},
|
|
1076
|
-
getId
|
|
992
|
+
getId(n) {
|
|
1077
993
|
if (!n || !n.__sn) {
|
|
1078
994
|
return -1;
|
|
1079
995
|
}
|
|
1080
996
|
return n.__sn.id;
|
|
1081
997
|
},
|
|
1082
|
-
getNode
|
|
998
|
+
getNode(id) {
|
|
1083
999
|
return this.map[id] || null;
|
|
1084
1000
|
},
|
|
1085
|
-
removeNodeFromMap
|
|
1086
|
-
|
|
1087
|
-
var id = n.__sn && n.__sn.id;
|
|
1001
|
+
removeNodeFromMap(n) {
|
|
1002
|
+
const id = n.__sn && n.__sn.id;
|
|
1088
1003
|
delete this.map[id];
|
|
1089
1004
|
if (n.childNodes) {
|
|
1090
|
-
n.childNodes.forEach(
|
|
1091
|
-
return _this.removeNodeFromMap(child);
|
|
1092
|
-
});
|
|
1005
|
+
n.childNodes.forEach((child) => this.removeNodeFromMap(child));
|
|
1093
1006
|
}
|
|
1094
1007
|
},
|
|
1095
|
-
has
|
|
1008
|
+
has(id) {
|
|
1096
1009
|
return this.map.hasOwnProperty(id);
|
|
1097
1010
|
},
|
|
1098
|
-
reset
|
|
1011
|
+
reset() {
|
|
1099
1012
|
this.map = {};
|
|
1100
1013
|
},
|
|
1101
1014
|
};
|
|
1102
1015
|
}
|
|
1103
|
-
|
|
1016
|
+
const DEPARTED_MIRROR_ACCESS_WARNING = 'Please stop import mirror directly. Instead of that,' +
|
|
1104
1017
|
'\r\n' +
|
|
1105
1018
|
'now you can use replayer.getMirror() to access the mirror instance of a replayer,' +
|
|
1106
1019
|
'\r\n' +
|
|
1107
1020
|
'or you can use record.mirror to access the mirror instance during recording.';
|
|
1108
|
-
|
|
1021
|
+
let _mirror = {
|
|
1109
1022
|
map: {},
|
|
1110
|
-
getId
|
|
1023
|
+
getId() {
|
|
1111
1024
|
console.error(DEPARTED_MIRROR_ACCESS_WARNING);
|
|
1112
1025
|
return -1;
|
|
1113
1026
|
},
|
|
1114
|
-
getNode
|
|
1027
|
+
getNode() {
|
|
1115
1028
|
console.error(DEPARTED_MIRROR_ACCESS_WARNING);
|
|
1116
1029
|
return null;
|
|
1117
1030
|
},
|
|
1118
|
-
removeNodeFromMap
|
|
1031
|
+
removeNodeFromMap() {
|
|
1119
1032
|
console.error(DEPARTED_MIRROR_ACCESS_WARNING);
|
|
1120
1033
|
},
|
|
1121
|
-
has
|
|
1034
|
+
has() {
|
|
1122
1035
|
console.error(DEPARTED_MIRROR_ACCESS_WARNING);
|
|
1123
1036
|
return false;
|
|
1124
1037
|
},
|
|
1125
|
-
reset
|
|
1038
|
+
reset() {
|
|
1126
1039
|
console.error(DEPARTED_MIRROR_ACCESS_WARNING);
|
|
1127
1040
|
},
|
|
1128
1041
|
};
|
|
1129
1042
|
if (typeof window !== 'undefined' && window.Proxy && window.Reflect) {
|
|
1130
1043
|
_mirror = new Proxy(_mirror, {
|
|
1131
|
-
get
|
|
1044
|
+
get(target, prop, receiver) {
|
|
1132
1045
|
if (prop === 'map') {
|
|
1133
1046
|
console.error(DEPARTED_MIRROR_ACCESS_WARNING);
|
|
1134
1047
|
}
|
|
@@ -1136,18 +1049,17 @@ if (typeof window !== 'undefined' && window.Proxy && window.Reflect) {
|
|
|
1136
1049
|
},
|
|
1137
1050
|
});
|
|
1138
1051
|
}
|
|
1139
|
-
function throttle(func, wait, options) {
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
var previous = 0;
|
|
1052
|
+
function throttle(func, wait, options = {}) {
|
|
1053
|
+
let timeout = null;
|
|
1054
|
+
let previous = 0;
|
|
1143
1055
|
return function (arg) {
|
|
1144
|
-
|
|
1056
|
+
let now = Date.now();
|
|
1145
1057
|
if (!previous && options.leading === false) {
|
|
1146
1058
|
previous = now;
|
|
1147
1059
|
}
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1060
|
+
let remaining = wait - (now - previous);
|
|
1061
|
+
let context = this;
|
|
1062
|
+
let args = arguments;
|
|
1151
1063
|
if (remaining <= 0 || remaining > wait) {
|
|
1152
1064
|
if (timeout) {
|
|
1153
1065
|
clearTimeout(timeout);
|
|
@@ -1157,7 +1069,7 @@ function throttle(func, wait, options) {
|
|
|
1157
1069
|
func.apply(context, args);
|
|
1158
1070
|
}
|
|
1159
1071
|
else if (!timeout && options.trailing !== false) {
|
|
1160
|
-
timeout = setTimeout(
|
|
1072
|
+
timeout = setTimeout(() => {
|
|
1161
1073
|
previous = options.leading === false ? 0 : Date.now();
|
|
1162
1074
|
timeout = null;
|
|
1163
1075
|
func.apply(context, args);
|
|
@@ -1165,47 +1077,45 @@ function throttle(func, wait, options) {
|
|
|
1165
1077
|
}
|
|
1166
1078
|
};
|
|
1167
1079
|
}
|
|
1168
|
-
function hookSetter(target, key, d, isRevoked, win) {
|
|
1169
|
-
|
|
1170
|
-
var original = win.Object.getOwnPropertyDescriptor(target, key);
|
|
1080
|
+
function hookSetter(target, key, d, isRevoked, win = window) {
|
|
1081
|
+
const original = win.Object.getOwnPropertyDescriptor(target, key);
|
|
1171
1082
|
win.Object.defineProperty(target, key, isRevoked
|
|
1172
1083
|
? d
|
|
1173
1084
|
: {
|
|
1174
|
-
set
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
d.set.call(_this, value);
|
|
1085
|
+
set(value) {
|
|
1086
|
+
setTimeout(() => {
|
|
1087
|
+
d.set.call(this, value);
|
|
1178
1088
|
}, 0);
|
|
1179
1089
|
if (original && original.set) {
|
|
1180
1090
|
original.set.call(this, value);
|
|
1181
1091
|
}
|
|
1182
1092
|
},
|
|
1183
1093
|
});
|
|
1184
|
-
return
|
|
1094
|
+
return () => hookSetter(target, key, original || {}, true);
|
|
1185
1095
|
}
|
|
1186
1096
|
function patch(source, name, replacement) {
|
|
1187
1097
|
try {
|
|
1188
1098
|
if (!(name in source)) {
|
|
1189
|
-
return
|
|
1099
|
+
return () => { };
|
|
1190
1100
|
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1101
|
+
const original = source[name];
|
|
1102
|
+
const wrapped = replacement(original);
|
|
1193
1103
|
if (typeof wrapped === 'function') {
|
|
1194
1104
|
wrapped.prototype = wrapped.prototype || {};
|
|
1195
1105
|
Object.defineProperties(wrapped, {
|
|
1196
1106
|
__rrweb_original__: {
|
|
1197
1107
|
enumerable: false,
|
|
1198
|
-
value:
|
|
1108
|
+
value: original,
|
|
1199
1109
|
},
|
|
1200
1110
|
});
|
|
1201
1111
|
}
|
|
1202
1112
|
source[name] = wrapped;
|
|
1203
|
-
return
|
|
1204
|
-
source[name] =
|
|
1113
|
+
return () => {
|
|
1114
|
+
source[name] = original;
|
|
1205
1115
|
};
|
|
1206
1116
|
}
|
|
1207
1117
|
catch (_a) {
|
|
1208
|
-
return
|
|
1118
|
+
return () => { };
|
|
1209
1119
|
}
|
|
1210
1120
|
}
|
|
1211
1121
|
function getWindowHeight() {
|
|
@@ -1223,23 +1133,23 @@ function isBlocked(node, blockClass) {
|
|
|
1223
1133
|
return false;
|
|
1224
1134
|
}
|
|
1225
1135
|
if (node.nodeType === node.ELEMENT_NODE) {
|
|
1226
|
-
|
|
1136
|
+
let needBlock = false;
|
|
1227
1137
|
if (typeof blockClass === 'string') {
|
|
1228
1138
|
if (node.closest !== undefined) {
|
|
1229
1139
|
return node.closest('.' + blockClass) !== null;
|
|
1230
1140
|
}
|
|
1231
1141
|
else {
|
|
1232
|
-
|
|
1142
|
+
needBlock = node.classList.contains(blockClass);
|
|
1233
1143
|
}
|
|
1234
1144
|
}
|
|
1235
1145
|
else {
|
|
1236
|
-
node.classList.forEach(
|
|
1146
|
+
node.classList.forEach((className) => {
|
|
1237
1147
|
if (blockClass.test(className)) {
|
|
1238
|
-
|
|
1148
|
+
needBlock = true;
|
|
1239
1149
|
}
|
|
1240
1150
|
});
|
|
1241
1151
|
}
|
|
1242
|
-
return
|
|
1152
|
+
return needBlock || isBlocked(node.parentNode, blockClass);
|
|
1243
1153
|
}
|
|
1244
1154
|
if (node.nodeType === node.TEXT_NODE) {
|
|
1245
1155
|
return isBlocked(node.parentNode, blockClass);
|
|
@@ -1256,7 +1166,7 @@ function isAncestorRemoved(target, mirror) {
|
|
|
1256
1166
|
if (isShadowRoot(target)) {
|
|
1257
1167
|
return false;
|
|
1258
1168
|
}
|
|
1259
|
-
|
|
1169
|
+
const id = mirror.getId(target);
|
|
1260
1170
|
if (!mirror.has(id)) {
|
|
1261
1171
|
return true;
|
|
1262
1172
|
}
|
|
@@ -1272,8 +1182,7 @@ function isAncestorRemoved(target, mirror) {
|
|
|
1272
1182
|
function isTouchEvent(event) {
|
|
1273
1183
|
return Boolean(event.changedTouches);
|
|
1274
1184
|
}
|
|
1275
|
-
function polyfill(win) {
|
|
1276
|
-
if (win === void 0) { win = window; }
|
|
1185
|
+
function polyfill(win = window) {
|
|
1277
1186
|
if ('NodeList' in win && !win.NodeList.prototype.forEach) {
|
|
1278
1187
|
win.NodeList.prototype.forEach = Array.prototype
|
|
1279
1188
|
.forEach;
|
|
@@ -1309,30 +1218,30 @@ function hasShadowRoot(n) {
|
|
|
1309
1218
|
function isNodeInLinkedList(n) {
|
|
1310
1219
|
return '__ln' in n;
|
|
1311
1220
|
}
|
|
1312
|
-
|
|
1313
|
-
|
|
1221
|
+
class DoubleLinkedList {
|
|
1222
|
+
constructor() {
|
|
1314
1223
|
this.length = 0;
|
|
1315
1224
|
this.head = null;
|
|
1316
1225
|
}
|
|
1317
|
-
|
|
1226
|
+
get(position) {
|
|
1318
1227
|
if (position >= this.length) {
|
|
1319
1228
|
throw new Error('Position outside of list range');
|
|
1320
1229
|
}
|
|
1321
|
-
|
|
1322
|
-
for (
|
|
1230
|
+
let current = this.head;
|
|
1231
|
+
for (let index = 0; index < position; index++) {
|
|
1323
1232
|
current = (current === null || current === void 0 ? void 0 : current.next) || null;
|
|
1324
1233
|
}
|
|
1325
1234
|
return current;
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
|
|
1235
|
+
}
|
|
1236
|
+
addNode(n) {
|
|
1237
|
+
const node = {
|
|
1329
1238
|
value: n,
|
|
1330
1239
|
previous: null,
|
|
1331
1240
|
next: null,
|
|
1332
1241
|
};
|
|
1333
1242
|
n.__ln = node;
|
|
1334
1243
|
if (n.previousSibling && isNodeInLinkedList(n.previousSibling)) {
|
|
1335
|
-
|
|
1244
|
+
const current = n.previousSibling.__ln.next;
|
|
1336
1245
|
node.next = current;
|
|
1337
1246
|
node.previous = n.previousSibling.__ln;
|
|
1338
1247
|
n.previousSibling.__ln.next = node;
|
|
@@ -1343,7 +1252,7 @@ var DoubleLinkedList = (function () {
|
|
|
1343
1252
|
else if (n.nextSibling &&
|
|
1344
1253
|
isNodeInLinkedList(n.nextSibling) &&
|
|
1345
1254
|
n.nextSibling.__ln.previous) {
|
|
1346
|
-
|
|
1255
|
+
const current = n.nextSibling.__ln.previous;
|
|
1347
1256
|
node.previous = current;
|
|
1348
1257
|
node.next = n.nextSibling.__ln;
|
|
1349
1258
|
n.nextSibling.__ln.previous = node;
|
|
@@ -1359,9 +1268,9 @@ var DoubleLinkedList = (function () {
|
|
|
1359
1268
|
this.head = node;
|
|
1360
1269
|
}
|
|
1361
1270
|
this.length++;
|
|
1362
|
-
}
|
|
1363
|
-
|
|
1364
|
-
|
|
1271
|
+
}
|
|
1272
|
+
removeNode(n) {
|
|
1273
|
+
const current = n.__ln;
|
|
1365
1274
|
if (!this.head) {
|
|
1366
1275
|
return;
|
|
1367
1276
|
}
|
|
@@ -1381,16 +1290,14 @@ var DoubleLinkedList = (function () {
|
|
|
1381
1290
|
delete n.__ln;
|
|
1382
1291
|
}
|
|
1383
1292
|
this.length--;
|
|
1384
|
-
}
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
var moveKey = function (id, parentId) { return "".concat(id, "@").concat(parentId); };
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
const moveKey = (id, parentId) => `${id}@${parentId}`;
|
|
1388
1296
|
function isINode(n) {
|
|
1389
1297
|
return '__sn' in n;
|
|
1390
1298
|
}
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
var _this = this;
|
|
1299
|
+
class MutationBuffer {
|
|
1300
|
+
constructor() {
|
|
1394
1301
|
this.frozen = false;
|
|
1395
1302
|
this.locked = false;
|
|
1396
1303
|
this.texts = [];
|
|
@@ -1401,146 +1308,125 @@ var MutationBuffer = (function () {
|
|
|
1401
1308
|
this.addedSet = new Set();
|
|
1402
1309
|
this.movedSet = new Set();
|
|
1403
1310
|
this.droppedSet = new Set();
|
|
1404
|
-
this.processMutations =
|
|
1405
|
-
mutations.forEach(
|
|
1406
|
-
|
|
1311
|
+
this.processMutations = (mutations) => {
|
|
1312
|
+
mutations.forEach(this.processMutation);
|
|
1313
|
+
this.emit();
|
|
1407
1314
|
};
|
|
1408
|
-
this.emit =
|
|
1409
|
-
|
|
1410
|
-
if (_this.frozen || _this.locked) {
|
|
1315
|
+
this.emit = () => {
|
|
1316
|
+
if (this.frozen || this.locked) {
|
|
1411
1317
|
return;
|
|
1412
1318
|
}
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1319
|
+
const adds = [];
|
|
1320
|
+
const addList = new DoubleLinkedList();
|
|
1321
|
+
const getNextId = (n) => {
|
|
1322
|
+
let ns = n;
|
|
1323
|
+
let nextId = IGNORED_NODE;
|
|
1418
1324
|
while (nextId === IGNORED_NODE) {
|
|
1419
1325
|
ns = ns && ns.nextSibling;
|
|
1420
|
-
nextId = ns &&
|
|
1326
|
+
nextId = ns && this.mirror.getId(ns);
|
|
1421
1327
|
}
|
|
1422
1328
|
return nextId;
|
|
1423
1329
|
};
|
|
1424
|
-
|
|
1330
|
+
const pushAdd = (n) => {
|
|
1425
1331
|
var _a, _b, _c, _d, _e;
|
|
1426
|
-
|
|
1332
|
+
const shadowHost = n.getRootNode
|
|
1427
1333
|
? (_a = n.getRootNode()) === null || _a === void 0 ? void 0 : _a.host
|
|
1428
1334
|
: null;
|
|
1429
|
-
|
|
1335
|
+
let rootShadowHost = shadowHost;
|
|
1430
1336
|
while ((_c = (_b = rootShadowHost === null || rootShadowHost === void 0 ? void 0 : rootShadowHost.getRootNode) === null || _b === void 0 ? void 0 : _b.call(rootShadowHost)) === null || _c === void 0 ? void 0 : _c.host)
|
|
1431
1337
|
rootShadowHost =
|
|
1432
1338
|
((_e = (_d = rootShadowHost === null || rootShadowHost === void 0 ? void 0 : rootShadowHost.getRootNode) === null || _d === void 0 ? void 0 : _d.call(rootShadowHost)) === null || _e === void 0 ? void 0 : _e.host) ||
|
|
1433
1339
|
null;
|
|
1434
|
-
|
|
1435
|
-
(rootShadowHost === null || !
|
|
1340
|
+
const notInDoc = !this.doc.contains(n) &&
|
|
1341
|
+
(rootShadowHost === null || !this.doc.contains(rootShadowHost));
|
|
1436
1342
|
if (!n.parentNode || notInDoc) {
|
|
1437
1343
|
return;
|
|
1438
1344
|
}
|
|
1439
|
-
|
|
1440
|
-
?
|
|
1441
|
-
:
|
|
1442
|
-
|
|
1345
|
+
const parentId = isShadowRoot(n.parentNode)
|
|
1346
|
+
? this.mirror.getId(shadowHost)
|
|
1347
|
+
: this.mirror.getId(n.parentNode);
|
|
1348
|
+
const nextId = getNextId(n);
|
|
1443
1349
|
if (parentId === -1 || nextId === -1) {
|
|
1444
1350
|
return addList.addNode(n);
|
|
1445
1351
|
}
|
|
1446
|
-
|
|
1447
|
-
doc:
|
|
1448
|
-
map:
|
|
1449
|
-
blockClass:
|
|
1450
|
-
blockSelector:
|
|
1451
|
-
unblockSelector:
|
|
1452
|
-
maskTextClass:
|
|
1453
|
-
maskTextSelector:
|
|
1454
|
-
unmaskTextSelector:
|
|
1455
|
-
maskInputSelector:
|
|
1456
|
-
unmaskInputSelector:
|
|
1352
|
+
let sn = serializeNodeWithId(n, {
|
|
1353
|
+
doc: this.doc,
|
|
1354
|
+
map: this.mirror.map,
|
|
1355
|
+
blockClass: this.blockClass,
|
|
1356
|
+
blockSelector: this.blockSelector,
|
|
1357
|
+
unblockSelector: this.unblockSelector,
|
|
1358
|
+
maskTextClass: this.maskTextClass,
|
|
1359
|
+
maskTextSelector: this.maskTextSelector,
|
|
1360
|
+
unmaskTextSelector: this.unmaskTextSelector,
|
|
1361
|
+
maskInputSelector: this.maskInputSelector,
|
|
1362
|
+
unmaskInputSelector: this.unmaskInputSelector,
|
|
1457
1363
|
skipChild: true,
|
|
1458
|
-
inlineStylesheet:
|
|
1459
|
-
maskInputOptions:
|
|
1460
|
-
maskTextFn:
|
|
1461
|
-
maskInputFn:
|
|
1462
|
-
slimDOMOptions:
|
|
1463
|
-
recordCanvas:
|
|
1464
|
-
inlineImages:
|
|
1465
|
-
onSerialize:
|
|
1364
|
+
inlineStylesheet: this.inlineStylesheet,
|
|
1365
|
+
maskInputOptions: this.maskInputOptions,
|
|
1366
|
+
maskTextFn: this.maskTextFn,
|
|
1367
|
+
maskInputFn: this.maskInputFn,
|
|
1368
|
+
slimDOMOptions: this.slimDOMOptions,
|
|
1369
|
+
recordCanvas: this.recordCanvas,
|
|
1370
|
+
inlineImages: this.inlineImages,
|
|
1371
|
+
onSerialize: (currentN) => {
|
|
1466
1372
|
if (isIframeINode(currentN)) {
|
|
1467
|
-
|
|
1373
|
+
this.iframeManager.addIframe(currentN);
|
|
1468
1374
|
}
|
|
1469
1375
|
if (hasShadowRoot(n)) {
|
|
1470
|
-
|
|
1376
|
+
this.shadowDomManager.addShadowRoot(n.shadowRoot, document);
|
|
1471
1377
|
}
|
|
1472
1378
|
},
|
|
1473
|
-
onIframeLoad:
|
|
1474
|
-
|
|
1475
|
-
|
|
1379
|
+
onIframeLoad: (iframe, childSn) => {
|
|
1380
|
+
this.iframeManager.attachIframe(iframe, childSn);
|
|
1381
|
+
this.shadowDomManager.observeAttachShadow(iframe);
|
|
1476
1382
|
},
|
|
1477
1383
|
});
|
|
1478
1384
|
if (sn) {
|
|
1479
1385
|
adds.push({
|
|
1480
|
-
parentId
|
|
1481
|
-
nextId
|
|
1386
|
+
parentId,
|
|
1387
|
+
nextId,
|
|
1482
1388
|
node: sn,
|
|
1483
1389
|
});
|
|
1484
1390
|
}
|
|
1485
1391
|
};
|
|
1486
|
-
while (
|
|
1487
|
-
|
|
1392
|
+
while (this.mapRemoves.length) {
|
|
1393
|
+
this.mirror.removeNodeFromMap(this.mapRemoves.shift());
|
|
1488
1394
|
}
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
!_this.movedSet.has(n.parentNode)) {
|
|
1494
|
-
continue;
|
|
1495
|
-
}
|
|
1496
|
-
pushAdd(n);
|
|
1395
|
+
for (const n of this.movedSet) {
|
|
1396
|
+
if (isParentRemoved(this.removes, n, this.mirror) &&
|
|
1397
|
+
!this.movedSet.has(n.parentNode)) {
|
|
1398
|
+
continue;
|
|
1497
1399
|
}
|
|
1400
|
+
pushAdd(n);
|
|
1498
1401
|
}
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1402
|
+
for (const n of this.addedSet) {
|
|
1403
|
+
if (!isAncestorInSet(this.droppedSet, n) &&
|
|
1404
|
+
!isParentRemoved(this.removes, n, this.mirror)) {
|
|
1405
|
+
pushAdd(n);
|
|
1503
1406
|
}
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
try {
|
|
1507
|
-
for (var _e = __values(_this.addedSet), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
1508
|
-
var n = _f.value;
|
|
1509
|
-
if (!isAncestorInSet(_this.droppedSet, n) &&
|
|
1510
|
-
!isParentRemoved(_this.removes, n, _this.mirror)) {
|
|
1511
|
-
pushAdd(n);
|
|
1512
|
-
}
|
|
1513
|
-
else if (isAncestorInSet(_this.movedSet, n)) {
|
|
1514
|
-
pushAdd(n);
|
|
1515
|
-
}
|
|
1516
|
-
else {
|
|
1517
|
-
_this.droppedSet.add(n);
|
|
1518
|
-
}
|
|
1407
|
+
else if (isAncestorInSet(this.movedSet, n)) {
|
|
1408
|
+
pushAdd(n);
|
|
1519
1409
|
}
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
finally {
|
|
1523
|
-
try {
|
|
1524
|
-
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
1410
|
+
else {
|
|
1411
|
+
this.droppedSet.add(n);
|
|
1525
1412
|
}
|
|
1526
|
-
finally { if (e_2) throw e_2.error; }
|
|
1527
1413
|
}
|
|
1528
|
-
|
|
1414
|
+
let candidate = null;
|
|
1529
1415
|
while (addList.length) {
|
|
1530
|
-
|
|
1416
|
+
let node = null;
|
|
1531
1417
|
if (candidate) {
|
|
1532
|
-
|
|
1533
|
-
|
|
1418
|
+
const parentId = this.mirror.getId(candidate.value.parentNode);
|
|
1419
|
+
const nextId = getNextId(candidate.value);
|
|
1534
1420
|
if (parentId !== -1 && nextId !== -1) {
|
|
1535
1421
|
node = candidate;
|
|
1536
1422
|
}
|
|
1537
1423
|
}
|
|
1538
1424
|
if (!node) {
|
|
1539
|
-
for (
|
|
1540
|
-
|
|
1425
|
+
for (let index = addList.length - 1; index >= 0; index--) {
|
|
1426
|
+
const _node = addList.get(index);
|
|
1541
1427
|
if (_node) {
|
|
1542
|
-
|
|
1543
|
-
|
|
1428
|
+
const parentId = this.mirror.getId(_node.value.parentNode);
|
|
1429
|
+
const nextId = getNextId(_node.value);
|
|
1544
1430
|
if (parentId !== -1 && nextId !== -1) {
|
|
1545
1431
|
node = _node;
|
|
1546
1432
|
break;
|
|
@@ -1558,21 +1444,21 @@ var MutationBuffer = (function () {
|
|
|
1558
1444
|
addList.removeNode(node.value);
|
|
1559
1445
|
pushAdd(node.value);
|
|
1560
1446
|
}
|
|
1561
|
-
|
|
1562
|
-
texts:
|
|
1563
|
-
.map(
|
|
1564
|
-
id:
|
|
1447
|
+
const payload = {
|
|
1448
|
+
texts: this.texts
|
|
1449
|
+
.map((text) => ({
|
|
1450
|
+
id: this.mirror.getId(text.node),
|
|
1565
1451
|
value: text.value,
|
|
1566
|
-
})
|
|
1567
|
-
.filter(
|
|
1568
|
-
attributes:
|
|
1569
|
-
.map(
|
|
1570
|
-
id:
|
|
1452
|
+
}))
|
|
1453
|
+
.filter((text) => this.mirror.has(text.id)),
|
|
1454
|
+
attributes: this.attributes
|
|
1455
|
+
.map((attribute) => ({
|
|
1456
|
+
id: this.mirror.getId(attribute.node),
|
|
1571
1457
|
attributes: attribute.attributes,
|
|
1572
|
-
})
|
|
1573
|
-
.filter(
|
|
1574
|
-
removes:
|
|
1575
|
-
adds
|
|
1458
|
+
}))
|
|
1459
|
+
.filter((attribute) => this.mirror.has(attribute.id)),
|
|
1460
|
+
removes: this.removes,
|
|
1461
|
+
adds,
|
|
1576
1462
|
};
|
|
1577
1463
|
if (!payload.texts.length &&
|
|
1578
1464
|
!payload.attributes.length &&
|
|
@@ -1580,28 +1466,27 @@ var MutationBuffer = (function () {
|
|
|
1580
1466
|
!payload.adds.length) {
|
|
1581
1467
|
return;
|
|
1582
1468
|
}
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1469
|
+
this.texts = [];
|
|
1470
|
+
this.attributes = [];
|
|
1471
|
+
this.removes = [];
|
|
1472
|
+
this.addedSet = new Set();
|
|
1473
|
+
this.movedSet = new Set();
|
|
1474
|
+
this.droppedSet = new Set();
|
|
1475
|
+
this.movedMap = {};
|
|
1476
|
+
this.mutationCb(payload);
|
|
1591
1477
|
};
|
|
1592
|
-
this.processMutation =
|
|
1593
|
-
var e_3, _a, e_4, _b;
|
|
1478
|
+
this.processMutation = (m) => {
|
|
1594
1479
|
if (isIgnored(m.target)) {
|
|
1595
1480
|
return;
|
|
1596
1481
|
}
|
|
1597
1482
|
switch (m.type) {
|
|
1598
1483
|
case 'characterData': {
|
|
1599
|
-
|
|
1600
|
-
if (!isBlocked(m.target,
|
|
1601
|
-
|
|
1602
|
-
value: needMaskingText(m.target,
|
|
1603
|
-
?
|
|
1604
|
-
?
|
|
1484
|
+
const value = m.target.textContent;
|
|
1485
|
+
if (!isBlocked(m.target, this.blockClass) && value !== m.oldValue) {
|
|
1486
|
+
this.texts.push({
|
|
1487
|
+
value: needMaskingText(m.target, this.maskTextClass, this.maskTextSelector, this.unmaskTextSelector) && value
|
|
1488
|
+
? this.maskTextFn
|
|
1489
|
+
? this.maskTextFn(value)
|
|
1605
1490
|
: value.replace(/[\S]/g, '*')
|
|
1606
1491
|
: value,
|
|
1607
1492
|
node: m.target,
|
|
@@ -1610,33 +1495,33 @@ var MutationBuffer = (function () {
|
|
|
1610
1495
|
break;
|
|
1611
1496
|
}
|
|
1612
1497
|
case 'attributes': {
|
|
1613
|
-
|
|
1614
|
-
|
|
1498
|
+
const target = m.target;
|
|
1499
|
+
let value = m.target.getAttribute(m.attributeName);
|
|
1615
1500
|
if (m.attributeName === 'value') {
|
|
1616
1501
|
value = maskInputValue({
|
|
1617
1502
|
input: target,
|
|
1618
|
-
maskInputSelector:
|
|
1619
|
-
unmaskInputSelector:
|
|
1620
|
-
maskInputOptions:
|
|
1503
|
+
maskInputSelector: this.maskInputSelector,
|
|
1504
|
+
unmaskInputSelector: this.unmaskInputSelector,
|
|
1505
|
+
maskInputOptions: this.maskInputOptions,
|
|
1621
1506
|
tagName: m.target.tagName,
|
|
1622
1507
|
type: m.target.getAttribute('type'),
|
|
1623
|
-
value
|
|
1624
|
-
maskInputFn:
|
|
1508
|
+
value,
|
|
1509
|
+
maskInputFn: this.maskInputFn,
|
|
1625
1510
|
});
|
|
1626
1511
|
}
|
|
1627
|
-
if (isBlocked(m.target,
|
|
1512
|
+
if (isBlocked(m.target, this.blockClass) || value === m.oldValue) {
|
|
1628
1513
|
return;
|
|
1629
1514
|
}
|
|
1630
|
-
|
|
1515
|
+
let item = this.attributes.find((a) => a.node === m.target);
|
|
1631
1516
|
if (!item) {
|
|
1632
1517
|
item = {
|
|
1633
1518
|
node: m.target,
|
|
1634
1519
|
attributes: {},
|
|
1635
1520
|
};
|
|
1636
|
-
|
|
1521
|
+
this.attributes.push(item);
|
|
1637
1522
|
}
|
|
1638
1523
|
if (m.attributeName === 'style') {
|
|
1639
|
-
|
|
1524
|
+
const old = this.doc.createElement('span');
|
|
1640
1525
|
if (m.oldValue) {
|
|
1641
1526
|
old.setAttribute('style', m.oldValue);
|
|
1642
1527
|
}
|
|
@@ -1645,44 +1530,24 @@ var MutationBuffer = (function () {
|
|
|
1645
1530
|
item.attributes.style = {};
|
|
1646
1531
|
}
|
|
1647
1532
|
try {
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
if (
|
|
1655
|
-
|
|
1656
|
-
if (newPriority === '') {
|
|
1657
|
-
styleObj[pname] = newValue;
|
|
1658
|
-
}
|
|
1659
|
-
else {
|
|
1660
|
-
styleObj[pname] = [newValue, newPriority];
|
|
1661
|
-
}
|
|
1533
|
+
const styleObj = item.attributes.style;
|
|
1534
|
+
for (const pname of Array.from(target.style)) {
|
|
1535
|
+
const newValue = target.style.getPropertyValue(pname);
|
|
1536
|
+
const newPriority = target.style.getPropertyPriority(pname);
|
|
1537
|
+
if (newValue !== old.style.getPropertyValue(pname) ||
|
|
1538
|
+
newPriority !== old.style.getPropertyPriority(pname)) {
|
|
1539
|
+
if (newPriority === '') {
|
|
1540
|
+
styleObj[pname] = newValue;
|
|
1662
1541
|
}
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1666
|
-
finally {
|
|
1667
|
-
try {
|
|
1668
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
1669
|
-
}
|
|
1670
|
-
finally { if (e_3) throw e_3.error; }
|
|
1671
|
-
}
|
|
1672
|
-
try {
|
|
1673
|
-
for (var _e = __values(Array.from(old.style)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
1674
|
-
var pname = _f.value;
|
|
1675
|
-
if (target.style.getPropertyValue(pname) === '') {
|
|
1676
|
-
styleObj[pname] = false;
|
|
1542
|
+
else {
|
|
1543
|
+
styleObj[pname] = [newValue, newPriority];
|
|
1677
1544
|
}
|
|
1678
1545
|
}
|
|
1679
1546
|
}
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
1547
|
+
for (const pname of Array.from(old.style)) {
|
|
1548
|
+
if (target.style.getPropertyValue(pname) === '') {
|
|
1549
|
+
styleObj[pname] = false;
|
|
1684
1550
|
}
|
|
1685
|
-
finally { if (e_4) throw e_4.error; }
|
|
1686
1551
|
}
|
|
1687
1552
|
}
|
|
1688
1553
|
catch (error) {
|
|
@@ -1690,70 +1555,69 @@ var MutationBuffer = (function () {
|
|
|
1690
1555
|
}
|
|
1691
1556
|
}
|
|
1692
1557
|
else {
|
|
1693
|
-
item.attributes[m.attributeName] = transformAttribute(
|
|
1558
|
+
item.attributes[m.attributeName] = transformAttribute(this.doc, m.target.tagName, m.attributeName, value);
|
|
1694
1559
|
}
|
|
1695
1560
|
break;
|
|
1696
1561
|
}
|
|
1697
1562
|
case 'childList': {
|
|
1698
|
-
m.addedNodes.forEach(
|
|
1699
|
-
m.removedNodes.forEach(
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
?
|
|
1703
|
-
:
|
|
1704
|
-
if (isBlocked(m.target,
|
|
1563
|
+
m.addedNodes.forEach((n) => this.genAdds(n, m.target));
|
|
1564
|
+
m.removedNodes.forEach((n) => {
|
|
1565
|
+
const nodeId = this.mirror.getId(n);
|
|
1566
|
+
const parentId = isShadowRoot(m.target)
|
|
1567
|
+
? this.mirror.getId(m.target.host)
|
|
1568
|
+
: this.mirror.getId(m.target);
|
|
1569
|
+
if (isBlocked(m.target, this.blockClass) || isIgnored(n)) {
|
|
1705
1570
|
return;
|
|
1706
1571
|
}
|
|
1707
|
-
if (
|
|
1708
|
-
deepDelete(
|
|
1709
|
-
|
|
1572
|
+
if (this.addedSet.has(n)) {
|
|
1573
|
+
deepDelete(this.addedSet, n);
|
|
1574
|
+
this.droppedSet.add(n);
|
|
1710
1575
|
}
|
|
1711
|
-
else if (
|
|
1712
|
-
else if (isAncestorRemoved(m.target,
|
|
1713
|
-
else if (
|
|
1714
|
-
|
|
1715
|
-
deepDelete(
|
|
1576
|
+
else if (this.addedSet.has(m.target) && nodeId === -1) ;
|
|
1577
|
+
else if (isAncestorRemoved(m.target, this.mirror)) ;
|
|
1578
|
+
else if (this.movedSet.has(n) &&
|
|
1579
|
+
this.movedMap[moveKey(nodeId, parentId)]) {
|
|
1580
|
+
deepDelete(this.movedSet, n);
|
|
1716
1581
|
}
|
|
1717
1582
|
else {
|
|
1718
|
-
|
|
1719
|
-
parentId
|
|
1583
|
+
this.removes.push({
|
|
1584
|
+
parentId,
|
|
1720
1585
|
id: nodeId,
|
|
1721
1586
|
isShadow: isShadowRoot(m.target) ? true : undefined,
|
|
1722
1587
|
});
|
|
1723
1588
|
}
|
|
1724
|
-
|
|
1589
|
+
this.mapRemoves.push(n);
|
|
1725
1590
|
});
|
|
1726
1591
|
break;
|
|
1727
1592
|
}
|
|
1728
1593
|
}
|
|
1729
1594
|
};
|
|
1730
|
-
this.genAdds =
|
|
1731
|
-
if (target && isBlocked(target,
|
|
1595
|
+
this.genAdds = (n, target) => {
|
|
1596
|
+
if (target && isBlocked(target, this.blockClass)) {
|
|
1732
1597
|
return;
|
|
1733
1598
|
}
|
|
1734
1599
|
if (isINode(n)) {
|
|
1735
1600
|
if (isIgnored(n)) {
|
|
1736
1601
|
return;
|
|
1737
1602
|
}
|
|
1738
|
-
|
|
1739
|
-
|
|
1603
|
+
this.movedSet.add(n);
|
|
1604
|
+
let targetId = null;
|
|
1740
1605
|
if (target && isINode(target)) {
|
|
1741
1606
|
targetId = target.__sn.id;
|
|
1742
1607
|
}
|
|
1743
1608
|
if (targetId) {
|
|
1744
|
-
|
|
1609
|
+
this.movedMap[moveKey(n.__sn.id, targetId)] = true;
|
|
1745
1610
|
}
|
|
1746
1611
|
}
|
|
1747
1612
|
else {
|
|
1748
|
-
|
|
1749
|
-
|
|
1613
|
+
this.addedSet.add(n);
|
|
1614
|
+
this.droppedSet.delete(n);
|
|
1750
1615
|
}
|
|
1751
|
-
if (!isBlocked(n,
|
|
1752
|
-
n.childNodes.forEach(
|
|
1616
|
+
if (!isBlocked(n, this.blockClass))
|
|
1617
|
+
n.childNodes.forEach((childN) => this.genAdds(childN));
|
|
1753
1618
|
};
|
|
1754
1619
|
}
|
|
1755
|
-
|
|
1756
|
-
var _this = this;
|
|
1620
|
+
init(options) {
|
|
1757
1621
|
[
|
|
1758
1622
|
'mutationCb',
|
|
1759
1623
|
'blockClass',
|
|
@@ -1776,54 +1640,53 @@ var MutationBuffer = (function () {
|
|
|
1776
1640
|
'iframeManager',
|
|
1777
1641
|
'shadowDomManager',
|
|
1778
1642
|
'canvasManager',
|
|
1779
|
-
].forEach(
|
|
1780
|
-
|
|
1643
|
+
].forEach((key) => {
|
|
1644
|
+
this[key] = options[key];
|
|
1781
1645
|
});
|
|
1782
|
-
}
|
|
1783
|
-
|
|
1646
|
+
}
|
|
1647
|
+
freeze() {
|
|
1784
1648
|
this.frozen = true;
|
|
1785
1649
|
this.canvasManager.freeze();
|
|
1786
|
-
}
|
|
1787
|
-
|
|
1650
|
+
}
|
|
1651
|
+
unfreeze() {
|
|
1788
1652
|
this.frozen = false;
|
|
1789
1653
|
this.canvasManager.unfreeze();
|
|
1790
1654
|
this.emit();
|
|
1791
|
-
}
|
|
1792
|
-
|
|
1655
|
+
}
|
|
1656
|
+
isFrozen() {
|
|
1793
1657
|
return this.frozen;
|
|
1794
|
-
}
|
|
1795
|
-
|
|
1658
|
+
}
|
|
1659
|
+
lock() {
|
|
1796
1660
|
this.locked = true;
|
|
1797
1661
|
this.canvasManager.lock();
|
|
1798
|
-
}
|
|
1799
|
-
|
|
1662
|
+
}
|
|
1663
|
+
unlock() {
|
|
1800
1664
|
this.locked = false;
|
|
1801
1665
|
this.canvasManager.unlock();
|
|
1802
1666
|
this.emit();
|
|
1803
|
-
}
|
|
1804
|
-
|
|
1667
|
+
}
|
|
1668
|
+
reset() {
|
|
1805
1669
|
this.shadowDomManager.reset();
|
|
1806
1670
|
this.canvasManager.reset();
|
|
1807
|
-
}
|
|
1808
|
-
|
|
1809
|
-
}());
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1810
1673
|
function deepDelete(addsSet, n) {
|
|
1811
1674
|
addsSet.delete(n);
|
|
1812
|
-
n.childNodes.forEach(
|
|
1675
|
+
n.childNodes.forEach((childN) => deepDelete(addsSet, childN));
|
|
1813
1676
|
}
|
|
1814
1677
|
function isParentRemoved(removes, n, mirror) {
|
|
1815
|
-
|
|
1678
|
+
const { parentNode } = n;
|
|
1816
1679
|
if (!parentNode) {
|
|
1817
1680
|
return false;
|
|
1818
1681
|
}
|
|
1819
|
-
|
|
1820
|
-
if (removes.some(
|
|
1682
|
+
const parentId = mirror.getId(parentNode);
|
|
1683
|
+
if (removes.some((r) => r.id === parentId)) {
|
|
1821
1684
|
return true;
|
|
1822
1685
|
}
|
|
1823
1686
|
return isParentRemoved(removes, parentNode, mirror);
|
|
1824
1687
|
}
|
|
1825
1688
|
function isAncestorInSet(set, n) {
|
|
1826
|
-
|
|
1689
|
+
const { parentNode } = n;
|
|
1827
1690
|
if (!parentNode) {
|
|
1828
1691
|
return false;
|
|
1829
1692
|
}
|
|
@@ -1833,17 +1696,28 @@ function isAncestorInSet(set, n) {
|
|
|
1833
1696
|
return isAncestorInSet(set, parentNode);
|
|
1834
1697
|
}
|
|
1835
1698
|
|
|
1836
|
-
const
|
|
1699
|
+
const callbackWrapper = (cb) => {
|
|
1700
|
+
const rrwebWrapped = (...rest) => {
|
|
1701
|
+
try {
|
|
1702
|
+
return cb(...rest);
|
|
1703
|
+
}
|
|
1704
|
+
catch (error) {
|
|
1705
|
+
try {
|
|
1706
|
+
error.__rrweb__ = true;
|
|
1707
|
+
}
|
|
1708
|
+
catch (_a) {
|
|
1709
|
+
}
|
|
1710
|
+
throw error;
|
|
1711
|
+
}
|
|
1712
|
+
};
|
|
1713
|
+
return rrwebWrapped;
|
|
1714
|
+
};
|
|
1837
1715
|
|
|
1838
|
-
|
|
1839
|
-
var isCSSGroupingRuleSupported = typeof CSSGroupingRule !== 'undefined';
|
|
1840
|
-
var isCSSMediaRuleSupported = typeof CSSMediaRule !== 'undefined';
|
|
1841
|
-
var isCSSSupportsRuleSupported = typeof CSSSupportsRule !== 'undefined';
|
|
1842
|
-
var isCSSConditionRuleSupported = typeof CSSConditionRule !== 'undefined';
|
|
1716
|
+
const mutationBuffers = [];
|
|
1843
1717
|
function getEventTarget(event) {
|
|
1844
1718
|
try {
|
|
1845
1719
|
if ('composedPath' in event) {
|
|
1846
|
-
|
|
1720
|
+
const path = event.composedPath();
|
|
1847
1721
|
if (path.length) {
|
|
1848
1722
|
return path[0];
|
|
1849
1723
|
}
|
|
@@ -1857,17 +1731,17 @@ function getEventTarget(event) {
|
|
|
1857
1731
|
}
|
|
1858
1732
|
function initMutationObserver(options, rootEl) {
|
|
1859
1733
|
var _a, _b;
|
|
1860
|
-
|
|
1734
|
+
const mutationBuffer = new MutationBuffer();
|
|
1861
1735
|
mutationBuffers.push(mutationBuffer);
|
|
1862
1736
|
mutationBuffer.init(options);
|
|
1863
|
-
|
|
1737
|
+
let mutationObserverCtor = window.MutationObserver ||
|
|
1864
1738
|
window.__rrMutationObserver;
|
|
1865
|
-
|
|
1739
|
+
const angularZoneSymbol = (_b = (_a = window === null || window === void 0 ? void 0 : window.Zone) === null || _a === void 0 ? void 0 : _a.__symbol__) === null || _b === void 0 ? void 0 : _b.call(_a, 'MutationObserver');
|
|
1866
1740
|
if (angularZoneSymbol &&
|
|
1867
1741
|
window[angularZoneSymbol]) {
|
|
1868
1742
|
mutationObserverCtor = window[angularZoneSymbol];
|
|
1869
1743
|
}
|
|
1870
|
-
|
|
1744
|
+
const observer = new mutationObserverCtor(callbackWrapper(mutationBuffer.processMutations.bind(mutationBuffer)));
|
|
1871
1745
|
observer.observe(rootEl, {
|
|
1872
1746
|
attributes: true,
|
|
1873
1747
|
attributeOldValue: true,
|
|
@@ -1878,31 +1752,30 @@ function initMutationObserver(options, rootEl) {
|
|
|
1878
1752
|
});
|
|
1879
1753
|
return observer;
|
|
1880
1754
|
}
|
|
1881
|
-
function initMoveObserver(
|
|
1882
|
-
var mousemoveCb = _a.mousemoveCb, sampling = _a.sampling, doc = _a.doc, mirror = _a.mirror;
|
|
1755
|
+
function initMoveObserver({ mousemoveCb, sampling, doc, mirror, }) {
|
|
1883
1756
|
if (sampling.mousemove === false) {
|
|
1884
|
-
return
|
|
1757
|
+
return () => { };
|
|
1885
1758
|
}
|
|
1886
|
-
|
|
1887
|
-
|
|
1759
|
+
const threshold = typeof sampling.mousemove === 'number' ? sampling.mousemove : 50;
|
|
1760
|
+
const callbackThreshold = typeof sampling.mousemoveCallback === 'number'
|
|
1888
1761
|
? sampling.mousemoveCallback
|
|
1889
1762
|
: 500;
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
mousemoveCb(positions.map(
|
|
1763
|
+
let positions = [];
|
|
1764
|
+
let timeBaseline;
|
|
1765
|
+
const wrappedCb = throttle((source) => {
|
|
1766
|
+
const totalOffset = Date.now() - timeBaseline;
|
|
1767
|
+
callbackWrapper(mousemoveCb)(positions.map((p) => {
|
|
1895
1768
|
p.timeOffset -= totalOffset;
|
|
1896
1769
|
return p;
|
|
1897
1770
|
}), source);
|
|
1898
1771
|
positions = [];
|
|
1899
1772
|
timeBaseline = null;
|
|
1900
1773
|
}, callbackThreshold);
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1774
|
+
const updatePosition = throttle((evt) => {
|
|
1775
|
+
const target = getEventTarget(evt);
|
|
1776
|
+
const { clientX, clientY } = isTouchEvent(evt)
|
|
1904
1777
|
? evt.changedTouches[0]
|
|
1905
|
-
: evt
|
|
1778
|
+
: evt;
|
|
1906
1779
|
if (!timeBaseline) {
|
|
1907
1780
|
timeBaseline = Date.now();
|
|
1908
1781
|
}
|
|
@@ -1920,95 +1793,90 @@ function initMoveObserver(_a) {
|
|
|
1920
1793
|
}, threshold, {
|
|
1921
1794
|
trailing: false,
|
|
1922
1795
|
});
|
|
1923
|
-
|
|
1924
|
-
on('mousemove', updatePosition, doc),
|
|
1925
|
-
on('touchmove', updatePosition, doc),
|
|
1926
|
-
on('drag', updatePosition, doc),
|
|
1796
|
+
const handlers = [
|
|
1797
|
+
on('mousemove', callbackWrapper(updatePosition), doc),
|
|
1798
|
+
on('touchmove', callbackWrapper(updatePosition), doc),
|
|
1799
|
+
on('drag', callbackWrapper(updatePosition), doc),
|
|
1927
1800
|
];
|
|
1928
|
-
return
|
|
1929
|
-
handlers.forEach(
|
|
1930
|
-
};
|
|
1801
|
+
return callbackWrapper(() => {
|
|
1802
|
+
handlers.forEach((h) => h());
|
|
1803
|
+
});
|
|
1931
1804
|
}
|
|
1932
|
-
function initMouseInteractionObserver(
|
|
1933
|
-
var mouseInteractionCb = _a.mouseInteractionCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, sampling = _a.sampling;
|
|
1805
|
+
function initMouseInteractionObserver({ mouseInteractionCb, doc, mirror, blockClass, sampling, }) {
|
|
1934
1806
|
if (sampling.mouseInteraction === false) {
|
|
1935
|
-
return
|
|
1807
|
+
return () => { };
|
|
1936
1808
|
}
|
|
1937
|
-
|
|
1809
|
+
const disableMap = sampling.mouseInteraction === true ||
|
|
1938
1810
|
sampling.mouseInteraction === undefined
|
|
1939
1811
|
? {}
|
|
1940
1812
|
: sampling.mouseInteraction;
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
return
|
|
1944
|
-
|
|
1813
|
+
const handlers = [];
|
|
1814
|
+
const getHandler = (eventKey) => {
|
|
1815
|
+
return (event) => {
|
|
1816
|
+
const target = getEventTarget(event);
|
|
1945
1817
|
if (isBlocked(target, blockClass)) {
|
|
1946
1818
|
return;
|
|
1947
1819
|
}
|
|
1948
|
-
|
|
1820
|
+
const e = isTouchEvent(event) ? event.changedTouches[0] : event;
|
|
1949
1821
|
if (!e) {
|
|
1950
1822
|
return;
|
|
1951
1823
|
}
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
mouseInteractionCb({
|
|
1824
|
+
const id = mirror.getId(target);
|
|
1825
|
+
const { clientX, clientY } = e;
|
|
1826
|
+
callbackWrapper(mouseInteractionCb)({
|
|
1955
1827
|
type: MouseInteractions[eventKey],
|
|
1956
|
-
id
|
|
1828
|
+
id,
|
|
1957
1829
|
x: clientX,
|
|
1958
1830
|
y: clientY,
|
|
1959
1831
|
});
|
|
1960
1832
|
};
|
|
1961
1833
|
};
|
|
1962
1834
|
Object.keys(MouseInteractions)
|
|
1963
|
-
.filter(
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
var eventName = eventKey.toLowerCase();
|
|
1970
|
-
var handler = getHandler(eventKey);
|
|
1835
|
+
.filter((key) => Number.isNaN(Number(key)) &&
|
|
1836
|
+
!key.endsWith('_Departed') &&
|
|
1837
|
+
disableMap[key] !== false)
|
|
1838
|
+
.forEach((eventKey) => {
|
|
1839
|
+
const eventName = eventKey.toLowerCase();
|
|
1840
|
+
const handler = callbackWrapper(getHandler(eventKey));
|
|
1971
1841
|
handlers.push(on(eventName, handler, doc));
|
|
1972
1842
|
});
|
|
1973
|
-
return
|
|
1974
|
-
handlers.forEach(
|
|
1975
|
-
};
|
|
1843
|
+
return callbackWrapper(() => {
|
|
1844
|
+
handlers.forEach((h) => h());
|
|
1845
|
+
});
|
|
1976
1846
|
}
|
|
1977
|
-
function initScrollObserver(
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
var target = getEventTarget(evt);
|
|
1847
|
+
function initScrollObserver({ scrollCb, doc, mirror, blockClass, sampling, }) {
|
|
1848
|
+
const updatePosition = throttle((evt) => {
|
|
1849
|
+
const target = getEventTarget(evt);
|
|
1981
1850
|
if (!target || isBlocked(target, blockClass)) {
|
|
1982
1851
|
return;
|
|
1983
1852
|
}
|
|
1984
|
-
|
|
1853
|
+
const id = mirror.getId(target);
|
|
1985
1854
|
if (target === doc) {
|
|
1986
|
-
|
|
1987
|
-
scrollCb({
|
|
1988
|
-
id
|
|
1855
|
+
const scrollEl = (doc.scrollingElement || doc.documentElement);
|
|
1856
|
+
callbackWrapper(scrollCb)({
|
|
1857
|
+
id,
|
|
1989
1858
|
x: scrollEl.scrollLeft,
|
|
1990
1859
|
y: scrollEl.scrollTop,
|
|
1991
1860
|
});
|
|
1992
1861
|
}
|
|
1993
1862
|
else {
|
|
1994
|
-
scrollCb({
|
|
1995
|
-
id
|
|
1863
|
+
callbackWrapper(scrollCb)({
|
|
1864
|
+
id,
|
|
1996
1865
|
x: target.scrollLeft,
|
|
1997
1866
|
y: target.scrollTop,
|
|
1998
1867
|
});
|
|
1999
1868
|
}
|
|
2000
1869
|
}, sampling.scroll || 100);
|
|
2001
|
-
return on('scroll', updatePosition, doc);
|
|
2002
|
-
}
|
|
2003
|
-
function initViewportResizeObserver(
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
var width = getWindowWidth();
|
|
1870
|
+
return on('scroll', callbackWrapper(updatePosition), doc);
|
|
1871
|
+
}
|
|
1872
|
+
function initViewportResizeObserver({ viewportResizeCb, }) {
|
|
1873
|
+
let lastH = -1;
|
|
1874
|
+
let lastW = -1;
|
|
1875
|
+
const updateDimension = throttle(() => {
|
|
1876
|
+
const height = getWindowHeight();
|
|
1877
|
+
const width = getWindowWidth();
|
|
2010
1878
|
if (lastH !== height || lastW !== width) {
|
|
2011
|
-
viewportResizeCb({
|
|
1879
|
+
callbackWrapper(viewportResizeCb)({
|
|
2012
1880
|
width: Number(width),
|
|
2013
1881
|
height: Number(height),
|
|
2014
1882
|
});
|
|
@@ -2016,21 +1884,20 @@ function initViewportResizeObserver(_a) {
|
|
|
2016
1884
|
lastW = width;
|
|
2017
1885
|
}
|
|
2018
1886
|
}, 200);
|
|
2019
|
-
return on('resize', updateDimension, window);
|
|
1887
|
+
return on('resize', callbackWrapper(updateDimension), window);
|
|
2020
1888
|
}
|
|
2021
1889
|
function wrapEventWithUserTriggeredFlag(v, enable) {
|
|
2022
|
-
|
|
1890
|
+
const value = Object.assign({}, v);
|
|
2023
1891
|
if (!enable)
|
|
2024
1892
|
delete value.userTriggered;
|
|
2025
1893
|
return value;
|
|
2026
1894
|
}
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
function initInputObserver(
|
|
2030
|
-
var inputCb = _a.inputCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, ignoreClass = _a.ignoreClass, ignoreSelector = _a.ignoreSelector, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, maskInputFn = _a.maskInputFn, sampling = _a.sampling, userTriggeredOnInput = _a.userTriggeredOnInput;
|
|
1895
|
+
const INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT'];
|
|
1896
|
+
const lastInputValueMap = new WeakMap();
|
|
1897
|
+
function initInputObserver({ inputCb, doc, mirror, blockClass, ignoreClass, ignoreSelector, maskInputSelector, unmaskInputSelector, maskInputOptions, maskInputFn, sampling, userTriggeredOnInput, }) {
|
|
2031
1898
|
function eventHandler(event) {
|
|
2032
|
-
|
|
2033
|
-
|
|
1899
|
+
let target = getEventTarget(event);
|
|
1900
|
+
const userTriggered = event.isTrusted;
|
|
2034
1901
|
if (target && target.tagName === 'OPTION')
|
|
2035
1902
|
target = target.parentElement;
|
|
2036
1903
|
if (!target ||
|
|
@@ -2039,13 +1906,13 @@ function initInputObserver(_a) {
|
|
|
2039
1906
|
isBlocked(target, blockClass)) {
|
|
2040
1907
|
return;
|
|
2041
1908
|
}
|
|
2042
|
-
|
|
1909
|
+
const type = target.type;
|
|
2043
1910
|
if (target.classList.contains(ignoreClass) ||
|
|
2044
1911
|
(ignoreSelector && target.matches(ignoreSelector))) {
|
|
2045
1912
|
return;
|
|
2046
1913
|
}
|
|
2047
|
-
|
|
2048
|
-
|
|
1914
|
+
let text = target.value;
|
|
1915
|
+
let isChecked = false;
|
|
2049
1916
|
if (type === 'radio' || type === 'checkbox') {
|
|
2050
1917
|
isChecked = target.checked;
|
|
2051
1918
|
}
|
|
@@ -2053,23 +1920,23 @@ function initInputObserver(_a) {
|
|
|
2053
1920
|
maskInputOptions[type]) {
|
|
2054
1921
|
text = maskInputValue({
|
|
2055
1922
|
input: target,
|
|
2056
|
-
maskInputOptions
|
|
2057
|
-
maskInputSelector
|
|
2058
|
-
unmaskInputSelector
|
|
1923
|
+
maskInputOptions,
|
|
1924
|
+
maskInputSelector,
|
|
1925
|
+
unmaskInputSelector,
|
|
2059
1926
|
tagName: target.tagName,
|
|
2060
|
-
type
|
|
1927
|
+
type,
|
|
2061
1928
|
value: text,
|
|
2062
|
-
maskInputFn
|
|
1929
|
+
maskInputFn,
|
|
2063
1930
|
});
|
|
2064
1931
|
}
|
|
2065
|
-
cbWithDedup(target, wrapEventWithUserTriggeredFlag({ text
|
|
2066
|
-
|
|
1932
|
+
cbWithDedup(target, callbackWrapper(wrapEventWithUserTriggeredFlag)({ text, isChecked, userTriggered }, userTriggeredOnInput));
|
|
1933
|
+
const name = target.name;
|
|
2067
1934
|
if (type === 'radio' && name && isChecked) {
|
|
2068
1935
|
doc
|
|
2069
|
-
.querySelectorAll(
|
|
2070
|
-
.forEach(
|
|
1936
|
+
.querySelectorAll(`input[type="radio"][name="${name}"]`)
|
|
1937
|
+
.forEach((el) => {
|
|
2071
1938
|
if (el !== target) {
|
|
2072
|
-
cbWithDedup(el, wrapEventWithUserTriggeredFlag({
|
|
1939
|
+
cbWithDedup(el, callbackWrapper(wrapEventWithUserTriggeredFlag)({
|
|
2073
1940
|
text: el.value,
|
|
2074
1941
|
isChecked: !isChecked,
|
|
2075
1942
|
userTriggered: false,
|
|
@@ -2079,19 +1946,19 @@ function initInputObserver(_a) {
|
|
|
2079
1946
|
}
|
|
2080
1947
|
}
|
|
2081
1948
|
function cbWithDedup(target, v) {
|
|
2082
|
-
|
|
1949
|
+
const lastInputValue = lastInputValueMap.get(target);
|
|
2083
1950
|
if (!lastInputValue ||
|
|
2084
1951
|
lastInputValue.text !== v.text ||
|
|
2085
1952
|
lastInputValue.isChecked !== v.isChecked) {
|
|
2086
1953
|
lastInputValueMap.set(target, v);
|
|
2087
|
-
|
|
2088
|
-
inputCb(
|
|
1954
|
+
const id = mirror.getId(target);
|
|
1955
|
+
inputCb(Object.assign(Object.assign({}, v), { id }));
|
|
2089
1956
|
}
|
|
2090
1957
|
}
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
1958
|
+
const events = sampling.input === 'last' ? ['change'] : ['input', 'change'];
|
|
1959
|
+
const handlers = events.map((eventName) => on(eventName, callbackWrapper(eventHandler), doc));
|
|
1960
|
+
const propertyDescriptor = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value');
|
|
1961
|
+
const hookProperties = [
|
|
2095
1962
|
[HTMLInputElement.prototype, 'value'],
|
|
2096
1963
|
[HTMLInputElement.prototype, 'checked'],
|
|
2097
1964
|
[HTMLSelectElement.prototype, 'value'],
|
|
@@ -2100,213 +1967,222 @@ function initInputObserver(_a) {
|
|
|
2100
1967
|
[HTMLOptionElement.prototype, 'selected'],
|
|
2101
1968
|
];
|
|
2102
1969
|
if (propertyDescriptor && propertyDescriptor.set) {
|
|
2103
|
-
handlers.push.
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
});
|
|
2109
|
-
})), false));
|
|
1970
|
+
handlers.push(...hookProperties.map((p) => hookSetter(p[0], p[1], {
|
|
1971
|
+
set() {
|
|
1972
|
+
callbackWrapper(eventHandler)({ target: this });
|
|
1973
|
+
},
|
|
1974
|
+
})));
|
|
2110
1975
|
}
|
|
2111
|
-
return
|
|
2112
|
-
handlers.forEach(
|
|
2113
|
-
};
|
|
1976
|
+
return callbackWrapper(() => {
|
|
1977
|
+
handlers.forEach((h) => h());
|
|
1978
|
+
});
|
|
2114
1979
|
}
|
|
2115
1980
|
function getNestedCSSRulePositions(rule) {
|
|
2116
|
-
|
|
1981
|
+
const positions = [];
|
|
2117
1982
|
function recurse(childRule, pos) {
|
|
2118
|
-
if ((
|
|
1983
|
+
if ((hasNestedCSSRule('CSSGroupingRule') &&
|
|
2119
1984
|
childRule.parentRule instanceof CSSGroupingRule) ||
|
|
2120
|
-
(
|
|
1985
|
+
(hasNestedCSSRule('CSSMediaRule') &&
|
|
2121
1986
|
childRule.parentRule instanceof CSSMediaRule) ||
|
|
2122
|
-
(
|
|
1987
|
+
(hasNestedCSSRule('CSSSupportsRule') &&
|
|
2123
1988
|
childRule.parentRule instanceof CSSSupportsRule) ||
|
|
2124
|
-
(
|
|
1989
|
+
(hasNestedCSSRule('CSSConditionRule') &&
|
|
2125
1990
|
childRule.parentRule instanceof CSSConditionRule)) {
|
|
2126
|
-
|
|
2127
|
-
|
|
1991
|
+
const rules = Array.from(childRule.parentRule.cssRules);
|
|
1992
|
+
const index = rules.indexOf(childRule);
|
|
2128
1993
|
pos.unshift(index);
|
|
2129
1994
|
}
|
|
2130
1995
|
else {
|
|
2131
|
-
|
|
2132
|
-
|
|
1996
|
+
const rules = Array.from(childRule.parentStyleSheet.cssRules);
|
|
1997
|
+
const index = rules.indexOf(childRule);
|
|
2133
1998
|
pos.unshift(index);
|
|
2134
1999
|
}
|
|
2135
2000
|
return pos;
|
|
2136
2001
|
}
|
|
2137
2002
|
return recurse(rule, positions);
|
|
2138
2003
|
}
|
|
2139
|
-
function initStyleSheetObserver(
|
|
2140
|
-
var styleSheetRuleCb = _a.styleSheetRuleCb, mirror = _a.mirror;
|
|
2141
|
-
var win = _b.win;
|
|
2004
|
+
function initStyleSheetObserver({ styleSheetRuleCb, mirror }, { win }) {
|
|
2142
2005
|
if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {
|
|
2143
|
-
return
|
|
2144
|
-
}
|
|
2145
|
-
|
|
2146
|
-
win.CSSStyleSheet.prototype.insertRule =
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2006
|
+
return () => { };
|
|
2007
|
+
}
|
|
2008
|
+
const insertRule = win.CSSStyleSheet.prototype.insertRule;
|
|
2009
|
+
win.CSSStyleSheet.prototype.insertRule = new Proxy(insertRule, {
|
|
2010
|
+
apply: callbackWrapper((target, thisArg, argumentsList) => {
|
|
2011
|
+
const [rule, index] = argumentsList;
|
|
2012
|
+
const id = mirror.getId(thisArg.ownerNode);
|
|
2013
|
+
if (id !== -1) {
|
|
2014
|
+
styleSheetRuleCb({
|
|
2015
|
+
id,
|
|
2016
|
+
adds: [{ rule, index }],
|
|
2017
|
+
});
|
|
2018
|
+
}
|
|
2019
|
+
return target.apply(thisArg, argumentsList);
|
|
2020
|
+
}),
|
|
2021
|
+
});
|
|
2022
|
+
const deleteRule = win.CSSStyleSheet.prototype.deleteRule;
|
|
2023
|
+
win.CSSStyleSheet.prototype.deleteRule = new Proxy(deleteRule, {
|
|
2024
|
+
apply: callbackWrapper((target, thisArg, argumentsList) => {
|
|
2025
|
+
const [index] = argumentsList;
|
|
2026
|
+
const id = mirror.getId(thisArg.ownerNode);
|
|
2027
|
+
if (id !== -1) {
|
|
2028
|
+
styleSheetRuleCb({
|
|
2029
|
+
id,
|
|
2030
|
+
removes: [{ index }],
|
|
2031
|
+
});
|
|
2032
|
+
}
|
|
2033
|
+
return target.apply(thisArg, argumentsList);
|
|
2034
|
+
}),
|
|
2035
|
+
});
|
|
2036
|
+
const supportedNestedCSSRuleTypes = {};
|
|
2037
|
+
if (canMonkeyPatchNestedCSSRule('CSSGroupingRule')) {
|
|
2169
2038
|
supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;
|
|
2170
2039
|
}
|
|
2171
2040
|
else {
|
|
2172
|
-
if (
|
|
2041
|
+
if (canMonkeyPatchNestedCSSRule('CSSMediaRule')) {
|
|
2173
2042
|
supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;
|
|
2174
2043
|
}
|
|
2175
|
-
if (
|
|
2044
|
+
if (canMonkeyPatchNestedCSSRule('CSSConditionRule')) {
|
|
2176
2045
|
supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;
|
|
2177
2046
|
}
|
|
2178
|
-
if (
|
|
2047
|
+
if (canMonkeyPatchNestedCSSRule('CSSSupportsRule')) {
|
|
2179
2048
|
supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;
|
|
2180
2049
|
}
|
|
2181
2050
|
}
|
|
2182
|
-
|
|
2183
|
-
Object.entries(supportedNestedCSSRuleTypes).forEach(
|
|
2184
|
-
var _b = __read(_a, 2), typeKey = _b[0], type = _b[1];
|
|
2051
|
+
const unmodifiedFunctions = {};
|
|
2052
|
+
Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {
|
|
2185
2053
|
unmodifiedFunctions[typeKey] = {
|
|
2186
2054
|
insertRule: type.prototype.insertRule,
|
|
2187
2055
|
deleteRule: type.prototype.deleteRule,
|
|
2188
2056
|
};
|
|
2189
|
-
type.prototype.insertRule =
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2057
|
+
type.prototype.insertRule = new Proxy(unmodifiedFunctions[typeKey].insertRule, {
|
|
2058
|
+
apply: callbackWrapper((target, thisArg, argumentsList) => {
|
|
2059
|
+
const [rule, index] = argumentsList;
|
|
2060
|
+
const id = mirror.getId(thisArg.parentStyleSheet.ownerNode);
|
|
2061
|
+
if (id !== -1) {
|
|
2062
|
+
styleSheetRuleCb({
|
|
2063
|
+
id,
|
|
2064
|
+
adds: [
|
|
2065
|
+
{
|
|
2066
|
+
rule,
|
|
2067
|
+
index: [
|
|
2068
|
+
...getNestedCSSRulePositions(thisArg),
|
|
2069
|
+
index || 0,
|
|
2070
|
+
],
|
|
2071
|
+
},
|
|
2072
|
+
],
|
|
2073
|
+
});
|
|
2074
|
+
}
|
|
2075
|
+
return target.apply(thisArg, argumentsList);
|
|
2076
|
+
}),
|
|
2077
|
+
});
|
|
2078
|
+
type.prototype.deleteRule = new Proxy(unmodifiedFunctions[typeKey].deleteRule, {
|
|
2079
|
+
apply: callbackWrapper((target, thisArg, argumentsList) => {
|
|
2080
|
+
const [index] = argumentsList;
|
|
2081
|
+
const id = mirror.getId(thisArg.parentStyleSheet.ownerNode);
|
|
2082
|
+
if (id !== -1) {
|
|
2083
|
+
styleSheetRuleCb({
|
|
2084
|
+
id,
|
|
2085
|
+
removes: [
|
|
2086
|
+
{ index: [...getNestedCSSRulePositions(thisArg), index] },
|
|
2087
|
+
],
|
|
2088
|
+
});
|
|
2089
|
+
}
|
|
2090
|
+
return target.apply(thisArg, argumentsList);
|
|
2091
|
+
}),
|
|
2092
|
+
});
|
|
2216
2093
|
});
|
|
2217
|
-
return
|
|
2094
|
+
return callbackWrapper(() => {
|
|
2218
2095
|
win.CSSStyleSheet.prototype.insertRule = insertRule;
|
|
2219
2096
|
win.CSSStyleSheet.prototype.deleteRule = deleteRule;
|
|
2220
|
-
Object.entries(supportedNestedCSSRuleTypes).forEach(
|
|
2221
|
-
var _b = __read(_a, 2), typeKey = _b[0], type = _b[1];
|
|
2097
|
+
Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {
|
|
2222
2098
|
type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;
|
|
2223
2099
|
type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;
|
|
2224
2100
|
});
|
|
2225
|
-
};
|
|
2101
|
+
});
|
|
2226
2102
|
}
|
|
2227
|
-
function initStyleDeclarationObserver(
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
win.CSSStyleDeclaration.prototype.removeProperty
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2103
|
+
function initStyleDeclarationObserver({ styleDeclarationCb, mirror }, { win }) {
|
|
2104
|
+
const setProperty = win.CSSStyleDeclaration.prototype.setProperty;
|
|
2105
|
+
win.CSSStyleDeclaration.prototype.setProperty = new Proxy(setProperty, {
|
|
2106
|
+
apply: callbackWrapper((target, thisArg, argumentsList) => {
|
|
2107
|
+
var _a, _b;
|
|
2108
|
+
const [property, value, priority] = argumentsList;
|
|
2109
|
+
const id = mirror.getId((_b = (_a = thisArg.parentRule) === null || _a === void 0 ? void 0 : _a.parentStyleSheet) === null || _b === void 0 ? void 0 : _b.ownerNode);
|
|
2110
|
+
if (id !== -1) {
|
|
2111
|
+
styleDeclarationCb({
|
|
2112
|
+
id,
|
|
2113
|
+
set: {
|
|
2114
|
+
property,
|
|
2115
|
+
value,
|
|
2116
|
+
priority,
|
|
2117
|
+
},
|
|
2118
|
+
index: getNestedCSSRulePositions(thisArg.parentRule),
|
|
2119
|
+
});
|
|
2120
|
+
}
|
|
2121
|
+
return target.apply(thisArg, argumentsList);
|
|
2122
|
+
}),
|
|
2123
|
+
});
|
|
2124
|
+
const removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;
|
|
2125
|
+
win.CSSStyleDeclaration.prototype.removeProperty = new Proxy(removeProperty, {
|
|
2126
|
+
apply: callbackWrapper((target, thisArg, argumentsList) => {
|
|
2127
|
+
var _a, _b;
|
|
2128
|
+
const [property] = argumentsList;
|
|
2129
|
+
const id = mirror.getId((_b = (_a = thisArg.parentRule) === null || _a === void 0 ? void 0 : _a.parentStyleSheet) === null || _b === void 0 ? void 0 : _b.ownerNode);
|
|
2130
|
+
if (id !== -1) {
|
|
2131
|
+
styleDeclarationCb({
|
|
2132
|
+
id,
|
|
2133
|
+
remove: {
|
|
2134
|
+
property,
|
|
2135
|
+
},
|
|
2136
|
+
index: getNestedCSSRulePositions(thisArg.parentRule),
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2139
|
+
return target.apply(thisArg, argumentsList);
|
|
2140
|
+
}),
|
|
2141
|
+
});
|
|
2142
|
+
return callbackWrapper(() => {
|
|
2263
2143
|
win.CSSStyleDeclaration.prototype.setProperty = setProperty;
|
|
2264
2144
|
win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;
|
|
2265
|
-
};
|
|
2145
|
+
});
|
|
2266
2146
|
}
|
|
2267
|
-
function initMediaInteractionObserver(
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
}, sampling.media || 500);
|
|
2284
|
-
};
|
|
2285
|
-
var handlers = [
|
|
2147
|
+
function initMediaInteractionObserver({ mediaInteractionCb, blockClass, mirror, sampling, }) {
|
|
2148
|
+
const handler = (type) => throttle(callbackWrapper((event) => {
|
|
2149
|
+
const target = getEventTarget(event);
|
|
2150
|
+
if (!target || isBlocked(target, blockClass)) {
|
|
2151
|
+
return;
|
|
2152
|
+
}
|
|
2153
|
+
const { currentTime, volume, muted } = target;
|
|
2154
|
+
mediaInteractionCb({
|
|
2155
|
+
type,
|
|
2156
|
+
id: mirror.getId(target),
|
|
2157
|
+
currentTime,
|
|
2158
|
+
volume,
|
|
2159
|
+
muted,
|
|
2160
|
+
});
|
|
2161
|
+
}), sampling.media || 500);
|
|
2162
|
+
const handlers = [
|
|
2286
2163
|
on('play', handler(0)),
|
|
2287
2164
|
on('pause', handler(1)),
|
|
2288
2165
|
on('seeked', handler(2)),
|
|
2289
2166
|
on('volumechange', handler(3)),
|
|
2290
2167
|
];
|
|
2291
|
-
return
|
|
2292
|
-
handlers.forEach(
|
|
2293
|
-
};
|
|
2168
|
+
return callbackWrapper(() => {
|
|
2169
|
+
handlers.forEach((h) => h());
|
|
2170
|
+
});
|
|
2294
2171
|
}
|
|
2295
|
-
function initFontObserver(
|
|
2296
|
-
|
|
2297
|
-
var win = doc.defaultView;
|
|
2172
|
+
function initFontObserver({ fontCb, doc }) {
|
|
2173
|
+
const win = doc.defaultView;
|
|
2298
2174
|
if (!win) {
|
|
2299
|
-
return
|
|
2175
|
+
return () => { };
|
|
2300
2176
|
}
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2177
|
+
const handlers = [];
|
|
2178
|
+
const fontMap = new WeakMap();
|
|
2179
|
+
const originalFontFace = win.FontFace;
|
|
2304
2180
|
win.FontFace = function FontFace(family, source, descriptors) {
|
|
2305
|
-
|
|
2181
|
+
const fontFace = new originalFontFace(family, source, descriptors);
|
|
2306
2182
|
fontMap.set(fontFace, {
|
|
2307
|
-
family
|
|
2183
|
+
family,
|
|
2308
2184
|
buffer: typeof source !== 'string',
|
|
2309
|
-
descriptors
|
|
2185
|
+
descriptors,
|
|
2310
2186
|
fontSource: typeof source === 'string'
|
|
2311
2187
|
? source
|
|
2312
2188
|
:
|
|
@@ -2314,10 +2190,10 @@ function initFontObserver(_a) {
|
|
|
2314
2190
|
});
|
|
2315
2191
|
return fontFace;
|
|
2316
2192
|
};
|
|
2317
|
-
|
|
2193
|
+
const restoreHandler = patch(doc.fonts, 'add', function (original) {
|
|
2318
2194
|
return function (fontFace) {
|
|
2319
|
-
setTimeout(
|
|
2320
|
-
|
|
2195
|
+
setTimeout(() => {
|
|
2196
|
+
const p = fontMap.get(fontFace);
|
|
2321
2197
|
if (p) {
|
|
2322
2198
|
fontCb(p);
|
|
2323
2199
|
fontMap.delete(fontFace);
|
|
@@ -2326,163 +2202,107 @@ function initFontObserver(_a) {
|
|
|
2326
2202
|
return original.apply(this, [fontFace]);
|
|
2327
2203
|
};
|
|
2328
2204
|
});
|
|
2329
|
-
handlers.push(
|
|
2205
|
+
handlers.push(() => {
|
|
2330
2206
|
win.FontFace = originalFontFace;
|
|
2331
2207
|
});
|
|
2332
2208
|
handlers.push(restoreHandler);
|
|
2333
|
-
return
|
|
2334
|
-
handlers.forEach(
|
|
2335
|
-
};
|
|
2209
|
+
return callbackWrapper(() => {
|
|
2210
|
+
handlers.forEach((h) => h());
|
|
2211
|
+
});
|
|
2336
2212
|
}
|
|
2337
2213
|
function mergeHooks(o, hooks) {
|
|
2338
|
-
|
|
2339
|
-
o.mutationCb =
|
|
2340
|
-
var p = [];
|
|
2341
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2342
|
-
p[_i] = arguments[_i];
|
|
2343
|
-
}
|
|
2214
|
+
const { mutationCb, mousemoveCb, mouseInteractionCb, scrollCb, viewportResizeCb, inputCb, mediaInteractionCb, styleSheetRuleCb, styleDeclarationCb, canvasMutationCb, fontCb, } = o;
|
|
2215
|
+
o.mutationCb = (...p) => {
|
|
2344
2216
|
if (hooks.mutation) {
|
|
2345
|
-
hooks.mutation
|
|
2217
|
+
hooks.mutation(...p);
|
|
2346
2218
|
}
|
|
2347
|
-
mutationCb
|
|
2219
|
+
mutationCb(...p);
|
|
2348
2220
|
};
|
|
2349
|
-
o.mousemoveCb =
|
|
2350
|
-
var p = [];
|
|
2351
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2352
|
-
p[_i] = arguments[_i];
|
|
2353
|
-
}
|
|
2221
|
+
o.mousemoveCb = (...p) => {
|
|
2354
2222
|
if (hooks.mousemove) {
|
|
2355
|
-
hooks.mousemove
|
|
2223
|
+
hooks.mousemove(...p);
|
|
2356
2224
|
}
|
|
2357
|
-
mousemoveCb
|
|
2225
|
+
mousemoveCb(...p);
|
|
2358
2226
|
};
|
|
2359
|
-
o.mouseInteractionCb =
|
|
2360
|
-
var p = [];
|
|
2361
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2362
|
-
p[_i] = arguments[_i];
|
|
2363
|
-
}
|
|
2227
|
+
o.mouseInteractionCb = (...p) => {
|
|
2364
2228
|
if (hooks.mouseInteraction) {
|
|
2365
|
-
hooks.mouseInteraction
|
|
2229
|
+
hooks.mouseInteraction(...p);
|
|
2366
2230
|
}
|
|
2367
|
-
mouseInteractionCb
|
|
2231
|
+
mouseInteractionCb(...p);
|
|
2368
2232
|
};
|
|
2369
|
-
o.scrollCb =
|
|
2370
|
-
var p = [];
|
|
2371
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2372
|
-
p[_i] = arguments[_i];
|
|
2373
|
-
}
|
|
2233
|
+
o.scrollCb = (...p) => {
|
|
2374
2234
|
if (hooks.scroll) {
|
|
2375
|
-
hooks.scroll
|
|
2235
|
+
hooks.scroll(...p);
|
|
2376
2236
|
}
|
|
2377
|
-
scrollCb
|
|
2237
|
+
scrollCb(...p);
|
|
2378
2238
|
};
|
|
2379
|
-
o.viewportResizeCb =
|
|
2380
|
-
var p = [];
|
|
2381
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2382
|
-
p[_i] = arguments[_i];
|
|
2383
|
-
}
|
|
2239
|
+
o.viewportResizeCb = (...p) => {
|
|
2384
2240
|
if (hooks.viewportResize) {
|
|
2385
|
-
hooks.viewportResize
|
|
2241
|
+
hooks.viewportResize(...p);
|
|
2386
2242
|
}
|
|
2387
|
-
viewportResizeCb
|
|
2243
|
+
viewportResizeCb(...p);
|
|
2388
2244
|
};
|
|
2389
|
-
o.inputCb =
|
|
2390
|
-
var p = [];
|
|
2391
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2392
|
-
p[_i] = arguments[_i];
|
|
2393
|
-
}
|
|
2245
|
+
o.inputCb = (...p) => {
|
|
2394
2246
|
if (hooks.input) {
|
|
2395
|
-
hooks.input
|
|
2247
|
+
hooks.input(...p);
|
|
2396
2248
|
}
|
|
2397
|
-
inputCb
|
|
2249
|
+
inputCb(...p);
|
|
2398
2250
|
};
|
|
2399
|
-
o.mediaInteractionCb =
|
|
2400
|
-
var p = [];
|
|
2401
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2402
|
-
p[_i] = arguments[_i];
|
|
2403
|
-
}
|
|
2251
|
+
o.mediaInteractionCb = (...p) => {
|
|
2404
2252
|
if (hooks.mediaInteaction) {
|
|
2405
|
-
hooks.mediaInteaction
|
|
2253
|
+
hooks.mediaInteaction(...p);
|
|
2406
2254
|
}
|
|
2407
|
-
mediaInteractionCb
|
|
2255
|
+
mediaInteractionCb(...p);
|
|
2408
2256
|
};
|
|
2409
|
-
o.styleSheetRuleCb =
|
|
2410
|
-
var p = [];
|
|
2411
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2412
|
-
p[_i] = arguments[_i];
|
|
2413
|
-
}
|
|
2257
|
+
o.styleSheetRuleCb = (...p) => {
|
|
2414
2258
|
if (hooks.styleSheetRule) {
|
|
2415
|
-
hooks.styleSheetRule
|
|
2259
|
+
hooks.styleSheetRule(...p);
|
|
2416
2260
|
}
|
|
2417
|
-
styleSheetRuleCb
|
|
2261
|
+
styleSheetRuleCb(...p);
|
|
2418
2262
|
};
|
|
2419
|
-
o.styleDeclarationCb =
|
|
2420
|
-
var p = [];
|
|
2421
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2422
|
-
p[_i] = arguments[_i];
|
|
2423
|
-
}
|
|
2263
|
+
o.styleDeclarationCb = (...p) => {
|
|
2424
2264
|
if (hooks.styleDeclaration) {
|
|
2425
|
-
hooks.styleDeclaration
|
|
2265
|
+
hooks.styleDeclaration(...p);
|
|
2426
2266
|
}
|
|
2427
|
-
styleDeclarationCb
|
|
2267
|
+
styleDeclarationCb(...p);
|
|
2428
2268
|
};
|
|
2429
|
-
o.canvasMutationCb =
|
|
2430
|
-
var p = [];
|
|
2431
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2432
|
-
p[_i] = arguments[_i];
|
|
2433
|
-
}
|
|
2269
|
+
o.canvasMutationCb = (...p) => {
|
|
2434
2270
|
if (hooks.canvasMutation) {
|
|
2435
|
-
hooks.canvasMutation
|
|
2271
|
+
hooks.canvasMutation(...p);
|
|
2436
2272
|
}
|
|
2437
|
-
canvasMutationCb
|
|
2273
|
+
canvasMutationCb(...p);
|
|
2438
2274
|
};
|
|
2439
|
-
o.fontCb =
|
|
2440
|
-
var p = [];
|
|
2441
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2442
|
-
p[_i] = arguments[_i];
|
|
2443
|
-
}
|
|
2275
|
+
o.fontCb = (...p) => {
|
|
2444
2276
|
if (hooks.font) {
|
|
2445
|
-
hooks.font
|
|
2277
|
+
hooks.font(...p);
|
|
2446
2278
|
}
|
|
2447
|
-
fontCb
|
|
2279
|
+
fontCb(...p);
|
|
2448
2280
|
};
|
|
2449
2281
|
}
|
|
2450
|
-
function initObservers(o, hooks) {
|
|
2451
|
-
|
|
2452
|
-
if (hooks === void 0) { hooks = {}; }
|
|
2453
|
-
var currentWindow = o.doc.defaultView;
|
|
2282
|
+
function initObservers(o, hooks = {}) {
|
|
2283
|
+
const currentWindow = o.doc.defaultView;
|
|
2454
2284
|
if (!currentWindow) {
|
|
2455
|
-
return
|
|
2285
|
+
return () => { };
|
|
2456
2286
|
}
|
|
2457
2287
|
mergeHooks(o, hooks);
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2288
|
+
const mutationObserver = initMutationObserver(o, o.doc);
|
|
2289
|
+
const mousemoveHandler = initMoveObserver(o);
|
|
2290
|
+
const mouseInteractionHandler = initMouseInteractionObserver(o);
|
|
2291
|
+
const scrollHandler = initScrollObserver(o);
|
|
2292
|
+
const viewportResizeHandler = initViewportResizeObserver(o);
|
|
2293
|
+
const inputHandler = initInputObserver(o);
|
|
2294
|
+
const mediaInteractionHandler = initMediaInteractionObserver(o);
|
|
2295
|
+
const styleSheetObserver = initStyleSheetObserver(o, { win: currentWindow });
|
|
2296
|
+
const styleDeclarationObserver = initStyleDeclarationObserver(o, {
|
|
2467
2297
|
win: currentWindow,
|
|
2468
2298
|
});
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
var plugin = _c.value;
|
|
2474
|
-
pluginHandlers.push(plugin.observer(plugin.callback, currentWindow, plugin.options));
|
|
2475
|
-
}
|
|
2299
|
+
const fontObserver = o.collectFonts ? initFontObserver(o) : () => { };
|
|
2300
|
+
const pluginHandlers = [];
|
|
2301
|
+
for (const plugin of o.plugins) {
|
|
2302
|
+
pluginHandlers.push(plugin.observer(plugin.callback, currentWindow, plugin.options));
|
|
2476
2303
|
}
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
try {
|
|
2480
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2481
|
-
}
|
|
2482
|
-
finally { if (e_1) throw e_1.error; }
|
|
2483
|
-
}
|
|
2484
|
-
return function () {
|
|
2485
|
-
mutationBuffers.forEach(function (b) { return b.reset(); });
|
|
2304
|
+
return callbackWrapper(() => {
|
|
2305
|
+
mutationBuffers.forEach((b) => b.reset());
|
|
2486
2306
|
mutationObserver.disconnect();
|
|
2487
2307
|
mousemoveHandler();
|
|
2488
2308
|
mouseInteractionHandler();
|
|
@@ -2497,22 +2317,31 @@ function initObservers(o, hooks) {
|
|
|
2497
2317
|
catch (e) {
|
|
2498
2318
|
}
|
|
2499
2319
|
fontObserver();
|
|
2500
|
-
pluginHandlers.forEach(
|
|
2501
|
-
};
|
|
2320
|
+
pluginHandlers.forEach((h) => h());
|
|
2321
|
+
});
|
|
2322
|
+
}
|
|
2323
|
+
function hasNestedCSSRule(prop) {
|
|
2324
|
+
return typeof window[prop] !== 'undefined';
|
|
2325
|
+
}
|
|
2326
|
+
function canMonkeyPatchNestedCSSRule(prop) {
|
|
2327
|
+
return Boolean(typeof window[prop] !== 'undefined' &&
|
|
2328
|
+
window[prop].prototype &&
|
|
2329
|
+
'insertRule' in window[prop].prototype &&
|
|
2330
|
+
'deleteRule' in window[prop].prototype);
|
|
2502
2331
|
}
|
|
2503
2332
|
|
|
2504
|
-
|
|
2505
|
-
|
|
2333
|
+
class IframeManager {
|
|
2334
|
+
constructor(options) {
|
|
2506
2335
|
this.iframes = new WeakMap();
|
|
2507
2336
|
this.mutationCb = options.mutationCb;
|
|
2508
2337
|
}
|
|
2509
|
-
|
|
2338
|
+
addIframe(iframeEl) {
|
|
2510
2339
|
this.iframes.set(iframeEl, true);
|
|
2511
|
-
}
|
|
2512
|
-
|
|
2340
|
+
}
|
|
2341
|
+
addLoadListener(cb) {
|
|
2513
2342
|
this.loadListener = cb;
|
|
2514
|
-
}
|
|
2515
|
-
|
|
2343
|
+
}
|
|
2344
|
+
attachIframe(iframeEl, childSn) {
|
|
2516
2345
|
var _a;
|
|
2517
2346
|
this.mutationCb({
|
|
2518
2347
|
adds: [
|
|
@@ -2528,80 +2357,99 @@ var IframeManager = (function () {
|
|
|
2528
2357
|
isAttachIframe: true,
|
|
2529
2358
|
});
|
|
2530
2359
|
(_a = this.loadListener) === null || _a === void 0 ? void 0 : _a.call(this, iframeEl);
|
|
2531
|
-
}
|
|
2532
|
-
|
|
2533
|
-
}());
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2534
2362
|
|
|
2535
|
-
|
|
2536
|
-
|
|
2363
|
+
class ShadowDomManager {
|
|
2364
|
+
constructor(options) {
|
|
2537
2365
|
this.restorePatches = [];
|
|
2538
2366
|
this.mutationCb = options.mutationCb;
|
|
2539
2367
|
this.scrollCb = options.scrollCb;
|
|
2540
2368
|
this.bypassOptions = options.bypassOptions;
|
|
2541
2369
|
this.mirror = options.mirror;
|
|
2542
|
-
|
|
2370
|
+
const manager = this;
|
|
2543
2371
|
this.restorePatches.push(patch(HTMLElement.prototype, 'attachShadow', function (original) {
|
|
2544
2372
|
return function () {
|
|
2545
|
-
|
|
2373
|
+
const shadowRoot = original.apply(this, arguments);
|
|
2546
2374
|
if (this.shadowRoot)
|
|
2547
2375
|
manager.addShadowRoot(this.shadowRoot, this.ownerDocument);
|
|
2548
2376
|
return shadowRoot;
|
|
2549
2377
|
};
|
|
2550
2378
|
}));
|
|
2551
2379
|
}
|
|
2552
|
-
|
|
2553
|
-
initMutationObserver(
|
|
2554
|
-
initScrollObserver(
|
|
2555
|
-
}
|
|
2556
|
-
|
|
2380
|
+
addShadowRoot(shadowRoot, doc) {
|
|
2381
|
+
initMutationObserver(Object.assign(Object.assign({}, this.bypassOptions), { doc, mutationCb: this.mutationCb, mirror: this.mirror, shadowDomManager: this }), shadowRoot);
|
|
2382
|
+
initScrollObserver(Object.assign(Object.assign({}, this.bypassOptions), { scrollCb: this.scrollCb, doc: shadowRoot, mirror: this.mirror }));
|
|
2383
|
+
}
|
|
2384
|
+
observeAttachShadow(iframeElement) {
|
|
2557
2385
|
if (iframeElement.contentWindow) {
|
|
2558
|
-
|
|
2386
|
+
const manager = this;
|
|
2559
2387
|
this.restorePatches.push(patch(iframeElement.contentWindow.HTMLElement.prototype, 'attachShadow', function (original) {
|
|
2560
2388
|
return function () {
|
|
2561
|
-
|
|
2389
|
+
const shadowRoot = original.apply(this, arguments);
|
|
2562
2390
|
if (this.shadowRoot)
|
|
2563
|
-
|
|
2391
|
+
manager.addShadowRoot(this.shadowRoot, iframeElement.contentDocument);
|
|
2564
2392
|
return shadowRoot;
|
|
2565
2393
|
};
|
|
2566
2394
|
}));
|
|
2567
2395
|
}
|
|
2568
|
-
}
|
|
2569
|
-
|
|
2570
|
-
this.restorePatches.forEach(
|
|
2571
|
-
}
|
|
2572
|
-
|
|
2573
|
-
|
|
2396
|
+
}
|
|
2397
|
+
reset() {
|
|
2398
|
+
this.restorePatches.forEach((restorePatch) => restorePatch());
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
|
|
2402
|
+
/******************************************************************************
|
|
2403
|
+
Copyright (c) Microsoft Corporation.
|
|
2404
|
+
|
|
2405
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
2406
|
+
purpose with or without fee is hereby granted.
|
|
2407
|
+
|
|
2408
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
2409
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
2410
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
2411
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
2412
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
2413
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
2414
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
2415
|
+
***************************************************************************** */
|
|
2416
|
+
|
|
2417
|
+
function __rest(s, e) {
|
|
2418
|
+
var t = {};
|
|
2419
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
2420
|
+
t[p] = s[p];
|
|
2421
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
2422
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
2423
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
2424
|
+
t[p[i]] = s[p[i]];
|
|
2425
|
+
}
|
|
2426
|
+
return t;
|
|
2427
|
+
}
|
|
2574
2428
|
|
|
2575
2429
|
function initCanvas2DMutationObserver(cb, win, blockClass, mirror) {
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
var _loop_1 = function (prop) {
|
|
2430
|
+
const handlers = [];
|
|
2431
|
+
const props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
|
|
2432
|
+
for (const prop of props2D) {
|
|
2580
2433
|
try {
|
|
2581
2434
|
if (typeof win.CanvasRenderingContext2D.prototype[prop] !== 'function') {
|
|
2582
|
-
|
|
2435
|
+
continue;
|
|
2583
2436
|
}
|
|
2584
|
-
|
|
2585
|
-
return function () {
|
|
2586
|
-
var _this = this;
|
|
2587
|
-
var args = [];
|
|
2588
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2589
|
-
args[_i] = arguments[_i];
|
|
2590
|
-
}
|
|
2437
|
+
const restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function (original) {
|
|
2438
|
+
return function (...args) {
|
|
2591
2439
|
if (!isBlocked(this.canvas, blockClass)) {
|
|
2592
|
-
setTimeout(
|
|
2593
|
-
|
|
2440
|
+
setTimeout(() => {
|
|
2441
|
+
const recordArgs = [...args];
|
|
2594
2442
|
if (prop === 'drawImage') {
|
|
2595
2443
|
if (recordArgs[0] &&
|
|
2596
2444
|
recordArgs[0] instanceof HTMLCanvasElement) {
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2445
|
+
const canvas = recordArgs[0];
|
|
2446
|
+
const ctx = canvas.getContext('2d');
|
|
2447
|
+
let imgd = ctx === null || ctx === void 0 ? void 0 : ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
2448
|
+
let pix = imgd === null || imgd === void 0 ? void 0 : imgd.data;
|
|
2601
2449
|
recordArgs[0] = JSON.stringify(pix);
|
|
2602
2450
|
}
|
|
2603
2451
|
}
|
|
2604
|
-
cb(
|
|
2452
|
+
cb(this.canvas, {
|
|
2605
2453
|
type: CanvasContext['2D'],
|
|
2606
2454
|
property: prop,
|
|
2607
2455
|
args: recordArgs,
|
|
@@ -2613,9 +2461,9 @@ function initCanvas2DMutationObserver(cb, win, blockClass, mirror) {
|
|
|
2613
2461
|
});
|
|
2614
2462
|
handlers.push(restoreHandler);
|
|
2615
2463
|
}
|
|
2616
|
-
catch (
|
|
2617
|
-
|
|
2618
|
-
set
|
|
2464
|
+
catch (_a) {
|
|
2465
|
+
const hookHandler = hookSetter(win.CanvasRenderingContext2D.prototype, prop, {
|
|
2466
|
+
set(v) {
|
|
2619
2467
|
cb(this.canvas, {
|
|
2620
2468
|
type: CanvasContext['2D'],
|
|
2621
2469
|
property: prop,
|
|
@@ -2626,39 +2474,22 @@ function initCanvas2DMutationObserver(cb, win, blockClass, mirror) {
|
|
|
2626
2474
|
});
|
|
2627
2475
|
handlers.push(hookHandler);
|
|
2628
2476
|
}
|
|
2629
|
-
};
|
|
2630
|
-
try {
|
|
2631
|
-
for (var props2D_1 = __values(props2D), props2D_1_1 = props2D_1.next(); !props2D_1_1.done; props2D_1_1 = props2D_1.next()) {
|
|
2632
|
-
var prop = props2D_1_1.value;
|
|
2633
|
-
_loop_1(prop);
|
|
2634
|
-
}
|
|
2635
|
-
}
|
|
2636
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2637
|
-
finally {
|
|
2638
|
-
try {
|
|
2639
|
-
if (props2D_1_1 && !props2D_1_1.done && (_a = props2D_1.return)) _a.call(props2D_1);
|
|
2640
|
-
}
|
|
2641
|
-
finally { if (e_1) throw e_1.error; }
|
|
2642
2477
|
}
|
|
2643
|
-
return
|
|
2644
|
-
handlers.forEach(
|
|
2478
|
+
return () => {
|
|
2479
|
+
handlers.forEach((h) => h());
|
|
2645
2480
|
};
|
|
2646
2481
|
}
|
|
2647
2482
|
|
|
2648
2483
|
function initCanvasContextObserver(win, blockClass) {
|
|
2649
|
-
|
|
2484
|
+
const handlers = [];
|
|
2650
2485
|
try {
|
|
2651
|
-
|
|
2652
|
-
return function (contextType) {
|
|
2653
|
-
var args = [];
|
|
2654
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2655
|
-
args[_i - 1] = arguments[_i];
|
|
2656
|
-
}
|
|
2486
|
+
const restoreHandler = patch(win.HTMLCanvasElement.prototype, 'getContext', function (original) {
|
|
2487
|
+
return function (contextType, ...args) {
|
|
2657
2488
|
if (!isBlocked(this, blockClass)) {
|
|
2658
2489
|
if (!('__context' in this))
|
|
2659
2490
|
this.__context = contextType;
|
|
2660
2491
|
}
|
|
2661
|
-
return original.apply(this,
|
|
2492
|
+
return original.apply(this, [contextType, ...args]);
|
|
2662
2493
|
};
|
|
2663
2494
|
});
|
|
2664
2495
|
handlers.push(restoreHandler);
|
|
@@ -2666,14 +2497,14 @@ function initCanvasContextObserver(win, blockClass) {
|
|
|
2666
2497
|
catch (_a) {
|
|
2667
2498
|
console.error('failed to patch HTMLCanvasElement.prototype.getContext');
|
|
2668
2499
|
}
|
|
2669
|
-
return
|
|
2670
|
-
handlers.forEach(
|
|
2500
|
+
return () => {
|
|
2501
|
+
handlers.forEach((h) => h());
|
|
2671
2502
|
};
|
|
2672
2503
|
}
|
|
2673
2504
|
|
|
2674
2505
|
/*
|
|
2675
|
-
* base64-arraybuffer 1.0.
|
|
2676
|
-
* Copyright (c)
|
|
2506
|
+
* base64-arraybuffer 1.0.2 <https://github.com/niklasvh/base64-arraybuffer>
|
|
2507
|
+
* Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
|
|
2677
2508
|
* Released under MIT License
|
|
2678
2509
|
*/
|
|
2679
2510
|
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
@@ -2699,9 +2530,9 @@ var encode = function (arraybuffer) {
|
|
|
2699
2530
|
return base64;
|
|
2700
2531
|
};
|
|
2701
2532
|
|
|
2702
|
-
|
|
2533
|
+
const webGLVarMap = new Map();
|
|
2703
2534
|
function variableListFor(ctx, ctor) {
|
|
2704
|
-
|
|
2535
|
+
let contextMap = webGLVarMap.get(ctx);
|
|
2705
2536
|
if (!contextMap) {
|
|
2706
2537
|
contextMap = new Map();
|
|
2707
2538
|
webGLVarMap.set(ctx, contextMap);
|
|
@@ -2711,13 +2542,13 @@ function variableListFor(ctx, ctor) {
|
|
|
2711
2542
|
}
|
|
2712
2543
|
return contextMap.get(ctor);
|
|
2713
2544
|
}
|
|
2714
|
-
|
|
2545
|
+
const saveWebGLVar = (value, win, ctx) => {
|
|
2715
2546
|
if (!value ||
|
|
2716
2547
|
!(isInstanceOfWebGLObject(value, win) || typeof value === 'object'))
|
|
2717
2548
|
return;
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2549
|
+
const name = value.constructor.name;
|
|
2550
|
+
const list = variableListFor(ctx, name);
|
|
2551
|
+
let index = list.indexOf(value);
|
|
2721
2552
|
if (index === -1) {
|
|
2722
2553
|
index = list.length;
|
|
2723
2554
|
list.push(value);
|
|
@@ -2726,7 +2557,7 @@ var saveWebGLVar = function (value, win, ctx) {
|
|
|
2726
2557
|
};
|
|
2727
2558
|
function serializeArg(value, win, ctx) {
|
|
2728
2559
|
if (value instanceof Array) {
|
|
2729
|
-
return value.map(
|
|
2560
|
+
return value.map((arg) => serializeArg(arg, win, ctx));
|
|
2730
2561
|
}
|
|
2731
2562
|
else if (value === null) {
|
|
2732
2563
|
return value;
|
|
@@ -2740,24 +2571,24 @@ function serializeArg(value, win, ctx) {
|
|
|
2740
2571
|
value instanceof Int16Array ||
|
|
2741
2572
|
value instanceof Int8Array ||
|
|
2742
2573
|
value instanceof Uint8ClampedArray) {
|
|
2743
|
-
|
|
2574
|
+
const name = value.constructor.name;
|
|
2744
2575
|
return {
|
|
2745
|
-
rr_type:
|
|
2576
|
+
rr_type: name,
|
|
2746
2577
|
args: [Object.values(value)],
|
|
2747
2578
|
};
|
|
2748
2579
|
}
|
|
2749
2580
|
else if (value instanceof ArrayBuffer) {
|
|
2750
|
-
|
|
2751
|
-
|
|
2581
|
+
const name = value.constructor.name;
|
|
2582
|
+
const base64 = encode(value);
|
|
2752
2583
|
return {
|
|
2753
|
-
rr_type:
|
|
2754
|
-
base64
|
|
2584
|
+
rr_type: name,
|
|
2585
|
+
base64,
|
|
2755
2586
|
};
|
|
2756
2587
|
}
|
|
2757
2588
|
else if (value instanceof DataView) {
|
|
2758
|
-
|
|
2589
|
+
const name = value.constructor.name;
|
|
2759
2590
|
return {
|
|
2760
|
-
rr_type:
|
|
2591
|
+
rr_type: name,
|
|
2761
2592
|
args: [
|
|
2762
2593
|
serializeArg(value.buffer, win, ctx),
|
|
2763
2594
|
value.byteOffset,
|
|
@@ -2766,35 +2597,35 @@ function serializeArg(value, win, ctx) {
|
|
|
2766
2597
|
};
|
|
2767
2598
|
}
|
|
2768
2599
|
else if (value instanceof HTMLImageElement) {
|
|
2769
|
-
|
|
2770
|
-
|
|
2600
|
+
const name = value.constructor.name;
|
|
2601
|
+
const { src } = value;
|
|
2771
2602
|
return {
|
|
2772
|
-
rr_type:
|
|
2773
|
-
src
|
|
2603
|
+
rr_type: name,
|
|
2604
|
+
src,
|
|
2774
2605
|
};
|
|
2775
2606
|
}
|
|
2776
2607
|
else if (value instanceof ImageData) {
|
|
2777
|
-
|
|
2608
|
+
const name = value.constructor.name;
|
|
2778
2609
|
return {
|
|
2779
|
-
rr_type:
|
|
2610
|
+
rr_type: name,
|
|
2780
2611
|
args: [serializeArg(value.data, win, ctx), value.width, value.height],
|
|
2781
2612
|
};
|
|
2782
2613
|
}
|
|
2783
2614
|
else if (isInstanceOfWebGLObject(value, win) || typeof value === 'object') {
|
|
2784
|
-
|
|
2785
|
-
|
|
2615
|
+
const name = value.constructor.name;
|
|
2616
|
+
const index = saveWebGLVar(value, win, ctx);
|
|
2786
2617
|
return {
|
|
2787
|
-
rr_type:
|
|
2618
|
+
rr_type: name,
|
|
2788
2619
|
index: index,
|
|
2789
2620
|
};
|
|
2790
2621
|
}
|
|
2791
2622
|
return value;
|
|
2792
2623
|
}
|
|
2793
|
-
|
|
2794
|
-
return
|
|
2624
|
+
const serializeArgs = (args, win, ctx) => {
|
|
2625
|
+
return [...args].map((arg) => serializeArg(arg, win, ctx));
|
|
2795
2626
|
};
|
|
2796
|
-
|
|
2797
|
-
|
|
2627
|
+
const isInstanceOfWebGLObject = (value, win) => {
|
|
2628
|
+
const webGLConstructorNames = [
|
|
2798
2629
|
'WebGLActiveInfo',
|
|
2799
2630
|
'WebGLBuffer',
|
|
2800
2631
|
'WebGLFramebuffer',
|
|
@@ -2807,32 +2638,27 @@ var isInstanceOfWebGLObject = function (value, win) {
|
|
|
2807
2638
|
'WebGLVertexArrayObject',
|
|
2808
2639
|
'WebGLVertexArrayObjectOES',
|
|
2809
2640
|
];
|
|
2810
|
-
|
|
2811
|
-
return Boolean(supportedWebGLConstructorNames.find(
|
|
2641
|
+
const supportedWebGLConstructorNames = webGLConstructorNames.filter((name) => typeof win[name] === 'function');
|
|
2642
|
+
return Boolean(supportedWebGLConstructorNames.find((name) => value instanceof win[name]));
|
|
2812
2643
|
};
|
|
2813
2644
|
|
|
2814
2645
|
function patchGLPrototype(prototype, type, cb, blockClass, mirror, win) {
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
var _loop_1 = function (prop) {
|
|
2646
|
+
const handlers = [];
|
|
2647
|
+
const props = Object.getOwnPropertyNames(prototype);
|
|
2648
|
+
for (const prop of props) {
|
|
2819
2649
|
try {
|
|
2820
2650
|
if (typeof prototype[prop] !== 'function') {
|
|
2821
|
-
|
|
2651
|
+
continue;
|
|
2822
2652
|
}
|
|
2823
|
-
|
|
2824
|
-
return function () {
|
|
2825
|
-
|
|
2826
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2827
|
-
args[_i] = arguments[_i];
|
|
2828
|
-
}
|
|
2829
|
-
var result = original.apply(this, args);
|
|
2653
|
+
const restoreHandler = patch(prototype, prop, function (original) {
|
|
2654
|
+
return function (...args) {
|
|
2655
|
+
const result = original.apply(this, args);
|
|
2830
2656
|
saveWebGLVar(result, win, prototype);
|
|
2831
2657
|
if (!isBlocked(this.canvas, blockClass)) {
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
type
|
|
2658
|
+
const id = mirror.getId(this.canvas);
|
|
2659
|
+
const recordArgs = serializeArgs([...args], win, prototype);
|
|
2660
|
+
const mutation = {
|
|
2661
|
+
type,
|
|
2836
2662
|
property: prop,
|
|
2837
2663
|
args: recordArgs,
|
|
2838
2664
|
};
|
|
@@ -2843,11 +2669,11 @@ function patchGLPrototype(prototype, type, cb, blockClass, mirror, win) {
|
|
|
2843
2669
|
});
|
|
2844
2670
|
handlers.push(restoreHandler);
|
|
2845
2671
|
}
|
|
2846
|
-
catch (
|
|
2847
|
-
|
|
2848
|
-
set
|
|
2672
|
+
catch (_a) {
|
|
2673
|
+
const hookHandler = hookSetter(prototype, prop, {
|
|
2674
|
+
set(v) {
|
|
2849
2675
|
cb(this.canvas, {
|
|
2850
|
-
type
|
|
2676
|
+
type,
|
|
2851
2677
|
property: prop,
|
|
2852
2678
|
args: [v],
|
|
2853
2679
|
setter: true,
|
|
@@ -2856,41 +2682,44 @@ function patchGLPrototype(prototype, type, cb, blockClass, mirror, win) {
|
|
|
2856
2682
|
});
|
|
2857
2683
|
handlers.push(hookHandler);
|
|
2858
2684
|
}
|
|
2859
|
-
};
|
|
2860
|
-
try {
|
|
2861
|
-
for (var props_1 = __values(props), props_1_1 = props_1.next(); !props_1_1.done; props_1_1 = props_1.next()) {
|
|
2862
|
-
var prop = props_1_1.value;
|
|
2863
|
-
_loop_1(prop);
|
|
2864
|
-
}
|
|
2865
|
-
}
|
|
2866
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2867
|
-
finally {
|
|
2868
|
-
try {
|
|
2869
|
-
if (props_1_1 && !props_1_1.done && (_a = props_1.return)) _a.call(props_1);
|
|
2870
|
-
}
|
|
2871
|
-
finally { if (e_1) throw e_1.error; }
|
|
2872
2685
|
}
|
|
2873
2686
|
return handlers;
|
|
2874
2687
|
}
|
|
2875
2688
|
function initCanvasWebGLMutationObserver(cb, win, blockClass, mirror) {
|
|
2876
|
-
|
|
2877
|
-
handlers.push
|
|
2689
|
+
const handlers = [];
|
|
2690
|
+
handlers.push(...patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, mirror, win));
|
|
2878
2691
|
if (typeof win.WebGL2RenderingContext !== 'undefined') {
|
|
2879
|
-
handlers.push
|
|
2692
|
+
handlers.push(...patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, mirror, win));
|
|
2880
2693
|
}
|
|
2881
|
-
return
|
|
2882
|
-
handlers.forEach(
|
|
2694
|
+
return () => {
|
|
2695
|
+
handlers.forEach((h) => h());
|
|
2883
2696
|
};
|
|
2884
2697
|
}
|
|
2885
2698
|
|
|
2886
|
-
|
|
2887
|
-
|
|
2699
|
+
class CanvasManager {
|
|
2700
|
+
reset() {
|
|
2701
|
+
this.pendingCanvasMutations.clear();
|
|
2702
|
+
this.resetObservers && this.resetObservers();
|
|
2703
|
+
}
|
|
2704
|
+
freeze() {
|
|
2705
|
+
this.frozen = true;
|
|
2706
|
+
}
|
|
2707
|
+
unfreeze() {
|
|
2708
|
+
this.frozen = false;
|
|
2709
|
+
}
|
|
2710
|
+
lock() {
|
|
2711
|
+
this.locked = true;
|
|
2712
|
+
}
|
|
2713
|
+
unlock() {
|
|
2714
|
+
this.locked = false;
|
|
2715
|
+
}
|
|
2716
|
+
constructor(options) {
|
|
2888
2717
|
this.pendingCanvasMutations = new Map();
|
|
2889
2718
|
this.rafStamps = { latestId: 0, invokeId: null };
|
|
2890
2719
|
this.frozen = false;
|
|
2891
2720
|
this.locked = false;
|
|
2892
2721
|
this.processMutation = function (target, mutation) {
|
|
2893
|
-
|
|
2722
|
+
const newFrame = this.rafStamps.invokeId &&
|
|
2894
2723
|
this.rafStamps.latestId !== this.rafStamps.invokeId;
|
|
2895
2724
|
if (newFrame || !this.rafStamps.invokeId)
|
|
2896
2725
|
this.rafStamps.invokeId = this.rafStamps.latestId;
|
|
@@ -2904,88 +2733,67 @@ var CanvasManager = (function () {
|
|
|
2904
2733
|
if (options.recordCanvas === true)
|
|
2905
2734
|
this.initCanvasMutationObserver(options.win, options.blockClass);
|
|
2906
2735
|
}
|
|
2907
|
-
|
|
2908
|
-
this.pendingCanvasMutations.clear();
|
|
2909
|
-
this.resetObservers && this.resetObservers();
|
|
2910
|
-
};
|
|
2911
|
-
CanvasManager.prototype.freeze = function () {
|
|
2912
|
-
this.frozen = true;
|
|
2913
|
-
};
|
|
2914
|
-
CanvasManager.prototype.unfreeze = function () {
|
|
2915
|
-
this.frozen = false;
|
|
2916
|
-
};
|
|
2917
|
-
CanvasManager.prototype.lock = function () {
|
|
2918
|
-
this.locked = true;
|
|
2919
|
-
};
|
|
2920
|
-
CanvasManager.prototype.unlock = function () {
|
|
2921
|
-
this.locked = false;
|
|
2922
|
-
};
|
|
2923
|
-
CanvasManager.prototype.initCanvasMutationObserver = function (win, blockClass) {
|
|
2736
|
+
initCanvasMutationObserver(win, blockClass) {
|
|
2924
2737
|
this.startRAFTimestamping();
|
|
2925
2738
|
this.startPendingCanvasMutationFlusher();
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
this.resetObservers =
|
|
2739
|
+
const canvasContextReset = initCanvasContextObserver(win, blockClass);
|
|
2740
|
+
const canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, this.mirror);
|
|
2741
|
+
const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, this.mirror);
|
|
2742
|
+
this.resetObservers = () => {
|
|
2930
2743
|
canvasContextReset();
|
|
2931
2744
|
canvas2DReset();
|
|
2932
2745
|
canvasWebGL1and2Reset();
|
|
2933
2746
|
};
|
|
2934
|
-
}
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
var setLatestRAFTimestamp = function (timestamp) {
|
|
2942
|
-
_this.rafStamps.latestId = timestamp;
|
|
2747
|
+
}
|
|
2748
|
+
startPendingCanvasMutationFlusher() {
|
|
2749
|
+
requestAnimationFrame(() => this.flushPendingCanvasMutations());
|
|
2750
|
+
}
|
|
2751
|
+
startRAFTimestamping() {
|
|
2752
|
+
const setLatestRAFTimestamp = (timestamp) => {
|
|
2753
|
+
this.rafStamps.latestId = timestamp;
|
|
2943
2754
|
requestAnimationFrame(setLatestRAFTimestamp);
|
|
2944
2755
|
};
|
|
2945
2756
|
requestAnimationFrame(setLatestRAFTimestamp);
|
|
2946
|
-
}
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
_this.flushPendingCanvasMutationFor(canvas, id);
|
|
2757
|
+
}
|
|
2758
|
+
flushPendingCanvasMutations() {
|
|
2759
|
+
this.pendingCanvasMutations.forEach((values, canvas) => {
|
|
2760
|
+
const id = this.mirror.getId(canvas);
|
|
2761
|
+
this.flushPendingCanvasMutationFor(canvas, id);
|
|
2952
2762
|
});
|
|
2953
|
-
requestAnimationFrame(
|
|
2954
|
-
}
|
|
2955
|
-
|
|
2763
|
+
requestAnimationFrame(() => this.flushPendingCanvasMutations());
|
|
2764
|
+
}
|
|
2765
|
+
flushPendingCanvasMutationFor(canvas, id) {
|
|
2956
2766
|
if (this.frozen || this.locked) {
|
|
2957
2767
|
return;
|
|
2958
2768
|
}
|
|
2959
|
-
|
|
2769
|
+
const valuesWithType = this.pendingCanvasMutations.get(canvas);
|
|
2960
2770
|
if (!valuesWithType || id === -1)
|
|
2961
2771
|
return;
|
|
2962
|
-
|
|
2963
|
-
|
|
2772
|
+
const values = valuesWithType.map((value) => {
|
|
2773
|
+
const rest = __rest(value, ["type"]);
|
|
2964
2774
|
return rest;
|
|
2965
2775
|
});
|
|
2966
|
-
|
|
2967
|
-
this.mutationCb({ id
|
|
2776
|
+
const { type } = valuesWithType[0];
|
|
2777
|
+
this.mutationCb({ id, type, commands: values });
|
|
2968
2778
|
this.pendingCanvasMutations.delete(canvas);
|
|
2969
|
-
}
|
|
2970
|
-
|
|
2971
|
-
}());
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2972
2781
|
|
|
2973
2782
|
function wrapEvent(e) {
|
|
2974
|
-
return
|
|
2975
|
-
}
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
function record(options) {
|
|
2980
|
-
|
|
2981
|
-
var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _a = options.blockClass, blockClass = _a === void 0 ? 'rr-block' : _a, _b = options.blockSelector, blockSelector = _b === void 0 ? null : _b, _c = options.unblockSelector, unblockSelector = _c === void 0 ? null : _c, _d = options.ignoreClass, ignoreClass = _d === void 0 ? 'rr-ignore' : _d, _e = options.ignoreSelector, ignoreSelector = _e === void 0 ? null : _e, _f = options.maskTextClass, maskTextClass = _f === void 0 ? 'rr-mask' : _f, _g = options.maskTextSelector, maskTextSelector = _g === void 0 ? null : _g, _h = options.maskInputSelector, maskInputSelector = _h === void 0 ? null : _h, _j = options.unmaskTextSelector, unmaskTextSelector = _j === void 0 ? null : _j, _k = options.unmaskInputSelector, unmaskInputSelector = _k === void 0 ? null : _k, _l = options.inlineStylesheet, inlineStylesheet = _l === void 0 ? true : _l, maskAllInputs = options.maskAllInputs, _maskInputOptions = options.maskInputOptions, _slimDOMOptions = options.slimDOMOptions, maskInputFn = options.maskInputFn, maskTextFn = options.maskTextFn, hooks = options.hooks, packFn = options.packFn, _m = options.sampling, sampling = _m === void 0 ? {} : _m, mousemoveWait = options.mousemoveWait, _o = options.recordCanvas, recordCanvas = _o === void 0 ? false : _o, _p = options.userTriggeredOnInput, userTriggeredOnInput = _p === void 0 ? false : _p, _q = options.collectFonts, collectFonts = _q === void 0 ? false : _q, _r = options.inlineImages, inlineImages = _r === void 0 ? false : _r, plugins = options.plugins, _s = options.keepIframeSrcFn, keepIframeSrcFn = _s === void 0 ? function () { return false; } : _s;
|
|
2783
|
+
return Object.assign(Object.assign({}, e), { timestamp: Date.now() });
|
|
2784
|
+
}
|
|
2785
|
+
let wrappedEmit;
|
|
2786
|
+
let takeFullSnapshot;
|
|
2787
|
+
const mirror = createMirror();
|
|
2788
|
+
function record(options = {}) {
|
|
2789
|
+
const { emit, checkoutEveryNms, checkoutEveryNth, blockClass = 'rr-block', blockSelector = null, unblockSelector = null, ignoreClass = 'rr-ignore', ignoreSelector = null, maskTextClass = 'rr-mask', maskTextSelector = null, maskInputSelector = null, unmaskTextSelector = null, unmaskInputSelector = null, inlineStylesheet = true, maskAllInputs, maskInputOptions: _maskInputOptions, slimDOMOptions: _slimDOMOptions, maskInputFn, maskTextFn, hooks, packFn, sampling = {}, mousemoveWait, recordCanvas = false, userTriggeredOnInput = false, collectFonts = false, inlineImages = false, plugins, keepIframeSrcFn = () => false, } = options;
|
|
2982
2790
|
if (!emit) {
|
|
2983
2791
|
throw new Error('emit function is required');
|
|
2984
2792
|
}
|
|
2985
2793
|
if (mousemoveWait !== undefined && sampling.mousemove === undefined) {
|
|
2986
2794
|
sampling.mousemove = mousemoveWait;
|
|
2987
2795
|
}
|
|
2988
|
-
|
|
2796
|
+
const maskInputOptions = maskAllInputs === true
|
|
2989
2797
|
? {
|
|
2990
2798
|
color: true,
|
|
2991
2799
|
date: true,
|
|
@@ -3007,7 +2815,7 @@ function record(options) {
|
|
|
3007
2815
|
: _maskInputOptions !== undefined
|
|
3008
2816
|
? _maskInputOptions
|
|
3009
2817
|
: { password: true };
|
|
3010
|
-
|
|
2818
|
+
const slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === 'all'
|
|
3011
2819
|
? {
|
|
3012
2820
|
script: true,
|
|
3013
2821
|
comment: true,
|
|
@@ -3024,37 +2832,26 @@ function record(options) {
|
|
|
3024
2832
|
? _slimDOMOptions
|
|
3025
2833
|
: {};
|
|
3026
2834
|
polyfill();
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
var plugin = _c.value;
|
|
3034
|
-
if (plugin.eventProcessor) {
|
|
3035
|
-
e = plugin.eventProcessor(e);
|
|
3036
|
-
}
|
|
2835
|
+
let lastFullSnapshotEvent;
|
|
2836
|
+
let incrementalSnapshotCount = 0;
|
|
2837
|
+
const eventProcessor = (e) => {
|
|
2838
|
+
for (const plugin of plugins || []) {
|
|
2839
|
+
if (plugin.eventProcessor) {
|
|
2840
|
+
e = plugin.eventProcessor(e);
|
|
3037
2841
|
}
|
|
3038
2842
|
}
|
|
3039
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
3040
|
-
finally {
|
|
3041
|
-
try {
|
|
3042
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3043
|
-
}
|
|
3044
|
-
finally { if (e_1) throw e_1.error; }
|
|
3045
|
-
}
|
|
3046
2843
|
if (packFn) {
|
|
3047
2844
|
e = packFn(e);
|
|
3048
2845
|
}
|
|
3049
2846
|
return e;
|
|
3050
2847
|
};
|
|
3051
|
-
wrappedEmit =
|
|
2848
|
+
wrappedEmit = (e, isCheckout) => {
|
|
3052
2849
|
var _a;
|
|
3053
2850
|
if (((_a = mutationBuffers[0]) === null || _a === void 0 ? void 0 : _a.isFrozen()) &&
|
|
3054
2851
|
e.type !== EventType.FullSnapshot &&
|
|
3055
2852
|
!(e.type === EventType.IncrementalSnapshot &&
|
|
3056
2853
|
e.data.source === IncrementalSource.Mutation)) {
|
|
3057
|
-
mutationBuffers.forEach(
|
|
2854
|
+
mutationBuffers.forEach((buf) => buf.unfreeze());
|
|
3058
2855
|
}
|
|
3059
2856
|
emit(eventProcessor(e), isCheckout);
|
|
3060
2857
|
if (e.type === EventType.FullSnapshot) {
|
|
@@ -3067,70 +2864,65 @@ function record(options) {
|
|
|
3067
2864
|
return;
|
|
3068
2865
|
}
|
|
3069
2866
|
incrementalSnapshotCount++;
|
|
3070
|
-
|
|
3071
|
-
|
|
2867
|
+
const exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
|
|
2868
|
+
const exceedTime = checkoutEveryNms &&
|
|
3072
2869
|
e.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
|
|
3073
2870
|
if (exceedCount || exceedTime) {
|
|
3074
2871
|
takeFullSnapshot(true);
|
|
3075
2872
|
}
|
|
3076
2873
|
}
|
|
3077
2874
|
};
|
|
3078
|
-
|
|
2875
|
+
const wrappedMutationEmit = (m) => {
|
|
3079
2876
|
wrappedEmit(wrapEvent({
|
|
3080
2877
|
type: EventType.IncrementalSnapshot,
|
|
3081
|
-
data:
|
|
3082
|
-
}));
|
|
3083
|
-
};
|
|
3084
|
-
var wrappedScrollEmit = function (p) {
|
|
3085
|
-
return wrappedEmit(wrapEvent({
|
|
3086
|
-
type: EventType.IncrementalSnapshot,
|
|
3087
|
-
data: __assign({ source: IncrementalSource.Scroll }, p),
|
|
2878
|
+
data: Object.assign({ source: IncrementalSource.Mutation }, m),
|
|
3088
2879
|
}));
|
|
3089
2880
|
};
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
2881
|
+
const wrappedScrollEmit = (p) => wrappedEmit(wrapEvent({
|
|
2882
|
+
type: EventType.IncrementalSnapshot,
|
|
2883
|
+
data: Object.assign({ source: IncrementalSource.Scroll }, p),
|
|
2884
|
+
}));
|
|
2885
|
+
const wrappedCanvasMutationEmit = (p) => wrappedEmit(wrapEvent({
|
|
2886
|
+
type: EventType.IncrementalSnapshot,
|
|
2887
|
+
data: Object.assign({ source: IncrementalSource.CanvasMutation }, p),
|
|
2888
|
+
}));
|
|
2889
|
+
const iframeManager = new IframeManager({
|
|
3097
2890
|
mutationCb: wrappedMutationEmit,
|
|
3098
2891
|
});
|
|
3099
|
-
|
|
3100
|
-
recordCanvas
|
|
2892
|
+
const canvasManager = new CanvasManager({
|
|
2893
|
+
recordCanvas,
|
|
3101
2894
|
mutationCb: wrappedCanvasMutationEmit,
|
|
3102
2895
|
win: window,
|
|
3103
|
-
blockClass
|
|
3104
|
-
mirror
|
|
2896
|
+
blockClass,
|
|
2897
|
+
mirror,
|
|
3105
2898
|
});
|
|
3106
|
-
|
|
2899
|
+
const shadowDomManager = new ShadowDomManager({
|
|
3107
2900
|
mutationCb: wrappedMutationEmit,
|
|
3108
2901
|
scrollCb: wrappedScrollEmit,
|
|
3109
2902
|
bypassOptions: {
|
|
3110
|
-
blockClass
|
|
3111
|
-
blockSelector
|
|
3112
|
-
unblockSelector
|
|
3113
|
-
maskTextClass
|
|
3114
|
-
maskTextSelector
|
|
3115
|
-
unmaskTextSelector
|
|
3116
|
-
maskInputSelector
|
|
3117
|
-
unmaskInputSelector
|
|
3118
|
-
inlineStylesheet
|
|
3119
|
-
maskInputOptions
|
|
3120
|
-
maskTextFn
|
|
3121
|
-
maskInputFn
|
|
3122
|
-
recordCanvas
|
|
3123
|
-
inlineImages
|
|
3124
|
-
sampling
|
|
3125
|
-
slimDOMOptions
|
|
3126
|
-
iframeManager
|
|
3127
|
-
canvasManager
|
|
2903
|
+
blockClass,
|
|
2904
|
+
blockSelector,
|
|
2905
|
+
unblockSelector,
|
|
2906
|
+
maskTextClass,
|
|
2907
|
+
maskTextSelector,
|
|
2908
|
+
unmaskTextSelector,
|
|
2909
|
+
maskInputSelector,
|
|
2910
|
+
unmaskInputSelector,
|
|
2911
|
+
inlineStylesheet,
|
|
2912
|
+
maskInputOptions,
|
|
2913
|
+
maskTextFn,
|
|
2914
|
+
maskInputFn,
|
|
2915
|
+
recordCanvas,
|
|
2916
|
+
inlineImages,
|
|
2917
|
+
sampling,
|
|
2918
|
+
slimDOMOptions,
|
|
2919
|
+
iframeManager,
|
|
2920
|
+
canvasManager,
|
|
3128
2921
|
},
|
|
3129
|
-
mirror
|
|
2922
|
+
mirror,
|
|
3130
2923
|
});
|
|
3131
|
-
takeFullSnapshot =
|
|
2924
|
+
takeFullSnapshot = (isCheckout = false) => {
|
|
3132
2925
|
var _a, _b, _c, _d;
|
|
3133
|
-
if (isCheckout === void 0) { isCheckout = false; }
|
|
3134
2926
|
wrappedEmit(wrapEvent({
|
|
3135
2927
|
type: EventType.Meta,
|
|
3136
2928
|
data: {
|
|
@@ -3139,23 +2931,23 @@ function record(options) {
|
|
|
3139
2931
|
height: getWindowHeight(),
|
|
3140
2932
|
},
|
|
3141
2933
|
}), isCheckout);
|
|
3142
|
-
mutationBuffers.forEach(
|
|
3143
|
-
|
|
3144
|
-
blockClass
|
|
3145
|
-
blockSelector
|
|
3146
|
-
unblockSelector
|
|
3147
|
-
maskTextClass
|
|
3148
|
-
maskTextSelector
|
|
3149
|
-
unmaskTextSelector
|
|
3150
|
-
maskInputSelector
|
|
3151
|
-
unmaskInputSelector
|
|
3152
|
-
inlineStylesheet
|
|
2934
|
+
mutationBuffers.forEach((buf) => buf.lock());
|
|
2935
|
+
const [node, idNodeMap] = snapshot(document, {
|
|
2936
|
+
blockClass,
|
|
2937
|
+
blockSelector,
|
|
2938
|
+
unblockSelector,
|
|
2939
|
+
maskTextClass,
|
|
2940
|
+
maskTextSelector,
|
|
2941
|
+
unmaskTextSelector,
|
|
2942
|
+
maskInputSelector,
|
|
2943
|
+
unmaskInputSelector,
|
|
2944
|
+
inlineStylesheet,
|
|
3153
2945
|
maskAllInputs: maskInputOptions,
|
|
3154
|
-
maskTextFn
|
|
2946
|
+
maskTextFn,
|
|
3155
2947
|
slimDOM: slimDOMOptions,
|
|
3156
|
-
recordCanvas
|
|
3157
|
-
inlineImages
|
|
3158
|
-
onSerialize:
|
|
2948
|
+
recordCanvas,
|
|
2949
|
+
inlineImages,
|
|
2950
|
+
onSerialize: (n) => {
|
|
3159
2951
|
if (isIframeINode(n)) {
|
|
3160
2952
|
iframeManager.addIframe(n);
|
|
3161
2953
|
}
|
|
@@ -3163,12 +2955,12 @@ function record(options) {
|
|
|
3163
2955
|
shadowDomManager.addShadowRoot(n.shadowRoot, document);
|
|
3164
2956
|
}
|
|
3165
2957
|
},
|
|
3166
|
-
onIframeLoad:
|
|
2958
|
+
onIframeLoad: (iframe, childSn) => {
|
|
3167
2959
|
iframeManager.attachIframe(iframe, childSn);
|
|
3168
2960
|
shadowDomManager.observeAttachShadow(iframe);
|
|
3169
2961
|
},
|
|
3170
|
-
keepIframeSrcFn
|
|
3171
|
-
})
|
|
2962
|
+
keepIframeSrcFn,
|
|
2963
|
+
});
|
|
3172
2964
|
if (!node) {
|
|
3173
2965
|
return console.warn('Failed to snapshot the document');
|
|
3174
2966
|
}
|
|
@@ -3176,7 +2968,7 @@ function record(options) {
|
|
|
3176
2968
|
wrappedEmit(wrapEvent({
|
|
3177
2969
|
type: EventType.FullSnapshot,
|
|
3178
2970
|
data: {
|
|
3179
|
-
node
|
|
2971
|
+
node,
|
|
3180
2972
|
initialOffset: {
|
|
3181
2973
|
left: window.pageXOffset !== undefined
|
|
3182
2974
|
? window.pageXOffset
|
|
@@ -3193,162 +2985,144 @@ function record(options) {
|
|
|
3193
2985
|
},
|
|
3194
2986
|
},
|
|
3195
2987
|
}));
|
|
3196
|
-
mutationBuffers.forEach(
|
|
2988
|
+
mutationBuffers.forEach((buf) => buf.unlock());
|
|
3197
2989
|
};
|
|
3198
2990
|
try {
|
|
3199
|
-
|
|
3200
|
-
|
|
2991
|
+
const handlers = [];
|
|
2992
|
+
handlers.push(on('DOMContentLoaded', () => {
|
|
3201
2993
|
wrappedEmit(wrapEvent({
|
|
3202
2994
|
type: EventType.DomContentLoaded,
|
|
3203
2995
|
data: {},
|
|
3204
2996
|
}));
|
|
3205
2997
|
}));
|
|
3206
|
-
|
|
2998
|
+
const observe = (doc) => {
|
|
3207
2999
|
var _a;
|
|
3208
|
-
return initObservers({
|
|
3000
|
+
return callbackWrapper(initObservers)({
|
|
3209
3001
|
mutationCb: wrappedMutationEmit,
|
|
3210
|
-
mousemoveCb:
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
type: EventType.IncrementalSnapshot,
|
|
3222
|
-
data: __assign({ source: IncrementalSource.MouseInteraction }, d),
|
|
3223
|
-
}));
|
|
3224
|
-
},
|
|
3002
|
+
mousemoveCb: (positions, source) => wrappedEmit(wrapEvent({
|
|
3003
|
+
type: EventType.IncrementalSnapshot,
|
|
3004
|
+
data: {
|
|
3005
|
+
source,
|
|
3006
|
+
positions,
|
|
3007
|
+
},
|
|
3008
|
+
})),
|
|
3009
|
+
mouseInteractionCb: (d) => wrappedEmit(wrapEvent({
|
|
3010
|
+
type: EventType.IncrementalSnapshot,
|
|
3011
|
+
data: Object.assign({ source: IncrementalSource.MouseInteraction }, d),
|
|
3012
|
+
})),
|
|
3225
3013
|
scrollCb: wrappedScrollEmit,
|
|
3226
|
-
viewportResizeCb:
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
})
|
|
3237
|
-
},
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
type: EventType.IncrementalSnapshot,
|
|
3247
|
-
data: __assign({ source: IncrementalSource.StyleSheetRule }, r),
|
|
3248
|
-
}));
|
|
3249
|
-
},
|
|
3250
|
-
styleDeclarationCb: function (r) {
|
|
3251
|
-
return wrappedEmit(wrapEvent({
|
|
3252
|
-
type: EventType.IncrementalSnapshot,
|
|
3253
|
-
data: __assign({ source: IncrementalSource.StyleDeclaration }, r),
|
|
3254
|
-
}));
|
|
3255
|
-
},
|
|
3014
|
+
viewportResizeCb: (d) => wrappedEmit(wrapEvent({
|
|
3015
|
+
type: EventType.IncrementalSnapshot,
|
|
3016
|
+
data: Object.assign({ source: IncrementalSource.ViewportResize }, d),
|
|
3017
|
+
})),
|
|
3018
|
+
inputCb: (v) => wrappedEmit(wrapEvent({
|
|
3019
|
+
type: EventType.IncrementalSnapshot,
|
|
3020
|
+
data: Object.assign({ source: IncrementalSource.Input }, v),
|
|
3021
|
+
})),
|
|
3022
|
+
mediaInteractionCb: (p) => wrappedEmit(wrapEvent({
|
|
3023
|
+
type: EventType.IncrementalSnapshot,
|
|
3024
|
+
data: Object.assign({ source: IncrementalSource.MediaInteraction }, p),
|
|
3025
|
+
})),
|
|
3026
|
+
styleSheetRuleCb: (r) => wrappedEmit(wrapEvent({
|
|
3027
|
+
type: EventType.IncrementalSnapshot,
|
|
3028
|
+
data: Object.assign({ source: IncrementalSource.StyleSheetRule }, r),
|
|
3029
|
+
})),
|
|
3030
|
+
styleDeclarationCb: (r) => wrappedEmit(wrapEvent({
|
|
3031
|
+
type: EventType.IncrementalSnapshot,
|
|
3032
|
+
data: Object.assign({ source: IncrementalSource.StyleDeclaration }, r),
|
|
3033
|
+
})),
|
|
3256
3034
|
canvasMutationCb: wrappedCanvasMutationEmit,
|
|
3257
|
-
fontCb:
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
canvasManager: canvasManager,
|
|
3288
|
-
plugins: ((_a = plugins === null || plugins === void 0 ? void 0 : plugins.filter(function (p) { return p.observer; })) === null || _a === void 0 ? void 0 : _a.map(function (p) { return ({
|
|
3035
|
+
fontCb: (p) => wrappedEmit(wrapEvent({
|
|
3036
|
+
type: EventType.IncrementalSnapshot,
|
|
3037
|
+
data: Object.assign({ source: IncrementalSource.Font }, p),
|
|
3038
|
+
})),
|
|
3039
|
+
blockClass,
|
|
3040
|
+
ignoreClass,
|
|
3041
|
+
ignoreSelector,
|
|
3042
|
+
maskTextClass,
|
|
3043
|
+
maskTextSelector,
|
|
3044
|
+
unmaskTextSelector,
|
|
3045
|
+
maskInputSelector,
|
|
3046
|
+
unmaskInputSelector,
|
|
3047
|
+
maskInputOptions,
|
|
3048
|
+
inlineStylesheet,
|
|
3049
|
+
sampling,
|
|
3050
|
+
recordCanvas,
|
|
3051
|
+
inlineImages,
|
|
3052
|
+
userTriggeredOnInput,
|
|
3053
|
+
collectFonts,
|
|
3054
|
+
doc,
|
|
3055
|
+
maskInputFn,
|
|
3056
|
+
maskTextFn,
|
|
3057
|
+
blockSelector,
|
|
3058
|
+
unblockSelector,
|
|
3059
|
+
slimDOMOptions,
|
|
3060
|
+
mirror,
|
|
3061
|
+
iframeManager,
|
|
3062
|
+
shadowDomManager,
|
|
3063
|
+
canvasManager,
|
|
3064
|
+
plugins: ((_a = plugins === null || plugins === void 0 ? void 0 : plugins.filter((p) => p.observer)) === null || _a === void 0 ? void 0 : _a.map((p) => ({
|
|
3289
3065
|
observer: p.observer,
|
|
3290
3066
|
options: p.options,
|
|
3291
|
-
callback:
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
},
|
|
3300
|
-
}); })) || [],
|
|
3067
|
+
callback: (payload) => wrappedEmit(wrapEvent({
|
|
3068
|
+
type: EventType.Plugin,
|
|
3069
|
+
data: {
|
|
3070
|
+
plugin: p.name,
|
|
3071
|
+
payload,
|
|
3072
|
+
},
|
|
3073
|
+
})),
|
|
3074
|
+
}))) || [],
|
|
3301
3075
|
}, hooks);
|
|
3302
3076
|
};
|
|
3303
|
-
iframeManager.addLoadListener(
|
|
3077
|
+
iframeManager.addLoadListener((iframeEl) => {
|
|
3304
3078
|
try {
|
|
3305
|
-
|
|
3079
|
+
handlers.push(observe(iframeEl.contentDocument));
|
|
3306
3080
|
}
|
|
3307
3081
|
catch (error) {
|
|
3308
3082
|
console.warn(error);
|
|
3309
3083
|
}
|
|
3310
3084
|
});
|
|
3311
|
-
|
|
3085
|
+
const init = () => {
|
|
3312
3086
|
takeFullSnapshot();
|
|
3313
|
-
|
|
3087
|
+
handlers.push(observe(document));
|
|
3314
3088
|
};
|
|
3315
3089
|
if (document.readyState === 'interactive' ||
|
|
3316
3090
|
document.readyState === 'complete') {
|
|
3317
|
-
|
|
3091
|
+
init();
|
|
3318
3092
|
}
|
|
3319
3093
|
else {
|
|
3320
|
-
|
|
3094
|
+
handlers.push(on('load', () => {
|
|
3321
3095
|
wrappedEmit(wrapEvent({
|
|
3322
3096
|
type: EventType.Load,
|
|
3323
3097
|
data: {},
|
|
3324
3098
|
}));
|
|
3325
|
-
|
|
3099
|
+
init();
|
|
3326
3100
|
}, window));
|
|
3327
3101
|
}
|
|
3328
|
-
return
|
|
3329
|
-
|
|
3102
|
+
return () => {
|
|
3103
|
+
handlers.forEach((h) => h());
|
|
3330
3104
|
};
|
|
3331
3105
|
}
|
|
3332
3106
|
catch (error) {
|
|
3333
3107
|
console.warn(error);
|
|
3334
3108
|
}
|
|
3335
3109
|
}
|
|
3336
|
-
record.addCustomEvent =
|
|
3110
|
+
record.addCustomEvent = (tag, payload) => {
|
|
3337
3111
|
if (!wrappedEmit) {
|
|
3338
3112
|
throw new Error('please add custom event after start recording');
|
|
3339
3113
|
}
|
|
3340
3114
|
wrappedEmit(wrapEvent({
|
|
3341
3115
|
type: EventType.Custom,
|
|
3342
3116
|
data: {
|
|
3343
|
-
tag
|
|
3344
|
-
payload
|
|
3117
|
+
tag,
|
|
3118
|
+
payload,
|
|
3345
3119
|
},
|
|
3346
3120
|
}));
|
|
3347
3121
|
};
|
|
3348
|
-
record.freezePage =
|
|
3349
|
-
mutationBuffers.forEach(
|
|
3122
|
+
record.freezePage = () => {
|
|
3123
|
+
mutationBuffers.forEach((buf) => buf.freeze());
|
|
3350
3124
|
};
|
|
3351
|
-
record.takeFullSnapshot =
|
|
3125
|
+
record.takeFullSnapshot = (isCheckout) => {
|
|
3352
3126
|
if (!takeFullSnapshot) {
|
|
3353
3127
|
throw new Error('please take full snapshot after start recording');
|
|
3354
3128
|
}
|
|
@@ -4042,6 +3816,12 @@ async function addEvent(
|
|
|
4042
3816
|
} catch (error) {
|
|
4043
3817
|
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.error(error);
|
|
4044
3818
|
replay.stop();
|
|
3819
|
+
|
|
3820
|
+
const client = core.getCurrentHub().getClient();
|
|
3821
|
+
|
|
3822
|
+
if (client) {
|
|
3823
|
+
client.recordDroppedEvent('internal_sdk_error', 'replay');
|
|
3824
|
+
}
|
|
4045
3825
|
}
|
|
4046
3826
|
}
|
|
4047
3827
|
|
|
@@ -4246,11 +4026,16 @@ function handleFetchSpanListener(replay) {
|
|
|
4246
4026
|
/**
|
|
4247
4027
|
* Returns true if we think the given event is an error originating inside of rrweb.
|
|
4248
4028
|
*/
|
|
4249
|
-
function isRrwebError(event) {
|
|
4029
|
+
function isRrwebError(event, hint) {
|
|
4250
4030
|
if (event.type || !event.exception || !event.exception.values || !event.exception.values.length) {
|
|
4251
4031
|
return false;
|
|
4252
4032
|
}
|
|
4253
4033
|
|
|
4034
|
+
// @ts-ignore this may be set by rrweb when it finds errors
|
|
4035
|
+
if (hint.originalException && hint.originalException.__rrweb__) {
|
|
4036
|
+
return true;
|
|
4037
|
+
}
|
|
4038
|
+
|
|
4254
4039
|
// Check if any exception originates from rrweb
|
|
4255
4040
|
return event.exception.values.some(exception => {
|
|
4256
4041
|
if (!exception.stacktrace || !exception.stacktrace.frames || !exception.stacktrace.frames.length) {
|
|
@@ -4265,7 +4050,7 @@ function isRrwebError(event) {
|
|
|
4265
4050
|
* Returns a listener to be added to `addGlobalEventProcessor(listener)`.
|
|
4266
4051
|
*/
|
|
4267
4052
|
function handleGlobalEventListener(replay) {
|
|
4268
|
-
return (event) => {
|
|
4053
|
+
return (event, hint) => {
|
|
4269
4054
|
// Do not apply replayId to the root event
|
|
4270
4055
|
if (event.type === REPLAY_EVENT_NAME) {
|
|
4271
4056
|
// Replays have separate set of breadcrumbs, do not include breadcrumbs
|
|
@@ -4276,7 +4061,7 @@ function handleGlobalEventListener(replay) {
|
|
|
4276
4061
|
|
|
4277
4062
|
// Unless `captureExceptions` is enabled, we want to ignore errors coming from rrweb
|
|
4278
4063
|
// As there can be a bunch of stuff going wrong in internals there, that we don't want to bubble up to users
|
|
4279
|
-
if (isRrwebError(event) && !replay.getOptions()._experiments.captureExceptions) {
|
|
4064
|
+
if (isRrwebError(event, hint) && !replay.getOptions()._experiments.captureExceptions) {
|
|
4280
4065
|
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.log('[Replay] Ignoring error from rrweb internals', event);
|
|
4281
4066
|
return null;
|
|
4282
4067
|
}
|
|
@@ -5845,9 +5630,16 @@ class ReplayContainer {
|
|
|
5845
5630
|
} catch (err) {
|
|
5846
5631
|
this._handleException(err);
|
|
5847
5632
|
|
|
5848
|
-
// This means we retried 3 times
|
|
5633
|
+
// This means we retried 3 times and all of them failed,
|
|
5634
|
+
// or we ran into a problem we don't want to retry, like rate limiting.
|
|
5849
5635
|
// In this case, we want to completely stop the replay - otherwise, we may get inconsistent segments
|
|
5850
5636
|
this.stop();
|
|
5637
|
+
|
|
5638
|
+
const client = core.getCurrentHub().getClient();
|
|
5639
|
+
|
|
5640
|
+
if (client) {
|
|
5641
|
+
client.recordDroppedEvent('send_error', 'replay');
|
|
5642
|
+
}
|
|
5851
5643
|
}
|
|
5852
5644
|
}
|
|
5853
5645
|
|