versatica / mediasoup-client

mediasoup client side JavaScript library
https://mediasoup.org
ISC License
591 stars 237 forks source link

Remove DOM TypeScript type #279

Closed ibc closed 6 months ago

ibc commented 1 year ago

In tsconfig.json we rely on "dom" TS library. We do it because we need definition of RTCPeerConnection, MediaStream and tons of things only available in browser.

However we also want that mediasoup-client runs in Node (by using mediasoup-client-aiortc for example). And it's a bad idea to use DOM TS types in a lib intended (also) for Node. So:

ibc commented 6 months ago

Actually I'm gonna close this task. Despite mediasoup-client can work in Node it heavily rely on WebRTC API. For example, Producer.ts depends on many "dom" types such as MediaStreamTrack, RTCRtpSender, etc:

/**
 * Associated RTCRtpSender.
 */
get rtpSender(): RTCRtpSender | undefined {
    return this._rtpSender;
}

/**
 * The associated track.
 */
get track(): MediaStreamTrack | null {
    return this._track;
}

We cannot replace them with "abstract" types because they are what they are.

The thing is that, when running in Node, the mediasoup-client handler (such as mediasoup-client-aiortc) must be ready to handle and produce objects with those types.