From eaf286b2ea42b62060dad13878ca9296df1e1576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Mon, 11 Nov 2024 18:59:40 +0100 Subject: [PATCH 1/3] Expose extras namespace ## Details - Expose `mediasoup.extras` which (for now) exports `EnhancedEventEmitter`, `Events` and `enhancedOnce()`. - Useful when writing mocks implementing mediasoup TS interfaces. --- CHANGELOG.md | 2 ++ node/src/RtpObserver.ts | 2 +- node/src/Transport.ts | 2 +- node/src/enhancedEvents.ts | 2 +- node/src/extras.ts | 1 + node/src/index.ts | 5 +++++ 6 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 node/src/extras.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dab8ee44b..4f349a4f45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ### NEXT +- Expose `extras` namespace which exports `EnhancedEventEmitter`, `Events` and `enhancedOnce()` for now ([PR #1464](https://github.com/versatica/mediasoup/pull/1464)). + ### 3.15.0 - Node: Add TypeScript interfaces for all exported classes ([PR #1463](https://github.com/versatica/mediasoup/pull/1463)). diff --git a/node/src/RtpObserver.ts b/node/src/RtpObserver.ts index ec42cedc6d..93c26e5231 100644 --- a/node/src/RtpObserver.ts +++ b/node/src/RtpObserver.ts @@ -53,7 +53,7 @@ export abstract class RtpObserverImpl< // Observer instance. readonly #observer: Observer; - constructor( + protected constructor( { internal, channel, diff --git a/node/src/Transport.ts b/node/src/Transport.ts index 7bbc28f4dd..d298dc5f0b 100644 --- a/node/src/Transport.ts +++ b/node/src/Transport.ts @@ -175,7 +175,7 @@ export abstract class TransportImpl< // Observer instance. readonly #observer: Observer; - constructor( + protected constructor( { internal, data, diff --git a/node/src/enhancedEvents.ts b/node/src/enhancedEvents.ts index 8f7a5eb59a..0ac7763f39 100644 --- a/node/src/enhancedEvents.ts +++ b/node/src/enhancedEvents.ts @@ -1,6 +1,6 @@ import { EventEmitter, once } from 'node:events'; -type Events = Record; +export type Events = Record; export class EnhancedEventEmitter< E extends Events = Events, diff --git a/node/src/extras.ts b/node/src/extras.ts new file mode 100644 index 0000000000..18274099cb --- /dev/null +++ b/node/src/extras.ts @@ -0,0 +1 @@ +export { EnhancedEventEmitter, Events, enhancedOnce } from './enhancedEvents'; diff --git a/node/src/index.ts b/node/src/index.ts index c366b0d357..241c928ab6 100644 --- a/node/src/index.ts +++ b/node/src/index.ts @@ -146,3 +146,8 @@ export function getSupportedRtpCapabilities(): RtpCapabilities { * Expose parseScalabilityMode() function. */ export { parseScalabilityMode } from './scalabilityModesUtils'; + +/** + * Expose extras module. + */ +export * as extras from './extras'; From 4295a1b7ae1f5d3a8c5211adef06f5cd450918f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Tue, 12 Nov 2024 10:55:30 +0100 Subject: [PATCH 2/3] don't expose Events --- CHANGELOG.md | 2 +- node/src/extras.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f349a4f45..bc416bf343 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### NEXT -- Expose `extras` namespace which exports `EnhancedEventEmitter`, `Events` and `enhancedOnce()` for now ([PR #1464](https://github.com/versatica/mediasoup/pull/1464)). +- Expose `extras` namespace which exports `EnhancedEventEmitter` and `enhancedOnce()` for now ([PR #1464](https://github.com/versatica/mediasoup/pull/1464)). ### 3.15.0 diff --git a/node/src/extras.ts b/node/src/extras.ts index 18274099cb..72ecee7755 100644 --- a/node/src/extras.ts +++ b/node/src/extras.ts @@ -1 +1 @@ -export { EnhancedEventEmitter, Events, enhancedOnce } from './enhancedEvents'; +export { EnhancedEventEmitter, enhancedOnce } from './enhancedEvents'; From 58676657fca3e3ea9c4eb6e2d010bf4c9049aba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Tue, 12 Nov 2024 10:55:55 +0100 Subject: [PATCH 3/3] fix --- node/src/enhancedEvents.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/src/enhancedEvents.ts b/node/src/enhancedEvents.ts index 0ac7763f39..8f7a5eb59a 100644 --- a/node/src/enhancedEvents.ts +++ b/node/src/enhancedEvents.ts @@ -1,6 +1,6 @@ import { EventEmitter, once } from 'node:events'; -export type Events = Record; +type Events = Record; export class EnhancedEventEmitter< E extends Events = Events,