@tanstack/vue-query 5.105.0 → 5.105.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (305) hide show
  1. package/build/legacy/devtools/devtools.cjs +1 -2
  2. package/build/legacy/devtools/devtools.d.cts +1 -3
  3. package/build/legacy/devtools/devtools.d.cts.map +1 -1
  4. package/build/legacy/devtools/devtools.d.ts +1 -3
  5. package/build/legacy/devtools/devtools.d.ts.map +1 -1
  6. package/build/legacy/devtools/devtools.js +1 -2
  7. package/build/legacy/devtools/utils.cjs +1 -2
  8. package/build/legacy/devtools/utils.d.cts +0 -2
  9. package/build/legacy/devtools/utils.d.cts.map +1 -1
  10. package/build/legacy/devtools/utils.d.ts +0 -2
  11. package/build/legacy/devtools/utils.d.ts.map +1 -1
  12. package/build/legacy/devtools/utils.js +1 -2
  13. package/build/legacy/index.d.cts +4 -4
  14. package/build/legacy/index.d.ts +4 -4
  15. package/build/legacy/{infiniteQueryOptions-CoRGgnPB.d.ts → infiniteQueryOptions-BLGtkUwV.d.ts} +28 -33
  16. package/build/legacy/infiniteQueryOptions-BLGtkUwV.d.ts.map +1 -0
  17. package/build/legacy/{infiniteQueryOptions-BOLnyklt.d.cts → infiniteQueryOptions-oStzZOCq.d.cts} +28 -33
  18. package/build/legacy/infiniteQueryOptions-oStzZOCq.d.cts.map +1 -0
  19. package/build/legacy/infiniteQueryOptions.cjs +1 -2
  20. package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
  21. package/build/legacy/infiniteQueryOptions.d.cts +1 -1
  22. package/build/legacy/infiniteQueryOptions.d.ts +1 -1
  23. package/build/legacy/infiniteQueryOptions.js +1 -2
  24. package/build/legacy/infiniteQueryOptions.js.map +1 -1
  25. package/build/legacy/mutationCache.cjs +1 -2
  26. package/build/legacy/mutationCache.d.cts +1 -3
  27. package/build/legacy/mutationCache.d.cts.map +1 -1
  28. package/build/legacy/mutationCache.d.ts +1 -3
  29. package/build/legacy/mutationCache.d.ts.map +1 -1
  30. package/build/legacy/mutationCache.js +1 -2
  31. package/build/legacy/mutationOptions.cjs +1 -2
  32. package/build/legacy/mutationOptions.d.cts +1 -3
  33. package/build/legacy/mutationOptions.d.cts.map +1 -1
  34. package/build/legacy/mutationOptions.d.ts +1 -3
  35. package/build/legacy/mutationOptions.d.ts.map +1 -1
  36. package/build/legacy/mutationOptions.js +1 -2
  37. package/build/legacy/queryCache.cjs +1 -2
  38. package/build/legacy/queryCache.d.cts +1 -3
  39. package/build/legacy/queryCache.d.cts.map +1 -1
  40. package/build/legacy/queryCache.d.ts +1 -3
  41. package/build/legacy/queryCache.d.ts.map +1 -1
  42. package/build/legacy/queryCache.js +1 -2
  43. package/build/{modern/queryClient-D4OU6h40.d.ts → legacy/queryClient-CVne8UYf.d.ts} +4 -6
  44. package/build/legacy/queryClient-CVne8UYf.d.ts.map +1 -0
  45. package/build/{modern/queryClient-4Y1X98Y3.d.cts → legacy/queryClient-DdZQqhoA.d.cts} +4 -6
  46. package/build/legacy/queryClient-DdZQqhoA.d.cts.map +1 -0
  47. package/build/legacy/queryClient.cjs +1 -2
  48. package/build/legacy/queryClient.cjs.map +1 -1
  49. package/build/legacy/queryClient.d.cts +1 -1
  50. package/build/legacy/queryClient.d.ts +1 -1
  51. package/build/legacy/queryClient.js +1 -2
  52. package/build/legacy/queryClient.js.map +1 -1
  53. package/build/{modern/queryOptions-gpn5D4rf.d.ts → legacy/queryOptions-BuZEBLtg.d.cts} +16 -16
  54. package/build/legacy/queryOptions-BuZEBLtg.d.cts.map +1 -0
  55. package/build/{modern/queryOptions-BvmZtmiU.d.cts → legacy/queryOptions-dXiBZnGk.d.ts} +16 -16
  56. package/build/legacy/queryOptions-dXiBZnGk.d.ts.map +1 -0
  57. package/build/legacy/queryOptions.cjs +1 -2
  58. package/build/legacy/queryOptions.cjs.map +1 -1
  59. package/build/legacy/queryOptions.d.cts +1 -1
  60. package/build/legacy/queryOptions.d.ts +1 -1
  61. package/build/legacy/queryOptions.js +1 -2
  62. package/build/legacy/queryOptions.js.map +1 -1
  63. package/build/legacy/{types-sdZdiLgo.d.ts → types-u_Tu5Ybs.d.cts} +1 -3
  64. package/build/legacy/{types-sdZdiLgo.d.ts.map → types-u_Tu5Ybs.d.cts.map} +1 -1
  65. package/build/{modern/types-sdZdiLgo.d.ts → legacy/types-u_Tu5Ybs.d.ts} +1 -3
  66. package/build/legacy/types-u_Tu5Ybs.d.ts.map +1 -0
  67. package/build/legacy/types.d.cts +1 -1
  68. package/build/legacy/types.d.ts +1 -1
  69. package/build/legacy/useBaseQuery.cjs +1 -2
  70. package/build/legacy/useBaseQuery.d.cts +1 -1
  71. package/build/legacy/useBaseQuery.d.ts +1 -1
  72. package/build/legacy/useBaseQuery.js +1 -2
  73. package/build/legacy/useInfiniteQuery.cjs +1 -2
  74. package/build/legacy/useInfiniteQuery.cjs.map +1 -1
  75. package/build/legacy/useInfiniteQuery.d.cts +1 -1
  76. package/build/legacy/useInfiniteQuery.d.ts +1 -1
  77. package/build/legacy/useInfiniteQuery.js +1 -2
  78. package/build/legacy/useInfiniteQuery.js.map +1 -1
  79. package/build/legacy/useIsFetching.cjs +1 -2
  80. package/build/legacy/useIsFetching.cjs.map +1 -1
  81. package/build/legacy/useIsFetching.d.cts +3 -5
  82. package/build/legacy/useIsFetching.d.cts.map +1 -1
  83. package/build/legacy/useIsFetching.d.ts +3 -5
  84. package/build/legacy/useIsFetching.d.ts.map +1 -1
  85. package/build/legacy/useIsFetching.js +1 -2
  86. package/build/legacy/useIsFetching.js.map +1 -1
  87. package/build/legacy/useMutation.cjs +1 -2
  88. package/build/legacy/useMutation.d.cts +2 -4
  89. package/build/legacy/useMutation.d.cts.map +1 -1
  90. package/build/legacy/useMutation.d.ts +2 -4
  91. package/build/legacy/useMutation.d.ts.map +1 -1
  92. package/build/legacy/useMutation.js +1 -2
  93. package/build/legacy/useMutationState.cjs +1 -2
  94. package/build/legacy/useMutationState.d.cts +2 -4
  95. package/build/legacy/useMutationState.d.cts.map +1 -1
  96. package/build/legacy/useMutationState.d.ts +2 -4
  97. package/build/legacy/useMutationState.d.ts.map +1 -1
  98. package/build/legacy/useMutationState.js +1 -2
  99. package/build/legacy/usePrefetchInfiniteQuery.cjs +1 -2
  100. package/build/legacy/usePrefetchInfiniteQuery.d.cts +2 -4
  101. package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -1
  102. package/build/legacy/usePrefetchInfiniteQuery.d.ts +2 -4
  103. package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -1
  104. package/build/legacy/usePrefetchInfiniteQuery.js +1 -2
  105. package/build/legacy/usePrefetchQuery.cjs +1 -2
  106. package/build/legacy/usePrefetchQuery.d.cts +2 -4
  107. package/build/legacy/usePrefetchQuery.d.cts.map +1 -1
  108. package/build/legacy/usePrefetchQuery.d.ts +2 -4
  109. package/build/legacy/usePrefetchQuery.d.ts.map +1 -1
  110. package/build/legacy/usePrefetchQuery.js +1 -2
  111. package/build/legacy/useQueries.cjs +1 -2
  112. package/build/legacy/useQueries.d.cts +3 -5
  113. package/build/legacy/useQueries.d.cts.map +1 -1
  114. package/build/legacy/useQueries.d.ts +3 -5
  115. package/build/legacy/useQueries.d.ts.map +1 -1
  116. package/build/legacy/useQueries.js +1 -2
  117. package/build/legacy/useQuery.cjs +1 -2
  118. package/build/legacy/useQuery.cjs.map +1 -1
  119. package/build/legacy/useQuery.d.cts +11 -12
  120. package/build/legacy/useQuery.d.cts.map +1 -1
  121. package/build/legacy/useQuery.d.ts +11 -12
  122. package/build/legacy/useQuery.d.ts.map +1 -1
  123. package/build/legacy/useQuery.js +1 -2
  124. package/build/legacy/useQuery.js.map +1 -1
  125. package/build/legacy/useQueryClient.cjs +1 -2
  126. package/build/legacy/useQueryClient.d.cts +1 -3
  127. package/build/legacy/useQueryClient.d.cts.map +1 -1
  128. package/build/legacy/useQueryClient.d.ts +1 -3
  129. package/build/legacy/useQueryClient.d.ts.map +1 -1
  130. package/build/legacy/useQueryClient.js +1 -2
  131. package/build/legacy/utils.cjs +1 -2
  132. package/build/legacy/utils.d.cts +1 -3
  133. package/build/legacy/utils.d.cts.map +1 -1
  134. package/build/legacy/utils.d.ts +1 -3
  135. package/build/legacy/utils.d.ts.map +1 -1
  136. package/build/legacy/utils.js +1 -2
  137. package/build/legacy/vueQueryPlugin.cjs +1 -2
  138. package/build/legacy/vueQueryPlugin.d.cts +2 -4
  139. package/build/legacy/vueQueryPlugin.d.cts.map +1 -1
  140. package/build/legacy/vueQueryPlugin.d.ts +2 -4
  141. package/build/legacy/vueQueryPlugin.d.ts.map +1 -1
  142. package/build/legacy/vueQueryPlugin.js +1 -2
  143. package/build/modern/devtools/devtools.cjs +1 -2
  144. package/build/modern/devtools/devtools.d.cts +1 -3
  145. package/build/modern/devtools/devtools.d.cts.map +1 -1
  146. package/build/modern/devtools/devtools.d.ts +1 -3
  147. package/build/modern/devtools/devtools.d.ts.map +1 -1
  148. package/build/modern/devtools/devtools.js +1 -2
  149. package/build/modern/devtools/utils.cjs +1 -2
  150. package/build/modern/devtools/utils.d.cts +0 -2
  151. package/build/modern/devtools/utils.d.cts.map +1 -1
  152. package/build/modern/devtools/utils.d.ts +0 -2
  153. package/build/modern/devtools/utils.d.ts.map +1 -1
  154. package/build/modern/devtools/utils.js +1 -2
  155. package/build/modern/index.d.cts +4 -4
  156. package/build/modern/index.d.ts +4 -4
  157. package/build/modern/{infiniteQueryOptions-CoRGgnPB.d.ts → infiniteQueryOptions-BLGtkUwV.d.ts} +28 -33
  158. package/build/modern/infiniteQueryOptions-BLGtkUwV.d.ts.map +1 -0
  159. package/build/modern/{infiniteQueryOptions-BOLnyklt.d.cts → infiniteQueryOptions-oStzZOCq.d.cts} +28 -33
  160. package/build/modern/infiniteQueryOptions-oStzZOCq.d.cts.map +1 -0
  161. package/build/modern/infiniteQueryOptions.cjs +1 -2
  162. package/build/modern/infiniteQueryOptions.cjs.map +1 -1
  163. package/build/modern/infiniteQueryOptions.d.cts +1 -1
  164. package/build/modern/infiniteQueryOptions.d.ts +1 -1
  165. package/build/modern/infiniteQueryOptions.js +1 -2
  166. package/build/modern/infiniteQueryOptions.js.map +1 -1
  167. package/build/modern/mutationCache.cjs +1 -2
  168. package/build/modern/mutationCache.d.cts +1 -3
  169. package/build/modern/mutationCache.d.cts.map +1 -1
  170. package/build/modern/mutationCache.d.ts +1 -3
  171. package/build/modern/mutationCache.d.ts.map +1 -1
  172. package/build/modern/mutationCache.js +1 -2
  173. package/build/modern/mutationOptions.cjs +1 -2
  174. package/build/modern/mutationOptions.d.cts +1 -3
  175. package/build/modern/mutationOptions.d.cts.map +1 -1
  176. package/build/modern/mutationOptions.d.ts +1 -3
  177. package/build/modern/mutationOptions.d.ts.map +1 -1
  178. package/build/modern/mutationOptions.js +1 -2
  179. package/build/modern/queryCache.cjs +1 -2
  180. package/build/modern/queryCache.d.cts +1 -3
  181. package/build/modern/queryCache.d.cts.map +1 -1
  182. package/build/modern/queryCache.d.ts +1 -3
  183. package/build/modern/queryCache.d.ts.map +1 -1
  184. package/build/modern/queryCache.js +1 -2
  185. package/build/{legacy/queryClient-D4OU6h40.d.ts → modern/queryClient-CVne8UYf.d.ts} +4 -6
  186. package/build/modern/queryClient-CVne8UYf.d.ts.map +1 -0
  187. package/build/{legacy/queryClient-4Y1X98Y3.d.cts → modern/queryClient-DdZQqhoA.d.cts} +4 -6
  188. package/build/modern/queryClient-DdZQqhoA.d.cts.map +1 -0
  189. package/build/modern/queryClient.cjs +1 -2
  190. package/build/modern/queryClient.cjs.map +1 -1
  191. package/build/modern/queryClient.d.cts +1 -1
  192. package/build/modern/queryClient.d.ts +1 -1
  193. package/build/modern/queryClient.js +1 -2
  194. package/build/modern/queryClient.js.map +1 -1
  195. package/build/{legacy/queryOptions-gpn5D4rf.d.ts → modern/queryOptions-BuZEBLtg.d.cts} +16 -16
  196. package/build/modern/queryOptions-BuZEBLtg.d.cts.map +1 -0
  197. package/build/{legacy/queryOptions-BvmZtmiU.d.cts → modern/queryOptions-dXiBZnGk.d.ts} +16 -16
  198. package/build/modern/queryOptions-dXiBZnGk.d.ts.map +1 -0
  199. package/build/modern/queryOptions.cjs +1 -2
  200. package/build/modern/queryOptions.cjs.map +1 -1
  201. package/build/modern/queryOptions.d.cts +1 -1
  202. package/build/modern/queryOptions.d.ts +1 -1
  203. package/build/modern/queryOptions.js +1 -2
  204. package/build/modern/queryOptions.js.map +1 -1
  205. package/build/{legacy/types-sdZdiLgo.d.cts → modern/types-u_Tu5Ybs.d.cts} +1 -3
  206. package/build/modern/{types-sdZdiLgo.d.ts.map → types-u_Tu5Ybs.d.cts.map} +1 -1
  207. package/build/modern/{types-sdZdiLgo.d.cts → types-u_Tu5Ybs.d.ts} +1 -3
  208. package/build/modern/types-u_Tu5Ybs.d.ts.map +1 -0
  209. package/build/modern/types.d.cts +1 -1
  210. package/build/modern/types.d.ts +1 -1
  211. package/build/modern/useBaseQuery.cjs +1 -2
  212. package/build/modern/useBaseQuery.d.cts +1 -1
  213. package/build/modern/useBaseQuery.d.ts +1 -1
  214. package/build/modern/useBaseQuery.js +1 -2
  215. package/build/modern/useInfiniteQuery.cjs +1 -2
  216. package/build/modern/useInfiniteQuery.cjs.map +1 -1
  217. package/build/modern/useInfiniteQuery.d.cts +1 -1
  218. package/build/modern/useInfiniteQuery.d.ts +1 -1
  219. package/build/modern/useInfiniteQuery.js +1 -2
  220. package/build/modern/useInfiniteQuery.js.map +1 -1
  221. package/build/modern/useIsFetching.cjs +1 -2
  222. package/build/modern/useIsFetching.cjs.map +1 -1
  223. package/build/modern/useIsFetching.d.cts +3 -5
  224. package/build/modern/useIsFetching.d.cts.map +1 -1
  225. package/build/modern/useIsFetching.d.ts +3 -5
  226. package/build/modern/useIsFetching.d.ts.map +1 -1
  227. package/build/modern/useIsFetching.js +1 -2
  228. package/build/modern/useIsFetching.js.map +1 -1
  229. package/build/modern/useMutation.cjs +1 -2
  230. package/build/modern/useMutation.d.cts +2 -4
  231. package/build/modern/useMutation.d.cts.map +1 -1
  232. package/build/modern/useMutation.d.ts +2 -4
  233. package/build/modern/useMutation.d.ts.map +1 -1
  234. package/build/modern/useMutation.js +1 -2
  235. package/build/modern/useMutationState.cjs +1 -2
  236. package/build/modern/useMutationState.d.cts +2 -4
  237. package/build/modern/useMutationState.d.cts.map +1 -1
  238. package/build/modern/useMutationState.d.ts +2 -4
  239. package/build/modern/useMutationState.d.ts.map +1 -1
  240. package/build/modern/useMutationState.js +1 -2
  241. package/build/modern/usePrefetchInfiniteQuery.cjs +1 -2
  242. package/build/modern/usePrefetchInfiniteQuery.d.cts +2 -4
  243. package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
  244. package/build/modern/usePrefetchInfiniteQuery.d.ts +2 -4
  245. package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
  246. package/build/modern/usePrefetchInfiniteQuery.js +1 -2
  247. package/build/modern/usePrefetchQuery.cjs +1 -2
  248. package/build/modern/usePrefetchQuery.d.cts +2 -4
  249. package/build/modern/usePrefetchQuery.d.cts.map +1 -1
  250. package/build/modern/usePrefetchQuery.d.ts +2 -4
  251. package/build/modern/usePrefetchQuery.d.ts.map +1 -1
  252. package/build/modern/usePrefetchQuery.js +1 -2
  253. package/build/modern/useQueries.cjs +1 -2
  254. package/build/modern/useQueries.d.cts +3 -5
  255. package/build/modern/useQueries.d.cts.map +1 -1
  256. package/build/modern/useQueries.d.ts +3 -5
  257. package/build/modern/useQueries.d.ts.map +1 -1
  258. package/build/modern/useQueries.js +1 -2
  259. package/build/modern/useQuery.cjs +1 -2
  260. package/build/modern/useQuery.cjs.map +1 -1
  261. package/build/modern/useQuery.d.cts +11 -12
  262. package/build/modern/useQuery.d.cts.map +1 -1
  263. package/build/modern/useQuery.d.ts +11 -12
  264. package/build/modern/useQuery.d.ts.map +1 -1
  265. package/build/modern/useQuery.js +1 -2
  266. package/build/modern/useQuery.js.map +1 -1
  267. package/build/modern/useQueryClient.cjs +1 -2
  268. package/build/modern/useQueryClient.d.cts +1 -3
  269. package/build/modern/useQueryClient.d.cts.map +1 -1
  270. package/build/modern/useQueryClient.d.ts +1 -3
  271. package/build/modern/useQueryClient.d.ts.map +1 -1
  272. package/build/modern/useQueryClient.js +1 -2
  273. package/build/modern/utils.cjs +1 -2
  274. package/build/modern/utils.d.cts +1 -3
  275. package/build/modern/utils.d.cts.map +1 -1
  276. package/build/modern/utils.d.ts +1 -3
  277. package/build/modern/utils.d.ts.map +1 -1
  278. package/build/modern/utils.js +1 -2
  279. package/build/modern/vueQueryPlugin.cjs +1 -2
  280. package/build/modern/vueQueryPlugin.d.cts +2 -4
  281. package/build/modern/vueQueryPlugin.d.cts.map +1 -1
  282. package/build/modern/vueQueryPlugin.d.ts +2 -4
  283. package/build/modern/vueQueryPlugin.d.ts.map +1 -1
  284. package/build/modern/vueQueryPlugin.js +1 -2
  285. package/package.json +2 -2
  286. package/src/infiniteQueryOptions.ts +28 -21
  287. package/src/queryClient.ts +3 -1
  288. package/src/queryOptions.ts +14 -12
  289. package/src/useInfiniteQuery.ts +3 -3
  290. package/src/useIsFetching.ts +2 -2
  291. package/src/useQuery.ts +7 -6
  292. package/build/legacy/infiniteQueryOptions-BOLnyklt.d.cts.map +0 -1
  293. package/build/legacy/infiniteQueryOptions-CoRGgnPB.d.ts.map +0 -1
  294. package/build/legacy/queryClient-4Y1X98Y3.d.cts.map +0 -1
  295. package/build/legacy/queryClient-D4OU6h40.d.ts.map +0 -1
  296. package/build/legacy/queryOptions-BvmZtmiU.d.cts.map +0 -1
  297. package/build/legacy/queryOptions-gpn5D4rf.d.ts.map +0 -1
  298. package/build/legacy/types-sdZdiLgo.d.cts.map +0 -1
  299. package/build/modern/infiniteQueryOptions-BOLnyklt.d.cts.map +0 -1
  300. package/build/modern/infiniteQueryOptions-CoRGgnPB.d.ts.map +0 -1
  301. package/build/modern/queryClient-4Y1X98Y3.d.cts.map +0 -1
  302. package/build/modern/queryClient-D4OU6h40.d.ts.map +0 -1
  303. package/build/modern/queryOptions-BvmZtmiU.d.cts.map +0 -1
  304. package/build/modern/queryOptions-gpn5D4rf.d.ts.map +0 -1
  305. package/build/modern/types-sdZdiLgo.d.cts.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 or may be `undefined` — `data` may be `undefined`\n * while the query is `pending`. See {@link UseBaseQueryReturnType}.\n */\nexport type UseQueryReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError\n>\n\n/**\n * The result of `useQuery` when `initialData` is set — `data` is never `undefined` (unless a `select` changes\n * `TData` to include `undefined`).\n */\nexport type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError,\n DefinedQueryObserverResult<TData, TError>\n>\n\n/**\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless\n * a `select` changes `TData` to include `undefined`).\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay\n * reactive when passed as a `ref` or a `computed`.\n * @param options - The {@link DefinedInitialQueryOptions} to use — everything you can pass to `useQuery`, with\n * `initialData` set.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result, typed so that `data` is never `undefined` (unless a `select` changes\n * `TData` to include `undefined`). `status` never resolves to `pending` in this overload's type, since\n * `initialData` guarantees data upfront.\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const { data, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <ul>\n * <li v-for=\"post in data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryDefinedReturnType<TData, TError>\n\n/**\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay\n * reactive when passed as a `ref` or a `computed`.\n * @param options - The {@link UndefinedInitialQueryOptions} to use — everything you can pass to `useQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if\n * the last fetch attempt failed, or `success` if the query has data to display.\n * @example\n * A query key built from a reactive `ref` — the query refetches whenever `postId` changes:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const postId = ref(1)\n * const { status, data, error } = useQuery({\n * queryKey: ['post', postId],\n * queryFn: () => fetchPost(postId.value),\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"status === 'pending'\">Loading...</span>\n * <span v-else-if=\"status === 'error'\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data.title }}</h1>\n * </template>\n * ```\n * @example\n * `select` derives whatever `data` a component needs from the cached value, without changing what's\n * actually stored in the cache — the cache still holds the full `Post[]`, but `data` here is a `number`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const { data, isPending, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * select: (posts) => posts.length,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isPending\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <span v-else>{{ data }} posts</span>\n * </template>\n * ```\n * @example\n * A dependent query, only enabled once `postId` is set — use `isLoading`, not `isPending`, so the\n * loading state doesn't show while the query is disabled:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number | undefined }>()\n *\n * const { data, isLoading, isError, error } = useQuery({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId!),\n * enabled: () => props.postId != null,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n * @example\n * Seeding a detail query from an already-cached list, to skip the loading state. `initialDataUpdatedAt` carries\n * over the list's own fetch time, so that if you set a `staleTime`, it's measured from when the list was\n * fetched rather than from now:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery, useQueryClient } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number }>()\n * const queryClient = useQueryClient()\n *\n * const { data, isError, error } = useQuery({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId),\n * initialData: () =>\n * queryClient\n * .getQueryData<Array<Post>>(['posts'])\n * ?.find((post) => post.id === props.postId),\n * initialDataUpdatedAt: () =>\n * queryClient.getQueryState(['posts'])?.dataUpdatedAt,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n * @example\n * Paginated data, keeping the previous page's data visible while the next page loads:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { keepPreviousData, useQuery } from '@tanstack/vue-query'\n *\n * const page = ref(0)\n *\n * const { data, isPlaceholderData, isError, error } = useQuery({\n * queryKey: ['posts', page],\n * queryFn: () => fetchPosts(page.value),\n * placeholderData: keepPreviousData,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <template v-else>\n * <ul>\n * <li v-for=\"post in data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * <button :disabled=\"isPlaceholderData\" @click=\"page++\">Next Page</button>\n * </template>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\n/**\n * Fallback overload for options whose `initialData` presence isn't statically known — for example, a\n * `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other\n * overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly.\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries.\n *\n * When `options` itself is a reactive getter, the whole object is re-evaluated on every change to its\n * dependencies, so any option inside it — not just `queryKey` and `enabled` — can change over time.\n * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UseQueryOptions} to use.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result, with `data` typed as possibly `undefined`.\n * @example\n * Passing a whole-options getter so `staleTime` reacts to a setting stored elsewhere, not just `queryKey`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ id: number; staleTime: number }>()\n *\n * const { data } = useQuery(() => ({\n * queryKey: ['post', props.id],\n * queryFn: () => fetchPost(props.id),\n * staleTime: props.staleTime,\n * }))\n * </script>\n *\n * <template>\n * <h1 v-if=\"data\">{{ data.title }}</h1>\n * </template>\n * ```\n * @example\n * `skipToken` disables the query in a type-safe way, without a non-null assertion on `props.postId` —\n * `queryFn` is only ever called when it's defined. The whole-options getter re-evaluates `queryFn` on every\n * change to `props.postId`. `queryFn` can also be a `computed`, but never a bare getter, since a function\n * there is the query function itself. `refetch` doesn't work while `queryFn` is `skipToken` — use\n * `enabled: false` instead if you need to trigger the query manually:\n * ```vue\n * <script setup lang=\"ts\">\n * import { skipToken, useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number | undefined }>()\n *\n * const { data, isLoading, isError, error } = useQuery(() => {\n * const postId = props.postId\n * return {\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * }\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n >,\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\nexport function useQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n >,\n queryClient?: QueryClient,\n):\n | UseQueryReturnType<TData, TError>\n | UseQueryDefinedReturnType<TData, TError> {\n return useBaseQuery(QueryObserver, options, queryClient)\n}\n"],"mappings":";;;;AAwSA,SAAgB,SAMd,SAGA,aAG2C;CAC3C,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 { UseBaseQueryReturnType } from './useBaseQuery'\nimport type { MaybeRefOrGetter } from './types'\nimport type { QueryClient } from './queryClient'\nimport type {\n DefinedInitialQueryOptions,\n UndefinedInitialQueryOptions,\n UseQueryOptions,\n} from './queryOptions'\n\n/**\n * The result of `useQuery` when `initialData` is omitted, may be `undefined`, or is a function that may\n * return `undefined` — `data` may be `undefined` while the query is `pending`. See\n * {@link UseBaseQueryReturnType}.\n */\nexport type UseQueryReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError\n>\n\n/**\n * The result of `useQuery` when `initialData` is set — `data` is never `undefined` (unless a `select` changes\n * `TData` to include `undefined`).\n */\nexport type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError,\n DefinedQueryObserverResult<TData, TError>\n>\n\n/**\n * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never\n * `undefined` (unless a `select` changes `TData` to include `undefined`).\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay\n * reactive when passed as a `ref` or a `computed`.\n * @param options - The {@link DefinedInitialQueryOptions} to use — everything you can pass to `useQuery`,\n * with `initialData` known to be defined.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result, typed so that `data` is never `undefined` (unless a `select` changes\n * `TData` to include `undefined`). `status` never resolves to `pending` in this overload's type, since\n * `initialData` guarantees data upfront.\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const { data, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <ul>\n * <li v-for=\"post in data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryDefinedReturnType<TData, TError>\n\n/**\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay\n * reactive when passed as a `ref` or a `computed`.\n * @param options - The {@link UndefinedInitialQueryOptions} to use — everything you can pass to `useQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if\n * the last fetch attempt failed, or `success` if the query has data to display.\n * @example\n * A query key built from a reactive `ref` — the query refetches whenever `postId` changes:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const postId = ref(1)\n * const { status, data, error } = useQuery({\n * queryKey: ['post', postId],\n * queryFn: () => fetchPost(postId.value),\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"status === 'pending'\">Loading...</span>\n * <span v-else-if=\"status === 'error'\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data.title }}</h1>\n * </template>\n * ```\n * @example\n * `select` derives whatever `data` a component needs from the cached value, without changing what's\n * actually stored in the cache — the cache still holds the full `Post[]`, but `data` here is a `number`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const { data, isPending, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * select: (posts) => posts.length,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isPending\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <span v-else>{{ data }} posts</span>\n * </template>\n * ```\n * @example\n * A dependent query, only enabled once `postId` is set — use `isLoading`, not `isPending`, so the\n * loading state doesn't show while the query is disabled:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number | undefined }>()\n *\n * const { data, isLoading, isError, error } = useQuery({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId!),\n * enabled: () => props.postId != null,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n * @example\n * Seeding a detail query from an already-cached list, to skip the loading state. `initialDataUpdatedAt` carries\n * over the list's own fetch time, so that if you set a `staleTime`, it's measured from when the list was\n * fetched rather than from now:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery, useQueryClient } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number }>()\n * const queryClient = useQueryClient()\n *\n * const { data, isError, error } = useQuery({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId),\n * initialData: () =>\n * queryClient\n * .getQueryData<Array<Post>>(['posts'])\n * ?.find((post) => post.id === props.postId),\n * initialDataUpdatedAt: () =>\n * queryClient.getQueryState(['posts'])?.dataUpdatedAt,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n * @example\n * Paginated data, keeping the previous page's data visible while the next page loads:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { keepPreviousData, useQuery } from '@tanstack/vue-query'\n *\n * const page = ref(0)\n *\n * const { data, isPlaceholderData, isError, error } = useQuery({\n * queryKey: ['posts', page],\n * queryFn: () => fetchPosts(page.value),\n * placeholderData: keepPreviousData,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <template v-else>\n * <ul>\n * <li v-for=\"post in data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * <button :disabled=\"isPlaceholderData\" @click=\"page++\">Next Page</button>\n * </template>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\n/**\n * Fallback overload for options whose `initialData` presence isn't statically known — for example, a\n * `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other\n * overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly.\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries.\n *\n * When `options` itself is a reactive getter, the whole object is re-evaluated on every change to its\n * dependencies, so any option inside it — not just `queryKey` and `enabled` — can change over time.\n * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UseQueryOptions} to use.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result, with `data` typed as possibly `undefined`.\n * @example\n * Passing a whole-options getter so `staleTime` reacts to a setting stored elsewhere, not just `queryKey`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ id: number; staleTime: number }>()\n *\n * const { data } = useQuery(() => ({\n * queryKey: ['post', props.id],\n * queryFn: () => fetchPost(props.id),\n * staleTime: props.staleTime,\n * }))\n * </script>\n *\n * <template>\n * <h1 v-if=\"data\">{{ data.title }}</h1>\n * </template>\n * ```\n * @example\n * `skipToken` disables the query in a type-safe way, without a non-null assertion on `props.postId` —\n * `queryFn` is only ever called when it's defined. The whole-options getter re-evaluates `queryFn` on every\n * change to `props.postId`. `queryFn` can also be a `computed`, but never a bare getter, since a function\n * there is the query function itself. `refetch` doesn't work while `queryFn` is `skipToken` — use\n * `enabled: false` instead if you need to trigger the query manually:\n * ```vue\n * <script setup lang=\"ts\">\n * import { skipToken, useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number | undefined }>()\n *\n * const { data, isLoading, isError, error } = useQuery(() => {\n * const postId = props.postId\n * return {\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * }\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n >,\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\nexport function useQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n >,\n queryClient?: QueryClient,\n):\n | UseQueryReturnType<TData, TError>\n | UseQueryDefinedReturnType<TData, TError> {\n return useBaseQuery(QueryObserver, options, queryClient)\n}\n"],"mappings":";;;;AAySA,SAAgB,SAMd,SAGA,aAG2C;CAC3C,OAAOA,qBAAAA,aAAaC,qBAAAA,eAAe,SAAS,WAAW;AACzD"}
@@ -1,12 +1,12 @@
1
- import { s as MaybeRefOrGetter } from "./types-sdZdiLgo.cjs";
2
- import { i as UndefinedInitialQueryOptions, o as UseQueryOptions, t as DefinedInitialQueryOptions } from "./queryOptions-BvmZtmiU.cjs";
3
- import { t as QueryClient$1 } from "./queryClient-4Y1X98Y3.cjs";
4
- import { s as UseBaseQueryReturnType } from "./infiniteQueryOptions-BOLnyklt.cjs";
1
+ import { s as MaybeRefOrGetter } from "./types-u_Tu5Ybs.cjs";
2
+ import { i as UndefinedInitialQueryOptions, o as UseQueryOptions, t as DefinedInitialQueryOptions } from "./queryOptions-BuZEBLtg.cjs";
3
+ import { t as QueryClient$1 } from "./queryClient-DdZQqhoA.cjs";
4
+ import { s as UseBaseQueryReturnType } from "./infiniteQueryOptions-oStzZOCq.cjs";
5
5
  import { DefaultError, DefinedQueryObserverResult, QueryKey } from "@tanstack/query-core";
6
- //#region src/useQuery.d.ts
7
6
  /**
8
- * The result of `useQuery` when `initialData` is omitted or may be `undefined` — `data` may be `undefined`
9
- * while the query is `pending`. See {@link UseBaseQueryReturnType}.
7
+ * The result of `useQuery` when `initialData` is omitted, may be `undefined`, or is a function that may
8
+ * return `undefined` — `data` may be `undefined` while the query is `pending`. See
9
+ * {@link UseBaseQueryReturnType}.
10
10
  */
11
11
  export type UseQueryReturnType<TData, TError> = UseBaseQueryReturnType<TData, TError>;
12
12
  /**
@@ -15,15 +15,15 @@ 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 set, so the resulting `data` is never `undefined` (unless
19
- * a `select` changes `TData` to include `undefined`).
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`).
20
20
  *
21
21
  * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter
22
22
  * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and
23
23
  * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay
24
24
  * reactive when passed as a `ref` or a `computed`.
25
- * @param options - The {@link DefinedInitialQueryOptions} to use — everything you can pass to `useQuery`, with
26
- * `initialData` set.
25
+ * @param options - The {@link DefinedInitialQueryOptions} to use — everything you can pass to `useQuery`,
26
+ * with `initialData` known to be defined.
27
27
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
28
28
  * will be used.
29
29
  * @returns The current query result, typed so that `data` is never `undefined` (unless a `select` changes
@@ -246,5 +246,4 @@ export declare function useQuery<TQueryFnData = unknown, TError = DefaultError,
246
246
  * ```
247
247
  */
248
248
  export declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: MaybeRefOrGetter<UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>>, queryClient?: QueryClient$1): UseQueryReturnType<TData, TError>;
249
- //#endregion
250
249
  //# sourceMappingURL=useQuery.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useQuery.d.cts","names":["QueryClient"],"sources":["../../src/useQuery.ts"],"mappings":";;;;;;;;;;YAoBY,mBAAmB,OAAO,UAAU,uBAC9C,OACA;;;;;YAOU,0BAA0B,OAAO,UAAU,uBACrD,OACA,QACA,2BAA2B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwCpB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,2BAA2B,cAAc,QAAQ,OAAO,YACjE,cAAcA,gBACb,0BAA0B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmIpB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,6BAA6B,cAAc,QAAQ,OAAO,YACnE,cAAcA,gBACb,mBAAmB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAiEb,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,iBACP,gBAAgB,cAAc,QAAQ,OAAO,cAAc,aAE7D,cAAcA,gBACb,mBAAmB,OAAO"}
1
+ {"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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmIpB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,6BAA6B,cAAc,QAAQ,OAAO,YACnE,cAAcA,gBACb,mBAAmB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAiEb,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,iBACP,gBAAgB,cAAc,QAAQ,OAAO,cAAc,aAE7D,cAAcA,gBACb,mBAAmB,OAAO"}
@@ -1,12 +1,12 @@
1
- import { s as MaybeRefOrGetter } from "./types-sdZdiLgo.js";
2
- import { i as UndefinedInitialQueryOptions, o as UseQueryOptions, t as DefinedInitialQueryOptions } from "./queryOptions-gpn5D4rf.js";
3
- import { t as QueryClient$1 } from "./queryClient-D4OU6h40.js";
4
- import { s as UseBaseQueryReturnType } from "./infiniteQueryOptions-CoRGgnPB.js";
1
+ import { s as MaybeRefOrGetter } from "./types-u_Tu5Ybs.js";
2
+ import { i as UndefinedInitialQueryOptions, o as UseQueryOptions, t as DefinedInitialQueryOptions } from "./queryOptions-dXiBZnGk.js";
3
+ import { t as QueryClient$1 } from "./queryClient-CVne8UYf.js";
4
+ import { s as UseBaseQueryReturnType } from "./infiniteQueryOptions-BLGtkUwV.js";
5
5
  import { DefaultError, DefinedQueryObserverResult, QueryKey } from "@tanstack/query-core";
6
- //#region src/useQuery.d.ts
7
6
  /**
8
- * The result of `useQuery` when `initialData` is omitted or may be `undefined` — `data` may be `undefined`
9
- * while the query is `pending`. See {@link UseBaseQueryReturnType}.
7
+ * The result of `useQuery` when `initialData` is omitted, may be `undefined`, or is a function that may
8
+ * return `undefined` — `data` may be `undefined` while the query is `pending`. See
9
+ * {@link UseBaseQueryReturnType}.
10
10
  */
11
11
  export type UseQueryReturnType<TData, TError> = UseBaseQueryReturnType<TData, TError>;
12
12
  /**
@@ -15,15 +15,15 @@ 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 set, so the resulting `data` is never `undefined` (unless
19
- * a `select` changes `TData` to include `undefined`).
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`).
20
20
  *
21
21
  * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter
22
22
  * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and
23
23
  * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay
24
24
  * reactive when passed as a `ref` or a `computed`.
25
- * @param options - The {@link DefinedInitialQueryOptions} to use — everything you can pass to `useQuery`, with
26
- * `initialData` set.
25
+ * @param options - The {@link DefinedInitialQueryOptions} to use — everything you can pass to `useQuery`,
26
+ * with `initialData` known to be defined.
27
27
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
28
28
  * will be used.
29
29
  * @returns The current query result, typed so that `data` is never `undefined` (unless a `select` changes
@@ -246,5 +246,4 @@ export declare function useQuery<TQueryFnData = unknown, TError = DefaultError,
246
246
  * ```
247
247
  */
248
248
  export declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: MaybeRefOrGetter<UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>>, queryClient?: QueryClient$1): UseQueryReturnType<TData, TError>;
249
- //#endregion
250
249
  //# sourceMappingURL=useQuery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useQuery.d.ts","names":["QueryClient"],"sources":["../../src/useQuery.ts"],"mappings":";;;;;;;;;;YAoBY,mBAAmB,OAAO,UAAU,uBAC9C,OACA;;;;;YAOU,0BAA0B,OAAO,UAAU,uBACrD,OACA,QACA,2BAA2B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwCpB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,2BAA2B,cAAc,QAAQ,OAAO,YACjE,cAAcA,gBACb,0BAA0B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmIpB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,6BAA6B,cAAc,QAAQ,OAAO,YACnE,cAAcA,gBACb,mBAAmB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAiEb,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,iBACP,gBAAgB,cAAc,QAAQ,OAAO,cAAc,aAE7D,cAAcA,gBACb,mBAAmB,OAAO"}
1
+ {"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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmIpB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,6BAA6B,cAAc,QAAQ,OAAO,YACnE,cAAcA,gBACb,mBAAmB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAiEb,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,iBACP,gBAAgB,cAAc,QAAQ,OAAO,cAAc,aAE7D,cAAcA,gBACb,mBAAmB,OAAO"}
@@ -1,10 +1,9 @@
1
1
  import { useBaseQuery } from "./useBaseQuery.js";
2
2
  import { QueryObserver } from "@tanstack/query-core";
3
- //#region src/useQuery.ts
3
+ // src/useQuery.ts
4
4
  function useQuery(options, queryClient) {
5
5
  return useBaseQuery(QueryObserver, options, queryClient);
6
6
  }
7
- //#endregion
8
7
  export { useQuery };
9
8
 
10
9
  //# sourceMappingURL=useQuery.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useQuery.js","names":[],"sources":["../../src/useQuery.ts"],"sourcesContent":["import { QueryObserver } from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n DefaultError,\n DefinedQueryObserverResult,\n QueryKey,\n} from '@tanstack/query-core'\nimport type { UseBaseQueryReturnType } from './useBaseQuery'\nimport type { MaybeRefOrGetter } from './types'\nimport type { QueryClient } from './queryClient'\nimport type {\n DefinedInitialQueryOptions,\n UndefinedInitialQueryOptions,\n UseQueryOptions,\n} from './queryOptions'\n\n/**\n * The result of `useQuery` when `initialData` is omitted or may be `undefined` — `data` may be `undefined`\n * while the query is `pending`. See {@link UseBaseQueryReturnType}.\n */\nexport type UseQueryReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError\n>\n\n/**\n * The result of `useQuery` when `initialData` is set — `data` is never `undefined` (unless a `select` changes\n * `TData` to include `undefined`).\n */\nexport type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError,\n DefinedQueryObserverResult<TData, TError>\n>\n\n/**\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless\n * a `select` changes `TData` to include `undefined`).\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay\n * reactive when passed as a `ref` or a `computed`.\n * @param options - The {@link DefinedInitialQueryOptions} to use — everything you can pass to `useQuery`, with\n * `initialData` set.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result, typed so that `data` is never `undefined` (unless a `select` changes\n * `TData` to include `undefined`). `status` never resolves to `pending` in this overload's type, since\n * `initialData` guarantees data upfront.\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const { data, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <ul>\n * <li v-for=\"post in data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryDefinedReturnType<TData, TError>\n\n/**\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay\n * reactive when passed as a `ref` or a `computed`.\n * @param options - The {@link UndefinedInitialQueryOptions} to use — everything you can pass to `useQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if\n * the last fetch attempt failed, or `success` if the query has data to display.\n * @example\n * A query key built from a reactive `ref` — the query refetches whenever `postId` changes:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const postId = ref(1)\n * const { status, data, error } = useQuery({\n * queryKey: ['post', postId],\n * queryFn: () => fetchPost(postId.value),\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"status === 'pending'\">Loading...</span>\n * <span v-else-if=\"status === 'error'\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data.title }}</h1>\n * </template>\n * ```\n * @example\n * `select` derives whatever `data` a component needs from the cached value, without changing what's\n * actually stored in the cache — the cache still holds the full `Post[]`, but `data` here is a `number`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const { data, isPending, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * select: (posts) => posts.length,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isPending\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <span v-else>{{ data }} posts</span>\n * </template>\n * ```\n * @example\n * A dependent query, only enabled once `postId` is set — use `isLoading`, not `isPending`, so the\n * loading state doesn't show while the query is disabled:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number | undefined }>()\n *\n * const { data, isLoading, isError, error } = useQuery({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId!),\n * enabled: () => props.postId != null,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n * @example\n * Seeding a detail query from an already-cached list, to skip the loading state. `initialDataUpdatedAt` carries\n * over the list's own fetch time, so that if you set a `staleTime`, it's measured from when the list was\n * fetched rather than from now:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery, useQueryClient } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number }>()\n * const queryClient = useQueryClient()\n *\n * const { data, isError, error } = useQuery({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId),\n * initialData: () =>\n * queryClient\n * .getQueryData<Array<Post>>(['posts'])\n * ?.find((post) => post.id === props.postId),\n * initialDataUpdatedAt: () =>\n * queryClient.getQueryState(['posts'])?.dataUpdatedAt,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n * @example\n * Paginated data, keeping the previous page's data visible while the next page loads:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { keepPreviousData, useQuery } from '@tanstack/vue-query'\n *\n * const page = ref(0)\n *\n * const { data, isPlaceholderData, isError, error } = useQuery({\n * queryKey: ['posts', page],\n * queryFn: () => fetchPosts(page.value),\n * placeholderData: keepPreviousData,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <template v-else>\n * <ul>\n * <li v-for=\"post in data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * <button :disabled=\"isPlaceholderData\" @click=\"page++\">Next Page</button>\n * </template>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\n/**\n * Fallback overload for options whose `initialData` presence isn't statically known — for example, a\n * `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other\n * overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly.\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries.\n *\n * When `options` itself is a reactive getter, the whole object is re-evaluated on every change to its\n * dependencies, so any option inside it — not just `queryKey` and `enabled` — can change over time.\n * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UseQueryOptions} to use.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result, with `data` typed as possibly `undefined`.\n * @example\n * Passing a whole-options getter so `staleTime` reacts to a setting stored elsewhere, not just `queryKey`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ id: number; staleTime: number }>()\n *\n * const { data } = useQuery(() => ({\n * queryKey: ['post', props.id],\n * queryFn: () => fetchPost(props.id),\n * staleTime: props.staleTime,\n * }))\n * </script>\n *\n * <template>\n * <h1 v-if=\"data\">{{ data.title }}</h1>\n * </template>\n * ```\n * @example\n * `skipToken` disables the query in a type-safe way, without a non-null assertion on `props.postId` —\n * `queryFn` is only ever called when it's defined. The whole-options getter re-evaluates `queryFn` on every\n * change to `props.postId`. `queryFn` can also be a `computed`, but never a bare getter, since a function\n * there is the query function itself. `refetch` doesn't work while `queryFn` is `skipToken` — use\n * `enabled: false` instead if you need to trigger the query manually:\n * ```vue\n * <script setup lang=\"ts\">\n * import { skipToken, useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number | undefined }>()\n *\n * const { data, isLoading, isError, error } = useQuery(() => {\n * const postId = props.postId\n * return {\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * }\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n >,\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\nexport function useQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n >,\n queryClient?: QueryClient,\n):\n | UseQueryReturnType<TData, TError>\n | UseQueryDefinedReturnType<TData, TError> {\n return useBaseQuery(QueryObserver, options, queryClient)\n}\n"],"mappings":";;;AAwSA,SAAgB,SAMd,SAGA,aAG2C;CAC3C,OAAO,aAAa,eAAe,SAAS,WAAW;AACzD"}
1
+ {"version":3,"file":"useQuery.js","names":[],"sources":["../../src/useQuery.ts"],"sourcesContent":["import { QueryObserver } from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n DefaultError,\n DefinedQueryObserverResult,\n QueryKey,\n} from '@tanstack/query-core'\nimport type { UseBaseQueryReturnType } from './useBaseQuery'\nimport type { MaybeRefOrGetter } from './types'\nimport type { QueryClient } from './queryClient'\nimport type {\n DefinedInitialQueryOptions,\n UndefinedInitialQueryOptions,\n UseQueryOptions,\n} from './queryOptions'\n\n/**\n * The result of `useQuery` when `initialData` is omitted, may be `undefined`, or is a function that may\n * return `undefined` — `data` may be `undefined` while the query is `pending`. See\n * {@link UseBaseQueryReturnType}.\n */\nexport type UseQueryReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError\n>\n\n/**\n * The result of `useQuery` when `initialData` is set — `data` is never `undefined` (unless a `select` changes\n * `TData` to include `undefined`).\n */\nexport type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError,\n DefinedQueryObserverResult<TData, TError>\n>\n\n/**\n * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never\n * `undefined` (unless a `select` changes `TData` to include `undefined`).\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay\n * reactive when passed as a `ref` or a `computed`.\n * @param options - The {@link DefinedInitialQueryOptions} to use — everything you can pass to `useQuery`,\n * with `initialData` known to be defined.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result, typed so that `data` is never `undefined` (unless a `select` changes\n * `TData` to include `undefined`). `status` never resolves to `pending` in this overload's type, since\n * `initialData` guarantees data upfront.\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const { data, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <ul>\n * <li v-for=\"post in data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryDefinedReturnType<TData, TError>\n\n/**\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay\n * reactive when passed as a `ref` or a `computed`.\n * @param options - The {@link UndefinedInitialQueryOptions} to use — everything you can pass to `useQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if\n * the last fetch attempt failed, or `success` if the query has data to display.\n * @example\n * A query key built from a reactive `ref` — the query refetches whenever `postId` changes:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const postId = ref(1)\n * const { status, data, error } = useQuery({\n * queryKey: ['post', postId],\n * queryFn: () => fetchPost(postId.value),\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"status === 'pending'\">Loading...</span>\n * <span v-else-if=\"status === 'error'\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data.title }}</h1>\n * </template>\n * ```\n * @example\n * `select` derives whatever `data` a component needs from the cached value, without changing what's\n * actually stored in the cache — the cache still holds the full `Post[]`, but `data` here is a `number`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const { data, isPending, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * select: (posts) => posts.length,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isPending\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <span v-else>{{ data }} posts</span>\n * </template>\n * ```\n * @example\n * A dependent query, only enabled once `postId` is set — use `isLoading`, not `isPending`, so the\n * loading state doesn't show while the query is disabled:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number | undefined }>()\n *\n * const { data, isLoading, isError, error } = useQuery({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId!),\n * enabled: () => props.postId != null,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n * @example\n * Seeding a detail query from an already-cached list, to skip the loading state. `initialDataUpdatedAt` carries\n * over the list's own fetch time, so that if you set a `staleTime`, it's measured from when the list was\n * fetched rather than from now:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery, useQueryClient } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number }>()\n * const queryClient = useQueryClient()\n *\n * const { data, isError, error } = useQuery({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId),\n * initialData: () =>\n * queryClient\n * .getQueryData<Array<Post>>(['posts'])\n * ?.find((post) => post.id === props.postId),\n * initialDataUpdatedAt: () =>\n * queryClient.getQueryState(['posts'])?.dataUpdatedAt,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n * @example\n * Paginated data, keeping the previous page's data visible while the next page loads:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { keepPreviousData, useQuery } from '@tanstack/vue-query'\n *\n * const page = ref(0)\n *\n * const { data, isPlaceholderData, isError, error } = useQuery({\n * queryKey: ['posts', page],\n * queryFn: () => fetchPosts(page.value),\n * placeholderData: keepPreviousData,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <template v-else>\n * <ul>\n * <li v-for=\"post in data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * <button :disabled=\"isPlaceholderData\" @click=\"page++\">Next Page</button>\n * </template>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\n/**\n * Fallback overload for options whose `initialData` presence isn't statically known — for example, a\n * `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other\n * overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly.\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries.\n *\n * When `options` itself is a reactive getter, the whole object is re-evaluated on every change to its\n * dependencies, so any option inside it — not just `queryKey` and `enabled` — can change over time.\n * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UseQueryOptions} to use.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result, with `data` typed as possibly `undefined`.\n * @example\n * Passing a whole-options getter so `staleTime` reacts to a setting stored elsewhere, not just `queryKey`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ id: number; staleTime: number }>()\n *\n * const { data } = useQuery(() => ({\n * queryKey: ['post', props.id],\n * queryFn: () => fetchPost(props.id),\n * staleTime: props.staleTime,\n * }))\n * </script>\n *\n * <template>\n * <h1 v-if=\"data\">{{ data.title }}</h1>\n * </template>\n * ```\n * @example\n * `skipToken` disables the query in a type-safe way, without a non-null assertion on `props.postId` —\n * `queryFn` is only ever called when it's defined. The whole-options getter re-evaluates `queryFn` on every\n * change to `props.postId`. `queryFn` can also be a `computed`, but never a bare getter, since a function\n * there is the query function itself. `refetch` doesn't work while `queryFn` is `skipToken` — use\n * `enabled: false` instead if you need to trigger the query manually:\n * ```vue\n * <script setup lang=\"ts\">\n * import { skipToken, useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number | undefined }>()\n *\n * const { data, isLoading, isError, error } = useQuery(() => {\n * const postId = props.postId\n * return {\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * }\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n >,\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\nexport function useQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n >,\n queryClient?: QueryClient,\n):\n | UseQueryReturnType<TData, TError>\n | UseQueryDefinedReturnType<TData, TError> {\n return useBaseQuery(QueryObserver, options, queryClient)\n}\n"],"mappings":";;;AAySA,SAAgB,SAMd,SAGA,aAG2C;CAC3C,OAAO,aAAa,eAAe,SAAS,WAAW;AACzD"}
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_utils = require("./utils.cjs");
3
3
  let vue_demi = require("vue-demi");
4
- //#region src/useQueryClient.ts
4
+ // src/useQueryClient.ts
5
5
  /**
6
6
  * Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside
7
7
  * `setup()` or another function that supports an injection context.
@@ -30,7 +30,6 @@ function useQueryClient(id = "") {
30
30
  if (!queryClient) throw new Error("No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.");
31
31
  return queryClient;
32
32
  }
33
- //#endregion
34
33
  exports.useQueryClient = useQueryClient;
35
34
 
36
35
  //# sourceMappingURL=useQueryClient.cjs.map
@@ -1,5 +1,4 @@
1
- import { t as QueryClient } from "./queryClient-4Y1X98Y3.cjs";
2
- //#region src/useQueryClient.d.ts
1
+ import { t as QueryClient } from "./queryClient-DdZQqhoA.cjs";
3
2
  /**
4
3
  * Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside
5
4
  * `setup()` or another function that supports an injection context.
@@ -22,5 +21,4 @@ import { t as QueryClient } from "./queryClient-4Y1X98Y3.cjs";
22
21
  * ```
23
22
  */
24
23
  export declare function useQueryClient(id?: string): QueryClient;
25
- //#endregion
26
24
  //# sourceMappingURL=useQueryClient.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useQueryClient.d.cts","names":[],"sources":["../../src/useQueryClient.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;wBA0BgB,eAAe,cAAU"}
1
+ {"version":3,"file":"useQueryClient.d.cts","names":[],"sources":["../../src/useQueryClient.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;wBA0BgB,eAAe,cAAU"}
@@ -1,5 +1,4 @@
1
- import { t as QueryClient } from "./queryClient-D4OU6h40.js";
2
- //#region src/useQueryClient.d.ts
1
+ import { t as QueryClient } from "./queryClient-CVne8UYf.js";
3
2
  /**
4
3
  * Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside
5
4
  * `setup()` or another function that supports an injection context.
@@ -22,5 +21,4 @@ import { t as QueryClient } from "./queryClient-D4OU6h40.js";
22
21
  * ```
23
22
  */
24
23
  export declare function useQueryClient(id?: string): QueryClient;
25
- //#endregion
26
24
  //# sourceMappingURL=useQueryClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useQueryClient.d.ts","names":[],"sources":["../../src/useQueryClient.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;wBA0BgB,eAAe,cAAU"}
1
+ {"version":3,"file":"useQueryClient.d.ts","names":[],"sources":["../../src/useQueryClient.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;wBA0BgB,eAAe,cAAU"}
@@ -1,6 +1,6 @@
1
1
  import { getClientKey } from "./utils.js";
2
2
  import { hasInjectionContext, inject } from "vue-demi";
3
- //#region src/useQueryClient.ts
3
+ // src/useQueryClient.ts
4
4
  /**
5
5
  * Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside
6
6
  * `setup()` or another function that supports an injection context.
@@ -29,7 +29,6 @@ function useQueryClient(id = "") {
29
29
  if (!queryClient) throw new Error("No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.");
30
30
  return queryClient;
31
31
  }
32
- //#endregion
33
32
  export { useQueryClient };
34
33
 
35
34
  //# sourceMappingURL=useQueryClient.js.map
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let vue_demi = require("vue-demi");
3
- //#region src/utils.ts
3
+ // src/utils.ts
4
4
  /**
5
5
  * Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under.
6
6
  * @internal
@@ -108,7 +108,6 @@ function isFunction(value) {
108
108
  function toValueDeep(source) {
109
109
  return isFunction(source) ? source() : cloneDeepUnref(source);
110
110
  }
111
- //#endregion
112
111
  exports.VUE_QUERY_CLIENT = VUE_QUERY_CLIENT;
113
112
  exports.cloneDeep = cloneDeep;
114
113
  exports.cloneDeepUnref = cloneDeepUnref;
@@ -1,5 +1,4 @@
1
- import { o as MaybeRefDeep } from "./types-sdZdiLgo.cjs";
2
- //#region src/utils.d.ts
1
+ import { o as MaybeRefDeep } from "./types-u_Tu5Ybs.cjs";
3
2
  /**
4
3
  * Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under.
5
4
  * @internal
@@ -48,5 +47,4 @@ export declare function cloneDeepUnref<T>(obj: MaybeRefDeep<T>, unrefGetters?: b
48
47
  * @returns The resolved plain value.
49
48
  */
50
49
  export declare function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T;
51
- //#endregion
52
50
  //# sourceMappingURL=utils.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.cts","names":[],"sources":["../../src/utils.ts"],"mappings":";;;;;;qBAOa;;;;;;;wBAQG,aAAa;;;;;;;wBAWb,YACd,OAAO,qBACP,QAAQ;;;;;;;;;;;wBA+DM,UAAU,GACxB,OAAO,aAAa,IACpB,aACE,KAAK,aAAa,IAClB,aACA,kBACG,gBACJ;;;;;;;;;;;wBAca,eAAe,GAC7B,KAAK,aAAa,IAClB,yBACC;;;;;;;wBAwDa,YAAY,GAAG,eAAe,KAAK,aAAa,KAAK"}
1
+ {"version":3,"file":"utils.d.cts","names":[],"sources":["../../src/utils.ts"],"mappings":";;;;;qBAOa;;;;;;;wBAQG,aAAa;;;;;;;wBAWb,YACd,OAAO,qBACP,QAAQ;;;;;;;;;;;wBA+DM,UAAU,GACxB,OAAO,aAAa,IACpB,aACE,KAAK,aAAa,IAClB,aACA,kBACG,gBACJ;;;;;;;;;;;wBAca,eAAe,GAC7B,KAAK,aAAa,IAClB,yBACC;;;;;;;wBAwDa,YAAY,GAAG,eAAe,KAAK,aAAa,KAAK"}
@@ -1,5 +1,4 @@
1
- import { o as MaybeRefDeep } from "./types-sdZdiLgo.js";
2
- //#region src/utils.d.ts
1
+ import { o as MaybeRefDeep } from "./types-u_Tu5Ybs.js";
3
2
  /**
4
3
  * Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under.
5
4
  * @internal
@@ -48,5 +47,4 @@ export declare function cloneDeepUnref<T>(obj: MaybeRefDeep<T>, unrefGetters?: b
48
47
  * @returns The resolved plain value.
49
48
  */
50
49
  export declare function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T;
51
- //#endregion
52
50
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","names":[],"sources":["../../src/utils.ts"],"mappings":";;;;;;qBAOa;;;;;;;wBAQG,aAAa;;;;;;;wBAWb,YACd,OAAO,qBACP,QAAQ;;;;;;;;;;;wBA+DM,UAAU,GACxB,OAAO,aAAa,IACpB,aACE,KAAK,aAAa,IAClB,aACA,kBACG,gBACJ;;;;;;;;;;;wBAca,eAAe,GAC7B,KAAK,aAAa,IAClB,yBACC;;;;;;;wBAwDa,YAAY,GAAG,eAAe,KAAK,aAAa,KAAK"}
1
+ {"version":3,"file":"utils.d.ts","names":[],"sources":["../../src/utils.ts"],"mappings":";;;;;qBAOa;;;;;;;wBAQG,aAAa;;;;;;;wBAWb,YACd,OAAO,qBACP,QAAQ;;;;;;;;;;;wBA+DM,UAAU,GACxB,OAAO,aAAa,IACpB,aACE,KAAK,aAAa,IAClB,aACA,kBACG,gBACJ;;;;;;;;;;;wBAca,eAAe,GAC7B,KAAK,aAAa,IAClB,yBACC;;;;;;;wBAwDa,YAAY,GAAG,eAAe,KAAK,aAAa,KAAK"}
@@ -1,5 +1,5 @@
1
1
  import { isRef, unref } from "vue-demi";
2
- //#region src/utils.ts
2
+ // src/utils.ts
3
3
  /**
4
4
  * Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under.
5
5
  * @internal
@@ -107,7 +107,6 @@ function isFunction(value) {
107
107
  function toValueDeep(source) {
108
108
  return isFunction(source) ? source() : cloneDeepUnref(source);
109
109
  }
110
- //#endregion
111
110
  export { VUE_QUERY_CLIENT, cloneDeep, cloneDeepUnref, getClientKey, toValueDeep, updateState };
112
111
 
113
112
  //# sourceMappingURL=utils.js.map
@@ -4,7 +4,7 @@ const require_queryClient = require("./queryClient.cjs");
4
4
  const require_devtools_devtools = require("./devtools/devtools.cjs");
5
5
  let _tanstack_query_core = require("@tanstack/query-core");
6
6
  let vue_demi = require("vue-demi");
7
- //#region src/vueQueryPlugin.ts
7
+ // src/vueQueryPlugin.ts
8
8
  /**
9
9
  * Installs a `QueryClient` on the Vue app, making it available to every descendant component through
10
10
  * `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin
@@ -87,7 +87,6 @@ const VueQueryPlugin = { install: (app, options = {}) => {
87
87
  }
88
88
  }
89
89
  } };
90
- //#endregion
91
90
  exports.VueQueryPlugin = VueQueryPlugin;
92
91
 
93
92
  //# sourceMappingURL=vueQueryPlugin.cjs.map
@@ -1,6 +1,5 @@
1
- import { u as QueryClientConfig } from "./types-sdZdiLgo.cjs";
2
- import { t as QueryClient } from "./queryClient-4Y1X98Y3.cjs";
3
- //#region src/vueQueryPlugin.d.ts
1
+ import { u as QueryClientConfig } from "./types-u_Tu5Ybs.cjs";
2
+ import { t as QueryClient } from "./queryClient-DdZQqhoA.cjs";
4
3
  type ClientPersister = (client: QueryClient) => [() => void, Promise<void>];
5
4
  interface CommonOptions {
6
5
  /** Enables the legacy Vue Devtools v6 plugin panel. Prefer `@tanstack/vue-query-devtools` for Vue 3 apps. */
@@ -65,5 +64,4 @@ export type VueQueryPluginOptions = ConfigOptions | ClientOptions;
65
64
  export declare const VueQueryPlugin: {
66
65
  install: (app: any, options?: VueQueryPluginOptions) => void;
67
66
  };
68
- //#endregion
69
67
  //# sourceMappingURL=vueQueryPlugin.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vueQueryPlugin.d.cts","names":[],"sources":["../../src/vueQueryPlugin.ts"],"mappings":";;;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":";;KAQK,mBAAmB,QAAQ,6BAA6B;UAEnD;;EAER;;;;;EAKA;;;;;EAKA,kBAAkB;;EAElB,4BAA4B,QAAQ;;UAG5B,sBAAsB;;EAE9B,oBAAoB;;UAGZ,sBAAsB;;EAE9B,cAAc;;;;;;YAOJ,wBAAwB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAiCvC;EACI,UAAA,UAAG,UAAW"}
@@ -1,6 +1,5 @@
1
- import { u as QueryClientConfig } from "./types-sdZdiLgo.js";
2
- import { t as QueryClient } from "./queryClient-D4OU6h40.js";
3
- //#region src/vueQueryPlugin.d.ts
1
+ import { u as QueryClientConfig } from "./types-u_Tu5Ybs.js";
2
+ import { t as QueryClient } from "./queryClient-CVne8UYf.js";
4
3
  type ClientPersister = (client: QueryClient) => [() => void, Promise<void>];
5
4
  interface CommonOptions {
6
5
  /** Enables the legacy Vue Devtools v6 plugin panel. Prefer `@tanstack/vue-query-devtools` for Vue 3 apps. */
@@ -65,5 +64,4 @@ export type VueQueryPluginOptions = ConfigOptions | ClientOptions;
65
64
  export declare const VueQueryPlugin: {
66
65
  install: (app: any, options?: VueQueryPluginOptions) => void;
67
66
  };
68
- //#endregion
69
67
  //# sourceMappingURL=vueQueryPlugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vueQueryPlugin.d.ts","names":[],"sources":["../../src/vueQueryPlugin.ts"],"mappings":";;;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":";;KAQK,mBAAmB,QAAQ,6BAA6B;UAEnD;;EAER;;;;;EAKA;;;;;EAKA,kBAAkB;;EAElB,4BAA4B,QAAQ;;UAG5B,sBAAsB;;EAE9B,oBAAoB;;UAGZ,sBAAsB;;EAE9B,cAAc;;;;;;YAOJ,wBAAwB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAiCvC;EACI,UAAA,UAAG,UAAW"}
@@ -3,7 +3,7 @@ import { QueryClient as QueryClient$1 } from "./queryClient.js";
3
3
  import { setupDevtools } from "./devtools/devtools.js";
4
4
  import { environmentManager } from "@tanstack/query-core";
5
5
  import { isVue2 } from "vue-demi";
6
- //#region src/vueQueryPlugin.ts
6
+ // src/vueQueryPlugin.ts
7
7
  /**
8
8
  * Installs a `QueryClient` on the Vue app, making it available to every descendant component through
9
9
  * `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin
@@ -86,7 +86,6 @@ const VueQueryPlugin = { install: (app, options = {}) => {
86
86
  }
87
87
  }
88
88
  } };
89
- //#endregion
90
89
  export { VueQueryPlugin };
91
90
 
92
91
  //# sourceMappingURL=vueQueryPlugin.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/vue-query",
3
- "version": "5.105.0",
3
+ "version": "5.105.1",
4
4
  "description": "Hooks for managing, caching and syncing asynchronous and remote data in Vue",
5
5
  "author": "Damian Osipiuk",
6
6
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  ],
41
41
  "dependencies": {
42
42
  "@tanstack/match-sorter-utils": "^9.1.2",
43
- "@tanstack/query-core": "5.105.0",
43
+ "@tanstack/query-core": "5.105.1",
44
44
  "@vue/devtools-api": "^6.6.3",
45
45
  "vue-demi": "^0.14.10"
46
46
  },
@@ -1,6 +1,7 @@
1
1
  import type {
2
2
  DefaultError,
3
3
  InfiniteData,
4
+ InitialDataFunction,
4
5
  NonUndefinedGuard,
5
6
  QueryKey,
6
7
  QueryKeyWithDataTag,
@@ -8,8 +9,9 @@ import type {
8
9
  import type { UseInfiniteQueryOptions } from './useInfiniteQuery'
9
10
 
10
11
  /**
11
- * The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data`
12
- * may be `undefined` while the query is `pending`.
12
+ * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is omitted, may be
13
+ * `undefined`, or is a function that may return `undefined` — `data` may be `undefined` while the query is
14
+ * `pending`.
13
15
  * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
14
16
  * @template TError - The type of errors your `queryFn` may throw.
15
17
  * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
@@ -30,12 +32,17 @@ export type UndefinedInitialDataInfiniteOptions<
30
32
  TQueryKey,
31
33
  TPageParam
32
34
  > & {
33
- initialData?: undefined
35
+ initialData?:
36
+ | undefined
37
+ | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>
38
+ | InitialDataFunction<
39
+ NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>
40
+ >
34
41
  }
35
42
 
36
43
  /**
37
- * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is
38
- * never `undefined` (unless a `select` changes `TData` to include `undefined`).
44
+ * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is known to be
45
+ * defined — `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`).
39
46
  * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
40
47
  * @template TError - The type of errors your `queryFn` may throw.
41
48
  * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
@@ -72,8 +79,11 @@ export type DefinedInitialDataInfiniteOptions<
72
79
  * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.
73
80
  * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.
74
81
  * `options.queryKey` is required and is the query key to generate options for.
75
- * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to
76
- * `useInfiniteQuery`.
82
+ *
83
+ * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never
84
+ * `undefined` (unless a `select` changes `TData` to include `undefined`).
85
+ * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to
86
+ * `useInfiniteQuery`, with `initialData` known to be defined.
77
87
  * @returns The same options object, typed so that `queryKey` carries the inferred data type.
78
88
  * @see {@link useInfiniteQuery} to run an infinite query with these options.
79
89
  * @example
@@ -86,9 +96,12 @@ export type DefinedInitialDataInfiniteOptions<
86
96
  * queryFn: ({ pageParam }) => fetchProjects(pageParam),
87
97
  * initialPageParam: 0,
88
98
  * getNextPageParam: (lastPage) => lastPage.nextId,
99
+ * initialData: { pages: [], pageParams: [] },
89
100
  * })
90
101
  *
91
- * const { data, isError, error, fetchNextPage } = useInfiniteQuery(projectsOptions)
102
+ * // `data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the
103
+ * // list stays visible alongside the error.
104
+ * const { data, isError, error } = useInfiniteQuery(projectsOptions)
92
105
  * </script>
93
106
  * ```
94
107
  */
@@ -99,14 +112,14 @@ export function infiniteQueryOptions<
99
112
  TQueryKey extends QueryKey = QueryKey,
100
113
  TPageParam = unknown,
101
114
  >(
102
- options: UndefinedInitialDataInfiniteOptions<
115
+ options: DefinedInitialDataInfiniteOptions<
103
116
  TQueryFnData,
104
117
  TError,
105
118
  TData,
106
119
  TQueryKey,
107
120
  TPageParam
108
121
  >,
109
- ): UndefinedInitialDataInfiniteOptions<
122
+ ): DefinedInitialDataInfiniteOptions<
110
123
  TQueryFnData,
111
124
  TError,
112
125
  TData,
@@ -119,11 +132,8 @@ export function infiniteQueryOptions<
119
132
  * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.
120
133
  * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.
121
134
  * `options.queryKey` is required and is the query key to generate options for.
122
- *
123
- * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
124
- * a `select` changes `TData` to include `undefined`).
125
- * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to
126
- * `useInfiniteQuery`, with `initialData` set.
135
+ * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to
136
+ * `useInfiniteQuery`.
127
137
  * @returns The same options object, typed so that `queryKey` carries the inferred data type.
128
138
  * @see {@link useInfiniteQuery} to run an infinite query with these options.
129
139
  * @example
@@ -136,12 +146,9 @@ export function infiniteQueryOptions<
136
146
  * queryFn: ({ pageParam }) => fetchProjects(pageParam),
137
147
  * initialPageParam: 0,
138
148
  * getNextPageParam: (lastPage) => lastPage.nextId,
139
- * initialData: { pages: [], pageParams: [] },
140
149
  * })
141
150
  *
142
- * // `data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the
143
- * // list stays visible alongside the error.
144
- * const { data, isError, error } = useInfiniteQuery(projectsOptions)
151
+ * const { data, isError, error, fetchNextPage } = useInfiniteQuery(projectsOptions)
145
152
  * </script>
146
153
  * ```
147
154
  */
@@ -152,14 +159,14 @@ export function infiniteQueryOptions<
152
159
  TQueryKey extends QueryKey = QueryKey,
153
160
  TPageParam = unknown,
154
161
  >(
155
- options: DefinedInitialDataInfiniteOptions<
162
+ options: UndefinedInitialDataInfiniteOptions<
156
163
  TQueryFnData,
157
164
  TError,
158
165
  TData,
159
166
  TQueryKey,
160
167
  TPageParam
161
168
  >,
162
- ): DefinedInitialDataInfiniteOptions<
169
+ ): UndefinedInitialDataInfiniteOptions<
163
170
  TQueryFnData,
164
171
  TError,
165
172
  TData,