@hot-updater/console 1.0.0-rc.8 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (342) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/assets/ConsoleFeatureUnavailable-jB4Loglh.js +1 -0
  3. package/.output/public/assets/EventDetails-B6yUsyNA.js +1 -0
  4. package/.output/public/assets/HashValueDisplay-BFX_kY3-.js +1 -0
  5. package/.output/public/assets/InsightsInfo-BNO0WznZ.js +1 -0
  6. package/.output/public/assets/InsightsPageHeader-B892oVml.js +1 -0
  7. package/.output/public/assets/NotFoundPage-DIqCpWa3.js +1 -0
  8. package/.output/public/assets/alert-dialog-Bbk_4-WJ.js +1 -0
  9. package/.output/public/assets/api-DCM0wr6O.js +1 -0
  10. package/.output/public/assets/api-keys-CIO9L_wu.js +1 -0
  11. package/.output/public/assets/api-keys-DVTL_--f.js +1 -0
  12. package/.output/public/assets/arrow-left-CnMYpqB7.js +1 -0
  13. package/.output/public/assets/arrow-up-right-BtffZA6e.js +1 -0
  14. package/.output/public/assets/chevron-right-BqD5wtFb.js +1 -0
  15. package/.output/public/assets/clipboard-DS9ucUQL.js +1 -0
  16. package/.output/public/assets/console-features-api-BH5m_PtQ.js +1 -0
  17. package/.output/public/assets/dialog-Bqbb7B0N.js +1 -0
  18. package/.output/public/assets/dist-LxKJB-Vu.js +1 -0
  19. package/.output/public/assets/empty-CuT2UhFp.js +1 -0
  20. package/.output/public/assets/field-BBDpjIqu.js +1 -0
  21. package/.output/public/assets/index-6o51GkFe.js +11 -0
  22. package/.output/public/assets/input-group-ja_30qaF.js +1 -0
  23. package/.output/public/assets/insights-CmraDzQh.js +1 -0
  24. package/.output/public/assets/insights-CxZ2GCYV.js +2 -0
  25. package/.output/public/assets/insights-api-BigAU9sZ.js +1 -0
  26. package/.output/public/assets/insights-usage-rpc-DYEhsCKT.js +1 -0
  27. package/.output/public/assets/insights-vNRCrfnS.js +42 -0
  28. package/.output/public/assets/insights_.distribution-ChOerfJt.js +1 -0
  29. package/.output/public/assets/insights_.distribution-D-e4iga8.js +1 -0
  30. package/.output/public/assets/insights_.distribution-DZtkibX1.js +2 -0
  31. package/.output/public/assets/installations-BazSJXE0.js +2 -0
  32. package/.output/public/assets/installations-ClHTqdAO.js +1 -0
  33. package/.output/public/assets/installations-DpKsBuHi.js +1 -0
  34. package/.output/public/assets/key-round-wS_SIZ6b.js +1 -0
  35. package/.output/public/assets/list-CgrYiadM.js +1 -0
  36. package/.output/public/assets/refresh-cw-BYgoNCco.js +1 -0
  37. package/.output/public/assets/remote-config-BWwHOkCK.js +1 -0
  38. package/.output/public/assets/remote-config-Br56BODb.js +6 -0
  39. package/.output/public/assets/remote-config-CXOi0LRu.js +1 -0
  40. package/.output/public/assets/routes-B88Erkpk.js +2 -0
  41. package/.output/public/assets/routes-CfzsAleC.js +1 -0
  42. package/.output/public/assets/search-DaTDPW25.js +1 -0
  43. package/.output/public/assets/select-BZZBXMkr.js +1 -0
  44. package/.output/public/assets/sidebar-DNVyJPfX.js +3 -0
  45. package/.output/public/assets/smartphone-DpTFgtKf.js +1 -0
  46. package/.output/public/assets/styles-DTGEAJFv.css +2 -0
  47. package/.output/public/assets/switch-DZ1TPwx-.js +1 -0
  48. package/.output/public/assets/table-Gm4qRWwE.js +1 -0
  49. package/.output/public/assets/tabs-C7FOEjFC.js +1 -0
  50. package/.output/public/assets/undo-2-CmrHjwFc.js +1 -0
  51. package/.output/public/assets/useCompositeListItem-9E4pj_CH.js +1 -0
  52. package/.output/public/assets/valueToPercent-CH8GCHaL.js +1 -0
  53. package/.output/server/__23tanstack-start-server-fn-resolver-BpRlos5Q.mjs +170 -0
  54. package/.output/server/_libs/@base-ui/react+[...].mjs +4389 -4207
  55. package/.output/server/_libs/@tanstack/react-router+[...].mjs +3802 -4022
  56. package/.output/server/_libs/@tanstack/react-router-ssr-query+[...].mjs +140 -97
  57. package/.output/server/_libs/lucide-react.mjs +221 -9
  58. package/.output/server/_libs/next-themes.mjs +1 -1
  59. package/.output/server/_libs/react-redux+[...].mjs +1 -1
  60. package/.output/server/_libs/recharts+[...].mjs +483 -901
  61. package/.output/server/_libs/sonner.mjs +1 -1
  62. package/.output/server/_libs/tanstack__history.mjs +68 -41
  63. package/.output/server/_libs/tanstack__query-core.mjs +2010 -309
  64. package/.output/server/_libs/tanstack__react-query.mjs +448 -21
  65. package/.output/server/_libs/verkit.mjs +102 -1
  66. package/.output/server/_ssr/BundleIdDisplay-x94o9rlU.mjs +13 -0
  67. package/.output/server/_ssr/ConsoleFeatureUnavailable-ldW8v8-q.mjs +58 -0
  68. package/.output/server/_ssr/EventDetails-Q8kfj9Nr.mjs +344 -0
  69. package/.output/server/_ssr/{HashValueDisplay-C5tS4oGo.mjs → HashValueDisplay-n1GholGS.mjs} +3 -3
  70. package/.output/server/_ssr/InsightsInfo-DuJFatQO.mjs +75 -0
  71. package/.output/server/_ssr/InsightsPageHeader-BSUX3Ye9.mjs +145 -0
  72. package/.output/server/_ssr/NotFoundPage-DZzOOzS3.mjs +37 -0
  73. package/.output/server/_ssr/{dialog-WiIAKl4L.mjs → alert-dialog-C43Doa0I.mjs} +6 -83
  74. package/.output/server/_ssr/{api-keys-aXriWrv7.mjs → api-keys-B4sYm8dM.mjs} +48 -9
  75. package/.output/server/_ssr/api-keys-CEnM9fqG.mjs +5 -0
  76. package/.output/server/_ssr/api-keys-rpc-BIFuUgMt.mjs +52 -0
  77. package/.output/server/_ssr/api-oZjRn9tP.mjs +186 -0
  78. package/.output/server/_ssr/api-rpc-BNiFRRK8.mjs +240 -0
  79. package/.output/server/_ssr/{auth-BF8mbAgF.mjs → auth-UP0wXs4i.mjs} +1 -1
  80. package/.output/server/_ssr/{auth-rpc-B7w3AdRr.mjs → auth-rpc-DnZqYxyq.mjs} +6 -6
  81. package/.output/server/_ssr/auth.server-DFpyxRDd.mjs +5374 -0
  82. package/.output/server/_ssr/bundleActivity-M5gzBFNg.mjs +18 -0
  83. package/.output/server/_ssr/config-WVX4IxSR.mjs +15 -0
  84. package/.output/server/_ssr/config.server-DskXCAyI.mjs +35 -0
  85. package/.output/server/_ssr/console-access-BJfAXknd.mjs +17 -0
  86. package/.output/server/_ssr/console-features-Oz0q20jJ.mjs +61 -0
  87. package/.output/server/_ssr/console-features-api-C9kiKvaV.mjs +43 -0
  88. package/.output/server/_ssr/console-features-rpc-P0GL7Z-R.mjs +19 -0
  89. package/.output/server/_ssr/{createServerFn-B2hcXoPM.mjs → createMiddleware-Cm6Tn0_Y.mjs} +67 -56
  90. package/.output/server/_ssr/{createServerRpc-DB29C_5p.mjs → createServerRpc-RLR4H-Fn.mjs} +2 -2
  91. package/.output/server/_ssr/databaseConfig-C5SkAyUy.mjs +5 -0
  92. package/.output/server/_ssr/{databaseJsonValue-d6I3nAS4.mjs → databaseJsonValue-Csbuzc9Q.mjs} +28 -5
  93. package/.output/server/_ssr/databaseRows-CPphvbag.mjs +73 -0
  94. package/.output/server/_ssr/dialog-BbYDMjdC.mjs +84 -0
  95. package/.output/server/_ssr/{dist-CyzPaI5v.mjs → dist-CbQbBIw-.mjs} +140 -7
  96. package/.output/server/_ssr/{downloadBundle-CI7JUKvC.mjs → downloadBundle-CZysjmNW.mjs} +10 -10
  97. package/.output/server/_ssr/empty-CVLGfxuu.mjs +60 -0
  98. package/.output/server/_ssr/{empty-plugin-adapters-B5QvGpEl.mjs → empty-plugin-adapters-CPtwX8a7.mjs} +1 -1
  99. package/.output/server/_ssr/failureReports-DKDhVsXA.mjs +33 -0
  100. package/.output/server/_ssr/field-asw83X0v.mjs +189 -0
  101. package/.output/server/_ssr/getBundleChildren-Cv9iz1As.mjs +22 -0
  102. package/.output/server/_ssr/{input-group-Coj6SwVP.mjs → input-group-CuYJHosb.mjs} +2 -2
  103. package/.output/server/_ssr/insights-B55FG5fm.mjs +14 -0
  104. package/.output/server/_ssr/insights-CWnHIFUV.mjs +5 -0
  105. package/.output/server/_ssr/insights-CpLpedFZ.mjs +2315 -0
  106. package/.output/server/_ssr/insights-api-sjws23WF.mjs +122 -0
  107. package/.output/server/_ssr/insights-errors-BjnFUyZj.mjs +34 -0
  108. package/.output/server/_ssr/insights-failures-rpc-BvbWvqNf.mjs +36 -0
  109. package/.output/server/_ssr/insights-failures-xaa41Buf.mjs +46 -0
  110. package/.output/server/_ssr/insights-recovery-BWQhiZaF.mjs +28 -0
  111. package/.output/server/_ssr/insights-recovery-rpc-GiYXdkaY.mjs +32 -0
  112. package/.output/server/_ssr/{insights-rpc-l2-oBYth.mjs → insights-rpc-DP_8Rmz4.mjs} +22 -14
  113. package/.output/server/_ssr/insights-usage-BpBM0U0c.mjs +29 -0
  114. package/.output/server/_ssr/insights-usage-rpc-BiolgB8e.mjs +29 -0
  115. package/.output/server/_ssr/insights-usage-rpc-KStL0zOx.mjs +41 -0
  116. package/.output/server/_ssr/insightsUsage-CzhVjsc8.mjs +56 -0
  117. package/.output/server/_ssr/insights_.distribution-CVrnbP3R.mjs +7 -0
  118. package/.output/server/_ssr/insights_.distribution-D2HaNTAA.mjs +16 -0
  119. package/.output/server/_ssr/{insights_.distribution-INw6QxbU.mjs → insights_.distribution-DN9pR422.mjs} +50 -22
  120. package/.output/server/_ssr/installations-BHmbbnH8.mjs +5 -0
  121. package/.output/server/_ssr/{installations-DH-tQuRo.mjs → installations-BSCmFq8Q.mjs} +279 -367
  122. package/.output/server/_ssr/installations-DD1g__Nc.mjs +69 -0
  123. package/.output/server/_ssr/listReleases-BfUBlCHo.mjs +79 -0
  124. package/.output/server/_ssr/plugins-BaD1slHx.mjs +2086 -0
  125. package/.output/server/_ssr/release-adoption-005tQRpo.mjs +55 -0
  126. package/.output/server/_ssr/release-adoption-rpc-BsstqxUp.mjs +41 -0
  127. package/.output/server/_ssr/releaseAdoption-CtOFkwli.mjs +114 -0
  128. package/.output/server/_ssr/releaseManagement-DFMUnDF5.mjs +11 -0
  129. package/.output/server/_ssr/remote-config-C2Ee8lXO.mjs +5 -0
  130. package/.output/server/_ssr/remote-config-Dv1ccMo-.mjs +17 -0
  131. package/.output/server/_ssr/remote-config-of0lGQH8.mjs +2648 -0
  132. package/.output/server/_ssr/remote-config-rpc-BzX31mUS.mjs +115 -0
  133. package/.output/server/_ssr/rolldown-runtime-rSIU-vHC.mjs +13 -0
  134. package/.output/server/_ssr/{router-DfFyAp5p.mjs → router-D8NuoJ_I.mjs} +117 -136
  135. package/.output/server/_ssr/{routes-BtsfVx-p.mjs → routes-DgvnFqDy.mjs} +195 -429
  136. package/.output/server/_ssr/routes-V8sDybGf.mjs +409 -0
  137. package/.output/server/_ssr/runtime.server-De0QVWc9.mjs +104 -0
  138. package/.output/server/_ssr/schema-BiAVyEj2.mjs +361 -0
  139. package/.output/server/_ssr/{select-CyvLaMza.mjs → select-t3iXRwc9.mjs} +3 -3
  140. package/.output/server/_ssr/server-h4VxnExB.mjs +8325 -0
  141. package/.output/server/_ssr/{createSsrRpc-C-dLcQuy.mjs → sidebar-DJcErBMo.mjs} +107 -47
  142. package/.output/server/_ssr/ssr.mjs +1 -1
  143. package/.output/server/_ssr/start-BfFbHKMK.mjs +4 -0
  144. package/.output/server/_ssr/switch-E-btwMGt.mjs +43 -0
  145. package/.output/server/_ssr/{table-CkVhsNpe.mjs → table-37Dd23TN.mjs} +2 -2
  146. package/.output/server/_ssr/tabs-DEFnTm95.mjs +45 -0
  147. package/.output/server/_ssr/updateFailures-H6pnnYK4.mjs +40 -0
  148. package/.output/server/_ssr/{uuidv7-D0QFkPL_.mjs → uuidv7-C88s9jWF.mjs} +2 -2
  149. package/.output/server/_tanstack-start-manifest_v-55AGsehh.mjs +139 -0
  150. package/.output/server/index.mjs +303 -205
  151. package/LICENSE +13 -14
  152. package/README.md +80 -71
  153. package/lib/index.d.mts +23 -11
  154. package/lib/vite-internal.mjs +13 -3
  155. package/lib/vite.d.mts +2 -0
  156. package/package.json +14 -14
  157. package/src/components/AppSidebar.tsx +74 -75
  158. package/src/components/ConsoleAccessPage.tsx +5 -1
  159. package/src/components/ConsoleFeatureUnavailable.tsx +80 -0
  160. package/src/components/NotFoundPage.tsx +7 -7
  161. package/src/components/features/FeatureSlots.tsx +103 -0
  162. package/src/components/features/api-keys/apiKeysFeatureUi.tsx +15 -0
  163. package/src/components/features/bundles/BundleMetadata.tsx +8 -5
  164. package/src/components/features/bundles/RolloutCohortsDialog.tsx +1 -1
  165. package/src/components/features/channels/ChannelManagementDialog.tsx +8 -6
  166. package/src/components/features/insights/AppUsage.tsx +41 -14
  167. package/src/components/features/insights/BuiltinBundle.tsx +36 -0
  168. package/src/components/features/insights/ComparedBundlesChart.tsx +310 -0
  169. package/src/components/features/insights/EstimatedCount.tsx +18 -0
  170. package/src/components/features/insights/EventDetails.tsx +390 -26
  171. package/src/components/features/insights/EventHistoryCard.tsx +111 -25
  172. package/src/components/features/insights/EventHistoryList.tsx +1 -1
  173. package/src/components/features/insights/FailureReports.tsx +407 -0
  174. package/src/components/features/insights/InsightsControls.tsx +240 -142
  175. package/src/components/features/insights/InsightsErrorAlert.tsx +14 -1
  176. package/src/components/features/insights/InsightsOverview.tsx +601 -403
  177. package/src/components/features/insights/InsightsPageHeader.tsx +19 -14
  178. package/src/components/features/insights/InsightsPeriodSelector.tsx +67 -12
  179. package/src/components/features/insights/InstallationHistoryCard.tsx +65 -10
  180. package/src/components/features/insights/InstallationMatchesCard.tsx +1 -1
  181. package/src/components/features/insights/ReleaseActivity.tsx +308 -0
  182. package/src/components/features/insights/ReportingDevicesSummary.tsx +13 -13
  183. package/src/components/features/insights/RollbackButton.tsx +118 -0
  184. package/src/components/features/insights/UpdateFailures.tsx +382 -0
  185. package/src/components/features/insights/insightsFeatureUi.tsx +35 -0
  186. package/src/components/features/releases/ReleaseEditorSheet.tsx +27 -13
  187. package/src/components/features/remote-config/ConditionDialog.tsx +592 -0
  188. package/src/components/features/remote-config/ConditionsCard.tsx +247 -0
  189. package/src/components/features/remote-config/ParameterDialog.tsx +426 -0
  190. package/src/components/features/remote-config/ParametersCard.tsx +254 -0
  191. package/src/components/features/remote-config/PreviewCard.tsx +284 -0
  192. package/src/components/features/remote-config/PublishDialog.tsx +325 -0
  193. package/src/components/features/remote-config/RemoteConfigPage.tsx +353 -0
  194. package/src/components/features/remote-config/RuleSummary.tsx +21 -0
  195. package/src/components/features/remote-config/ValueInput.tsx +151 -0
  196. package/src/components/features/remote-config/VersionsCard.tsx +384 -0
  197. package/src/components/features/remote-config/remoteConfigFeatureUi.tsx +15 -0
  198. package/src/components/features/remote-config/useDateTimeText.ts +16 -0
  199. package/src/components/ui/sidebar.tsx +22 -29
  200. package/src/index.ts +26 -19
  201. package/src/lib/api-keys-api.ts +0 -28
  202. package/src/lib/api-keys-rpc.ts +27 -38
  203. package/src/lib/api-rpc.ts +125 -288
  204. package/src/lib/api.ts +15 -134
  205. package/src/lib/bundle-activity.ts +24 -4
  206. package/src/lib/console-access.ts +20 -0
  207. package/src/lib/console-features-api.ts +68 -0
  208. package/src/lib/console-features-rpc.ts +13 -0
  209. package/src/lib/console-features.ts +98 -0
  210. package/src/lib/insights-api.ts +56 -2
  211. package/src/lib/insights-errors.ts +64 -0
  212. package/src/lib/insights-failures-rpc.ts +36 -0
  213. package/src/lib/insights-failures.ts +130 -0
  214. package/src/lib/insights-recovery-rpc.ts +13 -17
  215. package/src/lib/insights-recovery.ts +12 -36
  216. package/src/lib/insights-retention.ts +21 -0
  217. package/src/lib/insights-rpc.ts +30 -12
  218. package/src/lib/insights-search.ts +50 -4
  219. package/src/lib/insights-usage-rpc.ts +15 -9
  220. package/src/lib/insights-usage.ts +41 -3
  221. package/src/lib/insights-view.ts +34 -5
  222. package/src/lib/release-adoption-api.ts +214 -0
  223. package/src/lib/release-adoption-rpc.ts +49 -0
  224. package/src/lib/release-adoption.ts +164 -0
  225. package/src/lib/remote-config-api.ts +119 -0
  226. package/src/lib/remote-config-draft.ts +666 -0
  227. package/src/lib/remote-config-rpc.ts +196 -0
  228. package/src/lib/scroll-restoration.ts +21 -0
  229. package/src/lib/server/auth.server.ts +13 -5
  230. package/src/lib/server/bundleActivity.ts +27 -28
  231. package/src/lib/server/config.server.ts +21 -76
  232. package/src/lib/server/console-feature-apis.ts +70 -0
  233. package/src/lib/server/console-runtime.server.ts +82 -38
  234. package/src/lib/server/downloadBundle.ts +14 -15
  235. package/src/lib/server/failureReports.ts +50 -0
  236. package/src/lib/server/getBundleChildren.ts +31 -122
  237. package/src/lib/server/insightsUsage.ts +52 -113
  238. package/src/lib/server/listReleases.ts +109 -44
  239. package/src/lib/server/releaseAdoption.ts +151 -0
  240. package/src/lib/server/releaseReachability.ts +8 -8
  241. package/src/lib/server/remoteConfig.ts +75 -0
  242. package/src/lib/server/runtime.server.ts +120 -31
  243. package/src/lib/server/updateFailures.ts +66 -0
  244. package/src/lib/use-dialog-target.ts +27 -0
  245. package/src/routeTree.gen.ts +44 -44
  246. package/src/router.tsx +3 -2
  247. package/src/routes/-installations-search.ts +32 -8
  248. package/src/routes/-releases-search.ts +76 -29
  249. package/src/routes/__root.tsx +7 -1
  250. package/src/routes/api/bundles/$bundleId/download.ts +2 -5
  251. package/src/routes/api-keys.tsx +5 -2
  252. package/src/routes/index.tsx +210 -152
  253. package/src/routes/insights.tsx +91 -23
  254. package/src/routes/insights_.distribution.tsx +50 -9
  255. package/src/routes/installations.tsx +97 -40
  256. package/src/routes/remote-config.tsx +42 -0
  257. package/src/styles.css +9 -0
  258. package/src/vite-internal.ts +15 -3
  259. package/src/vite.ts +2 -0
  260. package/.output/public/assets/HashValueDisplay-BpTc3Oyg.js +0 -1
  261. package/.output/public/assets/InsightsPageHeader-DC2eEst8.js +0 -1
  262. package/.output/public/assets/api-CdUyUqzR.js +0 -42
  263. package/.output/public/assets/api-keys-64PM9PwW.js +0 -1
  264. package/.output/public/assets/api-keys-api-BeaJnvY5.js +0 -1
  265. package/.output/public/assets/arrow-left-04Rh8Zgp.js +0 -1
  266. package/.output/public/assets/card-CYHs5FZv.js +0 -1
  267. package/.output/public/assets/chart-no-axes-combined-DwyMsVFW.js +0 -1
  268. package/.output/public/assets/createServerFn-DU71xucx.js +0 -3
  269. package/.output/public/assets/dialog-IVMkBRCq.js +0 -1
  270. package/.output/public/assets/dist-BR4GzeEu.js +0 -1
  271. package/.output/public/assets/field-B3CYDpjg.js +0 -1
  272. package/.output/public/assets/index-C39o7rJH.js +0 -10
  273. package/.output/public/assets/info-C3y9HNoU.js +0 -1
  274. package/.output/public/assets/input-group-nLZylhWF.js +0 -1
  275. package/.output/public/assets/insights-Bm9v8uO3.js +0 -2
  276. package/.output/public/assets/insights-DS3iO7Up.js +0 -1
  277. package/.output/public/assets/insights-search-Byj3g3Mp.js +0 -1
  278. package/.output/public/assets/insights-usage-rpc-BaGR3lgq.js +0 -1
  279. package/.output/public/assets/insights_.distribution-B1i6cjlQ.js +0 -1
  280. package/.output/public/assets/insights_.distribution-C1Wf27eB.js +0 -2
  281. package/.output/public/assets/installations-CkFW4fV9.js +0 -2
  282. package/.output/public/assets/installations-DxTaIcHD.js +0 -1
  283. package/.output/public/assets/lazyRouteComponent-BapzjYnb.js +0 -1
  284. package/.output/public/assets/list-Dqt53fWZ.js +0 -1
  285. package/.output/public/assets/loader-circle-CUKfUqow.js +0 -1
  286. package/.output/public/assets/preload-helper-ClBMtM1g.js +0 -1
  287. package/.output/public/assets/refresh-cw-CNE_2PnD.js +0 -1
  288. package/.output/public/assets/routes-Cgtvspjg.js +0 -2
  289. package/.output/public/assets/routes-O2r2UUN8.js +0 -1
  290. package/.output/public/assets/shield-check-BFcJ46kz.js +0 -1
  291. package/.output/public/assets/signing-BgspC-xP.js +0 -1
  292. package/.output/public/assets/styles-DnrWuBwd.css +0 -2
  293. package/.output/public/assets/table-BuWQgxJJ.js +0 -1
  294. package/.output/public/assets/useMutation-CSV9NCUl.js +0 -1
  295. package/.output/public/assets/useOpenInteractionType-D5kduCTD.js +0 -1
  296. package/.output/public/assets/valueToPercent-BAtcbSLk.js +0 -1
  297. package/.output/server/__23tanstack-start-server-fn-resolver-CmYkol9D.mjs +0 -150
  298. package/.output/server/_ssr/InsightsPageHeader-Dma3dVj1.mjs +0 -64
  299. package/.output/server/_ssr/api-C3bGmgY0.mjs +0 -332
  300. package/.output/server/_ssr/api-keys-api-BRF6rbRC.mjs +0 -60
  301. package/.output/server/_ssr/api-keys-rpc-BMa1ZM6N.mjs +0 -136
  302. package/.output/server/_ssr/api-rpc-BYQ2e0z6.mjs +0 -1399
  303. package/.output/server/_ssr/auth.server-CmicHh0J.mjs +0 -47
  304. package/.output/server/_ssr/bundle-signing-rpc-DbQ4pFAX.mjs +0 -16
  305. package/.output/server/_ssr/bundle-signing.server-Uqt1OF49.mjs +0 -12
  306. package/.output/server/_ssr/bundleActivity-pBrPSG01.mjs +0 -28
  307. package/.output/server/_ssr/card-B7KSO_25.mjs +0 -108
  308. package/.output/server/_ssr/config-Dv8qLDZ0.mjs +0 -13
  309. package/.output/server/_ssr/config.server-C-d1QaBU.mjs +0 -368
  310. package/.output/server/_ssr/databaseRows-5bCRTxm-.mjs +0 -126
  311. package/.output/server/_ssr/deleteBundle-8X-jq7Z7.mjs +0 -66
  312. package/.output/server/_ssr/field-BDwuU8RE.mjs +0 -74
  313. package/.output/server/_ssr/getBundleChildren-DoL8l_AS.mjs +0 -50
  314. package/.output/server/_ssr/insights-BDJjaDLp.mjs +0 -938
  315. package/.output/server/_ssr/insights-D0FWpfOS.mjs +0 -10
  316. package/.output/server/_ssr/insights-recovery-Cv6RSyeR.mjs +0 -21
  317. package/.output/server/_ssr/insights-recovery-rpc-BE9YsK_T.mjs +0 -37
  318. package/.output/server/_ssr/insights-search-1czJMZgk.mjs +0 -21
  319. package/.output/server/_ssr/insights-usage-rpc-BE_aCnea.mjs +0 -184
  320. package/.output/server/_ssr/insights-usage-rpc-CtAolz-t.mjs +0 -24
  321. package/.output/server/_ssr/insightsContract-B09K_Px1.mjs +0 -303
  322. package/.output/server/_ssr/insightsHistory-Ci4rYAgl.mjs +0 -41
  323. package/.output/server/_ssr/insightsRecovery-CaghWL2t.mjs +0 -113
  324. package/.output/server/_ssr/insightsUsage-DNIj6jxF.mjs +0 -71
  325. package/.output/server/_ssr/insights_.distribution-Cp0kf1vW.mjs +0 -10
  326. package/.output/server/_ssr/installations-Bhyiwx8G.mjs +0 -29
  327. package/.output/server/_ssr/routes-xBkI2Fmt.mjs +0 -37
  328. package/.output/server/_ssr/runtime.server-CsiKFp_Z.mjs +0 -436
  329. package/.output/server/_ssr/server-BdkuOWe8.mjs +0 -7468
  330. package/.output/server/_ssr/signing-CQ70saFm.mjs +0 -133
  331. package/.output/server/_ssr/start-DpViQGnt.mjs +0 -4
  332. package/.output/server/_tanstack-start-manifest_v-CrBsoKQQ.mjs +0 -125
  333. package/src/components/features/bundles/BundleActivityChart.tsx +0 -97
  334. package/src/components/features/bundles/BundleInsightsSummary.tsx +0 -126
  335. package/src/components/features/signing/BundleSigningPage.tsx +0 -139
  336. package/src/lib/bundle-signing-api.ts +0 -14
  337. package/src/lib/bundle-signing-rpc.ts +0 -16
  338. package/src/lib/server/bundle-signing.server.ts +0 -23
  339. package/src/lib/server/deleteBundle.ts +0 -145
  340. package/src/lib/server/insightsHistory.ts +0 -52
  341. package/src/lib/server/insightsRecovery.ts +0 -187
  342. package/src/routes/signing.tsx +0 -37
@@ -1,110 +1,156 @@
1
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/subscribable.js
2
- var Subscribable = class {
3
- constructor() {
4
- this.listeners = /* @__PURE__ */ new Set();
5
- this.subscribe = this.subscribe.bind(this);
6
- }
7
- subscribe(listener) {
8
- this.listeners.add(listener);
9
- this.onSubscribe();
10
- return () => {
11
- this.listeners.delete(listener);
12
- this.onUnsubscribe();
13
- };
14
- }
15
- hasListeners() {
16
- return this.listeners.size > 0;
17
- }
18
- onSubscribe() {}
19
- onUnsubscribe() {}
20
- };
21
- //#endregion
22
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/focusManager.js
23
- var FocusManager = class extends Subscribable {
24
- #focused;
25
- #cleanup;
26
- #setup;
27
- constructor() {
28
- super();
29
- this.#setup = (onFocus) => {
30
- if (typeof window !== "undefined" && window.addEventListener) {
31
- const listener = () => onFocus();
32
- window.addEventListener("visibilitychange", listener, false);
33
- return () => {
34
- window.removeEventListener("visibilitychange", listener);
35
- };
36
- }
37
- };
38
- }
39
- onSubscribe() {
40
- if (!this.#cleanup) this.setEventListener(this.#setup);
41
- }
42
- onUnsubscribe() {
43
- if (!this.hasListeners()) {
44
- this.#cleanup?.();
45
- this.#cleanup = void 0;
46
- }
47
- }
48
- setEventListener(setup) {
49
- this.#setup = setup;
50
- this.#cleanup?.();
51
- this.#cleanup = setup((focused) => {
52
- if (typeof focused === "boolean") this.setFocused(focused);
53
- else this.onFocus();
54
- });
55
- }
56
- setFocused(focused) {
57
- if (this.#focused !== focused) {
58
- this.#focused = focused;
59
- this.onFocus();
60
- }
61
- }
62
- onFocus() {
63
- const isFocused = this.isFocused();
64
- this.listeners.forEach((listener) => {
65
- listener(isFocused);
66
- });
67
- }
68
- isFocused() {
69
- if (typeof this.#focused === "boolean") return this.#focused;
70
- return globalThis.document?.visibilityState !== "hidden";
71
- }
72
- };
73
- var focusManager = new FocusManager();
74
- //#endregion
75
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/timeoutManager.js
1
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/timeoutManager.js
76
2
  var defaultTimeoutProvider = {
77
3
  setTimeout: (callback, delay) => setTimeout(callback, delay),
78
4
  clearTimeout: (timeoutId) => clearTimeout(timeoutId),
79
5
  setInterval: (callback, delay) => setInterval(callback, delay),
80
6
  clearInterval: (intervalId) => clearInterval(intervalId)
81
7
  };
8
+ /**
9
+ * Allows customization of how timeouts are created.
10
+ *
11
+ * @tanstack/query-core makes liberal use of timeouts to implement `staleTime`
12
+ * and `gcTime`. The default TimeoutManager provider uses the platform's global
13
+ * `setTimeout` implementation, which is known to have scalability issues with
14
+ * thousands of timeouts on the event loop.
15
+ *
16
+ * If you hit this limitation, consider providing a custom TimeoutProvider that
17
+ * coalesces timeouts.
18
+ */
82
19
  var TimeoutManager = class {
83
20
  #provider = defaultTimeoutProvider;
84
21
  #providerCalled = false;
22
+ /**
23
+ * `setTimeoutProvider` can be used to set a custom implementation of the
24
+ * `setTimeout`, `clearTimeout`, `setInterval`, `clearInterval` functions,
25
+ * called a `TimeoutProvider`.
26
+ *
27
+ * This may be useful if you notice event loop performance issues with
28
+ * thousands of queries. A custom TimeoutProvider could also support timer
29
+ * delays longer than the global `setTimeout` maximum delay value of about
30
+ * 24 days.
31
+ *
32
+ * It is important to call `setTimeoutProvider` before creating a
33
+ * QueryClient or queries, so that the same provider is used consistently
34
+ * for all timers in the application, since different TimeoutProviders
35
+ * cannot cancel each others' timers.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { timeoutManager, QueryClient } from '@tanstack/query-core'
40
+ * import { CustomTimeoutProvider } from './CustomTimeoutProvider'
41
+ *
42
+ * timeoutManager.setTimeoutProvider(new CustomTimeoutProvider())
43
+ *
44
+ * export const queryClient = new QueryClient()
45
+ * ```
46
+ */
85
47
  setTimeoutProvider(provider) {
86
48
  this.#provider = provider;
87
49
  }
50
+ /**
51
+ * `setTimeout` schedules a callback to run after approximately `delay`
52
+ * milliseconds, like the global `setTimeout` function. The callback can be
53
+ * canceled with `clearTimeout`.
54
+ *
55
+ * It returns a timer ID, which may be a number or an object that can be
56
+ * coerced to a number via `Symbol.toPrimitive`.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * import { timeoutManager } from '@tanstack/query-core'
61
+ *
62
+ * const timeoutId = timeoutManager.setTimeout(
63
+ * () => console.log('ran at:', new Date()),
64
+ * 1000,
65
+ * )
66
+ *
67
+ * const timeoutIdNumber: number = Number(timeoutId)
68
+ * ```
69
+ */
88
70
  setTimeout(callback, delay) {
89
71
  return this.#provider.setTimeout(callback, delay);
90
72
  }
73
+ /**
74
+ * `clearTimeout` cancels a timeout callback scheduled with `setTimeout`,
75
+ * like the global `clearTimeout` function. It should be called with a
76
+ * timer ID returned by `setTimeout`.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * import { timeoutManager } from '@tanstack/query-core'
81
+ *
82
+ * const timeoutId = timeoutManager.setTimeout(
83
+ * () => console.log('ran at:', new Date()),
84
+ * 1000,
85
+ * )
86
+ *
87
+ * timeoutManager.clearTimeout(timeoutId)
88
+ * ```
89
+ */
91
90
  clearTimeout(timeoutId) {
92
91
  this.#provider.clearTimeout(timeoutId);
93
92
  }
93
+ /**
94
+ * `setInterval` schedules a callback to be called approximately every
95
+ * `delay` milliseconds, like the global `setInterval` function.
96
+ *
97
+ * Like `setTimeout`, it returns a timer ID, which may be a number or an
98
+ * object that can be coerced to a number via `Symbol.toPrimitive`.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * import { timeoutManager } from '@tanstack/query-core'
103
+ *
104
+ * const intervalId = timeoutManager.setInterval(
105
+ * () => console.log('ran at:', new Date()),
106
+ * 1000,
107
+ * )
108
+ * ```
109
+ */
94
110
  setInterval(callback, delay) {
95
111
  return this.#provider.setInterval(callback, delay);
96
112
  }
113
+ /**
114
+ * `clearInterval` can be used to cancel an interval, like the global
115
+ * `clearInterval` function. It should be called with an interval ID
116
+ * returned by `setInterval`.
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * import { timeoutManager } from '@tanstack/query-core'
121
+ *
122
+ * const intervalId = timeoutManager.setInterval(
123
+ * () => console.log('ran at:', new Date()),
124
+ * 1000,
125
+ * )
126
+ *
127
+ * timeoutManager.clearInterval(intervalId)
128
+ * ```
129
+ */
97
130
  clearInterval(intervalId) {
98
131
  this.#provider.clearInterval(intervalId);
99
132
  }
100
133
  };
134
+ /**
135
+ * Singleton instance of {@link TimeoutManager}, used throughout TanStack Query to schedule and cancel timers.
136
+ */
101
137
  var timeoutManager = new TimeoutManager();
138
+ /**
139
+ * In many cases code wants to delay to the next event loop tick; this is not
140
+ * mediated by {@link timeoutManager}.
141
+ *
142
+ * This function is provided to make auditing the `tanstack/query-core` for
143
+ * incorrect use of system `setTimeout` easier.
144
+ */
102
145
  function systemSetTimeoutZero(callback) {
103
146
  setTimeout(callback, 0);
104
147
  }
105
148
  //#endregion
106
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/utils.js
107
- var isServer = typeof window === "undefined" || "Deno" in globalThis;
149
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/utils.js
150
+ /** @deprecated
151
+ * use `environmentManager.isServer()` instead.
152
+ */
153
+ var isServer$1 = typeof window === "undefined" || "Deno" in globalThis;
108
154
  function noop() {}
109
155
  function functionalUpdate(updater, input) {
110
156
  return typeof updater === "function" ? updater(input) : updater;
@@ -115,12 +161,22 @@ function isValidTimeout(value) {
115
161
  function timeUntilStale(updatedAt, staleTime) {
116
162
  return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
117
163
  }
118
- function resolveStaleTime(staleTime, query) {
119
- return typeof staleTime === "function" ? staleTime(query) : staleTime;
120
- }
121
- function resolveQueryBoolean(option, query) {
122
- return typeof option === "function" ? option(query) : option;
164
+ function resolveQueryValue(value, query) {
165
+ return typeof value === "function" ? value(query) : value;
123
166
  }
167
+ /**
168
+ * Checks whether a query matches the given {@link QueryFilters}.
169
+ * Every filter that is specified must match; filters that are left unspecified are ignored.
170
+ *
171
+ * @example
172
+ * ```ts
173
+ * const queryCache = queryClient.getQueryCache()
174
+ *
175
+ * const matchingQueries = queryCache
176
+ * .getAll()
177
+ * .filter((query) => matchQuery({ queryKey: ['posts'] }, query))
178
+ * ```
179
+ */
124
180
  function matchQuery(filters, query) {
125
181
  const { type = "all", exact, fetchStatus, predicate, queryKey, stale } = filters;
126
182
  if (queryKey) {
@@ -138,6 +194,20 @@ function matchQuery(filters, query) {
138
194
  if (predicate && !predicate(query)) return false;
139
195
  return true;
140
196
  }
197
+ /**
198
+ * Checks whether a mutation matches the given {@link MutationFilters}.
199
+ * Every filter that is specified must match; filters that are left unspecified are ignored.
200
+ * If a `mutationKey` filter is provided but the mutation has no `mutationKey` of its own, it does not match.
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * const mutationCache = queryClient.getMutationCache()
205
+ *
206
+ * const matchingMutations = mutationCache
207
+ * .getAll()
208
+ * .filter((mutation) => matchMutation({ mutationKey: ['addPost'] }, mutation))
209
+ * ```
210
+ */
141
211
  function matchMutation(filters, mutation) {
142
212
  const { exact, status, predicate, mutationKey } = filters;
143
213
  if (mutationKey) {
@@ -153,6 +223,16 @@ function matchMutation(filters, mutation) {
153
223
  function hashQueryKeyByOptions(queryKey, options) {
154
224
  return (options?.queryKeyHashFn || hashKey)(queryKey);
155
225
  }
226
+ /**
227
+ * Default query & mutation keys hash function.
228
+ * Hashes the value into a stable hash.
229
+ *
230
+ * @example
231
+ * ```ts
232
+ * // Object keys are sorted, so key order doesn't affect the hash:
233
+ * hashKey(['todos', { page: 1, filter: 'done' }]) // === '["todos",{"filter":"done","page":1}]'
234
+ * ```
235
+ */
156
236
  function hashKey(queryKey) {
157
237
  return JSON.stringify(queryKey, (_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
158
238
  result[key] = val[key];
@@ -162,7 +242,16 @@ function hashKey(queryKey) {
162
242
  function partialMatchKey(a, b) {
163
243
  if (a === b) return true;
164
244
  if (typeof a !== typeof b) return false;
165
- if (a && b && typeof a === "object" && typeof b === "object") return Object.keys(b).every((key) => partialMatchKey(a[key], b[key]));
245
+ if (a && b && typeof a === "object" && typeof b === "object") {
246
+ if (Array.isArray(a) && Array.isArray(b)) {
247
+ if (b.length > a.length) return false;
248
+ for (let i = 0; i < b.length; i++) if (!partialMatchKey(a[i], b[i])) return false;
249
+ return true;
250
+ }
251
+ const bKeys = Object.keys(b);
252
+ for (const key of bKeys) if (!partialMatchKey(a[key], b[key])) return false;
253
+ return true;
254
+ }
166
255
  return false;
167
256
  }
168
257
  var hasOwn = Object.prototype.hasOwnProperty;
@@ -195,6 +284,9 @@ function replaceEqualDeep(a, b, depth = 0) {
195
284
  }
196
285
  return aSize === bSize && equalItems === aSize ? a : copy;
197
286
  }
287
+ /**
288
+ * Shallow compare objects.
289
+ */
198
290
  function shallowEqualObjects(a, b) {
199
291
  if (!b || Object.keys(a).length !== Object.keys(b).length) return false;
200
292
  for (const key in a) if (a[key] !== b[key]) return false;
@@ -205,12 +297,14 @@ function isPlainArray(value) {
205
297
  }
206
298
  function isPlainObject(o) {
207
299
  if (!hasObjectPrototype(o)) return false;
208
- const ctor = o.constructor;
300
+ const objectPrototype = Object.getPrototypeOf(o);
301
+ const ctor = objectPrototype?.constructor;
209
302
  if (ctor === void 0) return true;
303
+ if (typeof ctor !== "function") return false;
210
304
  const prot = ctor.prototype;
211
305
  if (!hasObjectPrototype(prot)) return false;
212
306
  if (!prot.hasOwnProperty("isPrototypeOf")) return false;
213
- if (Object.getPrototypeOf(o) !== Object.prototype) return false;
307
+ if (objectPrototype !== Object.prototype) return false;
214
308
  return true;
215
309
  }
216
310
  function hasObjectPrototype(o) {
@@ -226,6 +320,23 @@ function replaceData(prevData, data, options) {
226
320
  else if (options.structuralSharing !== false) return replaceEqualDeep(prevData, data);
227
321
  return data;
228
322
  }
323
+ /**
324
+ * Intended to be passed as a query's `placeholderData` option, for example
325
+ * `placeholderData: keepPreviousData`. Instead of resetting the query's data to `undefined` while a new
326
+ * query key is fetching, it keeps displaying the previously fetched data until the new data arrives.
327
+ *
328
+ * @example
329
+ * ```ts
330
+ * new QueryObserver(queryClient, {
331
+ * queryKey: ['posts', page],
332
+ * queryFn: () => fetchPosts(page),
333
+ * placeholderData: keepPreviousData,
334
+ * })
335
+ * ```
336
+ */
337
+ function keepPreviousData(previousData) {
338
+ return previousData;
339
+ }
229
340
  function addToEnd(items, item, max = 0) {
230
341
  const newItems = [...items, item];
231
342
  return max && newItems.length > max ? newItems.slice(1) : newItems;
@@ -234,12 +345,40 @@ function addToStart(items, item, max = 0) {
234
345
  const newItems = [item, ...items];
235
346
  return max && newItems.length > max ? newItems.slice(0, -1) : newItems;
236
347
  }
237
- var skipToken = /* @__PURE__ */ Symbol();
348
+ /**
349
+ * Sentinel value that can be passed as a query's `queryFn` to conditionally disable the query (equivalent
350
+ * to `enabled: false`) while preserving full type inference for the query's data. Unlike `enabled: false`,
351
+ * a query disabled via `skipToken` cannot be triggered with `refetch`.
352
+ *
353
+ * @example
354
+ * ```ts
355
+ * new QueryObserver(queryClient, {
356
+ * queryKey: ['post', postId],
357
+ * queryFn: postId != null ? () => fetchPost(postId) : skipToken,
358
+ * })
359
+ * ```
360
+ */
361
+ var skipToken = Symbol();
238
362
  function ensureQueryFn(options, fetchOptions) {
239
363
  if (!options.queryFn && fetchOptions?.initialPromise) return () => fetchOptions.initialPromise;
240
364
  if (!options.queryFn || options.queryFn === skipToken) return () => Promise.reject(/* @__PURE__ */ new Error(`Missing queryFn: '${options.queryHash}'`));
241
365
  return options.queryFn;
242
366
  }
367
+ /**
368
+ * Resolves a `throwOnError` option to a boolean.
369
+ * If `throwOnError` is a function, it is called with `params` (e.g. the error and, depending on the caller,
370
+ * additional context such as the query or mutation) and its result is returned, allowing the throwing
371
+ * behavior to be decided per error. Otherwise, `throwOnError` itself is coerced to a boolean (`undefined`
372
+ * resolves to `false`).
373
+ *
374
+ * @example
375
+ * ```ts
376
+ * const throwOnError =
377
+ * query.state.error && typeof options.throwOnError === 'function'
378
+ * ? shouldThrowError(options.throwOnError, [query.state.error, query])
379
+ * : options.throwOnError
380
+ * ```
381
+ */
243
382
  function shouldThrowError(throwOnError, params) {
244
383
  if (typeof throwOnError === "function") return throwOnError(...params);
245
384
  return !!throwOnError;
@@ -261,136 +400,244 @@ function addConsumeAwareSignal(object, getSignal, onCancelled) {
261
400
  return object;
262
401
  }
263
402
  //#endregion
264
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/environmentManager.js
265
- var environmentManager = /* @__PURE__ */ (() => {
266
- let isServerFn = () => isServer;
267
- return {
268
- isServer() {
269
- return isServerFn();
270
- },
271
- setIsServer(isServerValue) {
272
- isServerFn = isServerValue;
273
- }
274
- };
275
- })();
403
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/environmentManager.js
404
+ var isServerFn = () => isServer$1;
405
+ /**
406
+ * Returns whether the current runtime should be treated as a server environment.
407
+ */
408
+ var isServer = () => isServerFn();
276
409
  //#endregion
277
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/thenable.js
278
- function pendingThenable() {
279
- let resolve;
280
- let reject;
281
- const thenable = new Promise((_resolve, _reject) => {
282
- resolve = _resolve;
283
- reject = _reject;
284
- });
285
- thenable.status = "pending";
286
- thenable.catch(() => {});
287
- function finalize(data) {
288
- Object.assign(thenable, data);
289
- delete thenable.resolve;
290
- delete thenable.reject;
291
- }
292
- thenable.resolve = (value) => {
293
- finalize({
294
- status: "fulfilled",
295
- value
410
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/subscribable.js
411
+ /**
412
+ * The base class behind everything in Query that you can subscribe to: `QueryCache`, `MutationCache`,
413
+ * the observers, and the `FocusManager`/`OnlineManager` behind `focusManager` and `onlineManager`.
414
+ * Subclasses decide what a listener receives and when it is called.
415
+ */
416
+ var Subscribable = class {
417
+ constructor() {
418
+ this.listeners = /* @__PURE__ */ new Set();
419
+ this.subscribe = this.subscribe.bind(this);
420
+ }
421
+ /**
422
+ * Registers a listener to be called on every update this object notifies about. Returns a function
423
+ * that removes the listener again — call it to stop listening. The base class never drops a listener
424
+ * on its own, though some subclasses clear all of theirs in `destroy()`.
425
+ * @param listener - Called on each update, with whatever the subclass passes to its subscribers.
426
+ * @example
427
+ * ```ts
428
+ * const unsubscribe = subscribable.subscribe(() => {
429
+ * // react to the update
430
+ * })
431
+ *
432
+ * unsubscribe()
433
+ * ```
434
+ */
435
+ subscribe(listener) {
436
+ this.listeners.add(listener);
437
+ this.onSubscribe();
438
+ return () => {
439
+ this.listeners.delete(listener);
440
+ this.onUnsubscribe();
441
+ };
442
+ }
443
+ /**
444
+ * Returns `true` while at least one listener is registered, `false` once they have all unsubscribed.
445
+ */
446
+ hasListeners() {
447
+ return this.listeners.size > 0;
448
+ }
449
+ onSubscribe() {}
450
+ onUnsubscribe() {}
451
+ };
452
+ //#endregion
453
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/focusManager.js
454
+ /**
455
+ * The `FocusManager` manages the focus state within TanStack Query.
456
+ *
457
+ * It can be used to change the default event listeners or to manually change the focus state.
458
+ */
459
+ var FocusManager = class extends Subscribable {
460
+ #focused;
461
+ #cleanup;
462
+ #setup;
463
+ constructor() {
464
+ super();
465
+ this.#setup = (onFocus) => {
466
+ if (typeof window !== "undefined" && window.addEventListener) {
467
+ const listener = () => onFocus();
468
+ window.addEventListener("visibilitychange", listener, false);
469
+ return () => {
470
+ window.removeEventListener("visibilitychange", listener);
471
+ };
472
+ }
473
+ };
474
+ }
475
+ onSubscribe() {
476
+ if (!this.#cleanup) this.setEventListener(this.#setup);
477
+ }
478
+ onUnsubscribe() {
479
+ if (!this.hasListeners()) {
480
+ this.#cleanup?.();
481
+ this.#cleanup = void 0;
482
+ }
483
+ }
484
+ /**
485
+ * `setEventListener` can be used to set a custom event listener that will
486
+ * be used to determine the focus state. The provided `setup` function
487
+ * receives a `setFocused` callback: call it with a `boolean` to manually
488
+ * set the focus state, or with no arguments to re-evaluate the current
489
+ * focus state and notify subscribers.
490
+ *
491
+ * @example
492
+ * ```ts
493
+ * import { focusManager } from '@tanstack/query-core'
494
+ *
495
+ * focusManager.setEventListener((handleFocus) => {
496
+ * const listener = () => handleFocus()
497
+ * // Listen to visibilitychange
498
+ * if (typeof window !== 'undefined' && window.addEventListener) {
499
+ * window.addEventListener('visibilitychange', listener, false)
500
+ * }
501
+ *
502
+ * return () => {
503
+ * // Be sure to unsubscribe if a new handler is set
504
+ * window.removeEventListener('visibilitychange', listener)
505
+ * }
506
+ * })
507
+ * ```
508
+ */
509
+ setEventListener(setup) {
510
+ this.#setup = setup;
511
+ this.#cleanup?.();
512
+ this.#cleanup = setup((focused) => {
513
+ if (typeof focused === "boolean") this.setFocused(focused);
514
+ else this.onFocus();
296
515
  });
297
- resolve(value);
298
- };
299
- thenable.reject = (reason) => {
300
- finalize({
301
- status: "rejected",
302
- reason
516
+ }
517
+ /**
518
+ * `setFocused` can be used to manually set the focus state. Set `undefined`
519
+ * to fall back to the default focus check.
520
+ *
521
+ * @example
522
+ * ```ts
523
+ * import { focusManager } from '@tanstack/query-core'
524
+ *
525
+ * // Set focused
526
+ * focusManager.setFocused(true)
527
+ *
528
+ * // Set unfocused
529
+ * focusManager.setFocused(false)
530
+ *
531
+ * // Fallback to the default focus check
532
+ * focusManager.setFocused(undefined)
533
+ * ```
534
+ */
535
+ setFocused(focused) {
536
+ if (this.#focused !== focused) {
537
+ this.#focused = focused;
538
+ this.onFocus();
539
+ }
540
+ }
541
+ /**
542
+ * `onFocus` notifies all subscribed listeners with the current focus state.
543
+ */
544
+ onFocus() {
545
+ const isFocused = this.isFocused();
546
+ this.listeners.forEach((listener) => {
547
+ listener(isFocused);
303
548
  });
304
- reject(reason);
305
- };
306
- return thenable;
307
- }
549
+ }
550
+ /**
551
+ * `isFocused` can be used to get the current focus state.
552
+ */
553
+ isFocused() {
554
+ if (typeof this.#focused === "boolean") return this.#focused;
555
+ return globalThis.document?.visibilityState !== "hidden";
556
+ }
557
+ };
558
+ /**
559
+ * Singleton instance of {@link FocusManager}, used to manage and observe the focus state within TanStack Query.
560
+ */
561
+ var focusManager = new FocusManager();
562
+ //#endregion
563
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/hydration.js
308
564
  function tryResolveSync(promise) {
309
565
  let data;
310
566
  promise.then((result) => {
311
567
  data = result;
312
568
  return result;
313
- }, noop)?.catch(noop);
569
+ }, noop)?.catch?.(noop);
314
570
  if (data !== void 0) return { data };
315
571
  }
316
- //#endregion
317
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/hydration.js
318
- function defaultTransformerFn(data) {
319
- return data;
320
- }
321
- function dehydrateMutation(mutation) {
322
- return {
323
- mutationKey: mutation.options.mutationKey,
324
- state: mutation.state,
325
- ...mutation.options.scope && { scope: mutation.options.scope },
326
- ...mutation.meta && { meta: mutation.meta }
327
- };
572
+ function dehydratePromise(query, serializeData, shouldRedactErrors) {
573
+ const promise = query.promise?.then(serializeData).catch((error) => {
574
+ if (shouldRedactErrors?.(error) === false) return Promise.reject(error);
575
+ return Promise.reject(/* @__PURE__ */ new Error("redacted"));
576
+ });
577
+ promise?.catch(noop);
578
+ return promise;
328
579
  }
580
+ /**
581
+ * Dehydrates a single `Query` into a serializable `DehydratedQuery` snapshot. Note that most query config (e.g.
582
+ * `queryFn`, `staleTime`) is not dehydrated but instead meant to be configured again when consuming the
583
+ * de/rehydrated data, typically with `useQuery` on the client. If the query is still `pending`, its in-flight
584
+ * promise is dehydrated too so it can be resumed on the other side instead of re-fetched.
585
+ * @param query - The query to dehydrate.
586
+ * @param serializeData - Optional transform applied to `query.state.data` before it is included in the snapshot.
587
+ * @param shouldRedactErrors - Optional predicate; if it returns `false` for the promise's rejection error, that
588
+ * error is kept as-is instead of being redacted.
589
+ */
329
590
  function dehydrateQuery(query, serializeData, shouldRedactErrors) {
330
- const dehydratePromise = () => {
331
- const promise = query.promise?.then(serializeData).catch((error) => {
332
- if (!shouldRedactErrors(error)) return Promise.reject(error);
333
- return Promise.reject(/* @__PURE__ */ new Error("redacted"));
334
- });
335
- promise?.catch(noop);
336
- return promise;
337
- };
338
591
  return {
339
592
  dehydratedAt: Date.now(),
340
593
  state: {
341
594
  ...query.state,
342
- ...query.state.data !== void 0 && { data: serializeData(query.state.data) }
595
+ ...query.state.data !== void 0 && { data: serializeData ? serializeData(query.state.data) : query.state.data }
343
596
  },
344
597
  queryKey: query.queryKey,
345
598
  queryHash: query.queryHash,
346
- ...query.state.status === "pending" && { promise: dehydratePromise() },
599
+ ...query.state.status === "pending" && { promise: dehydratePromise(query, serializeData, shouldRedactErrors) },
347
600
  ...query.meta && { meta: query.meta },
348
601
  ...query.queryType && { queryType: query.queryType }
349
602
  };
350
603
  }
351
- function defaultShouldDehydrateMutation(mutation) {
352
- return mutation.state.isPaused;
353
- }
354
- function defaultShouldDehydrateQuery(query) {
355
- return query.state.status === "success";
356
- }
357
- function defaultShouldRedactErrors(_) {
358
- return true;
359
- }
360
- function dehydrate(client, options = {}) {
361
- const filterMutation = options.shouldDehydrateMutation ?? client.getDefaultOptions().dehydrate?.shouldDehydrateMutation ?? defaultShouldDehydrateMutation;
362
- const mutations = client.getMutationCache().getAll().flatMap((mutation) => filterMutation(mutation) ? [dehydrateMutation(mutation)] : []);
363
- const filterQuery = options.shouldDehydrateQuery ?? client.getDefaultOptions().dehydrate?.shouldDehydrateQuery ?? defaultShouldDehydrateQuery;
364
- const shouldRedactErrors = options.shouldRedactErrors ?? client.getDefaultOptions().dehydrate?.shouldRedactErrors ?? defaultShouldRedactErrors;
365
- const serializeData = options.serializeData ?? client.getDefaultOptions().dehydrate?.serializeData ?? defaultTransformerFn;
366
- return {
367
- mutations,
368
- queries: client.getQueryCache().getAll().flatMap((query) => filterQuery(query) ? [dehydrateQuery(query, serializeData, shouldRedactErrors)] : [])
369
- };
370
- }
604
+ /**
605
+ * Restores a `DehydratedState` (as produced by `dehydrate`) into a `QueryClient`'s cache, typically to seed the
606
+ * client with data already fetched on the server. `mutations` and `queries` are each optional on `dehydratedState`.
607
+ * Queries not yet in the cache are built from the dehydrated snapshot; queries that already exist are only updated
608
+ * when the dehydrated data is newer than what's already cached. Newly built queries have their `fetchStatus` reset
609
+ * to `'idle'` so they don't hydrate stuck in a fetching state. If a dehydrated query still had an in-flight
610
+ * promise, it is resumed via `query.fetch()` (reusing that promise as `initialPromise`) rather than re-invoking
611
+ * `queryFn`.
612
+ * @example
613
+ * ```ts
614
+ * // dehydratedState was produced by `dehydrate` on the server
615
+ * // and sent to the client, e.g. embedded in server-rendered markup.
616
+ * const queryClient = new QueryClient()
617
+ *
618
+ * hydrate(queryClient, dehydratedState)
619
+ * ```
620
+ */
371
621
  function hydrate(client, dehydratedState, options) {
372
- if (typeof dehydratedState !== "object" || dehydratedState === null) return;
373
622
  const mutationCache = client.getMutationCache();
374
623
  const queryCache = client.getQueryCache();
375
- const deserializeData = options?.defaultOptions?.deserializeData ?? client.getDefaultOptions().hydrate?.deserializeData ?? defaultTransformerFn;
376
- const mutations = dehydratedState.mutations || [];
377
- const queries = dehydratedState.queries || [];
378
- mutations.forEach(({ state, ...mutationOptions }) => {
624
+ const deserializeData = options?.defaultOptions?.deserializeData ?? client.getDefaultOptions().hydrate?.deserializeData;
625
+ dehydratedState.mutations?.forEach(({ state, ...mutationOptions }) => {
379
626
  mutationCache.build(client, {
380
627
  ...client.getDefaultOptions().hydrate?.mutations,
381
628
  ...options?.defaultOptions?.mutations,
382
629
  ...mutationOptions
383
630
  }, state);
384
631
  });
385
- queries.forEach(({ queryKey, state, queryHash, meta, promise, dehydratedAt, queryType }) => {
632
+ dehydratedState.queries?.forEach(({ queryKey, state, queryHash, meta, promise, dehydratedAt, queryType }) => {
386
633
  const syncData = promise ? tryResolveSync(promise) : void 0;
387
634
  const rawData = state.data === void 0 ? syncData?.data : state.data;
388
- const data = rawData === void 0 ? rawData : deserializeData(rawData);
635
+ const data = rawData === void 0 ? rawData : deserializeData ? deserializeData(rawData) : rawData;
389
636
  let query = queryCache.get(queryHash);
390
637
  const existingQueryIsPending = query?.state.status === "pending";
391
638
  const existingQueryIsFetching = query?.state.fetchStatus === "fetching";
392
639
  if (query) {
393
- const hasNewerSyncData = syncData && dehydratedAt !== void 0 && dehydratedAt > query.state.dataUpdatedAt;
640
+ const hasNewerSyncData = syncData && dehydratedAt > query.state.dataUpdatedAt;
394
641
  if (state.dataUpdatedAt > query.state.dataUpdatedAt || hasNewerSyncData) {
395
642
  const { fetchStatus: _ignored, ...serializedState } = state;
396
643
  query.setState({
@@ -398,6 +645,7 @@ function hydrate(client, dehydratedState, options) {
398
645
  data,
399
646
  ...state.status === "pending" && data !== void 0 && {
400
647
  status: "success",
648
+ dataUpdatedAt: dehydratedAt,
401
649
  ...!existingQueryIsFetching && { fetchStatus: "idle" }
402
650
  }
403
651
  });
@@ -413,13 +661,18 @@ function hydrate(client, dehydratedState, options) {
413
661
  ...state,
414
662
  data,
415
663
  fetchStatus: "idle",
416
- status: state.status === "pending" && data !== void 0 ? "success" : state.status
664
+ status: state.status === "pending" && data !== void 0 ? "success" : state.status,
665
+ ...state.status === "pending" && data !== void 0 && { dataUpdatedAt: dehydratedAt }
417
666
  });
418
- if (promise && !syncData && !existingQueryIsPending && !existingQueryIsFetching && (dehydratedAt === void 0 || dehydratedAt > query.state.dataUpdatedAt)) query.fetch(void 0, { initialPromise: Promise.resolve(promise).then(deserializeData) }).catch(noop);
667
+ if (promise && !syncData && !existingQueryIsPending && !existingQueryIsFetching && dehydratedAt > query.state.dataUpdatedAt) query.fetch(void 0, { initialPromise: Promise.resolve(promise).then(deserializeData) }).catch(noop);
419
668
  });
420
669
  }
421
670
  //#endregion
422
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/notifyManager.js
671
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/notifyManager.js
672
+ /**
673
+ * Default scheduling function used by the notify manager.
674
+ * Schedules the callback with the system's `setTimeout(callback, 0)`.
675
+ */
423
676
  var defaultScheduler = systemSetTimeoutZero;
424
677
  function createNotifyManager() {
425
678
  let queue = [];
@@ -479,9 +732,21 @@ function createNotifyManager() {
479
732
  }
480
733
  };
481
734
  }
735
+ /**
736
+ * Handles scheduling and batching callbacks in TanStack Query.
737
+ */
482
738
  var notifyManager = createNotifyManager();
483
739
  //#endregion
484
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/onlineManager.js
740
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/onlineManager.js
741
+ /**
742
+ * The `OnlineManager` manages the online state within TanStack Query. It can
743
+ * be used to change the default event listeners or to manually change the
744
+ * online state.
745
+ *
746
+ * By default, the `onlineManager` assumes an active network connection, and
747
+ * listens to the `online` and `offline` events on the `window` object to
748
+ * detect changes.
749
+ */
485
750
  var OnlineManager = class extends Subscribable {
486
751
  #online = true;
487
752
  #cleanup;
@@ -510,11 +775,43 @@ var OnlineManager = class extends Subscribable {
510
775
  this.#cleanup = void 0;
511
776
  }
512
777
  }
778
+ /**
779
+ * `setEventListener` can be used to set a custom event listener that will
780
+ * be used to determine the online state. The provided `setup` function
781
+ * receives a `setOnline` callback that should be called with a `boolean`
782
+ * whenever the online state changes.
783
+ *
784
+ * @example
785
+ * ```ts
786
+ * import NetInfo from '@react-native-community/netinfo'
787
+ * import { onlineManager } from '@tanstack/query-core'
788
+ *
789
+ * onlineManager.setEventListener((setOnline) => {
790
+ * return NetInfo.addEventListener((state) => {
791
+ * setOnline(!!state.isConnected)
792
+ * })
793
+ * })
794
+ * ```
795
+ */
513
796
  setEventListener(setup) {
514
797
  this.#setup = setup;
515
798
  this.#cleanup?.();
516
799
  this.#cleanup = setup(this.setOnline.bind(this));
517
800
  }
801
+ /**
802
+ * `setOnline` can be used to manually set the online state.
803
+ *
804
+ * @example
805
+ * ```ts
806
+ * import { onlineManager } from '@tanstack/query-core'
807
+ *
808
+ * // Set to online
809
+ * onlineManager.setOnline(true)
810
+ *
811
+ * // Set to offline
812
+ * onlineManager.setOnline(false)
813
+ * ```
814
+ */
518
815
  setOnline(online) {
519
816
  if (this.#online !== online) {
520
817
  this.#online = online;
@@ -523,19 +820,43 @@ var OnlineManager = class extends Subscribable {
523
820
  });
524
821
  }
525
822
  }
823
+ /**
824
+ * `isOnline` can be used to get the current online state.
825
+ */
526
826
  isOnline() {
527
827
  return this.#online;
528
828
  }
529
829
  };
830
+ /**
831
+ * Singleton instance of {@link OnlineManager}, used to manage and observe the online state within TanStack Query.
832
+ */
530
833
  var onlineManager = new OnlineManager();
531
834
  //#endregion
532
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/retryer.js
835
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/retryer.js
533
836
  function defaultRetryDelay(failureCount) {
534
837
  return Math.min(1e3 * 2 ** failureCount, 3e4);
535
838
  }
536
839
  function canFetch(networkMode) {
537
840
  return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
538
841
  }
842
+ /**
843
+ * The error thrown by a `Retryer` (and surfaced to `query.promise`/`mutation`) when a fetch is cancelled, e.g. via
844
+ * `query.cancel()`. `revert`, if `true`, tells the caller to restore the state the query was in before the fetch
845
+ * started instead of surfacing the error. `silent`, if `true`, tells the caller to suppress this error and instead
846
+ * resolve with the promise of the fetch that triggered the cancellation.
847
+ * @example
848
+ * ```ts
849
+ * query.cancel()
850
+ *
851
+ * try {
852
+ * await query.promise
853
+ * } catch (error) {
854
+ * if (error instanceof CancelledError) {
855
+ * // the fetch was cancelled, e.g. via `query.cancel()`
856
+ * }
857
+ * }
858
+ * ```
859
+ */
539
860
  var CancelledError = class extends Error {
540
861
  constructor(options) {
541
862
  super("CancelledError");
@@ -547,8 +868,15 @@ function createRetryer(config) {
547
868
  let isRetryCancelled = false;
548
869
  let failureCount = 0;
549
870
  let continueFn;
550
- const thenable = pendingThenable();
551
- const isResolved = () => thenable.status !== "pending";
871
+ let status = "pending";
872
+ let promiseResolve;
873
+ let promiseReject;
874
+ const promise = new Promise((resolve, reject) => {
875
+ promiseResolve = resolve;
876
+ promiseReject = reject;
877
+ });
878
+ promise.catch(noop);
879
+ const isResolved = () => status !== "pending";
552
880
  const cancel = (cancelOptions) => {
553
881
  if (!isResolved()) {
554
882
  const error = new CancelledError(cancelOptions);
@@ -567,13 +895,15 @@ function createRetryer(config) {
567
895
  const resolve = (value) => {
568
896
  if (!isResolved()) {
569
897
  continueFn?.();
570
- thenable.resolve(value);
898
+ status = "resolved";
899
+ promiseResolve(value);
571
900
  }
572
901
  };
573
902
  const reject = (value) => {
574
903
  if (!isResolved()) {
575
904
  continueFn?.();
576
- thenable.reject(value);
905
+ status = "rejected";
906
+ promiseReject(value);
577
907
  }
578
908
  };
579
909
  const pause = () => {
@@ -598,7 +928,7 @@ function createRetryer(config) {
598
928
  }
599
929
  Promise.resolve(promiseOrValue).then(resolve).catch((error) => {
600
930
  if (isResolved()) return;
601
- const retry = config.retry ?? (environmentManager.isServer() ? 0 : 3);
931
+ const retry = config.retry ?? (isServer() ? 0 : 3);
602
932
  const retryDelay = config.retryDelay ?? defaultRetryDelay;
603
933
  const delay = typeof retryDelay === "function" ? retryDelay(failureCount, error) : retryDelay;
604
934
  const shouldRetry = retry === true || typeof retry === "number" && failureCount < retry || typeof retry === "function" && retry(failureCount, error);
@@ -617,12 +947,12 @@ function createRetryer(config) {
617
947
  });
618
948
  };
619
949
  return {
620
- promise: thenable,
621
- status: () => thenable.status,
950
+ promise,
951
+ status: () => status,
622
952
  cancel,
623
953
  continue: () => {
624
954
  continueFn?.();
625
- return thenable;
955
+ return promise;
626
956
  },
627
957
  cancelRetry,
628
958
  continueRetry,
@@ -630,14 +960,23 @@ function createRetryer(config) {
630
960
  start: () => {
631
961
  if (canStart()) run();
632
962
  else pause().then(run);
633
- return thenable;
963
+ return promise;
634
964
  }
635
965
  };
636
966
  }
637
967
  //#endregion
638
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/removable.js
968
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/removable.js
969
+ /**
970
+ * The base class for cache entries that are garbage collected once nothing is using them —
971
+ * `Query` and `Mutation` both extend it. `gcTime` controls how long an unused entry is kept.
972
+ */
639
973
  var Removable = class {
640
974
  #gcTimeout;
975
+ /**
976
+ * Clears the pending garbage collection timeout, so the entry is no longer scheduled for removal.
977
+ * A subclass may override this to release what it holds on to as well — `Query` also cancels any
978
+ * in-flight fetch.
979
+ */
641
980
  destroy() {
642
981
  this.clearGcTimeout();
643
982
  }
@@ -648,7 +987,7 @@ var Removable = class {
648
987
  }, this.gcTime);
649
988
  }
650
989
  updateGcTime(newGcTime) {
651
- this.gcTime = Math.max(this.gcTime || 0, newGcTime ?? (environmentManager.isServer() ? Infinity : 300 * 1e3));
990
+ this.gcTime = Math.max(this.gcTime || 0, newGcTime ?? (isServer() ? Infinity : 3e5));
652
991
  }
653
992
  clearGcTimeout() {
654
993
  if (this.#gcTimeout !== void 0) {
@@ -658,7 +997,7 @@ var Removable = class {
658
997
  }
659
998
  };
660
999
  //#endregion
661
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js
1000
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js
662
1001
  function infiniteQueryBehavior(pages) {
663
1002
  return { onFetch: (context, query) => {
664
1003
  const options = context.options;
@@ -680,15 +1019,15 @@ function infiniteQueryBehavior(pages) {
680
1019
  if (cancelled) return Promise.reject(context.signal.reason);
681
1020
  if (param == null && data.pages.length) return Promise.resolve(data);
682
1021
  const createQueryFnContext = () => {
683
- const queryFnContext2 = {
1022
+ const queryFnContext = {
684
1023
  client: context.client,
685
1024
  queryKey: context.queryKey,
686
1025
  pageParam: param,
687
1026
  direction: previous ? "backward" : "forward",
688
1027
  meta: context.options.meta
689
1028
  };
690
- addSignalProperty(queryFnContext2);
691
- return queryFnContext2;
1029
+ addSignalProperty(queryFnContext);
1030
+ return queryFnContext;
692
1031
  };
693
1032
  const page = await queryFn(createQueryFnContext());
694
1033
  const { maxPages } = context.options;
@@ -735,8 +1074,41 @@ function getNextPageParam(options, { pages, pageParams }) {
735
1074
  function getPreviousPageParam(options, { pages, pageParams }) {
736
1075
  return pages.length > 0 ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams) : void 0;
737
1076
  }
1077
+ /**
1078
+ * Checks if there is a next page.
1079
+ */
1080
+ function hasNextPage(options, data) {
1081
+ if (!data) return false;
1082
+ return getNextPageParam(options, data) != null;
1083
+ }
1084
+ /**
1085
+ * Checks if there is a previous page.
1086
+ */
1087
+ function hasPreviousPage(options, data) {
1088
+ if (!data || !options.getPreviousPageParam) return false;
1089
+ return getPreviousPageParam(options, data) != null;
1090
+ }
738
1091
  //#endregion
739
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/query.js
1092
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/query.js
1093
+ /**
1094
+ * Represents a single cached query. A `Query` holds the query's key, options,
1095
+ * state (data/error/status), and the observers currently subscribed to it.
1096
+ *
1097
+ * Instances are created and managed internally by `QueryCache`; application
1098
+ * code typically interacts with queries indirectly through `QueryClient` or
1099
+ * a framework hook like `useQuery`. Direct access to a `Query` instance is
1100
+ * possible via `queryCache.find()`/`findAll()` for inspecting cache state.
1101
+ *
1102
+ * @example
1103
+ * ```ts
1104
+ * const queryCache = queryClient.getQueryCache()
1105
+ * const query = queryCache.find({ queryKey: ['posts'] })
1106
+ *
1107
+ * if (query) {
1108
+ * console.log(query.state.dataUpdatedAt)
1109
+ * }
1110
+ * ```
1111
+ */
740
1112
  var Query = class extends Removable {
741
1113
  #queryType;
742
1114
  #initialState;
@@ -760,15 +1132,24 @@ var Query = class extends Removable {
760
1132
  this.state = config.state ?? this.#initialState;
761
1133
  this.scheduleGc();
762
1134
  }
1135
+ /**
1136
+ * The `meta` object passed in the query's options, if any.
1137
+ */
763
1138
  get meta() {
764
1139
  return this.options.meta;
765
1140
  }
1141
+ /** @internal */
766
1142
  get queryType() {
767
1143
  return this.#queryType;
768
1144
  }
1145
+ /**
1146
+ * The promise for the currently in-flight fetch, if the query is fetching.
1147
+ * `undefined` when the query is not fetching.
1148
+ */
769
1149
  get promise() {
770
1150
  return this.#retryer?.promise;
771
1151
  }
1152
+ /** @internal */
772
1153
  setOptions(options) {
773
1154
  this.options = {
774
1155
  ...this.#defaultOptions,
@@ -787,6 +1168,7 @@ var Query = class extends Removable {
787
1168
  optionalRemove() {
788
1169
  if (!this.observers.length && this.state.fetchStatus === "idle") this.#cache.remove(this);
789
1170
  }
1171
+ /** @internal */
790
1172
  setData(newData, options) {
791
1173
  const data = replaceData(this.state.data, newData, this.options);
792
1174
  this.#dispatch({
@@ -797,60 +1179,141 @@ var Query = class extends Removable {
797
1179
  });
798
1180
  return data;
799
1181
  }
1182
+ /**
1183
+ * Merges the given partial state directly into this query's state, notifying observers. Used
1184
+ * by persistence and broadcast plugins to restore a state snapshot, and by devtools to let a
1185
+ * user manually trigger a loading/error state or edit the cached data.
1186
+ */
800
1187
  setState(state) {
801
1188
  this.#dispatch({
802
1189
  type: "setState",
803
1190
  state
804
1191
  });
805
1192
  }
1193
+ /**
1194
+ * Cancels the query's currently in-flight fetch, if any.
1195
+ * - Returns a promise that resolves once the cancellation has settled.
1196
+ * - If no fetch is in progress, resolves immediately.
1197
+ *
1198
+ * @example
1199
+ * ```ts
1200
+ * await query.cancel()
1201
+ * ```
1202
+ */
806
1203
  cancel(options) {
807
1204
  const promise = this.#retryer?.promise;
808
1205
  this.#retryer?.cancel(options);
809
1206
  return promise ? promise.then(noop).catch(noop) : Promise.resolve();
810
1207
  }
1208
+ /**
1209
+ * Clears the query's garbage collection timeout and silently cancels any
1210
+ * in-flight fetch. Called by `QueryCache` when the query is removed from
1211
+ * the cache.
1212
+ *
1213
+ * @see {@link Query#cancel}
1214
+ */
811
1215
  destroy() {
812
1216
  super.destroy();
813
1217
  this.cancel({ silent: true });
814
1218
  }
1219
+ /** @internal */
815
1220
  get resetState() {
816
1221
  return this.#initialState;
817
1222
  }
1223
+ /**
1224
+ * Resets the query back to its initial state (the state it had when it was
1225
+ * first created, e.g. any `initialData`), destroying it first to cancel any
1226
+ * in-flight fetch.
1227
+ */
818
1228
  reset() {
819
1229
  this.destroy();
820
1230
  this.setState(this.resetState);
821
1231
  }
1232
+ /**
1233
+ * Returns `true` if the query has at least one observer for which `enabled`
1234
+ * does not resolve to `false`.
1235
+ */
822
1236
  isActive() {
823
- return this.observers.some((observer) => resolveQueryBoolean(observer.options.enabled, this) !== false);
1237
+ return this.observers.some((observer) => resolveQueryValue(observer.options.enabled, this) !== false);
824
1238
  }
1239
+ /**
1240
+ * Returns `true` if the query is disabled, meaning it will not fetch
1241
+ * automatically.
1242
+ * - If the query has observers, it is disabled when none of them are active
1243
+ * (see `isActive`).
1244
+ * - If the query has no observers, it is disabled when its `queryFn` is
1245
+ * `skipToken` or it has never been fetched.
1246
+ */
825
1247
  isDisabled() {
826
1248
  if (this.getObserversCount() > 0) return !this.isActive();
827
1249
  return this.options.queryFn === skipToken || !this.isFetched();
828
1250
  }
1251
+ /**
1252
+ * Returns `true` if the query has been fetched, i.e. it has resolved with
1253
+ * either data or an error at least once.
1254
+ */
829
1255
  isFetched() {
830
1256
  return this.state.dataUpdateCount + this.state.errorUpdateCount > 0;
831
1257
  }
1258
+ /**
1259
+ * Returns `true` if the query has at least one observer configured with
1260
+ * `staleTime: 'static'`, meaning it is treated as never stale.
1261
+ */
832
1262
  isStatic() {
833
- if (this.getObserversCount() > 0) return this.observers.some((observer) => resolveStaleTime(observer.options.staleTime, this) === "static");
1263
+ if (this.getObserversCount() > 0) return this.observers.some((observer) => resolveQueryValue(observer.options.staleTime, this) === "static");
834
1264
  return false;
835
1265
  }
1266
+ /**
1267
+ * Returns `true` if the query is stale.
1268
+ * - If the query has observers, defers to whether any observer's current
1269
+ * result reports `isStale` (which accounts for each observer's own
1270
+ * `staleTime` and `enabled` state).
1271
+ * - If the query has no observers, it is considered stale when it has no
1272
+ * data or has been invalidated.
1273
+ *
1274
+ * @see {@link Query#isStaleByTime}
1275
+ * @example
1276
+ * ```ts
1277
+ * if (query.isStale()) {
1278
+ * // refetch or otherwise treat the cached data as outdated
1279
+ * }
1280
+ * ```
1281
+ */
836
1282
  isStale() {
837
1283
  if (this.getObserversCount() > 0) return this.observers.some((observer) => observer.getCurrentResult().isStale);
838
1284
  return this.state.data === void 0 || this.state.isInvalidated;
839
1285
  }
1286
+ /**
1287
+ * Returns `true` if the query's data is stale relative to the given
1288
+ * `staleTime` (defaults to `0`).
1289
+ * - A query with no data is always stale.
1290
+ * - `staleTime: 'static'` is never stale.
1291
+ * - An invalidated query is always stale.
1292
+ * - Otherwise, staleness is based on elapsed time since `dataUpdatedAt`.
1293
+ *
1294
+ * @see {@link Query#isStale}
1295
+ * @example
1296
+ * ```ts
1297
+ * const isStale = query.isStaleByTime(1000 * 60)
1298
+ * ```
1299
+ */
840
1300
  isStaleByTime(staleTime = 0) {
841
1301
  if (this.state.data === void 0) return true;
842
1302
  if (staleTime === "static") return false;
843
1303
  if (this.state.isInvalidated) return true;
844
1304
  return !timeUntilStale(this.state.dataUpdatedAt, staleTime);
845
1305
  }
1306
+ /** @internal */
846
1307
  onFocus() {
847
1308
  this.observers.find((x) => x.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: false });
848
1309
  this.#retryer?.continue();
849
1310
  }
1311
+ /** @internal */
850
1312
  onOnline() {
851
1313
  this.observers.find((x) => x.shouldFetchOnReconnect())?.refetch({ cancelRefetch: false });
852
1314
  this.#retryer?.continue();
853
1315
  }
1316
+ /** @internal */
854
1317
  addObserver(observer) {
855
1318
  if (!this.observers.includes(observer)) {
856
1319
  this.observers.push(observer);
@@ -862,11 +1325,13 @@ var Query = class extends Removable {
862
1325
  });
863
1326
  }
864
1327
  }
1328
+ /** @internal */
865
1329
  removeObserver(observer) {
866
- if (this.observers.includes(observer)) {
867
- this.observers = this.observers.filter((x) => x !== observer);
1330
+ const index = this.observers.indexOf(observer);
1331
+ if (index !== -1) {
1332
+ this.observers.splice(index, 1);
868
1333
  if (!this.observers.length) {
869
- if (this.#retryer) if (this.#abortSignalConsumed || this.#isInitialPausedFetch()) this.#retryer.cancel({ revert: true });
1334
+ if (this.#retryer) if (this.#abortSignalConsumed || this.state.fetchStatus === "paused" && this.state.status === "pending") this.#retryer.cancel({ revert: true });
870
1335
  else this.#retryer.cancelRetry();
871
1336
  this.scheduleGc();
872
1337
  }
@@ -877,15 +1342,42 @@ var Query = class extends Removable {
877
1342
  });
878
1343
  }
879
1344
  }
1345
+ /**
1346
+ * Returns the number of observers currently subscribed to this query.
1347
+ *
1348
+ * @example
1349
+ * ```ts
1350
+ * if (query.getObserversCount() === 0) {
1351
+ * // no component is currently watching this query
1352
+ * }
1353
+ * ```
1354
+ */
880
1355
  getObserversCount() {
881
1356
  return this.observers.length;
882
1357
  }
883
- #isInitialPausedFetch() {
884
- return this.state.fetchStatus === "paused" && this.state.status === "pending";
885
- }
1358
+ /**
1359
+ * Marks the query as invalidated, unless it is already invalidated. This
1360
+ * updates `state.isInvalidated` and notifies observers, but does not by
1361
+ * itself trigger a refetch.
1362
+ *
1363
+ * @example
1364
+ * ```ts
1365
+ * query.invalidate()
1366
+ * ```
1367
+ */
886
1368
  invalidate() {
887
1369
  if (!this.state.isInvalidated) this.#dispatch({ type: "invalidate" });
888
1370
  }
1371
+ /**
1372
+ * Fetches the query, i.e. runs its `queryFn` (through any configured
1373
+ * retryer/behavior) and updates the query's state with the result.
1374
+ * - If a fetch is already in flight, returns its promise instead of
1375
+ * starting a new one, unless `fetchOptions.cancelRefetch` is set and the
1376
+ * query already has data, in which case the current fetch is silently
1377
+ * cancelled first.
1378
+ * - If `options` is passed, it replaces the query's current options
1379
+ * before fetching.
1380
+ */
889
1381
  async fetch(options, fetchOptions) {
890
1382
  if (this.state.fetchStatus !== "idle" && this.#retryer?.status() !== "rejected") {
891
1383
  if (this.state.data !== void 0 && fetchOptions?.cancelRefetch) this.cancel({ silent: true });
@@ -912,13 +1404,13 @@ var Query = class extends Removable {
912
1404
  const fetchFn = () => {
913
1405
  const queryFn = ensureQueryFn(this.options, fetchOptions);
914
1406
  const createQueryFnContext = () => {
915
- const queryFnContext2 = {
1407
+ const queryFnContext = {
916
1408
  client: this.#client,
917
1409
  queryKey: this.queryKey,
918
1410
  meta: this.meta
919
1411
  };
920
- addSignalProperty(queryFnContext2);
921
- return queryFnContext2;
1412
+ addSignalProperty(queryFnContext);
1413
+ return queryFnContext;
922
1414
  };
923
1415
  const queryFnContext = createQueryFnContext();
924
1416
  this.#abortSignalConsumed = false;
@@ -926,7 +1418,7 @@ var Query = class extends Removable {
926
1418
  return queryFn(queryFnContext);
927
1419
  };
928
1420
  const createFetchContext = () => {
929
- const context2 = {
1421
+ const context = {
930
1422
  fetchOptions,
931
1423
  options: this.options,
932
1424
  queryKey: this.queryKey,
@@ -934,8 +1426,8 @@ var Query = class extends Removable {
934
1426
  state: this.state,
935
1427
  fetchFn
936
1428
  };
937
- addSignalProperty(context2);
938
- return context2;
1429
+ addSignalProperty(context);
1430
+ return context;
939
1431
  };
940
1432
  const context = createFetchContext();
941
1433
  (this.#queryType === "infinite" ? infiniteQueryBehavior(this.options.pages) : this.options.behavior)?.onFetch(context, this);
@@ -944,7 +1436,7 @@ var Query = class extends Removable {
944
1436
  type: "fetch",
945
1437
  meta: context.fetchOptions?.meta
946
1438
  });
947
- this.#retryer = createRetryer({
1439
+ const retryer = this.#retryer = createRetryer({
948
1440
  initialPromise: fetchOptions?.initialPromise,
949
1441
  fn: context.fetchFn,
950
1442
  onCancel: (error) => {
@@ -973,7 +1465,7 @@ var Query = class extends Removable {
973
1465
  canRun: () => true
974
1466
  });
975
1467
  try {
976
- const data = await this.#retryer.start();
1468
+ const data = await retryer.start();
977
1469
  if (data === void 0) throw new Error(`${this.queryHash} data is undefined`);
978
1470
  this.setData(data);
979
1471
  this.#cache.config.onSuccess?.(data, this);
@@ -995,6 +1487,7 @@ var Query = class extends Removable {
995
1487
  this.#cache.config.onSettled?.(this.state.data, error, this);
996
1488
  throw error;
997
1489
  } finally {
1490
+ if (this.#retryer === retryer) this.#retryer = void 0;
998
1491
  this.scheduleGc();
999
1492
  }
1000
1493
  }
@@ -1057,7 +1550,7 @@ var Query = class extends Removable {
1057
1550
  };
1058
1551
  this.state = reducer(this.state);
1059
1552
  notifyManager.batch(() => {
1060
- this.observers.forEach((observer) => {
1553
+ this.observers.slice().forEach((observer) => {
1061
1554
  observer.onQueryUpdate();
1062
1555
  });
1063
1556
  this.#cache.notify({
@@ -1108,24 +1601,34 @@ function getDefaultState$1(options) {
1108
1601
  };
1109
1602
  }
1110
1603
  //#endregion
1111
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/queryObserver.js
1604
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/queryObserver.js
1605
+ /**
1606
+ * A `QueryObserver` watches a single query in the `QueryCache` and computes a
1607
+ * `QueryObserverResult` from its state, recomputing and notifying subscribers
1608
+ * whenever the underlying query (or the observer's options) changes. It is
1609
+ * the primitive that framework adapters (e.g. `useQuery`) build their hooks
1610
+ * on top of, but it can also be used directly to observe and switch between
1611
+ * queries outside of any framework.
1612
+ *
1613
+ * @example
1614
+ * ```ts
1615
+ * const observer = new QueryObserver(queryClient, {
1616
+ * queryKey: ['posts'],
1617
+ * queryFn: fetchPosts,
1618
+ * })
1619
+ *
1620
+ * const unsubscribe = observer.subscribe((result) => {
1621
+ * console.log(result.data)
1622
+ * })
1623
+ * ```
1624
+ */
1112
1625
  var QueryObserver = class extends Subscribable {
1113
- constructor(client, options) {
1114
- super();
1115
- this.options = options;
1116
- this.#client = client;
1117
- this.#selectError = null;
1118
- this.#currentThenable = pendingThenable();
1119
- this.bindMethods();
1120
- this.setOptions(options);
1121
- }
1122
1626
  #client;
1123
1627
  #currentQuery = void 0;
1124
1628
  #currentQueryInitialState = void 0;
1125
1629
  #currentResult = void 0;
1126
1630
  #currentResultState;
1127
1631
  #currentResultOptions;
1128
- #currentThenable;
1129
1632
  #selectError;
1130
1633
  #selectFn;
1131
1634
  #selectResult;
@@ -1134,6 +1637,14 @@ var QueryObserver = class extends Subscribable {
1134
1637
  #refetchIntervalId;
1135
1638
  #currentRefetchInterval;
1136
1639
  #trackedProps = /* @__PURE__ */ new Set();
1640
+ constructor(client, options) {
1641
+ super();
1642
+ this.options = options;
1643
+ this.#client = client;
1644
+ this.#selectError = null;
1645
+ this.bindMethods();
1646
+ this.setOptions(options);
1647
+ }
1137
1648
  bindMethods() {
1138
1649
  this.refetch = this.refetch.bind(this);
1139
1650
  }
@@ -1148,23 +1659,52 @@ var QueryObserver = class extends Subscribable {
1148
1659
  onUnsubscribe() {
1149
1660
  if (!this.hasListeners()) this.destroy();
1150
1661
  }
1662
+ /**
1663
+ * Returns whether the observed query is currently stale and configured
1664
+ * (via the `refetchOnReconnect` option) to refetch when the network
1665
+ * reconnects.
1666
+ */
1151
1667
  shouldFetchOnReconnect() {
1152
1668
  return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnReconnect);
1153
1669
  }
1670
+ /**
1671
+ * Returns whether the observed query is currently stale and configured
1672
+ * (via the `refetchOnWindowFocus` option) to refetch when the window
1673
+ * regains focus.
1674
+ */
1154
1675
  shouldFetchOnWindowFocus() {
1155
1676
  return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnWindowFocus);
1156
1677
  }
1678
+ /**
1679
+ * Stops observing the current query: clears all listeners, cancels the
1680
+ * stale and refetch-interval timers, and removes this observer from the
1681
+ * query it was observing.
1682
+ */
1157
1683
  destroy() {
1158
1684
  this.listeners = /* @__PURE__ */ new Set();
1159
1685
  this.#clearStaleTimeout();
1160
1686
  this.#clearRefetchInterval();
1161
1687
  this.#currentQuery.removeObserver(this);
1162
1688
  }
1689
+ /**
1690
+ * Updates the observer's options. This will re-resolve the query being
1691
+ * observed (switching to a different query if the `queryKey` changed),
1692
+ * trigger a fetch if the new options require one and the observer has
1693
+ * subscribers, recompute the current result, and reschedule the stale and
1694
+ * refetch-interval timers as needed.
1695
+ *
1696
+ * @example
1697
+ * ```ts
1698
+ * observer.setOptions({ queryKey: ['posts', 1], queryFn: () => fetchPost(1) })
1699
+ * // later: switch to a different query, reusing the same observer
1700
+ * observer.setOptions({ queryKey: ['posts', 2], queryFn: () => fetchPost(2) })
1701
+ * ```
1702
+ */
1163
1703
  setOptions(options) {
1164
1704
  const prevOptions = this.options;
1165
1705
  const prevQuery = this.#currentQuery;
1166
1706
  this.options = this.#client.defaultQueryOptions(options);
1167
- if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveQueryBoolean(this.options.enabled, this.#currentQuery) !== "boolean") throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");
1707
+ if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveQueryValue(this.options.enabled, this.#currentQuery) !== "boolean") throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");
1168
1708
  this.#updateQuery();
1169
1709
  this.#currentQuery.setOptions(this.options);
1170
1710
  if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) this.#client.getQueryCache().notify({
@@ -1175,47 +1715,119 @@ var QueryObserver = class extends Subscribable {
1175
1715
  const mounted = this.hasListeners();
1176
1716
  if (mounted && shouldFetchOptionally(this.#currentQuery, prevQuery, this.options, prevOptions)) this.#executeFetch();
1177
1717
  this.updateResult();
1178
- if (mounted && (this.#currentQuery !== prevQuery || resolveQueryBoolean(this.options.enabled, this.#currentQuery) !== resolveQueryBoolean(prevOptions.enabled, this.#currentQuery) || resolveStaleTime(this.options.staleTime, this.#currentQuery) !== resolveStaleTime(prevOptions.staleTime, this.#currentQuery))) this.#updateStaleTimeout();
1718
+ if (mounted && (this.#currentQuery !== prevQuery || resolveQueryValue(this.options.enabled, this.#currentQuery) !== resolveQueryValue(prevOptions.enabled, this.#currentQuery) || resolveQueryValue(this.options.staleTime, this.#currentQuery) !== resolveQueryValue(prevOptions.staleTime, this.#currentQuery))) this.#updateStaleTimeout();
1179
1719
  const nextRefetchInterval = this.#computeRefetchInterval();
1180
- if (mounted && (this.#currentQuery !== prevQuery || resolveQueryBoolean(this.options.enabled, this.#currentQuery) !== resolveQueryBoolean(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) this.#updateRefetchInterval(nextRefetchInterval);
1720
+ if (mounted && (this.#currentQuery !== prevQuery || resolveQueryValue(this.options.enabled, this.#currentQuery) !== resolveQueryValue(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) this.#updateRefetchInterval(nextRefetchInterval);
1181
1721
  }
1722
+ /**
1723
+ * Computes the result the observer would produce for the given (already-defaulted) options
1724
+ * right now, building the underlying `Query` if it doesn't exist yet, without waiting for a
1725
+ * subscription callback. Called by framework adapters on every render (e.g. `useQuery`) so the
1726
+ * returned value is available synchronously, ahead of `setOptions` triggering an actual fetch.
1727
+ */
1182
1728
  getOptimisticResult(options) {
1183
1729
  const query = this.#client.getQueryCache().build(this.#client, options);
1184
1730
  const result = this.createResult(query, options);
1185
- if (shouldAssignObserverCurrentProperties(this, result)) {
1731
+ if (!shallowEqualObjects(this.getCurrentResult(), result)) {
1186
1732
  this.#currentResult = result;
1187
1733
  this.#currentResultOptions = this.options;
1188
1734
  this.#currentResultState = this.#currentQuery.state;
1189
1735
  }
1190
1736
  return result;
1191
1737
  }
1738
+ /**
1739
+ * Returns the most recently computed `QueryObserverResult` for the
1740
+ * observed query. This is a point-in-time read; to be notified of updates
1741
+ * as they happen, subscribe to the observer instead (its inherited
1742
+ * `subscribe` method).
1743
+ *
1744
+ * @example
1745
+ * ```ts
1746
+ * const result = observer.getCurrentResult()
1747
+ * console.log(result.status, result.data)
1748
+ * ```
1749
+ */
1192
1750
  getCurrentResult() {
1193
1751
  return this.#currentResult;
1194
1752
  }
1753
+ /**
1754
+ * Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via
1755
+ * {@link QueryObserver#trackProp} (and an optional `onPropTracked` callback). Used by framework
1756
+ * adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on
1757
+ * properties you actually read" behavior.
1758
+ */
1195
1759
  trackResult(result, onPropTracked) {
1196
1760
  return new Proxy(result, { get: (target, key) => {
1197
1761
  this.trackProp(key);
1198
1762
  onPropTracked?.(key);
1199
- if (key === "promise") {
1200
- this.trackProp("data");
1201
- if (!this.options.experimental_prefetchInRender && this.#currentThenable.status === "pending") this.#currentThenable.reject(/* @__PURE__ */ new Error("experimental_prefetchInRender feature flag is not enabled"));
1202
- }
1203
1763
  return Reflect.get(target, key);
1204
1764
  } });
1205
1765
  }
1766
+ /**
1767
+ * Records that the given `QueryObserverResult` property was read, so a subsequent update only
1768
+ * notifies this observer if a tracked property actually changed. Normally called indirectly via
1769
+ * {@link QueryObserver#trackResult}'s proxy; exposed directly for adapters that track property
1770
+ * access themselves (e.g. through their own reactivity system) instead of via the proxy.
1771
+ */
1206
1772
  trackProp(key) {
1207
1773
  this.#trackedProps.add(key);
1208
1774
  }
1775
+ /**
1776
+ * Returns the `Query` instance this observer is currently observing.
1777
+ */
1209
1778
  getCurrentQuery() {
1210
1779
  return this.#currentQuery;
1211
1780
  }
1781
+ /**
1782
+ * Refetches the observed query and returns a promise that resolves with
1783
+ * the resulting `QueryObserverResult`.
1784
+ *
1785
+ * @example
1786
+ * ```ts
1787
+ * const result = await observer.refetch({ cancelRefetch: false })
1788
+ * console.log(result.data)
1789
+ * ```
1790
+ */
1212
1791
  refetch({ ...options } = {}) {
1213
1792
  return this.fetch({ ...options });
1214
1793
  }
1794
+ /**
1795
+ * Fetches a query defined by the given options without affecting this
1796
+ * observer's own tracked query or result, and returns a promise that
1797
+ * resolves with the `QueryObserverResult` for that fetch. This is useful
1798
+ * for prefetching data that another observer (e.g. a query about to be
1799
+ * navigated to) will need, ahead of time.
1800
+ *
1801
+ * @example
1802
+ * ```ts
1803
+ * const result = await observer.fetchOptimistic({
1804
+ * queryKey: ['posts', 2],
1805
+ * queryFn: () => fetchPost(2),
1806
+ * })
1807
+ * console.log(result.data)
1808
+ * ```
1809
+ */
1215
1810
  fetchOptimistic(options) {
1216
1811
  const defaultedOptions = this.#client.defaultQueryOptions(options);
1217
1812
  const query = this.#client.getQueryCache().build(this.#client, defaultedOptions);
1218
- return query.fetch().then(() => this.createResult(query, defaultedOptions));
1813
+ let unsubscribe = () => {};
1814
+ let resolveEarly;
1815
+ const cachePromise = new Promise((resolve) => {
1816
+ resolveEarly = resolve;
1817
+ unsubscribe = this.#client.getQueryCache().subscribe((event) => {
1818
+ if (event.type === "updated" && event.query.queryHash === query.queryHash && query.state.data !== void 0) {
1819
+ unsubscribe();
1820
+ resolve(this.createResult(query, defaultedOptions));
1821
+ }
1822
+ });
1823
+ });
1824
+ return Promise.race([query.fetch().then(() => {
1825
+ const result = this.createResult(query, defaultedOptions);
1826
+ resolveEarly?.(result);
1827
+ return result;
1828
+ }).finally(() => {
1829
+ unsubscribe();
1830
+ }), cachePromise]);
1219
1831
  }
1220
1832
  fetch(fetchOptions) {
1221
1833
  return this.#executeFetch({
@@ -1232,22 +1844,25 @@ var QueryObserver = class extends Subscribable {
1232
1844
  if (!fetchOptions?.throwOnError) promise = promise.catch(noop);
1233
1845
  return promise;
1234
1846
  }
1847
+ #shouldScheduleTimer(timeout) {
1848
+ return !isServer() && resolveQueryValue(this.options.enabled, this.#currentQuery) !== false && isValidTimeout(timeout);
1849
+ }
1235
1850
  #updateStaleTimeout() {
1236
1851
  this.#clearStaleTimeout();
1237
- const staleTime = resolveStaleTime(this.options.staleTime, this.#currentQuery);
1238
- if (environmentManager.isServer() || this.#currentResult.isStale || !isValidTimeout(staleTime)) return;
1852
+ const staleTime = resolveQueryValue(this.options.staleTime, this.#currentQuery);
1853
+ if (this.#currentResult.isStale || !this.#shouldScheduleTimer(staleTime)) return;
1239
1854
  const timeout = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime) + 1;
1240
1855
  this.#staleTimeoutId = timeoutManager.setTimeout(() => {
1241
1856
  if (!this.#currentResult.isStale) this.updateResult();
1242
1857
  }, timeout);
1243
1858
  }
1244
1859
  #computeRefetchInterval() {
1245
- return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false;
1860
+ return resolveQueryValue(this.options.refetchInterval, this.#currentQuery) ?? false;
1246
1861
  }
1247
1862
  #updateRefetchInterval(nextInterval) {
1248
1863
  this.#clearRefetchInterval();
1249
1864
  this.#currentRefetchInterval = nextInterval;
1250
- if (environmentManager.isServer() || resolveQueryBoolean(this.options.enabled, this.#currentQuery) === false || !isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) return;
1865
+ if (this.#currentRefetchInterval === 0 || !this.#shouldScheduleTimer(this.#currentRefetchInterval)) return;
1251
1866
  this.#refetchIntervalId = timeoutManager.setInterval(() => {
1252
1867
  if (this.options.refetchIntervalInBackground || focusManager.isFocused()) this.#executeFetch();
1253
1868
  }, this.#currentRefetchInterval);
@@ -1314,18 +1929,20 @@ var QueryObserver = class extends Subscribable {
1314
1929
  } catch (selectError) {
1315
1930
  this.#selectError = selectError;
1316
1931
  }
1932
+ else if (data === void 0) this.#selectError = null;
1317
1933
  if (this.#selectError) {
1318
1934
  error = this.#selectError;
1319
1935
  data = this.#selectResult;
1320
1936
  errorUpdatedAt = Date.now();
1321
1937
  status = "error";
1938
+ isPlaceholderData = false;
1322
1939
  }
1323
1940
  const isFetching = newState.fetchStatus === "fetching";
1324
1941
  const isPending = status === "pending";
1325
1942
  const isError = status === "error";
1326
1943
  const isLoading = isPending && isFetching;
1327
1944
  const hasData = data !== void 0;
1328
- const nextResult = {
1945
+ return {
1329
1946
  status,
1330
1947
  fetchStatus: newState.fetchStatus,
1331
1948
  isPending,
@@ -1350,34 +1967,14 @@ var QueryObserver = class extends Subscribable {
1350
1967
  isRefetchError: isError && hasData,
1351
1968
  isStale: isStale(query, options),
1352
1969
  refetch: this.refetch,
1353
- promise: this.#currentThenable,
1354
- isEnabled: resolveQueryBoolean(options.enabled, query) !== false
1970
+ isEnabled: resolveQueryValue(options.enabled, query) !== false
1355
1971
  };
1356
- if (this.options.experimental_prefetchInRender) {
1357
- const hasResultData = nextResult.data !== void 0;
1358
- const isErrorWithoutData = nextResult.status === "error" && !hasResultData;
1359
- const finalizeThenableIfPossible = (thenable) => {
1360
- if (isErrorWithoutData) thenable.reject(nextResult.error);
1361
- else if (hasResultData) thenable.resolve(nextResult.data);
1362
- };
1363
- const recreateThenable = () => {
1364
- finalizeThenableIfPossible(this.#currentThenable = nextResult.promise = pendingThenable());
1365
- };
1366
- const prevThenable = this.#currentThenable;
1367
- switch (prevThenable.status) {
1368
- case "pending":
1369
- if (query.queryHash === prevQuery.queryHash) finalizeThenableIfPossible(prevThenable);
1370
- break;
1371
- case "fulfilled":
1372
- if (isErrorWithoutData || nextResult.data !== prevThenable.value) recreateThenable();
1373
- break;
1374
- case "rejected":
1375
- if (!isErrorWithoutData || nextResult.error !== prevThenable.reason) recreateThenable();
1376
- break;
1377
- }
1378
- }
1379
- return nextResult;
1380
1972
  }
1973
+ /**
1974
+ * Recomputes and stores the current result from the current query/options, notifying listeners
1975
+ * if it changed. Framework adapters call this right after subscribing to make sure no query
1976
+ * update was missed in the gap between creating the observer and subscribing to it.
1977
+ */
1381
1978
  updateResult() {
1382
1979
  const prevResult = this.#currentResult;
1383
1980
  const nextResult = this.createResult(this.#currentQuery, this.options);
@@ -1398,7 +1995,16 @@ var QueryObserver = class extends Subscribable {
1398
1995
  return this.#currentResult[typedKey] !== prevResult[typedKey] && includedProps.has(typedKey);
1399
1996
  });
1400
1997
  };
1401
- this.#notify({ listeners: shouldNotifyListeners() });
1998
+ const notifyListeners = shouldNotifyListeners();
1999
+ notifyManager.batch(() => {
2000
+ if (notifyListeners) this.listeners.forEach((listener) => {
2001
+ listener(this.#currentResult);
2002
+ });
2003
+ this.#client.getQueryCache().notify({
2004
+ query: this.#currentQuery,
2005
+ type: "observerResultsUpdated"
2006
+ });
2007
+ });
1402
2008
  }
1403
2009
  #updateQuery() {
1404
2010
  const query = this.#client.getQueryCache().build(this.#client, this.options);
@@ -1411,47 +2017,172 @@ var QueryObserver = class extends Subscribable {
1411
2017
  query.addObserver(this);
1412
2018
  }
1413
2019
  }
2020
+ /** @internal */
1414
2021
  onQueryUpdate() {
1415
2022
  this.updateResult();
1416
2023
  if (this.hasListeners()) this.#updateTimers();
1417
2024
  }
1418
- #notify(notifyOptions) {
1419
- notifyManager.batch(() => {
1420
- if (notifyOptions.listeners) this.listeners.forEach((listener) => {
1421
- listener(this.#currentResult);
1422
- });
1423
- this.#client.getQueryCache().notify({
1424
- query: this.#currentQuery,
1425
- type: "observerResultsUpdated"
1426
- });
1427
- });
1428
- }
1429
2025
  };
1430
2026
  function shouldLoadOnMount(query, options) {
1431
- return resolveQueryBoolean(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && resolveQueryBoolean(options.retryOnMount, query) === false);
2027
+ return resolveQueryValue(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && resolveQueryValue(options.retryOnMount, query) === false);
1432
2028
  }
1433
2029
  function shouldFetchOnMount(query, options) {
1434
2030
  return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
1435
2031
  }
1436
2032
  function shouldFetchOn(query, options, field) {
1437
- if (resolveQueryBoolean(options.enabled, query) !== false && resolveStaleTime(options.staleTime, query) !== "static") {
1438
- const value = typeof field === "function" ? field(query) : field;
2033
+ if (resolveQueryValue(options.enabled, query) !== false && resolveQueryValue(options.staleTime, query) !== "static") {
2034
+ const value = resolveQueryValue(field, query);
1439
2035
  return value === "always" || value !== false && isStale(query, options);
1440
2036
  }
1441
2037
  return false;
1442
2038
  }
1443
2039
  function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
1444
- return (query !== prevQuery || resolveQueryBoolean(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
2040
+ return (query !== prevQuery || resolveQueryValue(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
1445
2041
  }
1446
2042
  function isStale(query, options) {
1447
- return resolveQueryBoolean(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query));
1448
- }
1449
- function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
1450
- if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) return true;
1451
- return false;
2043
+ return resolveQueryValue(options.enabled, query) !== false && query.isStaleByTime(resolveQueryValue(options.staleTime, query));
1452
2044
  }
1453
2045
  //#endregion
1454
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/mutation.js
2046
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryObserver.js
2047
+ /**
2048
+ * An `InfiniteQueryObserver` extends `QueryObserver` to observe and switch
2049
+ * between infinite queries. It augments the base `QueryObserverResult` with
2050
+ * infinite-query-specific fields and methods, such as `hasNextPage` and
2051
+ * `fetchNextPage`, and is the primitive that framework adapters (e.g.
2052
+ * `useInfiniteQuery`) build their hooks on top of.
2053
+ *
2054
+ * @example
2055
+ * ```ts
2056
+ * const observer = new InfiniteQueryObserver(queryClient, {
2057
+ * queryKey: ['projects'],
2058
+ * queryFn: ({ pageParam }) => fetchProjects(pageParam),
2059
+ * initialPageParam: 0,
2060
+ * getNextPageParam: (lastPage) => lastPage.nextCursor,
2061
+ * })
2062
+ *
2063
+ * const unsubscribe = observer.subscribe((result) => console.log(result))
2064
+ * ```
2065
+ */
2066
+ var InfiniteQueryObserver = class extends QueryObserver {
2067
+ constructor(client, options) {
2068
+ super(client, options);
2069
+ }
2070
+ bindMethods() {
2071
+ super.bindMethods();
2072
+ this.fetchNextPage = this.fetchNextPage.bind(this);
2073
+ this.fetchPreviousPage = this.fetchPreviousPage.bind(this);
2074
+ }
2075
+ /**
2076
+ * Updates the observer's options. Behaves the same as
2077
+ * `QueryObserver.setOptions`, additionally marking the options as
2078
+ * belonging to an infinite query before delegating to the base
2079
+ * implementation.
2080
+ */
2081
+ setOptions(options) {
2082
+ options._type = "infinite";
2083
+ super.setOptions(options);
2084
+ }
2085
+ /**
2086
+ * The infinite-query counterpart of {@link QueryObserver#getOptimisticResult}, marking the
2087
+ * options as an infinite query before delegating to it. Called by framework adapters (e.g.
2088
+ * `useInfiniteQuery`) ahead of subscribing, to compute the current `InfiniteQueryObserverResult`
2089
+ * synchronously.
2090
+ */
2091
+ getOptimisticResult(options) {
2092
+ options._type = "infinite";
2093
+ return super.getOptimisticResult(options);
2094
+ }
2095
+ /**
2096
+ * Fetches the next page of the infinite query and returns a promise that
2097
+ * resolves with the resulting `InfiniteQueryObserverResult`. The page
2098
+ * param used for the fetch is determined by `getNextPageParam`, which
2099
+ * receives the current pages/page params and whose result also determines
2100
+ * `hasNextPage`.
2101
+ *
2102
+ * @example
2103
+ * ```ts
2104
+ * const { hasNextPage } = observer.getCurrentResult()
2105
+ *
2106
+ * if (hasNextPage) {
2107
+ * await observer.fetchNextPage()
2108
+ * }
2109
+ * ```
2110
+ *
2111
+ * @see {@link InfiniteQueryObserver#fetchPreviousPage}
2112
+ */
2113
+ fetchNextPage(options) {
2114
+ return this.fetch({
2115
+ ...options,
2116
+ meta: { fetchMore: { direction: "forward" } }
2117
+ });
2118
+ }
2119
+ /**
2120
+ * Fetches the previous page of the infinite query and returns a promise
2121
+ * that resolves with the resulting `InfiniteQueryObserverResult`. The page
2122
+ * param used for the fetch is determined by `getPreviousPageParam`, which
2123
+ * receives the current pages/page params and whose result also determines
2124
+ * `hasPreviousPage`.
2125
+ *
2126
+ * @example
2127
+ * ```ts
2128
+ * const { hasPreviousPage } = observer.getCurrentResult()
2129
+ *
2130
+ * if (hasPreviousPage) {
2131
+ * await observer.fetchPreviousPage()
2132
+ * }
2133
+ * ```
2134
+ *
2135
+ * @see {@link InfiniteQueryObserver#fetchNextPage}
2136
+ */
2137
+ fetchPreviousPage(options) {
2138
+ return this.fetch({
2139
+ ...options,
2140
+ meta: { fetchMore: { direction: "backward" } }
2141
+ });
2142
+ }
2143
+ createResult(query, options) {
2144
+ const { state } = query;
2145
+ const parentResult = super.createResult(query, options);
2146
+ const { isFetching, isRefetching, isError, isRefetchError } = parentResult;
2147
+ const fetchDirection = state.fetchMeta?.fetchMore?.direction;
2148
+ const isFetchNextPageError = isError && fetchDirection === "forward";
2149
+ const isFetchingNextPage = isFetching && fetchDirection === "forward";
2150
+ const isFetchPreviousPageError = isError && fetchDirection === "backward";
2151
+ const isFetchingPreviousPage = isFetching && fetchDirection === "backward";
2152
+ return {
2153
+ ...parentResult,
2154
+ fetchNextPage: this.fetchNextPage,
2155
+ fetchPreviousPage: this.fetchPreviousPage,
2156
+ hasNextPage: hasNextPage(options, state.data),
2157
+ hasPreviousPage: hasPreviousPage(options, state.data),
2158
+ isFetchNextPageError,
2159
+ isFetchingNextPage,
2160
+ isFetchPreviousPageError,
2161
+ isFetchingPreviousPage,
2162
+ isRefetchError: isRefetchError && !isFetchNextPageError && !isFetchPreviousPageError,
2163
+ isRefetching: isRefetching && !isFetchingNextPage && !isFetchingPreviousPage
2164
+ };
2165
+ }
2166
+ };
2167
+ //#endregion
2168
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/mutation.js
2169
+ /**
2170
+ * Represents a single mutation attempt. A `Mutation` holds the mutation's
2171
+ * options, state (data/error/status), and the `MutationObserver`s currently
2172
+ * subscribed to it.
2173
+ *
2174
+ * Instances are created and managed internally by `MutationCache`; application
2175
+ * code typically interacts with mutations indirectly through `QueryClient` or
2176
+ * a framework hook like `useMutation`. Direct access to a `Mutation` instance
2177
+ * is possible via `mutationCache.find()`/`getAll()` for inspecting cache state.
2178
+ *
2179
+ * @example
2180
+ * ```ts
2181
+ * const mutationCache = queryClient.getMutationCache()
2182
+ *
2183
+ * const mutation = mutationCache.find({ mutationKey: ['addPost'] })
2184
+ * ```
2185
+ */
1455
2186
  var Mutation = class extends Removable {
1456
2187
  #client;
1457
2188
  #observers;
@@ -1467,13 +2198,18 @@ var Mutation = class extends Removable {
1467
2198
  this.setOptions(config.options);
1468
2199
  this.scheduleGc();
1469
2200
  }
2201
+ /** @internal */
1470
2202
  setOptions(options) {
1471
2203
  this.options = options;
1472
2204
  this.updateGcTime(this.options.gcTime);
1473
2205
  }
2206
+ /**
2207
+ * The `meta` object passed in the mutation's options, if any.
2208
+ */
1474
2209
  get meta() {
1475
2210
  return this.options.meta;
1476
2211
  }
2212
+ /** @internal */
1477
2213
  addObserver(observer) {
1478
2214
  if (!this.#observers.includes(observer)) {
1479
2215
  this.#observers.push(observer);
@@ -1485,6 +2221,7 @@ var Mutation = class extends Removable {
1485
2221
  });
1486
2222
  }
1487
2223
  }
2224
+ /** @internal */
1488
2225
  removeObserver(observer) {
1489
2226
  this.#observers = this.#observers.filter((x) => x !== observer);
1490
2227
  this.scheduleGc();
@@ -1498,9 +2235,60 @@ var Mutation = class extends Removable {
1498
2235
  if (!this.#observers.length) if (this.state.status === "pending") this.scheduleGc();
1499
2236
  else this.#mutationCache.remove(this);
1500
2237
  }
2238
+ /**
2239
+ * Resumes a mutation that is currently paused or was restored from a
2240
+ * dehydrated, still-`pending` state.
2241
+ *
2242
+ * - If this mutation has an active retryer (it paused mid-attempt, e.g. due
2243
+ * to the network mode or scope-based queuing), its retryer is resumed.
2244
+ * - Otherwise, if the mutation's status is still `pending` (e.g. it was
2245
+ * dehydrated while an attempt was in flight and never got a retryer in
2246
+ * this instance), `execute` is called again with the last known variables.
2247
+ * - Otherwise the mutation has already settled and this resolves immediately
2248
+ * without running anything again.
2249
+ *
2250
+ * @example
2251
+ * ```ts
2252
+ * // typically driven by reconnect handling, e.g. queryClient.resumePausedMutations()
2253
+ * const mutation = mutationCache.find({ mutationKey: ['addPost'] })
2254
+ * await mutation?.continue()
2255
+ * ```
2256
+ *
2257
+ * @see {@link Mutation#execute}
2258
+ */
1501
2259
  continue() {
1502
- return this.#retryer?.continue() ?? this.execute(this.state.variables);
2260
+ return this.#retryer?.continue() ?? (this.state.status === "pending" ? this.execute(this.state.variables) : Promise.resolve());
1503
2261
  }
2262
+ /**
2263
+ * Runs the mutation function for the given variables through a retryer, and
2264
+ * drives the mutation's state and lifecycle callbacks through to settlement.
2265
+ *
2266
+ * If this mutation's state is already `pending` when `execute` is called
2267
+ * (i.e. it was restored, still in-flight, from a dehydrated state), the
2268
+ * `onMutate` step is skipped and a `continue` action is dispatched to
2269
+ * unpause it; otherwise a `pending` action is dispatched first, then the
2270
+ * mutation cache's `onMutate` and the mutation's own `onMutate` option are
2271
+ * awaited in that order, and the resulting context is stored.
2272
+ *
2273
+ * The mutation function is then run (subject to `retry`/`retryDelay`/
2274
+ * `networkMode`, and to the mutation cache's scope-based serialization).
2275
+ * On success, the cache's `onSuccess`/`onSettled` callbacks run before the
2276
+ * mutation's own `onSuccess`/`onSettled` options, a `success` action is
2277
+ * dispatched, and the resolved data is returned. On failure, the same
2278
+ * cache-then-option ordering is used for `onError`/`onSettled`, but each of
2279
+ * those four callbacks is individually caught so that a throwing callback
2280
+ * cannot mask the original error; an `error` action is then dispatched and
2281
+ * the original error is re-thrown.
2282
+ *
2283
+ * @example
2284
+ * ```ts
2285
+ * // Called internally by `MutationObserver.mutate` and `Mutation.continue` —
2286
+ * // applications normally trigger mutations through those, not this method.
2287
+ * const data = await mutation.execute(variables)
2288
+ * ```
2289
+ *
2290
+ * @see {@link Mutation#continue}
2291
+ */
1504
2292
  async execute(variables) {
1505
2293
  const onContinue = () => {
1506
2294
  this.#dispatch({ type: "continue" });
@@ -1510,7 +2298,7 @@ var Mutation = class extends Removable {
1510
2298
  meta: this.options.meta,
1511
2299
  mutationKey: this.options.mutationKey
1512
2300
  };
1513
- this.#retryer = createRetryer({
2301
+ const retryer = this.#retryer = createRetryer({
1514
2302
  fn: () => {
1515
2303
  if (!this.options.mutationFn) return Promise.reject(/* @__PURE__ */ new Error("No mutationFn found"));
1516
2304
  return this.options.mutationFn(variables, mutationFnContext);
@@ -1532,7 +2320,7 @@ var Mutation = class extends Removable {
1532
2320
  canRun: () => this.#mutationCache.canRun(this)
1533
2321
  });
1534
2322
  const restored = this.state.status === "pending";
1535
- const isPaused = !this.#retryer.canStart();
2323
+ const isPaused = !retryer.canStart();
1536
2324
  try {
1537
2325
  if (restored) onContinue();
1538
2326
  else {
@@ -1550,7 +2338,7 @@ var Mutation = class extends Removable {
1550
2338
  isPaused
1551
2339
  });
1552
2340
  }
1553
- const data = await this.#retryer.start();
2341
+ const data = await retryer.start();
1554
2342
  await this.#mutationCache.config.onSuccess?.(data, variables, this.state.context, this, mutationFnContext);
1555
2343
  await this.options.onSuccess?.(data, variables, this.state.context, mutationFnContext);
1556
2344
  await this.#mutationCache.config.onSettled?.(data, null, this.state.variables, this.state.context, this, mutationFnContext);
@@ -1587,6 +2375,7 @@ var Mutation = class extends Removable {
1587
2375
  });
1588
2376
  throw error;
1589
2377
  } finally {
2378
+ if (this.#retryer === retryer) this.#retryer = void 0;
1590
2379
  this.#mutationCache.runNext(this);
1591
2380
  }
1592
2381
  }
@@ -1665,8 +2454,25 @@ function getDefaultState() {
1665
2454
  };
1666
2455
  }
1667
2456
  //#endregion
1668
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/mutationCache.js
2457
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/mutationCache.js
2458
+ /**
2459
+ * The `MutationCache` is the storage for mutations.
2460
+ *
2461
+ * Normally, you will not interact with the `MutationCache` directly and instead use a
2462
+ * `QueryClient`. You can subscribe to it (inherited from `Subscribable`) to be informed of
2463
+ * safe/known updates to the cache, such as mutations being added, removed, or updated.
2464
+ *
2465
+ * @example
2466
+ * ```ts
2467
+ * const unsubscribe = mutationCache.subscribe((event) => {
2468
+ * console.log(event.type, event.mutation)
2469
+ * })
2470
+ * ```
2471
+ */
1669
2472
  var MutationCache = class extends Subscribable {
2473
+ #mutations;
2474
+ #scopes;
2475
+ #mutationId;
1670
2476
  constructor(config = {}) {
1671
2477
  super();
1672
2478
  this.config = config;
@@ -1674,9 +2480,7 @@ var MutationCache = class extends Subscribable {
1674
2480
  this.#scopes = /* @__PURE__ */ new Map();
1675
2481
  this.#mutationId = 0;
1676
2482
  }
1677
- #mutations;
1678
- #scopes;
1679
- #mutationId;
2483
+ /** @internal */
1680
2484
  build(client, options, state) {
1681
2485
  const mutation = new Mutation({
1682
2486
  client,
@@ -1688,6 +2492,7 @@ var MutationCache = class extends Subscribable {
1688
2492
  this.add(mutation);
1689
2493
  return mutation;
1690
2494
  }
2495
+ /** @internal */
1691
2496
  add(mutation) {
1692
2497
  this.#mutations.add(mutation);
1693
2498
  const scope = scopeFor(mutation);
@@ -1701,6 +2506,7 @@ var MutationCache = class extends Subscribable {
1701
2506
  mutation
1702
2507
  });
1703
2508
  }
2509
+ /** @internal */
1704
2510
  remove(mutation) {
1705
2511
  if (this.#mutations.delete(mutation)) {
1706
2512
  const scope = scopeFor(mutation);
@@ -1719,6 +2525,7 @@ var MutationCache = class extends Subscribable {
1719
2525
  mutation
1720
2526
  });
1721
2527
  }
2528
+ /** @internal */
1722
2529
  canRun(mutation) {
1723
2530
  const scope = scopeFor(mutation);
1724
2531
  if (typeof scope === "string") {
@@ -1726,11 +2533,22 @@ var MutationCache = class extends Subscribable {
1726
2533
  return !firstPendingMutation || firstPendingMutation === mutation;
1727
2534
  } else return true;
1728
2535
  }
2536
+ /** @internal */
1729
2537
  runNext(mutation) {
1730
2538
  const scope = scopeFor(mutation);
1731
2539
  if (typeof scope === "string") return (this.#scopes.get(scope)?.find((m) => m !== mutation && m.state.isPaused))?.continue() ?? Promise.resolve();
1732
2540
  else return Promise.resolve();
1733
2541
  }
2542
+ /**
2543
+ * Removes all mutations from the cache.
2544
+ *
2545
+ * @example
2546
+ * ```ts
2547
+ * const mutationCache = queryClient.getMutationCache()
2548
+ *
2549
+ * mutationCache.clear()
2550
+ * ```
2551
+ */
1734
2552
  clear() {
1735
2553
  notifyManager.batch(() => {
1736
2554
  this.#mutations.forEach((mutation) => {
@@ -1743,9 +2561,37 @@ var MutationCache = class extends Subscribable {
1743
2561
  this.#scopes.clear();
1744
2562
  });
1745
2563
  }
2564
+ /**
2565
+ * Returns all mutations within the cache.
2566
+ *
2567
+ * This is not typically needed for most applications, but can come in handy when needing more
2568
+ * information about a mutation in rare scenarios.
2569
+ *
2570
+ * @example
2571
+ * ```ts
2572
+ * const mutationCache = queryClient.getMutationCache()
2573
+ *
2574
+ * const mutations = mutationCache.getAll()
2575
+ * ```
2576
+ */
1746
2577
  getAll() {
1747
2578
  return Array.from(this.#mutations);
1748
2579
  }
2580
+ /**
2581
+ * A slightly more advanced method that can be used to get an existing mutation instance from
2582
+ * the cache. If the mutation does not exist, `undefined` is returned.
2583
+ *
2584
+ * This is not typically needed for most applications, but can come in handy when needing more
2585
+ * information about a mutation in rare scenarios.
2586
+ *
2587
+ * @see {@link MutationCache#findAll}
2588
+ * @example
2589
+ * ```ts
2590
+ * const mutationCache = queryClient.getMutationCache()
2591
+ *
2592
+ * const mutation = mutationCache.find({ mutationKey: ['addPost'] })
2593
+ * ```
2594
+ */
1749
2595
  find(filters) {
1750
2596
  const defaultedFilters = {
1751
2597
  exact: true,
@@ -1753,9 +2599,25 @@ var MutationCache = class extends Subscribable {
1753
2599
  };
1754
2600
  return this.getAll().find((mutation) => matchMutation(defaultedFilters, mutation));
1755
2601
  }
2602
+ /**
2603
+ * An even more advanced method that can be used to get existing mutation instances from the
2604
+ * cache that match the given filters. If no mutations match, an empty array is returned.
2605
+ *
2606
+ * This is not typically needed for most applications, but can come in handy when needing more
2607
+ * information about mutations in rare scenarios.
2608
+ *
2609
+ * @see {@link MutationCache#find}
2610
+ * @example
2611
+ * ```ts
2612
+ * const mutationCache = queryClient.getMutationCache()
2613
+ *
2614
+ * const mutations = mutationCache.findAll({ mutationKey: ['addPost'] })
2615
+ * ```
2616
+ */
1756
2617
  findAll(filters = {}) {
1757
2618
  return this.getAll().filter((mutation) => matchMutation(filters, mutation));
1758
2619
  }
2620
+ /** @internal */
1759
2621
  notify(event) {
1760
2622
  notifyManager.batch(() => {
1761
2623
  this.listeners.forEach((listener) => {
@@ -1763,6 +2625,7 @@ var MutationCache = class extends Subscribable {
1763
2625
  });
1764
2626
  });
1765
2627
  }
2628
+ /** @internal */
1766
2629
  resumePausedMutations() {
1767
2630
  const pausedMutations = this.getAll().filter((x) => x.state.isPaused);
1768
2631
  return notifyManager.batch(() => Promise.all(pausedMutations.map((mutation) => mutation.continue().catch(noop))));
@@ -1772,7 +2635,22 @@ function scopeFor(mutation) {
1772
2635
  return mutation.options.scope?.id;
1773
2636
  }
1774
2637
  //#endregion
1775
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/mutationObserver.js
2638
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/mutationObserver.js
2639
+ /**
2640
+ * Observes a single mutation and derives a `MutationObserverResult` from it.
2641
+ * A framework hook like `useMutation` creates one `MutationObserver` per hook
2642
+ * call, keeps it stable across re-renders, calls `setOptions` when the options
2643
+ * passed to the hook change, subscribes to it to re-render on updates, and
2644
+ * reads `getCurrentResult()` for the value to return. Calling `mutate()`
2645
+ * builds a new underlying `Mutation` in the `MutationCache` and executes it.
2646
+ *
2647
+ * @example
2648
+ * ```ts
2649
+ * const observer = new MutationObserver(queryClient, {
2650
+ * mutationFn: (variables: { title: string }) => addPost(variables),
2651
+ * })
2652
+ * ```
2653
+ */
1776
2654
  var MutationObserver = class extends Subscribable {
1777
2655
  #client;
1778
2656
  #currentResult = void 0;
@@ -1789,6 +2667,22 @@ var MutationObserver = class extends Subscribable {
1789
2667
  this.mutate = this.mutate.bind(this);
1790
2668
  this.reset = this.reset.bind(this);
1791
2669
  }
2670
+ /**
2671
+ * Updates the observer's options.
2672
+ *
2673
+ * If the new `mutationKey` differs from the previous one (and both were
2674
+ * defined), the observer is reset, detaching it from the mutation it was
2675
+ * observing. Otherwise, if the currently observed mutation is still
2676
+ * `pending`, its options are updated in place as well.
2677
+ *
2678
+ * @example
2679
+ * ```ts
2680
+ * observer.setOptions({
2681
+ * mutationFn: (variables: { title: string }) => addPost(variables),
2682
+ * onSuccess: (data) => console.log(data),
2683
+ * })
2684
+ * ```
2685
+ */
1792
2686
  setOptions(options) {
1793
2687
  const prevOptions = this.options;
1794
2688
  this.options = this.#client.defaultMutationOptions(options);
@@ -1800,22 +2694,68 @@ var MutationObserver = class extends Subscribable {
1800
2694
  if (prevOptions?.mutationKey && this.options.mutationKey && hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)) this.reset();
1801
2695
  else if (this.#currentMutation?.state.status === "pending") this.#currentMutation.setOptions(this.options);
1802
2696
  }
2697
+ onSubscribe() {
2698
+ if (this.listeners.size === 1 && this.#currentMutation) {
2699
+ this.#currentMutation.addObserver(this);
2700
+ this.#updateResult();
2701
+ }
2702
+ }
1803
2703
  onUnsubscribe() {
1804
2704
  if (!this.hasListeners()) this.#currentMutation?.removeObserver(this);
1805
2705
  }
2706
+ /** @internal */
1806
2707
  onMutationUpdate(action) {
1807
2708
  this.#updateResult();
1808
2709
  this.#notify(action);
1809
2710
  }
2711
+ /**
2712
+ * Returns the observer's current result, derived from the observed
2713
+ * mutation's state (or the default, `idle` state if no mutation has been
2714
+ * built yet, e.g. before the first `mutate()` call or after `reset()`).
2715
+ */
1810
2716
  getCurrentResult() {
1811
2717
  return this.#currentResult;
1812
2718
  }
2719
+ /**
2720
+ * Detaches the observer from the mutation it is currently observing (if
2721
+ * any) and resets the observed result back to its default, `idle` state.
2722
+ *
2723
+ * This does not cancel an in-flight mutation; the mutation itself keeps
2724
+ * running to completion and its own callbacks still fire, but this
2725
+ * observer stops reflecting its state and a subsequent `mutate()` call
2726
+ * will build a brand new mutation.
2727
+ *
2728
+ * @example
2729
+ * ```ts
2730
+ * observer.reset()
2731
+ * ```
2732
+ *
2733
+ * @see {@link MutationObserver#mutate}
2734
+ */
1813
2735
  reset() {
1814
2736
  this.#currentMutation?.removeObserver(this);
1815
2737
  this.#currentMutation = void 0;
1816
2738
  this.#updateResult();
1817
2739
  this.#notify();
1818
2740
  }
2741
+ /**
2742
+ * Builds a new `Mutation` in the `MutationCache` using the observer's
2743
+ * current options, detaches this observer from any previously observed
2744
+ * mutation, attaches it to the new one, and executes it with the given
2745
+ * variables.
2746
+ *
2747
+ * The optional per-call `options` (`onSuccess`/`onError`/`onSettled`) are
2748
+ * invoked once the mutation settles, in addition to any callbacks defined
2749
+ * on the observer's own options.
2750
+ *
2751
+ * @example
2752
+ * ```ts
2753
+ * await observer.mutate(
2754
+ * { title: 'New post' },
2755
+ * { onSuccess: (data) => console.log(data) },
2756
+ * )
2757
+ * ```
2758
+ */
1819
2759
  mutate(variables, options) {
1820
2760
  this.#mutateOptions = options;
1821
2761
  this.#currentMutation?.removeObserver(this);
@@ -1876,14 +2816,286 @@ var MutationObserver = class extends Subscribable {
1876
2816
  }
1877
2817
  };
1878
2818
  //#endregion
1879
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/queryCache.js
2819
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/queriesObserver.js
2820
+ function difference(array1, array2) {
2821
+ const excludeSet = new Set(array2);
2822
+ return array1.filter((x) => !excludeSet.has(x));
2823
+ }
2824
+ /**
2825
+ * A `QueriesObserver` watches an array of queries at once, exposing them as
2826
+ * a single array of `QueryObserverResult`s (or, when a `combine` option is
2827
+ * given, as a combined value derived from that array). It manages one
2828
+ * internal `QueryObserver` per query, and is the primitive that framework
2829
+ * adapters (e.g. `useQueries`) build their hooks on top of.
2830
+ *
2831
+ * @example
2832
+ * ```ts
2833
+ * const observer = new QueriesObserver(queryClient, [
2834
+ * { queryKey: ['post', 1], queryFn: fetchPost },
2835
+ * { queryKey: ['post', 2], queryFn: fetchPost },
2836
+ * ])
2837
+ *
2838
+ * const unsubscribe = observer.subscribe((result) => {
2839
+ * console.log(result)
2840
+ * })
2841
+ * ```
2842
+ */
2843
+ var QueriesObserver = class extends Subscribable {
2844
+ #client;
2845
+ #result;
2846
+ #queries;
2847
+ #options;
2848
+ #observers;
2849
+ #combinedResult;
2850
+ #lastCombine;
2851
+ #lastResult;
2852
+ #lastQueryHashes;
2853
+ #observerMatches = [];
2854
+ constructor(client, queries, options) {
2855
+ super();
2856
+ this.#client = client;
2857
+ this.#options = options;
2858
+ this.#queries = [];
2859
+ this.#observers = [];
2860
+ this.#result = [];
2861
+ this.setQueries(queries);
2862
+ }
2863
+ onSubscribe() {
2864
+ if (this.listeners.size === 1) this.#observers.forEach((observer) => {
2865
+ observer.subscribe((result) => {
2866
+ this.#onUpdate(observer, result);
2867
+ });
2868
+ });
2869
+ }
2870
+ onUnsubscribe() {
2871
+ if (!this.listeners.size) this.destroy();
2872
+ }
2873
+ /**
2874
+ * Stops observing all queries: clears all listeners and destroys every
2875
+ * underlying `QueryObserver` this observer manages.
2876
+ */
2877
+ destroy() {
2878
+ this.listeners = /* @__PURE__ */ new Set();
2879
+ this.#observers.forEach((observer) => {
2880
+ observer.destroy();
2881
+ });
2882
+ }
2883
+ /**
2884
+ * Replaces the set of queries being observed. Existing `QueryObserver`s
2885
+ * are reused for queries that match an already-observed query hash;
2886
+ * observers for queries that are no longer present are destroyed, and new
2887
+ * observers are created and subscribed to for newly added queries.
2888
+ *
2889
+ * @example
2890
+ * ```ts
2891
+ * observer.setQueries([
2892
+ * { queryKey: ['post', 1], queryFn: fetchPost },
2893
+ * { queryKey: ['post', 3], queryFn: fetchPost },
2894
+ * ])
2895
+ * ```
2896
+ */
2897
+ setQueries(queries, options) {
2898
+ this.#queries = queries;
2899
+ this.#options = options;
2900
+ notifyManager.batch(() => {
2901
+ const prevObservers = this.#observers;
2902
+ const newObserverMatches = this.#findMatchingObservers(this.#queries);
2903
+ newObserverMatches.forEach((match) => match.observer.setOptions(match.defaultedQueryOptions));
2904
+ const newObservers = newObserverMatches.map((match) => match.observer);
2905
+ const newResult = newObservers.map((observer) => observer.getCurrentResult());
2906
+ const hasLengthChange = prevObservers.length !== newObservers.length;
2907
+ const hasIndexChange = newObservers.some((observer, index) => observer !== prevObservers[index]);
2908
+ const hasStructuralChange = hasLengthChange || hasIndexChange;
2909
+ const hasResultChange = hasStructuralChange ? true : newResult.some((result, index) => {
2910
+ const prev = this.#result[index];
2911
+ return !prev || !shallowEqualObjects(result, prev);
2912
+ });
2913
+ if (!hasStructuralChange && !hasResultChange) return;
2914
+ if (hasStructuralChange) {
2915
+ this.#observerMatches = newObserverMatches;
2916
+ this.#observers = newObservers;
2917
+ }
2918
+ this.#result = newResult;
2919
+ if (!this.hasListeners()) return;
2920
+ if (hasStructuralChange) {
2921
+ difference(prevObservers, newObservers).forEach((observer) => {
2922
+ observer.destroy();
2923
+ });
2924
+ difference(newObservers, prevObservers).forEach((observer) => {
2925
+ observer.subscribe((result) => {
2926
+ this.#onUpdate(observer, result);
2927
+ });
2928
+ });
2929
+ }
2930
+ this.#notify();
2931
+ });
2932
+ }
2933
+ /**
2934
+ * Returns the most recently computed array of `QueryObserverResult`s, one
2935
+ * per observed query, in the same order as the queries passed to the
2936
+ * constructor or `setQueries`.
2937
+ *
2938
+ * @example
2939
+ * ```ts
2940
+ * const results = observer.getCurrentResult()
2941
+ * const data = results.map((result) => result.data)
2942
+ * ```
2943
+ */
2944
+ getCurrentResult() {
2945
+ return this.#result;
2946
+ }
2947
+ /**
2948
+ * Returns the underlying `Query` instances currently being observed, in
2949
+ * the same order as the queries passed to the constructor or `setQueries`.
2950
+ */
2951
+ getQueries() {
2952
+ return this.#observers.map((observer) => observer.getCurrentQuery());
2953
+ }
2954
+ /**
2955
+ * Returns the underlying `QueryObserver` instances this observer manages,
2956
+ * in the same order as the queries passed to the constructor or
2957
+ * `setQueries`.
2958
+ */
2959
+ getObservers() {
2960
+ return this.#observers;
2961
+ }
2962
+ /**
2963
+ * The `QueriesObserver` counterpart of {@link QueryObserver#getOptimisticResult} — computes
2964
+ * the result for the given (already-defaulted) queries right now, synchronously. Called by
2965
+ * framework adapters (e.g. `useQueries`) ahead of subscribing, returning a tuple of the raw
2966
+ * per-query results, a function to compute the combined result from them, and a function to
2967
+ * wrap the results for property-access tracking.
2968
+ */
2969
+ getOptimisticResult(queries, combine) {
2970
+ const matches = this.#findMatchingObservers(queries);
2971
+ const result = matches.map((match) => match.observer.getOptimisticResult(match.defaultedQueryOptions));
2972
+ const queryHashes = matches.map((match) => match.defaultedQueryOptions.queryHash);
2973
+ return [
2974
+ result,
2975
+ (r) => {
2976
+ return this.#combineResult(r ?? result, combine, queryHashes);
2977
+ },
2978
+ () => {
2979
+ return this.#trackResult(result, matches);
2980
+ }
2981
+ ];
2982
+ }
2983
+ #trackResult(result, matches) {
2984
+ const trackedProps = /* @__PURE__ */ new Set();
2985
+ return matches.map((match, index) => {
2986
+ const observerResult = result[index];
2987
+ return !match.defaultedQueryOptions.notifyOnChangeProps ? match.observer.trackResult(observerResult, (accessedProp) => {
2988
+ if (!trackedProps.has(accessedProp)) {
2989
+ trackedProps.add(accessedProp);
2990
+ matches.forEach((m) => {
2991
+ m.observer.trackProp(accessedProp);
2992
+ });
2993
+ }
2994
+ }) : observerResult;
2995
+ });
2996
+ }
2997
+ #combineResult(input, combine, queryHashes) {
2998
+ if (combine) {
2999
+ const lastHashes = this.#lastQueryHashes;
3000
+ const queryHashesChanged = queryHashes !== void 0 && lastHashes !== void 0 && (lastHashes.length !== queryHashes.length || queryHashes.some((hash, i) => hash !== lastHashes[i]));
3001
+ if (this.#result !== this.#lastResult || queryHashesChanged || combine !== this.#lastCombine) {
3002
+ this.#lastCombine = combine;
3003
+ this.#lastResult = this.#result;
3004
+ if (queryHashes !== void 0) this.#lastQueryHashes = queryHashes;
3005
+ this.#combinedResult = replaceEqualDeep(this.#combinedResult, combine(input));
3006
+ }
3007
+ return this.#combinedResult;
3008
+ }
3009
+ return input;
3010
+ }
3011
+ #shouldSkipCombine() {
3012
+ return !this.#options?.combine || this.#observers.some((observer, index) => {
3013
+ return observer.options.suspense && this.#result[index]?.data === void 0;
3014
+ });
3015
+ }
3016
+ #findMatchingObservers(queries) {
3017
+ const prevObserversMap = /* @__PURE__ */ new Map();
3018
+ this.#observers.forEach((observer) => {
3019
+ const key = observer.options.queryHash;
3020
+ if (!key) return;
3021
+ const previousObservers = prevObserversMap.get(key);
3022
+ if (previousObservers) previousObservers.push(observer);
3023
+ else prevObserversMap.set(key, [observer]);
3024
+ });
3025
+ const observers = [];
3026
+ queries.forEach((options) => {
3027
+ const defaultedOptions = this.#client.defaultQueryOptions(options);
3028
+ const observer = prevObserversMap.get(defaultedOptions.queryHash)?.shift() ?? new QueryObserver(this.#client, defaultedOptions);
3029
+ observers.push({
3030
+ defaultedQueryOptions: defaultedOptions,
3031
+ observer
3032
+ });
3033
+ });
3034
+ return observers;
3035
+ }
3036
+ #onUpdate(observer, result) {
3037
+ const index = this.#observers.indexOf(observer);
3038
+ if (index !== -1) {
3039
+ this.#result = this.#result.slice();
3040
+ this.#result[index] = result;
3041
+ this.#notify();
3042
+ }
3043
+ }
3044
+ #notify() {
3045
+ if (this.hasListeners()) {
3046
+ const shouldSkipCombine = this.#shouldSkipCombine();
3047
+ const previousResult = this.#combinedResult;
3048
+ const newResult = shouldSkipCombine ? previousResult : this.#combineResult(this.#trackResult(this.#result, this.#observerMatches), this.#options?.combine);
3049
+ if (shouldSkipCombine || previousResult !== newResult) notifyManager.batch(() => {
3050
+ this.listeners.forEach((listener) => {
3051
+ listener(this.#result);
3052
+ });
3053
+ });
3054
+ }
3055
+ }
3056
+ };
3057
+ //#endregion
3058
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/queryCache.js
3059
+ /**
3060
+ * The `QueryCache` is the storage mechanism for TanStack Query. It stores all the data, meta
3061
+ * information, and state of the queries it contains.
3062
+ *
3063
+ * Normally, you will not interact with the `QueryCache` directly and instead use a `QueryClient`
3064
+ * for a specific cache. You can subscribe to it (inherited from `Subscribable`) to be informed of
3065
+ * safe/known updates to the cache, such as queries being added, removed, or updated — updates made
3066
+ * outside of the cache's own tracked mechanisms (e.g. mutating a query's state object directly) do
3067
+ * not notify subscribers.
3068
+ *
3069
+ * @example
3070
+ * ```ts
3071
+ * const unsubscribe = queryCache.subscribe((event) => {
3072
+ * console.log(event.type, event.query)
3073
+ * })
3074
+ * ```
3075
+ */
1880
3076
  var QueryCache = class extends Subscribable {
3077
+ #queries;
1881
3078
  constructor(config = {}) {
1882
3079
  super();
1883
3080
  this.config = config;
1884
3081
  this.#queries = /* @__PURE__ */ new Map();
1885
3082
  }
1886
- #queries;
3083
+ /**
3084
+ * Returns the existing `Query` instance for the given options' `queryKey`/`queryHash`, or
3085
+ * builds and adds a new one to the cache if none exists yet. Used by framework adapters and
3086
+ * plugins (e.g. broadcast/persistence) that need to get-or-create a `Query` directly, bypassing
3087
+ * the reactive `QueryObserver` machinery.
3088
+ *
3089
+ * @example
3090
+ * ```ts
3091
+ * const queryCache = queryClient.getQueryCache()
3092
+ *
3093
+ * const query = queryCache.build(queryClient, {
3094
+ * queryKey: ['posts'],
3095
+ * queryFn: fetchPosts,
3096
+ * })
3097
+ * ```
3098
+ */
1887
3099
  build(client, options, state) {
1888
3100
  const queryKey = options.queryKey;
1889
3101
  const queryHash = options.queryHash ?? hashQueryKeyByOptions(queryKey, options);
@@ -1901,6 +3113,7 @@ var QueryCache = class extends Subscribable {
1901
3113
  }
1902
3114
  return query;
1903
3115
  }
3116
+ /** @internal */
1904
3117
  add(query) {
1905
3118
  if (!this.#queries.has(query.queryHash)) {
1906
3119
  this.#queries.set(query.queryHash, query);
@@ -1910,17 +3123,42 @@ var QueryCache = class extends Subscribable {
1910
3123
  });
1911
3124
  }
1912
3125
  }
3126
+ /**
3127
+ * Destroys the given `Query` and removes it from the cache, notifying subscribers with a
3128
+ * `'removed'` event. A no-op if the query is no longer the one currently stored under its hash
3129
+ * (e.g. it was already replaced). Used by plugins (e.g. the broadcast client) that mirror
3130
+ * removals across `QueryCache` instances.
3131
+ *
3132
+ * @example
3133
+ * ```ts
3134
+ * const queryCache = queryClient.getQueryCache()
3135
+ * const query = queryCache.find({ queryKey: ['posts'] })
3136
+ *
3137
+ * if (query) {
3138
+ * queryCache.remove(query)
3139
+ * }
3140
+ * ```
3141
+ */
1913
3142
  remove(query) {
1914
- const queryInMap = this.#queries.get(query.queryHash);
1915
- if (queryInMap) {
3143
+ if (this.#queries.get(query.queryHash) === query) {
1916
3144
  query.destroy();
1917
- if (queryInMap === query) this.#queries.delete(query.queryHash);
3145
+ this.#queries.delete(query.queryHash);
1918
3146
  this.notify({
1919
3147
  type: "removed",
1920
3148
  query
1921
3149
  });
1922
3150
  }
1923
3151
  }
3152
+ /**
3153
+ * Removes all queries from the cache.
3154
+ *
3155
+ * @example
3156
+ * ```ts
3157
+ * const queryCache = queryClient.getQueryCache()
3158
+ *
3159
+ * queryCache.clear()
3160
+ * ```
3161
+ */
1924
3162
  clear() {
1925
3163
  notifyManager.batch(() => {
1926
3164
  this.getAll().forEach((query) => {
@@ -1928,12 +3166,54 @@ var QueryCache = class extends Subscribable {
1928
3166
  });
1929
3167
  });
1930
3168
  }
3169
+ /**
3170
+ * Returns the `Query` instance stored under the given `queryHash`, or `undefined` if none
3171
+ * exists. Unlike {@link QueryCache#find}, this looks up by the already-computed hash rather
3172
+ * than by `QueryFilters`. Used by plugins (e.g. broadcast/hydration) that already have a hash
3173
+ * to look up directly.
3174
+ *
3175
+ * @example
3176
+ * ```ts
3177
+ * const queryCache = queryClient.getQueryCache()
3178
+ * const queryHash = hashKey(['posts'])
3179
+ *
3180
+ * const query = queryCache.get(queryHash)
3181
+ * ```
3182
+ */
1931
3183
  get(queryHash) {
1932
3184
  return this.#queries.get(queryHash);
1933
3185
  }
3186
+ /**
3187
+ * Returns all queries within the cache.
3188
+ *
3189
+ * @example
3190
+ * ```ts
3191
+ * const queryCache = queryClient.getQueryCache()
3192
+ *
3193
+ * const queries = queryCache.getAll()
3194
+ * ```
3195
+ */
1934
3196
  getAll() {
1935
3197
  return [...this.#queries.values()];
1936
3198
  }
3199
+ /**
3200
+ * A slightly more advanced method that can be used to get an existing query instance from the
3201
+ * cache. This instance not only contains all the state for the query, but all of the instances,
3202
+ * and underlying guts of the query as well. If the query does not exist, `undefined` is
3203
+ * returned.
3204
+ *
3205
+ * This is not typically needed for most applications, but can come in handy when needing more
3206
+ * information about a query in rare scenarios (e.g. looking at `query.state.dataUpdatedAt` to
3207
+ * decide whether a query is fresh enough to be used as an initial value).
3208
+ *
3209
+ * @see {@link QueryCache#findAll}
3210
+ * @example
3211
+ * ```ts
3212
+ * const queryCache = queryClient.getQueryCache()
3213
+ *
3214
+ * const query = queryCache.find({ queryKey: ['posts'] })
3215
+ * ```
3216
+ */
1937
3217
  find(filters) {
1938
3218
  const defaultedFilters = {
1939
3219
  exact: true,
@@ -1941,10 +3221,26 @@ var QueryCache = class extends Subscribable {
1941
3221
  };
1942
3222
  return this.getAll().find((query) => matchQuery(defaultedFilters, query));
1943
3223
  }
3224
+ /**
3225
+ * An even more advanced method that can be used to get existing query instances from the cache
3226
+ * that partially match a query key. If no queries match, an empty array is returned.
3227
+ *
3228
+ * This is not typically needed for most applications, but can come in handy when needing more
3229
+ * information about queries in rare scenarios.
3230
+ *
3231
+ * @see {@link QueryCache#find}
3232
+ * @example
3233
+ * ```ts
3234
+ * const queryCache = queryClient.getQueryCache()
3235
+ *
3236
+ * const queries = queryCache.findAll({ queryKey: ['posts'] })
3237
+ * ```
3238
+ */
1944
3239
  findAll(filters = {}) {
1945
3240
  const queries = this.getAll();
1946
3241
  return Object.keys(filters).length > 0 ? queries.filter((query) => matchQuery(filters, query)) : queries;
1947
3242
  }
3243
+ /** @internal */
1948
3244
  notify(event) {
1949
3245
  notifyManager.batch(() => {
1950
3246
  this.listeners.forEach((listener) => {
@@ -1952,6 +3248,7 @@ var QueryCache = class extends Subscribable {
1952
3248
  });
1953
3249
  });
1954
3250
  }
3251
+ /** @internal */
1955
3252
  onFocus() {
1956
3253
  notifyManager.batch(() => {
1957
3254
  this.getAll().forEach((query) => {
@@ -1959,6 +3256,7 @@ var QueryCache = class extends Subscribable {
1959
3256
  });
1960
3257
  });
1961
3258
  }
3259
+ /** @internal */
1962
3260
  onOnline() {
1963
3261
  notifyManager.batch(() => {
1964
3262
  this.getAll().forEach((query) => {
@@ -1968,7 +3266,25 @@ var QueryCache = class extends Subscribable {
1968
3266
  }
1969
3267
  };
1970
3268
  //#endregion
1971
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/queryClient.js
3269
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/queryClient.js
3270
+ /**
3271
+ * `QueryClient` is used to interact with a cache of queries and mutations. It owns a
3272
+ * `QueryCache` and a `MutationCache` (creating default ones if none are passed in) and holds
3273
+ * the default options that are applied to queries and mutations created through it.
3274
+ *
3275
+ * @example
3276
+ * ```ts
3277
+ * const queryClient = new QueryClient({
3278
+ * defaultOptions: {
3279
+ * queries: {
3280
+ * staleTime: Infinity,
3281
+ * },
3282
+ * },
3283
+ * })
3284
+ *
3285
+ * await queryClient.query({ queryKey: ['posts'], queryFn: fetchPosts })
3286
+ * ```
3287
+ */
1972
3288
  var QueryClient = class {
1973
3289
  #queryCache;
1974
3290
  #mutationCache;
@@ -1986,6 +3302,12 @@ var QueryClient = class {
1986
3302
  this.#mutationDefaults = /* @__PURE__ */ new Map();
1987
3303
  this.#mountCount = 0;
1988
3304
  }
3305
+ /**
3306
+ * Called by a framework adapter's `QueryClientProvider`-equivalent when it mounts, to start
3307
+ * listening for focus/online events and resume paused mutations. Ref-counted via an internal
3308
+ * mount count, so nested or multiple providers sharing the same `QueryClient` don't tear down
3309
+ * the shared listeners until the last one unmounts.
3310
+ */
1989
3311
  mount() {
1990
3312
  this.#mountCount++;
1991
3313
  if (this.#mountCount !== 1) return;
@@ -2002,6 +3324,11 @@ var QueryClient = class {
2002
3324
  }
2003
3325
  });
2004
3326
  }
3327
+ /**
3328
+ * The inverse of {@link QueryClient#mount} — called by a framework adapter's
3329
+ * `QueryClientProvider`-equivalent when it unmounts. Only tears down the focus/online
3330
+ * listeners once the mount count returns to `0`.
3331
+ */
2005
3332
  unmount() {
2006
3333
  this.#mountCount--;
2007
3334
  if (this.#mountCount !== 0) return;
@@ -2010,12 +3337,35 @@ var QueryClient = class {
2010
3337
  this.#unsubscribeOnline?.();
2011
3338
  this.#unsubscribeOnline = void 0;
2012
3339
  }
3340
+ /**
3341
+ * Returns the number of queries in the cache that are currently fetching, optionally
3342
+ * matching a set of filters. This includes background-fetching, loading new pages, and
3343
+ * loading more infinite query results.
3344
+ *
3345
+ * @example
3346
+ * ```ts
3347
+ * if (queryClient.isFetching()) {
3348
+ * console.log('At least one query is fetching!')
3349
+ * }
3350
+ * ```
3351
+ */
2013
3352
  isFetching(filters) {
2014
3353
  return this.#queryCache.findAll({
2015
3354
  ...filters,
2016
3355
  fetchStatus: "fetching"
2017
3356
  }).length;
2018
3357
  }
3358
+ /**
3359
+ * Returns the number of mutations in the cache that are currently pending, optionally
3360
+ * matching a set of filters.
3361
+ *
3362
+ * @example
3363
+ * ```ts
3364
+ * if (queryClient.isMutating()) {
3365
+ * console.log('At least one mutation is pending!')
3366
+ * }
3367
+ * ```
3368
+ */
2019
3369
  isMutating(filters) {
2020
3370
  return this.#mutationCache.findAll({
2021
3371
  ...filters,
@@ -2028,24 +3378,72 @@ var QueryClient = class {
2028
3378
  *
2029
3379
  * Hint: Do not use this function inside a component, because it won't receive updates.
2030
3380
  * Use `useQuery` to create a `QueryObserver` that subscribes to changes.
3381
+ *
3382
+ * @returns The cached data for the query, or `undefined` if no query with this key has been observed yet.
3383
+ * @see {@link QueryClient#getQueriesData}
2031
3384
  */
2032
3385
  getQueryData(queryKey) {
2033
3386
  const options = this.defaultQueryOptions({ queryKey });
2034
3387
  return this.#queryCache.get(options.queryHash)?.state.data;
2035
3388
  }
3389
+ /**
3390
+ * @deprecated Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version.
3391
+ */
2036
3392
  ensureQueryData(options) {
2037
3393
  const defaultedOptions = this.defaultQueryOptions(options);
2038
3394
  const query = this.#queryCache.build(this, defaultedOptions);
2039
3395
  const cachedData = query.state.data;
2040
3396
  if (cachedData === void 0) return this.fetchQuery(options);
2041
- if (options.revalidateIfStale && query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query))) this.prefetchQuery(defaultedOptions);
3397
+ if (options.revalidateIfStale && query.isStaleByTime(resolveQueryValue(defaultedOptions.staleTime, query))) this.prefetchQuery(defaultedOptions);
2042
3398
  return Promise.resolve(cachedData);
2043
3399
  }
3400
+ /**
3401
+ * Imperative (non-reactive) way to retrieve the cached data of multiple queries at once.
3402
+ * Only queries matching the given filters are returned; if none match, an empty array is
3403
+ * returned.
3404
+ *
3405
+ * Because the matched queries can hold data of different shapes (e.g. a broad filter can match
3406
+ * queries with unrelated data types), the `TQueryFnData` generic defaults to `unknown` rather
3407
+ * than being inferred. Passing a more specific type is a convenience for call sites that know
3408
+ * every matched query holds the same shape — it is not checked against the actual cache
3409
+ * contents.
3410
+ *
3411
+ * @returns An array of query key and data pairs. The data is `undefined` for a query with no cached data.
3412
+ * @see {@link QueryClient#getQueryData}
3413
+ * @example
3414
+ * ```ts
3415
+ * const data = queryClient.getQueriesData({ queryKey: ['posts'] })
3416
+ * ```
3417
+ */
2044
3418
  getQueriesData(filters) {
2045
3419
  return this.#queryCache.findAll(filters).map(({ queryKey, state }) => {
2046
3420
  return [queryKey, state.data];
2047
3421
  });
2048
3422
  }
3423
+ /**
3424
+ * Synchronous way to immediately update a query's cached data. If the updater (or the value
3425
+ * passed) resolves to `undefined`, the cache is left untouched and no query is created;
3426
+ * otherwise, if the query does not exist yet, it will be created. To update multiple queries
3427
+ * at once by partially matching query keys, use {@link QueryClient#setQueriesData} instead.
3428
+ *
3429
+ * Updates must be performed immutably: do not mutate `oldData`, or data previously retrieved
3430
+ * via {@link QueryClient#getQueryData}, in place.
3431
+ *
3432
+ * @param queryKey - The query key to set data for.
3433
+ * @param updater - Either the new data, or a function that receives the current data (which
3434
+ * may be `undefined`) and returns the new data.
3435
+ * @param options - Set `updatedAt` to override the timestamp the written data is recorded with.
3436
+ * @returns The data that was written, or `undefined` if the updater returned `undefined` — in that case
3437
+ * the write is skipped and the cache is left unchanged.
3438
+ *
3439
+ * @example
3440
+ * ```ts
3441
+ * queryClient.setQueryData(['posts'], newPosts)
3442
+ *
3443
+ * // Or, using an updater function that receives the current data:
3444
+ * queryClient.setQueryData(['posts'], (oldPosts) => [...oldPosts, newPost])
3445
+ * ```
3446
+ */
2049
3447
  setQueryData(queryKey, updater, options) {
2050
3448
  const defaultedOptions = this.defaultQueryOptions({ queryKey });
2051
3449
  const prevData = this.#queryCache.get(defaultedOptions.queryHash)?.state.data;
@@ -2056,13 +3454,49 @@ var QueryClient = class {
2056
3454
  manual: true
2057
3455
  });
2058
3456
  }
3457
+ /**
3458
+ * Synchronous way to immediately update the cached data of multiple queries at once, using
3459
+ * filters or partial query key matching. Only queries that already exist and match the given
3460
+ * filters are updated; no new cache entries are created. Internally this calls
3461
+ * {@link QueryClient#setQueryData} for each matching query.
3462
+ *
3463
+ * @returns One `[queryKey, data]` tuple per matched query, in the same shape and with the same
3464
+ * `undefined` case as {@link QueryClient#setQueryData}.
3465
+ * @example
3466
+ * ```ts
3467
+ * queryClient.setQueriesData({ queryKey: ['posts'] }, (oldPosts) =>
3468
+ * oldPosts ? oldPosts.filter((post) => post.id !== deletedId) : oldPosts,
3469
+ * )
3470
+ * ```
3471
+ */
2059
3472
  setQueriesData(filters, updater, options) {
2060
3473
  return notifyManager.batch(() => this.#queryCache.findAll(filters).map(({ queryKey }) => [queryKey, this.setQueryData(queryKey, updater, options)]));
2061
3474
  }
3475
+ /**
3476
+ * Imperative (non-reactive) way to retrieve an existing query's state. If the query does not
3477
+ * exist, `undefined` is returned.
3478
+ *
3479
+ * @example
3480
+ * ```ts
3481
+ * const state = queryClient.getQueryState(['posts'])
3482
+ * console.log(state?.dataUpdatedAt)
3483
+ * ```
3484
+ */
2062
3485
  getQueryState(queryKey) {
2063
3486
  const options = this.defaultQueryOptions({ queryKey });
2064
3487
  return this.#queryCache.get(options.queryHash)?.state;
2065
3488
  }
3489
+ /**
3490
+ * Removes queries from the cache that match the given filters. Unlike
3491
+ * {@link QueryClient#invalidateQueries} or {@link QueryClient#refetchQueries}, this removes
3492
+ * matching queries from the cache instead of refetching them. Without filters, every query in
3493
+ * the cache is removed.
3494
+ *
3495
+ * @example
3496
+ * ```ts
3497
+ * queryClient.removeQueries({ queryKey: ['posts'], exact: true })
3498
+ * ```
3499
+ */
2066
3500
  removeQueries(filters) {
2067
3501
  const queryCache = this.#queryCache;
2068
3502
  notifyManager.batch(() => {
@@ -2071,18 +3505,43 @@ var QueryClient = class {
2071
3505
  });
2072
3506
  });
2073
3507
  }
3508
+ /**
3509
+ * Resets queries matching the given filters back to their initial state (e.g. any
3510
+ * `initialData`), notifying subscribers rather than removing them. Active queries among the
3511
+ * matched set are then refetched, and the returned promise resolves once that refetch settles.
3512
+ *
3513
+ * @example
3514
+ * ```ts
3515
+ * await queryClient.resetQueries({ queryKey: ['posts'], exact: true })
3516
+ * ```
3517
+ */
2074
3518
  resetQueries(filters, options) {
2075
3519
  const queryCache = this.#queryCache;
2076
3520
  return notifyManager.batch(() => {
2077
- queryCache.findAll(filters).forEach((query) => {
3521
+ const matched = queryCache.findAll(filters);
3522
+ const queriesToRefetch = new Set(matched);
3523
+ matched.forEach((query) => {
2078
3524
  query.reset();
2079
3525
  });
2080
3526
  return this.refetchQueries({
2081
3527
  type: "active",
2082
- ...filters
3528
+ predicate: (query) => queriesToRefetch.has(query)
2083
3529
  }, options);
2084
3530
  });
2085
3531
  }
3532
+ /**
3533
+ * Cancels outgoing fetches for queries matching the given filters. Most useful when performing
3534
+ * optimistic updates, since any outgoing refetch that resolves afterwards would otherwise
3535
+ * overwrite the optimistic update. By default (`revert: true`), a cancelled query's data is
3536
+ * reverted to its state before the outgoing fetch started.
3537
+ *
3538
+ * The returned promise never rejects, even if individual cancellations fail.
3539
+ *
3540
+ * @example
3541
+ * ```ts
3542
+ * await queryClient.cancelQueries({ queryKey: ['posts'], exact: true })
3543
+ * ```
3544
+ */
2086
3545
  cancelQueries(filters, cancelOptions = {}) {
2087
3546
  const defaultedCancelOptions = {
2088
3547
  revert: true,
@@ -2091,6 +3550,19 @@ var QueryClient = class {
2091
3550
  const promises = notifyManager.batch(() => this.#queryCache.findAll(filters).map((query) => query.cancel(defaultedCancelOptions)));
2092
3551
  return Promise.all(promises).then(noop).catch(noop);
2093
3552
  }
3553
+ /**
3554
+ * Marks queries matching the given filters as invalidated. Unlike
3555
+ * {@link QueryClient#removeQueries}, invalidated queries stay in the cache.
3556
+ *
3557
+ * Unless `filters.refetchType` is `'none'`, matching queries are then refetched via
3558
+ * {@link QueryClient#refetchQueries}, using `filters.refetchType` if set, otherwise
3559
+ * `filters.type`, otherwise `'active'`.
3560
+ *
3561
+ * @example
3562
+ * ```ts
3563
+ * await queryClient.invalidateQueries({ queryKey: ['posts'], refetchType: 'active' })
3564
+ * ```
3565
+ */
2094
3566
  invalidateQueries(filters, options = {}) {
2095
3567
  return notifyManager.batch(() => {
2096
3568
  this.#queryCache.findAll(filters).forEach((query) => {
@@ -2103,6 +3575,21 @@ var QueryClient = class {
2103
3575
  }, options);
2104
3576
  });
2105
3577
  }
3578
+ /**
3579
+ * Refetches queries matching the given filters, regardless of whether they are stale. Without
3580
+ * filters, every query in the cache is refetched. Queries that are disabled, or static (only
3581
+ * have observers with a static `staleTime`), are never refetched.
3582
+ *
3583
+ * By default (`cancelRefetch: true`), a currently running fetch is cancelled before the new
3584
+ * one starts. The returned promise resolves once all matching queries have settled; it does
3585
+ * not reject on individual query failures unless `throwOnError` is set.
3586
+ *
3587
+ * @example
3588
+ * ```ts
3589
+ * // refetch all active queries partially matching a query key:
3590
+ * await queryClient.refetchQueries({ queryKey: ['posts'], type: 'active' })
3591
+ * ```
3592
+ */
2106
3593
  refetchQueries(filters, options = {}) {
2107
3594
  const fetchOptions = {
2108
3595
  ...options,
@@ -2115,48 +3602,218 @@ var QueryClient = class {
2115
3602
  }));
2116
3603
  return Promise.all(promises).then(noop);
2117
3604
  }
3605
+ /**
3606
+ * Asynchronous method to fetch and cache a query, resolving with the data or throwing with
3607
+ * the error.
3608
+ *
3609
+ * If the query already exists in the cache and its data is not stale (per the given
3610
+ * `staleTime`), the cached data is returned without fetching. Otherwise, the query is fetched
3611
+ * and the promise resolves once the fetch settles. If a `select` function is provided, it is
3612
+ * applied to the data in both cases (cached or freshly fetched) before it is returned.
3613
+ *
3614
+ * Unlike a reactive observer, retries are disabled by default here (`retry: false`) unless
3615
+ * explicitly configured, since there is no component to catch a thrown error and retry through
3616
+ * re-render.
3617
+ *
3618
+ * The accepted options are `QueryObserverOptions` minus the fields that only make sense for a
3619
+ * reactive observer — `enabled`, `refetchInterval`, `refetchIntervalInBackground`,
3620
+ * `refetchOnWindowFocus`, `refetchOnReconnect`, `refetchOnMount`, `retryOnMount`,
3621
+ * `notifyOnChangeProps`, `throwOnError`, `suspense`, and `placeholderData` are not part of this
3622
+ * method's options.
3623
+ *
3624
+ * This method replaces the deprecated `fetchQuery`, and — combined with
3625
+ * `{ staleTime: 'static' }` — the deprecated `ensureQueryData`.
3626
+ *
3627
+ * @example
3628
+ * ```ts
3629
+ * try {
3630
+ * const data = await queryClient.query({ queryKey, queryFn, staleTime: 10000 })
3631
+ * } catch (error) {
3632
+ * console.log(error)
3633
+ * }
3634
+ * ```
3635
+ */
3636
+ async query(options) {
3637
+ const defaultedOptions = this.defaultQueryOptions(options);
3638
+ if (defaultedOptions.retry === void 0) defaultedOptions.retry = false;
3639
+ const query = this.#queryCache.build(this, defaultedOptions);
3640
+ const queryData = query.isStaleByTime(resolveQueryValue(defaultedOptions.staleTime, query)) ? await query.fetch(defaultedOptions) : query.state.data;
3641
+ const select = defaultedOptions.select;
3642
+ if (select) return select(queryData);
3643
+ return queryData;
3644
+ }
3645
+ /**
3646
+ * @deprecated Use queryClient.query(options) instead. This method will be removed in the next major version.
3647
+ */
2118
3648
  fetchQuery(options) {
2119
3649
  const defaultedOptions = this.defaultQueryOptions(options);
2120
3650
  if (defaultedOptions.retry === void 0) defaultedOptions.retry = false;
2121
3651
  const query = this.#queryCache.build(this, defaultedOptions);
2122
- return query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query)) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data);
3652
+ return query.isStaleByTime(resolveQueryValue(defaultedOptions.staleTime, query)) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data);
2123
3653
  }
3654
+ /**
3655
+ * @deprecated Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version.
3656
+ */
2124
3657
  prefetchQuery(options) {
2125
3658
  return this.fetchQuery(options).then(noop).catch(noop);
2126
3659
  }
3660
+ /**
3661
+ * Asynchronous method to fetch and cache an infinite query, resolving with an
3662
+ * {@link InfiniteData} object or throwing with the error.
3663
+ *
3664
+ * Behaves like {@link QueryClient#query}, accepting the same options (minus
3665
+ * `initialPageParam`), plus the required `initialPageParam`, and an optional `pages` /
3666
+ * `getNextPageParam` pair used to refetch a fixed number of pages from the start.
3667
+ *
3668
+ * This method replaces the deprecated `fetchInfiniteQuery`, and — combined with
3669
+ * `{ staleTime: 'static' }` — the deprecated `ensureInfiniteQueryData`.
3670
+ *
3671
+ * @example
3672
+ * ```ts
3673
+ * try {
3674
+ * const data = await queryClient.infiniteQuery({ queryKey, queryFn, initialPageParam: 0 })
3675
+ * console.log(data.pages)
3676
+ * } catch (error) {
3677
+ * console.log(error)
3678
+ * }
3679
+ * ```
3680
+ */
3681
+ infiniteQuery(options) {
3682
+ options._type = "infinite";
3683
+ return this.query(options);
3684
+ }
3685
+ /**
3686
+ * @deprecated Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version.
3687
+ */
2127
3688
  fetchInfiniteQuery(options) {
2128
3689
  options._type = "infinite";
2129
3690
  return this.fetchQuery(options);
2130
3691
  }
3692
+ /**
3693
+ * @deprecated Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version.
3694
+ */
2131
3695
  prefetchInfiniteQuery(options) {
2132
3696
  return this.fetchInfiniteQuery(options).then(noop).catch(noop);
2133
3697
  }
3698
+ /**
3699
+ * @deprecated Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version.
3700
+ */
2134
3701
  ensureInfiniteQueryData(options) {
2135
3702
  options._type = "infinite";
2136
3703
  return this.ensureQueryData(options);
2137
3704
  }
3705
+ /**
3706
+ * Resumes mutations that were paused because there was no network connection. Does nothing
3707
+ * (resolving immediately) if the client is currently offline.
3708
+ *
3709
+ * @example
3710
+ * ```ts
3711
+ * import { QueryClient } from '@tanstack/query-core'
3712
+ *
3713
+ * const queryClient = new QueryClient()
3714
+ * await queryClient.resumePausedMutations()
3715
+ * ```
3716
+ */
2138
3717
  resumePausedMutations() {
2139
3718
  if (onlineManager.isOnline()) return this.#mutationCache.resumePausedMutations();
2140
3719
  return Promise.resolve();
2141
3720
  }
3721
+ /**
3722
+ * Returns the query cache this client is connected to.
3723
+ *
3724
+ * @example
3725
+ * ```ts
3726
+ * import { QueryClient } from '@tanstack/query-core'
3727
+ *
3728
+ * const queryClient = new QueryClient()
3729
+ * const queryCache = queryClient.getQueryCache()
3730
+ * const queries = queryCache.findAll({ queryKey: ['posts'] })
3731
+ * ```
3732
+ */
2142
3733
  getQueryCache() {
2143
3734
  return this.#queryCache;
2144
3735
  }
3736
+ /**
3737
+ * Returns the mutation cache this client is connected to.
3738
+ *
3739
+ * @example
3740
+ * ```ts
3741
+ * import { QueryClient } from '@tanstack/query-core'
3742
+ *
3743
+ * const queryClient = new QueryClient()
3744
+ * const mutationCache = queryClient.getMutationCache()
3745
+ * const mutations = mutationCache.findAll({ status: 'pending' })
3746
+ * ```
3747
+ */
2145
3748
  getMutationCache() {
2146
3749
  return this.#mutationCache;
2147
3750
  }
3751
+ /**
3752
+ * Returns the default options that were set when creating the client, or via
3753
+ * {@link QueryClient#setDefaultOptions}.
3754
+ *
3755
+ * @example
3756
+ * ```ts
3757
+ * import { QueryClient } from '@tanstack/query-core'
3758
+ *
3759
+ * const queryClient = new QueryClient()
3760
+ * const defaultOptions = queryClient.getDefaultOptions()
3761
+ * ```
3762
+ */
2148
3763
  getDefaultOptions() {
2149
3764
  return this.#defaultOptions;
2150
3765
  }
3766
+ /**
3767
+ * Dynamically sets the default options for this client, overwriting any previously defined
3768
+ * default options.
3769
+ *
3770
+ * @see {@link QueryClient#getDefaultOptions}
3771
+ * @example
3772
+ * ```ts
3773
+ * import { QueryClient } from '@tanstack/query-core'
3774
+ *
3775
+ * const queryClient = new QueryClient()
3776
+ * queryClient.setDefaultOptions({
3777
+ * queries: {
3778
+ * staleTime: Infinity,
3779
+ * },
3780
+ * })
3781
+ * ```
3782
+ */
2151
3783
  setDefaultOptions(options) {
2152
3784
  this.#defaultOptions = options;
2153
3785
  }
3786
+ /**
3787
+ * Sets default options for queries whose query key partially matches the given `queryKey`.
3788
+ *
3789
+ * If several registered query defaults match a given query key, they are merged together in
3790
+ * registration order by {@link QueryClient#getQueryDefaults}, so register defaults from the
3791
+ * most generic key to the least generic one — more specific defaults should be registered
3792
+ * after more generic ones so they take precedence.
3793
+ *
3794
+ * @example
3795
+ * ```ts
3796
+ * queryClient.setQueryDefaults(['posts'], { queryFn: fetchPosts })
3797
+ *
3798
+ * await queryClient.query({ queryKey: ['posts'] })
3799
+ * ```
3800
+ */
2154
3801
  setQueryDefaults(queryKey, options) {
2155
3802
  this.#queryDefaults.set(hashKey(queryKey), {
2156
3803
  queryKey,
2157
3804
  defaultOptions: options
2158
3805
  });
2159
3806
  }
3807
+ /**
3808
+ * Returns the default options registered for queries whose query key partially matches the
3809
+ * given `queryKey`, via {@link QueryClient#setQueryDefaults}. If multiple registered defaults
3810
+ * match, they are merged together in registration order.
3811
+ *
3812
+ * @example
3813
+ * ```ts
3814
+ * const defaultOptions = queryClient.getQueryDefaults(['posts'])
3815
+ * ```
3816
+ */
2160
3817
  getQueryDefaults(queryKey) {
2161
3818
  const defaults = [...this.#queryDefaults.values()];
2162
3819
  const result = {};
@@ -2165,12 +3822,33 @@ var QueryClient = class {
2165
3822
  });
2166
3823
  return result;
2167
3824
  }
3825
+ /**
3826
+ * Sets default options for mutations whose mutation key partially matches the given
3827
+ * `mutationKey`. As with {@link QueryClient#setQueryDefaults}, the order of registration
3828
+ * matters when several registered defaults match the same mutation key.
3829
+ *
3830
+ * @see {@link QueryClient#getMutationDefaults}
3831
+ * @example
3832
+ * ```ts
3833
+ * queryClient.setMutationDefaults(['addPost'], { mutationFn: addPost })
3834
+ * ```
3835
+ */
2168
3836
  setMutationDefaults(mutationKey, options) {
2169
3837
  this.#mutationDefaults.set(hashKey(mutationKey), {
2170
3838
  mutationKey,
2171
3839
  defaultOptions: options
2172
3840
  });
2173
3841
  }
3842
+ /**
3843
+ * Returns the default options registered for mutations whose mutation key partially matches
3844
+ * the given `mutationKey`, via {@link QueryClient#setMutationDefaults}. If multiple registered
3845
+ * defaults match, they are merged together in registration order.
3846
+ *
3847
+ * @example
3848
+ * ```ts
3849
+ * const defaultOptions = queryClient.getMutationDefaults(['addPost'])
3850
+ * ```
3851
+ */
2174
3852
  getMutationDefaults(mutationKey) {
2175
3853
  const defaults = [...this.#mutationDefaults.values()];
2176
3854
  const result = {};
@@ -2179,6 +3857,12 @@ var QueryClient = class {
2179
3857
  });
2180
3858
  return result;
2181
3859
  }
3860
+ /**
3861
+ * Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the
3862
+ * caller into their final, defaulted form: merging `queryClient.setQueryDefaults` for the
3863
+ * given `queryKey`, then the client's own `defaultOptions.queries`, then the caller's options
3864
+ * on top. A no-op if the options are already defaulted (`_defaulted: true`).
3865
+ */
2182
3866
  defaultQueryOptions(options) {
2183
3867
  if (options._defaulted) return options;
2184
3868
  const defaultedOptions = {
@@ -2194,6 +3878,12 @@ var QueryClient = class {
2194
3878
  if (defaultedOptions.queryFn === skipToken) defaultedOptions.enabled = false;
2195
3879
  return defaultedOptions;
2196
3880
  }
3881
+ /**
3882
+ * The mutation counterpart of {@link QueryClient#defaultQueryOptions}. Called by framework
3883
+ * adapters (e.g. inside `useMutation`) to merge `queryClient.setMutationDefaults` for the
3884
+ * given `mutationKey`, then the client's `defaultOptions.mutations`, then the caller's options
3885
+ * on top. A no-op if the options are already defaulted (`_defaulted: true`).
3886
+ */
2197
3887
  defaultMutationOptions(options) {
2198
3888
  if (options?._defaulted) return options;
2199
3889
  return {
@@ -2203,10 +3893,21 @@ var QueryClient = class {
2203
3893
  _defaulted: true
2204
3894
  };
2205
3895
  }
3896
+ /**
3897
+ * Clears both the query cache and the mutation cache this client is connected to.
3898
+ *
3899
+ * @example
3900
+ * ```ts
3901
+ * import { QueryClient } from '@tanstack/query-core'
3902
+ *
3903
+ * const queryClient = new QueryClient()
3904
+ * queryClient.clear()
3905
+ * ```
3906
+ */
2206
3907
  clear() {
2207
3908
  this.#queryCache.clear();
2208
3909
  this.#mutationCache.clear();
2209
3910
  }
2210
3911
  };
2211
3912
  //#endregion
2212
- export { dehydrate as a, noop as c, notifyManager as i, shouldThrowError as l, MutationObserver as n, hydrate as o, QueryObserver as r, environmentManager as s, QueryClient as t };
3913
+ export { QueryObserver as a, hydrate as c, shouldThrowError as d, InfiniteQueryObserver as i, keepPreviousData as l, QueriesObserver as n, notifyManager as o, MutationObserver as r, dehydrateQuery as s, QueryClient as t, noop as u };