@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/browser/index.js +22 -38
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +27 -43
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -29,10 +29,7 @@ var __objRest = (source, exclude) => {
|
|
|
29
29
|
}
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
|
-
var __publicField = (obj, key, value) =>
|
|
33
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
34
|
-
return value;
|
|
35
|
-
};
|
|
32
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
36
33
|
var __async = (__this, __arguments, generator) => {
|
|
37
34
|
return new Promise((resolve, reject) => {
|
|
38
35
|
var fulfilled = (value) => {
|
|
@@ -1073,8 +1070,7 @@ var Dispatcher = class {
|
|
|
1073
1070
|
this.logger.debug({ title: "Deleting request", type: "system", extra: { queryKey, requestId, abortKey } });
|
|
1074
1071
|
const queue = this.getQueue(queryKey);
|
|
1075
1072
|
const queueItem = queue.requests.find((req) => req.requestId === requestId);
|
|
1076
|
-
if (!queueItem)
|
|
1077
|
-
return;
|
|
1073
|
+
if (!queueItem) return;
|
|
1078
1074
|
queue.requests = queue.requests.filter((req) => req.requestId !== requestId);
|
|
1079
1075
|
this.storage.set(queryKey, queue);
|
|
1080
1076
|
if (this.hasRunningRequest(queryKey, requestId)) {
|
|
@@ -1281,21 +1277,17 @@ var getRequestType = (request, latestRequest) => {
|
|
|
1281
1277
|
// src/request/request.utils.ts
|
|
1282
1278
|
var stringifyKey = (value) => {
|
|
1283
1279
|
try {
|
|
1284
|
-
if (typeof value === "string")
|
|
1285
|
-
|
|
1286
|
-
if (value === void 0 || value === null)
|
|
1287
|
-
return "";
|
|
1280
|
+
if (typeof value === "string") return value;
|
|
1281
|
+
if (value === void 0 || value === null) return "";
|
|
1288
1282
|
const data = JSON.stringify(value);
|
|
1289
|
-
if (typeof data !== "string")
|
|
1290
|
-
throw new Error();
|
|
1283
|
+
if (typeof data !== "string") throw new Error();
|
|
1291
1284
|
return data;
|
|
1292
1285
|
} catch (_) {
|
|
1293
1286
|
return "";
|
|
1294
1287
|
}
|
|
1295
1288
|
};
|
|
1296
1289
|
var getProgressValue = ({ loaded, total }) => {
|
|
1297
|
-
if (!loaded || !total)
|
|
1298
|
-
return 0;
|
|
1290
|
+
if (!loaded || !total) return 0;
|
|
1299
1291
|
return Number((loaded * 100 / total).toFixed(0));
|
|
1300
1292
|
};
|
|
1301
1293
|
var getRequestEta = (startDate, progressDate, { total, loaded }) => {
|
|
@@ -1394,16 +1386,14 @@ var sendRequest = (request, options) => {
|
|
|
1394
1386
|
const willRetry = canRetryRequest(details.retries, request.retry);
|
|
1395
1387
|
const handleResponse2 = (success, data) => {
|
|
1396
1388
|
var _a3;
|
|
1397
|
-
if (!success && isOfflineStatus)
|
|
1398
|
-
|
|
1399
|
-
if (!success && willRetry)
|
|
1400
|
-
return;
|
|
1389
|
+
if (!success && isOfflineStatus) return;
|
|
1390
|
+
if (!success && willRetry) return;
|
|
1401
1391
|
(_a3 = options == null ? void 0 : options.onResponse) == null ? void 0 : _a3.call(options, values);
|
|
1402
1392
|
resolve(data);
|
|
1403
1393
|
umountAll();
|
|
1404
1394
|
};
|
|
1405
1395
|
if (mapping instanceof Promise) {
|
|
1406
|
-
(() => __async(
|
|
1396
|
+
(() => __async(null, null, function* () {
|
|
1407
1397
|
const responseData = yield mapping;
|
|
1408
1398
|
const { success } = responseData;
|
|
1409
1399
|
handleResponse2(success, responseData);
|
|
@@ -1442,7 +1432,7 @@ var sendRequest = (request, options) => {
|
|
|
1442
1432
|
};
|
|
1443
1433
|
|
|
1444
1434
|
// src/adapter/adapter.bindings.ts
|
|
1445
|
-
var getAdapterBindings = (_0) => __async(
|
|
1435
|
+
var getAdapterBindings = (_0) => __async(null, [_0], function* ({
|
|
1446
1436
|
request: baseRequest,
|
|
1447
1437
|
requestId,
|
|
1448
1438
|
resolve,
|
|
@@ -1491,8 +1481,7 @@ var getAdapterBindings = (_0) => __async(void 0, [_0], function* ({
|
|
|
1491
1481
|
return responseStartTimestamp;
|
|
1492
1482
|
};
|
|
1493
1483
|
const getTotal = (previousTotal, progress) => {
|
|
1494
|
-
if (!progress)
|
|
1495
|
-
return previousTotal;
|
|
1484
|
+
if (!progress) return previousTotal;
|
|
1496
1485
|
const total = Number(progress.total || 0);
|
|
1497
1486
|
const loaded = Number(progress.loaded || 0);
|
|
1498
1487
|
return Math.max(total, loaded, previousTotal);
|
|
@@ -1601,7 +1590,7 @@ var getAdapterBindings = (_0) => __async(void 0, [_0], function* ({
|
|
|
1601
1590
|
});
|
|
1602
1591
|
return progressTimestamp;
|
|
1603
1592
|
};
|
|
1604
|
-
const onSuccess = (_02) => __async(
|
|
1593
|
+
const onSuccess = (_02) => __async(null, [_02], function* ({
|
|
1605
1594
|
data,
|
|
1606
1595
|
error,
|
|
1607
1596
|
status,
|
|
@@ -1759,7 +1748,7 @@ function getAdapterOnError({
|
|
|
1759
1748
|
logger: logger2
|
|
1760
1749
|
}) {
|
|
1761
1750
|
const { client } = request;
|
|
1762
|
-
return (_0) => __async(
|
|
1751
|
+
return (_0) => __async(null, [_0], function* ({
|
|
1763
1752
|
error,
|
|
1764
1753
|
status,
|
|
1765
1754
|
extra
|
|
@@ -1792,7 +1781,7 @@ function getAdapterOnError({
|
|
|
1792
1781
|
}
|
|
1793
1782
|
|
|
1794
1783
|
// src/mocker/mocker.ts
|
|
1795
|
-
var mocker = (_0) => __async(
|
|
1784
|
+
var mocker = (_0) => __async(null, [_0], function* ({
|
|
1796
1785
|
request,
|
|
1797
1786
|
requestId,
|
|
1798
1787
|
onError,
|
|
@@ -2469,15 +2458,13 @@ var stringifyValue = (response) => {
|
|
|
2469
2458
|
var getAdapterHeaders = (request) => {
|
|
2470
2459
|
const isFormData = hasWindow() && request.payload instanceof FormData;
|
|
2471
2460
|
const headers = {};
|
|
2472
|
-
if (!isFormData)
|
|
2473
|
-
headers["Content-Type"] = "application/json";
|
|
2461
|
+
if (!isFormData) headers["Content-Type"] = "application/json";
|
|
2474
2462
|
Object.assign(headers, request.headers);
|
|
2475
2463
|
return headers;
|
|
2476
2464
|
};
|
|
2477
2465
|
var getAdapterPayload = (data) => {
|
|
2478
2466
|
const isFormData = hasWindow() && data instanceof FormData;
|
|
2479
|
-
if (isFormData)
|
|
2480
|
-
return data;
|
|
2467
|
+
if (isFormData) return data;
|
|
2481
2468
|
return stringifyValue(data);
|
|
2482
2469
|
};
|
|
2483
2470
|
|
|
@@ -2842,7 +2829,7 @@ var getAdapter = () => new Adapter({
|
|
|
2842
2829
|
systemErrorStatus: 0,
|
|
2843
2830
|
systemErrorExtra: xhrExtra
|
|
2844
2831
|
}).setQueryParamsMapper(stringifyQueryParams).setFetcher(
|
|
2845
|
-
(_0) => __async(
|
|
2832
|
+
(_0) => __async(null, [_0], function* ({
|
|
2846
2833
|
request,
|
|
2847
2834
|
adapterOptions,
|
|
2848
2835
|
headers,
|
|
@@ -3256,24 +3243,22 @@ var getCacheEvents = (emitter) => ({
|
|
|
3256
3243
|
});
|
|
3257
3244
|
|
|
3258
3245
|
// src/client/client.utils.ts
|
|
3259
|
-
var interceptRequest = (interceptors, request) => __async(
|
|
3246
|
+
var interceptRequest = (interceptors, request) => __async(null, null, function* () {
|
|
3260
3247
|
let newRequest = request;
|
|
3261
3248
|
if (!request.requestOptions.disableRequestInterceptors) {
|
|
3262
3249
|
for (const interceptor of interceptors) {
|
|
3263
3250
|
newRequest = yield interceptor(request);
|
|
3264
|
-
if (!newRequest)
|
|
3265
|
-
throw new Error("Request modifier must return request");
|
|
3251
|
+
if (!newRequest) throw new Error("Request modifier must return request");
|
|
3266
3252
|
}
|
|
3267
3253
|
}
|
|
3268
3254
|
return newRequest;
|
|
3269
3255
|
});
|
|
3270
|
-
var interceptResponse = (interceptors, response, request) => __async(
|
|
3256
|
+
var interceptResponse = (interceptors, response, request) => __async(null, null, function* () {
|
|
3271
3257
|
let newResponse = response;
|
|
3272
3258
|
if (!request.requestOptions.disableResponseInterceptors) {
|
|
3273
3259
|
for (const interceptor of interceptors) {
|
|
3274
3260
|
newResponse = yield interceptor(response, request);
|
|
3275
|
-
if (!newResponse)
|
|
3276
|
-
throw new Error("Response modifier must return data");
|
|
3261
|
+
if (!newResponse) throw new Error("Response modifier must return data");
|
|
3277
3262
|
}
|
|
3278
3263
|
}
|
|
3279
3264
|
return newResponse;
|
|
@@ -3539,8 +3524,7 @@ var Client = class {
|
|
|
3539
3524
|
*/
|
|
3540
3525
|
__publicField(this, "hydrate", (hydrationData, options) => {
|
|
3541
3526
|
hydrationData == null ? void 0 : hydrationData.forEach((item) => {
|
|
3542
|
-
if (!item)
|
|
3543
|
-
return;
|
|
3527
|
+
if (!item) return;
|
|
3544
3528
|
const _a = item, { cacheKey, response } = _a, fallbackOptions = __objRest(_a, ["cacheKey", "response"]);
|
|
3545
3529
|
const defaults = {
|
|
3546
3530
|
cache: true,
|