@sentry/replay 11.4.0 → 11.5.0

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.
@@ -21,7 +21,7 @@ const MIN_REPLAY_DURATION = 4999;
21
21
  const MIN_REPLAY_DURATION_LIMIT = 5e4;
22
22
  const MAX_REPLAY_DURATION = 36e5;
23
23
 
24
- const Hd="sentry.segment.name.source";
24
+ const jd="sentry.segment.name.source";
25
25
 
26
26
  var __defProp = Object.defineProperty;
27
27
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -156,6 +156,9 @@ class Mirror {
156
156
  (childNode) => this.removeNodeFromMap(childNode)
157
157
  );
158
158
  }
159
+ if (isElement$1(n) && n.shadowRoot) {
160
+ this.removeNodeFromMap(n.shadowRoot);
161
+ }
159
162
  }
160
163
  has(id) {
161
164
  return this.idNodeMap.has(id);
@@ -272,8 +275,9 @@ function getImplementation$1(name) {
272
275
  if (cached) {
273
276
  return cached;
274
277
  }
278
+ const windowImpl = window[name].bind(window);
279
+ let impl = windowImpl;
275
280
  const document2 = window.document;
276
- let impl = window[name];
277
281
  if (document2 && typeof document2.createElement === "function") {
278
282
  try {
279
283
  const sandbox = document2.createElement("iframe");
@@ -281,16 +285,21 @@ function getImplementation$1(name) {
281
285
  document2.head.appendChild(sandbox);
282
286
  const contentWindow = sandbox.contentWindow;
283
287
  if (contentWindow && contentWindow[name]) {
284
- impl = // eslint-disable-next-line @typescript-eslint/unbound-method
285
- contentWindow[name];
288
+ const sandboxImpl = contentWindow[name].bind(window);
289
+ impl = (...args) => {
290
+ try {
291
+ return sandboxImpl(...args);
292
+ } catch {
293
+ cachedImplementations$1[name] = windowImpl;
294
+ return windowImpl(...args);
295
+ }
296
+ };
286
297
  }
287
298
  document2.head.removeChild(sandbox);
288
299
  } catch (e) {
289
300
  }
290
301
  }
291
- return cachedImplementations$1[name] = impl.bind(
292
- window
293
- );
302
+ return cachedImplementations$1[name] = impl;
294
303
  }
295
304
  function setTimeout$1(...rest) {
296
305
  return getImplementation$1("setTimeout")(...rest);
@@ -549,6 +558,9 @@ function elementClassMatchesRegex(el, regex) {
549
558
  }
550
559
  function distanceToMatch(node, matchPredicate, limit = Infinity, distance = 0) {
551
560
  if (!node) return -1;
561
+ if (isShadowRoot(node)) {
562
+ return distanceToMatch(node.host, matchPredicate, limit, distance + 1);
563
+ }
552
564
  if (node.nodeType !== node.ELEMENT_NODE) return -1;
553
565
  if (distance > limit) return -1;
554
566
  if (matchPredicate(node)) return distance;
@@ -1749,8 +1761,9 @@ function getImplementation(name) {
1749
1761
  if (cached) {
1750
1762
  return cached;
1751
1763
  }
1764
+ const windowImpl = window[name].bind(window);
1765
+ let impl = windowImpl;
1752
1766
  const document2 = window.document;
1753
- let impl = window[name];
1754
1767
  if (document2 && typeof document2.createElement === "function") {
1755
1768
  try {
1756
1769
  const sandbox = document2.createElement("iframe");
@@ -1758,16 +1771,21 @@ function getImplementation(name) {
1758
1771
  document2.head.appendChild(sandbox);
1759
1772
  const contentWindow = sandbox.contentWindow;
1760
1773
  if (contentWindow && contentWindow[name]) {
1761
- impl = // eslint-disable-next-line @typescript-eslint/unbound-method
1762
- contentWindow[name];
1774
+ const sandboxImpl = contentWindow[name].bind(window);
1775
+ impl = (...args) => {
1776
+ try {
1777
+ return sandboxImpl(...args);
1778
+ } catch {
1779
+ cachedImplementations[name] = windowImpl;
1780
+ return windowImpl(...args);
1781
+ }
1782
+ };
1763
1783
  }
1764
1784
  document2.head.removeChild(sandbox);
1765
1785
  } catch (e) {
1766
1786
  }
1767
1787
  }
1768
- return cachedImplementations[name] = impl.bind(
1769
- window
1770
- );
1788
+ return cachedImplementations[name] = impl;
1771
1789
  }
1772
1790
  function onRequestAnimationFrame(...rest) {
1773
1791
  return getImplementation("requestAnimationFrame")(...rest);
@@ -3904,10 +3922,14 @@ class ShadowDomManager {
3904
3922
  const iframeDoc = getIFrameContentDocument(iframeElement);
3905
3923
  const iframeWindow = getIFrameContentWindow(iframeElement);
3906
3924
  if (!iframeDoc || !iframeWindow) return;
3907
- this.patchAttachShadow(
3908
- iframeWindow.Element,
3909
- iframeDoc
3910
- );
3925
+ let iframeElementConstructor;
3926
+ try {
3927
+ iframeElementConstructor = iframeWindow.Element;
3928
+ } catch (e2) {
3929
+ return;
3930
+ }
3931
+ if (!iframeElementConstructor) return;
3932
+ this.patchAttachShadow(iframeElementConstructor, iframeDoc);
3911
3933
  }
3912
3934
  /**
3913
3935
  * Patch 'attachShadow' to observe newly added shadow doms.
@@ -7711,7 +7733,7 @@ class ReplayContainer {
7711
7733
  return void 0;
7712
7734
  }
7713
7735
  const spanJson = spanToJSON(lastRootSpan);
7714
- const source = spanJson.attributes[Hd];
7736
+ const source = spanJson.attributes[jd];
7715
7737
  if (!source || !["route", "custom"].includes(source)) {
7716
7738
  return void 0;
7717
7739
  }