/** * Options accepted by {@link WebRTCClient}. * * @property endpoint HTTP endpoint that exchanges SDP with the * backend; must accept a POST of * `{ sdp, type, webrtc_id }` and return the * answer description. * @property onConnected Fires after `setRemoteDescription` succeeds. * @property onDisconnected Fires when `disconnect()` is invoked, * regardless of whether a connection existed. * @property onMessage Invoked for every JSON-parsed message * received on the `text` data channel. * @property onAudioStream Receives the remote `MediaStream` once * negotiated so the caller can attach it to * an audio element. * @property onAudioLevel Throttled average microphone level in * `[0, 1]`. Updates roughly every 100ms. * @property audioInputDeviceId Optional `deviceId` constraint for * `getUserMedia`. * @property audioOutputDeviceId Output device id forwarded to the audio * stream consumer via * `options.audioOutputDeviceId`. */ interface WebRTCClientOptions { endpoint: string; onConnected?: () => void; onDisconnected?: () => void; onMessage?: (message: any) => void; onAudioStream?: (stream: MediaStream) => void; onAudioLevel?: (level: number) => void; audioInputDeviceId?: string; audioOutputDeviceId?: string; } /** * Browser-side WebRTC helper that opens an audio peer connection to a PieUI * backend endpoint, exchanges SDP, and exposes lightweight hooks for * messaging and microphone level analysis. * * The class is safe to instantiate in SSR environments — `connect()` and * device setters guard on `typeof window !== 'undefined'` and no-op on the * server. Calling any method twice cleanly re-establishes the connection. */ export declare class WebRTCClient { private peerConnection; private mediaStream; private dataChannel; private options; private audioContext; private analyser; private dataArray; private animationFrameId; private currentInputDeviceId; private currentOutputDeviceId; constructor(options: WebRTCClientOptions); /** * Changes the active microphone device. * * If a peer connection is already open the client tears it down and * re-connects with the new device, because WebRTC tracks cannot be * swapped mid-session without renegotiation. */ setAudioInputDevice(deviceId: string): void; /** * Changes the preferred audio output device. Because the actual sink is * attached to the `