@stream-io/video-client 1.12.1 → 1.12.3
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 +17 -0
- package/dist/index.browser.es.js +32 -23
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +32 -23
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +32 -23
- package/dist/index.es.js.map +1 -1
- package/dist/src/coordinator/connection/types.d.ts +1 -1
- package/package.json +2 -3
- package/src/StreamVideoClient.ts +2 -3
- package/src/coordinator/connection/types.ts +1 -1
- package/src/devices/BrowserPermission.ts +7 -3
- package/src/devices/devices.ts +21 -18
- package/src/timers/worker.build.ts +7 -5
package/dist/index.es.js
CHANGED
|
@@ -3300,7 +3300,7 @@ const retryable = async (rpc, signal) => {
|
|
|
3300
3300
|
return result;
|
|
3301
3301
|
};
|
|
3302
3302
|
|
|
3303
|
-
const version = "1.12.
|
|
3303
|
+
const version = "1.12.3";
|
|
3304
3304
|
const [major, minor, patch] = version.split('.');
|
|
3305
3305
|
let sdkInfo = {
|
|
3306
3306
|
type: SdkType.PLAIN_JAVASCRIPT,
|
|
@@ -6449,14 +6449,16 @@ function lazy(factory) {
|
|
|
6449
6449
|
};
|
|
6450
6450
|
}
|
|
6451
6451
|
|
|
6452
|
+
// Do not modify this file manually. Instead, edit worker.ts
|
|
6453
|
+
// and the run ./generate-timer-worker.sh
|
|
6452
6454
|
const timerWorker = {
|
|
6453
|
-
src: `
|
|
6454
|
-
self.addEventListener('message',
|
|
6455
|
-
|
|
6455
|
+
src: `const timerIdMapping = new Map();
|
|
6456
|
+
self.addEventListener('message', (event) => {
|
|
6457
|
+
const request = event.data;
|
|
6456
6458
|
switch (request.type) {
|
|
6457
6459
|
case 'setTimeout':
|
|
6458
6460
|
case 'setInterval':
|
|
6459
|
-
timerIdMapping.set(request.id, (request.type === 'setTimeout' ? setTimeout : setInterval)(
|
|
6461
|
+
timerIdMapping.set(request.id, (request.type === 'setTimeout' ? setTimeout : setInterval)(() => {
|
|
6460
6462
|
tick(request.id);
|
|
6461
6463
|
if (request.type === 'setTimeout') {
|
|
6462
6464
|
timerIdMapping.delete(request.id);
|
|
@@ -6471,7 +6473,7 @@ self.addEventListener('message', function (event) {
|
|
|
6471
6473
|
}
|
|
6472
6474
|
});
|
|
6473
6475
|
function tick(id) {
|
|
6474
|
-
|
|
6476
|
+
const message = { type: 'tick', id };
|
|
6475
6477
|
self.postMessage(message);
|
|
6476
6478
|
}`,
|
|
6477
6479
|
};
|
|
@@ -8320,7 +8322,7 @@ class BrowserPermission {
|
|
|
8320
8322
|
(this.wasPrompted && !forcePrompt)) {
|
|
8321
8323
|
const isGranted = this.state === 'granted';
|
|
8322
8324
|
if (!isGranted && throwOnNotAllowed) {
|
|
8323
|
-
throw new
|
|
8325
|
+
throw new Error('Permission was not granted previously, and prompting again is not allowed');
|
|
8324
8326
|
}
|
|
8325
8327
|
return isGranted;
|
|
8326
8328
|
}
|
|
@@ -8332,7 +8334,10 @@ class BrowserPermission {
|
|
|
8332
8334
|
return true;
|
|
8333
8335
|
}
|
|
8334
8336
|
catch (e) {
|
|
8335
|
-
if (e
|
|
8337
|
+
if (e &&
|
|
8338
|
+
typeof e === 'object' &&
|
|
8339
|
+
'name' in e &&
|
|
8340
|
+
(e.name === 'NotAllowedError' || e.name === 'SecurityError')) {
|
|
8336
8341
|
this.logger('info', 'Browser permission was not granted', {
|
|
8337
8342
|
permission: this.permission,
|
|
8338
8343
|
});
|
|
@@ -8487,6 +8492,14 @@ const getStream = async (constraints) => {
|
|
|
8487
8492
|
}
|
|
8488
8493
|
return stream;
|
|
8489
8494
|
};
|
|
8495
|
+
function isOverconstrainedError(error) {
|
|
8496
|
+
return (error &&
|
|
8497
|
+
typeof error === 'object' &&
|
|
8498
|
+
(('name' in error && error.name === 'OverconstrainedError') ||
|
|
8499
|
+
('message' in error &&
|
|
8500
|
+
typeof error.message === 'string' &&
|
|
8501
|
+
error.message.startsWith('OverconstrainedError'))));
|
|
8502
|
+
}
|
|
8490
8503
|
/**
|
|
8491
8504
|
* Returns an audio media stream that fulfills the given constraints.
|
|
8492
8505
|
* If no constraints are provided, it uses the browser's default ones.
|
|
@@ -8510,12 +8523,10 @@ const getAudioStream = async (trackConstraints) => {
|
|
|
8510
8523
|
return await getStream(constraints);
|
|
8511
8524
|
}
|
|
8512
8525
|
catch (error) {
|
|
8513
|
-
if (error
|
|
8514
|
-
|
|
8515
|
-
|
|
8516
|
-
|
|
8517
|
-
getLogger(['devices'])('warn', 'Failed to get audio stream, will try again with relaxed contraints', { error, constraints, relaxedContraints });
|
|
8518
|
-
return getAudioStream(relaxedContraints);
|
|
8526
|
+
if (isOverconstrainedError(error) && trackConstraints?.deviceId) {
|
|
8527
|
+
const { deviceId, ...relaxedConstraints } = trackConstraints;
|
|
8528
|
+
getLogger(['devices'])('warn', 'Failed to get audio stream, will try again with relaxed constraints', { error, constraints, relaxedConstraints });
|
|
8529
|
+
return getAudioStream(relaxedConstraints);
|
|
8519
8530
|
}
|
|
8520
8531
|
getLogger(['devices'])('error', 'Failed to get audio stream', {
|
|
8521
8532
|
error,
|
|
@@ -8547,12 +8558,10 @@ const getVideoStream = async (trackConstraints) => {
|
|
|
8547
8558
|
return await getStream(constraints);
|
|
8548
8559
|
}
|
|
8549
8560
|
catch (error) {
|
|
8550
|
-
if (error
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
getLogger(['devices'])('warn', 'Failed to get video stream, will try again with relaxed contraints', { error, constraints, relaxedContraints });
|
|
8555
|
-
return getVideoStream(relaxedContraints);
|
|
8561
|
+
if (isOverconstrainedError(error) && trackConstraints?.deviceId) {
|
|
8562
|
+
const { deviceId, ...relaxedConstraints } = trackConstraints;
|
|
8563
|
+
getLogger(['devices'])('warn', 'Failed to get video stream, will try again with relaxed constraints', { error, constraints, relaxedConstraints });
|
|
8564
|
+
return getVideoStream(relaxedConstraints);
|
|
8556
8565
|
}
|
|
8557
8566
|
getLogger(['devices'])('error', 'Failed to get video stream', {
|
|
8558
8567
|
error,
|
|
@@ -12801,7 +12810,7 @@ class StreamClient {
|
|
|
12801
12810
|
return await this.wsConnection.connect(this.defaultWSTimeout);
|
|
12802
12811
|
};
|
|
12803
12812
|
this.getUserAgent = () => {
|
|
12804
|
-
const version = "1.12.
|
|
12813
|
+
const version = "1.12.3";
|
|
12805
12814
|
return (this.userAgent ||
|
|
12806
12815
|
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
|
|
12807
12816
|
};
|
|
@@ -13222,13 +13231,13 @@ class StreamVideoClient {
|
|
|
13222
13231
|
if (typeof apiKeyOrArgs === 'string') {
|
|
13223
13232
|
logLevel = opts?.logLevel || logLevel;
|
|
13224
13233
|
logger = opts?.logger || logger;
|
|
13225
|
-
if (opts?.
|
|
13234
|
+
if (opts?.enableTimerWorker)
|
|
13226
13235
|
enableTimerWorker();
|
|
13227
13236
|
}
|
|
13228
13237
|
else {
|
|
13229
13238
|
logLevel = apiKeyOrArgs.options?.logLevel || logLevel;
|
|
13230
13239
|
logger = apiKeyOrArgs.options?.logger || logger;
|
|
13231
|
-
if (apiKeyOrArgs.options?.
|
|
13240
|
+
if (apiKeyOrArgs.options?.enableTimerWorker)
|
|
13232
13241
|
enableTimerWorker();
|
|
13233
13242
|
}
|
|
13234
13243
|
setLogger(logger, logLevel);
|