1{"version":3,"file":"customizeFrame.js","names":["_url","data","require","INTERNAL_CALLSITES_REGEX","RegExp","join","exports","isUrl","value","URL","getDefaultCustomizeFrame","frame","file","lineNumber","column","collapse","Boolean","test","_frame$file","methodName","match"],"sources":["../src/customizeFrame.ts"],"sourcesContent":["// Copyright 2023-present 650 Industries (Expo). All rights reserved.\nimport { SymbolicatorConfigT } from 'metro-config';\nimport { URL } from 'url';\n\ntype CustomizeFrameFunc = SymbolicatorConfigT['customizeFrame'];\n\n// Import only the types here, the values will be imported from the project, at runtime.\nexport const INTERNAL_CALLSITES_REGEX = new RegExp(\n [\n '/Libraries/Renderer/implementations/.+\\\\.js$',\n '/Libraries/BatchedBridge/MessageQueue\\\\.js$',\n '/Libraries/YellowBox/.+\\\\.js$',\n '/Libraries/LogBox/.+\\\\.js$',\n '/Libraries/Core/Timers/.+\\\\.js$',\n 'node_modules/react-devtools-core/.+\\\\.js$',\n 'node_modules/react-refresh/.+\\\\.js$',\n 'node_modules/scheduler/.+\\\\.js$',\n // Metro replaces `require()` with a different method,\n // we want to omit this method from the stack trace.\n // This is akin to most React tooling.\n '/metro/.*/polyfills/require.js$',\n // Hide frames related to a fast refresh.\n '/metro/.*/lib/bundle-modules/.+\\\\.js$',\n 'node_modules/react-native/Libraries/Utilities/HMRClient.js$',\n 'node_modules/eventemitter3/index.js',\n 'node_modules/event-target-shim/dist/.+\\\\.js$',\n // Ignore the log forwarder used in the expo package.\n '/expo/build/logs/RemoteConsole.js$',\n // Improve errors thrown by invariant (ex: `Invariant Violation: \"main\" has not been registered`).\n 'node_modules/invariant/.+\\\\.js$',\n // Remove babel runtime additions\n 'node_modules/regenerator-runtime/.+\\\\.js$',\n // Remove react native setImmediate ponyfill\n 'node_modules/promise/setimmediate/.+\\\\.js$',\n // Babel helpers that implement language features\n 'node_modules/@babel/runtime/.+\\\\.js$',\n // Hide Hermes internal bytecode\n '/InternalBytecode/InternalBytecode\\\\.js$',\n // Block native code invocations\n `\\\\[native code\\\\]`,\n // Hide react-dom (web)\n 'node_modules/react-dom/.+\\\\.js$',\n '@expo/metro-runtime/build/.+\\\\.js$',\n ].join('|')\n);\n\nfunction isUrl(value: string): boolean {\n try {\n // eslint-disable-next-line no-new\n new URL(value);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * The default frame processor. This is used to modify the stack traces.\n * This method attempts to collapse all frames that aren't relevant to\n * the user by default.\n */\nexport function getDefaultCustomizeFrame(): CustomizeFrameFunc {\n return (frame: Parameters<CustomizeFrameFunc>[0]) => {\n if (frame.file && isUrl(frame.file)) {\n return {\n ...frame,\n // HACK: This prevents Metro from attempting to read the invalid file URL it sent us.\n lineNumber: null,\n column: null,\n // This prevents the invalid frame from being shown by default.\n collapse: true,\n };\n }\n let collapse = Boolean(frame.file && INTERNAL_CALLSITES_REGEX.test(frame.file));\n\n if (!collapse) {\n // This represents the first frame of the stacktrace.\n // Often this looks like: `__r(0);`.\n // The URL will also be unactionable in the app and therefore not very useful to the developer.\n if (\n frame.column === 3 &&\n frame.methodName === 'global code' &&\n frame.file?.match(/^https?:\\/\\//g)\n ) {\n collapse = true;\n }\n }\n\n return { ...(frame || {}), collapse };\n };\n}\n"],"mappings":";;;;;;;AAEA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAFA;;AAMA;AACO,MAAME,wBAAwB,GAAG,IAAIC,MAAM,CAChD,CACE,8CAA8C,EAC9C,6CAA6C,EAC7C,+BAA+B,EAC/B,4BAA4B,EAC5B,iCAAiC,EACjC,2CAA2C,EAC3C,qCAAqC,EACrC,iCAAiC;AACjC;AACA;AACA;AACA,iCAAiC;AACjC;AACA,uCAAuC,EACvC,6DAA6D,EAC7D,qCAAqC,EACrC,8CAA8C;AAC9C;AACA,oCAAoC;AACpC;AACA,iCAAiC;AACjC;AACA,2CAA2C;AAC3C;AACA,4CAA4C;AAC5C;AACA,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