@stream-io/video-client 0.5.1 → 0.5.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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ### [0.5.2](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-0.5.1...@stream-io/video-client-0.5.2) (2023-12-11)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **ringing:** Auto-Cancel outgoing calls ([#1217](https://github.com/GetStream/stream-video-js/issues/1217)) ([c4d557b](https://github.com/GetStream/stream-video-js/commit/c4d557b736df8ff0a95166d1f9f0a52d4a57a122)), closes [#1215](https://github.com/GetStream/stream-video-js/issues/1215)
11
+
5
12
  ### [0.5.1](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-0.5.0...@stream-io/video-client-0.5.1) (2023-12-05)
6
13
 
7
14
 
@@ -4,7 +4,7 @@ import { ServiceType, stackIntercept } from '@protobuf-ts/runtime-rpc';
4
4
  import axios, { AxiosHeaders } from 'axios';
5
5
  export { AxiosError } from 'axios';
6
6
  import { TwirpFetchTransport } from '@protobuf-ts/twirp-transport';
7
- import { ReplaySubject, combineLatest, BehaviorSubject, map as map$1, shareReplay, distinctUntilChanged, takeWhile, distinctUntilKeyChanged, merge, from, Observable, debounceTime, concatMap, pairwise, of, filter, tap, debounce, timer } from 'rxjs';
7
+ import { ReplaySubject, combineLatest, BehaviorSubject, map as map$1, shareReplay, distinctUntilChanged, takeWhile, distinctUntilKeyChanged, merge, from, Observable, debounceTime, concatMap, pairwise, of, filter, debounce, timer } from 'rxjs';
8
8
  import * as SDP from 'sdp-transform';
9
9
  import { UAParser } from 'ua-parser-js';
10
10
  import WebSocket from 'isomorphic-ws';
@@ -6492,7 +6492,7 @@ class Publisher {
6492
6492
  */
6493
6493
  const handleTrackEnded = async () => {
6494
6494
  logger$3('info', `Track ${TrackType[trackType]} has ended, notifying the SFU`);
6495
- await this.notifyTrackMuteStateChanged(mediaStream, track, trackType, true);
6495
+ await this.notifyTrackMuteStateChanged(mediaStream, trackType, true);
6496
6496
  // clean-up, this event listener needs to run only once.
6497
6497
  track.removeEventListener('ended', handleTrackEnded);
6498
6498
  };
@@ -6548,7 +6548,7 @@ class Publisher {
6548
6548
  }
6549
6549
  await transceiver.sender.replaceTrack(track);
6550
6550
  }
6551
- await this.notifyTrackMuteStateChanged(mediaStream, track, trackType, false);
6551
+ await this.notifyTrackMuteStateChanged(mediaStream, trackType, false);
6552
6552
  };
6553
6553
  /**
6554
6554
  * Stops publishing the given track type to the SFU, if it is currently being published.
@@ -6570,7 +6570,7 @@ class Publisher {
6570
6570
  : (transceiver.sender.track.enabled = false);
6571
6571
  // We don't need to notify SFU if unpublishing in response to remote soft mute
6572
6572
  if (this.state.localParticipant?.publishedTracks.includes(trackType)) {
6573
- await this.notifyTrackMuteStateChanged(undefined, transceiver.sender.track, trackType, true);
6573
+ await this.notifyTrackMuteStateChanged(undefined, trackType, true);
6574
6574
  }
6575
6575
  }
6576
6576
  };
@@ -6602,7 +6602,7 @@ class Publisher {
6602
6602
  }
6603
6603
  return false;
6604
6604
  };
6605
- this.notifyTrackMuteStateChanged = async (mediaStream, track, trackType, isMuted) => {
6605
+ this.notifyTrackMuteStateChanged = async (mediaStream, trackType, isMuted) => {
6606
6606
  await this.sfuClient.updateMuteState(trackType, isMuted);
6607
6607
  const audioOrVideoOrScreenShareStream = trackTypeToParticipantStreamKey(trackType);
6608
6608
  if (isMuted) {
@@ -7646,131 +7646,6 @@ var rxUtils = /*#__PURE__*/Object.freeze({
7646
7646
  setCurrentValue: setCurrentValue
7647
7647
  });
7648
7648
 
7649
- class StreamVideoWriteableStateStore {
7650
- constructor() {
7651
- /**
7652
- * A store keeping data of a successfully connected user over WS to the coordinator server.
7653
- */
7654
- this.connectedUserSubject = new BehaviorSubject(undefined);
7655
- /**
7656
- * A list of {@link Call} objects created/tracked by this client.
7657
- */
7658
- this.callsSubject = new BehaviorSubject([]);
7659
- /**
7660
- * Gets the current value of an observable, or undefined if the observable has
7661
- * not emitted a value yet.
7662
- *
7663
- * @param observable$ the observable to get the value from.
7664
- */
7665
- this.getCurrentValue = getCurrentValue;
7666
- /**
7667
- * Updates the value of the provided Subject.
7668
- * An `update` can either be a new value or a function which takes
7669
- * the current value and returns a new value.
7670
- *
7671
- * @param subject the subject to update.
7672
- * @param update the update to apply to the subject.
7673
- * @return the updated value.
7674
- */
7675
- this.setCurrentValue = setCurrentValue;
7676
- /**
7677
- * Sets the currently connected user.
7678
- *
7679
- * @internal
7680
- * @param user the user to set as connected.
7681
- */
7682
- this.setConnectedUser = (user) => {
7683
- return this.setCurrentValue(this.connectedUserSubject, user);
7684
- };
7685
- /**
7686
- * Sets the list of {@link Call} objects created/tracked by this client.
7687
- * @param calls
7688
- */
7689
- this.setCalls = (calls) => {
7690
- return this.setCurrentValue(this.callsSubject, calls);
7691
- };
7692
- /**
7693
- * Adds a {@link Call} object to the list of {@link Call} objects created/tracked by this client.
7694
- *
7695
- * @param call the call to add.
7696
- */
7697
- this.registerCall = (call) => {
7698
- if (!this.calls.find((c) => c.cid === call.cid)) {
7699
- this.setCalls((calls) => [...calls, call]);
7700
- }
7701
- };
7702
- /**
7703
- * Removes a {@link Call} object from the list of {@link Call} objects created/tracked by this client.
7704
- *
7705
- * @param call the call to remove
7706
- */
7707
- this.unregisterCall = (call) => {
7708
- return this.setCalls((calls) => calls.filter((c) => c !== call));
7709
- };
7710
- /**
7711
- * Finds a {@link Call} object in the list of {@link Call} objects created/tracked by this client.
7712
- *
7713
- * @param type the type of call to find.
7714
- * @param id the id of the call to find.
7715
- */
7716
- this.findCall = (type, id) => {
7717
- return this.calls.find((c) => c.type === type && c.id === id);
7718
- };
7719
- this.connectedUserSubject.subscribe(async (user) => {
7720
- // leave all calls when the user disconnects.
7721
- if (!user) {
7722
- for (const call of this.calls) {
7723
- getLogger(['client-state'])('info', `User disconnected, leaving call: ${call.cid}`);
7724
- await call.leave();
7725
- }
7726
- }
7727
- });
7728
- }
7729
- /**
7730
- * The currently connected user.
7731
- */
7732
- get connectedUser() {
7733
- return this.getCurrentValue(this.connectedUserSubject);
7734
- }
7735
- /**
7736
- * A list of {@link Call} objects created/tracked by this client.
7737
- */
7738
- get calls() {
7739
- return this.getCurrentValue(this.callsSubject);
7740
- }
7741
- }
7742
- /**
7743
- * A reactive store that exposes state variables in a reactive manner.
7744
- * You can subscribe to changes of the different state variables.
7745
- * This central store contains all the state variables related to [`StreamVideoClient`](./StreamVideClient.md) and [`Call`](./Call.md).
7746
- */
7747
- class StreamVideoReadOnlyStateStore {
7748
- constructor(store) {
7749
- /**
7750
- * This method allows you the get the current value of a state variable.
7751
- *
7752
- * @param observable the observable to get the current value of.
7753
- * @returns the current value of the observable.
7754
- */
7755
- this.getCurrentValue = getCurrentValue;
7756
- // convert and expose subjects as observables
7757
- this.connectedUser$ = store.connectedUserSubject.asObservable();
7758
- this.calls$ = store.callsSubject.asObservable();
7759
- }
7760
- /**
7761
- * The current user connected over WS to the backend.
7762
- */
7763
- get connectedUser() {
7764
- return getCurrentValue(this.connectedUser$);
7765
- }
7766
- /**
7767
- * A list of {@link Call} objects created/tracked by this client.
7768
- */
7769
- get calls() {
7770
- return getCurrentValue(this.calls$);
7771
- }
7772
- }
7773
-
7774
7649
  /**
7775
7650
  * Creates a new combined {@link Comparator<T>} which sorts items by the given comparators.
7776
7651
  * The comparators are applied in the order they are given (left -> right).
@@ -8729,6 +8604,136 @@ class CallState {
8729
8604
  }
8730
8605
  }
8731
8606
 
8607
+ class StreamVideoWriteableStateStore {
8608
+ constructor() {
8609
+ /**
8610
+ * A store keeping data of a successfully connected user over WS to the coordinator server.
8611
+ */
8612
+ this.connectedUserSubject = new BehaviorSubject(undefined);
8613
+ /**
8614
+ * A list of {@link Call} objects created/tracked by this client.
8615
+ */
8616
+ this.callsSubject = new BehaviorSubject([]);
8617
+ /**
8618
+ * Gets the current value of an observable, or undefined if the observable has
8619
+ * not emitted a value yet.
8620
+ *
8621
+ * @param observable$ the observable to get the value from.
8622
+ */
8623
+ this.getCurrentValue = getCurrentValue;
8624
+ /**
8625
+ * Updates the value of the provided Subject.
8626
+ * An `update` can either be a new value or a function which takes
8627
+ * the current value and returns a new value.
8628
+ *
8629
+ * @param subject the subject to update.
8630
+ * @param update the update to apply to the subject.
8631
+ * @return the updated value.
8632
+ */
8633
+ this.setCurrentValue = setCurrentValue;
8634
+ /**
8635
+ * Sets the currently connected user.
8636
+ *
8637
+ * @internal
8638
+ * @param user the user to set as connected.
8639
+ */
8640
+ this.setConnectedUser = (user) => {
8641
+ return this.setCurrentValue(this.connectedUserSubject, user);
8642
+ };
8643
+ /**
8644
+ * Sets the list of {@link Call} objects created/tracked by this client.
8645
+ * @param calls
8646
+ */
8647
+ this.setCalls = (calls) => {
8648
+ return this.setCurrentValue(this.callsSubject, calls);
8649
+ };
8650
+ /**
8651
+ * Adds a {@link Call} object to the list of {@link Call} objects created/tracked by this client.
8652
+ *
8653
+ * @param call the call to add.
8654
+ */
8655
+ this.registerCall = (call) => {
8656
+ if (!this.calls.find((c) => c.cid === call.cid)) {
8657
+ this.setCalls((calls) => [...calls, call]);
8658
+ }
8659
+ };
8660
+ /**
8661
+ * Removes a {@link Call} object from the list of {@link Call} objects created/tracked by this client.
8662
+ *
8663
+ * @param call the call to remove
8664
+ */
8665
+ this.unregisterCall = (call) => {
8666
+ return this.setCalls((calls) => calls.filter((c) => c !== call));
8667
+ };
8668
+ /**
8669
+ * Finds a {@link Call} object in the list of {@link Call} objects created/tracked by this client.
8670
+ *
8671
+ * @param type the type of call to find.
8672
+ * @param id the id of the call to find.
8673
+ */
8674
+ this.findCall = (type, id) => {
8675
+ return this.calls.find((c) => c.type === type && c.id === id);
8676
+ };
8677
+ this.connectedUserSubject.subscribe(async (user) => {
8678
+ // leave all calls when the user disconnects.
8679
+ if (!user) {
8680
+ const logger = getLogger(['client-state']);
8681
+ for (const call of this.calls) {
8682
+ if (call.state.callingState === CallingState.LEFT)
8683
+ continue;
8684
+ logger('info', `User disconnected, leaving call: ${call.cid}`);
8685
+ await call.leave().catch((err) => {
8686
+ logger('error', `Error leaving call: ${call.cid}`, err);
8687
+ });
8688
+ }
8689
+ }
8690
+ });
8691
+ }
8692
+ /**
8693
+ * The currently connected user.
8694
+ */
8695
+ get connectedUser() {
8696
+ return this.getCurrentValue(this.connectedUserSubject);
8697
+ }
8698
+ /**
8699
+ * A list of {@link Call} objects created/tracked by this client.
8700
+ */
8701
+ get calls() {
8702
+ return this.getCurrentValue(this.callsSubject);
8703
+ }
8704
+ }
8705
+ /**
8706
+ * A reactive store that exposes state variables in a reactive manner.
8707
+ * You can subscribe to changes of the different state variables.
8708
+ * This central store contains all the state variables related to [`StreamVideoClient`](./StreamVideClient.md) and [`Call`](./Call.md).
8709
+ */
8710
+ class StreamVideoReadOnlyStateStore {
8711
+ constructor(store) {
8712
+ /**
8713
+ * This method allows you the get the current value of a state variable.
8714
+ *
8715
+ * @param observable the observable to get the current value of.
8716
+ * @returns the current value of the observable.
8717
+ */
8718
+ this.getCurrentValue = getCurrentValue;
8719
+ // convert and expose subjects as observables
8720
+ this.connectedUser$ = store.connectedUserSubject.asObservable();
8721
+ this.calls$ = store.callsSubject.asObservable();
8722
+ }
8723
+ /**
8724
+ * The current user connected over WS to the backend.
8725
+ */
8726
+ get connectedUser() {
8727
+ return getCurrentValue(this.connectedUser$);
8728
+ }
8729
+ /**
8730
+ * A list of {@link Call} objects created/tracked by this client.
8731
+ */
8732
+ get calls() {
8733
+ return getCurrentValue(this.calls$);
8734
+ }
8735
+ }
8736
+
8732
8737
  /**
8733
8738
  * Event handler that watched the delivery of `call.accepted`.
8734
8739
  * Once the event is received, the call is joined.
@@ -11915,9 +11920,10 @@ class Call {
11915
11920
  return this.state.setSortParticipantsBy(criteria);
11916
11921
  };
11917
11922
  /**
11923
+ * Updates the list of video layers to publish.
11924
+ *
11918
11925
  * @internal
11919
- * @param enabledRids
11920
- * @returns
11926
+ * @param enabledLayers the list of layers to enable.
11921
11927
  */
11922
11928
  this.updatePublishQuality = async (enabledLayers) => {
11923
11929
  return this.publisher?.updateVideoPublishQuality(enabledLayers);
@@ -12189,35 +12195,29 @@ class Call {
12189
12195
  this.updateCallMembers = async (data) => {
12190
12196
  return this.streamClient.post(`${this.streamClientBasePath}/members`, data);
12191
12197
  };
12198
+ /**
12199
+ * Schedules an auto-drop timeout based on the call settings.
12200
+ * Applicable only for ringing calls.
12201
+ */
12192
12202
  this.scheduleAutoDrop = () => {
12193
- if (this.dropTimeout)
12194
- clearTimeout(this.dropTimeout);
12195
- const subscription = this.state.settings$
12196
- .pipe(pairwise(), tap(([prevSettings, currentSettings]) => {
12197
- if (!currentSettings || !this.clientStore.connectedUser)
12203
+ clearTimeout(this.dropTimeout);
12204
+ this.leaveCallHooks.add(createSubscription(this.state.settings$, (settings) => {
12205
+ if (!settings)
12198
12206
  return;
12199
- const isOutgoingCall = this.currentUserId === this.state.createdBy?.id;
12200
- const [prevTimeoutMs, timeoutMs] = isOutgoingCall
12201
- ? [
12202
- prevSettings?.ring.auto_cancel_timeout_ms,
12203
- currentSettings.ring.auto_cancel_timeout_ms,
12204
- ]
12205
- : [
12206
- prevSettings?.ring.incoming_call_timeout_ms,
12207
- currentSettings.ring.incoming_call_timeout_ms,
12208
- ];
12209
- if (typeof timeoutMs === 'undefined' ||
12210
- timeoutMs === prevTimeoutMs ||
12211
- timeoutMs === 0)
12207
+ // ignore if the call is not ringing
12208
+ if (this.state.callingState !== CallingState.RINGING)
12212
12209
  return;
12213
- if (this.dropTimeout)
12214
- clearTimeout(this.dropTimeout);
12215
- this.dropTimeout = setTimeout(() => this.leave(), timeoutMs);
12216
- }), takeWhile(() => !!this.clientStore.calls.find((call) => call.cid === this.cid)))
12217
- .subscribe();
12218
- this.leaveCallHooks.add(() => {
12219
- !subscription.closed && subscription.unsubscribe();
12220
- });
12210
+ const timeoutInMs = settings.ring.auto_cancel_timeout_ms;
12211
+ // 0 means no auto-drop
12212
+ if (timeoutInMs <= 0)
12213
+ return;
12214
+ clearTimeout(this.dropTimeout);
12215
+ this.dropTimeout = setTimeout(() => {
12216
+ this.leave().catch((err) => {
12217
+ this.logger('error', 'Failed to drop call', err);
12218
+ });
12219
+ }, timeoutInMs);
12220
+ }));
12221
12221
  };
12222
12222
  /**
12223
12223
  * Retrieves the list of recordings for the current call or call session.
@@ -14141,7 +14141,7 @@ class StreamClient {
14141
14141
  });
14142
14142
  };
14143
14143
  this.getUserAgent = () => {
14144
- const version = "0.5.1" ;
14144
+ const version = "0.5.2" ;
14145
14145
  return (this.userAgent ||
14146
14146
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
14147
14147
  };