@node-red/editor-client 3.0.2 → 3.1.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 (127) hide show
  1. package/locales/de/editor.json +2 -0
  2. package/locales/de/infotips.json +0 -0
  3. package/locales/de/jsonata.json +0 -0
  4. package/locales/en-US/editor.json +37 -6
  5. package/locales/en-US/infotips.json +0 -0
  6. package/locales/en-US/jsonata.json +0 -0
  7. package/locales/fr/editor.json +1238 -0
  8. package/locales/fr/infotips.json +23 -0
  9. package/locales/fr/jsonata.json +274 -0
  10. package/locales/ja/editor.json +48 -9
  11. package/locales/ko/editor.json +233 -31
  12. package/locales/ko/infotips.json +0 -0
  13. package/locales/ko/jsonata.json +0 -0
  14. package/locales/pt-BR/editor.json +1208 -0
  15. package/locales/pt-BR/infotips.json +23 -0
  16. package/locales/pt-BR/jsonata.json +274 -0
  17. package/locales/ru/editor.json +2 -0
  18. package/locales/ru/infotips.json +0 -0
  19. package/locales/ru/jsonata.json +0 -0
  20. package/locales/zh-CN/editor.json +1175 -1049
  21. package/locales/zh-TW/editor.json +3 -0
  22. package/package.json +1 -1
  23. package/public/red/about +140 -0
  24. package/public/red/red.js +2699 -1397
  25. package/public/red/red.min.js +4 -3
  26. package/public/red/style.min.css +1 -1
  27. package/public/red/tours/3.0/images/context-menu.png +0 -0
  28. package/public/red/tours/3.0/welcome.js +155 -0
  29. package/public/red/tours/images/context-menu.png +0 -0
  30. package/public/red/tours/images/global-env-vars.png +0 -0
  31. package/public/red/tours/images/hiding-flows.png +0 -0
  32. package/public/red/tours/images/locking-flows.png +0 -0
  33. package/public/red/tours/images/mermaid.png +0 -0
  34. package/public/red/tours/images/node-help.png +0 -0
  35. package/public/red/tours/images/tab-changes.png +0 -0
  36. package/public/red/tours/welcome.js +111 -94
  37. package/public/types/node/assert/strict.d.ts +11 -0
  38. package/public/types/node/assert.d.ts +898 -64
  39. package/public/types/node/async_hooks.d.ts +362 -94
  40. package/public/types/node/buffer.d.ts +2158 -14
  41. package/public/types/node/child_process.d.ts +1109 -257
  42. package/public/types/node/cluster.d.ts +349 -200
  43. package/public/types/node/console.d.ts +313 -43
  44. package/public/types/node/crypto.d.ts +3329 -656
  45. package/public/types/node/dgram.d.ts +459 -58
  46. package/public/types/node/diagnostics_channel.d.ts +155 -0
  47. package/public/types/node/dns/promises.d.ts +371 -0
  48. package/public/types/node/dns.d.ts +532 -265
  49. package/public/types/node/domain.d.ts +159 -16
  50. package/public/types/node/events.d.ts +589 -30
  51. package/public/types/node/fs/promises.d.ts +1097 -0
  52. package/public/types/node/fs.d.ts +2484 -958
  53. package/public/types/node/globals.d.ts +43 -503
  54. package/public/types/node/http.d.ts +1156 -145
  55. package/public/types/node/http2.d.ts +1610 -470
  56. package/public/types/node/https.d.ts +462 -72
  57. package/public/types/node/module.d.ts +72 -13
  58. package/public/types/node/net.d.ts +663 -131
  59. package/public/types/node/os.d.ts +238 -25
  60. package/public/types/node/path.d.ts +57 -23
  61. package/public/types/node/perf_hooks.d.ts +424 -112
  62. package/public/types/node/process.d.ts +1261 -193
  63. package/public/types/node/querystring.d.ts +107 -7
  64. package/public/types/node/readline.d.ts +443 -74
  65. package/public/types/node/stream/consumers.d.ts +15 -0
  66. package/public/types/node/stream/promises.d.ts +45 -0
  67. package/public/types/node/stream/web.d.ts +395 -0
  68. package/public/types/node/stream.d.ts +1081 -177
  69. package/public/types/node/string_decoder.d.ts +57 -0
  70. package/public/types/node/test.d.ts +193 -0
  71. package/public/types/node/timers/promises.d.ts +96 -0
  72. package/public/types/node/timers.d.ts +87 -12
  73. package/public/types/node/tls.d.ts +457 -222
  74. package/public/types/node/trace_events.d.ts +107 -10
  75. package/public/types/node/tty.d.ts +158 -23
  76. package/public/types/node/url.d.ts +734 -28
  77. package/public/types/node/util.d.ts +1542 -164
  78. package/public/types/node/v8.d.ts +261 -73
  79. package/public/types/node/vm.d.ts +384 -32
  80. package/public/types/node/wasi.d.ts +92 -23
  81. package/public/types/node/worker_threads.d.ts +531 -123
  82. package/public/types/node/zlib.d.ts +216 -63
  83. package/public/types/node-red/func.d.ts +3 -0
  84. package/public/vendor/jquery/css/base/images/ui-icons_444444_256x240.png +0 -0
  85. package/public/vendor/jquery/css/base/images/ui-icons_555555_256x240.png +0 -0
  86. package/public/vendor/jquery/css/base/images/ui-icons_777620_256x240.png +0 -0
  87. package/public/vendor/jquery/css/base/images/ui-icons_777777_256x240.png +0 -0
  88. package/public/vendor/jquery/css/base/images/ui-icons_cc0000_256x240.png +0 -0
  89. package/public/vendor/jquery/css/base/images/ui-icons_ffffff_256x240.png +0 -0
  90. package/public/vendor/jquery/css/base/jquery-ui.min.css +4 -4
  91. package/public/vendor/mermaid/mermaid.min.js +1284 -0
  92. package/public/vendor/monaco/dist/{ade705761eb7e702770d.ttf → 7064e66c3890a12c47b4.ttf} +0 -0
  93. package/public/vendor/monaco/dist/css.worker.js +1 -1
  94. package/public/vendor/monaco/dist/css.worker.js.LICENSE.txt +1 -1
  95. package/public/vendor/monaco/dist/editor.js +1 -1
  96. package/public/vendor/monaco/dist/editor.js.LICENSE.txt +5 -1
  97. package/public/vendor/monaco/dist/editor.worker.js +1 -1
  98. package/public/vendor/monaco/dist/html.worker.js +1 -1
  99. package/public/vendor/monaco/dist/html.worker.js.LICENSE.txt +1 -1
  100. package/public/vendor/monaco/dist/json.worker.js +1 -1
  101. package/public/vendor/monaco/dist/json.worker.js.LICENSE.txt +1 -1
  102. package/public/vendor/monaco/dist/locale/cs.js +319 -71
  103. package/public/vendor/monaco/dist/locale/de.js +323 -75
  104. package/public/vendor/monaco/dist/locale/es.js +318 -70
  105. package/public/vendor/monaco/dist/locale/fr.js +327 -79
  106. package/public/vendor/monaco/dist/locale/it.js +325 -77
  107. package/public/vendor/monaco/dist/locale/ja.js +337 -89
  108. package/public/vendor/monaco/dist/locale/ko.js +324 -76
  109. package/public/vendor/monaco/dist/locale/pl.js +322 -74
  110. package/public/vendor/monaco/dist/locale/pt-br.js +321 -73
  111. package/public/vendor/monaco/dist/locale/qps-ploc.js +1580 -1332
  112. package/public/vendor/monaco/dist/locale/ru.js +324 -76
  113. package/public/vendor/monaco/dist/locale/tr.js +326 -78
  114. package/public/vendor/monaco/dist/locale/zh-hans.js +328 -80
  115. package/public/vendor/monaco/dist/locale/zh-hant.js +321 -73
  116. package/public/vendor/monaco/dist/theme/forge.json +236 -0
  117. package/public/vendor/monaco/dist/theme/github-dark.json +348 -0
  118. package/public/vendor/monaco/dist/theme/github-light.json +348 -0
  119. package/public/vendor/monaco/dist/theme/nord.json +93 -0
  120. package/public/vendor/monaco/dist/ts.worker.js +1 -1
  121. package/public/vendor/monaco/dist/ts.worker.js.LICENSE.txt +14 -6
  122. package/public/vendor/vendor.js +9 -15
  123. /package/public/red/tours/{images → 3.0/images}/continuous-search.png +0 -0
  124. /package/public/red/tours/{images → 3.0/images}/debug-path-tooltip.png +0 -0
  125. /package/public/red/tours/{images → 3.0/images}/junction-quick-add.png +0 -0
  126. /package/public/red/tours/{images → 3.0/images}/junction-slice.gif +0 -0
  127. /package/public/red/tours/{images → 3.0/images}/split-wire-with-links.gif +0 -0
@@ -1,75 +1,246 @@
1
1
 
2
2
  /* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
3
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 `parse()` call. In actual
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/v16.9.0/lib/worker_threads.js)
56
+ */
4
57
  declare module 'worker_threads' {
5
- import { Context } from 'vm';
6
- import EventEmitter = require('events');
7
- import { Readable, Writable } from 'stream';
8
- import { URL } from 'url';
9
- import { FileHandle } from 'fs/promises';
10
-
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';
11
66
  const isMainThread: boolean;
12
67
  const parentPort: null | MessagePort;
13
68
  const resourceLimits: ResourceLimits;
14
69
  const SHARE_ENV: unique symbol;
15
70
  const threadId: number;
16
71
  const workerData: any;
17
-
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
+ */
18
87
  class MessageChannel {
19
88
  readonly port1: MessagePort;
20
89
  readonly port2: MessagePort;
21
90
  }
22
-
23
- type TransferListItem = ArrayBuffer | MessagePort | FileHandle;
24
-
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
+ */
25
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
+ */
26
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
+ */
27
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
+ */
28
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
+ */
29
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
+ */
30
210
  start(): void;
31
-
32
- addListener(event: "close", listener: () => void): this;
33
- addListener(event: "message", listener: (value: any) => void): this;
34
- addListener(event: "messageerror", listener: (error: Error) => void): this;
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;
35
214
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
36
-
37
- emit(event: "close"): boolean;
38
- emit(event: "message", value: any): boolean;
39
- emit(event: "messageerror", error: Error): boolean;
215
+ emit(event: 'close'): boolean;
216
+ emit(event: 'message', value: any): boolean;
217
+ emit(event: 'messageerror', error: Error): boolean;
40
218
  emit(event: string | symbol, ...args: any[]): boolean;
41
-
42
- on(event: "close", listener: () => void): this;
43
- on(event: "message", listener: (value: any) => void): this;
44
- on(event: "messageerror", listener: (error: Error) => void): this;
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;
45
222
  on(event: string | symbol, listener: (...args: any[]) => void): this;
46
-
47
- once(event: "close", listener: () => void): this;
48
- once(event: "message", listener: (value: any) => void): this;
49
- once(event: "messageerror", listener: (error: Error) => 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;
50
226
  once(event: string | symbol, listener: (...args: any[]) => void): this;
51
-
52
- prependListener(event: "close", listener: () => void): this;
53
- prependListener(event: "message", listener: (value: any) => void): this;
54
- prependListener(event: "messageerror", listener: (error: Error) => 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;
55
230
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
56
-
57
- prependOnceListener(event: "close", listener: () => void): this;
58
- prependOnceListener(event: "message", listener: (value: any) => void): this;
59
- prependOnceListener(event: "messageerror", listener: (error: Error) => 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;
60
234
  prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
61
-
62
- removeListener(event: "close", listener: () => void): this;
63
- removeListener(event: "message", listener: (value: any) => void): this;
64
- removeListener(event: "messageerror", listener: (error: Error) => 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;
65
238
  removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
66
-
67
- off(event: "close", listener: () => void): this;
68
- off(event: "message", listener: (value: any) => void): this;
69
- off(event: "messageerror", listener: (error: Error) => 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;
70
242
  off(event: string | symbol, listener: (...args: any[]) => void): this;
71
243
  }
72
-
73
244
  interface WorkerOptions {
74
245
  /**
75
246
  * List of arguments which would be stringified and appended to
@@ -90,9 +261,11 @@ declare module 'worker_threads' {
90
261
  * Additional data to send in the first worker message.
91
262
  */
92
263
  transferList?: TransferListItem[] | undefined;
264
+ /**
265
+ * @default true
266
+ */
93
267
  trackUnmanagedFds?: boolean | undefined;
94
268
  }
95
-
96
269
  interface ResourceLimits {
97
270
  /**
98
271
  * The maximum size of a heap space for recently created objects.
@@ -112,132 +285,367 @@ declare module 'worker_threads' {
112
285
  */
113
286
  stackSizeMb?: number | undefined;
114
287
  }
115
-
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
+ */
116
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
+ */
117
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
+ */
118
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
+ */
119
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
+ */
120
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
+ */
121
386
  readonly resourceLimits?: ResourceLimits | undefined;
122
-
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, v12.22.0
391
+ */
392
+ readonly performance: WorkerPerformance;
123
393
  /**
124
394
  * @param filename The path to the Worker’s main script or module.
125
395
  * Must be either an absolute path or a relative path (i.e. relative to the current working directory) starting with ./ or ../,
126
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.
127
397
  */
128
398
  constructor(filename: string | URL, options?: WorkerOptions);
129
-
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
+ */
130
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
+ */
131
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
+ */
132
417
  unref(): void;
133
418
  /**
134
419
  * Stop all JavaScript execution in the worker thread as soon as possible.
135
- * Returns a Promise for the exit code that is fulfilled when the `exit` event is emitted.
420
+ * Returns a Promise for the exit code that is fulfilled when the `'exit' event` is emitted.
421
+ * @since v10.5.0
136
422
  */
137
423
  terminate(): Promise<number>;
138
-
139
424
  /**
140
425
  * Returns a readable stream for a V8 snapshot of the current state of the Worker.
141
- * See [`v8.getHeapSnapshot()`][] for more details.
426
+ * See `v8.getHeapSnapshot()` for more details.
142
427
  *
143
- * If the Worker thread is no longer running, which may occur before the
144
- * [`'exit'` event][] is emitted, the returned `Promise` will be rejected
145
- * immediately with an [`ERR_WORKER_NOT_RUNNING`][] error
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
146
432
  */
147
433
  getHeapSnapshot(): Promise<Readable>;
148
-
149
- addListener(event: "error", listener: (err: Error) => void): this;
150
- addListener(event: "exit", listener: (exitCode: number) => void): this;
151
- addListener(event: "message", listener: (value: any) => void): this;
152
- addListener(event: "messageerror", listener: (error: Error) => void): this;
153
- addListener(event: "online", listener: () => void): this;
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;
154
439
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
155
-
156
- emit(event: "error", err: Error): boolean;
157
- emit(event: "exit", exitCode: number): boolean;
158
- emit(event: "message", value: any): boolean;
159
- emit(event: "messageerror", error: Error): boolean;
160
- emit(event: "online"): boolean;
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;
161
445
  emit(event: string | symbol, ...args: any[]): boolean;
162
-
163
- on(event: "error", listener: (err: Error) => void): this;
164
- on(event: "exit", listener: (exitCode: number) => void): this;
165
- on(event: "message", listener: (value: any) => void): this;
166
- on(event: "messageerror", listener: (error: Error) => void): this;
167
- on(event: "online", listener: () => void): this;
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;
168
451
  on(event: string | symbol, listener: (...args: any[]) => void): this;
169
-
170
- once(event: "error", listener: (err: Error) => void): this;
171
- once(event: "exit", listener: (exitCode: number) => void): this;
172
- once(event: "message", listener: (value: any) => void): this;
173
- once(event: "messageerror", listener: (error: Error) => void): this;
174
- once(event: "online", listener: () => 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;
175
457
  once(event: string | symbol, listener: (...args: any[]) => void): this;
176
-
177
- prependListener(event: "error", listener: (err: Error) => void): this;
178
- prependListener(event: "exit", listener: (exitCode: number) => void): this;
179
- prependListener(event: "message", listener: (value: any) => void): this;
180
- prependListener(event: "messageerror", listener: (error: Error) => void): this;
181
- prependListener(event: "online", listener: () => 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;
182
463
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
183
-
184
- prependOnceListener(event: "error", listener: (err: Error) => void): this;
185
- prependOnceListener(event: "exit", listener: (exitCode: number) => void): this;
186
- prependOnceListener(event: "message", listener: (value: any) => void): this;
187
- prependOnceListener(event: "messageerror", listener: (error: Error) => void): this;
188
- prependOnceListener(event: "online", listener: () => 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;
189
469
  prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
190
-
191
- removeListener(event: "error", listener: (err: Error) => void): this;
192
- removeListener(event: "exit", listener: (exitCode: number) => void): this;
193
- removeListener(event: "message", listener: (value: any) => void): this;
194
- removeListener(event: "messageerror", listener: (error: Error) => void): this;
195
- removeListener(event: "online", listener: () => 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;
196
475
  removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
197
-
198
- off(event: "error", listener: (err: Error) => void): this;
199
- off(event: "exit", listener: (exitCode: number) => void): this;
200
- off(event: "message", listener: (value: any) => void): this;
201
- off(event: "messageerror", listener: (error: Error) => void): this;
202
- off(event: "online", listener: () => 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;
203
481
  off(event: string | symbol, listener: (...args: any[]) => void): this;
204
482
  }
205
-
483
+ interface BroadcastChannel extends NodeJS.RefCounted {}
206
484
  /**
207
- * Mark an object as not transferable.
208
- * If `object` occurs in the transfer list of a `port.postMessage()` call, it will be ignored.
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');
209
496
  *
210
- * In particular, this makes sense for objects that can be cloned, rather than transferred,
211
- * and which are used by other objects on the sending side. For example, Node.js marks
212
- * the `ArrayBuffer`s it uses for its Buffer pool with this.
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
+ * @experimental
514
+ */
515
+ class BroadcastChannel {
516
+ readonly name: string;
517
+ /**
518
+ * Invoked with a single \`MessageEvent\` argument when a message is received.
519
+ * @since v15.4.0
520
+ */
521
+ onmessage: (message: unknown) => void;
522
+ /**
523
+ * Invoked with a received message cannot be deserialized.
524
+ * @since v15.4.0
525
+ */
526
+ onmessageerror: (message: unknown) => void;
527
+ constructor(name: string);
528
+ /**
529
+ * Closes the `BroadcastChannel` connection.
530
+ * @since v15.4.0
531
+ */
532
+ close(): void;
533
+ /**
534
+ * @since v15.4.0
535
+ * @param message Any cloneable JavaScript value.
536
+ */
537
+ postMessage(message: unknown): void;
538
+ }
539
+ /**
540
+ * Mark an object as not transferable. If `object` occurs in the transfer list of
541
+ * a `port.postMessage()` call, it is ignored.
542
+ *
543
+ * In particular, this makes sense for objects that can be cloned, rather than
544
+ * transferred, and which are used by other objects on the sending side.
545
+ * For example, Node.js marks the `ArrayBuffer`s it uses for its `Buffer pool` with this.
213
546
  *
214
547
  * This operation cannot be undone.
548
+ *
549
+ * ```js
550
+ * const { MessageChannel, markAsUntransferable } = require('worker_threads');
551
+ *
552
+ * const pooledBuffer = new ArrayBuffer(8);
553
+ * const typedArray1 = new Uint8Array(pooledBuffer);
554
+ * const typedArray2 = new Float64Array(pooledBuffer);
555
+ *
556
+ * markAsUntransferable(pooledBuffer);
557
+ *
558
+ * const { port1 } = new MessageChannel();
559
+ * port1.postMessage(typedArray1, [ typedArray1.buffer ]);
560
+ *
561
+ * // The following line prints the contents of typedArray1 -- it still owns
562
+ * // its memory and has been cloned, not transferred. Without
563
+ * // `markAsUntransferable()`, this would print an empty Uint8Array.
564
+ * // typedArray2 is intact as well.
565
+ * console.log(typedArray1);
566
+ * console.log(typedArray2);
567
+ * ```
568
+ *
569
+ * There is no equivalent to this API in browsers.
570
+ * @since v14.5.0, v12.19.0
215
571
  */
216
572
  function markAsUntransferable(object: object): void;
217
-
218
573
  /**
219
- * Transfer a `MessagePort` to a different `vm` Context. The original `port`
220
- * object will be rendered unusable, and the returned `MessagePort` instance will
221
- * take its place.
574
+ * Transfer a `MessagePort` to a different `vm` Context. The original `port`object is rendered unusable, and the returned `MessagePort` instance
575
+ * takes its place.
222
576
  *
223
- * The returned `MessagePort` will be an object in the target context, and will
224
- * inherit from its global `Object` class. Objects passed to the
225
- * `port.onmessage()` listener will also be created in the target context
577
+ * The returned `MessagePort` is an object in the target context and
578
+ * 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
579
+ * target context
226
580
  * and inherit from its global `Object` class.
227
581
  *
228
- * However, the created `MessagePort` will no longer inherit from
229
- * `EventEmitter`, and only `port.onmessage()` can be used to receive
582
+ * However, the created `MessagePort` no longer inherits from [`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget), and only
583
+ * [`port.onmessage()`](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/onmessage) can be used to receive
230
584
  * events using it.
585
+ * @since v11.13.0
586
+ * @param port The message port to transfer.
587
+ * @param contextifiedSandbox A `contextified` object as returned by the `vm.createContext()` method.
231
588
  */
232
- function moveMessagePortToContext(port: MessagePort, context: Context): MessagePort;
233
-
589
+ function moveMessagePortToContext(port: MessagePort, contextifiedSandbox: Context): MessagePort;
590
+ /**
591
+ * Receive a single message from a given `MessagePort`. If no message is available,`undefined` is returned, otherwise an object with a single `message` property
592
+ * that contains the message payload, corresponding to the oldest message in the`MessagePort`’s queue.
593
+ *
594
+ * ```js
595
+ * const { MessageChannel, receiveMessageOnPort } = require('worker_threads');
596
+ * const { port1, port2 } = new MessageChannel();
597
+ * port1.postMessage({ hello: 'world' });
598
+ *
599
+ * console.log(receiveMessageOnPort(port2));
600
+ * // Prints: { message: { hello: 'world' } }
601
+ * console.log(receiveMessageOnPort(port2));
602
+ * // Prints: undefined
603
+ * ```
604
+ *
605
+ * When this function is used, no `'message'` event is emitted and the`onmessage` listener is not invoked.
606
+ * @since v12.3.0
607
+ */
608
+ function receiveMessageOnPort(port: MessagePort):
609
+ | {
610
+ message: any;
611
+ }
612
+ | undefined;
613
+ type Serializable = string | object | number | boolean | bigint;
614
+ /**
615
+ * Within a worker thread, `worker.getEnvironmentData()` returns a clone
616
+ * of data passed to the spawning thread's `worker.setEnvironmentData()`.
617
+ * Every new `Worker` receives its own copy of the environment data
618
+ * automatically.
619
+ *
620
+ * ```js
621
+ * const {
622
+ * Worker,
623
+ * isMainThread,
624
+ * setEnvironmentData,
625
+ * getEnvironmentData,
626
+ * } = require('worker_threads');
627
+ *
628
+ * if (isMainThread) {
629
+ * setEnvironmentData('Hello', 'World!');
630
+ * const worker = new Worker(__filename);
631
+ * } else {
632
+ * console.log(getEnvironmentData('Hello')); // Prints 'World!'.
633
+ * }
634
+ * ```
635
+ * @since v15.12.0
636
+ * @experimental
637
+ * @param key Any arbitrary, cloneable JavaScript value that can be used as a {Map} key.
638
+ */
639
+ function getEnvironmentData(key: Serializable): Serializable;
234
640
  /**
235
- * Receive a single message from a given `MessagePort`. If no message is available,
236
- * `undefined` is returned, otherwise an object with a single `message` property
237
- * that contains the message payload, corresponding to the oldest message in the
238
- * `MessagePort`’s queue.
641
+ * The `worker.setEnvironmentData()` API sets the content of`worker.getEnvironmentData()` in the current thread and all new `Worker`instances spawned from the current context.
642
+ * @since v15.12.0
643
+ * @experimental
644
+ * @param key Any arbitrary, cloneable JavaScript value that can be used as a {Map} key.
645
+ * @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
646
+ * for the `key` will be deleted.
239
647
  */
240
- function receiveMessageOnPort(port: MessagePort): { message: any } | undefined;
648
+ function setEnvironmentData(key: Serializable, value: Serializable): void;
241
649
  }
242
650
  declare module 'node:worker_threads' {
243
651
  export * from 'worker_threads';