formacao
This commit is contained in:
+15
-5
@@ -233,8 +233,11 @@ const stackIgnorePatterns = [
|
||||
/node:\w+/,
|
||||
/__vitest_test__/,
|
||||
/__vitest_browser__/,
|
||||
"/@id/__x00__vitest/browser",
|
||||
/\/deps\/vitest_/
|
||||
];
|
||||
const NOW_LENGTH = Date.now().toString().length;
|
||||
const REGEXP_VITEST = new RegExp(`vitest=\\d{${NOW_LENGTH}}`);
|
||||
function extractLocation(urlLike) {
|
||||
// Fail-fast but return locations like "(native)"
|
||||
if (!urlLike.includes(":")) {
|
||||
@@ -259,6 +262,9 @@ function extractLocation(urlLike) {
|
||||
const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url);
|
||||
url = url.slice(isWindows ? 5 : 4);
|
||||
}
|
||||
if (url.includes("vitest=")) {
|
||||
url = url.replace(REGEXP_VITEST, "").replace(/[?&]$/, "");
|
||||
}
|
||||
return [
|
||||
url,
|
||||
parts[2] || undefined,
|
||||
@@ -352,7 +358,7 @@ function parseSingleV8Stack(raw) {
|
||||
// normalize Windows path (\ -> /)
|
||||
file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve(file);
|
||||
if (method) {
|
||||
method = method.replace(/__vite_ssr_import_\d+__\./g, "").replace(/(Object\.)?__vite_ssr_export_default__\s?/g, "");
|
||||
method = method.replace(/\(0\s?,\s?__vite_ssr_import_\d+__.(\w+)\)/g, "$1").replace(/__(vite_ssr_import|vi_import)_\d+__\./g, "").replace(/(Object\.)?__vite_ssr_export_default__\s?/g, "");
|
||||
}
|
||||
return {
|
||||
method,
|
||||
@@ -372,13 +378,17 @@ function createStackString(stacks) {
|
||||
}
|
||||
function parseStacktrace(stack, options = {}) {
|
||||
const { ignoreStackEntries = stackIgnorePatterns } = options;
|
||||
const stacks = !CHROME_IE_STACK_REGEXP.test(stack) ? parseFFOrSafariStackTrace(stack) : parseV8Stacktrace(stack);
|
||||
let stacks = !CHROME_IE_STACK_REGEXP.test(stack) ? parseFFOrSafariStackTrace(stack) : parseV8Stacktrace(stack);
|
||||
// remove vi.defineHelper's internal stacks
|
||||
const helperIndex = stacks.findLastIndex((s) => s.method.includes("__VITEST_HELPER__"));
|
||||
if (helperIndex >= 0) {
|
||||
stacks = stacks.slice(helperIndex + 1);
|
||||
}
|
||||
return stacks.map((stack) => {
|
||||
var _options$getSourceMap;
|
||||
if (options.getUrlId) {
|
||||
stack.file = options.getUrlId(stack.file);
|
||||
}
|
||||
const map = (_options$getSourceMap = options.getSourceMap) === null || _options$getSourceMap === void 0 ? void 0 : _options$getSourceMap.call(options, stack.file);
|
||||
const map = options.getSourceMap?.(stack.file);
|
||||
if (!map || typeof map !== "object" || !map.version) {
|
||||
return shouldFilter(ignoreStackEntries, stack.file) ? null : stack;
|
||||
}
|
||||
@@ -457,7 +467,7 @@ class DecodedMap {
|
||||
this._encoded = mappings || "";
|
||||
this._decodedMemo = memoizedState();
|
||||
this.url = from;
|
||||
this.resolvedSources = (sources || []).map((s) => resolve(s || "", from));
|
||||
this.resolvedSources = (sources || []).map((s) => resolve(from, "..", s || ""));
|
||||
}
|
||||
}
|
||||
function memoizedState() {
|
||||
|
||||
Reference in New Issue
Block a user