@cometchat/calls-sdk-react-native 5.0.0-beta.1 → 5.0.0-beta.2

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.js CHANGED
@@ -485,59 +485,125 @@ function debounce(func, delay) {
485
485
  //#endregion
486
486
  //#region calls-sdk-core/utils/session-methods-core.ts
487
487
  var SessionMethodsCore = class {
488
+ /**
489
+ * Mutes the local user's audio during the call.
490
+ */
488
491
  static muteAudio() {
489
492
  muteAudioTrack();
490
493
  }
494
+ /**
495
+ * Unmutes the local user's audio during the call.
496
+ */
491
497
  static unmuteAudio() {
492
498
  unMuteAudioTrack();
493
499
  }
500
+ /**
501
+ * Pauses the local user's video stream.
502
+ */
494
503
  static pauseVideo() {
495
504
  pauseVideoTrack();
496
505
  }
506
+ /**
507
+ * Resumes the local user's video stream.
508
+ */
497
509
  static resumeVideo() {
498
510
  resumeVideoTrack();
499
511
  }
512
+ /**
513
+ * Local user leaves the current session.
514
+ */
500
515
  static leaveSession() {
501
516
  leaveSession();
502
517
  }
518
+ /**
519
+ * Starts sharing the user's screen with other participants.
520
+ */
503
521
  static startScreenSharing() {
504
522
  startScreenSharing();
505
523
  }
524
+ /**
525
+ * Stops the ongoing screen sharing session.
526
+ */
506
527
  static stopScreenSharing() {
507
528
  stopScreenSharing();
508
529
  }
530
+ /**
531
+ * Raises the user's virtual hand in the call.
532
+ */
509
533
  static raiseHand() {
510
534
  raisedHandLocal();
511
535
  }
536
+ /**
537
+ * Lowers the user's virtual hand in the call.
538
+ */
512
539
  static lowerHand() {
513
540
  lowerHandLocal();
514
541
  }
542
+ /**
543
+ * Switches between the front and rear camera.
544
+ */
515
545
  static switchCamera() {
516
546
  switchCamera();
517
547
  }
548
+ /**
549
+ * Sets the layout type for the call.
550
+ * @param layout - The type of layout to set (tile, sidebar or spotlight).
551
+ */
518
552
  static setLayout(layout$1) {
519
553
  setLayout(layout$1);
520
554
  }
555
+ /**
556
+ * Starts recording the call.
557
+ */
521
558
  static startRecording() {}
559
+ /**
560
+ * Stops the ongoing call recording.
561
+ */
522
562
  static stopRecording() {}
563
+ /**
564
+ * Enables Picture-in-Picture (PIP) layout during the call.
565
+ */
523
566
  static enablePictureInPictureLayout() {
524
567
  enablePictureInPictureLayout();
525
568
  }
569
+ /**
570
+ * Disables Picture-in-Picture (PIP) layout.
571
+ */
526
572
  static disablePictureInPictureLayout() {
527
573
  disablePictureInPictureLayout();
528
574
  }
575
+ /**
576
+ * Pins a participant's video to focus on them.
577
+ * @param participantId - The ID of the participant to pin.
578
+ * @param type - The type of the participant.
579
+ */
529
580
  static pinParticipant(participantId, type) {
530
581
  pinParticipant(participantId, type);
531
582
  }
583
+ /**
584
+ * Unpins a participant's video.
585
+ */
532
586
  static unpinParticipant() {
533
587
  unpinParticipant();
534
588
  }
589
+ /**
590
+ * Mutes the audio of a specific participant.
591
+ * @param participantId - The ID of the participant to mute.
592
+ */
535
593
  static muteParticipant(participantId) {
536
594
  muteParticipant(participantId);
537
595
  }
596
+ /**
597
+ * Pauses the video stream of a specific participant.
598
+ * @param participantId - The ID of the participant whose video to pause.
599
+ */
538
600
  static pauseParticipantVideo(participantId) {
539
601
  pauseParticipantVideo(participantId);
540
602
  }
603
+ /**
604
+ * Sets the unread message count displayed on the chat button.
605
+ * @param count - The number of unread messages.
606
+ */
541
607
  static setChatButtonUnreadCount(count) {
542
608
  setChatButtonUnreadCount(count);
543
609
  }
@@ -554,7 +620,7 @@ var SessionMethodsCore = class {
554
620
  this.stopScreenSharing();
555
621
  }
556
622
  /**
557
- * @deprecated switchToVideoCall is deprecated and not supported
623
+ * @deprecated switchToVideoCall is deprecated and not supported.
558
624
  */
559
625
  static switchToVideoCall() {
560
626
  console.error("switchToVideoCall method deprecated and not supported.");
@@ -10579,6 +10645,12 @@ var CometChatCalls = class extends SessionMethodsCore {
10579
10645
  static CallSettingsBuilder = CallSettingsBuilder;
10580
10646
  static CallAppSettingsBuilder = CallAppSettingsBuilder;
10581
10647
  static Component = AppComponent;
10648
+ /**
10649
+ * Initializes the CometChat Calls SDK with the provided app settings.
10650
+ * Must be called before any other SDK methods.
10651
+ * @param appSettings - The application settings for configuring the SDK.
10652
+ * @returns An object indicating success or failure with error details.
10653
+ */
10582
10654
  static async init(appSettings) {
10583
10655
  const parsedAppSettings = valibot.safeParse(CallAppSettingsSchema, appSettings);
10584
10656
  if (!parsedAppSettings.success) {
@@ -10613,6 +10685,14 @@ var CometChatCalls = class extends SessionMethodsCore {
10613
10685
  error: null
10614
10686
  };
10615
10687
  }
10688
+ /**
10689
+ * Logs in a user with their UID and an optional auth key.
10690
+ * If no auth key is provided, the one from app settings is used.
10691
+ * @param uid - The unique identifier of the user.
10692
+ * @param authKey - The authentication key. Falls back to the key provided in app settings.
10693
+ * @returns A Promise that resolves to the logged-in User object.
10694
+ * @throws {CometChatException} If login fails or validation errors occur.
10695
+ */
10616
10696
  static async login(uid, authKey) {
10617
10697
  try {
10618
10698
  if (this.loginInProgress) {
@@ -10670,6 +10750,12 @@ var CometChatCalls = class extends SessionMethodsCore {
10670
10750
  throw cometChatError;
10671
10751
  }
10672
10752
  }
10753
+ /**
10754
+ * Logs in a user directly with an auth token.
10755
+ * @param authToken - The authentication token for the user.
10756
+ * @returns A Promise that resolves to the logged-in User object.
10757
+ * @throws {CometChatException} If login fails or the token is invalid.
10758
+ */
10673
10759
  static async loginWithAuthToken(authToken) {
10674
10760
  try {
10675
10761
  if (this.loginInProgress) {
@@ -10712,6 +10798,11 @@ var CometChatCalls = class extends SessionMethodsCore {
10712
10798
  throw cometChatError;
10713
10799
  }
10714
10800
  }
10801
+ /**
10802
+ * Logs out the currently logged-in user and clears local session data.
10803
+ * @returns A Promise that resolves to a success message string.
10804
+ * @throws {CometChatException} If no user is logged in or logout fails.
10805
+ */
10715
10806
  static async logout() {
10716
10807
  try {
10717
10808
  if (!this.loggedInUser) {
@@ -10729,24 +10820,53 @@ var CometChatCalls = class extends SessionMethodsCore {
10729
10820
  throw cometChatError;
10730
10821
  }
10731
10822
  }
10823
+ /**
10824
+ * Retrieves the currently logged-in user.
10825
+ * @returns The logged-in User object, or null if no user is logged in.
10826
+ */
10732
10827
  static getLoggedInUser() {
10733
10828
  if (this.loggedInUser && typeof this.loggedInUser === "string") {
10734
10829
  this.loggedInUser = JSON.parse(this.loggedInUser);
10735
10830
  }
10736
10831
  return this.loggedInUser;
10737
10832
  }
10833
+ /**
10834
+ * Retrieves the auth token of the currently logged-in user.
10835
+ * @returns The auth token string, or null if no user is logged in.
10836
+ */
10738
10837
  static getUserAuthToken() {
10739
10838
  return this.loggedInUser?.authToken || null;
10740
10839
  }
10840
+ /**
10841
+ * Checks whether a user is currently logged in.
10842
+ * @returns True if a user is logged in with a valid auth token, false otherwise.
10843
+ */
10741
10844
  static isUserLoggedIn() {
10742
10845
  return this.loggedInUser !== null && this.loggedInUser.authToken !== undefined;
10743
10846
  }
10847
+ /**
10848
+ * Registers a login listener to receive login/logout lifecycle callbacks.
10849
+ * @param listenerId - A unique identifier for the listener.
10850
+ * @param listener - The listener object with callback methods.
10851
+ */
10744
10852
  static addLoginListener(listenerId, listener) {
10745
10853
  this.loginListeners.set(listenerId, listener);
10746
10854
  }
10855
+ /**
10856
+ * Removes a previously registered login listener.
10857
+ * @param listenerId - The unique identifier of the listener to remove.
10858
+ */
10747
10859
  static removeLoginListener(listenerId) {
10748
10860
  this.loginListeners.delete(listenerId);
10749
10861
  }
10862
+ /**
10863
+ * Generates a call token for the given session.
10864
+ * Uses the provided auth token or falls back to the logged-in user's token.
10865
+ * @param sessionId - The session ID to generate a token for.
10866
+ * @param authToken - Optional auth token. If omitted, the logged-in user's token is used.
10867
+ * @returns A Promise that resolves to an object containing the generated token.
10868
+ * @throws {CometChatException} If the session ID is missing, no auth token is available, or the SDK is not initialized.
10869
+ */
10750
10870
  static async generateToken(sessionId, authToken) {
10751
10871
  try {
10752
10872
  if (!sessionId || sessionId.trim() === "") {
@@ -10980,6 +11100,12 @@ var CometChatCalls = class extends SessionMethodsCore {
10980
11100
  }
10981
11101
  });
10982
11102
  }
11103
+ /**
11104
+ * Adds an event listener for SDK events.
11105
+ * @param eventType - The type of event to listen for.
11106
+ * @param listener - The callback function to invoke when the event fires.
11107
+ * @returns An unsubscribe function to remove the listener.
11108
+ */
10983
11109
  static addEventListener(eventType, listener) {
10984
11110
  return eventBus.subscribe(eventType, listener);
10985
11111
  }