@visulima/error 4.6.0 → 4.6.1
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 +10 -0
- package/dist/code-frame/index.cjs +6 -136
- package/dist/code-frame/index.mjs +6 -131
- package/dist/error/index.cjs +1 -25
- package/dist/error/index.mjs +1 -8
- package/dist/index.cjs +1 -43
- package/dist/index.mjs +1 -16
- package/dist/packem_shared/NonError-CQn4sdxd.cjs +1 -0
- package/dist/packem_shared/NonError-CS10kwil.mjs +1 -0
- package/dist/packem_shared/addKnownErrorConstructor-B5dNFGsR.cjs +1 -0
- package/dist/packem_shared/addKnownErrorConstructor-BqqnTSZp.mjs +1 -0
- package/dist/packem_shared/aiFinder-Be-xHFVO.mjs +1 -0
- package/dist/packem_shared/aiFinder-CN0pneE2.cjs +1 -0
- package/dist/packem_shared/aiSolutionResponse-C5apAmTu.cjs +10 -0
- package/dist/packem_shared/aiSolutionResponse-RD0AK1jh.mjs +10 -0
- package/dist/packem_shared/captureRawStackTrace-B9d1821F.cjs +1 -0
- package/dist/packem_shared/captureRawStackTrace-CQPNHvBG.mjs +1 -0
- package/dist/packem_shared/deserializeError-2C6o7QF7.cjs +1 -0
- package/dist/packem_shared/deserializeError-tzZhIV70.mjs +1 -0
- package/dist/packem_shared/errorHintFinder-C_g0nvml.mjs +2 -0
- package/dist/packem_shared/errorHintFinder-DRCn1Ysx.cjs +2 -0
- package/dist/packem_shared/formatStackFrameLine-DD2DUdW0.cjs +2 -0
- package/dist/packem_shared/formatStackFrameLine-iU54KA81.mjs +2 -0
- package/dist/packem_shared/getErrorCauses-B7_Z_gEF.cjs +1 -0
- package/dist/packem_shared/getErrorCauses-D025FGyO.mjs +1 -0
- package/dist/packem_shared/index-CLFYRLyq.mjs +1 -0
- package/dist/packem_shared/index-CqSGigts.cjs +1 -0
- package/dist/packem_shared/indexToLineColumn-B1F7aNZh.mjs +1 -0
- package/dist/packem_shared/indexToLineColumn-C_v57REF.cjs +1 -0
- package/dist/packem_shared/isVisulimaError-CrvBm0kw.cjs +1 -0
- package/dist/packem_shared/isVisulimaError-jVZgumOU.mjs +1 -0
- package/dist/packem_shared/parseStacktrace-Dnxnc4PL.mjs +2 -0
- package/dist/packem_shared/parseStacktrace-MW4-SLXl.cjs +2 -0
- package/dist/packem_shared/renderError-D7R71d_7.mjs +18 -0
- package/dist/packem_shared/renderError-D8XJnkIF.cjs +18 -0
- package/dist/packem_shared/ruleBasedFinder-DTyLJeCs.cjs +35 -0
- package/dist/packem_shared/ruleBasedFinder-W5UXhtHl.mjs +35 -0
- package/dist/packem_shared/serializeError-7S1IG6zs.cjs +1 -0
- package/dist/packem_shared/serializeError-Bc-QciX0.mjs +1 -0
- package/dist/solution/ai/ai-prompt.cjs +7 -17
- package/dist/solution/ai/ai-prompt.mjs +7 -15
- package/dist/solution/ai/index.cjs +1 -13
- package/dist/solution/ai/index.mjs +1 -3
- package/dist/solution/index.cjs +1 -11
- package/dist/solution/index.mjs +1 -2
- package/dist/stacktrace/index.cjs +1 -12
- package/dist/stacktrace/index.mjs +1 -2
- package/package.json +1 -1
- package/dist/packem_shared/NonError-BrwMc2LE.mjs +0 -13
- package/dist/packem_shared/NonError-DqwGL5Cy.cjs +0 -15
- package/dist/packem_shared/addKnownErrorConstructor-DBmmT2OF.mjs +0 -32
- package/dist/packem_shared/addKnownErrorConstructor-J1_ZUURa.cjs +0 -39
- package/dist/packem_shared/aiFinder-BR9Pq804.cjs +0 -259
- package/dist/packem_shared/aiFinder-CFHvOjD8.mjs +0 -257
- package/dist/packem_shared/aiSolutionResponse-BaN1M990.mjs +0 -36
- package/dist/packem_shared/aiSolutionResponse-Cqi0mFxy.cjs +0 -38
- package/dist/packem_shared/captureRawStackTrace-ClSI1tHb.cjs +0 -14
- package/dist/packem_shared/captureRawStackTrace-Tl3Rqkat.mjs +0 -12
- package/dist/packem_shared/deserializeError-Be3qOGBQ.cjs +0 -120
- package/dist/packem_shared/deserializeError-DuzHucBb.mjs +0 -118
- package/dist/packem_shared/errorHintFinder-CQy_qIK3.mjs +0 -23
- package/dist/packem_shared/errorHintFinder-DZugFHq0.cjs +0 -25
- package/dist/packem_shared/formatStackFrameLine-DcXSX--m.cjs +0 -31
- package/dist/packem_shared/formatStackFrameLine-DqkmKWH3.mjs +0 -26
- package/dist/packem_shared/getErrorCauses-CG_JRE6j.mjs +0 -24
- package/dist/packem_shared/getErrorCauses-miTeYJEG.cjs +0 -26
- package/dist/packem_shared/index-BmoOJLvu.mjs +0 -12
- package/dist/packem_shared/index-C53Tqb7g.cjs +0 -14
- package/dist/packem_shared/indexToLineColumn-CKQKtKEK.mjs +0 -52
- package/dist/packem_shared/indexToLineColumn-Cro5eT8v.cjs +0 -54
- package/dist/packem_shared/isVisulimaError-Bb1_TB6w.cjs +0 -44
- package/dist/packem_shared/isVisulimaError-zyd80Gui.mjs +0 -39
- package/dist/packem_shared/parseStacktrace-BlguTUcF.mjs +0 -275
- package/dist/packem_shared/parseStacktrace-woJgU2XY.cjs +0 -277
- package/dist/packem_shared/renderError-Cn8M0fQ3.mjs +0 -180
- package/dist/packem_shared/renderError-n3kXGdYj.cjs +0 -184
- package/dist/packem_shared/ruleBasedFinder-Cbmc6N7f.mjs +0 -227
- package/dist/packem_shared/ruleBasedFinder-CkybTSHw.cjs +0 -229
- package/dist/packem_shared/serializeError-DHIelq5o.mjs +0 -144
- package/dist/packem_shared/serializeError-Dt7oFM2R.cjs +0 -148
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
const debugLog = /* @__PURE__ */ __name((message, ...arguments_) => {
|
|
4
|
-
if (process.env.DEBUG && String(process.env.DEBUG) === "true") {
|
|
5
|
-
console.debug(`error:parse-stacktrace: ${message}`, ...arguments_);
|
|
6
|
-
}
|
|
7
|
-
}, "debugLog");
|
|
8
|
-
const UNKNOWN_FUNCTION = "<unknown>";
|
|
9
|
-
const CHROMIUM_REGEX = /^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
|
|
10
|
-
const CHROMIUM_EVAL_REGEX = /\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/;
|
|
11
|
-
const CHROMIUM_MAPPED = /(.*?):(\d+):(\d+)(\s<-\s(.+):(\d+):(\d+))?/;
|
|
12
|
-
const WINDOWS_EVAL_REGEX = /(eval)\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*(<anonymous>)?:(\d+)?:(\d+)/;
|
|
13
|
-
const NODE_REGEX = /^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/;
|
|
14
|
-
const NODE_NESTED_REGEX = /in\s(.*)\s\(at\s(.+)\)\sat/;
|
|
15
|
-
const REACT_ANDROID_NATIVE_REGEX = /^(?:.*@)?(.*):(\d+):(\d+)$/;
|
|
16
|
-
const GECKO_REGEX = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
|
|
17
|
-
const GECKO_EVAL_REGEX = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
|
|
18
|
-
const FIREFOX_REGEX = /(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/;
|
|
19
|
-
const WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
|
|
20
|
-
const extractSafariExtensionDetails = /* @__PURE__ */ __name((methodName, url) => {
|
|
21
|
-
const isSafariExtension = methodName.includes("safari-extension");
|
|
22
|
-
const isSafariWebExtension = methodName.includes("safari-web-extension");
|
|
23
|
-
return isSafariExtension || isSafariWebExtension ? [
|
|
24
|
-
methodName.includes("@") ? methodName.split("@")[0] : UNKNOWN_FUNCTION,
|
|
25
|
-
isSafariExtension ? `safari-extension:${url}` : `safari-web-extension:${url}`
|
|
26
|
-
] : [methodName, url];
|
|
27
|
-
}, "extractSafariExtensionDetails");
|
|
28
|
-
const parseMapped = /* @__PURE__ */ __name((trace, maybeMapped) => {
|
|
29
|
-
const match = CHROMIUM_MAPPED.exec(maybeMapped);
|
|
30
|
-
if (match) {
|
|
31
|
-
trace.file = match[1];
|
|
32
|
-
trace.line = +match[2];
|
|
33
|
-
trace.column = +match[3];
|
|
34
|
-
}
|
|
35
|
-
}, "parseMapped");
|
|
36
|
-
const parseNode = /* @__PURE__ */ __name((line) => {
|
|
37
|
-
const nestedNode = NODE_NESTED_REGEX.exec(line);
|
|
38
|
-
if (nestedNode) {
|
|
39
|
-
debugLog(`parse nested node error stack line: "${line}"`, `found: ${JSON.stringify(nestedNode)}`);
|
|
40
|
-
const split = nestedNode[2].split(":");
|
|
41
|
-
return {
|
|
42
|
-
column: split[2] ? +split[2] : void 0,
|
|
43
|
-
file: split[0],
|
|
44
|
-
line: split[1] ? +split[1] : void 0,
|
|
45
|
-
methodName: nestedNode[1] || UNKNOWN_FUNCTION,
|
|
46
|
-
raw: line,
|
|
47
|
-
type: void 0
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
const node = NODE_REGEX.exec(line);
|
|
51
|
-
if (node) {
|
|
52
|
-
debugLog(`parse node error stack line: "${line}"`, `found: ${JSON.stringify(node)}`);
|
|
53
|
-
const trace = {
|
|
54
|
-
column: node[4] ? +node[4] : void 0,
|
|
55
|
-
file: node[2] ? node[2].replace(/at\s/, "") : void 0,
|
|
56
|
-
line: node[3] ? +node[3] : void 0,
|
|
57
|
-
methodName: node[1] || UNKNOWN_FUNCTION,
|
|
58
|
-
raw: line,
|
|
59
|
-
type: line.startsWith("internal") ? "internal" : void 0
|
|
60
|
-
};
|
|
61
|
-
parseMapped(trace, `${node[2]}:${node[3]}:${node[4]}`);
|
|
62
|
-
return trace;
|
|
63
|
-
}
|
|
64
|
-
return void 0;
|
|
65
|
-
}, "parseNode");
|
|
66
|
-
const parseChromium = /* @__PURE__ */ __name((line) => {
|
|
67
|
-
const parts = CHROMIUM_REGEX.exec(line);
|
|
68
|
-
if (parts) {
|
|
69
|
-
debugLog(`parse chrome error stack line: "${line}"`, `found: ${JSON.stringify(parts)}`);
|
|
70
|
-
const isNative = parts[2]?.startsWith("native");
|
|
71
|
-
const isEval = parts[2]?.startsWith("eval") || parts[1]?.startsWith("eval");
|
|
72
|
-
let evalOrigin;
|
|
73
|
-
let windowsParts;
|
|
74
|
-
if (isEval) {
|
|
75
|
-
const subMatch = CHROMIUM_EVAL_REGEX.exec(line);
|
|
76
|
-
if (subMatch) {
|
|
77
|
-
const split = /^(\S+):(\d+):(\d+)$|^(\S+):(\d+)$/.exec(subMatch[1]);
|
|
78
|
-
if (split) {
|
|
79
|
-
parts[2] = split[4] ?? split[1];
|
|
80
|
-
parts[3] = split[5] ?? split[2];
|
|
81
|
-
parts[4] = split[3];
|
|
82
|
-
} else if (subMatch[2]) {
|
|
83
|
-
parts[2] = subMatch[1];
|
|
84
|
-
}
|
|
85
|
-
if (subMatch[2]) {
|
|
86
|
-
evalOrigin = {
|
|
87
|
-
column: subMatch[4] ? +subMatch[4] : void 0,
|
|
88
|
-
file: subMatch[2],
|
|
89
|
-
line: subMatch[3] ? +subMatch[3] : void 0,
|
|
90
|
-
methodName: "eval",
|
|
91
|
-
raw: line,
|
|
92
|
-
type: "eval"
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
} else {
|
|
96
|
-
const windowsSubMatch = WINDOWS_EVAL_REGEX.exec(line);
|
|
97
|
-
if (windowsSubMatch) {
|
|
98
|
-
windowsParts = {
|
|
99
|
-
column: windowsSubMatch[5] ? +windowsSubMatch[5] : void 0,
|
|
100
|
-
file: windowsSubMatch[3],
|
|
101
|
-
line: windowsSubMatch[4] ? +windowsSubMatch[4] : void 0
|
|
102
|
-
};
|
|
103
|
-
evalOrigin = {
|
|
104
|
-
column: windowsSubMatch[8] ? +windowsSubMatch[8] : void 0,
|
|
105
|
-
file: windowsSubMatch[2],
|
|
106
|
-
line: windowsSubMatch[7] ? +windowsSubMatch[7] : void 0,
|
|
107
|
-
methodName: "eval",
|
|
108
|
-
raw: windowsSubMatch[0],
|
|
109
|
-
type: "eval"
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
const [methodName, file] = extractSafariExtensionDetails(
|
|
115
|
-
// Normalize IE's 'Anonymous function'
|
|
116
|
-
parts[1] ? parts[1].replace(/^Anonymous function$/, "<anonymous>") : UNKNOWN_FUNCTION,
|
|
117
|
-
parts[2]
|
|
118
|
-
);
|
|
119
|
-
const trace = {
|
|
120
|
-
column: parts[4] ? +parts[4] : void 0,
|
|
121
|
-
evalOrigin,
|
|
122
|
-
file,
|
|
123
|
-
line: parts[3] ? +parts[3] : void 0,
|
|
124
|
-
methodName,
|
|
125
|
-
raw: line,
|
|
126
|
-
// eslint-disable-next-line sonarjs/no-nested-conditional
|
|
127
|
-
type: isEval ? "eval" : isNative ? "native" : void 0
|
|
128
|
-
};
|
|
129
|
-
if (windowsParts) {
|
|
130
|
-
trace.column = windowsParts.column;
|
|
131
|
-
trace.file = windowsParts.file;
|
|
132
|
-
trace.line = windowsParts.line;
|
|
133
|
-
} else {
|
|
134
|
-
parseMapped(trace, `${file}:${parts[3]}:${parts[4]}`);
|
|
135
|
-
}
|
|
136
|
-
return trace;
|
|
137
|
-
}
|
|
138
|
-
return void 0;
|
|
139
|
-
}, "parseChromium");
|
|
140
|
-
const parseGecko = /* @__PURE__ */ __name((line, topFrameMeta) => {
|
|
141
|
-
const parts = GECKO_REGEX.exec(line);
|
|
142
|
-
if (parts) {
|
|
143
|
-
debugLog(`parse gecko error stack line: "${line}"`, `found: ${JSON.stringify(parts)}`);
|
|
144
|
-
const isEval = parts[3]?.includes(" > eval");
|
|
145
|
-
const subMatch = isEval && parts[3] && GECKO_EVAL_REGEX.exec(parts[3]);
|
|
146
|
-
let evalOrigin;
|
|
147
|
-
if (isEval && subMatch) {
|
|
148
|
-
parts[3] = subMatch[1];
|
|
149
|
-
evalOrigin = {
|
|
150
|
-
column: parts[5] ? +parts[5] : void 0,
|
|
151
|
-
file: parts[3],
|
|
152
|
-
line: parts[4] ? +parts[4] : void 0,
|
|
153
|
-
methodName: "eval",
|
|
154
|
-
raw: line,
|
|
155
|
-
type: "eval"
|
|
156
|
-
};
|
|
157
|
-
parts[4] = subMatch[2];
|
|
158
|
-
}
|
|
159
|
-
const [methodName, file] = extractSafariExtensionDetails(
|
|
160
|
-
// Normalize IE's 'Anonymous function'
|
|
161
|
-
parts[1] ? parts[1].replace(/^Anonymous function$/, "<anonymous>") : UNKNOWN_FUNCTION,
|
|
162
|
-
parts[3]
|
|
163
|
-
);
|
|
164
|
-
let column;
|
|
165
|
-
if ((topFrameMeta?.type === "safari" || !isEval && topFrameMeta?.type === "firefox") && topFrameMeta.column) {
|
|
166
|
-
column = topFrameMeta.column;
|
|
167
|
-
} else if (!isEval && parts[5]) {
|
|
168
|
-
column = +parts[5];
|
|
169
|
-
}
|
|
170
|
-
let lineNumber;
|
|
171
|
-
if ((topFrameMeta?.type === "safari" || !isEval && topFrameMeta?.type === "firefox") && topFrameMeta.line) {
|
|
172
|
-
lineNumber = topFrameMeta.line;
|
|
173
|
-
} else if (parts[4]) {
|
|
174
|
-
lineNumber = +parts[4];
|
|
175
|
-
}
|
|
176
|
-
return {
|
|
177
|
-
column,
|
|
178
|
-
evalOrigin,
|
|
179
|
-
file,
|
|
180
|
-
line: lineNumber,
|
|
181
|
-
methodName,
|
|
182
|
-
raw: line,
|
|
183
|
-
// eslint-disable-next-line sonarjs/no-nested-conditional
|
|
184
|
-
type: isEval ? "eval" : file.includes("[native code]") ? "native" : void 0
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
return void 0;
|
|
188
|
-
}, "parseGecko");
|
|
189
|
-
const parseFirefox = /* @__PURE__ */ __name((line, topFrameMeta) => {
|
|
190
|
-
const parts = FIREFOX_REGEX.exec(line);
|
|
191
|
-
const isEval = parts ? parts[2].includes(" > eval") : false;
|
|
192
|
-
if (!isEval && parts) {
|
|
193
|
-
debugLog(`parse firefox error stack line: "${line}"`, `found: ${JSON.stringify(parts)}`);
|
|
194
|
-
return {
|
|
195
|
-
column: parts[4] ? +parts[4] : topFrameMeta?.column ?? void 0,
|
|
196
|
-
file: parts[2],
|
|
197
|
-
line: parts[3] ? +parts[3] : topFrameMeta?.line ?? void 0,
|
|
198
|
-
methodName: parts[1] || UNKNOWN_FUNCTION,
|
|
199
|
-
raw: line,
|
|
200
|
-
type: void 0
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
return void 0;
|
|
204
|
-
}, "parseFirefox");
|
|
205
|
-
const parseReactAndroidNative = /* @__PURE__ */ __name((line) => {
|
|
206
|
-
const parts = REACT_ANDROID_NATIVE_REGEX.exec(line);
|
|
207
|
-
if (parts) {
|
|
208
|
-
debugLog(`parse react android native error stack line: "${line}"`, `found: ${JSON.stringify(parts)}`);
|
|
209
|
-
return {
|
|
210
|
-
column: parts[3] ? +parts[3] : void 0,
|
|
211
|
-
file: parts[1],
|
|
212
|
-
line: parts[2] ? +parts[2] : void 0,
|
|
213
|
-
methodName: UNKNOWN_FUNCTION,
|
|
214
|
-
raw: line,
|
|
215
|
-
type: void 0
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
return void 0;
|
|
219
|
-
}, "parseReactAndroidNative");
|
|
220
|
-
const parseStacktrace = /* @__PURE__ */ __name((error, { filter, frameLimit = 50 } = {}) => {
|
|
221
|
-
let lines = (error.stacktrace ?? error.stack ?? "").split("\n").map((line) => {
|
|
222
|
-
const cleanedLine = WEBPACK_ERROR_REGEXP.test(line) ? line.replace(WEBPACK_ERROR_REGEXP, "$1") : line;
|
|
223
|
-
return cleanedLine.replace(/^\s+|\s+$/g, "");
|
|
224
|
-
}).filter((line) => !/\S*(?:Error: |AggregateError:)/.test(line) && line !== "eval code");
|
|
225
|
-
if (filter) {
|
|
226
|
-
lines = lines.filter((element) => filter(element));
|
|
227
|
-
}
|
|
228
|
-
lines = lines.slice(0, frameLimit);
|
|
229
|
-
return lines.reduce((stack, line, currentIndex) => {
|
|
230
|
-
if (!line) {
|
|
231
|
-
return stack;
|
|
232
|
-
}
|
|
233
|
-
if (line.length > 1024) {
|
|
234
|
-
return stack;
|
|
235
|
-
}
|
|
236
|
-
let parseResult;
|
|
237
|
-
if (/^\s*in\s.*/.test(line)) {
|
|
238
|
-
parseResult = parseNode(line);
|
|
239
|
-
} else if (/^.*?\s*at\s.*/.test(line)) {
|
|
240
|
-
parseResult = parseChromium(line);
|
|
241
|
-
} else if (/^.*?\s*@.*|\[native code\]/.test(line)) {
|
|
242
|
-
let topFrameMeta;
|
|
243
|
-
if (currentIndex === 0) {
|
|
244
|
-
if (error.columnNumber || error.lineNumber) {
|
|
245
|
-
topFrameMeta = {
|
|
246
|
-
// @ts-expect-error columnNumber and columnNumber property only exists on Firefox
|
|
247
|
-
column: error.columnNumber,
|
|
248
|
-
// @ts-expect-error columnNumber and lineNumber property only exists on Firefox
|
|
249
|
-
line: error.lineNumber,
|
|
250
|
-
type: "firefox"
|
|
251
|
-
};
|
|
252
|
-
} else if (error.line || error.column) {
|
|
253
|
-
topFrameMeta = {
|
|
254
|
-
// @ts-expect-error column property only exists on safari
|
|
255
|
-
column: error.column,
|
|
256
|
-
// @ts-expect-error line property only exists on safari
|
|
257
|
-
line: error.line,
|
|
258
|
-
type: "safari"
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
parseResult = parseFirefox(line, topFrameMeta) || parseGecko(line, topFrameMeta);
|
|
263
|
-
} else {
|
|
264
|
-
parseResult = parseReactAndroidNative(line);
|
|
265
|
-
}
|
|
266
|
-
if (parseResult) {
|
|
267
|
-
stack.push(parseResult);
|
|
268
|
-
} else {
|
|
269
|
-
debugLog(`parse error stack line: "${line}"`, "not parser found");
|
|
270
|
-
}
|
|
271
|
-
return stack;
|
|
272
|
-
}, []);
|
|
273
|
-
}, "parseStacktrace");
|
|
274
|
-
|
|
275
|
-
export { parseStacktrace as default };
|
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
-
const debugLog = /* @__PURE__ */ __name((message, ...arguments_) => {
|
|
6
|
-
if (process.env.DEBUG && String(process.env.DEBUG) === "true") {
|
|
7
|
-
console.debug(`error:parse-stacktrace: ${message}`, ...arguments_);
|
|
8
|
-
}
|
|
9
|
-
}, "debugLog");
|
|
10
|
-
const UNKNOWN_FUNCTION = "<unknown>";
|
|
11
|
-
const CHROMIUM_REGEX = /^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
|
|
12
|
-
const CHROMIUM_EVAL_REGEX = /\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/;
|
|
13
|
-
const CHROMIUM_MAPPED = /(.*?):(\d+):(\d+)(\s<-\s(.+):(\d+):(\d+))?/;
|
|
14
|
-
const WINDOWS_EVAL_REGEX = /(eval)\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*(<anonymous>)?:(\d+)?:(\d+)/;
|
|
15
|
-
const NODE_REGEX = /^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/;
|
|
16
|
-
const NODE_NESTED_REGEX = /in\s(.*)\s\(at\s(.+)\)\sat/;
|
|
17
|
-
const REACT_ANDROID_NATIVE_REGEX = /^(?:.*@)?(.*):(\d+):(\d+)$/;
|
|
18
|
-
const GECKO_REGEX = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
|
|
19
|
-
const GECKO_EVAL_REGEX = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
|
|
20
|
-
const FIREFOX_REGEX = /(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/;
|
|
21
|
-
const WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
|
|
22
|
-
const extractSafariExtensionDetails = /* @__PURE__ */ __name((methodName, url) => {
|
|
23
|
-
const isSafariExtension = methodName.includes("safari-extension");
|
|
24
|
-
const isSafariWebExtension = methodName.includes("safari-web-extension");
|
|
25
|
-
return isSafariExtension || isSafariWebExtension ? [
|
|
26
|
-
methodName.includes("@") ? methodName.split("@")[0] : UNKNOWN_FUNCTION,
|
|
27
|
-
isSafariExtension ? `safari-extension:${url}` : `safari-web-extension:${url}`
|
|
28
|
-
] : [methodName, url];
|
|
29
|
-
}, "extractSafariExtensionDetails");
|
|
30
|
-
const parseMapped = /* @__PURE__ */ __name((trace, maybeMapped) => {
|
|
31
|
-
const match = CHROMIUM_MAPPED.exec(maybeMapped);
|
|
32
|
-
if (match) {
|
|
33
|
-
trace.file = match[1];
|
|
34
|
-
trace.line = +match[2];
|
|
35
|
-
trace.column = +match[3];
|
|
36
|
-
}
|
|
37
|
-
}, "parseMapped");
|
|
38
|
-
const parseNode = /* @__PURE__ */ __name((line) => {
|
|
39
|
-
const nestedNode = NODE_NESTED_REGEX.exec(line);
|
|
40
|
-
if (nestedNode) {
|
|
41
|
-
debugLog(`parse nested node error stack line: "${line}"`, `found: ${JSON.stringify(nestedNode)}`);
|
|
42
|
-
const split = nestedNode[2].split(":");
|
|
43
|
-
return {
|
|
44
|
-
column: split[2] ? +split[2] : void 0,
|
|
45
|
-
file: split[0],
|
|
46
|
-
line: split[1] ? +split[1] : void 0,
|
|
47
|
-
methodName: nestedNode[1] || UNKNOWN_FUNCTION,
|
|
48
|
-
raw: line,
|
|
49
|
-
type: void 0
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
const node = NODE_REGEX.exec(line);
|
|
53
|
-
if (node) {
|
|
54
|
-
debugLog(`parse node error stack line: "${line}"`, `found: ${JSON.stringify(node)}`);
|
|
55
|
-
const trace = {
|
|
56
|
-
column: node[4] ? +node[4] : void 0,
|
|
57
|
-
file: node[2] ? node[2].replace(/at\s/, "") : void 0,
|
|
58
|
-
line: node[3] ? +node[3] : void 0,
|
|
59
|
-
methodName: node[1] || UNKNOWN_FUNCTION,
|
|
60
|
-
raw: line,
|
|
61
|
-
type: line.startsWith("internal") ? "internal" : void 0
|
|
62
|
-
};
|
|
63
|
-
parseMapped(trace, `${node[2]}:${node[3]}:${node[4]}`);
|
|
64
|
-
return trace;
|
|
65
|
-
}
|
|
66
|
-
return void 0;
|
|
67
|
-
}, "parseNode");
|
|
68
|
-
const parseChromium = /* @__PURE__ */ __name((line) => {
|
|
69
|
-
const parts = CHROMIUM_REGEX.exec(line);
|
|
70
|
-
if (parts) {
|
|
71
|
-
debugLog(`parse chrome error stack line: "${line}"`, `found: ${JSON.stringify(parts)}`);
|
|
72
|
-
const isNative = parts[2]?.startsWith("native");
|
|
73
|
-
const isEval = parts[2]?.startsWith("eval") || parts[1]?.startsWith("eval");
|
|
74
|
-
let evalOrigin;
|
|
75
|
-
let windowsParts;
|
|
76
|
-
if (isEval) {
|
|
77
|
-
const subMatch = CHROMIUM_EVAL_REGEX.exec(line);
|
|
78
|
-
if (subMatch) {
|
|
79
|
-
const split = /^(\S+):(\d+):(\d+)$|^(\S+):(\d+)$/.exec(subMatch[1]);
|
|
80
|
-
if (split) {
|
|
81
|
-
parts[2] = split[4] ?? split[1];
|
|
82
|
-
parts[3] = split[5] ?? split[2];
|
|
83
|
-
parts[4] = split[3];
|
|
84
|
-
} else if (subMatch[2]) {
|
|
85
|
-
parts[2] = subMatch[1];
|
|
86
|
-
}
|
|
87
|
-
if (subMatch[2]) {
|
|
88
|
-
evalOrigin = {
|
|
89
|
-
column: subMatch[4] ? +subMatch[4] : void 0,
|
|
90
|
-
file: subMatch[2],
|
|
91
|
-
line: subMatch[3] ? +subMatch[3] : void 0,
|
|
92
|
-
methodName: "eval",
|
|
93
|
-
raw: line,
|
|
94
|
-
type: "eval"
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
} else {
|
|
98
|
-
const windowsSubMatch = WINDOWS_EVAL_REGEX.exec(line);
|
|
99
|
-
if (windowsSubMatch) {
|
|
100
|
-
windowsParts = {
|
|
101
|
-
column: windowsSubMatch[5] ? +windowsSubMatch[5] : void 0,
|
|
102
|
-
file: windowsSubMatch[3],
|
|
103
|
-
line: windowsSubMatch[4] ? +windowsSubMatch[4] : void 0
|
|
104
|
-
};
|
|
105
|
-
evalOrigin = {
|
|
106
|
-
column: windowsSubMatch[8] ? +windowsSubMatch[8] : void 0,
|
|
107
|
-
file: windowsSubMatch[2],
|
|
108
|
-
line: windowsSubMatch[7] ? +windowsSubMatch[7] : void 0,
|
|
109
|
-
methodName: "eval",
|
|
110
|
-
raw: windowsSubMatch[0],
|
|
111
|
-
type: "eval"
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
const [methodName, file] = extractSafariExtensionDetails(
|
|
117
|
-
// Normalize IE's 'Anonymous function'
|
|
118
|
-
parts[1] ? parts[1].replace(/^Anonymous function$/, "<anonymous>") : UNKNOWN_FUNCTION,
|
|
119
|
-
parts[2]
|
|
120
|
-
);
|
|
121
|
-
const trace = {
|
|
122
|
-
column: parts[4] ? +parts[4] : void 0,
|
|
123
|
-
evalOrigin,
|
|
124
|
-
file,
|
|
125
|
-
line: parts[3] ? +parts[3] : void 0,
|
|
126
|
-
methodName,
|
|
127
|
-
raw: line,
|
|
128
|
-
// eslint-disable-next-line sonarjs/no-nested-conditional
|
|
129
|
-
type: isEval ? "eval" : isNative ? "native" : void 0
|
|
130
|
-
};
|
|
131
|
-
if (windowsParts) {
|
|
132
|
-
trace.column = windowsParts.column;
|
|
133
|
-
trace.file = windowsParts.file;
|
|
134
|
-
trace.line = windowsParts.line;
|
|
135
|
-
} else {
|
|
136
|
-
parseMapped(trace, `${file}:${parts[3]}:${parts[4]}`);
|
|
137
|
-
}
|
|
138
|
-
return trace;
|
|
139
|
-
}
|
|
140
|
-
return void 0;
|
|
141
|
-
}, "parseChromium");
|
|
142
|
-
const parseGecko = /* @__PURE__ */ __name((line, topFrameMeta) => {
|
|
143
|
-
const parts = GECKO_REGEX.exec(line);
|
|
144
|
-
if (parts) {
|
|
145
|
-
debugLog(`parse gecko error stack line: "${line}"`, `found: ${JSON.stringify(parts)}`);
|
|
146
|
-
const isEval = parts[3]?.includes(" > eval");
|
|
147
|
-
const subMatch = isEval && parts[3] && GECKO_EVAL_REGEX.exec(parts[3]);
|
|
148
|
-
let evalOrigin;
|
|
149
|
-
if (isEval && subMatch) {
|
|
150
|
-
parts[3] = subMatch[1];
|
|
151
|
-
evalOrigin = {
|
|
152
|
-
column: parts[5] ? +parts[5] : void 0,
|
|
153
|
-
file: parts[3],
|
|
154
|
-
line: parts[4] ? +parts[4] : void 0,
|
|
155
|
-
methodName: "eval",
|
|
156
|
-
raw: line,
|
|
157
|
-
type: "eval"
|
|
158
|
-
};
|
|
159
|
-
parts[4] = subMatch[2];
|
|
160
|
-
}
|
|
161
|
-
const [methodName, file] = extractSafariExtensionDetails(
|
|
162
|
-
// Normalize IE's 'Anonymous function'
|
|
163
|
-
parts[1] ? parts[1].replace(/^Anonymous function$/, "<anonymous>") : UNKNOWN_FUNCTION,
|
|
164
|
-
parts[3]
|
|
165
|
-
);
|
|
166
|
-
let column;
|
|
167
|
-
if ((topFrameMeta?.type === "safari" || !isEval && topFrameMeta?.type === "firefox") && topFrameMeta.column) {
|
|
168
|
-
column = topFrameMeta.column;
|
|
169
|
-
} else if (!isEval && parts[5]) {
|
|
170
|
-
column = +parts[5];
|
|
171
|
-
}
|
|
172
|
-
let lineNumber;
|
|
173
|
-
if ((topFrameMeta?.type === "safari" || !isEval && topFrameMeta?.type === "firefox") && topFrameMeta.line) {
|
|
174
|
-
lineNumber = topFrameMeta.line;
|
|
175
|
-
} else if (parts[4]) {
|
|
176
|
-
lineNumber = +parts[4];
|
|
177
|
-
}
|
|
178
|
-
return {
|
|
179
|
-
column,
|
|
180
|
-
evalOrigin,
|
|
181
|
-
file,
|
|
182
|
-
line: lineNumber,
|
|
183
|
-
methodName,
|
|
184
|
-
raw: line,
|
|
185
|
-
// eslint-disable-next-line sonarjs/no-nested-conditional
|
|
186
|
-
type: isEval ? "eval" : file.includes("[native code]") ? "native" : void 0
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
return void 0;
|
|
190
|
-
}, "parseGecko");
|
|
191
|
-
const parseFirefox = /* @__PURE__ */ __name((line, topFrameMeta) => {
|
|
192
|
-
const parts = FIREFOX_REGEX.exec(line);
|
|
193
|
-
const isEval = parts ? parts[2].includes(" > eval") : false;
|
|
194
|
-
if (!isEval && parts) {
|
|
195
|
-
debugLog(`parse firefox error stack line: "${line}"`, `found: ${JSON.stringify(parts)}`);
|
|
196
|
-
return {
|
|
197
|
-
column: parts[4] ? +parts[4] : topFrameMeta?.column ?? void 0,
|
|
198
|
-
file: parts[2],
|
|
199
|
-
line: parts[3] ? +parts[3] : topFrameMeta?.line ?? void 0,
|
|
200
|
-
methodName: parts[1] || UNKNOWN_FUNCTION,
|
|
201
|
-
raw: line,
|
|
202
|
-
type: void 0
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
return void 0;
|
|
206
|
-
}, "parseFirefox");
|
|
207
|
-
const parseReactAndroidNative = /* @__PURE__ */ __name((line) => {
|
|
208
|
-
const parts = REACT_ANDROID_NATIVE_REGEX.exec(line);
|
|
209
|
-
if (parts) {
|
|
210
|
-
debugLog(`parse react android native error stack line: "${line}"`, `found: ${JSON.stringify(parts)}`);
|
|
211
|
-
return {
|
|
212
|
-
column: parts[3] ? +parts[3] : void 0,
|
|
213
|
-
file: parts[1],
|
|
214
|
-
line: parts[2] ? +parts[2] : void 0,
|
|
215
|
-
methodName: UNKNOWN_FUNCTION,
|
|
216
|
-
raw: line,
|
|
217
|
-
type: void 0
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
return void 0;
|
|
221
|
-
}, "parseReactAndroidNative");
|
|
222
|
-
const parseStacktrace = /* @__PURE__ */ __name((error, { filter, frameLimit = 50 } = {}) => {
|
|
223
|
-
let lines = (error.stacktrace ?? error.stack ?? "").split("\n").map((line) => {
|
|
224
|
-
const cleanedLine = WEBPACK_ERROR_REGEXP.test(line) ? line.replace(WEBPACK_ERROR_REGEXP, "$1") : line;
|
|
225
|
-
return cleanedLine.replace(/^\s+|\s+$/g, "");
|
|
226
|
-
}).filter((line) => !/\S*(?:Error: |AggregateError:)/.test(line) && line !== "eval code");
|
|
227
|
-
if (filter) {
|
|
228
|
-
lines = lines.filter((element) => filter(element));
|
|
229
|
-
}
|
|
230
|
-
lines = lines.slice(0, frameLimit);
|
|
231
|
-
return lines.reduce((stack, line, currentIndex) => {
|
|
232
|
-
if (!line) {
|
|
233
|
-
return stack;
|
|
234
|
-
}
|
|
235
|
-
if (line.length > 1024) {
|
|
236
|
-
return stack;
|
|
237
|
-
}
|
|
238
|
-
let parseResult;
|
|
239
|
-
if (/^\s*in\s.*/.test(line)) {
|
|
240
|
-
parseResult = parseNode(line);
|
|
241
|
-
} else if (/^.*?\s*at\s.*/.test(line)) {
|
|
242
|
-
parseResult = parseChromium(line);
|
|
243
|
-
} else if (/^.*?\s*@.*|\[native code\]/.test(line)) {
|
|
244
|
-
let topFrameMeta;
|
|
245
|
-
if (currentIndex === 0) {
|
|
246
|
-
if (error.columnNumber || error.lineNumber) {
|
|
247
|
-
topFrameMeta = {
|
|
248
|
-
// @ts-expect-error columnNumber and columnNumber property only exists on Firefox
|
|
249
|
-
column: error.columnNumber,
|
|
250
|
-
// @ts-expect-error columnNumber and lineNumber property only exists on Firefox
|
|
251
|
-
line: error.lineNumber,
|
|
252
|
-
type: "firefox"
|
|
253
|
-
};
|
|
254
|
-
} else if (error.line || error.column) {
|
|
255
|
-
topFrameMeta = {
|
|
256
|
-
// @ts-expect-error column property only exists on safari
|
|
257
|
-
column: error.column,
|
|
258
|
-
// @ts-expect-error line property only exists on safari
|
|
259
|
-
line: error.line,
|
|
260
|
-
type: "safari"
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
parseResult = parseFirefox(line, topFrameMeta) || parseGecko(line, topFrameMeta);
|
|
265
|
-
} else {
|
|
266
|
-
parseResult = parseReactAndroidNative(line);
|
|
267
|
-
}
|
|
268
|
-
if (parseResult) {
|
|
269
|
-
stack.push(parseResult);
|
|
270
|
-
} else {
|
|
271
|
-
debugLog(`parse error stack line: "${line}"`, "not parser found");
|
|
272
|
-
}
|
|
273
|
-
return stack;
|
|
274
|
-
}, []);
|
|
275
|
-
}, "parseStacktrace");
|
|
276
|
-
|
|
277
|
-
module.exports = parseStacktrace;
|