From 76cb9c2a39d477a64824a985ade40507e3bbade1 Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Fri, 13 Feb 2026 21:34:48 -0800 Subject: feat(vanilla): add testing infrastructure and tests (NK-wjnczv) --- .../vitest/dist/chunks/worker.d.Dyxm8DEL.d.ts | 255 +++++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 vanilla/node_modules/vitest/dist/chunks/worker.d.Dyxm8DEL.d.ts (limited to 'vanilla/node_modules/vitest/dist/chunks/worker.d.Dyxm8DEL.d.ts') diff --git a/vanilla/node_modules/vitest/dist/chunks/worker.d.Dyxm8DEL.d.ts b/vanilla/node_modules/vitest/dist/chunks/worker.d.Dyxm8DEL.d.ts new file mode 100644 index 0000000..3177880 --- /dev/null +++ b/vanilla/node_modules/vitest/dist/chunks/worker.d.Dyxm8DEL.d.ts @@ -0,0 +1,255 @@ +import { FileSpecification, Task, CancelReason } from '@vitest/runner'; +import { EvaluatedModules } from 'vite/module-runner'; +import { S as SerializedConfig } from './config.d.Cy95HiCx.js'; +import { E as Environment } from './environment.d.CrsxCzP1.js'; +import { R as RuntimeRPC, a as RunnerRPC } from './rpc.d.RH3apGEf.js'; + +//#region src/messages.d.ts +declare const TYPE_REQUEST: "q"; +interface RpcRequest { + /** + * Type + */ + t: typeof TYPE_REQUEST; + /** + * ID + */ + i?: string; + /** + * Method + */ + m: string; + /** + * Arguments + */ + a: any[]; + /** + * Optional + */ + o?: boolean; +} +//#endregion +//#region src/utils.d.ts +type ArgumentsType = T extends ((...args: infer A) => any) ? A : never; +type ReturnType = T extends ((...args: any) => infer R) ? R : never; +type Thenable = T | PromiseLike; +//#endregion +//#region src/main.d.ts +type PromisifyFn = ReturnType extends Promise ? T : (...args: ArgumentsType) => Promise>>; +type BirpcResolver = (this: This, name: string, resolved: (...args: unknown[]) => unknown) => Thenable<((...args: any[]) => any) | undefined>; +interface ChannelOptions { + /** + * Function to post raw message + */ + post: (data: any, ...extras: any[]) => Thenable; + /** + * Listener to receive raw message + */ + on: (fn: (data: any, ...extras: any[]) => void) => Thenable; + /** + * Clear the listener when `$close` is called + */ + off?: (fn: (data: any, ...extras: any[]) => void) => Thenable; + /** + * 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; + /** + * Call the methods with the RPC context or the original functions object + */ + bind?: 'rpc' | 'functions'; + /** + * Custom meta data to attached to the RPC instance's `$meta` property + */ + meta?: any; +} +interface EventOptions, LocalFunctions extends object = Record, Proxify extends boolean = true> { + /** + * Names of remote functions that do not need response. + */ + eventNames?: (keyof RemoteFunctions)[]; + /** + * Maximum timeout for waiting for response, in milliseconds. + * + * @default 60_000 + */ + timeout?: number; + /** + * Whether to proxy the remote functions. + * + * When `proxify` is false, calling the remote function + * with `rpc.$call('method', ...args)` instead of `rpc.method(...args)` + * explicitly is required. + * + * @default true + */ + proxify?: Proxify; + /** + * Custom resolver to resolve function to be called + * + * For advanced use cases only + */ + resolver?: BirpcResolver>; + /** + * Hook triggered before an event is sent to the remote + * + * @param req - Request parameters + * @param next - Function to continue the request + * @param resolve - Function to resolve the response directly + */ + onRequest?: (this: BirpcReturn, req: RpcRequest, next: (req?: RpcRequest) => Promise, resolve: (res: any) => void) => void | Promise; + /** + * Custom error handler for errors occurred in local functions being called + * + * @returns `true` to prevent the error from being thrown + */ + onFunctionError?: (this: BirpcReturn, error: Error, functionName: string, args: any[]) => boolean | void; + /** + * Custom error handler for errors occurred during serialization or messsaging + * + * @returns `true` to prevent the error from being thrown + */ + onGeneralError?: (this: BirpcReturn, error: Error, functionName?: string, args?: any[]) => boolean | void; + /** + * Custom error handler for timeouts + * + * @returns `true` to prevent the error from being thrown + */ + onTimeoutError?: (this: BirpcReturn, functionName: string, args: any[]) => boolean | void; +} +type BirpcOptions, LocalFunctions extends object = Record, Proxify extends boolean = true> = EventOptions & ChannelOptions; +type BirpcFn = PromisifyFn & { + /** + * Send event without asking for response + */ + asEvent: (...args: ArgumentsType) => Promise; +}; +interface BirpcReturnBuiltin> { + /** + * Raw functions object + */ + $functions: LocalFunctions; + /** + * Whether the RPC is closed + */ + readonly $closed: boolean; + /** + * Custom meta data attached to the RPC instance + */ + readonly $meta: any; + /** + * Close the RPC connection + */ + $close: (error?: Error) => void; + /** + * Reject pending calls + */ + $rejectPendingCalls: (handler?: PendingCallHandler) => Promise[]; + /** + * Call the remote function and wait for the result. + * An alternative to directly calling the function + */ + $call: (method: K$1, ...args: ArgumentsType) => Promise>>; + /** + * Same as `$call`, but returns `undefined` if the function is not defined on the remote side. + */ + $callOptional: (method: K$1, ...args: ArgumentsType) => Promise | undefined>>; + /** + * Send event without asking for response + */ + $callEvent: (method: K$1, ...args: ArgumentsType) => Promise; + /** + * Call the remote function with the raw options. + */ + $callRaw: (options: { + method: string; + args: unknown[]; + event?: boolean; + optional?: boolean; + }) => Promise>[]>; +} +type ProxifiedRemoteFunctions> = { [K in keyof RemoteFunctions]: BirpcFn }; +type BirpcReturn, LocalFunctions extends object = Record, Proxify extends boolean = true> = Proxify extends true ? ProxifiedRemoteFunctions & BirpcReturnBuiltin : BirpcReturnBuiltin; +type PendingCallHandler = (options: Pick) => void | Promise; +interface PromiseEntry { + resolve: (arg: any) => void; + reject: (error: any) => void; + method: string; + timeoutId?: ReturnType; +} +declare const setTimeout: typeof globalThis.setTimeout; + +type WorkerRPC = BirpcReturn; +interface ContextTestEnvironment { + name: string; + options: Record | null; +} +interface WorkerTestEnvironment { + name: string; + options: Record | null; +} +type TestExecutionMethod = "run" | "collect"; +interface WorkerExecuteContext { + files: FileSpecification[]; + providedContext: Record; + invalidates?: string[]; + environment: ContextTestEnvironment; + /** Exposed to test runner as `VITEST_WORKER_ID`. Value is unique per each isolated worker. */ + workerId: number; +} +interface ContextRPC { + pool: string; + config: SerializedConfig; + projectName: string; + environment: WorkerTestEnvironment; + rpc: WorkerRPC; + files: FileSpecification[]; + providedContext: Record; + invalidates?: string[]; + /** Exposed to test runner as `VITEST_WORKER_ID`. Value is unique per each isolated worker. */ + workerId: number; +} +interface WorkerSetupContext { + environment: WorkerTestEnvironment; + pool: string; + config: SerializedConfig; + projectName: string; + rpc: WorkerRPC; +} +interface WorkerGlobalState { + ctx: ContextRPC; + config: SerializedConfig; + rpc: WorkerRPC; + current?: Task; + filepath?: string; + metaEnv: { + [key: string]: any; + BASE_URL: string; + MODE: string; + DEV: boolean; + PROD: boolean; + SSR: boolean; + }; + environment: Environment; + evaluatedModules: EvaluatedModules; + resolvingModules: Set; + moduleExecutionInfo: Map; + onCancel: (listener: (reason: CancelReason) => unknown) => void; + onCleanup: (listener: () => unknown) => void; + providedContext: Record; + durations: { + environment: number; + prepare: number; + }; + onFilterStackTrace?: (trace: string) => string; +} + +export type { BirpcOptions as B, ContextRPC as C, TestExecutionMethod as T, WorkerGlobalState as W, WorkerSetupContext as a, BirpcReturn as b, ContextTestEnvironment as c, WorkerExecuteContext as d, WorkerTestEnvironment as e }; -- cgit v1.2.3