@tanstack/preact-query 5.101.4 → 5.102.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/README.md +15 -1
- package/build/legacy/HydrationBoundary.cjs +35 -79
- package/build/legacy/HydrationBoundary.cjs.map +1 -1
- package/build/legacy/HydrationBoundary.d.cts +15 -2
- package/build/legacy/HydrationBoundary.d.cts.map +1 -0
- package/build/legacy/HydrationBoundary.d.ts +15 -2
- package/build/legacy/HydrationBoundary.d.ts.map +1 -0
- package/build/legacy/HydrationBoundary.js +31 -51
- package/build/legacy/HydrationBoundary.js.map +1 -1
- package/build/legacy/IsRestoringProvider.cjs +10 -35
- package/build/legacy/IsRestoringProvider.cjs.map +1 -1
- package/build/legacy/IsRestoringProvider.d.cts +6 -2
- package/build/legacy/IsRestoringProvider.d.cts.map +1 -0
- package/build/legacy/IsRestoringProvider.d.ts +6 -2
- package/build/legacy/IsRestoringProvider.d.ts.map +1 -0
- package/build/legacy/IsRestoringProvider.js +7 -8
- package/build/legacy/IsRestoringProvider.js.map +1 -1
- package/build/legacy/QueryClientProvider.cjs +26 -58
- package/build/legacy/QueryClientProvider.cjs.map +1 -1
- package/build/legacy/QueryClientProvider.d.cts +13 -4
- package/build/legacy/QueryClientProvider.d.cts.map +1 -0
- package/build/legacy/QueryClientProvider.d.ts +13 -4
- package/build/legacy/QueryClientProvider.d.ts.map +1 -0
- package/build/legacy/QueryClientProvider.js +21 -29
- package/build/legacy/QueryClientProvider.js.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.cjs +29 -53
- package/build/legacy/QueryErrorResetBoundary.cjs.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.d.cts +19 -8
- package/build/legacy/QueryErrorResetBoundary.d.cts.map +1 -0
- package/build/legacy/QueryErrorResetBoundary.d.ts +19 -8
- package/build/legacy/QueryErrorResetBoundary.d.ts.map +1 -0
- package/build/legacy/QueryErrorResetBoundary.js +24 -24
- package/build/legacy/QueryErrorResetBoundary.js.map +1 -1
- package/build/legacy/errorBoundaryUtils.cjs +20 -53
- package/build/legacy/errorBoundaryUtils.cjs.map +1 -1
- package/build/legacy/errorBoundaryUtils.d.cts +15 -3
- package/build/legacy/errorBoundaryUtils.d.cts.map +1 -0
- package/build/legacy/errorBoundaryUtils.d.ts +15 -3
- package/build/legacy/errorBoundaryUtils.d.ts.map +1 -0
- package/build/legacy/errorBoundaryUtils.js +15 -24
- package/build/legacy/errorBoundaryUtils.js.map +1 -1
- package/build/legacy/index.cjs +55 -95
- package/build/legacy/index.cjs.map +1 -1
- package/build/legacy/index.d.cts +21 -205
- package/build/legacy/index.d.ts +21 -205
- package/build/legacy/index.js +11 -39
- package/build/legacy/index.js.map +1 -1
- package/build/legacy/infiniteQueryOptions.cjs +6 -30
- package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.cts +18 -4
- package/build/legacy/infiniteQueryOptions.d.cts.map +1 -0
- package/build/legacy/infiniteQueryOptions.d.ts +18 -4
- package/build/legacy/infiniteQueryOptions.d.ts.map +1 -0
- package/build/legacy/infiniteQueryOptions.js +5 -5
- package/build/legacy/infiniteQueryOptions.js.map +1 -1
- package/build/legacy/mutationOptions.cjs +6 -30
- package/build/legacy/mutationOptions.cjs.map +1 -1
- package/build/legacy/mutationOptions.d.cts +8 -1
- package/build/legacy/mutationOptions.d.cts.map +1 -0
- package/build/legacy/mutationOptions.d.ts +8 -1
- package/build/legacy/mutationOptions.d.ts.map +1 -0
- package/build/legacy/mutationOptions.js +5 -5
- package/build/legacy/mutationOptions.js.map +1 -1
- package/build/legacy/queryOptions.cjs +6 -30
- package/build/legacy/queryOptions.cjs.map +1 -1
- package/build/legacy/queryOptions.d.cts +19 -4
- package/build/legacy/queryOptions.d.cts.map +1 -0
- package/build/legacy/queryOptions.d.ts +19 -4
- package/build/legacy/queryOptions.d.ts.map +1 -0
- package/build/legacy/queryOptions.js +5 -5
- package/build/legacy/queryOptions.js.map +1 -1
- package/build/legacy/suspense.cjs +20 -55
- package/build/legacy/suspense.cjs.map +1 -1
- package/build/legacy/suspense.d.cts +10 -5
- package/build/legacy/suspense.d.cts.map +1 -0
- package/build/legacy/suspense.d.ts +10 -5
- package/build/legacy/suspense.d.ts.map +1 -0
- package/build/legacy/suspense.js +16 -26
- package/build/legacy/suspense.js.map +1 -1
- package/build/legacy/types.cjs +3 -17
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +54 -24
- package/build/legacy/types.d.cts.map +1 -0
- package/build/legacy/types.d.ts +54 -24
- package/build/legacy/types.d.ts.map +1 -0
- package/build/legacy/types.js +5 -0
- package/build/legacy/types.js.map +1 -1
- package/build/legacy/useBaseQuery.cjs +48 -118
- package/build/legacy/useBaseQuery.cjs.map +1 -1
- package/build/legacy/useBaseQuery.d.cts +7 -1
- package/build/legacy/useBaseQuery.d.cts.map +1 -0
- package/build/legacy/useBaseQuery.d.ts +7 -1
- package/build/legacy/useBaseQuery.d.ts.map +1 -0
- package/build/legacy/useBaseQuery.js +44 -99
- package/build/legacy/useBaseQuery.js.map +1 -1
- package/build/legacy/useInfiniteQuery.cjs +8 -36
- package/build/legacy/useInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useInfiniteQuery.d.cts +10 -1
- package/build/legacy/useInfiniteQuery.d.cts.map +1 -0
- package/build/legacy/useInfiniteQuery.d.ts +10 -1
- package/build/legacy/useInfiniteQuery.d.ts.map +1 -0
- package/build/legacy/useInfiniteQuery.js +6 -10
- package/build/legacy/useInfiniteQuery.js.map +1 -1
- package/build/legacy/useIsFetching.cjs +12 -42
- package/build/legacy/useIsFetching.cjs.map +1 -1
- package/build/legacy/useIsFetching.d.cts +6 -1
- package/build/legacy/useIsFetching.d.cts.map +1 -0
- package/build/legacy/useIsFetching.d.ts +6 -1
- package/build/legacy/useIsFetching.d.ts.map +1 -0
- package/build/legacy/useIsFetching.js +9 -15
- package/build/legacy/useIsFetching.js.map +1 -1
- package/build/legacy/useMutation.cjs +24 -60
- package/build/legacy/useMutation.cjs.map +1 -1
- package/build/legacy/useMutation.d.cts +7 -1
- package/build/legacy/useMutation.d.cts.map +1 -0
- package/build/legacy/useMutation.d.ts +7 -1
- package/build/legacy/useMutation.d.ts.map +1 -0
- package/build/legacy/useMutation.js +21 -38
- package/build/legacy/useMutation.js.map +1 -1
- package/build/legacy/useMutationState.cjs +30 -68
- package/build/legacy/useMutationState.cjs.map +1 -1
- package/build/legacy/useMutationState.d.cts +12 -2
- package/build/legacy/useMutationState.d.cts.map +1 -0
- package/build/legacy/useMutationState.d.ts +12 -2
- package/build/legacy/useMutationState.d.ts.map +1 -0
- package/build/legacy/useMutationState.js +26 -40
- package/build/legacy/useMutationState.js.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.cjs +9 -34
- package/build/legacy/usePrefetchInfiniteQuery.cjs.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.cts +7 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -0
- package/build/legacy/usePrefetchInfiniteQuery.d.ts +7 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -0
- package/build/legacy/usePrefetchInfiniteQuery.js +7 -8
- package/build/legacy/usePrefetchInfiniteQuery.js.map +1 -1
- package/build/legacy/usePrefetchQuery.cjs +9 -34
- package/build/legacy/usePrefetchQuery.cjs.map +1 -1
- package/build/legacy/usePrefetchQuery.d.cts +7 -1
- package/build/legacy/usePrefetchQuery.d.cts.map +1 -0
- package/build/legacy/usePrefetchQuery.d.ts +7 -1
- package/build/legacy/usePrefetchQuery.d.ts.map +1 -0
- package/build/legacy/usePrefetchQuery.js +7 -8
- package/build/legacy/usePrefetchQuery.js.map +1 -1
- package/build/legacy/useQueries.cjs +64 -114
- package/build/legacy/useQueries.cjs.map +1 -1
- package/build/legacy/useQueries.d.cts +57 -3
- package/build/legacy/useQueries.d.cts.map +1 -0
- package/build/legacy/useQueries.d.ts +57 -3
- package/build/legacy/useQueries.d.ts.map +1 -0
- package/build/legacy/useQueries.js +60 -99
- package/build/legacy/useQueries.js.map +1 -1
- package/build/legacy/useQuery.cjs +8 -32
- package/build/legacy/useQuery.cjs.map +1 -1
- package/build/legacy/useQuery.d.cts +10 -1
- package/build/legacy/useQuery.d.cts.map +1 -0
- package/build/legacy/useQuery.d.ts +10 -1
- package/build/legacy/useQuery.d.ts.map +1 -0
- package/build/legacy/useQuery.js +6 -6
- package/build/legacy/useQuery.js.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.cjs +18 -47
- package/build/legacy/useSuspenseInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.cts +7 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.cts.map +1 -0
- package/build/legacy/useSuspenseInfiniteQuery.d.ts +7 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.ts.map +1 -0
- package/build/legacy/useSuspenseInfiniteQuery.js +15 -20
- package/build/legacy/useSuspenseInfiniteQuery.js.map +1 -1
- package/build/legacy/useSuspenseQueries.cjs +23 -52
- package/build/legacy/useSuspenseQueries.cjs.map +1 -1
- package/build/legacy/useSuspenseQueries.d.cts +60 -3
- package/build/legacy/useSuspenseQueries.d.cts.map +1 -0
- package/build/legacy/useSuspenseQueries.d.ts +60 -3
- package/build/legacy/useSuspenseQueries.d.ts.map +1 -0
- package/build/legacy/useSuspenseQueries.js +20 -25
- package/build/legacy/useSuspenseQueries.js.map +1 -1
- package/build/legacy/useSuspenseQuery.cjs +18 -48
- package/build/legacy/useSuspenseQuery.cjs.map +1 -1
- package/build/legacy/useSuspenseQuery.d.cts +7 -1
- package/build/legacy/useSuspenseQuery.d.cts.map +1 -0
- package/build/legacy/useSuspenseQuery.d.ts +7 -1
- package/build/legacy/useSuspenseQuery.d.ts.map +1 -0
- package/build/legacy/useSuspenseQuery.js +15 -21
- package/build/legacy/useSuspenseQuery.js.map +1 -1
- package/build/legacy/utils.cjs +43 -72
- package/build/legacy/utils.cjs.map +1 -1
- package/build/legacy/utils.d.cts +6 -2
- package/build/legacy/utils.d.cts.map +1 -0
- package/build/legacy/utils.d.ts +6 -2
- package/build/legacy/utils.d.ts.map +1 -0
- package/build/legacy/utils.js +40 -45
- package/build/legacy/utils.js.map +1 -1
- package/build/modern/HydrationBoundary.cjs +35 -79
- package/build/modern/HydrationBoundary.cjs.map +1 -1
- package/build/modern/HydrationBoundary.d.cts +15 -2
- package/build/modern/HydrationBoundary.d.cts.map +1 -0
- package/build/modern/HydrationBoundary.d.ts +15 -2
- package/build/modern/HydrationBoundary.d.ts.map +1 -0
- package/build/modern/HydrationBoundary.js +31 -51
- package/build/modern/HydrationBoundary.js.map +1 -1
- package/build/modern/IsRestoringProvider.cjs +10 -35
- package/build/modern/IsRestoringProvider.cjs.map +1 -1
- package/build/modern/IsRestoringProvider.d.cts +6 -2
- package/build/modern/IsRestoringProvider.d.cts.map +1 -0
- package/build/modern/IsRestoringProvider.d.ts +6 -2
- package/build/modern/IsRestoringProvider.d.ts.map +1 -0
- package/build/modern/IsRestoringProvider.js +7 -8
- package/build/modern/IsRestoringProvider.js.map +1 -1
- package/build/modern/QueryClientProvider.cjs +26 -58
- package/build/modern/QueryClientProvider.cjs.map +1 -1
- package/build/modern/QueryClientProvider.d.cts +13 -4
- package/build/modern/QueryClientProvider.d.cts.map +1 -0
- package/build/modern/QueryClientProvider.d.ts +13 -4
- package/build/modern/QueryClientProvider.d.ts.map +1 -0
- package/build/modern/QueryClientProvider.js +21 -29
- package/build/modern/QueryClientProvider.js.map +1 -1
- package/build/modern/QueryErrorResetBoundary.cjs +29 -53
- package/build/modern/QueryErrorResetBoundary.cjs.map +1 -1
- package/build/modern/QueryErrorResetBoundary.d.cts +19 -8
- package/build/modern/QueryErrorResetBoundary.d.cts.map +1 -0
- package/build/modern/QueryErrorResetBoundary.d.ts +19 -8
- package/build/modern/QueryErrorResetBoundary.d.ts.map +1 -0
- package/build/modern/QueryErrorResetBoundary.js +24 -24
- package/build/modern/QueryErrorResetBoundary.js.map +1 -1
- package/build/modern/errorBoundaryUtils.cjs +20 -53
- package/build/modern/errorBoundaryUtils.cjs.map +1 -1
- package/build/modern/errorBoundaryUtils.d.cts +15 -3
- package/build/modern/errorBoundaryUtils.d.cts.map +1 -0
- package/build/modern/errorBoundaryUtils.d.ts +15 -3
- package/build/modern/errorBoundaryUtils.d.ts.map +1 -0
- package/build/modern/errorBoundaryUtils.js +15 -24
- package/build/modern/errorBoundaryUtils.js.map +1 -1
- package/build/modern/index.cjs +55 -95
- package/build/modern/index.cjs.map +1 -1
- package/build/modern/index.d.cts +21 -205
- package/build/modern/index.d.ts +21 -205
- package/build/modern/index.js +11 -39
- package/build/modern/index.js.map +1 -1
- package/build/modern/infiniteQueryOptions.cjs +6 -30
- package/build/modern/infiniteQueryOptions.cjs.map +1 -1
- package/build/modern/infiniteQueryOptions.d.cts +18 -4
- package/build/modern/infiniteQueryOptions.d.cts.map +1 -0
- package/build/modern/infiniteQueryOptions.d.ts +18 -4
- package/build/modern/infiniteQueryOptions.d.ts.map +1 -0
- package/build/modern/infiniteQueryOptions.js +5 -5
- package/build/modern/infiniteQueryOptions.js.map +1 -1
- package/build/modern/mutationOptions.cjs +6 -30
- package/build/modern/mutationOptions.cjs.map +1 -1
- package/build/modern/mutationOptions.d.cts +8 -1
- package/build/modern/mutationOptions.d.cts.map +1 -0
- package/build/modern/mutationOptions.d.ts +8 -1
- package/build/modern/mutationOptions.d.ts.map +1 -0
- package/build/modern/mutationOptions.js +5 -5
- package/build/modern/mutationOptions.js.map +1 -1
- package/build/modern/queryOptions.cjs +6 -30
- package/build/modern/queryOptions.cjs.map +1 -1
- package/build/modern/queryOptions.d.cts +19 -4
- package/build/modern/queryOptions.d.cts.map +1 -0
- package/build/modern/queryOptions.d.ts +19 -4
- package/build/modern/queryOptions.d.ts.map +1 -0
- package/build/modern/queryOptions.js +5 -5
- package/build/modern/queryOptions.js.map +1 -1
- package/build/modern/suspense.cjs +20 -55
- package/build/modern/suspense.cjs.map +1 -1
- package/build/modern/suspense.d.cts +10 -5
- package/build/modern/suspense.d.cts.map +1 -0
- package/build/modern/suspense.d.ts +10 -5
- package/build/modern/suspense.d.ts.map +1 -0
- package/build/modern/suspense.js +16 -26
- package/build/modern/suspense.js.map +1 -1
- package/build/modern/types.cjs +3 -17
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +54 -24
- package/build/modern/types.d.cts.map +1 -0
- package/build/modern/types.d.ts +54 -24
- package/build/modern/types.d.ts.map +1 -0
- package/build/modern/types.js +5 -0
- package/build/modern/types.js.map +1 -1
- package/build/modern/useBaseQuery.cjs +48 -115
- package/build/modern/useBaseQuery.cjs.map +1 -1
- package/build/modern/useBaseQuery.d.cts +7 -1
- package/build/modern/useBaseQuery.d.cts.map +1 -0
- package/build/modern/useBaseQuery.d.ts +7 -1
- package/build/modern/useBaseQuery.d.ts.map +1 -0
- package/build/modern/useBaseQuery.js +44 -96
- package/build/modern/useBaseQuery.js.map +1 -1
- package/build/modern/useInfiniteQuery.cjs +8 -36
- package/build/modern/useInfiniteQuery.cjs.map +1 -1
- package/build/modern/useInfiniteQuery.d.cts +10 -1
- package/build/modern/useInfiniteQuery.d.cts.map +1 -0
- package/build/modern/useInfiniteQuery.d.ts +10 -1
- package/build/modern/useInfiniteQuery.d.ts.map +1 -0
- package/build/modern/useInfiniteQuery.js +6 -10
- package/build/modern/useInfiniteQuery.js.map +1 -1
- package/build/modern/useIsFetching.cjs +12 -42
- package/build/modern/useIsFetching.cjs.map +1 -1
- package/build/modern/useIsFetching.d.cts +6 -1
- package/build/modern/useIsFetching.d.cts.map +1 -0
- package/build/modern/useIsFetching.d.ts +6 -1
- package/build/modern/useIsFetching.d.ts.map +1 -0
- package/build/modern/useIsFetching.js +9 -15
- package/build/modern/useIsFetching.js.map +1 -1
- package/build/modern/useMutation.cjs +24 -60
- package/build/modern/useMutation.cjs.map +1 -1
- package/build/modern/useMutation.d.cts +7 -1
- package/build/modern/useMutation.d.cts.map +1 -0
- package/build/modern/useMutation.d.ts +7 -1
- package/build/modern/useMutation.d.ts.map +1 -0
- package/build/modern/useMutation.js +21 -38
- package/build/modern/useMutation.js.map +1 -1
- package/build/modern/useMutationState.cjs +30 -68
- package/build/modern/useMutationState.cjs.map +1 -1
- package/build/modern/useMutationState.d.cts +12 -2
- package/build/modern/useMutationState.d.cts.map +1 -0
- package/build/modern/useMutationState.d.ts +12 -2
- package/build/modern/useMutationState.d.ts.map +1 -0
- package/build/modern/useMutationState.js +26 -40
- package/build/modern/useMutationState.js.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.cjs +9 -34
- package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.cts +7 -1
- package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -0
- package/build/modern/usePrefetchInfiniteQuery.d.ts +7 -1
- package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -0
- package/build/modern/usePrefetchInfiniteQuery.js +7 -8
- package/build/modern/usePrefetchInfiniteQuery.js.map +1 -1
- package/build/modern/usePrefetchQuery.cjs +9 -34
- package/build/modern/usePrefetchQuery.cjs.map +1 -1
- package/build/modern/usePrefetchQuery.d.cts +7 -1
- package/build/modern/usePrefetchQuery.d.cts.map +1 -0
- package/build/modern/usePrefetchQuery.d.ts +7 -1
- package/build/modern/usePrefetchQuery.d.ts.map +1 -0
- package/build/modern/usePrefetchQuery.js +7 -8
- package/build/modern/usePrefetchQuery.js.map +1 -1
- package/build/modern/useQueries.cjs +64 -114
- package/build/modern/useQueries.cjs.map +1 -1
- package/build/modern/useQueries.d.cts +57 -3
- package/build/modern/useQueries.d.cts.map +1 -0
- package/build/modern/useQueries.d.ts +57 -3
- package/build/modern/useQueries.d.ts.map +1 -0
- package/build/modern/useQueries.js +60 -99
- package/build/modern/useQueries.js.map +1 -1
- package/build/modern/useQuery.cjs +8 -32
- package/build/modern/useQuery.cjs.map +1 -1
- package/build/modern/useQuery.d.cts +10 -1
- package/build/modern/useQuery.d.cts.map +1 -0
- package/build/modern/useQuery.d.ts +10 -1
- package/build/modern/useQuery.d.ts.map +1 -0
- package/build/modern/useQuery.js +6 -6
- package/build/modern/useQuery.js.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.cjs +18 -47
- package/build/modern/useSuspenseInfiniteQuery.cjs.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.d.cts +7 -1
- package/build/modern/useSuspenseInfiniteQuery.d.cts.map +1 -0
- package/build/modern/useSuspenseInfiniteQuery.d.ts +7 -1
- package/build/modern/useSuspenseInfiniteQuery.d.ts.map +1 -0
- package/build/modern/useSuspenseInfiniteQuery.js +15 -20
- package/build/modern/useSuspenseInfiniteQuery.js.map +1 -1
- package/build/modern/useSuspenseQueries.cjs +23 -52
- package/build/modern/useSuspenseQueries.cjs.map +1 -1
- package/build/modern/useSuspenseQueries.d.cts +60 -3
- package/build/modern/useSuspenseQueries.d.cts.map +1 -0
- package/build/modern/useSuspenseQueries.d.ts +60 -3
- package/build/modern/useSuspenseQueries.d.ts.map +1 -0
- package/build/modern/useSuspenseQueries.js +20 -25
- package/build/modern/useSuspenseQueries.js.map +1 -1
- package/build/modern/useSuspenseQuery.cjs +18 -48
- package/build/modern/useSuspenseQuery.cjs.map +1 -1
- package/build/modern/useSuspenseQuery.d.cts +7 -1
- package/build/modern/useSuspenseQuery.d.cts.map +1 -0
- package/build/modern/useSuspenseQuery.d.ts +7 -1
- package/build/modern/useSuspenseQuery.d.ts.map +1 -0
- package/build/modern/useSuspenseQuery.js +15 -21
- package/build/modern/useSuspenseQuery.js.map +1 -1
- package/build/modern/utils.cjs +43 -72
- package/build/modern/utils.cjs.map +1 -1
- package/build/modern/utils.d.cts +6 -2
- package/build/modern/utils.d.cts.map +1 -0
- package/build/modern/utils.d.ts +6 -2
- package/build/modern/utils.d.ts.map +1 -0
- package/build/modern/utils.js +40 -45
- package/build/modern/utils.js.map +1 -1
- package/build/query-codemods/root.eslint.config.js +1 -1
- package/package.json +7 -9
- package/src/errorBoundaryUtils.ts +7 -5
- package/src/infiniteQueryOptions.ts +7 -10
- package/src/queryOptions.ts +7 -10
- package/src/suspense.ts +0 -5
- package/src/types.ts +47 -10
- package/src/useBaseQuery.ts +11 -41
- package/src/useMutation.ts +6 -2
- package/src/useMutationState.ts +32 -7
- package/src/usePrefetchInfiniteQuery.tsx +6 -9
- package/src/usePrefetchQuery.tsx +12 -4
- package/src/useQueries.ts +4 -3
- package/src/useQuery.ts +3 -3
- package/src/useSuspenseInfiniteQuery.ts +1 -0
- package/build/legacy/_tsup-dts-rollup.d.cts +0 -954
- package/build/legacy/_tsup-dts-rollup.d.ts +0 -954
- package/build/modern/_tsup-dts-rollup.d.cts +0 -954
- package/build/modern/_tsup-dts-rollup.d.ts +0 -954
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils.ts"],"sourcesContent":["import { useEffect, useLayoutEffect, useRef, useState } from 'preact/hooks'\n\n/**\n * This is taken from https://github.com/preactjs/preact/blob/main/compat/src/hooks.js#L8-L54\n * which is taken from https://github.com/facebook/react/blob/main/packages/use-sync-external-store/src/useSyncExternalStoreShimClient.js#L84\n * on a high level this cuts out the warnings, ... and attempts a smaller implementation.\n * This way we don't have to import preact/compat with side effects\n */\ntype InternalStore = {\n _value: any\n _getSnapshot: () => any\n}\ntype StoreRef = {\n _instance: InternalStore\n}\nexport function useSyncExternalStore(\n subscribe: (onStoreChange: () => void) => () => void,\n getSnapshot: () => any,\n) {\n const value = getSnapshot()\n\n const [{ _instance }, forceUpdate] = useState<StoreRef>({\n _instance: { _value: value, _getSnapshot: getSnapshot },\n })\n\n useLayoutEffect(() => {\n _instance._value = value\n _instance._getSnapshot = getSnapshot\n\n if (didSnapshotChange(_instance)) {\n forceUpdate({ _instance })\n }\n }, [subscribe, value, getSnapshot])\n\n useEffect(() => {\n if (didSnapshotChange(_instance)) {\n forceUpdate({ _instance })\n }\n\n return subscribe(() => {\n if (didSnapshotChange(_instance)) {\n forceUpdate({ _instance })\n }\n })\n }, [subscribe])\n\n return value\n}\n\nfunction didSnapshotChange(inst: {\n _getSnapshot: () => any\n _value: any\n}): boolean {\n const latestGetSnapshot = inst._getSnapshot\n const prevValue = inst._value\n try {\n const nextValue = latestGetSnapshot()\n return !Object.is(prevValue, nextValue)\n // eslint-disable-next-line no-unused-vars\n } catch (_error) {\n return true\n }\n}\n\nexport function useSyncExternalStoreWithSelector<TSnapshot, TSelected>(\n subscribe: (onStoreChange: () => void) => () => void,\n getSnapshot: () => TSnapshot,\n selector: (snapshot: TSnapshot) => TSelected,\n isEqual: (a: TSelected, b: TSelected) => boolean,\n): TSelected {\n const selectedSnapshotRef = useRef<TSelected | undefined>()\n\n const getSelectedSnapshot = () => {\n const snapshot = getSnapshot()\n const selected = selector(snapshot)\n\n if (\n selectedSnapshotRef.current === undefined ||\n !isEqual(selectedSnapshotRef.current, selected)\n ) {\n selectedSnapshotRef.current = selected\n }\n\n return selectedSnapshotRef.current\n }\n\n return useSyncExternalStore(subscribe, getSelectedSnapshot)\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["import { useEffect, useLayoutEffect, useRef, useState } from 'preact/hooks'\n\n/**\n * This is taken from https://github.com/preactjs/preact/blob/main/compat/src/hooks.js#L8-L54\n * which is taken from https://github.com/facebook/react/blob/main/packages/use-sync-external-store/src/useSyncExternalStoreShimClient.js#L84\n * on a high level this cuts out the warnings, ... and attempts a smaller implementation.\n * This way we don't have to import preact/compat with side effects\n */\ntype InternalStore = {\n _value: any\n _getSnapshot: () => any\n}\ntype StoreRef = {\n _instance: InternalStore\n}\nexport function useSyncExternalStore(\n subscribe: (onStoreChange: () => void) => () => void,\n getSnapshot: () => any,\n) {\n const value = getSnapshot()\n\n const [{ _instance }, forceUpdate] = useState<StoreRef>({\n _instance: { _value: value, _getSnapshot: getSnapshot },\n })\n\n useLayoutEffect(() => {\n _instance._value = value\n _instance._getSnapshot = getSnapshot\n\n if (didSnapshotChange(_instance)) {\n forceUpdate({ _instance })\n }\n }, [subscribe, value, getSnapshot])\n\n useEffect(() => {\n if (didSnapshotChange(_instance)) {\n forceUpdate({ _instance })\n }\n\n return subscribe(() => {\n if (didSnapshotChange(_instance)) {\n forceUpdate({ _instance })\n }\n })\n }, [subscribe])\n\n return value\n}\n\nfunction didSnapshotChange(inst: {\n _getSnapshot: () => any\n _value: any\n}): boolean {\n const latestGetSnapshot = inst._getSnapshot\n const prevValue = inst._value\n try {\n const nextValue = latestGetSnapshot()\n return !Object.is(prevValue, nextValue)\n // eslint-disable-next-line no-unused-vars\n } catch (_error) {\n return true\n }\n}\n\nexport function useSyncExternalStoreWithSelector<TSnapshot, TSelected>(\n subscribe: (onStoreChange: () => void) => () => void,\n getSnapshot: () => TSnapshot,\n selector: (snapshot: TSnapshot) => TSelected,\n isEqual: (a: TSelected, b: TSelected) => boolean,\n): TSelected {\n const selectedSnapshotRef = useRef<TSelected | undefined>()\n\n const getSelectedSnapshot = () => {\n const snapshot = getSnapshot()\n const selected = selector(snapshot)\n\n if (\n selectedSnapshotRef.current === undefined ||\n !isEqual(selectedSnapshotRef.current, selected)\n ) {\n selectedSnapshotRef.current = selected\n }\n\n return selectedSnapshotRef.current\n }\n\n return useSyncExternalStore(subscribe, getSelectedSnapshot)\n}\n"],"mappings":";;AAeA,SAAgB,qBACd,WACA,aACA;CACA,MAAM,QAAQ,YAAY;CAE1B,MAAM,CAAC,EAAE,aAAa,eAAe,SAAmB,EACtD,WAAW;EAAE,QAAQ;EAAO,cAAc;CAAY,EACxD,CAAC;CAED,sBAAsB;EACpB,UAAU,SAAS;EACnB,UAAU,eAAe;EAEzB,IAAI,kBAAkB,SAAS,GAC7B,YAAY,EAAE,UAAU,CAAC;CAE7B,GAAG;EAAC;EAAW;EAAO;CAAW,CAAC;CAElC,gBAAgB;EACd,IAAI,kBAAkB,SAAS,GAC7B,YAAY,EAAE,UAAU,CAAC;EAG3B,OAAO,gBAAgB;GACrB,IAAI,kBAAkB,SAAS,GAC7B,YAAY,EAAE,UAAU,CAAC;EAE7B,CAAC;CACH,GAAG,CAAC,SAAS,CAAC;CAEd,OAAO;AACT;AAEA,SAAS,kBAAkB,MAGf;CACV,MAAM,oBAAoB,KAAK;CAC/B,MAAM,YAAY,KAAK;CACvB,IAAI;EACF,MAAM,YAAY,kBAAkB;EACpC,OAAO,CAAC,OAAO,GAAG,WAAW,SAAS;CAExC,SAAS,QAAQ;EACf,OAAO;CACT;AACF;AAEA,SAAgB,iCACd,WACA,aACA,UACA,SACW;CACX,MAAM,sBAAsB,OAA8B;CAE1D,MAAM,4BAA4B;EAEhC,MAAM,WAAW,SADA,YACgB,CAAC;EAElC,IACE,oBAAoB,YAAY,KAAA,KAChC,CAAC,QAAQ,oBAAoB,SAAS,QAAQ,GAE9C,oBAAoB,UAAU;EAGhC,OAAO,oBAAoB;CAC7B;CAEA,OAAO,qBAAqB,WAAW,mBAAmB;AAC5D"}
|
|
@@ -32,7 +32,7 @@ export default [
|
|
|
32
32
|
'tanstack', // Our package scope
|
|
33
33
|
'todos', // Too general word to be caught as error
|
|
34
34
|
'tsqd', // Our public interface (TanStack Query Devtools shorthand)
|
|
35
|
-
'
|
|
35
|
+
'tsdown', // We use tsdown as builder
|
|
36
36
|
'typecheck', // Field of vite.config.ts
|
|
37
37
|
'vue-demi', // dependency of @tanstack/vue-query
|
|
38
38
|
'ɵkind', // Angular specific
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/preact-query",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.102.0",
|
|
4
4
|
"description": "Hooks for managing, caching and syncing asynchronous and remote data in preact",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"!build/codemods/**/__tests__"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@tanstack/query-core": "5.
|
|
46
|
+
"@tanstack/query-core": "5.102.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@preact/preset-vite": "^2.10.2",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"npm-run-all2": "^5.0.0",
|
|
54
54
|
"preact": "^10.28.0",
|
|
55
55
|
"preact-render-to-string": "^6.6.4",
|
|
56
|
-
"typescript": "
|
|
56
|
+
"typescript": "6.0.3",
|
|
57
57
|
"typescript-eslint": "^8.54.0",
|
|
58
|
-
"@tanstack/query-persist-client-core": "5.
|
|
58
|
+
"@tanstack/query-persist-client-core": "5.102.0",
|
|
59
59
|
"@tanstack/query-test-utils": "0.0.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
@@ -66,19 +66,17 @@
|
|
|
66
66
|
"compile": "tsc --build",
|
|
67
67
|
"test:eslint": "eslint --concurrency=auto ./src",
|
|
68
68
|
"test:types": "npm-run-all --serial test:types:*",
|
|
69
|
-
"test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js --build tsconfig.legacy.json",
|
|
70
|
-
"test:types:ts55": "node ../../node_modules/typescript55/lib/tsc.js --build tsconfig.legacy.json",
|
|
71
69
|
"test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js --build tsconfig.legacy.json",
|
|
72
70
|
"test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js --build tsconfig.legacy.json",
|
|
73
71
|
"test:types:ts58": "node ../../node_modules/typescript58/lib/tsc.js --build tsconfig.legacy.json",
|
|
74
72
|
"test:types:ts59": "node ../../node_modules/typescript59/lib/tsc.js --build tsconfig.legacy.json",
|
|
75
73
|
"test:types:tscurrent": "tsc --build",
|
|
76
|
-
"test:types:
|
|
74
|
+
"test:types:ts70": "node ../../node_modules/typescript70/lib/tsc.js --build",
|
|
77
75
|
"test:lib": "vitest",
|
|
78
76
|
"test:lib:dev": "pnpm run test:lib --watch",
|
|
79
77
|
"test:build": "publint --strict && attw --pack",
|
|
80
|
-
"build": "pnpm build:
|
|
81
|
-
"build:
|
|
78
|
+
"build": "pnpm build:tsdown && pnpm build:codemods",
|
|
79
|
+
"build:tsdown": "tsdown --tsconfig tsconfig.prod.json",
|
|
82
80
|
"build:codemods": "cpy ../query-codemods/* ./build/codemods"
|
|
83
81
|
}
|
|
84
82
|
}
|
|
@@ -25,12 +25,14 @@ export const ensurePreventErrorBoundaryRetry = <
|
|
|
25
25
|
TQueryKey
|
|
26
26
|
>,
|
|
27
27
|
errorResetBoundary: QueryErrorResetBoundaryValue,
|
|
28
|
+
query: Query<TQueryFnData, TError, TQueryData, TQueryKey> | undefined,
|
|
28
29
|
) => {
|
|
29
|
-
|
|
30
|
-
options.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const throwOnError =
|
|
31
|
+
query?.state.error && typeof options.throwOnError === 'function'
|
|
32
|
+
? shouldThrowError(options.throwOnError, [query.state.error, query])
|
|
33
|
+
: options.throwOnError
|
|
34
|
+
|
|
35
|
+
if (options.suspense || throwOnError) {
|
|
34
36
|
// Prevent retrying failed query if the error boundary has not been reset yet
|
|
35
37
|
if (!errorResetBoundary.isReset()) {
|
|
36
38
|
options.retryOnMount = false
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
DataTag,
|
|
3
2
|
DefaultError,
|
|
4
3
|
InfiniteData,
|
|
5
4
|
InitialDataFunction,
|
|
6
5
|
NonUndefinedGuard,
|
|
7
6
|
OmitKeyof,
|
|
8
7
|
QueryKey,
|
|
8
|
+
QueryKeyWithDataTag,
|
|
9
9
|
SkipToken,
|
|
10
10
|
} from '@tanstack/query-core'
|
|
11
11
|
|
|
@@ -93,9 +93,8 @@ export function infiniteQueryOptions<
|
|
|
93
93
|
TData,
|
|
94
94
|
TQueryKey,
|
|
95
95
|
TPageParam
|
|
96
|
-
> &
|
|
97
|
-
|
|
98
|
-
}
|
|
96
|
+
> &
|
|
97
|
+
QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
|
|
99
98
|
|
|
100
99
|
export function infiniteQueryOptions<
|
|
101
100
|
TQueryFnData,
|
|
@@ -117,9 +116,8 @@ export function infiniteQueryOptions<
|
|
|
117
116
|
TData,
|
|
118
117
|
TQueryKey,
|
|
119
118
|
TPageParam
|
|
120
|
-
> &
|
|
121
|
-
|
|
122
|
-
}
|
|
119
|
+
> &
|
|
120
|
+
QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
|
|
123
121
|
|
|
124
122
|
export function infiniteQueryOptions<
|
|
125
123
|
TQueryFnData,
|
|
@@ -141,9 +139,8 @@ export function infiniteQueryOptions<
|
|
|
141
139
|
TData,
|
|
142
140
|
TQueryKey,
|
|
143
141
|
TPageParam
|
|
144
|
-
> &
|
|
145
|
-
|
|
146
|
-
}
|
|
142
|
+
> &
|
|
143
|
+
QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
|
|
147
144
|
|
|
148
145
|
export function infiniteQueryOptions(options: unknown) {
|
|
149
146
|
return options
|
package/src/queryOptions.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
DataTag,
|
|
3
2
|
DefaultError,
|
|
4
3
|
InitialDataFunction,
|
|
5
4
|
NonUndefinedGuard,
|
|
6
5
|
OmitKeyof,
|
|
7
6
|
QueryFunction,
|
|
8
7
|
QueryKey,
|
|
8
|
+
QueryKeyWithDataTag,
|
|
9
9
|
SkipToken,
|
|
10
10
|
} from '@tanstack/query-core'
|
|
11
11
|
|
|
@@ -57,9 +57,8 @@ export function queryOptions<
|
|
|
57
57
|
TQueryKey extends QueryKey = QueryKey,
|
|
58
58
|
>(
|
|
59
59
|
options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
60
|
-
): DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &
|
|
61
|
-
|
|
62
|
-
}
|
|
60
|
+
): DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &
|
|
61
|
+
QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>
|
|
63
62
|
|
|
64
63
|
export function queryOptions<
|
|
65
64
|
TQueryFnData = unknown,
|
|
@@ -68,9 +67,8 @@ export function queryOptions<
|
|
|
68
67
|
TQueryKey extends QueryKey = QueryKey,
|
|
69
68
|
>(
|
|
70
69
|
options: UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
71
|
-
): UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey> &
|
|
72
|
-
|
|
73
|
-
}
|
|
70
|
+
): UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey> &
|
|
71
|
+
QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>
|
|
74
72
|
|
|
75
73
|
export function queryOptions<
|
|
76
74
|
TQueryFnData = unknown,
|
|
@@ -79,9 +77,8 @@ export function queryOptions<
|
|
|
79
77
|
TQueryKey extends QueryKey = QueryKey,
|
|
80
78
|
>(
|
|
81
79
|
options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
82
|
-
): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &
|
|
83
|
-
|
|
84
|
-
}
|
|
80
|
+
): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &
|
|
81
|
+
QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>
|
|
85
82
|
|
|
86
83
|
export function queryOptions(options: unknown) {
|
|
87
84
|
return options
|
package/src/suspense.ts
CHANGED
|
@@ -47,11 +47,6 @@ export const ensureSuspenseTimers = (
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
export const willFetch = (
|
|
51
|
-
result: QueryObserverResult<any, any>,
|
|
52
|
-
isRestoring: boolean,
|
|
53
|
-
) => result.isLoading && result.isFetching && !isRestoring
|
|
54
|
-
|
|
55
50
|
export const shouldSuspend = (
|
|
56
51
|
defaultedOptions:
|
|
57
52
|
| DefaultedQueryObserverOptions<any, any, any, any, any>
|
package/src/types.ts
CHANGED
|
@@ -4,7 +4,8 @@ import type {
|
|
|
4
4
|
DefinedInfiniteQueryObserverResult,
|
|
5
5
|
DefinedQueryObserverResult,
|
|
6
6
|
DistributiveOmit,
|
|
7
|
-
|
|
7
|
+
InfiniteData,
|
|
8
|
+
InfiniteQueryExecuteOptions,
|
|
8
9
|
InfiniteQueryObserverOptions,
|
|
9
10
|
InfiniteQueryObserverResult,
|
|
10
11
|
MutateFunction,
|
|
@@ -12,6 +13,7 @@ import type {
|
|
|
12
13
|
MutationObserverResult,
|
|
13
14
|
OmitKeyof,
|
|
14
15
|
Override,
|
|
16
|
+
QueryExecuteOptions,
|
|
15
17
|
QueryKey,
|
|
16
18
|
QueryObserverOptions,
|
|
17
19
|
QueryObserverResult,
|
|
@@ -45,17 +47,52 @@ export interface UseBaseQueryOptions<
|
|
|
45
47
|
subscribed?: boolean
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
export
|
|
50
|
+
export type UsePrefetchQueryOptions<
|
|
49
51
|
TQueryFnData = unknown,
|
|
50
52
|
TError = DefaultError,
|
|
51
53
|
TData = TQueryFnData,
|
|
54
|
+
TQueryData = TQueryFnData,
|
|
52
55
|
TQueryKey extends QueryKey = QueryKey,
|
|
53
|
-
>
|
|
54
|
-
|
|
56
|
+
> = DistributiveOmit<
|
|
57
|
+
QueryExecuteOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>,
|
|
55
58
|
'queryFn'
|
|
56
|
-
> {
|
|
59
|
+
> & {
|
|
57
60
|
queryFn?: Exclude<
|
|
58
|
-
|
|
61
|
+
QueryExecuteOptions<
|
|
62
|
+
TQueryFnData,
|
|
63
|
+
TError,
|
|
64
|
+
TData,
|
|
65
|
+
TQueryFnData,
|
|
66
|
+
TQueryKey
|
|
67
|
+
>['queryFn'],
|
|
68
|
+
SkipToken
|
|
69
|
+
>
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export type UsePrefetchInfiniteQueryOptions<
|
|
73
|
+
TQueryFnData = unknown,
|
|
74
|
+
TError = DefaultError,
|
|
75
|
+
TData = TQueryFnData,
|
|
76
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
77
|
+
TPageParam = unknown,
|
|
78
|
+
> = DistributiveOmit<
|
|
79
|
+
InfiniteQueryExecuteOptions<
|
|
80
|
+
TQueryFnData,
|
|
81
|
+
TError,
|
|
82
|
+
TData,
|
|
83
|
+
TQueryKey,
|
|
84
|
+
TPageParam
|
|
85
|
+
>,
|
|
86
|
+
'queryFn'
|
|
87
|
+
> & {
|
|
88
|
+
queryFn?: Exclude<
|
|
89
|
+
InfiniteQueryExecuteOptions<
|
|
90
|
+
TQueryFnData,
|
|
91
|
+
TError,
|
|
92
|
+
TData,
|
|
93
|
+
TQueryKey,
|
|
94
|
+
TPageParam
|
|
95
|
+
>['queryFn'],
|
|
59
96
|
SkipToken
|
|
60
97
|
>
|
|
61
98
|
}
|
|
@@ -102,7 +139,7 @@ export type AnyUseInfiniteQueryOptions = UseInfiniteQueryOptions<
|
|
|
102
139
|
export interface UseInfiniteQueryOptions<
|
|
103
140
|
TQueryFnData = unknown,
|
|
104
141
|
TError = DefaultError,
|
|
105
|
-
TData = TQueryFnData
|
|
142
|
+
TData = InfiniteData<TQueryFnData>,
|
|
106
143
|
TQueryKey extends QueryKey = QueryKey,
|
|
107
144
|
TPageParam = unknown,
|
|
108
145
|
> extends OmitKeyof<
|
|
@@ -127,7 +164,7 @@ export type AnyUseSuspenseInfiniteQueryOptions =
|
|
|
127
164
|
export interface UseSuspenseInfiniteQueryOptions<
|
|
128
165
|
TQueryFnData = unknown,
|
|
129
166
|
TError = DefaultError,
|
|
130
|
-
TData = TQueryFnData
|
|
167
|
+
TData = InfiniteData<TQueryFnData>,
|
|
131
168
|
TQueryKey extends QueryKey = QueryKey,
|
|
132
169
|
TPageParam = unknown,
|
|
133
170
|
> extends OmitKeyof<
|
|
@@ -161,7 +198,7 @@ export type UseSuspenseQueryResult<
|
|
|
161
198
|
TError = DefaultError,
|
|
162
199
|
> = DistributiveOmit<
|
|
163
200
|
DefinedQueryObserverResult<TData, TError>,
|
|
164
|
-
'isPlaceholderData'
|
|
201
|
+
'isPlaceholderData'
|
|
165
202
|
>
|
|
166
203
|
|
|
167
204
|
export type DefinedUseQueryResult<
|
|
@@ -184,7 +221,7 @@ export type UseSuspenseInfiniteQueryResult<
|
|
|
184
221
|
TError = DefaultError,
|
|
185
222
|
> = OmitKeyof<
|
|
186
223
|
DefinedInfiniteQueryObserverResult<TData, TError>,
|
|
187
|
-
'isPlaceholderData'
|
|
224
|
+
'isPlaceholderData'
|
|
188
225
|
>
|
|
189
226
|
|
|
190
227
|
export type AnyUseMutationOptions = UseMutationOptions<any, any, any, any>
|
package/src/useBaseQuery.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { noop, notifyManager } from '@tanstack/query-core'
|
|
2
2
|
import type {
|
|
3
3
|
QueryClient,
|
|
4
4
|
QueryKey,
|
|
@@ -19,7 +19,6 @@ import {
|
|
|
19
19
|
ensureSuspenseTimers,
|
|
20
20
|
fetchOptimistic,
|
|
21
21
|
shouldSuspend,
|
|
22
|
-
willFetch,
|
|
23
22
|
} from './suspense'
|
|
24
23
|
import type { UseBaseQueryOptions } from './types'
|
|
25
24
|
import { useSyncExternalStore } from './utils'
|
|
@@ -54,9 +53,14 @@ export function useBaseQuery<
|
|
|
54
53
|
const client = useQueryClient(queryClient)
|
|
55
54
|
const defaultedOptions = client.defaultQueryOptions(options)
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
const query = client
|
|
57
|
+
.getQueryCache()
|
|
58
|
+
.get<
|
|
59
|
+
TQueryFnData,
|
|
60
|
+
TError,
|
|
61
|
+
TQueryData,
|
|
62
|
+
TQueryKey
|
|
63
|
+
>(defaultedOptions.queryHash)
|
|
60
64
|
|
|
61
65
|
if (process.env.NODE_ENV !== 'production') {
|
|
62
66
|
if (!defaultedOptions.queryFn) {
|
|
@@ -72,15 +76,10 @@ export function useBaseQuery<
|
|
|
72
76
|
: 'optimistic'
|
|
73
77
|
|
|
74
78
|
ensureSuspenseTimers(defaultedOptions)
|
|
75
|
-
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary)
|
|
79
|
+
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary, query)
|
|
76
80
|
|
|
77
81
|
useClearResetErrorBoundary(errorResetBoundary)
|
|
78
82
|
|
|
79
|
-
// this needs to be invoked before creating the Observer because that can create a cache entry
|
|
80
|
-
const isNewCacheEntry = !client
|
|
81
|
-
.getQueryCache()
|
|
82
|
-
.get(defaultedOptions.queryHash)
|
|
83
|
-
|
|
84
83
|
const [observer] = useState(
|
|
85
84
|
() =>
|
|
86
85
|
new Observer<TQueryFnData, TError, TData, TQueryData, TQueryKey>(
|
|
@@ -126,42 +125,13 @@ export function useBaseQuery<
|
|
|
126
125
|
result,
|
|
127
126
|
errorResetBoundary,
|
|
128
127
|
throwOnError: defaultedOptions.throwOnError,
|
|
129
|
-
query
|
|
130
|
-
.getQueryCache()
|
|
131
|
-
.get<
|
|
132
|
-
TQueryFnData,
|
|
133
|
-
TError,
|
|
134
|
-
TQueryData,
|
|
135
|
-
TQueryKey
|
|
136
|
-
>(defaultedOptions.queryHash),
|
|
128
|
+
query,
|
|
137
129
|
suspense: defaultedOptions.suspense,
|
|
138
130
|
})
|
|
139
131
|
) {
|
|
140
132
|
throw result.error
|
|
141
133
|
}
|
|
142
134
|
|
|
143
|
-
;(client.getDefaultOptions().queries as any)?._experimental_afterQuery?.(
|
|
144
|
-
defaultedOptions,
|
|
145
|
-
result,
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
if (
|
|
149
|
-
defaultedOptions.experimental_prefetchInRender &&
|
|
150
|
-
!environmentManager.isServer() &&
|
|
151
|
-
willFetch(result, isRestoring)
|
|
152
|
-
) {
|
|
153
|
-
const promise = isNewCacheEntry
|
|
154
|
-
? // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
|
|
155
|
-
fetchOptimistic(defaultedOptions, observer, errorResetBoundary)
|
|
156
|
-
: // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
|
|
157
|
-
client.getQueryCache().get(defaultedOptions.queryHash)?.promise
|
|
158
|
-
|
|
159
|
-
promise?.catch(noop).finally(() => {
|
|
160
|
-
// `.updateResult()` will trigger `.#currentThenable` to finalize
|
|
161
|
-
observer.updateResult()
|
|
162
|
-
})
|
|
163
|
-
}
|
|
164
|
-
|
|
165
135
|
// Handle result property usage tracking
|
|
166
136
|
return !defaultedOptions.notifyOnChangeProps
|
|
167
137
|
? observer.trackResult(result)
|
package/src/useMutation.ts
CHANGED
|
@@ -52,8 +52,12 @@ export function useMutation<
|
|
|
52
52
|
const mutate = useCallback<
|
|
53
53
|
UseMutateFunction<TData, TError, TVariables, TOnMutateResult>
|
|
54
54
|
>(
|
|
55
|
-
(
|
|
56
|
-
|
|
55
|
+
(
|
|
56
|
+
...args: Parameters<
|
|
57
|
+
UseMutateFunction<TData, TError, TVariables, TOnMutateResult>
|
|
58
|
+
>
|
|
59
|
+
) => {
|
|
60
|
+
observer.mutate(args[0] as TVariables, args[1]).catch(noop)
|
|
57
61
|
},
|
|
58
62
|
[observer],
|
|
59
63
|
)
|
package/src/useMutationState.ts
CHANGED
|
@@ -22,25 +22,50 @@ export function useIsMutating(
|
|
|
22
22
|
).length
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
type
|
|
25
|
+
type MutationTypeFromResult<TResult> = [TResult] extends [
|
|
26
|
+
MutationState<
|
|
27
|
+
infer TData,
|
|
28
|
+
infer TError,
|
|
29
|
+
infer TVariables,
|
|
30
|
+
infer TOnMutateResult
|
|
31
|
+
>,
|
|
32
|
+
]
|
|
33
|
+
? Mutation<TData, TError, TVariables, TOnMutateResult>
|
|
34
|
+
: Mutation
|
|
35
|
+
|
|
36
|
+
type MutationStateOptions<
|
|
37
|
+
TResult = MutationState,
|
|
38
|
+
TMutation extends Mutation<any, any, any, any> =
|
|
39
|
+
MutationTypeFromResult<TResult>,
|
|
40
|
+
> = {
|
|
26
41
|
filters?: MutationFilters
|
|
27
|
-
select?: (mutation:
|
|
42
|
+
select?: (mutation: TMutation) => TResult
|
|
28
43
|
}
|
|
29
44
|
|
|
30
|
-
function getResult<
|
|
45
|
+
function getResult<
|
|
46
|
+
TResult = MutationState,
|
|
47
|
+
TMutation extends Mutation<any, any, any, any> =
|
|
48
|
+
MutationTypeFromResult<TResult>,
|
|
49
|
+
>(
|
|
31
50
|
mutationCache: MutationCache,
|
|
32
|
-
options: MutationStateOptions<TResult>,
|
|
51
|
+
options: MutationStateOptions<TResult, TMutation>,
|
|
33
52
|
): Array<TResult> {
|
|
34
53
|
return mutationCache
|
|
35
54
|
.findAll(options.filters)
|
|
36
55
|
.map(
|
|
37
56
|
(mutation): TResult =>
|
|
38
|
-
(options.select
|
|
57
|
+
(options.select
|
|
58
|
+
? options.select(mutation as TMutation)
|
|
59
|
+
: mutation.state) as TResult,
|
|
39
60
|
)
|
|
40
61
|
}
|
|
41
62
|
|
|
42
|
-
export function useMutationState<
|
|
43
|
-
|
|
63
|
+
export function useMutationState<
|
|
64
|
+
TResult = MutationState,
|
|
65
|
+
TMutation extends Mutation<any, any, any, any> =
|
|
66
|
+
MutationTypeFromResult<TResult>,
|
|
67
|
+
>(
|
|
68
|
+
options: MutationStateOptions<TResult, TMutation> = {},
|
|
44
69
|
queryClient?: QueryClient,
|
|
45
70
|
): Array<TResult> {
|
|
46
71
|
const mutationCache = useQueryClient(queryClient).getMutationCache()
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
DefaultError,
|
|
3
|
-
FetchInfiniteQueryOptions,
|
|
4
|
-
QueryClient,
|
|
5
|
-
QueryKey,
|
|
6
|
-
} from '@tanstack/query-core'
|
|
7
|
-
|
|
1
|
+
import { noop } from '@tanstack/query-core'
|
|
8
2
|
import { useQueryClient } from './QueryClientProvider'
|
|
9
3
|
|
|
4
|
+
import type { DefaultError, QueryClient, QueryKey } from '@tanstack/query-core'
|
|
5
|
+
import type { UsePrefetchInfiniteQueryOptions } from './types'
|
|
6
|
+
|
|
10
7
|
export function usePrefetchInfiniteQuery<
|
|
11
8
|
TQueryFnData = unknown,
|
|
12
9
|
TError = DefaultError,
|
|
@@ -14,7 +11,7 @@ export function usePrefetchInfiniteQuery<
|
|
|
14
11
|
TQueryKey extends QueryKey = QueryKey,
|
|
15
12
|
TPageParam = unknown,
|
|
16
13
|
>(
|
|
17
|
-
options:
|
|
14
|
+
options: UsePrefetchInfiniteQueryOptions<
|
|
18
15
|
TQueryFnData,
|
|
19
16
|
TError,
|
|
20
17
|
TData,
|
|
@@ -26,6 +23,6 @@ export function usePrefetchInfiniteQuery<
|
|
|
26
23
|
const client = useQueryClient(queryClient)
|
|
27
24
|
|
|
28
25
|
if (!client.getQueryState(options.queryKey)) {
|
|
29
|
-
client.
|
|
26
|
+
void client.infiniteQuery(options).catch(noop)
|
|
30
27
|
}
|
|
31
28
|
}
|
package/src/usePrefetchQuery.tsx
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { noop } from '@tanstack/query-core'
|
|
3
2
|
import { useQueryClient } from './QueryClientProvider'
|
|
3
|
+
|
|
4
|
+
import type { DefaultError, QueryClient, QueryKey } from '@tanstack/query-core'
|
|
4
5
|
import type { UsePrefetchQueryOptions } from './types'
|
|
5
6
|
|
|
6
7
|
export function usePrefetchQuery<
|
|
7
8
|
TQueryFnData = unknown,
|
|
8
9
|
TError = DefaultError,
|
|
9
10
|
TData = TQueryFnData,
|
|
11
|
+
TQueryData = TQueryFnData,
|
|
10
12
|
TQueryKey extends QueryKey = QueryKey,
|
|
11
13
|
>(
|
|
12
|
-
options: UsePrefetchQueryOptions<
|
|
14
|
+
options: UsePrefetchQueryOptions<
|
|
15
|
+
TQueryFnData,
|
|
16
|
+
TError,
|
|
17
|
+
TData,
|
|
18
|
+
TQueryData,
|
|
19
|
+
TQueryKey
|
|
20
|
+
>,
|
|
13
21
|
queryClient?: QueryClient,
|
|
14
22
|
) {
|
|
15
23
|
const client = useQueryClient(queryClient)
|
|
16
24
|
|
|
17
25
|
if (!client.getQueryState(options.queryKey)) {
|
|
18
|
-
client.
|
|
26
|
+
void client.fetchQuery(options).catch(noop)
|
|
19
27
|
}
|
|
20
28
|
}
|
package/src/useQueries.ts
CHANGED
|
@@ -241,9 +241,10 @@ export function useQueries<
|
|
|
241
241
|
[queries, client, isRestoring],
|
|
242
242
|
)
|
|
243
243
|
|
|
244
|
-
defaultedQueries.forEach((
|
|
245
|
-
ensureSuspenseTimers(
|
|
246
|
-
|
|
244
|
+
defaultedQueries.forEach((queryOptions) => {
|
|
245
|
+
ensureSuspenseTimers(queryOptions)
|
|
246
|
+
const query = client.getQueryCache().get(queryOptions.queryHash)
|
|
247
|
+
ensurePreventErrorBoundaryRetry(queryOptions, errorResetBoundary, query)
|
|
247
248
|
})
|
|
248
249
|
|
|
249
250
|
useClearResetErrorBoundary(errorResetBoundary)
|
package/src/useQuery.ts
CHANGED
|
@@ -20,7 +20,7 @@ export function useQuery<
|
|
|
20
20
|
>(
|
|
21
21
|
options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
22
22
|
queryClient?: QueryClient,
|
|
23
|
-
): DefinedUseQueryResult<
|
|
23
|
+
): DefinedUseQueryResult<TData, TError>
|
|
24
24
|
|
|
25
25
|
export function useQuery<
|
|
26
26
|
TQueryFnData = unknown,
|
|
@@ -30,7 +30,7 @@ export function useQuery<
|
|
|
30
30
|
>(
|
|
31
31
|
options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
32
32
|
queryClient?: QueryClient,
|
|
33
|
-
): UseQueryResult<
|
|
33
|
+
): UseQueryResult<TData, TError>
|
|
34
34
|
|
|
35
35
|
export function useQuery<
|
|
36
36
|
TQueryFnData = unknown,
|
|
@@ -40,7 +40,7 @@ export function useQuery<
|
|
|
40
40
|
>(
|
|
41
41
|
options: UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
42
42
|
queryClient?: QueryClient,
|
|
43
|
-
): UseQueryResult<
|
|
43
|
+
): UseQueryResult<TData, TError>
|
|
44
44
|
|
|
45
45
|
export function useQuery(options: UseQueryOptions, queryClient?: QueryClient) {
|
|
46
46
|
return useBaseQuery(options, QueryObserver, queryClient)
|