vitest 1.0.0-beta.2 → 1.0.0-beta.3
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/LICENSE.md +0 -29
- package/dist/browser.d.ts +1 -1
- package/dist/child.js +9 -4
- package/dist/{chunk-api-setup.5d9a93c7.js → chunk-api-setup.37a43981.js} +0 -2
- package/dist/{chunk-install-pkg.43d58972.js → chunk-install-pkg.6349b322.js} +10 -12
- package/dist/{chunk-node-git.2f1df48f.js → chunk-node-git.6c12e560.js} +1 -1
- package/dist/cli-wrapper.js +1 -1
- package/dist/cli.js +11 -18
- package/dist/config.d.ts +2 -2
- package/dist/coverage.d.ts +1 -1
- package/dist/coverage.js +2 -2
- package/dist/entry-vm.js +1 -1
- package/dist/entry.js +1 -1
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -13
- package/dist/execute.d.ts +1 -1
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/node.d.ts +5 -3
- package/dist/node.js +14 -16
- package/dist/{reporters-d10f25e1.d.ts → reporters-1678fe04.d.ts} +62 -30
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +1 -1
- package/dist/runners.d.ts +3 -2
- package/dist/runners.js +32 -35
- package/dist/{suite-919dd548.d.ts → suite-0579b50d.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/{vendor-environments.094f240c.js → vendor-environments.dcc4a34e.js} +4 -37
- package/dist/{vendor-execute.07d1a420.js → vendor-execute.e6e4e89b.js} +1 -0
- package/dist/{vendor-index.d36f5516.js → vendor-index.3d079eea.js} +6 -1
- package/dist/{vendor-index.e006069f.js → vendor-index.8efe7746.js} +371 -371
- package/dist/{vendor-index.0b5b3600.js → vendor-loader.9c966f23.js} +36 -9
- package/dist/{vendor-node.e5a35bfe.js → vendor-node.327f8f1f.js} +1928 -1953
- package/dist/{vendor-reporters.2953082e.js → vendor-reporters.b9600369.js} +40 -23
- package/dist/vm.js +9 -4
- package/dist/worker.js +9 -4
- package/package.json +11 -27
- package/dist/loader.js +0 -100
- package/dist/vendor-index.98139333.js +0 -129
|
@@ -229,6 +229,7 @@ class BaseReporter {
|
|
|
229
229
|
_lastRunTimer;
|
|
230
230
|
_lastRunCount = 0;
|
|
231
231
|
_timeStart = /* @__PURE__ */ new Date();
|
|
232
|
+
_offUnhandledRejection;
|
|
232
233
|
constructor() {
|
|
233
234
|
this.registerUnhandledRejection();
|
|
234
235
|
}
|
|
@@ -237,6 +238,10 @@ class BaseReporter {
|
|
|
237
238
|
}
|
|
238
239
|
onInit(ctx) {
|
|
239
240
|
this.ctx = ctx;
|
|
241
|
+
ctx.onClose(() => {
|
|
242
|
+
var _a2;
|
|
243
|
+
(_a2 = this._offUnhandledRejection) == null ? void 0 : _a2.call(this);
|
|
244
|
+
});
|
|
240
245
|
ctx.logger.printBanner();
|
|
241
246
|
this.start = performance.now();
|
|
242
247
|
}
|
|
@@ -303,8 +308,7 @@ class BaseReporter {
|
|
|
303
308
|
else
|
|
304
309
|
this.ctx.logger.log(WAIT_FOR_CHANGE_PASS);
|
|
305
310
|
const hints = [];
|
|
306
|
-
|
|
307
|
-
hints.push(HELP_HINT);
|
|
311
|
+
hints.push(HELP_HINT);
|
|
308
312
|
if (failedSnap)
|
|
309
313
|
hints.unshift(HELP_UPDATE_SNAP);
|
|
310
314
|
else
|
|
@@ -426,7 +430,7 @@ ${log.content}
|
|
|
426
430
|
}
|
|
427
431
|
logger.log(padTitle("Test Files"), getStateString(files));
|
|
428
432
|
logger.log(padTitle("Tests"), getStateString(tests));
|
|
429
|
-
if (this.
|
|
433
|
+
if (this.ctx.projects.some((c2) => c2.config.typecheck.enabled)) {
|
|
430
434
|
const failed = tests.filter((t) => {
|
|
431
435
|
var _a2, _b, _c;
|
|
432
436
|
return ((_a2 = t.meta) == null ? void 0 : _a2.typecheck) && ((_c = (_b = t.result) == null ? void 0 : _b.errors) == null ? void 0 : _c.length);
|
|
@@ -436,12 +440,18 @@ ${log.content}
|
|
|
436
440
|
if (errors.length)
|
|
437
441
|
logger.log(padTitle("Errors"), c.bold(c.red(`${errors.length} error${errors.length > 1 ? "s" : ""}`)));
|
|
438
442
|
logger.log(padTitle("Start at"), formatTimeString(this._timeStart));
|
|
439
|
-
if (this.watchFilters)
|
|
443
|
+
if (this.watchFilters) {
|
|
440
444
|
logger.log(padTitle("Duration"), time(threadTime));
|
|
441
|
-
else
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
+
} else {
|
|
446
|
+
let timers = `transform ${time(transformTime)}, setup ${time(setupTime)}, collect ${time(collectTime)}, tests ${time(testsTime)}, environment ${time(environmentTime)}, prepare ${time(prepareTime)}`;
|
|
447
|
+
const typecheck = this.ctx.projects.reduce((acc, c2) => {
|
|
448
|
+
var _a2;
|
|
449
|
+
return acc + (((_a2 = c2.typechecker) == null ? void 0 : _a2.getResult().time) || 0);
|
|
450
|
+
}, 0);
|
|
451
|
+
if (typecheck)
|
|
452
|
+
timers += `, typecheck ${time(typecheck)}`;
|
|
453
|
+
logger.log(padTitle("Duration"), time(executionTime) + c.dim(` (${timers})`));
|
|
454
|
+
}
|
|
445
455
|
logger.log();
|
|
446
456
|
}
|
|
447
457
|
async printErrorsSummary(files, errors) {
|
|
@@ -539,12 +549,16 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
539
549
|
}
|
|
540
550
|
}
|
|
541
551
|
registerUnhandledRejection() {
|
|
542
|
-
|
|
552
|
+
const onUnhandledRejection = async (err) => {
|
|
543
553
|
process.exitCode = 1;
|
|
544
554
|
await this.ctx.logger.printError(err, { fullStack: true, type: "Unhandled Rejection" });
|
|
545
555
|
this.ctx.logger.error("\n\n");
|
|
546
556
|
process.exit(1);
|
|
547
|
-
}
|
|
557
|
+
};
|
|
558
|
+
process.on("unhandledRejection", onUnhandledRejection);
|
|
559
|
+
this._offUnhandledRejection = () => {
|
|
560
|
+
process.off("unhandledRejection", onUnhandledRejection);
|
|
561
|
+
};
|
|
548
562
|
}
|
|
549
563
|
}
|
|
550
564
|
|
|
@@ -1455,7 +1469,7 @@ function renderBenchmark$1(task, tasks) {
|
|
|
1455
1469
|
].join("");
|
|
1456
1470
|
}
|
|
1457
1471
|
function renderTree$1(tasks, options, level = 0, maxRows) {
|
|
1458
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
1472
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1459
1473
|
const output = [];
|
|
1460
1474
|
let currentRowCount = 0;
|
|
1461
1475
|
for (const task of [...tasks].reverse()) {
|
|
@@ -1466,27 +1480,27 @@ function renderTree$1(tasks, options, level = 0, maxRows) {
|
|
|
1466
1480
|
prefix += formatProjectName(task.projectName);
|
|
1467
1481
|
if (task.type === "test" && ((_a = task.result) == null ? void 0 : _a.retryCount) && task.result.retryCount > 0)
|
|
1468
1482
|
suffix += c.yellow(` (retry x${task.result.retryCount})`);
|
|
1469
|
-
if (task.type === "suite"
|
|
1483
|
+
if (task.type === "suite") {
|
|
1470
1484
|
const tests = getTests(task);
|
|
1471
1485
|
suffix += c.dim(` (${tests.length})`);
|
|
1472
1486
|
}
|
|
1473
1487
|
if (task.mode === "skip" || task.mode === "todo")
|
|
1474
1488
|
suffix += ` ${c.dim(c.gray("[skipped]"))}`;
|
|
1475
|
-
if (task.type === "test" && ((
|
|
1489
|
+
if (task.type === "test" && ((_b = task.result) == null ? void 0 : _b.repeatCount) && task.result.repeatCount > 0)
|
|
1476
1490
|
suffix += c.yellow(` (repeat x${task.result.repeatCount})`);
|
|
1477
|
-
if (((
|
|
1491
|
+
if (((_c = task.result) == null ? void 0 : _c.duration) != null) {
|
|
1478
1492
|
if (task.result.duration > DURATION_LONG$1)
|
|
1479
1493
|
suffix += c.yellow(` ${Math.round(task.result.duration)}${c.dim("ms")}`);
|
|
1480
1494
|
}
|
|
1481
|
-
if (options.showHeap && ((
|
|
1495
|
+
if (options.showHeap && ((_d = task.result) == null ? void 0 : _d.heap) != null)
|
|
1482
1496
|
suffix += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
|
|
1483
1497
|
let name = task.name;
|
|
1484
1498
|
if (level === 0)
|
|
1485
1499
|
name = formatFilepath$1(name);
|
|
1486
1500
|
const padding = " ".repeat(level);
|
|
1487
|
-
const body = ((
|
|
1501
|
+
const body = ((_e = task.meta) == null ? void 0 : _e.benchmark) ? renderBenchmark$1(task, tasks) : name;
|
|
1488
1502
|
taskOutput.push(padding + prefix + body + suffix);
|
|
1489
|
-
if (((
|
|
1503
|
+
if (((_f = task.result) == null ? void 0 : _f.state) !== "pass" && outputMap$1.get(task) != null) {
|
|
1490
1504
|
let data = outputMap$1.get(task);
|
|
1491
1505
|
if (typeof data === "string") {
|
|
1492
1506
|
data = stripAnsi(data.trim().split("\n").filter(Boolean).pop());
|
|
@@ -1501,7 +1515,7 @@ function renderTree$1(tasks, options, level = 0, maxRows) {
|
|
|
1501
1515
|
taskOutput.push(renderHookState(task, "beforeAll", level + 1));
|
|
1502
1516
|
taskOutput.push(renderHookState(task, "beforeEach", level + 1));
|
|
1503
1517
|
if (task.type === "suite" && task.tasks.length > 0) {
|
|
1504
|
-
if (((
|
|
1518
|
+
if (((_g = task.result) == null ? void 0 : _g.state) === "fail" || ((_h = task.result) == null ? void 0 : _h.state) === "run" || options.renderSucceed) {
|
|
1505
1519
|
if (options.logger.ctx.config.hideSkippedTests) {
|
|
1506
1520
|
const filteredTasks = task.tasks.filter((t) => t.mode !== "skip" && t.mode !== "todo");
|
|
1507
1521
|
taskOutput.push(renderTree$1(filteredTasks, options, level + 1, maxRows));
|
|
@@ -1910,7 +1924,8 @@ let JsonReporter$1 = class JsonReporter {
|
|
|
1910
1924
|
return;
|
|
1911
1925
|
const project = this.ctx.getProjectByTaskId(test.id);
|
|
1912
1926
|
const stack = parseErrorStacktrace(error, {
|
|
1913
|
-
getSourceMap: (file) => project.getBrowserSourceMapModuleById(file)
|
|
1927
|
+
getSourceMap: (file) => project.getBrowserSourceMapModuleById(file),
|
|
1928
|
+
frameFilter: this.ctx.config.onStackTrace
|
|
1914
1929
|
});
|
|
1915
1930
|
const frame = stack[0];
|
|
1916
1931
|
if (!frame)
|
|
@@ -2015,7 +2030,8 @@ class TapReporter {
|
|
|
2015
2030
|
this.logger.indent();
|
|
2016
2031
|
task.result.errors.forEach((error) => {
|
|
2017
2032
|
const stacks = parseErrorStacktrace(error, {
|
|
2018
|
-
getSourceMap: (file) => project.getBrowserSourceMapModuleById(file)
|
|
2033
|
+
getSourceMap: (file) => project.getBrowserSourceMapModuleById(file),
|
|
2034
|
+
frameFilter: this.ctx.config.onStackTrace
|
|
2019
2035
|
});
|
|
2020
2036
|
const stack = stacks[0];
|
|
2021
2037
|
this.logger.log("---");
|
|
@@ -2128,7 +2144,8 @@ class JUnitReporter {
|
|
|
2128
2144
|
await this.baseLog(escapeXML(errorDetails));
|
|
2129
2145
|
const project = this.ctx.getProjectByTaskId(task.id);
|
|
2130
2146
|
const stack = parseErrorStacktrace(error, {
|
|
2131
|
-
getSourceMap: (file) => project.getBrowserSourceMapModuleById(file)
|
|
2147
|
+
getSourceMap: (file) => project.getBrowserSourceMapModuleById(file),
|
|
2148
|
+
frameFilter: this.ctx.config.onStackTrace
|
|
2132
2149
|
});
|
|
2133
2150
|
for (const frame of stack) {
|
|
2134
2151
|
const path = relative(this.ctx.config.root, frame.file);
|
|
@@ -2156,13 +2173,13 @@ class JUnitReporter {
|
|
|
2156
2173
|
name: task.name,
|
|
2157
2174
|
time: getDuration(task)
|
|
2158
2175
|
}, async () => {
|
|
2159
|
-
var _a
|
|
2176
|
+
var _a;
|
|
2160
2177
|
await this.writeLogs(task, "out");
|
|
2161
2178
|
await this.writeLogs(task, "err");
|
|
2162
2179
|
if (task.mode === "skip" || task.mode === "todo")
|
|
2163
2180
|
await this.logger.log("<skipped/>");
|
|
2164
2181
|
if (((_a = task.result) == null ? void 0 : _a.state) === "fail") {
|
|
2165
|
-
const errors =
|
|
2182
|
+
const errors = task.result.errors || [];
|
|
2166
2183
|
for (const error of errors) {
|
|
2167
2184
|
await this.writeElement("failure", {
|
|
2168
2185
|
message: error == null ? void 0 : error.message,
|
package/dist/vm.js
CHANGED
|
@@ -7,11 +7,10 @@ import { c as createBirpc } from './vendor-index.1ca68bd5.js';
|
|
|
7
7
|
import { resolve } from 'pathe';
|
|
8
8
|
import { installSourcemapsSupport } from 'vite-node/source-map';
|
|
9
9
|
import { d as distDir } from './vendor-paths.84fc7a99.js';
|
|
10
|
-
import { l as loadEnvironment } from './vendor-
|
|
11
|
-
import { b as startVitestExecutor } from './vendor-execute.
|
|
10
|
+
import { l as loadEnvironment } from './vendor-loader.9c966f23.js';
|
|
11
|
+
import { b as startVitestExecutor } from './vendor-execute.e6e4e89b.js';
|
|
12
12
|
import { createCustomConsole } from './chunk-runtime-console.f3263f87.js';
|
|
13
13
|
import { c as createSafeRpc } from './vendor-rpc.cbd8e972.js';
|
|
14
|
-
import './vendor-index.0b5b3600.js';
|
|
15
14
|
import 'acorn';
|
|
16
15
|
import 'node:module';
|
|
17
16
|
import 'node:fs';
|
|
@@ -20,6 +19,7 @@ import 'node:process';
|
|
|
20
19
|
import 'node:path';
|
|
21
20
|
import 'node:v8';
|
|
22
21
|
import 'node:util';
|
|
22
|
+
import './vendor-environments.dcc4a34e.js';
|
|
23
23
|
import 'node:console';
|
|
24
24
|
import 'local-pkg';
|
|
25
25
|
import 'vite-node/utils';
|
|
@@ -94,7 +94,12 @@ async function run(ctx) {
|
|
|
94
94
|
const context = vm.getVmContext();
|
|
95
95
|
if (!isContext(context))
|
|
96
96
|
throw new TypeError(`Environment ${ctx.environment.name} doesn't provide a valid context. It should be created by "vm.createContext" method.`);
|
|
97
|
-
context
|
|
97
|
+
Object.defineProperty(context, "__vitest_worker__", {
|
|
98
|
+
value: state,
|
|
99
|
+
configurable: true,
|
|
100
|
+
writable: true,
|
|
101
|
+
enumerable: false
|
|
102
|
+
});
|
|
98
103
|
context.process = process;
|
|
99
104
|
context.global = context;
|
|
100
105
|
context.console = createCustomConsole(state);
|
package/dist/worker.js
CHANGED
|
@@ -2,12 +2,11 @@ import { performance } from 'node:perf_hooks';
|
|
|
2
2
|
import { c as createBirpc } from './vendor-index.1ca68bd5.js';
|
|
3
3
|
import { workerId } from 'tinypool';
|
|
4
4
|
import { g as getWorkerState } from './vendor-global.97e4527c.js';
|
|
5
|
-
import { l as loadEnvironment } from './vendor-
|
|
6
|
-
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.
|
|
5
|
+
import { l as loadEnvironment } from './vendor-loader.9c966f23.js';
|
|
6
|
+
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.e6e4e89b.js';
|
|
7
7
|
import { s as setupInspect } from './vendor-inspector.209edf5a.js';
|
|
8
8
|
import { r as rpcDone, c as createSafeRpc } from './vendor-rpc.cbd8e972.js';
|
|
9
9
|
import 'pathe';
|
|
10
|
-
import './vendor-index.0b5b3600.js';
|
|
11
10
|
import 'acorn';
|
|
12
11
|
import 'node:module';
|
|
13
12
|
import 'node:fs';
|
|
@@ -18,6 +17,7 @@ import 'node:path';
|
|
|
18
17
|
import 'node:v8';
|
|
19
18
|
import 'node:util';
|
|
20
19
|
import 'vite-node/client';
|
|
20
|
+
import './vendor-environments.dcc4a34e.js';
|
|
21
21
|
import 'node:console';
|
|
22
22
|
import 'local-pkg';
|
|
23
23
|
import 'node:vm';
|
|
@@ -76,7 +76,12 @@ async function init(ctx) {
|
|
|
76
76
|
},
|
|
77
77
|
rpc
|
|
78
78
|
};
|
|
79
|
-
globalThis
|
|
79
|
+
Object.defineProperty(globalThis, "__vitest_worker__", {
|
|
80
|
+
value: state,
|
|
81
|
+
configurable: true,
|
|
82
|
+
writable: true,
|
|
83
|
+
enumerable: false
|
|
84
|
+
});
|
|
80
85
|
if (ctx.invalidates) {
|
|
81
86
|
ctx.invalidates.forEach((fsPath) => {
|
|
82
87
|
moduleCache.delete(fsPath);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.3",
|
|
5
5
|
"description": "Next generation testing framework powered by Vite",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -98,18 +98,15 @@
|
|
|
98
98
|
"*.cjs"
|
|
99
99
|
],
|
|
100
100
|
"engines": {
|
|
101
|
-
"node": ">=
|
|
101
|
+
"node": "^18.0.0 || >=20.0.0"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
104
|
"@edge-runtime/vm": "*",
|
|
105
|
-
"@types/node": ">=
|
|
105
|
+
"@types/node": "^18.0.0 || >=20.0.0",
|
|
106
106
|
"@vitest/browser": "*",
|
|
107
107
|
"@vitest/ui": "*",
|
|
108
108
|
"happy-dom": "*",
|
|
109
|
-
"jsdom": "*"
|
|
110
|
-
"playwright": "*",
|
|
111
|
-
"safaridriver": "*",
|
|
112
|
-
"webdriverio": "*"
|
|
109
|
+
"jsdom": "*"
|
|
113
110
|
},
|
|
114
111
|
"peerDependenciesMeta": {
|
|
115
112
|
"@types/node": {
|
|
@@ -127,15 +124,6 @@
|
|
|
127
124
|
"jsdom": {
|
|
128
125
|
"optional": true
|
|
129
126
|
},
|
|
130
|
-
"webdriverio": {
|
|
131
|
-
"optional": true
|
|
132
|
-
},
|
|
133
|
-
"safaridriver": {
|
|
134
|
-
"optional": true
|
|
135
|
-
},
|
|
136
|
-
"playwright": {
|
|
137
|
-
"optional": true
|
|
138
|
-
},
|
|
139
127
|
"@edge-runtime/vm": {
|
|
140
128
|
"optional": true
|
|
141
129
|
}
|
|
@@ -147,7 +135,7 @@
|
|
|
147
135
|
"chai": "^4.3.10",
|
|
148
136
|
"debug": "^4.3.4",
|
|
149
137
|
"local-pkg": "^0.4.3",
|
|
150
|
-
"magic-string": "^0.30.
|
|
138
|
+
"magic-string": "^0.30.5",
|
|
151
139
|
"pathe": "^1.1.1",
|
|
152
140
|
"picocolors": "^1.0.0",
|
|
153
141
|
"std-env": "^3.3.3",
|
|
@@ -156,12 +144,12 @@
|
|
|
156
144
|
"tinypool": "^0.8.1",
|
|
157
145
|
"vite": "^3.1.0 || ^4.0.0 || ^5.0.0-0",
|
|
158
146
|
"why-is-node-running": "^2.2.2",
|
|
159
|
-
"@vitest/
|
|
160
|
-
"@vitest/
|
|
161
|
-
"
|
|
162
|
-
"@vitest/
|
|
163
|
-
"@vitest/
|
|
164
|
-
"
|
|
147
|
+
"@vitest/expect": "1.0.0-beta.3",
|
|
148
|
+
"@vitest/runner": "1.0.0-beta.3",
|
|
149
|
+
"@vitest/snapshot": "1.0.0-beta.3",
|
|
150
|
+
"@vitest/spy": "1.0.0-beta.3",
|
|
151
|
+
"@vitest/utils": "1.0.0-beta.3",
|
|
152
|
+
"vite-node": "1.0.0-beta.3"
|
|
165
153
|
},
|
|
166
154
|
"devDependencies": {
|
|
167
155
|
"@ampproject/remapping": "^2.2.1",
|
|
@@ -179,7 +167,6 @@
|
|
|
179
167
|
"birpc": "0.2.14",
|
|
180
168
|
"chai-subset": "^1.6.0",
|
|
181
169
|
"cli-truncate": "^3.1.0",
|
|
182
|
-
"event-target-polyfill": "^0.0.3",
|
|
183
170
|
"execa": "^7.1.1",
|
|
184
171
|
"expect-type": "^0.16.0",
|
|
185
172
|
"fast-glob": "^3.3.0",
|
|
@@ -193,12 +180,9 @@
|
|
|
193
180
|
"mlly": "^1.4.0",
|
|
194
181
|
"p-limit": "^4.0.0",
|
|
195
182
|
"pkg-types": "^1.0.3",
|
|
196
|
-
"playwright": "^1.35.1",
|
|
197
183
|
"pretty-format": "^29.5.0",
|
|
198
184
|
"prompts": "^2.4.2",
|
|
199
|
-
"safaridriver": "^0.0.5",
|
|
200
185
|
"strip-ansi": "^7.1.0",
|
|
201
|
-
"webdriverio": "^8.11.2",
|
|
202
186
|
"ws": "^8.13.0"
|
|
203
187
|
},
|
|
204
188
|
"scripts": {
|
package/dist/loader.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
2
|
-
import { readFile } from 'node:fs/promises';
|
|
3
|
-
import { i as isNodeBuiltin, h as hasCJSSyntax } from './vendor-index.0b5b3600.js';
|
|
4
|
-
import { normalizeModuleId } from 'vite-node/utils';
|
|
5
|
-
import './vendor-index.29282562.js';
|
|
6
|
-
import { g as getWorkerState } from './vendor-global.97e4527c.js';
|
|
7
|
-
import 'acorn';
|
|
8
|
-
import 'node:module';
|
|
9
|
-
import 'node:fs';
|
|
10
|
-
import 'pathe';
|
|
11
|
-
import 'node:assert';
|
|
12
|
-
import 'node:process';
|
|
13
|
-
import 'node:path';
|
|
14
|
-
import 'node:v8';
|
|
15
|
-
import 'node:util';
|
|
16
|
-
import 'std-env';
|
|
17
|
-
import '@vitest/runner/utils';
|
|
18
|
-
import '@vitest/utils';
|
|
19
|
-
|
|
20
|
-
var ModuleFormat = /* @__PURE__ */ ((ModuleFormat2) => {
|
|
21
|
-
ModuleFormat2["Builtin"] = "builtin";
|
|
22
|
-
ModuleFormat2["Commonjs"] = "commonjs";
|
|
23
|
-
ModuleFormat2["Json"] = "json";
|
|
24
|
-
ModuleFormat2["Module"] = "module";
|
|
25
|
-
ModuleFormat2["Wasm"] = "wasm";
|
|
26
|
-
return ModuleFormat2;
|
|
27
|
-
})(ModuleFormat || {});
|
|
28
|
-
|
|
29
|
-
const ESM_RE = /([\s;}]|^)(import[\w,{}\s*]*from|import\s*['"*{]|export\b\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\.meta\b)/m;
|
|
30
|
-
function hasESMSyntax(code) {
|
|
31
|
-
return ESM_RE.test(code);
|
|
32
|
-
}
|
|
33
|
-
const cache = /* @__PURE__ */ new Map();
|
|
34
|
-
async function getPotentialSource(filepath, result) {
|
|
35
|
-
var _a;
|
|
36
|
-
if (!result.url.startsWith("file://") || result.format === "module")
|
|
37
|
-
return null;
|
|
38
|
-
let source = (_a = cache.get(result.url)) == null ? void 0 : _a.source;
|
|
39
|
-
if (source == null)
|
|
40
|
-
source = await readFile(filepath, "utf8");
|
|
41
|
-
return source;
|
|
42
|
-
}
|
|
43
|
-
function detectESM(url, source) {
|
|
44
|
-
const cached = cache.get(url);
|
|
45
|
-
if (cached)
|
|
46
|
-
return cached.isPseudoESM;
|
|
47
|
-
if (!source)
|
|
48
|
-
return false;
|
|
49
|
-
return hasESMSyntax(source) && !hasCJSSyntax(source);
|
|
50
|
-
}
|
|
51
|
-
const resolve = async (url, context, next) => {
|
|
52
|
-
var _a;
|
|
53
|
-
const { parentURL } = context;
|
|
54
|
-
const state = getWorkerState();
|
|
55
|
-
const resolver = state == null ? void 0 : state.rpc.resolveId;
|
|
56
|
-
const environment = state == null ? void 0 : state.ctx.environment;
|
|
57
|
-
if (!parentURL || isNodeBuiltin(url) || !resolver || !environment)
|
|
58
|
-
return next(url, context, next);
|
|
59
|
-
const id = normalizeModuleId(url);
|
|
60
|
-
const importer = normalizeModuleId(parentURL);
|
|
61
|
-
const resolved = await resolver(id, importer, environment.transformMode ?? ((_a = environment.environment) == null ? void 0 : _a.transformMode) ?? "ssr");
|
|
62
|
-
let result;
|
|
63
|
-
let filepath;
|
|
64
|
-
if (resolved) {
|
|
65
|
-
const resolvedUrl = pathToFileURL(resolved.id).toString();
|
|
66
|
-
filepath = resolved.id;
|
|
67
|
-
result = {
|
|
68
|
-
url: resolvedUrl,
|
|
69
|
-
shortCircuit: true
|
|
70
|
-
};
|
|
71
|
-
} else {
|
|
72
|
-
const { url: resolvedUrl, format } = await next(url, context, next);
|
|
73
|
-
filepath = fileURLToPath(resolvedUrl);
|
|
74
|
-
result = {
|
|
75
|
-
url: resolvedUrl,
|
|
76
|
-
format,
|
|
77
|
-
shortCircuit: true
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
const source = await getPotentialSource(filepath, result);
|
|
81
|
-
const isPseudoESM = detectESM(result.url, source);
|
|
82
|
-
if (typeof source === "string")
|
|
83
|
-
cache.set(result.url, { isPseudoESM, source });
|
|
84
|
-
if (isPseudoESM)
|
|
85
|
-
result.format = ModuleFormat.Module;
|
|
86
|
-
return result;
|
|
87
|
-
};
|
|
88
|
-
const load = async (url, context, next) => {
|
|
89
|
-
const result = await next(url, context, next);
|
|
90
|
-
const cached = cache.get(url);
|
|
91
|
-
if ((cached == null ? void 0 : cached.isPseudoESM) && result.format !== "module") {
|
|
92
|
-
return {
|
|
93
|
-
source: cached.source,
|
|
94
|
-
format: ModuleFormat.Module
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
return result;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export { load, resolve };
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.7d1333e8.js';
|
|
2
|
-
|
|
3
|
-
const root =
|
|
4
|
-
(typeof globalThis !== "undefined" && globalThis) ||
|
|
5
|
-
(typeof self !== "undefined" && self) ||
|
|
6
|
-
(typeof commonjsGlobal !== "undefined" && commonjsGlobal);
|
|
7
|
-
|
|
8
|
-
function isConstructor(fn) {
|
|
9
|
-
try {
|
|
10
|
-
new fn();
|
|
11
|
-
} catch (error) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (typeof root.Event !== "function" || !isConstructor(root.Event)) {
|
|
18
|
-
root.Event = (function () {
|
|
19
|
-
function Event(type, options) {
|
|
20
|
-
this.bubbles = !!options && !!options.bubbles;
|
|
21
|
-
this.cancelable = !!options && !!options.cancelable;
|
|
22
|
-
this.composed = !!options && !!options.composed;
|
|
23
|
-
this.type = type;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return Event;
|
|
27
|
-
})();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (typeof root.EventTarget === "undefined" || !isConstructor(root.Event)) {
|
|
31
|
-
root.EventTarget = (function () {
|
|
32
|
-
function EventTarget() {
|
|
33
|
-
this.__listeners = new Map();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
EventTarget.prototype = Object.create(Object.prototype);
|
|
37
|
-
|
|
38
|
-
EventTarget.prototype.addEventListener = function (
|
|
39
|
-
type,
|
|
40
|
-
listener,
|
|
41
|
-
options
|
|
42
|
-
) {
|
|
43
|
-
if (arguments.length < 2) {
|
|
44
|
-
throw new TypeError(
|
|
45
|
-
`TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only ${arguments.length} present.`
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
const __listeners = this.__listeners;
|
|
49
|
-
const actualType = type.toString();
|
|
50
|
-
if (!__listeners.has(actualType)) {
|
|
51
|
-
__listeners.set(actualType, new Map());
|
|
52
|
-
}
|
|
53
|
-
const listenersForType = __listeners.get(actualType);
|
|
54
|
-
if (!listenersForType.has(listener)) {
|
|
55
|
-
// Any given listener is only registered once
|
|
56
|
-
listenersForType.set(listener, options);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
EventTarget.prototype.removeEventListener = function (
|
|
61
|
-
type,
|
|
62
|
-
listener,
|
|
63
|
-
_options
|
|
64
|
-
) {
|
|
65
|
-
if (arguments.length < 2) {
|
|
66
|
-
throw new TypeError(
|
|
67
|
-
`TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only ${arguments.length} present.`
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
const __listeners = this.__listeners;
|
|
71
|
-
const actualType = type.toString();
|
|
72
|
-
if (__listeners.has(actualType)) {
|
|
73
|
-
const listenersForType = __listeners.get(actualType);
|
|
74
|
-
if (listenersForType.has(listener)) {
|
|
75
|
-
listenersForType.delete(listener);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
EventTarget.prototype.dispatchEvent = function (event) {
|
|
81
|
-
if (!(event instanceof Event)) {
|
|
82
|
-
throw new TypeError(
|
|
83
|
-
`Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.`
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
const type = event.type;
|
|
87
|
-
const __listeners = this.__listeners;
|
|
88
|
-
const listenersForType = __listeners.get(type);
|
|
89
|
-
if (listenersForType) {
|
|
90
|
-
for (const [listener, options] of listenersForType.entries()) {
|
|
91
|
-
try {
|
|
92
|
-
if (typeof listener === "function") {
|
|
93
|
-
// Listener functions must be executed with the EventTarget as the `this` context.
|
|
94
|
-
listener.call(this, event);
|
|
95
|
-
} else if (listener && typeof listener.handleEvent === "function") {
|
|
96
|
-
// Listener objects have their handleEvent method called, if they have one
|
|
97
|
-
listener.handleEvent(event);
|
|
98
|
-
}
|
|
99
|
-
} catch (err) {
|
|
100
|
-
// We need to report the error to the global error handling event,
|
|
101
|
-
// but we do not want to break the loop that is executing the events.
|
|
102
|
-
// Unfortunately, this is the best we can do, which isn't great, because the
|
|
103
|
-
// native EventTarget will actually do this synchronously before moving to the next
|
|
104
|
-
// event in the loop.
|
|
105
|
-
setTimeout(() => {
|
|
106
|
-
throw err;
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
if (options && options.once) {
|
|
110
|
-
// If this was registered with { once: true }, we need
|
|
111
|
-
// to remove it now.
|
|
112
|
-
listenersForType.delete(listener);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
// Since there are no cancellable events on a base EventTarget,
|
|
117
|
-
// this should always return true.
|
|
118
|
-
return true;
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
return EventTarget;
|
|
122
|
-
})();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
126
|
-
__proto__: null
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
export { index as i };
|