@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.
@@ -9364,14 +9364,20 @@ const testableMethods = {
9364
9364
  MutationObserver: ["constructor"]
9365
9365
  };
9366
9366
  const untaintedBasePrototype = {};
9367
- const isAngularZonePresent = () => {
9368
- return !!globalThis.Zone;
9369
- };
9367
+ function angularZoneUnpatchedAlternative(key) {
9368
+ var _a2, _b2;
9369
+ const angularUnpatchedVersionSymbol = (_b2 = (_a2 = globalThis == null ? void 0 : globalThis.Zone) == null ? void 0 : _a2.__symbol__) == null ? void 0 : _b2.call(_a2, key);
9370
+ if (angularUnpatchedVersionSymbol && globalThis[angularUnpatchedVersionSymbol]) {
9371
+ return globalThis[angularUnpatchedVersionSymbol];
9372
+ } else {
9373
+ return void 0;
9374
+ }
9375
+ }
9370
9376
  function getUntaintedPrototype(key) {
9371
9377
  if (untaintedBasePrototype[key])
9372
9378
  return untaintedBasePrototype[key];
9373
- const defaultObj = globalThis[key];
9374
- const defaultPrototype = defaultObj.prototype;
9379
+ const candidate = angularZoneUnpatchedAlternative(key) || globalThis[key];
9380
+ const defaultPrototype = candidate.prototype;
9375
9381
  const accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
9376
9382
  const isUntaintedAccessors = Boolean(
9377
9383
  accessorNames && // @ts-expect-error 2345
@@ -9394,15 +9400,15 @@ function getUntaintedPrototype(key) {
9394
9400
  }
9395
9401
  )
9396
9402
  );
9397
- if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {
9398
- untaintedBasePrototype[key] = defaultObj.prototype;
9399
- return defaultObj.prototype;
9403
+ if (isUntaintedAccessors && isUntaintedMethods) {
9404
+ untaintedBasePrototype[key] = candidate.prototype;
9405
+ return candidate.prototype;
9400
9406
  }
9401
9407
  try {
9402
9408
  const iframeEl = document.createElement("iframe");
9403
9409
  document.body.appendChild(iframeEl);
9404
9410
  const win = iframeEl.contentWindow;
9405
- if (!win) return defaultObj.prototype;
9411
+ if (!win) return candidate.prototype;
9406
9412
  const untaintedObject = win[key].prototype;
9407
9413
  document.body.removeChild(iframeEl);
9408
9414
  if (!untaintedObject) return defaultPrototype;
@@ -10941,6 +10947,7 @@ function removeDialogFromTopLevel(node2, attributeMutation) {
10941
10947
  }
10942
10948
  const mitt = mitt$1 || mittProxy;
10943
10949
  const REPLAY_CONSOLE_PREFIX = "[replayer]";
10950
+ const INJECTED_STYLE_ID = "__rrweb-injected-style__";
10944
10951
  const defaultMouseTailConfig = {
10945
10952
  duration: 500,
10946
10953
  lineCap: "round",
@@ -11596,6 +11603,39 @@ class Replayer {
11596
11603
  }
11597
11604
  }
11598
11605
  }
11606
+ isShadowRoot(root2) {
11607
+ return root2.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
11608
+ }
11609
+ insertStyleRulesIntoShadowRoot(root2) {
11610
+ var _a2;
11611
+ const injectStylesRules = rules(
11612
+ this.config.blockClass
11613
+ ).concat(this.config.insertStyleRules);
11614
+ if (!injectStylesRules.length) return;
11615
+ if (this.usingVirtualDom && root2.getAttribute("id") !== INJECTED_STYLE_ID) {
11616
+ const styleEl = this.virtualDom.createElement("style");
11617
+ this.virtualDom.mirror.add(
11618
+ styleEl,
11619
+ getDefaultSN(styleEl, this.virtualDom.unserializedId)
11620
+ );
11621
+ styleEl.setAttribute("id", INJECTED_STYLE_ID);
11622
+ root2.insertBefore(
11623
+ styleEl,
11624
+ root2.firstChild || null
11625
+ );
11626
+ styleEl.rules.push({
11627
+ source: IncrementalSource.StyleSheetRule,
11628
+ adds: injectStylesRules.map((rule2, index2) => ({ rule: rule2, index: index2 }))
11629
+ });
11630
+ } else if (this.isShadowRoot(root2) && !root2.getElementById(INJECTED_STYLE_ID)) {
11631
+ const styleEl = document.createElement("style");
11632
+ styleEl.id = INJECTED_STYLE_ID;
11633
+ root2.insertBefore(styleEl, root2.firstChild ?? null);
11634
+ for (let idx = 0; idx < injectStylesRules.length; idx++) {
11635
+ (_a2 = styleEl.sheet) == null ? void 0 : _a2.insertRule(injectStylesRules[idx], idx);
11636
+ }
11637
+ }
11638
+ }
11599
11639
  attachDocumentToIframe(mutation, iframeEl) {
11600
11640
  const mirror2 = this.usingVirtualDom ? this.virtualDom.mirror : this.mirror;
11601
11641
  const collectedIframes = [];
@@ -12090,7 +12130,10 @@ class Replayer {
12090
12130
  if (!hasShadowRoot(parent)) {
12091
12131
  parent.attachShadow({ mode: "open" });
12092
12132
  parent = parent.shadowRoot;
12093
- } else parent = parent.shadowRoot;
12133
+ } else {
12134
+ parent = parent.shadowRoot;
12135
+ }
12136
+ this.insertStyleRulesIntoShadowRoot(parent);
12094
12137
  }
12095
12138
  let previous = null;
12096
12139
  let next = null;