@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.cjs.js CHANGED
@@ -10278,11 +10278,10 @@ class InputMediaDeviceManager {
10278
10278
  this.state.setDefaultConstraints(constraints);
10279
10279
  }
10280
10280
  /**
10281
- * Select device
10281
+ * Selects a device.
10282
10282
  *
10283
10283
  * Note: this method is not supported in React Native
10284
- *
10285
- * @param deviceId
10284
+ * @param deviceId the device id to select.
10286
10285
  */
10287
10286
  async select(deviceId) {
10288
10287
  if (isReactNative()) {
@@ -10449,8 +10448,16 @@ class InputMediaDeviceManager {
10449
10448
  }
10450
10449
 
10451
10450
  class InputMediaDeviceManagerState {
10452
- constructor(disableMode = 'stop-tracks') {
10451
+ /**
10452
+ * Constructs new InputMediaDeviceManagerState instance.
10453
+ *
10454
+ * @param disableMode the disable mode to use.
10455
+ * @param permissionName the permission name to use for querying.
10456
+ * `undefined` means no permission is required.
10457
+ */
10458
+ constructor(disableMode = 'stop-tracks', permissionName = undefined) {
10453
10459
  this.disableMode = disableMode;
10460
+ this.permissionName = permissionName;
10454
10461
  this.statusSubject = new rxjs.BehaviorSubject(undefined);
10455
10462
  this.mediaStreamSubject = new rxjs.BehaviorSubject(undefined);
10456
10463
  this.selectedDeviceSubject = new rxjs.BehaviorSubject(undefined);
@@ -10474,6 +10481,33 @@ class InputMediaDeviceManagerState {
10474
10481
  * The default constraints for the device.
10475
10482
  */
10476
10483
  this.defaultConstraints$ = this.defaultConstraintsSubject.asObservable();
10484
+ /**
10485
+ * An observable that will emit `true` if browser/system permission
10486
+ * is granted, `false` otherwise.
10487
+ */
10488
+ this.hasBrowserPermission$ = new rxjs.Observable((subscriber) => {
10489
+ const notifyGranted = () => subscriber.next(true);
10490
+ if (isReactNative() || !this.permissionName)
10491
+ return notifyGranted();
10492
+ let permissionState;
10493
+ const notify = () => subscriber.next(permissionState.state === 'granted');
10494
+ navigator.permissions
10495
+ .query({ name: this.permissionName })
10496
+ .then((permissionStatus) => {
10497
+ permissionState = permissionStatus;
10498
+ permissionState.addEventListener('change', notify);
10499
+ notify();
10500
+ })
10501
+ .catch(() => {
10502
+ // permission doesn't exist or can't be queried -> assume it's granted
10503
+ // an example would be Firefox,
10504
+ // where neither camera microphone permission can be queried
10505
+ notifyGranted();
10506
+ });
10507
+ return () => {
10508
+ permissionState?.removeEventListener('change', notify);
10509
+ };
10510
+ }).pipe(rxjs.shareReplay(1));
10477
10511
  /**
10478
10512
  * Gets the current value of an observable, or undefined if the observable has
10479
10513
  * not emitted a value yet.
@@ -10555,7 +10589,10 @@ class InputMediaDeviceManagerState {
10555
10589
 
10556
10590
  class CameraManagerState extends InputMediaDeviceManagerState {
10557
10591
  constructor() {
10558
- super('stop-tracks');
10592
+ super('stop-tracks',
10593
+ // `camera` is not in the W3C standard yet,
10594
+ // but it's supported by Chrome and Safari.
10595
+ 'camera');
10559
10596
  this.directionSubject = new rxjs.BehaviorSubject(undefined);
10560
10597
  this.direction$ = this.directionSubject
10561
10598
  .asObservable()
@@ -10685,7 +10722,10 @@ class CameraManager extends InputMediaDeviceManager {
10685
10722
 
10686
10723
  class MicrophoneManagerState extends InputMediaDeviceManagerState {
10687
10724
  constructor() {
10688
- super('disable-tracks');
10725
+ super('disable-tracks',
10726
+ // `microphone` is not in the W3C standard yet,
10727
+ // but it's supported by Chrome and Safari.
10728
+ 'microphone');
10689
10729
  this.speakingWhileMutedSubject = new rxjs.BehaviorSubject(false);
10690
10730
  this.speakingWhileMuted$ = this.speakingWhileMutedSubject
10691
10731
  .asObservable()
@@ -13994,7 +14034,7 @@ class StreamClient {
13994
14034
  });
13995
14035
  };
13996
14036
  this.getUserAgent = () => {
13997
- const version = "0.4.6" ;
14037
+ const version = "0.4.7" ;
13998
14038
  return (this.userAgent ||
13999
14039
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
14000
14040
  };