@highlight-run/rrweb 2.0.1 → 2.0.4
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.js +408 -609
- package/dist/plugins/console-record.min.js +12 -15
- package/dist/plugins/console-record.min.js.map +1 -1
- package/dist/plugins/console-replay.js +142 -271
- package/dist/plugins/console-replay.min.js +4 -15
- package/dist/plugins/console-replay.min.js.map +1 -1
- package/dist/plugins/sequential-id-record.js +23 -26
- package/dist/plugins/sequential-id-record.min.js +1 -1
- package/dist/plugins/sequential-id-record.min.js.map +1 -1
- package/dist/plugins/sequential-id-replay.js +26 -30
- package/dist/plugins/sequential-id-replay.min.js +1 -1
- package/dist/plugins/sequential-id-replay.min.js.map +1 -1
- package/dist/record/rrweb-record-pack.js +63 -146
- package/dist/record/rrweb-record-pack.min.js +3 -15
- package/dist/record/rrweb-record-pack.min.js.map +1 -1
- package/dist/record/rrweb-record.js +3002 -3118
- package/dist/record/rrweb-record.min.js +4 -15
- package/dist/record/rrweb-record.min.js.map +1 -1
- package/dist/replay/rrweb-replay-unpack.js +4354 -4054
- package/dist/replay/rrweb-replay-unpack.min.js +5 -17
- package/dist/replay/rrweb-replay-unpack.min.js.map +1 -1
- package/dist/replay/rrweb-replay.js +4286 -3984
- package/dist/replay/rrweb-replay.min.js +5 -17
- package/dist/replay/rrweb-replay.min.js.map +1 -1
- package/dist/rrweb-all.js +7634 -7453
- package/dist/rrweb-all.min.js +16 -17
- package/dist/rrweb-all.min.js.map +1 -1
- package/dist/rrweb.js +7339 -7075
- package/dist/rrweb.min.js +6 -17
- package/dist/rrweb.min.js.map +1 -1
- package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +12 -0
- package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +7 -0
- package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +31 -0
- package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +11 -0
- package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +18 -0
- package/es/rrweb/_virtual/image-bitmap-data-url-worker.js +6 -0
- package/es/rrweb/ext/mitt/dist/mitt.es.js +1 -1
- package/es/rrweb/ext/tslib/tslib.es6.js +38 -0
- package/es/rrweb/packages/rrdom/es/virtual-dom.js +1099 -0
- package/es/rrweb/packages/rrweb/src/index.js +6 -4
- package/es/rrweb/packages/rrweb/src/packer/base.js +1 -1
- package/es/rrweb/packages/rrweb/src/packer/pack.js +4 -5
- package/es/rrweb/packages/rrweb/src/packer/unpack.js +24 -24
- package/es/rrweb/packages/rrweb/src/plugins/console/record/error-stack-parser.js +175 -176
- package/es/rrweb/packages/rrweb/src/plugins/console/record/index.js +109 -128
- package/es/rrweb/packages/rrweb/src/plugins/console/record/stringify.js +125 -138
- package/es/rrweb/packages/rrweb/src/plugins/console/replay/index.js +88 -105
- package/es/rrweb/packages/rrweb/src/plugins/sequential-id/record/index.js +19 -20
- package/es/rrweb/packages/rrweb/src/plugins/sequential-id/replay/index.js +25 -25
- package/es/rrweb/packages/rrweb/src/record/iframe-manager.js +29 -30
- package/es/rrweb/packages/rrweb/src/record/index.js +348 -373
- package/es/rrweb/packages/rrweb/src/record/mutation.js +487 -528
- package/es/rrweb/packages/rrweb/src/record/observer.js +584 -659
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js +44 -73
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js +166 -87
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js +21 -26
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/serialize-args.js +119 -112
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js +53 -72
- package/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js +38 -40
- package/es/rrweb/packages/rrweb/src/record/stylesheet-manager.js +31 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/2d.js +27 -23
- package/es/rrweb/packages/rrweb/src/replay/canvas/deserialize-args.js +67 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/index.js +37 -29
- package/es/rrweb/packages/rrweb/src/replay/canvas/webgl.js +58 -120
- package/es/rrweb/packages/rrweb/src/replay/index.js +1545 -1854
- package/es/rrweb/packages/rrweb/src/replay/machine.js +275 -315
- package/es/rrweb/packages/rrweb/src/replay/smoothscroll.js +216 -218
- package/es/rrweb/packages/rrweb/src/replay/styles/inject-style.js +7 -7
- package/es/rrweb/packages/rrweb/src/replay/timer.js +87 -91
- package/es/rrweb/packages/rrweb/src/types.js +72 -72
- package/es/rrweb/packages/rrweb/src/utils.js +312 -506
- package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +195 -71
- package/lib/plugins/console-record.js +469 -627
- package/lib/plugins/console-replay.js +198 -268
- package/lib/plugins/sequential-id-record.js +19 -20
- package/lib/plugins/sequential-id-replay.js +25 -25
- package/lib/record/rrweb-record-pack.js +184 -139
- package/lib/record/rrweb-record.js +2473 -2425
- package/lib/replay/rrweb-replay-unpack.js +3797 -3343
- package/lib/replay/rrweb-replay.js +3742 -3288
- package/lib/rrweb-all.js +6725 -6247
- package/lib/rrweb.js +6157 -5632
- package/package.json +14 -13
- package/typings/packer/base.d.ts +1 -1
- package/typings/plugins/console/record/index.d.ts +1 -1
- package/typings/plugins/console/record/stringify.d.ts +1 -1
- package/typings/plugins/sequential-id/record/index.d.ts +1 -1
- package/typings/plugins/sequential-id/replay/index.d.ts +1 -1
- package/typings/record/iframe-manager.d.ts +3 -3
- package/typings/record/index.d.ts +1 -1
- package/typings/record/mutation.d.ts +2 -1
- package/typings/record/observers/canvas/2d.d.ts +2 -1
- package/typings/record/observers/canvas/canvas-manager.d.ts +5 -2
- package/typings/record/observers/canvas/canvas.d.ts +1 -1
- package/typings/record/observers/canvas/serialize-args.d.ts +5 -5
- package/typings/record/observers/canvas/webgl.d.ts +2 -1
- package/typings/record/shadow-dom-manager.d.ts +2 -1
- package/typings/record/stylesheet-manager.d.ts +12 -0
- package/typings/record/workers/image-bitmap-data-url-worker.d.ts +5 -0
- package/typings/replay/canvas/2d.d.ts +3 -3
- package/typings/replay/canvas/deserialize-args.d.ts +7 -0
- package/typings/replay/canvas/index.d.ts +4 -3
- package/typings/replay/canvas/webgl.d.ts +3 -5
- package/typings/replay/index.d.ts +7 -10
- package/typings/types.d.ts +45 -17
- package/typings/utils.d.ts +17 -44
- package/dist/replay/rrweb-replay-unpack.min.css +0 -2
- package/dist/replay/rrweb-replay-unpack.min.css.map +0 -1
- package/dist/replay/rrweb-replay.min.css +0 -2
- package/dist/replay/rrweb-replay.min.css.map +0 -1
- package/dist/rrweb-all.min.css +0 -2
- package/dist/rrweb-all.min.css.map +0 -1
- package/dist/rrweb.min.css +0 -2
- package/dist/rrweb.min.css.map +0 -1
- package/es/rrweb/packages/rrweb/ext/tslib/tslib.es6.js +0 -78
- package/es/rrweb/packages/rrweb/src/replay/virtual-styles.js +0 -121
- package/typings/replay/virtual-styles.d.ts +0 -43
|
@@ -16,6 +16,60 @@ function isShadowRoot(n) {
|
|
|
16
16
|
var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;
|
|
17
17
|
return Boolean(host && host.shadowRoot && host.shadowRoot === n);
|
|
18
18
|
}
|
|
19
|
+
var Mirror = (function () {
|
|
20
|
+
function Mirror() {
|
|
21
|
+
this.idNodeMap = new Map();
|
|
22
|
+
this.nodeMetaMap = new WeakMap();
|
|
23
|
+
}
|
|
24
|
+
Mirror.prototype.getId = function (n) {
|
|
25
|
+
var _a;
|
|
26
|
+
if (!n)
|
|
27
|
+
return -1;
|
|
28
|
+
var id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id;
|
|
29
|
+
return id !== null && id !== void 0 ? id : -1;
|
|
30
|
+
};
|
|
31
|
+
Mirror.prototype.getNode = function (id) {
|
|
32
|
+
return this.idNodeMap.get(id) || null;
|
|
33
|
+
};
|
|
34
|
+
Mirror.prototype.getIds = function () {
|
|
35
|
+
return Array.from(this.idNodeMap.keys());
|
|
36
|
+
};
|
|
37
|
+
Mirror.prototype.getMeta = function (n) {
|
|
38
|
+
return this.nodeMetaMap.get(n) || null;
|
|
39
|
+
};
|
|
40
|
+
Mirror.prototype.removeNodeFromMap = function (n) {
|
|
41
|
+
var _this = this;
|
|
42
|
+
var id = this.getId(n);
|
|
43
|
+
this.idNodeMap["delete"](id);
|
|
44
|
+
if (n.childNodes) {
|
|
45
|
+
n.childNodes.forEach(function (childNode) {
|
|
46
|
+
return _this.removeNodeFromMap(childNode);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
Mirror.prototype.has = function (id) {
|
|
51
|
+
return this.idNodeMap.has(id);
|
|
52
|
+
};
|
|
53
|
+
Mirror.prototype.hasNode = function (node) {
|
|
54
|
+
return this.nodeMetaMap.has(node);
|
|
55
|
+
};
|
|
56
|
+
Mirror.prototype.add = function (n, meta) {
|
|
57
|
+
var id = meta.id;
|
|
58
|
+
this.idNodeMap.set(id, n);
|
|
59
|
+
this.nodeMetaMap.set(n, meta);
|
|
60
|
+
};
|
|
61
|
+
Mirror.prototype.replace = function (id, n) {
|
|
62
|
+
this.idNodeMap.set(id, n);
|
|
63
|
+
};
|
|
64
|
+
Mirror.prototype.reset = function () {
|
|
65
|
+
this.idNodeMap = new Map();
|
|
66
|
+
this.nodeMetaMap = new WeakMap();
|
|
67
|
+
};
|
|
68
|
+
return Mirror;
|
|
69
|
+
}());
|
|
70
|
+
function createMirror() {
|
|
71
|
+
return new Mirror();
|
|
72
|
+
}
|
|
19
73
|
function maskInputValue(_a) {
|
|
20
74
|
var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;
|
|
21
75
|
var text = value || '';
|
|
@@ -338,12 +392,40 @@ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
|
|
|
338
392
|
}
|
|
339
393
|
iframeEl.addEventListener('load', listener);
|
|
340
394
|
}
|
|
395
|
+
function isStylesheetLoaded(link) {
|
|
396
|
+
if (!link.getAttribute('href'))
|
|
397
|
+
return true;
|
|
398
|
+
return link.sheet !== null;
|
|
399
|
+
}
|
|
400
|
+
function onceStylesheetLoaded(link, listener, iframeLoadTimeout) {
|
|
401
|
+
var fired = false;
|
|
402
|
+
var styleSheetLoaded;
|
|
403
|
+
try {
|
|
404
|
+
styleSheetLoaded = link.sheet;
|
|
405
|
+
}
|
|
406
|
+
catch (error) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
if (styleSheetLoaded)
|
|
410
|
+
return;
|
|
411
|
+
var timer = setTimeout(function () {
|
|
412
|
+
if (!fired) {
|
|
413
|
+
listener();
|
|
414
|
+
fired = true;
|
|
415
|
+
}
|
|
416
|
+
}, iframeLoadTimeout);
|
|
417
|
+
link.addEventListener('load', function () {
|
|
418
|
+
clearTimeout(timer);
|
|
419
|
+
fired = true;
|
|
420
|
+
listener();
|
|
421
|
+
});
|
|
422
|
+
}
|
|
341
423
|
function serializeNode(n, options) {
|
|
342
424
|
var _a;
|
|
343
|
-
var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn, enableStrictPrivacy = options.enableStrictPrivacy;
|
|
425
|
+
var doc = options.doc, mirror = options.mirror, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn, enableStrictPrivacy = options.enableStrictPrivacy;
|
|
344
426
|
var rootId;
|
|
345
|
-
if (doc
|
|
346
|
-
var docId = doc
|
|
427
|
+
if (mirror.getMeta(doc)) {
|
|
428
|
+
var docId = mirror.getId(doc);
|
|
347
429
|
rootId = docId === 1 ? undefined : docId;
|
|
348
430
|
}
|
|
349
431
|
switch (n.nodeType) {
|
|
@@ -375,9 +457,10 @@ function serializeNode(n, options) {
|
|
|
375
457
|
var needBlock = _isBlockedElement(n, blockClass, blockSelector);
|
|
376
458
|
var tagName = getValidTagName(n);
|
|
377
459
|
var attributes_1 = {};
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
460
|
+
var len = n.attributes.length;
|
|
461
|
+
for (var i = 0; i < len; i++) {
|
|
462
|
+
var attr = n.attributes[i];
|
|
463
|
+
attributes_1[attr.name] = transformAttribute(doc, tagName, attr.name, attr.value);
|
|
381
464
|
}
|
|
382
465
|
if (tagName === 'link' && inlineStylesheet) {
|
|
383
466
|
var stylesheet = Array.from(doc.styleSheets).find(function (s) {
|
|
@@ -469,7 +552,7 @@ function serializeNode(n, options) {
|
|
|
469
552
|
}
|
|
470
553
|
oldValue_1
|
|
471
554
|
? (attributes_1.crossOrigin = oldValue_1)
|
|
472
|
-
:
|
|
555
|
+
: image_1.removeAttribute('crossorigin');
|
|
473
556
|
};
|
|
474
557
|
if (image_1.complete && image_1.naturalWidth !== 0)
|
|
475
558
|
recordInlineImage();
|
|
@@ -489,7 +572,7 @@ function serializeNode(n, options) {
|
|
|
489
572
|
attributes_1.rr_scrollTop = n.scrollTop;
|
|
490
573
|
}
|
|
491
574
|
if (needBlock || (tagName === 'img' && enableStrictPrivacy)) {
|
|
492
|
-
var
|
|
575
|
+
var _d = n.getBoundingClientRect(), width = _d.width, height = _d.height;
|
|
493
576
|
attributes_1 = {
|
|
494
577
|
"class": attributes_1["class"],
|
|
495
578
|
rr_width: width + "px",
|
|
@@ -664,10 +747,11 @@ function slimDOMExcluded(sn, slimDOMOptions) {
|
|
|
664
747
|
return false;
|
|
665
748
|
}
|
|
666
749
|
function serializeNodeWithId(n, options) {
|
|
667
|
-
var doc = options.doc,
|
|
668
|
-
var
|
|
750
|
+
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;
|
|
751
|
+
var _k = options.preserveWhiteSpace, preserveWhiteSpace = _k === void 0 ? true : _k;
|
|
669
752
|
var _serializedNode = serializeNode(n, {
|
|
670
753
|
doc: doc,
|
|
754
|
+
mirror: mirror,
|
|
671
755
|
blockClass: blockClass,
|
|
672
756
|
blockSelector: blockSelector,
|
|
673
757
|
maskTextClass: maskTextClass,
|
|
@@ -687,8 +771,8 @@ function serializeNodeWithId(n, options) {
|
|
|
687
771
|
return null;
|
|
688
772
|
}
|
|
689
773
|
var id;
|
|
690
|
-
if (
|
|
691
|
-
id = n
|
|
774
|
+
if (mirror.hasNode(n)) {
|
|
775
|
+
id = mirror.getId(n);
|
|
692
776
|
}
|
|
693
777
|
else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||
|
|
694
778
|
(!preserveWhiteSpace &&
|
|
@@ -700,12 +784,11 @@ function serializeNodeWithId(n, options) {
|
|
|
700
784
|
else {
|
|
701
785
|
id = genId();
|
|
702
786
|
}
|
|
703
|
-
var serializedNode = Object.assign(_serializedNode, { id: id });
|
|
704
|
-
n.__sn = serializedNode;
|
|
705
787
|
if (id === IGNORED_NODE) {
|
|
706
788
|
return null;
|
|
707
789
|
}
|
|
708
|
-
|
|
790
|
+
var serializedNode = Object.assign(_serializedNode, { id: id });
|
|
791
|
+
mirror.add(n, serializedNode);
|
|
709
792
|
if (onSerialize) {
|
|
710
793
|
onSerialize(n);
|
|
711
794
|
}
|
|
@@ -715,7 +798,13 @@ function serializeNodeWithId(n, options) {
|
|
|
715
798
|
if (serializedNode.needBlock && serializedNode.tagName === 'img') {
|
|
716
799
|
var clone = n.cloneNode();
|
|
717
800
|
clone.src = '';
|
|
718
|
-
|
|
801
|
+
mirror.add(clone, serializedNode);
|
|
802
|
+
}
|
|
803
|
+
if (serializedNode.tagName === 'link') {
|
|
804
|
+
var clone = n.cloneNode();
|
|
805
|
+
clone.href = '';
|
|
806
|
+
clone.innerText = serializedNode.attributes._cssText;
|
|
807
|
+
mirror.add(clone, serializedNode);
|
|
719
808
|
}
|
|
720
809
|
delete serializedNode.needBlock;
|
|
721
810
|
if (n.shadowRoot)
|
|
@@ -725,13 +814,13 @@ function serializeNodeWithId(n, options) {
|
|
|
725
814
|
serializedNode.type === NodeType.Element) &&
|
|
726
815
|
recordChild) {
|
|
727
816
|
if (slimDOMOptions.headWhitespace &&
|
|
728
|
-
|
|
729
|
-
|
|
817
|
+
serializedNode.type === NodeType.Element &&
|
|
818
|
+
serializedNode.tagName === 'head') {
|
|
730
819
|
preserveWhiteSpace = false;
|
|
731
820
|
}
|
|
732
821
|
var bypassOptions = {
|
|
733
822
|
doc: doc,
|
|
734
|
-
|
|
823
|
+
mirror: mirror,
|
|
735
824
|
blockClass: blockClass,
|
|
736
825
|
blockSelector: blockSelector,
|
|
737
826
|
maskTextClass: maskTextClass,
|
|
@@ -749,19 +838,21 @@ function serializeNodeWithId(n, options) {
|
|
|
749
838
|
onSerialize: onSerialize,
|
|
750
839
|
onIframeLoad: onIframeLoad,
|
|
751
840
|
iframeLoadTimeout: iframeLoadTimeout,
|
|
841
|
+
onStylesheetLoad: onStylesheetLoad,
|
|
842
|
+
stylesheetLoadTimeout: stylesheetLoadTimeout,
|
|
752
843
|
keepIframeSrcFn: keepIframeSrcFn,
|
|
753
844
|
enableStrictPrivacy: enableStrictPrivacy
|
|
754
845
|
};
|
|
755
|
-
for (var _i = 0,
|
|
756
|
-
var childN =
|
|
846
|
+
for (var _i = 0, _l = Array.from(n.childNodes); _i < _l.length; _i++) {
|
|
847
|
+
var childN = _l[_i];
|
|
757
848
|
var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
758
849
|
if (serializedChildNode) {
|
|
759
850
|
serializedNode.childNodes.push(serializedChildNode);
|
|
760
851
|
}
|
|
761
852
|
}
|
|
762
853
|
if (isElement(n) && n.shadowRoot) {
|
|
763
|
-
for (var
|
|
764
|
-
var childN = _m
|
|
854
|
+
for (var _m = 0, _o = Array.from(n.shadowRoot.childNodes); _m < _o.length; _m++) {
|
|
855
|
+
var childN = _o[_m];
|
|
765
856
|
var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
766
857
|
if (serializedChildNode) {
|
|
767
858
|
serializedChildNode.isShadow = true;
|
|
@@ -780,7 +871,7 @@ function serializeNodeWithId(n, options) {
|
|
|
780
871
|
if (iframeDoc && onIframeLoad) {
|
|
781
872
|
var serializedIframeNode = serializeNodeWithId(iframeDoc, {
|
|
782
873
|
doc: iframeDoc,
|
|
783
|
-
|
|
874
|
+
mirror: mirror,
|
|
784
875
|
blockClass: blockClass,
|
|
785
876
|
blockSelector: blockSelector,
|
|
786
877
|
maskTextClass: maskTextClass,
|
|
@@ -807,11 +898,47 @@ function serializeNodeWithId(n, options) {
|
|
|
807
898
|
}
|
|
808
899
|
}, iframeLoadTimeout);
|
|
809
900
|
}
|
|
901
|
+
if (serializedNode.type === NodeType.Element &&
|
|
902
|
+
serializedNode.tagName === 'link' &&
|
|
903
|
+
serializedNode.attributes.rel === 'stylesheet') {
|
|
904
|
+
onceStylesheetLoaded(n, function () {
|
|
905
|
+
if (onStylesheetLoad) {
|
|
906
|
+
var serializedLinkNode = serializeNodeWithId(n, {
|
|
907
|
+
doc: doc,
|
|
908
|
+
mirror: mirror,
|
|
909
|
+
blockClass: blockClass,
|
|
910
|
+
blockSelector: blockSelector,
|
|
911
|
+
maskTextClass: maskTextClass,
|
|
912
|
+
maskTextSelector: maskTextSelector,
|
|
913
|
+
skipChild: false,
|
|
914
|
+
inlineStylesheet: inlineStylesheet,
|
|
915
|
+
maskInputOptions: maskInputOptions,
|
|
916
|
+
maskTextFn: maskTextFn,
|
|
917
|
+
maskInputFn: maskInputFn,
|
|
918
|
+
slimDOMOptions: slimDOMOptions,
|
|
919
|
+
dataURLOptions: dataURLOptions,
|
|
920
|
+
inlineImages: inlineImages,
|
|
921
|
+
recordCanvas: recordCanvas,
|
|
922
|
+
preserveWhiteSpace: preserveWhiteSpace,
|
|
923
|
+
onSerialize: onSerialize,
|
|
924
|
+
onIframeLoad: onIframeLoad,
|
|
925
|
+
onStylesheetLoad: onStylesheetLoad,
|
|
926
|
+
iframeLoadTimeout: iframeLoadTimeout,
|
|
927
|
+
keepIframeSrcFn: keepIframeSrcFn,
|
|
928
|
+
enableStrictPrivacy: enableStrictPrivacy
|
|
929
|
+
});
|
|
930
|
+
if (serializedLinkNode) {
|
|
931
|
+
onStylesheetLoad(n, serializedLinkNode);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
}, stylesheetLoadTimeout);
|
|
935
|
+
if (isStylesheetLoaded(n) === false)
|
|
936
|
+
return null;
|
|
937
|
+
}
|
|
810
938
|
return serializedNode;
|
|
811
939
|
}
|
|
812
940
|
function snapshot(n, options) {
|
|
813
|
-
var _a = options || {}, _b = _a.blockClass, blockClass =
|
|
814
|
-
var idNodeMap = {};
|
|
941
|
+
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;
|
|
815
942
|
var maskInputOptions = maskAllInputs === true
|
|
816
943
|
? {
|
|
817
944
|
color: true,
|
|
@@ -853,32 +980,30 @@ function snapshot(n, options) {
|
|
|
853
980
|
: slimDOM === false
|
|
854
981
|
? {}
|
|
855
982
|
: slimDOM;
|
|
856
|
-
return
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
idNodeMap,
|
|
881
|
-
];
|
|
983
|
+
return serializeNodeWithId(n, {
|
|
984
|
+
doc: n,
|
|
985
|
+
mirror: mirror,
|
|
986
|
+
blockClass: blockClass,
|
|
987
|
+
blockSelector: blockSelector,
|
|
988
|
+
maskTextClass: maskTextClass,
|
|
989
|
+
maskTextSelector: maskTextSelector,
|
|
990
|
+
skipChild: false,
|
|
991
|
+
inlineStylesheet: inlineStylesheet,
|
|
992
|
+
maskInputOptions: maskInputOptions,
|
|
993
|
+
maskTextFn: maskTextFn,
|
|
994
|
+
maskInputFn: maskInputFn,
|
|
995
|
+
slimDOMOptions: slimDOMOptions,
|
|
996
|
+
dataURLOptions: dataURLOptions,
|
|
997
|
+
inlineImages: inlineImages,
|
|
998
|
+
recordCanvas: recordCanvas,
|
|
999
|
+
preserveWhiteSpace: preserveWhiteSpace,
|
|
1000
|
+
onSerialize: onSerialize,
|
|
1001
|
+
onIframeLoad: onIframeLoad,
|
|
1002
|
+
iframeLoadTimeout: iframeLoadTimeout,
|
|
1003
|
+
onStylesheetLoad: onStylesheetLoad,
|
|
1004
|
+
stylesheetLoadTimeout: stylesheetLoadTimeout, keepIframeSrcFn: keepIframeSrcFn,
|
|
1005
|
+
enableStrictPrivacy: enableStrictPrivacy
|
|
1006
|
+
});
|
|
882
1007
|
}
|
|
883
1008
|
|
|
884
1009
|
var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
|
|
@@ -1589,13 +1714,13 @@ function buildNode(n, options) {
|
|
|
1589
1714
|
}
|
|
1590
1715
|
}
|
|
1591
1716
|
function buildNodeWithSN(n, options) {
|
|
1592
|
-
var doc = options.doc,
|
|
1717
|
+
var doc = options.doc, mirror = options.mirror, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache;
|
|
1593
1718
|
var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });
|
|
1594
1719
|
if (!node) {
|
|
1595
1720
|
return null;
|
|
1596
1721
|
}
|
|
1597
1722
|
if (n.rootId) {
|
|
1598
|
-
console.assert(
|
|
1723
|
+
console.assert(mirror.getNode(n.rootId) === doc, 'Target document should have the same root id.');
|
|
1599
1724
|
}
|
|
1600
1725
|
if (n.type === NodeType.Document) {
|
|
1601
1726
|
doc.close();
|
|
@@ -1614,15 +1739,14 @@ function buildNodeWithSN(n, options) {
|
|
|
1614
1739
|
}
|
|
1615
1740
|
node = doc;
|
|
1616
1741
|
}
|
|
1617
|
-
node
|
|
1618
|
-
map[n.id] = node;
|
|
1742
|
+
mirror.add(node, n);
|
|
1619
1743
|
if ((n.type === NodeType.Document || n.type === NodeType.Element) &&
|
|
1620
1744
|
!skipChild) {
|
|
1621
1745
|
for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {
|
|
1622
1746
|
var childN = _c[_i];
|
|
1623
1747
|
var childNode = buildNodeWithSN(childN, {
|
|
1624
1748
|
doc: doc,
|
|
1625
|
-
|
|
1749
|
+
mirror: mirror,
|
|
1626
1750
|
skipChild: false,
|
|
1627
1751
|
hackCss: hackCss,
|
|
1628
1752
|
afterAppend: afterAppend,
|
|
@@ -1645,19 +1769,20 @@ function buildNodeWithSN(n, options) {
|
|
|
1645
1769
|
}
|
|
1646
1770
|
return node;
|
|
1647
1771
|
}
|
|
1648
|
-
function visit(
|
|
1772
|
+
function visit(mirror, onVisit) {
|
|
1649
1773
|
function walk(node) {
|
|
1650
1774
|
onVisit(node);
|
|
1651
1775
|
}
|
|
1652
|
-
for (var
|
|
1653
|
-
|
|
1654
|
-
|
|
1776
|
+
for (var _i = 0, _a = mirror.getIds(); _i < _a.length; _i++) {
|
|
1777
|
+
var id = _a[_i];
|
|
1778
|
+
if (mirror.has(id)) {
|
|
1779
|
+
walk(mirror.getNode(id));
|
|
1655
1780
|
}
|
|
1656
1781
|
}
|
|
1657
1782
|
}
|
|
1658
|
-
function handleScroll(node) {
|
|
1659
|
-
var n = node
|
|
1660
|
-
if (n.type !== NodeType.Element) {
|
|
1783
|
+
function handleScroll(node, mirror) {
|
|
1784
|
+
var n = mirror.getMeta(node);
|
|
1785
|
+
if ((n === null || n === void 0 ? void 0 : n.type) !== NodeType.Element) {
|
|
1661
1786
|
return;
|
|
1662
1787
|
}
|
|
1663
1788
|
var el = node;
|
|
@@ -1675,23 +1800,22 @@ function handleScroll(node) {
|
|
|
1675
1800
|
}
|
|
1676
1801
|
}
|
|
1677
1802
|
function rebuild(n, options) {
|
|
1678
|
-
var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache;
|
|
1679
|
-
var idNodeMap = {};
|
|
1803
|
+
var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache, _b = options.mirror, mirror = _b === void 0 ? new Mirror() : _b;
|
|
1680
1804
|
var node = buildNodeWithSN(n, {
|
|
1681
1805
|
doc: doc,
|
|
1682
|
-
|
|
1806
|
+
mirror: mirror,
|
|
1683
1807
|
skipChild: false,
|
|
1684
1808
|
hackCss: hackCss,
|
|
1685
1809
|
afterAppend: afterAppend,
|
|
1686
1810
|
cache: cache
|
|
1687
1811
|
});
|
|
1688
|
-
visit(
|
|
1812
|
+
visit(mirror, function (visitedNode) {
|
|
1689
1813
|
if (onVisit) {
|
|
1690
1814
|
onVisit(visitedNode);
|
|
1691
1815
|
}
|
|
1692
|
-
handleScroll(visitedNode);
|
|
1816
|
+
handleScroll(visitedNode, mirror);
|
|
1693
1817
|
});
|
|
1694
|
-
return
|
|
1818
|
+
return node;
|
|
1695
1819
|
}
|
|
1696
1820
|
|
|
1697
|
-
export { IGNORED_NODE, NodeType, addHoverClass, buildNodeWithSN, createCache, is2DCanvasBlank, isElement, isShadowRoot, maskInputValue, needMaskingText, obfuscateText, rebuild, serializeNodeWithId, snapshot, transformAttribute };
|
|
1821
|
+
export { IGNORED_NODE, Mirror, NodeType, addHoverClass, buildNodeWithSN, createCache, createMirror, is2DCanvasBlank, isElement, isShadowRoot, maskInputValue, needMaskingText, obfuscateText, rebuild, serializeNodeWithId, snapshot, transformAttribute };
|