@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/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.4.7](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-0.4.6...@stream-io/video-client-0.4.7) (2023-11-13)
6
+
7
+
8
+ ### Features
9
+
10
+ * **device-api:** Browser Permissions API ([#1184](https://github.com/GetStream/stream-video-js/issues/1184)) ([a0b3573](https://github.com/GetStream/stream-video-js/commit/a0b3573b630ff8450953cdf1102fe722aea83f6f))
11
+
5
12
  ### [0.4.6](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-0.4.5...@stream-io/video-client-0.4.6) (2023-11-13)
6
13
 
7
14
 
@@ -10255,11 +10255,10 @@ class InputMediaDeviceManager {
10255
10255
  this.state.setDefaultConstraints(constraints);
10256
10256
  }
10257
10257
  /**
10258
- * Select device
10258
+ * Selects a device.
10259
10259
  *
10260
10260
  * Note: this method is not supported in React Native
10261
- *
10262
- * @param deviceId
10261
+ * @param deviceId the device id to select.
10263
10262
  */
10264
10263
  async select(deviceId) {
10265
10264
  if (isReactNative()) {
@@ -10426,8 +10425,16 @@ class InputMediaDeviceManager {
10426
10425
  }
10427
10426
 
10428
10427
  class InputMediaDeviceManagerState {
10429
- constructor(disableMode = 'stop-tracks') {
10428
+ /**
10429
+ * Constructs new InputMediaDeviceManagerState instance.
10430
+ *
10431
+ * @param disableMode the disable mode to use.
10432
+ * @param permissionName the permission name to use for querying.
10433
+ * `undefined` means no permission is required.
10434
+ */
10435
+ constructor(disableMode = 'stop-tracks', permissionName = undefined) {
10430
10436
  this.disableMode = disableMode;
10437
+ this.permissionName = permissionName;
10431
10438
  this.statusSubject = new BehaviorSubject(undefined);
10432
10439
  this.mediaStreamSubject = new BehaviorSubject(undefined);
10433
10440
  this.selectedDeviceSubject = new BehaviorSubject(undefined);
@@ -10451,6 +10458,33 @@ class InputMediaDeviceManagerState {
10451
10458
  * The default constraints for the device.
10452
10459
  */
10453
10460
  this.defaultConstraints$ = this.defaultConstraintsSubject.asObservable();
10461
+ /**
10462
+ * An observable that will emit `true` if browser/system permission
10463
+ * is granted, `false` otherwise.
10464
+ */
10465
+ this.hasBrowserPermission$ = new Observable((subscriber) => {
10466
+ const notifyGranted = () => subscriber.next(true);
10467
+ if (isReactNative() || !this.permissionName)
10468
+ return notifyGranted();
10469
+ let permissionState;
10470
+ const notify = () => subscriber.next(permissionState.state === 'granted');
10471
+ navigator.permissions
10472
+ .query({ name: this.permissionName })
10473
+ .then((permissionStatus) => {
10474
+ permissionState = permissionStatus;
10475
+ permissionState.addEventListener('change', notify);
10476
+ notify();
10477
+ })
10478
+ .catch(() => {
10479
+ // permission doesn't exist or can't be queried -> assume it's granted
10480
+ // an example would be Firefox,
10481
+ // where neither camera microphone permission can be queried
10482
+ notifyGranted();
10483
+ });
10484
+ return () => {
10485
+ permissionState?.removeEventListener('change', notify);
10486
+ };
10487
+ }).pipe(shareReplay(1));
10454
10488
  /**
10455
10489
  * Gets the current value of an observable, or undefined if the observable has
10456
10490
  * not emitted a value yet.
@@ -10532,7 +10566,10 @@ class InputMediaDeviceManagerState {
10532
10566
 
10533
10567
  class CameraManagerState extends InputMediaDeviceManagerState {
10534
10568
  constructor() {
10535
- super('stop-tracks');
10569
+ super('stop-tracks',
10570
+ // `camera` is not in the W3C standard yet,
10571
+ // but it's supported by Chrome and Safari.
10572
+ 'camera');
10536
10573
  this.directionSubject = new BehaviorSubject(undefined);
10537
10574
  this.direction$ = this.directionSubject
10538
10575
  .asObservable()
@@ -10662,7 +10699,10 @@ class CameraManager extends InputMediaDeviceManager {
10662
10699
 
10663
10700
  class MicrophoneManagerState extends InputMediaDeviceManagerState {
10664
10701
  constructor() {
10665
- super('disable-tracks');
10702
+ super('disable-tracks',
10703
+ // `microphone` is not in the W3C standard yet,
10704
+ // but it's supported by Chrome and Safari.
10705
+ 'microphone');
10666
10706
  this.speakingWhileMutedSubject = new BehaviorSubject(false);
10667
10707
  this.speakingWhileMuted$ = this.speakingWhileMutedSubject
10668
10708
  .asObservable()
@@ -13970,7 +14010,7 @@ class StreamClient {
13970
14010
  });
13971
14011
  };
13972
14012
  this.getUserAgent = () => {
13973
- const version = "0.4.6" ;
14013
+ const version = "0.4.7" ;
13974
14014
  return (this.userAgent ||
13975
14015
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
13976
14016
  };