@tanstack/vue-query 5.104.1 → 5.104.2
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/legacy/devtools/devtools.cjs +6 -0
- package/build/legacy/devtools/devtools.cjs.map +1 -1
- package/build/legacy/devtools/devtools.d.cts +7 -1
- package/build/legacy/devtools/devtools.d.cts.map +1 -1
- package/build/legacy/devtools/devtools.d.ts +7 -1
- package/build/legacy/devtools/devtools.d.ts.map +1 -1
- package/build/legacy/devtools/devtools.js +6 -0
- package/build/legacy/devtools/devtools.js.map +1 -1
- package/build/legacy/devtools/utils.cjs +21 -0
- package/build/legacy/devtools/utils.cjs.map +1 -1
- package/build/legacy/devtools/utils.d.cts +21 -0
- package/build/legacy/devtools/utils.d.cts.map +1 -1
- package/build/legacy/devtools/utils.d.ts +21 -0
- package/build/legacy/devtools/utils.d.ts.map +1 -1
- package/build/legacy/devtools/utils.js +21 -0
- package/build/legacy/devtools/utils.js.map +1 -1
- package/build/legacy/index.d.cts +6 -6
- package/build/legacy/index.d.ts +6 -6
- package/build/legacy/{infiniteQueryOptions-NucMX_M_.d.ts → infiniteQueryOptions-BaoKhSzb.d.ts} +26 -27
- package/build/legacy/infiniteQueryOptions-BaoKhSzb.d.ts.map +1 -0
- package/build/legacy/{infiniteQueryOptions-CnTRbIP5.d.cts → infiniteQueryOptions-ClNe2-FB.d.cts} +26 -27
- package/build/legacy/infiniteQueryOptions-ClNe2-FB.d.cts.map +1 -0
- package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.cts +1 -1
- package/build/legacy/infiniteQueryOptions.d.ts +1 -1
- package/build/legacy/infiniteQueryOptions.js.map +1 -1
- package/build/legacy/mutationCache.cjs.map +1 -1
- package/build/legacy/mutationCache.d.cts +1 -1
- package/build/legacy/mutationCache.d.cts.map +1 -1
- package/build/legacy/mutationCache.d.ts +1 -1
- package/build/legacy/mutationCache.d.ts.map +1 -1
- package/build/legacy/mutationCache.js.map +1 -1
- package/build/legacy/mutationOptions.cjs.map +1 -1
- package/build/legacy/mutationOptions.d.cts +5 -13
- package/build/legacy/mutationOptions.d.cts.map +1 -1
- package/build/legacy/mutationOptions.d.ts +5 -13
- package/build/legacy/mutationOptions.d.ts.map +1 -1
- package/build/legacy/mutationOptions.js.map +1 -1
- package/build/legacy/queryCache.cjs.map +1 -1
- package/build/legacy/queryCache.d.cts +1 -1
- package/build/legacy/queryCache.d.cts.map +1 -1
- package/build/legacy/queryCache.d.ts +1 -1
- package/build/legacy/queryCache.d.ts.map +1 -1
- package/build/legacy/queryCache.js.map +1 -1
- package/build/legacy/{queryClient-Bn2Ql_Lu.d.cts → queryClient-BK9W57Qu.d.cts} +3 -3
- package/build/legacy/queryClient-BK9W57Qu.d.cts.map +1 -0
- package/build/legacy/{queryClient-B6mLtXOj.d.ts → queryClient-BoBzDWAZ.d.ts} +3 -3
- package/build/legacy/queryClient-BoBzDWAZ.d.ts.map +1 -0
- package/build/legacy/queryClient.cjs.map +1 -1
- package/build/legacy/queryClient.d.cts +1 -1
- package/build/legacy/queryClient.d.ts +1 -1
- package/build/legacy/queryClient.js.map +1 -1
- package/build/{modern/queryOptions-CwqQgQmQ.d.cts → legacy/queryOptions-BvmZtmiU.d.cts} +14 -19
- package/build/legacy/queryOptions-BvmZtmiU.d.cts.map +1 -0
- package/build/{modern/queryOptions-CsM5TXD2.d.ts → legacy/queryOptions-gpn5D4rf.d.ts} +14 -19
- package/build/legacy/queryOptions-gpn5D4rf.d.ts.map +1 -0
- package/build/legacy/queryOptions.cjs.map +1 -1
- package/build/legacy/queryOptions.d.cts +1 -1
- package/build/legacy/queryOptions.d.ts +1 -1
- package/build/legacy/queryOptions.js.map +1 -1
- package/build/{modern/types-JpJB72CS.d.cts → legacy/types-sdZdiLgo.d.cts} +48 -3
- package/build/legacy/types-sdZdiLgo.d.cts.map +1 -0
- package/build/legacy/{types-JpJB72CS.d.cts → types-sdZdiLgo.d.ts} +48 -3
- package/build/legacy/types-sdZdiLgo.d.ts.map +1 -0
- package/build/legacy/types.d.cts +1 -1
- package/build/legacy/types.d.ts +1 -1
- package/build/legacy/useBaseQuery.cjs +1 -1
- package/build/legacy/useBaseQuery.cjs.map +1 -1
- package/build/legacy/useBaseQuery.d.cts +1 -1
- package/build/legacy/useBaseQuery.d.ts +1 -1
- package/build/legacy/useBaseQuery.js +1 -1
- package/build/legacy/useBaseQuery.js.map +1 -1
- package/build/legacy/useInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useInfiniteQuery.d.cts +1 -1
- package/build/legacy/useInfiniteQuery.d.ts +1 -1
- package/build/legacy/useInfiniteQuery.js.map +1 -1
- package/build/legacy/useIsFetching.cjs +0 -3
- package/build/legacy/useIsFetching.cjs.map +1 -1
- package/build/legacy/useIsFetching.d.cts +6 -5
- package/build/legacy/useIsFetching.d.cts.map +1 -1
- package/build/legacy/useIsFetching.d.ts +6 -5
- package/build/legacy/useIsFetching.d.ts.map +1 -1
- package/build/legacy/useIsFetching.js +0 -3
- package/build/legacy/useIsFetching.js.map +1 -1
- package/build/legacy/useMutation.cjs +2 -8
- package/build/legacy/useMutation.cjs.map +1 -1
- package/build/legacy/useMutation.d.cts +17 -11
- package/build/legacy/useMutation.d.cts.map +1 -1
- package/build/legacy/useMutation.d.ts +17 -11
- package/build/legacy/useMutation.d.ts.map +1 -1
- package/build/legacy/useMutation.js +2 -8
- package/build/legacy/useMutation.js.map +1 -1
- package/build/legacy/useMutationState.cjs +7 -6
- package/build/legacy/useMutationState.cjs.map +1 -1
- package/build/legacy/useMutationState.d.cts +16 -8
- package/build/legacy/useMutationState.d.cts.map +1 -1
- package/build/legacy/useMutationState.d.ts +16 -8
- package/build/legacy/useMutationState.d.ts.map +1 -1
- package/build/legacy/useMutationState.js +7 -6
- package/build/legacy/useMutationState.js.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.cjs +5 -3
- package/build/legacy/usePrefetchInfiniteQuery.cjs.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.cts +6 -5
- package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.ts +6 -5
- package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.js +5 -3
- package/build/legacy/usePrefetchInfiniteQuery.js.map +1 -1
- package/build/legacy/usePrefetchQuery.cjs +5 -3
- package/build/legacy/usePrefetchQuery.cjs.map +1 -1
- package/build/legacy/usePrefetchQuery.d.cts +6 -5
- package/build/legacy/usePrefetchQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchQuery.d.ts +6 -5
- package/build/legacy/usePrefetchQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchQuery.js +5 -3
- package/build/legacy/usePrefetchQuery.js.map +1 -1
- package/build/legacy/useQueries.cjs +1 -4
- package/build/legacy/useQueries.cjs.map +1 -1
- package/build/legacy/useQueries.d.cts +4 -7
- package/build/legacy/useQueries.d.cts.map +1 -1
- package/build/legacy/useQueries.d.ts +4 -7
- package/build/legacy/useQueries.d.ts.map +1 -1
- package/build/legacy/useQueries.js +1 -4
- package/build/legacy/useQueries.js.map +1 -1
- package/build/legacy/useQuery.cjs.map +1 -1
- package/build/legacy/useQuery.d.cts +12 -15
- package/build/legacy/useQuery.d.cts.map +1 -1
- package/build/legacy/useQuery.d.ts +12 -15
- package/build/legacy/useQuery.d.ts.map +1 -1
- package/build/legacy/useQuery.js.map +1 -1
- package/build/legacy/useQueryClient.cjs +3 -3
- package/build/legacy/useQueryClient.cjs.map +1 -1
- package/build/legacy/useQueryClient.d.cts +4 -4
- package/build/legacy/useQueryClient.d.ts +4 -4
- package/build/legacy/useQueryClient.js +3 -3
- package/build/legacy/useQueryClient.js.map +1 -1
- package/build/legacy/utils.cjs +54 -6
- package/build/legacy/utils.cjs.map +1 -1
- package/build/legacy/utils.d.cts +34 -7
- package/build/legacy/utils.d.cts.map +1 -1
- package/build/legacy/utils.d.ts +34 -7
- package/build/legacy/utils.d.ts.map +1 -1
- package/build/legacy/utils.js +54 -6
- package/build/legacy/utils.js.map +1 -1
- package/build/legacy/vueQueryPlugin.cjs +0 -3
- package/build/legacy/vueQueryPlugin.cjs.map +1 -1
- package/build/legacy/vueQueryPlugin.d.cts +6 -5
- package/build/legacy/vueQueryPlugin.d.cts.map +1 -1
- package/build/legacy/vueQueryPlugin.d.ts +6 -5
- package/build/legacy/vueQueryPlugin.d.ts.map +1 -1
- package/build/legacy/vueQueryPlugin.js +0 -3
- package/build/legacy/vueQueryPlugin.js.map +1 -1
- package/build/modern/devtools/devtools.cjs +6 -0
- package/build/modern/devtools/devtools.cjs.map +1 -1
- package/build/modern/devtools/devtools.d.cts +7 -1
- package/build/modern/devtools/devtools.d.cts.map +1 -1
- package/build/modern/devtools/devtools.d.ts +7 -1
- package/build/modern/devtools/devtools.d.ts.map +1 -1
- package/build/modern/devtools/devtools.js +6 -0
- package/build/modern/devtools/devtools.js.map +1 -1
- package/build/modern/devtools/utils.cjs +21 -0
- package/build/modern/devtools/utils.cjs.map +1 -1
- package/build/modern/devtools/utils.d.cts +21 -0
- package/build/modern/devtools/utils.d.cts.map +1 -1
- package/build/modern/devtools/utils.d.ts +21 -0
- package/build/modern/devtools/utils.d.ts.map +1 -1
- package/build/modern/devtools/utils.js +21 -0
- package/build/modern/devtools/utils.js.map +1 -1
- package/build/modern/index.d.cts +6 -6
- package/build/modern/index.d.ts +6 -6
- package/build/modern/{infiniteQueryOptions-NucMX_M_.d.ts → infiniteQueryOptions-BaoKhSzb.d.ts} +26 -27
- package/build/modern/infiniteQueryOptions-BaoKhSzb.d.ts.map +1 -0
- package/build/modern/{infiniteQueryOptions-CnTRbIP5.d.cts → infiniteQueryOptions-ClNe2-FB.d.cts} +26 -27
- package/build/modern/infiniteQueryOptions-ClNe2-FB.d.cts.map +1 -0
- package/build/modern/infiniteQueryOptions.cjs.map +1 -1
- package/build/modern/infiniteQueryOptions.d.cts +1 -1
- package/build/modern/infiniteQueryOptions.d.ts +1 -1
- package/build/modern/infiniteQueryOptions.js.map +1 -1
- package/build/modern/mutationCache.cjs.map +1 -1
- package/build/modern/mutationCache.d.cts +1 -1
- package/build/modern/mutationCache.d.cts.map +1 -1
- package/build/modern/mutationCache.d.ts +1 -1
- package/build/modern/mutationCache.d.ts.map +1 -1
- package/build/modern/mutationCache.js.map +1 -1
- package/build/modern/mutationOptions.cjs.map +1 -1
- package/build/modern/mutationOptions.d.cts +5 -13
- package/build/modern/mutationOptions.d.cts.map +1 -1
- package/build/modern/mutationOptions.d.ts +5 -13
- package/build/modern/mutationOptions.d.ts.map +1 -1
- package/build/modern/mutationOptions.js.map +1 -1
- package/build/modern/queryCache.cjs.map +1 -1
- package/build/modern/queryCache.d.cts +1 -1
- package/build/modern/queryCache.d.cts.map +1 -1
- package/build/modern/queryCache.d.ts +1 -1
- package/build/modern/queryCache.d.ts.map +1 -1
- package/build/modern/queryCache.js.map +1 -1
- package/build/modern/{queryClient-Bn2Ql_Lu.d.cts → queryClient-BK9W57Qu.d.cts} +3 -3
- package/build/modern/queryClient-BK9W57Qu.d.cts.map +1 -0
- package/build/modern/{queryClient-B6mLtXOj.d.ts → queryClient-BoBzDWAZ.d.ts} +3 -3
- package/build/modern/queryClient-BoBzDWAZ.d.ts.map +1 -0
- package/build/modern/queryClient.cjs.map +1 -1
- package/build/modern/queryClient.d.cts +1 -1
- package/build/modern/queryClient.d.ts +1 -1
- package/build/modern/queryClient.js.map +1 -1
- package/build/{legacy/queryOptions-CwqQgQmQ.d.cts → modern/queryOptions-BvmZtmiU.d.cts} +14 -19
- package/build/modern/queryOptions-BvmZtmiU.d.cts.map +1 -0
- package/build/{legacy/queryOptions-CsM5TXD2.d.ts → modern/queryOptions-gpn5D4rf.d.ts} +14 -19
- package/build/modern/queryOptions-gpn5D4rf.d.ts.map +1 -0
- package/build/modern/queryOptions.cjs.map +1 -1
- package/build/modern/queryOptions.d.cts +1 -1
- package/build/modern/queryOptions.d.ts +1 -1
- package/build/modern/queryOptions.js.map +1 -1
- package/build/modern/{types-JpJB72CS.d.ts → types-sdZdiLgo.d.cts} +48 -3
- package/build/modern/types-sdZdiLgo.d.cts.map +1 -0
- package/build/{legacy/types-JpJB72CS.d.ts → modern/types-sdZdiLgo.d.ts} +48 -3
- package/build/modern/types-sdZdiLgo.d.ts.map +1 -0
- package/build/modern/types.d.cts +1 -1
- package/build/modern/types.d.ts +1 -1
- package/build/modern/useBaseQuery.cjs +1 -1
- package/build/modern/useBaseQuery.cjs.map +1 -1
- package/build/modern/useBaseQuery.d.cts +1 -1
- package/build/modern/useBaseQuery.d.ts +1 -1
- package/build/modern/useBaseQuery.js +1 -1
- package/build/modern/useBaseQuery.js.map +1 -1
- package/build/modern/useInfiniteQuery.cjs.map +1 -1
- package/build/modern/useInfiniteQuery.d.cts +1 -1
- package/build/modern/useInfiniteQuery.d.ts +1 -1
- package/build/modern/useInfiniteQuery.js.map +1 -1
- package/build/modern/useIsFetching.cjs +0 -3
- package/build/modern/useIsFetching.cjs.map +1 -1
- package/build/modern/useIsFetching.d.cts +6 -5
- package/build/modern/useIsFetching.d.cts.map +1 -1
- package/build/modern/useIsFetching.d.ts +6 -5
- package/build/modern/useIsFetching.d.ts.map +1 -1
- package/build/modern/useIsFetching.js +0 -3
- package/build/modern/useIsFetching.js.map +1 -1
- package/build/modern/useMutation.cjs +2 -8
- package/build/modern/useMutation.cjs.map +1 -1
- package/build/modern/useMutation.d.cts +17 -11
- package/build/modern/useMutation.d.cts.map +1 -1
- package/build/modern/useMutation.d.ts +17 -11
- package/build/modern/useMutation.d.ts.map +1 -1
- package/build/modern/useMutation.js +2 -8
- package/build/modern/useMutation.js.map +1 -1
- package/build/modern/useMutationState.cjs +7 -6
- package/build/modern/useMutationState.cjs.map +1 -1
- package/build/modern/useMutationState.d.cts +16 -8
- package/build/modern/useMutationState.d.cts.map +1 -1
- package/build/modern/useMutationState.d.ts +16 -8
- package/build/modern/useMutationState.d.ts.map +1 -1
- package/build/modern/useMutationState.js +7 -6
- package/build/modern/useMutationState.js.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.cjs +5 -3
- package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.cts +6 -5
- package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.ts +6 -5
- package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.js +5 -3
- package/build/modern/usePrefetchInfiniteQuery.js.map +1 -1
- package/build/modern/usePrefetchQuery.cjs +5 -3
- package/build/modern/usePrefetchQuery.cjs.map +1 -1
- package/build/modern/usePrefetchQuery.d.cts +6 -5
- package/build/modern/usePrefetchQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchQuery.d.ts +6 -5
- package/build/modern/usePrefetchQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchQuery.js +5 -3
- package/build/modern/usePrefetchQuery.js.map +1 -1
- package/build/modern/useQueries.cjs +1 -4
- package/build/modern/useQueries.cjs.map +1 -1
- package/build/modern/useQueries.d.cts +4 -7
- package/build/modern/useQueries.d.cts.map +1 -1
- package/build/modern/useQueries.d.ts +4 -7
- package/build/modern/useQueries.d.ts.map +1 -1
- package/build/modern/useQueries.js +1 -4
- package/build/modern/useQueries.js.map +1 -1
- package/build/modern/useQuery.cjs.map +1 -1
- package/build/modern/useQuery.d.cts +12 -15
- package/build/modern/useQuery.d.cts.map +1 -1
- package/build/modern/useQuery.d.ts +12 -15
- package/build/modern/useQuery.d.ts.map +1 -1
- package/build/modern/useQuery.js.map +1 -1
- package/build/modern/useQueryClient.cjs +3 -3
- package/build/modern/useQueryClient.cjs.map +1 -1
- package/build/modern/useQueryClient.d.cts +4 -4
- package/build/modern/useQueryClient.d.ts +4 -4
- package/build/modern/useQueryClient.js +3 -3
- package/build/modern/useQueryClient.js.map +1 -1
- package/build/modern/utils.cjs +54 -6
- package/build/modern/utils.cjs.map +1 -1
- package/build/modern/utils.d.cts +34 -7
- package/build/modern/utils.d.cts.map +1 -1
- package/build/modern/utils.d.ts +34 -7
- package/build/modern/utils.d.ts.map +1 -1
- package/build/modern/utils.js +54 -6
- package/build/modern/utils.js.map +1 -1
- package/build/modern/vueQueryPlugin.cjs +0 -3
- package/build/modern/vueQueryPlugin.cjs.map +1 -1
- package/build/modern/vueQueryPlugin.d.cts +6 -5
- package/build/modern/vueQueryPlugin.d.cts.map +1 -1
- package/build/modern/vueQueryPlugin.d.ts +6 -5
- package/build/modern/vueQueryPlugin.d.ts.map +1 -1
- package/build/modern/vueQueryPlugin.js +0 -3
- package/build/modern/vueQueryPlugin.js.map +1 -1
- package/package.json +4 -5
- package/src/devtools/devtools.ts +6 -0
- package/src/devtools/utils.ts +21 -0
- package/src/index.ts +5 -1
- package/src/infiniteQueryOptions.ts +2 -8
- package/src/mutationCache.ts +4 -2
- package/src/mutationOptions.ts +4 -12
- package/src/queryCache.ts +6 -2
- package/src/queryClient.ts +55 -52
- package/src/queryOptions.ts +22 -25
- package/src/types.ts +47 -2
- package/src/useBaseQuery.ts +8 -2
- package/src/useInfiniteQuery.ts +15 -14
- package/src/useIsFetching.ts +6 -4
- package/src/useMutation.ts +15 -9
- package/src/useMutationState.ts +23 -7
- package/src/usePrefetchInfiniteQuery.ts +9 -3
- package/src/usePrefetchQuery.ts +9 -3
- package/src/useQueries.ts +1 -4
- package/src/useQuery.ts +10 -12
- package/src/useQueryClient.ts +3 -3
- package/src/utils.ts +55 -9
- package/src/vueQueryPlugin.ts +4 -3
- package/build/legacy/infiniteQueryOptions-CnTRbIP5.d.cts.map +0 -1
- package/build/legacy/infiniteQueryOptions-NucMX_M_.d.ts.map +0 -1
- package/build/legacy/queryClient-B6mLtXOj.d.ts.map +0 -1
- package/build/legacy/queryClient-Bn2Ql_Lu.d.cts.map +0 -1
- package/build/legacy/queryOptions-CsM5TXD2.d.ts.map +0 -1
- package/build/legacy/queryOptions-CwqQgQmQ.d.cts.map +0 -1
- package/build/legacy/types-JpJB72CS.d.cts.map +0 -1
- package/build/legacy/types-JpJB72CS.d.ts.map +0 -1
- package/build/modern/infiniteQueryOptions-CnTRbIP5.d.cts.map +0 -1
- package/build/modern/infiniteQueryOptions-NucMX_M_.d.ts.map +0 -1
- package/build/modern/queryClient-B6mLtXOj.d.ts.map +0 -1
- package/build/modern/queryClient-Bn2Ql_Lu.d.cts.map +0 -1
- package/build/modern/queryOptions-CsM5TXD2.d.ts.map +0 -1
- package/build/modern/queryOptions-CwqQgQmQ.d.cts.map +0 -1
- package/build/modern/types-JpJB72CS.d.cts.map +0 -1
- package/build/modern/types-JpJB72CS.d.ts.map +0 -1
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import { s as MaybeRefOrGetter } from "./types-
|
|
2
|
-
import { i as UndefinedInitialQueryOptions, o as UseQueryOptions, t as DefinedInitialQueryOptions } from "./queryOptions-
|
|
3
|
-
import { t as QueryClient$1 } from "./queryClient-
|
|
4
|
-
import { s as UseBaseQueryReturnType } from "./infiniteQueryOptions-
|
|
1
|
+
import { s as MaybeRefOrGetter } from "./types-sdZdiLgo.js";
|
|
2
|
+
import { i as UndefinedInitialQueryOptions, o as UseQueryOptions, t as DefinedInitialQueryOptions } from "./queryOptions-gpn5D4rf.js";
|
|
3
|
+
import { t as QueryClient$1 } from "./queryClient-BoBzDWAZ.js";
|
|
4
|
+
import { s as UseBaseQueryReturnType } from "./infiniteQueryOptions-BaoKhSzb.js";
|
|
5
5
|
import { DefaultError, DefinedQueryObserverResult, QueryKey } from "@tanstack/query-core";
|
|
6
6
|
//#region src/useQuery.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* The result of `useQuery` when `initialData` is omitted or may be `undefined` — `data` may be `undefined`
|
|
9
|
+
* while the query is `pending`. See {@link UseBaseQueryReturnType}.
|
|
10
|
+
*/
|
|
7
11
|
export type UseQueryReturnType<TData, TError> = UseBaseQueryReturnType<TData, TError>;
|
|
12
|
+
/**
|
|
13
|
+
* The result of `useQuery` when `initialData` is set — `data` is never `undefined` (unless a `select` changes
|
|
14
|
+
* `TData` to include `undefined`).
|
|
15
|
+
*/
|
|
8
16
|
export type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<TData, TError, DefinedQueryObserverResult<TData, TError>>;
|
|
9
17
|
/**
|
|
10
18
|
* This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
|
|
@@ -14,7 +22,6 @@ export type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<TD
|
|
|
14
22
|
* (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and
|
|
15
23
|
* reactive getters as individual entries. Other options are read once when passed as a plain value, and stay
|
|
16
24
|
* reactive when passed as a `ref` or a `computed`.
|
|
17
|
-
*
|
|
18
25
|
* @param options - The {@link DefinedInitialQueryOptions} to use — everything you can pass to `useQuery`, with
|
|
19
26
|
* `initialData` set.
|
|
20
27
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
|
|
@@ -22,7 +29,6 @@ export type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<TD
|
|
|
22
29
|
* @returns The current query result, typed so that `data` is never `undefined` (unless a `select` changes
|
|
23
30
|
* `TData` to include `undefined`). `status` never resolves to `pending` in this overload's type, since
|
|
24
31
|
* `initialData` guarantees data upfront.
|
|
25
|
-
*
|
|
26
32
|
* @example
|
|
27
33
|
* ```vue
|
|
28
34
|
* <script setup lang="ts">
|
|
@@ -51,13 +57,11 @@ export declare function useQuery<TQueryFnData = unknown, TError = DefaultError,
|
|
|
51
57
|
* (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and
|
|
52
58
|
* reactive getters as individual entries. Other options are read once when passed as a plain value, and stay
|
|
53
59
|
* reactive when passed as a `ref` or a `computed`.
|
|
54
|
-
*
|
|
55
60
|
* @param options - The {@link UndefinedInitialQueryOptions} to use — everything you can pass to `useQuery`.
|
|
56
61
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
|
|
57
62
|
* will be used.
|
|
58
63
|
* @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if
|
|
59
64
|
* the last fetch attempt failed, or `success` if the query has data to display.
|
|
60
|
-
*
|
|
61
65
|
* @example
|
|
62
66
|
* A query key built from a reactive `ref` — the query refetches whenever `postId` changes:
|
|
63
67
|
* ```vue
|
|
@@ -78,7 +82,6 @@ export declare function useQuery<TQueryFnData = unknown, TError = DefaultError,
|
|
|
78
82
|
* <h1 v-else>{{ data.title }}</h1>
|
|
79
83
|
* </template>
|
|
80
84
|
* ```
|
|
81
|
-
*
|
|
82
85
|
* @example
|
|
83
86
|
* `select` derives whatever `data` a component needs from the cached value, without changing what's
|
|
84
87
|
* actually stored in the cache — the cache still holds the full `Post[]`, but `data` here is a `number`:
|
|
@@ -99,7 +102,6 @@ export declare function useQuery<TQueryFnData = unknown, TError = DefaultError,
|
|
|
99
102
|
* <span v-else>{{ data }} posts</span>
|
|
100
103
|
* </template>
|
|
101
104
|
* ```
|
|
102
|
-
*
|
|
103
105
|
* @example
|
|
104
106
|
* A dependent query, only enabled once `postId` is set — use `isLoading`, not `isPending`, so the
|
|
105
107
|
* loading state doesn't show while the query is disabled:
|
|
@@ -124,7 +126,6 @@ export declare function useQuery<TQueryFnData = unknown, TError = DefaultError,
|
|
|
124
126
|
* <h1 v-else>{{ data?.title }}</h1>
|
|
125
127
|
* </template>
|
|
126
128
|
* ```
|
|
127
|
-
*
|
|
128
129
|
* @example
|
|
129
130
|
* Seeding a detail query from an already-cached list, to skip the loading state. `initialDataUpdatedAt` carries
|
|
130
131
|
* over the list's own fetch time, so that if you set a `staleTime`, it's measured from when the list was
|
|
@@ -153,7 +154,6 @@ export declare function useQuery<TQueryFnData = unknown, TError = DefaultError,
|
|
|
153
154
|
* <h1 v-else>{{ data?.title }}</h1>
|
|
154
155
|
* </template>
|
|
155
156
|
* ```
|
|
156
|
-
*
|
|
157
157
|
* @example
|
|
158
158
|
* Paginated data, keeping the previous page's data visible while the next page loads:
|
|
159
159
|
* ```vue
|
|
@@ -193,12 +193,10 @@ export declare function useQuery<TQueryFnData = unknown, TError = DefaultError,
|
|
|
193
193
|
*
|
|
194
194
|
* When `options` itself is a reactive getter, the whole object is re-evaluated on every change to its
|
|
195
195
|
* dependencies, so any option inside it — not just `queryKey` and `enabled` — can change over time.
|
|
196
|
-
*
|
|
197
196
|
* @param options - A `ref`, plain value, or reactive getter resolving to the {@link UseQueryOptions} to use.
|
|
198
197
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
|
|
199
198
|
* will be used.
|
|
200
199
|
* @returns The current query result, with `data` typed as possibly `undefined`.
|
|
201
|
-
*
|
|
202
200
|
* @example
|
|
203
201
|
* Passing a whole-options getter so `staleTime` reacts to a setting stored elsewhere, not just `queryKey`:
|
|
204
202
|
* ```vue
|
|
@@ -218,7 +216,6 @@ export declare function useQuery<TQueryFnData = unknown, TError = DefaultError,
|
|
|
218
216
|
* <h1 v-if="data">{{ data.title }}</h1>
|
|
219
217
|
* </template>
|
|
220
218
|
* ```
|
|
221
|
-
*
|
|
222
219
|
* @example
|
|
223
220
|
* `skipToken` disables the query in a type-safe way, without a non-null assertion on `props.postId` —
|
|
224
221
|
* `queryFn` is only ever called when it's defined. The whole-options getter re-evaluates `queryFn` on every
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuery.d.ts","names":["QueryClient"],"sources":["../../src/useQuery.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useQuery.d.ts","names":["QueryClient"],"sources":["../../src/useQuery.ts"],"mappings":";;;;;;;;;;YAoBY,mBAAmB,OAAO,UAAU,uBAC9C,OACA;;;;;YAOU,0BAA0B,OAAO,UAAU,uBACrD,OACA,QACA,2BAA2B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwCpB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,2BAA2B,cAAc,QAAQ,OAAO,YACjE,cAAcA,gBACb,0BAA0B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmIpB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,6BAA6B,cAAc,QAAQ,OAAO,YACnE,cAAcA,gBACb,mBAAmB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAiEb,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,iBACP,gBAAgB,cAAc,QAAQ,OAAO,cAAc,aAE7D,cAAcA,gBACb,mBAAmB,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuery.js","names":[],"sources":["../../src/useQuery.ts"],"sourcesContent":["import { QueryObserver } from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n DefaultError,\n DefinedQueryObserverResult,\n QueryKey,\n} from '@tanstack/query-core'\nimport type { UseBaseQueryReturnType } from './useBaseQuery'\nimport type { MaybeRefOrGetter } from './types'\nimport type { QueryClient } from './queryClient'\nimport type {\n DefinedInitialQueryOptions,\n UndefinedInitialQueryOptions,\n UseQueryOptions,\n} from './queryOptions'\n\nexport type UseQueryReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError\n>\n\nexport type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError,\n DefinedQueryObserverResult<TData, TError>\n>\n\n/**\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless\n * a `select` changes `TData` to include `undefined`).\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay\n * reactive when passed as a `ref` or a `computed`.\n *\n * @param options - The {@link DefinedInitialQueryOptions} to use — everything you can pass to `useQuery`, with\n * `initialData` set.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result, typed so that `data` is never `undefined` (unless a `select` changes\n * `TData` to include `undefined`). `status` never resolves to `pending` in this overload's type, since\n * `initialData` guarantees data upfront.\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const { data, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <ul>\n * <li v-for=\"post in data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryDefinedReturnType<TData, TError>\n\n/**\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay\n * reactive when passed as a `ref` or a `computed`.\n *\n * @param options - The {@link UndefinedInitialQueryOptions} to use — everything you can pass to `useQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if\n * the last fetch attempt failed, or `success` if the query has data to display.\n *\n * @example\n * A query key built from a reactive `ref` — the query refetches whenever `postId` changes:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const postId = ref(1)\n * const { status, data, error } = useQuery({\n * queryKey: ['post', postId],\n * queryFn: () => fetchPost(postId.value),\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"status === 'pending'\">Loading...</span>\n * <span v-else-if=\"status === 'error'\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data.title }}</h1>\n * </template>\n * ```\n *\n * @example\n * `select` derives whatever `data` a component needs from the cached value, without changing what's\n * actually stored in the cache — the cache still holds the full `Post[]`, but `data` here is a `number`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const { data, isPending, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * select: (posts) => posts.length,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isPending\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <span v-else>{{ data }} posts</span>\n * </template>\n * ```\n *\n * @example\n * A dependent query, only enabled once `postId` is set — use `isLoading`, not `isPending`, so the\n * loading state doesn't show while the query is disabled:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number | undefined }>()\n *\n * const { data, isLoading, isError, error } = useQuery({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId!),\n * enabled: () => props.postId != null,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n *\n * @example\n * Seeding a detail query from an already-cached list, to skip the loading state. `initialDataUpdatedAt` carries\n * over the list's own fetch time, so that if you set a `staleTime`, it's measured from when the list was\n * fetched rather than from now:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery, useQueryClient } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number }>()\n * const queryClient = useQueryClient()\n *\n * const { data, isError, error } = useQuery({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId),\n * initialData: () =>\n * queryClient\n * .getQueryData<Array<Post>>(['posts'])\n * ?.find((post) => post.id === props.postId),\n * initialDataUpdatedAt: () =>\n * queryClient.getQueryState(['posts'])?.dataUpdatedAt,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n *\n * @example\n * Paginated data, keeping the previous page's data visible while the next page loads:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { keepPreviousData, useQuery } from '@tanstack/vue-query'\n *\n * const page = ref(0)\n *\n * const { data, isPlaceholderData, isError, error } = useQuery({\n * queryKey: ['posts', page],\n * queryFn: () => fetchPosts(page.value),\n * placeholderData: keepPreviousData,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <template v-else>\n * <ul>\n * <li v-for=\"post in data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * <button :disabled=\"isPlaceholderData\" @click=\"page++\">Next Page</button>\n * </template>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\n/**\n * Fallback overload for options whose `initialData` presence isn't statically known — for example, a\n * `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other\n * overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly.\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries.\n *\n * When `options` itself is a reactive getter, the whole object is re-evaluated on every change to its\n * dependencies, so any option inside it — not just `queryKey` and `enabled` — can change over time.\n *\n * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UseQueryOptions} to use.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result, with `data` typed as possibly `undefined`.\n *\n * @example\n * Passing a whole-options getter so `staleTime` reacts to a setting stored elsewhere, not just `queryKey`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ id: number; staleTime: number }>()\n *\n * const { data } = useQuery(() => ({\n * queryKey: ['post', props.id],\n * queryFn: () => fetchPost(props.id),\n * staleTime: props.staleTime,\n * }))\n * </script>\n *\n * <template>\n * <h1 v-if=\"data\">{{ data.title }}</h1>\n * </template>\n * ```\n *\n * @example\n * `skipToken` disables the query in a type-safe way, without a non-null assertion on `props.postId` —\n * `queryFn` is only ever called when it's defined. The whole-options getter re-evaluates `queryFn` on every\n * change to `props.postId`. `queryFn` can also be a `computed`, but never a bare getter, since a function\n * there is the query function itself. `refetch` doesn't work while `queryFn` is `skipToken` — use\n * `enabled: false` instead if you need to trigger the query manually:\n * ```vue\n * <script setup lang=\"ts\">\n * import { skipToken, useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number | undefined }>()\n *\n * const { data, isLoading, isError, error } = useQuery(() => {\n * const postId = props.postId\n * return {\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * }\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n >,\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\nexport function useQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n >,\n queryClient?: QueryClient,\n):\n UseQueryReturnType<TData, TError> | UseQueryDefinedReturnType<TData, TError> {\n return useBaseQuery(QueryObserver, options, queryClient)\n}\n"],"mappings":";;;AA2SA,SAAgB,SAMd,SAGA,aAE6E;CAC7E,OAAO,aAAa,eAAe,SAAS,WAAW;AACzD"}
|
|
1
|
+
{"version":3,"file":"useQuery.js","names":[],"sources":["../../src/useQuery.ts"],"sourcesContent":["import { QueryObserver } from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n DefaultError,\n DefinedQueryObserverResult,\n QueryKey,\n} from '@tanstack/query-core'\nimport type { UseBaseQueryReturnType } from './useBaseQuery'\nimport type { MaybeRefOrGetter } from './types'\nimport type { QueryClient } from './queryClient'\nimport type {\n DefinedInitialQueryOptions,\n UndefinedInitialQueryOptions,\n UseQueryOptions,\n} from './queryOptions'\n\n/**\n * The result of `useQuery` when `initialData` is omitted or may be `undefined` — `data` may be `undefined`\n * while the query is `pending`. See {@link UseBaseQueryReturnType}.\n */\nexport type UseQueryReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError\n>\n\n/**\n * The result of `useQuery` when `initialData` is set — `data` is never `undefined` (unless a `select` changes\n * `TData` to include `undefined`).\n */\nexport type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError,\n DefinedQueryObserverResult<TData, TError>\n>\n\n/**\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless\n * a `select` changes `TData` to include `undefined`).\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay\n * reactive when passed as a `ref` or a `computed`.\n * @param options - The {@link DefinedInitialQueryOptions} to use — everything you can pass to `useQuery`, with\n * `initialData` set.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result, typed so that `data` is never `undefined` (unless a `select` changes\n * `TData` to include `undefined`). `status` never resolves to `pending` in this overload's type, since\n * `initialData` guarantees data upfront.\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const { data, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <ul>\n * <li v-for=\"post in data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryDefinedReturnType<TData, TError>\n\n/**\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay\n * reactive when passed as a `ref` or a `computed`.\n * @param options - The {@link UndefinedInitialQueryOptions} to use — everything you can pass to `useQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if\n * the last fetch attempt failed, or `success` if the query has data to display.\n * @example\n * A query key built from a reactive `ref` — the query refetches whenever `postId` changes:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const postId = ref(1)\n * const { status, data, error } = useQuery({\n * queryKey: ['post', postId],\n * queryFn: () => fetchPost(postId.value),\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"status === 'pending'\">Loading...</span>\n * <span v-else-if=\"status === 'error'\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data.title }}</h1>\n * </template>\n * ```\n * @example\n * `select` derives whatever `data` a component needs from the cached value, without changing what's\n * actually stored in the cache — the cache still holds the full `Post[]`, but `data` here is a `number`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const { data, isPending, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * select: (posts) => posts.length,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isPending\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <span v-else>{{ data }} posts</span>\n * </template>\n * ```\n * @example\n * A dependent query, only enabled once `postId` is set — use `isLoading`, not `isPending`, so the\n * loading state doesn't show while the query is disabled:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number | undefined }>()\n *\n * const { data, isLoading, isError, error } = useQuery({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId!),\n * enabled: () => props.postId != null,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n * @example\n * Seeding a detail query from an already-cached list, to skip the loading state. `initialDataUpdatedAt` carries\n * over the list's own fetch time, so that if you set a `staleTime`, it's measured from when the list was\n * fetched rather than from now:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery, useQueryClient } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number }>()\n * const queryClient = useQueryClient()\n *\n * const { data, isError, error } = useQuery({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId),\n * initialData: () =>\n * queryClient\n * .getQueryData<Array<Post>>(['posts'])\n * ?.find((post) => post.id === props.postId),\n * initialDataUpdatedAt: () =>\n * queryClient.getQueryState(['posts'])?.dataUpdatedAt,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n * @example\n * Paginated data, keeping the previous page's data visible while the next page loads:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { keepPreviousData, useQuery } from '@tanstack/vue-query'\n *\n * const page = ref(0)\n *\n * const { data, isPlaceholderData, isError, error } = useQuery({\n * queryKey: ['posts', page],\n * queryFn: () => fetchPosts(page.value),\n * placeholderData: keepPreviousData,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <template v-else>\n * <ul>\n * <li v-for=\"post in data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * <button :disabled=\"isPlaceholderData\" @click=\"page++\">Next Page</button>\n * </template>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\n/**\n * Fallback overload for options whose `initialData` presence isn't statically known — for example, a\n * `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other\n * overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly.\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries.\n *\n * When `options` itself is a reactive getter, the whole object is re-evaluated on every change to its\n * dependencies, so any option inside it — not just `queryKey` and `enabled` — can change over time.\n * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UseQueryOptions} to use.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result, with `data` typed as possibly `undefined`.\n * @example\n * Passing a whole-options getter so `staleTime` reacts to a setting stored elsewhere, not just `queryKey`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ id: number; staleTime: number }>()\n *\n * const { data } = useQuery(() => ({\n * queryKey: ['post', props.id],\n * queryFn: () => fetchPost(props.id),\n * staleTime: props.staleTime,\n * }))\n * </script>\n *\n * <template>\n * <h1 v-if=\"data\">{{ data.title }}</h1>\n * </template>\n * ```\n * @example\n * `skipToken` disables the query in a type-safe way, without a non-null assertion on `props.postId` —\n * `queryFn` is only ever called when it's defined. The whole-options getter re-evaluates `queryFn` on every\n * change to `props.postId`. `queryFn` can also be a `computed`, but never a bare getter, since a function\n * there is the query function itself. `refetch` doesn't work while `queryFn` is `skipToken` — use\n * `enabled: false` instead if you need to trigger the query manually:\n * ```vue\n * <script setup lang=\"ts\">\n * import { skipToken, useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number | undefined }>()\n *\n * const { data, isLoading, isError, error } = useQuery(() => {\n * const postId = props.postId\n * return {\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * }\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n >,\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\nexport function useQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n >,\n queryClient?: QueryClient,\n):\n | UseQueryReturnType<TData, TError>\n | UseQueryDefinedReturnType<TData, TError> {\n return useBaseQuery(QueryObserver, options, queryClient)\n}\n"],"mappings":";;;AAwSA,SAAgB,SAMd,SAGA,aAG2C;CAC3C,OAAO,aAAa,eAAe,SAAS,WAAW;AACzD"}
|
|
@@ -5,11 +5,11 @@ let vue_demi = require("vue-demi");
|
|
|
5
5
|
/**
|
|
6
6
|
* Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside
|
|
7
7
|
* `setup()` or another function that supports an injection context.
|
|
8
|
-
*
|
|
9
8
|
* @param id - The `queryClientKey` passed to `VueQueryPlugin` — only needed when multiple `QueryClient`s are
|
|
10
9
|
* installed in the same app.
|
|
11
|
-
* @
|
|
12
|
-
*
|
|
10
|
+
* @returns The installed `QueryClient`.
|
|
11
|
+
* @throws {Error} If called outside an injection context, or if no `QueryClient` was installed via
|
|
12
|
+
* `VueQueryPlugin`.
|
|
13
13
|
* @example
|
|
14
14
|
* ```vue
|
|
15
15
|
* <script setup lang="ts">
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueryClient.cjs","names":["hasInjectionContext","getClientKey","inject"],"sources":["../../src/useQueryClient.ts"],"sourcesContent":["import { hasInjectionContext, inject } from 'vue-demi'\n\nimport { getClientKey } from './utils'\nimport type { QueryClient } from './queryClient'\n\n/**\n * Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside\n * `setup()` or another function that supports an injection context.\n
|
|
1
|
+
{"version":3,"file":"useQueryClient.cjs","names":["hasInjectionContext","getClientKey","inject"],"sources":["../../src/useQueryClient.ts"],"sourcesContent":["import { hasInjectionContext, inject } from 'vue-demi'\n\nimport { getClientKey } from './utils'\nimport type { QueryClient } from './queryClient'\n\n/**\n * Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside\n * `setup()` or another function that supports an injection context.\n * @param id - The `queryClientKey` passed to `VueQueryPlugin` — only needed when multiple `QueryClient`s are\n * installed in the same app.\n * @returns The installed `QueryClient`.\n * @throws {Error} If called outside an injection context, or if no `QueryClient` was installed via\n * `VueQueryPlugin`.\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQueryClient } from '@tanstack/vue-query'\n *\n * const queryClient = useQueryClient()\n *\n * function invalidate() {\n * queryClient.invalidateQueries({ queryKey: ['todos'] })\n * }\n * </script>\n * ```\n */\nexport function useQueryClient(id = ''): QueryClient {\n // ensures that `inject()` can be used\n if (!hasInjectionContext()) {\n throw new Error(\n 'vue-query hooks can only be used inside setup() function or functions that support injection context.',\n )\n }\n\n const key = getClientKey(id)\n const queryClient = inject<QueryClient>(key)\n\n if (!queryClient) {\n throw new Error(\n \"No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.\",\n )\n }\n\n return queryClient\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,eAAe,KAAK,IAAiB;CAEnD,IAAI,EAAA,GAACA,SAAAA,oBAAAA,CAAoB,GACvB,MAAM,IAAI,MACR,uGACF;CAGF,MAAM,MAAMC,cAAAA,aAAa,EAAE;CAC3B,MAAM,eAAA,GAAcC,SAAAA,OAAAA,CAAoB,GAAG;CAE3C,IAAI,CAAC,aACH,MAAM,IAAI,MACR,iGACF;CAGF,OAAO;AACT"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { t as QueryClient } from "./queryClient-
|
|
1
|
+
import { t as QueryClient } from "./queryClient-BK9W57Qu.cjs";
|
|
2
2
|
//#region src/useQueryClient.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside
|
|
5
5
|
* `setup()` or another function that supports an injection context.
|
|
6
|
-
*
|
|
7
6
|
* @param id - The `queryClientKey` passed to `VueQueryPlugin` — only needed when multiple `QueryClient`s are
|
|
8
7
|
* installed in the same app.
|
|
9
|
-
* @
|
|
10
|
-
*
|
|
8
|
+
* @returns The installed `QueryClient`.
|
|
9
|
+
* @throws {Error} If called outside an injection context, or if no `QueryClient` was installed via
|
|
10
|
+
* `VueQueryPlugin`.
|
|
11
11
|
* @example
|
|
12
12
|
* ```vue
|
|
13
13
|
* <script setup lang="ts">
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { t as QueryClient } from "./queryClient-
|
|
1
|
+
import { t as QueryClient } from "./queryClient-BoBzDWAZ.js";
|
|
2
2
|
//#region src/useQueryClient.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside
|
|
5
5
|
* `setup()` or another function that supports an injection context.
|
|
6
|
-
*
|
|
7
6
|
* @param id - The `queryClientKey` passed to `VueQueryPlugin` — only needed when multiple `QueryClient`s are
|
|
8
7
|
* installed in the same app.
|
|
9
|
-
* @
|
|
10
|
-
*
|
|
8
|
+
* @returns The installed `QueryClient`.
|
|
9
|
+
* @throws {Error} If called outside an injection context, or if no `QueryClient` was installed via
|
|
10
|
+
* `VueQueryPlugin`.
|
|
11
11
|
* @example
|
|
12
12
|
* ```vue
|
|
13
13
|
* <script setup lang="ts">
|
|
@@ -4,11 +4,11 @@ import { hasInjectionContext, inject } from "vue-demi";
|
|
|
4
4
|
/**
|
|
5
5
|
* Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside
|
|
6
6
|
* `setup()` or another function that supports an injection context.
|
|
7
|
-
*
|
|
8
7
|
* @param id - The `queryClientKey` passed to `VueQueryPlugin` — only needed when multiple `QueryClient`s are
|
|
9
8
|
* installed in the same app.
|
|
10
|
-
* @
|
|
11
|
-
*
|
|
9
|
+
* @returns The installed `QueryClient`.
|
|
10
|
+
* @throws {Error} If called outside an injection context, or if no `QueryClient` was installed via
|
|
11
|
+
* `VueQueryPlugin`.
|
|
12
12
|
* @example
|
|
13
13
|
* ```vue
|
|
14
14
|
* <script setup lang="ts">
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueryClient.js","names":[],"sources":["../../src/useQueryClient.ts"],"sourcesContent":["import { hasInjectionContext, inject } from 'vue-demi'\n\nimport { getClientKey } from './utils'\nimport type { QueryClient } from './queryClient'\n\n/**\n * Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside\n * `setup()` or another function that supports an injection context.\n
|
|
1
|
+
{"version":3,"file":"useQueryClient.js","names":[],"sources":["../../src/useQueryClient.ts"],"sourcesContent":["import { hasInjectionContext, inject } from 'vue-demi'\n\nimport { getClientKey } from './utils'\nimport type { QueryClient } from './queryClient'\n\n/**\n * Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside\n * `setup()` or another function that supports an injection context.\n * @param id - The `queryClientKey` passed to `VueQueryPlugin` — only needed when multiple `QueryClient`s are\n * installed in the same app.\n * @returns The installed `QueryClient`.\n * @throws {Error} If called outside an injection context, or if no `QueryClient` was installed via\n * `VueQueryPlugin`.\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQueryClient } from '@tanstack/vue-query'\n *\n * const queryClient = useQueryClient()\n *\n * function invalidate() {\n * queryClient.invalidateQueries({ queryKey: ['todos'] })\n * }\n * </script>\n * ```\n */\nexport function useQueryClient(id = ''): QueryClient {\n // ensures that `inject()` can be used\n if (!hasInjectionContext()) {\n throw new Error(\n 'vue-query hooks can only be used inside setup() function or functions that support injection context.',\n )\n }\n\n const key = getClientKey(id)\n const queryClient = inject<QueryClient>(key)\n\n if (!queryClient) {\n throw new Error(\n \"No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.\",\n )\n }\n\n return queryClient\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,eAAe,KAAK,IAAiB;CAEnD,IAAI,CAAC,oBAAoB,GACvB,MAAM,IAAI,MACR,uGACF;CAGF,MAAM,MAAM,aAAa,EAAE;CAC3B,MAAM,cAAc,OAAoB,GAAG;CAE3C,IAAI,CAAC,aACH,MAAM,IAAI,MACR,iGACF;CAGF,OAAO;AACT"}
|
package/build/legacy/utils.cjs
CHANGED
|
@@ -1,19 +1,42 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let vue_demi = require("vue-demi");
|
|
3
3
|
//#region src/utils.ts
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
5
8
|
const VUE_QUERY_CLIENT = "VUE_QUERY_CLIENT";
|
|
6
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Builds the injection key `useQueryClient`/`VueQueryPlugin` use for a given `queryClientKey`.
|
|
11
|
+
* @internal
|
|
12
|
+
* @param key - The `queryClientKey`. Without it, the base key is used.
|
|
13
|
+
* @returns The injection key.
|
|
14
|
+
*/
|
|
7
15
|
function getClientKey(key) {
|
|
8
16
|
const suffix = key ? `:${key}` : "";
|
|
9
17
|
return `${VUE_QUERY_CLIENT}${suffix}`;
|
|
10
18
|
}
|
|
11
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Copies each property from `update` onto `state`, in place, for every key already on `state`.
|
|
21
|
+
* @internal
|
|
22
|
+
* @param state - The object to update.
|
|
23
|
+
* @param update - The object to copy the values from.
|
|
24
|
+
*/
|
|
12
25
|
function updateState(state, update) {
|
|
13
26
|
Object.keys(state).forEach((key) => {
|
|
14
27
|
state[key] = update[key];
|
|
15
28
|
});
|
|
16
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Recursive implementation of {@link cloneDeep}, which also tracks the key and nesting level of
|
|
32
|
+
* the current node for `customize`.
|
|
33
|
+
* @param value - The value to clone.
|
|
34
|
+
* @param customize - Called for every node with its key and nesting level. If it returns a value
|
|
35
|
+
* other than `undefined`, that value is used instead of recursing.
|
|
36
|
+
* @param currentKey - The key of the current node.
|
|
37
|
+
* @param currentLevel - The nesting level of the current node.
|
|
38
|
+
* @returns The cloned value.
|
|
39
|
+
*/
|
|
17
40
|
function _cloneDeep(value, customize, currentKey = "", currentLevel = 0) {
|
|
18
41
|
if (customize) {
|
|
19
42
|
const result = customize(value, currentKey, currentLevel);
|
|
@@ -28,18 +51,27 @@ function _cloneDeep(value, customize, currentKey = "", currentLevel = 0) {
|
|
|
28
51
|
return value;
|
|
29
52
|
}
|
|
30
53
|
/**
|
|
31
|
-
*
|
|
54
|
+
* Deep-clones `value`, recursing into arrays and plain objects. `customize`, if provided, can
|
|
32
55
|
* intercept any node (by key and nesting level) and substitute its own return value instead of recursing
|
|
33
56
|
* further.
|
|
57
|
+
* @internal
|
|
58
|
+
* @param value - The value to clone.
|
|
59
|
+
* @param customize - Called for every node with its key and nesting level. If it returns a value
|
|
60
|
+
* other than `undefined`, that value is used instead of recursing.
|
|
61
|
+
* @returns The cloned value.
|
|
34
62
|
*/
|
|
35
63
|
function cloneDeep(value, customize) {
|
|
36
64
|
return _cloneDeep(value, customize);
|
|
37
65
|
}
|
|
38
66
|
/**
|
|
39
|
-
*
|
|
67
|
+
* Deep-clones `value` like {@link cloneDeep}, additionally unwrapping any `ref`s it encounters (and,
|
|
40
68
|
* if `unrefGetters` is `true`, calling any functions it encounters and unwrapping their result too). Always
|
|
41
69
|
* resolves `queryKey` this way, regardless of `unrefGetters` — this is what lets a `queryKey` containing `ref`s
|
|
42
70
|
* be passed straight through to `@tanstack/query-core`.
|
|
71
|
+
* @internal
|
|
72
|
+
* @param obj - The value to clone.
|
|
73
|
+
* @param unrefGetters - Whether to also call functions and unwrap their result.
|
|
74
|
+
* @returns The cloned value, with `ref`s unwrapped.
|
|
43
75
|
*/
|
|
44
76
|
function cloneDeepUnref(obj, unrefGetters = false) {
|
|
45
77
|
return cloneDeep(obj, (val, key, level) => {
|
|
@@ -48,15 +80,31 @@ function cloneDeepUnref(obj, unrefGetters = false) {
|
|
|
48
80
|
if ((0, vue_demi.isRef)(val)) return cloneDeepUnref((0, vue_demi.unref)(val), unrefGetters);
|
|
49
81
|
});
|
|
50
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Checks whether a value is a plain object, created with an object literal or
|
|
85
|
+
* `Object.create(null)`.
|
|
86
|
+
* @param value - The value to check.
|
|
87
|
+
* @returns `true` if `value` is a plain object.
|
|
88
|
+
*/
|
|
51
89
|
function isPlainObject(value) {
|
|
52
90
|
if (Object.prototype.toString.call(value) !== "[object Object]") return false;
|
|
53
91
|
const prototype = Object.getPrototypeOf(value);
|
|
54
92
|
return prototype === null || prototype === Object.prototype;
|
|
55
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Checks whether a value is a function.
|
|
96
|
+
* @param value - The value to check.
|
|
97
|
+
* @returns `true` if `value` is a function.
|
|
98
|
+
*/
|
|
56
99
|
function isFunction(value) {
|
|
57
100
|
return typeof value === "function";
|
|
58
101
|
}
|
|
59
|
-
/**
|
|
102
|
+
/**
|
|
103
|
+
* Resolves `source` to a plain value — calls it if it's a function, otherwise deep-unwraps it.
|
|
104
|
+
* @internal
|
|
105
|
+
* @param source - A getter, or a value that may contain `ref`s.
|
|
106
|
+
* @returns The resolved plain value.
|
|
107
|
+
*/
|
|
60
108
|
function toValueDeep(source) {
|
|
61
109
|
return isFunction(source) ? source() : cloneDeepUnref(source);
|
|
62
110
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","names":["isRef","unref"],"sources":["../../src/utils.ts"],"sourcesContent":["import { isRef, unref } from 'vue-demi'\nimport type { MaybeRefDeep } from './types'\n\n
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":["isRef","unref"],"sources":["../../src/utils.ts"],"sourcesContent":["import { isRef, unref } from 'vue-demi'\nimport type { MaybeRefDeep } from './types'\n\n/**\n * Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under.\n * @internal\n */\nexport const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT'\n\n/**\n * Builds the injection key `useQueryClient`/`VueQueryPlugin` use for a given `queryClientKey`.\n * @internal\n * @param key - The `queryClientKey`. Without it, the base key is used.\n * @returns The injection key.\n */\nexport function getClientKey(key?: string) {\n const suffix = key ? `:${key}` : ''\n return `${VUE_QUERY_CLIENT}${suffix}`\n}\n\n/**\n * Copies each property from `update` onto `state`, in place, for every key already on `state`.\n * @internal\n * @param state - The object to update.\n * @param update - The object to copy the values from.\n */\nexport function updateState(\n state: Record<string, any>,\n update: Record<string, any>,\n): void {\n Object.keys(state).forEach((key) => {\n state[key] = update[key]\n })\n}\n\n/**\n * Recursive implementation of {@link cloneDeep}, which also tracks the key and nesting level of\n * the current node for `customize`.\n * @param value - The value to clone.\n * @param customize - Called for every node with its key and nesting level. If it returns a value\n * other than `undefined`, that value is used instead of recursing.\n * @param currentKey - The key of the current node.\n * @param currentLevel - The nesting level of the current node.\n * @returns The cloned value.\n */\nfunction _cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n currentKey: string = '',\n currentLevel: number = 0,\n): T {\n if (customize) {\n const result = customize(value, currentKey, currentLevel)\n if (result === undefined && isRef(value)) {\n return result as T\n }\n if (result !== undefined) {\n return result\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((val, index) =>\n _cloneDeep(val, customize, String(index), currentLevel + 1),\n ) as unknown as T\n }\n\n if (typeof value === 'object' && isPlainObject(value)) {\n const entries = Object.entries(value).map(([key, val]) => [\n key,\n _cloneDeep(val, customize, key, currentLevel + 1),\n ])\n return Object.fromEntries(entries)\n }\n\n return value as T\n}\n\n/**\n * Deep-clones `value`, recursing into arrays and plain objects. `customize`, if provided, can\n * intercept any node (by key and nesting level) and substitute its own return value instead of recursing\n * further.\n * @internal\n * @param value - The value to clone.\n * @param customize - Called for every node with its key and nesting level. If it returns a value\n * other than `undefined`, that value is used instead of recursing.\n * @returns The cloned value.\n */\nexport function cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n): T {\n return _cloneDeep(value, customize)\n}\n\n/**\n * Deep-clones `value` like {@link cloneDeep}, additionally unwrapping any `ref`s it encounters (and,\n * if `unrefGetters` is `true`, calling any functions it encounters and unwrapping their result too). Always\n * resolves `queryKey` this way, regardless of `unrefGetters` — this is what lets a `queryKey` containing `ref`s\n * be passed straight through to `@tanstack/query-core`.\n * @internal\n * @param obj - The value to clone.\n * @param unrefGetters - Whether to also call functions and unwrap their result.\n * @returns The cloned value, with `ref`s unwrapped.\n */\nexport function cloneDeepUnref<T>(\n obj: MaybeRefDeep<T>,\n unrefGetters = false,\n): T {\n return cloneDeep(obj, (val, key, level) => {\n // Check if we're at the top level and the key is 'queryKey'\n //\n // If so, take the recursive descent where we resolve\n // getters to values as well as refs.\n if (level === 1 && key === 'queryKey') {\n return cloneDeepUnref(val, true)\n }\n\n // Resolve getters to values if specified.\n if (unrefGetters && isFunction(val)) {\n // Cast due to older TS versions not allowing calling\n // on certain intersection types.\n return cloneDeepUnref((val as Function)(), unrefGetters)\n }\n\n // Unref refs and continue to recurse into the value.\n if (isRef(val)) {\n return cloneDeepUnref(unref(val), unrefGetters)\n }\n\n return undefined\n })\n}\n\n/**\n * Checks whether a value is a plain object, created with an object literal or\n * `Object.create(null)`.\n * @param value - The value to check.\n * @returns `true` if `value` is a plain object.\n */\n// oxlint-disable-next-line typescript/no-wrapper-object-types\nfunction isPlainObject(value: unknown): value is Object {\n if (Object.prototype.toString.call(value) !== '[object Object]') {\n return false\n }\n\n const prototype = Object.getPrototypeOf(value)\n return prototype === null || prototype === Object.prototype\n}\n\n/**\n * Checks whether a value is a function.\n * @param value - The value to check.\n * @returns `true` if `value` is a function.\n */\nfunction isFunction(value: unknown): value is Function {\n return typeof value === 'function'\n}\n\n/**\n * Resolves `source` to a plain value — calls it if it's a function, otherwise deep-unwraps it.\n * @internal\n * @param source - A getter, or a value that may contain `ref`s.\n * @returns The resolved plain value.\n */\nexport function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T {\n return isFunction(source) ? source() : cloneDeepUnref(source)\n}\n"],"mappings":";;;;;;;AAOA,MAAa,mBAAmB;;;;;;;AAQhC,SAAgB,aAAa,KAAc;CACzC,MAAM,SAAS,MAAM,IAAI,QAAQ;CACjC,OAAO,GAAG,mBAAmB;AAC/B;;;;;;;AAQA,SAAgB,YACd,OACA,QACM;CACN,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,QAAQ;EAClC,MAAM,OAAO,OAAO;CACtB,CAAC;AACH;;;;;;;;;;;AAYA,SAAS,WACP,OACA,WAKA,aAAqB,IACrB,eAAuB,GACpB;CACH,IAAI,WAAW;EACb,MAAM,SAAS,UAAU,OAAO,YAAY,YAAY;EACxD,IAAI,WAAW,KAAA,MAAA,GAAaA,SAAAA,MAAAA,CAAM,KAAK,GACrC,OAAO;EAET,IAAI,WAAW,KAAA,GACb,OAAO;CAEX;CAEA,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,KAAK,KAAK,UACrB,WAAW,KAAK,WAAW,OAAO,KAAK,GAAG,eAAe,CAAC,CAC5D;CAGF,IAAI,OAAO,UAAU,YAAY,cAAc,KAAK,GAAG;EACrD,MAAM,UAAU,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,SAAS,CACxD,KACA,WAAW,KAAK,WAAW,KAAK,eAAe,CAAC,CAClD,CAAC;EACD,OAAO,OAAO,YAAY,OAAO;CACnC;CAEA,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,UACd,OACA,WAKG;CACH,OAAO,WAAW,OAAO,SAAS;AACpC;;;;;;;;;;;AAYA,SAAgB,eACd,KACA,eAAe,OACZ;CACH,OAAO,UAAU,MAAM,KAAK,KAAK,UAAU;EAKzC,IAAI,UAAU,KAAK,QAAQ,YACzB,OAAO,eAAe,KAAK,IAAI;EAIjC,IAAI,gBAAgB,WAAW,GAAG,GAGhC,OAAO,eAAgB,IAAiB,GAAG,YAAY;EAIzD,KAAA,GAAIA,SAAAA,MAAAA,CAAM,GAAG,GACX,OAAO,gBAAA,GAAeC,SAAAA,MAAAA,CAAM,GAAG,GAAG,YAAY;CAIlD,CAAC;AACH;;;;;;;AASA,SAAS,cAAc,OAAiC;CACtD,IAAI,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM,mBAC5C,OAAO;CAGT,MAAM,YAAY,OAAO,eAAe,KAAK;CAC7C,OAAO,cAAc,QAAQ,cAAc,OAAO;AACpD;;;;;;AAOA,SAAS,WAAW,OAAmC;CACrD,OAAO,OAAO,UAAU;AAC1B;;;;;;;AAQA,SAAgB,YAAe,QAAwC;CACrE,OAAO,WAAW,MAAM,IAAI,OAAO,IAAI,eAAe,MAAM;AAC9D"}
|
package/build/legacy/utils.d.cts
CHANGED
|
@@ -1,25 +1,52 @@
|
|
|
1
|
-
import { o as MaybeRefDeep } from "./types-
|
|
1
|
+
import { o as MaybeRefDeep } from "./types-sdZdiLgo.cjs";
|
|
2
2
|
//#region src/utils.d.ts
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
4
7
|
export declare const VUE_QUERY_CLIENT = "VUE_QUERY_CLIENT";
|
|
5
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Builds the injection key `useQueryClient`/`VueQueryPlugin` use for a given `queryClientKey`.
|
|
10
|
+
* @internal
|
|
11
|
+
* @param key - The `queryClientKey`. Without it, the base key is used.
|
|
12
|
+
* @returns The injection key.
|
|
13
|
+
*/
|
|
6
14
|
export declare function getClientKey(key?: string): string;
|
|
7
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Copies each property from `update` onto `state`, in place, for every key already on `state`.
|
|
17
|
+
* @internal
|
|
18
|
+
* @param state - The object to update.
|
|
19
|
+
* @param update - The object to copy the values from.
|
|
20
|
+
*/
|
|
8
21
|
export declare function updateState(state: Record<string, any>, update: Record<string, any>): void;
|
|
9
22
|
/**
|
|
10
|
-
*
|
|
23
|
+
* Deep-clones `value`, recursing into arrays and plain objects. `customize`, if provided, can
|
|
11
24
|
* intercept any node (by key and nesting level) and substitute its own return value instead of recursing
|
|
12
25
|
* further.
|
|
26
|
+
* @internal
|
|
27
|
+
* @param value - The value to clone.
|
|
28
|
+
* @param customize - Called for every node with its key and nesting level. If it returns a value
|
|
29
|
+
* other than `undefined`, that value is used instead of recursing.
|
|
30
|
+
* @returns The cloned value.
|
|
13
31
|
*/
|
|
14
32
|
export declare function cloneDeep<T>(value: MaybeRefDeep<T>, customize?: (val: MaybeRefDeep<T>, key: string, level: number) => T | undefined): T;
|
|
15
33
|
/**
|
|
16
|
-
*
|
|
34
|
+
* Deep-clones `value` like {@link cloneDeep}, additionally unwrapping any `ref`s it encounters (and,
|
|
17
35
|
* if `unrefGetters` is `true`, calling any functions it encounters and unwrapping their result too). Always
|
|
18
36
|
* resolves `queryKey` this way, regardless of `unrefGetters` — this is what lets a `queryKey` containing `ref`s
|
|
19
37
|
* be passed straight through to `@tanstack/query-core`.
|
|
38
|
+
* @internal
|
|
39
|
+
* @param obj - The value to clone.
|
|
40
|
+
* @param unrefGetters - Whether to also call functions and unwrap their result.
|
|
41
|
+
* @returns The cloned value, with `ref`s unwrapped.
|
|
20
42
|
*/
|
|
21
43
|
export declare function cloneDeepUnref<T>(obj: MaybeRefDeep<T>, unrefGetters?: boolean): T;
|
|
22
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Resolves `source` to a plain value — calls it if it's a function, otherwise deep-unwraps it.
|
|
46
|
+
* @internal
|
|
47
|
+
* @param source - A getter, or a value that may contain `ref`s.
|
|
48
|
+
* @returns The resolved plain value.
|
|
49
|
+
*/
|
|
23
50
|
export declare function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T;
|
|
24
51
|
//#endregion
|
|
25
52
|
//# sourceMappingURL=utils.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.cts","names":[],"sources":["../../src/utils.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.cts","names":[],"sources":["../../src/utils.ts"],"mappings":";;;;;;qBAOa;;;;;;;wBAQG,aAAa;;;;;;;wBAWb,YACd,OAAO,qBACP,QAAQ;;;;;;;;;;;wBAgEM,UAAU,GACxB,OAAO,aAAa,IACpB,aACE,KAAK,aAAa,IAClB,aACA,kBACG,gBACJ;;;;;;;;;;;wBAca,eAAe,GAC7B,KAAK,aAAa,IAClB,yBACC;;;;;;;wBAyDa,YAAY,GAAG,eAAe,KAAK,aAAa,KAAK"}
|
package/build/legacy/utils.d.ts
CHANGED
|
@@ -1,25 +1,52 @@
|
|
|
1
|
-
import { o as MaybeRefDeep } from "./types-
|
|
1
|
+
import { o as MaybeRefDeep } from "./types-sdZdiLgo.js";
|
|
2
2
|
//#region src/utils.d.ts
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
4
7
|
export declare const VUE_QUERY_CLIENT = "VUE_QUERY_CLIENT";
|
|
5
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Builds the injection key `useQueryClient`/`VueQueryPlugin` use for a given `queryClientKey`.
|
|
10
|
+
* @internal
|
|
11
|
+
* @param key - The `queryClientKey`. Without it, the base key is used.
|
|
12
|
+
* @returns The injection key.
|
|
13
|
+
*/
|
|
6
14
|
export declare function getClientKey(key?: string): string;
|
|
7
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Copies each property from `update` onto `state`, in place, for every key already on `state`.
|
|
17
|
+
* @internal
|
|
18
|
+
* @param state - The object to update.
|
|
19
|
+
* @param update - The object to copy the values from.
|
|
20
|
+
*/
|
|
8
21
|
export declare function updateState(state: Record<string, any>, update: Record<string, any>): void;
|
|
9
22
|
/**
|
|
10
|
-
*
|
|
23
|
+
* Deep-clones `value`, recursing into arrays and plain objects. `customize`, if provided, can
|
|
11
24
|
* intercept any node (by key and nesting level) and substitute its own return value instead of recursing
|
|
12
25
|
* further.
|
|
26
|
+
* @internal
|
|
27
|
+
* @param value - The value to clone.
|
|
28
|
+
* @param customize - Called for every node with its key and nesting level. If it returns a value
|
|
29
|
+
* other than `undefined`, that value is used instead of recursing.
|
|
30
|
+
* @returns The cloned value.
|
|
13
31
|
*/
|
|
14
32
|
export declare function cloneDeep<T>(value: MaybeRefDeep<T>, customize?: (val: MaybeRefDeep<T>, key: string, level: number) => T | undefined): T;
|
|
15
33
|
/**
|
|
16
|
-
*
|
|
34
|
+
* Deep-clones `value` like {@link cloneDeep}, additionally unwrapping any `ref`s it encounters (and,
|
|
17
35
|
* if `unrefGetters` is `true`, calling any functions it encounters and unwrapping their result too). Always
|
|
18
36
|
* resolves `queryKey` this way, regardless of `unrefGetters` — this is what lets a `queryKey` containing `ref`s
|
|
19
37
|
* be passed straight through to `@tanstack/query-core`.
|
|
38
|
+
* @internal
|
|
39
|
+
* @param obj - The value to clone.
|
|
40
|
+
* @param unrefGetters - Whether to also call functions and unwrap their result.
|
|
41
|
+
* @returns The cloned value, with `ref`s unwrapped.
|
|
20
42
|
*/
|
|
21
43
|
export declare function cloneDeepUnref<T>(obj: MaybeRefDeep<T>, unrefGetters?: boolean): T;
|
|
22
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Resolves `source` to a plain value — calls it if it's a function, otherwise deep-unwraps it.
|
|
46
|
+
* @internal
|
|
47
|
+
* @param source - A getter, or a value that may contain `ref`s.
|
|
48
|
+
* @returns The resolved plain value.
|
|
49
|
+
*/
|
|
23
50
|
export declare function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T;
|
|
24
51
|
//#endregion
|
|
25
52
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","names":[],"sources":["../../src/utils.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","names":[],"sources":["../../src/utils.ts"],"mappings":";;;;;;qBAOa;;;;;;;wBAQG,aAAa;;;;;;;wBAWb,YACd,OAAO,qBACP,QAAQ;;;;;;;;;;;wBAgEM,UAAU,GACxB,OAAO,aAAa,IACpB,aACE,KAAK,aAAa,IAClB,aACA,kBACG,gBACJ;;;;;;;;;;;wBAca,eAAe,GAC7B,KAAK,aAAa,IAClB,yBACC;;;;;;;wBAyDa,YAAY,GAAG,eAAe,KAAK,aAAa,KAAK"}
|