@highlight-run/rrweb 2.0.8 → 2.0.11

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 +3 -4
  14. package/dist/replay/rrweb-replay-unpack.min.js +3 -4
  15. package/dist/replay/rrweb-replay-unpack.min.js.map +1 -1
  16. package/dist/replay/rrweb-replay.js +3 -4
  17. package/dist/replay/rrweb-replay.min.js +3 -4
  18. package/dist/replay/rrweb-replay.min.js.map +1 -1
  19. package/dist/rrweb-all.js +24 -25
  20. package/dist/rrweb-all.min.js +24 -25
  21. package/dist/rrweb-all.min.js.map +1 -1
  22. package/dist/rrweb.js +14 -15
  23. package/dist/rrweb.min.js +14 -15
  24. package/dist/rrweb.min.js.map +1 -1
  25. package/es/rrweb/packages/rrdom/es/virtual-dom.js +51 -90
  26. package/es/rrweb/packages/rrweb/src/index.js +1 -1
  27. package/es/rrweb/packages/rrweb/src/record/index.js +6 -3
  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/lib/plugins/console-record.js +1 -9
  33. package/lib/plugins/console-replay.js +1 -9
  34. package/lib/record/rrweb-record-pack.js +3 -9
  35. package/lib/record/rrweb-record.js +21 -1061
  36. package/lib/replay/rrweb-replay-unpack.js +96 -1015
  37. package/lib/replay/rrweb-replay.js +96 -1015
  38. package/lib/rrweb-all.js +141 -2034
  39. package/lib/rrweb.js +141 -2034
  40. package/package.json +4 -4
  41. package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +0 -1858
@@ -1,1049 +1,6 @@
1
1
  'use strict';
2
2
 
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
- keepIframeSrcFn: keepIframeSrcFn,
930
- enableStrictPrivacy: enableStrictPrivacy
931
- });
932
- if (serializedIframeNode) {
933
- onIframeLoad(n, serializedIframeNode);
934
- }
935
- }
936
- }, iframeLoadTimeout);
937
- }
938
- if (serializedNode.type === NodeType.Element &&
939
- serializedNode.tagName === 'link' &&
940
- serializedNode.attributes.rel === 'stylesheet') {
941
- onceStylesheetLoaded(n, function () {
942
- if (onStylesheetLoad) {
943
- var serializedLinkNode = serializeNodeWithId(n, {
944
- doc: doc,
945
- mirror: mirror,
946
- blockClass: blockClass,
947
- blockSelector: blockSelector,
948
- maskTextClass: maskTextClass,
949
- maskTextSelector: maskTextSelector,
950
- skipChild: false,
951
- inlineStylesheet: inlineStylesheet,
952
- maskInputOptions: maskInputOptions,
953
- maskTextFn: maskTextFn,
954
- maskInputFn: maskInputFn,
955
- slimDOMOptions: slimDOMOptions,
956
- dataURLOptions: dataURLOptions,
957
- inlineImages: inlineImages,
958
- recordCanvas: recordCanvas,
959
- preserveWhiteSpace: preserveWhiteSpace,
960
- onSerialize: onSerialize,
961
- onIframeLoad: onIframeLoad,
962
- onStylesheetLoad: onStylesheetLoad,
963
- iframeLoadTimeout: iframeLoadTimeout,
964
- keepIframeSrcFn: keepIframeSrcFn,
965
- enableStrictPrivacy: enableStrictPrivacy
966
- });
967
- if (serializedLinkNode) {
968
- onStylesheetLoad(n, serializedLinkNode);
969
- }
970
- }
971
- }, stylesheetLoadTimeout);
972
- if (isStylesheetLoaded(n) === false)
973
- return null;
974
- }
975
- return serializedNode;
976
- }
977
- function snapshot(n, options) {
978
- 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;
979
- var maskInputOptions = maskAllInputs === true
980
- ? {
981
- color: true,
982
- date: true,
983
- 'datetime-local': true,
984
- email: true,
985
- month: true,
986
- number: true,
987
- range: true,
988
- search: true,
989
- tel: true,
990
- text: true,
991
- time: true,
992
- url: true,
993
- week: true,
994
- textarea: true,
995
- select: true,
996
- password: true
997
- }
998
- : maskAllInputs === false
999
- ? {
1000
- password: true
1001
- }
1002
- : maskAllInputs;
1003
- var slimDOMOptions = slimDOM === true || slimDOM === 'all'
1004
- ?
1005
- {
1006
- script: true,
1007
- comment: true,
1008
- headFavicon: true,
1009
- headWhitespace: true,
1010
- headMetaDescKeywords: slimDOM === 'all',
1011
- headMetaSocial: true,
1012
- headMetaRobots: true,
1013
- headMetaHttpEquiv: true,
1014
- headMetaAuthorship: true,
1015
- headMetaVerification: true
1016
- }
1017
- : slimDOM === false
1018
- ? {}
1019
- : slimDOM;
1020
- return serializeNodeWithId(n, {
1021
- doc: n,
1022
- mirror: mirror,
1023
- blockClass: blockClass,
1024
- blockSelector: blockSelector,
1025
- maskTextClass: maskTextClass,
1026
- maskTextSelector: maskTextSelector,
1027
- skipChild: false,
1028
- inlineStylesheet: inlineStylesheet,
1029
- maskInputOptions: maskInputOptions,
1030
- maskTextFn: maskTextFn,
1031
- maskInputFn: maskInputFn,
1032
- slimDOMOptions: slimDOMOptions,
1033
- dataURLOptions: dataURLOptions,
1034
- inlineImages: inlineImages,
1035
- recordCanvas: recordCanvas,
1036
- preserveWhiteSpace: preserveWhiteSpace,
1037
- onSerialize: onSerialize,
1038
- onIframeLoad: onIframeLoad,
1039
- iframeLoadTimeout: iframeLoadTimeout,
1040
- onStylesheetLoad: onStylesheetLoad,
1041
- stylesheetLoadTimeout: stylesheetLoadTimeout,
1042
- keepIframeSrcFn: keepIframeSrcFn,
1043
- newlyAddedElement: false,
1044
- enableStrictPrivacy: enableStrictPrivacy
1045
- });
1046
- }
3
+ var rrwebSnapshot = require('@highlight-run/rrweb-snapshot');
1047
4
 
1048
5
  function on(type, fn, target = document) {
1049
6
  const options = { capture: true, passive: true };
@@ -1192,7 +149,7 @@ function isBlocked(node, blockClass, checkAncestors) {
1192
149
  return true;
1193
150
  }
1194
151
  else {
1195
- if (classMatchesRegex(el, blockClass, checkAncestors))
152
+ if (rrwebSnapshot.classMatchesRegex(el, blockClass, checkAncestors))
1196
153
  return true;
1197
154
  }
1198
155
  return false;
@@ -1201,10 +158,10 @@ function isSerialized(n, mirror) {
1201
158
  return mirror.getId(n) !== -1;
1202
159
  }
1203
160
  function isIgnored(n, mirror) {
1204
- return mirror.getId(n) === IGNORED_NODE;
161
+ return mirror.getId(n) === rrwebSnapshot.IGNORED_NODE;
1205
162
  }
1206
163
  function isAncestorRemoved(target, mirror) {
1207
- if (isShadowRoot(target)) {
164
+ if (rrwebSnapshot.isShadowRoot(target)) {
1208
165
  return false;
1209
166
  }
1210
167
  const id = mirror.getId(target);
@@ -1436,8 +393,8 @@ class MutationBuffer {
1436
393
  const addList = new DoubleLinkedList();
1437
394
  const getNextId = (n) => {
1438
395
  let ns = n;
1439
- let nextId = IGNORED_NODE;
1440
- while (nextId === IGNORED_NODE) {
396
+ let nextId = rrwebSnapshot.IGNORED_NODE;
397
+ while (nextId === rrwebSnapshot.IGNORED_NODE) {
1441
398
  ns = ns && ns.nextSibling;
1442
399
  nextId = ns && this.mirror.getId(ns);
1443
400
  }
@@ -1458,14 +415,14 @@ class MutationBuffer {
1458
415
  if (!n.parentNode || notInDoc) {
1459
416
  return;
1460
417
  }
1461
- const parentId = isShadowRoot(n.parentNode)
418
+ const parentId = rrwebSnapshot.isShadowRoot(n.parentNode)
1462
419
  ? this.mirror.getId(shadowHost)
1463
420
  : this.mirror.getId(n.parentNode);
1464
421
  const nextId = getNextId(n);
1465
422
  if (parentId === -1 || nextId === -1) {
1466
423
  return addList.addNode(n);
1467
424
  }
1468
- const sn = serializeNodeWithId(n, {
425
+ const sn = rrwebSnapshot.serializeNodeWithId(n, {
1469
426
  doc: this.doc,
1470
427
  mirror: this.mirror,
1471
428
  blockClass: this.blockClass,
@@ -1569,7 +526,7 @@ class MutationBuffer {
1569
526
  .map((text) => {
1570
527
  let value = text.value;
1571
528
  if (this.enableStrictPrivacy && value) {
1572
- value = obfuscateText(value);
529
+ value = rrwebSnapshot.obfuscateText(value);
1573
530
  }
1574
531
  return {
1575
532
  id: this.mirror.getId(text.node),
@@ -1611,7 +568,7 @@ class MutationBuffer {
1611
568
  if (!isBlocked(m.target, this.blockClass, false) &&
1612
569
  value !== m.oldValue) {
1613
570
  this.texts.push({
1614
- value: needMaskingText(m.target, this.maskTextClass, this.maskTextSelector) && value
571
+ value: rrwebSnapshot.needMaskingText(m.target, this.maskTextClass, this.maskTextSelector) && value
1615
572
  ? this.maskTextFn
1616
573
  ? this.maskTextFn(value)
1617
574
  : value.replace(/[\S]/g, '*')
@@ -1625,7 +582,7 @@ class MutationBuffer {
1625
582
  const target = m.target;
1626
583
  let value = m.target.getAttribute(m.attributeName);
1627
584
  if (m.attributeName === 'value') {
1628
- value = maskInputValue({
585
+ value = rrwebSnapshot.maskInputValue({
1629
586
  maskInputOptions: this.maskInputOptions,
1630
587
  tagName: m.target.tagName,
1631
588
  type: m.target.getAttribute('type'),
@@ -1683,7 +640,7 @@ class MutationBuffer {
1683
640
  break;
1684
641
  }
1685
642
  }
1686
- item.attributes[m.attributeName] = transformAttribute(this.doc, m.target.tagName, m.attributeName, value);
643
+ item.attributes[m.attributeName] = rrwebSnapshot.transformAttribute(this.doc, m.target.tagName, m.attributeName, value);
1687
644
  }
1688
645
  break;
1689
646
  }
@@ -1693,7 +650,7 @@ class MutationBuffer {
1693
650
  m.addedNodes.forEach((n) => this.genAdds(n, m.target));
1694
651
  m.removedNodes.forEach((n) => {
1695
652
  const nodeId = this.mirror.getId(n);
1696
- const parentId = isShadowRoot(m.target)
653
+ const parentId = rrwebSnapshot.isShadowRoot(m.target)
1697
654
  ? this.mirror.getId(m.target.host)
1698
655
  : this.mirror.getId(m.target);
1699
656
  if (isBlocked(m.target, this.blockClass, false) ||
@@ -1715,7 +672,7 @@ class MutationBuffer {
1715
672
  this.removes.push({
1716
673
  parentId,
1717
674
  id: nodeId,
1718
- isShadow: isShadowRoot(m.target) ? true : undefined,
675
+ isShadow: rrwebSnapshot.isShadowRoot(m.target) ? true : undefined,
1719
676
  });
1720
677
  }
1721
678
  this.mapRemoves.push(n);
@@ -2044,7 +1001,7 @@ function initInputObserver({ inputCb, doc, mirror, blockClass, ignoreClass, mask
2044
1001
  }
2045
1002
  else if (maskInputOptions[target.tagName.toLowerCase()] ||
2046
1003
  maskInputOptions[type]) {
2047
- text = maskInputValue({
1004
+ text = rrwebSnapshot.maskInputValue({
2048
1005
  maskInputOptions,
2049
1006
  tagName: target.tagName,
2050
1007
  type,
@@ -3060,7 +2017,7 @@ function wrapEvent(e) {
3060
2017
  }
3061
2018
  let wrappedEmit;
3062
2019
  let takeFullSnapshot;
3063
- const mirror = createMirror();
2020
+ const mirror = rrwebSnapshot.createMirror();
3064
2021
  function record(options = {}) {
3065
2022
  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;
3066
2023
  if (!emit) {
@@ -3211,7 +2168,7 @@ function record(options = {}) {
3211
2168
  },
3212
2169
  }), isCheckout);
3213
2170
  mutationBuffers.forEach((buf) => buf.lock());
3214
- const node = snapshot(document, {
2171
+ const node = rrwebSnapshot.snapshot(document, {
3215
2172
  mirror,
3216
2173
  blockClass,
3217
2174
  blockSelector,
@@ -3228,6 +2185,9 @@ function record(options = {}) {
3228
2185
  if (isSerializedIframe(n, mirror)) {
3229
2186
  iframeManager.addIframe(n);
3230
2187
  }
2188
+ if (isSerializedStylesheet(n, mirror)) {
2189
+ stylesheetManager.addStylesheet(n);
2190
+ }
3231
2191
  if (hasShadowRoot(n)) {
3232
2192
  shadowDomManager.addShadowRoot(n.shadowRoot, document);
3233
2193
  }
@@ -3237,7 +2197,7 @@ function record(options = {}) {
3237
2197
  shadowDomManager.observeAttachShadow(iframe);
3238
2198
  },
3239
2199
  onStylesheetLoad: (linkEl, childSn) => {
3240
- this.stylesheetManager.attachStylesheet(linkEl, childSn, this.mirror);
2200
+ stylesheetManager.attachStylesheet(linkEl, childSn, mirror);
3241
2201
  },
3242
2202
  keepIframeSrcFn,
3243
2203
  });