mediasoup-client 3.6.59 → 3.6.60

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 (86) hide show
  1. package/README.md +17 -3
  2. package/lib/Consumer.d.ts +3 -3
  3. package/lib/Consumer.d.ts.map +1 -1
  4. package/lib/DataConsumer.d.ts +3 -3
  5. package/lib/DataConsumer.d.ts.map +1 -1
  6. package/lib/DataProducer.d.ts +3 -3
  7. package/lib/DataProducer.d.ts.map +1 -1
  8. package/lib/Device.d.ts +3 -3
  9. package/lib/Device.d.ts.map +1 -1
  10. package/lib/EnhancedEventEmitter.d.ts +1 -1
  11. package/lib/EnhancedEventEmitter.d.ts.map +1 -1
  12. package/lib/Producer.d.ts +4 -4
  13. package/lib/Producer.d.ts.map +1 -1
  14. package/lib/RtpParameters.d.ts +11 -11
  15. package/lib/RtpParameters.d.ts.map +1 -1
  16. package/lib/SctpParameters.d.ts +4 -4
  17. package/lib/SctpParameters.d.ts.map +1 -1
  18. package/lib/Transport.d.ts +11 -11
  19. package/lib/Transport.d.ts.map +1 -1
  20. package/lib/handlers/Chrome55.js +6 -6
  21. package/lib/handlers/Chrome67.js +6 -6
  22. package/lib/handlers/Chrome70.d.ts.map +1 -1
  23. package/lib/handlers/Chrome70.js +10 -7
  24. package/lib/handlers/Chrome74.d.ts.map +1 -1
  25. package/lib/handlers/Chrome74.js +10 -7
  26. package/lib/handlers/Edge11.js +6 -6
  27. package/lib/handlers/FakeHandler.d.ts +1 -1
  28. package/lib/handlers/FakeHandler.d.ts.map +1 -1
  29. package/lib/handlers/FakeHandler.js +6 -6
  30. package/lib/handlers/Firefox60.d.ts.map +1 -1
  31. package/lib/handlers/Firefox60.js +10 -7
  32. package/lib/handlers/HandlerInterface.d.ts +11 -11
  33. package/lib/handlers/HandlerInterface.d.ts.map +1 -1
  34. package/lib/handlers/ReactNative.js +6 -6
  35. package/lib/handlers/Safari11.js +6 -6
  36. package/lib/handlers/Safari12.d.ts.map +1 -1
  37. package/lib/handlers/Safari12.js +10 -7
  38. package/lib/index.d.ts +1 -1
  39. package/lib/index.js +1 -1
  40. package/lib/scalabilityModes.d.ts +1 -1
  41. package/lib/scalabilityModes.d.ts.map +1 -1
  42. package/npm-scripts.js +124 -28
  43. package/package.json +17 -5
  44. package/.eslintrc.js +0 -243
  45. package/.github/FUNDING.yml +0 -12
  46. package/.github/ISSUE_TEMPLATE/Bug_Report.md +0 -24
  47. package/.github/ISSUE_TEMPLATE/Feature_Request.md +0 -7
  48. package/.github/ISSUE_TEMPLATE/Support_Question.md +0 -12
  49. package/.travis.yml +0 -26
  50. package/src/Consumer.ts +0 -334
  51. package/src/DataConsumer.ts +0 -271
  52. package/src/DataProducer.ts +0 -291
  53. package/src/Device.ts +0 -584
  54. package/src/EnhancedEventEmitter.ts +0 -133
  55. package/src/Logger.ts +0 -47
  56. package/src/Producer.ts +0 -534
  57. package/src/RtpParameters.ts +0 -326
  58. package/src/SctpParameters.ts +0 -74
  59. package/src/Transport.ts +0 -1275
  60. package/src/errors.ts +0 -45
  61. package/src/handlers/Chrome55.ts +0 -866
  62. package/src/handlers/Chrome67.ts +0 -951
  63. package/src/handlers/Chrome70.ts +0 -964
  64. package/src/handlers/Chrome74.ts +0 -1058
  65. package/src/handlers/Edge11.ts +0 -667
  66. package/src/handlers/FakeHandler.ts +0 -448
  67. package/src/handlers/Firefox60.ts +0 -1040
  68. package/src/handlers/HandlerInterface.ts +0 -162
  69. package/src/handlers/ReactNative.ts +0 -886
  70. package/src/handlers/Safari11.ts +0 -944
  71. package/src/handlers/Safari12.ts +0 -1009
  72. package/src/handlers/ortc/edgeUtils.ts +0 -77
  73. package/src/handlers/sdp/MediaSection.ts +0 -836
  74. package/src/handlers/sdp/RemoteSdp.ts +0 -474
  75. package/src/handlers/sdp/commonUtils.ts +0 -259
  76. package/src/handlers/sdp/plainRtpUtils.ts +0 -58
  77. package/src/handlers/sdp/planBUtils.ts +0 -227
  78. package/src/handlers/sdp/unifiedPlanUtils.ts +0 -188
  79. package/src/index.ts +0 -28
  80. package/src/ortc.ts +0 -1169
  81. package/src/scalabilityModes.ts +0 -27
  82. package/src/types.ts +0 -11
  83. package/src/utils.ts +0 -18
  84. package/test/fakeParameters.js +0 -701
  85. package/test/test.js +0 -1672
  86. package/tsconfig.json +0 -17
package/src/Device.ts DELETED
@@ -1,584 +0,0 @@
1
- /* global RTCRtpTransceiver */
2
-
3
- import Bowser from 'bowser';
4
- import { Logger } from './Logger';
5
- import { EnhancedEventEmitter } from './EnhancedEventEmitter';
6
- import { UnsupportedError, InvalidStateError } from './errors';
7
- import * as utils from './utils';
8
- import * as ortc from './ortc';
9
- import { Transport, TransportOptions, CanProduceByKind } from './Transport';
10
- import { HandlerFactory, HandlerInterface } from './handlers/HandlerInterface';
11
- import { Chrome74 } from './handlers/Chrome74';
12
- import { Chrome70 } from './handlers/Chrome70';
13
- import { Chrome67 } from './handlers/Chrome67';
14
- import { Chrome55 } from './handlers/Chrome55';
15
- import { Firefox60 } from './handlers/Firefox60';
16
- import { Safari12 } from './handlers/Safari12';
17
- import { Safari11 } from './handlers/Safari11';
18
- import { Edge11 } from './handlers/Edge11';
19
- import { ReactNative } from './handlers/ReactNative';
20
- import { RtpCapabilities, MediaKind } from './RtpParameters';
21
- import { SctpCapabilities } from './SctpParameters';
22
-
23
- const logger = new Logger('Device');
24
-
25
- export type BuiltinHandlerName =
26
- | 'Chrome74'
27
- | 'Chrome70'
28
- | 'Chrome67'
29
- | 'Chrome55'
30
- | 'Firefox60'
31
- | 'Safari12'
32
- | 'Safari11'
33
- | 'Edge11'
34
- | 'ReactNative';
35
-
36
- export type DeviceOptions =
37
- {
38
- /**
39
- * The name of one of the builtin handlers.
40
- */
41
- handlerName?: BuiltinHandlerName;
42
- /**
43
- * Custom handler factory.
44
- */
45
- handlerFactory?: HandlerFactory;
46
- /**
47
- * DEPRECATED!
48
- * The name of one of the builtin handlers.
49
- */
50
- Handler?: string;
51
- };
52
-
53
- interface InternalTransportOptions extends TransportOptions
54
- {
55
- direction: 'send' | 'recv';
56
- }
57
-
58
- export function detectDevice(): BuiltinHandlerName | undefined
59
- {
60
- // React-Native.
61
- // NOTE: react-native-webrtc >= 1.75.0 is required.
62
- if (typeof navigator === 'object' && navigator.product === 'ReactNative')
63
- {
64
- if (typeof RTCPeerConnection === 'undefined')
65
- {
66
- logger.warn(
67
- 'this._detectDevice() | unsupported ReactNative without RTCPeerConnection');
68
-
69
- return undefined;
70
- }
71
-
72
- logger.debug('this._detectDevice() | ReactNative handler chosen');
73
-
74
- return 'ReactNative';
75
- }
76
- // Browser.
77
- else if (typeof navigator === 'object' && typeof navigator.userAgent === 'string')
78
- {
79
- const ua = navigator.userAgent;
80
- const browser = Bowser.getParser(ua);
81
- const engine = browser.getEngine();
82
-
83
- // Chrome, Chromium, and Edge.
84
- if (browser.satisfies({ chrome: '>=74', chromium: '>=74', 'microsoft edge': '>=88' }))
85
- {
86
- return 'Chrome74';
87
- }
88
- else if (browser.satisfies({ chrome: '>=70', chromium: '>=70' }))
89
- {
90
- return 'Chrome70';
91
- }
92
- else if (browser.satisfies({ chrome: '>=67', chromium: '>=67' }))
93
- {
94
- return 'Chrome67';
95
- }
96
- else if (browser.satisfies({ chrome: '>=55', chromium: '>=55' }))
97
- {
98
- return 'Chrome55';
99
- }
100
- // Firefox.
101
- else if (browser.satisfies({ firefox: '>=60' }))
102
- {
103
- return 'Firefox60';
104
- }
105
- // Firefox on iOS.
106
- else if (browser.satisfies({ ios: { OS: '>=14.3', firefox: '>=30.0' } }))
107
- {
108
- return 'Safari12';
109
- }
110
- // Safari with Unified-Plan support enabled.
111
- else if (
112
- browser.satisfies({ safari: '>=12.0' }) &&
113
- typeof RTCRtpTransceiver !== 'undefined' &&
114
- RTCRtpTransceiver.prototype.hasOwnProperty('currentDirection')
115
- )
116
- {
117
- return 'Safari12';
118
- }
119
- // Safari with Plab-B support.
120
- else if (browser.satisfies({ safari: '>=11' }))
121
- {
122
- return 'Safari11';
123
- }
124
- // Old Edge with ORTC support.
125
- else if (
126
- browser.satisfies({ 'microsoft edge': '>=11' }) &&
127
- browser.satisfies({ 'microsoft edge': '<=18' })
128
- )
129
- {
130
- return 'Edge11';
131
- }
132
- // Best effort for Chromium based browsers.
133
- else if (engine.name && engine.name.toLowerCase() === 'blink')
134
- {
135
- const match = ua.match(/(?:(?:Chrome|Chromium))[ /](\w+)/i);
136
-
137
- if (match)
138
- {
139
- const version = Number(match[1]);
140
-
141
- if (version >= 74)
142
- {
143
- return 'Chrome74';
144
- }
145
- else if (version >= 70)
146
- {
147
- return 'Chrome70';
148
- }
149
- else if (version >= 67)
150
- {
151
- return 'Chrome67';
152
- }
153
- else
154
- {
155
- return 'Chrome55';
156
- }
157
- }
158
- else
159
- {
160
- return 'Chrome74';
161
- }
162
- }
163
- // Unsupported browser.
164
- else
165
- {
166
- logger.warn(
167
- 'this._detectDevice() | browser not supported [name:%s, version:%s]',
168
- browser.getBrowserName(), browser.getBrowserVersion());
169
-
170
- return undefined;
171
- }
172
- }
173
- // Unknown device.
174
- else
175
- {
176
- logger.warn('this._detectDevice() | unknown device');
177
-
178
- return undefined;
179
- }
180
- }
181
-
182
- export type DeviceObserverEvents =
183
- {
184
- newtransport: [Transport];
185
- }
186
-
187
- export class Device
188
- {
189
- // RTC handler factory.
190
- private readonly _handlerFactory: HandlerFactory;
191
- // Handler name.
192
- private readonly _handlerName: string;
193
- // Loaded flag.
194
- private _loaded = false;
195
- // Extended RTP capabilities.
196
- private _extendedRtpCapabilities?: any;
197
- // Local RTP capabilities for receiving media.
198
- private _recvRtpCapabilities?: RtpCapabilities;
199
- // Whether we can produce audio/video based on computed extended RTP
200
- // capabilities.
201
- private readonly _canProduceByKind: CanProduceByKind;
202
- // Local SCTP capabilities.
203
- private _sctpCapabilities?: SctpCapabilities;
204
- // Observer instance.
205
- protected readonly _observer = new EnhancedEventEmitter<DeviceObserverEvents>();
206
-
207
- /**
208
- * Create a new Device to connect to mediasoup server.
209
- *
210
- * @throws {UnsupportedError} if device is not supported.
211
- */
212
- constructor({ handlerName, handlerFactory, Handler }: DeviceOptions = {})
213
- {
214
- logger.debug('constructor()');
215
-
216
- // Handle deprecated option.
217
- if (Handler)
218
- {
219
- logger.warn(
220
- 'constructor() | Handler option is DEPRECATED, use handlerName or handlerFactory instead');
221
-
222
- if (typeof Handler === 'string')
223
- handlerName = Handler as BuiltinHandlerName;
224
- else
225
- throw new TypeError(
226
- 'non string Handler option no longer supported, use handlerFactory instead');
227
- }
228
-
229
- if (handlerName && handlerFactory)
230
- {
231
- throw new TypeError(
232
- 'just one of handlerName or handlerInterface can be given');
233
- }
234
-
235
- if (handlerFactory)
236
- {
237
- this._handlerFactory = handlerFactory;
238
- }
239
- else
240
- {
241
- if (handlerName)
242
- {
243
- logger.debug('constructor() | handler given: %s', handlerName);
244
- }
245
- else
246
- {
247
- handlerName = detectDevice();
248
-
249
- if (handlerName)
250
- logger.debug('constructor() | detected handler: %s', handlerName);
251
- else
252
- throw new UnsupportedError('device not supported');
253
- }
254
-
255
- switch (handlerName)
256
- {
257
- case 'Chrome74':
258
- this._handlerFactory = Chrome74.createFactory();
259
- break;
260
- case 'Chrome70':
261
- this._handlerFactory = Chrome70.createFactory();
262
- break;
263
- case 'Chrome67':
264
- this._handlerFactory = Chrome67.createFactory();
265
- break;
266
- case 'Chrome55':
267
- this._handlerFactory = Chrome55.createFactory();
268
- break;
269
- case 'Firefox60':
270
- this._handlerFactory = Firefox60.createFactory();
271
- break;
272
- case 'Safari12':
273
- this._handlerFactory = Safari12.createFactory();
274
- break;
275
- case 'Safari11':
276
- this._handlerFactory = Safari11.createFactory();
277
- break;
278
- case 'Edge11':
279
- this._handlerFactory = Edge11.createFactory();
280
- break;
281
- case 'ReactNative':
282
- this._handlerFactory = ReactNative.createFactory();
283
- break;
284
- default:
285
- throw new TypeError(`unknown handlerName "${handlerName}"`);
286
- }
287
- }
288
-
289
- // Create a temporal handler to get its name.
290
- const handler = this._handlerFactory();
291
-
292
- this._handlerName = handler.name;
293
-
294
- handler.close();
295
-
296
- this._extendedRtpCapabilities = undefined;
297
- this._recvRtpCapabilities = undefined;
298
- this._canProduceByKind =
299
- {
300
- audio : false,
301
- video : false
302
- };
303
- this._sctpCapabilities = undefined;
304
- }
305
-
306
- /**
307
- * The RTC handler name.
308
- */
309
- get handlerName(): string
310
- {
311
- return this._handlerName;
312
- }
313
-
314
- /**
315
- * Whether the Device is loaded.
316
- */
317
- get loaded(): boolean
318
- {
319
- return this._loaded;
320
- }
321
-
322
- /**
323
- * RTP capabilities of the Device for receiving media.
324
- *
325
- * @throws {InvalidStateError} if not loaded.
326
- */
327
- get rtpCapabilities(): RtpCapabilities
328
- {
329
- if (!this._loaded)
330
- throw new InvalidStateError('not loaded');
331
-
332
- return this._recvRtpCapabilities!;
333
- }
334
-
335
- /**
336
- * SCTP capabilities of the Device.
337
- *
338
- * @throws {InvalidStateError} if not loaded.
339
- */
340
- get sctpCapabilities(): SctpCapabilities
341
- {
342
- if (!this._loaded)
343
- throw new InvalidStateError('not loaded');
344
-
345
- return this._sctpCapabilities!;
346
- }
347
-
348
- get observer(): EnhancedEventEmitter
349
- {
350
- return this._observer;
351
- }
352
-
353
- /**
354
- * Initialize the Device.
355
- */
356
- async load(
357
- { routerRtpCapabilities }:
358
- { routerRtpCapabilities: RtpCapabilities }
359
- ): Promise<void>
360
- {
361
- logger.debug('load() [routerRtpCapabilities:%o]', routerRtpCapabilities);
362
-
363
- routerRtpCapabilities = utils.clone(routerRtpCapabilities, undefined);
364
-
365
- // Temporal handler to get its capabilities.
366
- let handler: HandlerInterface | undefined;
367
-
368
- try
369
- {
370
- if (this._loaded)
371
- throw new InvalidStateError('already loaded');
372
-
373
- // This may throw.
374
- ortc.validateRtpCapabilities(routerRtpCapabilities);
375
-
376
- handler = this._handlerFactory();
377
-
378
- const nativeRtpCapabilities = await handler.getNativeRtpCapabilities();
379
-
380
- logger.debug(
381
- 'load() | got native RTP capabilities:%o', nativeRtpCapabilities);
382
-
383
- // This may throw.
384
- ortc.validateRtpCapabilities(nativeRtpCapabilities);
385
-
386
- // Get extended RTP capabilities.
387
- this._extendedRtpCapabilities = ortc.getExtendedRtpCapabilities(
388
- nativeRtpCapabilities, routerRtpCapabilities);
389
-
390
- logger.debug(
391
- 'load() | got extended RTP capabilities:%o',
392
- this._extendedRtpCapabilities);
393
-
394
- // Check whether we can produce audio/video.
395
- this._canProduceByKind.audio =
396
- ortc.canSend('audio', this._extendedRtpCapabilities);
397
- this._canProduceByKind.video =
398
- ortc.canSend('video', this._extendedRtpCapabilities);
399
-
400
- // Generate our receiving RTP capabilities for receiving media.
401
- this._recvRtpCapabilities =
402
- ortc.getRecvRtpCapabilities(this._extendedRtpCapabilities);
403
-
404
- // This may throw.
405
- ortc.validateRtpCapabilities(this._recvRtpCapabilities);
406
-
407
- logger.debug(
408
- 'load() | got receiving RTP capabilities:%o',
409
- this._recvRtpCapabilities);
410
-
411
- // Generate our SCTP capabilities.
412
- this._sctpCapabilities = await handler.getNativeSctpCapabilities();
413
-
414
- logger.debug(
415
- 'load() | got native SCTP capabilities:%o', this._sctpCapabilities);
416
-
417
- // This may throw.
418
- ortc.validateSctpCapabilities(this._sctpCapabilities);
419
-
420
- logger.debug('load() succeeded');
421
-
422
- this._loaded = true;
423
-
424
- handler.close();
425
- }
426
- catch (error)
427
- {
428
- if (handler)
429
- handler.close();
430
-
431
- throw error;
432
- }
433
- }
434
-
435
- /**
436
- * Whether we can produce audio/video.
437
- *
438
- * @throws {InvalidStateError} if not loaded.
439
- * @throws {TypeError} if wrong arguments.
440
- */
441
- canProduce(kind: MediaKind): boolean
442
- {
443
- if (!this._loaded)
444
- throw new InvalidStateError('not loaded');
445
- else if (kind !== 'audio' && kind !== 'video')
446
- throw new TypeError(`invalid kind "${kind}"`);
447
-
448
- return this._canProduceByKind[kind];
449
- }
450
-
451
- /**
452
- * Creates a Transport for sending media.
453
- *
454
- * @throws {InvalidStateError} if not loaded.
455
- * @throws {TypeError} if wrong arguments.
456
- */
457
- createSendTransport(
458
- {
459
- id,
460
- iceParameters,
461
- iceCandidates,
462
- dtlsParameters,
463
- sctpParameters,
464
- iceServers,
465
- iceTransportPolicy,
466
- additionalSettings,
467
- proprietaryConstraints,
468
- appData
469
- }: TransportOptions
470
- ): Transport
471
- {
472
- logger.debug('createSendTransport()');
473
-
474
- return this._createTransport(
475
- {
476
- direction : 'send',
477
- id : id,
478
- iceParameters : iceParameters,
479
- iceCandidates : iceCandidates,
480
- dtlsParameters : dtlsParameters,
481
- sctpParameters : sctpParameters,
482
- iceServers : iceServers,
483
- iceTransportPolicy : iceTransportPolicy,
484
- additionalSettings : additionalSettings,
485
- proprietaryConstraints : proprietaryConstraints,
486
- appData : appData
487
- });
488
- }
489
-
490
- /**
491
- * Creates a Transport for receiving media.
492
- *
493
- * @throws {InvalidStateError} if not loaded.
494
- * @throws {TypeError} if wrong arguments.
495
- */
496
- createRecvTransport(
497
- {
498
- id,
499
- iceParameters,
500
- iceCandidates,
501
- dtlsParameters,
502
- sctpParameters,
503
- iceServers,
504
- iceTransportPolicy,
505
- additionalSettings,
506
- proprietaryConstraints,
507
- appData
508
- }: TransportOptions
509
- ): Transport
510
- {
511
- logger.debug('createRecvTransport()');
512
-
513
- return this._createTransport(
514
- {
515
- direction : 'recv',
516
- id : id,
517
- iceParameters : iceParameters,
518
- iceCandidates : iceCandidates,
519
- dtlsParameters : dtlsParameters,
520
- sctpParameters : sctpParameters,
521
- iceServers : iceServers,
522
- iceTransportPolicy : iceTransportPolicy,
523
- additionalSettings : additionalSettings,
524
- proprietaryConstraints : proprietaryConstraints,
525
- appData : appData
526
- });
527
- }
528
-
529
- private _createTransport(
530
- {
531
- direction,
532
- id,
533
- iceParameters,
534
- iceCandidates,
535
- dtlsParameters,
536
- sctpParameters,
537
- iceServers,
538
- iceTransportPolicy,
539
- additionalSettings,
540
- proprietaryConstraints,
541
- appData
542
- }: InternalTransportOptions
543
- ): Transport
544
- {
545
- if (!this._loaded)
546
- throw new InvalidStateError('not loaded');
547
- else if (typeof id !== 'string')
548
- throw new TypeError('missing id');
549
- else if (typeof iceParameters !== 'object')
550
- throw new TypeError('missing iceParameters');
551
- else if (!Array.isArray(iceCandidates))
552
- throw new TypeError('missing iceCandidates');
553
- else if (typeof dtlsParameters !== 'object')
554
- throw new TypeError('missing dtlsParameters');
555
- else if (sctpParameters && typeof sctpParameters !== 'object')
556
- throw new TypeError('wrong sctpParameters');
557
- else if (appData && typeof appData !== 'object')
558
- throw new TypeError('if given, appData must be an object');
559
-
560
- // Create a new Transport.
561
- const transport = new Transport(
562
- {
563
- direction,
564
- id,
565
- iceParameters,
566
- iceCandidates,
567
- dtlsParameters,
568
- sctpParameters,
569
- iceServers,
570
- iceTransportPolicy,
571
- additionalSettings,
572
- proprietaryConstraints,
573
- appData,
574
- handlerFactory : this._handlerFactory,
575
- extendedRtpCapabilities : this._extendedRtpCapabilities,
576
- canProduceByKind : this._canProduceByKind
577
- });
578
-
579
- // Emit observer event.
580
- this._observer.safeEmit('newtransport', transport);
581
-
582
- return transport;
583
- }
584
- }
@@ -1,133 +0,0 @@
1
- import { EventEmitter } from 'events';
2
- import { Logger } from './Logger';
3
-
4
- const logger = new Logger('EnhancedEventEmitter');
5
-
6
- type Events = Record<string, any[]>
7
-
8
- export class EnhancedEventEmitter<E extends Events = Events> extends EventEmitter
9
- {
10
- constructor()
11
- {
12
- super();
13
- this.setMaxListeners(Infinity);
14
- }
15
-
16
- emit<K extends keyof E & string>(eventName: K, ...args: E[K]): boolean
17
- {
18
- return super.emit(eventName, ...args);
19
- }
20
-
21
- /**
22
- * Special addition to the EventEmitter API.
23
- */
24
- safeEmit<K extends keyof E & string>(eventName: K, ...args: E[K]): boolean
25
- {
26
- const numListeners = super.listenerCount(eventName);
27
-
28
- try
29
- {
30
- return super.emit(eventName, ...args);
31
- }
32
- catch (error)
33
- {
34
- logger.error(
35
- 'safeEmit() | event listener threw an error [eventName:%s]:%o',
36
- eventName, error);
37
-
38
- return Boolean(numListeners);
39
- }
40
- }
41
-
42
- on<K extends keyof E & string>(
43
- eventName: K,
44
- listener: (...args: E[K]) => void
45
- ): this
46
- {
47
- super.on(eventName, listener as (...args: any[]) => void);
48
-
49
- return this;
50
- }
51
-
52
- off<K extends keyof E & string>(
53
- eventName: K,
54
- listener: (...args: E[K]) => void
55
- ): this
56
- {
57
- super.off(eventName, listener as (...args: any[]) => void);
58
-
59
- return this;
60
- }
61
-
62
- addListener<K extends keyof E & string>(
63
- eventName: K,
64
- listener: (...args: E[K]) => void
65
- ): this
66
- {
67
- super.on(eventName, listener as (...args: any[]) => void);
68
-
69
- return this;
70
- }
71
-
72
- prependListener<K extends keyof E & string>(
73
- eventName: K,
74
- listener: (...args: E[K]) => void
75
- ): this
76
- {
77
- super.prependListener(eventName, listener as (...args: any[]) => void);
78
-
79
- return this;
80
- }
81
-
82
- once<K extends keyof E & string>(
83
- eventName: K,
84
- listener: (...args: E[K]) => void
85
- ): this
86
- {
87
- super.once(eventName, listener as (...args: any[]) => void);
88
-
89
- return this;
90
- }
91
-
92
- prependOnceListener<K extends keyof E & string>(
93
- eventName: K,
94
- listener: (...args: E[K]) => void
95
- ): this
96
- {
97
- super.prependOnceListener(eventName, listener as (...args: any[]) => void);
98
-
99
- return this;
100
- }
101
-
102
- removeListener<K extends keyof E & string>(
103
- eventName: K,
104
- listener: (...args: E[K]) => void
105
- ): this
106
- {
107
- super.off(eventName, listener as (...args: any[]) => void);
108
-
109
- return this;
110
- }
111
-
112
- removeAllListeners<K extends keyof E & string>(eventName?: K): this
113
- {
114
- super.removeAllListeners(eventName);
115
-
116
- return this;
117
- }
118
-
119
- listenerCount<K extends keyof E & string>(eventName: K): number
120
- {
121
- return super.listenerCount(eventName);
122
- }
123
-
124
- listeners<K extends keyof E & string>(eventName: K): Function[]
125
- {
126
- return super.listeners(eventName);
127
- }
128
-
129
- rawListeners<K extends keyof E & string>(eventName: K): Function[]
130
- {
131
- return super.rawListeners(eventName);
132
- }
133
- }