@amplitude/rrweb-player 2.0.0-alpha.30 → 2.0.0-alpha.31

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.
@@ -10981,6 +10981,7 @@ function removeDialogFromTopLevel(node2, attributeMutation) {
10981
10981
  }
10982
10982
  const mitt = mitt$1 || mittProxy;
10983
10983
  const REPLAY_CONSOLE_PREFIX = "[replayer]";
10984
+ const INJECTED_STYLE_ID = "__rrweb-injected-style__";
10984
10985
  const defaultMouseTailConfig = {
10985
10986
  duration: 500,
10986
10987
  lineCap: "round",
@@ -11636,6 +11637,40 @@ class Replayer {
11636
11637
  }
11637
11638
  }
11638
11639
  }
11640
+ isShadowRoot(root2) {
11641
+ return root2.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
11642
+ }
11643
+ insertStyleRulesIntoShadowRoot(root2) {
11644
+ var _a3;
11645
+ var _a2;
11646
+ const injectStylesRules = rules(
11647
+ this.config.blockClass
11648
+ ).concat(this.config.insertStyleRules);
11649
+ if (!injectStylesRules.length) return;
11650
+ if (this.usingVirtualDom && root2.getAttribute("id") !== INJECTED_STYLE_ID) {
11651
+ const styleEl = this.virtualDom.createElement("style");
11652
+ this.virtualDom.mirror.add(
11653
+ styleEl,
11654
+ getDefaultSN(styleEl, this.virtualDom.unserializedId)
11655
+ );
11656
+ styleEl.setAttribute("id", INJECTED_STYLE_ID);
11657
+ root2.insertBefore(
11658
+ styleEl,
11659
+ root2.firstChild || null
11660
+ );
11661
+ styleEl.rules.push({
11662
+ source: IncrementalSource.StyleSheetRule,
11663
+ adds: injectStylesRules.map((rule2, index2) => ({ rule: rule2, index: index2 }))
11664
+ });
11665
+ } else if (this.isShadowRoot(root2) && !root2.getElementById(INJECTED_STYLE_ID)) {
11666
+ const styleEl = document.createElement("style");
11667
+ styleEl.id = INJECTED_STYLE_ID;
11668
+ root2.insertBefore(styleEl, (_a3 = root2.firstChild) != null ? _a3 : null);
11669
+ for (let idx = 0; idx < injectStylesRules.length; idx++) {
11670
+ (_a2 = styleEl.sheet) == null ? void 0 : _a2.insertRule(injectStylesRules[idx], idx);
11671
+ }
11672
+ }
11673
+ }
11639
11674
  attachDocumentToIframe(mutation, iframeEl) {
11640
11675
  const mirror2 = this.usingVirtualDom ? this.virtualDom.mirror : this.mirror;
11641
11676
  const collectedIframes = [];
@@ -12128,7 +12163,10 @@ class Replayer {
12128
12163
  if (!hasShadowRoot(parent)) {
12129
12164
  parent.attachShadow({ mode: "open" });
12130
12165
  parent = parent.shadowRoot;
12131
- } else parent = parent.shadowRoot;
12166
+ } else {
12167
+ parent = parent.shadowRoot;
12168
+ }
12169
+ this.insertStyleRulesIntoShadowRoot(parent);
12132
12170
  }
12133
12171
  let previous = null;
12134
12172
  let next = null;