@cometchat/calls-sdk-react-native 5.0.0-beta.1 → 5.0.0-beta.3
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/cometchat-calls-sdk-react-native.podspec +20 -0
- package/dist/index.d.mts +164 -43
- package/dist/index.d.ts +164 -43
- package/dist/index.js +275 -85
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +275 -85
- package/dist/index.mjs.map +1 -1
- package/ios/Audio/CometChatAudioSession+Private.h +24 -0
- package/ios/Audio/CometChatAudioSession.h +26 -0
- package/ios/Audio/CometChatAudioSession.m +35 -0
- package/ios/Modules/AudioMode.m +384 -0
- package/ios/Modules/KeepAwake.h +4 -0
- package/ios/Modules/KeepAwake.m +29 -0
- package/package.json +10 -3
package/dist/index.mjs
CHANGED
|
@@ -44,17 +44,24 @@ var EventBus = class {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
subscribe(actionType, listener) {
|
|
47
|
+
subscribe(actionType, listener, options) {
|
|
48
|
+
if (options?.signal?.aborted) {
|
|
49
|
+
return () => {};
|
|
50
|
+
}
|
|
48
51
|
if (!this.actionListenersMap.get(actionType)) {
|
|
49
52
|
this.actionListenersMap.set(actionType, []);
|
|
50
53
|
}
|
|
51
54
|
this.actionListenersMap.get(actionType)?.push(listener);
|
|
52
|
-
|
|
55
|
+
const unsubscribe = () => {
|
|
53
56
|
const listenersList = this.actionListenersMap.get(actionType);
|
|
54
57
|
if (listenersList) {
|
|
55
58
|
this.actionListenersMap.set(actionType, listenersList.filter((l) => l !== listener));
|
|
56
59
|
}
|
|
57
60
|
};
|
|
61
|
+
if (options?.signal) {
|
|
62
|
+
options.signal.addEventListener("abort", unsubscribe, { once: true });
|
|
63
|
+
}
|
|
64
|
+
return unsubscribe;
|
|
58
65
|
}
|
|
59
66
|
};
|
|
60
67
|
const eventBus = new EventBus();
|
|
@@ -408,9 +415,9 @@ function getDefaultDevice(devices) {
|
|
|
408
415
|
|
|
409
416
|
//#endregion
|
|
410
417
|
//#region calls-sdk-core/utils/try-catch.ts
|
|
411
|
-
async function tryCatch(promise) {
|
|
418
|
+
async function tryCatch(promise, timeoutMs) {
|
|
412
419
|
try {
|
|
413
|
-
const data = await promise;
|
|
420
|
+
const data = timeoutMs != null ? await Promise.race([promise, new Promise((_, reject) => setTimeout(() => reject(new Error("timeout")), timeoutMs))]) : await promise;
|
|
414
421
|
return {
|
|
415
422
|
data,
|
|
416
423
|
error: null
|
|
@@ -454,76 +461,106 @@ function debounce(func, delay) {
|
|
|
454
461
|
//#endregion
|
|
455
462
|
//#region calls-sdk-core/utils/session-methods-core.ts
|
|
456
463
|
var SessionMethodsCore = class {
|
|
464
|
+
/**
|
|
465
|
+
* Mutes the local user's audio during the call.
|
|
466
|
+
*/
|
|
457
467
|
static muteAudio() {
|
|
458
468
|
muteAudioTrack();
|
|
459
469
|
}
|
|
470
|
+
/**
|
|
471
|
+
* Unmutes the local user's audio during the call.
|
|
472
|
+
*/
|
|
460
473
|
static unmuteAudio() {
|
|
461
474
|
unMuteAudioTrack();
|
|
462
475
|
}
|
|
476
|
+
/**
|
|
477
|
+
* Pauses the local user's video stream.
|
|
478
|
+
*/
|
|
463
479
|
static pauseVideo() {
|
|
464
480
|
pauseVideoTrack();
|
|
465
481
|
}
|
|
482
|
+
/**
|
|
483
|
+
* Resumes the local user's video stream.
|
|
484
|
+
*/
|
|
466
485
|
static resumeVideo() {
|
|
467
486
|
resumeVideoTrack();
|
|
468
487
|
}
|
|
488
|
+
/**
|
|
489
|
+
* Local user leaves the current session.
|
|
490
|
+
*/
|
|
469
491
|
static leaveSession() {
|
|
470
492
|
leaveSession();
|
|
471
493
|
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
static stopScreenSharing() {
|
|
476
|
-
stopScreenSharing();
|
|
477
|
-
}
|
|
494
|
+
/**
|
|
495
|
+
* Raises the user's virtual hand in the call.
|
|
496
|
+
*/
|
|
478
497
|
static raiseHand() {
|
|
479
498
|
raisedHandLocal();
|
|
480
499
|
}
|
|
500
|
+
/**
|
|
501
|
+
* Lowers the user's virtual hand in the call.
|
|
502
|
+
*/
|
|
481
503
|
static lowerHand() {
|
|
482
504
|
lowerHandLocal();
|
|
483
505
|
}
|
|
506
|
+
/**
|
|
507
|
+
* Switches between the front and rear camera.
|
|
508
|
+
*/
|
|
484
509
|
static switchCamera() {
|
|
485
510
|
switchCamera();
|
|
486
511
|
}
|
|
512
|
+
/**
|
|
513
|
+
* Sets the layout type for the call.
|
|
514
|
+
* @param layout - The type of layout to set (tile, sidebar or spotlight).
|
|
515
|
+
*/
|
|
487
516
|
static setLayout(layout$1) {
|
|
488
517
|
setLayout(layout$1);
|
|
489
518
|
}
|
|
519
|
+
/**
|
|
520
|
+
* Starts recording the call.
|
|
521
|
+
*/
|
|
490
522
|
static startRecording() {}
|
|
523
|
+
/**
|
|
524
|
+
* Stops the ongoing call recording.
|
|
525
|
+
*/
|
|
491
526
|
static stopRecording() {}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
}
|
|
527
|
+
/**
|
|
528
|
+
* Pins a participant's video to focus on them.
|
|
529
|
+
* @param participantId - The ID of the participant to pin.
|
|
530
|
+
* @param type - The type of the participant.
|
|
531
|
+
*/
|
|
498
532
|
static pinParticipant(participantId, type) {
|
|
499
533
|
pinParticipant(participantId, type);
|
|
500
534
|
}
|
|
535
|
+
/**
|
|
536
|
+
* Unpins a participant's video.
|
|
537
|
+
*/
|
|
501
538
|
static unpinParticipant() {
|
|
502
539
|
unpinParticipant();
|
|
503
540
|
}
|
|
541
|
+
/**
|
|
542
|
+
* Mutes the audio of a specific participant.
|
|
543
|
+
* @param participantId - The ID of the participant to mute.
|
|
544
|
+
*/
|
|
504
545
|
static muteParticipant(participantId) {
|
|
505
546
|
muteParticipant(participantId);
|
|
506
547
|
}
|
|
507
|
-
static pauseParticipantVideo(participantId) {
|
|
508
|
-
pauseParticipantVideo(participantId);
|
|
509
|
-
}
|
|
510
|
-
static setChatButtonUnreadCount(count) {
|
|
511
|
-
setChatButtonUnreadCount(count);
|
|
512
|
-
}
|
|
513
548
|
/**
|
|
514
|
-
*
|
|
549
|
+
* Pauses the video stream of a specific participant.
|
|
550
|
+
* @param participantId - The ID of the participant whose video to pause.
|
|
515
551
|
*/
|
|
516
|
-
static
|
|
517
|
-
|
|
552
|
+
static pauseParticipantVideo(participantId) {
|
|
553
|
+
pauseParticipantVideo(participantId);
|
|
518
554
|
}
|
|
519
555
|
/**
|
|
520
|
-
*
|
|
556
|
+
* Sets the unread message count displayed on the chat button.
|
|
557
|
+
* @param count - The number of unread messages.
|
|
521
558
|
*/
|
|
522
|
-
static
|
|
523
|
-
|
|
559
|
+
static setChatButtonUnreadCount(count) {
|
|
560
|
+
setChatButtonUnreadCount(count);
|
|
524
561
|
}
|
|
525
562
|
/**
|
|
526
|
-
* @deprecated switchToVideoCall is deprecated and not supported
|
|
563
|
+
* @deprecated switchToVideoCall is deprecated and not supported.
|
|
527
564
|
*/
|
|
528
565
|
static switchToVideoCall() {
|
|
529
566
|
console.error("switchToVideoCall method deprecated and not supported.");
|
|
@@ -613,6 +650,27 @@ async function createLocalTrack(type, deviceId = null, cameraFacing = CAMERA_FAC
|
|
|
613
650
|
}
|
|
614
651
|
}
|
|
615
652
|
}
|
|
653
|
+
function createLocalTracks() {
|
|
654
|
+
const enableCompanionMode = useConfigStore.getState().enableCompanionMode;
|
|
655
|
+
if (!enableCompanionMode) {
|
|
656
|
+
const audioInputDeviceId = useConfigStore.getState().audioInputDeviceId ?? useBaseStore.getState().audioInputDevice?.deviceId;
|
|
657
|
+
createLocalTrack("audio", audioInputDeviceId);
|
|
658
|
+
}
|
|
659
|
+
const sessionType = useConfigStore.getState().sessionType;
|
|
660
|
+
if (sessionType === SESSION_TYPE.VIDEO) {
|
|
661
|
+
const videoInputDeviceIdP1 = useConfigStore.getState().videoInputDeviceId;
|
|
662
|
+
const videoInputDeviceIdP2 = useBaseStore.getState().videoInputDevice?.deviceId;
|
|
663
|
+
const initialCameraFacingP1 = useConfigStore.getState().initialCameraFacing;
|
|
664
|
+
const initialCameraFacingP2 = useBaseStore.getState().cameraFacing;
|
|
665
|
+
if (videoInputDeviceIdP1) {
|
|
666
|
+
createLocalTrack("video", videoInputDeviceIdP1);
|
|
667
|
+
} else if (initialCameraFacingP1) {
|
|
668
|
+
createLocalTrack("video", null, initialCameraFacingP2);
|
|
669
|
+
} else {
|
|
670
|
+
createLocalTrack("video", videoInputDeviceIdP2, initialCameraFacingP2);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
616
674
|
function updateAudioInputDevice(deviceId) {
|
|
617
675
|
const audioInputDevices = useBaseStore.getState().audioInputDevices.filter((device) => device.deviceId !== "");
|
|
618
676
|
if (audioInputDevices.length > 0) {
|
|
@@ -812,7 +870,6 @@ const initialState$7 = {
|
|
|
812
870
|
hideLeaveSessionButton: false,
|
|
813
871
|
hideToggleAudioButton: false,
|
|
814
872
|
hideParticipantListButton: false,
|
|
815
|
-
hideSwitchLayoutButton: false,
|
|
816
873
|
hideChatButton: true,
|
|
817
874
|
hideToggleVideoButton: false,
|
|
818
875
|
hideScreenSharingButton: false,
|
|
@@ -829,7 +886,9 @@ const initialState$7 = {
|
|
|
829
886
|
idleTimeoutPeriodAfterPrompt: 18e4,
|
|
830
887
|
enableSpotlightDrag: true,
|
|
831
888
|
enableSpotlightSwap: true,
|
|
832
|
-
showFrameRate: false
|
|
889
|
+
showFrameRate: false,
|
|
890
|
+
enableCompanionMode: false,
|
|
891
|
+
isPeerCall: false
|
|
833
892
|
};
|
|
834
893
|
const useConfigStore = create()(subscribeWithSelector(combine(initialState$7, (set) => ({ reset: () => set(initialState$7) }))));
|
|
835
894
|
const setConfig = (config) => {
|
|
@@ -1107,13 +1166,22 @@ const useConferenceStore = create()(subscribeWithSelector(combine(initialState$5
|
|
|
1107
1166
|
leaveConference: async () => {
|
|
1108
1167
|
const conference = useConferenceStore.getState().conference;
|
|
1109
1168
|
if (conference) {
|
|
1110
|
-
const { error } = await tryCatch(conference.leave());
|
|
1169
|
+
const { error } = await tryCatch(conference.leave(), 500);
|
|
1111
1170
|
if (error) {
|
|
1112
1171
|
console.warn("Error leaving conference:", error);
|
|
1113
1172
|
eventBus.publish({ type: EVENT_LISTENER_METHODS.SessionStatusListener.onSessionLeft });
|
|
1114
1173
|
}
|
|
1115
1174
|
}
|
|
1116
1175
|
},
|
|
1176
|
+
endConference: async () => {
|
|
1177
|
+
const conference = useConferenceStore.getState().conference;
|
|
1178
|
+
if (conference) {
|
|
1179
|
+
const { error } = await tryCatch(conference.end());
|
|
1180
|
+
if (error) {
|
|
1181
|
+
console.warn("Error ending conference:", error);
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
},
|
|
1117
1185
|
stopRecording: async () => {
|
|
1118
1186
|
const conference = useConferenceStore.getState().conference;
|
|
1119
1187
|
if (conference) {
|
|
@@ -1957,12 +2025,34 @@ const useConnectionStore = create()(subscribeWithSelector(combine(initialState$2
|
|
|
1957
2025
|
},
|
|
1958
2026
|
reset: () => set(initialState$2)
|
|
1959
2027
|
}))));
|
|
2028
|
+
function waitForConnection() {
|
|
2029
|
+
const { connectionStatus } = useConnectionStore.getState();
|
|
2030
|
+
if (connectionStatus === "connected") return Promise.resolve();
|
|
2031
|
+
return new Promise((resolve, reject) => {
|
|
2032
|
+
const timeout = setTimeout(() => {
|
|
2033
|
+
unsub();
|
|
2034
|
+
reject(new Error("Connection timed out after 3 seconds"));
|
|
2035
|
+
}, 3e3);
|
|
2036
|
+
const unsub = useConnectionStore.subscribe((s) => s.connectionStatus, (status) => {
|
|
2037
|
+
if (status === "connected") {
|
|
2038
|
+
clearTimeout(timeout);
|
|
2039
|
+
unsub();
|
|
2040
|
+
resolve();
|
|
2041
|
+
} else if (status === "error") {
|
|
2042
|
+
clearTimeout(timeout);
|
|
2043
|
+
unsub();
|
|
2044
|
+
reject(useConnectionStore.getState().error);
|
|
2045
|
+
}
|
|
2046
|
+
});
|
|
2047
|
+
});
|
|
2048
|
+
}
|
|
1960
2049
|
|
|
1961
2050
|
//#endregion
|
|
1962
2051
|
//#region calls-sdk-core/store/utils/hooks.ts
|
|
1963
2052
|
const useHideMuteAudioButton = () => {
|
|
1964
2053
|
const hideMuteAudioButton = useConfigStore((state) => state.hideToggleAudioButton);
|
|
1965
|
-
|
|
2054
|
+
const enableCompanionMode = useConfigStore((state) => state.enableCompanionMode);
|
|
2055
|
+
return hideMuteAudioButton || enableCompanionMode;
|
|
1966
2056
|
};
|
|
1967
2057
|
const useHideToggleVideoButton = () => {
|
|
1968
2058
|
const hideToggleVideoButton = useConfigStore((state) => state.hideToggleVideoButton);
|
|
@@ -2280,8 +2370,13 @@ var ConferenceListener = class {
|
|
|
2280
2370
|
track.removeAllListeners(JitsiMeetJS.events.track.NO_DATA_FROM_SOURCE);
|
|
2281
2371
|
}
|
|
2282
2372
|
onConferenceJoinInProgress() {}
|
|
2283
|
-
onConferenceFailed(
|
|
2284
|
-
console.
|
|
2373
|
+
onConferenceFailed(errorName, error, message) {
|
|
2374
|
+
console.log();
|
|
2375
|
+
if (errorName === JitsiMeetJS.errors.conference.CONFERENCE_DESTROYED) {
|
|
2376
|
+
leaveSession({ forceLeave: true });
|
|
2377
|
+
return;
|
|
2378
|
+
}
|
|
2379
|
+
console.error("Conference failed:", errorName, error, message);
|
|
2285
2380
|
useConferenceStore.setState({
|
|
2286
2381
|
conferenceStatus: "error",
|
|
2287
2382
|
conferenceJoined: false,
|
|
@@ -2481,17 +2576,23 @@ function addConferenceListeners(conference) {
|
|
|
2481
2576
|
}
|
|
2482
2577
|
});
|
|
2483
2578
|
}
|
|
2484
|
-
async function
|
|
2579
|
+
async function _createConference() {
|
|
2580
|
+
const sessionId = useConfigStore.getState().sessionId;
|
|
2581
|
+
const connection = useConnectionStore.getState().connection;
|
|
2485
2582
|
if (!connection) {
|
|
2486
2583
|
throw new Error("No connection available");
|
|
2487
2584
|
}
|
|
2585
|
+
const connectionStatus = useConnectionStore.getState().connectionStatus;
|
|
2586
|
+
if (connectionStatus !== "connected") {
|
|
2587
|
+
await waitForConnection();
|
|
2588
|
+
}
|
|
2488
2589
|
const existingConference = useConferenceStore.getState().conference;
|
|
2489
2590
|
if (existingConference) {
|
|
2490
2591
|
console.log("Conference already exists, skipping creation");
|
|
2491
2592
|
return;
|
|
2492
2593
|
}
|
|
2493
2594
|
const connectionConfig = useConnectionStore.getState().connectionConfig;
|
|
2494
|
-
const conference = connection.initJitsiConference(
|
|
2595
|
+
const conference = connection.initJitsiConference(sessionId, connectionConfig);
|
|
2495
2596
|
const localAudioTrack = getLocalTrack(MEDIA_TYPE.AUDIO)?.originalTrack;
|
|
2496
2597
|
const localVideoTrack = getLocalTrack(MEDIA_TYPE.VIDEO)?.originalTrack;
|
|
2497
2598
|
if (localAudioTrack) {
|
|
@@ -2506,6 +2607,20 @@ async function createConference(connection, roomName) {
|
|
|
2506
2607
|
conference.setDisplayName(useParticipantStore.getState().localParticipant.name);
|
|
2507
2608
|
conference.join();
|
|
2508
2609
|
}
|
|
2610
|
+
async function createConference() {
|
|
2611
|
+
const conference = useConferenceStore.getState().conference;
|
|
2612
|
+
if (!conference) {
|
|
2613
|
+
const result = await tryCatch(_createConference());
|
|
2614
|
+
if (result.error) {
|
|
2615
|
+
console.error("Error creating conference", result.error);
|
|
2616
|
+
useConferenceStore.setState({
|
|
2617
|
+
conferenceStatus: "error",
|
|
2618
|
+
conferenceJoined: false,
|
|
2619
|
+
conferenceError: result.error.message
|
|
2620
|
+
});
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2623
|
+
}
|
|
2509
2624
|
function muteParticipant(participantId) {
|
|
2510
2625
|
const conference = useConferenceStore.getState().conference;
|
|
2511
2626
|
conference?.muteParticipant(participantId, "audio");
|
|
@@ -2517,7 +2632,12 @@ function pauseParticipantVideo(participantId) {
|
|
|
2517
2632
|
|
|
2518
2633
|
//#endregion
|
|
2519
2634
|
//#region calls-sdk-core/handlers/connection.ts
|
|
2520
|
-
function connect(
|
|
2635
|
+
async function connect(autoJoinConference = true) {
|
|
2636
|
+
const existingConnection = useConnectionStore.getState().connection;
|
|
2637
|
+
if (existingConnection) {
|
|
2638
|
+
createConference();
|
|
2639
|
+
return;
|
|
2640
|
+
}
|
|
2521
2641
|
const options = useConnectionStore.getState().connectionConfig;
|
|
2522
2642
|
const jwt = useConnectionStore.getState().jwt;
|
|
2523
2643
|
const iAmRecorder = useConfigStore.getState().iAmRecorder;
|
|
@@ -2533,15 +2653,8 @@ function connect(roomName) {
|
|
|
2533
2653
|
async function onConnectionEstablished() {
|
|
2534
2654
|
useConnectionStore.getState().connectionEstablished(connection);
|
|
2535
2655
|
eventBus.publish({ type: INTERNAL_EVENTS.onConnectionEstablished });
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
console.error("Error creating conference", result.error);
|
|
2539
|
-
useConferenceStore.setState({
|
|
2540
|
-
conferenceStatus: "error",
|
|
2541
|
-
conferenceJoined: false,
|
|
2542
|
-
conferenceError: result.error.message
|
|
2543
|
-
});
|
|
2544
|
-
}
|
|
2656
|
+
if (!autoJoinConference) return;
|
|
2657
|
+
createConference();
|
|
2545
2658
|
}
|
|
2546
2659
|
function onConnectionFailed(err, message, ...args) {
|
|
2547
2660
|
unsubscribe();
|
|
@@ -2747,6 +2860,7 @@ function initializeLib() {
|
|
|
2747
2860
|
let isSessionStarted = false;
|
|
2748
2861
|
let reconnectTimeoutId = null;
|
|
2749
2862
|
const RECONNECT_DEBOUNCE_DELAY = 3e3;
|
|
2863
|
+
initializeLib();
|
|
2750
2864
|
function startSession() {
|
|
2751
2865
|
const sessionId = useConfigStore.getState().sessionId;
|
|
2752
2866
|
if (!sessionId) {
|
|
@@ -2759,29 +2873,13 @@ function startSession() {
|
|
|
2759
2873
|
}
|
|
2760
2874
|
isSessionStarted = true;
|
|
2761
2875
|
console.log(`Session started in room: ${sessionId}`);
|
|
2762
|
-
|
|
2763
|
-
const audioInputDeviceId = useConfigStore.getState().audioInputDeviceId ?? useBaseStore.getState().audioInputDevice?.deviceId;
|
|
2764
|
-
createLocalTrack("audio", audioInputDeviceId);
|
|
2765
|
-
const sessionType = useConfigStore.getState().sessionType;
|
|
2766
|
-
if (sessionType === SESSION_TYPE.VIDEO) {
|
|
2767
|
-
const videoInputDeviceIdP1 = useConfigStore.getState().videoInputDeviceId;
|
|
2768
|
-
const videoInputDeviceIdP2 = useBaseStore.getState().videoInputDevice?.deviceId;
|
|
2769
|
-
const initialCameraFacingP1 = useConfigStore.getState().initialCameraFacing;
|
|
2770
|
-
const initialCameraFacingP2 = useBaseStore.getState().cameraFacing;
|
|
2771
|
-
if (videoInputDeviceIdP1) {
|
|
2772
|
-
createLocalTrack("video", videoInputDeviceIdP1);
|
|
2773
|
-
} else if (initialCameraFacingP1) {
|
|
2774
|
-
createLocalTrack("video", null, initialCameraFacingP2);
|
|
2775
|
-
} else {
|
|
2776
|
-
createLocalTrack("video", videoInputDeviceIdP2, initialCameraFacingP2);
|
|
2777
|
-
}
|
|
2778
|
-
}
|
|
2876
|
+
createLocalTracks();
|
|
2779
2877
|
const audioOutputDeviceId = useConfigStore.getState().audioOutputDeviceId ?? useBaseStore.getState().audioOutputDevice?.deviceId;
|
|
2780
2878
|
if (audioOutputDeviceId) {
|
|
2781
2879
|
updateAudioOutputDevice(audioOutputDeviceId);
|
|
2782
2880
|
}
|
|
2783
2881
|
eventBus.startEmitting();
|
|
2784
|
-
const test = tryCatchSync(() => connect(
|
|
2882
|
+
const test = tryCatchSync(() => connect());
|
|
2785
2883
|
if (test.error) {
|
|
2786
2884
|
console.error("Error connecting to session:", test.error);
|
|
2787
2885
|
useConnectionStore.getState().connectionFailed(test.error.message);
|
|
@@ -2798,8 +2896,14 @@ async function _leaveSession() {
|
|
|
2798
2896
|
await useConnectionStore.getState().disconnect();
|
|
2799
2897
|
}
|
|
2800
2898
|
const sessionMutex = new Mutex();
|
|
2801
|
-
function leaveSession() {
|
|
2899
|
+
function leaveSession(options = {}) {
|
|
2802
2900
|
return sessionMutex.run(async () => {
|
|
2901
|
+
const isPeerCall = useConfigStore.getState().isPeerCall;
|
|
2902
|
+
const shouldEnd = isPeerCall && !options.forceLeave;
|
|
2903
|
+
if (shouldEnd) {
|
|
2904
|
+
useConferenceStore.getState().endConference();
|
|
2905
|
+
return;
|
|
2906
|
+
}
|
|
2803
2907
|
useBaseStore.getState().clearIdealTimeoutTimer();
|
|
2804
2908
|
cancelPendingReconnect();
|
|
2805
2909
|
await _leaveSession();
|
|
@@ -3896,6 +4000,11 @@ const PopupMenu = ({ visible, onClose, options, anchorLayout }) => {
|
|
|
3896
4000
|
return /* @__PURE__ */ jsx(Modal, {
|
|
3897
4001
|
transparent: true,
|
|
3898
4002
|
animationType: "none",
|
|
4003
|
+
supportedOrientations: [
|
|
4004
|
+
"portrait",
|
|
4005
|
+
"landscape-left",
|
|
4006
|
+
"landscape-right"
|
|
4007
|
+
],
|
|
3899
4008
|
onRequestClose: onClose,
|
|
3900
4009
|
children: /* @__PURE__ */ jsx(Pressable, {
|
|
3901
4010
|
style: styles$27.backdrop,
|
|
@@ -4982,6 +5091,11 @@ function ConfirmationDialog() {
|
|
|
4982
5091
|
visible,
|
|
4983
5092
|
transparent: true,
|
|
4984
5093
|
animationType: "fade",
|
|
5094
|
+
supportedOrientations: [
|
|
5095
|
+
"portrait",
|
|
5096
|
+
"landscape-left",
|
|
5097
|
+
"landscape-right"
|
|
5098
|
+
],
|
|
4985
5099
|
onRequestClose: handleBackdropPress,
|
|
4986
5100
|
children: /* @__PURE__ */ jsx(Pressable, {
|
|
4987
5101
|
style: styles$15.backdrop,
|
|
@@ -5786,6 +5900,11 @@ const IdealTimeoutModal = ({ style = {} }) => {
|
|
|
5786
5900
|
transparent: true,
|
|
5787
5901
|
visible: idleTimeoutModalVisible,
|
|
5788
5902
|
animationType: "none",
|
|
5903
|
+
supportedOrientations: [
|
|
5904
|
+
"portrait",
|
|
5905
|
+
"landscape-left",
|
|
5906
|
+
"landscape-right"
|
|
5907
|
+
],
|
|
5789
5908
|
statusBarTranslucent: true,
|
|
5790
5909
|
children: /* @__PURE__ */ jsx(TouchableWithoutFeedback, {
|
|
5791
5910
|
onPress: handleOverlayPress,
|
|
@@ -5838,7 +5957,7 @@ const IdealTimeoutModal = ({ style = {} }) => {
|
|
|
5838
5957
|
})
|
|
5839
5958
|
}), /* @__PURE__ */ jsx(TouchableOpacity, {
|
|
5840
5959
|
style: [styles$6.button, styles$6.buttonPrimary],
|
|
5841
|
-
onPress: leaveSession,
|
|
5960
|
+
onPress: () => leaveSession(),
|
|
5842
5961
|
activeOpacity: .8,
|
|
5843
5962
|
children: /* @__PURE__ */ jsx(Text, {
|
|
5844
5963
|
style: [commonStyles.bodyMedium, styles$6.buttonPrimaryText],
|
|
@@ -5867,6 +5986,7 @@ const styles$6 = StyleSheet.create({
|
|
|
5867
5986
|
borderWidth: 1,
|
|
5868
5987
|
borderColor: "#383838",
|
|
5869
5988
|
width: "100%",
|
|
5989
|
+
maxWidth: 372,
|
|
5870
5990
|
paddingTop: 32,
|
|
5871
5991
|
paddingHorizontal: 20,
|
|
5872
5992
|
paddingBottom: 20,
|
|
@@ -6408,11 +6528,11 @@ function CallUI(props) {
|
|
|
6408
6528
|
const isConferenceJoined = useIsConferenceJoined();
|
|
6409
6529
|
useLayoutEffect(() => {
|
|
6410
6530
|
eventBus.publish({ type: INTERNAL_EVENTS.lifecycle.componentDidMount });
|
|
6411
|
-
updateConfig(props.
|
|
6531
|
+
updateConfig(props.sessionSettings);
|
|
6412
6532
|
return () => {
|
|
6413
6533
|
eventBus.publish({ type: INTERNAL_EVENTS.lifecycle.componentWillUnmount }, true);
|
|
6414
6534
|
};
|
|
6415
|
-
}, [props.
|
|
6535
|
+
}, [props.sessionSettings]);
|
|
6416
6536
|
useEffect(() => {
|
|
6417
6537
|
useBaseStore.setState({ sdkPlatform: Platform.OS });
|
|
6418
6538
|
startSession();
|
|
@@ -6429,13 +6549,13 @@ function CallUI(props) {
|
|
|
6429
6549
|
useEffect(() => {
|
|
6430
6550
|
if (Platform.OS === "android") {
|
|
6431
6551
|
AudioModeModule_default.setMode(type === SESSION_TYPE.VOICE ? AudioModeModule_default.AUDIO_CALL : AudioModeModule_default.VIDEO_CALL);
|
|
6432
|
-
if (props.
|
|
6433
|
-
AudioModeModule_default.setAudioDevice(props.
|
|
6552
|
+
if (props.sessionSettings.audioMode) {
|
|
6553
|
+
AudioModeModule_default.setAudioDevice(props.sessionSettings.audioMode);
|
|
6434
6554
|
}
|
|
6435
6555
|
} else if (Platform.OS === "ios") {
|
|
6436
6556
|
AudioModeModule_default.updateDeviceList();
|
|
6437
6557
|
}
|
|
6438
|
-
}, [props.
|
|
6558
|
+
}, [props.sessionSettings.audioMode, type]);
|
|
6439
6559
|
if (isPIPLayoutEnabled) {
|
|
6440
6560
|
return /* @__PURE__ */ jsx(PiPTile_default, {});
|
|
6441
6561
|
}
|
|
@@ -6727,8 +6847,8 @@ async function callVerifyTokenAPI({ appId, region, calltoken, baseURL }) {
|
|
|
6727
6847
|
}
|
|
6728
6848
|
|
|
6729
6849
|
//#endregion
|
|
6730
|
-
//#region src/
|
|
6731
|
-
function
|
|
6850
|
+
//#region src/AppReactNativeSDK.tsx
|
|
6851
|
+
function AppReactNativeSDK(props) {
|
|
6732
6852
|
const [internalSettings, setInternalSettings] = React.useState(null);
|
|
6733
6853
|
const [infoMessage, setInfoMessage] = React.useState(null);
|
|
6734
6854
|
useEffect(() => {
|
|
@@ -6740,7 +6860,7 @@ function App(props) {
|
|
|
6740
6860
|
}, []);
|
|
6741
6861
|
useEffect(() => {
|
|
6742
6862
|
const listeners = [];
|
|
6743
|
-
const cs = props.
|
|
6863
|
+
const cs = props.sessionSettings ?? {};
|
|
6744
6864
|
if (cs.listener?.onUserJoined) {
|
|
6745
6865
|
listeners.push(CometChatCalls.addEventListener("onParticipantJoined", cs.listener.onUserJoined));
|
|
6746
6866
|
}
|
|
@@ -6778,7 +6898,7 @@ function App(props) {
|
|
|
6778
6898
|
listener();
|
|
6779
6899
|
});
|
|
6780
6900
|
};
|
|
6781
|
-
}, [props.
|
|
6901
|
+
}, [props.sessionSettings]);
|
|
6782
6902
|
useEffect(() => {
|
|
6783
6903
|
callVerifyTokenAPI({
|
|
6784
6904
|
appId: CometChatCalls.appSettings?.appId || "",
|
|
@@ -6807,14 +6927,12 @@ function App(props) {
|
|
|
6807
6927
|
visible: true
|
|
6808
6928
|
});
|
|
6809
6929
|
}
|
|
6810
|
-
return /* @__PURE__ */ jsx(index_native_default, {
|
|
6811
|
-
...props.
|
|
6812
|
-
...convertLegacyCallSettingsToV5Props(props?.
|
|
6930
|
+
return /* @__PURE__ */ jsx(index_native_default, { sessionSettings: {
|
|
6931
|
+
...props.sessionSettings,
|
|
6932
|
+
...convertLegacyCallSettingsToV5Props(props?.sessionSettings ?? {}),
|
|
6813
6933
|
internalSettings
|
|
6814
6934
|
} });
|
|
6815
6935
|
}
|
|
6816
|
-
var AppRN_default = App;
|
|
6817
|
-
const AppComponent = App;
|
|
6818
6936
|
|
|
6819
6937
|
//#endregion
|
|
6820
6938
|
//#region src/v4/Constants.ts
|
|
@@ -10547,7 +10665,13 @@ var CometChatCalls = class extends SessionMethodsCore {
|
|
|
10547
10665
|
static OngoingCallListener = OngoingCallListener;
|
|
10548
10666
|
static CallSettingsBuilder = CallSettingsBuilder;
|
|
10549
10667
|
static CallAppSettingsBuilder = CallAppSettingsBuilder;
|
|
10550
|
-
static Component =
|
|
10668
|
+
static Component = AppReactNativeSDK;
|
|
10669
|
+
/**
|
|
10670
|
+
* Initializes the CometChat Calls SDK with the provided app settings.
|
|
10671
|
+
* Must be called before any other SDK methods.
|
|
10672
|
+
* @param appSettings - The application settings for configuring the SDK.
|
|
10673
|
+
* @returns An object indicating success or failure with error details.
|
|
10674
|
+
*/
|
|
10551
10675
|
static async init(appSettings) {
|
|
10552
10676
|
const parsedAppSettings = v.safeParse(CallAppSettingsSchema, appSettings);
|
|
10553
10677
|
if (!parsedAppSettings.success) {
|
|
@@ -10582,6 +10706,14 @@ var CometChatCalls = class extends SessionMethodsCore {
|
|
|
10582
10706
|
error: null
|
|
10583
10707
|
};
|
|
10584
10708
|
}
|
|
10709
|
+
/**
|
|
10710
|
+
* Logs in a user with their UID and an optional auth key.
|
|
10711
|
+
* If no auth key is provided, the one from app settings is used.
|
|
10712
|
+
* @param uid - The unique identifier of the user.
|
|
10713
|
+
* @param authKey - The authentication key. Falls back to the key provided in app settings.
|
|
10714
|
+
* @returns A Promise that resolves to the logged-in User object.
|
|
10715
|
+
* @throws {CometChatException} If login fails or validation errors occur.
|
|
10716
|
+
*/
|
|
10585
10717
|
static async login(uid, authKey) {
|
|
10586
10718
|
try {
|
|
10587
10719
|
if (this.loginInProgress) {
|
|
@@ -10624,7 +10756,6 @@ var CometChatCalls = class extends SessionMethodsCore {
|
|
|
10624
10756
|
if (this.loggedInUser && this.loggedInUser.uid !== uid) {
|
|
10625
10757
|
await this.logoutInternal();
|
|
10626
10758
|
}
|
|
10627
|
-
console.log("Logging in user with UID:", uid);
|
|
10628
10759
|
const authToken = await this.loginWithUID(uid, resolvedAuthKey);
|
|
10629
10760
|
const user = await this.authenticateWithToken(authToken);
|
|
10630
10761
|
this.loginInProgress = false;
|
|
@@ -10639,6 +10770,12 @@ var CometChatCalls = class extends SessionMethodsCore {
|
|
|
10639
10770
|
throw cometChatError;
|
|
10640
10771
|
}
|
|
10641
10772
|
}
|
|
10773
|
+
/**
|
|
10774
|
+
* Logs in a user directly with an auth token.
|
|
10775
|
+
* @param authToken - The authentication token for the user.
|
|
10776
|
+
* @returns A Promise that resolves to the logged-in User object.
|
|
10777
|
+
* @throws {CometChatException} If login fails or the token is invalid.
|
|
10778
|
+
*/
|
|
10642
10779
|
static async loginWithAuthToken(authToken) {
|
|
10643
10780
|
try {
|
|
10644
10781
|
if (this.loginInProgress) {
|
|
@@ -10681,6 +10818,11 @@ var CometChatCalls = class extends SessionMethodsCore {
|
|
|
10681
10818
|
throw cometChatError;
|
|
10682
10819
|
}
|
|
10683
10820
|
}
|
|
10821
|
+
/**
|
|
10822
|
+
* Logs out the currently logged-in user and clears local session data.
|
|
10823
|
+
* @returns A Promise that resolves to a success message string.
|
|
10824
|
+
* @throws {CometChatException} If no user is logged in or logout fails.
|
|
10825
|
+
*/
|
|
10684
10826
|
static async logout() {
|
|
10685
10827
|
try {
|
|
10686
10828
|
if (!this.loggedInUser) {
|
|
@@ -10698,24 +10840,53 @@ var CometChatCalls = class extends SessionMethodsCore {
|
|
|
10698
10840
|
throw cometChatError;
|
|
10699
10841
|
}
|
|
10700
10842
|
}
|
|
10843
|
+
/**
|
|
10844
|
+
* Retrieves the currently logged-in user.
|
|
10845
|
+
* @returns The logged-in User object, or null if no user is logged in.
|
|
10846
|
+
*/
|
|
10701
10847
|
static getLoggedInUser() {
|
|
10702
10848
|
if (this.loggedInUser && typeof this.loggedInUser === "string") {
|
|
10703
10849
|
this.loggedInUser = JSON.parse(this.loggedInUser);
|
|
10704
10850
|
}
|
|
10705
10851
|
return this.loggedInUser;
|
|
10706
10852
|
}
|
|
10853
|
+
/**
|
|
10854
|
+
* Retrieves the auth token of the currently logged-in user.
|
|
10855
|
+
* @returns The auth token string, or null if no user is logged in.
|
|
10856
|
+
*/
|
|
10707
10857
|
static getUserAuthToken() {
|
|
10708
10858
|
return this.loggedInUser?.authToken || null;
|
|
10709
10859
|
}
|
|
10860
|
+
/**
|
|
10861
|
+
* Checks whether a user is currently logged in.
|
|
10862
|
+
* @returns True if a user is logged in with a valid auth token, false otherwise.
|
|
10863
|
+
*/
|
|
10710
10864
|
static isUserLoggedIn() {
|
|
10711
10865
|
return this.loggedInUser !== null && this.loggedInUser.authToken !== undefined;
|
|
10712
10866
|
}
|
|
10867
|
+
/**
|
|
10868
|
+
* Registers a login listener to receive login/logout lifecycle callbacks.
|
|
10869
|
+
* @param listenerId - A unique identifier for the listener.
|
|
10870
|
+
* @param listener - The listener object with callback methods.
|
|
10871
|
+
*/
|
|
10713
10872
|
static addLoginListener(listenerId, listener) {
|
|
10714
10873
|
this.loginListeners.set(listenerId, listener);
|
|
10715
10874
|
}
|
|
10875
|
+
/**
|
|
10876
|
+
* Removes a previously registered login listener.
|
|
10877
|
+
* @param listenerId - The unique identifier of the listener to remove.
|
|
10878
|
+
*/
|
|
10716
10879
|
static removeLoginListener(listenerId) {
|
|
10717
10880
|
this.loginListeners.delete(listenerId);
|
|
10718
10881
|
}
|
|
10882
|
+
/**
|
|
10883
|
+
* Generates a call token for the given session.
|
|
10884
|
+
* Uses the provided auth token or falls back to the logged-in user's token.
|
|
10885
|
+
* @param sessionId - The session ID to generate a token for.
|
|
10886
|
+
* @param authToken - Optional auth token. If omitted, the logged-in user's token is used.
|
|
10887
|
+
* @returns A Promise that resolves to an object containing the generated token.
|
|
10888
|
+
* @throws {CometChatException} If the session ID is missing, no auth token is available, or the SDK is not initialized.
|
|
10889
|
+
*/
|
|
10719
10890
|
static async generateToken(sessionId, authToken) {
|
|
10720
10891
|
try {
|
|
10721
10892
|
if (!sessionId || sessionId.trim() === "") {
|
|
@@ -10949,8 +11120,27 @@ var CometChatCalls = class extends SessionMethodsCore {
|
|
|
10949
11120
|
}
|
|
10950
11121
|
});
|
|
10951
11122
|
}
|
|
10952
|
-
|
|
10953
|
-
|
|
11123
|
+
/**
|
|
11124
|
+
* Adds an event listener for SDK events.
|
|
11125
|
+
* @param eventType - The type of event to listen for.
|
|
11126
|
+
* @param listener - The callback function to invoke when the event fires.
|
|
11127
|
+
* @param options - Optional configuration including an AbortSignal for automatic cleanup.
|
|
11128
|
+
* @returns An unsubscribe function to remove the listener.
|
|
11129
|
+
*/
|
|
11130
|
+
static addEventListener(eventType, listener, options) {
|
|
11131
|
+
return eventBus.subscribe(eventType, listener, options);
|
|
11132
|
+
}
|
|
11133
|
+
/**
|
|
11134
|
+
* Enables Picture-in-Picture (PIP) layout during the call.
|
|
11135
|
+
*/
|
|
11136
|
+
static enablePictureInPictureLayout() {
|
|
11137
|
+
enablePictureInPictureLayout();
|
|
11138
|
+
}
|
|
11139
|
+
/**
|
|
11140
|
+
* Disables Picture-in-Picture (PIP) layout.
|
|
11141
|
+
*/
|
|
11142
|
+
static disablePictureInPictureLayout() {
|
|
11143
|
+
disablePictureInPictureLayout();
|
|
10954
11144
|
}
|
|
10955
11145
|
};
|
|
10956
11146
|
|