@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.js
CHANGED
|
@@ -75,17 +75,24 @@ var EventBus = class {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
subscribe(actionType, listener) {
|
|
78
|
+
subscribe(actionType, listener, options) {
|
|
79
|
+
if (options?.signal?.aborted) {
|
|
80
|
+
return () => {};
|
|
81
|
+
}
|
|
79
82
|
if (!this.actionListenersMap.get(actionType)) {
|
|
80
83
|
this.actionListenersMap.set(actionType, []);
|
|
81
84
|
}
|
|
82
85
|
this.actionListenersMap.get(actionType)?.push(listener);
|
|
83
|
-
|
|
86
|
+
const unsubscribe = () => {
|
|
84
87
|
const listenersList = this.actionListenersMap.get(actionType);
|
|
85
88
|
if (listenersList) {
|
|
86
89
|
this.actionListenersMap.set(actionType, listenersList.filter((l) => l !== listener));
|
|
87
90
|
}
|
|
88
91
|
};
|
|
92
|
+
if (options?.signal) {
|
|
93
|
+
options.signal.addEventListener("abort", unsubscribe, { once: true });
|
|
94
|
+
}
|
|
95
|
+
return unsubscribe;
|
|
89
96
|
}
|
|
90
97
|
};
|
|
91
98
|
const eventBus = new EventBus();
|
|
@@ -439,9 +446,9 @@ function getDefaultDevice(devices) {
|
|
|
439
446
|
|
|
440
447
|
//#endregion
|
|
441
448
|
//#region calls-sdk-core/utils/try-catch.ts
|
|
442
|
-
async function tryCatch(promise) {
|
|
449
|
+
async function tryCatch(promise, timeoutMs) {
|
|
443
450
|
try {
|
|
444
|
-
const data = await promise;
|
|
451
|
+
const data = timeoutMs != null ? await Promise.race([promise, new Promise((_, reject) => setTimeout(() => reject(new Error("timeout")), timeoutMs))]) : await promise;
|
|
445
452
|
return {
|
|
446
453
|
data,
|
|
447
454
|
error: null
|
|
@@ -485,76 +492,106 @@ function debounce(func, delay) {
|
|
|
485
492
|
//#endregion
|
|
486
493
|
//#region calls-sdk-core/utils/session-methods-core.ts
|
|
487
494
|
var SessionMethodsCore = class {
|
|
495
|
+
/**
|
|
496
|
+
* Mutes the local user's audio during the call.
|
|
497
|
+
*/
|
|
488
498
|
static muteAudio() {
|
|
489
499
|
muteAudioTrack();
|
|
490
500
|
}
|
|
501
|
+
/**
|
|
502
|
+
* Unmutes the local user's audio during the call.
|
|
503
|
+
*/
|
|
491
504
|
static unmuteAudio() {
|
|
492
505
|
unMuteAudioTrack();
|
|
493
506
|
}
|
|
507
|
+
/**
|
|
508
|
+
* Pauses the local user's video stream.
|
|
509
|
+
*/
|
|
494
510
|
static pauseVideo() {
|
|
495
511
|
pauseVideoTrack();
|
|
496
512
|
}
|
|
513
|
+
/**
|
|
514
|
+
* Resumes the local user's video stream.
|
|
515
|
+
*/
|
|
497
516
|
static resumeVideo() {
|
|
498
517
|
resumeVideoTrack();
|
|
499
518
|
}
|
|
519
|
+
/**
|
|
520
|
+
* Local user leaves the current session.
|
|
521
|
+
*/
|
|
500
522
|
static leaveSession() {
|
|
501
523
|
leaveSession();
|
|
502
524
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
static stopScreenSharing() {
|
|
507
|
-
stopScreenSharing();
|
|
508
|
-
}
|
|
525
|
+
/**
|
|
526
|
+
* Raises the user's virtual hand in the call.
|
|
527
|
+
*/
|
|
509
528
|
static raiseHand() {
|
|
510
529
|
raisedHandLocal();
|
|
511
530
|
}
|
|
531
|
+
/**
|
|
532
|
+
* Lowers the user's virtual hand in the call.
|
|
533
|
+
*/
|
|
512
534
|
static lowerHand() {
|
|
513
535
|
lowerHandLocal();
|
|
514
536
|
}
|
|
537
|
+
/**
|
|
538
|
+
* Switches between the front and rear camera.
|
|
539
|
+
*/
|
|
515
540
|
static switchCamera() {
|
|
516
541
|
switchCamera();
|
|
517
542
|
}
|
|
543
|
+
/**
|
|
544
|
+
* Sets the layout type for the call.
|
|
545
|
+
* @param layout - The type of layout to set (tile, sidebar or spotlight).
|
|
546
|
+
*/
|
|
518
547
|
static setLayout(layout$1) {
|
|
519
548
|
setLayout(layout$1);
|
|
520
549
|
}
|
|
550
|
+
/**
|
|
551
|
+
* Starts recording the call.
|
|
552
|
+
*/
|
|
521
553
|
static startRecording() {}
|
|
554
|
+
/**
|
|
555
|
+
* Stops the ongoing call recording.
|
|
556
|
+
*/
|
|
522
557
|
static stopRecording() {}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
}
|
|
558
|
+
/**
|
|
559
|
+
* Pins a participant's video to focus on them.
|
|
560
|
+
* @param participantId - The ID of the participant to pin.
|
|
561
|
+
* @param type - The type of the participant.
|
|
562
|
+
*/
|
|
529
563
|
static pinParticipant(participantId, type) {
|
|
530
564
|
pinParticipant(participantId, type);
|
|
531
565
|
}
|
|
566
|
+
/**
|
|
567
|
+
* Unpins a participant's video.
|
|
568
|
+
*/
|
|
532
569
|
static unpinParticipant() {
|
|
533
570
|
unpinParticipant();
|
|
534
571
|
}
|
|
572
|
+
/**
|
|
573
|
+
* Mutes the audio of a specific participant.
|
|
574
|
+
* @param participantId - The ID of the participant to mute.
|
|
575
|
+
*/
|
|
535
576
|
static muteParticipant(participantId) {
|
|
536
577
|
muteParticipant(participantId);
|
|
537
578
|
}
|
|
538
|
-
static pauseParticipantVideo(participantId) {
|
|
539
|
-
pauseParticipantVideo(participantId);
|
|
540
|
-
}
|
|
541
|
-
static setChatButtonUnreadCount(count) {
|
|
542
|
-
setChatButtonUnreadCount(count);
|
|
543
|
-
}
|
|
544
579
|
/**
|
|
545
|
-
*
|
|
580
|
+
* Pauses the video stream of a specific participant.
|
|
581
|
+
* @param participantId - The ID of the participant whose video to pause.
|
|
546
582
|
*/
|
|
547
|
-
static
|
|
548
|
-
|
|
583
|
+
static pauseParticipantVideo(participantId) {
|
|
584
|
+
pauseParticipantVideo(participantId);
|
|
549
585
|
}
|
|
550
586
|
/**
|
|
551
|
-
*
|
|
587
|
+
* Sets the unread message count displayed on the chat button.
|
|
588
|
+
* @param count - The number of unread messages.
|
|
552
589
|
*/
|
|
553
|
-
static
|
|
554
|
-
|
|
590
|
+
static setChatButtonUnreadCount(count) {
|
|
591
|
+
setChatButtonUnreadCount(count);
|
|
555
592
|
}
|
|
556
593
|
/**
|
|
557
|
-
* @deprecated switchToVideoCall is deprecated and not supported
|
|
594
|
+
* @deprecated switchToVideoCall is deprecated and not supported.
|
|
558
595
|
*/
|
|
559
596
|
static switchToVideoCall() {
|
|
560
597
|
console.error("switchToVideoCall method deprecated and not supported.");
|
|
@@ -644,6 +681,27 @@ async function createLocalTrack(type, deviceId = null, cameraFacing = CAMERA_FAC
|
|
|
644
681
|
}
|
|
645
682
|
}
|
|
646
683
|
}
|
|
684
|
+
function createLocalTracks() {
|
|
685
|
+
const enableCompanionMode = useConfigStore.getState().enableCompanionMode;
|
|
686
|
+
if (!enableCompanionMode) {
|
|
687
|
+
const audioInputDeviceId = useConfigStore.getState().audioInputDeviceId ?? useBaseStore.getState().audioInputDevice?.deviceId;
|
|
688
|
+
createLocalTrack("audio", audioInputDeviceId);
|
|
689
|
+
}
|
|
690
|
+
const sessionType = useConfigStore.getState().sessionType;
|
|
691
|
+
if (sessionType === SESSION_TYPE.VIDEO) {
|
|
692
|
+
const videoInputDeviceIdP1 = useConfigStore.getState().videoInputDeviceId;
|
|
693
|
+
const videoInputDeviceIdP2 = useBaseStore.getState().videoInputDevice?.deviceId;
|
|
694
|
+
const initialCameraFacingP1 = useConfigStore.getState().initialCameraFacing;
|
|
695
|
+
const initialCameraFacingP2 = useBaseStore.getState().cameraFacing;
|
|
696
|
+
if (videoInputDeviceIdP1) {
|
|
697
|
+
createLocalTrack("video", videoInputDeviceIdP1);
|
|
698
|
+
} else if (initialCameraFacingP1) {
|
|
699
|
+
createLocalTrack("video", null, initialCameraFacingP2);
|
|
700
|
+
} else {
|
|
701
|
+
createLocalTrack("video", videoInputDeviceIdP2, initialCameraFacingP2);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
647
705
|
function updateAudioInputDevice(deviceId) {
|
|
648
706
|
const audioInputDevices = useBaseStore.getState().audioInputDevices.filter((device) => device.deviceId !== "");
|
|
649
707
|
if (audioInputDevices.length > 0) {
|
|
@@ -843,7 +901,6 @@ const initialState$7 = {
|
|
|
843
901
|
hideLeaveSessionButton: false,
|
|
844
902
|
hideToggleAudioButton: false,
|
|
845
903
|
hideParticipantListButton: false,
|
|
846
|
-
hideSwitchLayoutButton: false,
|
|
847
904
|
hideChatButton: true,
|
|
848
905
|
hideToggleVideoButton: false,
|
|
849
906
|
hideScreenSharingButton: false,
|
|
@@ -860,7 +917,9 @@ const initialState$7 = {
|
|
|
860
917
|
idleTimeoutPeriodAfterPrompt: 18e4,
|
|
861
918
|
enableSpotlightDrag: true,
|
|
862
919
|
enableSpotlightSwap: true,
|
|
863
|
-
showFrameRate: false
|
|
920
|
+
showFrameRate: false,
|
|
921
|
+
enableCompanionMode: false,
|
|
922
|
+
isPeerCall: false
|
|
864
923
|
};
|
|
865
924
|
const useConfigStore = (0, zustand.create)()((0, zustand_middleware.subscribeWithSelector)((0, zustand_middleware.combine)(initialState$7, (set) => ({ reset: () => set(initialState$7) }))));
|
|
866
925
|
const setConfig = (config) => {
|
|
@@ -1138,13 +1197,22 @@ const useConferenceStore = (0, zustand.create)()((0, zustand_middleware.subscrib
|
|
|
1138
1197
|
leaveConference: async () => {
|
|
1139
1198
|
const conference = useConferenceStore.getState().conference;
|
|
1140
1199
|
if (conference) {
|
|
1141
|
-
const { error } = await tryCatch(conference.leave());
|
|
1200
|
+
const { error } = await tryCatch(conference.leave(), 500);
|
|
1142
1201
|
if (error) {
|
|
1143
1202
|
console.warn("Error leaving conference:", error);
|
|
1144
1203
|
eventBus.publish({ type: EVENT_LISTENER_METHODS.SessionStatusListener.onSessionLeft });
|
|
1145
1204
|
}
|
|
1146
1205
|
}
|
|
1147
1206
|
},
|
|
1207
|
+
endConference: async () => {
|
|
1208
|
+
const conference = useConferenceStore.getState().conference;
|
|
1209
|
+
if (conference) {
|
|
1210
|
+
const { error } = await tryCatch(conference.end());
|
|
1211
|
+
if (error) {
|
|
1212
|
+
console.warn("Error ending conference:", error);
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
},
|
|
1148
1216
|
stopRecording: async () => {
|
|
1149
1217
|
const conference = useConferenceStore.getState().conference;
|
|
1150
1218
|
if (conference) {
|
|
@@ -1988,12 +2056,34 @@ const useConnectionStore = (0, zustand.create)()((0, zustand_middleware.subscrib
|
|
|
1988
2056
|
},
|
|
1989
2057
|
reset: () => set(initialState$2)
|
|
1990
2058
|
}))));
|
|
2059
|
+
function waitForConnection() {
|
|
2060
|
+
const { connectionStatus } = useConnectionStore.getState();
|
|
2061
|
+
if (connectionStatus === "connected") return Promise.resolve();
|
|
2062
|
+
return new Promise((resolve, reject) => {
|
|
2063
|
+
const timeout = setTimeout(() => {
|
|
2064
|
+
unsub();
|
|
2065
|
+
reject(new Error("Connection timed out after 3 seconds"));
|
|
2066
|
+
}, 3e3);
|
|
2067
|
+
const unsub = useConnectionStore.subscribe((s) => s.connectionStatus, (status) => {
|
|
2068
|
+
if (status === "connected") {
|
|
2069
|
+
clearTimeout(timeout);
|
|
2070
|
+
unsub();
|
|
2071
|
+
resolve();
|
|
2072
|
+
} else if (status === "error") {
|
|
2073
|
+
clearTimeout(timeout);
|
|
2074
|
+
unsub();
|
|
2075
|
+
reject(useConnectionStore.getState().error);
|
|
2076
|
+
}
|
|
2077
|
+
});
|
|
2078
|
+
});
|
|
2079
|
+
}
|
|
1991
2080
|
|
|
1992
2081
|
//#endregion
|
|
1993
2082
|
//#region calls-sdk-core/store/utils/hooks.ts
|
|
1994
2083
|
const useHideMuteAudioButton = () => {
|
|
1995
2084
|
const hideMuteAudioButton = useConfigStore((state) => state.hideToggleAudioButton);
|
|
1996
|
-
|
|
2085
|
+
const enableCompanionMode = useConfigStore((state) => state.enableCompanionMode);
|
|
2086
|
+
return hideMuteAudioButton || enableCompanionMode;
|
|
1997
2087
|
};
|
|
1998
2088
|
const useHideToggleVideoButton = () => {
|
|
1999
2089
|
const hideToggleVideoButton = useConfigStore((state) => state.hideToggleVideoButton);
|
|
@@ -2311,8 +2401,13 @@ var ConferenceListener = class {
|
|
|
2311
2401
|
track.removeAllListeners(lib_jitsi_meet.default.events.track.NO_DATA_FROM_SOURCE);
|
|
2312
2402
|
}
|
|
2313
2403
|
onConferenceJoinInProgress() {}
|
|
2314
|
-
onConferenceFailed(
|
|
2315
|
-
console.
|
|
2404
|
+
onConferenceFailed(errorName, error, message) {
|
|
2405
|
+
console.log();
|
|
2406
|
+
if (errorName === lib_jitsi_meet.default.errors.conference.CONFERENCE_DESTROYED) {
|
|
2407
|
+
leaveSession({ forceLeave: true });
|
|
2408
|
+
return;
|
|
2409
|
+
}
|
|
2410
|
+
console.error("Conference failed:", errorName, error, message);
|
|
2316
2411
|
useConferenceStore.setState({
|
|
2317
2412
|
conferenceStatus: "error",
|
|
2318
2413
|
conferenceJoined: false,
|
|
@@ -2512,17 +2607,23 @@ function addConferenceListeners(conference) {
|
|
|
2512
2607
|
}
|
|
2513
2608
|
});
|
|
2514
2609
|
}
|
|
2515
|
-
async function
|
|
2610
|
+
async function _createConference() {
|
|
2611
|
+
const sessionId = useConfigStore.getState().sessionId;
|
|
2612
|
+
const connection = useConnectionStore.getState().connection;
|
|
2516
2613
|
if (!connection) {
|
|
2517
2614
|
throw new Error("No connection available");
|
|
2518
2615
|
}
|
|
2616
|
+
const connectionStatus = useConnectionStore.getState().connectionStatus;
|
|
2617
|
+
if (connectionStatus !== "connected") {
|
|
2618
|
+
await waitForConnection();
|
|
2619
|
+
}
|
|
2519
2620
|
const existingConference = useConferenceStore.getState().conference;
|
|
2520
2621
|
if (existingConference) {
|
|
2521
2622
|
console.log("Conference already exists, skipping creation");
|
|
2522
2623
|
return;
|
|
2523
2624
|
}
|
|
2524
2625
|
const connectionConfig = useConnectionStore.getState().connectionConfig;
|
|
2525
|
-
const conference = connection.initJitsiConference(
|
|
2626
|
+
const conference = connection.initJitsiConference(sessionId, connectionConfig);
|
|
2526
2627
|
const localAudioTrack = getLocalTrack(MEDIA_TYPE.AUDIO)?.originalTrack;
|
|
2527
2628
|
const localVideoTrack = getLocalTrack(MEDIA_TYPE.VIDEO)?.originalTrack;
|
|
2528
2629
|
if (localAudioTrack) {
|
|
@@ -2537,6 +2638,20 @@ async function createConference(connection, roomName) {
|
|
|
2537
2638
|
conference.setDisplayName(useParticipantStore.getState().localParticipant.name);
|
|
2538
2639
|
conference.join();
|
|
2539
2640
|
}
|
|
2641
|
+
async function createConference() {
|
|
2642
|
+
const conference = useConferenceStore.getState().conference;
|
|
2643
|
+
if (!conference) {
|
|
2644
|
+
const result = await tryCatch(_createConference());
|
|
2645
|
+
if (result.error) {
|
|
2646
|
+
console.error("Error creating conference", result.error);
|
|
2647
|
+
useConferenceStore.setState({
|
|
2648
|
+
conferenceStatus: "error",
|
|
2649
|
+
conferenceJoined: false,
|
|
2650
|
+
conferenceError: result.error.message
|
|
2651
|
+
});
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2540
2655
|
function muteParticipant(participantId) {
|
|
2541
2656
|
const conference = useConferenceStore.getState().conference;
|
|
2542
2657
|
conference?.muteParticipant(participantId, "audio");
|
|
@@ -2548,7 +2663,12 @@ function pauseParticipantVideo(participantId) {
|
|
|
2548
2663
|
|
|
2549
2664
|
//#endregion
|
|
2550
2665
|
//#region calls-sdk-core/handlers/connection.ts
|
|
2551
|
-
function connect(
|
|
2666
|
+
async function connect(autoJoinConference = true) {
|
|
2667
|
+
const existingConnection = useConnectionStore.getState().connection;
|
|
2668
|
+
if (existingConnection) {
|
|
2669
|
+
createConference();
|
|
2670
|
+
return;
|
|
2671
|
+
}
|
|
2552
2672
|
const options = useConnectionStore.getState().connectionConfig;
|
|
2553
2673
|
const jwt = useConnectionStore.getState().jwt;
|
|
2554
2674
|
const iAmRecorder = useConfigStore.getState().iAmRecorder;
|
|
@@ -2564,15 +2684,8 @@ function connect(roomName) {
|
|
|
2564
2684
|
async function onConnectionEstablished() {
|
|
2565
2685
|
useConnectionStore.getState().connectionEstablished(connection);
|
|
2566
2686
|
eventBus.publish({ type: INTERNAL_EVENTS.onConnectionEstablished });
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
console.error("Error creating conference", result.error);
|
|
2570
|
-
useConferenceStore.setState({
|
|
2571
|
-
conferenceStatus: "error",
|
|
2572
|
-
conferenceJoined: false,
|
|
2573
|
-
conferenceError: result.error.message
|
|
2574
|
-
});
|
|
2575
|
-
}
|
|
2687
|
+
if (!autoJoinConference) return;
|
|
2688
|
+
createConference();
|
|
2576
2689
|
}
|
|
2577
2690
|
function onConnectionFailed(err, message, ...args) {
|
|
2578
2691
|
unsubscribe();
|
|
@@ -2778,6 +2891,7 @@ function initializeLib() {
|
|
|
2778
2891
|
let isSessionStarted = false;
|
|
2779
2892
|
let reconnectTimeoutId = null;
|
|
2780
2893
|
const RECONNECT_DEBOUNCE_DELAY = 3e3;
|
|
2894
|
+
initializeLib();
|
|
2781
2895
|
function startSession() {
|
|
2782
2896
|
const sessionId = useConfigStore.getState().sessionId;
|
|
2783
2897
|
if (!sessionId) {
|
|
@@ -2790,29 +2904,13 @@ function startSession() {
|
|
|
2790
2904
|
}
|
|
2791
2905
|
isSessionStarted = true;
|
|
2792
2906
|
console.log(`Session started in room: ${sessionId}`);
|
|
2793
|
-
|
|
2794
|
-
const audioInputDeviceId = useConfigStore.getState().audioInputDeviceId ?? useBaseStore.getState().audioInputDevice?.deviceId;
|
|
2795
|
-
createLocalTrack("audio", audioInputDeviceId);
|
|
2796
|
-
const sessionType = useConfigStore.getState().sessionType;
|
|
2797
|
-
if (sessionType === SESSION_TYPE.VIDEO) {
|
|
2798
|
-
const videoInputDeviceIdP1 = useConfigStore.getState().videoInputDeviceId;
|
|
2799
|
-
const videoInputDeviceIdP2 = useBaseStore.getState().videoInputDevice?.deviceId;
|
|
2800
|
-
const initialCameraFacingP1 = useConfigStore.getState().initialCameraFacing;
|
|
2801
|
-
const initialCameraFacingP2 = useBaseStore.getState().cameraFacing;
|
|
2802
|
-
if (videoInputDeviceIdP1) {
|
|
2803
|
-
createLocalTrack("video", videoInputDeviceIdP1);
|
|
2804
|
-
} else if (initialCameraFacingP1) {
|
|
2805
|
-
createLocalTrack("video", null, initialCameraFacingP2);
|
|
2806
|
-
} else {
|
|
2807
|
-
createLocalTrack("video", videoInputDeviceIdP2, initialCameraFacingP2);
|
|
2808
|
-
}
|
|
2809
|
-
}
|
|
2907
|
+
createLocalTracks();
|
|
2810
2908
|
const audioOutputDeviceId = useConfigStore.getState().audioOutputDeviceId ?? useBaseStore.getState().audioOutputDevice?.deviceId;
|
|
2811
2909
|
if (audioOutputDeviceId) {
|
|
2812
2910
|
updateAudioOutputDevice(audioOutputDeviceId);
|
|
2813
2911
|
}
|
|
2814
2912
|
eventBus.startEmitting();
|
|
2815
|
-
const test = tryCatchSync(() => connect(
|
|
2913
|
+
const test = tryCatchSync(() => connect());
|
|
2816
2914
|
if (test.error) {
|
|
2817
2915
|
console.error("Error connecting to session:", test.error);
|
|
2818
2916
|
useConnectionStore.getState().connectionFailed(test.error.message);
|
|
@@ -2829,8 +2927,14 @@ async function _leaveSession() {
|
|
|
2829
2927
|
await useConnectionStore.getState().disconnect();
|
|
2830
2928
|
}
|
|
2831
2929
|
const sessionMutex = new Mutex();
|
|
2832
|
-
function leaveSession() {
|
|
2930
|
+
function leaveSession(options = {}) {
|
|
2833
2931
|
return sessionMutex.run(async () => {
|
|
2932
|
+
const isPeerCall = useConfigStore.getState().isPeerCall;
|
|
2933
|
+
const shouldEnd = isPeerCall && !options.forceLeave;
|
|
2934
|
+
if (shouldEnd) {
|
|
2935
|
+
useConferenceStore.getState().endConference();
|
|
2936
|
+
return;
|
|
2937
|
+
}
|
|
2834
2938
|
useBaseStore.getState().clearIdealTimeoutTimer();
|
|
2835
2939
|
cancelPendingReconnect();
|
|
2836
2940
|
await _leaveSession();
|
|
@@ -3927,6 +4031,11 @@ const PopupMenu = ({ visible, onClose, options, anchorLayout }) => {
|
|
|
3927
4031
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Modal, {
|
|
3928
4032
|
transparent: true,
|
|
3929
4033
|
animationType: "none",
|
|
4034
|
+
supportedOrientations: [
|
|
4035
|
+
"portrait",
|
|
4036
|
+
"landscape-left",
|
|
4037
|
+
"landscape-right"
|
|
4038
|
+
],
|
|
3930
4039
|
onRequestClose: onClose,
|
|
3931
4040
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Pressable, {
|
|
3932
4041
|
style: styles$27.backdrop,
|
|
@@ -5013,6 +5122,11 @@ function ConfirmationDialog() {
|
|
|
5013
5122
|
visible,
|
|
5014
5123
|
transparent: true,
|
|
5015
5124
|
animationType: "fade",
|
|
5125
|
+
supportedOrientations: [
|
|
5126
|
+
"portrait",
|
|
5127
|
+
"landscape-left",
|
|
5128
|
+
"landscape-right"
|
|
5129
|
+
],
|
|
5016
5130
|
onRequestClose: handleBackdropPress,
|
|
5017
5131
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Pressable, {
|
|
5018
5132
|
style: styles$15.backdrop,
|
|
@@ -5817,6 +5931,11 @@ const IdealTimeoutModal = ({ style = {} }) => {
|
|
|
5817
5931
|
transparent: true,
|
|
5818
5932
|
visible: idleTimeoutModalVisible,
|
|
5819
5933
|
animationType: "none",
|
|
5934
|
+
supportedOrientations: [
|
|
5935
|
+
"portrait",
|
|
5936
|
+
"landscape-left",
|
|
5937
|
+
"landscape-right"
|
|
5938
|
+
],
|
|
5820
5939
|
statusBarTranslucent: true,
|
|
5821
5940
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.TouchableWithoutFeedback, {
|
|
5822
5941
|
onPress: handleOverlayPress,
|
|
@@ -5869,7 +5988,7 @@ const IdealTimeoutModal = ({ style = {} }) => {
|
|
|
5869
5988
|
})
|
|
5870
5989
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.TouchableOpacity, {
|
|
5871
5990
|
style: [styles$6.button, styles$6.buttonPrimary],
|
|
5872
|
-
onPress: leaveSession,
|
|
5991
|
+
onPress: () => leaveSession(),
|
|
5873
5992
|
activeOpacity: .8,
|
|
5874
5993
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
5875
5994
|
style: [commonStyles.bodyMedium, styles$6.buttonPrimaryText],
|
|
@@ -5898,6 +6017,7 @@ const styles$6 = react_native.StyleSheet.create({
|
|
|
5898
6017
|
borderWidth: 1,
|
|
5899
6018
|
borderColor: "#383838",
|
|
5900
6019
|
width: "100%",
|
|
6020
|
+
maxWidth: 372,
|
|
5901
6021
|
paddingTop: 32,
|
|
5902
6022
|
paddingHorizontal: 20,
|
|
5903
6023
|
paddingBottom: 20,
|
|
@@ -6439,11 +6559,11 @@ function CallUI(props) {
|
|
|
6439
6559
|
const isConferenceJoined = useIsConferenceJoined();
|
|
6440
6560
|
(0, react.useLayoutEffect)(() => {
|
|
6441
6561
|
eventBus.publish({ type: INTERNAL_EVENTS.lifecycle.componentDidMount });
|
|
6442
|
-
updateConfig(props.
|
|
6562
|
+
updateConfig(props.sessionSettings);
|
|
6443
6563
|
return () => {
|
|
6444
6564
|
eventBus.publish({ type: INTERNAL_EVENTS.lifecycle.componentWillUnmount }, true);
|
|
6445
6565
|
};
|
|
6446
|
-
}, [props.
|
|
6566
|
+
}, [props.sessionSettings]);
|
|
6447
6567
|
(0, react.useEffect)(() => {
|
|
6448
6568
|
useBaseStore.setState({ sdkPlatform: react_native.Platform.OS });
|
|
6449
6569
|
startSession();
|
|
@@ -6460,13 +6580,13 @@ function CallUI(props) {
|
|
|
6460
6580
|
(0, react.useEffect)(() => {
|
|
6461
6581
|
if (react_native.Platform.OS === "android") {
|
|
6462
6582
|
AudioModeModule_default.setMode(type === SESSION_TYPE.VOICE ? AudioModeModule_default.AUDIO_CALL : AudioModeModule_default.VIDEO_CALL);
|
|
6463
|
-
if (props.
|
|
6464
|
-
AudioModeModule_default.setAudioDevice(props.
|
|
6583
|
+
if (props.sessionSettings.audioMode) {
|
|
6584
|
+
AudioModeModule_default.setAudioDevice(props.sessionSettings.audioMode);
|
|
6465
6585
|
}
|
|
6466
6586
|
} else if (react_native.Platform.OS === "ios") {
|
|
6467
6587
|
AudioModeModule_default.updateDeviceList();
|
|
6468
6588
|
}
|
|
6469
|
-
}, [props.
|
|
6589
|
+
}, [props.sessionSettings.audioMode, type]);
|
|
6470
6590
|
if (isPIPLayoutEnabled) {
|
|
6471
6591
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PiPTile_default, {});
|
|
6472
6592
|
}
|
|
@@ -6758,8 +6878,8 @@ async function callVerifyTokenAPI({ appId, region, calltoken, baseURL }) {
|
|
|
6758
6878
|
}
|
|
6759
6879
|
|
|
6760
6880
|
//#endregion
|
|
6761
|
-
//#region src/
|
|
6762
|
-
function
|
|
6881
|
+
//#region src/AppReactNativeSDK.tsx
|
|
6882
|
+
function AppReactNativeSDK(props) {
|
|
6763
6883
|
const [internalSettings, setInternalSettings] = react.default.useState(null);
|
|
6764
6884
|
const [infoMessage, setInfoMessage] = react.default.useState(null);
|
|
6765
6885
|
(0, react.useEffect)(() => {
|
|
@@ -6771,7 +6891,7 @@ function App(props) {
|
|
|
6771
6891
|
}, []);
|
|
6772
6892
|
(0, react.useEffect)(() => {
|
|
6773
6893
|
const listeners = [];
|
|
6774
|
-
const cs = props.
|
|
6894
|
+
const cs = props.sessionSettings ?? {};
|
|
6775
6895
|
if (cs.listener?.onUserJoined) {
|
|
6776
6896
|
listeners.push(CometChatCalls.addEventListener("onParticipantJoined", cs.listener.onUserJoined));
|
|
6777
6897
|
}
|
|
@@ -6809,7 +6929,7 @@ function App(props) {
|
|
|
6809
6929
|
listener();
|
|
6810
6930
|
});
|
|
6811
6931
|
};
|
|
6812
|
-
}, [props.
|
|
6932
|
+
}, [props.sessionSettings]);
|
|
6813
6933
|
(0, react.useEffect)(() => {
|
|
6814
6934
|
callVerifyTokenAPI({
|
|
6815
6935
|
appId: CometChatCalls.appSettings?.appId || "",
|
|
@@ -6838,14 +6958,12 @@ function App(props) {
|
|
|
6838
6958
|
visible: true
|
|
6839
6959
|
});
|
|
6840
6960
|
}
|
|
6841
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(index_native_default, {
|
|
6842
|
-
...props.
|
|
6843
|
-
...convertLegacyCallSettingsToV5Props(props?.
|
|
6961
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(index_native_default, { sessionSettings: {
|
|
6962
|
+
...props.sessionSettings,
|
|
6963
|
+
...convertLegacyCallSettingsToV5Props(props?.sessionSettings ?? {}),
|
|
6844
6964
|
internalSettings
|
|
6845
6965
|
} });
|
|
6846
6966
|
}
|
|
6847
|
-
var AppRN_default = App;
|
|
6848
|
-
const AppComponent = App;
|
|
6849
6967
|
|
|
6850
6968
|
//#endregion
|
|
6851
6969
|
//#region src/v4/Constants.ts
|
|
@@ -10578,7 +10696,13 @@ var CometChatCalls = class extends SessionMethodsCore {
|
|
|
10578
10696
|
static OngoingCallListener = OngoingCallListener;
|
|
10579
10697
|
static CallSettingsBuilder = CallSettingsBuilder;
|
|
10580
10698
|
static CallAppSettingsBuilder = CallAppSettingsBuilder;
|
|
10581
|
-
static Component =
|
|
10699
|
+
static Component = AppReactNativeSDK;
|
|
10700
|
+
/**
|
|
10701
|
+
* Initializes the CometChat Calls SDK with the provided app settings.
|
|
10702
|
+
* Must be called before any other SDK methods.
|
|
10703
|
+
* @param appSettings - The application settings for configuring the SDK.
|
|
10704
|
+
* @returns An object indicating success or failure with error details.
|
|
10705
|
+
*/
|
|
10582
10706
|
static async init(appSettings) {
|
|
10583
10707
|
const parsedAppSettings = valibot.safeParse(CallAppSettingsSchema, appSettings);
|
|
10584
10708
|
if (!parsedAppSettings.success) {
|
|
@@ -10613,6 +10737,14 @@ var CometChatCalls = class extends SessionMethodsCore {
|
|
|
10613
10737
|
error: null
|
|
10614
10738
|
};
|
|
10615
10739
|
}
|
|
10740
|
+
/**
|
|
10741
|
+
* Logs in a user with their UID and an optional auth key.
|
|
10742
|
+
* If no auth key is provided, the one from app settings is used.
|
|
10743
|
+
* @param uid - The unique identifier of the user.
|
|
10744
|
+
* @param authKey - The authentication key. Falls back to the key provided in app settings.
|
|
10745
|
+
* @returns A Promise that resolves to the logged-in User object.
|
|
10746
|
+
* @throws {CometChatException} If login fails or validation errors occur.
|
|
10747
|
+
*/
|
|
10616
10748
|
static async login(uid, authKey) {
|
|
10617
10749
|
try {
|
|
10618
10750
|
if (this.loginInProgress) {
|
|
@@ -10655,7 +10787,6 @@ var CometChatCalls = class extends SessionMethodsCore {
|
|
|
10655
10787
|
if (this.loggedInUser && this.loggedInUser.uid !== uid) {
|
|
10656
10788
|
await this.logoutInternal();
|
|
10657
10789
|
}
|
|
10658
|
-
console.log("Logging in user with UID:", uid);
|
|
10659
10790
|
const authToken = await this.loginWithUID(uid, resolvedAuthKey);
|
|
10660
10791
|
const user = await this.authenticateWithToken(authToken);
|
|
10661
10792
|
this.loginInProgress = false;
|
|
@@ -10670,6 +10801,12 @@ var CometChatCalls = class extends SessionMethodsCore {
|
|
|
10670
10801
|
throw cometChatError;
|
|
10671
10802
|
}
|
|
10672
10803
|
}
|
|
10804
|
+
/**
|
|
10805
|
+
* Logs in a user directly with an auth token.
|
|
10806
|
+
* @param authToken - The authentication token for the user.
|
|
10807
|
+
* @returns A Promise that resolves to the logged-in User object.
|
|
10808
|
+
* @throws {CometChatException} If login fails or the token is invalid.
|
|
10809
|
+
*/
|
|
10673
10810
|
static async loginWithAuthToken(authToken) {
|
|
10674
10811
|
try {
|
|
10675
10812
|
if (this.loginInProgress) {
|
|
@@ -10712,6 +10849,11 @@ var CometChatCalls = class extends SessionMethodsCore {
|
|
|
10712
10849
|
throw cometChatError;
|
|
10713
10850
|
}
|
|
10714
10851
|
}
|
|
10852
|
+
/**
|
|
10853
|
+
* Logs out the currently logged-in user and clears local session data.
|
|
10854
|
+
* @returns A Promise that resolves to a success message string.
|
|
10855
|
+
* @throws {CometChatException} If no user is logged in or logout fails.
|
|
10856
|
+
*/
|
|
10715
10857
|
static async logout() {
|
|
10716
10858
|
try {
|
|
10717
10859
|
if (!this.loggedInUser) {
|
|
@@ -10729,24 +10871,53 @@ var CometChatCalls = class extends SessionMethodsCore {
|
|
|
10729
10871
|
throw cometChatError;
|
|
10730
10872
|
}
|
|
10731
10873
|
}
|
|
10874
|
+
/**
|
|
10875
|
+
* Retrieves the currently logged-in user.
|
|
10876
|
+
* @returns The logged-in User object, or null if no user is logged in.
|
|
10877
|
+
*/
|
|
10732
10878
|
static getLoggedInUser() {
|
|
10733
10879
|
if (this.loggedInUser && typeof this.loggedInUser === "string") {
|
|
10734
10880
|
this.loggedInUser = JSON.parse(this.loggedInUser);
|
|
10735
10881
|
}
|
|
10736
10882
|
return this.loggedInUser;
|
|
10737
10883
|
}
|
|
10884
|
+
/**
|
|
10885
|
+
* Retrieves the auth token of the currently logged-in user.
|
|
10886
|
+
* @returns The auth token string, or null if no user is logged in.
|
|
10887
|
+
*/
|
|
10738
10888
|
static getUserAuthToken() {
|
|
10739
10889
|
return this.loggedInUser?.authToken || null;
|
|
10740
10890
|
}
|
|
10891
|
+
/**
|
|
10892
|
+
* Checks whether a user is currently logged in.
|
|
10893
|
+
* @returns True if a user is logged in with a valid auth token, false otherwise.
|
|
10894
|
+
*/
|
|
10741
10895
|
static isUserLoggedIn() {
|
|
10742
10896
|
return this.loggedInUser !== null && this.loggedInUser.authToken !== undefined;
|
|
10743
10897
|
}
|
|
10898
|
+
/**
|
|
10899
|
+
* Registers a login listener to receive login/logout lifecycle callbacks.
|
|
10900
|
+
* @param listenerId - A unique identifier for the listener.
|
|
10901
|
+
* @param listener - The listener object with callback methods.
|
|
10902
|
+
*/
|
|
10744
10903
|
static addLoginListener(listenerId, listener) {
|
|
10745
10904
|
this.loginListeners.set(listenerId, listener);
|
|
10746
10905
|
}
|
|
10906
|
+
/**
|
|
10907
|
+
* Removes a previously registered login listener.
|
|
10908
|
+
* @param listenerId - The unique identifier of the listener to remove.
|
|
10909
|
+
*/
|
|
10747
10910
|
static removeLoginListener(listenerId) {
|
|
10748
10911
|
this.loginListeners.delete(listenerId);
|
|
10749
10912
|
}
|
|
10913
|
+
/**
|
|
10914
|
+
* Generates a call token for the given session.
|
|
10915
|
+
* Uses the provided auth token or falls back to the logged-in user's token.
|
|
10916
|
+
* @param sessionId - The session ID to generate a token for.
|
|
10917
|
+
* @param authToken - Optional auth token. If omitted, the logged-in user's token is used.
|
|
10918
|
+
* @returns A Promise that resolves to an object containing the generated token.
|
|
10919
|
+
* @throws {CometChatException} If the session ID is missing, no auth token is available, or the SDK is not initialized.
|
|
10920
|
+
*/
|
|
10750
10921
|
static async generateToken(sessionId, authToken) {
|
|
10751
10922
|
try {
|
|
10752
10923
|
if (!sessionId || sessionId.trim() === "") {
|
|
@@ -10980,8 +11151,27 @@ var CometChatCalls = class extends SessionMethodsCore {
|
|
|
10980
11151
|
}
|
|
10981
11152
|
});
|
|
10982
11153
|
}
|
|
10983
|
-
|
|
10984
|
-
|
|
11154
|
+
/**
|
|
11155
|
+
* Adds an event listener for SDK events.
|
|
11156
|
+
* @param eventType - The type of event to listen for.
|
|
11157
|
+
* @param listener - The callback function to invoke when the event fires.
|
|
11158
|
+
* @param options - Optional configuration including an AbortSignal for automatic cleanup.
|
|
11159
|
+
* @returns An unsubscribe function to remove the listener.
|
|
11160
|
+
*/
|
|
11161
|
+
static addEventListener(eventType, listener, options) {
|
|
11162
|
+
return eventBus.subscribe(eventType, listener, options);
|
|
11163
|
+
}
|
|
11164
|
+
/**
|
|
11165
|
+
* Enables Picture-in-Picture (PIP) layout during the call.
|
|
11166
|
+
*/
|
|
11167
|
+
static enablePictureInPictureLayout() {
|
|
11168
|
+
enablePictureInPictureLayout();
|
|
11169
|
+
}
|
|
11170
|
+
/**
|
|
11171
|
+
* Disables Picture-in-Picture (PIP) layout.
|
|
11172
|
+
*/
|
|
11173
|
+
static disablePictureInPictureLayout() {
|
|
11174
|
+
disablePictureInPictureLayout();
|
|
10985
11175
|
}
|
|
10986
11176
|
};
|
|
10987
11177
|
|