@visulima/error 3.2.11 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ ## @visulima/error [4.0.0](https://github.com/visulima/visulima/compare/@visulima/error@3.2.11...@visulima/error@4.0.0) (2024-06-16)
2
+
3
+ ### ⚠ BREAKING CHANGES
4
+
5
+ * **error:** moved source-map handling into a new package @visulima/source-map
6
+ Signed-off-by: prisis <d.bannert@anolilab.de>
7
+
8
+ Signed-off-by: prisis <d.bannert@anolilab.de>
9
+
10
+ ### Features
11
+
12
+ * **error:** removed source-map handling ([716ef11](https://github.com/visulima/visulima/commit/716ef11a054fd9405f58ba448a868054b5368b50))
13
+ * **source-map:** new source-map package ([d4114c6](https://github.com/visulima/visulima/commit/d4114c6e7cd73bacf14ba7d8df509507d8daa3ee))
14
+
15
+ ### Bug Fixes
16
+
17
+ * **error:** fixed new eval syntax on windows ([e50a816](https://github.com/visulima/visulima/commit/e50a8164d6b2f15818b77d67ac876bbe638bba8a))
18
+
19
+ ### Miscellaneous Chores
20
+
21
+ * **error:** added missing @visulima/path as dev dep ([c83d103](https://github.com/visulima/visulima/commit/c83d1035209a9b0f4674ede207918b403efc5fbf))
22
+ * **source-map:** moved fixtures from error to source-map ([664b287](https://github.com/visulima/visulima/commit/664b2870d4405fb27b65f7dc264b89f1bf29306d))
23
+ * updated all dev deps ([ef143ce](https://github.com/visulima/visulima/commit/ef143ce2e15952a0910aa5c8bd78d25de9ebd7f3))
24
+
25
+ ### Build System
26
+
27
+ * fixed found audit error, updated all dev package deps, updated deps in apps and examples ([4c51950](https://github.com/visulima/visulima/commit/4c519500dc5504579d35725572920658999885cb))
28
+
1
29
  ## @visulima/error [3.2.11](https://github.com/visulima/visulima/compare/@visulima/error@3.2.10...@visulima/error@3.2.11) (2024-06-06)
2
30
 
3
31
 
package/README.md CHANGED
@@ -228,29 +228,6 @@ console.log(stack);
228
228
  // ];
229
229
  ```
230
230
 
231
- ## Source Map
232
-
233
- ```ts
234
- import { loadSourceMap, originalPositionFor, sourceContentFor } from "@visulima/error";
235
-
236
- const sourceMap = loadSourceMap("your_path/src/index.js"); // returns a TraceMap
237
-
238
- const traced = originalPositionFor(sourceMap, { column: 13, line: 30 });
239
-
240
- console.log(traced);
241
-
242
- // {
243
- // column: 9,
244
- // line: 15,
245
- // name: "setState",
246
- // source: "your_path/src/index.js"
247
- // }
248
-
249
- console.log(sourceContentFor(sourceMap, traced.source)); // 'content for your_path/src/index.js'
250
- ```
251
-
252
- For more information about the TraceMap see [@jridgewell/trace-mapping](https://github.com/jridgewell/trace-mapping)
253
-
254
231
  ## Supported Node.js Versions
255
232
 
256
233
  Libraries in this ecosystem make the best effort to track [Node.js’ release schedule](https://github.com/nodejs/release#release-schedule).
@@ -0,0 +1,6 @@
1
+ var u=(s,...e)=>{process.env.DEBUG&&String(process.env.DEBUG)==="true"&&console.debug(`error:parse-stacktrace: ${s}`,...e);},f="<unknown>",T=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,v=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,N=/(.*?):(\d+):(\d+)(\s<-\s(.+):(\d+):(\d+))?/,$=/(eval)\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*(<anonymous>)?:(\d+)?:(\d+)/,x=/^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/,b=/in\s(.*)\s\(at\s(.+)\)\sat/,O=/^(?:.*@)?(.*):(\d+):(\d+)$/,R=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,S=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,_=/(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/,p=/\(error: (.*)\)/,m=(s,e)=>{let n=s.includes("safari-extension"),i=s.includes("safari-web-extension");return n||i?[s.includes("@")?s.split("@")[0]:f,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[s,e]},E=(s,e)=>{let n=N.exec(e);n&&(s.file=n[1],s.line=+n[2],s.column=+n[3]);},h=s=>{let e=b.exec(s);if(e){u(`parse nested node error stack line: "${s}"`,`found: ${JSON.stringify(e)}`);let i=e[2].split(":");return {column:i[2]?+i[2]:void 0,file:i[0],line:i[1]?+i[1]:void 0,methodName:e[1]||f,raw:s,type:void 0}}let n=x.exec(s);if(n){u(`parse node error stack line: "${s}"`,`found: ${JSON.stringify(n)}`);let i={column:n[4]?+n[4]:void 0,file:n[2]?n[2].replace(/at\s/,""):void 0,line:n[3]?+n[3]:void 0,methodName:n[1]||f,raw:s,type:s.startsWith("internal")?"internal":void 0};return E(i,`${n[2]}:${n[3]}:${n[4]}`),i}},w=s=>{let e=T.exec(s);if(e){u(`parse chrome error stack line: "${s}"`,`found: ${JSON.stringify(e)}`);let n=e[2]&&e[2].startsWith("native"),i=e[2]&&e[2].startsWith("eval")||e[1]&&e[1].startsWith("eval"),r,t;if(i){let c=v.exec(s);if(c){let a=/(\S+):(\d+):(\d+)|(\S+):(\d+)$/.exec(c[1]);a?(e[2]=a[4]??a[1],e[3]=a[5]??a[2],e[4]=a[3]):c[2]&&(e[2]=c[1]),c[2]&&(r={column:c[4]?+c[4]:void 0,file:c[2],line:c[3]?+c[3]:void 0,methodName:"eval",raw:s,type:"eval"});}else {let a=$.exec(s);a&&(t={column:a[5]?+a[5]:void 0,file:a[3],line:a[4]?+a[4]:void 0},r={column:a[8]?+a[8]:void 0,file:a[2],line:a[7]?+a[7]:void 0,methodName:"eval",raw:a[0],type:"eval"});}}let[l,o]=m(e[1]?e[1].replace(/^Anonymous function$/,"<anonymous>"):f,e[2]),d={column:e[4]?+e[4]:void 0,evalOrigin:r,file:o,line:e[3]?+e[3]:void 0,methodName:l,raw:s,type:i?"eval":n?"native":void 0};return t?(d.column=t.column,d.file=t.file,d.line=t.line):E(d,`${o}:${e[3]}:${e[4]}`),d}},G=(s,e)=>{let n=R.exec(s);if(n){u(`parse gecko error stack line: "${s}"`,`found: ${JSON.stringify(n)}`);let i=n[3]?.includes(" > eval"),r=i&&n[3]&&S.exec(n[3]),t;i&&r&&(n[3]=r[1],t={column:n[5]?+n[5]:void 0,file:n[3],line:n[4]?+n[4]:void 0,methodName:"eval",raw:s,type:"eval"},n[4]=r[2]);let[l,o]=m(n[1]?n[1].replace(/^Anonymous function$/,"<anonymous>"):f,n[3]),d;(e?.type==="safari"||!i&&e?.type==="firefox")&&e.column?d=e.column:!i&&n[5]&&(d=+n[5]);let c;return (e?.type==="safari"||!i&&e?.type==="firefox")&&e.line?c=e.line:n[4]&&(c=+n[4]),{column:d,evalOrigin:t,file:o,line:c,methodName:l,raw:s,type:i?"eval":o.includes("[native code]")?"native":void 0}}},k=(s,e)=>{let n=_.exec(s);if(!(n?n[2].includes(" > eval"):!1)&&n)return u(`parse firefox error stack line: "${s}"`,`found: ${JSON.stringify(n)}`),{column:n[4]?+n[4]:e?.column??void 0,file:n[2],line:n[3]?+n[3]:e?.line??void 0,methodName:n[1]||f,raw:s,type:void 0}},A=s=>{let e=O.exec(s);if(e)return u(`parse react android native error stack line: "${s}"`,`found: ${JSON.stringify(e)}`),{column:e[3]?+e[3]:void 0,file:e[1],line:e[2]?+e[2]:void 0,methodName:f,raw:s,type:void 0}},X=(s,e={})=>{let{frameLimit:n=50}=e,i=(s.stacktrace??s.stack??"").split(`
2
+ `).map(r=>(p.test(r)?r.replace(p,"$1"):r).replace(/^\s+|\s+$/g,"")).filter(r=>!/\S*Error: /.test(r)&&r!=="eval code");return i.length>n&&(i=i.slice(0,n)),i.reduce((r,t,l)=>{if(!t||t.length>1024)return r;let o;if(/^\s*in\s.*/.test(t))o=h(t);else if(/^.*?\s*at\s.*/.test(t))o=w(t);else if(/^.*?\s*@.*|\[native code\]/.test(t)){let d;l===0&&(s.columnNumber||s.lineNumber?d={column:s.columnNumber,line:s.lineNumber,type:"firefox"}:(s.line||s.column)&&(d={column:s.column,line:s.line,type:"safari"})),o=k(t,d)||G(t,d);}else o=A(t);return o?r.push(o):u(`parse error stack line: "${t}"`,"not parser found"),r},[])},D=X;
3
+
4
+ export { D as a };
5
+ //# sourceMappingURL=out.js.map
6
+ //# sourceMappingURL=chunk-WOVTAVVR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/stacktrace/parse-stacktrace.ts"],"names":["debugLog","message","arguments_","UNKNOWN_FUNCTION","CHROMIUM_REGEX","CHROMIUM_EVAL_REGEX","CHROMIUM_MAPPED","WINDOWS_EVAL_REGEX","NODE_REGEX","NODE_NESTED_REGEX","REACT_ANDROID_NATIVE_REGEX","GECKO_REGEX","GECKO_EVAL_REGEX","FIREFOX_REGEX","WEBPACK_ERROR_REGEXP","extractSafariExtensionDetails","methodName","url","isSafariExtension","isSafariWebExtension","parseMapped","trace","maybeMapped","match","parseNode","line","nestedNode","split","node","parseChromium","parts","isNative","isEval","evalOrigin","windowsParts","subMatch","windowsSubMatch","file","parseGecko","topFrameMeta","column","lineNumber","parseFirefox","parseReactAndroidNative","parse","error","options","frameLimit","lines","stack","currentIndex","parseResult","parse_stacktrace_default"],"mappings":"AAQA,IAAMA,EAAW,CAACC,KAAoBC,IAAgC,CAC9D,QAAQ,IAAI,OAAS,OAAO,QAAQ,IAAI,KAAK,IAAM,QAEnD,QAAQ,MAAM,2BAA2BD,CAAO,GAAI,GAAGC,CAAU,CAEzE,EAEMC,EAAmB,YAsBnBC,EAEF,yJAEEC,EAAsB,0CAItBC,EAAkB,6CAIlBC,EAAqB,qFAIrBC,EAAa,qFACbC,EAAoB,6BAG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ChC0B,EAActB,EAAcJ,CAAI,UAEzB,6BAA6B,KAAKA,CAAI,EAAG,CAChD,IAAIc,EAEAW,IAAiB,IAEbL,EAAM,cAAgBA,EAAM,WAC5BN,EAAe,CAEX,OAAQM,EAAM,aAEd,KAAMA,EAAM,WACZ,KAAM,SACV,GAEOA,EAAM,MAAQA,EAAM,UAC3BN,EAAe,CAEX,OAAQM,EAAM,OAEd,KAAMA,EAAM,KACZ,KAAM,QACV,IAIRM,EAEIT,EAAajB,EAAMc,CAAY,GAAKD,EAAWb,EAAMc,CAAY,CACzE,MACIY,EAAcR,EAAwBlB,CAAI,EAG9C,OAAI0B,EACAF,EAAM,KAAKE,CAAW,EAEtBnD,EAAS,4BAA4ByB,CAAI,IAAK,kBAAkB,EAG7DwB,CACX,EAAG,CAAC,CAAC,CACT,EAEOG,EAAQR","sourcesContent":["import type { Trace, TraceType } from \"./types\";\n\ntype TopFrameMeta = {\n column?: number;\n line?: number;\n type: \"firefox\" | \"safari\";\n};\n\nconst debugLog = (message: string, ...arguments_: unknown[]): void => {\n if (process.env.DEBUG && String(process.env.DEBUG) === \"true\") {\n // eslint-disable-next-line no-console\n console.debug(`error:parse-stacktrace: ${message}`, ...arguments_);\n }\n};\n\nconst UNKNOWN_FUNCTION = \"<unknown>\";\n\n// at <SomeFramework>\n// at <SomeFramework>:123:39\n// -----------------\n// at about:blank:1:7\n// at index.js:23\n// >= Chrome 99\n// at /projects/foo.test.js:689:1 <- /projects/foo.test.js:10:1\n// -----------------\n// at bar (<anonymous>:1:19 <- <anonymous>:2:3)\n// -----------------\n// at foo.bar(bob) (foo.bar.js:123:39)\n// at foo.bar(bob) (foo.bar.js:123:39 <- original.js:123:34)\n// -----------------\n// >= Chrome 88\n// spy() at Component.Foo [as constructor] (original.js:123:34)\n// spy() at Component.Foo [as constructor] (foo.bar.js:123:39 <- original.js:123:34)\n// -----------------\n// at Module.load (internal/modules/cjs/loader.js:641:32)\n// -----------------\n// Chromium based browsers: Chrome, Brave, new Opera, new Edge\nconst CHROMIUM_REGEX =\n // eslint-disable-next-line security/detect-unsafe-regex,regexp/no-super-linear-backtracking\n /^.*?\\s*at\\s(?:(.+?\\)(?:\\s\\[.+\\])?|\\(?.*?)\\s?\\((?:address\\sat\\s)?)?(?:async\\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\\/)?.*?)(?::(\\d+))?(?::(\\d+))?\\)?\\s*$/i;\n// eslint-disable-next-line security/detect-unsafe-regex\nconst CHROMIUM_EVAL_REGEX = /\\((\\S+)\\),\\s(<[^>]+>)?:(\\d+)?:(\\d+)?\\)?/;\n// foo.bar.js:123:39\n// foo.bar.js:123:39 <- original.js:123:34\n// eslint-disable-next-line security/detect-unsafe-regex,regexp/no-unused-capturing-group\nconst CHROMIUM_MAPPED = /(.*?):(\\d+):(\\d+)(\\s<-\\s(.+):(\\d+):(\\d+))?/;\n\n// eval at <anonymous> (C:\\\\Users\\\\user\\\\project\\\\visulima\\\\packages\\\\error\\\\__tests__\\\\stacktrace\\\\parse-stacktrace.test.ts\n// eslint-disable-next-line regexp/optimal-quantifier-concatenation,regexp/no-unused-capturing-group,security/detect-unsafe-regex\nconst WINDOWS_EVAL_REGEX = /(eval)\\sat\\s(<anonymous>)\\s\\((.*)\\)?:(\\d+)?:(\\d+)\\),\\s*(<anonymous>)?:(\\d+)?:(\\d+)/;\n\n// in AppProviders (at App.tsx:28)\n// eslint-disable-next-line security/detect-unsafe-regex\nconst NODE_REGEX = /^\\s*in\\s(?:([^\\\\/]+(?:\\s\\[as\\s\\S+\\])?)\\s\\(?)?\\(at?\\s?(.*?):(\\d+)(?::(\\d+))?\\)?\\s*$/;\nconst NODE_NESTED_REGEX = /in\\s(.*)\\s\\(at\\s(.+)\\)\\sat/;\n\n// eslint-disable-next-line security/detect-unsafe-regex,regexp/no-super-linear-backtracking\nconst REACT_ANDROID_NATIVE_REGEX = /^(?:.*@)?(.*):(\\d+):(\\d+)$/;\n\n// gecko regex: `(?:bundle|\\d+\\.js)`: `bundle` is for react native, `\\d+\\.js` also but specifically for ram bundles because it\n// generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js\n// We need this specific case for now because we want no other regex to match.\n// eslint-disable-next-line regexp/no-super-linear-backtracking,security/detect-unsafe-regex,regexp/no-optional-assertion,regexp/no-trivially-nested-quantifier,regexp/no-useless-escape,no-useless-escape,regexp/optimal-quantifier-concatenation\nconst GECKO_REGEX = /^\\s*(.*?)(?:\\((.*?)\\))?(?:^|@)?((?:[-a-z]+)?:\\/.*?|\\[native code\\]|[^@]*(?:bundle|\\d+\\.js)|\\/[\\w\\-. \\/=]+)(?::(\\d+))?(?::(\\d+))?\\s*$/i;\n// eslint-disable-next-line security/detect-unsafe-regex\nconst GECKO_EVAL_REGEX = /(\\S+) line (\\d+)(?: > eval line \\d+)* > eval/i;\n\n// @http://localhost:8080/file.js:33:9\n// foo@debugger eval code:1:27\n// obj[\"@fn\"]@Scratchpad/1:10:29\n// eslint-disable-next-line regexp/no-super-linear-backtracking\nconst FIREFOX_REGEX = /(\\S[^\\s[]*\\[.*\\]|.*?)@(.*):(\\d+):(\\d+)/;\n\n// Used to sanitize webpack (error: *) wrapped stack errors\nconst WEBPACK_ERROR_REGEXP = /\\(error: (.*)\\)/;\n\n/**\n * Safari web extensions, starting version unknown, can produce \"frames-only\" stacktraces.\n * What it means, is that instead of format like:\n *\n * Error: wat\n * at function@url:row:col\n * at function@url:row:col\n * at function@url:row:col\n *\n * it produces something like:\n *\n * function@url:row:col\n * function@url:row:col\n * function@url:row:col\n *\n * Because of that, it won't be captured by `chrome` RegExp and will fall into `Gecko` branch.\n * This function is extracted so that we can use it in both places without duplicating the logic.\n * Unfortunately \"just\" changing RegExp is too complicated now and making it pass all tests\n * and fix this case seems like an impossible, or at least way too time-consuming task.\n */\nconst extractSafariExtensionDetails = (methodName: string, url: string): [string, string] => {\n const isSafariExtension = methodName.includes(\"safari-extension\");\n const isSafariWebExtension = methodName.includes(\"safari-web-extension\");\n\n return isSafariExtension || isSafariWebExtension\n ? [\n methodName.includes(\"@\") ? (methodName.split(\"@\")[0] as string) : UNKNOWN_FUNCTION,\n isSafariExtension ? `safari-extension:${url}` : `safari-web-extension:${url}`,\n ]\n : [methodName, url];\n};\n\nconst parseMapped = (trace: Trace, maybeMapped: string) => {\n const match = CHROMIUM_MAPPED.exec(maybeMapped);\n\n if (match) {\n // eslint-disable-next-line no-param-reassign,prefer-destructuring\n trace.file = match[1];\n // eslint-disable-next-line no-param-reassign\n trace.line = +(<string>match[2]);\n // eslint-disable-next-line no-param-reassign\n trace.column = +(<string>match[3]);\n }\n};\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst parseNode = (line: string): Trace | undefined => {\n const nestedNode = NODE_NESTED_REGEX.exec(line);\n\n if (nestedNode) {\n debugLog(`parse nested node error stack line: \"${line}\"`, `found: ${JSON.stringify(nestedNode)}`);\n\n const split = (nestedNode[2] as string).split(\":\");\n\n return {\n column: split[2] ? +split[2] : undefined,\n file: split[0],\n line: split[1] ? +split[1] : undefined,\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n methodName: nestedNode[1] || UNKNOWN_FUNCTION,\n raw: line,\n type: undefined,\n };\n }\n\n const node = NODE_REGEX.exec(line);\n\n if (node) {\n debugLog(`parse node error stack line: \"${line}\"`, `found: ${JSON.stringify(node)}`);\n\n const trace = {\n column: node[4] ? +node[4] : undefined,\n file: node[2] ? node[2].replace(/at\\s/, \"\") : undefined,\n line: node[3] ? +node[3] : undefined,\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n methodName: node[1] || UNKNOWN_FUNCTION,\n raw: line,\n type: line.startsWith(\"internal\") ? (\"internal\" as TraceType) : undefined,\n };\n\n parseMapped(trace, `${node[2]}:${node[3]}:${node[4]}`);\n\n return trace;\n }\n\n return undefined;\n};\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst parseChromium = (line: string): Trace | undefined => {\n const parts = CHROMIUM_REGEX.exec(line) as (string | undefined)[] | null;\n\n if (parts) {\n debugLog(`parse chrome error stack line: \"${line}\"`, `found: ${JSON.stringify(parts)}`);\n\n const isNative = parts[2] && parts[2].startsWith(\"native\"); // start of line\n const isEval = (parts[2] && parts[2].startsWith(\"eval\")) || (parts[1] && parts[1].startsWith(\"eval\")); // start of line\n\n let evalOrigin: Trace | undefined;\n let windowsParts:\n | {\n column: number | undefined;\n file: string | undefined;\n line: number | undefined;\n }\n | undefined;\n\n if (isEval) {\n const subMatch = CHROMIUM_EVAL_REGEX.exec(line);\n\n if (subMatch) {\n // can be index.js:123:39 or index.js:123 or index.js\n const split = /(\\S+):(\\d+):(\\d+)|(\\S+):(\\d+)$/.exec(subMatch[1] as string);\n\n if (split) {\n // throw out eval line/column and use top-most line/column number\n parts[2] = split[4] ?? split[1]; // url\n parts[3] = split[5] ?? split[2]; // line\n // eslint-disable-next-line prefer-destructuring\n parts[4] = split[3]; // column\n } else if (subMatch[2]) {\n // eslint-disable-next-line prefer-destructuring\n parts[2] = subMatch[1];\n }\n\n if (subMatch[2]) {\n evalOrigin = {\n column: subMatch[4] ? +subMatch[4] : undefined,\n file: subMatch[2],\n line: subMatch[3] ? +subMatch[3] : undefined,\n methodName: \"eval\",\n raw: line,\n type: \"eval\" as TraceType,\n };\n }\n } else {\n const windowsSubMatch = WINDOWS_EVAL_REGEX.exec(line);\n\n if (windowsSubMatch) {\n windowsParts = {\n column: windowsSubMatch[5] ? +windowsSubMatch[5] : undefined,\n file: windowsSubMatch[3],\n line: windowsSubMatch[4] ? +windowsSubMatch[4] : undefined,\n };\n\n evalOrigin = {\n column: windowsSubMatch[8] ? +windowsSubMatch[8] : undefined,\n file: windowsSubMatch[2],\n line: windowsSubMatch[7] ? +windowsSubMatch[7] : undefined,\n methodName: \"eval\",\n raw: windowsSubMatch[0],\n type: \"eval\" as TraceType,\n };\n }\n }\n }\n\n const [methodName, file] = extractSafariExtensionDetails(\n // Normalize IE's 'Anonymous function'\n parts[1] ? parts[1].replace(/^Anonymous function$/, \"<anonymous>\") : UNKNOWN_FUNCTION,\n parts[2] as string,\n );\n\n const trace = {\n column: parts[4] ? +parts[4] : undefined,\n evalOrigin,\n file,\n line: parts[3] ? +parts[3] : undefined,\n methodName,\n raw: line,\n type: (isEval ? \"eval\" : isNative ? \"native\" : undefined) as TraceType,\n };\n\n if (windowsParts) {\n trace.column = windowsParts.column;\n trace.file = windowsParts.file as string;\n trace.line = windowsParts.line;\n } else {\n parseMapped(trace, `${file}:${parts[3]}:${parts[4]}`);\n }\n\n return trace;\n }\n\n return undefined;\n};\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst parseGecko = (line: string, topFrameMeta?: TopFrameMeta): Trace | undefined => {\n const parts = GECKO_REGEX.exec(line);\n\n if (parts) {\n debugLog(`parse gecko error stack line: \"${line}\"`, `found: ${JSON.stringify(parts)}`);\n\n const isEval = parts[3]?.includes(\" > eval\");\n const subMatch = isEval && parts[3] && GECKO_EVAL_REGEX.exec(parts[3]);\n\n let evalOrigin: Trace | undefined;\n\n if (isEval && subMatch) {\n // overwrite file\n parts[3] = <string>subMatch[1];\n\n evalOrigin = {\n column: parts[5] ? +parts[5] : undefined,\n file: parts[3],\n line: parts[4] ? +parts[4] : undefined,\n methodName: \"eval\",\n raw: line,\n type: \"eval\" as TraceType,\n };\n\n // overwrite line\n parts[4] = <string>subMatch[2];\n }\n\n const [methodName, file] = extractSafariExtensionDetails(\n // Normalize IE's 'Anonymous function'\n parts[1] ? parts[1].replace(/^Anonymous function$/, \"<anonymous>\") : UNKNOWN_FUNCTION,\n parts[3] as string,\n );\n\n let column: number | undefined; // no column when eval\n\n if ((topFrameMeta?.type === \"safari\" || (!isEval && topFrameMeta?.type === \"firefox\")) && topFrameMeta.column) {\n column = topFrameMeta.column;\n } else if (!isEval && parts[5]) {\n column = +parts[5];\n }\n\n let lineNumber: number | undefined; // no line when eval\n\n if ((topFrameMeta?.type === \"safari\" || (!isEval && topFrameMeta?.type === \"firefox\")) && topFrameMeta.line) {\n lineNumber = topFrameMeta.line;\n } else if (parts[4]) {\n lineNumber = +parts[4];\n }\n\n return {\n column,\n evalOrigin,\n file,\n line: lineNumber,\n methodName,\n raw: line,\n type: isEval ? \"eval\" : file.includes(\"[native code]\") ? \"native\" : undefined,\n };\n }\n\n return undefined;\n};\n\nconst parseFirefox = (line: string, topFrameMeta?: TopFrameMeta): Trace | undefined => {\n const parts = FIREFOX_REGEX.exec(line);\n\n const isEval = parts ? (parts[2] as string).includes(\" > eval\") : false;\n\n if (!isEval && parts) {\n debugLog(`parse firefox error stack line: \"${line}\"`, `found: ${JSON.stringify(parts)}`);\n\n return {\n column: parts[4] ? +parts[4] : topFrameMeta?.column ?? undefined,\n file: parts[2],\n line: parts[3] ? +parts[3] : topFrameMeta?.line ?? undefined,\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n methodName: parts[1] || UNKNOWN_FUNCTION,\n raw: line,\n type: undefined,\n };\n }\n\n return undefined;\n};\n\nconst parseReactAndroidNative = (line: string): Trace | undefined => {\n const parts = REACT_ANDROID_NATIVE_REGEX.exec(line);\n\n if (parts) {\n debugLog(`parse react android native error stack line: \"${line}\"`, `found: ${JSON.stringify(parts)}`);\n\n return {\n column: parts[3] ? +parts[3] : undefined,\n file: parts[1],\n line: parts[2] ? +parts[2] : undefined,\n methodName: UNKNOWN_FUNCTION,\n raw: line,\n type: undefined,\n };\n }\n\n return undefined;\n};\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst parse = (error: Error, options: Partial<{ frameLimit: number }> = {}): Trace[] => {\n const { frameLimit = 50 } = options;\n\n // @ts-expect-error missing stacktrace property\n let lines = (error.stacktrace ?? error.stack ?? \"\")\n .split(\"\\n\")\n .map((line: string): string => {\n // https://github.com/getsentry/sentry-javascript/issues/5459\n // Remove webpack (error: *) wrappers\n const cleanedLine = WEBPACK_ERROR_REGEXP.test(line) ? line.replace(WEBPACK_ERROR_REGEXP, \"$1\") : line;\n\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n return cleanedLine.replace(/^\\s+|\\s+$/g, \"\");\n })\n // https://github.com/getsentry/sentry-javascript/issues/7813\n // Skip Error: lines\n // Skip eval code without more context\n .filter((line: string): boolean => !/\\S*Error: /.test(line) && line !== \"eval code\");\n\n if (lines.length > frameLimit) {\n lines = lines.slice(0, frameLimit);\n }\n\n // eslint-disable-next-line unicorn/no-array-reduce,@typescript-eslint/no-unsafe-return\n return lines.reduce((stack: Trace[], line: string, currentIndex: number): Trace[] => {\n if (!line) {\n return stack;\n }\n\n // Ignore lines over 1kb as they are unlikely to be stack frames.\n // Many of the regular expressions use backtracking which results in run time that increases exponentially with\n // input size. Huge strings can result in hangs/Denial of Service:\n // https://github.com/getsentry/sentry-javascript/issues/2286\n if (line.length > 1024) {\n return stack;\n }\n\n let parseResult: Trace | undefined;\n\n if (/^\\s*in\\s.*/.test(line)) {\n parseResult = parseNode(line);\n // eslint-disable-next-line regexp/no-super-linear-backtracking\n } else if (/^.*?\\s*at\\s.*/.test(line)) {\n parseResult = parseChromium(line);\n // eslint-disable-next-line regexp/no-super-linear-backtracking\n } else if (/^.*?\\s*@.*|\\[native code\\]/.test(line)) {\n let topFrameMeta: TopFrameMeta | undefined;\n\n if (currentIndex === 0) {\n // @ts-expect-error columnNumber and lineNumber property only exists on Firefox\n if (error.columnNumber || error.lineNumber) {\n topFrameMeta = {\n // @ts-expect-error columnNumber and columnNumber property only exists on Firefox\n column: error.columnNumber,\n // @ts-expect-error columnNumber and lineNumber property only exists on Firefox\n line: error.lineNumber,\n type: \"firefox\",\n };\n // @ts-expect-error line and column property only exists on safari\n } else if (error.line || error.column) {\n topFrameMeta = {\n // @ts-expect-error column property only exists on safari\n column: error.column,\n // @ts-expect-error line property only exists on safari\n line: error.line,\n type: \"safari\",\n };\n }\n }\n\n parseResult =\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n parseFirefox(line, topFrameMeta) || parseGecko(line, topFrameMeta);\n } else {\n parseResult = parseReactAndroidNative(line);\n }\n\n if (parseResult) {\n stack.push(parseResult);\n } else {\n debugLog(`parse error stack line: \"${line}\"`, \"not parser found\");\n }\n\n return stack;\n }, []);\n};\n\nexport default parse;\n"]}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  export { CODE_FRAME_POINTER, CodeFrameLocation, CodeFrameNodeLocation, CodeFrameOptions, ColorizeMethod, codeFrame } from './code-frame/index.js';
2
2
  export { ErrorHint, ErrorLocation, ErrorProperties, VisulimaError, getErrorCauses, isVisulimaError } from './error/index.js';
3
- export { loadSourceMap } from './sourcemap/index.js';
4
- export { TraceMap, generatedPositionFor, originalPositionFor, sourceContentFor, traceSegment } from '@jridgewell/trace-mapping';
5
3
  export { Trace, TraceType, parseStacktrace } from './stacktrace/index.js';
6
4
 
7
5
  declare const indexToLineColumn: (input: number[] | string, index: number, options?: {
package/dist/index.js CHANGED
@@ -1,10 +1,9 @@
1
1
  export { a as CODE_FRAME_POINTER, b as codeFrame } from './chunk-BKLPSU5H.js';
2
2
  export { c as VisulimaError, a as getErrorCauses, b as isVisulimaError } from './chunk-HAVTTG7L.js';
3
- export { b as generatedPositionFor, a as loadSourceMap, c as originalPositionFor, d as sourceContentFor, e as traceSegment } from './chunk-D22N6ARA.js';
4
- export { a as parseStacktrace } from './chunk-ZMWUTAJM.js';
3
+ export { a as parseStacktrace } from './chunk-WOVTAVVR.js';
5
4
 
6
- var m=(r,e)=>{let o=0,t=e.length-2;for(;o<t;){let n=o+(t-o>>1);if(r<e[n])t=n-1;else if(r>=e[n+1])o=n+1;else {o=n;break}}return o},E=r=>r.split(/\n|\r(?!\n)/).reduce((e,o)=>(e.push(e.at(-1)+o.length+1),e),[0]),x=(r,e,o)=>{let t=o?.skipChecks??!1;if(!t&&(!Array.isArray(r)&&typeof r!="string"||(typeof r=="string"||Array.isArray(r))&&r.length===0))return {column:0,line:0};if(!t&&(typeof e!="number"||typeof r=="string"&&e>=r.length||Array.isArray(r)&&e+1>=r.at(-1)))return {column:0,line:0};if(typeof r=="string"){let s=E(r),a=m(e,s);return {column:e-s[a]+1,line:a+1}}let n=m(e,r);return {column:e-r[n]+1,line:n+1}},F=x;
5
+ var m=(r,e)=>{let o=0,t=e.length-2;for(;o<t;){let n=o+(t-o>>1);if(r<e[n])t=n-1;else if(r>=e[n+1])o=n+1;else {o=n;break}}return o},g=r=>r.split(/\n|\r(?!\n)/).reduce((e,o)=>(e.push(e.at(-1)+o.length+1),e),[0]),h=(r,e,o)=>{let t=o?.skipChecks??!1;if(!t&&(!Array.isArray(r)&&typeof r!="string"||(typeof r=="string"||Array.isArray(r))&&r.length===0))return {column:0,line:0};if(!t&&(typeof e!="number"||typeof r=="string"&&e>=r.length||Array.isArray(r)&&e+1>=r.at(-1)))return {column:0,line:0};if(typeof r=="string"){let s=g(r),a=m(e,s);return {column:e-s[a]+1,line:a+1}}let n=m(e,r);return {column:e-r[n]+1,line:n+1}},C=h;
7
6
 
8
- export { F as indexToLineColumn };
7
+ export { C as indexToLineColumn };
9
8
  //# sourceMappingURL=out.js.map
10
9
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/code-frame/index-to-line-column.ts"],"names":["binarySearch","element","array","m","n","key","getLineStartIndexes","string_","accumulator","current","indexToLineColumn","input","index","options","skipChecks","startIndexesOfEachLine","line","index_to_line_column_default"],"mappings":"iNAAA,IAAMA,EAAe,CAACC,EAAiBC,IAA4B,CAC/D,IAAIC,EAAI,EACJC,EAAIF,EAAM,OAAS,EAGvB,KAAOC,EAAIC,GAAG,CAEV,IAAMC,EAAMF,GAAMC,EAAID,GAAM,GAE5B,GAAIF,EAAWC,EAAMG,CAAG,EACpBD,EAAIC,EAAM,UACHJ,GAAYC,EAAMG,EAAM,CAAC,EAChCF,EAAIE,EAAM,MACP,CACHF,EAAIE,EACJ,KACJ,CACJ,CAEA,OAAOF,CACX,EAIMG,EAAuBC,GAEzBA,EAAQ,MAAM,aAAa,EAAE,OACzB,CAACC,EAAuBC,KACpBD,EAAY,KAAMA,EAAY,GAAG,EAAE,EAAeC,EAAQ,OAAS,CAAC,EAE7DD,GAEX,CAAC,CAAC,CACN,EAEEE,EAAoB,CACtBC,EACAC,EACAC,IAMC,CACD,IAAMC,EAAaD,GAAS,YAAc,GAE1C,GAAI,CAACC,IAAgB,CAAC,MAAM,QAAQH,CAAK,GAAK,OAAOA,GAAU,WAAe,OAAOA,GAAU,UAAY,MAAM,QAAQA,CAAK,IAAMA,EAAM,SAAW,GACjJ,MAAO,CAAE,OAAQ,EAAG,KAAM,CAAE,EAGhC,GACI,CAACG,IACA,OAAOF,GAAU,UAAa,OAAOD,GAAU,UAAYC,GAASD,EAAM,QAAY,MAAM,QAAQA,CAAK,GAAKC,EAAQ,GAAMD,EAAM,GAAG,EAAE,GAExI,MAAO,CAAE,OAAQ,EAAG,KAAM,CAAE,EAIhC,GAAI,OAAOA,GAAU,SAAU,CAE3B,IAAMI,EAAyBT,EAAoBK,CAAK,EAClDK,EAAOhB,EAAaY,EAAOG,CAAsB,EAEvD,MAAO,CAEH,OAAQH,EAASG,EAAuBC,CAAI,EAAe,EAC3D,KAAMA,EAAO,CACjB,CACJ,CAGA,IAAMA,EAAOhB,EAAaY,EAAOD,CAAK,EAEtC,MAAO,CAEH,OAAQC,EAASD,EAAMK,CAAI,EAAe,EAC1C,KAAMA,EAAO,CACjB,CACJ,EAEOC,EAAQP","sourcesContent":["const binarySearch = (element: number, array: number[]): number => {\n let m = 0;\n let n = array.length - 2;\n\n // eslint-disable-next-line no-loops/no-loops\n while (m < n) {\n // eslint-disable-next-line no-bitwise\n const key = m + ((n - m) >> 1);\n // eslint-disable-next-line security/detect-object-injection\n if (element < (array[key] as number)) {\n n = key - 1;\n } else if (element >= (array[key + 1] as number)) {\n m = key + 1;\n } else {\n m = key;\n break;\n }\n }\n\n return m;\n};\n\n// split by line break characters, CR, LF or CRLF\n// compile an array of indexes, where each line starts\nconst getLineStartIndexes = (string_: string): number[] =>\n // eslint-disable-next-line unicorn/no-array-reduce\n string_.split(/\\n|\\r(?!\\n)/).reduce(\n (accumulator: number[], current) => {\n accumulator.push((accumulator.at(-1) as number) + current.length + 1);\n\n return accumulator;\n },\n [0],\n );\n\nconst indexToLineColumn = (\n input: number[] | string,\n index: number,\n options?: {\n skipChecks: boolean;\n },\n): {\n column: number;\n line: number;\n} => {\n const skipChecks = options?.skipChecks ?? false;\n\n if (!skipChecks && ((!Array.isArray(input) && typeof input !== \"string\") || ((typeof input === \"string\" || Array.isArray(input)) && input.length === 0))) {\n return { column: 0, line: 0 };\n }\n\n if (\n !skipChecks &&\n (typeof index !== \"number\" || (typeof input === \"string\" && index >= input.length) || (Array.isArray(input) && index + 1 >= (input.at(-1) as number)))\n ) {\n return { column: 0, line: 0 };\n }\n\n // it depends, pre-cached input was given or a string\n if (typeof input === \"string\") {\n // not cached - calculate the line start indexes\n const startIndexesOfEachLine = getLineStartIndexes(input);\n const line = binarySearch(index, startIndexesOfEachLine);\n\n return {\n // eslint-disable-next-line security/detect-object-injection\n column: index - (startIndexesOfEachLine[line] as number) + 1,\n line: line + 1,\n };\n }\n\n // ELSE - cached line start indexes - we don't even need the string source!\n const line = binarySearch(index, input);\n\n return {\n // eslint-disable-next-line security/detect-object-injection\n column: index - (input[line] as number) + 1,\n line: line + 1,\n };\n};\n\nexport default indexToLineColumn;\n"]}
1
+ {"version":3,"sources":["../src/code-frame/index-to-line-column.ts"],"names":["binarySearch","element","array","m","n","key","getLineStartIndexes","string_","accumulator","current","indexToLineColumn","input","index","options","skipChecks","startIndexesOfEachLine","line","index_to_line_column_default"],"mappings":"6IAAA,IAAMA,EAAe,CAACC,EAAiBC,IAA4B,CAC/D,IAAIC,EAAI,EACJC,EAAIF,EAAM,OAAS,EAGvB,KAAOC,EAAIC,GAAG,CAEV,IAAMC,EAAMF,GAAMC,EAAID,GAAM,GAE5B,GAAIF,EAAWC,EAAMG,CAAG,EACpBD,EAAIC,EAAM,UACHJ,GAAYC,EAAMG,EAAM,CAAC,EAChCF,EAAIE,EAAM,MACP,CACHF,EAAIE,EACJ,KACJ,CACJ,CAEA,OAAOF,CACX,EAIMG,EAAuBC,GAEzBA,EAAQ,MAAM,aAAa,EAAE,OACzB,CAACC,EAAuBC,KACpBD,EAAY,KAAMA,EAAY,GAAG,EAAE,EAAeC,EAAQ,OAAS,CAAC,EAE7DD,GAEX,CAAC,CAAC,CACN,EAEEE,EAAoB,CACtBC,EACAC,EACAC,IAMC,CACD,IAAMC,EAAaD,GAAS,YAAc,GAE1C,GAAI,CAACC,IAAgB,CAAC,MAAM,QAAQH,CAAK,GAAK,OAAOA,GAAU,WAAe,OAAOA,GAAU,UAAY,MAAM,QAAQA,CAAK,IAAMA,EAAM,SAAW,GACjJ,MAAO,CAAE,OAAQ,EAAG,KAAM,CAAE,EAGhC,GACI,CAACG,IACA,OAAOF,GAAU,UAAa,OAAOD,GAAU,UAAYC,GAASD,EAAM,QAAY,MAAM,QAAQA,CAAK,GAAKC,EAAQ,GAAMD,EAAM,GAAG,EAAE,GAExI,MAAO,CAAE,OAAQ,EAAG,KAAM,CAAE,EAIhC,GAAI,OAAOA,GAAU,SAAU,CAE3B,IAAMI,EAAyBT,EAAoBK,CAAK,EAClDK,EAAOhB,EAAaY,EAAOG,CAAsB,EAEvD,MAAO,CAEH,OAAQH,EAASG,EAAuBC,CAAI,EAAe,EAC3D,KAAMA,EAAO,CACjB,CACJ,CAGA,IAAMA,EAAOhB,EAAaY,EAAOD,CAAK,EAEtC,MAAO,CAEH,OAAQC,EAASD,EAAMK,CAAI,EAAe,EAC1C,KAAMA,EAAO,CACjB,CACJ,EAEOC,EAAQP","sourcesContent":["const binarySearch = (element: number, array: number[]): number => {\n let m = 0;\n let n = array.length - 2;\n\n // eslint-disable-next-line no-loops/no-loops\n while (m < n) {\n // eslint-disable-next-line no-bitwise\n const key = m + ((n - m) >> 1);\n // eslint-disable-next-line security/detect-object-injection\n if (element < (array[key] as number)) {\n n = key - 1;\n } else if (element >= (array[key + 1] as number)) {\n m = key + 1;\n } else {\n m = key;\n break;\n }\n }\n\n return m;\n};\n\n// split by line break characters, CR, LF or CRLF\n// compile an array of indexes, where each line starts\nconst getLineStartIndexes = (string_: string): number[] =>\n // eslint-disable-next-line unicorn/no-array-reduce\n string_.split(/\\n|\\r(?!\\n)/).reduce(\n (accumulator: number[], current) => {\n accumulator.push((accumulator.at(-1) as number) + current.length + 1);\n\n return accumulator;\n },\n [0],\n );\n\nconst indexToLineColumn = (\n input: number[] | string,\n index: number,\n options?: {\n skipChecks: boolean;\n },\n): {\n column: number;\n line: number;\n} => {\n const skipChecks = options?.skipChecks ?? false;\n\n if (!skipChecks && ((!Array.isArray(input) && typeof input !== \"string\") || ((typeof input === \"string\" || Array.isArray(input)) && input.length === 0))) {\n return { column: 0, line: 0 };\n }\n\n if (\n !skipChecks &&\n (typeof index !== \"number\" || (typeof input === \"string\" && index >= input.length) || (Array.isArray(input) && index + 1 >= (input.at(-1) as number)))\n ) {\n return { column: 0, line: 0 };\n }\n\n // it depends, pre-cached input was given or a string\n if (typeof input === \"string\") {\n // not cached - calculate the line start indexes\n const startIndexesOfEachLine = getLineStartIndexes(input);\n const line = binarySearch(index, startIndexesOfEachLine);\n\n return {\n // eslint-disable-next-line security/detect-object-injection\n column: index - (startIndexesOfEachLine[line] as number) + 1,\n line: line + 1,\n };\n }\n\n // ELSE - cached line start indexes - we don't even need the string source!\n const line = binarySearch(index, input);\n\n return {\n // eslint-disable-next-line security/detect-object-injection\n column: index - (input[line] as number) + 1,\n line: line + 1,\n };\n};\n\nexport default indexToLineColumn;\n"]}
@@ -1,3 +1,3 @@
1
- export { a as parseStacktrace } from '../chunk-ZMWUTAJM.js';
1
+ export { a as parseStacktrace } from '../chunk-WOVTAVVR.js';
2
2
  //# sourceMappingURL=out.js.map
3
3
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@visulima/error",
3
- "version": "3.2.11",
4
- "description": "Error with more than just a message, stacktrace parsing and sourcemap loading.",
3
+ "version": "4.0.0",
4
+ "description": "Error with more than just a message, stacktrace parsing.",
5
5
  "keywords": [
6
6
  "anolilab",
7
7
  "character",
@@ -18,7 +18,6 @@
18
18
  "location",
19
19
  "parser",
20
20
  "position",
21
- "source-map",
22
21
  "stack",
23
22
  "stack-trace",
24
23
  "stacktrace",
@@ -70,12 +69,6 @@
70
69
  "default": "./dist/error/index.js"
71
70
  }
72
71
  },
73
- "./sourcemap": {
74
- "import": {
75
- "types": "./dist/sourcemap/index.d.ts",
76
- "default": "./dist/sourcemap/index.js"
77
- }
78
- },
79
72
  "./stacktrace": {
80
73
  "import": {
81
74
  "types": "./dist/stacktrace/index.d.ts",
@@ -91,16 +84,12 @@
91
84
  "CHANGELOG.md",
92
85
  "LICENSE.md"
93
86
  ],
94
- "dependencies": {
95
- "@jridgewell/trace-mapping": "^0.3.25",
96
- "@visulima/path": "1.0.2"
97
- },
98
87
  "devDependencies": {
99
88
  "@anolilab/eslint-config": "^15.0.3",
100
89
  "@anolilab/prettier-config": "^5.0.14",
101
- "@anolilab/semantic-release-pnpm": "^1.1.0",
102
- "@anolilab/semantic-release-preset": "^8.1.0",
103
- "@babel/core": "^7.24.6",
90
+ "@anolilab/semantic-release-pnpm": "^1.1.3",
91
+ "@anolilab/semantic-release-preset": "^9.0.0",
92
+ "@babel/core": "^7.24.7",
104
93
  "@eslint-types/deprecation": "^2.0.0",
105
94
  "@eslint-types/import": "^2.29.1",
106
95
  "@eslint-types/jsdoc": "^48.2.2",
@@ -109,10 +98,12 @@
109
98
  "@rushstack/eslint-plugin-security": "^0.8.1",
110
99
  "@total-typescript/ts-reset": "^0.5.1",
111
100
  "@types/command-line-args": "^5.2.3",
112
- "@types/node": "18.18.14",
101
+ "@types/node": "18.19.15",
102
+ "@visulima/path": "1.0.2",
113
103
  "@visulima/nextra-theme-docs": "4.0.26",
114
104
  "@vitest/coverage-v8": "^1.6.0",
115
105
  "@vitest/ui": "^1.6.0",
106
+ "conventional-changelog-conventionalcommits": "8.0.0",
116
107
  "cross-env": "^7.0.3",
117
108
  "eslint": "^8.57.0",
118
109
  "eslint-plugin-deprecation": "^3.0.0",
@@ -120,9 +111,9 @@
120
111
  "eslint-plugin-mdx": "^3.1.5",
121
112
  "eslint-plugin-vitest": "^0.4.1",
122
113
  "eslint-plugin-vitest-globals": "^1.5.0",
123
- "prettier": "^3.3.0",
114
+ "prettier": "^3.3.2",
124
115
  "rimraf": "^5.0.7",
125
- "semantic-release": "23.1.1",
116
+ "semantic-release": "24.0.0",
126
117
  "tsup": "^8.1.0",
127
118
  "typescript": "^5.4.5",
128
119
  "vitest": "^1.6.0"
@@ -156,7 +147,6 @@
156
147
  "src/index.ts",
157
148
  "src/code-frame/index.ts",
158
149
  "src/error/index.ts",
159
- "src/sourcemap/index.ts",
160
150
  "src/stacktrace/index.ts"
161
151
  ],
162
152
  "scripts": {
@@ -1,13 +0,0 @@
1
- import { readFileSync } from 'node:fs';
2
- import { AnyMap } from '@jridgewell/trace-mapping';
3
- export { generatedPositionFor as b, originalPositionFor as c, sourceContentFor as d, traceSegment as e } from '@jridgewell/trace-mapping';
4
- import { dirname, resolve } from '@visulima/path';
5
-
6
- var l=/^data:application\/json[^,]+base64,/,f=/\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+)[ \t]*$|\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*\*\/[ \t]*$/,c=e=>l.test(e),m=(e,n)=>{let o=e.split(/\r?\n/),t=null;for(let r=o.length-1;r>=0&&!t;r--)t=f.exec(o[r]);if(t)return c(t[1])?t[1]:resolve(n,t[1])},M=e=>{let n=e.slice(e.indexOf(",")+1);return Buffer.from(n,"base64").toString()},y=e=>{let n;try{n=readFileSync(e,{encoding:"utf8"});}catch(r){throw r.message=`Error reading sourcemap for file "${e}":
7
- ${r.message}`,r}let o=m(n,dirname(e));if(!o)return;let t;if(c(o))t=M(o);else try{t=readFileSync(o,{encoding:"utf8"});}catch(r){throw r.message=`Error reading sourcemap for file "${e}":
8
- ${r.message}`,r}try{return new AnyMap(t,o)}catch(r){throw r.message=`Error parsing sourcemap for file "${e}":
9
- ${r.message}`,r}},p=y;
10
-
11
- export { p as a };
12
- //# sourceMappingURL=out.js.map
13
- //# sourceMappingURL=chunk-D22N6ARA.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/sourcemap/load-source-map.ts","../src/sourcemap/sourcemap.ts"],"names":["readFileSync","AnyMap","dirname","resolve","INLINE_SOURCEMAP_REGEX","SOURCEMAP_REGEX","isInlineMap","url","resolveSourceMapUrl","sourceFile","sourcePath","lines","sourceMapUrl","index","decodeInlineMap","data","rawData","loadSourceMap","filename","sourceMapContent","error","traceMapContent","load_source_map_default","generatedPositionFor","originalPositionFor","sourceContentFor","traceSegment"],"mappings":"AAAA,OAAS,gBAAAA,MAAoB,UAG7B,OAAS,UAAAC,MAAc,4BACvB,OAAS,WAAAC,EAAS,WAAAC,MAAe,iBAEjC,IAAMC,EAAyB,sCAEzBC,EAAkB,4GAElBC,EAAeC,GAAyBH,EAAuB,KAAKG,CAAG,EAEvEC,EAAsB,CAACC,EAAoBC,IAA2C,CACxF,IAAMC,EAAQF,EAAW,MAAM,OAAO,EAElCG,EAAe,KAGnB,QAASC,EAAQF,EAAM,OAAS,EAAGE,GAAS,GAAK,CAACD,EAAcC,IAE5DD,EAAeP,EAAgB,KAAKM,EAAME,CAAK,CAAW,EAG9D,GAAKD,EAIL,OAAON,EAAYM,EAAa,CAAC,CAAW,EAAKA,EAAa,CAAC,EAAgBT,EAAQO,EAAYE,EAAa,CAAC,CAAW,CAChI,EAEME,EAAmBC,GAAiB,CACtC,IAAMC,EAAUD,EAAK,MAAMA,EAAK,QAAQ,GAAG,EAAI,CAAC,EAEhD,OAAO,OAAO,KAAKC,EAAS,QAAQ,EAAE,SAAS,CACnD,EAEMC,EAAiBC,GAA2C,CAC9D,IAAIC,EAEJ,GAAI,CAEAA,EAAmBnB,EAAakB,EAAU,CAAE,SAAU,MAAO,CAAC,CAElE,OAASE,EAAY,CACjB,MAAAA,EAAM,QAAU,qCAAqCF,CAAQ;AAAA,EAAOE,EAAM,OAAO,GAE3EA,CACV,CAEA,IAAMR,EAAeJ,EAAoBW,EAAkBjB,EAAQgB,CAAQ,CAAC,EAE5E,GAAI,CAACN,EACD,OAGJ,IAAIS,EAGJ,GAAIf,EAAYM,CAAY,EACxBS,EAAkBP,EAAgBF,CAAY,MAE9C,IAAI,CAGAS,EAAkBrB,EAAaY,EAAc,CAAE,SAAU,MAAO,CAAC,CAErE,OAASQ,EAAY,CACjB,MAAAA,EAAM,QAAU,qCAAqCF,CAAQ;AAAA,EAAOE,EAAM,OAAO,GAE3EA,CACV,CAGJ,GAAI,CACA,OAAO,IAAInB,EAAOoB,EAAiBT,CAAY,CAEnD,OAASQ,EAAY,CACjB,MAAAA,EAAM,QAAU,qCAAqCF,CAAQ;AAAA,EAAOE,EAAM,OAAO,GAE3EA,CACV,CACJ,EAEOE,EAAQL,ECjFf,OAAS,wBAAAM,EAAsB,uBAAAC,EAAqB,oBAAAC,EAAkB,gBAAAC,MAAoB","sourcesContent":["import { readFileSync } from \"node:fs\";\n\nimport type { TraceMap } from \"@jridgewell/trace-mapping\";\nimport { AnyMap } from \"@jridgewell/trace-mapping\";\nimport { dirname, resolve } from \"@visulima/path\";\n\nconst INLINE_SOURCEMAP_REGEX = /^data:application\\/json[^,]+base64,/;\n// eslint-disable-next-line regexp/no-unused-capturing-group,regexp/no-super-linear-backtracking\nconst SOURCEMAP_REGEX = /\\/\\/[@#][ \\t]+sourceMappingURL=([^\\s'\"]+)[ \\t]*$|\\/\\*[@#][ \\t]+sourceMappingURL=([^*]+?)[ \\t]*\\*\\/[ \\t]*$/;\n\nconst isInlineMap = (url: string): boolean => INLINE_SOURCEMAP_REGEX.test(url);\n\nconst resolveSourceMapUrl = (sourceFile: string, sourcePath: string): string | undefined => {\n const lines = sourceFile.split(/\\r?\\n/);\n\n let sourceMapUrl = null;\n\n // eslint-disable-next-line no-loops/no-loops,no-plusplus\n for (let index = lines.length - 1; index >= 0 && !sourceMapUrl; index--) {\n // eslint-disable-next-line security/detect-object-injection\n sourceMapUrl = SOURCEMAP_REGEX.exec(lines[index] as string);\n }\n\n if (!sourceMapUrl) {\n return undefined;\n }\n\n return isInlineMap(sourceMapUrl[1] as string) ? (sourceMapUrl[1] as string) : (resolve(sourcePath, sourceMapUrl[1] as string) as string);\n};\n\nconst decodeInlineMap = (data: string) => {\n const rawData = data.slice(data.indexOf(\",\") + 1);\n\n return Buffer.from(rawData, \"base64\").toString();\n};\n\nconst loadSourceMap = (filename: string): TraceMap | undefined => {\n let sourceMapContent: string | undefined;\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n sourceMapContent = readFileSync(filename, { encoding: \"utf8\" });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n error.message = `Error reading sourcemap for file \"${filename}\":\\n${error.message}`;\n\n throw error;\n }\n\n const sourceMapUrl = resolveSourceMapUrl(sourceMapContent, dirname(filename));\n\n if (!sourceMapUrl) {\n return undefined;\n }\n\n let traceMapContent: string | undefined;\n\n // If it's an inline map, decode it and pass it through the same consumer factory\n if (isInlineMap(sourceMapUrl)) {\n traceMapContent = decodeInlineMap(sourceMapUrl);\n } else {\n try {\n // Load actual source map from given path\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n traceMapContent = readFileSync(sourceMapUrl, { encoding: \"utf8\" });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n error.message = `Error reading sourcemap for file \"${filename}\":\\n${error.message}`;\n\n throw error;\n }\n }\n\n try {\n return new AnyMap(traceMapContent, sourceMapUrl);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n error.message = `Error parsing sourcemap for file \"${filename}\":\\n${error.message}`;\n\n throw error;\n }\n};\n\nexport default loadSourceMap;\n","export { default as loadSourceMap } from \"./load-source-map\";\nexport type { TraceMap } from \"@jridgewell/trace-mapping\";\nexport { generatedPositionFor, originalPositionFor, sourceContentFor, traceSegment } from \"@jridgewell/trace-mapping\";\n"]}
@@ -1,6 +0,0 @@
1
- var o=(s,...e)=>{process.env.DEBUG&&String(process.env.DEBUG)==="true"&&console.debug(`error:parse-stacktrace: ${s}`,...e);},f="<unknown>",y=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,T=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,v=/(.*?):(\d+):(\d+)(\s<-\s(.+):(\d+):(\d+))?/,$=/^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/,N=/in\s(.*)\s\(at\s(.+)\)\sat/,x=/^(?:.*@)?(.*):(\d+):(\d+)$/,b=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,O=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,R=/(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/,l=/\(error: (.*)\)/,p=(s,e)=>{let n=s.includes("safari-extension"),t=s.includes("safari-web-extension");return n||t?[s.includes("@")?s.split("@")[0]:f,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[s,e]},m=(s,e)=>{let n=v.exec(e);n&&(s.file=n[1],s.line=+n[2],s.column=+n[3]);},S=s=>{let e=N.exec(s);if(e){o(`parse nested node error stack line: "${s}"`,`found: ${JSON.stringify(e)}`);let t=e[2].split(":");return {column:t[2]?+t[2]:void 0,file:t[0],line:t[1]?+t[1]:void 0,methodName:e[1]||f,raw:s,type:void 0}}let n=$.exec(s);if(n){o(`parse node error stack line: "${s}"`,`found: ${JSON.stringify(n)}`);let t={column:n[4]?+n[4]:void 0,file:n[2]?n[2].replace(/at\s/,""):void 0,line:n[3]?+n[3]:void 0,methodName:n[1]||f,raw:s,type:s.startsWith("internal")?"internal":void 0};return m(t,`${n[2]}:${n[3]}:${n[4]}`),t}},_=s=>{let e=y.exec(s);if(e){o(`parse chrome error stack line: "${s}"`,`found: ${JSON.stringify(e)}`);let n=e[2]&&e[2].startsWith("native"),t=e[2]&&e[2].startsWith("eval")||e[1]&&e[1].startsWith("eval"),r;if(t){let i=T.exec(s);if(i){let c=/(\S+):(\d+):(\d+)|(\S+):(\d+)$/.exec(i[1]);c?(e[2]=c[4]??c[1],e[3]=c[5]??c[2],e[4]=c[3]):i[2]&&(e[2]=i[1]),i[2]&&(r={column:i[4]?+i[4]:void 0,file:i[2],line:i[3]?+i[3]:void 0,methodName:"eval",raw:s,type:"eval"});}}let[a,u]=p(e[1]?e[1].replace(/^Anonymous function$/,"<anonymous>"):f,e[2]),d={column:e[4]?+e[4]:void 0,evalOrigin:r,file:u,line:e[3]?+e[3]:void 0,methodName:a,raw:s,type:t?"eval":n?"native":void 0};return m(d,`${u}:${e[3]}:${e[4]}`),d}},h=(s,e)=>{let n=b.exec(s);if(n){o(`parse gecko error stack line: "${s}"`,`found: ${JSON.stringify(n)}`);let t=n[3]?.includes(" > eval"),r=t&&n[3]&&O.exec(n[3]),a;t&&r&&(n[3]=r[1],a={column:n[5]?+n[5]:void 0,file:n[3],line:n[4]?+n[4]:void 0,methodName:"eval",raw:s,type:"eval"},n[4]=r[2]);let[u,d]=p(n[1]?n[1].replace(/^Anonymous function$/,"<anonymous>"):f,n[3]),i;(e?.type==="safari"||!t&&e?.type==="firefox")&&e.column?i=e.column:!t&&n[5]&&(i=+n[5]);let c;return (e?.type==="safari"||!t&&e?.type==="firefox")&&e.line?c=e.line:n[4]&&(c=+n[4]),{column:i,evalOrigin:a,file:d,line:c,methodName:u,raw:s,type:t?"eval":d.includes("[native code]")?"native":void 0}}},G=(s,e)=>{let n=R.exec(s);if(!(n?n[2].includes(" > eval"):!1)&&n)return o(`parse firefox error stack line: "${s}"`,`found: ${JSON.stringify(n)}`),{column:n[4]?+n[4]:e?.column??void 0,file:n[2],line:n[3]?+n[3]:e?.line??void 0,methodName:n[1]||f,raw:s,type:void 0}},w=s=>{let e=x.exec(s);if(e)return o(`parse react android native error stack line: "${s}"`,`found: ${JSON.stringify(e)}`),{column:e[3]?+e[3]:void 0,file:e[1],line:e[2]?+e[2]:void 0,methodName:f,raw:s,type:void 0}},k=(s,e={})=>{let{frameLimit:n=50}=e,t=(s.stacktrace??s.stack??"").split(`
2
- `).map(r=>(l.test(r)?r.replace(l,"$1"):r).replace(/^\s+|\s+$/g,"")).filter(r=>!/\S*Error: /.test(r)&&r!=="eval code");return t.length>n&&(t=t.slice(0,n)),t.reduce((r,a,u)=>{if(!a||a.length>1024)return r;let d;if(/^\s*in\s.*/.test(a))d=S(a);else if(/^.*?\s*at\s.*/.test(a))d=_(a);else if(/^.*?\s*@.*|\[native code\]/.test(a)){let i;u===0&&(s.columnNumber||s.lineNumber?i={column:s.columnNumber,line:s.lineNumber,type:"firefox"}:(s.line||s.column)&&(i={column:s.column,line:s.line,type:"safari"})),d=G(a,i)||h(a,i);}else d=w(a);return d?r.push(d):o(`parse error stack line: "${a}"`,"not parser found"),r},[])},A=k;
3
-
4
- export { A as a };
5
- //# sourceMappingURL=out.js.map
6
- //# sourceMappingURL=chunk-ZMWUTAJM.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/stacktrace/parse-stacktrace.ts"],"names":["debugLog","message","arguments_","UNKNOWN_FUNCTION","CHROMIUM_REGEX","CHROMIUM_EVAL_REGEX","CHROMIUM_MAPPED","NODE_REGEX","NODE_NESTED_REGEX","REACT_ANDROID_NATIVE_REGEX","GECKO_REGEX","GECKO_EVAL_REGEX","FIREFOX_REGEX","WEBPACK_ERROR_REGEXP","extractSafariExtensionDetails","methodName","url","isSafariExtension","isSafariWebExtension","parseMapped","trace","maybeMapped","match","parseNode","line","nestedNode","split","node","parseChromium","parts","isNative","isEval","evalOrigin","subMatch","file","parseGecko","topFrameMeta","column","lineNumber","parseFirefox","parseReactAndroidNative","parse","error","options","frameLimit","lines","stack","currentIndex","parseResult","parse_stacktrace_default"],"mappings":"AAQA,IAAMA,EAAW,CAACC,KAAoBC,IAAgC,CAC9D,QAAQ,IAAI,OAAS,OAAO,QAAQ,IAAI,KAAK,IAAM,QAEnD,QAAQ,MAAM,2BAA2BD,CAAO,GAAI,GAAGC,CAAU,CAEzE,EAEMC,EAAmB,YAsBnBC,EAEF,yJAEEC,EAAsB,0CAItBC,EAAkB,6CAIlBC,EAAa,qFACbC,EAAoB,6BAGpBC,EAA6B,6BAM7BC,EAAc,wIAEdC,EAAmB,gDAMnBC,EAAgB,yCAGhBC,EAAuB,kBAsBvBC,EAAgC,CAACC,EAAoBC,IAAkC,CACzF,IAAMC,EAAoBF,EAAW,SAAS,kBAAkB,EAC1DG,EAAuBH,EAAW,SAAS,sBAAsB,EAEvE,OAAOE,GAAqBC,EACtB,CACIH,EAAW,SAAS,GAAG,EAAKA,EAAW,MAAM,GAAG,EAAE,CAAC,EAAeZ,EAClEc,EAAoB,oBAAoBD,CAAG,GAAK,wBAAwBA,CAAG,EAC/E,EACA,CAACD,EAAYC,CAAG,CAC1B,EAEMG,EAAc,CAACC,EAAcC,IAAwB,CACvD,IAAMC,EAAQhB,EAAgB,KAAKe,CAAW,EAE1CC,IAEAF,EAAM,KAAOE,EAAM,CAAC,EAEpBF,EAAM,KAAO,CAAUE,EAAM,CAAC,EAE9BF,EAAM,OAAS,CAAUE,EAAM,CAAC,EAExC,EAGMC,EAAaC,GAAoC,CACnD,IAAMC,EAAajB,EAAkB,KAAKgB,CAAI,EAE9C,GAAIC,EAAY,CACZzB,EAAS,wCAAwCwB,CAAI,IAAK,UAAU,KAAK,UAAUC,CAAU,CAAC,EAAE,EAEhG,IAAMC,EAASD,EAAW,CAAC,EAAa,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AAiB,IAEbL,EAAM,cAAgBA,EAAM,WAC5BN,EAAe,CAEX,OAAQM,EAAM,aAEd,KAAMA,EAAM,WACZ,KAAM,SACV,GAEOA,EAAM,MAAQA,EAAM,UAC3BN,EAAe,CAEX,OAAQM,EAAM,OAEd,KAAMA,EAAM,KACZ,KAAM,QACV,IAIRM,EAEIT,EAAaf,EAAMY,CAAY,GAAKD,EAAWX,EAAMY,CAAY,CACzE,MACIY,EAAcR,EAAwBhB,CAAI,EAG9C,OAAIwB,EACAF,EAAM,KAAKE,CAAW,EAEtBhD,EAAS,4BAA4BwB,CAAI,IAAK,kBAAkB,EAG7DsB,CACX,EAAG,CAAC,CAAC,CACT,EAEOG,EAAQR","sourcesContent":["import type { Trace, TraceType } from \"./types\";\n\ntype TopFrameMeta = {\n column?: number;\n line?: number;\n type: \"firefox\" | \"safari\";\n};\n\nconst debugLog = (message: string, ...arguments_: unknown[]): void => {\n if (process.env.DEBUG && String(process.env.DEBUG) === \"true\") {\n // eslint-disable-next-line no-console\n console.debug(`error:parse-stacktrace: ${message}`, ...arguments_);\n }\n};\n\nconst UNKNOWN_FUNCTION = \"<unknown>\";\n\n// at <SomeFramework>\n// at <SomeFramework>:123:39\n// -----------------\n// at about:blank:1:7\n// at index.js:23\n// >= Chrome 99\n// at /projects/foo.test.js:689:1 <- /projects/foo.test.js:10:1\n// -----------------\n// at bar (<anonymous>:1:19 <- <anonymous>:2:3)\n// -----------------\n// at foo.bar(bob) (foo.bar.js:123:39)\n// at foo.bar(bob) (foo.bar.js:123:39 <- original.js:123:34)\n// -----------------\n// >= Chrome 88\n// spy() at Component.Foo [as constructor] (original.js:123:34)\n// spy() at Component.Foo [as constructor] (foo.bar.js:123:39 <- original.js:123:34)\n// -----------------\n// at Module.load (internal/modules/cjs/loader.js:641:32)\n// -----------------\n// Chromium based browsers: Chrome, Brave, new Opera, new Edge\nconst CHROMIUM_REGEX =\n // eslint-disable-next-line security/detect-unsafe-regex,regexp/no-super-linear-backtracking\n /^.*?\\s*at\\s(?:(.+?\\)(?:\\s\\[.+\\])?|\\(?.*?)\\s?\\((?:address\\sat\\s)?)?(?:async\\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\\/)?.*?)(?::(\\d+))?(?::(\\d+))?\\)?\\s*$/i;\n// eslint-disable-next-line security/detect-unsafe-regex\nconst CHROMIUM_EVAL_REGEX = /\\((\\S+)\\),\\s(<[^>]+>)?:(\\d+)?:(\\d+)?\\)?/;\n// foo.bar.js:123:39\n// foo.bar.js:123:39 <- original.js:123:34\n// eslint-disable-next-line security/detect-unsafe-regex,regexp/no-unused-capturing-group\nconst CHROMIUM_MAPPED = /(.*?):(\\d+):(\\d+)(\\s<-\\s(.+):(\\d+):(\\d+))?/;\n\n// in AppProviders (at App.tsx:28)\n// eslint-disable-next-line security/detect-unsafe-regex\nconst NODE_REGEX = /^\\s*in\\s(?:([^\\\\/]+(?:\\s\\[as\\s\\S+\\])?)\\s\\(?)?\\(at?\\s?(.*?):(\\d+)(?::(\\d+))?\\)?\\s*$/;\nconst NODE_NESTED_REGEX = /in\\s(.*)\\s\\(at\\s(.+)\\)\\sat/;\n\n// eslint-disable-next-line security/detect-unsafe-regex,regexp/no-super-linear-backtracking\nconst REACT_ANDROID_NATIVE_REGEX = /^(?:.*@)?(.*):(\\d+):(\\d+)$/;\n\n// gecko regex: `(?:bundle|\\d+\\.js)`: `bundle` is for react native, `\\d+\\.js` also but specifically for ram bundles because it\n// generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js\n// We need this specific case for now because we want no other regex to match.\n// eslint-disable-next-line regexp/no-super-linear-backtracking,security/detect-unsafe-regex,regexp/no-optional-assertion,regexp/no-trivially-nested-quantifier,regexp/no-useless-escape,no-useless-escape,regexp/optimal-quantifier-concatenation\nconst GECKO_REGEX = /^\\s*(.*?)(?:\\((.*?)\\))?(?:^|@)?((?:[-a-z]+)?:\\/.*?|\\[native code\\]|[^@]*(?:bundle|\\d+\\.js)|\\/[\\w\\-. \\/=]+)(?::(\\d+))?(?::(\\d+))?\\s*$/i;\n// eslint-disable-next-line security/detect-unsafe-regex\nconst GECKO_EVAL_REGEX = /(\\S+) line (\\d+)(?: > eval line \\d+)* > eval/i;\n\n// @http://localhost:8080/file.js:33:9\n// foo@debugger eval code:1:27\n// obj[\"@fn\"]@Scratchpad/1:10:29\n// eslint-disable-next-line regexp/no-super-linear-backtracking\nconst FIREFOX_REGEX = /(\\S[^\\s[]*\\[.*\\]|.*?)@(.*):(\\d+):(\\d+)/;\n\n// Used to sanitize webpack (error: *) wrapped stack errors\nconst WEBPACK_ERROR_REGEXP = /\\(error: (.*)\\)/;\n\n/**\n * Safari web extensions, starting version unknown, can produce \"frames-only\" stacktraces.\n * What it means, is that instead of format like:\n *\n * Error: wat\n * at function@url:row:col\n * at function@url:row:col\n * at function@url:row:col\n *\n * it produces something like:\n *\n * function@url:row:col\n * function@url:row:col\n * function@url:row:col\n *\n * Because of that, it won't be captured by `chrome` RegExp and will fall into `Gecko` branch.\n * This function is extracted so that we can use it in both places without duplicating the logic.\n * Unfortunately \"just\" changing RegExp is too complicated now and making it pass all tests\n * and fix this case seems like an impossible, or at least way too time-consuming task.\n */\nconst extractSafariExtensionDetails = (methodName: string, url: string): [string, string] => {\n const isSafariExtension = methodName.includes(\"safari-extension\");\n const isSafariWebExtension = methodName.includes(\"safari-web-extension\");\n\n return isSafariExtension || isSafariWebExtension\n ? [\n methodName.includes(\"@\") ? (methodName.split(\"@\")[0] as string) : UNKNOWN_FUNCTION,\n isSafariExtension ? `safari-extension:${url}` : `safari-web-extension:${url}`,\n ]\n : [methodName, url];\n};\n\nconst parseMapped = (trace: Trace, maybeMapped: string) => {\n const match = CHROMIUM_MAPPED.exec(maybeMapped);\n\n if (match) {\n // eslint-disable-next-line no-param-reassign,prefer-destructuring\n trace.file = match[1];\n // eslint-disable-next-line no-param-reassign\n trace.line = +(<string>match[2]);\n // eslint-disable-next-line no-param-reassign\n trace.column = +(<string>match[3]);\n }\n};\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst parseNode = (line: string): Trace | undefined => {\n const nestedNode = NODE_NESTED_REGEX.exec(line);\n\n if (nestedNode) {\n debugLog(`parse nested node error stack line: \"${line}\"`, `found: ${JSON.stringify(nestedNode)}`);\n\n const split = (nestedNode[2] as string).split(\":\");\n\n return {\n column: split[2] ? +split[2] : undefined,\n file: split[0],\n line: split[1] ? +split[1] : undefined,\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n methodName: nestedNode[1] || UNKNOWN_FUNCTION,\n raw: line,\n type: undefined,\n };\n }\n\n const node = NODE_REGEX.exec(line);\n\n if (node) {\n debugLog(`parse node error stack line: \"${line}\"`, `found: ${JSON.stringify(node)}`);\n\n const trace = {\n column: node[4] ? +node[4] : undefined,\n file: node[2] ? node[2].replace(/at\\s/, \"\") : undefined,\n line: node[3] ? +node[3] : undefined,\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n methodName: node[1] || UNKNOWN_FUNCTION,\n raw: line,\n type: line.startsWith(\"internal\") ? (\"internal\" as TraceType) : undefined,\n };\n\n parseMapped(trace, `${node[2]}:${node[3]}:${node[4]}`);\n\n return trace;\n }\n\n return undefined;\n};\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst parseChromium = (line: string): Trace | undefined => {\n const parts = CHROMIUM_REGEX.exec(line) as (string | undefined)[] | null;\n\n if (parts) {\n debugLog(`parse chrome error stack line: \"${line}\"`, `found: ${JSON.stringify(parts)}`);\n\n const isNative = parts[2] && parts[2].startsWith(\"native\"); // start of line\n const isEval = (parts[2] && parts[2].startsWith(\"eval\")) || (parts[1] && parts[1].startsWith(\"eval\")); // start of line\n\n let evalOrigin: Trace | undefined;\n\n if (isEval) {\n const subMatch = CHROMIUM_EVAL_REGEX.exec(line);\n\n if (subMatch) {\n // can be index.js:123:39 or index.js:123 or index.js\n const split = /(\\S+):(\\d+):(\\d+)|(\\S+):(\\d+)$/.exec(subMatch[1] as string);\n\n if (split) {\n // throw out eval line/column and use top-most line/column number\n parts[2] = split[4] ?? split[1]; // url\n parts[3] = split[5] ?? split[2]; // line\n // eslint-disable-next-line prefer-destructuring\n parts[4] = split[3]; // column\n } else if (subMatch[2]) {\n // eslint-disable-next-line prefer-destructuring\n parts[2] = subMatch[1];\n }\n\n if (subMatch[2]) {\n evalOrigin = {\n column: subMatch[4] ? +subMatch[4] : undefined,\n file: subMatch[2],\n line: subMatch[3] ? +subMatch[3] : undefined,\n methodName: \"eval\",\n raw: line,\n type: \"eval\" as TraceType,\n };\n }\n }\n }\n\n const [methodName, file] = extractSafariExtensionDetails(\n // Normalize IE's 'Anonymous function'\n parts[1] ? parts[1].replace(/^Anonymous function$/, \"<anonymous>\") : UNKNOWN_FUNCTION,\n parts[2] as string,\n );\n\n const trace = {\n column: parts[4] ? +parts[4] : undefined,\n evalOrigin,\n file,\n line: parts[3] ? +parts[3] : undefined,\n // Normalize IE's 'Anonymous function'\n methodName,\n raw: line,\n type: (isEval ? \"eval\" : isNative ? \"native\" : undefined) as TraceType,\n };\n\n parseMapped(trace, `${file}:${parts[3]}:${parts[4]}`);\n\n return trace;\n }\n\n return undefined;\n};\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst parseGecko = (line: string, topFrameMeta?: TopFrameMeta): Trace | undefined => {\n const parts = GECKO_REGEX.exec(line);\n\n if (parts) {\n debugLog(`parse gecko error stack line: \"${line}\"`, `found: ${JSON.stringify(parts)}`);\n\n const isEval = parts[3]?.includes(\" > eval\");\n const subMatch = isEval && parts[3] && GECKO_EVAL_REGEX.exec(parts[3]);\n\n let evalOrigin: Trace | undefined;\n\n if (isEval && subMatch) {\n // overwrite file\n parts[3] = <string>subMatch[1];\n\n evalOrigin = {\n column: parts[5] ? +parts[5] : undefined,\n file: parts[3],\n line: parts[4] ? +parts[4] : undefined,\n methodName: \"eval\",\n raw: line,\n type: \"eval\" as TraceType,\n };\n\n // overwrite line\n parts[4] = <string>subMatch[2];\n }\n\n const [methodName, file] = extractSafariExtensionDetails(\n // Normalize IE's 'Anonymous function'\n parts[1] ? parts[1].replace(/^Anonymous function$/, \"<anonymous>\") : UNKNOWN_FUNCTION,\n parts[3] as string,\n );\n\n let column: number | undefined; // no column when eval\n\n if ((topFrameMeta?.type === \"safari\" || (!isEval && topFrameMeta?.type === \"firefox\")) && topFrameMeta.column) {\n column = topFrameMeta.column;\n } else if (!isEval && parts[5]) {\n column = +parts[5];\n }\n\n let lineNumber: number | undefined; // no line when eval\n\n if ((topFrameMeta?.type === \"safari\" || (!isEval && topFrameMeta?.type === \"firefox\")) && topFrameMeta.line) {\n lineNumber = topFrameMeta.line;\n } else if (parts[4]) {\n lineNumber = +parts[4];\n }\n\n return {\n column,\n evalOrigin,\n file,\n line: lineNumber,\n methodName,\n raw: line,\n type: isEval ? \"eval\" : file.includes(\"[native code]\") ? \"native\" : undefined,\n };\n }\n\n return undefined;\n};\n\nconst parseFirefox = (line: string, topFrameMeta?: TopFrameMeta): Trace | undefined => {\n const parts = FIREFOX_REGEX.exec(line);\n\n const isEval = parts ? (parts[2] as string).includes(\" > eval\") : false;\n\n if (!isEval && parts) {\n debugLog(`parse firefox error stack line: \"${line}\"`, `found: ${JSON.stringify(parts)}`);\n\n return {\n column: parts[4] ? +parts[4] : topFrameMeta?.column ?? undefined,\n file: parts[2],\n line: parts[3] ? +parts[3] : topFrameMeta?.line ?? undefined,\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n methodName: parts[1] || UNKNOWN_FUNCTION,\n raw: line,\n type: undefined,\n };\n }\n\n return undefined;\n};\n\nconst parseReactAndroidNative = (line: string): Trace | undefined => {\n const parts = REACT_ANDROID_NATIVE_REGEX.exec(line);\n\n if (parts) {\n debugLog(`parse react android native error stack line: \"${line}\"`, `found: ${JSON.stringify(parts)}`);\n\n return {\n column: parts[3] ? +parts[3] : undefined,\n file: parts[1],\n line: parts[2] ? +parts[2] : undefined,\n methodName: UNKNOWN_FUNCTION,\n raw: line,\n type: undefined,\n };\n }\n\n return undefined;\n};\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst parse = (error: Error, options: Partial<{ frameLimit: number }> = {}): Trace[] => {\n const { frameLimit = 50 } = options;\n\n // @ts-expect-error missing stacktrace property\n let lines = (error.stacktrace ?? error.stack ?? \"\")\n .split(\"\\n\")\n .map((line: string): string => {\n // https://github.com/getsentry/sentry-javascript/issues/5459\n // Remove webpack (error: *) wrappers\n const cleanedLine = WEBPACK_ERROR_REGEXP.test(line) ? line.replace(WEBPACK_ERROR_REGEXP, \"$1\") : line;\n\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n return cleanedLine.replace(/^\\s+|\\s+$/g, \"\");\n })\n // https://github.com/getsentry/sentry-javascript/issues/7813\n // Skip Error: lines\n // Skip eval code without more context\n .filter((line: string): boolean => !/\\S*Error: /.test(line) && line !== \"eval code\");\n\n if (lines.length > frameLimit) {\n lines = lines.slice(0, frameLimit);\n }\n\n // eslint-disable-next-line unicorn/no-array-reduce,@typescript-eslint/no-unsafe-return\n return lines.reduce((stack: Trace[], line: string, currentIndex: number): Trace[] => {\n if (!line) {\n return stack;\n }\n\n // Ignore lines over 1kb as they are unlikely to be stack frames.\n // Many of the regular expressions use backtracking which results in run time that increases exponentially with\n // input size. Huge strings can result in hangs/Denial of Service:\n // https://github.com/getsentry/sentry-javascript/issues/2286\n if (line.length > 1024) {\n return stack;\n }\n\n let parseResult: Trace | undefined;\n\n if (/^\\s*in\\s.*/.test(line)) {\n parseResult = parseNode(line);\n // eslint-disable-next-line regexp/no-super-linear-backtracking\n } else if (/^.*?\\s*at\\s.*/.test(line)) {\n parseResult = parseChromium(line);\n // eslint-disable-next-line regexp/no-super-linear-backtracking\n } else if (/^.*?\\s*@.*|\\[native code\\]/.test(line)) {\n let topFrameMeta: TopFrameMeta | undefined;\n\n if (currentIndex === 0) {\n // @ts-expect-error columnNumber and lineNumber property only exists on Firefox\n if (error.columnNumber || error.lineNumber) {\n topFrameMeta = {\n // @ts-expect-error columnNumber and columnNumber property only exists on Firefox\n column: error.columnNumber,\n // @ts-expect-error columnNumber and lineNumber property only exists on Firefox\n line: error.lineNumber,\n type: \"firefox\",\n };\n // @ts-expect-error line and column property only exists on safari\n } else if (error.line || error.column) {\n topFrameMeta = {\n // @ts-expect-error column property only exists on safari\n column: error.column,\n // @ts-expect-error line property only exists on safari\n line: error.line,\n type: \"safari\",\n };\n }\n }\n\n parseResult =\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n parseFirefox(line, topFrameMeta) || parseGecko(line, topFrameMeta);\n } else {\n parseResult = parseReactAndroidNative(line);\n }\n\n if (parseResult) {\n stack.push(parseResult);\n } else {\n debugLog(`parse error stack line: \"${line}\"`, \"not parser found\");\n }\n\n return stack;\n }, []);\n};\n\nexport default parse;\n"]}
@@ -1,6 +0,0 @@
1
- import { TraceMap } from '@jridgewell/trace-mapping';
2
- export { TraceMap, generatedPositionFor, originalPositionFor, sourceContentFor, traceSegment } from '@jridgewell/trace-mapping';
3
-
4
- declare const loadSourceMap: (filename: string) => TraceMap | undefined;
5
-
6
- export { loadSourceMap };
@@ -1,3 +0,0 @@
1
- export { b as generatedPositionFor, a as loadSourceMap, c as originalPositionFor, d as sourceContentFor, e as traceSegment } from '../chunk-D22N6ARA.js';
2
- //# sourceMappingURL=out.js.map
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}