@tanstack/vue-query 5.102.7 → 5.103.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (329) hide show
  1. package/build/legacy/devtools/devtools.d.cts +1 -1
  2. package/build/legacy/devtools/devtools.d.ts +1 -1
  3. package/build/legacy/index.d.cts +8 -6
  4. package/build/legacy/index.d.ts +8 -6
  5. package/build/legacy/infiniteQueryOptions-CEDiLwh5.d.ts +365 -0
  6. package/build/legacy/infiniteQueryOptions-CEDiLwh5.d.ts.map +1 -0
  7. package/build/legacy/infiniteQueryOptions-qN6sOJM-.d.cts +365 -0
  8. package/build/legacy/infiniteQueryOptions-qN6sOJM-.d.cts.map +1 -0
  9. package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
  10. package/build/legacy/infiniteQueryOptions.d.cts +1 -1
  11. package/build/legacy/infiniteQueryOptions.d.ts +1 -1
  12. package/build/legacy/infiniteQueryOptions.js.map +1 -1
  13. package/build/legacy/mutationCache.cjs +5 -0
  14. package/build/legacy/mutationCache.cjs.map +1 -1
  15. package/build/legacy/mutationCache.d.cts +6 -1
  16. package/build/legacy/mutationCache.d.cts.map +1 -1
  17. package/build/legacy/mutationCache.d.ts +6 -1
  18. package/build/legacy/mutationCache.d.ts.map +1 -1
  19. package/build/legacy/mutationCache.js +5 -0
  20. package/build/legacy/mutationCache.js.map +1 -1
  21. package/build/legacy/mutationOptions.cjs.map +1 -1
  22. package/build/legacy/mutationOptions.d.cts +121 -1
  23. package/build/legacy/mutationOptions.d.cts.map +1 -1
  24. package/build/legacy/mutationOptions.d.ts +121 -1
  25. package/build/legacy/mutationOptions.d.ts.map +1 -1
  26. package/build/legacy/mutationOptions.js.map +1 -1
  27. package/build/legacy/queryCache.cjs +5 -0
  28. package/build/legacy/queryCache.cjs.map +1 -1
  29. package/build/legacy/queryCache.d.cts +6 -1
  30. package/build/legacy/queryCache.d.cts.map +1 -1
  31. package/build/legacy/queryCache.d.ts +6 -1
  32. package/build/legacy/queryCache.d.ts.map +1 -1
  33. package/build/legacy/queryCache.js +5 -0
  34. package/build/legacy/queryCache.js.map +1 -1
  35. package/build/legacy/queryClient-CZeNAt68.d.cts +71 -0
  36. package/build/legacy/queryClient-CZeNAt68.d.cts.map +1 -0
  37. package/build/legacy/queryClient-Cv73nzNT.d.ts +71 -0
  38. package/build/legacy/queryClient-Cv73nzNT.d.ts.map +1 -0
  39. package/build/legacy/queryClient.cjs +7 -0
  40. package/build/legacy/queryClient.cjs.map +1 -1
  41. package/build/legacy/queryClient.d.cts +1 -1
  42. package/build/legacy/queryClient.d.ts +1 -1
  43. package/build/legacy/queryClient.js +7 -0
  44. package/build/legacy/queryClient.js.map +1 -1
  45. package/build/legacy/queryOptions-DPDwdVBu.d.ts +227 -0
  46. package/build/legacy/queryOptions-DPDwdVBu.d.ts.map +1 -0
  47. package/build/legacy/queryOptions-rkZ3sk6g.d.cts +227 -0
  48. package/build/legacy/queryOptions-rkZ3sk6g.d.cts.map +1 -0
  49. package/build/legacy/queryOptions.cjs.map +1 -1
  50. package/build/legacy/queryOptions.d.cts +2 -19
  51. package/build/legacy/queryOptions.d.ts +2 -19
  52. package/build/legacy/queryOptions.js.map +1 -1
  53. package/build/{modern/types-BzZi3_rS.d.cts → legacy/types-JpJB72CS.d.cts} +19 -1
  54. package/build/legacy/types-JpJB72CS.d.cts.map +1 -0
  55. package/build/legacy/{types-BzZi3_rS.d.cts → types-JpJB72CS.d.ts} +19 -1
  56. package/build/legacy/types-JpJB72CS.d.ts.map +1 -0
  57. package/build/legacy/types.d.cts +1 -1
  58. package/build/legacy/types.d.ts +1 -1
  59. package/build/legacy/useBaseQuery.cjs +8 -0
  60. package/build/legacy/useBaseQuery.cjs.map +1 -1
  61. package/build/legacy/useBaseQuery.d.cts +1 -1
  62. package/build/legacy/useBaseQuery.d.ts +1 -1
  63. package/build/legacy/useBaseQuery.js +8 -0
  64. package/build/legacy/useBaseQuery.js.map +1 -1
  65. package/build/legacy/useInfiniteQuery.cjs.map +1 -1
  66. package/build/legacy/useInfiniteQuery.d.cts +1 -1
  67. package/build/legacy/useInfiniteQuery.d.ts +1 -1
  68. package/build/legacy/useInfiniteQuery.js.map +1 -1
  69. package/build/legacy/useIsFetching.cjs +41 -0
  70. package/build/legacy/useIsFetching.cjs.map +1 -1
  71. package/build/legacy/useIsFetching.d.cts +47 -6
  72. package/build/legacy/useIsFetching.d.cts.map +1 -1
  73. package/build/legacy/useIsFetching.d.ts +47 -6
  74. package/build/legacy/useIsFetching.d.ts.map +1 -1
  75. package/build/legacy/useIsFetching.js +41 -0
  76. package/build/legacy/useIsFetching.js.map +1 -1
  77. package/build/legacy/useMutation.cjs +170 -9
  78. package/build/legacy/useMutation.cjs.map +1 -1
  79. package/build/legacy/useMutation.d.cts +164 -3
  80. package/build/legacy/useMutation.d.cts.map +1 -1
  81. package/build/legacy/useMutation.d.ts +164 -3
  82. package/build/legacy/useMutation.d.ts.map +1 -1
  83. package/build/legacy/useMutation.js +170 -9
  84. package/build/legacy/useMutation.js.map +1 -1
  85. package/build/legacy/useMutationState.cjs +103 -0
  86. package/build/legacy/useMutationState.cjs.map +1 -1
  87. package/build/legacy/useMutationState.d.cts +111 -7
  88. package/build/legacy/useMutationState.d.cts.map +1 -1
  89. package/build/legacy/useMutationState.d.ts +111 -7
  90. package/build/legacy/useMutationState.d.ts.map +1 -1
  91. package/build/legacy/useMutationState.js +103 -0
  92. package/build/legacy/useMutationState.js.map +1 -1
  93. package/build/legacy/usePrefetchInfiniteQuery.cjs +46 -0
  94. package/build/legacy/usePrefetchInfiniteQuery.cjs.map +1 -1
  95. package/build/legacy/usePrefetchInfiniteQuery.d.cts +48 -2
  96. package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -1
  97. package/build/legacy/usePrefetchInfiniteQuery.d.ts +48 -2
  98. package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -1
  99. package/build/legacy/usePrefetchInfiniteQuery.js +46 -0
  100. package/build/legacy/usePrefetchInfiniteQuery.js.map +1 -1
  101. package/build/legacy/usePrefetchQuery.cjs +37 -0
  102. package/build/legacy/usePrefetchQuery.cjs.map +1 -1
  103. package/build/legacy/usePrefetchQuery.d.cts +39 -2
  104. package/build/legacy/usePrefetchQuery.d.cts.map +1 -1
  105. package/build/legacy/usePrefetchQuery.d.ts +39 -2
  106. package/build/legacy/usePrefetchQuery.d.ts.map +1 -1
  107. package/build/legacy/usePrefetchQuery.js +37 -0
  108. package/build/legacy/usePrefetchQuery.js.map +1 -1
  109. package/build/legacy/useQueries.cjs +123 -0
  110. package/build/legacy/useQueries.cjs.map +1 -1
  111. package/build/legacy/useQueries.d.cts +126 -2
  112. package/build/legacy/useQueries.d.cts.map +1 -1
  113. package/build/legacy/useQueries.d.ts +126 -2
  114. package/build/legacy/useQueries.d.ts.map +1 -1
  115. package/build/legacy/useQueries.js +123 -0
  116. package/build/legacy/useQueries.js.map +1 -1
  117. package/build/legacy/useQuery.cjs.map +1 -1
  118. package/build/legacy/useQuery.d.cts +248 -2
  119. package/build/legacy/useQuery.d.cts.map +1 -0
  120. package/build/legacy/useQuery.d.ts +248 -2
  121. package/build/legacy/useQuery.d.ts.map +1 -0
  122. package/build/legacy/useQuery.js.map +1 -1
  123. package/build/legacy/useQueryClient.cjs +21 -0
  124. package/build/legacy/useQueryClient.cjs.map +1 -1
  125. package/build/legacy/useQueryClient.d.cts +22 -1
  126. package/build/legacy/useQueryClient.d.cts.map +1 -1
  127. package/build/legacy/useQueryClient.d.ts +22 -1
  128. package/build/legacy/useQueryClient.d.ts.map +1 -1
  129. package/build/legacy/useQueryClient.js +21 -0
  130. package/build/legacy/useQueryClient.js.map +1 -1
  131. package/build/legacy/utils.cjs +15 -0
  132. package/build/legacy/utils.cjs.map +1 -1
  133. package/build/legacy/utils.d.cts +16 -1
  134. package/build/legacy/utils.d.cts.map +1 -1
  135. package/build/legacy/utils.d.ts +16 -1
  136. package/build/legacy/utils.d.ts.map +1 -1
  137. package/build/legacy/utils.js +15 -0
  138. package/build/legacy/utils.js.map +1 -1
  139. package/build/legacy/vueQueryPlugin.cjs +34 -0
  140. package/build/legacy/vueQueryPlugin.cjs.map +1 -1
  141. package/build/legacy/vueQueryPlugin.d.cts +48 -2
  142. package/build/legacy/vueQueryPlugin.d.cts.map +1 -1
  143. package/build/legacy/vueQueryPlugin.d.ts +48 -2
  144. package/build/legacy/vueQueryPlugin.d.ts.map +1 -1
  145. package/build/legacy/vueQueryPlugin.js +34 -0
  146. package/build/legacy/vueQueryPlugin.js.map +1 -1
  147. package/build/modern/devtools/devtools.d.cts +1 -1
  148. package/build/modern/devtools/devtools.d.ts +1 -1
  149. package/build/modern/index.d.cts +8 -6
  150. package/build/modern/index.d.ts +8 -6
  151. package/build/modern/infiniteQueryOptions-CEDiLwh5.d.ts +365 -0
  152. package/build/modern/infiniteQueryOptions-CEDiLwh5.d.ts.map +1 -0
  153. package/build/modern/infiniteQueryOptions-qN6sOJM-.d.cts +365 -0
  154. package/build/modern/infiniteQueryOptions-qN6sOJM-.d.cts.map +1 -0
  155. package/build/modern/infiniteQueryOptions.cjs.map +1 -1
  156. package/build/modern/infiniteQueryOptions.d.cts +1 -1
  157. package/build/modern/infiniteQueryOptions.d.ts +1 -1
  158. package/build/modern/infiniteQueryOptions.js.map +1 -1
  159. package/build/modern/mutationCache.cjs +5 -0
  160. package/build/modern/mutationCache.cjs.map +1 -1
  161. package/build/modern/mutationCache.d.cts +6 -1
  162. package/build/modern/mutationCache.d.cts.map +1 -1
  163. package/build/modern/mutationCache.d.ts +6 -1
  164. package/build/modern/mutationCache.d.ts.map +1 -1
  165. package/build/modern/mutationCache.js +5 -0
  166. package/build/modern/mutationCache.js.map +1 -1
  167. package/build/modern/mutationOptions.cjs.map +1 -1
  168. package/build/modern/mutationOptions.d.cts +121 -1
  169. package/build/modern/mutationOptions.d.cts.map +1 -1
  170. package/build/modern/mutationOptions.d.ts +121 -1
  171. package/build/modern/mutationOptions.d.ts.map +1 -1
  172. package/build/modern/mutationOptions.js.map +1 -1
  173. package/build/modern/queryCache.cjs +5 -0
  174. package/build/modern/queryCache.cjs.map +1 -1
  175. package/build/modern/queryCache.d.cts +6 -1
  176. package/build/modern/queryCache.d.cts.map +1 -1
  177. package/build/modern/queryCache.d.ts +6 -1
  178. package/build/modern/queryCache.d.ts.map +1 -1
  179. package/build/modern/queryCache.js +5 -0
  180. package/build/modern/queryCache.js.map +1 -1
  181. package/build/modern/queryClient-CZeNAt68.d.cts +71 -0
  182. package/build/modern/queryClient-CZeNAt68.d.cts.map +1 -0
  183. package/build/modern/queryClient-Cv73nzNT.d.ts +71 -0
  184. package/build/modern/queryClient-Cv73nzNT.d.ts.map +1 -0
  185. package/build/modern/queryClient.cjs +7 -0
  186. package/build/modern/queryClient.cjs.map +1 -1
  187. package/build/modern/queryClient.d.cts +1 -1
  188. package/build/modern/queryClient.d.ts +1 -1
  189. package/build/modern/queryClient.js +7 -0
  190. package/build/modern/queryClient.js.map +1 -1
  191. package/build/modern/queryOptions-DPDwdVBu.d.ts +227 -0
  192. package/build/modern/queryOptions-DPDwdVBu.d.ts.map +1 -0
  193. package/build/modern/queryOptions-rkZ3sk6g.d.cts +227 -0
  194. package/build/modern/queryOptions-rkZ3sk6g.d.cts.map +1 -0
  195. package/build/modern/queryOptions.cjs.map +1 -1
  196. package/build/modern/queryOptions.d.cts +2 -19
  197. package/build/modern/queryOptions.d.ts +2 -19
  198. package/build/modern/queryOptions.js.map +1 -1
  199. package/build/modern/{types-BzZi3_rS.d.ts → types-JpJB72CS.d.cts} +19 -1
  200. package/build/modern/types-JpJB72CS.d.cts.map +1 -0
  201. package/build/{legacy/types-BzZi3_rS.d.ts → modern/types-JpJB72CS.d.ts} +19 -1
  202. package/build/modern/types-JpJB72CS.d.ts.map +1 -0
  203. package/build/modern/types.d.cts +1 -1
  204. package/build/modern/types.d.ts +1 -1
  205. package/build/modern/useBaseQuery.cjs +8 -0
  206. package/build/modern/useBaseQuery.cjs.map +1 -1
  207. package/build/modern/useBaseQuery.d.cts +1 -1
  208. package/build/modern/useBaseQuery.d.ts +1 -1
  209. package/build/modern/useBaseQuery.js +8 -0
  210. package/build/modern/useBaseQuery.js.map +1 -1
  211. package/build/modern/useInfiniteQuery.cjs.map +1 -1
  212. package/build/modern/useInfiniteQuery.d.cts +1 -1
  213. package/build/modern/useInfiniteQuery.d.ts +1 -1
  214. package/build/modern/useInfiniteQuery.js.map +1 -1
  215. package/build/modern/useIsFetching.cjs +41 -0
  216. package/build/modern/useIsFetching.cjs.map +1 -1
  217. package/build/modern/useIsFetching.d.cts +47 -6
  218. package/build/modern/useIsFetching.d.cts.map +1 -1
  219. package/build/modern/useIsFetching.d.ts +47 -6
  220. package/build/modern/useIsFetching.d.ts.map +1 -1
  221. package/build/modern/useIsFetching.js +41 -0
  222. package/build/modern/useIsFetching.js.map +1 -1
  223. package/build/modern/useMutation.cjs +170 -9
  224. package/build/modern/useMutation.cjs.map +1 -1
  225. package/build/modern/useMutation.d.cts +164 -3
  226. package/build/modern/useMutation.d.cts.map +1 -1
  227. package/build/modern/useMutation.d.ts +164 -3
  228. package/build/modern/useMutation.d.ts.map +1 -1
  229. package/build/modern/useMutation.js +170 -9
  230. package/build/modern/useMutation.js.map +1 -1
  231. package/build/modern/useMutationState.cjs +103 -0
  232. package/build/modern/useMutationState.cjs.map +1 -1
  233. package/build/modern/useMutationState.d.cts +111 -7
  234. package/build/modern/useMutationState.d.cts.map +1 -1
  235. package/build/modern/useMutationState.d.ts +111 -7
  236. package/build/modern/useMutationState.d.ts.map +1 -1
  237. package/build/modern/useMutationState.js +103 -0
  238. package/build/modern/useMutationState.js.map +1 -1
  239. package/build/modern/usePrefetchInfiniteQuery.cjs +46 -0
  240. package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -1
  241. package/build/modern/usePrefetchInfiniteQuery.d.cts +48 -2
  242. package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
  243. package/build/modern/usePrefetchInfiniteQuery.d.ts +48 -2
  244. package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
  245. package/build/modern/usePrefetchInfiniteQuery.js +46 -0
  246. package/build/modern/usePrefetchInfiniteQuery.js.map +1 -1
  247. package/build/modern/usePrefetchQuery.cjs +37 -0
  248. package/build/modern/usePrefetchQuery.cjs.map +1 -1
  249. package/build/modern/usePrefetchQuery.d.cts +39 -2
  250. package/build/modern/usePrefetchQuery.d.cts.map +1 -1
  251. package/build/modern/usePrefetchQuery.d.ts +39 -2
  252. package/build/modern/usePrefetchQuery.d.ts.map +1 -1
  253. package/build/modern/usePrefetchQuery.js +37 -0
  254. package/build/modern/usePrefetchQuery.js.map +1 -1
  255. package/build/modern/useQueries.cjs +123 -0
  256. package/build/modern/useQueries.cjs.map +1 -1
  257. package/build/modern/useQueries.d.cts +126 -2
  258. package/build/modern/useQueries.d.cts.map +1 -1
  259. package/build/modern/useQueries.d.ts +126 -2
  260. package/build/modern/useQueries.d.ts.map +1 -1
  261. package/build/modern/useQueries.js +123 -0
  262. package/build/modern/useQueries.js.map +1 -1
  263. package/build/modern/useQuery.cjs.map +1 -1
  264. package/build/modern/useQuery.d.cts +248 -2
  265. package/build/modern/useQuery.d.cts.map +1 -0
  266. package/build/modern/useQuery.d.ts +248 -2
  267. package/build/modern/useQuery.d.ts.map +1 -0
  268. package/build/modern/useQuery.js.map +1 -1
  269. package/build/modern/useQueryClient.cjs +21 -0
  270. package/build/modern/useQueryClient.cjs.map +1 -1
  271. package/build/modern/useQueryClient.d.cts +22 -1
  272. package/build/modern/useQueryClient.d.cts.map +1 -1
  273. package/build/modern/useQueryClient.d.ts +22 -1
  274. package/build/modern/useQueryClient.d.ts.map +1 -1
  275. package/build/modern/useQueryClient.js +21 -0
  276. package/build/modern/useQueryClient.js.map +1 -1
  277. package/build/modern/utils.cjs +15 -0
  278. package/build/modern/utils.cjs.map +1 -1
  279. package/build/modern/utils.d.cts +16 -1
  280. package/build/modern/utils.d.cts.map +1 -1
  281. package/build/modern/utils.d.ts +16 -1
  282. package/build/modern/utils.d.ts.map +1 -1
  283. package/build/modern/utils.js +15 -0
  284. package/build/modern/utils.js.map +1 -1
  285. package/build/modern/vueQueryPlugin.cjs +34 -0
  286. package/build/modern/vueQueryPlugin.cjs.map +1 -1
  287. package/build/modern/vueQueryPlugin.d.cts +48 -2
  288. package/build/modern/vueQueryPlugin.d.cts.map +1 -1
  289. package/build/modern/vueQueryPlugin.d.ts +48 -2
  290. package/build/modern/vueQueryPlugin.d.ts.map +1 -1
  291. package/build/modern/vueQueryPlugin.js +34 -0
  292. package/build/modern/vueQueryPlugin.js.map +1 -1
  293. package/package.json +10 -10
  294. package/src/index.ts +9 -9
  295. package/src/infiniteQueryOptions.ts +86 -0
  296. package/src/mutationCache.ts +5 -0
  297. package/src/mutationOptions.ts +123 -0
  298. package/src/queryCache.ts +5 -0
  299. package/src/queryClient.ts +17 -1
  300. package/src/queryOptions.ts +276 -10
  301. package/src/types.ts +18 -0
  302. package/src/useBaseQuery.ts +9 -1
  303. package/src/useInfiniteQuery.ts +240 -0
  304. package/src/useIsFetching.ts +46 -3
  305. package/src/useMutation.ts +170 -17
  306. package/src/useMutationState.ts +111 -4
  307. package/src/usePrefetchInfiniteQuery.ts +46 -0
  308. package/src/usePrefetchQuery.ts +37 -0
  309. package/src/useQueries.ts +124 -1
  310. package/src/useQuery.ts +240 -79
  311. package/src/useQueryClient.ts +21 -0
  312. package/src/utils.ts +15 -0
  313. package/src/vueQueryPlugin.ts +46 -0
  314. package/build/legacy/queryClient-C07d0chJ.d.cts +0 -97
  315. package/build/legacy/queryClient-C07d0chJ.d.cts.map +0 -1
  316. package/build/legacy/queryClient-hf6i_vCa.d.ts +0 -97
  317. package/build/legacy/queryClient-hf6i_vCa.d.ts.map +0 -1
  318. package/build/legacy/queryOptions.d.cts.map +0 -1
  319. package/build/legacy/queryOptions.d.ts.map +0 -1
  320. package/build/legacy/types-BzZi3_rS.d.cts.map +0 -1
  321. package/build/legacy/types-BzZi3_rS.d.ts.map +0 -1
  322. package/build/modern/queryClient-C07d0chJ.d.cts +0 -97
  323. package/build/modern/queryClient-C07d0chJ.d.cts.map +0 -1
  324. package/build/modern/queryClient-hf6i_vCa.d.ts +0 -97
  325. package/build/modern/queryClient-hf6i_vCa.d.ts.map +0 -1
  326. package/build/modern/queryOptions.d.cts.map +0 -1
  327. package/build/modern/queryOptions.d.ts.map +0 -1
  328. package/build/modern/types-BzZi3_rS.d.cts.map +0 -1
  329. package/build/modern/types-BzZi3_rS.d.ts.map +0 -1
@@ -1,10 +1,56 @@
1
- import { t as QueryClient$1 } from "./queryClient-C07d0chJ.cjs";
2
- import { o as MaybeRefDeep, s as MaybeRefOrGetter } from "./types-BzZi3_rS.cjs";
1
+ import { o as MaybeRefDeep, s as MaybeRefOrGetter } from "./types-JpJB72CS.cjs";
2
+ import { t as QueryClient$1 } from "./queryClient-CZeNAt68.cjs";
3
3
  import { DefaultError, DistributiveOmit, InfiniteData, InfiniteQueryExecuteOptions, QueryKey, SkipToken } from "@tanstack/query-core";
4
4
  //#region src/usePrefetchInfiniteQuery.d.ts
5
5
  type UsePrefetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey extends QueryKey, TPageParam> = DistributiveOmit<InfiniteQueryExecuteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'queryFn'> & {
6
6
  queryFn?: Exclude<InfiniteQueryExecuteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>['queryFn'], SkipToken>;
7
7
  };
8
+ /**
9
+ * `usePrefetchInfiniteQuery` does not return anything — it fires a prefetch as a reactive side effect, useful
10
+ * for kicking off a fetch ahead of the component that will actually render the data with `useInfiniteQuery`.
11
+ * You can pass everything to `usePrefetchInfiniteQuery` that you can pass to `queryClient.infiniteQuery`,
12
+ * though `queryKey`, `initialPageParam`, and `getNextPageParam` are always required, and `queryFn` is required
13
+ * unless a default query function has been defined.
14
+ *
15
+ * `getNextPageParam` receives both the last page of the infinite list of data and the full array of all pages,
16
+ * as well as pageParam information, and should return a single variable that will be passed to your query
17
+ * function as `context.pageParam`. Return `undefined` or `null` to indicate there is no next page available.
18
+ *
19
+ * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left
20
+ * over from a previous attempt — so it won't refetch data that's already there or already in flight. It
21
+ * re-runs whenever a reactive dependency in `options` (built with `infiniteQueryOptions`, for example) changes.
22
+ *
23
+ * Fire this during render, before a suspense boundary that wraps a component using `useInfiniteQuery`'s
24
+ * `suspense()` — see the {@link https://tanstack.com/query/latest/docs/framework/vue/guides/suspense | Suspense guide}.
25
+ *
26
+ * @param options - A `ref`, plain value, or reactive getter resolving to the
27
+ * {@link UsePrefetchInfiniteQueryOptions} to use — everything you can pass to `queryClient.infiniteQuery`.
28
+ * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
29
+ * will be used.
30
+ * @returns `void` — nothing is returned.
31
+ *
32
+ * @example
33
+ * ```vue
34
+ * <script setup lang="ts">
35
+ * import { infiniteQueryOptions, usePrefetchInfiniteQuery } from '@tanstack/vue-query'
36
+ * import Projects from './Projects.vue'
37
+ *
38
+ * const projectsOptions = infiniteQueryOptions({
39
+ * queryKey: ['projects'],
40
+ * queryFn: ({ pageParam }) => fetchProjects(pageParam),
41
+ * initialPageParam: 0,
42
+ * getNextPageParam: (lastPage) => lastPage.nextId,
43
+ * })
44
+ *
45
+ * // Fire the prefetch as soon as this component runs, before `Projects` mounts and calls `useInfiniteQuery`.
46
+ * usePrefetchInfiniteQuery(projectsOptions)
47
+ * </script>
48
+ *
49
+ * <template>
50
+ * <Projects />
51
+ * </template>
52
+ * ```
53
+ */
8
54
  declare function usePrefetchInfiniteQuery<TQueryFnData = unknown, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: MaybeRefOrGetter<MaybeRefDeep<UsePrefetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>>>, queryClient?: QueryClient$1): void;
9
55
  //#endregion
10
56
  export { UsePrefetchInfiniteQueryOptions, usePrefetchInfiniteQuery };
@@ -1 +1 @@
1
- {"version":3,"file":"usePrefetchInfiniteQuery.d.cts","names":[],"sources":["../../src/usePrefetchInfiniteQuery.ts"],"mappings":";;;;KAeY,gCACV,cACA,QACA,OACA,kBAAkB,UAClB,cACE,iBACF,4BACE,cACA,QACA,OACA,WACA;EAIF,UAAU,QACR,4BACE,cACA,QACA,OACA,WACA,wBAEF;;iBAQY,yBACd,wBACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,iBACP,aACE,gCACE,cACA,QACA,OACA,WACA,eAIN,cAAc"}
1
+ {"version":3,"file":"usePrefetchInfiniteQuery.d.cts","names":[],"sources":["../../src/usePrefetchInfiniteQuery.ts"],"mappings":";;;;KAeY,gCACV,cACA,QACA,OACA,kBAAkB,UAClB,cACE,iBACF,4BACE,cACA,QACA,OACA,WACA;EAIF,UAAU,QACR,4BACE,cACA,QACA,OACA,WACA,wBAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsDY,yBACd,wBACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,iBACP,aACE,gCACE,cACA,QACA,OACA,WACA,eAIN,cAAc"}
@@ -1,10 +1,56 @@
1
- import { t as QueryClient$1 } from "./queryClient-hf6i_vCa.js";
2
- import { o as MaybeRefDeep, s as MaybeRefOrGetter } from "./types-BzZi3_rS.js";
1
+ import { o as MaybeRefDeep, s as MaybeRefOrGetter } from "./types-JpJB72CS.js";
2
+ import { t as QueryClient$1 } from "./queryClient-Cv73nzNT.js";
3
3
  import { DefaultError, DistributiveOmit, InfiniteData, InfiniteQueryExecuteOptions, QueryKey, SkipToken } from "@tanstack/query-core";
4
4
  //#region src/usePrefetchInfiniteQuery.d.ts
5
5
  type UsePrefetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey extends QueryKey, TPageParam> = DistributiveOmit<InfiniteQueryExecuteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'queryFn'> & {
6
6
  queryFn?: Exclude<InfiniteQueryExecuteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>['queryFn'], SkipToken>;
7
7
  };
8
+ /**
9
+ * `usePrefetchInfiniteQuery` does not return anything — it fires a prefetch as a reactive side effect, useful
10
+ * for kicking off a fetch ahead of the component that will actually render the data with `useInfiniteQuery`.
11
+ * You can pass everything to `usePrefetchInfiniteQuery` that you can pass to `queryClient.infiniteQuery`,
12
+ * though `queryKey`, `initialPageParam`, and `getNextPageParam` are always required, and `queryFn` is required
13
+ * unless a default query function has been defined.
14
+ *
15
+ * `getNextPageParam` receives both the last page of the infinite list of data and the full array of all pages,
16
+ * as well as pageParam information, and should return a single variable that will be passed to your query
17
+ * function as `context.pageParam`. Return `undefined` or `null` to indicate there is no next page available.
18
+ *
19
+ * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left
20
+ * over from a previous attempt — so it won't refetch data that's already there or already in flight. It
21
+ * re-runs whenever a reactive dependency in `options` (built with `infiniteQueryOptions`, for example) changes.
22
+ *
23
+ * Fire this during render, before a suspense boundary that wraps a component using `useInfiniteQuery`'s
24
+ * `suspense()` — see the {@link https://tanstack.com/query/latest/docs/framework/vue/guides/suspense | Suspense guide}.
25
+ *
26
+ * @param options - A `ref`, plain value, or reactive getter resolving to the
27
+ * {@link UsePrefetchInfiniteQueryOptions} to use — everything you can pass to `queryClient.infiniteQuery`.
28
+ * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
29
+ * will be used.
30
+ * @returns `void` — nothing is returned.
31
+ *
32
+ * @example
33
+ * ```vue
34
+ * <script setup lang="ts">
35
+ * import { infiniteQueryOptions, usePrefetchInfiniteQuery } from '@tanstack/vue-query'
36
+ * import Projects from './Projects.vue'
37
+ *
38
+ * const projectsOptions = infiniteQueryOptions({
39
+ * queryKey: ['projects'],
40
+ * queryFn: ({ pageParam }) => fetchProjects(pageParam),
41
+ * initialPageParam: 0,
42
+ * getNextPageParam: (lastPage) => lastPage.nextId,
43
+ * })
44
+ *
45
+ * // Fire the prefetch as soon as this component runs, before `Projects` mounts and calls `useInfiniteQuery`.
46
+ * usePrefetchInfiniteQuery(projectsOptions)
47
+ * </script>
48
+ *
49
+ * <template>
50
+ * <Projects />
51
+ * </template>
52
+ * ```
53
+ */
8
54
  declare function usePrefetchInfiniteQuery<TQueryFnData = unknown, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: MaybeRefOrGetter<MaybeRefDeep<UsePrefetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>>>, queryClient?: QueryClient$1): void;
9
55
  //#endregion
10
56
  export { UsePrefetchInfiniteQueryOptions, usePrefetchInfiniteQuery };
@@ -1 +1 @@
1
- {"version":3,"file":"usePrefetchInfiniteQuery.d.ts","names":[],"sources":["../../src/usePrefetchInfiniteQuery.ts"],"mappings":";;;;KAeY,gCACV,cACA,QACA,OACA,kBAAkB,UAClB,cACE,iBACF,4BACE,cACA,QACA,OACA,WACA;EAIF,UAAU,QACR,4BACE,cACA,QACA,OACA,WACA,wBAEF;;iBAQY,yBACd,wBACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,iBACP,aACE,gCACE,cACA,QACA,OACA,WACA,eAIN,cAAc"}
1
+ {"version":3,"file":"usePrefetchInfiniteQuery.d.ts","names":[],"sources":["../../src/usePrefetchInfiniteQuery.ts"],"mappings":";;;;KAeY,gCACV,cACA,QACA,OACA,kBAAkB,UAClB,cACE,iBACF,4BACE,cACA,QACA,OACA,WACA;EAIF,UAAU,QACR,4BACE,cACA,QACA,OACA,WACA,wBAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsDY,yBACd,wBACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,iBACP,aACE,gCACE,cACA,QACA,OACA,WACA,eAIN,cAAc"}
@@ -6,6 +6,52 @@ import { getCurrentScope, unref, watchEffect } from "vue-demi";
6
6
  function isGetter(value) {
7
7
  return typeof value === "function";
8
8
  }
9
+ /**
10
+ * `usePrefetchInfiniteQuery` does not return anything — it fires a prefetch as a reactive side effect, useful
11
+ * for kicking off a fetch ahead of the component that will actually render the data with `useInfiniteQuery`.
12
+ * You can pass everything to `usePrefetchInfiniteQuery` that you can pass to `queryClient.infiniteQuery`,
13
+ * though `queryKey`, `initialPageParam`, and `getNextPageParam` are always required, and `queryFn` is required
14
+ * unless a default query function has been defined.
15
+ *
16
+ * `getNextPageParam` receives both the last page of the infinite list of data and the full array of all pages,
17
+ * as well as pageParam information, and should return a single variable that will be passed to your query
18
+ * function as `context.pageParam`. Return `undefined` or `null` to indicate there is no next page available.
19
+ *
20
+ * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left
21
+ * over from a previous attempt — so it won't refetch data that's already there or already in flight. It
22
+ * re-runs whenever a reactive dependency in `options` (built with `infiniteQueryOptions`, for example) changes.
23
+ *
24
+ * Fire this during render, before a suspense boundary that wraps a component using `useInfiniteQuery`'s
25
+ * `suspense()` — see the {@link https://tanstack.com/query/latest/docs/framework/vue/guides/suspense | Suspense guide}.
26
+ *
27
+ * @param options - A `ref`, plain value, or reactive getter resolving to the
28
+ * {@link UsePrefetchInfiniteQueryOptions} to use — everything you can pass to `queryClient.infiniteQuery`.
29
+ * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
30
+ * will be used.
31
+ * @returns `void` — nothing is returned.
32
+ *
33
+ * @example
34
+ * ```vue
35
+ * <script setup lang="ts">
36
+ * import { infiniteQueryOptions, usePrefetchInfiniteQuery } from '@tanstack/vue-query'
37
+ * import Projects from './Projects.vue'
38
+ *
39
+ * const projectsOptions = infiniteQueryOptions({
40
+ * queryKey: ['projects'],
41
+ * queryFn: ({ pageParam }) => fetchProjects(pageParam),
42
+ * initialPageParam: 0,
43
+ * getNextPageParam: (lastPage) => lastPage.nextId,
44
+ * })
45
+ *
46
+ * // Fire the prefetch as soon as this component runs, before `Projects` mounts and calls `useInfiniteQuery`.
47
+ * usePrefetchInfiniteQuery(projectsOptions)
48
+ * <\/script>
49
+ *
50
+ * <template>
51
+ * <Projects />
52
+ * </template>
53
+ * ```
54
+ */
9
55
  function usePrefetchInfiniteQuery(options, queryClient) {
10
56
  if (process.env.NODE_ENV === "development") {
11
57
  if (!getCurrentScope()) console.warn("vue-query composable like \"useQuery()\" should only be used inside a \"setup()\" function or a running effect scope. They might otherwise lead to memory leaks.");
@@ -1 +1 @@
1
- {"version":3,"file":"usePrefetchInfiniteQuery.js","names":[],"sources":["../../src/usePrefetchInfiniteQuery.ts"],"sourcesContent":["import { getCurrentScope, unref, watchEffect } from 'vue-demi'\nimport { noop } from '@tanstack/query-core'\nimport { useQueryClient } from './useQueryClient'\nimport { cloneDeepUnref } from './utils'\nimport type {\n DefaultError,\n DistributiveOmit,\n InfiniteData,\n InfiniteQueryExecuteOptions,\n QueryKey,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './queryClient'\nimport type { MaybeRefDeep, MaybeRefOrGetter } from './types'\n\nexport type UsePrefetchInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey extends QueryKey,\n TPageParam,\n> = DistributiveOmit<\n InfiniteQueryExecuteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n 'queryFn'\n> & {\n queryFn?: Exclude<\n InfiniteQueryExecuteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >['queryFn'],\n SkipToken\n >\n}\n\nfunction isGetter<T>(value: MaybeRefOrGetter<T>): value is () => T {\n return typeof value === 'function'\n}\n\nexport function usePrefetchInfiniteQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: MaybeRefOrGetter<\n MaybeRefDeep<\n UsePrefetchInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n >\n >,\n queryClient?: QueryClient,\n): void {\n if (process.env.NODE_ENV === 'development') {\n if (!getCurrentScope()) {\n console.warn(\n 'vue-query composable like \"useQuery()\" should only be used inside a \"setup()\" function or a running effect scope. They might otherwise lead to memory leaks.',\n )\n }\n }\n\n const client = queryClient || useQueryClient()\n\n watchEffect(() => {\n const resolvedOptions = isGetter(options) ? options() : unref(options)\n\n const clonedOptions: UsePrefetchInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n > = cloneDeepUnref(resolvedOptions)\n\n if (!client.getQueryState(clonedOptions.queryKey)) {\n void client.infiniteQuery(clonedOptions).then(noop).catch(noop)\n }\n })\n}\n"],"mappings":";;;;;AA2CA,SAAS,SAAY,OAA8C;CACjE,OAAO,OAAO,UAAU;AAC1B;AAEA,SAAgB,yBAOd,SAWA,aACM;CACN,IAAI,QAAQ,IAAI,aAAa,eACvB;MAAA,CAAC,gBAAgB,GACnB,QAAQ,KACN,kKACF;CAAA;CAIJ,MAAM,SAAS,eAAe,eAAe;CAE7C,kBAAkB;EAChB,MAAM,kBAAkB,SAAS,OAAO,IAAI,QAAQ,IAAI,MAAM,OAAO;EAErE,MAAM,gBAMF,eAAe,eAAe;EAElC,IAAI,CAAC,OAAO,cAAc,cAAc,QAAQ,GAC9C,OAAY,cAAc,aAAa,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,IAAI;CAElE,CAAC;AACH"}
1
+ {"version":3,"file":"usePrefetchInfiniteQuery.js","names":[],"sources":["../../src/usePrefetchInfiniteQuery.ts"],"sourcesContent":["import { getCurrentScope, unref, watchEffect } from 'vue-demi'\nimport { noop } from '@tanstack/query-core'\nimport { useQueryClient } from './useQueryClient'\nimport { cloneDeepUnref } from './utils'\nimport type {\n DefaultError,\n DistributiveOmit,\n InfiniteData,\n InfiniteQueryExecuteOptions,\n QueryKey,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './queryClient'\nimport type { MaybeRefDeep, MaybeRefOrGetter } from './types'\n\nexport type UsePrefetchInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey extends QueryKey,\n TPageParam,\n> = DistributiveOmit<\n InfiniteQueryExecuteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n 'queryFn'\n> & {\n queryFn?: Exclude<\n InfiniteQueryExecuteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >['queryFn'],\n SkipToken\n >\n}\n\nfunction isGetter<T>(value: MaybeRefOrGetter<T>): value is () => T {\n return typeof value === 'function'\n}\n\n/**\n * `usePrefetchInfiniteQuery` does not return anything — it fires a prefetch as a reactive side effect, useful\n * for kicking off a fetch ahead of the component that will actually render the data with `useInfiniteQuery`.\n * You can pass everything to `usePrefetchInfiniteQuery` that you can pass to `queryClient.infiniteQuery`,\n * though `queryKey`, `initialPageParam`, and `getNextPageParam` are always required, and `queryFn` is required\n * unless a default query function has been defined.\n *\n * `getNextPageParam` receives both the last page of the infinite list of data and the full array of all pages,\n * as well as pageParam information, and should return a single variable that will be passed to your query\n * function as `context.pageParam`. Return `undefined` or `null` to indicate there is no next page available.\n *\n * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left\n * over from a previous attempt — so it won't refetch data that's already there or already in flight. It\n * re-runs whenever a reactive dependency in `options` (built with `infiniteQueryOptions`, for example) changes.\n *\n * Fire this during render, before a suspense boundary that wraps a component using `useInfiniteQuery`'s\n * `suspense()` — see the {@link https://tanstack.com/query/latest/docs/framework/vue/guides/suspense | Suspense guide}.\n *\n * @param options - A `ref`, plain value, or reactive getter resolving to the\n * {@link UsePrefetchInfiniteQueryOptions} to use — everything you can pass to `queryClient.infiniteQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns `void` — nothing is returned.\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { infiniteQueryOptions, usePrefetchInfiniteQuery } from '@tanstack/vue-query'\n * import Projects from './Projects.vue'\n *\n * const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * // Fire the prefetch as soon as this component runs, before `Projects` mounts and calls `useInfiniteQuery`.\n * usePrefetchInfiniteQuery(projectsOptions)\n * </script>\n *\n * <template>\n * <Projects />\n * </template>\n * ```\n */\nexport function usePrefetchInfiniteQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: MaybeRefOrGetter<\n MaybeRefDeep<\n UsePrefetchInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n >\n >,\n queryClient?: QueryClient,\n): void {\n if (process.env.NODE_ENV === 'development') {\n if (!getCurrentScope()) {\n console.warn(\n 'vue-query composable like \"useQuery()\" should only be used inside a \"setup()\" function or a running effect scope. They might otherwise lead to memory leaks.',\n )\n }\n }\n\n const client = queryClient || useQueryClient()\n\n watchEffect(() => {\n const resolvedOptions = isGetter(options) ? options() : unref(options)\n\n const clonedOptions: UsePrefetchInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n > = cloneDeepUnref(resolvedOptions)\n\n if (!client.getQueryState(clonedOptions.queryKey)) {\n void client.infiniteQuery(clonedOptions).then(noop).catch(noop)\n }\n })\n}\n"],"mappings":";;;;;AA2CA,SAAS,SAAY,OAA8C;CACjE,OAAO,OAAO,UAAU;AAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,yBAOd,SAWA,aACM;CACN,IAAI,QAAQ,IAAI,aAAa,eACvB;MAAA,CAAC,gBAAgB,GACnB,QAAQ,KACN,kKACF;CAAA;CAIJ,MAAM,SAAS,eAAe,eAAe;CAE7C,kBAAkB;EAChB,MAAM,kBAAkB,SAAS,OAAO,IAAI,QAAQ,IAAI,MAAM,OAAO;EAErE,MAAM,gBAMF,eAAe,eAAe;EAElC,IAAI,CAAC,OAAO,cAAc,cAAc,QAAQ,GAC9C,OAAY,cAAc,aAAa,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,IAAI;CAElE,CAAC;AACH"}
@@ -7,6 +7,43 @@ let vue_demi = require("vue-demi");
7
7
  function isGetter(value) {
8
8
  return typeof value === "function";
9
9
  }
10
+ /**
11
+ * `usePrefetchQuery` does not return anything — it fires a prefetch as a reactive side effect, useful for
12
+ * kicking off a fetch ahead of the component that will actually render the data with `useQuery`. You can pass
13
+ * everything to `usePrefetchQuery` that you can pass to `queryClient.query`, though `queryKey` is always
14
+ * required, and `queryFn` is required unless a default query function has been defined.
15
+ *
16
+ * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left
17
+ * over from a previous attempt — so it won't refetch data that's already there or already in flight. It
18
+ * re-runs whenever a reactive dependency in `options` (built with `queryOptions`, for example) changes.
19
+ *
20
+ * Fire this during render, before a suspense boundary that wraps a component using `useQuery`'s `suspense()`
21
+ * — see the {@link https://tanstack.com/query/latest/docs/framework/vue/guides/suspense | Suspense guide}.
22
+ *
23
+ * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UsePrefetchQueryOptions} to
24
+ * use — everything you can pass to `queryClient.query`.
25
+ * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
26
+ * will be used.
27
+ * @returns `void` — nothing is returned.
28
+ *
29
+ * @example
30
+ * ```vue
31
+ * <script setup lang="ts">
32
+ * import { usePrefetchQuery } from '@tanstack/vue-query'
33
+ * import Posts from './Posts.vue'
34
+ *
35
+ * // Fire the prefetch as soon as this component runs, before `Posts` mounts and calls `useQuery`.
36
+ * usePrefetchQuery({
37
+ * queryKey: ['posts'],
38
+ * queryFn: fetchPosts,
39
+ * })
40
+ * <\/script>
41
+ *
42
+ * <template>
43
+ * <Posts />
44
+ * </template>
45
+ * ```
46
+ */
10
47
  function usePrefetchQuery(options, queryClient) {
11
48
  if (process.env.NODE_ENV === "development") {
12
49
  if (!(0, vue_demi.getCurrentScope)()) console.warn("vue-query composable like \"useQuery()\" should only be used inside a \"setup()\" function or a running effect scope. They might otherwise lead to memory leaks.");
@@ -1 +1 @@
1
- {"version":3,"file":"usePrefetchQuery.cjs","names":["getCurrentScope","useQueryClient","unref","cloneDeepUnref","noop"],"sources":["../../src/usePrefetchQuery.ts"],"sourcesContent":["import { getCurrentScope, unref, watchEffect } from 'vue-demi'\nimport { noop } from '@tanstack/query-core'\nimport { useQueryClient } from './useQueryClient'\nimport { cloneDeepUnref } from './utils'\nimport type {\n DefaultError,\n OmitKeyof,\n QueryExecuteOptions,\n QueryKey,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './queryClient'\nimport type { MaybeRefDeep, MaybeRefOrGetter } from './types'\n\nexport type UsePrefetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n> = OmitKeyof<\n QueryExecuteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n never\n >,\n 'queryFn'\n> & {\n queryFn?: Exclude<\n QueryExecuteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n never\n >['queryFn'],\n SkipToken\n >\n}\n\nfunction isGetter<T>(value: MaybeRefOrGetter<T>): value is () => T {\n return typeof value === 'function'\n}\n\nexport function usePrefetchQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n MaybeRefDeep<\n UsePrefetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >\n >\n >,\n queryClient?: QueryClient,\n): void {\n if (process.env.NODE_ENV === 'development') {\n if (!getCurrentScope()) {\n console.warn(\n 'vue-query composable like \"useQuery()\" should only be used inside a \"setup()\" function or a running effect scope. They might otherwise lead to memory leaks.',\n )\n }\n }\n\n const client = queryClient || useQueryClient()\n\n watchEffect(() => {\n const resolvedOptions = isGetter(options) ? options() : unref(options)\n const clonedOptions: UsePrefetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n > = cloneDeepUnref(resolvedOptions)\n\n if (!client.getQueryState(clonedOptions.queryKey)) {\n void client.query(clonedOptions).catch(noop)\n }\n })\n}\n"],"mappings":";;;;;;AA4CA,SAAS,SAAY,OAA8C;CACjE,OAAO,OAAO,UAAU;AAC1B;AAEA,SAAgB,iBAOd,SAWA,aACM;CACN,IAAI,QAAQ,IAAI,aAAa,eACvB;MAAA,EAAA,GAACA,SAAAA,gBAAAA,CAAgB,GACnB,QAAQ,KACN,kKACF;CAAA;CAIJ,MAAM,SAAS,eAAeC,uBAAAA,eAAe;CAE7C,CAAA,GAAA,SAAA,YAAA,OAAkB;EAChB,MAAM,kBAAkB,SAAS,OAAO,IAAI,QAAQ,KAAA,GAAIC,SAAAA,MAAAA,CAAM,OAAO;EACrE,MAAM,gBAMFC,cAAAA,eAAe,eAAe;EAElC,IAAI,CAAC,OAAO,cAAc,cAAc,QAAQ,GAC9C,OAAY,MAAM,aAAa,CAAC,CAAC,MAAMC,qBAAAA,IAAI;CAE/C,CAAC;AACH"}
1
+ {"version":3,"file":"usePrefetchQuery.cjs","names":["getCurrentScope","useQueryClient","unref","cloneDeepUnref","noop"],"sources":["../../src/usePrefetchQuery.ts"],"sourcesContent":["import { getCurrentScope, unref, watchEffect } from 'vue-demi'\nimport { noop } from '@tanstack/query-core'\nimport { useQueryClient } from './useQueryClient'\nimport { cloneDeepUnref } from './utils'\nimport type {\n DefaultError,\n OmitKeyof,\n QueryExecuteOptions,\n QueryKey,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './queryClient'\nimport type { MaybeRefDeep, MaybeRefOrGetter } from './types'\n\nexport type UsePrefetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n> = OmitKeyof<\n QueryExecuteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n never\n >,\n 'queryFn'\n> & {\n queryFn?: Exclude<\n QueryExecuteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n never\n >['queryFn'],\n SkipToken\n >\n}\n\nfunction isGetter<T>(value: MaybeRefOrGetter<T>): value is () => T {\n return typeof value === 'function'\n}\n\n/**\n * `usePrefetchQuery` does not return anything — it fires a prefetch as a reactive side effect, useful for\n * kicking off a fetch ahead of the component that will actually render the data with `useQuery`. You can pass\n * everything to `usePrefetchQuery` that you can pass to `queryClient.query`, though `queryKey` is always\n * required, and `queryFn` is required unless a default query function has been defined.\n *\n * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left\n * over from a previous attempt — so it won't refetch data that's already there or already in flight. It\n * re-runs whenever a reactive dependency in `options` (built with `queryOptions`, for example) changes.\n *\n * Fire this during render, before a suspense boundary that wraps a component using `useQuery`'s `suspense()`\n * — see the {@link https://tanstack.com/query/latest/docs/framework/vue/guides/suspense | Suspense guide}.\n *\n * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UsePrefetchQueryOptions} to\n * use — everything you can pass to `queryClient.query`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns `void` — nothing is returned.\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { usePrefetchQuery } from '@tanstack/vue-query'\n * import Posts from './Posts.vue'\n *\n * // Fire the prefetch as soon as this component runs, before `Posts` mounts and calls `useQuery`.\n * usePrefetchQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n * </script>\n *\n * <template>\n * <Posts />\n * </template>\n * ```\n */\nexport function usePrefetchQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n MaybeRefDeep<\n UsePrefetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >\n >\n >,\n queryClient?: QueryClient,\n): void {\n if (process.env.NODE_ENV === 'development') {\n if (!getCurrentScope()) {\n console.warn(\n 'vue-query composable like \"useQuery()\" should only be used inside a \"setup()\" function or a running effect scope. They might otherwise lead to memory leaks.',\n )\n }\n }\n\n const client = queryClient || useQueryClient()\n\n watchEffect(() => {\n const resolvedOptions = isGetter(options) ? options() : unref(options)\n const clonedOptions: UsePrefetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n > = cloneDeepUnref(resolvedOptions)\n\n if (!client.getQueryState(clonedOptions.queryKey)) {\n void client.query(clonedOptions).catch(noop)\n }\n })\n}\n"],"mappings":";;;;;;AA4CA,SAAS,SAAY,OAA8C;CACjE,OAAO,OAAO,UAAU;AAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,iBAOd,SAWA,aACM;CACN,IAAI,QAAQ,IAAI,aAAa,eACvB;MAAA,EAAA,GAACA,SAAAA,gBAAAA,CAAgB,GACnB,QAAQ,KACN,kKACF;CAAA;CAIJ,MAAM,SAAS,eAAeC,uBAAAA,eAAe;CAE7C,CAAA,GAAA,SAAA,YAAA,OAAkB;EAChB,MAAM,kBAAkB,SAAS,OAAO,IAAI,QAAQ,KAAA,GAAIC,SAAAA,MAAAA,CAAM,OAAO;EACrE,MAAM,gBAMFC,cAAAA,eAAe,eAAe;EAElC,IAAI,CAAC,OAAO,cAAc,cAAc,QAAQ,GAC9C,OAAY,MAAM,aAAa,CAAC,CAAC,MAAMC,qBAAAA,IAAI;CAE/C,CAAC;AACH"}
@@ -1,10 +1,47 @@
1
- import { t as QueryClient$1 } from "./queryClient-C07d0chJ.cjs";
2
- import { o as MaybeRefDeep, s as MaybeRefOrGetter } from "./types-BzZi3_rS.cjs";
1
+ import { o as MaybeRefDeep, s as MaybeRefOrGetter } from "./types-JpJB72CS.cjs";
2
+ import { t as QueryClient$1 } from "./queryClient-CZeNAt68.cjs";
3
3
  import { DefaultError, OmitKeyof, QueryExecuteOptions, QueryKey, SkipToken } from "@tanstack/query-core";
4
4
  //#region src/usePrefetchQuery.d.ts
5
5
  type UsePrefetchQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey> = OmitKeyof<QueryExecuteOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, never>, 'queryFn'> & {
6
6
  queryFn?: Exclude<QueryExecuteOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, never>['queryFn'], SkipToken>;
7
7
  };
8
+ /**
9
+ * `usePrefetchQuery` does not return anything — it fires a prefetch as a reactive side effect, useful for
10
+ * kicking off a fetch ahead of the component that will actually render the data with `useQuery`. You can pass
11
+ * everything to `usePrefetchQuery` that you can pass to `queryClient.query`, though `queryKey` is always
12
+ * required, and `queryFn` is required unless a default query function has been defined.
13
+ *
14
+ * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left
15
+ * over from a previous attempt — so it won't refetch data that's already there or already in flight. It
16
+ * re-runs whenever a reactive dependency in `options` (built with `queryOptions`, for example) changes.
17
+ *
18
+ * Fire this during render, before a suspense boundary that wraps a component using `useQuery`'s `suspense()`
19
+ * — see the {@link https://tanstack.com/query/latest/docs/framework/vue/guides/suspense | Suspense guide}.
20
+ *
21
+ * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UsePrefetchQueryOptions} to
22
+ * use — everything you can pass to `queryClient.query`.
23
+ * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
24
+ * will be used.
25
+ * @returns `void` — nothing is returned.
26
+ *
27
+ * @example
28
+ * ```vue
29
+ * <script setup lang="ts">
30
+ * import { usePrefetchQuery } from '@tanstack/vue-query'
31
+ * import Posts from './Posts.vue'
32
+ *
33
+ * // Fire the prefetch as soon as this component runs, before `Posts` mounts and calls `useQuery`.
34
+ * usePrefetchQuery({
35
+ * queryKey: ['posts'],
36
+ * queryFn: fetchPosts,
37
+ * })
38
+ * </script>
39
+ *
40
+ * <template>
41
+ * <Posts />
42
+ * </template>
43
+ * ```
44
+ */
8
45
  declare function usePrefetchQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: MaybeRefOrGetter<MaybeRefDeep<UsePrefetchQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>>>, queryClient?: QueryClient$1): void;
9
46
  //#endregion
10
47
  export { UsePrefetchQueryOptions, usePrefetchQuery };
@@ -1 +1 @@
1
- {"version":3,"file":"usePrefetchQuery.d.cts","names":[],"sources":["../../src/usePrefetchQuery.ts"],"mappings":";;;;KAcY,wBACV,cACA,QACA,OACA,YACA,kBAAkB,YAChB,UACF,oBACE,cACA,QACA,OACA,YACA;EAKF,UAAU,QACR,oBACE,cACA,QACA,OACA,YACA,8BAGF;;iBAQY,iBACd,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,UAE7B,SAAS,iBACP,aACE,wBACE,cACA,QACA,OACA,YACA,cAIN,cAAc"}
1
+ {"version":3,"file":"usePrefetchQuery.d.cts","names":[],"sources":["../../src/usePrefetchQuery.ts"],"mappings":";;;;KAcY,wBACV,cACA,QACA,OACA,YACA,kBAAkB,YAChB,UACF,oBACE,cACA,QACA,OACA,YACA;EAKF,UAAU,QACR,oBACE,cACA,QACA,OACA,YACA,8BAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6CY,iBACd,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,UAE7B,SAAS,iBACP,aACE,wBACE,cACA,QACA,OACA,YACA,cAIN,cAAc"}
@@ -1,10 +1,47 @@
1
- import { t as QueryClient$1 } from "./queryClient-hf6i_vCa.js";
2
- import { o as MaybeRefDeep, s as MaybeRefOrGetter } from "./types-BzZi3_rS.js";
1
+ import { o as MaybeRefDeep, s as MaybeRefOrGetter } from "./types-JpJB72CS.js";
2
+ import { t as QueryClient$1 } from "./queryClient-Cv73nzNT.js";
3
3
  import { DefaultError, OmitKeyof, QueryExecuteOptions, QueryKey, SkipToken } from "@tanstack/query-core";
4
4
  //#region src/usePrefetchQuery.d.ts
5
5
  type UsePrefetchQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey> = OmitKeyof<QueryExecuteOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, never>, 'queryFn'> & {
6
6
  queryFn?: Exclude<QueryExecuteOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, never>['queryFn'], SkipToken>;
7
7
  };
8
+ /**
9
+ * `usePrefetchQuery` does not return anything — it fires a prefetch as a reactive side effect, useful for
10
+ * kicking off a fetch ahead of the component that will actually render the data with `useQuery`. You can pass
11
+ * everything to `usePrefetchQuery` that you can pass to `queryClient.query`, though `queryKey` is always
12
+ * required, and `queryFn` is required unless a default query function has been defined.
13
+ *
14
+ * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left
15
+ * over from a previous attempt — so it won't refetch data that's already there or already in flight. It
16
+ * re-runs whenever a reactive dependency in `options` (built with `queryOptions`, for example) changes.
17
+ *
18
+ * Fire this during render, before a suspense boundary that wraps a component using `useQuery`'s `suspense()`
19
+ * — see the {@link https://tanstack.com/query/latest/docs/framework/vue/guides/suspense | Suspense guide}.
20
+ *
21
+ * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UsePrefetchQueryOptions} to
22
+ * use — everything you can pass to `queryClient.query`.
23
+ * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
24
+ * will be used.
25
+ * @returns `void` — nothing is returned.
26
+ *
27
+ * @example
28
+ * ```vue
29
+ * <script setup lang="ts">
30
+ * import { usePrefetchQuery } from '@tanstack/vue-query'
31
+ * import Posts from './Posts.vue'
32
+ *
33
+ * // Fire the prefetch as soon as this component runs, before `Posts` mounts and calls `useQuery`.
34
+ * usePrefetchQuery({
35
+ * queryKey: ['posts'],
36
+ * queryFn: fetchPosts,
37
+ * })
38
+ * </script>
39
+ *
40
+ * <template>
41
+ * <Posts />
42
+ * </template>
43
+ * ```
44
+ */
8
45
  declare function usePrefetchQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: MaybeRefOrGetter<MaybeRefDeep<UsePrefetchQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>>>, queryClient?: QueryClient$1): void;
9
46
  //#endregion
10
47
  export { UsePrefetchQueryOptions, usePrefetchQuery };
@@ -1 +1 @@
1
- {"version":3,"file":"usePrefetchQuery.d.ts","names":[],"sources":["../../src/usePrefetchQuery.ts"],"mappings":";;;;KAcY,wBACV,cACA,QACA,OACA,YACA,kBAAkB,YAChB,UACF,oBACE,cACA,QACA,OACA,YACA;EAKF,UAAU,QACR,oBACE,cACA,QACA,OACA,YACA,8BAGF;;iBAQY,iBACd,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,UAE7B,SAAS,iBACP,aACE,wBACE,cACA,QACA,OACA,YACA,cAIN,cAAc"}
1
+ {"version":3,"file":"usePrefetchQuery.d.ts","names":[],"sources":["../../src/usePrefetchQuery.ts"],"mappings":";;;;KAcY,wBACV,cACA,QACA,OACA,YACA,kBAAkB,YAChB,UACF,oBACE,cACA,QACA,OACA,YACA;EAKF,UAAU,QACR,oBACE,cACA,QACA,OACA,YACA,8BAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6CY,iBACd,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,UAE7B,SAAS,iBACP,aACE,wBACE,cACA,QACA,OACA,YACA,cAIN,cAAc"}
@@ -6,6 +6,43 @@ import { getCurrentScope, unref, watchEffect } from "vue-demi";
6
6
  function isGetter(value) {
7
7
  return typeof value === "function";
8
8
  }
9
+ /**
10
+ * `usePrefetchQuery` does not return anything — it fires a prefetch as a reactive side effect, useful for
11
+ * kicking off a fetch ahead of the component that will actually render the data with `useQuery`. You can pass
12
+ * everything to `usePrefetchQuery` that you can pass to `queryClient.query`, though `queryKey` is always
13
+ * required, and `queryFn` is required unless a default query function has been defined.
14
+ *
15
+ * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left
16
+ * over from a previous attempt — so it won't refetch data that's already there or already in flight. It
17
+ * re-runs whenever a reactive dependency in `options` (built with `queryOptions`, for example) changes.
18
+ *
19
+ * Fire this during render, before a suspense boundary that wraps a component using `useQuery`'s `suspense()`
20
+ * — see the {@link https://tanstack.com/query/latest/docs/framework/vue/guides/suspense | Suspense guide}.
21
+ *
22
+ * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UsePrefetchQueryOptions} to
23
+ * use — everything you can pass to `queryClient.query`.
24
+ * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
25
+ * will be used.
26
+ * @returns `void` — nothing is returned.
27
+ *
28
+ * @example
29
+ * ```vue
30
+ * <script setup lang="ts">
31
+ * import { usePrefetchQuery } from '@tanstack/vue-query'
32
+ * import Posts from './Posts.vue'
33
+ *
34
+ * // Fire the prefetch as soon as this component runs, before `Posts` mounts and calls `useQuery`.
35
+ * usePrefetchQuery({
36
+ * queryKey: ['posts'],
37
+ * queryFn: fetchPosts,
38
+ * })
39
+ * <\/script>
40
+ *
41
+ * <template>
42
+ * <Posts />
43
+ * </template>
44
+ * ```
45
+ */
9
46
  function usePrefetchQuery(options, queryClient) {
10
47
  if (process.env.NODE_ENV === "development") {
11
48
  if (!getCurrentScope()) console.warn("vue-query composable like \"useQuery()\" should only be used inside a \"setup()\" function or a running effect scope. They might otherwise lead to memory leaks.");
@@ -1 +1 @@
1
- {"version":3,"file":"usePrefetchQuery.js","names":[],"sources":["../../src/usePrefetchQuery.ts"],"sourcesContent":["import { getCurrentScope, unref, watchEffect } from 'vue-demi'\nimport { noop } from '@tanstack/query-core'\nimport { useQueryClient } from './useQueryClient'\nimport { cloneDeepUnref } from './utils'\nimport type {\n DefaultError,\n OmitKeyof,\n QueryExecuteOptions,\n QueryKey,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './queryClient'\nimport type { MaybeRefDeep, MaybeRefOrGetter } from './types'\n\nexport type UsePrefetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n> = OmitKeyof<\n QueryExecuteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n never\n >,\n 'queryFn'\n> & {\n queryFn?: Exclude<\n QueryExecuteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n never\n >['queryFn'],\n SkipToken\n >\n}\n\nfunction isGetter<T>(value: MaybeRefOrGetter<T>): value is () => T {\n return typeof value === 'function'\n}\n\nexport function usePrefetchQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n MaybeRefDeep<\n UsePrefetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >\n >\n >,\n queryClient?: QueryClient,\n): void {\n if (process.env.NODE_ENV === 'development') {\n if (!getCurrentScope()) {\n console.warn(\n 'vue-query composable like \"useQuery()\" should only be used inside a \"setup()\" function or a running effect scope. They might otherwise lead to memory leaks.',\n )\n }\n }\n\n const client = queryClient || useQueryClient()\n\n watchEffect(() => {\n const resolvedOptions = isGetter(options) ? options() : unref(options)\n const clonedOptions: UsePrefetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n > = cloneDeepUnref(resolvedOptions)\n\n if (!client.getQueryState(clonedOptions.queryKey)) {\n void client.query(clonedOptions).catch(noop)\n }\n })\n}\n"],"mappings":";;;;;AA4CA,SAAS,SAAY,OAA8C;CACjE,OAAO,OAAO,UAAU;AAC1B;AAEA,SAAgB,iBAOd,SAWA,aACM;CACN,IAAI,QAAQ,IAAI,aAAa,eACvB;MAAA,CAAC,gBAAgB,GACnB,QAAQ,KACN,kKACF;CAAA;CAIJ,MAAM,SAAS,eAAe,eAAe;CAE7C,kBAAkB;EAChB,MAAM,kBAAkB,SAAS,OAAO,IAAI,QAAQ,IAAI,MAAM,OAAO;EACrE,MAAM,gBAMF,eAAe,eAAe;EAElC,IAAI,CAAC,OAAO,cAAc,cAAc,QAAQ,GAC9C,OAAY,MAAM,aAAa,CAAC,CAAC,MAAM,IAAI;CAE/C,CAAC;AACH"}
1
+ {"version":3,"file":"usePrefetchQuery.js","names":[],"sources":["../../src/usePrefetchQuery.ts"],"sourcesContent":["import { getCurrentScope, unref, watchEffect } from 'vue-demi'\nimport { noop } from '@tanstack/query-core'\nimport { useQueryClient } from './useQueryClient'\nimport { cloneDeepUnref } from './utils'\nimport type {\n DefaultError,\n OmitKeyof,\n QueryExecuteOptions,\n QueryKey,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './queryClient'\nimport type { MaybeRefDeep, MaybeRefOrGetter } from './types'\n\nexport type UsePrefetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n> = OmitKeyof<\n QueryExecuteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n never\n >,\n 'queryFn'\n> & {\n queryFn?: Exclude<\n QueryExecuteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n never\n >['queryFn'],\n SkipToken\n >\n}\n\nfunction isGetter<T>(value: MaybeRefOrGetter<T>): value is () => T {\n return typeof value === 'function'\n}\n\n/**\n * `usePrefetchQuery` does not return anything — it fires a prefetch as a reactive side effect, useful for\n * kicking off a fetch ahead of the component that will actually render the data with `useQuery`. You can pass\n * everything to `usePrefetchQuery` that you can pass to `queryClient.query`, though `queryKey` is always\n * required, and `queryFn` is required unless a default query function has been defined.\n *\n * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left\n * over from a previous attempt — so it won't refetch data that's already there or already in flight. It\n * re-runs whenever a reactive dependency in `options` (built with `queryOptions`, for example) changes.\n *\n * Fire this during render, before a suspense boundary that wraps a component using `useQuery`'s `suspense()`\n * — see the {@link https://tanstack.com/query/latest/docs/framework/vue/guides/suspense | Suspense guide}.\n *\n * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UsePrefetchQueryOptions} to\n * use — everything you can pass to `queryClient.query`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns `void` — nothing is returned.\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { usePrefetchQuery } from '@tanstack/vue-query'\n * import Posts from './Posts.vue'\n *\n * // Fire the prefetch as soon as this component runs, before `Posts` mounts and calls `useQuery`.\n * usePrefetchQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n * </script>\n *\n * <template>\n * <Posts />\n * </template>\n * ```\n */\nexport function usePrefetchQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n MaybeRefDeep<\n UsePrefetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >\n >\n >,\n queryClient?: QueryClient,\n): void {\n if (process.env.NODE_ENV === 'development') {\n if (!getCurrentScope()) {\n console.warn(\n 'vue-query composable like \"useQuery()\" should only be used inside a \"setup()\" function or a running effect scope. They might otherwise lead to memory leaks.',\n )\n }\n }\n\n const client = queryClient || useQueryClient()\n\n watchEffect(() => {\n const resolvedOptions = isGetter(options) ? options() : unref(options)\n const clonedOptions: UsePrefetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n > = cloneDeepUnref(resolvedOptions)\n\n if (!client.getQueryState(clonedOptions.queryKey)) {\n void client.query(clonedOptions).catch(noop)\n }\n })\n}\n"],"mappings":";;;;;AA4CA,SAAS,SAAY,OAA8C;CACjE,OAAO,OAAO,UAAU;AAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,iBAOd,SAWA,aACM;CACN,IAAI,QAAQ,IAAI,aAAa,eACvB;MAAA,CAAC,gBAAgB,GACnB,QAAQ,KACN,kKACF;CAAA;CAIJ,MAAM,SAAS,eAAe,eAAe;CAE7C,kBAAkB;EAChB,MAAM,kBAAkB,SAAS,OAAO,IAAI,QAAQ,IAAI,MAAM,OAAO;EACrE,MAAM,gBAMF,eAAe,eAAe;EAElC,IAAI,CAAC,OAAO,cAAc,cAAc,QAAQ,GAC9C,OAAY,MAAM,aAAa,CAAC,CAAC,MAAM,IAAI;CAE/C,CAAC;AACH"}
@@ -4,6 +4,129 @@ const require_useQueryClient = require("./useQueryClient.cjs");
4
4
  let _tanstack_query_core = require("@tanstack/query-core");
5
5
  let vue_demi = require("vue-demi");
6
6
  //#region src/useQueries.ts
7
+ /**
8
+ * The `useQueries` composable can be used to fetch a variable number of queries.
9
+ *
10
+ * The `queries` option accepts an array of query option objects mostly identical to `useQuery`'s. It may be a
11
+ * plain array, a `ref`/reactive array (each entry tracked individually), or a getter function — pass a getter
12
+ * if the array itself (its length, or which queries are in it) depends on other reactive state.
13
+ *
14
+ * Having the same query key more than once in the array of query objects may cause some data to be shared
15
+ * between queries. To avoid this, consider de-duplicating the queries and map the results back to the desired
16
+ * structure.
17
+ *
18
+ * The `combine` option can be used to combine the results of the queries into a single value. The result will
19
+ * be structurally shared to be as referentially stable as possible.
20
+ *
21
+ * `placeholderData` is supported here too, but unlike `useQuery`, it doesn't receive information from
22
+ * previously rendered queries, because the number of queries can differ between renders.
23
+ *
24
+ * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
25
+ * will be used.
26
+ * @returns A `ref` to the combined result. Without `combine`, this is an array with all the query results, in
27
+ * the same order as the input. When `combine` is provided, this is the value returned by `combine` instead.
28
+ *
29
+ * @example
30
+ * ```vue
31
+ * <script setup lang="ts">
32
+ * import { useQueries } from '@tanstack/vue-query'
33
+ *
34
+ * const props = defineProps<{ ids: Array<number> }>()
35
+ *
36
+ * const postQueries = useQueries({
37
+ * queries: () =>
38
+ * props.ids.map((id) => ({
39
+ * queryKey: ['post', id],
40
+ * queryFn: () => fetchPost(id),
41
+ * staleTime: Infinity,
42
+ * })),
43
+ * })
44
+ * <\/script>
45
+ *
46
+ * <template>
47
+ * <ul>
48
+ * <li v-for="(query, index) in postQueries" :key="props.ids[index]">
49
+ * <span v-if="query.isPending">Loading...</span>
50
+ * <span v-else-if="query.isError">Error: {{ query.error.message }}</span>
51
+ * <span v-else>{{ query.data.title }}</span>
52
+ * </li>
53
+ * </ul>
54
+ * </template>
55
+ * ```
56
+ *
57
+ * @example
58
+ * Combining results into a single value:
59
+ * ```vue
60
+ * <script setup lang="ts">
61
+ * import { useQueries } from '@tanstack/vue-query'
62
+ *
63
+ * const props = defineProps<{ ids: Array<number> }>()
64
+ *
65
+ * const combined = useQueries({
66
+ * queries: () =>
67
+ * props.ids.map((id) => ({
68
+ * queryKey: ['post', id],
69
+ * queryFn: () => fetchPost(id),
70
+ * })),
71
+ * combine: (postQueries) => ({
72
+ * data: postQueries.map((query) => query.data),
73
+ * isPending: postQueries.some((query) => query.isPending),
74
+ * isError: postQueries.some((query) => query.isError),
75
+ * }),
76
+ * })
77
+ * <\/script>
78
+ *
79
+ * <template>
80
+ * <span v-if="combined.isPending">Loading...</span>
81
+ * <span v-else-if="combined.isError">Error!</span>
82
+ * <ul v-else>
83
+ * <li v-for="post in combined.data" :key="post.id">{{ post.title }}</li>
84
+ * </ul>
85
+ * </template>
86
+ * ```
87
+ *
88
+ * @example
89
+ * Typing `select` via {@link queryOptions}. Note that spreading a `queryOptions` result and overriding
90
+ * `select` inline still falls back to `unknown` — wrap the spread in `queryOptions` again so the override is
91
+ * resolved before it reaches `useQueries`:
92
+ * ```vue
93
+ * <script setup lang="ts">
94
+ * import { queryOptions, useQueries } from '@tanstack/vue-query'
95
+ *
96
+ * const props = defineProps<{ id: number }>()
97
+ *
98
+ * const postOptions = (id: number) =>
99
+ * queryOptions({
100
+ * queryKey: ['post', id],
101
+ * queryFn: () => fetchPost(id),
102
+ * })
103
+ *
104
+ * const [{ data: broken }] = useQueries({
105
+ * queries: () => [
106
+ * {
107
+ * ...postOptions(props.id),
108
+ * // ❌ `data` is `unknown` here
109
+ * select: (data) => data.title,
110
+ * },
111
+ * ],
112
+ * })
113
+ *
114
+ * const [{ data: fixed }] = useQueries({
115
+ * queries: () => [
116
+ * queryOptions({
117
+ * ...postOptions(props.id),
118
+ * // ✅ `data` is `Post`
119
+ * select: (data) => data.title,
120
+ * }),
121
+ * ],
122
+ * })
123
+ * <\/script>
124
+ *
125
+ * <template>
126
+ * <h1>{{ fixed }}</h1>
127
+ * </template>
128
+ * ```
129
+ */
7
130
  function useQueries({ queries, ...options }, queryClient) {
8
131
  if (process.env.NODE_ENV === "development") {
9
132
  if (!(0, vue_demi.getCurrentScope)()) console.warn("vue-query composable like \"useQuery()\" should only be used inside a \"setup()\" function or a running effect scope. They might otherwise lead to memory leaks.");