import { FetchResult, ViteNodeResolveId, RawSourceMap, ModuleCacheMap } from 'vite-node'; import { File, TaskResultPack, CancelReason, Task } from '@vitest/runner'; import { S as SerializedConfig } from './config.Crbj2GAb.js'; import { SnapshotResult } from '@vitest/snapshot'; import { T as TransformMode, U as UserConsoleLog, A as AfterSuiteRunMeta, E as Environment } from './environment.CzISCQ7o.js'; interface RuntimeRPC { fetch: (id: string, transformMode: TransformMode) => Promise<{ externalize?: string; id?: string; }>; transform: (id: string, transformMode: TransformMode) => Promise; resolveId: (id: string, importer: string | undefined, transformMode: TransformMode) => Promise; getSourceMap: (id: string, force?: boolean) => Promise; onFinished: (files: File[], errors?: unknown[]) => void; onPathsCollected: (paths: string[]) => void; onUserConsoleLog: (log: UserConsoleLog) => void; onUnhandledError: (err: unknown, type: string) => void; onCollected: (files: File[]) => Promise; onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void; onTaskUpdate: (pack: TaskResultPack[]) => Promise; onCancel: (reason: CancelReason) => void; getCountOfFailedTests: () => number; snapshotSaved: (snapshot: SnapshotResult) => void; resolveSnapshotPath: (testPath: string) => string; } interface RunnerRPC { onCancel: (reason: CancelReason) => void; } type ArgumentsType = T extends (...args: infer A) => any ? A : never; type ReturnType = T extends (...args: any) => infer R ? R : never; type PromisifyFn = ReturnType extends Promise ? T : (...args: ArgumentsType) => Promise>>; type BirpcResolver = (name: string, resolved: (...args: unknown[]) => unknown) => ((...args: unknown[]) => unknown) | undefined; interface ChannelOptions { /** * Function to post raw message */ post: (data: any, ...extras: any[]) => any | Promise; /** * Listener to receive raw message */ on: (fn: (data: any, ...extras: any[]) => void) => any | Promise; /** * Custom function to serialize data * * by default it passes the data as-is */ serialize?: (data: any) => any; /** * Custom function to deserialize data * * by default it passes the data as-is */ deserialize?: (data: any) => any; } interface EventOptions { /** * Names of remote functions that do not need response. */ eventNames?: (keyof Remote)[]; /** * Maximum timeout for waiting for response, in milliseconds. * * @default 60_000 */ timeout?: number; /** * Custom resolver to resolve function to be called * * For advanced use cases only */ resolver?: BirpcResolver; /** * Custom error handler */ onError?: (error: Error, functionName: string, args: any[]) => boolean | void; /** * Custom error handler for timeouts */ onTimeoutError?: (functionName: string, args: any[]) => boolean | void; } type BirpcOptions = EventOptions & ChannelOptions; type BirpcFn = PromisifyFn & { /** * Send event without asking for response */ asEvent: (...args: ArgumentsType) => void; }; type BirpcReturn> = { [K in keyof RemoteFunctions]: BirpcFn; } & { $functions: LocalFunctions; }; /** @deprecated unused */ type ResolveIdFunction = (id: string, importer?: string) => Promise; type WorkerRPC = BirpcReturn; interface ContextTestEnvironment { name: string; transformMode?: TransformMode; options: Record | null; } interface ContextRPC { pool: string; worker: string; workerId: number; config: SerializedConfig; projectName: string; files: string[]; environment: ContextTestEnvironment; providedContext: Record; invalidates?: string[]; } interface WorkerGlobalState { ctx: ContextRPC; config: SerializedConfig; rpc: WorkerRPC; current?: Task; filepath?: string; environment: Environment; environmentTeardownRun?: boolean; onCancel: Promise; moduleCache: ModuleCacheMap; providedContext: Record; durations: { environment: number; prepare: number; }; } export type { BirpcOptions as B, ContextRPC as C, RuntimeRPC as R, WorkerGlobalState as W, BirpcReturn as a, RunnerRPC as b, ResolveIdFunction as c, WorkerRPC as d, ContextTestEnvironment as e };