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