@tanstack/preact-query 5.104.0 → 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 (364) 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 +3 -4
  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 +4 -5
  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 +6 -4
  26. package/build/legacy/QueryErrorResetBoundary.cjs.map +1 -1
  27. package/build/legacy/QueryErrorResetBoundary.d.cts +5 -5
  28. package/build/legacy/QueryErrorResetBoundary.d.cts.map +1 -1
  29. package/build/legacy/QueryErrorResetBoundary.d.ts +5 -5
  30. package/build/legacy/QueryErrorResetBoundary.d.ts.map +1 -1
  31. package/build/legacy/QueryErrorResetBoundary.js +6 -4
  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 +13 -12
  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 +13 -12
  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 +3 -3
  128. package/build/legacy/useQueries.cjs.map +1 -1
  129. package/build/legacy/useQueries.d.cts +3 -6
  130. package/build/legacy/useQueries.d.cts.map +1 -1
  131. package/build/legacy/useQueries.d.ts +3 -6
  132. package/build/legacy/useQueries.d.ts.map +1 -1
  133. package/build/legacy/useQueries.js +3 -3
  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/legacy/utils.cjs +21 -1
  164. package/build/legacy/utils.cjs.map +1 -1
  165. package/build/legacy/utils.d.cts +15 -0
  166. package/build/legacy/utils.d.cts.map +1 -1
  167. package/build/legacy/utils.d.ts +15 -0
  168. package/build/legacy/utils.d.ts.map +1 -1
  169. package/build/legacy/utils.js +21 -1
  170. package/build/legacy/utils.js.map +1 -1
  171. package/build/modern/HydrationBoundary.cjs +2 -3
  172. package/build/modern/HydrationBoundary.cjs.map +1 -1
  173. package/build/modern/HydrationBoundary.d.cts +3 -4
  174. package/build/modern/HydrationBoundary.d.cts.map +1 -1
  175. package/build/modern/HydrationBoundary.d.ts +2 -3
  176. package/build/modern/HydrationBoundary.d.ts.map +1 -1
  177. package/build/modern/HydrationBoundary.js +2 -3
  178. package/build/modern/HydrationBoundary.js.map +1 -1
  179. package/build/modern/IsRestoringProvider.cjs +0 -1
  180. package/build/modern/IsRestoringProvider.cjs.map +1 -1
  181. package/build/modern/IsRestoringProvider.d.cts +0 -1
  182. package/build/modern/IsRestoringProvider.d.cts.map +1 -1
  183. package/build/modern/IsRestoringProvider.d.ts +0 -1
  184. package/build/modern/IsRestoringProvider.d.ts.map +1 -1
  185. package/build/modern/IsRestoringProvider.js +0 -1
  186. package/build/modern/IsRestoringProvider.js.map +1 -1
  187. package/build/modern/QueryClientProvider.cjs +3 -4
  188. package/build/modern/QueryClientProvider.cjs.map +1 -1
  189. package/build/modern/QueryClientProvider.d.cts +4 -5
  190. package/build/modern/QueryClientProvider.d.cts.map +1 -1
  191. package/build/modern/QueryClientProvider.d.ts +3 -4
  192. package/build/modern/QueryClientProvider.d.ts.map +1 -1
  193. package/build/modern/QueryClientProvider.js +3 -4
  194. package/build/modern/QueryClientProvider.js.map +1 -1
  195. package/build/modern/QueryErrorResetBoundary.cjs +6 -4
  196. package/build/modern/QueryErrorResetBoundary.cjs.map +1 -1
  197. package/build/modern/QueryErrorResetBoundary.d.cts +5 -5
  198. package/build/modern/QueryErrorResetBoundary.d.cts.map +1 -1
  199. package/build/modern/QueryErrorResetBoundary.d.ts +5 -5
  200. package/build/modern/QueryErrorResetBoundary.d.ts.map +1 -1
  201. package/build/modern/QueryErrorResetBoundary.js +6 -4
  202. package/build/modern/QueryErrorResetBoundary.js.map +1 -1
  203. package/build/modern/errorBoundaryUtils.cjs +21 -0
  204. package/build/modern/errorBoundaryUtils.cjs.map +1 -1
  205. package/build/modern/errorBoundaryUtils.d.cts +21 -0
  206. package/build/modern/errorBoundaryUtils.d.cts.map +1 -1
  207. package/build/modern/errorBoundaryUtils.d.ts +21 -0
  208. package/build/modern/errorBoundaryUtils.d.ts.map +1 -1
  209. package/build/modern/errorBoundaryUtils.js +21 -0
  210. package/build/modern/errorBoundaryUtils.js.map +1 -1
  211. package/build/modern/infiniteQueryOptions.cjs.map +1 -1
  212. package/build/modern/infiniteQueryOptions.d.cts +5 -16
  213. package/build/modern/infiniteQueryOptions.d.cts.map +1 -1
  214. package/build/modern/infiniteQueryOptions.d.ts +5 -16
  215. package/build/modern/infiniteQueryOptions.d.ts.map +1 -1
  216. package/build/modern/infiniteQueryOptions.js.map +1 -1
  217. package/build/modern/mutationOptions.cjs.map +1 -1
  218. package/build/modern/mutationOptions.d.cts +2 -6
  219. package/build/modern/mutationOptions.d.cts.map +1 -1
  220. package/build/modern/mutationOptions.d.ts +2 -6
  221. package/build/modern/mutationOptions.d.ts.map +1 -1
  222. package/build/modern/mutationOptions.js.map +1 -1
  223. package/build/modern/queryOptions.cjs.map +1 -1
  224. package/build/modern/queryOptions.d.cts +6 -16
  225. package/build/modern/queryOptions.d.cts.map +1 -1
  226. package/build/modern/queryOptions.d.ts +6 -16
  227. package/build/modern/queryOptions.d.ts.map +1 -1
  228. package/build/modern/queryOptions.js.map +1 -1
  229. package/build/modern/suspense.cjs +27 -0
  230. package/build/modern/suspense.cjs.map +1 -1
  231. package/build/modern/suspense.d.cts +27 -0
  232. package/build/modern/suspense.d.cts.map +1 -1
  233. package/build/modern/suspense.d.ts +27 -0
  234. package/build/modern/suspense.d.ts.map +1 -1
  235. package/build/modern/suspense.js +27 -0
  236. package/build/modern/suspense.js.map +1 -1
  237. package/build/modern/types.cjs.map +1 -1
  238. package/build/modern/types.d.cts +2 -22
  239. package/build/modern/types.d.cts.map +1 -1
  240. package/build/modern/types.d.ts +2 -22
  241. package/build/modern/types.d.ts.map +1 -1
  242. package/build/modern/types.js.map +1 -1
  243. package/build/modern/useBaseQuery.cjs +13 -0
  244. package/build/modern/useBaseQuery.cjs.map +1 -1
  245. package/build/modern/useBaseQuery.d.cts +13 -0
  246. package/build/modern/useBaseQuery.d.cts.map +1 -1
  247. package/build/modern/useBaseQuery.d.ts +13 -0
  248. package/build/modern/useBaseQuery.d.ts.map +1 -1
  249. package/build/modern/useBaseQuery.js +13 -0
  250. package/build/modern/useBaseQuery.js.map +1 -1
  251. package/build/modern/useInfiniteQuery.cjs.map +1 -1
  252. package/build/modern/useInfiniteQuery.d.cts +12 -21
  253. package/build/modern/useInfiniteQuery.d.cts.map +1 -1
  254. package/build/modern/useInfiniteQuery.d.ts +12 -21
  255. package/build/modern/useInfiniteQuery.d.ts.map +1 -1
  256. package/build/modern/useInfiniteQuery.js.map +1 -1
  257. package/build/modern/useIsFetching.cjs +0 -3
  258. package/build/modern/useIsFetching.cjs.map +1 -1
  259. package/build/modern/useIsFetching.d.cts +0 -3
  260. package/build/modern/useIsFetching.d.cts.map +1 -1
  261. package/build/modern/useIsFetching.d.ts +0 -3
  262. package/build/modern/useIsFetching.d.ts.map +1 -1
  263. package/build/modern/useIsFetching.js +0 -3
  264. package/build/modern/useIsFetching.js.map +1 -1
  265. package/build/modern/useMutation.cjs +4 -8
  266. package/build/modern/useMutation.cjs.map +1 -1
  267. package/build/modern/useMutation.d.cts +4 -8
  268. package/build/modern/useMutation.d.cts.map +1 -1
  269. package/build/modern/useMutation.d.ts +4 -8
  270. package/build/modern/useMutation.d.ts.map +1 -1
  271. package/build/modern/useMutation.js +4 -8
  272. package/build/modern/useMutation.js.map +1 -1
  273. package/build/modern/useMutationState.cjs +13 -12
  274. package/build/modern/useMutationState.cjs.map +1 -1
  275. package/build/modern/useMutationState.d.cts +0 -6
  276. package/build/modern/useMutationState.d.cts.map +1 -1
  277. package/build/modern/useMutationState.d.ts +0 -6
  278. package/build/modern/useMutationState.d.ts.map +1 -1
  279. package/build/modern/useMutationState.js +13 -12
  280. package/build/modern/useMutationState.js.map +1 -1
  281. package/build/modern/usePrefetchInfiniteQuery.cjs +0 -3
  282. package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -1
  283. package/build/modern/usePrefetchInfiniteQuery.d.cts +0 -3
  284. package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
  285. package/build/modern/usePrefetchInfiniteQuery.d.ts +0 -3
  286. package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
  287. package/build/modern/usePrefetchInfiniteQuery.js +0 -3
  288. package/build/modern/usePrefetchInfiniteQuery.js.map +1 -1
  289. package/build/modern/usePrefetchQuery.cjs +0 -3
  290. package/build/modern/usePrefetchQuery.cjs.map +1 -1
  291. package/build/modern/usePrefetchQuery.d.cts +0 -3
  292. package/build/modern/usePrefetchQuery.d.cts.map +1 -1
  293. package/build/modern/usePrefetchQuery.d.ts +0 -3
  294. package/build/modern/usePrefetchQuery.d.ts.map +1 -1
  295. package/build/modern/usePrefetchQuery.js +0 -3
  296. package/build/modern/usePrefetchQuery.js.map +1 -1
  297. package/build/modern/useQueries.cjs +3 -3
  298. package/build/modern/useQueries.cjs.map +1 -1
  299. package/build/modern/useQueries.d.cts +3 -6
  300. package/build/modern/useQueries.d.cts.map +1 -1
  301. package/build/modern/useQueries.d.ts +3 -6
  302. package/build/modern/useQueries.d.ts.map +1 -1
  303. package/build/modern/useQueries.js +3 -3
  304. package/build/modern/useQueries.js.map +1 -1
  305. package/build/modern/useQuery.cjs.map +1 -1
  306. package/build/modern/useQuery.d.cts +8 -13
  307. package/build/modern/useQuery.d.cts.map +1 -1
  308. package/build/modern/useQuery.d.ts +8 -13
  309. package/build/modern/useQuery.d.ts.map +1 -1
  310. package/build/modern/useQuery.js.map +1 -1
  311. package/build/modern/useSuspenseInfiniteQuery.cjs +6 -8
  312. package/build/modern/useSuspenseInfiniteQuery.cjs.map +1 -1
  313. package/build/modern/useSuspenseInfiniteQuery.d.cts +6 -8
  314. package/build/modern/useSuspenseInfiniteQuery.d.cts.map +1 -1
  315. package/build/modern/useSuspenseInfiniteQuery.d.ts +6 -8
  316. package/build/modern/useSuspenseInfiniteQuery.d.ts.map +1 -1
  317. package/build/modern/useSuspenseInfiniteQuery.js +6 -8
  318. package/build/modern/useSuspenseInfiniteQuery.js.map +1 -1
  319. package/build/modern/useSuspenseQueries.cjs.map +1 -1
  320. package/build/modern/useSuspenseQueries.d.cts +0 -9
  321. package/build/modern/useSuspenseQueries.d.cts.map +1 -1
  322. package/build/modern/useSuspenseQueries.d.ts +0 -9
  323. package/build/modern/useSuspenseQueries.d.ts.map +1 -1
  324. package/build/modern/useSuspenseQueries.js.map +1 -1
  325. package/build/modern/useSuspenseQuery.cjs +4 -6
  326. package/build/modern/useSuspenseQuery.cjs.map +1 -1
  327. package/build/modern/useSuspenseQuery.d.cts +4 -6
  328. package/build/modern/useSuspenseQuery.d.cts.map +1 -1
  329. package/build/modern/useSuspenseQuery.d.ts +4 -6
  330. package/build/modern/useSuspenseQuery.d.ts.map +1 -1
  331. package/build/modern/useSuspenseQuery.js +4 -6
  332. package/build/modern/useSuspenseQuery.js.map +1 -1
  333. package/build/modern/utils.cjs +21 -1
  334. package/build/modern/utils.cjs.map +1 -1
  335. package/build/modern/utils.d.cts +15 -0
  336. package/build/modern/utils.d.cts.map +1 -1
  337. package/build/modern/utils.d.ts +15 -0
  338. package/build/modern/utils.d.ts.map +1 -1
  339. package/build/modern/utils.js +21 -1
  340. package/build/modern/utils.js.map +1 -1
  341. package/package.json +10 -13
  342. package/src/HydrationBoundary.tsx +8 -8
  343. package/src/IsRestoringProvider.ts +0 -1
  344. package/src/QueryClientProvider.tsx +5 -6
  345. package/src/QueryErrorResetBoundary.tsx +11 -6
  346. package/src/errorBoundaryUtils.ts +22 -1
  347. package/src/infiniteQueryOptions.ts +5 -16
  348. package/src/mutationOptions.ts +2 -6
  349. package/src/queryOptions.ts +8 -17
  350. package/src/suspense.ts +29 -1
  351. package/src/types.ts +2 -22
  352. package/src/useBaseQuery.ts +20 -7
  353. package/src/useInfiniteQuery.ts +13 -22
  354. package/src/useIsFetching.ts +1 -4
  355. package/src/useMutation.ts +6 -10
  356. package/src/useMutationState.ts +18 -17
  357. package/src/usePrefetchInfiniteQuery.tsx +0 -3
  358. package/src/usePrefetchQuery.tsx +0 -3
  359. package/src/useQueries.ts +15 -18
  360. package/src/useQuery.ts +9 -14
  361. package/src/useSuspenseInfiniteQuery.ts +8 -10
  362. package/src/useSuspenseQueries.ts +2 -11
  363. package/src/useSuspenseQuery.ts +6 -8
  364. package/src/utils.ts +21 -1
package/src/useQueries.ts CHANGED
@@ -4,17 +4,6 @@ import {
4
4
  noop,
5
5
  notifyManager,
6
6
  } from '@tanstack/query-core'
7
- import type {
8
- DefaultError,
9
- OmitKeyof,
10
- QueriesObserverOptions,
11
- QueriesPlaceholderDataFunction,
12
- QueryClient,
13
- QueryFunction,
14
- QueryKey,
15
- QueryObserverOptions,
16
- ThrowOnError,
17
- } from '@tanstack/query-core'
18
7
  import { useCallback, useEffect, useMemo, useState } from 'preact/hooks'
19
8
 
20
9
  import { useIsRestoring } from './IsRestoringProvider'
@@ -30,12 +19,23 @@ import {
30
19
  fetchOptimistic,
31
20
  shouldSuspend,
32
21
  } from './suspense'
22
+ import { useSyncExternalStore } from './utils'
33
23
  import type {
34
24
  DefinedUseQueryResult,
35
25
  UseQueryOptions,
36
26
  UseQueryResult,
37
27
  } from './types'
38
- import { useSyncExternalStore } from './utils'
28
+ import type {
29
+ DefaultError,
30
+ OmitKeyof,
31
+ QueriesObserverOptions,
32
+ QueriesPlaceholderDataFunction,
33
+ QueryClient,
34
+ QueryFunction,
35
+ QueryKey,
36
+ QueryObserverOptions,
37
+ ThrowOnError,
38
+ } from '@tanstack/query-core'
39
39
 
40
40
  // This defines the `UseQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.
41
41
  // `placeholderData` function always gets undefined passed
@@ -150,7 +150,6 @@ type GetUseQueryResult<T> =
150
150
  * matches a query options object is mapped per-element instead, still inferring each entry individually; any
151
151
  * other non-tuple array — one whose element type doesn't match the expected options shape — falls back to
152
152
  * that same homogeneous options type too.
153
- *
154
153
  * @template T - The type of the `queries` array as written at the call site.
155
154
  * @template TResults - The internal accumulator that this type builds during recursion. It is not meant
156
155
  * to be set explicitly.
@@ -201,7 +200,6 @@ export type QueriesOptions<
201
200
  * tuple element's result type is inferred individually, up to 20 elements. A non-tuple array is mapped
202
201
  * per-element instead, still inferring each entry individually; only past 20 elements does this fall back to a
203
202
  * single homogeneous {@link UseQueryResult} type.
204
- *
205
203
  * @template T - The type of the `queries` array, as inferred by {@link QueriesOptions}.
206
204
  * @template TResults - The internal accumulator that this type builds during recursion. It is not meant
207
205
  * to be set explicitly.
@@ -239,12 +237,13 @@ export type QueriesResults<
239
237
  *
240
238
  * The `combine` option can be used to combine the results of the queries into a single value. The result will
241
239
  * be structurally shared to be as referentially stable as possible.
242
- *
240
+ * @param options - The `queries` array to run, and the optional `combine` and `subscribed` options.
243
241
  * @param queryClient - Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context
244
242
  * will be used.
245
243
  * @returns The combined result. Without `combine`, this is an array with all the query results, in the same
246
244
  * order as the input. When `combine` is provided, this is the value returned by `combine` instead.
247
- *
245
+ * @throws {Error} The error of the first query that should be thrown to the nearest error boundary (see
246
+ * `throwOnError`). While suspending, it throws a promise instead.
248
247
  * @example
249
248
  * ```tsx
250
249
  * import { useQueries } from '@tanstack/preact-query'
@@ -269,7 +268,6 @@ export type QueriesResults<
269
268
  * )
270
269
  * }
271
270
  * ```
272
- *
273
271
  * @example
274
272
  * Combining results into a single value:
275
273
  * ```tsx
@@ -327,7 +325,6 @@ export function useQueries<
327
325
  combine?: (result: QueriesResults<T>) => TCombinedResult
328
326
  /**
329
327
  * Set this to `false` to unsubscribe this observer from updates to the query cache.
330
- *
331
328
  * @defaultValue true
332
329
  */
333
330
  subscribed?: boolean
package/src/useQuery.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { QueryObserver } from '@tanstack/query-core'
2
+ import { useBaseQuery } from './useBaseQuery'
2
3
  import type { DefaultError, QueryClient, QueryKey } from '@tanstack/query-core'
3
4
 
4
5
  import type {
@@ -10,20 +11,17 @@ import type {
10
11
  UseQueryOptions,
11
12
  UseQueryResult,
12
13
  } from './types'
13
- import { useBaseQuery } from './useBaseQuery'
14
14
 
15
15
  /**
16
16
  * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
17
17
  * a `select` changes `TData` to include `undefined`).
18
- *
19
- * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
20
18
  * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` set.
21
19
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
22
20
  * be used.
23
21
  * @returns The current query result, typed so that `status` is `success` — or `error` if a fetch attempt
24
22
  * fails while keeping the existing data (`status` never resolves to `pending` in this overload's type,
25
23
  * since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for convenience.
26
- *
24
+ * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
27
25
  * @example
28
26
  * ```tsx
29
27
  * import { useQuery } from '@tanstack/preact-query'
@@ -59,14 +57,15 @@ export function useQuery<
59
57
  ): DefinedUseQueryResult<TData, TError>
60
58
 
61
59
  /**
62
- * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
60
+ * This overload is selected when `initialData` is omitted or may be `undefined`, so the resulting `data`
61
+ * can be `undefined`.
63
62
  * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`.
64
63
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
65
64
  * be used.
66
65
  * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if
67
66
  * the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError`
68
67
  * are derived booleans for convenience.
69
- *
68
+ * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
70
69
  * @example
71
70
  * ```tsx
72
71
  * import { useQuery } from '@tanstack/preact-query'
@@ -92,7 +91,6 @@ export function useQuery<
92
91
  * )
93
92
  * }
94
93
  * ```
95
- *
96
94
  * @example
97
95
  * The same query, checking `isPending`/`isError` instead of `status` — pick whichever reads better to you:
98
96
  * ```tsx
@@ -126,14 +124,16 @@ export function useQuery<
126
124
  ): UseQueryResult<TData, TError>
127
125
 
128
126
  /**
129
- * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
127
+ * Fallback overload for options whose `initialData` presence isn't statically known — for example, an
128
+ * object typed as {@link UseQueryOptions} rather than an object literal. Prefer one of the other overloads
129
+ * when possible, since they infer whether `data` can be `undefined` from `initialData` directly.
130
130
  * @param options - The {@link UseQueryOptions} to use — everything you can pass to `useQuery`.
131
131
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
132
132
  * be used.
133
133
  * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if
134
134
  * the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError`
135
135
  * are derived booleans for convenience.
136
- *
136
+ * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
137
137
  * @example
138
138
  * ```tsx
139
139
  * import { useQuery } from '@tanstack/preact-query'
@@ -159,7 +159,6 @@ export function useQuery<
159
159
  * )
160
160
  * }
161
161
  * ```
162
- *
163
162
  * @example
164
163
  * `select` derives whatever `data` a component needs from the cached value, without changing what's
165
164
  * actually stored in the cache — the cache still holds the full `Post[]`, but `data` here is a `number`:
@@ -179,7 +178,6 @@ export function useQuery<
179
178
  * return <span>{data} posts</span>
180
179
  * }
181
180
  * ```
182
- *
183
181
  * @example
184
182
  * A dependent query, only enabled once `postId` is set — use `isLoading`, not `isPending`, so the
185
183
  * loading state doesn't show while the query is disabled:
@@ -200,7 +198,6 @@ export function useQuery<
200
198
  * return <h1>{data?.title}</h1>
201
199
  * }
202
200
  * ```
203
- *
204
201
  * @example
205
202
  * The same dependent query, type safe: `skipToken` disables the query without needing the
206
203
  * non-null assertion above, since `queryFn` is only ever called when `postId` is defined.
@@ -222,7 +219,6 @@ export function useQuery<
222
219
  * return <h1>{data?.title}</h1>
223
220
  * }
224
221
  * ```
225
- *
226
222
  * @example
227
223
  * Seeding a detail query from an already-cached list, to skip the loading state. `initialDataUpdatedAt` carries
228
224
  * over the list's own fetch time, so that if you set a `staleTime`, it's measured from when the list was
@@ -249,7 +245,6 @@ export function useQuery<
249
245
  * return <h1>{data?.title}</h1>
250
246
  * }
251
247
  * ```
252
- *
253
248
  * @example
254
249
  * Paginated data, keeping the previous page's data visible while the next page loads:
255
250
  * ```tsx
@@ -1,4 +1,6 @@
1
1
  import { InfiniteQueryObserver, skipToken } from '@tanstack/query-core'
2
+ import { defaultThrowOnError } from './suspense'
3
+ import { useBaseQuery } from './useBaseQuery'
2
4
  import type {
3
5
  DefaultError,
4
6
  InfiniteData,
@@ -8,19 +10,22 @@ import type {
8
10
  QueryObserver,
9
11
  } from '@tanstack/query-core'
10
12
 
11
- import { defaultThrowOnError } from './suspense'
12
13
  import type {
13
14
  UseSuspenseInfiniteQueryOptions,
14
15
  UseSuspenseInfiniteQueryResult,
15
16
  } from './types'
16
- import { useBaseQuery } from './useBaseQuery'
17
17
 
18
18
  /**
19
19
  * The options for `useSuspenseInfiniteQuery` are the same as for `useInfiniteQuery`, except for `throwOnError`,
20
20
  * `enabled`, and `placeholderData`.
21
21
  *
22
22
  * Caveat: cancellation does not work.
23
- *
23
+ * @param options - The {@link UseSuspenseInfiniteQueryOptions} to use — the same options as `useInfiniteQuery`, minus the ones listed above.
24
+ * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
25
+ * be used.
26
+ * @returns The same object as `useInfiniteQuery`, except that `data` is guaranteed to be defined,
27
+ * `isPlaceholderData` is missing, and `status` is either `success` or `error` (with the derived flags set
28
+ * accordingly).
24
29
  * @remarks Multiple suspenseful query calls in the same component suspend serially, causing a request
25
30
  * waterfall — each one blocks rendering until it resolves, so the next doesn't even start fetching until
26
31
  * then. There's no way to parallelize multiple infinite queries under Suspense. Also keep in mind that
@@ -28,13 +33,6 @@ import { useBaseQuery } from './useBaseQuery'
28
33
  * resulting in outdated data. Make sure to call these functions only in response to user actions, or add
29
34
  * conditions like `hasNextPage && !isFetching`.
30
35
  * @see {@link useInfiniteQuery} for the non-Suspense version of this hook.
31
- * @param options - The {@link UseSuspenseInfiniteQueryOptions} to use — the same options as `useInfiniteQuery`, minus the ones listed above.
32
- * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
33
- * be used.
34
- * @returns The same object as `useInfiniteQuery`, except that `data` is guaranteed to be defined,
35
- * `isPlaceholderData` is missing, and `status` is either `success` or `error` (with the derived flags set
36
- * accordingly).
37
- *
38
36
  * @example
39
37
  * The query error is thrown if a fetch fails and no cached data exists yet, so an error boundary is
40
38
  * required around `<Suspense>`. A failed background refetch instead continues to render the cached data.
@@ -1,4 +1,6 @@
1
1
  import { skipToken } from '@tanstack/query-core'
2
+ import { defaultThrowOnError } from './suspense'
3
+ import { useQueries } from './useQueries'
2
4
  import type {
3
5
  DefaultError,
4
6
  QueryClient,
@@ -6,9 +8,7 @@ import type {
6
8
  ThrowOnError,
7
9
  } from '@tanstack/query-core'
8
10
 
9
- import { defaultThrowOnError } from './suspense'
10
11
  import type { UseSuspenseQueryOptions, UseSuspenseQueryResult } from './types'
11
- import { useQueries } from './useQueries'
12
12
 
13
13
  // Avoid TS depth-limit error in case of large array literal
14
14
  type MAXIMUM_DEPTH = 20
@@ -113,7 +113,6 @@ type GetUseSuspenseQueryResult<T> =
113
113
  * matches a query options object is mapped per-element instead, still inferring each entry individually; any
114
114
  * other non-tuple array — one whose element type doesn't match the expected options shape — falls back to
115
115
  * that same homogeneous options type too.
116
- *
117
116
  * @template T - The type of the `queries` array as written at the call site.
118
117
  * @template TResults - The internal accumulator that this type builds during recursion. It is not meant
119
118
  * to be set explicitly.
@@ -159,7 +158,6 @@ export type SuspenseQueriesOptions<
159
158
  * {@link SuspenseQueriesOptions}: each tuple element's result type is inferred individually, up to 20 elements.
160
159
  * A non-tuple array is mapped per-element instead, still inferring each entry individually; only past 20
161
160
  * elements does this fall back to a single homogeneous {@link UseSuspenseQueryResult} type.
162
- *
163
161
  * @template T - The type of the `queries` array, as inferred by {@link SuspenseQueriesOptions}.
164
162
  * @template TResults - The internal accumulator that this type builds during recursion. It is not meant
165
163
  * to be set explicitly.
@@ -187,7 +185,6 @@ export type SuspenseQueriesResults<
187
185
  /**
188
186
  * The options for `useSuspenseQueries` are the same as for `useQueries`, except that the top-level `subscribed`
189
187
  * option isn't supported, and each `query` can't have `throwOnError`, `enabled`, or `placeholderData`.
190
- *
191
188
  * @param options - The `queries` array to run in Suspense, and an optional `combine` function.
192
189
  * @param queryClient - Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context
193
190
  * will be used.
@@ -198,7 +195,6 @@ export type SuspenseQueriesResults<
198
195
  * Caveat: the component will only re-mount after all queries have finished loading. Hence, if a query has gone
199
196
  * stale in the time it took for all the queries to complete, it will be fetched again at re-mount. To avoid
200
197
  * this, make sure to set a high enough `staleTime`. Cancellation does not work.
201
- *
202
198
  * @example
203
199
  * The query error is thrown if a fetch fails and no cached data exists yet, so an error boundary is
204
200
  * required around `<Suspense>`. A failed background refetch instead continues to render the cached data.
@@ -271,7 +267,6 @@ export type SuspenseQueriesResults<
271
267
  * return children
272
268
  * }
273
269
  * ```
274
- *
275
270
  * @example
276
271
  * Several different queries — use `useSuspenseQueries` instead of multiple `useSuspenseQuery` calls, so
277
272
  * they fetch in parallel rather than suspending one after another:
@@ -343,7 +338,6 @@ export type SuspenseQueriesResults<
343
338
  * return children
344
339
  * }
345
340
  * ```
346
- *
347
341
  * @example
348
342
  * `combine`s the results into a single boolean, so `Refresh` only re-renders when that boolean changes,
349
343
  * not on every individual query update. This overload is the only one that accepts `combine`:
@@ -433,7 +427,6 @@ export function useSuspenseQueries<
433
427
  /**
434
428
  * The options for `useSuspenseQueries` are the same as for `useQueries`, except that the top-level `subscribed`
435
429
  * option isn't supported, and each `query` can't have `throwOnError`, `enabled`, or `placeholderData`.
436
- *
437
430
  * @param options - The `queries` array to run in Suspense, and an optional `combine` function.
438
431
  * @param queryClient - Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context
439
432
  * will be used.
@@ -444,7 +437,6 @@ export function useSuspenseQueries<
444
437
  * Caveat: the component will only re-mount after all queries have finished loading. Hence, if a query has gone
445
438
  * stale in the time it took for all the queries to complete, it will be fetched again at re-mount. To avoid
446
439
  * this, make sure to set a high enough `staleTime`. Cancellation does not work.
447
- *
448
440
  * @example
449
441
  * The query error is thrown if a fetch fails and no cached data exists yet, so an error boundary is
450
442
  * required around `<Suspense>`. A failed background refetch instead continues to render the cached data.
@@ -517,7 +509,6 @@ export function useSuspenseQueries<
517
509
  * return children
518
510
  * }
519
511
  * ```
520
- *
521
512
  * @example
522
513
  * Several different queries — use `useSuspenseQueries` instead of multiple `useSuspenseQuery` calls, so
523
514
  * they fetch in parallel rather than suspending one after another:
@@ -1,26 +1,24 @@
1
1
  import { QueryObserver, skipToken } from '@tanstack/query-core'
2
+ import { defaultThrowOnError } from './suspense'
3
+ import { useBaseQuery } from './useBaseQuery'
2
4
  import type { DefaultError, QueryClient, QueryKey } from '@tanstack/query-core'
3
5
 
4
- import { defaultThrowOnError } from './suspense'
5
6
  import type { UseSuspenseQueryOptions, UseSuspenseQueryResult } from './types'
6
- import { useBaseQuery } from './useBaseQuery'
7
7
 
8
8
  /**
9
9
  * The options for `useSuspenseQuery` are the same as for `useQuery`, except for `throwOnError`, `enabled`, and
10
10
  * `placeholderData`.
11
11
  *
12
12
  * Caveat: cancellation does not work.
13
- *
14
- * @remarks Multiple `useSuspenseQuery` calls in the same component suspend serially, causing a request
15
- * waterfall — each one blocks rendering until it resolves, so the next doesn't even start fetching until then.
16
- * Use {@link useSuspenseQueries} instead when you have more than one suspenseful query in a component, so they
17
- * fetch in parallel.
18
13
  * @param options - The {@link UseSuspenseQueryOptions} to use — the same options as `useQuery`, minus the ones listed above.
19
14
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
20
15
  * be used.
21
16
  * @returns The same object as `useQuery`, except that `data` is guaranteed to be defined, `isPlaceholderData`
22
17
  * is missing, and `status` is either `success` or `error` (with the derived flags set accordingly).
23
- *
18
+ * @remarks Multiple `useSuspenseQuery` calls in the same component suspend serially, causing a request
19
+ * waterfall — each one blocks rendering until it resolves, so the next doesn't even start fetching until then.
20
+ * Use {@link useSuspenseQueries} instead when you have more than one suspenseful query in a component, so they
21
+ * fetch in parallel.
24
22
  * @example
25
23
  * The query error is thrown if the fetch fails and no cached data exists yet, so an error boundary is
26
24
  * required around `<Suspense>`. A failed background refetch instead continues to render the cached data.
package/src/utils.ts CHANGED
@@ -13,6 +13,12 @@ type InternalStore = {
13
13
  type StoreRef = {
14
14
  _instance: InternalStore
15
15
  }
16
+ /**
17
+ * Subscribes to an external store and returns its current snapshot, re-rendering when it changes.
18
+ * @param subscribe - Subscribes to the store, and returns a function that unsubscribes.
19
+ * @param getSnapshot - Returns the current snapshot of the store.
20
+ * @returns The current snapshot.
21
+ */
16
22
  export function useSyncExternalStore(
17
23
  subscribe: (onStoreChange: () => void) => () => void,
18
24
  getSnapshot: () => any,
@@ -47,6 +53,11 @@ export function useSyncExternalStore(
47
53
  return value
48
54
  }
49
55
 
56
+ /**
57
+ * Checks whether the store's snapshot changed since it was last read.
58
+ * @param inst - The stored snapshot and the function that reads the current one.
59
+ * @returns `true` if the current snapshot differs, or if reading it throws.
60
+ */
50
61
  function didSnapshotChange(inst: {
51
62
  _getSnapshot: () => any
52
63
  _value: any
@@ -61,13 +72,22 @@ function didSnapshotChange(inst: {
61
72
  }
62
73
  }
63
74
 
75
+ /**
76
+ * Like {@link useSyncExternalStore}, but returns a selected part of the snapshot, only updating it
77
+ * when `isEqual` reports a change.
78
+ * @param subscribe - Subscribes to the store, and returns a function that unsubscribes.
79
+ * @param getSnapshot - Returns the current snapshot of the store.
80
+ * @param selector - Selects the part of the snapshot to return.
81
+ * @param isEqual - Compares the previous and the new selection.
82
+ * @returns The selected part of the current snapshot.
83
+ */
64
84
  export function useSyncExternalStoreWithSelector<TSnapshot, TSelected>(
65
85
  subscribe: (onStoreChange: () => void) => () => void,
66
86
  getSnapshot: () => TSnapshot,
67
87
  selector: (snapshot: TSnapshot) => TSelected,
68
88
  isEqual: (a: TSelected, b: TSelected) => boolean,
69
89
  ): TSelected {
70
- const selectedSnapshotRef = useRef<TSelected | undefined>()
90
+ const selectedSnapshotRef = useRef<TSelected | undefined>(undefined)
71
91
 
72
92
  const getSelectedSnapshot = () => {
73
93
  const snapshot = getSnapshot()