@cometchat/calls-sdk-react-native 5.0.0-beta.5 → 5.0.0-beta.7

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/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as v from "valibot";
2
- import * as zustand1 from "zustand";
2
+ import * as zustand7 from "zustand";
3
3
  import * as zustand_middleware0 from "zustand/middleware";
4
4
  import React from "react";
5
5
  import JitsiMeetJS from "lib-jitsi-meet";
@@ -357,6 +357,10 @@ type BaseState = {
357
357
  startIndex: number;
358
358
  endIndex: number;
359
359
  };
360
+ sidebarVisibleParticipants: {
361
+ startIndex: number;
362
+ endIndex: number;
363
+ };
360
364
  };
361
365
  type Actions$5 = {
362
366
  toggleParticipantListVisible: () => void;
@@ -369,7 +373,7 @@ type Actions$5 = {
369
373
  isMobileSDK: () => boolean;
370
374
  isMobile: () => boolean;
371
375
  };
372
- declare const useBaseStore: zustand1.UseBoundStore<Omit<Omit<zustand1.StoreApi<BaseState & Actions$5>, "subscribe"> & {
376
+ declare const useBaseStore: zustand7.UseBoundStore<Omit<Omit<zustand7.StoreApi<BaseState & Actions$5>, "subscribe"> & {
373
377
  subscribe: {
374
378
  (listener: (selectedState: BaseState & Actions$5, previousSelectedState: BaseState & Actions$5) => void): () => void;
375
379
  <U>(selector: (state: BaseState & Actions$5) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
@@ -449,7 +453,7 @@ type Actions$4 = {
449
453
  endConference: () => Promise<void>;
450
454
  stopRecording: () => Promise<void>;
451
455
  };
452
- declare const useConferenceStore: zustand1.UseBoundStore<Omit<zustand1.StoreApi<ConferenceState & Actions$4>, "subscribe"> & {
456
+ declare const useConferenceStore: zustand7.UseBoundStore<Omit<zustand7.StoreApi<ConferenceState & Actions$4>, "subscribe"> & {
453
457
  subscribe: {
454
458
  (listener: (selectedState: ConferenceState & Actions$4, previousSelectedState: ConferenceState & Actions$4) => void): () => void;
455
459
  <U>(selector: (state: ConferenceState & Actions$4) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
@@ -525,7 +529,7 @@ type ConfigState = ConfigStateInternal & ConfigStateMobile & ConfigStateWeb & Co
525
529
  type Actions$3 = {
526
530
  reset: () => void;
527
531
  };
528
- declare const useConfigStore: zustand1.UseBoundStore<Omit<zustand1.StoreApi<ConfigStateInternal & ConfigStateMobile & ConfigStateWeb & ConfigStateBoth & Actions$3>, "subscribe"> & {
532
+ declare const useConfigStore: zustand7.UseBoundStore<Omit<zustand7.StoreApi<ConfigStateInternal & ConfigStateMobile & ConfigStateWeb & ConfigStateBoth & Actions$3>, "subscribe"> & {
529
533
  subscribe: {
530
534
  (listener: (selectedState: ConfigStateInternal & ConfigStateMobile & ConfigStateWeb & ConfigStateBoth & Actions$3, previousSelectedState: ConfigStateInternal & ConfigStateMobile & ConfigStateWeb & ConfigStateBoth & Actions$3) => void): () => void;
531
535
  <U>(selector: (state: ConfigStateInternal & ConfigStateMobile & ConfigStateWeb & ConfigStateBoth & Actions$3) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
@@ -677,7 +681,7 @@ type Actions$2 = {
677
681
  disconnect: () => Promise<void>;
678
682
  reset: () => void;
679
683
  };
680
- declare const useConnectionStore: zustand1.UseBoundStore<Omit<zustand1.StoreApi<ConnectionState & Actions$2>, "subscribe"> & {
684
+ declare const useConnectionStore: zustand7.UseBoundStore<Omit<zustand7.StoreApi<ConnectionState & Actions$2>, "subscribe"> & {
681
685
  subscribe: {
682
686
  (listener: (selectedState: ConnectionState & Actions$2, previousSelectedState: ConnectionState & Actions$2) => void): () => void;
683
687
  <U>(selector: (state: ConnectionState & Actions$2) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
@@ -728,7 +732,7 @@ type Actions$1 = {
728
732
  getParticipantById: (pid: string) => HumanParticipant | undefined;
729
733
  reset: () => void;
730
734
  };
731
- declare const useParticipantStore: zustand1.UseBoundStore<Omit<zustand1.StoreApi<ParticipantsState & Actions$1>, "subscribe"> & {
735
+ declare const useParticipantStore: zustand7.UseBoundStore<Omit<zustand7.StoreApi<ParticipantsState & Actions$1>, "subscribe"> & {
732
736
  subscribe: {
733
737
  (listener: (selectedState: ParticipantsState & Actions$1, previousSelectedState: ParticipantsState & Actions$1) => void): () => void;
734
738
  <U>(selector: (state: ParticipantsState & Actions$1) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
@@ -774,7 +778,7 @@ type Actions = {
774
778
  updateTrack: (originalTrack: any, updatedTrack: Partial<Track>) => void;
775
779
  updateLocalTrack: (mediaType: MediaType, updatedTrack: Partial<Track>) => void;
776
780
  };
777
- declare const useTracksStore: zustand1.UseBoundStore<Omit<zustand1.StoreApi<TracksState & Actions>, "subscribe"> & {
781
+ declare const useTracksStore: zustand7.UseBoundStore<Omit<zustand7.StoreApi<TracksState & Actions>, "subscribe"> & {
778
782
  subscribe: {
779
783
  (listener: (selectedState: TracksState & Actions, previousSelectedState: TracksState & Actions) => void): () => void;
780
784
  <U>(selector: (state: TracksState & Actions) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
@@ -856,6 +860,11 @@ declare class SessionMethodsCore {
856
860
  * Local user leaves the current session.
857
861
  */
858
862
  static leaveSession(): void;
863
+ /**
864
+ * Ends the current session for all participants.
865
+ * This will terminate the conference and disconnect everyone.
866
+ */
867
+ static endSessionForAll(): void;
859
868
  /**
860
869
  * Raises the user's virtual hand in the call.
861
870
  */
@@ -1112,6 +1121,7 @@ declare function removeScreenShareParticipant(participantId: string): void;
1112
1121
  declare function startSession(): void;
1113
1122
  declare function leaveSession(options?: {
1114
1123
  forceLeave?: boolean;
1124
+ shouldEndSession?: boolean;
1115
1125
  }): Promise<void>;
1116
1126
  declare function leaveSessionDueToIdleTimeout(): Promise<void>;
1117
1127
  declare function reconnectSession(): Promise<void>;
@@ -1260,7 +1270,7 @@ interface TranslationState {
1260
1270
  translations: Record<string, typeof __json_default_export>;
1261
1271
  currentLocale: CometChatSupportedLocale | Omit<string, CometChatSupportedLocale>;
1262
1272
  }
1263
- declare const useTranslationStore: zustand1.UseBoundStore<Omit<zustand1.StoreApi<Omit<TranslationState, "reset" | "setLocale"> & {
1273
+ declare const useTranslationStore: zustand7.UseBoundStore<Omit<zustand7.StoreApi<Omit<TranslationState, "reset" | "setLocale"> & {
1264
1274
  reset: () => void;
1265
1275
  setLocale: (locale: CometChatSupportedLocale) => void;
1266
1276
  }>, "subscribe"> & {
@@ -2647,6 +2657,10 @@ declare class MainVideoContainerSetting {
2647
2657
  //#region src/AppReactNativeSDK.d.ts
2648
2658
  interface AppProps extends Partial<ConfigStateMobile & ConfigStateBoth> {
2649
2659
  callToken: string;
2660
+ /**
2661
+ * @deprecated Use `sessionSettings` instead.
2662
+ */
2663
+ callSettings: CallSettings | Partial<ConfigStateMobile & ConfigStateBoth>;
2650
2664
  sessionSettings?: CallSettings | Partial<ConfigStateMobile & ConfigStateBoth>;
2651
2665
  }
2652
2666
  declare function AppReactNativeSDK(props: AppProps): React.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -357,6 +357,10 @@ type BaseState = {
357
357
  startIndex: number;
358
358
  endIndex: number;
359
359
  };
360
+ sidebarVisibleParticipants: {
361
+ startIndex: number;
362
+ endIndex: number;
363
+ };
360
364
  };
361
365
  type Actions$5 = {
362
366
  toggleParticipantListVisible: () => void;
@@ -856,6 +860,11 @@ declare class SessionMethodsCore {
856
860
  * Local user leaves the current session.
857
861
  */
858
862
  static leaveSession(): void;
863
+ /**
864
+ * Ends the current session for all participants.
865
+ * This will terminate the conference and disconnect everyone.
866
+ */
867
+ static endSessionForAll(): void;
859
868
  /**
860
869
  * Raises the user's virtual hand in the call.
861
870
  */
@@ -1112,6 +1121,7 @@ declare function removeScreenShareParticipant(participantId: string): void;
1112
1121
  declare function startSession(): void;
1113
1122
  declare function leaveSession(options?: {
1114
1123
  forceLeave?: boolean;
1124
+ shouldEndSession?: boolean;
1115
1125
  }): Promise<void>;
1116
1126
  declare function leaveSessionDueToIdleTimeout(): Promise<void>;
1117
1127
  declare function reconnectSession(): Promise<void>;
@@ -2647,6 +2657,10 @@ declare class MainVideoContainerSetting {
2647
2657
  //#region src/AppReactNativeSDK.d.ts
2648
2658
  interface AppProps extends Partial<ConfigStateMobile & ConfigStateBoth> {
2649
2659
  callToken: string;
2660
+ /**
2661
+ * @deprecated Use `sessionSettings` instead.
2662
+ */
2663
+ callSettings: CallSettings | Partial<ConfigStateMobile & ConfigStateBoth>;
2650
2664
  sessionSettings?: CallSettings | Partial<ConfigStateMobile & ConfigStateBoth>;
2651
2665
  }
2652
2666
  declare function AppReactNativeSDK(props: AppProps): React.JSX.Element;
package/dist/index.js CHANGED
@@ -566,6 +566,13 @@ var SessionMethodsCore = class {
566
566
  leaveSession();
567
567
  }
568
568
  /**
569
+ * Ends the current session for all participants.
570
+ * This will terminate the conference and disconnect everyone.
571
+ */
572
+ static endSessionForAll() {
573
+ leaveSession({ shouldEndSession: true });
574
+ }
575
+ /**
569
576
  * Raises the user's virtual hand in the call.
570
577
  */
571
578
  static raiseHand() {
@@ -1872,6 +1879,10 @@ const initialState$3 = {
1872
1879
  visibleParticipants: {
1873
1880
  startIndex: 0,
1874
1881
  endIndex: 0
1882
+ },
1883
+ sidebarVisibleParticipants: {
1884
+ startIndex: 0,
1885
+ endIndex: 0
1875
1886
  }
1876
1887
  };
1877
1888
  const useBaseStore = (0, zustand.create)()((0, zustand_middleware.subscribeWithSelector)((0, zustand_middleware.persist)((0, zustand_middleware.combine)(initialState$3, (set, get$1) => ({
@@ -2397,8 +2408,10 @@ function setReceiverConstraintsInternal() {
2397
2408
  }
2398
2409
  });
2399
2410
  } else if (layout$1 === "SIDEBAR") {
2400
- const participants = useParticipantStore.getState().participants;
2401
- participants.forEach((participant) => {
2411
+ const { startIndex, endIndex } = useBaseStore.getState().sidebarVisibleParticipants;
2412
+ const allParticipants = getAllParticipants();
2413
+ const visibleSidebarParticipants = allParticipants.slice(startIndex, endIndex);
2414
+ visibleSidebarParticipants.forEach((participant) => {
2402
2415
  const videoSources$1 = participant.sources?.get("video");
2403
2416
  if (videoSources$1) {
2404
2417
  Array.from(videoSources$1.keys()).forEach((source) => {
@@ -2424,6 +2437,9 @@ const setReceiverConstraints = debounce(setReceiverConstraintsInternal, 200);
2424
2437
  useBaseStore.subscribe((state) => state.visibleParticipants, () => {
2425
2438
  setReceiverConstraints();
2426
2439
  });
2440
+ useBaseStore.subscribe((state) => state.sidebarVisibleParticipants, () => {
2441
+ setReceiverConstraints();
2442
+ });
2427
2443
  useBaseStore.subscribe((state) => state.layout, () => {
2428
2444
  setReceiverConstraints();
2429
2445
  });
@@ -2522,7 +2538,6 @@ var ConferenceListener = class {
2522
2538
  }
2523
2539
  onConferenceJoinInProgress() {}
2524
2540
  onConferenceFailed(errorName, error, message) {
2525
- console.log();
2526
2541
  if (errorName === lib_jitsi_meet.default.errors.conference.CONFERENCE_DESTROYED) {
2527
2542
  leaveSession({ forceLeave: true });
2528
2543
  return;
@@ -2562,6 +2577,7 @@ var ConferenceListener = class {
2562
2577
  }
2563
2578
  onConnectionEstablished() {
2564
2579
  useConferenceStore.setState({ conferenceStatus: "joined" });
2580
+ setTimeout(setReceiverConstraints, 500);
2565
2581
  }
2566
2582
  onConnectionInterrupted() {
2567
2583
  useConferenceStore.setState({ conferenceStatus: "interrupted" });
@@ -3072,7 +3088,7 @@ const sessionMutex = new Mutex();
3072
3088
  function leaveSession(options = {}) {
3073
3089
  return sessionMutex.run(async () => {
3074
3090
  const isPeerCall = useConfigStore.getState().isPeerCall;
3075
- const shouldEnd = isPeerCall && !options.forceLeave;
3091
+ const shouldEnd = options.shouldEndSession || isPeerCall && !options.forceLeave;
3076
3092
  if (shouldEnd) {
3077
3093
  useConferenceStore.getState().endConference();
3078
3094
  return;
@@ -7068,6 +7084,7 @@ async function callVerifyTokenAPI({ appId, region, calltoken, baseURL }) {
7068
7084
  function AppReactNativeSDK(props) {
7069
7085
  const [internalSettings, setInternalSettings] = react.default.useState(null);
7070
7086
  const [infoMessage, setInfoMessage] = react.default.useState(null);
7087
+ const sessionSettings = props.sessionSettings ?? props.callSettings ?? {};
7071
7088
  (0, react.useEffect)(() => {
7072
7089
  return eventBus.subscribe("onConnectionClosed", () => {
7073
7090
  setTimeout(() => {
@@ -7077,7 +7094,7 @@ function AppReactNativeSDK(props) {
7077
7094
  }, []);
7078
7095
  (0, react.useEffect)(() => {
7079
7096
  const listeners = [];
7080
- const cs = props.sessionSettings ?? {};
7097
+ const cs = sessionSettings ?? {};
7081
7098
  if (cs.listener?.onUserJoined) {
7082
7099
  listeners.push(CometChatCalls.addEventListener("onParticipantJoined", cs.listener.onUserJoined));
7083
7100
  }
@@ -7115,7 +7132,7 @@ function AppReactNativeSDK(props) {
7115
7132
  listener();
7116
7133
  });
7117
7134
  };
7118
- }, [props.sessionSettings]);
7135
+ }, [sessionSettings]);
7119
7136
  (0, react.useEffect)(() => {
7120
7137
  callVerifyTokenAPI({
7121
7138
  appId: CometChatCalls.appSettings?.appId || "",
@@ -7145,8 +7162,8 @@ function AppReactNativeSDK(props) {
7145
7162
  });
7146
7163
  }
7147
7164
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(index_native_default, { sessionSettings: {
7148
- ...props.sessionSettings,
7149
- ...convertLegacyCallSettingsToV5Props(props?.sessionSettings ?? {}),
7165
+ ...sessionSettings,
7166
+ ...convertLegacyCallSettingsToV5Props(sessionSettings ?? {}),
7150
7167
  internalSettings
7151
7168
  } });
7152
7169
  }
package/dist/index.mjs CHANGED
@@ -534,6 +534,13 @@ var SessionMethodsCore = class {
534
534
  leaveSession();
535
535
  }
536
536
  /**
537
+ * Ends the current session for all participants.
538
+ * This will terminate the conference and disconnect everyone.
539
+ */
540
+ static endSessionForAll() {
541
+ leaveSession({ shouldEndSession: true });
542
+ }
543
+ /**
537
544
  * Raises the user's virtual hand in the call.
538
545
  */
539
546
  static raiseHand() {
@@ -1840,6 +1847,10 @@ const initialState$3 = {
1840
1847
  visibleParticipants: {
1841
1848
  startIndex: 0,
1842
1849
  endIndex: 0
1850
+ },
1851
+ sidebarVisibleParticipants: {
1852
+ startIndex: 0,
1853
+ endIndex: 0
1843
1854
  }
1844
1855
  };
1845
1856
  const useBaseStore = create()(subscribeWithSelector(persist(combine(initialState$3, (set, get$1) => ({
@@ -2365,8 +2376,10 @@ function setReceiverConstraintsInternal() {
2365
2376
  }
2366
2377
  });
2367
2378
  } else if (layout$1 === "SIDEBAR") {
2368
- const participants = useParticipantStore.getState().participants;
2369
- participants.forEach((participant) => {
2379
+ const { startIndex, endIndex } = useBaseStore.getState().sidebarVisibleParticipants;
2380
+ const allParticipants = getAllParticipants();
2381
+ const visibleSidebarParticipants = allParticipants.slice(startIndex, endIndex);
2382
+ visibleSidebarParticipants.forEach((participant) => {
2370
2383
  const videoSources$1 = participant.sources?.get("video");
2371
2384
  if (videoSources$1) {
2372
2385
  Array.from(videoSources$1.keys()).forEach((source) => {
@@ -2392,6 +2405,9 @@ const setReceiverConstraints = debounce(setReceiverConstraintsInternal, 200);
2392
2405
  useBaseStore.subscribe((state) => state.visibleParticipants, () => {
2393
2406
  setReceiverConstraints();
2394
2407
  });
2408
+ useBaseStore.subscribe((state) => state.sidebarVisibleParticipants, () => {
2409
+ setReceiverConstraints();
2410
+ });
2395
2411
  useBaseStore.subscribe((state) => state.layout, () => {
2396
2412
  setReceiverConstraints();
2397
2413
  });
@@ -2490,7 +2506,6 @@ var ConferenceListener = class {
2490
2506
  }
2491
2507
  onConferenceJoinInProgress() {}
2492
2508
  onConferenceFailed(errorName, error, message) {
2493
- console.log();
2494
2509
  if (errorName === JitsiMeetJS.errors.conference.CONFERENCE_DESTROYED) {
2495
2510
  leaveSession({ forceLeave: true });
2496
2511
  return;
@@ -2530,6 +2545,7 @@ var ConferenceListener = class {
2530
2545
  }
2531
2546
  onConnectionEstablished() {
2532
2547
  useConferenceStore.setState({ conferenceStatus: "joined" });
2548
+ setTimeout(setReceiverConstraints, 500);
2533
2549
  }
2534
2550
  onConnectionInterrupted() {
2535
2551
  useConferenceStore.setState({ conferenceStatus: "interrupted" });
@@ -3040,7 +3056,7 @@ const sessionMutex = new Mutex();
3040
3056
  function leaveSession(options = {}) {
3041
3057
  return sessionMutex.run(async () => {
3042
3058
  const isPeerCall = useConfigStore.getState().isPeerCall;
3043
- const shouldEnd = isPeerCall && !options.forceLeave;
3059
+ const shouldEnd = options.shouldEndSession || isPeerCall && !options.forceLeave;
3044
3060
  if (shouldEnd) {
3045
3061
  useConferenceStore.getState().endConference();
3046
3062
  return;
@@ -7036,6 +7052,7 @@ async function callVerifyTokenAPI({ appId, region, calltoken, baseURL }) {
7036
7052
  function AppReactNativeSDK(props) {
7037
7053
  const [internalSettings, setInternalSettings] = React.useState(null);
7038
7054
  const [infoMessage, setInfoMessage] = React.useState(null);
7055
+ const sessionSettings = props.sessionSettings ?? props.callSettings ?? {};
7039
7056
  useEffect(() => {
7040
7057
  return eventBus.subscribe("onConnectionClosed", () => {
7041
7058
  setTimeout(() => {
@@ -7045,7 +7062,7 @@ function AppReactNativeSDK(props) {
7045
7062
  }, []);
7046
7063
  useEffect(() => {
7047
7064
  const listeners = [];
7048
- const cs = props.sessionSettings ?? {};
7065
+ const cs = sessionSettings ?? {};
7049
7066
  if (cs.listener?.onUserJoined) {
7050
7067
  listeners.push(CometChatCalls.addEventListener("onParticipantJoined", cs.listener.onUserJoined));
7051
7068
  }
@@ -7083,7 +7100,7 @@ function AppReactNativeSDK(props) {
7083
7100
  listener();
7084
7101
  });
7085
7102
  };
7086
- }, [props.sessionSettings]);
7103
+ }, [sessionSettings]);
7087
7104
  useEffect(() => {
7088
7105
  callVerifyTokenAPI({
7089
7106
  appId: CometChatCalls.appSettings?.appId || "",
@@ -7113,8 +7130,8 @@ function AppReactNativeSDK(props) {
7113
7130
  });
7114
7131
  }
7115
7132
  return /* @__PURE__ */ jsx(index_native_default, { sessionSettings: {
7116
- ...props.sessionSettings,
7117
- ...convertLegacyCallSettingsToV5Props(props?.sessionSettings ?? {}),
7133
+ ...sessionSettings,
7134
+ ...convertLegacyCallSettingsToV5Props(sessionSettings ?? {}),
7118
7135
  internalSettings
7119
7136
  } });
7120
7137
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cometchat/calls-sdk-react-native",
3
- "version": "5.0.0-beta.5",
3
+ "version": "5.0.0-beta.7",
4
4
  "description": "CometChat Calls SDK for React Native provides voice and video calling capabilities for React Native applications.",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
@@ -13,17 +13,17 @@
13
13
  "cometchat-calls-sdk-react-native.podspec"
14
14
  ],
15
15
  "scripts": {},
16
- "dependencies": {
16
+ "dependencies": {},
17
+ "devDependencies": {},
18
+ "peerDependencies": {
17
19
  "@xmldom/xmldom": "^0.8.11",
18
20
  "abab": "^2.0.6",
19
- "clsx": "^2.1.1",
20
21
  "promise.allsettled": "^1.0.7",
21
22
  "text-encoding": "^0.7.0",
22
23
  "valibot": "^1.2.0",
23
- "lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1790.0.0+311766e3/lib-jitsi-meet.tgz"
24
+ "lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1790.0.0+311766e3/lib-jitsi-meet.tgz",
25
+ "zustand": "^5.0.4"
24
26
  },
25
- "devDependencies": {},
26
- "peerDependencies": {},
27
27
  "engines": {
28
28
  "node": ">=18"
29
29
  },