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