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