@suspensive/react-query-4 3.17.2 → 3.18.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/dist/{IsFetching-BDzr-LPo.d.cts → IsFetching-CThOxeZB.d.cts} +3 -3
- package/dist/{IsFetching-BDzr-LPo.d.cts.map → IsFetching-CThOxeZB.d.cts.map} +1 -1
- package/dist/IsFetching.d.cts +1 -1
- package/dist/{Mutation-kNfR4Z34.d.cts → Mutation-Dt5kUsd8.d.cts} +3 -3
- package/dist/{Mutation-kNfR4Z34.d.cts.map → Mutation-Dt5kUsd8.d.cts.map} +1 -1
- package/dist/Mutation.d.cts +1 -1
- package/dist/{PrefetchInfiniteQuery-B176YxLR.d.cts → PrefetchInfiniteQuery-C4FsMPPo.d.cts} +3 -3
- package/dist/{PrefetchInfiniteQuery-B176YxLR.d.cts.map → PrefetchInfiniteQuery-C4FsMPPo.d.cts.map} +1 -1
- package/dist/PrefetchInfiniteQuery.d.cts +1 -1
- package/dist/{PrefetchQuery-UXE0XDb0.d.cts → PrefetchQuery-DAqAWOeP.d.mts} +3 -3
- package/dist/{PrefetchQuery-DfCIfLWZ.d.mts.map → PrefetchQuery-DAqAWOeP.d.mts.map} +1 -1
- package/dist/{PrefetchQuery-DfCIfLWZ.d.mts → PrefetchQuery-DFwiRhmK.d.cts} +2 -2
- package/dist/{PrefetchQuery-UXE0XDb0.d.cts.map → PrefetchQuery-DFwiRhmK.d.cts.map} +1 -1
- package/dist/PrefetchQuery.d.cts +1 -1
- package/dist/PrefetchQuery.d.mts +1 -1
- package/dist/{QueriesHydration-Bl02gjbZ.d.mts → QueriesHydration-99AzKj29.d.cts} +7 -6
- package/dist/QueriesHydration-99AzKj29.d.cts.map +1 -0
- package/dist/{QueriesHydration-BT0rn0KQ.cjs → QueriesHydration-BARmyHJu.cjs} +2 -2
- package/dist/QueriesHydration-BARmyHJu.cjs.map +1 -0
- package/dist/{QueriesHydration-BvU3699s.mjs → QueriesHydration-BrMSJHsz.mjs} +2 -2
- package/dist/QueriesHydration-BrMSJHsz.mjs.map +1 -0
- package/dist/{QueriesHydration-CZOIEBb-.d.cts → QueriesHydration-M2zoVGgJ.d.mts} +7 -6
- package/dist/QueriesHydration-M2zoVGgJ.d.mts.map +1 -0
- package/dist/QueriesHydration.cjs +1 -1
- package/dist/QueriesHydration.d.cts +1 -1
- package/dist/QueriesHydration.d.mts +1 -1
- package/dist/QueriesHydration.mjs +1 -1
- package/dist/{QueryClientConsumer-CPUb7Jr6.d.cts → QueryClientConsumer-BGHJsJCv.d.cts} +3 -3
- package/dist/{QueryClientConsumer-CPUb7Jr6.d.cts.map → QueryClientConsumer-BGHJsJCv.d.cts.map} +1 -1
- package/dist/{QueryClientConsumer-DJo29zBV.d.mts → QueryClientConsumer-BW1kmzJX.d.mts} +3 -3
- package/dist/{QueryClientConsumer-DJo29zBV.d.mts.map → QueryClientConsumer-BW1kmzJX.d.mts.map} +1 -1
- package/dist/QueryClientConsumer.d.cts +1 -1
- package/dist/QueryClientConsumer.d.mts +1 -1
- package/dist/{SuspenseInfiniteQuery-DdnqEVHY.d.cts → SuspenseInfiniteQuery-B6hHnPDQ.d.mts} +4 -4
- package/dist/{SuspenseInfiniteQuery-BeKUK5uX.d.mts.map → SuspenseInfiniteQuery-B6hHnPDQ.d.mts.map} +1 -1
- package/dist/{SuspenseInfiniteQuery-BeKUK5uX.d.mts → SuspenseInfiniteQuery-BwSKmJgm.d.cts} +3 -3
- package/dist/{SuspenseInfiniteQuery-DdnqEVHY.d.cts.map → SuspenseInfiniteQuery-BwSKmJgm.d.cts.map} +1 -1
- package/dist/SuspenseInfiniteQuery.d.cts +1 -1
- package/dist/SuspenseInfiniteQuery.d.mts +1 -1
- package/dist/{SuspenseQueries-qFfeHxxp.d.cts → SuspenseQueries-B-UR1dnn.d.cts} +3 -3
- package/dist/{SuspenseQueries-iahkpf8N.d.mts.map → SuspenseQueries-B-UR1dnn.d.cts.map} +1 -1
- package/dist/{SuspenseQueries-iahkpf8N.d.mts → SuspenseQueries-CF_WoDIW.d.mts} +3 -3
- package/dist/{SuspenseQueries-qFfeHxxp.d.cts.map → SuspenseQueries-CF_WoDIW.d.mts.map} +1 -1
- package/dist/SuspenseQueries.d.cts +1 -1
- package/dist/SuspenseQueries.d.mts +1 -1
- package/dist/{SuspenseQuery-VjYG_b1z.d.mts → SuspenseQuery-BT6EsguP.d.cts} +3 -3
- package/dist/{SuspenseQuery-VjYG_b1z.d.mts.map → SuspenseQuery-BT6EsguP.d.cts.map} +1 -1
- package/dist/{SuspenseQuery-dE_OqtUB.d.cts → SuspenseQuery-BZ20Rsoo.d.mts} +3 -3
- package/dist/{SuspenseQuery-dE_OqtUB.d.cts.map → SuspenseQuery-BZ20Rsoo.d.mts.map} +1 -1
- package/dist/SuspenseQuery.d.cts +1 -1
- package/dist/SuspenseQuery.d.mts +1 -1
- package/dist/components/ClientOnly.d.cts +2 -2
- package/dist/components/ClientOnly.d.mts +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +9 -9
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/QueriesHydration.spec.tsx +98 -1
- package/src/QueriesHydration.test-d.tsx +21 -7
- package/src/QueriesHydration.tsx +12 -3
- package/dist/QueriesHydration-BT0rn0KQ.cjs.map +0 -1
- package/dist/QueriesHydration-Bl02gjbZ.d.mts.map +0 -1
- package/dist/QueriesHydration-BvU3699s.mjs.map +0 -1
- package/dist/QueriesHydration-CZOIEBb-.d.cts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime5 from "react/jsx-runtime";
|
|
2
2
|
import { QueryFilters, useIsFetching } from "@tanstack/react-query";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@ declare const IsFetching: ({
|
|
|
10
10
|
children
|
|
11
11
|
}: QueryFilters & {
|
|
12
12
|
children: (isFetching: ReturnType<typeof useIsFetching>) => ReactNode;
|
|
13
|
-
}) =>
|
|
13
|
+
}) => react_jsx_runtime5.JSX.Element;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { IsFetching as t };
|
|
16
|
-
//# sourceMappingURL=IsFetching-
|
|
16
|
+
//# sourceMappingURL=IsFetching-CThOxeZB.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IsFetching-
|
|
1
|
+
{"version":3,"file":"IsFetching-CThOxeZB.d.cts","names":[],"sources":["../src/IsFetching.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAQa,cAAA,UAIZ,EAAA,CAAA;EAAA;CAAA,EAFE,YAEF,GAAA;EAJ0B,QAAA,EAAA,CAAA,UAAA,EAEgB,UAFhB,CAAA,OAEkC,aAFlC,CAAA,EAAA,GAEqD,SAFrD;CAExB,EAAA,GAAwF,kBAAA,CAAA,GAAA,CAAA,OAAxF"}
|
package/dist/IsFetching.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as IsFetching } from "./IsFetching-
|
|
1
|
+
import { t as IsFetching } from "./IsFetching-CThOxeZB.cjs";
|
|
2
2
|
export { IsFetching };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
2
|
import { UseMutationOptions, UseMutationResult } from "@tanstack/react-query";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
|
|
@@ -8,7 +8,7 @@ declare function Mutation<TData = unknown, TError = unknown, TVariables = void,
|
|
|
8
8
|
...options
|
|
9
9
|
}: UseMutationOptions<TData, TError, TVariables, TContext> & {
|
|
10
10
|
children: (mutationResult: UseMutationResult<TData, TError, TVariables, TContext>) => ReactNode;
|
|
11
|
-
}):
|
|
11
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { Mutation as t };
|
|
14
|
-
//# sourceMappingURL=Mutation-
|
|
14
|
+
//# sourceMappingURL=Mutation-Dt5kUsd8.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mutation-
|
|
1
|
+
{"version":3,"file":"Mutation-Dt5kUsd8.d.cts","names":[],"sources":["../src/Mutation.tsx"],"sourcesContent":[],"mappings":";;;;;iBAKgB;;;GAGb,mBAAmB,OAAO,QAAQ,YAAY;6BACpB,kBAAkB,OAAO,QAAQ,YAAY,cAAc;IACvF,kBAAA,CAAA,GAAA,CAAA"}
|
package/dist/Mutation.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as Mutation } from "./Mutation-
|
|
1
|
+
import { t as Mutation } from "./Mutation-Dt5kUsd8.cjs";
|
|
2
2
|
export { Mutation };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime4 from "react/jsx-runtime";
|
|
2
2
|
import { FetchInfiniteQueryOptions, QueryKey } from "@tanstack/react-query";
|
|
3
3
|
|
|
4
4
|
//#region src/PrefetchInfiniteQuery.d.ts
|
|
@@ -11,7 +11,7 @@ import { FetchInfiniteQueryOptions, QueryKey } from "@tanstack/react-query";
|
|
|
11
11
|
* <PrefetchInfiniteQuery queryKey={['queryKey']} queryFn={queryFn} />
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
declare function PrefetchInfiniteQuery<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: FetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey>):
|
|
14
|
+
declare function PrefetchInfiniteQuery<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: FetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey>): react_jsx_runtime4.JSX.Element;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { PrefetchInfiniteQuery as t };
|
|
17
|
-
//# sourceMappingURL=PrefetchInfiniteQuery-
|
|
17
|
+
//# sourceMappingURL=PrefetchInfiniteQuery-C4FsMPPo.d.cts.map
|
package/dist/{PrefetchInfiniteQuery-B176YxLR.d.cts.map → PrefetchInfiniteQuery-C4FsMPPo.d.cts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrefetchInfiniteQuery-
|
|
1
|
+
{"version":3,"file":"PrefetchInfiniteQuery-C4FsMPPo.d.cts","names":[],"sources":["../src/PrefetchInfiniteQuery.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAaA;;;;;AAKmD,iBALnC,qBAKmC,CAAA,eAAA,OAAA,EAAA,SAAA,OAAA,EAAA,QAFzC,YAEyC,EAAA,kBAD/B,QAC+B,GADpB,QACoB,CAAA,CAAA,OAAA,EAAxC,yBAAwC,CAAd,YAAc,EAAA,MAAA,EAAQ,KAAR,EAAe,SAAf,CAAA,CAAA,EAAyB,kBAAA,CAAA,GAAA,CAAA,OAAzB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as PrefetchInfiniteQuery } from "./PrefetchInfiniteQuery-
|
|
1
|
+
import { t as PrefetchInfiniteQuery } from "./PrefetchInfiniteQuery-C4FsMPPo.cjs";
|
|
2
2
|
export { PrefetchInfiniteQuery };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as react_jsx_runtime5 from "react/jsx-runtime";
|
|
2
1
|
import { FetchQueryOptions, QueryKey } from "@tanstack/react-query";
|
|
2
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/PrefetchQuery.d.ts
|
|
5
5
|
|
|
@@ -11,7 +11,7 @@ import { FetchQueryOptions, QueryKey } from "@tanstack/react-query";
|
|
|
11
11
|
* <PrefetchQuery queryKey={['queryKey']} queryFn={queryFn} />
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
declare function PrefetchQuery<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>):
|
|
14
|
+
declare function PrefetchQuery<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>): react_jsx_runtime2.JSX.Element;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { PrefetchQuery as t };
|
|
17
|
-
//# sourceMappingURL=PrefetchQuery-
|
|
17
|
+
//# sourceMappingURL=PrefetchQuery-DAqAWOeP.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrefetchQuery-
|
|
1
|
+
{"version":3,"file":"PrefetchQuery-DAqAWOeP.d.mts","names":[],"sources":["../src/PrefetchQuery.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAaA;;;;;AAK2C,iBAL3B,aAK2B,CAAA,eAAA,OAAA,EAAA,SAAA,OAAA,EAAA,QAFjC,YAEiC,EAAA,kBADvB,QACuB,GADZ,QACY,CAAA,CAAA,OAAA,EAAhC,iBAAgC,CAAd,YAAc,EAAA,MAAA,EAAQ,KAAR,EAAe,SAAf,CAAA,CAAA,EAAyB,kBAAA,CAAA,GAAA,CAAA,OAAzB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FetchQueryOptions, QueryKey } from "@tanstack/react-query";
|
|
2
1
|
import * as react_jsx_runtime7 from "react/jsx-runtime";
|
|
2
|
+
import { FetchQueryOptions, QueryKey } from "@tanstack/react-query";
|
|
3
3
|
|
|
4
4
|
//#region src/PrefetchQuery.d.ts
|
|
5
5
|
|
|
@@ -14,4 +14,4 @@ import * as react_jsx_runtime7 from "react/jsx-runtime";
|
|
|
14
14
|
declare function PrefetchQuery<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>): react_jsx_runtime7.JSX.Element;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { PrefetchQuery as t };
|
|
17
|
-
//# sourceMappingURL=PrefetchQuery-
|
|
17
|
+
//# sourceMappingURL=PrefetchQuery-DFwiRhmK.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrefetchQuery-
|
|
1
|
+
{"version":3,"file":"PrefetchQuery-DFwiRhmK.d.cts","names":[],"sources":["../src/PrefetchQuery.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAaA;;;;;AAK2C,iBAL3B,aAK2B,CAAA,eAAA,OAAA,EAAA,SAAA,OAAA,EAAA,QAFjC,YAEiC,EAAA,kBADvB,QACuB,GADZ,QACY,CAAA,CAAA,OAAA,EAAhC,iBAAgC,CAAd,YAAc,EAAA,MAAA,EAAQ,KAAR,EAAe,SAAf,CAAA,CAAA,EAAyB,kBAAA,CAAA,GAAA,CAAA,OAAzB"}
|
package/dist/PrefetchQuery.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as PrefetchQuery } from "./PrefetchQuery-
|
|
1
|
+
import { t as PrefetchQuery } from "./PrefetchQuery-DFwiRhmK.cjs";
|
|
2
2
|
export { PrefetchQuery };
|
package/dist/PrefetchQuery.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as PrefetchQuery } from "./PrefetchQuery-
|
|
1
|
+
import { t as PrefetchQuery } from "./PrefetchQuery-DAqAWOeP.mjs";
|
|
2
2
|
export { PrefetchQuery };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
|
+
import { HydrateProps, OmitKeyof, QueryClient, QueryOptions, UseInfiniteQueryOptions, WithRequired } from "@tanstack/react-query";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/QueriesHydration.d.ts
|
|
@@ -80,9 +80,10 @@ declare function QueriesHydration({
|
|
|
80
80
|
*/
|
|
81
81
|
queryClient?: QueryClient;
|
|
82
82
|
/**
|
|
83
|
-
* An array of query options to be fetched on the server. Each query must include a `queryKey`.
|
|
83
|
+
* An array of query options or infinite query options to be fetched on the server. Each query must include a `queryKey`.
|
|
84
|
+
* You can mix regular queries and infinite queries in the same array.
|
|
84
85
|
*/
|
|
85
|
-
queries: WithRequired<QueryOptions<any, any, any, any>, 'queryKey'>[];
|
|
86
|
+
queries: (WithRequired<QueryOptions<any, any, any, any>, 'queryKey'> | WithRequired<UseInfiniteQueryOptions<any, any, any, any, any>, 'queryKey'>)[];
|
|
86
87
|
/**
|
|
87
88
|
* Controls error handling behavior:
|
|
88
89
|
* - `true` (default): Skips SSR and falls back to client-side rendering when server fetch fails
|
|
@@ -92,7 +93,7 @@ declare function QueriesHydration({
|
|
|
92
93
|
skipSsrOnError?: boolean | {
|
|
93
94
|
fallback: ReactNode;
|
|
94
95
|
};
|
|
95
|
-
} & OmitKeyof<HydrateProps, 'state'>): Promise<
|
|
96
|
+
} & OmitKeyof<HydrateProps, 'state'>): Promise<react_jsx_runtime0.JSX.Element>;
|
|
96
97
|
//#endregion
|
|
97
98
|
export { QueriesHydration as t };
|
|
98
|
-
//# sourceMappingURL=QueriesHydration-
|
|
99
|
+
//# sourceMappingURL=QueriesHydration-99AzKj29.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueriesHydration-99AzKj29.d.cts","names":[],"sources":["../src/QueriesHydration.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;AA6EA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAsB,gBAAA;;;;;;;;;;gBAUN;;;;;YAMV,aAAa,gDACb,aAAa;;;;;;;;cAWD;;IAEd,UAAU,yBAAsB,QAAA,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -109,7 +109,7 @@ function _QueriesHydration() {
|
|
|
109
109
|
_QueriesHydration = _asyncToGenerator(function* (_ref) {
|
|
110
110
|
let { queries, children, queryClient = new __tanstack_react_query.QueryClient(), skipSsrOnError = true } = _ref, props = require_objectWithoutProperties._objectWithoutProperties(_ref, _excluded);
|
|
111
111
|
try {
|
|
112
|
-
yield Promise.all(queries.map((query) => queryClient.
|
|
112
|
+
yield Promise.all(queries.map((query) => "getNextPageParam" in query ? queryClient.fetchInfiniteQuery(query) : queryClient.fetchQuery(query)));
|
|
113
113
|
} catch (_unused) {
|
|
114
114
|
if (skipSsrOnError) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ClientOnly.ClientOnly, {
|
|
115
115
|
fallback: skipSsrOnError === true ? void 0 : skipSsrOnError.fallback,
|
|
@@ -131,4 +131,4 @@ Object.defineProperty(exports, 'QueriesHydration', {
|
|
|
131
131
|
return QueriesHydration;
|
|
132
132
|
}
|
|
133
133
|
});
|
|
134
|
-
//# sourceMappingURL=QueriesHydration-
|
|
134
|
+
//# sourceMappingURL=QueriesHydration-BARmyHJu.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueriesHydration-BARmyHJu.cjs","names":["QueryClient","ClientOnly","Hydrate"],"sources":["../src/QueriesHydration.tsx"],"sourcesContent":["import {\n Hydrate,\n type HydrateProps,\n type OmitKeyof,\n QueryClient,\n type QueryOptions,\n type UseInfiniteQueryOptions,\n type WithRequired,\n dehydrate,\n} from '@tanstack/react-query'\nimport type { ReactNode } from 'react'\nimport { ClientOnly } from './components/ClientOnly'\n\n/**\n * A server component that fetches multiple queries on the server and hydrates them to the client.\n *\n * @experimental This component is experimental and may be changed or removed in the future.\n *\n * @description\n * QueriesHydration is designed for React Server Components (RSC).\n * It pre-fetches multiple queries on the server side and automatically hydrates\n * the data to the client, enabling seamless data synchronization between server and client.\n *\n * When errors occur during server-side fetching, the component gracefully falls back\n * to client-side rendering, ensuring your application remains resilient.\n *\n * @example\n * ```tsx\n * // app/page.tsx (Server Component)\n * import { Suspense } from 'react'\n * import { QueriesHydration } from '@suspensive/react-query'\n * import { queryOptions } from '@tanstack/react-query'\n *\n * const userQueryOptions = (userId: string) => queryOptions({\n * queryKey: ['user', userId],\n * queryFn: () => fetchUser(userId)\n * })\n *\n * const postsQueryOptions = () => queryOptions({\n * queryKey: ['posts'],\n * queryFn: () => fetchPosts()\n * })\n *\n * export default function Page({ userId }: { userId: string }) {\n * return (\n * <>\n * <Suspense fallback={<div>Loading user...</div>}>\n * <QueriesHydration queries={[userQueryOptions(userId)]}>\n * <UserProfile />\n * </QueriesHydration>\n * </Suspense>\n *\n * <Suspense fallback={<div>Loading posts...</div>}>\n * <QueriesHydration queries={[postsQueryOptions()]}>\n * <PostsList />\n * </QueriesHydration>\n * </Suspense>\n * </>\n * )\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With custom error fallback\n * <Suspense fallback={<div>Loading user...</div>}>\n * <QueriesHydration\n * queries={[userQueryOptions(userId)]}\n * skipSsrOnError={{ fallback: <div>Fetching on client...</div> }}\n * >\n * <UserProfile />\n * </QueriesHydration>\n * </Suspense>\n * ```\n *\n * @see {@link https://suspensive.org/docs/react-query/QueriesHydration Documentation}\n */\nexport async function QueriesHydration({\n queries,\n children,\n queryClient = new QueryClient(),\n skipSsrOnError = true,\n ...props\n}: {\n /**\n * The QueryClient instance to use for fetching queries.\n */\n queryClient?: QueryClient\n /**\n * An array of query options or infinite query options to be fetched on the server. Each query must include a `queryKey`.\n * You can mix regular queries and infinite queries in the same array.\n */\n queries: (\n | WithRequired<QueryOptions<any, any, any, any>, 'queryKey'>\n | WithRequired<UseInfiniteQueryOptions<any, any, any, any, any>, 'queryKey'>\n )[]\n /**\n * Controls error handling behavior:\n * - `true` (default): Skips SSR and falls back to client-side rendering when server fetch fails\n * - `false`: Proceeds with SSR without hydration (retry fetching on client component server rendering)\n * - `{ fallback: ReactNode }`: Skips SSR with custom fallback UI during client-side rendering\n */\n skipSsrOnError?:\n | boolean\n | {\n fallback: ReactNode\n }\n} & OmitKeyof<HydrateProps, 'state'>) {\n try {\n await Promise.all(\n queries.map((query) =>\n 'getNextPageParam' in query ? queryClient.fetchInfiniteQuery(query) : queryClient.fetchQuery(query)\n )\n )\n } catch {\n if (skipSsrOnError) {\n return (\n <ClientOnly fallback={skipSsrOnError === true ? undefined : skipSsrOnError.fallback}>{children}</ClientOnly>\n )\n }\n }\n return (\n <Hydrate {...props} state={dehydrate(queryClient)}>\n {children}\n </Hydrate>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8EE;CACA;CACA;CACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAJF,SAAsB,iBAAiB;;;;wDA8BD;MA9BC,EACrC,SACA,UACA,cAAc,IAAIA,oCAAa,EAC/B,iBAAiB,eACd;AA0BH,MAAI;AACF,SAAM,QAAQ,IACZ,QAAQ,KAAK,UACX,sBAAsB,QAAQ,YAAY,mBAAmB,MAAM,GAAG,YAAY,WAAW,MAAM,CACpG,CACF;oBACK;AACN,OAAI,eACF,QACE,2CAACC;IAAW,UAAU,mBAAmB,OAAO,SAAY,eAAe;IAAW;KAAsB;;AAIlH,SACE,2CAACC,8GAAY;GAAO,6CAAiB,YAAY;GAC9C;KACO"}
|
|
@@ -109,7 +109,7 @@ function _QueriesHydration() {
|
|
|
109
109
|
_QueriesHydration = _asyncToGenerator(function* (_ref) {
|
|
110
110
|
let { queries, children, queryClient = new QueryClient(), skipSsrOnError = true } = _ref, props = _objectWithoutProperties(_ref, _excluded);
|
|
111
111
|
try {
|
|
112
|
-
yield Promise.all(queries.map((query) => queryClient.
|
|
112
|
+
yield Promise.all(queries.map((query) => "getNextPageParam" in query ? queryClient.fetchInfiniteQuery(query) : queryClient.fetchQuery(query)));
|
|
113
113
|
} catch (_unused) {
|
|
114
114
|
if (skipSsrOnError) return /* @__PURE__ */ jsx(ClientOnly, {
|
|
115
115
|
fallback: skipSsrOnError === true ? void 0 : skipSsrOnError.fallback,
|
|
@@ -126,4 +126,4 @@ function _QueriesHydration() {
|
|
|
126
126
|
|
|
127
127
|
//#endregion
|
|
128
128
|
export { QueriesHydration as t };
|
|
129
|
-
//# sourceMappingURL=QueriesHydration-
|
|
129
|
+
//# sourceMappingURL=QueriesHydration-BrMSJHsz.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueriesHydration-BrMSJHsz.mjs","names":[],"sources":["../src/QueriesHydration.tsx"],"sourcesContent":["import {\n Hydrate,\n type HydrateProps,\n type OmitKeyof,\n QueryClient,\n type QueryOptions,\n type UseInfiniteQueryOptions,\n type WithRequired,\n dehydrate,\n} from '@tanstack/react-query'\nimport type { ReactNode } from 'react'\nimport { ClientOnly } from './components/ClientOnly'\n\n/**\n * A server component that fetches multiple queries on the server and hydrates them to the client.\n *\n * @experimental This component is experimental and may be changed or removed in the future.\n *\n * @description\n * QueriesHydration is designed for React Server Components (RSC).\n * It pre-fetches multiple queries on the server side and automatically hydrates\n * the data to the client, enabling seamless data synchronization between server and client.\n *\n * When errors occur during server-side fetching, the component gracefully falls back\n * to client-side rendering, ensuring your application remains resilient.\n *\n * @example\n * ```tsx\n * // app/page.tsx (Server Component)\n * import { Suspense } from 'react'\n * import { QueriesHydration } from '@suspensive/react-query'\n * import { queryOptions } from '@tanstack/react-query'\n *\n * const userQueryOptions = (userId: string) => queryOptions({\n * queryKey: ['user', userId],\n * queryFn: () => fetchUser(userId)\n * })\n *\n * const postsQueryOptions = () => queryOptions({\n * queryKey: ['posts'],\n * queryFn: () => fetchPosts()\n * })\n *\n * export default function Page({ userId }: { userId: string }) {\n * return (\n * <>\n * <Suspense fallback={<div>Loading user...</div>}>\n * <QueriesHydration queries={[userQueryOptions(userId)]}>\n * <UserProfile />\n * </QueriesHydration>\n * </Suspense>\n *\n * <Suspense fallback={<div>Loading posts...</div>}>\n * <QueriesHydration queries={[postsQueryOptions()]}>\n * <PostsList />\n * </QueriesHydration>\n * </Suspense>\n * </>\n * )\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With custom error fallback\n * <Suspense fallback={<div>Loading user...</div>}>\n * <QueriesHydration\n * queries={[userQueryOptions(userId)]}\n * skipSsrOnError={{ fallback: <div>Fetching on client...</div> }}\n * >\n * <UserProfile />\n * </QueriesHydration>\n * </Suspense>\n * ```\n *\n * @see {@link https://suspensive.org/docs/react-query/QueriesHydration Documentation}\n */\nexport async function QueriesHydration({\n queries,\n children,\n queryClient = new QueryClient(),\n skipSsrOnError = true,\n ...props\n}: {\n /**\n * The QueryClient instance to use for fetching queries.\n */\n queryClient?: QueryClient\n /**\n * An array of query options or infinite query options to be fetched on the server. Each query must include a `queryKey`.\n * You can mix regular queries and infinite queries in the same array.\n */\n queries: (\n | WithRequired<QueryOptions<any, any, any, any>, 'queryKey'>\n | WithRequired<UseInfiniteQueryOptions<any, any, any, any, any>, 'queryKey'>\n )[]\n /**\n * Controls error handling behavior:\n * - `true` (default): Skips SSR and falls back to client-side rendering when server fetch fails\n * - `false`: Proceeds with SSR without hydration (retry fetching on client component server rendering)\n * - `{ fallback: ReactNode }`: Skips SSR with custom fallback UI during client-side rendering\n */\n skipSsrOnError?:\n | boolean\n | {\n fallback: ReactNode\n }\n} & OmitKeyof<HydrateProps, 'state'>) {\n try {\n await Promise.all(\n queries.map((query) =>\n 'getNextPageParam' in query ? queryClient.fetchInfiniteQuery(query) : queryClient.fetchQuery(query)\n )\n )\n } catch {\n if (skipSsrOnError) {\n return (\n <ClientOnly fallback={skipSsrOnError === true ? undefined : skipSsrOnError.fallback}>{children}</ClientOnly>\n )\n }\n }\n return (\n <Hydrate {...props} state={dehydrate(queryClient)}>\n {children}\n </Hydrate>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8EE;CACA;CACA;CACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAJF,SAAsB,iBAAiB;;;;wDA8BD;MA9BC,EACrC,SACA,UACA,cAAc,IAAI,aAAa,EAC/B,iBAAiB,eACd;AA0BH,MAAI;AACF,SAAM,QAAQ,IACZ,QAAQ,KAAK,UACX,sBAAsB,QAAQ,YAAY,mBAAmB,MAAM,GAAG,YAAY,WAAW,MAAM,CACpG,CACF;oBACK;AACN,OAAI,eACF,QACE,oBAAC;IAAW,UAAU,mBAAmB,OAAO,SAAY,eAAe;IAAW;KAAsB;;AAIlH,SACE,oBAAC,2CAAY;GAAO,OAAO,UAAU,YAAY;GAC9C;KACO"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { HydrateProps, OmitKeyof, QueryClient, QueryOptions, UseInfiniteQueryOptions, WithRequired } from "@tanstack/react-query";
|
|
2
|
+
import * as react_jsx_runtime3 from "react/jsx-runtime";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/QueriesHydration.d.ts
|
|
@@ -80,9 +80,10 @@ declare function QueriesHydration({
|
|
|
80
80
|
*/
|
|
81
81
|
queryClient?: QueryClient;
|
|
82
82
|
/**
|
|
83
|
-
* An array of query options to be fetched on the server. Each query must include a `queryKey`.
|
|
83
|
+
* An array of query options or infinite query options to be fetched on the server. Each query must include a `queryKey`.
|
|
84
|
+
* You can mix regular queries and infinite queries in the same array.
|
|
84
85
|
*/
|
|
85
|
-
queries: WithRequired<QueryOptions<any, any, any, any>, 'queryKey'>[];
|
|
86
|
+
queries: (WithRequired<QueryOptions<any, any, any, any>, 'queryKey'> | WithRequired<UseInfiniteQueryOptions<any, any, any, any, any>, 'queryKey'>)[];
|
|
86
87
|
/**
|
|
87
88
|
* Controls error handling behavior:
|
|
88
89
|
* - `true` (default): Skips SSR and falls back to client-side rendering when server fetch fails
|
|
@@ -92,7 +93,7 @@ declare function QueriesHydration({
|
|
|
92
93
|
skipSsrOnError?: boolean | {
|
|
93
94
|
fallback: ReactNode;
|
|
94
95
|
};
|
|
95
|
-
} & OmitKeyof<HydrateProps, 'state'>): Promise<
|
|
96
|
+
} & OmitKeyof<HydrateProps, 'state'>): Promise<react_jsx_runtime3.JSX.Element>;
|
|
96
97
|
//#endregion
|
|
97
98
|
export { QueriesHydration as t };
|
|
98
|
-
//# sourceMappingURL=QueriesHydration-
|
|
99
|
+
//# sourceMappingURL=QueriesHydration-M2zoVGgJ.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueriesHydration-M2zoVGgJ.d.mts","names":[],"sources":["../src/QueriesHydration.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;AA6EA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAsB,gBAAA;;;;;;;;;;gBAUN;;;;;YAMV,aAAa,gDACb,aAAa;;;;;;;;cAWD;;IAEd,UAAU,yBAAsB,QAAA,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as QueriesHydration } from "./QueriesHydration-
|
|
1
|
+
import { t as QueriesHydration } from "./QueriesHydration-99AzKj29.cjs";
|
|
2
2
|
export { QueriesHydration };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as QueriesHydration } from "./QueriesHydration-
|
|
1
|
+
import { t as QueriesHydration } from "./QueriesHydration-M2zoVGgJ.mjs";
|
|
2
2
|
export { QueriesHydration };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
2
2
|
import { QueryClient } from "@tanstack/react-query";
|
|
3
3
|
import { Context, ReactNode } from "react";
|
|
4
4
|
|
|
@@ -12,7 +12,7 @@ declare function QueryClientConsumer({
|
|
|
12
12
|
}: {
|
|
13
13
|
children: (queryClient: QueryClient) => ReactNode;
|
|
14
14
|
context?: Context<QueryClient | undefined>;
|
|
15
|
-
}):
|
|
15
|
+
}): react_jsx_runtime1.JSX.Element;
|
|
16
16
|
//#endregion
|
|
17
17
|
export { QueryClientConsumer as t };
|
|
18
|
-
//# sourceMappingURL=QueryClientConsumer-
|
|
18
|
+
//# sourceMappingURL=QueryClientConsumer-BGHJsJCv.d.cts.map
|
package/dist/{QueryClientConsumer-CPUb7Jr6.d.cts.map → QueryClientConsumer-BGHJsJCv.d.cts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryClientConsumer-
|
|
1
|
+
{"version":3,"file":"QueryClientConsumer-BGHJsJCv.d.cts","names":[],"sources":["../src/QueryClientConsumer.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAQgB,iBAAA,mBAAA,CAAmB;EAAA,QAAA;EAAA;CAAA,EAAA;EACjC,QAAA,EAAA,CAAA,WAAA,EAGwB,WAHxB,EAAA,GAGwC,SAHxC;EACA,OAAA,CAAA,EAGU,OAHV,CAGkB,WAHlB,GAAA,SAAA,CAAA;CAEwB,CAAA,EAEzB,kBAAA,CAAA,GAAA,CAAA,OAFyB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryClient } from "@tanstack/react-query";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime4 from "react/jsx-runtime";
|
|
3
3
|
import { Context, ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/QueryClientConsumer.d.ts
|
|
@@ -12,7 +12,7 @@ declare function QueryClientConsumer({
|
|
|
12
12
|
}: {
|
|
13
13
|
children: (queryClient: QueryClient) => ReactNode;
|
|
14
14
|
context?: Context<QueryClient | undefined>;
|
|
15
|
-
}):
|
|
15
|
+
}): react_jsx_runtime4.JSX.Element;
|
|
16
16
|
//#endregion
|
|
17
17
|
export { QueryClientConsumer as t };
|
|
18
|
-
//# sourceMappingURL=QueryClientConsumer-
|
|
18
|
+
//# sourceMappingURL=QueryClientConsumer-BW1kmzJX.d.mts.map
|
package/dist/{QueryClientConsumer-DJo29zBV.d.mts.map → QueryClientConsumer-BW1kmzJX.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryClientConsumer-
|
|
1
|
+
{"version":3,"file":"QueryClientConsumer-BW1kmzJX.d.mts","names":[],"sources":["../src/QueryClientConsumer.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAQgB,iBAAA,mBAAA,CAAmB;EAAA,QAAA;EAAA;CAAA,EAAA;EACjC,QAAA,EAAA,CAAA,WAAA,EAGwB,WAHxB,EAAA,GAGwC,SAHxC;EACA,OAAA,CAAA,EAGU,OAHV,CAGkB,WAHlB,GAAA,SAAA,CAAA;CAEwB,CAAA,EAEzB,kBAAA,CAAA,GAAA,CAAA,OAFyB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as QueryClientConsumer } from "./QueryClientConsumer-
|
|
1
|
+
import { t as QueryClientConsumer } from "./QueryClientConsumer-BGHJsJCv.cjs";
|
|
2
2
|
export { QueryClientConsumer };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as QueryClientConsumer } from "./QueryClientConsumer-
|
|
1
|
+
import { t as QueryClientConsumer } from "./QueryClientConsumer-BW1kmzJX.mjs";
|
|
2
2
|
export { QueryClientConsumer };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as UseSuspenseInfiniteQueryOptions } from "./useSuspenseInfiniteQuery-
|
|
2
|
-
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
1
|
+
import { t as UseSuspenseInfiniteQueryOptions } from "./useSuspenseInfiniteQuery-Bh0nh8Kc.mjs";
|
|
3
2
|
import { QueryKey, UseSuspenseInfiniteQueryResult } from "@tanstack/react-query";
|
|
3
|
+
import * as react_jsx_runtime5 from "react/jsx-runtime";
|
|
4
4
|
import { ReactNode } from "react";
|
|
5
5
|
|
|
6
6
|
//#region src/SuspenseInfiniteQuery.d.ts
|
|
@@ -26,7 +26,7 @@ declare const SuspenseInfiniteQuery: <TQueryFnData = unknown, TError = unknown,
|
|
|
26
26
|
...options
|
|
27
27
|
}: UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
28
28
|
children: (query: UseSuspenseInfiniteQueryResult<TData, TError>) => ReactNode;
|
|
29
|
-
}) =>
|
|
29
|
+
}) => react_jsx_runtime5.JSX.Element;
|
|
30
30
|
//#endregion
|
|
31
31
|
export { SuspenseInfiniteQuery as t };
|
|
32
|
-
//# sourceMappingURL=SuspenseInfiniteQuery-
|
|
32
|
+
//# sourceMappingURL=SuspenseInfiniteQuery-B6hHnPDQ.d.mts.map
|
package/dist/{SuspenseInfiniteQuery-BeKUK5uX.d.mts.map → SuspenseInfiniteQuery-B6hHnPDQ.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuspenseInfiniteQuery-
|
|
1
|
+
{"version":3,"file":"SuspenseInfiniteQuery-B6hHnPDQ.d.mts","names":[],"sources":["../src/SuspenseInfiniteQuery.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;AAqBA;;;;;;;;;;;;;AASsE,cATzD,qBASyD,EAAA,CAAA,eAAA,OAAA,EAAA,SAAA,OAAA,EAAA,QAN5D,YAM4D,EAAA,kBALlD,QAKkD,GALvC,QAKuC,CAAA,CAAA;EAAA,QAAA;EAAA,GAAA;CAAA,EADnE,+BACmE,CADnC,YACmC,EADrB,MACqB,EADb,KACa,EADN,SACM,CAAA,GAAA;EACrE,QAAA,EAAA,CAAA,KAAA,EADmB,8BACnB,CADkD,KAClD,EADyD,MACzD,CAAA,EAAA,GADqE,SACrE;CAAuD,EAAA,GAAvD,kBAAA,CAAA,GAAA,CAAA,OAAuD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as UseSuspenseInfiniteQueryOptions } from "./useSuspenseInfiniteQuery-
|
|
2
|
-
import { QueryKey, UseSuspenseInfiniteQueryResult } from "@tanstack/react-query";
|
|
1
|
+
import { t as UseSuspenseInfiniteQueryOptions } from "./useSuspenseInfiniteQuery-xXu-A7cX.cjs";
|
|
3
2
|
import * as react_jsx_runtime3 from "react/jsx-runtime";
|
|
3
|
+
import { QueryKey, UseSuspenseInfiniteQueryResult } from "@tanstack/react-query";
|
|
4
4
|
import { ReactNode } from "react";
|
|
5
5
|
|
|
6
6
|
//#region src/SuspenseInfiniteQuery.d.ts
|
|
@@ -29,4 +29,4 @@ declare const SuspenseInfiniteQuery: <TQueryFnData = unknown, TError = unknown,
|
|
|
29
29
|
}) => react_jsx_runtime3.JSX.Element;
|
|
30
30
|
//#endregion
|
|
31
31
|
export { SuspenseInfiniteQuery as t };
|
|
32
|
-
//# sourceMappingURL=SuspenseInfiniteQuery-
|
|
32
|
+
//# sourceMappingURL=SuspenseInfiniteQuery-BwSKmJgm.d.cts.map
|
package/dist/{SuspenseInfiniteQuery-DdnqEVHY.d.cts.map → SuspenseInfiniteQuery-BwSKmJgm.d.cts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuspenseInfiniteQuery-
|
|
1
|
+
{"version":3,"file":"SuspenseInfiniteQuery-BwSKmJgm.d.cts","names":[],"sources":["../src/SuspenseInfiniteQuery.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;AAqBA;;;;;;;;;;;;;AASsE,cATzD,qBASyD,EAAA,CAAA,eAAA,OAAA,EAAA,SAAA,OAAA,EAAA,QAN5D,YAM4D,EAAA,kBALlD,QAKkD,GALvC,QAKuC,CAAA,CAAA;EAAA,QAAA;EAAA,GAAA;CAAA,EADnE,+BACmE,CADnC,YACmC,EADrB,MACqB,EADb,KACa,EADN,SACM,CAAA,GAAA;EACrE,QAAA,EAAA,CAAA,KAAA,EADmB,8BACnB,CADkD,KAClD,EADyD,MACzD,CAAA,EAAA,GADqE,SACrE;CAAuD,EAAA,GAAvD,kBAAA,CAAA,GAAA,CAAA,OAAuD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as SuspenseInfiniteQuery } from "./SuspenseInfiniteQuery-
|
|
1
|
+
import { t as SuspenseInfiniteQuery } from "./SuspenseInfiniteQuery-BwSKmJgm.cjs";
|
|
2
2
|
export { SuspenseInfiniteQuery };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime6 from "react/jsx-runtime";
|
|
2
2
|
import { SuspenseQueriesOptions, SuspenseQueriesResults } from "@tanstack/react-query";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
|
|
@@ -25,7 +25,7 @@ declare function SuspenseQueries<T extends any[]>({
|
|
|
25
25
|
}: {
|
|
26
26
|
queries: readonly [...SuspenseQueriesOptions<T>];
|
|
27
27
|
children: (queries: SuspenseQueriesResults<T>) => ReactNode;
|
|
28
|
-
}):
|
|
28
|
+
}): react_jsx_runtime6.JSX.Element;
|
|
29
29
|
//#endregion
|
|
30
30
|
export { SuspenseQueries as t };
|
|
31
|
-
//# sourceMappingURL=SuspenseQueries-
|
|
31
|
+
//# sourceMappingURL=SuspenseQueries-B-UR1dnn.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuspenseQueries-
|
|
1
|
+
{"version":3,"file":"SuspenseQueries-B-UR1dnn.d.cts","names":[],"sources":["../src/SuspenseQueries.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;AAoBA;;;;;;;;;;;;iBAAgB;;;;wBAIQ,uBAAuB;sBACzB,uBAAuB,OAAO;IACnD,kBAAA,CAAA,GAAA,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SuspenseQueriesOptions, SuspenseQueriesResults } from "@tanstack/react-query";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime6 from "react/jsx-runtime";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/SuspenseQueries.d.ts
|
|
@@ -25,7 +25,7 @@ declare function SuspenseQueries<T extends any[]>({
|
|
|
25
25
|
}: {
|
|
26
26
|
queries: readonly [...SuspenseQueriesOptions<T>];
|
|
27
27
|
children: (queries: SuspenseQueriesResults<T>) => ReactNode;
|
|
28
|
-
}):
|
|
28
|
+
}): react_jsx_runtime6.JSX.Element;
|
|
29
29
|
//#endregion
|
|
30
30
|
export { SuspenseQueries as t };
|
|
31
|
-
//# sourceMappingURL=SuspenseQueries-
|
|
31
|
+
//# sourceMappingURL=SuspenseQueries-CF_WoDIW.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuspenseQueries-
|
|
1
|
+
{"version":3,"file":"SuspenseQueries-CF_WoDIW.d.mts","names":[],"sources":["../src/SuspenseQueries.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;AAoBA;;;;;;;;;;;;iBAAgB;;;;wBAIQ,uBAAuB;sBACzB,uBAAuB,OAAO;IACnD,kBAAA,CAAA,GAAA,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as SuspenseQueries } from "./SuspenseQueries-
|
|
1
|
+
import { t as SuspenseQueries } from "./SuspenseQueries-B-UR1dnn.cjs";
|
|
2
2
|
export { SuspenseQueries };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as SuspenseQueries } from "./SuspenseQueries-
|
|
1
|
+
import { t as SuspenseQueries } from "./SuspenseQueries-CF_WoDIW.mjs";
|
|
2
2
|
export { SuspenseQueries };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
1
2
|
import { QueryKey, UseSuspenseQueryOptions, UseSuspenseQueryResult } from "@tanstack/react-query";
|
|
2
|
-
import * as react_jsx_runtime5 from "react/jsx-runtime";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/SuspenseQuery.d.ts
|
|
@@ -25,7 +25,7 @@ declare const SuspenseQuery: <TQueryFnData = unknown, TError = unknown, TData =
|
|
|
25
25
|
...options
|
|
26
26
|
}: UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
27
27
|
children: (queryResult: UseSuspenseQueryResult<TData, TError>) => ReactNode;
|
|
28
|
-
}) =>
|
|
28
|
+
}) => react_jsx_runtime2.JSX.Element;
|
|
29
29
|
//#endregion
|
|
30
30
|
export { SuspenseQuery as t };
|
|
31
|
-
//# sourceMappingURL=SuspenseQuery-
|
|
31
|
+
//# sourceMappingURL=SuspenseQuery-BT6EsguP.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuspenseQuery-
|
|
1
|
+
{"version":3,"file":"SuspenseQuery-BT6EsguP.d.cts","names":[],"sources":["../src/SuspenseQuery.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;AA0BA;;;;;;;;;;;;;AASoE,cATvD,aASuD,EAAA,CAAA,eAAA,OAAA,EAAA,SAAA,OAAA,EAAA,QAN1D,YAM0D,EAAA,kBALhD,QAKgD,GALrC,QAKqC,CAAA,CAAA;EAAA,QAAA;EAAA,GAAA;CAAA,EADjE,uBACiE,CADzC,YACyC,EAD3B,MAC2B,EADnB,KACmB,EADZ,SACY,CAAA,GAAA;EACnE,QAAA,EAAA,CAAA,WAAA,EADyB,sBACzB,CADgD,KAChD,EADuD,MACvD,CAAA,EAAA,GADmE,SACnE;CAA+C,EAAA,GAA/C,kBAAA,CAAA,GAAA,CAAA,OAA+C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
2
1
|
import { QueryKey, UseSuspenseQueryOptions, UseSuspenseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import * as react_jsx_runtime7 from "react/jsx-runtime";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/SuspenseQuery.d.ts
|
|
@@ -25,7 +25,7 @@ declare const SuspenseQuery: <TQueryFnData = unknown, TError = unknown, TData =
|
|
|
25
25
|
...options
|
|
26
26
|
}: UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
27
27
|
children: (queryResult: UseSuspenseQueryResult<TData, TError>) => ReactNode;
|
|
28
|
-
}) =>
|
|
28
|
+
}) => react_jsx_runtime7.JSX.Element;
|
|
29
29
|
//#endregion
|
|
30
30
|
export { SuspenseQuery as t };
|
|
31
|
-
//# sourceMappingURL=SuspenseQuery-
|
|
31
|
+
//# sourceMappingURL=SuspenseQuery-BZ20Rsoo.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuspenseQuery-
|
|
1
|
+
{"version":3,"file":"SuspenseQuery-BZ20Rsoo.d.mts","names":[],"sources":["../src/SuspenseQuery.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;AA0BA;;;;;;;;;;;;;AASoE,cATvD,aASuD,EAAA,CAAA,eAAA,OAAA,EAAA,SAAA,OAAA,EAAA,QAN1D,YAM0D,EAAA,kBALhD,QAKgD,GALrC,QAKqC,CAAA,CAAA;EAAA,QAAA;EAAA,GAAA;CAAA,EADjE,uBACiE,CADzC,YACyC,EAD3B,MAC2B,EADnB,KACmB,EADZ,SACY,CAAA,GAAA;EACnE,QAAA,EAAA,CAAA,WAAA,EADyB,sBACzB,CADgD,KAChD,EADuD,MACvD,CAAA,EAAA,GADmE,SACnE;CAA+C,EAAA,GAA/C,kBAAA,CAAA,GAAA,CAAA,OAA+C"}
|
package/dist/SuspenseQuery.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as SuspenseQuery } from "./SuspenseQuery-
|
|
1
|
+
import { t as SuspenseQuery } from "./SuspenseQuery-BT6EsguP.cjs";
|
|
2
2
|
export { SuspenseQuery };
|
package/dist/SuspenseQuery.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as SuspenseQuery } from "./SuspenseQuery-
|
|
1
|
+
import { t as SuspenseQuery } from "./SuspenseQuery-BZ20Rsoo.mjs";
|
|
2
2
|
export { SuspenseQuery };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime8 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/components/ClientOnly.d.ts
|
|
4
4
|
declare const ClientOnly: ({
|
|
@@ -7,7 +7,7 @@ declare const ClientOnly: ({
|
|
|
7
7
|
}: {
|
|
8
8
|
children: React.ReactNode;
|
|
9
9
|
fallback: React.ReactNode;
|
|
10
|
-
}) =>
|
|
10
|
+
}) => react_jsx_runtime8.JSX.Element;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { ClientOnly };
|
|
13
13
|
//# sourceMappingURL=ClientOnly.d.cts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime8 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/components/ClientOnly.d.ts
|
|
4
4
|
declare const ClientOnly: ({
|
|
@@ -7,7 +7,7 @@ declare const ClientOnly: ({
|
|
|
7
7
|
}: {
|
|
8
8
|
children: React.ReactNode;
|
|
9
9
|
fallback: React.ReactNode;
|
|
10
|
-
}) =>
|
|
10
|
+
}) => react_jsx_runtime8.JSX.Element;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { ClientOnly };
|
|
13
13
|
//# sourceMappingURL=ClientOnly.d.mts.map
|
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ const require_usePrefetchInfiniteQuery = require('./usePrefetchInfiniteQuery-BmZ
|
|
|
4
4
|
const require_PrefetchInfiniteQuery = require('./PrefetchInfiniteQuery-cCSXqKVR.cjs');
|
|
5
5
|
const require_usePrefetchQuery = require('./usePrefetchQuery-woiivAJc.cjs');
|
|
6
6
|
const require_PrefetchQuery = require('./PrefetchQuery-0pdYNtpS.cjs');
|
|
7
|
-
const require_QueriesHydration = require('./QueriesHydration-
|
|
7
|
+
const require_QueriesHydration = require('./QueriesHydration-BARmyHJu.cjs');
|
|
8
8
|
const require_QueryClientConsumer = require('./QueryClientConsumer-mF0OUwkq.cjs');
|
|
9
9
|
const require_SuspenseInfiniteQuery = require('./SuspenseInfiniteQuery-Dq97Dear.cjs');
|
|
10
10
|
const require_SuspenseQueries = require('./SuspenseQueries-Brk6gtMw.cjs');
|
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { t as IsFetching } from "./IsFetching-
|
|
2
|
-
import { t as Mutation } from "./Mutation-
|
|
3
|
-
import { t as PrefetchInfiniteQuery } from "./PrefetchInfiniteQuery-
|
|
4
|
-
import { t as PrefetchQuery } from "./PrefetchQuery-
|
|
5
|
-
import { t as QueriesHydration } from "./QueriesHydration-
|
|
6
|
-
import { t as QueryClientConsumer } from "./QueryClientConsumer-
|
|
1
|
+
import { t as IsFetching } from "./IsFetching-CThOxeZB.cjs";
|
|
2
|
+
import { t as Mutation } from "./Mutation-Dt5kUsd8.cjs";
|
|
3
|
+
import { t as PrefetchInfiniteQuery } from "./PrefetchInfiniteQuery-C4FsMPPo.cjs";
|
|
4
|
+
import { t as PrefetchQuery } from "./PrefetchQuery-DFwiRhmK.cjs";
|
|
5
|
+
import { t as QueriesHydration } from "./QueriesHydration-99AzKj29.cjs";
|
|
6
|
+
import { t as QueryClientConsumer } from "./QueryClientConsumer-BGHJsJCv.cjs";
|
|
7
7
|
import { n as UseSuspenseInfiniteQueryResult, r as useSuspenseInfiniteQuery, t as UseSuspenseInfiniteQueryOptions } from "./useSuspenseInfiniteQuery-xXu-A7cX.cjs";
|
|
8
|
-
import { t as SuspenseInfiniteQuery } from "./SuspenseInfiniteQuery-
|
|
9
|
-
import { t as SuspenseQueries } from "./SuspenseQueries-
|
|
10
|
-
import { t as SuspenseQuery } from "./SuspenseQuery-
|
|
8
|
+
import { t as SuspenseInfiniteQuery } from "./SuspenseInfiniteQuery-BwSKmJgm.cjs";
|
|
9
|
+
import { t as SuspenseQueries } from "./SuspenseQueries-B-UR1dnn.cjs";
|
|
10
|
+
import { t as SuspenseQuery } from "./SuspenseQuery-BT6EsguP.cjs";
|
|
11
11
|
import { t as createGetQueryClient } from "./createGetQueryClient-iXoXO7so.cjs";
|
|
12
12
|
import { n as UnSelectedInfiniteOptions, r as infiniteQueryOptions, t as SelectedInfiniteOptions } from "./infiniteQueryOptions-Be7VYTUR.cjs";
|
|
13
13
|
import { n as UnSelectedQueryOptions, r as queryOptions, t as SelectedQueryOptions } from "./queryOptions-DNGHeGX5.cjs";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { t as IsFetching } from "./IsFetching-D3xmE2Kn.mjs";
|
|
2
2
|
import { t as Mutation } from "./Mutation-CGpbCg54.mjs";
|
|
3
3
|
import { t as PrefetchInfiniteQuery } from "./PrefetchInfiniteQuery-Dzjm5lf8.mjs";
|
|
4
|
-
import { t as PrefetchQuery } from "./PrefetchQuery-
|
|
5
|
-
import { t as QueriesHydration } from "./QueriesHydration-
|
|
6
|
-
import { t as QueryClientConsumer } from "./QueryClientConsumer-
|
|
4
|
+
import { t as PrefetchQuery } from "./PrefetchQuery-DAqAWOeP.mjs";
|
|
5
|
+
import { t as QueriesHydration } from "./QueriesHydration-M2zoVGgJ.mjs";
|
|
6
|
+
import { t as QueryClientConsumer } from "./QueryClientConsumer-BW1kmzJX.mjs";
|
|
7
7
|
import { n as UseSuspenseInfiniteQueryResult, r as useSuspenseInfiniteQuery, t as UseSuspenseInfiniteQueryOptions } from "./useSuspenseInfiniteQuery-Bh0nh8Kc.mjs";
|
|
8
|
-
import { t as SuspenseInfiniteQuery } from "./SuspenseInfiniteQuery-
|
|
9
|
-
import { t as SuspenseQueries } from "./SuspenseQueries-
|
|
10
|
-
import { t as SuspenseQuery } from "./SuspenseQuery-
|
|
8
|
+
import { t as SuspenseInfiniteQuery } from "./SuspenseInfiniteQuery-B6hHnPDQ.mjs";
|
|
9
|
+
import { t as SuspenseQueries } from "./SuspenseQueries-CF_WoDIW.mjs";
|
|
10
|
+
import { t as SuspenseQuery } from "./SuspenseQuery-BZ20Rsoo.mjs";
|
|
11
11
|
import { t as createGetQueryClient } from "./createGetQueryClient-DTKVVwpJ.mjs";
|
|
12
12
|
import { n as UnSelectedInfiniteOptions, r as infiniteQueryOptions, t as SelectedInfiniteOptions } from "./infiniteQueryOptions-Bpz4mFYH.mjs";
|
|
13
13
|
import { n as UnSelectedQueryOptions, r as queryOptions, t as SelectedQueryOptions } from "./queryOptions-DILe-4vk.mjs";
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { t as usePrefetchInfiniteQuery } from "./usePrefetchInfiniteQuery-CQSN-P
|
|
|
4
4
|
import { t as PrefetchInfiniteQuery } from "./PrefetchInfiniteQuery-RS3Qz-7B.mjs";
|
|
5
5
|
import { t as usePrefetchQuery } from "./usePrefetchQuery-CtrJciA6.mjs";
|
|
6
6
|
import { t as PrefetchQuery } from "./PrefetchQuery-uh4idoXK.mjs";
|
|
7
|
-
import { t as QueriesHydration } from "./QueriesHydration-
|
|
7
|
+
import { t as QueriesHydration } from "./QueriesHydration-BrMSJHsz.mjs";
|
|
8
8
|
import { t as QueryClientConsumer } from "./QueryClientConsumer-e7PyaFF3.mjs";
|
|
9
9
|
import { t as SuspenseInfiniteQuery } from "./SuspenseInfiniteQuery-DwW5I_M2.mjs";
|
|
10
10
|
import { t as SuspenseQueries } from "./SuspenseQueries-C0mF_XD_.mjs";
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { QueryClient, dehydrate } from '@tanstack/react-query'
|
|
1
|
+
import { QueryClient, dehydrate, infiniteQueryOptions } from '@tanstack/react-query'
|
|
2
2
|
import { render, screen } from '@testing-library/react'
|
|
3
3
|
import type { ComponentProps, ReactNode } from 'react'
|
|
4
4
|
import { describe, expect, it, vi } from 'vitest'
|
|
@@ -254,4 +254,101 @@ describe('<QueriesHydration/>', () => {
|
|
|
254
254
|
expect(dehydratedState.queries[0].queryKey).toEqual(['test-query'])
|
|
255
255
|
expect(dehydratedState.queries[0].state.data).toEqual(mockData)
|
|
256
256
|
})
|
|
257
|
+
|
|
258
|
+
it('should fetch infiniteQueryOptions and hydrate them successfully', async () => {
|
|
259
|
+
const queryClient = new QueryClient()
|
|
260
|
+
const mockInfiniteQueryFn = vi.fn().mockResolvedValue({ data: 'page-1' })
|
|
261
|
+
|
|
262
|
+
const infiniteOptions = infiniteQueryOptions({
|
|
263
|
+
queryKey: ['infinite-query'],
|
|
264
|
+
queryFn: mockInfiniteQueryFn,
|
|
265
|
+
getNextPageParam: () => null,
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
const result = await QueriesHydration({
|
|
269
|
+
queries: [infiniteOptions],
|
|
270
|
+
queryClient,
|
|
271
|
+
children: <div>Test Children</div>,
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
expect(mockInfiniteQueryFn).toHaveBeenCalledTimes(1)
|
|
275
|
+
expect(result).toBeDefined()
|
|
276
|
+
expect(result.type).toBeDefined()
|
|
277
|
+
})
|
|
278
|
+
|
|
279
|
+
it('should handle mixed queries and infiniteQueryOptions', async () => {
|
|
280
|
+
const queryClient = new QueryClient()
|
|
281
|
+
const mockQueryFn = vi.fn().mockResolvedValue({ data: 'regular-data' })
|
|
282
|
+
const mockInfiniteQueryFn = vi.fn().mockResolvedValue({ data: 'infinite-data' })
|
|
283
|
+
|
|
284
|
+
const queries = [
|
|
285
|
+
{
|
|
286
|
+
queryKey: ['regular-query'],
|
|
287
|
+
queryFn: mockQueryFn,
|
|
288
|
+
},
|
|
289
|
+
infiniteQueryOptions({
|
|
290
|
+
queryKey: ['infinite-query'],
|
|
291
|
+
queryFn: mockInfiniteQueryFn,
|
|
292
|
+
getNextPageParam: () => null,
|
|
293
|
+
}),
|
|
294
|
+
]
|
|
295
|
+
|
|
296
|
+
const result = await QueriesHydration({
|
|
297
|
+
queries,
|
|
298
|
+
queryClient,
|
|
299
|
+
children: <div>Test Children</div>,
|
|
300
|
+
})
|
|
301
|
+
|
|
302
|
+
expect(mockQueryFn).toHaveBeenCalledTimes(1)
|
|
303
|
+
expect(mockInfiniteQueryFn).toHaveBeenCalledTimes(1)
|
|
304
|
+
expect(result).toBeDefined()
|
|
305
|
+
})
|
|
306
|
+
|
|
307
|
+
it('should skip SSR when infiniteQueryOptions fails and skipSsrOnError is true', async () => {
|
|
308
|
+
const queryClient = new QueryClient()
|
|
309
|
+
const mockInfiniteQueryFn = vi.fn().mockRejectedValue(new Error('Infinite query failed'))
|
|
310
|
+
|
|
311
|
+
const infiniteOptions = infiniteQueryOptions({
|
|
312
|
+
queryKey: ['failing-infinite-query'],
|
|
313
|
+
queryFn: mockInfiniteQueryFn,
|
|
314
|
+
getNextPageParam: () => null,
|
|
315
|
+
})
|
|
316
|
+
|
|
317
|
+
const result = await QueriesHydration({
|
|
318
|
+
queries: [infiniteOptions],
|
|
319
|
+
queryClient,
|
|
320
|
+
children: <div>Test Children</div>,
|
|
321
|
+
})
|
|
322
|
+
|
|
323
|
+
expect(mockInfiniteQueryFn).toHaveBeenCalledTimes(1)
|
|
324
|
+
|
|
325
|
+
render(result as React.ReactElement)
|
|
326
|
+
expect(screen.getByTestId('client-only')).toBeInTheDocument()
|
|
327
|
+
})
|
|
328
|
+
|
|
329
|
+
it('should dehydrate infiniteQueryOptions state correctly', async () => {
|
|
330
|
+
const queryClient = new QueryClient()
|
|
331
|
+
|
|
332
|
+
const mockInfiniteQueryFn = vi.fn().mockResolvedValue({ data: 'page-1' })
|
|
333
|
+
|
|
334
|
+
const infiniteOptions = infiniteQueryOptions({
|
|
335
|
+
queryKey: ['infinite-query'],
|
|
336
|
+
queryFn: mockInfiniteQueryFn,
|
|
337
|
+
getNextPageParam: () => null,
|
|
338
|
+
})
|
|
339
|
+
|
|
340
|
+
await QueriesHydration({
|
|
341
|
+
queries: [infiniteOptions],
|
|
342
|
+
queryClient,
|
|
343
|
+
children: <div>Test Children</div>,
|
|
344
|
+
})
|
|
345
|
+
|
|
346
|
+
const dehydratedState = dehydrate(queryClient)
|
|
347
|
+
expect(dehydratedState.queries).toHaveLength(1)
|
|
348
|
+
expect(dehydratedState.queries[0].queryKey).toEqual(['infinite-query'])
|
|
349
|
+
expect(dehydratedState.queries[0].state.data).toEqual({
|
|
350
|
+
pages: [{ data: 'page-1' }],
|
|
351
|
+
pageParams: [undefined],
|
|
352
|
+
})
|
|
353
|
+
})
|
|
257
354
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { QueryClient, queryOptions } from '@tanstack/react-query'
|
|
1
|
+
import { QueryClient, infiniteQueryOptions, queryOptions } from '@tanstack/react-query'
|
|
2
2
|
import { describe, expectTypeOf, it } from 'vitest'
|
|
3
3
|
import { QueriesHydration } from './QueriesHydration'
|
|
4
4
|
import { queryFn, queryKey } from './test-utils'
|
|
@@ -17,12 +17,7 @@ describe('<QueriesHydration/>', () => {
|
|
|
17
17
|
// Should accept queries array with queryKey
|
|
18
18
|
void (async () =>
|
|
19
19
|
await QueriesHydration({
|
|
20
|
-
queries: [
|
|
21
|
-
{
|
|
22
|
-
queryKey: queryKey,
|
|
23
|
-
queryFn: queryFn,
|
|
24
|
-
},
|
|
25
|
-
],
|
|
20
|
+
queries: [{ queryKey, queryFn }],
|
|
26
21
|
children: <></>,
|
|
27
22
|
}))()
|
|
28
23
|
|
|
@@ -65,6 +60,25 @@ describe('<QueriesHydration/>', () => {
|
|
|
65
60
|
children: <></>,
|
|
66
61
|
}))()
|
|
67
62
|
|
|
63
|
+
// Should accept infiniteQueryOptions
|
|
64
|
+
const infiniteOptions = infiniteQueryOptions({
|
|
65
|
+
queryKey: ['infinite'],
|
|
66
|
+
queryFn: queryFn,
|
|
67
|
+
getNextPageParam: () => null,
|
|
68
|
+
})
|
|
69
|
+
void (async () =>
|
|
70
|
+
await QueriesHydration({
|
|
71
|
+
queries: [infiniteOptions],
|
|
72
|
+
children: <></>,
|
|
73
|
+
}))()
|
|
74
|
+
|
|
75
|
+
// Should accept mixed queries and infiniteQueryOptions
|
|
76
|
+
void (async () =>
|
|
77
|
+
await QueriesHydration({
|
|
78
|
+
queries: [options1, infiniteOptions],
|
|
79
|
+
children: <></>,
|
|
80
|
+
}))()
|
|
81
|
+
|
|
68
82
|
// Return type should be JSX.Element (Promise<JSX.Element>)
|
|
69
83
|
expectTypeOf(
|
|
70
84
|
QueriesHydration({
|
package/src/QueriesHydration.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
type OmitKeyof,
|
|
5
5
|
QueryClient,
|
|
6
6
|
type QueryOptions,
|
|
7
|
+
type UseInfiniteQueryOptions,
|
|
7
8
|
type WithRequired,
|
|
8
9
|
dehydrate,
|
|
9
10
|
} from '@tanstack/react-query'
|
|
@@ -86,9 +87,13 @@ export async function QueriesHydration({
|
|
|
86
87
|
*/
|
|
87
88
|
queryClient?: QueryClient
|
|
88
89
|
/**
|
|
89
|
-
* An array of query options to be fetched on the server. Each query must include a `queryKey`.
|
|
90
|
+
* An array of query options or infinite query options to be fetched on the server. Each query must include a `queryKey`.
|
|
91
|
+
* You can mix regular queries and infinite queries in the same array.
|
|
90
92
|
*/
|
|
91
|
-
queries:
|
|
93
|
+
queries: (
|
|
94
|
+
| WithRequired<QueryOptions<any, any, any, any>, 'queryKey'>
|
|
95
|
+
| WithRequired<UseInfiniteQueryOptions<any, any, any, any, any>, 'queryKey'>
|
|
96
|
+
)[]
|
|
92
97
|
/**
|
|
93
98
|
* Controls error handling behavior:
|
|
94
99
|
* - `true` (default): Skips SSR and falls back to client-side rendering when server fetch fails
|
|
@@ -102,7 +107,11 @@ export async function QueriesHydration({
|
|
|
102
107
|
}
|
|
103
108
|
} & OmitKeyof<HydrateProps, 'state'>) {
|
|
104
109
|
try {
|
|
105
|
-
await Promise.all(
|
|
110
|
+
await Promise.all(
|
|
111
|
+
queries.map((query) =>
|
|
112
|
+
'getNextPageParam' in query ? queryClient.fetchInfiniteQuery(query) : queryClient.fetchQuery(query)
|
|
113
|
+
)
|
|
114
|
+
)
|
|
106
115
|
} catch {
|
|
107
116
|
if (skipSsrOnError) {
|
|
108
117
|
return (
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QueriesHydration-BT0rn0KQ.cjs","names":["QueryClient","ClientOnly","Hydrate"],"sources":["../src/QueriesHydration.tsx"],"sourcesContent":["import {\n Hydrate,\n type HydrateProps,\n type OmitKeyof,\n QueryClient,\n type QueryOptions,\n type WithRequired,\n dehydrate,\n} from '@tanstack/react-query'\nimport type { ReactNode } from 'react'\nimport { ClientOnly } from './components/ClientOnly'\n\n/**\n * A server component that fetches multiple queries on the server and hydrates them to the client.\n *\n * @experimental This component is experimental and may be changed or removed in the future.\n *\n * @description\n * QueriesHydration is designed for React Server Components (RSC).\n * It pre-fetches multiple queries on the server side and automatically hydrates\n * the data to the client, enabling seamless data synchronization between server and client.\n *\n * When errors occur during server-side fetching, the component gracefully falls back\n * to client-side rendering, ensuring your application remains resilient.\n *\n * @example\n * ```tsx\n * // app/page.tsx (Server Component)\n * import { Suspense } from 'react'\n * import { QueriesHydration } from '@suspensive/react-query'\n * import { queryOptions } from '@tanstack/react-query'\n *\n * const userQueryOptions = (userId: string) => queryOptions({\n * queryKey: ['user', userId],\n * queryFn: () => fetchUser(userId)\n * })\n *\n * const postsQueryOptions = () => queryOptions({\n * queryKey: ['posts'],\n * queryFn: () => fetchPosts()\n * })\n *\n * export default function Page({ userId }: { userId: string }) {\n * return (\n * <>\n * <Suspense fallback={<div>Loading user...</div>}>\n * <QueriesHydration queries={[userQueryOptions(userId)]}>\n * <UserProfile />\n * </QueriesHydration>\n * </Suspense>\n *\n * <Suspense fallback={<div>Loading posts...</div>}>\n * <QueriesHydration queries={[postsQueryOptions()]}>\n * <PostsList />\n * </QueriesHydration>\n * </Suspense>\n * </>\n * )\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With custom error fallback\n * <Suspense fallback={<div>Loading user...</div>}>\n * <QueriesHydration\n * queries={[userQueryOptions(userId)]}\n * skipSsrOnError={{ fallback: <div>Fetching on client...</div> }}\n * >\n * <UserProfile />\n * </QueriesHydration>\n * </Suspense>\n * ```\n *\n * @see {@link https://suspensive.org/docs/react-query/QueriesHydration Documentation}\n */\nexport async function QueriesHydration({\n queries,\n children,\n queryClient = new QueryClient(),\n skipSsrOnError = true,\n ...props\n}: {\n /**\n * The QueryClient instance to use for fetching queries.\n */\n queryClient?: QueryClient\n /**\n * An array of query options to be fetched on the server. Each query must include a `queryKey`.\n */\n queries: WithRequired<QueryOptions<any, any, any, any>, 'queryKey'>[]\n /**\n * Controls error handling behavior:\n * - `true` (default): Skips SSR and falls back to client-side rendering when server fetch fails\n * - `false`: Proceeds with SSR without hydration (retry fetching on client component server rendering)\n * - `{ fallback: ReactNode }`: Skips SSR with custom fallback UI during client-side rendering\n */\n skipSsrOnError?:\n | boolean\n | {\n fallback: ReactNode\n }\n} & OmitKeyof<HydrateProps, 'state'>) {\n try {\n await Promise.all(queries.map((query) => queryClient.ensureQueryData(query)))\n } catch {\n if (skipSsrOnError) {\n return (\n <ClientOnly fallback={skipSsrOnError === true ? undefined : skipSsrOnError.fallback}>{children}</ClientOnly>\n )\n }\n }\n return (\n <Hydrate {...props} state={dehydrate(queryClient)}>\n {children}\n </Hydrate>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6EE;CACA;CACA;CACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAJF,SAAsB,iBAAiB;;;;wDA0BD;MA1BC,EACrC,SACA,UACA,cAAc,IAAIA,oCAAa,EAC/B,iBAAiB,eACd;AAsBH,MAAI;AACF,SAAM,QAAQ,IAAI,QAAQ,KAAK,UAAU,YAAY,gBAAgB,MAAM,CAAC,CAAC;oBACvE;AACN,OAAI,eACF,QACE,2CAACC;IAAW,UAAU,mBAAmB,OAAO,SAAY,eAAe;IAAW;KAAsB;;AAIlH,SACE,2CAACC,8GAAY;GAAO,6CAAiB,YAAY;GAC9C;KACO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QueriesHydration-Bl02gjbZ.d.mts","names":[],"sources":["../src/QueriesHydration.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;AA4EA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAsB,gBAAA;;;;;;;;;;gBAUN;;;;WAIL,aAAa;;;;;;;;cAUN;;IAEd,UAAU,yBAAsB,QAAA,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QueriesHydration-BvU3699s.mjs","names":[],"sources":["../src/QueriesHydration.tsx"],"sourcesContent":["import {\n Hydrate,\n type HydrateProps,\n type OmitKeyof,\n QueryClient,\n type QueryOptions,\n type WithRequired,\n dehydrate,\n} from '@tanstack/react-query'\nimport type { ReactNode } from 'react'\nimport { ClientOnly } from './components/ClientOnly'\n\n/**\n * A server component that fetches multiple queries on the server and hydrates them to the client.\n *\n * @experimental This component is experimental and may be changed or removed in the future.\n *\n * @description\n * QueriesHydration is designed for React Server Components (RSC).\n * It pre-fetches multiple queries on the server side and automatically hydrates\n * the data to the client, enabling seamless data synchronization between server and client.\n *\n * When errors occur during server-side fetching, the component gracefully falls back\n * to client-side rendering, ensuring your application remains resilient.\n *\n * @example\n * ```tsx\n * // app/page.tsx (Server Component)\n * import { Suspense } from 'react'\n * import { QueriesHydration } from '@suspensive/react-query'\n * import { queryOptions } from '@tanstack/react-query'\n *\n * const userQueryOptions = (userId: string) => queryOptions({\n * queryKey: ['user', userId],\n * queryFn: () => fetchUser(userId)\n * })\n *\n * const postsQueryOptions = () => queryOptions({\n * queryKey: ['posts'],\n * queryFn: () => fetchPosts()\n * })\n *\n * export default function Page({ userId }: { userId: string }) {\n * return (\n * <>\n * <Suspense fallback={<div>Loading user...</div>}>\n * <QueriesHydration queries={[userQueryOptions(userId)]}>\n * <UserProfile />\n * </QueriesHydration>\n * </Suspense>\n *\n * <Suspense fallback={<div>Loading posts...</div>}>\n * <QueriesHydration queries={[postsQueryOptions()]}>\n * <PostsList />\n * </QueriesHydration>\n * </Suspense>\n * </>\n * )\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With custom error fallback\n * <Suspense fallback={<div>Loading user...</div>}>\n * <QueriesHydration\n * queries={[userQueryOptions(userId)]}\n * skipSsrOnError={{ fallback: <div>Fetching on client...</div> }}\n * >\n * <UserProfile />\n * </QueriesHydration>\n * </Suspense>\n * ```\n *\n * @see {@link https://suspensive.org/docs/react-query/QueriesHydration Documentation}\n */\nexport async function QueriesHydration({\n queries,\n children,\n queryClient = new QueryClient(),\n skipSsrOnError = true,\n ...props\n}: {\n /**\n * The QueryClient instance to use for fetching queries.\n */\n queryClient?: QueryClient\n /**\n * An array of query options to be fetched on the server. Each query must include a `queryKey`.\n */\n queries: WithRequired<QueryOptions<any, any, any, any>, 'queryKey'>[]\n /**\n * Controls error handling behavior:\n * - `true` (default): Skips SSR and falls back to client-side rendering when server fetch fails\n * - `false`: Proceeds with SSR without hydration (retry fetching on client component server rendering)\n * - `{ fallback: ReactNode }`: Skips SSR with custom fallback UI during client-side rendering\n */\n skipSsrOnError?:\n | boolean\n | {\n fallback: ReactNode\n }\n} & OmitKeyof<HydrateProps, 'state'>) {\n try {\n await Promise.all(queries.map((query) => queryClient.ensureQueryData(query)))\n } catch {\n if (skipSsrOnError) {\n return (\n <ClientOnly fallback={skipSsrOnError === true ? undefined : skipSsrOnError.fallback}>{children}</ClientOnly>\n )\n }\n }\n return (\n <Hydrate {...props} state={dehydrate(queryClient)}>\n {children}\n </Hydrate>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6EE;CACA;CACA;CACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAJF,SAAsB,iBAAiB;;;;wDA0BD;MA1BC,EACrC,SACA,UACA,cAAc,IAAI,aAAa,EAC/B,iBAAiB,eACd;AAsBH,MAAI;AACF,SAAM,QAAQ,IAAI,QAAQ,KAAK,UAAU,YAAY,gBAAgB,MAAM,CAAC,CAAC;oBACvE;AACN,OAAI,eACF,QACE,oBAAC;IAAW,UAAU,mBAAmB,OAAO,SAAY,eAAe;IAAW;KAAsB;;AAIlH,SACE,oBAAC,2CAAY;GAAO,OAAO,UAAU,YAAY;GAC9C;KACO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QueriesHydration-CZOIEBb-.d.cts","names":[],"sources":["../src/QueriesHydration.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;AA4EA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAsB,gBAAA;;;;;;;;;;gBAUN;;;;WAIL,aAAa;;;;;;;;cAUN;;IAEd,UAAU,yBAAsB,QAAA,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|