| 1 |
/** An event emitted by the child process. */ |
| 2 |
export type Event = StdoutEvent | StderrEvent | ExitEvent; |
| 3 |
/** An event sent from the worker to the host. */ |
| 4 |
export type InternalEvent = InternalStdoutEvent | InternalStderrEvent | ExitEvent | ErrorEvent; |
| 5 |
/** An event indicating that data has been emitted over stdout. */ |
| 6 |
export interface StdoutEvent { |
| 7 |
type: 'stdout'; |
| 8 |
data: Buffer; |
| 9 |
} |
| 10 |
/** An event indicating that data has been emitted over stderr. */ |
| 11 |
export interface StderrEvent { |
| 12 |
type: 'stderr'; |
| 13 |
data: Buffer; |
| 14 |
} |
| 15 |
/** An event indicating that process has exited. */ |
| 16 |
export interface ExitEvent { |
| 17 |
type: 'exit'; |
| 18 |
/** |
| 19 |
* The exit code. This will be `undefined` if the subprocess was killed via |
| 20 |
* signal. |
| 21 |
*/ |
| 22 |
code?: number; |
| 23 |
/** |
| 24 |
* The signal that caused this process to exit. This will be `undefined` if |
| 25 |
* the subprocess exited normally. |
| 26 |
*/ |
| 27 |
signal?: NodeJS.Signals; |
| 28 |
} |
| 29 |
/** |
| 30 |
* The stdout event sent from the worker to the host. The structured clone |
| 31 |
* algorithm automatically converts `Buffer`s sent through `MessagePort`s to |
| 32 |
* `Uint8Array`s. |
| 33 |
*/ |
| 34 |
export interface InternalStdoutEvent { |
| 35 |
type: 'stdout'; |
| 36 |
data: Buffer | Uint8Array; |
| 37 |
} |
| 38 |
/** |
| 39 |
* The stderr event sent from the worker to the host. The structured clone |
| 40 |
* algorithm automatically converts `Buffer`s sent through `MessagePort`s to |
| 41 |
* `Uint8Array`s. |
| 42 |
*/ |
| 43 |
export interface InternalStderrEvent { |
| 44 |
type: 'stderr'; |
| 45 |
data: Buffer | Uint8Array; |
| 46 |
} |
| 47 |
/** |
| 48 |
* An error occurred when starting or closing the child process. This is only |
| 49 |
* used internally; the host will throw the error rather than returning it to |
| 50 |
* the caller. |
| 51 |
*/ |
| 52 |
export interface ErrorEvent { |
| 53 |
type: 'error'; |
| 54 |
error: Error; |
| 55 |
} |