@sentry/rrweb-player 2.45.0 → 2.46.0

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/global.css CHANGED
@@ -7,6 +7,7 @@ body {
7
7
 
8
8
  body {
9
9
  box-sizing: border-box;
10
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
11
- Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
10
+ font-family:
11
+ -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu,
12
+ Cantarell, 'Helvetica Neue', sans-serif;
12
13
  }
@@ -4694,9 +4694,7 @@ class Mirror {
4694
4694
  const id = this.getId(n2);
4695
4695
  this.idNodeMap.delete(id);
4696
4696
  if (n2.childNodes) {
4697
- n2.childNodes.forEach(
4698
- (childNode) => this.removeNodeFromMap(childNode)
4699
- );
4697
+ n2.childNodes.forEach((childNode) => this.removeNodeFromMap(childNode));
4700
4698
  }
4701
4699
  if (isElement$1(n2) && n2.shadowRoot) {
4702
4700
  this.removeNodeFromMap(n2.shadowRoot);
@@ -5506,6 +5504,9 @@ function buildNodeWithSN(n2, options) {
5506
5504
  if (n2.type === NodeType$2.Document) {
5507
5505
  doc.close();
5508
5506
  doc.open();
5507
+ while (doc.firstChild) {
5508
+ doc.removeChild(doc.firstChild);
5509
+ }
5509
5510
  if (n2.compatMode === "BackCompat" && n2.childNodes && n2.childNodes[0].type !== NodeType$2.DocumentType) {
5510
5511
  if (n2.childNodes[0].type === NodeType$2.Element && "xmlns" in n2.childNodes[0].attributes && n2.childNodes[0].attributes.xmlns === "http://www.w3.org/1999/xhtml") {
5511
5512
  doc.write(
@@ -5990,9 +5991,7 @@ let Mirror$1 = class Mirror2 {
5990
5991
  const id = this.getId(n2);
5991
5992
  this.idNodeMap.delete(id);
5992
5993
  if (n2.childNodes) {
5993
- n2.childNodes.forEach(
5994
- (childNode) => this.removeNodeFromMap(childNode)
5995
- );
5994
+ n2.childNodes.forEach((childNode) => this.removeNodeFromMap(childNode));
5996
5995
  }
5997
5996
  if (isElement(n2) && n2.shadowRoot) {
5998
5997
  this.removeNodeFromMap(n2.shadowRoot);
@@ -6277,12 +6276,9 @@ class BaseRRElement extends BaseRRNode {
6277
6276
  this.appendChild(this.ownerDocument.createTextNode(textContent));
6278
6277
  }
6279
6278
  get classList() {
6280
- return new ClassList(
6281
- this.attributes.class,
6282
- (newClassName) => {
6283
- this.attributes.class = newClassName;
6284
- }
6285
- );
6279
+ return new ClassList(this.attributes.class, (newClassName) => {
6280
+ this.attributes.class = newClassName;
6281
+ });
6286
6282
  }
6287
6283
  get id() {
6288
6284
  return this.attributes.id || "";
@@ -8246,6 +8242,7 @@ class Replayer {
8246
8242
  this.canvasEventMap = /* @__PURE__ */ new Map();
8247
8243
  this.mirror = createMirror$2();
8248
8244
  this.styleMirror = new StyleSheetMirror();
8245
+ this.pendingAdoptedStyles = /* @__PURE__ */ new Map();
8249
8246
  this.firstFullSnapshot = null;
8250
8247
  this.newDocumentQueue = [];
8251
8248
  this.pointers = {};
@@ -8313,6 +8310,7 @@ class Replayer {
8313
8310
  this.rebuildFullSnapshot(event, isSync);
8314
8311
  this.iframe.contentWindow?.scrollTo(event.data.initialOffset);
8315
8312
  this.styleMirror.reset();
8313
+ this.pendingAdoptedStyles.clear();
8316
8314
  };
8317
8315
  break;
8318
8316
  case EventType$1.IncrementalSnapshot:
@@ -8422,10 +8420,10 @@ class Replayer {
8422
8420
  if (this.usingVirtualDom) {
8423
8421
  const replayerHandler = {
8424
8422
  mirror: this.mirror,
8425
- applyCanvas: (canvasEvent, canvasMutationData2, target) => {
8423
+ applyCanvas: (canvasEvent, canvasMutationData, target) => {
8426
8424
  void canvasMutation({
8427
8425
  event: canvasEvent,
8428
- mutation: canvasMutationData2,
8426
+ mutation: canvasMutationData,
8429
8427
  target,
8430
8428
  imageMap: this.imageMap,
8431
8429
  canvasEventMap: this.canvasEventMap,
@@ -8481,14 +8479,14 @@ class Replayer {
8481
8479
  }
8482
8480
  }
8483
8481
  }
8484
- this.constructedStyleMutations.forEach((data) => {
8485
- this.applyStyleSheetMutation(data);
8486
- });
8487
- this.constructedStyleMutations = [];
8488
8482
  this.adoptedStyleSheets.forEach((data) => {
8489
8483
  this.applyAdoptedStyleSheet(data);
8490
8484
  });
8491
8485
  this.adoptedStyleSheets = [];
8486
+ this.constructedStyleMutations.forEach((data) => {
8487
+ this.applyStyleSheetMutation(data);
8488
+ });
8489
+ this.constructedStyleMutations = [];
8492
8490
  }
8493
8491
  for (const [
8494
8492
  pointerId,
@@ -8528,6 +8526,7 @@ class Replayer {
8528
8526
  this.firstFullSnapshot = null;
8529
8527
  this.mirror.reset();
8530
8528
  this.styleMirror.reset();
8529
+ this.pendingAdoptedStyles.clear();
8531
8530
  });
8532
8531
  const timer = new Timer([], {
8533
8532
  speed: this.config.speed
@@ -8588,9 +8587,7 @@ class Replayer {
8588
8587
  return;
8589
8588
  }
8590
8589
  this.firstFullSnapshot = firstFullsnapshot;
8591
- this.rebuildFullSnapshot(
8592
- firstFullsnapshot
8593
- );
8590
+ this.rebuildFullSnapshot(firstFullsnapshot);
8594
8591
  this.iframe.contentWindow?.scrollTo(
8595
8592
  firstFullsnapshot.data.initialOffset
8596
8593
  );
@@ -8807,12 +8804,12 @@ class Replayer {
8807
8804
  this.wrapper.classList.add("replayer-wrapper");
8808
8805
  this.config.root.appendChild(this.wrapper);
8809
8806
  this.iframe = document.createElement("iframe");
8810
- const attributes2 = ["allow-same-origin"];
8807
+ const attributes = ["allow-same-origin"];
8811
8808
  if (this.config.UNSAFE_replayCanvas) {
8812
- attributes2.push("allow-scripts");
8809
+ attributes.push("allow-scripts");
8813
8810
  }
8814
8811
  this.iframe.style.display = "none";
8815
- this.iframe.setAttribute("sandbox", attributes2.join(" "));
8812
+ this.iframe.setAttribute("sandbox", attributes.join(" "));
8816
8813
  this.disableInteract();
8817
8814
  this.wrapper.appendChild(this.iframe);
8818
8815
  const iframeDoc = getIFrameContentDocument(this.iframe);
@@ -8922,10 +8919,7 @@ class Replayer {
8922
8919
  const sn = mirror2.getMeta(builtNode);
8923
8920
  if (sn?.type === NodeType$2.Element && sn?.tagName.toUpperCase() === "HTML" && iframeContentDoc) {
8924
8921
  const { documentElement, head } = iframeContentDoc;
8925
- this.insertStyleRules(
8926
- documentElement,
8927
- head
8928
- );
8922
+ this.insertStyleRules(documentElement, head);
8929
8923
  }
8930
8924
  if (this.usingVirtualDom) return;
8931
8925
  for (const plugin of this.config.plugins || []) {
@@ -9756,7 +9750,11 @@ class Replayer {
9756
9750
  if (data.styleId) styleSheet = this.styleMirror.getStyle(data.styleId);
9757
9751
  else if (data.id)
9758
9752
  styleSheet = this.mirror.getNode(data.id)?.sheet || null;
9759
- if (!styleSheet) return;
9753
+ if (!styleSheet) {
9754
+ if (data.styleId)
9755
+ this.pendingAdoptedStyles.get(data.styleId)?.mutations.push(data);
9756
+ return;
9757
+ }
9760
9758
  if (data.source === IncrementalSource$1.StyleSheetRule)
9761
9759
  this.applyStyleSheetRule(data, styleSheet);
9762
9760
  else if (data.source === IncrementalSource$1.StyleDeclaration)
@@ -9819,30 +9817,50 @@ class Replayer {
9819
9817
  rule && rule.style && rule.style.removeProperty(data.remove.property);
9820
9818
  }
9821
9819
  }
9820
+ createAdoptedStyleSheet(hostWindow, styleId, rules2) {
9821
+ try {
9822
+ const newStyleSheet = new hostWindow.CSSStyleSheet();
9823
+ this.styleMirror.add(newStyleSheet, styleId);
9824
+ this.applyStyleSheetRule(
9825
+ {
9826
+ source: IncrementalSource$1.StyleSheetRule,
9827
+ adds: rules2
9828
+ },
9829
+ newStyleSheet
9830
+ );
9831
+ } catch (e2) {
9832
+ }
9833
+ }
9822
9834
  applyAdoptedStyleSheet(data) {
9823
9835
  const targetHost = this.mirror.getNode(data.id);
9824
- if (!targetHost) return;
9825
- data.styles?.forEach((style) => {
9826
- let newStyleSheet = null;
9827
- let hostWindow = null;
9828
- if (hasShadowRoot(targetHost))
9829
- hostWindow = targetHost.ownerDocument?.defaultView || null;
9830
- else if (targetHost.nodeName === "#document")
9831
- hostWindow = targetHost.defaultView;
9832
- if (!hostWindow) return;
9833
- try {
9834
- newStyleSheet = new hostWindow.CSSStyleSheet();
9835
- this.styleMirror.add(newStyleSheet, style.styleId);
9836
- this.applyStyleSheetRule(
9837
- {
9838
- source: IncrementalSource$1.StyleSheetRule,
9839
- adds: style.rules
9840
- },
9841
- newStyleSheet
9836
+ if (!targetHost) {
9837
+ data.styles?.forEach(
9838
+ (style) => this.pendingAdoptedStyles.set(style.styleId, {
9839
+ rules: style.rules,
9840
+ mutations: []
9841
+ })
9842
+ );
9843
+ return;
9844
+ }
9845
+ let hostWindow = null;
9846
+ if (hasShadowRoot(targetHost))
9847
+ hostWindow = targetHost.ownerDocument?.defaultView || null;
9848
+ else if (targetHost.nodeName === "#document")
9849
+ hostWindow = targetHost.defaultView;
9850
+ if (hostWindow) {
9851
+ for (const style of data.styles || [])
9852
+ this.createAdoptedStyleSheet(hostWindow, style.styleId, style.rules);
9853
+ for (const styleId of data.styleIds) {
9854
+ const pending = this.pendingAdoptedStyles.get(styleId);
9855
+ if (!pending) continue;
9856
+ this.pendingAdoptedStyles.delete(styleId);
9857
+ if (!this.styleMirror.getStyle(styleId))
9858
+ this.createAdoptedStyleSheet(hostWindow, styleId, pending.rules);
9859
+ pending.mutations.forEach(
9860
+ (mutation) => this.applyStyleSheetMutation(mutation)
9842
9861
  );
9843
- } catch (e2) {
9844
9862
  }
9845
- });
9863
+ }
9846
9864
  const MAX_RETRY_TIME = 10;
9847
9865
  let count = 0;
9848
9866
  const adoptStyleSheets = (targetHost2, styleIds) => {
@@ -10990,6 +11008,7 @@ function Player$1($$anchor, $$props) {
10990
11008
  uiEventListeners[event] = [];
10991
11009
  }
10992
11010
  uiEventListeners[event].push(handler);
11011
+ break;
10993
11012
  }
10994
11013
  };
10995
11014
  function handleUiEvent(event, detail) {