@amplitude/rrweb-player 2.1.4 → 2.1.5

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.
@@ -5673,6 +5673,7 @@ function serializeNodeWithId(n2, options) {
5673
5673
  preserveWhiteSpace,
5674
5674
  onSerialize,
5675
5675
  onAdoptedStyleSheet,
5676
+ _emittedStyleIds: emittedStyleIds,
5676
5677
  onIframeLoad,
5677
5678
  iframeLoadTimeout,
5678
5679
  onStylesheetLoad,
@@ -5753,6 +5754,7 @@ function snapshot(n2, options) {
5753
5754
  preserveWhiteSpace,
5754
5755
  onSerialize,
5755
5756
  onAdoptedStyleSheet,
5757
+ _emittedStyleIds,
5756
5758
  onIframeLoad,
5757
5759
  iframeLoadTimeout,
5758
5760
  onStylesheetLoad,
@@ -5816,6 +5818,7 @@ function snapshot(n2, options) {
5816
5818
  preserveWhiteSpace,
5817
5819
  onSerialize,
5818
5820
  onAdoptedStyleSheet,
5821
+ _emittedStyleIds,
5819
5822
  onIframeLoad,
5820
5823
  iframeLoadTimeout,
5821
5824
  onStylesheetLoad,
@@ -17362,9 +17365,7 @@ class Replayer {
17362
17365
  this.adoptedStyleSheets = [];
17363
17366
  this.snapshotAdoptedStyleSheetQueue.forEach(
17364
17367
  ({ id, adoptedStyleSheets }) => {
17365
- const node2 = this.mirror.getNode(id);
17366
- if (node2)
17367
- this.applySnapshotAdoptedStyleSheets(node2, adoptedStyleSheets);
17368
+ this.applyQueuedSnapshotAdoptedStyleSheets(id, adoptedStyleSheets);
17368
17369
  }
17369
17370
  );
17370
17371
  this.snapshotAdoptedStyleSheetQueue = [];
@@ -18416,8 +18417,22 @@ class Replayer {
18416
18417
  return;
18417
18418
  }
18418
18419
  const afterAppend = (node2, id) => {
18420
+ const inlineAdoptedStyleSheets = this.inlineAdoptedStyleSheetsFromMutationNode(mutation.node, node2);
18421
+ if (inlineAdoptedStyleSheets && this.usingVirtualDom) {
18422
+ this.snapshotAdoptedStyleSheetQueue.push({
18423
+ id,
18424
+ adoptedStyleSheets: inlineAdoptedStyleSheets
18425
+ });
18426
+ }
18419
18427
  if (this.usingVirtualDom) return;
18420
18428
  applyDialogToTopLevel(node2);
18429
+ if (inlineAdoptedStyleSheets) {
18430
+ this.ensureShadowHostForInlineAdoptedStyles(mutation.node, node2);
18431
+ this.applySnapshotAdoptedStyleSheets(
18432
+ node2,
18433
+ inlineAdoptedStyleSheets
18434
+ );
18435
+ }
18421
18436
  for (const plugin of this.config.plugins || []) {
18422
18437
  if (plugin.onBuild) plugin.onBuild(node2, { id, replayer: this });
18423
18438
  }
@@ -18805,6 +18820,39 @@ class Replayer {
18805
18820
  rule2.style.removeProperty(data.remove.property);
18806
18821
  }
18807
18822
  }
18823
+ applyQueuedSnapshotAdoptedStyleSheets(id, adoptedStyleSheets) {
18824
+ const node2 = this.mirror.getNode(id);
18825
+ if (!node2) return;
18826
+ const meta = this.mirror.getMeta(node2);
18827
+ if ((meta == null ? void 0 : meta.type) === NodeType.Element && meta.isShadowHost && node2.nodeType === Node.ELEMENT_NODE && !hasShadowRoot(node2)) {
18828
+ node2.attachShadow({ mode: "open" });
18829
+ }
18830
+ this.applySnapshotAdoptedStyleSheets(node2, adoptedStyleSheets);
18831
+ }
18832
+ inlineAdoptedStyleSheetsFromMutationNode(mutationNode, builtNode) {
18833
+ var _a22;
18834
+ if (!("adoptedStyleSheets" in mutationNode) || !((_a22 = mutationNode.adoptedStyleSheets) == null ? void 0 : _a22.length)) {
18835
+ return null;
18836
+ }
18837
+ if (mutationNode.type === NodeType.Document) {
18838
+ return mutationNode.adoptedStyleSheets;
18839
+ }
18840
+ if (mutationNode.type === NodeType.Element && mutationNode.isShadowHost) {
18841
+ return mutationNode.adoptedStyleSheets;
18842
+ }
18843
+ if (hasShadowRoot(builtNode)) {
18844
+ return mutationNode.adoptedStyleSheets;
18845
+ }
18846
+ return null;
18847
+ }
18848
+ ensureShadowHostForInlineAdoptedStyles(mutationNode, builtNode) {
18849
+ if (mutationNode.type !== NodeType.Element || !mutationNode.isShadowHost) {
18850
+ return;
18851
+ }
18852
+ const el = builtNode;
18853
+ if (el.nodeType !== Node.ELEMENT_NODE || hasShadowRoot(el)) return;
18854
+ el.attachShadow({ mode: "open" });
18855
+ }
18808
18856
  applySnapshotAdoptedStyleSheets(node2, adoptedStyleSheets) {
18809
18857
  var _a22;
18810
18858
  let hostWindow = null;