@highlight-run/rrweb 2.0.11 → 2.0.12

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.
Files changed (41) hide show
  1. package/dist/plugins/console-record.js +5 -5
  2. package/dist/plugins/console-record.min.js +5 -5
  3. package/dist/plugins/console-record.min.js.map +1 -1
  4. package/dist/plugins/console-replay.js +3 -3
  5. package/dist/plugins/console-replay.min.js +3 -3
  6. package/dist/plugins/console-replay.min.js.map +1 -1
  7. package/dist/record/rrweb-record-pack.js +2 -2
  8. package/dist/record/rrweb-record-pack.min.js +2 -2
  9. package/dist/record/rrweb-record-pack.min.js.map +1 -1
  10. package/dist/record/rrweb-record.js +3 -3
  11. package/dist/record/rrweb-record.min.js +3 -3
  12. package/dist/record/rrweb-record.min.js.map +1 -1
  13. package/dist/replay/rrweb-replay-unpack.js +4 -3
  14. package/dist/replay/rrweb-replay-unpack.min.js +4 -3
  15. package/dist/replay/rrweb-replay-unpack.min.js.map +1 -1
  16. package/dist/replay/rrweb-replay.js +4 -3
  17. package/dist/replay/rrweb-replay.min.js +4 -3
  18. package/dist/replay/rrweb-replay.min.js.map +1 -1
  19. package/dist/rrweb-all.js +25 -24
  20. package/dist/rrweb-all.min.js +25 -24
  21. package/dist/rrweb-all.min.js.map +1 -1
  22. package/dist/rrweb.js +15 -14
  23. package/dist/rrweb.min.js +15 -14
  24. package/dist/rrweb.min.js.map +1 -1
  25. package/es/rrweb/packages/rrdom/es/virtual-dom.js +63 -1
  26. package/es/rrweb/packages/rrweb/src/index.js +1 -1
  27. package/es/rrweb/packages/rrweb/src/record/index.js +1 -1
  28. package/es/rrweb/packages/rrweb/src/record/mutation.js +1 -1
  29. package/es/rrweb/packages/rrweb/src/record/observer.js +1 -1
  30. package/es/rrweb/packages/rrweb/src/replay/index.js +1 -1
  31. package/es/rrweb/packages/rrweb/src/utils.js +1 -1
  32. package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +1871 -0
  33. package/lib/plugins/console-record.js +9 -1
  34. package/lib/plugins/console-replay.js +9 -1
  35. package/lib/record/rrweb-record-pack.js +9 -3
  36. package/lib/record/rrweb-record.js +1063 -17
  37. package/lib/replay/rrweb-replay-unpack.js +999 -47
  38. package/lib/replay/rrweb-replay.js +999 -47
  39. package/lib/rrweb-all.js +2020 -88
  40. package/lib/rrweb.js +2020 -88
  41. package/package.json +3 -3
@@ -1,6 +1,1052 @@
1
1
  'use strict';
2
2
 
3
- var rrwebSnapshot = require('@highlight-run/rrweb-snapshot');
3
+ var NodeType;
4
+ (function (NodeType) {
5
+ NodeType[NodeType["Document"] = 0] = "Document";
6
+ NodeType[NodeType["DocumentType"] = 1] = "DocumentType";
7
+ NodeType[NodeType["Element"] = 2] = "Element";
8
+ NodeType[NodeType["Text"] = 3] = "Text";
9
+ NodeType[NodeType["CDATA"] = 4] = "CDATA";
10
+ NodeType[NodeType["Comment"] = 5] = "Comment";
11
+ })(NodeType || (NodeType = {}));
12
+
13
+ function isElement(n) {
14
+ return n.nodeType === n.ELEMENT_NODE;
15
+ }
16
+ function isShadowRoot(n) {
17
+ var _a;
18
+ var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;
19
+ return Boolean((host === null || host === void 0 ? void 0 : host.shadowRoot) === n);
20
+ }
21
+ var Mirror = (function () {
22
+ function Mirror() {
23
+ this.idNodeMap = new Map();
24
+ this.nodeMetaMap = new WeakMap();
25
+ }
26
+ Mirror.prototype.getId = function (n) {
27
+ var _a;
28
+ if (!n)
29
+ return -1;
30
+ var id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id;
31
+ return id !== null && id !== void 0 ? id : -1;
32
+ };
33
+ Mirror.prototype.getNode = function (id) {
34
+ return this.idNodeMap.get(id) || null;
35
+ };
36
+ Mirror.prototype.getIds = function () {
37
+ return Array.from(this.idNodeMap.keys());
38
+ };
39
+ Mirror.prototype.getMeta = function (n) {
40
+ return this.nodeMetaMap.get(n) || null;
41
+ };
42
+ Mirror.prototype.removeNodeFromMap = function (n) {
43
+ var _this = this;
44
+ var id = this.getId(n);
45
+ this.idNodeMap["delete"](id);
46
+ if (n.childNodes) {
47
+ n.childNodes.forEach(function (childNode) {
48
+ return _this.removeNodeFromMap(childNode);
49
+ });
50
+ }
51
+ };
52
+ Mirror.prototype.has = function (id) {
53
+ return this.idNodeMap.has(id);
54
+ };
55
+ Mirror.prototype.hasNode = function (node) {
56
+ return this.nodeMetaMap.has(node);
57
+ };
58
+ Mirror.prototype.add = function (n, meta) {
59
+ var id = meta.id;
60
+ this.idNodeMap.set(id, n);
61
+ this.nodeMetaMap.set(n, meta);
62
+ };
63
+ Mirror.prototype.replace = function (id, n) {
64
+ this.idNodeMap.set(id, n);
65
+ };
66
+ Mirror.prototype.reset = function () {
67
+ this.idNodeMap = new Map();
68
+ this.nodeMetaMap = new WeakMap();
69
+ };
70
+ return Mirror;
71
+ }());
72
+ function createMirror() {
73
+ return new Mirror();
74
+ }
75
+ function maskInputValue(_a) {
76
+ var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;
77
+ var text = value || '';
78
+ if (maskInputOptions[tagName.toLowerCase()] ||
79
+ maskInputOptions[type]) {
80
+ if (maskInputFn) {
81
+ text = maskInputFn(text);
82
+ }
83
+ else {
84
+ text = '*'.repeat(text.length);
85
+ }
86
+ }
87
+ return text;
88
+ }
89
+ var ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';
90
+ function is2DCanvasBlank(canvas) {
91
+ var ctx = canvas.getContext('2d');
92
+ if (!ctx)
93
+ return true;
94
+ var chunkSize = 50;
95
+ for (var x = 0; x < canvas.width; x += chunkSize) {
96
+ for (var y = 0; y < canvas.height; y += chunkSize) {
97
+ var getImageData = ctx.getImageData;
98
+ var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData
99
+ ? getImageData[ORIGINAL_ATTRIBUTE_NAME]
100
+ : getImageData;
101
+ var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);
102
+ if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))
103
+ return false;
104
+ }
105
+ }
106
+ return true;
107
+ }
108
+ function obfuscateText(text) {
109
+ text = text.replace(/[^ -~]+/g, '');
110
+ text =
111
+ (text === null || text === void 0 ? void 0 : text.split(' ').map(function (word) { return Math.random().toString(20).substr(2, word.length); }).join(' ')) || '';
112
+ return text;
113
+ }
114
+
115
+ var _id = 1;
116
+ var tagNameRegex = new RegExp('[^a-z0-9-_:]');
117
+ var IGNORED_NODE = -2;
118
+ function genId() {
119
+ return _id++;
120
+ }
121
+ function getValidTagName(element) {
122
+ if (element instanceof HTMLFormElement) {
123
+ return 'form';
124
+ }
125
+ var processedTagName = element.tagName.toLowerCase().trim();
126
+ if (tagNameRegex.test(processedTagName)) {
127
+ return 'div';
128
+ }
129
+ return processedTagName;
130
+ }
131
+ function getCssRulesString(s) {
132
+ try {
133
+ var rules = s.rules || s.cssRules;
134
+ return rules ? Array.from(rules).map(getCssRuleString).join('') : null;
135
+ }
136
+ catch (error) {
137
+ return null;
138
+ }
139
+ }
140
+ function getCssRuleString(rule) {
141
+ var cssStringified = rule.cssText;
142
+ if (isCSSImportRule(rule)) {
143
+ try {
144
+ cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;
145
+ }
146
+ catch (_a) {
147
+ }
148
+ }
149
+ return cssStringified;
150
+ }
151
+ function isCSSImportRule(rule) {
152
+ return 'styleSheet' in rule;
153
+ }
154
+ function stringifyStyleSheet(sheet) {
155
+ return sheet.cssRules
156
+ ? Array.from(sheet.cssRules)
157
+ .map(function (rule) { return rule.cssText || ''; })
158
+ .join('')
159
+ : '';
160
+ }
161
+ function extractOrigin(url) {
162
+ var origin = '';
163
+ if (url.indexOf('//') > -1) {
164
+ origin = url.split('/').slice(0, 3).join('/');
165
+ }
166
+ else {
167
+ origin = url.split('/')[0];
168
+ }
169
+ origin = origin.split('?')[0];
170
+ return origin;
171
+ }
172
+ var canvasService;
173
+ var canvasCtx;
174
+ var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
175
+ var RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/;
176
+ var DATA_URI = /^(data:)([^,]*),(.*)/i;
177
+ function absoluteToStylesheet(cssText, href) {
178
+ return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {
179
+ var filePath = path1 || path2 || path3;
180
+ var maybeQuote = quote1 || quote2 || '';
181
+ if (!filePath) {
182
+ return origin;
183
+ }
184
+ if (!RELATIVE_PATH.test(filePath)) {
185
+ return "url(" + maybeQuote + filePath + maybeQuote + ")";
186
+ }
187
+ if (DATA_URI.test(filePath)) {
188
+ return "url(" + maybeQuote + filePath + maybeQuote + ")";
189
+ }
190
+ if (filePath[0] === '/') {
191
+ return "url(" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + ")";
192
+ }
193
+ var stack = href.split('/');
194
+ var parts = filePath.split('/');
195
+ stack.pop();
196
+ for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
197
+ var part = parts_1[_i];
198
+ if (part === '.') {
199
+ continue;
200
+ }
201
+ else if (part === '..') {
202
+ stack.pop();
203
+ }
204
+ else {
205
+ stack.push(part);
206
+ }
207
+ }
208
+ return "url(" + maybeQuote + stack.join('/') + maybeQuote + ")";
209
+ });
210
+ }
211
+ var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
212
+ var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
213
+ function getAbsoluteSrcsetString(doc, attributeValue) {
214
+ if (attributeValue.trim() === '') {
215
+ return attributeValue;
216
+ }
217
+ var pos = 0;
218
+ function collectCharacters(regEx) {
219
+ var chars;
220
+ var match = regEx.exec(attributeValue.substring(pos));
221
+ if (match) {
222
+ chars = match[0];
223
+ pos += chars.length;
224
+ return chars;
225
+ }
226
+ return '';
227
+ }
228
+ var output = [];
229
+ while (true) {
230
+ collectCharacters(SRCSET_COMMAS_OR_SPACES);
231
+ if (pos >= attributeValue.length) {
232
+ break;
233
+ }
234
+ var url = collectCharacters(SRCSET_NOT_SPACES);
235
+ if (url.slice(-1) === ',') {
236
+ url = absoluteToDoc(doc, url.substring(0, url.length - 1));
237
+ output.push(url);
238
+ }
239
+ else {
240
+ var descriptorsStr = '';
241
+ url = absoluteToDoc(doc, url);
242
+ var inParens = false;
243
+ while (true) {
244
+ var c = attributeValue.charAt(pos);
245
+ if (c === '') {
246
+ output.push((url + descriptorsStr).trim());
247
+ break;
248
+ }
249
+ else if (!inParens) {
250
+ if (c === ',') {
251
+ pos += 1;
252
+ output.push((url + descriptorsStr).trim());
253
+ break;
254
+ }
255
+ else if (c === '(') {
256
+ inParens = true;
257
+ }
258
+ }
259
+ else {
260
+ if (c === ')') {
261
+ inParens = false;
262
+ }
263
+ }
264
+ descriptorsStr += c;
265
+ pos += 1;
266
+ }
267
+ }
268
+ }
269
+ return output.join(', ');
270
+ }
271
+ function absoluteToDoc(doc, attributeValue) {
272
+ if (!attributeValue || attributeValue.trim() === '') {
273
+ return attributeValue;
274
+ }
275
+ var a = doc.createElement('a');
276
+ a.href = attributeValue;
277
+ return a.href;
278
+ }
279
+ function isSVGElement(el) {
280
+ return Boolean(el.tagName === 'svg' || el.ownerSVGElement);
281
+ }
282
+ function getHref() {
283
+ var a = document.createElement('a');
284
+ a.href = '';
285
+ return a.href;
286
+ }
287
+ function transformAttribute(doc, tagName, name, value) {
288
+ if (name === 'src' || (name === 'href' && value)) {
289
+ return absoluteToDoc(doc, value);
290
+ }
291
+ else if (name === 'xlink:href' && value && value[0] !== '#') {
292
+ return absoluteToDoc(doc, value);
293
+ }
294
+ else if (name === 'background' &&
295
+ value &&
296
+ (tagName === 'table' || tagName === 'td' || tagName === 'th')) {
297
+ return absoluteToDoc(doc, value);
298
+ }
299
+ else if (name === 'srcset' && value) {
300
+ return getAbsoluteSrcsetString(doc, value);
301
+ }
302
+ else if (name === 'style' && value) {
303
+ return absoluteToStylesheet(value, getHref());
304
+ }
305
+ else if (tagName === 'object' && name === 'data' && value) {
306
+ return absoluteToDoc(doc, value);
307
+ }
308
+ else {
309
+ return value;
310
+ }
311
+ }
312
+ function _isBlockedElement(element, blockClass, blockSelector) {
313
+ if (typeof blockClass === 'string') {
314
+ if (element.classList.contains(blockClass)) {
315
+ return true;
316
+ }
317
+ }
318
+ else {
319
+ for (var eIndex = element.classList.length; eIndex--;) {
320
+ var className = element.classList[eIndex];
321
+ if (blockClass.test(className)) {
322
+ return true;
323
+ }
324
+ }
325
+ }
326
+ if (blockSelector) {
327
+ return element.matches(blockSelector);
328
+ }
329
+ return false;
330
+ }
331
+ function classMatchesRegex(node, regex, checkAncestors) {
332
+ if (!node)
333
+ return false;
334
+ if (node.nodeType !== node.ELEMENT_NODE) {
335
+ if (!checkAncestors)
336
+ return false;
337
+ return classMatchesRegex(node.parentNode, regex, checkAncestors);
338
+ }
339
+ for (var eIndex = node.classList.length; eIndex--;) {
340
+ var className = node.classList[eIndex];
341
+ if (regex.test(className)) {
342
+ return true;
343
+ }
344
+ }
345
+ if (!checkAncestors)
346
+ return false;
347
+ return classMatchesRegex(node.parentNode, regex, checkAncestors);
348
+ }
349
+ function needMaskingText(node, maskTextClass, maskTextSelector) {
350
+ var el = node.nodeType === node.ELEMENT_NODE
351
+ ? node
352
+ : node.parentElement;
353
+ if (el === null)
354
+ return false;
355
+ if (typeof maskTextClass === 'string') {
356
+ if (el.classList.contains(maskTextClass))
357
+ return true;
358
+ if (el.closest("." + maskTextClass))
359
+ return true;
360
+ }
361
+ else {
362
+ if (classMatchesRegex(el, maskTextClass, true))
363
+ return true;
364
+ }
365
+ if (maskTextSelector) {
366
+ if (el.matches(maskTextSelector))
367
+ return true;
368
+ if (el.closest(maskTextSelector))
369
+ return true;
370
+ }
371
+ return false;
372
+ }
373
+ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
374
+ var win = iframeEl.contentWindow;
375
+ if (!win) {
376
+ return;
377
+ }
378
+ var fired = false;
379
+ var readyState;
380
+ try {
381
+ readyState = win.document.readyState;
382
+ }
383
+ catch (error) {
384
+ return;
385
+ }
386
+ if (readyState !== 'complete') {
387
+ var timer_1 = setTimeout(function () {
388
+ if (!fired) {
389
+ listener();
390
+ fired = true;
391
+ }
392
+ }, iframeLoadTimeout);
393
+ iframeEl.addEventListener('load', function () {
394
+ clearTimeout(timer_1);
395
+ fired = true;
396
+ listener();
397
+ });
398
+ return;
399
+ }
400
+ var blankUrl = 'about:blank';
401
+ if (win.location.href !== blankUrl ||
402
+ iframeEl.src === blankUrl ||
403
+ iframeEl.src === '') {
404
+ setTimeout(listener, 0);
405
+ return;
406
+ }
407
+ iframeEl.addEventListener('load', listener);
408
+ }
409
+ function isStylesheetLoaded(link) {
410
+ if (!link.getAttribute('href'))
411
+ return true;
412
+ return link.sheet !== null;
413
+ }
414
+ function onceStylesheetLoaded(link, listener, iframeLoadTimeout) {
415
+ var fired = false;
416
+ var styleSheetLoaded;
417
+ try {
418
+ styleSheetLoaded = link.sheet;
419
+ }
420
+ catch (error) {
421
+ return;
422
+ }
423
+ if (styleSheetLoaded)
424
+ return;
425
+ var timer = setTimeout(function () {
426
+ if (!fired) {
427
+ listener();
428
+ fired = true;
429
+ }
430
+ }, iframeLoadTimeout);
431
+ link.addEventListener('load', function () {
432
+ clearTimeout(timer);
433
+ fired = true;
434
+ listener();
435
+ });
436
+ }
437
+ function serializeNode(n, options) {
438
+ var doc = options.doc, mirror = options.mirror, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _a = options.maskInputOptions, maskInputOptions = _a === void 0 ? {} : _a, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _b = options.dataURLOptions, dataURLOptions = _b === void 0 ? {} : _b, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn, _c = options.newlyAddedElement, newlyAddedElement = _c === void 0 ? false : _c, enableStrictPrivacy = options.enableStrictPrivacy;
439
+ var rootId = getRootId(doc, mirror);
440
+ switch (n.nodeType) {
441
+ case n.DOCUMENT_NODE:
442
+ if (n.compatMode !== 'CSS1Compat') {
443
+ return {
444
+ type: NodeType.Document,
445
+ childNodes: [],
446
+ compatMode: n.compatMode,
447
+ rootId: rootId
448
+ };
449
+ }
450
+ else {
451
+ return {
452
+ type: NodeType.Document,
453
+ childNodes: [],
454
+ rootId: rootId
455
+ };
456
+ }
457
+ case n.DOCUMENT_TYPE_NODE:
458
+ return {
459
+ type: NodeType.DocumentType,
460
+ name: n.name,
461
+ publicId: n.publicId,
462
+ systemId: n.systemId,
463
+ rootId: rootId
464
+ };
465
+ case n.ELEMENT_NODE:
466
+ return serializeElementNode(n, {
467
+ doc: doc,
468
+ blockClass: blockClass,
469
+ blockSelector: blockSelector,
470
+ inlineStylesheet: inlineStylesheet,
471
+ maskInputOptions: maskInputOptions,
472
+ maskInputFn: maskInputFn,
473
+ dataURLOptions: dataURLOptions,
474
+ inlineImages: inlineImages,
475
+ recordCanvas: recordCanvas,
476
+ keepIframeSrcFn: keepIframeSrcFn,
477
+ newlyAddedElement: newlyAddedElement,
478
+ enableStrictPrivacy: enableStrictPrivacy,
479
+ rootId: rootId
480
+ });
481
+ case n.TEXT_NODE:
482
+ return serializeTextNode(n, {
483
+ maskTextClass: maskTextClass,
484
+ maskTextSelector: maskTextSelector,
485
+ maskTextFn: maskTextFn,
486
+ enableStrictPrivacy: enableStrictPrivacy,
487
+ rootId: rootId
488
+ });
489
+ case n.CDATA_SECTION_NODE:
490
+ return {
491
+ type: NodeType.CDATA,
492
+ textContent: '',
493
+ rootId: rootId
494
+ };
495
+ case n.COMMENT_NODE:
496
+ return {
497
+ type: NodeType.Comment,
498
+ textContent: n.textContent || '',
499
+ rootId: rootId
500
+ };
501
+ default:
502
+ return false;
503
+ }
504
+ }
505
+ function getRootId(doc, mirror) {
506
+ if (!mirror.hasNode(doc))
507
+ return undefined;
508
+ var docId = mirror.getId(doc);
509
+ return docId === 1 ? undefined : docId;
510
+ }
511
+ function serializeTextNode(n, options) {
512
+ var _a;
513
+ var maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, maskTextFn = options.maskTextFn, enableStrictPrivacy = options.enableStrictPrivacy, rootId = options.rootId;
514
+ var parentTagName = n.parentNode && n.parentNode.tagName;
515
+ var textContent = n.textContent;
516
+ var isStyle = parentTagName === 'STYLE' ? true : undefined;
517
+ var isScript = parentTagName === 'SCRIPT' ? true : undefined;
518
+ var textContentHandled = false;
519
+ if (isStyle && textContent) {
520
+ try {
521
+ if (n.nextSibling || n.previousSibling) {
522
+ }
523
+ else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {
524
+ textContent = stringifyStyleSheet(n.parentNode.sheet);
525
+ }
526
+ }
527
+ catch (err) {
528
+ console.warn("Cannot get CSS styles from text's parentNode. Error: " + err, n);
529
+ }
530
+ textContent = absoluteToStylesheet(textContent, getHref());
531
+ textContentHandled = true;
532
+ }
533
+ if (isScript) {
534
+ textContent = 'SCRIPT_PLACEHOLDER';
535
+ textContentHandled = true;
536
+ }
537
+ else if (parentTagName === 'NOSCRIPT') {
538
+ textContent = '';
539
+ textContentHandled = true;
540
+ }
541
+ if (!isStyle &&
542
+ !isScript &&
543
+ textContent &&
544
+ needMaskingText(n, maskTextClass, maskTextSelector)) {
545
+ textContent = maskTextFn
546
+ ? maskTextFn(textContent)
547
+ : textContent.replace(/[\S]/g, '*');
548
+ }
549
+ if (enableStrictPrivacy && !textContentHandled && parentTagName) {
550
+ var IGNORE_TAG_NAMES = new Set([
551
+ 'HEAD',
552
+ 'TITLE',
553
+ 'STYLE',
554
+ 'SCRIPT',
555
+ 'HTML',
556
+ 'BODY',
557
+ 'NOSCRIPT',
558
+ ]);
559
+ if (!IGNORE_TAG_NAMES.has(parentTagName) && textContent) {
560
+ textContent = obfuscateText(textContent);
561
+ }
562
+ }
563
+ return {
564
+ type: NodeType.Text,
565
+ textContent: textContent || '',
566
+ isStyle: isStyle,
567
+ rootId: rootId
568
+ };
569
+ }
570
+ function serializeElementNode(n, options) {
571
+ var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, inlineStylesheet = options.inlineStylesheet, _a = options.maskInputOptions, maskInputOptions = _a === void 0 ? {} : _a, maskInputFn = options.maskInputFn, _b = options.dataURLOptions, dataURLOptions = _b === void 0 ? {} : _b, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn, _c = options.newlyAddedElement, newlyAddedElement = _c === void 0 ? false : _c, enableStrictPrivacy = options.enableStrictPrivacy, rootId = options.rootId;
572
+ var needBlock = _isBlockedElement(n, blockClass, blockSelector);
573
+ var tagName = getValidTagName(n);
574
+ var attributes = {};
575
+ var len = n.attributes.length;
576
+ for (var i = 0; i < len; i++) {
577
+ var attr = n.attributes[i];
578
+ attributes[attr.name] = transformAttribute(doc, tagName, attr.name, attr.value);
579
+ }
580
+ if (tagName === 'link' && inlineStylesheet) {
581
+ var stylesheet = Array.from(doc.styleSheets).find(function (s) {
582
+ return s.href === n.href;
583
+ });
584
+ var cssText = null;
585
+ if (stylesheet) {
586
+ cssText = getCssRulesString(stylesheet);
587
+ }
588
+ if (cssText) {
589
+ delete attributes.rel;
590
+ delete attributes.href;
591
+ attributes._cssText = absoluteToStylesheet(cssText, stylesheet.href);
592
+ }
593
+ }
594
+ if (tagName === 'style' &&
595
+ n.sheet &&
596
+ !(n.innerText || n.textContent || '').trim().length) {
597
+ var cssText = getCssRulesString(n.sheet);
598
+ if (cssText) {
599
+ attributes._cssText = absoluteToStylesheet(cssText, getHref());
600
+ }
601
+ }
602
+ if (tagName === 'input' || tagName === 'textarea' || tagName === 'select') {
603
+ var value = n.value;
604
+ if (attributes.type !== 'radio' &&
605
+ attributes.type !== 'checkbox' &&
606
+ attributes.type !== 'submit' &&
607
+ attributes.type !== 'button' &&
608
+ value) {
609
+ attributes.value = maskInputValue({
610
+ type: attributes.type,
611
+ tagName: tagName,
612
+ value: value,
613
+ maskInputOptions: maskInputOptions,
614
+ maskInputFn: maskInputFn
615
+ });
616
+ }
617
+ else if (n.checked) {
618
+ attributes.checked = n.checked;
619
+ }
620
+ }
621
+ if (tagName === 'option') {
622
+ if (n.selected && !maskInputOptions['select']) {
623
+ attributes.selected = true;
624
+ }
625
+ else {
626
+ delete attributes.selected;
627
+ }
628
+ }
629
+ if (tagName === 'canvas' && recordCanvas) {
630
+ if (n.__context === '2d') {
631
+ if (!is2DCanvasBlank(n)) {
632
+ attributes.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
633
+ }
634
+ }
635
+ else if (!('__context' in n)) {
636
+ var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
637
+ var blankCanvas = document.createElement('canvas');
638
+ blankCanvas.width = n.width;
639
+ blankCanvas.height = n.height;
640
+ var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
641
+ if (canvasDataURL !== blankCanvasDataURL) {
642
+ attributes.rr_dataURL = canvasDataURL;
643
+ }
644
+ }
645
+ }
646
+ if (tagName === 'img' && inlineImages) {
647
+ if (!canvasService) {
648
+ canvasService = doc.createElement('canvas');
649
+ canvasCtx = canvasService.getContext('2d');
650
+ }
651
+ var image_1 = n;
652
+ var oldValue_1 = image_1.crossOrigin;
653
+ image_1.crossOrigin = 'anonymous';
654
+ var recordInlineImage = function () {
655
+ try {
656
+ canvasService.width = image_1.naturalWidth;
657
+ canvasService.height = image_1.naturalHeight;
658
+ canvasCtx.drawImage(image_1, 0, 0);
659
+ attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
660
+ }
661
+ catch (err) {
662
+ console.warn("Cannot inline img src=" + image_1.currentSrc + "! Error: " + err);
663
+ }
664
+ oldValue_1
665
+ ? (attributes.crossOrigin = oldValue_1)
666
+ : image_1.removeAttribute('crossorigin');
667
+ };
668
+ if (image_1.complete && image_1.naturalWidth !== 0)
669
+ recordInlineImage();
670
+ else
671
+ image_1.onload = recordInlineImage;
672
+ }
673
+ if (tagName === 'audio' || tagName === 'video') {
674
+ attributes.rr_mediaState = n.paused
675
+ ? 'paused'
676
+ : 'played';
677
+ attributes.rr_mediaCurrentTime = n.currentTime;
678
+ }
679
+ if (!newlyAddedElement) {
680
+ if (n.scrollLeft) {
681
+ attributes.rr_scrollLeft = n.scrollLeft;
682
+ }
683
+ if (n.scrollTop) {
684
+ attributes.rr_scrollTop = n.scrollTop;
685
+ }
686
+ }
687
+ if (needBlock || (tagName === 'img' && enableStrictPrivacy)) {
688
+ var _d = n.getBoundingClientRect(), width = _d.width, height = _d.height;
689
+ attributes = {
690
+ "class": attributes["class"],
691
+ rr_width: width + "px",
692
+ rr_height: height + "px"
693
+ };
694
+ needBlock = true;
695
+ }
696
+ if (tagName === 'iframe' && !keepIframeSrcFn(attributes.src)) {
697
+ if (!n.contentDocument) {
698
+ attributes.rr_src = attributes.src;
699
+ }
700
+ delete attributes.src;
701
+ }
702
+ return {
703
+ type: NodeType.Element,
704
+ tagName: tagName,
705
+ attributes: attributes,
706
+ childNodes: [],
707
+ isSVG: isSVGElement(n) || undefined,
708
+ needBlock: needBlock,
709
+ rootId: rootId
710
+ };
711
+ }
712
+ function lowerIfExists(maybeAttr) {
713
+ if (maybeAttr === undefined) {
714
+ return '';
715
+ }
716
+ else {
717
+ return maybeAttr.toLowerCase();
718
+ }
719
+ }
720
+ function slimDOMExcluded(sn, slimDOMOptions) {
721
+ if (slimDOMOptions.comment && sn.type === NodeType.Comment) {
722
+ return true;
723
+ }
724
+ else if (sn.type === NodeType.Element) {
725
+ if (slimDOMOptions.script &&
726
+ (sn.tagName === 'script' ||
727
+ (sn.tagName === 'link' &&
728
+ sn.attributes.rel === 'preload' &&
729
+ sn.attributes.as === 'script') ||
730
+ (sn.tagName === 'link' &&
731
+ sn.attributes.rel === 'prefetch' &&
732
+ typeof sn.attributes.href === 'string' &&
733
+ sn.attributes.href.endsWith('.js')))) {
734
+ return true;
735
+ }
736
+ else if (slimDOMOptions.headFavicon &&
737
+ ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||
738
+ (sn.tagName === 'meta' &&
739
+ (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) ||
740
+ lowerIfExists(sn.attributes.name) === 'application-name' ||
741
+ lowerIfExists(sn.attributes.rel) === 'icon' ||
742
+ lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||
743
+ lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) {
744
+ return true;
745
+ }
746
+ else if (sn.tagName === 'meta') {
747
+ if (slimDOMOptions.headMetaDescKeywords &&
748
+ lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
749
+ return true;
750
+ }
751
+ else if (slimDOMOptions.headMetaSocial &&
752
+ (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) ||
753
+ lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||
754
+ lowerIfExists(sn.attributes.name) === 'pinterest')) {
755
+ return true;
756
+ }
757
+ else if (slimDOMOptions.headMetaRobots &&
758
+ (lowerIfExists(sn.attributes.name) === 'robots' ||
759
+ lowerIfExists(sn.attributes.name) === 'googlebot' ||
760
+ lowerIfExists(sn.attributes.name) === 'bingbot')) {
761
+ return true;
762
+ }
763
+ else if (slimDOMOptions.headMetaHttpEquiv &&
764
+ sn.attributes['http-equiv'] !== undefined) {
765
+ return true;
766
+ }
767
+ else if (slimDOMOptions.headMetaAuthorship &&
768
+ (lowerIfExists(sn.attributes.name) === 'author' ||
769
+ lowerIfExists(sn.attributes.name) === 'generator' ||
770
+ lowerIfExists(sn.attributes.name) === 'framework' ||
771
+ lowerIfExists(sn.attributes.name) === 'publisher' ||
772
+ lowerIfExists(sn.attributes.name) === 'progid' ||
773
+ lowerIfExists(sn.attributes.property).match(/^article:/) ||
774
+ lowerIfExists(sn.attributes.property).match(/^product:/))) {
775
+ return true;
776
+ }
777
+ else if (slimDOMOptions.headMetaVerification &&
778
+ (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||
779
+ lowerIfExists(sn.attributes.name) === 'yandex-verification' ||
780
+ lowerIfExists(sn.attributes.name) === 'csrf-token' ||
781
+ lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||
782
+ lowerIfExists(sn.attributes.name) === 'verify-v1' ||
783
+ lowerIfExists(sn.attributes.name) === 'verification' ||
784
+ lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) {
785
+ return true;
786
+ }
787
+ }
788
+ }
789
+ return false;
790
+ }
791
+ function serializeNodeWithId(n, options) {
792
+ var doc = options.doc, mirror = options.mirror, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, onStylesheetLoad = options.onStylesheetLoad, _h = options.stylesheetLoadTimeout, stylesheetLoadTimeout = _h === void 0 ? 5000 : _h, _j = options.keepIframeSrcFn, keepIframeSrcFn = _j === void 0 ? function () { return false; } : _j, _k = options.newlyAddedElement, newlyAddedElement = _k === void 0 ? false : _k, enableStrictPrivacy = options.enableStrictPrivacy;
793
+ var _l = options.preserveWhiteSpace, preserveWhiteSpace = _l === void 0 ? true : _l;
794
+ var _serializedNode = serializeNode(n, {
795
+ doc: doc,
796
+ mirror: mirror,
797
+ blockClass: blockClass,
798
+ blockSelector: blockSelector,
799
+ maskTextClass: maskTextClass,
800
+ maskTextSelector: maskTextSelector,
801
+ inlineStylesheet: inlineStylesheet,
802
+ maskInputOptions: maskInputOptions,
803
+ maskTextFn: maskTextFn,
804
+ maskInputFn: maskInputFn,
805
+ dataURLOptions: dataURLOptions,
806
+ inlineImages: inlineImages,
807
+ recordCanvas: recordCanvas,
808
+ keepIframeSrcFn: keepIframeSrcFn,
809
+ newlyAddedElement: newlyAddedElement,
810
+ enableStrictPrivacy: enableStrictPrivacy
811
+ });
812
+ if (!_serializedNode) {
813
+ console.warn(n, 'not serialized');
814
+ return null;
815
+ }
816
+ var id;
817
+ if (mirror.hasNode(n)) {
818
+ id = mirror.getId(n);
819
+ }
820
+ else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||
821
+ (!preserveWhiteSpace &&
822
+ _serializedNode.type === NodeType.Text &&
823
+ !_serializedNode.isStyle &&
824
+ !_serializedNode.textContent.replace(/^\s+|\s+$/gm, '').length)) {
825
+ id = IGNORED_NODE;
826
+ }
827
+ else {
828
+ id = genId();
829
+ }
830
+ if (id === IGNORED_NODE) {
831
+ return null;
832
+ }
833
+ var serializedNode = Object.assign(_serializedNode, { id: id });
834
+ mirror.add(n, serializedNode);
835
+ if (onSerialize) {
836
+ onSerialize(n);
837
+ }
838
+ var recordChild = !skipChild;
839
+ if (serializedNode.type === NodeType.Element) {
840
+ recordChild = recordChild && !serializedNode.needBlock;
841
+ if (serializedNode.needBlock && serializedNode.tagName === 'img') {
842
+ var clone = n.cloneNode();
843
+ clone.src = '';
844
+ mirror.add(clone, serializedNode);
845
+ }
846
+ delete serializedNode.needBlock;
847
+ if (n.shadowRoot)
848
+ serializedNode.isShadowHost = true;
849
+ }
850
+ if ((serializedNode.type === NodeType.Document ||
851
+ serializedNode.type === NodeType.Element) &&
852
+ recordChild) {
853
+ if (slimDOMOptions.headWhitespace &&
854
+ serializedNode.type === NodeType.Element &&
855
+ serializedNode.tagName === 'head') {
856
+ preserveWhiteSpace = false;
857
+ }
858
+ var bypassOptions = {
859
+ doc: doc,
860
+ mirror: mirror,
861
+ blockClass: blockClass,
862
+ blockSelector: blockSelector,
863
+ maskTextClass: maskTextClass,
864
+ maskTextSelector: maskTextSelector,
865
+ skipChild: skipChild,
866
+ inlineStylesheet: inlineStylesheet,
867
+ maskInputOptions: maskInputOptions,
868
+ maskTextFn: maskTextFn,
869
+ maskInputFn: maskInputFn,
870
+ slimDOMOptions: slimDOMOptions,
871
+ dataURLOptions: dataURLOptions,
872
+ inlineImages: inlineImages,
873
+ recordCanvas: recordCanvas,
874
+ preserveWhiteSpace: preserveWhiteSpace,
875
+ onSerialize: onSerialize,
876
+ onIframeLoad: onIframeLoad,
877
+ iframeLoadTimeout: iframeLoadTimeout,
878
+ onStylesheetLoad: onStylesheetLoad,
879
+ stylesheetLoadTimeout: stylesheetLoadTimeout,
880
+ keepIframeSrcFn: keepIframeSrcFn,
881
+ enableStrictPrivacy: enableStrictPrivacy
882
+ };
883
+ for (var _i = 0, _m = Array.from(n.childNodes); _i < _m.length; _i++) {
884
+ var childN = _m[_i];
885
+ var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
886
+ if (serializedChildNode) {
887
+ serializedNode.childNodes.push(serializedChildNode);
888
+ }
889
+ }
890
+ if (isElement(n) && n.shadowRoot) {
891
+ for (var _o = 0, _p = Array.from(n.shadowRoot.childNodes); _o < _p.length; _o++) {
892
+ var childN = _p[_o];
893
+ var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
894
+ if (serializedChildNode) {
895
+ serializedChildNode.isShadow = true;
896
+ serializedNode.childNodes.push(serializedChildNode);
897
+ }
898
+ }
899
+ }
900
+ }
901
+ if (n.parentNode && isShadowRoot(n.parentNode)) {
902
+ serializedNode.isShadow = true;
903
+ }
904
+ if (serializedNode.type === NodeType.Element &&
905
+ serializedNode.tagName === 'iframe') {
906
+ onceIframeLoaded(n, function () {
907
+ var iframeDoc = n.contentDocument;
908
+ if (iframeDoc && onIframeLoad) {
909
+ var serializedIframeNode = serializeNodeWithId(iframeDoc, {
910
+ doc: iframeDoc,
911
+ mirror: mirror,
912
+ blockClass: blockClass,
913
+ blockSelector: blockSelector,
914
+ maskTextClass: maskTextClass,
915
+ maskTextSelector: maskTextSelector,
916
+ skipChild: false,
917
+ inlineStylesheet: inlineStylesheet,
918
+ maskInputOptions: maskInputOptions,
919
+ maskTextFn: maskTextFn,
920
+ maskInputFn: maskInputFn,
921
+ slimDOMOptions: slimDOMOptions,
922
+ dataURLOptions: dataURLOptions,
923
+ inlineImages: inlineImages,
924
+ recordCanvas: recordCanvas,
925
+ preserveWhiteSpace: preserveWhiteSpace,
926
+ onSerialize: onSerialize,
927
+ onIframeLoad: onIframeLoad,
928
+ iframeLoadTimeout: iframeLoadTimeout,
929
+ onStylesheetLoad: onStylesheetLoad,
930
+ stylesheetLoadTimeout: stylesheetLoadTimeout,
931
+ keepIframeSrcFn: keepIframeSrcFn,
932
+ enableStrictPrivacy: enableStrictPrivacy
933
+ });
934
+ if (serializedIframeNode) {
935
+ onIframeLoad(n, serializedIframeNode);
936
+ }
937
+ }
938
+ }, iframeLoadTimeout);
939
+ }
940
+ if (serializedNode.type === NodeType.Element &&
941
+ serializedNode.tagName === 'link' &&
942
+ serializedNode.attributes.rel === 'stylesheet') {
943
+ onceStylesheetLoaded(n, function () {
944
+ if (onStylesheetLoad) {
945
+ var serializedLinkNode = serializeNodeWithId(n, {
946
+ doc: doc,
947
+ mirror: mirror,
948
+ blockClass: blockClass,
949
+ blockSelector: blockSelector,
950
+ maskTextClass: maskTextClass,
951
+ maskTextSelector: maskTextSelector,
952
+ skipChild: false,
953
+ inlineStylesheet: inlineStylesheet,
954
+ maskInputOptions: maskInputOptions,
955
+ maskTextFn: maskTextFn,
956
+ maskInputFn: maskInputFn,
957
+ slimDOMOptions: slimDOMOptions,
958
+ dataURLOptions: dataURLOptions,
959
+ inlineImages: inlineImages,
960
+ recordCanvas: recordCanvas,
961
+ preserveWhiteSpace: preserveWhiteSpace,
962
+ onSerialize: onSerialize,
963
+ onIframeLoad: onIframeLoad,
964
+ iframeLoadTimeout: iframeLoadTimeout,
965
+ onStylesheetLoad: onStylesheetLoad,
966
+ stylesheetLoadTimeout: stylesheetLoadTimeout,
967
+ keepIframeSrcFn: keepIframeSrcFn,
968
+ enableStrictPrivacy: enableStrictPrivacy
969
+ });
970
+ if (serializedLinkNode) {
971
+ onStylesheetLoad(n, serializedLinkNode);
972
+ }
973
+ }
974
+ }, stylesheetLoadTimeout);
975
+ if (isStylesheetLoaded(n) === false)
976
+ return null;
977
+ }
978
+ return serializedNode;
979
+ }
980
+ function snapshot(n, options) {
981
+ var _a = options || {}, _b = _a.mirror, mirror = _b === void 0 ? new Mirror() : _b, _c = _a.blockClass, blockClass = _c === void 0 ? 'highlight-block' : _c, _d = _a.blockSelector, blockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'highlight-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.inlineStylesheet, inlineStylesheet = _g === void 0 ? true : _g, _h = _a.inlineImages, inlineImages = _h === void 0 ? false : _h, _j = _a.recordCanvas, recordCanvas = _j === void 0 ? false : _j, _k = _a.maskAllInputs, maskAllInputs = _k === void 0 ? false : _k, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _l = _a.slimDOM, slimDOM = _l === void 0 ? false : _l, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, onStylesheetLoad = _a.onStylesheetLoad, stylesheetLoadTimeout = _a.stylesheetLoadTimeout, _m = _a.keepIframeSrcFn, keepIframeSrcFn = _m === void 0 ? function () { return false; } : _m, _o = _a.enableStrictPrivacy, enableStrictPrivacy = _o === void 0 ? false : _o;
982
+ var maskInputOptions = maskAllInputs === true
983
+ ? {
984
+ color: true,
985
+ date: true,
986
+ 'datetime-local': true,
987
+ email: true,
988
+ month: true,
989
+ number: true,
990
+ range: true,
991
+ search: true,
992
+ tel: true,
993
+ text: true,
994
+ time: true,
995
+ url: true,
996
+ week: true,
997
+ textarea: true,
998
+ select: true,
999
+ password: true
1000
+ }
1001
+ : maskAllInputs === false
1002
+ ? {
1003
+ password: true
1004
+ }
1005
+ : maskAllInputs;
1006
+ var slimDOMOptions = slimDOM === true || slimDOM === 'all'
1007
+ ?
1008
+ {
1009
+ script: true,
1010
+ comment: true,
1011
+ headFavicon: true,
1012
+ headWhitespace: true,
1013
+ headMetaDescKeywords: slimDOM === 'all',
1014
+ headMetaSocial: true,
1015
+ headMetaRobots: true,
1016
+ headMetaHttpEquiv: true,
1017
+ headMetaAuthorship: true,
1018
+ headMetaVerification: true
1019
+ }
1020
+ : slimDOM === false
1021
+ ? {}
1022
+ : slimDOM;
1023
+ return serializeNodeWithId(n, {
1024
+ doc: n,
1025
+ mirror: mirror,
1026
+ blockClass: blockClass,
1027
+ blockSelector: blockSelector,
1028
+ maskTextClass: maskTextClass,
1029
+ maskTextSelector: maskTextSelector,
1030
+ skipChild: false,
1031
+ inlineStylesheet: inlineStylesheet,
1032
+ maskInputOptions: maskInputOptions,
1033
+ maskTextFn: maskTextFn,
1034
+ maskInputFn: maskInputFn,
1035
+ slimDOMOptions: slimDOMOptions,
1036
+ dataURLOptions: dataURLOptions,
1037
+ inlineImages: inlineImages,
1038
+ recordCanvas: recordCanvas,
1039
+ preserveWhiteSpace: preserveWhiteSpace,
1040
+ onSerialize: onSerialize,
1041
+ onIframeLoad: onIframeLoad,
1042
+ iframeLoadTimeout: iframeLoadTimeout,
1043
+ onStylesheetLoad: onStylesheetLoad,
1044
+ stylesheetLoadTimeout: stylesheetLoadTimeout,
1045
+ keepIframeSrcFn: keepIframeSrcFn,
1046
+ newlyAddedElement: false,
1047
+ enableStrictPrivacy: enableStrictPrivacy
1048
+ });
1049
+ }
4
1050
 
5
1051
  function on(type, fn, target = document) {
6
1052
  const options = { capture: true, passive: true };
@@ -149,7 +1195,7 @@ function isBlocked(node, blockClass, checkAncestors) {
149
1195
  return true;
150
1196
  }
151
1197
  else {
152
- if (rrwebSnapshot.classMatchesRegex(el, blockClass, checkAncestors))
1198
+ if (classMatchesRegex(el, blockClass, checkAncestors))
153
1199
  return true;
154
1200
  }
155
1201
  return false;
@@ -158,10 +1204,10 @@ function isSerialized(n, mirror) {
158
1204
  return mirror.getId(n) !== -1;
159
1205
  }
160
1206
  function isIgnored(n, mirror) {
161
- return mirror.getId(n) === rrwebSnapshot.IGNORED_NODE;
1207
+ return mirror.getId(n) === IGNORED_NODE;
162
1208
  }
163
1209
  function isAncestorRemoved(target, mirror) {
164
- if (rrwebSnapshot.isShadowRoot(target)) {
1210
+ if (isShadowRoot(target)) {
165
1211
  return false;
166
1212
  }
167
1213
  const id = mirror.getId(target);
@@ -393,8 +1439,8 @@ class MutationBuffer {
393
1439
  const addList = new DoubleLinkedList();
394
1440
  const getNextId = (n) => {
395
1441
  let ns = n;
396
- let nextId = rrwebSnapshot.IGNORED_NODE;
397
- while (nextId === rrwebSnapshot.IGNORED_NODE) {
1442
+ let nextId = IGNORED_NODE;
1443
+ while (nextId === IGNORED_NODE) {
398
1444
  ns = ns && ns.nextSibling;
399
1445
  nextId = ns && this.mirror.getId(ns);
400
1446
  }
@@ -415,14 +1461,14 @@ class MutationBuffer {
415
1461
  if (!n.parentNode || notInDoc) {
416
1462
  return;
417
1463
  }
418
- const parentId = rrwebSnapshot.isShadowRoot(n.parentNode)
1464
+ const parentId = isShadowRoot(n.parentNode)
419
1465
  ? this.mirror.getId(shadowHost)
420
1466
  : this.mirror.getId(n.parentNode);
421
1467
  const nextId = getNextId(n);
422
1468
  if (parentId === -1 || nextId === -1) {
423
1469
  return addList.addNode(n);
424
1470
  }
425
- const sn = rrwebSnapshot.serializeNodeWithId(n, {
1471
+ const sn = serializeNodeWithId(n, {
426
1472
  doc: this.doc,
427
1473
  mirror: this.mirror,
428
1474
  blockClass: this.blockClass,
@@ -526,7 +1572,7 @@ class MutationBuffer {
526
1572
  .map((text) => {
527
1573
  let value = text.value;
528
1574
  if (this.enableStrictPrivacy && value) {
529
- value = rrwebSnapshot.obfuscateText(value);
1575
+ value = obfuscateText(value);
530
1576
  }
531
1577
  return {
532
1578
  id: this.mirror.getId(text.node),
@@ -568,7 +1614,7 @@ class MutationBuffer {
568
1614
  if (!isBlocked(m.target, this.blockClass, false) &&
569
1615
  value !== m.oldValue) {
570
1616
  this.texts.push({
571
- value: rrwebSnapshot.needMaskingText(m.target, this.maskTextClass, this.maskTextSelector) && value
1617
+ value: needMaskingText(m.target, this.maskTextClass, this.maskTextSelector) && value
572
1618
  ? this.maskTextFn
573
1619
  ? this.maskTextFn(value)
574
1620
  : value.replace(/[\S]/g, '*')
@@ -582,7 +1628,7 @@ class MutationBuffer {
582
1628
  const target = m.target;
583
1629
  let value = m.target.getAttribute(m.attributeName);
584
1630
  if (m.attributeName === 'value') {
585
- value = rrwebSnapshot.maskInputValue({
1631
+ value = maskInputValue({
586
1632
  maskInputOptions: this.maskInputOptions,
587
1633
  tagName: m.target.tagName,
588
1634
  type: m.target.getAttribute('type'),
@@ -640,7 +1686,7 @@ class MutationBuffer {
640
1686
  break;
641
1687
  }
642
1688
  }
643
- item.attributes[m.attributeName] = rrwebSnapshot.transformAttribute(this.doc, m.target.tagName, m.attributeName, value);
1689
+ item.attributes[m.attributeName] = transformAttribute(this.doc, m.target.tagName, m.attributeName, value);
644
1690
  }
645
1691
  break;
646
1692
  }
@@ -650,7 +1696,7 @@ class MutationBuffer {
650
1696
  m.addedNodes.forEach((n) => this.genAdds(n, m.target));
651
1697
  m.removedNodes.forEach((n) => {
652
1698
  const nodeId = this.mirror.getId(n);
653
- const parentId = rrwebSnapshot.isShadowRoot(m.target)
1699
+ const parentId = isShadowRoot(m.target)
654
1700
  ? this.mirror.getId(m.target.host)
655
1701
  : this.mirror.getId(m.target);
656
1702
  if (isBlocked(m.target, this.blockClass, false) ||
@@ -672,7 +1718,7 @@ class MutationBuffer {
672
1718
  this.removes.push({
673
1719
  parentId,
674
1720
  id: nodeId,
675
- isShadow: rrwebSnapshot.isShadowRoot(m.target) ? true : undefined,
1721
+ isShadow: isShadowRoot(m.target) ? true : undefined,
676
1722
  });
677
1723
  }
678
1724
  this.mapRemoves.push(n);
@@ -1001,7 +2047,7 @@ function initInputObserver({ inputCb, doc, mirror, blockClass, ignoreClass, mask
1001
2047
  }
1002
2048
  else if (maskInputOptions[target.tagName.toLowerCase()] ||
1003
2049
  maskInputOptions[type]) {
1004
- text = rrwebSnapshot.maskInputValue({
2050
+ text = maskInputValue({
1005
2051
  maskInputOptions,
1006
2052
  tagName: target.tagName,
1007
2053
  type,
@@ -2017,7 +3063,7 @@ function wrapEvent(e) {
2017
3063
  }
2018
3064
  let wrappedEmit;
2019
3065
  let takeFullSnapshot;
2020
- const mirror = rrwebSnapshot.createMirror();
3066
+ const mirror = createMirror();
2021
3067
  function record(options = {}) {
2022
3068
  const { emit, checkoutEveryNms, checkoutEveryNth, blockClass = 'highlight-block', blockSelector = null, ignoreClass = 'highlight-ignore', maskTextClass = 'highlight-mask', maskTextSelector = 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, enableStrictPrivacy = false, } = options;
2023
3069
  if (!emit) {
@@ -2168,7 +3214,7 @@ function record(options = {}) {
2168
3214
  },
2169
3215
  }), isCheckout);
2170
3216
  mutationBuffers.forEach((buf) => buf.lock());
2171
- const node = rrwebSnapshot.snapshot(document, {
3217
+ const node = snapshot(document, {
2172
3218
  mirror,
2173
3219
  blockClass,
2174
3220
  blockSelector,