@tanstack/vue-query 5.102.8 → 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,5 +1,26 @@
1
- import { t as QueryClient } from "./queryClient-C07d0chJ.cjs";
1
+ import { t as QueryClient } from "./queryClient-CZeNAt68.cjs";
2
2
  //#region src/useQueryClient.d.ts
3
+ /**
4
+ * Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside
5
+ * `setup()` or another function that supports an injection context.
6
+ *
7
+ * @param id - The `queryClientKey` passed to `VueQueryPlugin` — only needed when multiple `QueryClient`s are
8
+ * installed in the same app.
9
+ * @throws If called outside an injection context, or if no `QueryClient` was installed via `VueQueryPlugin`.
10
+ *
11
+ * @example
12
+ * ```vue
13
+ * <script setup lang="ts">
14
+ * import { useQueryClient } from '@tanstack/vue-query'
15
+ *
16
+ * const queryClient = useQueryClient()
17
+ *
18
+ * function invalidate() {
19
+ * queryClient.invalidateQueries({ queryKey: ['todos'] })
20
+ * }
21
+ * </script>
22
+ * ```
23
+ */
3
24
  declare function useQueryClient(id?: string): QueryClient;
4
25
  //#endregion
5
26
  export { useQueryClient };
@@ -1 +1 @@
1
- {"version":3,"file":"useQueryClient.d.cts","names":[],"sources":["../../src/useQueryClient.ts"],"mappings":";;iBAKgB,eAAe,cAAU"}
1
+ {"version":3,"file":"useQueryClient.d.cts","names":[],"sources":["../../src/useQueryClient.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;iBA0BgB,eAAe,cAAU"}
@@ -1,5 +1,26 @@
1
- import { t as QueryClient } from "./queryClient-hf6i_vCa.js";
1
+ import { t as QueryClient } from "./queryClient-Cv73nzNT.js";
2
2
  //#region src/useQueryClient.d.ts
3
+ /**
4
+ * Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside
5
+ * `setup()` or another function that supports an injection context.
6
+ *
7
+ * @param id - The `queryClientKey` passed to `VueQueryPlugin` — only needed when multiple `QueryClient`s are
8
+ * installed in the same app.
9
+ * @throws If called outside an injection context, or if no `QueryClient` was installed via `VueQueryPlugin`.
10
+ *
11
+ * @example
12
+ * ```vue
13
+ * <script setup lang="ts">
14
+ * import { useQueryClient } from '@tanstack/vue-query'
15
+ *
16
+ * const queryClient = useQueryClient()
17
+ *
18
+ * function invalidate() {
19
+ * queryClient.invalidateQueries({ queryKey: ['todos'] })
20
+ * }
21
+ * </script>
22
+ * ```
23
+ */
3
24
  declare function useQueryClient(id?: string): QueryClient;
4
25
  //#endregion
5
26
  export { useQueryClient };
@@ -1 +1 @@
1
- {"version":3,"file":"useQueryClient.d.ts","names":[],"sources":["../../src/useQueryClient.ts"],"mappings":";;iBAKgB,eAAe,cAAU"}
1
+ {"version":3,"file":"useQueryClient.d.ts","names":[],"sources":["../../src/useQueryClient.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;iBA0BgB,eAAe,cAAU"}
@@ -1,6 +1,27 @@
1
1
  import { getClientKey } from "./utils.js";
2
2
  import { hasInjectionContext, inject } from "vue-demi";
3
3
  //#region src/useQueryClient.ts
4
+ /**
5
+ * Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside
6
+ * `setup()` or another function that supports an injection context.
7
+ *
8
+ * @param id - The `queryClientKey` passed to `VueQueryPlugin` — only needed when multiple `QueryClient`s are
9
+ * installed in the same app.
10
+ * @throws If called outside an injection context, or if no `QueryClient` was installed via `VueQueryPlugin`.
11
+ *
12
+ * @example
13
+ * ```vue
14
+ * <script setup lang="ts">
15
+ * import { useQueryClient } from '@tanstack/vue-query'
16
+ *
17
+ * const queryClient = useQueryClient()
18
+ *
19
+ * function invalidate() {
20
+ * queryClient.invalidateQueries({ queryKey: ['todos'] })
21
+ * }
22
+ * <\/script>
23
+ * ```
24
+ */
4
25
  function useQueryClient(id = "") {
5
26
  if (!hasInjectionContext()) throw new Error("vue-query hooks can only be used inside setup() function or functions that support injection context.");
6
27
  const key = getClientKey(id);
@@ -1 +1 @@
1
- {"version":3,"file":"useQueryClient.js","names":[],"sources":["../../src/useQueryClient.ts"],"sourcesContent":["import { hasInjectionContext, inject } from 'vue-demi'\n\nimport { getClientKey } from './utils'\nimport type { QueryClient } from './queryClient'\n\nexport function useQueryClient(id = ''): QueryClient {\n // ensures that `inject()` can be used\n if (!hasInjectionContext()) {\n throw new Error(\n 'vue-query hooks can only be used inside setup() function or functions that support injection context.',\n )\n }\n\n const key = getClientKey(id)\n const queryClient = inject<QueryClient>(key)\n\n if (!queryClient) {\n throw new Error(\n \"No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.\",\n )\n }\n\n return queryClient\n}\n"],"mappings":";;;AAKA,SAAgB,eAAe,KAAK,IAAiB;CAEnD,IAAI,CAAC,oBAAoB,GACvB,MAAM,IAAI,MACR,uGACF;CAGF,MAAM,MAAM,aAAa,EAAE;CAC3B,MAAM,cAAc,OAAoB,GAAG;CAE3C,IAAI,CAAC,aACH,MAAM,IAAI,MACR,iGACF;CAGF,OAAO;AACT"}
1
+ {"version":3,"file":"useQueryClient.js","names":[],"sources":["../../src/useQueryClient.ts"],"sourcesContent":["import { hasInjectionContext, inject } from 'vue-demi'\n\nimport { getClientKey } from './utils'\nimport type { QueryClient } from './queryClient'\n\n/**\n * Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside\n * `setup()` or another function that supports an injection context.\n *\n * @param id - The `queryClientKey` passed to `VueQueryPlugin` — only needed when multiple `QueryClient`s are\n * installed in the same app.\n * @throws If called outside an injection context, or if no `QueryClient` was installed via `VueQueryPlugin`.\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQueryClient } from '@tanstack/vue-query'\n *\n * const queryClient = useQueryClient()\n *\n * function invalidate() {\n * queryClient.invalidateQueries({ queryKey: ['todos'] })\n * }\n * </script>\n * ```\n */\nexport function useQueryClient(id = ''): QueryClient {\n // ensures that `inject()` can be used\n if (!hasInjectionContext()) {\n throw new Error(\n 'vue-query hooks can only be used inside setup() function or functions that support injection context.',\n )\n }\n\n const key = getClientKey(id)\n const queryClient = inject<QueryClient>(key)\n\n if (!queryClient) {\n throw new Error(\n \"No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.\",\n )\n }\n\n return queryClient\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,eAAe,KAAK,IAAiB;CAEnD,IAAI,CAAC,oBAAoB,GACvB,MAAM,IAAI,MACR,uGACF;CAGF,MAAM,MAAM,aAAa,EAAE;CAC3B,MAAM,cAAc,OAAoB,GAAG;CAE3C,IAAI,CAAC,aACH,MAAM,IAAI,MACR,iGACF;CAGF,OAAO;AACT"}
@@ -1,11 +1,14 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let vue_demi = require("vue-demi");
3
3
  //#region src/utils.ts
4
+ /** @internal Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under. */
4
5
  const VUE_QUERY_CLIENT = "VUE_QUERY_CLIENT";
6
+ /** @internal Builds the injection key `useQueryClient`/`VueQueryPlugin` use for a given `queryClientKey`. */
5
7
  function getClientKey(key) {
6
8
  const suffix = key ? `:${key}` : "";
7
9
  return `${VUE_QUERY_CLIENT}${suffix}`;
8
10
  }
11
+ /** @internal Copies each property from `update` onto `state`, in place, for every key already on `state`. */
9
12
  function updateState(state, update) {
10
13
  Object.keys(state).forEach((key) => {
11
14
  state[key] = update[key];
@@ -24,9 +27,20 @@ function _cloneDeep(value, customize, currentKey = "", currentLevel = 0) {
24
27
  }
25
28
  return value;
26
29
  }
30
+ /**
31
+ * @internal Deep-clones `value`, recursing into arrays and plain objects. `customize`, if provided, can
32
+ * intercept any node (by key and nesting level) and substitute its own return value instead of recursing
33
+ * further.
34
+ */
27
35
  function cloneDeep(value, customize) {
28
36
  return _cloneDeep(value, customize);
29
37
  }
38
+ /**
39
+ * @internal Deep-clones `value` like {@link cloneDeep}, additionally unwrapping any `ref`s it encounters (and,
40
+ * if `unrefGetters` is `true`, calling any functions it encounters and unwrapping their result too). Always
41
+ * resolves `queryKey` this way, regardless of `unrefGetters` — this is what lets a `queryKey` containing `ref`s
42
+ * be passed straight through to `@tanstack/query-core`.
43
+ */
30
44
  function cloneDeepUnref(obj, unrefGetters = false) {
31
45
  return cloneDeep(obj, (val, key, level) => {
32
46
  if (level === 1 && key === "queryKey") return cloneDeepUnref(val, true);
@@ -42,6 +56,7 @@ function isPlainObject(value) {
42
56
  function isFunction(value) {
43
57
  return typeof value === "function";
44
58
  }
59
+ /** @internal Resolves `source` to a plain value — calls it if it's a function, otherwise deep-unwraps it. */
45
60
  function toValueDeep(source) {
46
61
  return isFunction(source) ? source() : cloneDeepUnref(source);
47
62
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","names":["isRef","unref"],"sources":["../../src/utils.ts"],"sourcesContent":["import { isRef, unref } from 'vue-demi'\nimport type { MaybeRefDeep } from './types'\n\nexport const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT'\n\nexport function getClientKey(key?: string) {\n const suffix = key ? `:${key}` : ''\n return `${VUE_QUERY_CLIENT}${suffix}`\n}\n\nexport function updateState(\n state: Record<string, any>,\n update: Record<string, any>,\n): void {\n Object.keys(state).forEach((key) => {\n state[key] = update[key]\n })\n}\n\n// Helper function for cloning deep objects where\n// the level and key is provided to the callback function.\nfunction _cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n currentKey: string = '',\n currentLevel: number = 0,\n): T {\n if (customize) {\n const result = customize(value, currentKey, currentLevel)\n if (result === undefined && isRef(value)) {\n return result as T\n }\n if (result !== undefined) {\n return result\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((val, index) =>\n _cloneDeep(val, customize, String(index), currentLevel + 1),\n ) as unknown as T\n }\n\n if (typeof value === 'object' && isPlainObject(value)) {\n const entries = Object.entries(value).map(([key, val]) => [\n key,\n _cloneDeep(val, customize, key, currentLevel + 1),\n ])\n return Object.fromEntries(entries)\n }\n\n return value as T\n}\n\nexport function cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n): T {\n return _cloneDeep(value, customize)\n}\n\nexport function cloneDeepUnref<T>(\n obj: MaybeRefDeep<T>,\n unrefGetters = false,\n): T {\n return cloneDeep(obj, (val, key, level) => {\n // Check if we're at the top level and the key is 'queryKey'\n //\n // If so, take the recursive descent where we resolve\n // getters to values as well as refs.\n if (level === 1 && key === 'queryKey') {\n return cloneDeepUnref(val, true)\n }\n\n // Resolve getters to values if specified.\n if (unrefGetters && isFunction(val)) {\n // Cast due to older TS versions not allowing calling\n // on certain intersection types.\n return cloneDeepUnref((val as Function)(), unrefGetters)\n }\n\n // Unref refs and continue to recurse into the value.\n if (isRef(val)) {\n return cloneDeepUnref(unref(val), unrefGetters)\n }\n\n return undefined\n })\n}\n\n// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\nfunction isPlainObject(value: unknown): value is Object {\n if (Object.prototype.toString.call(value) !== '[object Object]') {\n return false\n }\n\n const prototype = Object.getPrototypeOf(value)\n return prototype === null || prototype === Object.prototype\n}\n\nfunction isFunction(value: unknown): value is Function {\n return typeof value === 'function'\n}\n\nexport function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T {\n return isFunction(source) ? source() : cloneDeepUnref(source)\n}\n"],"mappings":";;;AAGA,MAAa,mBAAmB;AAEhC,SAAgB,aAAa,KAAc;CACzC,MAAM,SAAS,MAAM,IAAI,QAAQ;CACjC,OAAO,GAAG,mBAAmB;AAC/B;AAEA,SAAgB,YACd,OACA,QACM;CACN,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,QAAQ;EAClC,MAAM,OAAO,OAAO;CACtB,CAAC;AACH;AAIA,SAAS,WACP,OACA,WAKA,aAAqB,IACrB,eAAuB,GACpB;CACH,IAAI,WAAW;EACb,MAAM,SAAS,UAAU,OAAO,YAAY,YAAY;EACxD,IAAI,WAAW,KAAA,MAAA,GAAaA,SAAAA,MAAAA,CAAM,KAAK,GACrC,OAAO;EAET,IAAI,WAAW,KAAA,GACb,OAAO;CAEX;CAEA,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,KAAK,KAAK,UACrB,WAAW,KAAK,WAAW,OAAO,KAAK,GAAG,eAAe,CAAC,CAC5D;CAGF,IAAI,OAAO,UAAU,YAAY,cAAc,KAAK,GAAG;EACrD,MAAM,UAAU,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,SAAS,CACxD,KACA,WAAW,KAAK,WAAW,KAAK,eAAe,CAAC,CAClD,CAAC;EACD,OAAO,OAAO,YAAY,OAAO;CACnC;CAEA,OAAO;AACT;AAEA,SAAgB,UACd,OACA,WAKG;CACH,OAAO,WAAW,OAAO,SAAS;AACpC;AAEA,SAAgB,eACd,KACA,eAAe,OACZ;CACH,OAAO,UAAU,MAAM,KAAK,KAAK,UAAU;EAKzC,IAAI,UAAU,KAAK,QAAQ,YACzB,OAAO,eAAe,KAAK,IAAI;EAIjC,IAAI,gBAAgB,WAAW,GAAG,GAGhC,OAAO,eAAgB,IAAiB,GAAG,YAAY;EAIzD,KAAA,GAAIA,SAAAA,MAAAA,CAAM,GAAG,GACX,OAAO,gBAAA,GAAeC,SAAAA,MAAAA,CAAM,GAAG,GAAG,YAAY;CAIlD,CAAC;AACH;AAGA,SAAS,cAAc,OAAiC;CACtD,IAAI,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM,mBAC5C,OAAO;CAGT,MAAM,YAAY,OAAO,eAAe,KAAK;CAC7C,OAAO,cAAc,QAAQ,cAAc,OAAO;AACpD;AAEA,SAAS,WAAW,OAAmC;CACrD,OAAO,OAAO,UAAU;AAC1B;AAEA,SAAgB,YAAe,QAAwC;CACrE,OAAO,WAAW,MAAM,IAAI,OAAO,IAAI,eAAe,MAAM;AAC9D"}
1
+ {"version":3,"file":"utils.cjs","names":["isRef","unref"],"sources":["../../src/utils.ts"],"sourcesContent":["import { isRef, unref } from 'vue-demi'\nimport type { MaybeRefDeep } from './types'\n\n/** @internal Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under. */\nexport const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT'\n\n/** @internal Builds the injection key `useQueryClient`/`VueQueryPlugin` use for a given `queryClientKey`. */\nexport function getClientKey(key?: string) {\n const suffix = key ? `:${key}` : ''\n return `${VUE_QUERY_CLIENT}${suffix}`\n}\n\n/** @internal Copies each property from `update` onto `state`, in place, for every key already on `state`. */\nexport function updateState(\n state: Record<string, any>,\n update: Record<string, any>,\n): void {\n Object.keys(state).forEach((key) => {\n state[key] = update[key]\n })\n}\n\n// Helper function for cloning deep objects where\n// the level and key is provided to the callback function.\nfunction _cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n currentKey: string = '',\n currentLevel: number = 0,\n): T {\n if (customize) {\n const result = customize(value, currentKey, currentLevel)\n if (result === undefined && isRef(value)) {\n return result as T\n }\n if (result !== undefined) {\n return result\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((val, index) =>\n _cloneDeep(val, customize, String(index), currentLevel + 1),\n ) as unknown as T\n }\n\n if (typeof value === 'object' && isPlainObject(value)) {\n const entries = Object.entries(value).map(([key, val]) => [\n key,\n _cloneDeep(val, customize, key, currentLevel + 1),\n ])\n return Object.fromEntries(entries)\n }\n\n return value as T\n}\n\n/**\n * @internal Deep-clones `value`, recursing into arrays and plain objects. `customize`, if provided, can\n * intercept any node (by key and nesting level) and substitute its own return value instead of recursing\n * further.\n */\nexport function cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n): T {\n return _cloneDeep(value, customize)\n}\n\n/**\n * @internal Deep-clones `value` like {@link cloneDeep}, additionally unwrapping any `ref`s it encounters (and,\n * if `unrefGetters` is `true`, calling any functions it encounters and unwrapping their result too). Always\n * resolves `queryKey` this way, regardless of `unrefGetters` — this is what lets a `queryKey` containing `ref`s\n * be passed straight through to `@tanstack/query-core`.\n */\nexport function cloneDeepUnref<T>(\n obj: MaybeRefDeep<T>,\n unrefGetters = false,\n): T {\n return cloneDeep(obj, (val, key, level) => {\n // Check if we're at the top level and the key is 'queryKey'\n //\n // If so, take the recursive descent where we resolve\n // getters to values as well as refs.\n if (level === 1 && key === 'queryKey') {\n return cloneDeepUnref(val, true)\n }\n\n // Resolve getters to values if specified.\n if (unrefGetters && isFunction(val)) {\n // Cast due to older TS versions not allowing calling\n // on certain intersection types.\n return cloneDeepUnref((val as Function)(), unrefGetters)\n }\n\n // Unref refs and continue to recurse into the value.\n if (isRef(val)) {\n return cloneDeepUnref(unref(val), unrefGetters)\n }\n\n return undefined\n })\n}\n\n// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\nfunction isPlainObject(value: unknown): value is Object {\n if (Object.prototype.toString.call(value) !== '[object Object]') {\n return false\n }\n\n const prototype = Object.getPrototypeOf(value)\n return prototype === null || prototype === Object.prototype\n}\n\nfunction isFunction(value: unknown): value is Function {\n return typeof value === 'function'\n}\n\n/** @internal Resolves `source` to a plain value — calls it if it's a function, otherwise deep-unwraps it. */\nexport function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T {\n return isFunction(source) ? source() : cloneDeepUnref(source)\n}\n"],"mappings":";;;;AAIA,MAAa,mBAAmB;;AAGhC,SAAgB,aAAa,KAAc;CACzC,MAAM,SAAS,MAAM,IAAI,QAAQ;CACjC,OAAO,GAAG,mBAAmB;AAC/B;;AAGA,SAAgB,YACd,OACA,QACM;CACN,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,QAAQ;EAClC,MAAM,OAAO,OAAO;CACtB,CAAC;AACH;AAIA,SAAS,WACP,OACA,WAKA,aAAqB,IACrB,eAAuB,GACpB;CACH,IAAI,WAAW;EACb,MAAM,SAAS,UAAU,OAAO,YAAY,YAAY;EACxD,IAAI,WAAW,KAAA,MAAA,GAAaA,SAAAA,MAAAA,CAAM,KAAK,GACrC,OAAO;EAET,IAAI,WAAW,KAAA,GACb,OAAO;CAEX;CAEA,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,KAAK,KAAK,UACrB,WAAW,KAAK,WAAW,OAAO,KAAK,GAAG,eAAe,CAAC,CAC5D;CAGF,IAAI,OAAO,UAAU,YAAY,cAAc,KAAK,GAAG;EACrD,MAAM,UAAU,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,SAAS,CACxD,KACA,WAAW,KAAK,WAAW,KAAK,eAAe,CAAC,CAClD,CAAC;EACD,OAAO,OAAO,YAAY,OAAO;CACnC;CAEA,OAAO;AACT;;;;;;AAOA,SAAgB,UACd,OACA,WAKG;CACH,OAAO,WAAW,OAAO,SAAS;AACpC;;;;;;;AAQA,SAAgB,eACd,KACA,eAAe,OACZ;CACH,OAAO,UAAU,MAAM,KAAK,KAAK,UAAU;EAKzC,IAAI,UAAU,KAAK,QAAQ,YACzB,OAAO,eAAe,KAAK,IAAI;EAIjC,IAAI,gBAAgB,WAAW,GAAG,GAGhC,OAAO,eAAgB,IAAiB,GAAG,YAAY;EAIzD,KAAA,GAAIA,SAAAA,MAAAA,CAAM,GAAG,GACX,OAAO,gBAAA,GAAeC,SAAAA,MAAAA,CAAM,GAAG,GAAG,YAAY;CAIlD,CAAC;AACH;AAGA,SAAS,cAAc,OAAiC;CACtD,IAAI,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM,mBAC5C,OAAO;CAGT,MAAM,YAAY,OAAO,eAAe,KAAK;CAC7C,OAAO,cAAc,QAAQ,cAAc,OAAO;AACpD;AAEA,SAAS,WAAW,OAAmC;CACrD,OAAO,OAAO,UAAU;AAC1B;;AAGA,SAAgB,YAAe,QAAwC;CACrE,OAAO,WAAW,MAAM,IAAI,OAAO,IAAI,eAAe,MAAM;AAC9D"}
@@ -1,10 +1,25 @@
1
- import { o as MaybeRefDeep } from "./types-BzZi3_rS.cjs";
1
+ import { o as MaybeRefDeep } from "./types-JpJB72CS.cjs";
2
2
  //#region src/utils.d.ts
3
+ /** @internal Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under. */
3
4
  declare const VUE_QUERY_CLIENT = "VUE_QUERY_CLIENT";
5
+ /** @internal Builds the injection key `useQueryClient`/`VueQueryPlugin` use for a given `queryClientKey`. */
4
6
  declare function getClientKey(key?: string): string;
7
+ /** @internal Copies each property from `update` onto `state`, in place, for every key already on `state`. */
5
8
  declare function updateState(state: Record<string, any>, update: Record<string, any>): void;
9
+ /**
10
+ * @internal Deep-clones `value`, recursing into arrays and plain objects. `customize`, if provided, can
11
+ * intercept any node (by key and nesting level) and substitute its own return value instead of recursing
12
+ * further.
13
+ */
6
14
  declare function cloneDeep<T>(value: MaybeRefDeep<T>, customize?: (val: MaybeRefDeep<T>, key: string, level: number) => T | undefined): T;
15
+ /**
16
+ * @internal Deep-clones `value` like {@link cloneDeep}, additionally unwrapping any `ref`s it encounters (and,
17
+ * if `unrefGetters` is `true`, calling any functions it encounters and unwrapping their result too). Always
18
+ * resolves `queryKey` this way, regardless of `unrefGetters` — this is what lets a `queryKey` containing `ref`s
19
+ * be passed straight through to `@tanstack/query-core`.
20
+ */
7
21
  declare function cloneDeepUnref<T>(obj: MaybeRefDeep<T>, unrefGetters?: boolean): T;
22
+ /** @internal Resolves `source` to a plain value — calls it if it's a function, otherwise deep-unwraps it. */
8
23
  declare function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T;
9
24
  //#endregion
10
25
  export { VUE_QUERY_CLIENT, cloneDeep, cloneDeepUnref, getClientKey, toValueDeep, updateState };
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.cts","names":[],"sources":["../../src/utils.ts"],"mappings":";;cAGa;iBAEG,aAAa;iBAKb,YACd,OAAO,qBACP,QAAQ;iBA8CM,UAAU,GACxB,OAAO,aAAa,IACpB,aACE,KAAK,aAAa,IAClB,aACA,kBACG,gBACJ;iBAIa,eAAe,GAC7B,KAAK,aAAa,IAClB,yBACC;iBAwCa,YAAY,GAAG,eAAe,KAAK,aAAa,KAAK"}
1
+ {"version":3,"file":"utils.d.cts","names":[],"sources":["../../src/utils.ts"],"mappings":";;;cAIa;;iBAGG,aAAa;;iBAMb,YACd,OAAO,qBACP,QAAQ;;;;;;iBAmDM,UAAU,GACxB,OAAO,aAAa,IACpB,aACE,KAAK,aAAa,IAClB,aACA,kBACG,gBACJ;;;;;;;iBAUa,eAAe,GAC7B,KAAK,aAAa,IAClB,yBACC;;iBAyCa,YAAY,GAAG,eAAe,KAAK,aAAa,KAAK"}
@@ -1,10 +1,25 @@
1
- import { o as MaybeRefDeep } from "./types-BzZi3_rS.js";
1
+ import { o as MaybeRefDeep } from "./types-JpJB72CS.js";
2
2
  //#region src/utils.d.ts
3
+ /** @internal Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under. */
3
4
  declare const VUE_QUERY_CLIENT = "VUE_QUERY_CLIENT";
5
+ /** @internal Builds the injection key `useQueryClient`/`VueQueryPlugin` use for a given `queryClientKey`. */
4
6
  declare function getClientKey(key?: string): string;
7
+ /** @internal Copies each property from `update` onto `state`, in place, for every key already on `state`. */
5
8
  declare function updateState(state: Record<string, any>, update: Record<string, any>): void;
9
+ /**
10
+ * @internal Deep-clones `value`, recursing into arrays and plain objects. `customize`, if provided, can
11
+ * intercept any node (by key and nesting level) and substitute its own return value instead of recursing
12
+ * further.
13
+ */
6
14
  declare function cloneDeep<T>(value: MaybeRefDeep<T>, customize?: (val: MaybeRefDeep<T>, key: string, level: number) => T | undefined): T;
15
+ /**
16
+ * @internal Deep-clones `value` like {@link cloneDeep}, additionally unwrapping any `ref`s it encounters (and,
17
+ * if `unrefGetters` is `true`, calling any functions it encounters and unwrapping their result too). Always
18
+ * resolves `queryKey` this way, regardless of `unrefGetters` — this is what lets a `queryKey` containing `ref`s
19
+ * be passed straight through to `@tanstack/query-core`.
20
+ */
7
21
  declare function cloneDeepUnref<T>(obj: MaybeRefDeep<T>, unrefGetters?: boolean): T;
22
+ /** @internal Resolves `source` to a plain value — calls it if it's a function, otherwise deep-unwraps it. */
8
23
  declare function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T;
9
24
  //#endregion
10
25
  export { VUE_QUERY_CLIENT, cloneDeep, cloneDeepUnref, getClientKey, toValueDeep, updateState };
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","names":[],"sources":["../../src/utils.ts"],"mappings":";;cAGa;iBAEG,aAAa;iBAKb,YACd,OAAO,qBACP,QAAQ;iBA8CM,UAAU,GACxB,OAAO,aAAa,IACpB,aACE,KAAK,aAAa,IAClB,aACA,kBACG,gBACJ;iBAIa,eAAe,GAC7B,KAAK,aAAa,IAClB,yBACC;iBAwCa,YAAY,GAAG,eAAe,KAAK,aAAa,KAAK"}
1
+ {"version":3,"file":"utils.d.ts","names":[],"sources":["../../src/utils.ts"],"mappings":";;;cAIa;;iBAGG,aAAa;;iBAMb,YACd,OAAO,qBACP,QAAQ;;;;;;iBAmDM,UAAU,GACxB,OAAO,aAAa,IACpB,aACE,KAAK,aAAa,IAClB,aACA,kBACG,gBACJ;;;;;;;iBAUa,eAAe,GAC7B,KAAK,aAAa,IAClB,yBACC;;iBAyCa,YAAY,GAAG,eAAe,KAAK,aAAa,KAAK"}
@@ -1,10 +1,13 @@
1
1
  import { isRef, unref } from "vue-demi";
2
2
  //#region src/utils.ts
3
+ /** @internal Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under. */
3
4
  const VUE_QUERY_CLIENT = "VUE_QUERY_CLIENT";
5
+ /** @internal Builds the injection key `useQueryClient`/`VueQueryPlugin` use for a given `queryClientKey`. */
4
6
  function getClientKey(key) {
5
7
  const suffix = key ? `:${key}` : "";
6
8
  return `${VUE_QUERY_CLIENT}${suffix}`;
7
9
  }
10
+ /** @internal Copies each property from `update` onto `state`, in place, for every key already on `state`. */
8
11
  function updateState(state, update) {
9
12
  Object.keys(state).forEach((key) => {
10
13
  state[key] = update[key];
@@ -23,9 +26,20 @@ function _cloneDeep(value, customize, currentKey = "", currentLevel = 0) {
23
26
  }
24
27
  return value;
25
28
  }
29
+ /**
30
+ * @internal Deep-clones `value`, recursing into arrays and plain objects. `customize`, if provided, can
31
+ * intercept any node (by key and nesting level) and substitute its own return value instead of recursing
32
+ * further.
33
+ */
26
34
  function cloneDeep(value, customize) {
27
35
  return _cloneDeep(value, customize);
28
36
  }
37
+ /**
38
+ * @internal Deep-clones `value` like {@link cloneDeep}, additionally unwrapping any `ref`s it encounters (and,
39
+ * if `unrefGetters` is `true`, calling any functions it encounters and unwrapping their result too). Always
40
+ * resolves `queryKey` this way, regardless of `unrefGetters` — this is what lets a `queryKey` containing `ref`s
41
+ * be passed straight through to `@tanstack/query-core`.
42
+ */
29
43
  function cloneDeepUnref(obj, unrefGetters = false) {
30
44
  return cloneDeep(obj, (val, key, level) => {
31
45
  if (level === 1 && key === "queryKey") return cloneDeepUnref(val, true);
@@ -41,6 +55,7 @@ function isPlainObject(value) {
41
55
  function isFunction(value) {
42
56
  return typeof value === "function";
43
57
  }
58
+ /** @internal Resolves `source` to a plain value — calls it if it's a function, otherwise deep-unwraps it. */
44
59
  function toValueDeep(source) {
45
60
  return isFunction(source) ? source() : cloneDeepUnref(source);
46
61
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["import { isRef, unref } from 'vue-demi'\nimport type { MaybeRefDeep } from './types'\n\nexport const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT'\n\nexport function getClientKey(key?: string) {\n const suffix = key ? `:${key}` : ''\n return `${VUE_QUERY_CLIENT}${suffix}`\n}\n\nexport function updateState(\n state: Record<string, any>,\n update: Record<string, any>,\n): void {\n Object.keys(state).forEach((key) => {\n state[key] = update[key]\n })\n}\n\n// Helper function for cloning deep objects where\n// the level and key is provided to the callback function.\nfunction _cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n currentKey: string = '',\n currentLevel: number = 0,\n): T {\n if (customize) {\n const result = customize(value, currentKey, currentLevel)\n if (result === undefined && isRef(value)) {\n return result as T\n }\n if (result !== undefined) {\n return result\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((val, index) =>\n _cloneDeep(val, customize, String(index), currentLevel + 1),\n ) as unknown as T\n }\n\n if (typeof value === 'object' && isPlainObject(value)) {\n const entries = Object.entries(value).map(([key, val]) => [\n key,\n _cloneDeep(val, customize, key, currentLevel + 1),\n ])\n return Object.fromEntries(entries)\n }\n\n return value as T\n}\n\nexport function cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n): T {\n return _cloneDeep(value, customize)\n}\n\nexport function cloneDeepUnref<T>(\n obj: MaybeRefDeep<T>,\n unrefGetters = false,\n): T {\n return cloneDeep(obj, (val, key, level) => {\n // Check if we're at the top level and the key is 'queryKey'\n //\n // If so, take the recursive descent where we resolve\n // getters to values as well as refs.\n if (level === 1 && key === 'queryKey') {\n return cloneDeepUnref(val, true)\n }\n\n // Resolve getters to values if specified.\n if (unrefGetters && isFunction(val)) {\n // Cast due to older TS versions not allowing calling\n // on certain intersection types.\n return cloneDeepUnref((val as Function)(), unrefGetters)\n }\n\n // Unref refs and continue to recurse into the value.\n if (isRef(val)) {\n return cloneDeepUnref(unref(val), unrefGetters)\n }\n\n return undefined\n })\n}\n\n// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\nfunction isPlainObject(value: unknown): value is Object {\n if (Object.prototype.toString.call(value) !== '[object Object]') {\n return false\n }\n\n const prototype = Object.getPrototypeOf(value)\n return prototype === null || prototype === Object.prototype\n}\n\nfunction isFunction(value: unknown): value is Function {\n return typeof value === 'function'\n}\n\nexport function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T {\n return isFunction(source) ? source() : cloneDeepUnref(source)\n}\n"],"mappings":";;AAGA,MAAa,mBAAmB;AAEhC,SAAgB,aAAa,KAAc;CACzC,MAAM,SAAS,MAAM,IAAI,QAAQ;CACjC,OAAO,GAAG,mBAAmB;AAC/B;AAEA,SAAgB,YACd,OACA,QACM;CACN,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,QAAQ;EAClC,MAAM,OAAO,OAAO;CACtB,CAAC;AACH;AAIA,SAAS,WACP,OACA,WAKA,aAAqB,IACrB,eAAuB,GACpB;CACH,IAAI,WAAW;EACb,MAAM,SAAS,UAAU,OAAO,YAAY,YAAY;EACxD,IAAI,WAAW,KAAA,KAAa,MAAM,KAAK,GACrC,OAAO;EAET,IAAI,WAAW,KAAA,GACb,OAAO;CAEX;CAEA,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,KAAK,KAAK,UACrB,WAAW,KAAK,WAAW,OAAO,KAAK,GAAG,eAAe,CAAC,CAC5D;CAGF,IAAI,OAAO,UAAU,YAAY,cAAc,KAAK,GAAG;EACrD,MAAM,UAAU,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,SAAS,CACxD,KACA,WAAW,KAAK,WAAW,KAAK,eAAe,CAAC,CAClD,CAAC;EACD,OAAO,OAAO,YAAY,OAAO;CACnC;CAEA,OAAO;AACT;AAEA,SAAgB,UACd,OACA,WAKG;CACH,OAAO,WAAW,OAAO,SAAS;AACpC;AAEA,SAAgB,eACd,KACA,eAAe,OACZ;CACH,OAAO,UAAU,MAAM,KAAK,KAAK,UAAU;EAKzC,IAAI,UAAU,KAAK,QAAQ,YACzB,OAAO,eAAe,KAAK,IAAI;EAIjC,IAAI,gBAAgB,WAAW,GAAG,GAGhC,OAAO,eAAgB,IAAiB,GAAG,YAAY;EAIzD,IAAI,MAAM,GAAG,GACX,OAAO,eAAe,MAAM,GAAG,GAAG,YAAY;CAIlD,CAAC;AACH;AAGA,SAAS,cAAc,OAAiC;CACtD,IAAI,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM,mBAC5C,OAAO;CAGT,MAAM,YAAY,OAAO,eAAe,KAAK;CAC7C,OAAO,cAAc,QAAQ,cAAc,OAAO;AACpD;AAEA,SAAS,WAAW,OAAmC;CACrD,OAAO,OAAO,UAAU;AAC1B;AAEA,SAAgB,YAAe,QAAwC;CACrE,OAAO,WAAW,MAAM,IAAI,OAAO,IAAI,eAAe,MAAM;AAC9D"}
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["import { isRef, unref } from 'vue-demi'\nimport type { MaybeRefDeep } from './types'\n\n/** @internal Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under. */\nexport const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT'\n\n/** @internal Builds the injection key `useQueryClient`/`VueQueryPlugin` use for a given `queryClientKey`. */\nexport function getClientKey(key?: string) {\n const suffix = key ? `:${key}` : ''\n return `${VUE_QUERY_CLIENT}${suffix}`\n}\n\n/** @internal Copies each property from `update` onto `state`, in place, for every key already on `state`. */\nexport function updateState(\n state: Record<string, any>,\n update: Record<string, any>,\n): void {\n Object.keys(state).forEach((key) => {\n state[key] = update[key]\n })\n}\n\n// Helper function for cloning deep objects where\n// the level and key is provided to the callback function.\nfunction _cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n currentKey: string = '',\n currentLevel: number = 0,\n): T {\n if (customize) {\n const result = customize(value, currentKey, currentLevel)\n if (result === undefined && isRef(value)) {\n return result as T\n }\n if (result !== undefined) {\n return result\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((val, index) =>\n _cloneDeep(val, customize, String(index), currentLevel + 1),\n ) as unknown as T\n }\n\n if (typeof value === 'object' && isPlainObject(value)) {\n const entries = Object.entries(value).map(([key, val]) => [\n key,\n _cloneDeep(val, customize, key, currentLevel + 1),\n ])\n return Object.fromEntries(entries)\n }\n\n return value as T\n}\n\n/**\n * @internal Deep-clones `value`, recursing into arrays and plain objects. `customize`, if provided, can\n * intercept any node (by key and nesting level) and substitute its own return value instead of recursing\n * further.\n */\nexport function cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n): T {\n return _cloneDeep(value, customize)\n}\n\n/**\n * @internal Deep-clones `value` like {@link cloneDeep}, additionally unwrapping any `ref`s it encounters (and,\n * if `unrefGetters` is `true`, calling any functions it encounters and unwrapping their result too). Always\n * resolves `queryKey` this way, regardless of `unrefGetters` — this is what lets a `queryKey` containing `ref`s\n * be passed straight through to `@tanstack/query-core`.\n */\nexport function cloneDeepUnref<T>(\n obj: MaybeRefDeep<T>,\n unrefGetters = false,\n): T {\n return cloneDeep(obj, (val, key, level) => {\n // Check if we're at the top level and the key is 'queryKey'\n //\n // If so, take the recursive descent where we resolve\n // getters to values as well as refs.\n if (level === 1 && key === 'queryKey') {\n return cloneDeepUnref(val, true)\n }\n\n // Resolve getters to values if specified.\n if (unrefGetters && isFunction(val)) {\n // Cast due to older TS versions not allowing calling\n // on certain intersection types.\n return cloneDeepUnref((val as Function)(), unrefGetters)\n }\n\n // Unref refs and continue to recurse into the value.\n if (isRef(val)) {\n return cloneDeepUnref(unref(val), unrefGetters)\n }\n\n return undefined\n })\n}\n\n// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\nfunction isPlainObject(value: unknown): value is Object {\n if (Object.prototype.toString.call(value) !== '[object Object]') {\n return false\n }\n\n const prototype = Object.getPrototypeOf(value)\n return prototype === null || prototype === Object.prototype\n}\n\nfunction isFunction(value: unknown): value is Function {\n return typeof value === 'function'\n}\n\n/** @internal Resolves `source` to a plain value — calls it if it's a function, otherwise deep-unwraps it. */\nexport function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T {\n return isFunction(source) ? source() : cloneDeepUnref(source)\n}\n"],"mappings":";;;AAIA,MAAa,mBAAmB;;AAGhC,SAAgB,aAAa,KAAc;CACzC,MAAM,SAAS,MAAM,IAAI,QAAQ;CACjC,OAAO,GAAG,mBAAmB;AAC/B;;AAGA,SAAgB,YACd,OACA,QACM;CACN,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,QAAQ;EAClC,MAAM,OAAO,OAAO;CACtB,CAAC;AACH;AAIA,SAAS,WACP,OACA,WAKA,aAAqB,IACrB,eAAuB,GACpB;CACH,IAAI,WAAW;EACb,MAAM,SAAS,UAAU,OAAO,YAAY,YAAY;EACxD,IAAI,WAAW,KAAA,KAAa,MAAM,KAAK,GACrC,OAAO;EAET,IAAI,WAAW,KAAA,GACb,OAAO;CAEX;CAEA,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,KAAK,KAAK,UACrB,WAAW,KAAK,WAAW,OAAO,KAAK,GAAG,eAAe,CAAC,CAC5D;CAGF,IAAI,OAAO,UAAU,YAAY,cAAc,KAAK,GAAG;EACrD,MAAM,UAAU,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,SAAS,CACxD,KACA,WAAW,KAAK,WAAW,KAAK,eAAe,CAAC,CAClD,CAAC;EACD,OAAO,OAAO,YAAY,OAAO;CACnC;CAEA,OAAO;AACT;;;;;;AAOA,SAAgB,UACd,OACA,WAKG;CACH,OAAO,WAAW,OAAO,SAAS;AACpC;;;;;;;AAQA,SAAgB,eACd,KACA,eAAe,OACZ;CACH,OAAO,UAAU,MAAM,KAAK,KAAK,UAAU;EAKzC,IAAI,UAAU,KAAK,QAAQ,YACzB,OAAO,eAAe,KAAK,IAAI;EAIjC,IAAI,gBAAgB,WAAW,GAAG,GAGhC,OAAO,eAAgB,IAAiB,GAAG,YAAY;EAIzD,IAAI,MAAM,GAAG,GACX,OAAO,eAAe,MAAM,GAAG,GAAG,YAAY;CAIlD,CAAC;AACH;AAGA,SAAS,cAAc,OAAiC;CACtD,IAAI,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM,mBAC5C,OAAO;CAGT,MAAM,YAAY,OAAO,eAAe,KAAK;CAC7C,OAAO,cAAc,QAAQ,cAAc,OAAO;AACpD;AAEA,SAAS,WAAW,OAAmC;CACrD,OAAO,OAAO,UAAU;AAC1B;;AAGA,SAAgB,YAAe,QAAwC;CACrE,OAAO,WAAW,MAAM,IAAI,OAAO,IAAI,eAAe,MAAM;AAC9D"}
@@ -5,6 +5,40 @@ const require_devtools_devtools = require("./devtools/devtools.cjs");
5
5
  let _tanstack_query_core = require("@tanstack/query-core");
6
6
  let vue_demi = require("vue-demi");
7
7
  //#region src/vueQueryPlugin.ts
8
+ /**
9
+ * Installs a `QueryClient` on the Vue app, making it available to every descendant component through
10
+ * `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin
11
+ * instead of a wrapping component.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { createApp } from 'vue'
16
+ * import { VueQueryPlugin } from '@tanstack/vue-query'
17
+ *
18
+ * const app = createApp(App)
19
+ * app.use(VueQueryPlugin)
20
+ * ```
21
+ *
22
+ * @example
23
+ * Pass a `queryClient` you constructed yourself — useful for SSR, where you need a fresh `QueryClient` per
24
+ * request, or when the same instance also needs to be used outside of Vue components:
25
+ * ```ts
26
+ * import { QueryClient, VueQueryPlugin } from '@tanstack/vue-query'
27
+ *
28
+ * const queryClient = new QueryClient()
29
+ * app.use(VueQueryPlugin, { queryClient })
30
+ * ```
31
+ *
32
+ * @example
33
+ * Or pass `queryClientConfig` to let the plugin construct the `QueryClient` for you, with your own defaults:
34
+ * ```ts
35
+ * app.use(VueQueryPlugin, {
36
+ * queryClientConfig: {
37
+ * defaultOptions: { queries: { staleTime: 5 * 1000 } },
38
+ * },
39
+ * })
40
+ * ```
41
+ */
8
42
  const VueQueryPlugin = { install: (app, options = {}) => {
9
43
  const clientKey = require_utils.getClientKey(options.queryClientKey);
10
44
  let client;
@@ -1 +1 @@
1
- {"version":3,"file":"vueQueryPlugin.cjs","names":["getClientKey","QueryClient","environmentManager","isVue2"],"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { environmentManager } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { QueryClientConfig } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n enableDevtoolsV6Plugin?: boolean\n queryClientKey?: string\n clientPersister?: ClientPersister\n clientPersisterOnSuccess?: (client: QueryClient) => void\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: QueryClientConfig\n}\n\ninterface ClientOptions extends CommonOptions {\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!environmentManager.isServer()) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n if (client.isRestoring) {\n client.isRestoring.value = true\n }\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n if (client.isRestoring) {\n client.isRestoring.value = false\n }\n options.clientPersisterOnSuccess?.(client)\n })\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root && options.enableDevtoolsV6Plugin) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n if (options.enableDevtoolsV6Plugin) {\n setupDevtools(app, client)\n }\n }\n }\n },\n}\n"],"mappings":";;;;;;;AA2BA,MAAa,iBAAiB,EAC5B,UAAU,KAAU,UAAiC,CAAC,MAAM;CAC1D,MAAM,YAAYA,cAAAA,aAAa,QAAQ,cAAc;CACrD,IAAI;CAEJ,IAAI,iBAAiB,WAAW,QAAQ,aACtC,SAAS,QAAQ;MACZ;EACL,MAAM,eACJ,uBAAuB,UAAU,QAAQ,oBAAoB,KAAA;EAC/D,SAAS,IAAIC,oBAAAA,YAAY,YAAY;CACvC;CAEA,IAAI,CAACC,qBAAAA,mBAAmB,SAAS,GAC/B,OAAO,MAAM;CAGf,IAAI,yBAAyB,CAE7B;CAEA,IAAI,QAAQ,iBAAiB;EAC3B,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;EAE7B,MAAM,CAAC,SAAS,WAAW,QAAQ,gBAAgB,MAAM;EACzD,mBAAmB;EACnB,QAAQ,WAAW;GACjB,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;GAE7B,QAAQ,2BAA2B,MAAM;EAC3C,CAAC;CACH;CAEA,MAAM,gBAAgB;EACpB,OAAO,QAAQ;EACf,iBAAiB;CACnB;CAEA,IAAI,IAAI,WACN,IAAI,UAAU,OAAO;MAChB;EACL,MAAM,kBAAkB,IAAI;EAC5B,IAAI,UAAU,SAAS,kBAAkB;GACvC,QAAQ;GACR,gBAAgB;EAClB;CACF;CAEA,IAAIC,SAAAA,QACF,IAAI,MAAM,EACR,eAAe;EAEb,IAAI,CAAC,KAAK,WAAW;GACnB,MAAM,eAAe,CAAC;GACtB,OAAO,eAAe,MAAM,aAAa;IACvC,WAAW;IACX,MAAM,MAAM,OAAO,OAAO,cAAc,CAAC;GAC3C,CAAC;EACH;EAEA,KAAK,UAAU,aAAa;EAE5B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,SAAS,KAAK,SAAS,QAAQ,wBACjC,0BAAA,cAAc,MAAM,MAAM;EAAA;CAGhC,EACF,CAAC;MACI;EACL,IAAI,QAAQ,WAAW,MAAM;EAE7B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,QAAQ,wBACV,0BAAA,cAAc,KAAK,MAAM;EAAA;CAG/B;AACF,EACF"}
1
+ {"version":3,"file":"vueQueryPlugin.cjs","names":["getClientKey","QueryClient","environmentManager","isVue2"],"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { environmentManager } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { QueryClientConfig } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n /** Enables the legacy Vue Devtools v6 plugin panel. Prefer `@tanstack/vue-query-devtools` for Vue 3 apps. */\n enableDevtoolsV6Plugin?: boolean\n /**\n * Distinguishes multiple `QueryClient`s provided in the same app — pass the same key to `useQueryClient` to\n * pick this one. Only needed when installing more than one client.\n */\n queryClientKey?: string\n /**\n * Restores a persisted cache before the app mounts. While it runs, `queryClient.isRestoring` is `true`, which\n * suppresses fetches — see `usePersistQueryClient` in `@tanstack/query-persist-client-core` for building one.\n */\n clientPersister?: ClientPersister\n /** Called once `clientPersister`'s returned promise resolves and the cache has finished restoring. */\n clientPersisterOnSuccess?: (client: QueryClient) => void\n}\n\ninterface ConfigOptions extends CommonOptions {\n /** Options for the `QueryClient` the plugin constructs. Ignored if `queryClient` is also set. */\n queryClientConfig?: QueryClientConfig\n}\n\ninterface ClientOptions extends CommonOptions {\n /** Use your own `QueryClient` instance instead of having the plugin construct one from `queryClientConfig`. */\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\n/**\n * Installs a `QueryClient` on the Vue app, making it available to every descendant component through\n * `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin\n * instead of a wrapping component.\n *\n * @example\n * ```ts\n * import { createApp } from 'vue'\n * import { VueQueryPlugin } from '@tanstack/vue-query'\n *\n * const app = createApp(App)\n * app.use(VueQueryPlugin)\n * ```\n *\n * @example\n * Pass a `queryClient` you constructed yourself — useful for SSR, where you need a fresh `QueryClient` per\n * request, or when the same instance also needs to be used outside of Vue components:\n * ```ts\n * import { QueryClient, VueQueryPlugin } from '@tanstack/vue-query'\n *\n * const queryClient = new QueryClient()\n * app.use(VueQueryPlugin, { queryClient })\n * ```\n *\n * @example\n * Or pass `queryClientConfig` to let the plugin construct the `QueryClient` for you, with your own defaults:\n * ```ts\n * app.use(VueQueryPlugin, {\n * queryClientConfig: {\n * defaultOptions: { queries: { staleTime: 5 * 1000 } },\n * },\n * })\n * ```\n */\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!environmentManager.isServer()) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n if (client.isRestoring) {\n client.isRestoring.value = true\n }\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n if (client.isRestoring) {\n client.isRestoring.value = false\n }\n options.clientPersisterOnSuccess?.(client)\n })\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root && options.enableDevtoolsV6Plugin) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n if (options.enableDevtoolsV6Plugin) {\n setupDevtools(app, client)\n }\n }\n }\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,MAAa,iBAAiB,EAC5B,UAAU,KAAU,UAAiC,CAAC,MAAM;CAC1D,MAAM,YAAYA,cAAAA,aAAa,QAAQ,cAAc;CACrD,IAAI;CAEJ,IAAI,iBAAiB,WAAW,QAAQ,aACtC,SAAS,QAAQ;MACZ;EACL,MAAM,eACJ,uBAAuB,UAAU,QAAQ,oBAAoB,KAAA;EAC/D,SAAS,IAAIC,oBAAAA,YAAY,YAAY;CACvC;CAEA,IAAI,CAACC,qBAAAA,mBAAmB,SAAS,GAC/B,OAAO,MAAM;CAGf,IAAI,yBAAyB,CAE7B;CAEA,IAAI,QAAQ,iBAAiB;EAC3B,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;EAE7B,MAAM,CAAC,SAAS,WAAW,QAAQ,gBAAgB,MAAM;EACzD,mBAAmB;EACnB,QAAQ,WAAW;GACjB,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;GAE7B,QAAQ,2BAA2B,MAAM;EAC3C,CAAC;CACH;CAEA,MAAM,gBAAgB;EACpB,OAAO,QAAQ;EACf,iBAAiB;CACnB;CAEA,IAAI,IAAI,WACN,IAAI,UAAU,OAAO;MAChB;EACL,MAAM,kBAAkB,IAAI;EAC5B,IAAI,UAAU,SAAS,kBAAkB;GACvC,QAAQ;GACR,gBAAgB;EAClB;CACF;CAEA,IAAIC,SAAAA,QACF,IAAI,MAAM,EACR,eAAe;EAEb,IAAI,CAAC,KAAK,WAAW;GACnB,MAAM,eAAe,CAAC;GACtB,OAAO,eAAe,MAAM,aAAa;IACvC,WAAW;IACX,MAAM,MAAM,OAAO,OAAO,cAAc,CAAC;GAC3C,CAAC;EACH;EAEA,KAAK,UAAU,aAAa;EAE5B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,SAAS,KAAK,SAAS,QAAQ,wBACjC,0BAAA,cAAc,MAAM,MAAM;EAAA;CAGhC,EACF,CAAC;MACI;EACL,IAAI,QAAQ,WAAW,MAAM;EAE7B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,QAAQ,wBACV,0BAAA,cAAc,KAAK,MAAM;EAAA;CAG/B;AACF,EACF"}
@@ -1,20 +1,66 @@
1
- import { t as QueryClient } from "./queryClient-C07d0chJ.cjs";
2
- import { u as QueryClientConfig } from "./types-BzZi3_rS.cjs";
1
+ import { u as QueryClientConfig } from "./types-JpJB72CS.cjs";
2
+ import { t as QueryClient } from "./queryClient-CZeNAt68.cjs";
3
3
  //#region src/vueQueryPlugin.d.ts
4
4
  type ClientPersister = (client: QueryClient) => [() => void, Promise<void>];
5
5
  interface CommonOptions {
6
+ /** Enables the legacy Vue Devtools v6 plugin panel. Prefer `@tanstack/vue-query-devtools` for Vue 3 apps. */
6
7
  enableDevtoolsV6Plugin?: boolean;
8
+ /**
9
+ * Distinguishes multiple `QueryClient`s provided in the same app — pass the same key to `useQueryClient` to
10
+ * pick this one. Only needed when installing more than one client.
11
+ */
7
12
  queryClientKey?: string;
13
+ /**
14
+ * Restores a persisted cache before the app mounts. While it runs, `queryClient.isRestoring` is `true`, which
15
+ * suppresses fetches — see `usePersistQueryClient` in `@tanstack/query-persist-client-core` for building one.
16
+ */
8
17
  clientPersister?: ClientPersister;
18
+ /** Called once `clientPersister`'s returned promise resolves and the cache has finished restoring. */
9
19
  clientPersisterOnSuccess?: (client: QueryClient) => void;
10
20
  }
11
21
  interface ConfigOptions extends CommonOptions {
22
+ /** Options for the `QueryClient` the plugin constructs. Ignored if `queryClient` is also set. */
12
23
  queryClientConfig?: QueryClientConfig;
13
24
  }
14
25
  interface ClientOptions extends CommonOptions {
26
+ /** Use your own `QueryClient` instance instead of having the plugin construct one from `queryClientConfig`. */
15
27
  queryClient?: QueryClient;
16
28
  }
17
29
  type VueQueryPluginOptions = ConfigOptions | ClientOptions;
30
+ /**
31
+ * Installs a `QueryClient` on the Vue app, making it available to every descendant component through
32
+ * `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin
33
+ * instead of a wrapping component.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * import { createApp } from 'vue'
38
+ * import { VueQueryPlugin } from '@tanstack/vue-query'
39
+ *
40
+ * const app = createApp(App)
41
+ * app.use(VueQueryPlugin)
42
+ * ```
43
+ *
44
+ * @example
45
+ * Pass a `queryClient` you constructed yourself — useful for SSR, where you need a fresh `QueryClient` per
46
+ * request, or when the same instance also needs to be used outside of Vue components:
47
+ * ```ts
48
+ * import { QueryClient, VueQueryPlugin } from '@tanstack/vue-query'
49
+ *
50
+ * const queryClient = new QueryClient()
51
+ * app.use(VueQueryPlugin, { queryClient })
52
+ * ```
53
+ *
54
+ * @example
55
+ * Or pass `queryClientConfig` to let the plugin construct the `QueryClient` for you, with your own defaults:
56
+ * ```ts
57
+ * app.use(VueQueryPlugin, {
58
+ * queryClientConfig: {
59
+ * defaultOptions: { queries: { staleTime: 5 * 1000 } },
60
+ * },
61
+ * })
62
+ * ```
63
+ */
18
64
  declare const VueQueryPlugin: {
19
65
  install: (app: any, options?: VueQueryPluginOptions) => void;
20
66
  };
@@ -1 +1 @@
1
- {"version":3,"file":"vueQueryPlugin.d.cts","names":[],"sources":["../../src/vueQueryPlugin.ts"],"mappings":";;;KAQK,mBAAmB,QAAQ,6BAA6B;UAEnD;EACR;EACA;EACA,kBAAkB;EAClB,4BAA4B,QAAQ;;UAG5B,sBAAsB;EAC9B,oBAAoB;;UAGZ,sBAAsB;EAC9B,cAAc;;KAGJ,wBAAwB,gBAAgB;cAEvC;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;;KAGJ,wBAAwB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAoCvC;EACI,UAAA,UAAG,UAAW"}
@@ -1,20 +1,66 @@
1
- import { t as QueryClient } from "./queryClient-hf6i_vCa.js";
2
- import { u as QueryClientConfig } from "./types-BzZi3_rS.js";
1
+ import { u as QueryClientConfig } from "./types-JpJB72CS.js";
2
+ import { t as QueryClient } from "./queryClient-Cv73nzNT.js";
3
3
  //#region src/vueQueryPlugin.d.ts
4
4
  type ClientPersister = (client: QueryClient) => [() => void, Promise<void>];
5
5
  interface CommonOptions {
6
+ /** Enables the legacy Vue Devtools v6 plugin panel. Prefer `@tanstack/vue-query-devtools` for Vue 3 apps. */
6
7
  enableDevtoolsV6Plugin?: boolean;
8
+ /**
9
+ * Distinguishes multiple `QueryClient`s provided in the same app — pass the same key to `useQueryClient` to
10
+ * pick this one. Only needed when installing more than one client.
11
+ */
7
12
  queryClientKey?: string;
13
+ /**
14
+ * Restores a persisted cache before the app mounts. While it runs, `queryClient.isRestoring` is `true`, which
15
+ * suppresses fetches — see `usePersistQueryClient` in `@tanstack/query-persist-client-core` for building one.
16
+ */
8
17
  clientPersister?: ClientPersister;
18
+ /** Called once `clientPersister`'s returned promise resolves and the cache has finished restoring. */
9
19
  clientPersisterOnSuccess?: (client: QueryClient) => void;
10
20
  }
11
21
  interface ConfigOptions extends CommonOptions {
22
+ /** Options for the `QueryClient` the plugin constructs. Ignored if `queryClient` is also set. */
12
23
  queryClientConfig?: QueryClientConfig;
13
24
  }
14
25
  interface ClientOptions extends CommonOptions {
26
+ /** Use your own `QueryClient` instance instead of having the plugin construct one from `queryClientConfig`. */
15
27
  queryClient?: QueryClient;
16
28
  }
17
29
  type VueQueryPluginOptions = ConfigOptions | ClientOptions;
30
+ /**
31
+ * Installs a `QueryClient` on the Vue app, making it available to every descendant component through
32
+ * `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin
33
+ * instead of a wrapping component.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * import { createApp } from 'vue'
38
+ * import { VueQueryPlugin } from '@tanstack/vue-query'
39
+ *
40
+ * const app = createApp(App)
41
+ * app.use(VueQueryPlugin)
42
+ * ```
43
+ *
44
+ * @example
45
+ * Pass a `queryClient` you constructed yourself — useful for SSR, where you need a fresh `QueryClient` per
46
+ * request, or when the same instance also needs to be used outside of Vue components:
47
+ * ```ts
48
+ * import { QueryClient, VueQueryPlugin } from '@tanstack/vue-query'
49
+ *
50
+ * const queryClient = new QueryClient()
51
+ * app.use(VueQueryPlugin, { queryClient })
52
+ * ```
53
+ *
54
+ * @example
55
+ * Or pass `queryClientConfig` to let the plugin construct the `QueryClient` for you, with your own defaults:
56
+ * ```ts
57
+ * app.use(VueQueryPlugin, {
58
+ * queryClientConfig: {
59
+ * defaultOptions: { queries: { staleTime: 5 * 1000 } },
60
+ * },
61
+ * })
62
+ * ```
63
+ */
18
64
  declare const VueQueryPlugin: {
19
65
  install: (app: any, options?: VueQueryPluginOptions) => void;
20
66
  };
@@ -1 +1 @@
1
- {"version":3,"file":"vueQueryPlugin.d.ts","names":[],"sources":["../../src/vueQueryPlugin.ts"],"mappings":";;;KAQK,mBAAmB,QAAQ,6BAA6B;UAEnD;EACR;EACA;EACA,kBAAkB;EAClB,4BAA4B,QAAQ;;UAG5B,sBAAsB;EAC9B,oBAAoB;;UAGZ,sBAAsB;EAC9B,cAAc;;KAGJ,wBAAwB,gBAAgB;cAEvC;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;;KAGJ,wBAAwB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAoCvC;EACI,UAAA,UAAG,UAAW"}
@@ -4,6 +4,40 @@ import { setupDevtools } from "./devtools/devtools.js";
4
4
  import { environmentManager } from "@tanstack/query-core";
5
5
  import { isVue2 } from "vue-demi";
6
6
  //#region src/vueQueryPlugin.ts
7
+ /**
8
+ * Installs a `QueryClient` on the Vue app, making it available to every descendant component through
9
+ * `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin
10
+ * instead of a wrapping component.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { createApp } from 'vue'
15
+ * import { VueQueryPlugin } from '@tanstack/vue-query'
16
+ *
17
+ * const app = createApp(App)
18
+ * app.use(VueQueryPlugin)
19
+ * ```
20
+ *
21
+ * @example
22
+ * Pass a `queryClient` you constructed yourself — useful for SSR, where you need a fresh `QueryClient` per
23
+ * request, or when the same instance also needs to be used outside of Vue components:
24
+ * ```ts
25
+ * import { QueryClient, VueQueryPlugin } from '@tanstack/vue-query'
26
+ *
27
+ * const queryClient = new QueryClient()
28
+ * app.use(VueQueryPlugin, { queryClient })
29
+ * ```
30
+ *
31
+ * @example
32
+ * Or pass `queryClientConfig` to let the plugin construct the `QueryClient` for you, with your own defaults:
33
+ * ```ts
34
+ * app.use(VueQueryPlugin, {
35
+ * queryClientConfig: {
36
+ * defaultOptions: { queries: { staleTime: 5 * 1000 } },
37
+ * },
38
+ * })
39
+ * ```
40
+ */
7
41
  const VueQueryPlugin = { install: (app, options = {}) => {
8
42
  const clientKey = getClientKey(options.queryClientKey);
9
43
  let client;
@@ -1 +1 @@
1
- {"version":3,"file":"vueQueryPlugin.js","names":["QueryClient"],"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { environmentManager } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { QueryClientConfig } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n enableDevtoolsV6Plugin?: boolean\n queryClientKey?: string\n clientPersister?: ClientPersister\n clientPersisterOnSuccess?: (client: QueryClient) => void\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: QueryClientConfig\n}\n\ninterface ClientOptions extends CommonOptions {\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!environmentManager.isServer()) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n if (client.isRestoring) {\n client.isRestoring.value = true\n }\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n if (client.isRestoring) {\n client.isRestoring.value = false\n }\n options.clientPersisterOnSuccess?.(client)\n })\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root && options.enableDevtoolsV6Plugin) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n if (options.enableDevtoolsV6Plugin) {\n setupDevtools(app, client)\n }\n }\n }\n },\n}\n"],"mappings":";;;;;;AA2BA,MAAa,iBAAiB,EAC5B,UAAU,KAAU,UAAiC,CAAC,MAAM;CAC1D,MAAM,YAAY,aAAa,QAAQ,cAAc;CACrD,IAAI;CAEJ,IAAI,iBAAiB,WAAW,QAAQ,aACtC,SAAS,QAAQ;MACZ;EACL,MAAM,eACJ,uBAAuB,UAAU,QAAQ,oBAAoB,KAAA;EAC/D,SAAS,IAAIA,cAAY,YAAY;CACvC;CAEA,IAAI,CAAC,mBAAmB,SAAS,GAC/B,OAAO,MAAM;CAGf,IAAI,yBAAyB,CAE7B;CAEA,IAAI,QAAQ,iBAAiB;EAC3B,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;EAE7B,MAAM,CAAC,SAAS,WAAW,QAAQ,gBAAgB,MAAM;EACzD,mBAAmB;EACnB,QAAQ,WAAW;GACjB,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;GAE7B,QAAQ,2BAA2B,MAAM;EAC3C,CAAC;CACH;CAEA,MAAM,gBAAgB;EACpB,OAAO,QAAQ;EACf,iBAAiB;CACnB;CAEA,IAAI,IAAI,WACN,IAAI,UAAU,OAAO;MAChB;EACL,MAAM,kBAAkB,IAAI;EAC5B,IAAI,UAAU,SAAS,kBAAkB;GACvC,QAAQ;GACR,gBAAgB;EAClB;CACF;CAEA,IAAI,QACF,IAAI,MAAM,EACR,eAAe;EAEb,IAAI,CAAC,KAAK,WAAW;GACnB,MAAM,eAAe,CAAC;GACtB,OAAO,eAAe,MAAM,aAAa;IACvC,WAAW;IACX,MAAM,MAAM,OAAO,OAAO,cAAc,CAAC;GAC3C,CAAC;EACH;EAEA,KAAK,UAAU,aAAa;EAE5B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,SAAS,KAAK,SAAS,QAAQ,wBACjC,cAAc,MAAM,MAAM;EAAA;CAGhC,EACF,CAAC;MACI;EACL,IAAI,QAAQ,WAAW,MAAM;EAE7B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,QAAQ,wBACV,cAAc,KAAK,MAAM;EAAA;CAG/B;AACF,EACF"}
1
+ {"version":3,"file":"vueQueryPlugin.js","names":["QueryClient"],"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { environmentManager } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { QueryClientConfig } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n /** Enables the legacy Vue Devtools v6 plugin panel. Prefer `@tanstack/vue-query-devtools` for Vue 3 apps. */\n enableDevtoolsV6Plugin?: boolean\n /**\n * Distinguishes multiple `QueryClient`s provided in the same app — pass the same key to `useQueryClient` to\n * pick this one. Only needed when installing more than one client.\n */\n queryClientKey?: string\n /**\n * Restores a persisted cache before the app mounts. While it runs, `queryClient.isRestoring` is `true`, which\n * suppresses fetches — see `usePersistQueryClient` in `@tanstack/query-persist-client-core` for building one.\n */\n clientPersister?: ClientPersister\n /** Called once `clientPersister`'s returned promise resolves and the cache has finished restoring. */\n clientPersisterOnSuccess?: (client: QueryClient) => void\n}\n\ninterface ConfigOptions extends CommonOptions {\n /** Options for the `QueryClient` the plugin constructs. Ignored if `queryClient` is also set. */\n queryClientConfig?: QueryClientConfig\n}\n\ninterface ClientOptions extends CommonOptions {\n /** Use your own `QueryClient` instance instead of having the plugin construct one from `queryClientConfig`. */\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\n/**\n * Installs a `QueryClient` on the Vue app, making it available to every descendant component through\n * `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin\n * instead of a wrapping component.\n *\n * @example\n * ```ts\n * import { createApp } from 'vue'\n * import { VueQueryPlugin } from '@tanstack/vue-query'\n *\n * const app = createApp(App)\n * app.use(VueQueryPlugin)\n * ```\n *\n * @example\n * Pass a `queryClient` you constructed yourself — useful for SSR, where you need a fresh `QueryClient` per\n * request, or when the same instance also needs to be used outside of Vue components:\n * ```ts\n * import { QueryClient, VueQueryPlugin } from '@tanstack/vue-query'\n *\n * const queryClient = new QueryClient()\n * app.use(VueQueryPlugin, { queryClient })\n * ```\n *\n * @example\n * Or pass `queryClientConfig` to let the plugin construct the `QueryClient` for you, with your own defaults:\n * ```ts\n * app.use(VueQueryPlugin, {\n * queryClientConfig: {\n * defaultOptions: { queries: { staleTime: 5 * 1000 } },\n * },\n * })\n * ```\n */\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!environmentManager.isServer()) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n if (client.isRestoring) {\n client.isRestoring.value = true\n }\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n if (client.isRestoring) {\n client.isRestoring.value = false\n }\n options.clientPersisterOnSuccess?.(client)\n })\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root && options.enableDevtoolsV6Plugin) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n if (options.enableDevtoolsV6Plugin) {\n setupDevtools(app, client)\n }\n }\n }\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,MAAa,iBAAiB,EAC5B,UAAU,KAAU,UAAiC,CAAC,MAAM;CAC1D,MAAM,YAAY,aAAa,QAAQ,cAAc;CACrD,IAAI;CAEJ,IAAI,iBAAiB,WAAW,QAAQ,aACtC,SAAS,QAAQ;MACZ;EACL,MAAM,eACJ,uBAAuB,UAAU,QAAQ,oBAAoB,KAAA;EAC/D,SAAS,IAAIA,cAAY,YAAY;CACvC;CAEA,IAAI,CAAC,mBAAmB,SAAS,GAC/B,OAAO,MAAM;CAGf,IAAI,yBAAyB,CAE7B;CAEA,IAAI,QAAQ,iBAAiB;EAC3B,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;EAE7B,MAAM,CAAC,SAAS,WAAW,QAAQ,gBAAgB,MAAM;EACzD,mBAAmB;EACnB,QAAQ,WAAW;GACjB,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;GAE7B,QAAQ,2BAA2B,MAAM;EAC3C,CAAC;CACH;CAEA,MAAM,gBAAgB;EACpB,OAAO,QAAQ;EACf,iBAAiB;CACnB;CAEA,IAAI,IAAI,WACN,IAAI,UAAU,OAAO;MAChB;EACL,MAAM,kBAAkB,IAAI;EAC5B,IAAI,UAAU,SAAS,kBAAkB;GACvC,QAAQ;GACR,gBAAgB;EAClB;CACF;CAEA,IAAI,QACF,IAAI,MAAM,EACR,eAAe;EAEb,IAAI,CAAC,KAAK,WAAW;GACnB,MAAM,eAAe,CAAC;GACtB,OAAO,eAAe,MAAM,aAAa;IACvC,WAAW;IACX,MAAM,MAAM,OAAO,OAAO,cAAc,CAAC;GAC3C,CAAC;EACH;EAEA,KAAK,UAAU,aAAa;EAE5B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,SAAS,KAAK,SAAS,QAAQ,wBACjC,cAAc,MAAM,MAAM;EAAA;CAGhC,EACF,CAAC;MACI;EACL,IAAI,QAAQ,WAAW,MAAM;EAE7B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,QAAQ,wBACV,cAAc,KAAK,MAAM;EAAA;CAG/B;AACF,EACF"}