@tanstack/vue-query 5.107.1 → 5.108.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/README.md +2 -3
  2. package/build/legacy/devtools/devtools.cjs +1 -1
  3. package/build/legacy/devtools/devtools.cjs.map +1 -1
  4. package/build/legacy/devtools/devtools.d.cts +1 -1
  5. package/build/legacy/devtools/devtools.d.ts +1 -1
  6. package/build/legacy/devtools/devtools.js +1 -1
  7. package/build/legacy/devtools/devtools.js.map +1 -1
  8. package/build/legacy/index.cjs +1 -1
  9. package/build/legacy/index.d.cts +3 -3
  10. package/build/legacy/index.d.ts +3 -3
  11. package/build/legacy/index.js +1 -1
  12. package/build/legacy/{infiniteQueryOptions-BSwO8rvy.d.cts → infiniteQueryOptions-CLfd_vOE.d.cts} +23 -15
  13. package/build/legacy/infiniteQueryOptions-CLfd_vOE.d.cts.map +1 -0
  14. package/build/legacy/{infiniteQueryOptions-Bq8UQFvj.d.ts → infiniteQueryOptions-vEnw-JaW.d.ts} +23 -15
  15. package/build/legacy/infiniteQueryOptions-vEnw-JaW.d.ts.map +1 -0
  16. package/build/legacy/infiniteQueryOptions.d.cts +1 -1
  17. package/build/legacy/infiniteQueryOptions.d.ts +1 -1
  18. package/build/{modern/queryClient-Bgw9hMbf.d.ts → legacy/queryClient-6AWIHAhP.d.ts} +2 -2
  19. package/build/legacy/{queryClient-Bgw9hMbf.d.ts.map → queryClient-6AWIHAhP.d.ts.map} +1 -1
  20. package/build/{modern/queryClient-BSSPWSvX.d.cts → legacy/queryClient-yJW8K_VP.d.cts} +2 -2
  21. package/build/legacy/{queryClient-BSSPWSvX.d.cts.map → queryClient-yJW8K_VP.d.cts.map} +1 -1
  22. package/build/legacy/queryClient.cjs +1 -1
  23. package/build/legacy/queryClient.cjs.map +1 -1
  24. package/build/legacy/queryClient.d.cts +1 -1
  25. package/build/legacy/queryClient.d.ts +1 -1
  26. package/build/legacy/queryClient.js +1 -1
  27. package/build/legacy/queryClient.js.map +1 -1
  28. package/build/{modern/queryOptions-B-eHjgaY.d.cts → legacy/queryOptions-nndmAASX.d.cts} +17 -14
  29. package/build/legacy/queryOptions-nndmAASX.d.cts.map +1 -0
  30. package/build/{modern/queryOptions-D1-foH1W.d.ts → legacy/queryOptions-v0l6M7Eo.d.ts} +17 -14
  31. package/build/legacy/queryOptions-v0l6M7Eo.d.ts.map +1 -0
  32. package/build/legacy/queryOptions.cjs.map +1 -1
  33. package/build/legacy/queryOptions.d.cts +1 -1
  34. package/build/legacy/queryOptions.d.ts +1 -1
  35. package/build/legacy/queryOptions.js.map +1 -1
  36. package/build/legacy/types-u_Tu5Ybs.d.cts.map +1 -1
  37. package/build/legacy/types-u_Tu5Ybs.d.ts.map +1 -1
  38. package/build/legacy/useBaseQuery.cjs.map +1 -1
  39. package/build/legacy/useBaseQuery.d.cts +1 -1
  40. package/build/legacy/useBaseQuery.d.ts +1 -1
  41. package/build/legacy/useBaseQuery.js.map +1 -1
  42. package/build/legacy/useInfiniteQuery.cjs.map +1 -1
  43. package/build/legacy/useInfiniteQuery.d.cts +1 -1
  44. package/build/legacy/useInfiniteQuery.d.ts +1 -1
  45. package/build/legacy/useInfiniteQuery.js.map +1 -1
  46. package/build/legacy/useIsFetching.cjs.map +1 -1
  47. package/build/legacy/useIsFetching.d.cts +1 -1
  48. package/build/legacy/useIsFetching.d.ts +1 -1
  49. package/build/legacy/useIsFetching.js.map +1 -1
  50. package/build/legacy/useMutation.cjs.map +1 -1
  51. package/build/legacy/useMutation.d.cts +1 -1
  52. package/build/legacy/useMutation.d.ts +1 -1
  53. package/build/legacy/useMutation.js.map +1 -1
  54. package/build/legacy/useMutationState.cjs.map +1 -1
  55. package/build/legacy/useMutationState.d.cts +1 -1
  56. package/build/legacy/useMutationState.d.ts +1 -1
  57. package/build/legacy/useMutationState.js.map +1 -1
  58. package/build/legacy/usePrefetchInfiniteQuery.cjs.map +1 -1
  59. package/build/legacy/usePrefetchInfiniteQuery.d.cts +1 -1
  60. package/build/legacy/usePrefetchInfiniteQuery.d.ts +1 -1
  61. package/build/legacy/usePrefetchInfiniteQuery.js.map +1 -1
  62. package/build/legacy/usePrefetchQuery.cjs.map +1 -1
  63. package/build/legacy/usePrefetchQuery.d.cts +1 -1
  64. package/build/legacy/usePrefetchQuery.d.ts +1 -1
  65. package/build/legacy/usePrefetchQuery.js.map +1 -1
  66. package/build/legacy/useQueries.cjs.map +1 -1
  67. package/build/legacy/useQueries.d.cts +2 -2
  68. package/build/legacy/useQueries.d.cts.map +1 -1
  69. package/build/legacy/useQueries.d.ts +2 -2
  70. package/build/legacy/useQueries.d.ts.map +1 -1
  71. package/build/legacy/useQueries.js.map +1 -1
  72. package/build/legacy/useQuery.cjs.map +1 -1
  73. package/build/legacy/useQuery.d.cts +37 -24
  74. package/build/legacy/useQuery.d.cts.map +1 -1
  75. package/build/legacy/useQuery.d.ts +37 -24
  76. package/build/legacy/useQuery.d.ts.map +1 -1
  77. package/build/legacy/useQuery.js.map +1 -1
  78. package/build/legacy/useQueryClient.cjs.map +1 -1
  79. package/build/legacy/useQueryClient.d.cts +1 -1
  80. package/build/legacy/useQueryClient.d.cts.map +1 -1
  81. package/build/legacy/useQueryClient.d.ts +1 -1
  82. package/build/legacy/useQueryClient.d.ts.map +1 -1
  83. package/build/legacy/useQueryClient.js.map +1 -1
  84. package/build/legacy/utils.cjs.map +1 -1
  85. package/build/legacy/utils.js.map +1 -1
  86. package/build/legacy/vueQueryPlugin.cjs +1 -1
  87. package/build/legacy/vueQueryPlugin.cjs.map +1 -1
  88. package/build/legacy/vueQueryPlugin.d.cts +1 -1
  89. package/build/legacy/vueQueryPlugin.d.cts.map +1 -1
  90. package/build/legacy/vueQueryPlugin.d.ts +1 -1
  91. package/build/legacy/vueQueryPlugin.d.ts.map +1 -1
  92. package/build/legacy/vueQueryPlugin.js +1 -1
  93. package/build/legacy/vueQueryPlugin.js.map +1 -1
  94. package/build/modern/devtools/devtools.cjs +1 -1
  95. package/build/modern/devtools/devtools.cjs.map +1 -1
  96. package/build/modern/devtools/devtools.d.cts +1 -1
  97. package/build/modern/devtools/devtools.d.ts +1 -1
  98. package/build/modern/devtools/devtools.js +1 -1
  99. package/build/modern/devtools/devtools.js.map +1 -1
  100. package/build/modern/index.cjs +1 -1
  101. package/build/modern/index.d.cts +3 -3
  102. package/build/modern/index.d.ts +3 -3
  103. package/build/modern/index.js +1 -1
  104. package/build/modern/{infiniteQueryOptions-BSwO8rvy.d.cts → infiniteQueryOptions-CLfd_vOE.d.cts} +23 -15
  105. package/build/modern/infiniteQueryOptions-CLfd_vOE.d.cts.map +1 -0
  106. package/build/modern/{infiniteQueryOptions-Bq8UQFvj.d.ts → infiniteQueryOptions-vEnw-JaW.d.ts} +23 -15
  107. package/build/modern/infiniteQueryOptions-vEnw-JaW.d.ts.map +1 -0
  108. package/build/modern/infiniteQueryOptions.d.cts +1 -1
  109. package/build/modern/infiniteQueryOptions.d.ts +1 -1
  110. package/build/{legacy/queryClient-Bgw9hMbf.d.ts → modern/queryClient-6AWIHAhP.d.ts} +2 -2
  111. package/build/modern/{queryClient-Bgw9hMbf.d.ts.map → queryClient-6AWIHAhP.d.ts.map} +1 -1
  112. package/build/{legacy/queryClient-BSSPWSvX.d.cts → modern/queryClient-yJW8K_VP.d.cts} +2 -2
  113. package/build/modern/{queryClient-BSSPWSvX.d.cts.map → queryClient-yJW8K_VP.d.cts.map} +1 -1
  114. package/build/modern/queryClient.cjs +1 -1
  115. package/build/modern/queryClient.cjs.map +1 -1
  116. package/build/modern/queryClient.d.cts +1 -1
  117. package/build/modern/queryClient.d.ts +1 -1
  118. package/build/modern/queryClient.js +1 -1
  119. package/build/modern/queryClient.js.map +1 -1
  120. package/build/{legacy/queryOptions-B-eHjgaY.d.cts → modern/queryOptions-nndmAASX.d.cts} +17 -14
  121. package/build/modern/queryOptions-nndmAASX.d.cts.map +1 -0
  122. package/build/{legacy/queryOptions-D1-foH1W.d.ts → modern/queryOptions-v0l6M7Eo.d.ts} +17 -14
  123. package/build/modern/queryOptions-v0l6M7Eo.d.ts.map +1 -0
  124. package/build/modern/queryOptions.cjs.map +1 -1
  125. package/build/modern/queryOptions.d.cts +1 -1
  126. package/build/modern/queryOptions.d.ts +1 -1
  127. package/build/modern/queryOptions.js.map +1 -1
  128. package/build/modern/types-u_Tu5Ybs.d.cts.map +1 -1
  129. package/build/modern/types-u_Tu5Ybs.d.ts.map +1 -1
  130. package/build/modern/useBaseQuery.cjs.map +1 -1
  131. package/build/modern/useBaseQuery.d.cts +1 -1
  132. package/build/modern/useBaseQuery.d.ts +1 -1
  133. package/build/modern/useBaseQuery.js.map +1 -1
  134. package/build/modern/useInfiniteQuery.cjs.map +1 -1
  135. package/build/modern/useInfiniteQuery.d.cts +1 -1
  136. package/build/modern/useInfiniteQuery.d.ts +1 -1
  137. package/build/modern/useInfiniteQuery.js.map +1 -1
  138. package/build/modern/useIsFetching.cjs.map +1 -1
  139. package/build/modern/useIsFetching.d.cts +1 -1
  140. package/build/modern/useIsFetching.d.ts +1 -1
  141. package/build/modern/useIsFetching.js.map +1 -1
  142. package/build/modern/useMutation.cjs.map +1 -1
  143. package/build/modern/useMutation.d.cts +1 -1
  144. package/build/modern/useMutation.d.ts +1 -1
  145. package/build/modern/useMutation.js.map +1 -1
  146. package/build/modern/useMutationState.cjs.map +1 -1
  147. package/build/modern/useMutationState.d.cts +1 -1
  148. package/build/modern/useMutationState.d.ts +1 -1
  149. package/build/modern/useMutationState.js.map +1 -1
  150. package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -1
  151. package/build/modern/usePrefetchInfiniteQuery.d.cts +1 -1
  152. package/build/modern/usePrefetchInfiniteQuery.d.ts +1 -1
  153. package/build/modern/usePrefetchInfiniteQuery.js.map +1 -1
  154. package/build/modern/usePrefetchQuery.cjs.map +1 -1
  155. package/build/modern/usePrefetchQuery.d.cts +1 -1
  156. package/build/modern/usePrefetchQuery.d.ts +1 -1
  157. package/build/modern/usePrefetchQuery.js.map +1 -1
  158. package/build/modern/useQueries.cjs.map +1 -1
  159. package/build/modern/useQueries.d.cts +2 -2
  160. package/build/modern/useQueries.d.cts.map +1 -1
  161. package/build/modern/useQueries.d.ts +2 -2
  162. package/build/modern/useQueries.d.ts.map +1 -1
  163. package/build/modern/useQueries.js.map +1 -1
  164. package/build/modern/useQuery.cjs.map +1 -1
  165. package/build/modern/useQuery.d.cts +37 -24
  166. package/build/modern/useQuery.d.cts.map +1 -1
  167. package/build/modern/useQuery.d.ts +37 -24
  168. package/build/modern/useQuery.d.ts.map +1 -1
  169. package/build/modern/useQuery.js.map +1 -1
  170. package/build/modern/useQueryClient.cjs.map +1 -1
  171. package/build/modern/useQueryClient.d.cts +1 -1
  172. package/build/modern/useQueryClient.d.cts.map +1 -1
  173. package/build/modern/useQueryClient.d.ts +1 -1
  174. package/build/modern/useQueryClient.d.ts.map +1 -1
  175. package/build/modern/useQueryClient.js.map +1 -1
  176. package/build/modern/utils.cjs.map +1 -1
  177. package/build/modern/utils.js.map +1 -1
  178. package/build/modern/vueQueryPlugin.cjs +1 -1
  179. package/build/modern/vueQueryPlugin.cjs.map +1 -1
  180. package/build/modern/vueQueryPlugin.d.cts +1 -1
  181. package/build/modern/vueQueryPlugin.d.cts.map +1 -1
  182. package/build/modern/vueQueryPlugin.d.ts +1 -1
  183. package/build/modern/vueQueryPlugin.d.ts.map +1 -1
  184. package/build/modern/vueQueryPlugin.js +1 -1
  185. package/build/modern/vueQueryPlugin.js.map +1 -1
  186. package/package.json +12 -2
  187. package/src/devtools/devtools.ts +2 -2
  188. package/src/index.ts +1 -0
  189. package/src/queryClient.ts +12 -12
  190. package/src/queryOptions.ts +23 -20
  191. package/src/types.ts +2 -0
  192. package/src/useBaseQuery.ts +3 -3
  193. package/src/useInfiniteQuery.ts +27 -21
  194. package/src/useIsFetching.ts +2 -2
  195. package/src/useMutation.ts +4 -4
  196. package/src/useMutationState.ts +2 -2
  197. package/src/usePrefetchInfiniteQuery.ts +1 -1
  198. package/src/usePrefetchQuery.ts +1 -1
  199. package/src/useQueries.ts +2 -3
  200. package/src/useQuery.ts +36 -23
  201. package/src/useQueryClient.ts +0 -1
  202. package/src/utils.ts +2 -2
  203. package/src/vueQueryPlugin.ts +2 -3
  204. package/build/legacy/infiniteQueryOptions-BSwO8rvy.d.cts.map +0 -1
  205. package/build/legacy/infiniteQueryOptions-Bq8UQFvj.d.ts.map +0 -1
  206. package/build/legacy/queryOptions-B-eHjgaY.d.cts.map +0 -1
  207. package/build/legacy/queryOptions-D1-foH1W.d.ts.map +0 -1
  208. package/build/modern/infiniteQueryOptions-BSwO8rvy.d.cts.map +0 -1
  209. package/build/modern/infiniteQueryOptions-Bq8UQFvj.d.ts.map +0 -1
  210. package/build/modern/queryOptions-B-eHjgaY.d.cts.map +0 -1
  211. package/build/modern/queryOptions-D1-foH1W.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useQuery.cjs","names":["useBaseQuery","QueryObserver"],"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. `state` is that result as one\n * reactive object — `state.data`, `state.isPending`, and the rest are plain values, and `state.status === 'success'`\n * narrows `state.data` to `TData`.\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 * @example\n * `state` keeps `data`, `error`, `status`, and `isPending` on one reactive object, so a `status` check\n * narrows `data` and you never read `.value`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const { state } = useQuery({\n * queryKey: ['post'],\n * queryFn: fetchPost,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"state.status === 'pending'\">Loading...</span>\n * <span v-else-if=\"state.status === 'error'\">Error: {{ state.error.message }}</span>\n * <h1 v-else>{{ state.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: 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":";;;;AA8TA,SAAgB,SAMd,SAGA,aAG2C;CAC3C,OAAOA,qBAAAA,aAAaC,qBAAAA,eAAe,SAAS,WAAW;AACzD"}
1
+ {"version":3,"file":"useQuery.cjs","names":["useBaseQuery","QueryObserver"],"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 { QueryClient } from './queryClient'\nimport type {\n DefinedInitialQueryOptions,\n UndefinedInitialQueryOptions,\n UseQueryOptions,\n} from './queryOptions'\nimport type { MaybeRefOrGetter } from './types'\nimport type { UseBaseQueryReturnType } from './useBaseQuery'\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 typed as never\n * `undefined` (unless a `select` changes `TData` to include `undefined`). At runtime, `data` is still `undefined`\n * if `select` throws on its first call.\n *\n * `enabled` accepts a `ref`, a plain boolean, or a zero-argument getter (`() => ...`): a `ref` or a getter is\n * tracked, while a plain boolean isn't tracked on its own. query-core's `(query) => boolean` callback is\n * accepted too and is passed through untracked. `queryKey` reacts through a `ref` or a reactive getter for the\n * array itself, or `ref`s and reactive getters as individual entries. Other options are read once when passed as\n * a plain value, and stay 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 `status` is `success` or `error` (`status` never resolves\n * to `pending` in this overload's type, since `initialData` guarantees data upfront). `status` is `error` if\n * the query has an error from a fetch that failed after its retries or if `select` threw, and `success`\n * otherwise. `isSuccess`/`isError` are derived boolean `ref`s for convenience. `state` is that result as one\n * readonly reactive object — `state.data`, `state.isPending`, and the rest are plain values.\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` accepts a `ref`, a plain boolean, or a zero-argument getter (`() => ...`): a `ref` or a getter is\n * tracked, while a plain boolean isn't tracked on its own. query-core's `(query) => boolean` callback is\n * accepted too and is passed through untracked. `queryKey` reacts through a `ref` or a reactive getter for the\n * array itself, or `ref`s and reactive getters as individual entries. Other options are read once when passed as\n * a plain value, and stay 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 `error` if the query has an error from a fetch that failed\n * after its retries or if `select` threw, `success` if the query has cached data (even if `select` returns\n * `undefined`) or data from `placeholderData`, and `pending` otherwise. `isPending`/`isSuccess`/`isError` are\n * derived boolean `ref`s for convenience. `state` is that result as one readonly reactive object —\n * `state.data`, `state.isPending`, and the rest are plain values, and `state.status === 'success'` narrows\n * `state.data` to `TData`.\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 * @example\n * `state` keeps `data`, `error`, `status`, and `isPending` on one reactive object, so a `status` check\n * narrows `data` and you never read `.value`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const { state } = useQuery({\n * queryKey: ['post'],\n * queryFn: fetchPost,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"state.status === 'pending'\">Loading...</span>\n * <span v-else-if=\"state.status === 'error'\">Error: {{ state.error.message }}</span>\n * <h1 v-else>{{ state.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: 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` accepts a `ref`, a plain boolean, or a zero-argument getter (`() => ...`): a `ref` or a getter is\n * tracked, while a plain boolean isn't tracked on its own. query-core's `(query) => boolean` callback is\n * accepted too and is passed through untracked. `queryKey` reacts through a `ref` or a reactive getter for the\n * array itself, or `ref`s and 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. `status` is `error` if the query has an error from a fetch that failed\n * after its retries or if `select` threw, `success` if the query has cached data (even if `select` returns\n * `undefined`) or data from `placeholderData`, and `pending` otherwise. `isPending`/`isSuccess`/`isError` are\n * derived boolean `ref`s for convenience. `state` is that result as one readonly reactive object —\n * `state.data`, `state.isPending`, and the rest are plain values, and `state.status === 'success'` narrows\n * `state.data` to `TData`.\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":";;;;AA2UA,SAAgB,SAMd,SAGA,aAG2C;CAC3C,OAAOA,qBAAAA,aAAaC,qBAAAA,eAAe,SAAS,WAAW;AACzD"}
@@ -1,7 +1,7 @@
1
1
  import { s as MaybeRefOrGetter } from "./types-u_Tu5Ybs.cjs";
2
- import { i as UndefinedInitialQueryOptions, o as UseQueryOptions, t as DefinedInitialQueryOptions } from "./queryOptions-B-eHjgaY.cjs";
3
- import { t as QueryClient$1 } from "./queryClient-BSSPWSvX.cjs";
4
- import { c as UseBaseQueryReturnType } from "./infiniteQueryOptions-BSwO8rvy.cjs";
2
+ import { i as UndefinedInitialQueryOptions, o as UseQueryOptions, t as DefinedInitialQueryOptions } from "./queryOptions-nndmAASX.cjs";
3
+ import { t as QueryClient$1 } from "./queryClient-yJW8K_VP.cjs";
4
+ import { c as UseBaseQueryReturnType } from "./infiniteQueryOptions-CLfd_vOE.cjs";
5
5
  import { DefaultError, DefinedQueryObserverResult, QueryKey } from "@tanstack/query-core";
6
6
  /**
7
7
  * The result of `useQuery` when `initialData` is omitted, may be `undefined`, or is a function that may
@@ -15,20 +15,24 @@ export type UseQueryReturnType<TData, TError> = UseBaseQueryReturnType<TData, TE
15
15
  */
16
16
  export type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<TData, TError, DefinedQueryObserverResult<TData, TError>>;
17
17
  /**
18
- * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never
19
- * `undefined` (unless a `select` changes `TData` to include `undefined`).
18
+ * This overload is selected when `initialData` is known to be defined, so the resulting `data` is typed as never
19
+ * `undefined` (unless a `select` changes `TData` to include `undefined`). At runtime, `data` is still `undefined`
20
+ * if `select` throws on its first call.
20
21
  *
21
- * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter
22
- * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and
23
- * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay
24
- * reactive when passed as a `ref` or a `computed`.
22
+ * `enabled` accepts a `ref`, a plain boolean, or a zero-argument getter (`() => ...`): a `ref` or a getter is
23
+ * tracked, while a plain boolean isn't tracked on its own. query-core's `(query) => boolean` callback is
24
+ * accepted too and is passed through untracked. `queryKey` reacts through a `ref` or a reactive getter for the
25
+ * array itself, or `ref`s and reactive getters as individual entries. Other options are read once when passed as
26
+ * a plain value, and stay reactive when passed as a `ref` or a `computed`.
25
27
  * @param options - The {@link DefinedInitialQueryOptions} to use — everything you can pass to `useQuery`,
26
28
  * with `initialData` known to be defined.
27
29
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
28
30
  * will be used.
29
- * @returns The current query result, typed so that `data` is never `undefined` (unless a `select` changes
30
- * `TData` to include `undefined`). `status` never resolves to `pending` in this overload's type, since
31
- * `initialData` guarantees data upfront.
31
+ * @returns The current query result, typed so that `status` is `success` or `error` (`status` never resolves
32
+ * to `pending` in this overload's type, since `initialData` guarantees data upfront). `status` is `error` if
33
+ * the query has an error from a fetch that failed after its retries or if `select` threw, and `success`
34
+ * otherwise. `isSuccess`/`isError` are derived boolean `ref`s for convenience. `state` is that result as one
35
+ * readonly reactive object — `state.data`, `state.isPending`, and the rest are plain values.
32
36
  * @example
33
37
  * ```vue
34
38
  * <script setup lang="ts">
@@ -53,17 +57,20 @@ export type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<TD
53
57
  */
54
58
  export declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient$1): UseQueryDefinedReturnType<TData, TError>;
55
59
  /**
56
- * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter
57
- * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and
58
- * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay
59
- * reactive when passed as a `ref` or a `computed`.
60
+ * `enabled` accepts a `ref`, a plain boolean, or a zero-argument getter (`() => ...`): a `ref` or a getter is
61
+ * tracked, while a plain boolean isn't tracked on its own. query-core's `(query) => boolean` callback is
62
+ * accepted too and is passed through untracked. `queryKey` reacts through a `ref` or a reactive getter for the
63
+ * array itself, or `ref`s and reactive getters as individual entries. Other options are read once when passed as
64
+ * a plain value, and stay reactive when passed as a `ref` or a `computed`.
60
65
  * @param options - The {@link UndefinedInitialQueryOptions} to use — everything you can pass to `useQuery`.
61
66
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
62
67
  * will be used.
63
- * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if
64
- * the last fetch attempt failed, or `success` if the query has data to display. `state` is that result as one
65
- * reactive object — `state.data`, `state.isPending`, and the rest are plain values, and `state.status === 'success'`
66
- * narrows `state.data` to `TData`.
68
+ * @returns The current query result. `status` is `error` if the query has an error from a fetch that failed
69
+ * after its retries or if `select` threw, `success` if the query has cached data (even if `select` returns
70
+ * `undefined`) or data from `placeholderData`, and `pending` otherwise. `isPending`/`isSuccess`/`isError` are
71
+ * derived boolean `ref`s for convenience. `state` is that result as one readonly reactive object —
72
+ * `state.data`, `state.isPending`, and the rest are plain values, and `state.status === 'success'` narrows
73
+ * `state.data` to `TData`.
67
74
  * @example
68
75
  * A query key built from a reactive `ref` — the query refetches whenever `postId` changes:
69
76
  * ```vue
@@ -208,16 +215,22 @@ export declare function useQuery<TQueryFnData = unknown, TError = DefaultError,
208
215
  * `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other
209
216
  * overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly.
210
217
  *
211
- * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter
212
- * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and
213
- * reactive getters as individual entries.
218
+ * `enabled` accepts a `ref`, a plain boolean, or a zero-argument getter (`() => ...`): a `ref` or a getter is
219
+ * tracked, while a plain boolean isn't tracked on its own. query-core's `(query) => boolean` callback is
220
+ * accepted too and is passed through untracked. `queryKey` reacts through a `ref` or a reactive getter for the
221
+ * array itself, or `ref`s and reactive getters as individual entries.
214
222
  *
215
223
  * When `options` itself is a reactive getter, the whole object is re-evaluated on every change to its
216
224
  * dependencies, so any option inside it — not just `queryKey` and `enabled` — can change over time.
217
225
  * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UseQueryOptions} to use.
218
226
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
219
227
  * will be used.
220
- * @returns The current query result, with `data` typed as possibly `undefined`.
228
+ * @returns The current query result. `status` is `error` if the query has an error from a fetch that failed
229
+ * after its retries or if `select` threw, `success` if the query has cached data (even if `select` returns
230
+ * `undefined`) or data from `placeholderData`, and `pending` otherwise. `isPending`/`isSuccess`/`isError` are
231
+ * derived boolean `ref`s for convenience. `state` is that result as one readonly reactive object —
232
+ * `state.data`, `state.isPending`, and the rest are plain values, and `state.status === 'success'` narrows
233
+ * `state.data` to `TData`.
221
234
  * @example
222
235
  * Passing a whole-options getter so `staleTime` reacts to a setting stored elsewhere, not just `queryKey`:
223
236
  * ```vue
@@ -1 +1 @@
1
- {"version":3,"file":"useQuery.d.cts","names":["QueryClient"],"sources":["../../src/useQuery.ts"],"mappings":";;;;;;;;;;YAqBY,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwJpB,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
+ {"version":3,"file":"useQuery.d.cts","names":["QueryClient"],"sources":["../../src/useQuery.ts"],"mappings":";;;;;;;;;;YAqBY,mBAAmB,OAAO,UAAU,uBAC9C,OACA;;;;;YAOU,0BAA0B,OAAO,UAAU,uBACrD,OACA,QACA,2BAA2B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA4CpB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,2BAA2B,cAAc,QAAQ,OAAO,YACjE,cAAcA,gBACb,0BAA0B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA2JpB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,6BAA6B,cAAc,QAAQ,OAAO,YACnE,cAAcA,gBACb,mBAAmB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAuEb,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,iBACP,gBAAgB,cAAc,QAAQ,OAAO,cAAc,aAE7D,cAAcA,gBACb,mBAAmB,OAAO"}
@@ -1,7 +1,7 @@
1
1
  import { s as MaybeRefOrGetter } from "./types-u_Tu5Ybs.js";
2
- import { i as UndefinedInitialQueryOptions, o as UseQueryOptions, t as DefinedInitialQueryOptions } from "./queryOptions-D1-foH1W.js";
3
- import { t as QueryClient$1 } from "./queryClient-Bgw9hMbf.js";
4
- import { c as UseBaseQueryReturnType } from "./infiniteQueryOptions-Bq8UQFvj.js";
2
+ import { i as UndefinedInitialQueryOptions, o as UseQueryOptions, t as DefinedInitialQueryOptions } from "./queryOptions-v0l6M7Eo.js";
3
+ import { t as QueryClient$1 } from "./queryClient-6AWIHAhP.js";
4
+ import { c as UseBaseQueryReturnType } from "./infiniteQueryOptions-vEnw-JaW.js";
5
5
  import { DefaultError, DefinedQueryObserverResult, QueryKey } from "@tanstack/query-core";
6
6
  /**
7
7
  * The result of `useQuery` when `initialData` is omitted, may be `undefined`, or is a function that may
@@ -15,20 +15,24 @@ export type UseQueryReturnType<TData, TError> = UseBaseQueryReturnType<TData, TE
15
15
  */
16
16
  export type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<TData, TError, DefinedQueryObserverResult<TData, TError>>;
17
17
  /**
18
- * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never
19
- * `undefined` (unless a `select` changes `TData` to include `undefined`).
18
+ * This overload is selected when `initialData` is known to be defined, so the resulting `data` is typed as never
19
+ * `undefined` (unless a `select` changes `TData` to include `undefined`). At runtime, `data` is still `undefined`
20
+ * if `select` throws on its first call.
20
21
  *
21
- * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter
22
- * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and
23
- * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay
24
- * reactive when passed as a `ref` or a `computed`.
22
+ * `enabled` accepts a `ref`, a plain boolean, or a zero-argument getter (`() => ...`): a `ref` or a getter is
23
+ * tracked, while a plain boolean isn't tracked on its own. query-core's `(query) => boolean` callback is
24
+ * accepted too and is passed through untracked. `queryKey` reacts through a `ref` or a reactive getter for the
25
+ * array itself, or `ref`s and reactive getters as individual entries. Other options are read once when passed as
26
+ * a plain value, and stay reactive when passed as a `ref` or a `computed`.
25
27
  * @param options - The {@link DefinedInitialQueryOptions} to use — everything you can pass to `useQuery`,
26
28
  * with `initialData` known to be defined.
27
29
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
28
30
  * will be used.
29
- * @returns The current query result, typed so that `data` is never `undefined` (unless a `select` changes
30
- * `TData` to include `undefined`). `status` never resolves to `pending` in this overload's type, since
31
- * `initialData` guarantees data upfront.
31
+ * @returns The current query result, typed so that `status` is `success` or `error` (`status` never resolves
32
+ * to `pending` in this overload's type, since `initialData` guarantees data upfront). `status` is `error` if
33
+ * the query has an error from a fetch that failed after its retries or if `select` threw, and `success`
34
+ * otherwise. `isSuccess`/`isError` are derived boolean `ref`s for convenience. `state` is that result as one
35
+ * readonly reactive object — `state.data`, `state.isPending`, and the rest are plain values.
32
36
  * @example
33
37
  * ```vue
34
38
  * <script setup lang="ts">
@@ -53,17 +57,20 @@ export type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<TD
53
57
  */
54
58
  export declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient$1): UseQueryDefinedReturnType<TData, TError>;
55
59
  /**
56
- * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter
57
- * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and
58
- * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay
59
- * reactive when passed as a `ref` or a `computed`.
60
+ * `enabled` accepts a `ref`, a plain boolean, or a zero-argument getter (`() => ...`): a `ref` or a getter is
61
+ * tracked, while a plain boolean isn't tracked on its own. query-core's `(query) => boolean` callback is
62
+ * accepted too and is passed through untracked. `queryKey` reacts through a `ref` or a reactive getter for the
63
+ * array itself, or `ref`s and reactive getters as individual entries. Other options are read once when passed as
64
+ * a plain value, and stay reactive when passed as a `ref` or a `computed`.
60
65
  * @param options - The {@link UndefinedInitialQueryOptions} to use — everything you can pass to `useQuery`.
61
66
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
62
67
  * will be used.
63
- * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if
64
- * the last fetch attempt failed, or `success` if the query has data to display. `state` is that result as one
65
- * reactive object — `state.data`, `state.isPending`, and the rest are plain values, and `state.status === 'success'`
66
- * narrows `state.data` to `TData`.
68
+ * @returns The current query result. `status` is `error` if the query has an error from a fetch that failed
69
+ * after its retries or if `select` threw, `success` if the query has cached data (even if `select` returns
70
+ * `undefined`) or data from `placeholderData`, and `pending` otherwise. `isPending`/`isSuccess`/`isError` are
71
+ * derived boolean `ref`s for convenience. `state` is that result as one readonly reactive object —
72
+ * `state.data`, `state.isPending`, and the rest are plain values, and `state.status === 'success'` narrows
73
+ * `state.data` to `TData`.
67
74
  * @example
68
75
  * A query key built from a reactive `ref` — the query refetches whenever `postId` changes:
69
76
  * ```vue
@@ -208,16 +215,22 @@ export declare function useQuery<TQueryFnData = unknown, TError = DefaultError,
208
215
  * `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other
209
216
  * overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly.
210
217
  *
211
- * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter
212
- * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and
213
- * reactive getters as individual entries.
218
+ * `enabled` accepts a `ref`, a plain boolean, or a zero-argument getter (`() => ...`): a `ref` or a getter is
219
+ * tracked, while a plain boolean isn't tracked on its own. query-core's `(query) => boolean` callback is
220
+ * accepted too and is passed through untracked. `queryKey` reacts through a `ref` or a reactive getter for the
221
+ * array itself, or `ref`s and reactive getters as individual entries.
214
222
  *
215
223
  * When `options` itself is a reactive getter, the whole object is re-evaluated on every change to its
216
224
  * dependencies, so any option inside it — not just `queryKey` and `enabled` — can change over time.
217
225
  * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UseQueryOptions} to use.
218
226
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
219
227
  * will be used.
220
- * @returns The current query result, with `data` typed as possibly `undefined`.
228
+ * @returns The current query result. `status` is `error` if the query has an error from a fetch that failed
229
+ * after its retries or if `select` threw, `success` if the query has cached data (even if `select` returns
230
+ * `undefined`) or data from `placeholderData`, and `pending` otherwise. `isPending`/`isSuccess`/`isError` are
231
+ * derived boolean `ref`s for convenience. `state` is that result as one readonly reactive object —
232
+ * `state.data`, `state.isPending`, and the rest are plain values, and `state.status === 'success'` narrows
233
+ * `state.data` to `TData`.
221
234
  * @example
222
235
  * Passing a whole-options getter so `staleTime` reacts to a setting stored elsewhere, not just `queryKey`:
223
236
  * ```vue
@@ -1 +1 @@
1
- {"version":3,"file":"useQuery.d.ts","names":["QueryClient"],"sources":["../../src/useQuery.ts"],"mappings":";;;;;;;;;;YAqBY,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwJpB,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
+ {"version":3,"file":"useQuery.d.ts","names":["QueryClient"],"sources":["../../src/useQuery.ts"],"mappings":";;;;;;;;;;YAqBY,mBAAmB,OAAO,UAAU,uBAC9C,OACA;;;;;YAOU,0BAA0B,OAAO,UAAU,uBACrD,OACA,QACA,2BAA2B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA4CpB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,2BAA2B,cAAc,QAAQ,OAAO,YACjE,cAAcA,gBACb,0BAA0B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA2JpB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,6BAA6B,cAAc,QAAQ,OAAO,YACnE,cAAcA,gBACb,mBAAmB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAuEb,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\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. `state` is that result as one\n * reactive object — `state.data`, `state.isPending`, and the rest are plain values, and `state.status === 'success'`\n * narrows `state.data` to `TData`.\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 * @example\n * `state` keeps `data`, `error`, `status`, and `isPending` on one reactive object, so a `status` check\n * narrows `data` and you never read `.value`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const { state } = useQuery({\n * queryKey: ['post'],\n * queryFn: fetchPost,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"state.status === 'pending'\">Loading...</span>\n * <span v-else-if=\"state.status === 'error'\">Error: {{ state.error.message }}</span>\n * <h1 v-else>{{ state.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: 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":";;;AA8TA,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 { QueryClient } from './queryClient'\nimport type {\n DefinedInitialQueryOptions,\n UndefinedInitialQueryOptions,\n UseQueryOptions,\n} from './queryOptions'\nimport type { MaybeRefOrGetter } from './types'\nimport type { UseBaseQueryReturnType } from './useBaseQuery'\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 typed as never\n * `undefined` (unless a `select` changes `TData` to include `undefined`). At runtime, `data` is still `undefined`\n * if `select` throws on its first call.\n *\n * `enabled` accepts a `ref`, a plain boolean, or a zero-argument getter (`() => ...`): a `ref` or a getter is\n * tracked, while a plain boolean isn't tracked on its own. query-core's `(query) => boolean` callback is\n * accepted too and is passed through untracked. `queryKey` reacts through a `ref` or a reactive getter for the\n * array itself, or `ref`s and reactive getters as individual entries. Other options are read once when passed as\n * a plain value, and stay 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 `status` is `success` or `error` (`status` never resolves\n * to `pending` in this overload's type, since `initialData` guarantees data upfront). `status` is `error` if\n * the query has an error from a fetch that failed after its retries or if `select` threw, and `success`\n * otherwise. `isSuccess`/`isError` are derived boolean `ref`s for convenience. `state` is that result as one\n * readonly reactive object — `state.data`, `state.isPending`, and the rest are plain values.\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` accepts a `ref`, a plain boolean, or a zero-argument getter (`() => ...`): a `ref` or a getter is\n * tracked, while a plain boolean isn't tracked on its own. query-core's `(query) => boolean` callback is\n * accepted too and is passed through untracked. `queryKey` reacts through a `ref` or a reactive getter for the\n * array itself, or `ref`s and reactive getters as individual entries. Other options are read once when passed as\n * a plain value, and stay 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 `error` if the query has an error from a fetch that failed\n * after its retries or if `select` threw, `success` if the query has cached data (even if `select` returns\n * `undefined`) or data from `placeholderData`, and `pending` otherwise. `isPending`/`isSuccess`/`isError` are\n * derived boolean `ref`s for convenience. `state` is that result as one readonly reactive object —\n * `state.data`, `state.isPending`, and the rest are plain values, and `state.status === 'success'` narrows\n * `state.data` to `TData`.\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 * @example\n * `state` keeps `data`, `error`, `status`, and `isPending` on one reactive object, so a `status` check\n * narrows `data` and you never read `.value`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const { state } = useQuery({\n * queryKey: ['post'],\n * queryFn: fetchPost,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"state.status === 'pending'\">Loading...</span>\n * <span v-else-if=\"state.status === 'error'\">Error: {{ state.error.message }}</span>\n * <h1 v-else>{{ state.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: 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` accepts a `ref`, a plain boolean, or a zero-argument getter (`() => ...`): a `ref` or a getter is\n * tracked, while a plain boolean isn't tracked on its own. query-core's `(query) => boolean` callback is\n * accepted too and is passed through untracked. `queryKey` reacts through a `ref` or a reactive getter for the\n * array itself, or `ref`s and 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. `status` is `error` if the query has an error from a fetch that failed\n * after its retries or if `select` threw, `success` if the query has cached data (even if `select` returns\n * `undefined`) or data from `placeholderData`, and `pending` otherwise. `isPending`/`isSuccess`/`isError` are\n * derived boolean `ref`s for convenience. `state` is that result as one readonly reactive object —\n * `state.data`, `state.isPending`, and the rest are plain values, and `state.status === 'success'` narrows\n * `state.data` to `TData`.\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":";;;AA2UA,SAAgB,SAMd,SAGA,aAG2C;CAC3C,OAAO,aAAa,eAAe,SAAS,WAAW;AACzD"}
@@ -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 * @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
+ {"version":3,"file":"useQueryClient.cjs","names":["hasInjectionContext","getClientKey","inject"],"sources":["../../src/useQueryClient.ts"],"sourcesContent":["import { hasInjectionContext, inject } from 'vue-demi'\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":";;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,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,4 +1,4 @@
1
- import { t as QueryClient } from "./queryClient-BSSPWSvX.cjs";
1
+ import { t as QueryClient } from "./queryClient-yJW8K_VP.cjs";
2
2
  /**
3
3
  * Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside
4
4
  * `setup()` or another function that supports an injection context.
@@ -1 +1 @@
1
- {"version":3,"file":"useQueryClient.d.cts","names":[],"sources":["../../src/useQueryClient.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;wBA0BgB,eAAe,cAAU"}
1
+ {"version":3,"file":"useQueryClient.d.cts","names":[],"sources":["../../src/useQueryClient.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;wBAyBgB,eAAe,cAAU"}
@@ -1,4 +1,4 @@
1
- import { t as QueryClient } from "./queryClient-Bgw9hMbf.js";
1
+ import { t as QueryClient } from "./queryClient-6AWIHAhP.js";
2
2
  /**
3
3
  * Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside
4
4
  * `setup()` or another function that supports an injection context.
@@ -1 +1 @@
1
- {"version":3,"file":"useQueryClient.d.ts","names":[],"sources":["../../src/useQueryClient.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;wBA0BgB,eAAe,cAAU"}
1
+ {"version":3,"file":"useQueryClient.d.ts","names":[],"sources":["../../src/useQueryClient.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;wBAyBgB,eAAe,cAAU"}
@@ -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 * @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"}
1
+ {"version":3,"file":"useQueryClient.js","names":[],"sources":["../../src/useQueryClient.ts"],"sourcesContent":["import { hasInjectionContext, inject } from 'vue-demi'\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":";;;;;;;;;;;;;;;;;;;;;;;;AAyBA,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"}
@@ -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 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"}
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 () => any)(), 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 (...args: Array<any>) => any {\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,IAAkB,GAAG,YAAY;EAI1D,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,OAAuD;CACzE,OAAO,OAAO,UAAU;AAC1B;;;;;;;AAQA,SAAgB,YAAe,QAAwC;CACrE,OAAO,WAAW,MAAM,IAAI,OAAO,IAAI,eAAe,MAAM;AAC9D"}
@@ -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 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"}
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 () => any)(), 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 (...args: Array<any>) => any {\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,IAAkB,GAAG,YAAY;EAI1D,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,OAAuD;CACzE,OAAO,OAAO,UAAU;AAC1B;;;;;;;AAQA,SAAgB,YAAe,QAAwC;CACrE,OAAO,WAAW,MAAM,IAAI,OAAO,IAAI,eAAe,MAAM;AAC9D"}
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_utils = require("./utils.cjs");
3
- const require_queryClient = require("./queryClient.cjs");
4
3
  const require_devtools_devtools = require("./devtools/devtools.cjs");
4
+ const require_queryClient = require("./queryClient.cjs");
5
5
  let _tanstack_query_core = require("@tanstack/query-core");
6
6
  let vue_demi = require("vue-demi");
7
7
  // src/vueQueryPlugin.ts
@@ -1 +1 @@
1
- {"version":3,"file":"vueQueryPlugin.cjs","names":["getClientKey","QueryClient","environmentManager","isVue2"],"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { environmentManager } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { QueryClientConfig } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n /** Enables the legacy Vue Devtools v6 plugin panel. Prefer `@tanstack/vue-query-devtools` for Vue 3 apps. */\n enableDevtoolsV6Plugin?: boolean\n /**\n * Distinguishes multiple `QueryClient`s provided in the same app — pass the same key to `useQueryClient` to\n * pick this one. Only needed when installing more than one client.\n */\n queryClientKey?: string\n /**\n * Restores a persisted cache before the app mounts. While it runs, `queryClient.isRestoring` is `true`, which\n * suppresses fetches — see `usePersistQueryClient` in `@tanstack/query-persist-client-core` for building one.\n */\n clientPersister?: ClientPersister\n /** Called once `clientPersister`'s returned promise resolves and the cache has finished restoring. */\n clientPersisterOnSuccess?: (client: QueryClient) => void\n}\n\ninterface ConfigOptions extends CommonOptions {\n /** Options for the `QueryClient` the plugin constructs. Ignored if `queryClient` is also set. */\n queryClientConfig?: QueryClientConfig\n}\n\ninterface ClientOptions extends CommonOptions {\n /** Use your own `QueryClient` instance instead of having the plugin construct one from `queryClientConfig`. */\n queryClient?: QueryClient\n}\n\n/**\n * The options accepted by `VueQueryPlugin`: either a `queryClient` to install, or a `queryClientConfig` for the\n * client the plugin creates, plus the shared options.\n */\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\n/**\n * Installs a `QueryClient` on the Vue app, making it available to every descendant component through\n * `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin\n * instead of a wrapping component.\n * @example\n * ```ts\n * import { createApp } from 'vue'\n * import { VueQueryPlugin } from '@tanstack/vue-query'\n *\n * const app = createApp(App)\n * app.use(VueQueryPlugin)\n * ```\n * @example\n * Pass a `queryClient` you constructed yourself — useful for SSR, where you need a fresh `QueryClient` per\n * request, or when the same instance also needs to be used outside of Vue components:\n * ```ts\n * import { QueryClient, VueQueryPlugin } from '@tanstack/vue-query'\n *\n * const queryClient = new QueryClient()\n * app.use(VueQueryPlugin, { queryClient })\n * ```\n * @example\n * Or pass `queryClientConfig` to let the plugin construct the `QueryClient` for you, with your own defaults:\n * ```ts\n * app.use(VueQueryPlugin, {\n * queryClientConfig: {\n * defaultOptions: { queries: { staleTime: 5 * 1000 } },\n * },\n * })\n * ```\n */\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!environmentManager.isServer()) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n if (client.isRestoring) {\n client.isRestoring.value = true\n }\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(\n () => {\n if (client.isRestoring) {\n client.isRestoring.value = false\n }\n options.clientPersisterOnSuccess?.(client)\n },\n () => {\n if (client.isRestoring) {\n client.isRestoring.value = false\n }\n },\n )\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root && options.enableDevtoolsV6Plugin) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n if (options.enableDevtoolsV6Plugin) {\n setupDevtools(app, client)\n }\n }\n }\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EA,MAAa,iBAAiB,EAC5B,UAAU,KAAU,UAAiC,CAAC,MAAM;CAC1D,MAAM,YAAYA,cAAAA,aAAa,QAAQ,cAAc;CACrD,IAAI;CAEJ,IAAI,iBAAiB,WAAW,QAAQ,aACtC,SAAS,QAAQ;MACZ;EACL,MAAM,eACJ,uBAAuB,UAAU,QAAQ,oBAAoB,KAAA;EAC/D,SAAS,IAAIC,oBAAAA,YAAY,YAAY;CACvC;CAEA,IAAI,CAACC,qBAAAA,mBAAmB,SAAS,GAC/B,OAAO,MAAM;CAGf,IAAI,yBAAyB,CAE7B;CAEA,IAAI,QAAQ,iBAAiB;EAC3B,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;EAE7B,MAAM,CAAC,SAAS,WAAW,QAAQ,gBAAgB,MAAM;EACzD,mBAAmB;EACnB,QAAQ,WACA;;GACJ,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;GAE7B,CAAA,wBAAA,QAAQ,8BAAA,QAAA,0BAAA,KAAA,KAAA,sBAAA,KAAA,SAA2B,MAAM;EAC3C,SACM;GACJ,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;EAE/B,CACF;CACF;CAEA,MAAM,gBAAgB;EACpB,OAAO,QAAQ;EACf,iBAAiB;CACnB;CAEA,IAAI,IAAI,WACN,IAAI,UAAU,OAAO;MAChB;EACL,MAAM,kBAAkB,IAAI;EAC5B,IAAI,UAAU,SAAS,kBAAkB;GACvC,QAAQ;GACR,gBAAgB;EAClB;CACF;CAEA,IAAIC,SAAAA,QACF,IAAI,MAAM,EACR,eAAe;EAEb,IAAI,CAAC,KAAK,WAAW;GACnB,MAAM,eAAe,CAAC;GACtB,OAAO,eAAe,MAAM,aAAa;IACvC,WAAW;IACX,MAAM,MAAM,OAAO,OAAO,cAAc,CAAC;GAC3C,CAAC;EACH;EAEA,KAAK,UAAU,aAAa;EAE5B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,SAAS,KAAK,SAAS,QAAQ,wBACjC,0BAAA,cAAc,MAAM,MAAM;EAAA;CAGhC,EACF,CAAC;MACI;EACL,IAAI,QAAQ,WAAW,MAAM;EAE7B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,QAAQ,wBACV,0BAAA,cAAc,KAAK,MAAM;EAAA;CAG/B;AACF,EACF"}
1
+ {"version":3,"file":"vueQueryPlugin.cjs","names":["getClientKey","QueryClient","environmentManager","isVue2"],"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { environmentManager } from '@tanstack/query-core'\nimport { isVue2 } from 'vue-demi'\nimport { setupDevtools } from './devtools/devtools'\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport type { QueryClientConfig } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n /** Enables the legacy Vue Devtools v6 plugin panel. Prefer `@tanstack/vue-query-devtools` for Vue 3 apps. */\n enableDevtoolsV6Plugin?: boolean\n /**\n * Distinguishes multiple `QueryClient`s provided in the same app — pass the same key to `useQueryClient` to\n * pick this one. Only needed when installing more than one client.\n */\n queryClientKey?: string\n /**\n * Restores a persisted cache before the app mounts. While it runs, `queryClient.isRestoring` is `true`, which\n * suppresses fetches — see `usePersistQueryClient` in `@tanstack/query-persist-client-core` for building one.\n */\n clientPersister?: ClientPersister\n /** Called once `clientPersister`'s returned promise resolves and the cache has finished restoring. */\n clientPersisterOnSuccess?: (client: QueryClient) => void\n}\n\ninterface ConfigOptions extends CommonOptions {\n /** Options for the `QueryClient` the plugin constructs. Ignored if `queryClient` is also set. */\n queryClientConfig?: QueryClientConfig\n}\n\ninterface ClientOptions extends CommonOptions {\n /** Use your own `QueryClient` instance instead of having the plugin construct one from `queryClientConfig`. */\n queryClient?: QueryClient\n}\n\n/**\n * The options accepted by `VueQueryPlugin`: either a `queryClient` to install, or a `queryClientConfig` for the\n * client the plugin creates, plus the shared options.\n */\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\n/**\n * Installs a `QueryClient` on the Vue app, making it available to every descendant component through\n * `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin\n * instead of a wrapping component.\n * @example\n * ```ts\n * import { createApp } from 'vue'\n * import { VueQueryPlugin } from '@tanstack/vue-query'\n *\n * const app = createApp(App)\n * app.use(VueQueryPlugin)\n * ```\n * @example\n * Pass a `queryClient` you constructed yourself — useful for SSR, where you need a fresh `QueryClient` per\n * request, or when the same instance also needs to be used outside of Vue components:\n * ```ts\n * import { QueryClient, VueQueryPlugin } from '@tanstack/vue-query'\n *\n * const queryClient = new QueryClient()\n * app.use(VueQueryPlugin, { queryClient })\n * ```\n * @example\n * Or pass `queryClientConfig` to let the plugin construct the `QueryClient` for you, with your own defaults:\n * ```ts\n * app.use(VueQueryPlugin, {\n * queryClientConfig: {\n * defaultOptions: { queries: { staleTime: 5 * 1000 } },\n * },\n * })\n * ```\n */\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!environmentManager.isServer()) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n if (client.isRestoring) {\n client.isRestoring.value = true\n }\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(\n () => {\n if (client.isRestoring) {\n client.isRestoring.value = false\n }\n options.clientPersisterOnSuccess?.(client)\n },\n () => {\n if (client.isRestoring) {\n client.isRestoring.value = false\n }\n },\n )\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root && options.enableDevtoolsV6Plugin) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n if (options.enableDevtoolsV6Plugin) {\n setupDevtools(app, client)\n }\n }\n }\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,MAAa,iBAAiB,EAC5B,UAAU,KAAU,UAAiC,CAAC,MAAM;CAC1D,MAAM,YAAYA,cAAAA,aAAa,QAAQ,cAAc;CACrD,IAAI;CAEJ,IAAI,iBAAiB,WAAW,QAAQ,aACtC,SAAS,QAAQ;MACZ;EACL,MAAM,eACJ,uBAAuB,UAAU,QAAQ,oBAAoB,KAAA;EAC/D,SAAS,IAAIC,oBAAAA,YAAY,YAAY;CACvC;CAEA,IAAI,CAACC,qBAAAA,mBAAmB,SAAS,GAC/B,OAAO,MAAM;CAGf,IAAI,yBAAyB,CAE7B;CAEA,IAAI,QAAQ,iBAAiB;EAC3B,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;EAE7B,MAAM,CAAC,SAAS,WAAW,QAAQ,gBAAgB,MAAM;EACzD,mBAAmB;EACnB,QAAQ,WACA;;GACJ,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;GAE7B,CAAA,wBAAA,QAAQ,8BAAA,QAAA,0BAAA,KAAA,KAAA,sBAAA,KAAA,SAA2B,MAAM;EAC3C,SACM;GACJ,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;EAE/B,CACF;CACF;CAEA,MAAM,gBAAgB;EACpB,OAAO,QAAQ;EACf,iBAAiB;CACnB;CAEA,IAAI,IAAI,WACN,IAAI,UAAU,OAAO;MAChB;EACL,MAAM,kBAAkB,IAAI;EAC5B,IAAI,UAAU,SAAS,kBAAkB;GACvC,QAAQ;GACR,gBAAgB;EAClB;CACF;CAEA,IAAIC,SAAAA,QACF,IAAI,MAAM,EACR,eAAe;EAEb,IAAI,CAAC,KAAK,WAAW;GACnB,MAAM,eAAe,CAAC;GACtB,OAAO,eAAe,MAAM,aAAa;IACvC,WAAW;IACX,MAAM,MAAM,OAAO,OAAO,cAAc,CAAC;GAC3C,CAAC;EACH;EAEA,KAAK,UAAU,aAAa;EAE5B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,SAAS,KAAK,SAAS,QAAQ,wBACjC,0BAAA,cAAc,MAAM,MAAM;EAAA;CAGhC,EACF,CAAC;MACI;EACL,IAAI,QAAQ,WAAW,MAAM;EAE7B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,QAAQ,wBACV,0BAAA,cAAc,KAAK,MAAM;EAAA;CAG/B;AACF,EACF"}
@@ -1,5 +1,5 @@
1
1
  import { u as QueryClientConfig } from "./types-u_Tu5Ybs.cjs";
2
- import { t as QueryClient } from "./queryClient-BSSPWSvX.cjs";
2
+ import { t as QueryClient } from "./queryClient-yJW8K_VP.cjs";
3
3
  type ClientPersister = (client: QueryClient) => [() => void, Promise<void>];
4
4
  interface CommonOptions {
5
5
  /** Enables the legacy Vue Devtools v6 plugin panel. Prefer `@tanstack/vue-query-devtools` for Vue 3 apps. */
@@ -1 +1 @@
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
+ {"version":3,"file":"vueQueryPlugin.d.cts","names":[],"sources":["../../src/vueQueryPlugin.ts"],"mappings":";;KAOK,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,5 +1,5 @@
1
1
  import { u as QueryClientConfig } from "./types-u_Tu5Ybs.js";
2
- import { t as QueryClient } from "./queryClient-Bgw9hMbf.js";
2
+ import { t as QueryClient } from "./queryClient-6AWIHAhP.js";
3
3
  type ClientPersister = (client: QueryClient) => [() => void, Promise<void>];
4
4
  interface CommonOptions {
5
5
  /** Enables the legacy Vue Devtools v6 plugin panel. Prefer `@tanstack/vue-query-devtools` for Vue 3 apps. */
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"vueQueryPlugin.d.ts","names":[],"sources":["../../src/vueQueryPlugin.ts"],"mappings":";;KAOK,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"}