@hyper-fetch/core 7.2.5 → 7.2.6

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.js CHANGED
@@ -55,10 +55,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
55
55
  mod
56
56
  ));
57
57
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
- var __publicField = (obj, key, value) => {
59
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
60
- return value;
61
- };
58
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
62
59
  var __async = (__this, __arguments, generator) => {
63
60
  return new Promise((resolve, reject) => {
64
61
  var fulfilled = (value) => {
@@ -81,8 +78,8 @@ var __async = (__this, __arguments, generator) => {
81
78
  };
82
79
 
83
80
  // src/index.ts
84
- var src_exports = {};
85
- __export(src_exports, {
81
+ var index_exports = {};
82
+ __export(index_exports, {
86
83
  AbortError: () => AbortError,
87
84
  Adapter: () => Adapter,
88
85
  AppEvents: () => AppEvents,
@@ -192,7 +189,7 @@ __export(src_exports, {
192
189
  stringifyValue: () => stringifyValue,
193
190
  xhrExtra: () => xhrExtra
194
191
  });
195
- module.exports = __toCommonJS(src_exports);
192
+ module.exports = __toCommonJS(index_exports);
196
193
 
197
194
  // src/plugin/plugin.ts
198
195
  var Plugin = class {
@@ -1213,8 +1210,7 @@ var Dispatcher = class {
1213
1210
  this.logger.debug({ title: "Deleting request", type: "system", extra: { queryKey, requestId, abortKey } });
1214
1211
  const queue = this.getQueue(queryKey);
1215
1212
  const queueItem = queue.requests.find((req) => req.requestId === requestId);
1216
- if (!queueItem)
1217
- return;
1213
+ if (!queueItem) return;
1218
1214
  queue.requests = queue.requests.filter((req) => req.requestId !== requestId);
1219
1215
  this.storage.set(queryKey, queue);
1220
1216
  if (this.hasRunningRequest(queryKey, requestId)) {
@@ -1421,21 +1417,17 @@ var getRequestType = (request, latestRequest) => {
1421
1417
  // src/request/request.utils.ts
1422
1418
  var stringifyKey = (value) => {
1423
1419
  try {
1424
- if (typeof value === "string")
1425
- return value;
1426
- if (value === void 0 || value === null)
1427
- return "";
1420
+ if (typeof value === "string") return value;
1421
+ if (value === void 0 || value === null) return "";
1428
1422
  const data = JSON.stringify(value);
1429
- if (typeof data !== "string")
1430
- throw new Error();
1423
+ if (typeof data !== "string") throw new Error();
1431
1424
  return data;
1432
1425
  } catch (_) {
1433
1426
  return "";
1434
1427
  }
1435
1428
  };
1436
1429
  var getProgressValue = ({ loaded, total }) => {
1437
- if (!loaded || !total)
1438
- return 0;
1430
+ if (!loaded || !total) return 0;
1439
1431
  return Number((loaded * 100 / total).toFixed(0));
1440
1432
  };
1441
1433
  var getRequestEta = (startDate, progressDate, { total, loaded }) => {
@@ -1534,16 +1526,14 @@ var sendRequest = (request, options) => {
1534
1526
  const willRetry = canRetryRequest(details.retries, request.retry);
1535
1527
  const handleResponse2 = (success, data) => {
1536
1528
  var _a3;
1537
- if (!success && isOfflineStatus)
1538
- return;
1539
- if (!success && willRetry)
1540
- return;
1529
+ if (!success && isOfflineStatus) return;
1530
+ if (!success && willRetry) return;
1541
1531
  (_a3 = options == null ? void 0 : options.onResponse) == null ? void 0 : _a3.call(options, values);
1542
1532
  resolve(data);
1543
1533
  umountAll();
1544
1534
  };
1545
1535
  if (mapping instanceof Promise) {
1546
- (() => __async(void 0, null, function* () {
1536
+ (() => __async(null, null, function* () {
1547
1537
  const responseData = yield mapping;
1548
1538
  const { success } = responseData;
1549
1539
  handleResponse2(success, responseData);
@@ -1582,7 +1572,7 @@ var sendRequest = (request, options) => {
1582
1572
  };
1583
1573
 
1584
1574
  // src/adapter/adapter.bindings.ts
1585
- var getAdapterBindings = (_0) => __async(void 0, [_0], function* ({
1575
+ var getAdapterBindings = (_0) => __async(null, [_0], function* ({
1586
1576
  request: baseRequest,
1587
1577
  requestId,
1588
1578
  resolve,
@@ -1631,8 +1621,7 @@ var getAdapterBindings = (_0) => __async(void 0, [_0], function* ({
1631
1621
  return responseStartTimestamp;
1632
1622
  };
1633
1623
  const getTotal = (previousTotal, progress) => {
1634
- if (!progress)
1635
- return previousTotal;
1624
+ if (!progress) return previousTotal;
1636
1625
  const total = Number(progress.total || 0);
1637
1626
  const loaded = Number(progress.loaded || 0);
1638
1627
  return Math.max(total, loaded, previousTotal);
@@ -1741,7 +1730,7 @@ var getAdapterBindings = (_0) => __async(void 0, [_0], function* ({
1741
1730
  });
1742
1731
  return progressTimestamp;
1743
1732
  };
1744
- const onSuccess = (_02) => __async(void 0, [_02], function* ({
1733
+ const onSuccess = (_02) => __async(null, [_02], function* ({
1745
1734
  data,
1746
1735
  error,
1747
1736
  status,
@@ -1899,7 +1888,7 @@ function getAdapterOnError({
1899
1888
  logger: logger2
1900
1889
  }) {
1901
1890
  const { client } = request;
1902
- return (_0) => __async(this, [_0], function* ({
1891
+ return (_0) => __async(null, [_0], function* ({
1903
1892
  error,
1904
1893
  status,
1905
1894
  extra
@@ -1932,7 +1921,7 @@ function getAdapterOnError({
1932
1921
  }
1933
1922
 
1934
1923
  // src/mocker/mocker.ts
1935
- var mocker = (_0) => __async(void 0, [_0], function* ({
1924
+ var mocker = (_0) => __async(null, [_0], function* ({
1936
1925
  request,
1937
1926
  requestId,
1938
1927
  onError,
@@ -2609,15 +2598,13 @@ var stringifyValue = (response) => {
2609
2598
  var getAdapterHeaders = (request) => {
2610
2599
  const isFormData = hasWindow() && request.payload instanceof FormData;
2611
2600
  const headers = {};
2612
- if (!isFormData)
2613
- headers["Content-Type"] = "application/json";
2601
+ if (!isFormData) headers["Content-Type"] = "application/json";
2614
2602
  Object.assign(headers, request.headers);
2615
2603
  return headers;
2616
2604
  };
2617
2605
  var getAdapterPayload = (data) => {
2618
2606
  const isFormData = hasWindow() && data instanceof FormData;
2619
- if (isFormData)
2620
- return data;
2607
+ if (isFormData) return data;
2621
2608
  return stringifyValue(data);
2622
2609
  };
2623
2610
 
@@ -2982,7 +2969,7 @@ var getAdapter = () => new Adapter({
2982
2969
  systemErrorStatus: 0,
2983
2970
  systemErrorExtra: xhrExtra
2984
2971
  }).setQueryParamsMapper(stringifyQueryParams).setFetcher(
2985
- (_0) => __async(void 0, [_0], function* ({
2972
+ (_0) => __async(null, [_0], function* ({
2986
2973
  request,
2987
2974
  adapterOptions,
2988
2975
  headers,
@@ -3055,7 +3042,7 @@ var getAdapter2 = () => new Adapter({
3055
3042
  systemErrorStatus: 0,
3056
3043
  systemErrorExtra: xhrExtra
3057
3044
  }).setQueryParamsMapper(stringifyQueryParams).setFetcher(
3058
- (_0) => __async(void 0, [_0], function* ({
3045
+ (_0) => __async(null, [_0], function* ({
3059
3046
  request,
3060
3047
  adapterOptions,
3061
3048
  adapter,
@@ -3112,7 +3099,7 @@ var getAdapter2 = () => new Adapter({
3112
3099
  chunks += chunk;
3113
3100
  onResponseProgress({ total: totalDownloadBytes, loaded: downloadedBytes });
3114
3101
  });
3115
- response.on("end", () => __async(void 0, null, function* () {
3102
+ response.on("end", () => __async(null, null, function* () {
3116
3103
  const { statusCode = adapter.systemErrorStatus } = response;
3117
3104
  const success = String(statusCode).startsWith("2") || String(statusCode).startsWith("3");
3118
3105
  if (success) {
@@ -3494,24 +3481,22 @@ var getCacheEvents = (emitter) => ({
3494
3481
  });
3495
3482
 
3496
3483
  // src/client/client.utils.ts
3497
- var interceptRequest = (interceptors, request) => __async(void 0, null, function* () {
3484
+ var interceptRequest = (interceptors, request) => __async(null, null, function* () {
3498
3485
  let newRequest = request;
3499
3486
  if (!request.requestOptions.disableRequestInterceptors) {
3500
3487
  for (const interceptor of interceptors) {
3501
3488
  newRequest = yield interceptor(request);
3502
- if (!newRequest)
3503
- throw new Error("Request modifier must return request");
3489
+ if (!newRequest) throw new Error("Request modifier must return request");
3504
3490
  }
3505
3491
  }
3506
3492
  return newRequest;
3507
3493
  });
3508
- var interceptResponse = (interceptors, response, request) => __async(void 0, null, function* () {
3494
+ var interceptResponse = (interceptors, response, request) => __async(null, null, function* () {
3509
3495
  let newResponse = response;
3510
3496
  if (!request.requestOptions.disableResponseInterceptors) {
3511
3497
  for (const interceptor of interceptors) {
3512
3498
  newResponse = yield interceptor(response, request);
3513
- if (!newResponse)
3514
- throw new Error("Response modifier must return data");
3499
+ if (!newResponse) throw new Error("Response modifier must return data");
3515
3500
  }
3516
3501
  }
3517
3502
  return newResponse;
@@ -3777,8 +3762,7 @@ var Client = class {
3777
3762
  */
3778
3763
  __publicField(this, "hydrate", (hydrationData, options) => {
3779
3764
  hydrationData == null ? void 0 : hydrationData.forEach((item) => {
3780
- if (!item)
3781
- return;
3765
+ if (!item) return;
3782
3766
  const _a = item, { cacheKey, response } = _a, fallbackOptions = __objRest(_a, ["cacheKey", "response"]);
3783
3767
  const defaults = {
3784
3768
  cache: true,