myio-js-library 0.1.214 → 0.1.215

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 CHANGED
@@ -29206,13 +29206,31 @@ var DefaultSettingsPersister = class {
29206
29206
  };
29207
29207
 
29208
29208
  // src/components/premium-modals/settings/SettingsFetcher.ts
29209
- var DefaultSettingsFetcher = class {
29209
+ var DefaultSettingsFetcher = class _DefaultSettingsFetcher {
29210
29210
  jwtToken;
29211
29211
  tbBaseUrl;
29212
+ static FETCH_TIMEOUT_MS = 8e3;
29213
+ // 8 second timeout
29212
29214
  constructor(jwtToken, apiConfig) {
29213
29215
  this.jwtToken = jwtToken;
29214
29216
  this.tbBaseUrl = apiConfig?.tbBaseUrl || window.location.origin;
29215
29217
  }
29218
+ /**
29219
+ * Fetch with timeout to prevent hanging requests from blocking modal render
29220
+ */
29221
+ async fetchWithTimeout(url, options, timeoutMs = _DefaultSettingsFetcher.FETCH_TIMEOUT_MS) {
29222
+ const controller = new AbortController();
29223
+ const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
29224
+ try {
29225
+ const response = await fetch(url, {
29226
+ ...options,
29227
+ signal: controller.signal
29228
+ });
29229
+ return response;
29230
+ } finally {
29231
+ clearTimeout(timeoutId);
29232
+ }
29233
+ }
29216
29234
  async fetchCurrentSettings(deviceId, jwtToken, scope = "SERVER_SCOPE") {
29217
29235
  try {
29218
29236
  const [entityResult, attributesResult] = await Promise.allSettled([
@@ -29246,9 +29264,12 @@ var DefaultSettingsFetcher = class {
29246
29264
  }
29247
29265
  }
29248
29266
  async fetchDeviceEntity(deviceId) {
29249
- const response = await fetch(`${this.tbBaseUrl}/api/device/${deviceId}`, {
29250
- headers: { "X-Authorization": `Bearer ${this.jwtToken}` }
29251
- });
29267
+ const response = await this.fetchWithTimeout(
29268
+ `${this.tbBaseUrl}/api/device/${deviceId}`,
29269
+ {
29270
+ headers: { "X-Authorization": `Bearer ${this.jwtToken}` }
29271
+ }
29272
+ );
29252
29273
  if (!response.ok) {
29253
29274
  throw new Error(
29254
29275
  `Failed to fetch device entity: ${response.status} ${response.statusText}`
@@ -29260,7 +29281,7 @@ var DefaultSettingsFetcher = class {
29260
29281
  };
29261
29282
  }
29262
29283
  async fetchDeviceAttributes(deviceId, scope) {
29263
- const response = await fetch(
29284
+ const response = await this.fetchWithTimeout(
29264
29285
  `${this.tbBaseUrl}/api/plugins/telemetry/DEVICE/${deviceId}/values/attributes/${scope}`,
29265
29286
  {
29266
29287
  headers: { "X-Authorization": `Bearer ${this.jwtToken}` }
@@ -29469,12 +29490,16 @@ var SettingsController = class {
29469
29490
  const tbBaseUrl = this.params.api?.tbBaseUrl || window.location.origin;
29470
29491
  const url = `${tbBaseUrl}/api/plugins/telemetry/CUSTOMER/${customerId}/values/attributes/SERVER_SCOPE?keys=mapInstantaneousPower`;
29471
29492
  console.log("[SettingsModal] RFC-0080: Fetching GLOBAL from:", url);
29493
+ const controller = new AbortController();
29494
+ const timeoutId = setTimeout(() => controller.abort(), 8e3);
29472
29495
  const response = await fetch(url, {
29473
29496
  headers: {
29474
29497
  "X-Authorization": `Bearer ${jwtToken}`,
29475
29498
  "Content-Type": "application/json"
29476
- }
29499
+ },
29500
+ signal: controller.signal
29477
29501
  });
29502
+ clearTimeout(timeoutId);
29478
29503
  if (!response.ok) {
29479
29504
  throw new Error(`HTTP ${response.status}`);
29480
29505
  }
package/dist/index.js CHANGED
@@ -29034,13 +29034,31 @@ var DefaultSettingsPersister = class {
29034
29034
  };
29035
29035
 
29036
29036
  // src/components/premium-modals/settings/SettingsFetcher.ts
29037
- var DefaultSettingsFetcher = class {
29037
+ var DefaultSettingsFetcher = class _DefaultSettingsFetcher {
29038
29038
  jwtToken;
29039
29039
  tbBaseUrl;
29040
+ static FETCH_TIMEOUT_MS = 8e3;
29041
+ // 8 second timeout
29040
29042
  constructor(jwtToken, apiConfig) {
29041
29043
  this.jwtToken = jwtToken;
29042
29044
  this.tbBaseUrl = apiConfig?.tbBaseUrl || window.location.origin;
29043
29045
  }
29046
+ /**
29047
+ * Fetch with timeout to prevent hanging requests from blocking modal render
29048
+ */
29049
+ async fetchWithTimeout(url, options, timeoutMs = _DefaultSettingsFetcher.FETCH_TIMEOUT_MS) {
29050
+ const controller = new AbortController();
29051
+ const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
29052
+ try {
29053
+ const response = await fetch(url, {
29054
+ ...options,
29055
+ signal: controller.signal
29056
+ });
29057
+ return response;
29058
+ } finally {
29059
+ clearTimeout(timeoutId);
29060
+ }
29061
+ }
29044
29062
  async fetchCurrentSettings(deviceId, jwtToken, scope = "SERVER_SCOPE") {
29045
29063
  try {
29046
29064
  const [entityResult, attributesResult] = await Promise.allSettled([
@@ -29074,9 +29092,12 @@ var DefaultSettingsFetcher = class {
29074
29092
  }
29075
29093
  }
29076
29094
  async fetchDeviceEntity(deviceId) {
29077
- const response = await fetch(`${this.tbBaseUrl}/api/device/${deviceId}`, {
29078
- headers: { "X-Authorization": `Bearer ${this.jwtToken}` }
29079
- });
29095
+ const response = await this.fetchWithTimeout(
29096
+ `${this.tbBaseUrl}/api/device/${deviceId}`,
29097
+ {
29098
+ headers: { "X-Authorization": `Bearer ${this.jwtToken}` }
29099
+ }
29100
+ );
29080
29101
  if (!response.ok) {
29081
29102
  throw new Error(
29082
29103
  `Failed to fetch device entity: ${response.status} ${response.statusText}`
@@ -29088,7 +29109,7 @@ var DefaultSettingsFetcher = class {
29088
29109
  };
29089
29110
  }
29090
29111
  async fetchDeviceAttributes(deviceId, scope) {
29091
- const response = await fetch(
29112
+ const response = await this.fetchWithTimeout(
29092
29113
  `${this.tbBaseUrl}/api/plugins/telemetry/DEVICE/${deviceId}/values/attributes/${scope}`,
29093
29114
  {
29094
29115
  headers: { "X-Authorization": `Bearer ${this.jwtToken}` }
@@ -29297,12 +29318,16 @@ var SettingsController = class {
29297
29318
  const tbBaseUrl = this.params.api?.tbBaseUrl || window.location.origin;
29298
29319
  const url = `${tbBaseUrl}/api/plugins/telemetry/CUSTOMER/${customerId}/values/attributes/SERVER_SCOPE?keys=mapInstantaneousPower`;
29299
29320
  console.log("[SettingsModal] RFC-0080: Fetching GLOBAL from:", url);
29321
+ const controller = new AbortController();
29322
+ const timeoutId = setTimeout(() => controller.abort(), 8e3);
29300
29323
  const response = await fetch(url, {
29301
29324
  headers: {
29302
29325
  "X-Authorization": `Bearer ${jwtToken}`,
29303
29326
  "Content-Type": "application/json"
29304
- }
29327
+ },
29328
+ signal: controller.signal
29305
29329
  });
29330
+ clearTimeout(timeoutId);
29306
29331
  if (!response.ok) {
29307
29332
  throw new Error(`HTTP ${response.status}`);
29308
29333
  }
@@ -28848,13 +28848,31 @@
28848
28848
  };
28849
28849
 
28850
28850
  // src/components/premium-modals/settings/SettingsFetcher.ts
28851
- var DefaultSettingsFetcher = class {
28851
+ var DefaultSettingsFetcher = class _DefaultSettingsFetcher {
28852
28852
  jwtToken;
28853
28853
  tbBaseUrl;
28854
+ static FETCH_TIMEOUT_MS = 8e3;
28855
+ // 8 second timeout
28854
28856
  constructor(jwtToken, apiConfig) {
28855
28857
  this.jwtToken = jwtToken;
28856
28858
  this.tbBaseUrl = apiConfig?.tbBaseUrl || window.location.origin;
28857
28859
  }
28860
+ /**
28861
+ * Fetch with timeout to prevent hanging requests from blocking modal render
28862
+ */
28863
+ async fetchWithTimeout(url, options, timeoutMs = _DefaultSettingsFetcher.FETCH_TIMEOUT_MS) {
28864
+ const controller = new AbortController();
28865
+ const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
28866
+ try {
28867
+ const response = await fetch(url, {
28868
+ ...options,
28869
+ signal: controller.signal
28870
+ });
28871
+ return response;
28872
+ } finally {
28873
+ clearTimeout(timeoutId);
28874
+ }
28875
+ }
28858
28876
  async fetchCurrentSettings(deviceId, jwtToken, scope = "SERVER_SCOPE") {
28859
28877
  try {
28860
28878
  const [entityResult, attributesResult] = await Promise.allSettled([
@@ -28888,9 +28906,12 @@
28888
28906
  }
28889
28907
  }
28890
28908
  async fetchDeviceEntity(deviceId) {
28891
- const response = await fetch(`${this.tbBaseUrl}/api/device/${deviceId}`, {
28892
- headers: { "X-Authorization": `Bearer ${this.jwtToken}` }
28893
- });
28909
+ const response = await this.fetchWithTimeout(
28910
+ `${this.tbBaseUrl}/api/device/${deviceId}`,
28911
+ {
28912
+ headers: { "X-Authorization": `Bearer ${this.jwtToken}` }
28913
+ }
28914
+ );
28894
28915
  if (!response.ok) {
28895
28916
  throw new Error(
28896
28917
  `Failed to fetch device entity: ${response.status} ${response.statusText}`
@@ -28902,7 +28923,7 @@
28902
28923
  };
28903
28924
  }
28904
28925
  async fetchDeviceAttributes(deviceId, scope) {
28905
- const response = await fetch(
28926
+ const response = await this.fetchWithTimeout(
28906
28927
  `${this.tbBaseUrl}/api/plugins/telemetry/DEVICE/${deviceId}/values/attributes/${scope}`,
28907
28928
  {
28908
28929
  headers: { "X-Authorization": `Bearer ${this.jwtToken}` }
@@ -29111,12 +29132,16 @@
29111
29132
  const tbBaseUrl = this.params.api?.tbBaseUrl || window.location.origin;
29112
29133
  const url = `${tbBaseUrl}/api/plugins/telemetry/CUSTOMER/${customerId}/values/attributes/SERVER_SCOPE?keys=mapInstantaneousPower`;
29113
29134
  console.log("[SettingsModal] RFC-0080: Fetching GLOBAL from:", url);
29135
+ const controller = new AbortController();
29136
+ const timeoutId = setTimeout(() => controller.abort(), 8e3);
29114
29137
  const response = await fetch(url, {
29115
29138
  headers: {
29116
29139
  "X-Authorization": `Bearer ${jwtToken}`,
29117
29140
  "Content-Type": "application/json"
29118
- }
29141
+ },
29142
+ signal: controller.signal
29119
29143
  });
29144
+ clearTimeout(timeoutId);
29120
29145
  if (!response.ok) {
29121
29146
  throw new Error(`HTTP ${response.status}`);
29122
29147
  }