@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/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$1;
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$1 = l;
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$1 || logToConsole;
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.3";
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 logger = getLogger(['location']);
11931
- const HINT_URL = `https://hint.stream-io-video.com/`;
11932
- const getLocationHint = async (hintUrl = HINT_URL, timeout = 2000) => {
11933
- const abortController = new AbortController();
11934
- const timeoutId = setTimeout(() => abortController.abort(), timeout);
11935
- try {
11936
- const response = await fetch(hintUrl, {
11937
- method: 'HEAD',
11938
- signal: abortController.signal,
11939
- });
11940
- const awsPop = response.headers.get('x-amz-cf-pop') || 'ERR';
11941
- logger('debug', `Location header: ${awsPop}`);
11942
- return awsPop.substring(0, 3); // AMS1-P2 -> AMS
11943
- }
11944
- catch (e) {
11945
- logger('warn', `Failed to get location hint from ${hintUrl}`, e);
11946
- return 'ERR';
11947
- }
11948
- finally {
11949
- clearTimeout(timeoutId);
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.3";
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,