@tanstack/query-core 5.103.2 → 5.104.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 (267) hide show
  1. package/build/legacy/{classPrivateFieldSet2-CV7wyte-.js → classPrivateFieldSet2-CukOTU3U.js} +5 -5
  2. package/build/legacy/{classPrivateFieldSet2-Bo0ZyOIv.cjs → classPrivateFieldSet2-CvCEk6bM.cjs} +5 -5
  3. package/build/legacy/{classPrivateMethodInitSpec-CBwa_Y7C.js → classPrivateMethodInitSpec-CgB-WYk3.js} +2 -2
  4. package/build/legacy/{classPrivateMethodInitSpec-DVhcLejn.cjs → classPrivateMethodInitSpec-Nr6mgZRs.cjs} +2 -2
  5. package/build/legacy/environmentManager.d.cts +3 -4
  6. package/build/legacy/environmentManager.d.cts.map +1 -1
  7. package/build/legacy/environmentManager.d.ts +3 -4
  8. package/build/legacy/environmentManager.d.ts.map +1 -1
  9. package/build/legacy/focusManager.cjs +1 -1
  10. package/build/legacy/focusManager.d.cts +3 -4
  11. package/build/legacy/focusManager.d.cts.map +1 -1
  12. package/build/legacy/focusManager.d.ts +3 -4
  13. package/build/legacy/focusManager.d.ts.map +1 -1
  14. package/build/legacy/focusManager.js +1 -1
  15. package/build/legacy/{hydration-Bp57N3SP.d.ts → hydration-B9t5w6NC.d.ts} +11 -4
  16. package/build/legacy/hydration-B9t5w6NC.d.ts.map +1 -0
  17. package/build/{modern/hydration-DRcloXEn.d.cts → legacy/hydration-Br9VIGXa.d.cts} +11 -4
  18. package/build/legacy/hydration-Br9VIGXa.d.cts.map +1 -0
  19. package/build/legacy/hydration.d.cts +1 -1
  20. package/build/legacy/hydration.d.ts +1 -1
  21. package/build/legacy/index.d.cts +1 -1
  22. package/build/legacy/index.d.ts +1 -1
  23. package/build/legacy/infiniteQueryBehavior.d.cts +4 -5
  24. package/build/legacy/infiniteQueryBehavior.d.cts.map +1 -1
  25. package/build/legacy/infiniteQueryBehavior.d.ts +4 -5
  26. package/build/legacy/infiniteQueryBehavior.d.ts.map +1 -1
  27. package/build/legacy/infiniteQueryObserver.d.cts +3 -4
  28. package/build/legacy/infiniteQueryObserver.d.cts.map +1 -1
  29. package/build/legacy/infiniteQueryObserver.d.ts +3 -4
  30. package/build/legacy/infiniteQueryObserver.d.ts.map +1 -1
  31. package/build/legacy/mutation.cjs +2 -2
  32. package/build/legacy/mutation.d.cts +1 -1
  33. package/build/legacy/mutation.d.ts +1 -1
  34. package/build/legacy/mutation.js +2 -2
  35. package/build/legacy/mutationCache.cjs +1 -1
  36. package/build/legacy/mutationCache.d.cts +1 -1
  37. package/build/legacy/mutationCache.d.ts +1 -1
  38. package/build/legacy/mutationCache.js +1 -1
  39. package/build/legacy/mutationObserver.cjs +2 -2
  40. package/build/legacy/mutationObserver.d.cts +1 -1
  41. package/build/legacy/mutationObserver.d.ts +1 -1
  42. package/build/legacy/mutationObserver.js +2 -2
  43. package/build/legacy/notifyManager.d.cts +3 -4
  44. package/build/legacy/notifyManager.d.cts.map +1 -1
  45. package/build/legacy/notifyManager.d.ts +3 -4
  46. package/build/legacy/notifyManager.d.ts.map +1 -1
  47. package/build/legacy/onlineManager.cjs +1 -1
  48. package/build/legacy/onlineManager.d.cts +3 -4
  49. package/build/legacy/onlineManager.d.cts.map +1 -1
  50. package/build/legacy/onlineManager.d.ts +3 -4
  51. package/build/legacy/onlineManager.d.ts.map +1 -1
  52. package/build/legacy/onlineManager.js +1 -1
  53. package/build/legacy/queriesObserver.cjs +2 -2
  54. package/build/legacy/queriesObserver.d.cts +4 -5
  55. package/build/legacy/queriesObserver.d.cts.map +1 -1
  56. package/build/legacy/queriesObserver.d.ts +4 -5
  57. package/build/legacy/queriesObserver.d.ts.map +1 -1
  58. package/build/legacy/queriesObserver.js +2 -2
  59. package/build/legacy/query.cjs +2 -2
  60. package/build/legacy/query.cjs.map +1 -1
  61. package/build/legacy/query.d.cts +1 -1
  62. package/build/legacy/query.d.ts +1 -1
  63. package/build/legacy/query.js +2 -2
  64. package/build/legacy/query.js.map +1 -1
  65. package/build/legacy/queryCache.cjs +1 -1
  66. package/build/legacy/queryCache.cjs.map +1 -1
  67. package/build/legacy/queryCache.d.cts +1 -1
  68. package/build/legacy/queryCache.d.ts +1 -1
  69. package/build/legacy/queryCache.js +1 -1
  70. package/build/legacy/queryCache.js.map +1 -1
  71. package/build/legacy/queryClient.cjs +8 -1
  72. package/build/legacy/queryClient.cjs.map +1 -1
  73. package/build/legacy/queryClient.d.cts +1 -1
  74. package/build/legacy/queryClient.d.ts +1 -1
  75. package/build/legacy/queryClient.js +8 -1
  76. package/build/legacy/queryClient.js.map +1 -1
  77. package/build/legacy/queryObserver.cjs +2 -2
  78. package/build/legacy/queryObserver.cjs.map +1 -1
  79. package/build/legacy/queryObserver.d.cts +1 -1
  80. package/build/legacy/queryObserver.d.ts +1 -1
  81. package/build/legacy/queryObserver.js +2 -2
  82. package/build/legacy/queryObserver.js.map +1 -1
  83. package/build/legacy/removable-0GzhW1PK.d.cts +22 -0
  84. package/build/legacy/removable-0GzhW1PK.d.cts.map +1 -0
  85. package/build/legacy/removable-0GzhW1PK.d.ts +22 -0
  86. package/build/legacy/removable-0GzhW1PK.d.ts.map +1 -0
  87. package/build/legacy/removable.cjs +10 -1
  88. package/build/legacy/removable.cjs.map +1 -1
  89. package/build/legacy/removable.d.cts +1 -1
  90. package/build/legacy/removable.d.ts +1 -1
  91. package/build/legacy/removable.js +10 -1
  92. package/build/legacy/removable.js.map +1 -1
  93. package/build/legacy/retryer.d.cts +1 -1
  94. package/build/legacy/retryer.d.ts +1 -1
  95. package/build/legacy/streamedQuery.cjs +0 -7
  96. package/build/legacy/streamedQuery.cjs.map +1 -1
  97. package/build/legacy/streamedQuery.d.cts +2 -10
  98. package/build/legacy/streamedQuery.d.cts.map +1 -1
  99. package/build/legacy/streamedQuery.d.ts +2 -10
  100. package/build/legacy/streamedQuery.d.ts.map +1 -1
  101. package/build/legacy/streamedQuery.js +0 -7
  102. package/build/legacy/streamedQuery.js.map +1 -1
  103. package/build/legacy/subscribable-CysQ0tne.d.cts +34 -0
  104. package/build/legacy/subscribable-CysQ0tne.d.cts.map +1 -0
  105. package/build/legacy/subscribable-CysQ0tne.d.ts +34 -0
  106. package/build/legacy/subscribable-CysQ0tne.d.ts.map +1 -0
  107. package/build/legacy/subscribable.cjs +22 -0
  108. package/build/legacy/subscribable.cjs.map +1 -1
  109. package/build/legacy/subscribable.d.cts +1 -1
  110. package/build/legacy/subscribable.d.ts +1 -1
  111. package/build/legacy/subscribable.js +22 -0
  112. package/build/legacy/subscribable.js.map +1 -1
  113. package/build/legacy/timeoutManager.cjs +1 -1
  114. package/build/legacy/timeoutManager.d.cts +7 -8
  115. package/build/legacy/timeoutManager.d.cts.map +1 -1
  116. package/build/legacy/timeoutManager.d.ts +7 -8
  117. package/build/legacy/timeoutManager.d.ts.map +1 -1
  118. package/build/legacy/timeoutManager.js +1 -1
  119. package/build/legacy/types.cjs.map +1 -1
  120. package/build/legacy/types.d.cts +1 -1
  121. package/build/legacy/types.d.ts +1 -1
  122. package/build/legacy/types.js.map +1 -1
  123. package/build/legacy/utils.d.cts +1 -1
  124. package/build/legacy/utils.d.ts +1 -1
  125. package/build/modern/environmentManager.d.cts +3 -4
  126. package/build/modern/environmentManager.d.cts.map +1 -1
  127. package/build/modern/environmentManager.d.ts +3 -4
  128. package/build/modern/environmentManager.d.ts.map +1 -1
  129. package/build/modern/focusManager.cjs.map +1 -1
  130. package/build/modern/focusManager.d.cts +3 -4
  131. package/build/modern/focusManager.d.cts.map +1 -1
  132. package/build/modern/focusManager.d.ts +3 -4
  133. package/build/modern/focusManager.d.ts.map +1 -1
  134. package/build/modern/focusManager.js.map +1 -1
  135. package/build/{legacy/hydration-DRcloXEn.d.cts → modern/hydration-B9t5w6NC.d.ts} +11 -4
  136. package/build/modern/hydration-B9t5w6NC.d.ts.map +1 -0
  137. package/build/modern/{hydration-Bp57N3SP.d.ts → hydration-Br9VIGXa.d.cts} +11 -4
  138. package/build/modern/hydration-Br9VIGXa.d.cts.map +1 -0
  139. package/build/modern/hydration.d.cts +1 -1
  140. package/build/modern/hydration.d.ts +1 -1
  141. package/build/modern/index.d.cts +1 -1
  142. package/build/modern/index.d.ts +1 -1
  143. package/build/modern/infiniteQueryBehavior.d.cts +4 -5
  144. package/build/modern/infiniteQueryBehavior.d.cts.map +1 -1
  145. package/build/modern/infiniteQueryBehavior.d.ts +4 -5
  146. package/build/modern/infiniteQueryBehavior.d.ts.map +1 -1
  147. package/build/modern/infiniteQueryObserver.d.cts +3 -4
  148. package/build/modern/infiniteQueryObserver.d.cts.map +1 -1
  149. package/build/modern/infiniteQueryObserver.d.ts +3 -4
  150. package/build/modern/infiniteQueryObserver.d.ts.map +1 -1
  151. package/build/modern/mutation.cjs.map +1 -1
  152. package/build/modern/mutation.d.cts +1 -1
  153. package/build/modern/mutation.d.ts +1 -1
  154. package/build/modern/mutation.js.map +1 -1
  155. package/build/modern/mutationCache.cjs.map +1 -1
  156. package/build/modern/mutationCache.d.cts +1 -1
  157. package/build/modern/mutationCache.d.ts +1 -1
  158. package/build/modern/mutationCache.js.map +1 -1
  159. package/build/modern/mutationObserver.cjs.map +1 -1
  160. package/build/modern/mutationObserver.d.cts +1 -1
  161. package/build/modern/mutationObserver.d.ts +1 -1
  162. package/build/modern/mutationObserver.js.map +1 -1
  163. package/build/modern/notifyManager.d.cts +3 -4
  164. package/build/modern/notifyManager.d.cts.map +1 -1
  165. package/build/modern/notifyManager.d.ts +3 -4
  166. package/build/modern/notifyManager.d.ts.map +1 -1
  167. package/build/modern/onlineManager.cjs.map +1 -1
  168. package/build/modern/onlineManager.d.cts +3 -4
  169. package/build/modern/onlineManager.d.cts.map +1 -1
  170. package/build/modern/onlineManager.d.ts +3 -4
  171. package/build/modern/onlineManager.d.ts.map +1 -1
  172. package/build/modern/onlineManager.js.map +1 -1
  173. package/build/modern/queriesObserver.cjs.map +1 -1
  174. package/build/modern/queriesObserver.d.cts +4 -5
  175. package/build/modern/queriesObserver.d.cts.map +1 -1
  176. package/build/modern/queriesObserver.d.ts +4 -5
  177. package/build/modern/queriesObserver.d.ts.map +1 -1
  178. package/build/modern/queriesObserver.js.map +1 -1
  179. package/build/modern/query.cjs.map +1 -1
  180. package/build/modern/query.d.cts +1 -1
  181. package/build/modern/query.d.ts +1 -1
  182. package/build/modern/query.js.map +1 -1
  183. package/build/modern/queryCache.cjs.map +1 -1
  184. package/build/modern/queryCache.d.cts +1 -1
  185. package/build/modern/queryCache.d.ts +1 -1
  186. package/build/modern/queryCache.js.map +1 -1
  187. package/build/modern/queryClient.cjs +7 -0
  188. package/build/modern/queryClient.cjs.map +1 -1
  189. package/build/modern/queryClient.d.cts +1 -1
  190. package/build/modern/queryClient.d.ts +1 -1
  191. package/build/modern/queryClient.js +7 -0
  192. package/build/modern/queryClient.js.map +1 -1
  193. package/build/modern/queryObserver.cjs.map +1 -1
  194. package/build/modern/queryObserver.d.cts +1 -1
  195. package/build/modern/queryObserver.d.ts +1 -1
  196. package/build/modern/queryObserver.js.map +1 -1
  197. package/build/modern/removable-0GzhW1PK.d.cts +22 -0
  198. package/build/modern/removable-0GzhW1PK.d.cts.map +1 -0
  199. package/build/modern/removable-0GzhW1PK.d.ts +22 -0
  200. package/build/modern/removable-0GzhW1PK.d.ts.map +1 -0
  201. package/build/modern/removable.cjs +9 -0
  202. package/build/modern/removable.cjs.map +1 -1
  203. package/build/modern/removable.d.cts +1 -1
  204. package/build/modern/removable.d.ts +1 -1
  205. package/build/modern/removable.js +9 -0
  206. package/build/modern/removable.js.map +1 -1
  207. package/build/modern/retryer.d.cts +1 -1
  208. package/build/modern/retryer.d.ts +1 -1
  209. package/build/modern/streamedQuery.cjs +0 -7
  210. package/build/modern/streamedQuery.cjs.map +1 -1
  211. package/build/modern/streamedQuery.d.cts +2 -10
  212. package/build/modern/streamedQuery.d.cts.map +1 -1
  213. package/build/modern/streamedQuery.d.ts +2 -10
  214. package/build/modern/streamedQuery.d.ts.map +1 -1
  215. package/build/modern/streamedQuery.js +0 -7
  216. package/build/modern/streamedQuery.js.map +1 -1
  217. package/build/modern/subscribable-CysQ0tne.d.cts +34 -0
  218. package/build/modern/subscribable-CysQ0tne.d.cts.map +1 -0
  219. package/build/modern/subscribable-CysQ0tne.d.ts +34 -0
  220. package/build/modern/subscribable-CysQ0tne.d.ts.map +1 -0
  221. package/build/modern/subscribable.cjs +22 -0
  222. package/build/modern/subscribable.cjs.map +1 -1
  223. package/build/modern/subscribable.d.cts +1 -1
  224. package/build/modern/subscribable.d.ts +1 -1
  225. package/build/modern/subscribable.js +22 -0
  226. package/build/modern/subscribable.js.map +1 -1
  227. package/build/modern/timeoutManager.cjs.map +1 -1
  228. package/build/modern/timeoutManager.d.cts +7 -8
  229. package/build/modern/timeoutManager.d.cts.map +1 -1
  230. package/build/modern/timeoutManager.d.ts +7 -8
  231. package/build/modern/timeoutManager.d.ts.map +1 -1
  232. package/build/modern/timeoutManager.js.map +1 -1
  233. package/build/modern/types.cjs.map +1 -1
  234. package/build/modern/types.d.cts +1 -1
  235. package/build/modern/types.d.ts +1 -1
  236. package/build/modern/types.js.map +1 -1
  237. package/build/modern/utils.d.cts +1 -1
  238. package/build/modern/utils.d.ts +1 -1
  239. package/package.json +3 -3
  240. package/src/query.ts +1 -2
  241. package/src/queryCache.ts +1 -2
  242. package/src/queryClient.ts +7 -0
  243. package/src/queryObserver.ts +4 -8
  244. package/src/removable.ts +9 -0
  245. package/src/streamedQuery.ts +1 -7
  246. package/src/subscribable.ts +22 -0
  247. package/src/types.ts +9 -15
  248. package/build/legacy/hydration-Bp57N3SP.d.ts.map +0 -1
  249. package/build/legacy/hydration-DRcloXEn.d.cts.map +0 -1
  250. package/build/legacy/removable-DeMjhW5M.d.cts +0 -13
  251. package/build/legacy/removable-DeMjhW5M.d.cts.map +0 -1
  252. package/build/legacy/removable-DeMjhW5M.d.ts +0 -13
  253. package/build/legacy/removable-DeMjhW5M.d.ts.map +0 -1
  254. package/build/legacy/subscribable-CbifVTKz.d.cts +0 -12
  255. package/build/legacy/subscribable-CbifVTKz.d.cts.map +0 -1
  256. package/build/legacy/subscribable-CbifVTKz.d.ts +0 -12
  257. package/build/legacy/subscribable-CbifVTKz.d.ts.map +0 -1
  258. package/build/modern/hydration-Bp57N3SP.d.ts.map +0 -1
  259. package/build/modern/hydration-DRcloXEn.d.cts.map +0 -1
  260. package/build/modern/removable-DeMjhW5M.d.cts +0 -13
  261. package/build/modern/removable-DeMjhW5M.d.cts.map +0 -1
  262. package/build/modern/removable-DeMjhW5M.d.ts +0 -13
  263. package/build/modern/removable-DeMjhW5M.d.ts.map +0 -1
  264. package/build/modern/subscribable-CbifVTKz.d.cts +0 -12
  265. package/build/modern/subscribable-CbifVTKz.d.cts.map +0 -1
  266. package/build/modern/subscribable-CbifVTKz.d.ts +0 -12
  267. package/build/modern/subscribable-CbifVTKz.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"streamedQuery.cjs","names":["addToEnd","addConsumeAwareSignal"],"sources":["../../src/streamedQuery.ts"],"sourcesContent":["import { addConsumeAwareSignal, addToEnd } from './utils'\nimport type {\n OmitKeyof,\n QueryFunction,\n QueryFunctionContext,\n QueryKey,\n} from './types'\n\ntype BaseStreamedQueryParams<TQueryFnData, TQueryKey extends QueryKey> = {\n /** The function that returns an `AsyncIterable` to stream data from. */\n streamFn: (\n context: QueryFunctionContext<TQueryKey>,\n ) => AsyncIterable<TQueryFnData> | Promise<AsyncIterable<TQueryFnData>>\n /**\n * Defines how refetches are handled.\n * - `'reset'` (default): erases all data and puts the query back into `pending` state.\n * - `'append'`: appends new data to the existing data.\n * - `'replace'`: writes all data to the cache once the stream ends.\n */\n refetchMode?: 'append' | 'reset' | 'replace'\n}\n\ntype SimpleStreamedQueryParams<\n TQueryFnData,\n TQueryKey extends QueryKey,\n> = BaseStreamedQueryParams<TQueryFnData, TQueryKey> & {\n reducer?: never\n initialValue?: never\n}\n\ntype ReducibleStreamedQueryParams<\n TQueryFnData,\n TData,\n TQueryKey extends QueryKey,\n> = BaseStreamedQueryParams<TQueryFnData, TQueryKey> & {\n /**\n * Reduces streamed chunks into the final data shape. Required whenever `TData` is not an\n * array, since there is no default way to accumulate non-array chunks.\n */\n reducer: (acc: TData, chunk: TQueryFnData) => TData\n /**\n * The value used while the first chunk is being fetched, and returned if the stream yields no\n * values. Required together with a custom `reducer`.\n */\n initialValue: TData\n}\n\ntype StreamedQueryParams<TQueryFnData, TData, TQueryKey extends QueryKey> =\n | SimpleStreamedQueryParams<TQueryFnData, TQueryKey>\n | ReducibleStreamedQueryParams<TQueryFnData, TData, TQueryKey>\n\n/**\n * This is a helper function to create a query function that streams data from an AsyncIterable.\n * Data will be an Array of all the chunks received.\n * The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that.\n * The query will stay in fetchStatus 'fetching' until the stream ends.\n * @param streamFn - The function that returns an AsyncIterable to stream data from.\n * @param refetchMode - Defines how re-fetches are handled.\n * Defaults to `'reset'`, erases all data and puts the query back into `pending` state.\n * Set to `'append'` to append new data to the existing data.\n * Set to `'replace'` to write all data to the cache once the stream ends.\n * @param reducer - A function to reduce the streamed chunks into the final data.\n * Defaults to a function that appends chunks to the end of the array.\n * @param initialValue - Initial value to be used while the first chunk is being fetched, and returned if the stream yields no values.\n * @example\n * ```ts\n * await queryClient.query({\n * queryKey: ['data'],\n * queryFn: streamedQuery({\n * streamFn: fetchDataInChunks,\n * }),\n * })\n * ```\n */\nexport function streamedQuery<\n TQueryFnData = unknown,\n TData = Array<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n>({\n streamFn,\n refetchMode = 'reset',\n reducer = (items, chunk) =>\n addToEnd(items as Array<TQueryFnData>, chunk) as TData,\n initialValue = [] as TData,\n}: StreamedQueryParams<TQueryFnData, TData, TQueryKey>): QueryFunction<\n TData,\n TQueryKey\n> {\n return async (context) => {\n const query = context.client\n .getQueryCache()\n .find({ queryKey: context.queryKey, exact: true })\n const isRefetch = !!query && query.isFetched()\n if (isRefetch && refetchMode === 'reset') {\n query.setState({\n ...query.resetState,\n fetchStatus: 'fetching',\n })\n }\n\n let result = initialValue\n\n let cancelled: boolean = false as boolean\n const streamFnContext = addConsumeAwareSignal<\n OmitKeyof<typeof context, 'signal'>\n >(\n {\n client: context.client,\n meta: context.meta,\n queryKey: context.queryKey,\n pageParam: context.pageParam,\n direction: context.direction,\n },\n () => context.signal,\n () => (cancelled = true),\n )\n\n const stream = await streamFn(streamFnContext)\n\n const isReplaceRefetch = isRefetch && refetchMode === 'replace'\n\n for await (const chunk of stream) {\n if (cancelled) {\n break\n }\n\n if (isReplaceRefetch) {\n // don't append to the cache directly when replace-refetching\n result = reducer(result, chunk)\n } else {\n context.client.setQueryData<TData>(context.queryKey, (prev) =>\n reducer(prev === undefined ? initialValue : prev, chunk),\n )\n }\n }\n\n // finalize result: replace-refetching needs to write to the cache\n if (isReplaceRefetch && !cancelled) {\n context.client.setQueryData<TData>(context.queryKey, result)\n }\n\n const data = context.client.getQueryData<TData>(context.queryKey)\n return data === undefined ? initialValue : data\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0EA,SAAgB,cAId,EACA,UACA,cAAc,SACd,WAAW,OAAO,UAChBA,cAAAA,SAAS,OAA8B,KAAK,GAC9C,eAAe,CAAC,KAIhB;CACA,OAAO,OAAO,YAAY;EACxB,MAAM,QAAQ,QAAQ,OACnB,cAAc,CAAC,CACf,KAAK;GAAE,UAAU,QAAQ;GAAU,OAAO;EAAK,CAAC;EACnD,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,UAAU;EAC7C,IAAI,aAAa,gBAAgB,SAC/B,MAAM,SAAS;GACb,GAAG,MAAM;GACT,aAAa;EACf,CAAC;EAGH,IAAI,SAAS;EAEb,IAAI,YAAqB;EAezB,MAAM,SAAS,MAAM,SAdGC,cAAAA,sBAGtB;GACE,QAAQ,QAAQ;GAChB,MAAM,QAAQ;GACd,UAAU,QAAQ;GAClB,WAAW,QAAQ;GACnB,WAAW,QAAQ;EACrB,SACM,QAAQ,cACP,YAAY,IAGuB,CAAC;EAE7C,MAAM,mBAAmB,aAAa,gBAAgB;EAEtD,WAAW,MAAM,SAAS,QAAQ;GAChC,IAAI,WACF;GAGF,IAAI,kBAEF,SAAS,QAAQ,QAAQ,KAAK;QAE9B,QAAQ,OAAO,aAAoB,QAAQ,WAAW,SACpD,QAAQ,SAAS,KAAA,IAAY,eAAe,MAAM,KAAK,CACzD;EAEJ;EAGA,IAAI,oBAAoB,CAAC,WACvB,QAAQ,OAAO,aAAoB,QAAQ,UAAU,MAAM;EAG7D,MAAM,OAAO,QAAQ,OAAO,aAAoB,QAAQ,QAAQ;EAChE,OAAO,SAAS,KAAA,IAAY,eAAe;CAC7C;AACF"}
1
+ {"version":3,"file":"streamedQuery.cjs","names":["addToEnd","addConsumeAwareSignal"],"sources":["../../src/streamedQuery.ts"],"sourcesContent":["import { addConsumeAwareSignal, addToEnd } from './utils'\nimport type {\n OmitKeyof,\n QueryFunction,\n QueryFunctionContext,\n QueryKey,\n} from './types'\n\ntype BaseStreamedQueryParams<TQueryFnData, TQueryKey extends QueryKey> = {\n /** The function that returns an `AsyncIterable` to stream data from. */\n streamFn: (\n context: QueryFunctionContext<TQueryKey>,\n ) => AsyncIterable<TQueryFnData> | Promise<AsyncIterable<TQueryFnData>>\n /**\n * Defines how refetches are handled.\n * - `'reset'` (default): erases all data and puts the query back into `pending` state.\n * - `'append'`: appends new data to the existing data.\n * - `'replace'`: writes all data to the cache once the stream ends.\n */\n refetchMode?: 'append' | 'reset' | 'replace'\n}\n\ntype SimpleStreamedQueryParams<\n TQueryFnData,\n TQueryKey extends QueryKey,\n> = BaseStreamedQueryParams<TQueryFnData, TQueryKey> & {\n reducer?: never\n initialValue?: never\n}\n\ntype ReducibleStreamedQueryParams<\n TQueryFnData,\n TData,\n TQueryKey extends QueryKey,\n> = BaseStreamedQueryParams<TQueryFnData, TQueryKey> & {\n /**\n * Reduces streamed chunks into the final data shape. Required whenever `TData` is not an\n * array, since there is no default way to accumulate non-array chunks.\n */\n reducer: (acc: TData, chunk: TQueryFnData) => TData\n /**\n * The value used while the first chunk is being fetched, and returned if the stream yields no\n * values. Required together with a custom `reducer`.\n */\n initialValue: TData\n}\n\ntype StreamedQueryParams<TQueryFnData, TData, TQueryKey extends QueryKey> =\n | SimpleStreamedQueryParams<TQueryFnData, TQueryKey>\n | ReducibleStreamedQueryParams<TQueryFnData, TData, TQueryKey>\n\n/**\n * This is a helper function to create a query function that streams data from an AsyncIterable.\n * Data will be an Array of all the chunks received.\n * The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that.\n * The query will stay in fetchStatus 'fetching' until the stream ends.\n * @param streamFn - The function that returns an AsyncIterable to stream data from.\n * @example\n * ```ts\n * await queryClient.query({\n * queryKey: ['data'],\n * queryFn: streamedQuery({\n * streamFn: fetchDataInChunks,\n * }),\n * })\n * ```\n */\nexport function streamedQuery<\n TQueryFnData = unknown,\n TData = Array<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n>({\n streamFn,\n refetchMode = 'reset',\n reducer = (items, chunk) =>\n addToEnd(items as Array<TQueryFnData>, chunk) as TData,\n initialValue = [] as TData,\n}: StreamedQueryParams<TQueryFnData, TData, TQueryKey>): QueryFunction<\n TData,\n TQueryKey\n> {\n return async (context) => {\n const query = context.client\n .getQueryCache()\n .find({ queryKey: context.queryKey, exact: true })\n const isRefetch = !!query && query.isFetched()\n if (isRefetch && refetchMode === 'reset') {\n query.setState({\n ...query.resetState,\n fetchStatus: 'fetching',\n })\n }\n\n let result = initialValue\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n let cancelled: boolean = false as boolean\n const streamFnContext = addConsumeAwareSignal<\n OmitKeyof<typeof context, 'signal'>\n >(\n {\n client: context.client,\n meta: context.meta,\n queryKey: context.queryKey,\n pageParam: context.pageParam,\n direction: context.direction,\n },\n () => context.signal,\n () => (cancelled = true),\n )\n\n const stream = await streamFn(streamFnContext)\n\n const isReplaceRefetch = isRefetch && refetchMode === 'replace'\n\n for await (const chunk of stream) {\n if (cancelled) {\n break\n }\n\n if (isReplaceRefetch) {\n // don't append to the cache directly when replace-refetching\n result = reducer(result, chunk)\n } else {\n context.client.setQueryData<TData>(context.queryKey, (prev) =>\n reducer(prev === undefined ? initialValue : prev, chunk),\n )\n }\n }\n\n // finalize result: replace-refetching needs to write to the cache\n if (isReplaceRefetch && !cancelled) {\n context.client.setQueryData<TData>(context.queryKey, result)\n }\n\n const data = context.client.getQueryData<TData>(context.queryKey)\n return data === undefined ? initialValue : data\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmEA,SAAgB,cAId,EACA,UACA,cAAc,SACd,WAAW,OAAO,UAChBA,cAAAA,SAAS,OAA8B,KAAK,GAC9C,eAAe,CAAC,KAIhB;CACA,OAAO,OAAO,YAAY;EACxB,MAAM,QAAQ,QAAQ,OACnB,cAAc,CAAC,CACf,KAAK;GAAE,UAAU,QAAQ;GAAU,OAAO;EAAK,CAAC;EACnD,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,UAAU;EAC7C,IAAI,aAAa,gBAAgB,SAC/B,MAAM,SAAS;GACb,GAAG,MAAM;GACT,aAAa;EACf,CAAC;EAGH,IAAI,SAAS;EAGb,IAAI,YAAqB;EAezB,MAAM,SAAS,MAAM,SAdGC,cAAAA,sBAGtB;GACE,QAAQ,QAAQ;GAChB,MAAM,QAAQ;GACd,UAAU,QAAQ;GAClB,WAAW,QAAQ;GACnB,WAAW,QAAQ;EACrB,SACM,QAAQ,cACP,YAAY,IAGuB,CAAC;EAE7C,MAAM,mBAAmB,aAAa,gBAAgB;EAEtD,WAAW,MAAM,SAAS,QAAQ;GAChC,IAAI,WACF;GAGF,IAAI,kBAEF,SAAS,QAAQ,QAAQ,KAAK;QAE9B,QAAQ,OAAO,aAAoB,QAAQ,WAAW,SACpD,QAAQ,SAAS,KAAA,IAAY,eAAe,MAAM,KAAK,CACzD;EAEJ;EAGA,IAAI,oBAAoB,CAAC,WACvB,QAAQ,OAAO,aAAoB,QAAQ,UAAU,MAAM;EAG7D,MAAM,OAAO,QAAQ,OAAO,aAAoB,QAAQ,QAAQ;EAChE,OAAO,SAAS,KAAA,IAAY,eAAe;CAC7C;AACF"}
@@ -1,4 +1,4 @@
1
- import { Ct as QueryKey, St as QueryFunctionContext, xt as QueryFunction } from "./hydration-DRcloXEn.cjs";
1
+ import { Ct as QueryKey, St as QueryFunctionContext, xt as QueryFunction } from "./hydration-Br9VIGXa.cjs";
2
2
  //#region src/streamedQuery.d.ts
3
3
  type BaseStreamedQueryParams<TQueryFnData, TQueryKey extends QueryKey> = {
4
4
  /** The function that returns an `AsyncIterable` to stream data from. */
@@ -34,13 +34,6 @@ type StreamedQueryParams<TQueryFnData, TData, TQueryKey extends QueryKey> = Simp
34
34
  * The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that.
35
35
  * The query will stay in fetchStatus 'fetching' until the stream ends.
36
36
  * @param streamFn - The function that returns an AsyncIterable to stream data from.
37
- * @param refetchMode - Defines how re-fetches are handled.
38
- * Defaults to `'reset'`, erases all data and puts the query back into `pending` state.
39
- * Set to `'append'` to append new data to the existing data.
40
- * Set to `'replace'` to write all data to the cache once the stream ends.
41
- * @param reducer - A function to reduce the streamed chunks into the final data.
42
- * Defaults to a function that appends chunks to the end of the array.
43
- * @param initialValue - Initial value to be used while the first chunk is being fetched, and returned if the stream yields no values.
44
37
  * @example
45
38
  * ```ts
46
39
  * await queryClient.query({
@@ -51,7 +44,6 @@ type StreamedQueryParams<TQueryFnData, TData, TQueryKey extends QueryKey> = Simp
51
44
  * })
52
45
  * ```
53
46
  */
54
- declare function streamedQuery<TQueryFnData = unknown, TData = Array<TQueryFnData>, TQueryKey extends QueryKey = QueryKey>({ streamFn, refetchMode, reducer, initialValue }: StreamedQueryParams<TQueryFnData, TData, TQueryKey>): QueryFunction<TData, TQueryKey>;
47
+ export declare function streamedQuery<TQueryFnData = unknown, TData = Array<TQueryFnData>, TQueryKey extends QueryKey = QueryKey>({ streamFn, refetchMode, reducer, initialValue }: StreamedQueryParams<TQueryFnData, TData, TQueryKey>): QueryFunction<TData, TQueryKey>;
55
48
  //#endregion
56
- export { streamedQuery };
57
49
  //# sourceMappingURL=streamedQuery.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"streamedQuery.d.cts","names":[],"sources":["../../src/streamedQuery.ts"],"mappings":";;KAQK,wBAAwB,cAAc,kBAAkB;;EAE3D,WACE,SAAS,qBAAqB,eAC3B,cAAc,gBAAgB,QAAQ,cAAc;;;;;;;EAOzD;;KAGG,0BACH,cACA,kBAAkB,YAChB,wBAAwB,cAAc;EACxC;EACA;;KAGG,6BACH,cACA,OACA,kBAAkB,YAChB,wBAAwB,cAAc;;;;;EAKxC,UAAU,KAAK,OAAO,OAAO,iBAAiB;;;;;EAK9C,cAAc;;KAGX,oBAAoB,cAAc,OAAO,kBAAkB,YAC5D,0BAA0B,cAAc,aACxC,6BAA6B,cAAc,OAAO;;;;;;;;;;;;;;;;;;;;;;;;iBAyBtC,cACd,wBACA,QAAQ,MAAM,eACd,kBAAkB,WAAW,YAE7B,UACA,aACA,SAEA,gBACC,oBAAoB,cAAc,OAAO,aAAa,cACvD,OACA"}
1
+ {"version":3,"file":"streamedQuery.d.cts","names":[],"sources":["../../src/streamedQuery.ts"],"mappings":";;KAQK,wBAAwB,cAAc,kBAAkB;;EAE3D,WACE,SAAS,qBAAqB,eAC3B,cAAc,gBAAgB,QAAQ,cAAc;;;;;;;EAOzD;;KAGG,0BACH,cACA,kBAAkB,YAChB,wBAAwB,cAAc;EACxC;EACA;;KAGG,6BACH,cACA,OACA,kBAAkB,YAChB,wBAAwB,cAAc;;;;;EAKxC,UAAU,KAAK,OAAO,OAAO,iBAAiB;;;;;EAK9C,cAAc;;KAGX,oBAAoB,cAAc,OAAO,kBAAkB,YAC5D,0BAA0B,cAAc,aACxC,6BAA6B,cAAc,OAAO;;;;;;;;;;;;;;;;;wBAkBtC,cACd,wBACA,QAAQ,MAAM,eACd,kBAAkB,WAAW,YAE7B,UACA,aACA,SAEA,gBACC,oBAAoB,cAAc,OAAO,aAAa,cACvD,OACA"}
@@ -1,4 +1,4 @@
1
- import { Ct as QueryKey, St as QueryFunctionContext, xt as QueryFunction } from "./hydration-Bp57N3SP.js";
1
+ import { Ct as QueryKey, St as QueryFunctionContext, xt as QueryFunction } from "./hydration-B9t5w6NC.js";
2
2
  //#region src/streamedQuery.d.ts
3
3
  type BaseStreamedQueryParams<TQueryFnData, TQueryKey extends QueryKey> = {
4
4
  /** The function that returns an `AsyncIterable` to stream data from. */
@@ -34,13 +34,6 @@ type StreamedQueryParams<TQueryFnData, TData, TQueryKey extends QueryKey> = Simp
34
34
  * The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that.
35
35
  * The query will stay in fetchStatus 'fetching' until the stream ends.
36
36
  * @param streamFn - The function that returns an AsyncIterable to stream data from.
37
- * @param refetchMode - Defines how re-fetches are handled.
38
- * Defaults to `'reset'`, erases all data and puts the query back into `pending` state.
39
- * Set to `'append'` to append new data to the existing data.
40
- * Set to `'replace'` to write all data to the cache once the stream ends.
41
- * @param reducer - A function to reduce the streamed chunks into the final data.
42
- * Defaults to a function that appends chunks to the end of the array.
43
- * @param initialValue - Initial value to be used while the first chunk is being fetched, and returned if the stream yields no values.
44
37
  * @example
45
38
  * ```ts
46
39
  * await queryClient.query({
@@ -51,7 +44,6 @@ type StreamedQueryParams<TQueryFnData, TData, TQueryKey extends QueryKey> = Simp
51
44
  * })
52
45
  * ```
53
46
  */
54
- declare function streamedQuery<TQueryFnData = unknown, TData = Array<TQueryFnData>, TQueryKey extends QueryKey = QueryKey>({ streamFn, refetchMode, reducer, initialValue }: StreamedQueryParams<TQueryFnData, TData, TQueryKey>): QueryFunction<TData, TQueryKey>;
47
+ export declare function streamedQuery<TQueryFnData = unknown, TData = Array<TQueryFnData>, TQueryKey extends QueryKey = QueryKey>({ streamFn, refetchMode, reducer, initialValue }: StreamedQueryParams<TQueryFnData, TData, TQueryKey>): QueryFunction<TData, TQueryKey>;
55
48
  //#endregion
56
- export { streamedQuery };
57
49
  //# sourceMappingURL=streamedQuery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"streamedQuery.d.ts","names":[],"sources":["../../src/streamedQuery.ts"],"mappings":";;KAQK,wBAAwB,cAAc,kBAAkB;;EAE3D,WACE,SAAS,qBAAqB,eAC3B,cAAc,gBAAgB,QAAQ,cAAc;;;;;;;EAOzD;;KAGG,0BACH,cACA,kBAAkB,YAChB,wBAAwB,cAAc;EACxC;EACA;;KAGG,6BACH,cACA,OACA,kBAAkB,YAChB,wBAAwB,cAAc;;;;;EAKxC,UAAU,KAAK,OAAO,OAAO,iBAAiB;;;;;EAK9C,cAAc;;KAGX,oBAAoB,cAAc,OAAO,kBAAkB,YAC5D,0BAA0B,cAAc,aACxC,6BAA6B,cAAc,OAAO;;;;;;;;;;;;;;;;;;;;;;;;iBAyBtC,cACd,wBACA,QAAQ,MAAM,eACd,kBAAkB,WAAW,YAE7B,UACA,aACA,SAEA,gBACC,oBAAoB,cAAc,OAAO,aAAa,cACvD,OACA"}
1
+ {"version":3,"file":"streamedQuery.d.ts","names":[],"sources":["../../src/streamedQuery.ts"],"mappings":";;KAQK,wBAAwB,cAAc,kBAAkB;;EAE3D,WACE,SAAS,qBAAqB,eAC3B,cAAc,gBAAgB,QAAQ,cAAc;;;;;;;EAOzD;;KAGG,0BACH,cACA,kBAAkB,YAChB,wBAAwB,cAAc;EACxC;EACA;;KAGG,6BACH,cACA,OACA,kBAAkB,YAChB,wBAAwB,cAAc;;;;;EAKxC,UAAU,KAAK,OAAO,OAAO,iBAAiB;;;;;EAK9C,cAAc;;KAGX,oBAAoB,cAAc,OAAO,kBAAkB,YAC5D,0BAA0B,cAAc,aACxC,6BAA6B,cAAc,OAAO;;;;;;;;;;;;;;;;;wBAkBtC,cACd,wBACA,QAAQ,MAAM,eACd,kBAAkB,WAAW,YAE7B,UACA,aACA,SAEA,gBACC,oBAAoB,cAAc,OAAO,aAAa,cACvD,OACA"}
@@ -6,13 +6,6 @@ import { addConsumeAwareSignal, addToEnd } from "./utils.js";
6
6
  * The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that.
7
7
  * The query will stay in fetchStatus 'fetching' until the stream ends.
8
8
  * @param streamFn - The function that returns an AsyncIterable to stream data from.
9
- * @param refetchMode - Defines how re-fetches are handled.
10
- * Defaults to `'reset'`, erases all data and puts the query back into `pending` state.
11
- * Set to `'append'` to append new data to the existing data.
12
- * Set to `'replace'` to write all data to the cache once the stream ends.
13
- * @param reducer - A function to reduce the streamed chunks into the final data.
14
- * Defaults to a function that appends chunks to the end of the array.
15
- * @param initialValue - Initial value to be used while the first chunk is being fetched, and returned if the stream yields no values.
16
9
  * @example
17
10
  * ```ts
18
11
  * await queryClient.query({
@@ -1 +1 @@
1
- {"version":3,"file":"streamedQuery.js","names":[],"sources":["../../src/streamedQuery.ts"],"sourcesContent":["import { addConsumeAwareSignal, addToEnd } from './utils'\nimport type {\n OmitKeyof,\n QueryFunction,\n QueryFunctionContext,\n QueryKey,\n} from './types'\n\ntype BaseStreamedQueryParams<TQueryFnData, TQueryKey extends QueryKey> = {\n /** The function that returns an `AsyncIterable` to stream data from. */\n streamFn: (\n context: QueryFunctionContext<TQueryKey>,\n ) => AsyncIterable<TQueryFnData> | Promise<AsyncIterable<TQueryFnData>>\n /**\n * Defines how refetches are handled.\n * - `'reset'` (default): erases all data and puts the query back into `pending` state.\n * - `'append'`: appends new data to the existing data.\n * - `'replace'`: writes all data to the cache once the stream ends.\n */\n refetchMode?: 'append' | 'reset' | 'replace'\n}\n\ntype SimpleStreamedQueryParams<\n TQueryFnData,\n TQueryKey extends QueryKey,\n> = BaseStreamedQueryParams<TQueryFnData, TQueryKey> & {\n reducer?: never\n initialValue?: never\n}\n\ntype ReducibleStreamedQueryParams<\n TQueryFnData,\n TData,\n TQueryKey extends QueryKey,\n> = BaseStreamedQueryParams<TQueryFnData, TQueryKey> & {\n /**\n * Reduces streamed chunks into the final data shape. Required whenever `TData` is not an\n * array, since there is no default way to accumulate non-array chunks.\n */\n reducer: (acc: TData, chunk: TQueryFnData) => TData\n /**\n * The value used while the first chunk is being fetched, and returned if the stream yields no\n * values. Required together with a custom `reducer`.\n */\n initialValue: TData\n}\n\ntype StreamedQueryParams<TQueryFnData, TData, TQueryKey extends QueryKey> =\n | SimpleStreamedQueryParams<TQueryFnData, TQueryKey>\n | ReducibleStreamedQueryParams<TQueryFnData, TData, TQueryKey>\n\n/**\n * This is a helper function to create a query function that streams data from an AsyncIterable.\n * Data will be an Array of all the chunks received.\n * The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that.\n * The query will stay in fetchStatus 'fetching' until the stream ends.\n * @param streamFn - The function that returns an AsyncIterable to stream data from.\n * @param refetchMode - Defines how re-fetches are handled.\n * Defaults to `'reset'`, erases all data and puts the query back into `pending` state.\n * Set to `'append'` to append new data to the existing data.\n * Set to `'replace'` to write all data to the cache once the stream ends.\n * @param reducer - A function to reduce the streamed chunks into the final data.\n * Defaults to a function that appends chunks to the end of the array.\n * @param initialValue - Initial value to be used while the first chunk is being fetched, and returned if the stream yields no values.\n * @example\n * ```ts\n * await queryClient.query({\n * queryKey: ['data'],\n * queryFn: streamedQuery({\n * streamFn: fetchDataInChunks,\n * }),\n * })\n * ```\n */\nexport function streamedQuery<\n TQueryFnData = unknown,\n TData = Array<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n>({\n streamFn,\n refetchMode = 'reset',\n reducer = (items, chunk) =>\n addToEnd(items as Array<TQueryFnData>, chunk) as TData,\n initialValue = [] as TData,\n}: StreamedQueryParams<TQueryFnData, TData, TQueryKey>): QueryFunction<\n TData,\n TQueryKey\n> {\n return async (context) => {\n const query = context.client\n .getQueryCache()\n .find({ queryKey: context.queryKey, exact: true })\n const isRefetch = !!query && query.isFetched()\n if (isRefetch && refetchMode === 'reset') {\n query.setState({\n ...query.resetState,\n fetchStatus: 'fetching',\n })\n }\n\n let result = initialValue\n\n let cancelled: boolean = false as boolean\n const streamFnContext = addConsumeAwareSignal<\n OmitKeyof<typeof context, 'signal'>\n >(\n {\n client: context.client,\n meta: context.meta,\n queryKey: context.queryKey,\n pageParam: context.pageParam,\n direction: context.direction,\n },\n () => context.signal,\n () => (cancelled = true),\n )\n\n const stream = await streamFn(streamFnContext)\n\n const isReplaceRefetch = isRefetch && refetchMode === 'replace'\n\n for await (const chunk of stream) {\n if (cancelled) {\n break\n }\n\n if (isReplaceRefetch) {\n // don't append to the cache directly when replace-refetching\n result = reducer(result, chunk)\n } else {\n context.client.setQueryData<TData>(context.queryKey, (prev) =>\n reducer(prev === undefined ? initialValue : prev, chunk),\n )\n }\n }\n\n // finalize result: replace-refetching needs to write to the cache\n if (isReplaceRefetch && !cancelled) {\n context.client.setQueryData<TData>(context.queryKey, result)\n }\n\n const data = context.client.getQueryData<TData>(context.queryKey)\n return data === undefined ? initialValue : data\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0EA,SAAgB,cAId,EACA,UACA,cAAc,SACd,WAAW,OAAO,UAChB,SAAS,OAA8B,KAAK,GAC9C,eAAe,CAAC,KAIhB;CACA,OAAO,OAAO,YAAY;EACxB,MAAM,QAAQ,QAAQ,OACnB,cAAc,CAAC,CACf,KAAK;GAAE,UAAU,QAAQ;GAAU,OAAO;EAAK,CAAC;EACnD,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,UAAU;EAC7C,IAAI,aAAa,gBAAgB,SAC/B,MAAM,SAAS;GACb,GAAG,MAAM;GACT,aAAa;EACf,CAAC;EAGH,IAAI,SAAS;EAEb,IAAI,YAAqB;EAezB,MAAM,SAAS,MAAM,SAdG,sBAGtB;GACE,QAAQ,QAAQ;GAChB,MAAM,QAAQ;GACd,UAAU,QAAQ;GAClB,WAAW,QAAQ;GACnB,WAAW,QAAQ;EACrB,SACM,QAAQ,cACP,YAAY,IAGuB,CAAC;EAE7C,MAAM,mBAAmB,aAAa,gBAAgB;EAEtD,WAAW,MAAM,SAAS,QAAQ;GAChC,IAAI,WACF;GAGF,IAAI,kBAEF,SAAS,QAAQ,QAAQ,KAAK;QAE9B,QAAQ,OAAO,aAAoB,QAAQ,WAAW,SACpD,QAAQ,SAAS,KAAA,IAAY,eAAe,MAAM,KAAK,CACzD;EAEJ;EAGA,IAAI,oBAAoB,CAAC,WACvB,QAAQ,OAAO,aAAoB,QAAQ,UAAU,MAAM;EAG7D,MAAM,OAAO,QAAQ,OAAO,aAAoB,QAAQ,QAAQ;EAChE,OAAO,SAAS,KAAA,IAAY,eAAe;CAC7C;AACF"}
1
+ {"version":3,"file":"streamedQuery.js","names":[],"sources":["../../src/streamedQuery.ts"],"sourcesContent":["import { addConsumeAwareSignal, addToEnd } from './utils'\nimport type {\n OmitKeyof,\n QueryFunction,\n QueryFunctionContext,\n QueryKey,\n} from './types'\n\ntype BaseStreamedQueryParams<TQueryFnData, TQueryKey extends QueryKey> = {\n /** The function that returns an `AsyncIterable` to stream data from. */\n streamFn: (\n context: QueryFunctionContext<TQueryKey>,\n ) => AsyncIterable<TQueryFnData> | Promise<AsyncIterable<TQueryFnData>>\n /**\n * Defines how refetches are handled.\n * - `'reset'` (default): erases all data and puts the query back into `pending` state.\n * - `'append'`: appends new data to the existing data.\n * - `'replace'`: writes all data to the cache once the stream ends.\n */\n refetchMode?: 'append' | 'reset' | 'replace'\n}\n\ntype SimpleStreamedQueryParams<\n TQueryFnData,\n TQueryKey extends QueryKey,\n> = BaseStreamedQueryParams<TQueryFnData, TQueryKey> & {\n reducer?: never\n initialValue?: never\n}\n\ntype ReducibleStreamedQueryParams<\n TQueryFnData,\n TData,\n TQueryKey extends QueryKey,\n> = BaseStreamedQueryParams<TQueryFnData, TQueryKey> & {\n /**\n * Reduces streamed chunks into the final data shape. Required whenever `TData` is not an\n * array, since there is no default way to accumulate non-array chunks.\n */\n reducer: (acc: TData, chunk: TQueryFnData) => TData\n /**\n * The value used while the first chunk is being fetched, and returned if the stream yields no\n * values. Required together with a custom `reducer`.\n */\n initialValue: TData\n}\n\ntype StreamedQueryParams<TQueryFnData, TData, TQueryKey extends QueryKey> =\n | SimpleStreamedQueryParams<TQueryFnData, TQueryKey>\n | ReducibleStreamedQueryParams<TQueryFnData, TData, TQueryKey>\n\n/**\n * This is a helper function to create a query function that streams data from an AsyncIterable.\n * Data will be an Array of all the chunks received.\n * The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that.\n * The query will stay in fetchStatus 'fetching' until the stream ends.\n * @param streamFn - The function that returns an AsyncIterable to stream data from.\n * @example\n * ```ts\n * await queryClient.query({\n * queryKey: ['data'],\n * queryFn: streamedQuery({\n * streamFn: fetchDataInChunks,\n * }),\n * })\n * ```\n */\nexport function streamedQuery<\n TQueryFnData = unknown,\n TData = Array<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n>({\n streamFn,\n refetchMode = 'reset',\n reducer = (items, chunk) =>\n addToEnd(items as Array<TQueryFnData>, chunk) as TData,\n initialValue = [] as TData,\n}: StreamedQueryParams<TQueryFnData, TData, TQueryKey>): QueryFunction<\n TData,\n TQueryKey\n> {\n return async (context) => {\n const query = context.client\n .getQueryCache()\n .find({ queryKey: context.queryKey, exact: true })\n const isRefetch = !!query && query.isFetched()\n if (isRefetch && refetchMode === 'reset') {\n query.setState({\n ...query.resetState,\n fetchStatus: 'fetching',\n })\n }\n\n let result = initialValue\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n let cancelled: boolean = false as boolean\n const streamFnContext = addConsumeAwareSignal<\n OmitKeyof<typeof context, 'signal'>\n >(\n {\n client: context.client,\n meta: context.meta,\n queryKey: context.queryKey,\n pageParam: context.pageParam,\n direction: context.direction,\n },\n () => context.signal,\n () => (cancelled = true),\n )\n\n const stream = await streamFn(streamFnContext)\n\n const isReplaceRefetch = isRefetch && refetchMode === 'replace'\n\n for await (const chunk of stream) {\n if (cancelled) {\n break\n }\n\n if (isReplaceRefetch) {\n // don't append to the cache directly when replace-refetching\n result = reducer(result, chunk)\n } else {\n context.client.setQueryData<TData>(context.queryKey, (prev) =>\n reducer(prev === undefined ? initialValue : prev, chunk),\n )\n }\n }\n\n // finalize result: replace-refetching needs to write to the cache\n if (isReplaceRefetch && !cancelled) {\n context.client.setQueryData<TData>(context.queryKey, result)\n }\n\n const data = context.client.getQueryData<TData>(context.queryKey)\n return data === undefined ? initialValue : data\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmEA,SAAgB,cAId,EACA,UACA,cAAc,SACd,WAAW,OAAO,UAChB,SAAS,OAA8B,KAAK,GAC9C,eAAe,CAAC,KAIhB;CACA,OAAO,OAAO,YAAY;EACxB,MAAM,QAAQ,QAAQ,OACnB,cAAc,CAAC,CACf,KAAK;GAAE,UAAU,QAAQ;GAAU,OAAO;EAAK,CAAC;EACnD,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,UAAU;EAC7C,IAAI,aAAa,gBAAgB,SAC/B,MAAM,SAAS;GACb,GAAG,MAAM;GACT,aAAa;EACf,CAAC;EAGH,IAAI,SAAS;EAGb,IAAI,YAAqB;EAezB,MAAM,SAAS,MAAM,SAdG,sBAGtB;GACE,QAAQ,QAAQ;GAChB,MAAM,QAAQ;GACd,UAAU,QAAQ;GAClB,WAAW,QAAQ;GACnB,WAAW,QAAQ;EACrB,SACM,QAAQ,cACP,YAAY,IAGuB,CAAC;EAE7C,MAAM,mBAAmB,aAAa,gBAAgB;EAEtD,WAAW,MAAM,SAAS,QAAQ;GAChC,IAAI,WACF;GAGF,IAAI,kBAEF,SAAS,QAAQ,QAAQ,KAAK;QAE9B,QAAQ,OAAO,aAAoB,QAAQ,WAAW,SACpD,QAAQ,SAAS,KAAA,IAAY,eAAe,MAAM,KAAK,CACzD;EAEJ;EAGA,IAAI,oBAAoB,CAAC,WACvB,QAAQ,OAAO,aAAoB,QAAQ,UAAU,MAAM;EAG7D,MAAM,OAAO,QAAQ,OAAO,aAAoB,QAAQ,QAAQ;EAChE,OAAO,SAAS,KAAA,IAAY,eAAe;CAC7C;AACF"}
@@ -0,0 +1,34 @@
1
+ //#region src/subscribable.d.ts
2
+ /**
3
+ * The base class behind everything in Query that you can subscribe to: `QueryCache`, `MutationCache`,
4
+ * the observers, and the `FocusManager`/`OnlineManager` behind `focusManager` and `onlineManager`.
5
+ * Subclasses decide what a listener receives and when it is called.
6
+ */
7
+ declare class Subscribable<TListener extends Function> {
8
+ protected listeners: Set<TListener>;
9
+ constructor();
10
+ /**
11
+ * Registers a listener to be called on every update this object notifies about. Returns a function
12
+ * that removes the listener again — call it to stop listening. The base class never drops a listener
13
+ * on its own, though some subclasses clear all of theirs in `destroy()`.
14
+ * @param listener - Called on each update, with whatever the subclass passes to its subscribers.
15
+ * @example
16
+ * ```ts
17
+ * const unsubscribe = subscribable.subscribe(() => {
18
+ * // react to the update
19
+ * })
20
+ *
21
+ * unsubscribe()
22
+ * ```
23
+ */
24
+ subscribe(listener: TListener): () => void;
25
+ /**
26
+ * Returns `true` while at least one listener is registered, `false` once they have all unsubscribed.
27
+ */
28
+ hasListeners(): boolean;
29
+ protected onSubscribe(): void;
30
+ protected onUnsubscribe(): void;
31
+ }
32
+ //#endregion
33
+ export { Subscribable as t };
34
+ //# sourceMappingURL=subscribable-CysQ0tne.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscribable-CysQ0tne.d.cts","names":[],"sources":["../../src/subscribable.ts"],"mappings":";;;;;;cAKa,aAAa,kBAAkB;YAChC,WAAS,IAAA;;;;;;;;;;;;;;;;EAoBnB,UAAU,UAAU;;;;EAcpB;YAIU;YAIA"}
@@ -0,0 +1,34 @@
1
+ //#region src/subscribable.d.ts
2
+ /**
3
+ * The base class behind everything in Query that you can subscribe to: `QueryCache`, `MutationCache`,
4
+ * the observers, and the `FocusManager`/`OnlineManager` behind `focusManager` and `onlineManager`.
5
+ * Subclasses decide what a listener receives and when it is called.
6
+ */
7
+ declare class Subscribable<TListener extends Function> {
8
+ protected listeners: Set<TListener>;
9
+ constructor();
10
+ /**
11
+ * Registers a listener to be called on every update this object notifies about. Returns a function
12
+ * that removes the listener again — call it to stop listening. The base class never drops a listener
13
+ * on its own, though some subclasses clear all of theirs in `destroy()`.
14
+ * @param listener - Called on each update, with whatever the subclass passes to its subscribers.
15
+ * @example
16
+ * ```ts
17
+ * const unsubscribe = subscribable.subscribe(() => {
18
+ * // react to the update
19
+ * })
20
+ *
21
+ * unsubscribe()
22
+ * ```
23
+ */
24
+ subscribe(listener: TListener): () => void;
25
+ /**
26
+ * Returns `true` while at least one listener is registered, `false` once they have all unsubscribed.
27
+ */
28
+ hasListeners(): boolean;
29
+ protected onSubscribe(): void;
30
+ protected onUnsubscribe(): void;
31
+ }
32
+ //#endregion
33
+ export { Subscribable as t };
34
+ //# sourceMappingURL=subscribable-CysQ0tne.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscribable-CysQ0tne.d.ts","names":[],"sources":["../../src/subscribable.ts"],"mappings":";;;;;;cAKa,aAAa,kBAAkB;YAChC,WAAS,IAAA;;;;;;;;;;;;;;;;EAoBnB,UAAU,UAAU;;;;EAcpB;YAIU;YAIA"}
@@ -1,10 +1,29 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/subscribable.ts
3
+ /**
4
+ * The base class behind everything in Query that you can subscribe to: `QueryCache`, `MutationCache`,
5
+ * the observers, and the `FocusManager`/`OnlineManager` behind `focusManager` and `onlineManager`.
6
+ * Subclasses decide what a listener receives and when it is called.
7
+ */
3
8
  var Subscribable = class {
4
9
  constructor() {
5
10
  this.listeners = /* @__PURE__ */ new Set();
6
11
  this.subscribe = this.subscribe.bind(this);
7
12
  }
13
+ /**
14
+ * Registers a listener to be called on every update this object notifies about. Returns a function
15
+ * that removes the listener again — call it to stop listening. The base class never drops a listener
16
+ * on its own, though some subclasses clear all of theirs in `destroy()`.
17
+ * @param listener - Called on each update, with whatever the subclass passes to its subscribers.
18
+ * @example
19
+ * ```ts
20
+ * const unsubscribe = subscribable.subscribe(() => {
21
+ * // react to the update
22
+ * })
23
+ *
24
+ * unsubscribe()
25
+ * ```
26
+ */
8
27
  subscribe(listener) {
9
28
  this.listeners.add(listener);
10
29
  this.onSubscribe();
@@ -13,6 +32,9 @@ var Subscribable = class {
13
32
  this.onUnsubscribe();
14
33
  };
15
34
  }
35
+ /**
36
+ * Returns `true` while at least one listener is registered, `false` once they have all unsubscribed.
37
+ */
16
38
  hasListeners() {
17
39
  return this.listeners.size > 0;
18
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"subscribable.cjs","names":[],"sources":["../../src/subscribable.ts"],"sourcesContent":["export class Subscribable<TListener extends Function> {\n protected listeners = new Set<TListener>()\n\n constructor() {\n this.subscribe = this.subscribe.bind(this)\n }\n\n subscribe(listener: TListener): () => void {\n this.listeners.add(listener)\n\n this.onSubscribe()\n\n return () => {\n this.listeners.delete(listener)\n this.onUnsubscribe()\n }\n }\n\n hasListeners(): boolean {\n return this.listeners.size > 0\n }\n\n protected onSubscribe(): void {\n // Do nothing\n }\n\n protected onUnsubscribe(): void {\n // Do nothing\n }\n}\n"],"mappings":";;AAAA,IAAa,eAAb,MAAsD;CAGpD,cAAc;EAFd,KAAU,4BAAY,IAAI,IAAe;EAGvC,KAAK,YAAY,KAAK,UAAU,KAAK,IAAI;CAC3C;CAEA,UAAU,UAAiC;EACzC,KAAK,UAAU,IAAI,QAAQ;EAE3B,KAAK,YAAY;EAEjB,aAAa;GACX,KAAK,UAAU,OAAO,QAAQ;GAC9B,KAAK,cAAc;EACrB;CACF;CAEA,eAAwB;EACtB,OAAO,KAAK,UAAU,OAAO;CAC/B;CAEA,cAA8B,CAE9B;CAEA,gBAAgC,CAEhC;AACF"}
1
+ {"version":3,"file":"subscribable.cjs","names":[],"sources":["../../src/subscribable.ts"],"sourcesContent":["/**\n * The base class behind everything in Query that you can subscribe to: `QueryCache`, `MutationCache`,\n * the observers, and the `FocusManager`/`OnlineManager` behind `focusManager` and `onlineManager`.\n * Subclasses decide what a listener receives and when it is called.\n */\nexport class Subscribable<TListener extends Function> {\n protected listeners = new Set<TListener>()\n\n constructor() {\n this.subscribe = this.subscribe.bind(this)\n }\n\n /**\n * Registers a listener to be called on every update this object notifies about. Returns a function\n * that removes the listener again — call it to stop listening. The base class never drops a listener\n * on its own, though some subclasses clear all of theirs in `destroy()`.\n * @param listener - Called on each update, with whatever the subclass passes to its subscribers.\n * @example\n * ```ts\n * const unsubscribe = subscribable.subscribe(() => {\n * // react to the update\n * })\n *\n * unsubscribe()\n * ```\n */\n subscribe(listener: TListener): () => void {\n this.listeners.add(listener)\n\n this.onSubscribe()\n\n return () => {\n this.listeners.delete(listener)\n this.onUnsubscribe()\n }\n }\n\n /**\n * Returns `true` while at least one listener is registered, `false` once they have all unsubscribed.\n */\n hasListeners(): boolean {\n return this.listeners.size > 0\n }\n\n protected onSubscribe(): void {\n // Do nothing\n }\n\n protected onUnsubscribe(): void {\n // Do nothing\n }\n}\n"],"mappings":";;;;;;;AAKA,IAAa,eAAb,MAAsD;CAGpD,cAAc;EAFd,KAAU,4BAAY,IAAI,IAAe;EAGvC,KAAK,YAAY,KAAK,UAAU,KAAK,IAAI;CAC3C;;;;;;;;;;;;;;;CAgBA,UAAU,UAAiC;EACzC,KAAK,UAAU,IAAI,QAAQ;EAE3B,KAAK,YAAY;EAEjB,aAAa;GACX,KAAK,UAAU,OAAO,QAAQ;GAC9B,KAAK,cAAc;EACrB;CACF;;;;CAKA,eAAwB;EACtB,OAAO,KAAK,UAAU,OAAO;CAC/B;CAEA,cAA8B,CAE9B;CAEA,gBAAgC,CAEhC;AACF"}
@@ -1,2 +1,2 @@
1
- import { t as Subscribable } from "./subscribable-CbifVTKz.cjs";
1
+ import { t as Subscribable } from "./subscribable-CysQ0tne.cjs";
2
2
  export { Subscribable };
@@ -1,2 +1,2 @@
1
- import { t as Subscribable } from "./subscribable-CbifVTKz.js";
1
+ import { t as Subscribable } from "./subscribable-CysQ0tne.js";
2
2
  export { Subscribable };
@@ -1,9 +1,28 @@
1
1
  //#region src/subscribable.ts
2
+ /**
3
+ * The base class behind everything in Query that you can subscribe to: `QueryCache`, `MutationCache`,
4
+ * the observers, and the `FocusManager`/`OnlineManager` behind `focusManager` and `onlineManager`.
5
+ * Subclasses decide what a listener receives and when it is called.
6
+ */
2
7
  var Subscribable = class {
3
8
  constructor() {
4
9
  this.listeners = /* @__PURE__ */ new Set();
5
10
  this.subscribe = this.subscribe.bind(this);
6
11
  }
12
+ /**
13
+ * Registers a listener to be called on every update this object notifies about. Returns a function
14
+ * that removes the listener again — call it to stop listening. The base class never drops a listener
15
+ * on its own, though some subclasses clear all of theirs in `destroy()`.
16
+ * @param listener - Called on each update, with whatever the subclass passes to its subscribers.
17
+ * @example
18
+ * ```ts
19
+ * const unsubscribe = subscribable.subscribe(() => {
20
+ * // react to the update
21
+ * })
22
+ *
23
+ * unsubscribe()
24
+ * ```
25
+ */
7
26
  subscribe(listener) {
8
27
  this.listeners.add(listener);
9
28
  this.onSubscribe();
@@ -12,6 +31,9 @@ var Subscribable = class {
12
31
  this.onUnsubscribe();
13
32
  };
14
33
  }
34
+ /**
35
+ * Returns `true` while at least one listener is registered, `false` once they have all unsubscribed.
36
+ */
15
37
  hasListeners() {
16
38
  return this.listeners.size > 0;
17
39
  }
@@ -1 +1 @@
1
- {"version":3,"file":"subscribable.js","names":[],"sources":["../../src/subscribable.ts"],"sourcesContent":["export class Subscribable<TListener extends Function> {\n protected listeners = new Set<TListener>()\n\n constructor() {\n this.subscribe = this.subscribe.bind(this)\n }\n\n subscribe(listener: TListener): () => void {\n this.listeners.add(listener)\n\n this.onSubscribe()\n\n return () => {\n this.listeners.delete(listener)\n this.onUnsubscribe()\n }\n }\n\n hasListeners(): boolean {\n return this.listeners.size > 0\n }\n\n protected onSubscribe(): void {\n // Do nothing\n }\n\n protected onUnsubscribe(): void {\n // Do nothing\n }\n}\n"],"mappings":";AAAA,IAAa,eAAb,MAAsD;CAGpD,cAAc;EAFd,KAAU,4BAAY,IAAI,IAAe;EAGvC,KAAK,YAAY,KAAK,UAAU,KAAK,IAAI;CAC3C;CAEA,UAAU,UAAiC;EACzC,KAAK,UAAU,IAAI,QAAQ;EAE3B,KAAK,YAAY;EAEjB,aAAa;GACX,KAAK,UAAU,OAAO,QAAQ;GAC9B,KAAK,cAAc;EACrB;CACF;CAEA,eAAwB;EACtB,OAAO,KAAK,UAAU,OAAO;CAC/B;CAEA,cAA8B,CAE9B;CAEA,gBAAgC,CAEhC;AACF"}
1
+ {"version":3,"file":"subscribable.js","names":[],"sources":["../../src/subscribable.ts"],"sourcesContent":["/**\n * The base class behind everything in Query that you can subscribe to: `QueryCache`, `MutationCache`,\n * the observers, and the `FocusManager`/`OnlineManager` behind `focusManager` and `onlineManager`.\n * Subclasses decide what a listener receives and when it is called.\n */\nexport class Subscribable<TListener extends Function> {\n protected listeners = new Set<TListener>()\n\n constructor() {\n this.subscribe = this.subscribe.bind(this)\n }\n\n /**\n * Registers a listener to be called on every update this object notifies about. Returns a function\n * that removes the listener again — call it to stop listening. The base class never drops a listener\n * on its own, though some subclasses clear all of theirs in `destroy()`.\n * @param listener - Called on each update, with whatever the subclass passes to its subscribers.\n * @example\n * ```ts\n * const unsubscribe = subscribable.subscribe(() => {\n * // react to the update\n * })\n *\n * unsubscribe()\n * ```\n */\n subscribe(listener: TListener): () => void {\n this.listeners.add(listener)\n\n this.onSubscribe()\n\n return () => {\n this.listeners.delete(listener)\n this.onUnsubscribe()\n }\n }\n\n /**\n * Returns `true` while at least one listener is registered, `false` once they have all unsubscribed.\n */\n hasListeners(): boolean {\n return this.listeners.size > 0\n }\n\n protected onSubscribe(): void {\n // Do nothing\n }\n\n protected onUnsubscribe(): void {\n // Do nothing\n }\n}\n"],"mappings":";;;;;;AAKA,IAAa,eAAb,MAAsD;CAGpD,cAAc;EAFd,KAAU,4BAAY,IAAI,IAAe;EAGvC,KAAK,YAAY,KAAK,UAAU,KAAK,IAAI;CAC3C;;;;;;;;;;;;;;;CAgBA,UAAU,UAAiC;EACzC,KAAK,UAAU,IAAI,QAAQ;EAE3B,KAAK,YAAY;EAEjB,aAAa;GACX,KAAK,UAAU,OAAO,QAAQ;GAC9B,KAAK,cAAc;EACrB;CACF;;;;CAKA,eAAwB;EACtB,OAAO,KAAK,UAAU,OAAO;CAC/B;CAEA,cAA8B,CAE9B;CAEA,gBAAgC,CAEhC;AACF"}
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_classPrivateFieldSet2 = require("./classPrivateFieldSet2-Bo0ZyOIv.cjs");
2
+ const require_classPrivateFieldSet2 = require("./classPrivateFieldSet2-CvCEk6bM.cjs");
3
3
  //#region src/timeoutManager.ts
4
4
  const defaultTimeoutProvider = {
5
5
  setTimeout: (callback, delay) => setTimeout(callback, delay),
@@ -7,14 +7,14 @@
7
7
  * If we don't accept a single void argument, then
8
8
  * `new Promise(resolve => timeoutManager.setTimeout(resolve, N))` is a type error.
9
9
  */
10
- type TimeoutCallback = (_: void) => void;
10
+ export type TimeoutCallback = (_: void) => void;
11
11
  /**
12
12
  * Wrapping `setTimeout` is awkward from a typing perspective because platform
13
13
  * typings may extend the return type of `setTimeout`. For example, NodeJS
14
14
  * typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be
15
15
  * able to return such a type.
16
16
  */
17
- type ManagedTimerId = number | {
17
+ export type ManagedTimerId = number | {
18
18
  [Symbol.toPrimitive]: () => number;
19
19
  };
20
20
  /**
@@ -26,13 +26,13 @@ type ManagedTimerId = number | {
26
26
  * `setTimeout`/`setInterval`) does not do. A custom provider can implement coalescing, and can
27
27
  * also support delays longer than the ~24-day maximum of the global `setTimeout`.
28
28
  */
29
- type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> = {
29
+ export type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> = {
30
30
  readonly setTimeout: (callback: TimeoutCallback, delay: number) => TTimerId;
31
31
  readonly clearTimeout: (timeoutId: TTimerId | undefined) => void;
32
32
  readonly setInterval: (callback: TimeoutCallback, delay: number) => TTimerId;
33
33
  readonly clearInterval: (intervalId: TTimerId | undefined) => void;
34
34
  };
35
- declare const defaultTimeoutProvider: TimeoutProvider;
35
+ export declare const defaultTimeoutProvider: TimeoutProvider;
36
36
  /**
37
37
  * Allows customization of how timeouts are created.
38
38
  *
@@ -44,7 +44,7 @@ declare const defaultTimeoutProvider: TimeoutProvider;
44
44
  * If you hit this limitation, consider providing a custom TimeoutProvider that
45
45
  * coalesces timeouts.
46
46
  */
47
- declare class TimeoutManager implements Omit<TimeoutProvider, 'name'> {
47
+ export declare class TimeoutManager implements Omit<TimeoutProvider, 'name'> {
48
48
  #private;
49
49
  /**
50
50
  * `setTimeoutProvider` can be used to set a custom implementation of the
@@ -151,7 +151,7 @@ declare class TimeoutManager implements Omit<TimeoutProvider, 'name'> {
151
151
  /**
152
152
  * Singleton instance of {@link TimeoutManager}, used throughout TanStack Query to schedule and cancel timers.
153
153
  */
154
- declare const timeoutManager: TimeoutManager;
154
+ export declare const timeoutManager: TimeoutManager;
155
155
  /**
156
156
  * In many cases code wants to delay to the next event loop tick; this is not
157
157
  * mediated by {@link timeoutManager}.
@@ -159,7 +159,6 @@ declare const timeoutManager: TimeoutManager;
159
159
  * This function is provided to make auditing the `tanstack/query-core` for
160
160
  * incorrect use of system `setTimeout` easier.
161
161
  */
162
- declare function systemSetTimeoutZero(callback: TimeoutCallback): void;
162
+ export declare function systemSetTimeoutZero(callback: TimeoutCallback): void;
163
163
  //#endregion
164
- export { ManagedTimerId, TimeoutCallback, TimeoutManager, TimeoutProvider, defaultTimeoutProvider, systemSetTimeoutZero, timeoutManager };
165
164
  //# sourceMappingURL=timeoutManager.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"timeoutManager.d.cts","names":[],"sources":["../../src/timeoutManager.ts"],"mappings":";;;;;;;;;KAQY,mBAAmB;;;;;;;KAQnB;GAA6B,OAAO;;;;;;;;;;;KAWpC,gBAAgB,iBAAiB,iBAAiB;WAEjD,aAAa,UAAU,iBAAiB,kBAAkB;WAC1D,eAAe,WAAW;WAE1B,cAAc,UAAU,iBAAiB,kBAAkB;WAC3D,gBAAgB,YAAY;;cAK5B,wBAAwB;;;;;;;;;;;;cA+BxB,0BAA0B,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoC1C,mBAAmB,iBAAiB,gBAClC,UAAU,gBAAgB;;;;;;;;;;;;;;;;;;;;;EAgD5B,WAAW,UAAU,iBAAiB,gBAAgB;;;;;;;;;;;;;;;;;;EAwBtD,aAAa,WAAW;;;;;;;;;;;;;;;;;;EAqBxB,YAAY,UAAU,iBAAiB,gBAAgB;;;;;;;;;;;;;;;;;;EAwBvD,cAAc,YAAY;;;;;cAQf,gBAAc;;;;;;;;iBASX,qBAAqB,UAAU"}
1
+ {"version":3,"file":"timeoutManager.d.cts","names":[],"sources":["../../src/timeoutManager.ts"],"mappings":";;;;;;;;;YAQY,mBAAmB;;;;;;;YAQnB;GAA6B,OAAO;;;;;;;;;;;YAWpC,gBAAgB,iBAAiB,iBAAiB;WAEjD,aAAa,UAAU,iBAAiB,kBAAkB;WAC1D,eAAe,WAAW;WAE1B,cAAc,UAAU,iBAAiB,kBAAkB;WAC3D,gBAAgB,YAAY;;qBAK5B,wBAAwB;;;;;;;;;;;;qBA+BxB,0BAA0B,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoC1C,mBAAmB,iBAAiB,gBAClC,UAAU,gBAAgB;;;;;;;;;;;;;;;;;;;;;EAgD5B,WAAW,UAAU,iBAAiB,gBAAgB;;;;;;;;;;;;;;;;;;EAwBtD,aAAa,WAAW;;;;;;;;;;;;;;;;;;EAqBxB,YAAY,UAAU,iBAAiB,gBAAgB;;;;;;;;;;;;;;;;;;EAwBvD,cAAc,YAAY;;;;;qBAQf,gBAAc;;;;;;;;wBASX,qBAAqB,UAAU"}
@@ -7,14 +7,14 @@
7
7
  * If we don't accept a single void argument, then
8
8
  * `new Promise(resolve => timeoutManager.setTimeout(resolve, N))` is a type error.
9
9
  */
10
- type TimeoutCallback = (_: void) => void;
10
+ export type TimeoutCallback = (_: void) => void;
11
11
  /**
12
12
  * Wrapping `setTimeout` is awkward from a typing perspective because platform
13
13
  * typings may extend the return type of `setTimeout`. For example, NodeJS
14
14
  * typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be
15
15
  * able to return such a type.
16
16
  */
17
- type ManagedTimerId = number | {
17
+ export type ManagedTimerId = number | {
18
18
  [Symbol.toPrimitive]: () => number;
19
19
  };
20
20
  /**
@@ -26,13 +26,13 @@ type ManagedTimerId = number | {
26
26
  * `setTimeout`/`setInterval`) does not do. A custom provider can implement coalescing, and can
27
27
  * also support delays longer than the ~24-day maximum of the global `setTimeout`.
28
28
  */
29
- type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> = {
29
+ export type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> = {
30
30
  readonly setTimeout: (callback: TimeoutCallback, delay: number) => TTimerId;
31
31
  readonly clearTimeout: (timeoutId: TTimerId | undefined) => void;
32
32
  readonly setInterval: (callback: TimeoutCallback, delay: number) => TTimerId;
33
33
  readonly clearInterval: (intervalId: TTimerId | undefined) => void;
34
34
  };
35
- declare const defaultTimeoutProvider: TimeoutProvider;
35
+ export declare const defaultTimeoutProvider: TimeoutProvider;
36
36
  /**
37
37
  * Allows customization of how timeouts are created.
38
38
  *
@@ -44,7 +44,7 @@ declare const defaultTimeoutProvider: TimeoutProvider;
44
44
  * If you hit this limitation, consider providing a custom TimeoutProvider that
45
45
  * coalesces timeouts.
46
46
  */
47
- declare class TimeoutManager implements Omit<TimeoutProvider, 'name'> {
47
+ export declare class TimeoutManager implements Omit<TimeoutProvider, 'name'> {
48
48
  #private;
49
49
  /**
50
50
  * `setTimeoutProvider` can be used to set a custom implementation of the
@@ -151,7 +151,7 @@ declare class TimeoutManager implements Omit<TimeoutProvider, 'name'> {
151
151
  /**
152
152
  * Singleton instance of {@link TimeoutManager}, used throughout TanStack Query to schedule and cancel timers.
153
153
  */
154
- declare const timeoutManager: TimeoutManager;
154
+ export declare const timeoutManager: TimeoutManager;
155
155
  /**
156
156
  * In many cases code wants to delay to the next event loop tick; this is not
157
157
  * mediated by {@link timeoutManager}.
@@ -159,7 +159,6 @@ declare const timeoutManager: TimeoutManager;
159
159
  * This function is provided to make auditing the `tanstack/query-core` for
160
160
  * incorrect use of system `setTimeout` easier.
161
161
  */
162
- declare function systemSetTimeoutZero(callback: TimeoutCallback): void;
162
+ export declare function systemSetTimeoutZero(callback: TimeoutCallback): void;
163
163
  //#endregion
164
- export { ManagedTimerId, TimeoutCallback, TimeoutManager, TimeoutProvider, defaultTimeoutProvider, systemSetTimeoutZero, timeoutManager };
165
164
  //# sourceMappingURL=timeoutManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"timeoutManager.d.ts","names":[],"sources":["../../src/timeoutManager.ts"],"mappings":";;;;;;;;;KAQY,mBAAmB;;;;;;;KAQnB;GAA6B,OAAO;;;;;;;;;;;KAWpC,gBAAgB,iBAAiB,iBAAiB;WAEjD,aAAa,UAAU,iBAAiB,kBAAkB;WAC1D,eAAe,WAAW;WAE1B,cAAc,UAAU,iBAAiB,kBAAkB;WAC3D,gBAAgB,YAAY;;cAK5B,wBAAwB;;;;;;;;;;;;cA+BxB,0BAA0B,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoC1C,mBAAmB,iBAAiB,gBAClC,UAAU,gBAAgB;;;;;;;;;;;;;;;;;;;;;EAgD5B,WAAW,UAAU,iBAAiB,gBAAgB;;;;;;;;;;;;;;;;;;EAwBtD,aAAa,WAAW;;;;;;;;;;;;;;;;;;EAqBxB,YAAY,UAAU,iBAAiB,gBAAgB;;;;;;;;;;;;;;;;;;EAwBvD,cAAc,YAAY;;;;;cAQf,gBAAc;;;;;;;;iBASX,qBAAqB,UAAU"}
1
+ {"version":3,"file":"timeoutManager.d.ts","names":[],"sources":["../../src/timeoutManager.ts"],"mappings":";;;;;;;;;YAQY,mBAAmB;;;;;;;YAQnB;GAA6B,OAAO;;;;;;;;;;;YAWpC,gBAAgB,iBAAiB,iBAAiB;WAEjD,aAAa,UAAU,iBAAiB,kBAAkB;WAC1D,eAAe,WAAW;WAE1B,cAAc,UAAU,iBAAiB,kBAAkB;WAC3D,gBAAgB,YAAY;;qBAK5B,wBAAwB;;;;;;;;;;;;qBA+BxB,0BAA0B,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoC1C,mBAAmB,iBAAiB,gBAClC,UAAU,gBAAgB;;;;;;;;;;;;;;;;;;;;;EAgD5B,WAAW,UAAU,iBAAiB,gBAAgB;;;;;;;;;;;;;;;;;;EAwBtD,aAAa,WAAW;;;;;;;;;;;;;;;;;;EAqBxB,YAAY,UAAU,iBAAiB,gBAAgB;;;;;;;;;;;;;;;;;;EAwBvD,cAAc,YAAY;;;;;qBAQf,gBAAc;;;;;;;;wBASX,qBAAqB,UAAU"}
@@ -1,4 +1,4 @@
1
- import { i as _classPrivateFieldInitSpec, n as _classPrivateFieldGet2, t as _classPrivateFieldSet2 } from "./classPrivateFieldSet2-CV7wyte-.js";
1
+ import { i as _classPrivateFieldInitSpec, n as _classPrivateFieldGet2, t as _classPrivateFieldSet2 } from "./classPrivateFieldSet2-CukOTU3U.js";
2
2
  //#region src/timeoutManager.ts
3
3
  const defaultTimeoutProvider = {
4
4
  setTimeout: (callback, delay) => setTimeout(callback, delay),