@tanstack/vue-query 5.101.4 → 5.102.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 (355) hide show
  1. package/README.md +17 -0
  2. package/build/legacy/devtools/devtools.cjs +203 -258
  3. package/build/legacy/devtools/devtools.cjs.map +1 -1
  4. package/build/legacy/devtools/devtools.d.cts +6 -1
  5. package/build/legacy/devtools/devtools.d.cts.map +1 -0
  6. package/build/legacy/devtools/devtools.d.ts +6 -1
  7. package/build/legacy/devtools/devtools.d.ts.map +1 -0
  8. package/build/legacy/devtools/devtools.js +200 -236
  9. package/build/legacy/devtools/devtools.js.map +1 -1
  10. package/build/legacy/devtools/utils.cjs +37 -94
  11. package/build/legacy/devtools/utils.cjs.map +1 -1
  12. package/build/legacy/devtools/utils.d.cts +18 -5
  13. package/build/legacy/devtools/utils.d.cts.map +1 -0
  14. package/build/legacy/devtools/utils.d.ts +18 -5
  15. package/build/legacy/devtools/utils.d.ts.map +1 -0
  16. package/build/legacy/devtools/utils.js +32 -65
  17. package/build/legacy/devtools/utils.js.map +1 -1
  18. package/build/legacy/index.cjs +44 -83
  19. package/build/legacy/index.d.cts +17 -173
  20. package/build/legacy/index.d.ts +17 -173
  21. package/build/legacy/index.js +6 -27
  22. package/build/legacy/infiniteQueryOptions.cjs +6 -30
  23. package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
  24. package/build/legacy/infiniteQueryOptions.d.cts +2 -3
  25. package/build/legacy/infiniteQueryOptions.d.ts +2 -3
  26. package/build/legacy/infiniteQueryOptions.js +5 -5
  27. package/build/legacy/infiniteQueryOptions.js.map +1 -1
  28. package/build/legacy/mutationCache.cjs +13 -37
  29. package/build/legacy/mutationCache.cjs.map +1 -1
  30. package/build/legacy/mutationCache.d.cts +10 -1
  31. package/build/legacy/mutationCache.d.cts.map +1 -0
  32. package/build/legacy/mutationCache.d.ts +10 -1
  33. package/build/legacy/mutationCache.d.ts.map +1 -0
  34. package/build/legacy/mutationCache.js +12 -12
  35. package/build/legacy/mutationCache.js.map +1 -1
  36. package/build/legacy/mutationOptions.cjs +6 -30
  37. package/build/legacy/mutationOptions.cjs.map +1 -1
  38. package/build/legacy/mutationOptions.d.cts +10 -1
  39. package/build/legacy/mutationOptions.d.cts.map +1 -0
  40. package/build/legacy/mutationOptions.d.ts +10 -1
  41. package/build/legacy/mutationOptions.d.ts.map +1 -0
  42. package/build/legacy/mutationOptions.js +5 -5
  43. package/build/legacy/mutationOptions.js.map +1 -1
  44. package/build/legacy/queryCache.cjs +13 -37
  45. package/build/legacy/queryCache.cjs.map +1 -1
  46. package/build/legacy/queryCache.d.cts +10 -1
  47. package/build/legacy/queryCache.d.cts.map +1 -0
  48. package/build/legacy/queryCache.d.ts +10 -1
  49. package/build/legacy/queryCache.d.ts.map +1 -0
  50. package/build/legacy/queryCache.js +12 -12
  51. package/build/legacy/queryCache.js.map +1 -1
  52. package/build/legacy/queryClient-C07d0chJ.d.cts +97 -0
  53. package/build/legacy/queryClient-C07d0chJ.d.cts.map +1 -0
  54. package/build/legacy/queryClient-hf6i_vCa.d.ts +97 -0
  55. package/build/legacy/queryClient-hf6i_vCa.d.ts.map +1 -0
  56. package/build/legacy/queryClient.cjs +104 -142
  57. package/build/legacy/queryClient.cjs.map +1 -1
  58. package/build/legacy/queryClient.d.cts +2 -1
  59. package/build/legacy/queryClient.d.ts +2 -1
  60. package/build/legacy/queryClient.js +103 -117
  61. package/build/legacy/queryClient.js.map +1 -1
  62. package/build/legacy/queryOptions.cjs +6 -30
  63. package/build/legacy/queryOptions.cjs.map +1 -1
  64. package/build/legacy/queryOptions.d.cts +19 -4
  65. package/build/legacy/queryOptions.d.cts.map +1 -0
  66. package/build/legacy/queryOptions.d.ts +19 -4
  67. package/build/legacy/queryOptions.d.ts.map +1 -0
  68. package/build/legacy/queryOptions.js +5 -5
  69. package/build/legacy/queryOptions.js.map +1 -1
  70. package/build/legacy/types-BzZi3_rS.d.cts +33 -0
  71. package/build/legacy/types-BzZi3_rS.d.cts.map +1 -0
  72. package/build/legacy/types-BzZi3_rS.d.ts +33 -0
  73. package/build/legacy/types-BzZi3_rS.d.ts.map +1 -0
  74. package/build/legacy/types.cjs +0 -19
  75. package/build/legacy/types.d.cts +2 -11
  76. package/build/legacy/types.d.ts +2 -11
  77. package/build/legacy/types.js +1 -1
  78. package/build/legacy/useBaseQuery.cjs +78 -140
  79. package/build/legacy/useBaseQuery.cjs.map +1 -1
  80. package/build/legacy/useBaseQuery.d.cts +2 -2
  81. package/build/legacy/useBaseQuery.d.ts +2 -2
  82. package/build/legacy/useBaseQuery.js +76 -124
  83. package/build/legacy/useBaseQuery.js.map +1 -1
  84. package/build/legacy/useInfiniteQuery.cjs +8 -36
  85. package/build/legacy/useInfiniteQuery.cjs.map +1 -1
  86. package/build/legacy/useInfiniteQuery.d.cts +2 -3
  87. package/build/legacy/useInfiniteQuery.d.ts +2 -3
  88. package/build/legacy/useInfiniteQuery.js +6 -10
  89. package/build/legacy/useInfiniteQuery.js.map +1 -1
  90. package/build/legacy/useIsFetching.cjs +23 -51
  91. package/build/legacy/useIsFetching.cjs.map +1 -1
  92. package/build/legacy/useIsFetching.d.cts +10 -2
  93. package/build/legacy/useIsFetching.d.cts.map +1 -0
  94. package/build/legacy/useIsFetching.d.ts +10 -2
  95. package/build/legacy/useIsFetching.d.ts.map +1 -0
  96. package/build/legacy/useIsFetching.js +21 -25
  97. package/build/legacy/useIsFetching.js.map +1 -1
  98. package/build/legacy/useMutation.cjs +42 -76
  99. package/build/legacy/useMutation.cjs.map +1 -1
  100. package/build/legacy/useMutation.d.cts +17 -3
  101. package/build/legacy/useMutation.d.cts.map +1 -0
  102. package/build/legacy/useMutation.d.ts +17 -3
  103. package/build/legacy/useMutation.d.ts.map +1 -0
  104. package/build/legacy/useMutation.js +39 -59
  105. package/build/legacy/useMutation.js.map +1 -1
  106. package/build/legacy/useMutationState.cjs +38 -75
  107. package/build/legacy/useMutationState.cjs.map +1 -1
  108. package/build/legacy/useMutationState.d.cts +16 -4
  109. package/build/legacy/useMutationState.d.cts.map +1 -0
  110. package/build/legacy/useMutationState.d.ts +16 -4
  111. package/build/legacy/useMutationState.d.ts.map +1 -0
  112. package/build/legacy/useMutationState.js +35 -55
  113. package/build/legacy/useMutationState.js.map +1 -1
  114. package/build/legacy/usePrefetchInfiniteQuery.cjs +19 -50
  115. package/build/legacy/usePrefetchInfiniteQuery.cjs.map +1 -1
  116. package/build/legacy/usePrefetchInfiniteQuery.d.cts +11 -2
  117. package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -0
  118. package/build/legacy/usePrefetchInfiniteQuery.d.ts +11 -2
  119. package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -0
  120. package/build/legacy/usePrefetchInfiniteQuery.js +17 -24
  121. package/build/legacy/usePrefetchInfiniteQuery.js.map +1 -1
  122. package/build/legacy/usePrefetchQuery.cjs +19 -48
  123. package/build/legacy/usePrefetchQuery.cjs.map +1 -1
  124. package/build/legacy/usePrefetchQuery.d.cts +11 -2
  125. package/build/legacy/usePrefetchQuery.d.cts.map +1 -0
  126. package/build/legacy/usePrefetchQuery.d.ts +11 -2
  127. package/build/legacy/usePrefetchQuery.d.ts.map +1 -0
  128. package/build/legacy/usePrefetchQuery.js +17 -22
  129. package/build/legacy/usePrefetchQuery.js.map +1 -1
  130. package/build/legacy/useQueries.cjs +57 -113
  131. package/build/legacy/useQueries.cjs.map +1 -1
  132. package/build/legacy/useQueries.d.cts +63 -3
  133. package/build/legacy/useQueries.d.cts.map +1 -0
  134. package/build/legacy/useQueries.d.ts +63 -3
  135. package/build/legacy/useQueries.d.ts.map +1 -0
  136. package/build/legacy/useQueries.js +55 -96
  137. package/build/legacy/useQueries.js.map +1 -1
  138. package/build/legacy/useQuery.cjs +8 -32
  139. package/build/legacy/useQuery.cjs.map +1 -1
  140. package/build/legacy/useQuery.d.cts +2 -6
  141. package/build/legacy/useQuery.d.ts +2 -6
  142. package/build/legacy/useQuery.js +6 -6
  143. package/build/legacy/useQuery.js.map +1 -1
  144. package/build/legacy/useQueryClient.cjs +12 -44
  145. package/build/legacy/useQueryClient.cjs.map +1 -1
  146. package/build/legacy/useQueryClient.d.cts +6 -1
  147. package/build/legacy/useQueryClient.d.cts.map +1 -0
  148. package/build/legacy/useQueryClient.d.ts +6 -1
  149. package/build/legacy/useQueryClient.d.ts.map +1 -0
  150. package/build/legacy/useQueryClient.js +10 -18
  151. package/build/legacy/useQueryClient.js.map +1 -1
  152. package/build/legacy/utils.cjs +40 -89
  153. package/build/legacy/utils.cjs.map +1 -1
  154. package/build/legacy/utils.d.cts +11 -6
  155. package/build/legacy/utils.d.cts.map +1 -0
  156. package/build/legacy/utils.d.ts +11 -6
  157. package/build/legacy/utils.d.ts.map +1 -0
  158. package/build/legacy/utils.js +32 -57
  159. package/build/legacy/utils.js.map +1 -1
  160. package/build/legacy/vueQueryPlugin.cjs +61 -103
  161. package/build/legacy/vueQueryPlugin.cjs.map +1 -1
  162. package/build/legacy/vueQueryPlugin.d.cts +23 -2
  163. package/build/legacy/vueQueryPlugin.d.cts.map +1 -0
  164. package/build/legacy/vueQueryPlugin.d.ts +23 -2
  165. package/build/legacy/vueQueryPlugin.d.ts.map +1 -0
  166. package/build/legacy/vueQueryPlugin.js +59 -77
  167. package/build/legacy/vueQueryPlugin.js.map +1 -1
  168. package/build/modern/devtools/devtools.cjs +201 -256
  169. package/build/modern/devtools/devtools.cjs.map +1 -1
  170. package/build/modern/devtools/devtools.d.cts +6 -1
  171. package/build/modern/devtools/devtools.d.cts.map +1 -0
  172. package/build/modern/devtools/devtools.d.ts +6 -1
  173. package/build/modern/devtools/devtools.d.ts.map +1 -0
  174. package/build/modern/devtools/devtools.js +198 -234
  175. package/build/modern/devtools/devtools.js.map +1 -1
  176. package/build/modern/devtools/utils.cjs +37 -94
  177. package/build/modern/devtools/utils.cjs.map +1 -1
  178. package/build/modern/devtools/utils.d.cts +18 -5
  179. package/build/modern/devtools/utils.d.cts.map +1 -0
  180. package/build/modern/devtools/utils.d.ts +18 -5
  181. package/build/modern/devtools/utils.d.ts.map +1 -0
  182. package/build/modern/devtools/utils.js +32 -65
  183. package/build/modern/devtools/utils.js.map +1 -1
  184. package/build/modern/index.cjs +44 -83
  185. package/build/modern/index.d.cts +17 -173
  186. package/build/modern/index.d.ts +17 -173
  187. package/build/modern/index.js +6 -27
  188. package/build/modern/infiniteQueryOptions.cjs +6 -30
  189. package/build/modern/infiniteQueryOptions.cjs.map +1 -1
  190. package/build/modern/infiniteQueryOptions.d.cts +2 -3
  191. package/build/modern/infiniteQueryOptions.d.ts +2 -3
  192. package/build/modern/infiniteQueryOptions.js +5 -5
  193. package/build/modern/infiniteQueryOptions.js.map +1 -1
  194. package/build/modern/mutationCache.cjs +13 -37
  195. package/build/modern/mutationCache.cjs.map +1 -1
  196. package/build/modern/mutationCache.d.cts +10 -1
  197. package/build/modern/mutationCache.d.cts.map +1 -0
  198. package/build/modern/mutationCache.d.ts +10 -1
  199. package/build/modern/mutationCache.d.ts.map +1 -0
  200. package/build/modern/mutationCache.js +12 -12
  201. package/build/modern/mutationCache.js.map +1 -1
  202. package/build/modern/mutationOptions.cjs +6 -30
  203. package/build/modern/mutationOptions.cjs.map +1 -1
  204. package/build/modern/mutationOptions.d.cts +10 -1
  205. package/build/modern/mutationOptions.d.cts.map +1 -0
  206. package/build/modern/mutationOptions.d.ts +10 -1
  207. package/build/modern/mutationOptions.d.ts.map +1 -0
  208. package/build/modern/mutationOptions.js +5 -5
  209. package/build/modern/mutationOptions.js.map +1 -1
  210. package/build/modern/queryCache.cjs +13 -37
  211. package/build/modern/queryCache.cjs.map +1 -1
  212. package/build/modern/queryCache.d.cts +10 -1
  213. package/build/modern/queryCache.d.cts.map +1 -0
  214. package/build/modern/queryCache.d.ts +10 -1
  215. package/build/modern/queryCache.d.ts.map +1 -0
  216. package/build/modern/queryCache.js +12 -12
  217. package/build/modern/queryCache.js.map +1 -1
  218. package/build/modern/queryClient-C07d0chJ.d.cts +97 -0
  219. package/build/modern/queryClient-C07d0chJ.d.cts.map +1 -0
  220. package/build/modern/queryClient-hf6i_vCa.d.ts +97 -0
  221. package/build/modern/queryClient-hf6i_vCa.d.ts.map +1 -0
  222. package/build/modern/queryClient.cjs +104 -142
  223. package/build/modern/queryClient.cjs.map +1 -1
  224. package/build/modern/queryClient.d.cts +2 -1
  225. package/build/modern/queryClient.d.ts +2 -1
  226. package/build/modern/queryClient.js +103 -117
  227. package/build/modern/queryClient.js.map +1 -1
  228. package/build/modern/queryOptions.cjs +6 -30
  229. package/build/modern/queryOptions.cjs.map +1 -1
  230. package/build/modern/queryOptions.d.cts +19 -4
  231. package/build/modern/queryOptions.d.cts.map +1 -0
  232. package/build/modern/queryOptions.d.ts +19 -4
  233. package/build/modern/queryOptions.d.ts.map +1 -0
  234. package/build/modern/queryOptions.js +5 -5
  235. package/build/modern/queryOptions.js.map +1 -1
  236. package/build/modern/types-BzZi3_rS.d.cts +33 -0
  237. package/build/modern/types-BzZi3_rS.d.cts.map +1 -0
  238. package/build/modern/types-BzZi3_rS.d.ts +33 -0
  239. package/build/modern/types-BzZi3_rS.d.ts.map +1 -0
  240. package/build/modern/types.cjs +0 -19
  241. package/build/modern/types.d.cts +2 -11
  242. package/build/modern/types.d.ts +2 -11
  243. package/build/modern/types.js +1 -1
  244. package/build/modern/useBaseQuery.cjs +77 -139
  245. package/build/modern/useBaseQuery.cjs.map +1 -1
  246. package/build/modern/useBaseQuery.d.cts +2 -2
  247. package/build/modern/useBaseQuery.d.ts +2 -2
  248. package/build/modern/useBaseQuery.js +75 -123
  249. package/build/modern/useBaseQuery.js.map +1 -1
  250. package/build/modern/useInfiniteQuery.cjs +8 -36
  251. package/build/modern/useInfiniteQuery.cjs.map +1 -1
  252. package/build/modern/useInfiniteQuery.d.cts +2 -3
  253. package/build/modern/useInfiniteQuery.d.ts +2 -3
  254. package/build/modern/useInfiniteQuery.js +6 -10
  255. package/build/modern/useInfiniteQuery.js.map +1 -1
  256. package/build/modern/useIsFetching.cjs +23 -51
  257. package/build/modern/useIsFetching.cjs.map +1 -1
  258. package/build/modern/useIsFetching.d.cts +10 -2
  259. package/build/modern/useIsFetching.d.cts.map +1 -0
  260. package/build/modern/useIsFetching.d.ts +10 -2
  261. package/build/modern/useIsFetching.d.ts.map +1 -0
  262. package/build/modern/useIsFetching.js +21 -25
  263. package/build/modern/useIsFetching.js.map +1 -1
  264. package/build/modern/useMutation.cjs +42 -76
  265. package/build/modern/useMutation.cjs.map +1 -1
  266. package/build/modern/useMutation.d.cts +17 -3
  267. package/build/modern/useMutation.d.cts.map +1 -0
  268. package/build/modern/useMutation.d.ts +17 -3
  269. package/build/modern/useMutation.d.ts.map +1 -0
  270. package/build/modern/useMutation.js +39 -59
  271. package/build/modern/useMutation.js.map +1 -1
  272. package/build/modern/useMutationState.cjs +38 -75
  273. package/build/modern/useMutationState.cjs.map +1 -1
  274. package/build/modern/useMutationState.d.cts +16 -4
  275. package/build/modern/useMutationState.d.cts.map +1 -0
  276. package/build/modern/useMutationState.d.ts +16 -4
  277. package/build/modern/useMutationState.d.ts.map +1 -0
  278. package/build/modern/useMutationState.js +35 -55
  279. package/build/modern/useMutationState.js.map +1 -1
  280. package/build/modern/usePrefetchInfiniteQuery.cjs +19 -50
  281. package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -1
  282. package/build/modern/usePrefetchInfiniteQuery.d.cts +11 -2
  283. package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -0
  284. package/build/modern/usePrefetchInfiniteQuery.d.ts +11 -2
  285. package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -0
  286. package/build/modern/usePrefetchInfiniteQuery.js +17 -24
  287. package/build/modern/usePrefetchInfiniteQuery.js.map +1 -1
  288. package/build/modern/usePrefetchQuery.cjs +19 -48
  289. package/build/modern/usePrefetchQuery.cjs.map +1 -1
  290. package/build/modern/usePrefetchQuery.d.cts +11 -2
  291. package/build/modern/usePrefetchQuery.d.cts.map +1 -0
  292. package/build/modern/usePrefetchQuery.d.ts +11 -2
  293. package/build/modern/usePrefetchQuery.d.ts.map +1 -0
  294. package/build/modern/usePrefetchQuery.js +17 -22
  295. package/build/modern/usePrefetchQuery.js.map +1 -1
  296. package/build/modern/useQueries.cjs +56 -112
  297. package/build/modern/useQueries.cjs.map +1 -1
  298. package/build/modern/useQueries.d.cts +63 -3
  299. package/build/modern/useQueries.d.cts.map +1 -0
  300. package/build/modern/useQueries.d.ts +63 -3
  301. package/build/modern/useQueries.d.ts.map +1 -0
  302. package/build/modern/useQueries.js +54 -95
  303. package/build/modern/useQueries.js.map +1 -1
  304. package/build/modern/useQuery.cjs +8 -32
  305. package/build/modern/useQuery.cjs.map +1 -1
  306. package/build/modern/useQuery.d.cts +2 -6
  307. package/build/modern/useQuery.d.ts +2 -6
  308. package/build/modern/useQuery.js +6 -6
  309. package/build/modern/useQuery.js.map +1 -1
  310. package/build/modern/useQueryClient.cjs +12 -44
  311. package/build/modern/useQueryClient.cjs.map +1 -1
  312. package/build/modern/useQueryClient.d.cts +6 -1
  313. package/build/modern/useQueryClient.d.cts.map +1 -0
  314. package/build/modern/useQueryClient.d.ts +6 -1
  315. package/build/modern/useQueryClient.d.ts.map +1 -0
  316. package/build/modern/useQueryClient.js +10 -18
  317. package/build/modern/useQueryClient.js.map +1 -1
  318. package/build/modern/utils.cjs +40 -89
  319. package/build/modern/utils.cjs.map +1 -1
  320. package/build/modern/utils.d.cts +11 -6
  321. package/build/modern/utils.d.cts.map +1 -0
  322. package/build/modern/utils.d.ts +11 -6
  323. package/build/modern/utils.d.ts.map +1 -0
  324. package/build/modern/utils.js +32 -57
  325. package/build/modern/utils.js.map +1 -1
  326. package/build/modern/vueQueryPlugin.cjs +60 -102
  327. package/build/modern/vueQueryPlugin.cjs.map +1 -1
  328. package/build/modern/vueQueryPlugin.d.cts +23 -2
  329. package/build/modern/vueQueryPlugin.d.cts.map +1 -0
  330. package/build/modern/vueQueryPlugin.d.ts +23 -2
  331. package/build/modern/vueQueryPlugin.d.ts.map +1 -0
  332. package/build/modern/vueQueryPlugin.js +58 -76
  333. package/build/modern/vueQueryPlugin.js.map +1 -1
  334. package/package.json +5 -7
  335. package/src/index.ts +5 -1
  336. package/src/infiniteQueryOptions.ts +5 -7
  337. package/src/queryClient.ts +150 -36
  338. package/src/queryOptions.ts +32 -14
  339. package/src/useMutation.ts +4 -4
  340. package/src/useMutationState.ts +33 -8
  341. package/src/usePrefetchInfiniteQuery.ts +22 -42
  342. package/src/usePrefetchQuery.ts +29 -5
  343. package/src/useQuery.ts +19 -9
  344. package/build/legacy/_tsup-dts-rollup.d.cts +0 -884
  345. package/build/legacy/_tsup-dts-rollup.d.ts +0 -884
  346. package/build/legacy/index.cjs.map +0 -1
  347. package/build/legacy/index.js.map +0 -1
  348. package/build/legacy/types.cjs.map +0 -1
  349. package/build/legacy/types.js.map +0 -1
  350. package/build/modern/_tsup-dts-rollup.d.cts +0 -884
  351. package/build/modern/_tsup-dts-rollup.d.ts +0 -884
  352. package/build/modern/index.cjs.map +0 -1
  353. package/build/modern/index.js.map +0 -1
  354. package/build/modern/types.cjs.map +0 -1
  355. package/build/modern/types.js.map +0 -1
@@ -1,80 +1,62 @@
1
- // src/vueQueryPlugin.ts
2
- import { isVue2 } from "vue-demi";
3
- import { environmentManager } from "@tanstack/query-core";
4
- import { QueryClient } from "./queryClient.js";
5
1
  import { getClientKey } from "./utils.js";
2
+ import { QueryClient as QueryClient$1 } from "./queryClient.js";
6
3
  import { setupDevtools } from "./devtools/devtools.js";
7
- var VueQueryPlugin = {
8
- install: (app, options = {}) => {
9
- const clientKey = getClientKey(options.queryClientKey);
10
- let client;
11
- if ("queryClient" in options && options.queryClient) {
12
- client = options.queryClient;
13
- } else {
14
- const clientConfig = "queryClientConfig" in options ? options.queryClientConfig : void 0;
15
- client = new QueryClient(clientConfig);
16
- }
17
- if (!environmentManager.isServer()) {
18
- client.mount();
19
- }
20
- let persisterUnmount = () => {
21
- };
22
- if (options.clientPersister) {
23
- if (client.isRestoring) {
24
- client.isRestoring.value = true;
25
- }
26
- const [unmount, promise] = options.clientPersister(client);
27
- persisterUnmount = unmount;
28
- promise.then(() => {
29
- var _a;
30
- if (client.isRestoring) {
31
- client.isRestoring.value = false;
32
- }
33
- (_a = options.clientPersisterOnSuccess) == null ? void 0 : _a.call(options, client);
34
- });
35
- }
36
- const cleanup = () => {
37
- client.unmount();
38
- persisterUnmount();
39
- };
40
- if (app.onUnmount) {
41
- app.onUnmount(cleanup);
42
- } else {
43
- const originalUnmount = app.unmount;
44
- app.unmount = function vueQueryUnmount() {
45
- cleanup();
46
- originalUnmount();
47
- };
48
- }
49
- if (isVue2) {
50
- app.mixin({
51
- beforeCreate() {
52
- if (!this._provided) {
53
- const provideCache = {};
54
- Object.defineProperty(this, "_provided", {
55
- get: () => provideCache,
56
- set: (v) => Object.assign(provideCache, v)
57
- });
58
- }
59
- this._provided[clientKey] = client;
60
- if (process.env.NODE_ENV === "development") {
61
- if (this === this.$root && options.enableDevtoolsV6Plugin) {
62
- setupDevtools(this, client);
63
- }
64
- }
65
- }
66
- });
67
- } else {
68
- app.provide(clientKey, client);
69
- if (process.env.NODE_ENV === "development") {
70
- if (options.enableDevtoolsV6Plugin) {
71
- setupDevtools(app, client);
72
- }
73
- }
74
- }
75
- }
76
- };
77
- export {
78
- VueQueryPlugin
79
- };
4
+ import { environmentManager } from "@tanstack/query-core";
5
+ import { isVue2 } from "vue-demi";
6
+ //#region src/vueQueryPlugin.ts
7
+ const VueQueryPlugin = { install: (app, options = {}) => {
8
+ const clientKey = getClientKey(options.queryClientKey);
9
+ let client;
10
+ if ("queryClient" in options && options.queryClient) client = options.queryClient;
11
+ else {
12
+ const clientConfig = "queryClientConfig" in options ? options.queryClientConfig : void 0;
13
+ client = new QueryClient$1(clientConfig);
14
+ }
15
+ if (!environmentManager.isServer()) client.mount();
16
+ let persisterUnmount = () => {};
17
+ if (options.clientPersister) {
18
+ if (client.isRestoring) client.isRestoring.value = true;
19
+ const [unmount, promise] = options.clientPersister(client);
20
+ persisterUnmount = unmount;
21
+ promise.then(() => {
22
+ var _options$clientPersis;
23
+ if (client.isRestoring) client.isRestoring.value = false;
24
+ (_options$clientPersis = options.clientPersisterOnSuccess) === null || _options$clientPersis === void 0 || _options$clientPersis.call(options, client);
25
+ });
26
+ }
27
+ const cleanup = () => {
28
+ client.unmount();
29
+ persisterUnmount();
30
+ };
31
+ if (app.onUnmount) app.onUnmount(cleanup);
32
+ else {
33
+ const originalUnmount = app.unmount;
34
+ app.unmount = function vueQueryUnmount() {
35
+ cleanup();
36
+ originalUnmount();
37
+ };
38
+ }
39
+ if (isVue2) app.mixin({ beforeCreate() {
40
+ if (!this._provided) {
41
+ const provideCache = {};
42
+ Object.defineProperty(this, "_provided", {
43
+ get: () => provideCache,
44
+ set: (v) => Object.assign(provideCache, v)
45
+ });
46
+ }
47
+ this._provided[clientKey] = client;
48
+ if (process.env.NODE_ENV === "development") {
49
+ if (this === this.$root && options.enableDevtoolsV6Plugin) setupDevtools(this, client);
50
+ }
51
+ } });
52
+ else {
53
+ app.provide(clientKey, client);
54
+ if (process.env.NODE_ENV === "development") {
55
+ if (options.enableDevtoolsV6Plugin) setupDevtools(app, client);
56
+ }
57
+ }
58
+ } };
59
+ //#endregion
60
+ export { VueQueryPlugin };
61
+
80
62
  //# sourceMappingURL=vueQueryPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"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":";AAAA,SAAS,cAAc;AACvB,SAAS,0BAA0B;AAEnC,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAsBvB,IAAM,iBAAiB;AAAA,EAC5B,SAAS,CAAC,KAAU,UAAiC,CAAC,MAAM;AAC1D,UAAM,YAAY,aAAa,QAAQ,cAAc;AACrD,QAAI;AAEJ,QAAI,iBAAiB,WAAW,QAAQ,aAAa;AACnD,eAAS,QAAQ;AAAA,IACnB,OAAO;AACL,YAAM,eACJ,uBAAuB,UAAU,QAAQ,oBAAoB;AAC/D,eAAS,IAAI,YAAY,YAAY;AAAA,IACvC;AAEA,QAAI,CAAC,mBAAmB,SAAS,GAAG;AAClC,aAAO,MAAM;AAAA,IACf;AAEA,QAAI,mBAAmB,MAAM;AAAA,IAE7B;AAEA,QAAI,QAAQ,iBAAiB;AAC3B,UAAI,OAAO,aAAa;AACtB,eAAO,YAAY,QAAQ;AAAA,MAC7B;AACA,YAAM,CAAC,SAAS,OAAO,IAAI,QAAQ,gBAAgB,MAAM;AACzD,yBAAmB;AACnB,cAAQ,KAAK,MAAM;AAtDzB;AAuDQ,YAAI,OAAO,aAAa;AACtB,iBAAO,YAAY,QAAQ;AAAA,QAC7B;AACA,sBAAQ,6BAAR,iCAAmC;AAAA,MACrC,CAAC;AAAA,IACH;AAEA,UAAM,UAAU,MAAM;AACpB,aAAO,QAAQ;AACf,uBAAiB;AAAA,IACnB;AAEA,QAAI,IAAI,WAAW;AACjB,UAAI,UAAU,OAAO;AAAA,IACvB,OAAO;AACL,YAAM,kBAAkB,IAAI;AAC5B,UAAI,UAAU,SAAS,kBAAkB;AACvC,gBAAQ;AACR,wBAAgB;AAAA,MAClB;AAAA,IACF;AAEA,QAAI,QAAQ;AACV,UAAI,MAAM;AAAA,QACR,eAAe;AAEb,cAAI,CAAC,KAAK,WAAW;AACnB,kBAAM,eAAe,CAAC;AACtB,mBAAO,eAAe,MAAM,aAAa;AAAA,cACvC,KAAK,MAAM;AAAA,cACX,KAAK,CAAC,MAAM,OAAO,OAAO,cAAc,CAAC;AAAA,YAC3C,CAAC;AAAA,UACH;AAEA,eAAK,UAAU,SAAS,IAAI;AAE5B,cAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,gBAAI,SAAS,KAAK,SAAS,QAAQ,wBAAwB;AACzD,4BAAc,MAAM,MAAM;AAAA,YAC5B;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH,OAAO;AACL,UAAI,QAAQ,WAAW,MAAM;AAE7B,UAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,YAAI,QAAQ,wBAAwB;AAClC,wBAAc,KAAK,MAAM;AAAA,QAC3B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
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,CAAA,wBAAA,QAAQ,8BAAA,QAAA,0BAAA,KAAA,KAAA,sBAAA,KAAA,SAA2B,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,259 +1,204 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/devtools/devtools.ts
21
- var devtools_exports = {};
22
- __export(devtools_exports, {
23
- setupDevtools: () => setupDevtools
24
- });
25
- module.exports = __toCommonJS(devtools_exports);
26
- var import_devtools_api = require("@vue/devtools-api");
27
- var import_match_sorter_utils = require("@tanstack/match-sorter-utils");
28
- var import_query_core = require("@tanstack/query-core");
29
- var import_utils = require("./utils.cjs");
30
- var pluginId = "vue-query";
31
- var pluginName = "Vue Query";
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_devtools_utils = require("./utils.cjs");
3
+ let _tanstack_query_core = require("@tanstack/query-core");
4
+ let _vue_devtools_api = require("@vue/devtools-api");
5
+ let _tanstack_match_sorter_utils = require("@tanstack/match-sorter-utils");
6
+ //#region src/devtools/devtools.ts
7
+ const pluginId = "vue-query";
8
+ const pluginName = "Vue Query";
32
9
  function setupDevtools(app, queryClient) {
33
- (0, import_devtools_api.setupDevtoolsPlugin)(
34
- {
35
- id: pluginId,
36
- label: pluginName,
37
- packageName: "vue-query",
38
- homepage: "https://tanstack.com/query/latest",
39
- logo: "https://raw.githubusercontent.com/TanStack/query/main/packages/vue-query/media/vue-query.svg",
40
- app,
41
- settings: {
42
- baseSort: {
43
- type: "choice",
44
- component: "button-group",
45
- label: "Sort Cache Entries",
46
- options: [
47
- {
48
- label: "ASC",
49
- value: 1
50
- },
51
- {
52
- label: "DESC",
53
- value: -1
54
- }
55
- ],
56
- defaultValue: 1
57
- },
58
- sortFn: {
59
- type: "choice",
60
- label: "Sort Function",
61
- options: Object.keys(import_utils.sortFns).map((key) => ({
62
- label: key,
63
- value: key
64
- })),
65
- defaultValue: Object.keys(import_utils.sortFns)[0]
66
- },
67
- onlineMode: {
68
- type: "choice",
69
- component: "button-group",
70
- label: "Online mode",
71
- options: [
72
- {
73
- label: "Online",
74
- value: 1
75
- },
76
- {
77
- label: "Offline",
78
- value: 0
79
- }
80
- ],
81
- defaultValue: 1
82
- }
83
- }
84
- },
85
- (api) => {
86
- const initialSettings = api.getSettings();
87
- import_query_core.onlineManager.setOnline(Boolean(initialSettings.onlineMode.valueOf()));
88
- const queryCache = queryClient.getQueryCache();
89
- api.addInspector({
90
- id: pluginId,
91
- label: pluginName,
92
- icon: "api",
93
- nodeActions: [
94
- {
95
- icon: "file_download",
96
- tooltip: "Refetch",
97
- action: (queryHash) => {
98
- queryCache.get(queryHash)?.fetch();
99
- }
100
- },
101
- {
102
- icon: "alarm",
103
- tooltip: "Invalidate",
104
- action: (queryHash) => {
105
- const query = queryCache.get(queryHash);
106
- queryClient.invalidateQueries({
107
- queryKey: query.queryKey,
108
- exact: true
109
- });
110
- }
111
- },
112
- {
113
- icon: "settings_backup_restore",
114
- tooltip: "Reset",
115
- action: (queryHash) => {
116
- queryCache.get(queryHash)?.reset();
117
- }
118
- },
119
- {
120
- icon: "delete",
121
- tooltip: "Remove",
122
- action: (queryHash) => {
123
- const query = queryCache.get(queryHash);
124
- queryCache.remove(query);
125
- }
126
- },
127
- {
128
- icon: "hourglass_empty",
129
- tooltip: "Force loading",
130
- action: (queryHash) => {
131
- const query = queryCache.get(queryHash);
132
- query.setState({
133
- data: void 0,
134
- status: "pending"
135
- });
136
- }
137
- },
138
- {
139
- icon: "error_outline",
140
- tooltip: "Force error",
141
- action: (queryHash) => {
142
- const query = queryCache.get(queryHash);
143
- query.setState({
144
- data: void 0,
145
- status: "error",
146
- error: new Error("Unknown error from devtools")
147
- });
148
- }
149
- }
150
- ]
151
- });
152
- api.addTimelineLayer({
153
- id: pluginId,
154
- label: pluginName,
155
- color: 16767308
156
- });
157
- queryCache.subscribe((event) => {
158
- api.sendInspectorTree(pluginId);
159
- api.sendInspectorState(pluginId);
160
- const queryEvents = [
161
- "added",
162
- "removed",
163
- "updated"
164
- ];
165
- if (queryEvents.includes(event.type)) {
166
- api.addTimelineEvent({
167
- layerId: pluginId,
168
- event: {
169
- title: event.type,
170
- subtitle: event.query.queryHash,
171
- time: api.now(),
172
- data: {
173
- queryHash: event.query.queryHash,
174
- ...event
175
- }
176
- }
177
- });
178
- }
179
- });
180
- api.on.setPluginSettings((payload) => {
181
- if (payload.key === "onlineMode") {
182
- import_query_core.onlineManager.setOnline(Boolean(payload.newValue));
183
- }
184
- });
185
- api.on.getInspectorTree((payload) => {
186
- if (payload.inspectorId === pluginId) {
187
- const queries = queryCache.getAll();
188
- const settings = api.getSettings();
189
- const filtered = payload.filter ? queries.filter(
190
- (item) => (0, import_match_sorter_utils.rankItem)(item.queryHash, payload.filter).passed
191
- ) : [...queries];
192
- const sorted = filtered.sort(
193
- (a, b) => import_utils.sortFns[settings.sortFn](a, b) * settings.baseSort
194
- );
195
- const nodes = sorted.map((query) => {
196
- const stateLabel = (0, import_utils.getQueryStateLabel)(query);
197
- return {
198
- id: query.queryHash,
199
- label: query.queryHash,
200
- tags: [
201
- {
202
- label: `${stateLabel} [${query.getObserversCount()}]`,
203
- textColor: (0, import_utils.getQueryStatusFg)(query),
204
- backgroundColor: (0, import_utils.getQueryStatusBg)(query)
205
- }
206
- ]
207
- };
208
- });
209
- payload.rootNodes = nodes;
210
- }
211
- });
212
- api.on.getInspectorState((payload) => {
213
- if (payload.inspectorId === pluginId) {
214
- const query = queryCache.get(payload.nodeId);
215
- if (!query) {
216
- return;
217
- }
218
- payload.state = {
219
- " Query Details": [
220
- {
221
- key: "Query key",
222
- value: query.queryHash
223
- },
224
- {
225
- key: "Query status",
226
- value: (0, import_utils.getQueryStateLabel)(query)
227
- },
228
- {
229
- key: "Observers",
230
- value: query.getObserversCount()
231
- },
232
- {
233
- key: "Last Updated",
234
- value: new Date(query.state.dataUpdatedAt).toLocaleTimeString()
235
- }
236
- ],
237
- "Data Explorer": [
238
- {
239
- key: "Data",
240
- value: query.state.data
241
- }
242
- ],
243
- "Query Explorer": [
244
- {
245
- key: "Query",
246
- value: query
247
- }
248
- ]
249
- };
250
- }
251
- });
252
- }
253
- );
10
+ (0, _vue_devtools_api.setupDevtoolsPlugin)({
11
+ id: pluginId,
12
+ label: pluginName,
13
+ packageName: "vue-query",
14
+ homepage: "https://tanstack.com/query/latest",
15
+ logo: "https://raw.githubusercontent.com/TanStack/query/main/packages/vue-query/media/vue-query.svg",
16
+ app,
17
+ settings: {
18
+ baseSort: {
19
+ type: "choice",
20
+ component: "button-group",
21
+ label: "Sort Cache Entries",
22
+ options: [{
23
+ label: "ASC",
24
+ value: 1
25
+ }, {
26
+ label: "DESC",
27
+ value: -1
28
+ }],
29
+ defaultValue: 1
30
+ },
31
+ sortFn: {
32
+ type: "choice",
33
+ label: "Sort Function",
34
+ options: Object.keys(require_devtools_utils.sortFns).map((key) => ({
35
+ label: key,
36
+ value: key
37
+ })),
38
+ defaultValue: Object.keys(require_devtools_utils.sortFns)[0]
39
+ },
40
+ onlineMode: {
41
+ type: "choice",
42
+ component: "button-group",
43
+ label: "Online mode",
44
+ options: [{
45
+ label: "Online",
46
+ value: 1
47
+ }, {
48
+ label: "Offline",
49
+ value: 0
50
+ }],
51
+ defaultValue: 1
52
+ }
53
+ }
54
+ }, (api) => {
55
+ const initialSettings = api.getSettings();
56
+ _tanstack_query_core.onlineManager.setOnline(Boolean(initialSettings.onlineMode.valueOf()));
57
+ const queryCache = queryClient.getQueryCache();
58
+ api.addInspector({
59
+ id: pluginId,
60
+ label: pluginName,
61
+ icon: "api",
62
+ nodeActions: [
63
+ {
64
+ icon: "file_download",
65
+ tooltip: "Refetch",
66
+ action: (queryHash) => {
67
+ queryCache.get(queryHash)?.fetch();
68
+ }
69
+ },
70
+ {
71
+ icon: "alarm",
72
+ tooltip: "Invalidate",
73
+ action: (queryHash) => {
74
+ const query = queryCache.get(queryHash);
75
+ queryClient.invalidateQueries({
76
+ queryKey: query.queryKey,
77
+ exact: true
78
+ });
79
+ }
80
+ },
81
+ {
82
+ icon: "settings_backup_restore",
83
+ tooltip: "Reset",
84
+ action: (queryHash) => {
85
+ queryCache.get(queryHash)?.reset();
86
+ }
87
+ },
88
+ {
89
+ icon: "delete",
90
+ tooltip: "Remove",
91
+ action: (queryHash) => {
92
+ const query = queryCache.get(queryHash);
93
+ queryCache.remove(query);
94
+ }
95
+ },
96
+ {
97
+ icon: "hourglass_empty",
98
+ tooltip: "Force loading",
99
+ action: (queryHash) => {
100
+ queryCache.get(queryHash).setState({
101
+ data: void 0,
102
+ status: "pending"
103
+ });
104
+ }
105
+ },
106
+ {
107
+ icon: "error_outline",
108
+ tooltip: "Force error",
109
+ action: (queryHash) => {
110
+ queryCache.get(queryHash).setState({
111
+ data: void 0,
112
+ status: "error",
113
+ error: /* @__PURE__ */ new Error("Unknown error from devtools")
114
+ });
115
+ }
116
+ }
117
+ ]
118
+ });
119
+ api.addTimelineLayer({
120
+ id: pluginId,
121
+ label: pluginName,
122
+ color: 16767308
123
+ });
124
+ queryCache.subscribe((event) => {
125
+ api.sendInspectorTree(pluginId);
126
+ api.sendInspectorState(pluginId);
127
+ if ([
128
+ "added",
129
+ "removed",
130
+ "updated"
131
+ ].includes(event.type)) api.addTimelineEvent({
132
+ layerId: pluginId,
133
+ event: {
134
+ title: event.type,
135
+ subtitle: event.query.queryHash,
136
+ time: api.now(),
137
+ data: {
138
+ queryHash: event.query.queryHash,
139
+ ...event
140
+ }
141
+ }
142
+ });
143
+ });
144
+ api.on.setPluginSettings((payload) => {
145
+ if (payload.key === "onlineMode") _tanstack_query_core.onlineManager.setOnline(Boolean(payload.newValue));
146
+ });
147
+ api.on.getInspectorTree((payload) => {
148
+ if (payload.inspectorId === pluginId) {
149
+ const queries = queryCache.getAll();
150
+ const settings = api.getSettings();
151
+ payload.rootNodes = (payload.filter ? queries.filter((item) => (0, _tanstack_match_sorter_utils.rankItem)(item.queryHash, payload.filter).passed) : [...queries]).sort((a, b) => require_devtools_utils.sortFns[settings.sortFn](a, b) * settings.baseSort).map((query) => {
152
+ const stateLabel = require_devtools_utils.getQueryStateLabel(query);
153
+ return {
154
+ id: query.queryHash,
155
+ label: query.queryHash,
156
+ tags: [{
157
+ label: `${stateLabel} [${query.getObserversCount()}]`,
158
+ textColor: require_devtools_utils.getQueryStatusFg(query),
159
+ backgroundColor: require_devtools_utils.getQueryStatusBg(query)
160
+ }]
161
+ };
162
+ });
163
+ }
164
+ });
165
+ api.on.getInspectorState((payload) => {
166
+ if (payload.inspectorId === pluginId) {
167
+ const query = queryCache.get(payload.nodeId);
168
+ if (!query) return;
169
+ payload.state = {
170
+ " Query Details": [
171
+ {
172
+ key: "Query key",
173
+ value: query.queryHash
174
+ },
175
+ {
176
+ key: "Query status",
177
+ value: require_devtools_utils.getQueryStateLabel(query)
178
+ },
179
+ {
180
+ key: "Observers",
181
+ value: query.getObserversCount()
182
+ },
183
+ {
184
+ key: "Last Updated",
185
+ value: new Date(query.state.dataUpdatedAt).toLocaleTimeString()
186
+ }
187
+ ],
188
+ "Data Explorer": [{
189
+ key: "Data",
190
+ value: query.state.data
191
+ }],
192
+ "Query Explorer": [{
193
+ key: "Query",
194
+ value: query
195
+ }]
196
+ };
197
+ }
198
+ });
199
+ });
254
200
  }
255
- // Annotate the CommonJS export names for ESM import in node:
256
- 0 && (module.exports = {
257
- setupDevtools
258
- });
201
+ //#endregion
202
+ exports.setupDevtools = setupDevtools;
203
+
259
204
  //# sourceMappingURL=devtools.cjs.map