@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,681 @@
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
+ * Much of the Node.js core API is built around an idiomatic asynchronous
6
+ * event-driven architecture in which certain kinds of objects (called "emitters")
7
+ * emit named events that cause `Function` objects ("listeners") to be called.
8
+ *
9
+ * For instance: a `net.Server` object emits an event each time a peer
10
+ * connects to it; a `fs.ReadStream` emits an event when the file is opened;
11
+ * a `stream` emits an event whenever data is available to be read.
12
+ *
13
+ * All objects that emit events are instances of the `EventEmitter` class. These
14
+ * objects expose an `eventEmitter.on()` function that allows one or more
15
+ * functions to be attached to named events emitted by the object. Typically,
16
+ * event names are camel-cased strings but any valid JavaScript property key
17
+ * can be used.
18
+ *
19
+ * When the `EventEmitter` object emits an event, all of the functions attached
20
+ * to that specific event are called _synchronously_. Any values returned by the
21
+ * called listeners are _ignored_ and discarded.
22
+ *
23
+ * The following example shows a simple `EventEmitter` instance with a single
24
+ * listener. The `eventEmitter.on()` method is used to register listeners, while
25
+ * the `eventEmitter.emit()` method is used to trigger the event.
26
+ *
27
+ * ```js
28
+ * const EventEmitter = require('events');
29
+ *
30
+ * class MyEmitter extends EventEmitter {}
31
+ *
32
+ * const myEmitter = new MyEmitter();
33
+ * myEmitter.on('event', () => {
34
+ * console.log('an event occurred!');
35
+ * });
36
+ * myEmitter.emit('event');
37
+ * ```
38
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/events.js)
39
+ */
40
+ declare module 'events' {
41
+ // NOTE: This class is in the docs but is **not actually exported** by Node.
42
+ // If https://github.com/nodejs/node/issues/39903 gets resolved and Node
43
+ // actually starts exporting the class, uncomment below.
44
+
45
+ // import { EventListener, EventListenerObject } from '__dom-events';
46
+ // /** The NodeEventTarget is a Node.js-specific extension to EventTarget that emulates a subset of the EventEmitter API. */
47
+ // interface NodeEventTarget extends EventTarget {
48
+ // /**
49
+ // * Node.js-specific extension to the `EventTarget` class that emulates the equivalent `EventEmitter` API.
50
+ // * The only difference between `addListener()` and `addEventListener()` is that addListener() will return a reference to the EventTarget.
51
+ // */
52
+ // addListener(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this;
53
+ // /** Node.js-specific extension to the `EventTarget` class that returns an array of event `type` names for which event listeners are registered. */
54
+ // eventNames(): string[];
55
+ // /** Node.js-specific extension to the `EventTarget` class that returns the number of event listeners registered for the `type`. */
56
+ // listenerCount(type: string): number;
57
+ // /** Node.js-specific alias for `eventTarget.removeListener()`. */
58
+ // off(type: string, listener: EventListener | EventListenerObject): this;
59
+ // /** Node.js-specific alias for `eventTarget.addListener()`. */
60
+ // on(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this;
61
+ // /** Node.js-specific extension to the `EventTarget` class that adds a `once` listener for the given event `type`. This is equivalent to calling `on` with the `once` option set to `true`. */
62
+ // once(type: string, listener: EventListener | EventListenerObject): this;
63
+ // /**
64
+ // * Node.js-specific extension to the `EventTarget` class.
65
+ // * If `type` is specified, removes all registered listeners for `type`,
66
+ // * otherwise removes all registered listeners.
67
+ // */
68
+ // removeAllListeners(type: string): this;
69
+ // /**
70
+ // * Node.js-specific extension to the `EventTarget` class that removes the listener for the given `type`.
71
+ // * The only difference between `removeListener()` and `removeEventListener()` is that `removeListener()` will return a reference to the `EventTarget`.
72
+ // */
73
+ // removeListener(type: string, listener: EventListener | EventListenerObject): this;
74
+ // }
75
+
76
+ interface EventEmitterOptions {
77
+ /**
78
+ * Enables automatic capturing of promise rejection.
79
+ */
80
+ captureRejections?: boolean | undefined;
81
+ }
82
+ // Any EventTarget with a Node-style `once` function
83
+ interface _NodeEventTarget {
84
+ once(eventName: string | symbol, listener: (...args: any[]) => void): this;
85
+ }
86
+ // Any EventTarget with a DOM-style `addEventListener`
87
+ interface _DOMEventTarget {
88
+ addEventListener(
89
+ eventName: string,
90
+ listener: (...args: any[]) => void,
91
+ opts?: {
92
+ once: boolean;
93
+ }
94
+ ): any;
95
+ }
96
+ interface StaticEventEmitterOptions {
97
+ signal?: AbortSignal | undefined;
98
+ }
99
+ interface EventEmitter extends NodeJS.EventEmitter {}
100
+ /**
101
+ * The `EventEmitter` class is defined and exposed by the `events` module:
102
+ *
103
+ * ```js
104
+ * const EventEmitter = require('events');
105
+ * ```
106
+ *
107
+ * All `EventEmitter`s emit the event `'newListener'` when new listeners are
108
+ * added and `'removeListener'` when existing listeners are removed.
109
+ *
110
+ * It supports the following option:
111
+ * @since v0.1.26
112
+ */
113
+ class EventEmitter {
114
+ constructor(options?: EventEmitterOptions);
115
+ /**
116
+ * Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
117
+ * event or that is rejected if the `EventEmitter` emits `'error'` while waiting.
118
+ * The `Promise` will resolve with an array of all the arguments emitted to the
119
+ * given event.
120
+ *
121
+ * This method is intentionally generic and works with the web platform [EventTarget](https://dom.spec.whatwg.org/#interface-eventtarget) interface, which has no special`'error'` event
122
+ * semantics and does not listen to the `'error'` event.
123
+ *
124
+ * ```js
125
+ * const { once, EventEmitter } = require('events');
126
+ *
127
+ * async function run() {
128
+ * const ee = new EventEmitter();
129
+ *
130
+ * process.nextTick(() => {
131
+ * ee.emit('myevent', 42);
132
+ * });
133
+ *
134
+ * const [value] = await once(ee, 'myevent');
135
+ * console.log(value);
136
+ *
137
+ * const err = new Error('kaboom');
138
+ * process.nextTick(() => {
139
+ * ee.emit('error', err);
140
+ * });
141
+ *
142
+ * try {
143
+ * await once(ee, 'myevent');
144
+ * } catch (err) {
145
+ * console.log('error happened', err);
146
+ * }
147
+ * }
148
+ *
149
+ * run();
150
+ * ```
151
+ *
152
+ * The special handling of the `'error'` event is only used when `events.once()`is used to wait for another event. If `events.once()` is used to wait for the
153
+ * '`error'` event itself, then it is treated as any other kind of event without
154
+ * special handling:
155
+ *
156
+ * ```js
157
+ * const { EventEmitter, once } = require('events');
158
+ *
159
+ * const ee = new EventEmitter();
160
+ *
161
+ * once(ee, 'error')
162
+ * .then(([err]) => console.log('ok', err.message))
163
+ * .catch((err) => console.log('error', err.message));
164
+ *
165
+ * ee.emit('error', new Error('boom'));
166
+ *
167
+ * // Prints: ok boom
168
+ * ```
169
+ *
170
+ * An `AbortSignal` can be used to cancel waiting for the event:
171
+ *
172
+ * ```js
173
+ * const { EventEmitter, once } = require('events');
174
+ *
175
+ * const ee = new EventEmitter();
176
+ * const ac = new AbortController();
177
+ *
178
+ * async function foo(emitter, event, signal) {
179
+ * try {
180
+ * await once(emitter, event, { signal });
181
+ * console.log('event emitted!');
182
+ * } catch (error) {
183
+ * if (error.name === 'AbortError') {
184
+ * console.error('Waiting for the event was canceled!');
185
+ * } else {
186
+ * console.error('There was an error', error.message);
187
+ * }
188
+ * }
189
+ * }
190
+ *
191
+ * foo(ee, 'foo', ac.signal);
192
+ * ac.abort(); // Abort waiting for the event
193
+ * ee.emit('foo'); // Prints: Waiting for the event was canceled!
194
+ * ```
195
+ * @since v11.13.0, v10.16.0
196
+ */
197
+ static once(emitter: _NodeEventTarget, eventName: string | symbol, options?: StaticEventEmitterOptions): Promise<any[]>;
198
+ static once(emitter: _DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise<any[]>;
199
+ /**
200
+ * ```js
201
+ * const { on, EventEmitter } = require('events');
202
+ *
203
+ * (async () => {
204
+ * const ee = new EventEmitter();
205
+ *
206
+ * // Emit later on
207
+ * process.nextTick(() => {
208
+ * ee.emit('foo', 'bar');
209
+ * ee.emit('foo', 42);
210
+ * });
211
+ *
212
+ * for await (const event of on(ee, 'foo')) {
213
+ * // The execution of this inner block is synchronous and it
214
+ * // processes one event at a time (even with await). Do not use
215
+ * // if concurrent execution is required.
216
+ * console.log(event); // prints ['bar'] [42]
217
+ * }
218
+ * // Unreachable here
219
+ * })();
220
+ * ```
221
+ *
222
+ * Returns an `AsyncIterator` that iterates `eventName` events. It will throw
223
+ * if the `EventEmitter` emits `'error'`. It removes all listeners when
224
+ * exiting the loop. The `value` returned by each iteration is an array
225
+ * composed of the emitted event arguments.
226
+ *
227
+ * An `AbortSignal` can be used to cancel waiting on events:
228
+ *
229
+ * ```js
230
+ * const { on, EventEmitter } = require('events');
231
+ * const ac = new AbortController();
232
+ *
233
+ * (async () => {
234
+ * const ee = new EventEmitter();
235
+ *
236
+ * // Emit later on
237
+ * process.nextTick(() => {
238
+ * ee.emit('foo', 'bar');
239
+ * ee.emit('foo', 42);
240
+ * });
241
+ *
242
+ * for await (const event of on(ee, 'foo', { signal: ac.signal })) {
243
+ * // The execution of this inner block is synchronous and it
244
+ * // processes one event at a time (even with await). Do not use
245
+ * // if concurrent execution is required.
246
+ * console.log(event); // prints ['bar'] [42]
247
+ * }
248
+ * // Unreachable here
249
+ * })();
250
+ *
251
+ * process.nextTick(() => ac.abort());
252
+ * ```
253
+ * @since v13.6.0, v12.16.0
254
+ * @param eventName The name of the event being listened for
255
+ * @return that iterates `eventName` events emitted by the `emitter`
256
+ */
257
+ static on(emitter: NodeJS.EventEmitter, eventName: string, options?: StaticEventEmitterOptions): AsyncIterableIterator<any>;
258
+ /**
259
+ * A class method that returns the number of listeners for the given `eventName`registered on the given `emitter`.
260
+ *
261
+ * ```js
262
+ * const { EventEmitter, listenerCount } = require('events');
263
+ * const myEmitter = new EventEmitter();
264
+ * myEmitter.on('event', () => {});
265
+ * myEmitter.on('event', () => {});
266
+ * console.log(listenerCount(myEmitter, 'event'));
267
+ * // Prints: 2
268
+ * ```
269
+ * @since v0.9.12
270
+ * @deprecated Since v3.2.0 - Use `listenerCount` instead.
271
+ * @param emitter The emitter to query
272
+ * @param eventName The event name
273
+ */
274
+ static listenerCount(emitter: NodeJS.EventEmitter, eventName: string | symbol): number;
275
+ /**
276
+ * Returns a copy of the array of listeners for the event named `eventName`.
277
+ *
278
+ * For `EventEmitter`s this behaves exactly the same as calling `.listeners` on
279
+ * the emitter.
280
+ *
281
+ * For `EventTarget`s this is the only way to get the event listeners for the
282
+ * event target. This is useful for debugging and diagnostic purposes.
283
+ *
284
+ * ```js
285
+ * const { getEventListeners, EventEmitter } = require('events');
286
+ *
287
+ * {
288
+ * const ee = new EventEmitter();
289
+ * const listener = () => console.log('Events are fun');
290
+ * ee.on('foo', listener);
291
+ * getEventListeners(ee, 'foo'); // [listener]
292
+ * }
293
+ * {
294
+ * const et = new EventTarget();
295
+ * const listener = () => console.log('Events are fun');
296
+ * et.addEventListener('foo', listener);
297
+ * getEventListeners(et, 'foo'); // [listener]
298
+ * }
299
+ * ```
300
+ * @since v15.2.0, v14.17.0
301
+ */
302
+ static getEventListeners(emitter: _DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[];
303
+ /**
304
+ * ```js
305
+ * const {
306
+ * setMaxListeners,
307
+ * EventEmitter
308
+ * } = require('events');
309
+ *
310
+ * const target = new EventTarget();
311
+ * const emitter = new EventEmitter();
312
+ *
313
+ * setMaxListeners(5, target, emitter);
314
+ * ```
315
+ * @since v15.4.0
316
+ * @param n A non-negative number. The maximum number of listeners per `EventTarget` event.
317
+ * @param eventsTargets Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, `n` is set as the default max for all newly created {EventTarget} and {EventEmitter}
318
+ * objects.
319
+ */
320
+ static setMaxListeners(n?: number, ...eventTargets: Array<_DOMEventTarget | NodeJS.EventEmitter>): void;
321
+ /**
322
+ * This symbol shall be used to install a listener for only monitoring `'error'`
323
+ * events. Listeners installed using this symbol are called before the regular
324
+ * `'error'` listeners are called.
325
+ *
326
+ * Installing a listener using this symbol does not change the behavior once an
327
+ * `'error'` event is emitted, therefore the process will still crash if no
328
+ * regular `'error'` listener is installed.
329
+ */
330
+ static readonly errorMonitor: unique symbol;
331
+ static readonly captureRejectionSymbol: unique symbol;
332
+ /**
333
+ * Sets or gets the default captureRejection value for all emitters.
334
+ */
335
+ // TODO: These should be described using static getter/setter pairs:
336
+ static captureRejections: boolean;
337
+ static defaultMaxListeners: number;
338
+ }
339
+ import internal = require('node:events');
340
+ namespace EventEmitter {
341
+ // Should just be `export { EventEmitter }`, but that doesn't work in TypeScript 3.4
342
+ export { internal as EventEmitter };
343
+ export interface Abortable {
344
+ /**
345
+ * When provided the corresponding `AbortController` can be used to cancel an asynchronous action.
346
+ */
347
+ signal?: AbortSignal | undefined;
348
+ }
349
+ }
350
+ global {
351
+ namespace NodeJS {
352
+ interface EventEmitter {
353
+ /**
354
+ * Alias for `emitter.on(eventName, listener)`.
355
+ * @since v0.1.26
356
+ */
357
+ addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
358
+ /**
359
+ * Adds the `listener` function to the end of the listeners array for the
360
+ * event named `eventName`. No checks are made to see if the `listener` has
361
+ * already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple
362
+ * times.
363
+ *
364
+ * ```js
365
+ * server.on('connection', (stream) => {
366
+ * console.log('someone connected!');
367
+ * });
368
+ * ```
369
+ *
370
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
371
+ *
372
+ * By default, event listeners are invoked in the order they are added. The`emitter.prependListener()` method can be used as an alternative to add the
373
+ * event listener to the beginning of the listeners array.
374
+ *
375
+ * ```js
376
+ * const myEE = new EventEmitter();
377
+ * myEE.on('foo', () => console.log('a'));
378
+ * myEE.prependListener('foo', () => console.log('b'));
379
+ * myEE.emit('foo');
380
+ * // Prints:
381
+ * // b
382
+ * // a
383
+ * ```
384
+ * @since v0.1.101
385
+ * @param eventName The name of the event.
386
+ * @param listener The callback function
387
+ */
388
+ on(eventName: string | symbol, listener: (...args: any[]) => void): this;
389
+ /**
390
+ * Adds a **one-time**`listener` function for the event named `eventName`. The
391
+ * next time `eventName` is triggered, this listener is removed and then invoked.
392
+ *
393
+ * ```js
394
+ * server.once('connection', (stream) => {
395
+ * console.log('Ah, we have our first user!');
396
+ * });
397
+ * ```
398
+ *
399
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
400
+ *
401
+ * By default, event listeners are invoked in the order they are added. The`emitter.prependOnceListener()` method can be used as an alternative to add the
402
+ * event listener to the beginning of the listeners array.
403
+ *
404
+ * ```js
405
+ * const myEE = new EventEmitter();
406
+ * myEE.once('foo', () => console.log('a'));
407
+ * myEE.prependOnceListener('foo', () => console.log('b'));
408
+ * myEE.emit('foo');
409
+ * // Prints:
410
+ * // b
411
+ * // a
412
+ * ```
413
+ * @since v0.3.0
414
+ * @param eventName The name of the event.
415
+ * @param listener The callback function
416
+ */
417
+ once(eventName: string | symbol, listener: (...args: any[]) => void): this;
418
+ /**
419
+ * Removes the specified `listener` from the listener array for the event named`eventName`.
420
+ *
421
+ * ```js
422
+ * const callback = (stream) => {
423
+ * console.log('someone connected!');
424
+ * };
425
+ * server.on('connection', callback);
426
+ * // ...
427
+ * server.removeListener('connection', callback);
428
+ * ```
429
+ *
430
+ * `removeListener()` will remove, at most, one instance of a listener from the
431
+ * listener array. If any single listener has been added multiple times to the
432
+ * listener array for the specified `eventName`, then `removeListener()` must be
433
+ * called multiple times to remove each instance.
434
+ *
435
+ * Once an event is emitted, all listeners attached to it at the
436
+ * time of emitting are called in order. This implies that any`removeListener()` or `removeAllListeners()` calls _after_ emitting and _before_ the last listener finishes execution
437
+ * will not remove them from`emit()` in progress. Subsequent events behave as expected.
438
+ *
439
+ * ```js
440
+ * const myEmitter = new MyEmitter();
441
+ *
442
+ * const callbackA = () => {
443
+ * console.log('A');
444
+ * myEmitter.removeListener('event', callbackB);
445
+ * };
446
+ *
447
+ * const callbackB = () => {
448
+ * console.log('B');
449
+ * };
450
+ *
451
+ * myEmitter.on('event', callbackA);
452
+ *
453
+ * myEmitter.on('event', callbackB);
454
+ *
455
+ * // callbackA removes listener callbackB but it will still be called.
456
+ * // Internal listener array at time of emit [callbackA, callbackB]
457
+ * myEmitter.emit('event');
458
+ * // Prints:
459
+ * // A
460
+ * // B
461
+ *
462
+ * // callbackB is now removed.
463
+ * // Internal listener array [callbackA]
464
+ * myEmitter.emit('event');
465
+ * // Prints:
466
+ * // A
467
+ * ```
468
+ *
469
+ * Because listeners are managed using an internal array, calling this will
470
+ * change the position indices of any listener registered _after_ the listener
471
+ * being removed. This will not impact the order in which listeners are called,
472
+ * but it means that any copies of the listener array as returned by
473
+ * the `emitter.listeners()` method will need to be recreated.
474
+ *
475
+ * When a single function has been added as a handler multiple times for a single
476
+ * event (as in the example below), `removeListener()` will remove the most
477
+ * recently added instance. In the example the `once('ping')`listener is removed:
478
+ *
479
+ * ```js
480
+ * const ee = new EventEmitter();
481
+ *
482
+ * function pong() {
483
+ * console.log('pong');
484
+ * }
485
+ *
486
+ * ee.on('ping', pong);
487
+ * ee.once('ping', pong);
488
+ * ee.removeListener('ping', pong);
489
+ *
490
+ * ee.emit('ping');
491
+ * ee.emit('ping');
492
+ * ```
493
+ *
494
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
495
+ * @since v0.1.26
496
+ */
497
+ removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
498
+ /**
499
+ * Alias for `emitter.removeListener()`.
500
+ * @since v10.0.0
501
+ */
502
+ off(eventName: string | symbol, listener: (...args: any[]) => void): this;
503
+ /**
504
+ * Removes all listeners, or those of the specified `eventName`.
505
+ *
506
+ * It is bad practice to remove listeners added elsewhere in the code,
507
+ * particularly when the `EventEmitter` instance was created by some other
508
+ * component or module (e.g. sockets or file streams).
509
+ *
510
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
511
+ * @since v0.1.26
512
+ */
513
+ removeAllListeners(event?: string | symbol): this;
514
+ /**
515
+ * By default `EventEmitter`s will print a warning if more than `10` listeners are
516
+ * added for a particular event. This is a useful default that helps finding
517
+ * memory leaks. The `emitter.setMaxListeners()` method allows the limit to be
518
+ * modified for this specific `EventEmitter` instance. The value can be set to`Infinity` (or `0`) to indicate an unlimited number of listeners.
519
+ *
520
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
521
+ * @since v0.3.5
522
+ */
523
+ setMaxListeners(n: number): this;
524
+ /**
525
+ * Returns the current max listener value for the `EventEmitter` which is either
526
+ * set by `emitter.setMaxListeners(n)` or defaults to {@link defaultMaxListeners}.
527
+ * @since v1.0.0
528
+ */
529
+ getMaxListeners(): number;
530
+ /**
531
+ * Returns a copy of the array of listeners for the event named `eventName`.
532
+ *
533
+ * ```js
534
+ * server.on('connection', (stream) => {
535
+ * console.log('someone connected!');
536
+ * });
537
+ * console.log(util.inspect(server.listeners('connection')));
538
+ * // Prints: [ [Function] ]
539
+ * ```
540
+ * @since v0.1.26
541
+ */
542
+ listeners(eventName: string | symbol): Function[];
543
+ /**
544
+ * Returns a copy of the array of listeners for the event named `eventName`,
545
+ * including any wrappers (such as those created by `.once()`).
546
+ *
547
+ * ```js
548
+ * const emitter = new EventEmitter();
549
+ * emitter.once('log', () => console.log('log once'));
550
+ *
551
+ * // Returns a new Array with a function `onceWrapper` which has a property
552
+ * // `listener` which contains the original listener bound above
553
+ * const listeners = emitter.rawListeners('log');
554
+ * const logFnWrapper = listeners[0];
555
+ *
556
+ * // Logs "log once" to the console and does not unbind the `once` event
557
+ * logFnWrapper.listener();
558
+ *
559
+ * // Logs "log once" to the console and removes the listener
560
+ * logFnWrapper();
561
+ *
562
+ * emitter.on('log', () => console.log('log persistently'));
563
+ * // Will return a new Array with a single function bound by `.on()` above
564
+ * const newListeners = emitter.rawListeners('log');
565
+ *
566
+ * // Logs "log persistently" twice
567
+ * newListeners[0]();
568
+ * emitter.emit('log');
569
+ * ```
570
+ * @since v9.4.0
571
+ */
572
+ rawListeners(eventName: string | symbol): Function[];
573
+ /**
574
+ * Synchronously calls each of the listeners registered for the event named`eventName`, in the order they were registered, passing the supplied arguments
575
+ * to each.
576
+ *
577
+ * Returns `true` if the event had listeners, `false` otherwise.
578
+ *
579
+ * ```js
580
+ * const EventEmitter = require('events');
581
+ * const myEmitter = new EventEmitter();
582
+ *
583
+ * // First listener
584
+ * myEmitter.on('event', function firstListener() {
585
+ * console.log('Helloooo! first listener');
586
+ * });
587
+ * // Second listener
588
+ * myEmitter.on('event', function secondListener(arg1, arg2) {
589
+ * console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
590
+ * });
591
+ * // Third listener
592
+ * myEmitter.on('event', function thirdListener(...args) {
593
+ * const parameters = args.join(', ');
594
+ * console.log(`event with parameters ${parameters} in third listener`);
595
+ * });
596
+ *
597
+ * console.log(myEmitter.listeners('event'));
598
+ *
599
+ * myEmitter.emit('event', 1, 2, 3, 4, 5);
600
+ *
601
+ * // Prints:
602
+ * // [
603
+ * // [Function: firstListener],
604
+ * // [Function: secondListener],
605
+ * // [Function: thirdListener]
606
+ * // ]
607
+ * // Helloooo! first listener
608
+ * // event with parameters 1, 2 in second listener
609
+ * // event with parameters 1, 2, 3, 4, 5 in third listener
610
+ * ```
611
+ * @since v0.1.26
612
+ */
613
+ emit(eventName: string | symbol, ...args: any[]): boolean;
614
+ /**
615
+ * Returns the number of listeners listening to the event named `eventName`.
616
+ * @since v3.2.0
617
+ * @param eventName The name of the event being listened for
618
+ */
619
+ listenerCount(eventName: string | symbol): number;
620
+ /**
621
+ * Adds the `listener` function to the _beginning_ of the listeners array for the
622
+ * event named `eventName`. No checks are made to see if the `listener` has
623
+ * already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple
624
+ * times.
625
+ *
626
+ * ```js
627
+ * server.prependListener('connection', (stream) => {
628
+ * console.log('someone connected!');
629
+ * });
630
+ * ```
631
+ *
632
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
633
+ * @since v6.0.0
634
+ * @param eventName The name of the event.
635
+ * @param listener The callback function
636
+ */
637
+ prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
638
+ /**
639
+ * Adds a **one-time**`listener` function for the event named `eventName` to the _beginning_ of the listeners array. The next time `eventName` is triggered, this
640
+ * listener is removed, and then invoked.
641
+ *
642
+ * ```js
643
+ * server.prependOnceListener('connection', (stream) => {
644
+ * console.log('Ah, we have our first user!');
645
+ * });
646
+ * ```
647
+ *
648
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
649
+ * @since v6.0.0
650
+ * @param eventName The name of the event.
651
+ * @param listener The callback function
652
+ */
653
+ prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
654
+ /**
655
+ * Returns an array listing the events for which the emitter has registered
656
+ * listeners. The values in the array are strings or `Symbol`s.
657
+ *
658
+ * ```js
659
+ * const EventEmitter = require('events');
660
+ * const myEE = new EventEmitter();
661
+ * myEE.on('foo', () => {});
662
+ * myEE.on('bar', () => {});
663
+ *
664
+ * const sym = Symbol('symbol');
665
+ * myEE.on(sym, () => {});
666
+ *
667
+ * console.log(myEE.eventNames());
668
+ * // Prints: [ 'foo', 'bar', Symbol(symbol) ]
669
+ * ```
670
+ * @since v6.0.0
671
+ */
672
+ eventNames(): Array<string | symbol>;
673
+ }
674
+ }
675
+ }
676
+ export = EventEmitter;
677
+ }
678
+ declare module 'node:events' {
679
+ import events = require('events');
680
+ export = events;
681
+ }