ropegeo-common 1.12.8 → 1.12.10
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/components/RopeGeoCursorPaginationHttpRequest.d.ts +7 -1
- package/dist/components/RopeGeoCursorPaginationHttpRequest.d.ts.map +1 -1
- package/dist/components/RopeGeoCursorPaginationHttpRequest.js +24 -3
- package/dist/components/RopeGeoHttpRequest.d.ts +8 -1
- package/dist/components/RopeGeoHttpRequest.d.ts.map +1 -1
- package/dist/components/RopeGeoHttpRequest.js +17 -2
- package/dist/components/RopeGeoPaginationHttpRequest.d.ts +8 -1
- package/dist/components/RopeGeoPaginationHttpRequest.d.ts.map +1 -1
- package/dist/components/RopeGeoPaginationHttpRequest.js +8 -1
- package/dist/helpers/network/index.d.ts +1 -1
- package/dist/helpers/network/index.d.ts.map +1 -1
- package/dist/helpers/network/index.js +2 -1
- package/dist/helpers/network/networkRequestPolicy.d.ts +2 -0
- package/dist/helpers/network/networkRequestPolicy.d.ts.map +1 -1
- package/dist/helpers/network/networkRequestPolicy.js +7 -2
- package/package.json +1 -1
|
@@ -12,6 +12,12 @@ export type RopeGeoCursorPaginationHttpRequestProps<T = unknown> = {
|
|
|
12
12
|
* and countdown are disabled.
|
|
13
13
|
*/
|
|
14
14
|
timeoutAfterSeconds?: number;
|
|
15
|
+
/**
|
|
16
|
+
* When `false`, no HTTP requests run and children receive {@link NO_NETWORK_MESSAGE} as the error.
|
|
17
|
+
* Previously loaded `data` and cursor `params` are kept until the network returns (same stale
|
|
18
|
+
* behavior as {@link RopeGeoPaginationHttpRequest} / {@link RopeGeoHttpRequest} when offline).
|
|
19
|
+
*/
|
|
20
|
+
isOnline?: boolean;
|
|
15
21
|
/**
|
|
16
22
|
* Response body is parsed via CursorPaginationResults.fromResponseBody (must include resultType).
|
|
17
23
|
* Parsed shape is ValidatedCursorPaginationResponse; children receive result.results as data.
|
|
@@ -26,5 +32,5 @@ export type RopeGeoCursorPaginationHttpRequestProps<T = unknown> = {
|
|
|
26
32
|
timeoutCountdown: number | null;
|
|
27
33
|
}) => ReactNode;
|
|
28
34
|
};
|
|
29
|
-
export declare function RopeGeoCursorPaginationHttpRequest<T = unknown>({ service, method, path, pathParams, queryParams, timeoutAfterSeconds, children, }: RopeGeoCursorPaginationHttpRequestProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
export declare function RopeGeoCursorPaginationHttpRequest<T = unknown>({ service, method, path, pathParams, queryParams, timeoutAfterSeconds, isOnline, children, }: RopeGeoCursorPaginationHttpRequestProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
30
36
|
//# sourceMappingURL=RopeGeoCursorPaginationHttpRequest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RopeGeoCursorPaginationHttpRequest.d.ts","sourceRoot":"","sources":["../../src/components/RopeGeoCursorPaginationHttpRequest.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"RopeGeoCursorPaginationHttpRequest.d.ts","sourceRoot":"","sources":["../../src/components/RopeGeoCursorPaginationHttpRequest.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASvC,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAoB,MAAM,sBAAsB,CAAC;AAsCzE,MAAM,MAAM,uCAAuC,CAAC,CAAC,GAAG,OAAO,IAAI;IACjE,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,WAAW,EAAE,sBAAsB,CAAC;IACpC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE;QACf,OAAO,EAAE,OAAO,CAAC;QACjB,WAAW,EAAE,OAAO,CAAC;QACrB,IAAI,EAAE,CAAC,EAAE,CAAC;QACV,MAAM,EAAE,KAAK,GAAG,IAAI,CAAC;QACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;QACrB,OAAO,EAAE,OAAO,CAAC;QACjB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;KACjC,KAAK,SAAS,CAAC;CACjB,CAAC;AAEF,wBAAgB,kCAAkC,CAAC,CAAC,GAAG,OAAO,EAAE,EAC9D,OAAO,EACP,MAAmB,EACnB,IAAI,EACJ,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,QAAQ,EACR,QAAQ,GACT,EAAE,uCAAuC,CAAC,CAAC,CAAC,2CAsQ5C"}
|
|
@@ -30,7 +30,7 @@ function getResponseBody(raw) {
|
|
|
30
30
|
}
|
|
31
31
|
return raw;
|
|
32
32
|
}
|
|
33
|
-
function RopeGeoCursorPaginationHttpRequest({ service, method = RopeGeoHttpRequest_1.Method.GET, path, pathParams, queryParams, timeoutAfterSeconds, children, }) {
|
|
33
|
+
function RopeGeoCursorPaginationHttpRequest({ service, method = RopeGeoHttpRequest_1.Method.GET, path, pathParams, queryParams, timeoutAfterSeconds, isOnline, children, }) {
|
|
34
34
|
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
35
35
|
const [loadingMore, setLoadingMore] = (0, react_1.useState)(false);
|
|
36
36
|
const [data, setData] = (0, react_1.useState)([]);
|
|
@@ -48,6 +48,16 @@ function RopeGeoCursorPaginationHttpRequest({ service, method = RopeGeoHttpReque
|
|
|
48
48
|
return new URL(fullPath, baseUrl).toString();
|
|
49
49
|
}, [service, path, pathParams]);
|
|
50
50
|
(0, react_1.useEffect)(() => {
|
|
51
|
+
if (isOnline === false) {
|
|
52
|
+
loadMoreAbortRef.current?.abort();
|
|
53
|
+
loadMoreAbortRef.current = null;
|
|
54
|
+
loadingMoreRef.current = false;
|
|
55
|
+
setLoadingMore(false);
|
|
56
|
+
setLoading(false);
|
|
57
|
+
setErrors(new Error(network_1.NO_NETWORK_MESSAGE));
|
|
58
|
+
setTimeoutCountdown(null);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
51
61
|
let cancelled = false;
|
|
52
62
|
const abortController = new AbortController();
|
|
53
63
|
const timedOutRef = { current: false };
|
|
@@ -148,13 +158,24 @@ function RopeGeoCursorPaginationHttpRequest({ service, method = RopeGeoHttpReque
|
|
|
148
158
|
policyDispose();
|
|
149
159
|
abortController.abort();
|
|
150
160
|
};
|
|
151
|
-
}, [
|
|
161
|
+
}, [
|
|
162
|
+
service,
|
|
163
|
+
method,
|
|
164
|
+
path,
|
|
165
|
+
pathParams,
|
|
166
|
+
queryParams,
|
|
167
|
+
buildUrl,
|
|
168
|
+
timeoutAfterSeconds,
|
|
169
|
+
isOnline,
|
|
170
|
+
]);
|
|
152
171
|
(0, react_1.useEffect)(() => {
|
|
153
172
|
return () => {
|
|
154
173
|
loadMoreAbortRef.current?.abort();
|
|
155
174
|
};
|
|
156
175
|
}, []);
|
|
157
176
|
const loadMore = (0, react_1.useCallback)(() => {
|
|
177
|
+
if (isOnline === false)
|
|
178
|
+
return;
|
|
158
179
|
if (params.cursor == null)
|
|
159
180
|
return;
|
|
160
181
|
if (loadingMoreRef.current)
|
|
@@ -238,7 +259,7 @@ function RopeGeoCursorPaginationHttpRequest({ service, method = RopeGeoHttpReque
|
|
|
238
259
|
loadingMoreRef.current = false;
|
|
239
260
|
setLoadingMore(false);
|
|
240
261
|
});
|
|
241
|
-
}, [params, method, buildUrl, timeoutAfterSeconds]);
|
|
262
|
+
}, [params, method, buildUrl, timeoutAfterSeconds, isOnline]);
|
|
242
263
|
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({
|
|
243
264
|
loading,
|
|
244
265
|
loadingMore,
|
|
@@ -22,6 +22,13 @@ export type RopeGeoHttpRequestProps<T = unknown> = {
|
|
|
22
22
|
* Request deadline in seconds (abort + timeout error). When omitted, no timeout is enforced.
|
|
23
23
|
*/
|
|
24
24
|
timeoutAfterSeconds?: number;
|
|
25
|
+
/**
|
|
26
|
+
* When `false`, the request is not started and children receive {@link NO_NETWORK_MESSAGE} as the
|
|
27
|
+
* error. Previously loaded `data` is kept until the network returns. When `true` or omitted,
|
|
28
|
+
* behavior is unchanged. Pass from app-level connectivity (e.g. `expo-network`) so fetches are
|
|
29
|
+
* not fired while offline.
|
|
30
|
+
*/
|
|
31
|
+
isOnline?: boolean;
|
|
25
32
|
/**
|
|
26
33
|
* Response body is parsed via Result.fromResponseBody (must include resultType and result).
|
|
27
34
|
* Children receive the validated result.result as data (typed by T).
|
|
@@ -38,5 +45,5 @@ export type RopeGeoHttpRequestProps<T = unknown> = {
|
|
|
38
45
|
timeoutCountdown: number | null;
|
|
39
46
|
}) => ReactNode;
|
|
40
47
|
};
|
|
41
|
-
export declare function RopeGeoHttpRequest<T = unknown>({ service, method, path, pathParams, queryParams, body, timeoutAfterSeconds, children, }: RopeGeoHttpRequestProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
48
|
+
export declare function RopeGeoHttpRequest<T = unknown>({ service, method, path, pathParams, queryParams, body, timeoutAfterSeconds, isOnline, children, }: RopeGeoHttpRequestProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
42
49
|
//# sourceMappingURL=RopeGeoHttpRequest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RopeGeoHttpRequest.d.ts","sourceRoot":"","sources":["../../src/components/RopeGeoHttpRequest.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"RopeGeoHttpRequest.d.ts","s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M,EACN,IAAI,EACJ,UAAU,EACV,WAAW,EACX,IAAI,EACJ,mBAAmB,EACnB,QAAQ,EACR,QAAQ,GACT,EAAE,uBAAuB,CAAC,CAAC,CAAC,2CAwJ5B"}
|
|
@@ -40,7 +40,7 @@ function buildUrl(baseUrl, path, pathParams, queryParams) {
|
|
|
40
40
|
}
|
|
41
41
|
return url.toString();
|
|
42
42
|
}
|
|
43
|
-
function RopeGeoHttpRequest({ service, method, path, pathParams, queryParams, body, timeoutAfterSeconds, children, }) {
|
|
43
|
+
function RopeGeoHttpRequest({ service, method, path, pathParams, queryParams, body, timeoutAfterSeconds, isOnline, children, }) {
|
|
44
44
|
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
45
45
|
const [data, setData] = (0, react_1.useState)(null);
|
|
46
46
|
const [errors, setErrors] = (0, react_1.useState)(null);
|
|
@@ -53,6 +53,12 @@ function RopeGeoHttpRequest({ service, method, path, pathParams, queryParams, bo
|
|
|
53
53
|
? JSON.stringify(body)
|
|
54
54
|
: body;
|
|
55
55
|
(0, react_1.useEffect)(() => {
|
|
56
|
+
if (isOnline === false) {
|
|
57
|
+
setLoading(false);
|
|
58
|
+
setErrors(new Error(network_1.NO_NETWORK_MESSAGE));
|
|
59
|
+
setTimeoutCountdown(null);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
56
62
|
let cancelled = false;
|
|
57
63
|
const abortController = new AbortController();
|
|
58
64
|
const timedOutRef = { current: false };
|
|
@@ -154,7 +160,16 @@ function RopeGeoHttpRequest({ service, method, path, pathParams, queryParams, bo
|
|
|
154
160
|
policyDispose();
|
|
155
161
|
abortController.abort();
|
|
156
162
|
};
|
|
157
|
-
}, [
|
|
163
|
+
}, [
|
|
164
|
+
service,
|
|
165
|
+
method,
|
|
166
|
+
path,
|
|
167
|
+
pathParamsKey,
|
|
168
|
+
queryParamsKey,
|
|
169
|
+
bodyKey,
|
|
170
|
+
timeoutAfterSeconds,
|
|
171
|
+
isOnline,
|
|
172
|
+
]);
|
|
158
173
|
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({
|
|
159
174
|
loading,
|
|
160
175
|
data,
|
|
@@ -18,6 +18,13 @@ export type RopeGeoPaginationHttpRequestProps<T = unknown> = {
|
|
|
18
18
|
* When omitted, timeout and countdown are disabled.
|
|
19
19
|
*/
|
|
20
20
|
timeoutAfterSeconds?: number;
|
|
21
|
+
/**
|
|
22
|
+
* When `false`, no HTTP requests run and children receive {@link NO_NETWORK_MESSAGE} as the error.
|
|
23
|
+
* Previously loaded `data`, `received`, and `total` are kept so UIs can stay on stale results until
|
|
24
|
+
* the network returns. Same semantics as `isOnline` on {@link RopeGeoHttpRequest} and
|
|
25
|
+
* {@link RopeGeoCursorPaginationHttpRequest}.
|
|
26
|
+
*/
|
|
27
|
+
isOnline?: boolean;
|
|
21
28
|
children: (args: {
|
|
22
29
|
loading: boolean;
|
|
23
30
|
received: number;
|
|
@@ -39,5 +46,5 @@ export type RopeGeoPaginationHttpRequestProps<T = unknown> = {
|
|
|
39
46
|
* {@link PaginationResults.fromResponseBody}. Final `data` is pages concatenated in page order.
|
|
40
47
|
* In-flight requests use one {@link AbortController}: unmount or any failure aborts the rest.
|
|
41
48
|
*/
|
|
42
|
-
export declare function RopeGeoPaginationHttpRequest<T = unknown>({ service, method, path, pathParams, queryParams, batchSize, timeoutAfterSeconds, children, }: RopeGeoPaginationHttpRequestProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
export declare function RopeGeoPaginationHttpRequest<T = unknown>({ service, method, path, pathParams, queryParams, batchSize, timeoutAfterSeconds, isOnline, children, }: RopeGeoPaginationHttpRequestProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
43
50
|
//# sourceMappingURL=RopeGeoPaginationHttpRequest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RopeGeoPaginationHttpRequest.d.ts","sourceRoot":"","sources":["../../src/components/RopeGeoPaginationHttpRequest.tsx"],"names":[],"mappings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xD,OAAO,EACP,MAAmB,EACnB,IAAI,EACJ,UAAU,EACV,WAAW,EACX,SAAc,EACd,mBAAmB,EACnB,QAAQ,EACR,QAAQ,GACT,EAAE,iCAAiC,CAAC,CAAC,CAAC,2CAoPtC"}
|
|
@@ -57,7 +57,7 @@ function concatPaginationResultItemsSorted(pagesByNum) {
|
|
|
57
57
|
* {@link PaginationResults.fromResponseBody}. Final `data` is pages concatenated in page order.
|
|
58
58
|
* In-flight requests use one {@link AbortController}: unmount or any failure aborts the rest.
|
|
59
59
|
*/
|
|
60
|
-
function RopeGeoPaginationHttpRequest({ service, method = RopeGeoHttpRequest_1.Method.GET, path, pathParams, queryParams, batchSize = 10, timeoutAfterSeconds, children, }) {
|
|
60
|
+
function RopeGeoPaginationHttpRequest({ service, method = RopeGeoHttpRequest_1.Method.GET, path, pathParams, queryParams, batchSize = 10, timeoutAfterSeconds, isOnline, children, }) {
|
|
61
61
|
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
62
62
|
const [received, setReceived] = (0, react_1.useState)(0);
|
|
63
63
|
const [total, setTotal] = (0, react_1.useState)(null);
|
|
@@ -68,6 +68,12 @@ function RopeGeoPaginationHttpRequest({ service, method = RopeGeoHttpRequest_1.M
|
|
|
68
68
|
const queryParamsKey = queryParams.toQueryString();
|
|
69
69
|
const effectiveBatch = Math.max(1, Math.floor(batchSize));
|
|
70
70
|
(0, react_1.useEffect)(() => {
|
|
71
|
+
if (isOnline === false) {
|
|
72
|
+
setLoading(false);
|
|
73
|
+
setErrors(new Error(network_1.NO_NETWORK_MESSAGE));
|
|
74
|
+
setTimeoutCountdown(null);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
71
77
|
let cancelled = false;
|
|
72
78
|
const abortController = new AbortController();
|
|
73
79
|
const { signal } = abortController;
|
|
@@ -269,6 +275,7 @@ function RopeGeoPaginationHttpRequest({ service, method = RopeGeoHttpRequest_1.M
|
|
|
269
275
|
queryParams,
|
|
270
276
|
effectiveBatch,
|
|
271
277
|
timeoutAfterSeconds,
|
|
278
|
+
isOnline,
|
|
272
279
|
]);
|
|
273
280
|
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({
|
|
274
281
|
loading,
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Published as `ropegeo-common/helpers/network`. Prefer this entry over `ropegeo-common/helpers` in
|
|
4
4
|
* Metro/RN bundles so the full helpers barrel (S3 folder upload, etc.) is not resolved.
|
|
5
5
|
*/
|
|
6
|
-
export { NETWORK_REQUEST_TIMED_OUT_MESSAGE, installNetworkRequestPolicyTimers, isAbortError, isNetworkRequestTimeoutError, mergeParentSignalWithDeadline, resolveRequestTimeoutMs, type MergedDeadlineHandles, type NetworkRequestPolicyTimerCallbacks, } from "./networkRequestPolicy";
|
|
6
|
+
export { NETWORK_REQUEST_TIMED_OUT_MESSAGE, NO_NETWORK_MESSAGE, installNetworkRequestPolicyTimers, isAbortError, isNetworkRequestTimeoutError, mergeParentSignalWithDeadline, resolveRequestTimeoutMs, type MergedDeadlineHandles, type NetworkRequestPolicyTimerCallbacks, } from "./networkRequestPolicy";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/network/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,iCAAiC,EACjC,iCAAiC,EACjC,YAAY,EACZ,4BAA4B,EAC5B,6BAA6B,EAC7B,uBAAuB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,kCAAkC,GACxC,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/network/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,iCAAiC,EACjC,kBAAkB,EAClB,iCAAiC,EACjC,YAAY,EACZ,4BAA4B,EAC5B,6BAA6B,EAC7B,uBAAuB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,kCAAkC,GACxC,MAAM,wBAAwB,CAAC"}
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
* Metro/RN bundles so the full helpers barrel (S3 folder upload, etc.) is not resolved.
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.resolveRequestTimeoutMs = exports.mergeParentSignalWithDeadline = exports.isNetworkRequestTimeoutError = exports.isAbortError = exports.installNetworkRequestPolicyTimers = exports.NETWORK_REQUEST_TIMED_OUT_MESSAGE = void 0;
|
|
8
|
+
exports.resolveRequestTimeoutMs = exports.mergeParentSignalWithDeadline = exports.isNetworkRequestTimeoutError = exports.isAbortError = exports.installNetworkRequestPolicyTimers = exports.NO_NETWORK_MESSAGE = exports.NETWORK_REQUEST_TIMED_OUT_MESSAGE = void 0;
|
|
9
9
|
var networkRequestPolicy_1 = require("./networkRequestPolicy");
|
|
10
10
|
Object.defineProperty(exports, "NETWORK_REQUEST_TIMED_OUT_MESSAGE", { enumerable: true, get: function () { return networkRequestPolicy_1.NETWORK_REQUEST_TIMED_OUT_MESSAGE; } });
|
|
11
|
+
Object.defineProperty(exports, "NO_NETWORK_MESSAGE", { enumerable: true, get: function () { return networkRequestPolicy_1.NO_NETWORK_MESSAGE; } });
|
|
11
12
|
Object.defineProperty(exports, "installNetworkRequestPolicyTimers", { enumerable: true, get: function () { return networkRequestPolicy_1.installNetworkRequestPolicyTimers; } });
|
|
12
13
|
Object.defineProperty(exports, "isAbortError", { enumerable: true, get: function () { return networkRequestPolicy_1.isAbortError; } });
|
|
13
14
|
Object.defineProperty(exports, "isNetworkRequestTimeoutError", { enumerable: true, get: function () { return networkRequestPolicy_1.isNetworkRequestTimeoutError; } });
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/** Network helpers for optional request deadlines and timeout countdowns. */
|
|
2
2
|
/** Use this exact message so callers can detect timeout vs other failures. */
|
|
3
3
|
export declare const NETWORK_REQUEST_TIMED_OUT_MESSAGE = "Network request timed out";
|
|
4
|
+
/** Use this exact message for client-side offline gating and RN fetch failures treated as offline. */
|
|
5
|
+
export declare const NO_NETWORK_MESSAGE = "No network connection";
|
|
4
6
|
export declare function isNetworkRequestTimeoutError(e: unknown): boolean;
|
|
5
7
|
export declare function isAbortError(e: unknown): boolean;
|
|
6
8
|
/** Milliseconds for `timeoutAfterSeconds` on request components; `null` when timeout is disabled. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"networkRequestPolicy.d.ts","sourceRoot":"","sources":["../../../src/helpers/network/networkRequestPolicy.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAE7E,8EAA8E;AAC9E,eAAO,MAAM,iCAAiC,8BAA8B,CAAC;AAE7E,wBAAgB,4BAA4B,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAEhE;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"networkRequestPolicy.d.ts","sourceRoot":"","sources":["../../../src/helpers/network/networkRequestPolicy.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAE7E,8EAA8E;AAC9E,eAAO,MAAM,iCAAiC,8BAA8B,CAAC;AAE7E,sGAAsG;AACtG,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D,wBAAgB,4BAA4B,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAEhE;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAUhD;AAED,qGAAqG;AACrG,wBAAgB,uBAAuB,CAAC,mBAAmB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CASnF;AAED,MAAM,MAAM,kCAAkC,GAAG;IAC/C,QAAQ,EAAE,MAAM,OAAO,CAAC;IACxB,kBAAkB,EAAE,CAAC,gBAAgB,EAAE,MAAM,KAAK,IAAI,CAAC;IACvD,uBAAuB,EAAE,MAAM,IAAI,CAAC;IACpC,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,iCAAiC,CAC/C,kBAAkB,EAAE,MAAM,EAC1B,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,kCAAkC,GAC5C,MAAM,IAAI,CAuCZ;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,iBAAiB,EAAE,MAAM,OAAO,CAAC;CAClC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,YAAY,EAAE,WAAW,EACzB,UAAU,EAAE,MAAM,GACjB,qBAAqB,CAqCvB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/** Network helpers for optional request deadlines and timeout countdowns. */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.NETWORK_REQUEST_TIMED_OUT_MESSAGE = void 0;
|
|
4
|
+
exports.NO_NETWORK_MESSAGE = exports.NETWORK_REQUEST_TIMED_OUT_MESSAGE = void 0;
|
|
5
5
|
exports.isNetworkRequestTimeoutError = isNetworkRequestTimeoutError;
|
|
6
6
|
exports.isAbortError = isAbortError;
|
|
7
7
|
exports.resolveRequestTimeoutMs = resolveRequestTimeoutMs;
|
|
@@ -9,12 +9,17 @@ exports.installNetworkRequestPolicyTimers = installNetworkRequestPolicyTimers;
|
|
|
9
9
|
exports.mergeParentSignalWithDeadline = mergeParentSignalWithDeadline;
|
|
10
10
|
/** Use this exact message so callers can detect timeout vs other failures. */
|
|
11
11
|
exports.NETWORK_REQUEST_TIMED_OUT_MESSAGE = "Network request timed out";
|
|
12
|
+
/** Use this exact message for client-side offline gating and RN fetch failures treated as offline. */
|
|
13
|
+
exports.NO_NETWORK_MESSAGE = "No network connection";
|
|
12
14
|
function isNetworkRequestTimeoutError(e) {
|
|
13
15
|
return e instanceof Error && e.message === exports.NETWORK_REQUEST_TIMED_OUT_MESSAGE;
|
|
14
16
|
}
|
|
15
17
|
function isAbortError(e) {
|
|
16
|
-
if (
|
|
18
|
+
if (typeof DOMException !== "undefined" &&
|
|
19
|
+
e instanceof DOMException &&
|
|
20
|
+
e.name === "AbortError") {
|
|
17
21
|
return true;
|
|
22
|
+
}
|
|
18
23
|
if (e instanceof Error && e.name === "AbortError")
|
|
19
24
|
return true;
|
|
20
25
|
return false;
|