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