@sentry/replay 10.75.3 → 10.76.1

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.
@@ -154,6 +154,9 @@ class Mirror {
154
154
  (childNode) => this.removeNodeFromMap(childNode)
155
155
  );
156
156
  }
157
+ if (isElement$1(n) && n.shadowRoot) {
158
+ this.removeNodeFromMap(n.shadowRoot);
159
+ }
157
160
  }
158
161
  has(id) {
159
162
  return this.idNodeMap.has(id);
@@ -270,8 +273,9 @@ function getImplementation$1(name) {
270
273
  if (cached) {
271
274
  return cached;
272
275
  }
276
+ const windowImpl = window[name].bind(window);
277
+ let impl = windowImpl;
273
278
  const document2 = window.document;
274
- let impl = window[name];
275
279
  if (document2 && typeof document2.createElement === "function") {
276
280
  try {
277
281
  const sandbox = document2.createElement("iframe");
@@ -279,16 +283,21 @@ function getImplementation$1(name) {
279
283
  document2.head.appendChild(sandbox);
280
284
  const contentWindow = sandbox.contentWindow;
281
285
  if (contentWindow && contentWindow[name]) {
282
- impl = // eslint-disable-next-line @typescript-eslint/unbound-method
283
- contentWindow[name];
286
+ const sandboxImpl = contentWindow[name].bind(window);
287
+ impl = (...args) => {
288
+ try {
289
+ return sandboxImpl(...args);
290
+ } catch {
291
+ cachedImplementations$1[name] = windowImpl;
292
+ return windowImpl(...args);
293
+ }
294
+ };
284
295
  }
285
296
  document2.head.removeChild(sandbox);
286
297
  } catch (e) {
287
298
  }
288
299
  }
289
- return cachedImplementations$1[name] = impl.bind(
290
- window
291
- );
300
+ return cachedImplementations$1[name] = impl;
292
301
  }
293
302
  function setTimeout$1(...rest) {
294
303
  return getImplementation$1("setTimeout")(...rest);
@@ -547,6 +556,9 @@ function elementClassMatchesRegex(el, regex) {
547
556
  }
548
557
  function distanceToMatch(node, matchPredicate, limit = Infinity, distance = 0) {
549
558
  if (!node) return -1;
559
+ if (isShadowRoot(node)) {
560
+ return distanceToMatch(node.host, matchPredicate, limit, distance + 1);
561
+ }
550
562
  if (node.nodeType !== node.ELEMENT_NODE) return -1;
551
563
  if (distance > limit) return -1;
552
564
  if (matchPredicate(node)) return distance;
@@ -1747,8 +1759,9 @@ function getImplementation(name) {
1747
1759
  if (cached) {
1748
1760
  return cached;
1749
1761
  }
1762
+ const windowImpl = window[name].bind(window);
1763
+ let impl = windowImpl;
1750
1764
  const document2 = window.document;
1751
- let impl = window[name];
1752
1765
  if (document2 && typeof document2.createElement === "function") {
1753
1766
  try {
1754
1767
  const sandbox = document2.createElement("iframe");
@@ -1756,16 +1769,21 @@ function getImplementation(name) {
1756
1769
  document2.head.appendChild(sandbox);
1757
1770
  const contentWindow = sandbox.contentWindow;
1758
1771
  if (contentWindow && contentWindow[name]) {
1759
- impl = // eslint-disable-next-line @typescript-eslint/unbound-method
1760
- contentWindow[name];
1772
+ const sandboxImpl = contentWindow[name].bind(window);
1773
+ impl = (...args) => {
1774
+ try {
1775
+ return sandboxImpl(...args);
1776
+ } catch {
1777
+ cachedImplementations[name] = windowImpl;
1778
+ return windowImpl(...args);
1779
+ }
1780
+ };
1761
1781
  }
1762
1782
  document2.head.removeChild(sandbox);
1763
1783
  } catch (e) {
1764
1784
  }
1765
1785
  }
1766
- return cachedImplementations[name] = impl.bind(
1767
- window
1768
- );
1786
+ return cachedImplementations[name] = impl;
1769
1787
  }
1770
1788
  function onRequestAnimationFrame(...rest) {
1771
1789
  return getImplementation("requestAnimationFrame")(...rest);
@@ -3902,10 +3920,14 @@ class ShadowDomManager {
3902
3920
  const iframeDoc = getIFrameContentDocument(iframeElement);
3903
3921
  const iframeWindow = getIFrameContentWindow(iframeElement);
3904
3922
  if (!iframeDoc || !iframeWindow) return;
3905
- this.patchAttachShadow(
3906
- iframeWindow.Element,
3907
- iframeDoc
3908
- );
3923
+ let iframeElementConstructor;
3924
+ try {
3925
+ iframeElementConstructor = iframeWindow.Element;
3926
+ } catch (e2) {
3927
+ return;
3928
+ }
3929
+ if (!iframeElementConstructor) return;
3930
+ this.patchAttachShadow(iframeElementConstructor, iframeDoc);
3909
3931
  }
3910
3932
  /**
3911
3933
  * Patch 'attachShadow' to observe newly added shadow doms.