@stream-io/video-client 1.10.0 → 1.10.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.cjs.js CHANGED
@@ -3129,7 +3129,7 @@ const retryable = async (rpc, signal) => {
3129
3129
  return result;
3130
3130
  };
3131
3131
 
3132
- const version = "1.10.0";
3132
+ const version = "1.10.2";
3133
3133
  const [major, minor, patch] = version.split('.');
3134
3134
  let sdkInfo = {
3135
3135
  type: SdkType.PLAIN_JAVASCRIPT,
@@ -7851,7 +7851,7 @@ class BrowserPermission {
7851
7851
  const signal = this.disposeController.signal;
7852
7852
  this.ready = (async () => {
7853
7853
  const assumeGranted = (error) => {
7854
- this.setState('granted');
7854
+ this.setState('prompt');
7855
7855
  };
7856
7856
  if (!canQueryPermissions()) {
7857
7857
  return assumeGranted();
@@ -7897,6 +7897,7 @@ class BrowserPermission {
7897
7897
  this.wasPrompted = true;
7898
7898
  const stream = await navigator.mediaDevices.getUserMedia(this.permission.constraints);
7899
7899
  disposeOfMediaStream(stream);
7900
+ this.setState('granted');
7900
7901
  return true;
7901
7902
  }
7902
7903
  catch (e) {
@@ -7904,6 +7905,7 @@ class BrowserPermission {
7904
7905
  this.logger('info', 'Browser permission was not granted', {
7905
7906
  permission: this.permission,
7906
7907
  });
7908
+ this.setState('denied');
7907
7909
  if (throwOnNotAllowed) {
7908
7910
  throw e;
7909
7911
  }
@@ -7975,7 +7977,9 @@ const getDevices = (permission, kind) => {
7975
7977
  await permission.prompt({ throwOnNotAllowed: true });
7976
7978
  devices = await navigator.mediaDevices.enumerateDevices();
7977
7979
  }
7978
- return devices.filter((d) => d.kind === kind);
7980
+ return devices.filter((device) => device.kind === kind &&
7981
+ device.label !== '' &&
7982
+ device.deviceId !== 'default');
7979
7983
  })());
7980
7984
  };
7981
7985
  /**
@@ -8045,20 +8049,27 @@ const getAudioDevices = lazy(() => {
8045
8049
  * if devices are added/removed the list is updated, and if the permission is revoked,
8046
8050
  * the observable errors.
8047
8051
  */
8048
- const getVideoDevices = () => {
8052
+ const getVideoDevices = lazy(() => {
8049
8053
  return rxjs.merge(getDeviceChangeObserver(), getVideoBrowserPermission().asObservable()).pipe(rxjs.startWith(undefined), rxjs.concatMap(() => getDevices(getVideoBrowserPermission(), 'videoinput')), rxjs.shareReplay(1));
8050
- };
8054
+ });
8051
8055
  /**
8052
8056
  * Prompts the user for a permission to use video devices (if not already granted
8053
8057
  * and was not prompted before) and lists the available 'audiooutput' devices,
8054
8058
  * if devices are added/removed the list is updated, and if the permission is revoked,
8055
8059
  * the observable errors.
8056
8060
  */
8057
- const getAudioOutputDevices = () => {
8061
+ const getAudioOutputDevices = lazy(() => {
8058
8062
  return rxjs.merge(getDeviceChangeObserver(), getAudioBrowserPermission().asObservable()).pipe(rxjs.startWith(undefined), rxjs.concatMap(() => getDevices(getAudioBrowserPermission(), 'audiooutput')), rxjs.shareReplay(1));
8059
- };
8063
+ });
8060
8064
  const getStream = async (constraints) => {
8061
- return await navigator.mediaDevices.getUserMedia(constraints);
8065
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
8066
+ if (isFirefox()) {
8067
+ // When enumerating devices, Firefox will hide device labels unless there's been
8068
+ // an active user media stream on the page. So we force device list updates after
8069
+ // every successful getUserMedia call.
8070
+ navigator.mediaDevices.dispatchEvent(new Event('devicechange'));
8071
+ }
8072
+ return stream;
8062
8073
  };
8063
8074
  /**
8064
8075
  * Returns an audio media stream that fulfills the given constraints.
@@ -8234,6 +8245,7 @@ class InputMediaDeviceManager {
8234
8245
  * Starts stream.
8235
8246
  */
8236
8247
  async enable() {
8248
+ this.state.prevStatus = this.state.optimisticStatus;
8237
8249
  if (this.state.optimisticStatus === 'enabled') {
8238
8250
  return;
8239
8251
  }
@@ -8255,7 +8267,7 @@ class InputMediaDeviceManager {
8255
8267
  * @param {boolean} [forceStop=false] when true, stops the tracks regardless of the state.disableMode
8256
8268
  */
8257
8269
  async disable(forceStop = false) {
8258
- this.state.prevStatus = this.state.status;
8270
+ this.state.prevStatus = this.state.optimisticStatus;
8259
8271
  if (!forceStop && this.state.optimisticStatus === 'disabled') {
8260
8272
  return;
8261
8273
  }
@@ -8284,7 +8296,7 @@ class InputMediaDeviceManager {
8284
8296
  */
8285
8297
  async resume() {
8286
8298
  if (this.state.prevStatus === 'enabled' &&
8287
- this.state.status === 'disabled') {
8299
+ this.state.status !== 'enabled') {
8288
8300
  await this.enable();
8289
8301
  }
8290
8302
  }
@@ -12703,7 +12715,7 @@ class StreamClient {
12703
12715
  });
12704
12716
  };
12705
12717
  this.getUserAgent = () => {
12706
- const version = "1.10.0";
12718
+ const version = "1.10.2";
12707
12719
  return (this.userAgent ||
12708
12720
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
12709
12721
  };