@amplitude/rrweb-player 2.0.0-alpha.29 → 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.
@@ -4315,6 +4315,11 @@ function buildNode(n2, options) {
4315
4315
  node2.style.setProperty("width", value.toString());
4316
4316
  } else if (name === "rr_height") {
4317
4317
  node2.style.setProperty("height", value.toString());
4318
+ } else if (name === "rr_background_color") {
4319
+ node2.style.setProperty(
4320
+ "background-color",
4321
+ value.toString()
4322
+ );
4318
4323
  } else if (name === "rr_mediaCurrentTime" && typeof value === "number") {
4319
4324
  node2.currentTime = value;
4320
4325
  } else if (name === "rr_mediaState") {
@@ -10976,6 +10981,7 @@ function removeDialogFromTopLevel(node2, attributeMutation) {
10976
10981
  }
10977
10982
  const mitt = mitt$1 || mittProxy;
10978
10983
  const REPLAY_CONSOLE_PREFIX = "[replayer]";
10984
+ const INJECTED_STYLE_ID = "__rrweb-injected-style__";
10979
10985
  const defaultMouseTailConfig = {
10980
10986
  duration: 500,
10981
10987
  lineCap: "round",
@@ -11631,6 +11637,40 @@ class Replayer {
11631
11637
  }
11632
11638
  }
11633
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
+ }
11634
11674
  attachDocumentToIframe(mutation, iframeEl) {
11635
11675
  const mirror2 = this.usingVirtualDom ? this.virtualDom.mirror : this.mirror;
11636
11676
  const collectedIframes = [];
@@ -12123,7 +12163,10 @@ class Replayer {
12123
12163
  if (!hasShadowRoot(parent)) {
12124
12164
  parent.attachShadow({ mode: "open" });
12125
12165
  parent = parent.shadowRoot;
12126
- } else parent = parent.shadowRoot;
12166
+ } else {
12167
+ parent = parent.shadowRoot;
12168
+ }
12169
+ this.insertStyleRulesIntoShadowRoot(parent);
12127
12170
  }
12128
12171
  let previous = null;
12129
12172
  let next = null;