/** * Copyright (c) Facebook, Inc. and its affiliates. * * MIT License * * Copyright (c) 2014-2019 Georg Tavonius * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * @emails oncall+recoil * @flow strict-local * @format */ // Adapted from https://github.com/errwischt/stacktrace-parser 'use strict'; export type Frame = { file: ?string, methodName: string, arguments: Array, lineNumber: ?number, column: ?number, }; const UNKNOWN_FUNCTION = ''; /** * This parses the different stack traces and puts them into one format * This borrows heavily from TraceKit (https://github.com/csnover/TraceKit) */ declare function stackTraceParser(stackString: string): Array; const chromeRe = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack||\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i; const chromeEvalRe = /\((\S*)(?::(\d+))(?::(\d+))\)/; declare function parseChrome(line: string): ?Frame; const winjsRe = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i; declare function parseWinjs(line: any): ?Frame; const geckoRe = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i; const geckoEvalRe = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i; declare function parseGecko(line: any): ?Frame; const javaScriptCoreRe = /^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i; declare function parseJSC(line: any): ?Frame; const nodeRe = /^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i; declare function parseNode(line: any): ?Frame; module.exports = stackTraceParser;