@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.
@@ -10943,6 +10943,7 @@ function removeDialogFromTopLevel(node2, attributeMutation) {
10943
10943
  }
10944
10944
  const mitt = mitt$1 || mittProxy;
10945
10945
  const REPLAY_CONSOLE_PREFIX = "[replayer]";
10946
+ const INJECTED_STYLE_ID = "__rrweb-injected-style__";
10946
10947
  const defaultMouseTailConfig = {
10947
10948
  duration: 500,
10948
10949
  lineCap: "round",
@@ -11598,6 +11599,39 @@ class Replayer {
11598
11599
  }
11599
11600
  }
11600
11601
  }
11602
+ isShadowRoot(root2) {
11603
+ return root2.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
11604
+ }
11605
+ insertStyleRulesIntoShadowRoot(root2) {
11606
+ var _a2;
11607
+ const injectStylesRules = rules(
11608
+ this.config.blockClass
11609
+ ).concat(this.config.insertStyleRules);
11610
+ if (!injectStylesRules.length) return;
11611
+ if (this.usingVirtualDom && root2.getAttribute("id") !== INJECTED_STYLE_ID) {
11612
+ const styleEl = this.virtualDom.createElement("style");
11613
+ this.virtualDom.mirror.add(
11614
+ styleEl,
11615
+ getDefaultSN(styleEl, this.virtualDom.unserializedId)
11616
+ );
11617
+ styleEl.setAttribute("id", INJECTED_STYLE_ID);
11618
+ root2.insertBefore(
11619
+ styleEl,
11620
+ root2.firstChild || null
11621
+ );
11622
+ styleEl.rules.push({
11623
+ source: IncrementalSource.StyleSheetRule,
11624
+ adds: injectStylesRules.map((rule2, index2) => ({ rule: rule2, index: index2 }))
11625
+ });
11626
+ } else if (this.isShadowRoot(root2) && !root2.getElementById(INJECTED_STYLE_ID)) {
11627
+ const styleEl = document.createElement("style");
11628
+ styleEl.id = INJECTED_STYLE_ID;
11629
+ root2.insertBefore(styleEl, root2.firstChild ?? null);
11630
+ for (let idx = 0; idx < injectStylesRules.length; idx++) {
11631
+ (_a2 = styleEl.sheet) == null ? void 0 : _a2.insertRule(injectStylesRules[idx], idx);
11632
+ }
11633
+ }
11634
+ }
11601
11635
  attachDocumentToIframe(mutation, iframeEl) {
11602
11636
  const mirror2 = this.usingVirtualDom ? this.virtualDom.mirror : this.mirror;
11603
11637
  const collectedIframes = [];
@@ -12092,7 +12126,10 @@ class Replayer {
12092
12126
  if (!hasShadowRoot(parent)) {
12093
12127
  parent.attachShadow({ mode: "open" });
12094
12128
  parent = parent.shadowRoot;
12095
- } else parent = parent.shadowRoot;
12129
+ } else {
12130
+ parent = parent.shadowRoot;
12131
+ }
12132
+ this.insertStyleRulesIntoShadowRoot(parent);
12096
12133
  }
12097
12134
  let previous = null;
12098
12135
  let next = null;