Files
zeekay cda4e3c4e8 Add node-datachannel stub with polyfill subpath for next build
@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.
2026-02-24 18:07:34 -08:00

31 lines
1.1 KiB
JavaScript

// Stub polyfill for @ipshipyard/node-datachannel/polyfill (CJS)
class RTCPeerConnection {
constructor() {}
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 {
constructor() { this.readyState = 'closed'; }
close() {}
send() {}
addEventListener() {}
removeEventListener() {}
}
class RTCDataChannelEvent {
constructor(type, init) { this.type = type; this.channel = init?.channel ?? null; }
}
module.exports = { RTCPeerConnection, RTCSessionDescription, RTCIceCandidate, RTCDataChannel, RTCDataChannelEvent };