werift-webrtc
werift-webrtc copied to clipboard
Spec compliance?
I'm trying to integrate this module with some isomorphic code that runs on node and in browsers but I've noticed some incompatibilities with the WebRTC types as supplied with TypeScript in lib.dom.d.ts
.
-
RTCPeerConnection
- Missing properties
- constructor arg
iceServers
is typeIceServer
but theIceServer.urls
property is incompatible - it isstring
but it should bestring | string[]
-
RTCDataChannel
- Missing properties
-
RTCSessionDescription
- the constructor signature here expects two arguments,
sdp: string
andtype: "offer" | "answer"
- the spec says it should be one argument, a RTCSessionDescriptionInit dictionary with two keystype
which is a value from RTCSdpType andsdp
, a string
- the constructor signature here expects two arguments,
-
RTCErrorEvent
- Does not extend Event
-
General
- Uses EventTarget/Event polyfills instead of globals supplied by Node
These are just the errors tsc reported, there may be others.
Spec compliance is planned in the roadmap, but no specific date has been set for when it will be implemented. https://github.com/shinyoshiaki/werift-webrtc?tab=readme-ov-file#road-map-towards-20
Sounds great. Would PRs that move this module closer to the spec be accepted?
Acceptable, but be prepared to modify all existing test code if you are modifying an existing PeerConnection. It may be easier to first implement a new PeerConnection with a different name like W3CPeerConnection
It could be also in the form of a polyfill like https://github.com/murat-dogan/node-datachannel/tree/master/polyfill. It has been very helpful. I am just sharing ideas. These make life much easier as we can share the same code among multiple implementations (browser, wrtc-M87, wrtc-M94, libdatachannel).