@amplitude/rrweb-player 2.0.0-alpha.30 → 2.0.0-alpha.32

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.
@@ -9404,14 +9404,20 @@ const testableMethods = {
9404
9404
  MutationObserver: ["constructor"]
9405
9405
  };
9406
9406
  const untaintedBasePrototype = {};
9407
- const isAngularZonePresent = () => {
9408
- return !!globalThis.Zone;
9409
- };
9407
+ function angularZoneUnpatchedAlternative(key) {
9408
+ var _a2, _b2;
9409
+ const angularUnpatchedVersionSymbol = (_b2 = (_a2 = globalThis == null ? void 0 : globalThis.Zone) == null ? void 0 : _a2.__symbol__) == null ? void 0 : _b2.call(_a2, key);
9410
+ if (angularUnpatchedVersionSymbol && globalThis[angularUnpatchedVersionSymbol]) {
9411
+ return globalThis[angularUnpatchedVersionSymbol];
9412
+ } else {
9413
+ return void 0;
9414
+ }
9415
+ }
9410
9416
  function getUntaintedPrototype(key) {
9411
9417
  if (untaintedBasePrototype[key])
9412
9418
  return untaintedBasePrototype[key];
9413
- const defaultObj = globalThis[key];
9414
- const defaultPrototype = defaultObj.prototype;
9419
+ const candidate = angularZoneUnpatchedAlternative(key) || globalThis[key];
9420
+ const defaultPrototype = candidate.prototype;
9415
9421
  const accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
9416
9422
  const isUntaintedAccessors = Boolean(
9417
9423
  accessorNames && // @ts-expect-error 2345
@@ -9434,15 +9440,15 @@ function getUntaintedPrototype(key) {
9434
9440
  }
9435
9441
  )
9436
9442
  );
9437
- if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {
9438
- untaintedBasePrototype[key] = defaultObj.prototype;
9439
- return defaultObj.prototype;
9443
+ if (isUntaintedAccessors && isUntaintedMethods) {
9444
+ untaintedBasePrototype[key] = candidate.prototype;
9445
+ return candidate.prototype;
9440
9446
  }
9441
9447
  try {
9442
9448
  const iframeEl = document.createElement("iframe");
9443
9449
  document.body.appendChild(iframeEl);
9444
9450
  const win = iframeEl.contentWindow;
9445
- if (!win) return defaultObj.prototype;
9451
+ if (!win) return candidate.prototype;
9446
9452
  const untaintedObject = win[key].prototype;
9447
9453
  document.body.removeChild(iframeEl);
9448
9454
  if (!untaintedObject) return defaultPrototype;
@@ -10981,6 +10987,7 @@ function removeDialogFromTopLevel(node2, attributeMutation) {
10981
10987
  }
10982
10988
  const mitt = mitt$1 || mittProxy;
10983
10989
  const REPLAY_CONSOLE_PREFIX = "[replayer]";
10990
+ const INJECTED_STYLE_ID = "__rrweb-injected-style__";
10984
10991
  const defaultMouseTailConfig = {
10985
10992
  duration: 500,
10986
10993
  lineCap: "round",
@@ -11636,6 +11643,40 @@ class Replayer {
11636
11643
  }
11637
11644
  }
11638
11645
  }
11646
+ isShadowRoot(root2) {
11647
+ return root2.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
11648
+ }
11649
+ insertStyleRulesIntoShadowRoot(root2) {
11650
+ var _a3;
11651
+ var _a2;
11652
+ const injectStylesRules = rules(
11653
+ this.config.blockClass
11654
+ ).concat(this.config.insertStyleRules);
11655
+ if (!injectStylesRules.length) return;
11656
+ if (this.usingVirtualDom && root2.getAttribute("id") !== INJECTED_STYLE_ID) {
11657
+ const styleEl = this.virtualDom.createElement("style");
11658
+ this.virtualDom.mirror.add(
11659
+ styleEl,
11660
+ getDefaultSN(styleEl, this.virtualDom.unserializedId)
11661
+ );
11662
+ styleEl.setAttribute("id", INJECTED_STYLE_ID);
11663
+ root2.insertBefore(
11664
+ styleEl,
11665
+ root2.firstChild || null
11666
+ );
11667
+ styleEl.rules.push({
11668
+ source: IncrementalSource.StyleSheetRule,
11669
+ adds: injectStylesRules.map((rule2, index2) => ({ rule: rule2, index: index2 }))
11670
+ });
11671
+ } else if (this.isShadowRoot(root2) && !root2.getElementById(INJECTED_STYLE_ID)) {
11672
+ const styleEl = document.createElement("style");
11673
+ styleEl.id = INJECTED_STYLE_ID;
11674
+ root2.insertBefore(styleEl, (_a3 = root2.firstChild) != null ? _a3 : null);
11675
+ for (let idx = 0; idx < injectStylesRules.length; idx++) {
11676
+ (_a2 = styleEl.sheet) == null ? void 0 : _a2.insertRule(injectStylesRules[idx], idx);
11677
+ }
11678
+ }
11679
+ }
11639
11680
  attachDocumentToIframe(mutation, iframeEl) {
11640
11681
  const mirror2 = this.usingVirtualDom ? this.virtualDom.mirror : this.mirror;
11641
11682
  const collectedIframes = [];
@@ -12128,7 +12169,10 @@ class Replayer {
12128
12169
  if (!hasShadowRoot(parent)) {
12129
12170
  parent.attachShadow({ mode: "open" });
12130
12171
  parent = parent.shadowRoot;
12131
- } else parent = parent.shadowRoot;
12172
+ } else {
12173
+ parent = parent.shadowRoot;
12174
+ }
12175
+ this.insertStyleRulesIntoShadowRoot(parent);
12132
12176
  }
12133
12177
  let previous = null;
12134
12178
  let next = null;