@highlight-run/rrweb 2.0.6 → 2.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/plugins/console-record.min.js.map +1 -1
- package/dist/plugins/console-replay.min.js.map +1 -1
- package/dist/record/rrweb-record-pack.min.js.map +1 -1
- package/dist/record/rrweb-record.js +3 -3
- package/dist/record/rrweb-record.min.js +3 -3
- package/dist/record/rrweb-record.min.js.map +1 -1
- package/dist/replay/rrweb-replay-unpack.js +4 -4
- package/dist/replay/rrweb-replay-unpack.min.js +4 -4
- package/dist/replay/rrweb-replay-unpack.min.js.map +1 -1
- package/dist/replay/rrweb-replay.js +4 -4
- package/dist/replay/rrweb-replay.min.js +4 -4
- package/dist/replay/rrweb-replay.min.js.map +1 -1
- package/dist/rrweb-all.js +12 -12
- package/dist/rrweb-all.min.js +12 -12
- package/dist/rrweb-all.min.js.map +1 -1
- package/dist/rrweb.js +5 -5
- package/dist/rrweb.min.js +5 -5
- package/dist/rrweb.min.js.map +1 -1
- package/es/rrweb/packages/rrdom/es/virtual-dom.js +47 -24
- package/es/rrweb/packages/rrweb/src/record/index.js +5 -2
- package/es/rrweb/packages/rrweb/src/record/mutation.js +23 -11
- package/es/rrweb/packages/rrweb/src/record/observer.js +6 -6
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js +1 -1
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js +2 -2
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js +1 -2
- package/es/rrweb/packages/rrweb/src/utils.js +16 -23
- package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +292 -236
- package/lib/record/rrweb-record.js +333 -280
- package/lib/replay/rrweb-replay-unpack.js +57 -24
- package/lib/replay/rrweb-replay.js +57 -24
- package/lib/rrweb-all.js +390 -304
- package/lib/rrweb.js +390 -304
- package/package.json +4 -4
- package/typings/utils.d.ts +1 -1
package/lib/rrweb-all.js
CHANGED
|
@@ -18,7 +18,7 @@ function isElement(n) {
|
|
|
18
18
|
function isShadowRoot(n) {
|
|
19
19
|
var _a;
|
|
20
20
|
var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;
|
|
21
|
-
return Boolean(host
|
|
21
|
+
return Boolean((host === null || host === void 0 ? void 0 : host.shadowRoot) === n);
|
|
22
22
|
}
|
|
23
23
|
var Mirror$2 = (function () {
|
|
24
24
|
function Mirror() {
|
|
@@ -318,7 +318,7 @@ function _isBlockedElement(element, blockClass, blockSelector) {
|
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
else {
|
|
321
|
-
for (var eIndex =
|
|
321
|
+
for (var eIndex = element.classList.length; eIndex--;) {
|
|
322
322
|
var className = element.classList[eIndex];
|
|
323
323
|
if (blockClass.test(className)) {
|
|
324
324
|
return true;
|
|
@@ -330,35 +330,47 @@ function _isBlockedElement(element, blockClass, blockSelector) {
|
|
|
330
330
|
}
|
|
331
331
|
return false;
|
|
332
332
|
}
|
|
333
|
-
function
|
|
334
|
-
if (!node)
|
|
333
|
+
function classMatchesRegex(node, regex, checkAncestors) {
|
|
334
|
+
if (!node)
|
|
335
335
|
return false;
|
|
336
|
+
if (node.nodeType !== node.ELEMENT_NODE) {
|
|
337
|
+
if (!checkAncestors)
|
|
338
|
+
return false;
|
|
339
|
+
return classMatchesRegex(node.parentNode, regex, checkAncestors);
|
|
336
340
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
else {
|
|
344
|
-
for (var eIndex = 0; eIndex < node.classList.length; eIndex++) {
|
|
345
|
-
var className = node.classList[eIndex];
|
|
346
|
-
if (maskTextClass.test(className)) {
|
|
347
|
-
return true;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
if (maskTextSelector) {
|
|
352
|
-
if (node.matches(maskTextSelector)) {
|
|
353
|
-
return true;
|
|
354
|
-
}
|
|
341
|
+
for (var eIndex = node.classList.length; eIndex--;) {
|
|
342
|
+
var className = node.classList[eIndex];
|
|
343
|
+
if (regex.test(className)) {
|
|
344
|
+
return true;
|
|
355
345
|
}
|
|
356
|
-
return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);
|
|
357
346
|
}
|
|
358
|
-
if (
|
|
359
|
-
return
|
|
347
|
+
if (!checkAncestors)
|
|
348
|
+
return false;
|
|
349
|
+
return classMatchesRegex(node.parentNode, regex, checkAncestors);
|
|
350
|
+
}
|
|
351
|
+
function needMaskingText(node, maskTextClass, maskTextSelector) {
|
|
352
|
+
var el = node.nodeType === node.ELEMENT_NODE
|
|
353
|
+
? node
|
|
354
|
+
: node.parentElement;
|
|
355
|
+
if (el === null)
|
|
356
|
+
return false;
|
|
357
|
+
if (typeof maskTextClass === 'string') {
|
|
358
|
+
if (el.classList.contains(maskTextClass))
|
|
359
|
+
return true;
|
|
360
|
+
if (el.closest("." + maskTextClass))
|
|
361
|
+
return true;
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
if (classMatchesRegex(el, maskTextClass, true))
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
367
|
+
if (maskTextSelector) {
|
|
368
|
+
if (el.matches(maskTextSelector))
|
|
369
|
+
return true;
|
|
370
|
+
if (el.closest(maskTextSelector))
|
|
371
|
+
return true;
|
|
360
372
|
}
|
|
361
|
-
return
|
|
373
|
+
return false;
|
|
362
374
|
}
|
|
363
375
|
function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
|
|
364
376
|
var win = iframeEl.contentWindow;
|
|
@@ -425,13 +437,8 @@ function onceStylesheetLoaded(link, listener, iframeLoadTimeout) {
|
|
|
425
437
|
});
|
|
426
438
|
}
|
|
427
439
|
function serializeNode(n, options) {
|
|
428
|
-
var _a;
|
|
429
|
-
var
|
|
430
|
-
var rootId;
|
|
431
|
-
if (mirror.getMeta(doc)) {
|
|
432
|
-
var docId = mirror.getId(doc);
|
|
433
|
-
rootId = docId === 1 ? undefined : docId;
|
|
434
|
-
}
|
|
440
|
+
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;
|
|
441
|
+
var rootId = getRootId(doc, mirror);
|
|
435
442
|
switch (n.nodeType) {
|
|
436
443
|
case n.DOCUMENT_NODE:
|
|
437
444
|
if (n.compatMode !== 'CSS1Compat') {
|
|
@@ -458,203 +465,29 @@ function serializeNode(n, options) {
|
|
|
458
465
|
rootId: rootId
|
|
459
466
|
};
|
|
460
467
|
case n.ELEMENT_NODE:
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
if (stylesheet) {
|
|
475
|
-
cssText = getCssRulesString(stylesheet);
|
|
476
|
-
}
|
|
477
|
-
if (cssText) {
|
|
478
|
-
delete attributes_1.rel;
|
|
479
|
-
delete attributes_1.href;
|
|
480
|
-
attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
if (tagName === 'style' &&
|
|
484
|
-
n.sheet &&
|
|
485
|
-
!(n.innerText ||
|
|
486
|
-
n.textContent ||
|
|
487
|
-
'').trim().length) {
|
|
488
|
-
var cssText = getCssRulesString(n.sheet);
|
|
489
|
-
if (cssText) {
|
|
490
|
-
attributes_1._cssText = absoluteToStylesheet(cssText, getHref());
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
if (tagName === 'input' ||
|
|
494
|
-
tagName === 'textarea' ||
|
|
495
|
-
tagName === 'select') {
|
|
496
|
-
var value = n.value;
|
|
497
|
-
if (attributes_1.type !== 'radio' &&
|
|
498
|
-
attributes_1.type !== 'checkbox' &&
|
|
499
|
-
attributes_1.type !== 'submit' &&
|
|
500
|
-
attributes_1.type !== 'button' &&
|
|
501
|
-
value) {
|
|
502
|
-
attributes_1.value = maskInputValue({
|
|
503
|
-
type: attributes_1.type,
|
|
504
|
-
tagName: tagName,
|
|
505
|
-
value: value,
|
|
506
|
-
maskInputOptions: maskInputOptions,
|
|
507
|
-
maskInputFn: maskInputFn
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
else if (n.checked) {
|
|
511
|
-
attributes_1.checked = n.checked;
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
if (tagName === 'option') {
|
|
515
|
-
if (n.selected && !maskInputOptions['select']) {
|
|
516
|
-
attributes_1.selected = true;
|
|
517
|
-
}
|
|
518
|
-
else {
|
|
519
|
-
delete attributes_1.selected;
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
if (tagName === 'canvas' && recordCanvas) {
|
|
523
|
-
if (n.__context === '2d') {
|
|
524
|
-
if (!is2DCanvasBlank(n)) {
|
|
525
|
-
attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
else if (!('__context' in n)) {
|
|
529
|
-
var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
530
|
-
var blankCanvas = document.createElement('canvas');
|
|
531
|
-
blankCanvas.width = n.width;
|
|
532
|
-
blankCanvas.height = n.height;
|
|
533
|
-
var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
534
|
-
if (canvasDataURL !== blankCanvasDataURL) {
|
|
535
|
-
attributes_1.rr_dataURL = canvasDataURL;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
if (tagName === 'img' && inlineImages) {
|
|
540
|
-
if (!canvasService) {
|
|
541
|
-
canvasService = doc.createElement('canvas');
|
|
542
|
-
canvasCtx = canvasService.getContext('2d');
|
|
543
|
-
}
|
|
544
|
-
var image_1 = n;
|
|
545
|
-
var oldValue_1 = image_1.crossOrigin;
|
|
546
|
-
image_1.crossOrigin = 'anonymous';
|
|
547
|
-
var recordInlineImage = function () {
|
|
548
|
-
try {
|
|
549
|
-
canvasService.width = image_1.naturalWidth;
|
|
550
|
-
canvasService.height = image_1.naturalHeight;
|
|
551
|
-
canvasCtx.drawImage(image_1, 0, 0);
|
|
552
|
-
attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
553
|
-
}
|
|
554
|
-
catch (err) {
|
|
555
|
-
console.warn("Cannot inline img src=" + image_1.currentSrc + "! Error: " + err);
|
|
556
|
-
}
|
|
557
|
-
oldValue_1
|
|
558
|
-
? (attributes_1.crossOrigin = oldValue_1)
|
|
559
|
-
: image_1.removeAttribute('crossorigin');
|
|
560
|
-
};
|
|
561
|
-
if (image_1.complete && image_1.naturalWidth !== 0)
|
|
562
|
-
recordInlineImage();
|
|
563
|
-
else
|
|
564
|
-
image_1.onload = recordInlineImage;
|
|
565
|
-
}
|
|
566
|
-
if (tagName === 'audio' || tagName === 'video') {
|
|
567
|
-
attributes_1.rr_mediaState = n.paused
|
|
568
|
-
? 'paused'
|
|
569
|
-
: 'played';
|
|
570
|
-
attributes_1.rr_mediaCurrentTime = n.currentTime;
|
|
571
|
-
}
|
|
572
|
-
if (n.scrollLeft) {
|
|
573
|
-
attributes_1.rr_scrollLeft = n.scrollLeft;
|
|
574
|
-
}
|
|
575
|
-
if (n.scrollTop) {
|
|
576
|
-
attributes_1.rr_scrollTop = n.scrollTop;
|
|
577
|
-
}
|
|
578
|
-
if (needBlock || (tagName === 'img' && enableStrictPrivacy)) {
|
|
579
|
-
var _d = n.getBoundingClientRect(), width = _d.width, height = _d.height;
|
|
580
|
-
attributes_1 = {
|
|
581
|
-
"class": attributes_1["class"],
|
|
582
|
-
rr_width: width + "px",
|
|
583
|
-
rr_height: height + "px"
|
|
584
|
-
};
|
|
585
|
-
needBlock = true;
|
|
586
|
-
}
|
|
587
|
-
if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) {
|
|
588
|
-
if (!n.contentDocument) {
|
|
589
|
-
attributes_1.rr_src = attributes_1.src;
|
|
590
|
-
}
|
|
591
|
-
delete attributes_1.src;
|
|
592
|
-
}
|
|
593
|
-
return {
|
|
594
|
-
type: NodeType$2.Element,
|
|
595
|
-
tagName: tagName,
|
|
596
|
-
attributes: attributes_1,
|
|
597
|
-
childNodes: [],
|
|
598
|
-
isSVG: isSVGElement(n) || undefined,
|
|
599
|
-
needBlock: needBlock,
|
|
468
|
+
return serializeElementNode(n, {
|
|
469
|
+
doc: doc,
|
|
470
|
+
blockClass: blockClass,
|
|
471
|
+
blockSelector: blockSelector,
|
|
472
|
+
inlineStylesheet: inlineStylesheet,
|
|
473
|
+
maskInputOptions: maskInputOptions,
|
|
474
|
+
maskInputFn: maskInputFn,
|
|
475
|
+
dataURLOptions: dataURLOptions,
|
|
476
|
+
inlineImages: inlineImages,
|
|
477
|
+
recordCanvas: recordCanvas,
|
|
478
|
+
keepIframeSrcFn: keepIframeSrcFn,
|
|
479
|
+
newlyAddedElement: newlyAddedElement,
|
|
480
|
+
enableStrictPrivacy: enableStrictPrivacy,
|
|
600
481
|
rootId: rootId
|
|
601
|
-
};
|
|
482
|
+
});
|
|
602
483
|
case n.TEXT_NODE:
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
if (isStyle && textContent) {
|
|
609
|
-
try {
|
|
610
|
-
if (n.nextSibling || n.previousSibling) {
|
|
611
|
-
}
|
|
612
|
-
else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {
|
|
613
|
-
textContent = stringifyStyleSheet(n.parentNode.sheet);
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
catch (err) {
|
|
617
|
-
console.warn("Cannot get CSS styles from text's parentNode. Error: " + err, n);
|
|
618
|
-
}
|
|
619
|
-
textContent = absoluteToStylesheet(textContent, getHref());
|
|
620
|
-
textContentHandled = true;
|
|
621
|
-
}
|
|
622
|
-
if (isScript) {
|
|
623
|
-
textContent = 'SCRIPT_PLACEHOLDER';
|
|
624
|
-
textContentHandled = true;
|
|
625
|
-
}
|
|
626
|
-
else if (parentTagName === 'NOSCRIPT') {
|
|
627
|
-
textContent = '';
|
|
628
|
-
textContentHandled = true;
|
|
629
|
-
}
|
|
630
|
-
if (!isStyle &&
|
|
631
|
-
!isScript &&
|
|
632
|
-
needMaskingText(n, maskTextClass, maskTextSelector) &&
|
|
633
|
-
textContent) {
|
|
634
|
-
textContent = maskTextFn
|
|
635
|
-
? maskTextFn(textContent)
|
|
636
|
-
: textContent.replace(/[\S]/g, '*');
|
|
637
|
-
}
|
|
638
|
-
if (enableStrictPrivacy && !textContentHandled && parentTagName) {
|
|
639
|
-
var IGNORE_TAG_NAMES = new Set([
|
|
640
|
-
'HEAD',
|
|
641
|
-
'TITLE',
|
|
642
|
-
'STYLE',
|
|
643
|
-
'SCRIPT',
|
|
644
|
-
'HTML',
|
|
645
|
-
'BODY',
|
|
646
|
-
'NOSCRIPT',
|
|
647
|
-
]);
|
|
648
|
-
if (!IGNORE_TAG_NAMES.has(parentTagName) && textContent) {
|
|
649
|
-
textContent = obfuscateText(textContent);
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
return {
|
|
653
|
-
type: NodeType$2.Text,
|
|
654
|
-
textContent: textContent || '',
|
|
655
|
-
isStyle: isStyle,
|
|
484
|
+
return serializeTextNode(n, {
|
|
485
|
+
maskTextClass: maskTextClass,
|
|
486
|
+
maskTextSelector: maskTextSelector,
|
|
487
|
+
maskTextFn: maskTextFn,
|
|
488
|
+
enableStrictPrivacy: enableStrictPrivacy,
|
|
656
489
|
rootId: rootId
|
|
657
|
-
};
|
|
490
|
+
});
|
|
658
491
|
case n.CDATA_SECTION_NODE:
|
|
659
492
|
return {
|
|
660
493
|
type: NodeType$2.CDATA,
|
|
@@ -671,6 +504,213 @@ function serializeNode(n, options) {
|
|
|
671
504
|
return false;
|
|
672
505
|
}
|
|
673
506
|
}
|
|
507
|
+
function getRootId(doc, mirror) {
|
|
508
|
+
if (!mirror.hasNode(doc))
|
|
509
|
+
return undefined;
|
|
510
|
+
var docId = mirror.getId(doc);
|
|
511
|
+
return docId === 1 ? undefined : docId;
|
|
512
|
+
}
|
|
513
|
+
function serializeTextNode(n, options) {
|
|
514
|
+
var _a;
|
|
515
|
+
var maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, maskTextFn = options.maskTextFn, enableStrictPrivacy = options.enableStrictPrivacy, rootId = options.rootId;
|
|
516
|
+
var parentTagName = n.parentNode && n.parentNode.tagName;
|
|
517
|
+
var textContent = n.textContent;
|
|
518
|
+
var isStyle = parentTagName === 'STYLE' ? true : undefined;
|
|
519
|
+
var isScript = parentTagName === 'SCRIPT' ? true : undefined;
|
|
520
|
+
var textContentHandled = false;
|
|
521
|
+
if (isStyle && textContent) {
|
|
522
|
+
try {
|
|
523
|
+
if (n.nextSibling || n.previousSibling) {
|
|
524
|
+
}
|
|
525
|
+
else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {
|
|
526
|
+
textContent = stringifyStyleSheet(n.parentNode.sheet);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
catch (err) {
|
|
530
|
+
console.warn("Cannot get CSS styles from text's parentNode. Error: " + err, n);
|
|
531
|
+
}
|
|
532
|
+
textContent = absoluteToStylesheet(textContent, getHref());
|
|
533
|
+
textContentHandled = true;
|
|
534
|
+
}
|
|
535
|
+
if (isScript) {
|
|
536
|
+
textContent = 'SCRIPT_PLACEHOLDER';
|
|
537
|
+
textContentHandled = true;
|
|
538
|
+
}
|
|
539
|
+
else if (parentTagName === 'NOSCRIPT') {
|
|
540
|
+
textContent = '';
|
|
541
|
+
textContentHandled = true;
|
|
542
|
+
}
|
|
543
|
+
if (!isStyle &&
|
|
544
|
+
!isScript &&
|
|
545
|
+
textContent &&
|
|
546
|
+
needMaskingText(n, maskTextClass, maskTextSelector)) {
|
|
547
|
+
textContent = maskTextFn
|
|
548
|
+
? maskTextFn(textContent)
|
|
549
|
+
: textContent.replace(/[\S]/g, '*');
|
|
550
|
+
}
|
|
551
|
+
if (enableStrictPrivacy && !textContentHandled && parentTagName) {
|
|
552
|
+
var IGNORE_TAG_NAMES = new Set([
|
|
553
|
+
'HEAD',
|
|
554
|
+
'TITLE',
|
|
555
|
+
'STYLE',
|
|
556
|
+
'SCRIPT',
|
|
557
|
+
'HTML',
|
|
558
|
+
'BODY',
|
|
559
|
+
'NOSCRIPT',
|
|
560
|
+
]);
|
|
561
|
+
if (!IGNORE_TAG_NAMES.has(parentTagName) && textContent) {
|
|
562
|
+
textContent = obfuscateText(textContent);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return {
|
|
566
|
+
type: NodeType$2.Text,
|
|
567
|
+
textContent: textContent || '',
|
|
568
|
+
isStyle: isStyle,
|
|
569
|
+
rootId: rootId
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
function serializeElementNode(n, options) {
|
|
573
|
+
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;
|
|
574
|
+
var needBlock = _isBlockedElement(n, blockClass, blockSelector);
|
|
575
|
+
var tagName = getValidTagName$1(n);
|
|
576
|
+
var attributes = {};
|
|
577
|
+
var len = n.attributes.length;
|
|
578
|
+
for (var i = 0; i < len; i++) {
|
|
579
|
+
var attr = n.attributes[i];
|
|
580
|
+
attributes[attr.name] = transformAttribute(doc, tagName, attr.name, attr.value);
|
|
581
|
+
}
|
|
582
|
+
if (tagName === 'link' && inlineStylesheet) {
|
|
583
|
+
var stylesheet = Array.from(doc.styleSheets).find(function (s) {
|
|
584
|
+
return s.href === n.href;
|
|
585
|
+
});
|
|
586
|
+
var cssText = null;
|
|
587
|
+
if (stylesheet) {
|
|
588
|
+
cssText = getCssRulesString(stylesheet);
|
|
589
|
+
}
|
|
590
|
+
if (cssText) {
|
|
591
|
+
delete attributes.rel;
|
|
592
|
+
delete attributes.href;
|
|
593
|
+
attributes._cssText = absoluteToStylesheet(cssText, stylesheet.href);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
if (tagName === 'style' &&
|
|
597
|
+
n.sheet &&
|
|
598
|
+
!(n.innerText || n.textContent || '').trim().length) {
|
|
599
|
+
var cssText = getCssRulesString(n.sheet);
|
|
600
|
+
if (cssText) {
|
|
601
|
+
attributes._cssText = absoluteToStylesheet(cssText, getHref());
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
if (tagName === 'input' || tagName === 'textarea' || tagName === 'select') {
|
|
605
|
+
var value = n.value;
|
|
606
|
+
if (attributes.type !== 'radio' &&
|
|
607
|
+
attributes.type !== 'checkbox' &&
|
|
608
|
+
attributes.type !== 'submit' &&
|
|
609
|
+
attributes.type !== 'button' &&
|
|
610
|
+
value) {
|
|
611
|
+
attributes.value = maskInputValue({
|
|
612
|
+
type: attributes.type,
|
|
613
|
+
tagName: tagName,
|
|
614
|
+
value: value,
|
|
615
|
+
maskInputOptions: maskInputOptions,
|
|
616
|
+
maskInputFn: maskInputFn
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
else if (n.checked) {
|
|
620
|
+
attributes.checked = n.checked;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
if (tagName === 'option') {
|
|
624
|
+
if (n.selected && !maskInputOptions['select']) {
|
|
625
|
+
attributes.selected = true;
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
628
|
+
delete attributes.selected;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
if (tagName === 'canvas' && recordCanvas) {
|
|
632
|
+
if (n.__context === '2d') {
|
|
633
|
+
if (!is2DCanvasBlank(n)) {
|
|
634
|
+
attributes.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
else if (!('__context' in n)) {
|
|
638
|
+
var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
639
|
+
var blankCanvas = document.createElement('canvas');
|
|
640
|
+
blankCanvas.width = n.width;
|
|
641
|
+
blankCanvas.height = n.height;
|
|
642
|
+
var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
643
|
+
if (canvasDataURL !== blankCanvasDataURL) {
|
|
644
|
+
attributes.rr_dataURL = canvasDataURL;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
if (tagName === 'img' && inlineImages) {
|
|
649
|
+
if (!canvasService) {
|
|
650
|
+
canvasService = doc.createElement('canvas');
|
|
651
|
+
canvasCtx = canvasService.getContext('2d');
|
|
652
|
+
}
|
|
653
|
+
var image_1 = n;
|
|
654
|
+
var oldValue_1 = image_1.crossOrigin;
|
|
655
|
+
image_1.crossOrigin = 'anonymous';
|
|
656
|
+
var recordInlineImage = function () {
|
|
657
|
+
try {
|
|
658
|
+
canvasService.width = image_1.naturalWidth;
|
|
659
|
+
canvasService.height = image_1.naturalHeight;
|
|
660
|
+
canvasCtx.drawImage(image_1, 0, 0);
|
|
661
|
+
attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
662
|
+
}
|
|
663
|
+
catch (err) {
|
|
664
|
+
console.warn("Cannot inline img src=" + image_1.currentSrc + "! Error: " + err);
|
|
665
|
+
}
|
|
666
|
+
oldValue_1
|
|
667
|
+
? (attributes.crossOrigin = oldValue_1)
|
|
668
|
+
: image_1.removeAttribute('crossorigin');
|
|
669
|
+
};
|
|
670
|
+
if (image_1.complete && image_1.naturalWidth !== 0)
|
|
671
|
+
recordInlineImage();
|
|
672
|
+
else
|
|
673
|
+
image_1.onload = recordInlineImage;
|
|
674
|
+
}
|
|
675
|
+
if (tagName === 'audio' || tagName === 'video') {
|
|
676
|
+
attributes.rr_mediaState = n.paused
|
|
677
|
+
? 'paused'
|
|
678
|
+
: 'played';
|
|
679
|
+
attributes.rr_mediaCurrentTime = n.currentTime;
|
|
680
|
+
}
|
|
681
|
+
if (!newlyAddedElement) {
|
|
682
|
+
if (n.scrollLeft) {
|
|
683
|
+
attributes.rr_scrollLeft = n.scrollLeft;
|
|
684
|
+
}
|
|
685
|
+
if (n.scrollTop) {
|
|
686
|
+
attributes.rr_scrollTop = n.scrollTop;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
if (needBlock || (tagName === 'img' && enableStrictPrivacy)) {
|
|
690
|
+
var _d = n.getBoundingClientRect(), width = _d.width, height = _d.height;
|
|
691
|
+
attributes = {
|
|
692
|
+
"class": attributes["class"],
|
|
693
|
+
rr_width: width + "px",
|
|
694
|
+
rr_height: height + "px"
|
|
695
|
+
};
|
|
696
|
+
needBlock = true;
|
|
697
|
+
}
|
|
698
|
+
if (tagName === 'iframe' && !keepIframeSrcFn(attributes.src)) {
|
|
699
|
+
if (!n.contentDocument) {
|
|
700
|
+
attributes.rr_src = attributes.src;
|
|
701
|
+
}
|
|
702
|
+
delete attributes.src;
|
|
703
|
+
}
|
|
704
|
+
return {
|
|
705
|
+
type: NodeType$2.Element,
|
|
706
|
+
tagName: tagName,
|
|
707
|
+
attributes: attributes,
|
|
708
|
+
childNodes: [],
|
|
709
|
+
isSVG: isSVGElement(n) || undefined,
|
|
710
|
+
needBlock: needBlock,
|
|
711
|
+
rootId: rootId
|
|
712
|
+
};
|
|
713
|
+
}
|
|
674
714
|
function lowerIfExists(maybeAttr) {
|
|
675
715
|
if (maybeAttr === undefined) {
|
|
676
716
|
return '';
|
|
@@ -751,8 +791,8 @@ function slimDOMExcluded(sn, slimDOMOptions) {
|
|
|
751
791
|
return false;
|
|
752
792
|
}
|
|
753
793
|
function serializeNodeWithId(n, options) {
|
|
754
|
-
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, enableStrictPrivacy = options.enableStrictPrivacy;
|
|
755
|
-
var
|
|
794
|
+
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;
|
|
795
|
+
var _l = options.preserveWhiteSpace, preserveWhiteSpace = _l === void 0 ? true : _l;
|
|
756
796
|
var _serializedNode = serializeNode(n, {
|
|
757
797
|
doc: doc,
|
|
758
798
|
mirror: mirror,
|
|
@@ -768,6 +808,7 @@ function serializeNodeWithId(n, options) {
|
|
|
768
808
|
inlineImages: inlineImages,
|
|
769
809
|
recordCanvas: recordCanvas,
|
|
770
810
|
keepIframeSrcFn: keepIframeSrcFn,
|
|
811
|
+
newlyAddedElement: newlyAddedElement,
|
|
771
812
|
enableStrictPrivacy: enableStrictPrivacy
|
|
772
813
|
});
|
|
773
814
|
if (!_serializedNode) {
|
|
@@ -841,16 +882,16 @@ function serializeNodeWithId(n, options) {
|
|
|
841
882
|
keepIframeSrcFn: keepIframeSrcFn,
|
|
842
883
|
enableStrictPrivacy: enableStrictPrivacy
|
|
843
884
|
};
|
|
844
|
-
for (var _i = 0,
|
|
845
|
-
var childN =
|
|
885
|
+
for (var _i = 0, _m = Array.from(n.childNodes); _i < _m.length; _i++) {
|
|
886
|
+
var childN = _m[_i];
|
|
846
887
|
var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
847
888
|
if (serializedChildNode) {
|
|
848
889
|
serializedNode.childNodes.push(serializedChildNode);
|
|
849
890
|
}
|
|
850
891
|
}
|
|
851
892
|
if (isElement(n) && n.shadowRoot) {
|
|
852
|
-
for (var
|
|
853
|
-
var childN = _o
|
|
893
|
+
for (var _o = 0, _p = Array.from(n.shadowRoot.childNodes); _o < _p.length; _o++) {
|
|
894
|
+
var childN = _p[_o];
|
|
854
895
|
var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
855
896
|
if (serializedChildNode) {
|
|
856
897
|
serializedChildNode.isShadow = true;
|
|
@@ -887,6 +928,8 @@ function serializeNodeWithId(n, options) {
|
|
|
887
928
|
onSerialize: onSerialize,
|
|
888
929
|
onIframeLoad: onIframeLoad,
|
|
889
930
|
iframeLoadTimeout: iframeLoadTimeout,
|
|
931
|
+
onStylesheetLoad: onStylesheetLoad,
|
|
932
|
+
stylesheetLoadTimeout: stylesheetLoadTimeout,
|
|
890
933
|
keepIframeSrcFn: keepIframeSrcFn,
|
|
891
934
|
enableStrictPrivacy: enableStrictPrivacy
|
|
892
935
|
});
|
|
@@ -920,8 +963,9 @@ function serializeNodeWithId(n, options) {
|
|
|
920
963
|
preserveWhiteSpace: preserveWhiteSpace,
|
|
921
964
|
onSerialize: onSerialize,
|
|
922
965
|
onIframeLoad: onIframeLoad,
|
|
923
|
-
onStylesheetLoad: onStylesheetLoad,
|
|
924
966
|
iframeLoadTimeout: iframeLoadTimeout,
|
|
967
|
+
onStylesheetLoad: onStylesheetLoad,
|
|
968
|
+
stylesheetLoadTimeout: stylesheetLoadTimeout,
|
|
925
969
|
keepIframeSrcFn: keepIframeSrcFn,
|
|
926
970
|
enableStrictPrivacy: enableStrictPrivacy
|
|
927
971
|
});
|
|
@@ -999,7 +1043,9 @@ function snapshot(n, options) {
|
|
|
999
1043
|
onIframeLoad: onIframeLoad,
|
|
1000
1044
|
iframeLoadTimeout: iframeLoadTimeout,
|
|
1001
1045
|
onStylesheetLoad: onStylesheetLoad,
|
|
1002
|
-
stylesheetLoadTimeout: stylesheetLoadTimeout,
|
|
1046
|
+
stylesheetLoadTimeout: stylesheetLoadTimeout,
|
|
1047
|
+
keepIframeSrcFn: keepIframeSrcFn,
|
|
1048
|
+
newlyAddedElement: false,
|
|
1003
1049
|
enableStrictPrivacy: enableStrictPrivacy
|
|
1004
1050
|
});
|
|
1005
1051
|
}
|
|
@@ -1660,6 +1706,7 @@ function buildNode(n, options) {
|
|
|
1660
1706
|
if (!image.currentSrc.startsWith('data:')) {
|
|
1661
1707
|
image.setAttribute('rrweb-original-src', n.attributes.src);
|
|
1662
1708
|
image.src = value;
|
|
1709
|
+
image.setAttribute('rrweb-inline-src', value);
|
|
1663
1710
|
}
|
|
1664
1711
|
}
|
|
1665
1712
|
if (name_1 === 'rr_width') {
|
|
@@ -1688,6 +1735,15 @@ function buildNode(n, options) {
|
|
|
1688
1735
|
for (var name_1 in n.attributes) {
|
|
1689
1736
|
_loop_1(name_1);
|
|
1690
1737
|
}
|
|
1738
|
+
if (tagName === 'img') {
|
|
1739
|
+
var image = node_1;
|
|
1740
|
+
if (!image.currentSrc.startsWith('data:')) {
|
|
1741
|
+
var inlineSrc = image.getAttribute('rrweb-inline-src');
|
|
1742
|
+
if (inlineSrc === null || inlineSrc === void 0 ? void 0 : inlineSrc.startsWith('data:')) {
|
|
1743
|
+
image.src = inlineSrc;
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1691
1747
|
if (n.isShadowHost) {
|
|
1692
1748
|
if (!node_1.shadowRoot) {
|
|
1693
1749
|
node_1.attachShadow({ mode: 'open' });
|
|
@@ -1947,33 +2003,26 @@ const isCanvasNode = (node) => {
|
|
|
1947
2003
|
}
|
|
1948
2004
|
return false;
|
|
1949
2005
|
};
|
|
1950
|
-
function isBlocked(node, blockClass) {
|
|
2006
|
+
function isBlocked(node, blockClass, checkAncestors) {
|
|
1951
2007
|
if (!node) {
|
|
1952
2008
|
return false;
|
|
1953
2009
|
}
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
else {
|
|
1965
|
-
node.classList.forEach((className) => {
|
|
1966
|
-
if (blockClass.test(className)) {
|
|
1967
|
-
needBlock = true;
|
|
1968
|
-
}
|
|
1969
|
-
});
|
|
1970
|
-
}
|
|
1971
|
-
return needBlock || isBlocked(node.parentNode, blockClass);
|
|
2010
|
+
const el = node.nodeType === node.ELEMENT_NODE
|
|
2011
|
+
? node
|
|
2012
|
+
: node.parentElement;
|
|
2013
|
+
if (!el)
|
|
2014
|
+
return false;
|
|
2015
|
+
if (typeof blockClass === 'string') {
|
|
2016
|
+
if (el.classList.contains(blockClass))
|
|
2017
|
+
return true;
|
|
2018
|
+
if (checkAncestors && el.closest('.' + blockClass) !== null)
|
|
2019
|
+
return true;
|
|
1972
2020
|
}
|
|
1973
|
-
|
|
1974
|
-
|
|
2021
|
+
else {
|
|
2022
|
+
if (classMatchesRegex(el, blockClass, checkAncestors))
|
|
2023
|
+
return true;
|
|
1975
2024
|
}
|
|
1976
|
-
return
|
|
2025
|
+
return false;
|
|
1977
2026
|
}
|
|
1978
2027
|
function isSerialized(n, mirror) {
|
|
1979
2028
|
return mirror.getId(n) !== -1;
|
|
@@ -2394,6 +2443,7 @@ class MutationBuffer {
|
|
|
2394
2443
|
onStylesheetLoad: (link, childSn) => {
|
|
2395
2444
|
this.stylesheetManager.attachStylesheet(link, childSn, this.mirror);
|
|
2396
2445
|
},
|
|
2446
|
+
newlyAddedElement: true,
|
|
2397
2447
|
});
|
|
2398
2448
|
if (sn) {
|
|
2399
2449
|
adds.push({
|
|
@@ -2502,7 +2552,8 @@ class MutationBuffer {
|
|
|
2502
2552
|
switch (m.type) {
|
|
2503
2553
|
case 'characterData': {
|
|
2504
2554
|
const value = m.target.textContent;
|
|
2505
|
-
if (!isBlocked(m.target, this.blockClass) &&
|
|
2555
|
+
if (!isBlocked(m.target, this.blockClass, false) &&
|
|
2556
|
+
value !== m.oldValue) {
|
|
2506
2557
|
this.texts.push({
|
|
2507
2558
|
value: needMaskingText(m.target, this.maskTextClass, this.maskTextSelector) && value
|
|
2508
2559
|
? this.maskTextFn
|
|
@@ -2526,7 +2577,8 @@ class MutationBuffer {
|
|
|
2526
2577
|
maskInputFn: this.maskInputFn,
|
|
2527
2578
|
});
|
|
2528
2579
|
}
|
|
2529
|
-
if (isBlocked(m.target, this.blockClass) ||
|
|
2580
|
+
if (isBlocked(m.target, this.blockClass, false) ||
|
|
2581
|
+
value === m.oldValue) {
|
|
2530
2582
|
return;
|
|
2531
2583
|
}
|
|
2532
2584
|
let item = this.attributes.find((a) => a.node === m.target);
|
|
@@ -2580,13 +2632,15 @@ class MutationBuffer {
|
|
|
2580
2632
|
break;
|
|
2581
2633
|
}
|
|
2582
2634
|
case 'childList': {
|
|
2635
|
+
if (isBlocked(m.target, this.blockClass, true))
|
|
2636
|
+
return;
|
|
2583
2637
|
m.addedNodes.forEach((n) => this.genAdds(n, m.target));
|
|
2584
2638
|
m.removedNodes.forEach((n) => {
|
|
2585
2639
|
const nodeId = this.mirror.getId(n);
|
|
2586
2640
|
const parentId = isShadowRoot(m.target)
|
|
2587
2641
|
? this.mirror.getId(m.target.host)
|
|
2588
2642
|
: this.mirror.getId(m.target);
|
|
2589
|
-
if (isBlocked(m.target, this.blockClass) ||
|
|
2643
|
+
if (isBlocked(m.target, this.blockClass, false) ||
|
|
2590
2644
|
isIgnored(n, this.mirror) ||
|
|
2591
2645
|
!isSerialized(n, this.mirror)) {
|
|
2592
2646
|
return;
|
|
@@ -2615,16 +2669,13 @@ class MutationBuffer {
|
|
|
2615
2669
|
}
|
|
2616
2670
|
};
|
|
2617
2671
|
this.genAdds = (n, target) => {
|
|
2618
|
-
if (
|
|
2619
|
-
return;
|
|
2620
|
-
}
|
|
2621
|
-
if (this.mirror.getMeta(n)) {
|
|
2672
|
+
if (this.mirror.hasNode(n)) {
|
|
2622
2673
|
if (isIgnored(n, this.mirror)) {
|
|
2623
2674
|
return;
|
|
2624
2675
|
}
|
|
2625
2676
|
this.movedSet.add(n);
|
|
2626
2677
|
let targetId = null;
|
|
2627
|
-
if (target && this.mirror.
|
|
2678
|
+
if (target && this.mirror.hasNode(target)) {
|
|
2628
2679
|
targetId = this.mirror.getId(target);
|
|
2629
2680
|
}
|
|
2630
2681
|
if (targetId && targetId !== -1) {
|
|
@@ -2635,7 +2686,7 @@ class MutationBuffer {
|
|
|
2635
2686
|
this.addedSet.add(n);
|
|
2636
2687
|
this.droppedSet.delete(n);
|
|
2637
2688
|
}
|
|
2638
|
-
if (!isBlocked(n, this.blockClass))
|
|
2689
|
+
if (!isBlocked(n, this.blockClass, false))
|
|
2639
2690
|
n.childNodes.forEach((childN) => this.genAdds(childN));
|
|
2640
2691
|
};
|
|
2641
2692
|
}
|
|
@@ -2695,6 +2746,11 @@ function deepDelete(addsSet, n) {
|
|
|
2695
2746
|
n.childNodes.forEach((childN) => deepDelete(addsSet, childN));
|
|
2696
2747
|
}
|
|
2697
2748
|
function isParentRemoved(removes, n, mirror) {
|
|
2749
|
+
if (removes.length === 0)
|
|
2750
|
+
return false;
|
|
2751
|
+
return _isParentRemoved(removes, n, mirror);
|
|
2752
|
+
}
|
|
2753
|
+
function _isParentRemoved(removes, n, mirror) {
|
|
2698
2754
|
const { parentNode } = n;
|
|
2699
2755
|
if (!parentNode) {
|
|
2700
2756
|
return false;
|
|
@@ -2703,9 +2759,14 @@ function isParentRemoved(removes, n, mirror) {
|
|
|
2703
2759
|
if (removes.some((r) => r.id === parentId)) {
|
|
2704
2760
|
return true;
|
|
2705
2761
|
}
|
|
2706
|
-
return
|
|
2762
|
+
return _isParentRemoved(removes, parentNode, mirror);
|
|
2707
2763
|
}
|
|
2708
2764
|
function isAncestorInSet(set, n) {
|
|
2765
|
+
if (set.size === 0)
|
|
2766
|
+
return false;
|
|
2767
|
+
return _isAncestorInSet(set, n);
|
|
2768
|
+
}
|
|
2769
|
+
function _isAncestorInSet(set, n) {
|
|
2709
2770
|
const { parentNode } = n;
|
|
2710
2771
|
if (!parentNode) {
|
|
2711
2772
|
return false;
|
|
@@ -2713,7 +2774,7 @@ function isAncestorInSet(set, n) {
|
|
|
2713
2774
|
if (set.has(parentNode)) {
|
|
2714
2775
|
return true;
|
|
2715
2776
|
}
|
|
2716
|
-
return
|
|
2777
|
+
return _isAncestorInSet(set, parentNode);
|
|
2717
2778
|
}
|
|
2718
2779
|
|
|
2719
2780
|
const mutationBuffers = [];
|
|
@@ -2823,7 +2884,7 @@ function initMouseInteractionObserver({ mouseInteractionCb, doc, mirror, blockCl
|
|
|
2823
2884
|
const getHandler = (eventKey) => {
|
|
2824
2885
|
return (event) => {
|
|
2825
2886
|
const target = getEventTarget(event);
|
|
2826
|
-
if (isBlocked(target, blockClass) ||
|
|
2887
|
+
if (isBlocked(target, blockClass, true) ||
|
|
2827
2888
|
isCanvasNode(target)) {
|
|
2828
2889
|
return;
|
|
2829
2890
|
}
|
|
@@ -2857,7 +2918,7 @@ function initMouseInteractionObserver({ mouseInteractionCb, doc, mirror, blockCl
|
|
|
2857
2918
|
function initScrollObserver({ scrollCb, doc, mirror, blockClass, sampling, }) {
|
|
2858
2919
|
const updatePosition = throttle((evt) => {
|
|
2859
2920
|
const target = getEventTarget(evt);
|
|
2860
|
-
if (!target || isBlocked(target, blockClass)) {
|
|
2921
|
+
if (!target || isBlocked(target, blockClass, true)) {
|
|
2861
2922
|
return;
|
|
2862
2923
|
}
|
|
2863
2924
|
const id = mirror.getId(target);
|
|
@@ -2913,7 +2974,7 @@ function initInputObserver({ inputCb, doc, mirror, blockClass, ignoreClass, mask
|
|
|
2913
2974
|
if (!target ||
|
|
2914
2975
|
!target.tagName ||
|
|
2915
2976
|
INPUT_TAGS.indexOf(target.tagName) < 0 ||
|
|
2916
|
-
isBlocked(target, blockClass)) {
|
|
2977
|
+
isBlocked(target, blockClass, true)) {
|
|
2917
2978
|
return;
|
|
2918
2979
|
}
|
|
2919
2980
|
const type = target.type;
|
|
@@ -3048,8 +3109,8 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror }, { win }) {
|
|
|
3048
3109
|
const unmodifiedFunctions = {};
|
|
3049
3110
|
Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {
|
|
3050
3111
|
unmodifiedFunctions[typeKey] = {
|
|
3051
|
-
insertRule:
|
|
3052
|
-
deleteRule:
|
|
3112
|
+
insertRule: type.prototype.insertRule,
|
|
3113
|
+
deleteRule: type.prototype.deleteRule,
|
|
3053
3114
|
};
|
|
3054
3115
|
type.prototype.insertRule = function (rule, index) {
|
|
3055
3116
|
const id = mirror.getId(this.parentStyleSheet.ownerNode);
|
|
@@ -3130,7 +3191,7 @@ function initStyleDeclarationObserver({ styleDeclarationCb, mirror }, { win }) {
|
|
|
3130
3191
|
function initMediaInteractionObserver({ mediaInteractionCb, blockClass, mirror, sampling, }) {
|
|
3131
3192
|
const handler = (type) => throttle((event) => {
|
|
3132
3193
|
const target = getEventTarget(event);
|
|
3133
|
-
if (!target || isBlocked(target, blockClass)) {
|
|
3194
|
+
if (!target || isBlocked(target, blockClass, true)) {
|
|
3134
3195
|
return;
|
|
3135
3196
|
}
|
|
3136
3197
|
const { currentTime, volume, muted } = target;
|
|
@@ -3584,7 +3645,7 @@ function initCanvas2DMutationObserver(cb, win, blockClass, mirror) {
|
|
|
3584
3645
|
}
|
|
3585
3646
|
const restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function (original) {
|
|
3586
3647
|
return function (...args) {
|
|
3587
|
-
if (!isBlocked(this.canvas, blockClass)) {
|
|
3648
|
+
if (!isBlocked(this.canvas, blockClass, true)) {
|
|
3588
3649
|
setTimeout(() => {
|
|
3589
3650
|
const recordArgs = serializeArgs([...args], win, this);
|
|
3590
3651
|
cb(this.canvas, {
|
|
@@ -3623,9 +3684,9 @@ function initCanvasContextObserver(win, blockClass) {
|
|
|
3623
3684
|
try {
|
|
3624
3685
|
const restoreHandler = patch(win.HTMLCanvasElement.prototype, 'getContext', function (original) {
|
|
3625
3686
|
return function (contextType, ...args) {
|
|
3626
|
-
if (!isBlocked(this, blockClass)) {
|
|
3687
|
+
if (!isBlocked(this, blockClass, true)) {
|
|
3627
3688
|
if (!('__context' in this))
|
|
3628
|
-
|
|
3689
|
+
this.__context = contextType;
|
|
3629
3690
|
}
|
|
3630
3691
|
return original.apply(this, [contextType, ...args]);
|
|
3631
3692
|
};
|
|
@@ -3652,8 +3713,7 @@ function patchGLPrototype(prototype, type, cb, blockClass, mirror, win) {
|
|
|
3652
3713
|
return function (...args) {
|
|
3653
3714
|
const result = original.apply(this, args);
|
|
3654
3715
|
saveWebGLVar(result, win, prototype);
|
|
3655
|
-
if (!isBlocked(this.canvas, blockClass)) {
|
|
3656
|
-
const id = mirror.getId(this.canvas);
|
|
3716
|
+
if (!isBlocked(this.canvas, blockClass, true)) {
|
|
3657
3717
|
const recordArgs = serializeArgs([...args], win, prototype);
|
|
3658
3718
|
const mutation = {
|
|
3659
3719
|
type,
|
|
@@ -4132,6 +4192,9 @@ function record(options = {}) {
|
|
|
4132
4192
|
if (isSerializedIframe(n, mirror)) {
|
|
4133
4193
|
iframeManager.addIframe(n);
|
|
4134
4194
|
}
|
|
4195
|
+
if (isSerializedStylesheet(n, mirror)) {
|
|
4196
|
+
stylesheetManager.addStylesheet(n);
|
|
4197
|
+
}
|
|
4135
4198
|
if (hasShadowRoot(n)) {
|
|
4136
4199
|
shadowDomManager.addShadowRoot(n.shadowRoot, document);
|
|
4137
4200
|
}
|
|
@@ -4141,7 +4204,7 @@ function record(options = {}) {
|
|
|
4141
4204
|
shadowDomManager.observeAttachShadow(iframe);
|
|
4142
4205
|
},
|
|
4143
4206
|
onStylesheetLoad: (linkEl, childSn) => {
|
|
4144
|
-
|
|
4207
|
+
stylesheetManager.attachStylesheet(linkEl, childSn, mirror);
|
|
4145
4208
|
},
|
|
4146
4209
|
keepIframeSrcFn,
|
|
4147
4210
|
});
|
|
@@ -4842,7 +4905,7 @@ function diff(oldTree, newTree, replayer, rrnodeMirror) {
|
|
|
4842
4905
|
break;
|
|
4843
4906
|
}
|
|
4844
4907
|
case NodeType$1.Element: {
|
|
4845
|
-
const oldElement =
|
|
4908
|
+
const oldElement = oldTree;
|
|
4846
4909
|
const newRRElement = newTree;
|
|
4847
4910
|
diffProps(oldElement, newRRElement, rrnodeMirror);
|
|
4848
4911
|
scrollDataToApply = newRRElement.scrollData;
|
|
@@ -4850,7 +4913,7 @@ function diff(oldTree, newTree, replayer, rrnodeMirror) {
|
|
|
4850
4913
|
switch (newRRElement.tagName) {
|
|
4851
4914
|
case 'AUDIO':
|
|
4852
4915
|
case 'VIDEO': {
|
|
4853
|
-
const oldMediaElement =
|
|
4916
|
+
const oldMediaElement = oldTree;
|
|
4854
4917
|
const newMediaRRElement = newRRElement;
|
|
4855
4918
|
if (newMediaRRElement.paused !== undefined)
|
|
4856
4919
|
newMediaRRElement.paused
|
|
@@ -4865,7 +4928,7 @@ function diff(oldTree, newTree, replayer, rrnodeMirror) {
|
|
|
4865
4928
|
break;
|
|
4866
4929
|
}
|
|
4867
4930
|
case 'CANVAS':
|
|
4868
|
-
newTree.canvasMutations.forEach((canvasMutation) => replayer.applyCanvas(canvasMutation.event, canvasMutation.mutation,
|
|
4931
|
+
newTree.canvasMutations.forEach((canvasMutation) => replayer.applyCanvas(canvasMutation.event, canvasMutation.mutation, oldTree));
|
|
4869
4932
|
break;
|
|
4870
4933
|
case 'STYLE':
|
|
4871
4934
|
applyVirtualStyleRulesToNode(oldElement, newTree.rules);
|
|
@@ -4892,8 +4955,7 @@ function diff(oldTree, newTree, replayer, rrnodeMirror) {
|
|
|
4892
4955
|
scrollDataToApply && replayer.applyScroll(scrollDataToApply, true);
|
|
4893
4956
|
inputDataToApply && replayer.applyInput(inputDataToApply);
|
|
4894
4957
|
if (newTree.nodeName === 'IFRAME') {
|
|
4895
|
-
const oldContentDocument =
|
|
4896
|
-
.contentDocument;
|
|
4958
|
+
const oldContentDocument = oldTree.contentDocument;
|
|
4897
4959
|
const newIFrameElement = newTree;
|
|
4898
4960
|
if (oldContentDocument) {
|
|
4899
4961
|
const sn = rrnodeMirror.getMeta(newIFrameElement.contentDocument);
|
|
@@ -4954,16 +5016,26 @@ function diffChildren(oldChildren, newChildren, parentNode, replayer, rrnodeMirr
|
|
|
4954
5016
|
newEndNode = newChildren[--newEndIndex];
|
|
4955
5017
|
}
|
|
4956
5018
|
else if (replayer.mirror.getId(oldStartNode) === rrnodeMirror.getId(newEndNode)) {
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
5019
|
+
try {
|
|
5020
|
+
parentNode.insertBefore(oldStartNode, oldEndNode.nextSibling);
|
|
5021
|
+
diff(oldStartNode, newEndNode, replayer, rrnodeMirror);
|
|
5022
|
+
oldStartNode = oldChildren[++oldStartIndex];
|
|
5023
|
+
newEndNode = newChildren[--newEndIndex];
|
|
5024
|
+
}
|
|
5025
|
+
catch (e) {
|
|
5026
|
+
console.error(e, parentNode, oldStartNode, oldEndNode);
|
|
5027
|
+
}
|
|
4961
5028
|
}
|
|
4962
5029
|
else if (replayer.mirror.getId(oldEndNode) === rrnodeMirror.getId(newStartNode)) {
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
5030
|
+
try {
|
|
5031
|
+
parentNode.insertBefore(oldEndNode, oldStartNode);
|
|
5032
|
+
diff(oldEndNode, newStartNode, replayer, rrnodeMirror);
|
|
5033
|
+
oldEndNode = oldChildren[--oldEndIndex];
|
|
5034
|
+
newStartNode = newChildren[++newStartIndex];
|
|
5035
|
+
}
|
|
5036
|
+
catch (e) {
|
|
5037
|
+
console.error(e, parentNode, oldEndNode, oldStartNode);
|
|
5038
|
+
}
|
|
4967
5039
|
}
|
|
4968
5040
|
else {
|
|
4969
5041
|
if (!oldIdToIndex) {
|
|
@@ -4977,21 +5049,31 @@ function diffChildren(oldChildren, newChildren, parentNode, replayer, rrnodeMirr
|
|
|
4977
5049
|
indexInOld = oldIdToIndex[rrnodeMirror.getId(newStartNode)];
|
|
4978
5050
|
if (indexInOld) {
|
|
4979
5051
|
const nodeToMove = oldChildren[indexInOld];
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
5052
|
+
try {
|
|
5053
|
+
parentNode.insertBefore(nodeToMove, oldStartNode);
|
|
5054
|
+
diff(nodeToMove, newStartNode, replayer, rrnodeMirror);
|
|
5055
|
+
oldChildren[indexInOld] = undefined;
|
|
5056
|
+
}
|
|
5057
|
+
catch (e) {
|
|
5058
|
+
console.error(e, parentNode, nodeToMove, oldStartNode);
|
|
5059
|
+
}
|
|
4983
5060
|
}
|
|
4984
5061
|
else {
|
|
4985
5062
|
const newNode = createOrGetNode(newStartNode, replayer.mirror, rrnodeMirror);
|
|
4986
5063
|
if (((_a = replayer.mirror.getMeta(parentNode)) === null || _a === void 0 ? void 0 : _a.type) === NodeType$1.Document &&
|
|
4987
5064
|
((_b = replayer.mirror.getMeta(newNode)) === null || _b === void 0 ? void 0 : _b.type) === NodeType$1.Element &&
|
|
4988
|
-
|
|
4989
|
-
parentNode.removeChild(
|
|
5065
|
+
parentNode.documentElement) {
|
|
5066
|
+
parentNode.removeChild(parentNode.documentElement);
|
|
4990
5067
|
oldChildren[oldStartIndex] = undefined;
|
|
4991
5068
|
oldStartNode = undefined;
|
|
4992
5069
|
}
|
|
4993
|
-
|
|
4994
|
-
|
|
5070
|
+
try {
|
|
5071
|
+
parentNode.insertBefore(newNode, oldStartNode || null);
|
|
5072
|
+
diff(newNode, newStartNode, replayer, rrnodeMirror);
|
|
5073
|
+
}
|
|
5074
|
+
catch (e) {
|
|
5075
|
+
console.error(e, parentNode, newNode, oldStartNode || null);
|
|
5076
|
+
}
|
|
4995
5077
|
}
|
|
4996
5078
|
newStartNode = newChildren[++newStartIndex];
|
|
4997
5079
|
}
|
|
@@ -5006,8 +5088,13 @@ function diffChildren(oldChildren, newChildren, parentNode, replayer, rrnodeMirr
|
|
|
5006
5088
|
});
|
|
5007
5089
|
for (; newStartIndex <= newEndIndex; ++newStartIndex) {
|
|
5008
5090
|
const newNode = createOrGetNode(newChildren[newStartIndex], replayer.mirror, rrnodeMirror);
|
|
5009
|
-
|
|
5010
|
-
|
|
5091
|
+
try {
|
|
5092
|
+
parentNode.insertBefore(newNode, referenceNode);
|
|
5093
|
+
diff(newNode, newChildren[newStartIndex], replayer, rrnodeMirror);
|
|
5094
|
+
}
|
|
5095
|
+
catch (e) {
|
|
5096
|
+
console.error(e, parentNode, newNode, referenceNode);
|
|
5097
|
+
}
|
|
5011
5098
|
}
|
|
5012
5099
|
}
|
|
5013
5100
|
else if (newStartIndex > newEndIndex) {
|
|
@@ -5061,8 +5148,7 @@ function getNestedRule(rules, position) {
|
|
|
5061
5148
|
return rule;
|
|
5062
5149
|
}
|
|
5063
5150
|
else {
|
|
5064
|
-
return getNestedRule(
|
|
5065
|
-
.cssRules, position.slice(2));
|
|
5151
|
+
return getNestedRule(rule.cssRules[position[1]].cssRules, position.slice(2));
|
|
5066
5152
|
}
|
|
5067
5153
|
}
|
|
5068
5154
|
var StyleRuleType;
|