vitest 0.9.2 → 0.10.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.
Files changed (30) hide show
  1. package/LICENSE.md +7 -0
  2. package/dist/{chunk-api-setup.7290422e.js → chunk-api-setup.d70fc960.js} +5 -5
  3. package/dist/{chunk-constants.e59013dc.js → chunk-constants.d540b1d1.js} +1 -1
  4. package/dist/{chunk-defaults.9aa0ce42.js → chunk-defaults.04d5d90b.js} +1 -1
  5. package/dist/{chunk-install-pkg.7dd40977.js → chunk-install-pkg.73b84ae1.js} +113 -115
  6. package/dist/chunk-integrations-globals.d2c09cd2.js +29 -0
  7. package/dist/chunk-integrations-spy.f036df6f.js +102 -0
  8. package/dist/{chunk-runtime-chain.94cf66a4.js → chunk-runtime-chain.f863f182.js} +934 -897
  9. package/dist/{chunk-runtime-mocker.7f4b1850.js → chunk-runtime-mocker.111ac858.js} +3 -3
  10. package/dist/{chunk-runtime-rpc.4b80b6bd.js → chunk-runtime-rpc.8f648236.js} +1 -1
  11. package/dist/{chunk-utils-global.10dcdfa6.js → chunk-utils-global.37a7c822.js} +8 -10
  12. package/dist/{chunk-utils-timers.4800834c.js → chunk-utils-timers.12bc05d1.js} +1404 -1057
  13. package/dist/{chunk-vite-node-externalize.ddf2a6fb.js → chunk-vite-node-externalize.5c678054.js} +1773 -4417
  14. package/dist/{chunk-vite-node-utils.7f0053fb.js → chunk-vite-node-utils.33447cc0.js} +71 -71
  15. package/dist/cli.js +13 -13
  16. package/dist/entry.js +15 -919
  17. package/dist/index.d.ts +92 -25
  18. package/dist/index.js +8 -8
  19. package/dist/node.d.ts +25 -7
  20. package/dist/node.js +12 -12
  21. package/dist/spy.js +2 -102
  22. package/dist/vendor-_commonjsHelpers.addc3445.js +3 -0
  23. package/dist/vendor-entry.369fd6c9.js +949 -0
  24. package/dist/vendor-index.405e58ef.js +6291 -0
  25. package/dist/{vendor-index.87b2fc14.js → vendor-index.40be925a.js} +167 -152
  26. package/dist/worker.js +6 -6
  27. package/package.json +11 -11
  28. package/dist/chunk-integrations-globals.c040aaa9.js +0 -23
  29. package/dist/vendor-_commonjsHelpers.34b404ce.js +0 -7
  30. package/dist/vendor-index.ee829ed6.js +0 -5707
@@ -1,7 +1,7 @@
1
1
  import { builtinModules, createRequire } from 'module';
2
2
  import { pathToFileURL, fileURLToPath as fileURLToPath$2, URL as URL$1 } from 'url';
3
3
  import vm from 'vm';
4
- import { l as isAbsolute$2, w as resolve, j as join$2, A as extname$2, k as dirname$2 } from './chunk-utils-global.10dcdfa6.js';
4
+ import { l as isAbsolute$2, k as resolve, j as join$2, A as extname$2, h as dirname$2 } from './chunk-utils-global.37a7c822.js';
5
5
  import path from 'path';
6
6
  import fs, { realpathSync, statSync, Stats, promises, existsSync } from 'fs';
7
7
  import assert from 'assert';
@@ -8875,76 +8875,6 @@ async function withInlineSourcemap(result) {
8875
8875
  return result;
8876
8876
  }
8877
8877
 
8878
- const DEFAULT_TIMEOUT = 6e4;
8879
- function createBirpc(functions, options) {
8880
- const {
8881
- post,
8882
- on,
8883
- eventNames = [],
8884
- serialize = (i) => i,
8885
- deserialize = (i) => i,
8886
- timeout = DEFAULT_TIMEOUT
8887
- } = options;
8888
- const rpcPromiseMap = /* @__PURE__ */ new Map();
8889
- const rpc = new Proxy({}, {
8890
- get(_, method) {
8891
- const sendEvent = (...args) => {
8892
- post(serialize({ m: method, a: args, t: "q" }));
8893
- };
8894
- if (eventNames.includes(method)) {
8895
- sendEvent.asEvent = sendEvent;
8896
- return sendEvent;
8897
- }
8898
- const sendCall = (...args) => {
8899
- return new Promise((resolve, reject) => {
8900
- const id = nanoid();
8901
- rpcPromiseMap.set(id, { resolve, reject });
8902
- post(serialize({ m: method, a: args, i: id, t: "q" }));
8903
- if (timeout >= 0) {
8904
- setTimeout(() => {
8905
- reject(new Error(`[birpc] timeout on calling "${method}"`));
8906
- rpcPromiseMap.delete(id);
8907
- }, timeout);
8908
- }
8909
- });
8910
- };
8911
- sendCall.asEvent = sendEvent;
8912
- return sendCall;
8913
- }
8914
- });
8915
- on(async (data, ...extra) => {
8916
- const msg = deserialize(data);
8917
- if (msg.t === "q") {
8918
- const { m: method, a: args } = msg;
8919
- let result, error;
8920
- try {
8921
- result = await functions[method].apply(rpc, args);
8922
- } catch (e) {
8923
- error = e;
8924
- }
8925
- if (msg.i)
8926
- post(serialize({ t: "s", i: msg.i, r: result, e: error }), ...extra);
8927
- } else {
8928
- const { i: ack, r: result, e: error } = msg;
8929
- const promise = rpcPromiseMap.get(ack);
8930
- if (error)
8931
- promise?.reject(error);
8932
- else
8933
- promise?.resolve(result);
8934
- rpcPromiseMap.delete(ack);
8935
- }
8936
- });
8937
- return rpc;
8938
- }
8939
- const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
8940
- function nanoid(size = 21) {
8941
- let id = "";
8942
- let i = size;
8943
- while (i--)
8944
- id += urlAlphabet[Math.random() * 64 | 0];
8945
- return id;
8946
- }
8947
-
8948
8878
  const DEFAULT_REQUEST_STUBS = {
8949
8879
  "/@vite/client": {
8950
8880
  injectQuery: (id) => id,
@@ -9149,4 +9079,74 @@ function exportAll(exports, sourceModule) {
9149
9079
  }
9150
9080
  }
9151
9081
 
9082
+ const DEFAULT_TIMEOUT = 6e4;
9083
+ function createBirpc(functions, options) {
9084
+ const {
9085
+ post,
9086
+ on,
9087
+ eventNames = [],
9088
+ serialize = (i) => i,
9089
+ deserialize = (i) => i,
9090
+ timeout = DEFAULT_TIMEOUT
9091
+ } = options;
9092
+ const rpcPromiseMap = /* @__PURE__ */ new Map();
9093
+ const rpc = new Proxy({}, {
9094
+ get(_, method) {
9095
+ const sendEvent = (...args) => {
9096
+ post(serialize({ m: method, a: args, t: "q" }));
9097
+ };
9098
+ if (eventNames.includes(method)) {
9099
+ sendEvent.asEvent = sendEvent;
9100
+ return sendEvent;
9101
+ }
9102
+ const sendCall = (...args) => {
9103
+ return new Promise((resolve, reject) => {
9104
+ const id = nanoid();
9105
+ rpcPromiseMap.set(id, { resolve, reject });
9106
+ post(serialize({ m: method, a: args, i: id, t: "q" }));
9107
+ if (timeout >= 0) {
9108
+ setTimeout(() => {
9109
+ reject(new Error(`[birpc] timeout on calling "${method}"`));
9110
+ rpcPromiseMap.delete(id);
9111
+ }, timeout);
9112
+ }
9113
+ });
9114
+ };
9115
+ sendCall.asEvent = sendEvent;
9116
+ return sendCall;
9117
+ }
9118
+ });
9119
+ on(async (data, ...extra) => {
9120
+ const msg = deserialize(data);
9121
+ if (msg.t === "q") {
9122
+ const { m: method, a: args } = msg;
9123
+ let result, error;
9124
+ try {
9125
+ result = await functions[method].apply(rpc, args);
9126
+ } catch (e) {
9127
+ error = e;
9128
+ }
9129
+ if (msg.i)
9130
+ post(serialize({ t: "s", i: msg.i, r: result, e: error }), ...extra);
9131
+ } else {
9132
+ const { i: ack, r: result, e: error } = msg;
9133
+ const promise = rpcPromiseMap.get(ack);
9134
+ if (error)
9135
+ promise?.reject(error);
9136
+ else
9137
+ promise?.resolve(result);
9138
+ rpcPromiseMap.delete(ack);
9139
+ }
9140
+ });
9141
+ return rpc;
9142
+ }
9143
+ const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
9144
+ function nanoid(size = 21) {
9145
+ let id = "";
9146
+ let i = size;
9147
+ while (i--)
9148
+ id += urlAlphabet[Math.random() * 64 | 0];
9149
+ return id;
9150
+ }
9151
+
9152
9152
  export { ModuleCacheMap as M, ViteNodeRunner as V, isValidNodeImport as a, createBirpc as c, isNodeBuiltin as i, normalizeRequestId as n, slash as s, toFilePath as t, withInlineSourcemap as w };
package/dist/cli.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { EventEmitter } from 'events';
2
- import { e as c } from './chunk-utils-global.10dcdfa6.js';
3
- import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.ddf2a6fb.js';
4
- import 'path';
2
+ import { p as picocolors } from './chunk-utils-global.37a7c822.js';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.5c678054.js';
5
4
  import 'tty';
6
5
  import 'local-pkg';
6
+ import 'path';
7
7
  import 'buffer';
8
8
  import 'child_process';
9
9
  import 'process';
10
- import './vendor-index.87b2fc14.js';
11
- import './vendor-_commonjsHelpers.34b404ce.js';
10
+ import './vendor-index.40be925a.js';
11
+ import './vendor-_commonjsHelpers.addc3445.js';
12
12
  import 'fs';
13
13
  import 'assert';
14
14
  import 'stream';
@@ -16,18 +16,18 @@ import 'util';
16
16
  import 'url';
17
17
  import 'os';
18
18
  import 'vite';
19
- import './chunk-constants.e59013dc.js';
20
- import './chunk-vite-node-utils.7f0053fb.js';
19
+ import './chunk-constants.d540b1d1.js';
20
+ import 'readline';
21
+ import './chunk-vite-node-utils.33447cc0.js';
21
22
  import 'module';
22
23
  import 'vm';
23
- import './chunk-defaults.9aa0ce42.js';
24
- import 'perf_hooks';
25
- import './chunk-utils-timers.4800834c.js';
24
+ import './chunk-defaults.04d5d90b.js';
26
25
  import 'worker_threads';
27
26
  import 'tinypool';
27
+ import 'perf_hooks';
28
+ import './chunk-utils-timers.12bc05d1.js';
28
29
  import './chunk-magic-string.d5e0e473.js';
29
- import 'readline';
30
- import './vendor-index.ee829ed6.js';
30
+ import './vendor-index.405e58ef.js';
31
31
 
32
32
  function toArr(any) {
33
33
  return any == null ? [] : Array.isArray(any) ? any : [any];
@@ -666,7 +666,7 @@ async function start(cliFilters, options) {
666
666
  } catch (e) {
667
667
  process.exitCode = 1;
668
668
  console.error(`
669
- ${c.red(divider(c.bold(c.inverse(" Unhandled Error "))))}`);
669
+ ${picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(" Unhandled Error "))))}`);
670
670
  console.error(e);
671
671
  console.error("\n\n");
672
672
  }