@capgo/capacitor-stream-call 0.0.3 → 0.0.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAU1E,MAAM,OAAO,aAAc,SAAQ,SAAS;IAA5C;;QAOU,kBAAa,GAA4B,IAAI,GAAG,EAAE,CAAC;QACnD,kBAAa,GAA4B,IAAI,GAAG,EAAE,CAAC;QASnD,iBAAY,GAAG,CAAC,KAAmC,EAAE,EAAE;;YAC7D,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;YACrD,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC;YAC/B,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;gBACtB,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAChD,IAAI,CAAC,WAAW,GAAG,MAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACrE,IAAI,CAAC,eAAe,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC;YAC5F,CAAC;YACD,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACrB,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;gBAC/C,IAAI,CAAC,qBAA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,GAAG,CAAC,gBAAgB,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACpC,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC;QACtD,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\nimport type { AllClientEvents, Call, CallResponse, StreamVideoParticipant } from '@stream-io/video-client';\nimport { CallingState, StreamVideoClient } from '@stream-io/video-client';\n\nimport type {\n CallOptions,\n StreamCallPlugin,\n SuccessResponse,\n LoginOptions,\n CameraEnabledResponse,\n} from './definitions';\n\nexport class StreamCallWeb extends WebPlugin implements StreamCallPlugin {\n private client?: StreamVideoClient;\n private currentCall?: Call;\n private callStateSubscription?: { unsubscribe: () => void };\n private incomingCall?: CallResponse;\n private outgoingCall?: string;\n private magicDivId?: string;\n private videoBindings: Map<string, () => void> = new Map();\n private audioBindings: Map<string, () => void> = new Map();\n private participantJoinedListener?: (event: { participant?: { sessionId: string } }) => void;\n private participantLeftListener?: (event: { participant?: { sessionId: string } }) => void;\n\n private setupCallRingListener() {\n this.client?.off('call.ring', this.ringCallback);\n this.client?.on('call.ring', this.ringCallback);\n }\n\n private ringCallback = (event: AllClientEvents['call.ring']) => {\n console.log('Call ringing', event, this.currentCall);\n this.incomingCall = event.call;\n if (!this.currentCall) {\n console.log('Creating new call', event.call.id);\n this.currentCall = this.client?.call(event.call.type, event.call.id);\n this.notifyListeners('callEvent', { callId: event.call.id, state: CallingState.RINGING });\n }\n if (this.currentCall) {\n console.log('Call found', this.currentCall.id);\n this.callStateSubscription = this.currentCall?.state.callingState$.subscribe((s) => {\n console.log('Call state', s);\n if (s === CallingState.JOINED) {\n this.setupParticipantListener();\n } else if (s === CallingState.LEFT || s === CallingState.RECONNECTING_FAILED) {\n this.cleanupCall();\n }\n if (this.outgoingCall && s === CallingState.RINGING) {\n this.outgoingCall = undefined;\n } else {\n this.notifyListeners('callEvent', { callId: this.currentCall?.id, state: s });\n }\n });\n }\n };\n\n private setupParticipantListener() {\n // Subscribe to participant changes\n this.incomingCall = undefined;\n if (!this.currentCall) return;\n\n this.participantJoinedListener = (event) => {\n if (this.magicDivId && event.participant) {\n const magicDiv = document.getElementById(this.magicDivId);\n if (magicDiv && this.currentCall) {\n this.setupParticipantVideo(this.currentCall, event.participant as StreamVideoParticipant, magicDiv);\n this.setupParticipantAudio(this.currentCall, event.participant as StreamVideoParticipant, magicDiv);\n }\n }\n };\n\n this.participantLeftListener = (event) => {\n if (this.magicDivId && event.participant) {\n const videoId = `video-${event.participant.sessionId}`;\n const audioId = `audio-${event.participant.sessionId}`;\n\n // Remove video element\n const videoEl = document.getElementById(videoId) as HTMLVideoElement;\n if (videoEl) {\n const unbindVideo = this.videoBindings.get(videoId);\n if (unbindVideo) {\n unbindVideo();\n this.videoBindings.delete(videoId);\n }\n const tracks = videoEl.srcObject as MediaStream;\n if (tracks) {\n tracks.getTracks().forEach((track) => {\n track.stop();\n track.enabled = false;\n });\n videoEl.srcObject = null;\n }\n videoEl.remove();\n }\n\n // Remove audio element\n const audioEl = document.getElementById(audioId) as HTMLAudioElement;\n if (audioEl) {\n const unbindAudio = this.audioBindings.get(audioId);\n if (unbindAudio) {\n unbindAudio();\n this.audioBindings.delete(audioId);\n }\n const tracks = audioEl.srcObject as MediaStream;\n if (tracks) {\n tracks.getTracks().forEach((track) => {\n track.stop();\n track.enabled = false;\n });\n audioEl.srcObject = null;\n }\n audioEl.remove();\n }\n }\n };\n\n this.currentCall.on('participantJoined', this.participantJoinedListener);\n this.currentCall.on('participantLeft', this.participantLeftListener);\n\n // Setup initial participants\n const participants = this.currentCall.state.participants;\n if (this.magicDivId) {\n const magicDiv = document.getElementById(this.magicDivId);\n if (magicDiv) {\n participants.forEach((participant: StreamVideoParticipant) => {\n if (this.currentCall) {\n this.setupParticipantVideo(this.currentCall, participant, magicDiv);\n this.setupParticipantAudio(this.currentCall, participant, magicDiv);\n }\n });\n }\n }\n }\n\n private setupParticipantVideo(call: Call, participant: StreamVideoParticipant, container: HTMLElement) {\n const id = `video-${participant.sessionId}`;\n if (!document.getElementById(id)) {\n const videoEl = document.createElement('video');\n videoEl.id = id;\n videoEl.style.width = '100%';\n videoEl.style.maxWidth = '300px';\n videoEl.style.aspectRatio = '16/9';\n container.appendChild(videoEl);\n\n const unbind = call.bindVideoElement(videoEl, participant.sessionId, 'videoTrack');\n if (unbind) this.videoBindings.set(id, unbind);\n }\n }\n\n private setupParticipantAudio(call: Call, participant: StreamVideoParticipant, container: HTMLElement) {\n if (participant.isLocalParticipant) return;\n\n const id = `audio-${participant.sessionId}`;\n if (!document.getElementById(id)) {\n const audioEl = document.createElement('audio');\n audioEl.id = id;\n container.appendChild(audioEl);\n\n const unbind = call.bindAudioElement(audioEl, participant.sessionId);\n if (unbind) this.audioBindings.set(id, unbind);\n }\n }\n\n private cleanupCall() {\n // First cleanup the call listeners\n if (this.currentCall) {\n if (this.participantJoinedListener) {\n this.currentCall.off('participantJoined', this.participantJoinedListener);\n this.participantJoinedListener = undefined;\n }\n if (this.participantLeftListener) {\n this.currentCall.off('participantLeft', this.participantLeftListener);\n this.participantLeftListener = undefined;\n }\n this.callStateSubscription?.unsubscribe();\n }\n\n if (this.magicDivId) {\n const magicDiv = document.getElementById(this.magicDivId);\n if (magicDiv) {\n // Remove all video elements\n const videoElements = magicDiv.querySelectorAll('video');\n videoElements.forEach((video) => {\n const id = video.id;\n const unbind = this.videoBindings.get(id);\n if (unbind) {\n unbind();\n this.videoBindings.delete(id);\n }\n // Stop all tracks\n const tracks = (video as HTMLVideoElement).srcObject as MediaStream;\n if (tracks) {\n tracks.getTracks().forEach((track) => {\n track.stop();\n track.enabled = false;\n });\n video.srcObject = null;\n }\n video.remove();\n });\n\n // Remove all audio elements\n const audioElements = magicDiv.querySelectorAll('audio');\n audioElements.forEach((audio) => {\n const id = audio.id;\n const unbind = this.audioBindings.get(id);\n if (unbind) {\n unbind();\n this.audioBindings.delete(id);\n }\n // Stop all tracks\n const tracks = (audio as HTMLAudioElement).srcObject as MediaStream;\n if (tracks) {\n tracks.getTracks().forEach((track) => {\n track.stop();\n track.enabled = false;\n });\n audio.srcObject = null;\n }\n audio.remove();\n });\n\n // Clear the container\n while (magicDiv.firstChild) {\n magicDiv.removeChild(magicDiv.firstChild);\n }\n }\n }\n\n // Clear all bindings\n this.videoBindings.clear();\n this.audioBindings.clear();\n\n // Clear call references\n this.currentCall = undefined;\n this.incomingCall = undefined;\n }\n\n async login(options: LoginOptions): Promise<SuccessResponse> {\n this.client = StreamVideoClient.getOrCreateInstance({\n apiKey: options.apiKey,\n user: { id: options.userId, name: options.name, image: options.imageURL },\n token: options.token,\n });\n\n this.magicDivId = options.magicDivId;\n this.setupCallRingListener();\n\n return { success: true };\n }\n\n async logout(): Promise<SuccessResponse> {\n if (!this.client) {\n console.log('No client', this.client);\n throw new Error('Client not initialized');\n }\n\n // Cleanup subscription\n this.callStateSubscription?.unsubscribe();\n this.callStateSubscription = undefined;\n\n await this.client.disconnectUser();\n this.client = undefined;\n this.currentCall = undefined;\n return { success: true };\n }\n\n async call(options: CallOptions): Promise<SuccessResponse> {\n if (!this.client) {\n console.log('No client', this.client);\n throw new Error('Client not initialized - Please login first');\n }\n\n const call = this.client.call(options.type || 'default', crypto.randomUUID());\n const members = options.userIds.map((userId) => ({ user_id: userId }));\n if (this.client.streamClient.userID && options.userIds.includes(this.client.streamClient.userID)) {\n members.push({ user_id: this.client.streamClient.userID });\n }\n await call.getOrCreate({ data: { members } });\n this.currentCall = call;\n if (options.ring) {\n this.outgoingCall = call.cid;\n await call.ring();\n }\n\n await call.join();\n return { success: true };\n }\n\n async endCall(): Promise<SuccessResponse> {\n if (!this.currentCall) {\n console.log('No active call', this.currentCall);\n throw new Error('No active call');\n }\n\n await this.currentCall.leave();\n this.currentCall = undefined;\n this.cleanupCall();\n\n return { success: true };\n }\n\n async setMicrophoneEnabled(options: { enabled: boolean }): Promise<SuccessResponse> {\n if (!this.currentCall) {\n console.log('No active call', this.currentCall);\n throw new Error('No active call');\n }\n\n if (options.enabled) {\n await this.currentCall.microphone.enable();\n } else {\n await this.currentCall.microphone.disable();\n }\n\n return { success: true };\n }\n\n async setCameraEnabled(options: { enabled: boolean }): Promise<SuccessResponse> {\n if (!this.currentCall) {\n console.log('No active call', this.currentCall);\n throw new Error('No active call');\n }\n\n if (options.enabled) {\n await this.currentCall.camera.enable();\n } else {\n await this.currentCall.camera.disable();\n }\n\n return { success: true };\n }\n\n async acceptCall(): Promise<SuccessResponse> {\n if (!this.incomingCall || !this.client) {\n console.log('No incoming call to accept', this.incomingCall, this.client);\n throw new Error('No incoming call to accept');\n }\n console.log('Accepting call', this.incomingCall);\n const call = this.client.call(this.incomingCall.type, this.incomingCall.id);\n this.currentCall = call;\n console.log('Joining call', call);\n await call.accept();\n await call.join();\n console.log('Joined call', call);\n this.notifyListeners('callEvent', { callId: call.id, state: CallingState.JOINED });\n this.setupParticipantListener();\n return { success: true };\n }\n\n async rejectCall(): Promise<SuccessResponse> {\n if (!this.incomingCall || !this.client) {\n console.log('No incoming call to reject', this.incomingCall, this.client);\n throw new Error('No incoming call to reject');\n }\n console.log('Rejecting call', this.incomingCall);\n const call: Call = this.client.call(this.incomingCall.type, this.incomingCall.id);\n console.log('Leaving call', call);\n await call.leave();\n this.incomingCall = undefined;\n console.log('Rejected call', call);\n this.notifyListeners('callEvent', { callId: call.id, state: CallingState.LEFT });\n this.cleanupCall();\n return { success: true };\n }\n\n async isCameraEnabled(): Promise<CameraEnabledResponse> {\n if (!this.currentCall) {\n console.log('No active call', this.currentCall);\n throw new Error('No active call');\n }\n const enabled = await this.currentCall.camera.enabled;\n return { enabled };\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,C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Ae,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC;QACjF,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACpC,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC;QACtD,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\nimport type { AllClientEvents, Call, CallResponse, StreamVideoParticipant } from '@stream-io/video-client';\nimport { CallingState, StreamVideoClient } from '@stream-io/video-client';\n\nimport type {\n CallOptions,\n StreamCallPlugin,\n SuccessResponse,\n LoginOptions,\n CameraEnabledResponse,\n} from './definitions';\n\nexport class StreamCallWeb extends WebPlugin implements StreamCallPlugin {\n private client?: StreamVideoClient;\n private currentCall?: Call;\n private callStateSubscription?: { unsubscribe: () => void };\n private incomingCall?: CallResponse;\n private outgoingCall?: string;\n private magicDivId?: string;\n private videoBindings: Map<string, () => void> = new Map();\n private audioBindings: Map<string, () => void> = new Map();\n private participantJoinedListener?: (event: { participant?: { sessionId: string } }) => void;\n private participantLeftListener?: (event: { participant?: { sessionId: string } }) => void;\n private participantResponses: Map<string, string> = new Map();\n private callMembersExpected: Map<string, number> = new Map();\n// private currentActiveCallId?: string;\n\n private setupCallRingListener() {\n this.client?.off('call.ring', this.ringCallback);\n this.client?.off('call.session_started', this.callSessionStartedCallback);\n\n this.client?.on('call.ring', this.ringCallback);\n this.client?.on('call.session_started', this.callSessionStartedCallback);\n }\n\n private setupCallEventListeners() {\n // Clear previous listeners if any\n this.client?.off('call.rejected', this.callRejectedCallback);\n this.client?.off('call.accepted', this.callAcceptedCallback);\n this.client?.off('call.missed', this.callMissedCallback); \n // Register event listeners\n this.client?.on('call.rejected', this.callRejectedCallback);\n this.client?.on('call.accepted', this.callAcceptedCallback);\n this.client?.on('call.missed', this.callMissedCallback);\n }\n\n private ringCallback = (event: AllClientEvents['call.ring']) => {\n console.log('Call ringing', event, this.currentCall);\n this.incomingCall = event.call;\n if (!this.currentCall) {\n console.log('Creating new call', event.call.id);\n this.currentCall = this.client?.call(event.call.type, event.call.id);\n // this.currentActiveCallId = this.currentCall?.cid;\n this.notifyListeners('callEvent', { callId: event.call.id, state: CallingState.RINGING });\n // Clear previous responses when a new call starts\n this.participantResponses.clear();\n }\n if (this.currentCall) {\n console.log('Call found', this.currentCall.id);\n this.callStateSubscription = this.currentCall?.state.callingState$.subscribe((s) => {\n console.log('Call state', s);\n if (s === CallingState.JOINED) {\n this.setupParticipantListener();\n this.setupCallEventListeners();\n } else if (s === CallingState.LEFT || s === CallingState.RECONNECTING_FAILED) {\n this.cleanupCall();\n }\n if (this.outgoingCall && s === CallingState.RINGING) {\n this.outgoingCall = undefined;\n } else {\n this.notifyListeners('callEvent', { callId: this.currentCall?.id, state: s });\n }\n });\n }\n };\n\n private setupParticipantListener() {\n // Subscribe to participant changes\n this.incomingCall = undefined;\n if (!this.currentCall) return;\n\n this.participantJoinedListener = (event) => {\n if (this.magicDivId && event.participant) {\n const magicDiv = document.getElementById(this.magicDivId);\n if (magicDiv && this.currentCall) {\n this.setupParticipantVideo(this.currentCall, event.participant as StreamVideoParticipant, magicDiv);\n this.setupParticipantAudio(this.currentCall, event.participant as StreamVideoParticipant, magicDiv);\n }\n }\n };\n\n this.participantLeftListener = (event) => {\n if (this.magicDivId && event.participant) {\n const videoId = `video-${event.participant.sessionId}`;\n const audioId = `audio-${event.participant.sessionId}`;\n\n // Remove video element\n const videoEl = document.getElementById(videoId) as HTMLVideoElement;\n if (videoEl) {\n const unbindVideo = this.videoBindings.get(videoId);\n if (unbindVideo) {\n unbindVideo();\n this.videoBindings.delete(videoId);\n }\n const tracks = videoEl.srcObject as MediaStream;\n if (tracks) {\n tracks.getTracks().forEach((track) => {\n track.stop();\n });\n }\n videoEl.srcObject = null;\n videoEl.remove();\n }\n\n // Remove audio element\n const audioEl = document.getElementById(audioId) as HTMLAudioElement;\n if (audioEl) {\n const unbindAudio = this.audioBindings.get(audioId);\n if (unbindAudio) {\n unbindAudio();\n this.audioBindings.delete(audioId);\n }\n const tracks = audioEl.srcObject as MediaStream;\n if (tracks) {\n tracks.getTracks().forEach((track) => {\n track.stop();\n });\n }\n audioEl.srcObject = null;\n audioEl.remove();\n }\n }\n \n // Check if we're the only participant left in the call\n if (this.currentCall && this.currentCall.state.session) {\n // Get the remaining participants count (we need to subtract 1 as we haven't been removed from the list yet)\n const remainingParticipants = this.currentCall.state.session.participants.length - 1;\n \n // If we're the only one left, end the call\n if (remainingParticipants <= 1) {\n console.log(`We are left solo in a call. Ending. cID: ${this.currentCall.cid}`);\n \n // End the call\n this.currentCall.leave();\n \n // Clean up resources\n const callCid = this.currentCall.cid;\n \n // Invalidate and remove timer\n const callState = this.callStates?.get(callCid);\n if (callState?.timer) {\n clearInterval(callState.timer);\n }\n \n // Remove from callStates\n this.callStates?.delete(callCid);\n \n // Reset the current call\n this.currentCall = undefined;\n // this.currentActiveCallId = undefined;\n \n // Clean up\n this.cleanupCall();\n \n console.log(`Cleaned up resources for ended call: ${callCid}`);\n \n // Notify that the call has ended\n this.notifyListeners('callEvent', { \n callId: callCid, \n state: 'left',\n reason: 'participant_left'\n });\n }\n }\n };\n\n this.currentCall.on('participantJoined', this.participantJoinedListener);\n this.currentCall.on('participantLeft', this.participantLeftListener);\n\n // Setup initial participants\n const participants = this.currentCall.state.participants;\n if (this.magicDivId) {\n const magicDiv = document.getElementById(this.magicDivId);\n if (magicDiv) {\n participants.forEach((participant: StreamVideoParticipant) => {\n if (this.currentCall) {\n this.setupParticipantVideo(this.currentCall, participant, magicDiv);\n this.setupParticipantAudio(this.currentCall, participant, magicDiv);\n }\n });\n }\n }\n }\n\n private setupParticipantVideo(call: Call, participant: StreamVideoParticipant, container: HTMLElement) {\n const id = `video-${participant.sessionId}`;\n if (!document.getElementById(id)) {\n const videoEl = document.createElement('video');\n videoEl.id = id;\n videoEl.style.width = '100%';\n videoEl.style.maxWidth = '300px';\n videoEl.style.aspectRatio = '16/9';\n container.appendChild(videoEl);\n\n const unbind = call.bindVideoElement(videoEl, participant.sessionId, 'videoTrack');\n if (unbind) this.videoBindings.set(id, unbind);\n }\n }\n\n private setupParticipantAudio(call: Call, participant: StreamVideoParticipant, container: HTMLElement) {\n if (participant.isLocalParticipant) return;\n\n const id = `audio-${participant.sessionId}`;\n if (!document.getElementById(id)) {\n const audioEl = document.createElement('audio');\n audioEl.id = id;\n container.appendChild(audioEl);\n\n const unbind = call.bindAudioElement(audioEl, participant.sessionId);\n if (unbind) this.audioBindings.set(id, unbind);\n }\n }\n\n private callSessionStartedCallback = (event: AllClientEvents['call.session_started']) => {\n console.log('Call created (session started)', event);\n if (event.call && event.call.session && event.call.session.participants) {\n // Store the number of expected participants for this call\n const callCid = event.call.cid;\n const memberCount = event.call.session.participants.length;\n console.log(`Call ${callCid} created with ${memberCount} members`);\n this.callMembersExpected.set(callCid, memberCount);\n \n // Store call members in callStates\n this.callStates.set(callCid, {\n members: event.call.session.participants.map(p => ({ user_id: p.user?.id || '' })),\n participantResponses: new Map(),\n expectedMemberCount: memberCount,\n createdAt: new Date(),\n });\n \n // Start a timeout task that runs every second\n const timeoutTask = setInterval(() => this.checkCallTimeout(callCid), 1000);\n \n // Update the callState with the timeout task\n const callState = this.callStates.get(callCid);\n if (callState) {\n callState.timer = timeoutTask;\n this.callStates.set(callCid, callState);\n }\n }\n };\n\n private callRejectedCallback = (event: AllClientEvents['call.rejected']) => {\n console.log('Call rejected', event);\n if (event.user && event.user.id) {\n this.participantResponses.set(event.user.id, 'rejected');\n \n // Update the combined callStates map\n const callState = this.callStates.get(event.call_cid);\n if (callState) {\n callState.participantResponses.set(event.user.id, 'rejected');\n this.callStates.set(event.call_cid, callState);\n }\n \n this.notifyListeners('callEvent', { \n callId: event.call_cid, \n state: 'rejected',\n userId: event.user.id\n });\n \n this.checkAllParticipantsResponded();\n }\n };\n\n private callAcceptedCallback = (event: AllClientEvents['call.accepted']) => {\n console.log('Call accepted', event);\n if (event.user && event.user.id) {\n this.participantResponses.set(event.user.id, 'accepted');\n \n // Update the combined callStates map\n const callState = this.callStates.get(event.call_cid);\n if (callState) {\n callState.participantResponses.set(event.user.id, 'accepted');\n \n // If someone accepted, clear the timer as we don't need to check anymore\n if (callState.timer) {\n clearInterval(callState.timer);\n callState.timer = undefined;\n }\n \n this.callStates.set(event.call_cid, callState);\n }\n \n this.notifyListeners('callEvent', { \n callId: event.call_cid, \n state: 'accepted',\n userId: event.user.id\n });\n }\n };\n\n private callMissedCallback = (event: AllClientEvents['call.missed']) => {\n console.log('Call missed', event);\n if (event.user && event.user.id) {\n this.participantResponses.set(event.user.id, 'missed');\n \n // Update the combined callStates map\n const callState = this.callStates.get(event.call_cid);\n if (callState) {\n callState.participantResponses.set(event.user.id, 'missed');\n this.callStates.set(event.call_cid, callState);\n }\n \n this.notifyListeners('callEvent', { \n callId: event.call_cid, \n state: 'missed',\n userId: event.user.id\n });\n \n this.checkAllParticipantsResponded();\n }\n };\n \n // Add a combined map for call states, mirroring the iOS implementation\n private callStates: Map<string, {\n members: { user_id: string }[],\n participantResponses: Map<string, string>,\n expectedMemberCount: number,\n createdAt: Date,\n timer?: ReturnType<typeof setInterval>\n }> = new Map();\n \n private checkCallTimeout(callCid: string) {\n const callState = this.callStates.get(callCid);\n if (!callState) return;\n \n // Calculate time elapsed since call creation\n const now = new Date();\n const elapsedSeconds = (now.getTime() - callState.createdAt.getTime()) / 1000;\n \n // Check if 30 seconds have passed\n if (elapsedSeconds >= 30) {\n console.log(`Call ${callCid} has timed out after ${elapsedSeconds} seconds`);\n \n // Check if anyone has accepted\n const hasAccepted = Array.from(callState.participantResponses.values())\n .some(response => response === 'accepted');\n \n if (!hasAccepted) {\n console.log(`No one accepted call ${callCid}, marking all non-responders as missed`);\n \n // Mark all members who haven't responded as \"missed\"\n callState.members.forEach(member => {\n if (!callState.participantResponses.has(member.user_id)) {\n callState.participantResponses.set(member.user_id, 'missed');\n this.participantResponses.set(member.user_id, 'missed');\n \n this.notifyListeners('callEvent', { \n callId: callCid, \n state: 'missed',\n userId: member.user_id\n });\n }\n });\n \n // End the call\n if (this.currentCall && this.currentCall.cid === callCid) {\n this.currentCall.leave();\n }\n \n // Clear the timeout task\n if (callState.timer) {\n clearInterval(callState.timer);\n callState.timer = undefined;\n }\n \n // Remove from callStates\n this.callStates.delete(callCid);\n \n // Clean up\n this.cleanupCall();\n \n // Notify that the call has ended\n this.notifyListeners('callEvent', { \n callId: callCid, \n state: 'ended',\n reason: 'timeout'\n });\n }\n }\n }\n\n private checkAllParticipantsResponded() {\n if (!this.currentCall) return;\n \n const callCid = this.currentCall.cid;\n const totalParticipants = this.callMembersExpected.get(callCid);\n \n if (!totalParticipants) {\n console.log(`No expected participant count found for call: ${callCid}`);\n return;\n }\n \n console.log(`Total expected participants: ${totalParticipants}`);\n \n // Count rejections and misses\n let rejectedOrMissedCount = 0;\n this.participantResponses.forEach(response => {\n if (response === 'rejected' || response === 'missed') {\n rejectedOrMissedCount++;\n }\n });\n \n console.log(`Participants responded: ${this.participantResponses.size}/${totalParticipants}`);\n console.log(`Rejected or missed: ${rejectedOrMissedCount}`);\n \n const allResponded = this.participantResponses.size >= totalParticipants;\n const allRejectedOrMissed = allResponded && \n Array.from(this.participantResponses.values()).every(response => \n response === 'rejected' || response === 'missed'\n );\n \n // If all participants have rejected or missed the call\n if (allResponded && allRejectedOrMissed) {\n console.log('All participants have rejected or missed the call');\n \n // End the call\n this.currentCall.leave();\n \n // Clean up the timer if exists in callStates\n const callState = this.callStates.get(callCid);\n if (callState?.timer) {\n clearInterval(callState.timer);\n }\n \n // Remove from callStates\n this.callStates.delete(callCid);\n \n // Clear the responses\n this.participantResponses.clear();\n \n // Clean up\n this.cleanupCall();\n \n // Notify that the call has ended\n this.notifyListeners('callEvent', { \n callId: callCid, \n state: 'ended',\n reason: 'all_rejected_or_missed'\n });\n }\n }\n\n private cleanupCall() {\n // First cleanup the call listeners\n if (this.currentCall) {\n if (this.participantJoinedListener) {\n this.currentCall.off('participantJoined', this.participantJoinedListener);\n this.participantJoinedListener = undefined;\n }\n if (this.participantLeftListener) {\n this.currentCall.off('participantLeft', this.participantLeftListener);\n this.participantLeftListener = undefined;\n }\n this.callStateSubscription?.unsubscribe();\n }\n\n if (this.magicDivId) {\n const magicDiv = document.getElementById(this.magicDivId);\n if (magicDiv) {\n // Remove all video elements\n const videoElements = magicDiv.querySelectorAll('video');\n videoElements.forEach((video) => {\n const id = video.id;\n const unbind = this.videoBindings.get(id);\n if (unbind) {\n unbind();\n this.videoBindings.delete(id);\n }\n // Stop all tracks\n const tracks = (video as HTMLVideoElement).srcObject as MediaStream;\n if (tracks) {\n tracks.getTracks().forEach((track) => {\n track.stop();\n track.enabled = false;\n });\n video.srcObject = null;\n }\n video.remove();\n });\n\n // Remove all audio elements\n const audioElements = magicDiv.querySelectorAll('audio');\n audioElements.forEach((audio) => {\n const id = audio.id;\n const unbind = this.audioBindings.get(id);\n if (unbind) {\n unbind();\n this.audioBindings.delete(id);\n }\n // Stop all tracks\n const tracks = (audio as HTMLAudioElement).srcObject as MediaStream;\n if (tracks) {\n tracks.getTracks().forEach((track) => {\n track.stop();\n track.enabled = false;\n });\n audio.srcObject = null;\n }\n audio.remove();\n });\n\n // Clear the container\n while (magicDiv.firstChild) {\n magicDiv.removeChild(magicDiv.firstChild);\n }\n }\n }\n\n // Clear all bindings\n this.videoBindings.clear();\n this.audioBindings.clear();\n\n // Clear call references\n this.currentCall = undefined;\n this.incomingCall = undefined;\n }\n\n async login(options: LoginOptions): Promise<SuccessResponse> {\n this.client = StreamVideoClient.getOrCreateInstance({\n apiKey: options.apiKey,\n user: { id: options.userId, name: options.name, image: options.imageURL },\n token: options.token,\n });\n\n this.magicDivId = options.magicDivId;\n this.setupCallRingListener();\n\n return { success: true };\n }\n\n async logout(): Promise<SuccessResponse> {\n if (!this.client) {\n console.log('No client', this.client);\n throw new Error('Client not initialized');\n }\n\n // Cleanup subscription\n this.callStateSubscription?.unsubscribe();\n this.callStateSubscription = undefined;\n\n await this.client.disconnectUser();\n this.client = undefined;\n this.currentCall = undefined;\n return { success: true };\n }\n\n async call(options: CallOptions): Promise<SuccessResponse> {\n if (!this.client) {\n console.log('No client', this.client);\n throw new Error('Client not initialized - Please login first');\n }\n\n const call = this.client.call(options.type || 'default', crypto.randomUUID());\n const members = options.userIds.map((userId) => ({ user_id: userId }));\n if (this.client.streamClient.userID && !options.userIds.includes(this.client.streamClient.userID)) {\n members.push({ user_id: this.client.streamClient.userID });\n }\n await call.getOrCreate({ data: { members } });\n \n // Store the expected member count for this call\n // -1, because we don't count the caller themselves\n this.callMembersExpected.set(call.cid, members.length);\n console.log(`Setting expected members for call ${call.cid}: ${members.length}`);\n \n this.currentCall = call;\n if (options.ring) {\n this.outgoingCall = call.cid;\n await call.ring();\n }\n\n await call.join();\n return { success: true };\n }\n\n async endCall(): Promise<SuccessResponse> {\n if (!this.currentCall) {\n console.log('No active call', this.currentCall);\n throw new Error('No active call');\n }\n\n await this.currentCall.leave();\n this.currentCall = undefined;\n this.cleanupCall();\n\n return { success: true };\n }\n\n async setMicrophoneEnabled(options: { enabled: boolean }): Promise<SuccessResponse> {\n if (!this.currentCall) {\n console.log('No active call', this.currentCall);\n throw new Error('No active call');\n }\n\n if (options.enabled) {\n await this.currentCall.microphone.enable();\n } else {\n await this.currentCall.microphone.disable();\n }\n\n return { success: true };\n }\n\n async setCameraEnabled(options: { enabled: boolean }): Promise<SuccessResponse> {\n if (!this.currentCall) {\n console.log('No active call', this.currentCall);\n throw new Error('No active call');\n }\n\n if (options.enabled) {\n await this.currentCall.camera.enable();\n } else {\n await this.currentCall.camera.disable();\n }\n\n return { success: true };\n }\n\n async acceptCall(): Promise<SuccessResponse> {\n if (!this.incomingCall || !this.client) {\n console.log('No incoming call to accept', this.incomingCall, this.client);\n throw new Error('No incoming call to accept');\n }\n console.log('Accepting call', this.incomingCall);\n const call = this.client.call(this.incomingCall.type, this.incomingCall.id);\n this.currentCall = call;\n console.log('Joining call', call);\n await call.accept();\n await call.join();\n console.log('Joined call', call);\n this.notifyListeners('callEvent', { callId: call.id, state: CallingState.JOINED });\n this.setupParticipantListener();\n return { success: true };\n }\n\n async rejectCall(): Promise<SuccessResponse> {\n if (!this.incomingCall || !this.client) {\n console.log('No incoming call to reject', this.incomingCall, this.client);\n throw new Error('No incoming call to reject');\n }\n console.log('Rejecting call', this.incomingCall);\n const call: Call = this.client.call(this.incomingCall.type, this.incomingCall.id);\n console.log('Leaving call', call);\n await call.reject();\n this.incomingCall = undefined;\n console.log('Rejected call', call);\n this.notifyListeners('callEvent', { callId: call.id, state: CallingState.LEFT });\n this.cleanupCall();\n return { success: true };\n }\n\n async isCameraEnabled(): Promise<CameraEnabledResponse> {\n if (!this.currentCall) {\n console.log('No active call', this.currentCall);\n throw new Error('No active call');\n }\n const enabled = await this.currentCall.camera.enabled;\n return { enabled };\n }\n}\n"]}
@@ -12,6 +12,8 @@ class StreamCallWeb extends core.WebPlugin {
12
12
  super(...arguments);
13
13
  this.videoBindings = new Map();
14
14
  this.audioBindings = new Map();
15
+ this.participantResponses = new Map();
16
+ this.callMembersExpected = new Map();
15
17
  this.ringCallback = (event) => {
16
18
  var _a, _b;
17
19
  console.log('Call ringing', event, this.currentCall);
@@ -19,7 +21,10 @@ class StreamCallWeb extends core.WebPlugin {
19
21
  if (!this.currentCall) {
20
22
  console.log('Creating new call', event.call.id);
21
23
  this.currentCall = (_a = this.client) === null || _a === void 0 ? void 0 : _a.call(event.call.type, event.call.id);
24
+ // this.currentActiveCallId = this.currentCall?.cid;
22
25
  this.notifyListeners('callEvent', { callId: event.call.id, state: videoClient.CallingState.RINGING });
26
+ // Clear previous responses when a new call starts
27
+ this.participantResponses.clear();
23
28
  }
24
29
  if (this.currentCall) {
25
30
  console.log('Call found', this.currentCall.id);
@@ -28,6 +33,7 @@ class StreamCallWeb extends core.WebPlugin {
28
33
  console.log('Call state', s);
29
34
  if (s === videoClient.CallingState.JOINED) {
30
35
  this.setupParticipantListener();
36
+ this.setupCallEventListeners();
31
37
  }
32
38
  else if (s === videoClient.CallingState.LEFT || s === videoClient.CallingState.RECONNECTING_FAILED) {
33
39
  this.cleanupCall();
@@ -41,11 +47,110 @@ class StreamCallWeb extends core.WebPlugin {
41
47
  });
42
48
  }
43
49
  };
50
+ this.callSessionStartedCallback = (event) => {
51
+ console.log('Call created (session started)', event);
52
+ if (event.call && event.call.session && event.call.session.participants) {
53
+ // Store the number of expected participants for this call
54
+ const callCid = event.call.cid;
55
+ const memberCount = event.call.session.participants.length;
56
+ console.log(`Call ${callCid} created with ${memberCount} members`);
57
+ this.callMembersExpected.set(callCid, memberCount);
58
+ // Store call members in callStates
59
+ this.callStates.set(callCid, {
60
+ members: event.call.session.participants.map(p => { var _a; return ({ user_id: ((_a = p.user) === null || _a === void 0 ? void 0 : _a.id) || '' }); }),
61
+ participantResponses: new Map(),
62
+ expectedMemberCount: memberCount,
63
+ createdAt: new Date(),
64
+ });
65
+ // Start a timeout task that runs every second
66
+ const timeoutTask = setInterval(() => this.checkCallTimeout(callCid), 1000);
67
+ // Update the callState with the timeout task
68
+ const callState = this.callStates.get(callCid);
69
+ if (callState) {
70
+ callState.timer = timeoutTask;
71
+ this.callStates.set(callCid, callState);
72
+ }
73
+ }
74
+ };
75
+ this.callRejectedCallback = (event) => {
76
+ console.log('Call rejected', event);
77
+ if (event.user && event.user.id) {
78
+ this.participantResponses.set(event.user.id, 'rejected');
79
+ // Update the combined callStates map
80
+ const callState = this.callStates.get(event.call_cid);
81
+ if (callState) {
82
+ callState.participantResponses.set(event.user.id, 'rejected');
83
+ this.callStates.set(event.call_cid, callState);
84
+ }
85
+ this.notifyListeners('callEvent', {
86
+ callId: event.call_cid,
87
+ state: 'rejected',
88
+ userId: event.user.id
89
+ });
90
+ this.checkAllParticipantsResponded();
91
+ }
92
+ };
93
+ this.callAcceptedCallback = (event) => {
94
+ console.log('Call accepted', event);
95
+ if (event.user && event.user.id) {
96
+ this.participantResponses.set(event.user.id, 'accepted');
97
+ // Update the combined callStates map
98
+ const callState = this.callStates.get(event.call_cid);
99
+ if (callState) {
100
+ callState.participantResponses.set(event.user.id, 'accepted');
101
+ // If someone accepted, clear the timer as we don't need to check anymore
102
+ if (callState.timer) {
103
+ clearInterval(callState.timer);
104
+ callState.timer = undefined;
105
+ }
106
+ this.callStates.set(event.call_cid, callState);
107
+ }
108
+ this.notifyListeners('callEvent', {
109
+ callId: event.call_cid,
110
+ state: 'accepted',
111
+ userId: event.user.id
112
+ });
113
+ }
114
+ };
115
+ this.callMissedCallback = (event) => {
116
+ console.log('Call missed', event);
117
+ if (event.user && event.user.id) {
118
+ this.participantResponses.set(event.user.id, 'missed');
119
+ // Update the combined callStates map
120
+ const callState = this.callStates.get(event.call_cid);
121
+ if (callState) {
122
+ callState.participantResponses.set(event.user.id, 'missed');
123
+ this.callStates.set(event.call_cid, callState);
124
+ }
125
+ this.notifyListeners('callEvent', {
126
+ callId: event.call_cid,
127
+ state: 'missed',
128
+ userId: event.user.id
129
+ });
130
+ this.checkAllParticipantsResponded();
131
+ }
132
+ };
133
+ // Add a combined map for call states, mirroring the iOS implementation
134
+ this.callStates = new Map();
44
135
  }
136
+ // private currentActiveCallId?: string;
45
137
  setupCallRingListener() {
46
- var _a, _b;
138
+ var _a, _b, _c, _d;
47
139
  (_a = this.client) === null || _a === void 0 ? void 0 : _a.off('call.ring', this.ringCallback);
48
- (_b = this.client) === null || _b === void 0 ? void 0 : _b.on('call.ring', this.ringCallback);
140
+ (_b = this.client) === null || _b === void 0 ? void 0 : _b.off('call.session_started', this.callSessionStartedCallback);
141
+ (_c = this.client) === null || _c === void 0 ? void 0 : _c.on('call.ring', this.ringCallback);
142
+ (_d = this.client) === null || _d === void 0 ? void 0 : _d.on('call.session_started', this.callSessionStartedCallback);
143
+ }
144
+ setupCallEventListeners() {
145
+ var _a, _b, _c, _d, _e, _f;
146
+ // Clear previous listeners if any
147
+ (_a = this.client) === null || _a === void 0 ? void 0 : _a.off('call.rejected', this.callRejectedCallback);
148
+ (_b = this.client) === null || _b === void 0 ? void 0 : _b.off('call.accepted', this.callAcceptedCallback);
149
+ (_c = this.client) === null || _c === void 0 ? void 0 : _c.off('call.missed', this.callMissedCallback);
150
+ // Register event listeners
151
+ (_d = this.client) === null || _d === void 0 ? void 0 : _d.on('call.rejected', this.callRejectedCallback);
152
+ (_e = this.client) === null || _e === void 0 ? void 0 : _e.on('call.accepted', this.callAcceptedCallback);
153
+ (_f = this.client) === null || _f === void 0 ? void 0 : _f.on('call.missed', this.callMissedCallback);
49
154
  }
50
155
  setupParticipantListener() {
51
156
  // Subscribe to participant changes
@@ -62,6 +167,7 @@ class StreamCallWeb extends core.WebPlugin {
62
167
  }
63
168
  };
64
169
  this.participantLeftListener = (event) => {
170
+ var _a, _b;
65
171
  if (this.magicDivId && event.participant) {
66
172
  const videoId = `video-${event.participant.sessionId}`;
67
173
  const audioId = `audio-${event.participant.sessionId}`;
@@ -77,10 +183,9 @@ class StreamCallWeb extends core.WebPlugin {
77
183
  if (tracks) {
78
184
  tracks.getTracks().forEach((track) => {
79
185
  track.stop();
80
- track.enabled = false;
81
186
  });
82
- videoEl.srcObject = null;
83
187
  }
188
+ videoEl.srcObject = null;
84
189
  videoEl.remove();
85
190
  }
86
191
  // Remove audio element
@@ -95,13 +200,44 @@ class StreamCallWeb extends core.WebPlugin {
95
200
  if (tracks) {
96
201
  tracks.getTracks().forEach((track) => {
97
202
  track.stop();
98
- track.enabled = false;
99
203
  });
100
- audioEl.srcObject = null;
101
204
  }
205
+ audioEl.srcObject = null;
102
206
  audioEl.remove();
103
207
  }
104
208
  }
209
+ // Check if we're the only participant left in the call
210
+ if (this.currentCall && this.currentCall.state.session) {
211
+ // Get the remaining participants count (we need to subtract 1 as we haven't been removed from the list yet)
212
+ const remainingParticipants = this.currentCall.state.session.participants.length - 1;
213
+ // If we're the only one left, end the call
214
+ if (remainingParticipants <= 1) {
215
+ console.log(`We are left solo in a call. Ending. cID: ${this.currentCall.cid}`);
216
+ // End the call
217
+ this.currentCall.leave();
218
+ // Clean up resources
219
+ const callCid = this.currentCall.cid;
220
+ // Invalidate and remove timer
221
+ const callState = (_a = this.callStates) === null || _a === void 0 ? void 0 : _a.get(callCid);
222
+ if (callState === null || callState === void 0 ? void 0 : callState.timer) {
223
+ clearInterval(callState.timer);
224
+ }
225
+ // Remove from callStates
226
+ (_b = this.callStates) === null || _b === void 0 ? void 0 : _b.delete(callCid);
227
+ // Reset the current call
228
+ this.currentCall = undefined;
229
+ // this.currentActiveCallId = undefined;
230
+ // Clean up
231
+ this.cleanupCall();
232
+ console.log(`Cleaned up resources for ended call: ${callCid}`);
233
+ // Notify that the call has ended
234
+ this.notifyListeners('callEvent', {
235
+ callId: callCid,
236
+ state: 'left',
237
+ reason: 'participant_left'
238
+ });
239
+ }
240
+ }
105
241
  };
106
242
  this.currentCall.on('participantJoined', this.participantJoinedListener);
107
243
  this.currentCall.on('participantLeft', this.participantLeftListener);
@@ -146,6 +282,101 @@ class StreamCallWeb extends core.WebPlugin {
146
282
  this.audioBindings.set(id, unbind);
147
283
  }
148
284
  }
285
+ checkCallTimeout(callCid) {
286
+ const callState = this.callStates.get(callCid);
287
+ if (!callState)
288
+ return;
289
+ // Calculate time elapsed since call creation
290
+ const now = new Date();
291
+ const elapsedSeconds = (now.getTime() - callState.createdAt.getTime()) / 1000;
292
+ // Check if 30 seconds have passed
293
+ if (elapsedSeconds >= 30) {
294
+ console.log(`Call ${callCid} has timed out after ${elapsedSeconds} seconds`);
295
+ // Check if anyone has accepted
296
+ const hasAccepted = Array.from(callState.participantResponses.values())
297
+ .some(response => response === 'accepted');
298
+ if (!hasAccepted) {
299
+ console.log(`No one accepted call ${callCid}, marking all non-responders as missed`);
300
+ // Mark all members who haven't responded as "missed"
301
+ callState.members.forEach(member => {
302
+ if (!callState.participantResponses.has(member.user_id)) {
303
+ callState.participantResponses.set(member.user_id, 'missed');
304
+ this.participantResponses.set(member.user_id, 'missed');
305
+ this.notifyListeners('callEvent', {
306
+ callId: callCid,
307
+ state: 'missed',
308
+ userId: member.user_id
309
+ });
310
+ }
311
+ });
312
+ // End the call
313
+ if (this.currentCall && this.currentCall.cid === callCid) {
314
+ this.currentCall.leave();
315
+ }
316
+ // Clear the timeout task
317
+ if (callState.timer) {
318
+ clearInterval(callState.timer);
319
+ callState.timer = undefined;
320
+ }
321
+ // Remove from callStates
322
+ this.callStates.delete(callCid);
323
+ // Clean up
324
+ this.cleanupCall();
325
+ // Notify that the call has ended
326
+ this.notifyListeners('callEvent', {
327
+ callId: callCid,
328
+ state: 'ended',
329
+ reason: 'timeout'
330
+ });
331
+ }
332
+ }
333
+ }
334
+ checkAllParticipantsResponded() {
335
+ if (!this.currentCall)
336
+ return;
337
+ const callCid = this.currentCall.cid;
338
+ const totalParticipants = this.callMembersExpected.get(callCid);
339
+ if (!totalParticipants) {
340
+ console.log(`No expected participant count found for call: ${callCid}`);
341
+ return;
342
+ }
343
+ console.log(`Total expected participants: ${totalParticipants}`);
344
+ // Count rejections and misses
345
+ let rejectedOrMissedCount = 0;
346
+ this.participantResponses.forEach(response => {
347
+ if (response === 'rejected' || response === 'missed') {
348
+ rejectedOrMissedCount++;
349
+ }
350
+ });
351
+ console.log(`Participants responded: ${this.participantResponses.size}/${totalParticipants}`);
352
+ console.log(`Rejected or missed: ${rejectedOrMissedCount}`);
353
+ const allResponded = this.participantResponses.size >= totalParticipants;
354
+ const allRejectedOrMissed = allResponded &&
355
+ Array.from(this.participantResponses.values()).every(response => response === 'rejected' || response === 'missed');
356
+ // If all participants have rejected or missed the call
357
+ if (allResponded && allRejectedOrMissed) {
358
+ console.log('All participants have rejected or missed the call');
359
+ // End the call
360
+ this.currentCall.leave();
361
+ // Clean up the timer if exists in callStates
362
+ const callState = this.callStates.get(callCid);
363
+ if (callState === null || callState === void 0 ? void 0 : callState.timer) {
364
+ clearInterval(callState.timer);
365
+ }
366
+ // Remove from callStates
367
+ this.callStates.delete(callCid);
368
+ // Clear the responses
369
+ this.participantResponses.clear();
370
+ // Clean up
371
+ this.cleanupCall();
372
+ // Notify that the call has ended
373
+ this.notifyListeners('callEvent', {
374
+ callId: callCid,
375
+ state: 'ended',
376
+ reason: 'all_rejected_or_missed'
377
+ });
378
+ }
379
+ }
149
380
  cleanupCall() {
150
381
  var _a;
151
382
  // First cleanup the call listeners
@@ -247,10 +478,14 @@ class StreamCallWeb extends core.WebPlugin {
247
478
  }
248
479
  const call = this.client.call(options.type || 'default', crypto.randomUUID());
249
480
  const members = options.userIds.map((userId) => ({ user_id: userId }));
250
- if (this.client.streamClient.userID && options.userIds.includes(this.client.streamClient.userID)) {
481
+ if (this.client.streamClient.userID && !options.userIds.includes(this.client.streamClient.userID)) {
251
482
  members.push({ user_id: this.client.streamClient.userID });
252
483
  }
253
484
  await call.getOrCreate({ data: { members } });
485
+ // Store the expected member count for this call
486
+ // -1, because we don't count the caller themselves
487
+ this.callMembersExpected.set(call.cid, members.length);
488
+ console.log(`Setting expected members for call ${call.cid}: ${members.length}`);
254
489
  this.currentCall = call;
255
490
  if (options.ring) {
256
491
  this.outgoingCall = call.cid;
@@ -319,7 +554,7 @@ class StreamCallWeb extends core.WebPlugin {
319
554
  console.log('Rejecting call', this.incomingCall);
320
555
  const call = this.client.call(this.incomingCall.type, this.incomingCall.id);
321
556
  console.log('Leaving call', call);
322
- await call.leave();
557
+ await call.reject();
323
558
  this.incomingCall = undefined;
324
559
  console.log('Rejected call', call);
325
560
  this.notifyListeners('callEvent', { callId: call.id, state: videoClient.CallingState.LEFT });