UNPKG

@webrtc2/client

Version:

WebRTC2 Client - React Native, Web & Electron WebRTC hooks and components for cross-platform real-time video calls, audio communication, and screen sharing

115 lines (105 loc) 2.7 kB
import * as react_jsx_runtime from 'react/jsx-runtime'; import { ReactNode } from 'react'; /** * AudioCall component for WebRTC audio communication */ declare function AudioCall(): null; /** * ScreenShare component for WebRTC screen sharing */ declare function ScreenShare(): null; /** * VideoCall component for WebRTC video communication * * @example * ```tsx * <VideoCall roomId="room-123" /> * ``` */ declare function VideoCall(): null; /** * WebRTC2 Client Types */ interface WebRTCConfig { iceServers: RTCIceServer[]; signaling: { url: string; options?: any; }; } type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'failed' | 'closed'; interface MediaStreamOptions { video?: boolean | MediaTrackConstraints; audio?: boolean | MediaTrackConstraints; screen?: boolean; } interface PeerConnection { id: string; connection: RTCPeerConnection; stream?: MediaStream; } type CallState = 'idle' | 'calling' | 'ringing' | 'connected' | 'ended'; interface WebRTCHookReturn { connect: (roomId: string) => Promise<void>; disconnect: () => void; localStream: MediaStream | null; remoteStream: MediaStream | null; connectionState: ConnectionState; callState: CallState; } /** * Main WebRTC hook for managing peer connections * * @example * ```tsx * const { connect, localStream, remoteStream, connectionState } = useWebRTC(); * ``` */ declare function useWebRTC(): WebRTCHookReturn; interface WebRTCProviderProps { children: ReactNode; config?: WebRTCConfig; } /** * WebRTC Provider component * * @example * ```tsx * <WebRTCProvider config={config}> * <App /> * </WebRTCProvider> * ``` */ declare function WebRTCProvider({ children, config }: WebRTCProviderProps): react_jsx_runtime.JSX.Element; /** * @webrtc2/client * * WebRTC2 Client - React hooks and components for real-time communication * * @example * ```tsx * import { useWebRTC, WebRTCProvider } from '@webrtc2/client'; * * function App() { * return ( * <WebRTCProvider> * <VideoCall /> * </WebRTCProvider> * ); * } * * function VideoCall() { * const { connect, localStream, remoteStream } = useWebRTC(); * * return ( * <div> * <video srcObject={localStream} autoPlay muted /> * <video srcObject={remoteStream} autoPlay /> * <button onClick={() => connect('room-id')}>Connect</button> * </div> * ); * } * ``` */ declare const VERSION = "1.0.0"; export { AudioCall, type CallState, type ConnectionState, type MediaStreamOptions, type PeerConnection, ScreenShare, VERSION, VideoCall, type WebRTCConfig, WebRTCProvider, useWebRTC };