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// Improve errors thrown by invariant (ex: `Invariant Violation: "main" has not been registered`). 26'node_modules/invariant/.+\\.js$', 27// Remove babel runtime additions 28'node_modules/regenerator-runtime/.+\\.js$', 29// Remove react native setImmediate ponyfill 30'node_modules/promise/setimmediate/.+\\.js$', 31// Babel helpers that implement language features 32'node_modules/@babel/runtime/.+\\.js$', 33// Hide Hermes internal bytecode 34'/InternalBytecode/InternalBytecode\\.js$', 35// Block native code invocations 36`\\[native code\\]`, 37// Hide react-dom (web) 38'node_modules/react-dom/.+\\.js$', 39// Block expo's metro-runtime 40'@expo/metro-runtime/build/.+\\.js$', 41// Block upstream metro-runtime 42'/metro-runtime/.+\\.js$'].join('|')); 43exports.INTERNAL_CALLSITES_REGEX = INTERNAL_CALLSITES_REGEX; 44function isUrl(value) { 45 try { 46 // eslint-disable-next-line no-new 47 new (_url().URL)(value); 48 return true; 49 } catch { 50 return false; 51 } 52} 53 54/** 55 * The default frame processor. This is used to modify the stack traces. 56 * This method attempts to collapse all frames that aren't relevant to 57 * the user by default. 58 */ 59function getDefaultCustomizeFrame() { 60 return frame => { 61 if (frame.file && isUrl(frame.file)) { 62 return { 63 ...frame, 64 // HACK: This prevents Metro from attempting to read the invalid file URL it sent us. 65 lineNumber: null, 66 column: null, 67 // This prevents the invalid frame from being shown by default. 68 collapse: true 69 }; 70 } 71 let collapse = Boolean(frame.file && INTERNAL_CALLSITES_REGEX.test(frame.file)); 72 if (!collapse) { 73 var _frame$file; 74 // This represents the first frame of the stacktrace. 75 // Often this looks like: `__r(0);`. 76 // The URL will also be unactionable in the app and therefore not very useful to the developer. 77 if (frame.column === 3 && frame.methodName === 'global code' && (_frame$file = frame.file) !== null && _frame$file !== void 0 && _frame$file.match(/^https?:\/\//g)) { 78 collapse = true; 79 } 80 } 81 return { 82 ...(frame || {}), 83 collapse 84 }; 85 }; 86} 87//# sourceMappingURL=customizeFrame.js.map