@vitest/browser 0.31.0 → 0.31.2
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/client/__vitest__/assets/{index-412667a2.css → index-8c3757f8.css} +1 -1
- package/dist/client/__vitest__/assets/index-ee3ae6f1.js +43 -0
- package/dist/client/__vitest__/index.html +2 -2
- package/dist/client/assets/{index-5fc20d62.js → index-0eaf4198.js} +47 -19
- package/dist/client/index.html +1 -1
- package/dist/index.js +3 -7
- package/package.json +7 -7
- package/dist/client/__vitest__/assets/index-ee62cb59.js +0 -43
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
})()
|
|
18
18
|
</script>
|
|
19
19
|
<!-- !LOAD_METADATA! -->
|
|
20
|
-
<script type="module" crossorigin src="./assets/index-
|
|
21
|
-
<link rel="stylesheet" href="./assets/index-
|
|
20
|
+
<script type="module" crossorigin src="./assets/index-ee3ae6f1.js"></script>
|
|
21
|
+
<link rel="stylesheet" href="./assets/index-8c3757f8.css">
|
|
22
22
|
</head>
|
|
23
23
|
<body>
|
|
24
24
|
<div id="app"></div>
|
|
@@ -90,18 +90,28 @@ const __vitePreload = function preload(baseModule, deps, importerUrl) {
|
|
|
90
90
|
})).then(() => baseModule());
|
|
91
91
|
};
|
|
92
92
|
const DEFAULT_TIMEOUT = 6e4;
|
|
93
|
+
function defaultSerialize(i) {
|
|
94
|
+
return i;
|
|
95
|
+
}
|
|
96
|
+
const defaultDeserialize = defaultSerialize;
|
|
97
|
+
const { setTimeout: setTimeout$1 } = globalThis;
|
|
98
|
+
const random = Math.random.bind(Math);
|
|
93
99
|
function createBirpc(functions, options) {
|
|
94
100
|
const {
|
|
95
101
|
post,
|
|
96
102
|
on,
|
|
97
103
|
eventNames = [],
|
|
98
|
-
serialize =
|
|
99
|
-
deserialize =
|
|
104
|
+
serialize = defaultSerialize,
|
|
105
|
+
deserialize = defaultDeserialize,
|
|
106
|
+
resolver,
|
|
100
107
|
timeout = DEFAULT_TIMEOUT
|
|
101
108
|
} = options;
|
|
102
109
|
const rpcPromiseMap = /* @__PURE__ */ new Map();
|
|
110
|
+
let _promise;
|
|
103
111
|
const rpc2 = new Proxy({}, {
|
|
104
112
|
get(_, method) {
|
|
113
|
+
if (method === "$functions")
|
|
114
|
+
return functions;
|
|
105
115
|
const sendEvent = (...args) => {
|
|
106
116
|
post(serialize({ m: method, a: args, t: "q" }));
|
|
107
117
|
};
|
|
@@ -109,13 +119,14 @@ function createBirpc(functions, options) {
|
|
|
109
119
|
sendEvent.asEvent = sendEvent;
|
|
110
120
|
return sendEvent;
|
|
111
121
|
}
|
|
112
|
-
const sendCall = (...args) => {
|
|
122
|
+
const sendCall = async (...args) => {
|
|
123
|
+
await _promise;
|
|
113
124
|
return new Promise((resolve2, reject) => {
|
|
114
125
|
const id = nanoid();
|
|
115
126
|
rpcPromiseMap.set(id, { resolve: resolve2, reject });
|
|
116
127
|
post(serialize({ m: method, a: args, i: id, t: "q" }));
|
|
117
128
|
if (timeout >= 0) {
|
|
118
|
-
setTimeout(() => {
|
|
129
|
+
setTimeout$1(() => {
|
|
119
130
|
reject(new Error(`[birpc] timeout on calling "${method}"`));
|
|
120
131
|
rpcPromiseMap.delete(id);
|
|
121
132
|
}, timeout);
|
|
@@ -126,25 +137,35 @@ function createBirpc(functions, options) {
|
|
|
126
137
|
return sendCall;
|
|
127
138
|
}
|
|
128
139
|
});
|
|
129
|
-
on(async (data, ...extra) => {
|
|
140
|
+
_promise = on(async (data, ...extra) => {
|
|
130
141
|
const msg = deserialize(data);
|
|
131
142
|
if (msg.t === "q") {
|
|
132
143
|
const { m: method, a: args } = msg;
|
|
133
144
|
let result, error;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
145
|
+
const fn = resolver ? resolver(method, functions[method]) : functions[method];
|
|
146
|
+
if (!fn) {
|
|
147
|
+
error = new Error(`[birpc] function "${method}" not found`);
|
|
148
|
+
} else {
|
|
149
|
+
try {
|
|
150
|
+
result = await fn.apply(rpc2, args);
|
|
151
|
+
} catch (e) {
|
|
152
|
+
error = e;
|
|
153
|
+
}
|
|
138
154
|
}
|
|
139
|
-
if (msg.i)
|
|
155
|
+
if (msg.i) {
|
|
156
|
+
if (error && options.onError)
|
|
157
|
+
options.onError(error, method, args);
|
|
140
158
|
post(serialize({ t: "s", i: msg.i, r: result, e: error }), ...extra);
|
|
159
|
+
}
|
|
141
160
|
} else {
|
|
142
161
|
const { i: ack, r: result, e: error } = msg;
|
|
143
162
|
const promise = rpcPromiseMap.get(ack);
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
163
|
+
if (promise) {
|
|
164
|
+
if (error)
|
|
165
|
+
promise.reject(error);
|
|
166
|
+
else
|
|
167
|
+
promise.resolve(result);
|
|
168
|
+
}
|
|
148
169
|
rpcPromiseMap.delete(ack);
|
|
149
170
|
}
|
|
150
171
|
});
|
|
@@ -155,7 +176,7 @@ function nanoid(size = 21) {
|
|
|
155
176
|
let id = "";
|
|
156
177
|
let i = size;
|
|
157
178
|
while (i--)
|
|
158
|
-
id += urlAlphabet[
|
|
179
|
+
id += urlAlphabet[random() * 64 | 0];
|
|
159
180
|
return id;
|
|
160
181
|
}
|
|
161
182
|
/*! (c) 2020 Andrea Giammarchi */
|
|
@@ -357,7 +378,10 @@ class StateManager {
|
|
|
357
378
|
catchError(err, type) {
|
|
358
379
|
if (isAggregateError(err))
|
|
359
380
|
return err.errors.forEach((error) => this.catchError(error, type));
|
|
360
|
-
err
|
|
381
|
+
if (err === Object(err))
|
|
382
|
+
err.type = type;
|
|
383
|
+
else
|
|
384
|
+
err = { type, message: err };
|
|
361
385
|
this.errorsSet.add(err);
|
|
362
386
|
}
|
|
363
387
|
clearErrors() {
|
|
@@ -426,9 +450,12 @@ class StateManager {
|
|
|
426
450
|
}
|
|
427
451
|
}
|
|
428
452
|
updateTasks(packs) {
|
|
429
|
-
for (const [id, result] of packs) {
|
|
430
|
-
|
|
431
|
-
|
|
453
|
+
for (const [id, result, meta] of packs) {
|
|
454
|
+
const task = this.idMap.get(id);
|
|
455
|
+
if (task) {
|
|
456
|
+
task.result = result;
|
|
457
|
+
task.meta = meta;
|
|
458
|
+
}
|
|
432
459
|
}
|
|
433
460
|
}
|
|
434
461
|
updateUserLog(log) {
|
|
@@ -455,6 +482,7 @@ class StateManager {
|
|
|
455
482
|
result: {
|
|
456
483
|
state: "skip"
|
|
457
484
|
},
|
|
485
|
+
meta: {},
|
|
458
486
|
// Cancelled files have not yet collected tests
|
|
459
487
|
tasks: []
|
|
460
488
|
})));
|
package/dist/client/index.html
CHANGED
package/dist/index.js
CHANGED
|
@@ -1705,7 +1705,7 @@ const skipHijack = [
|
|
|
1705
1705
|
"/@vite/env",
|
|
1706
1706
|
/vite\/dist\/client/
|
|
1707
1707
|
];
|
|
1708
|
-
function injectVitestModule(code, id, parse
|
|
1708
|
+
function injectVitestModule(code, id, parse) {
|
|
1709
1709
|
if (skipHijack.some((skip) => id.match(skip)))
|
|
1710
1710
|
return;
|
|
1711
1711
|
const s = new MagicString(code);
|
|
@@ -1835,11 +1835,9 @@ Object.defineProperty(${viInjectedKey}, "default", { enumerable: true, configura
|
|
|
1835
1835
|
node.start + 14,
|
|
1836
1836
|
`${viInjectedKey}.default =`
|
|
1837
1837
|
);
|
|
1838
|
-
|
|
1839
|
-
s.append(`
|
|
1838
|
+
s.append(`
|
|
1840
1839
|
export default { ${viInjectedKey}: ${viInjectedKey}.default };
|
|
1841
1840
|
`);
|
|
1842
|
-
}
|
|
1843
1841
|
}
|
|
1844
1842
|
}
|
|
1845
1843
|
if (node.type === "ExportAllDeclaration") {
|
|
@@ -1967,9 +1965,7 @@ var index = (project, base = "/") => {
|
|
|
1967
1965
|
const hijackESM = project.config.browser.slowHijackESM ?? false;
|
|
1968
1966
|
if (!hijackESM)
|
|
1969
1967
|
return;
|
|
1970
|
-
return injectVitestModule(source, id, this.parse
|
|
1971
|
-
cacheDir: project.server.config.cacheDir
|
|
1972
|
-
});
|
|
1968
|
+
return injectVitestModule(source, id, this.parse);
|
|
1973
1969
|
}
|
|
1974
1970
|
}
|
|
1975
1971
|
];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/browser",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.31.
|
|
4
|
+
"version": "0.31.2",
|
|
5
5
|
"description": "Browser running for Vitest",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"vitest": ">=0.31.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"modern-node-polyfills": "^0.1.
|
|
37
|
-
"sirv": "^2.0.
|
|
36
|
+
"modern-node-polyfills": "^0.1.3",
|
|
37
|
+
"sirv": "^2.0.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/estree": "^1.0.1",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"estree-walker": "^3.0.3",
|
|
43
43
|
"periscopic": "^3.1.0",
|
|
44
44
|
"rollup": "3.20.2",
|
|
45
|
-
"@vitest/runner": "0.31.
|
|
46
|
-
"@vitest/ui": "0.31.
|
|
47
|
-
"@vitest/ws-client": "0.31.
|
|
48
|
-
"vitest": "0.31.
|
|
45
|
+
"@vitest/runner": "0.31.2",
|
|
46
|
+
"@vitest/ui": "0.31.2",
|
|
47
|
+
"@vitest/ws-client": "0.31.2",
|
|
48
|
+
"vitest": "0.31.2"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "rimraf dist && pnpm build:node && pnpm build:client",
|