@visulima/error 6.0.0-alpha.6 → 6.0.0-alpha.8
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 +35 -0
- package/dist/code-frame/index.js +5 -5
- package/dist/error/get-error-causes.d.ts +1 -1
- package/dist/error/index.js +4 -4
- package/dist/error/types.d.ts +1 -1
- package/dist/index.js +10 -10
- package/dist/packem_shared/{aiFinder-HftEgsry.js → aiFinder-CDaOm_ur.js} +2 -2
- package/dist/packem_shared/{aiSolutionResponse-CJBMLS9t.js → aiSolutionResponse-DlSn3Imq.js} +1 -1
- package/dist/packem_shared/{deserializeError-BsFrjsrV.js → deserializeError-BEH-kMcX.js} +1 -1
- package/dist/packem_shared/{errorHintFinder-DEaeRnRW.js → errorHintFinder-bk-fyNyF.js} +7 -7
- package/dist/packem_shared/{formatStackFrameLine-D3_6oSWZ.js → formatStackFrameLine-BaISxse1.js} +4 -4
- package/dist/packem_shared/{getErrorCauses-DpUsmuqw.js → getErrorCauses-BLHM3CNA.js} +1 -1
- package/dist/packem_shared/{indexToLineColumn-Bg8UW1bU.js → indexToLineColumn-BUb0GPKl.js} +2 -1
- package/dist/packem_shared/{parseStacktrace-oQvk7wYp.js → parseStacktrace-B_dIfRHt.js} +44 -32
- package/dist/packem_shared/{renderError-C30PRFtU.js → renderError-BVWwJmI2.js} +4 -4
- package/dist/packem_shared/{ruleBasedFinder-C2F8rQ30.js → ruleBasedFinder-E1R-t_rj.js} +14 -14
- package/dist/packem_shared/{serializeError-e9YW13-X.js → serializeError-CcomaUJN.js} +15 -13
- package/dist/solution/ai/ai-prompt.js +3 -3
- package/dist/solution/ai/index.js +2 -2
- package/dist/solution/index.js +2 -2
- package/dist/solution/types.d.ts +1 -1
- package/dist/stacktrace/index.js +2 -2
- package/dist/stacktrace/types.d.ts +6 -6
- package/package.json +3 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
## @visulima/error [6.0.0-alpha.8](https://github.com/visulima/visulima/compare/@visulima/error@6.0.0-alpha.7...@visulima/error@6.0.0-alpha.8) (2026-04-08)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **error:** properly fix eslint errors in code ([4f4cf45](https://github.com/visulima/visulima/commit/4f4cf45f223ad0482bb9c0eed14738303662105a))
|
|
6
|
+
* **error:** remove remaining eslint suppressions with proper code fixes ([e92dc33](https://github.com/visulima/visulima/commit/e92dc3372363051cf635a69f918c5f875fd1bd72))
|
|
7
|
+
* **error:** resolve eslint errors ([52639e9](https://github.com/visulima/visulima/commit/52639e902f8bc7b29498ecfb0c546cf9642d7af8))
|
|
8
|
+
|
|
9
|
+
### Miscellaneous Chores
|
|
10
|
+
|
|
11
|
+
* **error-debugging:** remove empty dependency objects from package.json ([7eb7c8e](https://github.com/visulima/visulima/commit/7eb7c8eba1394e515fa77c0f56baf41c0810de2e))
|
|
12
|
+
* **error:** add tsconfig.eslint.json for type-aware linting ([c5fa576](https://github.com/visulima/visulima/commit/c5fa57628362636cdafc09139d955c60bd1db3d0))
|
|
13
|
+
* **error:** apply prettier formatting ([10704af](https://github.com/visulima/visulima/commit/10704af82a1317a43b5379982617f35953b8d069))
|
|
14
|
+
* **error:** migrate .prettierrc.cjs to prettier.config.js ([15ca04c](https://github.com/visulima/visulima/commit/15ca04cb0de5f026607aef88e98b68a0fffa3366))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Dependencies
|
|
18
|
+
|
|
19
|
+
* **@visulima/path:** upgraded to 3.0.0-alpha.8
|
|
20
|
+
|
|
21
|
+
## @visulima/error [6.0.0-alpha.7](https://github.com/visulima/visulima/compare/@visulima/error@6.0.0-alpha.6...@visulima/error@6.0.0-alpha.7) (2026-03-26)
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* **web:** auto-generate packages page from workspace metadata ([623e520](https://github.com/visulima/visulima/commit/623e5207693a7fe720f5f2f179593a3654c880e3))
|
|
26
|
+
|
|
27
|
+
### Miscellaneous Chores
|
|
28
|
+
|
|
29
|
+
* update homepage URLs to visulima.com/packages/ format ([be42968](https://github.com/visulima/visulima/commit/be42968129df85fb074224435e33135ff44cab91))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Dependencies
|
|
33
|
+
|
|
34
|
+
* **@visulima/path:** upgraded to 3.0.0-alpha.7
|
|
35
|
+
|
|
1
36
|
## @visulima/error [6.0.0-alpha.6](https://github.com/visulima/visulima/compare/@visulima/error@6.0.0-alpha.5...@visulima/error@6.0.0-alpha.6) (2026-03-26)
|
|
2
37
|
|
|
3
38
|
### Bug Fixes
|
package/dist/code-frame/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const normalizeLF = (code) => code.replaceAll(/\r\n|\r(?!\n)|\n/gu, "\n");
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const rawProcess = globalThis.process ?? /* @__PURE__ */ Object.create(null);
|
|
4
4
|
const processShims = {
|
|
5
5
|
versions: {}
|
|
6
6
|
};
|
|
7
|
-
const process = /* @__PURE__ */ new Proxy(
|
|
7
|
+
const process = /* @__PURE__ */ new Proxy(rawProcess, {
|
|
8
8
|
get(target, property) {
|
|
9
9
|
if (property in target) {
|
|
10
10
|
return target[property];
|
|
@@ -81,9 +81,9 @@ const codeFrame = (source, loc, options) => {
|
|
|
81
81
|
...options?.color
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
|
-
const hasColumns =
|
|
84
|
+
const hasColumns = typeof loc.start.column === "number";
|
|
85
85
|
let lines = normalizeLF(source).split("\n");
|
|
86
|
-
if (typeof config
|
|
86
|
+
if (typeof config.tabWidth === "number") {
|
|
87
87
|
lines = lines.map((ln) => ln.replaceAll(" ", " ".repeat(config.tabWidth)));
|
|
88
88
|
}
|
|
89
89
|
const { end, markerLines, start } = getMarkerLines(loc, lines, config.linesAbove, config.linesBelow);
|
|
@@ -92,7 +92,7 @@ const codeFrame = (source, loc, options) => {
|
|
|
92
92
|
let frame = lines.slice(start, end).map((line, index) => {
|
|
93
93
|
const number = start + 1 + index;
|
|
94
94
|
const hasMarker = markerLines[number];
|
|
95
|
-
const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
|
|
95
|
+
const paddedNumber = ` ${String(number)}`.slice(-numberMaxWidth);
|
|
96
96
|
const lastMarkerLine = !markerLines[number + 1];
|
|
97
97
|
const gutter = ` ${paddedNumber}${config.showGutter ? " |" : ""}`;
|
|
98
98
|
if (hasMarker) {
|
|
@@ -2,5 +2,5 @@ import type { VisulimaError } from "./visulima-error.d.ts";
|
|
|
2
2
|
/**
|
|
3
3
|
* Will return an array of all causes in the error in the order they occurred.
|
|
4
4
|
*/
|
|
5
|
-
declare const getErrorCauses: <E = Error | VisulimaError
|
|
5
|
+
declare const getErrorCauses: <E = Error | VisulimaError>(error: E) => E[];
|
|
6
6
|
export default getErrorCauses;
|
package/dist/error/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { default as captureRawStackTrace } from '../packem_shared/captureRawStackTrace-ySw7cU0U.js';
|
|
2
|
-
export { default as getErrorCauses } from '../packem_shared/getErrorCauses-
|
|
3
|
-
export { renderError } from '../packem_shared/renderError-
|
|
4
|
-
export { default as deserializeError } from '../packem_shared/deserializeError-
|
|
2
|
+
export { default as getErrorCauses } from '../packem_shared/getErrorCauses-BLHM3CNA.js';
|
|
3
|
+
export { renderError } from '../packem_shared/renderError-BVWwJmI2.js';
|
|
4
|
+
export { default as deserializeError } from '../packem_shared/deserializeError-BEH-kMcX.js';
|
|
5
5
|
export { addKnownErrorConstructor, isErrorLike } from '../packem_shared/addKnownErrorConstructor-s_3SsXtQ.js';
|
|
6
6
|
export { default as NonError } from '../packem_shared/NonError-D5FGLYKY.js';
|
|
7
|
-
export { serialize as serializeError } from '../packem_shared/serializeError-
|
|
7
|
+
export { serialize as serializeError } from '../packem_shared/serializeError-CcomaUJN.js';
|
|
8
8
|
export { VisulimaError, isVisulimaError } from '../packem_shared/isVisulimaError-DA7QsCxH.js';
|
package/dist/error/types.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export { CODE_FRAME_POINTER, codeFrame } from './code-frame/index.js';
|
|
2
|
-
export { default as indexToLineColumn } from './packem_shared/indexToLineColumn-
|
|
2
|
+
export { default as indexToLineColumn } from './packem_shared/indexToLineColumn-BUb0GPKl.js';
|
|
3
3
|
export { default as aiPrompt } from './solution/ai/ai-prompt.js';
|
|
4
|
-
export { default as aiSolutionResponse } from './packem_shared/aiSolutionResponse-
|
|
5
|
-
export { default as errorHintFinder } from './packem_shared/errorHintFinder-
|
|
6
|
-
export { default as ruleBasedFinder } from './packem_shared/ruleBasedFinder-
|
|
4
|
+
export { default as aiSolutionResponse } from './packem_shared/aiSolutionResponse-DlSn3Imq.js';
|
|
5
|
+
export { default as errorHintFinder } from './packem_shared/errorHintFinder-bk-fyNyF.js';
|
|
6
|
+
export { default as ruleBasedFinder } from './packem_shared/ruleBasedFinder-E1R-t_rj.js';
|
|
7
7
|
export { default as NonError } from './packem_shared/NonError-D5FGLYKY.js';
|
|
8
8
|
export { default as captureRawStackTrace } from './packem_shared/captureRawStackTrace-ySw7cU0U.js';
|
|
9
|
-
export { default as deserializeError } from './packem_shared/deserializeError-
|
|
10
|
-
export { default as getErrorCauses } from './packem_shared/getErrorCauses-
|
|
11
|
-
export { default as parseStacktrace } from './packem_shared/parseStacktrace-
|
|
9
|
+
export { default as deserializeError } from './packem_shared/deserializeError-BEH-kMcX.js';
|
|
10
|
+
export { default as getErrorCauses } from './packem_shared/getErrorCauses-BLHM3CNA.js';
|
|
11
|
+
export { default as parseStacktrace } from './packem_shared/parseStacktrace-B_dIfRHt.js';
|
|
12
12
|
export { VisulimaError, isVisulimaError } from './packem_shared/isVisulimaError-DA7QsCxH.js';
|
|
13
13
|
export { addKnownErrorConstructor, isErrorLike } from './packem_shared/addKnownErrorConstructor-s_3SsXtQ.js';
|
|
14
|
-
export { formatStackFrameLine, formatStacktrace } from './packem_shared/formatStackFrameLine-
|
|
15
|
-
export { renderError } from './packem_shared/renderError-
|
|
16
|
-
export { serialize as serializeError } from './packem_shared/serializeError-
|
|
14
|
+
export { formatStackFrameLine, formatStacktrace } from './packem_shared/formatStackFrameLine-BaISxse1.js';
|
|
15
|
+
export { renderError } from './packem_shared/renderError-BVWwJmI2.js';
|
|
16
|
+
export { serialize as serializeError } from './packem_shared/serializeError-CcomaUJN.js';
|
|
@@ -31,7 +31,7 @@ const {
|
|
|
31
31
|
} = __cjs_getBuiltinModule("node:os");
|
|
32
32
|
import { generateText } from 'ai';
|
|
33
33
|
import aiPrompt from '../solution/ai/ai-prompt.js';
|
|
34
|
-
import aiSolutionResponse from './aiSolutionResponse-
|
|
34
|
+
import aiSolutionResponse from './aiSolutionResponse-DlSn3Imq.js';
|
|
35
35
|
|
|
36
36
|
const DRIVE_LETTER_START_RE = /^[A-Z]:\//i;
|
|
37
37
|
const normalizeWindowsPath = (input = "") => {
|
|
@@ -140,7 +140,7 @@ const join = (...segments) => {
|
|
|
140
140
|
continue;
|
|
141
141
|
}
|
|
142
142
|
if (path2.length > 0) {
|
|
143
|
-
const pathTrailing = path2
|
|
143
|
+
const pathTrailing = path2.at(-1) === "/";
|
|
144
144
|
const segLeading = seg[0] === "/";
|
|
145
145
|
const both = pathTrailing && segLeading;
|
|
146
146
|
if (both) {
|
package/dist/packem_shared/{aiSolutionResponse-CJBMLS9t.js → aiSolutionResponse-DlSn3Imq.js}
RENAMED
|
@@ -21,7 +21,7 @@ const aiSolutionResponse = (rawText) => {
|
|
|
21
21
|
].join("</br></br>");
|
|
22
22
|
}
|
|
23
23
|
const links = between("LINKS", "ENDLINKS", rawText).split("\n").map((link) => JSON.parse(link));
|
|
24
|
-
return `${description.replaceAll(/"([^"]*)"(
|
|
24
|
+
return `${description.replaceAll(/"([^"]*)"(?:\s|\.)/g, "<code>$1</code> ")}
|
|
25
25
|
|
|
26
26
|
## Links
|
|
27
27
|
|
|
@@ -23,7 +23,7 @@ const reconstructError = (serialized, options, depth) => {
|
|
|
23
23
|
return new NonError(JSON.stringify(serialized));
|
|
24
24
|
}
|
|
25
25
|
const { cause, errors, message, name, stack, ...properties } = serialized;
|
|
26
|
-
const Constructor = getErrorConstructor(name)
|
|
26
|
+
const Constructor = getErrorConstructor(name) ?? Error;
|
|
27
27
|
const error = name === "AggregateError" && Array.isArray(errors) ? reconstructAggregateError(Constructor, errors, message, options, depth) : new Constructor(message);
|
|
28
28
|
if (!error.name && name) {
|
|
29
29
|
error.name = name;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
const errorHintFinder = {
|
|
2
|
-
handle:
|
|
3
|
-
if (error.hint === void 0
|
|
4
|
-
return void 0;
|
|
2
|
+
handle: (error) => {
|
|
3
|
+
if (error.hint === void 0) {
|
|
4
|
+
return Promise.resolve(void 0);
|
|
5
5
|
}
|
|
6
6
|
if (typeof error.hint === "string" && error.hint !== "") {
|
|
7
|
-
return { body: error.hint };
|
|
7
|
+
return Promise.resolve({ body: error.hint });
|
|
8
8
|
}
|
|
9
9
|
if (typeof error.hint === "object" && typeof error.hint.body === "string") {
|
|
10
|
-
return error.hint;
|
|
10
|
+
return Promise.resolve(error.hint);
|
|
11
11
|
}
|
|
12
12
|
if (Array.isArray(error.hint)) {
|
|
13
|
-
return { body: error.hint.join("\n") };
|
|
13
|
+
return Promise.resolve({ body: error.hint.join("\n") });
|
|
14
14
|
}
|
|
15
|
-
return void 0;
|
|
15
|
+
return Promise.resolve(void 0);
|
|
16
16
|
},
|
|
17
17
|
name: "errorHint",
|
|
18
18
|
priority: 1
|
package/dist/packem_shared/{formatStackFrameLine-D3_6oSWZ.js → formatStackFrameLine-BaISxse1.js}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const formatStackFrameLine = (frame) => {
|
|
2
2
|
const method = frame.methodName && frame.methodName !== "<unknown>" ? `${frame.methodName} ` : "";
|
|
3
3
|
const file = frame.file ?? "<unknown>";
|
|
4
|
-
const line = frame.line ?? 0;
|
|
5
|
-
const column = frame.column ?? 0;
|
|
4
|
+
const line = String(frame.line ?? 0);
|
|
5
|
+
const column = String(frame.column ?? 0);
|
|
6
6
|
if (method.trim()) {
|
|
7
7
|
return ` at ${method}(${file}:${line}:${column})`;
|
|
8
8
|
}
|
|
@@ -11,8 +11,8 @@ const formatStackFrameLine = (frame) => {
|
|
|
11
11
|
const formatStacktrace = (frames, options) => {
|
|
12
12
|
const lines = [];
|
|
13
13
|
if (options?.header && (options.header.name || options.header.message)) {
|
|
14
|
-
const headerName =
|
|
15
|
-
const headerMessage =
|
|
14
|
+
const headerName = options.header.name ?? "Error";
|
|
15
|
+
const headerMessage = options.header.message ?? "";
|
|
16
16
|
lines.push(`${headerName}${headerMessage ? ": " : ""}${headerMessage}`);
|
|
17
17
|
}
|
|
18
18
|
for (const frame of frames) {
|
|
@@ -14,9 +14,10 @@ const binarySearch = (element, array) => {
|
|
|
14
14
|
}
|
|
15
15
|
return m;
|
|
16
16
|
};
|
|
17
|
+
const LINE_BREAK_REGEX = /\n|\r(?!\n)/;
|
|
17
18
|
const getLineStartIndexes = (string_) => (
|
|
18
19
|
// eslint-disable-next-line unicorn/no-array-reduce
|
|
19
|
-
string_.split(
|
|
20
|
+
string_.split(LINE_BREAK_REGEX).reduce(
|
|
20
21
|
(accumulator, current) => {
|
|
21
22
|
accumulator.push(accumulator.at(-1) + current.length + 1);
|
|
22
23
|
return accumulator;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const debugLog = (message, ...arguments_) => {
|
|
2
|
-
if (process.env.DEBUG &&
|
|
2
|
+
if (process.env.DEBUG && process.env.DEBUG === "true") {
|
|
3
3
|
console.debug(`error:parse-stacktrace: ${message}`, ...arguments_);
|
|
4
4
|
}
|
|
5
5
|
};
|
|
6
6
|
const UNKNOWN_FUNCTION = "<unknown>";
|
|
7
7
|
const CHROMIUM_REGEX = /^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
|
|
8
8
|
const CHROMIUM_EVAL_REGEX = /\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/;
|
|
9
|
-
const CHROMIUM_MAPPED = /(.*?):(\d+):(\d+)(
|
|
10
|
-
const WINDOWS_EVAL_REGEX = /
|
|
9
|
+
const CHROMIUM_MAPPED = /(.*?):(\d+):(\d+)(?:\s<-\s.+:\d+:\d+)?/;
|
|
10
|
+
const WINDOWS_EVAL_REGEX = /eval\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*<anonymous>?:(\d+)?:(\d+)/;
|
|
11
11
|
const NODE_REGEX = /^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/;
|
|
12
12
|
const NODE_NESTED_REGEX = /in\s(.*)\s\(at\s(.+)\)\sat/;
|
|
13
13
|
const REACT_ANDROID_NATIVE_REGEX = /^(?:.*@)?(.*):(\d+):(\d+)$/;
|
|
@@ -15,6 +15,14 @@ const GECKO_REGEX = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native
|
|
|
15
15
|
const GECKO_EVAL_REGEX = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
|
|
16
16
|
const FIREFOX_REGEX = /(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/;
|
|
17
17
|
const WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
|
|
18
|
+
const AT_PREFIX_REGEX = /at\s/;
|
|
19
|
+
const CHROMIUM_EVAL_SPLIT_REGEX = /^(\S+):(\d+):(\d+)$|^(\S+):(\d+)$/;
|
|
20
|
+
const TRIM_REGEX = /^\s+|\s+$/g;
|
|
21
|
+
const ERROR_LINE_REGEX = /\S*(?:Error: |AggregateError:)/;
|
|
22
|
+
const ANONYMOUS_FUNCTION_REGEX = /^Anonymous function$/;
|
|
23
|
+
const NODE_LINE_REGEX = /^\s*in\s.*/;
|
|
24
|
+
const CHROMIUM_LINE_REGEX = /^.*?\s*at\s.*/;
|
|
25
|
+
const GECKO_LINE_REGEX = /^.*?\s*@.*|\[native code\]/;
|
|
18
26
|
const extractSafariExtensionDetails = (methodName, url) => {
|
|
19
27
|
const isSafariExtension = methodName.includes("safari-extension");
|
|
20
28
|
const isSafariWebExtension = methodName.includes("safari-web-extension");
|
|
@@ -40,7 +48,7 @@ const parseNode = (line) => {
|
|
|
40
48
|
column: split[2] ? +split[2] : void 0,
|
|
41
49
|
file: split[0],
|
|
42
50
|
line: split[1] ? +split[1] : void 0,
|
|
43
|
-
methodName: nestedNode[1]
|
|
51
|
+
methodName: nestedNode[1] ?? UNKNOWN_FUNCTION,
|
|
44
52
|
raw: line,
|
|
45
53
|
type: void 0
|
|
46
54
|
};
|
|
@@ -50,9 +58,9 @@ const parseNode = (line) => {
|
|
|
50
58
|
debugLog(`parse node error stack line: "${line}"`, `found: ${JSON.stringify(node)}`);
|
|
51
59
|
const trace = {
|
|
52
60
|
column: node[4] ? +node[4] : void 0,
|
|
53
|
-
file: node[2] ? node[2].replace(
|
|
61
|
+
file: node[2] ? node[2].replace(AT_PREFIX_REGEX, "") : void 0,
|
|
54
62
|
line: node[3] ? +node[3] : void 0,
|
|
55
|
-
methodName: node[1]
|
|
63
|
+
methodName: node[1] ?? UNKNOWN_FUNCTION,
|
|
56
64
|
raw: line,
|
|
57
65
|
type: line.startsWith("internal") ? "internal" : void 0
|
|
58
66
|
};
|
|
@@ -72,7 +80,7 @@ const parseChromium = (line) => {
|
|
|
72
80
|
if (isEval) {
|
|
73
81
|
const subMatch = CHROMIUM_EVAL_REGEX.exec(line);
|
|
74
82
|
if (subMatch) {
|
|
75
|
-
const split =
|
|
83
|
+
const split = CHROMIUM_EVAL_SPLIT_REGEX.exec(subMatch[1]);
|
|
76
84
|
if (split) {
|
|
77
85
|
parts[2] = split[4] ?? split[1];
|
|
78
86
|
parts[3] = split[5] ?? split[2];
|
|
@@ -94,14 +102,14 @@ const parseChromium = (line) => {
|
|
|
94
102
|
const windowsSubMatch = WINDOWS_EVAL_REGEX.exec(line);
|
|
95
103
|
if (windowsSubMatch) {
|
|
96
104
|
windowsParts = {
|
|
97
|
-
column: windowsSubMatch[
|
|
98
|
-
file: windowsSubMatch[
|
|
99
|
-
line: windowsSubMatch[
|
|
105
|
+
column: windowsSubMatch[4] ? +windowsSubMatch[4] : void 0,
|
|
106
|
+
file: windowsSubMatch[2],
|
|
107
|
+
line: windowsSubMatch[3] ? +windowsSubMatch[3] : void 0
|
|
100
108
|
};
|
|
101
109
|
evalOrigin = {
|
|
102
|
-
column: windowsSubMatch[
|
|
103
|
-
file: windowsSubMatch[
|
|
104
|
-
line: windowsSubMatch[
|
|
110
|
+
column: windowsSubMatch[6] ? +windowsSubMatch[6] : void 0,
|
|
111
|
+
file: windowsSubMatch[1],
|
|
112
|
+
line: windowsSubMatch[5] ? +windowsSubMatch[5] : void 0,
|
|
105
113
|
methodName: "eval",
|
|
106
114
|
raw: windowsSubMatch[0],
|
|
107
115
|
type: "eval"
|
|
@@ -111,7 +119,7 @@ const parseChromium = (line) => {
|
|
|
111
119
|
}
|
|
112
120
|
const [methodName, file] = extractSafariExtensionDetails(
|
|
113
121
|
// Normalize IE's 'Anonymous function'
|
|
114
|
-
parts[1] ? parts[1].replace(
|
|
122
|
+
parts[1] ? parts[1].replace(ANONYMOUS_FUNCTION_REGEX, "<anonymous>") : UNKNOWN_FUNCTION,
|
|
115
123
|
parts[2]
|
|
116
124
|
);
|
|
117
125
|
const trace = {
|
|
@@ -156,7 +164,7 @@ const parseGecko = (line, topFrameMeta) => {
|
|
|
156
164
|
}
|
|
157
165
|
const [methodName, file] = extractSafariExtensionDetails(
|
|
158
166
|
// Normalize IE's 'Anonymous function'
|
|
159
|
-
parts[1] ? parts[1].replace(
|
|
167
|
+
parts[1] ? parts[1].replace(ANONYMOUS_FUNCTION_REGEX, "<anonymous>") : UNKNOWN_FUNCTION,
|
|
160
168
|
parts[3]
|
|
161
169
|
);
|
|
162
170
|
let column;
|
|
@@ -193,6 +201,7 @@ const parseFirefox = (line, topFrameMeta) => {
|
|
|
193
201
|
column: parts[4] ? +parts[4] : topFrameMeta?.column ?? void 0,
|
|
194
202
|
file: parts[2],
|
|
195
203
|
line: parts[3] ? +parts[3] : topFrameMeta?.line ?? void 0,
|
|
204
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentionally using || to treat empty string as unknown
|
|
196
205
|
methodName: parts[1] || UNKNOWN_FUNCTION,
|
|
197
206
|
raw: line,
|
|
198
207
|
type: void 0
|
|
@@ -216,10 +225,12 @@ const parseReactAndroidNative = (line) => {
|
|
|
216
225
|
return void 0;
|
|
217
226
|
};
|
|
218
227
|
const parseStacktrace = (error, { filter, frameLimit = 50 } = {}) => {
|
|
219
|
-
|
|
228
|
+
const errorRecord = error;
|
|
229
|
+
const rawStack = typeof errorRecord.stacktrace === "string" ? errorRecord.stacktrace : error.stack ?? "";
|
|
230
|
+
let lines = rawStack.split("\n").map((line) => {
|
|
220
231
|
const cleanedLine = WEBPACK_ERROR_REGEXP.test(line) ? line.replace(WEBPACK_ERROR_REGEXP, "$1") : line;
|
|
221
|
-
return cleanedLine.
|
|
222
|
-
}).filter((line) =>
|
|
232
|
+
return cleanedLine.replaceAll(TRIM_REGEX, "");
|
|
233
|
+
}).filter((line) => !ERROR_LINE_REGEX.test(line) && line !== "eval code");
|
|
223
234
|
if (filter) {
|
|
224
235
|
lines = lines.filter((element) => filter(element));
|
|
225
236
|
}
|
|
@@ -232,32 +243,33 @@ const parseStacktrace = (error, { filter, frameLimit = 50 } = {}) => {
|
|
|
232
243
|
return stack;
|
|
233
244
|
}
|
|
234
245
|
let parseResult;
|
|
235
|
-
if (
|
|
246
|
+
if (NODE_LINE_REGEX.test(line)) {
|
|
236
247
|
parseResult = parseNode(line);
|
|
237
|
-
} else if (
|
|
248
|
+
} else if (CHROMIUM_LINE_REGEX.test(line)) {
|
|
238
249
|
parseResult = parseChromium(line);
|
|
239
|
-
} else if (
|
|
250
|
+
} else if (GECKO_LINE_REGEX.test(line)) {
|
|
240
251
|
let topFrameMeta;
|
|
241
252
|
if (currentIndex === 0) {
|
|
242
|
-
|
|
253
|
+
const browserError = error;
|
|
254
|
+
const columnNumber = browserError.columnNumber;
|
|
255
|
+
const lineNumber = browserError.lineNumber;
|
|
256
|
+
const safariLine = browserError.line;
|
|
257
|
+
const safariColumn = browserError.column;
|
|
258
|
+
if (columnNumber || lineNumber) {
|
|
243
259
|
topFrameMeta = {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
// @ts-expect-error columnNumber and lineNumber property only exists on Firefox
|
|
247
|
-
line: error.lineNumber,
|
|
260
|
+
column: columnNumber,
|
|
261
|
+
line: lineNumber,
|
|
248
262
|
type: "firefox"
|
|
249
263
|
};
|
|
250
|
-
} else if (
|
|
264
|
+
} else if (safariLine || safariColumn) {
|
|
251
265
|
topFrameMeta = {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
// @ts-expect-error line property only exists on safari
|
|
255
|
-
line: error.line,
|
|
266
|
+
column: safariColumn,
|
|
267
|
+
line: safariLine,
|
|
256
268
|
type: "safari"
|
|
257
269
|
};
|
|
258
270
|
}
|
|
259
271
|
}
|
|
260
|
-
parseResult = parseFirefox(line, topFrameMeta)
|
|
272
|
+
parseResult = parseFirefox(line, topFrameMeta) ?? parseGecko(line, topFrameMeta);
|
|
261
273
|
} else {
|
|
262
274
|
parseResult = parseReactAndroidNative(line);
|
|
263
275
|
}
|
|
@@ -31,11 +31,11 @@ const {
|
|
|
31
31
|
fileURLToPath
|
|
32
32
|
} = __cjs_getBuiltinModule("node:url");
|
|
33
33
|
import { codeFrame } from '../code-frame/index.js';
|
|
34
|
-
import parseStacktrace from './parseStacktrace-
|
|
34
|
+
import parseStacktrace from './parseStacktrace-B_dIfRHt.js';
|
|
35
35
|
|
|
36
36
|
const getPrefix = (prefix, indentation, deep) => {
|
|
37
37
|
if (deep === 0) {
|
|
38
|
-
return prefix
|
|
38
|
+
return prefix;
|
|
39
39
|
}
|
|
40
40
|
if (indentation === " ") {
|
|
41
41
|
return prefix + " ".repeat(deep);
|
|
@@ -63,7 +63,7 @@ const getHint = (error, { color, indentation, prefix }, deep) => {
|
|
|
63
63
|
let message = "";
|
|
64
64
|
if (Array.isArray(error.hint)) {
|
|
65
65
|
for (const line of error.hint) {
|
|
66
|
-
message += `${
|
|
66
|
+
message += `${spaces + line}
|
|
67
67
|
`;
|
|
68
68
|
}
|
|
69
69
|
} else {
|
|
@@ -76,7 +76,7 @@ const getMainFrame = (trace, { color, cwd: cwdPath, displayShortPath, indentatio
|
|
|
76
76
|
const { fileLine, method } = color;
|
|
77
77
|
return `${getPrefix(prefix, indentation, deep)}at ${trace.methodName ? `${method(trace.methodName)} ` : ""}${fileLine(filePath)}:${fileLine(
|
|
78
78
|
trace.line?.toString() ?? ""
|
|
79
|
-
)}
|
|
79
|
+
)}`;
|
|
80
80
|
};
|
|
81
81
|
const getCode = (trace, { color, indentation, linesAbove, linesBelow, prefix, showGutter, showLineNumbers, tabWidth }, deep) => {
|
|
82
82
|
if (trace.file === void 0) {
|
|
@@ -18,7 +18,7 @@ const rules = [
|
|
|
18
18
|
{
|
|
19
19
|
name: "esm-cjs-interop",
|
|
20
20
|
test: (error) => {
|
|
21
|
-
const message =
|
|
21
|
+
const { message } = error;
|
|
22
22
|
if (has(
|
|
23
23
|
message,
|
|
24
24
|
"err_require_esm",
|
|
@@ -52,7 +52,7 @@ const rules = [
|
|
|
52
52
|
{
|
|
53
53
|
name: "missing-default-export",
|
|
54
54
|
test: (error) => {
|
|
55
|
-
const message =
|
|
55
|
+
const { message } = error;
|
|
56
56
|
if (has(message, "default export not found", "has no default export", "does not provide an export named 'default'", "is not exported from")) {
|
|
57
57
|
return {
|
|
58
58
|
md: [
|
|
@@ -73,7 +73,7 @@ const rules = [
|
|
|
73
73
|
{
|
|
74
74
|
name: "port-in-use",
|
|
75
75
|
test: (error) => {
|
|
76
|
-
const message =
|
|
76
|
+
const { message } = error;
|
|
77
77
|
if (has(message, "eaddrinuse", "address already in use", "listen eaddrinuse")) {
|
|
78
78
|
return {
|
|
79
79
|
md: [
|
|
@@ -96,7 +96,7 @@ const rules = [
|
|
|
96
96
|
{
|
|
97
97
|
name: "file-not-found-or-case",
|
|
98
98
|
test: (error, file) => {
|
|
99
|
-
const message =
|
|
99
|
+
const { message } = error;
|
|
100
100
|
if (has(message, "enoent", "module not found", "cannot find module")) {
|
|
101
101
|
return {
|
|
102
102
|
md: [
|
|
@@ -104,7 +104,7 @@ const rules = [
|
|
|
104
104
|
"If using TS path aliases, verify `tsconfig.paths` and bundler aliases.",
|
|
105
105
|
"",
|
|
106
106
|
"Current file:",
|
|
107
|
-
code(`${file.file}:${file.line}`)
|
|
107
|
+
code(`${file.file}:${String(file.line)}`)
|
|
108
108
|
].join("\n"),
|
|
109
109
|
title: "Missing file or path case mismatch"
|
|
110
110
|
};
|
|
@@ -115,7 +115,7 @@ const rules = [
|
|
|
115
115
|
{
|
|
116
116
|
name: "ts-path-mapping",
|
|
117
117
|
test: (error) => {
|
|
118
|
-
const message =
|
|
118
|
+
const { message } = error;
|
|
119
119
|
if (has(message, "ts2307", "cannot find module") || message.includes("TS2307")) {
|
|
120
120
|
return {
|
|
121
121
|
md: [
|
|
@@ -139,7 +139,7 @@ const rules = [
|
|
|
139
139
|
{
|
|
140
140
|
name: "network-dns-enotfound",
|
|
141
141
|
test: (error) => {
|
|
142
|
-
const message =
|
|
142
|
+
const { message } = error;
|
|
143
143
|
if (has(message, "enotfound", "getaddrinfo enotfound", "dns", "fetch failed", "ecconnrefused", "econnrefused")) {
|
|
144
144
|
return {
|
|
145
145
|
md: [
|
|
@@ -161,7 +161,7 @@ const rules = [
|
|
|
161
161
|
{
|
|
162
162
|
name: "undefined-property",
|
|
163
163
|
test: (error) => {
|
|
164
|
-
const message =
|
|
164
|
+
const { message } = error;
|
|
165
165
|
if (has(message, "cannot read properties of undefined", "reading '")) {
|
|
166
166
|
return {
|
|
167
167
|
md: [
|
|
@@ -181,23 +181,23 @@ const rules = [
|
|
|
181
181
|
}
|
|
182
182
|
];
|
|
183
183
|
const ruleBasedFinder = {
|
|
184
|
-
handle:
|
|
184
|
+
handle: (error, file) => {
|
|
185
185
|
try {
|
|
186
186
|
const matches = rules.map((r) => {
|
|
187
187
|
return { match: r.test(error, file), rule: r };
|
|
188
188
|
}).filter((x) => Boolean(x.match));
|
|
189
189
|
if (matches.length === 0) {
|
|
190
|
-
return void 0;
|
|
190
|
+
return Promise.resolve(void 0);
|
|
191
191
|
}
|
|
192
|
-
const sections = matches.toSorted((a, b) => (a.match.priority
|
|
192
|
+
const sections = matches.toSorted((a, b) => (a.match.priority ?? 0) - (b.match.priority ?? 0)).map((m) => `#### ${m.match.title}
|
|
193
193
|
|
|
194
194
|
${m.match.md}`).join("\n\n---\n\n");
|
|
195
195
|
if (sections === "") {
|
|
196
|
-
return void 0;
|
|
196
|
+
return Promise.resolve(void 0);
|
|
197
197
|
}
|
|
198
|
-
return { body: sections, header: "### Potential fixes detected" };
|
|
198
|
+
return Promise.resolve({ body: sections, header: "### Potential fixes detected" });
|
|
199
199
|
} catch {
|
|
200
|
-
return void 0;
|
|
200
|
+
return Promise.resolve(void 0);
|
|
201
201
|
}
|
|
202
202
|
},
|
|
203
203
|
name: "ruleBasedHints",
|
|
@@ -38,9 +38,6 @@ const ErrorProto = Object.create(
|
|
|
38
38
|
|
|
39
39
|
const toJsonWasCalled = /* @__PURE__ */ new WeakSet();
|
|
40
40
|
const makePropertiesEnumerable = (object) => {
|
|
41
|
-
if (!object || typeof object !== "object") {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
41
|
const props = Object.getOwnPropertyNames(object);
|
|
45
42
|
for (const prop of props) {
|
|
46
43
|
const descriptor = Object.getOwnPropertyDescriptor(object, prop);
|
|
@@ -61,7 +58,11 @@ const toJSON = (from) => {
|
|
|
61
58
|
toJsonWasCalled.add(from);
|
|
62
59
|
const json = from.toJSON();
|
|
63
60
|
toJsonWasCalled.delete(from);
|
|
64
|
-
if (
|
|
61
|
+
if (
|
|
62
|
+
// Only make properties enumerable if the object is extensible
|
|
63
|
+
// Non-extensible objects (like when toJSON returns 'this') should preserve original enumerability
|
|
64
|
+
Object.isExtensible(json)
|
|
65
|
+
) {
|
|
65
66
|
makePropertiesEnumerable(json);
|
|
66
67
|
}
|
|
67
68
|
return json;
|
|
@@ -70,7 +71,7 @@ const serializeValue = (value, seen, depth, options) => {
|
|
|
70
71
|
if (value && value instanceof Uint8Array && value.constructor.name === "Buffer") {
|
|
71
72
|
return "[object Buffer]";
|
|
72
73
|
}
|
|
73
|
-
if (value !== null && typeof value === "object" && typeof value.pipe === "function") {
|
|
74
|
+
if (value !== null && typeof value === "object" && "pipe" in value && typeof value.pipe === "function") {
|
|
74
75
|
return "[object Stream]";
|
|
75
76
|
}
|
|
76
77
|
if (value instanceof Error) {
|
|
@@ -80,17 +81,17 @@ const serializeValue = (value, seen, depth, options) => {
|
|
|
80
81
|
depth += 1;
|
|
81
82
|
return _serialize(value, options, seen, depth);
|
|
82
83
|
}
|
|
83
|
-
if (options.useToJSON && typeof value.toJSON === "function") {
|
|
84
|
+
if (options.useToJSON && value !== null && typeof value === "object" && "toJSON" in value && typeof value.toJSON === "function") {
|
|
84
85
|
return value.toJSON();
|
|
85
86
|
}
|
|
86
|
-
if (
|
|
87
|
+
if (value instanceof Date) {
|
|
87
88
|
return value.toISOString();
|
|
88
89
|
}
|
|
89
90
|
if (typeof value === "function") {
|
|
90
91
|
return `[Function: ${value.name || "anonymous"}]`;
|
|
91
92
|
}
|
|
92
93
|
if (typeof value === "bigint") {
|
|
93
|
-
return `${value}n`;
|
|
94
|
+
return `${String(value)}n`;
|
|
94
95
|
}
|
|
95
96
|
if (isPlainObject(value)) {
|
|
96
97
|
if (options.maxDepth !== void 0 && options.maxDepth !== Number.POSITIVE_INFINITY && depth + 1 >= options.maxDepth) {
|
|
@@ -160,9 +161,10 @@ const _serialize = (error, options, seen, depth) => {
|
|
|
160
161
|
writable: true
|
|
161
162
|
});
|
|
162
163
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
const causeValue = error.cause;
|
|
165
|
+
if (causeValue !== void 0 && causeValue !== null) {
|
|
166
|
+
if (causeValue instanceof Error) {
|
|
167
|
+
if (seen.has(causeValue)) {
|
|
166
168
|
Object.defineProperty(protoError, "cause", {
|
|
167
169
|
configurable: true,
|
|
168
170
|
enumerable: true,
|
|
@@ -173,12 +175,12 @@ const _serialize = (error, options, seen, depth) => {
|
|
|
173
175
|
Object.defineProperty(protoError, "cause", {
|
|
174
176
|
configurable: true,
|
|
175
177
|
enumerable: true,
|
|
176
|
-
value: _serialize(
|
|
178
|
+
value: _serialize(causeValue, options, seen, depth),
|
|
177
179
|
writable: true
|
|
178
180
|
});
|
|
179
181
|
}
|
|
180
182
|
} else {
|
|
181
|
-
const serializedCause = serializeValue(
|
|
183
|
+
const serializedCause = serializeValue(causeValue, seen, depth, options);
|
|
182
184
|
Object.defineProperty(protoError, "cause", {
|
|
183
185
|
configurable: true,
|
|
184
186
|
enumerable: true,
|
|
@@ -2,7 +2,7 @@ const aiPrompt = ({
|
|
|
2
2
|
applicationType,
|
|
3
3
|
error,
|
|
4
4
|
file
|
|
5
|
-
}) => `You are a very skilled ${file.language} programmer.
|
|
5
|
+
}) => `You are a very skilled ${file.language ?? "unknown"} programmer.
|
|
6
6
|
|
|
7
7
|
${applicationType ? `You are working on a ${applicationType} application.` : ""}
|
|
8
8
|
|
|
@@ -21,13 +21,13 @@ ENDLINKS
|
|
|
21
21
|
|
|
22
22
|
Here comes the context and the exception message:
|
|
23
23
|
|
|
24
|
-
Line: ${file.line}
|
|
24
|
+
Line: ${String(file.line)}
|
|
25
25
|
|
|
26
26
|
File:
|
|
27
27
|
${file.file}
|
|
28
28
|
|
|
29
29
|
Snippet including line numbers:
|
|
30
|
-
${file.snippet}
|
|
30
|
+
${file.snippet ?? ""}
|
|
31
31
|
|
|
32
32
|
Exception class:
|
|
33
33
|
${error.name}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as aiFinder } from '../../packem_shared/aiFinder-
|
|
1
|
+
export { default as aiFinder } from '../../packem_shared/aiFinder-CDaOm_ur.js';
|
|
2
2
|
export { default as aiPrompt } from './ai-prompt.js';
|
|
3
|
-
export { default as aiSolutionResponse } from '../../packem_shared/aiSolutionResponse-
|
|
3
|
+
export { default as aiSolutionResponse } from '../../packem_shared/aiSolutionResponse-DlSn3Imq.js';
|
package/dist/solution/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as errorHintFinder } from '../packem_shared/errorHintFinder-
|
|
2
|
-
export { default as ruleBasedFinder } from '../packem_shared/ruleBasedFinder-
|
|
1
|
+
export { default as errorHintFinder } from '../packem_shared/errorHintFinder-bk-fyNyF.js';
|
|
2
|
+
export { default as ruleBasedFinder } from '../packem_shared/ruleBasedFinder-E1R-t_rj.js';
|
package/dist/solution/types.d.ts
CHANGED
package/dist/stacktrace/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as parseStacktrace } from '../packem_shared/parseStacktrace-
|
|
2
|
-
export { formatStackFrameLine, formatStacktrace } from '../packem_shared/formatStackFrameLine-
|
|
1
|
+
export { default as parseStacktrace } from '../packem_shared/parseStacktrace-B_dIfRHt.js';
|
|
2
|
+
export { formatStackFrameLine, formatStacktrace } from '../packem_shared/formatStackFrameLine-BaISxse1.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export type TraceType = "eval" | "internal" | "native" | undefined;
|
|
2
2
|
export interface Trace {
|
|
3
|
-
column
|
|
4
|
-
evalOrigin?: Trace
|
|
5
|
-
file
|
|
6
|
-
line
|
|
7
|
-
methodName
|
|
3
|
+
column?: number;
|
|
4
|
+
evalOrigin?: Trace;
|
|
5
|
+
file?: string;
|
|
6
|
+
line?: number;
|
|
7
|
+
methodName?: string;
|
|
8
8
|
raw: string;
|
|
9
|
-
type?: TraceType
|
|
9
|
+
type?: TraceType;
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/error",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.8",
|
|
4
4
|
"description": "Error with more than just a message, stacktrace parsing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"pretty",
|
|
37
37
|
"visulima"
|
|
38
38
|
],
|
|
39
|
-
"homepage": "https://
|
|
39
|
+
"homepage": "https://visulima.com/packages/error/",
|
|
40
40
|
"bugs": {
|
|
41
41
|
"url": "https://github.com/visulima/visulima/issues"
|
|
42
42
|
},
|
|
@@ -99,16 +99,14 @@
|
|
|
99
99
|
"CHANGELOG.md",
|
|
100
100
|
"LICENSE.md"
|
|
101
101
|
],
|
|
102
|
-
"dependencies": {},
|
|
103
102
|
"peerDependencies": {
|
|
104
|
-
"ai": "6.0.
|
|
103
|
+
"ai": "6.0.154"
|
|
105
104
|
},
|
|
106
105
|
"peerDependenciesMeta": {
|
|
107
106
|
"ai": {
|
|
108
107
|
"optional": true
|
|
109
108
|
}
|
|
110
109
|
},
|
|
111
|
-
"optionalDependencies": {},
|
|
112
110
|
"engines": {
|
|
113
111
|
"node": ">=22.13 <=25.x"
|
|
114
112
|
},
|