@tanstack/react-query 4.14.6 → 4.15.0
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/build/lib/suspense.d.ts +9 -0
- package/build/lib/suspense.esm.js +24 -0
- package/build/lib/suspense.esm.js.map +1 -0
- package/build/lib/suspense.js +31 -0
- package/build/lib/suspense.js.map +1 -0
- package/build/lib/suspense.mjs +24 -0
- package/build/lib/suspense.mjs.map +1 -0
- package/build/lib/useBaseQuery.esm.js +4 -19
- package/build/lib/useBaseQuery.esm.js.map +1 -1
- package/build/lib/useBaseQuery.js +4 -19
- package/build/lib/useBaseQuery.js.map +1 -1
- package/build/lib/useBaseQuery.mjs +4 -19
- package/build/lib/useBaseQuery.mjs.map +1 -1
- package/build/lib/useQueries.esm.js +26 -4
- package/build/lib/useQueries.esm.js.map +1 -1
- package/build/lib/useQueries.js +26 -4
- package/build/lib/useQueries.js.map +1 -1
- package/build/lib/useQueries.mjs +26 -4
- package/build/lib/useQueries.mjs.map +1 -1
- package/build/umd/index.development.js +54 -23
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/suspense.test.tsx +111 -0
- package/src/suspense.ts +59 -0
- package/src/useBaseQuery.ts +4 -25
- package/src/useQueries.ts +41 -9
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DefaultedQueryObserverOptions } from '@tanstack/query-core';
|
|
2
|
+
import type { QueryObserver } from '@tanstack/query-core';
|
|
3
|
+
import type { QueryErrorResetBoundaryValue } from './QueryErrorResetBoundary';
|
|
4
|
+
import type { QueryObserverResult } from '@tanstack/query-core';
|
|
5
|
+
import type { QueryKey } from '@tanstack/query-core';
|
|
6
|
+
export declare const ensureStaleTime: (defaultedOptions: DefaultedQueryObserverOptions<any, any, any, any, any>) => void;
|
|
7
|
+
export declare const willFetch: (result: QueryObserverResult<any, any>, isRestoring: boolean) => boolean;
|
|
8
|
+
export declare const shouldSuspend: (defaultedOptions: DefaultedQueryObserverOptions<any, any, any, any, any> | undefined, result: QueryObserverResult<any, any>, isRestoring: boolean) => boolean | undefined;
|
|
9
|
+
export declare const fetchOptimistic: <TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey>(defaultedOptions: DefaultedQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>, observer: QueryObserver<TQueryFnData, TError, TData, TQueryData, TQueryKey>, errorResetBoundary: QueryErrorResetBoundaryValue) => Promise<void>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const ensureStaleTime = defaultedOptions => {
|
|
2
|
+
if (defaultedOptions.suspense) {
|
|
3
|
+
// Always set stale time when using suspense to prevent
|
|
4
|
+
// fetching again when directly mounting after suspending
|
|
5
|
+
if (typeof defaultedOptions.staleTime !== 'number') {
|
|
6
|
+
defaultedOptions.staleTime = 1000;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
const willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring;
|
|
11
|
+
const shouldSuspend = (defaultedOptions, result, isRestoring) => (defaultedOptions == null ? void 0 : defaultedOptions.suspense) && willFetch(result, isRestoring);
|
|
12
|
+
const fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).then(({
|
|
13
|
+
data
|
|
14
|
+
}) => {
|
|
15
|
+
defaultedOptions.onSuccess == null ? void 0 : defaultedOptions.onSuccess(data);
|
|
16
|
+
defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(data, null);
|
|
17
|
+
}).catch(error => {
|
|
18
|
+
errorResetBoundary.clearReset();
|
|
19
|
+
defaultedOptions.onError == null ? void 0 : defaultedOptions.onError(error);
|
|
20
|
+
defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(undefined, error);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export { ensureStaleTime, fetchOptimistic, shouldSuspend, willFetch };
|
|
24
|
+
//# sourceMappingURL=suspense.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suspense.esm.js","sources":["../../src/suspense.ts"],"sourcesContent":["import type { DefaultedQueryObserverOptions } from '@tanstack/query-core'\nimport type { QueryObserver } from '@tanstack/query-core'\nimport type { QueryErrorResetBoundaryValue } from './QueryErrorResetBoundary'\nimport type { QueryObserverResult } from '@tanstack/query-core'\nimport type { QueryKey } from '@tanstack/query-core'\n\nexport const ensureStaleTime = (\n defaultedOptions: DefaultedQueryObserverOptions<any, any, any, any, any>,\n) => {\n if (defaultedOptions.suspense) {\n // Always set stale time when using suspense to prevent\n // fetching again when directly mounting after suspending\n if (typeof defaultedOptions.staleTime !== 'number') {\n defaultedOptions.staleTime = 1000\n }\n }\n}\n\nexport const willFetch = (\n result: QueryObserverResult<any, any>,\n isRestoring: boolean,\n) => result.isLoading && result.isFetching && !isRestoring\n\nexport const shouldSuspend = (\n defaultedOptions:\n | DefaultedQueryObserverOptions<any, any, any, any, any>\n | undefined,\n result: QueryObserverResult<any, any>,\n isRestoring: boolean,\n) => defaultedOptions?.suspense && willFetch(result, isRestoring)\n\nexport const fetchOptimistic = <\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n defaultedOptions: DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n observer: QueryObserver<TQueryFnData, TError, TData, TQueryData, TQueryKey>,\n errorResetBoundary: QueryErrorResetBoundaryValue,\n) =>\n observer\n .fetchOptimistic(defaultedOptions)\n .then(({ data }) => {\n defaultedOptions.onSuccess?.(data as TData)\n defaultedOptions.onSettled?.(data, null)\n })\n .catch((error) => {\n errorResetBoundary.clearReset()\n defaultedOptions.onError?.(error)\n defaultedOptions.onSettled?.(undefined, error)\n })\n"],"names":["ensureStaleTime","defaultedOptions","suspense","staleTime","willFetch","result","isRestoring","isLoading","isFetching","shouldSuspend","fetchOptimistic","observer","errorResetBoundary","then","data","onSuccess","onSettled","catch","error","clearReset","onError","undefined"],"mappings":"AAMaA,MAAAA,eAAe,GAC1BC,gBAD6B,IAE1B;EACH,IAAIA,gBAAgB,CAACC,QAArB,EAA+B;AAC7B;AACA;AACA,IAAA,IAAI,OAAOD,gBAAgB,CAACE,SAAxB,KAAsC,QAA1C,EAAoD;MAClDF,gBAAgB,CAACE,SAAjB,GAA6B,IAA7B,CAAA;AACD,KAAA;AACF,GAAA;AACF,EAVM;MAYMC,SAAS,GAAG,CACvBC,MADuB,EAEvBC,WAFuB,KAGpBD,MAAM,CAACE,SAAP,IAAoBF,MAAM,CAACG,UAA3B,IAAyC,CAACF,YAHxC;AAKA,MAAMG,aAAa,GAAG,CAC3BR,gBAD2B,EAI3BI,MAJ2B,EAK3BC,WAL2B,KAMxB,CAAAL,gBAAgB,IAAhB,IAAA,GAAA,KAAA,CAAA,GAAAA,gBAAgB,CAAEC,QAAlB,KAA8BE,SAAS,CAACC,MAAD,EAASC,WAAT,EANrC;MAQMI,eAAe,GAAG,CAO7BT,gBAP6B,EAc7BU,QAd6B,EAe7BC,kBAf6B,KAiB7BD,QAAQ,CACLD,eADH,CACmBT,gBADnB,CAEGY,CAAAA,IAFH,CAEQ,CAAC;AAAEC,EAAAA,IAAAA;AAAF,CAAD,KAAc;AAClBb,EAAAA,gBAAgB,CAACc,SAAjB,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAd,gBAAgB,CAACc,SAAjB,CAA6BD,IAA7B,CAAA,CAAA;EACAb,gBAAgB,CAACe,SAAjB,IAAAf,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,gBAAgB,CAACe,SAAjB,CAA6BF,IAA7B,EAAmC,IAAnC,CAAA,CAAA;AACD,CALH,CAMGG,CAAAA,KANH,CAMUC,KAAD,IAAW;AAChBN,EAAAA,kBAAkB,CAACO,UAAnB,EAAA,CAAA;AACAlB,EAAAA,gBAAgB,CAACmB,OAAjB,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAnB,gBAAgB,CAACmB,OAAjB,CAA2BF,KAA3B,CAAA,CAAA;EACAjB,gBAAgB,CAACe,SAAjB,IAAAf,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,gBAAgB,CAACe,SAAjB,CAA6BK,SAA7B,EAAwCH,KAAxC,CAAA,CAAA;AACD,CAVH;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const ensureStaleTime = defaultedOptions => {
|
|
6
|
+
if (defaultedOptions.suspense) {
|
|
7
|
+
// Always set stale time when using suspense to prevent
|
|
8
|
+
// fetching again when directly mounting after suspending
|
|
9
|
+
if (typeof defaultedOptions.staleTime !== 'number') {
|
|
10
|
+
defaultedOptions.staleTime = 1000;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring;
|
|
15
|
+
const shouldSuspend = (defaultedOptions, result, isRestoring) => (defaultedOptions == null ? void 0 : defaultedOptions.suspense) && willFetch(result, isRestoring);
|
|
16
|
+
const fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).then(({
|
|
17
|
+
data
|
|
18
|
+
}) => {
|
|
19
|
+
defaultedOptions.onSuccess == null ? void 0 : defaultedOptions.onSuccess(data);
|
|
20
|
+
defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(data, null);
|
|
21
|
+
}).catch(error => {
|
|
22
|
+
errorResetBoundary.clearReset();
|
|
23
|
+
defaultedOptions.onError == null ? void 0 : defaultedOptions.onError(error);
|
|
24
|
+
defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(undefined, error);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
exports.ensureStaleTime = ensureStaleTime;
|
|
28
|
+
exports.fetchOptimistic = fetchOptimistic;
|
|
29
|
+
exports.shouldSuspend = shouldSuspend;
|
|
30
|
+
exports.willFetch = willFetch;
|
|
31
|
+
//# sourceMappingURL=suspense.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suspense.js","sources":["../../src/suspense.ts"],"sourcesContent":["import type { DefaultedQueryObserverOptions } from '@tanstack/query-core'\nimport type { QueryObserver } from '@tanstack/query-core'\nimport type { QueryErrorResetBoundaryValue } from './QueryErrorResetBoundary'\nimport type { QueryObserverResult } from '@tanstack/query-core'\nimport type { QueryKey } from '@tanstack/query-core'\n\nexport const ensureStaleTime = (\n defaultedOptions: DefaultedQueryObserverOptions<any, any, any, any, any>,\n) => {\n if (defaultedOptions.suspense) {\n // Always set stale time when using suspense to prevent\n // fetching again when directly mounting after suspending\n if (typeof defaultedOptions.staleTime !== 'number') {\n defaultedOptions.staleTime = 1000\n }\n }\n}\n\nexport const willFetch = (\n result: QueryObserverResult<any, any>,\n isRestoring: boolean,\n) => result.isLoading && result.isFetching && !isRestoring\n\nexport const shouldSuspend = (\n defaultedOptions:\n | DefaultedQueryObserverOptions<any, any, any, any, any>\n | undefined,\n result: QueryObserverResult<any, any>,\n isRestoring: boolean,\n) => defaultedOptions?.suspense && willFetch(result, isRestoring)\n\nexport const fetchOptimistic = <\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n defaultedOptions: DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n observer: QueryObserver<TQueryFnData, TError, TData, TQueryData, TQueryKey>,\n errorResetBoundary: QueryErrorResetBoundaryValue,\n) =>\n observer\n .fetchOptimistic(defaultedOptions)\n .then(({ data }) => {\n defaultedOptions.onSuccess?.(data as TData)\n defaultedOptions.onSettled?.(data, null)\n })\n .catch((error) => {\n errorResetBoundary.clearReset()\n defaultedOptions.onError?.(error)\n defaultedOptions.onSettled?.(undefined, error)\n })\n"],"names":["ensureStaleTime","defaultedOptions","suspense","staleTime","willFetch","result","isRestoring","isLoading","isFetching","shouldSuspend","fetchOptimistic","observer","errorResetBoundary","then","data","onSuccess","onSettled","catch","error","clearReset","onError","undefined"],"mappings":";;;;AAMaA,MAAAA,eAAe,GAC1BC,gBAD6B,IAE1B;EACH,IAAIA,gBAAgB,CAACC,QAArB,EAA+B;AAC7B;AACA;AACA,IAAA,IAAI,OAAOD,gBAAgB,CAACE,SAAxB,KAAsC,QAA1C,EAAoD;MAClDF,gBAAgB,CAACE,SAAjB,GAA6B,IAA7B,CAAA;AACD,KAAA;AACF,GAAA;AACF,EAVM;MAYMC,SAAS,GAAG,CACvBC,MADuB,EAEvBC,WAFuB,KAGpBD,MAAM,CAACE,SAAP,IAAoBF,MAAM,CAACG,UAA3B,IAAyC,CAACF,YAHxC;AAKA,MAAMG,aAAa,GAAG,CAC3BR,gBAD2B,EAI3BI,MAJ2B,EAK3BC,WAL2B,KAMxB,CAAAL,gBAAgB,IAAhB,IAAA,GAAA,KAAA,CAAA,GAAAA,gBAAgB,CAAEC,QAAlB,KAA8BE,SAAS,CAACC,MAAD,EAASC,WAAT,EANrC;MAQMI,eAAe,GAAG,CAO7BT,gBAP6B,EAc7BU,QAd6B,EAe7BC,kBAf6B,KAiB7BD,QAAQ,CACLD,eADH,CACmBT,gBADnB,CAEGY,CAAAA,IAFH,CAEQ,CAAC;AAAEC,EAAAA,IAAAA;AAAF,CAAD,KAAc;AAClBb,EAAAA,gBAAgB,CAACc,SAAjB,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAd,gBAAgB,CAACc,SAAjB,CAA6BD,IAA7B,CAAA,CAAA;EACAb,gBAAgB,CAACe,SAAjB,IAAAf,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,gBAAgB,CAACe,SAAjB,CAA6BF,IAA7B,EAAmC,IAAnC,CAAA,CAAA;AACD,CALH,CAMGG,CAAAA,KANH,CAMUC,KAAD,IAAW;AAChBN,EAAAA,kBAAkB,CAACO,UAAnB,EAAA,CAAA;AACAlB,EAAAA,gBAAgB,CAACmB,OAAjB,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAnB,gBAAgB,CAACmB,OAAjB,CAA2BF,KAA3B,CAAA,CAAA;EACAjB,gBAAgB,CAACe,SAAjB,IAAAf,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,gBAAgB,CAACe,SAAjB,CAA6BK,SAA7B,EAAwCH,KAAxC,CAAA,CAAA;AACD,CAVH;;;;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const ensureStaleTime = defaultedOptions => {
|
|
2
|
+
if (defaultedOptions.suspense) {
|
|
3
|
+
// Always set stale time when using suspense to prevent
|
|
4
|
+
// fetching again when directly mounting after suspending
|
|
5
|
+
if (typeof defaultedOptions.staleTime !== 'number') {
|
|
6
|
+
defaultedOptions.staleTime = 1000;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
const willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring;
|
|
11
|
+
const shouldSuspend = (defaultedOptions, result, isRestoring) => (defaultedOptions == null ? void 0 : defaultedOptions.suspense) && willFetch(result, isRestoring);
|
|
12
|
+
const fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).then(({
|
|
13
|
+
data
|
|
14
|
+
}) => {
|
|
15
|
+
defaultedOptions.onSuccess == null ? void 0 : defaultedOptions.onSuccess(data);
|
|
16
|
+
defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(data, null);
|
|
17
|
+
}).catch(error => {
|
|
18
|
+
errorResetBoundary.clearReset();
|
|
19
|
+
defaultedOptions.onError == null ? void 0 : defaultedOptions.onError(error);
|
|
20
|
+
defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(undefined, error);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export { ensureStaleTime, fetchOptimistic, shouldSuspend, willFetch };
|
|
24
|
+
//# sourceMappingURL=suspense.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suspense.mjs","sources":["../../src/suspense.ts"],"sourcesContent":["import type { DefaultedQueryObserverOptions } from '@tanstack/query-core'\nimport type { QueryObserver } from '@tanstack/query-core'\nimport type { QueryErrorResetBoundaryValue } from './QueryErrorResetBoundary'\nimport type { QueryObserverResult } from '@tanstack/query-core'\nimport type { QueryKey } from '@tanstack/query-core'\n\nexport const ensureStaleTime = (\n defaultedOptions: DefaultedQueryObserverOptions<any, any, any, any, any>,\n) => {\n if (defaultedOptions.suspense) {\n // Always set stale time when using suspense to prevent\n // fetching again when directly mounting after suspending\n if (typeof defaultedOptions.staleTime !== 'number') {\n defaultedOptions.staleTime = 1000\n }\n }\n}\n\nexport const willFetch = (\n result: QueryObserverResult<any, any>,\n isRestoring: boolean,\n) => result.isLoading && result.isFetching && !isRestoring\n\nexport const shouldSuspend = (\n defaultedOptions:\n | DefaultedQueryObserverOptions<any, any, any, any, any>\n | undefined,\n result: QueryObserverResult<any, any>,\n isRestoring: boolean,\n) => defaultedOptions?.suspense && willFetch(result, isRestoring)\n\nexport const fetchOptimistic = <\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n defaultedOptions: DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n observer: QueryObserver<TQueryFnData, TError, TData, TQueryData, TQueryKey>,\n errorResetBoundary: QueryErrorResetBoundaryValue,\n) =>\n observer\n .fetchOptimistic(defaultedOptions)\n .then(({ data }) => {\n defaultedOptions.onSuccess?.(data as TData)\n defaultedOptions.onSettled?.(data, null)\n })\n .catch((error) => {\n errorResetBoundary.clearReset()\n defaultedOptions.onError?.(error)\n defaultedOptions.onSettled?.(undefined, error)\n })\n"],"names":["ensureStaleTime","defaultedOptions","suspense","staleTime","willFetch","result","isRestoring","isLoading","isFetching","shouldSuspend","fetchOptimistic","observer","errorReset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AAnB,gBAAgB,CAACmB,OAAjB,CAA2BF,KAA3B,CAAA,CAAA;EACAjB,gBAAgB,CAACe,SAAjB,IAAAf,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,gBAAgB,CAACe,SAAjB,CAA6BK,SAA7B,EAAwCH,KAAxC,CAAA,CAAA;AACD,CAVH;;;;"}
|
|
@@ -5,6 +5,7 @@ import { useQueryErrorResetBoundary } from './QueryErrorResetBoundary.esm.js';
|
|
|
5
5
|
import { useQueryClient } from './QueryClientProvider.esm.js';
|
|
6
6
|
import { useIsRestoring } from './isRestoring.esm.js';
|
|
7
7
|
import { ensurePreventErrorBoundaryRetry, useClearResetErrorBoundary, getHasError } from './errorBoundaryUtils.esm.js';
|
|
8
|
+
import { ensureStaleTime, shouldSuspend, fetchOptimistic } from './suspense.esm.js';
|
|
8
9
|
|
|
9
10
|
function useBaseQuery(options, Observer) {
|
|
10
11
|
const queryClient = useQueryClient({
|
|
@@ -28,14 +29,7 @@ function useBaseQuery(options, Observer) {
|
|
|
28
29
|
defaultedOptions.onSettled = notifyManager.batchCalls(defaultedOptions.onSettled);
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
// Always set stale time when using suspense to prevent
|
|
33
|
-
// fetching again when directly mounting after suspending
|
|
34
|
-
if (typeof defaultedOptions.staleTime !== 'number') {
|
|
35
|
-
defaultedOptions.staleTime = 1000;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
32
|
+
ensureStaleTime(defaultedOptions);
|
|
39
33
|
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
|
|
40
34
|
useClearResetErrorBoundary(errorResetBoundary);
|
|
41
35
|
const [observer] = React.useState(() => new Observer(queryClient, defaultedOptions));
|
|
@@ -49,17 +43,8 @@ function useBaseQuery(options, Observer) {
|
|
|
49
43
|
});
|
|
50
44
|
}, [defaultedOptions, observer]); // Handle suspense
|
|
51
45
|
|
|
52
|
-
if (defaultedOptions
|
|
53
|
-
throw
|
|
54
|
-
data
|
|
55
|
-
}) => {
|
|
56
|
-
defaultedOptions.onSuccess == null ? void 0 : defaultedOptions.onSuccess(data);
|
|
57
|
-
defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(data, null);
|
|
58
|
-
}).catch(error => {
|
|
59
|
-
errorResetBoundary.clearReset();
|
|
60
|
-
defaultedOptions.onError == null ? void 0 : defaultedOptions.onError(error);
|
|
61
|
-
defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(undefined, error);
|
|
62
|
-
});
|
|
46
|
+
if (shouldSuspend(defaultedOptions, result, isRestoring)) {
|
|
47
|
+
throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
|
|
63
48
|
} // Handle error boundary
|
|
64
49
|
|
|
65
50
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBaseQuery.esm.js","sources":["../../src/useBaseQuery.ts"],"sourcesContent":["import * as React from 'react'\nimport { useSyncExternalStore } from './useSyncExternalStore'\n\nimport type { QueryKey, QueryObserver } from '@tanstack/query-core'\nimport { notifyManager } from '@tanstack/query-core'\nimport { useQueryErrorResetBoundary } from './QueryErrorResetBoundary'\nimport { useQueryClient } from './QueryClientProvider'\nimport type { UseBaseQueryOptions } from './types'\nimport { useIsRestoring } from './isRestoring'\nimport {\n ensurePreventErrorBoundaryRetry,\n getHasError,\n useClearResetErrorBoundary,\n} from './errorBoundaryUtils'\n\nexport function useBaseQuery<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n options: UseBaseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n Observer: typeof QueryObserver,\n) {\n const queryClient = useQueryClient({ context: options.context })\n const isRestoring = useIsRestoring()\n const errorResetBoundary = useQueryErrorResetBoundary()\n const defaultedOptions = queryClient.defaultQueryOptions(options)\n\n // Make sure results are optimistically set in fetching state before subscribing or updating options\n defaultedOptions._optimisticResults = isRestoring\n ? 'isRestoring'\n : 'optimistic'\n\n // Include callbacks in batch renders\n if (defaultedOptions.onError) {\n defaultedOptions.onError = notifyManager.batchCalls(\n defaultedOptions.onError,\n )\n }\n\n if (defaultedOptions.onSuccess) {\n defaultedOptions.onSuccess = notifyManager.batchCalls(\n defaultedOptions.onSuccess,\n )\n }\n\n if (defaultedOptions.onSettled) {\n defaultedOptions.onSettled = notifyManager.batchCalls(\n defaultedOptions.onSettled,\n )\n }\n\n
|
|
1
|
+
{"version":3,"file":"useBaseQuery.esm.js","sources":["../../src/useBaseQuery.ts"],"sourcesContent":["import * as React from 'react'\nimport { useSyncExternalStore } from './useSyncExternalStore'\n\nimport type { QueryKey, QueryObserver } from '@tanstack/query-core'\nimport { notifyManager } from '@tanstack/query-core'\nimport { useQueryErrorResetBoundary } from './QueryErrorResetBoundary'\nimport { useQueryClient } from './QueryClientProvider'\nimport type { UseBaseQueryOptions } from './types'\nimport { useIsRestoring } from './isRestoring'\nimport {\n ensurePreventErrorBoundaryRetry,\n getHasError,\n useClearResetErrorBoundary,\n} from './errorBoundaryUtils'\nimport { ensureStaleTime, shouldSuspend, fetchOptimistic } from './suspense'\n\nexport function useBaseQuery<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n options: UseBaseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n Observer: typeof QueryObserver,\n) {\n const queryClient = useQueryClient({ context: options.context })\n const isRestoring = useIsRestoring()\n const errorResetBoundary = useQueryErrorResetBoundary()\n const defaultedOptions = queryClient.defaultQueryOptions(options)\n\n // Make sure results are optimistically set in fetching state before subscribing or updating options\n defaultedOptions._optimisticResults = isRestoring\n ? 'isRestoring'\n : 'optimistic'\n\n // Include callbacks in batch renders\n if (defaultedOptions.onError) {\n defaultedOptions.onError = notifyManager.batchCalls(\n defaultedOptions.onError,\n )\n }\n\n if (defaultedOptions.onSuccess) {\n defaultedOptions.onSuccess = notifyManager.batchCalls(\n defaultedOptions.onSuccess,\n )\n }\n\n if (defaultedOptions.onSettled) {\n defaultedOptions.onSettled = notifyManager.batchCalls(\n defaultedOptions.onSettled,\n )\n }\n\n ensureStaleTime(defaultedOptions)\n ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary)\n\n useClearResetErrorBoundary(errorResetBoundary)\n\n const [observer] = React.useState(\n () =>\n new Observer<TQueryFnData, TError, TData, TQueryData, TQueryKey>(\n queryClient,\n defaultedOptions,\n ),\n )\n\n const result = observer.getOptimisticResult(defaultedOptions)\n\n useSyncExternalStore(\n React.useCallback(\n (onStoreChange) =>\n isRestoring\n ? () => undefined\n : observer.subscribe(notifyManager.batchCalls(onStoreChange)),\n [observer, isRestoring],\n ),\n () => observer.getCurrentResult(),\n () => observer.getCurrentResult(),\n )\n\n React.useEffect(() => {\n // Do not notify on updates because of changes in the options because\n // these changes should already be reflected in the optimistic result.\n observer.setOptions(defaultedOptions, { listeners: false })\n }, [defaultedOptions, observer])\n\n // Handle suspense\n if (shouldSuspend(defaultedOptions, result, isRestoring)) {\n throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary)\n }\n\n // Handle error boundary\n if (\n getHasError({\n result,\n errorResetBoundary,\n useErrorBoundary: defaultedOptions.useErrorBoundary,\n query: observer.getCurrentQuery(),\n })\n ) {\n throw result.error\n }\n\n // Handle result property usage tracking\n return !defaultedOptions.notifyOnChangeProps\n ? observer.trackResult(result)\n : result\n}\n"],"names":["useBaseQuery","options","Observer","queryClient","useQueryClient","context","isRestoring","useIsRestoring","errorResetBoundary","useQueryErrorResetBoundary","defaultedOptions","defaultQueryOptions","_optimisticResults","onError","notifyManager","batchCalls","onSuccess","onSettled","ensureStaleTime","ensurePreventErrorBoundaryRetry","useClearResetErrorBoundary","observer","React","useState","result","getOptimisticResult","useSyncExternalStore","useCallback","onStoreChange","undefined","subscribe","getCurrentResult","useEffect","setOptions","listeners","shouldSuspend","fetchOptimistic","getHasError","useErrorBoundary","query","getCurrentQuery","error","not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A6Bf,gBAA7B,CAAf,CAAA;AAEAgB,EAAAA,oBAAoB,CAClBJ,KAAK,CAACK,WAAN,CACGC,aAAD,IACEtB,WAAW,GACP,MAAMuB,SADC,GAEPR,QAAQ,CAACS,SAAT,CAAmBhB,aAAa,CAACC,UAAd,CAAyBa,aAAzB,CAAnB,CAJR,EAKE,CAACP,QAAD,EAAWf,WAAX,CALF,CADkB,EAQlB,MAAMe,QAAQ,CAACU,gBAAT,EARY,EASlB,MAAMV,QAAQ,CAACU,gBAAT,EATY,CAApB,CAAA;EAYAT,KAAK,CAACU,SAAN,CAAgB,MAAM;AACpB;AACA;AACAX,IAAAA,QAAQ,CAACY,UAAT,CAAoBvB,gBAApB,EAAsC;AAAEwB,MAAAA,SAAS,EAAE,KAAA;KAAnD,CAAA,CAAA;AACD,GAJD,EAIG,CAACxB,gBAAD,EAAmBW,QAAnB,CAJH,EAzDA;;EAgEA,IAAIc,aAAa,CAACzB,gBAAD,EAAmBc,MAAnB,EAA2BlB,WAA3B,CAAjB,EAA0D;AACxD,IAAA,MAAM8B,eAAe,CAAC1B,gBAAD,EAAmBW,QAAnB,EAA6Bb,kBAA7B,CAArB,CAAA;AACD,GAlED;;;AAqEA,EAAA,IACE6B,WAAW,CAAC;IACVb,MADU;IAEVhB,kBAFU;IAGV8B,gBAAgB,EAAE5B,gBAAgB,CAAC4B,gBAHzB;IAIVC,KAAK,EAAElB,QAAQ,CAACmB,eAAT,EAAA;AAJG,GAAD,CADb,EAOE;IACA,MAAMhB,MAAM,CAACiB,KAAb,CAAA;AACD,GA9ED;;;AAiFA,EAAA,OAAO,CAAC/B,gBAAgB,CAACgC,mBAAlB,GACHrB,QAAQ,CAACsB,WAAT,CAAqBnB,MAArB,CADG,GAEHA,MAFJ,CAAA;AAGD;;;;"}
|
|
@@ -9,6 +9,7 @@ var QueryErrorResetBoundary = require('./QueryErrorResetBoundary.js');
|
|
|
9
9
|
var QueryClientProvider = require('./QueryClientProvider.js');
|
|
10
10
|
var isRestoring = require('./isRestoring.js');
|
|
11
11
|
var errorBoundaryUtils = require('./errorBoundaryUtils.js');
|
|
12
|
+
var suspense = require('./suspense.js');
|
|
12
13
|
|
|
13
14
|
function _interopNamespace(e) {
|
|
14
15
|
if (e && e.__esModule) return e;
|
|
@@ -52,14 +53,7 @@ function useBaseQuery(options, Observer) {
|
|
|
52
53
|
defaultedOptions.onSettled = queryCore.notifyManager.batchCalls(defaultedOptions.onSettled);
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
// Always set stale time when using suspense to prevent
|
|
57
|
-
// fetching again when directly mounting after suspending
|
|
58
|
-
if (typeof defaultedOptions.staleTime !== 'number') {
|
|
59
|
-
defaultedOptions.staleTime = 1000;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
56
|
+
suspense.ensureStaleTime(defaultedOptions);
|
|
63
57
|
errorBoundaryUtils.ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
|
|
64
58
|
errorBoundaryUtils.useClearResetErrorBoundary(errorResetBoundary);
|
|
65
59
|
const [observer] = React__namespace.useState(() => new Observer(queryClient, defaultedOptions));
|
|
@@ -73,17 +67,8 @@ function useBaseQuery(options, Observer) {
|
|
|
73
67
|
});
|
|
74
68
|
}, [defaultedOptions, observer]); // Handle suspense
|
|
75
69
|
|
|
76
|
-
if (
|
|
77
|
-
throw
|
|
78
|
-
data
|
|
79
|
-
}) => {
|
|
80
|
-
defaultedOptions.onSuccess == null ? void 0 : defaultedOptions.onSuccess(data);
|
|
81
|
-
defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(data, null);
|
|
82
|
-
}).catch(error => {
|
|
83
|
-
errorResetBoundary.clearReset();
|
|
84
|
-
defaultedOptions.onError == null ? void 0 : defaultedOptions.onError(error);
|
|
85
|
-
defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(undefined, error);
|
|
86
|
-
});
|
|
70
|
+
if (suspense.shouldSuspend(defaultedOptions, result, isRestoring$1)) {
|
|
71
|
+
throw suspense.fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
|
|
87
72
|
} // Handle error boundary
|
|
88
73
|
|
|
89
74
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBaseQuery.js","sources":["../../src/useBaseQuery.ts"],"sourcesContent":["import * as React from 'react'\nimport { useSyncExternalStore } from './useSyncExternalStore'\n\nimport type { QueryKey, QueryObserver } from '@tanstack/query-core'\nimport { notifyManager } from '@tanstack/query-core'\nimport { useQueryErrorResetBoundary } from './QueryErrorResetBoundary'\nimport { useQueryClient } from './QueryClientProvider'\nimport type { UseBaseQueryOptions } from './types'\nimport { useIsRestoring } from './isRestoring'\nimport {\n ensurePreventErrorBoundaryRetry,\n getHasError,\n useClearResetErrorBoundary,\n} from './errorBoundaryUtils'\n\nexport function useBaseQuery<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n options: UseBaseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n Observer: typeof QueryObserver,\n) {\n const queryClient = useQueryClient({ context: options.context })\n const isRestoring = useIsRestoring()\n const errorResetBoundary = useQueryErrorResetBoundary()\n const defaultedOptions = queryClient.defaultQueryOptions(options)\n\n // Make sure results are optimistically set in fetching state before subscribing or updating options\n defaultedOptions._optimisticResults = isRestoring\n ? 'isRestoring'\n : 'optimistic'\n\n // Include callbacks in batch renders\n if (defaultedOptions.onError) {\n defaultedOptions.onError = notifyManager.batchCalls(\n defaultedOptions.onError,\n )\n }\n\n if (defaultedOptions.onSuccess) {\n defaultedOptions.onSuccess = notifyManager.batchCalls(\n defaultedOptions.onSuccess,\n )\n }\n\n if (defaultedOptions.onSettled) {\n defaultedOptions.onSettled = notifyManager.batchCalls(\n defaultedOptions.onSettled,\n )\n }\n\n if (defaultedOptions.suspense) {\n // Always set stale time when using suspense to prevent\n // fetching again when directly mounting after suspending\n if (typeof defaultedOptions.staleTime !== 'number') {\n defaultedOptions.staleTime = 1000\n }\n }\n\n ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary)\n\n useClearResetErrorBoundary(errorResetBoundary)\n\n const [observer] = React.useState(\n () =>\n new Observer<TQueryFnData, TError, TData, TQueryData, TQueryKey>(\n queryClient,\n defaultedOptions,\n ),\n )\n\n const result = observer.getOptimisticResult(defaultedOptions)\n\n useSyncExternalStore(\n React.useCallback(\n (onStoreChange) =>\n isRestoring\n ? () => undefined\n : observer.subscribe(notifyManager.batchCalls(onStoreChange)),\n [observer, isRestoring],\n ),\n () => observer.getCurrentResult(),\n () => observer.getCurrentResult(),\n )\n\n React.useEffect(() => {\n // Do not notify on updates because of changes in the options because\n // these changes should already be reflected in the optimistic result.\n observer.setOptions(defaultedOptions, { listeners: false })\n }, [defaultedOptions, observer])\n\n // Handle suspense\n if (\n defaultedOptions.suspense &&\n result.isLoading &&\n result.isFetching &&\n !isRestoring\n ) {\n throw observer\n .fetchOptimistic(defaultedOptions)\n .then(({ data }) => {\n defaultedOptions.onSuccess?.(data as TData)\n defaultedOptions.onSettled?.(data, null)\n })\n .catch((error) => {\n errorResetBoundary.clearReset()\n defaultedOptions.onError?.(error)\n defaultedOptions.onSettled?.(undefined, error)\n })\n }\n\n // Handle error boundary\n if (\n getHasError({\n result,\n errorResetBoundary,\n useErrorBoundary: defaultedOptions.useErrorBoundary,\n query: observer.getCurrentQuery(),\n })\n ) {\n throw result.error\n }\n\n // Handle result property usage tracking\n return !defaultedOptions.notifyOnChangeProps\n ? observer.trackResult(result)\n : result\n}\n"],"names":["useBaseQuery","options","Observer","queryClient","useQueryClient","context","isRestoring","useIsRestoring","errorResetBoundary","useQueryErrorResetBoundary","defaultedOptions","defaultQueryOptions","_optimisticResults","onError","notifyManager","batchCalls","onSuccess","onSettled","suspense","staleTime","ensurePreventErrorBoundaryRetry","useClearResetErrorBoundary","observer","React","useState","result","getOptimisticResult","useSyncExternalStore","useCallback","onStoreChange","undefined","subscribe","getCurrentResult","useEffect","setOptions","listeners","isLoading","isFetching","fetchOptimistic","then","data","catch","error","clearReset","getHasError","useErrorBoundary","query","getCurrentQuery","notifyOnChangeProps","trackResult"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAASA,CAAT,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAOLC,CAPK,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAcLC,QAdK,CAeL,CAAA,CAAA;EACA,CAAMC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAW,CAAGC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAc,CAAC,CAAA;IAAEC,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAEJ,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAACI,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA;AAAnB,CAAA,CAAA,CAAD,CAAlC,CAAA;EACA,CAAMC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAW,CAAGC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA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CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAACsC,mBAAlB,CACH1B,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAQ,CAAC2B,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAT,CAAqBxB,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAArB,CADG,CAAA,CAAA,CAEHA,MAFJ,CAAA;AAGD,CAAA;;"}
|
|
1
|
+
{"version":3,"file":"useBaseQuery.js","sources":["../../src/useBaseQuery.ts"],"sourcesContent":["import * as React from 'react'\nimport { useSyncExternalStore } from './useSyncExternalStore'\n\nimport type { QueryKey, QueryObserver } from '@tanstack/query-core'\nimport { notifyManager } from '@tanstack/query-core'\nimport { useQueryErrorResetBoundary } from './QueryErrorResetBoundary'\nimport { useQueryClient } from './QueryClientProvider'\nimport type { UseBaseQueryOptions } from './types'\nimport { useIsRestoring } from './isRestoring'\nimport {\n ensurePreventErrorBoundaryRetry,\n getHasError,\n useClearResetErrorBoundary,\n} from './errorBoundaryUtils'\nimport { ensureStaleTime, shouldSuspend, fetchOptimistic } from './suspense'\n\nexport function useBaseQuery<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n options: UseBaseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n Observer: typeof QueryObserver,\n) {\n const queryClient = useQueryClient({ context: options.context })\n const isRestoring = useIsRestoring()\n const errorResetBoundary = useQueryErrorResetBoundary()\n const defaultedOptions = queryClient.defaultQueryOptions(options)\n\n // Make sure results are optimistically set in fetching state before subscribing or updating options\n defaultedOptions._optimisticResults = isRestoring\n ? 'isRestoring'\n : 'optimistic'\n\n // Include callbacks in batch renders\n if (defaultedOptions.onError) {\n defaultedOptions.onError = notifyManager.batchCalls(\n defaultedOptions.onError,\n )\n }\n\n if (defaultedOptions.onSuccess) {\n defaultedOptions.onSuccess = notifyManager.batchCalls(\n defaultedOptions.onSuccess,\n )\n }\n\n if (defaultedOptions.onSettled) {\n defaultedOptions.onSettled = notifyManager.batchCalls(\n defaultedOptions.onSettled,\n )\n }\n\n ensureStaleTime(defaultedOptions)\n ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary)\n\n useClearResetErrorBoundary(errorResetBoundary)\n\n const [observer] = React.useState(\n () =>\n new Observer<TQueryFnData, TError, TData, TQueryData, TQueryKey>(\n queryClient,\n defaultedOptions,\n ),\n )\n\n const result = observer.getOptimisticResult(defaultedOptions)\n\n useSyncExternalStore(\n React.useCallback(\n (onStoreChange) =>\n isRestoring\n ? () => undefined\n : observer.subscribe(notifyManager.batchCalls(onStoreChange)),\n [observer, isRestoring],\n ),\n () => observer.getCurrentResult(),\n () => observer.getCurrentResult(),\n )\n\n React.useEffect(() => {\n // Do not notify on updates because of changes in the options because\n // these changes should already be reflected in the optimistic result.\n observer.setOptions(defaultedOptions, { listeners: false })\n }, [defaultedOptions, observer])\n\n // Handle suspense\n if (shouldSuspend(defaultedOptions, result, isRestoring)) {\n throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary)\n }\n\n // Handle error boundary\n if (\n getHasError({\n result,\n errorResetBoundary,\n useErrorBoundary: defaultedOptions.useErrorBoundary,\n query: observer.getCurrentQuery(),\n })\n ) {\n throw result.error\n }\n\n // Handle result property usage tracking\n return !defaultedOptions.notifyOnChangeProps\n ? observer.trackResult(result)\n : result\n}\n"],"names":["useBaseQuery","options","Observer","queryClient","useQueryClient","context","isRestoring","useIsRestoring","errorResetBoundary","useQueryErrorResetBoundary","defaultedOptions","defaultQueryOptions","_optimisticResults","onError","notifyManager","batchCalls","onSuccess","onSettled","ensureStaleTime","ensurePreventErrorBoundaryRetry","useClearResetErrorBoundary","observer","React","useState","result","getOptimisticResult","useSyncExternalStore","useCallback","onStoreChange","undefined","subscribe","getCurrentResult","useEffect","setOptions","listeners","shouldSuspend","fetchOptimistic","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lB,CACHrB,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAQ,CAACsB,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAT,CAAqBnB,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAArB,CADG,CAAA,CAAA,CAEHA,MAFJ,CAAA;AAGD,CAAA;;"}
|
|
@@ -5,6 +5,7 @@ import { useQueryErrorResetBoundary } from './QueryErrorResetBoundary.mjs';
|
|
|
5
5
|
import { useQueryClient } from './QueryClientProvider.mjs';
|
|
6
6
|
import { useIsRestoring } from './isRestoring.mjs';
|
|
7
7
|
import { ensurePreventErrorBoundaryRetry, useClearResetErrorBoundary, getHasError } from './errorBoundaryUtils.mjs';
|
|
8
|
+
import { ensureStaleTime, shouldSuspend, fetchOptimistic } from './suspense.mjs';
|
|
8
9
|
|
|
9
10
|
function useBaseQuery(options, Observer) {
|
|
10
11
|
const queryClient = useQueryClient({
|
|
@@ -28,14 +29,7 @@ function useBaseQuery(options, Observer) {
|
|
|
28
29
|
defaultedOptions.onSettled = notifyManager.batchCalls(defaultedOptions.onSettled);
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
// Always set stale time when using suspense to prevent
|
|
33
|
-
// fetching again when directly mounting after suspending
|
|
34
|
-
if (typeof defaultedOptions.staleTime !== 'number') {
|
|
35
|
-
defaultedOptions.staleTime = 1000;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
32
|
+
ensureStaleTime(defaultedOptions);
|
|
39
33
|
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
|
|
40
34
|
useClearResetErrorBoundary(errorResetBoundary);
|
|
41
35
|
const [observer] = React.useState(() => new Observer(queryClient, defaultedOptions));
|
|
@@ -49,17 +43,8 @@ function useBaseQuery(options, Observer) {
|
|
|
49
43
|
});
|
|
50
44
|
}, [defaultedOptions, observer]); // Handle suspense
|
|
51
45
|
|
|
52
|
-
if (defaultedOptions
|
|
53
|
-
throw
|
|
54
|
-
data
|
|
55
|
-
}) => {
|
|
56
|
-
defaultedOptions.onSuccess == null ? void 0 : defaultedOptions.onSuccess(data);
|
|
57
|
-
defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(data, null);
|
|
58
|
-
}).catch(error => {
|
|
59
|
-
errorResetBoundary.clearReset();
|
|
60
|
-
defaultedOptions.onError == null ? void 0 : defaultedOptions.onError(error);
|
|
61
|
-
defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(undefined, error);
|
|
62
|
-
});
|
|
46
|
+
if (shouldSuspend(defaultedOptions, result, isRestoring)) {
|
|
47
|
+
throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
|
|
63
48
|
} // Handle error boundary
|
|
64
49
|
|
|
65
50
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBaseQuery.mjs","sources":["../../src/useBaseQuery.ts"],"sourcesContent":["import * as React from 'react'\nimport { useSyncExternalStore } from './useSyncExternalStore'\n\nimport type { QueryKey, QueryObserver } from '@tanstack/query-core'\nimport { notifyManager } from '@tanstack/query-core'\nimport { useQueryErrorResetBoundary } from './QueryErrorResetBoundary'\nimport { useQueryClient } from './QueryClientProvider'\nimport type { UseBaseQueryOptions } from './types'\nimport { useIsRestoring } from './isRestoring'\nimport {\n ensurePreventErrorBoundaryRetry,\n getHasError,\n useClearResetErrorBoundary,\n} from './errorBoundaryUtils'\n\nexport function useBaseQuery<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n options: UseBaseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n Observer: typeof QueryObserver,\n) {\n const queryClient = useQueryClient({ context: options.context })\n const isRestoring = useIsRestoring()\n const errorResetBoundary = useQueryErrorResetBoundary()\n const defaultedOptions = queryClient.defaultQueryOptions(options)\n\n // Make sure results are optimistically set in fetching state before subscribing or updating options\n defaultedOptions._optimisticResults = isRestoring\n ? 'isRestoring'\n : 'optimistic'\n\n // Include callbacks in batch renders\n if (defaultedOptions.onError) {\n defaultedOptions.onError = notifyManager.batchCalls(\n defaultedOptions.onError,\n )\n }\n\n if (defaultedOptions.onSuccess) {\n defaultedOptions.onSuccess = notifyManager.batchCalls(\n defaultedOptions.onSuccess,\n )\n }\n\n if (defaultedOptions.onSettled) {\n defaultedOptions.onSettled = notifyManager.batchCalls(\n defaultedOptions.onSettled,\n )\n }\n\n
|
|
1
|
+
{"version":3,"file":"useBaseQuery.mjs","sources":["../../src/useBaseQuery.ts"],"sourcesContent":["import * as React from 'react'\nimport { useSyncExternalStore } from './useSyncExternalStore'\n\nimport type { QueryKey, QueryObserver } from '@tanstack/query-core'\nimport { notifyManager } from '@tanstack/query-core'\nimport { useQueryErrorResetBoundary } from './QueryErrorResetBoundary'\nimport { useQueryClient } from './QueryClientProvider'\nimport type { UseBaseQueryOptions } from './types'\nimport { useIsRestoring } from './isRestoring'\nimport {\n ensurePreventErrorBoundaryRetry,\n getHasError,\n useClearResetErrorBoundary,\n} from './errorBoundaryUtils'\nimport { ensureStaleTime, shouldSuspend, fetchOptimistic } from './suspense'\n\nexport function useBaseQuery<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n options: UseBaseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n Observer: typeof QueryObserver,\n) {\n const queryClient = useQueryClient({ context: options.context })\n const isRestoring = useIsRestoring()\n const errorResetBoundary = useQueryErrorResetBoundary()\n const defaultedOptions = queryClient.defaultQueryOptions(options)\n\n // Make sure results are optimistically set in fetching state before subscribing or updating options\n defaultedOptions._optimisticResults = isRestoring\n ? 'isRestoring'\n : 'optimistic'\n\n // Include callbacks in batch renders\n if (defaultedOptions.onError) {\n defaultedOptions.onError = notifyManager.batchCalls(\n defaultedOptions.onError,\n )\n }\n\n if (defaultedOptions.onSuccess) {\n defaultedOptions.onSuccess = notifyManager.batchCalls(\n defaultedOptions.onSuccess,\n )\n }\n\n if (defaultedOptions.onSettled) {\n defaultedOptions.onSettled = notifyManager.batchCalls(\n defaultedOptions.onSettled,\n )\n }\n\n ensureStaleTime(defaultedOptions)\n ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary)\n\n useClearResetErrorBoundary(errorResetBoundary)\n\n const [observer] = React.useState(\n () =>\n new Observer<TQueryFnData, TError, TData, TQueryData, TQueryKey>(\n queryClient,\n defaultedOptions,\n ),\n )\n\n const result = observer.getOptimisticResult(defaultedOptions)\n\n useSyncExternalStore(\n React.useCallback(\n (onStoreChange) =>\n isRestoring\n ? () => undefined\n : observer.subscribe(notifyManager.batchCalls(onStoreChange)),\n [observer, isRestoring],\n ),\n () => observer.getCurrentResult(),\n () => observer.getCurrentResult(),\n )\n\n React.useEffect(() => {\n // Do not notify on updates because of changes in the options because\n // these changes should already be reflected in the optimistic result.\n observer.setOptions(defaultedOptions, { listeners: false })\n }, [defaultedOptions, observer])\n\n // Handle suspense\n if (shouldSuspend(defaultedOptions, result, isRestoring)) {\n throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary)\n }\n\n // Handle error boundary\n if (\n getHasError({\n result,\n errorResetBoundary,\n useErrorBoundary: defaultedOptions.useErrorBoundary,\n query: observer.getCurrentQuery(),\n })\n ) {\n throw result.error\n }\n\n // Handle result property usage tracking\n return !defaultedOptions.notifyOnChangeProps\n ? observer.trackResult(result)\n : result\n}\n"],"names":["useBaseQuery","options","Observer","queryClient","useQueryClient","context","isRestoring","useIsRestoring","errorResetBoundary","useQueryErrorResetBoundary","defaultedOptions","defaultQueryOptions","_optimisticResults","onError","notifyManager","batchCalls","onSuccess","onSettled","ensureStaleTime","ensurePreventErrorBoundaryRetry","useClearResetErrorBoundary","observer","React","useState","result","getOptimisticResult","useSyncExternalStore","useCallback","onStoreChange","undefined","subscribe","getCurrentResult","useEffect","setOptions","listeners","shouldSuspend","fetchOptimistic","getHasError","useErrorBoundary","query","getCurrentQuery","error","notifyOnChangeProps","trackResult"],"mappings":";;;;;;;;;AAgBO,SAASA,YAAT,CAOLC,OAPK,EAcLC,QAdK,EAeL;EACA,MAAMC,WAAW,GAAGC,cAAc,CAAC;IAAEC,OAAO,EAAEJ,OAAO,CAACI,OAAAA;AAAnB,GAAD,CAAlC,CAAA;EACA,MAAMC,WAAW,GAAGC,cAAc,EAAlC,CAAA;EACA,MAAMC,kBAAkB,GAAGC,0BAA0B,EAArD,CAAA;EACA,MAAMC,gBAAgB,GAAGP,WAAW,CAACQ,mBAAZ,CAAgCV,OAAhC,CAAzB,CAJA;;EAOAS,gBAAgB,CAACE,kBAAjB,GAAsCN,WAAW,GAC7C,aAD6C,GAE7C,YAFJ,CAPA;;EAYA,IAAII,gBAAgB,CAACG,OAArB,EAA8B;IAC5BH,gBAAgB,CAACG,OAAjB,GAA2BC,aAAa,CAACC,UAAd,CACzBL,gBAAgB,CAACG,OADQ,CAA3B,CAAA;AAGD,GAAA;;EAED,IAAIH,gBAAgB,CAACM,SAArB,EAAgC;IAC9BN,gBAAgB,CAACM,SAAjB,GAA6BF,aAAa,CAACC,UAAd,CAC3BL,gBAAgB,CAACM,SADU,CAA7B,CAAA;AAGD,GAAA;;EAED,IAAIN,gBAAgB,CAACO,SAArB,EAAgC;IAC9BP,gBAAgB,CAACO,SAAjB,GAA6BH,aAAa,CAACC,UAAd,CAC3BL,gBAAgB,CAACO,SADU,CAA7B,CAAA;AAGD,GAAA;;EAEDC,eAAe,CAACR,gBAAD,CAAf,CAAA;AACAS,EAAAA,+BAA+B,CAACT,gBAAD,EAAmBF,kBAAnB,CAA/B,CAAA;EAEAY,0BAA0B,CAACZ,kBAAD,CAA1B,CAAA;AAEA,EAAA,MAAM,CAACa,QAAD,CAAaC,GAAAA,KAAK,CAACC,QAAN,CACjB,MACE,IAAIrB,QAAJ,CACEC,WADF,EAEEO,gBAFF,CAFe,CAAnB,CAAA;A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useIsRestoring } from './isRestoring.esm.js';
|
|
6
6
|
import { useQueryErrorResetBoundary } from './QueryErrorResetBoundary.esm.js';
|
|
7
7
|
import { ensurePreventErrorBoundaryRetry, useClearResetErrorBoundary, getHasError } from './errorBoundaryUtils.esm.js';
|
|
8
|
+
import { ensureStaleTime, shouldSuspend, fetchOptimistic, willFetch } from './suspense.esm.js';
|
|
8
9
|
|
|
9
10
|
// - `context` is omitted as it is passed as a root-level option to `useQueries` instead.
|
|
10
11
|
|
|
@@ -23,7 +24,7 @@ function useQueries({
|
|
|
23
24
|
return defaultedOptions;
|
|
24
25
|
}), [queries, queryClient, isRestoring]);
|
|
25
26
|
const [observer] = React.useState(() => new QueriesObserver(queryClient, defaultedQueries));
|
|
26
|
-
const
|
|
27
|
+
const optimisticResult = observer.getOptimisticResult(defaultedQueries);
|
|
27
28
|
useSyncExternalStore(React.useCallback(onStoreChange => isRestoring ? () => undefined : observer.subscribe(notifyManager.batchCalls(onStoreChange)), [observer, isRestoring]), () => observer.getCurrentResult(), () => observer.getCurrentResult());
|
|
28
29
|
React.useEffect(() => {
|
|
29
30
|
// Do not notify on updates because of changes in the options because
|
|
@@ -35,13 +36,34 @@ function useQueries({
|
|
|
35
36
|
const errorResetBoundary = useQueryErrorResetBoundary();
|
|
36
37
|
defaultedQueries.forEach(query => {
|
|
37
38
|
ensurePreventErrorBoundaryRetry(query, errorResetBoundary);
|
|
39
|
+
ensureStaleTime(query);
|
|
38
40
|
});
|
|
39
41
|
useClearResetErrorBoundary(errorResetBoundary);
|
|
40
|
-
const
|
|
42
|
+
const shouldAtLeastOneSuspend = optimisticResult.some((result, index) => shouldSuspend(defaultedQueries[index], result, isRestoring));
|
|
43
|
+
const suspensePromises = shouldAtLeastOneSuspend ? optimisticResult.flatMap((result, index) => {
|
|
44
|
+
const options = defaultedQueries[index];
|
|
45
|
+
const queryObserver = observer.getObservers()[index];
|
|
46
|
+
|
|
47
|
+
if (options && queryObserver) {
|
|
48
|
+
if (shouldSuspend(options, result, isRestoring)) {
|
|
49
|
+
return fetchOptimistic(options, queryObserver, errorResetBoundary);
|
|
50
|
+
} else if (willFetch(result, isRestoring)) {
|
|
51
|
+
void fetchOptimistic(options, queryObserver, errorResetBoundary);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return [];
|
|
56
|
+
}) : [];
|
|
57
|
+
|
|
58
|
+
if (suspensePromises.length > 0) {
|
|
59
|
+
throw Promise.all(suspensePromises);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const firstSingleResultWhichShouldThrow = optimisticResult.find((result, index) => {
|
|
41
63
|
var _defaultedQueries$ind, _defaultedQueries$ind2;
|
|
42
64
|
|
|
43
65
|
return getHasError({
|
|
44
|
-
result
|
|
66
|
+
result,
|
|
45
67
|
errorResetBoundary,
|
|
46
68
|
useErrorBoundary: (_defaultedQueries$ind = (_defaultedQueries$ind2 = defaultedQueries[index]) == null ? void 0 : _defaultedQueries$ind2.useErrorBoundary) != null ? _defaultedQueries$ind : false,
|
|
47
69
|
query: observer.getQueries()[index]
|
|
@@ -52,7 +74,7 @@ function useQueries({
|
|
|
52
74
|
throw firstSingleResultWhichShouldThrow.error;
|
|
53
75
|
}
|
|
54
76
|
|
|
55
|
-
return
|
|
77
|
+
return optimisticResult;
|
|
56
78
|
}
|
|
57
79
|
|
|
58
80
|
export { useQueries };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueries.esm.js","sources":["../../src/useQueries.ts"],"sourcesContent":["import * as React from 'react'\nimport { useSyncExternalStore } from './useSyncExternalStore'\n\nimport type { QueryKey, QueryFunction } from '@tanstack/query-core'\nimport { notifyManager, QueriesObserver } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\nimport type { UseQueryOptions, UseQueryResult } from './types'\nimport { useIsRestoring } from './isRestoring'\nimport { useQueryErrorResetBoundary } from './QueryErrorResetBoundary'\nimport {\n ensurePreventErrorBoundaryRetry,\n getHasError,\n useClearResetErrorBoundary,\n} from './errorBoundaryUtils'\n\n// This defines the `UseQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.\n// - `context` is omitted as it is passed as a root-level option to `useQueries` instead.\ntype UseQueryOptionsForUseQueries<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'context'>\n\n// Avoid TS depth-limit error in case of large array literal\ntype MAXIMUM_DEPTH = 20\n\ntype GetOptions<T> =\n // Part 1: responsible for applying explicit type parameter to function arguments, if object { queryFnData: TQueryFnData, error: TError, data: TData }\n T extends {\n queryFnData: infer TQueryFnData\n error?: infer TError\n data: infer TData\n }\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? UseQueryOptionsForUseQueries<unknown, TError, TData>\n : // Part 2: responsible for applying explicit type parameter to function arguments, if tuple [TQueryFnData, TError, TData]\n T extends [infer TQueryFnData, infer TError, infer TData]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData>\n : T extends [infer TQueryFnData, infer TError]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? UseQueryOptionsForUseQueries<TQueryFnData>\n : // Part 3: responsible for inferring and enforcing type if no explicit parameter was provided\n T extends {\n queryFn?: QueryFunction<infer TQueryFnData, infer TQueryKey>\n select: (data: any) => infer TData\n }\n ? UseQueryOptionsForUseQueries<TQueryFnData, unknown, TData, TQueryKey>\n : T extends { queryFn?: QueryFunction<infer TQueryFnData, infer TQueryKey> }\n ? UseQueryOptionsForUseQueries<\n TQueryFnData,\n unknown,\n TQueryFnData,\n TQueryKey\n >\n : // Fallback\n UseQueryOptionsForUseQueries\n\ntype GetResults<T> =\n // Part 1: responsible for mapping explicit type parameter to function result, if object\n T extends { queryFnData: any; error?: infer TError; data: infer TData }\n ? UseQueryResult<TData, TError>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseQueryResult<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? UseQueryResult<TData, TError>\n : // Part 2: responsible for mapping explicit type parameter to function result, if tuple\n T extends [any, infer TError, infer TData]\n ? UseQueryResult<TData, TError>\n : T extends [infer TQueryFnData, infer TError]\n ? UseQueryResult<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? UseQueryResult<TQueryFnData>\n : // Part 3: responsible for mapping inferred type to results, if no explicit parameter was provided\n T extends {\n queryFn?: QueryFunction<unknown, any>\n select: (data: any) => infer TData\n }\n ? UseQueryResult<TData>\n : T extends { queryFn?: QueryFunction<infer TQueryFnData, any> }\n ? UseQueryResult<TQueryFnData>\n : // Fallback\n UseQueryResult\n\n/**\n * QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param\n */\nexport type QueriesOptions<\n T extends any[],\n Result extends any[] = [],\n Depth extends ReadonlyArray<number> = [],\n> = Depth['length'] extends MAXIMUM_DEPTH\n ? UseQueryOptionsForUseQueries[]\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...Result, GetOptions<Head>]\n : T extends [infer Head, ...infer Tail]\n ? QueriesOptions<[...Tail], [...Result, GetOptions<Head>], [...Depth, 1]>\n : unknown[] extends T\n ? T\n : // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogenous type!\n // use this to infer the param types in the case of Array.map() argument\n T extends UseQueryOptionsForUseQueries<\n infer TQueryFnData,\n infer TError,\n infer TData,\n infer TQueryKey\n >[]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData, TQueryKey>[]\n : // Fallback\n UseQueryOptionsForUseQueries[]\n\n/**\n * QueriesResults reducer recursively maps type param to results\n */\nexport type QueriesResults<\n T extends any[],\n Result extends any[] = [],\n Depth extends ReadonlyArray<number> = [],\n> = Depth['length'] extends MAXIMUM_DEPTH\n ? UseQueryResult[]\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...Result, GetResults<Head>]\n : T extends [infer Head, ...infer Tail]\n ? QueriesResults<[...Tail], [...Result, GetResults<Head>], [...Depth, 1]>\n : T extends UseQueryOptionsForUseQueries<\n infer TQueryFnData,\n infer TError,\n infer TData,\n any\n >[]\n ? // Dynamic-size (homogenous) UseQueryOptions array: map directly to array of results\n UseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[]\n : // Fallback\n UseQueryResult[]\n\nexport function useQueries<T extends any[]>({\n queries,\n context,\n}: {\n queries: readonly [...QueriesOptions<T>]\n context?: UseQueryOptions['context']\n}): QueriesResults<T> {\n const queryClient = useQueryClient({ context })\n const isRestoring = useIsRestoring()\n\n const defaultedQueries = React.useMemo(\n () =>\n queries.map((options) => {\n const defaultedOptions = queryClient.defaultQueryOptions(options)\n\n // Make sure the results are already in fetching state before subscribing or updating options\n defaultedOptions._optimisticResults = isRestoring\n ? 'isRestoring'\n : 'optimistic'\n\n return defaultedOptions\n }),\n [queries, queryClient, isRestoring],\n )\n\n const [observer] = React.useState(\n () => new QueriesObserver(queryClient, defaultedQueries),\n )\n\n const result = observer.getOptimisticResult(defaultedQueries)\n\n useSyncExternalStore(\n React.useCallback(\n (onStoreChange) =>\n isRestoring\n ? () => undefined\n : observer.subscribe(notifyManager.batchCalls(onStoreChange)),\n [observer, isRestoring],\n ),\n () => observer.getCurrentResult(),\n () => observer.getCurrentResult(),\n )\n\n React.useEffect(() => {\n // Do not notify on updates because of changes in the options because\n // these changes should already be reflected in the optimistic result.\n observer.setQueries(defaultedQueries, { listeners: false })\n }, [defaultedQueries, observer])\n\n const errorResetBoundary = useQueryErrorResetBoundary()\n\n defaultedQueries.forEach((query) => {\n ensurePreventErrorBoundaryRetry(query, errorResetBoundary)\n })\n\n useClearResetErrorBoundary(errorResetBoundary)\n\n const firstSingleResultWhichShouldThrow = result.find((singleResult, index) =>\n getHasError({\n result: singleResult,\n errorResetBoundary,\n useErrorBoundary: defaultedQueries[index]?.useErrorBoundary ?? false,\n query: observer.getQueries()[index]!,\n }),\n )\n\n if (firstSingleResultWhichShouldThrow?.error) {\n throw firstSingleResultWhichShouldThrow.error\n }\n\n return result as QueriesResults<T>\n}\n"],"names":["useQueries","queries","context","queryClient","useQueryClient","isRestoring","useIsRestoring","defaultedQueries","React","useMemo","map","options","defaultedOptions","defaultQueryOptions","_optimisticResults","observer","useState","QueriesObserver","result","getOptimisticResult","useSyncExternalStore","useCallback","onStoreChange","undefined","subscribe","notifyManager","batchCalls","getCurrentResult","useEffect","setQueries","listeners","errorResetBoundary","useQueryErrorResetBoundary","forEach","query","ensurePreventErrorBoundaryRetry","useClearResetErrorBoundary","firstSingleResultWhichShouldThrow","find","singleResult","index","getHasError","useErrorBoundary","getQueries","error"],"mappings":";;;;;;;;AAgBA;;AA+HO,SAASA,UAAT,CAAqC;EAC1CC,OAD0C;AAE1CC,EAAAA,OAAAA;AAF0C,CAArC,EAMe;EACpB,MAAMC,WAAW,GAAGC,cAAc,CAAC;AAAEF,IAAAA,OAAAA;AAAF,GAAD,CAAlC,CAAA;EACA,MAAMG,WAAW,GAAGC,cAAc,EAAlC,CAAA;AAEA,EAAA,MAAMC,gBAAgB,GAAGC,KAAK,CAACC,OAAN,CACvB,MACER,OAAO,CAACS,GAAR,CAAaC,OAAD,IAAa;IACvB,MAAMC,gBAAgB,GAAGT,WAAW,CAACU,mBAAZ,CAAgCF,OAAhC,CAAzB,CADuB;;AAIvBC,IAAAA,gBAAgB,CAACE,kBAAjB,GAAsCT,WAAW,GAC7C,aAD6C,GAE7C,YAFJ,CAAA;AAIA,IAAA,OAAOO,gBAAP,CAAA;GARF,CAFqB,EAYvB,CAACX,OAAD,EAAUE,WAAV,EAAuBE,WAAvB,CAZuB,CAAzB,CAAA;AAeA,EAAA,MAAM,CAACU,QAAD,CAAaP,GAAAA,KAAK,CAACQ,QAAN,CACjB,MAAM,IAAIC,eAAJ,CAAoBd,WAApB,EAAiCI,g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gBAA3B,KAAA,IAAA,GAAA,qBAAA,GAA+C,KAHrD;AAIVR,MAAAA,KAAK,EAAEnB,QAAQ,CAAC4B,UAAT,GAAsBH,KAAtB,CAAA;AAJG,KAAD,CADyC,CAAA;AAAA,GAAZ,CAA1C,CAAA;;AASA,EAAA,IAAIH,iCAAJ,IAAA,IAAA,IAAIA,iCAAiC,CAAEO,KAAvC,EAA8C;IAC5C,MAAMP,iCAAiC,CAACO,KAAxC,CAAA;AACD,GAAA;;AAED,EAAA,OAAO1B,MAAP,CAAA;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"useQueries.esm.js","sources":["../../src/useQueries.ts"],"sourcesContent":["import * as React from 'react'\nimport { useSyncExternalStore } from './useSyncExternalStore'\n\nimport type { QueryKey, QueryFunction } from '@tanstack/query-core'\nimport { notifyManager, QueriesObserver } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\nimport type { UseQueryOptions, UseQueryResult } from './types'\nimport { useIsRestoring } from './isRestoring'\nimport { useQueryErrorResetBoundary } from './QueryErrorResetBoundary'\nimport {\n ensurePreventErrorBoundaryRetry,\n getHasError,\n useClearResetErrorBoundary,\n} from './errorBoundaryUtils'\nimport {\n ensureStaleTime,\n shouldSuspend,\n fetchOptimistic,\n willFetch,\n} from './suspense'\n\n// This defines the `UseQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.\n// - `context` is omitted as it is passed as a root-level option to `useQueries` instead.\ntype UseQueryOptionsForUseQueries<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'context'>\n\n// Avoid TS depth-limit error in case of large array literal\ntype MAXIMUM_DEPTH = 20\n\ntype GetOptions<T> =\n // Part 1: responsible for applying explicit type parameter to function arguments, if object { queryFnData: TQueryFnData, error: TError, data: TData }\n T extends {\n queryFnData: infer TQueryFnData\n error?: infer TError\n data: infer TData\n }\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? UseQueryOptionsForUseQueries<unknown, TError, TData>\n : // Part 2: responsible for applying explicit type parameter to function arguments, if tuple [TQueryFnData, TError, TData]\n T extends [infer TQueryFnData, infer TError, infer TData]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData>\n : T extends [infer TQueryFnData, infer TError]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? UseQueryOptionsForUseQueries<TQueryFnData>\n : // Part 3: responsible for inferring and enforcing type if no explicit parameter was provided\n T extends {\n queryFn?: QueryFunction<infer TQueryFnData, infer TQueryKey>\n select: (data: any) => infer TData\n }\n ? UseQueryOptionsForUseQueries<TQueryFnData, unknown, TData, TQueryKey>\n : T extends { queryFn?: QueryFunction<infer TQueryFnData, infer TQueryKey> }\n ? UseQueryOptionsForUseQueries<\n TQueryFnData,\n unknown,\n TQueryFnData,\n TQueryKey\n >\n : // Fallback\n UseQueryOptionsForUseQueries\n\ntype GetResults<T> =\n // Part 1: responsible for mapping explicit type parameter to function result, if object\n T extends { queryFnData: any; error?: infer TError; data: infer TData }\n ? UseQueryResult<TData, TError>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseQueryResult<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? UseQueryResult<TData, TError>\n : // Part 2: responsible for mapping explicit type parameter to function result, if tuple\n T extends [any, infer TError, infer TData]\n ? UseQueryResult<TData, TError>\n : T extends [infer TQueryFnData, infer TError]\n ? UseQueryResult<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? UseQueryResult<TQueryFnData>\n : // Part 3: responsible for mapping inferred type to results, if no explicit parameter was provided\n T extends {\n queryFn?: QueryFunction<unknown, any>\n select: (data: any) => infer TData\n }\n ? UseQueryResult<TData>\n : T extends { queryFn?: QueryFunction<infer TQueryFnData, any> }\n ? UseQueryResult<TQueryFnData>\n : // Fallback\n UseQueryResult\n\n/**\n * QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param\n */\nexport type QueriesOptions<\n T extends any[],\n Result extends any[] = [],\n Depth extends ReadonlyArray<number> = [],\n> = Depth['length'] extends MAXIMUM_DEPTH\n ? UseQueryOptionsForUseQueries[]\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...Result, GetOptions<Head>]\n : T extends [infer Head, ...infer Tail]\n ? QueriesOptions<[...Tail], [...Result, GetOptions<Head>], [...Depth, 1]>\n : unknown[] extends T\n ? T\n : // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogenous type!\n // use this to infer the param types in the case of Array.map() argument\n T extends UseQueryOptionsForUseQueries<\n infer TQueryFnData,\n infer TError,\n infer TData,\n infer TQueryKey\n >[]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData, TQueryKey>[]\n : // Fallback\n UseQueryOptionsForUseQueries[]\n\n/**\n * QueriesResults reducer recursively maps type param to results\n */\nexport type QueriesResults<\n T extends any[],\n Result extends any[] = [],\n Depth extends ReadonlyArray<number> = [],\n> = Depth['length'] extends MAXIMUM_DEPTH\n ? UseQueryResult[]\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...Result, GetResults<Head>]\n : T extends [infer Head, ...infer Tail]\n ? QueriesResults<[...Tail], [...Result, GetResults<Head>], [...Depth, 1]>\n : T extends UseQueryOptionsForUseQueries<\n infer TQueryFnData,\n infer TError,\n infer TData,\n any\n >[]\n ? // Dynamic-size (homogenous) UseQueryOptions array: map directly to array of results\n UseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[]\n : // Fallback\n UseQueryResult[]\n\nexport function useQueries<T extends any[]>({\n queries,\n context,\n}: {\n queries: readonly [...QueriesOptions<T>]\n context?: UseQueryOptions['context']\n}): QueriesResults<T> {\n const queryClient = useQueryClient({ context })\n const isRestoring = useIsRestoring()\n\n const defaultedQueries = React.useMemo(\n () =>\n queries.map((options) => {\n const defaultedOptions = queryClient.defaultQueryOptions(options)\n\n // Make sure the results are already in fetching state before subscribing or updating options\n defaultedOptions._optimisticResults = isRestoring\n ? 'isRestoring'\n : 'optimistic'\n\n return defaultedOptions\n }),\n [queries, queryClient, isRestoring],\n )\n\n const [observer] = React.useState(\n () => new QueriesObserver(queryClient, defaultedQueries),\n )\n\n const optimisticResult = observer.getOptimisticResult(defaultedQueries)\n\n useSyncExternalStore(\n React.useCallback(\n (onStoreChange) =>\n isRestoring\n ? () => undefined\n : observer.subscribe(notifyManager.batchCalls(onStoreChange)),\n [observer, isRestoring],\n ),\n () => observer.getCurrentResult(),\n () => observer.getCurrentResult(),\n )\n\n React.useEffect(() => {\n // Do not notify on updates because of changes in the options because\n // these changes should already be reflected in the optimistic result.\n observer.setQueries(defaultedQueries, { listeners: false })\n }, [defaultedQueries, observer])\n\n const errorResetBoundary = useQueryErrorResetBoundary()\n\n defaultedQueries.forEach((query) => {\n ensurePreventErrorBoundaryRetry(query, errorResetBoundary)\n ensureStaleTime(query)\n })\n\n useClearResetErrorBoundary(errorResetBoundary)\n\n const shouldAtLeastOneSuspend = optimisticResult.some((result, index) =>\n shouldSuspend(defaultedQueries[index], result, isRestoring),\n )\n\n const suspensePromises = shouldAtLeastOneSuspend\n ? optimisticResult.flatMap((result, index) => {\n const options = defaultedQueries[index]\n const queryObserver = observer.getObservers()[index]\n\n if (options && queryObserver) {\n if (shouldSuspend(options, result, isRestoring)) {\n return fetchOptimistic(options, queryObserver, errorResetBoundary)\n } else if (willFetch(result, isRestoring)) {\n void fetchOptimistic(options, queryObserver, errorResetBoundary)\n }\n }\n return []\n })\n : []\n\n if (suspensePromises.length > 0) {\n throw Promise.all(suspensePromises)\n }\n\n const firstSingleResultWhichShouldThrow = optimisticResult.find(\n (result, index) =>\n getHasError({\n result,\n errorResetBoundary,\n useErrorBoundary: defaultedQueries[index]?.useErrorBoundary ?? false,\n query: observer.getQueries()[index]!,\n }),\n )\n\n if (firstSingleResultWhichShouldThrow?.error) {\n throw firstSingleResultWhichShouldThrow.error\n }\n\n return optimisticResult as QueriesResults<T>\n}\n"],"names":["useQueries","queries","context","queryClient","useQueryClient","isRestoring","useIsRestoring","defaultedQueries","React","useMemo","map","options","defaultedOptions","defaultQueryOptions","_optimisticResults","observer","useState","QueriesObserver","optimisticResult","getOptimisticResult","useSyncExternalStore","useCallback","onStoreChange","undefined","subscribe","notifyManager","batchCalls","getCurrentResult","useEffect","setQueries","listeners","errorResetBoundary","useQueryErrorResetBoundary","forEach","query","ensurePreventErrorBoundaryRetry","ensureStaleTime","useClearResetErrorBoundary","shouldAtLeastOneSuspend","some","result","index","shouldSuspend","suspensePromises","flatMap","queryObserver","getObservers","fetchOptimistic","willFetch","length","Promise","all","firstSingleResultWhichShouldThrow","find","getHasError","useErrorBoundary","getQueries","error"],"mappings":";;;;;;;;;AAsBA;;AA+HO,SAASA,UAAT,CAAqC;EAC1CC,OAD0C;AAE1CC,EAAAA,OAAAA;AAF0C,CAArC,EAMe;EACpB,MAAMC,WAAW,GAAGC,cAAc,CAAC;AAAEF,IAAAA,OAAAA;AAAF,GAAD,CAAlC,CAAA;EACA,MAAMG,WAAW,GAAGC,cAAc,EAAlC,CAAA;AAEA,EAAA,MAAMC,gBAAgB,GAAGC,KAAK,CAACC,OAAN,CACvB,MACER,OAAO,CAACS,GAAR,CAAaC,OAAD,IAAa;IACvB,MAAMC,gBAAgB,GAAGT,WAAW,CAACU,mBAAZ,CAAgCF,OAAhC,CAAzB,CADuB;;AAIvBC,IAAAA,gBAAgB,CAACE,kBAAjB,GAAsCT,WAAW,GAC7C,aAD6C,GAE7C,YAFJ,CAAA;AAIA,IAAA,OAAOO,gBAAP,CAAA;GARF,CAFqB,EAYvB,CAACX,OAAD,EAAUE,WAAV,EAAuBE,WAAvB,CAZuB,CAAzB,CAAA;AAeA,EAAA,MAAM,CAACU,QAAD,CAAaP,GAAAA,KAAK,CAACQ,QAA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