vitest 0.24.5 → 0.25.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/LICENSE.md +286 -57
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +18 -11
- package/dist/{chunk-api-setup.629f8133.js → chunk-api-setup.f40616e2.js} +38 -19
- package/dist/{chunk-env-node.700b7e95.js → chunk-env-node.67948209.js} +8 -11
- package/dist/{chunk-install-pkg.22707ee4.js → chunk-install-pkg.579a5a27.js} +3 -4
- package/dist/{chunk-integrations-coverage.cca09977.js → chunk-integrations-coverage.befed097.js} +57 -1
- package/dist/chunk-integrations-globals.796fe181.js +25 -0
- package/dist/{chunk-node-git.82174cfe.js → chunk-node-git.5a1b1656.js} +5 -6
- package/dist/{chunk-runtime-chain.37ec5d73.js → chunk-runtime-chain.e387e274.js} +36 -25
- package/dist/{chunk-runtime-error.17751c39.js → chunk-runtime-error.6287172c.js} +9 -2
- package/dist/{chunk-runtime-mocker.41b92ec9.js → chunk-runtime-mocker.503a4f67.js} +4 -4
- package/dist/{chunk-runtime-rpc.b418c0ab.js → chunk-runtime-rpc.1e7530d3.js} +2 -2
- package/dist/chunk-runtime-setup.5c4e0f49.js +1363 -0
- package/dist/{chunk-runtime-hooks.d748b085.js → chunk-runtime-test-state.4ed42543.js} +119 -6
- package/dist/{chunk-mock-date.030959d3.js → chunk-typecheck-constants.4891f22f.js} +23 -4
- package/dist/{chunk-utils-env.b1281522.js → chunk-utils-env.03f840f2.js} +2 -0
- package/dist/chunk-utils-source-map.c6dfbbc1.js +90 -0
- package/dist/{chunk-utils-timers.8fca243e.js → chunk-utils-timers.06f993db.js} +86 -79
- package/dist/{chunk-vite-node-client.3868b3ba.js → chunk-vite-node-client.b2ab6dcf.js} +25 -5
- package/dist/{chunk-vite-node-externalize.d9033432.js → chunk-vite-node-externalize.477f36a4.js} +821 -92
- package/dist/chunk-vite-node-utils.8f0b4a12.js +1400 -0
- package/dist/cli-wrapper.js +5 -6
- package/dist/cli.js +27 -13
- package/dist/config.cjs +6 -1
- package/dist/config.d.ts +6 -1
- package/dist/config.js +6 -1
- package/dist/entry.js +15 -13
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/index-2f5b6168.d.ts +256 -0
- package/dist/index.d.ts +13 -4
- package/dist/index.js +13 -7
- package/dist/loader.js +4 -3
- package/dist/node.d.ts +2 -2
- package/dist/node.js +18 -11
- package/dist/suite.js +6 -6
- package/dist/{global-58e8e951.d.ts → types-f302dae9.d.ts} +210 -19
- package/dist/{vendor-index.cc8d244b.js → vendor-index.737c3cff.js} +1 -2
- package/dist/{vendor-index.12d51d29.js → vendor-index.e1d4cf84.js} +279 -7
- package/dist/worker.js +9 -8
- package/globals.d.ts +2 -0
- package/package.json +13 -9
- package/dist/chunk-integrations-globals.32ef80c3.js +0 -25
- package/dist/chunk-runtime-setup.ab6b6274.js +0 -676
- package/dist/chunk-utils-source-map.663e2952.js +0 -3429
- package/dist/chunk-vite-node-utils.2144000e.js +0 -6946
- package/dist/index-220c1d70.d.ts +0 -117
- package/dist/vendor-index.1a291e86.js +0 -275
|
@@ -1,17 +1,37 @@
|
|
|
1
|
-
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, b as bench, c as createExpect, e as globalExpect } from './chunk-runtime-chain.
|
|
2
|
-
import { g as getWorkerState, R as RealDate, r as resetDate, m as mockDate, a as resetModules } from './chunk-
|
|
3
|
-
import { p as parseStacktrace } from './chunk-utils-source-map.
|
|
1
|
+
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, b as bench, c as createExpect, e as globalExpect } from './chunk-runtime-chain.e387e274.js';
|
|
2
|
+
import { g as getWorkerState, R as RealDate, r as resetDate, m as mockDate, a as resetModules } from './chunk-typecheck-constants.4891f22f.js';
|
|
3
|
+
import { p as parseStacktrace } from './chunk-utils-source-map.c6dfbbc1.js';
|
|
4
4
|
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
|
|
5
5
|
import util from 'util';
|
|
6
6
|
import { spyOn, fn, isMockFunction, spies } from './spy.js';
|
|
7
|
-
import { s as safeSetTimeout } from './chunk-utils-timers.
|
|
7
|
+
import { s as safeSetTimeout } from './chunk-utils-timers.06f993db.js';
|
|
8
8
|
import * as chai from 'chai';
|
|
9
9
|
import { assert, should } from 'chai';
|
|
10
10
|
|
|
11
|
+
let _test;
|
|
12
|
+
function setCurrentTest(test) {
|
|
13
|
+
_test = test;
|
|
14
|
+
}
|
|
15
|
+
function getCurrentTest() {
|
|
16
|
+
return _test;
|
|
17
|
+
}
|
|
18
|
+
|
|
11
19
|
const beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
|
|
12
20
|
const afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
|
|
13
21
|
const beforeEach = (fn, timeout) => getCurrentSuite().on("beforeEach", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
|
|
14
22
|
const afterEach = (fn, timeout) => getCurrentSuite().on("afterEach", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
|
|
23
|
+
const onTestFailed = createTestHook("onTestFailed", (test, handler) => {
|
|
24
|
+
test.onFailed || (test.onFailed = []);
|
|
25
|
+
test.onFailed.push(handler);
|
|
26
|
+
});
|
|
27
|
+
function createTestHook(name, handler) {
|
|
28
|
+
return (fn) => {
|
|
29
|
+
const current = getCurrentTest();
|
|
30
|
+
if (!current)
|
|
31
|
+
throw new Error(`Hook ${name}() can only be called inside a test`);
|
|
32
|
+
handler(current, fn);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
15
35
|
|
|
16
36
|
function withCallback(fn) {
|
|
17
37
|
return new Promise(
|
|
@@ -2663,6 +2683,7 @@ class VitestUtils {
|
|
|
2663
2683
|
constructor() {
|
|
2664
2684
|
this.spyOn = spyOn;
|
|
2665
2685
|
this.fn = fn;
|
|
2686
|
+
this._config = null;
|
|
2666
2687
|
this._mocker = typeof __vitest_mocker__ !== "undefined" ? __vitest_mocker__ : null;
|
|
2667
2688
|
this._mockedDate = null;
|
|
2668
2689
|
if (!this._mocker) {
|
|
@@ -2793,6 +2814,18 @@ class VitestUtils {
|
|
|
2793
2814
|
await Promise.allSettled(promises);
|
|
2794
2815
|
await new Promise((resolve) => safeSetTimeout(resolve, 1)).then(() => Promise.resolve());
|
|
2795
2816
|
}
|
|
2817
|
+
setConfig(config) {
|
|
2818
|
+
const state = getWorkerState();
|
|
2819
|
+
if (!this._config)
|
|
2820
|
+
this._config = { ...state.config };
|
|
2821
|
+
Object.assign(state.config, config);
|
|
2822
|
+
}
|
|
2823
|
+
resetConfig() {
|
|
2824
|
+
if (this._config) {
|
|
2825
|
+
const state = getWorkerState();
|
|
2826
|
+
state.config = { ...this._config };
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2796
2829
|
}
|
|
2797
2830
|
const vitest = new VitestUtils();
|
|
2798
2831
|
const vi = vitest;
|
|
@@ -2804,6 +2837,83 @@ function isWatchMode() {
|
|
|
2804
2837
|
return getRunningMode() === "watch";
|
|
2805
2838
|
}
|
|
2806
2839
|
|
|
2840
|
+
var dist = {};
|
|
2841
|
+
|
|
2842
|
+
(function (exports) {
|
|
2843
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2844
|
+
exports.expectTypeOf = void 0;
|
|
2845
|
+
const fn = () => true;
|
|
2846
|
+
/**
|
|
2847
|
+
* Similar to Jest's `expect`, but with type-awareness.
|
|
2848
|
+
* Gives you access to a number of type-matchers that let you make assertions about the
|
|
2849
|
+
* form of a reference or generic type parameter.
|
|
2850
|
+
*
|
|
2851
|
+
* @example
|
|
2852
|
+
* import {foo, bar} from '../foo'
|
|
2853
|
+
* import {expectTypeOf} from 'expect-type'
|
|
2854
|
+
*
|
|
2855
|
+
* test('foo types', () => {
|
|
2856
|
+
* // make sure `foo` has type {a: number}
|
|
2857
|
+
* expectTypeOf(foo).toMatchTypeOf({a: 1})
|
|
2858
|
+
* expectTypeOf(foo).toHaveProperty('a').toBeNumber()
|
|
2859
|
+
*
|
|
2860
|
+
* // make sure `bar` is a function taking a string:
|
|
2861
|
+
* expectTypeOf(bar).parameter(0).toBeString()
|
|
2862
|
+
* expectTypeOf(bar).returns.not.toBeAny()
|
|
2863
|
+
* })
|
|
2864
|
+
*
|
|
2865
|
+
* @description
|
|
2866
|
+
* See the [full docs](https://npmjs.com/package/expect-type#documentation) for lots more examples.
|
|
2867
|
+
*/
|
|
2868
|
+
const expectTypeOf = (_actual) => {
|
|
2869
|
+
const nonFunctionProperties = [
|
|
2870
|
+
'parameters',
|
|
2871
|
+
'returns',
|
|
2872
|
+
'resolves',
|
|
2873
|
+
'not',
|
|
2874
|
+
'items',
|
|
2875
|
+
'constructorParameters',
|
|
2876
|
+
'instance',
|
|
2877
|
+
'guards',
|
|
2878
|
+
'asserts',
|
|
2879
|
+
];
|
|
2880
|
+
const obj = {
|
|
2881
|
+
/* eslint-disable mmkal/@typescript-eslint/no-unsafe-assignment */
|
|
2882
|
+
toBeAny: fn,
|
|
2883
|
+
toBeUnknown: fn,
|
|
2884
|
+
toBeNever: fn,
|
|
2885
|
+
toBeFunction: fn,
|
|
2886
|
+
toBeObject: fn,
|
|
2887
|
+
toBeArray: fn,
|
|
2888
|
+
toBeString: fn,
|
|
2889
|
+
toBeNumber: fn,
|
|
2890
|
+
toBeBoolean: fn,
|
|
2891
|
+
toBeVoid: fn,
|
|
2892
|
+
toBeSymbol: fn,
|
|
2893
|
+
toBeNull: fn,
|
|
2894
|
+
toBeUndefined: fn,
|
|
2895
|
+
toBeNullable: fn,
|
|
2896
|
+
toMatchTypeOf: fn,
|
|
2897
|
+
toEqualTypeOf: fn,
|
|
2898
|
+
toBeCallableWith: fn,
|
|
2899
|
+
toBeConstructibleWith: fn,
|
|
2900
|
+
/* eslint-enable mmkal/@typescript-eslint/no-unsafe-assignment */
|
|
2901
|
+
extract: exports.expectTypeOf,
|
|
2902
|
+
exclude: exports.expectTypeOf,
|
|
2903
|
+
toHaveProperty: exports.expectTypeOf,
|
|
2904
|
+
parameter: exports.expectTypeOf,
|
|
2905
|
+
};
|
|
2906
|
+
const getterProperties = nonFunctionProperties;
|
|
2907
|
+
getterProperties.forEach((prop) => Object.defineProperty(obj, prop, { get: () => (0, exports.expectTypeOf)({}) }));
|
|
2908
|
+
return obj;
|
|
2909
|
+
};
|
|
2910
|
+
exports.expectTypeOf = expectTypeOf;
|
|
2911
|
+
} (dist));
|
|
2912
|
+
|
|
2913
|
+
const noop = () => {
|
|
2914
|
+
};
|
|
2915
|
+
const assertType = noop;
|
|
2916
|
+
|
|
2807
2917
|
var index = /*#__PURE__*/Object.freeze({
|
|
2808
2918
|
__proto__: null,
|
|
2809
2919
|
suite: suite,
|
|
@@ -2817,6 +2927,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
2817
2927
|
afterAll: afterAll,
|
|
2818
2928
|
beforeEach: beforeEach,
|
|
2819
2929
|
afterEach: afterEach,
|
|
2930
|
+
onTestFailed: onTestFailed,
|
|
2820
2931
|
withCallback: withCallback,
|
|
2821
2932
|
assert: assert,
|
|
2822
2933
|
should: should,
|
|
@@ -2826,7 +2937,9 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
2826
2937
|
vitest: vitest,
|
|
2827
2938
|
vi: vi,
|
|
2828
2939
|
getRunningMode: getRunningMode,
|
|
2829
|
-
isWatchMode: isWatchMode
|
|
2940
|
+
isWatchMode: isWatchMode,
|
|
2941
|
+
expectTypeOf: dist.expectTypeOf,
|
|
2942
|
+
assertType: assertType
|
|
2830
2943
|
});
|
|
2831
2944
|
|
|
2832
|
-
export { afterAll as a, beforeAll as b, beforeEach as c, afterEach as d,
|
|
2945
|
+
export { afterAll as a, beforeAll as b, beforeEach as c, afterEach as d, dist as e, assertType as f, runOnce as g, isFirstRun as h, index as i, vitest as j, getRunningMode as k, isWatchMode as l, onTestFailed as o, resetRunOnceCounter as r, setCurrentTest as s, vi as v, withCallback as w };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { relative } from 'path';
|
|
2
|
-
import { i as isNode, a as isBrowser, r as relative$1, p as picocolors, E as EXIT_CODE_RESTART } from './chunk-utils-env.
|
|
2
|
+
import { i as isNode, a as isBrowser, r as relative$1, p as picocolors, E as EXIT_CODE_RESTART } from './chunk-utils-env.03f840f2.js';
|
|
3
3
|
import { isPackageExists } from 'local-pkg';
|
|
4
4
|
|
|
5
|
+
const TYPECHECK_SUITE = Symbol("vitest:typecheck-suite");
|
|
6
|
+
|
|
5
7
|
const RealDate = Date;
|
|
6
8
|
let now = null;
|
|
7
9
|
class MockDate extends RealDate {
|
|
@@ -179,11 +181,21 @@ function shuffle(array, seed = RealDate.now()) {
|
|
|
179
181
|
}
|
|
180
182
|
|
|
181
183
|
function isAtomTest(s) {
|
|
182
|
-
return s.type === "test" || s.type === "benchmark";
|
|
184
|
+
return s.type === "test" || s.type === "benchmark" || s.type === "typecheck";
|
|
183
185
|
}
|
|
184
186
|
function getTests(suite) {
|
|
185
187
|
return toArray(suite).flatMap((s) => isAtomTest(s) ? [s] : s.tasks.flatMap((c) => isAtomTest(c) ? [c] : getTests(c)));
|
|
186
188
|
}
|
|
189
|
+
function isTypecheckTest(suite) {
|
|
190
|
+
return TYPECHECK_SUITE in suite;
|
|
191
|
+
}
|
|
192
|
+
function getTypecheckTests(suite) {
|
|
193
|
+
return toArray(suite).flatMap((s) => {
|
|
194
|
+
if (s.type !== "suite")
|
|
195
|
+
return [];
|
|
196
|
+
return TYPECHECK_SUITE in s ? [s, ...getTypecheckTests(s.tasks)] : getTypecheckTests(s.tasks);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
187
199
|
function getSuites(suite) {
|
|
188
200
|
return toArray(suite).flatMap((s) => s.type === "suite" ? [s, ...getSuites(s.tasks)] : []);
|
|
189
201
|
}
|
|
@@ -254,6 +266,13 @@ function resetModules(modules, resetMocks = false) {
|
|
|
254
266
|
function getFullName(task) {
|
|
255
267
|
return getNames(task).join(picocolors.exports.dim(" > "));
|
|
256
268
|
}
|
|
269
|
+
function removeUndefinedValues(obj) {
|
|
270
|
+
for (const key in Object.keys(obj)) {
|
|
271
|
+
if (obj[key] === void 0)
|
|
272
|
+
delete obj[key];
|
|
273
|
+
}
|
|
274
|
+
return obj;
|
|
275
|
+
}
|
|
257
276
|
async function ensurePackageInstalled(dependency, root) {
|
|
258
277
|
if (isPackageExists(dependency, { paths: [root] }))
|
|
259
278
|
return true;
|
|
@@ -270,7 +289,7 @@ async function ensurePackageInstalled(dependency, root) {
|
|
|
270
289
|
message: picocolors.exports.reset(`Do you want to install ${picocolors.exports.green(dependency)}?`)
|
|
271
290
|
});
|
|
272
291
|
if (install) {
|
|
273
|
-
await (await import('./chunk-install-pkg.
|
|
292
|
+
await (await import('./chunk-install-pkg.579a5a27.js')).installPackage(dependency, { dev: true });
|
|
274
293
|
process.stderr.write(picocolors.exports.yellow(`
|
|
275
294
|
Package ${dependency} installed, re-run the command to start.
|
|
276
295
|
`));
|
|
@@ -326,4 +345,4 @@ function createDefer() {
|
|
|
326
345
|
return p;
|
|
327
346
|
}
|
|
328
347
|
|
|
329
|
-
export { AggregateErrorPonyfill as A,
|
|
348
|
+
export { AggregateErrorPonyfill as A, getTypecheckTests as B, getSuites as C, isTypecheckTest as D, deepMerge as E, removeUndefinedValues as F, stdout as G, mergeSlashes as H, getAllMockableProperties as I, RealDate as R, TYPECHECK_SUITE as T, resetModules as a, getCallLastIndex as b, getNames as c, assertTypes as d, getFullName as e, isRunningInTest as f, getWorkerState as g, isRunningInBenchmark as h, isObject as i, notNullish as j, relativePath as k, shuffle as l, mockDate as m, noop as n, hasTests as o, partitionSuiteChildren as p, hasFailed as q, resetDate as r, slash as s, toArray as t, createDefer as u, deepClone as v, getType as w, ensurePackageInstalled as x, getTests as y, hasFailedSnapshot as z };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { s as slash, j as notNullish } from './chunk-typecheck-constants.4891f22f.js';
|
|
2
|
+
|
|
3
|
+
const lineSplitRE = /\r?\n/;
|
|
4
|
+
const stackIgnorePatterns = [
|
|
5
|
+
"node:internal",
|
|
6
|
+
"/vitest/dist/",
|
|
7
|
+
"/vitest/src/",
|
|
8
|
+
"/node_modules/chai/",
|
|
9
|
+
"/node_modules/tinypool/",
|
|
10
|
+
"/node_modules/tinyspy/"
|
|
11
|
+
];
|
|
12
|
+
function extractLocation(urlLike) {
|
|
13
|
+
if (!urlLike.includes(":"))
|
|
14
|
+
return [urlLike];
|
|
15
|
+
const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
|
|
16
|
+
const parts = regExp.exec(urlLike.replace(/[()]/g, ""));
|
|
17
|
+
if (!parts)
|
|
18
|
+
return [urlLike];
|
|
19
|
+
return [parts[1], parts[2] || void 0, parts[3] || void 0];
|
|
20
|
+
}
|
|
21
|
+
function parseStacktrace(e, full = false) {
|
|
22
|
+
if (!e)
|
|
23
|
+
return [];
|
|
24
|
+
if (e.stacks)
|
|
25
|
+
return e.stacks;
|
|
26
|
+
const stackStr = e.stack || e.stackStr || "";
|
|
27
|
+
const stackFrames = stackStr.split("\n").map((raw) => {
|
|
28
|
+
let line = raw.trim();
|
|
29
|
+
if (line.includes("(eval "))
|
|
30
|
+
line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
|
|
31
|
+
let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
|
|
32
|
+
const location = sanitizedLine.match(/ (\(.+\)$)/);
|
|
33
|
+
sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
|
|
34
|
+
const [url, lineNumber, columnNumber] = extractLocation(location ? location[1] : sanitizedLine);
|
|
35
|
+
let method = location && sanitizedLine || "";
|
|
36
|
+
let file = url && ["eval", "<anonymous>"].includes(url) ? void 0 : url;
|
|
37
|
+
if (!file || !lineNumber || !columnNumber)
|
|
38
|
+
return null;
|
|
39
|
+
if (method.startsWith("async "))
|
|
40
|
+
method = method.slice(6);
|
|
41
|
+
if (file.startsWith("file://"))
|
|
42
|
+
file = file.slice(7);
|
|
43
|
+
if (!full && stackIgnorePatterns.some((p) => file && file.includes(p)))
|
|
44
|
+
return null;
|
|
45
|
+
return {
|
|
46
|
+
method,
|
|
47
|
+
file: slash(file),
|
|
48
|
+
line: parseInt(lineNumber),
|
|
49
|
+
column: parseInt(columnNumber)
|
|
50
|
+
};
|
|
51
|
+
}).filter(notNullish);
|
|
52
|
+
e.stacks = stackFrames;
|
|
53
|
+
return stackFrames;
|
|
54
|
+
}
|
|
55
|
+
function posToNumber(source, pos) {
|
|
56
|
+
if (typeof pos === "number")
|
|
57
|
+
return pos;
|
|
58
|
+
const lines = source.split(lineSplitRE);
|
|
59
|
+
const { line, column } = pos;
|
|
60
|
+
let start = 0;
|
|
61
|
+
if (line > lines.length)
|
|
62
|
+
return source.length;
|
|
63
|
+
for (let i = 0; i < line - 1; i++)
|
|
64
|
+
start += lines[i].length + 1;
|
|
65
|
+
return start + column;
|
|
66
|
+
}
|
|
67
|
+
function numberToPos(source, offset) {
|
|
68
|
+
if (typeof offset !== "number")
|
|
69
|
+
return offset;
|
|
70
|
+
if (offset > source.length) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
`offset is longer than source length! offset ${offset} > length ${source.length}`
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
const lines = source.split(lineSplitRE);
|
|
76
|
+
let counted = 0;
|
|
77
|
+
let line = 0;
|
|
78
|
+
let column = 0;
|
|
79
|
+
for (; line < lines.length; line++) {
|
|
80
|
+
const lineLength = lines[line].length + 1;
|
|
81
|
+
if (counted + lineLength >= offset) {
|
|
82
|
+
column = offset - counted + 1;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
counted += lineLength;
|
|
86
|
+
}
|
|
87
|
+
return { line: line + 1, column };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export { posToNumber as a, lineSplitRE as l, numberToPos as n, parseStacktrace as p };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as picocolors } from './chunk-utils-env.
|
|
1
|
+
import { p as picocolors } from './chunk-utils-env.03f840f2.js';
|
|
2
2
|
|
|
3
3
|
const {
|
|
4
4
|
setTimeout: safeSetTimeout,
|
|
@@ -3043,74 +3043,78 @@ const wrapAnsi256 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`;
|
|
|
3043
3043
|
|
|
3044
3044
|
const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
|
|
3045
3045
|
|
|
3046
|
+
const styles = {
|
|
3047
|
+
modifier: {
|
|
3048
|
+
reset: [0, 0],
|
|
3049
|
+
// 21 isn't widely supported and 22 does the same thing
|
|
3050
|
+
bold: [1, 22],
|
|
3051
|
+
dim: [2, 22],
|
|
3052
|
+
italic: [3, 23],
|
|
3053
|
+
underline: [4, 24],
|
|
3054
|
+
overline: [53, 55],
|
|
3055
|
+
inverse: [7, 27],
|
|
3056
|
+
hidden: [8, 28],
|
|
3057
|
+
strikethrough: [9, 29],
|
|
3058
|
+
},
|
|
3059
|
+
color: {
|
|
3060
|
+
black: [30, 39],
|
|
3061
|
+
red: [31, 39],
|
|
3062
|
+
green: [32, 39],
|
|
3063
|
+
yellow: [33, 39],
|
|
3064
|
+
blue: [34, 39],
|
|
3065
|
+
magenta: [35, 39],
|
|
3066
|
+
cyan: [36, 39],
|
|
3067
|
+
white: [37, 39],
|
|
3068
|
+
|
|
3069
|
+
// Bright color
|
|
3070
|
+
blackBright: [90, 39],
|
|
3071
|
+
gray: [90, 39], // Alias of `blackBright`
|
|
3072
|
+
grey: [90, 39], // Alias of `blackBright`
|
|
3073
|
+
redBright: [91, 39],
|
|
3074
|
+
greenBright: [92, 39],
|
|
3075
|
+
yellowBright: [93, 39],
|
|
3076
|
+
blueBright: [94, 39],
|
|
3077
|
+
magentaBright: [95, 39],
|
|
3078
|
+
cyanBright: [96, 39],
|
|
3079
|
+
whiteBright: [97, 39],
|
|
3080
|
+
},
|
|
3081
|
+
bgColor: {
|
|
3082
|
+
bgBlack: [40, 49],
|
|
3083
|
+
bgRed: [41, 49],
|
|
3084
|
+
bgGreen: [42, 49],
|
|
3085
|
+
bgYellow: [43, 49],
|
|
3086
|
+
bgBlue: [44, 49],
|
|
3087
|
+
bgMagenta: [45, 49],
|
|
3088
|
+
bgCyan: [46, 49],
|
|
3089
|
+
bgWhite: [47, 49],
|
|
3090
|
+
|
|
3091
|
+
// Bright color
|
|
3092
|
+
bgBlackBright: [100, 49],
|
|
3093
|
+
bgGray: [100, 49], // Alias of `bgBlackBright`
|
|
3094
|
+
bgGrey: [100, 49], // Alias of `bgBlackBright`
|
|
3095
|
+
bgRedBright: [101, 49],
|
|
3096
|
+
bgGreenBright: [102, 49],
|
|
3097
|
+
bgYellowBright: [103, 49],
|
|
3098
|
+
bgBlueBright: [104, 49],
|
|
3099
|
+
bgMagentaBright: [105, 49],
|
|
3100
|
+
bgCyanBright: [106, 49],
|
|
3101
|
+
bgWhiteBright: [107, 49],
|
|
3102
|
+
},
|
|
3103
|
+
};
|
|
3104
|
+
|
|
3105
|
+
Object.keys(styles.modifier);
|
|
3106
|
+
const foregroundColorNames = Object.keys(styles.color);
|
|
3107
|
+
const backgroundColorNames = Object.keys(styles.bgColor);
|
|
3108
|
+
[...foregroundColorNames, ...backgroundColorNames];
|
|
3109
|
+
|
|
3046
3110
|
function assembleStyles() {
|
|
3047
3111
|
const codes = new Map();
|
|
3048
|
-
const styles = {
|
|
3049
|
-
modifier: {
|
|
3050
|
-
reset: [0, 0],
|
|
3051
|
-
// 21 isn't widely supported and 22 does the same thing
|
|
3052
|
-
bold: [1, 22],
|
|
3053
|
-
dim: [2, 22],
|
|
3054
|
-
italic: [3, 23],
|
|
3055
|
-
underline: [4, 24],
|
|
3056
|
-
overline: [53, 55],
|
|
3057
|
-
inverse: [7, 27],
|
|
3058
|
-
hidden: [8, 28],
|
|
3059
|
-
strikethrough: [9, 29]
|
|
3060
|
-
},
|
|
3061
|
-
color: {
|
|
3062
|
-
black: [30, 39],
|
|
3063
|
-
red: [31, 39],
|
|
3064
|
-
green: [32, 39],
|
|
3065
|
-
yellow: [33, 39],
|
|
3066
|
-
blue: [34, 39],
|
|
3067
|
-
magenta: [35, 39],
|
|
3068
|
-
cyan: [36, 39],
|
|
3069
|
-
white: [37, 39],
|
|
3070
|
-
|
|
3071
|
-
// Bright color
|
|
3072
|
-
blackBright: [90, 39],
|
|
3073
|
-
redBright: [91, 39],
|
|
3074
|
-
greenBright: [92, 39],
|
|
3075
|
-
yellowBright: [93, 39],
|
|
3076
|
-
blueBright: [94, 39],
|
|
3077
|
-
magentaBright: [95, 39],
|
|
3078
|
-
cyanBright: [96, 39],
|
|
3079
|
-
whiteBright: [97, 39]
|
|
3080
|
-
},
|
|
3081
|
-
bgColor: {
|
|
3082
|
-
bgBlack: [40, 49],
|
|
3083
|
-
bgRed: [41, 49],
|
|
3084
|
-
bgGreen: [42, 49],
|
|
3085
|
-
bgYellow: [43, 49],
|
|
3086
|
-
bgBlue: [44, 49],
|
|
3087
|
-
bgMagenta: [45, 49],
|
|
3088
|
-
bgCyan: [46, 49],
|
|
3089
|
-
bgWhite: [47, 49],
|
|
3090
|
-
|
|
3091
|
-
// Bright color
|
|
3092
|
-
bgBlackBright: [100, 49],
|
|
3093
|
-
bgRedBright: [101, 49],
|
|
3094
|
-
bgGreenBright: [102, 49],
|
|
3095
|
-
bgYellowBright: [103, 49],
|
|
3096
|
-
bgBlueBright: [104, 49],
|
|
3097
|
-
bgMagentaBright: [105, 49],
|
|
3098
|
-
bgCyanBright: [106, 49],
|
|
3099
|
-
bgWhiteBright: [107, 49]
|
|
3100
|
-
}
|
|
3101
|
-
};
|
|
3102
|
-
|
|
3103
|
-
// Alias bright black as gray (and grey)
|
|
3104
|
-
styles.color.gray = styles.color.blackBright;
|
|
3105
|
-
styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
|
|
3106
|
-
styles.color.grey = styles.color.blackBright;
|
|
3107
|
-
styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
|
|
3108
3112
|
|
|
3109
3113
|
for (const [groupName, group] of Object.entries(styles)) {
|
|
3110
3114
|
for (const [styleName, style] of Object.entries(group)) {
|
|
3111
3115
|
styles[styleName] = {
|
|
3112
3116
|
open: `\u001B[${style[0]}m`,
|
|
3113
|
-
close: `\u001B[${style[1]}m
|
|
3117
|
+
close: `\u001B[${style[1]}m`,
|
|
3114
3118
|
};
|
|
3115
3119
|
|
|
3116
3120
|
group[styleName] = styles[styleName];
|
|
@@ -3120,13 +3124,13 @@ function assembleStyles() {
|
|
|
3120
3124
|
|
|
3121
3125
|
Object.defineProperty(styles, groupName, {
|
|
3122
3126
|
value: group,
|
|
3123
|
-
enumerable: false
|
|
3127
|
+
enumerable: false,
|
|
3124
3128
|
});
|
|
3125
3129
|
}
|
|
3126
3130
|
|
|
3127
3131
|
Object.defineProperty(styles, 'codes', {
|
|
3128
3132
|
value: codes,
|
|
3129
|
-
enumerable: false
|
|
3133
|
+
enumerable: false,
|
|
3130
3134
|
});
|
|
3131
3135
|
|
|
3132
3136
|
styles.color.close = '\u001B[39m';
|
|
@@ -3157,39 +3161,41 @@ function assembleStyles() {
|
|
|
3157
3161
|
return Math.round(((red - 8) / 247) * 24) + 232;
|
|
3158
3162
|
}
|
|
3159
3163
|
|
|
3160
|
-
return 16
|
|
3161
|
-
(36 * Math.round(red / 255 * 5))
|
|
3162
|
-
(6 * Math.round(green / 255 * 5))
|
|
3163
|
-
Math.round(blue / 255 * 5);
|
|
3164
|
+
return 16
|
|
3165
|
+
+ (36 * Math.round(red / 255 * 5))
|
|
3166
|
+
+ (6 * Math.round(green / 255 * 5))
|
|
3167
|
+
+ Math.round(blue / 255 * 5);
|
|
3164
3168
|
},
|
|
3165
|
-
enumerable: false
|
|
3169
|
+
enumerable: false,
|
|
3166
3170
|
},
|
|
3167
3171
|
hexToRgb: {
|
|
3168
3172
|
value: hex => {
|
|
3169
|
-
const matches = /
|
|
3173
|
+
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
3170
3174
|
if (!matches) {
|
|
3171
3175
|
return [0, 0, 0];
|
|
3172
3176
|
}
|
|
3173
3177
|
|
|
3174
|
-
let
|
|
3178
|
+
let [colorString] = matches;
|
|
3175
3179
|
|
|
3176
3180
|
if (colorString.length === 3) {
|
|
3177
|
-
colorString = colorString.
|
|
3181
|
+
colorString = [...colorString].map(character => character + character).join('');
|
|
3178
3182
|
}
|
|
3179
3183
|
|
|
3180
3184
|
const integer = Number.parseInt(colorString, 16);
|
|
3181
3185
|
|
|
3182
3186
|
return [
|
|
3187
|
+
/* eslint-disable no-bitwise */
|
|
3183
3188
|
(integer >> 16) & 0xFF,
|
|
3184
3189
|
(integer >> 8) & 0xFF,
|
|
3185
|
-
integer & 0xFF
|
|
3190
|
+
integer & 0xFF,
|
|
3191
|
+
/* eslint-enable no-bitwise */
|
|
3186
3192
|
];
|
|
3187
3193
|
},
|
|
3188
|
-
enumerable: false
|
|
3194
|
+
enumerable: false,
|
|
3189
3195
|
},
|
|
3190
3196
|
hexToAnsi256: {
|
|
3191
3197
|
value: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
3192
|
-
enumerable: false
|
|
3198
|
+
enumerable: false,
|
|
3193
3199
|
},
|
|
3194
3200
|
ansi256ToAnsi: {
|
|
3195
3201
|
value: code => {
|
|
@@ -3225,6 +3231,7 @@ function assembleStyles() {
|
|
|
3225
3231
|
return 30;
|
|
3226
3232
|
}
|
|
3227
3233
|
|
|
3234
|
+
// eslint-disable-next-line no-bitwise
|
|
3228
3235
|
let result = 30 + ((Math.round(blue) << 2) | (Math.round(green) << 1) | Math.round(red));
|
|
3229
3236
|
|
|
3230
3237
|
if (value === 2) {
|
|
@@ -3233,16 +3240,16 @@ function assembleStyles() {
|
|
|
3233
3240
|
|
|
3234
3241
|
return result;
|
|
3235
3242
|
},
|
|
3236
|
-
enumerable: false
|
|
3243
|
+
enumerable: false,
|
|
3237
3244
|
},
|
|
3238
3245
|
rgbToAnsi: {
|
|
3239
3246
|
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
3240
|
-
enumerable: false
|
|
3247
|
+
enumerable: false,
|
|
3241
3248
|
},
|
|
3242
3249
|
hexToAnsi: {
|
|
3243
3250
|
value: hex => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
3244
|
-
enumerable: false
|
|
3245
|
-
}
|
|
3251
|
+
enumerable: false,
|
|
3252
|
+
},
|
|
3246
3253
|
});
|
|
3247
3254
|
|
|
3248
3255
|
return styles;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRequire } from 'module';
|
|
2
2
|
import { pathToFileURL, fileURLToPath } from 'url';
|
|
3
3
|
import vm from 'vm';
|
|
4
|
-
import { b as resolve, d as dirname, g as isAbsolute, l as extname } from './chunk-utils-env.
|
|
5
|
-
import { s as slash, n as normalizeRequestId, b as toFilePath, i as isNodeBuiltin, c as isPrimitive, d as normalizeModuleId, m as mergeSlashes } from './chunk-vite-node-utils.
|
|
4
|
+
import { b as resolve, d as dirname, g as isAbsolute, l as extname } from './chunk-utils-env.03f840f2.js';
|
|
5
|
+
import { s as slash, n as normalizeRequestId, b as toFilePath, i as isNodeBuiltin, c as isPrimitive, d as normalizeModuleId, m as mergeSlashes } from './chunk-vite-node-utils.8f0b4a12.js';
|
|
6
6
|
import createDebug from 'debug';
|
|
7
7
|
|
|
8
8
|
const debugExecute = createDebug("vite-node:client:execute");
|
|
@@ -95,6 +95,20 @@ class ModuleCacheMap extends Map {
|
|
|
95
95
|
}
|
|
96
96
|
return invalidated;
|
|
97
97
|
}
|
|
98
|
+
getSourceMap(id) {
|
|
99
|
+
var _a, _b;
|
|
100
|
+
const fsPath = this.normalizePath(id);
|
|
101
|
+
const cache = this.get(fsPath);
|
|
102
|
+
if (cache.map)
|
|
103
|
+
return cache.map;
|
|
104
|
+
const mapString = (_b = (_a = cache == null ? void 0 : cache.code) == null ? void 0 : _a.match(/\/\/# sourceMappingURL=data:application\/json;charset=utf-8;base64,(.+)/)) == null ? void 0 : _b[1];
|
|
105
|
+
if (mapString) {
|
|
106
|
+
const map = JSON.parse(Buffer.from(mapString, "base64").toString("utf-8"));
|
|
107
|
+
cache.map = map;
|
|
108
|
+
return map;
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
98
112
|
}
|
|
99
113
|
class ViteNodeRunner {
|
|
100
114
|
constructor(options) {
|
|
@@ -109,6 +123,9 @@ class ViteNodeRunner {
|
|
|
109
123
|
async executeId(id) {
|
|
110
124
|
return await this.cachedRequest(id, []);
|
|
111
125
|
}
|
|
126
|
+
getSourceMap(id) {
|
|
127
|
+
return this.moduleCache.getSourceMap(id);
|
|
128
|
+
}
|
|
112
129
|
async cachedRequest(rawId, callstack) {
|
|
113
130
|
const id = normalizeRequestId(rawId, this.options.base);
|
|
114
131
|
const fsPath = toFilePath(id, this.root);
|
|
@@ -240,10 +257,13 @@ ${getStack()}`), 2e3);
|
|
|
240
257
|
debugExecute(__filename);
|
|
241
258
|
if (transformed[0] === "#")
|
|
242
259
|
transformed = transformed.replace(/^\#\!.*/, (s) => " ".repeat(s.length));
|
|
243
|
-
const
|
|
244
|
-
}}
|
|
260
|
+
const codeDefinition = `'use strict';async (${Object.keys(context).join(",")})=>{{`;
|
|
261
|
+
const code = `${codeDefinition}${transformed}
|
|
262
|
+
}}`;
|
|
263
|
+
const fn = vm.runInThisContext(code, {
|
|
245
264
|
filename: fsPath,
|
|
246
|
-
lineOffset: 0
|
|
265
|
+
lineOffset: 0,
|
|
266
|
+
columnOffset: -codeDefinition.length
|
|
247
267
|
});
|
|
248
268
|
await fn(...Object.values(context));
|
|
249
269
|
return exports;
|