@stream-io/video-client 1.27.1 → 1.27.2
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 +6 -0
- package/dist/index.browser.es.js +53 -59
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +53 -59
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +53 -59
- package/dist/index.es.js.map +1 -1
- package/dist/src/coordinator/connection/client.d.ts +1 -5
- package/dist/src/devices/devices.d.ts +0 -7
- package/dist/src/devices/index.d.ts +1 -0
- package/dist/src/devices/utils.d.ts +7 -0
- package/package.json +1 -1
- package/src/Call.ts +6 -0
- package/src/StreamSfuClient.ts +3 -2
- package/src/coordinator/connection/client.ts +27 -46
- package/src/devices/BrowserPermission.ts +1 -1
- package/src/devices/devices.ts +0 -18
- package/src/devices/index.ts +1 -0
- package/src/devices/utils.ts +17 -0
package/dist/index.es.js
CHANGED
|
@@ -5915,7 +5915,7 @@ const aggregate = (stats) => {
|
|
|
5915
5915
|
return report;
|
|
5916
5916
|
};
|
|
5917
5917
|
|
|
5918
|
-
const version = "1.27.
|
|
5918
|
+
const version = "1.27.2";
|
|
5919
5919
|
const [major, minor, patch] = version.split('.');
|
|
5920
5920
|
let sdkInfo = {
|
|
5921
5921
|
type: SdkType.PLAIN_JAVASCRIPT,
|
|
@@ -8070,7 +8070,6 @@ class StreamSfuClient {
|
|
|
8070
8070
|
const current = this.joinResponseTask;
|
|
8071
8071
|
let timeoutId = undefined;
|
|
8072
8072
|
const unsubscribe = this.dispatcher.on('joinResponse', (joinResponse) => {
|
|
8073
|
-
this.logger('debug', 'Received joinResponse', joinResponse);
|
|
8074
8073
|
clearTimeout(timeoutId);
|
|
8075
8074
|
unsubscribe();
|
|
8076
8075
|
this.keepAlive();
|
|
@@ -8078,7 +8077,9 @@ class StreamSfuClient {
|
|
|
8078
8077
|
});
|
|
8079
8078
|
timeoutId = setTimeout(() => {
|
|
8080
8079
|
unsubscribe();
|
|
8081
|
-
|
|
8080
|
+
const message = `Waiting for "joinResponse" has timed out after ${this.joinResponseTimeout}ms`;
|
|
8081
|
+
this.tracer?.trace('joinRequestTimeout', message);
|
|
8082
|
+
current.reject(new Error(message));
|
|
8082
8083
|
}, this.joinResponseTimeout);
|
|
8083
8084
|
const joinRequest = SfuRequest.create({
|
|
8084
8085
|
requestPayload: {
|
|
@@ -9422,6 +9423,25 @@ const CallTypes = new CallTypesRegistry([
|
|
|
9422
9423
|
}),
|
|
9423
9424
|
]);
|
|
9424
9425
|
|
|
9426
|
+
/**
|
|
9427
|
+
* Deactivates MediaStream (stops and removes tracks) to be later garbage collected
|
|
9428
|
+
*
|
|
9429
|
+
* @param stream MediaStream
|
|
9430
|
+
* @returns void
|
|
9431
|
+
*/
|
|
9432
|
+
const disposeOfMediaStream = (stream) => {
|
|
9433
|
+
if (!stream.active)
|
|
9434
|
+
return;
|
|
9435
|
+
stream.getTracks().forEach((track) => {
|
|
9436
|
+
track.stop();
|
|
9437
|
+
});
|
|
9438
|
+
// @ts-expect-error release() is present in react-native-webrtc and must be called to dispose the stream
|
|
9439
|
+
if (typeof stream.release === 'function') {
|
|
9440
|
+
// @ts-expect-error - release() is present in react-native-webrtc
|
|
9441
|
+
stream.release();
|
|
9442
|
+
}
|
|
9443
|
+
};
|
|
9444
|
+
|
|
9425
9445
|
class BrowserPermission {
|
|
9426
9446
|
constructor(permission) {
|
|
9427
9447
|
this.permission = permission;
|
|
@@ -9819,24 +9839,6 @@ const deviceIds$ = typeof navigator !== 'undefined' &&
|
|
|
9819
9839
|
typeof navigator.mediaDevices !== 'undefined'
|
|
9820
9840
|
? getDeviceChangeObserver().pipe(startWith(undefined), concatMap(() => navigator.mediaDevices.enumerateDevices()), shareReplay(1))
|
|
9821
9841
|
: undefined;
|
|
9822
|
-
/**
|
|
9823
|
-
* Deactivates MediaStream (stops and removes tracks) to be later garbage collected
|
|
9824
|
-
*
|
|
9825
|
-
* @param stream MediaStream
|
|
9826
|
-
* @returns void
|
|
9827
|
-
*/
|
|
9828
|
-
const disposeOfMediaStream = (stream) => {
|
|
9829
|
-
if (!stream.active)
|
|
9830
|
-
return;
|
|
9831
|
-
stream.getTracks().forEach((track) => {
|
|
9832
|
-
track.stop();
|
|
9833
|
-
});
|
|
9834
|
-
// @ts-expect-error release() is present in react-native-webrtc and must be called to dispose the stream
|
|
9835
|
-
if (typeof stream.release === 'function') {
|
|
9836
|
-
// @ts-expect-error - release() is present in react-native-webrtc
|
|
9837
|
-
stream.release();
|
|
9838
|
-
}
|
|
9839
|
-
};
|
|
9840
9842
|
/**
|
|
9841
9843
|
* Resolves `default` device id into the real device id. Some browsers (notably,
|
|
9842
9844
|
* Chromium-based) report device with id `default` among audio input and output
|
|
@@ -11850,6 +11852,12 @@ class Call {
|
|
|
11850
11852
|
}
|
|
11851
11853
|
catch (err) {
|
|
11852
11854
|
this.logger('warn', `Failed to join call (${attempt})`, this.cid);
|
|
11855
|
+
if (err instanceof ErrorFromResponse && err.unrecoverable) {
|
|
11856
|
+
// if the error is unrecoverable, we should not retry as that signals
|
|
11857
|
+
// that connectivity is good, but the coordinator doesn't allow the user
|
|
11858
|
+
// to join the call due to some reason (e.g., ended call, expired token...)
|
|
11859
|
+
throw err;
|
|
11860
|
+
}
|
|
11853
11861
|
const sfuId = this.credentials?.server.edge_name || '';
|
|
11854
11862
|
const failures = (sfuJoinFailures.get(sfuId) || 0) + 1;
|
|
11855
11863
|
sfuJoinFailures.set(sfuId, failures);
|
|
@@ -14359,12 +14367,6 @@ class StreamClient {
|
|
|
14359
14367
|
response,
|
|
14360
14368
|
});
|
|
14361
14369
|
};
|
|
14362
|
-
this._logApiError = (type, url, error) => {
|
|
14363
|
-
this.logger('error', `client:${type} - Error - url: ${url}`, {
|
|
14364
|
-
url,
|
|
14365
|
-
error,
|
|
14366
|
-
});
|
|
14367
|
-
};
|
|
14368
14370
|
this.doAxiosRequest = async (type, url, data, options = {}) => {
|
|
14369
14371
|
if (!options.publicEndpoint) {
|
|
14370
14372
|
await Promise.all([
|
|
@@ -14411,27 +14413,36 @@ class StreamClient {
|
|
|
14411
14413
|
}
|
|
14412
14414
|
this._logApiResponse(type, url, response);
|
|
14413
14415
|
this.consecutiveFailures = 0;
|
|
14414
|
-
return
|
|
14416
|
+
return response.data;
|
|
14415
14417
|
}
|
|
14416
14418
|
catch (e /**TODO: generalize error types */) {
|
|
14417
14419
|
e.client_request_id = requestConfig.headers?.['x-client-request-id'];
|
|
14418
14420
|
this.consecutiveFailures += 1;
|
|
14419
|
-
|
|
14420
|
-
|
|
14421
|
-
|
|
14422
|
-
|
|
14423
|
-
|
|
14424
|
-
|
|
14425
|
-
|
|
14426
|
-
|
|
14427
|
-
|
|
14428
|
-
|
|
14421
|
+
const { response } = e;
|
|
14422
|
+
if (!response || !isErrorResponse(response)) {
|
|
14423
|
+
this.logger('error', `client:${type} url: ${url}`, e);
|
|
14424
|
+
throw e;
|
|
14425
|
+
}
|
|
14426
|
+
const { data: responseData, status } = response;
|
|
14427
|
+
const isTokenExpired = responseData.code === KnownCodes.TOKEN_EXPIRED;
|
|
14428
|
+
if (isTokenExpired && !this.tokenManager.isStatic()) {
|
|
14429
|
+
this.logger('warn', `client:${type}: url: ${url}`, response);
|
|
14430
|
+
if (this.consecutiveFailures > 1) {
|
|
14431
|
+
await sleep(retryInterval(this.consecutiveFailures));
|
|
14429
14432
|
}
|
|
14430
|
-
|
|
14433
|
+
// refresh and retry the request
|
|
14434
|
+
await this.tokenManager.loadToken();
|
|
14435
|
+
return await this.doAxiosRequest(type, url, data, options);
|
|
14431
14436
|
}
|
|
14432
14437
|
else {
|
|
14433
|
-
this.
|
|
14434
|
-
throw
|
|
14438
|
+
this.logger('error', `client:${type} url: ${url}`, response);
|
|
14439
|
+
throw new ErrorFromResponse({
|
|
14440
|
+
message: `Stream error code ${responseData.code}: ${responseData.message}`,
|
|
14441
|
+
code: responseData.code ?? null,
|
|
14442
|
+
unrecoverable: responseData.unrecoverable ?? null,
|
|
14443
|
+
response: response,
|
|
14444
|
+
status: status,
|
|
14445
|
+
});
|
|
14435
14446
|
}
|
|
14436
14447
|
}
|
|
14437
14448
|
};
|
|
@@ -14454,23 +14465,6 @@ class StreamClient {
|
|
|
14454
14465
|
params,
|
|
14455
14466
|
});
|
|
14456
14467
|
};
|
|
14457
|
-
this.errorFromResponse = (response) => {
|
|
14458
|
-
const { data, status } = response;
|
|
14459
|
-
return new ErrorFromResponse({
|
|
14460
|
-
message: `Stream error code ${data.code}: ${data.message}`,
|
|
14461
|
-
code: data.code ?? null,
|
|
14462
|
-
unrecoverable: data.unrecoverable ?? null,
|
|
14463
|
-
response: response,
|
|
14464
|
-
status: status,
|
|
14465
|
-
});
|
|
14466
|
-
};
|
|
14467
|
-
this.handleResponse = (response) => {
|
|
14468
|
-
const data = response.data;
|
|
14469
|
-
if (isErrorResponse(response)) {
|
|
14470
|
-
throw this.errorFromResponse(response);
|
|
14471
|
-
}
|
|
14472
|
-
return data;
|
|
14473
|
-
};
|
|
14474
14468
|
this.dispatchEvent = (event) => {
|
|
14475
14469
|
this.logger('debug', `Dispatching event: ${event.type}`, event);
|
|
14476
14470
|
if (!this.listeners)
|
|
@@ -14503,7 +14497,7 @@ class StreamClient {
|
|
|
14503
14497
|
this.getUserAgent = () => {
|
|
14504
14498
|
if (!this.cachedUserAgent) {
|
|
14505
14499
|
const { clientAppIdentifier = {} } = this.options;
|
|
14506
|
-
const { sdkName = 'js', sdkVersion = "1.27.
|
|
14500
|
+
const { sdkName = 'js', sdkVersion = "1.27.2", ...extras } = clientAppIdentifier;
|
|
14507
14501
|
this.cachedUserAgent = [
|
|
14508
14502
|
`stream-video-${sdkName}-v${sdkVersion}`,
|
|
14509
14503
|
...Object.entries(extras).map(([key, value]) => `${key}=${value}`),
|