@videosdk.live/react-sdk 0.1.82 → 0.1.84

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.
@@ -0,0 +1,28 @@
1
+ export class DeviceInfo extends MediaDeviceInfo {
2
+ }
3
+ export class CameraDeviceInfo extends DeviceInfo {
4
+ }
5
+ export class MicrophoneDeviceInfo extends DeviceInfo {
6
+ }
7
+ export class PlaybackDeviceInfo extends DeviceInfo {
8
+ }
9
+ declare class MediaDeviceInfo {
10
+ constructor(deviceId: any, groupId: any, kind: any, label: any);
11
+ /**
12
+ * @type {string}
13
+ */
14
+ deviceId: string;
15
+ /**
16
+ * @type {string}
17
+ */
18
+ groupId: string;
19
+ /**
20
+ * @type {string}
21
+ */
22
+ kind: string;
23
+ /**
24
+ * @type {string}
25
+ */
26
+ label: string;
27
+ }
28
+ export {};
@@ -6,6 +6,13 @@
6
6
  // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7
7
 
8
8
  import { Connection } from './connection';
9
+ import {
10
+ CameraDeviceInfo,
11
+ DeviceInfo,
12
+ MicrophoneDeviceInfo,
13
+ PlaybackDeviceInfo
14
+ } from './deviceInfo';
15
+ import { Permission } from './permission';
9
16
  import { Meeting } from './meeting';
10
17
  import { Participant } from './participant';
11
18
  import { Stream } from './stream';
@@ -62,7 +69,7 @@ import { Stream } from './stream';
62
69
  * - This is a boolean flag, when set to true, allows a participant to join a meeting directly without explicitly calling the join() function.
63
70
  *
64
71
  * - This is an OPTIONAL parameter. By default, it is set to false meaning, user has to manually call the join().
65
- *
72
+ *
66
73
  */
67
74
  export function MeetingProvider({
68
75
  children,
@@ -70,7 +77,7 @@ export function MeetingProvider({
70
77
  token,
71
78
  joinWithoutUserInteraction,
72
79
  reinitialiseMeetingOnConfigChange: _reinitialiseMeetingOnConfigChange,
73
- deviceInfo,
80
+ deviceInfo
74
81
  }: {
75
82
  children: any;
76
83
  config: {
@@ -188,7 +195,7 @@ export function MeetingConsumer({
188
195
  onRecordingStateChanged,
189
196
  onLivestreamStateChanged,
190
197
  onMeetingStateChanged,
191
- onParticipantModeChanged,
198
+ onParticipantModeChanged
192
199
  }: {
193
200
  children: any;
194
201
  onParticipantJoined?: (participant: Participant) => void;
@@ -200,7 +207,7 @@ export function MeetingConsumer({
200
207
  participantId,
201
208
  name,
202
209
  allow,
203
- deny,
210
+ deny
204
211
  }: {
205
212
  participantId: string;
206
213
  name: string;
@@ -209,7 +216,7 @@ export function MeetingConsumer({
209
216
  }) => void;
210
217
  onEntryResponded?: ({
211
218
  participantId,
212
- decision,
219
+ decision
213
220
  }: {
214
221
  participantId: string;
215
222
  decision: string;
@@ -232,7 +239,7 @@ export function MeetingConsumer({
232
239
  onWebcamRequested?: ({
233
240
  participantId,
234
241
  accept,
235
- reject,
242
+ reject
236
243
  }: {
237
244
  participantId: string;
238
245
  accept: () => void;
@@ -241,7 +248,7 @@ export function MeetingConsumer({
241
248
  onMicRequested?: ({
242
249
  participantId,
243
250
  accept,
244
- reject,
251
+ reject
245
252
  }: {
246
253
  participantId: string;
247
254
  accept: () => void;
@@ -250,7 +257,7 @@ export function MeetingConsumer({
250
257
  onPinStateChanged?: ({
251
258
  participantId,
252
259
  state,
253
- pinnedBy,
260
+ pinnedBy
254
261
  }: {
255
262
  participantId: string;
256
263
  state: { share: boolean; cam: boolean };
@@ -266,56 +273,88 @@ export function MeetingConsumer({
266
273
  status,
267
274
  downstreamUrl,
268
275
  playbackHlsUrl,
269
- livestreamUrl,
276
+ livestreamUrl
270
277
  }: {
271
278
  status:
272
- | 'HLS_STARTING'
273
- | 'HLS_STARTED'
274
- | 'HLS_PLAYABLE'
275
- | 'HLS_STOPPING'
276
- | 'HLS_STOPPED';
279
+ | 'HLS_STARTING'
280
+ | 'HLS_STARTED'
281
+ | 'HLS_PLAYABLE'
282
+ | 'HLS_STOPPING'
283
+ | 'HLS_STOPPED';
277
284
  downstreamUrl?: string;
278
285
  playbackHlsUrl?: string;
279
286
  livestreamUrl?: string;
280
287
  }) => void;
281
288
  onRecordingStateChanged?: ({
282
- status,
289
+ status
283
290
  }: {
284
291
  status:
285
- | 'RECORDING_STARTING'
286
- | 'RECORDING_STARTED'
287
- | 'RECORDING_STOPPING'
288
- | 'RECORDING_STOPPED';
292
+ | 'RECORDING_STARTING'
293
+ | 'RECORDING_STARTED'
294
+ | 'RECORDING_STOPPING'
295
+ | 'RECORDING_STOPPED';
289
296
  }) => void;
290
297
  onLivestreamStateChanged?: ({
291
- status,
298
+ status
292
299
  }: {
293
300
  status:
294
- | 'LIVESTREAM_STARTING'
295
- | 'LIVESTREAM_STARTED'
296
- | 'LIVESTREAM_STOPPING'
297
- | 'LIVESTREAM_STOPPED';
301
+ | 'LIVESTREAM_STARTING'
302
+ | 'LIVESTREAM_STARTED'
303
+ | 'LIVESTREAM_STOPPING'
304
+ | 'LIVESTREAM_STOPPED';
298
305
  }) => void;
299
306
  onMeetingStateChanged?: ({
300
- state,
307
+ state
301
308
  }: {
302
309
  state:
303
- | 'CONNECTING'
304
- | 'CONNECTED'
305
- | 'FAILED'
306
- | 'DISCONNECTED'
307
- | 'CLOSING'
308
- | 'CLOSED';
310
+ | 'CONNECTING'
311
+ | 'CONNECTED'
312
+ | 'FAILED'
313
+ | 'DISCONNECTED'
314
+ | 'CLOSING'
315
+ | 'CLOSED';
309
316
  }) => void;
310
317
  onParticipantModeChanged?: ({
311
318
  participantId,
312
- mode,
319
+ mode
313
320
  }: {
314
321
  participantId: string;
315
322
  mode: 'CONFERENCE' | 'VIEWER';
316
323
  }) => void;
317
324
  }): any;
318
325
 
326
+ /**
327
+ *
328
+ * ---
329
+ * @param onDeviceChanged - It's a callback which gets triggered whenever a media device such as a camera, microphone, or speaker is connected to or removed from the system.
330
+ *
331
+ * **Code Example :**
332
+ * ```js
333
+ * function onDeviceChanged(devices) {
334
+ * console.log("onDeviceChanged", devices);
335
+ * }
336
+ * const {} = useMediaDevice({
337
+ * onDeviceChanged
338
+ * });
339
+ * ```
340
+ * ---
341
+ * @returns This will returns methods and events associated with media devices and permissions. You can refer this [API Reference](https://docs.videosdk.live/react/api/sdk-reference/use-mediaDevice/introduction)
342
+ */
343
+ export function useMediaDevice({
344
+ onDeviceChanged
345
+ }?: {
346
+ onDeviceChanged?: (devices: Promise<Array<DeviceInfo>>) => void;
347
+ }): {
348
+ getDevices: () => Promise<Array<DeviceInfo>>;
349
+ getCameras: () => Promise<Array<CameraDeviceInfo>>;
350
+ getMicrophones: () => Promise<Array<MicrophoneDeviceInfo>>;
351
+ getPlaybackDevices: () => Promise<Array<PlaybackDeviceInfo>>;
352
+ checkPermissions: (permissions?: Permission) => Promise<Map<string, boolean>>;
353
+ requestPermission: (
354
+ permissions?: Permission
355
+ ) => Promise<Map<string, boolean>>;
356
+ };
357
+
319
358
  /**
320
359
  *
321
360
  * @param participantId - Id of the participant.
@@ -380,14 +419,14 @@ export function useParticipant(
380
419
  onStreamEnabled,
381
420
  onStreamDisabled,
382
421
  onMediaStatusChanged,
383
- onVideoQualityChanged,
422
+ onVideoQualityChanged
384
423
  }?: {
385
424
  onStreamDisabled?: (stream: Stream) => void;
386
425
  onStreamEnabled?: (stream: Stream) => void;
387
426
  onMediaStatusChanged?: ({
388
427
  kind,
389
428
  peerId,
390
- newStatus,
429
+ newStatus
391
430
  }: {
392
431
  kind: 'audio' | 'video';
393
432
  peerId: string;
@@ -396,13 +435,13 @@ export function useParticipant(
396
435
  onVideoQualityChanged?: ({
397
436
  peerId,
398
437
  prevQuality,
399
- currentQuality,
438
+ currentQuality
400
439
  }: {
401
440
  peerId: string;
402
441
  prevQuality: 'low' | 'med' | 'high';
403
442
  currentQuality: 'low' | 'med' | 'high';
404
443
  }) => void;
405
- },
444
+ }
406
445
  ): {
407
446
  displayName: string;
408
447
  participant: Participant;
@@ -429,13 +468,19 @@ export function useParticipant(
429
468
  enableWebcam: () => void;
430
469
  disableWebcam: () => void;
431
470
  remove: () => void;
432
- captureImage: ({ height, width }: { height?: number, width?: number }) => Promise<string | null>;
471
+ captureImage: ({
472
+ height,
473
+ width
474
+ }: {
475
+ height?: number;
476
+ width?: number;
477
+ }) => Promise<string | null>;
433
478
  pin: (data: 'SHARE_AND_CAM' | 'CAM' | 'SHARE') => void;
434
479
  unpin: (data: 'SHARE_AND_CAM' | 'CAM' | 'SHARE') => void;
435
480
  switchTo: ({
436
481
  meetingId,
437
482
  payload,
438
- token,
483
+ token
439
484
  }: {
440
485
  meetingId: string;
441
486
  payload: string;
@@ -592,7 +637,7 @@ export function useMeeting({
592
637
  onRecordingStateChanged,
593
638
  onLivestreamStateChanged,
594
639
  onMeetingStateChanged,
595
- onParticipantModeChanged,
640
+ onParticipantModeChanged
596
641
  }?: {
597
642
  onParticipantJoined?: (participant: Participant) => void;
598
643
  onParticipantLeft?: (participant: Participant) => void;
@@ -603,7 +648,7 @@ export function useMeeting({
603
648
  participantId,
604
649
  name,
605
650
  allow,
606
- deny,
651
+ deny
607
652
  }: {
608
653
  participantId: string;
609
654
  name: string;
@@ -612,7 +657,7 @@ export function useMeeting({
612
657
  }) => void;
613
658
  onEntryResponded?: ({
614
659
  participantId,
615
- decision,
660
+ decision
616
661
  }: {
617
662
  participantId: string;
618
663
  decision: string;
@@ -635,7 +680,7 @@ export function useMeeting({
635
680
  onWebcamRequested?: ({
636
681
  participantId,
637
682
  accept,
638
- reject,
683
+ reject
639
684
  }: {
640
685
  participantId: string;
641
686
  accept: () => void;
@@ -644,7 +689,7 @@ export function useMeeting({
644
689
  onMicRequested?: ({
645
690
  participantId,
646
691
  accept,
647
- reject,
692
+ reject
648
693
  }: {
649
694
  participantId: string;
650
695
  accept: () => void;
@@ -653,7 +698,7 @@ export function useMeeting({
653
698
  onPinStateChanged?: ({
654
699
  participantId,
655
700
  state,
656
- pinnedBy,
701
+ pinnedBy
657
702
  }: {
658
703
  participantId: string;
659
704
  state: { share: boolean; cam: boolean };
@@ -669,50 +714,50 @@ export function useMeeting({
669
714
  status,
670
715
  downstreamUrl,
671
716
  playbackHlsUrl,
672
- livestreamUrl,
717
+ livestreamUrl
673
718
  }: {
674
719
  status:
675
- | 'HLS_STARTING'
676
- | 'HLS_STARTED'
677
- | 'HLS_PLAYABLE'
678
- | 'HLS_STOPPING'
679
- | 'HLS_STOPPED';
720
+ | 'HLS_STARTING'
721
+ | 'HLS_STARTED'
722
+ | 'HLS_PLAYABLE'
723
+ | 'HLS_STOPPING'
724
+ | 'HLS_STOPPED';
680
725
  downstreamUrl?: string;
681
726
  playbackHlsUrl?: string;
682
727
  livestreamUrl?: string;
683
728
  }) => void;
684
729
  onRecordingStateChanged?: ({
685
- status,
730
+ status
686
731
  }: {
687
732
  status:
688
- | 'RECORDING_STARTING'
689
- | 'RECORDING_STARTED'
690
- | 'RECORDING_STOPPING'
691
- | 'RECORDING_STOPPED';
733
+ | 'RECORDING_STARTING'
734
+ | 'RECORDING_STARTED'
735
+ | 'RECORDING_STOPPING'
736
+ | 'RECORDING_STOPPED';
692
737
  }) => void;
693
738
  onLivestreamStateChanged?: ({
694
- status,
739
+ status
695
740
  }: {
696
741
  status:
697
- | 'LIVESTREAM_STARTING'
698
- | 'LIVESTREAM_STARTED'
699
- | 'LIVESTREAM_STOPPING'
700
- | 'LIVESTREAM_STOPPED';
742
+ | 'LIVESTREAM_STARTING'
743
+ | 'LIVESTREAM_STARTED'
744
+ | 'LIVESTREAM_STOPPING'
745
+ | 'LIVESTREAM_STOPPED';
701
746
  }) => void;
702
747
  onMeetingStateChanged?: ({
703
- state,
748
+ state
704
749
  }: {
705
750
  state:
706
- | 'CONNECTING'
707
- | 'CONNECTED'
708
- | 'FAILED'
709
- | 'DISCONNECTED'
710
- | 'CLOSING'
711
- | 'CLOSED';
751
+ | 'CONNECTING'
752
+ | 'CONNECTED'
753
+ | 'FAILED'
754
+ | 'DISCONNECTED'
755
+ | 'CLOSING'
756
+ | 'CLOSED';
712
757
  }) => void;
713
758
  onParticipantModeChanged?: ({
714
759
  participantId,
715
- mode,
760
+ mode
716
761
  }: {
717
762
  participantId: string;
718
763
  mode: 'CONFERENCE' | 'VIEWER';
@@ -769,7 +814,7 @@ export function useMeeting({
769
814
  theme: 'DEFAULT' | 'DARK' | 'LIGHT';
770
815
  quality: 'low' | 'med' | 'high';
771
816
  mode: 'video-and-audio' | 'audio';
772
- },
817
+ }
773
818
  ) => void;
774
819
  stopRecording: () => void;
775
820
  startLiveStream: (
@@ -784,7 +829,7 @@ export function useMeeting({
784
829
  gridSize: number;
785
830
  };
786
831
  theme: 'DEFAULT' | 'DARK' | 'LIGHT';
787
- },
832
+ }
788
833
  ) => void;
789
834
  stopLiveStream: () => void;
790
835
  startHls: (config?: {
@@ -822,7 +867,7 @@ export function useMeeting({
822
867
  seekVideo: ({ currentTime }: { currentTime: number }) => void;
823
868
  connectTo: ({
824
869
  meetingId,
825
- payload,
870
+ payload
826
871
  }: {
827
872
  meetingId: string;
828
873
  payload: string;
@@ -861,7 +906,7 @@ export function usePubSub(
861
906
  topic: string,
862
907
  {
863
908
  onMessageReceived,
864
- onOldMessagesReceived,
909
+ onOldMessagesReceived
865
910
  }?: {
866
911
  onMessageReceived?: (message: {
867
912
  id: string;
@@ -881,20 +926,20 @@ export function usePubSub(
881
926
  timestamp: string;
882
927
  topic: string;
883
928
  payload: object;
884
- }>,
929
+ }>
885
930
  ) => void;
886
- },
931
+ }
887
932
  ): {
888
933
  publish: (
889
934
  message: string,
890
935
  {
891
936
  persist,
892
- sendOnly,
937
+ sendOnly
893
938
  }: {
894
939
  persist: boolean;
895
940
  sendOnly?: Array<String>;
896
941
  },
897
- payload?: object,
942
+ payload?: object
898
943
  ) => void;
899
944
  messages: Array<{
900
945
  id: string;
@@ -908,19 +953,25 @@ export function usePubSub(
908
953
  };
909
954
 
910
955
  export function useFile(): {
911
- uploadBase64File: ({ base64Data, token, fileName }: {
956
+ uploadBase64File: ({
957
+ base64Data,
958
+ token,
959
+ fileName
960
+ }: {
912
961
  base64Data: string;
913
962
  token: string;
914
963
  fileName: string;
915
964
  }) => Promise<string | null>;
916
965
 
917
- fetchBase64File: ({ url, token }: {
966
+ fetchBase64File: ({
967
+ url,
968
+ token
969
+ }: {
918
970
  url: string;
919
971
  token: string;
920
972
  }) => Promise<string | null>;
921
973
  };
922
974
 
923
-
924
975
  /**
925
976
  * @param microphoneId - It will be the id of the mic from which the audio should be captured.
926
977
  * ---
@@ -956,23 +1007,23 @@ export function useFile(): {
956
1007
  export function createMicrophoneAudioTrack({
957
1008
  noiseConfig,
958
1009
  encoderConfig,
959
- microphoneId,
1010
+ microphoneId
960
1011
  }: {
961
1012
  noiseConfig?:
962
- | {
963
- echoCancellation: boolean;
964
- autoGainControl: boolean;
965
- noiseSuppression: boolean;
966
- }
967
- | undefined;
1013
+ | {
1014
+ echoCancellation: boolean;
1015
+ autoGainControl: boolean;
1016
+ noiseSuppression: boolean;
1017
+ }
1018
+ | undefined;
968
1019
  encoderConfig?:
969
- | 'speech_low_quality'
970
- | 'speech_standard'
971
- | 'music_standard'
972
- | 'standard_stereo'
973
- | 'high_quality'
974
- | 'high_quality_stereo'
975
- | undefined;
1020
+ | 'speech_low_quality'
1021
+ | 'speech_standard'
1022
+ | 'music_standard'
1023
+ | 'standard_stereo'
1024
+ | 'high_quality'
1025
+ | 'high_quality_stereo'
1026
+ | undefined;
976
1027
  microphoneId?: string | undefined;
977
1028
  }): Promise<MediaStream>;
978
1029
 
@@ -1015,29 +1066,29 @@ export function createCameraVideoTrack({
1015
1066
  encoderConfig,
1016
1067
  facingMode,
1017
1068
  optimizationMode,
1018
- multiStream,
1069
+ multiStream
1019
1070
  }: {
1020
1071
  cameraId?: string | undefined;
1021
1072
  encoderConfig?:
1022
- | 'h90p_w160p'
1023
- | 'h180p_w320p'
1024
- | 'h216p_w384p'
1025
- | 'h360p_w640p'
1026
- | 'h540p_w960p'
1027
- | 'h720p_w1280p'
1028
- | 'h1080p_w1920p'
1029
- | 'h1440p_w2560p'
1030
- | 'h2160p_w3840p'
1031
- | 'h120p_w160p'
1032
- | 'h180p_w240p'
1033
- | 'h240p_w320p'
1034
- | 'h360p_w480p'
1035
- | 'h480p_w640p'
1036
- | 'h540p_w720p'
1037
- | 'h720p_w960p'
1038
- | 'h1080p_w1440p'
1039
- | 'h1440p_w1920p'
1040
- | undefined;
1073
+ | 'h90p_w160p'
1074
+ | 'h180p_w320p'
1075
+ | 'h216p_w384p'
1076
+ | 'h360p_w640p'
1077
+ | 'h540p_w960p'
1078
+ | 'h720p_w1280p'
1079
+ | 'h1080p_w1920p'
1080
+ | 'h1440p_w2560p'
1081
+ | 'h2160p_w3840p'
1082
+ | 'h120p_w160p'
1083
+ | 'h180p_w240p'
1084
+ | 'h240p_w320p'
1085
+ | 'h360p_w480p'
1086
+ | 'h480p_w640p'
1087
+ | 'h540p_w720p'
1088
+ | 'h720p_w960p'
1089
+ | 'h1080p_w1440p'
1090
+ | 'h1440p_w1920p'
1091
+ | undefined;
1041
1092
  facingMode?: 'user' | 'environment' | undefined;
1042
1093
  optimizationMode?: 'text' | 'motion' | 'detail' | undefined;
1043
1094
  multiStream?: boolean;
@@ -1072,19 +1123,42 @@ export function createCameraVideoTrack({
1072
1123
  export function createScreenShareVideoTrack({
1073
1124
  encoderConfig,
1074
1125
  optimizationMode,
1075
- withAudio,
1126
+ withAudio
1076
1127
  }: {
1077
1128
  encoderConfig?:
1078
- | 'h360p_30fps'
1079
- | 'h720p_5fps'
1080
- | 'h720p_15fps'
1081
- | 'h1080p_15fps'
1082
- | 'h1080p_30fps'
1083
- | undefined;
1129
+ | 'h360p_30fps'
1130
+ | 'h720p_5fps'
1131
+ | 'h720p_15fps'
1132
+ | 'h1080p_15fps'
1133
+ | 'h1080p_30fps'
1134
+ | undefined;
1084
1135
  optimizationMode?: 'text' | 'motion' | 'detail' | undefined;
1085
1136
  withAudio?: 'enable' | 'disable';
1086
1137
  }): Promise<MediaStream>;
1087
1138
 
1139
+ /**
1140
+ * @param timeoutDuration - This will accept the timeoutDuration.
1141
+ *
1142
+ * **Code Example**
1143
+ * ```js
1144
+ * import { getNetworkStats } from "@videosdk.live/react-sdk";
1145
+ *
1146
+ * try{
1147
+ * const options = { timeoutDuration: 45000 };
1148
+ * const networkStats = await VideoSDK.getNetworkStats(options);
1149
+ * console.log("networkStats", networkStats);
1150
+ * }catch(Ex)
1151
+ * {
1152
+ * console.log("exception",Ex);
1153
+ * }
1154
+ * ```
1155
+ */
1156
+ export function getNetworkStats({
1157
+ timeoutDuration
1158
+ }?: {
1159
+ timeoutDuration?: number | undefined;
1160
+ }): Promise<{ downloadSpeed: number; uploadSpeed: number }>;
1161
+
1088
1162
  export const Constants: {
1089
1163
  errors: {
1090
1164
  INVALID_API_KEY: number;
@@ -1137,4 +1211,10 @@ export const Constants: {
1137
1211
  CONFERENCE: string;
1138
1212
  VIEWER: string;
1139
1213
  };
1214
+ permission: {
1215
+ AUDIO: Permission;
1216
+ VIDEO: Permission;
1217
+ AUDIO_AND_VIDEO: Permission;
1218
+ };
1140
1219
  };
1220
+ export { CameraDeviceInfo, DeviceInfo, MicrophoneDeviceInfo };
@@ -0,0 +1,5 @@
1
+ export declare enum Permission {
2
+ AUDIO = "audio",
3
+ VIDEO = "video",
4
+ AUDIO_AND_VIDEO = "audio_video"
5
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@videosdk.live/react-sdk",
3
- "version": "0.1.82",
3
+ "version": "0.1.84",
4
4
  "license": "ISC",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.modern.js",
@@ -73,7 +73,7 @@
73
73
  }
74
74
  },
75
75
  "dependencies": {
76
- "@videosdk.live/js-sdk": "0.0.78",
76
+ "@videosdk.live/js-sdk": "0.0.81",
77
77
  "events": "^3.3.0"
78
78
  }
79
79
  }