@node-red/editor-client 3.1.8 → 4.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/locales/de/editor.json +2 -0
  2. package/locales/en-US/editor.json +10 -1
  3. package/locales/fr/editor.json +8 -1
  4. package/locales/ja/editor.json +10 -3
  5. package/package.json +1 -1
  6. package/public/red/about +52 -0
  7. package/public/red/red.js +1433 -263
  8. package/public/red/red.min.js +3 -3
  9. package/public/red/style.min.css +2 -2
  10. package/public/red/tours/3.1/welcome.js +231 -0
  11. package/public/red/tours/images/nr4-auto-complete.png +0 -0
  12. package/public/red/tours/images/nr4-config-select.png +0 -0
  13. package/public/red/tours/images/nr4-multiplayer.png +0 -0
  14. package/public/red/tours/images/nr4-plugins.png +0 -0
  15. package/public/red/tours/images/nr4-sf-config.png +0 -0
  16. package/public/red/tours/images/nr4-timestamp-formatting.png +0 -0
  17. package/public/red/tours/welcome.js +105 -161
  18. package/public/types/node/assert/strict.d.ts +1 -1
  19. package/public/types/node/assert.d.ts +8 -9
  20. package/public/types/node/async_hooks.d.ts +9 -5
  21. package/public/types/node/buffer.d.ts +43 -18
  22. package/public/types/node/child_process.d.ts +8 -5
  23. package/public/types/node/cluster.d.ts +15 -19
  24. package/public/types/node/console.d.ts +2 -2
  25. package/public/types/node/crypto.d.ts +165 -70
  26. package/public/types/node/dgram.d.ts +4 -4
  27. package/public/types/node/diagnostics_channel.d.ts +8 -7
  28. package/public/types/node/dns/promises.d.ts +11 -9
  29. package/public/types/node/dns.d.ts +18 -13
  30. package/public/types/node/dom-events.d.ts +129 -0
  31. package/public/types/node/domain.d.ts +2 -2
  32. package/public/types/node/events.d.ts +49 -12
  33. package/public/types/node/fs/promises.d.ts +68 -24
  34. package/public/types/node/fs.d.ts +132 -59
  35. package/public/types/node/globals.d.ts +31 -17
  36. package/public/types/node/http.d.ts +138 -27
  37. package/public/types/node/http2.d.ts +38 -5
  38. package/public/types/node/https.d.ts +12 -3
  39. package/public/types/node/module.d.ts +1 -2
  40. package/public/types/node/net.d.ts +69 -28
  41. package/public/types/node/os.d.ts +16 -5
  42. package/public/types/node/path.d.ts +5 -5
  43. package/public/types/node/perf_hooks.d.ts +48 -9
  44. package/public/types/node/process.d.ts +18 -17
  45. package/public/types/node/querystring.d.ts +2 -2
  46. package/public/types/node/readline/promises.d.ts +146 -0
  47. package/public/types/node/readline.d.ts +141 -31
  48. package/public/types/node/stream/consumers.d.ts +2 -2
  49. package/public/types/node/stream/promises.d.ts +1 -1
  50. package/public/types/node/stream/web.d.ts +4 -66
  51. package/public/types/node/stream.d.ts +96 -118
  52. package/public/types/node/string_decoder.d.ts +2 -2
  53. package/public/types/node/test.d.ts +200 -16
  54. package/public/types/node/timers/promises.d.ts +1 -26
  55. package/public/types/node/timers.d.ts +2 -2
  56. package/public/types/node/tls.d.ts +21 -12
  57. package/public/types/node/trace_events.d.ts +12 -2
  58. package/public/types/node/ts4.8/assert/strict.d.ts +11 -0
  59. package/public/types/node/ts4.8/assert.d.ts +964 -0
  60. package/public/types/node/ts4.8/async_hooks.d.ts +504 -0
  61. package/public/types/node/ts4.8/buffer.d.ts +2262 -0
  62. package/public/types/node/ts4.8/child_process.d.ts +1372 -0
  63. package/public/types/node/ts4.8/cluster.d.ts +413 -0
  64. package/public/types/node/ts4.8/console.d.ts +415 -0
  65. package/public/types/node/ts4.8/crypto.d.ts +3967 -0
  66. package/public/types/node/ts4.8/dgram.d.ts +548 -0
  67. package/public/types/node/ts4.8/diagnostics_channel.d.ts +156 -0
  68. package/public/types/node/ts4.8/dns/promises.d.ts +373 -0
  69. package/public/types/node/ts4.8/dns.d.ts +662 -0
  70. package/public/types/node/ts4.8/dom-events.d.ts +129 -0
  71. package/public/types/node/ts4.8/domain.d.ts +173 -0
  72. package/public/types/node/ts4.8/events.d.ts +681 -0
  73. package/public/types/node/ts4.8/fs/promises.d.ts +1141 -0
  74. package/public/types/node/ts4.8/fs.d.ts +3875 -0
  75. package/public/types/node/ts4.8/globals.d.ts +297 -0
  76. package/public/types/node/ts4.8/http.d.ts +1617 -0
  77. package/public/types/node/ts4.8/http2.d.ts +2137 -0
  78. package/public/types/node/ts4.8/https.d.ts +544 -0
  79. package/public/types/node/ts4.8/module.d.ts +117 -0
  80. package/public/types/node/ts4.8/net.d.ts +872 -0
  81. package/public/types/node/ts4.8/os.d.ts +469 -0
  82. package/public/types/node/ts4.8/path.d.ts +194 -0
  83. package/public/types/node/ts4.8/perf_hooks.d.ts +628 -0
  84. package/public/types/node/ts4.8/process.d.ts +1485 -0
  85. package/public/types/node/ts4.8/querystring.d.ts +134 -0
  86. package/public/types/node/ts4.8/readline/promises.d.ts +146 -0
  87. package/public/types/node/ts4.8/readline.d.ts +656 -0
  88. package/public/types/node/ts4.8/stream/consumers.d.ts +15 -0
  89. package/public/types/node/ts4.8/stream/promises.d.ts +45 -0
  90. package/public/types/node/ts4.8/stream/web.d.ts +333 -0
  91. package/public/types/node/ts4.8/stream.d.ts +1343 -0
  92. package/public/types/node/ts4.8/string_decoder.d.ts +70 -0
  93. package/public/types/node/ts4.8/test.d.ts +377 -0
  94. package/public/types/node/ts4.8/timers/promises.d.ts +71 -0
  95. package/public/types/node/ts4.8/timers.d.ts +97 -0
  96. package/public/types/node/ts4.8/tls.d.ts +1031 -0
  97. package/public/types/node/ts4.8/trace_events.d.ts +174 -0
  98. package/public/types/node/ts4.8/tty.d.ts +209 -0
  99. package/public/types/node/ts4.8/url.d.ts +900 -0
  100. package/public/types/node/ts4.8/util.d.ts +1853 -0
  101. package/public/types/node/ts4.8/v8.d.ts +399 -0
  102. package/public/types/node/ts4.8/vm.d.ts +512 -0
  103. package/public/types/node/ts4.8/wasi.d.ts +161 -0
  104. package/public/types/node/ts4.8/worker_threads.d.ts +692 -0
  105. package/public/types/node/ts4.8/zlib.d.ts +520 -0
  106. package/public/types/node/tty.d.ts +5 -3
  107. package/public/types/node/url.d.ts +81 -39
  108. package/public/types/node/util.d.ts +269 -13
  109. package/public/types/node/v8.d.ts +22 -4
  110. package/public/types/node/vm.d.ts +7 -5
  111. package/public/types/node/wasi.d.ts +2 -2
  112. package/public/types/node/worker_threads.d.ts +51 -11
  113. package/public/types/node/zlib.d.ts +2 -2
  114. package/public/types/node-red/func.d.ts +26 -17
  115. package/public/vendor/ace/worker-jsonata.js +1 -1
  116. package/public/vendor/monaco/dist/{fa2cc0ab9f0bec2b3365.ttf → 0c718f5b7d2bce997c5f.ttf} +0 -0
  117. package/public/vendor/monaco/dist/css.worker.js +1 -1
  118. package/public/vendor/monaco/dist/css.worker.js.LICENSE.txt +1 -1
  119. package/public/vendor/monaco/dist/editor.js +1 -29
  120. package/public/vendor/monaco/dist/editor.js.LICENSE.txt +2 -2
  121. package/public/vendor/monaco/dist/editor.worker.js +1 -1
  122. package/public/vendor/monaco/dist/html.worker.js +1 -1
  123. package/public/vendor/monaco/dist/html.worker.js.LICENSE.txt +1 -1
  124. package/public/vendor/monaco/dist/json.worker.js +1 -1
  125. package/public/vendor/monaco/dist/json.worker.js.LICENSE.txt +1 -1
  126. package/public/vendor/monaco/dist/locale/cs.js +324 -106
  127. package/public/vendor/monaco/dist/locale/de.js +336 -118
  128. package/public/vendor/monaco/dist/locale/es.js +329 -111
  129. package/public/vendor/monaco/dist/locale/fr.js +334 -116
  130. package/public/vendor/monaco/dist/locale/it.js +327 -109
  131. package/public/vendor/monaco/dist/locale/ja.js +329 -111
  132. package/public/vendor/monaco/dist/locale/ko.js +330 -112
  133. package/public/vendor/monaco/dist/locale/pl.js +329 -111
  134. package/public/vendor/monaco/dist/locale/pt-br.js +329 -111
  135. package/public/vendor/monaco/dist/locale/qps-ploc.js +330 -112
  136. package/public/vendor/monaco/dist/locale/ru.js +331 -113
  137. package/public/vendor/monaco/dist/locale/tr.js +329 -111
  138. package/public/vendor/monaco/dist/locale/zh-hans.js +331 -113
  139. package/public/vendor/monaco/dist/locale/zh-hant.js +331 -113
  140. package/public/vendor/monaco/dist/ts.worker.js +2 -2
  141. package/public/vendor/vendor.js +1 -1
  142. package/public/vendor/monaco/dist/7064e66c3890a12c47b4.ttf +0 -0
  143. /package/public/red/tours/{images → 3.1/images}/context-menu.png +0 -0
  144. /package/public/red/tours/{images → 3.1/images}/global-env-vars.png +0 -0
  145. /package/public/red/tours/{images → 3.1/images}/hiding-flows.png +0 -0
  146. /package/public/red/tours/{images → 3.1/images}/locking-flows.png +0 -0
  147. /package/public/red/tours/{images → 3.1/images}/mermaid.png +0 -0
  148. /package/public/red/tours/{images → 3.1/images}/node-help.png +0 -0
  149. /package/public/red/tours/{images → 3.1/images}/tab-changes.png +0 -0
@@ -0,0 +1,692 @@
1
+
2
+ /* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
3
+
4
+ /**
5
+ * The `worker_threads` module enables the use of threads that execute JavaScript
6
+ * in parallel. To access it:
7
+ *
8
+ * ```js
9
+ * const worker = require('worker_threads');
10
+ * ```
11
+ *
12
+ * Workers (threads) are useful for performing CPU-intensive JavaScript operations.
13
+ * They do not help much with I/O-intensive work. The Node.js built-in
14
+ * asynchronous I/O operations are more efficient than Workers can be.
15
+ *
16
+ * Unlike `child_process` or `cluster`, `worker_threads` can share memory. They do
17
+ * so by transferring `ArrayBuffer` instances or sharing `SharedArrayBuffer`instances.
18
+ *
19
+ * ```js
20
+ * const {
21
+ * Worker, isMainThread, parentPort, workerData
22
+ * } = require('worker_threads');
23
+ *
24
+ * if (isMainThread) {
25
+ * module.exports = function parseJSAsync(script) {
26
+ * return new Promise((resolve, reject) => {
27
+ * const worker = new Worker(__filename, {
28
+ * workerData: script
29
+ * });
30
+ * worker.on('message', resolve);
31
+ * worker.on('error', reject);
32
+ * worker.on('exit', (code) => {
33
+ * if (code !== 0)
34
+ * reject(new Error(`Worker stopped with exit code ${code}`));
35
+ * });
36
+ * });
37
+ * };
38
+ * } else {
39
+ * const { parse } = require('some-js-parsing-library');
40
+ * const script = workerData;
41
+ * parentPort.postMessage(parse(script));
42
+ * }
43
+ * ```
44
+ *
45
+ * The above example spawns a Worker thread for each `parseJSAsync()` call. In
46
+ * practice, use a pool of Workers for these kinds of tasks. Otherwise, the
47
+ * overhead of creating Workers would likely exceed their benefit.
48
+ *
49
+ * When implementing a worker pool, use the `AsyncResource` API to inform
50
+ * diagnostic tools (e.g. to provide asynchronous stack traces) about the
51
+ * correlation between tasks and their outcomes. See `"Using AsyncResource for a Worker thread pool"` in the `async_hooks` documentation for an example implementation.
52
+ *
53
+ * Worker threads inherit non-process-specific options by default. Refer to `Worker constructor options` to know how to customize worker thread options,
54
+ * specifically `argv` and `execArgv` options.
55
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/worker_threads.js)
56
+ */
57
+ declare module 'worker_threads' {
58
+ import { Blob } from 'node:buffer';
59
+ import { Context } from 'node:vm';
60
+ import { EventEmitter } from 'node:events';
61
+ import { EventLoopUtilityFunction } from 'node:perf_hooks';
62
+ import { FileHandle } from 'node:fs/promises';
63
+ import { Readable, Writable } from 'node:stream';
64
+ import { URL } from 'node:url';
65
+ import { X509Certificate } from 'node:crypto';
66
+ const isMainThread: boolean;
67
+ const parentPort: null | MessagePort;
68
+ const resourceLimits: ResourceLimits;
69
+ const SHARE_ENV: unique symbol;
70
+ const threadId: number;
71
+ const workerData: any;
72
+ /**
73
+ * Instances of the `worker.MessageChannel` class represent an asynchronous,
74
+ * two-way communications channel.
75
+ * The `MessageChannel` has no methods of its own. `new MessageChannel()`yields an object with `port1` and `port2` properties, which refer to linked `MessagePort` instances.
76
+ *
77
+ * ```js
78
+ * const { MessageChannel } = require('worker_threads');
79
+ *
80
+ * const { port1, port2 } = new MessageChannel();
81
+ * port1.on('message', (message) => console.log('received', message));
82
+ * port2.postMessage({ foo: 'bar' });
83
+ * // Prints: received { foo: 'bar' } from the `port1.on('message')` listener
84
+ * ```
85
+ * @since v10.5.0
86
+ */
87
+ class MessageChannel {
88
+ readonly port1: MessagePort;
89
+ readonly port2: MessagePort;
90
+ }
91
+ interface WorkerPerformance {
92
+ eventLoopUtilization: EventLoopUtilityFunction;
93
+ }
94
+ type TransferListItem = ArrayBuffer | MessagePort | FileHandle | X509Certificate | Blob;
95
+ /**
96
+ * Instances of the `worker.MessagePort` class represent one end of an
97
+ * asynchronous, two-way communications channel. It can be used to transfer
98
+ * structured data, memory regions and other `MessagePort`s between different `Worker` s.
99
+ *
100
+ * This implementation matches [browser `MessagePort`](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort) s.
101
+ * @since v10.5.0
102
+ */
103
+ class MessagePort extends EventEmitter {
104
+ /**
105
+ * Disables further sending of messages on either side of the connection.
106
+ * This method can be called when no further communication will happen over this`MessagePort`.
107
+ *
108
+ * The `'close' event` is emitted on both `MessagePort` instances that
109
+ * are part of the channel.
110
+ * @since v10.5.0
111
+ */
112
+ close(): void;
113
+ /**
114
+ * Sends a JavaScript value to the receiving side of this channel.`value` is transferred in a way which is compatible with
115
+ * the [HTML structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm).
116
+ *
117
+ * In particular, the significant differences to `JSON` are:
118
+ *
119
+ * * `value` may contain circular references.
120
+ * * `value` may contain instances of builtin JS types such as `RegExp`s,`BigInt`s, `Map`s, `Set`s, etc.
121
+ * * `value` may contain typed arrays, both using `ArrayBuffer`s
122
+ * and `SharedArrayBuffer`s.
123
+ * * `value` may contain [`WebAssembly.Module`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module) instances.
124
+ * * `value` may not contain native (C++-backed) objects other than:
125
+ *
126
+ * ```js
127
+ * const { MessageChannel } = require('worker_threads');
128
+ * const { port1, port2 } = new MessageChannel();
129
+ *
130
+ * port1.on('message', (message) => console.log(message));
131
+ *
132
+ * const circularData = {};
133
+ * circularData.foo = circularData;
134
+ * // Prints: { foo: [Circular] }
135
+ * port2.postMessage(circularData);
136
+ * ```
137
+ *
138
+ * `transferList` may be a list of [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), `MessagePort` and `FileHandle` objects.
139
+ * After transferring, they are not usable on the sending side of the channel
140
+ * anymore (even if they are not contained in `value`). Unlike with `child processes`, transferring handles such as network sockets is currently
141
+ * not supported.
142
+ *
143
+ * If `value` contains [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) instances, those are accessible
144
+ * from either thread. They cannot be listed in `transferList`.
145
+ *
146
+ * `value` may still contain `ArrayBuffer` instances that are not in`transferList`; in that case, the underlying memory is copied rather than moved.
147
+ *
148
+ * ```js
149
+ * const { MessageChannel } = require('worker_threads');
150
+ * const { port1, port2 } = new MessageChannel();
151
+ *
152
+ * port1.on('message', (message) => console.log(message));
153
+ *
154
+ * const uint8Array = new Uint8Array([ 1, 2, 3, 4 ]);
155
+ * // This posts a copy of `uint8Array`:
156
+ * port2.postMessage(uint8Array);
157
+ * // This does not copy data, but renders `uint8Array` unusable:
158
+ * port2.postMessage(uint8Array, [ uint8Array.buffer ]);
159
+ *
160
+ * // The memory for the `sharedUint8Array` is accessible from both the
161
+ * // original and the copy received by `.on('message')`:
162
+ * const sharedUint8Array = new Uint8Array(new SharedArrayBuffer(4));
163
+ * port2.postMessage(sharedUint8Array);
164
+ *
165
+ * // This transfers a freshly created message port to the receiver.
166
+ * // This can be used, for example, to create communication channels between
167
+ * // multiple `Worker` threads that are children of the same parent thread.
168
+ * const otherChannel = new MessageChannel();
169
+ * port2.postMessage({ port: otherChannel.port1 }, [ otherChannel.port1 ]);
170
+ * ```
171
+ *
172
+ * The message object is cloned immediately, and can be modified after
173
+ * posting without having side effects.
174
+ *
175
+ * For more information on the serialization and deserialization mechanisms
176
+ * behind this API, see the `serialization API of the v8 module`.
177
+ * @since v10.5.0
178
+ */
179
+ postMessage(value: any, transferList?: ReadonlyArray<TransferListItem>): void;
180
+ /**
181
+ * Opposite of `unref()`. Calling `ref()` on a previously `unref()`ed port does _not_ let the program exit if it's the only active handle left (the default
182
+ * behavior). If the port is `ref()`ed, calling `ref()` again has no effect.
183
+ *
184
+ * If listeners are attached or removed using `.on('message')`, the port
185
+ * is `ref()`ed and `unref()`ed automatically depending on whether
186
+ * listeners for the event exist.
187
+ * @since v10.5.0
188
+ */
189
+ ref(): void;
190
+ /**
191
+ * Calling `unref()` on a port allows the thread to exit if this is the only
192
+ * active handle in the event system. If the port is already `unref()`ed calling`unref()` again has no effect.
193
+ *
194
+ * If listeners are attached or removed using `.on('message')`, the port is`ref()`ed and `unref()`ed automatically depending on whether
195
+ * listeners for the event exist.
196
+ * @since v10.5.0
197
+ */
198
+ unref(): void;
199
+ /**
200
+ * Starts receiving messages on this `MessagePort`. When using this port
201
+ * as an event emitter, this is called automatically once `'message'`listeners are attached.
202
+ *
203
+ * This method exists for parity with the Web `MessagePort` API. In Node.js,
204
+ * it is only useful for ignoring messages when no event listener is present.
205
+ * Node.js also diverges in its handling of `.onmessage`. Setting it
206
+ * automatically calls `.start()`, but unsetting it lets messages queue up
207
+ * until a new handler is set or the port is discarded.
208
+ * @since v10.5.0
209
+ */
210
+ start(): void;
211
+ addListener(event: 'close', listener: () => void): this;
212
+ addListener(event: 'message', listener: (value: any) => void): this;
213
+ addListener(event: 'messageerror', listener: (error: Error) => void): this;
214
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
215
+ emit(event: 'close'): boolean;
216
+ emit(event: 'message', value: any): boolean;
217
+ emit(event: 'messageerror', error: Error): boolean;
218
+ emit(event: string | symbol, ...args: any[]): boolean;
219
+ on(event: 'close', listener: () => void): this;
220
+ on(event: 'message', listener: (value: any) => void): this;
221
+ on(event: 'messageerror', listener: (error: Error) => void): this;
222
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
223
+ once(event: 'close', listener: () => void): this;
224
+ once(event: 'message', listener: (value: any) => void): this;
225
+ once(event: 'messageerror', listener: (error: Error) => void): this;
226
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
227
+ prependListener(event: 'close', listener: () => void): this;
228
+ prependListener(event: 'message', listener: (value: any) => void): this;
229
+ prependListener(event: 'messageerror', listener: (error: Error) => void): this;
230
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
231
+ prependOnceListener(event: 'close', listener: () => void): this;
232
+ prependOnceListener(event: 'message', listener: (value: any) => void): this;
233
+ prependOnceListener(event: 'messageerror', listener: (error: Error) => void): this;
234
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
235
+ removeListener(event: 'close', listener: () => void): this;
236
+ removeListener(event: 'message', listener: (value: any) => void): this;
237
+ removeListener(event: 'messageerror', listener: (error: Error) => void): this;
238
+ removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
239
+ off(event: 'close', listener: () => void): this;
240
+ off(event: 'message', listener: (value: any) => void): this;
241
+ off(event: 'messageerror', listener: (error: Error) => void): this;
242
+ off(event: string | symbol, listener: (...args: any[]) => void): this;
243
+ }
244
+ interface WorkerOptions {
245
+ /**
246
+ * List of arguments which would be stringified and appended to
247
+ * `process.argv` in the worker. This is mostly similar to the `workerData`
248
+ * but the values will be available on the global `process.argv` as if they
249
+ * were passed as CLI options to the script.
250
+ */
251
+ argv?: any[] | undefined;
252
+ env?: NodeJS.Dict<string> | typeof SHARE_ENV | undefined;
253
+ eval?: boolean | undefined;
254
+ workerData?: any;
255
+ stdin?: boolean | undefined;
256
+ stdout?: boolean | undefined;
257
+ stderr?: boolean | undefined;
258
+ execArgv?: string[] | undefined;
259
+ resourceLimits?: ResourceLimits | undefined;
260
+ /**
261
+ * Additional data to send in the first worker message.
262
+ */
263
+ transferList?: TransferListItem[] | undefined;
264
+ /**
265
+ * @default true
266
+ */
267
+ trackUnmanagedFds?: boolean | undefined;
268
+ }
269
+ interface ResourceLimits {
270
+ /**
271
+ * The maximum size of a heap space for recently created objects.
272
+ */
273
+ maxYoungGenerationSizeMb?: number | undefined;
274
+ /**
275
+ * The maximum size of the main heap in MB.
276
+ */
277
+ maxOldGenerationSizeMb?: number | undefined;
278
+ /**
279
+ * The size of a pre-allocated memory range used for generated code.
280
+ */
281
+ codeRangeSizeMb?: number | undefined;
282
+ /**
283
+ * The default maximum stack size for the thread. Small values may lead to unusable Worker instances.
284
+ * @default 4
285
+ */
286
+ stackSizeMb?: number | undefined;
287
+ }
288
+ /**
289
+ * The `Worker` class represents an independent JavaScript execution thread.
290
+ * Most Node.js APIs are available inside of it.
291
+ *
292
+ * Notable differences inside a Worker environment are:
293
+ *
294
+ * * The `process.stdin`, `process.stdout` and `process.stderr` may be redirected by the parent thread.
295
+ * * The `require('worker_threads').isMainThread` property is set to `false`.
296
+ * * The `require('worker_threads').parentPort` message port is available.
297
+ * * `process.exit()` does not stop the whole program, just the single thread,
298
+ * and `process.abort()` is not available.
299
+ * * `process.chdir()` and `process` methods that set group or user ids
300
+ * are not available.
301
+ * * `process.env` is a copy of the parent thread's environment variables,
302
+ * unless otherwise specified. Changes to one copy are not visible in other
303
+ * threads, and are not visible to native add-ons (unless `worker.SHARE_ENV` is passed as the `env` option to the `Worker` constructor).
304
+ * * `process.title` cannot be modified.
305
+ * * Signals are not delivered through `process.on('...')`.
306
+ * * Execution may stop at any point as a result of `worker.terminate()` being invoked.
307
+ * * IPC channels from parent processes are not accessible.
308
+ * * The `trace_events` module is not supported.
309
+ * * Native add-ons can only be loaded from multiple threads if they fulfill `certain conditions`.
310
+ *
311
+ * Creating `Worker` instances inside of other `Worker`s is possible.
312
+ *
313
+ * Like [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) and the `cluster module`, two-way communication can be
314
+ * achieved through inter-thread message passing. Internally, a `Worker` has a
315
+ * built-in pair of `MessagePort` s that are already associated with each other
316
+ * when the `Worker` is created. While the `MessagePort` object on the parent side
317
+ * is not directly exposed, its functionalities are exposed through `worker.postMessage()` and the `worker.on('message')` event
318
+ * on the `Worker` object for the parent thread.
319
+ *
320
+ * To create custom messaging channels (which is encouraged over using the default
321
+ * global channel because it facilitates separation of concerns), users can create
322
+ * a `MessageChannel` object on either thread and pass one of the`MessagePort`s on that `MessageChannel` to the other thread through a
323
+ * pre-existing channel, such as the global one.
324
+ *
325
+ * See `port.postMessage()` for more information on how messages are passed,
326
+ * and what kind of JavaScript values can be successfully transported through
327
+ * the thread barrier.
328
+ *
329
+ * ```js
330
+ * const assert = require('assert');
331
+ * const {
332
+ * Worker, MessageChannel, MessagePort, isMainThread, parentPort
333
+ * } = require('worker_threads');
334
+ * if (isMainThread) {
335
+ * const worker = new Worker(__filename);
336
+ * const subChannel = new MessageChannel();
337
+ * worker.postMessage({ hereIsYourPort: subChannel.port1 }, [subChannel.port1]);
338
+ * subChannel.port2.on('message', (value) => {
339
+ * console.log('received:', value);
340
+ * });
341
+ * } else {
342
+ * parentPort.once('message', (value) => {
343
+ * assert(value.hereIsYourPort instanceof MessagePort);
344
+ * value.hereIsYourPort.postMessage('the worker is sending this');
345
+ * value.hereIsYourPort.close();
346
+ * });
347
+ * }
348
+ * ```
349
+ * @since v10.5.0
350
+ */
351
+ class Worker extends EventEmitter {
352
+ /**
353
+ * If `stdin: true` was passed to the `Worker` constructor, this is a
354
+ * writable stream. The data written to this stream will be made available in
355
+ * the worker thread as `process.stdin`.
356
+ * @since v10.5.0
357
+ */
358
+ readonly stdin: Writable | null;
359
+ /**
360
+ * This is a readable stream which contains data written to `process.stdout` inside the worker thread. If `stdout: true` was not passed to the `Worker` constructor, then data is piped to the
361
+ * parent thread's `process.stdout` stream.
362
+ * @since v10.5.0
363
+ */
364
+ readonly stdout: Readable;
365
+ /**
366
+ * This is a readable stream which contains data written to `process.stderr` inside the worker thread. If `stderr: true` was not passed to the `Worker` constructor, then data is piped to the
367
+ * parent thread's `process.stderr` stream.
368
+ * @since v10.5.0
369
+ */
370
+ readonly stderr: Readable;
371
+ /**
372
+ * An integer identifier for the referenced thread. Inside the worker thread,
373
+ * it is available as `require('worker_threads').threadId`.
374
+ * This value is unique for each `Worker` instance inside a single process.
375
+ * @since v10.5.0
376
+ */
377
+ readonly threadId: number;
378
+ /**
379
+ * Provides the set of JS engine resource constraints for this Worker thread.
380
+ * If the `resourceLimits` option was passed to the `Worker` constructor,
381
+ * this matches its values.
382
+ *
383
+ * If the worker has stopped, the return value is an empty object.
384
+ * @since v13.2.0, v12.16.0
385
+ */
386
+ readonly resourceLimits?: ResourceLimits | undefined;
387
+ /**
388
+ * An object that can be used to query performance information from a worker
389
+ * instance. Similar to `perf_hooks.performance`.
390
+ * @since v15.1.0, v14.17.0, v12.22.0
391
+ */
392
+ readonly performance: WorkerPerformance;
393
+ /**
394
+ * @param filename The path to the Worker’s main script or module.
395
+ * Must be either an absolute path or a relative path (i.e. relative to the current working directory) starting with ./ or ../,
396
+ * or a WHATWG URL object using file: protocol. If options.eval is true, this is a string containing JavaScript code rather than a path.
397
+ */
398
+ constructor(filename: string | URL, options?: WorkerOptions);
399
+ /**
400
+ * Send a message to the worker that is received via `require('worker_threads').parentPort.on('message')`.
401
+ * See `port.postMessage()` for more details.
402
+ * @since v10.5.0
403
+ */
404
+ postMessage(value: any, transferList?: ReadonlyArray<TransferListItem>): void;
405
+ /**
406
+ * Opposite of `unref()`, calling `ref()` on a previously `unref()`ed worker does _not_ let the program exit if it's the only active handle left (the default
407
+ * behavior). If the worker is `ref()`ed, calling `ref()` again has
408
+ * no effect.
409
+ * @since v10.5.0
410
+ */
411
+ ref(): void;
412
+ /**
413
+ * Calling `unref()` on a worker allows the thread to exit if this is the only
414
+ * active handle in the event system. If the worker is already `unref()`ed calling`unref()` again has no effect.
415
+ * @since v10.5.0
416
+ */
417
+ unref(): void;
418
+ /**
419
+ * Stop all JavaScript execution in the worker thread as soon as possible.
420
+ * Returns a Promise for the exit code that is fulfilled when the `'exit' event` is emitted.
421
+ * @since v10.5.0
422
+ */
423
+ terminate(): Promise<number>;
424
+ /**
425
+ * Returns a readable stream for a V8 snapshot of the current state of the Worker.
426
+ * See `v8.getHeapSnapshot()` for more details.
427
+ *
428
+ * If the Worker thread is no longer running, which may occur before the `'exit' event` is emitted, the returned `Promise` is rejected
429
+ * immediately with an `ERR_WORKER_NOT_RUNNING` error.
430
+ * @since v13.9.0, v12.17.0
431
+ * @return A promise for a Readable Stream containing a V8 heap snapshot
432
+ */
433
+ getHeapSnapshot(): Promise<Readable>;
434
+ addListener(event: 'error', listener: (err: Error) => void): this;
435
+ addListener(event: 'exit', listener: (exitCode: number) => void): this;
436
+ addListener(event: 'message', listener: (value: any) => void): this;
437
+ addListener(event: 'messageerror', listener: (error: Error) => void): this;
438
+ addListener(event: 'online', listener: () => void): this;
439
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
440
+ emit(event: 'error', err: Error): boolean;
441
+ emit(event: 'exit', exitCode: number): boolean;
442
+ emit(event: 'message', value: any): boolean;
443
+ emit(event: 'messageerror', error: Error): boolean;
444
+ emit(event: 'online'): boolean;
445
+ emit(event: string | symbol, ...args: any[]): boolean;
446
+ on(event: 'error', listener: (err: Error) => void): this;
447
+ on(event: 'exit', listener: (exitCode: number) => void): this;
448
+ on(event: 'message', listener: (value: any) => void): this;
449
+ on(event: 'messageerror', listener: (error: Error) => void): this;
450
+ on(event: 'online', listener: () => void): this;
451
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
452
+ once(event: 'error', listener: (err: Error) => void): this;
453
+ once(event: 'exit', listener: (exitCode: number) => void): this;
454
+ once(event: 'message', listener: (value: any) => void): this;
455
+ once(event: 'messageerror', listener: (error: Error) => void): this;
456
+ once(event: 'online', listener: () => void): this;
457
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
458
+ prependListener(event: 'error', listener: (err: Error) => void): this;
459
+ prependListener(event: 'exit', listener: (exitCode: number) => void): this;
460
+ prependListener(event: 'message', listener: (value: any) => void): this;
461
+ prependListener(event: 'messageerror', listener: (error: Error) => void): this;
462
+ prependListener(event: 'online', listener: () => void): this;
463
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
464
+ prependOnceListener(event: 'error', listener: (err: Error) => void): this;
465
+ prependOnceListener(event: 'exit', listener: (exitCode: number) => void): this;
466
+ prependOnceListener(event: 'message', listener: (value: any) => void): this;
467
+ prependOnceListener(event: 'messageerror', listener: (error: Error) => void): this;
468
+ prependOnceListener(event: 'online', listener: () => void): this;
469
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
470
+ removeListener(event: 'error', listener: (err: Error) => void): this;
471
+ removeListener(event: 'exit', listener: (exitCode: number) => void): this;
472
+ removeListener(event: 'message', listener: (value: any) => void): this;
473
+ removeListener(event: 'messageerror', listener: (error: Error) => void): this;
474
+ removeListener(event: 'online', listener: () => void): this;
475
+ removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
476
+ off(event: 'error', listener: (err: Error) => void): this;
477
+ off(event: 'exit', listener: (exitCode: number) => void): this;
478
+ off(event: 'message', listener: (value: any) => void): this;
479
+ off(event: 'messageerror', listener: (error: Error) => void): this;
480
+ off(event: 'online', listener: () => void): this;
481
+ off(event: string | symbol, listener: (...args: any[]) => void): this;
482
+ }
483
+ interface BroadcastChannel extends NodeJS.RefCounted {}
484
+ /**
485
+ * Instances of `BroadcastChannel` allow asynchronous one-to-many communication
486
+ * with all other `BroadcastChannel` instances bound to the same channel name.
487
+ *
488
+ * ```js
489
+ * 'use strict';
490
+ *
491
+ * const {
492
+ * isMainThread,
493
+ * BroadcastChannel,
494
+ * Worker
495
+ * } = require('worker_threads');
496
+ *
497
+ * const bc = new BroadcastChannel('hello');
498
+ *
499
+ * if (isMainThread) {
500
+ * let c = 0;
501
+ * bc.onmessage = (event) => {
502
+ * console.log(event.data);
503
+ * if (++c === 10) bc.close();
504
+ * };
505
+ * for (let n = 0; n < 10; n++)
506
+ * new Worker(__filename);
507
+ * } else {
508
+ * bc.postMessage('hello from every worker');
509
+ * bc.close();
510
+ * }
511
+ * ```
512
+ * @since v15.4.0
513
+ */
514
+ class BroadcastChannel {
515
+ readonly name: string;
516
+ /**
517
+ * Invoked with a single \`MessageEvent\` argument when a message is received.
518
+ * @since v15.4.0
519
+ */
520
+ onmessage: (message: unknown) => void;
521
+ /**
522
+ * Invoked with a received message cannot be deserialized.
523
+ * @since v15.4.0
524
+ */
525
+ onmessageerror: (message: unknown) => void;
526
+ constructor(name: string);
527
+ /**
528
+ * Closes the `BroadcastChannel` connection.
529
+ * @since v15.4.0
530
+ */
531
+ close(): void;
532
+ /**
533
+ * @since v15.4.0
534
+ * @param message Any cloneable JavaScript value.
535
+ */
536
+ postMessage(message: unknown): void;
537
+ }
538
+ /**
539
+ * Mark an object as not transferable. If `object` occurs in the transfer list of
540
+ * a `port.postMessage()` call, it is ignored.
541
+ *
542
+ * In particular, this makes sense for objects that can be cloned, rather than
543
+ * transferred, and which are used by other objects on the sending side.
544
+ * For example, Node.js marks the `ArrayBuffer`s it uses for its `Buffer pool` with this.
545
+ *
546
+ * This operation cannot be undone.
547
+ *
548
+ * ```js
549
+ * const { MessageChannel, markAsUntransferable } = require('worker_threads');
550
+ *
551
+ * const pooledBuffer = new ArrayBuffer(8);
552
+ * const typedArray1 = new Uint8Array(pooledBuffer);
553
+ * const typedArray2 = new Float64Array(pooledBuffer);
554
+ *
555
+ * markAsUntransferable(pooledBuffer);
556
+ *
557
+ * const { port1 } = new MessageChannel();
558
+ * port1.postMessage(typedArray1, [ typedArray1.buffer ]);
559
+ *
560
+ * // The following line prints the contents of typedArray1 -- it still owns
561
+ * // its memory and has been cloned, not transferred. Without
562
+ * // `markAsUntransferable()`, this would print an empty Uint8Array.
563
+ * // typedArray2 is intact as well.
564
+ * console.log(typedArray1);
565
+ * console.log(typedArray2);
566
+ * ```
567
+ *
568
+ * There is no equivalent to this API in browsers.
569
+ * @since v14.5.0, v12.19.0
570
+ */
571
+ function markAsUntransferable(object: object): void;
572
+ /**
573
+ * Transfer a `MessagePort` to a different `vm` Context. The original `port`object is rendered unusable, and the returned `MessagePort` instance
574
+ * takes its place.
575
+ *
576
+ * The returned `MessagePort` is an object in the target context and
577
+ * inherits from its global `Object` class. Objects passed to the [`port.onmessage()`](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/onmessage) listener are also created in the
578
+ * target context
579
+ * and inherit from its global `Object` class.
580
+ *
581
+ * However, the created `MessagePort` no longer inherits from [`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget), and only
582
+ * [`port.onmessage()`](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/onmessage) can be used to receive
583
+ * events using it.
584
+ * @since v11.13.0
585
+ * @param port The message port to transfer.
586
+ * @param contextifiedSandbox A `contextified` object as returned by the `vm.createContext()` method.
587
+ */
588
+ function moveMessagePortToContext(port: MessagePort, contextifiedSandbox: Context): MessagePort;
589
+ /**
590
+ * Receive a single message from a given `MessagePort`. If no message is available,`undefined` is returned, otherwise an object with a single `message` property
591
+ * that contains the message payload, corresponding to the oldest message in the`MessagePort`’s queue.
592
+ *
593
+ * ```js
594
+ * const { MessageChannel, receiveMessageOnPort } = require('worker_threads');
595
+ * const { port1, port2 } = new MessageChannel();
596
+ * port1.postMessage({ hello: 'world' });
597
+ *
598
+ * console.log(receiveMessageOnPort(port2));
599
+ * // Prints: { message: { hello: 'world' } }
600
+ * console.log(receiveMessageOnPort(port2));
601
+ * // Prints: undefined
602
+ * ```
603
+ *
604
+ * When this function is used, no `'message'` event is emitted and the`onmessage` listener is not invoked.
605
+ * @since v12.3.0
606
+ */
607
+ function receiveMessageOnPort(port: MessagePort):
608
+ | {
609
+ message: any;
610
+ }
611
+ | undefined;
612
+ type Serializable = string | object | number | boolean | bigint;
613
+ /**
614
+ * Within a worker thread, `worker.getEnvironmentData()` returns a clone
615
+ * of data passed to the spawning thread's `worker.setEnvironmentData()`.
616
+ * Every new `Worker` receives its own copy of the environment data
617
+ * automatically.
618
+ *
619
+ * ```js
620
+ * const {
621
+ * Worker,
622
+ * isMainThread,
623
+ * setEnvironmentData,
624
+ * getEnvironmentData,
625
+ * } = require('worker_threads');
626
+ *
627
+ * if (isMainThread) {
628
+ * setEnvironmentData('Hello', 'World!');
629
+ * const worker = new Worker(__filename);
630
+ * } else {
631
+ * console.log(getEnvironmentData('Hello')); // Prints 'World!'.
632
+ * }
633
+ * ```
634
+ * @since v15.12.0, v14.18.0
635
+ * @param key Any arbitrary, cloneable JavaScript value that can be used as a {Map} key.
636
+ */
637
+ function getEnvironmentData(key: Serializable): Serializable;
638
+ /**
639
+ * The `worker.setEnvironmentData()` API sets the content of`worker.getEnvironmentData()` in the current thread and all new `Worker`instances spawned from the current context.
640
+ * @since v15.12.0, v14.18.0
641
+ * @param key Any arbitrary, cloneable JavaScript value that can be used as a {Map} key.
642
+ * @param value Any arbitrary, cloneable JavaScript value that will be cloned and passed automatically to all new `Worker` instances. If `value` is passed as `undefined`, any previously set value
643
+ * for the `key` will be deleted.
644
+ */
645
+ function setEnvironmentData(key: Serializable, value: Serializable): void;
646
+
647
+ import {
648
+ BroadcastChannel as _BroadcastChannel,
649
+ MessageChannel as _MessageChannel,
650
+ MessagePort as _MessagePort,
651
+ } from 'worker_threads';
652
+ global {
653
+ /**
654
+ * `BroadcastChannel` class is a global reference for `require('worker_threads').BroadcastChannel`
655
+ * https://nodejs.org/api/globals.html#broadcastchannel
656
+ * @since v18.0.0
657
+ */
658
+ var BroadcastChannel: typeof globalThis extends {
659
+ onmessage: any;
660
+ BroadcastChannel: infer T;
661
+ }
662
+ ? T
663
+ : typeof _BroadcastChannel;
664
+
665
+ /**
666
+ * `MessageChannel` class is a global reference for `require('worker_threads').MessageChannel`
667
+ * https://nodejs.org/api/globals.html#messagechannel
668
+ * @since v15.0.0
669
+ */
670
+ var MessageChannel: typeof globalThis extends {
671
+ onmessage: any;
672
+ MessageChannel: infer T;
673
+ }
674
+ ? T
675
+ : typeof _MessageChannel;
676
+
677
+ /**
678
+ * `MessagePort` class is a global reference for `require('worker_threads').MessagePort`
679
+ * https://nodejs.org/api/globals.html#messageport
680
+ * @since v15.0.0
681
+ */
682
+ var MessagePort: typeof globalThis extends {
683
+ onmessage: any;
684
+ MessagePort: infer T;
685
+ }
686
+ ? T
687
+ : typeof _MessagePort;
688
+ }
689
+ }
690
+ declare module 'node:worker_threads' {
691
+ export * from 'worker_threads';
692
+ }