|
1 | 1 | import { Logger, LoggerEmitter } from './Logger'; |
2 | 2 | import { EnhancedEventEmitter } from './enhancedEvents'; |
| 3 | +import type { |
| 4 | + Observer, |
| 5 | + ObserverEvents, |
| 6 | + LogEventListeners, |
| 7 | + Index, |
| 8 | +} from './indexTypes'; |
3 | 9 | import type { Worker, WorkerSettings } from './WorkerTypes'; |
4 | 10 | import { WorkerImpl, workerBin } from './Worker'; |
5 | 11 | import { supportedRtpCapabilities } from './supportedRtpCapabilities'; |
6 | 12 | import type { RtpCapabilities } from './rtpParametersTypes'; |
7 | | -import type * as types from './types'; |
| 13 | +import { parseScalabilityMode } from './scalabilityModesUtils'; |
| 14 | +import type { AppData } from './types'; |
8 | 15 | import * as utils from './utils'; |
9 | 16 |
|
10 | 17 | /** |
11 | 18 | * Expose all types. |
12 | 19 | */ |
13 | | -export { types }; |
| 20 | +export type * as types from './types'; |
14 | 21 |
|
15 | 22 | /** |
16 | 23 | * Expose mediasoup version. |
17 | 24 | */ |
18 | 25 | // eslint-disable-next-line @typescript-eslint/no-require-imports |
19 | 26 | export const version: string = require('../../package.json').version; |
20 | 27 |
|
21 | | -export type Observer = EnhancedEventEmitter<ObserverEvents>; |
22 | | - |
23 | | -export type ObserverEvents = { |
24 | | - newworker: [Worker]; |
25 | | -}; |
26 | | - |
27 | 28 | const observer: Observer = new EnhancedEventEmitter<ObserverEvents>(); |
28 | 29 |
|
29 | 30 | /** |
@@ -59,9 +60,7 @@ const logger = new Logger(); |
59 | 60 | * }); |
60 | 61 | * ``` |
61 | 62 | */ |
62 | | -export function setLogEventListeners( |
63 | | - listeners?: types.LogEventListeners |
64 | | -): void { |
| 63 | +export function setLogEventListeners(listeners?: LogEventListeners): void { |
65 | 64 | logger.debug('setLogEventListeners()'); |
66 | 65 |
|
67 | 66 | let debugLogEmitter: LoggerEmitter | undefined; |
@@ -92,9 +91,7 @@ export function setLogEventListeners( |
92 | 91 | /** |
93 | 92 | * Create a Worker. |
94 | 93 | */ |
95 | | -export async function createWorker< |
96 | | - WorkerAppData extends types.AppData = types.AppData, |
97 | | ->({ |
| 94 | +export async function createWorker<WorkerAppData extends AppData = AppData>({ |
98 | 95 | logLevel = 'error', |
99 | 96 | logTags, |
100 | 97 | rtcMinPort = 10000, |
@@ -145,9 +142,24 @@ export function getSupportedRtpCapabilities(): RtpCapabilities { |
145 | 142 | /** |
146 | 143 | * Expose parseScalabilityMode() function. |
147 | 144 | */ |
148 | | -export { parseScalabilityMode } from './scalabilityModesUtils'; |
| 145 | +export { parseScalabilityMode }; |
149 | 146 |
|
150 | 147 | /** |
151 | 148 | * Expose extras module. |
152 | 149 | */ |
153 | 150 | export * as extras from './extras'; |
| 151 | + |
| 152 | +// NOTE: This constant of type Index is created just to check at TypeScript |
| 153 | +// level that everything exported here (all but TS types) matches the Index |
| 154 | +// interface exposed by indexTypes.ts. |
| 155 | +// |
| 156 | +// eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 157 | +const indexImpl: Index = { |
| 158 | + version, |
| 159 | + observer, |
| 160 | + workerBin, |
| 161 | + setLogEventListeners, |
| 162 | + createWorker, |
| 163 | + getSupportedRtpCapabilities, |
| 164 | + parseScalabilityMode, |
| 165 | +}; |
0 commit comments