@tanstack/vue-query 5.104.5 → 5.105.1
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 +1 -2
- package/build/legacy/devtools/devtools.d.cts +1 -3
- package/build/legacy/devtools/devtools.d.cts.map +1 -1
- package/build/legacy/devtools/devtools.d.ts +1 -3
- package/build/legacy/devtools/devtools.d.ts.map +1 -1
- package/build/legacy/devtools/devtools.js +1 -2
- package/build/legacy/devtools/utils.cjs +1 -2
- package/build/legacy/devtools/utils.d.cts +0 -2
- package/build/legacy/devtools/utils.d.cts.map +1 -1
- package/build/legacy/devtools/utils.d.ts +0 -2
- package/build/legacy/devtools/utils.d.ts.map +1 -1
- package/build/legacy/devtools/utils.js +1 -2
- package/build/legacy/index.d.cts +4 -4
- package/build/legacy/index.d.ts +4 -4
- package/build/legacy/{infiniteQueryOptions-BaoKhSzb.d.ts → infiniteQueryOptions-BLGtkUwV.d.ts} +28 -33
- package/build/legacy/infiniteQueryOptions-BLGtkUwV.d.ts.map +1 -0
- package/build/legacy/{infiniteQueryOptions-ClNe2-FB.d.cts → infiniteQueryOptions-oStzZOCq.d.cts} +28 -33
- package/build/legacy/infiniteQueryOptions-oStzZOCq.d.cts.map +1 -0
- package/build/legacy/infiniteQueryOptions.cjs +1 -2
- 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 +1 -2
- package/build/legacy/infiniteQueryOptions.js.map +1 -1
- package/build/legacy/mutationCache.cjs +1 -2
- package/build/legacy/mutationCache.d.cts +1 -3
- package/build/legacy/mutationCache.d.cts.map +1 -1
- package/build/legacy/mutationCache.d.ts +1 -3
- package/build/legacy/mutationCache.d.ts.map +1 -1
- package/build/legacy/mutationCache.js +1 -2
- package/build/legacy/mutationOptions.cjs +1 -2
- package/build/legacy/mutationOptions.d.cts +1 -3
- package/build/legacy/mutationOptions.d.cts.map +1 -1
- package/build/legacy/mutationOptions.d.ts +1 -3
- package/build/legacy/mutationOptions.d.ts.map +1 -1
- package/build/legacy/mutationOptions.js +1 -2
- package/build/legacy/queryCache.cjs +1 -2
- package/build/legacy/queryCache.d.cts +1 -3
- package/build/legacy/queryCache.d.cts.map +1 -1
- package/build/legacy/queryCache.d.ts +1 -3
- package/build/legacy/queryCache.d.ts.map +1 -1
- package/build/legacy/queryCache.js +1 -2
- package/build/{modern/queryClient-BoBzDWAZ.d.ts → legacy/queryClient-CVne8UYf.d.ts} +57 -7
- package/build/legacy/queryClient-CVne8UYf.d.ts.map +1 -0
- package/build/{modern/queryClient-BK9W57Qu.d.cts → legacy/queryClient-DdZQqhoA.d.cts} +57 -7
- package/build/legacy/queryClient-DdZQqhoA.d.cts.map +1 -0
- package/build/legacy/queryClient.cjs +1 -2
- 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 +1 -2
- package/build/legacy/queryClient.js.map +1 -1
- package/build/{modern/queryOptions-gpn5D4rf.d.ts → legacy/queryOptions-BuZEBLtg.d.cts} +16 -16
- package/build/legacy/queryOptions-BuZEBLtg.d.cts.map +1 -0
- package/build/{modern/queryOptions-BvmZtmiU.d.cts → legacy/queryOptions-dXiBZnGk.d.ts} +16 -16
- package/build/legacy/queryOptions-dXiBZnGk.d.ts.map +1 -0
- package/build/legacy/queryOptions.cjs +1 -2
- 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 +1 -2
- package/build/legacy/queryOptions.js.map +1 -1
- package/build/legacy/{types-sdZdiLgo.d.ts → types-u_Tu5Ybs.d.cts} +1 -3
- package/build/legacy/{types-sdZdiLgo.d.ts.map → types-u_Tu5Ybs.d.cts.map} +1 -1
- package/build/{modern/types-sdZdiLgo.d.ts → legacy/types-u_Tu5Ybs.d.ts} +1 -3
- package/build/legacy/types-u_Tu5Ybs.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 -2
- package/build/legacy/useBaseQuery.d.cts +1 -1
- package/build/legacy/useBaseQuery.d.ts +1 -1
- package/build/legacy/useBaseQuery.js +1 -2
- package/build/legacy/useInfiniteQuery.cjs +1 -2
- 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 +1 -2
- package/build/legacy/useInfiniteQuery.js.map +1 -1
- package/build/legacy/useIsFetching.cjs +1 -2
- package/build/legacy/useIsFetching.cjs.map +1 -1
- package/build/legacy/useIsFetching.d.cts +3 -5
- package/build/legacy/useIsFetching.d.cts.map +1 -1
- package/build/legacy/useIsFetching.d.ts +3 -5
- package/build/legacy/useIsFetching.d.ts.map +1 -1
- package/build/legacy/useIsFetching.js +1 -2
- package/build/legacy/useIsFetching.js.map +1 -1
- package/build/legacy/useMutation.cjs +1 -2
- package/build/legacy/useMutation.d.cts +2 -4
- package/build/legacy/useMutation.d.cts.map +1 -1
- package/build/legacy/useMutation.d.ts +2 -4
- package/build/legacy/useMutation.d.ts.map +1 -1
- package/build/legacy/useMutation.js +1 -2
- package/build/legacy/useMutationState.cjs +1 -2
- package/build/legacy/useMutationState.d.cts +2 -4
- package/build/legacy/useMutationState.d.cts.map +1 -1
- package/build/legacy/useMutationState.d.ts +2 -4
- package/build/legacy/useMutationState.d.ts.map +1 -1
- package/build/legacy/useMutationState.js +1 -2
- package/build/legacy/usePrefetchInfiniteQuery.cjs +1 -2
- package/build/legacy/usePrefetchInfiniteQuery.d.cts +2 -4
- package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.ts +2 -4
- package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.js +1 -2
- package/build/legacy/usePrefetchQuery.cjs +1 -2
- package/build/legacy/usePrefetchQuery.d.cts +2 -4
- package/build/legacy/usePrefetchQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchQuery.d.ts +2 -4
- package/build/legacy/usePrefetchQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchQuery.js +1 -2
- package/build/legacy/useQueries.cjs +1 -2
- package/build/legacy/useQueries.d.cts +3 -5
- package/build/legacy/useQueries.d.cts.map +1 -1
- package/build/legacy/useQueries.d.ts +3 -5
- package/build/legacy/useQueries.d.ts.map +1 -1
- package/build/legacy/useQueries.js +1 -2
- package/build/legacy/useQuery.cjs +1 -2
- package/build/legacy/useQuery.cjs.map +1 -1
- package/build/legacy/useQuery.d.cts +11 -12
- package/build/legacy/useQuery.d.cts.map +1 -1
- package/build/legacy/useQuery.d.ts +11 -12
- package/build/legacy/useQuery.d.ts.map +1 -1
- package/build/legacy/useQuery.js +1 -2
- package/build/legacy/useQuery.js.map +1 -1
- package/build/legacy/useQueryClient.cjs +1 -2
- package/build/legacy/useQueryClient.d.cts +1 -3
- package/build/legacy/useQueryClient.d.cts.map +1 -1
- package/build/legacy/useQueryClient.d.ts +1 -3
- package/build/legacy/useQueryClient.d.ts.map +1 -1
- package/build/legacy/useQueryClient.js +1 -2
- package/build/legacy/utils.cjs +1 -2
- package/build/legacy/utils.cjs.map +1 -1
- package/build/legacy/utils.d.cts +1 -3
- package/build/legacy/utils.d.cts.map +1 -1
- package/build/legacy/utils.d.ts +1 -3
- package/build/legacy/utils.d.ts.map +1 -1
- package/build/legacy/utils.js +1 -2
- package/build/legacy/utils.js.map +1 -1
- package/build/legacy/vueQueryPlugin.cjs +1 -2
- package/build/legacy/vueQueryPlugin.d.cts +2 -4
- package/build/legacy/vueQueryPlugin.d.cts.map +1 -1
- package/build/legacy/vueQueryPlugin.d.ts +2 -4
- package/build/legacy/vueQueryPlugin.d.ts.map +1 -1
- package/build/legacy/vueQueryPlugin.js +1 -2
- package/build/modern/devtools/devtools.cjs +1 -2
- package/build/modern/devtools/devtools.d.cts +1 -3
- package/build/modern/devtools/devtools.d.cts.map +1 -1
- package/build/modern/devtools/devtools.d.ts +1 -3
- package/build/modern/devtools/devtools.d.ts.map +1 -1
- package/build/modern/devtools/devtools.js +1 -2
- package/build/modern/devtools/utils.cjs +1 -2
- package/build/modern/devtools/utils.d.cts +0 -2
- package/build/modern/devtools/utils.d.cts.map +1 -1
- package/build/modern/devtools/utils.d.ts +0 -2
- package/build/modern/devtools/utils.d.ts.map +1 -1
- package/build/modern/devtools/utils.js +1 -2
- package/build/modern/index.d.cts +4 -4
- package/build/modern/index.d.ts +4 -4
- package/build/modern/{infiniteQueryOptions-BaoKhSzb.d.ts → infiniteQueryOptions-BLGtkUwV.d.ts} +28 -33
- package/build/modern/infiniteQueryOptions-BLGtkUwV.d.ts.map +1 -0
- package/build/modern/{infiniteQueryOptions-ClNe2-FB.d.cts → infiniteQueryOptions-oStzZOCq.d.cts} +28 -33
- package/build/modern/infiniteQueryOptions-oStzZOCq.d.cts.map +1 -0
- package/build/modern/infiniteQueryOptions.cjs +1 -2
- 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 +1 -2
- package/build/modern/infiniteQueryOptions.js.map +1 -1
- package/build/modern/mutationCache.cjs +1 -2
- package/build/modern/mutationCache.d.cts +1 -3
- package/build/modern/mutationCache.d.cts.map +1 -1
- package/build/modern/mutationCache.d.ts +1 -3
- package/build/modern/mutationCache.d.ts.map +1 -1
- package/build/modern/mutationCache.js +1 -2
- package/build/modern/mutationOptions.cjs +1 -2
- package/build/modern/mutationOptions.d.cts +1 -3
- package/build/modern/mutationOptions.d.cts.map +1 -1
- package/build/modern/mutationOptions.d.ts +1 -3
- package/build/modern/mutationOptions.d.ts.map +1 -1
- package/build/modern/mutationOptions.js +1 -2
- package/build/modern/queryCache.cjs +1 -2
- package/build/modern/queryCache.d.cts +1 -3
- package/build/modern/queryCache.d.cts.map +1 -1
- package/build/modern/queryCache.d.ts +1 -3
- package/build/modern/queryCache.d.ts.map +1 -1
- package/build/modern/queryCache.js +1 -2
- package/build/{legacy/queryClient-BoBzDWAZ.d.ts → modern/queryClient-CVne8UYf.d.ts} +57 -7
- package/build/modern/queryClient-CVne8UYf.d.ts.map +1 -0
- package/build/{legacy/queryClient-BK9W57Qu.d.cts → modern/queryClient-DdZQqhoA.d.cts} +57 -7
- package/build/modern/queryClient-DdZQqhoA.d.cts.map +1 -0
- package/build/modern/queryClient.cjs +1 -2
- 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 +1 -2
- package/build/modern/queryClient.js.map +1 -1
- package/build/{legacy/queryOptions-gpn5D4rf.d.ts → modern/queryOptions-BuZEBLtg.d.cts} +16 -16
- package/build/modern/queryOptions-BuZEBLtg.d.cts.map +1 -0
- package/build/{legacy/queryOptions-BvmZtmiU.d.cts → modern/queryOptions-dXiBZnGk.d.ts} +16 -16
- package/build/modern/queryOptions-dXiBZnGk.d.ts.map +1 -0
- package/build/modern/queryOptions.cjs +1 -2
- 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 +1 -2
- package/build/modern/queryOptions.js.map +1 -1
- package/build/{legacy/types-sdZdiLgo.d.cts → modern/types-u_Tu5Ybs.d.cts} +1 -3
- package/build/modern/{types-sdZdiLgo.d.ts.map → types-u_Tu5Ybs.d.cts.map} +1 -1
- package/build/modern/{types-sdZdiLgo.d.cts → types-u_Tu5Ybs.d.ts} +1 -3
- package/build/modern/types-u_Tu5Ybs.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 -2
- package/build/modern/useBaseQuery.d.cts +1 -1
- package/build/modern/useBaseQuery.d.ts +1 -1
- package/build/modern/useBaseQuery.js +1 -2
- package/build/modern/useInfiniteQuery.cjs +1 -2
- 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 +1 -2
- package/build/modern/useInfiniteQuery.js.map +1 -1
- package/build/modern/useIsFetching.cjs +1 -2
- package/build/modern/useIsFetching.cjs.map +1 -1
- package/build/modern/useIsFetching.d.cts +3 -5
- package/build/modern/useIsFetching.d.cts.map +1 -1
- package/build/modern/useIsFetching.d.ts +3 -5
- package/build/modern/useIsFetching.d.ts.map +1 -1
- package/build/modern/useIsFetching.js +1 -2
- package/build/modern/useIsFetching.js.map +1 -1
- package/build/modern/useMutation.cjs +1 -2
- package/build/modern/useMutation.d.cts +2 -4
- package/build/modern/useMutation.d.cts.map +1 -1
- package/build/modern/useMutation.d.ts +2 -4
- package/build/modern/useMutation.d.ts.map +1 -1
- package/build/modern/useMutation.js +1 -2
- package/build/modern/useMutationState.cjs +1 -2
- package/build/modern/useMutationState.d.cts +2 -4
- package/build/modern/useMutationState.d.cts.map +1 -1
- package/build/modern/useMutationState.d.ts +2 -4
- package/build/modern/useMutationState.d.ts.map +1 -1
- package/build/modern/useMutationState.js +1 -2
- package/build/modern/usePrefetchInfiniteQuery.cjs +1 -2
- package/build/modern/usePrefetchInfiniteQuery.d.cts +2 -4
- package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.ts +2 -4
- package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.js +1 -2
- package/build/modern/usePrefetchQuery.cjs +1 -2
- package/build/modern/usePrefetchQuery.d.cts +2 -4
- package/build/modern/usePrefetchQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchQuery.d.ts +2 -4
- package/build/modern/usePrefetchQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchQuery.js +1 -2
- package/build/modern/useQueries.cjs +1 -2
- package/build/modern/useQueries.d.cts +3 -5
- package/build/modern/useQueries.d.cts.map +1 -1
- package/build/modern/useQueries.d.ts +3 -5
- package/build/modern/useQueries.d.ts.map +1 -1
- package/build/modern/useQueries.js +1 -2
- package/build/modern/useQuery.cjs +1 -2
- package/build/modern/useQuery.cjs.map +1 -1
- package/build/modern/useQuery.d.cts +11 -12
- package/build/modern/useQuery.d.cts.map +1 -1
- package/build/modern/useQuery.d.ts +11 -12
- package/build/modern/useQuery.d.ts.map +1 -1
- package/build/modern/useQuery.js +1 -2
- package/build/modern/useQuery.js.map +1 -1
- package/build/modern/useQueryClient.cjs +1 -2
- package/build/modern/useQueryClient.d.cts +1 -3
- package/build/modern/useQueryClient.d.cts.map +1 -1
- package/build/modern/useQueryClient.d.ts +1 -3
- package/build/modern/useQueryClient.d.ts.map +1 -1
- package/build/modern/useQueryClient.js +1 -2
- package/build/modern/utils.cjs +1 -2
- package/build/modern/utils.cjs.map +1 -1
- package/build/modern/utils.d.cts +1 -3
- package/build/modern/utils.d.cts.map +1 -1
- package/build/modern/utils.d.ts +1 -3
- package/build/modern/utils.d.ts.map +1 -1
- package/build/modern/utils.js +1 -2
- package/build/modern/utils.js.map +1 -1
- package/build/modern/vueQueryPlugin.cjs +1 -2
- package/build/modern/vueQueryPlugin.d.cts +2 -4
- package/build/modern/vueQueryPlugin.d.cts.map +1 -1
- package/build/modern/vueQueryPlugin.d.ts +2 -4
- package/build/modern/vueQueryPlugin.d.ts.map +1 -1
- package/build/modern/vueQueryPlugin.js +1 -2
- package/package.json +2 -2
- package/src/infiniteQueryOptions.ts +28 -21
- package/src/queryClient.ts +68 -2
- package/src/queryOptions.ts +14 -12
- package/src/useInfiniteQuery.ts +3 -3
- package/src/useIsFetching.ts +2 -2
- package/src/useQuery.ts +7 -6
- package/src/utils.ts +4 -6
- package/build/legacy/infiniteQueryOptions-BaoKhSzb.d.ts.map +0 -1
- package/build/legacy/infiniteQueryOptions-ClNe2-FB.d.cts.map +0 -1
- package/build/legacy/queryClient-BK9W57Qu.d.cts.map +0 -1
- package/build/legacy/queryClient-BoBzDWAZ.d.ts.map +0 -1
- package/build/legacy/queryOptions-BvmZtmiU.d.cts.map +0 -1
- package/build/legacy/queryOptions-gpn5D4rf.d.ts.map +0 -1
- package/build/legacy/types-sdZdiLgo.d.cts.map +0 -1
- package/build/modern/infiniteQueryOptions-BaoKhSzb.d.ts.map +0 -1
- package/build/modern/infiniteQueryOptions-ClNe2-FB.d.cts.map +0 -1
- package/build/modern/queryClient-BK9W57Qu.d.cts.map +0 -1
- package/build/modern/queryClient-BoBzDWAZ.d.ts.map +0 -1
- package/build/modern/queryOptions-BvmZtmiU.d.cts.map +0 -1
- package/build/modern/queryOptions-gpn5D4rf.d.ts.map +0 -1
- package/build/modern/types-sdZdiLgo.d.cts.map +0 -1
|
@@ -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\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"}
|
|
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, may be `undefined`, or is a function that may\n * return `undefined` — `data` may be `undefined` while the query is `pending`. See\n * {@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 known to be defined, so the resulting `data` is never\n * `undefined` (unless 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`,\n * with `initialData` known to be defined.\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":";;;AAySA,SAAgB,SAMd,SAGA,aAG2C;CAC3C,OAAO,aAAa,eAAe,SAAS,WAAW;AACzD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_utils = require("./utils.cjs");
|
|
3
3
|
let vue_demi = require("vue-demi");
|
|
4
|
-
|
|
4
|
+
// src/useQueryClient.ts
|
|
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.
|
|
@@ -30,7 +30,6 @@ function useQueryClient(id = "") {
|
|
|
30
30
|
if (!queryClient) throw new Error("No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.");
|
|
31
31
|
return queryClient;
|
|
32
32
|
}
|
|
33
|
-
//#endregion
|
|
34
33
|
exports.useQueryClient = useQueryClient;
|
|
35
34
|
|
|
36
35
|
//# sourceMappingURL=useQueryClient.cjs.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { t as QueryClient } from "./queryClient-
|
|
2
|
-
//#region src/useQueryClient.d.ts
|
|
1
|
+
import { t as QueryClient } from "./queryClient-DdZQqhoA.cjs";
|
|
3
2
|
/**
|
|
4
3
|
* Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside
|
|
5
4
|
* `setup()` or another function that supports an injection context.
|
|
@@ -22,5 +21,4 @@ import { t as QueryClient } from "./queryClient-BK9W57Qu.cjs";
|
|
|
22
21
|
* ```
|
|
23
22
|
*/
|
|
24
23
|
export declare function useQueryClient(id?: string): QueryClient;
|
|
25
|
-
//#endregion
|
|
26
24
|
//# sourceMappingURL=useQueryClient.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueryClient.d.cts","names":[],"sources":["../../src/useQueryClient.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useQueryClient.d.cts","names":[],"sources":["../../src/useQueryClient.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;wBA0BgB,eAAe,cAAU"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { t as QueryClient } from "./queryClient-
|
|
2
|
-
//#region src/useQueryClient.d.ts
|
|
1
|
+
import { t as QueryClient } from "./queryClient-CVne8UYf.js";
|
|
3
2
|
/**
|
|
4
3
|
* Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside
|
|
5
4
|
* `setup()` or another function that supports an injection context.
|
|
@@ -22,5 +21,4 @@ import { t as QueryClient } from "./queryClient-BoBzDWAZ.js";
|
|
|
22
21
|
* ```
|
|
23
22
|
*/
|
|
24
23
|
export declare function useQueryClient(id?: string): QueryClient;
|
|
25
|
-
//#endregion
|
|
26
24
|
//# sourceMappingURL=useQueryClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueryClient.d.ts","names":[],"sources":["../../src/useQueryClient.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useQueryClient.d.ts","names":[],"sources":["../../src/useQueryClient.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;wBA0BgB,eAAe,cAAU"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getClientKey } from "./utils.js";
|
|
2
2
|
import { hasInjectionContext, inject } from "vue-demi";
|
|
3
|
-
|
|
3
|
+
// src/useQueryClient.ts
|
|
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.
|
|
@@ -29,7 +29,6 @@ function useQueryClient(id = "") {
|
|
|
29
29
|
if (!queryClient) throw new Error("No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.");
|
|
30
30
|
return queryClient;
|
|
31
31
|
}
|
|
32
|
-
//#endregion
|
|
33
32
|
export { useQueryClient };
|
|
34
33
|
|
|
35
34
|
//# sourceMappingURL=useQueryClient.js.map
|
package/build/modern/utils.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let vue_demi = require("vue-demi");
|
|
3
|
-
|
|
3
|
+
// src/utils.ts
|
|
4
4
|
/**
|
|
5
5
|
* Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under.
|
|
6
6
|
* @internal
|
|
@@ -108,7 +108,6 @@ function isFunction(value) {
|
|
|
108
108
|
function toValueDeep(source) {
|
|
109
109
|
return isFunction(source) ? source() : cloneDeepUnref(source);
|
|
110
110
|
}
|
|
111
|
-
//#endregion
|
|
112
111
|
exports.VUE_QUERY_CLIENT = VUE_QUERY_CLIENT;
|
|
113
112
|
exports.cloneDeep = cloneDeep;
|
|
114
113
|
exports.cloneDeepUnref = cloneDeepUnref;
|
|
@@ -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/**\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]) => [
|
|
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 as Record<string, any>).map(\n ([key, val]) => [key, _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 */\nfunction isPlainObject(value: unknown): value is Record<PropertyKey, unknown> {\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,KAA4B,CAAC,CAAC,KAC1D,CAAC,KAAK,SAAS,CAAC,KAAK,WAAW,KAAK,WAAW,KAAK,eAAe,CAAC,CAAC,CACzE;EACA,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;;;;;;;AAQA,SAAS,cAAc,OAAuD;CAC5E,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/modern/utils.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { o as MaybeRefDeep } from "./types-
|
|
2
|
-
//#region src/utils.d.ts
|
|
1
|
+
import { o as MaybeRefDeep } from "./types-u_Tu5Ybs.cjs";
|
|
3
2
|
/**
|
|
4
3
|
* Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under.
|
|
5
4
|
* @internal
|
|
@@ -48,5 +47,4 @@ export declare function cloneDeepUnref<T>(obj: MaybeRefDeep<T>, unrefGetters?: b
|
|
|
48
47
|
* @returns The resolved plain value.
|
|
49
48
|
*/
|
|
50
49
|
export declare function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T;
|
|
51
|
-
//#endregion
|
|
52
50
|
//# 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;;;;;;;;;;;wBA+DM,UAAU,GACxB,OAAO,aAAa,IACpB,aACE,KAAK,aAAa,IAClB,aACA,kBACG,gBACJ;;;;;;;;;;;wBAca,eAAe,GAC7B,KAAK,aAAa,IAClB,yBACC;;;;;;;wBAwDa,YAAY,GAAG,eAAe,KAAK,aAAa,KAAK"}
|
package/build/modern/utils.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { o as MaybeRefDeep } from "./types-
|
|
2
|
-
//#region src/utils.d.ts
|
|
1
|
+
import { o as MaybeRefDeep } from "./types-u_Tu5Ybs.js";
|
|
3
2
|
/**
|
|
4
3
|
* Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under.
|
|
5
4
|
* @internal
|
|
@@ -48,5 +47,4 @@ export declare function cloneDeepUnref<T>(obj: MaybeRefDeep<T>, unrefGetters?: b
|
|
|
48
47
|
* @returns The resolved plain value.
|
|
49
48
|
*/
|
|
50
49
|
export declare function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T;
|
|
51
|
-
//#endregion
|
|
52
50
|
//# 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;;;;;;;;;;;wBA+DM,UAAU,GACxB,OAAO,aAAa,IACpB,aACE,KAAK,aAAa,IAClB,aACA,kBACG,gBACJ;;;;;;;;;;;wBAca,eAAe,GAC7B,KAAK,aAAa,IAClB,yBACC;;;;;;;wBAwDa,YAAY,GAAG,eAAe,KAAK,aAAa,KAAK"}
|
package/build/modern/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isRef, unref } from "vue-demi";
|
|
2
|
-
|
|
2
|
+
// src/utils.ts
|
|
3
3
|
/**
|
|
4
4
|
* Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under.
|
|
5
5
|
* @internal
|
|
@@ -107,7 +107,6 @@ function isFunction(value) {
|
|
|
107
107
|
function toValueDeep(source) {
|
|
108
108
|
return isFunction(source) ? source() : cloneDeepUnref(source);
|
|
109
109
|
}
|
|
110
|
-
//#endregion
|
|
111
110
|
export { VUE_QUERY_CLIENT, cloneDeep, cloneDeepUnref, getClientKey, toValueDeep, updateState };
|
|
112
111
|
|
|
113
112
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"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]) => [
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"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 as Record<string, any>).map(\n ([key, val]) => [key, _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 */\nfunction isPlainObject(value: unknown): value is Record<PropertyKey, unknown> {\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,KAAa,MAAM,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,KAA4B,CAAC,CAAC,KAC1D,CAAC,KAAK,SAAS,CAAC,KAAK,WAAW,KAAK,WAAW,KAAK,eAAe,CAAC,CAAC,CACzE;EACA,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,IAAI,MAAM,GAAG,GACX,OAAO,eAAe,MAAM,GAAG,GAAG,YAAY;CAIlD,CAAC;AACH;;;;;;;AAQA,SAAS,cAAc,OAAuD;CAC5E,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"}
|
|
@@ -4,7 +4,7 @@ const require_queryClient = require("./queryClient.cjs");
|
|
|
4
4
|
const require_devtools_devtools = require("./devtools/devtools.cjs");
|
|
5
5
|
let _tanstack_query_core = require("@tanstack/query-core");
|
|
6
6
|
let vue_demi = require("vue-demi");
|
|
7
|
-
|
|
7
|
+
// src/vueQueryPlugin.ts
|
|
8
8
|
/**
|
|
9
9
|
* Installs a `QueryClient` on the Vue app, making it available to every descendant component through
|
|
10
10
|
* `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin
|
|
@@ -87,7 +87,6 @@ const VueQueryPlugin = { install: (app, options = {}) => {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
} };
|
|
90
|
-
//#endregion
|
|
91
90
|
exports.VueQueryPlugin = VueQueryPlugin;
|
|
92
91
|
|
|
93
92
|
//# sourceMappingURL=vueQueryPlugin.cjs.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { u as QueryClientConfig } from "./types-
|
|
2
|
-
import { t as QueryClient } from "./queryClient-
|
|
3
|
-
//#region src/vueQueryPlugin.d.ts
|
|
1
|
+
import { u as QueryClientConfig } from "./types-u_Tu5Ybs.cjs";
|
|
2
|
+
import { t as QueryClient } from "./queryClient-DdZQqhoA.cjs";
|
|
4
3
|
type ClientPersister = (client: QueryClient) => [() => void, Promise<void>];
|
|
5
4
|
interface CommonOptions {
|
|
6
5
|
/** Enables the legacy Vue Devtools v6 plugin panel. Prefer `@tanstack/vue-query-devtools` for Vue 3 apps. */
|
|
@@ -65,5 +64,4 @@ export type VueQueryPluginOptions = ConfigOptions | ClientOptions;
|
|
|
65
64
|
export declare const VueQueryPlugin: {
|
|
66
65
|
install: (app: any, options?: VueQueryPluginOptions) => void;
|
|
67
66
|
};
|
|
68
|
-
//#endregion
|
|
69
67
|
//# sourceMappingURL=vueQueryPlugin.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vueQueryPlugin.d.cts","names":[],"sources":["../../src/vueQueryPlugin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"vueQueryPlugin.d.cts","names":[],"sources":["../../src/vueQueryPlugin.ts"],"mappings":";;KAQK,mBAAmB,QAAQ,6BAA6B;UAEnD;;EAER;;;;;EAKA;;;;;EAKA,kBAAkB;;EAElB,4BAA4B,QAAQ;;UAG5B,sBAAsB;;EAE9B,oBAAoB;;UAGZ,sBAAsB;;EAE9B,cAAc;;;;;;YAOJ,wBAAwB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAiCvC;EACI,UAAA,UAAG,UAAW"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { u as QueryClientConfig } from "./types-
|
|
2
|
-
import { t as QueryClient } from "./queryClient-
|
|
3
|
-
//#region src/vueQueryPlugin.d.ts
|
|
1
|
+
import { u as QueryClientConfig } from "./types-u_Tu5Ybs.js";
|
|
2
|
+
import { t as QueryClient } from "./queryClient-CVne8UYf.js";
|
|
4
3
|
type ClientPersister = (client: QueryClient) => [() => void, Promise<void>];
|
|
5
4
|
interface CommonOptions {
|
|
6
5
|
/** Enables the legacy Vue Devtools v6 plugin panel. Prefer `@tanstack/vue-query-devtools` for Vue 3 apps. */
|
|
@@ -65,5 +64,4 @@ export type VueQueryPluginOptions = ConfigOptions | ClientOptions;
|
|
|
65
64
|
export declare const VueQueryPlugin: {
|
|
66
65
|
install: (app: any, options?: VueQueryPluginOptions) => void;
|
|
67
66
|
};
|
|
68
|
-
//#endregion
|
|
69
67
|
//# sourceMappingURL=vueQueryPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vueQueryPlugin.d.ts","names":[],"sources":["../../src/vueQueryPlugin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"vueQueryPlugin.d.ts","names":[],"sources":["../../src/vueQueryPlugin.ts"],"mappings":";;KAQK,mBAAmB,QAAQ,6BAA6B;UAEnD;;EAER;;;;;EAKA;;;;;EAKA,kBAAkB;;EAElB,4BAA4B,QAAQ;;UAG5B,sBAAsB;;EAE9B,oBAAoB;;UAGZ,sBAAsB;;EAE9B,cAAc;;;;;;YAOJ,wBAAwB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAiCvC;EACI,UAAA,UAAG,UAAW"}
|
|
@@ -3,7 +3,7 @@ import { QueryClient as QueryClient$1 } from "./queryClient.js";
|
|
|
3
3
|
import { setupDevtools } from "./devtools/devtools.js";
|
|
4
4
|
import { environmentManager } from "@tanstack/query-core";
|
|
5
5
|
import { isVue2 } from "vue-demi";
|
|
6
|
-
|
|
6
|
+
// src/vueQueryPlugin.ts
|
|
7
7
|
/**
|
|
8
8
|
* Installs a `QueryClient` on the Vue app, making it available to every descendant component through
|
|
9
9
|
* `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin
|
|
@@ -86,7 +86,6 @@ const VueQueryPlugin = { install: (app, options = {}) => {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
} };
|
|
89
|
-
//#endregion
|
|
90
89
|
export { VueQueryPlugin };
|
|
91
90
|
|
|
92
91
|
//# sourceMappingURL=vueQueryPlugin.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/vue-query",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.105.1",
|
|
4
4
|
"description": "Hooks for managing, caching and syncing asynchronous and remote data in Vue",
|
|
5
5
|
"author": "Damian Osipiuk",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@tanstack/match-sorter-utils": "^9.1.2",
|
|
43
|
-
"@tanstack/query-core": "5.
|
|
43
|
+
"@tanstack/query-core": "5.105.1",
|
|
44
44
|
"@vue/devtools-api": "^6.6.3",
|
|
45
45
|
"vue-demi": "^0.14.10"
|
|
46
46
|
},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
DefaultError,
|
|
3
3
|
InfiniteData,
|
|
4
|
+
InitialDataFunction,
|
|
4
5
|
NonUndefinedGuard,
|
|
5
6
|
QueryKey,
|
|
6
7
|
QueryKeyWithDataTag,
|
|
@@ -8,8 +9,9 @@ import type {
|
|
|
8
9
|
import type { UseInfiniteQueryOptions } from './useInfiniteQuery'
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
|
-
* The options accepted by the `infiniteQueryOptions` overload selected when
|
|
12
|
-
* may be `undefined` while the query is
|
|
12
|
+
* The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is omitted, may be
|
|
13
|
+
* `undefined`, or is a function that may return `undefined` — `data` may be `undefined` while the query is
|
|
14
|
+
* `pending`.
|
|
13
15
|
* @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
|
|
14
16
|
* @template TError - The type of errors your `queryFn` may throw.
|
|
15
17
|
* @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
|
|
@@ -30,12 +32,17 @@ export type UndefinedInitialDataInfiniteOptions<
|
|
|
30
32
|
TQueryKey,
|
|
31
33
|
TPageParam
|
|
32
34
|
> & {
|
|
33
|
-
initialData?:
|
|
35
|
+
initialData?:
|
|
36
|
+
| undefined
|
|
37
|
+
| NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>
|
|
38
|
+
| InitialDataFunction<
|
|
39
|
+
NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>
|
|
40
|
+
>
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
/**
|
|
37
|
-
* The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is
|
|
38
|
-
* never `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
44
|
+
* The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is known to be
|
|
45
|
+
* defined — `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
39
46
|
* @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
|
|
40
47
|
* @template TError - The type of errors your `queryFn` may throw.
|
|
41
48
|
* @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
|
|
@@ -72,8 +79,11 @@ export type DefinedInitialDataInfiniteOptions<
|
|
|
72
79
|
* You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.
|
|
73
80
|
* These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.
|
|
74
81
|
* `options.queryKey` is required and is the query key to generate options for.
|
|
75
|
-
*
|
|
76
|
-
* `
|
|
82
|
+
*
|
|
83
|
+
* This overload is selected when `initialData` is known to be defined, so the resulting `data` is never
|
|
84
|
+
* `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
85
|
+
* @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to
|
|
86
|
+
* `useInfiniteQuery`, with `initialData` known to be defined.
|
|
77
87
|
* @returns The same options object, typed so that `queryKey` carries the inferred data type.
|
|
78
88
|
* @see {@link useInfiniteQuery} to run an infinite query with these options.
|
|
79
89
|
* @example
|
|
@@ -86,9 +96,12 @@ export type DefinedInitialDataInfiniteOptions<
|
|
|
86
96
|
* queryFn: ({ pageParam }) => fetchProjects(pageParam),
|
|
87
97
|
* initialPageParam: 0,
|
|
88
98
|
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
99
|
+
* initialData: { pages: [], pageParams: [] },
|
|
89
100
|
* })
|
|
90
101
|
*
|
|
91
|
-
*
|
|
102
|
+
* // `data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the
|
|
103
|
+
* // list stays visible alongside the error.
|
|
104
|
+
* const { data, isError, error } = useInfiniteQuery(projectsOptions)
|
|
92
105
|
* </script>
|
|
93
106
|
* ```
|
|
94
107
|
*/
|
|
@@ -99,14 +112,14 @@ export function infiniteQueryOptions<
|
|
|
99
112
|
TQueryKey extends QueryKey = QueryKey,
|
|
100
113
|
TPageParam = unknown,
|
|
101
114
|
>(
|
|
102
|
-
options:
|
|
115
|
+
options: DefinedInitialDataInfiniteOptions<
|
|
103
116
|
TQueryFnData,
|
|
104
117
|
TError,
|
|
105
118
|
TData,
|
|
106
119
|
TQueryKey,
|
|
107
120
|
TPageParam
|
|
108
121
|
>,
|
|
109
|
-
):
|
|
122
|
+
): DefinedInitialDataInfiniteOptions<
|
|
110
123
|
TQueryFnData,
|
|
111
124
|
TError,
|
|
112
125
|
TData,
|
|
@@ -119,11 +132,8 @@ export function infiniteQueryOptions<
|
|
|
119
132
|
* You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.
|
|
120
133
|
* These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.
|
|
121
134
|
* `options.queryKey` is required and is the query key to generate options for.
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* a `select` changes `TData` to include `undefined`).
|
|
125
|
-
* @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to
|
|
126
|
-
* `useInfiniteQuery`, with `initialData` set.
|
|
135
|
+
* @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to
|
|
136
|
+
* `useInfiniteQuery`.
|
|
127
137
|
* @returns The same options object, typed so that `queryKey` carries the inferred data type.
|
|
128
138
|
* @see {@link useInfiniteQuery} to run an infinite query with these options.
|
|
129
139
|
* @example
|
|
@@ -136,12 +146,9 @@ export function infiniteQueryOptions<
|
|
|
136
146
|
* queryFn: ({ pageParam }) => fetchProjects(pageParam),
|
|
137
147
|
* initialPageParam: 0,
|
|
138
148
|
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
139
|
-
* initialData: { pages: [], pageParams: [] },
|
|
140
149
|
* })
|
|
141
150
|
*
|
|
142
|
-
*
|
|
143
|
-
* // list stays visible alongside the error.
|
|
144
|
-
* const { data, isError, error } = useInfiniteQuery(projectsOptions)
|
|
151
|
+
* const { data, isError, error, fetchNextPage } = useInfiniteQuery(projectsOptions)
|
|
145
152
|
* </script>
|
|
146
153
|
* ```
|
|
147
154
|
*/
|
|
@@ -152,14 +159,14 @@ export function infiniteQueryOptions<
|
|
|
152
159
|
TQueryKey extends QueryKey = QueryKey,
|
|
153
160
|
TPageParam = unknown,
|
|
154
161
|
>(
|
|
155
|
-
options:
|
|
162
|
+
options: UndefinedInitialDataInfiniteOptions<
|
|
156
163
|
TQueryFnData,
|
|
157
164
|
TError,
|
|
158
165
|
TData,
|
|
159
166
|
TQueryKey,
|
|
160
167
|
TPageParam
|
|
161
168
|
>,
|
|
162
|
-
):
|
|
169
|
+
): UndefinedInitialDataInfiniteOptions<
|
|
163
170
|
TQueryFnData,
|
|
164
171
|
TError,
|
|
165
172
|
TData,
|