mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
@libp2p/webrtc imports @ipshipyard/node-datachannel/polyfill which requires native C++ compilation. Stub provides ESM+CJS exports for both main and polyfill subpaths with no-op WebRTC classes. Also ignores pnpm-lock.yaml in cspell and copies stubs dir in Dockerfiles.
65 lines
1.2 KiB
JavaScript
65 lines
1.2 KiB
JavaScript
// Stub polyfill for @ipshipyard/node-datachannel/polyfill
|
|
// Provides no-op WebRTC classes for environments where native WebRTC is not needed
|
|
|
|
class RTCPeerConnection {
|
|
close() {}
|
|
createDataChannel() {
|
|
return new RTCDataChannel();
|
|
}
|
|
createOffer() {
|
|
return Promise.resolve({});
|
|
}
|
|
createAnswer() {
|
|
return Promise.resolve({});
|
|
}
|
|
setLocalDescription() {
|
|
return Promise.resolve();
|
|
}
|
|
setRemoteDescription() {
|
|
return Promise.resolve();
|
|
}
|
|
addIceCandidate() {
|
|
return Promise.resolve();
|
|
}
|
|
addEventListener() {}
|
|
removeEventListener() {}
|
|
}
|
|
|
|
class RTCSessionDescription {
|
|
constructor(init) {
|
|
this.type = init?.type ?? '';
|
|
this.sdp = init?.sdp ?? '';
|
|
}
|
|
}
|
|
|
|
class RTCIceCandidate {
|
|
constructor(init) {
|
|
this.candidate = init?.candidate ?? '';
|
|
this.sdpMid = init?.sdpMid ?? null;
|
|
this.sdpMLineIndex = init?.sdpMLineIndex ?? null;
|
|
}
|
|
}
|
|
|
|
class RTCDataChannel {
|
|
readyState = 'closed';
|
|
close() {}
|
|
send() {}
|
|
addEventListener() {}
|
|
removeEventListener() {}
|
|
}
|
|
|
|
class RTCDataChannelEvent {
|
|
constructor(type, init) {
|
|
this.type = type;
|
|
this.channel = init?.channel ?? null;
|
|
}
|
|
}
|
|
|
|
export {
|
|
RTCPeerConnection,
|
|
RTCSessionDescription,
|
|
RTCIceCandidate,
|
|
RTCDataChannel,
|
|
RTCDataChannelEvent,
|
|
};
|