@stream-io/video-client 0.4.6 → 0.4.7

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
@@ -10258,11 +10258,10 @@ class InputMediaDeviceManager {
10258
10258
  this.state.setDefaultConstraints(constraints);
10259
10259
  }
10260
10260
  /**
10261
- * Select device
10261
+ * Selects a device.
10262
10262
  *
10263
10263
  * Note: this method is not supported in React Native
10264
- *
10265
- * @param deviceId
10264
+ * @param deviceId the device id to select.
10266
10265
  */
10267
10266
  async select(deviceId) {
10268
10267
  if (isReactNative()) {
@@ -10429,8 +10428,16 @@ class InputMediaDeviceManager {
10429
10428
  }
10430
10429
 
10431
10430
  class InputMediaDeviceManagerState {
10432
- constructor(disableMode = 'stop-tracks') {
10431
+ /**
10432
+ * Constructs new InputMediaDeviceManagerState instance.
10433
+ *
10434
+ * @param disableMode the disable mode to use.
10435
+ * @param permissionName the permission name to use for querying.
10436
+ * `undefined` means no permission is required.
10437
+ */
10438
+ constructor(disableMode = 'stop-tracks', permissionName = undefined) {
10433
10439
  this.disableMode = disableMode;
10440
+ this.permissionName = permissionName;
10434
10441
  this.statusSubject = new BehaviorSubject(undefined);
10435
10442
  this.mediaStreamSubject = new BehaviorSubject(undefined);
10436
10443
  this.selectedDeviceSubject = new BehaviorSubject(undefined);
@@ -10454,6 +10461,33 @@ class InputMediaDeviceManagerState {
10454
10461
  * The default constraints for the device.
10455
10462
  */
10456
10463
  this.defaultConstraints$ = this.defaultConstraintsSubject.asObservable();
10464
+ /**
10465
+ * An observable that will emit `true` if browser/system permission
10466
+ * is granted, `false` otherwise.
10467
+ */
10468
+ this.hasBrowserPermission$ = new Observable((subscriber) => {
10469
+ const notifyGranted = () => subscriber.next(true);
10470
+ if (isReactNative() || !this.permissionName)
10471
+ return notifyGranted();
10472
+ let permissionState;
10473
+ const notify = () => subscriber.next(permissionState.state === 'granted');
10474
+ navigator.permissions
10475
+ .query({ name: this.permissionName })
10476
+ .then((permissionStatus) => {
10477
+ permissionState = permissionStatus;
10478
+ permissionState.addEventListener('change', notify);
10479
+ notify();
10480
+ })
10481
+ .catch(() => {
10482
+ // permission doesn't exist or can't be queried -> assume it's granted
10483
+ // an example would be Firefox,
10484
+ // where neither camera microphone permission can be queried
10485
+ notifyGranted();
10486
+ });
10487
+ return () => {
10488
+ permissionState?.removeEventListener('change', notify);
10489
+ };
10490
+ }).pipe(shareReplay(1));
10457
10491
  /**
10458
10492
  * Gets the current value of an observable, or undefined if the observable has
10459
10493
  * not emitted a value yet.
@@ -10535,7 +10569,10 @@ class InputMediaDeviceManagerState {
10535
10569
 
10536
10570
  class CameraManagerState extends InputMediaDeviceManagerState {
10537
10571
  constructor() {
10538
- super('stop-tracks');
10572
+ super('stop-tracks',
10573
+ // `camera` is not in the W3C standard yet,
10574
+ // but it's supported by Chrome and Safari.
10575
+ 'camera');
10539
10576
  this.directionSubject = new BehaviorSubject(undefined);
10540
10577
  this.direction$ = this.directionSubject
10541
10578
  .asObservable()
@@ -10665,7 +10702,10 @@ class CameraManager extends InputMediaDeviceManager {
10665
10702
 
10666
10703
  class MicrophoneManagerState extends InputMediaDeviceManagerState {
10667
10704
  constructor() {
10668
- super('disable-tracks');
10705
+ super('disable-tracks',
10706
+ // `microphone` is not in the W3C standard yet,
10707
+ // but it's supported by Chrome and Safari.
10708
+ 'microphone');
10669
10709
  this.speakingWhileMutedSubject = new BehaviorSubject(false);
10670
10710
  this.speakingWhileMuted$ = this.speakingWhileMutedSubject
10671
10711
  .asObservable()
@@ -13974,7 +14014,7 @@ class StreamClient {
13974
14014
  });
13975
14015
  };
13976
14016
  this.getUserAgent = () => {
13977
- const version = "0.4.6" ;
14017
+ const version = "0.4.7" ;
13978
14018
  return (this.userAgent ||
13979
14019
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
13980
14020
  };