@tanstack/query-core 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 (359) hide show
  1. package/build/legacy/environmentManager.cjs +3 -1
  2. package/build/legacy/environmentManager.cjs.map +1 -1
  3. package/build/legacy/environmentManager.d.cts +6 -1
  4. package/build/legacy/environmentManager.d.cts.map +1 -1
  5. package/build/legacy/environmentManager.d.ts +6 -1
  6. package/build/legacy/environmentManager.d.ts.map +1 -1
  7. package/build/legacy/environmentManager.js +3 -1
  8. package/build/legacy/environmentManager.js.map +1 -1
  9. package/build/legacy/focusManager.cjs +4 -2
  10. package/build/legacy/focusManager.cjs.map +1 -1
  11. package/build/legacy/focusManager.d.cts +5 -3
  12. package/build/legacy/focusManager.d.cts.map +1 -1
  13. package/build/legacy/focusManager.d.ts +5 -3
  14. package/build/legacy/focusManager.d.ts.map +1 -1
  15. package/build/legacy/focusManager.js +4 -2
  16. package/build/legacy/focusManager.js.map +1 -1
  17. package/build/legacy/{hydration-B9t5w6NC.d.ts → hydration-Dfuxd5FW.d.cts} +1410 -128
  18. package/build/legacy/hydration-Dfuxd5FW.d.cts.map +1 -0
  19. package/build/legacy/{hydration-Br9VIGXa.d.cts → hydration-UAqdtMIf.d.ts} +1410 -128
  20. package/build/legacy/hydration-UAqdtMIf.d.ts.map +1 -0
  21. package/build/legacy/hydration.cjs +35 -0
  22. package/build/legacy/hydration.cjs.map +1 -1
  23. package/build/legacy/hydration.d.cts +1 -1
  24. package/build/legacy/hydration.d.ts +1 -1
  25. package/build/legacy/hydration.js +35 -0
  26. package/build/legacy/hydration.js.map +1 -1
  27. package/build/legacy/index.d.cts +1 -1
  28. package/build/legacy/index.d.ts +1 -1
  29. package/build/legacy/infiniteQueryBehavior.cjs +29 -0
  30. package/build/legacy/infiniteQueryBehavior.cjs.map +1 -1
  31. package/build/legacy/infiniteQueryBehavior.d.cts +16 -1
  32. package/build/legacy/infiniteQueryBehavior.d.cts.map +1 -1
  33. package/build/legacy/infiniteQueryBehavior.d.ts +16 -1
  34. package/build/legacy/infiniteQueryBehavior.d.ts.map +1 -1
  35. package/build/legacy/infiniteQueryBehavior.js +29 -0
  36. package/build/legacy/infiniteQueryBehavior.js.map +1 -1
  37. package/build/legacy/infiniteQueryObserver.cjs +13 -7
  38. package/build/legacy/infiniteQueryObserver.cjs.map +1 -1
  39. package/build/legacy/infiniteQueryObserver.d.cts +15 -9
  40. package/build/legacy/infiniteQueryObserver.d.cts.map +1 -1
  41. package/build/legacy/infiniteQueryObserver.d.ts +15 -9
  42. package/build/legacy/infiniteQueryObserver.d.ts.map +1 -1
  43. package/build/legacy/infiniteQueryObserver.js +13 -7
  44. package/build/legacy/infiniteQueryObserver.js.map +1 -1
  45. package/build/legacy/mutation.cjs +27 -10
  46. package/build/legacy/mutation.cjs.map +1 -1
  47. package/build/legacy/mutation.d.cts +1 -1
  48. package/build/legacy/mutation.d.ts +1 -1
  49. package/build/legacy/mutation.js +27 -10
  50. package/build/legacy/mutation.js.map +1 -1
  51. package/build/legacy/mutationCache.cjs +53 -12
  52. package/build/legacy/mutationCache.cjs.map +1 -1
  53. package/build/legacy/mutationCache.d.cts +1 -1
  54. package/build/legacy/mutationCache.d.ts +1 -1
  55. package/build/legacy/mutationCache.js +53 -12
  56. package/build/legacy/mutationCache.js.map +1 -1
  57. package/build/legacy/mutationObserver.cjs +27 -16
  58. package/build/legacy/mutationObserver.cjs.map +1 -1
  59. package/build/legacy/mutationObserver.d.cts +1 -1
  60. package/build/legacy/mutationObserver.d.ts +1 -1
  61. package/build/legacy/mutationObserver.js +27 -16
  62. package/build/legacy/mutationObserver.js.map +1 -1
  63. package/build/legacy/notifyManager.cjs +12 -2
  64. package/build/legacy/notifyManager.cjs.map +1 -1
  65. package/build/legacy/notifyManager.d.cts +19 -4
  66. package/build/legacy/notifyManager.d.cts.map +1 -1
  67. package/build/legacy/notifyManager.d.ts +19 -4
  68. package/build/legacy/notifyManager.d.ts.map +1 -1
  69. package/build/legacy/notifyManager.js +12 -2
  70. package/build/legacy/notifyManager.js.map +1 -1
  71. package/build/legacy/onlineManager.cjs +4 -2
  72. package/build/legacy/onlineManager.cjs.map +1 -1
  73. package/build/legacy/onlineManager.d.cts +5 -3
  74. package/build/legacy/onlineManager.d.cts.map +1 -1
  75. package/build/legacy/onlineManager.d.ts +5 -3
  76. package/build/legacy/onlineManager.d.ts.map +1 -1
  77. package/build/legacy/onlineManager.js +4 -2
  78. package/build/legacy/onlineManager.js.map +1 -1
  79. package/build/legacy/queriesObserver.cjs +15 -3
  80. package/build/legacy/queriesObserver.cjs.map +1 -1
  81. package/build/legacy/queriesObserver.d.cts +14 -5
  82. package/build/legacy/queriesObserver.d.cts.map +1 -1
  83. package/build/legacy/queriesObserver.d.ts +14 -5
  84. package/build/legacy/queriesObserver.d.ts.map +1 -1
  85. package/build/legacy/queriesObserver.js +15 -3
  86. package/build/legacy/queriesObserver.js.map +1 -1
  87. package/build/legacy/query.cjs +89 -15
  88. package/build/legacy/query.cjs.map +1 -1
  89. package/build/legacy/query.d.cts +1 -1
  90. package/build/legacy/query.d.ts +1 -1
  91. package/build/legacy/query.js +89 -15
  92. package/build/legacy/query.js.map +1 -1
  93. package/build/legacy/queryCache.cjs +34 -12
  94. package/build/legacy/queryCache.cjs.map +1 -1
  95. package/build/legacy/queryCache.d.cts +1 -1
  96. package/build/legacy/queryCache.d.ts +1 -1
  97. package/build/legacy/queryCache.js +34 -12
  98. package/build/legacy/queryCache.js.map +1 -1
  99. package/build/legacy/queryClient.cjs +104 -32
  100. package/build/legacy/queryClient.cjs.map +1 -1
  101. package/build/legacy/queryClient.d.cts +1 -1
  102. package/build/legacy/queryClient.d.ts +1 -1
  103. package/build/legacy/queryClient.js +104 -32
  104. package/build/legacy/queryClient.js.map +1 -1
  105. package/build/legacy/queryObserver.cjs +78 -6
  106. package/build/legacy/queryObserver.cjs.map +1 -1
  107. package/build/legacy/queryObserver.d.cts +1 -1
  108. package/build/legacy/queryObserver.d.ts +1 -1
  109. package/build/legacy/queryObserver.js +78 -6
  110. package/build/legacy/queryObserver.js.map +1 -1
  111. package/build/{modern/removable-0GzhW1PK.d.cts → legacy/removable-Cw9GNGyK.d.cts} +17 -1
  112. package/build/legacy/removable-Cw9GNGyK.d.cts.map +1 -0
  113. package/build/legacy/{removable-0GzhW1PK.d.cts → removable-Cw9GNGyK.d.ts} +17 -1
  114. package/build/legacy/removable-Cw9GNGyK.d.ts.map +1 -0
  115. package/build/legacy/removable.cjs +12 -0
  116. package/build/legacy/removable.cjs.map +1 -1
  117. package/build/legacy/removable.d.cts +1 -1
  118. package/build/legacy/removable.d.ts +1 -1
  119. package/build/legacy/removable.js +12 -0
  120. package/build/legacy/removable.js.map +1 -1
  121. package/build/legacy/retryer.cjs +26 -4
  122. package/build/legacy/retryer.cjs.map +1 -1
  123. package/build/legacy/retryer.d.cts +1 -1
  124. package/build/legacy/retryer.d.ts +1 -1
  125. package/build/legacy/retryer.js +26 -4
  126. package/build/legacy/retryer.js.map +1 -1
  127. package/build/legacy/streamedQuery.cjs +3 -1
  128. package/build/legacy/streamedQuery.cjs.map +1 -1
  129. package/build/legacy/streamedQuery.d.cts +4 -2
  130. package/build/legacy/streamedQuery.d.cts.map +1 -1
  131. package/build/legacy/streamedQuery.d.ts +4 -2
  132. package/build/legacy/streamedQuery.d.ts.map +1 -1
  133. package/build/legacy/streamedQuery.js +3 -1
  134. package/build/legacy/streamedQuery.js.map +1 -1
  135. package/build/{modern/subscribable-CysQ0tne.d.cts → legacy/subscribable-czlHOxMP.d.cts} +11 -1
  136. package/build/legacy/subscribable-czlHOxMP.d.cts.map +1 -0
  137. package/build/legacy/{subscribable-CysQ0tne.d.cts → subscribable-czlHOxMP.d.ts} +11 -1
  138. package/build/legacy/subscribable-czlHOxMP.d.ts.map +1 -0
  139. package/build/legacy/subscribable.cjs +10 -0
  140. package/build/legacy/subscribable.cjs.map +1 -1
  141. package/build/legacy/subscribable.d.cts +1 -1
  142. package/build/legacy/subscribable.d.ts +1 -1
  143. package/build/legacy/subscribable.js +10 -0
  144. package/build/legacy/subscribable.js.map +1 -1
  145. package/build/legacy/timeoutManager.cjs +11 -6
  146. package/build/legacy/timeoutManager.cjs.map +1 -1
  147. package/build/legacy/timeoutManager.d.cts +23 -6
  148. package/build/legacy/timeoutManager.d.cts.map +1 -1
  149. package/build/legacy/timeoutManager.d.ts +23 -6
  150. package/build/legacy/timeoutManager.d.ts.map +1 -1
  151. package/build/legacy/timeoutManager.js +11 -6
  152. package/build/legacy/timeoutManager.js.map +1 -1
  153. package/build/legacy/types.cjs.map +1 -1
  154. package/build/legacy/types.d.cts +1 -1
  155. package/build/legacy/types.d.ts +1 -1
  156. package/build/legacy/types.js.map +1 -1
  157. package/build/legacy/utils.cjs +117 -8
  158. package/build/legacy/utils.cjs.map +1 -1
  159. package/build/legacy/utils.d.cts +1 -1
  160. package/build/legacy/utils.d.ts +1 -1
  161. package/build/legacy/utils.js +117 -8
  162. package/build/legacy/utils.js.map +1 -1
  163. package/build/modern/environmentManager.cjs +3 -1
  164. package/build/modern/environmentManager.cjs.map +1 -1
  165. package/build/modern/environmentManager.d.cts +6 -1
  166. package/build/modern/environmentManager.d.cts.map +1 -1
  167. package/build/modern/environmentManager.d.ts +6 -1
  168. package/build/modern/environmentManager.d.ts.map +1 -1
  169. package/build/modern/environmentManager.js +3 -1
  170. package/build/modern/environmentManager.js.map +1 -1
  171. package/build/modern/focusManager.cjs +4 -2
  172. package/build/modern/focusManager.cjs.map +1 -1
  173. package/build/modern/focusManager.d.cts +5 -3
  174. package/build/modern/focusManager.d.cts.map +1 -1
  175. package/build/modern/focusManager.d.ts +5 -3
  176. package/build/modern/focusManager.d.ts.map +1 -1
  177. package/build/modern/focusManager.js +4 -2
  178. package/build/modern/focusManager.js.map +1 -1
  179. package/build/modern/{hydration-B9t5w6NC.d.ts → hydration-Dfuxd5FW.d.cts} +1410 -128
  180. package/build/modern/hydration-Dfuxd5FW.d.cts.map +1 -0
  181. package/build/modern/{hydration-Br9VIGXa.d.cts → hydration-UAqdtMIf.d.ts} +1410 -128
  182. package/build/modern/hydration-UAqdtMIf.d.ts.map +1 -0
  183. package/build/modern/hydration.cjs +35 -0
  184. package/build/modern/hydration.cjs.map +1 -1
  185. package/build/modern/hydration.d.cts +1 -1
  186. package/build/modern/hydration.d.ts +1 -1
  187. package/build/modern/hydration.js +35 -0
  188. package/build/modern/hydration.js.map +1 -1
  189. package/build/modern/index.d.cts +1 -1
  190. package/build/modern/index.d.ts +1 -1
  191. package/build/modern/infiniteQueryBehavior.cjs +29 -0
  192. package/build/modern/infiniteQueryBehavior.cjs.map +1 -1
  193. package/build/modern/infiniteQueryBehavior.d.cts +16 -1
  194. package/build/modern/infiniteQueryBehavior.d.cts.map +1 -1
  195. package/build/modern/infiniteQueryBehavior.d.ts +16 -1
  196. package/build/modern/infiniteQueryBehavior.d.ts.map +1 -1
  197. package/build/modern/infiniteQueryBehavior.js +29 -0
  198. package/build/modern/infiniteQueryBehavior.js.map +1 -1
  199. package/build/modern/infiniteQueryObserver.cjs +13 -7
  200. package/build/modern/infiniteQueryObserver.cjs.map +1 -1
  201. package/build/modern/infiniteQueryObserver.d.cts +15 -9
  202. package/build/modern/infiniteQueryObserver.d.cts.map +1 -1
  203. package/build/modern/infiniteQueryObserver.d.ts +15 -9
  204. package/build/modern/infiniteQueryObserver.d.ts.map +1 -1
  205. package/build/modern/infiniteQueryObserver.js +13 -7
  206. package/build/modern/infiniteQueryObserver.js.map +1 -1
  207. package/build/modern/mutation.cjs +27 -10
  208. package/build/modern/mutation.cjs.map +1 -1
  209. package/build/modern/mutation.d.cts +1 -1
  210. package/build/modern/mutation.d.ts +1 -1
  211. package/build/modern/mutation.js +27 -10
  212. package/build/modern/mutation.js.map +1 -1
  213. package/build/modern/mutationCache.cjs +53 -12
  214. package/build/modern/mutationCache.cjs.map +1 -1
  215. package/build/modern/mutationCache.d.cts +1 -1
  216. package/build/modern/mutationCache.d.ts +1 -1
  217. package/build/modern/mutationCache.js +53 -12
  218. package/build/modern/mutationCache.js.map +1 -1
  219. package/build/modern/mutationObserver.cjs +23 -12
  220. package/build/modern/mutationObserver.cjs.map +1 -1
  221. package/build/modern/mutationObserver.d.cts +1 -1
  222. package/build/modern/mutationObserver.d.ts +1 -1
  223. package/build/modern/mutationObserver.js +23 -12
  224. package/build/modern/mutationObserver.js.map +1 -1
  225. package/build/modern/notifyManager.cjs +12 -2
  226. package/build/modern/notifyManager.cjs.map +1 -1
  227. package/build/modern/notifyManager.d.cts +19 -4
  228. package/build/modern/notifyManager.d.cts.map +1 -1
  229. package/build/modern/notifyManager.d.ts +19 -4
  230. package/build/modern/notifyManager.d.ts.map +1 -1
  231. package/build/modern/notifyManager.js +12 -2
  232. package/build/modern/notifyManager.js.map +1 -1
  233. package/build/modern/onlineManager.cjs +4 -2
  234. package/build/modern/onlineManager.cjs.map +1 -1
  235. package/build/modern/onlineManager.d.cts +5 -3
  236. package/build/modern/onlineManager.d.cts.map +1 -1
  237. package/build/modern/onlineManager.d.ts +5 -3
  238. package/build/modern/onlineManager.d.ts.map +1 -1
  239. package/build/modern/onlineManager.js +4 -2
  240. package/build/modern/onlineManager.js.map +1 -1
  241. package/build/modern/queriesObserver.cjs +15 -3
  242. package/build/modern/queriesObserver.cjs.map +1 -1
  243. package/build/modern/queriesObserver.d.cts +14 -5
  244. package/build/modern/queriesObserver.d.cts.map +1 -1
  245. package/build/modern/queriesObserver.d.ts +14 -5
  246. package/build/modern/queriesObserver.d.ts.map +1 -1
  247. package/build/modern/queriesObserver.js +15 -3
  248. package/build/modern/queriesObserver.js.map +1 -1
  249. package/build/modern/query.cjs +89 -15
  250. package/build/modern/query.cjs.map +1 -1
  251. package/build/modern/query.d.cts +1 -1
  252. package/build/modern/query.d.ts +1 -1
  253. package/build/modern/query.js +89 -15
  254. package/build/modern/query.js.map +1 -1
  255. package/build/modern/queryCache.cjs +34 -12
  256. package/build/modern/queryCache.cjs.map +1 -1
  257. package/build/modern/queryCache.d.cts +1 -1
  258. package/build/modern/queryCache.d.ts +1 -1
  259. package/build/modern/queryCache.js +34 -12
  260. package/build/modern/queryCache.js.map +1 -1
  261. package/build/modern/queryClient.cjs +104 -32
  262. package/build/modern/queryClient.cjs.map +1 -1
  263. package/build/modern/queryClient.d.cts +1 -1
  264. package/build/modern/queryClient.d.ts +1 -1
  265. package/build/modern/queryClient.js +104 -32
  266. package/build/modern/queryClient.js.map +1 -1
  267. package/build/modern/queryObserver.cjs +78 -6
  268. package/build/modern/queryObserver.cjs.map +1 -1
  269. package/build/modern/queryObserver.d.cts +1 -1
  270. package/build/modern/queryObserver.d.ts +1 -1
  271. package/build/modern/queryObserver.js +78 -6
  272. package/build/modern/queryObserver.js.map +1 -1
  273. package/build/modern/{removable-0GzhW1PK.d.ts → removable-Cw9GNGyK.d.cts} +17 -1
  274. package/build/modern/removable-Cw9GNGyK.d.cts.map +1 -0
  275. package/build/{legacy/removable-0GzhW1PK.d.ts → modern/removable-Cw9GNGyK.d.ts} +17 -1
  276. package/build/modern/removable-Cw9GNGyK.d.ts.map +1 -0
  277. package/build/modern/removable.cjs +12 -0
  278. package/build/modern/removable.cjs.map +1 -1
  279. package/build/modern/removable.d.cts +1 -1
  280. package/build/modern/removable.d.ts +1 -1
  281. package/build/modern/removable.js +12 -0
  282. package/build/modern/removable.js.map +1 -1
  283. package/build/modern/retryer.cjs +26 -4
  284. package/build/modern/retryer.cjs.map +1 -1
  285. package/build/modern/retryer.d.cts +1 -1
  286. package/build/modern/retryer.d.ts +1 -1
  287. package/build/modern/retryer.js +26 -4
  288. package/build/modern/retryer.js.map +1 -1
  289. package/build/modern/streamedQuery.cjs +3 -1
  290. package/build/modern/streamedQuery.cjs.map +1 -1
  291. package/build/modern/streamedQuery.d.cts +4 -2
  292. package/build/modern/streamedQuery.d.cts.map +1 -1
  293. package/build/modern/streamedQuery.d.ts +4 -2
  294. package/build/modern/streamedQuery.d.ts.map +1 -1
  295. package/build/modern/streamedQuery.js +3 -1
  296. package/build/modern/streamedQuery.js.map +1 -1
  297. package/build/modern/{subscribable-CysQ0tne.d.ts → subscribable-czlHOxMP.d.cts} +11 -1
  298. package/build/modern/subscribable-czlHOxMP.d.cts.map +1 -0
  299. package/build/{legacy/subscribable-CysQ0tne.d.ts → modern/subscribable-czlHOxMP.d.ts} +11 -1
  300. package/build/modern/subscribable-czlHOxMP.d.ts.map +1 -0
  301. package/build/modern/subscribable.cjs +10 -0
  302. package/build/modern/subscribable.cjs.map +1 -1
  303. package/build/modern/subscribable.d.cts +1 -1
  304. package/build/modern/subscribable.d.ts +1 -1
  305. package/build/modern/subscribable.js +10 -0
  306. package/build/modern/subscribable.js.map +1 -1
  307. package/build/modern/timeoutManager.cjs +11 -6
  308. package/build/modern/timeoutManager.cjs.map +1 -1
  309. package/build/modern/timeoutManager.d.cts +23 -6
  310. package/build/modern/timeoutManager.d.cts.map +1 -1
  311. package/build/modern/timeoutManager.d.ts +23 -6
  312. package/build/modern/timeoutManager.d.ts.map +1 -1
  313. package/build/modern/timeoutManager.js +11 -6
  314. package/build/modern/timeoutManager.js.map +1 -1
  315. package/build/modern/types.cjs.map +1 -1
  316. package/build/modern/types.d.cts +1 -1
  317. package/build/modern/types.d.ts +1 -1
  318. package/build/modern/types.js.map +1 -1
  319. package/build/modern/utils.cjs +117 -8
  320. package/build/modern/utils.cjs.map +1 -1
  321. package/build/modern/utils.d.cts +1 -1
  322. package/build/modern/utils.d.ts +1 -1
  323. package/build/modern/utils.js +117 -8
  324. package/build/modern/utils.js.map +1 -1
  325. package/package.json +3 -3
  326. package/src/environmentManager.ts +6 -1
  327. package/src/focusManager.ts +8 -6
  328. package/src/hydration.ts +42 -1
  329. package/src/infiniteQueryBehavior.ts +29 -0
  330. package/src/infiniteQueryObserver.ts +20 -14
  331. package/src/mutation.ts +32 -11
  332. package/src/mutationCache.ts +53 -12
  333. package/src/mutationObserver.ts +29 -14
  334. package/src/notifyManager.ts +12 -2
  335. package/src/onlineManager.ts +7 -5
  336. package/src/queriesObserver.ts +20 -5
  337. package/src/query.ts +153 -20
  338. package/src/queryCache.ts +54 -13
  339. package/src/queryClient.ts +110 -38
  340. package/src/queryObserver.ts +88 -12
  341. package/src/removable.ts +16 -0
  342. package/src/retryer.ts +57 -4
  343. package/src/streamedQuery.ts +4 -3
  344. package/src/subscribable.ts +10 -0
  345. package/src/timeoutManager.ts +23 -6
  346. package/src/types.ts +801 -27
  347. package/src/utils.ts +130 -10
  348. package/build/legacy/hydration-B9t5w6NC.d.ts.map +0 -1
  349. package/build/legacy/hydration-Br9VIGXa.d.cts.map +0 -1
  350. package/build/legacy/removable-0GzhW1PK.d.cts.map +0 -1
  351. package/build/legacy/removable-0GzhW1PK.d.ts.map +0 -1
  352. package/build/legacy/subscribable-CysQ0tne.d.cts.map +0 -1
  353. package/build/legacy/subscribable-CysQ0tne.d.ts.map +0 -1
  354. package/build/modern/hydration-B9t5w6NC.d.ts.map +0 -1
  355. package/build/modern/hydration-Br9VIGXa.d.cts.map +0 -1
  356. package/build/modern/removable-0GzhW1PK.d.cts.map +0 -1
  357. package/build/modern/removable-0GzhW1PK.d.ts.map +0 -1
  358. package/build/modern/subscribable-CysQ0tne.d.cts.map +0 -1
  359. package/build/modern/subscribable-CysQ0tne.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"notifyManager.cjs","names":["systemSetTimeoutZero"],"sources":["../../src/notifyManager.ts"],"sourcesContent":["// TYPES\n\nimport { systemSetTimeoutZero } from './timeoutManager'\n\ntype NotifyCallback = () => void\n\ntype NotifyFunction = (callback: () => void) => void\n\ntype BatchNotifyFunction = (callback: () => void) => void\n\ntype BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void\n\ntype ScheduleFunction = (callback: () => void) => void\n\n/**\n * Default scheduling function used by the notify manager.\n * Schedules the callback with the system's `setTimeout(callback, 0)`.\n */\nexport const defaultScheduler: ScheduleFunction = systemSetTimeoutZero\n\nexport function createNotifyManager() {\n let queue: Array<NotifyCallback> = []\n let transactions = 0\n let notifyFn: NotifyFunction = (callback) => {\n callback()\n }\n let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {\n callback()\n }\n let scheduleFn = defaultScheduler\n\n const schedule = (callback: NotifyCallback): void => {\n if (transactions) {\n queue.push(callback)\n } else {\n scheduleFn(() => {\n notifyFn(callback)\n })\n }\n }\n const flush = (): void => {\n const originalQueue = queue\n queue = []\n if (originalQueue.length) {\n scheduleFn(() => {\n batchNotifyFn(() => {\n originalQueue.forEach((callback) => {\n notifyFn(callback)\n })\n })\n })\n }\n }\n\n return {\n /**\n * Batches all updates scheduled inside the passed callback.\n * This is mainly used internally to optimize query client updating.\n * Batches can be nested; the queue is only flushed once the outermost `batch` call finishes.\n * The return value of `callback` is passed through.\n */\n batch: <T>(callback: () => T): T => {\n let result\n transactions++\n try {\n result = callback()\n } finally {\n transactions--\n if (!transactions) {\n flush()\n }\n }\n return result\n },\n /**\n * All calls to the wrapped function will be batched.\n */\n batchCalls: <T extends Array<unknown>>(\n callback: BatchCallsCallback<T>,\n ): BatchCallsCallback<T> => {\n return (...args) => {\n schedule(() => {\n callback(...args)\n })\n }\n },\n /**\n * Schedules a function to be run on the next batch.\n * By default, the batch is run with a `setTimeout`, but this can be configured via `setScheduler`.\n */\n schedule,\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n */\n setNotifyFunction: (fn: NotifyFunction) => {\n notifyFn = fn\n },\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * Framework adapters use this to plug in their own batching primitive, so that a single query\n * update only triggers one re-render instead of one per subscriber.\n *\n * @example\n * ```ts\n * import { notifyManager } from '@tanstack/query-core'\n * import { batch } from 'solid-js'\n *\n * notifyManager.setBatchNotifyFunction(batch)\n * ```\n */\n setBatchNotifyFunction: (fn: BatchNotifyFunction) => {\n batchNotifyFn = fn\n },\n /**\n * Configures a custom callback that schedules when the next batch runs.\n * The default behavior is `setTimeout(callback, 0)`.\n *\n * @example\n * ```ts\n * import { notifyManager } from '@tanstack/query-core'\n *\n * // Schedule batches in the next microtask\n * notifyManager.setScheduler(queueMicrotask)\n *\n * // Schedule batches before the next frame is rendered\n * notifyManager.setScheduler(requestAnimationFrame)\n *\n * // Schedule batches some time in the future\n * notifyManager.setScheduler((cb) => setTimeout(cb, 10))\n * ```\n */\n setScheduler: (fn: ScheduleFunction) => {\n scheduleFn = fn\n },\n } as const\n}\n\n// SINGLETON\n\n/**\n * Handles scheduling and batching callbacks in TanStack Query.\n */\nexport const notifyManager = createNotifyManager()\n"],"mappings":";;;;;;AAkBA,MAAa,iDAAqCA,CAAAA,CAAAA;AAElD,SAAgB,sBAAsB;CACpC,IAAI,QAA+B,CAAC;CACpC,IAAI,eAAe;CACnB,IAAI,YAA4B,aAAa;EAC3C,SAAS;CACX;CACA,IAAI,iBAAsC,aAAyB;EACjE,SAAS;CACX;CACA,IAAI,aAAa;CAEjB,MAAM,YAAY,aAAmC;EACnD,IAAI,cACF,MAAM,KAAK,QAAQ;OAEnB,iBAAiB;GACf,SAAS,QAAQ;EACnB,CAAC;CAEL;CACA,MAAM,cAAoB;EACxB,MAAM,gBAAgB;EACtB,QAAQ,CAAC;EACT,IAAI,cAAc,QAChB,iBAAiB;GACf,oBAAoB;IAClB,cAAc,SAAS,aAAa;KAClC,SAAS,QAAQ;IACnB,CAAC;GACH,CAAC;EACH,CAAC;CAEL;CAEA,OAAO;;;;;;;EAOL,QAAW,aAAyB;GAClC,IAAI;GACJ;GACA,IAAI;IACF,SAAS,SAAS;GACpB,UAAU;IACR;IACA,IAAI,CAAC,cACH,MAAM;GAEV;GACA,OAAO;EACT;;;;EAIA,aACE,aAC0B;GAC1B,QAAQ,GAAG,SAAS;IAClB,eAAe;KACb,SAAS,GAAG,IAAI;IAClB,CAAC;GACH;EACF;;;;;EAKA;;;;;EAKA,oBAAoB,OAAuB;GACzC,WAAW;EACb;;;;;;;;;;;;;;EAcA,yBAAyB,OAA4B;GACnD,gBAAgB;EAClB;;;;;;;;;;;;;;;;;;;EAmBA,eAAe,OAAyB;GACtC,aAAa;EACf;CACF;AACF;;;;AAOA,MAAa,gBAAgB,oBAAoB"}
1
+ {"version":3,"file":"notifyManager.cjs","names":["systemSetTimeoutZero"],"sources":["../../src/notifyManager.ts"],"sourcesContent":["// TYPES\n\nimport { systemSetTimeoutZero } from './timeoutManager'\n\ntype NotifyCallback = () => void\n\ntype NotifyFunction = (callback: () => void) => void\n\ntype BatchNotifyFunction = (callback: () => void) => void\n\ntype BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void\n\ntype ScheduleFunction = (callback: () => void) => void\n\n/**\n * Default scheduling function used by the notify manager.\n * Schedules the callback with the system's `setTimeout(callback, 0)`.\n */\nexport const defaultScheduler: ScheduleFunction = systemSetTimeoutZero\n\n/**\n * Creates a notify manager, which schedules and batches notifications to subscribers. Query uses a\n * single instance of it, exported as {@link notifyManager}.\n * @returns A new notify manager.\n */\nexport function createNotifyManager() {\n let queue: Array<NotifyCallback> = []\n let transactions = 0\n let notifyFn: NotifyFunction = (callback) => {\n callback()\n }\n let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {\n callback()\n }\n let scheduleFn = defaultScheduler\n\n const schedule = (callback: NotifyCallback): void => {\n if (transactions) {\n queue.push(callback)\n } else {\n scheduleFn(() => {\n notifyFn(callback)\n })\n }\n }\n const flush = (): void => {\n const originalQueue = queue\n queue = []\n if (originalQueue.length) {\n scheduleFn(() => {\n batchNotifyFn(() => {\n originalQueue.forEach((callback) => {\n notifyFn(callback)\n })\n })\n })\n }\n }\n\n return {\n /**\n * Batches all updates scheduled inside the passed callback.\n * This is mainly used internally to optimize query client updating.\n * Batches can be nested; the queue is only flushed once the outermost `batch` call finishes.\n * The return value of `callback` is passed through.\n * @param callback - The function to run in the batch.\n * @returns The return value of `callback`.\n */\n batch: <T>(callback: () => T): T => {\n let result\n transactions++\n try {\n result = callback()\n } finally {\n transactions--\n if (!transactions) {\n flush()\n }\n }\n return result\n },\n /**\n * All calls to the wrapped function will be batched.\n * @param callback - The function to wrap.\n * @returns A function that schedules a call to `callback` with the given arguments.\n */\n batchCalls: <T extends Array<unknown>>(\n callback: BatchCallsCallback<T>,\n ): BatchCallsCallback<T> => {\n return (...args) => {\n schedule(() => {\n callback(...args)\n })\n }\n },\n /**\n * Schedules a function to be run on the next batch.\n * By default, the batch is run with a `setTimeout`, but this can be configured via `setScheduler`.\n */\n schedule,\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n * @param fn - Receives each notification callback and must call it.\n */\n setNotifyFunction: (fn: NotifyFunction) => {\n notifyFn = fn\n },\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * Framework adapters use this to plug in their own batching primitive, so that a single query\n * update only triggers one re-render instead of one per subscriber.\n * @param fn - Receives a function that runs a batch of notifications and must call it.\n * @example\n * ```ts\n * import { notifyManager } from '@tanstack/query-core'\n * import { batch } from 'solid-js'\n *\n * notifyManager.setBatchNotifyFunction(batch)\n * ```\n */\n setBatchNotifyFunction: (fn: BatchNotifyFunction) => {\n batchNotifyFn = fn\n },\n /**\n * Configures a custom callback that schedules when the next batch runs.\n * The default behavior is `setTimeout(callback, 0)`.\n * @param fn - Receives a callback that runs the next batch, and schedules it.\n * @example\n * ```ts\n * import { notifyManager } from '@tanstack/query-core'\n *\n * // Schedule batches in the next microtask\n * notifyManager.setScheduler(queueMicrotask)\n *\n * // Schedule batches before the next frame is rendered\n * notifyManager.setScheduler(requestAnimationFrame)\n *\n * // Schedule batches some time in the future\n * notifyManager.setScheduler((cb) => setTimeout(cb, 10))\n * ```\n */\n setScheduler: (fn: ScheduleFunction) => {\n scheduleFn = fn\n },\n } as const\n}\n\n// SINGLETON\n\n/**\n * Handles scheduling and batching callbacks in TanStack Query.\n */\nexport const notifyManager = createNotifyManager()\n"],"mappings":";;;;;;AAkBA,MAAa,iDAAqCA,CAAAA,CAAAA;;;;;;AAOlD,SAAgB,sBAAsB;CACpC,IAAI,QAA+B,CAAC;CACpC,IAAI,eAAe;CACnB,IAAI,YAA4B,aAAa;EAC3C,SAAS;CACX;CACA,IAAI,iBAAsC,aAAyB;EACjE,SAAS;CACX;CACA,IAAI,aAAa;CAEjB,MAAM,YAAY,aAAmC;EACnD,IAAI,cACF,MAAM,KAAK,QAAQ;OAEnB,iBAAiB;GACf,SAAS,QAAQ;EACnB,CAAC;CAEL;CACA,MAAM,cAAoB;EACxB,MAAM,gBAAgB;EACtB,QAAQ,CAAC;EACT,IAAI,cAAc,QAChB,iBAAiB;GACf,oBAAoB;IAClB,cAAc,SAAS,aAAa;KAClC,SAAS,QAAQ;IACnB,CAAC;GACH,CAAC;EACH,CAAC;CAEL;CAEA,OAAO;;;;;;;;;EASL,QAAW,aAAyB;GAClC,IAAI;GACJ;GACA,IAAI;IACF,SAAS,SAAS;GACpB,UAAU;IACR;IACA,IAAI,CAAC,cACH,MAAM;GAEV;GACA,OAAO;EACT;;;;;;EAMA,aACE,aAC0B;GAC1B,QAAQ,GAAG,SAAS;IAClB,eAAe;KACb,SAAS,GAAG,IAAI;IAClB,CAAC;GACH;EACF;;;;;EAKA;;;;;;EAMA,oBAAoB,OAAuB;GACzC,WAAW;EACb;;;;;;;;;;;;;;EAcA,yBAAyB,OAA4B;GACnD,gBAAgB;EAClB;;;;;;;;;;;;;;;;;;;EAmBA,eAAe,OAAyB;GACtC,aAAa;EACf;CACF;AACF;;;;AAOA,MAAa,gBAAgB,oBAAoB"}
@@ -9,16 +9,25 @@ type ScheduleFunction = (callback: () => void) => void;
9
9
  * Schedules the callback with the system's `setTimeout(callback, 0)`.
10
10
  */
11
11
  export declare const defaultScheduler: ScheduleFunction;
12
+ /**
13
+ * Creates a notify manager, which schedules and batches notifications to subscribers. Query uses a
14
+ * single instance of it, exported as {@link notifyManager}.
15
+ * @returns A new notify manager.
16
+ */
12
17
  export declare function createNotifyManager(): {
13
18
  /**
14
19
  * Batches all updates scheduled inside the passed callback.
15
20
  * This is mainly used internally to optimize query client updating.
16
21
  * Batches can be nested; the queue is only flushed once the outermost `batch` call finishes.
17
22
  * The return value of `callback` is passed through.
23
+ * @param callback - The function to run in the batch.
24
+ * @returns The return value of `callback`.
18
25
  */
19
26
  readonly batch: <T>(callback: () => T) => T;
20
27
  /**
21
28
  * All calls to the wrapped function will be batched.
29
+ * @param callback - The function to wrap.
30
+ * @returns A function that schedules a call to `callback` with the given arguments.
22
31
  */
23
32
  readonly batchCalls: <T extends Array<unknown>>(callback: BatchCallsCallback<T>) => BatchCallsCallback<T>;
24
33
  /**
@@ -29,13 +38,14 @@ export declare function createNotifyManager(): {
29
38
  /**
30
39
  * Use this method to set a custom notify function.
31
40
  * This can be used to for example wrap notifications with `React.act` while running tests.
41
+ * @param fn - Receives each notification callback and must call it.
32
42
  */
33
43
  readonly setNotifyFunction: (fn: NotifyFunction) => void;
34
44
  /**
35
45
  * Use this method to set a custom function to batch notifications together into a single tick.
36
46
  * Framework adapters use this to plug in their own batching primitive, so that a single query
37
47
  * update only triggers one re-render instead of one per subscriber.
38
- *
48
+ * @param fn - Receives a function that runs a batch of notifications and must call it.
39
49
  * @example
40
50
  * ```ts
41
51
  * import { notifyManager } from '@tanstack/query-core'
@@ -48,7 +58,7 @@ export declare function createNotifyManager(): {
48
58
  /**
49
59
  * Configures a custom callback that schedules when the next batch runs.
50
60
  * The default behavior is `setTimeout(callback, 0)`.
51
- *
61
+ * @param fn - Receives a callback that runs the next batch, and schedules it.
52
62
  * @example
53
63
  * ```ts
54
64
  * import { notifyManager } from '@tanstack/query-core'
@@ -74,10 +84,14 @@ export declare const notifyManager: {
74
84
  * This is mainly used internally to optimize query client updating.
75
85
  * Batches can be nested; the queue is only flushed once the outermost `batch` call finishes.
76
86
  * The return value of `callback` is passed through.
87
+ * @param callback - The function to run in the batch.
88
+ * @returns The return value of `callback`.
77
89
  */
78
90
  readonly batch: <T>(callback: () => T) => T;
79
91
  /**
80
92
  * All calls to the wrapped function will be batched.
93
+ * @param callback - The function to wrap.
94
+ * @returns A function that schedules a call to `callback` with the given arguments.
81
95
  */
82
96
  readonly batchCalls: <T extends Array<unknown>>(callback: BatchCallsCallback<T>) => BatchCallsCallback<T>;
83
97
  /**
@@ -88,13 +102,14 @@ export declare const notifyManager: {
88
102
  /**
89
103
  * Use this method to set a custom notify function.
90
104
  * This can be used to for example wrap notifications with `React.act` while running tests.
105
+ * @param fn - Receives each notification callback and must call it.
91
106
  */
92
107
  readonly setNotifyFunction: (fn: NotifyFunction) => void;
93
108
  /**
94
109
  * Use this method to set a custom function to batch notifications together into a single tick.
95
110
  * Framework adapters use this to plug in their own batching primitive, so that a single query
96
111
  * update only triggers one re-render instead of one per subscriber.
97
- *
112
+ * @param fn - Receives a function that runs a batch of notifications and must call it.
98
113
  * @example
99
114
  * ```ts
100
115
  * import { notifyManager } from '@tanstack/query-core'
@@ -107,7 +122,7 @@ export declare const notifyManager: {
107
122
  /**
108
123
  * Configures a custom callback that schedules when the next batch runs.
109
124
  * The default behavior is `setTimeout(callback, 0)`.
110
- *
125
+ * @param fn - Receives a callback that runs the next batch, and schedules it.
111
126
  * @example
112
127
  * ```ts
113
128
  * import { notifyManager } from '@tanstack/query-core'
@@ -1 +1 @@
1
- {"version":3,"file":"notifyManager.d.cts","names":[],"sources":["../../src/notifyManager.ts"],"mappings":";KAIK;KAEA,kBAAkB;KAElB,uBAAuB;KAEvB,mBAAmB,UAAU,sBAAsB,MAAM;KAEzD,oBAAoB;;;;;qBAMZ,kBAAkB;wBAEf;;;;;;;WAyCJ,QAAA,GAAC,gBAAkB,MAAI;;;;WAgBlB,aAAA,UAAU,gBAAc,UACzB,mBAAmB,OAC5B,mBAAmB;;;;;WAhDI,WAAA,UAAA;;;;;WAgEF,oBAAA,IAAA;;;;;;;;;;;;;;WAgBK,yBAAA,IAAA;;;;;;;;;;;;;;;;;;;WAqBV,eAAA,IAAA;;;;;qBAWV;;;;;;;WAlFD,QAAA,GAAC,gBAAkB,MAAI;;;;WAgBlB,aAAA,UAAU,gBAAc,UACzB,mBAAmB,OAC5B,mBAAmB;;;;;WAhDI,WAAA,UAAA;;;;;WAgEF,oBAAA,IAAA;;;;;;;;;;;;;;WAgBK,yBAAA,IAAA;;;;;;;;;;;;;;;;;;;WAqBV,eAAA,IAAA"}
1
+ {"version":3,"file":"notifyManager.d.cts","names":[],"sources":["../../src/notifyManager.ts"],"mappings":";KAIK;KAEA,kBAAkB;KAElB,uBAAuB;KAEvB,mBAAmB,UAAU,sBAAsB,MAAM;KAEzD,oBAAoB;;;;;qBAMZ,kBAAkB;;;;;;wBAOf;;;;;;;;;WA2CJ,QAAA,GAAC,gBAAkB,MAAI;;;;;;WAkBlB,aAAA,UAAU,gBAAc,UACzB,mBAAmB,OAC5B,mBAAmB;;;;;WApDI,WAAA,UAAA;;;;;;WAqEF,oBAAA,IAAA;;;;;;;;;;;;;;WAgBK,yBAAA,IAAA;;;;;;;;;;;;;;;;;;;WAqBV,eAAA,IAAA;;;;;qBAWV;;;;;;;;;WArFD,QAAA,GAAC,gBAAkB,MAAI;;;;;;WAkBlB,aAAA,UAAU,gBAAc,UACzB,mBAAmB,OAC5B,mBAAmB;;;;;WApDI,WAAA,UAAA;;;;;;WAqEF,oBAAA,IAAA;;;;;;;;;;;;;;WAgBK,yBAAA,IAAA;;;;;;;;;;;;;;;;;;;WAqBV,eAAA,IAAA"}
@@ -9,16 +9,25 @@ type ScheduleFunction = (callback: () => void) => void;
9
9
  * Schedules the callback with the system's `setTimeout(callback, 0)`.
10
10
  */
11
11
  export declare const defaultScheduler: ScheduleFunction;
12
+ /**
13
+ * Creates a notify manager, which schedules and batches notifications to subscribers. Query uses a
14
+ * single instance of it, exported as {@link notifyManager}.
15
+ * @returns A new notify manager.
16
+ */
12
17
  export declare function createNotifyManager(): {
13
18
  /**
14
19
  * Batches all updates scheduled inside the passed callback.
15
20
  * This is mainly used internally to optimize query client updating.
16
21
  * Batches can be nested; the queue is only flushed once the outermost `batch` call finishes.
17
22
  * The return value of `callback` is passed through.
23
+ * @param callback - The function to run in the batch.
24
+ * @returns The return value of `callback`.
18
25
  */
19
26
  readonly batch: <T>(callback: () => T) => T;
20
27
  /**
21
28
  * All calls to the wrapped function will be batched.
29
+ * @param callback - The function to wrap.
30
+ * @returns A function that schedules a call to `callback` with the given arguments.
22
31
  */
23
32
  readonly batchCalls: <T extends Array<unknown>>(callback: BatchCallsCallback<T>) => BatchCallsCallback<T>;
24
33
  /**
@@ -29,13 +38,14 @@ export declare function createNotifyManager(): {
29
38
  /**
30
39
  * Use this method to set a custom notify function.
31
40
  * This can be used to for example wrap notifications with `React.act` while running tests.
41
+ * @param fn - Receives each notification callback and must call it.
32
42
  */
33
43
  readonly setNotifyFunction: (fn: NotifyFunction) => void;
34
44
  /**
35
45
  * Use this method to set a custom function to batch notifications together into a single tick.
36
46
  * Framework adapters use this to plug in their own batching primitive, so that a single query
37
47
  * update only triggers one re-render instead of one per subscriber.
38
- *
48
+ * @param fn - Receives a function that runs a batch of notifications and must call it.
39
49
  * @example
40
50
  * ```ts
41
51
  * import { notifyManager } from '@tanstack/query-core'
@@ -48,7 +58,7 @@ export declare function createNotifyManager(): {
48
58
  /**
49
59
  * Configures a custom callback that schedules when the next batch runs.
50
60
  * The default behavior is `setTimeout(callback, 0)`.
51
- *
61
+ * @param fn - Receives a callback that runs the next batch, and schedules it.
52
62
  * @example
53
63
  * ```ts
54
64
  * import { notifyManager } from '@tanstack/query-core'
@@ -74,10 +84,14 @@ export declare const notifyManager: {
74
84
  * This is mainly used internally to optimize query client updating.
75
85
  * Batches can be nested; the queue is only flushed once the outermost `batch` call finishes.
76
86
  * The return value of `callback` is passed through.
87
+ * @param callback - The function to run in the batch.
88
+ * @returns The return value of `callback`.
77
89
  */
78
90
  readonly batch: <T>(callback: () => T) => T;
79
91
  /**
80
92
  * All calls to the wrapped function will be batched.
93
+ * @param callback - The function to wrap.
94
+ * @returns A function that schedules a call to `callback` with the given arguments.
81
95
  */
82
96
  readonly batchCalls: <T extends Array<unknown>>(callback: BatchCallsCallback<T>) => BatchCallsCallback<T>;
83
97
  /**
@@ -88,13 +102,14 @@ export declare const notifyManager: {
88
102
  /**
89
103
  * Use this method to set a custom notify function.
90
104
  * This can be used to for example wrap notifications with `React.act` while running tests.
105
+ * @param fn - Receives each notification callback and must call it.
91
106
  */
92
107
  readonly setNotifyFunction: (fn: NotifyFunction) => void;
93
108
  /**
94
109
  * Use this method to set a custom function to batch notifications together into a single tick.
95
110
  * Framework adapters use this to plug in their own batching primitive, so that a single query
96
111
  * update only triggers one re-render instead of one per subscriber.
97
- *
112
+ * @param fn - Receives a function that runs a batch of notifications and must call it.
98
113
  * @example
99
114
  * ```ts
100
115
  * import { notifyManager } from '@tanstack/query-core'
@@ -107,7 +122,7 @@ export declare const notifyManager: {
107
122
  /**
108
123
  * Configures a custom callback that schedules when the next batch runs.
109
124
  * The default behavior is `setTimeout(callback, 0)`.
110
- *
125
+ * @param fn - Receives a callback that runs the next batch, and schedules it.
111
126
  * @example
112
127
  * ```ts
113
128
  * import { notifyManager } from '@tanstack/query-core'
@@ -1 +1 @@
1
- {"version":3,"file":"notifyManager.d.ts","names":[],"sources":["../../src/notifyManager.ts"],"mappings":";KAIK;KAEA,kBAAkB;KAElB,uBAAuB;KAEvB,mBAAmB,UAAU,sBAAsB,MAAM;KAEzD,oBAAoB;;;;;qBAMZ,kBAAkB;wBAEf;;;;;;;WAyCJ,QAAA,GAAC,gBAAkB,MAAI;;;;WAgBlB,aAAA,UAAU,gBAAc,UACzB,mBAAmB,OAC5B,mBAAmB;;;;;WAhDI,WAAA,UAAA;;;;;WAgEF,oBAAA,IAAA;;;;;;;;;;;;;;WAgBK,yBAAA,IAAA;;;;;;;;;;;;;;;;;;;WAqBV,eAAA,IAAA;;;;;qBAWV;;;;;;;WAlFD,QAAA,GAAC,gBAAkB,MAAI;;;;WAgBlB,aAAA,UAAU,gBAAc,UACzB,mBAAmB,OAC5B,mBAAmB;;;;;WAhDI,WAAA,UAAA;;;;;WAgEF,oBAAA,IAAA;;;;;;;;;;;;;;WAgBK,yBAAA,IAAA;;;;;;;;;;;;;;;;;;;WAqBV,eAAA,IAAA"}
1
+ {"version":3,"file":"notifyManager.d.ts","names":[],"sources":["../../src/notifyManager.ts"],"mappings":";KAIK;KAEA,kBAAkB;KAElB,uBAAuB;KAEvB,mBAAmB,UAAU,sBAAsB,MAAM;KAEzD,oBAAoB;;;;;qBAMZ,kBAAkB;;;;;;wBAOf;;;;;;;;;WA2CJ,QAAA,GAAC,gBAAkB,MAAI;;;;;;WAkBlB,aAAA,UAAU,gBAAc,UACzB,mBAAmB,OAC5B,mBAAmB;;;;;WApDI,WAAA,UAAA;;;;;;WAqEF,oBAAA,IAAA;;;;;;;;;;;;;;WAgBK,yBAAA,IAAA;;;;;;;;;;;;;;;;;;;WAqBV,eAAA,IAAA;;;;;qBAWV;;;;;;;;;WArFD,QAAA,GAAC,gBAAkB,MAAI;;;;;;WAkBlB,aAAA,UAAU,gBAAc,UACzB,mBAAmB,OAC5B,mBAAmB;;;;;WApDI,WAAA,UAAA;;;;;;WAqEF,oBAAA,IAAA;;;;;;;;;;;;;;WAgBK,yBAAA,IAAA;;;;;;;;;;;;;;;;;;;WAqBV,eAAA,IAAA"}
@@ -5,6 +5,11 @@ import { systemSetTimeoutZero } from "./timeoutManager.js";
5
5
  * Schedules the callback with the system's `setTimeout(callback, 0)`.
6
6
  */
7
7
  const defaultScheduler = systemSetTimeoutZero;
8
+ /**
9
+ * Creates a notify manager, which schedules and batches notifications to subscribers. Query uses a
10
+ * single instance of it, exported as {@link notifyManager}.
11
+ * @returns A new notify manager.
12
+ */
8
13
  function createNotifyManager() {
9
14
  let queue = [];
10
15
  let transactions = 0;
@@ -38,6 +43,8 @@ function createNotifyManager() {
38
43
  * This is mainly used internally to optimize query client updating.
39
44
  * Batches can be nested; the queue is only flushed once the outermost `batch` call finishes.
40
45
  * The return value of `callback` is passed through.
46
+ * @param callback - The function to run in the batch.
47
+ * @returns The return value of `callback`.
41
48
  */
42
49
  batch: (callback) => {
43
50
  let result;
@@ -52,6 +59,8 @@ function createNotifyManager() {
52
59
  },
53
60
  /**
54
61
  * All calls to the wrapped function will be batched.
62
+ * @param callback - The function to wrap.
63
+ * @returns A function that schedules a call to `callback` with the given arguments.
55
64
  */
56
65
  batchCalls: (callback) => {
57
66
  return (...args) => {
@@ -68,6 +77,7 @@ function createNotifyManager() {
68
77
  /**
69
78
  * Use this method to set a custom notify function.
70
79
  * This can be used to for example wrap notifications with `React.act` while running tests.
80
+ * @param fn - Receives each notification callback and must call it.
71
81
  */
72
82
  setNotifyFunction: (fn) => {
73
83
  notifyFn = fn;
@@ -76,7 +86,7 @@ function createNotifyManager() {
76
86
  * Use this method to set a custom function to batch notifications together into a single tick.
77
87
  * Framework adapters use this to plug in their own batching primitive, so that a single query
78
88
  * update only triggers one re-render instead of one per subscriber.
79
- *
89
+ * @param fn - Receives a function that runs a batch of notifications and must call it.
80
90
  * @example
81
91
  * ```ts
82
92
  * import { notifyManager } from '@tanstack/query-core'
@@ -91,7 +101,7 @@ function createNotifyManager() {
91
101
  /**
92
102
  * Configures a custom callback that schedules when the next batch runs.
93
103
  * The default behavior is `setTimeout(callback, 0)`.
94
- *
104
+ * @param fn - Receives a callback that runs the next batch, and schedules it.
95
105
  * @example
96
106
  * ```ts
97
107
  * import { notifyManager } from '@tanstack/query-core'
@@ -1 +1 @@
1
- {"version":3,"file":"notifyManager.js","names":[],"sources":["../../src/notifyManager.ts"],"sourcesContent":["// TYPES\n\nimport { systemSetTimeoutZero } from './timeoutManager'\n\ntype NotifyCallback = () => void\n\ntype NotifyFunction = (callback: () => void) => void\n\ntype BatchNotifyFunction = (callback: () => void) => void\n\ntype BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void\n\ntype ScheduleFunction = (callback: () => void) => void\n\n/**\n * Default scheduling function used by the notify manager.\n * Schedules the callback with the system's `setTimeout(callback, 0)`.\n */\nexport const defaultScheduler: ScheduleFunction = systemSetTimeoutZero\n\nexport function createNotifyManager() {\n let queue: Array<NotifyCallback> = []\n let transactions = 0\n let notifyFn: NotifyFunction = (callback) => {\n callback()\n }\n let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {\n callback()\n }\n let scheduleFn = defaultScheduler\n\n const schedule = (callback: NotifyCallback): void => {\n if (transactions) {\n queue.push(callback)\n } else {\n scheduleFn(() => {\n notifyFn(callback)\n })\n }\n }\n const flush = (): void => {\n const originalQueue = queue\n queue = []\n if (originalQueue.length) {\n scheduleFn(() => {\n batchNotifyFn(() => {\n originalQueue.forEach((callback) => {\n notifyFn(callback)\n })\n })\n })\n }\n }\n\n return {\n /**\n * Batches all updates scheduled inside the passed callback.\n * This is mainly used internally to optimize query client updating.\n * Batches can be nested; the queue is only flushed once the outermost `batch` call finishes.\n * The return value of `callback` is passed through.\n */\n batch: <T>(callback: () => T): T => {\n let result\n transactions++\n try {\n result = callback()\n } finally {\n transactions--\n if (!transactions) {\n flush()\n }\n }\n return result\n },\n /**\n * All calls to the wrapped function will be batched.\n */\n batchCalls: <T extends Array<unknown>>(\n callback: BatchCallsCallback<T>,\n ): BatchCallsCallback<T> => {\n return (...args) => {\n schedule(() => {\n callback(...args)\n })\n }\n },\n /**\n * Schedules a function to be run on the next batch.\n * By default, the batch is run with a `setTimeout`, but this can be configured via `setScheduler`.\n */\n schedule,\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n */\n setNotifyFunction: (fn: NotifyFunction) => {\n notifyFn = fn\n },\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * Framework adapters use this to plug in their own batching primitive, so that a single query\n * update only triggers one re-render instead of one per subscriber.\n *\n * @example\n * ```ts\n * import { notifyManager } from '@tanstack/query-core'\n * import { batch } from 'solid-js'\n *\n * notifyManager.setBatchNotifyFunction(batch)\n * ```\n */\n setBatchNotifyFunction: (fn: BatchNotifyFunction) => {\n batchNotifyFn = fn\n },\n /**\n * Configures a custom callback that schedules when the next batch runs.\n * The default behavior is `setTimeout(callback, 0)`.\n *\n * @example\n * ```ts\n * import { notifyManager } from '@tanstack/query-core'\n *\n * // Schedule batches in the next microtask\n * notifyManager.setScheduler(queueMicrotask)\n *\n * // Schedule batches before the next frame is rendered\n * notifyManager.setScheduler(requestAnimationFrame)\n *\n * // Schedule batches some time in the future\n * notifyManager.setScheduler((cb) => setTimeout(cb, 10))\n * ```\n */\n setScheduler: (fn: ScheduleFunction) => {\n scheduleFn = fn\n },\n } as const\n}\n\n// SINGLETON\n\n/**\n * Handles scheduling and batching callbacks in TanStack Query.\n */\nexport const notifyManager = createNotifyManager()\n"],"mappings":";;;;;;AAkBA,MAAa,mBAAqC;AAElD,SAAgB,sBAAsB;CACpC,IAAI,QAA+B,CAAC;CACpC,IAAI,eAAe;CACnB,IAAI,YAA4B,aAAa;EAC3C,SAAS;CACX;CACA,IAAI,iBAAsC,aAAyB;EACjE,SAAS;CACX;CACA,IAAI,aAAa;CAEjB,MAAM,YAAY,aAAmC;EACnD,IAAI,cACF,MAAM,KAAK,QAAQ;OAEnB,iBAAiB;GACf,SAAS,QAAQ;EACnB,CAAC;CAEL;CACA,MAAM,cAAoB;EACxB,MAAM,gBAAgB;EACtB,QAAQ,CAAC;EACT,IAAI,cAAc,QAChB,iBAAiB;GACf,oBAAoB;IAClB,cAAc,SAAS,aAAa;KAClC,SAAS,QAAQ;IACnB,CAAC;GACH,CAAC;EACH,CAAC;CAEL;CAEA,OAAO;;;;;;;EAOL,QAAW,aAAyB;GAClC,IAAI;GACJ;GACA,IAAI;IACF,SAAS,SAAS;GACpB,UAAU;IACR;IACA,IAAI,CAAC,cACH,MAAM;GAEV;GACA,OAAO;EACT;;;;EAIA,aACE,aAC0B;GAC1B,QAAQ,GAAG,SAAS;IAClB,eAAe;KACb,SAAS,GAAG,IAAI;IAClB,CAAC;GACH;EACF;;;;;EAKA;;;;;EAKA,oBAAoB,OAAuB;GACzC,WAAW;EACb;;;;;;;;;;;;;;EAcA,yBAAyB,OAA4B;GACnD,gBAAgB;EAClB;;;;;;;;;;;;;;;;;;;EAmBA,eAAe,OAAyB;GACtC,aAAa;EACf;CACF;AACF;;;;AAOA,MAAa,gBAAgB,oBAAoB"}
1
+ {"version":3,"file":"notifyManager.js","names":[],"sources":["../../src/notifyManager.ts"],"sourcesContent":["// TYPES\n\nimport { systemSetTimeoutZero } from './timeoutManager'\n\ntype NotifyCallback = () => void\n\ntype NotifyFunction = (callback: () => void) => void\n\ntype BatchNotifyFunction = (callback: () => void) => void\n\ntype BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void\n\ntype ScheduleFunction = (callback: () => void) => void\n\n/**\n * Default scheduling function used by the notify manager.\n * Schedules the callback with the system's `setTimeout(callback, 0)`.\n */\nexport const defaultScheduler: ScheduleFunction = systemSetTimeoutZero\n\n/**\n * Creates a notify manager, which schedules and batches notifications to subscribers. Query uses a\n * single instance of it, exported as {@link notifyManager}.\n * @returns A new notify manager.\n */\nexport function createNotifyManager() {\n let queue: Array<NotifyCallback> = []\n let transactions = 0\n let notifyFn: NotifyFunction = (callback) => {\n callback()\n }\n let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {\n callback()\n }\n let scheduleFn = defaultScheduler\n\n const schedule = (callback: NotifyCallback): void => {\n if (transactions) {\n queue.push(callback)\n } else {\n scheduleFn(() => {\n notifyFn(callback)\n })\n }\n }\n const flush = (): void => {\n const originalQueue = queue\n queue = []\n if (originalQueue.length) {\n scheduleFn(() => {\n batchNotifyFn(() => {\n originalQueue.forEach((callback) => {\n notifyFn(callback)\n })\n })\n })\n }\n }\n\n return {\n /**\n * Batches all updates scheduled inside the passed callback.\n * This is mainly used internally to optimize query client updating.\n * Batches can be nested; the queue is only flushed once the outermost `batch` call finishes.\n * The return value of `callback` is passed through.\n * @param callback - The function to run in the batch.\n * @returns The return value of `callback`.\n */\n batch: <T>(callback: () => T): T => {\n let result\n transactions++\n try {\n result = callback()\n } finally {\n transactions--\n if (!transactions) {\n flush()\n }\n }\n return result\n },\n /**\n * All calls to the wrapped function will be batched.\n * @param callback - The function to wrap.\n * @returns A function that schedules a call to `callback` with the given arguments.\n */\n batchCalls: <T extends Array<unknown>>(\n callback: BatchCallsCallback<T>,\n ): BatchCallsCallback<T> => {\n return (...args) => {\n schedule(() => {\n callback(...args)\n })\n }\n },\n /**\n * Schedules a function to be run on the next batch.\n * By default, the batch is run with a `setTimeout`, but this can be configured via `setScheduler`.\n */\n schedule,\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n * @param fn - Receives each notification callback and must call it.\n */\n setNotifyFunction: (fn: NotifyFunction) => {\n notifyFn = fn\n },\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * Framework adapters use this to plug in their own batching primitive, so that a single query\n * update only triggers one re-render instead of one per subscriber.\n * @param fn - Receives a function that runs a batch of notifications and must call it.\n * @example\n * ```ts\n * import { notifyManager } from '@tanstack/query-core'\n * import { batch } from 'solid-js'\n *\n * notifyManager.setBatchNotifyFunction(batch)\n * ```\n */\n setBatchNotifyFunction: (fn: BatchNotifyFunction) => {\n batchNotifyFn = fn\n },\n /**\n * Configures a custom callback that schedules when the next batch runs.\n * The default behavior is `setTimeout(callback, 0)`.\n * @param fn - Receives a callback that runs the next batch, and schedules it.\n * @example\n * ```ts\n * import { notifyManager } from '@tanstack/query-core'\n *\n * // Schedule batches in the next microtask\n * notifyManager.setScheduler(queueMicrotask)\n *\n * // Schedule batches before the next frame is rendered\n * notifyManager.setScheduler(requestAnimationFrame)\n *\n * // Schedule batches some time in the future\n * notifyManager.setScheduler((cb) => setTimeout(cb, 10))\n * ```\n */\n setScheduler: (fn: ScheduleFunction) => {\n scheduleFn = fn\n },\n } as const\n}\n\n// SINGLETON\n\n/**\n * Handles scheduling and batching callbacks in TanStack Query.\n */\nexport const notifyManager = createNotifyManager()\n"],"mappings":";;;;;;AAkBA,MAAa,mBAAqC;;;;;;AAOlD,SAAgB,sBAAsB;CACpC,IAAI,QAA+B,CAAC;CACpC,IAAI,eAAe;CACnB,IAAI,YAA4B,aAAa;EAC3C,SAAS;CACX;CACA,IAAI,iBAAsC,aAAyB;EACjE,SAAS;CACX;CACA,IAAI,aAAa;CAEjB,MAAM,YAAY,aAAmC;EACnD,IAAI,cACF,MAAM,KAAK,QAAQ;OAEnB,iBAAiB;GACf,SAAS,QAAQ;EACnB,CAAC;CAEL;CACA,MAAM,cAAoB;EACxB,MAAM,gBAAgB;EACtB,QAAQ,CAAC;EACT,IAAI,cAAc,QAChB,iBAAiB;GACf,oBAAoB;IAClB,cAAc,SAAS,aAAa;KAClC,SAAS,QAAQ;IACnB,CAAC;GACH,CAAC;EACH,CAAC;CAEL;CAEA,OAAO;;;;;;;;;EASL,QAAW,aAAyB;GAClC,IAAI;GACJ;GACA,IAAI;IACF,SAAS,SAAS;GACpB,UAAU;IACR;IACA,IAAI,CAAC,cACH,MAAM;GAEV;GACA,OAAO;EACT;;;;;;EAMA,aACE,aAC0B;GAC1B,QAAQ,GAAG,SAAS;IAClB,eAAe;KACb,SAAS,GAAG,IAAI;IAClB,CAAC;GACH;EACF;;;;;EAKA;;;;;;EAMA,oBAAoB,OAAuB;GACzC,WAAW;EACb;;;;;;;;;;;;;;EAcA,yBAAyB,OAA4B;GACnD,gBAAgB;EAClB;;;;;;;;;;;;;;;;;;;EAmBA,eAAe,OAAyB;GACtC,aAAa;EACf;CACF;AACF;;;;AAOA,MAAa,gBAAgB,oBAAoB"}
@@ -43,7 +43,8 @@ var OnlineManager = class extends require_subscribable.Subscribable {
43
43
  * be used to determine the online state. The provided `setup` function
44
44
  * receives a `setOnline` callback that should be called with a `boolean`
45
45
  * whenever the online state changes.
46
- *
46
+ * @param setup - Receives the `setOnline` callback, registers the event listener, and may return
47
+ * a cleanup function that is called when the listener is replaced or no longer needed.
47
48
  * @example
48
49
  * ```ts
49
50
  * import NetInfo from '@react-native-community/netinfo'
@@ -63,7 +64,7 @@ var OnlineManager = class extends require_subscribable.Subscribable {
63
64
  }
64
65
  /**
65
66
  * `setOnline` can be used to manually set the online state.
66
- *
67
+ * @param online - The online state.
67
68
  * @example
68
69
  * ```ts
69
70
  * import { onlineManager } from '@tanstack/query-core'
@@ -85,6 +86,7 @@ var OnlineManager = class extends require_subscribable.Subscribable {
85
86
  }
86
87
  /**
87
88
  * `isOnline` can be used to get the current online state.
89
+ * @returns `true` if online.
88
90
  */
89
91
  isOnline() {
90
92
  return this.#online;
@@ -1 +1 @@
1
- {"version":3,"file":"onlineManager.cjs","names":["Subscribable"],"sources":["../../src/onlineManager.ts"],"sourcesContent":["import { Subscribable } from './subscribable'\n\ntype Listener = (online: boolean) => void\ntype SetupFn = (setOnline: Listener) => (() => void) | undefined\n\n/**\n * The `OnlineManager` manages the online state within TanStack Query. It can\n * be used to change the default event listeners or to manually change the\n * online state.\n *\n * By default, the `onlineManager` assumes an active network connection, and\n * listens to the `online` and `offline` events on the `window` object to\n * detect changes.\n */\nexport class OnlineManager extends Subscribable<Listener> {\n #online = true\n #cleanup?: () => void\n\n #setup: SetupFn\n\n constructor() {\n super()\n this.#setup = (onOnline) => {\n // addEventListener does not exist in React Native, but window does\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (typeof window !== 'undefined' && window.addEventListener) {\n const onlineListener = () => onOnline(true)\n const offlineListener = () => onOnline(false)\n // Listen to online\n window.addEventListener('online', onlineListener, false)\n window.addEventListener('offline', offlineListener, false)\n\n return () => {\n // Be sure to unsubscribe if a new handler is set\n window.removeEventListener('online', onlineListener)\n window.removeEventListener('offline', offlineListener)\n }\n }\n\n return\n }\n }\n\n protected onSubscribe(): void {\n if (!this.#cleanup) {\n this.setEventListener(this.#setup)\n }\n }\n\n protected onUnsubscribe() {\n if (!this.hasListeners()) {\n this.#cleanup?.()\n this.#cleanup = undefined\n }\n }\n\n /**\n * `setEventListener` can be used to set a custom event listener that will\n * be used to determine the online state. The provided `setup` function\n * receives a `setOnline` callback that should be called with a `boolean`\n * whenever the online state changes.\n *\n * @example\n * ```ts\n * import NetInfo from '@react-native-community/netinfo'\n * import { onlineManager } from '@tanstack/query-core'\n *\n * onlineManager.setEventListener((setOnline) => {\n * return NetInfo.addEventListener((state) => {\n * setOnline(!!state.isConnected)\n * })\n * })\n * ```\n */\n setEventListener(setup: SetupFn): void {\n this.#setup = setup\n this.#cleanup?.()\n this.#cleanup = setup(this.setOnline.bind(this))\n }\n\n /**\n * `setOnline` can be used to manually set the online state.\n *\n * @example\n * ```ts\n * import { onlineManager } from '@tanstack/query-core'\n *\n * // Set to online\n * onlineManager.setOnline(true)\n *\n * // Set to offline\n * onlineManager.setOnline(false)\n * ```\n */\n setOnline(online: boolean): void {\n const changed = this.#online !== online\n\n if (changed) {\n this.#online = online\n this.listeners.forEach((listener) => {\n listener(online)\n })\n }\n }\n\n /**\n * `isOnline` can be used to get the current online state.\n */\n isOnline(): boolean {\n return this.#online\n }\n}\n\n/**\n * Singleton instance of {@link OnlineManager}, used to manage and observe the online state within TanStack Query.\n */\nexport const onlineManager = new OnlineManager()\n"],"mappings":";;;;;;;;;;;;AAcA,IAAa,gBAAb,cAAmCA,qBAAAA,aAAuB;CACxD,UAAU;CACV;CAEA;CAEA,cAAc;EACZ,MAAM;EACN,KAAK,UAAU,aAAa;GAG1B,IAAI,OAAO,WAAW,eAAe,OAAO,kBAAkB;IAC5D,MAAM,uBAAuB,SAAS,IAAI;IAC1C,MAAM,wBAAwB,SAAS,KAAK;IAE5C,OAAO,iBAAiB,UAAU,gBAAgB,KAAK;IACvD,OAAO,iBAAiB,WAAW,iBAAiB,KAAK;IAEzD,aAAa;KAEX,OAAO,oBAAoB,UAAU,cAAc;KACnD,OAAO,oBAAoB,WAAW,eAAe;IACvD;GACF;EAGF;CACF;CAEA,cAA8B;EAC5B,IAAI,CAAC,KAAK,UACR,KAAK,iBAAiB,KAAK,MAAM;CAErC;CAEA,gBAA0B;EACxB,IAAI,CAAC,KAAK,aAAa,GAAG;GACxB,KAAK,WAAW;GAChB,KAAK,WAAW,KAAA;EAClB;CACF;;;;;;;;;;;;;;;;;;;CAoBA,iBAAiB,OAAsB;EACrC,KAAK,SAAS;EACd,KAAK,WAAW;EAChB,KAAK,WAAW,MAAM,KAAK,UAAU,KAAK,IAAI,CAAC;CACjD;;;;;;;;;;;;;;;CAgBA,UAAU,QAAuB;EAG/B,IAFgB,KAAK,YAAY,QAEpB;GACX,KAAK,UAAU;GACf,KAAK,UAAU,SAAS,aAAa;IACnC,SAAS,MAAM;GACjB,CAAC;EACH;CACF;;;;CAKA,WAAoB;EAClB,OAAO,KAAK;CACd;AACF;;;;AAKA,MAAa,gBAAgB,IAAI,cAAc"}
1
+ {"version":3,"file":"onlineManager.cjs","names":["Subscribable"],"sources":["../../src/onlineManager.ts"],"sourcesContent":["import { Subscribable } from './subscribable'\n\ntype Listener = (online: boolean) => void\ntype SetupFn = (setOnline: Listener) => (() => void) | undefined\n\n/**\n * The `OnlineManager` manages the online state within TanStack Query. It can\n * be used to change the default event listeners or to manually change the\n * online state.\n *\n * By default, the `onlineManager` assumes an active network connection, and\n * listens to the `online` and `offline` events on the `window` object to\n * detect changes.\n */\nexport class OnlineManager extends Subscribable<Listener> {\n #online = true\n #cleanup?: () => void\n\n #setup: SetupFn\n\n constructor() {\n super()\n this.#setup = (onOnline) => {\n // addEventListener does not exist in React Native, but window does\n // oxlint-disable-next-line typescript/no-unnecessary-condition\n if (typeof window !== 'undefined' && window.addEventListener) {\n const onlineListener = () => onOnline(true)\n const offlineListener = () => onOnline(false)\n // Listen to online\n window.addEventListener('online', onlineListener, false)\n window.addEventListener('offline', offlineListener, false)\n\n return () => {\n // Be sure to unsubscribe if a new handler is set\n window.removeEventListener('online', onlineListener)\n window.removeEventListener('offline', offlineListener)\n }\n }\n\n return\n }\n }\n\n protected override onSubscribe(): void {\n if (!this.#cleanup) {\n this.setEventListener(this.#setup)\n }\n }\n\n protected override onUnsubscribe() {\n if (!this.hasListeners()) {\n this.#cleanup?.()\n this.#cleanup = undefined\n }\n }\n\n /**\n * `setEventListener` can be used to set a custom event listener that will\n * be used to determine the online state. The provided `setup` function\n * receives a `setOnline` callback that should be called with a `boolean`\n * whenever the online state changes.\n * @param setup - Receives the `setOnline` callback, registers the event listener, and may return\n * a cleanup function that is called when the listener is replaced or no longer needed.\n * @example\n * ```ts\n * import NetInfo from '@react-native-community/netinfo'\n * import { onlineManager } from '@tanstack/query-core'\n *\n * onlineManager.setEventListener((setOnline) => {\n * return NetInfo.addEventListener((state) => {\n * setOnline(!!state.isConnected)\n * })\n * })\n * ```\n */\n setEventListener(setup: SetupFn): void {\n this.#setup = setup\n this.#cleanup?.()\n this.#cleanup = setup(this.setOnline.bind(this))\n }\n\n /**\n * `setOnline` can be used to manually set the online state.\n * @param online - The online state.\n * @example\n * ```ts\n * import { onlineManager } from '@tanstack/query-core'\n *\n * // Set to online\n * onlineManager.setOnline(true)\n *\n * // Set to offline\n * onlineManager.setOnline(false)\n * ```\n */\n setOnline(online: boolean): void {\n const changed = this.#online !== online\n\n if (changed) {\n this.#online = online\n this.listeners.forEach((listener) => {\n listener(online)\n })\n }\n }\n\n /**\n * `isOnline` can be used to get the current online state.\n * @returns `true` if online.\n */\n isOnline(): boolean {\n return this.#online\n }\n}\n\n/**\n * Singleton instance of {@link OnlineManager}, used to manage and observe the online state within TanStack Query.\n */\nexport const onlineManager = new OnlineManager()\n"],"mappings":";;;;;;;;;;;;AAcA,IAAa,gBAAb,cAAmCA,qBAAAA,aAAuB;CACxD,UAAU;CACV;CAEA;CAEA,cAAc;EACZ,MAAM;EACN,KAAK,UAAU,aAAa;GAG1B,IAAI,OAAO,WAAW,eAAe,OAAO,kBAAkB;IAC5D,MAAM,uBAAuB,SAAS,IAAI;IAC1C,MAAM,wBAAwB,SAAS,KAAK;IAE5C,OAAO,iBAAiB,UAAU,gBAAgB,KAAK;IACvD,OAAO,iBAAiB,WAAW,iBAAiB,KAAK;IAEzD,aAAa;KAEX,OAAO,oBAAoB,UAAU,cAAc;KACnD,OAAO,oBAAoB,WAAW,eAAe;IACvD;GACF;EAGF;CACF;CAEA,cAAuC;EACrC,IAAI,CAAC,KAAK,UACR,KAAK,iBAAiB,KAAK,MAAM;CAErC;CAEA,gBAAmC;EACjC,IAAI,CAAC,KAAK,aAAa,GAAG;GACxB,KAAK,WAAW;GAChB,KAAK,WAAW,KAAA;EAClB;CACF;;;;;;;;;;;;;;;;;;;;CAqBA,iBAAiB,OAAsB;EACrC,KAAK,SAAS;EACd,KAAK,WAAW;EAChB,KAAK,WAAW,MAAM,KAAK,UAAU,KAAK,IAAI,CAAC;CACjD;;;;;;;;;;;;;;;CAgBA,UAAU,QAAuB;EAG/B,IAFgB,KAAK,YAAY,QAEpB;GACX,KAAK,UAAU;GACf,KAAK,UAAU,SAAS,aAAa;IACnC,SAAS,MAAM;GACjB,CAAC;EACH;CACF;;;;;CAMA,WAAoB;EAClB,OAAO,KAAK;CACd;AACF;;;;AAKA,MAAa,gBAAgB,IAAI,cAAc"}
@@ -1,4 +1,4 @@
1
- import { t as Subscribable } from "./subscribable-CysQ0tne.cjs";
1
+ import { t as Subscribable } from "./subscribable-czlHOxMP.cjs";
2
2
  //#region src/onlineManager.d.ts
3
3
  type Listener = (online: boolean) => void;
4
4
  type SetupFn = (setOnline: Listener) => (() => void) | undefined;
@@ -21,7 +21,8 @@ export declare class OnlineManager extends Subscribable<Listener> {
21
21
  * be used to determine the online state. The provided `setup` function
22
22
  * receives a `setOnline` callback that should be called with a `boolean`
23
23
  * whenever the online state changes.
24
- *
24
+ * @param setup - Receives the `setOnline` callback, registers the event listener, and may return
25
+ * a cleanup function that is called when the listener is replaced or no longer needed.
25
26
  * @example
26
27
  * ```ts
27
28
  * import NetInfo from '@react-native-community/netinfo'
@@ -37,7 +38,7 @@ export declare class OnlineManager extends Subscribable<Listener> {
37
38
  setEventListener(setup: SetupFn): void;
38
39
  /**
39
40
  * `setOnline` can be used to manually set the online state.
40
- *
41
+ * @param online - The online state.
41
42
  * @example
42
43
  * ```ts
43
44
  * import { onlineManager } from '@tanstack/query-core'
@@ -52,6 +53,7 @@ export declare class OnlineManager extends Subscribable<Listener> {
52
53
  setOnline(online: boolean): void;
53
54
  /**
54
55
  * `isOnline` can be used to get the current online state.
56
+ * @returns `true` if online.
55
57
  */
56
58
  isOnline(): boolean;
57
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"onlineManager.d.cts","names":[],"sources":["../../src/onlineManager.ts"],"mappings":";;KAEK,YAAY;KACZ,WAAW,WAAW;;;;;;;;;;qBAWd,sBAAsB,aAAa;;;YA6BpC;YAMA;;;;;;;;;;;;;;;;;;;EAyBV,iBAAiB,OAAO;;;;;;;;;;;;;;;EAoBxB,UAAU;;;;EAcV;;;;;qBAQW,eAAa"}
1
+ {"version":3,"file":"onlineManager.d.cts","names":[],"sources":["../../src/onlineManager.ts"],"mappings":";;KAEK,YAAY;KACZ,WAAW,WAAW;;;;;;;;;;qBAWd,sBAAsB,aAAa;;;YA6B3B;YAMA;;;;;;;;;;;;;;;;;;;;EA0BnB,iBAAiB,OAAO;;;;;;;;;;;;;;;EAoBxB,UAAU;;;;;EAeV;;;;;qBAQW,eAAa"}
@@ -1,4 +1,4 @@
1
- import { t as Subscribable } from "./subscribable-CysQ0tne.js";
1
+ import { t as Subscribable } from "./subscribable-czlHOxMP.js";
2
2
  //#region src/onlineManager.d.ts
3
3
  type Listener = (online: boolean) => void;
4
4
  type SetupFn = (setOnline: Listener) => (() => void) | undefined;
@@ -21,7 +21,8 @@ export declare class OnlineManager extends Subscribable<Listener> {
21
21
  * be used to determine the online state. The provided `setup` function
22
22
  * receives a `setOnline` callback that should be called with a `boolean`
23
23
  * whenever the online state changes.
24
- *
24
+ * @param setup - Receives the `setOnline` callback, registers the event listener, and may return
25
+ * a cleanup function that is called when the listener is replaced or no longer needed.
25
26
  * @example
26
27
  * ```ts
27
28
  * import NetInfo from '@react-native-community/netinfo'
@@ -37,7 +38,7 @@ export declare class OnlineManager extends Subscribable<Listener> {
37
38
  setEventListener(setup: SetupFn): void;
38
39
  /**
39
40
  * `setOnline` can be used to manually set the online state.
40
- *
41
+ * @param online - The online state.
41
42
  * @example
42
43
  * ```ts
43
44
  * import { onlineManager } from '@tanstack/query-core'
@@ -52,6 +53,7 @@ export declare class OnlineManager extends Subscribable<Listener> {
52
53
  setOnline(online: boolean): void;
53
54
  /**
54
55
  * `isOnline` can be used to get the current online state.
56
+ * @returns `true` if online.
55
57
  */
56
58
  isOnline(): boolean;
57
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"onlineManager.d.ts","names":[],"sources":["../../src/onlineManager.ts"],"mappings":";;KAEK,YAAY;KACZ,WAAW,WAAW;;;;;;;;;;qBAWd,sBAAsB,aAAa;;;YA6BpC;YAMA;;;;;;;;;;;;;;;;;;;EAyBV,iBAAiB,OAAO;;;;;;;;;;;;;;;EAoBxB,UAAU;;;;EAcV;;;;;qBAQW,eAAa"}
1
+ {"version":3,"file":"onlineManager.d.ts","names":[],"sources":["../../src/onlineManager.ts"],"mappings":";;KAEK,YAAY;KACZ,WAAW,WAAW;;;;;;;;;;qBAWd,sBAAsB,aAAa;;;YA6B3B;YAMA;;;;;;;;;;;;;;;;;;;;EA0BnB,iBAAiB,OAAO;;;;;;;;;;;;;;;EAoBxB,UAAU;;;;;EAeV;;;;;qBAQW,eAAa"}
@@ -42,7 +42,8 @@ var OnlineManager = class extends Subscribable {
42
42
  * be used to determine the online state. The provided `setup` function
43
43
  * receives a `setOnline` callback that should be called with a `boolean`
44
44
  * whenever the online state changes.
45
- *
45
+ * @param setup - Receives the `setOnline` callback, registers the event listener, and may return
46
+ * a cleanup function that is called when the listener is replaced or no longer needed.
46
47
  * @example
47
48
  * ```ts
48
49
  * import NetInfo from '@react-native-community/netinfo'
@@ -62,7 +63,7 @@ var OnlineManager = class extends Subscribable {
62
63
  }
63
64
  /**
64
65
  * `setOnline` can be used to manually set the online state.
65
- *
66
+ * @param online - The online state.
66
67
  * @example
67
68
  * ```ts
68
69
  * import { onlineManager } from '@tanstack/query-core'
@@ -84,6 +85,7 @@ var OnlineManager = class extends Subscribable {
84
85
  }
85
86
  /**
86
87
  * `isOnline` can be used to get the current online state.
88
+ * @returns `true` if online.
87
89
  */
88
90
  isOnline() {
89
91
  return this.#online;
@@ -1 +1 @@
1
- {"version":3,"file":"onlineManager.js","names":[],"sources":["../../src/onlineManager.ts"],"sourcesContent":["import { Subscribable } from './subscribable'\n\ntype Listener = (online: boolean) => void\ntype SetupFn = (setOnline: Listener) => (() => void) | undefined\n\n/**\n * The `OnlineManager` manages the online state within TanStack Query. It can\n * be used to change the default event listeners or to manually change the\n * online state.\n *\n * By default, the `onlineManager` assumes an active network connection, and\n * listens to the `online` and `offline` events on the `window` object to\n * detect changes.\n */\nexport class OnlineManager extends Subscribable<Listener> {\n #online = true\n #cleanup?: () => void\n\n #setup: SetupFn\n\n constructor() {\n super()\n this.#setup = (onOnline) => {\n // addEventListener does not exist in React Native, but window does\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (typeof window !== 'undefined' && window.addEventListener) {\n const onlineListener = () => onOnline(true)\n const offlineListener = () => onOnline(false)\n // Listen to online\n window.addEventListener('online', onlineListener, false)\n window.addEventListener('offline', offlineListener, false)\n\n return () => {\n // Be sure to unsubscribe if a new handler is set\n window.removeEventListener('online', onlineListener)\n window.removeEventListener('offline', offlineListener)\n }\n }\n\n return\n }\n }\n\n protected onSubscribe(): void {\n if (!this.#cleanup) {\n this.setEventListener(this.#setup)\n }\n }\n\n protected onUnsubscribe() {\n if (!this.hasListeners()) {\n this.#cleanup?.()\n this.#cleanup = undefined\n }\n }\n\n /**\n * `setEventListener` can be used to set a custom event listener that will\n * be used to determine the online state. The provided `setup` function\n * receives a `setOnline` callback that should be called with a `boolean`\n * whenever the online state changes.\n *\n * @example\n * ```ts\n * import NetInfo from '@react-native-community/netinfo'\n * import { onlineManager } from '@tanstack/query-core'\n *\n * onlineManager.setEventListener((setOnline) => {\n * return NetInfo.addEventListener((state) => {\n * setOnline(!!state.isConnected)\n * })\n * })\n * ```\n */\n setEventListener(setup: SetupFn): void {\n this.#setup = setup\n this.#cleanup?.()\n this.#cleanup = setup(this.setOnline.bind(this))\n }\n\n /**\n * `setOnline` can be used to manually set the online state.\n *\n * @example\n * ```ts\n * import { onlineManager } from '@tanstack/query-core'\n *\n * // Set to online\n * onlineManager.setOnline(true)\n *\n * // Set to offline\n * onlineManager.setOnline(false)\n * ```\n */\n setOnline(online: boolean): void {\n const changed = this.#online !== online\n\n if (changed) {\n this.#online = online\n this.listeners.forEach((listener) => {\n listener(online)\n })\n }\n }\n\n /**\n * `isOnline` can be used to get the current online state.\n */\n isOnline(): boolean {\n return this.#online\n }\n}\n\n/**\n * Singleton instance of {@link OnlineManager}, used to manage and observe the online state within TanStack Query.\n */\nexport const onlineManager = new OnlineManager()\n"],"mappings":";;;;;;;;;;;AAcA,IAAa,gBAAb,cAAmC,aAAuB;CACxD,UAAU;CACV;CAEA;CAEA,cAAc;EACZ,MAAM;EACN,KAAK,UAAU,aAAa;GAG1B,IAAI,OAAO,WAAW,eAAe,OAAO,kBAAkB;IAC5D,MAAM,uBAAuB,SAAS,IAAI;IAC1C,MAAM,wBAAwB,SAAS,KAAK;IAE5C,OAAO,iBAAiB,UAAU,gBAAgB,KAAK;IACvD,OAAO,iBAAiB,WAAW,iBAAiB,KAAK;IAEzD,aAAa;KAEX,OAAO,oBAAoB,UAAU,cAAc;KACnD,OAAO,oBAAoB,WAAW,eAAe;IACvD;GACF;EAGF;CACF;CAEA,cAA8B;EAC5B,IAAI,CAAC,KAAK,UACR,KAAK,iBAAiB,KAAK,MAAM;CAErC;CAEA,gBAA0B;EACxB,IAAI,CAAC,KAAK,aAAa,GAAG;GACxB,KAAK,WAAW;GAChB,KAAK,WAAW,KAAA;EAClB;CACF;;;;;;;;;;;;;;;;;;;CAoBA,iBAAiB,OAAsB;EACrC,KAAK,SAAS;EACd,KAAK,WAAW;EAChB,KAAK,WAAW,MAAM,KAAK,UAAU,KAAK,IAAI,CAAC;CACjD;;;;;;;;;;;;;;;CAgBA,UAAU,QAAuB;EAG/B,IAFgB,KAAK,YAAY,QAEpB;GACX,KAAK,UAAU;GACf,KAAK,UAAU,SAAS,aAAa;IACnC,SAAS,MAAM;GACjB,CAAC;EACH;CACF;;;;CAKA,WAAoB;EAClB,OAAO,KAAK;CACd;AACF;;;;AAKA,MAAa,gBAAgB,IAAI,cAAc"}
1
+ {"version":3,"file":"onlineManager.js","names":[],"sources":["../../src/onlineManager.ts"],"sourcesContent":["import { Subscribable } from './subscribable'\n\ntype Listener = (online: boolean) => void\ntype SetupFn = (setOnline: Listener) => (() => void) | undefined\n\n/**\n * The `OnlineManager` manages the online state within TanStack Query. It can\n * be used to change the default event listeners or to manually change the\n * online state.\n *\n * By default, the `onlineManager` assumes an active network connection, and\n * listens to the `online` and `offline` events on the `window` object to\n * detect changes.\n */\nexport class OnlineManager extends Subscribable<Listener> {\n #online = true\n #cleanup?: () => void\n\n #setup: SetupFn\n\n constructor() {\n super()\n this.#setup = (onOnline) => {\n // addEventListener does not exist in React Native, but window does\n // oxlint-disable-next-line typescript/no-unnecessary-condition\n if (typeof window !== 'undefined' && window.addEventListener) {\n const onlineListener = () => onOnline(true)\n const offlineListener = () => onOnline(false)\n // Listen to online\n window.addEventListener('online', onlineListener, false)\n window.addEventListener('offline', offlineListener, false)\n\n return () => {\n // Be sure to unsubscribe if a new handler is set\n window.removeEventListener('online', onlineListener)\n window.removeEventListener('offline', offlineListener)\n }\n }\n\n return\n }\n }\n\n protected override onSubscribe(): void {\n if (!this.#cleanup) {\n this.setEventListener(this.#setup)\n }\n }\n\n protected override onUnsubscribe() {\n if (!this.hasListeners()) {\n this.#cleanup?.()\n this.#cleanup = undefined\n }\n }\n\n /**\n * `setEventListener` can be used to set a custom event listener that will\n * be used to determine the online state. The provided `setup` function\n * receives a `setOnline` callback that should be called with a `boolean`\n * whenever the online state changes.\n * @param setup - Receives the `setOnline` callback, registers the event listener, and may return\n * a cleanup function that is called when the listener is replaced or no longer needed.\n * @example\n * ```ts\n * import NetInfo from '@react-native-community/netinfo'\n * import { onlineManager } from '@tanstack/query-core'\n *\n * onlineManager.setEventListener((setOnline) => {\n * return NetInfo.addEventListener((state) => {\n * setOnline(!!state.isConnected)\n * })\n * })\n * ```\n */\n setEventListener(setup: SetupFn): void {\n this.#setup = setup\n this.#cleanup?.()\n this.#cleanup = setup(this.setOnline.bind(this))\n }\n\n /**\n * `setOnline` can be used to manually set the online state.\n * @param online - The online state.\n * @example\n * ```ts\n * import { onlineManager } from '@tanstack/query-core'\n *\n * // Set to online\n * onlineManager.setOnline(true)\n *\n * // Set to offline\n * onlineManager.setOnline(false)\n * ```\n */\n setOnline(online: boolean): void {\n const changed = this.#online !== online\n\n if (changed) {\n this.#online = online\n this.listeners.forEach((listener) => {\n listener(online)\n })\n }\n }\n\n /**\n * `isOnline` can be used to get the current online state.\n * @returns `true` if online.\n */\n isOnline(): boolean {\n return this.#online\n }\n}\n\n/**\n * Singleton instance of {@link OnlineManager}, used to manage and observe the online state within TanStack Query.\n */\nexport const onlineManager = new OnlineManager()\n"],"mappings":";;;;;;;;;;;AAcA,IAAa,gBAAb,cAAmC,aAAuB;CACxD,UAAU;CACV;CAEA;CAEA,cAAc;EACZ,MAAM;EACN,KAAK,UAAU,aAAa;GAG1B,IAAI,OAAO,WAAW,eAAe,OAAO,kBAAkB;IAC5D,MAAM,uBAAuB,SAAS,IAAI;IAC1C,MAAM,wBAAwB,SAAS,KAAK;IAE5C,OAAO,iBAAiB,UAAU,gBAAgB,KAAK;IACvD,OAAO,iBAAiB,WAAW,iBAAiB,KAAK;IAEzD,aAAa;KAEX,OAAO,oBAAoB,UAAU,cAAc;KACnD,OAAO,oBAAoB,WAAW,eAAe;IACvD;GACF;EAGF;CACF;CAEA,cAAuC;EACrC,IAAI,CAAC,KAAK,UACR,KAAK,iBAAiB,KAAK,MAAM;CAErC;CAEA,gBAAmC;EACjC,IAAI,CAAC,KAAK,aAAa,GAAG;GACxB,KAAK,WAAW;GAChB,KAAK,WAAW,KAAA;EAClB;CACF;;;;;;;;;;;;;;;;;;;;CAqBA,iBAAiB,OAAsB;EACrC,KAAK,SAAS;EACd,KAAK,WAAW;EAChB,KAAK,WAAW,MAAM,KAAK,UAAU,KAAK,IAAI,CAAC;CACjD;;;;;;;;;;;;;;;CAgBA,UAAU,QAAuB;EAG/B,IAFgB,KAAK,YAAY,QAEpB;GACX,KAAK,UAAU;GACf,KAAK,UAAU,SAAS,aAAa;IACnC,SAAS,MAAM;GACjB,CAAC;EACH;CACF;;;;;CAMA,WAAoB;EAClB,OAAO,KAAK;CACd;AACF;;;;AAKA,MAAa,gBAAgB,IAAI,cAAc"}
@@ -4,6 +4,12 @@ const require_subscribable = require("./subscribable.cjs");
4
4
  const require_notifyManager = require("./notifyManager.cjs");
5
5
  const require_queryObserver = require("./queryObserver.cjs");
6
6
  //#region src/queriesObserver.ts
7
+ /**
8
+ * Returns the items of `array1` that are not in `array2`.
9
+ * @param array1 - The items to filter.
10
+ * @param array2 - The items to exclude.
11
+ * @returns A new array with the items of `array1` that are not in `array2`.
12
+ */
7
13
  function difference(array1, array2) {
8
14
  const excludeSet = new Set(array2);
9
15
  return array1.filter((x) => !excludeSet.has(x));
@@ -14,7 +20,6 @@ function difference(array1, array2) {
14
20
  * given, as a combined value derived from that array). It manages one
15
21
  * internal `QueryObserver` per query, and is the primitive that framework
16
22
  * adapters (e.g. `useQueries`) build their hooks on top of.
17
- *
18
23
  * @example
19
24
  * ```ts
20
25
  * const observer = new QueriesObserver(queryClient, [
@@ -72,7 +77,8 @@ var QueriesObserver = class extends require_subscribable.Subscribable {
72
77
  * are reused for queries that match an already-observed query hash;
73
78
  * observers for queries that are no longer present are destroyed, and new
74
79
  * observers are created and subscribed to for newly added queries.
75
- *
80
+ * @param queries - The options of the queries to observe.
81
+ * @param options - Replaces the observer's options, e.g. its `combine` function.
76
82
  * @example
77
83
  * ```ts
78
84
  * observer.setQueries([
@@ -125,7 +131,7 @@ var QueriesObserver = class extends require_subscribable.Subscribable {
125
131
  * Returns the most recently computed array of `QueryObserverResult`s, one
126
132
  * per observed query, in the same order as the queries passed to the
127
133
  * constructor or `setQueries`.
128
- *
134
+ * @returns The current results.
129
135
  * @example
130
136
  * ```ts
131
137
  * const results = observer.getCurrentResult()
@@ -138,6 +144,7 @@ var QueriesObserver = class extends require_subscribable.Subscribable {
138
144
  /**
139
145
  * Returns the underlying `Query` instances currently being observed, in
140
146
  * the same order as the queries passed to the constructor or `setQueries`.
147
+ * @returns The observed queries.
141
148
  */
142
149
  getQueries() {
143
150
  return this.#observers.map((observer) => observer.getCurrentQuery());
@@ -146,6 +153,7 @@ var QueriesObserver = class extends require_subscribable.Subscribable {
146
153
  * Returns the underlying `QueryObserver` instances this observer manages,
147
154
  * in the same order as the queries passed to the constructor or
148
155
  * `setQueries`.
156
+ * @returns The managed query observers.
149
157
  */
150
158
  getObservers() {
151
159
  return this.#observers;
@@ -156,6 +164,10 @@ var QueriesObserver = class extends require_subscribable.Subscribable {
156
164
  * framework adapters (e.g. `useQueries`) ahead of subscribing, returning a tuple of the raw
157
165
  * per-query results, a function to compute the combined result from them, and a function to
158
166
  * wrap the results for property-access tracking.
167
+ * @param queries - The defaulted options of the queries to compute the result for.
168
+ * @param combine - The `combine` function used by the returned `combineResult`, if any.
169
+ * @returns A tuple of the per-query results, a function that computes the combined result, and a
170
+ * function that returns the results wrapped for property-access tracking.
159
171
  */
160
172
  getOptimisticResult(queries, combine) {
161
173
  const matches = this.#findMatchingObservers(queries);