vitest 0.9.4 → 0.10.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.
Files changed (31) hide show
  1. package/LICENSE.md +7 -0
  2. package/dist/{chunk-api-setup.49283db8.js → chunk-api-setup.b55307fb.js} +41 -18
  3. package/dist/{chunk-constants.c8f1d38c.js → chunk-constants.90075174.js} +1 -1
  4. package/dist/{chunk-defaults.43e746f3.js → chunk-defaults.fd5b939d.js} +1 -1
  5. package/dist/{chunk-install-pkg.cbf3a38b.js → chunk-install-pkg.73b84ae1.js} +113 -115
  6. package/dist/chunk-integrations-globals.16d9702f.js +29 -0
  7. package/dist/chunk-integrations-spy.f036df6f.js +102 -0
  8. package/dist/{chunk-runtime-chain.701cffd8.js → chunk-runtime-chain.6292a3de.js} +941 -901
  9. package/dist/{chunk-runtime-mocker.e802beae.js → chunk-runtime-mocker.ca5ecf98.js} +5 -21
  10. package/dist/{chunk-runtime-rpc.c47f2233.js → chunk-runtime-rpc.8e14ae4f.js} +1 -1
  11. package/dist/{chunk-utils-global.a3293dce.js → chunk-utils-global.9b434e81.js} +42 -10
  12. package/dist/{chunk-utils-timers.b26e7c5c.js → chunk-utils-timers.c50fec92.js} +1406 -1057
  13. package/dist/{chunk-vite-node-externalize.1c19fc5e.js → chunk-vite-node-externalize.4255f25f.js} +661 -548
  14. package/dist/{chunk-vite-node-utils.b4debb0b.js → chunk-vite-node-utils.c160b239.js} +73 -71
  15. package/dist/cli.js +12 -12
  16. package/dist/entry.js +15 -919
  17. package/dist/index.d.ts +112 -31
  18. package/dist/index.js +8 -8
  19. package/dist/node.d.ts +40 -12
  20. package/dist/node.js +11 -11
  21. package/dist/spy.js +2 -102
  22. package/dist/vendor-_commonjsHelpers.addc3445.js +3 -0
  23. package/dist/vendor-entry.17835032.js +991 -0
  24. package/dist/vendor-index.405e58ef.js +6291 -0
  25. package/dist/{vendor-index.bd255bc8.js → vendor-index.40be925a.js} +173 -158
  26. package/dist/worker.js +9 -6
  27. package/package.json +9 -10
  28. package/vitest.mjs +1 -1
  29. package/dist/chunk-integrations-globals.b4a20711.js +0 -23
  30. package/dist/vendor-_commonjsHelpers.34b404ce.js +0 -7
  31. package/dist/vendor-index.13468339.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.a3293dce.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.9b434e81.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,
@@ -9133,6 +9063,8 @@ function proxyMethod(name, tryDefault) {
9133
9063
  };
9134
9064
  }
9135
9065
  function exportAll(exports, sourceModule) {
9066
+ if (exports === sourceModule)
9067
+ return;
9136
9068
  for (const key in sourceModule) {
9137
9069
  if (key !== "default") {
9138
9070
  try {
@@ -9149,4 +9081,74 @@ function exportAll(exports, sourceModule) {
9149
9081
  }
9150
9082
  }
9151
9083
 
9084
+ const DEFAULT_TIMEOUT = 6e4;
9085
+ function createBirpc(functions, options) {
9086
+ const {
9087
+ post,
9088
+ on,
9089
+ eventNames = [],
9090
+ serialize = (i) => i,
9091
+ deserialize = (i) => i,
9092
+ timeout = DEFAULT_TIMEOUT
9093
+ } = options;
9094
+ const rpcPromiseMap = /* @__PURE__ */ new Map();
9095
+ const rpc = new Proxy({}, {
9096
+ get(_, method) {
9097
+ const sendEvent = (...args) => {
9098
+ post(serialize({ m: method, a: args, t: "q" }));
9099
+ };
9100
+ if (eventNames.includes(method)) {
9101
+ sendEvent.asEvent = sendEvent;
9102
+ return sendEvent;
9103
+ }
9104
+ const sendCall = (...args) => {
9105
+ return new Promise((resolve, reject) => {
9106
+ const id = nanoid();
9107
+ rpcPromiseMap.set(id, { resolve, reject });
9108
+ post(serialize({ m: method, a: args, i: id, t: "q" }));
9109
+ if (timeout >= 0) {
9110
+ setTimeout(() => {
9111
+ reject(new Error(`[birpc] timeout on calling "${method}"`));
9112
+ rpcPromiseMap.delete(id);
9113
+ }, timeout);
9114
+ }
9115
+ });
9116
+ };
9117
+ sendCall.asEvent = sendEvent;
9118
+ return sendCall;
9119
+ }
9120
+ });
9121
+ on(async (data, ...extra) => {
9122
+ const msg = deserialize(data);
9123
+ if (msg.t === "q") {
9124
+ const { m: method, a: args } = msg;
9125
+ let result, error;
9126
+ try {
9127
+ result = await functions[method].apply(rpc, args);
9128
+ } catch (e) {
9129
+ error = e;
9130
+ }
9131
+ if (msg.i)
9132
+ post(serialize({ t: "s", i: msg.i, r: result, e: error }), ...extra);
9133
+ } else {
9134
+ const { i: ack, r: result, e: error } = msg;
9135
+ const promise = rpcPromiseMap.get(ack);
9136
+ if (error)
9137
+ promise?.reject(error);
9138
+ else
9139
+ promise?.resolve(result);
9140
+ rpcPromiseMap.delete(ack);
9141
+ }
9142
+ });
9143
+ return rpc;
9144
+ }
9145
+ const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
9146
+ function nanoid(size = 21) {
9147
+ let id = "";
9148
+ let i = size;
9149
+ while (i--)
9150
+ id += urlAlphabet[Math.random() * 64 | 0];
9151
+ return id;
9152
+ }
9153
+
9152
9154
  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.a3293dce.js';
3
- import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.1c19fc5e.js';
4
- import 'path';
2
+ import { p as picocolors } from './chunk-utils-global.9b434e81.js';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.4255f25f.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.bd255bc8.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.c8f1d38c.js';
19
+ import './chunk-constants.90075174.js';
20
20
  import 'readline';
21
- import './chunk-vite-node-utils.b4debb0b.js';
21
+ import './chunk-vite-node-utils.c160b239.js';
22
22
  import 'module';
23
23
  import 'vm';
24
- import './chunk-defaults.43e746f3.js';
25
- import 'perf_hooks';
26
- import './chunk-utils-timers.b26e7c5c.js';
24
+ import './chunk-defaults.fd5b939d.js';
27
25
  import 'worker_threads';
28
26
  import 'tinypool';
27
+ import 'perf_hooks';
28
+ import './chunk-utils-timers.c50fec92.js';
29
29
  import './chunk-magic-string.d5e0e473.js';
30
- import './vendor-index.13468339.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
  }