@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.
@@ -4279,6 +4279,11 @@ function buildNode(n2, options) {
4279
4279
  node2.style.setProperty("width", value.toString());
4280
4280
  } else if (name === "rr_height") {
4281
4281
  node2.style.setProperty("height", value.toString());
4282
+ } else if (name === "rr_background_color") {
4283
+ node2.style.setProperty(
4284
+ "background-color",
4285
+ value.toString()
4286
+ );
4282
4287
  } else if (name === "rr_mediaCurrentTime" && typeof value === "number") {
4283
4288
  node2.currentTime = value;
4284
4289
  } else if (name === "rr_mediaState") {
@@ -10936,6 +10941,7 @@ function removeDialogFromTopLevel(node2, attributeMutation) {
10936
10941
  }
10937
10942
  const mitt = mitt$1 || mittProxy;
10938
10943
  const REPLAY_CONSOLE_PREFIX = "[replayer]";
10944
+ const INJECTED_STYLE_ID = "__rrweb-injected-style__";
10939
10945
  const defaultMouseTailConfig = {
10940
10946
  duration: 500,
10941
10947
  lineCap: "round",
@@ -11591,6 +11597,39 @@ class Replayer {
11591
11597
  }
11592
11598
  }
11593
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
+ }
11594
11633
  attachDocumentToIframe(mutation, iframeEl) {
11595
11634
  const mirror2 = this.usingVirtualDom ? this.virtualDom.mirror : this.mirror;
11596
11635
  const collectedIframes = [];
@@ -12085,7 +12124,10 @@ class Replayer {
12085
12124
  if (!hasShadowRoot(parent)) {
12086
12125
  parent.attachShadow({ mode: "open" });
12087
12126
  parent = parent.shadowRoot;
12088
- } else parent = parent.shadowRoot;
12127
+ } else {
12128
+ parent = parent.shadowRoot;
12129
+ }
12130
+ this.insertStyleRulesIntoShadowRoot(parent);
12089
12131
  }
12090
12132
  let previous = null;
12091
12133
  let next = null;