@visulima/cerebro 3.0.0-alpha.9 → 3.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 +591 -0
- package/LICENSE.md +1295 -3950
- package/README.md +182 -2
- package/dist/commands/completion-command.d.ts +6 -5
- package/dist/commands/completion-command.js +5 -203
- package/dist/commands/help-command.d.ts +10 -9
- package/dist/commands/help-command.js +1 -3
- package/dist/commands/readme-command.d.ts +6 -5
- package/dist/commands/readme-command.js +32 -330
- package/dist/commands/version-command.d.ts +4 -3
- package/dist/commands/version-command.js +1 -18
- package/dist/index.d.ts +516 -95
- package/dist/index.js +1 -7
- package/dist/logger/create-pail-logger.d.ts +770 -8
- package/dist/logger/create-pail-logger.js +1 -34
- package/dist/packem_chunks/has-new-version.js +1 -259
- package/dist/packem_shared/Cerebro-Czc4t-75.js +4 -0
- package/dist/packem_shared/VERBOSITY_DEBUG-XPultrIA.js +1 -0
- package/dist/packem_shared/VisulimaError-C90oeIMu.js +76 -0
- package/dist/packem_shared/VisulimaError-DTMgXonA-CzaryRgZ.js +1 -0
- package/dist/packem_shared/cerebro-error-BjBcYVRO.js +1 -0
- package/dist/packem_shared/command.d-DbhtfXF4.d.ts +639 -0
- package/dist/packem_shared/index-B7-8G-9s.js +29 -0
- package/dist/packem_shared/index.d-BL4NtVR3.d.ts +127 -0
- package/dist/packem_shared/lazyNamed-DMUm8mZe.js +1 -0
- package/dist/packem_shared/renderError-B3ePOoBG-BmZlyMcr.js +25 -0
- package/dist/packem_shared/runtime-process-Dmz0vCJy.js +1 -0
- package/dist/packem_shared/split-by-case-Dbpgd7rf.js +1 -0
- package/dist/plugins/error-handler-plugin.d.ts +21 -19
- package/dist/plugins/error-handler-plugin.js +1 -636
- package/dist/plugins/runtime-version-check-plugin.d.ts +22 -20
- package/dist/plugins/runtime-version-check-plugin.js +1 -77
- package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +28 -8
- package/dist/plugins/update-notifier/update-notifier-plugin.js +1 -517
- package/dist/util/general/compile-cache.d.ts +41 -0
- package/dist/util/general/compile-cache.js +1 -0
- package/dist/util/general/heap-tuning.d.ts +18 -0
- package/dist/util/general/heap-tuning.js +1 -0
- package/package.json +33 -28
- package/dist/cli.d.ts +0 -203
- package/dist/constants.d.ts +0 -29
- package/dist/default-env.d.ts +0 -7
- package/dist/default-options.d.ts +0 -3
- package/dist/empty-toolbox.d.ts +0 -15
- package/dist/errors/cerebro-error.d.ts +0 -10
- package/dist/errors/command-not-found-error.d.ts +0 -9
- package/dist/errors/command-validation-error.d.ts +0 -10
- package/dist/errors/completion-error.d.ts +0 -9
- package/dist/errors/conflicting-options-error.d.ts +0 -10
- package/dist/errors/plugin-error.d.ts +0 -9
- package/dist/errors/update-notifier-error.d.ts +0 -7
- package/dist/packem_shared/Cerebro-C2mnCyQf.js +0 -3313
- package/dist/packem_shared/VERBOSITY_QUIET-Dp46zlLW.js +0 -10
- package/dist/packem_shared/VisulimaError-DA7QsCxH.js +0 -34
- package/dist/packem_shared/cerebro-error-GmJ3jN7Q.js +0 -16
- package/dist/packem_shared/help-command-BY7rQUvM.js +0 -249
- package/dist/packem_shared/index-C2-8b3A4.js +0 -259
- package/dist/packem_shared/runtime-process-B6ZplyWn.js +0 -187
- package/dist/plugin-manager.d.ts +0 -53
- package/dist/plugins/update-notifier/cache.d.ts +0 -11
- package/dist/plugins/update-notifier/get-distribution-version.d.ts +0 -2
- package/dist/plugins/update-notifier/has-new-version.d.ts +0 -14
- package/dist/types/cli.d.ts +0 -102
- package/dist/types/command-line-usage.d.ts +0 -37
- package/dist/types/command.d.ts +0 -136
- package/dist/types/option-types.d.ts +0 -83
- package/dist/types/options.d.ts +0 -4
- package/dist/types/plugin.d.ts +0 -53
- package/dist/types/toolbox.d.ts +0 -96
- package/dist/util/arg-processing/get-boolean-values.d.ts +0 -7
- package/dist/util/arg-processing/get-parameter-option.d.ts +0 -7
- package/dist/util/arg-processing/map-option-type-label.d.ts +0 -3
- package/dist/util/arg-processing/option-is-boolean.d.ts +0 -9
- package/dist/util/arg-processing/remove-boolean-values.d.ts +0 -9
- package/dist/util/command-line-commands.d.ts +0 -10
- package/dist/util/command-line-usage/get-terminal-width.d.ts +0 -7
- package/dist/util/command-line-usage/index.d.ts +0 -3
- package/dist/util/command-line-usage/section/base-section.d.ts +0 -8
- package/dist/util/command-line-usage/section/content-section.d.ts +0 -65
- package/dist/util/command-line-usage/section/option-list-section.d.ts +0 -44
- package/dist/util/command-processing/command-processor.d.ts +0 -37
- package/dist/util/command-processing/command-validation.d.ts +0 -17
- package/dist/util/command-processing/nested-command-parser.d.ts +0 -25
- package/dist/util/command-processing/option-processor.d.ts +0 -44
- package/dist/util/data-processing/list-missing-arguments.d.ts +0 -15
- package/dist/util/data-processing/merge-arguments.d.ts +0 -7
- package/dist/util/general/find-alternatives.d.ts +0 -8
- package/dist/util/general/hide-bin.d.ts +0 -2
- package/dist/util/general/parse-raw-command.d.ts +0 -7
- package/dist/util/general/register-exception-handler.d.ts +0 -9
- package/dist/util/general/runtime-process.d.ts +0 -65
- package/dist/util/general/semver-gt.d.ts +0 -2
- package/dist/util/general/validate-input.d.ts +0 -24
- package/dist/util/process-env-variables.d.ts +0 -9
- package/dist/util/security.d.ts +0 -58
- package/dist/util/text-processing/template-format.d.ts +0 -5
|
@@ -1,636 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
-
|
|
5
|
-
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
-
|
|
7
|
-
const __cjs_getBuiltinModule = (module) => {
|
|
8
|
-
// Check if we're in Node.js and version supports getBuiltinModule
|
|
9
|
-
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
10
|
-
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
11
|
-
// Node.js 20.16.0+ and 22.3.0+
|
|
12
|
-
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
13
|
-
return __cjs_getProcess.getBuiltinModule(module);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
// Fallback to createRequire
|
|
17
|
-
return __cjs_require(module);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
import { e as exitProcess } from '../packem_shared/runtime-process-B6ZplyWn.js';
|
|
21
|
-
const {
|
|
22
|
-
createRequire
|
|
23
|
-
} = __cjs_getBuiltinModule("node:module");
|
|
24
|
-
|
|
25
|
-
const normalizeLF = (code) => code.replaceAll(/\r\n|\r(?!\n)|\n/gu, "\n");
|
|
26
|
-
const _process = globalThis.process || /* @__PURE__ */ Object.create(null);
|
|
27
|
-
const processShims = {
|
|
28
|
-
versions: {}
|
|
29
|
-
};
|
|
30
|
-
const process$1 = /* @__PURE__ */ new Proxy(_process, {
|
|
31
|
-
get(target, property) {
|
|
32
|
-
if (property in target) {
|
|
33
|
-
return target[property];
|
|
34
|
-
}
|
|
35
|
-
if (property in processShims) {
|
|
36
|
-
return processShims[property];
|
|
37
|
-
}
|
|
38
|
-
return void 0;
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
const getMarkerLines = (loc, source, linesAbove, linesBelow) => {
|
|
42
|
-
const startLoc = {
|
|
43
|
-
column: 0,
|
|
44
|
-
// @ts-expect-error Can be overwritten
|
|
45
|
-
line: -1,
|
|
46
|
-
...loc.start
|
|
47
|
-
};
|
|
48
|
-
const endLoc = {
|
|
49
|
-
...startLoc,
|
|
50
|
-
...loc.end
|
|
51
|
-
};
|
|
52
|
-
const startLine = startLoc.line;
|
|
53
|
-
const startColumn = startLoc.column;
|
|
54
|
-
const endLine = endLoc.line;
|
|
55
|
-
const endColumn = endLoc.column;
|
|
56
|
-
let start = Math.max(startLine - (linesAbove + 1), 0);
|
|
57
|
-
let end = Math.min(source.length, endLine + linesBelow);
|
|
58
|
-
if (startLine === -1) {
|
|
59
|
-
start = 0;
|
|
60
|
-
}
|
|
61
|
-
if (endLine === -1) {
|
|
62
|
-
end = source.length;
|
|
63
|
-
}
|
|
64
|
-
const lineDiff = endLine - startLine;
|
|
65
|
-
const markerLines = {};
|
|
66
|
-
if (lineDiff) {
|
|
67
|
-
for (let index = 0; index <= lineDiff; index++) {
|
|
68
|
-
const lineNumber = index + startLine;
|
|
69
|
-
if (!startColumn) {
|
|
70
|
-
markerLines[lineNumber] = true;
|
|
71
|
-
} else if (index === 0) {
|
|
72
|
-
const sourceLength = source[lineNumber - 1]?.length;
|
|
73
|
-
markerLines[lineNumber] = [startColumn, (sourceLength ?? 0) - startColumn + 1];
|
|
74
|
-
} else if (index === lineDiff) {
|
|
75
|
-
markerLines[lineNumber] = [0, endColumn];
|
|
76
|
-
} else {
|
|
77
|
-
const sourceLength = source[lineNumber - index]?.length;
|
|
78
|
-
markerLines[lineNumber] = [0, sourceLength];
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
} else if (startColumn === endColumn) {
|
|
82
|
-
markerLines[startLine] = startColumn ? [startColumn, 0] : true;
|
|
83
|
-
} else {
|
|
84
|
-
markerLines[startLine] = [startColumn, (endColumn ?? 0) - (startColumn ?? 0)];
|
|
85
|
-
}
|
|
86
|
-
return { end, markerLines, start };
|
|
87
|
-
};
|
|
88
|
-
const CODE_FRAME_POINTER = process$1.platform === "win32" && !process$1.env?.WT_SESSION ? ">" : "❯";
|
|
89
|
-
const codeFrame = (source, loc, options) => {
|
|
90
|
-
const config = {
|
|
91
|
-
// grab 2 lines before, and 3 lines after focused line
|
|
92
|
-
linesAbove: 2,
|
|
93
|
-
linesBelow: 3,
|
|
94
|
-
prefix: "",
|
|
95
|
-
showGutter: true,
|
|
96
|
-
tabWidth: 4,
|
|
97
|
-
...options,
|
|
98
|
-
color: {
|
|
99
|
-
gutter: (value) => value,
|
|
100
|
-
marker: (value) => value,
|
|
101
|
-
message: (value) => value,
|
|
102
|
-
...options?.color
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
const hasColumns = loc.start && typeof loc.start.column === "number";
|
|
106
|
-
let lines = normalizeLF(source).split("\n");
|
|
107
|
-
if (typeof config?.tabWidth === "number") {
|
|
108
|
-
lines = lines.map((ln) => ln.replaceAll(" ", " ".repeat(config.tabWidth)));
|
|
109
|
-
}
|
|
110
|
-
const { end, markerLines, start } = getMarkerLines(loc, lines, config.linesAbove, config.linesBelow);
|
|
111
|
-
const numberMaxWidth = String(end).length;
|
|
112
|
-
const { gutter: colorizeGutter, marker: colorizeMarker, message: colorizeMessage } = config.color;
|
|
113
|
-
let frame = lines.slice(start, end).map((line, index) => {
|
|
114
|
-
const number = start + 1 + index;
|
|
115
|
-
const hasMarker = markerLines[number];
|
|
116
|
-
const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
|
|
117
|
-
const lastMarkerLine = !markerLines[number + 1];
|
|
118
|
-
const gutter = ` ${paddedNumber}${config.showGutter ? " |" : ""}`;
|
|
119
|
-
if (hasMarker) {
|
|
120
|
-
let markerLine = "";
|
|
121
|
-
if (Array.isArray(hasMarker)) {
|
|
122
|
-
const markerSpacing = line.replaceAll(/[^\t]/g, " ").slice(0, Math.max(hasMarker[0] - 1, 0));
|
|
123
|
-
const numberOfMarkers = hasMarker[1] || 1;
|
|
124
|
-
markerLine = [
|
|
125
|
-
"\n ",
|
|
126
|
-
config.prefix + colorizeGutter(gutter.replaceAll(/\d/g, " ")),
|
|
127
|
-
" ",
|
|
128
|
-
markerSpacing,
|
|
129
|
-
colorizeMarker("^").repeat(numberOfMarkers)
|
|
130
|
-
].join("");
|
|
131
|
-
if (lastMarkerLine && config.message) {
|
|
132
|
-
markerLine += ` ${colorizeMessage(config.message)}`;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return [config.prefix + colorizeMarker(CODE_FRAME_POINTER), colorizeGutter(gutter), line.length > 0 ? ` ${line}` : "", markerLine].join("");
|
|
136
|
-
}
|
|
137
|
-
return `${config.prefix} ${colorizeGutter(gutter)}${line.length > 0 ? ` ${line}` : ""}`;
|
|
138
|
-
}).join("\n");
|
|
139
|
-
if (config.message && !hasColumns) {
|
|
140
|
-
frame = `${config.prefix + " ".repeat(numberMaxWidth + 1) + config.message}
|
|
141
|
-
${frame}`;
|
|
142
|
-
}
|
|
143
|
-
return frame;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
const debugLog = (message, ...arguments_) => {
|
|
147
|
-
if (process.env.DEBUG && String(process.env.DEBUG) === "true") {
|
|
148
|
-
console.debug(`error:parse-stacktrace: ${message}`, ...arguments_);
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
const UNKNOWN_FUNCTION = "<unknown>";
|
|
152
|
-
const CHROMIUM_REGEX = /^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
|
|
153
|
-
const CHROMIUM_EVAL_REGEX = /\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/;
|
|
154
|
-
const CHROMIUM_MAPPED = /(.*?):(\d+):(\d+)(\s<-\s(.+):(\d+):(\d+))?/;
|
|
155
|
-
const WINDOWS_EVAL_REGEX = /(eval)\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*(<anonymous>)?:(\d+)?:(\d+)/;
|
|
156
|
-
const NODE_REGEX = /^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/;
|
|
157
|
-
const NODE_NESTED_REGEX = /in\s(.*)\s\(at\s(.+)\)\sat/;
|
|
158
|
-
const REACT_ANDROID_NATIVE_REGEX = /^(?:.*@)?(.*):(\d+):(\d+)$/;
|
|
159
|
-
const GECKO_REGEX = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
|
|
160
|
-
const GECKO_EVAL_REGEX = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
|
|
161
|
-
const FIREFOX_REGEX = /(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/;
|
|
162
|
-
const WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
|
|
163
|
-
const extractSafariExtensionDetails = (methodName, url) => {
|
|
164
|
-
const isSafariExtension = methodName.includes("safari-extension");
|
|
165
|
-
const isSafariWebExtension = methodName.includes("safari-web-extension");
|
|
166
|
-
return isSafariExtension || isSafariWebExtension ? [
|
|
167
|
-
methodName.includes("@") ? methodName.split("@")[0] : UNKNOWN_FUNCTION,
|
|
168
|
-
isSafariExtension ? `safari-extension:${url}` : `safari-web-extension:${url}`
|
|
169
|
-
] : [methodName, url];
|
|
170
|
-
};
|
|
171
|
-
const parseMapped = (trace, maybeMapped) => {
|
|
172
|
-
const match = CHROMIUM_MAPPED.exec(maybeMapped);
|
|
173
|
-
if (match) {
|
|
174
|
-
trace.file = match[1];
|
|
175
|
-
trace.line = +match[2];
|
|
176
|
-
trace.column = +match[3];
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
const parseNode = (line) => {
|
|
180
|
-
const nestedNode = NODE_NESTED_REGEX.exec(line);
|
|
181
|
-
if (nestedNode) {
|
|
182
|
-
debugLog(`parse nested node error stack line: "${line}"`, `found: ${JSON.stringify(nestedNode)}`);
|
|
183
|
-
const split = nestedNode[2].split(":");
|
|
184
|
-
return {
|
|
185
|
-
column: split[2] ? +split[2] : void 0,
|
|
186
|
-
file: split[0],
|
|
187
|
-
line: split[1] ? +split[1] : void 0,
|
|
188
|
-
methodName: nestedNode[1] || UNKNOWN_FUNCTION,
|
|
189
|
-
raw: line,
|
|
190
|
-
type: void 0
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
const node = NODE_REGEX.exec(line);
|
|
194
|
-
if (node) {
|
|
195
|
-
debugLog(`parse node error stack line: "${line}"`, `found: ${JSON.stringify(node)}`);
|
|
196
|
-
const trace = {
|
|
197
|
-
column: node[4] ? +node[4] : void 0,
|
|
198
|
-
file: node[2] ? node[2].replace(/at\s/, "") : void 0,
|
|
199
|
-
line: node[3] ? +node[3] : void 0,
|
|
200
|
-
methodName: node[1] || UNKNOWN_FUNCTION,
|
|
201
|
-
raw: line,
|
|
202
|
-
type: line.startsWith("internal") ? "internal" : void 0
|
|
203
|
-
};
|
|
204
|
-
parseMapped(trace, `${node[2]}:${node[3]}:${node[4]}`);
|
|
205
|
-
return trace;
|
|
206
|
-
}
|
|
207
|
-
return void 0;
|
|
208
|
-
};
|
|
209
|
-
const parseChromium = (line) => {
|
|
210
|
-
const parts = CHROMIUM_REGEX.exec(line);
|
|
211
|
-
if (parts) {
|
|
212
|
-
debugLog(`parse chrome error stack line: "${line}"`, `found: ${JSON.stringify(parts)}`);
|
|
213
|
-
const isNative = parts[2]?.startsWith("native");
|
|
214
|
-
const isEval = parts[2]?.startsWith("eval") || parts[1]?.startsWith("eval");
|
|
215
|
-
let evalOrigin;
|
|
216
|
-
let windowsParts;
|
|
217
|
-
if (isEval) {
|
|
218
|
-
const subMatch = CHROMIUM_EVAL_REGEX.exec(line);
|
|
219
|
-
if (subMatch) {
|
|
220
|
-
const split = /^(\S+):(\d+):(\d+)$|^(\S+):(\d+)$/.exec(subMatch[1]);
|
|
221
|
-
if (split) {
|
|
222
|
-
parts[2] = split[4] ?? split[1];
|
|
223
|
-
parts[3] = split[5] ?? split[2];
|
|
224
|
-
parts[4] = split[3];
|
|
225
|
-
} else if (subMatch[2]) {
|
|
226
|
-
parts[2] = subMatch[1];
|
|
227
|
-
}
|
|
228
|
-
if (subMatch[2]) {
|
|
229
|
-
evalOrigin = {
|
|
230
|
-
column: subMatch[4] ? +subMatch[4] : void 0,
|
|
231
|
-
file: subMatch[2],
|
|
232
|
-
line: subMatch[3] ? +subMatch[3] : void 0,
|
|
233
|
-
methodName: "eval",
|
|
234
|
-
raw: line,
|
|
235
|
-
type: "eval"
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
} else {
|
|
239
|
-
const windowsSubMatch = WINDOWS_EVAL_REGEX.exec(line);
|
|
240
|
-
if (windowsSubMatch) {
|
|
241
|
-
windowsParts = {
|
|
242
|
-
column: windowsSubMatch[5] ? +windowsSubMatch[5] : void 0,
|
|
243
|
-
file: windowsSubMatch[3],
|
|
244
|
-
line: windowsSubMatch[4] ? +windowsSubMatch[4] : void 0
|
|
245
|
-
};
|
|
246
|
-
evalOrigin = {
|
|
247
|
-
column: windowsSubMatch[8] ? +windowsSubMatch[8] : void 0,
|
|
248
|
-
file: windowsSubMatch[2],
|
|
249
|
-
line: windowsSubMatch[7] ? +windowsSubMatch[7] : void 0,
|
|
250
|
-
methodName: "eval",
|
|
251
|
-
raw: windowsSubMatch[0],
|
|
252
|
-
type: "eval"
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
const [methodName, file] = extractSafariExtensionDetails(
|
|
258
|
-
// Normalize IE's 'Anonymous function'
|
|
259
|
-
parts[1] ? parts[1].replace(/^Anonymous function$/, "<anonymous>") : UNKNOWN_FUNCTION,
|
|
260
|
-
parts[2]
|
|
261
|
-
);
|
|
262
|
-
const trace = {
|
|
263
|
-
column: parts[4] ? +parts[4] : void 0,
|
|
264
|
-
evalOrigin,
|
|
265
|
-
file,
|
|
266
|
-
line: parts[3] ? +parts[3] : void 0,
|
|
267
|
-
methodName,
|
|
268
|
-
raw: line,
|
|
269
|
-
// eslint-disable-next-line sonarjs/no-nested-conditional
|
|
270
|
-
type: isEval ? "eval" : isNative ? "native" : void 0
|
|
271
|
-
};
|
|
272
|
-
if (windowsParts) {
|
|
273
|
-
trace.column = windowsParts.column;
|
|
274
|
-
trace.file = windowsParts.file;
|
|
275
|
-
trace.line = windowsParts.line;
|
|
276
|
-
} else {
|
|
277
|
-
parseMapped(trace, `${file}:${parts[3]}:${parts[4]}`);
|
|
278
|
-
}
|
|
279
|
-
return trace;
|
|
280
|
-
}
|
|
281
|
-
return void 0;
|
|
282
|
-
};
|
|
283
|
-
const parseGecko = (line, topFrameMeta) => {
|
|
284
|
-
const parts = GECKO_REGEX.exec(line);
|
|
285
|
-
if (parts) {
|
|
286
|
-
debugLog(`parse gecko error stack line: "${line}"`, `found: ${JSON.stringify(parts)}`);
|
|
287
|
-
const isEval = parts[3]?.includes(" > eval");
|
|
288
|
-
const subMatch = isEval && parts[3] && GECKO_EVAL_REGEX.exec(parts[3]);
|
|
289
|
-
let evalOrigin;
|
|
290
|
-
if (isEval && subMatch) {
|
|
291
|
-
parts[3] = subMatch[1];
|
|
292
|
-
evalOrigin = {
|
|
293
|
-
column: parts[5] ? +parts[5] : void 0,
|
|
294
|
-
file: parts[3],
|
|
295
|
-
line: parts[4] ? +parts[4] : void 0,
|
|
296
|
-
methodName: "eval",
|
|
297
|
-
raw: line,
|
|
298
|
-
type: "eval"
|
|
299
|
-
};
|
|
300
|
-
parts[4] = subMatch[2];
|
|
301
|
-
}
|
|
302
|
-
const [methodName, file] = extractSafariExtensionDetails(
|
|
303
|
-
// Normalize IE's 'Anonymous function'
|
|
304
|
-
parts[1] ? parts[1].replace(/^Anonymous function$/, "<anonymous>") : UNKNOWN_FUNCTION,
|
|
305
|
-
parts[3]
|
|
306
|
-
);
|
|
307
|
-
let column;
|
|
308
|
-
if ((topFrameMeta?.type === "safari" || !isEval && topFrameMeta?.type === "firefox") && topFrameMeta.column) {
|
|
309
|
-
column = topFrameMeta.column;
|
|
310
|
-
} else if (!isEval && parts[5]) {
|
|
311
|
-
column = +parts[5];
|
|
312
|
-
}
|
|
313
|
-
let lineNumber;
|
|
314
|
-
if ((topFrameMeta?.type === "safari" || !isEval && topFrameMeta?.type === "firefox") && topFrameMeta.line) {
|
|
315
|
-
lineNumber = topFrameMeta.line;
|
|
316
|
-
} else if (parts[4]) {
|
|
317
|
-
lineNumber = +parts[4];
|
|
318
|
-
}
|
|
319
|
-
return {
|
|
320
|
-
column,
|
|
321
|
-
evalOrigin,
|
|
322
|
-
file,
|
|
323
|
-
line: lineNumber,
|
|
324
|
-
methodName,
|
|
325
|
-
raw: line,
|
|
326
|
-
// eslint-disable-next-line sonarjs/no-nested-conditional
|
|
327
|
-
type: isEval ? "eval" : file.includes("[native code]") ? "native" : void 0
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
return void 0;
|
|
331
|
-
};
|
|
332
|
-
const parseFirefox = (line, topFrameMeta) => {
|
|
333
|
-
const parts = FIREFOX_REGEX.exec(line);
|
|
334
|
-
const isEval = parts ? parts[2].includes(" > eval") : false;
|
|
335
|
-
if (!isEval && parts) {
|
|
336
|
-
debugLog(`parse firefox error stack line: "${line}"`, `found: ${JSON.stringify(parts)}`);
|
|
337
|
-
return {
|
|
338
|
-
column: parts[4] ? +parts[4] : topFrameMeta?.column ?? void 0,
|
|
339
|
-
file: parts[2],
|
|
340
|
-
line: parts[3] ? +parts[3] : topFrameMeta?.line ?? void 0,
|
|
341
|
-
methodName: parts[1] || UNKNOWN_FUNCTION,
|
|
342
|
-
raw: line,
|
|
343
|
-
type: void 0
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
return void 0;
|
|
347
|
-
};
|
|
348
|
-
const parseReactAndroidNative = (line) => {
|
|
349
|
-
const parts = REACT_ANDROID_NATIVE_REGEX.exec(line);
|
|
350
|
-
if (parts) {
|
|
351
|
-
debugLog(`parse react android native error stack line: "${line}"`, `found: ${JSON.stringify(parts)}`);
|
|
352
|
-
return {
|
|
353
|
-
column: parts[3] ? +parts[3] : void 0,
|
|
354
|
-
file: parts[1],
|
|
355
|
-
line: parts[2] ? +parts[2] : void 0,
|
|
356
|
-
methodName: UNKNOWN_FUNCTION,
|
|
357
|
-
raw: line,
|
|
358
|
-
type: void 0
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
return void 0;
|
|
362
|
-
};
|
|
363
|
-
const parseStacktrace = (error, { filter, frameLimit = 50 } = {}) => {
|
|
364
|
-
let lines = (error.stacktrace ?? error.stack ?? "").split("\n").map((line) => {
|
|
365
|
-
const cleanedLine = WEBPACK_ERROR_REGEXP.test(line) ? line.replace(WEBPACK_ERROR_REGEXP, "$1") : line;
|
|
366
|
-
return cleanedLine.replace(/^\s+|\s+$/g, "");
|
|
367
|
-
}).filter((line) => !/\S*(?:Error: |AggregateError:)/.test(line) && line !== "eval code");
|
|
368
|
-
if (filter) {
|
|
369
|
-
lines = lines.filter((element) => filter(element));
|
|
370
|
-
}
|
|
371
|
-
lines = lines.slice(0, frameLimit);
|
|
372
|
-
return lines.reduce((stack, line, currentIndex) => {
|
|
373
|
-
if (!line) {
|
|
374
|
-
return stack;
|
|
375
|
-
}
|
|
376
|
-
if (line.length > 1024) {
|
|
377
|
-
return stack;
|
|
378
|
-
}
|
|
379
|
-
let parseResult;
|
|
380
|
-
if (/^\s*in\s.*/.test(line)) {
|
|
381
|
-
parseResult = parseNode(line);
|
|
382
|
-
} else if (/^.*?\s*at\s.*/.test(line)) {
|
|
383
|
-
parseResult = parseChromium(line);
|
|
384
|
-
} else if (/^.*?\s*@.*|\[native code\]/.test(line)) {
|
|
385
|
-
let topFrameMeta;
|
|
386
|
-
if (currentIndex === 0) {
|
|
387
|
-
if (error.columnNumber || error.lineNumber) {
|
|
388
|
-
topFrameMeta = {
|
|
389
|
-
// @ts-expect-error columnNumber and columnNumber property only exists on Firefox
|
|
390
|
-
column: error.columnNumber,
|
|
391
|
-
// @ts-expect-error columnNumber and lineNumber property only exists on Firefox
|
|
392
|
-
line: error.lineNumber,
|
|
393
|
-
type: "firefox"
|
|
394
|
-
};
|
|
395
|
-
} else if (error.line || error.column) {
|
|
396
|
-
topFrameMeta = {
|
|
397
|
-
// @ts-expect-error column property only exists on safari
|
|
398
|
-
column: error.column,
|
|
399
|
-
// @ts-expect-error line property only exists on safari
|
|
400
|
-
line: error.line,
|
|
401
|
-
type: "safari"
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
parseResult = parseFirefox(line, topFrameMeta) || parseGecko(line, topFrameMeta);
|
|
406
|
-
} else {
|
|
407
|
-
parseResult = parseReactAndroidNative(line);
|
|
408
|
-
}
|
|
409
|
-
if (parseResult) {
|
|
410
|
-
stack.push(parseResult);
|
|
411
|
-
} else {
|
|
412
|
-
debugLog(`parse error stack line: "${line}"`, "not parser found");
|
|
413
|
-
}
|
|
414
|
-
return stack;
|
|
415
|
-
}, []);
|
|
416
|
-
};
|
|
417
|
-
|
|
418
|
-
const {
|
|
419
|
-
existsSync,
|
|
420
|
-
readFileSync
|
|
421
|
-
} = __cjs_getBuiltinModule("node:fs");
|
|
422
|
-
const {
|
|
423
|
-
relative
|
|
424
|
-
} = __cjs_getBuiltinModule("node:path");
|
|
425
|
-
const {
|
|
426
|
-
cwd
|
|
427
|
-
} = __cjs_getProcess;
|
|
428
|
-
const {
|
|
429
|
-
fileURLToPath
|
|
430
|
-
} = __cjs_getBuiltinModule("node:url");
|
|
431
|
-
const getPrefix = (prefix, indentation, deep) => {
|
|
432
|
-
if (deep === 0) {
|
|
433
|
-
return prefix.toString();
|
|
434
|
-
}
|
|
435
|
-
if (indentation === " ") {
|
|
436
|
-
return prefix + " ".repeat(deep);
|
|
437
|
-
}
|
|
438
|
-
return prefix + " ".repeat(indentation * deep);
|
|
439
|
-
};
|
|
440
|
-
const getRelativePath = (filePath, cwdPath) => {
|
|
441
|
-
const path = filePath.replace("async file:", "file:");
|
|
442
|
-
return relative(cwdPath, path.startsWith("file:") ? fileURLToPath(path) : path);
|
|
443
|
-
};
|
|
444
|
-
const getTitleText = (error, hideErrorTitle, color) => {
|
|
445
|
-
if (hideErrorTitle) {
|
|
446
|
-
return color.title(error.message);
|
|
447
|
-
}
|
|
448
|
-
const messagePart = error.message ? `: ${error.message}` : "";
|
|
449
|
-
return color.title(error.name + messagePart);
|
|
450
|
-
};
|
|
451
|
-
const getMessage = (error, { color, hideErrorTitle, indentation, prefix }, deep) => `${getPrefix(prefix, indentation, deep)}${getTitleText(error, hideErrorTitle, color)}
|
|
452
|
-
`;
|
|
453
|
-
const getHint = (error, { color, indentation, prefix }, deep) => {
|
|
454
|
-
if (error.hint === void 0) {
|
|
455
|
-
return void 0;
|
|
456
|
-
}
|
|
457
|
-
const spaces = getPrefix(prefix, indentation, deep);
|
|
458
|
-
let message = "";
|
|
459
|
-
if (Array.isArray(error.hint)) {
|
|
460
|
-
for (const line of error.hint) {
|
|
461
|
-
message += `${(spaces + line).toString()}
|
|
462
|
-
`;
|
|
463
|
-
}
|
|
464
|
-
} else {
|
|
465
|
-
message += spaces + error.hint;
|
|
466
|
-
}
|
|
467
|
-
return color.hint(message);
|
|
468
|
-
};
|
|
469
|
-
const getMainFrame = (trace, { color, cwd: cwdPath, displayShortPath, indentation, prefix }, deep = 0) => {
|
|
470
|
-
const filePath = displayShortPath ? getRelativePath(trace.file, cwdPath) : trace.file;
|
|
471
|
-
const { fileLine, method } = color;
|
|
472
|
-
return `${getPrefix(prefix, indentation, deep)}at ${trace.methodName ? `${method(trace.methodName)} ` : ""}${fileLine(filePath)}:${fileLine(
|
|
473
|
-
trace.line?.toString() ?? ""
|
|
474
|
-
)}`.toString();
|
|
475
|
-
};
|
|
476
|
-
const getCode = (trace, { color, indentation, linesAbove, linesBelow, prefix, showGutter, showLineNumbers, tabWidth }, deep) => {
|
|
477
|
-
if (trace.file === void 0) {
|
|
478
|
-
return void 0;
|
|
479
|
-
}
|
|
480
|
-
const filePath = trace.file.replace("file://", "");
|
|
481
|
-
if (!existsSync(filePath)) {
|
|
482
|
-
return void 0;
|
|
483
|
-
}
|
|
484
|
-
const fileContent = readFileSync(filePath, "utf8");
|
|
485
|
-
return codeFrame(
|
|
486
|
-
fileContent,
|
|
487
|
-
{
|
|
488
|
-
start: { column: trace.column, line: trace.line }
|
|
489
|
-
},
|
|
490
|
-
{ color, linesAbove, linesBelow, prefix: getPrefix(prefix, indentation, deep), showGutter, showLineNumbers, tabWidth }
|
|
491
|
-
);
|
|
492
|
-
};
|
|
493
|
-
const getErrors = (error, options, deep) => {
|
|
494
|
-
if (error.errors.length === 0) {
|
|
495
|
-
return void 0;
|
|
496
|
-
}
|
|
497
|
-
let message = `${getPrefix(options.prefix, options.indentation, deep)}Errors:
|
|
498
|
-
|
|
499
|
-
`;
|
|
500
|
-
let first = true;
|
|
501
|
-
for (const error_ of error.errors) {
|
|
502
|
-
if (first) {
|
|
503
|
-
first = false;
|
|
504
|
-
} else {
|
|
505
|
-
message += "\n\n";
|
|
506
|
-
}
|
|
507
|
-
message += internalRenderError(error_, { ...options, framesMaxLimit: 1, hideErrorCodeView: options.hideErrorErrorsCodeView }, deep + 1);
|
|
508
|
-
}
|
|
509
|
-
return `
|
|
510
|
-
${message}`;
|
|
511
|
-
};
|
|
512
|
-
const getCause = (error, options, deep) => {
|
|
513
|
-
let message = `${getPrefix(options.prefix, options.indentation, deep)}Caused by:
|
|
514
|
-
|
|
515
|
-
`;
|
|
516
|
-
const cause = error.cause;
|
|
517
|
-
message += getMessage(cause, options, deep);
|
|
518
|
-
const stacktrace = parseStacktrace(cause);
|
|
519
|
-
const mainFrame = stacktrace.shift();
|
|
520
|
-
const hint = getHint(cause, options, deep);
|
|
521
|
-
if (hint) {
|
|
522
|
-
message += `${hint}
|
|
523
|
-
`;
|
|
524
|
-
}
|
|
525
|
-
if (mainFrame) {
|
|
526
|
-
message += getMainFrame(mainFrame, options, deep);
|
|
527
|
-
if (!options.hideErrorCauseCodeView) {
|
|
528
|
-
const code = getCode(mainFrame, options, deep);
|
|
529
|
-
if (code !== void 0) {
|
|
530
|
-
message += `
|
|
531
|
-
${code}`;
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
if (cause.cause) {
|
|
536
|
-
message += `
|
|
537
|
-
${getCause(cause, options, deep + 1)}`;
|
|
538
|
-
} else if (cause instanceof AggregateError) {
|
|
539
|
-
const errors = getErrors(cause, options, deep);
|
|
540
|
-
if (errors !== void 0) {
|
|
541
|
-
message += `
|
|
542
|
-
${errors}`;
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
return `
|
|
546
|
-
${message}`;
|
|
547
|
-
};
|
|
548
|
-
const getStacktrace = (stack, options) => (stack.length > 0 ? "\n" : "") + stack.map((frame) => getMainFrame(frame, options)).join("\n");
|
|
549
|
-
const internalRenderError = (error, options, deep) => {
|
|
550
|
-
const config = {
|
|
551
|
-
cwd: cwd(),
|
|
552
|
-
displayShortPath: false,
|
|
553
|
-
filterStacktrace: void 0,
|
|
554
|
-
framesMaxLimit: Number.POSITIVE_INFINITY,
|
|
555
|
-
hideErrorCauseCodeView: false,
|
|
556
|
-
hideErrorCodeView: false,
|
|
557
|
-
hideErrorErrorsCodeView: false,
|
|
558
|
-
hideErrorTitle: false,
|
|
559
|
-
hideMessage: false,
|
|
560
|
-
indentation: 4,
|
|
561
|
-
linesAbove: 2,
|
|
562
|
-
linesBelow: 3,
|
|
563
|
-
prefix: "",
|
|
564
|
-
showGutter: true,
|
|
565
|
-
showLineNumbers: true,
|
|
566
|
-
tabWidth: 4,
|
|
567
|
-
...options,
|
|
568
|
-
color: {
|
|
569
|
-
fileLine: (value) => value,
|
|
570
|
-
gutter: (value) => value,
|
|
571
|
-
hint: (value) => value,
|
|
572
|
-
marker: (value) => value,
|
|
573
|
-
message: (value) => value,
|
|
574
|
-
method: (value) => value,
|
|
575
|
-
title: (value) => value,
|
|
576
|
-
...options.color
|
|
577
|
-
}
|
|
578
|
-
};
|
|
579
|
-
const stack = parseStacktrace(error, {
|
|
580
|
-
filter: options.filterStacktrace,
|
|
581
|
-
frameLimit: config.framesMaxLimit
|
|
582
|
-
});
|
|
583
|
-
const mainFrame = stack.shift();
|
|
584
|
-
return [
|
|
585
|
-
options.hideMessage ? void 0 : getMessage(error, config, deep),
|
|
586
|
-
getHint(error, config, deep),
|
|
587
|
-
mainFrame ? getMainFrame(mainFrame, config, deep) : void 0,
|
|
588
|
-
mainFrame && !config.hideErrorCodeView ? getCode(mainFrame, config, deep) : void 0,
|
|
589
|
-
error instanceof AggregateError ? getErrors(error, config, deep) : void 0,
|
|
590
|
-
error.cause === void 0 ? void 0 : getCause(error, config, deep),
|
|
591
|
-
stack.length > 0 ? getStacktrace(stack, config) : void 0
|
|
592
|
-
].filter(Boolean).join("\n").replaceAll("\\", "/");
|
|
593
|
-
};
|
|
594
|
-
const renderError = (error, options = {}) => {
|
|
595
|
-
if (options.framesMaxLimit !== void 0 && options.framesMaxLimit <= 0) {
|
|
596
|
-
throw new RangeError("The 'framesMaxLimit' option must be a positive number");
|
|
597
|
-
}
|
|
598
|
-
return internalRenderError(error, options, 0);
|
|
599
|
-
};
|
|
600
|
-
|
|
601
|
-
const errorHandlerPlugin = (options = {}) => {
|
|
602
|
-
const handleError = async (error, toolbox) => {
|
|
603
|
-
const { logger, runtime } = toolbox;
|
|
604
|
-
const { detailed = false, exitOnError = true, formatter, logErrors = true, renderOptions = {} } = options;
|
|
605
|
-
if (logErrors) {
|
|
606
|
-
if (formatter) {
|
|
607
|
-
logger.error(formatter(error));
|
|
608
|
-
} else if (detailed) {
|
|
609
|
-
const cwd = runtime.getCwd();
|
|
610
|
-
const renderedError = renderError(error, {
|
|
611
|
-
cwd,
|
|
612
|
-
hideErrorCodeView: false,
|
|
613
|
-
hideErrorTitle: false,
|
|
614
|
-
hideMessage: false,
|
|
615
|
-
linesAbove: 2,
|
|
616
|
-
linesBelow: 3,
|
|
617
|
-
...renderOptions
|
|
618
|
-
});
|
|
619
|
-
logger.error(renderedError);
|
|
620
|
-
} else {
|
|
621
|
-
logger.error(error);
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
if (exitOnError) {
|
|
625
|
-
exitProcess(1);
|
|
626
|
-
}
|
|
627
|
-
};
|
|
628
|
-
return {
|
|
629
|
-
description: "Enhanced error handling and reporting with beautiful code frames",
|
|
630
|
-
name: "error-handler",
|
|
631
|
-
onError: handleError,
|
|
632
|
-
version: "1.0.0"
|
|
633
|
-
};
|
|
634
|
-
};
|
|
635
|
-
|
|
636
|
-
export { errorHandlerPlugin };
|
|
1
|
+
import{U as g}from"../packem_shared/renderError-B3ePOoBG-BmZlyMcr.js";import{e as m}from"../packem_shared/runtime-process-Dmz0vCJy.js";const E=(i={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:(e,n)=>{const{logger:r,runtime:s}=n,{detailed:t=!1,exitOnError:l=!0,formatter:o,logErrors:a=!0,renderOptions:d={}}=i;if(a)if(o)r.error(o(e));else if(t){const f=s.getCwd(),c=g(e,{cwd:f,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...d});r.error(c)}else r.error(e);l&&m(1)},version:"1.0.0"});export{E as errorHandlerPlugin};
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { P as Plugin } from "../packem_shared/command.d-DbhtfXF4.js";
|
|
2
|
+
import '@visulima/tabular';
|
|
3
|
+
type RuntimeType = "bun" | "deno" | "node";
|
|
4
|
+
type RuntimeVersionRequirement = {
|
|
5
|
+
/** Minimum version required */
|
|
6
|
+
minVersion: number;
|
|
6
7
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
type RuntimeVersionCheckOptions = {
|
|
9
|
+
/** Runtime version requirements for specific runtimes */
|
|
10
|
+
runtimes?: {
|
|
11
|
+
/** Minimum Bun version requirement */
|
|
12
|
+
bun?: RuntimeVersionRequirement;
|
|
13
|
+
/** Minimum Deno version requirement */
|
|
14
|
+
deno?: RuntimeVersionRequirement;
|
|
15
|
+
/** Minimum Node.js version requirement */
|
|
16
|
+
node?: RuntimeVersionRequirement;
|
|
17
|
+
};
|
|
17
18
|
};
|
|
18
19
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
* Create a runtime version check plugin that supports Node.js, Bun, and Deno.
|
|
21
|
+
* @param options Configuration for runtime version requirements
|
|
22
|
+
* @returns Plugin instance that validates runtime version on initialization
|
|
23
|
+
*/
|
|
24
|
+
declare const runtimeVersionCheckPlugin: (options?: RuntimeVersionCheckOptions) => Plugin;
|
|
25
|
+
export { RuntimeType, RuntimeVersionCheckOptions, RuntimeVersionRequirement, runtimeVersionCheckPlugin };
|