@vitest/browser 0.34.6 → 1.0.0-beta.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.
@@ -17,7 +17,7 @@
17
17
  })()
18
18
  </script>
19
19
  <!-- !LOAD_METADATA! -->
20
- <script type="module" crossorigin src="./assets/index-cb1927be.js"></script>
20
+ <script type="module" crossorigin src="./assets/index-8d09873f.js"></script>
21
21
  <link rel="stylesheet" href="./assets/index-528f947f.css">
22
22
  </head>
23
23
  <body>
@@ -101,7 +101,7 @@ function defaultSerialize(i) {
101
101
  return i;
102
102
  }
103
103
  const defaultDeserialize = defaultSerialize;
104
- const { setTimeout: setTimeout$1 } = globalThis;
104
+ const { clearTimeout, setTimeout: setTimeout$1 } = globalThis;
105
105
  const random = Math.random.bind(Math);
106
106
  function createBirpc(functions, options) {
107
107
  const {
@@ -129,15 +129,17 @@ function createBirpc(functions, options) {
129
129
  const sendCall = async (...args) => {
130
130
  await _promise;
131
131
  return new Promise((resolve2, reject) => {
132
+ var _a, _b;
132
133
  const id = nanoid();
133
- rpcPromiseMap.set(id, { resolve: resolve2, reject });
134
- post(serialize({ m: method, a: args, i: id, t: "q" }));
134
+ let timeoutId;
135
135
  if (timeout >= 0) {
136
- setTimeout$1(() => {
136
+ timeoutId = (_b = (_a = setTimeout$1(() => {
137
137
  reject(new Error(`[birpc] timeout on calling "${method}"`));
138
138
  rpcPromiseMap.delete(id);
139
- }, timeout);
139
+ }, timeout)).unref) == null ? void 0 : _b.call(_a);
140
140
  }
141
+ rpcPromiseMap.set(id, { resolve: resolve2, reject, timeoutId });
142
+ post(serialize({ m: method, a: args, i: id, t: "q" }));
141
143
  });
142
144
  };
143
145
  sendCall.asEvent = sendEvent;
@@ -168,6 +170,7 @@ function createBirpc(functions, options) {
168
170
  const { i: ack, r: result, e: error } = msg;
169
171
  const promise = rpcPromiseMap.get(ack);
170
172
  if (promise) {
173
+ clearTimeout(promise.timeoutId);
171
174
  if (error)
172
175
  promise.reject(error);
173
176
  else
@@ -597,7 +600,7 @@ function createClient(url2, options = {}) {
597
600
  const { get } = Reflect;
598
601
  function withSafeTimers(getTimers, fn) {
599
602
  var _a;
600
- const { setTimeout: setTimeout2, clearTimeout, nextTick, setImmediate, clearImmediate } = getTimers();
603
+ const { setTimeout: setTimeout2, clearTimeout: clearTimeout2, nextTick, setImmediate, clearImmediate } = getTimers();
601
604
  const currentSetTimeout = globalThis.setTimeout;
602
605
  const currentClearTimeout = globalThis.clearTimeout;
603
606
  const currentSetImmediate = globalThis.setImmediate;
@@ -605,7 +608,7 @@ function withSafeTimers(getTimers, fn) {
605
608
  const currentNextTick = (_a = globalThis.process) == null ? void 0 : _a.nextTick;
606
609
  try {
607
610
  globalThis.setTimeout = setTimeout2;
608
- globalThis.clearTimeout = clearTimeout;
611
+ globalThis.clearTimeout = clearTimeout2;
609
612
  globalThis.setImmediate = setImmediate;
610
613
  globalThis.clearImmediate = clearImmediate;
611
614
  if (globalThis.process)
@@ -661,7 +664,7 @@ function createBrowserRunner(original, coverageModule) {
661
664
  this.config = options.config;
662
665
  this.hashMap = options.browserHashMap;
663
666
  }
664
- async onAfterRunTest(task) {
667
+ async onAfterRunTask(task) {
665
668
  var _a, _b, _c, _d, _e;
666
669
  await ((_a = super.onAfterRunTest) == null ? void 0 : _a.call(this, task));
667
670
  (_c = (_b = task.result) == null ? void 0 : _b.errors) == null ? void 0 : _c.forEach((error) => {
@@ -676,7 +679,7 @@ function createBrowserRunner(original, coverageModule) {
676
679
  }
677
680
  }
678
681
  }
679
- async onAfterRun() {
682
+ async onAfterRunFiles() {
680
683
  var _a, _b;
681
684
  await ((_a = super.onAfterRun) == null ? void 0 : _a.call(this));
682
685
  const coverage = await ((_b = coverageModule == null ? void 0 : coverageModule.takeCoverage) == null ? void 0 : _b.call(coverageModule));
@@ -21,7 +21,7 @@
21
21
  border: none;
22
22
  }
23
23
  </style>
24
- <script type="module" crossorigin src="/__vitest_browser__/index-7107c1a2.js"></script>
24
+ <script type="module" crossorigin src="/__vitest_browser__/index-b263a587.js"></script>
25
25
  </head>
26
26
  <body>
27
27
  <iframe id="vitest-ui" src=""></iframe>
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { fileURLToPath } from 'url';
2
2
  import { resolve } from 'path';
3
3
  import { builtinModules } from 'module';
4
- import { polyfillPath } from 'modern-node-polyfills';
5
4
  import sirv from 'sirv';
6
5
  import MagicString from 'magic-string';
7
6
  import { walk } from 'estree-walker';
@@ -435,9 +434,6 @@ export { ${viInjectedKey} }`);
435
434
  };
436
435
  }
437
436
 
438
- const polyfills = [
439
- "util"
440
- ];
441
437
  var index = (project, base = "/") => {
442
438
  const pkgRoot = resolve(fileURLToPath(import.meta.url), "../..");
443
439
  const distRoot = resolve(pkgRoot, "dist");
@@ -461,13 +457,12 @@ var index = (project, base = "/") => {
461
457
  }
462
458
  },
463
459
  {
464
- name: "modern-node-polyfills",
460
+ name: "vitest:browser:tests",
465
461
  enforce: "pre",
466
462
  config() {
467
463
  return {
468
464
  optimizeDeps: {
469
465
  exclude: [
470
- ...polyfills,
471
466
  ...builtinModules,
472
467
  "vitest",
473
468
  "vitest/utils",
@@ -488,18 +483,14 @@ var index = (project, base = "/") => {
488
483
  };
489
484
  },
490
485
  async resolveId(id) {
491
- if (!builtinModules.includes(id) && !polyfills.includes(id) && !id.startsWith("node:")) {
492
- if (!/\?browserv=\w+$/.test(id))
493
- return;
494
- let useId = id.slice(0, id.lastIndexOf("?"));
495
- if (useId.startsWith("/@fs/"))
496
- useId = useId.slice(5);
497
- if (/^\w:/.test(useId))
498
- useId = useId.replace(/\\/g, "/");
499
- return useId;
500
- }
501
- id = normalizeId(id);
502
- return { id: await polyfillPath(id), moduleSideEffects: false };
486
+ if (!/\?browserv=\w+$/.test(id))
487
+ return;
488
+ let useId = id.slice(0, id.lastIndexOf("?"));
489
+ if (useId.startsWith("/@fs/"))
490
+ useId = useId.slice(5);
491
+ if (/^\w:/.test(useId))
492
+ useId = useId.replace(/\\/g, "/");
493
+ return useId;
503
494
  }
504
495
  },
505
496
  {
@@ -514,10 +505,5 @@ var index = (project, base = "/") => {
514
505
  }
515
506
  ];
516
507
  };
517
- function normalizeId(id, base) {
518
- if (base && id.startsWith(base))
519
- id = `/${id.slice(base.length)}`;
520
- return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/^node:/, "").replace(/[?&]v=\w+/, "?").replace(/\?$/, "");
521
- }
522
508
 
523
509
  export { index as default };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/browser",
3
3
  "type": "module",
4
- "version": "0.34.6",
4
+ "version": "1.0.0-beta.0",
5
5
  "description": "Browser running for Vitest",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -35,17 +35,16 @@
35
35
  "dependencies": {
36
36
  "estree-walker": "^3.0.3",
37
37
  "magic-string": "^0.30.1",
38
- "modern-node-polyfills": "^1.0.0",
39
38
  "sirv": "^2.0.3"
40
39
  },
41
40
  "devDependencies": {
42
41
  "@types/estree": "^1.0.1",
43
42
  "@types/ws": "^8.5.5",
44
43
  "periscopic": "^3.1.0",
45
- "@vitest/runner": "0.34.6",
46
- "@vitest/ws-client": "0.34.6",
47
- "vitest": "0.34.6",
48
- "@vitest/ui": "0.34.6"
44
+ "vitest": "1.0.0-beta.0",
45
+ "@vitest/ws-client": "1.0.0-beta.0",
46
+ "@vitest/runner": "1.0.0-beta.0",
47
+ "@vitest/ui": "1.0.0-beta.0"
49
48
  },
50
49
  "scripts": {
51
50
  "build": "rimraf dist && pnpm build:node && pnpm build:client",