-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TypeScript interfaces for all exported classes #1463
Conversation
## Details - `mediasoup.types` namespace no longer exports `Worker`, `Router`, `Producer`, etc classes in `types` but instead it exports `WorkerInterface`, `RouterInterface`, `ProducerInterface`, etc. - NOTE: This is a breaking change somehow, but just at TS level. - Use the new interfaces everywhere. - This makes it easier for applications to create mediasoup mocks. ## TODO - How to export as interface/types the functions and consts exposed by `index.ts` such as `createWorker()`, `setLogEventListeners()`, `getSupportedRtpCapabilities()`, `observer`, etc? - In the future we may want to move those interfaces/types to another separate package so a Node application that only depends on mediasoup types doesn't need to install mediaosup. Even if we don't do that, we should change things so `types.ts` doesn't export **anything** that depends on compiled FBS types.
…sUtils.ts and same for SCTP and SRTP files
…sFbsUtils` Rename `scalabilityModes.ts` tp `scalabilityModesTypes.ts`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it 👍
Definitelly yes, that will be useful, just only now I have a bit of work to update Mafalda... Have you though / do you mind if we move the interfaces to a types-only package that can be used by both projects as dependency? And related to this, do you know of any other Mediasoup mock/API project? |
This will probably happen but definitely not yet. Will be done once we use and evaluate how easy and useful those interfaces are, and probably more changes/additions are needed (spoiler: they are). |
Yeah, I know they are useful, I think I asked for that interfaces several years ego for selfish reasons 😈 Just curious if it was already in the roadmap and how much soonish, or if I can help on that. I need first to fix the compatibility with 3.14.15 (I have been taking self-care and focused on my day job during last months and got totally disconnected of Mediasoup since at least May...), but after that I would need to have the types package, just only to know if do it as a nightly package that extract and publish them the same I'm doing with the tests to check for compatibility and other components, or do it by hand and make Mediasoup as dependent of it. TL;DR: if you need help on moving out the interfaces, you can count on me. |
We will reach that moment in which it will make sense to talk about a separate types package. |
Details
mediasoup.types
namespace now exportsWorker
,Router
,Producer
, etc types instead of classes, and those types are TypeScript interfaces.XxxxxTypes.ts
files export theXxxxx
interface and related types. For example,ProducerTypes.ts
exports theProducer
interface and Producer related types.Xxxxx.ts
files export the implementation classes with nameXxxxxImpl
. For example,Producer.ts
exports theProducerImpl
class that implements theProducer
interface declared inProducerTypes.ts
.RtpParameters.ts
intortpParametersTypes.ts
andrtpParametersFbsUtils.ts
and same for SCTP and SRTP files.RtpStream.ts
intortpStreamStatsTypes.ts
andrtpStreamStatsFbsUtils
.scalabilityModes.ts
tpscalabilityModesTypes.ts
import type
when possible instead ofimport
.Types.ts
only import types and do not depend on FBS generated TS code/types.transport.type
getter than returns'webrtc' | 'plain' | 'pipe' | 'direct'
.rtpObserver.type
getter than returns'activespeaker' | 'audiolevel'
.Logger
fromEnhancedEventEmitter
.dump()
methods missing in same classes and wrong tests.