@hot-updater/console 1.0.0-rc.20 → 1.0.0-rc.21

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 (180) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/assets/{ConsoleFeatureUnavailable-B9VYGA3N.js → ConsoleFeatureUnavailable-D0LPL1Gy.js} +1 -1
  3. package/.output/public/assets/{HashValueDisplay-D880zntR.js → HashValueDisplay-BmuB4FW-.js} +1 -1
  4. package/.output/public/assets/InsightsInfo--v4SC07c.js +1 -0
  5. package/.output/public/assets/InsightsPageHeader-dU83CAQY.js +1 -0
  6. package/.output/public/assets/{NotFoundPage-Dys8C0cW.js → NotFoundPage-B5mhGG2a.js} +1 -1
  7. package/.output/public/assets/api-D-vOVlQ4.js +1 -0
  8. package/.output/public/assets/api-keys-Csh8ARKU.js +1 -0
  9. package/.output/public/assets/api-keys-OMPUoA_A.js +1 -0
  10. package/.output/public/assets/arrow-left-Bwq9X1eS.js +1 -0
  11. package/.output/public/assets/arrow-up-right-BkOVn4if.js +1 -0
  12. package/.output/public/assets/{card-DzCPSRsh.js → card-C_7d6O9a.js} +1 -1
  13. package/.output/public/assets/console-features-api-C1jRZTGw.js +1 -0
  14. package/.output/public/assets/dialog-DE8wFN_P.js +1 -0
  15. package/.output/public/assets/{dist-Clb6cQ9l.js → dist-C7ENGzpS.js} +1 -1
  16. package/.output/public/assets/empty-CVd5NlQD.js +1 -0
  17. package/.output/public/assets/{field-Bou7shoO.js → field-C06q1iC9.js} +1 -1
  18. package/.output/public/assets/index-BeWlQtO6.js +11 -0
  19. package/.output/public/assets/{input-group-DVtWFUUF.js → input-group-Bi61biIA.js} +1 -1
  20. package/.output/public/assets/insights-BjnAtC0f.js +2 -0
  21. package/.output/public/assets/insights-D86m11yH.js +42 -0
  22. package/.output/public/assets/insights-DpYstMoY.js +1 -0
  23. package/.output/public/assets/{insights-recovery-rpc-wvdyM4LD.js → insights-recovery-rpc-BIm5_ALc.js} +1 -1
  24. package/.output/public/assets/{insights-usage-rpc-qUkNtrWr.js → insights-usage-rpc-VHj8vyBt.js} +1 -1
  25. package/.output/public/assets/insights_.distribution-ADcrX48c.js +2 -0
  26. package/.output/public/assets/insights_.distribution-CuuJUN6Y.js +1 -0
  27. package/.output/public/assets/{insights_.distribution-CItZw3-8.js → insights_.distribution-DJRjuXsO.js} +1 -1
  28. package/.output/public/assets/installations-BSBBzqWs.js +2 -0
  29. package/.output/public/assets/installations-DqIE6WcO.js +1 -0
  30. package/.output/public/assets/installations-UsELbDvw.js +1 -0
  31. package/.output/public/assets/{loader-circle-Ca7C9YY1.js → loader-circle-CnCBxzHp.js} +1 -1
  32. package/.output/public/assets/mutation-Csp7xUNh.js +1 -0
  33. package/.output/public/assets/preload-helper-B-cOmpLH.js +1 -0
  34. package/.output/public/assets/{refresh-cw-CVGqvy8Z.js → refresh-cw-FF1NtzlQ.js} +1 -1
  35. package/.output/public/assets/{routes-veKtDW39.js → routes-CoN9XHP_.js} +2 -2
  36. package/.output/public/assets/routes-DT1jB0Zi.js +1 -0
  37. package/.output/public/assets/sidebar-D8mJRF15.js +3 -0
  38. package/.output/public/assets/styles-Bwt7v6U5.css +2 -0
  39. package/.output/public/assets/table-WBgfvgXg.js +1 -0
  40. package/.output/public/assets/{useCompositeListItem-CF7vsfcA.js → useCompositeListItem-CloBmDwn.js} +1 -1
  41. package/.output/public/assets/useMutation-DO8cvsTx.js +1 -0
  42. package/.output/public/assets/{useOpenInteractionType-AnAMWYIY.js → useOpenInteractionType-ReGr9GzJ.js} +1 -1
  43. package/.output/public/assets/valueToPercent-BvPAi4bP.js +1 -0
  44. package/.output/server/{__23tanstack-start-server-fn-resolver-CUQLz7hs.mjs → __23tanstack-start-server-fn-resolver-DMRD4e4f.mjs} +34 -42
  45. package/.output/server/_libs/@tanstack/react-router+[...].mjs +3756 -4022
  46. package/.output/server/_libs/@tanstack/react-router-ssr-query+[...].mjs +138 -95
  47. package/.output/server/_libs/tanstack__history.mjs +68 -41
  48. package/.output/server/_libs/tanstack__query-core.mjs +1618 -309
  49. package/.output/server/_libs/tanstack__react-query.mjs +255 -20
  50. package/.output/server/_ssr/{ConsoleFeatureUnavailable-DoxET2AT.mjs → ConsoleFeatureUnavailable-Du7jNPNS.mjs} +7 -7
  51. package/.output/server/_ssr/{HashValueDisplay-BplboHEb.mjs → HashValueDisplay-GQvFkXoi.mjs} +2 -2
  52. package/.output/server/_ssr/{InsightsInfo-o2YPd5Qc.mjs → InsightsInfo-Do7QSaFR.mjs} +2 -2
  53. package/.output/server/_ssr/{InsightsPageHeader-NExCJL1I.mjs → InsightsPageHeader-DSUWUWRc.mjs} +6 -6
  54. package/.output/server/_ssr/{NotFoundPage-Cd-A8ock.mjs → NotFoundPage-DsF4Vrhg.mjs} +2 -2
  55. package/.output/server/_ssr/{api-B1Ro0uys.mjs → api-BEiVs0H7.mjs} +9 -8
  56. package/.output/server/_ssr/{api-keys-Dvvy1sem.mjs → api-keys-BrvBWGRf.mjs} +2 -2
  57. package/.output/server/_ssr/{api-keys-CT3HG7KT.mjs → api-keys-K5v32nf7.mjs} +8 -8
  58. package/.output/server/_ssr/{api-keys-rpc-b1qTTFfG.mjs → api-keys-rpc-B96bBllm.mjs} +5 -5
  59. package/.output/server/_ssr/{api-rpc-Cbns2MGx.mjs → api-rpc-DcUe280B.mjs} +13 -55
  60. package/.output/server/_ssr/{auth-rpc-DChS7m9y.mjs → auth-rpc-C68W56DP.mjs} +6 -6
  61. package/.output/server/_ssr/{api-C0G9MTMI.mjs → auth.server-DM1J6NwR.mjs} +2815 -1308
  62. package/.output/server/_ssr/{bundleActivity-D17Pb_h5.mjs → bundleActivity-CpuY9CTP.mjs} +1 -1
  63. package/.output/server/_ssr/{card-DMbcvlPz.mjs → card-CPAEKx0w.mjs} +1 -1
  64. package/.output/server/_ssr/config-nsIcsHh8.mjs +15 -0
  65. package/.output/server/_ssr/config.server-DDCZk3Sq.mjs +36 -0
  66. package/.output/server/_ssr/{console-access-KpPv5lin.mjs → console-access-Da-2Qd7q.mjs} +3 -3
  67. package/.output/server/_ssr/{console-features-CsbyHYfK.mjs → console-features-Dzu2iUGD.mjs} +6 -6
  68. package/.output/server/_ssr/{console-features-api-B-KVuo4p.mjs → console-features-api-xAsSgFa_.mjs} +6 -6
  69. package/.output/server/_ssr/{console-features-rpc-Djyo5740.mjs → console-features-rpc-qARGpB24.mjs} +5 -5
  70. package/.output/server/_ssr/{createMiddleware-B_I3Ll4M.mjs → createMiddleware-BdBf_ezN.mjs} +41 -56
  71. package/.output/server/_ssr/{createServerRpc-DuNm5mmo.mjs → createServerRpc-B_y2lrwA.mjs} +2 -2
  72. package/.output/server/_ssr/databaseJsonValue-Bhxciy7Z.mjs +68 -0
  73. package/.output/server/_ssr/databaseRows-DwMAjaF8.mjs +74 -0
  74. package/.output/server/_ssr/{dialog-cOmLTUV2.mjs → dialog-q__BJ7mQ.mjs} +1 -1
  75. package/.output/server/_ssr/{dist-B-r4u3Lg.mjs → dist-Cxo9ghYv.mjs} +114 -3
  76. package/.output/server/_ssr/{downloadBundle-CexOFoZ4.mjs → downloadBundle-BW9I-pMQ.mjs} +6 -5
  77. package/.output/server/_ssr/{empty-BHoY_5jt.mjs → empty-DcBTAooP.mjs} +2 -2
  78. package/.output/server/_ssr/{empty-plugin-adapters-B5QvGpEl.mjs → empty-plugin-adapters-CYdinE-i.mjs} +1 -1
  79. package/.output/server/_ssr/{field-mjhcNEXD.mjs → field-QCDBVpXA.mjs} +2 -2
  80. package/.output/server/_ssr/{getBundleChildren-DbDXe9wB.mjs → getBundleChildren-DIAGCF4a.mjs} +2 -2
  81. package/.output/server/_ssr/{input-group-96H30HWC.mjs → input-group-hCk2nUoU.mjs} +1 -1
  82. package/.output/server/_ssr/{insights-DgFv1NsO.mjs → insights-BfBO0RFr.mjs} +18 -18
  83. package/.output/server/_ssr/{insights-D359GJFL.mjs → insights-DsAU3-TB.mjs} +5 -5
  84. package/.output/server/_ssr/{insights-D25VDVaz.mjs → insights-RIfg447W.mjs} +2 -2
  85. package/.output/server/_ssr/{insights-api-ChAKrbhG.mjs → insights-api-CDn-QQHU.mjs} +5 -5
  86. package/.output/server/_ssr/{insights-failures-WQ-ttjOx.mjs → insights-failures-BBGMhuUr.mjs} +2 -2
  87. package/.output/server/_ssr/{insights-failures-rpc-BFsqlltN.mjs → insights-failures-rpc-rA2dctK2.mjs} +8 -8
  88. package/.output/server/_ssr/{insights-recovery-DkL6bxMW.mjs → insights-recovery-Dpk6Mfb9.mjs} +1 -1
  89. package/.output/server/_ssr/{insights-recovery-rpc-2P5m8F62.mjs → insights-recovery-rpc-BCaF-xSd.mjs} +11 -11
  90. package/.output/server/_ssr/{insights-recovery-rpc-Tj8vNC19.mjs → insights-recovery-rpc-CcgYyUHk.mjs} +5 -5
  91. package/.output/server/_ssr/{insights-rpc-DrkVmV9o.mjs → insights-rpc-keycmwzw.mjs} +5 -5
  92. package/.output/server/_ssr/{insights-search-BsalnNw-.mjs → insights-search-BRg5VsNe.mjs} +1 -1
  93. package/.output/server/_ssr/{insights-usage-1nVTQrLy.mjs → insights-usage-cbw9n2Fq.mjs} +1 -1
  94. package/.output/server/_ssr/{insights-usage-rpc-Ct_4xHhZ.mjs → insights-usage-rpc-BKgV1QDf.mjs} +8 -8
  95. package/.output/server/_ssr/{insights-usage-rpc-DaYIRtFK.mjs → insights-usage-rpc-D-JYachy.mjs} +5 -5
  96. package/.output/server/_ssr/{insightsRecovery-CpGucWN1.mjs → insightsRecovery-B7oMc8d8.mjs} +2 -2
  97. package/.output/server/_ssr/{insightsUsage-JYpKZAF7.mjs → insightsUsage-Oa7kk5ek.mjs} +3 -3
  98. package/.output/server/_ssr/{insights_.distribution-jQZEF07J.mjs → insights_.distribution-BIqOqRW0.mjs} +13 -13
  99. package/.output/server/_ssr/{insights_.distribution-Bcu6uYs_.mjs → insights_.distribution-CuUrDa7P.mjs} +2 -2
  100. package/.output/server/_ssr/{insights_.distribution-D3Csuyjw.mjs → insights_.distribution-RT_6x_ud.mjs} +5 -5
  101. package/.output/server/_ssr/{installations-Cxikllmx.mjs → installations-BO5CjX2z.mjs} +11 -11
  102. package/.output/server/_ssr/{installations-BI5kelHv.mjs → installations-BjaHiIfh.mjs} +2 -2
  103. package/.output/server/_ssr/{installations-B8Vh54lH.mjs → installations-Dt5luA-N.mjs} +4 -4
  104. package/.output/server/_ssr/{listReleases-DqU9t1l3.mjs → listReleases-BitHzOYB.mjs} +1 -1
  105. package/.output/server/_ssr/{router-CRkm-wHD.mjs → router-DfVAixxe.mjs} +42 -39
  106. package/.output/server/_ssr/{routes-CNAi0Mmv.mjs → routes-C6LstNp8.mjs} +14 -14
  107. package/.output/server/_ssr/{routes-B3IJo_jL.mjs → routes-Q3Uhmwwz.mjs} +11 -11
  108. package/.output/server/_ssr/{runtime.server-NucbYjc7.mjs → runtime.server-fL0o6I2b.mjs} +500 -413
  109. package/.output/server/_ssr/schema-BKY9SqaY.mjs +25 -0
  110. package/.output/server/_ssr/{select-BkPAJFL7.mjs → select-CUlInmjk.mjs} +1 -1
  111. package/.output/server/_ssr/server-C43wq9ft.mjs +8330 -0
  112. package/.output/server/_ssr/{sidebar-Cw1VuC7d.mjs → sidebar-DKbx2ach.mjs} +3 -3
  113. package/.output/server/_ssr/ssr.mjs +1 -1
  114. package/.output/server/_ssr/start-BXUOv_n8.mjs +4 -0
  115. package/.output/server/_ssr/{table-q0P9wz7x.mjs → table-NGWV8B-S.mjs} +1 -1
  116. package/.output/server/_ssr/{updateFailures-DMU9f0pK.mjs → updateFailures-Jwe2Baab.mjs} +3 -3
  117. package/.output/server/_ssr/{uuidv7-BzSO-fr-.mjs → uuidv7-C8bwiZr8.mjs} +2 -2
  118. package/.output/server/_tanstack-start-manifest_v-WQ5qGn8n.mjs +124 -0
  119. package/.output/server/index.mjs +218 -218
  120. package/LICENSE +13 -14
  121. package/README.md +16 -12
  122. package/lib/index.d.mts +18 -8
  123. package/lib/vite-internal.mjs +15 -8
  124. package/lib/vite.d.mts +2 -0
  125. package/package.json +14 -14
  126. package/src/components/AppSidebar.tsx +9 -0
  127. package/src/components/ConsoleFeatureUnavailable.tsx +1 -3
  128. package/src/components/features/bundles/BundleMetadata.tsx +1 -1
  129. package/src/components/features/bundles/RolloutCohortsDialog.tsx +1 -1
  130. package/src/components/features/releases/ReleaseEditorSheet.tsx +6 -6
  131. package/src/index.ts +27 -15
  132. package/src/lib/api-rpc.ts +1 -54
  133. package/src/lib/api.ts +8 -89
  134. package/src/lib/console-features.ts +5 -5
  135. package/src/lib/scroll-restoration.ts +1 -1
  136. package/src/lib/server/config.server.ts +15 -52
  137. package/src/lib/server/console-runtime.server.ts +84 -6
  138. package/src/lib/server/downloadBundle.ts +10 -6
  139. package/src/lib/server/releaseReachability.ts +4 -4
  140. package/src/lib/server/runtime.server.ts +34 -46
  141. package/src/routeTree.gen.ts +31 -31
  142. package/src/routes/api/bundles/$bundleId/download.ts +2 -2
  143. package/src/vite-internal.ts +17 -8
  144. package/src/vite.ts +2 -0
  145. package/.output/public/assets/InsightsInfo-By_sPjTE.js +0 -1
  146. package/.output/public/assets/InsightsPageHeader-9_kx_LL7.js +0 -1
  147. package/.output/public/assets/api-CtarlV0l.js +0 -1
  148. package/.output/public/assets/api-keys-DFF_QqtN.js +0 -1
  149. package/.output/public/assets/api-keys-evfsQ4sN.js +0 -1
  150. package/.output/public/assets/arrow-left-BP9D-ta_.js +0 -1
  151. package/.output/public/assets/arrow-up-right-CDP9Tevw.js +0 -1
  152. package/.output/public/assets/console-features-api-yv7rm3DX.js +0 -1
  153. package/.output/public/assets/dialog-BDvCy_QO.js +0 -1
  154. package/.output/public/assets/empty-C5x9mn_s.js +0 -1
  155. package/.output/public/assets/index-0eg3l8aC.js +0 -10
  156. package/.output/public/assets/insights-2MbdiSNv.js +0 -1
  157. package/.output/public/assets/insights-C6tmCZHk.js +0 -2
  158. package/.output/public/assets/insights-CadS_aIA.js +0 -42
  159. package/.output/public/assets/insights_.distribution-BhBs6PNA.js +0 -1
  160. package/.output/public/assets/insights_.distribution-CJUH_wAS.js +0 -2
  161. package/.output/public/assets/installations-CH2H7JQt.js +0 -2
  162. package/.output/public/assets/installations-DMeMuwsW.js +0 -1
  163. package/.output/public/assets/installations-DnvxI9Dt.js +0 -1
  164. package/.output/public/assets/mutation-x9L28_CD.js +0 -1
  165. package/.output/public/assets/preload-helper-BN-UkjOE.js +0 -1
  166. package/.output/public/assets/routes-BhK8DuZA.js +0 -1
  167. package/.output/public/assets/sidebar-B45aMqRm.js +0 -3
  168. package/.output/public/assets/styles-Dn0pK1EX.css +0 -2
  169. package/.output/public/assets/table-CwLnN6KX.js +0 -1
  170. package/.output/public/assets/useMutation-CN1ygYEr.js +0 -1
  171. package/.output/public/assets/valueToPercent-C-t8FT0y.js +0 -1
  172. package/.output/server/_ssr/auth.server-Ccqz2iVv.mjs +0 -37
  173. package/.output/server/_ssr/config-DMEJdhoW.mjs +0 -13
  174. package/.output/server/_ssr/config.server-DyypN6cQ.mjs +0 -60
  175. package/.output/server/_ssr/databaseRows-CXxf_VIB.mjs +0 -132
  176. package/.output/server/_ssr/deleteBundle-Dcc21Lbd.mjs +0 -56
  177. package/.output/server/_ssr/server-DKJYsaCP.mjs +0 -7442
  178. package/.output/server/_ssr/start-DpViQGnt.mjs +0 -4
  179. package/.output/server/_tanstack-start-manifest_v-Bb0gKDbb.mjs +0 -124
  180. package/src/lib/server/deleteBundle.ts +0 -136
@@ -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) {
@@ -234,12 +328,40 @@ function addToStart(items, item, max = 0) {
234
328
  const newItems = [item, ...items];
235
329
  return max && newItems.length > max ? newItems.slice(0, -1) : newItems;
236
330
  }
237
- var skipToken = /* @__PURE__ */ Symbol();
331
+ /**
332
+ * Sentinel value that can be passed as a query's `queryFn` to conditionally disable the query (equivalent
333
+ * to `enabled: false`) while preserving full type inference for the query's data. Unlike `enabled: false`,
334
+ * a query disabled via `skipToken` cannot be triggered with `refetch`.
335
+ *
336
+ * @example
337
+ * ```ts
338
+ * new QueryObserver(queryClient, {
339
+ * queryKey: ['post', postId],
340
+ * queryFn: postId != null ? () => fetchPost(postId) : skipToken,
341
+ * })
342
+ * ```
343
+ */
344
+ var skipToken = Symbol();
238
345
  function ensureQueryFn(options, fetchOptions) {
239
346
  if (!options.queryFn && fetchOptions?.initialPromise) return () => fetchOptions.initialPromise;
240
347
  if (!options.queryFn || options.queryFn === skipToken) return () => Promise.reject(/* @__PURE__ */ new Error(`Missing queryFn: '${options.queryHash}'`));
241
348
  return options.queryFn;
242
349
  }
350
+ /**
351
+ * Resolves a `throwOnError` option to a boolean.
352
+ * If `throwOnError` is a function, it is called with `params` (e.g. the error and, depending on the caller,
353
+ * additional context such as the query or mutation) and its result is returned, allowing the throwing
354
+ * behavior to be decided per error. Otherwise, `throwOnError` itself is coerced to a boolean (`undefined`
355
+ * resolves to `false`).
356
+ *
357
+ * @example
358
+ * ```ts
359
+ * const throwOnError =
360
+ * query.state.error && typeof options.throwOnError === 'function'
361
+ * ? shouldThrowError(options.throwOnError, [query.state.error, query])
362
+ * : options.throwOnError
363
+ * ```
364
+ */
243
365
  function shouldThrowError(throwOnError, params) {
244
366
  if (typeof throwOnError === "function") return throwOnError(...params);
245
367
  return !!throwOnError;
@@ -261,136 +383,244 @@ function addConsumeAwareSignal(object, getSignal, onCancelled) {
261
383
  return object;
262
384
  }
263
385
  //#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
- })();
386
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/environmentManager.js
387
+ var isServerFn = () => isServer$1;
388
+ /**
389
+ * Returns whether the current runtime should be treated as a server environment.
390
+ */
391
+ var isServer = () => isServerFn();
276
392
  //#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
393
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/subscribable.js
394
+ /**
395
+ * The base class behind everything in Query that you can subscribe to: `QueryCache`, `MutationCache`,
396
+ * the observers, and the `FocusManager`/`OnlineManager` behind `focusManager` and `onlineManager`.
397
+ * Subclasses decide what a listener receives and when it is called.
398
+ */
399
+ var Subscribable = class {
400
+ constructor() {
401
+ this.listeners = /* @__PURE__ */ new Set();
402
+ this.subscribe = this.subscribe.bind(this);
403
+ }
404
+ /**
405
+ * Registers a listener to be called on every update this object notifies about. Returns a function
406
+ * that removes the listener again — call it to stop listening. The base class never drops a listener
407
+ * on its own, though some subclasses clear all of theirs in `destroy()`.
408
+ * @param listener - Called on each update, with whatever the subclass passes to its subscribers.
409
+ * @example
410
+ * ```ts
411
+ * const unsubscribe = subscribable.subscribe(() => {
412
+ * // react to the update
413
+ * })
414
+ *
415
+ * unsubscribe()
416
+ * ```
417
+ */
418
+ subscribe(listener) {
419
+ this.listeners.add(listener);
420
+ this.onSubscribe();
421
+ return () => {
422
+ this.listeners.delete(listener);
423
+ this.onUnsubscribe();
424
+ };
425
+ }
426
+ /**
427
+ * Returns `true` while at least one listener is registered, `false` once they have all unsubscribed.
428
+ */
429
+ hasListeners() {
430
+ return this.listeners.size > 0;
431
+ }
432
+ onSubscribe() {}
433
+ onUnsubscribe() {}
434
+ };
435
+ //#endregion
436
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/focusManager.js
437
+ /**
438
+ * The `FocusManager` manages the focus state within TanStack Query.
439
+ *
440
+ * It can be used to change the default event listeners or to manually change the focus state.
441
+ */
442
+ var FocusManager = class extends Subscribable {
443
+ #focused;
444
+ #cleanup;
445
+ #setup;
446
+ constructor() {
447
+ super();
448
+ this.#setup = (onFocus) => {
449
+ if (typeof window !== "undefined" && window.addEventListener) {
450
+ const listener = () => onFocus();
451
+ window.addEventListener("visibilitychange", listener, false);
452
+ return () => {
453
+ window.removeEventListener("visibilitychange", listener);
454
+ };
455
+ }
456
+ };
457
+ }
458
+ onSubscribe() {
459
+ if (!this.#cleanup) this.setEventListener(this.#setup);
460
+ }
461
+ onUnsubscribe() {
462
+ if (!this.hasListeners()) {
463
+ this.#cleanup?.();
464
+ this.#cleanup = void 0;
465
+ }
466
+ }
467
+ /**
468
+ * `setEventListener` can be used to set a custom event listener that will
469
+ * be used to determine the focus state. The provided `setup` function
470
+ * receives a `setFocused` callback: call it with a `boolean` to manually
471
+ * set the focus state, or with no arguments to re-evaluate the current
472
+ * focus state and notify subscribers.
473
+ *
474
+ * @example
475
+ * ```ts
476
+ * import { focusManager } from '@tanstack/query-core'
477
+ *
478
+ * focusManager.setEventListener((handleFocus) => {
479
+ * const listener = () => handleFocus()
480
+ * // Listen to visibilitychange
481
+ * if (typeof window !== 'undefined' && window.addEventListener) {
482
+ * window.addEventListener('visibilitychange', listener, false)
483
+ * }
484
+ *
485
+ * return () => {
486
+ * // Be sure to unsubscribe if a new handler is set
487
+ * window.removeEventListener('visibilitychange', listener)
488
+ * }
489
+ * })
490
+ * ```
491
+ */
492
+ setEventListener(setup) {
493
+ this.#setup = setup;
494
+ this.#cleanup?.();
495
+ this.#cleanup = setup((focused) => {
496
+ if (typeof focused === "boolean") this.setFocused(focused);
497
+ else this.onFocus();
296
498
  });
297
- resolve(value);
298
- };
299
- thenable.reject = (reason) => {
300
- finalize({
301
- status: "rejected",
302
- reason
499
+ }
500
+ /**
501
+ * `setFocused` can be used to manually set the focus state. Set `undefined`
502
+ * to fall back to the default focus check.
503
+ *
504
+ * @example
505
+ * ```ts
506
+ * import { focusManager } from '@tanstack/query-core'
507
+ *
508
+ * // Set focused
509
+ * focusManager.setFocused(true)
510
+ *
511
+ * // Set unfocused
512
+ * focusManager.setFocused(false)
513
+ *
514
+ * // Fallback to the default focus check
515
+ * focusManager.setFocused(undefined)
516
+ * ```
517
+ */
518
+ setFocused(focused) {
519
+ if (this.#focused !== focused) {
520
+ this.#focused = focused;
521
+ this.onFocus();
522
+ }
523
+ }
524
+ /**
525
+ * `onFocus` notifies all subscribed listeners with the current focus state.
526
+ */
527
+ onFocus() {
528
+ const isFocused = this.isFocused();
529
+ this.listeners.forEach((listener) => {
530
+ listener(isFocused);
303
531
  });
304
- reject(reason);
305
- };
306
- return thenable;
307
- }
532
+ }
533
+ /**
534
+ * `isFocused` can be used to get the current focus state.
535
+ */
536
+ isFocused() {
537
+ if (typeof this.#focused === "boolean") return this.#focused;
538
+ return globalThis.document?.visibilityState !== "hidden";
539
+ }
540
+ };
541
+ /**
542
+ * Singleton instance of {@link FocusManager}, used to manage and observe the focus state within TanStack Query.
543
+ */
544
+ var focusManager = new FocusManager();
545
+ //#endregion
546
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/hydration.js
308
547
  function tryResolveSync(promise) {
309
548
  let data;
310
549
  promise.then((result) => {
311
550
  data = result;
312
551
  return result;
313
- }, noop)?.catch(noop);
552
+ }, noop)?.catch?.(noop);
314
553
  if (data !== void 0) return { data };
315
554
  }
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
- };
555
+ function dehydratePromise(query, serializeData, shouldRedactErrors) {
556
+ const promise = query.promise?.then(serializeData).catch((error) => {
557
+ if (shouldRedactErrors?.(error) === false) return Promise.reject(error);
558
+ return Promise.reject(/* @__PURE__ */ new Error("redacted"));
559
+ });
560
+ promise?.catch(noop);
561
+ return promise;
328
562
  }
563
+ /**
564
+ * Dehydrates a single `Query` into a serializable `DehydratedQuery` snapshot. Note that most query config (e.g.
565
+ * `queryFn`, `staleTime`) is not dehydrated but instead meant to be configured again when consuming the
566
+ * de/rehydrated data, typically with `useQuery` on the client. If the query is still `pending`, its in-flight
567
+ * promise is dehydrated too so it can be resumed on the other side instead of re-fetched.
568
+ * @param query - The query to dehydrate.
569
+ * @param serializeData - Optional transform applied to `query.state.data` before it is included in the snapshot.
570
+ * @param shouldRedactErrors - Optional predicate; if it returns `false` for the promise's rejection error, that
571
+ * error is kept as-is instead of being redacted.
572
+ */
329
573
  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
574
  return {
339
575
  dehydratedAt: Date.now(),
340
576
  state: {
341
577
  ...query.state,
342
- ...query.state.data !== void 0 && { data: serializeData(query.state.data) }
578
+ ...query.state.data !== void 0 && { data: serializeData ? serializeData(query.state.data) : query.state.data }
343
579
  },
344
580
  queryKey: query.queryKey,
345
581
  queryHash: query.queryHash,
346
- ...query.state.status === "pending" && { promise: dehydratePromise() },
582
+ ...query.state.status === "pending" && { promise: dehydratePromise(query, serializeData, shouldRedactErrors) },
347
583
  ...query.meta && { meta: query.meta },
348
584
  ...query.queryType && { queryType: query.queryType }
349
585
  };
350
586
  }
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
- }
587
+ /**
588
+ * Restores a `DehydratedState` (as produced by `dehydrate`) into a `QueryClient`'s cache, typically to seed the
589
+ * client with data already fetched on the server. `mutations` and `queries` are each optional on `dehydratedState`.
590
+ * Queries not yet in the cache are built from the dehydrated snapshot; queries that already exist are only updated
591
+ * when the dehydrated data is newer than what's already cached. Newly built queries have their `fetchStatus` reset
592
+ * to `'idle'` so they don't hydrate stuck in a fetching state. If a dehydrated query still had an in-flight
593
+ * promise, it is resumed via `query.fetch()` (reusing that promise as `initialPromise`) rather than re-invoking
594
+ * `queryFn`.
595
+ * @example
596
+ * ```ts
597
+ * // dehydratedState was produced by `dehydrate` on the server
598
+ * // and sent to the client, e.g. embedded in server-rendered markup.
599
+ * const queryClient = new QueryClient()
600
+ *
601
+ * hydrate(queryClient, dehydratedState)
602
+ * ```
603
+ */
371
604
  function hydrate(client, dehydratedState, options) {
372
- if (typeof dehydratedState !== "object" || dehydratedState === null) return;
373
605
  const mutationCache = client.getMutationCache();
374
606
  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 }) => {
607
+ const deserializeData = options?.defaultOptions?.deserializeData ?? client.getDefaultOptions().hydrate?.deserializeData;
608
+ dehydratedState.mutations?.forEach(({ state, ...mutationOptions }) => {
379
609
  mutationCache.build(client, {
380
610
  ...client.getDefaultOptions().hydrate?.mutations,
381
611
  ...options?.defaultOptions?.mutations,
382
612
  ...mutationOptions
383
613
  }, state);
384
614
  });
385
- queries.forEach(({ queryKey, state, queryHash, meta, promise, dehydratedAt, queryType }) => {
615
+ dehydratedState.queries?.forEach(({ queryKey, state, queryHash, meta, promise, dehydratedAt, queryType }) => {
386
616
  const syncData = promise ? tryResolveSync(promise) : void 0;
387
617
  const rawData = state.data === void 0 ? syncData?.data : state.data;
388
- const data = rawData === void 0 ? rawData : deserializeData(rawData);
618
+ const data = rawData === void 0 ? rawData : deserializeData ? deserializeData(rawData) : rawData;
389
619
  let query = queryCache.get(queryHash);
390
620
  const existingQueryIsPending = query?.state.status === "pending";
391
621
  const existingQueryIsFetching = query?.state.fetchStatus === "fetching";
392
622
  if (query) {
393
- const hasNewerSyncData = syncData && dehydratedAt !== void 0 && dehydratedAt > query.state.dataUpdatedAt;
623
+ const hasNewerSyncData = syncData && dehydratedAt > query.state.dataUpdatedAt;
394
624
  if (state.dataUpdatedAt > query.state.dataUpdatedAt || hasNewerSyncData) {
395
625
  const { fetchStatus: _ignored, ...serializedState } = state;
396
626
  query.setState({
@@ -398,6 +628,7 @@ function hydrate(client, dehydratedState, options) {
398
628
  data,
399
629
  ...state.status === "pending" && data !== void 0 && {
400
630
  status: "success",
631
+ dataUpdatedAt: dehydratedAt,
401
632
  ...!existingQueryIsFetching && { fetchStatus: "idle" }
402
633
  }
403
634
  });
@@ -413,13 +644,18 @@ function hydrate(client, dehydratedState, options) {
413
644
  ...state,
414
645
  data,
415
646
  fetchStatus: "idle",
416
- status: state.status === "pending" && data !== void 0 ? "success" : state.status
647
+ status: state.status === "pending" && data !== void 0 ? "success" : state.status,
648
+ ...state.status === "pending" && data !== void 0 && { dataUpdatedAt: dehydratedAt }
417
649
  });
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);
650
+ if (promise && !syncData && !existingQueryIsPending && !existingQueryIsFetching && dehydratedAt > query.state.dataUpdatedAt) query.fetch(void 0, { initialPromise: Promise.resolve(promise).then(deserializeData) }).catch(noop);
419
651
  });
420
652
  }
421
653
  //#endregion
422
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/notifyManager.js
654
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/notifyManager.js
655
+ /**
656
+ * Default scheduling function used by the notify manager.
657
+ * Schedules the callback with the system's `setTimeout(callback, 0)`.
658
+ */
423
659
  var defaultScheduler = systemSetTimeoutZero;
424
660
  function createNotifyManager() {
425
661
  let queue = [];
@@ -479,9 +715,21 @@ function createNotifyManager() {
479
715
  }
480
716
  };
481
717
  }
718
+ /**
719
+ * Handles scheduling and batching callbacks in TanStack Query.
720
+ */
482
721
  var notifyManager = createNotifyManager();
483
722
  //#endregion
484
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/onlineManager.js
723
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/onlineManager.js
724
+ /**
725
+ * The `OnlineManager` manages the online state within TanStack Query. It can
726
+ * be used to change the default event listeners or to manually change the
727
+ * online state.
728
+ *
729
+ * By default, the `onlineManager` assumes an active network connection, and
730
+ * listens to the `online` and `offline` events on the `window` object to
731
+ * detect changes.
732
+ */
485
733
  var OnlineManager = class extends Subscribable {
486
734
  #online = true;
487
735
  #cleanup;
@@ -510,11 +758,43 @@ var OnlineManager = class extends Subscribable {
510
758
  this.#cleanup = void 0;
511
759
  }
512
760
  }
761
+ /**
762
+ * `setEventListener` can be used to set a custom event listener that will
763
+ * be used to determine the online state. The provided `setup` function
764
+ * receives a `setOnline` callback that should be called with a `boolean`
765
+ * whenever the online state changes.
766
+ *
767
+ * @example
768
+ * ```ts
769
+ * import NetInfo from '@react-native-community/netinfo'
770
+ * import { onlineManager } from '@tanstack/query-core'
771
+ *
772
+ * onlineManager.setEventListener((setOnline) => {
773
+ * return NetInfo.addEventListener((state) => {
774
+ * setOnline(!!state.isConnected)
775
+ * })
776
+ * })
777
+ * ```
778
+ */
513
779
  setEventListener(setup) {
514
780
  this.#setup = setup;
515
781
  this.#cleanup?.();
516
782
  this.#cleanup = setup(this.setOnline.bind(this));
517
783
  }
784
+ /**
785
+ * `setOnline` can be used to manually set the online state.
786
+ *
787
+ * @example
788
+ * ```ts
789
+ * import { onlineManager } from '@tanstack/query-core'
790
+ *
791
+ * // Set to online
792
+ * onlineManager.setOnline(true)
793
+ *
794
+ * // Set to offline
795
+ * onlineManager.setOnline(false)
796
+ * ```
797
+ */
518
798
  setOnline(online) {
519
799
  if (this.#online !== online) {
520
800
  this.#online = online;
@@ -523,19 +803,43 @@ var OnlineManager = class extends Subscribable {
523
803
  });
524
804
  }
525
805
  }
806
+ /**
807
+ * `isOnline` can be used to get the current online state.
808
+ */
526
809
  isOnline() {
527
810
  return this.#online;
528
811
  }
529
812
  };
813
+ /**
814
+ * Singleton instance of {@link OnlineManager}, used to manage and observe the online state within TanStack Query.
815
+ */
530
816
  var onlineManager = new OnlineManager();
531
817
  //#endregion
532
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/retryer.js
818
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/retryer.js
533
819
  function defaultRetryDelay(failureCount) {
534
820
  return Math.min(1e3 * 2 ** failureCount, 3e4);
535
821
  }
536
822
  function canFetch(networkMode) {
537
823
  return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
538
824
  }
825
+ /**
826
+ * The error thrown by a `Retryer` (and surfaced to `query.promise`/`mutation`) when a fetch is cancelled, e.g. via
827
+ * `query.cancel()`. `revert`, if `true`, tells the caller to restore the state the query was in before the fetch
828
+ * started instead of surfacing the error. `silent`, if `true`, tells the caller to suppress this error and instead
829
+ * resolve with the promise of the fetch that triggered the cancellation.
830
+ * @example
831
+ * ```ts
832
+ * query.cancel()
833
+ *
834
+ * try {
835
+ * await query.promise
836
+ * } catch (error) {
837
+ * if (error instanceof CancelledError) {
838
+ * // the fetch was cancelled, e.g. via `query.cancel()`
839
+ * }
840
+ * }
841
+ * ```
842
+ */
539
843
  var CancelledError = class extends Error {
540
844
  constructor(options) {
541
845
  super("CancelledError");
@@ -547,8 +851,15 @@ function createRetryer(config) {
547
851
  let isRetryCancelled = false;
548
852
  let failureCount = 0;
549
853
  let continueFn;
550
- const thenable = pendingThenable();
551
- const isResolved = () => thenable.status !== "pending";
854
+ let status = "pending";
855
+ let promiseResolve;
856
+ let promiseReject;
857
+ const promise = new Promise((resolve, reject) => {
858
+ promiseResolve = resolve;
859
+ promiseReject = reject;
860
+ });
861
+ promise.catch(noop);
862
+ const isResolved = () => status !== "pending";
552
863
  const cancel = (cancelOptions) => {
553
864
  if (!isResolved()) {
554
865
  const error = new CancelledError(cancelOptions);
@@ -567,13 +878,15 @@ function createRetryer(config) {
567
878
  const resolve = (value) => {
568
879
  if (!isResolved()) {
569
880
  continueFn?.();
570
- thenable.resolve(value);
881
+ status = "resolved";
882
+ promiseResolve(value);
571
883
  }
572
884
  };
573
885
  const reject = (value) => {
574
886
  if (!isResolved()) {
575
887
  continueFn?.();
576
- thenable.reject(value);
888
+ status = "rejected";
889
+ promiseReject(value);
577
890
  }
578
891
  };
579
892
  const pause = () => {
@@ -598,7 +911,7 @@ function createRetryer(config) {
598
911
  }
599
912
  Promise.resolve(promiseOrValue).then(resolve).catch((error) => {
600
913
  if (isResolved()) return;
601
- const retry = config.retry ?? (environmentManager.isServer() ? 0 : 3);
914
+ const retry = config.retry ?? (isServer() ? 0 : 3);
602
915
  const retryDelay = config.retryDelay ?? defaultRetryDelay;
603
916
  const delay = typeof retryDelay === "function" ? retryDelay(failureCount, error) : retryDelay;
604
917
  const shouldRetry = retry === true || typeof retry === "number" && failureCount < retry || typeof retry === "function" && retry(failureCount, error);
@@ -617,12 +930,12 @@ function createRetryer(config) {
617
930
  });
618
931
  };
619
932
  return {
620
- promise: thenable,
621
- status: () => thenable.status,
933
+ promise,
934
+ status: () => status,
622
935
  cancel,
623
936
  continue: () => {
624
937
  continueFn?.();
625
- return thenable;
938
+ return promise;
626
939
  },
627
940
  cancelRetry,
628
941
  continueRetry,
@@ -630,14 +943,23 @@ function createRetryer(config) {
630
943
  start: () => {
631
944
  if (canStart()) run();
632
945
  else pause().then(run);
633
- return thenable;
946
+ return promise;
634
947
  }
635
948
  };
636
949
  }
637
950
  //#endregion
638
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/removable.js
951
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/removable.js
952
+ /**
953
+ * The base class for cache entries that are garbage collected once nothing is using them —
954
+ * `Query` and `Mutation` both extend it. `gcTime` controls how long an unused entry is kept.
955
+ */
639
956
  var Removable = class {
640
957
  #gcTimeout;
958
+ /**
959
+ * Clears the pending garbage collection timeout, so the entry is no longer scheduled for removal.
960
+ * A subclass may override this to release what it holds on to as well — `Query` also cancels any
961
+ * in-flight fetch.
962
+ */
641
963
  destroy() {
642
964
  this.clearGcTimeout();
643
965
  }
@@ -648,7 +970,7 @@ var Removable = class {
648
970
  }, this.gcTime);
649
971
  }
650
972
  updateGcTime(newGcTime) {
651
- this.gcTime = Math.max(this.gcTime || 0, newGcTime ?? (environmentManager.isServer() ? Infinity : 300 * 1e3));
973
+ this.gcTime = Math.max(this.gcTime || 0, newGcTime ?? (isServer() ? Infinity : 3e5));
652
974
  }
653
975
  clearGcTimeout() {
654
976
  if (this.#gcTimeout !== void 0) {
@@ -658,7 +980,7 @@ var Removable = class {
658
980
  }
659
981
  };
660
982
  //#endregion
661
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js
983
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js
662
984
  function infiniteQueryBehavior(pages) {
663
985
  return { onFetch: (context, query) => {
664
986
  const options = context.options;
@@ -680,15 +1002,15 @@ function infiniteQueryBehavior(pages) {
680
1002
  if (cancelled) return Promise.reject(context.signal.reason);
681
1003
  if (param == null && data.pages.length) return Promise.resolve(data);
682
1004
  const createQueryFnContext = () => {
683
- const queryFnContext2 = {
1005
+ const queryFnContext = {
684
1006
  client: context.client,
685
1007
  queryKey: context.queryKey,
686
1008
  pageParam: param,
687
1009
  direction: previous ? "backward" : "forward",
688
1010
  meta: context.options.meta
689
1011
  };
690
- addSignalProperty(queryFnContext2);
691
- return queryFnContext2;
1012
+ addSignalProperty(queryFnContext);
1013
+ return queryFnContext;
692
1014
  };
693
1015
  const page = await queryFn(createQueryFnContext());
694
1016
  const { maxPages } = context.options;
@@ -736,7 +1058,26 @@ function getPreviousPageParam(options, { pages, pageParams }) {
736
1058
  return pages.length > 0 ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams) : void 0;
737
1059
  }
738
1060
  //#endregion
739
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/query.js
1061
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/query.js
1062
+ /**
1063
+ * Represents a single cached query. A `Query` holds the query's key, options,
1064
+ * state (data/error/status), and the observers currently subscribed to it.
1065
+ *
1066
+ * Instances are created and managed internally by `QueryCache`; application
1067
+ * code typically interacts with queries indirectly through `QueryClient` or
1068
+ * a framework hook like `useQuery`. Direct access to a `Query` instance is
1069
+ * possible via `queryCache.find()`/`findAll()` for inspecting cache state.
1070
+ *
1071
+ * @example
1072
+ * ```ts
1073
+ * const queryCache = queryClient.getQueryCache()
1074
+ * const query = queryCache.find({ queryKey: ['posts'] })
1075
+ *
1076
+ * if (query) {
1077
+ * console.log(query.state.dataUpdatedAt)
1078
+ * }
1079
+ * ```
1080
+ */
740
1081
  var Query = class extends Removable {
741
1082
  #queryType;
742
1083
  #initialState;
@@ -760,15 +1101,24 @@ var Query = class extends Removable {
760
1101
  this.state = config.state ?? this.#initialState;
761
1102
  this.scheduleGc();
762
1103
  }
1104
+ /**
1105
+ * The `meta` object passed in the query's options, if any.
1106
+ */
763
1107
  get meta() {
764
1108
  return this.options.meta;
765
1109
  }
1110
+ /** @internal */
766
1111
  get queryType() {
767
1112
  return this.#queryType;
768
1113
  }
1114
+ /**
1115
+ * The promise for the currently in-flight fetch, if the query is fetching.
1116
+ * `undefined` when the query is not fetching.
1117
+ */
769
1118
  get promise() {
770
1119
  return this.#retryer?.promise;
771
1120
  }
1121
+ /** @internal */
772
1122
  setOptions(options) {
773
1123
  this.options = {
774
1124
  ...this.#defaultOptions,
@@ -787,6 +1137,7 @@ var Query = class extends Removable {
787
1137
  optionalRemove() {
788
1138
  if (!this.observers.length && this.state.fetchStatus === "idle") this.#cache.remove(this);
789
1139
  }
1140
+ /** @internal */
790
1141
  setData(newData, options) {
791
1142
  const data = replaceData(this.state.data, newData, this.options);
792
1143
  this.#dispatch({
@@ -797,60 +1148,141 @@ var Query = class extends Removable {
797
1148
  });
798
1149
  return data;
799
1150
  }
1151
+ /**
1152
+ * Merges the given partial state directly into this query's state, notifying observers. Used
1153
+ * by persistence and broadcast plugins to restore a state snapshot, and by devtools to let a
1154
+ * user manually trigger a loading/error state or edit the cached data.
1155
+ */
800
1156
  setState(state) {
801
1157
  this.#dispatch({
802
1158
  type: "setState",
803
1159
  state
804
1160
  });
805
1161
  }
1162
+ /**
1163
+ * Cancels the query's currently in-flight fetch, if any.
1164
+ * - Returns a promise that resolves once the cancellation has settled.
1165
+ * - If no fetch is in progress, resolves immediately.
1166
+ *
1167
+ * @example
1168
+ * ```ts
1169
+ * await query.cancel()
1170
+ * ```
1171
+ */
806
1172
  cancel(options) {
807
1173
  const promise = this.#retryer?.promise;
808
1174
  this.#retryer?.cancel(options);
809
1175
  return promise ? promise.then(noop).catch(noop) : Promise.resolve();
810
1176
  }
1177
+ /**
1178
+ * Clears the query's garbage collection timeout and silently cancels any
1179
+ * in-flight fetch. Called by `QueryCache` when the query is removed from
1180
+ * the cache.
1181
+ *
1182
+ * @see {@link Query#cancel}
1183
+ */
811
1184
  destroy() {
812
1185
  super.destroy();
813
1186
  this.cancel({ silent: true });
814
1187
  }
1188
+ /** @internal */
815
1189
  get resetState() {
816
1190
  return this.#initialState;
817
1191
  }
1192
+ /**
1193
+ * Resets the query back to its initial state (the state it had when it was
1194
+ * first created, e.g. any `initialData`), destroying it first to cancel any
1195
+ * in-flight fetch.
1196
+ */
818
1197
  reset() {
819
1198
  this.destroy();
820
1199
  this.setState(this.resetState);
821
1200
  }
1201
+ /**
1202
+ * Returns `true` if the query has at least one observer for which `enabled`
1203
+ * does not resolve to `false`.
1204
+ */
822
1205
  isActive() {
823
- return this.observers.some((observer) => resolveQueryBoolean(observer.options.enabled, this) !== false);
1206
+ return this.observers.some((observer) => resolveQueryValue(observer.options.enabled, this) !== false);
824
1207
  }
1208
+ /**
1209
+ * Returns `true` if the query is disabled, meaning it will not fetch
1210
+ * automatically.
1211
+ * - If the query has observers, it is disabled when none of them are active
1212
+ * (see `isActive`).
1213
+ * - If the query has no observers, it is disabled when its `queryFn` is
1214
+ * `skipToken` or it has never been fetched.
1215
+ */
825
1216
  isDisabled() {
826
1217
  if (this.getObserversCount() > 0) return !this.isActive();
827
1218
  return this.options.queryFn === skipToken || !this.isFetched();
828
1219
  }
1220
+ /**
1221
+ * Returns `true` if the query has been fetched, i.e. it has resolved with
1222
+ * either data or an error at least once.
1223
+ */
829
1224
  isFetched() {
830
1225
  return this.state.dataUpdateCount + this.state.errorUpdateCount > 0;
831
1226
  }
1227
+ /**
1228
+ * Returns `true` if the query has at least one observer configured with
1229
+ * `staleTime: 'static'`, meaning it is treated as never stale.
1230
+ */
832
1231
  isStatic() {
833
- if (this.getObserversCount() > 0) return this.observers.some((observer) => resolveStaleTime(observer.options.staleTime, this) === "static");
1232
+ if (this.getObserversCount() > 0) return this.observers.some((observer) => resolveQueryValue(observer.options.staleTime, this) === "static");
834
1233
  return false;
835
1234
  }
1235
+ /**
1236
+ * Returns `true` if the query is stale.
1237
+ * - If the query has observers, defers to whether any observer's current
1238
+ * result reports `isStale` (which accounts for each observer's own
1239
+ * `staleTime` and `enabled` state).
1240
+ * - If the query has no observers, it is considered stale when it has no
1241
+ * data or has been invalidated.
1242
+ *
1243
+ * @see {@link Query#isStaleByTime}
1244
+ * @example
1245
+ * ```ts
1246
+ * if (query.isStale()) {
1247
+ * // refetch or otherwise treat the cached data as outdated
1248
+ * }
1249
+ * ```
1250
+ */
836
1251
  isStale() {
837
1252
  if (this.getObserversCount() > 0) return this.observers.some((observer) => observer.getCurrentResult().isStale);
838
1253
  return this.state.data === void 0 || this.state.isInvalidated;
839
1254
  }
1255
+ /**
1256
+ * Returns `true` if the query's data is stale relative to the given
1257
+ * `staleTime` (defaults to `0`).
1258
+ * - A query with no data is always stale.
1259
+ * - `staleTime: 'static'` is never stale.
1260
+ * - An invalidated query is always stale.
1261
+ * - Otherwise, staleness is based on elapsed time since `dataUpdatedAt`.
1262
+ *
1263
+ * @see {@link Query#isStale}
1264
+ * @example
1265
+ * ```ts
1266
+ * const isStale = query.isStaleByTime(1000 * 60)
1267
+ * ```
1268
+ */
840
1269
  isStaleByTime(staleTime = 0) {
841
1270
  if (this.state.data === void 0) return true;
842
1271
  if (staleTime === "static") return false;
843
1272
  if (this.state.isInvalidated) return true;
844
1273
  return !timeUntilStale(this.state.dataUpdatedAt, staleTime);
845
1274
  }
1275
+ /** @internal */
846
1276
  onFocus() {
847
1277
  this.observers.find((x) => x.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: false });
848
1278
  this.#retryer?.continue();
849
1279
  }
1280
+ /** @internal */
850
1281
  onOnline() {
851
1282
  this.observers.find((x) => x.shouldFetchOnReconnect())?.refetch({ cancelRefetch: false });
852
1283
  this.#retryer?.continue();
853
1284
  }
1285
+ /** @internal */
854
1286
  addObserver(observer) {
855
1287
  if (!this.observers.includes(observer)) {
856
1288
  this.observers.push(observer);
@@ -862,11 +1294,13 @@ var Query = class extends Removable {
862
1294
  });
863
1295
  }
864
1296
  }
1297
+ /** @internal */
865
1298
  removeObserver(observer) {
866
- if (this.observers.includes(observer)) {
867
- this.observers = this.observers.filter((x) => x !== observer);
1299
+ const index = this.observers.indexOf(observer);
1300
+ if (index !== -1) {
1301
+ this.observers.splice(index, 1);
868
1302
  if (!this.observers.length) {
869
- if (this.#retryer) if (this.#abortSignalConsumed || this.#isInitialPausedFetch()) this.#retryer.cancel({ revert: true });
1303
+ if (this.#retryer) if (this.#abortSignalConsumed || this.state.fetchStatus === "paused" && this.state.status === "pending") this.#retryer.cancel({ revert: true });
870
1304
  else this.#retryer.cancelRetry();
871
1305
  this.scheduleGc();
872
1306
  }
@@ -877,15 +1311,42 @@ var Query = class extends Removable {
877
1311
  });
878
1312
  }
879
1313
  }
1314
+ /**
1315
+ * Returns the number of observers currently subscribed to this query.
1316
+ *
1317
+ * @example
1318
+ * ```ts
1319
+ * if (query.getObserversCount() === 0) {
1320
+ * // no component is currently watching this query
1321
+ * }
1322
+ * ```
1323
+ */
880
1324
  getObserversCount() {
881
1325
  return this.observers.length;
882
1326
  }
883
- #isInitialPausedFetch() {
884
- return this.state.fetchStatus === "paused" && this.state.status === "pending";
885
- }
1327
+ /**
1328
+ * Marks the query as invalidated, unless it is already invalidated. This
1329
+ * updates `state.isInvalidated` and notifies observers, but does not by
1330
+ * itself trigger a refetch.
1331
+ *
1332
+ * @example
1333
+ * ```ts
1334
+ * query.invalidate()
1335
+ * ```
1336
+ */
886
1337
  invalidate() {
887
1338
  if (!this.state.isInvalidated) this.#dispatch({ type: "invalidate" });
888
1339
  }
1340
+ /**
1341
+ * Fetches the query, i.e. runs its `queryFn` (through any configured
1342
+ * retryer/behavior) and updates the query's state with the result.
1343
+ * - If a fetch is already in flight, returns its promise instead of
1344
+ * starting a new one, unless `fetchOptions.cancelRefetch` is set and the
1345
+ * query already has data, in which case the current fetch is silently
1346
+ * cancelled first.
1347
+ * - If `options` is passed, it replaces the query's current options
1348
+ * before fetching.
1349
+ */
889
1350
  async fetch(options, fetchOptions) {
890
1351
  if (this.state.fetchStatus !== "idle" && this.#retryer?.status() !== "rejected") {
891
1352
  if (this.state.data !== void 0 && fetchOptions?.cancelRefetch) this.cancel({ silent: true });
@@ -912,13 +1373,13 @@ var Query = class extends Removable {
912
1373
  const fetchFn = () => {
913
1374
  const queryFn = ensureQueryFn(this.options, fetchOptions);
914
1375
  const createQueryFnContext = () => {
915
- const queryFnContext2 = {
1376
+ const queryFnContext = {
916
1377
  client: this.#client,
917
1378
  queryKey: this.queryKey,
918
1379
  meta: this.meta
919
1380
  };
920
- addSignalProperty(queryFnContext2);
921
- return queryFnContext2;
1381
+ addSignalProperty(queryFnContext);
1382
+ return queryFnContext;
922
1383
  };
923
1384
  const queryFnContext = createQueryFnContext();
924
1385
  this.#abortSignalConsumed = false;
@@ -926,7 +1387,7 @@ var Query = class extends Removable {
926
1387
  return queryFn(queryFnContext);
927
1388
  };
928
1389
  const createFetchContext = () => {
929
- const context2 = {
1390
+ const context = {
930
1391
  fetchOptions,
931
1392
  options: this.options,
932
1393
  queryKey: this.queryKey,
@@ -934,8 +1395,8 @@ var Query = class extends Removable {
934
1395
  state: this.state,
935
1396
  fetchFn
936
1397
  };
937
- addSignalProperty(context2);
938
- return context2;
1398
+ addSignalProperty(context);
1399
+ return context;
939
1400
  };
940
1401
  const context = createFetchContext();
941
1402
  (this.#queryType === "infinite" ? infiniteQueryBehavior(this.options.pages) : this.options.behavior)?.onFetch(context, this);
@@ -944,7 +1405,7 @@ var Query = class extends Removable {
944
1405
  type: "fetch",
945
1406
  meta: context.fetchOptions?.meta
946
1407
  });
947
- this.#retryer = createRetryer({
1408
+ const retryer = this.#retryer = createRetryer({
948
1409
  initialPromise: fetchOptions?.initialPromise,
949
1410
  fn: context.fetchFn,
950
1411
  onCancel: (error) => {
@@ -973,7 +1434,7 @@ var Query = class extends Removable {
973
1434
  canRun: () => true
974
1435
  });
975
1436
  try {
976
- const data = await this.#retryer.start();
1437
+ const data = await retryer.start();
977
1438
  if (data === void 0) throw new Error(`${this.queryHash} data is undefined`);
978
1439
  this.setData(data);
979
1440
  this.#cache.config.onSuccess?.(data, this);
@@ -995,6 +1456,7 @@ var Query = class extends Removable {
995
1456
  this.#cache.config.onSettled?.(this.state.data, error, this);
996
1457
  throw error;
997
1458
  } finally {
1459
+ if (this.#retryer === retryer) this.#retryer = void 0;
998
1460
  this.scheduleGc();
999
1461
  }
1000
1462
  }
@@ -1057,7 +1519,7 @@ var Query = class extends Removable {
1057
1519
  };
1058
1520
  this.state = reducer(this.state);
1059
1521
  notifyManager.batch(() => {
1060
- this.observers.forEach((observer) => {
1522
+ this.observers.slice().forEach((observer) => {
1061
1523
  observer.onQueryUpdate();
1062
1524
  });
1063
1525
  this.#cache.notify({
@@ -1108,24 +1570,34 @@ function getDefaultState$1(options) {
1108
1570
  };
1109
1571
  }
1110
1572
  //#endregion
1111
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/queryObserver.js
1573
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/queryObserver.js
1574
+ /**
1575
+ * A `QueryObserver` watches a single query in the `QueryCache` and computes a
1576
+ * `QueryObserverResult` from its state, recomputing and notifying subscribers
1577
+ * whenever the underlying query (or the observer's options) changes. It is
1578
+ * the primitive that framework adapters (e.g. `useQuery`) build their hooks
1579
+ * on top of, but it can also be used directly to observe and switch between
1580
+ * queries outside of any framework.
1581
+ *
1582
+ * @example
1583
+ * ```ts
1584
+ * const observer = new QueryObserver(queryClient, {
1585
+ * queryKey: ['posts'],
1586
+ * queryFn: fetchPosts,
1587
+ * })
1588
+ *
1589
+ * const unsubscribe = observer.subscribe((result) => {
1590
+ * console.log(result.data)
1591
+ * })
1592
+ * ```
1593
+ */
1112
1594
  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
1595
  #client;
1123
1596
  #currentQuery = void 0;
1124
1597
  #currentQueryInitialState = void 0;
1125
1598
  #currentResult = void 0;
1126
1599
  #currentResultState;
1127
1600
  #currentResultOptions;
1128
- #currentThenable;
1129
1601
  #selectError;
1130
1602
  #selectFn;
1131
1603
  #selectResult;
@@ -1134,6 +1606,14 @@ var QueryObserver = class extends Subscribable {
1134
1606
  #refetchIntervalId;
1135
1607
  #currentRefetchInterval;
1136
1608
  #trackedProps = /* @__PURE__ */ new Set();
1609
+ constructor(client, options) {
1610
+ super();
1611
+ this.options = options;
1612
+ this.#client = client;
1613
+ this.#selectError = null;
1614
+ this.bindMethods();
1615
+ this.setOptions(options);
1616
+ }
1137
1617
  bindMethods() {
1138
1618
  this.refetch = this.refetch.bind(this);
1139
1619
  }
@@ -1148,23 +1628,52 @@ var QueryObserver = class extends Subscribable {
1148
1628
  onUnsubscribe() {
1149
1629
  if (!this.hasListeners()) this.destroy();
1150
1630
  }
1631
+ /**
1632
+ * Returns whether the observed query is currently stale and configured
1633
+ * (via the `refetchOnReconnect` option) to refetch when the network
1634
+ * reconnects.
1635
+ */
1151
1636
  shouldFetchOnReconnect() {
1152
1637
  return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnReconnect);
1153
1638
  }
1639
+ /**
1640
+ * Returns whether the observed query is currently stale and configured
1641
+ * (via the `refetchOnWindowFocus` option) to refetch when the window
1642
+ * regains focus.
1643
+ */
1154
1644
  shouldFetchOnWindowFocus() {
1155
1645
  return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnWindowFocus);
1156
1646
  }
1647
+ /**
1648
+ * Stops observing the current query: clears all listeners, cancels the
1649
+ * stale and refetch-interval timers, and removes this observer from the
1650
+ * query it was observing.
1651
+ */
1157
1652
  destroy() {
1158
1653
  this.listeners = /* @__PURE__ */ new Set();
1159
1654
  this.#clearStaleTimeout();
1160
1655
  this.#clearRefetchInterval();
1161
1656
  this.#currentQuery.removeObserver(this);
1162
1657
  }
1658
+ /**
1659
+ * Updates the observer's options. This will re-resolve the query being
1660
+ * observed (switching to a different query if the `queryKey` changed),
1661
+ * trigger a fetch if the new options require one and the observer has
1662
+ * subscribers, recompute the current result, and reschedule the stale and
1663
+ * refetch-interval timers as needed.
1664
+ *
1665
+ * @example
1666
+ * ```ts
1667
+ * observer.setOptions({ queryKey: ['posts', 1], queryFn: () => fetchPost(1) })
1668
+ * // later: switch to a different query, reusing the same observer
1669
+ * observer.setOptions({ queryKey: ['posts', 2], queryFn: () => fetchPost(2) })
1670
+ * ```
1671
+ */
1163
1672
  setOptions(options) {
1164
1673
  const prevOptions = this.options;
1165
1674
  const prevQuery = this.#currentQuery;
1166
1675
  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");
1676
+ 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
1677
  this.#updateQuery();
1169
1678
  this.#currentQuery.setOptions(this.options);
1170
1679
  if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) this.#client.getQueryCache().notify({
@@ -1175,47 +1684,119 @@ var QueryObserver = class extends Subscribable {
1175
1684
  const mounted = this.hasListeners();
1176
1685
  if (mounted && shouldFetchOptionally(this.#currentQuery, prevQuery, this.options, prevOptions)) this.#executeFetch();
1177
1686
  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();
1687
+ 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
1688
  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);
1689
+ if (mounted && (this.#currentQuery !== prevQuery || resolveQueryValue(this.options.enabled, this.#currentQuery) !== resolveQueryValue(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) this.#updateRefetchInterval(nextRefetchInterval);
1181
1690
  }
1691
+ /**
1692
+ * Computes the result the observer would produce for the given (already-defaulted) options
1693
+ * right now, building the underlying `Query` if it doesn't exist yet, without waiting for a
1694
+ * subscription callback. Called by framework adapters on every render (e.g. `useQuery`) so the
1695
+ * returned value is available synchronously, ahead of `setOptions` triggering an actual fetch.
1696
+ */
1182
1697
  getOptimisticResult(options) {
1183
1698
  const query = this.#client.getQueryCache().build(this.#client, options);
1184
1699
  const result = this.createResult(query, options);
1185
- if (shouldAssignObserverCurrentProperties(this, result)) {
1700
+ if (!shallowEqualObjects(this.getCurrentResult(), result)) {
1186
1701
  this.#currentResult = result;
1187
1702
  this.#currentResultOptions = this.options;
1188
1703
  this.#currentResultState = this.#currentQuery.state;
1189
1704
  }
1190
1705
  return result;
1191
1706
  }
1707
+ /**
1708
+ * Returns the most recently computed `QueryObserverResult` for the
1709
+ * observed query. This is a point-in-time read; to be notified of updates
1710
+ * as they happen, subscribe to the observer instead (its inherited
1711
+ * `subscribe` method).
1712
+ *
1713
+ * @example
1714
+ * ```ts
1715
+ * const result = observer.getCurrentResult()
1716
+ * console.log(result.status, result.data)
1717
+ * ```
1718
+ */
1192
1719
  getCurrentResult() {
1193
1720
  return this.#currentResult;
1194
1721
  }
1722
+ /**
1723
+ * Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via
1724
+ * {@link QueryObserver#trackProp} (and an optional `onPropTracked` callback). Used by framework
1725
+ * adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on
1726
+ * properties you actually read" behavior.
1727
+ */
1195
1728
  trackResult(result, onPropTracked) {
1196
1729
  return new Proxy(result, { get: (target, key) => {
1197
1730
  this.trackProp(key);
1198
1731
  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
1732
  return Reflect.get(target, key);
1204
1733
  } });
1205
1734
  }
1735
+ /**
1736
+ * Records that the given `QueryObserverResult` property was read, so a subsequent update only
1737
+ * notifies this observer if a tracked property actually changed. Normally called indirectly via
1738
+ * {@link QueryObserver#trackResult}'s proxy; exposed directly for adapters that track property
1739
+ * access themselves (e.g. through their own reactivity system) instead of via the proxy.
1740
+ */
1206
1741
  trackProp(key) {
1207
1742
  this.#trackedProps.add(key);
1208
1743
  }
1744
+ /**
1745
+ * Returns the `Query` instance this observer is currently observing.
1746
+ */
1209
1747
  getCurrentQuery() {
1210
1748
  return this.#currentQuery;
1211
1749
  }
1750
+ /**
1751
+ * Refetches the observed query and returns a promise that resolves with
1752
+ * the resulting `QueryObserverResult`.
1753
+ *
1754
+ * @example
1755
+ * ```ts
1756
+ * const result = await observer.refetch({ cancelRefetch: false })
1757
+ * console.log(result.data)
1758
+ * ```
1759
+ */
1212
1760
  refetch({ ...options } = {}) {
1213
1761
  return this.fetch({ ...options });
1214
1762
  }
1763
+ /**
1764
+ * Fetches a query defined by the given options without affecting this
1765
+ * observer's own tracked query or result, and returns a promise that
1766
+ * resolves with the `QueryObserverResult` for that fetch. This is useful
1767
+ * for prefetching data that another observer (e.g. a query about to be
1768
+ * navigated to) will need, ahead of time.
1769
+ *
1770
+ * @example
1771
+ * ```ts
1772
+ * const result = await observer.fetchOptimistic({
1773
+ * queryKey: ['posts', 2],
1774
+ * queryFn: () => fetchPost(2),
1775
+ * })
1776
+ * console.log(result.data)
1777
+ * ```
1778
+ */
1215
1779
  fetchOptimistic(options) {
1216
1780
  const defaultedOptions = this.#client.defaultQueryOptions(options);
1217
1781
  const query = this.#client.getQueryCache().build(this.#client, defaultedOptions);
1218
- return query.fetch().then(() => this.createResult(query, defaultedOptions));
1782
+ let unsubscribe = () => {};
1783
+ let resolveEarly;
1784
+ const cachePromise = new Promise((resolve) => {
1785
+ resolveEarly = resolve;
1786
+ unsubscribe = this.#client.getQueryCache().subscribe((event) => {
1787
+ if (event.type === "updated" && event.query.queryHash === query.queryHash && query.state.data !== void 0) {
1788
+ unsubscribe();
1789
+ resolve(this.createResult(query, defaultedOptions));
1790
+ }
1791
+ });
1792
+ });
1793
+ return Promise.race([query.fetch().then(() => {
1794
+ const result = this.createResult(query, defaultedOptions);
1795
+ resolveEarly?.(result);
1796
+ return result;
1797
+ }).finally(() => {
1798
+ unsubscribe();
1799
+ }), cachePromise]);
1219
1800
  }
1220
1801
  fetch(fetchOptions) {
1221
1802
  return this.#executeFetch({
@@ -1232,22 +1813,25 @@ var QueryObserver = class extends Subscribable {
1232
1813
  if (!fetchOptions?.throwOnError) promise = promise.catch(noop);
1233
1814
  return promise;
1234
1815
  }
1816
+ #shouldScheduleTimer(timeout) {
1817
+ return !isServer() && resolveQueryValue(this.options.enabled, this.#currentQuery) !== false && isValidTimeout(timeout);
1818
+ }
1235
1819
  #updateStaleTimeout() {
1236
1820
  this.#clearStaleTimeout();
1237
- const staleTime = resolveStaleTime(this.options.staleTime, this.#currentQuery);
1238
- if (environmentManager.isServer() || this.#currentResult.isStale || !isValidTimeout(staleTime)) return;
1821
+ const staleTime = resolveQueryValue(this.options.staleTime, this.#currentQuery);
1822
+ if (this.#currentResult.isStale || !this.#shouldScheduleTimer(staleTime)) return;
1239
1823
  const timeout = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime) + 1;
1240
1824
  this.#staleTimeoutId = timeoutManager.setTimeout(() => {
1241
1825
  if (!this.#currentResult.isStale) this.updateResult();
1242
1826
  }, timeout);
1243
1827
  }
1244
1828
  #computeRefetchInterval() {
1245
- return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false;
1829
+ return resolveQueryValue(this.options.refetchInterval, this.#currentQuery) ?? false;
1246
1830
  }
1247
1831
  #updateRefetchInterval(nextInterval) {
1248
1832
  this.#clearRefetchInterval();
1249
1833
  this.#currentRefetchInterval = nextInterval;
1250
- if (environmentManager.isServer() || resolveQueryBoolean(this.options.enabled, this.#currentQuery) === false || !isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) return;
1834
+ if (this.#currentRefetchInterval === 0 || !this.#shouldScheduleTimer(this.#currentRefetchInterval)) return;
1251
1835
  this.#refetchIntervalId = timeoutManager.setInterval(() => {
1252
1836
  if (this.options.refetchIntervalInBackground || focusManager.isFocused()) this.#executeFetch();
1253
1837
  }, this.#currentRefetchInterval);
@@ -1314,18 +1898,20 @@ var QueryObserver = class extends Subscribable {
1314
1898
  } catch (selectError) {
1315
1899
  this.#selectError = selectError;
1316
1900
  }
1901
+ else if (data === void 0) this.#selectError = null;
1317
1902
  if (this.#selectError) {
1318
1903
  error = this.#selectError;
1319
1904
  data = this.#selectResult;
1320
1905
  errorUpdatedAt = Date.now();
1321
1906
  status = "error";
1907
+ isPlaceholderData = false;
1322
1908
  }
1323
1909
  const isFetching = newState.fetchStatus === "fetching";
1324
1910
  const isPending = status === "pending";
1325
1911
  const isError = status === "error";
1326
1912
  const isLoading = isPending && isFetching;
1327
1913
  const hasData = data !== void 0;
1328
- const nextResult = {
1914
+ return {
1329
1915
  status,
1330
1916
  fetchStatus: newState.fetchStatus,
1331
1917
  isPending,
@@ -1350,34 +1936,14 @@ var QueryObserver = class extends Subscribable {
1350
1936
  isRefetchError: isError && hasData,
1351
1937
  isStale: isStale(query, options),
1352
1938
  refetch: this.refetch,
1353
- promise: this.#currentThenable,
1354
- isEnabled: resolveQueryBoolean(options.enabled, query) !== false
1939
+ isEnabled: resolveQueryValue(options.enabled, query) !== false
1355
1940
  };
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
1941
  }
1942
+ /**
1943
+ * Recomputes and stores the current result from the current query/options, notifying listeners
1944
+ * if it changed. Framework adapters call this right after subscribing to make sure no query
1945
+ * update was missed in the gap between creating the observer and subscribing to it.
1946
+ */
1381
1947
  updateResult() {
1382
1948
  const prevResult = this.#currentResult;
1383
1949
  const nextResult = this.createResult(this.#currentQuery, this.options);
@@ -1398,7 +1964,16 @@ var QueryObserver = class extends Subscribable {
1398
1964
  return this.#currentResult[typedKey] !== prevResult[typedKey] && includedProps.has(typedKey);
1399
1965
  });
1400
1966
  };
1401
- this.#notify({ listeners: shouldNotifyListeners() });
1967
+ const notifyListeners = shouldNotifyListeners();
1968
+ notifyManager.batch(() => {
1969
+ if (notifyListeners) this.listeners.forEach((listener) => {
1970
+ listener(this.#currentResult);
1971
+ });
1972
+ this.#client.getQueryCache().notify({
1973
+ query: this.#currentQuery,
1974
+ type: "observerResultsUpdated"
1975
+ });
1976
+ });
1402
1977
  }
1403
1978
  #updateQuery() {
1404
1979
  const query = this.#client.getQueryCache().build(this.#client, this.options);
@@ -1411,47 +1986,50 @@ var QueryObserver = class extends Subscribable {
1411
1986
  query.addObserver(this);
1412
1987
  }
1413
1988
  }
1989
+ /** @internal */
1414
1990
  onQueryUpdate() {
1415
1991
  this.updateResult();
1416
1992
  if (this.hasListeners()) this.#updateTimers();
1417
1993
  }
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
1994
  };
1430
1995
  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);
1996
+ return resolveQueryValue(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && resolveQueryValue(options.retryOnMount, query) === false);
1432
1997
  }
1433
1998
  function shouldFetchOnMount(query, options) {
1434
1999
  return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
1435
2000
  }
1436
2001
  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;
2002
+ if (resolveQueryValue(options.enabled, query) !== false && resolveQueryValue(options.staleTime, query) !== "static") {
2003
+ const value = resolveQueryValue(field, query);
1439
2004
  return value === "always" || value !== false && isStale(query, options);
1440
2005
  }
1441
2006
  return false;
1442
2007
  }
1443
2008
  function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
1444
- return (query !== prevQuery || resolveQueryBoolean(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
2009
+ return (query !== prevQuery || resolveQueryValue(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
1445
2010
  }
1446
2011
  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;
2012
+ return resolveQueryValue(options.enabled, query) !== false && query.isStaleByTime(resolveQueryValue(options.staleTime, query));
1452
2013
  }
1453
2014
  //#endregion
1454
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/mutation.js
2015
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/mutation.js
2016
+ /**
2017
+ * Represents a single mutation attempt. A `Mutation` holds the mutation's
2018
+ * options, state (data/error/status), and the `MutationObserver`s currently
2019
+ * subscribed to it.
2020
+ *
2021
+ * Instances are created and managed internally by `MutationCache`; application
2022
+ * code typically interacts with mutations indirectly through `QueryClient` or
2023
+ * a framework hook like `useMutation`. Direct access to a `Mutation` instance
2024
+ * is possible via `mutationCache.find()`/`getAll()` for inspecting cache state.
2025
+ *
2026
+ * @example
2027
+ * ```ts
2028
+ * const mutationCache = queryClient.getMutationCache()
2029
+ *
2030
+ * const mutation = mutationCache.find({ mutationKey: ['addPost'] })
2031
+ * ```
2032
+ */
1455
2033
  var Mutation = class extends Removable {
1456
2034
  #client;
1457
2035
  #observers;
@@ -1467,13 +2045,18 @@ var Mutation = class extends Removable {
1467
2045
  this.setOptions(config.options);
1468
2046
  this.scheduleGc();
1469
2047
  }
2048
+ /** @internal */
1470
2049
  setOptions(options) {
1471
2050
  this.options = options;
1472
2051
  this.updateGcTime(this.options.gcTime);
1473
2052
  }
2053
+ /**
2054
+ * The `meta` object passed in the mutation's options, if any.
2055
+ */
1474
2056
  get meta() {
1475
2057
  return this.options.meta;
1476
2058
  }
2059
+ /** @internal */
1477
2060
  addObserver(observer) {
1478
2061
  if (!this.#observers.includes(observer)) {
1479
2062
  this.#observers.push(observer);
@@ -1485,6 +2068,7 @@ var Mutation = class extends Removable {
1485
2068
  });
1486
2069
  }
1487
2070
  }
2071
+ /** @internal */
1488
2072
  removeObserver(observer) {
1489
2073
  this.#observers = this.#observers.filter((x) => x !== observer);
1490
2074
  this.scheduleGc();
@@ -1498,9 +2082,60 @@ var Mutation = class extends Removable {
1498
2082
  if (!this.#observers.length) if (this.state.status === "pending") this.scheduleGc();
1499
2083
  else this.#mutationCache.remove(this);
1500
2084
  }
2085
+ /**
2086
+ * Resumes a mutation that is currently paused or was restored from a
2087
+ * dehydrated, still-`pending` state.
2088
+ *
2089
+ * - If this mutation has an active retryer (it paused mid-attempt, e.g. due
2090
+ * to the network mode or scope-based queuing), its retryer is resumed.
2091
+ * - Otherwise, if the mutation's status is still `pending` (e.g. it was
2092
+ * dehydrated while an attempt was in flight and never got a retryer in
2093
+ * this instance), `execute` is called again with the last known variables.
2094
+ * - Otherwise the mutation has already settled and this resolves immediately
2095
+ * without running anything again.
2096
+ *
2097
+ * @example
2098
+ * ```ts
2099
+ * // typically driven by reconnect handling, e.g. queryClient.resumePausedMutations()
2100
+ * const mutation = mutationCache.find({ mutationKey: ['addPost'] })
2101
+ * await mutation?.continue()
2102
+ * ```
2103
+ *
2104
+ * @see {@link Mutation#execute}
2105
+ */
1501
2106
  continue() {
1502
- return this.#retryer?.continue() ?? this.execute(this.state.variables);
2107
+ return this.#retryer?.continue() ?? (this.state.status === "pending" ? this.execute(this.state.variables) : Promise.resolve());
1503
2108
  }
2109
+ /**
2110
+ * Runs the mutation function for the given variables through a retryer, and
2111
+ * drives the mutation's state and lifecycle callbacks through to settlement.
2112
+ *
2113
+ * If this mutation's state is already `pending` when `execute` is called
2114
+ * (i.e. it was restored, still in-flight, from a dehydrated state), the
2115
+ * `onMutate` step is skipped and a `continue` action is dispatched to
2116
+ * unpause it; otherwise a `pending` action is dispatched first, then the
2117
+ * mutation cache's `onMutate` and the mutation's own `onMutate` option are
2118
+ * awaited in that order, and the resulting context is stored.
2119
+ *
2120
+ * The mutation function is then run (subject to `retry`/`retryDelay`/
2121
+ * `networkMode`, and to the mutation cache's scope-based serialization).
2122
+ * On success, the cache's `onSuccess`/`onSettled` callbacks run before the
2123
+ * mutation's own `onSuccess`/`onSettled` options, a `success` action is
2124
+ * dispatched, and the resolved data is returned. On failure, the same
2125
+ * cache-then-option ordering is used for `onError`/`onSettled`, but each of
2126
+ * those four callbacks is individually caught so that a throwing callback
2127
+ * cannot mask the original error; an `error` action is then dispatched and
2128
+ * the original error is re-thrown.
2129
+ *
2130
+ * @example
2131
+ * ```ts
2132
+ * // Called internally by `MutationObserver.mutate` and `Mutation.continue` —
2133
+ * // applications normally trigger mutations through those, not this method.
2134
+ * const data = await mutation.execute(variables)
2135
+ * ```
2136
+ *
2137
+ * @see {@link Mutation#continue}
2138
+ */
1504
2139
  async execute(variables) {
1505
2140
  const onContinue = () => {
1506
2141
  this.#dispatch({ type: "continue" });
@@ -1510,7 +2145,7 @@ var Mutation = class extends Removable {
1510
2145
  meta: this.options.meta,
1511
2146
  mutationKey: this.options.mutationKey
1512
2147
  };
1513
- this.#retryer = createRetryer({
2148
+ const retryer = this.#retryer = createRetryer({
1514
2149
  fn: () => {
1515
2150
  if (!this.options.mutationFn) return Promise.reject(/* @__PURE__ */ new Error("No mutationFn found"));
1516
2151
  return this.options.mutationFn(variables, mutationFnContext);
@@ -1532,7 +2167,7 @@ var Mutation = class extends Removable {
1532
2167
  canRun: () => this.#mutationCache.canRun(this)
1533
2168
  });
1534
2169
  const restored = this.state.status === "pending";
1535
- const isPaused = !this.#retryer.canStart();
2170
+ const isPaused = !retryer.canStart();
1536
2171
  try {
1537
2172
  if (restored) onContinue();
1538
2173
  else {
@@ -1550,7 +2185,7 @@ var Mutation = class extends Removable {
1550
2185
  isPaused
1551
2186
  });
1552
2187
  }
1553
- const data = await this.#retryer.start();
2188
+ const data = await retryer.start();
1554
2189
  await this.#mutationCache.config.onSuccess?.(data, variables, this.state.context, this, mutationFnContext);
1555
2190
  await this.options.onSuccess?.(data, variables, this.state.context, mutationFnContext);
1556
2191
  await this.#mutationCache.config.onSettled?.(data, null, this.state.variables, this.state.context, this, mutationFnContext);
@@ -1587,6 +2222,7 @@ var Mutation = class extends Removable {
1587
2222
  });
1588
2223
  throw error;
1589
2224
  } finally {
2225
+ if (this.#retryer === retryer) this.#retryer = void 0;
1590
2226
  this.#mutationCache.runNext(this);
1591
2227
  }
1592
2228
  }
@@ -1665,8 +2301,25 @@ function getDefaultState() {
1665
2301
  };
1666
2302
  }
1667
2303
  //#endregion
1668
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/mutationCache.js
2304
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/mutationCache.js
2305
+ /**
2306
+ * The `MutationCache` is the storage for mutations.
2307
+ *
2308
+ * Normally, you will not interact with the `MutationCache` directly and instead use a
2309
+ * `QueryClient`. You can subscribe to it (inherited from `Subscribable`) to be informed of
2310
+ * safe/known updates to the cache, such as mutations being added, removed, or updated.
2311
+ *
2312
+ * @example
2313
+ * ```ts
2314
+ * const unsubscribe = mutationCache.subscribe((event) => {
2315
+ * console.log(event.type, event.mutation)
2316
+ * })
2317
+ * ```
2318
+ */
1669
2319
  var MutationCache = class extends Subscribable {
2320
+ #mutations;
2321
+ #scopes;
2322
+ #mutationId;
1670
2323
  constructor(config = {}) {
1671
2324
  super();
1672
2325
  this.config = config;
@@ -1674,9 +2327,7 @@ var MutationCache = class extends Subscribable {
1674
2327
  this.#scopes = /* @__PURE__ */ new Map();
1675
2328
  this.#mutationId = 0;
1676
2329
  }
1677
- #mutations;
1678
- #scopes;
1679
- #mutationId;
2330
+ /** @internal */
1680
2331
  build(client, options, state) {
1681
2332
  const mutation = new Mutation({
1682
2333
  client,
@@ -1688,6 +2339,7 @@ var MutationCache = class extends Subscribable {
1688
2339
  this.add(mutation);
1689
2340
  return mutation;
1690
2341
  }
2342
+ /** @internal */
1691
2343
  add(mutation) {
1692
2344
  this.#mutations.add(mutation);
1693
2345
  const scope = scopeFor(mutation);
@@ -1701,6 +2353,7 @@ var MutationCache = class extends Subscribable {
1701
2353
  mutation
1702
2354
  });
1703
2355
  }
2356
+ /** @internal */
1704
2357
  remove(mutation) {
1705
2358
  if (this.#mutations.delete(mutation)) {
1706
2359
  const scope = scopeFor(mutation);
@@ -1719,6 +2372,7 @@ var MutationCache = class extends Subscribable {
1719
2372
  mutation
1720
2373
  });
1721
2374
  }
2375
+ /** @internal */
1722
2376
  canRun(mutation) {
1723
2377
  const scope = scopeFor(mutation);
1724
2378
  if (typeof scope === "string") {
@@ -1726,11 +2380,22 @@ var MutationCache = class extends Subscribable {
1726
2380
  return !firstPendingMutation || firstPendingMutation === mutation;
1727
2381
  } else return true;
1728
2382
  }
2383
+ /** @internal */
1729
2384
  runNext(mutation) {
1730
2385
  const scope = scopeFor(mutation);
1731
2386
  if (typeof scope === "string") return (this.#scopes.get(scope)?.find((m) => m !== mutation && m.state.isPaused))?.continue() ?? Promise.resolve();
1732
2387
  else return Promise.resolve();
1733
2388
  }
2389
+ /**
2390
+ * Removes all mutations from the cache.
2391
+ *
2392
+ * @example
2393
+ * ```ts
2394
+ * const mutationCache = queryClient.getMutationCache()
2395
+ *
2396
+ * mutationCache.clear()
2397
+ * ```
2398
+ */
1734
2399
  clear() {
1735
2400
  notifyManager.batch(() => {
1736
2401
  this.#mutations.forEach((mutation) => {
@@ -1743,9 +2408,37 @@ var MutationCache = class extends Subscribable {
1743
2408
  this.#scopes.clear();
1744
2409
  });
1745
2410
  }
2411
+ /**
2412
+ * Returns all mutations within the cache.
2413
+ *
2414
+ * This is not typically needed for most applications, but can come in handy when needing more
2415
+ * information about a mutation in rare scenarios.
2416
+ *
2417
+ * @example
2418
+ * ```ts
2419
+ * const mutationCache = queryClient.getMutationCache()
2420
+ *
2421
+ * const mutations = mutationCache.getAll()
2422
+ * ```
2423
+ */
1746
2424
  getAll() {
1747
2425
  return Array.from(this.#mutations);
1748
2426
  }
2427
+ /**
2428
+ * A slightly more advanced method that can be used to get an existing mutation instance from
2429
+ * the cache. If the mutation does not exist, `undefined` is returned.
2430
+ *
2431
+ * This is not typically needed for most applications, but can come in handy when needing more
2432
+ * information about a mutation in rare scenarios.
2433
+ *
2434
+ * @see {@link MutationCache#findAll}
2435
+ * @example
2436
+ * ```ts
2437
+ * const mutationCache = queryClient.getMutationCache()
2438
+ *
2439
+ * const mutation = mutationCache.find({ mutationKey: ['addPost'] })
2440
+ * ```
2441
+ */
1749
2442
  find(filters) {
1750
2443
  const defaultedFilters = {
1751
2444
  exact: true,
@@ -1753,9 +2446,25 @@ var MutationCache = class extends Subscribable {
1753
2446
  };
1754
2447
  return this.getAll().find((mutation) => matchMutation(defaultedFilters, mutation));
1755
2448
  }
2449
+ /**
2450
+ * An even more advanced method that can be used to get existing mutation instances from the
2451
+ * cache that match the given filters. If no mutations match, an empty array is returned.
2452
+ *
2453
+ * This is not typically needed for most applications, but can come in handy when needing more
2454
+ * information about mutations in rare scenarios.
2455
+ *
2456
+ * @see {@link MutationCache#find}
2457
+ * @example
2458
+ * ```ts
2459
+ * const mutationCache = queryClient.getMutationCache()
2460
+ *
2461
+ * const mutations = mutationCache.findAll({ mutationKey: ['addPost'] })
2462
+ * ```
2463
+ */
1756
2464
  findAll(filters = {}) {
1757
2465
  return this.getAll().filter((mutation) => matchMutation(filters, mutation));
1758
2466
  }
2467
+ /** @internal */
1759
2468
  notify(event) {
1760
2469
  notifyManager.batch(() => {
1761
2470
  this.listeners.forEach((listener) => {
@@ -1763,6 +2472,7 @@ var MutationCache = class extends Subscribable {
1763
2472
  });
1764
2473
  });
1765
2474
  }
2475
+ /** @internal */
1766
2476
  resumePausedMutations() {
1767
2477
  const pausedMutations = this.getAll().filter((x) => x.state.isPaused);
1768
2478
  return notifyManager.batch(() => Promise.all(pausedMutations.map((mutation) => mutation.continue().catch(noop))));
@@ -1772,7 +2482,22 @@ function scopeFor(mutation) {
1772
2482
  return mutation.options.scope?.id;
1773
2483
  }
1774
2484
  //#endregion
1775
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/mutationObserver.js
2485
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/mutationObserver.js
2486
+ /**
2487
+ * Observes a single mutation and derives a `MutationObserverResult` from it.
2488
+ * A framework hook like `useMutation` creates one `MutationObserver` per hook
2489
+ * call, keeps it stable across re-renders, calls `setOptions` when the options
2490
+ * passed to the hook change, subscribes to it to re-render on updates, and
2491
+ * reads `getCurrentResult()` for the value to return. Calling `mutate()`
2492
+ * builds a new underlying `Mutation` in the `MutationCache` and executes it.
2493
+ *
2494
+ * @example
2495
+ * ```ts
2496
+ * const observer = new MutationObserver(queryClient, {
2497
+ * mutationFn: (variables: { title: string }) => addPost(variables),
2498
+ * })
2499
+ * ```
2500
+ */
1776
2501
  var MutationObserver = class extends Subscribable {
1777
2502
  #client;
1778
2503
  #currentResult = void 0;
@@ -1789,6 +2514,22 @@ var MutationObserver = class extends Subscribable {
1789
2514
  this.mutate = this.mutate.bind(this);
1790
2515
  this.reset = this.reset.bind(this);
1791
2516
  }
2517
+ /**
2518
+ * Updates the observer's options.
2519
+ *
2520
+ * If the new `mutationKey` differs from the previous one (and both were
2521
+ * defined), the observer is reset, detaching it from the mutation it was
2522
+ * observing. Otherwise, if the currently observed mutation is still
2523
+ * `pending`, its options are updated in place as well.
2524
+ *
2525
+ * @example
2526
+ * ```ts
2527
+ * observer.setOptions({
2528
+ * mutationFn: (variables: { title: string }) => addPost(variables),
2529
+ * onSuccess: (data) => console.log(data),
2530
+ * })
2531
+ * ```
2532
+ */
1792
2533
  setOptions(options) {
1793
2534
  const prevOptions = this.options;
1794
2535
  this.options = this.#client.defaultMutationOptions(options);
@@ -1800,22 +2541,68 @@ var MutationObserver = class extends Subscribable {
1800
2541
  if (prevOptions?.mutationKey && this.options.mutationKey && hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)) this.reset();
1801
2542
  else if (this.#currentMutation?.state.status === "pending") this.#currentMutation.setOptions(this.options);
1802
2543
  }
2544
+ onSubscribe() {
2545
+ if (this.listeners.size === 1 && this.#currentMutation) {
2546
+ this.#currentMutation.addObserver(this);
2547
+ this.#updateResult();
2548
+ }
2549
+ }
1803
2550
  onUnsubscribe() {
1804
2551
  if (!this.hasListeners()) this.#currentMutation?.removeObserver(this);
1805
2552
  }
2553
+ /** @internal */
1806
2554
  onMutationUpdate(action) {
1807
2555
  this.#updateResult();
1808
2556
  this.#notify(action);
1809
2557
  }
2558
+ /**
2559
+ * Returns the observer's current result, derived from the observed
2560
+ * mutation's state (or the default, `idle` state if no mutation has been
2561
+ * built yet, e.g. before the first `mutate()` call or after `reset()`).
2562
+ */
1810
2563
  getCurrentResult() {
1811
2564
  return this.#currentResult;
1812
2565
  }
2566
+ /**
2567
+ * Detaches the observer from the mutation it is currently observing (if
2568
+ * any) and resets the observed result back to its default, `idle` state.
2569
+ *
2570
+ * This does not cancel an in-flight mutation; the mutation itself keeps
2571
+ * running to completion and its own callbacks still fire, but this
2572
+ * observer stops reflecting its state and a subsequent `mutate()` call
2573
+ * will build a brand new mutation.
2574
+ *
2575
+ * @example
2576
+ * ```ts
2577
+ * observer.reset()
2578
+ * ```
2579
+ *
2580
+ * @see {@link MutationObserver#mutate}
2581
+ */
1813
2582
  reset() {
1814
2583
  this.#currentMutation?.removeObserver(this);
1815
2584
  this.#currentMutation = void 0;
1816
2585
  this.#updateResult();
1817
2586
  this.#notify();
1818
2587
  }
2588
+ /**
2589
+ * Builds a new `Mutation` in the `MutationCache` using the observer's
2590
+ * current options, detaches this observer from any previously observed
2591
+ * mutation, attaches it to the new one, and executes it with the given
2592
+ * variables.
2593
+ *
2594
+ * The optional per-call `options` (`onSuccess`/`onError`/`onSettled`) are
2595
+ * invoked once the mutation settles, in addition to any callbacks defined
2596
+ * on the observer's own options.
2597
+ *
2598
+ * @example
2599
+ * ```ts
2600
+ * await observer.mutate(
2601
+ * { title: 'New post' },
2602
+ * { onSuccess: (data) => console.log(data) },
2603
+ * )
2604
+ * ```
2605
+ */
1819
2606
  mutate(variables, options) {
1820
2607
  this.#mutateOptions = options;
1821
2608
  this.#currentMutation?.removeObserver(this);
@@ -1876,14 +2663,47 @@ var MutationObserver = class extends Subscribable {
1876
2663
  }
1877
2664
  };
1878
2665
  //#endregion
1879
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/queryCache.js
2666
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/queryCache.js
2667
+ /**
2668
+ * The `QueryCache` is the storage mechanism for TanStack Query. It stores all the data, meta
2669
+ * information, and state of the queries it contains.
2670
+ *
2671
+ * Normally, you will not interact with the `QueryCache` directly and instead use a `QueryClient`
2672
+ * for a specific cache. You can subscribe to it (inherited from `Subscribable`) to be informed of
2673
+ * safe/known updates to the cache, such as queries being added, removed, or updated — updates made
2674
+ * outside of the cache's own tracked mechanisms (e.g. mutating a query's state object directly) do
2675
+ * not notify subscribers.
2676
+ *
2677
+ * @example
2678
+ * ```ts
2679
+ * const unsubscribe = queryCache.subscribe((event) => {
2680
+ * console.log(event.type, event.query)
2681
+ * })
2682
+ * ```
2683
+ */
1880
2684
  var QueryCache = class extends Subscribable {
2685
+ #queries;
1881
2686
  constructor(config = {}) {
1882
2687
  super();
1883
2688
  this.config = config;
1884
2689
  this.#queries = /* @__PURE__ */ new Map();
1885
2690
  }
1886
- #queries;
2691
+ /**
2692
+ * Returns the existing `Query` instance for the given options' `queryKey`/`queryHash`, or
2693
+ * builds and adds a new one to the cache if none exists yet. Used by framework adapters and
2694
+ * plugins (e.g. broadcast/persistence) that need to get-or-create a `Query` directly, bypassing
2695
+ * the reactive `QueryObserver` machinery.
2696
+ *
2697
+ * @example
2698
+ * ```ts
2699
+ * const queryCache = queryClient.getQueryCache()
2700
+ *
2701
+ * const query = queryCache.build(queryClient, {
2702
+ * queryKey: ['posts'],
2703
+ * queryFn: fetchPosts,
2704
+ * })
2705
+ * ```
2706
+ */
1887
2707
  build(client, options, state) {
1888
2708
  const queryKey = options.queryKey;
1889
2709
  const queryHash = options.queryHash ?? hashQueryKeyByOptions(queryKey, options);
@@ -1901,6 +2721,7 @@ var QueryCache = class extends Subscribable {
1901
2721
  }
1902
2722
  return query;
1903
2723
  }
2724
+ /** @internal */
1904
2725
  add(query) {
1905
2726
  if (!this.#queries.has(query.queryHash)) {
1906
2727
  this.#queries.set(query.queryHash, query);
@@ -1910,17 +2731,42 @@ var QueryCache = class extends Subscribable {
1910
2731
  });
1911
2732
  }
1912
2733
  }
2734
+ /**
2735
+ * Destroys the given `Query` and removes it from the cache, notifying subscribers with a
2736
+ * `'removed'` event. A no-op if the query is no longer the one currently stored under its hash
2737
+ * (e.g. it was already replaced). Used by plugins (e.g. the broadcast client) that mirror
2738
+ * removals across `QueryCache` instances.
2739
+ *
2740
+ * @example
2741
+ * ```ts
2742
+ * const queryCache = queryClient.getQueryCache()
2743
+ * const query = queryCache.find({ queryKey: ['posts'] })
2744
+ *
2745
+ * if (query) {
2746
+ * queryCache.remove(query)
2747
+ * }
2748
+ * ```
2749
+ */
1913
2750
  remove(query) {
1914
- const queryInMap = this.#queries.get(query.queryHash);
1915
- if (queryInMap) {
2751
+ if (this.#queries.get(query.queryHash) === query) {
1916
2752
  query.destroy();
1917
- if (queryInMap === query) this.#queries.delete(query.queryHash);
2753
+ this.#queries.delete(query.queryHash);
1918
2754
  this.notify({
1919
2755
  type: "removed",
1920
2756
  query
1921
2757
  });
1922
2758
  }
1923
2759
  }
2760
+ /**
2761
+ * Removes all queries from the cache.
2762
+ *
2763
+ * @example
2764
+ * ```ts
2765
+ * const queryCache = queryClient.getQueryCache()
2766
+ *
2767
+ * queryCache.clear()
2768
+ * ```
2769
+ */
1924
2770
  clear() {
1925
2771
  notifyManager.batch(() => {
1926
2772
  this.getAll().forEach((query) => {
@@ -1928,12 +2774,54 @@ var QueryCache = class extends Subscribable {
1928
2774
  });
1929
2775
  });
1930
2776
  }
2777
+ /**
2778
+ * Returns the `Query` instance stored under the given `queryHash`, or `undefined` if none
2779
+ * exists. Unlike {@link QueryCache#find}, this looks up by the already-computed hash rather
2780
+ * than by `QueryFilters`. Used by plugins (e.g. broadcast/hydration) that already have a hash
2781
+ * to look up directly.
2782
+ *
2783
+ * @example
2784
+ * ```ts
2785
+ * const queryCache = queryClient.getQueryCache()
2786
+ * const queryHash = hashKey(['posts'])
2787
+ *
2788
+ * const query = queryCache.get(queryHash)
2789
+ * ```
2790
+ */
1931
2791
  get(queryHash) {
1932
2792
  return this.#queries.get(queryHash);
1933
2793
  }
2794
+ /**
2795
+ * Returns all queries within the cache.
2796
+ *
2797
+ * @example
2798
+ * ```ts
2799
+ * const queryCache = queryClient.getQueryCache()
2800
+ *
2801
+ * const queries = queryCache.getAll()
2802
+ * ```
2803
+ */
1934
2804
  getAll() {
1935
2805
  return [...this.#queries.values()];
1936
2806
  }
2807
+ /**
2808
+ * A slightly more advanced method that can be used to get an existing query instance from the
2809
+ * cache. This instance not only contains all the state for the query, but all of the instances,
2810
+ * and underlying guts of the query as well. If the query does not exist, `undefined` is
2811
+ * returned.
2812
+ *
2813
+ * This is not typically needed for most applications, but can come in handy when needing more
2814
+ * information about a query in rare scenarios (e.g. looking at `query.state.dataUpdatedAt` to
2815
+ * decide whether a query is fresh enough to be used as an initial value).
2816
+ *
2817
+ * @see {@link QueryCache#findAll}
2818
+ * @example
2819
+ * ```ts
2820
+ * const queryCache = queryClient.getQueryCache()
2821
+ *
2822
+ * const query = queryCache.find({ queryKey: ['posts'] })
2823
+ * ```
2824
+ */
1937
2825
  find(filters) {
1938
2826
  const defaultedFilters = {
1939
2827
  exact: true,
@@ -1941,10 +2829,26 @@ var QueryCache = class extends Subscribable {
1941
2829
  };
1942
2830
  return this.getAll().find((query) => matchQuery(defaultedFilters, query));
1943
2831
  }
2832
+ /**
2833
+ * An even more advanced method that can be used to get existing query instances from the cache
2834
+ * that partially match a query key. If no queries match, an empty array is returned.
2835
+ *
2836
+ * This is not typically needed for most applications, but can come in handy when needing more
2837
+ * information about queries in rare scenarios.
2838
+ *
2839
+ * @see {@link QueryCache#find}
2840
+ * @example
2841
+ * ```ts
2842
+ * const queryCache = queryClient.getQueryCache()
2843
+ *
2844
+ * const queries = queryCache.findAll({ queryKey: ['posts'] })
2845
+ * ```
2846
+ */
1944
2847
  findAll(filters = {}) {
1945
2848
  const queries = this.getAll();
1946
2849
  return Object.keys(filters).length > 0 ? queries.filter((query) => matchQuery(filters, query)) : queries;
1947
2850
  }
2851
+ /** @internal */
1948
2852
  notify(event) {
1949
2853
  notifyManager.batch(() => {
1950
2854
  this.listeners.forEach((listener) => {
@@ -1952,6 +2856,7 @@ var QueryCache = class extends Subscribable {
1952
2856
  });
1953
2857
  });
1954
2858
  }
2859
+ /** @internal */
1955
2860
  onFocus() {
1956
2861
  notifyManager.batch(() => {
1957
2862
  this.getAll().forEach((query) => {
@@ -1959,6 +2864,7 @@ var QueryCache = class extends Subscribable {
1959
2864
  });
1960
2865
  });
1961
2866
  }
2867
+ /** @internal */
1962
2868
  onOnline() {
1963
2869
  notifyManager.batch(() => {
1964
2870
  this.getAll().forEach((query) => {
@@ -1968,7 +2874,25 @@ var QueryCache = class extends Subscribable {
1968
2874
  }
1969
2875
  };
1970
2876
  //#endregion
1971
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/queryClient.js
2877
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/queryClient.js
2878
+ /**
2879
+ * `QueryClient` is used to interact with a cache of queries and mutations. It owns a
2880
+ * `QueryCache` and a `MutationCache` (creating default ones if none are passed in) and holds
2881
+ * the default options that are applied to queries and mutations created through it.
2882
+ *
2883
+ * @example
2884
+ * ```ts
2885
+ * const queryClient = new QueryClient({
2886
+ * defaultOptions: {
2887
+ * queries: {
2888
+ * staleTime: Infinity,
2889
+ * },
2890
+ * },
2891
+ * })
2892
+ *
2893
+ * await queryClient.query({ queryKey: ['posts'], queryFn: fetchPosts })
2894
+ * ```
2895
+ */
1972
2896
  var QueryClient = class {
1973
2897
  #queryCache;
1974
2898
  #mutationCache;
@@ -1986,6 +2910,12 @@ var QueryClient = class {
1986
2910
  this.#mutationDefaults = /* @__PURE__ */ new Map();
1987
2911
  this.#mountCount = 0;
1988
2912
  }
2913
+ /**
2914
+ * Called by a framework adapter's `QueryClientProvider`-equivalent when it mounts, to start
2915
+ * listening for focus/online events and resume paused mutations. Ref-counted via an internal
2916
+ * mount count, so nested or multiple providers sharing the same `QueryClient` don't tear down
2917
+ * the shared listeners until the last one unmounts.
2918
+ */
1989
2919
  mount() {
1990
2920
  this.#mountCount++;
1991
2921
  if (this.#mountCount !== 1) return;
@@ -2002,6 +2932,11 @@ var QueryClient = class {
2002
2932
  }
2003
2933
  });
2004
2934
  }
2935
+ /**
2936
+ * The inverse of {@link QueryClient#mount} — called by a framework adapter's
2937
+ * `QueryClientProvider`-equivalent when it unmounts. Only tears down the focus/online
2938
+ * listeners once the mount count returns to `0`.
2939
+ */
2005
2940
  unmount() {
2006
2941
  this.#mountCount--;
2007
2942
  if (this.#mountCount !== 0) return;
@@ -2010,12 +2945,35 @@ var QueryClient = class {
2010
2945
  this.#unsubscribeOnline?.();
2011
2946
  this.#unsubscribeOnline = void 0;
2012
2947
  }
2948
+ /**
2949
+ * Returns the number of queries in the cache that are currently fetching, optionally
2950
+ * matching a set of filters. This includes background-fetching, loading new pages, and
2951
+ * loading more infinite query results.
2952
+ *
2953
+ * @example
2954
+ * ```ts
2955
+ * if (queryClient.isFetching()) {
2956
+ * console.log('At least one query is fetching!')
2957
+ * }
2958
+ * ```
2959
+ */
2013
2960
  isFetching(filters) {
2014
2961
  return this.#queryCache.findAll({
2015
2962
  ...filters,
2016
2963
  fetchStatus: "fetching"
2017
2964
  }).length;
2018
2965
  }
2966
+ /**
2967
+ * Returns the number of mutations in the cache that are currently pending, optionally
2968
+ * matching a set of filters.
2969
+ *
2970
+ * @example
2971
+ * ```ts
2972
+ * if (queryClient.isMutating()) {
2973
+ * console.log('At least one mutation is pending!')
2974
+ * }
2975
+ * ```
2976
+ */
2019
2977
  isMutating(filters) {
2020
2978
  return this.#mutationCache.findAll({
2021
2979
  ...filters,
@@ -2028,24 +2986,72 @@ var QueryClient = class {
2028
2986
  *
2029
2987
  * Hint: Do not use this function inside a component, because it won't receive updates.
2030
2988
  * Use `useQuery` to create a `QueryObserver` that subscribes to changes.
2989
+ *
2990
+ * @returns The cached data for the query, or `undefined` if no query with this key has been observed yet.
2991
+ * @see {@link QueryClient#getQueriesData}
2031
2992
  */
2032
2993
  getQueryData(queryKey) {
2033
2994
  const options = this.defaultQueryOptions({ queryKey });
2034
2995
  return this.#queryCache.get(options.queryHash)?.state.data;
2035
2996
  }
2997
+ /**
2998
+ * @deprecated Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version.
2999
+ */
2036
3000
  ensureQueryData(options) {
2037
3001
  const defaultedOptions = this.defaultQueryOptions(options);
2038
3002
  const query = this.#queryCache.build(this, defaultedOptions);
2039
3003
  const cachedData = query.state.data;
2040
3004
  if (cachedData === void 0) return this.fetchQuery(options);
2041
- if (options.revalidateIfStale && query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query))) this.prefetchQuery(defaultedOptions);
3005
+ if (options.revalidateIfStale && query.isStaleByTime(resolveQueryValue(defaultedOptions.staleTime, query))) this.prefetchQuery(defaultedOptions);
2042
3006
  return Promise.resolve(cachedData);
2043
3007
  }
3008
+ /**
3009
+ * Imperative (non-reactive) way to retrieve the cached data of multiple queries at once.
3010
+ * Only queries matching the given filters are returned; if none match, an empty array is
3011
+ * returned.
3012
+ *
3013
+ * Because the matched queries can hold data of different shapes (e.g. a broad filter can match
3014
+ * queries with unrelated data types), the `TQueryFnData` generic defaults to `unknown` rather
3015
+ * than being inferred. Passing a more specific type is a convenience for call sites that know
3016
+ * every matched query holds the same shape — it is not checked against the actual cache
3017
+ * contents.
3018
+ *
3019
+ * @returns An array of query key and data pairs. The data is `undefined` for a query with no cached data.
3020
+ * @see {@link QueryClient#getQueryData}
3021
+ * @example
3022
+ * ```ts
3023
+ * const data = queryClient.getQueriesData({ queryKey: ['posts'] })
3024
+ * ```
3025
+ */
2044
3026
  getQueriesData(filters) {
2045
3027
  return this.#queryCache.findAll(filters).map(({ queryKey, state }) => {
2046
3028
  return [queryKey, state.data];
2047
3029
  });
2048
3030
  }
3031
+ /**
3032
+ * Synchronous way to immediately update a query's cached data. If the updater (or the value
3033
+ * passed) resolves to `undefined`, the cache is left untouched and no query is created;
3034
+ * otherwise, if the query does not exist yet, it will be created. To update multiple queries
3035
+ * at once by partially matching query keys, use {@link QueryClient#setQueriesData} instead.
3036
+ *
3037
+ * Updates must be performed immutably: do not mutate `oldData`, or data previously retrieved
3038
+ * via {@link QueryClient#getQueryData}, in place.
3039
+ *
3040
+ * @param queryKey - The query key to set data for.
3041
+ * @param updater - Either the new data, or a function that receives the current data (which
3042
+ * may be `undefined`) and returns the new data.
3043
+ * @param options - Set `updatedAt` to override the timestamp the written data is recorded with.
3044
+ * @returns The data that was written, or `undefined` if the updater returned `undefined` — in that case
3045
+ * the write is skipped and the cache is left unchanged.
3046
+ *
3047
+ * @example
3048
+ * ```ts
3049
+ * queryClient.setQueryData(['posts'], newPosts)
3050
+ *
3051
+ * // Or, using an updater function that receives the current data:
3052
+ * queryClient.setQueryData(['posts'], (oldPosts) => [...oldPosts, newPost])
3053
+ * ```
3054
+ */
2049
3055
  setQueryData(queryKey, updater, options) {
2050
3056
  const defaultedOptions = this.defaultQueryOptions({ queryKey });
2051
3057
  const prevData = this.#queryCache.get(defaultedOptions.queryHash)?.state.data;
@@ -2056,13 +3062,49 @@ var QueryClient = class {
2056
3062
  manual: true
2057
3063
  });
2058
3064
  }
3065
+ /**
3066
+ * Synchronous way to immediately update the cached data of multiple queries at once, using
3067
+ * filters or partial query key matching. Only queries that already exist and match the given
3068
+ * filters are updated; no new cache entries are created. Internally this calls
3069
+ * {@link QueryClient#setQueryData} for each matching query.
3070
+ *
3071
+ * @returns One `[queryKey, data]` tuple per matched query, in the same shape and with the same
3072
+ * `undefined` case as {@link QueryClient#setQueryData}.
3073
+ * @example
3074
+ * ```ts
3075
+ * queryClient.setQueriesData({ queryKey: ['posts'] }, (oldPosts) =>
3076
+ * oldPosts ? oldPosts.filter((post) => post.id !== deletedId) : oldPosts,
3077
+ * )
3078
+ * ```
3079
+ */
2059
3080
  setQueriesData(filters, updater, options) {
2060
3081
  return notifyManager.batch(() => this.#queryCache.findAll(filters).map(({ queryKey }) => [queryKey, this.setQueryData(queryKey, updater, options)]));
2061
3082
  }
3083
+ /**
3084
+ * Imperative (non-reactive) way to retrieve an existing query's state. If the query does not
3085
+ * exist, `undefined` is returned.
3086
+ *
3087
+ * @example
3088
+ * ```ts
3089
+ * const state = queryClient.getQueryState(['posts'])
3090
+ * console.log(state?.dataUpdatedAt)
3091
+ * ```
3092
+ */
2062
3093
  getQueryState(queryKey) {
2063
3094
  const options = this.defaultQueryOptions({ queryKey });
2064
3095
  return this.#queryCache.get(options.queryHash)?.state;
2065
3096
  }
3097
+ /**
3098
+ * Removes queries from the cache that match the given filters. Unlike
3099
+ * {@link QueryClient#invalidateQueries} or {@link QueryClient#refetchQueries}, this removes
3100
+ * matching queries from the cache instead of refetching them. Without filters, every query in
3101
+ * the cache is removed.
3102
+ *
3103
+ * @example
3104
+ * ```ts
3105
+ * queryClient.removeQueries({ queryKey: ['posts'], exact: true })
3106
+ * ```
3107
+ */
2066
3108
  removeQueries(filters) {
2067
3109
  const queryCache = this.#queryCache;
2068
3110
  notifyManager.batch(() => {
@@ -2071,18 +3113,43 @@ var QueryClient = class {
2071
3113
  });
2072
3114
  });
2073
3115
  }
3116
+ /**
3117
+ * Resets queries matching the given filters back to their initial state (e.g. any
3118
+ * `initialData`), notifying subscribers rather than removing them. Active queries among the
3119
+ * matched set are then refetched, and the returned promise resolves once that refetch settles.
3120
+ *
3121
+ * @example
3122
+ * ```ts
3123
+ * await queryClient.resetQueries({ queryKey: ['posts'], exact: true })
3124
+ * ```
3125
+ */
2074
3126
  resetQueries(filters, options) {
2075
3127
  const queryCache = this.#queryCache;
2076
3128
  return notifyManager.batch(() => {
2077
- queryCache.findAll(filters).forEach((query) => {
3129
+ const matched = queryCache.findAll(filters);
3130
+ const queriesToRefetch = new Set(matched);
3131
+ matched.forEach((query) => {
2078
3132
  query.reset();
2079
3133
  });
2080
3134
  return this.refetchQueries({
2081
3135
  type: "active",
2082
- ...filters
3136
+ predicate: (query) => queriesToRefetch.has(query)
2083
3137
  }, options);
2084
3138
  });
2085
3139
  }
3140
+ /**
3141
+ * Cancels outgoing fetches for queries matching the given filters. Most useful when performing
3142
+ * optimistic updates, since any outgoing refetch that resolves afterwards would otherwise
3143
+ * overwrite the optimistic update. By default (`revert: true`), a cancelled query's data is
3144
+ * reverted to its state before the outgoing fetch started.
3145
+ *
3146
+ * The returned promise never rejects, even if individual cancellations fail.
3147
+ *
3148
+ * @example
3149
+ * ```ts
3150
+ * await queryClient.cancelQueries({ queryKey: ['posts'], exact: true })
3151
+ * ```
3152
+ */
2086
3153
  cancelQueries(filters, cancelOptions = {}) {
2087
3154
  const defaultedCancelOptions = {
2088
3155
  revert: true,
@@ -2091,6 +3158,19 @@ var QueryClient = class {
2091
3158
  const promises = notifyManager.batch(() => this.#queryCache.findAll(filters).map((query) => query.cancel(defaultedCancelOptions)));
2092
3159
  return Promise.all(promises).then(noop).catch(noop);
2093
3160
  }
3161
+ /**
3162
+ * Marks queries matching the given filters as invalidated. Unlike
3163
+ * {@link QueryClient#removeQueries}, invalidated queries stay in the cache.
3164
+ *
3165
+ * Unless `filters.refetchType` is `'none'`, matching queries are then refetched via
3166
+ * {@link QueryClient#refetchQueries}, using `filters.refetchType` if set, otherwise
3167
+ * `filters.type`, otherwise `'active'`.
3168
+ *
3169
+ * @example
3170
+ * ```ts
3171
+ * await queryClient.invalidateQueries({ queryKey: ['posts'], refetchType: 'active' })
3172
+ * ```
3173
+ */
2094
3174
  invalidateQueries(filters, options = {}) {
2095
3175
  return notifyManager.batch(() => {
2096
3176
  this.#queryCache.findAll(filters).forEach((query) => {
@@ -2103,6 +3183,21 @@ var QueryClient = class {
2103
3183
  }, options);
2104
3184
  });
2105
3185
  }
3186
+ /**
3187
+ * Refetches queries matching the given filters, regardless of whether they are stale. Without
3188
+ * filters, every query in the cache is refetched. Queries that are disabled, or static (only
3189
+ * have observers with a static `staleTime`), are never refetched.
3190
+ *
3191
+ * By default (`cancelRefetch: true`), a currently running fetch is cancelled before the new
3192
+ * one starts. The returned promise resolves once all matching queries have settled; it does
3193
+ * not reject on individual query failures unless `throwOnError` is set.
3194
+ *
3195
+ * @example
3196
+ * ```ts
3197
+ * // refetch all active queries partially matching a query key:
3198
+ * await queryClient.refetchQueries({ queryKey: ['posts'], type: 'active' })
3199
+ * ```
3200
+ */
2106
3201
  refetchQueries(filters, options = {}) {
2107
3202
  const fetchOptions = {
2108
3203
  ...options,
@@ -2115,48 +3210,218 @@ var QueryClient = class {
2115
3210
  }));
2116
3211
  return Promise.all(promises).then(noop);
2117
3212
  }
3213
+ /**
3214
+ * Asynchronous method to fetch and cache a query, resolving with the data or throwing with
3215
+ * the error.
3216
+ *
3217
+ * If the query already exists in the cache and its data is not stale (per the given
3218
+ * `staleTime`), the cached data is returned without fetching. Otherwise, the query is fetched
3219
+ * and the promise resolves once the fetch settles. If a `select` function is provided, it is
3220
+ * applied to the data in both cases (cached or freshly fetched) before it is returned.
3221
+ *
3222
+ * Unlike a reactive observer, retries are disabled by default here (`retry: false`) unless
3223
+ * explicitly configured, since there is no component to catch a thrown error and retry through
3224
+ * re-render.
3225
+ *
3226
+ * The accepted options are `QueryObserverOptions` minus the fields that only make sense for a
3227
+ * reactive observer — `enabled`, `refetchInterval`, `refetchIntervalInBackground`,
3228
+ * `refetchOnWindowFocus`, `refetchOnReconnect`, `refetchOnMount`, `retryOnMount`,
3229
+ * `notifyOnChangeProps`, `throwOnError`, `suspense`, and `placeholderData` are not part of this
3230
+ * method's options.
3231
+ *
3232
+ * This method replaces the deprecated `fetchQuery`, and — combined with
3233
+ * `{ staleTime: 'static' }` — the deprecated `ensureQueryData`.
3234
+ *
3235
+ * @example
3236
+ * ```ts
3237
+ * try {
3238
+ * const data = await queryClient.query({ queryKey, queryFn, staleTime: 10000 })
3239
+ * } catch (error) {
3240
+ * console.log(error)
3241
+ * }
3242
+ * ```
3243
+ */
3244
+ async query(options) {
3245
+ const defaultedOptions = this.defaultQueryOptions(options);
3246
+ if (defaultedOptions.retry === void 0) defaultedOptions.retry = false;
3247
+ const query = this.#queryCache.build(this, defaultedOptions);
3248
+ const queryData = query.isStaleByTime(resolveQueryValue(defaultedOptions.staleTime, query)) ? await query.fetch(defaultedOptions) : query.state.data;
3249
+ const select = defaultedOptions.select;
3250
+ if (select) return select(queryData);
3251
+ return queryData;
3252
+ }
3253
+ /**
3254
+ * @deprecated Use queryClient.query(options) instead. This method will be removed in the next major version.
3255
+ */
2118
3256
  fetchQuery(options) {
2119
3257
  const defaultedOptions = this.defaultQueryOptions(options);
2120
3258
  if (defaultedOptions.retry === void 0) defaultedOptions.retry = false;
2121
3259
  const query = this.#queryCache.build(this, defaultedOptions);
2122
- return query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query)) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data);
3260
+ return query.isStaleByTime(resolveQueryValue(defaultedOptions.staleTime, query)) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data);
2123
3261
  }
3262
+ /**
3263
+ * @deprecated Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version.
3264
+ */
2124
3265
  prefetchQuery(options) {
2125
3266
  return this.fetchQuery(options).then(noop).catch(noop);
2126
3267
  }
3268
+ /**
3269
+ * Asynchronous method to fetch and cache an infinite query, resolving with an
3270
+ * {@link InfiniteData} object or throwing with the error.
3271
+ *
3272
+ * Behaves like {@link QueryClient#query}, accepting the same options (minus
3273
+ * `initialPageParam`), plus the required `initialPageParam`, and an optional `pages` /
3274
+ * `getNextPageParam` pair used to refetch a fixed number of pages from the start.
3275
+ *
3276
+ * This method replaces the deprecated `fetchInfiniteQuery`, and — combined with
3277
+ * `{ staleTime: 'static' }` — the deprecated `ensureInfiniteQueryData`.
3278
+ *
3279
+ * @example
3280
+ * ```ts
3281
+ * try {
3282
+ * const data = await queryClient.infiniteQuery({ queryKey, queryFn, initialPageParam: 0 })
3283
+ * console.log(data.pages)
3284
+ * } catch (error) {
3285
+ * console.log(error)
3286
+ * }
3287
+ * ```
3288
+ */
3289
+ infiniteQuery(options) {
3290
+ options._type = "infinite";
3291
+ return this.query(options);
3292
+ }
3293
+ /**
3294
+ * @deprecated Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version.
3295
+ */
2127
3296
  fetchInfiniteQuery(options) {
2128
3297
  options._type = "infinite";
2129
3298
  return this.fetchQuery(options);
2130
3299
  }
3300
+ /**
3301
+ * @deprecated Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version.
3302
+ */
2131
3303
  prefetchInfiniteQuery(options) {
2132
3304
  return this.fetchInfiniteQuery(options).then(noop).catch(noop);
2133
3305
  }
3306
+ /**
3307
+ * @deprecated Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version.
3308
+ */
2134
3309
  ensureInfiniteQueryData(options) {
2135
3310
  options._type = "infinite";
2136
3311
  return this.ensureQueryData(options);
2137
3312
  }
3313
+ /**
3314
+ * Resumes mutations that were paused because there was no network connection. Does nothing
3315
+ * (resolving immediately) if the client is currently offline.
3316
+ *
3317
+ * @example
3318
+ * ```ts
3319
+ * import { QueryClient } from '@tanstack/query-core'
3320
+ *
3321
+ * const queryClient = new QueryClient()
3322
+ * await queryClient.resumePausedMutations()
3323
+ * ```
3324
+ */
2138
3325
  resumePausedMutations() {
2139
3326
  if (onlineManager.isOnline()) return this.#mutationCache.resumePausedMutations();
2140
3327
  return Promise.resolve();
2141
3328
  }
3329
+ /**
3330
+ * Returns the query cache this client is connected to.
3331
+ *
3332
+ * @example
3333
+ * ```ts
3334
+ * import { QueryClient } from '@tanstack/query-core'
3335
+ *
3336
+ * const queryClient = new QueryClient()
3337
+ * const queryCache = queryClient.getQueryCache()
3338
+ * const queries = queryCache.findAll({ queryKey: ['posts'] })
3339
+ * ```
3340
+ */
2142
3341
  getQueryCache() {
2143
3342
  return this.#queryCache;
2144
3343
  }
3344
+ /**
3345
+ * Returns the mutation cache this client is connected to.
3346
+ *
3347
+ * @example
3348
+ * ```ts
3349
+ * import { QueryClient } from '@tanstack/query-core'
3350
+ *
3351
+ * const queryClient = new QueryClient()
3352
+ * const mutationCache = queryClient.getMutationCache()
3353
+ * const mutations = mutationCache.findAll({ status: 'pending' })
3354
+ * ```
3355
+ */
2145
3356
  getMutationCache() {
2146
3357
  return this.#mutationCache;
2147
3358
  }
3359
+ /**
3360
+ * Returns the default options that were set when creating the client, or via
3361
+ * {@link QueryClient#setDefaultOptions}.
3362
+ *
3363
+ * @example
3364
+ * ```ts
3365
+ * import { QueryClient } from '@tanstack/query-core'
3366
+ *
3367
+ * const queryClient = new QueryClient()
3368
+ * const defaultOptions = queryClient.getDefaultOptions()
3369
+ * ```
3370
+ */
2148
3371
  getDefaultOptions() {
2149
3372
  return this.#defaultOptions;
2150
3373
  }
3374
+ /**
3375
+ * Dynamically sets the default options for this client, overwriting any previously defined
3376
+ * default options.
3377
+ *
3378
+ * @see {@link QueryClient#getDefaultOptions}
3379
+ * @example
3380
+ * ```ts
3381
+ * import { QueryClient } from '@tanstack/query-core'
3382
+ *
3383
+ * const queryClient = new QueryClient()
3384
+ * queryClient.setDefaultOptions({
3385
+ * queries: {
3386
+ * staleTime: Infinity,
3387
+ * },
3388
+ * })
3389
+ * ```
3390
+ */
2151
3391
  setDefaultOptions(options) {
2152
3392
  this.#defaultOptions = options;
2153
3393
  }
3394
+ /**
3395
+ * Sets default options for queries whose query key partially matches the given `queryKey`.
3396
+ *
3397
+ * If several registered query defaults match a given query key, they are merged together in
3398
+ * registration order by {@link QueryClient#getQueryDefaults}, so register defaults from the
3399
+ * most generic key to the least generic one — more specific defaults should be registered
3400
+ * after more generic ones so they take precedence.
3401
+ *
3402
+ * @example
3403
+ * ```ts
3404
+ * queryClient.setQueryDefaults(['posts'], { queryFn: fetchPosts })
3405
+ *
3406
+ * await queryClient.query({ queryKey: ['posts'] })
3407
+ * ```
3408
+ */
2154
3409
  setQueryDefaults(queryKey, options) {
2155
3410
  this.#queryDefaults.set(hashKey(queryKey), {
2156
3411
  queryKey,
2157
3412
  defaultOptions: options
2158
3413
  });
2159
3414
  }
3415
+ /**
3416
+ * Returns the default options registered for queries whose query key partially matches the
3417
+ * given `queryKey`, via {@link QueryClient#setQueryDefaults}. If multiple registered defaults
3418
+ * match, they are merged together in registration order.
3419
+ *
3420
+ * @example
3421
+ * ```ts
3422
+ * const defaultOptions = queryClient.getQueryDefaults(['posts'])
3423
+ * ```
3424
+ */
2160
3425
  getQueryDefaults(queryKey) {
2161
3426
  const defaults = [...this.#queryDefaults.values()];
2162
3427
  const result = {};
@@ -2165,12 +3430,33 @@ var QueryClient = class {
2165
3430
  });
2166
3431
  return result;
2167
3432
  }
3433
+ /**
3434
+ * Sets default options for mutations whose mutation key partially matches the given
3435
+ * `mutationKey`. As with {@link QueryClient#setQueryDefaults}, the order of registration
3436
+ * matters when several registered defaults match the same mutation key.
3437
+ *
3438
+ * @see {@link QueryClient#getMutationDefaults}
3439
+ * @example
3440
+ * ```ts
3441
+ * queryClient.setMutationDefaults(['addPost'], { mutationFn: addPost })
3442
+ * ```
3443
+ */
2168
3444
  setMutationDefaults(mutationKey, options) {
2169
3445
  this.#mutationDefaults.set(hashKey(mutationKey), {
2170
3446
  mutationKey,
2171
3447
  defaultOptions: options
2172
3448
  });
2173
3449
  }
3450
+ /**
3451
+ * Returns the default options registered for mutations whose mutation key partially matches
3452
+ * the given `mutationKey`, via {@link QueryClient#setMutationDefaults}. If multiple registered
3453
+ * defaults match, they are merged together in registration order.
3454
+ *
3455
+ * @example
3456
+ * ```ts
3457
+ * const defaultOptions = queryClient.getMutationDefaults(['addPost'])
3458
+ * ```
3459
+ */
2174
3460
  getMutationDefaults(mutationKey) {
2175
3461
  const defaults = [...this.#mutationDefaults.values()];
2176
3462
  const result = {};
@@ -2179,6 +3465,12 @@ var QueryClient = class {
2179
3465
  });
2180
3466
  return result;
2181
3467
  }
3468
+ /**
3469
+ * Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the
3470
+ * caller into their final, defaulted form: merging `queryClient.setQueryDefaults` for the
3471
+ * given `queryKey`, then the client's own `defaultOptions.queries`, then the caller's options
3472
+ * on top. A no-op if the options are already defaulted (`_defaulted: true`).
3473
+ */
2182
3474
  defaultQueryOptions(options) {
2183
3475
  if (options._defaulted) return options;
2184
3476
  const defaultedOptions = {
@@ -2194,6 +3486,12 @@ var QueryClient = class {
2194
3486
  if (defaultedOptions.queryFn === skipToken) defaultedOptions.enabled = false;
2195
3487
  return defaultedOptions;
2196
3488
  }
3489
+ /**
3490
+ * The mutation counterpart of {@link QueryClient#defaultQueryOptions}. Called by framework
3491
+ * adapters (e.g. inside `useMutation`) to merge `queryClient.setMutationDefaults` for the
3492
+ * given `mutationKey`, then the client's `defaultOptions.mutations`, then the caller's options
3493
+ * on top. A no-op if the options are already defaulted (`_defaulted: true`).
3494
+ */
2197
3495
  defaultMutationOptions(options) {
2198
3496
  if (options?._defaulted) return options;
2199
3497
  return {
@@ -2203,10 +3501,21 @@ var QueryClient = class {
2203
3501
  _defaulted: true
2204
3502
  };
2205
3503
  }
3504
+ /**
3505
+ * Clears both the query cache and the mutation cache this client is connected to.
3506
+ *
3507
+ * @example
3508
+ * ```ts
3509
+ * import { QueryClient } from '@tanstack/query-core'
3510
+ *
3511
+ * const queryClient = new QueryClient()
3512
+ * queryClient.clear()
3513
+ * ```
3514
+ */
2206
3515
  clear() {
2207
3516
  this.#queryCache.clear();
2208
3517
  this.#mutationCache.clear();
2209
3518
  }
2210
3519
  };
2211
3520
  //#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 };
3521
+ export { dehydrateQuery as a, shouldThrowError as c, notifyManager as i, MutationObserver as n, hydrate as o, QueryObserver as r, noop as s, QueryClient as t };