@stream-io/video-client 1.7.3 → 1.7.4
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 +7 -0
- package/dist/index.browser.es.js +31 -27
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +31 -27
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +31 -27
- package/dist/index.es.js.map +1 -1
- package/dist/src/coordinator/connection/location.d.ts +1 -1
- package/dist/src/coordinator/connection/types.d.ts +4 -0
- package/package.json +1 -1
- package/src/coordinator/connection/client.ts +1 -0
- package/src/coordinator/connection/location.ts +28 -22
- package/src/coordinator/connection/types.ts +4 -0
package/dist/index.cjs.js
CHANGED
|
@@ -2956,7 +2956,7 @@ const logLevels = Object.freeze({
|
|
|
2956
2956
|
warn: 3,
|
|
2957
2957
|
error: 4,
|
|
2958
2958
|
});
|
|
2959
|
-
let logger
|
|
2959
|
+
let logger;
|
|
2960
2960
|
let level = 'info';
|
|
2961
2961
|
const logToConsole = (logLevel, message, ...args) => {
|
|
2962
2962
|
let logMethod;
|
|
@@ -2990,7 +2990,7 @@ const logToConsole = (logLevel, message, ...args) => {
|
|
|
2990
2990
|
logMethod(message, ...args);
|
|
2991
2991
|
};
|
|
2992
2992
|
const setLogger = (l, lvl) => {
|
|
2993
|
-
logger
|
|
2993
|
+
logger = l;
|
|
2994
2994
|
if (lvl) {
|
|
2995
2995
|
setLogLevel(lvl);
|
|
2996
2996
|
}
|
|
@@ -3000,7 +3000,7 @@ const setLogLevel = (l) => {
|
|
|
3000
3000
|
};
|
|
3001
3001
|
const getLogLevel = () => level;
|
|
3002
3002
|
const getLogger = (withTags) => {
|
|
3003
|
-
const loggerMethod = logger
|
|
3003
|
+
const loggerMethod = logger || logToConsole;
|
|
3004
3004
|
const tags = (withTags || []).filter(Boolean).join(':');
|
|
3005
3005
|
const result = (logLevel, message, ...args) => {
|
|
3006
3006
|
if (logLevels[logLevel] >= logLevels[level]) {
|
|
@@ -3041,7 +3041,7 @@ const retryable = async (rpc, signal) => {
|
|
|
3041
3041
|
return result;
|
|
3042
3042
|
};
|
|
3043
3043
|
|
|
3044
|
-
const version = "1.7.
|
|
3044
|
+
const version = "1.7.4";
|
|
3045
3045
|
const [major, minor, patch] = version.split('.');
|
|
3046
3046
|
let sdkInfo = {
|
|
3047
3047
|
type: SdkType.PLAIN_JAVASCRIPT,
|
|
@@ -11927,27 +11927,31 @@ class WSConnectionFallback {
|
|
|
11927
11927
|
}
|
|
11928
11928
|
}
|
|
11929
11929
|
|
|
11930
|
-
const
|
|
11931
|
-
const
|
|
11932
|
-
|
|
11933
|
-
|
|
11934
|
-
|
|
11935
|
-
|
|
11936
|
-
const
|
|
11937
|
-
|
|
11938
|
-
|
|
11939
|
-
|
|
11940
|
-
|
|
11941
|
-
|
|
11942
|
-
|
|
11943
|
-
|
|
11944
|
-
|
|
11945
|
-
|
|
11946
|
-
|
|
11947
|
-
|
|
11948
|
-
|
|
11949
|
-
|
|
11950
|
-
|
|
11930
|
+
const getLocationHint = async (hintUrl = `https://hint.stream-io-video.com/`, timeout = 2000, maxAttempts = 3) => {
|
|
11931
|
+
const logger = getLogger(['location-hint']);
|
|
11932
|
+
let attempt = 0;
|
|
11933
|
+
let locationHint = 'ERR';
|
|
11934
|
+
do {
|
|
11935
|
+
const abortController = new AbortController();
|
|
11936
|
+
const timeoutId = setTimeout(() => abortController.abort(), timeout);
|
|
11937
|
+
try {
|
|
11938
|
+
const response = await fetch(hintUrl, {
|
|
11939
|
+
method: 'HEAD',
|
|
11940
|
+
signal: abortController.signal,
|
|
11941
|
+
});
|
|
11942
|
+
const awsPop = response.headers.get('x-amz-cf-pop') || 'ERR';
|
|
11943
|
+
logger('debug', `Location header: ${awsPop}`);
|
|
11944
|
+
locationHint = awsPop.substring(0, 3); // AMS1-P2 -> AMS
|
|
11945
|
+
}
|
|
11946
|
+
catch (e) {
|
|
11947
|
+
logger('warn', `Failed to get location hint from ${hintUrl}`, e);
|
|
11948
|
+
locationHint = 'ERR';
|
|
11949
|
+
}
|
|
11950
|
+
finally {
|
|
11951
|
+
clearTimeout(timeoutId);
|
|
11952
|
+
}
|
|
11953
|
+
} while (locationHint === 'ERR' && ++attempt < maxAttempts);
|
|
11954
|
+
return locationHint;
|
|
11951
11955
|
};
|
|
11952
11956
|
|
|
11953
11957
|
class StreamClient {
|
|
@@ -12388,7 +12392,7 @@ class StreamClient {
|
|
|
12388
12392
|
});
|
|
12389
12393
|
};
|
|
12390
12394
|
this.getUserAgent = () => {
|
|
12391
|
-
const version = "1.7.
|
|
12395
|
+
const version = "1.7.4";
|
|
12392
12396
|
return (this.userAgent ||
|
|
12393
12397
|
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
|
|
12394
12398
|
};
|
|
@@ -12471,7 +12475,7 @@ class StreamClient {
|
|
|
12471
12475
|
this.browser = inputOptions.browser || typeof window !== 'undefined';
|
|
12472
12476
|
this.node = !this.browser;
|
|
12473
12477
|
if (this.browser) {
|
|
12474
|
-
this.locationHint = getLocationHint(options?.locationHintUrl, options?.locationHintTimeout);
|
|
12478
|
+
this.locationHint = getLocationHint(options?.locationHintUrl, options?.locationHintTimeout, options?.locationHintMaxAttempts);
|
|
12475
12479
|
}
|
|
12476
12480
|
this.options = {
|
|
12477
12481
|
timeout: 5000,
|