ipc.d.ts
This file
Path
types/ipc.d.ts
162 lines · 4.8 KiB · TypeScript
Last changed by
Fix `execaNode()` and the `node` option missing IPC in their typesSindre Sorhusbefore adoption2633abb
History of this fileTake it
Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 1–20why, one step back1import type {Options} from './arguments/options.js';23// Message when the `serialization` option is `'advanced'`4type AdvancedMessage =5 | string6 | number7 | boolean8 | null9 | object;1011// Message when the `serialization` option is `'json'`12type JsonMessage =13 | string14 | number15 | boolean16 | null17 | readonly JsonMessage[]18 | {readonly [key: string | number]: JsonMessage};1920/**Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 21why, one step back21Type of messages exchanged between a process and its subprocess using `sendMessage()`, `getOneMessage()` and `getEachMessage()`.Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 22–28why, one step back2223This requires the `ipc` option to be `true`. The type of `message` depends on the `serialization` option.24*/25export type Message<26 Serialization extends Options['serialization'] = Options['serialization'],27> = Serialization extends 'json' ? JsonMessage : AdvancedMessage;28Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052
line 29why, one step back29/**Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 30why, one step back30Options to `sendMessage()` and `subprocess.sendMessage()`Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052
line 31why, one step back31*/Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 32why, one step back32type SendMessageOptions = {Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052
line 33why, one step back33 /**Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
lines 34–36why, one step back34 Throw when the other process is not receiving or listening to messages.3536 @default falseAdd `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052
line 37why, one step back37 */Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 38why, one step back38 readonly strict?: boolean;Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052
lines 39–40why, one step back39};40Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 41–46why, one step back41// IPC methods in subprocess42/**43Send a `message` to the parent process.4445This requires the `ipc` option to be `true`. The type of `message` depends on the `serialization` option.46*/Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 47why, one step back47export function sendMessage(message: Message, sendMessageOptions?: SendMessageOptions): Promise<void>;Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 48–49why, one step back4849/**Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
lines 50–58why, one step back50Options to `getOneMessage()` and `subprocess.getOneMessage()`51*/52type GetOneMessageOptions<53 Serialization extends Options['serialization'],54> = {55 /**56 Ignore any `message` that returns `false`.57 */58 readonly filter?: (message: Message<Serialization>) => boolean;Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6
lines 59–65why, one step back5960 /**61 Keep the subprocess alive while `getOneMessage()` is waiting.6263 @default true64 */65 readonly reference?: boolean;Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
lines 66–68why, one step back66};6768/**Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 69–72why, one step back69Receive a single `message` from the parent process.7071This requires the `ipc` option to be `true`. The type of `message` depends on the `serialization` option.72*/Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052
line 73why, one step back73export function getOneMessage(getOneMessageOptions?: GetOneMessageOptions<Options['serialization']>): Promise<Message>;Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 74–75why, one step back7475/**Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6
lines 76–87why, one step back76Options to `getEachMessage()` and `subprocess.getEachMessage()`77*/78type GetEachMessageOptions = {79 /**80 Keep the subprocess alive while `getEachMessage()` is waiting.8182 @default true83 */84 readonly reference?: boolean;85};8687/**Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 88–91why, one step back88Iterate over each `message` from the parent process.8990This requires the `ipc` option to be `true`. The type of `message` depends on the `serialization` option.91*/Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6
line 92why, one step back92export function getEachMessage(getEachMessageOptions?: GetEachMessageOptions): AsyncIterableIterator<Message>;Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 93why, one step back93Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
lines 94–101why, one step back94/**95Retrieves the [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) shared by the `cancelSignal` option.9697This can only be called inside a subprocess. This requires the `gracefulCancel` option to be `true`.98*/99export function getCancelSignal(): Promise<AbortSignal>;100101// IPC methods in the subprocessAdd promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 102why, one step back102export type IpcMethods<Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
line 103why, one step back103 IpcEnabled extends boolean,Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 104why, one step back104 Serialization extends Options['serialization'],Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
line 105why, one step back105> = IpcEnabled extends trueAdd promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 106–111why, one step back106 ? {107 /**108 Send a `message` to the subprocess.109110 This requires the `ipc` option to be `true`. The type of `message` depends on the `serialization` option.111 */Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 112why, one step back112 sendMessage(message: Message<Serialization>, sendMessageOptions?: SendMessageOptions): Promise<void>;Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 113–118why, one step back113114 /**115 Receive a single `message` from the subprocess.116117 This requires the `ipc` option to be `true`. The type of `message` depends on the `serialization` option.118 */Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052
line 119why, one step back119 getOneMessage(getOneMessageOptions?: GetOneMessageOptions<Serialization>): Promise<Message<Serialization>>;Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 120–125why, one step back120121 /**122 Iterate over each `message` from the subprocess.123124 This requires the `ipc` option to be `true`. The type of `message` depends on the `serialization` option.125 */Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6
line 126why, one step back126 getEachMessage(getEachMessageOptions?: GetEachMessageOptions): AsyncIterableIterator<Message<Serialization>>;Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 127–129why, one step back127 }128 // Those methods only work if the `ipc` option is `true`.129 // At runtime, they are actually defined, in order to provide with a nice error message.Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
line 130why, one step back130 // At type check time, they are typed as `undefined` to prevent calling them.Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 131why, one step back131 : {Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 132–134why, one step back132 sendMessage: undefined;133 getOneMessage: undefined;134 getEachMessage: undefined;Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 135why, one step back135 };Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
line 136why, one step back136Fix `execaNode()` and the `node` option missing IPC in their typesSindre Sorhusbefore adoption2633abb
line 137why, one step back137// Whether IPC is enabled, based on the `ipc`, `node`, `ipcInput` and `gracefulCancel` optionsAdd `ipcInput` option (#1068)ehmickybefore adoption46cae30
line 138why, one step back138export type HasIpc<OptionsType extends Options> = HasIpcOption<Require Node.js 22 (#1243)Sindre Sorhusbefore adoption04b4454
line 139why, one step back139 OptionsType['ipc'],Fix `execaNode()` and the `node` option missing IPC in their typesSindre Sorhusbefore adoption2633abb
line 140why, one step back140 'node' extends keyof OptionsType ? OptionsType['node'] : undefined,Require Node.js 22 (#1243)Sindre Sorhusbefore adoption04b4454
lines 141–142why, one step back141 'ipcInput' extends keyof OptionsType ? OptionsType['ipcInput'] : undefined,142 'gracefulCancel' extends keyof OptionsType ? OptionsType['gracefulCancel'] : undefinedAdd `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 143–146why, one step back143>;144145type HasIpcOption<146 IpcOption extends Options['ipc'],Fix `execaNode()` and the `node` option missing IPC in their typesSindre Sorhusbefore adoption2633abb
line 147why, one step back147 NodeOption extends Options['node'],Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
line 148why, one step back148 IpcInputOption extends Options['ipcInput'],Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
line 149why, one step back149 GracefulCancelOption extends Options['gracefulCancel'],Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 150–153why, one step back150> = IpcOption extends true151 ? true152 : IpcOption extends false153 ? falseFix `execaNode()` and the `node` option missing IPC in their typesSindre Sorhusbefore adoption2633abb
lines 154–160why, one step back154 : NodeOption extends true155 ? true156 : IpcInputOption extends undefined157 ? GracefulCancelOption extends true158 ? true159 : false160 : true;Ensure all `d.ts` files are considered as ESM (#1216)Sindre Sorhusbefore adoption964f650
lines 161–162why, one step back161162export {};