@tanstack/query-core 5.90.19 → 5.91.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 (199) hide show
  1. package/build/legacy/_tsup-dts-rollup.d.cts +2227 -0
  2. package/build/legacy/_tsup-dts-rollup.d.ts +2227 -0
  3. package/build/legacy/environmentManager.cjs +48 -0
  4. package/build/legacy/environmentManager.cjs.map +1 -0
  5. package/build/legacy/environmentManager.d.cts +2 -0
  6. package/build/legacy/environmentManager.d.ts +2 -0
  7. package/build/legacy/environmentManager.js +25 -0
  8. package/build/legacy/environmentManager.js.map +1 -0
  9. package/build/legacy/focusManager.cjs +1 -2
  10. package/build/legacy/focusManager.cjs.map +1 -1
  11. package/build/legacy/focusManager.d.cts +2 -17
  12. package/build/legacy/focusManager.d.ts +2 -17
  13. package/build/legacy/focusManager.js +1 -2
  14. package/build/legacy/focusManager.js.map +1 -1
  15. package/build/legacy/hydration.d.cts +7 -3
  16. package/build/legacy/hydration.d.ts +7 -3
  17. package/build/legacy/index.cjs +3 -0
  18. package/build/legacy/index.cjs.map +1 -1
  19. package/build/legacy/index.d.cts +142 -10
  20. package/build/legacy/index.d.ts +142 -10
  21. package/build/legacy/index.js +2 -0
  22. package/build/legacy/index.js.map +1 -1
  23. package/build/legacy/infiniteQueryBehavior.d.cts +3 -15
  24. package/build/legacy/infiniteQueryBehavior.d.ts +3 -15
  25. package/build/legacy/infiniteQueryObserver.d.cts +1 -20
  26. package/build/legacy/infiniteQueryObserver.d.ts +1 -20
  27. package/build/legacy/mutation.cjs +25 -24
  28. package/build/legacy/mutation.cjs.map +1 -1
  29. package/build/legacy/mutation.d.cts +4 -3
  30. package/build/legacy/mutation.d.ts +4 -3
  31. package/build/legacy/mutation.js +25 -24
  32. package/build/legacy/mutation.js.map +1 -1
  33. package/build/legacy/mutationCache.d.cts +2 -3
  34. package/build/legacy/mutationCache.d.ts +2 -3
  35. package/build/legacy/mutationObserver.d.cts +1 -3
  36. package/build/legacy/mutationObserver.d.ts +1 -3
  37. package/build/legacy/notifyManager.d.cts +3 -46
  38. package/build/legacy/notifyManager.d.ts +3 -46
  39. package/build/legacy/onlineManager.cjs +1 -2
  40. package/build/legacy/onlineManager.cjs.map +1 -1
  41. package/build/legacy/onlineManager.d.cts +2 -16
  42. package/build/legacy/onlineManager.d.ts +2 -16
  43. package/build/legacy/onlineManager.js +1 -2
  44. package/build/legacy/onlineManager.js.map +1 -1
  45. package/build/legacy/queriesObserver.d.cts +2 -27
  46. package/build/legacy/queriesObserver.d.ts +2 -27
  47. package/build/legacy/query.d.cts +10 -3
  48. package/build/legacy/query.d.ts +10 -3
  49. package/build/legacy/queryCache.d.cts +3 -3
  50. package/build/legacy/queryCache.d.ts +3 -3
  51. package/build/legacy/queryClient.d.cts +1 -3
  52. package/build/legacy/queryClient.d.ts +1 -3
  53. package/build/legacy/queryObserver.cjs +3 -2
  54. package/build/legacy/queryObserver.cjs.map +1 -1
  55. package/build/legacy/queryObserver.d.cts +1 -3
  56. package/build/legacy/queryObserver.d.ts +1 -3
  57. package/build/legacy/queryObserver.js +3 -3
  58. package/build/legacy/queryObserver.js.map +1 -1
  59. package/build/legacy/removable.cjs +2 -1
  60. package/build/legacy/removable.cjs.map +1 -1
  61. package/build/legacy/removable.d.cts +1 -11
  62. package/build/legacy/removable.d.ts +1 -11
  63. package/build/legacy/removable.js +3 -2
  64. package/build/legacy/removable.js.map +1 -1
  65. package/build/legacy/retryer.cjs +2 -1
  66. package/build/legacy/retryer.cjs.map +1 -1
  67. package/build/legacy/retryer.d.cts +7 -3
  68. package/build/legacy/retryer.d.ts +7 -3
  69. package/build/legacy/retryer.js +3 -2
  70. package/build/legacy/retryer.js.map +1 -1
  71. package/build/legacy/streamedQuery.d.cts +1 -34
  72. package/build/legacy/streamedQuery.d.ts +1 -34
  73. package/build/legacy/subscribable.d.cts +1 -10
  74. package/build/legacy/subscribable.d.ts +1 -10
  75. package/build/legacy/thenable.cjs.map +1 -1
  76. package/build/legacy/thenable.d.cts +6 -47
  77. package/build/legacy/thenable.d.ts +6 -47
  78. package/build/legacy/thenable.js.map +1 -1
  79. package/build/legacy/timeoutManager.d.cts +7 -58
  80. package/build/legacy/timeoutManager.d.ts +7 -58
  81. package/build/legacy/types.cjs +3 -3
  82. package/build/legacy/types.cjs.map +1 -1
  83. package/build/legacy/types.d.cts +95 -3
  84. package/build/legacy/types.d.ts +95 -3
  85. package/build/legacy/types.js +3 -3
  86. package/build/legacy/types.js.map +1 -1
  87. package/build/legacy/utils.cjs +1 -1
  88. package/build/legacy/utils.cjs.map +1 -1
  89. package/build/legacy/utils.d.cts +30 -3
  90. package/build/legacy/utils.d.ts +30 -3
  91. package/build/legacy/utils.js +1 -1
  92. package/build/legacy/utils.js.map +1 -1
  93. package/build/modern/_tsup-dts-rollup.d.cts +2227 -0
  94. package/build/modern/_tsup-dts-rollup.d.ts +2227 -0
  95. package/build/modern/environmentManager.cjs +48 -0
  96. package/build/modern/environmentManager.cjs.map +1 -0
  97. package/build/modern/environmentManager.d.cts +2 -0
  98. package/build/modern/environmentManager.d.ts +2 -0
  99. package/build/modern/environmentManager.js +23 -0
  100. package/build/modern/environmentManager.js.map +1 -0
  101. package/build/modern/focusManager.cjs +1 -2
  102. package/build/modern/focusManager.cjs.map +1 -1
  103. package/build/modern/focusManager.d.cts +2 -17
  104. package/build/modern/focusManager.d.ts +2 -17
  105. package/build/modern/focusManager.js +1 -2
  106. package/build/modern/focusManager.js.map +1 -1
  107. package/build/modern/hydration.d.cts +7 -3
  108. package/build/modern/hydration.d.ts +7 -3
  109. package/build/modern/index.cjs +3 -0
  110. package/build/modern/index.cjs.map +1 -1
  111. package/build/modern/index.d.cts +142 -10
  112. package/build/modern/index.d.ts +142 -10
  113. package/build/modern/index.js +2 -0
  114. package/build/modern/index.js.map +1 -1
  115. package/build/modern/infiniteQueryBehavior.d.cts +3 -15
  116. package/build/modern/infiniteQueryBehavior.d.ts +3 -15
  117. package/build/modern/infiniteQueryObserver.d.cts +1 -20
  118. package/build/modern/infiniteQueryObserver.d.ts +1 -20
  119. package/build/modern/mutation.cjs +7 -5
  120. package/build/modern/mutation.cjs.map +1 -1
  121. package/build/modern/mutation.d.cts +4 -3
  122. package/build/modern/mutation.d.ts +4 -3
  123. package/build/modern/mutation.js +7 -5
  124. package/build/modern/mutation.js.map +1 -1
  125. package/build/modern/mutationCache.d.cts +2 -3
  126. package/build/modern/mutationCache.d.ts +2 -3
  127. package/build/modern/mutationObserver.d.cts +1 -3
  128. package/build/modern/mutationObserver.d.ts +1 -3
  129. package/build/modern/notifyManager.d.cts +3 -46
  130. package/build/modern/notifyManager.d.ts +3 -46
  131. package/build/modern/onlineManager.cjs +1 -2
  132. package/build/modern/onlineManager.cjs.map +1 -1
  133. package/build/modern/onlineManager.d.cts +2 -16
  134. package/build/modern/onlineManager.d.ts +2 -16
  135. package/build/modern/onlineManager.js +1 -2
  136. package/build/modern/onlineManager.js.map +1 -1
  137. package/build/modern/queriesObserver.d.cts +2 -27
  138. package/build/modern/queriesObserver.d.ts +2 -27
  139. package/build/modern/query.d.cts +10 -3
  140. package/build/modern/query.d.ts +10 -3
  141. package/build/modern/queryCache.d.cts +3 -3
  142. package/build/modern/queryCache.d.ts +3 -3
  143. package/build/modern/queryClient.d.cts +1 -3
  144. package/build/modern/queryClient.d.ts +1 -3
  145. package/build/modern/queryObserver.cjs +3 -2
  146. package/build/modern/queryObserver.cjs.map +1 -1
  147. package/build/modern/queryObserver.d.cts +1 -3
  148. package/build/modern/queryObserver.d.ts +1 -3
  149. package/build/modern/queryObserver.js +3 -3
  150. package/build/modern/queryObserver.js.map +1 -1
  151. package/build/modern/removable.cjs +2 -1
  152. package/build/modern/removable.cjs.map +1 -1
  153. package/build/modern/removable.d.cts +1 -11
  154. package/build/modern/removable.d.ts +1 -11
  155. package/build/modern/removable.js +3 -2
  156. package/build/modern/removable.js.map +1 -1
  157. package/build/modern/retryer.cjs +2 -1
  158. package/build/modern/retryer.cjs.map +1 -1
  159. package/build/modern/retryer.d.cts +7 -3
  160. package/build/modern/retryer.d.ts +7 -3
  161. package/build/modern/retryer.js +3 -2
  162. package/build/modern/retryer.js.map +1 -1
  163. package/build/modern/streamedQuery.d.cts +1 -34
  164. package/build/modern/streamedQuery.d.ts +1 -34
  165. package/build/modern/subscribable.d.cts +1 -10
  166. package/build/modern/subscribable.d.ts +1 -10
  167. package/build/modern/thenable.cjs.map +1 -1
  168. package/build/modern/thenable.d.cts +6 -47
  169. package/build/modern/thenable.d.ts +6 -47
  170. package/build/modern/thenable.js.map +1 -1
  171. package/build/modern/timeoutManager.d.cts +7 -58
  172. package/build/modern/timeoutManager.d.ts +7 -58
  173. package/build/modern/types.cjs +3 -3
  174. package/build/modern/types.cjs.map +1 -1
  175. package/build/modern/types.d.cts +95 -3
  176. package/build/modern/types.d.ts +95 -3
  177. package/build/modern/types.js +3 -3
  178. package/build/modern/types.js.map +1 -1
  179. package/build/modern/utils.cjs +1 -1
  180. package/build/modern/utils.cjs.map +1 -1
  181. package/build/modern/utils.d.cts +30 -3
  182. package/build/modern/utils.d.ts +30 -3
  183. package/build/modern/utils.js +1 -1
  184. package/build/modern/utils.js.map +1 -1
  185. package/package.json +4 -5
  186. package/src/environmentManager.ts +25 -0
  187. package/src/focusManager.ts +1 -2
  188. package/src/index.ts +1 -0
  189. package/src/mutation.ts +7 -5
  190. package/src/onlineManager.ts +1 -2
  191. package/src/queryObserver.ts +7 -3
  192. package/src/removable.ts +3 -2
  193. package/src/retryer.ts +3 -2
  194. package/src/thenable.ts +1 -1
  195. package/src/utils.ts +3 -0
  196. package/build/legacy/hydration-BlEVG2Lp.d.ts +0 -1384
  197. package/build/legacy/hydration-uphG6M-i.d.cts +0 -1384
  198. package/build/modern/hydration-BlEVG2Lp.d.ts +0 -1384
  199. package/build/modern/hydration-uphG6M-i.d.cts +0 -1384
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/retryer.ts"],"sourcesContent":["import { focusManager } from './focusManager'\nimport { onlineManager } from './onlineManager'\nimport { pendingThenable } from './thenable'\nimport { isServer, sleep } from './utils'\nimport type { Thenable } from './thenable'\nimport type { CancelOptions, DefaultError, NetworkMode } from './types'\n\n// TYPES\n\ninterface RetryerConfig<TData = unknown, TError = DefaultError> {\n fn: () => TData | Promise<TData>\n initialPromise?: Promise<TData>\n onCancel?: (error: TError) => void\n onFail?: (failureCount: number, error: TError) => void\n onPause?: () => void\n onContinue?: () => void\n retry?: RetryValue<TError>\n retryDelay?: RetryDelayValue<TError>\n networkMode: NetworkMode | undefined\n canRun: () => boolean\n}\n\nexport interface Retryer<TData = unknown> {\n promise: Promise<TData>\n cancel: (cancelOptions?: CancelOptions) => void\n continue: () => Promise<unknown>\n cancelRetry: () => void\n continueRetry: () => void\n canStart: () => boolean\n start: () => Promise<TData>\n status: () => 'pending' | 'resolved' | 'rejected'\n}\n\nexport type RetryValue<TError> = boolean | number | ShouldRetryFunction<TError>\n\ntype ShouldRetryFunction<TError = DefaultError> = (\n failureCount: number,\n error: TError,\n) => boolean\n\nexport type RetryDelayValue<TError> = number | RetryDelayFunction<TError>\n\ntype RetryDelayFunction<TError = DefaultError> = (\n failureCount: number,\n error: TError,\n) => number\n\nfunction defaultRetryDelay(failureCount: number) {\n return Math.min(1000 * 2 ** failureCount, 30000)\n}\n\nexport function canFetch(networkMode: NetworkMode | undefined): boolean {\n return (networkMode ?? 'online') === 'online'\n ? onlineManager.isOnline()\n : true\n}\n\nexport class CancelledError extends Error {\n revert?: boolean\n silent?: boolean\n constructor(options?: CancelOptions) {\n super('CancelledError')\n this.revert = options?.revert\n this.silent = options?.silent\n }\n}\n\n/**\n * @deprecated Use instanceof `CancelledError` instead.\n */\nexport function isCancelledError(value: any): value is CancelledError {\n return value instanceof CancelledError\n}\n\nexport function createRetryer<TData = unknown, TError = DefaultError>(\n config: RetryerConfig<TData, TError>,\n): Retryer<TData> {\n let isRetryCancelled = false\n let failureCount = 0\n let continueFn: ((value?: unknown) => void) | undefined\n\n const thenable = pendingThenable<TData>()\n\n const isResolved = () =>\n (thenable.status as Thenable<TData>['status']) !== 'pending'\n\n const cancel = (cancelOptions?: CancelOptions): void => {\n if (!isResolved()) {\n const error = new CancelledError(cancelOptions) as TError\n reject(error)\n\n config.onCancel?.(error)\n }\n }\n const cancelRetry = () => {\n isRetryCancelled = true\n }\n\n const continueRetry = () => {\n isRetryCancelled = false\n }\n\n const canContinue = () =>\n focusManager.isFocused() &&\n (config.networkMode === 'always' || onlineManager.isOnline()) &&\n config.canRun()\n\n const canStart = () => canFetch(config.networkMode) && config.canRun()\n\n const resolve = (value: any) => {\n if (!isResolved()) {\n continueFn?.()\n thenable.resolve(value)\n }\n }\n\n const reject = (value: any) => {\n if (!isResolved()) {\n continueFn?.()\n thenable.reject(value)\n }\n }\n\n const pause = () => {\n return new Promise((continueResolve) => {\n continueFn = (value) => {\n if (isResolved() || canContinue()) {\n continueResolve(value)\n }\n }\n config.onPause?.()\n }).then(() => {\n continueFn = undefined\n if (!isResolved()) {\n config.onContinue?.()\n }\n })\n }\n\n // Create loop function\n const run = () => {\n // Do nothing if already resolved\n if (isResolved()) {\n return\n }\n\n let promiseOrValue: any\n\n // we can re-use config.initialPromise on the first call of run()\n const initialPromise =\n failureCount === 0 ? config.initialPromise : undefined\n\n // Execute query\n try {\n promiseOrValue = initialPromise ?? config.fn()\n } catch (error) {\n promiseOrValue = Promise.reject(error)\n }\n\n Promise.resolve(promiseOrValue)\n .then(resolve)\n .catch((error) => {\n // Stop if the fetch is already resolved\n if (isResolved()) {\n return\n }\n\n // Do we need to retry the request?\n const retry = config.retry ?? (isServer ? 0 : 3)\n const retryDelay = config.retryDelay ?? defaultRetryDelay\n const delay =\n typeof retryDelay === 'function'\n ? retryDelay(failureCount, error)\n : retryDelay\n const shouldRetry =\n retry === true ||\n (typeof retry === 'number' && failureCount < retry) ||\n (typeof retry === 'function' && retry(failureCount, error))\n\n if (isRetryCancelled || !shouldRetry) {\n // We are done if the query does not need to be retried\n reject(error)\n return\n }\n\n failureCount++\n\n // Notify on fail\n config.onFail?.(failureCount, error)\n\n // Delay\n sleep(delay)\n // Pause if the document is not visible or when the device is offline\n .then(() => {\n return canContinue() ? undefined : pause()\n })\n .then(() => {\n if (isRetryCancelled) {\n reject(error)\n } else {\n run()\n }\n })\n })\n }\n\n return {\n promise: thenable,\n status: () => thenable.status,\n cancel,\n continue: () => {\n continueFn?.()\n return thenable\n },\n cancelRetry,\n continueRetry,\n canStart,\n start: () => {\n // Start loop\n if (canStart()) {\n run()\n } else {\n pause().then(run)\n }\n return thenable\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA6B;AAC7B,2BAA8B;AAC9B,sBAAgC;AAChC,mBAAgC;AA4ChC,SAAS,kBAAkB,cAAsB;AAC/C,SAAO,KAAK,IAAI,MAAO,KAAK,cAAc,GAAK;AACjD;AAEO,SAAS,SAAS,aAA+C;AACtE,UAAQ,eAAe,cAAc,WACjC,mCAAc,SAAS,IACvB;AACN;AAEO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EAGxC,YAAY,SAAyB;AACnC,UAAM,gBAAgB;AACtB,SAAK,SAAS,SAAS;AACvB,SAAK,SAAS,SAAS;AAAA,EACzB;AACF;AAKO,SAAS,iBAAiB,OAAqC;AACpE,SAAO,iBAAiB;AAC1B;AAEO,SAAS,cACd,QACgB;AAChB,MAAI,mBAAmB;AACvB,MAAI,eAAe;AACnB,MAAI;AAEJ,QAAM,eAAW,iCAAuB;AAExC,QAAM,aAAa,MAChB,SAAS,WAAyC;AAErD,QAAM,SAAS,CAAC,kBAAwC;AACtD,QAAI,CAAC,WAAW,GAAG;AACjB,YAAM,QAAQ,IAAI,eAAe,aAAa;AAC9C,aAAO,KAAK;AAEZ,aAAO,WAAW,KAAK;AAAA,IACzB;AAAA,EACF;AACA,QAAM,cAAc,MAAM;AACxB,uBAAmB;AAAA,EACrB;AAEA,QAAM,g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AAW,cAAc,KAAK,IAC9B;AACN,YAAM,cACJ,UAAU,QACT,OAAO,UAAU,YAAY,eAAe,SAC5C,OAAO,UAAU,cAAc,MAAM,cAAc,KAAK;AAE3D,UAAI,oBAAoB,CAAC,aAAa;AAEpC,eAAO,KAAK;AACZ;AAAA,MACF;AAEA;AAGA,aAAO,SAAS,cAAc,KAAK;AAGnC,8BAAM,KAAK,EAER,KAAK,MAAM;AACV,eAAO,YAAY,IAAI,SAAY,MAAM;AAAA,MAC3C,CAAC,EACA,KAAK,MAAM;AACV,YAAI,kBAAkB;AACpB,iBAAO,KAAK;AAAA,QACd,OAAO;AACL,cAAI;AAAA,QACN;AAAA,MACF,CAAC;AAAA,IACL,CAAC;AAAA,EACL;AAEA,SAAO;AAAA,IACL,SAAS;AAAA,IACT,QAAQ,MAAM,SAAS;AAAA,IACvB;AAAA,IACA,UAAU,MAAM;AACd,mBAAa;AACb,aAAO;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,MAAM;AAEX,UAAI,SAAS,GAAG;AACd,YAAI;AAAA,MACN,OAAO;AACL,cAAM,EAAE,KAAK,GAAG;AAAA,MAClB;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/retryer.ts"],"sourcesContent":["import { focusManager } from './focusManager'\nimport { onlineManager } from './onlineManager'\nimport { pendingThenable } from './thenable'\nimport { environmentManager } from './environmentManager'\nimport { sleep } from './utils'\nimport type { Thenable } from './thenable'\nimport type { CancelOptions, DefaultError, NetworkMode } from './types'\n\n// TYPES\n\ninterface RetryerConfig<TData = unknown, TError = DefaultError> {\n fn: () => TData | Promise<TData>\n initialPromise?: Promise<TData>\n onCancel?: (error: TError) => void\n onFail?: (failureCount: number, error: TError) => void\n onPause?: () => void\n onContinue?: () => void\n retry?: RetryValue<TError>\n retryDelay?: RetryDelayValue<TError>\n networkMode: NetworkMode | undefined\n canRun: () => boolean\n}\n\nexport interface Retryer<TData = unknown> {\n promise: Promise<TData>\n cancel: (cancelOptions?: CancelOptions) => void\n continue: () => Promise<unknown>\n cancelRetry: () => void\n continueRetry: () => void\n canStart: () => boolean\n start: () => Promise<TData>\n status: () => 'pending' | 'resolved' | 'rejected'\n}\n\nexport type RetryValue<TError> = boolean | number | ShouldRetryFunction<TError>\n\ntype ShouldRetryFunction<TError = DefaultError> = (\n failureCount: number,\n error: TError,\n) => boolean\n\nexport type RetryDelayValue<TError> = number | RetryDelayFunction<TError>\n\ntype RetryDelayFunction<TError = DefaultError> = (\n failureCount: number,\n error: TError,\n) => number\n\nfunction defaultRetryDelay(failureCount: number) {\n return Math.min(1000 * 2 ** failureCount, 30000)\n}\n\nexport function canFetch(networkMode: NetworkMode | undefined): boolean {\n return (networkMode ?? 'online') === 'online'\n ? onlineManager.isOnline()\n : true\n}\n\nexport class CancelledError extends Error {\n revert?: boolean\n silent?: boolean\n constructor(options?: CancelOptions) {\n super('CancelledError')\n this.revert = options?.revert\n this.silent = options?.silent\n }\n}\n\n/**\n * @deprecated Use instanceof `CancelledError` instead.\n */\nexport function isCancelledError(value: any): value is CancelledError {\n return value instanceof CancelledError\n}\n\nexport function createRetryer<TData = unknown, TError = DefaultError>(\n config: RetryerConfig<TData, TError>,\n): Retryer<TData> {\n let isRetryCancelled = false\n let failureCount = 0\n let continueFn: ((value?: unknown) => void) | undefined\n\n const thenable = pendingThenable<TData>()\n\n const isResolved = () =>\n (thenable.status as Thenable<TData>['status']) !== 'pending'\n\n const cancel = (cancelOptions?: CancelOptions): void => {\n if (!isResolved()) {\n const error = new CancelledError(cancelOptions) as TError\n reject(error)\n\n config.onCancel?.(error)\n }\n }\n const cancelRetry = () => {\n isRetryCancelled = true\n }\n\n const continueRetry = () => {\n isRetryCancelled = false\n }\n\n const canContinue = () =>\n focusManager.isFocused() &&\n (config.networkMode === 'always' || onlineManager.isOnline()) &&\n config.canRun()\n\n const canStart = () => canFetch(config.networkMode) && config.canRun()\n\n const resolve = (value: any) => {\n if (!isResolved()) {\n continueFn?.()\n thenable.resolve(value)\n }\n }\n\n const reject = (value: any) => {\n if (!isResolved()) {\n continueFn?.()\n thenable.reject(value)\n }\n }\n\n const pause = () => {\n return new Promise((continueResolve) => {\n continueFn = (value) => {\n if (isResolved() || canContinue()) {\n continueResolve(value)\n }\n }\n config.onPause?.()\n }).then(() => {\n continueFn = undefined\n if (!isResolved()) {\n config.onContinue?.()\n }\n })\n }\n\n // Create loop function\n const run = () => {\n // Do nothing if already resolved\n if (isResolved()) {\n return\n }\n\n let promiseOrValue: any\n\n // we can re-use config.initialPromise on the first call of run()\n const initialPromise =\n failureCount === 0 ? config.initialPromise : undefined\n\n // Execute query\n try {\n promiseOrValue = initialPromise ?? config.fn()\n } catch (error) {\n promiseOrValue = Promise.reject(error)\n }\n\n Promise.resolve(promiseOrValue)\n .then(resolve)\n .catch((error) => {\n // Stop if the fetch is already resolved\n if (isResolved()) {\n return\n }\n\n // Do we need to retry the request?\n const retry = config.retry ?? (environmentManager.isServer() ? 0 : 3)\n const retryDelay = config.retryDelay ?? defaultRetryDelay\n const delay =\n typeof retryDelay === 'function'\n ? retryDelay(failureCount, error)\n : retryDelay\n const shouldRetry =\n retry === true ||\n (typeof retry === 'number' && failureCount < retry) ||\n (typeof retry === 'function' && retry(failureCount, error))\n\n if (isRetryCancelled || !shouldRetry) {\n // We are done if the query does not need to be retried\n reject(error)\n return\n }\n\n failureCount++\n\n // Notify on fail\n config.onFail?.(failureCount, error)\n\n // Delay\n sleep(delay)\n // Pause if the document is not visible or when the device is offline\n .then(() => {\n return canContinue() ? undefined : pause()\n })\n .then(() => {\n if (isRetryCancelled) {\n reject(error)\n } else {\n run()\n }\n })\n })\n }\n\n return {\n promise: thenable,\n status: () => thenable.status,\n cancel,\n continue: () => {\n continueFn?.()\n return thenable\n },\n cancelRetry,\n continueRetry,\n canStart,\n start: () => {\n // Start loop\n if (canStart()) {\n run()\n } else {\n pause().then(run)\n }\n return thenable\n },\n }\n}\n"],"m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V,YAAI,kBAAkB;AACpB,iBAAO,KAAK;AAAA,QACd,OAAO;AACL,cAAI;AAAA,QACN;AAAA,MACF,CAAC;AAAA,IACL,CAAC;AAAA,EACL;AAEA,SAAO;AAAA,IACL,SAAS;AAAA,IACT,QAAQ,MAAM,SAAS;AAAA,IACvB;AAAA,IACA,UAAU,MAAM;AACd,mBAAa;AACb,aAAO;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,MAAM;AAEX,UAAI,SAAS,GAAG;AACd,YAAI;AAAA,MACN,OAAO;AACL,cAAM,EAAE,KAAK,GAAG;AAAA,MAClB;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
@@ -1,3 +1,7 @@
1
- export { C as CancelledError, bE as RetryDelayValue, bD as RetryValue, bC as Retryer, bF as canFetch, bG as createRetryer, j as isCancelledError } from './hydration-uphG6M-i.cjs';
2
- import './removable.cjs';
3
- import './subscribable.cjs';
1
+ export { canFetch } from './_tsup-dts-rollup.cjs';
2
+ export { isCancelledError_alias_1 as isCancelledError } from './_tsup-dts-rollup.cjs';
3
+ export { createRetryer } from './_tsup-dts-rollup.cjs';
4
+ export { Retryer } from './_tsup-dts-rollup.cjs';
5
+ export { RetryValue } from './_tsup-dts-rollup.cjs';
6
+ export { RetryDelayValue } from './_tsup-dts-rollup.cjs';
7
+ export { CancelledError_alias_1 as CancelledError } from './_tsup-dts-rollup.cjs';
@@ -1,3 +1,7 @@
1
- export { C as CancelledError, bE as RetryDelayValue, bD as RetryValue, bC as Retryer, bF as canFetch, bG as createRetryer, j as isCancelledError } from './hydration-BlEVG2Lp.js';
2
- import './removable.js';
3
- import './subscribable.js';
1
+ export { canFetch } from './_tsup-dts-rollup.js';
2
+ export { isCancelledError_alias_1 as isCancelledError } from './_tsup-dts-rollup.js';
3
+ export { createRetryer } from './_tsup-dts-rollup.js';
4
+ export { Retryer } from './_tsup-dts-rollup.js';
5
+ export { RetryValue } from './_tsup-dts-rollup.js';
6
+ export { RetryDelayValue } from './_tsup-dts-rollup.js';
7
+ export { CancelledError_alias_1 as CancelledError } from './_tsup-dts-rollup.js';
@@ -2,7 +2,8 @@
2
2
  import { focusManager } from "./focusManager.js";
3
3
  import { onlineManager } from "./onlineManager.js";
4
4
  import { pendingThenable } from "./thenable.js";
5
- import { isServer, sleep } from "./utils.js";
5
+ import { environmentManager } from "./environmentManager.js";
6
+ import { sleep } from "./utils.js";
6
7
  function defaultRetryDelay(failureCount) {
7
8
  return Math.min(1e3 * 2 ** failureCount, 3e4);
8
9
  }
@@ -82,7 +83,7 @@ function createRetryer(config) {
82
83
  if (isResolved()) {
83
84
  return;
84
85
  }
85
- const retry = config.retry ?? (isServer ? 0 : 3);
86
+ const retry = config.retry ?? (environmentManager.isServer() ? 0 : 3);
86
87
  const retryDelay = config.retryDelay ?? defaultRetryDelay;
87
88
  const delay = typeof retryDelay === "function" ? retryDelay(failureCount, error) : retryDelay;
88
89
  const shouldRetry = retry === true || typeof retry === "number" && failureCount < retry || typeof retry === "function" && retry(failureCount, error);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/retryer.ts"],"sourcesContent":["import { focusManager } from './focusManager'\nimport { onlineManager } from './onlineManager'\nimport { pendingThenable } from './thenable'\nimport { isServer, sleep } from './utils'\nimport type { Thenable } from './thenable'\nimport type { CancelOptions, DefaultError, NetworkMode } from './types'\n\n// TYPES\n\ninterface RetryerConfig<TData = unknown, TError = DefaultError> {\n fn: () => TData | Promise<TData>\n initialPromise?: Promise<TData>\n onCancel?: (error: TError) => void\n onFail?: (failureCount: number, error: TError) => void\n onPause?: () => void\n onContinue?: () => void\n retry?: RetryValue<TError>\n retryDelay?: RetryDelayValue<TError>\n networkMode: NetworkMode | undefined\n canRun: () => boolean\n}\n\nexport interface Retryer<TData = unknown> {\n promise: Promise<TData>\n cancel: (cancelOptions?: CancelOptions) => void\n continue: () => Promise<unknown>\n cancelRetry: () => void\n continueRetry: () => void\n canStart: () => boolean\n start: () => Promise<TData>\n status: () => 'pending' | 'resolved' | 'rejected'\n}\n\nexport type RetryValue<TError> = boolean | number | ShouldRetryFunction<TError>\n\ntype ShouldRetryFunction<TError = DefaultError> = (\n failureCount: number,\n error: TError,\n) => boolean\n\nexport type RetryDelayValue<TError> = number | RetryDelayFunction<TError>\n\ntype RetryDelayFunction<TError = DefaultError> = (\n failureCount: number,\n error: TError,\n) => number\n\nfunction defaultRetryDelay(failureCount: number) {\n return Math.min(1000 * 2 ** failureCount, 30000)\n}\n\nexport function canFetch(networkMode: NetworkMode | undefined): boolean {\n return (networkMode ?? 'online') === 'online'\n ? onlineManager.isOnline()\n : true\n}\n\nexport class CancelledError extends Error {\n revert?: boolean\n silent?: boolean\n constructor(options?: CancelOptions) {\n super('CancelledError')\n this.revert = options?.revert\n this.silent = options?.silent\n }\n}\n\n/**\n * @deprecated Use instanceof `CancelledError` instead.\n */\nexport function isCancelledError(value: any): value is CancelledError {\n return value instanceof CancelledError\n}\n\nexport function createRetryer<TData = unknown, TError = DefaultError>(\n config: RetryerConfig<TData, TError>,\n): Retryer<TData> {\n let isRetryCancelled = false\n let failureCount = 0\n let continueFn: ((value?: unknown) => void) | undefined\n\n const thenable = pendingThenable<TData>()\n\n const isResolved = () =>\n (thenable.status as Thenable<TData>['status']) !== 'pending'\n\n const cancel = (cancelOptions?: CancelOptions): void => {\n if (!isResolved()) {\n const error = new CancelledError(cancelOptions) as TError\n reject(error)\n\n config.onCancel?.(error)\n }\n }\n const cancelRetry = () => {\n isRetryCancelled = true\n }\n\n const continueRetry = () => {\n isRetryCancelled = false\n }\n\n const canContinue = () =>\n focusManager.isFocused() &&\n (config.networkMode === 'always' || onlineManager.isOnline()) &&\n config.canRun()\n\n const canStart = () => canFetch(config.networkMode) && config.canRun()\n\n const resolve = (value: any) => {\n if (!isResolved()) {\n continueFn?.()\n thenable.resolve(value)\n }\n }\n\n const reject = (value: any) => {\n if (!isResolved()) {\n continueFn?.()\n thenable.reject(value)\n }\n }\n\n const pause = () => {\n return new Promise((continueResolve) => {\n continueFn = (value) => {\n if (isResolved() || canContinue()) {\n continueResolve(value)\n }\n }\n config.onPause?.()\n }).then(() => {\n continueFn = undefined\n if (!isResolved()) {\n config.onContinue?.()\n }\n })\n }\n\n // Create loop function\n const run = () => {\n // Do nothing if already resolved\n if (isResolved()) {\n return\n }\n\n let promiseOrValue: any\n\n // we can re-use config.initialPromise on the first call of run()\n const initialPromise =\n failureCount === 0 ? config.initialPromise : undefined\n\n // Execute query\n try {\n promiseOrValue = initialPromise ?? config.fn()\n } catch (error) {\n promiseOrValue = Promise.reject(error)\n }\n\n Promise.resolve(promiseOrValue)\n .then(resolve)\n .catch((error) => {\n // Stop if the fetch is already resolved\n if (isResolved()) {\n return\n }\n\n // Do we need to retry the request?\n const retry = config.retry ?? (isServer ? 0 : 3)\n const retryDelay = config.retryDelay ?? defaultRetryDelay\n const delay =\n typeof retryDelay === 'function'\n ? retryDelay(failureCount, error)\n : retryDelay\n const shouldRetry =\n retry === true ||\n (typeof retry === 'number' && failureCount < retry) ||\n (typeof retry === 'function' && retry(failureCount, error))\n\n if (isRetryCancelled || !shouldRetry) {\n // We are done if the query does not need to be retried\n reject(error)\n return\n }\n\n failureCount++\n\n // Notify on fail\n config.onFail?.(failureCount, error)\n\n // Delay\n sleep(delay)\n // Pause if the document is not visible or when the device is offline\n .then(() => {\n return canContinue() ? undefined : pause()\n })\n .then(() => {\n if (isRetryCancelled) {\n reject(error)\n } else {\n run()\n }\n })\n })\n }\n\n return {\n promise: thenable,\n status: () => thenable.status,\n cancel,\n continue: () => {\n continueFn?.()\n return thenable\n },\n cancelRetry,\n continueRetry,\n canStart,\n start: () => {\n // Start loop\n if (canStart()) {\n run()\n } else {\n pause().then(run)\n }\n return thenable\n },\n }\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAChC,SAAS,UAAU,aAAa;AA4ChC,SAAS,kBAAkB,cAAsB;AAC/C,SAAO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M;AACd,mBAAa;AACb,aAAO;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,MAAM;AAEX,UAAI,SAAS,GAAG;AACd,YAAI;AAAA,MACN,OAAO;AACL,cAAM,EAAE,KAAK,GAAG;AAAA,MAClB;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/retryer.ts"],"sourcesContent":["import { focusManager } from './focusManager'\nimport { onlineManager } from './onlineManager'\nimport { pendingThenable } from './thenable'\nimport { environmentManager } from './environmentManager'\nimport { sleep } from './utils'\nimport type { Thenable } from './thenable'\nimport type { CancelOptions, DefaultError, NetworkMode } from './types'\n\n// TYPES\n\ninterface RetryerConfig<TData = unknown, TError = DefaultError> {\n fn: () => TData | Promise<TData>\n initialPromise?: Promise<TData>\n onCancel?: (error: TError) => void\n onFail?: (failureCount: number, error: TError) => void\n onPause?: () => void\n onContinue?: () => void\n retry?: RetryValue<TError>\n retryDelay?: RetryDelayValue<TError>\n networkMode: NetworkMode | undefined\n canRun: () => boolean\n}\n\nexport interface Retryer<TData = unknown> {\n promise: Promise<TData>\n cancel: (cancelOptions?: CancelOptions) => void\n continue: () => Promise<unknown>\n cancelRetry: () => void\n continueRetry: () => void\n canStart: () => boolean\n start: () => Promise<TData>\n status: () => 'pending' | 'resolved' | 'rejected'\n}\n\nexport type RetryValue<TError> = boolean | number | ShouldRetryFunction<TError>\n\ntype ShouldRetryFunction<TError = DefaultError> = (\n failureCount: number,\n error: TError,\n) => boolean\n\nexport type RetryDelayValue<TError> = number | RetryDelayFunction<TError>\n\ntype RetryDelayFunction<TError = DefaultError> = (\n failureCount: number,\n error: TError,\n) => number\n\nfunction defaultRetryDelay(failureCount: number) {\n return Math.min(1000 * 2 ** failureCount, 30000)\n}\n\nexport function canFetch(networkMode: NetworkMode | undefined): boolean {\n return (networkMode ?? 'online') === 'online'\n ? onlineManager.isOnline()\n : true\n}\n\nexport class CancelledError extends Error {\n revert?: boolean\n silent?: boolean\n constructor(options?: CancelOptions) {\n super('CancelledError')\n this.revert = options?.revert\n this.silent = options?.silent\n }\n}\n\n/**\n * @deprecated Use instanceof `CancelledError` instead.\n */\nexport function isCancelledError(value: any): value is CancelledError {\n return value instanceof CancelledError\n}\n\nexport function createRetryer<TData = unknown, TError = DefaultError>(\n config: RetryerConfig<TData, TError>,\n): Retryer<TData> {\n let isRetryCancelled = false\n let failureCount = 0\n let continueFn: ((value?: unknown) => void) | undefined\n\n const thenable = pendingThenable<TData>()\n\n const isResolved = () =>\n (thenable.status as Thenable<TData>['status']) !== 'pending'\n\n const cancel = (cancelOptions?: CancelOptions): void => {\n if (!isResolved()) {\n const error = new CancelledError(cancelOptions) as TError\n reject(error)\n\n config.onCancel?.(error)\n }\n }\n const cancelRetry = () => {\n isRetryCancelled = true\n }\n\n const continueRetry = () => {\n isRetryCancelled = false\n }\n\n const canContinue = () =>\n focusManager.isFocused() &&\n (config.networkMode === 'always' || onlineManager.isOnline()) &&\n config.canRun()\n\n const canStart = () => canFetch(config.networkMode) && config.canRun()\n\n const resolve = (value: any) => {\n if (!isResolved()) {\n continueFn?.()\n thenable.resolve(value)\n }\n }\n\n const reject = (value: any) => {\n if (!isResolved()) {\n continueFn?.()\n thenable.reject(value)\n }\n }\n\n const pause = () => {\n return new Promise((continueResolve) => {\n continueFn = (value) => {\n if (isResolved() || canContinue()) {\n continueResolve(value)\n }\n }\n config.onPause?.()\n }).then(() => {\n continueFn = undefined\n if (!isResolved()) {\n config.onContinue?.()\n }\n })\n }\n\n // Create loop function\n const run = () => {\n // Do nothing if already resolved\n if (isResolved()) {\n return\n }\n\n let promiseOrValue: any\n\n // we can re-use config.initialPromise on the first call of run()\n const initialPromise =\n failureCount === 0 ? config.initialPromise : undefined\n\n // Execute query\n try {\n promiseOrValue = initialPromise ?? config.fn()\n } catch (error) {\n promiseOrValue = Promise.reject(error)\n }\n\n Promise.resolve(promiseOrValue)\n .then(resolve)\n .catch((error) => {\n // Stop if the fetch is already resolved\n if (isResolved()) {\n return\n }\n\n // Do we need to retry the request?\n const retry = config.retry ?? (environmentManager.isServer() ? 0 : 3)\n const retryDelay = config.retryDelay ?? defaultRetryDelay\n const delay =\n typeof retryDelay === 'function'\n ? retryDelay(failureCount, error)\n : retryDelay\n const shouldRetry =\n retry === true ||\n (typeof retry === 'number' && failureCount < retry) ||\n (typeof retry === 'function' && retry(failureCount, error))\n\n if (isRetryCancelled || !shouldRetry) {\n // We are done if the query does not need to be retried\n reject(error)\n return\n }\n\n failureCount++\n\n // Notify on fail\n config.onFail?.(failureCount, error)\n\n // Delay\n sleep(delay)\n // Pause if the document is not visible or when the device is offline\n .then(() => {\n return canContinue() ? undefined : pause()\n })\n .then(() => {\n if (isRetryCancelled) {\n reject(error)\n } else {\n run()\n }\n })\n })\n }\n\n return {\n promise: thenable,\n status: () => thenable.status,\n cancel,\n continue: () => {\n continueFn?.()\n return thenable\n },\n cancelRetry,\n continueRetry,\n canStart,\n start: () => {\n // Start loop\n if (canStart()) {\n run()\n } else {\n pause().then(run)\n }\n return thenable\n },\n }\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,aAAa;AA4CtB,SAAS,kBAAkB,cAAsB;AAC/C,SAAO,KAAK,IAAI,MAAO,KAAK,cAAc,GAAK;AACjD;AAEO,SAAS,SAAS,aAA+C;AACtE,UAAQ,eAAe,cAAc,WACjC,cAAc,SAAS,IACvB;AACN;AAEO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EAGxC,YAAY,SAAyB;AACnC,UAAM,gBAAgB;AACtB,SAAK,SAAS,SAAS;AACvB,SAAK,SAAS,SAAS;AAAA,EACzB;AACF;AAKO,SAAS,iBAAiB,OAAqC;AACpE,SAAO,iBAAiB;AAC1B;AAEO,SAAS,cACd,QACgB;AAChB,MAAI,mBAAmB;AACvB,MAAI,eAAe;AACnB,MAAI;A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A,IAC/C,SAAS,OAAO;AACd,uBAAiB,QAAQ,OAAO,KAAK;AAAA,IACvC;AAEA,YAAQ,QAAQ,cAAc,EAC3B,KAAK,OAAO,EACZ,MAAM,CAAC,UAAU;AAEhB,UAAI,WAAW,GAAG;AAChB;AAAA,MACF;AAGA,YAAM,QAAQ,OAAO,UAAU,mBAAmB,SAAS,IAAI,IAAI;AACnE,YAAM,aAAa,OAAO,cAAc;AACxC,YAAM,QACJ,OAAO,eAAe,aAClB,WAAW,cAAc,KAAK,IAC9B;AACN,YAAM,cACJ,UAAU,QACT,OAAO,UAAU,YAAY,eAAe,SAC5C,OAAO,UAAU,cAAc,MAAM,cAAc,KAAK;AAE3D,UAAI,oBAAoB,CAAC,aAAa;AAEpC,eAAO,KAAK;AACZ;AAAA,MACF;AAEA;AAGA,aAAO,SAAS,cAAc,KAAK;AAGnC,YAAM,KAAK,EAER,KAAK,MAAM;AACV,eAAO,YAAY,IAAI,SAAY,MAAM;AAAA,MAC3C,CAAC,EACA,KAAK,MAAM;AACV,YAAI,kBAAkB;AACpB,iBAAO,KAAK;AAAA,QACd,OAAO;AACL,cAAI;AAAA,QACN;AAAA,MACF,CAAC;AAAA,IACL,CAAC;AAAA,EACL;AAEA,SAAO;AAAA,IACL,SAAS;AAAA,IACT,QAAQ,MAAM,SAAS;AAAA,IACvB;AAAA,IACA,UAAU,MAAM;AACd,mBAAa;AACb,aAAO;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,MAAM;AAEX,UAAI,SAAS,GAAG;AACd,YAAI;AAAA,MACN,OAAO;AACL,cAAM,EAAE,KAAK,GAAG;AAAA,MAClB;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
@@ -1,34 +1 @@
1
- import { I as QueryKey, a1 as QueryFunctionContext, Y as QueryFunction } from './hydration-uphG6M-i.cjs';
2
- import './removable.cjs';
3
- import './subscribable.cjs';
4
-
5
- type BaseStreamedQueryParams<TQueryFnData, TQueryKey extends QueryKey> = {
6
- streamFn: (context: QueryFunctionContext<TQueryKey>) => AsyncIterable<TQueryFnData> | Promise<AsyncIterable<TQueryFnData>>;
7
- refetchMode?: 'append' | 'reset' | 'replace';
8
- };
9
- type SimpleStreamedQueryParams<TQueryFnData, TQueryKey extends QueryKey> = BaseStreamedQueryParams<TQueryFnData, TQueryKey> & {
10
- reducer?: never;
11
- initialValue?: never;
12
- };
13
- type ReducibleStreamedQueryParams<TQueryFnData, TData, TQueryKey extends QueryKey> = BaseStreamedQueryParams<TQueryFnData, TQueryKey> & {
14
- reducer: (acc: TData, chunk: TQueryFnData) => TData;
15
- initialValue: TData;
16
- };
17
- type StreamedQueryParams<TQueryFnData, TData, TQueryKey extends QueryKey> = SimpleStreamedQueryParams<TQueryFnData, TQueryKey> | ReducibleStreamedQueryParams<TQueryFnData, TData, TQueryKey>;
18
- /**
19
- * This is a helper function to create a query function that streams data from an AsyncIterable.
20
- * Data will be an Array of all the chunks received.
21
- * The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that.
22
- * The query will stay in fetchStatus 'fetching' until the stream ends.
23
- * @param queryFn - The function that returns an AsyncIterable to stream data from.
24
- * @param refetchMode - Defines how re-fetches are handled.
25
- * Defaults to `'reset'`, erases all data and puts the query back into `pending` state.
26
- * Set to `'append'` to append new data to the existing data.
27
- * Set to `'replace'` to write all data to the cache once the stream ends.
28
- * @param reducer - A function to reduce the streamed chunks into the final data.
29
- * Defaults to a function that appends chunks to the end of the array.
30
- * @param initialValue - Initial value to be used while the first chunk is being fetched, and returned if the stream yields no values.
31
- */
32
- declare function streamedQuery<TQueryFnData = unknown, TData = Array<TQueryFnData>, TQueryKey extends QueryKey = QueryKey>({ streamFn, refetchMode, reducer, initialValue, }: StreamedQueryParams<TQueryFnData, TData, TQueryKey>): QueryFunction<TData, TQueryKey>;
33
-
34
- export { streamedQuery };
1
+ export { streamedQuery } from './_tsup-dts-rollup.cjs';
@@ -1,34 +1 @@
1
- import { I as QueryKey, a1 as QueryFunctionContext, Y as QueryFunction } from './hydration-BlEVG2Lp.js';
2
- import './removable.js';
3
- import './subscribable.js';
4
-
5
- type BaseStreamedQueryParams<TQueryFnData, TQueryKey extends QueryKey> = {
6
- streamFn: (context: QueryFunctionContext<TQueryKey>) => AsyncIterable<TQueryFnData> | Promise<AsyncIterable<TQueryFnData>>;
7
- refetchMode?: 'append' | 'reset' | 'replace';
8
- };
9
- type SimpleStreamedQueryParams<TQueryFnData, TQueryKey extends QueryKey> = BaseStreamedQueryParams<TQueryFnData, TQueryKey> & {
10
- reducer?: never;
11
- initialValue?: never;
12
- };
13
- type ReducibleStreamedQueryParams<TQueryFnData, TData, TQueryKey extends QueryKey> = BaseStreamedQueryParams<TQueryFnData, TQueryKey> & {
14
- reducer: (acc: TData, chunk: TQueryFnData) => TData;
15
- initialValue: TData;
16
- };
17
- type StreamedQueryParams<TQueryFnData, TData, TQueryKey extends QueryKey> = SimpleStreamedQueryParams<TQueryFnData, TQueryKey> | ReducibleStreamedQueryParams<TQueryFnData, TData, TQueryKey>;
18
- /**
19
- * This is a helper function to create a query function that streams data from an AsyncIterable.
20
- * Data will be an Array of all the chunks received.
21
- * The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that.
22
- * The query will stay in fetchStatus 'fetching' until the stream ends.
23
- * @param queryFn - The function that returns an AsyncIterable to stream data from.
24
- * @param refetchMode - Defines how re-fetches are handled.
25
- * Defaults to `'reset'`, erases all data and puts the query back into `pending` state.
26
- * Set to `'append'` to append new data to the existing data.
27
- * Set to `'replace'` to write all data to the cache once the stream ends.
28
- * @param reducer - A function to reduce the streamed chunks into the final data.
29
- * Defaults to a function that appends chunks to the end of the array.
30
- * @param initialValue - Initial value to be used while the first chunk is being fetched, and returned if the stream yields no values.
31
- */
32
- declare function streamedQuery<TQueryFnData = unknown, TData = Array<TQueryFnData>, TQueryKey extends QueryKey = QueryKey>({ streamFn, refetchMode, reducer, initialValue, }: StreamedQueryParams<TQueryFnData, TData, TQueryKey>): QueryFunction<TData, TQueryKey>;
33
-
34
- export { streamedQuery };
1
+ export { streamedQuery } from './_tsup-dts-rollup.js';
@@ -1,10 +1 @@
1
- declare class Subscribable<TListener extends Function> {
2
- protected listeners: Set<TListener>;
3
- constructor();
4
- subscribe(listener: TListener): () => void;
5
- hasListeners(): boolean;
6
- protected onSubscribe(): void;
7
- protected onUnsubscribe(): void;
8
- }
9
-
10
- export { Subscribable };
1
+ export { Subscribable } from './_tsup-dts-rollup.cjs';
@@ -1,10 +1 @@
1
- declare class Subscribable<TListener extends Function> {
2
- protected listeners: Set<TListener>;
3
- constructor();
4
- subscribe(listener: TListener): () => void;
5
- hasListeners(): boolean;
6
- protected onSubscribe(): void;
7
- protected onUnsubscribe(): void;
8
- }
9
-
10
- export { Subscribable };
1
+ export { Subscribable } from './_tsup-dts-rollup.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/thenable.ts"],"sourcesContent":["/**\n * Thenable types which matches React's types for promises\n *\n * React seemingly uses `.status`, `.value` and `.reason` properties on a promises to optimistically unwrap data from promises\n *\n * @see https://github.com/facebook/react/blob/main/packages/shared/ReactTypes.js#L112-L138\n * @see https://github.com/facebook/react/blob/4f604941569d2e8947ce1460a0b2997e835f37b9/packages/react-debug-tools/src/ReactDebugHooks.js#L224-L227\n */\n\nimport { noop } from './utils'\n\ninterface Fulfilled<T> {\n status: 'fulfilled'\n value: T\n}\ninterface Rejected {\n status: 'rejected'\n reason: unknown\n}\ninterface Pending<T> {\n status: 'pending'\n\n /**\n * Resolve the promise with a value.\n * Will remove the `resolve` and `reject` properties from the promise.\n */\n resolve: (value: T) => void\n /**\n * Reject the promise with a reason.\n * Will remove the `resolve` and `reject` properties from the promise.\n */\n reject: (reason: unknown) => void\n}\n\nexport type FulfilledThenable<T> = Promise<T> & Fulfilled<T>\nexport type RejectedThenable<T> = Promise<T> & Rejected\nexport type PendingThenable<T> = Promise<T> & Pending<T>\n\nexport type Thenable<T> =\n | FulfilledThenable<T>\n | RejectedThenable<T>\n | PendingThenable<T>\n\nexport function pendingThenable<T>(): PendingThenable<T> {\n let resolve: Pending<T>['resolve']\n let reject: Pending<T>['reject']\n // this could use `Promise.withResolvers()` in the future\n const thenable = new Promise((_resolve, _reject) => {\n resolve = _resolve\n reject = _reject\n }) as PendingThenable<T>\n\n thenable.status = 'pending'\n thenable.catch(() => {\n // prevent unhandled rejection errors\n })\n\n function finalize(data: Fulfilled<T> | Rejected) {\n Object.assign(thenable, data)\n\n // clear pending props props to avoid calling them twice\n delete (thenable as Partial<PendingThenable<T>>).resolve\n delete (thenable as Partial<PendingThenable<T>>).reject\n }\n\n thenable.resolve = (value) => {\n finalize({\n status: 'fulfilled',\n value,\n })\n\n resolve(value)\n }\n thenable.reject = (reason) => {\n finalize({\n status: 'rejected',\n reason,\n })\n\n reject(reason)\n }\n\n return thenable\n}\n\n/**\n * This function takes a Promise-like input and detects whether the data\n * is synchronously available or not.\n *\n * It does not inspect .status, .value or .reason properties of the promise,\n * as those are not always available, and the .status of React's promises\n * should not be considered part of the public API.\n */\nexport function tryResolveSync(promise: Promise<unknown> | Thenable<unknown>) {\n let data: unknown\n\n promise\n .then((result) => {\n data = result\n return result\n }, noop)\n // .catch can be unavailable on certain kinds of thenable's\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n ?.catch(noop)\n\n if (data !== undefined) {\n return { data }\n }\n\n return undefined\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,mBAAqB;AAkCd,SAAS,kBAAyC;AACvD,MAAI;AACJ,MAAI;AAEJ,QAAM,WAAW,IAAI,QAAQ,CAAC,UAAU,YAAY;AAClD,cAAU;AACV,aAAS;AAAA,EACX,CAAC;AAED,WAAS,SAAS;AAClB,WAAS,MAAM,MAAM;AAAA,EAErB,CAAC;AAED,WAAS,SAAS,MAA+B;AAC/C,WAAO,OAAO,UAAU,IAAI;AAG5B,WAAQ,SAAyC;AACjD,WAAQ,SAAyC;AAAA,EACnD;AAEA,WAAS,UAAU,CAAC,UAAU;AAC5B,aAAS;AAAA,MACP,QAAQ;AAAA,MACR;AAAA,IACF,CAAC;AAED,YAAQ,KAAK;AAAA,EACf;AACA,WAAS,SAAS,CAAC,WAAW;AAC5B,aAAS;AAAA,MACP,QAAQ;AAAA,MACR;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AAAA,EACf;AAEA,SAAO;AACT;AAUO,SAAS,eAAe,SAA+C;AAC5E,MAAI;AAEJ,UACG,KAAK,CAAC,WAAW;AAChB,WAAO;AACP,WAAO;AAAA,EACT,GAAG,iBAAI,GAGL,MAAM,iBAAI;AAEd,MAAI,SAAS,QAAW;AACtB,WAAO,EAAE,KAAK;AAAA,EAChB;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/thenable.ts"],"sourcesContent":["/**\n * Thenable types which matches React's types for promises\n *\n * React seemingly uses `.status`, `.value` and `.reason` properties on a promises to optimistically unwrap data from promises\n *\n * @see https://github.com/facebook/react/blob/main/packages/shared/ReactTypes.js#L112-L138\n * @see https://github.com/facebook/react/blob/4f604941569d2e8947ce1460a0b2997e835f37b9/packages/react-debug-tools/src/ReactDebugHooks.js#L224-L227\n */\n\nimport { noop } from './utils'\n\ninterface Fulfilled<T> {\n status: 'fulfilled'\n value: T\n}\ninterface Rejected {\n status: 'rejected'\n reason: unknown\n}\ninterface Pending<T> {\n status: 'pending'\n\n /**\n * Resolve the promise with a value.\n * Will remove the `resolve` and `reject` properties from the promise.\n */\n resolve: (value: T) => void\n /**\n * Reject the promise with a reason.\n * Will remove the `resolve` and `reject` properties from the promise.\n */\n reject: (reason: unknown) => void\n}\n\nexport type FulfilledThenable<T> = Promise<T> & Fulfilled<T>\nexport type RejectedThenable<T> = Promise<T> & Rejected\nexport type PendingThenable<T> = Promise<T> & Pending<T>\n\nexport type Thenable<T> =\n | FulfilledThenable<T>\n | RejectedThenable<T>\n | PendingThenable<T>\n\nexport function pendingThenable<T>(): PendingThenable<T> {\n let resolve: Pending<T>['resolve']\n let reject: Pending<T>['reject']\n // this could use `Promise.withResolvers()` in the future\n const thenable = new Promise((_resolve, _reject) => {\n resolve = _resolve\n reject = _reject\n }) as PendingThenable<T>\n\n thenable.status = 'pending'\n thenable.catch(() => {\n // prevent unhandled rejection errors\n })\n\n function finalize(data: Fulfilled<T> | Rejected) {\n Object.assign(thenable, data)\n\n // clear pending props to avoid calling them twice\n delete (thenable as Partial<PendingThenable<T>>).resolve\n delete (thenable as Partial<PendingThenable<T>>).reject\n }\n\n thenable.resolve = (value) => {\n finalize({\n status: 'fulfilled',\n value,\n })\n\n resolve(value)\n }\n thenable.reject = (reason) => {\n finalize({\n status: 'rejected',\n reason,\n })\n\n reject(reason)\n }\n\n return thenable\n}\n\n/**\n * This function takes a Promise-like input and detects whether the data\n * is synchronously available or not.\n *\n * It does not inspect .status, .value or .reason properties of the promise,\n * as those are not always available, and the .status of React's promises\n * should not be considered part of the public API.\n */\nexport function tryResolveSync(promise: Promise<unknown> | Thenable<unknown>) {\n let data: unknown\n\n promise\n .then((result) => {\n data = result\n return result\n }, noop)\n // .catch can be unavailable on certain kinds of thenable's\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n ?.catch(noop)\n\n if (data !== undefined) {\n return { data }\n }\n\n return undefined\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,mBAAqB;AAkCd,SAAS,kBAAyC;AACvD,MAAI;AACJ,MAAI;AAEJ,QAAM,WAAW,IAAI,QAAQ,CAAC,UAAU,YAAY;AAClD,cAAU;AACV,aAAS;AAAA,EACX,CAAC;AAED,WAAS,SAAS;AAClB,WAAS,MAAM,MAAM;AAAA,EAErB,CAAC;AAED,WAAS,SAAS,MAA+B;AAC/C,WAAO,OAAO,UAAU,IAAI;AAG5B,WAAQ,SAAyC;AACjD,WAAQ,SAAyC;AAAA,EACnD;AAEA,WAAS,UAAU,CAAC,UAAU;AAC5B,aAAS;AAAA,MACP,QAAQ;AAAA,MACR;AAAA,IACF,CAAC;AAED,YAAQ,KAAK;AAAA,EACf;AACA,WAAS,SAAS,CAAC,WAAW;AAC5B,aAAS;AAAA,MACP,QAAQ;AAAA,MACR;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AAAA,EACf;AAEA,SAAO;AACT;AAUO,SAAS,eAAe,SAA+C;AAC5E,MAAI;AAEJ,UACG,KAAK,CAAC,WAAW;AAChB,WAAO;AACP,WAAO;AAAA,EACT,GAAG,iBAAI,GAGL,MAAM,iBAAI;AAEd,MAAI,SAAS,QAAW;AACtB,WAAO,EAAE,KAAK;AAAA,EAChB;AAEA,SAAO;AACT;","names":[]}
@@ -1,47 +1,6 @@
1
- /**
2
- * Thenable types which matches React's types for promises
3
- *
4
- * React seemingly uses `.status`, `.value` and `.reason` properties on a promises to optimistically unwrap data from promises
5
- *
6
- * @see https://github.com/facebook/react/blob/main/packages/shared/ReactTypes.js#L112-L138
7
- * @see https://github.com/facebook/react/blob/4f604941569d2e8947ce1460a0b2997e835f37b9/packages/react-debug-tools/src/ReactDebugHooks.js#L224-L227
8
- */
9
- interface Fulfilled<T> {
10
- status: 'fulfilled';
11
- value: T;
12
- }
13
- interface Rejected {
14
- status: 'rejected';
15
- reason: unknown;
16
- }
17
- interface Pending<T> {
18
- status: 'pending';
19
- /**
20
- * Resolve the promise with a value.
21
- * Will remove the `resolve` and `reject` properties from the promise.
22
- */
23
- resolve: (value: T) => void;
24
- /**
25
- * Reject the promise with a reason.
26
- * Will remove the `resolve` and `reject` properties from the promise.
27
- */
28
- reject: (reason: unknown) => void;
29
- }
30
- type FulfilledThenable<T> = Promise<T> & Fulfilled<T>;
31
- type RejectedThenable<T> = Promise<T> & Rejected;
32
- type PendingThenable<T> = Promise<T> & Pending<T>;
33
- type Thenable<T> = FulfilledThenable<T> | RejectedThenable<T> | PendingThenable<T>;
34
- declare function pendingThenable<T>(): PendingThenable<T>;
35
- /**
36
- * This function takes a Promise-like input and detects whether the data
37
- * is synchronously available or not.
38
- *
39
- * It does not inspect .status, .value or .reason properties of the promise,
40
- * as those are not always available, and the .status of React's promises
41
- * should not be considered part of the public API.
42
- */
43
- declare function tryResolveSync(promise: Promise<unknown> | Thenable<unknown>): {
44
- data: {} | null;
45
- } | undefined;
46
-
47
- export { type FulfilledThenable, type PendingThenable, type RejectedThenable, type Thenable, pendingThenable, tryResolveSync };
1
+ export { pendingThenable } from './_tsup-dts-rollup.cjs';
2
+ export { tryResolveSync } from './_tsup-dts-rollup.cjs';
3
+ export { FulfilledThenable } from './_tsup-dts-rollup.cjs';
4
+ export { RejectedThenable } from './_tsup-dts-rollup.cjs';
5
+ export { PendingThenable } from './_tsup-dts-rollup.cjs';
6
+ export { Thenable } from './_tsup-dts-rollup.cjs';
@@ -1,47 +1,6 @@
1
- /**
2
- * Thenable types which matches React's types for promises
3
- *
4
- * React seemingly uses `.status`, `.value` and `.reason` properties on a promises to optimistically unwrap data from promises
5
- *
6
- * @see https://github.com/facebook/react/blob/main/packages/shared/ReactTypes.js#L112-L138
7
- * @see https://github.com/facebook/react/blob/4f604941569d2e8947ce1460a0b2997e835f37b9/packages/react-debug-tools/src/ReactDebugHooks.js#L224-L227
8
- */
9
- interface Fulfilled<T> {
10
- status: 'fulfilled';
11
- value: T;
12
- }
13
- interface Rejected {
14
- status: 'rejected';
15
- reason: unknown;
16
- }
17
- interface Pending<T> {
18
- status: 'pending';
19
- /**
20
- * Resolve the promise with a value.
21
- * Will remove the `resolve` and `reject` properties from the promise.
22
- */
23
- resolve: (value: T) => void;
24
- /**
25
- * Reject the promise with a reason.
26
- * Will remove the `resolve` and `reject` properties from the promise.
27
- */
28
- reject: (reason: unknown) => void;
29
- }
30
- type FulfilledThenable<T> = Promise<T> & Fulfilled<T>;
31
- type RejectedThenable<T> = Promise<T> & Rejected;
32
- type PendingThenable<T> = Promise<T> & Pending<T>;
33
- type Thenable<T> = FulfilledThenable<T> | RejectedThenable<T> | PendingThenable<T>;
34
- declare function pendingThenable<T>(): PendingThenable<T>;
35
- /**
36
- * This function takes a Promise-like input and detects whether the data
37
- * is synchronously available or not.
38
- *
39
- * It does not inspect .status, .value or .reason properties of the promise,
40
- * as those are not always available, and the .status of React's promises
41
- * should not be considered part of the public API.
42
- */
43
- declare function tryResolveSync(promise: Promise<unknown> | Thenable<unknown>): {
44
- data: {} | null;
45
- } | undefined;
46
-
47
- export { type FulfilledThenable, type PendingThenable, type RejectedThenable, type Thenable, pendingThenable, tryResolveSync };
1
+ export { pendingThenable } from './_tsup-dts-rollup.js';
2
+ export { tryResolveSync } from './_tsup-dts-rollup.js';
3
+ export { FulfilledThenable } from './_tsup-dts-rollup.js';
4
+ export { RejectedThenable } from './_tsup-dts-rollup.js';
5
+ export { PendingThenable } from './_tsup-dts-rollup.js';
6
+ export { Thenable } from './_tsup-dts-rollup.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/thenable.ts"],"sourcesContent":["/**\n * Thenable types which matches React's types for promises\n *\n * React seemingly uses `.status`, `.value` and `.reason` properties on a promises to optimistically unwrap data from promises\n *\n * @see https://github.com/facebook/react/blob/main/packages/shared/ReactTypes.js#L112-L138\n * @see https://github.com/facebook/react/blob/4f604941569d2e8947ce1460a0b2997e835f37b9/packages/react-debug-tools/src/ReactDebugHooks.js#L224-L227\n */\n\nimport { noop } from './utils'\n\ninterface Fulfilled<T> {\n status: 'fulfilled'\n value: T\n}\ninterface Rejected {\n status: 'rejected'\n reason: unknown\n}\ninterface Pending<T> {\n status: 'pending'\n\n /**\n * Resolve the promise with a value.\n * Will remove the `resolve` and `reject` properties from the promise.\n */\n resolve: (value: T) => void\n /**\n * Reject the promise with a reason.\n * Will remove the `resolve` and `reject` properties from the promise.\n */\n reject: (reason: unknown) => void\n}\n\nexport type FulfilledThenable<T> = Promise<T> & Fulfilled<T>\nexport type RejectedThenable<T> = Promise<T> & Rejected\nexport type PendingThenable<T> = Promise<T> & Pending<T>\n\nexport type Thenable<T> =\n | FulfilledThenable<T>\n | RejectedThenable<T>\n | PendingThenable<T>\n\nexport function pendingThenable<T>(): PendingThenable<T> {\n let resolve: Pending<T>['resolve']\n let reject: Pending<T>['reject']\n // this could use `Promise.withResolvers()` in the future\n const thenable = new Promise((_resolve, _reject) => {\n resolve = _resolve\n reject = _reject\n }) as PendingThenable<T>\n\n thenable.status = 'pending'\n thenable.catch(() => {\n // prevent unhandled rejection errors\n })\n\n function finalize(data: Fulfilled<T> | Rejected) {\n Object.assign(thenable, data)\n\n // clear pending props props to avoid calling them twice\n delete (thenable as Partial<PendingThenable<T>>).resolve\n delete (thenable as Partial<PendingThenable<T>>).reject\n }\n\n thenable.resolve = (value) => {\n finalize({\n status: 'fulfilled',\n value,\n })\n\n resolve(value)\n }\n thenable.reject = (reason) => {\n finalize({\n status: 'rejected',\n reason,\n })\n\n reject(reason)\n }\n\n return thenable\n}\n\n/**\n * This function takes a Promise-like input and detects whether the data\n * is synchronously available or not.\n *\n * It does not inspect .status, .value or .reason properties of the promise,\n * as those are not always available, and the .status of React's promises\n * should not be considered part of the public API.\n */\nexport function tryResolveSync(promise: Promise<unknown> | Thenable<unknown>) {\n let data: unknown\n\n promise\n .then((result) => {\n data = result\n return result\n }, noop)\n // .catch can be unavailable on certain kinds of thenable's\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n ?.catch(noop)\n\n if (data !== undefined) {\n return { data }\n }\n\n return undefined\n}\n"],"mappings":";AASA,SAAS,YAAY;AAkCd,SAAS,kBAAyC;AACvD,MAAI;AACJ,MAAI;AAEJ,QAAM,WAAW,IAAI,QAAQ,CAAC,UAAU,YAAY;AAClD,cAAU;AACV,aAAS;AAAA,EACX,CAAC;AAED,WAAS,SAAS;AAClB,WAAS,MAAM,MAAM;AAAA,EAErB,CAAC;AAED,WAAS,SAAS,MAA+B;AAC/C,WAAO,OAAO,UAAU,IAAI;AAG5B,WAAQ,SAAyC;AACjD,WAAQ,SAAyC;AAAA,EACnD;AAEA,WAAS,UAAU,CAAC,UAAU;AAC5B,aAAS;AAAA,MACP,QAAQ;AAAA,MACR;AAAA,IACF,CAAC;AAED,YAAQ,KAAK;AAAA,EACf;AACA,WAAS,SAAS,CAAC,WAAW;AAC5B,aAAS;AAAA,MACP,QAAQ;AAAA,MACR;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AAAA,EACf;AAEA,SAAO;AACT;AAUO,SAAS,eAAe,SAA+C;AAC5E,MAAI;AAEJ,UACG,KAAK,CAAC,WAAW;AAChB,WAAO;AACP,WAAO;AAAA,EACT,GAAG,IAAI,GAGL,MAAM,IAAI;AAEd,MAAI,SAAS,QAAW;AACtB,WAAO,EAAE,KAAK;AAAA,EAChB;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/thenable.ts"],"sourcesContent":["/**\n * Thenable types which matches React's types for promises\n *\n * React seemingly uses `.status`, `.value` and `.reason` properties on a promises to optimistically unwrap data from promises\n *\n * @see https://github.com/facebook/react/blob/main/packages/shared/ReactTypes.js#L112-L138\n * @see https://github.com/facebook/react/blob/4f604941569d2e8947ce1460a0b2997e835f37b9/packages/react-debug-tools/src/ReactDebugHooks.js#L224-L227\n */\n\nimport { noop } from './utils'\n\ninterface Fulfilled<T> {\n status: 'fulfilled'\n value: T\n}\ninterface Rejected {\n status: 'rejected'\n reason: unknown\n}\ninterface Pending<T> {\n status: 'pending'\n\n /**\n * Resolve the promise with a value.\n * Will remove the `resolve` and `reject` properties from the promise.\n */\n resolve: (value: T) => void\n /**\n * Reject the promise with a reason.\n * Will remove the `resolve` and `reject` properties from the promise.\n */\n reject: (reason: unknown) => void\n}\n\nexport type FulfilledThenable<T> = Promise<T> & Fulfilled<T>\nexport type RejectedThenable<T> = Promise<T> & Rejected\nexport type PendingThenable<T> = Promise<T> & Pending<T>\n\nexport type Thenable<T> =\n | FulfilledThenable<T>\n | RejectedThenable<T>\n | PendingThenable<T>\n\nexport function pendingThenable<T>(): PendingThenable<T> {\n let resolve: Pending<T>['resolve']\n let reject: Pending<T>['reject']\n // this could use `Promise.withResolvers()` in the future\n const thenable = new Promise((_resolve, _reject) => {\n resolve = _resolve\n reject = _reject\n }) as PendingThenable<T>\n\n thenable.status = 'pending'\n thenable.catch(() => {\n // prevent unhandled rejection errors\n })\n\n function finalize(data: Fulfilled<T> | Rejected) {\n Object.assign(thenable, data)\n\n // clear pending props to avoid calling them twice\n delete (thenable as Partial<PendingThenable<T>>).resolve\n delete (thenable as Partial<PendingThenable<T>>).reject\n }\n\n thenable.resolve = (value) => {\n finalize({\n status: 'fulfilled',\n value,\n })\n\n resolve(value)\n }\n thenable.reject = (reason) => {\n finalize({\n status: 'rejected',\n reason,\n })\n\n reject(reason)\n }\n\n return thenable\n}\n\n/**\n * This function takes a Promise-like input and detects whether the data\n * is synchronously available or not.\n *\n * It does not inspect .status, .value or .reason properties of the promise,\n * as those are not always available, and the .status of React's promises\n * should not be considered part of the public API.\n */\nexport function tryResolveSync(promise: Promise<unknown> | Thenable<unknown>) {\n let data: unknown\n\n promise\n .then((result) => {\n data = result\n return result\n }, noop)\n // .catch can be unavailable on certain kinds of thenable's\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n ?.catch(noop)\n\n if (data !== undefined) {\n return { data }\n }\n\n return undefined\n}\n"],"mappings":";AASA,SAAS,YAAY;AAkCd,SAAS,kBAAyC;AACvD,MAAI;AACJ,MAAI;AAEJ,QAAM,WAAW,IAAI,QAAQ,CAAC,UAAU,YAAY;AAClD,cAAU;AACV,aAAS;AAAA,EACX,CAAC;AAED,WAAS,SAAS;AAClB,WAAS,MAAM,MAAM;AAAA,EAErB,CAAC;AAED,WAAS,SAAS,MAA+B;AAC/C,WAAO,OAAO,UAAU,IAAI;AAG5B,WAAQ,SAAyC;AACjD,WAAQ,SAAyC;AAAA,EACnD;AAEA,WAAS,UAAU,CAAC,UAAU;AAC5B,aAAS;AAAA,MACP,QAAQ;AAAA,MACR;AAAA,IACF,CAAC;AAED,YAAQ,KAAK;AAAA,EACf;AACA,WAAS,SAAS,CAAC,WAAW;AAC5B,aAAS;AAAA,MACP,QAAQ;AAAA,MACR;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AAAA,EACf;AAEA,SAAO;AACT;AAUO,SAAS,eAAe,SAA+C;AAC5E,MAAI;AAEJ,UACG,KAAK,CAAC,WAAW;AAChB,WAAO;AACP,WAAO;AAAA,EACT,GAAG,IAAI,GAGL,MAAM,IAAI;AAEd,MAAI,SAAS,QAAW;AACtB,WAAO,EAAE,KAAK;AAAA,EAChB;AAEA,SAAO;AACT;","names":[]}
@@ -1,58 +1,7 @@
1
- /**
2
- * {@link TimeoutManager} does not support passing arguments to the callback.
3
- *
4
- * `(_: void)` is the argument type inferred by TypeScript's default typings for
5
- * `setTimeout(cb, number)`.
6
- * If we don't accept a single void argument, then
7
- * `new Promise(resolve => timeoutManager.setTimeout(resolve, N))` is a type error.
8
- */
9
- type TimeoutCallback = (_: void) => void;
10
- /**
11
- * Wrapping `setTimeout` is awkward from a typing perspective because platform
12
- * typings may extend the return type of `setTimeout`. For example, NodeJS
13
- * typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be
14
- * able to return such a type.
15
- */
16
- type ManagedTimerId = number | {
17
- [Symbol.toPrimitive]: () => number;
18
- };
19
- /**
20
- * Backend for timer functions.
21
- */
22
- type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> = {
23
- readonly setTimeout: (callback: TimeoutCallback, delay: number) => TTimerId;
24
- readonly clearTimeout: (timeoutId: TTimerId | undefined) => void;
25
- readonly setInterval: (callback: TimeoutCallback, delay: number) => TTimerId;
26
- readonly clearInterval: (intervalId: TTimerId | undefined) => void;
27
- };
28
- declare const defaultTimeoutProvider: TimeoutProvider<ReturnType<typeof setTimeout>>;
29
- /**
30
- * Allows customization of how timeouts are created.
31
- *
32
- * @tanstack/query-core makes liberal use of timeouts to implement `staleTime`
33
- * and `gcTime`. The default TimeoutManager provider uses the platform's global
34
- * `setTimeout` implementation, which is known to have scalability issues with
35
- * thousands of timeouts on the event loop.
36
- *
37
- * If you hit this limitation, consider providing a custom TimeoutProvider that
38
- * coalesces timeouts.
39
- */
40
- declare class TimeoutManager implements Omit<TimeoutProvider, 'name'> {
41
- #private;
42
- setTimeoutProvider<TTimerId extends ManagedTimerId>(provider: TimeoutProvider<TTimerId>): void;
43
- setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId;
44
- clearTimeout(timeoutId: ManagedTimerId | undefined): void;
45
- setInterval(callback: TimeoutCallback, delay: number): ManagedTimerId;
46
- clearInterval(intervalId: ManagedTimerId | undefined): void;
47
- }
48
- declare const timeoutManager: TimeoutManager;
49
- /**
50
- * In many cases code wants to delay to the next event loop tick; this is not
51
- * mediated by {@link timeoutManager}.
52
- *
53
- * This function is provided to make auditing the `tanstack/query-core` for
54
- * incorrect use of system `setTimeout` easier.
55
- */
56
- declare function systemSetTimeoutZero(callback: TimeoutCallback): void;
57
-
58
- export { type ManagedTimerId, type TimeoutCallback, TimeoutManager, type TimeoutProvider, defaultTimeoutProvider, systemSetTimeoutZero, timeoutManager };
1
+ export { systemSetTimeoutZero } from './_tsup-dts-rollup.cjs';
2
+ export { TimeoutCallback_alias_1 as TimeoutCallback } from './_tsup-dts-rollup.cjs';
3
+ export { ManagedTimerId_alias_1 as ManagedTimerId } from './_tsup-dts-rollup.cjs';
4
+ export { TimeoutProvider_alias_1 as TimeoutProvider } from './_tsup-dts-rollup.cjs';
5
+ export { defaultTimeoutProvider } from './_tsup-dts-rollup.cjs';
6
+ export { TimeoutManager } from './_tsup-dts-rollup.cjs';
7
+ export { timeoutManager_alias_1 as timeoutManager } from './_tsup-dts-rollup.cjs';
@@ -1,58 +1,7 @@
1
- /**
2
- * {@link TimeoutManager} does not support passing arguments to the callback.
3
- *
4
- * `(_: void)` is the argument type inferred by TypeScript's default typings for
5
- * `setTimeout(cb, number)`.
6
- * If we don't accept a single void argument, then
7
- * `new Promise(resolve => timeoutManager.setTimeout(resolve, N))` is a type error.
8
- */
9
- type TimeoutCallback = (_: void) => void;
10
- /**
11
- * Wrapping `setTimeout` is awkward from a typing perspective because platform
12
- * typings may extend the return type of `setTimeout`. For example, NodeJS
13
- * typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be
14
- * able to return such a type.
15
- */
16
- type ManagedTimerId = number | {
17
- [Symbol.toPrimitive]: () => number;
18
- };
19
- /**
20
- * Backend for timer functions.
21
- */
22
- type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> = {
23
- readonly setTimeout: (callback: TimeoutCallback, delay: number) => TTimerId;
24
- readonly clearTimeout: (timeoutId: TTimerId | undefined) => void;
25
- readonly setInterval: (callback: TimeoutCallback, delay: number) => TTimerId;
26
- readonly clearInterval: (intervalId: TTimerId | undefined) => void;
27
- };
28
- declare const defaultTimeoutProvider: TimeoutProvider<ReturnType<typeof setTimeout>>;
29
- /**
30
- * Allows customization of how timeouts are created.
31
- *
32
- * @tanstack/query-core makes liberal use of timeouts to implement `staleTime`
33
- * and `gcTime`. The default TimeoutManager provider uses the platform's global
34
- * `setTimeout` implementation, which is known to have scalability issues with
35
- * thousands of timeouts on the event loop.
36
- *
37
- * If you hit this limitation, consider providing a custom TimeoutProvider that
38
- * coalesces timeouts.
39
- */
40
- declare class TimeoutManager implements Omit<TimeoutProvider, 'name'> {
41
- #private;
42
- setTimeoutProvider<TTimerId extends ManagedTimerId>(provider: TimeoutProvider<TTimerId>): void;
43
- setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId;
44
- clearTimeout(timeoutId: ManagedTimerId | undefined): void;
45
- setInterval(callback: TimeoutCallback, delay: number): ManagedTimerId;
46
- clearInterval(intervalId: ManagedTimerId | undefined): void;
47
- }
48
- declare const timeoutManager: TimeoutManager;
49
- /**
50
- * In many cases code wants to delay to the next event loop tick; this is not
51
- * mediated by {@link timeoutManager}.
52
- *
53
- * This function is provided to make auditing the `tanstack/query-core` for
54
- * incorrect use of system `setTimeout` easier.
55
- */
56
- declare function systemSetTimeoutZero(callback: TimeoutCallback): void;
57
-
58
- export { type ManagedTimerId, type TimeoutCallback, TimeoutManager, type TimeoutProvider, defaultTimeoutProvider, systemSetTimeoutZero, timeoutManager };
1
+ export { systemSetTimeoutZero } from './_tsup-dts-rollup.js';
2
+ export { TimeoutCallback_alias_1 as TimeoutCallback } from './_tsup-dts-rollup.js';
3
+ export { ManagedTimerId_alias_1 as ManagedTimerId } from './_tsup-dts-rollup.js';
4
+ export { TimeoutProvider_alias_1 as TimeoutProvider } from './_tsup-dts-rollup.js';
5
+ export { defaultTimeoutProvider } from './_tsup-dts-rollup.js';
6
+ export { TimeoutManager } from './_tsup-dts-rollup.js';
7
+ export { timeoutManager_alias_1 as timeoutManager } from './_tsup-dts-rollup.js';
@@ -25,9 +25,9 @@ __export(types_exports, {
25
25
  unsetMarker: () => unsetMarker
26
26
  });
27
27
  module.exports = __toCommonJS(types_exports);
28
- var dataTagSymbol = Symbol("dataTagSymbol");
29
- var dataTagErrorSymbol = Symbol("dataTagErrorSymbol");
30
- var unsetMarker = Symbol("unsetMarker");
28
+ var dataTagSymbol = /* @__PURE__ */ Symbol("dataTagSymbol");
29
+ var dataTagErrorSymbol = /* @__PURE__ */ Symbol("dataTagErrorSymbol");
30
+ var unsetMarker = /* @__PURE__ */ Symbol("unsetMarker");
31
31
  // Annotate the CommonJS export names for ESM import in node:
32
32
  0 && (module.exports = {
33
33
  dataTagErrorSymbol,