@stream-io/video-client 1.11.8 → 1.11.10

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
@@ -3318,7 +3318,7 @@ const retryable = async (rpc, signal) => {
3318
3318
  return result;
3319
3319
  };
3320
3320
 
3321
- const version = "1.11.8";
3321
+ const version = "1.11.10";
3322
3322
  const [major, minor, patch] = version.split('.');
3323
3323
  let sdkInfo = {
3324
3324
  type: SdkType.PLAIN_JAVASCRIPT,
@@ -6802,7 +6802,9 @@ const watchCallEnded = (call) => {
6802
6802
  const { callingState } = call.state;
6803
6803
  if (callingState !== exports.CallingState.IDLE &&
6804
6804
  callingState !== exports.CallingState.LEFT) {
6805
- call.leave({ reason: 'call.ended event received' }).catch((err) => {
6805
+ call
6806
+ .leave({ reason: 'call.ended event received', reject: false })
6807
+ .catch((err) => {
6806
6808
  call.logger('error', 'Failed to leave call after call.ended ', err);
6807
6809
  });
6808
6810
  }
@@ -8365,7 +8367,7 @@ const getAudioStream = async (trackConstraints) => {
8365
8367
  const constraints = {
8366
8368
  audio: {
8367
8369
  ...audioDeviceConstraints.audio,
8368
- ...trackConstraints,
8370
+ ...normalizeContraints(trackConstraints),
8369
8371
  },
8370
8372
  };
8371
8373
  try {
@@ -8376,11 +8378,6 @@ const getAudioStream = async (trackConstraints) => {
8376
8378
  return await getStream(constraints);
8377
8379
  }
8378
8380
  catch (error) {
8379
- if (error instanceof OverconstrainedError && trackConstraints?.deviceId) {
8380
- const { deviceId, ...relaxedContraints } = trackConstraints;
8381
- getLogger(['devices'])('warn', 'Failed to get audio stream, will try again with relaxed contraints', { error, constraints, relaxedContraints });
8382
- return getAudioStream(relaxedContraints);
8383
- }
8384
8381
  getLogger(['devices'])('error', 'Failed to get audio stream', {
8385
8382
  error,
8386
8383
  constraints,
@@ -8400,7 +8397,7 @@ const getVideoStream = async (trackConstraints) => {
8400
8397
  const constraints = {
8401
8398
  video: {
8402
8399
  ...videoDeviceConstraints.video,
8403
- ...trackConstraints,
8400
+ ...normalizeContraints(trackConstraints),
8404
8401
  },
8405
8402
  };
8406
8403
  try {
@@ -8411,11 +8408,6 @@ const getVideoStream = async (trackConstraints) => {
8411
8408
  return await getStream(constraints);
8412
8409
  }
8413
8410
  catch (error) {
8414
- if (error instanceof OverconstrainedError && trackConstraints?.deviceId) {
8415
- const { deviceId, ...relaxedContraints } = trackConstraints;
8416
- getLogger(['devices'])('warn', 'Failed to get video stream, will try again with relaxed contraints', { error, constraints, relaxedContraints });
8417
- return getVideoStream(relaxedContraints);
8418
- }
8419
8411
  getLogger(['devices'])('error', 'Failed to get video stream', {
8420
8412
  error,
8421
8413
  constraints,
@@ -8423,6 +8415,16 @@ const getVideoStream = async (trackConstraints) => {
8423
8415
  throw error;
8424
8416
  }
8425
8417
  };
8418
+ function normalizeContraints(constraints) {
8419
+ if (constraints?.deviceId === 'default' ||
8420
+ (typeof constraints?.deviceId === 'object' &&
8421
+ 'exact' in constraints.deviceId &&
8422
+ constraints.deviceId.exact === 'default')) {
8423
+ const { deviceId, ...contraintsWithoutDeviceId } = constraints;
8424
+ return contraintsWithoutDeviceId;
8425
+ }
8426
+ return constraints;
8427
+ }
8426
8428
  /**
8427
8429
  * Prompts the user for a permission to share a screen.
8428
8430
  * If the user grants the permission, a screen sharing stream is returned. Throws otherwise.
@@ -8649,6 +8651,7 @@ class InputMediaDeviceManager {
8649
8651
  }
8650
8652
  catch (error) {
8651
8653
  this.state.setDevice(prevDeviceId);
8654
+ await this.applySettingsToStream();
8652
8655
  throw error;
8653
8656
  }
8654
8657
  }
@@ -9943,7 +9946,7 @@ class Call {
9943
9946
  /**
9944
9947
  * Leave the call and stop the media streams that were published by the call.
9945
9948
  */
9946
- this.leave = async ({ reject = false, reason = 'user is leaving the call', } = {}) => {
9949
+ this.leave = async ({ reject, reason = 'user is leaving the call', } = {}) => {
9947
9950
  await withoutConcurrency(this.joinLeaveConcurrencyTag, async () => {
9948
9951
  const callingState = this.state.callingState;
9949
9952
  if (callingState === exports.CallingState.LEFT) {
@@ -9959,14 +9962,15 @@ class Call {
9959
9962
  };
9960
9963
  await waitUntilCallJoined();
9961
9964
  }
9962
- if (callingState === exports.CallingState.RINGING) {
9965
+ if (callingState === exports.CallingState.RINGING && reject !== false) {
9963
9966
  if (reject) {
9964
9967
  await this.reject(reason);
9965
9968
  }
9966
9969
  else {
9970
+ // if reject was undefined, we still have to cancel the call automatically
9971
+ // when I am the creator and everyone else left the call
9967
9972
  const hasOtherParticipants = this.state.remoteParticipants.length > 0;
9968
9973
  if (this.isCreatedByMe && !hasOtherParticipants) {
9969
- // I'm the one who started the call, so I should cancel it when there are no other participants.
9970
9974
  await this.reject('cancel');
9971
9975
  }
9972
9976
  }
@@ -12632,7 +12636,7 @@ class StreamClient {
12632
12636
  return await this.wsConnection.connect(this.defaultWSTimeout);
12633
12637
  };
12634
12638
  this.getUserAgent = () => {
12635
- const version = "1.11.8";
12639
+ const version = "1.11.10";
12636
12640
  return (this.userAgent ||
12637
12641
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
12638
12642
  };