@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.es.js CHANGED
@@ -3298,7 +3298,7 @@ const retryable = async (rpc, signal) => {
3298
3298
  return result;
3299
3299
  };
3300
3300
 
3301
- const version = "1.11.9";
3301
+ const version = "1.11.11";
3302
3302
  const [major, minor, patch] = version.split('.');
3303
3303
  let sdkInfo = {
3304
3304
  type: SdkType.PLAIN_JAVASCRIPT,
@@ -6782,7 +6782,9 @@ const watchCallEnded = (call) => {
6782
6782
  const { callingState } = call.state;
6783
6783
  if (callingState !== CallingState.IDLE &&
6784
6784
  callingState !== CallingState.LEFT) {
6785
- call.leave({ reason: 'call.ended event received' }).catch((err) => {
6785
+ call
6786
+ .leave({ reason: 'call.ended event received', reject: false })
6787
+ .catch((err) => {
6786
6788
  call.logger('error', 'Failed to leave call after call.ended ', err);
6787
6789
  });
6788
6790
  }
@@ -8345,7 +8347,7 @@ const getAudioStream = async (trackConstraints) => {
8345
8347
  const constraints = {
8346
8348
  audio: {
8347
8349
  ...audioDeviceConstraints.audio,
8348
- ...normalizeContraints(trackConstraints),
8350
+ ...trackConstraints,
8349
8351
  },
8350
8352
  };
8351
8353
  try {
@@ -8356,6 +8358,13 @@ const getAudioStream = async (trackConstraints) => {
8356
8358
  return await getStream(constraints);
8357
8359
  }
8358
8360
  catch (error) {
8361
+ if (error instanceof DOMException &&
8362
+ error.name === 'OverconstrainedError' &&
8363
+ trackConstraints?.deviceId) {
8364
+ const { deviceId, ...relaxedContraints } = trackConstraints;
8365
+ getLogger(['devices'])('warn', 'Failed to get audio stream, will try again with relaxed contraints', { error, constraints, relaxedContraints });
8366
+ return getAudioStream(relaxedContraints);
8367
+ }
8359
8368
  getLogger(['devices'])('error', 'Failed to get audio stream', {
8360
8369
  error,
8361
8370
  constraints,
@@ -8375,7 +8384,7 @@ const getVideoStream = async (trackConstraints) => {
8375
8384
  const constraints = {
8376
8385
  video: {
8377
8386
  ...videoDeviceConstraints.video,
8378
- ...normalizeContraints(trackConstraints),
8387
+ ...trackConstraints,
8379
8388
  },
8380
8389
  };
8381
8390
  try {
@@ -8386,6 +8395,13 @@ const getVideoStream = async (trackConstraints) => {
8386
8395
  return await getStream(constraints);
8387
8396
  }
8388
8397
  catch (error) {
8398
+ if (error instanceof DOMException &&
8399
+ error.name === 'OverconstrainedError' &&
8400
+ trackConstraints?.deviceId) {
8401
+ const { deviceId, ...relaxedContraints } = trackConstraints;
8402
+ getLogger(['devices'])('warn', 'Failed to get video stream, will try again with relaxed contraints', { error, constraints, relaxedContraints });
8403
+ return getVideoStream(relaxedContraints);
8404
+ }
8389
8405
  getLogger(['devices'])('error', 'Failed to get video stream', {
8390
8406
  error,
8391
8407
  constraints,
@@ -8393,16 +8409,6 @@ const getVideoStream = async (trackConstraints) => {
8393
8409
  throw error;
8394
8410
  }
8395
8411
  };
8396
- function normalizeContraints(constraints) {
8397
- if (constraints?.deviceId === 'default' ||
8398
- (typeof constraints?.deviceId === 'object' &&
8399
- 'exact' in constraints.deviceId &&
8400
- constraints.deviceId.exact === 'default')) {
8401
- const { deviceId, ...contraintsWithoutDeviceId } = constraints;
8402
- return contraintsWithoutDeviceId;
8403
- }
8404
- return constraints;
8405
- }
8406
8412
  /**
8407
8413
  * Prompts the user for a permission to share a screen.
8408
8414
  * If the user grants the permission, a screen sharing stream is returned. Throws otherwise.
@@ -8629,7 +8635,6 @@ class InputMediaDeviceManager {
8629
8635
  }
8630
8636
  catch (error) {
8631
8637
  this.state.setDevice(prevDeviceId);
8632
- await this.applySettingsToStream();
8633
8638
  throw error;
8634
8639
  }
8635
8640
  }
@@ -9924,7 +9929,7 @@ class Call {
9924
9929
  /**
9925
9930
  * Leave the call and stop the media streams that were published by the call.
9926
9931
  */
9927
- this.leave = async ({ reject = false, reason = 'user is leaving the call', } = {}) => {
9932
+ this.leave = async ({ reject, reason = 'user is leaving the call', } = {}) => {
9928
9933
  await withoutConcurrency(this.joinLeaveConcurrencyTag, async () => {
9929
9934
  const callingState = this.state.callingState;
9930
9935
  if (callingState === CallingState.LEFT) {
@@ -9940,14 +9945,15 @@ class Call {
9940
9945
  };
9941
9946
  await waitUntilCallJoined();
9942
9947
  }
9943
- if (callingState === CallingState.RINGING) {
9948
+ if (callingState === CallingState.RINGING && reject !== false) {
9944
9949
  if (reject) {
9945
9950
  await this.reject(reason);
9946
9951
  }
9947
9952
  else {
9953
+ // if reject was undefined, we still have to cancel the call automatically
9954
+ // when I am the creator and everyone else left the call
9948
9955
  const hasOtherParticipants = this.state.remoteParticipants.length > 0;
9949
9956
  if (this.isCreatedByMe && !hasOtherParticipants) {
9950
- // I'm the one who started the call, so I should cancel it when there are no other participants.
9951
9957
  await this.reject('cancel');
9952
9958
  }
9953
9959
  }
@@ -12613,7 +12619,7 @@ class StreamClient {
12613
12619
  return await this.wsConnection.connect(this.defaultWSTimeout);
12614
12620
  };
12615
12621
  this.getUserAgent = () => {
12616
- const version = "1.11.9";
12622
+ const version = "1.11.11";
12617
12623
  return (this.userAgent ||
12618
12624
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
12619
12625
  };