forked from vitest-dev/vitest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
worker.ts
29 lines (24 loc) · 991 Bytes
/
worker.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import type { MessagePort } from 'worker_threads'
import type { FetchFunction, RawSourceMap, ViteNodeResolveId } from 'vite-node'
import type { ResolvedConfig } from './config'
import type { File, TaskResultPack } from './tasks'
import type { SnapshotResult } from './snapshot'
import type { UserConsoleLog } from './general'
export interface WorkerContext {
port: MessagePort
config: ResolvedConfig
files: string[]
invalidates?: string[]
}
export type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>
export interface WorkerRPC {
fetch: FetchFunction
resolveId: ResolveIdFunction
getSourceMap: (id: string, force?: boolean) => Promise<RawSourceMap | undefined>
onFinished: (files: File[]) => void
onWorkerExit: (code?: number) => void
onUserConsoleLog: (log: UserConsoleLog) => void
onCollected: (files: File[]) => void
onTaskUpdate: (pack: TaskResultPack[]) => void
snapshotSaved: (snapshot: SnapshotResult) => void
}