vitest 0.8.2 → 0.8.5

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 (41) hide show
  1. package/dist/chunk-api-setup.da2f55ae.js +4442 -0
  2. package/dist/chunk-constants.76cf224a.js +31 -0
  3. package/dist/chunk-defaults.e85b72aa.js +148 -0
  4. package/dist/chunk-install-pkg.7dd40977.js +0 -1
  5. package/dist/chunk-integrations-globals.3713535d.js +24 -0
  6. package/dist/chunk-magic-string.d5e0e473.js +0 -1
  7. package/dist/chunk-runtime-chain.c86f1eb0.js +7131 -0
  8. package/dist/chunk-runtime-mocker.7cc59bee.js +258 -0
  9. package/dist/chunk-runtime-rpc.5263102e.js +8 -0
  10. package/dist/chunk-utils-base.aff0a195.js +408 -0
  11. package/dist/chunk-utils-global.7bcfa03c.js +0 -1
  12. package/dist/chunk-utils-timers.5657f2a4.js +4655 -0
  13. package/dist/chunk-vite-node-externalize.e472da7d.js +13611 -0
  14. package/dist/chunk-vite-node-utils.a6890356.js +9152 -0
  15. package/dist/cli.js +7 -8
  16. package/dist/config.cjs +3 -2
  17. package/dist/config.d.ts +26 -2
  18. package/dist/config.js +3 -2
  19. package/dist/entry.js +83 -52
  20. package/dist/index.d.ts +32 -9
  21. package/dist/index.js +5 -6
  22. package/dist/node.d.ts +20 -4
  23. package/dist/node.js +7 -8
  24. package/dist/spy.js +102 -0
  25. package/dist/vendor-_commonjsHelpers.34b404ce.js +0 -1
  26. package/dist/vendor-index.87b2fc14.js +0 -1
  27. package/dist/vendor-index.ee829ed6.js +0 -1
  28. package/dist/worker.js +5 -6
  29. package/package.json +17 -17
  30. package/dist/chunk-api-setup.f537ec22.js +0 -4443
  31. package/dist/chunk-constants.6062c404.js +0 -32
  32. package/dist/chunk-defaults.e5535971.js +0 -148
  33. package/dist/chunk-integrations-globals.1039302d.js +0 -25
  34. package/dist/chunk-runtime-chain.f873402e.js +0 -7068
  35. package/dist/chunk-runtime-rpc.e8aa1ebe.js +0 -9
  36. package/dist/chunk-utils-base.8408f73a.js +0 -409
  37. package/dist/chunk-utils-path.02d3f287.js +0 -267
  38. package/dist/chunk-utils-timers.7bdeea22.js +0 -4653
  39. package/dist/chunk-vite-node-externalize.a2ee7060.js +0 -13470
  40. package/dist/chunk-vite-node-utils.386c09c4.js +0 -9153
  41. package/dist/jest-mock.js +0 -100
@@ -0,0 +1,258 @@
1
+ import { n as normalizeRequestId, i as isNodeBuiltin, t as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.a6890356.js';
2
+ import { normalizePath } from 'vite';
3
+ import { z as isWindows, A as mergeSlashes, h as dirname, f as basename, u as resolve } from './chunk-utils-base.aff0a195.js';
4
+ import { existsSync, readdirSync } from 'fs';
5
+ import { d as distDir } from './chunk-constants.76cf224a.js';
6
+ import { g as getWorkerState } from './chunk-utils-global.7bcfa03c.js';
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ function getType(value) {
25
+ return Object.prototype.toString.apply(value).slice(8, -1);
26
+ }
27
+ function getAllProperties(obj) {
28
+ const allProps = /* @__PURE__ */ new Set();
29
+ let curr = obj;
30
+ do {
31
+ if (curr === Object.prototype || curr === Function.prototype || curr === RegExp.prototype)
32
+ break;
33
+ const props = Object.getOwnPropertyNames(curr);
34
+ props.forEach((prop) => allProps.add(prop));
35
+ } while (curr = Object.getPrototypeOf(curr));
36
+ return Array.from(allProps);
37
+ }
38
+ const _VitestMocker = class {
39
+ constructor(options, moduleCache, request) {
40
+ this.options = options;
41
+ this.moduleCache = moduleCache;
42
+ this.callbacks = {};
43
+ this.root = this.options.root;
44
+ this.request = request;
45
+ }
46
+ get mockMap() {
47
+ return this.options.mockMap;
48
+ }
49
+ on(event, cb) {
50
+ var _a;
51
+ (_a = this.callbacks)[event] ?? (_a[event] = []);
52
+ this.callbacks[event].push(cb);
53
+ }
54
+ emit(event, ...args) {
55
+ (this.callbacks[event] ?? []).forEach((fn) => fn(...args));
56
+ }
57
+ getSuiteFilepath() {
58
+ return getWorkerState().filepath || "global";
59
+ }
60
+ getMocks() {
61
+ const suite = this.getSuiteFilepath();
62
+ const suiteMocks = this.mockMap.get(suite);
63
+ const globalMocks = this.mockMap.get("global");
64
+ return __spreadValues(__spreadValues({}, globalMocks), suiteMocks);
65
+ }
66
+ async resolvePath(id, importer) {
67
+ const path = await this.options.resolveId(id, importer);
68
+ return {
69
+ path: normalizeRequestId((path == null ? void 0 : path.id) || id),
70
+ external: (path == null ? void 0 : path.id.includes("/node_modules/")) ? id : null
71
+ };
72
+ }
73
+ async resolveMocks() {
74
+ await Promise.all(_VitestMocker.pendingIds.map(async (mock) => {
75
+ const { path, external } = await this.resolvePath(mock.id, mock.importer);
76
+ if (mock.type === "unmock")
77
+ this.unmockPath(path);
78
+ if (mock.type === "mock")
79
+ this.mockPath(path, external, mock.factory);
80
+ }));
81
+ _VitestMocker.pendingIds = [];
82
+ }
83
+ async callFunctionMock(dep, mock) {
84
+ var _a;
85
+ const cacheName = `${dep}__mock`;
86
+ const cached = (_a = this.moduleCache.get(cacheName)) == null ? void 0 : _a.exports;
87
+ if (cached)
88
+ return cached;
89
+ const exports = await mock();
90
+ this.emit("mocked", cacheName, { exports });
91
+ return exports;
92
+ }
93
+ getDependencyMock(dep) {
94
+ return this.getMocks()[this.resolveDependency(dep)];
95
+ }
96
+ resolveDependency(dep) {
97
+ return normalizeRequestId(dep).replace(/^\/@fs\//, isWindows ? "" : "/");
98
+ }
99
+ normalizePath(path) {
100
+ return normalizeRequestId(path.replace(this.root, "")).replace(/^\/@fs\//, isWindows ? "" : "/");
101
+ }
102
+ getFsPath(path, external) {
103
+ if (external)
104
+ return mergeSlashes(`/@fs/${path}`);
105
+ return normalizeRequestId(path.replace(this.root, ""));
106
+ }
107
+ resolveMockPath(mockPath, external) {
108
+ const path = normalizeRequestId(external || mockPath);
109
+ if (external || isNodeBuiltin(mockPath)) {
110
+ const mockDirname = dirname(path);
111
+ const baseFilename = basename(path);
112
+ const mockFolder = resolve(this.root, "__mocks__", mockDirname);
113
+ if (!existsSync(mockFolder))
114
+ return null;
115
+ const files = readdirSync(mockFolder);
116
+ for (const file of files) {
117
+ const [basename2] = file.split(".");
118
+ if (basename2 === baseFilename)
119
+ return resolve(mockFolder, file).replace(this.root, "");
120
+ }
121
+ return null;
122
+ }
123
+ const dir = dirname(path);
124
+ const baseId = basename(path);
125
+ const fullPath = resolve(dir, "__mocks__", baseId);
126
+ return existsSync(fullPath) ? fullPath.replace(this.root, "") : null;
127
+ }
128
+ mockValue(value) {
129
+ if (!_VitestMocker.spyModule) {
130
+ throw new Error("Error: Spy module is not defined. This is likely an internal bug in Vitest. Please report it to https://github.com/vitest-dev/vitest/issues");
131
+ }
132
+ const type = getType(value);
133
+ if (Array.isArray(value))
134
+ return [];
135
+ else if (type !== "Object" && type !== "Module")
136
+ return value;
137
+ const newObj = {};
138
+ const proproperties = getAllProperties(value);
139
+ for (const k of proproperties) {
140
+ newObj[k] = this.mockValue(value[k]);
141
+ const type2 = getType(value[k]);
142
+ if (type2.includes("Function") && !value[k]._isMockFunction) {
143
+ _VitestMocker.spyModule.spyOn(newObj, k).mockImplementation(() => void 0);
144
+ Object.defineProperty(newObj[k], "length", { value: 0 });
145
+ }
146
+ }
147
+ Object.setPrototypeOf(newObj, Object.getPrototypeOf(value));
148
+ return newObj;
149
+ }
150
+ unmockPath(path) {
151
+ const suitefile = this.getSuiteFilepath();
152
+ const fsPath = this.normalizePath(path);
153
+ const mock = this.mockMap.get(suitefile);
154
+ if (mock == null ? void 0 : mock[fsPath])
155
+ delete mock[fsPath];
156
+ }
157
+ mockPath(path, external, factory) {
158
+ const suitefile = this.getSuiteFilepath();
159
+ const fsPath = this.normalizePath(path);
160
+ if (!this.mockMap.has(suitefile))
161
+ this.mockMap.set(suitefile, {});
162
+ this.mockMap.get(suitefile)[fsPath] = factory || this.resolveMockPath(path, external);
163
+ }
164
+ async importActual(id, importer) {
165
+ const { path, external } = await this.resolvePath(id, importer);
166
+ const fsPath = this.getFsPath(path, external);
167
+ const result = await this.request(fsPath);
168
+ return result;
169
+ }
170
+ async importMock(id, importer) {
171
+ const { path, external } = await this.resolvePath(id, importer);
172
+ let mock = this.getDependencyMock(path);
173
+ if (mock === void 0)
174
+ mock = this.resolveMockPath(path, external);
175
+ if (mock === null) {
176
+ await this.ensureSpy();
177
+ const fsPath = this.getFsPath(path, external);
178
+ const mod = await this.request(fsPath);
179
+ return this.mockValue(mod);
180
+ }
181
+ if (typeof mock === "function")
182
+ return this.callFunctionMock(path, mock);
183
+ return this.requestWithMock(mock);
184
+ }
185
+ async ensureSpy() {
186
+ if (_VitestMocker.spyModule)
187
+ return;
188
+ _VitestMocker.spyModule = await this.request(resolve(distDir, "spy.js"));
189
+ }
190
+ async requestWithMock(dep) {
191
+ var _a;
192
+ await this.ensureSpy();
193
+ await this.resolveMocks();
194
+ const mock = this.getDependencyMock(dep);
195
+ if (mock === null) {
196
+ const cacheName = `${dep}__mock`;
197
+ const cache = this.moduleCache.get(cacheName);
198
+ if (cache == null ? void 0 : cache.exports)
199
+ return cache.exports;
200
+ const cacheKey = toFilePath(dep, this.root);
201
+ const mod = ((_a = this.moduleCache.get(cacheKey)) == null ? void 0 : _a.exports) || await this.request(dep);
202
+ const exports = this.mockValue(mod);
203
+ this.emit("mocked", cacheName, { exports });
204
+ return exports;
205
+ }
206
+ if (typeof mock === "function")
207
+ return this.callFunctionMock(dep, mock);
208
+ if (typeof mock === "string")
209
+ dep = mock;
210
+ return this.request(dep);
211
+ }
212
+ queueMock(id, importer, factory) {
213
+ _VitestMocker.pendingIds.push({ type: "mock", id, importer, factory });
214
+ }
215
+ queueUnmock(id, importer) {
216
+ _VitestMocker.pendingIds.push({ type: "unmock", id, importer });
217
+ }
218
+ withRequest(request) {
219
+ return new _VitestMocker(this.options, this.moduleCache, request);
220
+ }
221
+ };
222
+ let VitestMocker = _VitestMocker;
223
+ VitestMocker.pendingIds = [];
224
+
225
+ async function executeInViteNode(options) {
226
+ const runner = new VitestRunner(options);
227
+ await runner.executeId("/@vite/env");
228
+ const result = [];
229
+ for (const file of options.files)
230
+ result.push(await runner.executeFile(file));
231
+ return result;
232
+ }
233
+ class VitestRunner extends ViteNodeRunner {
234
+ constructor(options) {
235
+ super(options);
236
+ this.options = options;
237
+ this.entries = /* @__PURE__ */ new Set();
238
+ this.mocker = new VitestMocker(options, this.moduleCache);
239
+ }
240
+ prepareContext(context) {
241
+ const request = context.__vite_ssr_import__;
242
+ const mocker = this.mocker.withRequest(request);
243
+ mocker.on("mocked", (dep, module) => {
244
+ this.moduleCache.set(dep, module);
245
+ });
246
+ const workerState = getWorkerState();
247
+ if (workerState.filepath && normalizePath(workerState.filepath) === normalizePath(context.__filename)) {
248
+ Object.defineProperty(context.__vite_ssr_import_meta__, "vitest", { get: () => globalThis.__vitest_index__ });
249
+ }
250
+ return Object.assign(context, {
251
+ __vite_ssr_import__: (dep) => mocker.requestWithMock(dep),
252
+ __vite_ssr_dynamic_import__: (dep) => mocker.requestWithMock(dep),
253
+ __vitest_mocker__: mocker
254
+ });
255
+ }
256
+ }
257
+
258
+ export { VitestRunner as V, executeInViteNode as e };
@@ -0,0 +1,8 @@
1
+ import './chunk-utils-base.aff0a195.js';
2
+ import { g as getWorkerState } from './chunk-utils-global.7bcfa03c.js';
3
+
4
+ const rpc = () => {
5
+ return getWorkerState().rpc;
6
+ };
7
+
8
+ export { rpc as r };
@@ -0,0 +1,408 @@
1
+ import path from 'path';
2
+ import require$$0 from 'tty';
3
+ import { isPackageExists } from 'local-pkg';
4
+
5
+ var picocolors = {exports: {}};
6
+
7
+ let tty = require$$0;
8
+
9
+ let isColorSupported =
10
+ !("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
11
+ ("FORCE_COLOR" in process.env ||
12
+ process.argv.includes("--color") ||
13
+ process.platform === "win32" ||
14
+ (tty.isatty(1) && process.env.TERM !== "dumb") ||
15
+ "CI" in process.env);
16
+
17
+ let formatter =
18
+ (open, close, replace = open) =>
19
+ input => {
20
+ let string = "" + input;
21
+ let index = string.indexOf(close, open.length);
22
+ return ~index
23
+ ? open + replaceClose(string, close, replace, index) + close
24
+ : open + string + close
25
+ };
26
+
27
+ let replaceClose = (string, close, replace, index) => {
28
+ let start = string.substring(0, index) + replace;
29
+ let end = string.substring(index + close.length);
30
+ let nextIndex = end.indexOf(close);
31
+ return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
32
+ };
33
+
34
+ let createColors = (enabled = isColorSupported) => ({
35
+ isColorSupported: enabled,
36
+ reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
37
+ bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
38
+ dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
39
+ italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
40
+ underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
41
+ inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
42
+ hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
43
+ strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
44
+ black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
45
+ red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
46
+ green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
47
+ yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
48
+ blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
49
+ magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
50
+ cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
51
+ white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
52
+ gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
53
+ bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
54
+ bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
55
+ bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
56
+ bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
57
+ bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
58
+ bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
59
+ bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
60
+ bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
61
+ });
62
+
63
+ picocolors.exports = createColors();
64
+ picocolors.exports.createColors = createColors;
65
+
66
+ var c = picocolors.exports;
67
+
68
+ function normalizeWindowsPath(input = "") {
69
+ if (!input.includes("\\")) {
70
+ return input;
71
+ }
72
+ return input.replace(/\\/g, "/");
73
+ }
74
+
75
+ const _UNC_REGEX = /^[/][/]/;
76
+ const _UNC_DRIVE_REGEX = /^[/][/]([.]{1,2}[/])?([a-zA-Z]):[/]/;
77
+ const _IS_ABSOLUTE_RE = /^\/|^\\|^[a-zA-Z]:[/\\]/;
78
+ const sep = "/";
79
+ const delimiter = ":";
80
+ const normalize = function(path2) {
81
+ if (path2.length === 0) {
82
+ return ".";
83
+ }
84
+ path2 = normalizeWindowsPath(path2);
85
+ const isUNCPath = path2.match(_UNC_REGEX);
86
+ const hasUNCDrive = isUNCPath && path2.match(_UNC_DRIVE_REGEX);
87
+ const isPathAbsolute = isAbsolute(path2);
88
+ const trailingSeparator = path2[path2.length - 1] === "/";
89
+ path2 = normalizeString(path2, !isPathAbsolute);
90
+ if (path2.length === 0) {
91
+ if (isPathAbsolute) {
92
+ return "/";
93
+ }
94
+ return trailingSeparator ? "./" : ".";
95
+ }
96
+ if (trailingSeparator) {
97
+ path2 += "/";
98
+ }
99
+ if (isUNCPath) {
100
+ if (hasUNCDrive) {
101
+ return `//./${path2}`;
102
+ }
103
+ return `//${path2}`;
104
+ }
105
+ return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
106
+ };
107
+ const join = function(...args) {
108
+ if (args.length === 0) {
109
+ return ".";
110
+ }
111
+ let joined;
112
+ for (let i = 0; i < args.length; ++i) {
113
+ const arg = args[i];
114
+ if (arg.length > 0) {
115
+ if (joined === void 0) {
116
+ joined = arg;
117
+ } else {
118
+ joined += `/${arg}`;
119
+ }
120
+ }
121
+ }
122
+ if (joined === void 0) {
123
+ return ".";
124
+ }
125
+ return normalize(joined);
126
+ };
127
+ const resolve = function(...args) {
128
+ args = args.map((arg) => normalizeWindowsPath(arg));
129
+ let resolvedPath = "";
130
+ let resolvedAbsolute = false;
131
+ for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
132
+ const path2 = i >= 0 ? args[i] : process.cwd();
133
+ if (path2.length === 0) {
134
+ continue;
135
+ }
136
+ resolvedPath = `${path2}/${resolvedPath}`;
137
+ resolvedAbsolute = isAbsolute(path2);
138
+ }
139
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
140
+ if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
141
+ return `/${resolvedPath}`;
142
+ }
143
+ return resolvedPath.length > 0 ? resolvedPath : ".";
144
+ };
145
+ function normalizeString(path2, allowAboveRoot) {
146
+ let res = "";
147
+ let lastSegmentLength = 0;
148
+ let lastSlash = -1;
149
+ let dots = 0;
150
+ let char = null;
151
+ for (let i = 0; i <= path2.length; ++i) {
152
+ if (i < path2.length) {
153
+ char = path2[i];
154
+ } else if (char === "/") {
155
+ break;
156
+ } else {
157
+ char = "/";
158
+ }
159
+ if (char === "/") {
160
+ if (lastSlash === i - 1 || dots === 1) ; else if (dots === 2) {
161
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
162
+ if (res.length > 2) {
163
+ const lastSlashIndex = res.lastIndexOf("/");
164
+ if (lastSlashIndex === -1) {
165
+ res = "";
166
+ lastSegmentLength = 0;
167
+ } else {
168
+ res = res.slice(0, lastSlashIndex);
169
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
170
+ }
171
+ lastSlash = i;
172
+ dots = 0;
173
+ continue;
174
+ } else if (res.length !== 0) {
175
+ res = "";
176
+ lastSegmentLength = 0;
177
+ lastSlash = i;
178
+ dots = 0;
179
+ continue;
180
+ }
181
+ }
182
+ if (allowAboveRoot) {
183
+ res += res.length > 0 ? "/.." : "..";
184
+ lastSegmentLength = 2;
185
+ }
186
+ } else {
187
+ if (res.length > 0) {
188
+ res += `/${path2.slice(lastSlash + 1, i)}`;
189
+ } else {
190
+ res = path2.slice(lastSlash + 1, i);
191
+ }
192
+ lastSegmentLength = i - lastSlash - 1;
193
+ }
194
+ lastSlash = i;
195
+ dots = 0;
196
+ } else if (char === "." && dots !== -1) {
197
+ ++dots;
198
+ } else {
199
+ dots = -1;
200
+ }
201
+ }
202
+ return res;
203
+ }
204
+ const isAbsolute = function(p) {
205
+ return _IS_ABSOLUTE_RE.test(p);
206
+ };
207
+ const toNamespacedPath = function(p) {
208
+ return normalizeWindowsPath(p);
209
+ };
210
+ const extname = function(p) {
211
+ return path.posix.extname(normalizeWindowsPath(p));
212
+ };
213
+ const relative = function(from, to) {
214
+ return path.posix.relative(normalizeWindowsPath(from), normalizeWindowsPath(to));
215
+ };
216
+ const dirname = function(p) {
217
+ return path.posix.dirname(normalizeWindowsPath(p));
218
+ };
219
+ const format = function(p) {
220
+ return normalizeWindowsPath(path.posix.format(p));
221
+ };
222
+ const basename = function(p, ext) {
223
+ return path.posix.basename(normalizeWindowsPath(p), ext);
224
+ };
225
+ const parse = function(p) {
226
+ return path.posix.parse(normalizeWindowsPath(p));
227
+ };
228
+
229
+ const _path = /*#__PURE__*/Object.freeze({
230
+ __proto__: null,
231
+ sep: sep,
232
+ delimiter: delimiter,
233
+ normalize: normalize,
234
+ join: join,
235
+ resolve: resolve,
236
+ normalizeString: normalizeString,
237
+ isAbsolute: isAbsolute,
238
+ toNamespacedPath: toNamespacedPath,
239
+ extname: extname,
240
+ relative: relative,
241
+ dirname: dirname,
242
+ format: format,
243
+ basename: basename,
244
+ parse: parse
245
+ });
246
+
247
+ const index = {
248
+ ..._path
249
+ };
250
+
251
+ function notNullish(v) {
252
+ return v != null;
253
+ }
254
+ function slash(str) {
255
+ return str.replace(/\\/g, "/");
256
+ }
257
+ function mergeSlashes(str) {
258
+ return str.replace(/\/\//g, "/");
259
+ }
260
+ const noop = () => {
261
+ };
262
+ function toArray(array) {
263
+ if (array === null || array === void 0)
264
+ array = [];
265
+ if (Array.isArray(array))
266
+ return array;
267
+ return [array];
268
+ }
269
+ const toString = (v) => Object.prototype.toString.call(v);
270
+ const isPlainObject = (val) => toString(val) === "[object Object]" && (!val.constructor || val.constructor.name === "Object");
271
+ function isObject(item) {
272
+ return item != null && typeof item === "object" && !Array.isArray(item);
273
+ }
274
+ function deepMerge(target, ...sources) {
275
+ if (!sources.length)
276
+ return target;
277
+ const source = sources.shift();
278
+ if (source === void 0)
279
+ return target;
280
+ if (isMergableObject(target) && isMergableObject(source)) {
281
+ Object.keys(source).forEach((key) => {
282
+ if (isMergableObject(source[key])) {
283
+ if (!target[key])
284
+ target[key] = {};
285
+ deepMerge(target[key], source[key]);
286
+ } else {
287
+ target[key] = source[key];
288
+ }
289
+ });
290
+ }
291
+ return deepMerge(target, ...sources);
292
+ }
293
+ function isMergableObject(item) {
294
+ return isPlainObject(item) && !Array.isArray(item);
295
+ }
296
+ function assertTypes(value, name, types) {
297
+ const receivedType = typeof value;
298
+ const pass = types.includes(receivedType);
299
+ if (!pass)
300
+ throw new TypeError(`${name} value must be ${types.join(" or ")}, received "${receivedType}"`);
301
+ }
302
+
303
+ function getTests(suite) {
304
+ return toArray(suite).flatMap((s) => s.type === "test" ? [s] : s.tasks.flatMap((c) => c.type === "test" ? [c] : getTests(c)));
305
+ }
306
+ function getSuites(suite) {
307
+ return toArray(suite).flatMap((s) => s.type === "suite" ? [s, ...getSuites(s.tasks)] : []);
308
+ }
309
+ function hasTests(suite) {
310
+ return toArray(suite).some((s) => s.tasks.some((c) => c.type === "test" || hasTests(c)));
311
+ }
312
+ function hasFailed(suite) {
313
+ return toArray(suite).some((s) => {
314
+ var _a;
315
+ return ((_a = s.result) == null ? void 0 : _a.state) === "fail" || s.type === "suite" && hasFailed(s.tasks);
316
+ });
317
+ }
318
+ function hasFailedSnapshot(suite) {
319
+ return getTests(suite).some((s) => {
320
+ var _a, _b;
321
+ const message = (_b = (_a = s.result) == null ? void 0 : _a.error) == null ? void 0 : _b.message;
322
+ return message == null ? void 0 : message.match(/Snapshot .* mismatched/);
323
+ });
324
+ }
325
+ function getNames(task) {
326
+ const names = [task.name];
327
+ let current = task;
328
+ while ((current == null ? void 0 : current.suite) || (current == null ? void 0 : current.file)) {
329
+ current = current.suite || current.file;
330
+ if (current == null ? void 0 : current.name)
331
+ names.unshift(current.name);
332
+ }
333
+ return names;
334
+ }
335
+
336
+ const isWindows = process.platform === "win32";
337
+ function partitionSuiteChildren(suite) {
338
+ let tasksGroup = [];
339
+ const tasksGroups = [];
340
+ for (const c2 of suite.tasks) {
341
+ if (tasksGroup.length === 0 || c2.concurrent === tasksGroup[0].concurrent) {
342
+ tasksGroup.push(c2);
343
+ } else {
344
+ tasksGroups.push(tasksGroup);
345
+ tasksGroup = [c2];
346
+ }
347
+ }
348
+ if (tasksGroup.length > 0)
349
+ tasksGroups.push(tasksGroup);
350
+ return tasksGroups;
351
+ }
352
+ function getFullName(task) {
353
+ return getNames(task).join(c.dim(" > "));
354
+ }
355
+ async function ensurePackageInstalled(dependency, promptInstall = !process.env.CI && process.stdout.isTTY) {
356
+ if (isPackageExists(dependency))
357
+ return true;
358
+ process.stderr.write(c.red(`${c.inverse(c.red(" MISSING DEP "))} Can not find dependency '${dependency}'
359
+
360
+ `));
361
+ if (!promptInstall)
362
+ return false;
363
+ const prompts = await import('./vendor-index.ee829ed6.js').then(function (n) { return n.i; });
364
+ const { install } = await prompts.prompt({
365
+ type: "confirm",
366
+ name: "install",
367
+ message: c.reset(`Do you want to install ${c.green(dependency)}?`)
368
+ });
369
+ if (install) {
370
+ await (await import('./chunk-install-pkg.7dd40977.js')).installPackage(dependency, { dev: true });
371
+ process.stderr.write(c.yellow(`
372
+ Package ${dependency} installed, re-run the command to start.
373
+ `));
374
+ process.exit(1);
375
+ return true;
376
+ }
377
+ return false;
378
+ }
379
+ function getCallLastIndex(code) {
380
+ let charIndex = -1;
381
+ let inString = null;
382
+ let startedBracers = 0;
383
+ let endedBracers = 0;
384
+ let beforeChar = null;
385
+ while (charIndex <= code.length) {
386
+ beforeChar = code[charIndex];
387
+ charIndex++;
388
+ const char = code[charIndex];
389
+ const isCharString = char === '"' || char === "'" || char === "`";
390
+ if (isCharString && beforeChar !== "\\") {
391
+ if (inString === char)
392
+ inString = null;
393
+ else if (!inString)
394
+ inString = char;
395
+ }
396
+ if (!inString) {
397
+ if (char === "(")
398
+ startedBracers++;
399
+ if (char === ")")
400
+ endedBracers++;
401
+ }
402
+ if (startedBracers && endedBracers && startedBracers === endedBracers)
403
+ return charIndex;
404
+ }
405
+ return null;
406
+ }
407
+
408
+ export { mergeSlashes as A, partitionSuiteChildren as B, hasTests as C, index as a, getNames as b, c, assertTypes as d, notNullish as e, basename as f, getCallLastIndex as g, dirname as h, isObject as i, join as j, isAbsolute as k, getFullName as l, hasFailed as m, noop as n, hasFailedSnapshot as o, getSuites as p, getTests as q, relative as r, slash as s, toArray as t, resolve as u, deepMerge as v, toNamespacedPath as w, ensurePackageInstalled as x, extname as y, isWindows as z };
@@ -3,4 +3,3 @@ function getWorkerState() {
3
3
  }
4
4
 
5
5
  export { getWorkerState as g };
6
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2h1bmstdXRpbHMtZ2xvYmFsLjdiY2ZhMDNjLmpzIiwic291cmNlcyI6WyIuLi9zcmMvdXRpbHMvZ2xvYmFsLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgV29ya2VyR2xvYmFsU3RhdGUgfSBmcm9tICcuLi90eXBlcydcblxuZXhwb3J0IGZ1bmN0aW9uIGdldFdvcmtlclN0YXRlKCk6IFdvcmtlckdsb2JhbFN0YXRlIHtcbiAgLy8gQHRzLWV4cGVjdC1lcnJvciB1bnR5cGVkIGdsb2JhbFxuICByZXR1cm4gZ2xvYmFsVGhpcy5fX3ZpdGVzdF93b3JrZXJfX1xufVxuIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFPLENBQUEsQ0FBQSxDQUFBLENBQUEsQ0FBQSxDQUFBLENBQUEsQ0FBQSxDQUFTLGNBQWMsQ0FBRyxDQUFBLENBQUEsQ0FBQTtBQUNqQyxDQUFBLENBQUUsQ0FBTyxDQUFBLENBQUEsQ0FBQSxDQUFBLENBQUEsQ0FBQSxDQUFBLENBQUEsQ0FBQSxDQUFBLENBQUEsQ0FBQSxDQUFBLENBQUEsQ0FBQSxDQUFVLENBQUMsQ0FBQSxDQUFBLENBQUEsQ0FBQSxDQUFBLENBQUEsQ0FBQSxDQUFBLENBQUEsQ0FBQSxDQUFBLENBQUEsQ0FBQSxDQUFBLENBQUEsQ0FBQSxDQUFpQixDQUFDO0FBQ3RDLENBQUE7OyJ9