@stream-io/video-client 1.11.9 → 1.11.11

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.9";
3321
+ const version = "1.11.11";
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
- ...normalizeContraints(trackConstraints),
8370
+ ...trackConstraints,
8369
8371
  },
8370
8372
  };
8371
8373
  try {
@@ -8376,6 +8378,13 @@ const getAudioStream = async (trackConstraints) => {
8376
8378
  return await getStream(constraints);
8377
8379
  }
8378
8380
  catch (error) {
8381
+ if (error instanceof DOMException &&
8382
+ error.name === 'OverconstrainedError' &&
8383
+ trackConstraints?.deviceId) {
8384
+ const { deviceId, ...relaxedContraints } = trackConstraints;
8385
+ getLogger(['devices'])('warn', 'Failed to get audio stream, will try again with relaxed contraints', { error, constraints, relaxedContraints });
8386
+ return getAudioStream(relaxedContraints);
8387
+ }
8379
8388
  getLogger(['devices'])('error', 'Failed to get audio stream', {
8380
8389
  error,
8381
8390
  constraints,
@@ -8395,7 +8404,7 @@ const getVideoStream = async (trackConstraints) => {
8395
8404
  const constraints = {
8396
8405
  video: {
8397
8406
  ...videoDeviceConstraints.video,
8398
- ...normalizeContraints(trackConstraints),
8407
+ ...trackConstraints,
8399
8408
  },
8400
8409
  };
8401
8410
  try {
@@ -8406,6 +8415,13 @@ const getVideoStream = async (trackConstraints) => {
8406
8415
  return await getStream(constraints);
8407
8416
  }
8408
8417
  catch (error) {
8418
+ if (error instanceof DOMException &&
8419
+ error.name === 'OverconstrainedError' &&
8420
+ trackConstraints?.deviceId) {
8421
+ const { deviceId, ...relaxedContraints } = trackConstraints;
8422
+ getLogger(['devices'])('warn', 'Failed to get video stream, will try again with relaxed contraints', { error, constraints, relaxedContraints });
8423
+ return getVideoStream(relaxedContraints);
8424
+ }
8409
8425
  getLogger(['devices'])('error', 'Failed to get video stream', {
8410
8426
  error,
8411
8427
  constraints,
@@ -8413,16 +8429,6 @@ const getVideoStream = async (trackConstraints) => {
8413
8429
  throw error;
8414
8430
  }
8415
8431
  };
8416
- function normalizeContraints(constraints) {
8417
- if (constraints?.deviceId === 'default' ||
8418
- (typeof constraints?.deviceId === 'object' &&
8419
- 'exact' in constraints.deviceId &&
8420
- constraints.deviceId.exact === 'default')) {
8421
- const { deviceId, ...contraintsWithoutDeviceId } = constraints;
8422
- return contraintsWithoutDeviceId;
8423
- }
8424
- return constraints;
8425
- }
8426
8432
  /**
8427
8433
  * Prompts the user for a permission to share a screen.
8428
8434
  * If the user grants the permission, a screen sharing stream is returned. Throws otherwise.
@@ -8649,7 +8655,6 @@ class InputMediaDeviceManager {
8649
8655
  }
8650
8656
  catch (error) {
8651
8657
  this.state.setDevice(prevDeviceId);
8652
- await this.applySettingsToStream();
8653
8658
  throw error;
8654
8659
  }
8655
8660
  }
@@ -9944,7 +9949,7 @@ class Call {
9944
9949
  /**
9945
9950
  * Leave the call and stop the media streams that were published by the call.
9946
9951
  */
9947
- this.leave = async ({ reject = false, reason = 'user is leaving the call', } = {}) => {
9952
+ this.leave = async ({ reject, reason = 'user is leaving the call', } = {}) => {
9948
9953
  await withoutConcurrency(this.joinLeaveConcurrencyTag, async () => {
9949
9954
  const callingState = this.state.callingState;
9950
9955
  if (callingState === exports.CallingState.LEFT) {
@@ -9960,14 +9965,15 @@ class Call {
9960
9965
  };
9961
9966
  await waitUntilCallJoined();
9962
9967
  }
9963
- if (callingState === exports.CallingState.RINGING) {
9968
+ if (callingState === exports.CallingState.RINGING && reject !== false) {
9964
9969
  if (reject) {
9965
9970
  await this.reject(reason);
9966
9971
  }
9967
9972
  else {
9973
+ // if reject was undefined, we still have to cancel the call automatically
9974
+ // when I am the creator and everyone else left the call
9968
9975
  const hasOtherParticipants = this.state.remoteParticipants.length > 0;
9969
9976
  if (this.isCreatedByMe && !hasOtherParticipants) {
9970
- // I'm the one who started the call, so I should cancel it when there are no other participants.
9971
9977
  await this.reject('cancel');
9972
9978
  }
9973
9979
  }
@@ -12633,7 +12639,7 @@ class StreamClient {
12633
12639
  return await this.wsConnection.connect(this.defaultWSTimeout);
12634
12640
  };
12635
12641
  this.getUserAgent = () => {
12636
- const version = "1.11.9";
12642
+ const version = "1.11.11";
12637
12643
  return (this.userAgent ||
12638
12644
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
12639
12645
  };