@tanstack/query-core 5.102.7 → 5.103.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (301) hide show
  1. package/build/legacy/environmentManager.cjs +15 -1
  2. package/build/legacy/environmentManager.cjs.map +1 -1
  3. package/build/legacy/environmentManager.d.cts +15 -1
  4. package/build/legacy/environmentManager.d.cts.map +1 -1
  5. package/build/legacy/environmentManager.d.ts +15 -1
  6. package/build/legacy/environmentManager.d.ts.map +1 -1
  7. package/build/legacy/environmentManager.js +15 -1
  8. package/build/legacy/environmentManager.js.map +1 -1
  9. package/build/legacy/focusManager.cjs +57 -0
  10. package/build/legacy/focusManager.cjs.map +1 -1
  11. package/build/legacy/focusManager.d.cts +57 -0
  12. package/build/legacy/focusManager.d.cts.map +1 -1
  13. package/build/legacy/focusManager.d.ts +57 -0
  14. package/build/legacy/focusManager.d.ts.map +1 -1
  15. package/build/legacy/focusManager.js +57 -0
  16. package/build/legacy/focusManager.js.map +1 -1
  17. package/build/legacy/{hydration-Bjs0MSgg.d.ts → hydration-Cq7QYAzB.d.ts} +1424 -7
  18. package/build/legacy/hydration-Cq7QYAzB.d.ts.map +1 -0
  19. package/build/legacy/{hydration-DWGr3cFC.d.cts → hydration-DwR10Hi-.d.cts} +1424 -7
  20. package/build/legacy/hydration-DwR10Hi-.d.cts.map +1 -0
  21. package/build/legacy/hydration.cjs +57 -4
  22. package/build/legacy/hydration.cjs.map +1 -1
  23. package/build/legacy/hydration.d.cts +1 -1
  24. package/build/legacy/hydration.d.ts +1 -1
  25. package/build/legacy/hydration.js +57 -4
  26. package/build/legacy/hydration.js.map +1 -1
  27. package/build/legacy/index.cjs.map +1 -1
  28. package/build/legacy/index.d.cts +5 -5
  29. package/build/legacy/index.d.ts +5 -5
  30. package/build/legacy/index.js.map +1 -1
  31. package/build/legacy/infiniteQueryBehavior.d.cts +1 -1
  32. package/build/legacy/infiniteQueryBehavior.d.ts +1 -1
  33. package/build/legacy/infiniteQueryObserver.cjs +67 -0
  34. package/build/legacy/infiniteQueryObserver.cjs.map +1 -1
  35. package/build/legacy/infiniteQueryObserver.d.cts +68 -1
  36. package/build/legacy/infiniteQueryObserver.d.cts.map +1 -1
  37. package/build/legacy/infiniteQueryObserver.d.ts +68 -1
  38. package/build/legacy/infiniteQueryObserver.d.ts.map +1 -1
  39. package/build/legacy/infiniteQueryObserver.js +67 -0
  40. package/build/legacy/infiniteQueryObserver.js.map +1 -1
  41. package/build/legacy/mutation.cjs +74 -0
  42. package/build/legacy/mutation.cjs.map +1 -1
  43. package/build/legacy/mutation.d.cts +1 -1
  44. package/build/legacy/mutation.d.ts +1 -1
  45. package/build/legacy/mutation.js +74 -0
  46. package/build/legacy/mutation.js.map +1 -1
  47. package/build/legacy/mutationCache.cjs +74 -0
  48. package/build/legacy/mutationCache.cjs.map +1 -1
  49. package/build/legacy/mutationCache.d.cts +1 -1
  50. package/build/legacy/mutationCache.d.ts +1 -1
  51. package/build/legacy/mutationCache.js +74 -0
  52. package/build/legacy/mutationCache.js.map +1 -1
  53. package/build/legacy/mutationObserver.cjs +71 -0
  54. package/build/legacy/mutationObserver.cjs.map +1 -1
  55. package/build/legacy/mutationObserver.d.cts +1 -1
  56. package/build/legacy/mutationObserver.d.ts +1 -1
  57. package/build/legacy/mutationObserver.js +71 -0
  58. package/build/legacy/mutationObserver.js.map +1 -1
  59. package/build/legacy/notifyManager.cjs +45 -1
  60. package/build/legacy/notifyManager.cjs.map +1 -1
  61. package/build/legacy/notifyManager.d.cts +83 -2
  62. package/build/legacy/notifyManager.d.cts.map +1 -1
  63. package/build/legacy/notifyManager.d.ts +83 -2
  64. package/build/legacy/notifyManager.d.ts.map +1 -1
  65. package/build/legacy/notifyManager.js +45 -1
  66. package/build/legacy/notifyManager.js.map +1 -1
  67. package/build/legacy/onlineManager.cjs +47 -0
  68. package/build/legacy/onlineManager.cjs.map +1 -1
  69. package/build/legacy/onlineManager.d.cts +47 -0
  70. package/build/legacy/onlineManager.d.cts.map +1 -1
  71. package/build/legacy/onlineManager.d.ts +47 -0
  72. package/build/legacy/onlineManager.d.ts.map +1 -1
  73. package/build/legacy/onlineManager.js +47 -0
  74. package/build/legacy/onlineManager.js.map +1 -1
  75. package/build/legacy/queriesObserver.cjs +64 -0
  76. package/build/legacy/queriesObserver.cjs.map +1 -1
  77. package/build/legacy/queriesObserver.d.cts +73 -1
  78. package/build/legacy/queriesObserver.d.cts.map +1 -1
  79. package/build/legacy/queriesObserver.d.ts +73 -1
  80. package/build/legacy/queriesObserver.d.ts.map +1 -1
  81. package/build/legacy/queriesObserver.js +64 -0
  82. package/build/legacy/queriesObserver.js.map +1 -1
  83. package/build/legacy/query.cjs +141 -0
  84. package/build/legacy/query.cjs.map +1 -1
  85. package/build/legacy/query.d.cts +1 -1
  86. package/build/legacy/query.d.ts +1 -1
  87. package/build/legacy/query.js +141 -0
  88. package/build/legacy/query.js.map +1 -1
  89. package/build/legacy/queryCache.cjs +120 -0
  90. package/build/legacy/queryCache.cjs.map +1 -1
  91. package/build/legacy/queryCache.d.cts +1 -1
  92. package/build/legacy/queryCache.d.ts +1 -1
  93. package/build/legacy/queryCache.js +120 -0
  94. package/build/legacy/queryCache.js.map +1 -1
  95. package/build/legacy/queryClient.cjs +363 -0
  96. package/build/legacy/queryClient.cjs.map +1 -1
  97. package/build/legacy/queryClient.d.cts +1 -1
  98. package/build/legacy/queryClient.d.ts +1 -1
  99. package/build/legacy/queryClient.js +363 -0
  100. package/build/legacy/queryClient.js.map +1 -1
  101. package/build/legacy/queryObserver.cjs +116 -2
  102. package/build/legacy/queryObserver.cjs.map +1 -1
  103. package/build/legacy/queryObserver.d.cts +1 -1
  104. package/build/legacy/queryObserver.d.ts +1 -1
  105. package/build/legacy/queryObserver.js +116 -2
  106. package/build/legacy/queryObserver.js.map +1 -1
  107. package/build/legacy/retryer.cjs +18 -0
  108. package/build/legacy/retryer.cjs.map +1 -1
  109. package/build/legacy/retryer.d.cts +1 -1
  110. package/build/legacy/retryer.d.ts +1 -1
  111. package/build/legacy/retryer.js +18 -0
  112. package/build/legacy/retryer.js.map +1 -1
  113. package/build/legacy/streamedQuery.cjs +10 -1
  114. package/build/legacy/streamedQuery.cjs.map +1 -1
  115. package/build/legacy/streamedQuery.d.cts +26 -2
  116. package/build/legacy/streamedQuery.d.cts.map +1 -1
  117. package/build/legacy/streamedQuery.d.ts +26 -2
  118. package/build/legacy/streamedQuery.d.ts.map +1 -1
  119. package/build/legacy/streamedQuery.js +10 -1
  120. package/build/legacy/streamedQuery.js.map +1 -1
  121. package/build/legacy/timeoutManager.cjs +99 -0
  122. package/build/legacy/timeoutManager.cjs.map +1 -1
  123. package/build/legacy/timeoutManager.d.cts +105 -0
  124. package/build/legacy/timeoutManager.d.cts.map +1 -1
  125. package/build/legacy/timeoutManager.d.ts +105 -0
  126. package/build/legacy/timeoutManager.d.ts.map +1 -1
  127. package/build/legacy/timeoutManager.js +99 -0
  128. package/build/legacy/timeoutManager.js.map +1 -1
  129. package/build/legacy/types.cjs.map +1 -1
  130. package/build/legacy/types.d.cts +1 -1
  131. package/build/legacy/types.d.ts +1 -1
  132. package/build/legacy/types.js.map +1 -1
  133. package/build/legacy/utils.cjs +76 -0
  134. package/build/legacy/utils.cjs.map +1 -1
  135. package/build/legacy/utils.d.cts +1 -1
  136. package/build/legacy/utils.d.ts +1 -1
  137. package/build/legacy/utils.js +76 -0
  138. package/build/legacy/utils.js.map +1 -1
  139. package/build/modern/environmentManager.cjs +15 -1
  140. package/build/modern/environmentManager.cjs.map +1 -1
  141. package/build/modern/environmentManager.d.cts +15 -1
  142. package/build/modern/environmentManager.d.cts.map +1 -1
  143. package/build/modern/environmentManager.d.ts +15 -1
  144. package/build/modern/environmentManager.d.ts.map +1 -1
  145. package/build/modern/environmentManager.js +15 -1
  146. package/build/modern/environmentManager.js.map +1 -1
  147. package/build/modern/focusManager.cjs +57 -0
  148. package/build/modern/focusManager.cjs.map +1 -1
  149. package/build/modern/focusManager.d.cts +57 -0
  150. package/build/modern/focusManager.d.cts.map +1 -1
  151. package/build/modern/focusManager.d.ts +57 -0
  152. package/build/modern/focusManager.d.ts.map +1 -1
  153. package/build/modern/focusManager.js +57 -0
  154. package/build/modern/focusManager.js.map +1 -1
  155. package/build/modern/{hydration-Bjs0MSgg.d.ts → hydration-Cq7QYAzB.d.ts} +1424 -7
  156. package/build/modern/hydration-Cq7QYAzB.d.ts.map +1 -0
  157. package/build/modern/{hydration-DWGr3cFC.d.cts → hydration-DwR10Hi-.d.cts} +1424 -7
  158. package/build/modern/hydration-DwR10Hi-.d.cts.map +1 -0
  159. package/build/modern/hydration.cjs +57 -4
  160. package/build/modern/hydration.cjs.map +1 -1
  161. package/build/modern/hydration.d.cts +1 -1
  162. package/build/modern/hydration.d.ts +1 -1
  163. package/build/modern/hydration.js +57 -4
  164. package/build/modern/hydration.js.map +1 -1
  165. package/build/modern/index.cjs.map +1 -1
  166. package/build/modern/index.d.cts +5 -5
  167. package/build/modern/index.d.ts +5 -5
  168. package/build/modern/index.js.map +1 -1
  169. package/build/modern/infiniteQueryBehavior.d.cts +1 -1
  170. package/build/modern/infiniteQueryBehavior.d.ts +1 -1
  171. package/build/modern/infiniteQueryObserver.cjs +67 -0
  172. package/build/modern/infiniteQueryObserver.cjs.map +1 -1
  173. package/build/modern/infiniteQueryObserver.d.cts +68 -1
  174. package/build/modern/infiniteQueryObserver.d.cts.map +1 -1
  175. package/build/modern/infiniteQueryObserver.d.ts +68 -1
  176. package/build/modern/infiniteQueryObserver.d.ts.map +1 -1
  177. package/build/modern/infiniteQueryObserver.js +67 -0
  178. package/build/modern/infiniteQueryObserver.js.map +1 -1
  179. package/build/modern/mutation.cjs +74 -0
  180. package/build/modern/mutation.cjs.map +1 -1
  181. package/build/modern/mutation.d.cts +1 -1
  182. package/build/modern/mutation.d.ts +1 -1
  183. package/build/modern/mutation.js +74 -0
  184. package/build/modern/mutation.js.map +1 -1
  185. package/build/modern/mutationCache.cjs +74 -0
  186. package/build/modern/mutationCache.cjs.map +1 -1
  187. package/build/modern/mutationCache.d.cts +1 -1
  188. package/build/modern/mutationCache.d.ts +1 -1
  189. package/build/modern/mutationCache.js +74 -0
  190. package/build/modern/mutationCache.js.map +1 -1
  191. package/build/modern/mutationObserver.cjs +71 -0
  192. package/build/modern/mutationObserver.cjs.map +1 -1
  193. package/build/modern/mutationObserver.d.cts +1 -1
  194. package/build/modern/mutationObserver.d.ts +1 -1
  195. package/build/modern/mutationObserver.js +71 -0
  196. package/build/modern/mutationObserver.js.map +1 -1
  197. package/build/modern/notifyManager.cjs +45 -1
  198. package/build/modern/notifyManager.cjs.map +1 -1
  199. package/build/modern/notifyManager.d.cts +83 -2
  200. package/build/modern/notifyManager.d.cts.map +1 -1
  201. package/build/modern/notifyManager.d.ts +83 -2
  202. package/build/modern/notifyManager.d.ts.map +1 -1
  203. package/build/modern/notifyManager.js +45 -1
  204. package/build/modern/notifyManager.js.map +1 -1
  205. package/build/modern/onlineManager.cjs +47 -0
  206. package/build/modern/onlineManager.cjs.map +1 -1
  207. package/build/modern/onlineManager.d.cts +47 -0
  208. package/build/modern/onlineManager.d.cts.map +1 -1
  209. package/build/modern/onlineManager.d.ts +47 -0
  210. package/build/modern/onlineManager.d.ts.map +1 -1
  211. package/build/modern/onlineManager.js +47 -0
  212. package/build/modern/onlineManager.js.map +1 -1
  213. package/build/modern/queriesObserver.cjs +64 -0
  214. package/build/modern/queriesObserver.cjs.map +1 -1
  215. package/build/modern/queriesObserver.d.cts +73 -1
  216. package/build/modern/queriesObserver.d.cts.map +1 -1
  217. package/build/modern/queriesObserver.d.ts +73 -1
  218. package/build/modern/queriesObserver.d.ts.map +1 -1
  219. package/build/modern/queriesObserver.js +64 -0
  220. package/build/modern/queriesObserver.js.map +1 -1
  221. package/build/modern/query.cjs +141 -0
  222. package/build/modern/query.cjs.map +1 -1
  223. package/build/modern/query.d.cts +1 -1
  224. package/build/modern/query.d.ts +1 -1
  225. package/build/modern/query.js +141 -0
  226. package/build/modern/query.js.map +1 -1
  227. package/build/modern/queryCache.cjs +120 -0
  228. package/build/modern/queryCache.cjs.map +1 -1
  229. package/build/modern/queryCache.d.cts +1 -1
  230. package/build/modern/queryCache.d.ts +1 -1
  231. package/build/modern/queryCache.js +120 -0
  232. package/build/modern/queryCache.js.map +1 -1
  233. package/build/modern/queryClient.cjs +363 -0
  234. package/build/modern/queryClient.cjs.map +1 -1
  235. package/build/modern/queryClient.d.cts +1 -1
  236. package/build/modern/queryClient.d.ts +1 -1
  237. package/build/modern/queryClient.js +363 -0
  238. package/build/modern/queryClient.js.map +1 -1
  239. package/build/modern/queryObserver.cjs +116 -2
  240. package/build/modern/queryObserver.cjs.map +1 -1
  241. package/build/modern/queryObserver.d.cts +1 -1
  242. package/build/modern/queryObserver.d.ts +1 -1
  243. package/build/modern/queryObserver.js +116 -2
  244. package/build/modern/queryObserver.js.map +1 -1
  245. package/build/modern/retryer.cjs +18 -0
  246. package/build/modern/retryer.cjs.map +1 -1
  247. package/build/modern/retryer.d.cts +1 -1
  248. package/build/modern/retryer.d.ts +1 -1
  249. package/build/modern/retryer.js +18 -0
  250. package/build/modern/retryer.js.map +1 -1
  251. package/build/modern/streamedQuery.cjs +10 -1
  252. package/build/modern/streamedQuery.cjs.map +1 -1
  253. package/build/modern/streamedQuery.d.cts +26 -2
  254. package/build/modern/streamedQuery.d.cts.map +1 -1
  255. package/build/modern/streamedQuery.d.ts +26 -2
  256. package/build/modern/streamedQuery.d.ts.map +1 -1
  257. package/build/modern/streamedQuery.js +10 -1
  258. package/build/modern/streamedQuery.js.map +1 -1
  259. package/build/modern/timeoutManager.cjs +99 -0
  260. package/build/modern/timeoutManager.cjs.map +1 -1
  261. package/build/modern/timeoutManager.d.cts +105 -0
  262. package/build/modern/timeoutManager.d.cts.map +1 -1
  263. package/build/modern/timeoutManager.d.ts +105 -0
  264. package/build/modern/timeoutManager.d.ts.map +1 -1
  265. package/build/modern/timeoutManager.js +99 -0
  266. package/build/modern/timeoutManager.js.map +1 -1
  267. package/build/modern/types.cjs.map +1 -1
  268. package/build/modern/types.d.cts +1 -1
  269. package/build/modern/types.d.ts +1 -1
  270. package/build/modern/types.js.map +1 -1
  271. package/build/modern/utils.cjs +76 -0
  272. package/build/modern/utils.cjs.map +1 -1
  273. package/build/modern/utils.d.cts +1 -1
  274. package/build/modern/utils.d.ts +1 -1
  275. package/build/modern/utils.js +76 -0
  276. package/build/modern/utils.js.map +1 -1
  277. package/package.json +9 -9
  278. package/src/environmentManager.ts +15 -1
  279. package/src/focusManager.ts +57 -0
  280. package/src/hydration.ts +82 -16
  281. package/src/index.ts +3 -0
  282. package/src/infiniteQueryObserver.ts +67 -0
  283. package/src/mutation.ts +108 -0
  284. package/src/mutationCache.ts +91 -0
  285. package/src/mutationObserver.ts +71 -0
  286. package/src/notifyManager.ts +46 -1
  287. package/src/onlineManager.ts +47 -0
  288. package/src/queriesObserver.ts +72 -0
  289. package/src/query.ts +193 -0
  290. package/src/queryCache.ts +134 -0
  291. package/src/queryClient.ts +369 -0
  292. package/src/queryObserver.ts +117 -4
  293. package/src/retryer.ts +18 -0
  294. package/src/streamedQuery.ts +25 -1
  295. package/src/timeoutManager.ts +105 -0
  296. package/src/types.ts +147 -5
  297. package/src/utils.ts +107 -0
  298. package/build/legacy/hydration-Bjs0MSgg.d.ts.map +0 -1
  299. package/build/legacy/hydration-DWGr3cFC.d.cts.map +0 -1
  300. package/build/modern/hydration-Bjs0MSgg.d.ts.map +0 -1
  301. package/build/modern/hydration-DWGr3cFC.d.cts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"queryClient.js","names":["#queryCache","#mutationCache","#defaultOptions","#queryDefaults","#mutationDefaults","#mountCount","#unsubscribeFocus","#unsubscribeOnline"],"sources":["../../src/queryClient.ts"],"sourcesContent":["import {\n functionalUpdate,\n hashKey,\n hashQueryKeyByOptions,\n noop,\n partialMatchKey,\n resolveQueryValue,\n skipToken,\n} from './utils'\nimport { QueryCache } from './queryCache'\nimport { MutationCache } from './mutationCache'\nimport { focusManager } from './focusManager'\nimport { onlineManager } from './onlineManager'\nimport { notifyManager } from './notifyManager'\nimport type {\n CancelOptions,\n DefaultError,\n DefaultOptions,\n DefaultedQueryObserverOptions,\n EnsureInfiniteQueryDataOptions,\n EnsureQueryDataOptions,\n FetchInfiniteQueryOptions,\n FetchQueryOptions,\n InferDataFromTag,\n InferErrorFromTag,\n InfiniteData,\n InfiniteQueryExecuteOptions,\n InvalidateOptions,\n InvalidateQueryFilters,\n MutationKey,\n MutationObserverOptions,\n MutationOptions,\n OmitKeyof,\n QueryClientConfig,\n QueryExecuteOptions,\n QueryKey,\n QueryObserverOptions,\n QueryOptions,\n RefetchOptions,\n RefetchQueryFilters,\n ResetOptions,\n SetDataOptions,\n} from './types'\nimport type { QueryState } from './query'\nimport type { MutationFilters, QueryFilters, Updater } from './utils'\n\n// TYPES\n\ninterface QueryDefaults {\n queryKey: QueryKey\n defaultOptions: OmitKeyof<QueryOptions<any, any, any>, 'queryKey'>\n}\n\ninterface MutationDefaults {\n mutationKey: MutationKey\n defaultOptions: MutationOptions<any, any, any, any>\n}\n\n// CLASS\n\nexport class QueryClient {\n #queryCache: QueryCache\n #mutationCache: MutationCache\n #defaultOptions: DefaultOptions\n #queryDefaults: Map<string, QueryDefaults>\n #mutationDefaults: Map<string, MutationDefaults>\n #mountCount: number\n #unsubscribeFocus?: () => void\n #unsubscribeOnline?: () => void\n\n constructor(config: QueryClientConfig = {}) {\n this.#queryCache = config.queryCache || new QueryCache()\n this.#mutationCache = config.mutationCache || new MutationCache()\n this.#defaultOptions = config.defaultOptions || {}\n this.#queryDefaults = new Map()\n this.#mutationDefaults = new Map()\n this.#mountCount = 0\n }\n\n mount(): void {\n this.#mountCount++\n if (this.#mountCount !== 1) return\n\n this.#unsubscribeFocus = focusManager.subscribe(async (focused) => {\n if (focused) {\n await this.resumePausedMutations()\n this.#queryCache.onFocus()\n }\n })\n this.#unsubscribeOnline = onlineManager.subscribe(async (online) => {\n if (online) {\n await this.resumePausedMutations()\n this.#queryCache.onOnline()\n }\n })\n }\n\n unmount(): void {\n this.#mountCount--\n if (this.#mountCount !== 0) return\n\n this.#unsubscribeFocus?.()\n this.#unsubscribeFocus = undefined\n\n this.#unsubscribeOnline?.()\n this.#unsubscribeOnline = undefined\n }\n\n isFetching<TQueryFilters extends QueryFilters<any> = QueryFilters>(\n filters?: TQueryFilters,\n ): number {\n return this.#queryCache.findAll({ ...filters, fetchStatus: 'fetching' })\n .length\n }\n\n isMutating<\n TMutationFilters extends MutationFilters<any, any> = MutationFilters,\n >(filters?: TMutationFilters): number {\n return this.#mutationCache.findAll({ ...filters, status: 'pending' }).length\n }\n\n /**\n * Imperative (non-reactive) way to retrieve data for a QueryKey.\n * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.\n *\n * Hint: Do not use this function inside a component, because it won't receive updates.\n * Use `useQuery` to create a `QueryObserver` that subscribes to changes.\n */\n getQueryData<\n TQueryFnData = unknown,\n TTaggedQueryKey extends QueryKey = QueryKey,\n TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,\n >(queryKey: TTaggedQueryKey): TInferredQueryFnData | undefined {\n const options = this.defaultQueryOptions({ queryKey })\n\n return this.#queryCache.get<TInferredQueryFnData>(options.queryHash)?.state\n .data\n }\n\n /**\n * @deprecated Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version.\n */\n ensureQueryData<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n >(\n options: EnsureQueryDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n ): Promise<TData> {\n const defaultedOptions = this.defaultQueryOptions(options)\n const query = this.#queryCache.build(this, defaultedOptions)\n const cachedData = query.state.data\n\n if (cachedData === undefined) {\n return this.fetchQuery(options)\n }\n\n if (\n options.revalidateIfStale &&\n query.isStaleByTime(resolveQueryValue(defaultedOptions.staleTime, query))\n ) {\n void this.prefetchQuery(defaultedOptions)\n }\n\n return Promise.resolve(cachedData)\n }\n\n getQueriesData<\n TQueryFnData = unknown,\n TQueryFilters extends QueryFilters<any> = QueryFilters,\n >(filters: TQueryFilters): Array<[QueryKey, TQueryFnData | undefined]> {\n return this.#queryCache.findAll(filters).map(({ queryKey, state }) => {\n const data = state.data as TQueryFnData | undefined\n return [queryKey, data]\n })\n }\n\n setQueryData<\n TQueryFnData = unknown,\n TTaggedQueryKey extends QueryKey = QueryKey,\n TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,\n >(\n queryKey: TTaggedQueryKey,\n updater: Updater<\n NoInfer<TInferredQueryFnData> | undefined,\n NoInfer<TInferredQueryFnData> | undefined\n >,\n options?: SetDataOptions,\n ): NoInfer<TInferredQueryFnData> | undefined {\n const defaultedOptions = this.defaultQueryOptions<\n any,\n any,\n unknown,\n any,\n QueryKey\n >({ queryKey })\n\n const query = this.#queryCache.get<TInferredQueryFnData>(\n defaultedOptions.queryHash,\n )\n const prevData = query?.state.data\n const data = functionalUpdate(updater, prevData)\n\n if (data === undefined) {\n return undefined\n }\n\n return this.#queryCache\n .build(this, defaultedOptions)\n .setData(data, { ...options, manual: true })\n }\n\n setQueriesData<\n TQueryFnData,\n TQueryFilters extends QueryFilters<any> = QueryFilters,\n >(\n filters: TQueryFilters,\n updater: Updater<\n NoInfer<TQueryFnData> | undefined,\n NoInfer<TQueryFnData> | undefined\n >,\n options?: SetDataOptions,\n ): Array<[QueryKey, TQueryFnData | undefined]> {\n return notifyManager.batch(() =>\n this.#queryCache\n .findAll(filters)\n .map(({ queryKey }) => [\n queryKey,\n this.setQueryData<TQueryFnData>(queryKey, updater, options),\n ]),\n )\n }\n\n getQueryState<\n TQueryFnData = unknown,\n TError = DefaultError,\n TTaggedQueryKey extends QueryKey = QueryKey,\n TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,\n TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,\n >(\n queryKey: TTaggedQueryKey,\n ): QueryState<TInferredQueryFnData, TInferredError> | undefined {\n const options = this.defaultQueryOptions({ queryKey })\n return this.#queryCache.get<TInferredQueryFnData, TInferredError>(\n options.queryHash,\n )?.state\n }\n\n removeQueries<TTaggedQueryKey extends QueryKey = QueryKey>(\n filters?: QueryFilters<TTaggedQueryKey>,\n ): void {\n const queryCache = this.#queryCache\n notifyManager.batch(() => {\n queryCache.findAll(filters).forEach((query) => {\n queryCache.remove(query)\n })\n })\n }\n\n resetQueries<TTaggedQueryKey extends QueryKey = QueryKey>(\n filters?: QueryFilters<TTaggedQueryKey>,\n options?: ResetOptions,\n ): Promise<void> {\n const queryCache = this.#queryCache\n\n return notifyManager.batch(() => {\n const matched = queryCache.findAll(filters)\n const queriesToRefetch = new Set(matched)\n matched.forEach((query) => {\n query.reset()\n })\n return this.refetchQueries(\n {\n type: 'active',\n predicate: (query) => queriesToRefetch.has(query),\n },\n options,\n )\n })\n }\n\n cancelQueries<TTaggedQueryKey extends QueryKey = QueryKey>(\n filters?: QueryFilters<TTaggedQueryKey>,\n cancelOptions: CancelOptions = {},\n ): Promise<void> {\n const defaultedCancelOptions = { revert: true, ...cancelOptions }\n\n const promises = notifyManager.batch(() =>\n this.#queryCache\n .findAll(filters)\n .map((query) => query.cancel(defaultedCancelOptions)),\n )\n\n return Promise.all(promises).then(noop).catch(noop)\n }\n\n invalidateQueries<TTaggedQueryKey extends QueryKey = QueryKey>(\n filters?: InvalidateQueryFilters<TTaggedQueryKey>,\n options: InvalidateOptions = {},\n ): Promise<void> {\n return notifyManager.batch(() => {\n this.#queryCache.findAll(filters).forEach((query) => {\n query.invalidate()\n })\n\n if (filters?.refetchType === 'none') {\n return Promise.resolve()\n }\n return this.refetchQueries(\n {\n ...filters,\n type: filters?.refetchType ?? filters?.type ?? 'active',\n },\n options,\n )\n })\n }\n\n refetchQueries<TTaggedQueryKey extends QueryKey = QueryKey>(\n filters?: RefetchQueryFilters<TTaggedQueryKey>,\n options: RefetchOptions = {},\n ): Promise<void> {\n const fetchOptions = {\n ...options,\n cancelRefetch: options.cancelRefetch ?? true,\n }\n const promises = notifyManager.batch(() =>\n this.#queryCache\n .findAll(filters)\n .filter((query) => !query.isDisabled() && !query.isStatic())\n .map((query) => {\n let promise = query.fetch(undefined, fetchOptions)\n if (!fetchOptions.throwOnError) {\n promise = promise.catch(noop)\n }\n return query.state.fetchStatus === 'paused'\n ? Promise.resolve()\n : promise\n }),\n )\n\n return Promise.all(promises).then(noop)\n }\n\n async query<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n >(\n options: QueryExecuteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n TPageParam\n >,\n ): Promise<TData> {\n const defaultedOptions = this.defaultQueryOptions(options)\n\n // https://github.com/tannerlinsley/react-query/issues/652\n if (defaultedOptions.retry === undefined) {\n defaultedOptions.retry = false\n }\n\n const query = this.#queryCache.build(this, defaultedOptions)\n\n const isStale = query.isStaleByTime(\n resolveQueryValue(defaultedOptions.staleTime, query),\n )\n\n const queryData = isStale\n ? await query.fetch(defaultedOptions)\n : (query.state.data as TQueryData)\n\n const select = defaultedOptions.select\n\n if (select) {\n return select(queryData)\n }\n\n return queryData as unknown as TData\n }\n\n /**\n * @deprecated Use queryClient.query(options) instead. This method will be removed in the next major version.\n */\n fetchQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n >(\n options: FetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n ): Promise<TData> {\n const defaultedOptions = this.defaultQueryOptions(options)\n\n // https://github.com/tannerlinsley/react-query/issues/652\n if (defaultedOptions.retry === undefined) {\n defaultedOptions.retry = false\n }\n\n const query = this.#queryCache.build(this, defaultedOptions)\n\n return query.isStaleByTime(\n resolveQueryValue(defaultedOptions.staleTime, query),\n )\n ? query.fetch(defaultedOptions)\n : Promise.resolve(query.state.data as TData)\n }\n\n /**\n * @deprecated Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version.\n */\n prefetchQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n >(\n options: FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n ): Promise<void> {\n return this.fetchQuery(options).then(noop).catch(noop)\n }\n\n infiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n >(\n options: InfiniteQueryExecuteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n ): Promise<\n Array<TData> extends Array<InfiniteData<TQueryFnData>>\n ? InfiniteData<TQueryFnData, TPageParam>\n : TData\n > {\n options._type = 'infinite'\n return this.query(options as any)\n }\n\n /**\n * @deprecated Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version.\n */\n fetchInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n >(\n options: FetchInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n ): Promise<InfiniteData<TData, TPageParam>> {\n options._type = 'infinite'\n return this.fetchQuery(options as any)\n }\n\n /**\n * @deprecated Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version.\n */\n prefetchInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n >(\n options: FetchInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n ): Promise<void> {\n return this.fetchInfiniteQuery(options).then(noop).catch(noop)\n }\n\n /**\n * @deprecated Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version.\n */\n ensureInfiniteQueryData<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n >(\n options: EnsureInfiniteQueryDataOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n ): Promise<InfiniteData<TData, TPageParam>> {\n options._type = 'infinite'\n\n return this.ensureQueryData(options as any)\n }\n\n resumePausedMutations(): Promise<unknown> {\n if (onlineManager.isOnline()) {\n return this.#mutationCache.resumePausedMutations()\n }\n return Promise.resolve()\n }\n\n getQueryCache(): QueryCache {\n return this.#queryCache\n }\n\n getMutationCache(): MutationCache {\n return this.#mutationCache\n }\n\n getDefaultOptions(): DefaultOptions {\n return this.#defaultOptions\n }\n\n setDefaultOptions(options: DefaultOptions): void {\n this.#defaultOptions = options\n }\n\n setQueryDefaults<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n >(\n queryKey: QueryKey,\n options: Partial<\n OmitKeyof<\n QueryObserverOptions<TQueryFnData, TError, TData, TQueryData>,\n 'queryKey'\n >\n >,\n ): void {\n this.#queryDefaults.set(hashKey(queryKey), {\n queryKey,\n defaultOptions: options,\n })\n }\n\n getQueryDefaults(\n queryKey: QueryKey,\n ): OmitKeyof<QueryObserverOptions<any, any, any, any, any>, 'queryKey'> {\n const defaults = [...this.#queryDefaults.values()]\n\n const result: OmitKeyof<\n QueryObserverOptions<any, any, any, any, any>,\n 'queryKey'\n > = {}\n\n defaults.forEach((queryDefault) => {\n if (partialMatchKey(queryKey, queryDefault.queryKey)) {\n Object.assign(result, queryDefault.defaultOptions)\n }\n })\n return result\n }\n\n setMutationDefaults<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n >(\n mutationKey: MutationKey,\n options: OmitKeyof<\n MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n >,\n ): void {\n this.#mutationDefaults.set(hashKey(mutationKey), {\n mutationKey,\n defaultOptions: options,\n })\n }\n\n getMutationDefaults(\n mutationKey: MutationKey,\n ): OmitKeyof<MutationObserverOptions<any, any, any, any>, 'mutationKey'> {\n const defaults = [...this.#mutationDefaults.values()]\n\n const result: OmitKeyof<\n MutationObserverOptions<any, any, any, any>,\n 'mutationKey'\n > = {}\n\n defaults.forEach((queryDefault) => {\n if (partialMatchKey(mutationKey, queryDefault.mutationKey)) {\n Object.assign(result, queryDefault.defaultOptions)\n }\n })\n\n return result\n }\n\n defaultQueryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n >(\n options:\n | QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n TPageParam\n >\n | DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n > {\n if (options._defaulted) {\n return options as DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >\n }\n\n const defaultedOptions = {\n ...this.#defaultOptions.queries,\n ...this.getQueryDefaults(options.queryKey),\n ...options,\n _defaulted: true,\n }\n\n if (!defaultedOptions.queryHash) {\n defaultedOptions.queryHash = hashQueryKeyByOptions(\n defaultedOptions.queryKey,\n defaultedOptions,\n )\n }\n\n // dependent default values\n if (defaultedOptions.refetchOnReconnect === undefined) {\n defaultedOptions.refetchOnReconnect =\n defaultedOptions.networkMode !== 'always'\n }\n if (defaultedOptions.throwOnError === undefined) {\n defaultedOptions.throwOnError = !!defaultedOptions.suspense\n }\n\n if (!defaultedOptions.networkMode && defaultedOptions.persister) {\n defaultedOptions.networkMode = 'offlineFirst'\n }\n\n if (defaultedOptions.queryFn === skipToken) {\n defaultedOptions.enabled = false\n }\n\n return defaultedOptions as DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >\n }\n\n defaultMutationOptions<T extends MutationOptions<any, any, any, any>>(\n options?: T,\n ): T {\n if (options?._defaulted) {\n return options\n }\n return {\n ...this.#defaultOptions.mutations,\n ...(options?.mutationKey &&\n this.getMutationDefaults(options.mutationKey)),\n ...options,\n _defaulted: true,\n } as T\n }\n\n clear(): void {\n this.#queryCache.clear()\n this.#mutationCache.clear()\n }\n}\n"],"mappings":";;;;;;;AA4DA,IAAa,cAAb,MAAyB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,SAA4B,CAAC,GAAG;EAC1C,KAAKA,cAAc,OAAO,cAAc,IAAI,WAAW;EACvD,KAAKC,iBAAiB,OAAO,iBAAiB,IAAI,cAAc;EAChE,KAAKC,kBAAkB,OAAO,kBAAkB,CAAC;EACjD,KAAKC,iCAAiB,IAAI,IAAI;EAC9B,KAAKC,oCAAoB,IAAI,IAAI;EACjC,KAAKC,cAAc;CACrB;CAEA,QAAc;EACZ,KAAKA;EACL,IAAI,KAAKA,gBAAgB,GAAG;EAE5B,KAAKC,oBAAoB,aAAa,UAAU,OAAO,YAAY;GACjE,IAAI,SAAS;IACX,MAAM,KAAK,sBAAsB;IACjC,KAAKN,YAAY,QAAQ;GAC3B;EACF,CAAC;EACD,KAAKO,qBAAqB,cAAc,UAAU,OAAO,WAAW;GAClE,IAAI,QAAQ;IACV,MAAM,KAAK,sBAAsB;IACjC,KAAKP,YAAY,SAAS;GAC5B;EACF,CAAC;CACH;CAEA,UAAgB;EACd,KAAKK;EACL,IAAI,KAAKA,gBAAgB,GAAG;EAE5B,KAAKC,oBAAoB;EACzB,KAAKA,oBAAoB,KAAA;EAEzB,KAAKC,qBAAqB;EAC1B,KAAKA,qBAAqB,KAAA;CAC5B;CAEA,WACE,SACQ;EACR,OAAO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AAC;EAEpD,MAAM,SAGF,CAAC;EAEL,SAAS,SAAS,iBAAiB;GACjC,IAAI,gBAAgB,aAAa,aAAa,WAAW,GACvD,OAAO,OAAO,QAAQ,aAAa,cAAc;EAErD,CAAC;EAED,OAAO;CACT;CAEA,oBAQE,SAsBA;EACA,IAAI,QAAQ,YACV,OAAO;EAST,MAAM,mBAAmB;GACvB,GAAG,KAAKF,gBAAgB;GACxB,GAAG,KAAK,iBAAiB,QAAQ,QAAQ;GACzC,GAAG;GACH,YAAY;EACd;EAEA,IAAI,CAAC,iBAAiB,WACpB,iBAAiB,YAAY,sBAC3B,iBAAiB,UACjB,gBACF;EAIF,IAAI,iBAAiB,uBAAuB,KAAA,GAC1C,iBAAiB,qBACf,iBAAiB,gBAAgB;EAErC,IAAI,iBAAiB,iBAAiB,KAAA,GACpC,iBAAiB,eAAe,CAAC,CAAC,iBAAiB;EAGrD,IAAI,CAAC,iBAAiB,eAAe,iBAAiB,WACpD,iBAAiB,cAAc;EAGjC,IAAI,iBAAiB,YAAY,WAC/B,iBAAiB,UAAU;EAG7B,OAAO;CAOT;CAEA,uBACE,SACG;EACH,IAAI,SAAS,YACX,OAAO;EAET,OAAO;GACL,GAAG,KAAKA,gBAAgB;GACxB,GAAI,SAAS,eACX,KAAK,oBAAoB,QAAQ,WAAW;GAC9C,GAAG;GACH,YAAY;EACd;CACF;CAEA,QAAc;EACZ,KAAKF,YAAY,MAAM;EACvB,KAAKC,eAAe,MAAM;CAC5B;AACF"}
1
+ {"version":3,"file":"queryClient.js","names":["#queryCache","#mutationCache","#defaultOptions","#queryDefaults","#mutationDefaults","#mountCount","#unsubscribeFocus","#unsubscribeOnline"],"sources":["../../src/queryClient.ts"],"sourcesContent":["import {\n functionalUpdate,\n hashKey,\n hashQueryKeyByOptions,\n noop,\n partialMatchKey,\n resolveQueryValue,\n skipToken,\n} from './utils'\nimport { QueryCache } from './queryCache'\nimport { MutationCache } from './mutationCache'\nimport { focusManager } from './focusManager'\nimport { onlineManager } from './onlineManager'\nimport { notifyManager } from './notifyManager'\nimport type {\n CancelOptions,\n DefaultError,\n DefaultOptions,\n DefaultedQueryObserverOptions,\n EnsureInfiniteQueryDataOptions,\n EnsureQueryDataOptions,\n FetchInfiniteQueryOptions,\n FetchQueryOptions,\n InferDataFromTag,\n InferErrorFromTag,\n InfiniteData,\n InfiniteQueryExecuteOptions,\n InvalidateOptions,\n InvalidateQueryFilters,\n MutationKey,\n MutationObserverOptions,\n MutationOptions,\n OmitKeyof,\n QueryClientConfig,\n QueryExecuteOptions,\n QueryKey,\n QueryObserverOptions,\n QueryOptions,\n RefetchOptions,\n RefetchQueryFilters,\n ResetOptions,\n SetDataOptions,\n} from './types'\nimport type { QueryState } from './query'\nimport type { MutationFilters, QueryFilters, Updater } from './utils'\n\n// TYPES\n\ninterface QueryDefaults {\n queryKey: QueryKey\n defaultOptions: OmitKeyof<QueryOptions<any, any, any>, 'queryKey'>\n}\n\ninterface MutationDefaults {\n mutationKey: MutationKey\n defaultOptions: MutationOptions<any, any, any, any>\n}\n\n// CLASS\n\n/**\n * `QueryClient` is used to interact with a cache of queries and mutations. It owns a\n * `QueryCache` and a `MutationCache` (creating default ones if none are passed in) and holds\n * the default options that are applied to queries and mutations created through it.\n *\n * @example\n * ```ts\n * const queryClient = new QueryClient({\n * defaultOptions: {\n * queries: {\n * staleTime: Infinity,\n * },\n * },\n * })\n *\n * await queryClient.query({ queryKey: ['posts'], queryFn: fetchPosts })\n * ```\n */\nexport class QueryClient {\n #queryCache: QueryCache\n #mutationCache: MutationCache\n #defaultOptions: DefaultOptions\n #queryDefaults: Map<string, QueryDefaults>\n #mutationDefaults: Map<string, MutationDefaults>\n #mountCount: number\n #unsubscribeFocus?: () => void\n #unsubscribeOnline?: () => void\n\n constructor(config: QueryClientConfig = {}) {\n this.#queryCache = config.queryCache || new QueryCache()\n this.#mutationCache = config.mutationCache || new MutationCache()\n this.#defaultOptions = config.defaultOptions || {}\n this.#queryDefaults = new Map()\n this.#mutationDefaults = new Map()\n this.#mountCount = 0\n }\n\n /**\n * Called by a framework adapter's `QueryClientProvider`-equivalent when it mounts, to start\n * listening for focus/online events and resume paused mutations. Ref-counted via an internal\n * mount count, so nested or multiple providers sharing the same `QueryClient` don't tear down\n * the shared listeners until the last one unmounts.\n */\n mount(): void {\n this.#mountCount++\n if (this.#mountCount !== 1) return\n\n this.#unsubscribeFocus = focusManager.subscribe(async (focused) => {\n if (focused) {\n await this.resumePausedMutations()\n this.#queryCache.onFocus()\n }\n })\n this.#unsubscribeOnline = onlineManager.subscribe(async (online) => {\n if (online) {\n await this.resumePausedMutations()\n this.#queryCache.onOnline()\n }\n })\n }\n\n /**\n * The inverse of {@link QueryClient#mount} — called by a framework adapter's\n * `QueryClientProvider`-equivalent when it unmounts. Only tears down the focus/online\n * listeners once the mount count returns to `0`.\n */\n unmount(): void {\n this.#mountCount--\n if (this.#mountCount !== 0) return\n\n this.#unsubscribeFocus?.()\n this.#unsubscribeFocus = undefined\n\n this.#unsubscribeOnline?.()\n this.#unsubscribeOnline = undefined\n }\n\n /**\n * Returns the number of queries in the cache that are currently fetching, optionally\n * matching a set of filters. This includes background-fetching, loading new pages, and\n * loading more infinite query results.\n *\n * @example\n * ```ts\n * if (queryClient.isFetching()) {\n * console.log('At least one query is fetching!')\n * }\n * ```\n */\n isFetching<TQueryFilters extends QueryFilters<any> = QueryFilters>(\n filters?: TQueryFilters,\n ): number {\n return this.#queryCache.findAll({ ...filters, fetchStatus: 'fetching' })\n .length\n }\n\n /**\n * Returns the number of mutations in the cache that are currently pending, optionally\n * matching a set of filters.\n *\n * @example\n * ```ts\n * if (queryClient.isMutating()) {\n * console.log('At least one mutation is pending!')\n * }\n * ```\n */\n isMutating<\n TMutationFilters extends MutationFilters<any, any> = MutationFilters,\n >(filters?: TMutationFilters): number {\n return this.#mutationCache.findAll({ ...filters, status: 'pending' }).length\n }\n\n /**\n * Imperative (non-reactive) way to retrieve data for a QueryKey.\n * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.\n *\n * Hint: Do not use this function inside a component, because it won't receive updates.\n * Use `useQuery` to create a `QueryObserver` that subscribes to changes.\n *\n * @see {@link QueryClient#getQueriesData}\n */\n getQueryData<\n TQueryFnData = unknown,\n TTaggedQueryKey extends QueryKey = QueryKey,\n TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,\n >(queryKey: TTaggedQueryKey): TInferredQueryFnData | undefined {\n const options = this.defaultQueryOptions({ queryKey })\n\n return this.#queryCache.get<TInferredQueryFnData>(options.queryHash)?.state\n .data\n }\n\n /**\n * @deprecated Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version.\n */\n ensureQueryData<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n >(\n options: EnsureQueryDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n ): Promise<TData> {\n const defaultedOptions = this.defaultQueryOptions(options)\n const query = this.#queryCache.build(this, defaultedOptions)\n const cachedData = query.state.data\n\n if (cachedData === undefined) {\n // eslint-disable-next-line no-restricted-syntax\n return this.fetchQuery(options)\n }\n\n if (\n options.revalidateIfStale &&\n query.isStaleByTime(resolveQueryValue(defaultedOptions.staleTime, query))\n ) {\n // eslint-disable-next-line no-restricted-syntax\n void this.prefetchQuery(defaultedOptions)\n }\n\n return Promise.resolve(cachedData)\n }\n\n /**\n * Imperative (non-reactive) way to retrieve the cached data of multiple queries at once.\n * Only queries matching the given filters are returned; if none match, an empty array is\n * returned.\n *\n * Because the matched queries can hold data of different shapes (e.g. a broad filter can match\n * queries with unrelated data types), the `TQueryFnData` generic defaults to `unknown` rather\n * than being inferred. Passing a more specific type is a convenience for call sites that know\n * every matched query holds the same shape — it is not checked against the actual cache\n * contents.\n *\n * @see {@link QueryClient#getQueryData}\n * @example\n * ```ts\n * const data = queryClient.getQueriesData({ queryKey: ['posts'] })\n * ```\n */\n getQueriesData<\n TQueryFnData = unknown,\n TQueryFilters extends QueryFilters<any> = QueryFilters,\n >(filters: TQueryFilters): Array<[QueryKey, TQueryFnData | undefined]> {\n return this.#queryCache.findAll(filters).map(({ queryKey, state }) => {\n const data = state.data as TQueryFnData | undefined\n return [queryKey, data]\n })\n }\n\n /**\n * Synchronous way to immediately update a query's cached data. If the updater (or the value\n * passed) resolves to `undefined`, the cache is left untouched and no query is created;\n * otherwise, if the query does not exist yet, it will be created. To update multiple queries\n * at once by partially matching query keys, use {@link QueryClient#setQueriesData} instead.\n *\n * Updates must be performed immutably: do not mutate `oldData`, or data previously retrieved\n * via {@link QueryClient#getQueryData}, in place.\n *\n * @param queryKey - The query key to set data for.\n * @param updater - Either the new data, or a function that receives the current data (which\n * may be `undefined`) and returns the new data.\n *\n * @example\n * ```ts\n * queryClient.setQueryData(['posts'], newPosts)\n *\n * // Or, using an updater function that receives the current data:\n * queryClient.setQueryData(['posts'], (oldPosts) => [...oldPosts, newPost])\n * ```\n */\n setQueryData<\n TQueryFnData = unknown,\n TTaggedQueryKey extends QueryKey = QueryKey,\n TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,\n >(\n queryKey: TTaggedQueryKey,\n updater: Updater<\n NoInfer<TInferredQueryFnData> | undefined,\n NoInfer<TInferredQueryFnData> | undefined\n >,\n options?: SetDataOptions,\n ): NoInfer<TInferredQueryFnData> | undefined {\n const defaultedOptions = this.defaultQueryOptions<\n any,\n any,\n unknown,\n any,\n QueryKey\n >({ queryKey })\n\n const query = this.#queryCache.get<TInferredQueryFnData>(\n defaultedOptions.queryHash,\n )\n const prevData = query?.state.data\n const data = functionalUpdate(updater, prevData)\n\n if (data === undefined) {\n return undefined\n }\n\n return this.#queryCache\n .build(this, defaultedOptions)\n .setData(data, { ...options, manual: true })\n }\n\n /**\n * Synchronous way to immediately update the cached data of multiple queries at once, using\n * filters or partial query key matching. Only queries that already exist and match the given\n * filters are updated; no new cache entries are created. Internally this calls\n * {@link QueryClient#setQueryData} for each matching query.\n *\n * @example\n * ```ts\n * queryClient.setQueriesData({ queryKey: ['posts'] }, (oldPosts) =>\n * oldPosts ? oldPosts.filter((post) => post.id !== deletedId) : oldPosts,\n * )\n * ```\n */\n setQueriesData<\n TQueryFnData,\n TQueryFilters extends QueryFilters<any> = QueryFilters,\n >(\n filters: TQueryFilters,\n updater: Updater<\n NoInfer<TQueryFnData> | undefined,\n NoInfer<TQueryFnData> | undefined\n >,\n options?: SetDataOptions,\n ): Array<[QueryKey, TQueryFnData | undefined]> {\n return notifyManager.batch(() =>\n this.#queryCache\n .findAll(filters)\n .map(({ queryKey }) => [\n queryKey,\n this.setQueryData<TQueryFnData>(queryKey, updater, options),\n ]),\n )\n }\n\n /**\n * Imperative (non-reactive) way to retrieve an existing query's state. If the query does not\n * exist, `undefined` is returned.\n *\n * @example\n * ```ts\n * const state = queryClient.getQueryState(['posts'])\n * console.log(state?.dataUpdatedAt)\n * ```\n */\n getQueryState<\n TQueryFnData = unknown,\n TError = DefaultError,\n TTaggedQueryKey extends QueryKey = QueryKey,\n TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,\n TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,\n >(\n queryKey: TTaggedQueryKey,\n ): QueryState<TInferredQueryFnData, TInferredError> | undefined {\n const options = this.defaultQueryOptions({ queryKey })\n return this.#queryCache.get<TInferredQueryFnData, TInferredError>(\n options.queryHash,\n )?.state\n }\n\n /**\n * Removes queries from the cache that match the given filters. Unlike\n * {@link QueryClient#invalidateQueries} or {@link QueryClient#refetchQueries}, this removes\n * matching queries from the cache instead of refetching them. Without filters, every query in\n * the cache is removed.\n *\n * @example\n * ```ts\n * queryClient.removeQueries({ queryKey: ['posts'], exact: true })\n * ```\n */\n removeQueries<TTaggedQueryKey extends QueryKey = QueryKey>(\n filters?: QueryFilters<TTaggedQueryKey>,\n ): void {\n const queryCache = this.#queryCache\n notifyManager.batch(() => {\n queryCache.findAll(filters).forEach((query) => {\n queryCache.remove(query)\n })\n })\n }\n\n /**\n * Resets queries matching the given filters back to their initial state (e.g. any\n * `initialData`), notifying subscribers rather than removing them. Active queries among the\n * matched set are then refetched, and the returned promise resolves once that refetch settles.\n *\n * @example\n * ```ts\n * await queryClient.resetQueries({ queryKey: ['posts'], exact: true })\n * ```\n */\n resetQueries<TTaggedQueryKey extends QueryKey = QueryKey>(\n filters?: QueryFilters<TTaggedQueryKey>,\n options?: ResetOptions,\n ): Promise<void> {\n const queryCache = this.#queryCache\n\n return notifyManager.batch(() => {\n const matched = queryCache.findAll(filters)\n const queriesToRefetch = new Set(matched)\n matched.forEach((query) => {\n query.reset()\n })\n return this.refetchQueries(\n {\n type: 'active',\n predicate: (query) => queriesToRefetch.has(query),\n },\n options,\n )\n })\n }\n\n /**\n * Cancels outgoing fetches for queries matching the given filters. Most useful when performing\n * optimistic updates, since any outgoing refetch that resolves afterwards would otherwise\n * overwrite the optimistic update. By default (`revert: true`), a cancelled query's data is\n * reverted to its state before the outgoing fetch started.\n *\n * The returned promise never rejects, even if individual cancellations fail.\n *\n * @example\n * ```ts\n * await queryClient.cancelQueries({ queryKey: ['posts'], exact: true })\n * ```\n */\n cancelQueries<TTaggedQueryKey extends QueryKey = QueryKey>(\n filters?: QueryFilters<TTaggedQueryKey>,\n cancelOptions: CancelOptions = {},\n ): Promise<void> {\n const defaultedCancelOptions = { revert: true, ...cancelOptions }\n\n const promises = notifyManager.batch(() =>\n this.#queryCache\n .findAll(filters)\n .map((query) => query.cancel(defaultedCancelOptions)),\n )\n\n return Promise.all(promises).then(noop).catch(noop)\n }\n\n /**\n * Marks queries matching the given filters as invalidated. Unlike\n * {@link QueryClient#removeQueries}, invalidated queries stay in the cache.\n *\n * Unless `filters.refetchType` is `'none'`, matching queries are then refetched via\n * {@link QueryClient#refetchQueries}, using `filters.refetchType` if set, otherwise\n * `filters.type`, otherwise `'active'`.\n *\n * @example\n * ```ts\n * await queryClient.invalidateQueries({ queryKey: ['posts'], refetchType: 'active' })\n * ```\n */\n invalidateQueries<TTaggedQueryKey extends QueryKey = QueryKey>(\n filters?: InvalidateQueryFilters<TTaggedQueryKey>,\n options: InvalidateOptions = {},\n ): Promise<void> {\n return notifyManager.batch(() => {\n this.#queryCache.findAll(filters).forEach((query) => {\n query.invalidate()\n })\n\n if (filters?.refetchType === 'none') {\n return Promise.resolve()\n }\n return this.refetchQueries(\n {\n ...filters,\n type: filters?.refetchType ?? filters?.type ?? 'active',\n },\n options,\n )\n })\n }\n\n /**\n * Refetches queries matching the given filters, regardless of whether they are stale. Without\n * filters, every query in the cache is refetched. Queries that are disabled, or static (only\n * have observers with a static `staleTime`), are never refetched.\n *\n * By default (`cancelRefetch: true`), a currently running fetch is cancelled before the new\n * one starts. The returned promise resolves once all matching queries have settled; it does\n * not reject on individual query failures unless `throwOnError` is set.\n *\n * @example\n * ```ts\n * // refetch all active queries partially matching a query key:\n * await queryClient.refetchQueries({ queryKey: ['posts'], type: 'active' })\n * ```\n */\n refetchQueries<TTaggedQueryKey extends QueryKey = QueryKey>(\n filters?: RefetchQueryFilters<TTaggedQueryKey>,\n options: RefetchOptions = {},\n ): Promise<void> {\n const fetchOptions = {\n ...options,\n cancelRefetch: options.cancelRefetch ?? true,\n }\n const promises = notifyManager.batch(() =>\n this.#queryCache\n .findAll(filters)\n .filter((query) => !query.isDisabled() && !query.isStatic())\n .map((query) => {\n let promise = query.fetch(undefined, fetchOptions)\n if (!fetchOptions.throwOnError) {\n promise = promise.catch(noop)\n }\n return query.state.fetchStatus === 'paused'\n ? Promise.resolve()\n : promise\n }),\n )\n\n return Promise.all(promises).then(noop)\n }\n\n /**\n * Asynchronous method to fetch and cache a query, resolving with the data or throwing with\n * the error.\n *\n * If the query already exists in the cache and its data is not stale (per the given\n * `staleTime`), the cached data is returned without fetching. Otherwise, the query is fetched\n * and the promise resolves once the fetch settles. If a `select` function is provided, it is\n * applied to the data in both cases (cached or freshly fetched) before it is returned.\n *\n * Unlike a reactive observer, retries are disabled by default here (`retry: false`) unless\n * explicitly configured, since there is no component to catch a thrown error and retry through\n * re-render.\n *\n * The accepted options are `QueryObserverOptions` minus the fields that only make sense for a\n * reactive observer — `enabled`, `refetchInterval`, `refetchIntervalInBackground`,\n * `refetchOnWindowFocus`, `refetchOnReconnect`, `refetchOnMount`, `retryOnMount`,\n * `notifyOnChangeProps`, `throwOnError`, `suspense`, and `placeholderData` are not part of this\n * method's options.\n *\n * This method replaces the deprecated `fetchQuery`, and — combined with\n * `{ staleTime: 'static' }` — the deprecated `ensureQueryData`.\n *\n * @example\n * ```ts\n * try {\n * const data = await queryClient.query({ queryKey, queryFn, staleTime: 10000 })\n * } catch (error) {\n * console.log(error)\n * }\n * ```\n */\n async query<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n >(\n options: QueryExecuteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n TPageParam\n >,\n ): Promise<TData> {\n const defaultedOptions = this.defaultQueryOptions(options)\n\n // https://github.com/tannerlinsley/react-query/issues/652\n if (defaultedOptions.retry === undefined) {\n defaultedOptions.retry = false\n }\n\n const query = this.#queryCache.build(this, defaultedOptions)\n\n const isStale = query.isStaleByTime(\n resolveQueryValue(defaultedOptions.staleTime, query),\n )\n\n const queryData = isStale\n ? await query.fetch(defaultedOptions)\n : (query.state.data as TQueryData)\n\n const select = defaultedOptions.select\n\n if (select) {\n return select(queryData)\n }\n\n return queryData as unknown as TData\n }\n\n /**\n * @deprecated Use queryClient.query(options) instead. This method will be removed in the next major version.\n */\n fetchQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n >(\n options: FetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n ): Promise<TData> {\n const defaultedOptions = this.defaultQueryOptions(options)\n\n // https://github.com/tannerlinsley/react-query/issues/652\n if (defaultedOptions.retry === undefined) {\n defaultedOptions.retry = false\n }\n\n const query = this.#queryCache.build(this, defaultedOptions)\n\n return query.isStaleByTime(\n resolveQueryValue(defaultedOptions.staleTime, query),\n )\n ? query.fetch(defaultedOptions)\n : Promise.resolve(query.state.data as TData)\n }\n\n /**\n * @deprecated Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version.\n */\n prefetchQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n >(\n options: FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n ): Promise<void> {\n // eslint-disable-next-line no-restricted-syntax\n return this.fetchQuery(options).then(noop).catch(noop)\n }\n\n /**\n * Asynchronous method to fetch and cache an infinite query, resolving with an\n * {@link InfiniteData} object or throwing with the error.\n *\n * Behaves like {@link QueryClient#query}, accepting the same options (minus\n * `initialPageParam`), plus the required `initialPageParam`, and an optional `pages` /\n * `getNextPageParam` pair used to refetch a fixed number of pages from the start.\n *\n * This method replaces the deprecated `fetchInfiniteQuery`, and — combined with\n * `{ staleTime: 'static' }` — the deprecated `ensureInfiniteQueryData`.\n *\n * @example\n * ```ts\n * try {\n * const data = await queryClient.infiniteQuery({ queryKey, queryFn, initialPageParam: 0 })\n * console.log(data.pages)\n * } catch (error) {\n * console.log(error)\n * }\n * ```\n */\n infiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n >(\n options: InfiniteQueryExecuteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n ): Promise<\n Array<TData> extends Array<InfiniteData<TQueryFnData>>\n ? InfiniteData<TQueryFnData, TPageParam>\n : TData\n > {\n options._type = 'infinite'\n return this.query(options as any)\n }\n\n /**\n * @deprecated Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version.\n */\n fetchInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n >(\n options: FetchInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n ): Promise<InfiniteData<TData, TPageParam>> {\n options._type = 'infinite'\n // eslint-disable-next-line no-restricted-syntax\n return this.fetchQuery(options as any)\n }\n\n /**\n * @deprecated Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version.\n */\n prefetchInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n >(\n options: FetchInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n ): Promise<void> {\n // eslint-disable-next-line no-restricted-syntax\n return this.fetchInfiniteQuery(options).then(noop).catch(noop)\n }\n\n /**\n * @deprecated Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version.\n */\n ensureInfiniteQueryData<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n >(\n options: EnsureInfiniteQueryDataOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n ): Promise<InfiniteData<TData, TPageParam>> {\n options._type = 'infinite'\n\n // eslint-disable-next-line no-restricted-syntax\n return this.ensureQueryData(options as any)\n }\n\n /**\n * Resumes mutations that were paused because there was no network connection. Does nothing\n * (resolving immediately) if the client is currently offline.\n *\n * @example\n * ```ts\n * import { QueryClient } from '@tanstack/query-core'\n *\n * const queryClient = new QueryClient()\n * await queryClient.resumePausedMutations()\n * ```\n */\n resumePausedMutations(): Promise<unknown> {\n if (onlineManager.isOnline()) {\n return this.#mutationCache.resumePausedMutations()\n }\n return Promise.resolve()\n }\n\n /**\n * Returns the query cache this client is connected to.\n *\n * @example\n * ```ts\n * import { QueryClient } from '@tanstack/query-core'\n *\n * const queryClient = new QueryClient()\n * const queryCache = queryClient.getQueryCache()\n * const queries = queryCache.findAll({ queryKey: ['posts'] })\n * ```\n */\n getQueryCache(): QueryCache {\n return this.#queryCache\n }\n\n /**\n * Returns the mutation cache this client is connected to.\n *\n * @example\n * ```ts\n * import { QueryClient } from '@tanstack/query-core'\n *\n * const queryClient = new QueryClient()\n * const mutationCache = queryClient.getMutationCache()\n * const mutations = mutationCache.findAll({ status: 'pending' })\n * ```\n */\n getMutationCache(): MutationCache {\n return this.#mutationCache\n }\n\n /**\n * Returns the default options that were set when creating the client, or via\n * {@link QueryClient#setDefaultOptions}.\n *\n * @example\n * ```ts\n * import { QueryClient } from '@tanstack/query-core'\n *\n * const queryClient = new QueryClient()\n * const defaultOptions = queryClient.getDefaultOptions()\n * ```\n */\n getDefaultOptions(): DefaultOptions {\n return this.#defaultOptions\n }\n\n /**\n * Dynamically sets the default options for this client, overwriting any previously defined\n * default options.\n *\n * @see {@link QueryClient#getDefaultOptions}\n * @example\n * ```ts\n * import { QueryClient } from '@tanstack/query-core'\n *\n * const queryClient = new QueryClient()\n * queryClient.setDefaultOptions({\n * queries: {\n * staleTime: Infinity,\n * },\n * })\n * ```\n */\n setDefaultOptions(options: DefaultOptions): void {\n this.#defaultOptions = options\n }\n\n /**\n * Sets default options for queries whose query key partially matches the given `queryKey`.\n *\n * If several registered query defaults match a given query key, they are merged together in\n * registration order by {@link QueryClient#getQueryDefaults}, so register defaults from the\n * most generic key to the least generic one — more specific defaults should be registered\n * after more generic ones so they take precedence.\n *\n * @example\n * ```ts\n * queryClient.setQueryDefaults(['posts'], { queryFn: fetchPosts })\n *\n * await queryClient.query({ queryKey: ['posts'] })\n * ```\n */\n setQueryDefaults<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n >(\n queryKey: QueryKey,\n options: Partial<\n OmitKeyof<\n QueryObserverOptions<TQueryFnData, TError, TData, TQueryData>,\n 'queryKey'\n >\n >,\n ): void {\n this.#queryDefaults.set(hashKey(queryKey), {\n queryKey,\n defaultOptions: options,\n })\n }\n\n /**\n * Returns the default options registered for queries whose query key partially matches the\n * given `queryKey`, via {@link QueryClient#setQueryDefaults}. If multiple registered defaults\n * match, they are merged together in registration order.\n *\n * @example\n * ```ts\n * const defaultOptions = queryClient.getQueryDefaults(['posts'])\n * ```\n */\n getQueryDefaults(\n queryKey: QueryKey,\n ): OmitKeyof<QueryObserverOptions<any, any, any, any, any>, 'queryKey'> {\n const defaults = [...this.#queryDefaults.values()]\n\n const result: OmitKeyof<\n QueryObserverOptions<any, any, any, any, any>,\n 'queryKey'\n > = {}\n\n defaults.forEach((queryDefault) => {\n if (partialMatchKey(queryKey, queryDefault.queryKey)) {\n Object.assign(result, queryDefault.defaultOptions)\n }\n })\n return result\n }\n\n /**\n * Sets default options for mutations whose mutation key partially matches the given\n * `mutationKey`. As with {@link QueryClient#setQueryDefaults}, the order of registration\n * matters when several registered defaults match the same mutation key.\n *\n * @see {@link QueryClient#getMutationDefaults}\n * @example\n * ```ts\n * queryClient.setMutationDefaults(['addPost'], { mutationFn: addPost })\n * ```\n */\n setMutationDefaults<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n >(\n mutationKey: MutationKey,\n options: OmitKeyof<\n MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n >,\n ): void {\n this.#mutationDefaults.set(hashKey(mutationKey), {\n mutationKey,\n defaultOptions: options,\n })\n }\n\n /**\n * Returns the default options registered for mutations whose mutation key partially matches\n * the given `mutationKey`, via {@link QueryClient#setMutationDefaults}. If multiple registered\n * defaults match, they are merged together in registration order.\n *\n * @example\n * ```ts\n * const defaultOptions = queryClient.getMutationDefaults(['addPost'])\n * ```\n */\n getMutationDefaults(\n mutationKey: MutationKey,\n ): OmitKeyof<MutationObserverOptions<any, any, any, any>, 'mutationKey'> {\n const defaults = [...this.#mutationDefaults.values()]\n\n const result: OmitKeyof<\n MutationObserverOptions<any, any, any, any>,\n 'mutationKey'\n > = {}\n\n defaults.forEach((queryDefault) => {\n if (partialMatchKey(mutationKey, queryDefault.mutationKey)) {\n Object.assign(result, queryDefault.defaultOptions)\n }\n })\n\n return result\n }\n\n /**\n * Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the\n * caller into their final, defaulted form: merging `queryClient.setQueryDefaults` for the\n * given `queryKey`, then the client's own `defaultOptions.queries`, then the caller's options\n * on top. A no-op if the options are already defaulted (`_defaulted: true`).\n */\n defaultQueryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n >(\n options:\n | QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n TPageParam\n >\n | DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n > {\n if (options._defaulted) {\n return options as DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >\n }\n\n const defaultedOptions = {\n ...this.#defaultOptions.queries,\n ...this.getQueryDefaults(options.queryKey),\n ...options,\n _defaulted: true,\n }\n\n if (!defaultedOptions.queryHash) {\n defaultedOptions.queryHash = hashQueryKeyByOptions(\n defaultedOptions.queryKey,\n defaultedOptions,\n )\n }\n\n // dependent default values\n if (defaultedOptions.refetchOnReconnect === undefined) {\n defaultedOptions.refetchOnReconnect =\n defaultedOptions.networkMode !== 'always'\n }\n if (defaultedOptions.throwOnError === undefined) {\n defaultedOptions.throwOnError = !!defaultedOptions.suspense\n }\n\n if (!defaultedOptions.networkMode && defaultedOptions.persister) {\n defaultedOptions.networkMode = 'offlineFirst'\n }\n\n if (defaultedOptions.queryFn === skipToken) {\n defaultedOptions.enabled = false\n }\n\n return defaultedOptions as DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >\n }\n\n /**\n * The mutation counterpart of {@link QueryClient#defaultQueryOptions}. Called by framework\n * adapters (e.g. inside `useMutation`) to merge `queryClient.setMutationDefaults` for the\n * given `mutationKey`, then the client's `defaultOptions.mutations`, then the caller's options\n * on top. A no-op if the options are already defaulted (`_defaulted: true`).\n */\n defaultMutationOptions<T extends MutationOptions<any, any, any, any>>(\n options?: T,\n ): T {\n if (options?._defaulted) {\n return options\n }\n return {\n ...this.#defaultOptions.mutations,\n ...(options?.mutationKey &&\n this.getMutationDefaults(options.mutationKey)),\n ...options,\n _defaulted: true,\n } as T\n }\n\n /**\n * Clears both the query cache and the mutation cache this client is connected to.\n *\n * @example\n * ```ts\n * import { QueryClient } from '@tanstack/query-core'\n *\n * const queryClient = new QueryClient()\n * queryClient.clear()\n * ```\n */\n clear(): void {\n this.#queryCache.clear()\n this.#mutationCache.clear()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8EA,IAAa,cAAb,MAAyB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,SAA4B,CAAC,GAAG;EAC1C,KAAKA,cAAc,OAAO,cAAc,IAAI,WAAW;EACvD,KAAKC,iBAAiB,OAAO,iBAAiB,IAAI,cAAc;EAChE,KAAKC,kBAAkB,OAAO,kBAAkB,CAAC;EACjD,KAAKC,iCAAiB,IAAI,IAAI;EAC9B,KAAKC,oCAAoB,IAAI,IAAI;EACjC,KAAKC,cAAc;CACrB;;;;;;;CAQA,QAAc;EACZ,KAAKA;EACL,IAAI,KAAKA,gBAAgB,GAAG;EAE5B,KAAKC,oBAAoB,aAAa,UAAU,OAAO,YAAY;GACjE,IAAI,SAAS;IACX,MAAM,KAAK,sBAAsB;IACjC,KAAKN,YAAY,QAAQ;GAC3B;EACF,CAAC;EACD,KAAKO,qBAAqB,cAAc,UAAU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CAAC,CAAC,iBAAiB;EAGrD,IAAI,CAAC,iBAAiB,eAAe,iBAAiB,WACpD,iBAAiB,cAAc;EAGjC,IAAI,iBAAiB,YAAY,WAC/B,iBAAiB,UAAU;EAG7B,OAAO;CAOT;;;;;;;CAQA,uBACE,SACG;EACH,IAAI,SAAS,YACX,OAAO;EAET,OAAO;GACL,GAAG,KAAKA,gBAAgB;GACxB,GAAI,SAAS,eACX,KAAK,oBAAoB,QAAQ,WAAW;GAC9C,GAAG;GACH,YAAY;EACd;CACF;;;;;;;;;;;;CAaA,QAAc;EACZ,KAAKF,YAAY,MAAM;EACvB,KAAKC,eAAe,MAAM;CAC5B;AACF"}
@@ -7,6 +7,26 @@ const require_focusManager = require("./focusManager.cjs");
7
7
  const require_notifyManager = require("./notifyManager.cjs");
8
8
  const require_query = require("./query.cjs");
9
9
  //#region src/queryObserver.ts
10
+ /**
11
+ * A `QueryObserver` watches a single query in the `QueryCache` and computes a
12
+ * `QueryObserverResult` from its state, recomputing and notifying subscribers
13
+ * whenever the underlying query (or the observer's options) changes. It is
14
+ * the primitive that framework adapters (e.g. `useQuery`) build their hooks
15
+ * on top of, but it can also be used directly to observe and switch between
16
+ * queries outside of any framework.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const observer = new QueryObserver(queryClient, {
21
+ * queryKey: ['posts'],
22
+ * queryFn: fetchPosts,
23
+ * })
24
+ *
25
+ * const unsubscribe = observer.subscribe((result) => {
26
+ * console.log(result.data)
27
+ * })
28
+ * ```
29
+ */
10
30
  var QueryObserver = class extends require_subscribable.Subscribable {
11
31
  #client;
12
32
  #currentQuery = void 0;
@@ -44,18 +64,47 @@ var QueryObserver = class extends require_subscribable.Subscribable {
44
64
  onUnsubscribe() {
45
65
  if (!this.hasListeners()) this.destroy();
46
66
  }
67
+ /**
68
+ * Returns whether the observed query is currently stale and configured
69
+ * (via the `refetchOnReconnect` option) to refetch when the network
70
+ * reconnects.
71
+ */
47
72
  shouldFetchOnReconnect() {
48
73
  return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnReconnect);
49
74
  }
75
+ /**
76
+ * Returns whether the observed query is currently stale and configured
77
+ * (via the `refetchOnWindowFocus` option) to refetch when the window
78
+ * regains focus.
79
+ */
50
80
  shouldFetchOnWindowFocus() {
51
81
  return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnWindowFocus);
52
82
  }
83
+ /**
84
+ * Stops observing the current query: clears all listeners, cancels the
85
+ * stale and refetch-interval timers, and removes this observer from the
86
+ * query it was observing.
87
+ */
53
88
  destroy() {
54
89
  this.listeners = /* @__PURE__ */ new Set();
55
90
  this.#clearStaleTimeout();
56
91
  this.#clearRefetchInterval();
57
92
  this.#currentQuery.removeObserver(this);
58
93
  }
94
+ /**
95
+ * Updates the observer's options. This will re-resolve the query being
96
+ * observed (switching to a different query if the `queryKey` changed),
97
+ * trigger a fetch if the new options require one and the observer has
98
+ * subscribers, recompute the current result, and reschedule the stale and
99
+ * refetch-interval timers as needed.
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * observer.setOptions({ queryKey: ['posts', 1], queryFn: () => fetchPost(1) })
104
+ * // later: switch to a different query, reusing the same observer
105
+ * observer.setOptions({ queryKey: ['posts', 2], queryFn: () => fetchPost(2) })
106
+ * ```
107
+ */
59
108
  setOptions(options) {
60
109
  const prevOptions = this.options;
61
110
  const prevQuery = this.#currentQuery;
@@ -75,6 +124,12 @@ var QueryObserver = class extends require_subscribable.Subscribable {
75
124
  const nextRefetchInterval = this.#computeRefetchInterval();
76
125
  if (mounted && (this.#currentQuery !== prevQuery || require_utils.resolveQueryValue(this.options.enabled, this.#currentQuery) !== require_utils.resolveQueryValue(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) this.#updateRefetchInterval(nextRefetchInterval);
77
126
  }
127
+ /**
128
+ * Computes the result the observer would produce for the given (already-defaulted) options
129
+ * right now, building the underlying `Query` if it doesn't exist yet, without waiting for a
130
+ * subscription callback. Called by framework adapters on every render (e.g. `useQuery`) so the
131
+ * returned value is available synchronously, ahead of `setOptions` triggering an actual fetch.
132
+ */
78
133
  getOptimisticResult(options) {
79
134
  const query = this.#client.getQueryCache().build(this.#client, options);
80
135
  const result = this.createResult(query, options);
@@ -85,9 +140,27 @@ var QueryObserver = class extends require_subscribable.Subscribable {
85
140
  }
86
141
  return result;
87
142
  }
143
+ /**
144
+ * Returns the most recently computed `QueryObserverResult` for the
145
+ * observed query. This is a point-in-time read; to be notified of updates
146
+ * as they happen, subscribe to the observer instead (its inherited
147
+ * `subscribe` method).
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * const result = observer.getCurrentResult()
152
+ * console.log(result.status, result.data)
153
+ * ```
154
+ */
88
155
  getCurrentResult() {
89
156
  return this.#currentResult;
90
157
  }
158
+ /**
159
+ * Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via
160
+ * {@link QueryObserver#trackProp} (and an optional `onPropTracked` callback). Used by framework
161
+ * adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on
162
+ * properties you actually read" behavior.
163
+ */
91
164
  trackResult(result, onPropTracked) {
92
165
  return new Proxy(result, { get: (target, key) => {
93
166
  this.trackProp(key);
@@ -95,15 +168,50 @@ var QueryObserver = class extends require_subscribable.Subscribable {
95
168
  return Reflect.get(target, key);
96
169
  } });
97
170
  }
171
+ /**
172
+ * Records that the given `QueryObserverResult` property was read, so a subsequent update only
173
+ * notifies this observer if a tracked property actually changed. Normally called indirectly via
174
+ * {@link QueryObserver#trackResult}'s proxy; exposed directly for adapters that track property
175
+ * access themselves (e.g. through their own reactivity system) instead of via the proxy.
176
+ */
98
177
  trackProp(key) {
99
178
  this.#trackedProps.add(key);
100
179
  }
180
+ /**
181
+ * Returns the `Query` instance this observer is currently observing.
182
+ */
101
183
  getCurrentQuery() {
102
184
  return this.#currentQuery;
103
185
  }
186
+ /**
187
+ * Refetches the observed query and returns a promise that resolves with
188
+ * the resulting `QueryObserverResult`.
189
+ *
190
+ * @example
191
+ * ```ts
192
+ * const result = await observer.refetch({ cancelRefetch: false })
193
+ * console.log(result.data)
194
+ * ```
195
+ */
104
196
  refetch({ ...options } = {}) {
105
197
  return this.fetch({ ...options });
106
198
  }
199
+ /**
200
+ * Fetches a query defined by the given options without affecting this
201
+ * observer's own tracked query or result, and returns a promise that
202
+ * resolves with the `QueryObserverResult` for that fetch. This is useful
203
+ * for prefetching data that another observer (e.g. a query about to be
204
+ * navigated to) will need, ahead of time.
205
+ *
206
+ * @example
207
+ * ```ts
208
+ * const result = await observer.fetchOptimistic({
209
+ * queryKey: ['posts', 2],
210
+ * queryFn: () => fetchPost(2),
211
+ * })
212
+ * console.log(result.data)
213
+ * ```
214
+ */
107
215
  fetchOptimistic(options) {
108
216
  const defaultedOptions = this.#client.defaultQueryOptions(options);
109
217
  const query = this.#client.getQueryCache().build(this.#client, defaultedOptions);
@@ -154,7 +262,7 @@ var QueryObserver = class extends require_subscribable.Subscribable {
154
262
  }, timeout);
155
263
  }
156
264
  #computeRefetchInterval() {
157
- return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false;
265
+ return require_utils.resolveQueryValue(this.options.refetchInterval, this.#currentQuery) ?? false;
158
266
  }
159
267
  #updateRefetchInterval(nextInterval) {
160
268
  this.#clearRefetchInterval();
@@ -268,6 +376,11 @@ var QueryObserver = class extends require_subscribable.Subscribable {
268
376
  isEnabled: require_utils.resolveQueryValue(options.enabled, query) !== false
269
377
  };
270
378
  }
379
+ /**
380
+ * Recomputes and stores the current result from the current query/options, notifying listeners
381
+ * if it changed. Framework adapters call this right after subscribing to make sure no query
382
+ * update was missed in the gap between creating the observer and subscribing to it.
383
+ */
271
384
  updateResult() {
272
385
  const prevResult = this.#currentResult;
273
386
  const nextResult = this.createResult(this.#currentQuery, this.options);
@@ -310,6 +423,7 @@ var QueryObserver = class extends require_subscribable.Subscribable {
310
423
  query.addObserver(this);
311
424
  }
312
425
  }
426
+ /** @internal */
313
427
  onQueryUpdate() {
314
428
  this.updateResult();
315
429
  if (this.hasListeners()) this.#updateTimers();
@@ -323,7 +437,7 @@ function shouldFetchOnMount(query, options) {
323
437
  }
324
438
  function shouldFetchOn(query, options, field) {
325
439
  if (require_utils.resolveQueryValue(options.enabled, query) !== false && require_utils.resolveQueryValue(options.staleTime, query) !== "static") {
326
- const value = typeof field === "function" ? field(query) : field;
440
+ const value = require_utils.resolveQueryValue(field, query);
327
441
  return value === "always" || value !== false && isStale(query, options);
328
442
  }
329
443
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"queryObserver.cjs","names":["Subscribable","#client","#selectError","#currentQuery","#executeFetch","#updateTimers","#clearStaleTimeout","#clearRefetchInterval","resolveQueryValue","#updateQuery","shallowEqualObjects","#updateStaleTimeout","#computeRefetchInterval","#currentRefetchInterval","#updateRefetchInterval","#currentResult","#currentResultOptions","#currentResultState","#trackedProps","noop","isServerEnvironment","isValidTimeout","#shouldScheduleTimer","timeUntilStale","#staleTimeoutId","timeoutManager","#refetchIntervalId","focusManager","#currentQueryInitialState","fetchState","#lastQueryWithDefinedData","replaceData","#selectFn","#selectResult"],"sources":["../../src/queryObserver.ts"],"sourcesContent":["import { focusManager } from './focusManager'\nimport { isServer as isServerEnvironment } from './environmentManager'\nimport { notifyManager } from './notifyManager'\nimport { fetchState } from './query'\nimport { Subscribable } from './subscribable'\nimport {\n isValidTimeout,\n noop,\n replaceData,\n resolveQueryValue,\n shallowEqualObjects,\n timeUntilStale,\n} from './utils'\nimport { timeoutManager } from './timeoutManager'\nimport type { ManagedTimerId } from './timeoutManager'\nimport type { FetchOptions, Query, QueryState } from './query'\nimport type { QueryClient } from './queryClient'\nimport type {\n DefaultError,\n DefaultedQueryObserverOptions,\n PlaceholderDataFunction,\n QueryKey,\n QueryObserverBaseResult,\n QueryObserverOptions,\n QueryObserverResult,\n RefetchOptions,\n} from './types'\n\ntype QueryObserverListener<TData, TError> = (\n result: QueryObserverResult<TData, TError>,\n) => void\n\ninterface ObserverFetchOptions extends FetchOptions {\n throwOnError?: boolean\n}\n\nexport class QueryObserver<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> extends Subscribable<QueryObserverListener<TData, TError>> {\n #client: QueryClient\n #currentQuery: Query<TQueryFnData, TError, TQueryData, TQueryKey> = undefined!\n #currentQueryInitialState: QueryState<TQueryData, TError> = undefined!\n #currentResult: QueryObserverResult<TData, TError> = undefined!\n #currentResultState?: QueryState<TQueryData, TError>\n #currentResultOptions?: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >\n #selectError: TError | null\n #selectFn?: (data: TQueryData) => TData\n #selectResult?: TData\n // This property keeps track of the last query with defined data.\n // It will be used to pass the previous data and query to the placeholder function between renders.\n #lastQueryWithDefinedData?: Query<TQueryFnData, TError, TQueryData, TQueryKey>\n #staleTimeoutId?: ManagedTimerId\n #refetchIntervalId?: ManagedTimerId\n #currentRefetchInterval?: number | false\n #trackedProps = new Set<keyof QueryObserverResult>()\n\n constructor(\n client: QueryClient,\n public options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ) {\n super()\n\n this.#client = client\n this.#selectError = null\n\n this.bindMethods()\n this.setOptions(options)\n }\n\n protected bindMethods(): void {\n this.refetch = this.refetch.bind(this)\n }\n\n protected onSubscribe(): void {\n if (this.listeners.size === 1) {\n this.#currentQuery.addObserver(this)\n\n if (shouldFetchOnMount(this.#currentQuery, this.options)) {\n this.#executeFetch()\n } else {\n this.updateResult()\n }\n\n this.#updateTimers()\n }\n }\n\n protected onUnsubscribe(): void {\n if (!this.hasListeners()) {\n this.destroy()\n }\n }\n\n shouldFetchOnReconnect(): boolean {\n return shouldFetchOn(\n this.#currentQuery,\n this.options,\n this.options.refetchOnReconnect,\n )\n }\n\n shouldFetchOnWindowFocus(): boolean {\n return shouldFetchOn(\n this.#currentQuery,\n this.options,\n this.options.refetchOnWindowFocus,\n )\n }\n\n destroy(): void {\n this.listeners = new Set()\n this.#clearStaleTimeout()\n this.#clearRefetchInterval()\n this.#currentQuery.removeObserver(this)\n }\n\n setOptions(\n options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): void {\n const prevOptions = this.options\n const prevQuery = this.#currentQuery\n\n this.options = this.#client.defaultQueryOptions(options)\n\n if (\n this.options.enabled !== undefined &&\n typeof this.options.enabled !== 'boolean' &&\n typeof this.options.enabled !== 'function' &&\n typeof resolveQueryValue(this.options.enabled, this.#currentQuery) !==\n 'boolean'\n ) {\n throw new Error(\n 'Expected enabled to be a boolean or a callback that returns a boolean',\n )\n }\n\n this.#updateQuery()\n this.#currentQuery.setOptions(this.options)\n\n if (\n prevOptions._defaulted &&\n !shallowEqualObjects(this.options, prevOptions)\n ) {\n this.#client.getQueryCache().notify({\n type: 'observerOptionsUpdated',\n query: this.#currentQuery,\n observer: this,\n })\n }\n\n const mounted = this.hasListeners()\n\n // Fetch if there are subscribers\n if (\n mounted &&\n shouldFetchOptionally(\n this.#currentQuery,\n prevQuery,\n this.options,\n prevOptions,\n )\n ) {\n this.#executeFetch()\n }\n\n // Update result\n this.updateResult()\n\n // Update stale interval if needed\n if (\n mounted &&\n (this.#currentQuery !== prevQuery ||\n resolveQueryValue(this.options.enabled, this.#currentQuery) !==\n resolveQueryValue(prevOptions.enabled, this.#currentQuery) ||\n resolveQueryValue(this.options.staleTime, this.#currentQuery) !==\n resolveQueryValue(prevOptions.staleTime, this.#currentQuery))\n ) {\n this.#updateStaleTimeout()\n }\n\n const nextRefetchInterval = this.#computeRefetchInterval()\n\n // Update refetch interval if needed\n if (\n mounted &&\n (this.#currentQuery !== prevQuery ||\n resolveQueryValue(this.options.enabled, this.#currentQuery) !==\n resolveQueryValue(prevOptions.enabled, this.#currentQuery) ||\n nextRefetchInterval !== this.#currentRefetchInterval)\n ) {\n this.#updateRefetchInterval(nextRefetchInterval)\n }\n }\n\n getOptimisticResult(\n options: DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): QueryObserverResult<TData, TError> {\n const query = this.#client.getQueryCache().build(this.#client, options)\n\n const result = this.createResult(query, options)\n\n if (!shallowEqualObjects(this.getCurrentResult(), result)) {\n // this assigns the optimistic result to the current Observer\n // because if the query function changes, useQuery will be performing\n // an effect where it would fetch again.\n // When the fetch finishes, we perform a deep data cloning in order\n // to reuse objects references. This deep data clone is performed against\n // the `observer.currentResult.data` property\n // When QueryKey changes, we refresh the query and get new `optimistic`\n // result, while we leave the `observer.currentResult`, so when new data\n // arrives, it finds the old `observer.currentResult` which is related\n // to the old QueryKey. Which means that currentResult and selectData are\n // out of sync already.\n // To solve this, we move the cursor of the currentResult every time\n // an observer reads an optimistic value.\n\n // When keeping the previous data, the result doesn't change until new\n // data arrives.\n this.#currentResult = result\n this.#currentResultOptions = this.options\n this.#currentResultState = this.#currentQuery.state\n }\n return result\n }\n\n getCurrentResult(): QueryObserverResult<TData, TError> {\n return this.#currentResult\n }\n\n trackResult(\n result: QueryObserverResult<TData, TError>,\n onPropTracked?: (key: keyof QueryObserverResult) => void,\n ): QueryObserverResult<TData, TError> {\n return new Proxy(result, {\n get: (target, key) => {\n this.trackProp(key as keyof QueryObserverResult)\n onPropTracked?.(key as keyof QueryObserverResult)\n return Reflect.get(target, key)\n },\n })\n }\n\n trackProp(key: keyof QueryObserverResult) {\n this.#trackedProps.add(key)\n }\n\n getCurrentQuery(): Query<TQueryFnData, TError, TQueryData, TQueryKey> {\n return this.#currentQuery\n }\n\n refetch({ ...options }: RefetchOptions = {}): Promise<\n QueryObserverResult<TData, TError>\n > {\n return this.fetch({\n ...options,\n })\n }\n\n fetchOptimistic(\n options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): Promise<QueryObserverResult<TData, TError>> {\n const defaultedOptions = this.#client.defaultQueryOptions(options)\n\n const query = this.#client\n .getQueryCache()\n .build(this.#client, defaultedOptions)\n\n let unsubscribe = () => {}\n let resolveEarly:\n | ((result: QueryObserverResult<TData, TError>) => void)\n | undefined\n\n const cachePromise = new Promise<QueryObserverResult<TData, TError>>(\n (resolve) => {\n resolveEarly = resolve\n unsubscribe = this.#client.getQueryCache().subscribe((event) => {\n if (\n event.type === 'updated' &&\n event.query.queryHash === query.queryHash &&\n query.state.data !== undefined\n ) {\n unsubscribe()\n resolve(this.createResult(query, defaultedOptions))\n }\n })\n },\n )\n\n return Promise.race([\n query\n .fetch()\n .then(() => {\n const result = this.createResult(query, defaultedOptions)\n // Settle the subscriber promise so both branches always settle.\n // This value is ignored by Promise.race since the fetch branch already won.\n resolveEarly?.(result)\n return result\n })\n .finally(() => {\n unsubscribe()\n }),\n cachePromise,\n ])\n }\n\n protected fetch(\n fetchOptions: ObserverFetchOptions,\n ): Promise<QueryObserverResult<TData, TError>> {\n return this.#executeFetch({\n ...fetchOptions,\n cancelRefetch: fetchOptions.cancelRefetch ?? true,\n }).then(() => {\n this.updateResult()\n return this.#currentResult\n })\n }\n\n #executeFetch(\n fetchOptions?: Omit<ObserverFetchOptions, 'initialPromise'>,\n ): Promise<TQueryData | undefined> {\n // Make sure we reference the latest query as the current one might have been removed\n this.#updateQuery()\n\n // Fetch\n let promise: Promise<TQueryData | undefined> = this.#currentQuery.fetch(\n this.options,\n fetchOptions,\n )\n\n if (!fetchOptions?.throwOnError) {\n promise = promise.catch(noop)\n }\n\n return promise\n }\n\n #shouldScheduleTimer(timeout: unknown): timeout is number {\n return (\n !isServerEnvironment() &&\n resolveQueryValue(this.options.enabled, this.#currentQuery) !== false &&\n isValidTimeout(timeout)\n )\n }\n\n #updateStaleTimeout(): void {\n this.#clearStaleTimeout()\n const staleTime = resolveQueryValue(\n this.options.staleTime,\n this.#currentQuery,\n )\n\n if (this.#currentResult.isStale || !this.#shouldScheduleTimer(staleTime)) {\n return\n }\n\n const time = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime)\n\n // The timeout is sometimes triggered 1 ms before the stale time expiration.\n // To mitigate this issue we always add 1 ms to the timeout.\n const timeout = time + 1\n\n this.#staleTimeoutId = timeoutManager.setTimeout(() => {\n if (!this.#currentResult.isStale) {\n this.updateResult()\n }\n }, timeout)\n }\n\n #computeRefetchInterval() {\n return (\n (typeof this.options.refetchInterval === 'function'\n ? this.options.refetchInterval(this.#currentQuery)\n : this.options.refetchInterval) ?? false\n )\n }\n\n #updateRefetchInterval(nextInterval: number | false): void {\n this.#clearRefetchInterval()\n\n this.#currentRefetchInterval = nextInterval\n\n if (\n this.#currentRefetchInterval === 0 ||\n !this.#shouldScheduleTimer(this.#currentRefetchInterval)\n ) {\n return\n }\n\n this.#refetchIntervalId = timeoutManager.setInterval(() => {\n if (\n this.options.refetchIntervalInBackground ||\n focusManager.isFocused()\n ) {\n this.#executeFetch()\n }\n }, this.#currentRefetchInterval)\n }\n\n #updateTimers(): void {\n this.#updateStaleTimeout()\n this.#updateRefetchInterval(this.#computeRefetchInterval())\n }\n\n #clearStaleTimeout(): void {\n if (this.#staleTimeoutId !== undefined) {\n timeoutManager.clearTimeout(this.#staleTimeoutId)\n this.#staleTimeoutId = undefined\n }\n }\n\n #clearRefetchInterval(): void {\n if (this.#refetchIntervalId !== undefined) {\n timeoutManager.clearInterval(this.#refetchIntervalId)\n this.#refetchIntervalId = undefined\n }\n }\n\n protected createResult(\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): QueryObserverResult<TData, TError> {\n const prevQuery = this.#currentQuery\n const prevOptions = this.options\n const prevResult = this.#currentResult as\n | QueryObserverResult<TData, TError>\n | undefined\n const prevResultState = this.#currentResultState\n const prevResultOptions = this.#currentResultOptions\n const queryChange = query !== prevQuery\n const queryInitialState = queryChange\n ? query.state\n : this.#currentQueryInitialState\n\n const { state } = query\n let newState = { ...state }\n let isPlaceholderData = false\n let data: TData | undefined\n\n // Optimistically set result in fetching state if needed\n if (options._optimisticResults) {\n const mounted = this.hasListeners()\n\n const fetchOnMount = !mounted && shouldFetchOnMount(query, options)\n\n const fetchOptionally =\n mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions)\n\n if (fetchOnMount || fetchOptionally) {\n newState = {\n ...newState,\n ...fetchState(state.data, query.options),\n }\n }\n if (options._optimisticResults === 'isRestoring') {\n newState.fetchStatus = 'idle'\n }\n }\n\n let { error, errorUpdatedAt, status } = newState\n\n // Per default, use query data\n data = newState.data as unknown as TData\n let skipSelect = false\n\n // use placeholderData if needed\n if (\n options.placeholderData !== undefined &&\n data === undefined &&\n status === 'pending'\n ) {\n let placeholderData\n\n // Memoize placeholder data\n if (\n prevResult?.isPlaceholderData &&\n options.placeholderData === prevResultOptions?.placeholderData\n ) {\n placeholderData = prevResult.data\n // we have to skip select when reading this memoization\n // because prevResult.data is already \"selected\"\n skipSelect = true\n } else {\n // compute placeholderData\n placeholderData =\n typeof options.placeholderData === 'function'\n ? (\n options.placeholderData as unknown as PlaceholderDataFunction<TQueryData>\n )(\n this.#lastQueryWithDefinedData?.state.data,\n this.#lastQueryWithDefinedData as any,\n )\n : options.placeholderData\n }\n\n if (placeholderData !== undefined) {\n status = 'success'\n data = replaceData(\n prevResult?.data,\n placeholderData as unknown,\n options,\n ) as TData\n isPlaceholderData = true\n }\n }\n\n // Select data if needed\n // this also runs placeholderData through the select function\n if (options.select && data !== undefined && !skipSelect) {\n // Memoize select result\n if (\n prevResult &&\n data === prevResultState?.data &&\n options.select === this.#selectFn\n ) {\n data = this.#selectResult\n } else {\n try {\n this.#selectFn = options.select\n data = options.select(data as any)\n data = replaceData(prevResult?.data, data, options)\n this.#selectResult = data\n this.#selectError = null\n } catch (selectError) {\n this.#selectError = selectError as TError\n }\n }\n } else if (data === undefined) {\n // a stored select error belongs to previously selected data; once that\n // data is gone (query switch or reset), it must not leak into this result\n this.#selectError = null\n }\n\n if (this.#selectError) {\n error = this.#selectError\n data = this.#selectResult\n errorUpdatedAt = Date.now()\n status = 'error'\n isPlaceholderData = false\n }\n\n const isFetching = newState.fetchStatus === 'fetching'\n const isPending = status === 'pending'\n const isError = status === 'error'\n\n const isLoading = isPending && isFetching\n const hasData = data !== undefined\n\n const result: QueryObserverBaseResult<TData, TError> = {\n status,\n fetchStatus: newState.fetchStatus,\n isPending,\n isSuccess: status === 'success',\n isError,\n isInitialLoading: isLoading,\n isLoading,\n data,\n dataUpdatedAt: newState.dataUpdatedAt,\n error,\n errorUpdatedAt,\n failureCount: newState.fetchFailureCount,\n failureReason: newState.fetchFailureReason,\n errorUpdateCount: newState.errorUpdateCount,\n isFetched: query.isFetched(),\n isFetchedAfterMount:\n newState.dataUpdateCount > queryInitialState.dataUpdateCount ||\n newState.errorUpdateCount > queryInitialState.errorUpdateCount,\n isFetching,\n isRefetching: isFetching && !isPending,\n isLoadingError: isError && !hasData,\n isPaused: newState.fetchStatus === 'paused',\n isPlaceholderData,\n isRefetchError: isError && hasData,\n isStale: isStale(query, options),\n refetch: this.refetch,\n isEnabled: resolveQueryValue(options.enabled, query) !== false,\n }\n\n const nextResult = result as QueryObserverResult<TData, TError>\n\n return nextResult\n }\n\n updateResult(): void {\n const prevResult = this.#currentResult as\n | QueryObserverResult<TData, TError>\n | undefined\n\n const nextResult = this.createResult(this.#currentQuery, this.options)\n\n this.#currentResultState = this.#currentQuery.state\n this.#currentResultOptions = this.options\n\n if (this.#currentResultState.data !== undefined) {\n this.#lastQueryWithDefinedData = this.#currentQuery\n }\n\n // Only notify and update result if something has changed\n if (shallowEqualObjects(nextResult, prevResult)) {\n return\n }\n\n this.#currentResult = nextResult\n\n const shouldNotifyListeners = (): boolean => {\n if (!prevResult) {\n return true\n }\n\n const { notifyOnChangeProps } = this.options\n const notifyOnChangePropsValue =\n typeof notifyOnChangeProps === 'function'\n ? notifyOnChangeProps()\n : notifyOnChangeProps\n\n if (\n notifyOnChangePropsValue === 'all' ||\n (!notifyOnChangePropsValue && !this.#trackedProps.size)\n ) {\n return true\n }\n\n const includedProps = new Set(\n notifyOnChangePropsValue ?? this.#trackedProps,\n )\n\n if (this.options.throwOnError) {\n includedProps.add('error')\n }\n\n return Object.keys(this.#currentResult).some((key) => {\n const typedKey = key as keyof QueryObserverResult\n const changed = this.#currentResult[typedKey] !== prevResult[typedKey]\n\n return changed && includedProps.has(typedKey)\n })\n }\n\n const notifyListeners = shouldNotifyListeners()\n\n notifyManager.batch(() => {\n // First, trigger the listeners\n if (notifyListeners) {\n this.listeners.forEach((listener) => {\n listener(this.#currentResult)\n })\n }\n\n // Then the cache listeners\n this.#client.getQueryCache().notify({\n query: this.#currentQuery,\n type: 'observerResultsUpdated',\n })\n })\n }\n\n #updateQuery(): void {\n const query = this.#client.getQueryCache().build(this.#client, this.options)\n\n if (query === this.#currentQuery) {\n return\n }\n\n const prevQuery = this.#currentQuery as\n | Query<TQueryFnData, TError, TQueryData, TQueryKey>\n | undefined\n this.#currentQuery = query\n this.#currentQueryInitialState = query.state\n\n if (this.hasListeners()) {\n prevQuery?.removeObserver(this)\n query.addObserver(this)\n }\n }\n\n onQueryUpdate(): void {\n this.updateResult()\n\n if (this.hasListeners()) {\n this.#updateTimers()\n }\n }\n}\n\nfunction shouldLoadOnMount(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any>,\n): boolean {\n return (\n resolveQueryValue(options.enabled, query) !== false &&\n query.state.data === undefined &&\n !(\n query.state.status === 'error' &&\n resolveQueryValue(options.retryOnMount, query) === false\n )\n )\n}\n\nfunction shouldFetchOnMount(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n): boolean {\n return (\n shouldLoadOnMount(query, options) ||\n (query.state.data !== undefined &&\n shouldFetchOn(query, options, options.refetchOnMount))\n )\n}\n\nfunction shouldFetchOn(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n field: (typeof options)['refetchOnMount'] &\n (typeof options)['refetchOnWindowFocus'] &\n (typeof options)['refetchOnReconnect'],\n) {\n if (\n resolveQueryValue(options.enabled, query) !== false &&\n resolveQueryValue(options.staleTime, query) !== 'static'\n ) {\n const value = typeof field === 'function' ? field(query) : field\n\n return value === 'always' || (value !== false && isStale(query, options))\n }\n return false\n}\n\nfunction shouldFetchOptionally(\n query: Query<any, any, any, any>,\n prevQuery: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n prevOptions: QueryObserverOptions<any, any, any, any, any>,\n): boolean {\n return (\n (query !== prevQuery ||\n resolveQueryValue(prevOptions.enabled, query) === false) &&\n (!options.suspense || query.state.status !== 'error') &&\n isStale(query, options)\n )\n}\n\nfunction isStale(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n): boolean {\n return (\n resolveQueryValue(options.enabled, query) !== false &&\n query.isStaleByTime(resolveQueryValue(options.staleTime, query))\n )\n}\n"],"mappings":";;;;;;;;;AAoCA,IAAa,gBAAb,cAMUA,qBAAAA,aAAmD;CAC3D;CACA,gBAAoE,KAAA;CACpE,4BAA4D,KAAA;CAC5D,iBAAqD,KAAA;CACrD;CACA;CAOA;CACA;CACA;CAGA;CACA;CACA;CACA;CACA,gCAAgB,IAAI,IAA+B;CAEnD,YACE,QACA,SAOA;EACA,MAAM;EARC,KAAA,UAAA;EAUP,KAAKC,UAAU;EACf,KAAKC,eAAe;EAEpB,KAAK,YAAY;EACjB,KAAK,WAAW,OAAO;CACzB;CAEA,cAA8B;EAC5B,KAAK,UAAU,KAAK,QAAQ,KAAK,IAAI;CACvC;CAEA,cAA8B;EAC5B,IAAI,KAAK,UAAU,SAAS,GAAG;GAC7B,KAAKC,cAAc,YAAY,IAAI;GAEnC,IAAI,mBAAmB,KAAKA,eAAe,KAAK,OAAO,GACrD,KAAKC,cAAc;QAEnB,KAAK,aAAa;GAGpB,KAAKC,cAAc;EACrB;CACF;CAEA,gBAAgC;EAC9B,IAAI,CAAC,KAAK,aAAa,GACrB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Q,OAAO,UAAU,aAAa,MAAM,KAAK,IAAI;EAE3D,OAAO,UAAU,YAAa,UAAU,SAAS,QAAQ,OAAO,OAAO;CACzE;CACA,OAAO;AACT;AAEA,SAAS,sBACP,OACA,WACA,SACA,aACS;CACT,QACG,UAAU,aACTA,cAAAA,kBAAkB,YAAY,SAAS,KAAK,MAAM,WACnD,CAAC,QAAQ,YAAY,MAAM,MAAM,WAAW,YAC7C,QAAQ,OAAO,OAAO;AAE1B;AAEA,SAAS,QACP,OACA,SACS;CACT,OACEA,cAAAA,kBAAkB,QAAQ,SAAS,KAAK,MAAM,SAC9C,MAAM,cAAcA,cAAAA,kBAAkB,QAAQ,WAAW,KAAK,CAAC;AAEnE"}
1
+ {"version":3,"file":"queryObserver.cjs","names":["Subscribable","#client","#selectError","#currentQuery","#executeFetch","#updateTimers","#clearStaleTimeout","#clearRefetchInterval","resolveQueryValue","#updateQuery","shallowEqualObjects","#updateStaleTimeout","#computeRefetchInterval","#currentRefetchInterval","#updateRefetchInterval","#currentResult","#currentResultOptions","#currentResultState","#trackedProps","noop","isServerEnvironment","isValidTimeout","#shouldScheduleTimer","timeUntilStale","#staleTimeoutId","timeoutManager","#refetchIntervalId","focusManager","#currentQueryInitialState","fetchState","#lastQueryWithDefinedData","replaceData","#selectFn","#selectResult"],"sources":["../../src/queryObserver.ts"],"sourcesContent":["import { focusManager } from './focusManager'\nimport { isServer as isServerEnvironment } from './environmentManager'\nimport { notifyManager } from './notifyManager'\nimport { fetchState } from './query'\nimport { Subscribable } from './subscribable'\nimport {\n isValidTimeout,\n noop,\n replaceData,\n resolveQueryValue,\n shallowEqualObjects,\n timeUntilStale,\n} from './utils'\nimport { timeoutManager } from './timeoutManager'\nimport type { ManagedTimerId } from './timeoutManager'\nimport type { FetchOptions, Query, QueryState } from './query'\nimport type { QueryClient } from './queryClient'\nimport type {\n DefaultError,\n DefaultedQueryObserverOptions,\n PlaceholderDataFunction,\n QueryKey,\n QueryObserverBaseResult,\n QueryObserverOptions,\n QueryObserverResult,\n RefetchOptions,\n} from './types'\n\ntype QueryObserverListener<TData, TError> = (\n result: QueryObserverResult<TData, TError>,\n) => void\n\ninterface ObserverFetchOptions extends FetchOptions {\n throwOnError?: boolean\n}\n\n/**\n * A `QueryObserver` watches a single query in the `QueryCache` and computes a\n * `QueryObserverResult` from its state, recomputing and notifying subscribers\n * whenever the underlying query (or the observer's options) changes. It is\n * the primitive that framework adapters (e.g. `useQuery`) build their hooks\n * on top of, but it can also be used directly to observe and switch between\n * queries outside of any framework.\n *\n * @example\n * ```ts\n * const observer = new QueryObserver(queryClient, {\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n *\n * const unsubscribe = observer.subscribe((result) => {\n * console.log(result.data)\n * })\n * ```\n */\nexport class QueryObserver<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> extends Subscribable<QueryObserverListener<TData, TError>> {\n #client: QueryClient\n #currentQuery: Query<TQueryFnData, TError, TQueryData, TQueryKey> = undefined!\n #currentQueryInitialState: QueryState<TQueryData, TError> = undefined!\n #currentResult: QueryObserverResult<TData, TError> = undefined!\n #currentResultState?: QueryState<TQueryData, TError>\n #currentResultOptions?: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >\n #selectError: TError | null\n #selectFn?: (data: TQueryData) => TData\n #selectResult?: TData\n // This property keeps track of the last query with defined data.\n // It will be used to pass the previous data and query to the placeholder function between renders.\n #lastQueryWithDefinedData?: Query<TQueryFnData, TError, TQueryData, TQueryKey>\n #staleTimeoutId?: ManagedTimerId\n #refetchIntervalId?: ManagedTimerId\n #currentRefetchInterval?: number | false\n #trackedProps = new Set<keyof QueryObserverResult>()\n\n constructor(\n client: QueryClient,\n public options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ) {\n super()\n\n this.#client = client\n this.#selectError = null\n\n this.bindMethods()\n this.setOptions(options)\n }\n\n protected bindMethods(): void {\n this.refetch = this.refetch.bind(this)\n }\n\n protected onSubscribe(): void {\n if (this.listeners.size === 1) {\n this.#currentQuery.addObserver(this)\n\n if (shouldFetchOnMount(this.#currentQuery, this.options)) {\n this.#executeFetch()\n } else {\n this.updateResult()\n }\n\n this.#updateTimers()\n }\n }\n\n protected onUnsubscribe(): void {\n if (!this.hasListeners()) {\n this.destroy()\n }\n }\n\n /**\n * Returns whether the observed query is currently stale and configured\n * (via the `refetchOnReconnect` option) to refetch when the network\n * reconnects.\n */\n shouldFetchOnReconnect(): boolean {\n return shouldFetchOn(\n this.#currentQuery,\n this.options,\n this.options.refetchOnReconnect,\n )\n }\n\n /**\n * Returns whether the observed query is currently stale and configured\n * (via the `refetchOnWindowFocus` option) to refetch when the window\n * regains focus.\n */\n shouldFetchOnWindowFocus(): boolean {\n return shouldFetchOn(\n this.#currentQuery,\n this.options,\n this.options.refetchOnWindowFocus,\n )\n }\n\n /**\n * Stops observing the current query: clears all listeners, cancels the\n * stale and refetch-interval timers, and removes this observer from the\n * query it was observing.\n */\n destroy(): void {\n this.listeners = new Set()\n this.#clearStaleTimeout()\n this.#clearRefetchInterval()\n this.#currentQuery.removeObserver(this)\n }\n\n /**\n * Updates the observer's options. This will re-resolve the query being\n * observed (switching to a different query if the `queryKey` changed),\n * trigger a fetch if the new options require one and the observer has\n * subscribers, recompute the current result, and reschedule the stale and\n * refetch-interval timers as needed.\n *\n * @example\n * ```ts\n * observer.setOptions({ queryKey: ['posts', 1], queryFn: () => fetchPost(1) })\n * // later: switch to a different query, reusing the same observer\n * observer.setOptions({ queryKey: ['posts', 2], queryFn: () => fetchPost(2) })\n * ```\n */\n setOptions(\n options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): void {\n const prevOptions = this.options\n const prevQuery = this.#currentQuery\n\n this.options = this.#client.defaultQueryOptions(options)\n\n if (\n this.options.enabled !== undefined &&\n typeof this.options.enabled !== 'boolean' &&\n typeof this.options.enabled !== 'function' &&\n typeof resolveQueryValue(this.options.enabled, this.#currentQuery) !==\n 'boolean'\n ) {\n throw new Error(\n 'Expected enabled to be a boolean or a callback that returns a boolean',\n )\n }\n\n this.#updateQuery()\n this.#currentQuery.setOptions(this.options)\n\n if (\n prevOptions._defaulted &&\n !shallowEqualObjects(this.options, prevOptions)\n ) {\n this.#client.getQueryCache().notify({\n type: 'observerOptionsUpdated',\n query: this.#currentQuery,\n observer: this,\n })\n }\n\n const mounted = this.hasListeners()\n\n // Fetch if there are subscribers\n if (\n mounted &&\n shouldFetchOptionally(\n this.#currentQuery,\n prevQuery,\n this.options,\n prevOptions,\n )\n ) {\n this.#executeFetch()\n }\n\n // Update result\n this.updateResult()\n\n // Update stale interval if needed\n if (\n mounted &&\n (this.#currentQuery !== prevQuery ||\n resolveQueryValue(this.options.enabled, this.#currentQuery) !==\n resolveQueryValue(prevOptions.enabled, this.#currentQuery) ||\n resolveQueryValue(this.options.staleTime, this.#currentQuery) !==\n resolveQueryValue(prevOptions.staleTime, this.#currentQuery))\n ) {\n this.#updateStaleTimeout()\n }\n\n const nextRefetchInterval = this.#computeRefetchInterval()\n\n // Update refetch interval if needed\n if (\n mounted &&\n (this.#currentQuery !== prevQuery ||\n resolveQueryValue(this.options.enabled, this.#currentQuery) !==\n resolveQueryValue(prevOptions.enabled, this.#currentQuery) ||\n nextRefetchInterval !== this.#currentRefetchInterval)\n ) {\n this.#updateRefetchInterval(nextRefetchInterval)\n }\n }\n\n /**\n * Computes the result the observer would produce for the given (already-defaulted) options\n * right now, building the underlying `Query` if it doesn't exist yet, without waiting for a\n * subscription callback. Called by framework adapters on every render (e.g. `useQuery`) so the\n * returned value is available synchronously, ahead of `setOptions` triggering an actual fetch.\n */\n getOptimisticResult(\n options: DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): QueryObserverResult<TData, TError> {\n const query = this.#client.getQueryCache().build(this.#client, options)\n\n const result = this.createResult(query, options)\n\n if (!shallowEqualObjects(this.getCurrentResult(), result)) {\n // this assigns the optimistic result to the current Observer\n // because if the query function changes, useQuery will be performing\n // an effect where it would fetch again.\n // When the fetch finishes, we perform a deep data cloning in order\n // to reuse objects references. This deep data clone is performed against\n // the `observer.currentResult.data` property\n // When QueryKey changes, we refresh the query and get new `optimistic`\n // result, while we leave the `observer.currentResult`, so when new data\n // arrives, it finds the old `observer.currentResult` which is related\n // to the old QueryKey. Which means that currentResult and selectData are\n // out of sync already.\n // To solve this, we move the cursor of the currentResult every time\n // an observer reads an optimistic value.\n\n // When keeping the previous data, the result doesn't change until new\n // data arrives.\n this.#currentResult = result\n this.#currentResultOptions = this.options\n this.#currentResultState = this.#currentQuery.state\n }\n return result\n }\n\n /**\n * Returns the most recently computed `QueryObserverResult` for the\n * observed query. This is a point-in-time read; to be notified of updates\n * as they happen, subscribe to the observer instead (its inherited\n * `subscribe` method).\n *\n * @example\n * ```ts\n * const result = observer.getCurrentResult()\n * console.log(result.status, result.data)\n * ```\n */\n getCurrentResult(): QueryObserverResult<TData, TError> {\n return this.#currentResult\n }\n\n /**\n * Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via\n * {@link QueryObserver#trackProp} (and an optional `onPropTracked` callback). Used by framework\n * adapters when `notifyOnChangeProps` is not set, to implement its default \"only re-render on\n * properties you actually read\" behavior.\n */\n trackResult(\n result: QueryObserverResult<TData, TError>,\n onPropTracked?: (key: keyof QueryObserverResult) => void,\n ): QueryObserverResult<TData, TError> {\n return new Proxy(result, {\n get: (target, key) => {\n this.trackProp(key as keyof QueryObserverResult)\n onPropTracked?.(key as keyof QueryObserverResult)\n return Reflect.get(target, key)\n },\n })\n }\n\n /**\n * Records that the given `QueryObserverResult` property was read, so a subsequent update only\n * notifies this observer if a tracked property actually changed. Normally called indirectly via\n * {@link QueryObserver#trackResult}'s proxy; exposed directly for adapters that track property\n * access themselves (e.g. through their own reactivity system) instead of via the proxy.\n */\n trackProp(key: keyof QueryObserverResult) {\n this.#trackedProps.add(key)\n }\n\n /**\n * Returns the `Query` instance this observer is currently observing.\n */\n getCurrentQuery(): Query<TQueryFnData, TError, TQueryData, TQueryKey> {\n return this.#currentQuery\n }\n\n /**\n * Refetches the observed query and returns a promise that resolves with\n * the resulting `QueryObserverResult`.\n *\n * @example\n * ```ts\n * const result = await observer.refetch({ cancelRefetch: false })\n * console.log(result.data)\n * ```\n */\n refetch({ ...options }: RefetchOptions = {}): Promise<\n QueryObserverResult<TData, TError>\n > {\n return this.fetch({\n ...options,\n })\n }\n\n /**\n * Fetches a query defined by the given options without affecting this\n * observer's own tracked query or result, and returns a promise that\n * resolves with the `QueryObserverResult` for that fetch. This is useful\n * for prefetching data that another observer (e.g. a query about to be\n * navigated to) will need, ahead of time.\n *\n * @example\n * ```ts\n * const result = await observer.fetchOptimistic({\n * queryKey: ['posts', 2],\n * queryFn: () => fetchPost(2),\n * })\n * console.log(result.data)\n * ```\n */\n fetchOptimistic(\n options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): Promise<QueryObserverResult<TData, TError>> {\n const defaultedOptions = this.#client.defaultQueryOptions(options)\n\n const query = this.#client\n .getQueryCache()\n .build(this.#client, defaultedOptions)\n\n let unsubscribe = () => {}\n let resolveEarly:\n | ((result: QueryObserverResult<TData, TError>) => void)\n | undefined\n\n const cachePromise = new Promise<QueryObserverResult<TData, TError>>(\n (resolve) => {\n resolveEarly = resolve\n unsubscribe = this.#client.getQueryCache().subscribe((event) => {\n if (\n event.type === 'updated' &&\n event.query.queryHash === query.queryHash &&\n query.state.data !== undefined\n ) {\n unsubscribe()\n resolve(this.createResult(query, defaultedOptions))\n }\n })\n },\n )\n\n return Promise.race([\n query\n .fetch()\n .then(() => {\n const result = this.createResult(query, defaultedOptions)\n // Settle the subscriber promise so both branches always settle.\n // This value is ignored by Promise.race since the fetch branch already won.\n resolveEarly?.(result)\n return result\n })\n .finally(() => {\n unsubscribe()\n }),\n cachePromise,\n ])\n }\n\n protected fetch(\n fetchOptions: ObserverFetchOptions,\n ): Promise<QueryObserverResult<TData, TError>> {\n return this.#executeFetch({\n ...fetchOptions,\n cancelRefetch: fetchOptions.cancelRefetch ?? true,\n }).then(() => {\n this.updateResult()\n return this.#currentResult\n })\n }\n\n #executeFetch(\n fetchOptions?: Omit<ObserverFetchOptions, 'initialPromise'>,\n ): Promise<TQueryData | undefined> {\n // Make sure we reference the latest query as the current one might have been removed\n this.#updateQuery()\n\n // Fetch\n let promise: Promise<TQueryData | undefined> = this.#currentQuery.fetch(\n this.options,\n fetchOptions,\n )\n\n if (!fetchOptions?.throwOnError) {\n promise = promise.catch(noop)\n }\n\n return promise\n }\n\n #shouldScheduleTimer(timeout: unknown): timeout is number {\n return (\n !isServerEnvironment() &&\n resolveQueryValue(this.options.enabled, this.#currentQuery) !== false &&\n isValidTimeout(timeout)\n )\n }\n\n #updateStaleTimeout(): void {\n this.#clearStaleTimeout()\n const staleTime = resolveQueryValue(\n this.options.staleTime,\n this.#currentQuery,\n )\n\n if (this.#currentResult.isStale || !this.#shouldScheduleTimer(staleTime)) {\n return\n }\n\n const time = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime)\n\n // The timeout is sometimes triggered 1 ms before the stale time expiration.\n // To mitigate this issue we always add 1 ms to the timeout.\n const timeout = time + 1\n\n this.#staleTimeoutId = timeoutManager.setTimeout(() => {\n if (!this.#currentResult.isStale) {\n this.updateResult()\n }\n }, timeout)\n }\n\n #computeRefetchInterval() {\n return (\n resolveQueryValue(this.options.refetchInterval, this.#currentQuery) ??\n false\n )\n }\n\n #updateRefetchInterval(nextInterval: number | false): void {\n this.#clearRefetchInterval()\n\n this.#currentRefetchInterval = nextInterval\n\n if (\n this.#currentRefetchInterval === 0 ||\n !this.#shouldScheduleTimer(this.#currentRefetchInterval)\n ) {\n return\n }\n\n this.#refetchIntervalId = timeoutManager.setInterval(() => {\n if (\n this.options.refetchIntervalInBackground ||\n focusManager.isFocused()\n ) {\n this.#executeFetch()\n }\n }, this.#currentRefetchInterval)\n }\n\n #updateTimers(): void {\n this.#updateStaleTimeout()\n this.#updateRefetchInterval(this.#computeRefetchInterval())\n }\n\n #clearStaleTimeout(): void {\n if (this.#staleTimeoutId !== undefined) {\n timeoutManager.clearTimeout(this.#staleTimeoutId)\n this.#staleTimeoutId = undefined\n }\n }\n\n #clearRefetchInterval(): void {\n if (this.#refetchIntervalId !== undefined) {\n timeoutManager.clearInterval(this.#refetchIntervalId)\n this.#refetchIntervalId = undefined\n }\n }\n\n protected createResult(\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n options: QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n ): QueryObserverResult<TData, TError> {\n const prevQuery = this.#currentQuery\n const prevOptions = this.options\n const prevResult = this.#currentResult as\n | QueryObserverResult<TData, TError>\n | undefined\n const prevResultState = this.#currentResultState\n const prevResultOptions = this.#currentResultOptions\n const queryChange = query !== prevQuery\n const queryInitialState = queryChange\n ? query.state\n : this.#currentQueryInitialState\n\n const { state } = query\n let newState = { ...state }\n let isPlaceholderData = false\n let data: TData | undefined\n\n // Optimistically set result in fetching state if needed\n if (options._optimisticResults) {\n const mounted = this.hasListeners()\n\n const fetchOnMount = !mounted && shouldFetchOnMount(query, options)\n\n const fetchOptionally =\n mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions)\n\n if (fetchOnMount || fetchOptionally) {\n newState = {\n ...newState,\n ...fetchState(state.data, query.options),\n }\n }\n if (options._optimisticResults === 'isRestoring') {\n newState.fetchStatus = 'idle'\n }\n }\n\n let { error, errorUpdatedAt, status } = newState\n\n // Per default, use query data\n data = newState.data as unknown as TData\n let skipSelect = false\n\n // use placeholderData if needed\n if (\n options.placeholderData !== undefined &&\n data === undefined &&\n status === 'pending'\n ) {\n let placeholderData\n\n // Memoize placeholder data\n if (\n prevResult?.isPlaceholderData &&\n options.placeholderData === prevResultOptions?.placeholderData\n ) {\n placeholderData = prevResult.data\n // we have to skip select when reading this memoization\n // because prevResult.data is already \"selected\"\n skipSelect = true\n } else {\n // compute placeholderData\n placeholderData =\n typeof options.placeholderData === 'function'\n ? (\n options.placeholderData as unknown as PlaceholderDataFunction<TQueryData>\n )(\n this.#lastQueryWithDefinedData?.state.data,\n this.#lastQueryWithDefinedData as any,\n )\n : options.placeholderData\n }\n\n if (placeholderData !== undefined) {\n status = 'success'\n data = replaceData(\n prevResult?.data,\n placeholderData as unknown,\n options,\n ) as TData\n isPlaceholderData = true\n }\n }\n\n // Select data if needed\n // this also runs placeholderData through the select function\n if (options.select && data !== undefined && !skipSelect) {\n // Memoize select result\n if (\n prevResult &&\n data === prevResultState?.data &&\n options.select === this.#selectFn\n ) {\n data = this.#selectResult\n } else {\n try {\n this.#selectFn = options.select\n data = options.select(data as any)\n data = replaceData(prevResult?.data, data, options)\n this.#selectResult = data\n this.#selectError = null\n } catch (selectError) {\n this.#selectError = selectError as TError\n }\n }\n } else if (data === undefined) {\n // a stored select error belongs to previously selected data; once that\n // data is gone (query switch or reset), it must not leak into this result\n this.#selectError = null\n }\n\n if (this.#selectError) {\n error = this.#selectError\n data = this.#selectResult\n errorUpdatedAt = Date.now()\n status = 'error'\n isPlaceholderData = false\n }\n\n const isFetching = newState.fetchStatus === 'fetching'\n const isPending = status === 'pending'\n const isError = status === 'error'\n\n const isLoading = isPending && isFetching\n const hasData = data !== undefined\n\n const result: QueryObserverBaseResult<TData, TError> = {\n status,\n fetchStatus: newState.fetchStatus,\n isPending,\n isSuccess: status === 'success',\n isError,\n isInitialLoading: isLoading,\n isLoading,\n data,\n dataUpdatedAt: newState.dataUpdatedAt,\n error,\n errorUpdatedAt,\n failureCount: newState.fetchFailureCount,\n failureReason: newState.fetchFailureReason,\n errorUpdateCount: newState.errorUpdateCount,\n isFetched: query.isFetched(),\n isFetchedAfterMount:\n newState.dataUpdateCount > queryInitialState.dataUpdateCount ||\n newState.errorUpdateCount > queryInitialState.errorUpdateCount,\n isFetching,\n isRefetching: isFetching && !isPending,\n isLoadingError: isError && !hasData,\n isPaused: newState.fetchStatus === 'paused',\n isPlaceholderData,\n isRefetchError: isError && hasData,\n isStale: isStale(query, options),\n refetch: this.refetch,\n isEnabled: resolveQueryValue(options.enabled, query) !== false,\n }\n\n const nextResult = result as QueryObserverResult<TData, TError>\n\n return nextResult\n }\n\n /**\n * Recomputes and stores the current result from the current query/options, notifying listeners\n * if it changed. Framework adapters call this right after subscribing to make sure no query\n * update was missed in the gap between creating the observer and subscribing to it.\n */\n updateResult(): void {\n const prevResult = this.#currentResult as\n | QueryObserverResult<TData, TError>\n | undefined\n\n const nextResult = this.createResult(this.#currentQuery, this.options)\n\n this.#currentResultState = this.#currentQuery.state\n this.#currentResultOptions = this.options\n\n if (this.#currentResultState.data !== undefined) {\n this.#lastQueryWithDefinedData = this.#currentQuery\n }\n\n // Only notify and update result if something has changed\n if (shallowEqualObjects(nextResult, prevResult)) {\n return\n }\n\n this.#currentResult = nextResult\n\n const shouldNotifyListeners = (): boolean => {\n if (!prevResult) {\n return true\n }\n\n const { notifyOnChangeProps } = this.options\n const notifyOnChangePropsValue =\n typeof notifyOnChangeProps === 'function'\n ? notifyOnChangeProps()\n : notifyOnChangeProps\n\n if (\n notifyOnChangePropsValue === 'all' ||\n (!notifyOnChangePropsValue && !this.#trackedProps.size)\n ) {\n return true\n }\n\n const includedProps = new Set(\n notifyOnChangePropsValue ?? this.#trackedProps,\n )\n\n if (this.options.throwOnError) {\n includedProps.add('error')\n }\n\n return Object.keys(this.#currentResult).some((key) => {\n const typedKey = key as keyof QueryObserverResult\n const changed = this.#currentResult[typedKey] !== prevResult[typedKey]\n\n return changed && includedProps.has(typedKey)\n })\n }\n\n const notifyListeners = shouldNotifyListeners()\n\n notifyManager.batch(() => {\n // First, trigger the listeners\n if (notifyListeners) {\n this.listeners.forEach((listener) => {\n listener(this.#currentResult)\n })\n }\n\n // Then the cache listeners\n this.#client.getQueryCache().notify({\n query: this.#currentQuery,\n type: 'observerResultsUpdated',\n })\n })\n }\n\n #updateQuery(): void {\n const query = this.#client.getQueryCache().build(this.#client, this.options)\n\n if (query === this.#currentQuery) {\n return\n }\n\n const prevQuery = this.#currentQuery as\n | Query<TQueryFnData, TError, TQueryData, TQueryKey>\n | undefined\n this.#currentQuery = query\n this.#currentQueryInitialState = query.state\n\n if (this.hasListeners()) {\n prevQuery?.removeObserver(this)\n query.addObserver(this)\n }\n }\n\n /** @internal */\n onQueryUpdate(): void {\n this.updateResult()\n\n if (this.hasListeners()) {\n this.#updateTimers()\n }\n }\n}\n\nfunction shouldLoadOnMount(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any>,\n): boolean {\n return (\n resolveQueryValue(options.enabled, query) !== false &&\n query.state.data === undefined &&\n !(\n query.state.status === 'error' &&\n resolveQueryValue(options.retryOnMount, query) === false\n )\n )\n}\n\nfunction shouldFetchOnMount(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n): boolean {\n return (\n shouldLoadOnMount(query, options) ||\n (query.state.data !== undefined &&\n shouldFetchOn(query, options, options.refetchOnMount))\n )\n}\n\nfunction shouldFetchOn(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n field: (typeof options)['refetchOnMount'] &\n (typeof options)['refetchOnWindowFocus'] &\n (typeof options)['refetchOnReconnect'],\n) {\n if (\n resolveQueryValue(options.enabled, query) !== false &&\n resolveQueryValue(options.staleTime, query) !== 'static'\n ) {\n const value = resolveQueryValue(field, query)\n\n return value === 'always' || (value !== false && isStale(query, options))\n }\n return false\n}\n\nfunction shouldFetchOptionally(\n query: Query<any, any, any, any>,\n prevQuery: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n prevOptions: QueryObserverOptions<any, any, any, any, any>,\n): boolean {\n return (\n (query !== prevQuery ||\n resolveQueryValue(prevOptions.enabled, query) === false) &&\n (!options.suspense || query.state.status !== 'error') &&\n isStale(query, options)\n )\n}\n\nfunction isStale(\n query: Query<any, any, any, any>,\n options: QueryObserverOptions<any, any, any, any, any>,\n): boolean {\n return (\n resolveQueryValue(options.enabled, query) !== false &&\n query.isStaleByTime(resolveQueryValue(options.staleTime, query))\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,IAAa,gBAAb,cAMUA,qBAAAA,aAAmD;CAC3D;CACA,gBAAoE,KAAA;CACpE,4BAA4D,KAAA;CAC5D,iBAAqD,KAAA;CACrD;CACA;CAOA;CACA;CACA;CAGA;CACA;CACA;CACA;CACA,gCAAgB,IAAI,IAA+B;CAEnD,YACE,QACA,SAOA;EACA,MAAM;EARC,KAAA,UAAA;EAUP,KAAKC,UAAU;EACf,KAAKC,eAAe;EAEpB,KAAK,YAAY;EACjB,KAAK,WAAW,OAAO;CACzB;CAEA,cAA8B;EAC5B,KAAK,UAAU,KAAK,QAAQ,KAAK,IAAI;CACvC;CAEA,cAA8B;EAC5B,IAAI,KAAK,UAAU,SAAS,GAAG;GAC7B,KAAKC,cAAc,YAAY,IAAI;GAEnC,IAAI,mBAAmB,KAAKA,eAAe,KAAK,OAAO,GACrD,KAAKC,cAAc;QAEnB,KAAK,aAAa;GAGpB,KAAKC,cAAc;EACrB;CACF;CAEA,gBAAgC;EAC9B,IAAI,CAAC,KAAK,aAAa,GACrB,KAAK,QAAQ;CAEjB;;;;;;CAOA,yBAAkC;EAChC,OAAO,cACL,KAAKF,eACL,KAAK,SACL,KAAK,QAAQ,kBACf;CACF;;;;;;CAOA,2BAAoC;EAClC,OAAO,cACL,KAAKA,eACL,KAAK,SACL,KAAK,QAAQ,oBACf;CACF;;;;;;CAOA,UAAgB;EACd,KAAK,4BAAY,IAAI,IAAI;EACzB,KAAKG,mBAAmB;EACxB,KAAKC,sBAAsB;EAC3B,KAAKJ,cAAc,eAAe,IAAI;CACxC;;;;;;;;;;;;;;;CAgBA,WACE,SAOM;EACN,MAAM,cAAc,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P,OACA,SACS;CACT,OACEA,cAAAA,kBAAkB,QAAQ,SAAS,KAAK,MAAM,SAC9C,MAAM,cAAcA,cAAAA,kBAAkB,QAAQ,WAAW,KAAK,CAAC;AAEnE"}
@@ -1,2 +1,2 @@
1
- import { rr as QueryObserver } from "./hydration-DWGr3cFC.cjs";
1
+ import { rr as QueryObserver } from "./hydration-DwR10Hi-.cjs";
2
2
  export { QueryObserver };
@@ -1,2 +1,2 @@
1
- import { rr as QueryObserver } from "./hydration-Bjs0MSgg.js";
1
+ import { rr as QueryObserver } from "./hydration-Cq7QYAzB.js";
2
2
  export { QueryObserver };