@tanstack/query-core 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 (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 +4 -4
  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":"queryObserver.cjs","names":["Subscribable","resolveQueryValue","shallowEqualObjects","fetchState","replaceData","noop","isServerEnvironment","isValidTimeout","timeUntilStale","timeoutManager","focusManager"],"sources":["../../src/queryObserver.ts"],"sourcesContent":["import { focusManager } from './focusManager'\nimport { isServer as isServerEnvironment } from './environmentManager'\nimport { notifyManager } from './notifyManager'\nimport { fetchState } from './query'\nimport { Subscribable } from './subscribable'\nimport {\n isValidTimeout,\n noop,\n replaceData,\n resolveQueryValue,\n shallowEqualObjects,\n timeUntilStale,\n} from './utils'\nimport { timeoutManager } from './timeoutManager'\nimport type { ManagedTimerId } from './timeoutManager'\nimport type { FetchOptions, Query, QueryState } from './query'\nimport type { QueryClient } from './queryClient'\nimport type {\n DefaultError,\n DefaultedQueryObserverOptions,\n PlaceholderDataFunction,\n QueryKey,\n QueryObserverBaseResult,\n QueryObserverOptions,\n QueryObserverResult,\n RefetchOptions,\n} from './types'\n\ntype QueryObserverListener<TData, TError> = (\n result: QueryObserverResult<TData, TError>,\n) => void\n\ninterface ObserverFetchOptions extends FetchOptions {\n throwOnError?: boolean\n}\n\n/**\n * A `QueryObserver` watches a single query in the `QueryCache` and computes a\n * `QueryObserverResult` from its state, recomputing and notifying subscribers\n * whenever the underlying query (or the observer's options) changes. It is\n * the primitive that framework adapters (e.g. `useQuery`) build their hooks\n * on top of, but it can also be used directly to observe and switch between\n * queries outside of any framework.\n *\n * @example\n * ```ts\n * const observer = new QueryObserver(queryClient, {\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n *\n * const unsubscribe = observer.subscribe((result) => {\n * console.log(result.data)\n * })\n * ```\n */\nexport class QueryObserver<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> extends Subscribable<QueryObserverListener<TData, TError>> {\n #client: QueryClient\n #currentQuery: Query<TQueryFnData, TError, TQueryData, TQueryKey> = undefined!\n #currentQueryInitialState: QueryState<TQueryData, TError> = undefined!\n #currentResult: QueryObserverResult<TData, TError> = undefined!\n #currentResultState?: QueryState<TQueryData, TError>\n #currentResultOptions?: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >\n #selectError: TError | null\n #selectFn?: (data: TQueryData) => TData\n #selectResult?: TData\n // This property keeps track of the last query with defined data.\n // It will be used to pass the previous data and query to the placeholder function between renders.\n #lastQueryWithDefinedData?: Query<TQueryFnData, TError, TQueryData, TQueryKey>\n #staleTimeoutId?: ManagedTimerId\n #refetchIntervalId?: ManagedTimerId\n #currentRefetchInterval?: number | false\n #trackedProps = new Set<keyof QueryObserverResult>()\n\n constructor(\n client: QueryClient,\n public options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ) {\n super()\n\n this.#client = client\n this.#selectError = null\n\n this.bindMethods()\n this.setOptions(options)\n }\n\n protected bindMethods(): void {\n this.refetch = this.refetch.bind(this)\n }\n\n protected onSubscribe(): void {\n if (this.listeners.size === 1) {\n this.#currentQuery.addObserver(this)\n\n if (shouldFetchOnMount(this.#currentQuery, this.options)) {\n this.#executeFetch()\n } else {\n this.updateResult()\n }\n\n this.#updateTimers()\n }\n }\n\n protected onUnsubscribe(): void {\n if (!this.hasListeners()) {\n this.destroy()\n }\n }\n\n /**\n * Returns whether the observed query is currently stale and configured\n * (via the `refetchOnReconnect` option) to refetch when the network\n * reconnects.\n */\n shouldFetchOnReconnect(): boolean {\n return shouldFetchOn(\n this.#currentQuery,\n this.options,\n this.options.refetchOnReconnect,\n )\n }\n\n /**\n * Returns whether the observed query is currently stale and configured\n * (via the `refetchOnWindowFocus` option) to refetch when the window\n * regains focus.\n */\n shouldFetchOnWindowFocus(): boolean {\n return shouldFetchOn(\n this.#currentQuery,\n this.options,\n this.options.refetchOnWindowFocus,\n )\n }\n\n /**\n * Stops observing the current query: clears all listeners, cancels the\n * stale and refetch-interval timers, and removes this observer from the\n * query it was observing.\n */\n destroy(): void {\n this.listeners = new Set()\n this.#clearStaleTimeout()\n this.#clearRefetchInterval()\n this.#currentQuery.removeObserver(this)\n }\n\n /**\n * Updates the observer's options. This will re-resolve the query being\n * observed (switching to a different query if the `queryKey` changed),\n * trigger a fetch if the new options require one and the observer has\n * subscribers, recompute the current result, and reschedule the stale and\n * refetch-interval timers as needed.\n *\n * @example\n * ```ts\n * observer.setOptions({ queryKey: ['posts', 1], queryFn: () => fetchPost(1) })\n * // later: switch to a different query, reusing the same observer\n * observer.setOptions({ queryKey: ['posts', 2], queryFn: () => fetchPost(2) })\n * ```\n */\n setOptions(\n options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): void {\n const prevOptions = this.options\n const prevQuery = this.#currentQuery\n\n this.options = this.#client.defaultQueryOptions(options)\n\n if (\n this.options.enabled !== undefined &&\n typeof this.options.enabled !== 'boolean' &&\n typeof this.options.enabled !== 'function' &&\n typeof resolveQueryValue(this.options.enabled, this.#currentQuery) !==\n 'boolean'\n ) {\n throw new Error(\n 'Expected enabled to be a boolean or a callback that returns a boolean',\n )\n }\n\n this.#updateQuery()\n this.#currentQuery.setOptions(this.options)\n\n if (\n prevOptions._defaulted &&\n !shallowEqualObjects(this.options, prevOptions)\n ) {\n this.#client.getQueryCache().notify({\n type: 'observerOptionsUpdated',\n query: this.#currentQuery,\n observer: this,\n })\n }\n\n const mounted = this.hasListeners()\n\n // Fetch if there are subscribers\n if (\n mounted &&\n shouldFetchOptionally(\n this.#currentQuery,\n prevQuery,\n this.options,\n prevOptions,\n )\n ) {\n this.#executeFetch()\n }\n\n // Update result\n this.updateResult()\n\n // Update stale interval if needed\n if (\n mounted &&\n (this.#currentQuery !== prevQuery ||\n resolveQueryValue(this.options.enabled, this.#currentQuery) !==\n resolveQueryValue(prevOptions.enabled, this.#currentQuery) ||\n resolveQueryValue(this.options.staleTime, this.#currentQuery) !==\n resolveQueryValue(prevOptions.staleTime, this.#currentQuery))\n ) {\n this.#updateStaleTimeout()\n }\n\n const nextRefetchInterval = this.#computeRefetchInterval()\n\n // Update refetch interval if needed\n if (\n mounted &&\n (this.#currentQuery !== prevQuery ||\n resolveQueryValue(this.options.enabled, this.#currentQuery) !==\n resolveQueryValue(prevOptions.enabled, this.#currentQuery) ||\n nextRefetchInterval !== this.#currentRefetchInterval)\n ) {\n this.#updateRefetchInterval(nextRefetchInterval)\n }\n }\n\n /**\n * Computes the result the observer would produce for the given (already-defaulted) options\n * right now, building the underlying `Query` if it doesn't exist yet, without waiting for a\n * subscription callback. Called by framework adapters on every render (e.g. `useQuery`) so the\n * returned value is available synchronously, ahead of `setOptions` triggering an actual fetch.\n */\n getOptimisticResult(\n options: DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): QueryObserverResult<TData, TError> {\n const query = this.#client.getQueryCache().build(this.#client, options)\n\n const result = this.createResult(query, options)\n\n if (!shallowEqualObjects(this.getCurrentResult(), result)) {\n // this assigns the optimistic result to the current Observer\n // because if the query function changes, useQuery will be performing\n // an effect where it would fetch again.\n // When the fetch finishes, we perform a deep data cloning in order\n // to reuse objects references. This deep data clone is performed against\n // the `observer.currentResult.data` property\n // When QueryKey changes, we refresh the query and get new `optimistic`\n // result, while we leave the `observer.currentResult`, so when new data\n // arrives, it finds the old `observer.currentResult` which is related\n // to the old QueryKey. Which means that currentResult and selectData are\n // out of sync already.\n // To solve this, we move the cursor of the currentResult every time\n // an observer reads an optimistic value.\n\n // When keeping the previous data, the result doesn't change until new\n // data arrives.\n this.#currentResult = result\n this.#currentResultOptions = this.options\n this.#currentResultState = this.#currentQuery.state\n }\n return result\n }\n\n /**\n * Returns the most recently computed `QueryObserverResult` for the\n * observed query. This is a point-in-time read; to be notified of updates\n * as they happen, subscribe to the observer instead (its inherited\n * `subscribe` method).\n *\n * @example\n * ```ts\n * const result = observer.getCurrentResult()\n * console.log(result.status, result.data)\n * ```\n */\n getCurrentResult(): QueryObserverResult<TData, TError> {\n return this.#currentResult\n }\n\n /**\n * Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via\n * {@link QueryObserver#trackProp} (and an optional `onPropTracked` callback). Used by framework\n * adapters when `notifyOnChangeProps` is not set, to implement its default \"only re-render on\n * properties you actually read\" behavior.\n */\n trackResult(\n result: QueryObserverResult<TData, TError>,\n onPropTracked?: (key: keyof QueryObserverResult) => void,\n ): QueryObserverResult<TData, TError> {\n return new Proxy(result, {\n get: (target, key) => {\n this.trackProp(key as keyof QueryObserverResult)\n onPropTracked?.(key as keyof QueryObserverResult)\n return Reflect.get(target, key)\n },\n })\n }\n\n /**\n * Records that the given `QueryObserverResult` property was read, so a subsequent update only\n * notifies this observer if a tracked property actually changed. Normally called indirectly via\n * {@link QueryObserver#trackResult}'s proxy; exposed directly for adapters that track property\n * access themselves (e.g. through their own reactivity system) instead of via the proxy.\n */\n trackProp(key: keyof QueryObserverResult) {\n this.#trackedProps.add(key)\n }\n\n /**\n * Returns the `Query` instance this observer is currently observing.\n */\n getCurrentQuery(): Query<TQueryFnData, TError, TQueryData, TQueryKey> {\n return this.#currentQuery\n }\n\n /**\n * Refetches the observed query and returns a promise that resolves with\n * the resulting `QueryObserverResult`.\n *\n * @example\n * ```ts\n * const result = await observer.refetch({ cancelRefetch: false })\n * console.log(result.data)\n * ```\n */\n refetch({ ...options }: RefetchOptions = {}): Promise<\n QueryObserverResult<TData, TError>\n > {\n return this.fetch({\n ...options,\n })\n }\n\n /**\n * Fetches a query defined by the given options without affecting this\n * observer's own tracked query or result, and returns a promise that\n * resolves with the `QueryObserverResult` for that fetch. This is useful\n * for prefetching data that another observer (e.g. a query about to be\n * navigated to) will need, ahead of time.\n *\n * @example\n * ```ts\n * const result = await observer.fetchOptimistic({\n * queryKey: ['posts', 2],\n * queryFn: () => fetchPost(2),\n * })\n * console.log(result.data)\n * ```\n */\n fetchOptimistic(\n options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): Promise<QueryObserverResult<TData, TError>> {\n const defaultedOptions = this.#client.defaultQueryOptions(options)\n\n const query = this.#client\n .getQueryCache()\n .build(this.#client, defaultedOptions)\n\n let unsubscribe = () => {}\n let resolveEarly:\n ((result: QueryObserverResult<TData, TError>) => void) | undefined\n\n const cachePromise = new Promise<QueryObserverResult<TData, TError>>(\n (resolve) => {\n resolveEarly = resolve\n unsubscribe = this.#client.getQueryCache().subscribe((event) => {\n if (\n event.type === 'updated' &&\n event.query.queryHash === query.queryHash &&\n query.state.data !== undefined\n ) {\n unsubscribe()\n resolve(this.createResult(query, defaultedOptions))\n }\n })\n },\n )\n\n return Promise.race([\n query\n .fetch()\n .then(() => {\n const result = this.createResult(query, defaultedOptions)\n // Settle the subscriber promise so both branches always settle.\n // This value is ignored by Promise.race since the fetch branch already won.\n resolveEarly?.(result)\n return result\n })\n .finally(() => {\n unsubscribe()\n }),\n cachePromise,\n ])\n }\n\n protected fetch(\n fetchOptions: ObserverFetchOptions,\n ): Promise<QueryObserverResult<TData, TError>> {\n return this.#executeFetch({\n ...fetchOptions,\n cancelRefetch: fetchOptions.cancelRefetch ?? true,\n }).then(() => {\n this.updateResult()\n return this.#currentResult\n })\n }\n\n #executeFetch(\n fetchOptions?: Omit<ObserverFetchOptions, 'initialPromise'>,\n ): Promise<TQueryData | undefined> {\n // Make sure we reference the latest query as the current one might have been removed\n this.#updateQuery()\n\n // Fetch\n let promise: Promise<TQueryData | undefined> = this.#currentQuery.fetch(\n this.options,\n fetchOptions,\n )\n\n if (!fetchOptions?.throwOnError) {\n promise = promise.catch(noop)\n }\n\n return promise\n }\n\n #shouldScheduleTimer(timeout: unknown): timeout is number {\n return (\n !isServerEnvironment() &&\n resolveQueryValue(this.options.enabled, this.#currentQuery) !== false &&\n isValidTimeout(timeout)\n )\n }\n\n #updateStaleTimeout(): void {\n this.#clearStaleTimeout()\n const staleTime = resolveQueryValue(\n this.options.staleTime,\n this.#currentQuery,\n )\n\n if (this.#currentResult.isStale || !this.#shouldScheduleTimer(staleTime)) {\n return\n }\n\n const time = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime)\n\n // The timeout is sometimes triggered 1 ms before the stale time expiration.\n // To mitigate this issue we always add 1 ms to the timeout.\n const timeout = time + 1\n\n this.#staleTimeoutId = timeoutManager.setTimeout(() => {\n if (!this.#currentResult.isStale) {\n this.updateResult()\n }\n }, timeout)\n }\n\n #computeRefetchInterval() {\n return (\n resolveQueryValue(this.options.refetchInterval, this.#currentQuery) ??\n false\n )\n }\n\n #updateRefetchInterval(nextInterval: number | false): void {\n this.#clearRefetchInterval()\n\n this.#currentRefetchInterval = nextInterval\n\n if (\n this.#currentRefetchInterval === 0 ||\n !this.#shouldScheduleTimer(this.#currentRefetchInterval)\n ) {\n return\n }\n\n this.#refetchIntervalId = timeoutManager.setInterval(() => {\n if (\n this.options.refetchIntervalInBackground ||\n focusManager.isFocused()\n ) {\n this.#executeFetch()\n }\n }, this.#currentRefetchInterval)\n }\n\n #updateTimers(): void {\n this.#updateStaleTimeout()\n this.#updateRefetchInterval(this.#computeRefetchInterval())\n }\n\n #clearStaleTimeout(): void {\n if (this.#staleTimeoutId !== undefined) {\n timeoutManager.clearTimeout(this.#staleTimeoutId)\n this.#staleTimeoutId = undefined\n }\n }\n\n #clearRefetchInterval(): void {\n if (this.#refetchIntervalId !== undefined) {\n timeoutManager.clearInterval(this.#refetchIntervalId)\n this.#refetchIntervalId = undefined\n }\n }\n\n protected createResult(\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): QueryObserverResult<TData, TError> {\n const prevQuery = this.#currentQuery\n const prevOptions = this.options\n const prevResult = this.#currentResult as\n QueryObserverResult<TData, TError> | undefined\n const prevResultState = this.#currentResultState\n const prevResultOptions = this.#currentResultOptions\n const queryChange = query !== prevQuery\n const queryInitialState = queryChange\n ? query.state\n : this.#currentQueryInitialState\n\n const { state } = query\n let newState = { ...state }\n let isPlaceholderData = false\n let data: TData | undefined\n\n // Optimistically set result in fetching state if needed\n if (options._optimisticResults) {\n const mounted = this.hasListeners()\n\n const fetchOnMount = !mounted && shouldFetchOnMount(query, options)\n\n const fetchOptionally =\n mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions)\n\n if (fetchOnMount || fetchOptionally) {\n newState = {\n ...newState,\n ...fetchState(state.data, query.options),\n }\n }\n if (options._optimisticResults === 'isRestoring') {\n newState.fetchStatus = 'idle'\n }\n }\n\n let { error, errorUpdatedAt, status } = newState\n\n // Per default, use query data\n data = newState.data as unknown as TData\n let skipSelect = false\n\n // use placeholderData if needed\n if (\n options.placeholderData !== undefined &&\n data === undefined &&\n status === 'pending'\n ) {\n let placeholderData\n\n // Memoize placeholder data\n if (\n prevResult?.isPlaceholderData &&\n options.placeholderData === prevResultOptions?.placeholderData\n ) {\n placeholderData = prevResult.data\n // we have to skip select when reading this memoization\n // because prevResult.data is already \"selected\"\n skipSelect = true\n } else {\n // compute placeholderData\n placeholderData =\n typeof options.placeholderData === 'function'\n ? (\n options.placeholderData as unknown as PlaceholderDataFunction<TQueryData>\n )(\n this.#lastQueryWithDefinedData?.state.data,\n this.#lastQueryWithDefinedData as any,\n )\n : options.placeholderData\n }\n\n if (placeholderData !== undefined) {\n status = 'success'\n data = replaceData(\n prevResult?.data,\n placeholderData as unknown,\n options,\n ) as TData\n isPlaceholderData = true\n }\n }\n\n // Select data if needed\n // this also runs placeholderData through the select function\n if (options.select && data !== undefined && !skipSelect) {\n // Memoize select result\n if (\n prevResult &&\n data === prevResultState?.data &&\n options.select === this.#selectFn\n ) {\n data = this.#selectResult\n } else {\n try {\n this.#selectFn = options.select\n data = options.select(data as any)\n data = replaceData(prevResult?.data, data, options)\n this.#selectResult = data\n this.#selectError = null\n } catch (selectError) {\n this.#selectError = selectError as TError\n }\n }\n } else if (data === undefined) {\n // a stored select error belongs to previously selected data; once that\n // data is gone (query switch or reset), it must not leak into this result\n this.#selectError = null\n }\n\n if (this.#selectError) {\n error = this.#selectError\n data = this.#selectResult\n errorUpdatedAt = Date.now()\n status = 'error'\n isPlaceholderData = false\n }\n\n const isFetching = newState.fetchStatus === 'fetching'\n const isPending = status === 'pending'\n const isError = status === 'error'\n\n const isLoading = isPending && isFetching\n const hasData = data !== undefined\n\n const result: QueryObserverBaseResult<TData, TError> = {\n status,\n fetchStatus: newState.fetchStatus,\n isPending,\n isSuccess: status === 'success',\n isError,\n isInitialLoading: isLoading,\n isLoading,\n data,\n dataUpdatedAt: newState.dataUpdatedAt,\n error,\n errorUpdatedAt,\n failureCount: newState.fetchFailureCount,\n failureReason: newState.fetchFailureReason,\n errorUpdateCount: newState.errorUpdateCount,\n isFetched: query.isFetched(),\n isFetchedAfterMount:\n newState.dataUpdateCount > queryInitialState.dataUpdateCount ||\n newState.errorUpdateCount > queryInitialState.errorUpdateCount,\n isFetching,\n isRefetching: isFetching && !isPending,\n isLoadingError: isError && !hasData,\n isPaused: newState.fetchStatus === 'paused',\n isPlaceholderData,\n isRefetchError: isError && hasData,\n isStale: isStale(query, options),\n refetch: this.refetch,\n isEnabled: resolveQueryValue(options.enabled, query) !== false,\n }\n\n const nextResult = result as QueryObserverResult<TData, TError>\n\n return nextResult\n }\n\n /**\n * Recomputes and stores the current result from the current query/options, notifying listeners\n * if it changed. Framework adapters call this right after subscribing to make sure no query\n * update was missed in the gap between creating the observer and subscribing to it.\n */\n updateResult(): void {\n const prevResult = this.#currentResult as\n QueryObserverResult<TData, TError> | undefined\n\n const nextResult = this.createResult(this.#currentQuery, this.options)\n\n this.#currentResultState = this.#currentQuery.state\n this.#currentResultOptions = this.options\n\n if (this.#currentResultState.data !== undefined) {\n this.#lastQueryWithDefinedData = this.#currentQuery\n }\n\n // Only notify and update result if something has changed\n if (shallowEqualObjects(nextResult, prevResult)) {\n return\n }\n\n this.#currentResult = nextResult\n\n const shouldNotifyListeners = (): boolean => {\n if (!prevResult) {\n return true\n }\n\n const { notifyOnChangeProps } = this.options\n const notifyOnChangePropsValue =\n typeof notifyOnChangeProps === 'function'\n ? notifyOnChangeProps()\n : notifyOnChangeProps\n\n if (\n notifyOnChangePropsValue === 'all' ||\n (!notifyOnChangePropsValue && !this.#trackedProps.size)\n ) {\n return true\n }\n\n const includedProps = new Set(\n notifyOnChangePropsValue ?? this.#trackedProps,\n )\n\n if (this.options.throwOnError) {\n includedProps.add('error')\n }\n\n return Object.keys(this.#currentResult).some((key) => {\n const typedKey = key as keyof QueryObserverResult\n const changed = this.#currentResult[typedKey] !== prevResult[typedKey]\n\n return changed && includedProps.has(typedKey)\n })\n }\n\n const notifyListeners = shouldNotifyListeners()\n\n notifyManager.batch(() => {\n // First, trigger the listeners\n if (notifyListeners) {\n this.listeners.forEach((listener) => {\n listener(this.#currentResult)\n })\n }\n\n // Then the cache listeners\n this.#client.getQueryCache().notify({\n query: this.#currentQuery,\n type: 'observerResultsUpdated',\n })\n })\n }\n\n #updateQuery(): void {\n const query = this.#client.getQueryCache().build(this.#client, this.options)\n\n if (query === this.#currentQuery) {\n return\n }\n\n const prevQuery = this.#currentQuery as\n Query<TQueryFnData, TError, TQueryData, TQueryKey> | undefined\n this.#currentQuery = query\n this.#currentQueryInitialState = query.state\n\n if (this.hasListeners()) {\n prevQuery?.removeObserver(this)\n query.addObserver(this)\n }\n }\n\n /** @internal */\n onQueryUpdate(): void {\n this.updateResult()\n\n if (this.hasListeners()) {\n this.#updateTimers()\n }\n }\n}\n\nfunction shouldLoadOnMount(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any>,\n): boolean {\n return (\n resolveQueryValue(options.enabled, query) !== false &&\n query.state.data === undefined &&\n !(\n query.state.status === 'error' &&\n resolveQueryValue(options.retryOnMount, query) === false\n )\n )\n}\n\nfunction shouldFetchOnMount(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n): boolean {\n return (\n shouldLoadOnMount(query, options) ||\n (query.state.data !== undefined &&\n shouldFetchOn(query, options, options.refetchOnMount))\n )\n}\n\nfunction shouldFetchOn(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n field: (typeof options)['refetchOnMount'] &\n (typeof options)['refetchOnWindowFocus'] &\n (typeof options)['refetchOnReconnect'],\n) {\n if (\n resolveQueryValue(options.enabled, query) !== false &&\n resolveQueryValue(options.staleTime, query) !== 'static'\n ) {\n const value = resolveQueryValue(field, query)\n\n return value === 'always' || (value !== false && isStale(query, options))\n }\n return false\n}\n\nfunction shouldFetchOptionally(\n query: Query<any, any, any, any>,\n prevQuery: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n prevOptions: QueryObserverOptions<any, any, any, any, any>,\n): boolean {\n return (\n (query !== prevQuery ||\n resolveQueryValue(prevOptions.enabled, query) === false) &&\n (!options.suspense || query.state.status !== 'error') &&\n isStale(query, options)\n )\n}\n\nfunction isStale(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n): boolean {\n return (\n resolveQueryValue(options.enabled, query) !== false &&\n query.isStaleByTime(resolveQueryValue(options.staleTime, query))\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,IAAa,gBAAb,cAMUA,qBAAAA,aAAmD;CAwB3D,YACE,QACA,SAOA;EACA,MAAM;EARC,KAAA,UAAA;;;EAxB2D,8BAAA,2BAAA,MAAA,eAAA,KAAA,CAAA;EACR,8BAAA,2BAAA,MAAA,2BAAA,KAAA,CAAA;EACP,8BAAA,2BAAA,MAAA,gBAAA,KAAA,CAAA;;;;;;;;;;EAkBrC,8BAAA,2BAAA,MAAA,+BAAA,IAAI,IAA+B,CAAA;EAcjD,8BAAA,uBAAA,SAAA,MAAe,MAAA;EACf,8BAAA,uBAAA,cAAA,MAAoB,IAAA;EAEpB,KAAK,YAAY;EACjB,KAAK,WAAW,OAAO;CACzB;CAEA,cAA8B;EAC5B,KAAK,UAAU,KAAK,QAAQ,KAAK,IAAI;CACvC;CAEA,cAA8B;EAC5B,IAAI,KAAK,UAAU,SAAS,GAAG;GAC7B,8BAAA,uBAAA,eAAA,IAAA,CAAA,CAAmB,YAAY,IAAI;GAEnC,IAAI,mBAAA,8BAAA,uBAAA,eAAmB,IAAA,GAAoB,KAAK,OAAO,GACrD,8BAAA,kBAAA,sBAAA,MAAA,aAAA,CAAA,CAAA,KAAA,IAAmB;QAEnB,KAAK,aAAa;GAGpB,8BAAA,kBAAA,sBAAA,MAAA,aAAA,CAAA,CAAA,KAAA,IAAmB;EACrB;CACF;CAEA,gBAAgC;EAC9B,IAAI,CAAC,KAAK,aAAa,GACrB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"}
1
+ {"version":3,"file":"queryObserver.cjs","names":["Subscribable","resolveQueryValue","shallowEqualObjects","fetchState","replaceData","noop","isServerEnvironment","isValidTimeout","timeUntilStale","timeoutManager","focusManager"],"sources":["../../src/queryObserver.ts"],"sourcesContent":["import { focusManager } from './focusManager'\nimport { isServer as isServerEnvironment } from './environmentManager'\nimport { notifyManager } from './notifyManager'\nimport { fetchState } from './query'\nimport { Subscribable } from './subscribable'\nimport {\n isValidTimeout,\n noop,\n replaceData,\n resolveQueryValue,\n shallowEqualObjects,\n timeUntilStale,\n} from './utils'\nimport { timeoutManager } from './timeoutManager'\nimport type { ManagedTimerId } from './timeoutManager'\nimport type { FetchOptions, Query, QueryState } from './query'\nimport type { QueryClient } from './queryClient'\nimport type {\n DefaultError,\n DefaultedQueryObserverOptions,\n PlaceholderDataFunction,\n QueryKey,\n QueryObserverBaseResult,\n QueryObserverOptions,\n QueryObserverResult,\n RefetchOptions,\n} from './types'\n\ntype QueryObserverListener<TData, TError> = (\n result: QueryObserverResult<TData, TError>,\n) => void\n\ninterface ObserverFetchOptions extends FetchOptions {\n throwOnError?: boolean\n}\n\n/**\n * A `QueryObserver` watches a single query in the `QueryCache` and computes a\n * `QueryObserverResult` from its state, recomputing and notifying subscribers\n * whenever the underlying query (or the observer's options) changes. It is\n * the primitive that framework adapters (e.g. `useQuery`) build their hooks\n * on top of, but it can also be used directly to observe and switch between\n * queries outside of any framework.\n * @example\n * ```ts\n * const observer = new QueryObserver(queryClient, {\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n *\n * const unsubscribe = observer.subscribe((result) => {\n * console.log(result.data)\n * })\n * ```\n */\nexport class QueryObserver<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> extends Subscribable<QueryObserverListener<TData, TError>> {\n #client: QueryClient\n #currentQuery: Query<TQueryFnData, TError, TQueryData, TQueryKey> = undefined!\n #currentQueryInitialState: QueryState<TQueryData, TError> = undefined!\n #currentResult: QueryObserverResult<TData, TError> = undefined!\n #currentResultState?: QueryState<TQueryData, TError>\n #currentResultOptions?: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >\n #selectError: TError | null\n #selectFn?: (data: TQueryData) => TData\n #selectResult?: TData\n // This property keeps track of the last query with defined data.\n // It will be used to pass the previous data and query to the placeholder function between renders.\n #lastQueryWithDefinedData?: Query<TQueryFnData, TError, TQueryData, TQueryKey>\n #staleTimeoutId?: ManagedTimerId\n #refetchIntervalId?: ManagedTimerId\n #currentRefetchInterval?: number | false\n #trackedProps = new Set<keyof QueryObserverResult>()\n\n constructor(\n client: QueryClient,\n public options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ) {\n super()\n\n this.#client = client\n this.#selectError = null\n\n this.bindMethods()\n this.setOptions(options)\n }\n\n /**\n * Binds the methods of the result (`refetch`) to the observer, so they keep working when destructured\n * from it. Subclasses override it to bind their own result methods as well.\n */\n protected bindMethods(): void {\n this.refetch = this.refetch.bind(this)\n }\n\n protected override onSubscribe(): void {\n if (this.listeners.size === 1) {\n this.#currentQuery.addObserver(this)\n\n if (shouldFetchOnMount(this.#currentQuery, this.options)) {\n this.#executeFetch()\n } else {\n this.updateResult()\n }\n\n this.#updateTimers()\n }\n }\n\n protected override onUnsubscribe(): void {\n if (!this.hasListeners()) {\n this.destroy()\n }\n }\n\n /**\n * Returns whether the observed query is currently stale and configured\n * (via the `refetchOnReconnect` option) to refetch when the network\n * reconnects.\n * @returns `true` if the observer should refetch the query on reconnect.\n */\n shouldFetchOnReconnect(): boolean {\n return shouldFetchOn(\n this.#currentQuery,\n this.options,\n this.options.refetchOnReconnect,\n )\n }\n\n /**\n * Returns whether the observed query is currently stale and configured\n * (via the `refetchOnWindowFocus` option) to refetch when the window\n * regains focus.\n * @returns `true` if the observer should refetch the query on window focus.\n */\n shouldFetchOnWindowFocus(): boolean {\n return shouldFetchOn(\n this.#currentQuery,\n this.options,\n this.options.refetchOnWindowFocus,\n )\n }\n\n /**\n * Stops observing the current query: clears all listeners, cancels the\n * stale and refetch-interval timers, and removes this observer from the\n * query it was observing.\n */\n destroy(): void {\n this.listeners = new Set()\n this.#clearStaleTimeout()\n this.#clearRefetchInterval()\n this.#currentQuery.removeObserver(this)\n }\n\n /**\n * Updates the observer's options. This will re-resolve the query being\n * observed (switching to a different query if the `queryKey` changed),\n * trigger a fetch if the new options require one and the observer has\n * subscribers, recompute the current result, and reschedule the stale and\n * refetch-interval timers as needed.\n * @param options - The new observer options. They are defaulted with {@link\n * QueryClient#defaultQueryOptions} before being applied.\n * @throws {Error} If `enabled` is neither a boolean nor a function.\n * @example\n * ```ts\n * observer.setOptions({ queryKey: ['posts', 1], queryFn: () => fetchPost(1) })\n * // later: switch to a different query, reusing the same observer\n * observer.setOptions({ queryKey: ['posts', 2], queryFn: () => fetchPost(2) })\n * ```\n */\n setOptions(\n options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): void {\n const prevOptions = this.options\n const prevQuery = this.#currentQuery\n\n this.options = this.#client.defaultQueryOptions(options)\n\n if (\n this.options.enabled !== undefined &&\n typeof this.options.enabled !== 'boolean' &&\n typeof this.options.enabled !== 'function' &&\n typeof resolveQueryValue(this.options.enabled, this.#currentQuery) !==\n 'boolean'\n ) {\n throw new Error(\n 'Expected enabled to be a boolean or a callback that returns a boolean',\n )\n }\n\n this.#updateQuery()\n this.#currentQuery.setOptions(this.options)\n\n if (\n prevOptions._defaulted &&\n !shallowEqualObjects(this.options, prevOptions)\n ) {\n this.#client.getQueryCache().notify({\n type: 'observerOptionsUpdated',\n query: this.#currentQuery,\n observer: this,\n })\n }\n\n const mounted = this.hasListeners()\n\n // Fetch if there are subscribers\n if (\n mounted &&\n shouldFetchOptionally(\n this.#currentQuery,\n prevQuery,\n this.options,\n prevOptions,\n )\n ) {\n this.#executeFetch()\n }\n\n // Update result\n this.updateResult()\n\n // Update stale interval if needed\n if (\n mounted &&\n (this.#currentQuery !== prevQuery ||\n resolveQueryValue(this.options.enabled, this.#currentQuery) !==\n resolveQueryValue(prevOptions.enabled, this.#currentQuery) ||\n resolveQueryValue(this.options.staleTime, this.#currentQuery) !==\n resolveQueryValue(prevOptions.staleTime, this.#currentQuery))\n ) {\n this.#updateStaleTimeout()\n }\n\n const nextRefetchInterval = this.#computeRefetchInterval()\n\n // Update refetch interval if needed\n if (\n mounted &&\n (this.#currentQuery !== prevQuery ||\n resolveQueryValue(this.options.enabled, this.#currentQuery) !==\n resolveQueryValue(prevOptions.enabled, this.#currentQuery) ||\n nextRefetchInterval !== this.#currentRefetchInterval)\n ) {\n this.#updateRefetchInterval(nextRefetchInterval)\n }\n }\n\n /**\n * Computes the result the observer would produce for the given (already-defaulted) options\n * right now, building the underlying `Query` if it doesn't exist yet, without waiting for a\n * subscription callback. Called by framework adapters on every render (e.g. `useQuery`) so the\n * returned value is available synchronously, ahead of `setOptions` triggering an actual fetch.\n * @param options - The defaulted observer options to compute the result for.\n * @returns The result for the given options.\n */\n getOptimisticResult(\n options: DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): QueryObserverResult<TData, TError> {\n const query = this.#client.getQueryCache().build(this.#client, options)\n\n const result = this.createResult(query, options)\n\n if (!shallowEqualObjects(this.getCurrentResult(), result)) {\n // this assigns the optimistic result to the current Observer\n // because if the query function changes, useQuery will be performing\n // an effect where it would fetch again.\n // When the fetch finishes, we perform a deep data cloning in order\n // to reuse objects references. This deep data clone is performed against\n // the `observer.currentResult.data` property\n // When QueryKey changes, we refresh the query and get new `optimistic`\n // result, while we leave the `observer.currentResult`, so when new data\n // arrives, it finds the old `observer.currentResult` which is related\n // to the old QueryKey. Which means that currentResult and selectData are\n // out of sync already.\n // To solve this, we move the cursor of the currentResult every time\n // an observer reads an optimistic value.\n\n // When keeping the previous data, the result doesn't change until new\n // data arrives.\n this.#currentResult = result\n this.#currentResultOptions = this.options\n this.#currentResultState = this.#currentQuery.state\n }\n return result\n }\n\n /**\n * Returns the most recently computed `QueryObserverResult` for the\n * observed query. This is a point-in-time read; to be notified of updates\n * as they happen, subscribe to the observer instead (its inherited\n * `subscribe` method).\n * @returns The observer's latest result.\n * @example\n * ```ts\n * const result = observer.getCurrentResult()\n * console.log(result.status, result.data)\n * ```\n */\n getCurrentResult(): QueryObserverResult<TData, TError> {\n return this.#currentResult\n }\n\n /**\n * Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via\n * {@link QueryObserver#trackProp} (and an optional `onPropTracked` callback). Used by framework\n * adapters when `notifyOnChangeProps` is not set, to implement its default \"only re-render on\n * properties you actually read\" behavior.\n * @param result - The result to wrap.\n * @param onPropTracked - Called with the name of each property that is read.\n * @returns A proxy of `result` that tracks property reads.\n */\n trackResult(\n result: QueryObserverResult<TData, TError>,\n onPropTracked?: (key: keyof QueryObserverResult) => void,\n ): QueryObserverResult<TData, TError> {\n return new Proxy(result, {\n get: (target, key) => {\n this.trackProp(key as keyof QueryObserverResult)\n onPropTracked?.(key as keyof QueryObserverResult)\n return Reflect.get(target, key)\n },\n })\n }\n\n /**\n * Records that the given `QueryObserverResult` property was read, so a subsequent update only\n * notifies this observer if a tracked property actually changed. Normally called indirectly via\n * {@link QueryObserver#trackResult}'s proxy; exposed directly for adapters that track property\n * access themselves (e.g. through their own reactivity system) instead of via the proxy.\n * @param key - The name of the property that was read.\n */\n trackProp(key: keyof QueryObserverResult) {\n this.#trackedProps.add(key)\n }\n\n /**\n * Returns the `Query` instance this observer is currently observing.\n * @returns The observed query.\n */\n getCurrentQuery(): Query<TQueryFnData, TError, TQueryData, TQueryKey> {\n return this.#currentQuery\n }\n\n /**\n * Refetches the observed query and returns a promise that resolves with\n * the resulting `QueryObserverResult`.\n * @param options - Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling\n * it, and `throwOnError` to `true` to reject when the refetch fails.\n * @returns A promise that resolves with the result after the refetch.\n * @example\n * ```ts\n * const result = await observer.refetch({ cancelRefetch: false })\n * console.log(result.data)\n * ```\n */\n refetch({ ...options }: RefetchOptions = {}): Promise<\n QueryObserverResult<TData, TError>\n > {\n return this.fetch({\n ...options,\n })\n }\n\n /**\n * Fetches a query defined by the given options without affecting this\n * observer's own tracked query or result, and returns a promise that\n * resolves with the `QueryObserverResult` for that fetch. This is useful\n * for prefetching data that another observer (e.g. a query about to be\n * navigated to) will need, ahead of time.\n * @param options - The observer options of the query to fetch.\n * @returns A promise that resolves with the result for the fetched query.\n * @example\n * ```ts\n * const result = await observer.fetchOptimistic({\n * queryKey: ['posts', 2],\n * queryFn: () => fetchPost(2),\n * })\n * console.log(result.data)\n * ```\n */\n fetchOptimistic(\n options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): Promise<QueryObserverResult<TData, TError>> {\n const defaultedOptions = this.#client.defaultQueryOptions(options)\n\n const query = this.#client\n .getQueryCache()\n .build(this.#client, defaultedOptions)\n\n let unsubscribe = () => {}\n let resolveEarly:\n | ((result: QueryObserverResult<TData, TError>) => void)\n | undefined\n\n const cachePromise = new Promise<QueryObserverResult<TData, TError>>(\n (resolve) => {\n resolveEarly = resolve\n unsubscribe = this.#client.getQueryCache().subscribe((event) => {\n if (\n event.type === 'updated' &&\n event.query.queryHash === query.queryHash &&\n query.state.data !== undefined\n ) {\n unsubscribe()\n resolve(this.createResult(query, defaultedOptions))\n }\n })\n },\n )\n\n return Promise.race([\n query\n .fetch()\n .then(() => {\n const result = this.createResult(query, defaultedOptions)\n // Settle the subscriber promise so both branches always settle.\n // This value is ignored by Promise.race since the fetch branch already won.\n resolveEarly?.(result)\n return result\n })\n .finally(() => {\n unsubscribe()\n }),\n cachePromise,\n ])\n }\n\n /**\n * Fetches the observed query and updates the result once the fetch settles. Used by `refetch` and,\n * in `InfiniteQueryObserver`, to fetch more pages.\n * @param fetchOptions - Options for this fetch. `cancelRefetch` defaults to `true`.\n * @returns A promise that resolves with the updated result.\n */\n protected fetch(\n fetchOptions: ObserverFetchOptions,\n ): Promise<QueryObserverResult<TData, TError>> {\n return this.#executeFetch({\n ...fetchOptions,\n cancelRefetch: fetchOptions.cancelRefetch ?? true,\n }).then(() => {\n this.updateResult()\n return this.#currentResult\n })\n }\n\n #executeFetch(\n fetchOptions?: Omit<ObserverFetchOptions, 'initialPromise'>,\n ): Promise<TQueryData | undefined> {\n // Make sure we reference the latest query as the current one might have been removed\n this.#updateQuery()\n\n // Fetch\n let promise: Promise<TQueryData | undefined> = this.#currentQuery.fetch(\n this.options,\n fetchOptions,\n )\n\n if (!fetchOptions?.throwOnError) {\n promise = promise.catch(noop)\n }\n\n return promise\n }\n\n #shouldScheduleTimer(timeout: unknown): timeout is number {\n return (\n !isServerEnvironment() &&\n resolveQueryValue(this.options.enabled, this.#currentQuery) !== false &&\n isValidTimeout(timeout)\n )\n }\n\n #updateStaleTimeout(): void {\n this.#clearStaleTimeout()\n const staleTime = resolveQueryValue(\n this.options.staleTime,\n this.#currentQuery,\n )\n\n if (this.#currentResult.isStale || !this.#shouldScheduleTimer(staleTime)) {\n return\n }\n\n const time = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime)\n\n // The timeout is sometimes triggered 1 ms before the stale time expiration.\n // To mitigate this issue we always add 1 ms to the timeout.\n const timeout = time + 1\n\n this.#staleTimeoutId = timeoutManager.setTimeout(() => {\n if (!this.#currentResult.isStale) {\n this.updateResult()\n }\n }, timeout)\n }\n\n #computeRefetchInterval() {\n return (\n resolveQueryValue(this.options.refetchInterval, this.#currentQuery) ??\n false\n )\n }\n\n #updateRefetchInterval(nextInterval: number | false): void {\n this.#clearRefetchInterval()\n\n this.#currentRefetchInterval = nextInterval\n\n if (\n this.#currentRefetchInterval === 0 ||\n !this.#shouldScheduleTimer(this.#currentRefetchInterval)\n ) {\n return\n }\n\n this.#refetchIntervalId = timeoutManager.setInterval(() => {\n if (\n this.options.refetchIntervalInBackground ||\n focusManager.isFocused()\n ) {\n this.#executeFetch()\n }\n }, this.#currentRefetchInterval)\n }\n\n #updateTimers(): void {\n this.#updateStaleTimeout()\n this.#updateRefetchInterval(this.#computeRefetchInterval())\n }\n\n #clearStaleTimeout(): void {\n if (this.#staleTimeoutId !== undefined) {\n timeoutManager.clearTimeout(this.#staleTimeoutId)\n this.#staleTimeoutId = undefined\n }\n }\n\n #clearRefetchInterval(): void {\n if (this.#refetchIntervalId !== undefined) {\n timeoutManager.clearInterval(this.#refetchIntervalId)\n this.#refetchIntervalId = undefined\n }\n }\n\n /**\n * Computes the result for a query and options from the query's state, applying `select`,\n * `placeholderData`, and the derived flags. Subclasses override it to add their own fields.\n * @param query - The query to compute the result for.\n * @param options - The observer options to compute the result with.\n * @returns The computed result.\n */\n protected createResult(\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): QueryObserverResult<TData, TError> {\n const prevQuery = this.#currentQuery\n const prevOptions = this.options\n const prevResult = this.#currentResult as\n | QueryObserverResult<TData, TError>\n | undefined\n const prevResultState = this.#currentResultState\n const prevResultOptions = this.#currentResultOptions\n const queryChange = query !== prevQuery\n const queryInitialState = queryChange\n ? query.state\n : this.#currentQueryInitialState\n\n const { state } = query\n let newState = { ...state }\n let isPlaceholderData = false\n let data: TData | undefined\n\n // Optimistically set result in fetching state if needed\n if (options._optimisticResults) {\n const mounted = this.hasListeners()\n\n const fetchOnMount = !mounted && shouldFetchOnMount(query, options)\n\n const fetchOptionally =\n mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions)\n\n if (fetchOnMount || fetchOptionally) {\n newState = {\n ...newState,\n ...fetchState(state.data, query.options),\n }\n }\n if (options._optimisticResults === 'isRestoring') {\n newState.fetchStatus = 'idle'\n }\n }\n\n let { error, errorUpdatedAt, status } = newState\n\n // Per default, use query data\n data = newState.data as unknown as TData\n let skipSelect = false\n\n // use placeholderData if needed\n if (\n options.placeholderData !== undefined &&\n data === undefined &&\n status === 'pending'\n ) {\n let placeholderData\n\n // Memoize placeholder data\n if (\n prevResult?.isPlaceholderData &&\n options.placeholderData === prevResultOptions?.placeholderData\n ) {\n placeholderData = prevResult.data\n // we have to skip select when reading this memoization\n // because prevResult.data is already \"selected\"\n skipSelect = true\n } else {\n // compute placeholderData\n placeholderData =\n typeof options.placeholderData === 'function'\n ? (\n options.placeholderData as unknown as PlaceholderDataFunction<TQueryData>\n )(\n this.#lastQueryWithDefinedData?.state.data,\n this.#lastQueryWithDefinedData as any,\n )\n : options.placeholderData\n }\n\n if (placeholderData !== undefined) {\n status = 'success'\n data = replaceData(\n prevResult?.data,\n placeholderData as unknown,\n options,\n ) as TData\n isPlaceholderData = true\n }\n }\n\n // Select data if needed\n // this also runs placeholderData through the select function\n if (options.select && data !== undefined && !skipSelect) {\n // Memoize select result\n if (\n prevResult &&\n data === prevResultState?.data &&\n options.select === this.#selectFn\n ) {\n data = this.#selectResult\n } else {\n try {\n this.#selectFn = options.select\n data = options.select(data as any)\n data = replaceData(prevResult?.data, data, options)\n this.#selectResult = data\n this.#selectError = null\n } catch (selectError) {\n this.#selectError = selectError as TError\n }\n }\n } else if (data === undefined) {\n // a stored select error belongs to previously selected data; once that\n // data is gone (query switch or reset), it must not leak into this result\n this.#selectError = null\n }\n\n if (this.#selectError) {\n error = this.#selectError\n data = this.#selectResult\n errorUpdatedAt = Date.now()\n status = 'error'\n isPlaceholderData = false\n }\n\n const isFetching = newState.fetchStatus === 'fetching'\n const isPending = status === 'pending'\n const isError = status === 'error'\n\n const isLoading = isPending && isFetching\n const hasData = data !== undefined\n\n const result: QueryObserverBaseResult<TData, TError> = {\n status,\n fetchStatus: newState.fetchStatus,\n isPending,\n isSuccess: status === 'success',\n isError,\n isInitialLoading: isLoading,\n isLoading,\n data,\n dataUpdatedAt: newState.dataUpdatedAt,\n error,\n errorUpdatedAt,\n failureCount: newState.fetchFailureCount,\n failureReason: newState.fetchFailureReason,\n errorUpdateCount: newState.errorUpdateCount,\n isFetched: query.isFetched(),\n isFetchedAfterMount:\n newState.dataUpdateCount > queryInitialState.dataUpdateCount ||\n newState.errorUpdateCount > queryInitialState.errorUpdateCount,\n isFetching,\n isRefetching: isFetching && !isPending,\n isLoadingError: isError && !hasData,\n isPaused: newState.fetchStatus === 'paused',\n isPlaceholderData,\n isRefetchError: isError && hasData,\n isStale: isStale(query, options),\n refetch: this.refetch,\n isEnabled: resolveQueryValue(options.enabled, query) !== false,\n }\n\n const nextResult = result as QueryObserverResult<TData, TError>\n\n return nextResult\n }\n\n /**\n * Recomputes and stores the current result from the current query/options, notifying listeners\n * if it changed. Framework adapters call this right after subscribing to make sure no query\n * update was missed in the gap between creating the observer and subscribing to it.\n */\n updateResult(): void {\n const prevResult = this.#currentResult as\n | QueryObserverResult<TData, TError>\n | undefined\n\n const nextResult = this.createResult(this.#currentQuery, this.options)\n\n this.#currentResultState = this.#currentQuery.state\n this.#currentResultOptions = this.options\n\n if (this.#currentResultState.data !== undefined) {\n this.#lastQueryWithDefinedData = this.#currentQuery\n }\n\n // Only notify and update result if something has changed\n if (shallowEqualObjects(nextResult, prevResult)) {\n return\n }\n\n this.#currentResult = nextResult\n\n const shouldNotifyListeners = (): boolean => {\n if (!prevResult) {\n return true\n }\n\n const { notifyOnChangeProps } = this.options\n const notifyOnChangePropsValue =\n typeof notifyOnChangeProps === 'function'\n ? notifyOnChangeProps()\n : notifyOnChangeProps\n\n if (\n notifyOnChangePropsValue === 'all' ||\n (!notifyOnChangePropsValue && !this.#trackedProps.size)\n ) {\n return true\n }\n\n const includedProps = new Set(\n notifyOnChangePropsValue ?? this.#trackedProps,\n )\n\n if (this.options.throwOnError) {\n includedProps.add('error')\n }\n\n return Object.keys(this.#currentResult).some((key) => {\n const typedKey = key as keyof QueryObserverResult\n const changed = this.#currentResult[typedKey] !== prevResult[typedKey]\n\n return changed && includedProps.has(typedKey)\n })\n }\n\n const notifyListeners = shouldNotifyListeners()\n\n notifyManager.batch(() => {\n // First, trigger the listeners\n if (notifyListeners) {\n this.listeners.forEach((listener) => {\n listener(this.#currentResult)\n })\n }\n\n // Then the cache listeners\n this.#client.getQueryCache().notify({\n query: this.#currentQuery,\n type: 'observerResultsUpdated',\n })\n })\n }\n\n #updateQuery(): void {\n const query = this.#client.getQueryCache().build(this.#client, this.options)\n\n if (query === this.#currentQuery) {\n return\n }\n\n const prevQuery = this.#currentQuery as\n | Query<TQueryFnData, TError, TQueryData, TQueryKey>\n | undefined\n this.#currentQuery = query\n this.#currentQueryInitialState = query.state\n\n if (this.hasListeners()) {\n prevQuery?.removeObserver(this)\n query.addObserver(this)\n }\n }\n\n /**\n * Updates the observer's result when the observed query changes, and reschedules its timers if it\n * has listeners.\n * @internal\n */\n onQueryUpdate(): void {\n this.updateResult()\n\n if (this.hasListeners()) {\n this.#updateTimers()\n }\n }\n}\n\n/**\n * Checks whether a query has no data yet and should do its initial load when an observer mounts.\n * @param query - The query to check.\n * @param options - The observer options.\n * @returns `true` if the query is enabled, has no data, and isn't in an error state with\n * `retryOnMount: false`.\n */\nfunction shouldLoadOnMount(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any>,\n): boolean {\n return (\n resolveQueryValue(options.enabled, query) !== false &&\n query.state.data === undefined &&\n !(\n query.state.status === 'error' &&\n resolveQueryValue(options.retryOnMount, query) === false\n )\n )\n}\n\n/**\n * Checks whether a query should fetch when an observer mounts: either for its initial load, or\n * because it has data and `refetchOnMount` asks for a refetch.\n * @param query - The query to check.\n * @param options - The observer options.\n * @returns `true` if the query should fetch on mount.\n */\nfunction shouldFetchOnMount(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n): boolean {\n return (\n shouldLoadOnMount(query, options) ||\n (query.state.data !== undefined &&\n shouldFetchOn(query, options, options.refetchOnMount))\n )\n}\n\n/**\n * Checks whether a query should fetch for a `refetchOnMount`, `refetchOnWindowFocus`, or\n * `refetchOnReconnect` option.\n * @param query - The query to check.\n * @param options - The observer options.\n * @param field - The value of the option to check.\n * @returns `true` if the query is enabled, not static, and the option is `'always'`, or is not\n * `false` and the query is stale.\n */\nfunction shouldFetchOn(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n field: (typeof options)['refetchOnMount'] &\n (typeof options)['refetchOnWindowFocus'] &\n (typeof options)['refetchOnReconnect'],\n) {\n if (\n resolveQueryValue(options.enabled, query) !== false &&\n resolveQueryValue(options.staleTime, query) !== 'static'\n ) {\n const value = resolveQueryValue(field, query)\n\n return value === 'always' || (value !== false && isStale(query, options))\n }\n return false\n}\n\n/**\n * Checks whether a query should fetch after the observer's options change.\n * @param query - The query observed with the new options.\n * @param prevQuery - The query observed with the previous options.\n * @param options - The new observer options.\n * @param prevOptions - The previous observer options.\n * @returns `true` if the query changed or was disabled before, it isn't a suspense query in an\n * error state, and it is stale.\n */\nfunction shouldFetchOptionally(\n query: Query<any, any, any, any>,\n prevQuery: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n prevOptions: QueryObserverOptions<any, any, any, any, any>,\n): boolean {\n return (\n (query !== prevQuery ||\n resolveQueryValue(prevOptions.enabled, query) === false) &&\n (!options.suspense || query.state.status !== 'error') &&\n isStale(query, options)\n )\n}\n\n/**\n * Checks whether a query is stale for the given observer options.\n * @param query - The query to check.\n * @param options - The observer options, whose `enabled` and `staleTime` are used.\n * @returns `true` if the query is enabled and its data is stale for `staleTime`.\n */\nfunction isStale(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n): boolean {\n return (\n resolveQueryValue(options.enabled, query) !== false &&\n query.isStaleByTime(resolveQueryValue(options.staleTime, query))\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,IAAa,gBAAb,cAMUA,qBAAAA,aAAmD;CAwB3D,YACE,QACA,SAOA;EACA,MAAM;EARC,KAAA,UA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AM,SAC9C,MAAM,MAAM,SAAS,KAAA,KACrB,EACE,MAAM,MAAM,WAAW,WACvBA,cAAAA,kBAAkB,QAAQ,cAAc,KAAK,MAAM;AAGzD;;;;;;;;AASA,SAAS,mBACP,OACA,SACS;CACT,OACE,kBAAkB,OAAO,OAAO,KAC/B,MAAM,MAAM,SAAS,KAAA,KACpB,cAAc,OAAO,SAAS,QAAQ,cAAc;AAE1D;;;;;;;;;;AAWA,SAAS,cACP,OACA,SACA,OAGA;CACA,IACEA,cAAAA,kBAAkB,QAAQ,SAAS,KAAK,MAAM,SAC9CA,cAAAA,kBAAkB,QAAQ,WAAW,KAAK,MAAM,UAChD;EACA,MAAM,QAAQA,cAAAA,kBAAkB,OAAO,KAAK;EAE5C,OAAO,UAAU,YAAa,UAAU,SAAS,QAAQ,OAAO,OAAO;CACzE;CACA,OAAO;AACT;;;;;;;;;;AAWA,SAAS,sBACP,OACA,WACA,SACA,aACS;CACT,QACG,UAAU,aACTA,cAAAA,kBAAkB,YAAY,SAAS,KAAK,MAAM,WACnD,CAAC,QAAQ,YAAY,MAAM,MAAM,WAAW,YAC7C,QAAQ,OAAO,OAAO;AAE1B;;;;;;;AAQA,SAAS,QACP,OACA,SACS;CACT,OACEA,cAAAA,kBAAkB,QAAQ,SAAS,KAAK,MAAM,SAC9C,MAAM,cAAcA,cAAAA,kBAAkB,QAAQ,WAAW,KAAK,CAAC;AAEnE"}
@@ -1,2 +1,2 @@
1
- import { rr as QueryObserver } from "./hydration-Br9VIGXa.cjs";
1
+ import { rr as QueryObserver } from "./hydration-Dfuxd5FW.cjs";
2
2
  export { QueryObserver };
@@ -1,2 +1,2 @@
1
- import { rr as QueryObserver } from "./hydration-B9t5w6NC.js";
1
+ import { rr as QueryObserver } from "./hydration-UAqdtMIf.js";
2
2
  export { QueryObserver };
@@ -30,7 +30,6 @@ var _QueryObserver_brand = /* @__PURE__ */ new WeakSet();
30
30
  * the primitive that framework adapters (e.g. `useQuery`) build their hooks
31
31
  * on top of, but it can also be used directly to observe and switch between
32
32
  * queries outside of any framework.
33
- *
34
33
  * @example
35
34
  * ```ts
36
35
  * const observer = new QueryObserver(queryClient, {
@@ -67,6 +66,10 @@ var QueryObserver = class extends Subscribable {
67
66
  this.bindMethods();
68
67
  this.setOptions(options);
69
68
  }
69
+ /**
70
+ * Binds the methods of the result (`refetch`) to the observer, so they keep working when destructured
71
+ * from it. Subclasses override it to bind their own result methods as well.
72
+ */
70
73
  bindMethods() {
71
74
  this.refetch = this.refetch.bind(this);
72
75
  }
@@ -85,6 +88,7 @@ var QueryObserver = class extends Subscribable {
85
88
  * Returns whether the observed query is currently stale and configured
86
89
  * (via the `refetchOnReconnect` option) to refetch when the network
87
90
  * reconnects.
91
+ * @returns `true` if the observer should refetch the query on reconnect.
88
92
  */
89
93
  shouldFetchOnReconnect() {
90
94
  return shouldFetchOn(_classPrivateFieldGet2(_currentQuery, this), this.options, this.options.refetchOnReconnect);
@@ -93,6 +97,7 @@ var QueryObserver = class extends Subscribable {
93
97
  * Returns whether the observed query is currently stale and configured
94
98
  * (via the `refetchOnWindowFocus` option) to refetch when the window
95
99
  * regains focus.
100
+ * @returns `true` if the observer should refetch the query on window focus.
96
101
  */
97
102
  shouldFetchOnWindowFocus() {
98
103
  return shouldFetchOn(_classPrivateFieldGet2(_currentQuery, this), this.options, this.options.refetchOnWindowFocus);
@@ -114,7 +119,9 @@ var QueryObserver = class extends Subscribable {
114
119
  * trigger a fetch if the new options require one and the observer has
115
120
  * subscribers, recompute the current result, and reschedule the stale and
116
121
  * refetch-interval timers as needed.
117
- *
122
+ * @param options - The new observer options. They are defaulted with {@link
123
+ * QueryClient#defaultQueryOptions} before being applied.
124
+ * @throws {Error} If `enabled` is neither a boolean nor a function.
118
125
  * @example
119
126
  * ```ts
120
127
  * observer.setOptions({ queryKey: ['posts', 1], queryFn: () => fetchPost(1) })
@@ -146,6 +153,8 @@ var QueryObserver = class extends Subscribable {
146
153
  * right now, building the underlying `Query` if it doesn't exist yet, without waiting for a
147
154
  * subscription callback. Called by framework adapters on every render (e.g. `useQuery`) so the
148
155
  * returned value is available synchronously, ahead of `setOptions` triggering an actual fetch.
156
+ * @param options - The defaulted observer options to compute the result for.
157
+ * @returns The result for the given options.
149
158
  */
150
159
  getOptimisticResult(options) {
151
160
  const query = _classPrivateFieldGet2(_client, this).getQueryCache().build(_classPrivateFieldGet2(_client, this), options);
@@ -162,7 +171,7 @@ var QueryObserver = class extends Subscribable {
162
171
  * observed query. This is a point-in-time read; to be notified of updates
163
172
  * as they happen, subscribe to the observer instead (its inherited
164
173
  * `subscribe` method).
165
- *
174
+ * @returns The observer's latest result.
166
175
  * @example
167
176
  * ```ts
168
177
  * const result = observer.getCurrentResult()
@@ -177,6 +186,9 @@ var QueryObserver = class extends Subscribable {
177
186
  * {@link QueryObserver#trackProp} (and an optional `onPropTracked` callback). Used by framework
178
187
  * adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on
179
188
  * properties you actually read" behavior.
189
+ * @param result - The result to wrap.
190
+ * @param onPropTracked - Called with the name of each property that is read.
191
+ * @returns A proxy of `result` that tracks property reads.
180
192
  */
181
193
  trackResult(result, onPropTracked) {
182
194
  return new Proxy(result, { get: (target, key) => {
@@ -190,12 +202,14 @@ var QueryObserver = class extends Subscribable {
190
202
  * notifies this observer if a tracked property actually changed. Normally called indirectly via
191
203
  * {@link QueryObserver#trackResult}'s proxy; exposed directly for adapters that track property
192
204
  * access themselves (e.g. through their own reactivity system) instead of via the proxy.
205
+ * @param key - The name of the property that was read.
193
206
  */
194
207
  trackProp(key) {
195
208
  _classPrivateFieldGet2(_trackedProps, this).add(key);
196
209
  }
197
210
  /**
198
211
  * Returns the `Query` instance this observer is currently observing.
212
+ * @returns The observed query.
199
213
  */
200
214
  getCurrentQuery() {
201
215
  return _classPrivateFieldGet2(_currentQuery, this);
@@ -203,7 +217,9 @@ var QueryObserver = class extends Subscribable {
203
217
  /**
204
218
  * Refetches the observed query and returns a promise that resolves with
205
219
  * the resulting `QueryObserverResult`.
206
- *
220
+ * @param options - Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling
221
+ * it, and `throwOnError` to `true` to reject when the refetch fails.
222
+ * @returns A promise that resolves with the result after the refetch.
207
223
  * @example
208
224
  * ```ts
209
225
  * const result = await observer.refetch({ cancelRefetch: false })
@@ -219,7 +235,8 @@ var QueryObserver = class extends Subscribable {
219
235
  * resolves with the `QueryObserverResult` for that fetch. This is useful
220
236
  * for prefetching data that another observer (e.g. a query about to be
221
237
  * navigated to) will need, ahead of time.
222
- *
238
+ * @param options - The observer options of the query to fetch.
239
+ * @returns A promise that resolves with the result for the fetched query.
223
240
  * @example
224
241
  * ```ts
225
242
  * const result = await observer.fetchOptimistic({
@@ -251,6 +268,12 @@ var QueryObserver = class extends Subscribable {
251
268
  unsubscribe();
252
269
  }), cachePromise]);
253
270
  }
271
+ /**
272
+ * Fetches the observed query and updates the result once the fetch settles. Used by `refetch` and,
273
+ * in `InfiniteQueryObserver`, to fetch more pages.
274
+ * @param fetchOptions - Options for this fetch. `cancelRefetch` defaults to `true`.
275
+ * @returns A promise that resolves with the updated result.
276
+ */
254
277
  fetch(fetchOptions) {
255
278
  return _assertClassBrand(_QueryObserver_brand, this, _executeFetch).call(this, {
256
279
  ...fetchOptions,
@@ -260,6 +283,13 @@ var QueryObserver = class extends Subscribable {
260
283
  return _classPrivateFieldGet2(_currentResult, this);
261
284
  });
262
285
  }
286
+ /**
287
+ * Computes the result for a query and options from the query's state, applying `select`,
288
+ * `placeholderData`, and the derived flags. Subclasses override it to add their own fields.
289
+ * @param query - The query to compute the result for.
290
+ * @param options - The observer options to compute the result with.
291
+ * @returns The computed result.
292
+ */
263
293
  createResult(query, options) {
264
294
  const prevQuery = _classPrivateFieldGet2(_currentQuery, this);
265
295
  const prevOptions = this.options;
@@ -387,7 +417,11 @@ var QueryObserver = class extends Subscribable {
387
417
  });
388
418
  });
389
419
  }
390
- /** @internal */
420
+ /**
421
+ * Updates the observer's result when the observed query changes, and reschedules its timers if it
422
+ * has listeners.
423
+ * @internal
424
+ */
391
425
  onQueryUpdate() {
392
426
  this.updateResult();
393
427
  if (this.hasListeners()) _assertClassBrand(_QueryObserver_brand, this, _updateTimers).call(this);
@@ -449,12 +483,35 @@ function _updateQuery() {
449
483
  query.addObserver(this);
450
484
  }
451
485
  }
486
+ /**
487
+ * Checks whether a query has no data yet and should do its initial load when an observer mounts.
488
+ * @param query - The query to check.
489
+ * @param options - The observer options.
490
+ * @returns `true` if the query is enabled, has no data, and isn't in an error state with
491
+ * `retryOnMount: false`.
492
+ */
452
493
  function shouldLoadOnMount(query, options) {
453
494
  return resolveQueryValue(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && resolveQueryValue(options.retryOnMount, query) === false);
454
495
  }
496
+ /**
497
+ * Checks whether a query should fetch when an observer mounts: either for its initial load, or
498
+ * because it has data and `refetchOnMount` asks for a refetch.
499
+ * @param query - The query to check.
500
+ * @param options - The observer options.
501
+ * @returns `true` if the query should fetch on mount.
502
+ */
455
503
  function shouldFetchOnMount(query, options) {
456
504
  return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
457
505
  }
506
+ /**
507
+ * Checks whether a query should fetch for a `refetchOnMount`, `refetchOnWindowFocus`, or
508
+ * `refetchOnReconnect` option.
509
+ * @param query - The query to check.
510
+ * @param options - The observer options.
511
+ * @param field - The value of the option to check.
512
+ * @returns `true` if the query is enabled, not static, and the option is `'always'`, or is not
513
+ * `false` and the query is stale.
514
+ */
458
515
  function shouldFetchOn(query, options, field) {
459
516
  if (resolveQueryValue(options.enabled, query) !== false && resolveQueryValue(options.staleTime, query) !== "static") {
460
517
  const value = resolveQueryValue(field, query);
@@ -462,9 +519,24 @@ function shouldFetchOn(query, options, field) {
462
519
  }
463
520
  return false;
464
521
  }
522
+ /**
523
+ * Checks whether a query should fetch after the observer's options change.
524
+ * @param query - The query observed with the new options.
525
+ * @param prevQuery - The query observed with the previous options.
526
+ * @param options - The new observer options.
527
+ * @param prevOptions - The previous observer options.
528
+ * @returns `true` if the query changed or was disabled before, it isn't a suspense query in an
529
+ * error state, and it is stale.
530
+ */
465
531
  function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
466
532
  return (query !== prevQuery || resolveQueryValue(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
467
533
  }
534
+ /**
535
+ * Checks whether a query is stale for the given observer options.
536
+ * @param query - The query to check.
537
+ * @param options - The observer options, whose `enabled` and `staleTime` are used.
538
+ * @returns `true` if the query is enabled and its data is stale for `staleTime`.
539
+ */
468
540
  function isStale(query, options) {
469
541
  return resolveQueryValue(options.enabled, query) !== false && query.isStaleByTime(resolveQueryValue(options.staleTime, query));
470
542
  }
@@ -1 +1 @@
1
- {"version":3,"file":"queryObserver.js","names":["isServerEnvironment"],"sources":["../../src/queryObserver.ts"],"sourcesContent":["import { focusManager } from './focusManager'\nimport { isServer as isServerEnvironment } from './environmentManager'\nimport { notifyManager } from './notifyManager'\nimport { fetchState } from './query'\nimport { Subscribable } from './subscribable'\nimport {\n isValidTimeout,\n noop,\n replaceData,\n resolveQueryValue,\n shallowEqualObjects,\n timeUntilStale,\n} from './utils'\nimport { timeoutManager } from './timeoutManager'\nimport type { ManagedTimerId } from './timeoutManager'\nimport type { FetchOptions, Query, QueryState } from './query'\nimport type { QueryClient } from './queryClient'\nimport type {\n DefaultError,\n DefaultedQueryObserverOptions,\n PlaceholderDataFunction,\n QueryKey,\n QueryObserverBaseResult,\n QueryObserverOptions,\n QueryObserverResult,\n RefetchOptions,\n} from './types'\n\ntype QueryObserverListener<TData, TError> = (\n result: QueryObserverResult<TData, TError>,\n) => void\n\ninterface ObserverFetchOptions extends FetchOptions {\n throwOnError?: boolean\n}\n\n/**\n * A `QueryObserver` watches a single query in the `QueryCache` and computes a\n * `QueryObserverResult` from its state, recomputing and notifying subscribers\n * whenever the underlying query (or the observer's options) changes. It is\n * the primitive that framework adapters (e.g. `useQuery`) build their hooks\n * on top of, but it can also be used directly to observe and switch between\n * queries outside of any framework.\n *\n * @example\n * ```ts\n * const observer = new QueryObserver(queryClient, {\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n *\n * const unsubscribe = observer.subscribe((result) => {\n * console.log(result.data)\n * })\n * ```\n */\nexport class QueryObserver<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> extends Subscribable<QueryObserverListener<TData, TError>> {\n #client: QueryClient\n #currentQuery: Query<TQueryFnData, TError, TQueryData, TQueryKey> = undefined!\n #currentQueryInitialState: QueryState<TQueryData, TError> = undefined!\n #currentResult: QueryObserverResult<TData, TError> = undefined!\n #currentResultState?: QueryState<TQueryData, TError>\n #currentResultOptions?: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >\n #selectError: TError | null\n #selectFn?: (data: TQueryData) => TData\n #selectResult?: TData\n // This property keeps track of the last query with defined data.\n // It will be used to pass the previous data and query to the placeholder function between renders.\n #lastQueryWithDefinedData?: Query<TQueryFnData, TError, TQueryData, TQueryKey>\n #staleTimeoutId?: ManagedTimerId\n #refetchIntervalId?: ManagedTimerId\n #currentRefetchInterval?: number | false\n #trackedProps = new Set<keyof QueryObserverResult>()\n\n constructor(\n client: QueryClient,\n public options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ) {\n super()\n\n this.#client = client\n this.#selectError = null\n\n this.bindMethods()\n this.setOptions(options)\n }\n\n protected bindMethods(): void {\n this.refetch = this.refetch.bind(this)\n }\n\n protected onSubscribe(): void {\n if (this.listeners.size === 1) {\n this.#currentQuery.addObserver(this)\n\n if (shouldFetchOnMount(this.#currentQuery, this.options)) {\n this.#executeFetch()\n } else {\n this.updateResult()\n }\n\n this.#updateTimers()\n }\n }\n\n protected onUnsubscribe(): void {\n if (!this.hasListeners()) {\n this.destroy()\n }\n }\n\n /**\n * Returns whether the observed query is currently stale and configured\n * (via the `refetchOnReconnect` option) to refetch when the network\n * reconnects.\n */\n shouldFetchOnReconnect(): boolean {\n return shouldFetchOn(\n this.#currentQuery,\n this.options,\n this.options.refetchOnReconnect,\n )\n }\n\n /**\n * Returns whether the observed query is currently stale and configured\n * (via the `refetchOnWindowFocus` option) to refetch when the window\n * regains focus.\n */\n shouldFetchOnWindowFocus(): boolean {\n return shouldFetchOn(\n this.#currentQuery,\n this.options,\n this.options.refetchOnWindowFocus,\n )\n }\n\n /**\n * Stops observing the current query: clears all listeners, cancels the\n * stale and refetch-interval timers, and removes this observer from the\n * query it was observing.\n */\n destroy(): void {\n this.listeners = new Set()\n this.#clearStaleTimeout()\n this.#clearRefetchInterval()\n this.#currentQuery.removeObserver(this)\n }\n\n /**\n * Updates the observer's options. This will re-resolve the query being\n * observed (switching to a different query if the `queryKey` changed),\n * trigger a fetch if the new options require one and the observer has\n * subscribers, recompute the current result, and reschedule the stale and\n * refetch-interval timers as needed.\n *\n * @example\n * ```ts\n * observer.setOptions({ queryKey: ['posts', 1], queryFn: () => fetchPost(1) })\n * // later: switch to a different query, reusing the same observer\n * observer.setOptions({ queryKey: ['posts', 2], queryFn: () => fetchPost(2) })\n * ```\n */\n setOptions(\n options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): void {\n const prevOptions = this.options\n const prevQuery = this.#currentQuery\n\n this.options = this.#client.defaultQueryOptions(options)\n\n if (\n this.options.enabled !== undefined &&\n typeof this.options.enabled !== 'boolean' &&\n typeof this.options.enabled !== 'function' &&\n typeof resolveQueryValue(this.options.enabled, this.#currentQuery) !==\n 'boolean'\n ) {\n throw new Error(\n 'Expected enabled to be a boolean or a callback that returns a boolean',\n )\n }\n\n this.#updateQuery()\n this.#currentQuery.setOptions(this.options)\n\n if (\n prevOptions._defaulted &&\n !shallowEqualObjects(this.options, prevOptions)\n ) {\n this.#client.getQueryCache().notify({\n type: 'observerOptionsUpdated',\n query: this.#currentQuery,\n observer: this,\n })\n }\n\n const mounted = this.hasListeners()\n\n // Fetch if there are subscribers\n if (\n mounted &&\n shouldFetchOptionally(\n this.#currentQuery,\n prevQuery,\n this.options,\n prevOptions,\n )\n ) {\n this.#executeFetch()\n }\n\n // Update result\n this.updateResult()\n\n // Update stale interval if needed\n if (\n mounted &&\n (this.#currentQuery !== prevQuery ||\n resolveQueryValue(this.options.enabled, this.#currentQuery) !==\n resolveQueryValue(prevOptions.enabled, this.#currentQuery) ||\n resolveQueryValue(this.options.staleTime, this.#currentQuery) !==\n resolveQueryValue(prevOptions.staleTime, this.#currentQuery))\n ) {\n this.#updateStaleTimeout()\n }\n\n const nextRefetchInterval = this.#computeRefetchInterval()\n\n // Update refetch interval if needed\n if (\n mounted &&\n (this.#currentQuery !== prevQuery ||\n resolveQueryValue(this.options.enabled, this.#currentQuery) !==\n resolveQueryValue(prevOptions.enabled, this.#currentQuery) ||\n nextRefetchInterval !== this.#currentRefetchInterval)\n ) {\n this.#updateRefetchInterval(nextRefetchInterval)\n }\n }\n\n /**\n * Computes the result the observer would produce for the given (already-defaulted) options\n * right now, building the underlying `Query` if it doesn't exist yet, without waiting for a\n * subscription callback. Called by framework adapters on every render (e.g. `useQuery`) so the\n * returned value is available synchronously, ahead of `setOptions` triggering an actual fetch.\n */\n getOptimisticResult(\n options: DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): QueryObserverResult<TData, TError> {\n const query = this.#client.getQueryCache().build(this.#client, options)\n\n const result = this.createResult(query, options)\n\n if (!shallowEqualObjects(this.getCurrentResult(), result)) {\n // this assigns the optimistic result to the current Observer\n // because if the query function changes, useQuery will be performing\n // an effect where it would fetch again.\n // When the fetch finishes, we perform a deep data cloning in order\n // to reuse objects references. This deep data clone is performed against\n // the `observer.currentResult.data` property\n // When QueryKey changes, we refresh the query and get new `optimistic`\n // result, while we leave the `observer.currentResult`, so when new data\n // arrives, it finds the old `observer.currentResult` which is related\n // to the old QueryKey. Which means that currentResult and selectData are\n // out of sync already.\n // To solve this, we move the cursor of the currentResult every time\n // an observer reads an optimistic value.\n\n // When keeping the previous data, the result doesn't change until new\n // data arrives.\n this.#currentResult = result\n this.#currentResultOptions = this.options\n this.#currentResultState = this.#currentQuery.state\n }\n return result\n }\n\n /**\n * Returns the most recently computed `QueryObserverResult` for the\n * observed query. This is a point-in-time read; to be notified of updates\n * as they happen, subscribe to the observer instead (its inherited\n * `subscribe` method).\n *\n * @example\n * ```ts\n * const result = observer.getCurrentResult()\n * console.log(result.status, result.data)\n * ```\n */\n getCurrentResult(): QueryObserverResult<TData, TError> {\n return this.#currentResult\n }\n\n /**\n * Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via\n * {@link QueryObserver#trackProp} (and an optional `onPropTracked` callback). Used by framework\n * adapters when `notifyOnChangeProps` is not set, to implement its default \"only re-render on\n * properties you actually read\" behavior.\n */\n trackResult(\n result: QueryObserverResult<TData, TError>,\n onPropTracked?: (key: keyof QueryObserverResult) => void,\n ): QueryObserverResult<TData, TError> {\n return new Proxy(result, {\n get: (target, key) => {\n this.trackProp(key as keyof QueryObserverResult)\n onPropTracked?.(key as keyof QueryObserverResult)\n return Reflect.get(target, key)\n },\n })\n }\n\n /**\n * Records that the given `QueryObserverResult` property was read, so a subsequent update only\n * notifies this observer if a tracked property actually changed. Normally called indirectly via\n * {@link QueryObserver#trackResult}'s proxy; exposed directly for adapters that track property\n * access themselves (e.g. through their own reactivity system) instead of via the proxy.\n */\n trackProp(key: keyof QueryObserverResult) {\n this.#trackedProps.add(key)\n }\n\n /**\n * Returns the `Query` instance this observer is currently observing.\n */\n getCurrentQuery(): Query<TQueryFnData, TError, TQueryData, TQueryKey> {\n return this.#currentQuery\n }\n\n /**\n * Refetches the observed query and returns a promise that resolves with\n * the resulting `QueryObserverResult`.\n *\n * @example\n * ```ts\n * const result = await observer.refetch({ cancelRefetch: false })\n * console.log(result.data)\n * ```\n */\n refetch({ ...options }: RefetchOptions = {}): Promise<\n QueryObserverResult<TData, TError>\n > {\n return this.fetch({\n ...options,\n })\n }\n\n /**\n * Fetches a query defined by the given options without affecting this\n * observer's own tracked query or result, and returns a promise that\n * resolves with the `QueryObserverResult` for that fetch. This is useful\n * for prefetching data that another observer (e.g. a query about to be\n * navigated to) will need, ahead of time.\n *\n * @example\n * ```ts\n * const result = await observer.fetchOptimistic({\n * queryKey: ['posts', 2],\n * queryFn: () => fetchPost(2),\n * })\n * console.log(result.data)\n * ```\n */\n fetchOptimistic(\n options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): Promise<QueryObserverResult<TData, TError>> {\n const defaultedOptions = this.#client.defaultQueryOptions(options)\n\n const query = this.#client\n .getQueryCache()\n .build(this.#client, defaultedOptions)\n\n let unsubscribe = () => {}\n let resolveEarly:\n ((result: QueryObserverResult<TData, TError>) => void) | undefined\n\n const cachePromise = new Promise<QueryObserverResult<TData, TError>>(\n (resolve) => {\n resolveEarly = resolve\n unsubscribe = this.#client.getQueryCache().subscribe((event) => {\n if (\n event.type === 'updated' &&\n event.query.queryHash === query.queryHash &&\n query.state.data !== undefined\n ) {\n unsubscribe()\n resolve(this.createResult(query, defaultedOptions))\n }\n })\n },\n )\n\n return Promise.race([\n query\n .fetch()\n .then(() => {\n const result = this.createResult(query, defaultedOptions)\n // Settle the subscriber promise so both branches always settle.\n // This value is ignored by Promise.race since the fetch branch already won.\n resolveEarly?.(result)\n return result\n })\n .finally(() => {\n unsubscribe()\n }),\n cachePromise,\n ])\n }\n\n protected fetch(\n fetchOptions: ObserverFetchOptions,\n ): Promise<QueryObserverResult<TData, TError>> {\n return this.#executeFetch({\n ...fetchOptions,\n cancelRefetch: fetchOptions.cancelRefetch ?? true,\n }).then(() => {\n this.updateResult()\n return this.#currentResult\n })\n }\n\n #executeFetch(\n fetchOptions?: Omit<ObserverFetchOptions, 'initialPromise'>,\n ): Promise<TQueryData | undefined> {\n // Make sure we reference the latest query as the current one might have been removed\n this.#updateQuery()\n\n // Fetch\n let promise: Promise<TQueryData | undefined> = this.#currentQuery.fetch(\n this.options,\n fetchOptions,\n )\n\n if (!fetchOptions?.throwOnError) {\n promise = promise.catch(noop)\n }\n\n return promise\n }\n\n #shouldScheduleTimer(timeout: unknown): timeout is number {\n return (\n !isServerEnvironment() &&\n resolveQueryValue(this.options.enabled, this.#currentQuery) !== false &&\n isValidTimeout(timeout)\n )\n }\n\n #updateStaleTimeout(): void {\n this.#clearStaleTimeout()\n const staleTime = resolveQueryValue(\n this.options.staleTime,\n this.#currentQuery,\n )\n\n if (this.#currentResult.isStale || !this.#shouldScheduleTimer(staleTime)) {\n return\n }\n\n const time = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime)\n\n // The timeout is sometimes triggered 1 ms before the stale time expiration.\n // To mitigate this issue we always add 1 ms to the timeout.\n const timeout = time + 1\n\n this.#staleTimeoutId = timeoutManager.setTimeout(() => {\n if (!this.#currentResult.isStale) {\n this.updateResult()\n }\n }, timeout)\n }\n\n #computeRefetchInterval() {\n return (\n resolveQueryValue(this.options.refetchInterval, this.#currentQuery) ??\n false\n )\n }\n\n #updateRefetchInterval(nextInterval: number | false): void {\n this.#clearRefetchInterval()\n\n this.#currentRefetchInterval = nextInterval\n\n if (\n this.#currentRefetchInterval === 0 ||\n !this.#shouldScheduleTimer(this.#currentRefetchInterval)\n ) {\n return\n }\n\n this.#refetchIntervalId = timeoutManager.setInterval(() => {\n if (\n this.options.refetchIntervalInBackground ||\n focusManager.isFocused()\n ) {\n this.#executeFetch()\n }\n }, this.#currentRefetchInterval)\n }\n\n #updateTimers(): void {\n this.#updateStaleTimeout()\n this.#updateRefetchInterval(this.#computeRefetchInterval())\n }\n\n #clearStaleTimeout(): void {\n if (this.#staleTimeoutId !== undefined) {\n timeoutManager.clearTimeout(this.#staleTimeoutId)\n this.#staleTimeoutId = undefined\n }\n }\n\n #clearRefetchInterval(): void {\n if (this.#refetchIntervalId !== undefined) {\n timeoutManager.clearInterval(this.#refetchIntervalId)\n this.#refetchIntervalId = undefined\n }\n }\n\n protected createResult(\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): QueryObserverResult<TData, TError> {\n const prevQuery = this.#currentQuery\n const prevOptions = this.options\n const prevResult = this.#currentResult as\n QueryObserverResult<TData, TError> | undefined\n const prevResultState = this.#currentResultState\n const prevResultOptions = this.#currentResultOptions\n const queryChange = query !== prevQuery\n const queryInitialState = queryChange\n ? query.state\n : this.#currentQueryInitialState\n\n const { state } = query\n let newState = { ...state }\n let isPlaceholderData = false\n let data: TData | undefined\n\n // Optimistically set result in fetching state if needed\n if (options._optimisticResults) {\n const mounted = this.hasListeners()\n\n const fetchOnMount = !mounted && shouldFetchOnMount(query, options)\n\n const fetchOptionally =\n mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions)\n\n if (fetchOnMount || fetchOptionally) {\n newState = {\n ...newState,\n ...fetchState(state.data, query.options),\n }\n }\n if (options._optimisticResults === 'isRestoring') {\n newState.fetchStatus = 'idle'\n }\n }\n\n let { error, errorUpdatedAt, status } = newState\n\n // Per default, use query data\n data = newState.data as unknown as TData\n let skipSelect = false\n\n // use placeholderData if needed\n if (\n options.placeholderData !== undefined &&\n data === undefined &&\n status === 'pending'\n ) {\n let placeholderData\n\n // Memoize placeholder data\n if (\n prevResult?.isPlaceholderData &&\n options.placeholderData === prevResultOptions?.placeholderData\n ) {\n placeholderData = prevResult.data\n // we have to skip select when reading this memoization\n // because prevResult.data is already \"selected\"\n skipSelect = true\n } else {\n // compute placeholderData\n placeholderData =\n typeof options.placeholderData === 'function'\n ? (\n options.placeholderData as unknown as PlaceholderDataFunction<TQueryData>\n )(\n this.#lastQueryWithDefinedData?.state.data,\n this.#lastQueryWithDefinedData as any,\n )\n : options.placeholderData\n }\n\n if (placeholderData !== undefined) {\n status = 'success'\n data = replaceData(\n prevResult?.data,\n placeholderData as unknown,\n options,\n ) as TData\n isPlaceholderData = true\n }\n }\n\n // Select data if needed\n // this also runs placeholderData through the select function\n if (options.select && data !== undefined && !skipSelect) {\n // Memoize select result\n if (\n prevResult &&\n data === prevResultState?.data &&\n options.select === this.#selectFn\n ) {\n data = this.#selectResult\n } else {\n try {\n this.#selectFn = options.select\n data = options.select(data as any)\n data = replaceData(prevResult?.data, data, options)\n this.#selectResult = data\n this.#selectError = null\n } catch (selectError) {\n this.#selectError = selectError as TError\n }\n }\n } else if (data === undefined) {\n // a stored select error belongs to previously selected data; once that\n // data is gone (query switch or reset), it must not leak into this result\n this.#selectError = null\n }\n\n if (this.#selectError) {\n error = this.#selectError\n data = this.#selectResult\n errorUpdatedAt = Date.now()\n status = 'error'\n isPlaceholderData = false\n }\n\n const isFetching = newState.fetchStatus === 'fetching'\n const isPending = status === 'pending'\n const isError = status === 'error'\n\n const isLoading = isPending && isFetching\n const hasData = data !== undefined\n\n const result: QueryObserverBaseResult<TData, TError> = {\n status,\n fetchStatus: newState.fetchStatus,\n isPending,\n isSuccess: status === 'success',\n isError,\n isInitialLoading: isLoading,\n isLoading,\n data,\n dataUpdatedAt: newState.dataUpdatedAt,\n error,\n errorUpdatedAt,\n failureCount: newState.fetchFailureCount,\n failureReason: newState.fetchFailureReason,\n errorUpdateCount: newState.errorUpdateCount,\n isFetched: query.isFetched(),\n isFetchedAfterMount:\n newState.dataUpdateCount > queryInitialState.dataUpdateCount ||\n newState.errorUpdateCount > queryInitialState.errorUpdateCount,\n isFetching,\n isRefetching: isFetching && !isPending,\n isLoadingError: isError && !hasData,\n isPaused: newState.fetchStatus === 'paused',\n isPlaceholderData,\n isRefetchError: isError && hasData,\n isStale: isStale(query, options),\n refetch: this.refetch,\n isEnabled: resolveQueryValue(options.enabled, query) !== false,\n }\n\n const nextResult = result as QueryObserverResult<TData, TError>\n\n return nextResult\n }\n\n /**\n * Recomputes and stores the current result from the current query/options, notifying listeners\n * if it changed. Framework adapters call this right after subscribing to make sure no query\n * update was missed in the gap between creating the observer and subscribing to it.\n */\n updateResult(): void {\n const prevResult = this.#currentResult as\n QueryObserverResult<TData, TError> | undefined\n\n const nextResult = this.createResult(this.#currentQuery, this.options)\n\n this.#currentResultState = this.#currentQuery.state\n this.#currentResultOptions = this.options\n\n if (this.#currentResultState.data !== undefined) {\n this.#lastQueryWithDefinedData = this.#currentQuery\n }\n\n // Only notify and update result if something has changed\n if (shallowEqualObjects(nextResult, prevResult)) {\n return\n }\n\n this.#currentResult = nextResult\n\n const shouldNotifyListeners = (): boolean => {\n if (!prevResult) {\n return true\n }\n\n const { notifyOnChangeProps } = this.options\n const notifyOnChangePropsValue =\n typeof notifyOnChangeProps === 'function'\n ? notifyOnChangeProps()\n : notifyOnChangeProps\n\n if (\n notifyOnChangePropsValue === 'all' ||\n (!notifyOnChangePropsValue && !this.#trackedProps.size)\n ) {\n return true\n }\n\n const includedProps = new Set(\n notifyOnChangePropsValue ?? this.#trackedProps,\n )\n\n if (this.options.throwOnError) {\n includedProps.add('error')\n }\n\n return Object.keys(this.#currentResult).some((key) => {\n const typedKey = key as keyof QueryObserverResult\n const changed = this.#currentResult[typedKey] !== prevResult[typedKey]\n\n return changed && includedProps.has(typedKey)\n })\n }\n\n const notifyListeners = shouldNotifyListeners()\n\n notifyManager.batch(() => {\n // First, trigger the listeners\n if (notifyListeners) {\n this.listeners.forEach((listener) => {\n listener(this.#currentResult)\n })\n }\n\n // Then the cache listeners\n this.#client.getQueryCache().notify({\n query: this.#currentQuery,\n type: 'observerResultsUpdated',\n })\n })\n }\n\n #updateQuery(): void {\n const query = this.#client.getQueryCache().build(this.#client, this.options)\n\n if (query === this.#currentQuery) {\n return\n }\n\n const prevQuery = this.#currentQuery as\n Query<TQueryFnData, TError, TQueryData, TQueryKey> | undefined\n this.#currentQuery = query\n this.#currentQueryInitialState = query.state\n\n if (this.hasListeners()) {\n prevQuery?.removeObserver(this)\n query.addObserver(this)\n }\n }\n\n /** @internal */\n onQueryUpdate(): void {\n this.updateResult()\n\n if (this.hasListeners()) {\n this.#updateTimers()\n }\n }\n}\n\nfunction shouldLoadOnMount(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any>,\n): boolean {\n return (\n resolveQueryValue(options.enabled, query) !== false &&\n query.state.data === undefined &&\n !(\n query.state.status === 'error' &&\n resolveQueryValue(options.retryOnMount, query) === false\n )\n )\n}\n\nfunction shouldFetchOnMount(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n): boolean {\n return (\n shouldLoadOnMount(query, options) ||\n (query.state.data !== undefined &&\n shouldFetchOn(query, options, options.refetchOnMount))\n )\n}\n\nfunction shouldFetchOn(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n field: (typeof options)['refetchOnMount'] &\n (typeof options)['refetchOnWindowFocus'] &\n (typeof options)['refetchOnReconnect'],\n) {\n if (\n resolveQueryValue(options.enabled, query) !== false &&\n resolveQueryValue(options.staleTime, query) !== 'static'\n ) {\n const value = resolveQueryValue(field, query)\n\n return value === 'always' || (value !== false && isStale(query, options))\n }\n return false\n}\n\nfunction shouldFetchOptionally(\n query: Query<any, any, any, any>,\n prevQuery: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n prevOptions: QueryObserverOptions<any, any, any, any, any>,\n): boolean {\n return (\n (query !== prevQuery ||\n resolveQueryValue(prevOptions.enabled, query) === false) &&\n (!options.suspense || query.state.status !== 'error') &&\n isStale(query, options)\n )\n}\n\nfunction isStale(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n): boolean {\n return (\n resolveQueryValue(options.enabled, query) !== false &&\n query.isStaleByTime(resolveQueryValue(options.staleTime, query))\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,IAAa,gBAAb,cAMU,aAAmD;CAwB3D,YACE,QACA,S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9B,MAAM,YAAY,IAAI;CACxB;AACF;AAYF,SAAS,kBACP,OACA,SACS;CACT,OACE,kBAAkB,QAAQ,SAAS,KAAK,MAAM,SAC9C,MAAM,MAAM,SAAS,KAAA,KACrB,EACE,MAAM,MAAM,WAAW,WACvB,kBAAkB,QAAQ,cAAc,KAAK,MAAM;AAGzD;AAEA,SAAS,mBACP,OACA,SACS;CACT,OACE,kBAAkB,OAAO,OAAO,KAC/B,MAAM,MAAM,SAAS,KAAA,KACpB,cAAc,OAAO,SAAS,QAAQ,cAAc;AAE1D;AAEA,SAAS,cACP,OACA,SACA,OAGA;CACA,IACE,kBAAkB,QAAQ,SAAS,KAAK,MAAM,SAC9C,kBAAkB,QAAQ,WAAW,KAAK,MAAM,UAChD;EACA,MAAM,QAAQ,kBAAkB,OAAO,KAAK;EAE5C,OAAO,UAAU,YAAa,UAAU,SAAS,QAAQ,OAAO,OAAO;CACzE;CACA,OAAO;AACT;AAEA,SAAS,sBACP,OACA,WACA,SACA,aACS;CACT,QACG,UAAU,aACT,kBAAkB,YAAY,SAAS,KAAK,MAAM,WACnD,CAAC,QAAQ,YAAY,MAAM,MAAM,WAAW,YAC7C,QAAQ,OAAO,OAAO;AAE1B;AAEA,SAAS,QACP,OACA,SACS;CACT,OACE,kBAAkB,QAAQ,SAAS,KAAK,MAAM,SAC9C,MAAM,cAAc,kBAAkB,QAAQ,WAAW,KAAK,CAAC;AAEnE"}
1
+ {"version":3,"file":"queryObserver.js","names":["isServerEnvironment"],"sources":["../../src/queryObserver.ts"],"sourcesContent":["import { focusManager } from './focusManager'\nimport { isServer as isServerEnvironment } from './environmentManager'\nimport { notifyManager } from './notifyManager'\nimport { fetchState } from './query'\nimport { Subscribable } from './subscribable'\nimport {\n isValidTimeout,\n noop,\n replaceData,\n resolveQueryValue,\n shallowEqualObjects,\n timeUntilStale,\n} from './utils'\nimport { timeoutManager } from './timeoutManager'\nimport type { ManagedTimerId } from './timeoutManager'\nimport type { FetchOptions, Query, QueryState } from './query'\nimport type { QueryClient } from './queryClient'\nimport type {\n DefaultError,\n DefaultedQueryObserverOptions,\n PlaceholderDataFunction,\n QueryKey,\n QueryObserverBaseResult,\n QueryObserverOptions,\n QueryObserverResult,\n RefetchOptions,\n} from './types'\n\ntype QueryObserverListener<TData, TError> = (\n result: QueryObserverResult<TData, TError>,\n) => void\n\ninterface ObserverFetchOptions extends FetchOptions {\n throwOnError?: boolean\n}\n\n/**\n * A `QueryObserver` watches a single query in the `QueryCache` and computes a\n * `QueryObserverResult` from its state, recomputing and notifying subscribers\n * whenever the underlying query (or the observer's options) changes. It is\n * the primitive that framework adapters (e.g. `useQuery`) build their hooks\n * on top of, but it can also be used directly to observe and switch between\n * queries outside of any framework.\n * @example\n * ```ts\n * const observer = new QueryObserver(queryClient, {\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n *\n * const unsubscribe = observer.subscribe((result) => {\n * console.log(result.data)\n * })\n * ```\n */\nexport class QueryObserver<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> extends Subscribable<QueryObserverListener<TData, TError>> {\n #client: QueryClient\n #currentQuery: Query<TQueryFnData, TError, TQueryData, TQueryKey> = undefined!\n #currentQueryInitialState: QueryState<TQueryData, TError> = undefined!\n #currentResult: QueryObserverResult<TData, TError> = undefined!\n #currentResultState?: QueryState<TQueryData, TError>\n #currentResultOptions?: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >\n #selectError: TError | null\n #selectFn?: (data: TQueryData) => TData\n #selectResult?: TData\n // This property keeps track of the last query with defined data.\n // It will be used to pass the previous data and query to the placeholder function between renders.\n #lastQueryWithDefinedData?: Query<TQueryFnData, TError, TQueryData, TQueryKey>\n #staleTimeoutId?: ManagedTimerId\n #refetchIntervalId?: ManagedTimerId\n #currentRefetchInterval?: number | false\n #trackedProps = new Set<keyof QueryObserverResult>()\n\n constructor(\n client: QueryClient,\n public options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ) {\n super()\n\n this.#client = client\n this.#selectError = null\n\n this.bindMethods()\n this.setOptions(options)\n }\n\n /**\n * Binds the methods of the result (`refetch`) to the observer, so they keep working when destructured\n * from it. Subclasses override it to bind their own result methods as well.\n */\n protected bindMethods(): void {\n this.refetch = this.refetch.bind(this)\n }\n\n protected override onSubscribe(): void {\n if (this.listeners.size === 1) {\n this.#currentQuery.addObserver(this)\n\n if (shouldFetchOnMount(this.#currentQuery, this.options)) {\n this.#executeFetch()\n } else {\n this.updateResult()\n }\n\n this.#updateTimers()\n }\n }\n\n protected override onUnsubscribe(): void {\n if (!this.hasListeners()) {\n this.destroy()\n }\n }\n\n /**\n * Returns whether the observed query is currently stale and configured\n * (via the `refetchOnReconnect` option) to refetch when the network\n * reconnects.\n * @returns `true` if the observer should refetch the query on reconnect.\n */\n shouldFetchOnReconnect(): boolean {\n return shouldFetchOn(\n this.#currentQuery,\n this.options,\n this.options.refetchOnReconnect,\n )\n }\n\n /**\n * Returns whether the observed query is currently stale and configured\n * (via the `refetchOnWindowFocus` option) to refetch when the window\n * regains focus.\n * @returns `true` if the observer should refetch the query on window focus.\n */\n shouldFetchOnWindowFocus(): boolean {\n return shouldFetchOn(\n this.#currentQuery,\n this.options,\n this.options.refetchOnWindowFocus,\n )\n }\n\n /**\n * Stops observing the current query: clears all listeners, cancels the\n * stale and refetch-interval timers, and removes this observer from the\n * query it was observing.\n */\n destroy(): void {\n this.listeners = new Set()\n this.#clearStaleTimeout()\n this.#clearRefetchInterval()\n this.#currentQuery.removeObserver(this)\n }\n\n /**\n * Updates the observer's options. This will re-resolve the query being\n * observed (switching to a different query if the `queryKey` changed),\n * trigger a fetch if the new options require one and the observer has\n * subscribers, recompute the current result, and reschedule the stale and\n * refetch-interval timers as needed.\n * @param options - The new observer options. They are defaulted with {@link\n * QueryClient#defaultQueryOptions} before being applied.\n * @throws {Error} If `enabled` is neither a boolean nor a function.\n * @example\n * ```ts\n * observer.setOptions({ queryKey: ['posts', 1], queryFn: () => fetchPost(1) })\n * // later: switch to a different query, reusing the same observer\n * observer.setOptions({ queryKey: ['posts', 2], queryFn: () => fetchPost(2) })\n * ```\n */\n setOptions(\n options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): void {\n const prevOptions = this.options\n const prevQuery = this.#currentQuery\n\n this.options = this.#client.defaultQueryOptions(options)\n\n if (\n this.options.enabled !== undefined &&\n typeof this.options.enabled !== 'boolean' &&\n typeof this.options.enabled !== 'function' &&\n typeof resolveQueryValue(this.options.enabled, this.#currentQuery) !==\n 'boolean'\n ) {\n throw new Error(\n 'Expected enabled to be a boolean or a callback that returns a boolean',\n )\n }\n\n this.#updateQuery()\n this.#currentQuery.setOptions(this.options)\n\n if (\n prevOptions._defaulted &&\n !shallowEqualObjects(this.options, prevOptions)\n ) {\n this.#client.getQueryCache().notify({\n type: 'observerOptionsUpdated',\n query: this.#currentQuery,\n observer: this,\n })\n }\n\n const mounted = this.hasListeners()\n\n // Fetch if there are subscribers\n if (\n mounted &&\n shouldFetchOptionally(\n this.#currentQuery,\n prevQuery,\n this.options,\n prevOptions,\n )\n ) {\n this.#executeFetch()\n }\n\n // Update result\n this.updateResult()\n\n // Update stale interval if needed\n if (\n mounted &&\n (this.#currentQuery !== prevQuery ||\n resolveQueryValue(this.options.enabled, this.#currentQuery) !==\n resolveQueryValue(prevOptions.enabled, this.#currentQuery) ||\n resolveQueryValue(this.options.staleTime, this.#currentQuery) !==\n resolveQueryValue(prevOptions.staleTime, this.#currentQuery))\n ) {\n this.#updateStaleTimeout()\n }\n\n const nextRefetchInterval = this.#computeRefetchInterval()\n\n // Update refetch interval if needed\n if (\n mounted &&\n (this.#currentQuery !== prevQuery ||\n resolveQueryValue(this.options.enabled, this.#currentQuery) !==\n resolveQueryValue(prevOptions.enabled, this.#currentQuery) ||\n nextRefetchInterval !== this.#currentRefetchInterval)\n ) {\n this.#updateRefetchInterval(nextRefetchInterval)\n }\n }\n\n /**\n * Computes the result the observer would produce for the given (already-defaulted) options\n * right now, building the underlying `Query` if it doesn't exist yet, without waiting for a\n * subscription callback. Called by framework adapters on every render (e.g. `useQuery`) so the\n * returned value is available synchronously, ahead of `setOptions` triggering an actual fetch.\n * @param options - The defaulted observer options to compute the result for.\n * @returns The result for the given options.\n */\n getOptimisticResult(\n options: DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): QueryObserverResult<TData, TError> {\n const query = this.#client.getQueryCache().build(this.#client, options)\n\n const result = this.createResult(query, options)\n\n if (!shallowEqualObjects(this.getCurrentResult(), result)) {\n // this assigns the optimistic result to the current Observer\n // because if the query function changes, useQuery will be performing\n // an effect where it would fetch again.\n // When the fetch finishes, we perform a deep data cloning in order\n // to reuse objects references. This deep data clone is performed against\n // the `observer.currentResult.data` property\n // When QueryKey changes, we refresh the query and get new `optimistic`\n // result, while we leave the `observer.currentResult`, so when new data\n // arrives, it finds the old `observer.currentResult` which is related\n // to the old QueryKey. Which means that currentResult and selectData are\n // out of sync already.\n // To solve this, we move the cursor of the currentResult every time\n // an observer reads an optimistic value.\n\n // When keeping the previous data, the result doesn't change until new\n // data arrives.\n this.#currentResult = result\n this.#currentResultOptions = this.options\n this.#currentResultState = this.#currentQuery.state\n }\n return result\n }\n\n /**\n * Returns the most recently computed `QueryObserverResult` for the\n * observed query. This is a point-in-time read; to be notified of updates\n * as they happen, subscribe to the observer instead (its inherited\n * `subscribe` method).\n * @returns The observer's latest result.\n * @example\n * ```ts\n * const result = observer.getCurrentResult()\n * console.log(result.status, result.data)\n * ```\n */\n getCurrentResult(): QueryObserverResult<TData, TError> {\n return this.#currentResult\n }\n\n /**\n * Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via\n * {@link QueryObserver#trackProp} (and an optional `onPropTracked` callback). Used by framework\n * adapters when `notifyOnChangeProps` is not set, to implement its default \"only re-render on\n * properties you actually read\" behavior.\n * @param result - The result to wrap.\n * @param onPropTracked - Called with the name of each property that is read.\n * @returns A proxy of `result` that tracks property reads.\n */\n trackResult(\n result: QueryObserverResult<TData, TError>,\n onPropTracked?: (key: keyof QueryObserverResult) => void,\n ): QueryObserverResult<TData, TError> {\n return new Proxy(result, {\n get: (target, key) => {\n this.trackProp(key as keyof QueryObserverResult)\n onPropTracked?.(key as keyof QueryObserverResult)\n return Reflect.get(target, key)\n },\n })\n }\n\n /**\n * Records that the given `QueryObserverResult` property was read, so a subsequent update only\n * notifies this observer if a tracked property actually changed. Normally called indirectly via\n * {@link QueryObserver#trackResult}'s proxy; exposed directly for adapters that track property\n * access themselves (e.g. through their own reactivity system) instead of via the proxy.\n * @param key - The name of the property that was read.\n */\n trackProp(key: keyof QueryObserverResult) {\n this.#trackedProps.add(key)\n }\n\n /**\n * Returns the `Query` instance this observer is currently observing.\n * @returns The observed query.\n */\n getCurrentQuery(): Query<TQueryFnData, TError, TQueryData, TQueryKey> {\n return this.#currentQuery\n }\n\n /**\n * Refetches the observed query and returns a promise that resolves with\n * the resulting `QueryObserverResult`.\n * @param options - Set `cancelRefetch` to `false` to keep a running fetch instead of cancelling\n * it, and `throwOnError` to `true` to reject when the refetch fails.\n * @returns A promise that resolves with the result after the refetch.\n * @example\n * ```ts\n * const result = await observer.refetch({ cancelRefetch: false })\n * console.log(result.data)\n * ```\n */\n refetch({ ...options }: RefetchOptions = {}): Promise<\n QueryObserverResult<TData, TError>\n > {\n return this.fetch({\n ...options,\n })\n }\n\n /**\n * Fetches a query defined by the given options without affecting this\n * observer's own tracked query or result, and returns a promise that\n * resolves with the `QueryObserverResult` for that fetch. This is useful\n * for prefetching data that another observer (e.g. a query about to be\n * navigated to) will need, ahead of time.\n * @param options - The observer options of the query to fetch.\n * @returns A promise that resolves with the result for the fetched query.\n * @example\n * ```ts\n * const result = await observer.fetchOptimistic({\n * queryKey: ['posts', 2],\n * queryFn: () => fetchPost(2),\n * })\n * console.log(result.data)\n * ```\n */\n fetchOptimistic(\n options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): Promise<QueryObserverResult<TData, TError>> {\n const defaultedOptions = this.#client.defaultQueryOptions(options)\n\n const query = this.#client\n .getQueryCache()\n .build(this.#client, defaultedOptions)\n\n let unsubscribe = () => {}\n let resolveEarly:\n | ((result: QueryObserverResult<TData, TError>) => void)\n | undefined\n\n const cachePromise = new Promise<QueryObserverResult<TData, TError>>(\n (resolve) => {\n resolveEarly = resolve\n unsubscribe = this.#client.getQueryCache().subscribe((event) => {\n if (\n event.type === 'updated' &&\n event.query.queryHash === query.queryHash &&\n query.state.data !== undefined\n ) {\n unsubscribe()\n resolve(this.createResult(query, defaultedOptions))\n }\n })\n },\n )\n\n return Promise.race([\n query\n .fetch()\n .then(() => {\n const result = this.createResult(query, defaultedOptions)\n // Settle the subscriber promise so both branches always settle.\n // This value is ignored by Promise.race since the fetch branch already won.\n resolveEarly?.(result)\n return result\n })\n .finally(() => {\n unsubscribe()\n }),\n cachePromise,\n ])\n }\n\n /**\n * Fetches the observed query and updates the result once the fetch settles. Used by `refetch` and,\n * in `InfiniteQueryObserver`, to fetch more pages.\n * @param fetchOptions - Options for this fetch. `cancelRefetch` defaults to `true`.\n * @returns A promise that resolves with the updated result.\n */\n protected fetch(\n fetchOptions: ObserverFetchOptions,\n ): Promise<QueryObserverResult<TData, TError>> {\n return this.#executeFetch({\n ...fetchOptions,\n cancelRefetch: fetchOptions.cancelRefetch ?? true,\n }).then(() => {\n this.updateResult()\n return this.#currentResult\n })\n }\n\n #executeFetch(\n fetchOptions?: Omit<ObserverFetchOptions, 'initialPromise'>,\n ): Promise<TQueryData | undefined> {\n // Make sure we reference the latest query as the current one might have been removed\n this.#updateQuery()\n\n // Fetch\n let promise: Promise<TQueryData | undefined> = this.#currentQuery.fetch(\n this.options,\n fetchOptions,\n )\n\n if (!fetchOptions?.throwOnError) {\n promise = promise.catch(noop)\n }\n\n return promise\n }\n\n #shouldScheduleTimer(timeout: unknown): timeout is number {\n return (\n !isServerEnvironment() &&\n resolveQueryValue(this.options.enabled, this.#currentQuery) !== false &&\n isValidTimeout(timeout)\n )\n }\n\n #updateStaleTimeout(): void {\n this.#clearStaleTimeout()\n const staleTime = resolveQueryValue(\n this.options.staleTime,\n this.#currentQuery,\n )\n\n if (this.#currentResult.isStale || !this.#shouldScheduleTimer(staleTime)) {\n return\n }\n\n const time = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime)\n\n // The timeout is sometimes triggered 1 ms before the stale time expiration.\n // To mitigate this issue we always add 1 ms to the timeout.\n const timeout = time + 1\n\n this.#staleTimeoutId = timeoutManager.setTimeout(() => {\n if (!this.#currentResult.isStale) {\n this.updateResult()\n }\n }, timeout)\n }\n\n #computeRefetchInterval() {\n return (\n resolveQueryValue(this.options.refetchInterval, this.#currentQuery) ??\n false\n )\n }\n\n #updateRefetchInterval(nextInterval: number | false): void {\n this.#clearRefetchInterval()\n\n this.#currentRefetchInterval = nextInterval\n\n if (\n this.#currentRefetchInterval === 0 ||\n !this.#shouldScheduleTimer(this.#currentRefetchInterval)\n ) {\n return\n }\n\n this.#refetchIntervalId = timeoutManager.setInterval(() => {\n if (\n this.options.refetchIntervalInBackground ||\n focusManager.isFocused()\n ) {\n this.#executeFetch()\n }\n }, this.#currentRefetchInterval)\n }\n\n #updateTimers(): void {\n this.#updateStaleTimeout()\n this.#updateRefetchInterval(this.#computeRefetchInterval())\n }\n\n #clearStaleTimeout(): void {\n if (this.#staleTimeoutId !== undefined) {\n timeoutManager.clearTimeout(this.#staleTimeoutId)\n this.#staleTimeoutId = undefined\n }\n }\n\n #clearRefetchInterval(): void {\n if (this.#refetchIntervalId !== undefined) {\n timeoutManager.clearInterval(this.#refetchIntervalId)\n this.#refetchIntervalId = undefined\n }\n }\n\n /**\n * Computes the result for a query and options from the query's state, applying `select`,\n * `placeholderData`, and the derived flags. Subclasses override it to add their own fields.\n * @param query - The query to compute the result for.\n * @param options - The observer options to compute the result with.\n * @returns The computed result.\n */\n protected createResult(\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): QueryObserverResult<TData, TError> {\n const prevQuery = this.#currentQuery\n const prevOptions = this.options\n const prevResult = this.#currentResult as\n | QueryObserverResult<TData, TError>\n | undefined\n const prevResultState = this.#currentResultState\n const prevResultOptions = this.#currentResultOptions\n const queryChange = query !== prevQuery\n const queryInitialState = queryChange\n ? query.state\n : this.#currentQueryInitialState\n\n const { state } = query\n let newState = { ...state }\n let isPlaceholderData = false\n let data: TData | undefined\n\n // Optimistically set result in fetching state if needed\n if (options._optimisticResults) {\n const mounted = this.hasListeners()\n\n const fetchOnMount = !mounted && shouldFetchOnMount(query, options)\n\n const fetchOptionally =\n mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions)\n\n if (fetchOnMount || fetchOptionally) {\n newState = {\n ...newState,\n ...fetchState(state.data, query.options),\n }\n }\n if (options._optimisticResults === 'isRestoring') {\n newState.fetchStatus = 'idle'\n }\n }\n\n let { error, errorUpdatedAt, status } = newState\n\n // Per default, use query data\n data = newState.data as unknown as TData\n let skipSelect = false\n\n // use placeholderData if needed\n if (\n options.placeholderData !== undefined &&\n data === undefined &&\n status === 'pending'\n ) {\n let placeholderData\n\n // Memoize placeholder data\n if (\n prevResult?.isPlaceholderData &&\n options.placeholderData === prevResultOptions?.placeholderData\n ) {\n placeholderData = prevResult.data\n // we have to skip select when reading this memoization\n // because prevResult.data is already \"selected\"\n skipSelect = true\n } else {\n // compute placeholderData\n placeholderData =\n typeof options.placeholderData === 'function'\n ? (\n options.placeholderData as unknown as PlaceholderDataFunction<TQueryData>\n )(\n this.#lastQueryWithDefinedData?.state.data,\n this.#lastQueryWithDefinedData as any,\n )\n : options.placeholderData\n }\n\n if (placeholderData !== undefined) {\n status = 'success'\n data = replaceData(\n prevResult?.data,\n placeholderData as unknown,\n options,\n ) as TData\n isPlaceholderData = true\n }\n }\n\n // Select data if needed\n // this also runs placeholderData through the select function\n if (options.select && data !== undefined && !skipSelect) {\n // Memoize select result\n if (\n prevResult &&\n data === prevResultState?.data &&\n options.select === this.#selectFn\n ) {\n data = this.#selectResult\n } else {\n try {\n this.#selectFn = options.select\n data = options.select(data as any)\n data = replaceData(prevResult?.data, data, options)\n this.#selectResult = data\n this.#selectError = null\n } catch (selectError) {\n this.#selectError = selectError as TError\n }\n }\n } else if (data === undefined) {\n // a stored select error belongs to previously selected data; once that\n // data is gone (query switch or reset), it must not leak into this result\n this.#selectError = null\n }\n\n if (this.#selectError) {\n error = this.#selectError\n data = this.#selectResult\n errorUpdatedAt = Date.now()\n status = 'error'\n isPlaceholderData = false\n }\n\n const isFetching = newState.fetchStatus === 'fetching'\n const isPending = status === 'pending'\n const isError = status === 'error'\n\n const isLoading = isPending && isFetching\n const hasData = data !== undefined\n\n const result: QueryObserverBaseResult<TData, TError> = {\n status,\n fetchStatus: newState.fetchStatus,\n isPending,\n isSuccess: status === 'success',\n isError,\n isInitialLoading: isLoading,\n isLoading,\n data,\n dataUpdatedAt: newState.dataUpdatedAt,\n error,\n errorUpdatedAt,\n failureCount: newState.fetchFailureCount,\n failureReason: newState.fetchFailureReason,\n errorUpdateCount: newState.errorUpdateCount,\n isFetched: query.isFetched(),\n isFetchedAfterMount:\n newState.dataUpdateCount > queryInitialState.dataUpdateCount ||\n newState.errorUpdateCount > queryInitialState.errorUpdateCount,\n isFetching,\n isRefetching: isFetching && !isPending,\n isLoadingError: isError && !hasData,\n isPaused: newState.fetchStatus === 'paused',\n isPlaceholderData,\n isRefetchError: isError && hasData,\n isStale: isStale(query, options),\n refetch: this.refetch,\n isEnabled: resolveQueryValue(options.enabled, query) !== false,\n }\n\n const nextResult = result as QueryObserverResult<TData, TError>\n\n return nextResult\n }\n\n /**\n * Recomputes and stores the current result from the current query/options, notifying listeners\n * if it changed. Framework adapters call this right after subscribing to make sure no query\n * update was missed in the gap between creating the observer and subscribing to it.\n */\n updateResult(): void {\n const prevResult = this.#currentResult as\n | QueryObserverResult<TData, TError>\n | undefined\n\n const nextResult = this.createResult(this.#currentQuery, this.options)\n\n this.#currentResultState = this.#currentQuery.state\n this.#currentResultOptions = this.options\n\n if (this.#currentResultState.data !== undefined) {\n this.#lastQueryWithDefinedData = this.#currentQuery\n }\n\n // Only notify and update result if something has changed\n if (shallowEqualObjects(nextResult, prevResult)) {\n return\n }\n\n this.#currentResult = nextResult\n\n const shouldNotifyListeners = (): boolean => {\n if (!prevResult) {\n return true\n }\n\n const { notifyOnChangeProps } = this.options\n const notifyOnChangePropsValue =\n typeof notifyOnChangeProps === 'function'\n ? notifyOnChangeProps()\n : notifyOnChangeProps\n\n if (\n notifyOnChangePropsValue === 'all' ||\n (!notifyOnChangePropsValue && !this.#trackedProps.size)\n ) {\n return true\n }\n\n const includedProps = new Set(\n notifyOnChangePropsValue ?? this.#trackedProps,\n )\n\n if (this.options.throwOnError) {\n includedProps.add('error')\n }\n\n return Object.keys(this.#currentResult).some((key) => {\n const typedKey = key as keyof QueryObserverResult\n const changed = this.#currentResult[typedKey] !== prevResult[typedKey]\n\n return changed && includedProps.has(typedKey)\n })\n }\n\n const notifyListeners = shouldNotifyListeners()\n\n notifyManager.batch(() => {\n // First, trigger the listeners\n if (notifyListeners) {\n this.listeners.forEach((listener) => {\n listener(this.#currentResult)\n })\n }\n\n // Then the cache listeners\n this.#client.getQueryCache().notify({\n query: this.#currentQuery,\n type: 'observerResultsUpdated',\n })\n })\n }\n\n #updateQuery(): void {\n const query = this.#client.getQueryCache().build(this.#client, this.options)\n\n if (query === this.#currentQuery) {\n return\n }\n\n const prevQuery = this.#currentQuery as\n | Query<TQueryFnData, TError, TQueryData, TQueryKey>\n | undefined\n this.#currentQuery = query\n this.#currentQueryInitialState = query.state\n\n if (this.hasListeners()) {\n prevQuery?.removeObserver(this)\n query.addObserver(this)\n }\n }\n\n /**\n * Updates the observer's result when the observed query changes, and reschedules its timers if it\n * has listeners.\n * @internal\n */\n onQueryUpdate(): void {\n this.updateResult()\n\n if (this.hasListeners()) {\n this.#updateTimers()\n }\n }\n}\n\n/**\n * Checks whether a query has no data yet and should do its initial load when an observer mounts.\n * @param query - The query to check.\n * @param options - The observer options.\n * @returns `true` if the query is enabled, has no data, and isn't in an error state with\n * `retryOnMount: false`.\n */\nfunction shouldLoadOnMount(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any>,\n): boolean {\n return (\n resolveQueryValue(options.enabled, query) !== false &&\n query.state.data === undefined &&\n !(\n query.state.status === 'error' &&\n resolveQueryValue(options.retryOnMount, query) === false\n )\n )\n}\n\n/**\n * Checks whether a query should fetch when an observer mounts: either for its initial load, or\n * because it has data and `refetchOnMount` asks for a refetch.\n * @param query - The query to check.\n * @param options - The observer options.\n * @returns `true` if the query should fetch on mount.\n */\nfunction shouldFetchOnMount(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n): boolean {\n return (\n shouldLoadOnMount(query, options) ||\n (query.state.data !== undefined &&\n shouldFetchOn(query, options, options.refetchOnMount))\n )\n}\n\n/**\n * Checks whether a query should fetch for a `refetchOnMount`, `refetchOnWindowFocus`, or\n * `refetchOnReconnect` option.\n * @param query - The query to check.\n * @param options - The observer options.\n * @param field - The value of the option to check.\n * @returns `true` if the query is enabled, not static, and the option is `'always'`, or is not\n * `false` and the query is stale.\n */\nfunction shouldFetchOn(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n field: (typeof options)['refetchOnMount'] &\n (typeof options)['refetchOnWindowFocus'] &\n (typeof options)['refetchOnReconnect'],\n) {\n if (\n resolveQueryValue(options.enabled, query) !== false &&\n resolveQueryValue(options.staleTime, query) !== 'static'\n ) {\n const value = resolveQueryValue(field, query)\n\n return value === 'always' || (value !== false && isStale(query, options))\n }\n return false\n}\n\n/**\n * Checks whether a query should fetch after the observer's options change.\n * @param query - The query observed with the new options.\n * @param prevQuery - The query observed with the previous options.\n * @param options - The new observer options.\n * @param prevOptions - The previous observer options.\n * @returns `true` if the query changed or was disabled before, it isn't a suspense query in an\n * error state, and it is stale.\n */\nfunction shouldFetchOptionally(\n query: Query<any, any, any, any>,\n prevQuery: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n prevOptions: QueryObserverOptions<any, any, any, any, any>,\n): boolean {\n return (\n (query !== prevQuery ||\n resolveQueryValue(prevOptions.enabled, query) === false) &&\n (!options.suspense || query.state.status !== 'error') &&\n isStale(query, options)\n )\n}\n\n/**\n * Checks whether a query is stale for the given observer options.\n * @param query - The query to check.\n * @param options - The observer options, whose `enabled` and `staleTime` are used.\n * @returns `true` if the query is enabled and its data is stale for `staleTime`.\n */\nfunction isStale(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n): boolean {\n return (\n resolveQueryValue(options.enabled, query) !== false &&\n query.isStaleByTime(resolveQueryValue(options.staleTime, query))\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,IAAa,gBAAb,cAMU,aAAmD;CAwB3D,YACE,QACA,SAOA;EACA,MAAM;EARC,KAAA,UAAA;;;EAxB2D,2BAAA,MAAA,eAAA,KAAA,CAAA;EACR,2BAAA,MAAA,2BAAA,KAAA,CAAA;EACP,2BAAA,MAAA,gBAAA,KAAA,CAAA;;;;;;;;;;EAkBrC,2BAAA,MAAA,+BAAA,IAAI,IAA+B,CAAA;EAcjD,uBAAA,SAAA,MAAe,MAAA;EACf,uBAAA,cAAA,MAAoB,IAAA;EAEpB,KAAK,YAAY;EACjB,KAAK,WAAW,OAAO;CACzB;;;;;CAMA,cAA8B;EAC5B,KAAK,UAAU,KAAK,QAAQ,KAAK,IAAI;CACvC;CAEA,cAAuC;EACrC,IAAI,KAAK,UAAU,SAAS,GAAG;GAC7B,uBAAA,eAAA,IAAA,CAAA,CA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