@klauswuestefeld/jux-web 2024.4.1 → 2024.4.24

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/jux-web.js CHANGED
@@ -193,6 +193,7 @@ var juxWeb = (function (exports) {
193
193
  };
194
194
  let requestRunning = false;
195
195
  const maxRetries = 20;
196
+ const timeout = 15000;
196
197
  const backendRequest = (url_1, options_1, onSuccess_1, onError_1, onRedirect_1, ...args_1) => __awaiter$2(void 0, [url_1, options_1, onSuccess_1, onError_1, onRedirect_1, ...args_1], void 0, function* (url, options, onSuccess, onError, onRedirect, requestType = 'query', handleUnauthorized = defaultHandleUnauthorized, retrial = false, retrialNum = 0) {
197
198
  if (requestRunning && !retrial) { // only allow one request at a time
198
199
  setTimeout(() => backendRequest(url, options, onSuccess, onError, onRedirect, requestType, handleUnauthorized, false), 300);
@@ -207,10 +208,12 @@ var juxWeb = (function (exports) {
207
208
  }
208
209
  let response;
209
210
  requestRunning = true;
210
- const requestInit = Object.assign({}, options);
211
+ const controller = new AbortController();
212
+ let timeoutId;
211
213
  if (requestType === 'query') {
212
- requestInit.signal = AbortSignal.timeout(15000);
214
+ timeoutId = setTimeout(() => controller.abort(), timeout); // abort connections that take longer than the value set on the timeout const
213
215
  }
216
+ const requestInit = Object.assign(Object.assign({}, options), { signal: controller.signal });
214
217
  if (onRedirect)
215
218
  requestInit.redirect = 'manual'; // Treat redirects manually instead of following them automatically.
216
219
  try {
@@ -246,11 +249,15 @@ var juxWeb = (function (exports) {
246
249
  return;
247
250
  }
248
251
  finally {
249
- requestRunning = false;
252
+ clearTimeout(timeoutId);
250
253
  }
251
254
  removeOverlay();
252
255
  if (onRedirect)
253
256
  onRedirect(response);
257
+ if (response.type === 'opaqueredirect') {
258
+ console.info('opaqueredirect'); // Stop processing request if its an opaqueredirect
259
+ return;
260
+ }
254
261
  if (response.status === 401) {
255
262
  handleUnauthorized();
256
263
  return;
@@ -274,6 +281,9 @@ var juxWeb = (function (exports) {
274
281
  // json conversion error / json response dealing errors
275
282
  onError(err);
276
283
  }
284
+ finally {
285
+ requestRunning = false;
286
+ }
277
287
  });
278
288
  const post = (endpoint, body, onSuccess, onError, onRedirect, requestType = "query") => {
279
289
  const options = {
package/dist/main.esm.js CHANGED
@@ -192,6 +192,7 @@ const defaultHandleUnauthorized = () => {
192
192
  };
193
193
  let requestRunning = false;
194
194
  const maxRetries = 20;
195
+ const timeout = 15000;
195
196
  const backendRequest = (url_1, options_1, onSuccess_1, onError_1, onRedirect_1, ...args_1) => __awaiter(void 0, [url_1, options_1, onSuccess_1, onError_1, onRedirect_1, ...args_1], void 0, function* (url, options, onSuccess, onError, onRedirect, requestType = 'query', handleUnauthorized = defaultHandleUnauthorized, retrial = false, retrialNum = 0) {
196
197
  if (requestRunning && !retrial) { // only allow one request at a time
197
198
  setTimeout(() => backendRequest(url, options, onSuccess, onError, onRedirect, requestType, handleUnauthorized, false), 300);
@@ -206,10 +207,12 @@ const backendRequest = (url_1, options_1, onSuccess_1, onError_1, onRedirect_1,
206
207
  }
207
208
  let response;
208
209
  requestRunning = true;
209
- const requestInit = Object.assign({}, options);
210
+ const controller = new AbortController();
211
+ let timeoutId;
210
212
  if (requestType === 'query') {
211
- requestInit.signal = AbortSignal.timeout(15000);
213
+ timeoutId = setTimeout(() => controller.abort(), timeout); // abort connections that take longer than the value set on the timeout const
212
214
  }
215
+ const requestInit = Object.assign(Object.assign({}, options), { signal: controller.signal });
213
216
  if (onRedirect)
214
217
  requestInit.redirect = 'manual'; // Treat redirects manually instead of following them automatically.
215
218
  try {
@@ -245,11 +248,15 @@ const backendRequest = (url_1, options_1, onSuccess_1, onError_1, onRedirect_1,
245
248
  return;
246
249
  }
247
250
  finally {
248
- requestRunning = false;
251
+ clearTimeout(timeoutId);
249
252
  }
250
253
  removeOverlay();
251
254
  if (onRedirect)
252
255
  onRedirect(response);
256
+ if (response.type === 'opaqueredirect') {
257
+ console.info('opaqueredirect'); // Stop processing request if its an opaqueredirect
258
+ return;
259
+ }
253
260
  if (response.status === 401) {
254
261
  handleUnauthorized();
255
262
  return;
@@ -273,6 +280,9 @@ const backendRequest = (url_1, options_1, onSuccess_1, onError_1, onRedirect_1,
273
280
  // json conversion error / json response dealing errors
274
281
  onError(err);
275
282
  }
283
+ finally {
284
+ requestRunning = false;
285
+ }
276
286
  });
277
287
  const post = (endpoint, body, onSuccess, onError, onRedirect, requestType = "query") => {
278
288
  const options = {
package/dist/main.js CHANGED
@@ -216,6 +216,7 @@ const defaultHandleUnauthorized = () => {
216
216
  };
217
217
  let requestRunning = false;
218
218
  const maxRetries = 20;
219
+ const timeout = 15000;
219
220
  const backendRequest = (url_1, options_1, onSuccess_1, onError_1, onRedirect_1, ...args_1) => __awaiter(void 0, [url_1, options_1, onSuccess_1, onError_1, onRedirect_1, ...args_1], void 0, function* (url, options, onSuccess, onError, onRedirect, requestType = 'query', handleUnauthorized = defaultHandleUnauthorized, retrial = false, retrialNum = 0) {
220
221
  if (requestRunning && !retrial) { // only allow one request at a time
221
222
  setTimeout(() => backendRequest(url, options, onSuccess, onError, onRedirect, requestType, handleUnauthorized, false), 300);
@@ -230,10 +231,12 @@ const backendRequest = (url_1, options_1, onSuccess_1, onError_1, onRedirect_1,
230
231
  }
231
232
  let response;
232
233
  requestRunning = true;
233
- const requestInit = Object.assign({}, options);
234
+ const controller = new AbortController();
235
+ let timeoutId;
234
236
  if (requestType === 'query') {
235
- requestInit.signal = AbortSignal.timeout(15000);
237
+ timeoutId = setTimeout(() => controller.abort(), timeout); // abort connections that take longer than the value set on the timeout const
236
238
  }
239
+ const requestInit = Object.assign(Object.assign({}, options), { signal: controller.signal });
237
240
  if (onRedirect)
238
241
  requestInit.redirect = 'manual'; // Treat redirects manually instead of following them automatically.
239
242
  try {
@@ -269,11 +272,15 @@ const backendRequest = (url_1, options_1, onSuccess_1, onError_1, onRedirect_1,
269
272
  return;
270
273
  }
271
274
  finally {
272
- requestRunning = false;
275
+ clearTimeout(timeoutId);
273
276
  }
274
277
  removeOverlay();
275
278
  if (onRedirect)
276
279
  onRedirect(response);
280
+ if (response.type === 'opaqueredirect') {
281
+ console.info('opaqueredirect'); // Stop processing request if its an opaqueredirect
282
+ return;
283
+ }
277
284
  if (response.status === 401) {
278
285
  handleUnauthorized();
279
286
  return;
@@ -297,6 +304,9 @@ const backendRequest = (url_1, options_1, onSuccess_1, onError_1, onRedirect_1,
297
304
  // json conversion error / json response dealing errors
298
305
  onError(err);
299
306
  }
307
+ finally {
308
+ requestRunning = false;
309
+ }
300
310
  });
301
311
  const post = (endpoint, body, onSuccess, onError, onRedirect, requestType = "query") => {
302
312
  const options = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@klauswuestefeld/jux-web",
3
- "version": "2024.4.1",
3
+ "version": "2024.4.24",
4
4
  "author": "Jux.House",
5
5
  "license": "Copyrighted",
6
6
  "description": "",