@tanstack/solid-pacer 0.22.0 → 0.23.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 (170) hide show
  1. package/README.md +4 -4
  2. package/dist/async-batcher/createAsyncBatcher.d.ts +5 -9
  3. package/dist/async-batcher/createAsyncBatcher.js +2 -5
  4. package/dist/async-debouncer/createAsyncDebouncer.d.ts +8 -11
  5. package/dist/async-debouncer/createAsyncDebouncer.js +5 -7
  6. package/dist/async-queuer/createAsyncQueuer.d.ts +9 -11
  7. package/dist/async-queuer/createAsyncQueuer.js +4 -5
  8. package/dist/async-rate-limiter/createAsyncRateLimiter.d.ts +10 -12
  9. package/dist/async-rate-limiter/createAsyncRateLimiter.js +7 -8
  10. package/dist/async-throttler/createAsyncThrottler.d.ts +8 -13
  11. package/dist/async-throttler/createAsyncThrottler.js +5 -9
  12. package/dist/batcher/createBatcher.d.ts +11 -14
  13. package/dist/batcher/createBatcher.js +6 -8
  14. package/dist/debouncer/createDebouncedSignal.d.ts +2 -4
  15. package/dist/debouncer/createDebouncedSignal.js +1 -2
  16. package/dist/debouncer/createDebouncedValue.d.ts +2 -4
  17. package/dist/debouncer/createDebouncedValue.js +1 -2
  18. package/dist/debouncer/createDebouncer.d.ts +4 -6
  19. package/dist/debouncer/createDebouncer.js +1 -2
  20. package/dist/provider/PacerProvider.d.ts +6 -8
  21. package/dist/provider/PacerProvider.js +1 -2
  22. package/dist/queuer/createQueuedSignal.d.ts +2 -4
  23. package/dist/queuer/createQueuedSignal.js +1 -2
  24. package/dist/queuer/createQueuer.d.ts +4 -6
  25. package/dist/queuer/createQueuer.js +1 -2
  26. package/dist/rate-limiter/createRateLimitedSignal.d.ts +12 -13
  27. package/dist/rate-limiter/createRateLimitedSignal.js +11 -11
  28. package/dist/rate-limiter/createRateLimitedValue.d.ts +2 -4
  29. package/dist/rate-limiter/createRateLimitedValue.js +1 -2
  30. package/dist/rate-limiter/createRateLimiter.d.ts +8 -9
  31. package/dist/rate-limiter/createRateLimiter.js +5 -5
  32. package/dist/throttler/createThrottledSignal.d.ts +2 -6
  33. package/dist/throttler/createThrottledSignal.js +1 -4
  34. package/dist/throttler/createThrottledValue.d.ts +2 -6
  35. package/dist/throttler/createThrottledValue.js +1 -4
  36. package/dist/throttler/createThrottler.d.ts +4 -8
  37. package/dist/throttler/createThrottler.js +1 -4
  38. package/package.json +23 -67
  39. package/dist/async-batcher/createAsyncBatcher.cjs +0 -166
  40. package/dist/async-batcher/createAsyncBatcher.cjs.map +0 -1
  41. package/dist/async-batcher/createAsyncBatcher.d.cts +0 -177
  42. package/dist/async-batcher/createAsyncBatcher.js.map +0 -1
  43. package/dist/async-batcher/index.cjs +0 -11
  44. package/dist/async-batcher/index.d.cts +0 -3
  45. package/dist/async-debouncer/createAsyncDebouncer.cjs +0 -151
  46. package/dist/async-debouncer/createAsyncDebouncer.cjs.map +0 -1
  47. package/dist/async-debouncer/createAsyncDebouncer.d.cts +0 -163
  48. package/dist/async-debouncer/createAsyncDebouncer.js.map +0 -1
  49. package/dist/async-debouncer/index.cjs +0 -11
  50. package/dist/async-debouncer/index.d.cts +0 -3
  51. package/dist/async-queuer/createAsyncQueuer.cjs +0 -158
  52. package/dist/async-queuer/createAsyncQueuer.cjs.map +0 -1
  53. package/dist/async-queuer/createAsyncQueuer.d.cts +0 -169
  54. package/dist/async-queuer/createAsyncQueuer.js.map +0 -1
  55. package/dist/async-queuer/index.cjs +0 -11
  56. package/dist/async-queuer/index.d.cts +0 -3
  57. package/dist/async-rate-limiter/createAsyncRateLimiter.cjs +0 -193
  58. package/dist/async-rate-limiter/createAsyncRateLimiter.cjs.map +0 -1
  59. package/dist/async-rate-limiter/createAsyncRateLimiter.d.cts +0 -208
  60. package/dist/async-rate-limiter/createAsyncRateLimiter.js.map +0 -1
  61. package/dist/async-rate-limiter/index.cjs +0 -11
  62. package/dist/async-rate-limiter/index.d.cts +0 -3
  63. package/dist/async-throttler/createAsyncThrottler.cjs +0 -151
  64. package/dist/async-throttler/createAsyncThrottler.cjs.map +0 -1
  65. package/dist/async-throttler/createAsyncThrottler.d.cts +0 -163
  66. package/dist/async-throttler/createAsyncThrottler.js.map +0 -1
  67. package/dist/async-throttler/index.cjs +0 -11
  68. package/dist/async-throttler/index.d.cts +0 -3
  69. package/dist/batcher/createBatcher.cjs +0 -132
  70. package/dist/batcher/createBatcher.cjs.map +0 -1
  71. package/dist/batcher/createBatcher.d.cts +0 -146
  72. package/dist/batcher/createBatcher.js.map +0 -1
  73. package/dist/batcher/index.cjs +0 -11
  74. package/dist/batcher/index.d.cts +0 -3
  75. package/dist/debouncer/createDebouncedSignal.cjs +0 -88
  76. package/dist/debouncer/createDebouncedSignal.cjs.map +0 -1
  77. package/dist/debouncer/createDebouncedSignal.d.cts +0 -79
  78. package/dist/debouncer/createDebouncedSignal.js.map +0 -1
  79. package/dist/debouncer/createDebouncedValue.cjs +0 -77
  80. package/dist/debouncer/createDebouncedValue.cjs.map +0 -1
  81. package/dist/debouncer/createDebouncedValue.d.cts +0 -70
  82. package/dist/debouncer/createDebouncedValue.js.map +0 -1
  83. package/dist/debouncer/createDebouncer.cjs +0 -129
  84. package/dist/debouncer/createDebouncer.cjs.map +0 -1
  85. package/dist/debouncer/createDebouncer.d.cts +0 -144
  86. package/dist/debouncer/createDebouncer.js.map +0 -1
  87. package/dist/debouncer/index.cjs +0 -15
  88. package/dist/debouncer/index.d.cts +0 -5
  89. package/dist/index.cjs +0 -47
  90. package/dist/index.d.cts +0 -20
  91. package/dist/provider/PacerProvider.cjs +0 -27
  92. package/dist/provider/PacerProvider.cjs.map +0 -1
  93. package/dist/provider/PacerProvider.d.cts +0 -28
  94. package/dist/provider/PacerProvider.js.map +0 -1
  95. package/dist/provider/index.cjs +0 -6
  96. package/dist/provider/index.d.cts +0 -2
  97. package/dist/queuer/createQueuedSignal.cjs +0 -129
  98. package/dist/queuer/createQueuedSignal.cjs.map +0 -1
  99. package/dist/queuer/createQueuedSignal.d.cts +0 -121
  100. package/dist/queuer/createQueuedSignal.js.map +0 -1
  101. package/dist/queuer/createQueuer.cjs +0 -133
  102. package/dist/queuer/createQueuer.cjs.map +0 -1
  103. package/dist/queuer/createQueuer.d.cts +0 -147
  104. package/dist/queuer/createQueuer.js.map +0 -1
  105. package/dist/queuer/index.cjs +0 -13
  106. package/dist/queuer/index.d.cts +0 -4
  107. package/dist/rate-limiter/createRateLimitedSignal.cjs +0 -102
  108. package/dist/rate-limiter/createRateLimitedSignal.cjs.map +0 -1
  109. package/dist/rate-limiter/createRateLimitedSignal.d.cts +0 -93
  110. package/dist/rate-limiter/createRateLimitedSignal.js.map +0 -1
  111. package/dist/rate-limiter/createRateLimitedValue.cjs +0 -102
  112. package/dist/rate-limiter/createRateLimitedValue.cjs.map +0 -1
  113. package/dist/rate-limiter/createRateLimitedValue.d.cts +0 -95
  114. package/dist/rate-limiter/createRateLimitedValue.js.map +0 -1
  115. package/dist/rate-limiter/createRateLimiter.cjs +0 -157
  116. package/dist/rate-limiter/createRateLimiter.cjs.map +0 -1
  117. package/dist/rate-limiter/createRateLimiter.d.cts +0 -173
  118. package/dist/rate-limiter/createRateLimiter.js.map +0 -1
  119. package/dist/rate-limiter/index.cjs +0 -15
  120. package/dist/rate-limiter/index.d.cts +0 -5
  121. package/dist/throttler/createThrottledSignal.cjs +0 -79
  122. package/dist/throttler/createThrottledSignal.cjs.map +0 -1
  123. package/dist/throttler/createThrottledSignal.d.cts +0 -70
  124. package/dist/throttler/createThrottledSignal.js.map +0 -1
  125. package/dist/throttler/createThrottledValue.cjs +0 -74
  126. package/dist/throttler/createThrottledValue.cjs.map +0 -1
  127. package/dist/throttler/createThrottledValue.d.cts +0 -67
  128. package/dist/throttler/createThrottledValue.js.map +0 -1
  129. package/dist/throttler/createThrottler.cjs +0 -132
  130. package/dist/throttler/createThrottler.cjs.map +0 -1
  131. package/dist/throttler/createThrottler.d.cts +0 -147
  132. package/dist/throttler/createThrottler.js.map +0 -1
  133. package/dist/throttler/index.cjs +0 -15
  134. package/dist/throttler/index.d.cts +0 -5
  135. package/dist/types/index.cjs +0 -8
  136. package/dist/types/index.d.cts +0 -1
  137. package/dist/utils/index.cjs +0 -8
  138. package/dist/utils/index.d.cts +0 -1
  139. package/src/async-batcher/createAsyncBatcher.ts +0 -234
  140. package/src/async-batcher/index.ts +0 -3
  141. package/src/async-debouncer/createAsyncDebouncer.ts +0 -225
  142. package/src/async-debouncer/index.ts +0 -4
  143. package/src/async-queuer/createAsyncQueuer.ts +0 -226
  144. package/src/async-queuer/index.ts +0 -3
  145. package/src/async-rate-limiter/createAsyncRateLimiter.ts +0 -269
  146. package/src/async-rate-limiter/index.ts +0 -4
  147. package/src/async-throttler/createAsyncThrottler.ts +0 -225
  148. package/src/async-throttler/index.ts +0 -4
  149. package/src/batcher/createBatcher.ts +0 -199
  150. package/src/batcher/index.ts +0 -3
  151. package/src/debouncer/createDebouncedSignal.ts +0 -92
  152. package/src/debouncer/createDebouncedValue.ts +0 -85
  153. package/src/debouncer/createDebouncer.ts +0 -201
  154. package/src/debouncer/index.ts +0 -6
  155. package/src/index.ts +0 -46
  156. package/src/provider/PacerProvider.tsx +0 -63
  157. package/src/provider/index.ts +0 -1
  158. package/src/queuer/createQueuedSignal.ts +0 -138
  159. package/src/queuer/createQueuer.ts +0 -199
  160. package/src/queuer/index.ts +0 -4
  161. package/src/rate-limiter/createRateLimitedSignal.ts +0 -117
  162. package/src/rate-limiter/createRateLimitedValue.ts +0 -110
  163. package/src/rate-limiter/createRateLimiter.ts +0 -226
  164. package/src/rate-limiter/index.ts +0 -5
  165. package/src/throttler/createThrottledSignal.ts +0 -81
  166. package/src/throttler/createThrottledValue.ts +0 -82
  167. package/src/throttler/createThrottler.ts +0 -204
  168. package/src/throttler/index.ts +0 -6
  169. package/src/types/index.ts +0 -1
  170. package/src/utils/index.ts +0 -1
@@ -1,147 +0,0 @@
1
- import { Store } from "@tanstack/solid-store";
2
- import { Accessor, JSX } from "solid-js";
3
- import { Queuer, QueuerOptions, QueuerState } from "@tanstack/pacer/queuer";
4
- //#region src/queuer/createQueuer.d.ts
5
- interface SolidQueuerOptions<TValue, TSelected = {}> extends QueuerOptions<TValue> {
6
- /**
7
- * Optional callback invoked when the owning component unmounts. Receives the queuer instance.
8
- * When provided, replaces the default cleanup (stop); use it to call flush(), flushAsBatch(), stop(), add logging, etc.
9
- */
10
- onUnmount?: (queuer: SolidQueuer<TValue, TSelected>) => void;
11
- }
12
- interface SolidQueuer<TValue, TSelected = {}> extends Omit<Queuer<TValue>, 'store'> {
13
- /**
14
- * A Solid component that allows you to subscribe to the queuer state.
15
- *
16
- * This is useful for tracking specific parts of the queuer state
17
- * deep in your component tree without needing to pass a selector to the hook.
18
- *
19
- * @example
20
- * <queuer.Subscribe selector={(state) => ({ size: state.size, isRunning: state.isRunning })}>
21
- * {(state) => (
22
- * <div>Queue: {state().size} items, {state().isRunning ? 'Processing' : 'Idle'}</div>
23
- * )}
24
- * </queuer.Subscribe>
25
- */
26
- Subscribe: <TSelected>(props: {
27
- selector: (state: QueuerState<TValue>) => TSelected;
28
- children: ((state: Accessor<TSelected>) => JSX.Element) | JSX.Element;
29
- }) => JSX.Element;
30
- /**
31
- * Reactive state that will be updated when the queuer state changes
32
- *
33
- * Use this instead of `queuer.store.state`
34
- */
35
- readonly state: Accessor<Readonly<TSelected>>;
36
- /**
37
- * @deprecated Use `queuer.state` instead of `queuer.store.state` if you want to read reactive state.
38
- * The state on the store object is not reactive, as it has not been wrapped in a `useSelector` hook internally.
39
- * Although, you can make the state reactive by using the `useSelector` in your own usage.
40
- */
41
- readonly store: Store<Readonly<QueuerState<TValue>>>;
42
- }
43
- /**
44
- * Creates a Solid-compatible Queuer instance for managing a synchronous queue of items, exposing Solid signals for all stateful properties.
45
- *
46
- * Features:
47
- * - Synchronous processing of items using the provided `fn` function
48
- * - FIFO (First In First Out) or LIFO (Last In First Out) queue behavior
49
- * - Priority queueing via `getPriority` or item `priority` property
50
- * - Item expiration and removal of stale items
51
- * - Configurable wait time between processing items
52
- * - Pause/resume processing
53
- * - Callbacks for queue state changes, execution, rejection, and expiration
54
- * - All stateful properties (items, counts, etc.) are exposed as Solid signals for reactivity
55
- *
56
- * The queue processes items synchronously in order, with optional delays between each item. When started, it will process one item per tick, with an optional wait time between ticks. You can pause and resume processing with `stop()` and `start()`.
57
- *
58
- * By default, the queue uses FIFO behavior, but you can configure LIFO or double-ended queueing by specifying the position when adding or removing items.
59
- *
60
- * ## State Management and Selector
61
- *
62
- * The hook uses TanStack Store for reactive state management. You can subscribe to state changes
63
- * in two ways:
64
- *
65
- * **1. Using `queuer.Subscribe` component (Recommended for component tree subscriptions)**
66
- *
67
- * Use the `Subscribe` component to subscribe to state changes deep in your component tree without
68
- * needing to pass a selector to the hook. This is ideal when you want to subscribe to state
69
- * in child components.
70
- *
71
- * **2. Using the `selector` parameter (For hook-level subscriptions)**
72
- *
73
- * The `selector` parameter allows you to specify which state changes will trigger reactive updates
74
- * at the hook level, optimizing performance by preventing unnecessary updates when irrelevant
75
- * state changes occur.
76
- *
77
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
78
- * tracking by providing a selector function or using the `Subscribe` component. This prevents unnecessary
79
- * updates and gives you full control over when your component tracks state changes.
80
- *
81
- * Available state properties:
82
- * - `executionCount`: Number of items that have been processed
83
- * - `isRunning`: Whether the queuer is currently running (not stopped)
84
- * - `items`: Array of items currently queued for processing
85
- * - `rejectionCount`: Number of items that were rejected (expired or failed validation)
86
- *
87
- * ## Unmount behavior
88
- *
89
- * By default, the primitive stops the queuer when the owning component unmounts.
90
- * Use the `onUnmount` option to customize this. For example, to flush pending items instead:
91
- *
92
- * ```tsx
93
- * const queue = createQueuer(fn, {
94
- * started: true,
95
- * wait: 1000,
96
- * onUnmount: (q) => q.flush()
97
- * });
98
- * ```
99
- *
100
- * Example usage:
101
- * ```tsx
102
- * // Default behavior - no reactive state subscriptions
103
- * const queue = createQueuer(
104
- * (item) => {
105
- * // process item synchronously
106
- * console.log('Processing', item);
107
- * },
108
- * {
109
- * started: true, // Start processing immediately
110
- * wait: 1000, // Process one item every second
111
- * getPriority: (item) => item.priority // Process higher priority items first
112
- * }
113
- * );
114
- *
115
- * // Opt-in to track items or isRunning changes (optimized for UI updates)
116
- * const queue = createQueuer(
117
- * (item) => console.log('Processing', item),
118
- * { started: true, wait: 1000 },
119
- * (state) => ({ items: state.items, isRunning: state.isRunning })
120
- * );
121
- *
122
- * // Opt-in to track execution metrics changes (optimized for tracking progress)
123
- * const queue = createQueuer(
124
- * (item) => console.log('Processing', item),
125
- * { started: true, wait: 1000 },
126
- * (state) => ({
127
- * executionCount: state.executionCount,
128
- * rejectionCount: state.rejectionCount
129
- * })
130
- * );
131
- *
132
- * // Add items to process - they'll be handled automatically
133
- * queue.addItem('task1');
134
- * queue.addItem('task2');
135
- *
136
- * // Control the scheduler
137
- * queue.stop(); // Pause processing
138
- * queue.start(); // Resume processing
139
- *
140
- * // Access the selected state (will be empty object {} unless selector provided)
141
- * const { items, isRunning } = queue.state();
142
- * ```
143
- */
144
- declare function createQueuer<TValue, TSelected = {}>(fn: (item: TValue) => void, options?: SolidQueuerOptions<TValue, TSelected>, selector?: (state: QueuerState<TValue>) => TSelected): SolidQueuer<TValue, TSelected>;
145
- //#endregion
146
- export { SolidQueuer, SolidQueuerOptions, createQueuer };
147
- //# sourceMappingURL=createQueuer.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createQueuer.js","names":[],"sources":["../../src/queuer/createQueuer.ts"],"sourcesContent":["import { Queuer } from '@tanstack/pacer/queuer'\nimport { shallow, useSelector } from '@tanstack/solid-store'\nimport { createEffect, onCleanup } from 'solid-js'\nimport { useDefaultPacerOptions } from '../provider/PacerProvider'\nimport type { Store } from '@tanstack/solid-store'\nimport type { Accessor, JSX } from 'solid-js'\nimport type { QueuerOptions, QueuerState } from '@tanstack/pacer/queuer'\n\nexport interface SolidQueuerOptions<\n TValue,\n TSelected = {},\n> extends QueuerOptions<TValue> {\n /**\n * Optional callback invoked when the owning component unmounts. Receives the queuer instance.\n * When provided, replaces the default cleanup (stop); use it to call flush(), flushAsBatch(), stop(), add logging, etc.\n */\n onUnmount?: (queuer: SolidQueuer<TValue, TSelected>) => void\n}\n\nexport interface SolidQueuer<TValue, TSelected = {}> extends Omit<\n Queuer<TValue>,\n 'store'\n> {\n /**\n * A Solid component that allows you to subscribe to the queuer state.\n *\n * This is useful for tracking specific parts of the queuer state\n * deep in your component tree without needing to pass a selector to the hook.\n *\n * @example\n * <queuer.Subscribe selector={(state) => ({ size: state.size, isRunning: state.isRunning })}>\n * {(state) => (\n * <div>Queue: {state().size} items, {state().isRunning ? 'Processing' : 'Idle'}</div>\n * )}\n * </queuer.Subscribe>\n */\n Subscribe: <TSelected>(props: {\n selector: (state: QueuerState<TValue>) => TSelected\n children: ((state: Accessor<TSelected>) => JSX.Element) | JSX.Element\n }) => JSX.Element\n /**\n * Reactive state that will be updated when the queuer state changes\n *\n * Use this instead of `queuer.store.state`\n */\n readonly state: Accessor<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, as it has not been wrapped in a `useSelector` hook internally.\n * Although, you can make the state reactive by using the `useSelector` in your own usage.\n */\n readonly store: Store<Readonly<QueuerState<TValue>>>\n}\n\n/**\n * Creates a Solid-compatible Queuer instance for managing a synchronous queue of items, exposing Solid signals for all stateful properties.\n *\n * Features:\n * - Synchronous processing of items using the provided `fn` function\n * - FIFO (First In First Out) or LIFO (Last In First Out) queue behavior\n * - Priority queueing via `getPriority` or item `priority` property\n * - Item expiration and removal of stale items\n * - Configurable wait time between processing items\n * - Pause/resume processing\n * - Callbacks for queue state changes, execution, rejection, and expiration\n * - All stateful properties (items, counts, etc.) are exposed as Solid signals for reactivity\n *\n * The queue processes items synchronously in order, with optional delays between each item. When started, it will process one item per tick, with an optional wait time between ticks. You can pause and resume processing with `stop()` and `start()`.\n *\n * By default, the queue uses FIFO behavior, but you can configure LIFO or double-ended queueing by specifying the position when adding or removing items.\n *\n * ## State Management and Selector\n *\n * The hook uses TanStack Store for reactive state management. You can subscribe to state changes\n * in two ways:\n *\n * **1. Using `queuer.Subscribe` component (Recommended for component tree subscriptions)**\n *\n * Use the `Subscribe` component to subscribe to state changes deep in your component tree without\n * needing to pass a selector to the hook. This is ideal when you want to subscribe to state\n * in child components.\n *\n * **2. Using the `selector` parameter (For hook-level subscriptions)**\n *\n * The `selector` parameter allows you to specify which state changes will trigger reactive updates\n * at the hook level, optimizing performance by preventing unnecessary updates when irrelevant\n * 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 or using the `Subscribe` component. This prevents unnecessary\n * updates and gives you full control over when your component tracks state changes.\n *\n * Available state properties:\n * - `executionCount`: Number of items that have been processed\n * - `isRunning`: Whether the queuer is currently running (not stopped)\n * - `items`: Array of items currently queued for processing\n * - `rejectionCount`: Number of items that were rejected (expired or failed validation)\n *\n * ## Unmount behavior\n *\n * By default, the primitive stops the queuer when the owning component unmounts.\n * Use the `onUnmount` option to customize this. For example, to flush pending items instead:\n *\n * ```tsx\n * const queue = createQueuer(fn, {\n * started: true,\n * wait: 1000,\n * onUnmount: (q) => q.flush()\n * });\n * ```\n *\n * Example usage:\n * ```tsx\n * // Default behavior - no reactive state subscriptions\n * const queue = createQueuer(\n * (item) => {\n * // process item synchronously\n * console.log('Processing', item);\n * },\n * {\n * started: true, // Start processing immediately\n * wait: 1000, // Process one item every second\n * getPriority: (item) => item.priority // Process higher priority items first\n * }\n * );\n *\n * // Opt-in to track items or isRunning changes (optimized for UI updates)\n * const queue = createQueuer(\n * (item) => console.log('Processing', item),\n * { started: true, wait: 1000 },\n * (state) => ({ items: state.items, isRunning: state.isRunning })\n * );\n *\n * // Opt-in to track execution metrics changes (optimized for tracking progress)\n * const queue = createQueuer(\n * (item) => console.log('Processing', item),\n * { started: true, wait: 1000 },\n * (state) => ({\n * executionCount: state.executionCount,\n * rejectionCount: state.rejectionCount\n * })\n * );\n *\n * // Add items to process - they'll be handled automatically\n * queue.addItem('task1');\n * queue.addItem('task2');\n *\n * // Control the scheduler\n * queue.stop(); // Pause processing\n * queue.start(); // Resume processing\n *\n * // Access the selected state (will be empty object {} unless selector provided)\n * const { items, isRunning } = queue.state();\n * ```\n */\nexport function createQueuer<TValue, TSelected = {}>(\n fn: (item: TValue) => void,\n options: SolidQueuerOptions<TValue, TSelected> = {},\n selector: (state: QueuerState<TValue>) => TSelected = () => ({}) as TSelected,\n): SolidQueuer<TValue, TSelected> {\n const mergedOptions = {\n ...useDefaultPacerOptions().queuer,\n ...options,\n } as SolidQueuerOptions<TValue, TSelected>\n const queuer = new Queuer(fn, mergedOptions) as unknown as SolidQueuer<\n TValue,\n TSelected\n >\n\n queuer.Subscribe = function Subscribe<TSelected>(props: {\n selector: (state: QueuerState<TValue>) => TSelected\n children: ((state: Accessor<TSelected>) => JSX.Element) | JSX.Element\n }) {\n const selected = useSelector(queuer.store, props.selector, {\n compare: shallow,\n })\n\n return typeof props.children === 'function'\n ? props.children(selected)\n : props.children\n }\n\n const state = useSelector(queuer.store, selector, { compare: shallow })\n\n createEffect(() => {\n onCleanup(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(queuer)\n } else {\n queuer.stop()\n }\n })\n })\n\n return {\n ...queuer,\n state,\n } as SolidQueuer<TValue, TSelected> // omit `store` in favor of `state`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2JA,SAAgB,aACd,IACA,UAAiD,CAAC,GAClD,kBAA6D,CAAC,IAC9B;CAChC,MAAM,gBAAgB;EACpB,GAAG,uBAAuB,CAAC,CAAC;EAC5B,GAAG;CACL;CACA,MAAM,SAAS,IAAI,OAAO,IAAI,aAAa;CAK3C,OAAO,YAAY,SAAS,UAAqB,OAG9C;EACD,MAAM,WAAW,YAAY,OAAO,OAAO,MAAM,UAAU,EACzD,SAAS,QACX,CAAC;EAED,OAAO,OAAO,MAAM,aAAa,aAC7B,MAAM,SAAS,QAAQ,IACvB,MAAM;CACZ;CAEA,MAAM,QAAQ,YAAY,OAAO,OAAO,UAAU,EAAE,SAAS,QAAQ,CAAC;CAEtE,mBAAmB;EACjB,gBAAgB;GACd,IAAI,cAAc,WAChB,cAAc,UAAU,MAAM;QAE9B,OAAO,KAAK;EAEhB,CAAC;CACH,CAAC;CAED,OAAO;EACL,GAAG;EACH;CACF;AACF"}
@@ -1,13 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_createQueuer = require('./createQueuer.cjs');
3
- const require_createQueuedSignal = require('./createQueuedSignal.cjs');
4
-
5
- exports.createQueuedSignal = require_createQueuedSignal.createQueuedSignal;
6
- exports.createQueuer = require_createQueuer.createQueuer;
7
- var _tanstack_pacer_queuer = require("@tanstack/pacer/queuer");
8
- Object.keys(_tanstack_pacer_queuer).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_queuer[k]; }
12
- });
13
- });
@@ -1,4 +0,0 @@
1
- import { SolidQueuer, SolidQueuerOptions, createQueuer } from "./createQueuer.cjs";
2
- import { createQueuedSignal } from "./createQueuedSignal.cjs";
3
- export * from "@tanstack/pacer/queuer";
4
- export { SolidQueuer, SolidQueuerOptions, createQueuedSignal, createQueuer };
@@ -1,102 +0,0 @@
1
- const require_createRateLimiter = require('./createRateLimiter.cjs');
2
- let solid_js = require("solid-js");
3
-
4
- //#region src/rate-limiter/createRateLimitedSignal.ts
5
- /**
6
- * A Solid hook that creates a rate-limited state value that enforces a hard limit on state updates within a time window.
7
- * This hook combines Solid's createSignal with rate limiting functionality to provide controlled state updates.
8
- *
9
- * Rate limiting is a simple "hard limit" approach - it allows all updates until the limit is reached, then blocks
10
- * subsequent updates until the window resets. Unlike throttling or debouncing, it does not attempt to space out
11
- * or intelligently collapse updates. This can lead to bursts of rapid updates followed by periods of no updates.
12
- *
13
- * The rate limiter supports two types of windows:
14
- * - 'fixed': A strict window that resets after the window period. All updates within the window count
15
- * towards the limit, and the window resets completely after the period.
16
- * - 'sliding': A rolling window that allows updates as old ones expire. This provides a more
17
- * consistent rate of updates over time.
18
- *
19
- * For smoother update patterns, consider:
20
- * - createThrottledSignal: When you want consistent spacing between updates (e.g. UI changes)
21
- * - createDebouncedSignal: When you want to collapse rapid updates into a single update (e.g. search input)
22
- *
23
- * Rate limiting should primarily be used when you need to enforce strict limits, like API rate limits.
24
- *
25
- * The hook returns a tuple containing:
26
- * - The rate-limited state value accessor
27
- * - A rate-limited setter function that respects the configured limits
28
- * - The rateLimiter instance for additional control
29
- *
30
- * For more direct control over rate limiting without state management,
31
- * consider using the lower-level createRateLimiter hook instead.
32
- *
33
- * ## State Management and Selector
34
- *
35
- * The hook uses TanStack Store for reactive state management via the underlying rate limiter instance.
36
- * The `selector` parameter allows you to specify which rate limiter state changes will trigger reactive updates,
37
- * optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.
38
- *
39
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
40
- * tracking by providing a selector function. This prevents unnecessary reactive updates and gives you
41
- * full control over when your component subscribes to state changes. Only when you provide a selector will
42
- * the reactive system track the selected state values.
43
- *
44
- * Available rate limiter state properties:
45
- * - `callsInWindow`: Number of calls made in the current window
46
- * - `remainingInWindow`: Number of calls remaining in the current window
47
- * - `windowStart`: Unix timestamp when the current window started
48
- * - `nextWindowStart`: Unix timestamp when the next window will start
49
- * - `msUntilNextWindow`: Milliseconds until the next window starts
50
- * - `isAtLimit`: Whether the call limit for the current window has been reached
51
- * - `status`: Current status ('disabled' | 'idle' | 'at-limit')
52
- *
53
- * @example
54
- * ```tsx
55
- * // Default behavior - no reactive state subscriptions
56
- * const [value, setValue, rateLimiter] = createRateLimitedSignal(0, {
57
- * limit: 5,
58
- * window: 60000,
59
- * windowType: 'sliding'
60
- * });
61
- *
62
- * // Opt-in to reactive updates when limit state changes (optimized for UI feedback)
63
- * const [value, setValue, rateLimiter] = createRateLimitedSignal(
64
- * 0,
65
- * { limit: 5, window: 60000 },
66
- * (state) => ({ isAtLimit: state.isAtLimit, remainingInWindow: state.remainingInWindow })
67
- * );
68
- *
69
- * // With rejection callback and fixed window
70
- * const [value, setValue] = createRateLimitedSignal(0, {
71
- * limit: 3,
72
- * window: 5000,
73
- * windowType: 'fixed',
74
- * onReject: (rateLimiter) => {
75
- * alert(`Rate limit reached. Try again in ${rateLimiter.getMsUntilNextWindow()}ms`);
76
- * }
77
- * });
78
- *
79
- * // Access rateLimiter state via signals
80
- * const handleSubmit = () => {
81
- * const remaining = rateLimiter.state().remainingInWindow;
82
- * if (remaining > 0) {
83
- * setValue(newValue);
84
- * } else {
85
- * showRateLimitWarning();
86
- * }
87
- * };
88
- * ```
89
- */
90
- function createRateLimitedSignal(value, initialOptions, selector) {
91
- const [rateLimitedValue, setRateLimitedValue] = (0, solid_js.createSignal)(value);
92
- const rateLimiter = require_createRateLimiter.createRateLimiter(setRateLimitedValue, initialOptions, selector);
93
- return [
94
- rateLimitedValue,
95
- rateLimiter.maybeExecute,
96
- rateLimiter
97
- ];
98
- }
99
-
100
- //#endregion
101
- exports.createRateLimitedSignal = createRateLimitedSignal;
102
- //# sourceMappingURL=createRateLimitedSignal.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createRateLimitedSignal.cjs","names":["createSignal","createRateLimiter"],"sources":["../../src/rate-limiter/createRateLimitedSignal.ts"],"sourcesContent":["import { createSignal } from 'solid-js'\nimport { createRateLimiter } from './createRateLimiter'\nimport type {\n SolidRateLimiter,\n SolidRateLimiterOptions,\n} from './createRateLimiter'\nimport type { Accessor, Setter } from 'solid-js'\nimport type { RateLimiterState } from '@tanstack/pacer/rate-limiter'\n\n/**\n * A Solid hook that creates a rate-limited state value that enforces a hard limit on state updates within a time window.\n * This hook combines Solid's createSignal with rate limiting functionality to provide controlled state updates.\n *\n * Rate limiting is a simple \"hard limit\" approach - it allows all updates until the limit is reached, then blocks\n * subsequent updates until the window resets. Unlike throttling or debouncing, it does not attempt to space out\n * or intelligently collapse updates. This can lead to bursts of rapid updates followed by periods of no updates.\n *\n * The rate limiter supports two types of windows:\n * - 'fixed': A strict window that resets after the window period. All updates within the window count\n * towards the limit, and the window resets completely after the period.\n * - 'sliding': A rolling window that allows updates as old ones expire. This provides a more\n * consistent rate of updates over time.\n *\n * For smoother update patterns, consider:\n * - createThrottledSignal: When you want consistent spacing between updates (e.g. UI changes)\n * - createDebouncedSignal: When you want to collapse rapid updates into a single update (e.g. search input)\n *\n * Rate limiting should primarily be used when you need to enforce strict limits, like API rate limits.\n *\n * The hook returns a tuple containing:\n * - The rate-limited state value accessor\n * - A rate-limited setter function that respects the configured limits\n * - The rateLimiter instance for additional control\n *\n * For more direct control over rate limiting without state management,\n * consider using the lower-level createRateLimiter hook instead.\n *\n * ## State Management and Selector\n *\n * The hook uses TanStack Store for reactive state management via the underlying rate limiter instance.\n * The `selector` parameter allows you to specify which rate limiter state changes will trigger reactive updates,\n * optimizing performance by preventing unnecessary subscriptions 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 reactive updates and gives you\n * full control over when your component subscribes to state changes. Only when you provide a selector will\n * the reactive system track the selected state values.\n *\n * Available rate limiter state properties:\n * - `callsInWindow`: Number of calls made in the current window\n * - `remainingInWindow`: Number of calls remaining in the current window\n * - `windowStart`: Unix timestamp when the current window started\n * - `nextWindowStart`: Unix timestamp when the next window will start\n * - `msUntilNextWindow`: Milliseconds until the next window starts\n * - `isAtLimit`: Whether the call limit for the current window has been reached\n * - `status`: Current status ('disabled' | 'idle' | 'at-limit')\n *\n * @example\n * ```tsx\n * // Default behavior - no reactive state subscriptions\n * const [value, setValue, rateLimiter] = createRateLimitedSignal(0, {\n * limit: 5,\n * window: 60000,\n * windowType: 'sliding'\n * });\n *\n * // Opt-in to reactive updates when limit state changes (optimized for UI feedback)\n * const [value, setValue, rateLimiter] = createRateLimitedSignal(\n * 0,\n * { limit: 5, window: 60000 },\n * (state) => ({ isAtLimit: state.isAtLimit, remainingInWindow: state.remainingInWindow })\n * );\n *\n * // With rejection callback and fixed window\n * const [value, setValue] = createRateLimitedSignal(0, {\n * limit: 3,\n * window: 5000,\n * windowType: 'fixed',\n * onReject: (rateLimiter) => {\n * alert(`Rate limit reached. Try again in ${rateLimiter.getMsUntilNextWindow()}ms`);\n * }\n * });\n *\n * // Access rateLimiter state via signals\n * const handleSubmit = () => {\n * const remaining = rateLimiter.state().remainingInWindow;\n * if (remaining > 0) {\n * setValue(newValue);\n * } else {\n * showRateLimitWarning();\n * }\n * };\n * ```\n */\nexport function createRateLimitedSignal<TValue, TSelected = {}>(\n value: TValue,\n initialOptions: SolidRateLimiterOptions<Setter<TValue>, TSelected>,\n selector?: (state: RateLimiterState) => TSelected,\n): [\n Accessor<TValue>,\n Setter<TValue>,\n SolidRateLimiter<Setter<TValue>, TSelected>,\n] {\n const [rateLimitedValue, setRateLimitedValue] = createSignal<TValue>(value)\n\n const rateLimiter = createRateLimiter(\n setRateLimitedValue,\n initialOptions,\n selector,\n )\n\n return [\n rateLimitedValue,\n rateLimiter.maybeExecute as Setter<TValue>,\n rateLimiter,\n ]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8FA,SAAgB,wBACd,OACA,gBACA,UAKA;CACA,MAAM,CAAC,kBAAkB,2BAAuBA,uBAAqB,KAAK;CAE1E,MAAM,cAAcC,4CAClB,qBACA,gBACA,QACF;CAEA,OAAO;EACL;EACA,YAAY;EACZ;CACF;AACF"}
@@ -1,93 +0,0 @@
1
- import { SolidRateLimiter, SolidRateLimiterOptions } from "./createRateLimiter.cjs";
2
- import { Accessor, Setter } from "solid-js";
3
- import { RateLimiterState } from "@tanstack/pacer/rate-limiter";
4
- //#region src/rate-limiter/createRateLimitedSignal.d.ts
5
- /**
6
- * A Solid hook that creates a rate-limited state value that enforces a hard limit on state updates within a time window.
7
- * This hook combines Solid's createSignal with rate limiting functionality to provide controlled state updates.
8
- *
9
- * Rate limiting is a simple "hard limit" approach - it allows all updates until the limit is reached, then blocks
10
- * subsequent updates until the window resets. Unlike throttling or debouncing, it does not attempt to space out
11
- * or intelligently collapse updates. This can lead to bursts of rapid updates followed by periods of no updates.
12
- *
13
- * The rate limiter supports two types of windows:
14
- * - 'fixed': A strict window that resets after the window period. All updates within the window count
15
- * towards the limit, and the window resets completely after the period.
16
- * - 'sliding': A rolling window that allows updates as old ones expire. This provides a more
17
- * consistent rate of updates over time.
18
- *
19
- * For smoother update patterns, consider:
20
- * - createThrottledSignal: When you want consistent spacing between updates (e.g. UI changes)
21
- * - createDebouncedSignal: When you want to collapse rapid updates into a single update (e.g. search input)
22
- *
23
- * Rate limiting should primarily be used when you need to enforce strict limits, like API rate limits.
24
- *
25
- * The hook returns a tuple containing:
26
- * - The rate-limited state value accessor
27
- * - A rate-limited setter function that respects the configured limits
28
- * - The rateLimiter instance for additional control
29
- *
30
- * For more direct control over rate limiting without state management,
31
- * consider using the lower-level createRateLimiter hook instead.
32
- *
33
- * ## State Management and Selector
34
- *
35
- * The hook uses TanStack Store for reactive state management via the underlying rate limiter instance.
36
- * The `selector` parameter allows you to specify which rate limiter state changes will trigger reactive updates,
37
- * optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.
38
- *
39
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
40
- * tracking by providing a selector function. This prevents unnecessary reactive updates and gives you
41
- * full control over when your component subscribes to state changes. Only when you provide a selector will
42
- * the reactive system track the selected state values.
43
- *
44
- * Available rate limiter state properties:
45
- * - `callsInWindow`: Number of calls made in the current window
46
- * - `remainingInWindow`: Number of calls remaining in the current window
47
- * - `windowStart`: Unix timestamp when the current window started
48
- * - `nextWindowStart`: Unix timestamp when the next window will start
49
- * - `msUntilNextWindow`: Milliseconds until the next window starts
50
- * - `isAtLimit`: Whether the call limit for the current window has been reached
51
- * - `status`: Current status ('disabled' | 'idle' | 'at-limit')
52
- *
53
- * @example
54
- * ```tsx
55
- * // Default behavior - no reactive state subscriptions
56
- * const [value, setValue, rateLimiter] = createRateLimitedSignal(0, {
57
- * limit: 5,
58
- * window: 60000,
59
- * windowType: 'sliding'
60
- * });
61
- *
62
- * // Opt-in to reactive updates when limit state changes (optimized for UI feedback)
63
- * const [value, setValue, rateLimiter] = createRateLimitedSignal(
64
- * 0,
65
- * { limit: 5, window: 60000 },
66
- * (state) => ({ isAtLimit: state.isAtLimit, remainingInWindow: state.remainingInWindow })
67
- * );
68
- *
69
- * // With rejection callback and fixed window
70
- * const [value, setValue] = createRateLimitedSignal(0, {
71
- * limit: 3,
72
- * window: 5000,
73
- * windowType: 'fixed',
74
- * onReject: (rateLimiter) => {
75
- * alert(`Rate limit reached. Try again in ${rateLimiter.getMsUntilNextWindow()}ms`);
76
- * }
77
- * });
78
- *
79
- * // Access rateLimiter state via signals
80
- * const handleSubmit = () => {
81
- * const remaining = rateLimiter.state().remainingInWindow;
82
- * if (remaining > 0) {
83
- * setValue(newValue);
84
- * } else {
85
- * showRateLimitWarning();
86
- * }
87
- * };
88
- * ```
89
- */
90
- declare function createRateLimitedSignal<TValue, TSelected = {}>(value: TValue, initialOptions: SolidRateLimiterOptions<Setter<TValue>, TSelected>, selector?: (state: RateLimiterState) => TSelected): [Accessor<TValue>, Setter<TValue>, SolidRateLimiter<Setter<TValue>, TSelected>];
91
- //#endregion
92
- export { createRateLimitedSignal };
93
- //# sourceMappingURL=createRateLimitedSignal.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createRateLimitedSignal.js","names":[],"sources":["../../src/rate-limiter/createRateLimitedSignal.ts"],"sourcesContent":["import { createSignal } from 'solid-js'\nimport { createRateLimiter } from './createRateLimiter'\nimport type {\n SolidRateLimiter,\n SolidRateLimiterOptions,\n} from './createRateLimiter'\nimport type { Accessor, Setter } from 'solid-js'\nimport type { RateLimiterState } from '@tanstack/pacer/rate-limiter'\n\n/**\n * A Solid hook that creates a rate-limited state value that enforces a hard limit on state updates within a time window.\n * This hook combines Solid's createSignal with rate limiting functionality to provide controlled state updates.\n *\n * Rate limiting is a simple \"hard limit\" approach - it allows all updates until the limit is reached, then blocks\n * subsequent updates until the window resets. Unlike throttling or debouncing, it does not attempt to space out\n * or intelligently collapse updates. This can lead to bursts of rapid updates followed by periods of no updates.\n *\n * The rate limiter supports two types of windows:\n * - 'fixed': A strict window that resets after the window period. All updates within the window count\n * towards the limit, and the window resets completely after the period.\n * - 'sliding': A rolling window that allows updates as old ones expire. This provides a more\n * consistent rate of updates over time.\n *\n * For smoother update patterns, consider:\n * - createThrottledSignal: When you want consistent spacing between updates (e.g. UI changes)\n * - createDebouncedSignal: When you want to collapse rapid updates into a single update (e.g. search input)\n *\n * Rate limiting should primarily be used when you need to enforce strict limits, like API rate limits.\n *\n * The hook returns a tuple containing:\n * - The rate-limited state value accessor\n * - A rate-limited setter function that respects the configured limits\n * - The rateLimiter instance for additional control\n *\n * For more direct control over rate limiting without state management,\n * consider using the lower-level createRateLimiter hook instead.\n *\n * ## State Management and Selector\n *\n * The hook uses TanStack Store for reactive state management via the underlying rate limiter instance.\n * The `selector` parameter allows you to specify which rate limiter state changes will trigger reactive updates,\n * optimizing performance by preventing unnecessary subscriptions 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 reactive updates and gives you\n * full control over when your component subscribes to state changes. Only when you provide a selector will\n * the reactive system track the selected state values.\n *\n * Available rate limiter state properties:\n * - `callsInWindow`: Number of calls made in the current window\n * - `remainingInWindow`: Number of calls remaining in the current window\n * - `windowStart`: Unix timestamp when the current window started\n * - `nextWindowStart`: Unix timestamp when the next window will start\n * - `msUntilNextWindow`: Milliseconds until the next window starts\n * - `isAtLimit`: Whether the call limit for the current window has been reached\n * - `status`: Current status ('disabled' | 'idle' | 'at-limit')\n *\n * @example\n * ```tsx\n * // Default behavior - no reactive state subscriptions\n * const [value, setValue, rateLimiter] = createRateLimitedSignal(0, {\n * limit: 5,\n * window: 60000,\n * windowType: 'sliding'\n * });\n *\n * // Opt-in to reactive updates when limit state changes (optimized for UI feedback)\n * const [value, setValue, rateLimiter] = createRateLimitedSignal(\n * 0,\n * { limit: 5, window: 60000 },\n * (state) => ({ isAtLimit: state.isAtLimit, remainingInWindow: state.remainingInWindow })\n * );\n *\n * // With rejection callback and fixed window\n * const [value, setValue] = createRateLimitedSignal(0, {\n * limit: 3,\n * window: 5000,\n * windowType: 'fixed',\n * onReject: (rateLimiter) => {\n * alert(`Rate limit reached. Try again in ${rateLimiter.getMsUntilNextWindow()}ms`);\n * }\n * });\n *\n * // Access rateLimiter state via signals\n * const handleSubmit = () => {\n * const remaining = rateLimiter.state().remainingInWindow;\n * if (remaining > 0) {\n * setValue(newValue);\n * } else {\n * showRateLimitWarning();\n * }\n * };\n * ```\n */\nexport function createRateLimitedSignal<TValue, TSelected = {}>(\n value: TValue,\n initialOptions: SolidRateLimiterOptions<Setter<TValue>, TSelected>,\n selector?: (state: RateLimiterState) => TSelected,\n): [\n Accessor<TValue>,\n Setter<TValue>,\n SolidRateLimiter<Setter<TValue>, TSelected>,\n] {\n const [rateLimitedValue, setRateLimitedValue] = createSignal<TValue>(value)\n\n const rateLimiter = createRateLimiter(\n setRateLimitedValue,\n initialOptions,\n selector,\n )\n\n return [\n rateLimitedValue,\n rateLimiter.maybeExecute as Setter<TValue>,\n rateLimiter,\n ]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8FA,SAAgB,wBACd,OACA,gBACA,UAKA;CACA,MAAM,CAAC,kBAAkB,uBAAuB,aAAqB,KAAK;CAE1E,MAAM,cAAc,kBAClB,qBACA,gBACA,QACF;CAEA,OAAO;EACL;EACA,YAAY;EACZ;CACF;AACF"}
@@ -1,102 +0,0 @@
1
- const require_createRateLimitedSignal = require('./createRateLimitedSignal.cjs');
2
- let solid_js = require("solid-js");
3
-
4
- //#region src/rate-limiter/createRateLimitedValue.ts
5
- /**
6
- * A high-level Solid hook that creates a rate-limited version of a value that updates at most a certain number of times within a time window.
7
- * This hook uses Solid's createSignal internally to manage the rate-limited state.
8
- *
9
- * Rate limiting is a simple "hard limit" approach - it allows all updates until the limit is reached, then blocks
10
- * subsequent updates until the window resets. Unlike throttling or debouncing, it does not attempt to space out
11
- * or intelligently collapse updates. This can lead to bursts of rapid updates followed by periods of no updates.
12
- *
13
- * The rate limiter supports two types of windows:
14
- * - 'fixed': A strict window that resets after the window period. All updates within the window count
15
- * towards the limit, and the window resets completely after the period.
16
- * - 'sliding': A rolling window that allows updates as old ones expire. This provides a more
17
- * consistent rate of updates over time.
18
- *
19
- * For smoother update patterns, consider:
20
- * - createThrottledValue: When you want consistent spacing between updates (e.g. UI changes)
21
- * - createDebouncedValue: When you want to collapse rapid updates into a single update (e.g. search input)
22
- *
23
- * Rate limiting should primarily be used when you need to enforce strict limits, like API rate limits.
24
- *
25
- * The hook returns a tuple containing:
26
- * - An accessor function that provides the rate-limited value
27
- * - The rate limiter instance with control methods
28
- *
29
- * For more direct control over rate limiting behavior without Solid state management,
30
- * consider using the lower-level createRateLimiter hook instead.
31
- *
32
- * ## State Management and Selector
33
- *
34
- * The hook uses TanStack Store for reactive state management via the underlying rate limiter instance.
35
- * The `selector` parameter allows you to specify which rate limiter state changes will trigger reactive updates,
36
- * optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.
37
- *
38
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
39
- * tracking by providing a selector function. This prevents unnecessary reactive updates and gives you
40
- * full control over when your component subscribes to state changes. Only when you provide a selector will
41
- * the reactive system track the selected state values.
42
- *
43
- * Available rate limiter state properties:
44
- * - `executionCount`: Number of function executions that have been completed
45
- * - `executionTimes`: Array of timestamps when executions occurred for rate limiting calculations
46
- * - `rejectionCount`: Number of function executions that have been rejected due to rate limiting
47
- *
48
- * @example
49
- * ```tsx
50
- * // Default behavior - no reactive state subscriptions
51
- * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(rawValue, {
52
- * limit: 5,
53
- * window: 60000,
54
- * windowType: 'sliding'
55
- * });
56
- *
57
- * // Opt-in to reactive updates when execution count changes (optimized for tracking successful updates)
58
- * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(
59
- * rawValue,
60
- * { limit: 5, window: 60000, windowType: 'sliding' },
61
- * (state) => ({ executionCount: state.executionCount })
62
- * );
63
- *
64
- * // Opt-in to reactive updates when rejection count changes (optimized for tracking rate limit violations)
65
- * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(
66
- * rawValue,
67
- * { limit: 5, window: 60000, windowType: 'sliding' },
68
- * (state) => ({ rejectionCount: state.rejectionCount })
69
- * );
70
- *
71
- * // Opt-in to reactive updates when execution times change (optimized for window calculations)
72
- * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(
73
- * rawValue,
74
- * { limit: 5, window: 60000, windowType: 'sliding' },
75
- * (state) => ({ executionTimes: state.executionTimes })
76
- * );
77
- *
78
- * // With rejection callback and fixed window
79
- * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(rawValue, {
80
- * limit: 3,
81
- * window: 5000,
82
- * windowType: 'fixed',
83
- * onReject: (rateLimiter) => {
84
- * console.log(`Update rejected. Try again in ${rateLimiter.getMsUntilNextWindow()}ms`);
85
- * }
86
- * });
87
- *
88
- * // Access the selected rate limiter state (will be empty object {} unless selector provided)
89
- * const { executionCount, rejectionCount } = rateLimiter.state;
90
- * ```
91
- */
92
- function createRateLimitedValue(value, initialOptions, selector) {
93
- const [rateLimitedValue, setRateLimitedValue, rateLimiter] = require_createRateLimitedSignal.createRateLimitedSignal(value(), initialOptions, selector);
94
- (0, solid_js.createEffect)(() => {
95
- setRateLimitedValue(value());
96
- });
97
- return [rateLimitedValue, rateLimiter];
98
- }
99
-
100
- //#endregion
101
- exports.createRateLimitedValue = createRateLimitedValue;
102
- //# sourceMappingURL=createRateLimitedValue.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createRateLimitedValue.cjs","names":["createRateLimitedSignal"],"sources":["../../src/rate-limiter/createRateLimitedValue.ts"],"sourcesContent":["import { createEffect } from 'solid-js'\nimport { createRateLimitedSignal } from './createRateLimitedSignal'\nimport type {\n SolidRateLimiter,\n SolidRateLimiterOptions,\n} from './createRateLimiter'\nimport type { Accessor, Setter } from 'solid-js'\nimport type { RateLimiterState } from '@tanstack/pacer/rate-limiter'\n\n/**\n * A high-level Solid hook that creates a rate-limited version of a value that updates at most a certain number of times within a time window.\n * This hook uses Solid's createSignal internally to manage the rate-limited state.\n *\n * Rate limiting is a simple \"hard limit\" approach - it allows all updates until the limit is reached, then blocks\n * subsequent updates until the window resets. Unlike throttling or debouncing, it does not attempt to space out\n * or intelligently collapse updates. This can lead to bursts of rapid updates followed by periods of no updates.\n *\n * The rate limiter supports two types of windows:\n * - 'fixed': A strict window that resets after the window period. All updates within the window count\n * towards the limit, and the window resets completely after the period.\n * - 'sliding': A rolling window that allows updates as old ones expire. This provides a more\n * consistent rate of updates over time.\n *\n * For smoother update patterns, consider:\n * - createThrottledValue: When you want consistent spacing between updates (e.g. UI changes)\n * - createDebouncedValue: When you want to collapse rapid updates into a single update (e.g. search input)\n *\n * Rate limiting should primarily be used when you need to enforce strict limits, like API rate limits.\n *\n * The hook returns a tuple containing:\n * - An accessor function that provides the rate-limited value\n * - The rate limiter instance with control methods\n *\n * For more direct control over rate limiting behavior without Solid state management,\n * consider using the lower-level createRateLimiter hook instead.\n *\n * ## State Management and Selector\n *\n * The hook uses TanStack Store for reactive state management via the underlying rate limiter instance.\n * The `selector` parameter allows you to specify which rate limiter state changes will trigger reactive updates,\n * optimizing performance by preventing unnecessary subscriptions 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 reactive updates and gives you\n * full control over when your component subscribes to state changes. Only when you provide a selector will\n * the reactive system track the selected state values.\n *\n * Available rate limiter state properties:\n * - `executionCount`: Number of function executions that have been completed\n * - `executionTimes`: Array of timestamps when executions occurred for rate limiting calculations\n * - `rejectionCount`: Number of function executions that have been rejected due to rate limiting\n *\n * @example\n * ```tsx\n * // Default behavior - no reactive state subscriptions\n * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(rawValue, {\n * limit: 5,\n * window: 60000,\n * windowType: 'sliding'\n * });\n *\n * // Opt-in to reactive updates when execution count changes (optimized for tracking successful updates)\n * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(\n * rawValue,\n * { limit: 5, window: 60000, windowType: 'sliding' },\n * (state) => ({ executionCount: state.executionCount })\n * );\n *\n * // Opt-in to reactive updates when rejection count changes (optimized for tracking rate limit violations)\n * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(\n * rawValue,\n * { limit: 5, window: 60000, windowType: 'sliding' },\n * (state) => ({ rejectionCount: state.rejectionCount })\n * );\n *\n * // Opt-in to reactive updates when execution times change (optimized for window calculations)\n * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(\n * rawValue,\n * { limit: 5, window: 60000, windowType: 'sliding' },\n * (state) => ({ executionTimes: state.executionTimes })\n * );\n *\n * // With rejection callback and fixed window\n * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(rawValue, {\n * limit: 3,\n * window: 5000,\n * windowType: 'fixed',\n * onReject: (rateLimiter) => {\n * console.log(`Update rejected. Try again in ${rateLimiter.getMsUntilNextWindow()}ms`);\n * }\n * });\n *\n * // Access the selected rate limiter state (will be empty object {} unless selector provided)\n * const { executionCount, rejectionCount } = rateLimiter.state;\n * ```\n */\nexport function createRateLimitedValue<TValue, TSelected = {}>(\n value: Accessor<TValue>,\n initialOptions: SolidRateLimiterOptions<Setter<TValue>, TSelected>,\n selector?: (state: RateLimiterState) => TSelected,\n): [Accessor<TValue>, SolidRateLimiter<Setter<TValue>, TSelected>] {\n const [rateLimitedValue, setRateLimitedValue, rateLimiter] =\n createRateLimitedSignal(value(), initialOptions, selector)\n\n createEffect(() => {\n setRateLimitedValue(value() as any)\n })\n\n return [rateLimitedValue, rateLimiter]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGA,SAAgB,uBACd,OACA,gBACA,UACiE;CACjE,MAAM,CAAC,kBAAkB,qBAAqB,eAC5CA,wDAAwB,MAAM,GAAG,gBAAgB,QAAQ;CAE3D,iCAAmB;EACjB,oBAAoB,MAAM,CAAQ;CACpC,CAAC;CAED,OAAO,CAAC,kBAAkB,WAAW;AACvC"}
@@ -1,95 +0,0 @@
1
- import { SolidRateLimiter, SolidRateLimiterOptions } from "./createRateLimiter.cjs";
2
- import { Accessor, Setter } from "solid-js";
3
- import { RateLimiterState } from "@tanstack/pacer/rate-limiter";
4
- //#region src/rate-limiter/createRateLimitedValue.d.ts
5
- /**
6
- * A high-level Solid hook that creates a rate-limited version of a value that updates at most a certain number of times within a time window.
7
- * This hook uses Solid's createSignal internally to manage the rate-limited state.
8
- *
9
- * Rate limiting is a simple "hard limit" approach - it allows all updates until the limit is reached, then blocks
10
- * subsequent updates until the window resets. Unlike throttling or debouncing, it does not attempt to space out
11
- * or intelligently collapse updates. This can lead to bursts of rapid updates followed by periods of no updates.
12
- *
13
- * The rate limiter supports two types of windows:
14
- * - 'fixed': A strict window that resets after the window period. All updates within the window count
15
- * towards the limit, and the window resets completely after the period.
16
- * - 'sliding': A rolling window that allows updates as old ones expire. This provides a more
17
- * consistent rate of updates over time.
18
- *
19
- * For smoother update patterns, consider:
20
- * - createThrottledValue: When you want consistent spacing between updates (e.g. UI changes)
21
- * - createDebouncedValue: When you want to collapse rapid updates into a single update (e.g. search input)
22
- *
23
- * Rate limiting should primarily be used when you need to enforce strict limits, like API rate limits.
24
- *
25
- * The hook returns a tuple containing:
26
- * - An accessor function that provides the rate-limited value
27
- * - The rate limiter instance with control methods
28
- *
29
- * For more direct control over rate limiting behavior without Solid state management,
30
- * consider using the lower-level createRateLimiter hook instead.
31
- *
32
- * ## State Management and Selector
33
- *
34
- * The hook uses TanStack Store for reactive state management via the underlying rate limiter instance.
35
- * The `selector` parameter allows you to specify which rate limiter state changes will trigger reactive updates,
36
- * optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.
37
- *
38
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
39
- * tracking by providing a selector function. This prevents unnecessary reactive updates and gives you
40
- * full control over when your component subscribes to state changes. Only when you provide a selector will
41
- * the reactive system track the selected state values.
42
- *
43
- * Available rate limiter state properties:
44
- * - `executionCount`: Number of function executions that have been completed
45
- * - `executionTimes`: Array of timestamps when executions occurred for rate limiting calculations
46
- * - `rejectionCount`: Number of function executions that have been rejected due to rate limiting
47
- *
48
- * @example
49
- * ```tsx
50
- * // Default behavior - no reactive state subscriptions
51
- * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(rawValue, {
52
- * limit: 5,
53
- * window: 60000,
54
- * windowType: 'sliding'
55
- * });
56
- *
57
- * // Opt-in to reactive updates when execution count changes (optimized for tracking successful updates)
58
- * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(
59
- * rawValue,
60
- * { limit: 5, window: 60000, windowType: 'sliding' },
61
- * (state) => ({ executionCount: state.executionCount })
62
- * );
63
- *
64
- * // Opt-in to reactive updates when rejection count changes (optimized for tracking rate limit violations)
65
- * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(
66
- * rawValue,
67
- * { limit: 5, window: 60000, windowType: 'sliding' },
68
- * (state) => ({ rejectionCount: state.rejectionCount })
69
- * );
70
- *
71
- * // Opt-in to reactive updates when execution times change (optimized for window calculations)
72
- * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(
73
- * rawValue,
74
- * { limit: 5, window: 60000, windowType: 'sliding' },
75
- * (state) => ({ executionTimes: state.executionTimes })
76
- * );
77
- *
78
- * // With rejection callback and fixed window
79
- * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(rawValue, {
80
- * limit: 3,
81
- * window: 5000,
82
- * windowType: 'fixed',
83
- * onReject: (rateLimiter) => {
84
- * console.log(`Update rejected. Try again in ${rateLimiter.getMsUntilNextWindow()}ms`);
85
- * }
86
- * });
87
- *
88
- * // Access the selected rate limiter state (will be empty object {} unless selector provided)
89
- * const { executionCount, rejectionCount } = rateLimiter.state;
90
- * ```
91
- */
92
- declare function createRateLimitedValue<TValue, TSelected = {}>(value: Accessor<TValue>, initialOptions: SolidRateLimiterOptions<Setter<TValue>, TSelected>, selector?: (state: RateLimiterState) => TSelected): [Accessor<TValue>, SolidRateLimiter<Setter<TValue>, TSelected>];
93
- //#endregion
94
- export { createRateLimitedValue };
95
- //# sourceMappingURL=createRateLimitedValue.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createRateLimitedValue.js","names":[],"sources":["../../src/rate-limiter/createRateLimitedValue.ts"],"sourcesContent":["import { createEffect } from 'solid-js'\nimport { createRateLimitedSignal } from './createRateLimitedSignal'\nimport type {\n SolidRateLimiter,\n SolidRateLimiterOptions,\n} from './createRateLimiter'\nimport type { Accessor, Setter } from 'solid-js'\nimport type { RateLimiterState } from '@tanstack/pacer/rate-limiter'\n\n/**\n * A high-level Solid hook that creates a rate-limited version of a value that updates at most a certain number of times within a time window.\n * This hook uses Solid's createSignal internally to manage the rate-limited state.\n *\n * Rate limiting is a simple \"hard limit\" approach - it allows all updates until the limit is reached, then blocks\n * subsequent updates until the window resets. Unlike throttling or debouncing, it does not attempt to space out\n * or intelligently collapse updates. This can lead to bursts of rapid updates followed by periods of no updates.\n *\n * The rate limiter supports two types of windows:\n * - 'fixed': A strict window that resets after the window period. All updates within the window count\n * towards the limit, and the window resets completely after the period.\n * - 'sliding': A rolling window that allows updates as old ones expire. This provides a more\n * consistent rate of updates over time.\n *\n * For smoother update patterns, consider:\n * - createThrottledValue: When you want consistent spacing between updates (e.g. UI changes)\n * - createDebouncedValue: When you want to collapse rapid updates into a single update (e.g. search input)\n *\n * Rate limiting should primarily be used when you need to enforce strict limits, like API rate limits.\n *\n * The hook returns a tuple containing:\n * - An accessor function that provides the rate-limited value\n * - The rate limiter instance with control methods\n *\n * For more direct control over rate limiting behavior without Solid state management,\n * consider using the lower-level createRateLimiter hook instead.\n *\n * ## State Management and Selector\n *\n * The hook uses TanStack Store for reactive state management via the underlying rate limiter instance.\n * The `selector` parameter allows you to specify which rate limiter state changes will trigger reactive updates,\n * optimizing performance by preventing unnecessary subscriptions 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 reactive updates and gives you\n * full control over when your component subscribes to state changes. Only when you provide a selector will\n * the reactive system track the selected state values.\n *\n * Available rate limiter state properties:\n * - `executionCount`: Number of function executions that have been completed\n * - `executionTimes`: Array of timestamps when executions occurred for rate limiting calculations\n * - `rejectionCount`: Number of function executions that have been rejected due to rate limiting\n *\n * @example\n * ```tsx\n * // Default behavior - no reactive state subscriptions\n * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(rawValue, {\n * limit: 5,\n * window: 60000,\n * windowType: 'sliding'\n * });\n *\n * // Opt-in to reactive updates when execution count changes (optimized for tracking successful updates)\n * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(\n * rawValue,\n * { limit: 5, window: 60000, windowType: 'sliding' },\n * (state) => ({ executionCount: state.executionCount })\n * );\n *\n * // Opt-in to reactive updates when rejection count changes (optimized for tracking rate limit violations)\n * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(\n * rawValue,\n * { limit: 5, window: 60000, windowType: 'sliding' },\n * (state) => ({ rejectionCount: state.rejectionCount })\n * );\n *\n * // Opt-in to reactive updates when execution times change (optimized for window calculations)\n * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(\n * rawValue,\n * { limit: 5, window: 60000, windowType: 'sliding' },\n * (state) => ({ executionTimes: state.executionTimes })\n * );\n *\n * // With rejection callback and fixed window\n * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(rawValue, {\n * limit: 3,\n * window: 5000,\n * windowType: 'fixed',\n * onReject: (rateLimiter) => {\n * console.log(`Update rejected. Try again in ${rateLimiter.getMsUntilNextWindow()}ms`);\n * }\n * });\n *\n * // Access the selected rate limiter state (will be empty object {} unless selector provided)\n * const { executionCount, rejectionCount } = rateLimiter.state;\n * ```\n */\nexport function createRateLimitedValue<TValue, TSelected = {}>(\n value: Accessor<TValue>,\n initialOptions: SolidRateLimiterOptions<Setter<TValue>, TSelected>,\n selector?: (state: RateLimiterState) => TSelected,\n): [Accessor<TValue>, SolidRateLimiter<Setter<TValue>, TSelected>] {\n const [rateLimitedValue, setRateLimitedValue, rateLimiter] =\n createRateLimitedSignal(value(), initialOptions, selector)\n\n createEffect(() => {\n setRateLimitedValue(value() as any)\n })\n\n return [rateLimitedValue, rateLimiter]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGA,SAAgB,uBACd,OACA,gBACA,UACiE;CACjE,MAAM,CAAC,kBAAkB,qBAAqB,eAC5C,wBAAwB,MAAM,GAAG,gBAAgB,QAAQ;CAE3D,mBAAmB;EACjB,oBAAoB,MAAM,CAAQ;CACpC,CAAC;CAED,OAAO,CAAC,kBAAkB,WAAW;AACvC"}