@capgo/capacitor-stream-call 0.0.43 → 0.0.51
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.
- package/README.md +110 -106
- package/android/src/main/java/ee/forgr/capacitor/streamcall/StreamCallPlugin.kt +184 -33
- package/dist/docs.json +124 -0
- package/dist/esm/definitions.d.ts +34 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +3 -0
- package/dist/esm/web.js +87 -4
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +87 -4
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +87 -4
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/StreamCallPlugin/StreamCallPlugin.swift +268 -24
- package/package.json +1 -1
package/dist/docs.json
CHANGED
|
@@ -408,6 +408,29 @@
|
|
|
408
408
|
"SuccessResponse"
|
|
409
409
|
],
|
|
410
410
|
"slug": "switchcamera"
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
"name": "getCallInfo",
|
|
414
|
+
"signature": "(options: { callId: string; }) => Promise<CallEvent>",
|
|
415
|
+
"parameters": [
|
|
416
|
+
{
|
|
417
|
+
"name": "options",
|
|
418
|
+
"docs": "- Options containing the call ID",
|
|
419
|
+
"type": "{ callId: string; }"
|
|
420
|
+
}
|
|
421
|
+
],
|
|
422
|
+
"returns": "Promise<CallEvent>",
|
|
423
|
+
"tags": [
|
|
424
|
+
{
|
|
425
|
+
"name": "param",
|
|
426
|
+
"text": "options - Options containing the call ID"
|
|
427
|
+
}
|
|
428
|
+
],
|
|
429
|
+
"docs": "Get detailed information about an active call including caller details",
|
|
430
|
+
"complexTypes": [
|
|
431
|
+
"CallEvent"
|
|
432
|
+
],
|
|
433
|
+
"slug": "getcallinfo"
|
|
411
434
|
}
|
|
412
435
|
],
|
|
413
436
|
"properties": []
|
|
@@ -618,6 +641,14 @@
|
|
|
618
641
|
{
|
|
619
642
|
"text": "{string} [reason] - Reason for the call state change",
|
|
620
643
|
"name": "property"
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
"text": "{CallMember} [caller] - Information about the caller (for incoming calls)",
|
|
647
|
+
"name": "property"
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
"text": "{CallMember[]} [members] - List of call members",
|
|
651
|
+
"name": "property"
|
|
621
652
|
}
|
|
622
653
|
],
|
|
623
654
|
"methods": [],
|
|
@@ -651,6 +682,24 @@
|
|
|
651
682
|
"docs": "Reason for the call state change, if applicable",
|
|
652
683
|
"complexTypes": [],
|
|
653
684
|
"type": "string | undefined"
|
|
685
|
+
},
|
|
686
|
+
{
|
|
687
|
+
"name": "caller",
|
|
688
|
+
"tags": [],
|
|
689
|
+
"docs": "Information about the caller (for incoming calls)",
|
|
690
|
+
"complexTypes": [
|
|
691
|
+
"CallMember"
|
|
692
|
+
],
|
|
693
|
+
"type": "CallMember"
|
|
694
|
+
},
|
|
695
|
+
{
|
|
696
|
+
"name": "members",
|
|
697
|
+
"tags": [],
|
|
698
|
+
"docs": "List of call members",
|
|
699
|
+
"complexTypes": [
|
|
700
|
+
"CallMember"
|
|
701
|
+
],
|
|
702
|
+
"type": "CallMember[] | undefined"
|
|
654
703
|
}
|
|
655
704
|
]
|
|
656
705
|
},
|
|
@@ -1134,6 +1183,68 @@
|
|
|
1134
1183
|
}
|
|
1135
1184
|
]
|
|
1136
1185
|
},
|
|
1186
|
+
{
|
|
1187
|
+
"name": "CallMember",
|
|
1188
|
+
"slug": "callmember",
|
|
1189
|
+
"docs": "",
|
|
1190
|
+
"tags": [
|
|
1191
|
+
{
|
|
1192
|
+
"text": "CallMember",
|
|
1193
|
+
"name": "interface"
|
|
1194
|
+
},
|
|
1195
|
+
{
|
|
1196
|
+
"text": "Information about a call member/participant",
|
|
1197
|
+
"name": "description"
|
|
1198
|
+
},
|
|
1199
|
+
{
|
|
1200
|
+
"text": "{string} userId - User ID of the member",
|
|
1201
|
+
"name": "property"
|
|
1202
|
+
},
|
|
1203
|
+
{
|
|
1204
|
+
"text": "{string} [name] - Display name of the user",
|
|
1205
|
+
"name": "property"
|
|
1206
|
+
},
|
|
1207
|
+
{
|
|
1208
|
+
"text": "{string} [imageURL] - Profile image URL of the user",
|
|
1209
|
+
"name": "property"
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
"text": "{string} [role] - Role of the user in the call",
|
|
1213
|
+
"name": "property"
|
|
1214
|
+
}
|
|
1215
|
+
],
|
|
1216
|
+
"methods": [],
|
|
1217
|
+
"properties": [
|
|
1218
|
+
{
|
|
1219
|
+
"name": "userId",
|
|
1220
|
+
"tags": [],
|
|
1221
|
+
"docs": "User ID of the member",
|
|
1222
|
+
"complexTypes": [],
|
|
1223
|
+
"type": "string"
|
|
1224
|
+
},
|
|
1225
|
+
{
|
|
1226
|
+
"name": "name",
|
|
1227
|
+
"tags": [],
|
|
1228
|
+
"docs": "Display name of the user",
|
|
1229
|
+
"complexTypes": [],
|
|
1230
|
+
"type": "string | undefined"
|
|
1231
|
+
},
|
|
1232
|
+
{
|
|
1233
|
+
"name": "imageURL",
|
|
1234
|
+
"tags": [],
|
|
1235
|
+
"docs": "Profile image URL of the user",
|
|
1236
|
+
"complexTypes": [],
|
|
1237
|
+
"type": "string | undefined"
|
|
1238
|
+
},
|
|
1239
|
+
{
|
|
1240
|
+
"name": "role",
|
|
1241
|
+
"tags": [],
|
|
1242
|
+
"docs": "Role of the user in the call",
|
|
1243
|
+
"complexTypes": [],
|
|
1244
|
+
"type": "string | undefined"
|
|
1245
|
+
}
|
|
1246
|
+
]
|
|
1247
|
+
},
|
|
1137
1248
|
{
|
|
1138
1249
|
"name": "IncomingCallPayload",
|
|
1139
1250
|
"slug": "incomingcallpayload",
|
|
@@ -1154,6 +1265,10 @@
|
|
|
1154
1265
|
{
|
|
1155
1266
|
"text": "{string} type - Always \"incoming\" for this event",
|
|
1156
1267
|
"name": "property"
|
|
1268
|
+
},
|
|
1269
|
+
{
|
|
1270
|
+
"text": "{CallMember} [caller] - Information about the caller",
|
|
1271
|
+
"name": "property"
|
|
1157
1272
|
}
|
|
1158
1273
|
],
|
|
1159
1274
|
"methods": [],
|
|
@@ -1171,6 +1286,15 @@
|
|
|
1171
1286
|
"docs": "Event type (currently always \"incoming\")",
|
|
1172
1287
|
"complexTypes": [],
|
|
1173
1288
|
"type": "'incoming'"
|
|
1289
|
+
},
|
|
1290
|
+
{
|
|
1291
|
+
"name": "caller",
|
|
1292
|
+
"tags": [],
|
|
1293
|
+
"docs": "Information about the caller",
|
|
1294
|
+
"complexTypes": [
|
|
1295
|
+
"CallMember"
|
|
1296
|
+
],
|
|
1297
|
+
"type": "CallMember"
|
|
1174
1298
|
}
|
|
1175
1299
|
]
|
|
1176
1300
|
},
|
|
@@ -36,6 +36,24 @@ export type CallState = 'idle' | 'ringing' | 'joining' | 'reconnecting' | 'joine
|
|
|
36
36
|
* - `development`: For testing ONLY. All permissions enabled, backstage disabled. **Not recommended for production.**
|
|
37
37
|
*/
|
|
38
38
|
export type CallType = 'default' | 'audio_room' | 'livestream' | 'development';
|
|
39
|
+
/**
|
|
40
|
+
* @interface CallMember
|
|
41
|
+
* @description Information about a call member/participant
|
|
42
|
+
* @property {string} userId - User ID of the member
|
|
43
|
+
* @property {string} [name] - Display name of the user
|
|
44
|
+
* @property {string} [imageURL] - Profile image URL of the user
|
|
45
|
+
* @property {string} [role] - Role of the user in the call
|
|
46
|
+
*/
|
|
47
|
+
export interface CallMember {
|
|
48
|
+
/** User ID of the member */
|
|
49
|
+
userId: string;
|
|
50
|
+
/** Display name of the user */
|
|
51
|
+
name?: string;
|
|
52
|
+
/** Profile image URL of the user */
|
|
53
|
+
imageURL?: string;
|
|
54
|
+
/** Role of the user in the call */
|
|
55
|
+
role?: string;
|
|
56
|
+
}
|
|
39
57
|
/**
|
|
40
58
|
* @interface CallEvent
|
|
41
59
|
* @description Event emitted when call state changes
|
|
@@ -43,6 +61,8 @@ export type CallType = 'default' | 'audio_room' | 'livestream' | 'development';
|
|
|
43
61
|
* @property {CallState} state - Current state of the call
|
|
44
62
|
* @property {string} [userId] - User ID of the participant who triggered the event
|
|
45
63
|
* @property {string} [reason] - Reason for the call state change
|
|
64
|
+
* @property {CallMember} [caller] - Information about the caller (for incoming calls)
|
|
65
|
+
* @property {CallMember[]} [members] - List of call members
|
|
46
66
|
*/
|
|
47
67
|
export interface CallEvent {
|
|
48
68
|
/** ID of the call */
|
|
@@ -53,6 +73,10 @@ export interface CallEvent {
|
|
|
53
73
|
userId?: string;
|
|
54
74
|
/** Reason for the call state change, if applicable */
|
|
55
75
|
reason?: string;
|
|
76
|
+
/** Information about the caller (for incoming calls) */
|
|
77
|
+
caller?: CallMember;
|
|
78
|
+
/** List of call members */
|
|
79
|
+
members?: CallMember[];
|
|
56
80
|
}
|
|
57
81
|
export interface CameraEnabledResponse {
|
|
58
82
|
enabled: boolean;
|
|
@@ -225,16 +249,26 @@ export interface StreamCallPlugin {
|
|
|
225
249
|
switchCamera(options: {
|
|
226
250
|
camera: 'front' | 'back';
|
|
227
251
|
}): Promise<SuccessResponse>;
|
|
252
|
+
/**
|
|
253
|
+
* Get detailed information about an active call including caller details
|
|
254
|
+
* @param options - Options containing the call ID
|
|
255
|
+
*/
|
|
256
|
+
getCallInfo(options: {
|
|
257
|
+
callId: string;
|
|
258
|
+
}): Promise<CallEvent>;
|
|
228
259
|
}
|
|
229
260
|
/**
|
|
230
261
|
* @interface IncomingCallPayload
|
|
231
262
|
* @description Payload delivered with "incomingCall" event (Android lock-screen).
|
|
232
263
|
* @property {string} cid - Call CID (type:id)
|
|
233
264
|
* @property {string} type - Always "incoming" for this event
|
|
265
|
+
* @property {CallMember} [caller] - Information about the caller
|
|
234
266
|
*/
|
|
235
267
|
export interface IncomingCallPayload {
|
|
236
268
|
/** Full call CID (e.g. default:123) */
|
|
237
269
|
cid: string;
|
|
238
270
|
/** Event type (currently always "incoming") */
|
|
239
271
|
type: 'incoming';
|
|
272
|
+
/** Information about the caller */
|
|
273
|
+
caller?: CallMember;
|
|
240
274
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * @interface LoginOptions\n * @description Configuration options for logging into the Stream Video service\n * @property {string} token - Stream Video API token for authentication\n * @property {string} userId - Unique identifier for the current user\n * @property {string} name - Display name for the current user\n * @property {string} [imageURL] - Avatar URL for the current user\n * @property {string} apiKey - Stream Video API key for your application\n * @property {string} [magicDivId] - DOM element ID where video will be rendered\n */\nexport interface LoginOptions {\n /** Stream Video API token */\n token: string;\n /** User ID for the current user */\n userId: string;\n /** Display name for the current user */\n name: string;\n /** Optional avatar URL for the current user */\n imageURL?: string;\n /** Stream Video API key */\n apiKey: string;\n /** ID of the HTML element where the video will be rendered */\n magicDivId?: string;\n}\n\n/**\n * @typedef CallState\n * @description Represents all possible call states from API and UI\n */\nexport type CallState =\n // User-facing states\n | 'idle'\n | 'ringing'\n | 'joining'\n | 'reconnecting'\n | 'joined'\n | 'leaving'\n | 'left'\n // Event-specific states\n | 'created'\n | 'session_started'\n | 'rejected'\n | 'missed'\n | 'accepted'\n | 'ended'\n | 'unknown';\n\n/**\n * @typedef CallType\n * @description Represents the pre-defined types of a call.\n * - `default`: Simple 1-1 or group video calling with sensible defaults. Video/audio enabled, backstage disabled. Admins/hosts have elevated permissions.\n * - `audio_room`: For audio-only spaces (like Clubhouse). Backstage enabled (requires `goLive`), pre-configured permissions for requesting to speak.\n * - `livestream`: For one-to-many streaming. Backstage enabled (requires `goLive`), access granted to all authenticated users.\n * - `development`: For testing ONLY. All permissions enabled, backstage disabled. **Not recommended for production.**\n */\nexport type CallType = 'default' | 'audio_room' | 'livestream' | 'development';\n\n/**\n * @interface CallEvent\n * @description Event emitted when call state changes\n * @property {string} callId - Unique identifier of the call\n * @property {CallState} state - Current state of the call\n * @property {string} [userId] - User ID of the participant who triggered the event\n * @property {string} [reason] - Reason for the call state change\n */\nexport interface CallEvent {\n /** ID of the call */\n callId: string;\n /** Current state of the call */\n state: CallState;\n /** User ID of the participant in the call who triggered the event */\n userId?: string;\n /** Reason for the call state change, if applicable */\n reason?: string;\n}\n\nexport interface CameraEnabledResponse {\n enabled: boolean;\n}\n\n/**\n * @interface SuccessResponse\n * @description Standard response indicating operation success/failure\n * @property {boolean} success - Whether the operation succeeded\n */\nexport interface SuccessResponse {\n /** Whether the operation was successful */\n success: boolean;\n}\n\n/**\n * @interface CallOptions\n * @description Options for initiating a video call\n * @property {string[]} userIds - IDs of the users to call\n * @property {CallType} [type=default] - Type of call\n * @property {boolean} [ring=true] - Whether to send ring notification\n * @property {string} [team] - Team name to call\n */\nexport interface CallOptions {\n /** User ID of the person to call */\n userIds: string[];\n /** Type of call, defaults to 'default' */\n type?: CallType;\n /** Whether to ring the other user, defaults to true */\n ring?: boolean;\n /** Team name to call */\n team?: string;\n}\n\n/**\n * @interface StreamCallPlugin\n * @description Capacitor plugin for Stream Video calling functionality\n */\nexport interface StreamCallPlugin {\n /**\n * Login to Stream Video service\n * @param {LoginOptions} options - Login configuration\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.login({\n * token: 'your-token',\n * userId: 'user-123',\n * name: 'John Doe',\n * apiKey: 'your-api-key'\n * });\n */\n login(options: LoginOptions): Promise<SuccessResponse>;\n\n /**\n * Logout from Stream Video service\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.logout();\n */\n logout(): Promise<SuccessResponse>;\n\n /**\n * Initiate a call to another user\n * @param {CallOptions} options - Call configuration\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.call({\n * userId: 'user-456',\n * type: 'video',\n * ring: true\n * });\n */\n call(options: CallOptions): Promise<SuccessResponse>;\n\n /**\n * End the current call\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.endCall();\n */\n endCall(): Promise<SuccessResponse>;\n\n /**\n * Enable or disable microphone\n * @param {{ enabled: boolean }} options - Microphone state\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.setMicrophoneEnabled({ enabled: false });\n */\n setMicrophoneEnabled(options: { enabled: boolean }): Promise<SuccessResponse>;\n\n /**\n * Enable or disable camera\n * @param {{ enabled: boolean }} options - Camera state\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.setCameraEnabled({ enabled: false });\n */\n setCameraEnabled(options: { enabled: boolean }): Promise<SuccessResponse>;\n\n /**\n * Add listener for call events\n * @param {'callEvent'} eventName - Name of the event to listen for\n * @param {(event: CallEvent) => void} listenerFunc - Callback function\n * @returns {Promise<{ remove: () => Promise<void> }>} Function to remove listener\n * @example\n * const listener = await StreamCall.addListener('callEvent', (event) => {\n * console.log(`Call ${event.callId} is now ${event.state}`);\n * });\n */\n addListener(\n eventName: 'callEvent',\n listenerFunc: (event: CallEvent) => void,\n ): Promise<{ remove: () => Promise<void> }>;\n\n /**\n * Listen for lock-screen incoming call (Android only).\n * Fired when the app is shown by full-screen intent before user interaction.\n */\n addListener(\n eventName: 'incomingCall',\n listenerFunc: (event: IncomingCallPayload) => void,\n ): Promise<{ remove: () => Promise<void> }>;\n\n /**\n * Remove all event listeners\n * @returns {Promise<void>}\n * @example\n * await StreamCall.removeAllListeners();\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Accept an incoming call\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.acceptCall();\n */\n acceptCall(): Promise<SuccessResponse>;\n\n /**\n * Reject an incoming call\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.rejectCall();\n */\n rejectCall(): Promise<SuccessResponse>;\n\n /**\n * Check if camera is enabled\n * @returns {Promise<CameraEnabledResponse>} Camera enabled status\n * @example\n * const isCameraEnabled = await StreamCall.isCameraEnabled();\n * console.log(isCameraEnabled);\n */\n isCameraEnabled(): Promise<CameraEnabledResponse>;\n\n /**\n * Get the current call status\n * @returns {Promise<CallEvent>} Current call status as a CallEvent\n * @example\n * const callStatus = await StreamCall.getCallStatus();\n * console.log(callStatus);\n */\n getCallStatus(): Promise<CallEvent>;\n\n /**\n * Set speakerphone on\n * @param {{ name: string }} options - Speakerphone name\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.setSpeaker({ name: 'speaker' });\n */\n setSpeaker(options: { name: string }): Promise<SuccessResponse>;\n\n /**\n * Switch camera\n * @param {{ camera: 'front' | 'back' }} options - Camera to switch to\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.switchCamera({ camera: 'back' });\n */\n switchCamera(options: { camera: 'front' | 'back' }): Promise<SuccessResponse>;\n}\n\n/**\n * @interface IncomingCallPayload\n * @description Payload delivered with \"incomingCall\" event (Android lock-screen).\n * @property {string} cid - Call CID (type:id)\n * @property {string} type - Always \"incoming\" for this event\n */\nexport interface IncomingCallPayload {\n /** Full call CID (e.g. default:123) */\n cid: string;\n /** Event type (currently always \"incoming\") */\n type: 'incoming';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * @interface LoginOptions\n * @description Configuration options for logging into the Stream Video service\n * @property {string} token - Stream Video API token for authentication\n * @property {string} userId - Unique identifier for the current user\n * @property {string} name - Display name for the current user\n * @property {string} [imageURL] - Avatar URL for the current user\n * @property {string} apiKey - Stream Video API key for your application\n * @property {string} [magicDivId] - DOM element ID where video will be rendered\n */\nexport interface LoginOptions {\n /** Stream Video API token */\n token: string;\n /** User ID for the current user */\n userId: string;\n /** Display name for the current user */\n name: string;\n /** Optional avatar URL for the current user */\n imageURL?: string;\n /** Stream Video API key */\n apiKey: string;\n /** ID of the HTML element where the video will be rendered */\n magicDivId?: string;\n}\n\n/**\n * @typedef CallState\n * @description Represents all possible call states from API and UI\n */\nexport type CallState =\n // User-facing states\n | 'idle'\n | 'ringing'\n | 'joining'\n | 'reconnecting'\n | 'joined'\n | 'leaving'\n | 'left'\n // Event-specific states\n | 'created'\n | 'session_started'\n | 'rejected'\n | 'missed'\n | 'accepted'\n | 'ended'\n | 'unknown';\n\n/**\n * @typedef CallType\n * @description Represents the pre-defined types of a call.\n * - `default`: Simple 1-1 or group video calling with sensible defaults. Video/audio enabled, backstage disabled. Admins/hosts have elevated permissions.\n * - `audio_room`: For audio-only spaces (like Clubhouse). Backstage enabled (requires `goLive`), pre-configured permissions for requesting to speak.\n * - `livestream`: For one-to-many streaming. Backstage enabled (requires `goLive`), access granted to all authenticated users.\n * - `development`: For testing ONLY. All permissions enabled, backstage disabled. **Not recommended for production.**\n */\nexport type CallType = 'default' | 'audio_room' | 'livestream' | 'development';\n\n/**\n * @interface CallMember\n * @description Information about a call member/participant\n * @property {string} userId - User ID of the member\n * @property {string} [name] - Display name of the user\n * @property {string} [imageURL] - Profile image URL of the user\n * @property {string} [role] - Role of the user in the call\n */\nexport interface CallMember {\n /** User ID of the member */\n userId: string;\n /** Display name of the user */\n name?: string;\n /** Profile image URL of the user */\n imageURL?: string;\n /** Role of the user in the call */\n role?: string;\n}\n\n/**\n * @interface CallEvent\n * @description Event emitted when call state changes\n * @property {string} callId - Unique identifier of the call\n * @property {CallState} state - Current state of the call\n * @property {string} [userId] - User ID of the participant who triggered the event\n * @property {string} [reason] - Reason for the call state change\n * @property {CallMember} [caller] - Information about the caller (for incoming calls)\n * @property {CallMember[]} [members] - List of call members\n */\nexport interface CallEvent {\n /** ID of the call */\n callId: string;\n /** Current state of the call */\n state: CallState;\n /** User ID of the participant in the call who triggered the event */\n userId?: string;\n /** Reason for the call state change, if applicable */\n reason?: string;\n /** Information about the caller (for incoming calls) */\n caller?: CallMember;\n /** List of call members */\n members?: CallMember[];\n}\n\nexport interface CameraEnabledResponse {\n enabled: boolean;\n}\n\n/**\n * @interface SuccessResponse\n * @description Standard response indicating operation success/failure\n * @property {boolean} success - Whether the operation succeeded\n */\nexport interface SuccessResponse {\n /** Whether the operation was successful */\n success: boolean;\n}\n\n/**\n * @interface CallOptions\n * @description Options for initiating a video call\n * @property {string[]} userIds - IDs of the users to call\n * @property {CallType} [type=default] - Type of call\n * @property {boolean} [ring=true] - Whether to send ring notification\n * @property {string} [team] - Team name to call\n */\nexport interface CallOptions {\n /** User ID of the person to call */\n userIds: string[];\n /** Type of call, defaults to 'default' */\n type?: CallType;\n /** Whether to ring the other user, defaults to true */\n ring?: boolean;\n /** Team name to call */\n team?: string;\n}\n\n/**\n * @interface StreamCallPlugin\n * @description Capacitor plugin for Stream Video calling functionality\n */\nexport interface StreamCallPlugin {\n /**\n * Login to Stream Video service\n * @param {LoginOptions} options - Login configuration\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.login({\n * token: 'your-token',\n * userId: 'user-123',\n * name: 'John Doe',\n * apiKey: 'your-api-key'\n * });\n */\n login(options: LoginOptions): Promise<SuccessResponse>;\n\n /**\n * Logout from Stream Video service\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.logout();\n */\n logout(): Promise<SuccessResponse>;\n\n /**\n * Initiate a call to another user\n * @param {CallOptions} options - Call configuration\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.call({\n * userId: 'user-456',\n * type: 'video',\n * ring: true\n * });\n */\n call(options: CallOptions): Promise<SuccessResponse>;\n\n /**\n * End the current call\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.endCall();\n */\n endCall(): Promise<SuccessResponse>;\n\n /**\n * Enable or disable microphone\n * @param {{ enabled: boolean }} options - Microphone state\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.setMicrophoneEnabled({ enabled: false });\n */\n setMicrophoneEnabled(options: { enabled: boolean }): Promise<SuccessResponse>;\n\n /**\n * Enable or disable camera\n * @param {{ enabled: boolean }} options - Camera state\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.setCameraEnabled({ enabled: false });\n */\n setCameraEnabled(options: { enabled: boolean }): Promise<SuccessResponse>;\n\n /**\n * Add listener for call events\n * @param {'callEvent'} eventName - Name of the event to listen for\n * @param {(event: CallEvent) => void} listenerFunc - Callback function\n * @returns {Promise<{ remove: () => Promise<void> }>} Function to remove listener\n * @example\n * const listener = await StreamCall.addListener('callEvent', (event) => {\n * console.log(`Call ${event.callId} is now ${event.state}`);\n * });\n */\n addListener(\n eventName: 'callEvent',\n listenerFunc: (event: CallEvent) => void,\n ): Promise<{ remove: () => Promise<void> }>;\n\n /**\n * Listen for lock-screen incoming call (Android only).\n * Fired when the app is shown by full-screen intent before user interaction.\n */\n addListener(\n eventName: 'incomingCall',\n listenerFunc: (event: IncomingCallPayload) => void,\n ): Promise<{ remove: () => Promise<void> }>;\n\n /**\n * Remove all event listeners\n * @returns {Promise<void>}\n * @example\n * await StreamCall.removeAllListeners();\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Accept an incoming call\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.acceptCall();\n */\n acceptCall(): Promise<SuccessResponse>;\n\n /**\n * Reject an incoming call\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.rejectCall();\n */\n rejectCall(): Promise<SuccessResponse>;\n\n /**\n * Check if camera is enabled\n * @returns {Promise<CameraEnabledResponse>} Camera enabled status\n * @example\n * const isCameraEnabled = await StreamCall.isCameraEnabled();\n * console.log(isCameraEnabled);\n */\n isCameraEnabled(): Promise<CameraEnabledResponse>;\n\n /**\n * Get the current call status\n * @returns {Promise<CallEvent>} Current call status as a CallEvent\n * @example\n * const callStatus = await StreamCall.getCallStatus();\n * console.log(callStatus);\n */\n getCallStatus(): Promise<CallEvent>;\n\n /**\n * Set speakerphone on\n * @param {{ name: string }} options - Speakerphone name\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.setSpeaker({ name: 'speaker' });\n */\n setSpeaker(options: { name: string }): Promise<SuccessResponse>;\n\n /**\n * Switch camera\n * @param {{ camera: 'front' | 'back' }} options - Camera to switch to\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.switchCamera({ camera: 'back' });\n */\n switchCamera(options: { camera: 'front' | 'back' }): Promise<SuccessResponse>;\n\n /**\n * Get detailed information about an active call including caller details\n * @param options - Options containing the call ID\n */\n getCallInfo(options: { callId: string }): Promise<CallEvent>;\n}\n\n/**\n * @interface IncomingCallPayload\n * @description Payload delivered with \"incomingCall\" event (Android lock-screen).\n * @property {string} cid - Call CID (type:id)\n * @property {string} type - Always \"incoming\" for this event\n * @property {CallMember} [caller] - Information about the caller\n */\nexport interface IncomingCallPayload {\n /** Full call CID (e.g. default:123) */\n cid: string;\n /** Event type (currently always \"incoming\") */\n type: 'incoming';\n /** Information about the caller */\n caller?: CallMember;\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -46,5 +46,8 @@ export declare class StreamCallWeb extends WebPlugin implements StreamCallPlugin
|
|
|
46
46
|
acceptCall(): Promise<SuccessResponse>;
|
|
47
47
|
rejectCall(): Promise<SuccessResponse>;
|
|
48
48
|
isCameraEnabled(): Promise<CameraEnabledResponse>;
|
|
49
|
+
getCallInfo(options: {
|
|
50
|
+
callId: string;
|
|
51
|
+
}): Promise<CallEvent>;
|
|
49
52
|
getCallStatus(): Promise<CallEvent>;
|
|
50
53
|
}
|
package/dist/esm/web.js
CHANGED
|
@@ -8,20 +8,34 @@ export class StreamCallWeb extends WebPlugin {
|
|
|
8
8
|
this.participantResponses = new Map();
|
|
9
9
|
this.callMembersExpected = new Map();
|
|
10
10
|
this.ringCallback = (event) => {
|
|
11
|
-
var _a, _b;
|
|
11
|
+
var _a, _b, _c;
|
|
12
12
|
console.log('Call ringing', event, this.currentCall);
|
|
13
13
|
this.incomingCall = event.call;
|
|
14
|
+
// Extract caller information
|
|
15
|
+
let caller;
|
|
16
|
+
if ((_a = event.call) === null || _a === void 0 ? void 0 : _a.created_by) {
|
|
17
|
+
caller = {
|
|
18
|
+
userId: event.call.created_by.id,
|
|
19
|
+
name: event.call.created_by.name,
|
|
20
|
+
imageURL: event.call.created_by.image,
|
|
21
|
+
role: event.call.created_by.role,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
14
24
|
if (!this.currentCall) {
|
|
15
25
|
console.log('Creating new call', event.call.id);
|
|
16
|
-
this.currentCall = (
|
|
26
|
+
this.currentCall = (_b = this.client) === null || _b === void 0 ? void 0 : _b.call(event.call.type, event.call.id);
|
|
17
27
|
// this.currentActiveCallId = this.currentCall?.cid;
|
|
18
|
-
this.notifyListeners('callEvent', {
|
|
28
|
+
this.notifyListeners('callEvent', {
|
|
29
|
+
callId: event.call.id,
|
|
30
|
+
state: CallingState.RINGING,
|
|
31
|
+
caller,
|
|
32
|
+
});
|
|
19
33
|
// Clear previous responses when a new call starts
|
|
20
34
|
this.participantResponses.clear();
|
|
21
35
|
}
|
|
22
36
|
if (this.currentCall) {
|
|
23
37
|
console.log('Call found', this.currentCall.id);
|
|
24
|
-
this.callStateSubscription = (
|
|
38
|
+
this.callStateSubscription = (_c = this.currentCall) === null || _c === void 0 ? void 0 : _c.state.callingState$.subscribe((s) => {
|
|
25
39
|
var _a;
|
|
26
40
|
console.log('Call state', s);
|
|
27
41
|
if (s === CallingState.JOINED) {
|
|
@@ -586,6 +600,75 @@ export class StreamCallWeb extends WebPlugin {
|
|
|
586
600
|
const enabled = await this.currentCall.camera.enabled;
|
|
587
601
|
return { enabled };
|
|
588
602
|
}
|
|
603
|
+
async getCallInfo(options) {
|
|
604
|
+
var _a;
|
|
605
|
+
if (!this.currentCall) {
|
|
606
|
+
throw new Error('No active call');
|
|
607
|
+
}
|
|
608
|
+
if (this.currentCall.id !== options.callId) {
|
|
609
|
+
throw new Error('Call ID does not match active call');
|
|
610
|
+
}
|
|
611
|
+
const callingState = this.currentCall.state.callingState;
|
|
612
|
+
let state;
|
|
613
|
+
switch (callingState) {
|
|
614
|
+
case CallingState.IDLE:
|
|
615
|
+
state = 'idle';
|
|
616
|
+
break;
|
|
617
|
+
case CallingState.RINGING:
|
|
618
|
+
state = 'ringing';
|
|
619
|
+
break;
|
|
620
|
+
case CallingState.JOINING:
|
|
621
|
+
state = 'joining';
|
|
622
|
+
break;
|
|
623
|
+
case CallingState.RECONNECTING:
|
|
624
|
+
state = 'reconnecting';
|
|
625
|
+
break;
|
|
626
|
+
case CallingState.JOINED:
|
|
627
|
+
state = 'joined';
|
|
628
|
+
break;
|
|
629
|
+
case CallingState.LEFT:
|
|
630
|
+
state = 'left';
|
|
631
|
+
break;
|
|
632
|
+
default:
|
|
633
|
+
state = 'unknown';
|
|
634
|
+
}
|
|
635
|
+
// Try to get caller information from the call
|
|
636
|
+
let caller;
|
|
637
|
+
let members = [];
|
|
638
|
+
try {
|
|
639
|
+
// Get call details
|
|
640
|
+
const callDetails = await this.currentCall.get();
|
|
641
|
+
if ((_a = callDetails === null || callDetails === void 0 ? void 0 : callDetails.call) === null || _a === void 0 ? void 0 : _a.created_by) {
|
|
642
|
+
caller = {
|
|
643
|
+
userId: callDetails.call.created_by.id,
|
|
644
|
+
name: callDetails.call.created_by.name,
|
|
645
|
+
imageURL: callDetails.call.created_by.image,
|
|
646
|
+
role: callDetails.call.created_by.role,
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
// Get current participants
|
|
650
|
+
if (this.currentCall.state.participants) {
|
|
651
|
+
members = this.currentCall.state.participants.map((participant) => {
|
|
652
|
+
var _a;
|
|
653
|
+
return ({
|
|
654
|
+
userId: participant.userId,
|
|
655
|
+
name: participant.name,
|
|
656
|
+
imageURL: participant.image,
|
|
657
|
+
role: (_a = participant.roles) === null || _a === void 0 ? void 0 : _a[0],
|
|
658
|
+
});
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
catch (error) {
|
|
663
|
+
console.warn('Failed to get call details:', error);
|
|
664
|
+
}
|
|
665
|
+
return {
|
|
666
|
+
callId: this.currentCall.id,
|
|
667
|
+
state,
|
|
668
|
+
caller,
|
|
669
|
+
members,
|
|
670
|
+
};
|
|
671
|
+
}
|
|
589
672
|
async getCallStatus() {
|
|
590
673
|
if (!this.currentCall) {
|
|
591
674
|
throw new Error('No active call');
|