vitest 4.0.15 → 4.0.16
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/dist/browser.d.ts +1 -1
- package/dist/browser.js +1 -1
- package/dist/chunks/{base.CTp-EStD.js → base.Bin-9uYm.js} +4 -3
- package/dist/chunks/{browser.d.DBzUq_Na.d.ts → browser.d.Bz3lxTX-.d.ts} +1 -1
- package/dist/chunks/{cac.BNNpZQl7.js → cac.BGonGPac.js} +3 -3
- package/dist/chunks/{cli-api.C7sYjHmQ.js → cli-api.BKg19Fvw.js} +51 -31
- package/dist/chunks/{coverage.CtyeYmKM.js → coverage.BuJUwVtg.js} +2 -1
- package/dist/chunks/{index.bFLgAE-Z.js → index.6Qv1eEA6.js} +2 -2
- package/dist/chunks/index.Chj8NDwU.js +206 -0
- package/dist/chunks/{init-forks.CKEYp90N.js → init-forks.v9UONQS6.js} +1 -1
- package/dist/chunks/{init-threads.D8Ok07M7.js → init-threads.DqYg3Trk.js} +1 -1
- package/dist/chunks/{init.B04saIIg.js → init.KmQZdqFg.js} +2 -2
- package/dist/chunks/{modules.DJPjQW6m.js → modules.BJuCwlRJ.js} +4 -3
- package/dist/chunks/{plugin.d.CY7CUjf-.d.ts → plugin.d.v1sC_bv1.d.ts} +1 -1
- package/dist/chunks/{reporters.d.OXEK7y4s.d.ts → reporters.d.Rsi0PyxX.d.ts} +2 -2
- package/dist/chunks/{rpc.BytlcPfC.js → rpc.BoxB0q7B.js} +1 -1
- package/dist/chunks/{startModuleRunner.Iz2V0ESw.js → startModuleRunner.DpqpB8k3.js} +1 -1
- package/dist/chunks/{test.BT8LKgU9.js → test.B8ej_ZHS.js} +1 -1
- package/dist/chunks/{vm.BwmD1Rql.js → vm.qFl6P1nF.js} +2 -2
- package/dist/chunks/worker.d.5JNaocaN.d.ts +254 -0
- package/dist/cli.js +1 -1
- package/dist/config.d.ts +5 -5
- package/dist/coverage.d.ts +3 -3
- package/dist/coverage.js +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/module-evaluator.js +2 -10
- package/dist/module-runner.js +2 -2
- package/dist/node.d.ts +16 -9
- package/dist/node.js +8 -8
- package/dist/reporters.d.ts +3 -3
- package/dist/runners.js +3 -3
- package/dist/worker.d.ts +4 -2
- package/dist/worker.js +8 -8
- package/dist/workers/forks.js +9 -9
- package/dist/workers/runVmTests.js +4 -4
- package/dist/workers/threads.js +9 -9
- package/dist/workers/vmForks.js +7 -7
- package/dist/workers/vmThreads.js +7 -7
- package/package.json +13 -13
- package/dist/chunks/index.0kCJoeWi.js +0 -220
- package/dist/chunks/worker.d.B4A26qg6.d.ts +0 -238
package/dist/workers/threads.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { s as setupEnvironment, r as runBaseTests } from '../chunks/base.
|
|
2
|
-
import { w as workerInit } from '../chunks/init-threads.
|
|
1
|
+
import { s as setupEnvironment, r as runBaseTests } from '../chunks/base.Bin-9uYm.js';
|
|
2
|
+
import { w as workerInit } from '../chunks/init-threads.DqYg3Trk.js';
|
|
3
3
|
import 'node:vm';
|
|
4
4
|
import '@vitest/spy';
|
|
5
|
-
import '../chunks/index.
|
|
5
|
+
import '../chunks/index.6Qv1eEA6.js';
|
|
6
6
|
import '@vitest/expect';
|
|
7
7
|
import '../chunks/setup-common.Cm-kSBVi.js';
|
|
8
8
|
import '../chunks/coverage.D_JHT54q.js';
|
|
9
9
|
import '@vitest/snapshot';
|
|
10
10
|
import '@vitest/utils/timers';
|
|
11
11
|
import '../chunks/utils.DvEY5TfP.js';
|
|
12
|
-
import '../chunks/rpc.
|
|
13
|
-
import '../chunks/index.
|
|
14
|
-
import '../chunks/test.
|
|
12
|
+
import '../chunks/rpc.BoxB0q7B.js';
|
|
13
|
+
import '../chunks/index.Chj8NDwU.js';
|
|
14
|
+
import '../chunks/test.B8ej_ZHS.js';
|
|
15
15
|
import '@vitest/runner';
|
|
16
16
|
import '@vitest/utils/helpers';
|
|
17
17
|
import '../chunks/benchmark.B3N2zMcH.js';
|
|
@@ -23,13 +23,13 @@ import '@vitest/utils/offset';
|
|
|
23
23
|
import '@vitest/utils/source-map';
|
|
24
24
|
import '../chunks/_commonjsHelpers.D26ty3Ew.js';
|
|
25
25
|
import '../chunks/date.Bq6ZW5rf.js';
|
|
26
|
-
import '../chunks/init.
|
|
26
|
+
import '../chunks/init.KmQZdqFg.js';
|
|
27
27
|
import 'node:fs';
|
|
28
28
|
import 'node:module';
|
|
29
29
|
import 'node:url';
|
|
30
30
|
import 'vite/module-runner';
|
|
31
|
-
import '../chunks/startModuleRunner.
|
|
32
|
-
import '../chunks/modules.
|
|
31
|
+
import '../chunks/startModuleRunner.DpqpB8k3.js';
|
|
32
|
+
import '../chunks/modules.BJuCwlRJ.js';
|
|
33
33
|
import '../path.js';
|
|
34
34
|
import 'node:path';
|
|
35
35
|
import '@vitest/utils/serialize';
|
package/dist/workers/vmForks.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { w as workerInit } from '../chunks/init-forks.
|
|
2
|
-
import { r as runVmTests } from '../chunks/vm.
|
|
3
|
-
import '../chunks/init.
|
|
1
|
+
import { w as workerInit } from '../chunks/init-forks.v9UONQS6.js';
|
|
2
|
+
import { r as runVmTests } from '../chunks/vm.qFl6P1nF.js';
|
|
3
|
+
import '../chunks/init.KmQZdqFg.js';
|
|
4
4
|
import 'node:fs';
|
|
5
5
|
import 'node:module';
|
|
6
6
|
import 'node:url';
|
|
7
7
|
import 'pathe';
|
|
8
8
|
import 'vite/module-runner';
|
|
9
|
-
import '../chunks/startModuleRunner.
|
|
9
|
+
import '../chunks/startModuleRunner.DpqpB8k3.js';
|
|
10
10
|
import '@vitest/utils/helpers';
|
|
11
|
-
import '../chunks/modules.
|
|
11
|
+
import '../chunks/modules.BJuCwlRJ.js';
|
|
12
12
|
import '../path.js';
|
|
13
13
|
import 'node:path';
|
|
14
14
|
import '@vitest/utils/serialize';
|
|
@@ -19,9 +19,9 @@ import '@vitest/mocker';
|
|
|
19
19
|
import '../chunks/index.BspFP3mn.js';
|
|
20
20
|
import 'node:console';
|
|
21
21
|
import '@vitest/utils/error';
|
|
22
|
-
import '../chunks/rpc.
|
|
22
|
+
import '../chunks/rpc.BoxB0q7B.js';
|
|
23
23
|
import '@vitest/utils/timers';
|
|
24
|
-
import '../chunks/index.
|
|
24
|
+
import '../chunks/index.Chj8NDwU.js';
|
|
25
25
|
import '../chunks/utils.DvEY5TfP.js';
|
|
26
26
|
import '@vitest/utils/source-map';
|
|
27
27
|
import '../chunks/inspector.CvyFGlXm.js';
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { w as workerInit } from '../chunks/init-threads.
|
|
2
|
-
import { r as runVmTests } from '../chunks/vm.
|
|
1
|
+
import { w as workerInit } from '../chunks/init-threads.DqYg3Trk.js';
|
|
2
|
+
import { r as runVmTests } from '../chunks/vm.qFl6P1nF.js';
|
|
3
3
|
import 'node:worker_threads';
|
|
4
|
-
import '../chunks/init.
|
|
4
|
+
import '../chunks/init.KmQZdqFg.js';
|
|
5
5
|
import 'node:fs';
|
|
6
6
|
import 'node:module';
|
|
7
7
|
import 'node:url';
|
|
8
8
|
import 'pathe';
|
|
9
9
|
import 'vite/module-runner';
|
|
10
|
-
import '../chunks/startModuleRunner.
|
|
10
|
+
import '../chunks/startModuleRunner.DpqpB8k3.js';
|
|
11
11
|
import '@vitest/utils/helpers';
|
|
12
|
-
import '../chunks/modules.
|
|
12
|
+
import '../chunks/modules.BJuCwlRJ.js';
|
|
13
13
|
import '../path.js';
|
|
14
14
|
import 'node:path';
|
|
15
15
|
import '@vitest/utils/serialize';
|
|
@@ -20,9 +20,9 @@ import '@vitest/mocker';
|
|
|
20
20
|
import '../chunks/index.BspFP3mn.js';
|
|
21
21
|
import 'node:console';
|
|
22
22
|
import '@vitest/utils/error';
|
|
23
|
-
import '../chunks/rpc.
|
|
23
|
+
import '../chunks/rpc.BoxB0q7B.js';
|
|
24
24
|
import '@vitest/utils/timers';
|
|
25
|
-
import '../chunks/index.
|
|
25
|
+
import '../chunks/index.Chj8NDwU.js';
|
|
26
26
|
import '../chunks/utils.DvEY5TfP.js';
|
|
27
27
|
import '@vitest/utils/source-map';
|
|
28
28
|
import '../chunks/inspector.CvyFGlXm.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.16",
|
|
5
5
|
"description": "Next generation testing framework powered by Vite",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -134,10 +134,10 @@
|
|
|
134
134
|
"@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0",
|
|
135
135
|
"happy-dom": "*",
|
|
136
136
|
"jsdom": "*",
|
|
137
|
-
"@vitest/browser-playwright": "4.0.
|
|
138
|
-
"@vitest/browser-preview": "4.0.
|
|
139
|
-
"@vitest/
|
|
140
|
-
"@vitest/
|
|
137
|
+
"@vitest/browser-playwright": "4.0.16",
|
|
138
|
+
"@vitest/browser-preview": "4.0.16",
|
|
139
|
+
"@vitest/browser-webdriverio": "4.0.16",
|
|
140
|
+
"@vitest/ui": "4.0.16"
|
|
141
141
|
},
|
|
142
142
|
"peerDependenciesMeta": {
|
|
143
143
|
"@edge-runtime/vm": {
|
|
@@ -182,13 +182,13 @@
|
|
|
182
182
|
"tinyrainbow": "^3.0.3",
|
|
183
183
|
"vite": "^6.0.0 || ^7.0.0",
|
|
184
184
|
"why-is-node-running": "^2.3.0",
|
|
185
|
-
"@vitest/expect": "4.0.
|
|
186
|
-
"@vitest/
|
|
187
|
-
"@vitest/runner": "4.0.
|
|
188
|
-
"@vitest/
|
|
189
|
-
"@vitest/snapshot": "4.0.
|
|
190
|
-
"@vitest/
|
|
191
|
-
"@vitest/
|
|
185
|
+
"@vitest/expect": "4.0.16",
|
|
186
|
+
"@vitest/mocker": "4.0.16",
|
|
187
|
+
"@vitest/runner": "4.0.16",
|
|
188
|
+
"@vitest/pretty-format": "4.0.16",
|
|
189
|
+
"@vitest/snapshot": "4.0.16",
|
|
190
|
+
"@vitest/spy": "4.0.16",
|
|
191
|
+
"@vitest/utils": "4.0.16"
|
|
192
192
|
},
|
|
193
193
|
"devDependencies": {
|
|
194
194
|
"@antfu/install-pkg": "^1.1.0",
|
|
@@ -205,7 +205,7 @@
|
|
|
205
205
|
"@types/prompts": "^2.4.9",
|
|
206
206
|
"@types/sinonjs__fake-timers": "^8.1.5",
|
|
207
207
|
"acorn-walk": "^8.3.4",
|
|
208
|
-
"birpc": "^
|
|
208
|
+
"birpc": "^4.0.0",
|
|
209
209
|
"cac": "^6.7.14",
|
|
210
210
|
"empathic": "^2.0.0",
|
|
211
211
|
"flatted": "^3.3.3",
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
const TYPE_REQUEST = "q";
|
|
2
|
-
const TYPE_RESPONSE = "s";
|
|
3
|
-
const DEFAULT_TIMEOUT = 6e4;
|
|
4
|
-
function defaultSerialize(i) {
|
|
5
|
-
return i;
|
|
6
|
-
}
|
|
7
|
-
const defaultDeserialize = defaultSerialize;
|
|
8
|
-
const { clearTimeout, setTimeout } = globalThis;
|
|
9
|
-
const random = Math.random.bind(Math);
|
|
10
|
-
function createBirpc($functions, options) {
|
|
11
|
-
const {
|
|
12
|
-
post,
|
|
13
|
-
on,
|
|
14
|
-
off = () => {
|
|
15
|
-
},
|
|
16
|
-
eventNames = [],
|
|
17
|
-
serialize = defaultSerialize,
|
|
18
|
-
deserialize = defaultDeserialize,
|
|
19
|
-
resolver,
|
|
20
|
-
bind = "rpc",
|
|
21
|
-
timeout = DEFAULT_TIMEOUT
|
|
22
|
-
} = options;
|
|
23
|
-
let $closed = false;
|
|
24
|
-
const _rpcPromiseMap = /* @__PURE__ */ new Map();
|
|
25
|
-
let _promiseInit;
|
|
26
|
-
async function _call(method, args, event, optional) {
|
|
27
|
-
if ($closed)
|
|
28
|
-
throw new Error(`[birpc] rpc is closed, cannot call "${method}"`);
|
|
29
|
-
const req = { m: method, a: args, t: TYPE_REQUEST };
|
|
30
|
-
if (optional)
|
|
31
|
-
req.o = true;
|
|
32
|
-
const send = async (_req) => post(serialize(_req));
|
|
33
|
-
if (event) {
|
|
34
|
-
await send(req);
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
if (_promiseInit) {
|
|
38
|
-
try {
|
|
39
|
-
await _promiseInit;
|
|
40
|
-
} finally {
|
|
41
|
-
_promiseInit = void 0;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
let { promise, resolve, reject } = createPromiseWithResolvers();
|
|
45
|
-
const id = nanoid();
|
|
46
|
-
req.i = id;
|
|
47
|
-
let timeoutId;
|
|
48
|
-
async function handler(newReq = req) {
|
|
49
|
-
if (timeout >= 0) {
|
|
50
|
-
timeoutId = setTimeout(() => {
|
|
51
|
-
try {
|
|
52
|
-
const handleResult = options.onTimeoutError?.(method, args);
|
|
53
|
-
if (handleResult !== true)
|
|
54
|
-
throw new Error(`[birpc] timeout on calling "${method}"`);
|
|
55
|
-
} catch (e) {
|
|
56
|
-
reject(e);
|
|
57
|
-
}
|
|
58
|
-
_rpcPromiseMap.delete(id);
|
|
59
|
-
}, timeout);
|
|
60
|
-
if (typeof timeoutId === "object")
|
|
61
|
-
timeoutId = timeoutId.unref?.();
|
|
62
|
-
}
|
|
63
|
-
_rpcPromiseMap.set(id, { resolve, reject, timeoutId, method });
|
|
64
|
-
await send(newReq);
|
|
65
|
-
return promise;
|
|
66
|
-
}
|
|
67
|
-
try {
|
|
68
|
-
if (options.onRequest)
|
|
69
|
-
await options.onRequest(req, handler, resolve);
|
|
70
|
-
else
|
|
71
|
-
await handler();
|
|
72
|
-
} catch (e) {
|
|
73
|
-
if (options.onGeneralError?.(e) !== true)
|
|
74
|
-
throw e;
|
|
75
|
-
return;
|
|
76
|
-
} finally {
|
|
77
|
-
clearTimeout(timeoutId);
|
|
78
|
-
_rpcPromiseMap.delete(id);
|
|
79
|
-
}
|
|
80
|
-
return promise;
|
|
81
|
-
}
|
|
82
|
-
const $call = (method, ...args) => _call(method, args, false);
|
|
83
|
-
const $callOptional = (method, ...args) => _call(method, args, false, true);
|
|
84
|
-
const $callEvent = (method, ...args) => _call(method, args, true);
|
|
85
|
-
const $callRaw = (options2) => _call(options2.method, options2.args, options2.event, options2.optional);
|
|
86
|
-
const builtinMethods = {
|
|
87
|
-
$call,
|
|
88
|
-
$callOptional,
|
|
89
|
-
$callEvent,
|
|
90
|
-
$callRaw,
|
|
91
|
-
$rejectPendingCalls,
|
|
92
|
-
get $closed() {
|
|
93
|
-
return $closed;
|
|
94
|
-
},
|
|
95
|
-
$close,
|
|
96
|
-
$functions
|
|
97
|
-
};
|
|
98
|
-
const rpc = new Proxy({}, {
|
|
99
|
-
get(_, method) {
|
|
100
|
-
if (Object.prototype.hasOwnProperty.call(builtinMethods, method))
|
|
101
|
-
return builtinMethods[method];
|
|
102
|
-
if (method === "then" && !eventNames.includes("then") && !("then" in $functions))
|
|
103
|
-
return void 0;
|
|
104
|
-
const sendEvent = (...args) => _call(method, args, true);
|
|
105
|
-
if (eventNames.includes(method)) {
|
|
106
|
-
sendEvent.asEvent = sendEvent;
|
|
107
|
-
return sendEvent;
|
|
108
|
-
}
|
|
109
|
-
const sendCall = (...args) => _call(method, args, false);
|
|
110
|
-
sendCall.asEvent = sendEvent;
|
|
111
|
-
return sendCall;
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
function $close(customError) {
|
|
115
|
-
$closed = true;
|
|
116
|
-
_rpcPromiseMap.forEach(({ reject, method }) => {
|
|
117
|
-
const error = new Error(`[birpc] rpc is closed, cannot call "${method}"`);
|
|
118
|
-
if (customError) {
|
|
119
|
-
customError.cause ??= error;
|
|
120
|
-
return reject(customError);
|
|
121
|
-
}
|
|
122
|
-
reject(error);
|
|
123
|
-
});
|
|
124
|
-
_rpcPromiseMap.clear();
|
|
125
|
-
off(onMessage);
|
|
126
|
-
}
|
|
127
|
-
function $rejectPendingCalls(handler) {
|
|
128
|
-
const entries = Array.from(_rpcPromiseMap.values());
|
|
129
|
-
const handlerResults = entries.map(({ method, reject }) => {
|
|
130
|
-
if (!handler) {
|
|
131
|
-
return reject(new Error(`[birpc]: rejected pending call "${method}".`));
|
|
132
|
-
}
|
|
133
|
-
return handler({ method, reject });
|
|
134
|
-
});
|
|
135
|
-
_rpcPromiseMap.clear();
|
|
136
|
-
return handlerResults;
|
|
137
|
-
}
|
|
138
|
-
async function onMessage(data, ...extra) {
|
|
139
|
-
let msg;
|
|
140
|
-
try {
|
|
141
|
-
msg = deserialize(data);
|
|
142
|
-
} catch (e) {
|
|
143
|
-
if (options.onGeneralError?.(e) !== true)
|
|
144
|
-
throw e;
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
if (msg.t === TYPE_REQUEST) {
|
|
148
|
-
const { m: method, a: args, o: optional } = msg;
|
|
149
|
-
let result, error;
|
|
150
|
-
let fn = await (resolver ? resolver(method, $functions[method]) : $functions[method]);
|
|
151
|
-
if (optional)
|
|
152
|
-
fn ||= () => void 0;
|
|
153
|
-
if (!fn) {
|
|
154
|
-
error = new Error(`[birpc] function "${method}" not found`);
|
|
155
|
-
} else {
|
|
156
|
-
try {
|
|
157
|
-
result = await fn.apply(bind === "rpc" ? rpc : $functions, args);
|
|
158
|
-
} catch (e) {
|
|
159
|
-
error = e;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
if (msg.i) {
|
|
163
|
-
if (error && options.onError)
|
|
164
|
-
options.onError(error, method, args);
|
|
165
|
-
if (error && options.onFunctionError) {
|
|
166
|
-
if (options.onFunctionError(error, method, args) === true)
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
if (!error) {
|
|
170
|
-
try {
|
|
171
|
-
await post(serialize({ t: TYPE_RESPONSE, i: msg.i, r: result }), ...extra);
|
|
172
|
-
return;
|
|
173
|
-
} catch (e) {
|
|
174
|
-
error = e;
|
|
175
|
-
if (options.onGeneralError?.(e, method, args) !== true)
|
|
176
|
-
throw e;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
try {
|
|
180
|
-
await post(serialize({ t: TYPE_RESPONSE, i: msg.i, e: error }), ...extra);
|
|
181
|
-
} catch (e) {
|
|
182
|
-
if (options.onGeneralError?.(e, method, args) !== true)
|
|
183
|
-
throw e;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
} else {
|
|
187
|
-
const { i: ack, r: result, e: error } = msg;
|
|
188
|
-
const promise = _rpcPromiseMap.get(ack);
|
|
189
|
-
if (promise) {
|
|
190
|
-
clearTimeout(promise.timeoutId);
|
|
191
|
-
if (error)
|
|
192
|
-
promise.reject(error);
|
|
193
|
-
else
|
|
194
|
-
promise.resolve(result);
|
|
195
|
-
}
|
|
196
|
-
_rpcPromiseMap.delete(ack);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
_promiseInit = on(onMessage);
|
|
200
|
-
return rpc;
|
|
201
|
-
}
|
|
202
|
-
function createPromiseWithResolvers() {
|
|
203
|
-
let resolve;
|
|
204
|
-
let reject;
|
|
205
|
-
const promise = new Promise((res, rej) => {
|
|
206
|
-
resolve = res;
|
|
207
|
-
reject = rej;
|
|
208
|
-
});
|
|
209
|
-
return { promise, resolve, reject };
|
|
210
|
-
}
|
|
211
|
-
const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
212
|
-
function nanoid(size = 21) {
|
|
213
|
-
let id = "";
|
|
214
|
-
let i = size;
|
|
215
|
-
while (i--)
|
|
216
|
-
id += urlAlphabet[random() * 64 | 0];
|
|
217
|
-
return id;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export { createBirpc as c };
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import { FileSpecification, Task, CancelReason } from '@vitest/runner';
|
|
2
|
-
import { EvaluatedModules } from 'vite/module-runner';
|
|
3
|
-
import { S as SerializedConfig } from './config.d.CzIjkicf.js';
|
|
4
|
-
import { E as Environment } from './environment.d.CrsxCzP1.js';
|
|
5
|
-
import { R as RuntimeRPC, a as RunnerRPC } from './rpc.d.RH3apGEf.js';
|
|
6
|
-
|
|
7
|
-
type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
|
|
8
|
-
type ReturnType<T> = T extends (...args: any) => infer R ? R : never;
|
|
9
|
-
type PromisifyFn<T> = ReturnType<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType<T>>>;
|
|
10
|
-
type Thenable<T> = T | PromiseLike<T>;
|
|
11
|
-
type BirpcResolver = (name: string, resolved: (...args: unknown[]) => unknown) => Thenable<((...args: unknown[]) => unknown) | undefined>;
|
|
12
|
-
interface ChannelOptions {
|
|
13
|
-
/**
|
|
14
|
-
* Function to post raw message
|
|
15
|
-
*/
|
|
16
|
-
post: (data: any, ...extras: any[]) => any | Promise<any>;
|
|
17
|
-
/**
|
|
18
|
-
* Listener to receive raw message
|
|
19
|
-
*/
|
|
20
|
-
on: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
|
|
21
|
-
/**
|
|
22
|
-
* Clear the listener when `$close` is called
|
|
23
|
-
*/
|
|
24
|
-
off?: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
|
|
25
|
-
/**
|
|
26
|
-
* Custom function to serialize data
|
|
27
|
-
*
|
|
28
|
-
* by default it passes the data as-is
|
|
29
|
-
*/
|
|
30
|
-
serialize?: (data: any) => any;
|
|
31
|
-
/**
|
|
32
|
-
* Custom function to deserialize data
|
|
33
|
-
*
|
|
34
|
-
* by default it passes the data as-is
|
|
35
|
-
*/
|
|
36
|
-
deserialize?: (data: any) => any;
|
|
37
|
-
/**
|
|
38
|
-
* Call the methods with the RPC context or the original functions object
|
|
39
|
-
*/
|
|
40
|
-
bind?: 'rpc' | 'functions';
|
|
41
|
-
}
|
|
42
|
-
interface EventOptions<Remote> {
|
|
43
|
-
/**
|
|
44
|
-
* Names of remote functions that do not need response.
|
|
45
|
-
*/
|
|
46
|
-
eventNames?: (keyof Remote)[];
|
|
47
|
-
/**
|
|
48
|
-
* Maximum timeout for waiting for response, in milliseconds.
|
|
49
|
-
*
|
|
50
|
-
* @default 60_000
|
|
51
|
-
*/
|
|
52
|
-
timeout?: number;
|
|
53
|
-
/**
|
|
54
|
-
* Custom resolver to resolve function to be called
|
|
55
|
-
*
|
|
56
|
-
* For advanced use cases only
|
|
57
|
-
*/
|
|
58
|
-
resolver?: BirpcResolver;
|
|
59
|
-
/**
|
|
60
|
-
* Hook triggered before an event is sent to the remote
|
|
61
|
-
*
|
|
62
|
-
* @param req - Request parameters
|
|
63
|
-
* @param next - Function to continue the request
|
|
64
|
-
* @param resolve - Function to resolve the response directly
|
|
65
|
-
*/
|
|
66
|
-
onRequest?: (req: Request, next: (req?: Request) => Promise<any>, resolve: (res: any) => void) => void | Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Custom error handler
|
|
69
|
-
*
|
|
70
|
-
* @deprecated use `onFunctionError` and `onGeneralError` instead
|
|
71
|
-
*/
|
|
72
|
-
onError?: (error: Error, functionName: string, args: any[]) => boolean | void;
|
|
73
|
-
/**
|
|
74
|
-
* Custom error handler for errors occurred in local functions being called
|
|
75
|
-
*
|
|
76
|
-
* @returns `true` to prevent the error from being thrown
|
|
77
|
-
*/
|
|
78
|
-
onFunctionError?: (error: Error, functionName: string, args: any[]) => boolean | void;
|
|
79
|
-
/**
|
|
80
|
-
* Custom error handler for errors occurred during serialization or messsaging
|
|
81
|
-
*
|
|
82
|
-
* @returns `true` to prevent the error from being thrown
|
|
83
|
-
*/
|
|
84
|
-
onGeneralError?: (error: Error, functionName?: string, args?: any[]) => boolean | void;
|
|
85
|
-
/**
|
|
86
|
-
* Custom error handler for timeouts
|
|
87
|
-
*
|
|
88
|
-
* @returns `true` to prevent the error from being thrown
|
|
89
|
-
*/
|
|
90
|
-
onTimeoutError?: (functionName: string, args: any[]) => boolean | void;
|
|
91
|
-
}
|
|
92
|
-
type BirpcOptions<Remote> = EventOptions<Remote> & ChannelOptions;
|
|
93
|
-
type BirpcFn<T> = PromisifyFn<T> & {
|
|
94
|
-
/**
|
|
95
|
-
* Send event without asking for response
|
|
96
|
-
*/
|
|
97
|
-
asEvent: (...args: ArgumentsType<T>) => Promise<void>;
|
|
98
|
-
};
|
|
99
|
-
interface BirpcReturnBuiltin<RemoteFunctions, LocalFunctions = Record<string, never>> {
|
|
100
|
-
/**
|
|
101
|
-
* Raw functions object
|
|
102
|
-
*/
|
|
103
|
-
$functions: LocalFunctions;
|
|
104
|
-
/**
|
|
105
|
-
* Whether the RPC is closed
|
|
106
|
-
*/
|
|
107
|
-
readonly $closed: boolean;
|
|
108
|
-
/**
|
|
109
|
-
* Close the RPC connection
|
|
110
|
-
*/
|
|
111
|
-
$close: (error?: Error) => void;
|
|
112
|
-
/**
|
|
113
|
-
* Reject pending calls
|
|
114
|
-
*/
|
|
115
|
-
$rejectPendingCalls: (handler?: PendingCallHandler) => Promise<void>[];
|
|
116
|
-
/**
|
|
117
|
-
* Call the remote function and wait for the result.
|
|
118
|
-
* An alternative to directly calling the function
|
|
119
|
-
*/
|
|
120
|
-
$call: <K extends keyof RemoteFunctions>(method: K, ...args: ArgumentsType<RemoteFunctions[K]>) => Promise<Awaited<ReturnType<RemoteFunctions[K]>>>;
|
|
121
|
-
/**
|
|
122
|
-
* Same as `$call`, but returns `undefined` if the function is not defined on the remote side.
|
|
123
|
-
*/
|
|
124
|
-
$callOptional: <K extends keyof RemoteFunctions>(method: K, ...args: ArgumentsType<RemoteFunctions[K]>) => Promise<Awaited<ReturnType<RemoteFunctions[K]> | undefined>>;
|
|
125
|
-
/**
|
|
126
|
-
* Send event without asking for response
|
|
127
|
-
*/
|
|
128
|
-
$callEvent: <K extends keyof RemoteFunctions>(method: K, ...args: ArgumentsType<RemoteFunctions[K]>) => Promise<void>;
|
|
129
|
-
/**
|
|
130
|
-
* Call the remote function with the raw options.
|
|
131
|
-
*/
|
|
132
|
-
$callRaw: (options: {
|
|
133
|
-
method: string;
|
|
134
|
-
args: unknown[];
|
|
135
|
-
event?: boolean;
|
|
136
|
-
optional?: boolean;
|
|
137
|
-
}) => Promise<Awaited<ReturnType<any>>[]>;
|
|
138
|
-
}
|
|
139
|
-
type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
|
|
140
|
-
[K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
|
|
141
|
-
} & BirpcReturnBuiltin<RemoteFunctions, LocalFunctions>;
|
|
142
|
-
type PendingCallHandler = (options: Pick<PromiseEntry, 'method' | 'reject'>) => void | Promise<void>;
|
|
143
|
-
interface PromiseEntry {
|
|
144
|
-
resolve: (arg: any) => void;
|
|
145
|
-
reject: (error: any) => void;
|
|
146
|
-
method: string;
|
|
147
|
-
timeoutId?: ReturnType<typeof setTimeout>;
|
|
148
|
-
}
|
|
149
|
-
declare const TYPE_REQUEST: "q";
|
|
150
|
-
interface Request {
|
|
151
|
-
/**
|
|
152
|
-
* Type
|
|
153
|
-
*/
|
|
154
|
-
t: typeof TYPE_REQUEST;
|
|
155
|
-
/**
|
|
156
|
-
* ID
|
|
157
|
-
*/
|
|
158
|
-
i?: string;
|
|
159
|
-
/**
|
|
160
|
-
* Method
|
|
161
|
-
*/
|
|
162
|
-
m: string;
|
|
163
|
-
/**
|
|
164
|
-
* Arguments
|
|
165
|
-
*/
|
|
166
|
-
a: any[];
|
|
167
|
-
/**
|
|
168
|
-
* Optional
|
|
169
|
-
*/
|
|
170
|
-
o?: boolean;
|
|
171
|
-
}
|
|
172
|
-
declare const setTimeout: typeof globalThis.setTimeout;
|
|
173
|
-
|
|
174
|
-
type WorkerRPC = BirpcReturn<RuntimeRPC, RunnerRPC>;
|
|
175
|
-
interface ContextTestEnvironment {
|
|
176
|
-
name: string;
|
|
177
|
-
options: Record<string, any> | null;
|
|
178
|
-
}
|
|
179
|
-
interface WorkerTestEnvironment {
|
|
180
|
-
name: string;
|
|
181
|
-
options: Record<string, any> | null;
|
|
182
|
-
}
|
|
183
|
-
type TestExecutionMethod = "run" | "collect";
|
|
184
|
-
interface WorkerExecuteContext {
|
|
185
|
-
files: FileSpecification[];
|
|
186
|
-
providedContext: Record<string, any>;
|
|
187
|
-
invalidates?: string[];
|
|
188
|
-
/** Exposed to test runner as `VITEST_WORKER_ID`. Value is unique per each isolated worker. */
|
|
189
|
-
workerId: number;
|
|
190
|
-
}
|
|
191
|
-
interface ContextRPC {
|
|
192
|
-
pool: string;
|
|
193
|
-
config: SerializedConfig;
|
|
194
|
-
projectName: string;
|
|
195
|
-
environment: WorkerTestEnvironment;
|
|
196
|
-
rpc: WorkerRPC;
|
|
197
|
-
files: FileSpecification[];
|
|
198
|
-
providedContext: Record<string, any>;
|
|
199
|
-
invalidates?: string[];
|
|
200
|
-
/** Exposed to test runner as `VITEST_WORKER_ID`. Value is unique per each isolated worker. */
|
|
201
|
-
workerId: number;
|
|
202
|
-
}
|
|
203
|
-
interface WorkerSetupContext {
|
|
204
|
-
environment: WorkerTestEnvironment;
|
|
205
|
-
pool: string;
|
|
206
|
-
config: SerializedConfig;
|
|
207
|
-
projectName: string;
|
|
208
|
-
rpc: WorkerRPC;
|
|
209
|
-
}
|
|
210
|
-
interface WorkerGlobalState {
|
|
211
|
-
ctx: ContextRPC;
|
|
212
|
-
config: SerializedConfig;
|
|
213
|
-
rpc: WorkerRPC;
|
|
214
|
-
current?: Task;
|
|
215
|
-
filepath?: string;
|
|
216
|
-
metaEnv: {
|
|
217
|
-
[key: string]: any;
|
|
218
|
-
BASE_URL: string;
|
|
219
|
-
MODE: string;
|
|
220
|
-
DEV: boolean;
|
|
221
|
-
PROD: boolean;
|
|
222
|
-
SSR: boolean;
|
|
223
|
-
};
|
|
224
|
-
environment: Environment;
|
|
225
|
-
evaluatedModules: EvaluatedModules;
|
|
226
|
-
resolvingModules: Set<string>;
|
|
227
|
-
moduleExecutionInfo: Map<string, any>;
|
|
228
|
-
onCancel: (listener: (reason: CancelReason) => unknown) => void;
|
|
229
|
-
onCleanup: (listener: () => unknown) => void;
|
|
230
|
-
providedContext: Record<string, any>;
|
|
231
|
-
durations: {
|
|
232
|
-
environment: number;
|
|
233
|
-
prepare: number;
|
|
234
|
-
};
|
|
235
|
-
onFilterStackTrace?: (trace: string) => string;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
export type { BirpcOptions as B, ContextRPC as C, TestExecutionMethod as T, WorkerGlobalState as W, WorkerSetupContext as a, BirpcReturn as b, ContextTestEnvironment as c, WorkerExecuteContext as d, WorkerTestEnvironment as e };
|