19
node_modules/vitest/dist/chunks/environments-node.vcoXCoKs.js
generated
vendored
Normal file
19
node_modules/vitest/dist/chunks/environments-node.vcoXCoKs.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { NodeSnapshotEnvironment } from '@vitest/snapshot/environment';
|
||||
import 'pathe';
|
||||
import '@vitest/runner/utils';
|
||||
import '@vitest/utils';
|
||||
import { g as getWorkerState } from '../vendor/global.CkGT_TMy.js';
|
||||
import '../vendor/env.AtSIuHFg.js';
|
||||
import 'std-env';
|
||||
|
||||
class VitestNodeSnapshotEnvironment extends NodeSnapshotEnvironment {
|
||||
getHeader() {
|
||||
return `// Vitest Snapshot v${this.getVersion()}, https://vitest.dev/guide/snapshot.html`;
|
||||
}
|
||||
resolvePath(filepath) {
|
||||
const rpc = getWorkerState().rpc;
|
||||
return rpc.resolveSnapshotPath(filepath);
|
||||
}
|
||||
}
|
||||
|
||||
export { VitestNodeSnapshotEnvironment };
|
||||
319
node_modules/vitest/dist/chunks/install-pkg.LE8oaA1t.js
generated
vendored
Normal file
319
node_modules/vitest/dist/chunks/install-pkg.LE8oaA1t.js
generated
vendored
Normal file
@@ -0,0 +1,319 @@
|
||||
import require$$0, { promises } from 'fs';
|
||||
import p from 'path';
|
||||
import process from 'process';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { execa } from 'execa';
|
||||
|
||||
var __defProp = Object.defineProperty;
|
||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||
var __publicField = (obj, key, value) => {
|
||||
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
||||
return value;
|
||||
};
|
||||
var __accessCheck = (obj, member, msg) => {
|
||||
if (!member.has(obj))
|
||||
throw TypeError("Cannot " + msg);
|
||||
};
|
||||
var __privateGet = (obj, member, getter) => {
|
||||
__accessCheck(obj, member, "read from private field");
|
||||
return getter ? getter.call(obj) : member.get(obj);
|
||||
};
|
||||
var __privateAdd = (obj, member, value) => {
|
||||
if (member.has(obj))
|
||||
throw TypeError("Cannot add the same private member more than once");
|
||||
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
||||
};
|
||||
var __privateSet = (obj, member, value, setter) => {
|
||||
__accessCheck(obj, member, "write to private field");
|
||||
setter ? setter.call(obj, value) : member.set(obj, value);
|
||||
return value;
|
||||
};
|
||||
var __privateWrapper = (obj, member, setter, getter) => ({
|
||||
set _(value) {
|
||||
__privateSet(obj, member, value, setter);
|
||||
},
|
||||
get _() {
|
||||
return __privateGet(obj, member, getter);
|
||||
}
|
||||
});
|
||||
|
||||
// node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
|
||||
var Node = class {
|
||||
constructor(value) {
|
||||
__publicField(this, "value");
|
||||
__publicField(this, "next");
|
||||
this.value = value;
|
||||
}
|
||||
};
|
||||
var _head, _tail, _size;
|
||||
var Queue = class {
|
||||
constructor() {
|
||||
__privateAdd(this, _head, void 0);
|
||||
__privateAdd(this, _tail, void 0);
|
||||
__privateAdd(this, _size, void 0);
|
||||
this.clear();
|
||||
}
|
||||
enqueue(value) {
|
||||
const node = new Node(value);
|
||||
if (__privateGet(this, _head)) {
|
||||
__privateGet(this, _tail).next = node;
|
||||
__privateSet(this, _tail, node);
|
||||
} else {
|
||||
__privateSet(this, _head, node);
|
||||
__privateSet(this, _tail, node);
|
||||
}
|
||||
__privateWrapper(this, _size)._++;
|
||||
}
|
||||
dequeue() {
|
||||
const current = __privateGet(this, _head);
|
||||
if (!current) {
|
||||
return;
|
||||
}
|
||||
__privateSet(this, _head, __privateGet(this, _head).next);
|
||||
__privateWrapper(this, _size)._--;
|
||||
return current.value;
|
||||
}
|
||||
clear() {
|
||||
__privateSet(this, _head, void 0);
|
||||
__privateSet(this, _tail, void 0);
|
||||
__privateSet(this, _size, 0);
|
||||
}
|
||||
get size() {
|
||||
return __privateGet(this, _size);
|
||||
}
|
||||
*[Symbol.iterator]() {
|
||||
let current = __privateGet(this, _head);
|
||||
while (current) {
|
||||
yield current.value;
|
||||
current = current.next;
|
||||
}
|
||||
}
|
||||
};
|
||||
_head = new WeakMap();
|
||||
_tail = new WeakMap();
|
||||
_size = new WeakMap();
|
||||
|
||||
// node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
|
||||
function pLimit(concurrency) {
|
||||
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
||||
throw new TypeError("Expected `concurrency` to be a number from 1 and up");
|
||||
}
|
||||
const queue = new Queue();
|
||||
let activeCount = 0;
|
||||
const next = () => {
|
||||
activeCount--;
|
||||
if (queue.size > 0) {
|
||||
queue.dequeue()();
|
||||
}
|
||||
};
|
||||
const run = async (fn, resolve, args) => {
|
||||
activeCount++;
|
||||
const result = (async () => fn(...args))();
|
||||
resolve(result);
|
||||
try {
|
||||
await result;
|
||||
} catch {
|
||||
}
|
||||
next();
|
||||
};
|
||||
const enqueue = (fn, resolve, args) => {
|
||||
queue.enqueue(run.bind(void 0, fn, resolve, args));
|
||||
(async () => {
|
||||
await Promise.resolve();
|
||||
if (activeCount < concurrency && queue.size > 0) {
|
||||
queue.dequeue()();
|
||||
}
|
||||
})();
|
||||
};
|
||||
const generator = (fn, ...args) => new Promise((resolve) => {
|
||||
enqueue(fn, resolve, args);
|
||||
});
|
||||
Object.defineProperties(generator, {
|
||||
activeCount: {
|
||||
get: () => activeCount
|
||||
},
|
||||
pendingCount: {
|
||||
get: () => queue.size
|
||||
},
|
||||
clearQueue: {
|
||||
value: () => {
|
||||
queue.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
return generator;
|
||||
}
|
||||
|
||||
// node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js
|
||||
var EndError = class extends Error {
|
||||
constructor(value) {
|
||||
super();
|
||||
this.value = value;
|
||||
}
|
||||
};
|
||||
var testElement = async (element, tester) => tester(await element);
|
||||
var finder = async (element) => {
|
||||
const values = await Promise.all(element);
|
||||
if (values[1] === true) {
|
||||
throw new EndError(values[0]);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
async function pLocate(iterable, tester, {
|
||||
concurrency = Number.POSITIVE_INFINITY,
|
||||
preserveOrder = true
|
||||
} = {}) {
|
||||
const limit = pLimit(concurrency);
|
||||
const items = [...iterable].map((element) => [element, limit(testElement, element, tester)]);
|
||||
const checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);
|
||||
try {
|
||||
await Promise.all(items.map((element) => checkLimit(finder, element)));
|
||||
} catch (error) {
|
||||
if (error instanceof EndError) {
|
||||
return error.value;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js
|
||||
var typeMappings = {
|
||||
directory: "isDirectory",
|
||||
file: "isFile"
|
||||
};
|
||||
function checkType(type) {
|
||||
if (Object.hasOwnProperty.call(typeMappings, type)) {
|
||||
return;
|
||||
}
|
||||
throw new Error(`Invalid type specified: ${type}`);
|
||||
}
|
||||
var matchType = (type, stat) => stat[typeMappings[type]]();
|
||||
var toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
||||
async function locatePath(paths, {
|
||||
cwd = process.cwd(),
|
||||
type = "file",
|
||||
allowSymlinks = true,
|
||||
concurrency,
|
||||
preserveOrder
|
||||
} = {}) {
|
||||
checkType(type);
|
||||
cwd = toPath(cwd);
|
||||
const statFunction = allowSymlinks ? promises.stat : promises.lstat;
|
||||
return pLocate(paths, async (path_) => {
|
||||
try {
|
||||
const stat = await statFunction(p.resolve(cwd, path_));
|
||||
return matchType(type, stat);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}, { concurrency, preserveOrder });
|
||||
}
|
||||
function toPath2(urlOrPath) {
|
||||
return urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
||||
}
|
||||
|
||||
// node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
|
||||
var findUpStop = Symbol("findUpStop");
|
||||
async function findUpMultiple(name, options = {}) {
|
||||
let directory = p.resolve(toPath2(options.cwd) ?? "");
|
||||
const { root } = p.parse(directory);
|
||||
const stopAt = p.resolve(directory, toPath2(options.stopAt ?? root));
|
||||
const limit = options.limit ?? Number.POSITIVE_INFINITY;
|
||||
const paths = [name].flat();
|
||||
const runMatcher = async (locateOptions) => {
|
||||
if (typeof name !== "function") {
|
||||
return locatePath(paths, locateOptions);
|
||||
}
|
||||
const foundPath = await name(locateOptions.cwd);
|
||||
if (typeof foundPath === "string") {
|
||||
return locatePath([foundPath], locateOptions);
|
||||
}
|
||||
return foundPath;
|
||||
};
|
||||
const matches = [];
|
||||
while (true) {
|
||||
const foundPath = await runMatcher({ ...options, cwd: directory });
|
||||
if (foundPath === findUpStop) {
|
||||
break;
|
||||
}
|
||||
if (foundPath) {
|
||||
matches.push(p.resolve(directory, foundPath));
|
||||
}
|
||||
if (directory === stopAt || matches.length >= limit) {
|
||||
break;
|
||||
}
|
||||
directory = p.dirname(directory);
|
||||
}
|
||||
return matches;
|
||||
}
|
||||
async function findUp(name, options = {}) {
|
||||
const matches = await findUpMultiple(name, { ...options, limit: 1 });
|
||||
return matches[0];
|
||||
}
|
||||
|
||||
// src/detect.ts
|
||||
var AGENTS = ["pnpm", "yarn", "npm", "pnpm@6", "yarn@berry", "bun"];
|
||||
var LOCKS = {
|
||||
"bun.lockb": "bun",
|
||||
"pnpm-lock.yaml": "pnpm",
|
||||
"yarn.lock": "yarn",
|
||||
"package-lock.json": "npm",
|
||||
"npm-shrinkwrap.json": "npm"
|
||||
};
|
||||
async function detectPackageManager(cwd = process.cwd()) {
|
||||
let agent = null;
|
||||
const lockPath = await findUp(Object.keys(LOCKS), { cwd });
|
||||
let packageJsonPath;
|
||||
if (lockPath)
|
||||
packageJsonPath = p.resolve(lockPath, "../package.json");
|
||||
else
|
||||
packageJsonPath = await findUp("package.json", { cwd });
|
||||
if (packageJsonPath && require$$0.existsSync(packageJsonPath)) {
|
||||
try {
|
||||
const pkg = JSON.parse(require$$0.readFileSync(packageJsonPath, "utf8"));
|
||||
if (typeof pkg.packageManager === "string") {
|
||||
const [name, version] = pkg.packageManager.split("@");
|
||||
if (name === "yarn" && Number.parseInt(version) > 1)
|
||||
agent = "yarn@berry";
|
||||
else if (name === "pnpm" && Number.parseInt(version) < 7)
|
||||
agent = "pnpm@6";
|
||||
else if (AGENTS.includes(name))
|
||||
agent = name;
|
||||
else
|
||||
console.warn("[ni] Unknown packageManager:", pkg.packageManager);
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
if (!agent && lockPath)
|
||||
agent = LOCKS[p.basename(lockPath)];
|
||||
return agent;
|
||||
}
|
||||
async function installPackage(names, options = {}) {
|
||||
const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
|
||||
const [agent] = detectedAgent.split("@");
|
||||
if (!Array.isArray(names))
|
||||
names = [names];
|
||||
const args = options.additionalArgs || [];
|
||||
if (options.preferOffline) {
|
||||
if (detectedAgent === "yarn@berry")
|
||||
args.unshift("--cached");
|
||||
else
|
||||
args.unshift("--prefer-offline");
|
||||
}
|
||||
return execa(
|
||||
agent,
|
||||
[
|
||||
agent === "yarn" ? "add" : "install",
|
||||
options.dev ? "-D" : "",
|
||||
...args,
|
||||
...names
|
||||
].filter(Boolean),
|
||||
{
|
||||
stdio: options.silent ? "ignore" : "inherit",
|
||||
cwd: options.cwd
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export { detectPackageManager, installPackage };
|
||||
31
node_modules/vitest/dist/chunks/integrations-globals.kw4co3rx.js
generated
vendored
Normal file
31
node_modules/vitest/dist/chunks/integrations-globals.kw4co3rx.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import { g as globalApis } from '../vendor/constants.5J7I254_.js';
|
||||
import { V as VitestIndex } from '../vendor/index.dI9lHwVn.js';
|
||||
import '@vitest/runner';
|
||||
import '../vendor/benchmark.yGkUTKnC.js';
|
||||
import '@vitest/runner/utils';
|
||||
import '@vitest/utils';
|
||||
import '../vendor/index.SMVOaj7F.js';
|
||||
import 'pathe';
|
||||
import '../vendor/global.CkGT_TMy.js';
|
||||
import '../vendor/env.AtSIuHFg.js';
|
||||
import 'std-env';
|
||||
import '../vendor/run-once.Olz_Zkd8.js';
|
||||
import '../vendor/vi.YFlodzP_.js';
|
||||
import 'chai';
|
||||
import '../vendor/_commonjsHelpers.jjO7Zipk.js';
|
||||
import '@vitest/expect';
|
||||
import '@vitest/snapshot';
|
||||
import '@vitest/utils/error';
|
||||
import '../vendor/tasks.IknbGB2n.js';
|
||||
import '@vitest/utils/source-map';
|
||||
import '../vendor/base.5NT-gWu5.js';
|
||||
import '../vendor/date.Ns1pGd_X.js';
|
||||
import '@vitest/spy';
|
||||
|
||||
function registerApiGlobally() {
|
||||
globalApis.forEach((api) => {
|
||||
globalThis[api] = VitestIndex[api];
|
||||
});
|
||||
}
|
||||
|
||||
export { registerApiGlobally };
|
||||
70
node_modules/vitest/dist/chunks/node-git.Hw101KjS.js
generated
vendored
Normal file
70
node_modules/vitest/dist/chunks/node-git.Hw101KjS.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
import { resolve } from 'pathe';
|
||||
import { execa } from 'execa';
|
||||
|
||||
class VitestGit {
|
||||
constructor(cwd) {
|
||||
this.cwd = cwd;
|
||||
}
|
||||
root;
|
||||
async resolveFilesWithGitCommand(args) {
|
||||
let result;
|
||||
try {
|
||||
result = await execa("git", args, { cwd: this.root });
|
||||
} catch (e) {
|
||||
e.message = e.stderr;
|
||||
throw e;
|
||||
}
|
||||
return result.stdout.split("\n").filter((s) => s !== "").map((changedPath) => resolve(this.root, changedPath));
|
||||
}
|
||||
async findChangedFiles(options) {
|
||||
const root = await this.getRoot(this.cwd);
|
||||
if (!root)
|
||||
return null;
|
||||
this.root = root;
|
||||
const changedSince = options.changedSince;
|
||||
if (typeof changedSince === "string") {
|
||||
const [committed, staged2, unstaged2] = await Promise.all([
|
||||
this.getFilesSince(changedSince),
|
||||
this.getStagedFiles(),
|
||||
this.getUnstagedFiles()
|
||||
]);
|
||||
return [...committed, ...staged2, ...unstaged2];
|
||||
}
|
||||
const [staged, unstaged] = await Promise.all([
|
||||
this.getStagedFiles(),
|
||||
this.getUnstagedFiles()
|
||||
]);
|
||||
return [...staged, ...unstaged];
|
||||
}
|
||||
getFilesSince(hash) {
|
||||
return this.resolveFilesWithGitCommand(
|
||||
["diff", "--name-only", `${hash}...HEAD`]
|
||||
);
|
||||
}
|
||||
getStagedFiles() {
|
||||
return this.resolveFilesWithGitCommand(
|
||||
["diff", "--cached", "--name-only"]
|
||||
);
|
||||
}
|
||||
getUnstagedFiles() {
|
||||
return this.resolveFilesWithGitCommand(
|
||||
[
|
||||
"ls-files",
|
||||
"--other",
|
||||
"--modified",
|
||||
"--exclude-standard"
|
||||
]
|
||||
);
|
||||
}
|
||||
async getRoot(cwd) {
|
||||
const options = ["rev-parse", "--show-cdup"];
|
||||
try {
|
||||
const result = await execa("git", options, { cwd });
|
||||
return resolve(cwd, result.stdout);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { VitestGit };
|
||||
131
node_modules/vitest/dist/chunks/runtime-console.EO5ha7qv.js
generated
vendored
Normal file
131
node_modules/vitest/dist/chunks/runtime-console.EO5ha7qv.js
generated
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
import { Writable } from 'node:stream';
|
||||
import { Console } from 'node:console';
|
||||
import { relative } from 'node:path';
|
||||
import { getSafeTimers, getColors } from '@vitest/utils';
|
||||
import { R as RealDate } from '../vendor/date.Ns1pGd_X.js';
|
||||
import 'pathe';
|
||||
import '@vitest/runner/utils';
|
||||
import { g as getWorkerState } from '../vendor/global.CkGT_TMy.js';
|
||||
import '../vendor/env.AtSIuHFg.js';
|
||||
import 'std-env';
|
||||
|
||||
const UNKNOWN_TEST_ID = "__vitest__unknown_test__";
|
||||
function getTaskIdByStack(root) {
|
||||
var _a, _b;
|
||||
const stack = (_a = new Error("STACK_TRACE_ERROR").stack) == null ? void 0 : _a.split("\n");
|
||||
if (!stack)
|
||||
return UNKNOWN_TEST_ID;
|
||||
const index = stack.findIndex((line2) => line2.includes("at Console.value"));
|
||||
const line = index === -1 ? null : stack[index + 2];
|
||||
if (!line)
|
||||
return UNKNOWN_TEST_ID;
|
||||
const filepath = (_b = line.match(/at\s(.*)\s?/)) == null ? void 0 : _b[1];
|
||||
if (filepath)
|
||||
return relative(root, filepath);
|
||||
return UNKNOWN_TEST_ID;
|
||||
}
|
||||
function createCustomConsole() {
|
||||
const stdoutBuffer = /* @__PURE__ */ new Map();
|
||||
const stderrBuffer = /* @__PURE__ */ new Map();
|
||||
const timers = /* @__PURE__ */ new Map();
|
||||
const { setTimeout, clearTimeout } = getSafeTimers();
|
||||
const state = () => getWorkerState();
|
||||
function schedule(taskId) {
|
||||
const timer = timers.get(taskId);
|
||||
const { stdoutTime, stderrTime } = timer;
|
||||
clearTimeout(timer.timer);
|
||||
timer.timer = setTimeout(() => {
|
||||
if (stderrTime < stdoutTime) {
|
||||
sendStderr(taskId);
|
||||
sendStdout(taskId);
|
||||
} else {
|
||||
sendStdout(taskId);
|
||||
sendStderr(taskId);
|
||||
}
|
||||
});
|
||||
}
|
||||
function sendStdout(taskId) {
|
||||
const buffer = stdoutBuffer.get(taskId);
|
||||
if (!buffer)
|
||||
return;
|
||||
const content = buffer.map((i) => String(i)).join("");
|
||||
const timer = timers.get(taskId);
|
||||
state().rpc.onUserConsoleLog({
|
||||
type: "stdout",
|
||||
content: content || "<empty line>",
|
||||
taskId,
|
||||
time: timer.stdoutTime || RealDate.now(),
|
||||
size: buffer.length
|
||||
});
|
||||
stdoutBuffer.set(taskId, []);
|
||||
timer.stdoutTime = 0;
|
||||
}
|
||||
function sendStderr(taskId) {
|
||||
const buffer = stderrBuffer.get(taskId);
|
||||
if (!buffer)
|
||||
return;
|
||||
const content = buffer.map((i) => String(i)).join("");
|
||||
const timer = timers.get(taskId);
|
||||
state().rpc.onUserConsoleLog({
|
||||
type: "stderr",
|
||||
content: content || "<empty line>",
|
||||
taskId,
|
||||
time: timer.stderrTime || RealDate.now(),
|
||||
size: buffer.length
|
||||
});
|
||||
stderrBuffer.set(taskId, []);
|
||||
timer.stderrTime = 0;
|
||||
}
|
||||
const stdout = new Writable({
|
||||
write(data, encoding, callback) {
|
||||
var _a, _b, _c;
|
||||
const s = state();
|
||||
const id = ((_a = s == null ? void 0 : s.current) == null ? void 0 : _a.id) || ((_c = (_b = s == null ? void 0 : s.current) == null ? void 0 : _b.file) == null ? void 0 : _c.id) || getTaskIdByStack(s.config.root);
|
||||
let timer = timers.get(id);
|
||||
if (timer) {
|
||||
timer.stdoutTime = timer.stdoutTime || RealDate.now();
|
||||
} else {
|
||||
timer = { stdoutTime: RealDate.now(), stderrTime: RealDate.now(), timer: 0 };
|
||||
timers.set(id, timer);
|
||||
}
|
||||
let buffer = stdoutBuffer.get(id);
|
||||
if (!buffer) {
|
||||
buffer = [];
|
||||
stdoutBuffer.set(id, buffer);
|
||||
}
|
||||
buffer.push(data);
|
||||
schedule(id);
|
||||
callback();
|
||||
}
|
||||
});
|
||||
const stderr = new Writable({
|
||||
write(data, encoding, callback) {
|
||||
var _a, _b, _c;
|
||||
const s = state();
|
||||
const id = ((_a = s == null ? void 0 : s.current) == null ? void 0 : _a.id) || ((_c = (_b = s == null ? void 0 : s.current) == null ? void 0 : _b.file) == null ? void 0 : _c.id) || getTaskIdByStack(s.config.root);
|
||||
let timer = timers.get(id);
|
||||
if (timer) {
|
||||
timer.stderrTime = timer.stderrTime || RealDate.now();
|
||||
} else {
|
||||
timer = { stderrTime: RealDate.now(), stdoutTime: RealDate.now(), timer: 0 };
|
||||
timers.set(id, timer);
|
||||
}
|
||||
let buffer = stderrBuffer.get(id);
|
||||
if (!buffer) {
|
||||
buffer = [];
|
||||
stderrBuffer.set(id, buffer);
|
||||
}
|
||||
buffer.push(data);
|
||||
schedule(id);
|
||||
callback();
|
||||
}
|
||||
});
|
||||
return new Console({
|
||||
stdout,
|
||||
stderr,
|
||||
colorMode: getColors().isColorSupported,
|
||||
groupIndentation: 2
|
||||
});
|
||||
}
|
||||
|
||||
export { UNKNOWN_TEST_ID, createCustomConsole };
|
||||
125
node_modules/vitest/dist/chunks/runtime-runBaseTests.oAvMKtQC.js
generated
vendored
Normal file
125
node_modules/vitest/dist/chunks/runtime-runBaseTests.oAvMKtQC.js
generated
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
import { performance } from 'node:perf_hooks';
|
||||
import { startTests } from '@vitest/runner';
|
||||
import 'pathe';
|
||||
import '@vitest/runner/utils';
|
||||
import { setupColors, createColors, getSafeTimers } from '@vitest/utils';
|
||||
import { g as getWorkerState } from '../vendor/global.CkGT_TMy.js';
|
||||
import '../vendor/env.AtSIuHFg.js';
|
||||
import { a as globalExpect, r as resetModules, v as vi } from '../vendor/vi.YFlodzP_.js';
|
||||
import { a as startCoverageInsideWorker, s as stopCoverageInsideWorker } from '../vendor/coverage.E7sG1b3r.js';
|
||||
import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from '../vendor/index.DpVgvm2P.js';
|
||||
import { createRequire } from 'node:module';
|
||||
import util from 'node:util';
|
||||
import timers from 'node:timers';
|
||||
import { isatty } from 'node:tty';
|
||||
import { installSourcemapsSupport } from 'vite-node/source-map';
|
||||
import { V as VitestIndex } from '../vendor/index.dI9lHwVn.js';
|
||||
import { s as setupCommonEnv } from '../vendor/setup-common.8nJLd4ay.js';
|
||||
import { c as closeInspector } from '../vendor/inspector.IgLX3ur5.js';
|
||||
import 'std-env';
|
||||
import 'chai';
|
||||
import '../vendor/_commonjsHelpers.jjO7Zipk.js';
|
||||
import '@vitest/expect';
|
||||
import '@vitest/snapshot';
|
||||
import '@vitest/utils/error';
|
||||
import '../vendor/tasks.IknbGB2n.js';
|
||||
import '@vitest/utils/source-map';
|
||||
import '../vendor/base.5NT-gWu5.js';
|
||||
import '../vendor/date.Ns1pGd_X.js';
|
||||
import '@vitest/spy';
|
||||
import '../path.js';
|
||||
import 'node:url';
|
||||
import '../vendor/rpc.joBhAkyK.js';
|
||||
import '../vendor/index.8bPxjt7g.js';
|
||||
import '../vendor/benchmark.yGkUTKnC.js';
|
||||
import '../vendor/index.SMVOaj7F.js';
|
||||
import '../vendor/run-once.Olz_Zkd8.js';
|
||||
|
||||
let globalSetup = false;
|
||||
async function setupGlobalEnv(config, { environment }, executor) {
|
||||
await setupCommonEnv(config);
|
||||
Object.defineProperty(globalThis, "__vitest_index__", {
|
||||
value: VitestIndex,
|
||||
enumerable: false
|
||||
});
|
||||
const state = getWorkerState();
|
||||
if (!state.config.snapshotOptions.snapshotEnvironment)
|
||||
state.config.snapshotOptions.snapshotEnvironment = await resolveSnapshotEnvironment(config, executor);
|
||||
if (globalSetup)
|
||||
return;
|
||||
globalSetup = true;
|
||||
setupColors(createColors(isatty(1)));
|
||||
if (environment.transformMode === "web") {
|
||||
const _require = createRequire(import.meta.url);
|
||||
_require.extensions[".css"] = () => ({});
|
||||
_require.extensions[".scss"] = () => ({});
|
||||
_require.extensions[".sass"] = () => ({});
|
||||
_require.extensions[".less"] = () => ({});
|
||||
process.env.SSR = "";
|
||||
} else {
|
||||
process.env.SSR = "1";
|
||||
}
|
||||
globalThis.__vitest_required__ = {
|
||||
util,
|
||||
timers
|
||||
};
|
||||
installSourcemapsSupport({
|
||||
getSourceMap: (source) => state.moduleCache.getSourceMap(source)
|
||||
});
|
||||
if (!config.disableConsoleIntercept)
|
||||
await setupConsoleLogSpy();
|
||||
}
|
||||
async function setupConsoleLogSpy() {
|
||||
const { createCustomConsole } = await import('./runtime-console.EO5ha7qv.js');
|
||||
globalThis.console = createCustomConsole();
|
||||
}
|
||||
async function withEnv({ environment }, options, fn) {
|
||||
globalThis.__vitest_environment__ = environment.name;
|
||||
globalExpect.setState({
|
||||
environment: environment.name
|
||||
});
|
||||
const env = await environment.setup(globalThis, options);
|
||||
try {
|
||||
await fn();
|
||||
} finally {
|
||||
const { setTimeout } = getSafeTimers();
|
||||
await new Promise((resolve) => setTimeout(resolve));
|
||||
await env.teardown(globalThis);
|
||||
}
|
||||
}
|
||||
|
||||
async function run(files, config, environment, executor) {
|
||||
const workerState = getWorkerState();
|
||||
await setupGlobalEnv(config, environment, executor);
|
||||
await startCoverageInsideWorker(config.coverage, executor);
|
||||
if (config.chaiConfig)
|
||||
setupChaiConfig(config.chaiConfig);
|
||||
const runner = await resolveTestRunner(config, executor);
|
||||
workerState.onCancel.then((reason) => {
|
||||
var _a;
|
||||
closeInspector(config);
|
||||
(_a = runner.onCancel) == null ? void 0 : _a.call(runner, reason);
|
||||
});
|
||||
workerState.durations.prepare = performance.now() - workerState.durations.prepare;
|
||||
workerState.durations.environment = performance.now();
|
||||
await withEnv(environment, environment.options || config.environmentOptions || {}, async () => {
|
||||
var _a, _b, _c, _d;
|
||||
workerState.durations.environment = performance.now() - workerState.durations.environment;
|
||||
for (const file of files) {
|
||||
const isIsolatedThreads = config.pool === "threads" && (((_b = (_a = config.poolOptions) == null ? void 0 : _a.threads) == null ? void 0 : _b.isolate) ?? true);
|
||||
const isIsolatedForks = config.pool === "forks" && (((_d = (_c = config.poolOptions) == null ? void 0 : _c.forks) == null ? void 0 : _d.isolate) ?? true);
|
||||
if (isIsolatedThreads || isIsolatedForks) {
|
||||
workerState.mockMap.clear();
|
||||
resetModules(workerState.moduleCache, true);
|
||||
}
|
||||
workerState.filepath = file;
|
||||
await startTests([file], runner);
|
||||
vi.resetConfig();
|
||||
vi.restoreAllMocks();
|
||||
}
|
||||
await stopCoverageInsideWorker(config.coverage, executor);
|
||||
});
|
||||
workerState.environmentTeardownRun = true;
|
||||
}
|
||||
|
||||
export { run };
|
||||
Reference in New Issue
Block a user