{"version":3,"file":"stacktrace.js","sources":["../../../src/vendor/stacktrace.ts"],"sourcesContent":["// Vendored from https://github.com/robertcepa/toucan-js/blob/036568729e49d0a937de527dc32d73580d9a41b3/packages/toucan-js/src/stacktrace.ts\n// MIT License\n\n// Copyright (c) 2022 Robert Cepa\n\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport type { StackLineParser, StackLineParserFn, StackParser } from '@sentry/core';\nimport { basename, createStackParser, nodeStackLineParser } from '@sentry/core';\n\ntype GetModuleFn = (filename: string | undefined) => string | undefined;\n\n/**\n * Stack line parser for Cloudflare Workers.\n * This wraps node stack parser and adjusts root paths to match with source maps.\n *\n */\nfunction workersStackLineParser(getModule?: GetModuleFn): StackLineParser {\n const [arg1, arg2] = nodeStackLineParser(getModule);\n\n const fn: StackLineParserFn = line => {\n const result = arg2(line);\n if (result) {\n const filename = result.filename;\n // Workers runtime runs a single bundled file that is always in a virtual root\n result.abs_path = filename !== undefined && !filename.startsWith('/') ? `/${filename}` : filename;\n // There is no way to tell what code is in_app and what comes from dependencies (node_modules), since we have one bundled file.\n // So everything is in_app, unless an error comes from runtime function (ie. JSON.parse), which is determined by the presence of filename.\n result.in_app = filename !== undefined;\n }\n return result;\n };\n\n return [arg1, fn];\n}\n\n/**\n * Gets the module from filename.\n *\n * @param filename\n * @returns Module name\n */\nexport function getModule(filename: string | undefined): string | undefined {\n if (!filename) {\n return;\n }\n\n // In Cloudflare Workers there is always only one bundled file\n return basename(filename, '.js');\n}\n\n/** Cloudflare Workers stack parser */\nexport const defaultStackParser: StackParser = createStackParser(workersStackLineParser(getModule));\n"],"names":["getModule"],"mappings":";;AAiCA,SAAS,uBAAuBA,UAAAA,EAA0C;AACxE,EAAA,MAAM,CAAC,IAAA,EAAM,IAAI,CAAA,GAAI,oBAAoBA,UAAS,CAAA;AAElD,EAAA,MAAM,KAAwB,CAAA,IAAA,KAAQ;AACpC,IAAA,MAAM,MAAA,GAAS,KAAK,IAAI,CAAA;AACxB,IAAA,IAAI,MAAA,EAAQ;AACV,MAAA,MAAM,WAAW,MAAA,CAAO,QAAA;AAExB,MAAA,MAAA,CAAO,QAAA,GAAW,QAAA,KAAa,MAAA,IAAa,CAAC,QAAA,CAAS,WAAW,GAAG,CAAA,GAAI,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAA,GAAK,QAAA;AAGzF,MAAA,MAAA,CAAO,SAAS,QAAA,KAAa,MAAA;AAAA,IAC/B;AACA,IAAA,OAAO,MAAA;AAAA,EACT,CAAA;AAEA,EAAA,OAAO,CAAC,MAAM,EAAE,CAAA;AAClB;AAQO,SAAS,UAAU,QAAA,EAAkD;AAC1E,EAAA,IAAI,CAAC,QAAA,EAAU;AACb,IAAA;AAAA,EACF;AAGA,EAAA,OAAO,QAAA,CAAS,UAAU,KAAK,CAAA;AACjC;AAGO,MAAM,kBAAA,GAAkC,iBAAA,CAAkB,sBAAA,CAAuB,SAAS,CAAC;;;;"}