@tanstack/angular-pacer 0.23.1 → 0.25.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 (250) hide show
  1. package/README.md +21 -6
  2. package/dist/async-batcher/injectAsyncBatchedCallback.d.ts +2 -5
  3. package/dist/async-batcher/injectAsyncBatchedCallback.js +1 -2
  4. package/dist/async-batcher/injectAsyncBatcher.d.ts +4 -7
  5. package/dist/async-batcher/injectAsyncBatcher.js +1 -2
  6. package/dist/async-debouncer/injectAsyncDebouncedCallback.d.ts +2 -5
  7. package/dist/async-debouncer/injectAsyncDebouncedCallback.js +1 -2
  8. package/dist/async-debouncer/injectAsyncDebouncer.d.ts +4 -7
  9. package/dist/async-debouncer/injectAsyncDebouncer.js +1 -2
  10. package/dist/async-queuer/injectAsyncQueuedSignal.d.ts +3 -6
  11. package/dist/async-queuer/injectAsyncQueuedSignal.js +1 -2
  12. package/dist/async-queuer/injectAsyncQueuer.d.ts +4 -7
  13. package/dist/async-queuer/injectAsyncQueuer.js +1 -2
  14. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.d.ts +2 -5
  15. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.js +1 -2
  16. package/dist/async-rate-limiter/injectAsyncRateLimiter.d.ts +4 -7
  17. package/dist/async-rate-limiter/injectAsyncRateLimiter.js +1 -2
  18. package/dist/async-throttler/injectAsyncThrottledCallback.d.ts +2 -5
  19. package/dist/async-throttler/injectAsyncThrottledCallback.js +1 -2
  20. package/dist/async-throttler/injectAsyncThrottler.d.ts +4 -7
  21. package/dist/async-throttler/injectAsyncThrottler.js +1 -2
  22. package/dist/batcher/injectBatchedCallback.d.ts +2 -5
  23. package/dist/batcher/injectBatchedCallback.js +1 -2
  24. package/dist/batcher/injectBatcher.d.ts +4 -7
  25. package/dist/batcher/injectBatcher.js +1 -2
  26. package/dist/debouncer/injectDebouncedCallback.d.ts +2 -5
  27. package/dist/debouncer/injectDebouncedCallback.js +1 -2
  28. package/dist/debouncer/injectDebouncedSignal.d.ts +3 -6
  29. package/dist/debouncer/injectDebouncedSignal.js +1 -2
  30. package/dist/debouncer/injectDebouncedValue.d.ts +3 -6
  31. package/dist/debouncer/injectDebouncedValue.js +1 -2
  32. package/dist/debouncer/injectDebouncer.d.ts +4 -7
  33. package/dist/debouncer/injectDebouncer.js +1 -2
  34. package/dist/provider/pacer-context.d.ts +4 -7
  35. package/dist/provider/pacer-context.js +1 -2
  36. package/dist/provider/pacer-provider.d.ts +2 -5
  37. package/dist/provider/pacer-provider.js +1 -2
  38. package/dist/queuer/injectQueuedSignal.d.ts +3 -6
  39. package/dist/queuer/injectQueuedSignal.js +1 -2
  40. package/dist/queuer/injectQueuedValue.d.ts +3 -6
  41. package/dist/queuer/injectQueuedValue.js +1 -2
  42. package/dist/queuer/injectQueuer.d.ts +4 -7
  43. package/dist/queuer/injectQueuer.js +1 -2
  44. package/dist/rate-limiter/injectRateLimitedCallback.d.ts +2 -5
  45. package/dist/rate-limiter/injectRateLimitedCallback.js +1 -2
  46. package/dist/rate-limiter/injectRateLimitedSignal.d.ts +3 -6
  47. package/dist/rate-limiter/injectRateLimitedSignal.js +1 -2
  48. package/dist/rate-limiter/injectRateLimitedValue.d.ts +3 -6
  49. package/dist/rate-limiter/injectRateLimitedValue.js +1 -2
  50. package/dist/rate-limiter/injectRateLimiter.d.ts +4 -7
  51. package/dist/rate-limiter/injectRateLimiter.js +1 -2
  52. package/dist/throttler/injectThrottledCallback.d.ts +2 -5
  53. package/dist/throttler/injectThrottledCallback.js +1 -2
  54. package/dist/throttler/injectThrottledSignal.d.ts +3 -8
  55. package/dist/throttler/injectThrottledSignal.js +1 -4
  56. package/dist/throttler/injectThrottledValue.d.ts +3 -8
  57. package/dist/throttler/injectThrottledValue.js +1 -2
  58. package/dist/throttler/injectThrottler.d.ts +4 -9
  59. package/dist/throttler/injectThrottler.js +1 -4
  60. package/package.json +25 -72
  61. package/dist/async-batcher/index.cjs +0 -13
  62. package/dist/async-batcher/index.d.cts +0 -4
  63. package/dist/async-batcher/injectAsyncBatchedCallback.cjs +0 -49
  64. package/dist/async-batcher/injectAsyncBatchedCallback.cjs.map +0 -1
  65. package/dist/async-batcher/injectAsyncBatchedCallback.d.cts +0 -45
  66. package/dist/async-batcher/injectAsyncBatchedCallback.js.map +0 -1
  67. package/dist/async-batcher/injectAsyncBatcher.cjs +0 -85
  68. package/dist/async-batcher/injectAsyncBatcher.cjs.map +0 -1
  69. package/dist/async-batcher/injectAsyncBatcher.d.cts +0 -85
  70. package/dist/async-batcher/injectAsyncBatcher.js.map +0 -1
  71. package/dist/async-debouncer/index.cjs +0 -13
  72. package/dist/async-debouncer/index.d.cts +0 -4
  73. package/dist/async-debouncer/injectAsyncDebouncedCallback.cjs +0 -49
  74. package/dist/async-debouncer/injectAsyncDebouncedCallback.cjs.map +0 -1
  75. package/dist/async-debouncer/injectAsyncDebouncedCallback.d.cts +0 -43
  76. package/dist/async-debouncer/injectAsyncDebouncedCallback.js.map +0 -1
  77. package/dist/async-debouncer/injectAsyncDebouncer.cjs +0 -107
  78. package/dist/async-debouncer/injectAsyncDebouncer.cjs.map +0 -1
  79. package/dist/async-debouncer/injectAsyncDebouncer.d.cts +0 -108
  80. package/dist/async-debouncer/injectAsyncDebouncer.js.map +0 -1
  81. package/dist/async-queuer/index.cjs +0 -13
  82. package/dist/async-queuer/index.d.cts +0 -4
  83. package/dist/async-queuer/injectAsyncQueuedSignal.cjs +0 -53
  84. package/dist/async-queuer/injectAsyncQueuedSignal.cjs.map +0 -1
  85. package/dist/async-queuer/injectAsyncQueuedSignal.d.cts +0 -50
  86. package/dist/async-queuer/injectAsyncQueuedSignal.js.map +0 -1
  87. package/dist/async-queuer/injectAsyncQueuer.cjs +0 -85
  88. package/dist/async-queuer/injectAsyncQueuer.cjs.map +0 -1
  89. package/dist/async-queuer/injectAsyncQueuer.d.cts +0 -85
  90. package/dist/async-queuer/injectAsyncQueuer.js.map +0 -1
  91. package/dist/async-rate-limiter/index.cjs +0 -13
  92. package/dist/async-rate-limiter/index.d.cts +0 -4
  93. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.cjs +0 -52
  94. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.cjs.map +0 -1
  95. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.d.cts +0 -46
  96. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.js.map +0 -1
  97. package/dist/async-rate-limiter/injectAsyncRateLimiter.cjs +0 -69
  98. package/dist/async-rate-limiter/injectAsyncRateLimiter.cjs.map +0 -1
  99. package/dist/async-rate-limiter/injectAsyncRateLimiter.d.cts +0 -72
  100. package/dist/async-rate-limiter/injectAsyncRateLimiter.js.map +0 -1
  101. package/dist/async-retryer/index.cjs +0 -9
  102. package/dist/async-retryer/index.d.cts +0 -1
  103. package/dist/async-throttler/index.cjs +0 -13
  104. package/dist/async-throttler/index.d.cts +0 -4
  105. package/dist/async-throttler/injectAsyncThrottledCallback.cjs +0 -50
  106. package/dist/async-throttler/injectAsyncThrottledCallback.cjs.map +0 -1
  107. package/dist/async-throttler/injectAsyncThrottledCallback.d.cts +0 -44
  108. package/dist/async-throttler/injectAsyncThrottledCallback.js.map +0 -1
  109. package/dist/async-throttler/injectAsyncThrottler.cjs +0 -86
  110. package/dist/async-throttler/injectAsyncThrottler.cjs.map +0 -1
  111. package/dist/async-throttler/injectAsyncThrottler.d.cts +0 -87
  112. package/dist/async-throttler/injectAsyncThrottler.js.map +0 -1
  113. package/dist/batcher/index.cjs +0 -13
  114. package/dist/batcher/index.d.cts +0 -4
  115. package/dist/batcher/injectBatchedCallback.cjs +0 -47
  116. package/dist/batcher/injectBatchedCallback.cjs.map +0 -1
  117. package/dist/batcher/injectBatchedCallback.d.cts +0 -43
  118. package/dist/batcher/injectBatchedCallback.js.map +0 -1
  119. package/dist/batcher/injectBatcher.cjs +0 -75
  120. package/dist/batcher/injectBatcher.cjs.map +0 -1
  121. package/dist/batcher/injectBatcher.d.cts +0 -77
  122. package/dist/batcher/injectBatcher.js.map +0 -1
  123. package/dist/debouncer/index.cjs +0 -17
  124. package/dist/debouncer/index.d.cts +0 -6
  125. package/dist/debouncer/injectDebouncedCallback.cjs +0 -46
  126. package/dist/debouncer/injectDebouncedCallback.cjs.map +0 -1
  127. package/dist/debouncer/injectDebouncedCallback.d.cts +0 -43
  128. package/dist/debouncer/injectDebouncedCallback.js.map +0 -1
  129. package/dist/debouncer/injectDebouncedSignal.cjs +0 -68
  130. package/dist/debouncer/injectDebouncedSignal.cjs.map +0 -1
  131. package/dist/debouncer/injectDebouncedSignal.d.cts +0 -60
  132. package/dist/debouncer/injectDebouncedSignal.js.map +0 -1
  133. package/dist/debouncer/injectDebouncedValue.cjs +0 -17
  134. package/dist/debouncer/injectDebouncedValue.cjs.map +0 -1
  135. package/dist/debouncer/injectDebouncedValue.d.cts +0 -76
  136. package/dist/debouncer/injectDebouncedValue.js.map +0 -1
  137. package/dist/debouncer/injectDebouncer.cjs +0 -95
  138. package/dist/debouncer/injectDebouncer.cjs.map +0 -1
  139. package/dist/debouncer/injectDebouncer.d.cts +0 -98
  140. package/dist/debouncer/injectDebouncer.js.map +0 -1
  141. package/dist/index.cjs +0 -65
  142. package/dist/index.d.cts +0 -30
  143. package/dist/provider/index.cjs +0 -7
  144. package/dist/provider/index.d.cts +0 -3
  145. package/dist/provider/pacer-context.cjs +0 -20
  146. package/dist/provider/pacer-context.cjs.map +0 -1
  147. package/dist/provider/pacer-context.d.cts +0 -21
  148. package/dist/provider/pacer-context.js.map +0 -1
  149. package/dist/provider/pacer-provider.cjs +0 -41
  150. package/dist/provider/pacer-provider.cjs.map +0 -1
  151. package/dist/provider/pacer-provider.d.cts +0 -36
  152. package/dist/provider/pacer-provider.js.map +0 -1
  153. package/dist/queuer/index.cjs +0 -15
  154. package/dist/queuer/index.d.cts +0 -5
  155. package/dist/queuer/injectQueuedSignal.cjs +0 -47
  156. package/dist/queuer/injectQueuedSignal.cjs.map +0 -1
  157. package/dist/queuer/injectQueuedSignal.d.cts +0 -44
  158. package/dist/queuer/injectQueuedSignal.js.map +0 -1
  159. package/dist/queuer/injectQueuedValue.cjs +0 -23
  160. package/dist/queuer/injectQueuedValue.cjs.map +0 -1
  161. package/dist/queuer/injectQueuedValue.d.cts +0 -34
  162. package/dist/queuer/injectQueuedValue.js.map +0 -1
  163. package/dist/queuer/injectQueuer.cjs +0 -80
  164. package/dist/queuer/injectQueuer.cjs.map +0 -1
  165. package/dist/queuer/injectQueuer.d.cts +0 -82
  166. package/dist/queuer/injectQueuer.js.map +0 -1
  167. package/dist/rate-limiter/index.cjs +0 -17
  168. package/dist/rate-limiter/index.d.cts +0 -6
  169. package/dist/rate-limiter/injectRateLimitedCallback.cjs +0 -45
  170. package/dist/rate-limiter/injectRateLimitedCallback.cjs.map +0 -1
  171. package/dist/rate-limiter/injectRateLimitedCallback.d.cts +0 -42
  172. package/dist/rate-limiter/injectRateLimitedCallback.js.map +0 -1
  173. package/dist/rate-limiter/injectRateLimitedSignal.cjs +0 -62
  174. package/dist/rate-limiter/injectRateLimitedSignal.cjs.map +0 -1
  175. package/dist/rate-limiter/injectRateLimitedSignal.d.cts +0 -54
  176. package/dist/rate-limiter/injectRateLimitedSignal.js.map +0 -1
  177. package/dist/rate-limiter/injectRateLimitedValue.cjs +0 -17
  178. package/dist/rate-limiter/injectRateLimitedValue.cjs.map +0 -1
  179. package/dist/rate-limiter/injectRateLimitedValue.d.cts +0 -49
  180. package/dist/rate-limiter/injectRateLimitedValue.js.map +0 -1
  181. package/dist/rate-limiter/injectRateLimiter.cjs +0 -100
  182. package/dist/rate-limiter/injectRateLimiter.cjs.map +0 -1
  183. package/dist/rate-limiter/injectRateLimiter.d.cts +0 -103
  184. package/dist/rate-limiter/injectRateLimiter.js.map +0 -1
  185. package/dist/throttler/index.cjs +0 -17
  186. package/dist/throttler/index.d.cts +0 -6
  187. package/dist/throttler/injectThrottledCallback.cjs +0 -45
  188. package/dist/throttler/injectThrottledCallback.cjs.map +0 -1
  189. package/dist/throttler/injectThrottledCallback.d.cts +0 -42
  190. package/dist/throttler/injectThrottledCallback.js.map +0 -1
  191. package/dist/throttler/injectThrottledSignal.cjs +0 -69
  192. package/dist/throttler/injectThrottledSignal.cjs.map +0 -1
  193. package/dist/throttler/injectThrottledSignal.d.cts +0 -61
  194. package/dist/throttler/injectThrottledSignal.js.map +0 -1
  195. package/dist/throttler/injectThrottledValue.cjs +0 -17
  196. package/dist/throttler/injectThrottledValue.cjs.map +0 -1
  197. package/dist/throttler/injectThrottledValue.d.cts +0 -74
  198. package/dist/throttler/injectThrottledValue.js.map +0 -1
  199. package/dist/throttler/injectThrottler.cjs +0 -95
  200. package/dist/throttler/injectThrottler.cjs.map +0 -1
  201. package/dist/throttler/injectThrottler.d.cts +0 -98
  202. package/dist/throttler/injectThrottler.js.map +0 -1
  203. package/dist/types/index.cjs +0 -9
  204. package/dist/types/index.d.cts +0 -1
  205. package/dist/utils/index.cjs +0 -9
  206. package/dist/utils/index.d.cts +0 -1
  207. package/src/async-batcher/index.ts +0 -4
  208. package/src/async-batcher/injectAsyncBatchedCallback.ts +0 -48
  209. package/src/async-batcher/injectAsyncBatcher.ts +0 -126
  210. package/src/async-debouncer/index.ts +0 -4
  211. package/src/async-debouncer/injectAsyncDebouncedCallback.ts +0 -50
  212. package/src/async-debouncer/injectAsyncDebouncer.ts +0 -152
  213. package/src/async-queuer/index.ts +0 -4
  214. package/src/async-queuer/injectAsyncQueuedSignal.ts +0 -74
  215. package/src/async-queuer/injectAsyncQueuer.ts +0 -126
  216. package/src/async-rate-limiter/index.ts +0 -4
  217. package/src/async-rate-limiter/injectAsyncRateLimitedCallback.ts +0 -52
  218. package/src/async-rate-limiter/injectAsyncRateLimiter.ts +0 -115
  219. package/src/async-retryer/index.ts +0 -1
  220. package/src/async-throttler/index.ts +0 -4
  221. package/src/async-throttler/injectAsyncThrottledCallback.ts +0 -50
  222. package/src/async-throttler/injectAsyncThrottler.ts +0 -131
  223. package/src/batcher/index.ts +0 -4
  224. package/src/batcher/injectBatchedCallback.ts +0 -46
  225. package/src/batcher/injectBatcher.ts +0 -114
  226. package/src/debouncer/index.ts +0 -6
  227. package/src/debouncer/injectDebouncedCallback.ts +0 -46
  228. package/src/debouncer/injectDebouncedSignal.ts +0 -94
  229. package/src/debouncer/injectDebouncedValue.ts +0 -126
  230. package/src/debouncer/injectDebouncer.ts +0 -137
  231. package/src/index.ts +0 -40
  232. package/src/provider/index.ts +0 -2
  233. package/src/provider/pacer-context.ts +0 -46
  234. package/src/provider/pacer-provider.ts +0 -38
  235. package/src/queuer/index.ts +0 -5
  236. package/src/queuer/injectQueuedSignal.ts +0 -65
  237. package/src/queuer/injectQueuedValue.ts +0 -101
  238. package/src/queuer/injectQueuer.ts +0 -118
  239. package/src/rate-limiter/index.ts +0 -6
  240. package/src/rate-limiter/injectRateLimitedCallback.ts +0 -45
  241. package/src/rate-limiter/injectRateLimitedSignal.ts +0 -88
  242. package/src/rate-limiter/injectRateLimitedValue.ts +0 -99
  243. package/src/rate-limiter/injectRateLimiter.ts +0 -140
  244. package/src/throttler/index.ts +0 -6
  245. package/src/throttler/injectThrottledCallback.ts +0 -45
  246. package/src/throttler/injectThrottledSignal.ts +0 -95
  247. package/src/throttler/injectThrottledValue.ts +0 -124
  248. package/src/throttler/injectThrottler.ts +0 -137
  249. package/src/types/index.ts +0 -1
  250. package/src/utils/index.ts +0 -1
@@ -1,53 +0,0 @@
1
- const require_injectAsyncQueuer = require('./injectAsyncQueuer.cjs');
2
- let _angular_core = require("@angular/core");
3
-
4
- //#region src/async-queuer/injectAsyncQueuedSignal.ts
5
- /**
6
- * An Angular function that creates an async queuer with managed state, combining Angular's signals with async queuing functionality.
7
- * This function provides both the current queue state and queue control methods.
8
- *
9
- * The queue state is automatically updated whenever items are added, removed, or processed in the queue.
10
- * All queue operations are reflected in the state array returned by the function.
11
- *
12
- * The function returns a callable object:
13
- * - `queued()`: Get the current queue items as an array
14
- * - `queued.addItem(...)`: Add an item to the queue
15
- * - `queued.queue`: The queuer instance with additional control methods
16
- *
17
- * @example
18
- * ```ts
19
- * // Default behavior - track items
20
- * const queued = injectAsyncQueuedSignal(
21
- * async (item) => {
22
- * const response = await fetch('/api/process', {
23
- * method: 'POST',
24
- * body: JSON.stringify(item)
25
- * });
26
- * return response.json();
27
- * },
28
- * { concurrency: 2, wait: 1000 }
29
- * );
30
- *
31
- * // Add items
32
- * queued.addItem(data1);
33
- *
34
- * // Access items
35
- * console.log(queued()); // [data1, ...]
36
- *
37
- * // Control the queue
38
- * queued.queuer.start();
39
- * queued.queuer.stop();
40
- * ```
41
- */
42
- function injectAsyncQueuedSignal(fn, options = {}, selector = (state) => ({ items: state.items })) {
43
- const queuer = require_injectAsyncQueuer.injectAsyncQueuer(fn, options, selector);
44
- const items = (0, _angular_core.computed)(() => queuer.state().items);
45
- return Object.assign(items, {
46
- addItem: queuer.addItem.bind(queuer),
47
- queuer
48
- });
49
- }
50
-
51
- //#endregion
52
- exports.injectAsyncQueuedSignal = injectAsyncQueuedSignal;
53
- //# sourceMappingURL=injectAsyncQueuedSignal.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncQueuedSignal.cjs","names":["injectAsyncQueuer"],"sources":["../../src/async-queuer/injectAsyncQueuedSignal.ts"],"sourcesContent":["import { computed } from '@angular/core'\nimport { injectAsyncQueuer } from './injectAsyncQueuer'\nimport type { AngularAsyncQueuer } from './injectAsyncQueuer'\nimport type {\n AsyncQueuerOptions,\n AsyncQueuerState,\n} from '@tanstack/pacer/async-queuer'\n\nexport interface AsyncQueuedSignal<TValue, TSelected = {}> {\n (): Array<TValue>\n addItem: AngularAsyncQueuer<TValue, TSelected>['addItem']\n queuer: AngularAsyncQueuer<TValue, TSelected>\n}\n\n/**\n * An Angular function that creates an async queuer with managed state, combining Angular's signals with async queuing functionality.\n * This function provides both the current queue state and queue control methods.\n *\n * The queue state is automatically updated whenever items are added, removed, or processed in the queue.\n * All queue operations are reflected in the state array returned by the function.\n *\n * The function returns a callable object:\n * - `queued()`: Get the current queue items as an array\n * - `queued.addItem(...)`: Add an item to the queue\n * - `queued.queue`: The queuer instance with additional control methods\n *\n * @example\n * ```ts\n * // Default behavior - track items\n * const queued = injectAsyncQueuedSignal(\n * async (item) => {\n * const response = await fetch('/api/process', {\n * method: 'POST',\n * body: JSON.stringify(item)\n * });\n * return response.json();\n * },\n * { concurrency: 2, wait: 1000 }\n * );\n *\n * // Add items\n * queued.addItem(data1);\n *\n * // Access items\n * console.log(queued()); // [data1, ...]\n *\n * // Control the queue\n * queued.queuer.start();\n * queued.queuer.stop();\n * ```\n */\nexport function injectAsyncQueuedSignal<\n TValue,\n TSelected extends Pick<AsyncQueuerState<TValue>, 'items'> = Pick<\n AsyncQueuerState<TValue>,\n 'items'\n >,\n>(\n fn: (value: TValue) => Promise<any>,\n options: AsyncQueuerOptions<TValue> = {},\n selector: (state: AsyncQueuerState<TValue>) => TSelected = (state) =>\n ({ items: state.items }) as TSelected,\n): AsyncQueuedSignal<TValue, TSelected> {\n const queuer = injectAsyncQueuer(fn, options, selector)\n\n const items = computed(() => queuer.state().items as Array<TValue>)\n\n const queued = Object.assign(items, {\n addItem: queuer.addItem.bind(queuer),\n queuer,\n }) as AsyncQueuedSignal<TValue, TSelected>\n\n return queued\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,SAAgB,wBAOd,IACA,UAAsC,EAAE,EACxC,YAA4D,WACzD,EAAE,OAAO,MAAM,OAAO,GACa;CACtC,MAAM,SAASA,4CAAkB,IAAI,SAAS,SAAS;CAEvD,MAAM,0CAAuB,OAAO,OAAO,CAAC,MAAuB;CAOnE,OALe,OAAO,OAAO,OAAO;EAClC,SAAS,OAAO,QAAQ,KAAK,OAAO;EACpC;EACD,CAEY"}
@@ -1,50 +0,0 @@
1
- import { AngularAsyncQueuer } from "./injectAsyncQueuer.cjs";
2
- import { AsyncQueuerOptions, AsyncQueuerState } from "@tanstack/pacer/async-queuer";
3
-
4
- //#region src/async-queuer/injectAsyncQueuedSignal.d.ts
5
- interface AsyncQueuedSignal<TValue, TSelected = {}> {
6
- (): Array<TValue>;
7
- addItem: AngularAsyncQueuer<TValue, TSelected>['addItem'];
8
- queuer: AngularAsyncQueuer<TValue, TSelected>;
9
- }
10
- /**
11
- * An Angular function that creates an async queuer with managed state, combining Angular's signals with async queuing functionality.
12
- * This function provides both the current queue state and queue control methods.
13
- *
14
- * The queue state is automatically updated whenever items are added, removed, or processed in the queue.
15
- * All queue operations are reflected in the state array returned by the function.
16
- *
17
- * The function returns a callable object:
18
- * - `queued()`: Get the current queue items as an array
19
- * - `queued.addItem(...)`: Add an item to the queue
20
- * - `queued.queue`: The queuer instance with additional control methods
21
- *
22
- * @example
23
- * ```ts
24
- * // Default behavior - track items
25
- * const queued = injectAsyncQueuedSignal(
26
- * async (item) => {
27
- * const response = await fetch('/api/process', {
28
- * method: 'POST',
29
- * body: JSON.stringify(item)
30
- * });
31
- * return response.json();
32
- * },
33
- * { concurrency: 2, wait: 1000 }
34
- * );
35
- *
36
- * // Add items
37
- * queued.addItem(data1);
38
- *
39
- * // Access items
40
- * console.log(queued()); // [data1, ...]
41
- *
42
- * // Control the queue
43
- * queued.queuer.start();
44
- * queued.queuer.stop();
45
- * ```
46
- */
47
- declare function injectAsyncQueuedSignal<TValue, TSelected extends Pick<AsyncQueuerState<TValue>, 'items'> = Pick<AsyncQueuerState<TValue>, 'items'>>(fn: (value: TValue) => Promise<any>, options?: AsyncQueuerOptions<TValue>, selector?: (state: AsyncQueuerState<TValue>) => TSelected): AsyncQueuedSignal<TValue, TSelected>;
48
- //#endregion
49
- export { AsyncQueuedSignal, injectAsyncQueuedSignal };
50
- //# sourceMappingURL=injectAsyncQueuedSignal.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncQueuedSignal.js","names":[],"sources":["../../src/async-queuer/injectAsyncQueuedSignal.ts"],"sourcesContent":["import { computed } from '@angular/core'\nimport { injectAsyncQueuer } from './injectAsyncQueuer'\nimport type { AngularAsyncQueuer } from './injectAsyncQueuer'\nimport type {\n AsyncQueuerOptions,\n AsyncQueuerState,\n} from '@tanstack/pacer/async-queuer'\n\nexport interface AsyncQueuedSignal<TValue, TSelected = {}> {\n (): Array<TValue>\n addItem: AngularAsyncQueuer<TValue, TSelected>['addItem']\n queuer: AngularAsyncQueuer<TValue, TSelected>\n}\n\n/**\n * An Angular function that creates an async queuer with managed state, combining Angular's signals with async queuing functionality.\n * This function provides both the current queue state and queue control methods.\n *\n * The queue state is automatically updated whenever items are added, removed, or processed in the queue.\n * All queue operations are reflected in the state array returned by the function.\n *\n * The function returns a callable object:\n * - `queued()`: Get the current queue items as an array\n * - `queued.addItem(...)`: Add an item to the queue\n * - `queued.queue`: The queuer instance with additional control methods\n *\n * @example\n * ```ts\n * // Default behavior - track items\n * const queued = injectAsyncQueuedSignal(\n * async (item) => {\n * const response = await fetch('/api/process', {\n * method: 'POST',\n * body: JSON.stringify(item)\n * });\n * return response.json();\n * },\n * { concurrency: 2, wait: 1000 }\n * );\n *\n * // Add items\n * queued.addItem(data1);\n *\n * // Access items\n * console.log(queued()); // [data1, ...]\n *\n * // Control the queue\n * queued.queuer.start();\n * queued.queuer.stop();\n * ```\n */\nexport function injectAsyncQueuedSignal<\n TValue,\n TSelected extends Pick<AsyncQueuerState<TValue>, 'items'> = Pick<\n AsyncQueuerState<TValue>,\n 'items'\n >,\n>(\n fn: (value: TValue) => Promise<any>,\n options: AsyncQueuerOptions<TValue> = {},\n selector: (state: AsyncQueuerState<TValue>) => TSelected = (state) =>\n ({ items: state.items }) as TSelected,\n): AsyncQueuedSignal<TValue, TSelected> {\n const queuer = injectAsyncQueuer(fn, options, selector)\n\n const items = computed(() => queuer.state().items as Array<TValue>)\n\n const queued = Object.assign(items, {\n addItem: queuer.addItem.bind(queuer),\n queuer,\n }) as AsyncQueuedSignal<TValue, TSelected>\n\n return queued\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,SAAgB,wBAOd,IACA,UAAsC,EAAE,EACxC,YAA4D,WACzD,EAAE,OAAO,MAAM,OAAO,GACa;CACtC,MAAM,SAAS,kBAAkB,IAAI,SAAS,SAAS;CAEvD,MAAM,QAAQ,eAAe,OAAO,OAAO,CAAC,MAAuB;CAOnE,OALe,OAAO,OAAO,OAAO;EAClC,SAAS,OAAO,QAAQ,KAAK,OAAO;EACpC;EACD,CAEY"}
@@ -1,85 +0,0 @@
1
- const require_pacer_context = require('../provider/pacer-context.cjs');
2
- let _angular_core = require("@angular/core");
3
- let _tanstack_angular_store = require("@tanstack/angular-store");
4
- let _tanstack_pacer_async_queuer = require("@tanstack/pacer/async-queuer");
5
-
6
- //#region src/async-queuer/injectAsyncQueuer.ts
7
- /**
8
- * An Angular function that creates and manages an AsyncQueuer instance.
9
- *
10
- * This is a lower-level function that provides direct access to the AsyncQueuer's functionality.
11
- * This allows you to integrate it with any state management solution you prefer.
12
- *
13
- * The AsyncQueuer processes items asynchronously with support for concurrent execution,
14
- * promise-based processing, error handling, retry capabilities, and abort support.
15
- *
16
- * ## State Management and Selector
17
- *
18
- * The function uses TanStack Store for state management and wraps it with Angular signals.
19
- * The `selector` parameter allows you to specify which state changes will trigger signal updates,
20
- * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.
21
- *
22
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
23
- * tracking by providing a selector function. This prevents unnecessary updates and gives you
24
- * full control over when your component tracks state changes.
25
- *
26
- * ## Cleanup on Destroy
27
- *
28
- * By default, the function stops the queuer and aborts in-flight work when the component is destroyed.
29
- * Use the `onUnmount` option to customize this. For example, to flush pending items instead:
30
- *
31
- * ```ts
32
- * const queuer = injectAsyncQueuer(fn, {
33
- * concurrency: 2,
34
- * onUnmount: (q) => q.flush()
35
- * });
36
- * ```
37
- *
38
- * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.
39
- *
40
- * @example
41
- * ```ts
42
- * // Default behavior - no reactive state subscriptions
43
- * const queuer = injectAsyncQueuer(
44
- * async (item: Data) => {
45
- * const response = await fetch('/api/process', {
46
- * method: 'POST',
47
- * body: JSON.stringify(item)
48
- * });
49
- * return response.json();
50
- * },
51
- * { concurrency: 2, wait: 1000 }
52
- * );
53
- *
54
- * // Add items
55
- * queuer.addItem(data1);
56
- * queuer.addItem(data2);
57
- *
58
- * // Access the selected state
59
- * const { items, isExecuting } = queuer.state();
60
- * ```
61
- */
62
- function injectAsyncQueuer(fn, options = {}, selector = () => ({})) {
63
- const mergedOptions = {
64
- ...require_pacer_context.injectPacerOptions().asyncQueuer,
65
- ...options
66
- };
67
- const queuer = new _tanstack_pacer_async_queuer.AsyncQueuer(fn, mergedOptions);
68
- const state = (0, _tanstack_angular_store.injectSelector)(queuer.store, selector);
69
- const result = {
70
- ...queuer,
71
- state
72
- };
73
- (0, _angular_core.inject)(_angular_core.DestroyRef, { optional: true })?.onDestroy(() => {
74
- if (mergedOptions.onUnmount) mergedOptions.onUnmount(result);
75
- else {
76
- queuer.stop();
77
- queuer.abort();
78
- }
79
- });
80
- return result;
81
- }
82
-
83
- //#endregion
84
- exports.injectAsyncQueuer = injectAsyncQueuer;
85
- //# sourceMappingURL=injectAsyncQueuer.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncQueuer.cjs","names":["injectPacerOptions","AsyncQueuer","DestroyRef"],"sources":["../../src/async-queuer/injectAsyncQueuer.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { AsyncQueuer } from '@tanstack/pacer/async-queuer'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type {\n AsyncQueuerOptions,\n AsyncQueuerState,\n} from '@tanstack/pacer/async-queuer'\n\nexport interface AngularAsyncQueuerOptions<\n TValue,\n TSelected = {},\n> extends AsyncQueuerOptions<TValue> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the queuer instance.\n * When provided, replaces the default cleanup (stop + abort); use it to call flush(), stop(), add logging, etc.\n * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.\n */\n onUnmount?: (queuer: AngularAsyncQueuer<TValue, TSelected>) => void\n}\n\nexport interface AngularAsyncQueuer<TValue, TSelected = {}> extends Omit<\n AsyncQueuer<TValue>,\n 'store'\n> {\n /**\n * Reactive state signal that will be updated when the async queuer state changes\n *\n * Use this instead of `queuer.store.state`\n */\n readonly state: Signal<Readonly<TSelected>>\n /**\n * @deprecated Use `queuer.state` instead of `queuer.store.state` if you want to read reactive state.\n * The state on the store object is not reactive in Angular signals.\n */\n readonly store: Store<Readonly<AsyncQueuerState<TValue>>>\n}\n\n/**\n * An Angular function that creates and manages an AsyncQueuer instance.\n *\n * This is a lower-level function that provides direct access to the AsyncQueuer's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * The AsyncQueuer processes items asynchronously with support for concurrent execution,\n * promise-based processing, error handling, retry capabilities, and abort support.\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for state management and wraps it with Angular signals.\n * The `selector` parameter allows you to specify which state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary updates and gives you\n * full control over when your component tracks state changes.\n *\n * ## Cleanup on Destroy\n *\n * By default, the function stops the queuer and aborts in-flight work when the component is destroyed.\n * Use the `onUnmount` option to customize this. For example, to flush pending items instead:\n *\n * ```ts\n * const queuer = injectAsyncQueuer(fn, {\n * concurrency: 2,\n * onUnmount: (q) => q.flush()\n * });\n * ```\n *\n * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const queuer = injectAsyncQueuer(\n * async (item: Data) => {\n * const response = await fetch('/api/process', {\n * method: 'POST',\n * body: JSON.stringify(item)\n * });\n * return response.json();\n * },\n * { concurrency: 2, wait: 1000 }\n * );\n *\n * // Add items\n * queuer.addItem(data1);\n * queuer.addItem(data2);\n *\n * // Access the selected state\n * const { items, isExecuting } = queuer.state();\n * ```\n */\nexport function injectAsyncQueuer<TValue, TSelected = {}>(\n fn: (value: TValue) => Promise<any>,\n options: AngularAsyncQueuerOptions<TValue, TSelected> = {},\n selector: (state: AsyncQueuerState<TValue>) => TSelected = () =>\n ({}) as TSelected,\n): AngularAsyncQueuer<TValue, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().asyncQueuer,\n ...options,\n } as AngularAsyncQueuerOptions<TValue, TSelected>\n\n const queuer = new AsyncQueuer<TValue>(fn, mergedOptions)\n const state = injectSelector(queuer.store, selector)\n\n const result = {\n ...queuer,\n state,\n } as AngularAsyncQueuer<TValue, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n } else {\n queuer.stop()\n queuer.abort()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+FA,SAAgB,kBACd,IACA,UAAwD,EAAE,EAC1D,kBACG,EAAE,GACkC;CACvC,MAAM,gBAAgB;EACpB,GAAGA,0CAAoB,CAAC;EACxB,GAAG;EACJ;CAED,MAAM,SAAS,IAAIC,yCAAoB,IAAI,cAAc;CACzD,MAAM,oDAAuB,OAAO,OAAO,SAAS;CAEpD,MAAM,SAAS;EACb,GAAG;EACH;EACD;CAGD,0BAD0BC,0BAAY,EAAE,UAAU,MAAM,CAC9C,EAAE,gBAAgB;EAC1B,IAAI,cAAc,WAChB,cAAc,UAAU,OAAO;OAC1B;GACL,OAAO,MAAM;GACb,OAAO,OAAO;;GAEhB;CAEF,OAAO"}
@@ -1,85 +0,0 @@
1
- import { Signal } from "@angular/core";
2
- import { Store } from "@tanstack/angular-store";
3
- import { AsyncQueuer, AsyncQueuerOptions, AsyncQueuerState } from "@tanstack/pacer/async-queuer";
4
-
5
- //#region src/async-queuer/injectAsyncQueuer.d.ts
6
- interface AngularAsyncQueuerOptions<TValue, TSelected = {}> extends AsyncQueuerOptions<TValue> {
7
- /**
8
- * Optional callback invoked when the component is destroyed. Receives the queuer instance.
9
- * When provided, replaces the default cleanup (stop + abort); use it to call flush(), stop(), add logging, etc.
10
- * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.
11
- */
12
- onUnmount?: (queuer: AngularAsyncQueuer<TValue, TSelected>) => void;
13
- }
14
- interface AngularAsyncQueuer<TValue, TSelected = {}> extends Omit<AsyncQueuer<TValue>, 'store'> {
15
- /**
16
- * Reactive state signal that will be updated when the async queuer state changes
17
- *
18
- * Use this instead of `queuer.store.state`
19
- */
20
- readonly state: Signal<Readonly<TSelected>>;
21
- /**
22
- * @deprecated Use `queuer.state` instead of `queuer.store.state` if you want to read reactive state.
23
- * The state on the store object is not reactive in Angular signals.
24
- */
25
- readonly store: Store<Readonly<AsyncQueuerState<TValue>>>;
26
- }
27
- /**
28
- * An Angular function that creates and manages an AsyncQueuer instance.
29
- *
30
- * This is a lower-level function that provides direct access to the AsyncQueuer's functionality.
31
- * This allows you to integrate it with any state management solution you prefer.
32
- *
33
- * The AsyncQueuer processes items asynchronously with support for concurrent execution,
34
- * promise-based processing, error handling, retry capabilities, and abort support.
35
- *
36
- * ## State Management and Selector
37
- *
38
- * The function uses TanStack Store for state management and wraps it with Angular signals.
39
- * The `selector` parameter allows you to specify which state changes will trigger signal updates,
40
- * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.
41
- *
42
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
43
- * tracking by providing a selector function. This prevents unnecessary updates and gives you
44
- * full control over when your component tracks state changes.
45
- *
46
- * ## Cleanup on Destroy
47
- *
48
- * By default, the function stops the queuer and aborts in-flight work when the component is destroyed.
49
- * Use the `onUnmount` option to customize this. For example, to flush pending items instead:
50
- *
51
- * ```ts
52
- * const queuer = injectAsyncQueuer(fn, {
53
- * concurrency: 2,
54
- * onUnmount: (q) => q.flush()
55
- * });
56
- * ```
57
- *
58
- * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.
59
- *
60
- * @example
61
- * ```ts
62
- * // Default behavior - no reactive state subscriptions
63
- * const queuer = injectAsyncQueuer(
64
- * async (item: Data) => {
65
- * const response = await fetch('/api/process', {
66
- * method: 'POST',
67
- * body: JSON.stringify(item)
68
- * });
69
- * return response.json();
70
- * },
71
- * { concurrency: 2, wait: 1000 }
72
- * );
73
- *
74
- * // Add items
75
- * queuer.addItem(data1);
76
- * queuer.addItem(data2);
77
- *
78
- * // Access the selected state
79
- * const { items, isExecuting } = queuer.state();
80
- * ```
81
- */
82
- declare function injectAsyncQueuer<TValue, TSelected = {}>(fn: (value: TValue) => Promise<any>, options?: AngularAsyncQueuerOptions<TValue, TSelected>, selector?: (state: AsyncQueuerState<TValue>) => TSelected): AngularAsyncQueuer<TValue, TSelected>;
83
- //#endregion
84
- export { AngularAsyncQueuer, AngularAsyncQueuerOptions, injectAsyncQueuer };
85
- //# sourceMappingURL=injectAsyncQueuer.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncQueuer.js","names":[],"sources":["../../src/async-queuer/injectAsyncQueuer.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { AsyncQueuer } from '@tanstack/pacer/async-queuer'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type {\n AsyncQueuerOptions,\n AsyncQueuerState,\n} from '@tanstack/pacer/async-queuer'\n\nexport interface AngularAsyncQueuerOptions<\n TValue,\n TSelected = {},\n> extends AsyncQueuerOptions<TValue> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the queuer instance.\n * When provided, replaces the default cleanup (stop + abort); use it to call flush(), stop(), add logging, etc.\n * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.\n */\n onUnmount?: (queuer: AngularAsyncQueuer<TValue, TSelected>) => void\n}\n\nexport interface AngularAsyncQueuer<TValue, TSelected = {}> extends Omit<\n AsyncQueuer<TValue>,\n 'store'\n> {\n /**\n * Reactive state signal that will be updated when the async queuer state changes\n *\n * Use this instead of `queuer.store.state`\n */\n readonly state: Signal<Readonly<TSelected>>\n /**\n * @deprecated Use `queuer.state` instead of `queuer.store.state` if you want to read reactive state.\n * The state on the store object is not reactive in Angular signals.\n */\n readonly store: Store<Readonly<AsyncQueuerState<TValue>>>\n}\n\n/**\n * An Angular function that creates and manages an AsyncQueuer instance.\n *\n * This is a lower-level function that provides direct access to the AsyncQueuer's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * The AsyncQueuer processes items asynchronously with support for concurrent execution,\n * promise-based processing, error handling, retry capabilities, and abort support.\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for state management and wraps it with Angular signals.\n * The `selector` parameter allows you to specify which state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary updates and gives you\n * full control over when your component tracks state changes.\n *\n * ## Cleanup on Destroy\n *\n * By default, the function stops the queuer and aborts in-flight work when the component is destroyed.\n * Use the `onUnmount` option to customize this. For example, to flush pending items instead:\n *\n * ```ts\n * const queuer = injectAsyncQueuer(fn, {\n * concurrency: 2,\n * onUnmount: (q) => q.flush()\n * });\n * ```\n *\n * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const queuer = injectAsyncQueuer(\n * async (item: Data) => {\n * const response = await fetch('/api/process', {\n * method: 'POST',\n * body: JSON.stringify(item)\n * });\n * return response.json();\n * },\n * { concurrency: 2, wait: 1000 }\n * );\n *\n * // Add items\n * queuer.addItem(data1);\n * queuer.addItem(data2);\n *\n * // Access the selected state\n * const { items, isExecuting } = queuer.state();\n * ```\n */\nexport function injectAsyncQueuer<TValue, TSelected = {}>(\n fn: (value: TValue) => Promise<any>,\n options: AngularAsyncQueuerOptions<TValue, TSelected> = {},\n selector: (state: AsyncQueuerState<TValue>) => TSelected = () =>\n ({}) as TSelected,\n): AngularAsyncQueuer<TValue, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().asyncQueuer,\n ...options,\n } as AngularAsyncQueuerOptions<TValue, TSelected>\n\n const queuer = new AsyncQueuer<TValue>(fn, mergedOptions)\n const state = injectSelector(queuer.store, selector)\n\n const result = {\n ...queuer,\n state,\n } as AngularAsyncQueuer<TValue, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n } else {\n queuer.stop()\n queuer.abort()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+FA,SAAgB,kBACd,IACA,UAAwD,EAAE,EAC1D,kBACG,EAAE,GACkC;CACvC,MAAM,gBAAgB;EACpB,GAAG,oBAAoB,CAAC;EACxB,GAAG;EACJ;CAED,MAAM,SAAS,IAAI,YAAoB,IAAI,cAAc;CACzD,MAAM,QAAQ,eAAe,OAAO,OAAO,SAAS;CAEpD,MAAM,SAAS;EACb,GAAG;EACH;EACD;CAGD,AADmB,OAAO,YAAY,EAAE,UAAU,MAAM,CAC9C,EAAE,gBAAgB;EAC1B,IAAI,cAAc,WAChB,cAAc,UAAU,OAAO;OAC1B;GACL,OAAO,MAAM;GACb,OAAO,OAAO;;GAEhB;CAEF,OAAO"}
@@ -1,13 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_injectAsyncRateLimiter = require('./injectAsyncRateLimiter.cjs');
3
- const require_injectAsyncRateLimitedCallback = require('./injectAsyncRateLimitedCallback.cjs');
4
-
5
- exports.injectAsyncRateLimitedCallback = require_injectAsyncRateLimitedCallback.injectAsyncRateLimitedCallback;
6
- exports.injectAsyncRateLimiter = require_injectAsyncRateLimiter.injectAsyncRateLimiter;
7
- var _tanstack_pacer_async_rate_limiter = require("@tanstack/pacer/async-rate-limiter");
8
- Object.keys(_tanstack_pacer_async_rate_limiter).forEach(function (k) {
9
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
10
- enumerable: true,
11
- get: function () { return _tanstack_pacer_async_rate_limiter[k]; }
12
- });
13
- });
@@ -1,4 +0,0 @@
1
- import { injectAsyncRateLimitedCallback } from "./injectAsyncRateLimitedCallback.cjs";
2
- import { AngularAsyncRateLimiter, AngularAsyncRateLimiterOptions, injectAsyncRateLimiter } from "./injectAsyncRateLimiter.cjs";
3
- export * from "@tanstack/pacer/async-rate-limiter";
4
- export { AngularAsyncRateLimiter, AngularAsyncRateLimiterOptions, injectAsyncRateLimitedCallback, injectAsyncRateLimiter };
@@ -1,52 +0,0 @@
1
- const require_injectAsyncRateLimiter = require('./injectAsyncRateLimiter.cjs');
2
-
3
- //#region src/async-rate-limiter/injectAsyncRateLimitedCallback.ts
4
- /**
5
- * An Angular function that creates an async rate-limited version of a callback function.
6
- * This function is essentially a wrapper around `injectAsyncRateLimiter` that provides
7
- * a simplified API for basic async rate limiting needs.
8
- *
9
- * This function provides a simpler API compared to `injectAsyncRateLimiter`, making it ideal for basic
10
- * async rate limiting needs. However, it does not expose the underlying AsyncRateLimiter instance.
11
- *
12
- * For advanced usage requiring features like:
13
- * - Manual cancellation/reset
14
- * - Access to execution counts
15
- * - Error handling callbacks
16
- * - Retry support
17
- *
18
- * Consider using the `injectAsyncRateLimiter` function instead.
19
- *
20
- * @example
21
- * ```ts
22
- * // Rate limit API calls
23
- * const makeApiCall = injectAsyncRateLimitedCallback(
24
- * async (data: ApiData) => {
25
- * const response = await fetch('/api/endpoint', {
26
- * method: 'POST',
27
- * body: JSON.stringify(data)
28
- * });
29
- * return response.json();
30
- * },
31
- * {
32
- * limit: 5,
33
- * window: 60000,
34
- * windowType: 'sliding',
35
- * }
36
- * );
37
- *
38
- * // Use in event handler
39
- * const result = await makeApiCall(apiData);
40
- * ```
41
- */
42
- function injectAsyncRateLimitedCallback(fn, options) {
43
- const rateLimiter = require_injectAsyncRateLimiter.injectAsyncRateLimiter(fn, options);
44
- return async (...args) => {
45
- const result = await rateLimiter.maybeExecute(...args);
46
- return result !== void 0 ? await result : void 0;
47
- };
48
- }
49
-
50
- //#endregion
51
- exports.injectAsyncRateLimitedCallback = injectAsyncRateLimitedCallback;
52
- //# sourceMappingURL=injectAsyncRateLimitedCallback.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncRateLimitedCallback.cjs","names":["injectAsyncRateLimiter"],"sources":["../../src/async-rate-limiter/injectAsyncRateLimitedCallback.ts"],"sourcesContent":["import { injectAsyncRateLimiter } from './injectAsyncRateLimiter'\nimport type { AsyncRateLimiterOptions } from '@tanstack/pacer/async-rate-limiter'\nimport type { AnyAsyncFunction } from '@tanstack/pacer/types'\n\n/**\n * An Angular function that creates an async rate-limited version of a callback function.\n * This function is essentially a wrapper around `injectAsyncRateLimiter` that provides\n * a simplified API for basic async rate limiting needs.\n *\n * This function provides a simpler API compared to `injectAsyncRateLimiter`, making it ideal for basic\n * async rate limiting needs. However, it does not expose the underlying AsyncRateLimiter instance.\n *\n * For advanced usage requiring features like:\n * - Manual cancellation/reset\n * - Access to execution counts\n * - Error handling callbacks\n * - Retry support\n *\n * Consider using the `injectAsyncRateLimiter` function instead.\n *\n * @example\n * ```ts\n * // Rate limit API calls\n * const makeApiCall = injectAsyncRateLimitedCallback(\n * async (data: ApiData) => {\n * const response = await fetch('/api/endpoint', {\n * method: 'POST',\n * body: JSON.stringify(data)\n * });\n * return response.json();\n * },\n * {\n * limit: 5,\n * window: 60000,\n * windowType: 'sliding',\n * }\n * );\n *\n * // Use in event handler\n * const result = await makeApiCall(apiData);\n * ```\n */\nexport function injectAsyncRateLimitedCallback<TFn extends AnyAsyncFunction>(\n fn: TFn,\n options: AsyncRateLimiterOptions<TFn>,\n): (...args: Parameters<TFn>) => Promise<Awaited<ReturnType<TFn>> | undefined> {\n const rateLimiter = injectAsyncRateLimiter(fn, options)\n return async (...args: Parameters<TFn>) => {\n const result = await rateLimiter.maybeExecute(...args)\n return result !== undefined ? await result : undefined\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAgB,+BACd,IACA,SAC6E;CAC7E,MAAM,cAAcA,sDAAuB,IAAI,QAAQ;CACvD,OAAO,OAAO,GAAG,SAA0B;EACzC,MAAM,SAAS,MAAM,YAAY,aAAa,GAAG,KAAK;EACtD,OAAO,WAAW,SAAY,MAAM,SAAS"}
@@ -1,46 +0,0 @@
1
- import { AnyAsyncFunction } from "@tanstack/pacer/types";
2
- import { AsyncRateLimiterOptions } from "@tanstack/pacer/async-rate-limiter";
3
-
4
- //#region src/async-rate-limiter/injectAsyncRateLimitedCallback.d.ts
5
- /**
6
- * An Angular function that creates an async rate-limited version of a callback function.
7
- * This function is essentially a wrapper around `injectAsyncRateLimiter` that provides
8
- * a simplified API for basic async rate limiting needs.
9
- *
10
- * This function provides a simpler API compared to `injectAsyncRateLimiter`, making it ideal for basic
11
- * async rate limiting needs. However, it does not expose the underlying AsyncRateLimiter instance.
12
- *
13
- * For advanced usage requiring features like:
14
- * - Manual cancellation/reset
15
- * - Access to execution counts
16
- * - Error handling callbacks
17
- * - Retry support
18
- *
19
- * Consider using the `injectAsyncRateLimiter` function instead.
20
- *
21
- * @example
22
- * ```ts
23
- * // Rate limit API calls
24
- * const makeApiCall = injectAsyncRateLimitedCallback(
25
- * async (data: ApiData) => {
26
- * const response = await fetch('/api/endpoint', {
27
- * method: 'POST',
28
- * body: JSON.stringify(data)
29
- * });
30
- * return response.json();
31
- * },
32
- * {
33
- * limit: 5,
34
- * window: 60000,
35
- * windowType: 'sliding',
36
- * }
37
- * );
38
- *
39
- * // Use in event handler
40
- * const result = await makeApiCall(apiData);
41
- * ```
42
- */
43
- declare function injectAsyncRateLimitedCallback<TFn extends AnyAsyncFunction>(fn: TFn, options: AsyncRateLimiterOptions<TFn>): (...args: Parameters<TFn>) => Promise<Awaited<ReturnType<TFn>> | undefined>;
44
- //#endregion
45
- export { injectAsyncRateLimitedCallback };
46
- //# sourceMappingURL=injectAsyncRateLimitedCallback.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncRateLimitedCallback.js","names":[],"sources":["../../src/async-rate-limiter/injectAsyncRateLimitedCallback.ts"],"sourcesContent":["import { injectAsyncRateLimiter } from './injectAsyncRateLimiter'\nimport type { AsyncRateLimiterOptions } from '@tanstack/pacer/async-rate-limiter'\nimport type { AnyAsyncFunction } from '@tanstack/pacer/types'\n\n/**\n * An Angular function that creates an async rate-limited version of a callback function.\n * This function is essentially a wrapper around `injectAsyncRateLimiter` that provides\n * a simplified API for basic async rate limiting needs.\n *\n * This function provides a simpler API compared to `injectAsyncRateLimiter`, making it ideal for basic\n * async rate limiting needs. However, it does not expose the underlying AsyncRateLimiter instance.\n *\n * For advanced usage requiring features like:\n * - Manual cancellation/reset\n * - Access to execution counts\n * - Error handling callbacks\n * - Retry support\n *\n * Consider using the `injectAsyncRateLimiter` function instead.\n *\n * @example\n * ```ts\n * // Rate limit API calls\n * const makeApiCall = injectAsyncRateLimitedCallback(\n * async (data: ApiData) => {\n * const response = await fetch('/api/endpoint', {\n * method: 'POST',\n * body: JSON.stringify(data)\n * });\n * return response.json();\n * },\n * {\n * limit: 5,\n * window: 60000,\n * windowType: 'sliding',\n * }\n * );\n *\n * // Use in event handler\n * const result = await makeApiCall(apiData);\n * ```\n */\nexport function injectAsyncRateLimitedCallback<TFn extends AnyAsyncFunction>(\n fn: TFn,\n options: AsyncRateLimiterOptions<TFn>,\n): (...args: Parameters<TFn>) => Promise<Awaited<ReturnType<TFn>> | undefined> {\n const rateLimiter = injectAsyncRateLimiter(fn, options)\n return async (...args: Parameters<TFn>) => {\n const result = await rateLimiter.maybeExecute(...args)\n return result !== undefined ? await result : undefined\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAgB,+BACd,IACA,SAC6E;CAC7E,MAAM,cAAc,uBAAuB,IAAI,QAAQ;CACvD,OAAO,OAAO,GAAG,SAA0B;EACzC,MAAM,SAAS,MAAM,YAAY,aAAa,GAAG,KAAK;EACtD,OAAO,WAAW,SAAY,MAAM,SAAS"}
@@ -1,69 +0,0 @@
1
- const require_pacer_context = require('../provider/pacer-context.cjs');
2
- let _angular_core = require("@angular/core");
3
- let _tanstack_angular_store = require("@tanstack/angular-store");
4
- let _tanstack_pacer_async_rate_limiter = require("@tanstack/pacer/async-rate-limiter");
5
-
6
- //#region src/async-rate-limiter/injectAsyncRateLimiter.ts
7
- /**
8
- * An Angular function that creates and manages an AsyncRateLimiter instance.
9
- *
10
- * This is a lower-level function that provides direct access to the AsyncRateLimiter's functionality.
11
- * This allows you to integrate it with any state management solution you prefer.
12
- *
13
- * This function provides async rate limiting functionality with promise support, error handling,
14
- * retry capabilities, and abort support.
15
- *
16
- * ## State Management and Selector
17
- *
18
- * The function uses TanStack Store for state management and wraps it with Angular signals.
19
- * The `selector` parameter allows you to specify which state changes will trigger signal updates,
20
- * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.
21
- *
22
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
23
- * tracking by providing a selector function. This prevents unnecessary updates and gives you
24
- * full control over when your component tracks state changes.
25
- *
26
- * ## Cleanup on Destroy
27
- *
28
- * By default, the function aborts in-flight work when the component is destroyed.
29
- * Use the `onUnmount` option to customize this.
30
- *
31
- * @example
32
- * ```ts
33
- * // Default behavior - no reactive state subscriptions
34
- * const rateLimiter = injectAsyncRateLimiter(
35
- * async (id: string) => {
36
- * const response = await fetch(`/api/data/${id}`);
37
- * return response.json();
38
- * },
39
- * { limit: 5, window: 60000, windowType: 'sliding' }
40
- * );
41
- *
42
- * // In an event handler
43
- * const handleRequest = async (id: string) => {
44
- * const result = await rateLimiter.maybeExecute(id);
45
- * console.log('Result:', result);
46
- * };
47
- * ```
48
- */
49
- function injectAsyncRateLimiter(fn, options, selector = () => ({})) {
50
- const mergedOptions = {
51
- ...require_pacer_context.injectPacerOptions().asyncRateLimiter,
52
- ...options
53
- };
54
- const rateLimiter = new _tanstack_pacer_async_rate_limiter.AsyncRateLimiter(fn, mergedOptions);
55
- const state = (0, _tanstack_angular_store.injectSelector)(rateLimiter.store, selector);
56
- const result = {
57
- ...rateLimiter,
58
- state
59
- };
60
- (0, _angular_core.inject)(_angular_core.DestroyRef, { optional: true })?.onDestroy(() => {
61
- if (mergedOptions.onUnmount) mergedOptions.onUnmount(result);
62
- else rateLimiter.abort();
63
- });
64
- return result;
65
- }
66
-
67
- //#endregion
68
- exports.injectAsyncRateLimiter = injectAsyncRateLimiter;
69
- //# sourceMappingURL=injectAsyncRateLimiter.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncRateLimiter.cjs","names":["injectPacerOptions","AsyncRateLimiter","DestroyRef"],"sources":["../../src/async-rate-limiter/injectAsyncRateLimiter.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { AsyncRateLimiter } from '@tanstack/pacer/async-rate-limiter'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type { AnyAsyncFunction } from '@tanstack/pacer/types'\nimport type {\n AsyncRateLimiterOptions,\n AsyncRateLimiterState,\n} from '@tanstack/pacer/async-rate-limiter'\n\nexport interface AngularAsyncRateLimiterOptions<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends AsyncRateLimiterOptions<TFn> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the rate limiter instance.\n * When provided, replaces the default cleanup (abort).\n */\n onUnmount?: (rateLimiter: AngularAsyncRateLimiter<TFn, TSelected>) => void\n}\n\nexport interface AngularAsyncRateLimiter<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends Omit<AsyncRateLimiter<TFn>, 'store'> {\n /**\n * Reactive state signal that will be updated when the async rate limiter state changes\n *\n * Use this instead of `rateLimiter.store.state`\n */\n readonly state: Signal<Readonly<TSelected>>\n /**\n * @deprecated Use `rateLimiter.state` instead of `rateLimiter.store.state` if you want to read reactive state.\n * The state on the store object is not reactive in Angular signals.\n */\n readonly store: Store<Readonly<AsyncRateLimiterState<TFn>>>\n}\n\n/**\n * An Angular function that creates and manages an AsyncRateLimiter instance.\n *\n * This is a lower-level function that provides direct access to the AsyncRateLimiter's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * This function provides async rate limiting functionality with promise support, error handling,\n * retry capabilities, and abort support.\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for state management and wraps it with Angular signals.\n * The `selector` parameter allows you to specify which state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary updates and gives you\n * full control over when your component tracks state changes.\n *\n * ## Cleanup on Destroy\n *\n * By default, the function aborts in-flight work when the component is destroyed.\n * Use the `onUnmount` option to customize this.\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const rateLimiter = injectAsyncRateLimiter(\n * async (id: string) => {\n * const response = await fetch(`/api/data/${id}`);\n * return response.json();\n * },\n * { limit: 5, window: 60000, windowType: 'sliding' }\n * );\n *\n * // In an event handler\n * const handleRequest = async (id: string) => {\n * const result = await rateLimiter.maybeExecute(id);\n * console.log('Result:', result);\n * };\n * ```\n */\nexport function injectAsyncRateLimiter<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n>(\n fn: TFn,\n options: AngularAsyncRateLimiterOptions<TFn, TSelected>,\n selector: (state: AsyncRateLimiterState<TFn>) => TSelected = () =>\n ({}) as TSelected,\n): AngularAsyncRateLimiter<TFn, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().asyncRateLimiter,\n ...options,\n } as AngularAsyncRateLimiterOptions<TFn, TSelected>\n\n const rateLimiter = new AsyncRateLimiter<TFn>(fn, mergedOptions)\n const state = injectSelector(rateLimiter.store, selector)\n\n const result = {\n ...rateLimiter,\n state,\n } as AngularAsyncRateLimiter<TFn, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n } else {\n rateLimiter.abort()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFA,SAAgB,uBAId,IACA,SACA,kBACG,EAAE,GACoC;CACzC,MAAM,gBAAgB;EACpB,GAAGA,0CAAoB,CAAC;EACxB,GAAG;EACJ;CAED,MAAM,cAAc,IAAIC,oDAAsB,IAAI,cAAc;CAChE,MAAM,oDAAuB,YAAY,OAAO,SAAS;CAEzD,MAAM,SAAS;EACb,GAAG;EACH;EACD;CAGD,0BAD0BC,0BAAY,EAAE,UAAU,MAAM,CAC9C,EAAE,gBAAgB;EAC1B,IAAI,cAAc,WAChB,cAAc,UAAU,OAAO;OAE/B,YAAY,OAAO;GAErB;CAEF,OAAO"}
@@ -1,72 +0,0 @@
1
- import { Signal } from "@angular/core";
2
- import { Store } from "@tanstack/angular-store";
3
- import { AnyAsyncFunction } from "@tanstack/pacer/types";
4
- import { AsyncRateLimiter, AsyncRateLimiterOptions, AsyncRateLimiterState } from "@tanstack/pacer/async-rate-limiter";
5
-
6
- //#region src/async-rate-limiter/injectAsyncRateLimiter.d.ts
7
- interface AngularAsyncRateLimiterOptions<TFn extends AnyAsyncFunction, TSelected = {}> extends AsyncRateLimiterOptions<TFn> {
8
- /**
9
- * Optional callback invoked when the component is destroyed. Receives the rate limiter instance.
10
- * When provided, replaces the default cleanup (abort).
11
- */
12
- onUnmount?: (rateLimiter: AngularAsyncRateLimiter<TFn, TSelected>) => void;
13
- }
14
- interface AngularAsyncRateLimiter<TFn extends AnyAsyncFunction, TSelected = {}> extends Omit<AsyncRateLimiter<TFn>, 'store'> {
15
- /**
16
- * Reactive state signal that will be updated when the async rate limiter state changes
17
- *
18
- * Use this instead of `rateLimiter.store.state`
19
- */
20
- readonly state: Signal<Readonly<TSelected>>;
21
- /**
22
- * @deprecated Use `rateLimiter.state` instead of `rateLimiter.store.state` if you want to read reactive state.
23
- * The state on the store object is not reactive in Angular signals.
24
- */
25
- readonly store: Store<Readonly<AsyncRateLimiterState<TFn>>>;
26
- }
27
- /**
28
- * An Angular function that creates and manages an AsyncRateLimiter instance.
29
- *
30
- * This is a lower-level function that provides direct access to the AsyncRateLimiter's functionality.
31
- * This allows you to integrate it with any state management solution you prefer.
32
- *
33
- * This function provides async rate limiting functionality with promise support, error handling,
34
- * retry capabilities, and abort support.
35
- *
36
- * ## State Management and Selector
37
- *
38
- * The function uses TanStack Store for state management and wraps it with Angular signals.
39
- * The `selector` parameter allows you to specify which state changes will trigger signal updates,
40
- * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.
41
- *
42
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
43
- * tracking by providing a selector function. This prevents unnecessary updates and gives you
44
- * full control over when your component tracks state changes.
45
- *
46
- * ## Cleanup on Destroy
47
- *
48
- * By default, the function aborts in-flight work when the component is destroyed.
49
- * Use the `onUnmount` option to customize this.
50
- *
51
- * @example
52
- * ```ts
53
- * // Default behavior - no reactive state subscriptions
54
- * const rateLimiter = injectAsyncRateLimiter(
55
- * async (id: string) => {
56
- * const response = await fetch(`/api/data/${id}`);
57
- * return response.json();
58
- * },
59
- * { limit: 5, window: 60000, windowType: 'sliding' }
60
- * );
61
- *
62
- * // In an event handler
63
- * const handleRequest = async (id: string) => {
64
- * const result = await rateLimiter.maybeExecute(id);
65
- * console.log('Result:', result);
66
- * };
67
- * ```
68
- */
69
- declare function injectAsyncRateLimiter<TFn extends AnyAsyncFunction, TSelected = {}>(fn: TFn, options: AngularAsyncRateLimiterOptions<TFn, TSelected>, selector?: (state: AsyncRateLimiterState<TFn>) => TSelected): AngularAsyncRateLimiter<TFn, TSelected>;
70
- //#endregion
71
- export { AngularAsyncRateLimiter, AngularAsyncRateLimiterOptions, injectAsyncRateLimiter };
72
- //# sourceMappingURL=injectAsyncRateLimiter.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncRateLimiter.js","names":[],"sources":["../../src/async-rate-limiter/injectAsyncRateLimiter.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { AsyncRateLimiter } from '@tanstack/pacer/async-rate-limiter'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type { AnyAsyncFunction } from '@tanstack/pacer/types'\nimport type {\n AsyncRateLimiterOptions,\n AsyncRateLimiterState,\n} from '@tanstack/pacer/async-rate-limiter'\n\nexport interface AngularAsyncRateLimiterOptions<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends AsyncRateLimiterOptions<TFn> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the rate limiter instance.\n * When provided, replaces the default cleanup (abort).\n */\n onUnmount?: (rateLimiter: AngularAsyncRateLimiter<TFn, TSelected>) => void\n}\n\nexport interface AngularAsyncRateLimiter<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends Omit<AsyncRateLimiter<TFn>, 'store'> {\n /**\n * Reactive state signal that will be updated when the async rate limiter state changes\n *\n * Use this instead of `rateLimiter.store.state`\n */\n readonly state: Signal<Readonly<TSelected>>\n /**\n * @deprecated Use `rateLimiter.state` instead of `rateLimiter.store.state` if you want to read reactive state.\n * The state on the store object is not reactive in Angular signals.\n */\n readonly store: Store<Readonly<AsyncRateLimiterState<TFn>>>\n}\n\n/**\n * An Angular function that creates and manages an AsyncRateLimiter instance.\n *\n * This is a lower-level function that provides direct access to the AsyncRateLimiter's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * This function provides async rate limiting functionality with promise support, error handling,\n * retry capabilities, and abort support.\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for state management and wraps it with Angular signals.\n * The `selector` parameter allows you to specify which state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary updates and gives you\n * full control over when your component tracks state changes.\n *\n * ## Cleanup on Destroy\n *\n * By default, the function aborts in-flight work when the component is destroyed.\n * Use the `onUnmount` option to customize this.\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const rateLimiter = injectAsyncRateLimiter(\n * async (id: string) => {\n * const response = await fetch(`/api/data/${id}`);\n * return response.json();\n * },\n * { limit: 5, window: 60000, windowType: 'sliding' }\n * );\n *\n * // In an event handler\n * const handleRequest = async (id: string) => {\n * const result = await rateLimiter.maybeExecute(id);\n * console.log('Result:', result);\n * };\n * ```\n */\nexport function injectAsyncRateLimiter<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n>(\n fn: TFn,\n options: AngularAsyncRateLimiterOptions<TFn, TSelected>,\n selector: (state: AsyncRateLimiterState<TFn>) => TSelected = () =>\n ({}) as TSelected,\n): AngularAsyncRateLimiter<TFn, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().asyncRateLimiter,\n ...options,\n } as AngularAsyncRateLimiterOptions<TFn, TSelected>\n\n const rateLimiter = new AsyncRateLimiter<TFn>(fn, mergedOptions)\n const state = injectSelector(rateLimiter.store, selector)\n\n const result = {\n ...rateLimiter,\n state,\n } as AngularAsyncRateLimiter<TFn, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n } else {\n rateLimiter.abort()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFA,SAAgB,uBAId,IACA,SACA,kBACG,EAAE,GACoC;CACzC,MAAM,gBAAgB;EACpB,GAAG,oBAAoB,CAAC;EACxB,GAAG;EACJ;CAED,MAAM,cAAc,IAAI,iBAAsB,IAAI,cAAc;CAChE,MAAM,QAAQ,eAAe,YAAY,OAAO,SAAS;CAEzD,MAAM,SAAS;EACb,GAAG;EACH;EACD;CAGD,AADmB,OAAO,YAAY,EAAE,UAAU,MAAM,CAC9C,EAAE,gBAAgB;EAC1B,IAAI,cAAc,WAChB,cAAc,UAAU,OAAO;OAE/B,YAAY,OAAO;GAErB;CAEF,OAAO"}
@@ -1,9 +0,0 @@
1
-
2
-
3
- var _tanstack_pacer_async_retryer = require("@tanstack/pacer/async-retryer");
4
- Object.keys(_tanstack_pacer_async_retryer).forEach(function (k) {
5
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
6
- enumerable: true,
7
- get: function () { return _tanstack_pacer_async_retryer[k]; }
8
- });
9
- });
@@ -1 +0,0 @@
1
- export * from "@tanstack/pacer/async-retryer";