1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4  value: true
5});
6exports.INTERNAL_CALLSITES_REGEX = void 0;
7exports.getDefaultCustomizeFrame = getDefaultCustomizeFrame;
8function _url() {
9  const data = require("url");
10  _url = function () {
11    return data;
12  };
13  return data;
14}
15// Copyright 2023-present 650 Industries (Expo). All rights reserved.
16
17// Import only the types here, the values will be imported from the project, at runtime.
18const INTERNAL_CALLSITES_REGEX = new RegExp(['/Libraries/Renderer/implementations/.+\\.js$', '/Libraries/BatchedBridge/MessageQueue\\.js$', '/Libraries/YellowBox/.+\\.js$', '/Libraries/LogBox/.+\\.js$', '/Libraries/Core/Timers/.+\\.js$', 'node_modules/react-devtools-core/.+\\.js$', 'node_modules/react-refresh/.+\\.js$', 'node_modules/scheduler/.+\\.js$',
19// Metro replaces `require()` with a different method,
20// we want to omit this method from the stack trace.
21// This is akin to most React tooling.
22'/metro/.*/polyfills/require.js$',
23// Hide frames related to a fast refresh.
24'/metro/.*/lib/bundle-modules/.+\\.js$', 'node_modules/react-native/Libraries/Utilities/HMRClient.js$', 'node_modules/eventemitter3/index.js', 'node_modules/event-target-shim/dist/.+\\.js$',
25// Ignore the log forwarder used in the expo package.
26'/expo/build/logs/RemoteConsole.js$',
27// Improve errors thrown by invariant (ex: `Invariant Violation: "main" has not been registered`).
28'node_modules/invariant/.+\\.js$',
29// Remove babel runtime additions
30'node_modules/regenerator-runtime/.+\\.js$',
31// Remove react native setImmediate ponyfill
32'node_modules/promise/setimmediate/.+\\.js$',
33// Babel helpers that implement language features
34'node_modules/@babel/runtime/.+\\.js$',
35// Hide Hermes internal bytecode
36'/InternalBytecode/InternalBytecode\\.js$',
37// Block native code invocations
38`\\[native code\\]`,
39// Hide react-dom (web)
40'node_modules/react-dom/.+\\.js$'].join('|'));
41exports.INTERNAL_CALLSITES_REGEX = INTERNAL_CALLSITES_REGEX;
42function isUrl(value) {
43  try {
44    // eslint-disable-next-line no-new
45    new (_url().URL)(value);
46    return true;
47  } catch {
48    return false;
49  }
50}
51
52/**
53 * The default frame processor. This is used to modify the stack traces.
54 * This method attempts to collapse all frames that aren't relevant to
55 * the user by default.
56 */
57function getDefaultCustomizeFrame() {
58  return frame => {
59    if (frame.file && isUrl(frame.file)) {
60      return {
61        ...frame,
62        // HACK: This prevents Metro from attempting to read the invalid file URL it sent us.
63        lineNumber: null,
64        column: null,
65        // This prevents the invalid frame from being shown by default.
66        collapse: true
67      };
68    }
69    let collapse = Boolean(frame.file && INTERNAL_CALLSITES_REGEX.test(frame.file));
70    if (!collapse) {
71      var _frame$file;
72      // This represents the first frame of the stacktrace.
73      // Often this looks like: `__r(0);`.
74      // The URL will also be unactionable in the app and therefore not very useful to the developer.
75      if (frame.column === 3 && frame.methodName === 'global code' && (_frame$file = frame.file) !== null && _frame$file !== void 0 && _frame$file.match(/^https?:\/\//g)) {
76        collapse = true;
77      }
78    }
79    return {
80      ...(frame || {}),
81      collapse
82    };
83  };
84}
85//# sourceMappingURL=customizeFrame.js.map