@sawport/peers-caller 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +782 -0
  2. package/dist/core/BaseStore.d.ts +13 -0
  3. package/dist/core/BaseStore.d.ts.map +1 -0
  4. package/dist/core/CallMediaStream.d.ts +101 -0
  5. package/dist/core/CallMediaStream.d.ts.map +1 -0
  6. package/dist/core/CallParticipant.d.ts +122 -0
  7. package/dist/core/CallParticipant.d.ts.map +1 -0
  8. package/dist/core/CallPeerConnection.d.ts +92 -0
  9. package/dist/core/CallPeerConnection.d.ts.map +1 -0
  10. package/dist/core/CallRecorder.d.ts +72 -0
  11. package/dist/core/CallRecorder.d.ts.map +1 -0
  12. package/dist/core/CallSocket.d.ts +131 -0
  13. package/dist/core/CallSocket.d.ts.map +1 -0
  14. package/dist/core/PeersCaller.d.ts +155 -0
  15. package/dist/core/PeersCaller.d.ts.map +1 -0
  16. package/dist/events/CallEventEmitter.d.ts +2 -0
  17. package/dist/events/CallEventEmitter.d.ts.map +1 -0
  18. package/dist/events/index.d.ts +2 -0
  19. package/dist/events/index.d.ts.map +1 -0
  20. package/dist/events/types.d.ts +2 -0
  21. package/dist/events/types.d.ts.map +1 -0
  22. package/dist/hooks/index.d.ts +90 -0
  23. package/dist/hooks/index.d.ts.map +1 -0
  24. package/dist/index.d.ts +19 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/peers-caller.es.js +7983 -0
  27. package/dist/peers-caller.es.js.map +1 -0
  28. package/dist/peers-caller.umd.js +22 -0
  29. package/dist/peers-caller.umd.js.map +1 -0
  30. package/dist/polyfills.d.ts +5 -0
  31. package/dist/polyfills.d.ts.map +1 -0
  32. package/dist/store/index.d.ts +57 -0
  33. package/dist/store/index.d.ts.map +1 -0
  34. package/dist/test-polyfills.d.ts +2 -0
  35. package/dist/test-polyfills.d.ts.map +1 -0
  36. package/dist/test-setup.d.ts +2 -0
  37. package/dist/test-setup.d.ts.map +1 -0
  38. package/dist/test-utils.d.ts +2 -0
  39. package/dist/test-utils.d.ts.map +1 -0
  40. package/dist/tester/App.d.ts +3 -0
  41. package/dist/tester/App.d.ts.map +1 -0
  42. package/dist/tester/components/ConfigPanel.d.ts +17 -0
  43. package/dist/tester/components/ConfigPanel.d.ts.map +1 -0
  44. package/dist/tester/components/ConnectionStatus.d.ts +21 -0
  45. package/dist/tester/components/ConnectionStatus.d.ts.map +1 -0
  46. package/dist/tester/components/ControlPanel.d.ts +23 -0
  47. package/dist/tester/components/ControlPanel.d.ts.map +1 -0
  48. package/dist/tester/components/DebugConsole.d.ts +27 -0
  49. package/dist/tester/components/DebugConsole.d.ts.map +1 -0
  50. package/dist/tester/components/ParticipantList.d.ts +10 -0
  51. package/dist/tester/components/ParticipantList.d.ts.map +1 -0
  52. package/dist/tester/components/VideoGrid.d.ts +10 -0
  53. package/dist/tester/components/VideoGrid.d.ts.map +1 -0
  54. package/dist/tester/hooks/useTester.d.ts +54 -0
  55. package/dist/tester/hooks/useTester.d.ts.map +1 -0
  56. package/dist/tester/main.d.ts +3 -0
  57. package/dist/tester/main.d.ts.map +1 -0
  58. package/dist/types/index.d.ts +262 -0
  59. package/dist/types/index.d.ts.map +1 -0
  60. package/dist/utils/index.d.ts +50 -0
  61. package/dist/utils/index.d.ts.map +1 -0
  62. package/package.json +78 -0
@@ -0,0 +1,13 @@
1
+ /**
2
+ * BaseStore - Abstract class to standardize store access for core classes
3
+ * Provides a typed state getter that proxies to store.getState().
4
+ */
5
+ export type ReadonlyZustandStore<TState> = {
6
+ getState: () => TState;
7
+ };
8
+ export declare abstract class BaseStore<TState extends object> {
9
+ protected readonly store: ReadonlyZustandStore<TState>;
10
+ protected constructor(storeOrState: ReadonlyZustandStore<TState> | TState);
11
+ get state(): TState;
12
+ }
13
+ //# sourceMappingURL=BaseStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseStore.d.ts","sourceRoot":"","sources":["../../src/core/BaseStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,oBAAoB,CAAC,MAAM,IAAI;IACzC,QAAQ,EAAE,MAAM,MAAM,CAAC;CACxB,CAAC;AAEF,8BAAsB,SAAS,CAAC,MAAM,SAAS,MAAM;IACnD,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAEvD,SAAS,aAAa,YAAY,EAAE,oBAAoB,CAAC,MAAM,CAAC,GAAG,MAAM;IAazE,IAAI,KAAK,IAAI,MAAM,CAElB;CACF"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * CallMediaStream - Media stream management for PeersCaller
3
+ * Handles camera, microphone, and screen sharing streams
4
+ */
5
+ import type { MediaStreamConfig, ScreenShareConfig } from "../types";
6
+ export declare class CallMediaStream {
7
+ private stream;
8
+ private videoElement;
9
+ private constraints;
10
+ private isScreenShare;
11
+ constructor(constraints?: MediaStreamConfig);
12
+ /**
13
+ * Initialize media stream with camera and microphone
14
+ */
15
+ initialize(): Promise<MediaStream>;
16
+ /**
17
+ * Start screen sharing
18
+ */
19
+ startScreenShare(config?: ScreenShareConfig): Promise<MediaStream>;
20
+ /**
21
+ * Stop screen sharing and revert to camera
22
+ */
23
+ stopScreenShare(cameraStream?: MediaStream | null): Promise<MediaStream>;
24
+ /**
25
+ * Toggle audio track
26
+ */
27
+ toggleAudio(enabled: boolean): void;
28
+ /**
29
+ * Toggle video track
30
+ */
31
+ toggleVideo(enabled: boolean): void;
32
+ /**
33
+ * Create and return a video element for displaying the stream
34
+ */
35
+ createVideoElement(): HTMLVideoElement;
36
+ /**
37
+ * Attach stream to an existing video element
38
+ */
39
+ attachToVideoElement(videoElement: HTMLVideoElement): void;
40
+ /**
41
+ * Replace the current stream (useful for switching between camera and screen)
42
+ */
43
+ replaceStream(newStream: MediaStream): void;
44
+ /**
45
+ * Get current stream
46
+ */
47
+ getStream(): MediaStream | null;
48
+ /**
49
+ * Get video element
50
+ */
51
+ getVideoElement(): HTMLVideoElement | null;
52
+ /**
53
+ * Check if current stream is screen share
54
+ */
55
+ getIsScreenShare(): boolean;
56
+ /**
57
+ * Get audio track enabled state
58
+ */
59
+ isAudioEnabled(): boolean;
60
+ /**
61
+ * Get video track enabled state
62
+ */
63
+ isVideoEnabled(): boolean;
64
+ /**
65
+ * Get stream information
66
+ */
67
+ getStreamInfo(): {
68
+ id: string;
69
+ videoTracks: number;
70
+ audioTracks: number;
71
+ isScreenShare: boolean;
72
+ videoEnabled: boolean;
73
+ audioEnabled: boolean;
74
+ videoConstraints: MediaTrackSettings | null;
75
+ audioConstraints: MediaTrackSettings | null;
76
+ } | null;
77
+ /**
78
+ * Stop all tracks and cleanup
79
+ */
80
+ cleanup(): void;
81
+ /**
82
+ * Handle media errors and provide user-friendly messages
83
+ */
84
+ private handleMediaError;
85
+ /**
86
+ * Get available media devices
87
+ */
88
+ static getAvailableDevices(): Promise<{
89
+ videoDevices: MediaDeviceInfo[];
90
+ audioDevices: MediaDeviceInfo[];
91
+ }>;
92
+ /**
93
+ * Check if browser supports required features
94
+ */
95
+ static checkBrowserSupport(): {
96
+ getUserMedia: boolean;
97
+ getDisplayMedia: boolean;
98
+ webRTC: boolean;
99
+ };
100
+ }
101
+ //# sourceMappingURL=CallMediaStream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CallMediaStream.d.ts","sourceRoot":"","sources":["../../src/core/CallMediaStream.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAErE,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,YAAY,CAAiC;IACrD,OAAO,CAAC,WAAW,CAAoB;IACvC,OAAO,CAAC,aAAa,CAAS;gBAElB,WAAW,GAAE,iBAAgD;IAIzE;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC;IAoBxC;;OAEG;IACG,gBAAgB,CACpB,MAAM,GAAE,iBAAiD,GACxD,OAAO,CAAC,WAAW,CAAC;IA+BvB;;OAEG;IACG,eAAe,CACnB,YAAY,CAAC,EAAE,WAAW,GAAG,IAAI,GAChC,OAAO,CAAC,WAAW,CAAC;IA0BvB;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAcnC;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAcnC;;OAEG;IACH,kBAAkB,IAAI,gBAAgB;IActC;;OAEG;IACH,oBAAoB,CAAC,YAAY,EAAE,gBAAgB,GAAG,IAAI;IAO1D;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI;IAgB3C;;OAEG;IACH,SAAS,IAAI,WAAW,GAAG,IAAI;IAI/B;;OAEG;IACH,eAAe,IAAI,gBAAgB,GAAG,IAAI;IAI1C;;OAEG;IACH,gBAAgB,IAAI,OAAO;IAI3B;;OAEG;IACH,cAAc,IAAI,OAAO;IAMzB;;OAEG;IACH,cAAc,IAAI,OAAO;IAMzB;;OAEG;IACH,aAAa;;;;;;;;;;IAoBb;;OAEG;IACH,OAAO,IAAI,IAAI;IAkBf;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAsBxB;;OAEG;WACU,mBAAmB,IAAI,OAAO,CAAC;QAC1C,YAAY,EAAE,eAAe,EAAE,CAAC;QAChC,YAAY,EAAE,eAAe,EAAE,CAAC;KACjC,CAAC;IAiBF;;OAEG;IACH,MAAM,CAAC,mBAAmB,IAAI;QAC5B,YAAY,EAAE,OAAO,CAAC;QACtB,eAAe,EAAE,OAAO,CAAC;QACzB,MAAM,EAAE,OAAO,CAAC;KACjB;CAWF"}
@@ -0,0 +1,122 @@
1
+ /**
2
+ * CallParticipant - Manages individual participant in a multi-peer call
3
+ * Handles participant state, media streams, and peer connections
4
+ */
5
+ import { CallMediaStream } from "./CallMediaStream";
6
+ import { CallPeerConnection } from "./CallPeerConnection";
7
+ import { type CallStore } from "../store";
8
+ import { BaseStore } from "./BaseStore";
9
+ import type { CallParticipant as ICallParticipant, PeerConnectionConfig } from "../types";
10
+ export declare class CallParticipant extends BaseStore<CallStore> {
11
+ private userId;
12
+ private mediaStream;
13
+ private peerConnections;
14
+ private remoteStreams;
15
+ private isLocalParticipant;
16
+ private callbacks;
17
+ constructor(userId: string, callbacks?: CallParticipant["callbacks"], isLocalParticipant?: boolean);
18
+ /**
19
+ * Initialize participant with media stream
20
+ */
21
+ initialize(constraints?: {
22
+ video: boolean;
23
+ audio: boolean;
24
+ }): Promise<void>;
25
+ /**
26
+ * Create peer connection to another participant
27
+ */
28
+ createPeerConnection(remoteUserId: string, config: PeerConnectionConfig, isInitiator: boolean): Promise<void>;
29
+ /**
30
+ * Get peer connection to specific user
31
+ */
32
+ getPeerConnection(remoteUserId: string): CallPeerConnection | undefined;
33
+ /**
34
+ * Signal to a specific peer
35
+ */
36
+ signalToPeer(remoteUserId: string, data: any): void;
37
+ /**
38
+ * Toggle audio for this participant
39
+ */
40
+ toggleAudio(enabled: boolean): void;
41
+ /**
42
+ * Toggle video for this participant
43
+ */
44
+ toggleVideo(enabled: boolean): void;
45
+ /**
46
+ * Start screen sharing
47
+ */
48
+ startScreenShare(): Promise<void>;
49
+ /**
50
+ * Stop screen sharing
51
+ */
52
+ stopScreenShare(): Promise<void>;
53
+ /**
54
+ * Get current participant state
55
+ */
56
+ getState(): ICallParticipant;
57
+ /**
58
+ * Get participant's user ID
59
+ */
60
+ getUserId(): string;
61
+ /**
62
+ * Get participant's media stream
63
+ */
64
+ getMediaStream(): CallMediaStream | null;
65
+ /**
66
+ * Get participant's current stream
67
+ */
68
+ getCurrentStream(): MediaStream | undefined;
69
+ /**
70
+ * Get participant's video element
71
+ */
72
+ getVideoElement(): HTMLVideoElement | undefined;
73
+ /**
74
+ * Get remote stream from specific participant
75
+ */
76
+ getRemoteStream(fromUserId: string): MediaStream | undefined;
77
+ /**
78
+ * Get all remote streams
79
+ */
80
+ getAllRemoteStreams(): Map<string, MediaStream>;
81
+ /**
82
+ * Get all peer connections
83
+ */
84
+ getAllPeerConnections(): Map<string, CallPeerConnection>;
85
+ /**
86
+ * Get connection status with all peers
87
+ */
88
+ getConnectionStatus(): Record<string, boolean>;
89
+ /**
90
+ * Remove peer connection
91
+ */
92
+ removePeerConnection(remoteUserId: string): void;
93
+ /**
94
+ * Update participant state and notify store and callbacks
95
+ */
96
+ private updateState;
97
+ /**
98
+ * Get participant info for debugging
99
+ */
100
+ getDebugInfo(): {
101
+ userId: string;
102
+ state: ICallParticipant;
103
+ peerConnections: string[];
104
+ remoteStreams: string[];
105
+ connectionStatus: Record<string, boolean>;
106
+ mediaStreamInfo: {
107
+ id: string;
108
+ videoTracks: number;
109
+ audioTracks: number;
110
+ isScreenShare: boolean;
111
+ videoEnabled: boolean;
112
+ audioEnabled: boolean;
113
+ videoConstraints: MediaTrackSettings | null;
114
+ audioConstraints: MediaTrackSettings | null;
115
+ } | null | undefined;
116
+ };
117
+ /**
118
+ * Cleanup participant resources
119
+ */
120
+ cleanup(): void;
121
+ }
122
+ //# sourceMappingURL=CallParticipant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CallParticipant.d.ts","sourceRoot":"","sources":["../../src/core/CallParticipant.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,kBAAkB,EAEnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EACV,eAAe,IAAI,gBAAgB,EACnC,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAElB,qBAAa,eAAgB,SAAQ,SAAS,CAAC,SAAS,CAAC;IACvD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,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OAEG;IACH,mBAAmB,IAAI,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC;IAI/C;;OAEG;IACH,qBAAqB,IAAI,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC;IAIxD;;OAEG;IACH,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAU9C;;OAEG;IACH,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAiBhD;;OAEG;IACH,OAAO,CAAC,WAAW;IAwBnB;;OAEG;IACH,YAAY;;;;;;;;;;;;;;;;;IAWZ;;OAEG;IACH,OAAO,IAAI,IAAI;CAyBhB"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * CallPeerConnection - WebRTC peer connection management using simple-peer
3
+ * Handles individual peer-to-peer connections in the mesh network
4
+ */
5
+ import SimplePeer from "simple-peer";
6
+ import type { PeerConnectionConfig } from "../types";
7
+ export interface PeerConnectionEvents {
8
+ onSignal: (data: SimplePeer.SignalData) => void;
9
+ onConnect: () => void;
10
+ onData: (data: any) => void;
11
+ onStream: (stream: MediaStream) => void;
12
+ onTrack: (track: MediaStreamTrack, stream: MediaStream) => void;
13
+ onClose: () => void;
14
+ onError: (error: Error) => void;
15
+ }
16
+ export declare class CallPeerConnection {
17
+ private peer;
18
+ private config;
19
+ private events;
20
+ private connectionState;
21
+ private isInitiator;
22
+ private remoteUserId;
23
+ private localStream;
24
+ constructor(remoteUserId: string, config: PeerConnectionConfig, events?: Partial<PeerConnectionEvents>);
25
+ /**
26
+ * Create and initialize the peer connection
27
+ */
28
+ createConnection(localStream?: MediaStream): Promise<void>;
29
+ /**
30
+ * Signal data to remote peer
31
+ */
32
+ signal(data: SimplePeer.SignalData): void;
33
+ /**
34
+ * Add stream to the peer connection
35
+ */
36
+ addStream(stream: MediaStream): void;
37
+ /**
38
+ * Remove stream from the peer connection
39
+ */
40
+ removeStream(stream: MediaStream): void;
41
+ /**
42
+ * Replace a track in the peer connection (useful for screen sharing)
43
+ */
44
+ replaceTrack(oldTrack: MediaStreamTrack, newTrack: MediaStreamTrack): void;
45
+ /**
46
+ * Send data through the data channel
47
+ */
48
+ sendData(data: any): void;
49
+ /**
50
+ * Set bandwidth limits
51
+ */
52
+ setBandwidthLimit(maxBitrate: number): Promise<void>;
53
+ /**
54
+ * Get connection state
55
+ */
56
+ getConnectionState(): RTCPeerConnectionState;
57
+ /**
58
+ * Check if peer is connected
59
+ */
60
+ isConnected(): boolean;
61
+ /**
62
+ * Get connection statistics
63
+ */
64
+ getStats(): Promise<RTCStatsReport | null>;
65
+ /**
66
+ * Get remote user ID
67
+ */
68
+ getRemoteUserId(): string;
69
+ /**
70
+ * Cleanup and destroy the peer connection
71
+ */
72
+ destroy(): void;
73
+ /**
74
+ * Setup event listeners for the peer connection
75
+ */
76
+ private setupPeerEventListeners;
77
+ /**
78
+ * Get detailed connection info for debugging
79
+ */
80
+ getConnectionInfo(): {
81
+ remoteUserId: string;
82
+ isInitiator: boolean;
83
+ connectionState: RTCPeerConnectionState;
84
+ connected: boolean;
85
+ hasLocalStream: boolean;
86
+ localStreamTracks: {
87
+ video: number;
88
+ audio: number;
89
+ } | null;
90
+ };
91
+ }
92
+ //# sourceMappingURL=CallPeerConnection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CallPeerConnection.d.ts","sourceRoot":"","sources":["../../src/core/CallPeerConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAErD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,UAAU,KAAK,IAAI,CAAC;IAChD,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAC5B,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;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IAAI,MAAM;IAIzB;;OAEG;IACH,OAAO,IAAI,IAAI;IAqBf;;OAEG;IACH,OAAO,CAAC,uBAAuB;IA+E/B;;OAEG;IACH,iBAAiB;;;;;;;;;;;CAelB"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * CallRecorder - Recording and transcription management for PeersCaller
3
+ * Handles local recording of mixed streams and audio transcription
4
+ */
5
+ import type { RecordingConfig, RecordingData, TranscriptData } from "../types";
6
+ export interface RecorderCallbacks {
7
+ onRecordingStarted?: (recordingData: RecordingData) => void;
8
+ onRecordingChunk?: (chunk: Blob, recordingData: RecordingData) => void;
9
+ onRecordingStopped?: (recordingData: RecordingData) => void;
10
+ onTranscriptReceived?: (transcript: TranscriptData) => void;
11
+ onError?: (error: Error) => void;
12
+ }
13
+ export declare class CallRecorder {
14
+ private mixer;
15
+ private recorder;
16
+ private localTranscriber;
17
+ private isRecording;
18
+ private config;
19
+ private callbacks;
20
+ constructor(conversationId: string, userId: string, config?: RecordingConfig, callbacks?: RecorderCallbacks);
21
+ /**
22
+ * Start recording with mixed streams and recording data
23
+ */
24
+ startRecording(streams: MediaStream[], recordingData: RecordingData): Promise<void>;
25
+ /**
26
+ * Stop recording
27
+ */
28
+ stopRecording(): Promise<TranscriptData[]>;
29
+ /**
30
+ * Reset video streams for mixer (used when screen sharing changes)
31
+ */
32
+ resetVideoStreams(streams: MediaStream[]): void;
33
+ /**
34
+ * Set up MediaRecorder event handlers
35
+ */
36
+ private setupRecorderEventHandlers;
37
+ /**
38
+ * Get current recording state
39
+ */
40
+ getRecordingState(): {
41
+ isRecording: boolean;
42
+ isTranscribing: boolean;
43
+ transcriptCount: number;
44
+ };
45
+ /**
46
+ * Get all transcripts
47
+ */
48
+ getTranscripts(): TranscriptData[];
49
+ /**
50
+ * Check if recording is supported
51
+ */
52
+ static isRecordingSupported(): boolean;
53
+ /**
54
+ * Check if transcription is supported
55
+ */
56
+ static isTranscriptionSupported(): boolean;
57
+ /**
58
+ * Get supported mime types for recording
59
+ */
60
+ static getSupportedMimeTypes(): string[];
61
+ /**
62
+ * Cleanup recorder resources
63
+ */
64
+ cleanup(): void;
65
+ }
66
+ declare global {
67
+ interface Window {
68
+ SpeechRecognition: any;
69
+ webkitSpeechRecognition: any;
70
+ }
71
+ }
72
+ //# sourceMappingURL=CallRecorder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CallRecorder.d.ts","sourceRoot":"","sources":["../../src/core/CallRecorder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/E,MAAM,WAAW,iBAAiB;IAChC,kBAAkB,CAAC,EAAE,CAAC,aAAa,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5D,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,KAAK,IAAI,CAAC;IACvE,kBAAkB,CAAC,EAAE,CAAC,aAAa,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5D,oBAAoB,CAAC,EAAE,CAAC,UAAU,EAAE,cAAc,KAAK,IAAI,CAAC;IAC5D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAkC;IAC/C,OAAO,CAAC,QAAQ,CAA8B;IAC9C,OAAO,CAAC,gBAAgB,CAA4B;IACpD,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,SAAS,CAAoB;gBAGnC,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,eAAoB,EAC5B,SAAS,GAAE,iBAAsB;IAiBnC;;OAEG;IACG,cAAc,CAClB,OAAO,EAAE,WAAW,EAAE,EACtB,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,IAAI,CAAC;IAkEhB;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAkChD;;OAEG;IACH,iBAAiB,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI;IAO/C;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAwBlC;;OAEG;IACH,iBAAiB,IAAI;QACnB,WAAW,EAAE,OAAO,CAAC;QACrB,cAAc,EAAE,OAAO,CAAC;QACxB,eAAe,EAAE,MAAM,CAAC;KACzB;IAQD;;OAEG;IACH,cAAc,IAAI,cAAc,EAAE;IAIlC;;OAEG;IACH,MAAM,CAAC,oBAAoB,IAAI,OAAO;IAOtC;;OAEG;IACH,MAAM,CAAC,wBAAwB,IAAI,OAAO;IAM1C;;OAEG;IACH,MAAM,CAAC,qBAAqB,IAAI,MAAM,EAAE;IAgBxC;;OAEG;IACH,OAAO,IAAI,IAAI;CAqBhB;AAGD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,iBAAiB,EAAE,GAAG,CAAC;QACvB,uBAAuB,EAAE,GAAG,CAAC;KAC9B;CACF"}
@@ -0,0 +1,131 @@
1
+ /**
2
+ * CallSocket - WebSocket signaling management for PeersCaller
3
+ * Handles all WebSocket communication for call signaling
4
+ */
5
+ import type { SignalingEvents, SignalingIncomingEvents } from "../types";
6
+ export declare class CallSocket {
7
+ private socket;
8
+ private serverUrl;
9
+ private socketPath;
10
+ private token;
11
+ private connected;
12
+ private reconnectAttempts;
13
+ private maxReconnectAttempts;
14
+ constructor(serverUrl: string, token: string, socketPath?: string);
15
+ /**
16
+ * Connect to the WebSocket server
17
+ */
18
+ connect(): Promise<void>;
19
+ /**
20
+ * Disconnect from the WebSocket server
21
+ */
22
+ disconnect(): void;
23
+ /**
24
+ * Check if socket is connected
25
+ */
26
+ isConnected(): boolean;
27
+ /**
28
+ * Emit a signaling event - fire and forget (no response expected)
29
+ */
30
+ emit<K extends keyof SignalingEvents>(event: K, data: Parameters<SignalingEvents[K]>[0]): void;
31
+ /**
32
+ * Emit a signaling event and wait for response
33
+ */
34
+ emitWithResponse<K extends keyof SignalingEvents>(event: K, data: Parameters<SignalingEvents[K]>[0], timeoutMs?: number): Promise<any>;
35
+ /**
36
+ * Listen for an incoming signaling event (from server)
37
+ */
38
+ on<K extends keyof SignalingIncomingEvents>(event: K, listener: SignalingIncomingEvents[K]): void;
39
+ /**
40
+ * Remove an incoming signaling event listener
41
+ */
42
+ off<K extends keyof SignalingIncomingEvents>(event: K, listener?: SignalingIncomingEvents[K]): void;
43
+ /**
44
+ * Start a new call
45
+ */
46
+ startCall(conversationId: string, userId: string): Promise<{
47
+ success: boolean;
48
+ participants: string[];
49
+ conversationId: string;
50
+ userId: string;
51
+ }>;
52
+ /**
53
+ * Join a call room for signaling
54
+ */
55
+ joinRoom(conversationId: string, userId: string): Promise<{
56
+ participants: string[];
57
+ conversationId: string;
58
+ }>;
59
+ /**
60
+ * Leave a call
61
+ */
62
+ leaveCall(conversationId: string, userId: string): Promise<{
63
+ conversationId: string;
64
+ success: boolean;
65
+ }>;
66
+ /**
67
+ * Send WebRTC offer
68
+ */
69
+ sendOffer(to: string, from: string, offer: RTCSessionDescriptionInit, conversationId: string): void;
70
+ /**
71
+ * Send WebRTC answer
72
+ */
73
+ sendAnswer(to: string, from: string, answer: RTCSessionDescriptionInit, conversationId: string): void;
74
+ /**
75
+ * Send ICE candidate
76
+ */
77
+ sendCandidate(to: string, from: string, candidate: RTCIceCandidateInit, conversationId: string): void;
78
+ /**
79
+ * Send participant state update
80
+ */
81
+ sendStateUpdate(to: string, from: string, state: any, conversationId: string): void;
82
+ /**
83
+ * End call for specific participant (legacy method)
84
+ */
85
+ endCall(to: string, _from: string, conversationId: string): void;
86
+ /**
87
+ * End call for all participants
88
+ */
89
+ endCallForAll(conversationId: string): Promise<void>;
90
+ /**
91
+ * Start recording
92
+ */
93
+ startRecording(conversationId: string, recordingId: string): Promise<{
94
+ recordingId: string;
95
+ conversationId: string;
96
+ }>;
97
+ /**
98
+ * Send recording chunk
99
+ */
100
+ sendRecordingChunk(conversationId: string, recordingId: string, chunk: Blob): void;
101
+ /**
102
+ * End recording
103
+ */
104
+ endRecording(conversationId: string, recordingId: string): Promise<{
105
+ recordingId: string;
106
+ conversationId: string;
107
+ success: boolean;
108
+ }>;
109
+ /**
110
+ * Send transcript
111
+ */
112
+ sendTranscript(conversationId: string, userId: string, transcript: string): void;
113
+ /**
114
+ * Check call status
115
+ */
116
+ checkCallStatus(conversationId: string, userId: string): Promise<any>;
117
+ /**
118
+ * Handle disconnection scenarios
119
+ */
120
+ private handleDisconnection;
121
+ /**
122
+ * Get connection health info
123
+ */
124
+ getConnectionInfo(): {
125
+ connected: boolean;
126
+ socketId: string | undefined;
127
+ transport: string | undefined;
128
+ reconnectAttempts: number;
129
+ };
130
+ }
131
+ //# sourceMappingURL=CallSocket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CallSocket.d.ts","sourceRoot":"","sources":["../../src/core/CallSocket.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAEzE,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,oBAAoB,CAAK;gBAG/B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,UAAU,SAAqB;IAOjC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAwD9B;;OAEG;IACH,UAAU,IAAI,IAAI;IASlB;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACH,IAAI,CAAC,CAAC,SAAS,MAAM,eAAe,EAClC,KAAK,EAAE,CAAC,EACR,IAAI,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