@highlight-run/rrweb 2.0.20 → 2.1.2

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 (51) hide show
  1. package/dist/plugins/console-record.js +8 -8
  2. package/dist/plugins/console-record.min.js +8 -8
  3. package/dist/plugins/console-record.min.js.map +1 -1
  4. package/dist/plugins/console-replay.min.js.map +1 -1
  5. package/dist/record/rrweb-record-pack.min.js.map +1 -1
  6. package/dist/record/rrweb-record.js +3 -3
  7. package/dist/record/rrweb-record.min.js +3 -3
  8. package/dist/record/rrweb-record.min.js.map +1 -1
  9. package/dist/replay/rrweb-replay-unpack.js +4 -4
  10. package/dist/replay/rrweb-replay-unpack.min.js +4 -4
  11. package/dist/replay/rrweb-replay-unpack.min.js.map +1 -1
  12. package/dist/replay/rrweb-replay.js +4 -4
  13. package/dist/replay/rrweb-replay.min.js +4 -4
  14. package/dist/replay/rrweb-replay.min.js.map +1 -1
  15. package/dist/rrweb-all.js +12 -12
  16. package/dist/rrweb-all.min.js +12 -12
  17. package/dist/rrweb-all.min.js.map +1 -1
  18. package/dist/rrweb.js +5 -5
  19. package/dist/rrweb.min.js +5 -5
  20. package/dist/rrweb.min.js.map +1 -1
  21. package/es/rrweb/ext/mitt/dist/mitt.mjs.js +3 -0
  22. package/es/rrweb/packages/rrdom/es/rrdom.js +66 -10
  23. package/es/rrweb/packages/rrweb/src/plugins/console/record/error-stack-parser.js +3 -11
  24. package/es/rrweb/packages/rrweb/src/plugins/console/record/index.js +10 -7
  25. package/es/rrweb/packages/rrweb/src/plugins/console/record/stringify.js +9 -6
  26. package/es/rrweb/packages/rrweb/src/record/mutation.js +5 -3
  27. package/es/rrweb/packages/rrweb/src/record/observer.js +22 -14
  28. package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js +1 -1
  29. package/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js +7 -4
  30. package/es/rrweb/packages/rrweb/src/replay/canvas/2d.js +3 -2
  31. package/es/rrweb/packages/rrweb/src/replay/canvas/webgl.js +1 -2
  32. package/es/rrweb/packages/rrweb/src/replay/index.js +151 -180
  33. package/es/rrweb/packages/rrweb/src/replay/timer.js +6 -7
  34. package/es/rrweb/packages/rrweb/src/utils.js +8 -6
  35. package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +60 -10
  36. package/lib/plugins/console-record.js +26 -26
  37. package/lib/record/rrweb-record.js +91 -31
  38. package/lib/replay/rrweb-replay-unpack.js +236 -265
  39. package/lib/replay/rrweb-replay.js +236 -265
  40. package/lib/rrweb-all.js +346 -318
  41. package/lib/rrweb.js +324 -294
  42. package/package.json +9 -8
  43. package/typings/plugins/console/record/index.d.ts +1 -1
  44. package/typings/plugins/console/record/stringify.d.ts +1 -1
  45. package/typings/record/observers/canvas/serialize-args.d.ts +5 -5
  46. package/typings/record/shadow-dom-manager.d.ts +1 -1
  47. package/typings/replay/index.d.ts +0 -2
  48. package/typings/types.d.ts +5 -6
  49. package/typings/utils.d.ts +2 -2
  50. package/es/rrweb/ext/mitt/dist/mitt.es.js +0 -63
  51. package/typings/record/observers/canvas/webgl2.d.ts +0 -2
@@ -0,0 +1,3 @@
1
+ function mitt(n){return {all:n=n||new Map,on:function(t,e){var i=n.get(t);i?i.push(e):n.set(t,[e]);},off:function(t,e){var i=n.get(t);i&&(e?i.splice(i.indexOf(e)>>>0,1):n.set(t,[]));},emit:function(t,e){var i=n.get(t);i&&i.slice().map(function(n){n(e);}),(i=n.get("*"))&&i.slice().map(function(n){n(t,e);});}}}
2
+
3
+ export { mitt as default };
@@ -102,7 +102,7 @@ const hyphenate = (str) => {
102
102
  };
103
103
 
104
104
  class BaseRRNode {
105
- constructor(...args) {
105
+ constructor(..._args) {
106
106
  this.childNodes = [];
107
107
  this.parentElement = null;
108
108
  this.parentNode = null;
@@ -138,7 +138,7 @@ class BaseRRNode {
138
138
  insertBefore(_newChild, _refChild) {
139
139
  throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.`);
140
140
  }
141
- removeChild(node) {
141
+ removeChild(_node) {
142
142
  throw new Error(`RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.`);
143
143
  }
144
144
  toString() {
@@ -517,6 +517,44 @@ const NAMESPACES = {
517
517
  'xlink:href': 'http://www.w3.org/1999/xlink',
518
518
  xmlns: 'http://www.w3.org/2000/xmlns/',
519
519
  };
520
+ const SVGTagMap = {
521
+ altglyph: 'altGlyph',
522
+ altglyphdef: 'altGlyphDef',
523
+ altglyphitem: 'altGlyphItem',
524
+ animatecolor: 'animateColor',
525
+ animatemotion: 'animateMotion',
526
+ animatetransform: 'animateTransform',
527
+ clippath: 'clipPath',
528
+ feblend: 'feBlend',
529
+ fecolormatrix: 'feColorMatrix',
530
+ fecomponenttransfer: 'feComponentTransfer',
531
+ fecomposite: 'feComposite',
532
+ feconvolvematrix: 'feConvolveMatrix',
533
+ fediffuselighting: 'feDiffuseLighting',
534
+ fedisplacementmap: 'feDisplacementMap',
535
+ fedistantlight: 'feDistantLight',
536
+ fedropshadow: 'feDropShadow',
537
+ feflood: 'feFlood',
538
+ fefunca: 'feFuncA',
539
+ fefuncb: 'feFuncB',
540
+ fefuncg: 'feFuncG',
541
+ fefuncr: 'feFuncR',
542
+ fegaussianblur: 'feGaussianBlur',
543
+ feimage: 'feImage',
544
+ femerge: 'feMerge',
545
+ femergenode: 'feMergeNode',
546
+ femorphology: 'feMorphology',
547
+ feoffset: 'feOffset',
548
+ fepointlight: 'fePointLight',
549
+ fespecularlighting: 'feSpecularLighting',
550
+ fespotlight: 'feSpotLight',
551
+ fetile: 'feTile',
552
+ feturbulence: 'feTurbulence',
553
+ foreignobject: 'foreignObject',
554
+ glyphref: 'glyphRef',
555
+ lineargradient: 'linearGradient',
556
+ radialgradient: 'radialGradient',
557
+ };
520
558
  function diff(oldTree, newTree, replayer, rrnodeMirror) {
521
559
  const oldChildren = oldTree.childNodes;
522
560
  const newChildren = newTree.childNodes;
@@ -547,8 +585,8 @@ function diff(oldTree, newTree, replayer, rrnodeMirror) {
547
585
  const newMediaRRElement = newRRElement;
548
586
  if (newMediaRRElement.paused !== undefined)
549
587
  newMediaRRElement.paused
550
- ? oldMediaElement.pause()
551
- : oldMediaElement.play();
588
+ ? void oldMediaElement.pause()
589
+ : void oldMediaElement.play();
552
590
  if (newMediaRRElement.muted !== undefined)
553
591
  oldMediaElement.muted = newMediaRRElement.muted;
554
592
  if (newMediaRRElement.volume !== undefined)
@@ -558,7 +596,20 @@ function diff(oldTree, newTree, replayer, rrnodeMirror) {
558
596
  break;
559
597
  }
560
598
  case 'CANVAS':
561
- newTree.canvasMutations.forEach((canvasMutation) => replayer.applyCanvas(canvasMutation.event, canvasMutation.mutation, oldTree));
599
+ {
600
+ const rrCanvasElement = newTree;
601
+ if (rrCanvasElement.rr_dataURL !== null) {
602
+ const image = document.createElement('img');
603
+ image.onload = () => {
604
+ const ctx = oldElement.getContext('2d');
605
+ if (ctx) {
606
+ ctx.drawImage(image, 0, 0, image.width, image.height);
607
+ }
608
+ };
609
+ image.src = rrCanvasElement.rr_dataURL;
610
+ }
611
+ rrCanvasElement.canvasMutations.forEach((canvasMutation) => replayer.applyCanvas(canvasMutation.event, canvasMutation.mutation, oldTree));
612
+ }
562
613
  break;
563
614
  case 'STYLE':
564
615
  applyVirtualStyleRulesToNode(oldElement, newTree.rules);
@@ -736,9 +787,10 @@ function createOrGetNode(rrNode, domMirror, rrnodeMirror) {
736
787
  node = document.implementation.createDocumentType(rrNode.name, rrNode.publicId, rrNode.systemId);
737
788
  break;
738
789
  case NodeType$1.Element: {
739
- rrNode.tagName.toLowerCase();
790
+ let tagName = rrNode.tagName.toLowerCase();
791
+ tagName = SVGTagMap[tagName] || tagName;
740
792
  if (sn && 'isSVG' in sn && (sn === null || sn === void 0 ? void 0 : sn.isSVG)) {
741
- node = document.createElementNS(NAMESPACES['svg'], rrNode.tagName.toLowerCase());
793
+ node = document.createElementNS(NAMESPACES['svg'], tagName);
742
794
  }
743
795
  else
744
796
  node = document.createElement(rrNode.tagName);
@@ -904,6 +956,7 @@ class RRMediaElement extends BaseRRMediaElementImpl(RRElement) {
904
956
  class RRCanvasElement extends RRElement {
905
957
  constructor() {
906
958
  super(...arguments);
959
+ this.rr_dataURL = null;
907
960
  this.canvasMutations = [];
908
961
  }
909
962
  getContext() {
@@ -943,11 +996,12 @@ function buildFromNode(node, rrdom, domMirror, parentRRNode) {
943
996
  rrNode.compatMode = node.compatMode;
944
997
  }
945
998
  break;
946
- case NodeType.DOCUMENT_TYPE_NODE:
999
+ case NodeType.DOCUMENT_TYPE_NODE: {
947
1000
  const documentType = node;
948
1001
  rrNode = rrdom.createDocumentType(documentType.name, documentType.publicId, documentType.systemId);
949
1002
  break;
950
- case NodeType.ELEMENT_NODE:
1003
+ }
1004
+ case NodeType.ELEMENT_NODE: {
951
1005
  const elementNode = node;
952
1006
  const tagName = getValidTagName(elementNode);
953
1007
  rrNode = rrdom.createElement(tagName);
@@ -958,6 +1012,7 @@ function buildFromNode(node, rrdom, domMirror, parentRRNode) {
958
1012
  elementNode.scrollLeft && (rrElement.scrollLeft = elementNode.scrollLeft);
959
1013
  elementNode.scrollTop && (rrElement.scrollTop = elementNode.scrollTop);
960
1014
  break;
1015
+ }
961
1016
  case NodeType.TEXT_NODE:
962
1017
  rrNode = rrdom.createTextNode(node.textContent || '');
963
1018
  break;
@@ -1067,7 +1122,7 @@ function getDefaultSN(node, id) {
1067
1122
  type: node.RRNodeType,
1068
1123
  childNodes: [],
1069
1124
  };
1070
- case NodeType$1.DocumentType:
1125
+ case NodeType$1.DocumentType: {
1071
1126
  const doctype = node;
1072
1127
  return {
1073
1128
  id,
@@ -1076,6 +1131,7 @@ function getDefaultSN(node, id) {
1076
1131
  publicId: doctype.publicId,
1077
1132
  systemId: doctype.systemId,
1078
1133
  };
1134
+ }
1079
1135
  case NodeType$1.Element:
1080
1136
  return {
1081
1137
  id,
@@ -8,17 +8,9 @@ class StackFrame {
8
8
  toString() {
9
9
  const lineNumber = this.lineNumber || '';
10
10
  const columnNumber = this.columnNumber || '';
11
- if (this.functionName) {
12
- return (this.functionName +
13
- ' (' +
14
- this.fileName +
15
- ':' +
16
- lineNumber +
17
- ':' +
18
- columnNumber +
19
- ')');
20
- }
21
- return this.fileName + ':' + lineNumber + ':' + columnNumber;
11
+ if (this.functionName)
12
+ return `${this.functionName} (${this.fileName}:${lineNumber}:${columnNumber})`;
13
+ return `${this.fileName}:${lineNumber}:${columnNumber}`;
22
14
  }
23
15
  }
24
16
  const FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+:\d+/;
@@ -27,10 +27,14 @@ const defaultLogOptions = {
27
27
  lengthThreshold: 1000,
28
28
  logger: 'console',
29
29
  };
30
- function initLogObserver(cb, win, logOptions) {
30
+ function initLogObserver(cb, win, options) {
31
+ const logOptions = (options
32
+ ? Object.assign({}, defaultLogOptions, options)
33
+ : defaultLogOptions);
31
34
  const loggerType = logOptions.logger;
32
35
  if (!loggerType) {
33
- return () => { };
36
+ return () => {
37
+ };
34
38
  }
35
39
  let logger;
36
40
  if (typeof loggerType === 'string') {
@@ -44,7 +48,7 @@ function initLogObserver(cb, win, logOptions) {
44
48
  if (logOptions.level.includes('error')) {
45
49
  if (window) {
46
50
  const errorHandler = (event) => {
47
- const { message, error } = event;
51
+ const message = event.message, error = event.error;
48
52
  const trace = ErrorStackParser.parse(error).map((stackFrame) => stackFrame.toString());
49
53
  const payload = [stringify(message, logOptions.stringifyOptions)];
50
54
  cb({
@@ -68,7 +72,8 @@ function initLogObserver(cb, win, logOptions) {
68
72
  };
69
73
  function replace(_logger, level) {
70
74
  if (!_logger[level]) {
71
- return () => { };
75
+ return () => {
76
+ };
72
77
  }
73
78
  return patch(_logger, level, (original) => {
74
79
  return (...args) => {
@@ -107,9 +112,7 @@ const PLUGIN_NAME = 'rrweb/console@1';
107
112
  const getRecordConsolePlugin = (options) => ({
108
113
  name: PLUGIN_NAME,
109
114
  observer: initLogObserver,
110
- options: options
111
- ? Object.assign({}, defaultLogOptions, options)
112
- : defaultLogOptions,
115
+ options: options,
113
116
  });
114
117
 
115
118
  export { PLUGIN_NAME, getRecordConsolePlugin };
@@ -22,7 +22,7 @@ function pathToSelector(node) {
22
22
  }
23
23
  }
24
24
  if (domSiblings.length > 1) {
25
- name += ':eq(' + domSiblings.indexOf(node) + ')';
25
+ name += `:eq(${domSiblings.indexOf(node)})`;
26
26
  }
27
27
  path = name + (path ? '>' + path : '');
28
28
  node = parent;
@@ -38,7 +38,8 @@ function isObjTooDeep(obj, limit) {
38
38
  }
39
39
  const keys = Object.keys(obj);
40
40
  for (const key of keys) {
41
- if (isObject(obj[key]) && isObjTooDeep(obj[key], limit - 1)) {
41
+ if (isObject(obj[key]) &&
42
+ isObjTooDeep(obj[key], limit - 1)) {
42
43
  return true;
43
44
  }
44
45
  }
@@ -72,9 +73,10 @@ function stringify(obj, stringifyOptions) {
72
73
  else {
73
74
  stack.push(value);
74
75
  }
75
- if (value === null || value === undefined) {
76
+ if (value === null)
76
77
  return value;
77
- }
78
+ if (value === undefined)
79
+ return 'undefined';
78
80
  if (shouldIgnore(value)) {
79
81
  return toString(value);
80
82
  }
@@ -83,7 +85,7 @@ function stringify(obj, stringifyOptions) {
83
85
  for (const eventKey in value) {
84
86
  const eventValue = value[eventKey];
85
87
  if (Array.isArray(eventValue)) {
86
- eventResult[eventKey] = pathToSelector(eventValue.length ? eventValue[0] : null);
88
+ eventResult[eventKey] = pathToSelector((eventValue.length ? eventValue[0] : null));
87
89
  }
88
90
  else {
89
91
  eventResult[eventKey] = eventValue;
@@ -111,7 +113,8 @@ function stringify(obj, stringifyOptions) {
111
113
  if (typeof _obj === 'function') {
112
114
  return true;
113
115
  }
114
- if (isObject(_obj) && isObjTooDeep(_obj, options.depthOfLimit)) {
116
+ if (isObject(_obj) &&
117
+ isObjTooDeep(_obj, options.depthOfLimit)) {
115
118
  return true;
116
119
  }
117
120
  return false;
@@ -1,4 +1,4 @@
1
- import { obfuscateText, isShadowRoot, maskInputValue, transformAttribute, needMaskingText, IGNORED_NODE, serializeNodeWithId } from '../../../rrweb-snapshot/es/rrweb-snapshot.js';
1
+ import { obfuscateText, isShadowRoot, isNativeShadowDom, maskInputValue, transformAttribute, needMaskingText, IGNORED_NODE, serializeNodeWithId } from '../../../rrweb-snapshot/es/rrweb-snapshot.js';
2
2
  import { isIgnored, isBlocked, isSerialized, isAncestorRemoved, isSerializedIframe, isSerializedStylesheet, hasShadowRoot } from '../utils.js';
3
3
 
4
4
  function isNodeInLinkedList(n) {
@@ -140,6 +140,7 @@ class MutationBuffer {
140
140
  maskTextClass: this.maskTextClass,
141
141
  maskTextSelector: this.maskTextSelector,
142
142
  skipChild: true,
143
+ newlyAddedElement: true,
143
144
  inlineStylesheet: this.inlineStylesheet,
144
145
  maskInputOptions: this.maskInputOptions,
145
146
  maskTextFn: this.maskTextFn,
@@ -166,7 +167,6 @@ class MutationBuffer {
166
167
  onStylesheetLoad: (link, childSn) => {
167
168
  this.stylesheetManager.attachStylesheet(link, childSn, this.mirror);
168
169
  },
169
- newlyAddedElement: true,
170
170
  });
171
171
  if (sn) {
172
172
  adds.push({
@@ -392,7 +392,9 @@ class MutationBuffer {
392
392
  this.removes.push({
393
393
  parentId,
394
394
  id: nodeId,
395
- isShadow: isShadowRoot(m.target) ? true : undefined,
395
+ isShadow: isShadowRoot(m.target) && isNativeShadowDom(m.target)
396
+ ? true
397
+ : undefined,
396
398
  });
397
399
  }
398
400
  this.mapRemoves.push(n);
@@ -50,7 +50,8 @@ function initMutationObserver(options, rootEl) {
50
50
  }
51
51
  function initMoveObserver({ mousemoveCb, sampling, doc, mirror, }) {
52
52
  if (sampling.mousemove === false) {
53
- return () => { };
53
+ return () => {
54
+ };
54
55
  }
55
56
  const threshold = typeof sampling.mousemove === 'number' ? sampling.mousemove : 50;
56
57
  const callbackThreshold = typeof sampling.mousemoveCallback === 'number'
@@ -100,7 +101,8 @@ function initMoveObserver({ mousemoveCb, sampling, doc, mirror, }) {
100
101
  }
101
102
  function initMouseInteractionObserver({ mouseInteractionCb, doc, mirror, blockClass, sampling, }) {
102
103
  if (sampling.mouseInteraction === false) {
103
- return () => { };
104
+ return () => {
105
+ };
104
106
  }
105
107
  const disableMap = sampling.mouseInteraction === true ||
106
108
  sampling.mouseInteraction === undefined
@@ -304,7 +306,7 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror }, { win }) {
304
306
  adds: [{ rule, index }],
305
307
  });
306
308
  }
307
- return insertRule.apply(this, arguments);
309
+ return insertRule.apply(this, [rule, index]);
308
310
  };
309
311
  const deleteRule = win.CSSStyleSheet.prototype.deleteRule;
310
312
  win.CSSStyleSheet.prototype.deleteRule = function (index) {
@@ -315,7 +317,7 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror }, { win }) {
315
317
  removes: [{ index }],
316
318
  });
317
319
  }
318
- return deleteRule.apply(this, arguments);
320
+ return deleteRule.apply(this, [index]);
319
321
  };
320
322
  const supportedNestedCSSRuleTypes = {};
321
323
  if (isCSSGroupingRuleSupported) {
@@ -354,17 +356,19 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror }, { win }) {
354
356
  ],
355
357
  });
356
358
  }
357
- return unmodifiedFunctions[typeKey].insertRule.apply(this, arguments);
359
+ return unmodifiedFunctions[typeKey].insertRule.apply(this, [rule, index]);
358
360
  };
359
361
  type.prototype.deleteRule = function (index) {
360
362
  const id = mirror.getId(this.parentStyleSheet.ownerNode);
361
363
  if (id !== -1) {
362
364
  styleSheetRuleCb({
363
365
  id,
364
- removes: [{ index: [...getNestedCSSRulePositions(this), index] }],
366
+ removes: [
367
+ { index: [...getNestedCSSRulePositions(this), index] },
368
+ ],
365
369
  });
366
370
  }
367
- return unmodifiedFunctions[typeKey].deleteRule.apply(this, arguments);
371
+ return unmodifiedFunctions[typeKey].deleteRule.apply(this, [index]);
368
372
  };
369
373
  });
370
374
  return () => {
@@ -392,7 +396,7 @@ function initStyleDeclarationObserver({ styleDeclarationCb, mirror }, { win }) {
392
396
  index: getNestedCSSRulePositions(this.parentRule),
393
397
  });
394
398
  }
395
- return setProperty.apply(this, arguments);
399
+ return setProperty.apply(this, [property, value, priority]);
396
400
  };
397
401
  const removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;
398
402
  win.CSSStyleDeclaration.prototype.removeProperty = function (property) {
@@ -407,7 +411,7 @@ function initStyleDeclarationObserver({ styleDeclarationCb, mirror }, { win }) {
407
411
  index: getNestedCSSRulePositions(this.parentRule),
408
412
  });
409
413
  }
410
- return removeProperty.apply(this, arguments);
414
+ return removeProperty.apply(this, [property]);
411
415
  };
412
416
  return () => {
413
417
  win.CSSStyleDeclaration.prototype.setProperty = setProperty;
@@ -442,7 +446,8 @@ function initMediaInteractionObserver({ mediaInteractionCb, blockClass, mirror,
442
446
  function initFontObserver({ fontCb, doc }) {
443
447
  const win = doc.defaultView;
444
448
  if (!win) {
445
- return () => { };
449
+ return () => {
450
+ };
446
451
  }
447
452
  const handlers = [];
448
453
  const fontMap = new WeakMap();
@@ -455,8 +460,7 @@ function initFontObserver({ fontCb, doc }) {
455
460
  descriptors,
456
461
  fontSource: typeof source === 'string'
457
462
  ? source
458
- :
459
- JSON.stringify(Array.from(new Uint8Array(source))),
463
+ : JSON.stringify(Array.from(new Uint8Array(source))),
460
464
  });
461
465
  return fontFace;
462
466
  };
@@ -552,7 +556,8 @@ function mergeHooks(o, hooks) {
552
556
  function initObservers(o, hooks = {}) {
553
557
  const currentWindow = o.doc.defaultView;
554
558
  if (!currentWindow) {
555
- return () => { };
559
+ return () => {
560
+ };
556
561
  }
557
562
  mergeHooks(o, hooks);
558
563
  const mutationObserver = initMutationObserver(o, o.doc);
@@ -566,7 +571,10 @@ function initObservers(o, hooks = {}) {
566
571
  const styleDeclarationObserver = initStyleDeclarationObserver(o, {
567
572
  win: currentWindow,
568
573
  });
569
- const fontObserver = o.collectFonts ? initFontObserver(o) : () => { };
574
+ const fontObserver = o.collectFonts
575
+ ? initFontObserver(o)
576
+ : () => {
577
+ };
570
578
  const pluginHandlers = [];
571
579
  for (const plugin of o.plugins) {
572
580
  pluginHandlers.push(plugin.observer(plugin.callback, currentWindow, plugin.options));
@@ -11,7 +11,7 @@ class CanvasManager {
11
11
  this.rafStamps = { latestId: 0, invokeId: null };
12
12
  this.frozen = false;
13
13
  this.locked = false;
14
- this.processMutation = function (target, mutation) {
14
+ this.processMutation = (target, mutation) => {
15
15
  const newFrame = this.rafStamps.invokeId &&
16
16
  this.rafStamps.latestId !== this.rafStamps.invokeId;
17
17
  if (newFrame || !this.rafStamps.invokeId)
@@ -1,5 +1,6 @@
1
1
  import { initMutationObserver, initScrollObserver } from './observer.js';
2
2
  import { patch } from '../utils.js';
3
+ import { isNativeShadowDom } from '../../../rrweb-snapshot/es/rrweb-snapshot.js';
3
4
 
4
5
  class ShadowDomManager {
5
6
  constructor(options) {
@@ -10,8 +11,8 @@ class ShadowDomManager {
10
11
  this.mirror = options.mirror;
11
12
  const manager = this;
12
13
  this.restorePatches.push(patch(HTMLElement.prototype, 'attachShadow', function (original) {
13
- return function () {
14
- const shadowRoot = original.apply(this, arguments);
14
+ return function (option) {
15
+ const shadowRoot = original.call(this, option);
15
16
  if (this.shadowRoot)
16
17
  manager.addShadowRoot(this.shadowRoot, this.ownerDocument);
17
18
  return shadowRoot;
@@ -19,6 +20,8 @@ class ShadowDomManager {
19
20
  }));
20
21
  }
21
22
  addShadowRoot(shadowRoot, doc) {
23
+ if (!isNativeShadowDom(shadowRoot))
24
+ return;
22
25
  initMutationObserver(Object.assign(Object.assign({}, this.bypassOptions), { doc, mutationCb: this.mutationCb, mirror: this.mirror, shadowDomManager: this }), shadowRoot);
23
26
  initScrollObserver(Object.assign(Object.assign({}, this.bypassOptions), { scrollCb: this.scrollCb, doc: shadowRoot, mirror: this.mirror }));
24
27
  }
@@ -26,8 +29,8 @@ class ShadowDomManager {
26
29
  if (iframeElement.contentWindow) {
27
30
  const manager = this;
28
31
  this.restorePatches.push(patch(iframeElement.contentWindow.HTMLElement.prototype, 'attachShadow', function (original) {
29
- return function () {
30
- const shadowRoot = original.apply(this, arguments);
32
+ return function (option) {
33
+ const shadowRoot = original.call(this, option);
31
34
  if (this.shadowRoot)
32
35
  manager.addShadowRoot(this.shadowRoot, iframeElement.contentDocument);
33
36
  return shadowRoot;
@@ -6,13 +6,14 @@ function canvasMutation({ event, mutation, target, imageMap, errorHandler, }) {
6
6
  try {
7
7
  const ctx = target.getContext('2d');
8
8
  if (mutation.setter) {
9
- ctx[mutation.property] = mutation.args[0];
9
+ ctx[mutation.property] =
10
+ mutation.args[0];
10
11
  return;
11
12
  }
12
13
  const original = ctx[mutation.property];
13
14
  if (mutation.property === 'drawImage' &&
14
15
  typeof mutation.args[0] === 'string') {
15
- const image = imageMap.get(event);
16
+ imageMap.get(event);
16
17
  original.apply(ctx, mutation.args);
17
18
  }
18
19
  else {
@@ -5,8 +5,7 @@ import { deserializeArg, variableListFor } from './deserialize-args.js';
5
5
  function getContext(target, type) {
6
6
  try {
7
7
  if (type === CanvasContext.WebGL) {
8
- return (target.getContext('webgl') ||
9
- target.getContext('experimental-webgl'));
8
+ return (target.getContext('webgl') || target.getContext('experimental-webgl'));
10
9
  }
11
10
  return target.getContext('webgl2');
12
11
  }