@highlight-run/rrweb 2.0.11 → 2.0.15

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