Skip to content
Myr

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 file

Take it

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 1–20why, one step back
1import 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 back
21Type 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 back
22
23This 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;28

Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052

line 29why, one step back
29/**

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

line 30why, one step back
30Options to `sendMessage()` and `subprocess.sendMessage()`

Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052

line 31why, one step back
31*/

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

line 32why, one step back
32type SendMessageOptions = {

Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052

line 33why, one step back
33 /**

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

lines 34–36why, one step back
34 Throw when the other process is not receiving or listening to messages.
3536 @default false

Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052

line 37why, one step back
37 */

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

line 38why, one step back
38 readonly strict?: boolean;

Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052

lines 39–40why, one step back
39};
40

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 41–46why, one step back
41// IPC methods in subprocess
42/**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 back
47export function sendMessage(message: Message, sendMessageOptions?: SendMessageOptions): Promise<void>;

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 48–49why, one step back
48
49/**

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

lines 50–58why, one step back
50Options 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 back
59
60 /**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 back
66};
6768/**

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 69–72why, one step back
69Receive 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 back
73export function getOneMessage(getOneMessageOptions?: GetOneMessageOptions<Options['serialization']>): Promise<Message>;

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 74–75why, one step back
74
75/**

Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6

lines 76–87why, one step back
76Options 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 back
88Iterate 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 back
92export function getEachMessage(getEachMessageOptions?: GetEachMessageOptions): AsyncIterableIterator<Message>;

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 93why, one step back
93

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

lines 94–101why, one step back
94/**
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 subprocess

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 102why, one step back
102export type IpcMethods<

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

line 103why, one step back
103 IpcEnabled extends boolean,

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 104why, one step back
104 Serialization extends Options['serialization'],

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

line 105why, one step back
105> = IpcEnabled extends true

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 106–111why, one step back
106 ? {
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 back
112 sendMessage(message: Message<Serialization>, sendMessageOptions?: SendMessageOptions): Promise<void>;

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 113–118why, one step back
113
114 /**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 back
119 getOneMessage(getOneMessageOptions?: GetOneMessageOptions<Serialization>): Promise<Message<Serialization>>;

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 120–125why, one step back
120
121 /**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 back
126 getEachMessage(getEachMessageOptions?: GetEachMessageOptions): AsyncIterableIterator<Message<Serialization>>;

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 127–129why, one step back
127 }
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 back
130 // At type check time, they are typed as `undefined` to prevent calling them.

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 131why, one step back
131 : {

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 132–134why, one step back
132 sendMessage: undefined;
133 getOneMessage: undefined;134 getEachMessage: undefined;

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 135why, one step back
135 };

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

line 136why, one step back
136

Fix `execaNode()` and the `node` option missing IPC in their typesSindre Sorhusbefore adoption2633abb

line 137why, one step back
137// Whether IPC is enabled, based on the `ipc`, `node`, `ipcInput` and `gracefulCancel` options

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

line 138why, one step back
138export type HasIpc<OptionsType extends Options> = HasIpcOption<

Require Node.js 22 (#1243)Sindre Sorhusbefore adoption04b4454

line 139why, one step back
139 OptionsType['ipc'],

Fix `execaNode()` and the `node` option missing IPC in their typesSindre Sorhusbefore adoption2633abb

line 140why, one step back
140 'node' extends keyof OptionsType ? OptionsType['node'] : undefined,

Require Node.js 22 (#1243)Sindre Sorhusbefore adoption04b4454

lines 141–142why, one step back
141 'ipcInput' extends keyof OptionsType ? OptionsType['ipcInput'] : undefined,
142 'gracefulCancel' extends keyof OptionsType ? OptionsType['gracefulCancel'] : undefined

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 143–146why, one step back
143>;
144145type HasIpcOption<146 IpcOption extends Options['ipc'],

Fix `execaNode()` and the `node` option missing IPC in their typesSindre Sorhusbefore adoption2633abb

line 147why, one step back
147 NodeOption extends Options['node'],

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

line 148why, one step back
148 IpcInputOption extends Options['ipcInput'],

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

line 149why, one step back
149 GracefulCancelOption extends Options['gracefulCancel'],

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 150–153why, one step back
150> = IpcOption extends true
151 ? true152 : IpcOption extends false153 ? false

Fix `execaNode()` and the `node` option missing IPC in their typesSindre Sorhusbefore adoption2633abb

lines 154–160why, one step back
154 : NodeOption extends true
155 ? 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 back
161
162export {};