Debian Codegraph @

new/packages/terser/src/type.ts

raw
1 import type { AsyncResource } from 'async_hooks';
2 import type { Worker } from 'worker_threads';
3
4 import type { MinifyOptions } from 'terser';
5
6 import type { taskInfo } from './constants';
7
8 export interface Options extends MinifyOptions {
9 nameCache?: Record<string, any>;
10 maxWorkers?: number;
11 }
12
13 export interface WorkerContext {
14 code: string;
15 options: Options;
16 }
17
18 export type WorkerCallback = (err: Error | null, output?: WorkerOutput) => void;
19
20 interface WorkerPoolTaskInfo extends AsyncResource {
21 done(err: Error | null, result: any): void;
22 }
23
24 export type WorkerWithTaskInfo = Worker & { [taskInfo]?: WorkerPoolTaskInfo | null };
25
26 export interface WorkerContextSerialized {
27 code: string;
28 options: string;
29 }
30
31 export interface WorkerOutput {
32 code: string;
33 nameCache?: Options['nameCache'];
34 sourceMap?: Record<string, any>;
35 }
36
37 export interface WorkerPoolOptions {
38 filePath: string;
39 maxWorkers?: number;
40 }
41
42 export interface WorkerPoolTask {
43 context: WorkerContext;
44 cb: WorkerCallback;
45 }