@sentry/rrweb-player 2.45.0 → 2.46.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.
@@ -5,17 +5,17 @@ import { SvelteComponent } from 'svelte';
5
5
 
6
6
  declare const Compat: ComponentType<SvelteComponent< {
7
7
  [key: string]: unknown;
8
- width?: number | undefined;
9
- height?: number | undefined;
10
- maxScale?: number | undefined;
11
- events: eventWithTime[];
12
- skipInactive?: boolean | undefined;
13
- autoPlay?: boolean | undefined;
14
- speedOption?: number[] | undefined;
15
- speed?: number | undefined;
16
- showController?: boolean | undefined;
17
- tags?: Record<string, string> | undefined;
18
- inactiveColor?: string | undefined;
8
+ width?: number;
9
+ height?: number;
10
+ maxScale?: number;
11
+ events: RRwebPlayerOptions["props"]["events"];
12
+ skipInactive?: boolean;
13
+ autoPlay?: boolean;
14
+ speedOption?: number[];
15
+ speed?: number;
16
+ showController?: boolean;
17
+ tags?: Record<string, string>;
18
+ inactiveColor?: string;
19
19
  }, Record<string, any>, Record<string, any>> & Record<string, any>>;
20
20
 
21
21
  declare class Player extends Compat {
@@ -5,17 +5,17 @@ import { SvelteComponent } from 'svelte';
5
5
 
6
6
  declare const Compat: ComponentType<SvelteComponent< {
7
7
  [key: string]: unknown;
8
- width?: number | undefined;
9
- height?: number | undefined;
10
- maxScale?: number | undefined;
11
- events: eventWithTime[];
12
- skipInactive?: boolean | undefined;
13
- autoPlay?: boolean | undefined;
14
- speedOption?: number[] | undefined;
15
- speed?: number | undefined;
16
- showController?: boolean | undefined;
17
- tags?: Record<string, string> | undefined;
18
- inactiveColor?: string | undefined;
8
+ width?: number;
9
+ height?: number;
10
+ maxScale?: number;
11
+ events: RRwebPlayerOptions["props"]["events"];
12
+ skipInactive?: boolean;
13
+ autoPlay?: boolean;
14
+ speedOption?: number[];
15
+ speed?: number;
16
+ showController?: boolean;
17
+ tags?: Record<string, string>;
18
+ inactiveColor?: string;
19
19
  }, Record<string, any>, Record<string, any>> & Record<string, any>>;
20
20
 
21
21
  declare class Player extends Compat {
@@ -4692,9 +4692,7 @@ class Mirror {
4692
4692
  const id = this.getId(n2);
4693
4693
  this.idNodeMap.delete(id);
4694
4694
  if (n2.childNodes) {
4695
- n2.childNodes.forEach(
4696
- (childNode) => this.removeNodeFromMap(childNode)
4697
- );
4695
+ n2.childNodes.forEach((childNode) => this.removeNodeFromMap(childNode));
4698
4696
  }
4699
4697
  if (isElement$1(n2) && n2.shadowRoot) {
4700
4698
  this.removeNodeFromMap(n2.shadowRoot);
@@ -5504,6 +5502,9 @@ function buildNodeWithSN(n2, options) {
5504
5502
  if (n2.type === NodeType$2.Document) {
5505
5503
  doc.close();
5506
5504
  doc.open();
5505
+ while (doc.firstChild) {
5506
+ doc.removeChild(doc.firstChild);
5507
+ }
5507
5508
  if (n2.compatMode === "BackCompat" && n2.childNodes && n2.childNodes[0].type !== NodeType$2.DocumentType) {
5508
5509
  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") {
5509
5510
  doc.write(
@@ -5988,9 +5989,7 @@ let Mirror$1 = class Mirror2 {
5988
5989
  const id = this.getId(n2);
5989
5990
  this.idNodeMap.delete(id);
5990
5991
  if (n2.childNodes) {
5991
- n2.childNodes.forEach(
5992
- (childNode) => this.removeNodeFromMap(childNode)
5993
- );
5992
+ n2.childNodes.forEach((childNode) => this.removeNodeFromMap(childNode));
5994
5993
  }
5995
5994
  if (isElement(n2) && n2.shadowRoot) {
5996
5995
  this.removeNodeFromMap(n2.shadowRoot);
@@ -6275,12 +6274,9 @@ class BaseRRElement extends BaseRRNode {
6275
6274
  this.appendChild(this.ownerDocument.createTextNode(textContent));
6276
6275
  }
6277
6276
  get classList() {
6278
- return new ClassList(
6279
- this.attributes.class,
6280
- (newClassName) => {
6281
- this.attributes.class = newClassName;
6282
- }
6283
- );
6277
+ return new ClassList(this.attributes.class, (newClassName) => {
6278
+ this.attributes.class = newClassName;
6279
+ });
6284
6280
  }
6285
6281
  get id() {
6286
6282
  return this.attributes.id || "";
@@ -8244,6 +8240,7 @@ class Replayer {
8244
8240
  this.canvasEventMap = /* @__PURE__ */ new Map();
8245
8241
  this.mirror = createMirror$2();
8246
8242
  this.styleMirror = new StyleSheetMirror();
8243
+ this.pendingAdoptedStyles = /* @__PURE__ */ new Map();
8247
8244
  this.firstFullSnapshot = null;
8248
8245
  this.newDocumentQueue = [];
8249
8246
  this.pointers = {};
@@ -8311,6 +8308,7 @@ class Replayer {
8311
8308
  this.rebuildFullSnapshot(event, isSync);
8312
8309
  this.iframe.contentWindow?.scrollTo(event.data.initialOffset);
8313
8310
  this.styleMirror.reset();
8311
+ this.pendingAdoptedStyles.clear();
8314
8312
  };
8315
8313
  break;
8316
8314
  case EventType$1.IncrementalSnapshot:
@@ -8420,10 +8418,10 @@ class Replayer {
8420
8418
  if (this.usingVirtualDom) {
8421
8419
  const replayerHandler = {
8422
8420
  mirror: this.mirror,
8423
- applyCanvas: (canvasEvent, canvasMutationData2, target) => {
8421
+ applyCanvas: (canvasEvent, canvasMutationData, target) => {
8424
8422
  void canvasMutation({
8425
8423
  event: canvasEvent,
8426
- mutation: canvasMutationData2,
8424
+ mutation: canvasMutationData,
8427
8425
  target,
8428
8426
  imageMap: this.imageMap,
8429
8427
  canvasEventMap: this.canvasEventMap,
@@ -8479,14 +8477,14 @@ class Replayer {
8479
8477
  }
8480
8478
  }
8481
8479
  }
8482
- this.constructedStyleMutations.forEach((data) => {
8483
- this.applyStyleSheetMutation(data);
8484
- });
8485
- this.constructedStyleMutations = [];
8486
8480
  this.adoptedStyleSheets.forEach((data) => {
8487
8481
  this.applyAdoptedStyleSheet(data);
8488
8482
  });
8489
8483
  this.adoptedStyleSheets = [];
8484
+ this.constructedStyleMutations.forEach((data) => {
8485
+ this.applyStyleSheetMutation(data);
8486
+ });
8487
+ this.constructedStyleMutations = [];
8490
8488
  }
8491
8489
  for (const [
8492
8490
  pointerId,
@@ -8526,6 +8524,7 @@ class Replayer {
8526
8524
  this.firstFullSnapshot = null;
8527
8525
  this.mirror.reset();
8528
8526
  this.styleMirror.reset();
8527
+ this.pendingAdoptedStyles.clear();
8529
8528
  });
8530
8529
  const timer = new Timer([], {
8531
8530
  speed: this.config.speed
@@ -8586,9 +8585,7 @@ class Replayer {
8586
8585
  return;
8587
8586
  }
8588
8587
  this.firstFullSnapshot = firstFullsnapshot;
8589
- this.rebuildFullSnapshot(
8590
- firstFullsnapshot
8591
- );
8588
+ this.rebuildFullSnapshot(firstFullsnapshot);
8592
8589
  this.iframe.contentWindow?.scrollTo(
8593
8590
  firstFullsnapshot.data.initialOffset
8594
8591
  );
@@ -8805,12 +8802,12 @@ class Replayer {
8805
8802
  this.wrapper.classList.add("replayer-wrapper");
8806
8803
  this.config.root.appendChild(this.wrapper);
8807
8804
  this.iframe = document.createElement("iframe");
8808
- const attributes2 = ["allow-same-origin"];
8805
+ const attributes = ["allow-same-origin"];
8809
8806
  if (this.config.UNSAFE_replayCanvas) {
8810
- attributes2.push("allow-scripts");
8807
+ attributes.push("allow-scripts");
8811
8808
  }
8812
8809
  this.iframe.style.display = "none";
8813
- this.iframe.setAttribute("sandbox", attributes2.join(" "));
8810
+ this.iframe.setAttribute("sandbox", attributes.join(" "));
8814
8811
  this.disableInteract();
8815
8812
  this.wrapper.appendChild(this.iframe);
8816
8813
  const iframeDoc = getIFrameContentDocument(this.iframe);
@@ -8920,10 +8917,7 @@ class Replayer {
8920
8917
  const sn = mirror2.getMeta(builtNode);
8921
8918
  if (sn?.type === NodeType$2.Element && sn?.tagName.toUpperCase() === "HTML" && iframeContentDoc) {
8922
8919
  const { documentElement, head } = iframeContentDoc;
8923
- this.insertStyleRules(
8924
- documentElement,
8925
- head
8926
- );
8920
+ this.insertStyleRules(documentElement, head);
8927
8921
  }
8928
8922
  if (this.usingVirtualDom) return;
8929
8923
  for (const plugin of this.config.plugins || []) {
@@ -9754,7 +9748,11 @@ class Replayer {
9754
9748
  if (data.styleId) styleSheet = this.styleMirror.getStyle(data.styleId);
9755
9749
  else if (data.id)
9756
9750
  styleSheet = this.mirror.getNode(data.id)?.sheet || null;
9757
- if (!styleSheet) return;
9751
+ if (!styleSheet) {
9752
+ if (data.styleId)
9753
+ this.pendingAdoptedStyles.get(data.styleId)?.mutations.push(data);
9754
+ return;
9755
+ }
9758
9756
  if (data.source === IncrementalSource$1.StyleSheetRule)
9759
9757
  this.applyStyleSheetRule(data, styleSheet);
9760
9758
  else if (data.source === IncrementalSource$1.StyleDeclaration)
@@ -9817,30 +9815,50 @@ class Replayer {
9817
9815
  rule && rule.style && rule.style.removeProperty(data.remove.property);
9818
9816
  }
9819
9817
  }
9818
+ createAdoptedStyleSheet(hostWindow, styleId, rules2) {
9819
+ try {
9820
+ const newStyleSheet = new hostWindow.CSSStyleSheet();
9821
+ this.styleMirror.add(newStyleSheet, styleId);
9822
+ this.applyStyleSheetRule(
9823
+ {
9824
+ source: IncrementalSource$1.StyleSheetRule,
9825
+ adds: rules2
9826
+ },
9827
+ newStyleSheet
9828
+ );
9829
+ } catch (e2) {
9830
+ }
9831
+ }
9820
9832
  applyAdoptedStyleSheet(data) {
9821
9833
  const targetHost = this.mirror.getNode(data.id);
9822
- if (!targetHost) return;
9823
- data.styles?.forEach((style) => {
9824
- let newStyleSheet = null;
9825
- let hostWindow = null;
9826
- if (hasShadowRoot(targetHost))
9827
- hostWindow = targetHost.ownerDocument?.defaultView || null;
9828
- else if (targetHost.nodeName === "#document")
9829
- hostWindow = targetHost.defaultView;
9830
- if (!hostWindow) return;
9831
- try {
9832
- newStyleSheet = new hostWindow.CSSStyleSheet();
9833
- this.styleMirror.add(newStyleSheet, style.styleId);
9834
- this.applyStyleSheetRule(
9835
- {
9836
- source: IncrementalSource$1.StyleSheetRule,
9837
- adds: style.rules
9838
- },
9839
- newStyleSheet
9834
+ if (!targetHost) {
9835
+ data.styles?.forEach(
9836
+ (style) => this.pendingAdoptedStyles.set(style.styleId, {
9837
+ rules: style.rules,
9838
+ mutations: []
9839
+ })
9840
+ );
9841
+ return;
9842
+ }
9843
+ let hostWindow = null;
9844
+ if (hasShadowRoot(targetHost))
9845
+ hostWindow = targetHost.ownerDocument?.defaultView || null;
9846
+ else if (targetHost.nodeName === "#document")
9847
+ hostWindow = targetHost.defaultView;
9848
+ if (hostWindow) {
9849
+ for (const style of data.styles || [])
9850
+ this.createAdoptedStyleSheet(hostWindow, style.styleId, style.rules);
9851
+ for (const styleId of data.styleIds) {
9852
+ const pending = this.pendingAdoptedStyles.get(styleId);
9853
+ if (!pending) continue;
9854
+ this.pendingAdoptedStyles.delete(styleId);
9855
+ if (!this.styleMirror.getStyle(styleId))
9856
+ this.createAdoptedStyleSheet(hostWindow, styleId, pending.rules);
9857
+ pending.mutations.forEach(
9858
+ (mutation) => this.applyStyleSheetMutation(mutation)
9840
9859
  );
9841
- } catch (e2) {
9842
9860
  }
9843
- });
9861
+ }
9844
9862
  const MAX_RETRY_TIME = 10;
9845
9863
  let count = 0;
9846
9864
  const adoptStyleSheets = (targetHost2, styleIds) => {
@@ -10988,6 +11006,7 @@ function Player$1($$anchor, $$props) {
10988
11006
  uiEventListeners[event] = [];
10989
11007
  }
10990
11008
  uiEventListeners[event].push(handler);
11009
+ break;
10991
11010
  }
10992
11011
  };
10993
11012
  function handleUiEvent(event, detail) {