import RTCPIPView, { startIOSPIP, stopIOSPIP } from './RTCPIPView.web'; import RTCView, { type RTCIOSPIPOptions, type RTCVideoViewProps } from './RTCView.web'; import ScreenCapturePickerView from './ScreenCapturePickerView.web'; import { patchMediaStream } from './webStream'; export type MediaTrackSettings = Record; export type PalabraConfig = Record; export type PalabraTranscription = { text: string; lang: string; isFinal: boolean; }; export type RTCEncryptedPacket = { payload: Uint8Array; iv: Uint8Array; keyIndex: number; }; export enum RTCFrameCryptorAlgorithm { kAesGcm = 'kAesGcm', } export enum RTCFrameCryptorState { kNew = 'kNew', kOk = 'kOk', } export type RTCKeyProviderOptions = Record; class UnsupportedFeature { protected unsupported(): never { throw new Error('This WebRTC native feature is not available on web.'); } } class RTCDataPacketCryptor extends UnsupportedFeature {} class RTCDataPacketCryptorFactory extends UnsupportedFeature { static async createDataPacketCryptor() { throw new Error('Data packet cryptor is not available on web.'); } } class RTCErrorEvent extends Event {} class RTCFrameCryptor extends UnsupportedFeature {} class RTCFrameCryptorFactory extends UnsupportedFeature { static createDefaultKeyProvider() { return new RTCKeyProvider(); } } class RTCKeyProvider extends UnsupportedFeature { setSharedKey() { this.unsupported(); } setKey() { this.unsupported(); } ratchetKey() { this.unsupported(); } ratchetSharedKey() { this.unsupported(); } setSifTrailer() { this.unsupported(); } // eslint-disable-next-line @typescript-eslint/no-empty-function dispose() {} } class RTCAudioSession { // eslint-disable-next-line @typescript-eslint/no-empty-function static async setConfiguration() {} } const mediaDevices = typeof navigator !== 'undefined' && navigator.mediaDevices ? navigator.mediaDevices : { enumerateDevices: async () => [], getDisplayMedia: async () => { throw new Error('Display capture is not available.'); }, getUserMedia: async () => { throw new Error('User media is not available.'); }, }; const permissions = { async check() { return true; }, async request() { return true; }, }; const RTCIceCandidateRef = typeof globalThis.RTCIceCandidate === 'function' ? globalThis.RTCIceCandidate : class {}; const RTCPeerConnectionRef = typeof globalThis.RTCPeerConnection === 'function' ? globalThis.RTCPeerConnection : class {}; const RTCSessionDescriptionRef = typeof globalThis.RTCSessionDescription === 'function' ? globalThis.RTCSessionDescription : class {}; const RTCRtpReceiverRef = typeof globalThis.RTCRtpReceiver === 'function' ? globalThis.RTCRtpReceiver : class {}; const RTCRtpSenderRef = typeof globalThis.RTCRtpSender === 'function' ? globalThis.RTCRtpSender : class {}; const RTCRtpTransceiverRef = typeof globalThis.RTCRtpTransceiver === 'function' ? globalThis.RTCRtpTransceiver : class {}; const MediaStreamRef = typeof globalThis.MediaStream === 'function' ? globalThis.MediaStream : class {}; const MediaStreamTrackRef = typeof globalThis.MediaStreamTrack === 'function' ? globalThis.MediaStreamTrack : class {}; const MediaStreamTrackEventRef = typeof globalThis.MediaStreamTrackEvent === 'function' ? globalThis.MediaStreamTrackEvent : class extends Event {}; export const RTCIceCandidate = RTCIceCandidateRef as typeof globalThis.RTCIceCandidate; export const RTCPeerConnection = RTCPeerConnectionRef as typeof globalThis.RTCPeerConnection; export const RTCSessionDescription = RTCSessionDescriptionRef as typeof globalThis.RTCSessionDescription; export const RTCRtpReceiver = RTCRtpReceiverRef as typeof globalThis.RTCRtpReceiver; export const RTCRtpSender = RTCRtpSenderRef as typeof globalThis.RTCRtpSender; export const RTCRtpTransceiver = RTCRtpTransceiverRef as typeof globalThis.RTCRtpTransceiver; export const MediaStream = MediaStreamRef as typeof globalThis.MediaStream; export const MediaStreamTrack = MediaStreamTrackRef as typeof globalThis.MediaStreamTrack; export const MediaStreamTrackEvent = MediaStreamTrackEventRef as typeof globalThis.MediaStreamTrackEvent; export function registerGlobals(): void { patchMediaStream(); const nav = (globalThis.navigator ?? {}) as unknown as Record & { mediaDevices?: typeof mediaDevices; }; if (typeof globalThis.navigator === 'undefined') { (globalThis as typeof globalThis & { navigator: typeof nav }).navigator = nav as any; } if (!nav.mediaDevices) { nav.mediaDevices = mediaDevices; } const globalRef = globalThis as typeof globalThis & Record; globalRef.RTCIceCandidate = RTCIceCandidate; globalRef.RTCPeerConnection = RTCPeerConnection; globalRef.RTCSessionDescription = RTCSessionDescription; globalRef.MediaStream = MediaStream; globalRef.MediaStreamTrack = MediaStreamTrack; globalRef.MediaStreamTrackEvent = MediaStreamTrackEvent; globalRef.RTCRtpTransceiver = RTCRtpTransceiver; globalRef.RTCRtpReceiver = RTCRtpReceiver; globalRef.RTCRtpSender = RTCRtpSender; globalRef.RTCErrorEvent = RTCErrorEvent; } export { mediaDevices, permissions, RTCView, RTCPIPView, ScreenCapturePickerView, RTCAudioSession, RTCDataPacketCryptor, RTCDataPacketCryptorFactory, RTCErrorEvent, RTCFrameCryptor, RTCFrameCryptorFactory, RTCKeyProvider, startIOSPIP, stopIOSPIP, type RTCVideoViewProps, type RTCIOSPIPOptions, };