@tanstack/react-query 5.0.0-alpha.9 → 5.0.0-alpha.91
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/codemods/remove-overloads/remove-overloads.js +59 -0
- package/build/codemods/remove-overloads/transformers/filter-aware-usage-transformer.js +153 -0
- package/build/codemods/remove-overloads/transformers/query-fn-aware-usage-transformer.js +188 -0
- package/build/codemods/remove-overloads/utils/index.js +124 -0
- package/build/codemods/remove-overloads/utils/unknown-usage-error.js +27 -0
- package/build/codemods/rename-hydrate/rename-hydrate.js +55 -0
- package/build/codemods/rename-properties/rename-properties.js +41 -0
- package/build/codemods/src/utils/index.js +205 -0
- package/build/codemods/src/v4/key-transformation.js +138 -0
- package/build/codemods/src/v4/replace-import-specifier.js +25 -0
- package/build/codemods/transformers/query-cache-transformer.js +116 -0
- package/build/codemods/transformers/query-client-transformer.js +48 -0
- package/build/codemods/transformers/use-query-like-transformer.js +32 -0
- package/build/codemods/utils/replacers/key-replacer.js +164 -0
- package/build/legacy/HydrationBoundary.cjs +60 -0
- package/build/legacy/HydrationBoundary.cjs.map +1 -0
- package/build/legacy/HydrationBoundary.d.cts +12 -0
- package/build/legacy/HydrationBoundary.d.ts +12 -0
- package/build/legacy/HydrationBoundary.js +26 -0
- package/build/legacy/HydrationBoundary.js.map +1 -0
- package/build/legacy/QueryClientProvider.cjs +71 -0
- package/build/legacy/QueryClientProvider.cjs.map +1 -0
- package/build/legacy/QueryClientProvider.d.cts +12 -0
- package/build/legacy/QueryClientProvider.d.ts +12 -0
- package/build/legacy/QueryClientProvider.js +35 -0
- package/build/legacy/QueryClientProvider.js.map +1 -0
- package/build/legacy/QueryErrorResetBoundary.cjs +66 -0
- package/build/legacy/QueryErrorResetBoundary.cjs.map +1 -0
- package/build/legacy/QueryErrorResetBoundary.d.cts +14 -0
- package/build/legacy/QueryErrorResetBoundary.d.ts +14 -0
- package/build/legacy/QueryErrorResetBoundary.js +31 -0
- package/build/legacy/QueryErrorResetBoundary.js.map +1 -0
- package/build/legacy/errorBoundaryUtils.cjs +67 -0
- package/build/legacy/errorBoundaryUtils.cjs.map +1 -0
- package/build/legacy/errorBoundaryUtils.d.cts +14 -0
- package/build/legacy/errorBoundaryUtils.d.ts +14 -0
- package/build/legacy/errorBoundaryUtils.js +31 -0
- package/build/legacy/errorBoundaryUtils.js.map +1 -0
- package/build/legacy/index.cjs +85 -0
- package/build/legacy/index.cjs.map +1 -0
- package/build/legacy/index.d.cts +17 -0
- package/build/legacy/index.d.ts +17 -0
- package/build/legacy/index.js +46 -0
- package/build/legacy/index.js.map +1 -0
- package/build/legacy/infiniteQueryOptions.cjs +33 -0
- package/build/legacy/infiniteQueryOptions.cjs.map +1 -0
- package/build/legacy/infiniteQueryOptions.d.cts +13 -0
- package/build/legacy/infiniteQueryOptions.d.ts +13 -0
- package/build/legacy/infiniteQueryOptions.js +8 -0
- package/build/legacy/infiniteQueryOptions.js.map +1 -0
- package/build/legacy/isRestoring.cjs +47 -0
- package/build/legacy/isRestoring.cjs.map +1 -0
- package/build/legacy/isRestoring.d.cts +6 -0
- package/build/legacy/isRestoring.d.ts +6 -0
- package/build/legacy/isRestoring.js +12 -0
- package/build/legacy/isRestoring.js.map +1 -0
- package/build/legacy/queryOptions.cjs +33 -0
- package/build/legacy/queryOptions.cjs.map +1 -0
- package/build/legacy/queryOptions.d.cts +13 -0
- package/build/legacy/queryOptions.d.ts +13 -0
- package/build/legacy/queryOptions.js +8 -0
- package/build/legacy/queryOptions.js.map +1 -0
- package/build/legacy/suspense.cjs +48 -0
- package/build/legacy/suspense.cjs.map +1 -0
- package/build/legacy/suspense.d.cts +10 -0
- package/build/legacy/suspense.d.ts +10 -0
- package/build/legacy/suspense.js +20 -0
- package/build/legacy/suspense.js.map +1 -0
- package/build/legacy/types.cjs +19 -0
- package/build/legacy/types.cjs.map +1 -0
- package/build/legacy/types.d.cts +34 -0
- package/build/legacy/types.d.ts +34 -0
- package/build/legacy/types.js +1 -0
- package/build/legacy/types.js.map +1 -0
- package/build/legacy/useBaseQuery.cjs +92 -0
- package/build/legacy/useBaseQuery.cjs.map +1 -0
- package/build/legacy/useBaseQuery.d.cts +92 -0
- package/build/legacy/useBaseQuery.d.ts +92 -0
- package/build/legacy/useBaseQuery.js +62 -0
- package/build/legacy/useBaseQuery.js.map +1 -0
- package/build/legacy/useInfiniteQuery.cjs +41 -0
- package/build/legacy/useInfiniteQuery.cjs.map +1 -0
- package/build/legacy/useInfiniteQuery.d.cts +8 -0
- package/build/legacy/useInfiniteQuery.d.ts +8 -0
- package/build/legacy/useInfiniteQuery.js +17 -0
- package/build/legacy/useInfiniteQuery.js.map +1 -0
- package/build/legacy/useIsFetching.cjs +56 -0
- package/build/legacy/useIsFetching.cjs.map +1 -0
- package/build/legacy/useIsFetching.d.cts +5 -0
- package/build/legacy/useIsFetching.d.ts +5 -0
- package/build/legacy/useIsFetching.js +22 -0
- package/build/legacy/useIsFetching.js.map +1 -0
- package/build/legacy/useMutation.cjs +77 -0
- package/build/legacy/useMutation.cjs.map +1 -0
- package/build/legacy/useMutation.d.cts +6 -0
- package/build/legacy/useMutation.d.ts +6 -0
- package/build/legacy/useMutation.js +43 -0
- package/build/legacy/useMutation.js.map +1 -0
- package/build/legacy/useMutationState.cjs +88 -0
- package/build/legacy/useMutationState.cjs.map +1 -0
- package/build/legacy/useMutationState.d.cts +10 -0
- package/build/legacy/useMutationState.d.ts +10 -0
- package/build/legacy/useMutationState.js +53 -0
- package/build/legacy/useMutationState.js.map +1 -0
- package/build/legacy/useQueries.cjs +128 -0
- package/build/legacy/useQueries.cjs.map +1 -0
- package/build/legacy/useQueries.d.cts +53 -0
- package/build/{lib → legacy}/useQueries.d.ts +14 -11
- package/build/legacy/useQueries.js +103 -0
- package/build/legacy/useQueries.js.map +1 -0
- package/build/legacy/useQuery.cjs +36 -0
- package/build/legacy/useQuery.cjs.map +1 -0
- package/build/legacy/useQuery.d.cts +8 -0
- package/build/legacy/useQuery.d.ts +8 -0
- package/build/legacy/useQuery.js +12 -0
- package/build/legacy/useQuery.js.map +1 -0
- package/build/legacy/useSuspenseInfiniteQuery.cjs +46 -0
- package/build/legacy/useSuspenseInfiniteQuery.cjs.map +1 -0
- package/build/legacy/useSuspenseInfiniteQuery.d.cts +6 -0
- package/build/legacy/useSuspenseInfiniteQuery.d.ts +6 -0
- package/build/legacy/useSuspenseInfiniteQuery.js +22 -0
- package/build/legacy/useSuspenseInfiniteQuery.js.map +1 -0
- package/build/legacy/useSuspenseQuery.cjs +45 -0
- package/build/legacy/useSuspenseQuery.cjs.map +1 -0
- package/build/legacy/useSuspenseQuery.d.cts +6 -0
- package/build/legacy/useSuspenseQuery.d.ts +6 -0
- package/build/legacy/useSuspenseQuery.js +21 -0
- package/build/legacy/useSuspenseQuery.js.map +1 -0
- package/build/legacy/utils.cjs +36 -0
- package/build/legacy/utils.cjs.map +1 -0
- package/build/legacy/utils.d.cts +3 -0
- package/build/legacy/utils.d.ts +3 -0
- package/build/legacy/utils.js +11 -0
- package/build/legacy/utils.js.map +1 -0
- package/build/modern/HydrationBoundary.cjs +60 -0
- package/build/modern/HydrationBoundary.cjs.map +1 -0
- package/build/modern/HydrationBoundary.d.cts +12 -0
- package/build/modern/HydrationBoundary.d.ts +12 -0
- package/build/modern/HydrationBoundary.js +26 -0
- package/build/modern/HydrationBoundary.js.map +1 -0
- package/build/modern/QueryClientProvider.cjs +71 -0
- package/build/modern/QueryClientProvider.cjs.map +1 -0
- package/build/modern/QueryClientProvider.d.cts +12 -0
- package/build/modern/QueryClientProvider.d.ts +12 -0
- package/build/modern/QueryClientProvider.js +35 -0
- package/build/modern/QueryClientProvider.js.map +1 -0
- package/build/modern/QueryErrorResetBoundary.cjs +66 -0
- package/build/modern/QueryErrorResetBoundary.cjs.map +1 -0
- package/build/modern/QueryErrorResetBoundary.d.cts +14 -0
- package/build/modern/QueryErrorResetBoundary.d.ts +14 -0
- package/build/modern/QueryErrorResetBoundary.js +31 -0
- package/build/modern/QueryErrorResetBoundary.js.map +1 -0
- package/build/modern/errorBoundaryUtils.cjs +67 -0
- package/build/modern/errorBoundaryUtils.cjs.map +1 -0
- package/build/modern/errorBoundaryUtils.d.cts +14 -0
- package/build/modern/errorBoundaryUtils.d.ts +14 -0
- package/build/modern/errorBoundaryUtils.js +31 -0
- package/build/modern/errorBoundaryUtils.js.map +1 -0
- package/build/modern/index.cjs +85 -0
- package/build/modern/index.cjs.map +1 -0
- package/build/modern/index.d.cts +17 -0
- package/build/modern/index.d.ts +17 -0
- package/build/modern/index.js +46 -0
- package/build/modern/index.js.map +1 -0
- package/build/modern/infiniteQueryOptions.cjs +33 -0
- package/build/modern/infiniteQueryOptions.cjs.map +1 -0
- package/build/modern/infiniteQueryOptions.d.cts +13 -0
- package/build/modern/infiniteQueryOptions.d.ts +13 -0
- package/build/modern/infiniteQueryOptions.js +8 -0
- package/build/modern/infiniteQueryOptions.js.map +1 -0
- package/build/modern/isRestoring.cjs +47 -0
- package/build/modern/isRestoring.cjs.map +1 -0
- package/build/modern/isRestoring.d.cts +6 -0
- package/build/modern/isRestoring.d.ts +6 -0
- package/build/modern/isRestoring.js +12 -0
- package/build/modern/isRestoring.js.map +1 -0
- package/build/modern/queryOptions.cjs +33 -0
- package/build/modern/queryOptions.cjs.map +1 -0
- package/build/modern/queryOptions.d.cts +13 -0
- package/build/modern/queryOptions.d.ts +13 -0
- package/build/modern/queryOptions.js +8 -0
- package/build/modern/queryOptions.js.map +1 -0
- package/build/modern/suspense.cjs +48 -0
- package/build/modern/suspense.cjs.map +1 -0
- package/build/modern/suspense.d.cts +10 -0
- package/build/modern/suspense.d.ts +10 -0
- package/build/modern/suspense.js +20 -0
- package/build/modern/suspense.js.map +1 -0
- package/build/modern/types.cjs +19 -0
- package/build/modern/types.cjs.map +1 -0
- package/build/modern/types.d.cts +34 -0
- package/build/modern/types.d.ts +34 -0
- package/build/modern/types.js +1 -0
- package/build/modern/types.js.map +1 -0
- package/build/modern/useBaseQuery.cjs +92 -0
- package/build/modern/useBaseQuery.cjs.map +1 -0
- package/build/modern/useBaseQuery.d.cts +92 -0
- package/build/modern/useBaseQuery.d.ts +92 -0
- package/build/modern/useBaseQuery.js +62 -0
- package/build/modern/useBaseQuery.js.map +1 -0
- package/build/modern/useInfiniteQuery.cjs +41 -0
- package/build/modern/useInfiniteQuery.cjs.map +1 -0
- package/build/modern/useInfiniteQuery.d.cts +8 -0
- package/build/modern/useInfiniteQuery.d.ts +8 -0
- package/build/modern/useInfiniteQuery.js +17 -0
- package/build/modern/useInfiniteQuery.js.map +1 -0
- package/build/modern/useIsFetching.cjs +56 -0
- package/build/modern/useIsFetching.cjs.map +1 -0
- package/build/modern/useIsFetching.d.cts +5 -0
- package/build/modern/useIsFetching.d.ts +5 -0
- package/build/modern/useIsFetching.js +22 -0
- package/build/modern/useIsFetching.js.map +1 -0
- package/build/modern/useMutation.cjs +77 -0
- package/build/modern/useMutation.cjs.map +1 -0
- package/build/modern/useMutation.d.cts +6 -0
- package/build/modern/useMutation.d.ts +6 -0
- package/build/modern/useMutation.js +43 -0
- package/build/modern/useMutation.js.map +1 -0
- package/build/modern/useMutationState.cjs +88 -0
- package/build/modern/useMutationState.cjs.map +1 -0
- package/build/modern/useMutationState.d.cts +10 -0
- package/build/modern/useMutationState.d.ts +10 -0
- package/build/modern/useMutationState.js +53 -0
- package/build/modern/useMutationState.js.map +1 -0
- package/build/modern/useQueries.cjs +125 -0
- package/build/modern/useQueries.cjs.map +1 -0
- package/build/modern/useQueries.d.cts +53 -0
- package/build/modern/useQueries.d.ts +53 -0
- package/build/modern/useQueries.js +100 -0
- package/build/modern/useQueries.js.map +1 -0
- package/build/modern/useQuery.cjs +36 -0
- package/build/modern/useQuery.cjs.map +1 -0
- package/build/modern/useQuery.d.cts +8 -0
- package/build/modern/useQuery.d.ts +8 -0
- package/build/modern/useQuery.js +12 -0
- package/build/modern/useQuery.js.map +1 -0
- package/build/modern/useSuspenseInfiniteQuery.cjs +46 -0
- package/build/modern/useSuspenseInfiniteQuery.cjs.map +1 -0
- package/build/modern/useSuspenseInfiniteQuery.d.cts +6 -0
- package/build/modern/useSuspenseInfiniteQuery.d.ts +6 -0
- package/build/modern/useSuspenseInfiniteQuery.js +22 -0
- package/build/modern/useSuspenseInfiniteQuery.js.map +1 -0
- package/build/modern/useSuspenseQuery.cjs +45 -0
- package/build/modern/useSuspenseQuery.cjs.map +1 -0
- package/build/modern/useSuspenseQuery.d.cts +6 -0
- package/build/modern/useSuspenseQuery.d.ts +6 -0
- package/build/modern/useSuspenseQuery.js +21 -0
- package/build/modern/useSuspenseQuery.js.map +1 -0
- package/build/modern/utils.cjs +36 -0
- package/build/modern/utils.cjs.map +1 -0
- package/build/modern/utils.d.cts +3 -0
- package/build/modern/utils.d.ts +3 -0
- package/build/modern/utils.js +11 -0
- package/build/modern/utils.js.map +1 -0
- package/package.json +29 -17
- package/src/HydrationBoundary.tsx +1 -1
- package/src/__tests__/HydrationBoundary.test.tsx +5 -5
- package/src/__tests__/QueryClientProvider.test.tsx +2 -2
- package/src/__tests__/QueryResetErrorBoundary.test.tsx +753 -621
- package/src/__tests__/ssr-hydration.test.tsx +4 -4
- package/src/__tests__/ssr.test.tsx +2 -2
- package/src/__tests__/suspense.test.tsx +8 -90
- package/src/__tests__/useInfiniteQuery.test.tsx +36 -74
- package/src/__tests__/useInfiniteQuery.type.test.tsx +2 -29
- package/src/__tests__/useIsFetching.test.tsx +1 -1
- package/src/__tests__/useMutation.test.tsx +22 -23
- package/src/__tests__/useMutationState.test.tsx +23 -0
- package/src/__tests__/useQueries.test.tsx +214 -91
- package/src/__tests__/useQuery.test.tsx +691 -551
- package/src/__tests__/useQuery.types.test.tsx +22 -1
- package/src/__tests__/utils.tsx +11 -5
- package/src/errorBoundaryUtils.ts +7 -7
- package/src/index.ts +4 -0
- package/src/infiniteQueryOptions.ts +93 -0
- package/src/queryOptions.ts +42 -0
- package/src/suspense.ts +9 -15
- package/src/types.ts +50 -8
- package/src/useBaseQuery.ts +14 -26
- package/src/useInfiniteQuery.ts +50 -7
- package/src/useIsFetching.ts +1 -1
- package/src/useMutation.ts +4 -4
- package/src/useMutationState.ts +8 -8
- package/src/useQueries.ts +53 -36
- package/src/useQuery.ts +6 -21
- package/src/useSuspenseInfiniteQuery.ts +47 -0
- package/src/useSuspenseQuery.ts +26 -0
- package/build/lib/HydrationBoundary.d.ts +0 -9
- package/build/lib/HydrationBoundary.esm.js +0 -29
- package/build/lib/HydrationBoundary.esm.js.map +0 -1
- package/build/lib/HydrationBoundary.js +0 -50
- package/build/lib/HydrationBoundary.js.map +0 -1
- package/build/lib/HydrationBoundary.mjs +0 -29
- package/build/lib/HydrationBoundary.mjs.map +0 -1
- package/build/lib/QueryClientProvider.d.ts +0 -9
- package/build/lib/QueryClientProvider.esm.js +0 -31
- package/build/lib/QueryClientProvider.esm.js.map +0 -1
- package/build/lib/QueryClientProvider.js +0 -54
- package/build/lib/QueryClientProvider.js.map +0 -1
- package/build/lib/QueryClientProvider.mjs +0 -31
- package/build/lib/QueryClientProvider.mjs.map +0 -1
- package/build/lib/QueryErrorResetBoundary.d.ts +0 -11
- package/build/lib/QueryErrorResetBoundary.esm.js +0 -38
- package/build/lib/QueryErrorResetBoundary.esm.js.map +0 -1
- package/build/lib/QueryErrorResetBoundary.js +0 -60
- package/build/lib/QueryErrorResetBoundary.js.map +0 -1
- package/build/lib/QueryErrorResetBoundary.mjs +0 -38
- package/build/lib/QueryErrorResetBoundary.mjs.map +0 -1
- package/build/lib/__tests__/HydrationBoundary.test.d.ts +0 -1
- package/build/lib/__tests__/QueryClientProvider.test.d.ts +0 -1
- package/build/lib/__tests__/QueryResetErrorBoundary.test.d.ts +0 -6
- package/build/lib/__tests__/ssr-hydration.test.d.ts +0 -1
- package/build/lib/__tests__/ssr.test.d.ts +0 -1
- package/build/lib/__tests__/suspense.test.d.ts +0 -1
- package/build/lib/__tests__/useInfiniteQuery.test.d.ts +0 -1
- package/build/lib/__tests__/useInfiniteQuery.type.test.d.ts +0 -1
- package/build/lib/__tests__/useIsFetching.test.d.ts +0 -1
- package/build/lib/__tests__/useMutation.test.d.ts +0 -1
- package/build/lib/__tests__/useMutationState.test.d.ts +0 -1
- package/build/lib/__tests__/useQueries.test.d.ts +0 -1
- package/build/lib/__tests__/useQuery.test.d.ts +0 -1
- package/build/lib/__tests__/useQuery.types.test.d.ts +0 -1
- package/build/lib/__tests__/utils.d.ts +0 -28
- package/build/lib/errorBoundaryUtils.d.ts +0 -10
- package/build/lib/errorBoundaryUtils.esm.js +0 -28
- package/build/lib/errorBoundaryUtils.esm.js.map +0 -1
- package/build/lib/errorBoundaryUtils.js +0 -51
- package/build/lib/errorBoundaryUtils.js.map +0 -1
- package/build/lib/errorBoundaryUtils.mjs +0 -28
- package/build/lib/errorBoundaryUtils.mjs.map +0 -1
- package/build/lib/index.d.ts +0 -16
- package/build/lib/index.esm.js +0 -12
- package/build/lib/index.esm.js.map +0 -1
- package/build/lib/index.js +0 -38
- package/build/lib/index.js.map +0 -1
- package/build/lib/index.mjs +0 -12
- package/build/lib/index.mjs.map +0 -1
- package/build/lib/isRestoring.d.ts +0 -3
- package/build/lib/isRestoring.esm.js +0 -9
- package/build/lib/isRestoring.esm.js.map +0 -1
- package/build/lib/isRestoring.js +0 -31
- package/build/lib/isRestoring.js.map +0 -1
- package/build/lib/isRestoring.mjs +0 -9
- package/build/lib/isRestoring.mjs.map +0 -1
- package/build/lib/suspense.d.ts +0 -9
- package/build/lib/suspense.esm.js +0 -24
- package/build/lib/suspense.esm.js.map +0 -1
- package/build/lib/suspense.js +0 -29
- package/build/lib/suspense.js.map +0 -1
- package/build/lib/suspense.mjs +0 -24
- package/build/lib/suspense.mjs.map +0 -1
- package/build/lib/types.d.ts +0 -26
- package/build/lib/useBaseQuery.d.ts +0 -3
- package/build/lib/useBaseQuery.esm.js +0 -63
- package/build/lib/useBaseQuery.esm.js.map +0 -1
- package/build/lib/useBaseQuery.js +0 -84
- package/build/lib/useBaseQuery.js.map +0 -1
- package/build/lib/useBaseQuery.mjs +0 -63
- package/build/lib/useBaseQuery.mjs.map +0 -1
- package/build/lib/useInfiniteQuery.d.ts +0 -3
- package/build/lib/useInfiniteQuery.esm.js +0 -13
- package/build/lib/useInfiniteQuery.esm.js.map +0 -1
- package/build/lib/useInfiniteQuery.js +0 -15
- package/build/lib/useInfiniteQuery.js.map +0 -1
- package/build/lib/useInfiniteQuery.mjs +0 -13
- package/build/lib/useInfiniteQuery.mjs.map +0 -1
- package/build/lib/useIsFetching.d.ts +0 -2
- package/build/lib/useIsFetching.esm.js +0 -13
- package/build/lib/useIsFetching.esm.js.map +0 -1
- package/build/lib/useIsFetching.js +0 -34
- package/build/lib/useIsFetching.js.map +0 -1
- package/build/lib/useIsFetching.mjs +0 -13
- package/build/lib/useIsFetching.mjs.map +0 -1
- package/build/lib/useMutation.d.ts +0 -3
- package/build/lib/useMutation.esm.js +0 -33
- package/build/lib/useMutation.esm.js.map +0 -1
- package/build/lib/useMutation.js +0 -54
- package/build/lib/useMutation.js.map +0 -1
- package/build/lib/useMutation.mjs +0 -33
- package/build/lib/useMutation.mjs.map +0 -1
- package/build/lib/useMutationState.d.ts +0 -8
- package/build/lib/useMutationState.esm.js +0 -38
- package/build/lib/useMutationState.esm.js.map +0 -1
- package/build/lib/useMutationState.js +0 -60
- package/build/lib/useMutationState.js.map +0 -1
- package/build/lib/useMutationState.mjs +0 -38
- package/build/lib/useMutationState.mjs.map +0 -1
- package/build/lib/useQueries.esm.js +0 -73
- package/build/lib/useQueries.esm.js.map +0 -1
- package/build/lib/useQueries.js +0 -94
- package/build/lib/useQueries.js.map +0 -1
- package/build/lib/useQueries.mjs +0 -70
- package/build/lib/useQueries.mjs.map +0 -1
- package/build/lib/useQuery.d.ts +0 -11
- package/build/lib/useQuery.esm.js +0 -12
- package/build/lib/useQuery.esm.js.map +0 -1
- package/build/lib/useQuery.js +0 -14
- package/build/lib/useQuery.js.map +0 -1
- package/build/lib/useQuery.mjs +0 -12
- package/build/lib/useQuery.mjs.map +0 -1
- package/build/lib/utils.d.ts +0 -1
- package/build/lib/utils.esm.js +0 -10
- package/build/lib/utils.esm.js.map +0 -1
- package/build/lib/utils.js +0 -12
- package/build/lib/utils.js.map +0 -1
- package/build/lib/utils.mjs +0 -10
- package/build/lib/utils.mjs.map +0 -1
- package/build/umd/index.development.js +0 -3040
- package/build/umd/index.development.js.map +0 -1
- package/build/umd/index.production.js +0 -2
- package/build/umd/index.production.js.map +0 -1
- /package/src/{isRestoring.tsx → isRestoring.ts} +0 -0
package/src/useQueries.ts
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import * as React from 'react'
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
QueryKey,
|
|
6
|
-
QueryFunction,
|
|
7
|
-
QueriesPlaceholderDataFunction,
|
|
8
|
-
QueryClient,
|
|
9
|
-
DefaultError,
|
|
10
|
-
} from '@tanstack/query-core'
|
|
11
|
-
import { notifyManager, QueriesObserver } from '@tanstack/query-core'
|
|
4
|
+
import { QueriesObserver, notifyManager } from '@tanstack/query-core'
|
|
12
5
|
import { useQueryClient } from './QueryClientProvider'
|
|
13
|
-
import type { UseQueryOptions, UseQueryResult } from './types'
|
|
14
6
|
import { useIsRestoring } from './isRestoring'
|
|
15
7
|
import { useQueryErrorResetBoundary } from './QueryErrorResetBoundary'
|
|
16
8
|
import {
|
|
@@ -20,10 +12,19 @@ import {
|
|
|
20
12
|
} from './errorBoundaryUtils'
|
|
21
13
|
import {
|
|
22
14
|
ensureStaleTime,
|
|
23
|
-
shouldSuspend,
|
|
24
15
|
fetchOptimistic,
|
|
16
|
+
shouldSuspend,
|
|
25
17
|
willFetch,
|
|
26
18
|
} from './suspense'
|
|
19
|
+
import type { UseQueryOptions, UseQueryResult } from './types'
|
|
20
|
+
import type {
|
|
21
|
+
DefaultError,
|
|
22
|
+
QueriesObserverOptions,
|
|
23
|
+
QueriesPlaceholderDataFunction,
|
|
24
|
+
QueryClient,
|
|
25
|
+
QueryFunction,
|
|
26
|
+
QueryKey,
|
|
27
|
+
} from '@tanstack/query-core'
|
|
27
28
|
|
|
28
29
|
// This defines the `UseQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.
|
|
29
30
|
// `placeholderData` function does not have a parameter
|
|
@@ -156,21 +157,27 @@ export type QueriesResults<
|
|
|
156
157
|
: // Fallback
|
|
157
158
|
UseQueryResult[]
|
|
158
159
|
|
|
159
|
-
export function useQueries<
|
|
160
|
+
export function useQueries<
|
|
161
|
+
T extends any[],
|
|
162
|
+
TCombinedResult = QueriesResults<T>,
|
|
163
|
+
>(
|
|
160
164
|
{
|
|
161
165
|
queries,
|
|
166
|
+
...options
|
|
162
167
|
}: {
|
|
163
168
|
queries: readonly [...QueriesOptions<T>]
|
|
169
|
+
combine?: (result: QueriesResults<T>) => TCombinedResult
|
|
164
170
|
},
|
|
165
171
|
queryClient?: QueryClient,
|
|
166
|
-
):
|
|
172
|
+
): TCombinedResult {
|
|
167
173
|
const client = useQueryClient(queryClient)
|
|
168
174
|
const isRestoring = useIsRestoring()
|
|
175
|
+
const errorResetBoundary = useQueryErrorResetBoundary()
|
|
169
176
|
|
|
170
177
|
const defaultedQueries = React.useMemo(
|
|
171
178
|
() =>
|
|
172
|
-
queries.map((
|
|
173
|
-
const defaultedOptions = client.defaultQueryOptions(
|
|
179
|
+
queries.map((opts) => {
|
|
180
|
+
const defaultedOptions = client.defaultQueryOptions(opts)
|
|
174
181
|
|
|
175
182
|
// Make sure the results are already in fetching state before subscribing or updating options
|
|
176
183
|
defaultedOptions._optimisticResults = isRestoring
|
|
@@ -182,11 +189,24 @@ export function useQueries<T extends any[]>(
|
|
|
182
189
|
[queries, client, isRestoring],
|
|
183
190
|
)
|
|
184
191
|
|
|
192
|
+
defaultedQueries.forEach((query) => {
|
|
193
|
+
ensureStaleTime(query)
|
|
194
|
+
ensurePreventErrorBoundaryRetry(query, errorResetBoundary)
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
useClearResetErrorBoundary(errorResetBoundary)
|
|
198
|
+
|
|
185
199
|
const [observer] = React.useState(
|
|
186
|
-
() =>
|
|
200
|
+
() =>
|
|
201
|
+
new QueriesObserver<TCombinedResult>(
|
|
202
|
+
client,
|
|
203
|
+
defaultedQueries,
|
|
204
|
+
options as QueriesObserverOptions<TCombinedResult>,
|
|
205
|
+
),
|
|
187
206
|
)
|
|
188
207
|
|
|
189
|
-
const optimisticResult =
|
|
208
|
+
const [optimisticResult, getCombinedResult, trackResult] =
|
|
209
|
+
observer.getOptimisticResult(defaultedQueries)
|
|
190
210
|
|
|
191
211
|
React.useSyncExternalStore(
|
|
192
212
|
React.useCallback(
|
|
@@ -203,17 +223,14 @@ export function useQueries<T extends any[]>(
|
|
|
203
223
|
React.useEffect(() => {
|
|
204
224
|
// Do not notify on updates because of changes in the options because
|
|
205
225
|
// these changes should already be reflected in the optimistic result.
|
|
206
|
-
observer.setQueries(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
})
|
|
215
|
-
|
|
216
|
-
useClearResetErrorBoundary(errorResetBoundary)
|
|
226
|
+
observer.setQueries(
|
|
227
|
+
defaultedQueries,
|
|
228
|
+
options as QueriesObserverOptions<TCombinedResult>,
|
|
229
|
+
{
|
|
230
|
+
listeners: false,
|
|
231
|
+
},
|
|
232
|
+
)
|
|
233
|
+
}, [defaultedQueries, options, observer])
|
|
217
234
|
|
|
218
235
|
const shouldAtLeastOneSuspend = optimisticResult.some((result, index) =>
|
|
219
236
|
shouldSuspend(defaultedQueries[index], result, isRestoring),
|
|
@@ -221,14 +238,14 @@ export function useQueries<T extends any[]>(
|
|
|
221
238
|
|
|
222
239
|
const suspensePromises = shouldAtLeastOneSuspend
|
|
223
240
|
? optimisticResult.flatMap((result, index) => {
|
|
224
|
-
const
|
|
241
|
+
const opts = defaultedQueries[index]
|
|
225
242
|
const queryObserver = observer.getObservers()[index]
|
|
226
243
|
|
|
227
|
-
if (
|
|
228
|
-
if (shouldSuspend(
|
|
229
|
-
return fetchOptimistic(
|
|
244
|
+
if (opts && queryObserver) {
|
|
245
|
+
if (shouldSuspend(opts, result, isRestoring)) {
|
|
246
|
+
return fetchOptimistic(opts, queryObserver, errorResetBoundary)
|
|
230
247
|
} else if (willFetch(result, isRestoring)) {
|
|
231
|
-
void fetchOptimistic(
|
|
248
|
+
void fetchOptimistic(opts, queryObserver, errorResetBoundary)
|
|
232
249
|
}
|
|
233
250
|
}
|
|
234
251
|
return []
|
|
@@ -238,14 +255,14 @@ export function useQueries<T extends any[]>(
|
|
|
238
255
|
if (suspensePromises.length > 0) {
|
|
239
256
|
throw Promise.all(suspensePromises)
|
|
240
257
|
}
|
|
241
|
-
|
|
258
|
+
const observerQueries = observer.getQueries()
|
|
242
259
|
const firstSingleResultWhichShouldThrow = optimisticResult.find(
|
|
243
260
|
(result, index) =>
|
|
244
261
|
getHasError({
|
|
245
262
|
result,
|
|
246
263
|
errorResetBoundary,
|
|
247
|
-
|
|
248
|
-
query:
|
|
264
|
+
throwOnError: defaultedQueries[index]?.throwOnError ?? false,
|
|
265
|
+
query: observerQueries[index]!,
|
|
249
266
|
}),
|
|
250
267
|
)
|
|
251
268
|
|
|
@@ -253,5 +270,5 @@ export function useQueries<T extends any[]>(
|
|
|
253
270
|
throw firstSingleResultWhichShouldThrow.error
|
|
254
271
|
}
|
|
255
272
|
|
|
256
|
-
return
|
|
273
|
+
return getCombinedResult(trackResult())
|
|
257
274
|
}
|
package/src/useQuery.ts
CHANGED
|
@@ -1,31 +1,16 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import type { QueryClient, QueryKey, DefaultError } from '@tanstack/query-core'
|
|
3
2
|
import { QueryObserver } from '@tanstack/query-core'
|
|
3
|
+
import { useBaseQuery } from './useBaseQuery'
|
|
4
|
+
import type { DefaultError, QueryClient, QueryKey } from '@tanstack/query-core'
|
|
4
5
|
import type {
|
|
5
6
|
DefinedUseQueryResult,
|
|
6
7
|
UseQueryOptions,
|
|
7
8
|
UseQueryResult,
|
|
8
9
|
} from './types'
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
TQueryFnData = unknown,
|
|
14
|
-
TError = DefaultError,
|
|
15
|
-
TData = TQueryFnData,
|
|
16
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
17
|
-
> = UseQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
18
|
-
initialData?: undefined
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
type DefinedInitialDataOptions<
|
|
22
|
-
TQueryFnData = unknown,
|
|
23
|
-
TError = DefaultError,
|
|
24
|
-
TData = TQueryFnData,
|
|
25
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
26
|
-
> = UseQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
27
|
-
initialData: TQueryFnData | (() => TQueryFnData)
|
|
28
|
-
}
|
|
10
|
+
import type {
|
|
11
|
+
DefinedInitialDataOptions,
|
|
12
|
+
UndefinedInitialDataOptions,
|
|
13
|
+
} from './queryOptions'
|
|
29
14
|
|
|
30
15
|
export function useQuery<
|
|
31
16
|
TQueryFnData = unknown,
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { InfiniteQueryObserver } from '@tanstack/query-core'
|
|
3
|
+
import { useBaseQuery } from './useBaseQuery'
|
|
4
|
+
import type {
|
|
5
|
+
InfiniteQueryObserverSuccessResult,
|
|
6
|
+
QueryObserver,
|
|
7
|
+
} from '@tanstack/query-core'
|
|
8
|
+
import type {
|
|
9
|
+
DefaultError,
|
|
10
|
+
InfiniteData,
|
|
11
|
+
QueryClient,
|
|
12
|
+
QueryKey,
|
|
13
|
+
} from '@tanstack/query-core'
|
|
14
|
+
import type {
|
|
15
|
+
UseSuspenseInfiniteQueryOptions,
|
|
16
|
+
UseSuspenseInfiniteQueryResult,
|
|
17
|
+
} from './types'
|
|
18
|
+
|
|
19
|
+
export function useSuspenseInfiniteQuery<
|
|
20
|
+
TQueryFnData,
|
|
21
|
+
TError = DefaultError,
|
|
22
|
+
TData = InfiniteData<TQueryFnData>,
|
|
23
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
24
|
+
TPageParam = unknown,
|
|
25
|
+
>(
|
|
26
|
+
options: UseSuspenseInfiniteQueryOptions<
|
|
27
|
+
TQueryFnData,
|
|
28
|
+
TError,
|
|
29
|
+
TData,
|
|
30
|
+
TQueryFnData,
|
|
31
|
+
TQueryKey,
|
|
32
|
+
TPageParam
|
|
33
|
+
>,
|
|
34
|
+
queryClient?: QueryClient,
|
|
35
|
+
): UseSuspenseInfiniteQueryResult<TData, TError> {
|
|
36
|
+
return useBaseQuery(
|
|
37
|
+
{
|
|
38
|
+
...options,
|
|
39
|
+
enabled: true,
|
|
40
|
+
suspense: true,
|
|
41
|
+
throwOnError: true,
|
|
42
|
+
},
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
44
|
+
InfiniteQueryObserver as typeof QueryObserver,
|
|
45
|
+
queryClient,
|
|
46
|
+
) as InfiniteQueryObserverSuccessResult<TData, TError>
|
|
47
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { QueryObserver } from '@tanstack/query-core'
|
|
3
|
+
import { useBaseQuery } from './useBaseQuery'
|
|
4
|
+
import type { UseSuspenseQueryOptions, UseSuspenseQueryResult } from './types'
|
|
5
|
+
import type { DefaultError, QueryClient, QueryKey } from '@tanstack/query-core'
|
|
6
|
+
|
|
7
|
+
export function useSuspenseQuery<
|
|
8
|
+
TQueryFnData = unknown,
|
|
9
|
+
TError = DefaultError,
|
|
10
|
+
TData = TQueryFnData,
|
|
11
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
12
|
+
>(
|
|
13
|
+
options: UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
14
|
+
queryClient?: QueryClient,
|
|
15
|
+
): UseSuspenseQueryResult<TData, TError> {
|
|
16
|
+
return useBaseQuery(
|
|
17
|
+
{
|
|
18
|
+
...options,
|
|
19
|
+
enabled: true,
|
|
20
|
+
suspense: true,
|
|
21
|
+
throwOnError: true,
|
|
22
|
+
},
|
|
23
|
+
QueryObserver,
|
|
24
|
+
queryClient,
|
|
25
|
+
) as UseSuspenseQueryResult<TData, TError>
|
|
26
|
+
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { HydrateOptions, QueryClient } from '@tanstack/query-core';
|
|
3
|
-
export interface HydrationBoundaryProps {
|
|
4
|
-
state?: unknown;
|
|
5
|
-
options?: HydrateOptions;
|
|
6
|
-
children?: React.ReactNode;
|
|
7
|
-
queryClient?: QueryClient;
|
|
8
|
-
}
|
|
9
|
-
export declare const HydrationBoundary: ({ children, options, state, queryClient, }: HydrationBoundaryProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { hydrate } from '@tanstack/query-core';
|
|
4
|
-
import { useQueryClient } from './QueryClientProvider.esm.js';
|
|
5
|
-
|
|
6
|
-
const HydrationBoundary = ({
|
|
7
|
-
children,
|
|
8
|
-
options = {},
|
|
9
|
-
state,
|
|
10
|
-
queryClient
|
|
11
|
-
}) => {
|
|
12
|
-
const client = useQueryClient(queryClient);
|
|
13
|
-
const optionsRef = React.useRef(options);
|
|
14
|
-
optionsRef.current = options;
|
|
15
|
-
|
|
16
|
-
// Running hydrate again with the same queries is safe,
|
|
17
|
-
// it wont overwrite or initialize existing queries,
|
|
18
|
-
// relying on useMemo here is only a performance optimization.
|
|
19
|
-
// hydrate can and should be run *during* render here for SSR to work properly
|
|
20
|
-
React.useMemo(() => {
|
|
21
|
-
if (state) {
|
|
22
|
-
hydrate(client, state, optionsRef.current);
|
|
23
|
-
}
|
|
24
|
-
}, [client, state]);
|
|
25
|
-
return children;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export { HydrationBoundary };
|
|
29
|
-
//# sourceMappingURL=HydrationBoundary.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HydrationBoundary.esm.js","sources":["../../src/HydrationBoundary.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { HydrateOptions, QueryClient } from '@tanstack/query-core'\nimport { hydrate } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\n\nexport interface HydrationBoundaryProps {\n state?: unknown\n options?: HydrateOptions\n children?: React.ReactNode\n queryClient?: QueryClient\n}\n\nexport const HydrationBoundary = ({\n children,\n options = {},\n state,\n queryClient,\n}: HydrationBoundaryProps) => {\n const client = useQueryClient(queryClient)\n\n const optionsRef = React.useRef(options)\n optionsRef.current = options\n\n // Running hydrate again with the same queries is safe,\n // it wont overwrite or initialize existing queries,\n // relying on useMemo here is only a performance optimization.\n // hydrate can and should be run *during* render here for SSR to work properly\n React.useMemo(() => {\n if (state) {\n hydrate(client, state, optionsRef.current)\n }\n }, [client, state])\n\n return children as React.ReactElement\n}\n"],"names":["queryClient"],"mappings":";;;;;AAcO;;;;AAILA;AACsB;AACtB;AAEA;;;AAGA;AACA;AACA;AACA;;AAEE;;AAEA;AACF;AAEA;AACF;;"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var React = require('react');
|
|
5
|
-
var queryCore = require('@tanstack/query-core');
|
|
6
|
-
var QueryClientProvider = require('./QueryClientProvider.js');
|
|
7
|
-
|
|
8
|
-
function _interopNamespaceDefault(e) {
|
|
9
|
-
var n = Object.create(null);
|
|
10
|
-
if (e) {
|
|
11
|
-
Object.keys(e).forEach(function (k) {
|
|
12
|
-
if (k !== 'default') {
|
|
13
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () { return e[k]; }
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
n.default = e;
|
|
22
|
-
return Object.freeze(n);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
26
|
-
|
|
27
|
-
const HydrationBoundary = ({
|
|
28
|
-
children,
|
|
29
|
-
options = {},
|
|
30
|
-
state,
|
|
31
|
-
queryClient
|
|
32
|
-
}) => {
|
|
33
|
-
const client = QueryClientProvider.useQueryClient(queryClient);
|
|
34
|
-
const optionsRef = React__namespace.useRef(options);
|
|
35
|
-
optionsRef.current = options;
|
|
36
|
-
|
|
37
|
-
// Running hydrate again with the same queries is safe,
|
|
38
|
-
// it wont overwrite or initialize existing queries,
|
|
39
|
-
// relying on useMemo here is only a performance optimization.
|
|
40
|
-
// hydrate can and should be run *during* render here for SSR to work properly
|
|
41
|
-
React__namespace.useMemo(() => {
|
|
42
|
-
if (state) {
|
|
43
|
-
queryCore.hydrate(client, state, optionsRef.current);
|
|
44
|
-
}
|
|
45
|
-
}, [client, state]);
|
|
46
|
-
return children;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
exports.HydrationBoundary = HydrationBoundary;
|
|
50
|
-
//# sourceMappingURL=HydrationBoundary.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HydrationBoundary.js","sources":["../../src/HydrationBoundary.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { HydrateOptions, QueryClient } from '@tanstack/query-core'\nimport { hydrate } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\n\nexport interface HydrationBoundaryProps {\n state?: unknown\n options?: HydrateOptions\n children?: React.ReactNode\n queryClient?: QueryClient\n}\n\nexport const HydrationBoundary = ({\n children,\n options = {},\n state,\n queryClient,\n}: HydrationBoundaryProps) => {\n const client = useQueryClient(queryClient)\n\n const optionsRef = React.useRef(options)\n optionsRef.current = options\n\n // Running hydrate again with the same queries is safe,\n // it wont overwrite or initialize existing queries,\n // relying on useMemo here is only a performance optimization.\n // hydrate can and should be run *during* render here for SSR to work properly\n React.useMemo(() => {\n if (state) {\n hydrate(client, state, optionsRef.current)\n }\n }, [client, state])\n\n return children as React.ReactElement\n}\n"],"names":["queryClient"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAcO;;;;AAILA;AACsB;AACtB;AAEA;;;AAGA;AACA;AACA;AACA;;AAEE;;AAEA;AACF;AAEA;AACF;;"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { hydrate } from '@tanstack/query-core';
|
|
4
|
-
import { useQueryClient } from './QueryClientProvider.mjs';
|
|
5
|
-
|
|
6
|
-
const HydrationBoundary = ({
|
|
7
|
-
children,
|
|
8
|
-
options = {},
|
|
9
|
-
state,
|
|
10
|
-
queryClient
|
|
11
|
-
}) => {
|
|
12
|
-
const client = useQueryClient(queryClient);
|
|
13
|
-
const optionsRef = React.useRef(options);
|
|
14
|
-
optionsRef.current = options;
|
|
15
|
-
|
|
16
|
-
// Running hydrate again with the same queries is safe,
|
|
17
|
-
// it wont overwrite or initialize existing queries,
|
|
18
|
-
// relying on useMemo here is only a performance optimization.
|
|
19
|
-
// hydrate can and should be run *during* render here for SSR to work properly
|
|
20
|
-
React.useMemo(() => {
|
|
21
|
-
if (state) {
|
|
22
|
-
hydrate(client, state, optionsRef.current);
|
|
23
|
-
}
|
|
24
|
-
}, [client, state]);
|
|
25
|
-
return children;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export { HydrationBoundary };
|
|
29
|
-
//# sourceMappingURL=HydrationBoundary.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HydrationBoundary.mjs","sources":["../../src/HydrationBoundary.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { HydrateOptions, QueryClient } from '@tanstack/query-core'\nimport { hydrate } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\n\nexport interface HydrationBoundaryProps {\n state?: unknown\n options?: HydrateOptions\n children?: React.ReactNode\n queryClient?: QueryClient\n}\n\nexport const HydrationBoundary = ({\n children,\n options = {},\n state,\n queryClient,\n}: HydrationBoundaryProps) => {\n const client = useQueryClient(queryClient)\n\n const optionsRef = React.useRef(options)\n optionsRef.current = options\n\n // Running hydrate again with the same queries is safe,\n // it wont overwrite or initialize existing queries,\n // relying on useMemo here is only a performance optimization.\n // hydrate can and should be run *during* render here for SSR to work properly\n React.useMemo(() => {\n if (state) {\n hydrate(client, state, optionsRef.current)\n }\n }, [client, state])\n\n return children as React.ReactElement\n}\n"],"names":["queryClient"],"mappings":";;;;;AAcO;;;;AAILA;AACsB;AACtB;AAEA;;;AAGA;AACA;AACA;AACA;;AAEE;;AAEA;AACF;AAEA;AACF;;"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { QueryClient } from '@tanstack/query-core';
|
|
3
|
-
export declare const QueryClientContext: React.Context<QueryClient | undefined>;
|
|
4
|
-
export declare const useQueryClient: (queryClient?: QueryClient) => QueryClient;
|
|
5
|
-
export declare type QueryClientProviderProps = {
|
|
6
|
-
client: QueryClient;
|
|
7
|
-
children?: React.ReactNode;
|
|
8
|
-
};
|
|
9
|
-
export declare const QueryClientProvider: ({ client, children, }: QueryClientProviderProps) => JSX.Element;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
|
|
4
|
-
const QueryClientContext = /*#__PURE__*/React.createContext(undefined);
|
|
5
|
-
const useQueryClient = queryClient => {
|
|
6
|
-
const client = React.useContext(QueryClientContext);
|
|
7
|
-
if (queryClient) {
|
|
8
|
-
return queryClient;
|
|
9
|
-
}
|
|
10
|
-
if (!client) {
|
|
11
|
-
throw new Error('No QueryClient set, use QueryClientProvider to set one');
|
|
12
|
-
}
|
|
13
|
-
return client;
|
|
14
|
-
};
|
|
15
|
-
const QueryClientProvider = ({
|
|
16
|
-
client,
|
|
17
|
-
children
|
|
18
|
-
}) => {
|
|
19
|
-
React.useEffect(() => {
|
|
20
|
-
client.mount();
|
|
21
|
-
return () => {
|
|
22
|
-
client.unmount();
|
|
23
|
-
};
|
|
24
|
-
}, [client]);
|
|
25
|
-
return /*#__PURE__*/React.createElement(QueryClientContext.Provider, {
|
|
26
|
-
value: client
|
|
27
|
-
}, children);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export { QueryClientContext, QueryClientProvider, useQueryClient };
|
|
31
|
-
//# sourceMappingURL=QueryClientProvider.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QueryClientProvider.esm.js","sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\n\nexport const QueryClientContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\n\nexport const useQueryClient = (queryClient?: QueryClient) => {\n const client = React.useContext(QueryClientContext)\n\n if (queryClient) {\n return queryClient\n }\n\n if (!client) {\n throw new Error('No QueryClient set, use QueryClientProvider to set one')\n }\n\n return client\n}\n\nexport type QueryClientProviderProps = {\n client: QueryClient\n children?: React.ReactNode\n}\n\nexport const QueryClientProvider = ({\n client,\n children,\n}: QueryClientProviderProps): JSX.Element => {\n React.useEffect(() => {\n client.mount()\n return () => {\n client.unmount()\n }\n }, [client])\n\n return (\n <QueryClientContext.Provider value={client}>\n {children}\n </QueryClientContext.Provider>\n )\n}\n"],"names":["useQueryClient","children"],"mappings":";;;AAKO;AAIMA;AACX;AAEA;AACE;AACF;;AAGE;AACF;AAEA;AACF;AAOO;;AAELC;AACwB;;;AAGtB;;;AAGF;;AAG+B;AAAc;AAI/C;;"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var React = require('react');
|
|
5
|
-
|
|
6
|
-
function _interopNamespaceDefault(e) {
|
|
7
|
-
var n = Object.create(null);
|
|
8
|
-
if (e) {
|
|
9
|
-
Object.keys(e).forEach(function (k) {
|
|
10
|
-
if (k !== 'default') {
|
|
11
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () { return e[k]; }
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
n.default = e;
|
|
20
|
-
return Object.freeze(n);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
24
|
-
|
|
25
|
-
const QueryClientContext = /*#__PURE__*/React__namespace.createContext(undefined);
|
|
26
|
-
const useQueryClient = queryClient => {
|
|
27
|
-
const client = React__namespace.useContext(QueryClientContext);
|
|
28
|
-
if (queryClient) {
|
|
29
|
-
return queryClient;
|
|
30
|
-
}
|
|
31
|
-
if (!client) {
|
|
32
|
-
throw new Error('No QueryClient set, use QueryClientProvider to set one');
|
|
33
|
-
}
|
|
34
|
-
return client;
|
|
35
|
-
};
|
|
36
|
-
const QueryClientProvider = ({
|
|
37
|
-
client,
|
|
38
|
-
children
|
|
39
|
-
}) => {
|
|
40
|
-
React__namespace.useEffect(() => {
|
|
41
|
-
client.mount();
|
|
42
|
-
return () => {
|
|
43
|
-
client.unmount();
|
|
44
|
-
};
|
|
45
|
-
}, [client]);
|
|
46
|
-
return /*#__PURE__*/React__namespace.createElement(QueryClientContext.Provider, {
|
|
47
|
-
value: client
|
|
48
|
-
}, children);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
exports.QueryClientContext = QueryClientContext;
|
|
52
|
-
exports.QueryClientProvider = QueryClientProvider;
|
|
53
|
-
exports.useQueryClient = useQueryClient;
|
|
54
|
-
//# sourceMappingURL=QueryClientProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QueryClientProvider.js","sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\n\nexport const QueryClientContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\n\nexport const useQueryClient = (queryClient?: QueryClient) => {\n const client = React.useContext(QueryClientContext)\n\n if (queryClient) {\n return queryClient\n }\n\n if (!client) {\n throw new Error('No QueryClient set, use QueryClientProvider to set one')\n }\n\n return client\n}\n\nexport type QueryClientProviderProps = {\n client: QueryClient\n children?: React.ReactNode\n}\n\nexport const QueryClientProvider = ({\n client,\n children,\n}: QueryClientProviderProps): JSX.Element => {\n React.useEffect(() => {\n client.mount()\n return () => {\n client.unmount()\n }\n }, [client])\n\n return (\n <QueryClientContext.Provider value={client}>\n {children}\n </QueryClientContext.Provider>\n )\n}\n"],"names":["useQueryClient","children"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKO;AAIMA;AACX;AAEA;AACE;AACF;;AAGE;AACF;AAEA;AACF;AAOO;;AAELC;AACwB;;;AAGtB;;;AAGF;;AAG+B;AAAc;AAI/C;;;;"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
|
|
4
|
-
const QueryClientContext = /*#__PURE__*/React.createContext(undefined);
|
|
5
|
-
const useQueryClient = queryClient => {
|
|
6
|
-
const client = React.useContext(QueryClientContext);
|
|
7
|
-
if (queryClient) {
|
|
8
|
-
return queryClient;
|
|
9
|
-
}
|
|
10
|
-
if (!client) {
|
|
11
|
-
throw new Error('No QueryClient set, use QueryClientProvider to set one');
|
|
12
|
-
}
|
|
13
|
-
return client;
|
|
14
|
-
};
|
|
15
|
-
const QueryClientProvider = ({
|
|
16
|
-
client,
|
|
17
|
-
children
|
|
18
|
-
}) => {
|
|
19
|
-
React.useEffect(() => {
|
|
20
|
-
client.mount();
|
|
21
|
-
return () => {
|
|
22
|
-
client.unmount();
|
|
23
|
-
};
|
|
24
|
-
}, [client]);
|
|
25
|
-
return /*#__PURE__*/React.createElement(QueryClientContext.Provider, {
|
|
26
|
-
value: client
|
|
27
|
-
}, children);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export { QueryClientContext, QueryClientProvider, useQueryClient };
|
|
31
|
-
//# sourceMappingURL=QueryClientProvider.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QueryClientProvider.mjs","sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\n\nexport const QueryClientContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\n\nexport const useQueryClient = (queryClient?: QueryClient) => {\n const client = React.useContext(QueryClientContext)\n\n if (queryClient) {\n return queryClient\n }\n\n if (!client) {\n throw new Error('No QueryClient set, use QueryClientProvider to set one')\n }\n\n return client\n}\n\nexport type QueryClientProviderProps = {\n client: QueryClient\n children?: React.ReactNode\n}\n\nexport const QueryClientProvider = ({\n client,\n children,\n}: QueryClientProviderProps): JSX.Element => {\n React.useEffect(() => {\n client.mount()\n return () => {\n client.unmount()\n }\n }, [client])\n\n return (\n <QueryClientContext.Provider value={client}>\n {children}\n </QueryClientContext.Provider>\n )\n}\n"],"names":["useQueryClient","children"],"mappings":";;;AAKO;AAIMA;AACX;AAEA;AACE;AACF;;AAGE;AACF;AAEA;AACF;AAOO;;AAELC;AACwB;;;AAGtB;;;AAGF;;AAG+B;AAAc;AAI/C;;"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export interface QueryErrorResetBoundaryValue {
|
|
3
|
-
clearReset: () => void;
|
|
4
|
-
isReset: () => boolean;
|
|
5
|
-
reset: () => void;
|
|
6
|
-
}
|
|
7
|
-
export declare const useQueryErrorResetBoundary: () => QueryErrorResetBoundaryValue;
|
|
8
|
-
export interface QueryErrorResetBoundaryProps {
|
|
9
|
-
children: ((value: QueryErrorResetBoundaryValue) => React.ReactNode) | React.ReactNode;
|
|
10
|
-
}
|
|
11
|
-
export declare const QueryErrorResetBoundary: ({ children, }: QueryErrorResetBoundaryProps) => JSX.Element;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
|
|
4
|
-
// CONTEXT
|
|
5
|
-
|
|
6
|
-
function createValue() {
|
|
7
|
-
let isReset = false;
|
|
8
|
-
return {
|
|
9
|
-
clearReset: () => {
|
|
10
|
-
isReset = false;
|
|
11
|
-
},
|
|
12
|
-
reset: () => {
|
|
13
|
-
isReset = true;
|
|
14
|
-
},
|
|
15
|
-
isReset: () => {
|
|
16
|
-
return isReset;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
const QueryErrorResetBoundaryContext = /*#__PURE__*/React.createContext(createValue());
|
|
21
|
-
|
|
22
|
-
// HOOK
|
|
23
|
-
|
|
24
|
-
const useQueryErrorResetBoundary = () => React.useContext(QueryErrorResetBoundaryContext);
|
|
25
|
-
|
|
26
|
-
// COMPONENT
|
|
27
|
-
|
|
28
|
-
const QueryErrorResetBoundary = ({
|
|
29
|
-
children
|
|
30
|
-
}) => {
|
|
31
|
-
const [value] = React.useState(() => createValue());
|
|
32
|
-
return /*#__PURE__*/React.createElement(QueryErrorResetBoundaryContext.Provider, {
|
|
33
|
-
value: value
|
|
34
|
-
}, typeof children === 'function' ? children(value) : children);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export { QueryErrorResetBoundary, useQueryErrorResetBoundary };
|
|
38
|
-
//# sourceMappingURL=QueryErrorResetBoundary.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QueryErrorResetBoundary.esm.js","sources":["../../src/QueryErrorResetBoundary.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\n// CONTEXT\n\nexport interface QueryErrorResetBoundaryValue {\n clearReset: () => void\n isReset: () => boolean\n reset: () => void\n}\n\nfunction createValue(): QueryErrorResetBoundaryValue {\n let isReset = false\n return {\n clearReset: () => {\n isReset = false\n },\n reset: () => {\n isReset = true\n },\n isReset: () => {\n return isReset\n },\n }\n}\n\nconst QueryErrorResetBoundaryContext = React.createContext(createValue())\n\n// HOOK\n\nexport const useQueryErrorResetBoundary = () =>\n React.useContext(QueryErrorResetBoundaryContext)\n\n// COMPONENT\n\nexport interface QueryErrorResetBoundaryProps {\n children:\n | ((value: QueryErrorResetBoundaryValue) => React.ReactNode)\n | React.ReactNode\n}\n\nexport const QueryErrorResetBoundary = ({\n children,\n}: QueryErrorResetBoundaryProps) => {\n const [value] = React.useState(() => createValue())\n return (\n <QueryErrorResetBoundaryContext.Provider value={value}>\n {typeof children === 'function'\n ? (children as Function)(value)\n : children}\n </QueryErrorResetBoundaryContext.Provider>\n )\n}\n"],"names":["clearReset","isReset","reset","children"],"mappings":";;;AAGA;;AAQA;;;AAGIA;AACEC;;AAEFC;AACED;;AAEFA;AACE;AACF;;AAEJ;AAEA;;AAEA;;AAEO;;AAGP;;AAQO;AACLE;AAC4B;;;AAGe;;AAM7C;;"}
|