@stream-io/video-client 0.4.6 → 0.4.8

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,20 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ### [0.4.8](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-0.4.7...@stream-io/video-client-0.4.8) (2023-11-16)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **device-api:** check for Permissions API availability ([#1193](https://github.com/GetStream/stream-video-js/issues/1193)) ([5ffeaa0](https://github.com/GetStream/stream-video-js/commit/5ffeaa0d2abdab401f9028a14b114d00723605c1)), closes [#1184](https://github.com/GetStream/stream-video-js/issues/1184)
11
+
12
+ ### [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)
13
+
14
+
15
+ ### Features
16
+
17
+ * **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))
18
+
5
19
  ### [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
20
 
7
21
 
@@ -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,36 @@ 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
+ const permissionsAPIAvailable = !!navigator?.permissions?.query;
10468
+ if (isReactNative() || !this.permissionName || !permissionsAPIAvailable) {
10469
+ getLogger(['devices'])('warn', `Permissions can't be queried. Assuming granted.`);
10470
+ return notifyGranted();
10471
+ }
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));
10454
10491
  /**
10455
10492
  * Gets the current value of an observable, or undefined if the observable has
10456
10493
  * not emitted a value yet.
@@ -10532,7 +10569,10 @@ class InputMediaDeviceManagerState {
10532
10569
 
10533
10570
  class CameraManagerState extends InputMediaDeviceManagerState {
10534
10571
  constructor() {
10535
- 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');
10536
10576
  this.directionSubject = new BehaviorSubject(undefined);
10537
10577
  this.direction$ = this.directionSubject
10538
10578
  .asObservable()
@@ -10662,7 +10702,10 @@ class CameraManager extends InputMediaDeviceManager {
10662
10702
 
10663
10703
  class MicrophoneManagerState extends InputMediaDeviceManagerState {
10664
10704
  constructor() {
10665
- 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');
10666
10709
  this.speakingWhileMutedSubject = new BehaviorSubject(false);
10667
10710
  this.speakingWhileMuted$ = this.speakingWhileMutedSubject
10668
10711
  .asObservable()
@@ -12230,13 +12273,13 @@ class Call {
12230
12273
  this.camera.state.status === 'enabled') {
12231
12274
  this.camera
12232
12275
  .disable()
12233
- .catch((err) => this.logger('error', `Error disabling camera after pemission revoked`, err));
12276
+ .catch((err) => this.logger('error', `Error disabling camera after permission revoked`, err));
12234
12277
  }
12235
12278
  if (trackType === TrackType.AUDIO &&
12236
12279
  this.microphone.state.status === 'enabled') {
12237
12280
  this.microphone
12238
12281
  .disable()
12239
- .catch((err) => this.logger('error', `Error disabling microphone after pemission revoked`, err));
12282
+ .catch((err) => this.logger('error', `Error disabling microphone after permission revoked`, err));
12240
12283
  }
12241
12284
  });
12242
12285
  }
@@ -13970,7 +14013,7 @@ class StreamClient {
13970
14013
  });
13971
14014
  };
13972
14015
  this.getUserAgent = () => {
13973
- const version = "0.4.6" ;
14016
+ const version = "0.4.8" ;
13974
14017
  return (this.userAgent ||
13975
14018
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
13976
14019
  };