@tanstack/react-query 5.104.1 → 5.104.2

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 (347) hide show
  1. package/build/legacy/HydrationBoundary.cjs +2 -3
  2. package/build/legacy/HydrationBoundary.cjs.map +1 -1
  3. package/build/legacy/HydrationBoundary.d.cts +2 -3
  4. package/build/legacy/HydrationBoundary.d.cts.map +1 -1
  5. package/build/legacy/HydrationBoundary.d.ts +2 -3
  6. package/build/legacy/HydrationBoundary.d.ts.map +1 -1
  7. package/build/legacy/HydrationBoundary.js +2 -3
  8. package/build/legacy/HydrationBoundary.js.map +1 -1
  9. package/build/legacy/IsRestoringProvider.cjs +0 -1
  10. package/build/legacy/IsRestoringProvider.cjs.map +1 -1
  11. package/build/legacy/IsRestoringProvider.d.cts +0 -1
  12. package/build/legacy/IsRestoringProvider.d.cts.map +1 -1
  13. package/build/legacy/IsRestoringProvider.d.ts +0 -1
  14. package/build/legacy/IsRestoringProvider.d.ts.map +1 -1
  15. package/build/legacy/IsRestoringProvider.js +0 -1
  16. package/build/legacy/IsRestoringProvider.js.map +1 -1
  17. package/build/legacy/QueryClientProvider.cjs +3 -4
  18. package/build/legacy/QueryClientProvider.cjs.map +1 -1
  19. package/build/legacy/QueryClientProvider.d.cts +3 -4
  20. package/build/legacy/QueryClientProvider.d.cts.map +1 -1
  21. package/build/legacy/QueryClientProvider.d.ts +3 -4
  22. package/build/legacy/QueryClientProvider.d.ts.map +1 -1
  23. package/build/legacy/QueryClientProvider.js +3 -4
  24. package/build/legacy/QueryClientProvider.js.map +1 -1
  25. package/build/legacy/QueryErrorResetBoundary.cjs +5 -5
  26. package/build/legacy/QueryErrorResetBoundary.cjs.map +1 -1
  27. package/build/legacy/QueryErrorResetBoundary.d.cts +23 -5
  28. package/build/legacy/QueryErrorResetBoundary.d.cts.map +1 -1
  29. package/build/legacy/QueryErrorResetBoundary.d.ts +23 -5
  30. package/build/legacy/QueryErrorResetBoundary.d.ts.map +1 -1
  31. package/build/legacy/QueryErrorResetBoundary.js +5 -5
  32. package/build/legacy/QueryErrorResetBoundary.js.map +1 -1
  33. package/build/legacy/errorBoundaryUtils.cjs +21 -0
  34. package/build/legacy/errorBoundaryUtils.cjs.map +1 -1
  35. package/build/legacy/errorBoundaryUtils.d.cts +21 -0
  36. package/build/legacy/errorBoundaryUtils.d.cts.map +1 -1
  37. package/build/legacy/errorBoundaryUtils.d.ts +21 -0
  38. package/build/legacy/errorBoundaryUtils.d.ts.map +1 -1
  39. package/build/legacy/errorBoundaryUtils.js +21 -0
  40. package/build/legacy/errorBoundaryUtils.js.map +1 -1
  41. package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
  42. package/build/legacy/infiniteQueryOptions.d.cts +5 -16
  43. package/build/legacy/infiniteQueryOptions.d.cts.map +1 -1
  44. package/build/legacy/infiniteQueryOptions.d.ts +5 -16
  45. package/build/legacy/infiniteQueryOptions.d.ts.map +1 -1
  46. package/build/legacy/infiniteQueryOptions.js.map +1 -1
  47. package/build/legacy/mutationOptions.cjs.map +1 -1
  48. package/build/legacy/mutationOptions.d.cts +2 -6
  49. package/build/legacy/mutationOptions.d.cts.map +1 -1
  50. package/build/legacy/mutationOptions.d.ts +2 -6
  51. package/build/legacy/mutationOptions.d.ts.map +1 -1
  52. package/build/legacy/mutationOptions.js.map +1 -1
  53. package/build/legacy/queryOptions.cjs.map +1 -1
  54. package/build/legacy/queryOptions.d.cts +6 -16
  55. package/build/legacy/queryOptions.d.cts.map +1 -1
  56. package/build/legacy/queryOptions.d.ts +6 -16
  57. package/build/legacy/queryOptions.d.ts.map +1 -1
  58. package/build/legacy/queryOptions.js.map +1 -1
  59. package/build/legacy/suspense.cjs +27 -0
  60. package/build/legacy/suspense.cjs.map +1 -1
  61. package/build/legacy/suspense.d.cts +27 -0
  62. package/build/legacy/suspense.d.cts.map +1 -1
  63. package/build/legacy/suspense.d.ts +27 -0
  64. package/build/legacy/suspense.d.ts.map +1 -1
  65. package/build/legacy/suspense.js +27 -0
  66. package/build/legacy/suspense.js.map +1 -1
  67. package/build/legacy/types.cjs.map +1 -1
  68. package/build/legacy/types.d.cts +2 -22
  69. package/build/legacy/types.d.cts.map +1 -1
  70. package/build/legacy/types.d.ts +2 -22
  71. package/build/legacy/types.d.ts.map +1 -1
  72. package/build/legacy/types.js.map +1 -1
  73. package/build/legacy/useBaseQuery.cjs +13 -0
  74. package/build/legacy/useBaseQuery.cjs.map +1 -1
  75. package/build/legacy/useBaseQuery.d.cts +13 -0
  76. package/build/legacy/useBaseQuery.d.cts.map +1 -1
  77. package/build/legacy/useBaseQuery.d.ts +13 -0
  78. package/build/legacy/useBaseQuery.d.ts.map +1 -1
  79. package/build/legacy/useBaseQuery.js +13 -0
  80. package/build/legacy/useBaseQuery.js.map +1 -1
  81. package/build/legacy/useInfiniteQuery.cjs.map +1 -1
  82. package/build/legacy/useInfiniteQuery.d.cts +12 -21
  83. package/build/legacy/useInfiniteQuery.d.cts.map +1 -1
  84. package/build/legacy/useInfiniteQuery.d.ts +12 -21
  85. package/build/legacy/useInfiniteQuery.d.ts.map +1 -1
  86. package/build/legacy/useInfiniteQuery.js.map +1 -1
  87. package/build/legacy/useIsFetching.cjs +0 -3
  88. package/build/legacy/useIsFetching.cjs.map +1 -1
  89. package/build/legacy/useIsFetching.d.cts +0 -3
  90. package/build/legacy/useIsFetching.d.cts.map +1 -1
  91. package/build/legacy/useIsFetching.d.ts +0 -3
  92. package/build/legacy/useIsFetching.d.ts.map +1 -1
  93. package/build/legacy/useIsFetching.js +0 -3
  94. package/build/legacy/useIsFetching.js.map +1 -1
  95. package/build/legacy/useMutation.cjs +4 -8
  96. package/build/legacy/useMutation.cjs.map +1 -1
  97. package/build/legacy/useMutation.d.cts +4 -8
  98. package/build/legacy/useMutation.d.cts.map +1 -1
  99. package/build/legacy/useMutation.d.ts +4 -8
  100. package/build/legacy/useMutation.d.ts.map +1 -1
  101. package/build/legacy/useMutation.js +4 -8
  102. package/build/legacy/useMutation.js.map +1 -1
  103. package/build/legacy/useMutationState.cjs +7 -6
  104. package/build/legacy/useMutationState.cjs.map +1 -1
  105. package/build/legacy/useMutationState.d.cts +0 -6
  106. package/build/legacy/useMutationState.d.cts.map +1 -1
  107. package/build/legacy/useMutationState.d.ts +0 -6
  108. package/build/legacy/useMutationState.d.ts.map +1 -1
  109. package/build/legacy/useMutationState.js +7 -6
  110. package/build/legacy/useMutationState.js.map +1 -1
  111. package/build/legacy/usePrefetchInfiniteQuery.cjs +0 -3
  112. package/build/legacy/usePrefetchInfiniteQuery.cjs.map +1 -1
  113. package/build/legacy/usePrefetchInfiniteQuery.d.cts +0 -3
  114. package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -1
  115. package/build/legacy/usePrefetchInfiniteQuery.d.ts +0 -3
  116. package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -1
  117. package/build/legacy/usePrefetchInfiniteQuery.js +0 -3
  118. package/build/legacy/usePrefetchInfiniteQuery.js.map +1 -1
  119. package/build/legacy/usePrefetchQuery.cjs +0 -3
  120. package/build/legacy/usePrefetchQuery.cjs.map +1 -1
  121. package/build/legacy/usePrefetchQuery.d.cts +0 -3
  122. package/build/legacy/usePrefetchQuery.d.cts.map +1 -1
  123. package/build/legacy/usePrefetchQuery.d.ts +0 -3
  124. package/build/legacy/usePrefetchQuery.d.ts.map +1 -1
  125. package/build/legacy/usePrefetchQuery.js +0 -3
  126. package/build/legacy/usePrefetchQuery.js.map +1 -1
  127. package/build/legacy/useQueries.cjs +7 -8
  128. package/build/legacy/useQueries.cjs.map +1 -1
  129. package/build/legacy/useQueries.d.cts +7 -11
  130. package/build/legacy/useQueries.d.cts.map +1 -1
  131. package/build/legacy/useQueries.d.ts +7 -11
  132. package/build/legacy/useQueries.d.ts.map +1 -1
  133. package/build/legacy/useQueries.js +7 -8
  134. package/build/legacy/useQueries.js.map +1 -1
  135. package/build/legacy/useQuery.cjs.map +1 -1
  136. package/build/legacy/useQuery.d.cts +8 -13
  137. package/build/legacy/useQuery.d.cts.map +1 -1
  138. package/build/legacy/useQuery.d.ts +8 -13
  139. package/build/legacy/useQuery.d.ts.map +1 -1
  140. package/build/legacy/useQuery.js.map +1 -1
  141. package/build/legacy/useSuspenseInfiniteQuery.cjs +6 -8
  142. package/build/legacy/useSuspenseInfiniteQuery.cjs.map +1 -1
  143. package/build/legacy/useSuspenseInfiniteQuery.d.cts +6 -8
  144. package/build/legacy/useSuspenseInfiniteQuery.d.cts.map +1 -1
  145. package/build/legacy/useSuspenseInfiniteQuery.d.ts +6 -8
  146. package/build/legacy/useSuspenseInfiniteQuery.d.ts.map +1 -1
  147. package/build/legacy/useSuspenseInfiniteQuery.js +6 -8
  148. package/build/legacy/useSuspenseInfiniteQuery.js.map +1 -1
  149. package/build/legacy/useSuspenseQueries.cjs.map +1 -1
  150. package/build/legacy/useSuspenseQueries.d.cts +0 -9
  151. package/build/legacy/useSuspenseQueries.d.cts.map +1 -1
  152. package/build/legacy/useSuspenseQueries.d.ts +0 -9
  153. package/build/legacy/useSuspenseQueries.d.ts.map +1 -1
  154. package/build/legacy/useSuspenseQueries.js.map +1 -1
  155. package/build/legacy/useSuspenseQuery.cjs +4 -6
  156. package/build/legacy/useSuspenseQuery.cjs.map +1 -1
  157. package/build/legacy/useSuspenseQuery.d.cts +4 -6
  158. package/build/legacy/useSuspenseQuery.d.cts.map +1 -1
  159. package/build/legacy/useSuspenseQuery.d.ts +4 -6
  160. package/build/legacy/useSuspenseQuery.d.ts.map +1 -1
  161. package/build/legacy/useSuspenseQuery.js +4 -6
  162. package/build/legacy/useSuspenseQuery.js.map +1 -1
  163. package/build/modern/HydrationBoundary.cjs +2 -3
  164. package/build/modern/HydrationBoundary.cjs.map +1 -1
  165. package/build/modern/HydrationBoundary.d.cts +2 -3
  166. package/build/modern/HydrationBoundary.d.cts.map +1 -1
  167. package/build/modern/HydrationBoundary.d.ts +2 -3
  168. package/build/modern/HydrationBoundary.d.ts.map +1 -1
  169. package/build/modern/HydrationBoundary.js +2 -3
  170. package/build/modern/HydrationBoundary.js.map +1 -1
  171. package/build/modern/IsRestoringProvider.cjs +0 -1
  172. package/build/modern/IsRestoringProvider.cjs.map +1 -1
  173. package/build/modern/IsRestoringProvider.d.cts +0 -1
  174. package/build/modern/IsRestoringProvider.d.cts.map +1 -1
  175. package/build/modern/IsRestoringProvider.d.ts +0 -1
  176. package/build/modern/IsRestoringProvider.d.ts.map +1 -1
  177. package/build/modern/IsRestoringProvider.js +0 -1
  178. package/build/modern/IsRestoringProvider.js.map +1 -1
  179. package/build/modern/QueryClientProvider.cjs +3 -4
  180. package/build/modern/QueryClientProvider.cjs.map +1 -1
  181. package/build/modern/QueryClientProvider.d.cts +3 -4
  182. package/build/modern/QueryClientProvider.d.cts.map +1 -1
  183. package/build/modern/QueryClientProvider.d.ts +3 -4
  184. package/build/modern/QueryClientProvider.d.ts.map +1 -1
  185. package/build/modern/QueryClientProvider.js +3 -4
  186. package/build/modern/QueryClientProvider.js.map +1 -1
  187. package/build/modern/QueryErrorResetBoundary.cjs +5 -5
  188. package/build/modern/QueryErrorResetBoundary.cjs.map +1 -1
  189. package/build/modern/QueryErrorResetBoundary.d.cts +23 -5
  190. package/build/modern/QueryErrorResetBoundary.d.cts.map +1 -1
  191. package/build/modern/QueryErrorResetBoundary.d.ts +23 -5
  192. package/build/modern/QueryErrorResetBoundary.d.ts.map +1 -1
  193. package/build/modern/QueryErrorResetBoundary.js +5 -5
  194. package/build/modern/QueryErrorResetBoundary.js.map +1 -1
  195. package/build/modern/errorBoundaryUtils.cjs +21 -0
  196. package/build/modern/errorBoundaryUtils.cjs.map +1 -1
  197. package/build/modern/errorBoundaryUtils.d.cts +21 -0
  198. package/build/modern/errorBoundaryUtils.d.cts.map +1 -1
  199. package/build/modern/errorBoundaryUtils.d.ts +21 -0
  200. package/build/modern/errorBoundaryUtils.d.ts.map +1 -1
  201. package/build/modern/errorBoundaryUtils.js +21 -0
  202. package/build/modern/errorBoundaryUtils.js.map +1 -1
  203. package/build/modern/infiniteQueryOptions.cjs.map +1 -1
  204. package/build/modern/infiniteQueryOptions.d.cts +5 -16
  205. package/build/modern/infiniteQueryOptions.d.cts.map +1 -1
  206. package/build/modern/infiniteQueryOptions.d.ts +5 -16
  207. package/build/modern/infiniteQueryOptions.d.ts.map +1 -1
  208. package/build/modern/infiniteQueryOptions.js.map +1 -1
  209. package/build/modern/mutationOptions.cjs.map +1 -1
  210. package/build/modern/mutationOptions.d.cts +2 -6
  211. package/build/modern/mutationOptions.d.cts.map +1 -1
  212. package/build/modern/mutationOptions.d.ts +2 -6
  213. package/build/modern/mutationOptions.d.ts.map +1 -1
  214. package/build/modern/mutationOptions.js.map +1 -1
  215. package/build/modern/queryOptions.cjs.map +1 -1
  216. package/build/modern/queryOptions.d.cts +6 -16
  217. package/build/modern/queryOptions.d.cts.map +1 -1
  218. package/build/modern/queryOptions.d.ts +6 -16
  219. package/build/modern/queryOptions.d.ts.map +1 -1
  220. package/build/modern/queryOptions.js.map +1 -1
  221. package/build/modern/suspense.cjs +27 -0
  222. package/build/modern/suspense.cjs.map +1 -1
  223. package/build/modern/suspense.d.cts +27 -0
  224. package/build/modern/suspense.d.cts.map +1 -1
  225. package/build/modern/suspense.d.ts +27 -0
  226. package/build/modern/suspense.d.ts.map +1 -1
  227. package/build/modern/suspense.js +27 -0
  228. package/build/modern/suspense.js.map +1 -1
  229. package/build/modern/types.cjs.map +1 -1
  230. package/build/modern/types.d.cts +2 -22
  231. package/build/modern/types.d.cts.map +1 -1
  232. package/build/modern/types.d.ts +2 -22
  233. package/build/modern/types.d.ts.map +1 -1
  234. package/build/modern/types.js.map +1 -1
  235. package/build/modern/useBaseQuery.cjs +13 -0
  236. package/build/modern/useBaseQuery.cjs.map +1 -1
  237. package/build/modern/useBaseQuery.d.cts +13 -0
  238. package/build/modern/useBaseQuery.d.cts.map +1 -1
  239. package/build/modern/useBaseQuery.d.ts +13 -0
  240. package/build/modern/useBaseQuery.d.ts.map +1 -1
  241. package/build/modern/useBaseQuery.js +13 -0
  242. package/build/modern/useBaseQuery.js.map +1 -1
  243. package/build/modern/useInfiniteQuery.cjs.map +1 -1
  244. package/build/modern/useInfiniteQuery.d.cts +12 -21
  245. package/build/modern/useInfiniteQuery.d.cts.map +1 -1
  246. package/build/modern/useInfiniteQuery.d.ts +12 -21
  247. package/build/modern/useInfiniteQuery.d.ts.map +1 -1
  248. package/build/modern/useInfiniteQuery.js.map +1 -1
  249. package/build/modern/useIsFetching.cjs +0 -3
  250. package/build/modern/useIsFetching.cjs.map +1 -1
  251. package/build/modern/useIsFetching.d.cts +0 -3
  252. package/build/modern/useIsFetching.d.cts.map +1 -1
  253. package/build/modern/useIsFetching.d.ts +0 -3
  254. package/build/modern/useIsFetching.d.ts.map +1 -1
  255. package/build/modern/useIsFetching.js +0 -3
  256. package/build/modern/useIsFetching.js.map +1 -1
  257. package/build/modern/useMutation.cjs +4 -8
  258. package/build/modern/useMutation.cjs.map +1 -1
  259. package/build/modern/useMutation.d.cts +4 -8
  260. package/build/modern/useMutation.d.cts.map +1 -1
  261. package/build/modern/useMutation.d.ts +4 -8
  262. package/build/modern/useMutation.d.ts.map +1 -1
  263. package/build/modern/useMutation.js +4 -8
  264. package/build/modern/useMutation.js.map +1 -1
  265. package/build/modern/useMutationState.cjs +7 -6
  266. package/build/modern/useMutationState.cjs.map +1 -1
  267. package/build/modern/useMutationState.d.cts +0 -6
  268. package/build/modern/useMutationState.d.cts.map +1 -1
  269. package/build/modern/useMutationState.d.ts +0 -6
  270. package/build/modern/useMutationState.d.ts.map +1 -1
  271. package/build/modern/useMutationState.js +7 -6
  272. package/build/modern/useMutationState.js.map +1 -1
  273. package/build/modern/usePrefetchInfiniteQuery.cjs +0 -3
  274. package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -1
  275. package/build/modern/usePrefetchInfiniteQuery.d.cts +0 -3
  276. package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
  277. package/build/modern/usePrefetchInfiniteQuery.d.ts +0 -3
  278. package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
  279. package/build/modern/usePrefetchInfiniteQuery.js +0 -3
  280. package/build/modern/usePrefetchInfiniteQuery.js.map +1 -1
  281. package/build/modern/usePrefetchQuery.cjs +0 -3
  282. package/build/modern/usePrefetchQuery.cjs.map +1 -1
  283. package/build/modern/usePrefetchQuery.d.cts +0 -3
  284. package/build/modern/usePrefetchQuery.d.cts.map +1 -1
  285. package/build/modern/usePrefetchQuery.d.ts +0 -3
  286. package/build/modern/usePrefetchQuery.d.ts.map +1 -1
  287. package/build/modern/usePrefetchQuery.js +0 -3
  288. package/build/modern/usePrefetchQuery.js.map +1 -1
  289. package/build/modern/useQueries.cjs +7 -8
  290. package/build/modern/useQueries.cjs.map +1 -1
  291. package/build/modern/useQueries.d.cts +7 -11
  292. package/build/modern/useQueries.d.cts.map +1 -1
  293. package/build/modern/useQueries.d.ts +7 -11
  294. package/build/modern/useQueries.d.ts.map +1 -1
  295. package/build/modern/useQueries.js +7 -8
  296. package/build/modern/useQueries.js.map +1 -1
  297. package/build/modern/useQuery.cjs.map +1 -1
  298. package/build/modern/useQuery.d.cts +8 -13
  299. package/build/modern/useQuery.d.cts.map +1 -1
  300. package/build/modern/useQuery.d.ts +8 -13
  301. package/build/modern/useQuery.d.ts.map +1 -1
  302. package/build/modern/useQuery.js.map +1 -1
  303. package/build/modern/useSuspenseInfiniteQuery.cjs +6 -8
  304. package/build/modern/useSuspenseInfiniteQuery.cjs.map +1 -1
  305. package/build/modern/useSuspenseInfiniteQuery.d.cts +6 -8
  306. package/build/modern/useSuspenseInfiniteQuery.d.cts.map +1 -1
  307. package/build/modern/useSuspenseInfiniteQuery.d.ts +6 -8
  308. package/build/modern/useSuspenseInfiniteQuery.d.ts.map +1 -1
  309. package/build/modern/useSuspenseInfiniteQuery.js +6 -8
  310. package/build/modern/useSuspenseInfiniteQuery.js.map +1 -1
  311. package/build/modern/useSuspenseQueries.cjs.map +1 -1
  312. package/build/modern/useSuspenseQueries.d.cts +0 -9
  313. package/build/modern/useSuspenseQueries.d.cts.map +1 -1
  314. package/build/modern/useSuspenseQueries.d.ts +0 -9
  315. package/build/modern/useSuspenseQueries.d.ts.map +1 -1
  316. package/build/modern/useSuspenseQueries.js.map +1 -1
  317. package/build/modern/useSuspenseQuery.cjs +4 -6
  318. package/build/modern/useSuspenseQuery.cjs.map +1 -1
  319. package/build/modern/useSuspenseQuery.d.cts +4 -6
  320. package/build/modern/useSuspenseQuery.d.cts.map +1 -1
  321. package/build/modern/useSuspenseQuery.d.ts +4 -6
  322. package/build/modern/useSuspenseQuery.d.ts.map +1 -1
  323. package/build/modern/useSuspenseQuery.js +4 -6
  324. package/build/modern/useSuspenseQuery.js.map +1 -1
  325. package/package.json +6 -6
  326. package/src/HydrationBoundary.tsx +4 -5
  327. package/src/IsRestoringProvider.ts +0 -1
  328. package/src/QueryClientProvider.tsx +3 -4
  329. package/src/QueryErrorResetBoundary.tsx +30 -6
  330. package/src/errorBoundaryUtils.ts +21 -0
  331. package/src/infiniteQueryOptions.ts +5 -16
  332. package/src/mutationOptions.ts +2 -6
  333. package/src/queryOptions.ts +8 -17
  334. package/src/suspense.ts +29 -1
  335. package/src/types.ts +2 -22
  336. package/src/useBaseQuery.ts +13 -0
  337. package/src/useInfiniteQuery.ts +12 -21
  338. package/src/useIsFetching.ts +0 -3
  339. package/src/useMutation.ts +4 -8
  340. package/src/useMutationState.ts +7 -6
  341. package/src/usePrefetchInfiniteQuery.tsx +0 -3
  342. package/src/usePrefetchQuery.tsx +0 -3
  343. package/src/useQueries.ts +7 -11
  344. package/src/useQuery.ts +8 -13
  345. package/src/useSuspenseInfiniteQuery.ts +6 -8
  346. package/src/useSuspenseQueries.ts +0 -9
  347. package/src/useSuspenseQuery.ts +4 -6
@@ -1 +1 @@
1
- {"version":3,"file":"usePrefetchInfiniteQuery.cjs","names":["useQueryClient","noop"],"sources":["../../src/usePrefetchInfiniteQuery.tsx"],"sourcesContent":["import { noop } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\n\nimport type {\n DefaultError,\n InfiniteData,\n QueryClient,\n QueryKey,\n} from '@tanstack/query-core'\nimport type { UsePrefetchInfiniteQueryOptions } from './types'\n\n/**\n * `usePrefetchInfiniteQuery` does not return anything, it should be used just to fire a prefetch during render,\n * before a suspense boundary that wraps a component that uses `useSuspenseInfiniteQuery`. You can pass\n * everything to `usePrefetchInfiniteQuery` that you can pass to `queryClient.infiniteQuery`, though\n * `queryKey`, `initialPageParam`, and `getNextPageParam` are always required, and `queryFn` is required unless\n * a default query function has been defined.\n *\n * `getNextPageParam` receives both the last page of the infinite list of data and the full array of all pages,\n * as well as pageParam information, and should return a single variable that will be passed to your query\n * function as `context.pageParam`. Return `undefined` or `null` to indicate there is no next page available.\n *\n * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left\n * over from a previous attempt — so calling this on every render is cheap and won't refetch data that's\n * already there or already in flight.\n *\n * @param options - The {@link UsePrefetchInfiniteQueryOptions} to use — everything you can pass to `queryClient.infiniteQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns `void` — nothing is returned.\n *\n * @example\n * ```tsx\n * import { Suspense } from 'react'\n * import { infiniteQueryOptions, usePrefetchInfiniteQuery } from '@tanstack/react-query'\n *\n * const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * function App() {\n * // Fire the prefetch during render, before the suspense boundary below.\n * usePrefetchInfiniteQuery(projectsOptions)\n *\n * return (\n * <Suspense fallback={<h1>Loading projects...</h1>}>\n * <Projects />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function usePrefetchInfiniteQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UsePrefetchInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: QueryClient,\n): void {\n const client = useQueryClient(queryClient)\n\n if (!client.getQueryState(options.queryKey)) {\n void client.infiniteQuery(options).catch(noop)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,SAAgB,yBAOd,SAOA,aACM;CACN,MAAM,SAASA,4BAAAA,eAAe,WAAW;CAEzC,IAAI,CAAC,OAAO,cAAc,QAAQ,QAAQ,GACxC,OAAY,cAAc,OAAO,CAAC,CAAC,MAAMC,qBAAAA,IAAI;AAEjD"}
1
+ {"version":3,"file":"usePrefetchInfiniteQuery.cjs","names":["useQueryClient","noop"],"sources":["../../src/usePrefetchInfiniteQuery.tsx"],"sourcesContent":["import { noop } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\n\nimport type {\n DefaultError,\n InfiniteData,\n QueryClient,\n QueryKey,\n} from '@tanstack/query-core'\nimport type { UsePrefetchInfiniteQueryOptions } from './types'\n\n/**\n * `usePrefetchInfiniteQuery` does not return anything, it should be used just to fire a prefetch during render,\n * before a suspense boundary that wraps a component that uses `useSuspenseInfiniteQuery`. You can pass\n * everything to `usePrefetchInfiniteQuery` that you can pass to `queryClient.infiniteQuery`, though\n * `queryKey`, `initialPageParam`, and `getNextPageParam` are always required, and `queryFn` is required unless\n * a default query function has been defined.\n *\n * `getNextPageParam` receives both the last page of the infinite list of data and the full array of all pages,\n * as well as pageParam information, and should return a single variable that will be passed to your query\n * function as `context.pageParam`. Return `undefined` or `null` to indicate there is no next page available.\n *\n * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left\n * over from a previous attempt — so calling this on every render is cheap and won't refetch data that's\n * already there or already in flight.\n * @param options - The {@link UsePrefetchInfiniteQueryOptions} to use — everything you can pass to `queryClient.infiniteQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @example\n * ```tsx\n * import { Suspense } from 'react'\n * import { infiniteQueryOptions, usePrefetchInfiniteQuery } from '@tanstack/react-query'\n *\n * const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * function App() {\n * // Fire the prefetch during render, before the suspense boundary below.\n * usePrefetchInfiniteQuery(projectsOptions)\n *\n * return (\n * <Suspense fallback={<h1>Loading projects...</h1>}>\n * <Projects />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function usePrefetchInfiniteQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UsePrefetchInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: QueryClient,\n): void {\n const client = useQueryClient(queryClient)\n\n if (!client.getQueryState(options.queryKey)) {\n void client.infiniteQuery(options).catch(noop)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,SAAgB,yBAOd,SAOA,aACM;CACN,MAAM,SAASA,4BAAAA,eAAe,WAAW;CAEzC,IAAI,CAAC,OAAO,cAAc,QAAQ,QAAQ,GACxC,OAAY,cAAc,OAAO,CAAC,CAAC,MAAMC,qBAAAA,IAAI;AAEjD"}
@@ -15,12 +15,9 @@ import { DefaultError, InfiniteData, QueryClient, QueryKey } from "@tanstack/que
15
15
  * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left
16
16
  * over from a previous attempt — so calling this on every render is cheap and won't refetch data that's
17
17
  * already there or already in flight.
18
- *
19
18
  * @param options - The {@link UsePrefetchInfiniteQueryOptions} to use — everything you can pass to `queryClient.infiniteQuery`.
20
19
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
21
20
  * be used.
22
- * @returns `void` — nothing is returned.
23
- *
24
21
  * @example
25
22
  * ```tsx
26
23
  * import { Suspense } from 'react'
@@ -1 +1 @@
1
- {"version":3,"file":"usePrefetchInfiniteQuery.d.cts","names":[],"sources":["../../src/usePrefetchInfiniteQuery.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAuDgB,yBACd,wBACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,gCACP,cACA,QACA,OACA,WACA,aAEF,cAAc"}
1
+ {"version":3,"file":"usePrefetchInfiniteQuery.d.cts","names":[],"sources":["../../src/usePrefetchInfiniteQuery.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAoDgB,yBACd,wBACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,gCACP,cACA,QACA,OACA,WACA,aAEF,cAAc"}
@@ -15,12 +15,9 @@ import { DefaultError, InfiniteData, QueryClient, QueryKey } from "@tanstack/que
15
15
  * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left
16
16
  * over from a previous attempt — so calling this on every render is cheap and won't refetch data that's
17
17
  * already there or already in flight.
18
- *
19
18
  * @param options - The {@link UsePrefetchInfiniteQueryOptions} to use — everything you can pass to `queryClient.infiniteQuery`.
20
19
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
21
20
  * be used.
22
- * @returns `void` — nothing is returned.
23
- *
24
21
  * @example
25
22
  * ```tsx
26
23
  * import { Suspense } from 'react'
@@ -1 +1 @@
1
- {"version":3,"file":"usePrefetchInfiniteQuery.d.ts","names":[],"sources":["../../src/usePrefetchInfiniteQuery.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAuDgB,yBACd,wBACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,gCACP,cACA,QACA,OACA,WACA,aAEF,cAAc"}
1
+ {"version":3,"file":"usePrefetchInfiniteQuery.d.ts","names":[],"sources":["../../src/usePrefetchInfiniteQuery.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAoDgB,yBACd,wBACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,gCACP,cACA,QACA,OACA,WACA,aAEF,cAAc"}
@@ -15,12 +15,9 @@ import { noop } from "@tanstack/query-core";
15
15
  * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left
16
16
  * over from a previous attempt — so calling this on every render is cheap and won't refetch data that's
17
17
  * already there or already in flight.
18
- *
19
18
  * @param options - The {@link UsePrefetchInfiniteQueryOptions} to use — everything you can pass to `queryClient.infiniteQuery`.
20
19
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
21
20
  * be used.
22
- * @returns `void` — nothing is returned.
23
- *
24
21
  * @example
25
22
  * ```tsx
26
23
  * import { Suspense } from 'react'
@@ -1 +1 @@
1
- {"version":3,"file":"usePrefetchInfiniteQuery.js","names":[],"sources":["../../src/usePrefetchInfiniteQuery.tsx"],"sourcesContent":["import { noop } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\n\nimport type {\n DefaultError,\n InfiniteData,\n QueryClient,\n QueryKey,\n} from '@tanstack/query-core'\nimport type { UsePrefetchInfiniteQueryOptions } from './types'\n\n/**\n * `usePrefetchInfiniteQuery` does not return anything, it should be used just to fire a prefetch during render,\n * before a suspense boundary that wraps a component that uses `useSuspenseInfiniteQuery`. You can pass\n * everything to `usePrefetchInfiniteQuery` that you can pass to `queryClient.infiniteQuery`, though\n * `queryKey`, `initialPageParam`, and `getNextPageParam` are always required, and `queryFn` is required unless\n * a default query function has been defined.\n *\n * `getNextPageParam` receives both the last page of the infinite list of data and the full array of all pages,\n * as well as pageParam information, and should return a single variable that will be passed to your query\n * function as `context.pageParam`. Return `undefined` or `null` to indicate there is no next page available.\n *\n * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left\n * over from a previous attempt — so calling this on every render is cheap and won't refetch data that's\n * already there or already in flight.\n *\n * @param options - The {@link UsePrefetchInfiniteQueryOptions} to use — everything you can pass to `queryClient.infiniteQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns `void` — nothing is returned.\n *\n * @example\n * ```tsx\n * import { Suspense } from 'react'\n * import { infiniteQueryOptions, usePrefetchInfiniteQuery } from '@tanstack/react-query'\n *\n * const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * function App() {\n * // Fire the prefetch during render, before the suspense boundary below.\n * usePrefetchInfiniteQuery(projectsOptions)\n *\n * return (\n * <Suspense fallback={<h1>Loading projects...</h1>}>\n * <Projects />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function usePrefetchInfiniteQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UsePrefetchInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: QueryClient,\n): void {\n const client = useQueryClient(queryClient)\n\n if (!client.getQueryState(options.queryKey)) {\n void client.infiniteQuery(options).catch(noop)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,SAAgB,yBAOd,SAOA,aACM;CACN,MAAM,SAAS,eAAe,WAAW;CAEzC,IAAI,CAAC,OAAO,cAAc,QAAQ,QAAQ,GACxC,OAAY,cAAc,OAAO,CAAC,CAAC,MAAM,IAAI;AAEjD"}
1
+ {"version":3,"file":"usePrefetchInfiniteQuery.js","names":[],"sources":["../../src/usePrefetchInfiniteQuery.tsx"],"sourcesContent":["import { noop } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\n\nimport type {\n DefaultError,\n InfiniteData,\n QueryClient,\n QueryKey,\n} from '@tanstack/query-core'\nimport type { UsePrefetchInfiniteQueryOptions } from './types'\n\n/**\n * `usePrefetchInfiniteQuery` does not return anything, it should be used just to fire a prefetch during render,\n * before a suspense boundary that wraps a component that uses `useSuspenseInfiniteQuery`. You can pass\n * everything to `usePrefetchInfiniteQuery` that you can pass to `queryClient.infiniteQuery`, though\n * `queryKey`, `initialPageParam`, and `getNextPageParam` are always required, and `queryFn` is required unless\n * a default query function has been defined.\n *\n * `getNextPageParam` receives both the last page of the infinite list of data and the full array of all pages,\n * as well as pageParam information, and should return a single variable that will be passed to your query\n * function as `context.pageParam`. Return `undefined` or `null` to indicate there is no next page available.\n *\n * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left\n * over from a previous attempt — so calling this on every render is cheap and won't refetch data that's\n * already there or already in flight.\n * @param options - The {@link UsePrefetchInfiniteQueryOptions} to use — everything you can pass to `queryClient.infiniteQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @example\n * ```tsx\n * import { Suspense } from 'react'\n * import { infiniteQueryOptions, usePrefetchInfiniteQuery } from '@tanstack/react-query'\n *\n * const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * function App() {\n * // Fire the prefetch during render, before the suspense boundary below.\n * usePrefetchInfiniteQuery(projectsOptions)\n *\n * return (\n * <Suspense fallback={<h1>Loading projects...</h1>}>\n * <Projects />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function usePrefetchInfiniteQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UsePrefetchInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: QueryClient,\n): void {\n const client = useQueryClient(queryClient)\n\n if (!client.getQueryState(options.queryKey)) {\n void client.infiniteQuery(options).catch(noop)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,SAAgB,yBAOd,SAOA,aACM;CACN,MAAM,SAAS,eAAe,WAAW;CAEzC,IAAI,CAAC,OAAO,cAAc,QAAQ,QAAQ,GACxC,OAAY,cAAc,OAAO,CAAC,CAAC,MAAM,IAAI;AAEjD"}
@@ -11,12 +11,9 @@ let _tanstack_query_core = require("@tanstack/query-core");
11
11
  * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left
12
12
  * over from a previous attempt — so calling this on every render is cheap and won't refetch data that's
13
13
  * already there or already in flight.
14
- *
15
14
  * @param options - The {@link UsePrefetchQueryOptions} to use — everything you can pass to `queryClient.query`.
16
15
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
17
16
  * be used.
18
- * @returns `void` — nothing is returned.
19
- *
20
17
  * @example
21
18
  * ```tsx
22
19
  * import { Suspense } from 'react'
@@ -1 +1 @@
1
- {"version":3,"file":"usePrefetchQuery.cjs","names":["useQueryClient","noop"],"sources":["../../src/usePrefetchQuery.tsx"],"sourcesContent":["import { noop } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\n\nimport type { DefaultError, QueryClient, QueryKey } from '@tanstack/query-core'\nimport type { UsePrefetchQueryOptions } from './types'\n\n/**\n * `usePrefetchQuery` does not return anything, it should be used just to fire a prefetch during render, before\n * a suspense boundary that wraps a component that uses `useSuspenseQuery`. You can pass everything to\n * `usePrefetchQuery` that you can pass to `queryClient.query`, though `queryKey` is always required, and\n * `queryFn` is required unless a default query function has been defined.\n *\n * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left\n * over from a previous attempt — so calling this on every render is cheap and won't refetch data that's\n * already there or already in flight.\n *\n * @param options - The {@link UsePrefetchQueryOptions} to use — everything you can pass to `queryClient.query`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns `void` — nothing is returned.\n *\n * @example\n * ```tsx\n * import { Suspense } from 'react'\n * import { usePrefetchQuery } from '@tanstack/react-query'\n *\n * function App() {\n * // Fire the prefetch during render, before the suspense boundary below.\n * usePrefetchQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n *\n * return (\n * <Suspense fallback={<h1>Loading posts...</h1>}>\n * <Posts />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function usePrefetchQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UsePrefetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n queryClient?: QueryClient,\n): void {\n const client = useQueryClient(queryClient)\n\n if (!client.getQueryState(options.queryKey)) {\n void client.query(options).catch(noop)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,SAAgB,iBAOd,SAOA,aACM;CACN,MAAM,SAASA,4BAAAA,eAAe,WAAW;CAEzC,IAAI,CAAC,OAAO,cAAc,QAAQ,QAAQ,GACxC,OAAY,MAAM,OAAO,CAAC,CAAC,MAAMC,qBAAAA,IAAI;AAEzC"}
1
+ {"version":3,"file":"usePrefetchQuery.cjs","names":["useQueryClient","noop"],"sources":["../../src/usePrefetchQuery.tsx"],"sourcesContent":["import { noop } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\n\nimport type { DefaultError, QueryClient, QueryKey } from '@tanstack/query-core'\nimport type { UsePrefetchQueryOptions } from './types'\n\n/**\n * `usePrefetchQuery` does not return anything, it should be used just to fire a prefetch during render, before\n * a suspense boundary that wraps a component that uses `useSuspenseQuery`. You can pass everything to\n * `usePrefetchQuery` that you can pass to `queryClient.query`, though `queryKey` is always required, and\n * `queryFn` is required unless a default query function has been defined.\n *\n * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left\n * over from a previous attempt — so calling this on every render is cheap and won't refetch data that's\n * already there or already in flight.\n * @param options - The {@link UsePrefetchQueryOptions} to use — everything you can pass to `queryClient.query`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @example\n * ```tsx\n * import { Suspense } from 'react'\n * import { usePrefetchQuery } from '@tanstack/react-query'\n *\n * function App() {\n * // Fire the prefetch during render, before the suspense boundary below.\n * usePrefetchQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n *\n * return (\n * <Suspense fallback={<h1>Loading posts...</h1>}>\n * <Posts />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function usePrefetchQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UsePrefetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n queryClient?: QueryClient,\n): void {\n const client = useQueryClient(queryClient)\n\n if (!client.getQueryState(options.queryKey)) {\n void client.query(options).catch(noop)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,iBAOd,SAOA,aACM;CACN,MAAM,SAASA,4BAAAA,eAAe,WAAW;CAEzC,IAAI,CAAC,OAAO,cAAc,QAAQ,QAAQ,GACxC,OAAY,MAAM,OAAO,CAAC,CAAC,MAAMC,qBAAAA,IAAI;AAEzC"}
@@ -10,12 +10,9 @@ import { DefaultError, QueryClient, QueryKey } from "@tanstack/query-core";
10
10
  * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left
11
11
  * over from a previous attempt — so calling this on every render is cheap and won't refetch data that's
12
12
  * already there or already in flight.
13
- *
14
13
  * @param options - The {@link UsePrefetchQueryOptions} to use — everything you can pass to `queryClient.query`.
15
14
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
16
15
  * be used.
17
- * @returns `void` — nothing is returned.
18
- *
19
16
  * @example
20
17
  * ```tsx
21
18
  * import { Suspense } from 'react'
@@ -1 +1 @@
1
- {"version":3,"file":"usePrefetchQuery.d.cts","names":[],"sources":["../../src/usePrefetchQuery.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAyCgB,iBACd,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,UAE7B,SAAS,wBACP,cACA,QACA,OACA,YACA,YAEF,cAAc"}
1
+ {"version":3,"file":"usePrefetchQuery.d.cts","names":[],"sources":["../../src/usePrefetchQuery.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAsCgB,iBACd,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,UAE7B,SAAS,wBACP,cACA,QACA,OACA,YACA,YAEF,cAAc"}
@@ -10,12 +10,9 @@ import { DefaultError, QueryClient, QueryKey } from "@tanstack/query-core";
10
10
  * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left
11
11
  * over from a previous attempt — so calling this on every render is cheap and won't refetch data that's
12
12
  * already there or already in flight.
13
- *
14
13
  * @param options - The {@link UsePrefetchQueryOptions} to use — everything you can pass to `queryClient.query`.
15
14
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
16
15
  * be used.
17
- * @returns `void` — nothing is returned.
18
- *
19
16
  * @example
20
17
  * ```tsx
21
18
  * import { Suspense } from 'react'
@@ -1 +1 @@
1
- {"version":3,"file":"usePrefetchQuery.d.ts","names":[],"sources":["../../src/usePrefetchQuery.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAyCgB,iBACd,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,UAE7B,SAAS,wBACP,cACA,QACA,OACA,YACA,YAEF,cAAc"}
1
+ {"version":3,"file":"usePrefetchQuery.d.ts","names":[],"sources":["../../src/usePrefetchQuery.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAsCgB,iBACd,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,UAE7B,SAAS,wBACP,cACA,QACA,OACA,YACA,YAEF,cAAc"}
@@ -10,12 +10,9 @@ import { noop } from "@tanstack/query-core";
10
10
  * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left
11
11
  * over from a previous attempt — so calling this on every render is cheap and won't refetch data that's
12
12
  * already there or already in flight.
13
- *
14
13
  * @param options - The {@link UsePrefetchQueryOptions} to use — everything you can pass to `queryClient.query`.
15
14
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
16
15
  * be used.
17
- * @returns `void` — nothing is returned.
18
- *
19
16
  * @example
20
17
  * ```tsx
21
18
  * import { Suspense } from 'react'
@@ -1 +1 @@
1
- {"version":3,"file":"usePrefetchQuery.js","names":[],"sources":["../../src/usePrefetchQuery.tsx"],"sourcesContent":["import { noop } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\n\nimport type { DefaultError, QueryClient, QueryKey } from '@tanstack/query-core'\nimport type { UsePrefetchQueryOptions } from './types'\n\n/**\n * `usePrefetchQuery` does not return anything, it should be used just to fire a prefetch during render, before\n * a suspense boundary that wraps a component that uses `useSuspenseQuery`. You can pass everything to\n * `usePrefetchQuery` that you can pass to `queryClient.query`, though `queryKey` is always required, and\n * `queryFn` is required unless a default query function has been defined.\n *\n * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left\n * over from a previous attempt — so calling this on every render is cheap and won't refetch data that's\n * already there or already in flight.\n *\n * @param options - The {@link UsePrefetchQueryOptions} to use — everything you can pass to `queryClient.query`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns `void` — nothing is returned.\n *\n * @example\n * ```tsx\n * import { Suspense } from 'react'\n * import { usePrefetchQuery } from '@tanstack/react-query'\n *\n * function App() {\n * // Fire the prefetch during render, before the suspense boundary below.\n * usePrefetchQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n *\n * return (\n * <Suspense fallback={<h1>Loading posts...</h1>}>\n * <Posts />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function usePrefetchQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UsePrefetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n queryClient?: QueryClient,\n): void {\n const client = useQueryClient(queryClient)\n\n if (!client.getQueryState(options.queryKey)) {\n void client.query(options).catch(noop)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,SAAgB,iBAOd,SAOA,aACM;CACN,MAAM,SAAS,eAAe,WAAW;CAEzC,IAAI,CAAC,OAAO,cAAc,QAAQ,QAAQ,GACxC,OAAY,MAAM,OAAO,CAAC,CAAC,MAAM,IAAI;AAEzC"}
1
+ {"version":3,"file":"usePrefetchQuery.js","names":[],"sources":["../../src/usePrefetchQuery.tsx"],"sourcesContent":["import { noop } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\n\nimport type { DefaultError, QueryClient, QueryKey } from '@tanstack/query-core'\nimport type { UsePrefetchQueryOptions } from './types'\n\n/**\n * `usePrefetchQuery` does not return anything, it should be used just to fire a prefetch during render, before\n * a suspense boundary that wraps a component that uses `useSuspenseQuery`. You can pass everything to\n * `usePrefetchQuery` that you can pass to `queryClient.query`, though `queryKey` is always required, and\n * `queryFn` is required unless a default query function has been defined.\n *\n * The prefetch is skipped if the query already has any cached state — including a `pending`/`error` state left\n * over from a previous attempt — so calling this on every render is cheap and won't refetch data that's\n * already there or already in flight.\n * @param options - The {@link UsePrefetchQueryOptions} to use — everything you can pass to `queryClient.query`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @example\n * ```tsx\n * import { Suspense } from 'react'\n * import { usePrefetchQuery } from '@tanstack/react-query'\n *\n * function App() {\n * // Fire the prefetch during render, before the suspense boundary below.\n * usePrefetchQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n *\n * return (\n * <Suspense fallback={<h1>Loading posts...</h1>}>\n * <Posts />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function usePrefetchQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UsePrefetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n queryClient?: QueryClient,\n): void {\n const client = useQueryClient(queryClient)\n\n if (!client.getQueryState(options.queryKey)) {\n void client.query(options).catch(noop)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,iBAOd,SAOA,aACM;CACN,MAAM,SAAS,eAAe,WAAW;CAEzC,IAAI,CAAC,OAAO,cAAc,QAAQ,QAAQ,GACxC,OAAY,MAAM,OAAO,CAAC,CAAC,MAAM,IAAI;AAEzC"}
@@ -23,7 +23,13 @@ let _tanstack_query_core = require("@tanstack/query-core");
23
23
  *
24
24
  * The `combine` option can be used to combine the results of the queries into a single value. The result will
25
25
  * be structurally shared to be as referentially stable as possible.
26
- *
26
+ * @param options - The `queries` array to run, and the optional `combine` and `subscribed` options.
27
+ * @param queryClient - Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context
28
+ * will be used.
29
+ * @returns The combined result. Without `combine`, this is an array with all the query results, in the same
30
+ * order as the input. When `combine` is provided, this is the value returned by `combine` instead.
31
+ * @throws {Error} The error of the first query that should be thrown to the nearest error boundary (see
32
+ * `throwOnError`). While suspending, it throws a promise instead.
27
33
  * @remarks The `combine` function only re-runs if it changed referentially, or if any of the query results
28
34
  * changed. An inlined `combine` function, as shown in the example below, therefore runs on every render — wrap
29
35
  * it in `useCallback`, or extract it to a stable function reference if it doesn't have any dependencies, to
@@ -39,11 +45,6 @@ let _tanstack_query_core = require("@tanstack/query-core");
39
45
  *
40
46
  * `placeholderData` is supported here too, but unlike `useQuery`, it doesn't receive information from
41
47
  * previously rendered queries, because the number of queries can differ between renders.
42
- * @param queryClient - Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context
43
- * will be used.
44
- * @returns The combined result. Without `combine`, this is an array with all the query results, in the same
45
- * order as the input. When `combine` is provided, this is the value returned by `combine` instead.
46
- *
47
48
  * @example
48
49
  * ```tsx
49
50
  * import { useQueries } from '@tanstack/react-query'
@@ -68,7 +69,6 @@ let _tanstack_query_core = require("@tanstack/query-core");
68
69
  * )
69
70
  * }
70
71
  * ```
71
- *
72
72
  * @example
73
73
  * Combining results into a single value:
74
74
  * ```tsx
@@ -101,7 +101,6 @@ let _tanstack_query_core = require("@tanstack/query-core");
101
101
  * )
102
102
  * }
103
103
  * ```
104
- *
105
104
  * @example
106
105
  * Typing `select` via {@link queryOptions}. Note that spreading a `queryOptions` result and overriding
107
106
  * `select` inline still falls back to `unknown` — wrap the spread in `queryOptions` again so the override is
@@ -1 +1 @@
1
- {"version":3,"file":"useQueries.cjs","names":["useQueryClient","useIsRestoring","useQueryErrorResetBoundary","React","QueriesObserver","notifyManager","noop","shouldSuspend","QueryObserver","fetchOptimistic","getHasError"],"sources":["../../src/useQueries.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport {\n QueriesObserver,\n QueryObserver,\n noop,\n notifyManager,\n} from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\nimport { useIsRestoring } from './IsRestoringProvider'\nimport { useQueryErrorResetBoundary } from './QueryErrorResetBoundary'\nimport {\n ensurePreventErrorBoundaryRetry,\n getHasError,\n useClearResetErrorBoundary,\n} from './errorBoundaryUtils'\nimport {\n ensureSuspenseTimers,\n fetchOptimistic,\n shouldSuspend,\n} from './suspense'\nimport type {\n DefinedUseQueryResult,\n UseQueryOptions,\n UseQueryResult,\n} from './types'\nimport type {\n DefaultError,\n OmitKeyof,\n QueriesObserverOptions,\n QueriesPlaceholderDataFunction,\n QueryClient,\n QueryFunction,\n QueryKey,\n QueryObserverOptions,\n ThrowOnError,\n} from '@tanstack/query-core'\n\n// This defines the `UseQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.\n// `placeholderData` function always gets undefined passed\ntype UseQueryOptionsForUseQueries<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'placeholderData' | 'subscribed'\n> & {\n placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>\n}\n\n// Avoid TS depth-limit error in case of large array literal\ntype MAXIMUM_DEPTH = 20\n\n// Widen the type of the symbol to enable type inference even if skipToken is not immutable.\ntype SkipTokenForUseQueries = symbol\n\ntype GetUseQueryOptionsForUseQueries<T> =\n // Part 1: responsible for applying explicit type parameter to function arguments, if object { queryFnData: TQueryFnData, error: TError, data: TData }\n T extends {\n queryFnData: infer TQueryFnData\n error?: infer TError\n data: infer TData\n }\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? UseQueryOptionsForUseQueries<unknown, TError, TData>\n : // Part 2: responsible for applying explicit type parameter to function arguments, if tuple [TQueryFnData, TError, TData]\n T extends [infer TQueryFnData, infer TError, infer TData]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData>\n : T extends [infer TQueryFnData, infer TError]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? UseQueryOptionsForUseQueries<TQueryFnData>\n : // Part 3: responsible for inferring and enforcing type if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, infer TQueryKey>\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseQueryOptionsForUseQueries<\n TQueryFnData,\n unknown extends TError ? DefaultError : TError,\n unknown extends TData ? TQueryFnData : TData,\n TQueryKey\n >\n : // Fallback\n UseQueryOptionsForUseQueries\n\n// A defined initialData setting should return a DefinedUseQueryResult rather than UseQueryResult\ntype GetDefinedOrUndefinedQueryResult<T, TData, TError = unknown> = T extends {\n initialData?: infer TInitialData\n}\n ? unknown extends TInitialData\n ? UseQueryResult<TData, TError>\n : TInitialData extends TData\n ? DefinedUseQueryResult<TData, TError>\n : TInitialData extends () => infer TInitialDataResult\n ? unknown extends TInitialDataResult\n ? UseQueryResult<TData, TError>\n : TInitialDataResult extends TData\n ? DefinedUseQueryResult<TData, TError>\n : UseQueryResult<TData, TError>\n : UseQueryResult<TData, TError>\n : UseQueryResult<TData, TError>\n\ntype GetUseQueryResult<T> =\n // Part 1: responsible for mapping explicit type parameter to function result, if object\n T extends { queryFnData: any; error?: infer TError; data: infer TData }\n ? GetDefinedOrUndefinedQueryResult<T, TData, TError>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? GetDefinedOrUndefinedQueryResult<T, TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? GetDefinedOrUndefinedQueryResult<T, TData, TError>\n : // Part 2: responsible for mapping explicit type parameter to function result, if tuple\n T extends [any, infer TError, infer TData]\n ? GetDefinedOrUndefinedQueryResult<T, TData, TError>\n : T extends [infer TQueryFnData, infer TError]\n ? GetDefinedOrUndefinedQueryResult<T, TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? GetDefinedOrUndefinedQueryResult<T, TQueryFnData>\n : // Part 3: responsible for mapping inferred type to results, if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, any>\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? GetDefinedOrUndefinedQueryResult<\n T,\n unknown extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n : // Fallback\n UseQueryResult\n\n/**\n * The `queries` array accepted by `useQueries`. Recursively unwraps each tuple element so every entry's\n * `queryFn`/`select`/`throwOnError` are inferred individually, up to 20 elements — past that, a tuple falls\n * back to a single homogeneous options type.\n *\n * An opaque array (e.g. `unknown[]`) is returned as-is; a non-tuple array whose element type structurally\n * matches a query options object is mapped per-element instead, still inferring each entry individually; any\n * other non-tuple array — one whose element type doesn't match the expected options shape — falls back to\n * that same homogeneous options type too.\n *\n * @template T - The type of the `queries` array as written at the call site.\n * @template TResults - The internal accumulator that this type builds during recursion. It is not meant\n * to be set explicitly.\n * @template TDepth - The internal recursion-depth counter, checked against the 20-element limit. It is not\n * meant to be set explicitly.\n */\nexport type QueriesOptions<\n T extends Array<any>,\n TResults extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<UseQueryOptionsForUseQueries>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResults, GetUseQueryOptionsForUseQueries<Head>]\n : T extends [infer Head, ...infer Tails]\n ? QueriesOptions<\n [...Tails],\n [...TResults, GetUseQueryOptionsForUseQueries<Head>],\n [...TDepth, 1]\n >\n : ReadonlyArray<unknown> extends T\n ? T\n : // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogeneous type!\n // use this to infer the param types in the case of Array.map() argument\n T extends Array<\n UseQueryOptionsForUseQueries<\n infer TQueryFnData,\n infer TError,\n infer TData,\n infer TQueryKey\n >\n >\n ? Array<\n UseQueryOptionsForUseQueries<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >\n >\n : // Fallback\n Array<UseQueryOptionsForUseQueries>\n\n/**\n * The result type returned by `useQueries`, when no `combine` is provided. Mirrors {@link QueriesOptions}: each\n * tuple element's result type is inferred individually, up to 20 elements. A non-tuple array is mapped\n * per-element instead, still inferring each entry individually; only past 20 elements does this fall back to a\n * single homogeneous {@link UseQueryResult} type.\n *\n * @template T - The type of the `queries` array, as inferred by {@link QueriesOptions}.\n * @template TResults - The internal accumulator that this type builds during recursion. It is not meant\n * to be set explicitly.\n * @template TDepth - The internal recursion-depth counter, checked against the 20-element limit. It is not\n * meant to be set explicitly.\n */\nexport type QueriesResults<\n T extends Array<any>,\n TResults extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<UseQueryResult>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResults, GetUseQueryResult<Head>]\n : T extends [infer Head, ...infer Tails]\n ? QueriesResults<\n [...Tails],\n [...TResults, GetUseQueryResult<Head>],\n [...TDepth, 1]\n >\n : { [K in keyof T]: GetUseQueryResult<T[K]> }\n\n/**\n * The `useQueries` hook can be used to fetch a variable number of queries.\n *\n * The `queries` key accepts an array with query option objects mostly identical to `useQuery` — the top-level\n * `subscribed` option isn't accepted per query (see `placeholderData` below for another difference). A custom\n * `QueryClient` is supplied once, as `useQueries`' own top-level second argument, rather than per query.\n *\n * Having the same query key more than once in the array of query objects may cause some data to be shared\n * between queries. To avoid this, consider de-duplicating the queries and map the results back to the desired\n * structure.\n *\n * The `combine` option can be used to combine the results of the queries into a single value. The result will\n * be structurally shared to be as referentially stable as possible.\n *\n * @remarks The `combine` function only re-runs if it changed referentially, or if any of the query results\n * changed. An inlined `combine` function, as shown in the example below, therefore runs on every render — wrap\n * it in `useCallback`, or extract it to a stable function reference if it doesn't have any dependencies, to\n * avoid that.\n *\n * Unlike `useQuery`, `useQueries` cannot infer the `data` argument of an _inline_ `select` from its sibling\n * `queryFn`. Because `useQueries` infers the type of the whole `queries` array at once, the `select` parameter\n * of a query object written inline cannot be contextually typed from that same object's `queryFn`, so it falls\n * back to `unknown` — a [known TypeScript limitation](https://github.com/TanStack/query/issues/6556). Annotate\n * the `select` parameter explicitly, or define the query with {@link queryOptions}, which resolves its types in\n * a single object _before_ it reaches `useQueries`, to work around this — see the example below. The same\n * limitation applies to {@link useSuspenseQueries}.\n *\n * `placeholderData` is supported here too, but unlike `useQuery`, it doesn't receive information from\n * previously rendered queries, because the number of queries can differ between renders.\n * @param queryClient - Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The combined result. Without `combine`, this is an array with all the query results, in the same\n * order as the input. When `combine` is provided, this is the value returned by `combine` instead.\n *\n * @example\n * ```tsx\n * import { useQueries } from '@tanstack/react-query'\n *\n * function Posts({ ids }: { ids: Array<number> }) {\n * const postQueries = useQueries({\n * queries: ids.map((id) => ({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * staleTime: Infinity,\n * })),\n * })\n *\n * return (\n * <ul>\n * {postQueries.map((query, index) => {\n * if (query.isPending) return <li key={ids[index]}>Loading...</li>\n * if (query.isError) return <li key={ids[index]}>Error: {query.error.message}</li>\n * return <li key={ids[index]}>{query.data.title}</li>\n * })}\n * </ul>\n * )\n * }\n * ```\n *\n * @example\n * Combining results into a single value:\n * ```tsx\n * import { useQueries } from '@tanstack/react-query'\n *\n * function Posts({ ids }: { ids: Array<number> }) {\n * const { data, isPending, isError } = useQueries({\n * queries: ids.map((id) => ({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })),\n * combine: (postQueries) => {\n * return {\n * data: postQueries.map((query) => query.data),\n * isPending: postQueries.some((query) => query.isPending),\n * isError: postQueries.some((query) => query.isError),\n * }\n * },\n * })\n *\n * if (isPending) return 'Loading...'\n * if (isError) return 'Error loading posts'\n *\n * return (\n * <ul>\n * {data.map((post) => (\n * <li key={post?.id}>{post?.title}</li>\n * ))}\n * </ul>\n * )\n * }\n * ```\n *\n * @example\n * Typing `select` via {@link queryOptions}. Note that spreading a `queryOptions` result and overriding\n * `select` inline still falls back to `unknown` — wrap the spread in `queryOptions` again so the override is\n * resolved before it reaches `useQueries`:\n * ```tsx\n * import { queryOptions, useQueries } from '@tanstack/react-query'\n *\n * const postOptions = (id: number) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function PostTitle({ id }: { id: number }) {\n * const [{ data: broken }] = useQueries({\n * queries: [\n * {\n * ...postOptions(id),\n * // ❌ `data` is `unknown` here\n * select: (data) => data.title,\n * },\n * ],\n * })\n *\n * const [{ data: fixed }] = useQueries({\n * queries: [\n * queryOptions({\n * ...postOptions(id),\n * // ✅ `data` is `Post`\n * select: (data) => data.title,\n * }),\n * ],\n * })\n *\n * return <h1>{fixed}</h1>\n * }\n * ```\n */\nexport function useQueries<\n T extends Array<any>,\n TCombinedResult = QueriesResults<T>,\n>(\n {\n queries,\n ...options\n }: {\n /**\n * An array with query option objects, mostly identical to `useQuery` — except that `queryClient` and\n * `subscribed` aren't accepted per-query (`subscribed` is a top-level option here instead), and\n * `placeholderData` accepts a {@link QueriesPlaceholderDataFunction}, which is called with `previousData`\n * and `previousQuery` always `undefined`, rather than `useQuery`'s placeholder function.\n */\n queries:\n | readonly [...QueriesOptions<T>]\n | readonly [...{ [K in keyof T]: GetUseQueryOptionsForUseQueries<T[K]> }]\n /**\n * Use this to combine the results of the queries into a single value. The result will be structurally\n * shared to be as referentially stable as possible.\n */\n combine?: (result: QueriesResults<T>) => TCombinedResult\n /**\n * Set this to `false` to unsubscribe this observer from updates to the query cache.\n *\n * @defaultValue true\n */\n subscribed?: boolean\n },\n queryClient?: QueryClient,\n): TCombinedResult {\n const client = useQueryClient(queryClient)\n const isRestoring = useIsRestoring()\n const errorResetBoundary = useQueryErrorResetBoundary()\n const subscribed = options.subscribed !== false\n\n const defaultedQueries = React.useMemo(\n () =>\n queries.map((opts) => {\n const defaultedOptions = client.defaultQueryOptions(\n opts as QueryObserverOptions,\n )\n\n // Make sure the results are already in fetching state before subscribing or updating options\n defaultedOptions._optimisticResults = isRestoring\n ? 'isRestoring'\n : subscribed\n ? 'optimistic'\n : undefined\n\n return defaultedOptions\n }),\n [queries, client, isRestoring, subscribed],\n )\n\n defaultedQueries.forEach((queryOptions) => {\n ensureSuspenseTimers(queryOptions)\n const query = client.getQueryCache().get(queryOptions.queryHash)\n ensurePreventErrorBoundaryRetry(queryOptions, errorResetBoundary, query)\n })\n\n useClearResetErrorBoundary(errorResetBoundary)\n\n const [observer] = React.useState(\n () =>\n new QueriesObserver<TCombinedResult>(\n client,\n defaultedQueries,\n options as QueriesObserverOptions<TCombinedResult>,\n ),\n )\n\n // note: this must be called before useSyncExternalStore\n const [optimisticResult, getCombinedResult, trackResult] =\n observer.getOptimisticResult(\n defaultedQueries,\n (options as QueriesObserverOptions<TCombinedResult>).combine,\n )\n\n const shouldSubscribe = !isRestoring && subscribed\n React.useSyncExternalStore(\n React.useCallback(\n (onStoreChange) =>\n shouldSubscribe\n ? observer.subscribe(notifyManager.batchCalls(onStoreChange))\n : noop,\n [observer, shouldSubscribe],\n ),\n () => observer.getCurrentResult(),\n () => observer.getCurrentResult(),\n )\n\n React.useEffect(() => {\n observer.setQueries(\n defaultedQueries,\n options as QueriesObserverOptions<TCombinedResult>,\n )\n }, [defaultedQueries, options, observer])\n\n const shouldAtLeastOneSuspend = optimisticResult.some((result, index) =>\n shouldSuspend(defaultedQueries[index], result),\n )\n\n const suspensePromises = shouldAtLeastOneSuspend\n ? optimisticResult.flatMap((result, index) => {\n const opts = defaultedQueries[index]\n\n if (opts && shouldSuspend(opts, result)) {\n const queryObserver = new QueryObserver(client, opts)\n return fetchOptimistic(opts, queryObserver, errorResetBoundary)\n }\n return []\n })\n : []\n\n if (suspensePromises.length > 0) {\n throw Promise.all(suspensePromises)\n }\n const firstSingleResultWhichShouldThrow = optimisticResult.find(\n (result, index) => {\n const query = defaultedQueries[index]\n return (\n query &&\n getHasError({\n result,\n errorResetBoundary,\n throwOnError: query.throwOnError,\n query: client.getQueryCache().get(query.queryHash),\n suspense: query.suspense,\n })\n )\n },\n )\n\n if (firstSingleResultWhichShouldThrow) {\n throw firstSingleResultWhichShouldThrow.error\n }\n\n return getCombinedResult(trackResult())\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsWA,SAAgB,WAId,EACE,SACA,GAAG,WAuBL,aACiB;CACjB,MAAM,SAASA,4BAAAA,eAAe,WAAW;CACzC,MAAM,cAAcC,4BAAAA,eAAe;CACnC,MAAM,qBAAqBC,gCAAAA,2BAA2B;CACtD,MAAM,aAAa,QAAQ,eAAe;CAE1C,MAAM,mBAAmBC,MAAM,cAE3B,QAAQ,KAAK,SAAS;EACpB,MAAM,mBAAmB,OAAO,oBAC9B,IACF;EAGA,iBAAiB,qBAAqB,cAClC,gBACA,aACE,eACA,KAAA;EAEN,OAAO;CACT,CAAC,GACH;EAAC;EAAS;EAAQ;EAAa;CAAU,CAC3C;CAEA,iBAAiB,SAAS,iBAAiB;EACzC,iBAAA,qBAAqB,YAAY;EACjC,MAAM,QAAQ,OAAO,cAAc,CAAC,CAAC,IAAI,aAAa,SAAS;EAC/D,2BAAA,gCAAgC,cAAc,oBAAoB,KAAK;CACzE,CAAC;CAED,2BAAA,2BAA2B,kBAAkB;CAE7C,MAAM,CAAC,YAAYA,MAAM,eAErB,IAAIC,qBAAAA,gBACF,QACA,kBACA,OACF,CACJ;CAGA,MAAM,CAAC,kBAAkB,mBAAmB,eAC1C,SAAS,oBACP,kBACC,QAAoD,OACvD;CAEF,MAAM,kBAAkB,CAAC,eAAe;CACxC,MAAM,qBACJD,MAAM,aACH,kBACC,kBACI,SAAS,UAAUE,qBAAAA,cAAc,WAAW,aAAa,CAAC,IAC1DC,qBAAAA,MACN,CAAC,UAAU,eAAe,CAC5B,SACM,SAAS,iBAAiB,SAC1B,SAAS,iBAAiB,CAClC;CAEA,MAAM,gBAAgB;EACpB,SAAS,WACP,kBACA,OACF;CACF,GAAG;EAAC;EAAkB;EAAS;CAAQ,CAAC;CAMxC,MAAM,mBAJ0B,iBAAiB,MAAM,QAAQ,UAC7DC,iBAAAA,cAAc,iBAAiB,QAAQ,MAAM,CAGA,IAC3C,iBAAiB,SAAS,QAAQ,UAAU;EAC1C,MAAM,OAAO,iBAAiB;EAE9B,IAAI,QAAQA,iBAAAA,cAAc,MAAM,MAAM,GAAG;GACvC,MAAM,gBAAgB,IAAIC,qBAAAA,cAAc,QAAQ,IAAI;GACpD,OAAOC,iBAAAA,gBAAgB,MAAM,eAAe,kBAAkB;EAChE;EACA,OAAO,CAAC;CACV,CAAC,IACD,CAAC;CAEL,IAAI,iBAAiB,SAAS,GAC5B,MAAM,QAAQ,IAAI,gBAAgB;CAEpC,MAAM,oCAAoC,iBAAiB,MACxD,QAAQ,UAAU;EACjB,MAAM,QAAQ,iBAAiB;EAC/B,OACE,SACAC,2BAAAA,YAAY;GACV;GACA;GACA,cAAc,MAAM;GACpB,OAAO,OAAO,cAAc,CAAC,CAAC,IAAI,MAAM,SAAS;GACjD,UAAU,MAAM;EAClB,CAAC;CAEL,CACF;CAEA,IAAI,mCACF,MAAM,kCAAkC;CAG1C,OAAO,kBAAkB,YAAY,CAAC;AACxC"}
1
+ {"version":3,"file":"useQueries.cjs","names":["useQueryClient","useIsRestoring","useQueryErrorResetBoundary","React","QueriesObserver","notifyManager","noop","shouldSuspend","QueryObserver","fetchOptimistic","getHasError"],"sources":["../../src/useQueries.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport {\n QueriesObserver,\n QueryObserver,\n noop,\n notifyManager,\n} from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\nimport { useIsRestoring } from './IsRestoringProvider'\nimport { useQueryErrorResetBoundary } from './QueryErrorResetBoundary'\nimport {\n ensurePreventErrorBoundaryRetry,\n getHasError,\n useClearResetErrorBoundary,\n} from './errorBoundaryUtils'\nimport {\n ensureSuspenseTimers,\n fetchOptimistic,\n shouldSuspend,\n} from './suspense'\nimport type {\n DefinedUseQueryResult,\n UseQueryOptions,\n UseQueryResult,\n} from './types'\nimport type {\n DefaultError,\n OmitKeyof,\n QueriesObserverOptions,\n QueriesPlaceholderDataFunction,\n QueryClient,\n QueryFunction,\n QueryKey,\n QueryObserverOptions,\n ThrowOnError,\n} from '@tanstack/query-core'\n\n// This defines the `UseQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.\n// `placeholderData` function always gets undefined passed\ntype UseQueryOptionsForUseQueries<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'placeholderData' | 'subscribed'\n> & {\n placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>\n}\n\n// Avoid TS depth-limit error in case of large array literal\ntype MAXIMUM_DEPTH = 20\n\n// Widen the type of the symbol to enable type inference even if skipToken is not immutable.\ntype SkipTokenForUseQueries = symbol\n\ntype GetUseQueryOptionsForUseQueries<T> =\n // Part 1: responsible for applying explicit type parameter to function arguments, if object { queryFnData: TQueryFnData, error: TError, data: TData }\n T extends {\n queryFnData: infer TQueryFnData\n error?: infer TError\n data: infer TData\n }\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? UseQueryOptionsForUseQueries<unknown, TError, TData>\n : // Part 2: responsible for applying explicit type parameter to function arguments, if tuple [TQueryFnData, TError, TData]\n T extends [infer TQueryFnData, infer TError, infer TData]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData>\n : T extends [infer TQueryFnData, infer TError]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? UseQueryOptionsForUseQueries<TQueryFnData>\n : // Part 3: responsible for inferring and enforcing type if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, infer TQueryKey>\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseQueryOptionsForUseQueries<\n TQueryFnData,\n unknown extends TError ? DefaultError : TError,\n unknown extends TData ? TQueryFnData : TData,\n TQueryKey\n >\n : // Fallback\n UseQueryOptionsForUseQueries\n\n// A defined initialData setting should return a DefinedUseQueryResult rather than UseQueryResult\ntype GetDefinedOrUndefinedQueryResult<T, TData, TError = unknown> = T extends {\n initialData?: infer TInitialData\n}\n ? unknown extends TInitialData\n ? UseQueryResult<TData, TError>\n : TInitialData extends TData\n ? DefinedUseQueryResult<TData, TError>\n : TInitialData extends () => infer TInitialDataResult\n ? unknown extends TInitialDataResult\n ? UseQueryResult<TData, TError>\n : TInitialDataResult extends TData\n ? DefinedUseQueryResult<TData, TError>\n : UseQueryResult<TData, TError>\n : UseQueryResult<TData, TError>\n : UseQueryResult<TData, TError>\n\ntype GetUseQueryResult<T> =\n // Part 1: responsible for mapping explicit type parameter to function result, if object\n T extends { queryFnData: any; error?: infer TError; data: infer TData }\n ? GetDefinedOrUndefinedQueryResult<T, TData, TError>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? GetDefinedOrUndefinedQueryResult<T, TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? GetDefinedOrUndefinedQueryResult<T, TData, TError>\n : // Part 2: responsible for mapping explicit type parameter to function result, if tuple\n T extends [any, infer TError, infer TData]\n ? GetDefinedOrUndefinedQueryResult<T, TData, TError>\n : T extends [infer TQueryFnData, infer TError]\n ? GetDefinedOrUndefinedQueryResult<T, TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? GetDefinedOrUndefinedQueryResult<T, TQueryFnData>\n : // Part 3: responsible for mapping inferred type to results, if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, any>\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? GetDefinedOrUndefinedQueryResult<\n T,\n unknown extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n : // Fallback\n UseQueryResult\n\n/**\n * The `queries` array accepted by `useQueries`. Recursively unwraps each tuple element so every entry's\n * `queryFn`/`select`/`throwOnError` are inferred individually, up to 20 elements — past that, a tuple falls\n * back to a single homogeneous options type.\n *\n * An opaque array (e.g. `unknown[]`) is returned as-is; a non-tuple array whose element type structurally\n * matches a query options object is mapped per-element instead, still inferring each entry individually; any\n * other non-tuple array — one whose element type doesn't match the expected options shape — falls back to\n * that same homogeneous options type too.\n * @template T - The type of the `queries` array as written at the call site.\n * @template TResults - The internal accumulator that this type builds during recursion. It is not meant\n * to be set explicitly.\n * @template TDepth - The internal recursion-depth counter, checked against the 20-element limit. It is not\n * meant to be set explicitly.\n */\nexport type QueriesOptions<\n T extends Array<any>,\n TResults extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<UseQueryOptionsForUseQueries>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResults, GetUseQueryOptionsForUseQueries<Head>]\n : T extends [infer Head, ...infer Tails]\n ? QueriesOptions<\n [...Tails],\n [...TResults, GetUseQueryOptionsForUseQueries<Head>],\n [...TDepth, 1]\n >\n : ReadonlyArray<unknown> extends T\n ? T\n : // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogeneous type!\n // use this to infer the param types in the case of Array.map() argument\n T extends Array<\n UseQueryOptionsForUseQueries<\n infer TQueryFnData,\n infer TError,\n infer TData,\n infer TQueryKey\n >\n >\n ? Array<\n UseQueryOptionsForUseQueries<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >\n >\n : // Fallback\n Array<UseQueryOptionsForUseQueries>\n\n/**\n * The result type returned by `useQueries`, when no `combine` is provided. Mirrors {@link QueriesOptions}: each\n * tuple element's result type is inferred individually, up to 20 elements. A non-tuple array is mapped\n * per-element instead, still inferring each entry individually; only past 20 elements does this fall back to a\n * single homogeneous {@link UseQueryResult} type.\n * @template T - The type of the `queries` array, as inferred by {@link QueriesOptions}.\n * @template TResults - The internal accumulator that this type builds during recursion. It is not meant\n * to be set explicitly.\n * @template TDepth - The internal recursion-depth counter, checked against the 20-element limit. It is not\n * meant to be set explicitly.\n */\nexport type QueriesResults<\n T extends Array<any>,\n TResults extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<UseQueryResult>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResults, GetUseQueryResult<Head>]\n : T extends [infer Head, ...infer Tails]\n ? QueriesResults<\n [...Tails],\n [...TResults, GetUseQueryResult<Head>],\n [...TDepth, 1]\n >\n : { [K in keyof T]: GetUseQueryResult<T[K]> }\n\n/**\n * The `useQueries` hook can be used to fetch a variable number of queries.\n *\n * The `queries` key accepts an array with query option objects mostly identical to `useQuery` — the top-level\n * `subscribed` option isn't accepted per query (see `placeholderData` below for another difference). A custom\n * `QueryClient` is supplied once, as `useQueries`' own top-level second argument, rather than per query.\n *\n * Having the same query key more than once in the array of query objects may cause some data to be shared\n * between queries. To avoid this, consider de-duplicating the queries and map the results back to the desired\n * structure.\n *\n * The `combine` option can be used to combine the results of the queries into a single value. The result will\n * be structurally shared to be as referentially stable as possible.\n * @param options - The `queries` array to run, and the optional `combine` and `subscribed` options.\n * @param queryClient - Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The combined result. Without `combine`, this is an array with all the query results, in the same\n * order as the input. When `combine` is provided, this is the value returned by `combine` instead.\n * @throws {Error} The error of the first query that should be thrown to the nearest error boundary (see\n * `throwOnError`). While suspending, it throws a promise instead.\n * @remarks The `combine` function only re-runs if it changed referentially, or if any of the query results\n * changed. An inlined `combine` function, as shown in the example below, therefore runs on every render — wrap\n * it in `useCallback`, or extract it to a stable function reference if it doesn't have any dependencies, to\n * avoid that.\n *\n * Unlike `useQuery`, `useQueries` cannot infer the `data` argument of an _inline_ `select` from its sibling\n * `queryFn`. Because `useQueries` infers the type of the whole `queries` array at once, the `select` parameter\n * of a query object written inline cannot be contextually typed from that same object's `queryFn`, so it falls\n * back to `unknown` — a [known TypeScript limitation](https://github.com/TanStack/query/issues/6556). Annotate\n * the `select` parameter explicitly, or define the query with {@link queryOptions}, which resolves its types in\n * a single object _before_ it reaches `useQueries`, to work around this — see the example below. The same\n * limitation applies to {@link useSuspenseQueries}.\n *\n * `placeholderData` is supported here too, but unlike `useQuery`, it doesn't receive information from\n * previously rendered queries, because the number of queries can differ between renders.\n * @example\n * ```tsx\n * import { useQueries } from '@tanstack/react-query'\n *\n * function Posts({ ids }: { ids: Array<number> }) {\n * const postQueries = useQueries({\n * queries: ids.map((id) => ({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * staleTime: Infinity,\n * })),\n * })\n *\n * return (\n * <ul>\n * {postQueries.map((query, index) => {\n * if (query.isPending) return <li key={ids[index]}>Loading...</li>\n * if (query.isError) return <li key={ids[index]}>Error: {query.error.message}</li>\n * return <li key={ids[index]}>{query.data.title}</li>\n * })}\n * </ul>\n * )\n * }\n * ```\n * @example\n * Combining results into a single value:\n * ```tsx\n * import { useQueries } from '@tanstack/react-query'\n *\n * function Posts({ ids }: { ids: Array<number> }) {\n * const { data, isPending, isError } = useQueries({\n * queries: ids.map((id) => ({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })),\n * combine: (postQueries) => {\n * return {\n * data: postQueries.map((query) => query.data),\n * isPending: postQueries.some((query) => query.isPending),\n * isError: postQueries.some((query) => query.isError),\n * }\n * },\n * })\n *\n * if (isPending) return 'Loading...'\n * if (isError) return 'Error loading posts'\n *\n * return (\n * <ul>\n * {data.map((post) => (\n * <li key={post?.id}>{post?.title}</li>\n * ))}\n * </ul>\n * )\n * }\n * ```\n * @example\n * Typing `select` via {@link queryOptions}. Note that spreading a `queryOptions` result and overriding\n * `select` inline still falls back to `unknown` — wrap the spread in `queryOptions` again so the override is\n * resolved before it reaches `useQueries`:\n * ```tsx\n * import { queryOptions, useQueries } from '@tanstack/react-query'\n *\n * const postOptions = (id: number) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function PostTitle({ id }: { id: number }) {\n * const [{ data: broken }] = useQueries({\n * queries: [\n * {\n * ...postOptions(id),\n * // ❌ `data` is `unknown` here\n * select: (data) => data.title,\n * },\n * ],\n * })\n *\n * const [{ data: fixed }] = useQueries({\n * queries: [\n * queryOptions({\n * ...postOptions(id),\n * // ✅ `data` is `Post`\n * select: (data) => data.title,\n * }),\n * ],\n * })\n *\n * return <h1>{fixed}</h1>\n * }\n * ```\n */\nexport function useQueries<\n T extends Array<any>,\n TCombinedResult = QueriesResults<T>,\n>(\n {\n queries,\n ...options\n }: {\n /**\n * An array with query option objects, mostly identical to `useQuery` — except that `queryClient` and\n * `subscribed` aren't accepted per-query (`subscribed` is a top-level option here instead), and\n * `placeholderData` accepts a {@link QueriesPlaceholderDataFunction}, which is called with `previousData`\n * and `previousQuery` always `undefined`, rather than `useQuery`'s placeholder function.\n */\n queries:\n | readonly [...QueriesOptions<T>]\n | readonly [...{ [K in keyof T]: GetUseQueryOptionsForUseQueries<T[K]> }]\n /**\n * Use this to combine the results of the queries into a single value. The result will be structurally\n * shared to be as referentially stable as possible.\n */\n combine?: (result: QueriesResults<T>) => TCombinedResult\n /**\n * Set this to `false` to unsubscribe this observer from updates to the query cache.\n * @defaultValue true\n */\n subscribed?: boolean\n },\n queryClient?: QueryClient,\n): TCombinedResult {\n const client = useQueryClient(queryClient)\n const isRestoring = useIsRestoring()\n const errorResetBoundary = useQueryErrorResetBoundary()\n const subscribed = options.subscribed !== false\n\n const defaultedQueries = React.useMemo(\n () =>\n queries.map((opts) => {\n const defaultedOptions = client.defaultQueryOptions(\n opts as QueryObserverOptions,\n )\n\n // Make sure the results are already in fetching state before subscribing or updating options\n defaultedOptions._optimisticResults = isRestoring\n ? 'isRestoring'\n : subscribed\n ? 'optimistic'\n : undefined\n\n return defaultedOptions\n }),\n [queries, client, isRestoring, subscribed],\n )\n\n defaultedQueries.forEach((queryOptions) => {\n ensureSuspenseTimers(queryOptions)\n const query = client.getQueryCache().get(queryOptions.queryHash)\n ensurePreventErrorBoundaryRetry(queryOptions, errorResetBoundary, query)\n })\n\n useClearResetErrorBoundary(errorResetBoundary)\n\n const [observer] = React.useState(\n () =>\n new QueriesObserver<TCombinedResult>(\n client,\n defaultedQueries,\n options as QueriesObserverOptions<TCombinedResult>,\n ),\n )\n\n // note: this must be called before useSyncExternalStore\n const [optimisticResult, getCombinedResult, trackResult] =\n observer.getOptimisticResult(\n defaultedQueries,\n (options as QueriesObserverOptions<TCombinedResult>).combine,\n )\n\n const shouldSubscribe = !isRestoring && subscribed\n React.useSyncExternalStore(\n React.useCallback(\n (onStoreChange) =>\n shouldSubscribe\n ? observer.subscribe(notifyManager.batchCalls(onStoreChange))\n : noop,\n [observer, shouldSubscribe],\n ),\n () => observer.getCurrentResult(),\n () => observer.getCurrentResult(),\n )\n\n React.useEffect(() => {\n observer.setQueries(\n defaultedQueries,\n options as QueriesObserverOptions<TCombinedResult>,\n )\n }, [defaultedQueries, options, observer])\n\n const shouldAtLeastOneSuspend = optimisticResult.some((result, index) =>\n shouldSuspend(defaultedQueries[index], result),\n )\n\n const suspensePromises = shouldAtLeastOneSuspend\n ? optimisticResult.flatMap((result, index) => {\n const opts = defaultedQueries[index]\n\n if (opts && shouldSuspend(opts, result)) {\n const queryObserver = new QueryObserver(client, opts)\n return fetchOptimistic(opts, queryObserver, errorResetBoundary)\n }\n return []\n })\n : []\n\n if (suspensePromises.length > 0) {\n throw Promise.all(suspensePromises)\n }\n const firstSingleResultWhichShouldThrow = optimisticResult.find(\n (result, index) => {\n const query = defaultedQueries[index]\n return (\n query &&\n getHasError({\n result,\n errorResetBoundary,\n throwOnError: query.throwOnError,\n query: client.getQueryCache().get(query.queryHash),\n suspense: query.suspense,\n })\n )\n },\n )\n\n if (firstSingleResultWhichShouldThrow) {\n throw firstSingleResultWhichShouldThrow.error\n }\n\n return getCombinedResult(trackResult())\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmWA,SAAgB,WAId,EACE,SACA,GAAG,WAsBL,aACiB;CACjB,MAAM,SAASA,4BAAAA,eAAe,WAAW;CACzC,MAAM,cAAcC,4BAAAA,eAAe;CACnC,MAAM,qBAAqBC,gCAAAA,2BAA2B;CACtD,MAAM,aAAa,QAAQ,eAAe;CAE1C,MAAM,mBAAmBC,MAAM,cAE3B,QAAQ,KAAK,SAAS;EACpB,MAAM,mBAAmB,OAAO,oBAC9B,IACF;EAGA,iBAAiB,qBAAqB,cAClC,gBACA,aACE,eACA,KAAA;EAEN,OAAO;CACT,CAAC,GACH;EAAC;EAAS;EAAQ;EAAa;CAAU,CAC3C;CAEA,iBAAiB,SAAS,iBAAiB;EACzC,iBAAA,qBAAqB,YAAY;EACjC,MAAM,QAAQ,OAAO,cAAc,CAAC,CAAC,IAAI,aAAa,SAAS;EAC/D,2BAAA,gCAAgC,cAAc,oBAAoB,KAAK;CACzE,CAAC;C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@@ type GetUseQueryResult<T> = T extends {
48
48
  * matches a query options object is mapped per-element instead, still inferring each entry individually; any
49
49
  * other non-tuple array — one whose element type doesn't match the expected options shape — falls back to
50
50
  * that same homogeneous options type too.
51
- *
52
51
  * @template T - The type of the `queries` array as written at the call site.
53
52
  * @template TResults - The internal accumulator that this type builds during recursion. It is not meant
54
53
  * to be set explicitly.
@@ -61,7 +60,6 @@ export type QueriesOptions<T extends Array<any>, TResults extends Array<any> = [
61
60
  * tuple element's result type is inferred individually, up to 20 elements. A non-tuple array is mapped
62
61
  * per-element instead, still inferring each entry individually; only past 20 elements does this fall back to a
63
62
  * single homogeneous {@link UseQueryResult} type.
64
- *
65
63
  * @template T - The type of the `queries` array, as inferred by {@link QueriesOptions}.
66
64
  * @template TResults - The internal accumulator that this type builds during recursion. It is not meant
67
65
  * to be set explicitly.
@@ -82,7 +80,13 @@ export type QueriesResults<T extends Array<any>, TResults extends Array<any> = [
82
80
  *
83
81
  * The `combine` option can be used to combine the results of the queries into a single value. The result will
84
82
  * be structurally shared to be as referentially stable as possible.
85
- *
83
+ * @param options - The `queries` array to run, and the optional `combine` and `subscribed` options.
84
+ * @param queryClient - Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context
85
+ * will be used.
86
+ * @returns The combined result. Without `combine`, this is an array with all the query results, in the same
87
+ * order as the input. When `combine` is provided, this is the value returned by `combine` instead.
88
+ * @throws {Error} The error of the first query that should be thrown to the nearest error boundary (see
89
+ * `throwOnError`). While suspending, it throws a promise instead.
86
90
  * @remarks The `combine` function only re-runs if it changed referentially, or if any of the query results
87
91
  * changed. An inlined `combine` function, as shown in the example below, therefore runs on every render — wrap
88
92
  * it in `useCallback`, or extract it to a stable function reference if it doesn't have any dependencies, to
@@ -98,11 +102,6 @@ export type QueriesResults<T extends Array<any>, TResults extends Array<any> = [
98
102
  *
99
103
  * `placeholderData` is supported here too, but unlike `useQuery`, it doesn't receive information from
100
104
  * previously rendered queries, because the number of queries can differ between renders.
101
- * @param queryClient - Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context
102
- * will be used.
103
- * @returns The combined result. Without `combine`, this is an array with all the query results, in the same
104
- * order as the input. When `combine` is provided, this is the value returned by `combine` instead.
105
- *
106
105
  * @example
107
106
  * ```tsx
108
107
  * import { useQueries } from '@tanstack/react-query'
@@ -127,7 +126,6 @@ export type QueriesResults<T extends Array<any>, TResults extends Array<any> = [
127
126
  * )
128
127
  * }
129
128
  * ```
130
- *
131
129
  * @example
132
130
  * Combining results into a single value:
133
131
  * ```tsx
@@ -160,7 +158,6 @@ export type QueriesResults<T extends Array<any>, TResults extends Array<any> = [
160
158
  * )
161
159
  * }
162
160
  * ```
163
- *
164
161
  * @example
165
162
  * Typing `select` via {@link queryOptions}. Note that spreading a `queryOptions` result and overriding
166
163
  * `select` inline still falls back to `unknown` — wrap the spread in `queryOptions` again so the override is
@@ -214,7 +211,6 @@ export declare function useQueries<T extends Array<any>, TCombinedResult = Queri
214
211
  combine?: (result: QueriesResults<T>) => TCombinedResult;
215
212
  /**
216
213
  * Set this to `false` to unsubscribe this observer from updates to the query cache.
217
- *
218
214
  * @defaultValue true
219
215
  */
220
216
  subscribed?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"useQueries.d.cts","names":[],"sources":["../../src/useQueries.ts"],"mappings":";;;KAyCK,6BACH,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,UACF,gBAAgB,cAAc,QAAQ,OAAO;EAG7C,kBAAkB,eAAe,+BAA+B;;KAI7D;KAGA;KAEA,gCAAgC,KAEnC;EACE,mBAAmB;EACnB,cAAc;EACd,YAAY;IAEV,6BAA6B,cAAc,QAAQ,SACnD;EAAY,mBAAmB;EAAc,cAAc;IACzD,6BAA6B,cAAc,UAC3C;EAAY,YAAY;EAAO,cAAc;IAC3C,sCAAsC,QAAQ,SAE9C,iBAAiB,oBAAoB,cAAc,SACjD,6BAA6B,cAAc,QAAQ,SACnD,iBAAiB,oBAAoB,UACnC,6BA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmIhC,WACd,UAAU,YACV,kBAAkB,eAAe,MAG/B,YACG;;;;;;;EAQH,sBACiB,eAAe,sBACZ,WAAW,IAAI,gCAAgC,EAAE;;;;;EAKrE,WAAW,QAAQ,eAAe,OAAO;;;;;EAKzC;GAEF,cAAc,cACb"}
@@ -48,7 +48,6 @@ type GetUseQueryResult<T> = T extends {
48
48
  * matches a query options object is mapped per-element instead, still inferring each entry individually; any
49
49
  * other non-tuple array — one whose element type doesn't match the expected options shape — falls back to
50
50
  * that same homogeneous options type too.
51
- *
52
51
  * @template T - The type of the `queries` array as written at the call site.
53
52
  * @template TResults - The internal accumulator that this type builds during recursion. It is not meant
54
53
  * to be set explicitly.
@@ -61,7 +60,6 @@ export type QueriesOptions<T extends Array<any>, TResults extends Array<any> = [
61
60
  * tuple element's result type is inferred individually, up to 20 elements. A non-tuple array is mapped
62
61
  * per-element instead, still inferring each entry individually; only past 20 elements does this fall back to a
63
62
  * single homogeneous {@link UseQueryResult} type.
64
- *
65
63
  * @template T - The type of the `queries` array, as inferred by {@link QueriesOptions}.
66
64
  * @template TResults - The internal accumulator that this type builds during recursion. It is not meant
67
65
  * to be set explicitly.
@@ -82,7 +80,13 @@ export type QueriesResults<T extends Array<any>, TResults extends Array<any> = [
82
80
  *
83
81
  * The `combine` option can be used to combine the results of the queries into a single value. The result will
84
82
  * be structurally shared to be as referentially stable as possible.
85
- *
83
+ * @param options - The `queries` array to run, and the optional `combine` and `subscribed` options.
84
+ * @param queryClient - Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context
85
+ * will be used.
86
+ * @returns The combined result. Without `combine`, this is an array with all the query results, in the same
87
+ * order as the input. When `combine` is provided, this is the value returned by `combine` instead.
88
+ * @throws {Error} The error of the first query that should be thrown to the nearest error boundary (see
89
+ * `throwOnError`). While suspending, it throws a promise instead.
86
90
  * @remarks The `combine` function only re-runs if it changed referentially, or if any of the query results
87
91
  * changed. An inlined `combine` function, as shown in the example below, therefore runs on every render — wrap
88
92
  * it in `useCallback`, or extract it to a stable function reference if it doesn't have any dependencies, to
@@ -98,11 +102,6 @@ export type QueriesResults<T extends Array<any>, TResults extends Array<any> = [
98
102
  *
99
103
  * `placeholderData` is supported here too, but unlike `useQuery`, it doesn't receive information from
100
104
  * previously rendered queries, because the number of queries can differ between renders.
101
- * @param queryClient - Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context
102
- * will be used.
103
- * @returns The combined result. Without `combine`, this is an array with all the query results, in the same
104
- * order as the input. When `combine` is provided, this is the value returned by `combine` instead.
105
- *
106
105
  * @example
107
106
  * ```tsx
108
107
  * import { useQueries } from '@tanstack/react-query'
@@ -127,7 +126,6 @@ export type QueriesResults<T extends Array<any>, TResults extends Array<any> = [
127
126
  * )
128
127
  * }
129
128
  * ```
130
- *
131
129
  * @example
132
130
  * Combining results into a single value:
133
131
  * ```tsx
@@ -160,7 +158,6 @@ export type QueriesResults<T extends Array<any>, TResults extends Array<any> = [
160
158
  * )
161
159
  * }
162
160
  * ```
163
- *
164
161
  * @example
165
162
  * Typing `select` via {@link queryOptions}. Note that spreading a `queryOptions` result and overriding
166
163
  * `select` inline still falls back to `unknown` — wrap the spread in `queryOptions` again so the override is
@@ -214,7 +211,6 @@ export declare function useQueries<T extends Array<any>, TCombinedResult = Queri
214
211
  combine?: (result: QueriesResults<T>) => TCombinedResult;
215
212
  /**
216
213
  * Set this to `false` to unsubscribe this observer from updates to the query cache.
217
- *
218
214
  * @defaultValue true
219
215
  */
220
216
  subscribed?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"useQueries.d.ts","names":[],"sources":["../../src/useQueries.ts"],"mappings":";;;KAyCK,6BACH,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,UACF,gBAAgB,cAAc,QAAQ,OAAO;EAG7C,kBAAk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ACA,cACA,aACA,cAGV,MACE,6BACE,cACA,QACA,OACA,cAIJ,MAAM;;;;;;;;;;;;YAaR,eACV,UAAU,YACV,iBAAiB,iBACjB,eAAe,8BACb,yBAAyB,gBACzB,MAAM,kBACN,oBAEE,iBAAiB,YACX,UAAU,kBAAkB,SAChC,iBAAiB,eAAe,SAC9B,mBACM,YACA,UAAU,kBAAkB,YAC5B,iBAEH,WAAW,IAAI,kBAAkB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmIhC,WACd,UAAU,YACV,kBAAkB,eAAe,MAG/B,YACG;;;;;;;EAQH,sBACiB,eAAe,sBACZ,WAAW,IAAI,gCAAgC,EAAE;;;;;EAKrE,WAAW,QAAQ,eAAe,OAAO;;;;;EAKzC;GAEF,cAAc,cACb"}
@@ -20,7 +20,13 @@ import { QueriesObserver, QueryObserver, noop, notifyManager } from "@tanstack/q
20
20
  *
21
21
  * The `combine` option can be used to combine the results of the queries into a single value. The result will
22
22
  * be structurally shared to be as referentially stable as possible.
23
- *
23
+ * @param options - The `queries` array to run, and the optional `combine` and `subscribed` options.
24
+ * @param queryClient - Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context
25
+ * will be used.
26
+ * @returns The combined result. Without `combine`, this is an array with all the query results, in the same
27
+ * order as the input. When `combine` is provided, this is the value returned by `combine` instead.
28
+ * @throws {Error} The error of the first query that should be thrown to the nearest error boundary (see
29
+ * `throwOnError`). While suspending, it throws a promise instead.
24
30
  * @remarks The `combine` function only re-runs if it changed referentially, or if any of the query results
25
31
  * changed. An inlined `combine` function, as shown in the example below, therefore runs on every render — wrap
26
32
  * it in `useCallback`, or extract it to a stable function reference if it doesn't have any dependencies, to
@@ -36,11 +42,6 @@ import { QueriesObserver, QueryObserver, noop, notifyManager } from "@tanstack/q
36
42
  *
37
43
  * `placeholderData` is supported here too, but unlike `useQuery`, it doesn't receive information from
38
44
  * previously rendered queries, because the number of queries can differ between renders.
39
- * @param queryClient - Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context
40
- * will be used.
41
- * @returns The combined result. Without `combine`, this is an array with all the query results, in the same
42
- * order as the input. When `combine` is provided, this is the value returned by `combine` instead.
43
- *
44
45
  * @example
45
46
  * ```tsx
46
47
  * import { useQueries } from '@tanstack/react-query'
@@ -65,7 +66,6 @@ import { QueriesObserver, QueryObserver, noop, notifyManager } from "@tanstack/q
65
66
  * )
66
67
  * }
67
68
  * ```
68
- *
69
69
  * @example
70
70
  * Combining results into a single value:
71
71
  * ```tsx
@@ -98,7 +98,6 @@ import { QueriesObserver, QueryObserver, noop, notifyManager } from "@tanstack/q
98
98
  * )
99
99
  * }
100
100
  * ```
101
- *
102
101
  * @example
103
102
  * Typing `select` via {@link queryOptions}. Note that spreading a `queryOptions` result and overriding
104
103
  * `select` inline still falls back to `unknown` — wrap the spread in `queryOptions` again so the override is