@highlight-run/rrweb 2.0.11 → 2.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/plugins/console-record.js +5 -5
  2. package/dist/plugins/console-record.min.js +5 -5
  3. package/dist/plugins/console-record.min.js.map +1 -1
  4. package/dist/plugins/console-replay.js +3 -3
  5. package/dist/plugins/console-replay.min.js +3 -3
  6. package/dist/plugins/console-replay.min.js.map +1 -1
  7. package/dist/record/rrweb-record-pack.js +2 -2
  8. package/dist/record/rrweb-record-pack.min.js +2 -2
  9. package/dist/record/rrweb-record-pack.min.js.map +1 -1
  10. package/dist/record/rrweb-record.js +3 -3
  11. package/dist/record/rrweb-record.min.js +3 -3
  12. package/dist/record/rrweb-record.min.js.map +1 -1
  13. package/dist/replay/rrweb-replay-unpack.js +4 -3
  14. package/dist/replay/rrweb-replay-unpack.min.js +4 -3
  15. package/dist/replay/rrweb-replay-unpack.min.js.map +1 -1
  16. package/dist/replay/rrweb-replay.js +4 -3
  17. package/dist/replay/rrweb-replay.min.js +4 -3
  18. package/dist/replay/rrweb-replay.min.js.map +1 -1
  19. package/dist/rrweb-all.js +25 -24
  20. package/dist/rrweb-all.min.js +25 -24
  21. package/dist/rrweb-all.min.js.map +1 -1
  22. package/dist/rrweb.js +15 -14
  23. package/dist/rrweb.min.js +15 -14
  24. package/dist/rrweb.min.js.map +1 -1
  25. package/es/rrweb/packages/rrdom/es/{virtual-dom.js → rrdom.js} +86 -49
  26. package/es/rrweb/packages/rrweb/src/index.js +2 -2
  27. package/es/rrweb/packages/rrweb/src/record/index.js +3 -1
  28. package/es/rrweb/packages/rrweb/src/record/mutation.js +13 -2
  29. package/es/rrweb/packages/rrweb/src/record/observer.js +1 -1
  30. package/es/rrweb/packages/rrweb/src/replay/index.js +4 -4
  31. package/es/rrweb/packages/rrweb/src/utils.js +1 -1
  32. package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +1870 -0
  33. package/lib/plugins/console-record.js +9 -1
  34. package/lib/plugins/console-replay.js +9 -1
  35. package/lib/record/rrweb-record-pack.js +9 -3
  36. package/lib/record/rrweb-record.js +1075 -17
  37. package/lib/replay/rrweb-replay-unpack.js +1023 -96
  38. package/lib/replay/rrweb-replay.js +1023 -96
  39. package/lib/rrweb-all.js +2056 -137
  40. package/lib/rrweb.js +2056 -137
  41. package/package.json +5 -5
  42. package/typings/record/mutation.d.ts +1 -0
  43. package/typings/replay/index.d.ts +1 -1
  44. package/typings/types.d.ts +3 -2
  45. package/typings/utils.d.ts +1 -1
@@ -2,8 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var rrwebSnapshot = require('@highlight-run/rrweb-snapshot');
6
-
7
5
  /*! *****************************************************************************
8
6
  Copyright (c) Microsoft Corporation.
9
7
 
@@ -29,6 +27,960 @@ function __awaiter(thisArg, _arguments, P, generator) {
29
27
  });
30
28
  }
31
29
 
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 "".concat(selector, ", ").concat(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, "".concat(PROXY_URL_1, "?url=").concat(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
+ image.setAttribute('rrweb-inline-src', value);
755
+ }
756
+ }
757
+ if (name_1 === 'rr_width') {
758
+ node_1.style.width = value;
759
+ }
760
+ else if (name_1 === 'rr_height') {
761
+ node_1.style.height = value;
762
+ }
763
+ else if (name_1 === 'rr_mediaCurrentTime') {
764
+ node_1.currentTime = n.attributes
765
+ .rr_mediaCurrentTime;
766
+ }
767
+ else if (name_1 === 'rr_mediaState') {
768
+ switch (value) {
769
+ case 'played':
770
+ node_1
771
+ .play()["catch"](function (e) { return console.warn('media playback error', e); });
772
+ break;
773
+ case 'paused':
774
+ node_1.pause();
775
+ break;
776
+ }
777
+ }
778
+ }
779
+ };
780
+ for (var name_1 in n.attributes) {
781
+ _loop_1(name_1);
782
+ }
783
+ if (tagName === 'img') {
784
+ var image = node_1;
785
+ if (!image.currentSrc.startsWith('data:')) {
786
+ var inlineSrc = image.getAttribute('rrweb-inline-src');
787
+ if (inlineSrc === null || inlineSrc === void 0 ? void 0 : inlineSrc.startsWith('data:')) {
788
+ image.src = inlineSrc;
789
+ }
790
+ }
791
+ }
792
+ if (n.isShadowHost) {
793
+ if (!node_1.shadowRoot) {
794
+ node_1.attachShadow({ mode: 'open' });
795
+ }
796
+ else {
797
+ while (node_1.shadowRoot.firstChild) {
798
+ node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);
799
+ }
800
+ }
801
+ }
802
+ return node_1;
803
+ case NodeType$2.Text:
804
+ return doc.createTextNode(n.isStyle && hackCss
805
+ ? addHoverClass(n.textContent, cache)
806
+ : n.textContent);
807
+ case NodeType$2.CDATA:
808
+ return doc.createCDATASection(n.textContent);
809
+ case NodeType$2.Comment:
810
+ return doc.createComment(n.textContent);
811
+ default:
812
+ return null;
813
+ }
814
+ }
815
+ function buildNodeWithSN(n, options) {
816
+ 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;
817
+ var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });
818
+ if (!node) {
819
+ return null;
820
+ }
821
+ if (n.rootId) {
822
+ console.assert(mirror.getNode(n.rootId) === doc, 'Target document should have the same root id.');
823
+ }
824
+ if (n.type === NodeType$2.Document) {
825
+ doc.close();
826
+ doc.open();
827
+ if (n.compatMode === 'BackCompat' &&
828
+ n.childNodes &&
829
+ n.childNodes[0].type !== NodeType$2.DocumentType) {
830
+ if (n.childNodes[0].type === NodeType$2.Element &&
831
+ 'xmlns' in n.childNodes[0].attributes &&
832
+ n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {
833
+ doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">');
834
+ }
835
+ else {
836
+ doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">');
837
+ }
838
+ }
839
+ node = doc;
840
+ }
841
+ mirror.add(node, n);
842
+ if ((n.type === NodeType$2.Document || n.type === NodeType$2.Element) &&
843
+ !skipChild) {
844
+ for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {
845
+ var childN = _c[_i];
846
+ var childNode = buildNodeWithSN(childN, {
847
+ doc: doc,
848
+ mirror: mirror,
849
+ skipChild: false,
850
+ hackCss: hackCss,
851
+ afterAppend: afterAppend,
852
+ cache: cache
853
+ });
854
+ if (!childNode) {
855
+ console.warn('Failed to rebuild', childN);
856
+ continue;
857
+ }
858
+ if (childN.isShadow && isElement(node) && node.shadowRoot) {
859
+ node.shadowRoot.appendChild(childNode);
860
+ }
861
+ else {
862
+ node.appendChild(childNode);
863
+ }
864
+ if (afterAppend) {
865
+ afterAppend(childNode);
866
+ }
867
+ }
868
+ }
869
+ return node;
870
+ }
871
+ function visit(mirror, onVisit) {
872
+ function walk(node) {
873
+ onVisit(node);
874
+ }
875
+ for (var _i = 0, _a = mirror.getIds(); _i < _a.length; _i++) {
876
+ var id = _a[_i];
877
+ if (mirror.has(id)) {
878
+ walk(mirror.getNode(id));
879
+ }
880
+ }
881
+ }
882
+ function handleScroll(node, mirror) {
883
+ var n = mirror.getMeta(node);
884
+ if ((n === null || n === void 0 ? void 0 : n.type) !== NodeType$2.Element) {
885
+ return;
886
+ }
887
+ var el = node;
888
+ for (var name_2 in n.attributes) {
889
+ if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {
890
+ continue;
891
+ }
892
+ var value = n.attributes[name_2];
893
+ if (name_2 === 'rr_scrollLeft') {
894
+ el.scrollLeft = value;
895
+ }
896
+ if (name_2 === 'rr_scrollTop') {
897
+ el.scrollTop = value;
898
+ }
899
+ }
900
+ }
901
+ function rebuild(n, options) {
902
+ 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;
903
+ var node = buildNodeWithSN(n, {
904
+ doc: doc,
905
+ mirror: mirror,
906
+ skipChild: false,
907
+ hackCss: hackCss,
908
+ afterAppend: afterAppend,
909
+ cache: cache
910
+ });
911
+ visit(mirror, function (visitedNode) {
912
+ if (onVisit) {
913
+ onVisit(visitedNode);
914
+ }
915
+ handleScroll(visitedNode, mirror);
916
+ });
917
+ return node;
918
+ }
919
+
920
+ var NodeType$1;
921
+ (function (NodeType) {
922
+ NodeType[NodeType["Document"] = 0] = "Document";
923
+ NodeType[NodeType["DocumentType"] = 1] = "DocumentType";
924
+ NodeType[NodeType["Element"] = 2] = "Element";
925
+ NodeType[NodeType["Text"] = 3] = "Text";
926
+ NodeType[NodeType["CDATA"] = 4] = "CDATA";
927
+ NodeType[NodeType["Comment"] = 5] = "Comment";
928
+ })(NodeType$1 || (NodeType$1 = {}));
929
+ var Mirror$1 = (function () {
930
+ function Mirror() {
931
+ this.idNodeMap = new Map();
932
+ this.nodeMetaMap = new WeakMap();
933
+ }
934
+ Mirror.prototype.getId = function (n) {
935
+ var _a;
936
+ if (!n)
937
+ return -1;
938
+ var id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id;
939
+ return id !== null && id !== void 0 ? id : -1;
940
+ };
941
+ Mirror.prototype.getNode = function (id) {
942
+ return this.idNodeMap.get(id) || null;
943
+ };
944
+ Mirror.prototype.getIds = function () {
945
+ return Array.from(this.idNodeMap.keys());
946
+ };
947
+ Mirror.prototype.getMeta = function (n) {
948
+ return this.nodeMetaMap.get(n) || null;
949
+ };
950
+ Mirror.prototype.removeNodeFromMap = function (n) {
951
+ var _this = this;
952
+ var id = this.getId(n);
953
+ this.idNodeMap["delete"](id);
954
+ if (n.childNodes) {
955
+ n.childNodes.forEach(function (childNode) {
956
+ return _this.removeNodeFromMap(childNode);
957
+ });
958
+ }
959
+ };
960
+ Mirror.prototype.has = function (id) {
961
+ return this.idNodeMap.has(id);
962
+ };
963
+ Mirror.prototype.hasNode = function (node) {
964
+ return this.nodeMetaMap.has(node);
965
+ };
966
+ Mirror.prototype.add = function (n, meta) {
967
+ var id = meta.id;
968
+ this.idNodeMap.set(id, n);
969
+ this.nodeMetaMap.set(n, meta);
970
+ };
971
+ Mirror.prototype.replace = function (id, n) {
972
+ this.idNodeMap.set(id, n);
973
+ };
974
+ Mirror.prototype.reset = function () {
975
+ this.idNodeMap = new Map();
976
+ this.nodeMetaMap = new WeakMap();
977
+ };
978
+ return Mirror;
979
+ }());
980
+ function createMirror$1() {
981
+ return new Mirror$1();
982
+ }
983
+
32
984
  function parseCSSText(cssText) {
33
985
  const res = {};
34
986
  const listDelimiter = /;(?![^(]*\))/g;
@@ -119,21 +1071,21 @@ function BaseRRDocumentImpl(RRNodeClass) {
119
1071
  this.nodeType = NodeType.DOCUMENT_NODE;
120
1072
  this.nodeName = '#document';
121
1073
  this.compatMode = 'CSS1Compat';
122
- this.RRNodeType = rrwebSnapshot.NodeType.Document;
1074
+ this.RRNodeType = NodeType$1.Document;
123
1075
  this.textContent = null;
124
1076
  }
125
1077
  get documentElement() {
126
- return (this.childNodes.find((node) => node.RRNodeType === rrwebSnapshot.NodeType.Element &&
1078
+ return (this.childNodes.find((node) => node.RRNodeType === NodeType$1.Element &&
127
1079
  node.tagName === 'HTML') || null);
128
1080
  }
129
1081
  get body() {
130
1082
  var _a;
131
- return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === rrwebSnapshot.NodeType.Element &&
1083
+ return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === NodeType$1.Element &&
132
1084
  node.tagName === 'BODY')) || null);
133
1085
  }
134
1086
  get head() {
135
1087
  var _a;
136
- return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === rrwebSnapshot.NodeType.Element &&
1088
+ return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === NodeType$1.Element &&
137
1089
  node.tagName === 'HEAD')) || null);
138
1090
  }
139
1091
  get implementation() {
@@ -144,10 +1096,10 @@ function BaseRRDocumentImpl(RRNodeClass) {
144
1096
  }
145
1097
  appendChild(childNode) {
146
1098
  const nodeType = childNode.RRNodeType;
147
- if (nodeType === rrwebSnapshot.NodeType.Element ||
148
- nodeType === rrwebSnapshot.NodeType.DocumentType) {
1099
+ if (nodeType === NodeType$1.Element ||
1100
+ nodeType === NodeType$1.DocumentType) {
149
1101
  if (this.childNodes.some((s) => s.RRNodeType === nodeType)) {
150
- throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${nodeType === rrwebSnapshot.NodeType.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`);
1102
+ throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`);
151
1103
  }
152
1104
  }
153
1105
  childNode.parentElement = null;
@@ -157,10 +1109,10 @@ function BaseRRDocumentImpl(RRNodeClass) {
157
1109
  }
158
1110
  insertBefore(newChild, refChild) {
159
1111
  const nodeType = newChild.RRNodeType;
160
- if (nodeType === rrwebSnapshot.NodeType.Element ||
161
- nodeType === rrwebSnapshot.NodeType.DocumentType) {
1112
+ if (nodeType === NodeType$1.Element ||
1113
+ nodeType === NodeType$1.DocumentType) {
162
1114
  if (this.childNodes.some((s) => s.RRNodeType === nodeType)) {
163
- throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${nodeType === rrwebSnapshot.NodeType.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`);
1115
+ throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`);
164
1116
  }
165
1117
  }
166
1118
  if (refChild === null)
@@ -242,7 +1194,7 @@ function BaseRRDocumentTypeImpl(RRNodeClass) {
242
1194
  constructor(qualifiedName, publicId, systemId) {
243
1195
  super();
244
1196
  this.nodeType = NodeType.DOCUMENT_TYPE_NODE;
245
- this.RRNodeType = rrwebSnapshot.NodeType.DocumentType;
1197
+ this.RRNodeType = NodeType$1.DocumentType;
246
1198
  this.textContent = null;
247
1199
  this.name = qualifiedName;
248
1200
  this.publicId = publicId;
@@ -259,7 +1211,7 @@ function BaseRRElementImpl(RRNodeClass) {
259
1211
  constructor(tagName) {
260
1212
  super();
261
1213
  this.nodeType = NodeType.ELEMENT_NODE;
262
- this.RRNodeType = rrwebSnapshot.NodeType.Element;
1214
+ this.RRNodeType = NodeType$1.Element;
263
1215
  this.attributes = {};
264
1216
  this.shadowRoot = null;
265
1217
  this.tagName = tagName.toUpperCase();
@@ -386,7 +1338,7 @@ function BaseRRTextImpl(RRNodeClass) {
386
1338
  super();
387
1339
  this.nodeType = NodeType.TEXT_NODE;
388
1340
  this.nodeName = '#text';
389
- this.RRNodeType = rrwebSnapshot.NodeType.Text;
1341
+ this.RRNodeType = NodeType$1.Text;
390
1342
  this.data = data;
391
1343
  }
392
1344
  get textContent() {
@@ -406,7 +1358,7 @@ function BaseRRCommentImpl(RRNodeClass) {
406
1358
  super();
407
1359
  this.nodeType = NodeType.COMMENT_NODE;
408
1360
  this.nodeName = '#comment';
409
- this.RRNodeType = rrwebSnapshot.NodeType.Comment;
1361
+ this.RRNodeType = NodeType$1.Comment;
410
1362
  this.data = data;
411
1363
  }
412
1364
  get textContent() {
@@ -426,7 +1378,7 @@ function BaseRRCDATASectionImpl(RRNodeClass) {
426
1378
  super();
427
1379
  this.nodeName = '#cdata-section';
428
1380
  this.nodeType = NodeType.CDATA_SECTION_NODE;
429
- this.RRNodeType = rrwebSnapshot.NodeType.CDATA;
1381
+ this.RRNodeType = NodeType$1.CDATA;
430
1382
  this.data = data;
431
1383
  }
432
1384
  get textContent() {
@@ -496,12 +1448,12 @@ function diff(oldTree, newTree, replayer, rrnodeMirror) {
496
1448
  }
497
1449
  let inputDataToApply = null, scrollDataToApply = null;
498
1450
  switch (newTree.RRNodeType) {
499
- case rrwebSnapshot.NodeType.Document: {
1451
+ case NodeType$1.Document: {
500
1452
  const newRRDocument = newTree;
501
1453
  scrollDataToApply = newRRDocument.scrollData;
502
1454
  break;
503
1455
  }
504
- case rrwebSnapshot.NodeType.Element: {
1456
+ case NodeType$1.Element: {
505
1457
  const oldElement = oldTree;
506
1458
  const newRRElement = newTree;
507
1459
  diffProps(oldElement, newRRElement, rrnodeMirror);
@@ -541,9 +1493,9 @@ function diff(oldTree, newTree, replayer, rrnodeMirror) {
541
1493
  }
542
1494
  break;
543
1495
  }
544
- case rrwebSnapshot.NodeType.Text:
545
- case rrwebSnapshot.NodeType.Comment:
546
- case rrwebSnapshot.NodeType.CDATA:
1496
+ case NodeType$1.Text:
1497
+ case NodeType$1.Comment:
1498
+ case NodeType$1.CDATA:
547
1499
  if (oldTree.textContent !==
548
1500
  newTree.data)
549
1501
  oldTree.textContent = newTree.data;
@@ -613,26 +1565,16 @@ function diffChildren(oldChildren, newChildren, parentNode, replayer, rrnodeMirr
613
1565
  newEndNode = newChildren[--newEndIndex];
614
1566
  }
615
1567
  else if (replayer.mirror.getId(oldStartNode) === rrnodeMirror.getId(newEndNode)) {
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
- }
1568
+ parentNode.insertBefore(oldStartNode, oldEndNode.nextSibling);
1569
+ diff(oldStartNode, newEndNode, replayer, rrnodeMirror);
1570
+ oldStartNode = oldChildren[++oldStartIndex];
1571
+ newEndNode = newChildren[--newEndIndex];
625
1572
  }
626
1573
  else if (replayer.mirror.getId(oldEndNode) === rrnodeMirror.getId(newStartNode)) {
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
- }
1574
+ parentNode.insertBefore(oldEndNode, oldStartNode);
1575
+ diff(oldEndNode, newStartNode, replayer, rrnodeMirror);
1576
+ oldEndNode = oldChildren[--oldEndIndex];
1577
+ newStartNode = newChildren[++newStartIndex];
636
1578
  }
637
1579
  else {
638
1580
  if (!oldIdToIndex) {
@@ -646,31 +1588,21 @@ function diffChildren(oldChildren, newChildren, parentNode, replayer, rrnodeMirr
646
1588
  indexInOld = oldIdToIndex[rrnodeMirror.getId(newStartNode)];
647
1589
  if (indexInOld) {
648
1590
  const nodeToMove = oldChildren[indexInOld];
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
- }
1591
+ parentNode.insertBefore(nodeToMove, oldStartNode);
1592
+ diff(nodeToMove, newStartNode, replayer, rrnodeMirror);
1593
+ oldChildren[indexInOld] = undefined;
657
1594
  }
658
1595
  else {
659
1596
  const newNode = createOrGetNode(newStartNode, replayer.mirror, rrnodeMirror);
660
1597
  if (parentNode.nodeName === '#document' &&
661
- ((_a = replayer.mirror.getMeta(newNode)) === null || _a === void 0 ? void 0 : _a.type) === rrwebSnapshot.NodeType.Element &&
1598
+ ((_a = replayer.mirror.getMeta(newNode)) === null || _a === void 0 ? void 0 : _a.type) === NodeType$1.Element &&
662
1599
  parentNode.documentElement) {
663
1600
  parentNode.removeChild(parentNode.documentElement);
664
1601
  oldChildren[oldStartIndex] = undefined;
665
1602
  oldStartNode = undefined;
666
1603
  }
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
- }
1604
+ parentNode.insertBefore(newNode, oldStartNode || null);
1605
+ diff(newNode, newStartNode, replayer, rrnodeMirror);
674
1606
  }
675
1607
  newStartNode = newChildren[++newStartIndex];
676
1608
  }
@@ -685,13 +1617,8 @@ function diffChildren(oldChildren, newChildren, parentNode, replayer, rrnodeMirr
685
1617
  });
686
1618
  for (; newStartIndex <= newEndIndex; ++newStartIndex) {
687
1619
  const newNode = createOrGetNode(newChildren[newStartIndex], replayer.mirror, rrnodeMirror);
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
- }
1620
+ parentNode.insertBefore(newNode, referenceNode);
1621
+ diff(newNode, newChildren[newStartIndex], replayer, rrnodeMirror);
695
1622
  }
696
1623
  }
697
1624
  else if (newStartIndex > newEndIndex) {
@@ -710,13 +1637,13 @@ function createOrGetNode(rrNode, domMirror, rrnodeMirror) {
710
1637
  if (node !== null)
711
1638
  return node;
712
1639
  switch (rrNode.RRNodeType) {
713
- case rrwebSnapshot.NodeType.Document:
1640
+ case NodeType$1.Document:
714
1641
  node = new Document();
715
1642
  break;
716
- case rrwebSnapshot.NodeType.DocumentType:
1643
+ case NodeType$1.DocumentType:
717
1644
  node = document.implementation.createDocumentType(rrNode.name, rrNode.publicId, rrNode.systemId);
718
1645
  break;
719
- case rrwebSnapshot.NodeType.Element: {
1646
+ case NodeType$1.Element: {
720
1647
  rrNode.tagName.toLowerCase();
721
1648
  if (sn && 'isSVG' in sn && (sn === null || sn === void 0 ? void 0 : sn.isSVG)) {
722
1649
  node = document.createElementNS(NAMESPACES['svg'], rrNode.tagName.toLowerCase());
@@ -725,13 +1652,13 @@ function createOrGetNode(rrNode, domMirror, rrnodeMirror) {
725
1652
  node = document.createElement(rrNode.tagName);
726
1653
  break;
727
1654
  }
728
- case rrwebSnapshot.NodeType.Text:
1655
+ case NodeType$1.Text:
729
1656
  node = document.createTextNode(rrNode.data);
730
1657
  break;
731
- case rrwebSnapshot.NodeType.Comment:
1658
+ case NodeType$1.Comment:
732
1659
  node = document.createComment(rrNode.data);
733
1660
  break;
734
- case rrwebSnapshot.NodeType.CDATA:
1661
+ case NodeType$1.CDATA:
735
1662
  node = document.createCDATASection(rrNode.data);
736
1663
  break;
737
1664
  }
@@ -925,11 +1852,11 @@ function buildFromNode(node, rrdom, domMirror, parentRRNode) {
925
1852
  }
926
1853
  break;
927
1854
  case NodeType.DOCUMENT_TYPE_NODE:
928
- const documentType = (node);
1855
+ const documentType = node;
929
1856
  rrNode = rrdom.createDocumentType(documentType.name, documentType.publicId, documentType.systemId);
930
1857
  break;
931
1858
  case NodeType.ELEMENT_NODE:
932
- const elementNode = (node);
1859
+ const elementNode = node;
933
1860
  const tagName = getValidTagName(elementNode);
934
1861
  rrNode = rrdom.createElement(tagName);
935
1862
  const rrElement = rrNode;
@@ -940,13 +1867,13 @@ function buildFromNode(node, rrdom, domMirror, parentRRNode) {
940
1867
  elementNode.scrollTop && (rrElement.scrollTop = elementNode.scrollTop);
941
1868
  break;
942
1869
  case NodeType.TEXT_NODE:
943
- rrNode = rrdom.createTextNode((node).textContent || '');
1870
+ rrNode = rrdom.createTextNode(node.textContent || '');
944
1871
  break;
945
1872
  case NodeType.CDATA_SECTION_NODE:
946
- rrNode = rrdom.createCDATASection((node).data);
1873
+ rrNode = rrdom.createCDATASection(node.data);
947
1874
  break;
948
1875
  case NodeType.COMMENT_NODE:
949
- rrNode = rrdom.createComment((node).textContent || '');
1876
+ rrNode = rrdom.createComment(node.textContent || '');
950
1877
  break;
951
1878
  case NodeType.DOCUMENT_FRAGMENT_NODE:
952
1879
  rrNode = parentRRNode.attachShadow({ mode: 'open' });
@@ -964,7 +1891,7 @@ function buildFromNode(node, rrdom, domMirror, parentRRNode) {
964
1891
  }
965
1892
  return rrNode;
966
1893
  }
967
- function buildFromDom(dom, domMirror = rrwebSnapshot.createMirror(), rrdom = new RRDocument()) {
1894
+ function buildFromDom(dom, domMirror = createMirror$1(), rrdom = new RRDocument()) {
968
1895
  function walk(node, parentRRNode) {
969
1896
  const rrNode = buildFromNode(node, rrdom, domMirror, parentRRNode);
970
1897
  if (rrNode === null)
@@ -982,8 +1909,8 @@ function buildFromDom(dom, domMirror = rrwebSnapshot.createMirror(), rrdom = new
982
1909
  node.nodeType === NodeType.ELEMENT_NODE ||
983
1910
  node.nodeType === NodeType.DOCUMENT_FRAGMENT_NODE) {
984
1911
  if (node.nodeType === NodeType.ELEMENT_NODE &&
985
- (node).shadowRoot)
986
- walk((node).shadowRoot, rrNode);
1912
+ node.shadowRoot)
1913
+ walk(node.shadowRoot, rrNode);
987
1914
  node.childNodes.forEach((childNode) => walk(childNode, rrNode));
988
1915
  }
989
1916
  }
@@ -1042,13 +1969,13 @@ class Mirror {
1042
1969
  }
1043
1970
  function getDefaultSN(node, id) {
1044
1971
  switch (node.RRNodeType) {
1045
- case rrwebSnapshot.NodeType.Document:
1972
+ case NodeType$1.Document:
1046
1973
  return {
1047
1974
  id,
1048
1975
  type: node.RRNodeType,
1049
1976
  childNodes: [],
1050
1977
  };
1051
- case rrwebSnapshot.NodeType.DocumentType:
1978
+ case NodeType$1.DocumentType:
1052
1979
  const doctype = node;
1053
1980
  return {
1054
1981
  id,
@@ -1057,7 +1984,7 @@ function getDefaultSN(node, id) {
1057
1984
  publicId: doctype.publicId,
1058
1985
  systemId: doctype.systemId,
1059
1986
  };
1060
- case rrwebSnapshot.NodeType.Element:
1987
+ case NodeType$1.Element:
1061
1988
  return {
1062
1989
  id,
1063
1990
  type: node.RRNodeType,
@@ -1065,19 +1992,19 @@ function getDefaultSN(node, id) {
1065
1992
  attributes: {},
1066
1993
  childNodes: [],
1067
1994
  };
1068
- case rrwebSnapshot.NodeType.Text:
1995
+ case NodeType$1.Text:
1069
1996
  return {
1070
1997
  id,
1071
1998
  type: node.RRNodeType,
1072
1999
  textContent: node.textContent || '',
1073
2000
  };
1074
- case rrwebSnapshot.NodeType.Comment:
2001
+ case NodeType$1.Comment:
1075
2002
  return {
1076
2003
  id,
1077
2004
  type: node.RRNodeType,
1078
2005
  textContent: node.textContent || '',
1079
2006
  };
1080
- case rrwebSnapshot.NodeType.CDATA:
2007
+ case NodeType$1.CDATA:
1081
2008
  return {
1082
2009
  id,
1083
2010
  type: node.RRNodeType,
@@ -2230,10 +3157,10 @@ class Replayer {
2230
3157
  this.emitter = mitt();
2231
3158
  this.activityIntervals = [];
2232
3159
  this.legacy_missingNodeRetryMap = {};
2233
- this.cache = rrwebSnapshot.createCache();
3160
+ this.cache = createCache();
2234
3161
  this.imageMap = new Map();
2235
3162
  this.canvasEventMap = new Map();
2236
- this.mirror = rrwebSnapshot.createMirror();
3163
+ this.mirror = createMirror$2();
2237
3164
  this.firstFullSnapshot = null;
2238
3165
  this.newDocumentQueue = [];
2239
3166
  this.mousePos = null;
@@ -2575,7 +3502,7 @@ class Replayer {
2575
3502
  this.iframe.style.pointerEvents = 'none';
2576
3503
  }
2577
3504
  resetCache() {
2578
- this.cache = rrwebSnapshot.createCache();
3505
+ this.cache = createCache();
2579
3506
  }
2580
3507
  setupDom() {
2581
3508
  this.wrapper = document.createElement('div');
@@ -2777,7 +3704,7 @@ class Replayer {
2777
3704
  }
2778
3705
  this.legacy_missingNodeRetryMap = {};
2779
3706
  const collected = [];
2780
- rrwebSnapshot.rebuild(event.data.node, {
3707
+ rebuild(event.data.node, {
2781
3708
  doc: this.iframe.contentDocument,
2782
3709
  afterAppend: (builtNode) => {
2783
3710
  this.collectIframeAndAttachDocument(collected, builtNode);
@@ -2825,7 +3752,7 @@ class Replayer {
2825
3752
  const styleEl = document.createElement('style');
2826
3753
  documentElement.insertBefore(styleEl, head);
2827
3754
  for (let idx = 0; idx < injectStylesRules.length; idx++) {
2828
- (styleEl.sheet).insertRule(injectStylesRules[idx], idx);
3755
+ styleEl.sheet.insertRule(injectStylesRules[idx], idx);
2829
3756
  }
2830
3757
  }
2831
3758
  }
@@ -2834,7 +3761,7 @@ class Replayer {
2834
3761
  ? this.virtualDom.mirror
2835
3762
  : this.mirror;
2836
3763
  const collected = [];
2837
- rrwebSnapshot.buildNodeWithSN(mutation.node, {
3764
+ buildNodeWithSN(mutation.node, {
2838
3765
  doc: iframeEl.contentDocument,
2839
3766
  mirror: mirror,
2840
3767
  hackCss: true,
@@ -2842,7 +3769,7 @@ class Replayer {
2842
3769
  afterAppend: (builtNode) => {
2843
3770
  this.collectIframeAndAttachDocument(collected, builtNode);
2844
3771
  const sn = mirror.getMeta(builtNode);
2845
- if ((sn === null || sn === void 0 ? void 0 : sn.type) === rrwebSnapshot.NodeType.Element &&
3772
+ if ((sn === null || sn === void 0 ? void 0 : sn.type) === NodeType$2.Element &&
2846
3773
  (sn === null || sn === void 0 ? void 0 : sn.tagName.toUpperCase()) === 'HTML') {
2847
3774
  const { documentElement, head } = iframeEl.contentDocument;
2848
3775
  this.insertStyleRules(documentElement, head);
@@ -3210,7 +4137,7 @@ class Replayer {
3210
4137
  if (!target) {
3211
4138
  return this.debugNodeNotFound(d, d.id);
3212
4139
  }
3213
- const styleSheet = (target).sheet;
4140
+ const styleSheet = target.sheet;
3214
4141
  (_d = d.adds) === null || _d === void 0 ? void 0 : _d.forEach(({ rule, index: nestedIndex }) => {
3215
4142
  try {
3216
4143
  if (Array.isArray(nestedIndex)) {
@@ -3396,7 +4323,7 @@ class Replayer {
3396
4323
  }
3397
4324
  let parent = mirror.getNode(mutation.parentId);
3398
4325
  if (!parent) {
3399
- if (mutation.node.type === rrwebSnapshot.NodeType.Document) {
4326
+ if (mutation.node.type === NodeType$2.Document) {
3400
4327
  return this.newDocumentQueue.push(mutation);
3401
4328
  }
3402
4329
  return queue.push(mutation);
@@ -3432,7 +4359,7 @@ class Replayer {
3432
4359
  this.attachDocumentToIframe(mutation, parent);
3433
4360
  return;
3434
4361
  }
3435
- const target = rrwebSnapshot.buildNodeWithSN(mutation.node, {
4362
+ const target = buildNodeWithSN(mutation.node, {
3436
4363
  doc: targetDoc,
3437
4364
  mirror: mirror,
3438
4365
  skipChild: true,
@@ -3448,9 +4375,9 @@ class Replayer {
3448
4375
  }
3449
4376
  const parentSn = mirror.getMeta(parent);
3450
4377
  if (parentSn &&
3451
- parentSn.type === rrwebSnapshot.NodeType.Element &&
4378
+ parentSn.type === NodeType$2.Element &&
3452
4379
  parentSn.tagName === 'textarea' &&
3453
- mutation.node.type === rrwebSnapshot.NodeType.Text) {
4380
+ mutation.node.type === NodeType$2.Text) {
3454
4381
  const childNodeArray = Array.isArray(parent.childNodes)
3455
4382
  ? parent.childNodes
3456
4383
  : Array.from(parent.childNodes);
@@ -3593,7 +4520,7 @@ class Replayer {
3593
4520
  behavior: isSync ? 'auto' : 'smooth',
3594
4521
  });
3595
4522
  }
3596
- else if ((sn === null || sn === void 0 ? void 0 : sn.type) === rrwebSnapshot.NodeType.Document) {
4523
+ else if ((sn === null || sn === void 0 ? void 0 : sn.type) === NodeType$2.Document) {
3597
4524
  target.defaultView.scrollTo({
3598
4525
  top: d.y,
3599
4526
  left: d.x,