@highlight-run/rrweb 2.0.8 → 2.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/plugins/console-record.js +5 -5
- package/dist/plugins/console-record.min.js +5 -5
- package/dist/plugins/console-record.min.js.map +1 -1
- package/dist/plugins/console-replay.js +3 -3
- package/dist/plugins/console-replay.min.js +3 -3
- package/dist/plugins/console-replay.min.js.map +1 -1
- package/dist/record/rrweb-record-pack.js +2 -2
- package/dist/record/rrweb-record-pack.min.js +2 -2
- 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 +3 -4
- package/dist/replay/rrweb-replay-unpack.min.js +3 -4
- package/dist/replay/rrweb-replay-unpack.min.js.map +1 -1
- package/dist/replay/rrweb-replay.js +3 -4
- package/dist/replay/rrweb-replay.min.js +3 -4
- package/dist/replay/rrweb-replay.min.js.map +1 -1
- package/dist/rrweb-all.js +24 -25
- package/dist/rrweb-all.min.js +24 -25
- package/dist/rrweb-all.min.js.map +1 -1
- package/dist/rrweb.js +14 -15
- package/dist/rrweb.min.js +14 -15
- package/dist/rrweb.min.js.map +1 -1
- package/es/rrweb/packages/rrdom/es/virtual-dom.js +51 -90
- package/es/rrweb/packages/rrweb/src/index.js +1 -1
- package/es/rrweb/packages/rrweb/src/record/index.js +6 -3
- package/es/rrweb/packages/rrweb/src/record/mutation.js +1 -1
- package/es/rrweb/packages/rrweb/src/record/observer.js +1 -1
- package/es/rrweb/packages/rrweb/src/replay/index.js +1 -1
- package/es/rrweb/packages/rrweb/src/utils.js +1 -1
- package/lib/plugins/console-record.js +1 -9
- package/lib/plugins/console-replay.js +1 -9
- package/lib/record/rrweb-record-pack.js +3 -9
- package/lib/record/rrweb-record.js +21 -1061
- package/lib/replay/rrweb-replay-unpack.js +96 -1015
- package/lib/replay/rrweb-replay.js +96 -1015
- package/lib/rrweb-all.js +141 -2034
- package/lib/rrweb.js +141 -2034
- package/package.json +4 -4
- package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +0 -1858
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var rrwebSnapshot = require('@highlight-run/rrweb-snapshot');
|
|
6
|
+
|
|
5
7
|
/*! *****************************************************************************
|
|
6
8
|
Copyright (c) Microsoft Corporation.
|
|
7
9
|
|
|
@@ -27,950 +29,6 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
27
29
|
});
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
var NodeType$2;
|
|
31
|
-
(function (NodeType) {
|
|
32
|
-
NodeType[NodeType["Document"] = 0] = "Document";
|
|
33
|
-
NodeType[NodeType["DocumentType"] = 1] = "DocumentType";
|
|
34
|
-
NodeType[NodeType["Element"] = 2] = "Element";
|
|
35
|
-
NodeType[NodeType["Text"] = 3] = "Text";
|
|
36
|
-
NodeType[NodeType["CDATA"] = 4] = "CDATA";
|
|
37
|
-
NodeType[NodeType["Comment"] = 5] = "Comment";
|
|
38
|
-
})(NodeType$2 || (NodeType$2 = {}));
|
|
39
|
-
|
|
40
|
-
function isElement(n) {
|
|
41
|
-
return n.nodeType === n.ELEMENT_NODE;
|
|
42
|
-
}
|
|
43
|
-
var Mirror$2 = (function () {
|
|
44
|
-
function Mirror() {
|
|
45
|
-
this.idNodeMap = new Map();
|
|
46
|
-
this.nodeMetaMap = new WeakMap();
|
|
47
|
-
}
|
|
48
|
-
Mirror.prototype.getId = function (n) {
|
|
49
|
-
var _a;
|
|
50
|
-
if (!n)
|
|
51
|
-
return -1;
|
|
52
|
-
var id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id;
|
|
53
|
-
return id !== null && id !== void 0 ? id : -1;
|
|
54
|
-
};
|
|
55
|
-
Mirror.prototype.getNode = function (id) {
|
|
56
|
-
return this.idNodeMap.get(id) || null;
|
|
57
|
-
};
|
|
58
|
-
Mirror.prototype.getIds = function () {
|
|
59
|
-
return Array.from(this.idNodeMap.keys());
|
|
60
|
-
};
|
|
61
|
-
Mirror.prototype.getMeta = function (n) {
|
|
62
|
-
return this.nodeMetaMap.get(n) || null;
|
|
63
|
-
};
|
|
64
|
-
Mirror.prototype.removeNodeFromMap = function (n) {
|
|
65
|
-
var _this = this;
|
|
66
|
-
var id = this.getId(n);
|
|
67
|
-
this.idNodeMap["delete"](id);
|
|
68
|
-
if (n.childNodes) {
|
|
69
|
-
n.childNodes.forEach(function (childNode) {
|
|
70
|
-
return _this.removeNodeFromMap(childNode);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
Mirror.prototype.has = function (id) {
|
|
75
|
-
return this.idNodeMap.has(id);
|
|
76
|
-
};
|
|
77
|
-
Mirror.prototype.hasNode = function (node) {
|
|
78
|
-
return this.nodeMetaMap.has(node);
|
|
79
|
-
};
|
|
80
|
-
Mirror.prototype.add = function (n, meta) {
|
|
81
|
-
var id = meta.id;
|
|
82
|
-
this.idNodeMap.set(id, n);
|
|
83
|
-
this.nodeMetaMap.set(n, meta);
|
|
84
|
-
};
|
|
85
|
-
Mirror.prototype.replace = function (id, n) {
|
|
86
|
-
this.idNodeMap.set(id, n);
|
|
87
|
-
};
|
|
88
|
-
Mirror.prototype.reset = function () {
|
|
89
|
-
this.idNodeMap = new Map();
|
|
90
|
-
this.nodeMetaMap = new WeakMap();
|
|
91
|
-
};
|
|
92
|
-
return Mirror;
|
|
93
|
-
}());
|
|
94
|
-
function createMirror$2() {
|
|
95
|
-
return new Mirror$2();
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
|
|
99
|
-
function parse(css, options) {
|
|
100
|
-
if (options === void 0) { options = {}; }
|
|
101
|
-
var lineno = 1;
|
|
102
|
-
var column = 1;
|
|
103
|
-
function updatePosition(str) {
|
|
104
|
-
var lines = str.match(/\n/g);
|
|
105
|
-
if (lines) {
|
|
106
|
-
lineno += lines.length;
|
|
107
|
-
}
|
|
108
|
-
var i = str.lastIndexOf('\n');
|
|
109
|
-
column = i === -1 ? column + str.length : str.length - i;
|
|
110
|
-
}
|
|
111
|
-
function position() {
|
|
112
|
-
var start = { line: lineno, column: column };
|
|
113
|
-
return function (node) {
|
|
114
|
-
node.position = new Position(start);
|
|
115
|
-
whitespace();
|
|
116
|
-
return node;
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
var Position = (function () {
|
|
120
|
-
function Position(start) {
|
|
121
|
-
this.start = start;
|
|
122
|
-
this.end = { line: lineno, column: column };
|
|
123
|
-
this.source = options.source;
|
|
124
|
-
}
|
|
125
|
-
return Position;
|
|
126
|
-
}());
|
|
127
|
-
Position.prototype.content = css;
|
|
128
|
-
var errorsList = [];
|
|
129
|
-
function error(msg) {
|
|
130
|
-
var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);
|
|
131
|
-
err.reason = msg;
|
|
132
|
-
err.filename = options.source;
|
|
133
|
-
err.line = lineno;
|
|
134
|
-
err.column = column;
|
|
135
|
-
err.source = css;
|
|
136
|
-
if (options.silent) {
|
|
137
|
-
errorsList.push(err);
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
throw err;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
function stylesheet() {
|
|
144
|
-
var rulesList = rules();
|
|
145
|
-
return {
|
|
146
|
-
type: 'stylesheet',
|
|
147
|
-
stylesheet: {
|
|
148
|
-
source: options.source,
|
|
149
|
-
rules: rulesList,
|
|
150
|
-
parsingErrors: errorsList
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
function open() {
|
|
155
|
-
return match(/^{\s*/);
|
|
156
|
-
}
|
|
157
|
-
function close() {
|
|
158
|
-
return match(/^}/);
|
|
159
|
-
}
|
|
160
|
-
function rules() {
|
|
161
|
-
var node;
|
|
162
|
-
var rules = [];
|
|
163
|
-
whitespace();
|
|
164
|
-
comments(rules);
|
|
165
|
-
while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {
|
|
166
|
-
if (node !== false) {
|
|
167
|
-
rules.push(node);
|
|
168
|
-
comments(rules);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
return rules;
|
|
172
|
-
}
|
|
173
|
-
function match(re) {
|
|
174
|
-
var m = re.exec(css);
|
|
175
|
-
if (!m) {
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
var str = m[0];
|
|
179
|
-
updatePosition(str);
|
|
180
|
-
css = css.slice(str.length);
|
|
181
|
-
return m;
|
|
182
|
-
}
|
|
183
|
-
function whitespace() {
|
|
184
|
-
match(/^\s*/);
|
|
185
|
-
}
|
|
186
|
-
function comments(rules) {
|
|
187
|
-
if (rules === void 0) { rules = []; }
|
|
188
|
-
var c;
|
|
189
|
-
while ((c = comment())) {
|
|
190
|
-
if (c !== false) {
|
|
191
|
-
rules.push(c);
|
|
192
|
-
}
|
|
193
|
-
c = comment();
|
|
194
|
-
}
|
|
195
|
-
return rules;
|
|
196
|
-
}
|
|
197
|
-
function comment() {
|
|
198
|
-
var pos = position();
|
|
199
|
-
if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
var i = 2;
|
|
203
|
-
while ('' !== css.charAt(i) &&
|
|
204
|
-
('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {
|
|
205
|
-
++i;
|
|
206
|
-
}
|
|
207
|
-
i += 2;
|
|
208
|
-
if ('' === css.charAt(i - 1)) {
|
|
209
|
-
return error('End of comment missing');
|
|
210
|
-
}
|
|
211
|
-
var str = css.slice(2, i - 2);
|
|
212
|
-
column += 2;
|
|
213
|
-
updatePosition(str);
|
|
214
|
-
css = css.slice(i);
|
|
215
|
-
column += 2;
|
|
216
|
-
return pos({
|
|
217
|
-
type: 'comment',
|
|
218
|
-
comment: str
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
function selector() {
|
|
222
|
-
var m = match(/^([^{]+)/);
|
|
223
|
-
if (!m) {
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
return trim(m[0])
|
|
227
|
-
.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '')
|
|
228
|
-
.replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function (m) {
|
|
229
|
-
return m.replace(/,/g, '\u200C');
|
|
230
|
-
})
|
|
231
|
-
.split(/\s*(?![^(]*\)),\s*/)
|
|
232
|
-
.map(function (s) {
|
|
233
|
-
return s.replace(/\u200C/g, ',');
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
function declaration() {
|
|
237
|
-
var pos = position();
|
|
238
|
-
var propMatch = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
|
|
239
|
-
if (!propMatch) {
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
var prop = trim(propMatch[0]);
|
|
243
|
-
if (!match(/^:\s*/)) {
|
|
244
|
-
return error("property missing ':'");
|
|
245
|
-
}
|
|
246
|
-
var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
|
|
247
|
-
var ret = pos({
|
|
248
|
-
type: 'declaration',
|
|
249
|
-
property: prop.replace(commentre, ''),
|
|
250
|
-
value: val ? trim(val[0]).replace(commentre, '') : ''
|
|
251
|
-
});
|
|
252
|
-
match(/^[;\s]*/);
|
|
253
|
-
return ret;
|
|
254
|
-
}
|
|
255
|
-
function declarations() {
|
|
256
|
-
var decls = [];
|
|
257
|
-
if (!open()) {
|
|
258
|
-
return error("missing '{'");
|
|
259
|
-
}
|
|
260
|
-
comments(decls);
|
|
261
|
-
var decl;
|
|
262
|
-
while ((decl = declaration())) {
|
|
263
|
-
if (decl !== false) {
|
|
264
|
-
decls.push(decl);
|
|
265
|
-
comments(decls);
|
|
266
|
-
}
|
|
267
|
-
decl = declaration();
|
|
268
|
-
}
|
|
269
|
-
if (!close()) {
|
|
270
|
-
return error("missing '}'");
|
|
271
|
-
}
|
|
272
|
-
return decls;
|
|
273
|
-
}
|
|
274
|
-
function keyframe() {
|
|
275
|
-
var m;
|
|
276
|
-
var vals = [];
|
|
277
|
-
var pos = position();
|
|
278
|
-
while ((m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/))) {
|
|
279
|
-
vals.push(m[1]);
|
|
280
|
-
match(/^,\s*/);
|
|
281
|
-
}
|
|
282
|
-
if (!vals.length) {
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
return pos({
|
|
286
|
-
type: 'keyframe',
|
|
287
|
-
values: vals,
|
|
288
|
-
declarations: declarations()
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
function atkeyframes() {
|
|
292
|
-
var pos = position();
|
|
293
|
-
var m = match(/^@([-\w]+)?keyframes\s*/);
|
|
294
|
-
if (!m) {
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
var vendor = m[1];
|
|
298
|
-
m = match(/^([-\w]+)\s*/);
|
|
299
|
-
if (!m) {
|
|
300
|
-
return error('@keyframes missing name');
|
|
301
|
-
}
|
|
302
|
-
var name = m[1];
|
|
303
|
-
if (!open()) {
|
|
304
|
-
return error("@keyframes missing '{'");
|
|
305
|
-
}
|
|
306
|
-
var frame;
|
|
307
|
-
var frames = comments();
|
|
308
|
-
while ((frame = keyframe())) {
|
|
309
|
-
frames.push(frame);
|
|
310
|
-
frames = frames.concat(comments());
|
|
311
|
-
}
|
|
312
|
-
if (!close()) {
|
|
313
|
-
return error("@keyframes missing '}'");
|
|
314
|
-
}
|
|
315
|
-
return pos({
|
|
316
|
-
type: 'keyframes',
|
|
317
|
-
name: name,
|
|
318
|
-
vendor: vendor,
|
|
319
|
-
keyframes: frames
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
function atsupports() {
|
|
323
|
-
var pos = position();
|
|
324
|
-
var m = match(/^@supports *([^{]+)/);
|
|
325
|
-
if (!m) {
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
var supports = trim(m[1]);
|
|
329
|
-
if (!open()) {
|
|
330
|
-
return error("@supports missing '{'");
|
|
331
|
-
}
|
|
332
|
-
var style = comments().concat(rules());
|
|
333
|
-
if (!close()) {
|
|
334
|
-
return error("@supports missing '}'");
|
|
335
|
-
}
|
|
336
|
-
return pos({
|
|
337
|
-
type: 'supports',
|
|
338
|
-
supports: supports,
|
|
339
|
-
rules: style
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
function athost() {
|
|
343
|
-
var pos = position();
|
|
344
|
-
var m = match(/^@host\s*/);
|
|
345
|
-
if (!m) {
|
|
346
|
-
return;
|
|
347
|
-
}
|
|
348
|
-
if (!open()) {
|
|
349
|
-
return error("@host missing '{'");
|
|
350
|
-
}
|
|
351
|
-
var style = comments().concat(rules());
|
|
352
|
-
if (!close()) {
|
|
353
|
-
return error("@host missing '}'");
|
|
354
|
-
}
|
|
355
|
-
return pos({
|
|
356
|
-
type: 'host',
|
|
357
|
-
rules: style
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
function atmedia() {
|
|
361
|
-
var pos = position();
|
|
362
|
-
var m = match(/^@media *([^{]+)/);
|
|
363
|
-
if (!m) {
|
|
364
|
-
return;
|
|
365
|
-
}
|
|
366
|
-
var media = trim(m[1]);
|
|
367
|
-
if (!open()) {
|
|
368
|
-
return error("@media missing '{'");
|
|
369
|
-
}
|
|
370
|
-
var style = comments().concat(rules());
|
|
371
|
-
if (!close()) {
|
|
372
|
-
return error("@media missing '}'");
|
|
373
|
-
}
|
|
374
|
-
return pos({
|
|
375
|
-
type: 'media',
|
|
376
|
-
media: media,
|
|
377
|
-
rules: style
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
function atcustommedia() {
|
|
381
|
-
var pos = position();
|
|
382
|
-
var m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
|
|
383
|
-
if (!m) {
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
|
-
return pos({
|
|
387
|
-
type: 'custom-media',
|
|
388
|
-
name: trim(m[1]),
|
|
389
|
-
media: trim(m[2])
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
function atpage() {
|
|
393
|
-
var pos = position();
|
|
394
|
-
var m = match(/^@page */);
|
|
395
|
-
if (!m) {
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
398
|
-
var sel = selector() || [];
|
|
399
|
-
if (!open()) {
|
|
400
|
-
return error("@page missing '{'");
|
|
401
|
-
}
|
|
402
|
-
var decls = comments();
|
|
403
|
-
var decl;
|
|
404
|
-
while ((decl = declaration())) {
|
|
405
|
-
decls.push(decl);
|
|
406
|
-
decls = decls.concat(comments());
|
|
407
|
-
}
|
|
408
|
-
if (!close()) {
|
|
409
|
-
return error("@page missing '}'");
|
|
410
|
-
}
|
|
411
|
-
return pos({
|
|
412
|
-
type: 'page',
|
|
413
|
-
selectors: sel,
|
|
414
|
-
declarations: decls
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
function atdocument() {
|
|
418
|
-
var pos = position();
|
|
419
|
-
var m = match(/^@([-\w]+)?document *([^{]+)/);
|
|
420
|
-
if (!m) {
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
var vendor = trim(m[1]);
|
|
424
|
-
var doc = trim(m[2]);
|
|
425
|
-
if (!open()) {
|
|
426
|
-
return error("@document missing '{'");
|
|
427
|
-
}
|
|
428
|
-
var style = comments().concat(rules());
|
|
429
|
-
if (!close()) {
|
|
430
|
-
return error("@document missing '}'");
|
|
431
|
-
}
|
|
432
|
-
return pos({
|
|
433
|
-
type: 'document',
|
|
434
|
-
document: doc,
|
|
435
|
-
vendor: vendor,
|
|
436
|
-
rules: style
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
function atfontface() {
|
|
440
|
-
var pos = position();
|
|
441
|
-
var m = match(/^@font-face\s*/);
|
|
442
|
-
if (!m) {
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
|
-
if (!open()) {
|
|
446
|
-
return error("@font-face missing '{'");
|
|
447
|
-
}
|
|
448
|
-
var decls = comments();
|
|
449
|
-
var decl;
|
|
450
|
-
while ((decl = declaration())) {
|
|
451
|
-
decls.push(decl);
|
|
452
|
-
decls = decls.concat(comments());
|
|
453
|
-
}
|
|
454
|
-
if (!close()) {
|
|
455
|
-
return error("@font-face missing '}'");
|
|
456
|
-
}
|
|
457
|
-
return pos({
|
|
458
|
-
type: 'font-face',
|
|
459
|
-
declarations: decls
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
var atimport = _compileAtrule('import');
|
|
463
|
-
var atcharset = _compileAtrule('charset');
|
|
464
|
-
var atnamespace = _compileAtrule('namespace');
|
|
465
|
-
function _compileAtrule(name) {
|
|
466
|
-
var re = new RegExp('^@' + name + '\\s*([^;]+);');
|
|
467
|
-
return function () {
|
|
468
|
-
var pos = position();
|
|
469
|
-
var m = match(re);
|
|
470
|
-
if (!m) {
|
|
471
|
-
return;
|
|
472
|
-
}
|
|
473
|
-
var ret = { type: name };
|
|
474
|
-
ret[name] = m[1].trim();
|
|
475
|
-
return pos(ret);
|
|
476
|
-
};
|
|
477
|
-
}
|
|
478
|
-
function atrule() {
|
|
479
|
-
if (css[0] !== '@') {
|
|
480
|
-
return;
|
|
481
|
-
}
|
|
482
|
-
return (atkeyframes() ||
|
|
483
|
-
atmedia() ||
|
|
484
|
-
atcustommedia() ||
|
|
485
|
-
atsupports() ||
|
|
486
|
-
atimport() ||
|
|
487
|
-
atcharset() ||
|
|
488
|
-
atnamespace() ||
|
|
489
|
-
atdocument() ||
|
|
490
|
-
atpage() ||
|
|
491
|
-
athost() ||
|
|
492
|
-
atfontface());
|
|
493
|
-
}
|
|
494
|
-
function rule() {
|
|
495
|
-
var pos = position();
|
|
496
|
-
var sel = selector();
|
|
497
|
-
if (!sel) {
|
|
498
|
-
return error('selector missing');
|
|
499
|
-
}
|
|
500
|
-
comments();
|
|
501
|
-
return pos({
|
|
502
|
-
type: 'rule',
|
|
503
|
-
selectors: sel,
|
|
504
|
-
declarations: declarations()
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
|
-
return addParent(stylesheet());
|
|
508
|
-
}
|
|
509
|
-
function trim(str) {
|
|
510
|
-
return str ? str.replace(/^\s+|\s+$/g, '') : '';
|
|
511
|
-
}
|
|
512
|
-
function addParent(obj, parent) {
|
|
513
|
-
var isNode = obj && typeof obj.type === 'string';
|
|
514
|
-
var childParent = isNode ? obj : parent;
|
|
515
|
-
for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {
|
|
516
|
-
var k = _a[_i];
|
|
517
|
-
var value = obj[k];
|
|
518
|
-
if (Array.isArray(value)) {
|
|
519
|
-
value.forEach(function (v) {
|
|
520
|
-
addParent(v, childParent);
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
|
-
else if (value && typeof value === 'object') {
|
|
524
|
-
addParent(value, childParent);
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
if (isNode) {
|
|
528
|
-
Object.defineProperty(obj, 'parent', {
|
|
529
|
-
configurable: true,
|
|
530
|
-
writable: true,
|
|
531
|
-
enumerable: false,
|
|
532
|
-
value: parent || null
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
return obj;
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
var tagMap = {
|
|
539
|
-
script: 'noscript',
|
|
540
|
-
altglyph: 'altGlyph',
|
|
541
|
-
altglyphdef: 'altGlyphDef',
|
|
542
|
-
altglyphitem: 'altGlyphItem',
|
|
543
|
-
animatecolor: 'animateColor',
|
|
544
|
-
animatemotion: 'animateMotion',
|
|
545
|
-
animatetransform: 'animateTransform',
|
|
546
|
-
clippath: 'clipPath',
|
|
547
|
-
feblend: 'feBlend',
|
|
548
|
-
fecolormatrix: 'feColorMatrix',
|
|
549
|
-
fecomponenttransfer: 'feComponentTransfer',
|
|
550
|
-
fecomposite: 'feComposite',
|
|
551
|
-
feconvolvematrix: 'feConvolveMatrix',
|
|
552
|
-
fediffuselighting: 'feDiffuseLighting',
|
|
553
|
-
fedisplacementmap: 'feDisplacementMap',
|
|
554
|
-
fedistantlight: 'feDistantLight',
|
|
555
|
-
fedropshadow: 'feDropShadow',
|
|
556
|
-
feflood: 'feFlood',
|
|
557
|
-
fefunca: 'feFuncA',
|
|
558
|
-
fefuncb: 'feFuncB',
|
|
559
|
-
fefuncg: 'feFuncG',
|
|
560
|
-
fefuncr: 'feFuncR',
|
|
561
|
-
fegaussianblur: 'feGaussianBlur',
|
|
562
|
-
feimage: 'feImage',
|
|
563
|
-
femerge: 'feMerge',
|
|
564
|
-
femergenode: 'feMergeNode',
|
|
565
|
-
femorphology: 'feMorphology',
|
|
566
|
-
feoffset: 'feOffset',
|
|
567
|
-
fepointlight: 'fePointLight',
|
|
568
|
-
fespecularlighting: 'feSpecularLighting',
|
|
569
|
-
fespotlight: 'feSpotLight',
|
|
570
|
-
fetile: 'feTile',
|
|
571
|
-
feturbulence: 'feTurbulence',
|
|
572
|
-
foreignobject: 'foreignObject',
|
|
573
|
-
glyphref: 'glyphRef',
|
|
574
|
-
lineargradient: 'linearGradient',
|
|
575
|
-
radialgradient: 'radialGradient'
|
|
576
|
-
};
|
|
577
|
-
function getTagName(n) {
|
|
578
|
-
var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;
|
|
579
|
-
if (tagName === 'link' && n.attributes._cssText) {
|
|
580
|
-
tagName = 'style';
|
|
581
|
-
}
|
|
582
|
-
return tagName;
|
|
583
|
-
}
|
|
584
|
-
function escapeRegExp(str) {
|
|
585
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
586
|
-
}
|
|
587
|
-
var HOVER_SELECTOR = /([^\\]):hover/;
|
|
588
|
-
var HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');
|
|
589
|
-
function addHoverClass(cssText, cache) {
|
|
590
|
-
var _a;
|
|
591
|
-
if (!((_a = window === null || window === void 0 ? void 0 : window.HIG_CONFIGURATION) === null || _a === void 0 ? void 0 : _a.enableOnHoverClass)) {
|
|
592
|
-
return cssText;
|
|
593
|
-
}
|
|
594
|
-
var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);
|
|
595
|
-
if (cachedStyle)
|
|
596
|
-
return cachedStyle;
|
|
597
|
-
var ast = parse(cssText, {
|
|
598
|
-
silent: true
|
|
599
|
-
});
|
|
600
|
-
if (!ast.stylesheet) {
|
|
601
|
-
return cssText;
|
|
602
|
-
}
|
|
603
|
-
var selectors = [];
|
|
604
|
-
ast.stylesheet.rules.forEach(function (rule) {
|
|
605
|
-
if ('selectors' in rule) {
|
|
606
|
-
(rule.selectors || []).forEach(function (selector) {
|
|
607
|
-
if (HOVER_SELECTOR.test(selector)) {
|
|
608
|
-
selectors.push(selector);
|
|
609
|
-
}
|
|
610
|
-
});
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
if (selectors.length === 0) {
|
|
614
|
-
return cssText;
|
|
615
|
-
}
|
|
616
|
-
var selectorMatcher = new RegExp(selectors
|
|
617
|
-
.filter(function (selector, index) { return selectors.indexOf(selector) === index; })
|
|
618
|
-
.sort(function (a, b) { return b.length - a.length; })
|
|
619
|
-
.map(function (selector) {
|
|
620
|
-
return escapeRegExp(selector);
|
|
621
|
-
})
|
|
622
|
-
.join('|'), 'g');
|
|
623
|
-
var result = cssText.replace(selectorMatcher, function (selector) {
|
|
624
|
-
var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\:hover');
|
|
625
|
-
return selector + ", " + newSelector;
|
|
626
|
-
});
|
|
627
|
-
cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);
|
|
628
|
-
return result;
|
|
629
|
-
}
|
|
630
|
-
function createCache() {
|
|
631
|
-
var stylesWithHoverClass = new Map();
|
|
632
|
-
return {
|
|
633
|
-
stylesWithHoverClass: stylesWithHoverClass
|
|
634
|
-
};
|
|
635
|
-
}
|
|
636
|
-
function buildNode(n, options) {
|
|
637
|
-
var doc = options.doc, hackCss = options.hackCss, cache = options.cache;
|
|
638
|
-
switch (n.type) {
|
|
639
|
-
case NodeType$2.Document:
|
|
640
|
-
return doc.implementation.createDocument(null, '', null);
|
|
641
|
-
case NodeType$2.DocumentType:
|
|
642
|
-
return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);
|
|
643
|
-
case NodeType$2.Element:
|
|
644
|
-
var tagName = getTagName(n);
|
|
645
|
-
var node_1;
|
|
646
|
-
if (n.isSVG) {
|
|
647
|
-
node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);
|
|
648
|
-
}
|
|
649
|
-
else {
|
|
650
|
-
node_1 = doc.createElement(tagName);
|
|
651
|
-
}
|
|
652
|
-
var _loop_1 = function (name_1) {
|
|
653
|
-
if (!n.attributes.hasOwnProperty(name_1)) {
|
|
654
|
-
return "continue";
|
|
655
|
-
}
|
|
656
|
-
var value = n.attributes[name_1];
|
|
657
|
-
if (tagName === 'option' && name_1 === 'selected' && value === false) {
|
|
658
|
-
return "continue";
|
|
659
|
-
}
|
|
660
|
-
value =
|
|
661
|
-
typeof value === 'boolean' || typeof value === 'number' ? '' : value;
|
|
662
|
-
if (!name_1.startsWith('rr_')) {
|
|
663
|
-
var isTextarea = tagName === 'textarea' && name_1 === 'value';
|
|
664
|
-
var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';
|
|
665
|
-
if (isRemoteOrDynamicCss && hackCss) {
|
|
666
|
-
value = addHoverClass(value, cache);
|
|
667
|
-
if (typeof value === 'string') {
|
|
668
|
-
var regex = /url\(\"https:\/\/\S*(.eot|.woff2|.ttf|.woff)\S*\"\)/gm;
|
|
669
|
-
var m = void 0;
|
|
670
|
-
var fontUrls_1 = [];
|
|
671
|
-
var PROXY_URL_1 = 'https://replay-cors-proxy.highlightrun.workers.dev';
|
|
672
|
-
while ((m = regex.exec(value)) !== null) {
|
|
673
|
-
if (m.index === regex.lastIndex) {
|
|
674
|
-
regex.lastIndex++;
|
|
675
|
-
}
|
|
676
|
-
m.forEach(function (match, groupIndex) {
|
|
677
|
-
if (groupIndex === 0) {
|
|
678
|
-
var url = match.slice(5, match.length - 2);
|
|
679
|
-
fontUrls_1.push({
|
|
680
|
-
originalUrl: url,
|
|
681
|
-
proxyUrl: url.replace(url, PROXY_URL_1 + "?url=" + url)
|
|
682
|
-
});
|
|
683
|
-
}
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
fontUrls_1.forEach(function (urlPair) {
|
|
687
|
-
value = value.replace(urlPair.originalUrl, urlPair.proxyUrl);
|
|
688
|
-
});
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
if (isTextarea || isRemoteOrDynamicCss) {
|
|
692
|
-
var child = doc.createTextNode(value);
|
|
693
|
-
for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {
|
|
694
|
-
var c = _a[_i];
|
|
695
|
-
if (c.nodeType === node_1.TEXT_NODE) {
|
|
696
|
-
node_1.removeChild(c);
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
node_1.appendChild(child);
|
|
700
|
-
return "continue";
|
|
701
|
-
}
|
|
702
|
-
try {
|
|
703
|
-
if (n.isSVG && name_1 === 'xlink:href') {
|
|
704
|
-
node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);
|
|
705
|
-
}
|
|
706
|
-
else if (name_1 === 'onload' ||
|
|
707
|
-
name_1 === 'onclick' ||
|
|
708
|
-
name_1.substring(0, 7) === 'onmouse') {
|
|
709
|
-
node_1.setAttribute('_' + name_1, value);
|
|
710
|
-
}
|
|
711
|
-
else if (tagName === 'meta' &&
|
|
712
|
-
n.attributes['http-equiv'] === 'Content-Security-Policy' &&
|
|
713
|
-
name_1 === 'content') {
|
|
714
|
-
node_1.setAttribute('csp-content', value);
|
|
715
|
-
return "continue";
|
|
716
|
-
}
|
|
717
|
-
else if (tagName === 'link' &&
|
|
718
|
-
n.attributes.rel === 'preload' &&
|
|
719
|
-
n.attributes.as === 'script') {
|
|
720
|
-
}
|
|
721
|
-
else if (tagName === 'link' &&
|
|
722
|
-
n.attributes.rel === 'prefetch' &&
|
|
723
|
-
typeof n.attributes.href === 'string' &&
|
|
724
|
-
n.attributes.href.endsWith('.js')) {
|
|
725
|
-
}
|
|
726
|
-
else if (tagName === 'img' &&
|
|
727
|
-
n.attributes.srcset &&
|
|
728
|
-
n.attributes.rr_dataURL) {
|
|
729
|
-
node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);
|
|
730
|
-
}
|
|
731
|
-
else {
|
|
732
|
-
node_1.setAttribute(name_1, value);
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
catch (error) {
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
else {
|
|
739
|
-
if (tagName === 'canvas' && name_1 === 'rr_dataURL') {
|
|
740
|
-
var image_1 = document.createElement('img');
|
|
741
|
-
image_1.src = value;
|
|
742
|
-
image_1.onload = function () {
|
|
743
|
-
var ctx = node_1.getContext('2d');
|
|
744
|
-
if (ctx) {
|
|
745
|
-
ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);
|
|
746
|
-
}
|
|
747
|
-
};
|
|
748
|
-
}
|
|
749
|
-
else if (tagName === 'img' && name_1 === 'rr_dataURL') {
|
|
750
|
-
var image = node_1;
|
|
751
|
-
if (!image.currentSrc.startsWith('data:')) {
|
|
752
|
-
image.setAttribute('rrweb-original-src', n.attributes.src);
|
|
753
|
-
image.src = value;
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
if (name_1 === 'rr_width') {
|
|
757
|
-
node_1.style.width = value;
|
|
758
|
-
}
|
|
759
|
-
else if (name_1 === 'rr_height') {
|
|
760
|
-
node_1.style.height = value;
|
|
761
|
-
}
|
|
762
|
-
else if (name_1 === 'rr_mediaCurrentTime') {
|
|
763
|
-
node_1.currentTime = n.attributes
|
|
764
|
-
.rr_mediaCurrentTime;
|
|
765
|
-
}
|
|
766
|
-
else if (name_1 === 'rr_mediaState') {
|
|
767
|
-
switch (value) {
|
|
768
|
-
case 'played':
|
|
769
|
-
node_1
|
|
770
|
-
.play()["catch"](function (e) { return console.warn('media playback error', e); });
|
|
771
|
-
break;
|
|
772
|
-
case 'paused':
|
|
773
|
-
node_1.pause();
|
|
774
|
-
break;
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
};
|
|
779
|
-
for (var name_1 in n.attributes) {
|
|
780
|
-
_loop_1(name_1);
|
|
781
|
-
}
|
|
782
|
-
if (n.isShadowHost) {
|
|
783
|
-
if (!node_1.shadowRoot) {
|
|
784
|
-
node_1.attachShadow({ mode: 'open' });
|
|
785
|
-
}
|
|
786
|
-
else {
|
|
787
|
-
while (node_1.shadowRoot.firstChild) {
|
|
788
|
-
node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
return node_1;
|
|
793
|
-
case NodeType$2.Text:
|
|
794
|
-
return doc.createTextNode(n.isStyle && hackCss
|
|
795
|
-
? addHoverClass(n.textContent, cache)
|
|
796
|
-
: n.textContent);
|
|
797
|
-
case NodeType$2.CDATA:
|
|
798
|
-
return doc.createCDATASection(n.textContent);
|
|
799
|
-
case NodeType$2.Comment:
|
|
800
|
-
return doc.createComment(n.textContent);
|
|
801
|
-
default:
|
|
802
|
-
return null;
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
function buildNodeWithSN(n, options) {
|
|
806
|
-
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;
|
|
807
|
-
var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });
|
|
808
|
-
if (!node) {
|
|
809
|
-
return null;
|
|
810
|
-
}
|
|
811
|
-
if (n.rootId) {
|
|
812
|
-
console.assert(mirror.getNode(n.rootId) === doc, 'Target document should have the same root id.');
|
|
813
|
-
}
|
|
814
|
-
if (n.type === NodeType$2.Document) {
|
|
815
|
-
doc.close();
|
|
816
|
-
doc.open();
|
|
817
|
-
if (n.compatMode === 'BackCompat' &&
|
|
818
|
-
n.childNodes &&
|
|
819
|
-
n.childNodes[0].type !== NodeType$2.DocumentType) {
|
|
820
|
-
if (n.childNodes[0].type === NodeType$2.Element &&
|
|
821
|
-
'xmlns' in n.childNodes[0].attributes &&
|
|
822
|
-
n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {
|
|
823
|
-
doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">');
|
|
824
|
-
}
|
|
825
|
-
else {
|
|
826
|
-
doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">');
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
node = doc;
|
|
830
|
-
}
|
|
831
|
-
mirror.add(node, n);
|
|
832
|
-
if ((n.type === NodeType$2.Document || n.type === NodeType$2.Element) &&
|
|
833
|
-
!skipChild) {
|
|
834
|
-
for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {
|
|
835
|
-
var childN = _c[_i];
|
|
836
|
-
var childNode = buildNodeWithSN(childN, {
|
|
837
|
-
doc: doc,
|
|
838
|
-
mirror: mirror,
|
|
839
|
-
skipChild: false,
|
|
840
|
-
hackCss: hackCss,
|
|
841
|
-
afterAppend: afterAppend,
|
|
842
|
-
cache: cache
|
|
843
|
-
});
|
|
844
|
-
if (!childNode) {
|
|
845
|
-
console.warn('Failed to rebuild', childN);
|
|
846
|
-
continue;
|
|
847
|
-
}
|
|
848
|
-
if (childN.isShadow && isElement(node) && node.shadowRoot) {
|
|
849
|
-
node.shadowRoot.appendChild(childNode);
|
|
850
|
-
}
|
|
851
|
-
else {
|
|
852
|
-
node.appendChild(childNode);
|
|
853
|
-
}
|
|
854
|
-
if (afterAppend) {
|
|
855
|
-
afterAppend(childNode);
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
return node;
|
|
860
|
-
}
|
|
861
|
-
function visit(mirror, onVisit) {
|
|
862
|
-
function walk(node) {
|
|
863
|
-
onVisit(node);
|
|
864
|
-
}
|
|
865
|
-
for (var _i = 0, _a = mirror.getIds(); _i < _a.length; _i++) {
|
|
866
|
-
var id = _a[_i];
|
|
867
|
-
if (mirror.has(id)) {
|
|
868
|
-
walk(mirror.getNode(id));
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
function handleScroll(node, mirror) {
|
|
873
|
-
var n = mirror.getMeta(node);
|
|
874
|
-
if ((n === null || n === void 0 ? void 0 : n.type) !== NodeType$2.Element) {
|
|
875
|
-
return;
|
|
876
|
-
}
|
|
877
|
-
var el = node;
|
|
878
|
-
for (var name_2 in n.attributes) {
|
|
879
|
-
if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {
|
|
880
|
-
continue;
|
|
881
|
-
}
|
|
882
|
-
var value = n.attributes[name_2];
|
|
883
|
-
if (name_2 === 'rr_scrollLeft') {
|
|
884
|
-
el.scrollLeft = value;
|
|
885
|
-
}
|
|
886
|
-
if (name_2 === 'rr_scrollTop') {
|
|
887
|
-
el.scrollTop = value;
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
function rebuild(n, options) {
|
|
892
|
-
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$2() : _b;
|
|
893
|
-
var node = buildNodeWithSN(n, {
|
|
894
|
-
doc: doc,
|
|
895
|
-
mirror: mirror,
|
|
896
|
-
skipChild: false,
|
|
897
|
-
hackCss: hackCss,
|
|
898
|
-
afterAppend: afterAppend,
|
|
899
|
-
cache: cache
|
|
900
|
-
});
|
|
901
|
-
visit(mirror, function (visitedNode) {
|
|
902
|
-
if (onVisit) {
|
|
903
|
-
onVisit(visitedNode);
|
|
904
|
-
}
|
|
905
|
-
handleScroll(visitedNode, mirror);
|
|
906
|
-
});
|
|
907
|
-
return node;
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
var NodeType$1;
|
|
911
|
-
(function (NodeType) {
|
|
912
|
-
NodeType[NodeType["Document"] = 0] = "Document";
|
|
913
|
-
NodeType[NodeType["DocumentType"] = 1] = "DocumentType";
|
|
914
|
-
NodeType[NodeType["Element"] = 2] = "Element";
|
|
915
|
-
NodeType[NodeType["Text"] = 3] = "Text";
|
|
916
|
-
NodeType[NodeType["CDATA"] = 4] = "CDATA";
|
|
917
|
-
NodeType[NodeType["Comment"] = 5] = "Comment";
|
|
918
|
-
})(NodeType$1 || (NodeType$1 = {}));
|
|
919
|
-
var Mirror$1 = (function () {
|
|
920
|
-
function Mirror() {
|
|
921
|
-
this.idNodeMap = new Map();
|
|
922
|
-
this.nodeMetaMap = new WeakMap();
|
|
923
|
-
}
|
|
924
|
-
Mirror.prototype.getId = function (n) {
|
|
925
|
-
var _a;
|
|
926
|
-
if (!n)
|
|
927
|
-
return -1;
|
|
928
|
-
var id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id;
|
|
929
|
-
return id !== null && id !== void 0 ? id : -1;
|
|
930
|
-
};
|
|
931
|
-
Mirror.prototype.getNode = function (id) {
|
|
932
|
-
return this.idNodeMap.get(id) || null;
|
|
933
|
-
};
|
|
934
|
-
Mirror.prototype.getIds = function () {
|
|
935
|
-
return Array.from(this.idNodeMap.keys());
|
|
936
|
-
};
|
|
937
|
-
Mirror.prototype.getMeta = function (n) {
|
|
938
|
-
return this.nodeMetaMap.get(n) || null;
|
|
939
|
-
};
|
|
940
|
-
Mirror.prototype.removeNodeFromMap = function (n) {
|
|
941
|
-
var _this = this;
|
|
942
|
-
var id = this.getId(n);
|
|
943
|
-
this.idNodeMap["delete"](id);
|
|
944
|
-
if (n.childNodes) {
|
|
945
|
-
n.childNodes.forEach(function (childNode) {
|
|
946
|
-
return _this.removeNodeFromMap(childNode);
|
|
947
|
-
});
|
|
948
|
-
}
|
|
949
|
-
};
|
|
950
|
-
Mirror.prototype.has = function (id) {
|
|
951
|
-
return this.idNodeMap.has(id);
|
|
952
|
-
};
|
|
953
|
-
Mirror.prototype.hasNode = function (node) {
|
|
954
|
-
return this.nodeMetaMap.has(node);
|
|
955
|
-
};
|
|
956
|
-
Mirror.prototype.add = function (n, meta) {
|
|
957
|
-
var id = meta.id;
|
|
958
|
-
this.idNodeMap.set(id, n);
|
|
959
|
-
this.nodeMetaMap.set(n, meta);
|
|
960
|
-
};
|
|
961
|
-
Mirror.prototype.replace = function (id, n) {
|
|
962
|
-
this.idNodeMap.set(id, n);
|
|
963
|
-
};
|
|
964
|
-
Mirror.prototype.reset = function () {
|
|
965
|
-
this.idNodeMap = new Map();
|
|
966
|
-
this.nodeMetaMap = new WeakMap();
|
|
967
|
-
};
|
|
968
|
-
return Mirror;
|
|
969
|
-
}());
|
|
970
|
-
function createMirror$1() {
|
|
971
|
-
return new Mirror$1();
|
|
972
|
-
}
|
|
973
|
-
|
|
974
32
|
function parseCSSText(cssText) {
|
|
975
33
|
const res = {};
|
|
976
34
|
const listDelimiter = /;(?![^(]*\))/g;
|
|
@@ -1061,21 +119,21 @@ function BaseRRDocumentImpl(RRNodeClass) {
|
|
|
1061
119
|
this.nodeType = NodeType.DOCUMENT_NODE;
|
|
1062
120
|
this.nodeName = '#document';
|
|
1063
121
|
this.compatMode = 'CSS1Compat';
|
|
1064
|
-
this.RRNodeType = NodeType
|
|
122
|
+
this.RRNodeType = rrwebSnapshot.NodeType.Document;
|
|
1065
123
|
this.textContent = null;
|
|
1066
124
|
}
|
|
1067
125
|
get documentElement() {
|
|
1068
|
-
return (this.childNodes.find((node) => node.RRNodeType === NodeType
|
|
126
|
+
return (this.childNodes.find((node) => node.RRNodeType === rrwebSnapshot.NodeType.Element &&
|
|
1069
127
|
node.tagName === 'HTML') || null);
|
|
1070
128
|
}
|
|
1071
129
|
get body() {
|
|
1072
130
|
var _a;
|
|
1073
|
-
return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === NodeType
|
|
131
|
+
return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === rrwebSnapshot.NodeType.Element &&
|
|
1074
132
|
node.tagName === 'BODY')) || null);
|
|
1075
133
|
}
|
|
1076
134
|
get head() {
|
|
1077
135
|
var _a;
|
|
1078
|
-
return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === NodeType
|
|
136
|
+
return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === rrwebSnapshot.NodeType.Element &&
|
|
1079
137
|
node.tagName === 'HEAD')) || null);
|
|
1080
138
|
}
|
|
1081
139
|
get implementation() {
|
|
@@ -1086,10 +144,10 @@ function BaseRRDocumentImpl(RRNodeClass) {
|
|
|
1086
144
|
}
|
|
1087
145
|
appendChild(childNode) {
|
|
1088
146
|
const nodeType = childNode.RRNodeType;
|
|
1089
|
-
if (nodeType === NodeType
|
|
1090
|
-
nodeType === NodeType
|
|
147
|
+
if (nodeType === rrwebSnapshot.NodeType.Element ||
|
|
148
|
+
nodeType === rrwebSnapshot.NodeType.DocumentType) {
|
|
1091
149
|
if (this.childNodes.some((s) => s.RRNodeType === nodeType)) {
|
|
1092
|
-
throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${nodeType === NodeType
|
|
150
|
+
throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${nodeType === rrwebSnapshot.NodeType.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`);
|
|
1093
151
|
}
|
|
1094
152
|
}
|
|
1095
153
|
childNode.parentElement = null;
|
|
@@ -1099,10 +157,10 @@ function BaseRRDocumentImpl(RRNodeClass) {
|
|
|
1099
157
|
}
|
|
1100
158
|
insertBefore(newChild, refChild) {
|
|
1101
159
|
const nodeType = newChild.RRNodeType;
|
|
1102
|
-
if (nodeType === NodeType
|
|
1103
|
-
nodeType === NodeType
|
|
160
|
+
if (nodeType === rrwebSnapshot.NodeType.Element ||
|
|
161
|
+
nodeType === rrwebSnapshot.NodeType.DocumentType) {
|
|
1104
162
|
if (this.childNodes.some((s) => s.RRNodeType === nodeType)) {
|
|
1105
|
-
throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${nodeType === NodeType
|
|
163
|
+
throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${nodeType === rrwebSnapshot.NodeType.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`);
|
|
1106
164
|
}
|
|
1107
165
|
}
|
|
1108
166
|
if (refChild === null)
|
|
@@ -1184,7 +242,7 @@ function BaseRRDocumentTypeImpl(RRNodeClass) {
|
|
|
1184
242
|
constructor(qualifiedName, publicId, systemId) {
|
|
1185
243
|
super();
|
|
1186
244
|
this.nodeType = NodeType.DOCUMENT_TYPE_NODE;
|
|
1187
|
-
this.RRNodeType = NodeType
|
|
245
|
+
this.RRNodeType = rrwebSnapshot.NodeType.DocumentType;
|
|
1188
246
|
this.textContent = null;
|
|
1189
247
|
this.name = qualifiedName;
|
|
1190
248
|
this.publicId = publicId;
|
|
@@ -1201,7 +259,7 @@ function BaseRRElementImpl(RRNodeClass) {
|
|
|
1201
259
|
constructor(tagName) {
|
|
1202
260
|
super();
|
|
1203
261
|
this.nodeType = NodeType.ELEMENT_NODE;
|
|
1204
|
-
this.RRNodeType = NodeType
|
|
262
|
+
this.RRNodeType = rrwebSnapshot.NodeType.Element;
|
|
1205
263
|
this.attributes = {};
|
|
1206
264
|
this.shadowRoot = null;
|
|
1207
265
|
this.tagName = tagName.toUpperCase();
|
|
@@ -1328,7 +386,7 @@ function BaseRRTextImpl(RRNodeClass) {
|
|
|
1328
386
|
super();
|
|
1329
387
|
this.nodeType = NodeType.TEXT_NODE;
|
|
1330
388
|
this.nodeName = '#text';
|
|
1331
|
-
this.RRNodeType = NodeType
|
|
389
|
+
this.RRNodeType = rrwebSnapshot.NodeType.Text;
|
|
1332
390
|
this.data = data;
|
|
1333
391
|
}
|
|
1334
392
|
get textContent() {
|
|
@@ -1348,7 +406,7 @@ function BaseRRCommentImpl(RRNodeClass) {
|
|
|
1348
406
|
super();
|
|
1349
407
|
this.nodeType = NodeType.COMMENT_NODE;
|
|
1350
408
|
this.nodeName = '#comment';
|
|
1351
|
-
this.RRNodeType = NodeType
|
|
409
|
+
this.RRNodeType = rrwebSnapshot.NodeType.Comment;
|
|
1352
410
|
this.data = data;
|
|
1353
411
|
}
|
|
1354
412
|
get textContent() {
|
|
@@ -1368,7 +426,7 @@ function BaseRRCDATASectionImpl(RRNodeClass) {
|
|
|
1368
426
|
super();
|
|
1369
427
|
this.nodeName = '#cdata-section';
|
|
1370
428
|
this.nodeType = NodeType.CDATA_SECTION_NODE;
|
|
1371
|
-
this.RRNodeType = NodeType
|
|
429
|
+
this.RRNodeType = rrwebSnapshot.NodeType.CDATA;
|
|
1372
430
|
this.data = data;
|
|
1373
431
|
}
|
|
1374
432
|
get textContent() {
|
|
@@ -1438,13 +496,13 @@ function diff(oldTree, newTree, replayer, rrnodeMirror) {
|
|
|
1438
496
|
}
|
|
1439
497
|
let inputDataToApply = null, scrollDataToApply = null;
|
|
1440
498
|
switch (newTree.RRNodeType) {
|
|
1441
|
-
case NodeType
|
|
499
|
+
case rrwebSnapshot.NodeType.Document: {
|
|
1442
500
|
const newRRDocument = newTree;
|
|
1443
501
|
scrollDataToApply = newRRDocument.scrollData;
|
|
1444
502
|
break;
|
|
1445
503
|
}
|
|
1446
|
-
case NodeType
|
|
1447
|
-
const oldElement =
|
|
504
|
+
case rrwebSnapshot.NodeType.Element: {
|
|
505
|
+
const oldElement = oldTree;
|
|
1448
506
|
const newRRElement = newTree;
|
|
1449
507
|
diffProps(oldElement, newRRElement, rrnodeMirror);
|
|
1450
508
|
scrollDataToApply = newRRElement.scrollData;
|
|
@@ -1452,7 +510,7 @@ function diff(oldTree, newTree, replayer, rrnodeMirror) {
|
|
|
1452
510
|
switch (newRRElement.tagName) {
|
|
1453
511
|
case 'AUDIO':
|
|
1454
512
|
case 'VIDEO': {
|
|
1455
|
-
const oldMediaElement =
|
|
513
|
+
const oldMediaElement = oldTree;
|
|
1456
514
|
const newMediaRRElement = newRRElement;
|
|
1457
515
|
if (newMediaRRElement.paused !== undefined)
|
|
1458
516
|
newMediaRRElement.paused
|
|
@@ -1467,7 +525,7 @@ function diff(oldTree, newTree, replayer, rrnodeMirror) {
|
|
|
1467
525
|
break;
|
|
1468
526
|
}
|
|
1469
527
|
case 'CANVAS':
|
|
1470
|
-
newTree.canvasMutations.forEach((canvasMutation) => replayer.applyCanvas(canvasMutation.event, canvasMutation.mutation,
|
|
528
|
+
newTree.canvasMutations.forEach((canvasMutation) => replayer.applyCanvas(canvasMutation.event, canvasMutation.mutation, oldTree));
|
|
1471
529
|
break;
|
|
1472
530
|
case 'STYLE':
|
|
1473
531
|
applyVirtualStyleRulesToNode(oldElement, newTree.rules);
|
|
@@ -1483,9 +541,9 @@ function diff(oldTree, newTree, replayer, rrnodeMirror) {
|
|
|
1483
541
|
}
|
|
1484
542
|
break;
|
|
1485
543
|
}
|
|
1486
|
-
case NodeType
|
|
1487
|
-
case NodeType
|
|
1488
|
-
case NodeType
|
|
544
|
+
case rrwebSnapshot.NodeType.Text:
|
|
545
|
+
case rrwebSnapshot.NodeType.Comment:
|
|
546
|
+
case rrwebSnapshot.NodeType.CDATA:
|
|
1489
547
|
if (oldTree.textContent !==
|
|
1490
548
|
newTree.data)
|
|
1491
549
|
oldTree.textContent = newTree.data;
|
|
@@ -1494,8 +552,7 @@ function diff(oldTree, newTree, replayer, rrnodeMirror) {
|
|
|
1494
552
|
scrollDataToApply && replayer.applyScroll(scrollDataToApply, true);
|
|
1495
553
|
inputDataToApply && replayer.applyInput(inputDataToApply);
|
|
1496
554
|
if (newTree.nodeName === 'IFRAME') {
|
|
1497
|
-
const oldContentDocument =
|
|
1498
|
-
.contentDocument;
|
|
555
|
+
const oldContentDocument = oldTree.contentDocument;
|
|
1499
556
|
const newIFrameElement = newTree;
|
|
1500
557
|
if (oldContentDocument) {
|
|
1501
558
|
const sn = rrnodeMirror.getMeta(newIFrameElement.contentDocument);
|
|
@@ -1534,7 +591,7 @@ function diffProps(oldTree, newTree, rrnodeMirror) {
|
|
|
1534
591
|
newTree.scrollTop && (oldTree.scrollTop = newTree.scrollTop);
|
|
1535
592
|
}
|
|
1536
593
|
function diffChildren(oldChildren, newChildren, parentNode, replayer, rrnodeMirror) {
|
|
1537
|
-
var _a
|
|
594
|
+
var _a;
|
|
1538
595
|
let oldStartIndex = 0, oldEndIndex = oldChildren.length - 1, newStartIndex = 0, newEndIndex = newChildren.length - 1;
|
|
1539
596
|
let oldStartNode = oldChildren[oldStartIndex], oldEndNode = oldChildren[oldEndIndex], newStartNode = newChildren[newStartIndex], newEndNode = newChildren[newEndIndex];
|
|
1540
597
|
let oldIdToIndex = undefined, indexInOld;
|
|
@@ -1556,16 +613,26 @@ function diffChildren(oldChildren, newChildren, parentNode, replayer, rrnodeMirr
|
|
|
1556
613
|
newEndNode = newChildren[--newEndIndex];
|
|
1557
614
|
}
|
|
1558
615
|
else if (replayer.mirror.getId(oldStartNode) === rrnodeMirror.getId(newEndNode)) {
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
616
|
+
try {
|
|
617
|
+
parentNode.insertBefore(oldStartNode, oldEndNode.nextSibling);
|
|
618
|
+
diff(oldStartNode, newEndNode, replayer, rrnodeMirror);
|
|
619
|
+
oldStartNode = oldChildren[++oldStartIndex];
|
|
620
|
+
newEndNode = newChildren[--newEndIndex];
|
|
621
|
+
}
|
|
622
|
+
catch (e) {
|
|
623
|
+
console.error(e, parentNode, oldStartNode, oldEndNode);
|
|
624
|
+
}
|
|
1563
625
|
}
|
|
1564
626
|
else if (replayer.mirror.getId(oldEndNode) === rrnodeMirror.getId(newStartNode)) {
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
627
|
+
try {
|
|
628
|
+
parentNode.insertBefore(oldEndNode, oldStartNode);
|
|
629
|
+
diff(oldEndNode, newStartNode, replayer, rrnodeMirror);
|
|
630
|
+
oldEndNode = oldChildren[--oldEndIndex];
|
|
631
|
+
newStartNode = newChildren[++newStartIndex];
|
|
632
|
+
}
|
|
633
|
+
catch (e) {
|
|
634
|
+
console.error(e, parentNode, oldEndNode, oldStartNode);
|
|
635
|
+
}
|
|
1569
636
|
}
|
|
1570
637
|
else {
|
|
1571
638
|
if (!oldIdToIndex) {
|
|
@@ -1579,21 +646,31 @@ function diffChildren(oldChildren, newChildren, parentNode, replayer, rrnodeMirr
|
|
|
1579
646
|
indexInOld = oldIdToIndex[rrnodeMirror.getId(newStartNode)];
|
|
1580
647
|
if (indexInOld) {
|
|
1581
648
|
const nodeToMove = oldChildren[indexInOld];
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
649
|
+
try {
|
|
650
|
+
parentNode.insertBefore(nodeToMove, oldStartNode);
|
|
651
|
+
diff(nodeToMove, newStartNode, replayer, rrnodeMirror);
|
|
652
|
+
oldChildren[indexInOld] = undefined;
|
|
653
|
+
}
|
|
654
|
+
catch (e) {
|
|
655
|
+
console.error(e, parentNode, nodeToMove, oldStartNode);
|
|
656
|
+
}
|
|
1585
657
|
}
|
|
1586
658
|
else {
|
|
1587
659
|
const newNode = createOrGetNode(newStartNode, replayer.mirror, rrnodeMirror);
|
|
1588
|
-
if (
|
|
1589
|
-
((
|
|
1590
|
-
|
|
1591
|
-
parentNode.removeChild(
|
|
660
|
+
if (parentNode.nodeName === '#document' &&
|
|
661
|
+
((_a = replayer.mirror.getMeta(newNode)) === null || _a === void 0 ? void 0 : _a.type) === rrwebSnapshot.NodeType.Element &&
|
|
662
|
+
parentNode.documentElement) {
|
|
663
|
+
parentNode.removeChild(parentNode.documentElement);
|
|
1592
664
|
oldChildren[oldStartIndex] = undefined;
|
|
1593
665
|
oldStartNode = undefined;
|
|
1594
666
|
}
|
|
1595
|
-
|
|
1596
|
-
|
|
667
|
+
try {
|
|
668
|
+
parentNode.insertBefore(newNode, oldStartNode || null);
|
|
669
|
+
diff(newNode, newStartNode, replayer, rrnodeMirror);
|
|
670
|
+
}
|
|
671
|
+
catch (e) {
|
|
672
|
+
console.error(e, parentNode, newNode, oldStartNode || null);
|
|
673
|
+
}
|
|
1597
674
|
}
|
|
1598
675
|
newStartNode = newChildren[++newStartIndex];
|
|
1599
676
|
}
|
|
@@ -1608,8 +685,13 @@ function diffChildren(oldChildren, newChildren, parentNode, replayer, rrnodeMirr
|
|
|
1608
685
|
});
|
|
1609
686
|
for (; newStartIndex <= newEndIndex; ++newStartIndex) {
|
|
1610
687
|
const newNode = createOrGetNode(newChildren[newStartIndex], replayer.mirror, rrnodeMirror);
|
|
1611
|
-
|
|
1612
|
-
|
|
688
|
+
try {
|
|
689
|
+
parentNode.insertBefore(newNode, referenceNode);
|
|
690
|
+
diff(newNode, newChildren[newStartIndex], replayer, rrnodeMirror);
|
|
691
|
+
}
|
|
692
|
+
catch (e) {
|
|
693
|
+
console.error(e, parentNode, newNode, referenceNode);
|
|
694
|
+
}
|
|
1613
695
|
}
|
|
1614
696
|
}
|
|
1615
697
|
else if (newStartIndex > newEndIndex) {
|
|
@@ -1628,13 +710,13 @@ function createOrGetNode(rrNode, domMirror, rrnodeMirror) {
|
|
|
1628
710
|
if (node !== null)
|
|
1629
711
|
return node;
|
|
1630
712
|
switch (rrNode.RRNodeType) {
|
|
1631
|
-
case NodeType
|
|
713
|
+
case rrwebSnapshot.NodeType.Document:
|
|
1632
714
|
node = new Document();
|
|
1633
715
|
break;
|
|
1634
|
-
case NodeType
|
|
716
|
+
case rrwebSnapshot.NodeType.DocumentType:
|
|
1635
717
|
node = document.implementation.createDocumentType(rrNode.name, rrNode.publicId, rrNode.systemId);
|
|
1636
718
|
break;
|
|
1637
|
-
case NodeType
|
|
719
|
+
case rrwebSnapshot.NodeType.Element: {
|
|
1638
720
|
rrNode.tagName.toLowerCase();
|
|
1639
721
|
if (sn && 'isSVG' in sn && (sn === null || sn === void 0 ? void 0 : sn.isSVG)) {
|
|
1640
722
|
node = document.createElementNS(NAMESPACES['svg'], rrNode.tagName.toLowerCase());
|
|
@@ -1643,13 +725,13 @@ function createOrGetNode(rrNode, domMirror, rrnodeMirror) {
|
|
|
1643
725
|
node = document.createElement(rrNode.tagName);
|
|
1644
726
|
break;
|
|
1645
727
|
}
|
|
1646
|
-
case NodeType
|
|
728
|
+
case rrwebSnapshot.NodeType.Text:
|
|
1647
729
|
node = document.createTextNode(rrNode.data);
|
|
1648
730
|
break;
|
|
1649
|
-
case NodeType
|
|
731
|
+
case rrwebSnapshot.NodeType.Comment:
|
|
1650
732
|
node = document.createComment(rrNode.data);
|
|
1651
733
|
break;
|
|
1652
|
-
case NodeType
|
|
734
|
+
case rrwebSnapshot.NodeType.CDATA:
|
|
1653
735
|
node = document.createCDATASection(rrNode.data);
|
|
1654
736
|
break;
|
|
1655
737
|
}
|
|
@@ -1663,8 +745,7 @@ function getNestedRule$1(rules, position) {
|
|
|
1663
745
|
return rule;
|
|
1664
746
|
}
|
|
1665
747
|
else {
|
|
1666
|
-
return getNestedRule$1(
|
|
1667
|
-
.cssRules, position.slice(2));
|
|
748
|
+
return getNestedRule$1(rule.cssRules[position[1]].cssRules, position.slice(2));
|
|
1668
749
|
}
|
|
1669
750
|
}
|
|
1670
751
|
var StyleRuleType;
|
|
@@ -1883,7 +964,7 @@ function buildFromNode(node, rrdom, domMirror, parentRRNode) {
|
|
|
1883
964
|
}
|
|
1884
965
|
return rrNode;
|
|
1885
966
|
}
|
|
1886
|
-
function buildFromDom(dom, domMirror = createMirror
|
|
967
|
+
function buildFromDom(dom, domMirror = rrwebSnapshot.createMirror(), rrdom = new RRDocument()) {
|
|
1887
968
|
function walk(node, parentRRNode) {
|
|
1888
969
|
const rrNode = buildFromNode(node, rrdom, domMirror, parentRRNode);
|
|
1889
970
|
if (rrNode === null)
|
|
@@ -1961,13 +1042,13 @@ class Mirror {
|
|
|
1961
1042
|
}
|
|
1962
1043
|
function getDefaultSN(node, id) {
|
|
1963
1044
|
switch (node.RRNodeType) {
|
|
1964
|
-
case NodeType
|
|
1045
|
+
case rrwebSnapshot.NodeType.Document:
|
|
1965
1046
|
return {
|
|
1966
1047
|
id,
|
|
1967
1048
|
type: node.RRNodeType,
|
|
1968
1049
|
childNodes: [],
|
|
1969
1050
|
};
|
|
1970
|
-
case NodeType
|
|
1051
|
+
case rrwebSnapshot.NodeType.DocumentType:
|
|
1971
1052
|
const doctype = node;
|
|
1972
1053
|
return {
|
|
1973
1054
|
id,
|
|
@@ -1976,7 +1057,7 @@ function getDefaultSN(node, id) {
|
|
|
1976
1057
|
publicId: doctype.publicId,
|
|
1977
1058
|
systemId: doctype.systemId,
|
|
1978
1059
|
};
|
|
1979
|
-
case NodeType
|
|
1060
|
+
case rrwebSnapshot.NodeType.Element:
|
|
1980
1061
|
return {
|
|
1981
1062
|
id,
|
|
1982
1063
|
type: node.RRNodeType,
|
|
@@ -1984,19 +1065,19 @@ function getDefaultSN(node, id) {
|
|
|
1984
1065
|
attributes: {},
|
|
1985
1066
|
childNodes: [],
|
|
1986
1067
|
};
|
|
1987
|
-
case NodeType
|
|
1068
|
+
case rrwebSnapshot.NodeType.Text:
|
|
1988
1069
|
return {
|
|
1989
1070
|
id,
|
|
1990
1071
|
type: node.RRNodeType,
|
|
1991
1072
|
textContent: node.textContent || '',
|
|
1992
1073
|
};
|
|
1993
|
-
case NodeType
|
|
1074
|
+
case rrwebSnapshot.NodeType.Comment:
|
|
1994
1075
|
return {
|
|
1995
1076
|
id,
|
|
1996
1077
|
type: node.RRNodeType,
|
|
1997
1078
|
textContent: node.textContent || '',
|
|
1998
1079
|
};
|
|
1999
|
-
case NodeType
|
|
1080
|
+
case rrwebSnapshot.NodeType.CDATA:
|
|
2000
1081
|
return {
|
|
2001
1082
|
id,
|
|
2002
1083
|
type: node.RRNodeType,
|
|
@@ -3149,10 +2230,10 @@ class Replayer {
|
|
|
3149
2230
|
this.emitter = mitt();
|
|
3150
2231
|
this.activityIntervals = [];
|
|
3151
2232
|
this.legacy_missingNodeRetryMap = {};
|
|
3152
|
-
this.cache = createCache();
|
|
2233
|
+
this.cache = rrwebSnapshot.createCache();
|
|
3153
2234
|
this.imageMap = new Map();
|
|
3154
2235
|
this.canvasEventMap = new Map();
|
|
3155
|
-
this.mirror = createMirror
|
|
2236
|
+
this.mirror = rrwebSnapshot.createMirror();
|
|
3156
2237
|
this.firstFullSnapshot = null;
|
|
3157
2238
|
this.newDocumentQueue = [];
|
|
3158
2239
|
this.mousePos = null;
|
|
@@ -3494,7 +2575,7 @@ class Replayer {
|
|
|
3494
2575
|
this.iframe.style.pointerEvents = 'none';
|
|
3495
2576
|
}
|
|
3496
2577
|
resetCache() {
|
|
3497
|
-
this.cache = createCache();
|
|
2578
|
+
this.cache = rrwebSnapshot.createCache();
|
|
3498
2579
|
}
|
|
3499
2580
|
setupDom() {
|
|
3500
2581
|
this.wrapper = document.createElement('div');
|
|
@@ -3696,7 +2777,7 @@ class Replayer {
|
|
|
3696
2777
|
}
|
|
3697
2778
|
this.legacy_missingNodeRetryMap = {};
|
|
3698
2779
|
const collected = [];
|
|
3699
|
-
rebuild(event.data.node, {
|
|
2780
|
+
rrwebSnapshot.rebuild(event.data.node, {
|
|
3700
2781
|
doc: this.iframe.contentDocument,
|
|
3701
2782
|
afterAppend: (builtNode) => {
|
|
3702
2783
|
this.collectIframeAndAttachDocument(collected, builtNode);
|
|
@@ -3753,7 +2834,7 @@ class Replayer {
|
|
|
3753
2834
|
? this.virtualDom.mirror
|
|
3754
2835
|
: this.mirror;
|
|
3755
2836
|
const collected = [];
|
|
3756
|
-
buildNodeWithSN(mutation.node, {
|
|
2837
|
+
rrwebSnapshot.buildNodeWithSN(mutation.node, {
|
|
3757
2838
|
doc: iframeEl.contentDocument,
|
|
3758
2839
|
mirror: mirror,
|
|
3759
2840
|
hackCss: true,
|
|
@@ -3761,7 +2842,7 @@ class Replayer {
|
|
|
3761
2842
|
afterAppend: (builtNode) => {
|
|
3762
2843
|
this.collectIframeAndAttachDocument(collected, builtNode);
|
|
3763
2844
|
const sn = mirror.getMeta(builtNode);
|
|
3764
|
-
if ((sn === null || sn === void 0 ? void 0 : sn.type) === NodeType
|
|
2845
|
+
if ((sn === null || sn === void 0 ? void 0 : sn.type) === rrwebSnapshot.NodeType.Element &&
|
|
3765
2846
|
(sn === null || sn === void 0 ? void 0 : sn.tagName.toUpperCase()) === 'HTML') {
|
|
3766
2847
|
const { documentElement, head } = iframeEl.contentDocument;
|
|
3767
2848
|
this.insertStyleRules(documentElement, head);
|
|
@@ -4315,7 +3396,7 @@ class Replayer {
|
|
|
4315
3396
|
}
|
|
4316
3397
|
let parent = mirror.getNode(mutation.parentId);
|
|
4317
3398
|
if (!parent) {
|
|
4318
|
-
if (mutation.node.type === NodeType
|
|
3399
|
+
if (mutation.node.type === rrwebSnapshot.NodeType.Document) {
|
|
4319
3400
|
return this.newDocumentQueue.push(mutation);
|
|
4320
3401
|
}
|
|
4321
3402
|
return queue.push(mutation);
|
|
@@ -4351,7 +3432,7 @@ class Replayer {
|
|
|
4351
3432
|
this.attachDocumentToIframe(mutation, parent);
|
|
4352
3433
|
return;
|
|
4353
3434
|
}
|
|
4354
|
-
const target = buildNodeWithSN(mutation.node, {
|
|
3435
|
+
const target = rrwebSnapshot.buildNodeWithSN(mutation.node, {
|
|
4355
3436
|
doc: targetDoc,
|
|
4356
3437
|
mirror: mirror,
|
|
4357
3438
|
skipChild: true,
|
|
@@ -4367,9 +3448,9 @@ class Replayer {
|
|
|
4367
3448
|
}
|
|
4368
3449
|
const parentSn = mirror.getMeta(parent);
|
|
4369
3450
|
if (parentSn &&
|
|
4370
|
-
parentSn.type === NodeType
|
|
3451
|
+
parentSn.type === rrwebSnapshot.NodeType.Element &&
|
|
4371
3452
|
parentSn.tagName === 'textarea' &&
|
|
4372
|
-
mutation.node.type === NodeType
|
|
3453
|
+
mutation.node.type === rrwebSnapshot.NodeType.Text) {
|
|
4373
3454
|
const childNodeArray = Array.isArray(parent.childNodes)
|
|
4374
3455
|
? parent.childNodes
|
|
4375
3456
|
: Array.from(parent.childNodes);
|
|
@@ -4512,7 +3593,7 @@ class Replayer {
|
|
|
4512
3593
|
behavior: isSync ? 'auto' : 'smooth',
|
|
4513
3594
|
});
|
|
4514
3595
|
}
|
|
4515
|
-
else if ((sn === null || sn === void 0 ? void 0 : sn.type) === NodeType
|
|
3596
|
+
else if ((sn === null || sn === void 0 ? void 0 : sn.type) === rrwebSnapshot.NodeType.Document) {
|
|
4516
3597
|
target.defaultView.scrollTo({
|
|
4517
3598
|
top: d.y,
|
|
4518
3599
|
left: d.x,
|