@stream-io/video-client 1.27.4 → 1.28.0

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.es.js CHANGED
@@ -60,6 +60,20 @@ const FrameRecordingSettingsResponseModeEnum = {
60
60
  DISABLED: 'disabled',
61
61
  AUTO_ON: 'auto-on',
62
62
  };
63
+ /**
64
+ * @export
65
+ */
66
+ const IngressAudioEncodingOptionsRequestChannelsEnum = {
67
+ NUMBER_1: 1,
68
+ NUMBER_2: 2,
69
+ };
70
+ /**
71
+ * @export
72
+ */
73
+ const IngressVideoLayerRequestCodecEnum = {
74
+ H264: 'h264',
75
+ VP8: 'vp8',
76
+ };
63
77
  /**
64
78
  * @export
65
79
  */
@@ -92,6 +106,7 @@ const OwnCapability = {
92
106
  JOIN_BACKSTAGE: 'join-backstage',
93
107
  JOIN_CALL: 'join-call',
94
108
  JOIN_ENDED_CALL: 'join-ended-call',
109
+ KICK_USER: 'kick-user',
95
110
  MUTE_USERS: 'mute-users',
96
111
  PIN_FOR_EVERYONE: 'pin-for-everyone',
97
112
  READ_CALL: 'read-call',
@@ -4301,13 +4316,6 @@ class StreamVideoWriteableStateStore {
4301
4316
  */
4302
4317
  class StreamVideoReadOnlyStateStore {
4303
4318
  constructor(store) {
4304
- /**
4305
- * This method allows you the get the current value of a state variable.
4306
- *
4307
- * @param observable the observable to get the current value of.
4308
- * @returns the current value of the observable.
4309
- */
4310
- this.getCurrentValue = getCurrentValue;
4311
4319
  // convert and expose subjects as observables
4312
4320
  this.connectedUser$ = store.connectedUserSubject.asObservable();
4313
4321
  this.calls$ = store.callsSubject.asObservable();
@@ -5295,6 +5303,7 @@ class CallState {
5295
5303
  this.eventHandlers = {
5296
5304
  // these events are not updating the call state:
5297
5305
  'call.frame_recording_ready': undefined,
5306
+ 'call.kicked_user': undefined,
5298
5307
  'call.moderation_blur': undefined,
5299
5308
  'call.moderation_warning': undefined,
5300
5309
  'call.permission_request': undefined,
@@ -5304,6 +5313,7 @@ class CallState {
5304
5313
  'call.rtmp_broadcast_stopped': undefined,
5305
5314
  'call.stats_report_ready': undefined,
5306
5315
  'call.transcription_ready': undefined,
5316
+ 'call.user_feedback_submitted': undefined,
5307
5317
  'call.user_muted': undefined,
5308
5318
  'connection.error': undefined,
5309
5319
  'connection.ok': undefined,
@@ -5644,7 +5654,7 @@ const getSdkVersion = (sdk) => {
5644
5654
  return sdk ? `${sdk.major}.${sdk.minor}.${sdk.patch}` : '0.0.0-development';
5645
5655
  };
5646
5656
 
5647
- const version = "1.27.4";
5657
+ const version = "1.28.0";
5648
5658
  const [major, minor, patch] = version.split('.');
5649
5659
  let sdkInfo = {
5650
5660
  type: SdkType.PLAIN_JAVASCRIPT,
@@ -12795,6 +12805,13 @@ class Call {
12795
12805
  user_id: userId,
12796
12806
  });
12797
12807
  };
12808
+ /**
12809
+ * Kicks the user with the given `userId`.
12810
+ * @param data the kick request.
12811
+ */
12812
+ this.kickUser = async (data) => {
12813
+ return this.streamClient.post(`${this.streamClientBasePath}/kick`, data);
12814
+ };
12798
12815
  /**
12799
12816
  * Mutes the current user.
12800
12817
  *
@@ -14544,7 +14561,7 @@ class StreamClient {
14544
14561
  this.getUserAgent = () => {
14545
14562
  if (!this.cachedUserAgent) {
14546
14563
  const { clientAppIdentifier = {} } = this.options;
14547
- const { sdkName = 'js', sdkVersion = "1.27.4", ...extras } = clientAppIdentifier;
14564
+ const { sdkName = 'js', sdkVersion = "1.28.0", ...extras } = clientAppIdentifier;
14548
14565
  this.cachedUserAgent = [
14549
14566
  `stream-video-${sdkName}-v${sdkVersion}`,
14550
14567
  ...Object.entries(extras).map(([key, value]) => `${key}=${value}`),
@@ -14665,6 +14682,13 @@ class StreamClient {
14665
14682
  const getInstanceKey = (apiKey, user) => {
14666
14683
  return `${apiKey}/${user.id}`;
14667
14684
  };
14685
+ /**
14686
+ * Returns a concurrency tag for call initialization.
14687
+ * @internal
14688
+ *
14689
+ * @param cid the call cid.
14690
+ */
14691
+ const getCallInitConcurrencyTag = (cid) => `call.init-${cid}`;
14668
14692
  /**
14669
14693
  * Utility function to get the client app identifier.
14670
14694
  */
@@ -14733,7 +14757,7 @@ class StreamVideoClient {
14733
14757
  this.registerEffects = () => {
14734
14758
  if (this.effectsRegistered)
14735
14759
  return;
14736
- this.eventHandlersToUnregister.push(this.on('connection.changed', (event) => {
14760
+ this.eventHandlersToUnregister.push(this.on('call.created', (event) => this.initCallFromEvent(event)), this.on('call.ring', (event) => this.initCallFromEvent(event)), this.on('connection.changed', (event) => {
14737
14761
  if (!event.online)
14738
14762
  return;
14739
14763
  const callsToReWatch = this.writeableStateStore.calls
@@ -14750,50 +14774,52 @@ class StreamVideoClient {
14750
14774
  this.logger('error', 'Failed to re-watch calls', err);
14751
14775
  });
14752
14776
  }));
14753
- this.eventHandlersToUnregister.push(this.on('call.created', (event) => {
14754
- const { call, members } = event;
14755
- if (this.state.connectedUser?.id === call.created_by.id) {
14756
- this.logger('warn', 'Received `call.created` sent by the current user');
14757
- return;
14758
- }
14759
- this.logger('info', `New call created and registered: ${call.cid}`);
14760
- const newCall = new Call({
14761
- streamClient: this.streamClient,
14762
- type: call.type,
14763
- id: call.id,
14764
- members,
14765
- clientStore: this.writeableStateStore,
14766
- });
14767
- newCall.state.updateFromCallResponse(call);
14768
- this.writeableStateStore.registerCall(newCall);
14769
- }));
14770
- this.eventHandlersToUnregister.push(this.on('call.ring', async (event) => {
14771
- const { call, members } = event;
14772
- if (this.state.connectedUser?.id === call.created_by.id) {
14773
- this.logger('debug', 'Received `call.ring` sent by the current user so ignoring the event');
14774
- return;
14775
- }
14776
- // if `call.created` was received before `call.ring`.
14777
- // the client already has the call instance and we just need to update the state
14778
- const theCall = this.writeableStateStore.findCall(call.type, call.id);
14779
- if (theCall) {
14780
- await theCall.updateFromRingingEvent(event);
14781
- }
14782
- else {
14783
- // if client doesn't have the call instance, create the instance and fetch the latest state
14784
- // Note: related - we also have onRingingCall method to handle this case from push notifications
14785
- const newCallInstance = new Call({
14777
+ this.effectsRegistered = true;
14778
+ };
14779
+ /**
14780
+ * Initializes a call from a call created or ringing event.
14781
+ * @param e the event.
14782
+ */
14783
+ this.initCallFromEvent = async (e) => {
14784
+ if (this.state.connectedUser?.id === e.call.created_by.id) {
14785
+ this.logger('debug', `Ignoring ${e.type} event sent by the current user`);
14786
+ return;
14787
+ }
14788
+ try {
14789
+ const concurrencyTag = getCallInitConcurrencyTag(e.call_cid);
14790
+ await withoutConcurrency(concurrencyTag, async () => {
14791
+ const ringing = e.type === 'call.ring';
14792
+ let call = this.writeableStateStore.findCall(e.call.type, e.call.id);
14793
+ if (call) {
14794
+ if (ringing) {
14795
+ await call.updateFromRingingEvent(e);
14796
+ }
14797
+ else {
14798
+ call.state.updateFromCallResponse(e.call);
14799
+ }
14800
+ return;
14801
+ }
14802
+ call = new Call({
14786
14803
  streamClient: this.streamClient,
14787
- type: call.type,
14788
- id: call.id,
14789
- members,
14804
+ type: e.call.type,
14805
+ id: e.call.id,
14806
+ members: e.members,
14790
14807
  clientStore: this.writeableStateStore,
14791
- ringing: true,
14808
+ ringing,
14792
14809
  });
14793
- await newCallInstance.get();
14794
- }
14795
- }));
14796
- this.effectsRegistered = true;
14810
+ call.state.updateFromCallResponse(e.call);
14811
+ if (ringing) {
14812
+ await call.get();
14813
+ }
14814
+ else {
14815
+ this.writeableStateStore.registerCall(call);
14816
+ this.logger('info', `New call created and registered: ${call.cid}`);
14817
+ }
14818
+ });
14819
+ }
14820
+ catch (err) {
14821
+ this.logger('error', `Failed to init call from event ${e.type}`, err);
14822
+ }
14797
14823
  };
14798
14824
  /**
14799
14825
  * Connects the given user to the client.
@@ -14893,6 +14919,7 @@ class StreamVideoClient {
14893
14919
  *
14894
14920
  * @param type the type of the call.
14895
14921
  * @param id the id of the call.
14922
+ * @param options additional options for call creation.
14896
14923
  */
14897
14924
  this.call = (type, id, options = {}) => {
14898
14925
  const call = options.reuseInstance
@@ -15023,22 +15050,24 @@ class StreamVideoClient {
15023
15050
  * @returns
15024
15051
  */
15025
15052
  this.onRingingCall = async (call_cid) => {
15026
- // if we find the call and is already ringing, we don't need to create a new call
15027
- // as client would have received the call.ring state because the app had WS alive when receiving push notifications
15028
- let call = this.state.calls.find((c) => c.cid === call_cid && c.ringing);
15029
- if (!call) {
15030
- // if not it means that WS is not alive when receiving the push notifications and we need to fetch the call
15031
- const [callType, callId] = call_cid.split(':');
15032
- call = new Call({
15033
- streamClient: this.streamClient,
15034
- type: callType,
15035
- id: callId,
15036
- clientStore: this.writeableStateStore,
15037
- ringing: true,
15038
- });
15039
- await call.get();
15040
- }
15041
- return call;
15053
+ return withoutConcurrency(getCallInitConcurrencyTag(call_cid), async () => {
15054
+ // if we find the call and is already ringing, we don't need to create a new call
15055
+ // as client would have received the call.ring state because the app had WS alive when receiving push notifications
15056
+ let call = this.state.calls.find((c) => c.cid === call_cid && c.ringing);
15057
+ if (!call) {
15058
+ // if not it means that WS is not alive when receiving the push notifications and we need to fetch the call
15059
+ const [callType, callId] = call_cid.split(':');
15060
+ call = new Call({
15061
+ streamClient: this.streamClient,
15062
+ type: callType,
15063
+ id: callId,
15064
+ clientStore: this.writeableStateStore,
15065
+ ringing: true,
15066
+ });
15067
+ await call.get();
15068
+ }
15069
+ return call;
15070
+ });
15042
15071
  };
15043
15072
  /**
15044
15073
  * Connects the given anonymous user to the client.
@@ -15097,5 +15126,5 @@ class StreamVideoClient {
15097
15126
  }
15098
15127
  StreamVideoClient._instances = new Map();
15099
15128
 
15100
- export { AudioSettingsRequestDefaultDeviceEnum, AudioSettingsResponseDefaultDeviceEnum, browsers as Browsers, Call, CallState, CallType, CallTypes, CallingState, CameraManager, CameraManagerState, CreateDeviceRequestPushProviderEnum, DebounceType, DynascaleManager, ErrorFromResponse, FrameRecordingSettingsRequestModeEnum, FrameRecordingSettingsRequestQualityEnum, FrameRecordingSettingsResponseModeEnum, InputMediaDeviceManager, InputMediaDeviceManagerState, LayoutSettingsRequestNameEnum, MicrophoneManager, MicrophoneManagerState, NoiseCancellationSettingsModeEnum, OwnCapability, RNSpeechDetector, RTMPBroadcastRequestQualityEnum, RTMPSettingsRequestQualityEnum, RecordSettingsRequestModeEnum, RecordSettingsRequestQualityEnum, rxUtils as RxUtils, ScreenShareManager, ScreenShareState, events as SfuEvents, models as SfuModels, SpeakerManager, SpeakerState, StartClosedCaptionsRequestLanguageEnum, StartTranscriptionRequestLanguageEnum, StreamSfuClient, StreamVideoClient, StreamVideoReadOnlyStateStore, StreamVideoWriteableStateStore, TranscriptionSettingsRequestClosedCaptionModeEnum, TranscriptionSettingsRequestLanguageEnum, TranscriptionSettingsRequestModeEnum, TranscriptionSettingsResponseClosedCaptionModeEnum, TranscriptionSettingsResponseLanguageEnum, TranscriptionSettingsResponseModeEnum, VideoSettingsRequestCameraFacingEnum, VideoSettingsResponseCameraFacingEnum, ViewportTracker, VisibilityState, checkIfAudioOutputChangeSupported, combineComparators, conditional, createSoundDetector, defaultSortPreset, descending, deviceIds$, disposeOfMediaStream, dominantSpeaker, getAudioBrowserPermission, getAudioDevices, getAudioOutputDevices, getAudioStream, getClientDetails, getDeviceState, getLogLevel, getLogger, getScreenShareStream, getSdkInfo, getVideoBrowserPermission, getVideoDevices, getVideoStream, getWebRTCInfo, hasAudio, hasPausedTrack, hasScreenShare, hasScreenShareAudio, hasVideo, isPinned, livestreamOrAudioRoomSortPreset, logLevels, logToConsole, name, noopComparator, paginatedLayoutSortPreset, pinned, publishingAudio, publishingVideo, reactionType, resolveDeviceId, role, screenSharing, setDeviceInfo, setLogLevel, setLogger, setOSInfo, setPowerState, setSdkInfo, setThermalState, setWebRTCInfo, speakerLayoutSortPreset, speaking };
15129
+ export { AudioSettingsRequestDefaultDeviceEnum, AudioSettingsResponseDefaultDeviceEnum, browsers as Browsers, Call, CallState, CallType, CallTypes, CallingState, CameraManager, CameraManagerState, CreateDeviceRequestPushProviderEnum, DebounceType, DynascaleManager, ErrorFromResponse, FrameRecordingSettingsRequestModeEnum, FrameRecordingSettingsRequestQualityEnum, FrameRecordingSettingsResponseModeEnum, IngressAudioEncodingOptionsRequestChannelsEnum, IngressVideoLayerRequestCodecEnum, InputMediaDeviceManager, InputMediaDeviceManagerState, LayoutSettingsRequestNameEnum, MicrophoneManager, MicrophoneManagerState, NoiseCancellationSettingsModeEnum, OwnCapability, RNSpeechDetector, RTMPBroadcastRequestQualityEnum, RTMPSettingsRequestQualityEnum, RecordSettingsRequestModeEnum, RecordSettingsRequestQualityEnum, rxUtils as RxUtils, ScreenShareManager, ScreenShareState, events as SfuEvents, models as SfuModels, SpeakerManager, SpeakerState, StartClosedCaptionsRequestLanguageEnum, StartTranscriptionRequestLanguageEnum, StreamSfuClient, StreamVideoClient, StreamVideoReadOnlyStateStore, StreamVideoWriteableStateStore, TranscriptionSettingsRequestClosedCaptionModeEnum, TranscriptionSettingsRequestLanguageEnum, TranscriptionSettingsRequestModeEnum, TranscriptionSettingsResponseClosedCaptionModeEnum, TranscriptionSettingsResponseLanguageEnum, TranscriptionSettingsResponseModeEnum, VideoSettingsRequestCameraFacingEnum, VideoSettingsResponseCameraFacingEnum, ViewportTracker, VisibilityState, checkIfAudioOutputChangeSupported, combineComparators, conditional, createSoundDetector, defaultSortPreset, descending, deviceIds$, disposeOfMediaStream, dominantSpeaker, getAudioBrowserPermission, getAudioDevices, getAudioOutputDevices, getAudioStream, getClientDetails, getDeviceState, getLogLevel, getLogger, getScreenShareStream, getSdkInfo, getVideoBrowserPermission, getVideoDevices, getVideoStream, getWebRTCInfo, hasAudio, hasPausedTrack, hasScreenShare, hasScreenShareAudio, hasVideo, isPinned, livestreamOrAudioRoomSortPreset, logLevels, logToConsole, name, noopComparator, paginatedLayoutSortPreset, pinned, publishingAudio, publishingVideo, reactionType, resolveDeviceId, role, screenSharing, setDeviceInfo, setLogLevel, setLogger, setOSInfo, setPowerState, setSdkInfo, setThermalState, setWebRTCInfo, speakerLayoutSortPreset, speaking };
15101
15130
  //# sourceMappingURL=index.es.js.map