| 1 | /** |
| 2 | * Make all properties in T non-readonly |
| 3 | */ |
| 4 | export type Draft<T> = { -readonly [P in keyof T]?: T[P] } |
| 5 | |
| 6 | /** |
| 7 | * Serializable primitive JSON value. |
| 8 | */ |
| 9 | export type JSONPrimitive = number | boolean | string | null |
| 10 | /** |
| 11 | * Serializable JSON value. |
| 12 | */ |
| 13 | // eslint-disable-next-line no-use-before-define |
| 14 | export type JSONValue = JSONPrimitive | JSONArray | JSONObject |
| 15 | /** |
| 16 | * Serializable JSON object. |
| 17 | */ |
| 18 | export type JSONObject = { [k: string]: JSONValue } |
| 19 | /** |
| 20 | * Serializable JSON array. |
| 21 | */ |
| 22 | export type JSONArray = Array<JSONValue> |
| 23 | |
| 24 | /** |
| 25 | * Message object that is passed between worker and main worker. |
| 26 | */ |
| 27 | export interface MessageValue<Data = unknown> { |
| 28 | /** |
| 29 | * Input data that will be passed to the worker. |
| 30 | */ |
| 31 | readonly data?: Data |
| 32 | /** |
| 33 | * ID of the message. |
| 34 | */ |
| 35 | readonly id?: number |
| 36 | /** |
| 37 | * Kill code. |
| 38 | */ |
| 39 | readonly kill?: number |
| 40 | /** |
| 41 | * Error. |
| 42 | */ |
| 43 | readonly error?: string |
| 44 | /** |
| 45 | * Reference to main worker. |
| 46 | * |
| 47 | * _Only for internal use_ |
| 48 | */ |
| 49 | readonly parent?: MessagePort |
| 50 | } |