@highlight-run/rrweb 1.2.0 → 2.0.1
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 +655 -0
- package/dist/plugins/console-record.min.js +1 -1
- package/dist/plugins/console-record.min.js.map +1 -1
- package/dist/plugins/console-replay.js +293 -0
- package/dist/plugins/console-replay.min.js +16 -0
- package/dist/plugins/console-replay.min.js.map +1 -0
- package/dist/plugins/sequential-id-record.js +33 -0
- package/dist/plugins/sequential-id-record.min.js +2 -0
- package/dist/plugins/sequential-id-record.min.js.map +1 -0
- package/dist/plugins/sequential-id-replay.js +37 -0
- package/dist/plugins/sequential-id-replay.min.js +2 -0
- package/dist/plugins/sequential-id-replay.min.js.map +1 -0
- package/dist/record/rrweb-record-pack.js +747 -0
- package/dist/record/rrweb-record-pack.min.js +16 -0
- package/dist/record/rrweb-record-pack.min.js.map +1 -0
- package/dist/record/rrweb-record.js +3318 -0
- package/dist/record/rrweb-record.min.js +16 -0
- package/dist/record/rrweb-record.min.js.map +1 -0
- package/dist/replay/rrweb-replay-unpack.js +4626 -0
- package/dist/replay/rrweb-replay-unpack.min.css +2 -0
- package/dist/replay/rrweb-replay-unpack.min.css.map +1 -0
- package/dist/replay/rrweb-replay-unpack.min.js +30 -0
- package/dist/replay/rrweb-replay-unpack.min.js.map +1 -0
- package/dist/replay/rrweb-replay.js +4216 -0
- package/dist/replay/rrweb-replay.min.css +2 -0
- package/dist/replay/rrweb-replay.min.css.map +1 -0
- package/dist/replay/rrweb-replay.min.js +30 -0
- package/dist/replay/rrweb-replay.min.js.map +1 -0
- package/dist/rrweb-all.js +8708 -0
- package/dist/rrweb-all.min.css +2 -0
- package/dist/rrweb-all.min.css.map +1 -0
- package/dist/rrweb-all.min.js +30 -0
- package/dist/rrweb-all.min.js.map +1 -0
- package/dist/rrweb.js +7294 -0
- package/dist/rrweb.min.css +2 -0
- package/dist/rrweb.min.css.map +1 -0
- package/dist/rrweb.min.js +2 -2
- package/dist/rrweb.min.js.map +1 -1
- package/es/rrweb/ext/@xstate/fsm/es/index.js +17 -0
- package/es/rrweb/ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js +49 -0
- package/es/rrweb/ext/fflate/esm/browser.js +777 -0
- package/es/rrweb/ext/mitt/dist/mitt.es.js +63 -0
- package/es/rrweb/packages/rrweb/ext/tslib/tslib.es6.js +78 -0
- package/es/rrweb/packages/rrweb/src/entries/all.js +13 -0
- package/es/rrweb/packages/rrweb/src/index.js +12 -0
- package/es/rrweb/packages/rrweb/src/packer/base.js +3 -0
- package/es/rrweb/packages/rrweb/src/packer/pack.js +10 -0
- package/es/rrweb/packages/rrweb/src/packer/unpack.js +29 -0
- package/es/rrweb/packages/rrweb/src/plugins/console/record/error-stack-parser.js +179 -0
- package/es/rrweb/packages/rrweb/src/plugins/console/record/index.js +134 -0
- package/es/rrweb/packages/rrweb/src/plugins/console/record/stringify.js +141 -0
- package/es/rrweb/packages/rrweb/src/plugins/console/replay/index.js +111 -0
- package/es/rrweb/packages/rrweb/src/plugins/sequential-id/record/index.js +23 -0
- package/es/rrweb/packages/rrweb/src/plugins/sequential-id/replay/index.js +28 -0
- package/es/rrweb/packages/rrweb/src/record/iframe-manager.js +32 -0
- package/es/rrweb/packages/rrweb/src/record/index.js +381 -0
- package/es/rrweb/packages/rrweb/src/record/mutation.js +532 -0
- package/es/rrweb/packages/rrweb/src/record/observer.js +665 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js +78 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js +93 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js +30 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/serialize-args.js +116 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js +78 -0
- package/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js +45 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/2d.js +25 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/index.js +35 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/webgl.js +124 -0
- package/es/rrweb/packages/rrweb/src/replay/index.js +1864 -0
- package/es/rrweb/packages/rrweb/src/replay/machine.js +321 -0
- package/es/rrweb/packages/rrweb/src/replay/smoothscroll.js +221 -0
- package/es/rrweb/packages/rrweb/src/replay/styles/inject-style.js +8 -0
- package/es/rrweb/packages/rrweb/src/replay/timer.js +96 -0
- package/es/rrweb/packages/rrweb/src/replay/virtual-styles.js +121 -0
- package/es/rrweb/packages/rrweb/src/types.js +75 -0
- package/es/rrweb/packages/rrweb/src/utils.js +509 -0
- package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +1697 -0
- package/lib/plugins/console-record.js +650 -0
- package/lib/plugins/console-replay.js +288 -0
- package/lib/plugins/sequential-id-record.js +28 -0
- package/lib/plugins/sequential-id-replay.js +32 -0
- package/lib/record/rrweb-record-pack.js +742 -0
- package/lib/record/rrweb-record.js +3315 -0
- package/lib/replay/rrweb-replay-unpack.js +4621 -0
- package/lib/replay/rrweb-replay.js +4211 -0
- package/lib/rrweb-all.js +8703 -0
- package/lib/rrweb.js +7289 -0
- package/package.json +41 -43
- package/typings/entries/all.d.ts +6 -0
- package/{dist → typings}/entries/record-pack.d.ts +0 -0
- package/{dist → typings}/entries/replay-unpack.d.ts +0 -0
- package/{dist → typings}/index.d.ts +1 -2
- package/{dist → typings}/packer/base.d.ts +0 -0
- package/{dist → typings}/packer/index.d.ts +0 -0
- package/{dist → typings}/packer/pack.d.ts +0 -0
- package/{dist → typings}/packer/unpack.d.ts +0 -0
- package/{dist → typings}/plugins/console/record/error-stack-parser.d.ts +0 -0
- package/{dist → typings}/plugins/console/record/index.d.ts +3 -2
- package/{dist → typings}/plugins/console/record/stringify.d.ts +0 -0
- package/{dist → typings}/plugins/console/replay/index.d.ts +2 -2
- package/{dist → typings}/plugins/sequential-id/record/index.d.ts +0 -0
- package/{dist → typings}/plugins/sequential-id/replay/index.d.ts +0 -0
- package/{dist → typings}/record/iframe-manager.d.ts +1 -1
- package/{dist → typings}/record/index.d.ts +0 -0
- package/{dist → typings}/record/mutation.d.ts +5 -8
- package/typings/record/observer.d.ts +7 -0
- package/{dist → typings}/record/observers/canvas/2d.d.ts +0 -0
- package/{dist → typings}/record/observers/canvas/canvas-manager.d.ts +0 -0
- package/{dist → typings}/record/observers/canvas/canvas.d.ts +0 -0
- package/{dist → typings}/record/observers/canvas/serialize-args.d.ts +1 -1
- package/{dist → typings}/record/observers/canvas/webgl.d.ts +0 -0
- package/typings/record/observers/canvas/webgl2.d.ts +2 -0
- package/typings/record/shadow-dom-manager.d.ts +21 -0
- package/{dist → typings}/replay/canvas/2d.d.ts +0 -0
- package/{dist → typings}/replay/canvas/index.d.ts +0 -0
- package/{dist → typings}/replay/canvas/webgl.d.ts +0 -0
- package/{dist → typings}/replay/index.d.ts +1 -0
- package/{dist → typings}/replay/machine.d.ts +0 -0
- package/{dist → typings}/replay/smoothscroll.d.ts +0 -0
- package/{dist → typings}/replay/styles/inject-style.d.ts +0 -0
- package/{dist → typings}/replay/timer.d.ts +0 -0
- package/{dist → typings}/replay/virtual-styles.d.ts +1 -1
- package/{dist → typings}/rrdom/index.d.ts +0 -0
- package/{dist → typings}/rrdom/tree-node.d.ts +0 -0
- package/{dist → typings}/types.d.ts +7 -8
- package/{dist → typings}/utils.d.ts +3 -4
- package/CHANGELOG.md +0 -26
- package/README.md +0 -124
- package/README.zh_CN.md +0 -122
- package/dist/entries/all.d.ts +0 -4
- package/dist/index.css +0 -82
- package/dist/index.css.map +0 -1
- package/dist/index.js +0 -3
- package/dist/index.js.LICENSE.txt +0 -14
- package/dist/index.js.map +0 -1
- package/dist/plugins/entries/all.d.ts +0 -4
- package/dist/plugins/entries/record-pack.d.ts +0 -2
- package/dist/plugins/entries/replay-unpack.d.ts +0 -2
- package/dist/plugins/index.d.ts +0 -9
- package/dist/plugins/packer/base.d.ts +0 -7
- package/dist/plugins/packer/index.d.ts +0 -2
- package/dist/plugins/packer/pack.d.ts +0 -2
- package/dist/plugins/packer/unpack.d.ts +0 -2
- package/dist/plugins/plugins/console/record/error-stack-parser.d.ts +0 -37
- package/dist/plugins/plugins/console/record/index.d.ts +0 -41
- package/dist/plugins/plugins/console/record/stringify.d.ts +0 -2
- package/dist/plugins/plugins/console/replay/index.d.ts +0 -9
- package/dist/plugins/plugins/sequential-id/record/index.d.ts +0 -6
- package/dist/plugins/plugins/sequential-id/replay/index.d.ts +0 -7
- package/dist/plugins/record/iframe-manager.d.ts +0 -13
- package/dist/plugins/record/index.d.ts +0 -9
- package/dist/plugins/record/mutation.d.ts +0 -45
- package/dist/plugins/record/observer.d.ts +0 -11
- package/dist/plugins/record/observers/canvas/2d.d.ts +0 -2
- package/dist/plugins/record/observers/canvas/canvas-manager.d.ts +0 -32
- package/dist/plugins/record/observers/canvas/canvas.d.ts +0 -2
- package/dist/plugins/record/observers/canvas/serialize-args.d.ts +0 -6
- package/dist/plugins/record/observers/canvas/webgl.d.ts +0 -2
- package/dist/plugins/record/shadow-dom-manager.d.ts +0 -34
- package/dist/plugins/replay/canvas/2d.d.ts +0 -9
- package/dist/plugins/replay/canvas/index.d.ts +0 -9
- package/dist/plugins/replay/canvas/webgl.d.ts +0 -11
- package/dist/plugins/replay/index.d.ts +0 -82
- package/dist/plugins/replay/machine.d.ts +0 -85
- package/dist/plugins/replay/smoothscroll.d.ts +0 -1
- package/dist/plugins/replay/styles/inject-style.d.ts +0 -2
- package/dist/plugins/replay/timer.d.ts +0 -19
- package/dist/plugins/replay/virtual-styles.d.ts +0 -43
- package/dist/plugins/rrdom/index.d.ts +0 -1
- package/dist/plugins/rrdom/tree-node.d.ts +0 -20
- package/dist/plugins/snapshot/css.d.ts +0 -92
- package/dist/plugins/snapshot/index.d.ts +0 -5
- package/dist/plugins/snapshot/rebuild.d.ts +0 -19
- package/dist/plugins/snapshot/snapshot.d.ts +0 -49
- package/dist/plugins/snapshot/types.d.ts +0 -99
- package/dist/plugins/snapshot/utils.d.ts +0 -11
- package/dist/plugins/types.d.ts +0 -509
- package/dist/plugins/utils.d.ts +0 -71
- package/dist/record/observer.d.ts +0 -11
- package/dist/record/shadow-dom-manager.d.ts +0 -34
- package/dist/snapshot/css.d.ts +0 -92
- package/dist/snapshot/index.d.ts +0 -5
- package/dist/snapshot/rebuild.d.ts +0 -19
- package/dist/snapshot/snapshot.d.ts +0 -49
- package/dist/snapshot/types.d.ts +0 -99
- package/dist/snapshot/utils.d.ts +0 -11
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
import { __values } from '../../ext/tslib/tslib.es6.js';
|
|
2
|
+
import { obfuscateText, isShadowRoot, maskInputValue, transformAttribute, needMaskingText, IGNORED_NODE, serializeNodeWithId } from '../../../rrweb-snapshot/es/rrweb-snapshot.js';
|
|
3
|
+
import { isIgnored, isBlocked, isAncestorRemoved, isIframeINode, hasShadowRoot } from '../utils.js';
|
|
4
|
+
|
|
5
|
+
function isNodeInLinkedList(n) {
|
|
6
|
+
return '__ln' in n;
|
|
7
|
+
}
|
|
8
|
+
var DoubleLinkedList = (function () {
|
|
9
|
+
function DoubleLinkedList() {
|
|
10
|
+
this.length = 0;
|
|
11
|
+
this.head = null;
|
|
12
|
+
}
|
|
13
|
+
DoubleLinkedList.prototype.get = function (position) {
|
|
14
|
+
if (position >= this.length) {
|
|
15
|
+
throw new Error('Position outside of list range');
|
|
16
|
+
}
|
|
17
|
+
var current = this.head;
|
|
18
|
+
for (var index = 0; index < position; index++) {
|
|
19
|
+
current = (current === null || current === void 0 ? void 0 : current.next) || null;
|
|
20
|
+
}
|
|
21
|
+
return current;
|
|
22
|
+
};
|
|
23
|
+
DoubleLinkedList.prototype.addNode = function (n) {
|
|
24
|
+
var node = {
|
|
25
|
+
value: n,
|
|
26
|
+
previous: null,
|
|
27
|
+
next: null,
|
|
28
|
+
};
|
|
29
|
+
n.__ln = node;
|
|
30
|
+
if (n.previousSibling && isNodeInLinkedList(n.previousSibling)) {
|
|
31
|
+
var current = n.previousSibling.__ln.next;
|
|
32
|
+
node.next = current;
|
|
33
|
+
node.previous = n.previousSibling.__ln;
|
|
34
|
+
n.previousSibling.__ln.next = node;
|
|
35
|
+
if (current) {
|
|
36
|
+
current.previous = node;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else if (n.nextSibling &&
|
|
40
|
+
isNodeInLinkedList(n.nextSibling) &&
|
|
41
|
+
n.nextSibling.__ln.previous) {
|
|
42
|
+
var current = n.nextSibling.__ln.previous;
|
|
43
|
+
node.previous = current;
|
|
44
|
+
node.next = n.nextSibling.__ln;
|
|
45
|
+
n.nextSibling.__ln.previous = node;
|
|
46
|
+
if (current) {
|
|
47
|
+
current.next = node;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
if (this.head) {
|
|
52
|
+
this.head.previous = node;
|
|
53
|
+
}
|
|
54
|
+
node.next = this.head;
|
|
55
|
+
this.head = node;
|
|
56
|
+
}
|
|
57
|
+
this.length++;
|
|
58
|
+
};
|
|
59
|
+
DoubleLinkedList.prototype.removeNode = function (n) {
|
|
60
|
+
var current = n.__ln;
|
|
61
|
+
if (!this.head) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (!current.previous) {
|
|
65
|
+
this.head = current.next;
|
|
66
|
+
if (this.head) {
|
|
67
|
+
this.head.previous = null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
current.previous.next = current.next;
|
|
72
|
+
if (current.next) {
|
|
73
|
+
current.next.previous = current.previous;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (n.__ln) {
|
|
77
|
+
delete n.__ln;
|
|
78
|
+
}
|
|
79
|
+
this.length--;
|
|
80
|
+
};
|
|
81
|
+
return DoubleLinkedList;
|
|
82
|
+
}());
|
|
83
|
+
var moveKey = function (id, parentId) { return "".concat(id, "@").concat(parentId); };
|
|
84
|
+
function isINode(n) {
|
|
85
|
+
return '__sn' in n;
|
|
86
|
+
}
|
|
87
|
+
var MutationBuffer = (function () {
|
|
88
|
+
function MutationBuffer() {
|
|
89
|
+
var _this = this;
|
|
90
|
+
this.frozen = false;
|
|
91
|
+
this.locked = false;
|
|
92
|
+
this.texts = [];
|
|
93
|
+
this.attributes = [];
|
|
94
|
+
this.removes = [];
|
|
95
|
+
this.mapRemoves = [];
|
|
96
|
+
this.movedMap = {};
|
|
97
|
+
this.addedSet = new Set();
|
|
98
|
+
this.movedSet = new Set();
|
|
99
|
+
this.droppedSet = new Set();
|
|
100
|
+
this.processMutations = function (mutations) {
|
|
101
|
+
mutations.forEach(_this.processMutation);
|
|
102
|
+
_this.emit();
|
|
103
|
+
};
|
|
104
|
+
this.emit = function () {
|
|
105
|
+
var e_1, _a, e_2, _b;
|
|
106
|
+
if (_this.frozen || _this.locked) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
var adds = [];
|
|
110
|
+
var addList = new DoubleLinkedList();
|
|
111
|
+
var getNextId = function (n) {
|
|
112
|
+
var ns = n;
|
|
113
|
+
var nextId = IGNORED_NODE;
|
|
114
|
+
while (nextId === IGNORED_NODE) {
|
|
115
|
+
ns = ns && ns.nextSibling;
|
|
116
|
+
nextId = ns && _this.mirror.getId(ns);
|
|
117
|
+
}
|
|
118
|
+
return nextId;
|
|
119
|
+
};
|
|
120
|
+
var pushAdd = function (n) {
|
|
121
|
+
var _a, _b, _c, _d, _e;
|
|
122
|
+
var shadowHost = n.getRootNode
|
|
123
|
+
? (_a = n.getRootNode()) === null || _a === void 0 ? void 0 : _a.host
|
|
124
|
+
: null;
|
|
125
|
+
var rootShadowHost = shadowHost;
|
|
126
|
+
while ((_c = (_b = rootShadowHost === null || rootShadowHost === void 0 ? void 0 : rootShadowHost.getRootNode) === null || _b === void 0 ? void 0 : _b.call(rootShadowHost)) === null || _c === void 0 ? void 0 : _c.host)
|
|
127
|
+
rootShadowHost =
|
|
128
|
+
((_e = (_d = rootShadowHost === null || rootShadowHost === void 0 ? void 0 : rootShadowHost.getRootNode) === null || _d === void 0 ? void 0 : _d.call(rootShadowHost)) === null || _e === void 0 ? void 0 : _e.host) ||
|
|
129
|
+
null;
|
|
130
|
+
var notInDoc = !_this.doc.contains(n) &&
|
|
131
|
+
(rootShadowHost === null || !_this.doc.contains(rootShadowHost));
|
|
132
|
+
if (!n.parentNode || notInDoc) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
var parentId = isShadowRoot(n.parentNode)
|
|
136
|
+
? _this.mirror.getId(shadowHost)
|
|
137
|
+
: _this.mirror.getId(n.parentNode);
|
|
138
|
+
var nextId = getNextId(n);
|
|
139
|
+
if (parentId === -1 || nextId === -1) {
|
|
140
|
+
return addList.addNode(n);
|
|
141
|
+
}
|
|
142
|
+
var sn = serializeNodeWithId(n, {
|
|
143
|
+
doc: _this.doc,
|
|
144
|
+
map: _this.mirror.map,
|
|
145
|
+
blockClass: _this.blockClass,
|
|
146
|
+
blockSelector: _this.blockSelector,
|
|
147
|
+
maskTextClass: _this.maskTextClass,
|
|
148
|
+
maskTextSelector: _this.maskTextSelector,
|
|
149
|
+
skipChild: true,
|
|
150
|
+
inlineStylesheet: _this.inlineStylesheet,
|
|
151
|
+
maskInputOptions: _this.maskInputOptions,
|
|
152
|
+
maskTextFn: _this.maskTextFn,
|
|
153
|
+
maskInputFn: _this.maskInputFn,
|
|
154
|
+
slimDOMOptions: _this.slimDOMOptions,
|
|
155
|
+
recordCanvas: _this.recordCanvas,
|
|
156
|
+
inlineImages: _this.inlineImages,
|
|
157
|
+
enableStrictPrivacy: _this.enableStrictPrivacy,
|
|
158
|
+
onSerialize: function (currentN) {
|
|
159
|
+
if (isIframeINode(currentN)) {
|
|
160
|
+
_this.iframeManager.addIframe(currentN);
|
|
161
|
+
}
|
|
162
|
+
if (hasShadowRoot(n)) {
|
|
163
|
+
_this.shadowDomManager.addShadowRoot(n.shadowRoot, document);
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
onIframeLoad: function (iframe, childSn) {
|
|
167
|
+
_this.iframeManager.attachIframe(iframe, childSn);
|
|
168
|
+
_this.shadowDomManager.observeAttachShadow(iframe);
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
if (sn) {
|
|
172
|
+
adds.push({
|
|
173
|
+
parentId: parentId,
|
|
174
|
+
nextId: nextId,
|
|
175
|
+
node: sn,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
while (_this.mapRemoves.length) {
|
|
180
|
+
_this.mirror.removeNodeFromMap(_this.mapRemoves.shift());
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
for (var _c = __values(_this.movedSet), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
184
|
+
var n = _d.value;
|
|
185
|
+
if (isParentRemoved(_this.removes, n, _this.mirror) &&
|
|
186
|
+
!_this.movedSet.has(n.parentNode)) {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
pushAdd(n);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
193
|
+
finally {
|
|
194
|
+
try {
|
|
195
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
196
|
+
}
|
|
197
|
+
finally { if (e_1) throw e_1.error; }
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
for (var _e = __values(_this.addedSet), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
201
|
+
var n = _f.value;
|
|
202
|
+
if (!isAncestorInSet(_this.droppedSet, n) &&
|
|
203
|
+
!isParentRemoved(_this.removes, n, _this.mirror)) {
|
|
204
|
+
pushAdd(n);
|
|
205
|
+
}
|
|
206
|
+
else if (isAncestorInSet(_this.movedSet, n)) {
|
|
207
|
+
pushAdd(n);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
_this.droppedSet.add(n);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
215
|
+
finally {
|
|
216
|
+
try {
|
|
217
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
218
|
+
}
|
|
219
|
+
finally { if (e_2) throw e_2.error; }
|
|
220
|
+
}
|
|
221
|
+
var candidate = null;
|
|
222
|
+
while (addList.length) {
|
|
223
|
+
var node = null;
|
|
224
|
+
if (candidate) {
|
|
225
|
+
var parentId = _this.mirror.getId(candidate.value.parentNode);
|
|
226
|
+
var nextId = getNextId(candidate.value);
|
|
227
|
+
if (parentId !== -1 && nextId !== -1) {
|
|
228
|
+
node = candidate;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (!node) {
|
|
232
|
+
for (var index = addList.length - 1; index >= 0; index--) {
|
|
233
|
+
var _node = addList.get(index);
|
|
234
|
+
if (_node) {
|
|
235
|
+
var parentId = _this.mirror.getId(_node.value.parentNode);
|
|
236
|
+
var nextId = getNextId(_node.value);
|
|
237
|
+
if (parentId !== -1 && nextId !== -1) {
|
|
238
|
+
node = _node;
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (!node) {
|
|
245
|
+
while (addList.head) {
|
|
246
|
+
addList.removeNode(addList.head.value);
|
|
247
|
+
}
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
candidate = node.previous;
|
|
251
|
+
addList.removeNode(node.value);
|
|
252
|
+
pushAdd(node.value);
|
|
253
|
+
}
|
|
254
|
+
var payload = {
|
|
255
|
+
texts: _this.texts
|
|
256
|
+
.map(function (text) {
|
|
257
|
+
var value = text.value;
|
|
258
|
+
if (_this.enableStrictPrivacy && value) {
|
|
259
|
+
value = obfuscateText(value);
|
|
260
|
+
}
|
|
261
|
+
return {
|
|
262
|
+
id: _this.mirror.getId(text.node),
|
|
263
|
+
value: value,
|
|
264
|
+
};
|
|
265
|
+
})
|
|
266
|
+
.filter(function (text) { return _this.mirror.has(text.id); }),
|
|
267
|
+
attributes: _this.attributes
|
|
268
|
+
.map(function (attribute) { return ({
|
|
269
|
+
id: _this.mirror.getId(attribute.node),
|
|
270
|
+
attributes: attribute.attributes,
|
|
271
|
+
}); })
|
|
272
|
+
.filter(function (attribute) { return _this.mirror.has(attribute.id); }),
|
|
273
|
+
removes: _this.removes,
|
|
274
|
+
adds: adds,
|
|
275
|
+
};
|
|
276
|
+
if (!payload.texts.length &&
|
|
277
|
+
!payload.attributes.length &&
|
|
278
|
+
!payload.removes.length &&
|
|
279
|
+
!payload.adds.length) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
_this.texts = [];
|
|
283
|
+
_this.attributes = [];
|
|
284
|
+
_this.removes = [];
|
|
285
|
+
_this.addedSet = new Set();
|
|
286
|
+
_this.movedSet = new Set();
|
|
287
|
+
_this.droppedSet = new Set();
|
|
288
|
+
_this.movedMap = {};
|
|
289
|
+
_this.mutationCb(payload);
|
|
290
|
+
};
|
|
291
|
+
this.processMutation = function (m) {
|
|
292
|
+
var e_3, _a, e_4, _b;
|
|
293
|
+
if (isIgnored(m.target)) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
switch (m.type) {
|
|
297
|
+
case 'characterData': {
|
|
298
|
+
var value = m.target.textContent;
|
|
299
|
+
if (!isBlocked(m.target, _this.blockClass) && value !== m.oldValue) {
|
|
300
|
+
_this.texts.push({
|
|
301
|
+
value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector) && value
|
|
302
|
+
? _this.maskTextFn
|
|
303
|
+
? _this.maskTextFn(value)
|
|
304
|
+
: value.replace(/[\S]/g, '*')
|
|
305
|
+
: value,
|
|
306
|
+
node: m.target,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
case 'attributes': {
|
|
312
|
+
var target = m.target;
|
|
313
|
+
var value = m.target.getAttribute(m.attributeName);
|
|
314
|
+
if (m.attributeName === 'value') {
|
|
315
|
+
value = maskInputValue({
|
|
316
|
+
maskInputOptions: _this.maskInputOptions,
|
|
317
|
+
tagName: m.target.tagName,
|
|
318
|
+
type: m.target.getAttribute('type'),
|
|
319
|
+
value: value,
|
|
320
|
+
maskInputFn: _this.maskInputFn,
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
if (isBlocked(m.target, _this.blockClass) || value === m.oldValue) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
var item = _this.attributes.find(function (a) { return a.node === m.target; });
|
|
327
|
+
if (!item) {
|
|
328
|
+
item = {
|
|
329
|
+
node: m.target,
|
|
330
|
+
attributes: {},
|
|
331
|
+
};
|
|
332
|
+
_this.attributes.push(item);
|
|
333
|
+
}
|
|
334
|
+
if (m.attributeName === 'style') {
|
|
335
|
+
var old = _this.doc.createElement('span');
|
|
336
|
+
if (m.oldValue) {
|
|
337
|
+
old.setAttribute('style', m.oldValue);
|
|
338
|
+
}
|
|
339
|
+
if (item.attributes.style === undefined ||
|
|
340
|
+
item.attributes.style === null) {
|
|
341
|
+
item.attributes.style = {};
|
|
342
|
+
}
|
|
343
|
+
var styleObj = item.attributes.style;
|
|
344
|
+
try {
|
|
345
|
+
for (var _c = __values(Array.from(target.style)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
346
|
+
var pname = _d.value;
|
|
347
|
+
var newValue = target.style.getPropertyValue(pname);
|
|
348
|
+
var newPriority = target.style.getPropertyPriority(pname);
|
|
349
|
+
if (newValue !== old.style.getPropertyValue(pname) ||
|
|
350
|
+
newPriority !== old.style.getPropertyPriority(pname)) {
|
|
351
|
+
if (newPriority === '') {
|
|
352
|
+
styleObj[pname] = newValue;
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
styleObj[pname] = [newValue, newPriority];
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
361
|
+
finally {
|
|
362
|
+
try {
|
|
363
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
364
|
+
}
|
|
365
|
+
finally { if (e_3) throw e_3.error; }
|
|
366
|
+
}
|
|
367
|
+
try {
|
|
368
|
+
for (var _e = __values(Array.from(old.style)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
369
|
+
var pname = _f.value;
|
|
370
|
+
if (target.style.getPropertyValue(pname) === '') {
|
|
371
|
+
styleObj[pname] = false;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
376
|
+
finally {
|
|
377
|
+
try {
|
|
378
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
379
|
+
}
|
|
380
|
+
finally { if (e_4) throw e_4.error; }
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
var tagName = m.target.tagName;
|
|
385
|
+
if (tagName === 'INPUT') {
|
|
386
|
+
var node = m.target;
|
|
387
|
+
if (node.type === 'password') {
|
|
388
|
+
item.attributes['value'] = '*'.repeat(node.value.length);
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
item.attributes[m.attributeName] = transformAttribute(_this.doc, m.target.tagName, m.attributeName, value);
|
|
393
|
+
}
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
case 'childList': {
|
|
397
|
+
m.addedNodes.forEach(function (n) { return _this.genAdds(n, m.target); });
|
|
398
|
+
m.removedNodes.forEach(function (n) {
|
|
399
|
+
var nodeId = _this.mirror.getId(n);
|
|
400
|
+
var parentId = isShadowRoot(m.target)
|
|
401
|
+
? _this.mirror.getId(m.target.host)
|
|
402
|
+
: _this.mirror.getId(m.target);
|
|
403
|
+
if (isBlocked(m.target, _this.blockClass) || isIgnored(n)) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
if (_this.addedSet.has(n)) {
|
|
407
|
+
deepDelete(_this.addedSet, n);
|
|
408
|
+
_this.droppedSet.add(n);
|
|
409
|
+
}
|
|
410
|
+
else if (_this.addedSet.has(m.target) && nodeId === -1) ;
|
|
411
|
+
else if (isAncestorRemoved(m.target, _this.mirror)) ;
|
|
412
|
+
else if (_this.movedSet.has(n) &&
|
|
413
|
+
_this.movedMap[moveKey(nodeId, parentId)]) {
|
|
414
|
+
deepDelete(_this.movedSet, n);
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
_this.removes.push({
|
|
418
|
+
parentId: parentId,
|
|
419
|
+
id: nodeId,
|
|
420
|
+
isShadow: isShadowRoot(m.target) ? true : undefined,
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
_this.mapRemoves.push(n);
|
|
424
|
+
});
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
this.genAdds = function (n, target) {
|
|
430
|
+
if (target && isBlocked(target, _this.blockClass)) {
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
if (isINode(n)) {
|
|
434
|
+
if (isIgnored(n)) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
_this.movedSet.add(n);
|
|
438
|
+
var targetId = null;
|
|
439
|
+
if (target && isINode(target)) {
|
|
440
|
+
targetId = target.__sn.id;
|
|
441
|
+
}
|
|
442
|
+
if (targetId) {
|
|
443
|
+
_this.movedMap[moveKey(n.__sn.id, targetId)] = true;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
_this.addedSet.add(n);
|
|
448
|
+
_this.droppedSet.delete(n);
|
|
449
|
+
}
|
|
450
|
+
if (!isBlocked(n, _this.blockClass))
|
|
451
|
+
n.childNodes.forEach(function (childN) { return _this.genAdds(childN); });
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
MutationBuffer.prototype.init = function (options) {
|
|
455
|
+
var _this = this;
|
|
456
|
+
[
|
|
457
|
+
'mutationCb',
|
|
458
|
+
'blockClass',
|
|
459
|
+
'blockSelector',
|
|
460
|
+
'maskTextClass',
|
|
461
|
+
'maskTextSelector',
|
|
462
|
+
'inlineStylesheet',
|
|
463
|
+
'maskInputOptions',
|
|
464
|
+
'maskTextFn',
|
|
465
|
+
'maskInputFn',
|
|
466
|
+
'recordCanvas',
|
|
467
|
+
'inlineImages',
|
|
468
|
+
'slimDOMOptions',
|
|
469
|
+
'doc',
|
|
470
|
+
'mirror',
|
|
471
|
+
'iframeManager',
|
|
472
|
+
'shadowDomManager',
|
|
473
|
+
'canvasManager',
|
|
474
|
+
'enableStrictPrivacy',
|
|
475
|
+
].forEach(function (key) {
|
|
476
|
+
_this[key] = options[key];
|
|
477
|
+
});
|
|
478
|
+
};
|
|
479
|
+
MutationBuffer.prototype.freeze = function () {
|
|
480
|
+
this.frozen = true;
|
|
481
|
+
this.canvasManager.freeze();
|
|
482
|
+
};
|
|
483
|
+
MutationBuffer.prototype.unfreeze = function () {
|
|
484
|
+
this.frozen = false;
|
|
485
|
+
this.canvasManager.unfreeze();
|
|
486
|
+
this.emit();
|
|
487
|
+
};
|
|
488
|
+
MutationBuffer.prototype.isFrozen = function () {
|
|
489
|
+
return this.frozen;
|
|
490
|
+
};
|
|
491
|
+
MutationBuffer.prototype.lock = function () {
|
|
492
|
+
this.locked = true;
|
|
493
|
+
this.canvasManager.lock();
|
|
494
|
+
};
|
|
495
|
+
MutationBuffer.prototype.unlock = function () {
|
|
496
|
+
this.locked = false;
|
|
497
|
+
this.canvasManager.unlock();
|
|
498
|
+
this.emit();
|
|
499
|
+
};
|
|
500
|
+
MutationBuffer.prototype.reset = function () {
|
|
501
|
+
this.shadowDomManager.reset();
|
|
502
|
+
this.canvasManager.reset();
|
|
503
|
+
};
|
|
504
|
+
return MutationBuffer;
|
|
505
|
+
}());
|
|
506
|
+
function deepDelete(addsSet, n) {
|
|
507
|
+
addsSet.delete(n);
|
|
508
|
+
n.childNodes.forEach(function (childN) { return deepDelete(addsSet, childN); });
|
|
509
|
+
}
|
|
510
|
+
function isParentRemoved(removes, n, mirror) {
|
|
511
|
+
var parentNode = n.parentNode;
|
|
512
|
+
if (!parentNode) {
|
|
513
|
+
return false;
|
|
514
|
+
}
|
|
515
|
+
var parentId = mirror.getId(parentNode);
|
|
516
|
+
if (removes.some(function (r) { return r.id === parentId; })) {
|
|
517
|
+
return true;
|
|
518
|
+
}
|
|
519
|
+
return isParentRemoved(removes, parentNode, mirror);
|
|
520
|
+
}
|
|
521
|
+
function isAncestorInSet(set, n) {
|
|
522
|
+
var parentNode = n.parentNode;
|
|
523
|
+
if (!parentNode) {
|
|
524
|
+
return false;
|
|
525
|
+
}
|
|
526
|
+
if (set.has(parentNode)) {
|
|
527
|
+
return true;
|
|
528
|
+
}
|
|
529
|
+
return isAncestorInSet(set, parentNode);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
export default MutationBuffer;
|