@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
@@ -3,14 +3,14 @@ import { Store } from "@tanstack/solid-store";
3
3
  import { Debouncer, DebouncerOptions, DebouncerState } from "@tanstack/pacer/debouncer";
4
4
  import { AnyFunction } from "@tanstack/pacer/types";
5
5
  //#region src/debouncer/createDebouncer.d.ts
6
- interface SolidDebouncerOptions<TFn extends AnyFunction, TSelected = {}> extends DebouncerOptions<TFn> {
6
+ export interface SolidDebouncerOptions<TFn extends AnyFunction, TSelected = {}> extends DebouncerOptions<TFn> {
7
7
  /**
8
8
  * Optional callback invoked when the owning component unmounts. Receives the debouncer instance.
9
9
  * When provided, replaces the default cleanup (cancel); use it to call flush(), reset(), cancel(), add logging, etc.
10
10
  */
11
11
  onUnmount?: (debouncer: SolidDebouncer<TFn, TSelected>) => void;
12
12
  }
13
- interface SolidDebouncer<TFn extends AnyFunction, TSelected = {}> extends Omit<Debouncer<TFn>, 'store'> {
13
+ export interface SolidDebouncer<TFn extends AnyFunction, TSelected = {}> extends Omit<Debouncer<TFn>, 'store'> {
14
14
  /**
15
15
  * A Solid component that allows you to subscribe to the debouncer state.
16
16
  *
@@ -138,7 +138,5 @@ interface SolidDebouncer<TFn extends AnyFunction, TSelected = {}> extends Omit<D
138
138
  * const { isPending } = debouncer.state();
139
139
  * ```
140
140
  */
141
- declare function createDebouncer<TFn extends AnyFunction, TSelected = {}>(fn: TFn, options: SolidDebouncerOptions<TFn, TSelected>, selector?: (state: DebouncerState<TFn>) => TSelected): SolidDebouncer<TFn, TSelected>;
142
- //#endregion
143
- export { SolidDebouncer, SolidDebouncerOptions, createDebouncer };
144
- //# sourceMappingURL=createDebouncer.d.ts.map
141
+ export declare function createDebouncer<TFn extends AnyFunction, TSelected = {}>(fn: TFn, options: SolidDebouncerOptions<TFn, TSelected>, selector?: (state: DebouncerState<TFn>) => TSelected): SolidDebouncer<TFn, TSelected>;
142
+ //#endregion
@@ -125,5 +125,4 @@ function createDebouncer(fn, options, selector = () => ({})) {
125
125
  }
126
126
 
127
127
  //#endregion
128
- export { createDebouncer };
129
- //# sourceMappingURL=createDebouncer.js.map
128
+ export { createDebouncer };
@@ -1,7 +1,7 @@
1
1
  import { AnyAsyncFunction, AnyFunction, AsyncBatcherOptions, AsyncDebouncerOptions, AsyncQueuerOptions, AsyncRateLimiterOptions, AsyncThrottlerOptions, BatcherOptions, DebouncerOptions, QueuerOptions, RateLimiterOptions, ThrottlerOptions } from "@tanstack/pacer";
2
2
  import { JSX } from "solid-js";
3
3
  //#region src/provider/PacerProvider.d.ts
4
- interface PacerProviderOptions {
4
+ export interface PacerProviderOptions {
5
5
  asyncBatcher?: Partial<AsyncBatcherOptions<any>>;
6
6
  asyncDebouncer?: Partial<AsyncDebouncerOptions<AnyAsyncFunction>>;
7
7
  asyncQueuer?: Partial<AsyncQueuerOptions<any>>;
@@ -16,13 +16,11 @@ interface PacerProviderOptions {
16
16
  interface PacerContextValue {
17
17
  defaultOptions: PacerProviderOptions;
18
18
  }
19
- interface PacerProviderProps {
19
+ export interface PacerProviderProps {
20
20
  children: JSX.Element;
21
21
  defaultOptions?: PacerProviderOptions;
22
22
  }
23
- declare function PacerProvider(props: PacerProviderProps): JSX.Element;
24
- declare function usePacerContext(): PacerContextValue | null;
25
- declare function useDefaultPacerOptions(): PacerProviderOptions;
26
- //#endregion
27
- export { PacerProvider, PacerProviderOptions, PacerProviderProps, useDefaultPacerOptions, usePacerContext };
28
- //# sourceMappingURL=PacerProvider.d.ts.map
23
+ export declare function PacerProvider(props: PacerProviderProps): JSX.Element;
24
+ export declare function usePacerContext(): PacerContextValue | null;
25
+ export declare function useDefaultPacerOptions(): PacerProviderOptions;
26
+ //#endregion
@@ -21,5 +21,4 @@ function useDefaultPacerOptions() {
21
21
  }
22
22
 
23
23
  //#endregion
24
- export { PacerProvider, useDefaultPacerOptions, usePacerContext };
25
- //# sourceMappingURL=PacerProvider.js.map
24
+ export { PacerProvider, useDefaultPacerOptions, usePacerContext };
@@ -115,7 +115,5 @@ import { QueuerState } from "@tanstack/pacer/queuer";
115
115
  * const { size, isRunning, executionCount } = queue.state;
116
116
  * ```
117
117
  */
118
- declare function createQueuedSignal<TValue, TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<QueuerState<TValue>, 'items'>>(fn: (item: TValue) => void, options?: SolidQueuerOptions<TValue, TSelected>, selector?: (state: QueuerState<TValue>) => TSelected): [() => Array<TValue>, SolidQueuer<TValue, TSelected>['addItem'], SolidQueuer<TValue, TSelected>];
119
- //#endregion
120
- export { createQueuedSignal };
121
- //# sourceMappingURL=createQueuedSignal.d.ts.map
118
+ export declare function createQueuedSignal<TValue, TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<QueuerState<TValue>, 'items'>>(fn: (item: TValue) => void, options?: SolidQueuerOptions<TValue, TSelected>, selector?: (state: QueuerState<TValue>) => TSelected): [() => Array<TValue>, SolidQueuer<TValue, TSelected>['addItem'], SolidQueuer<TValue, TSelected>];
119
+ //#endregion
@@ -125,5 +125,4 @@ function createQueuedSignal(fn, options = {}, selector = (state) => ({ items: st
125
125
  }
126
126
 
127
127
  //#endregion
128
- export { createQueuedSignal };
129
- //# sourceMappingURL=createQueuedSignal.js.map
128
+ export { createQueuedSignal };
@@ -2,14 +2,14 @@ import { Accessor, JSX } from "solid-js";
2
2
  import { Store } from "@tanstack/solid-store";
3
3
  import { Queuer, QueuerOptions, QueuerState } from "@tanstack/pacer/queuer";
4
4
  //#region src/queuer/createQueuer.d.ts
5
- interface SolidQueuerOptions<TValue, TSelected = {}> extends QueuerOptions<TValue> {
5
+ export interface SolidQueuerOptions<TValue, TSelected = {}> extends QueuerOptions<TValue> {
6
6
  /**
7
7
  * Optional callback invoked when the owning component unmounts. Receives the queuer instance.
8
8
  * When provided, replaces the default cleanup (stop); use it to call flush(), flushAsBatch(), stop(), add logging, etc.
9
9
  */
10
10
  onUnmount?: (queuer: SolidQueuer<TValue, TSelected>) => void;
11
11
  }
12
- interface SolidQueuer<TValue, TSelected = {}> extends Omit<Queuer<TValue>, 'store'> {
12
+ export interface SolidQueuer<TValue, TSelected = {}> extends Omit<Queuer<TValue>, 'store'> {
13
13
  /**
14
14
  * A Solid component that allows you to subscribe to the queuer state.
15
15
  *
@@ -141,7 +141,5 @@ interface SolidQueuer<TValue, TSelected = {}> extends Omit<Queuer<TValue>, 'stor
141
141
  * const { items, isRunning } = queue.state();
142
142
  * ```
143
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.ts.map
144
+ export declare function createQueuer<TValue, TSelected = {}>(fn: (item: TValue) => void, options?: SolidQueuerOptions<TValue, TSelected>, selector?: (state: QueuerState<TValue>) => TSelected): SolidQueuer<TValue, TSelected>;
145
+ //#endregion
@@ -129,5 +129,4 @@ function createQueuer(fn, options = {}, selector = () => ({})) {
129
129
  }
130
130
 
131
131
  //#endregion
132
- export { createQueuer };
133
- //# sourceMappingURL=createQueuer.js.map
132
+ export { createQueuer };
@@ -42,13 +42,14 @@ import { RateLimiterState } from "@tanstack/pacer/rate-limiter";
42
42
  * the reactive system track the selected state values.
43
43
  *
44
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')
45
+ * - `executionCount`: Number of function executions
46
+ * - `executionTimes`: Timestamps of executions tracked for the current window
47
+ * - `maybeExecuteCount`: Number of calls to maybeExecute
48
+ * - `rejectionCount`: Number of calls rejected by the rate limit
49
+ * - `isExceeded`: Whether the rate limit has been reached
50
+ * - `status`: Current status ('disabled' | 'exceeded' | 'idle')
51
+ *
52
+ * Use `getRemainingInWindow()` and `getMsUntilNextWindow()` for current window capacity and timing.
52
53
  *
53
54
  * @example
54
55
  * ```tsx
@@ -63,7 +64,7 @@ import { RateLimiterState } from "@tanstack/pacer/rate-limiter";
63
64
  * const [value, setValue, rateLimiter] = createRateLimitedSignal(
64
65
  * 0,
65
66
  * { limit: 5, window: 60000 },
66
- * (state) => ({ isAtLimit: state.isAtLimit, remainingInWindow: state.remainingInWindow })
67
+ * (state) => ({ isExceeded: state.isExceeded })
67
68
  * );
68
69
  *
69
70
  * // With rejection callback and fixed window
@@ -78,7 +79,7 @@ import { RateLimiterState } from "@tanstack/pacer/rate-limiter";
78
79
  *
79
80
  * // Access rateLimiter state via signals
80
81
  * const handleSubmit = () => {
81
- * const remaining = rateLimiter.state().remainingInWindow;
82
+ * const remaining = rateLimiter.getRemainingInWindow();
82
83
  * if (remaining > 0) {
83
84
  * setValue(newValue);
84
85
  * } else {
@@ -87,7 +88,5 @@ import { RateLimiterState } from "@tanstack/pacer/rate-limiter";
87
88
  * };
88
89
  * ```
89
90
  */
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.ts.map
91
+ export declare function createRateLimitedSignal<TValue, TSelected = {}>(value: TValue, initialOptions: SolidRateLimiterOptions<Setter<TValue>, TSelected>, selector?: (state: RateLimiterState) => TSelected): [Accessor<TValue>, Setter<TValue>, SolidRateLimiter<Setter<TValue>, TSelected>];
92
+ //#endregion
@@ -42,13 +42,14 @@ import { createSignal } from "solid-js";
42
42
  * the reactive system track the selected state values.
43
43
  *
44
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')
45
+ * - `executionCount`: Number of function executions
46
+ * - `executionTimes`: Timestamps of executions tracked for the current window
47
+ * - `maybeExecuteCount`: Number of calls to maybeExecute
48
+ * - `rejectionCount`: Number of calls rejected by the rate limit
49
+ * - `isExceeded`: Whether the rate limit has been reached
50
+ * - `status`: Current status ('disabled' | 'exceeded' | 'idle')
51
+ *
52
+ * Use `getRemainingInWindow()` and `getMsUntilNextWindow()` for current window capacity and timing.
52
53
  *
53
54
  * @example
54
55
  * ```tsx
@@ -63,7 +64,7 @@ import { createSignal } from "solid-js";
63
64
  * const [value, setValue, rateLimiter] = createRateLimitedSignal(
64
65
  * 0,
65
66
  * { limit: 5, window: 60000 },
66
- * (state) => ({ isAtLimit: state.isAtLimit, remainingInWindow: state.remainingInWindow })
67
+ * (state) => ({ isExceeded: state.isExceeded })
67
68
  * );
68
69
  *
69
70
  * // With rejection callback and fixed window
@@ -78,7 +79,7 @@ import { createSignal } from "solid-js";
78
79
  *
79
80
  * // Access rateLimiter state via signals
80
81
  * const handleSubmit = () => {
81
- * const remaining = rateLimiter.state().remainingInWindow;
82
+ * const remaining = rateLimiter.getRemainingInWindow();
82
83
  * if (remaining > 0) {
83
84
  * setValue(newValue);
84
85
  * } else {
@@ -98,5 +99,4 @@ function createRateLimitedSignal(value, initialOptions, selector) {
98
99
  }
99
100
 
100
101
  //#endregion
101
- export { createRateLimitedSignal };
102
- //# sourceMappingURL=createRateLimitedSignal.js.map
102
+ export { createRateLimitedSignal };
@@ -89,7 +89,5 @@ import { RateLimiterState } from "@tanstack/pacer/rate-limiter";
89
89
  * const { executionCount, rejectionCount } = rateLimiter.state;
90
90
  * ```
91
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.ts.map
92
+ export 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
@@ -98,5 +98,4 @@ function createRateLimitedValue(value, initialOptions, selector) {
98
98
  }
99
99
 
100
100
  //#endregion
101
- export { createRateLimitedValue };
102
- //# sourceMappingURL=createRateLimitedValue.js.map
101
+ export { createRateLimitedValue };
@@ -3,14 +3,14 @@ import { Store } from "@tanstack/solid-store";
3
3
  import { RateLimiter, RateLimiterOptions, RateLimiterState } from "@tanstack/pacer/rate-limiter";
4
4
  import { AnyFunction } from "@tanstack/pacer/types";
5
5
  //#region src/rate-limiter/createRateLimiter.d.ts
6
- interface SolidRateLimiterOptions<TFn extends AnyFunction, TSelected = {}> extends RateLimiterOptions<TFn> {
6
+ export interface SolidRateLimiterOptions<TFn extends AnyFunction, TSelected = {}> extends RateLimiterOptions<TFn> {
7
7
  /**
8
8
  * Optional callback invoked when the owning component unmounts. Receives the rate limiter instance.
9
9
  * When provided, replaces the default cleanup; use it to call reset(), add logging, etc.
10
10
  */
11
11
  onUnmount?: (rateLimiter: SolidRateLimiter<TFn, TSelected>) => void;
12
12
  }
13
- interface SolidRateLimiter<TFn extends AnyFunction, TSelected = {}> extends Omit<RateLimiter<TFn>, 'store'> {
13
+ export interface SolidRateLimiter<TFn extends AnyFunction, TSelected = {}> extends Omit<RateLimiter<TFn>, 'store'> {
14
14
  /**
15
15
  * A Solid component that allows you to subscribe to the rate limiter state.
16
16
  *
@@ -83,12 +83,13 @@ interface SolidRateLimiter<TFn extends AnyFunction, TSelected = {}> extends Omit
83
83
  * tracking by providing a selector function or using the `Subscribe` component. This prevents unnecessary
84
84
  * updates and gives you full control over when your component tracks state changes.
85
85
  *
86
+ * Use `getRemainingInWindow()` and `getMsUntilNextWindow()` for current window capacity and timing.
87
+ *
86
88
  * Available state properties:
89
+ * - `executionTimes`: Timestamps of executions tracked for the current window
90
+ * - `isExceeded`: Whether the rate limit has been reached
87
91
  * - `executionCount`: Number of function executions that have been completed
88
92
  * - `rejectionCount`: Number of function calls that were rejected due to rate limiting
89
- * - `remainingInWindow`: Number of executions remaining in the current window
90
- * - `nextWindowTime`: Timestamp when the next window begins
91
- * - `currentWindowStart`: Timestamp when the current window started
92
93
  *
93
94
  * @example
94
95
  * ```tsx
@@ -167,7 +168,5 @@ interface SolidRateLimiter<TFn extends AnyFunction, TSelected = {}> extends Omit
167
168
  * const { executionCount, rejectionCount } = rateLimiter.state();
168
169
  * ```
169
170
  */
170
- declare function createRateLimiter<TFn extends AnyFunction, TSelected = {}>(fn: TFn, options: SolidRateLimiterOptions<TFn, TSelected>, selector?: (state: RateLimiterState) => TSelected): SolidRateLimiter<TFn, TSelected>;
171
- //#endregion
172
- export { SolidRateLimiter, SolidRateLimiterOptions, createRateLimiter };
173
- //# sourceMappingURL=createRateLimiter.d.ts.map
171
+ export declare function createRateLimiter<TFn extends AnyFunction, TSelected = {}>(fn: TFn, options: SolidRateLimiterOptions<TFn, TSelected>, selector?: (state: RateLimiterState) => TSelected): SolidRateLimiter<TFn, TSelected>;
172
+ //#endregion
@@ -46,12 +46,13 @@ import { RateLimiter } from "@tanstack/pacer/rate-limiter";
46
46
  * tracking by providing a selector function or using the `Subscribe` component. This prevents unnecessary
47
47
  * updates and gives you full control over when your component tracks state changes.
48
48
  *
49
+ * Use `getRemainingInWindow()` and `getMsUntilNextWindow()` for current window capacity and timing.
50
+ *
49
51
  * Available state properties:
52
+ * - `executionTimes`: Timestamps of executions tracked for the current window
53
+ * - `isExceeded`: Whether the rate limit has been reached
50
54
  * - `executionCount`: Number of function executions that have been completed
51
55
  * - `rejectionCount`: Number of function calls that were rejected due to rate limiting
52
- * - `remainingInWindow`: Number of executions remaining in the current window
53
- * - `nextWindowTime`: Timestamp when the next window begins
54
- * - `currentWindowStart`: Timestamp when the current window started
55
56
  *
56
57
  * @example
57
58
  * ```tsx
@@ -153,5 +154,4 @@ function createRateLimiter(fn, options, selector = () => ({})) {
153
154
  }
154
155
 
155
156
  //#endregion
156
- export { createRateLimiter };
157
- //# sourceMappingURL=createRateLimiter.js.map
157
+ export { createRateLimiter };
@@ -29,8 +29,6 @@ import { ThrottlerState } from "@tanstack/pacer/throttler";
29
29
  * the reactive system track the selected state values.
30
30
  *
31
31
  * Available throttler state properties:
32
- * - `canLeadingExecute`: Whether the throttler can execute on the leading edge
33
- * - `canTrailingExecute`: Whether the throttler can execute on the trailing edge
34
32
  * - `executionCount`: Number of function executions that have been completed
35
33
  * - `isPending`: Whether the throttler is waiting for the timeout to trigger trailing execution
36
34
  * - `lastArgs`: The arguments from the most recent call to maybeExecute
@@ -64,7 +62,5 @@ import { ThrottlerState } from "@tanstack/pacer/throttler";
64
62
  * console.log('Next execution:', throttler.state().nextExecutionTime);
65
63
  * ```
66
64
  */
67
- declare function createThrottledSignal<TValue, TSelected = {}>(value: TValue, initialOptions: SolidThrottlerOptions<Setter<TValue>, TSelected>, selector?: (state: ThrottlerState<Setter<TValue>>) => TSelected): [Accessor<TValue>, Setter<TValue>, SolidThrottler<Setter<TValue>, TSelected>];
68
- //#endregion
69
- export { createThrottledSignal };
70
- //# sourceMappingURL=createThrottledSignal.d.ts.map
65
+ export declare function createThrottledSignal<TValue, TSelected = {}>(value: TValue, initialOptions: SolidThrottlerOptions<Setter<TValue>, TSelected>, selector?: (state: ThrottlerState<Setter<TValue>>) => TSelected): [Accessor<TValue>, Setter<TValue>, SolidThrottler<Setter<TValue>, TSelected>];
66
+ //#endregion
@@ -29,8 +29,6 @@ import { createSignal } from "solid-js";
29
29
  * the reactive system track the selected state values.
30
30
  *
31
31
  * Available throttler state properties:
32
- * - `canLeadingExecute`: Whether the throttler can execute on the leading edge
33
- * - `canTrailingExecute`: Whether the throttler can execute on the trailing edge
34
32
  * - `executionCount`: Number of function executions that have been completed
35
33
  * - `isPending`: Whether the throttler is waiting for the timeout to trigger trailing execution
36
34
  * - `lastArgs`: The arguments from the most recent call to maybeExecute
@@ -75,5 +73,4 @@ function createThrottledSignal(value, initialOptions, selector) {
75
73
  }
76
74
 
77
75
  //#endregion
78
- export { createThrottledSignal };
79
- //# sourceMappingURL=createThrottledSignal.js.map
76
+ export { createThrottledSignal };
@@ -30,8 +30,6 @@ import { ThrottlerState } from "@tanstack/pacer/throttler";
30
30
  * the reactive system track the selected state values.
31
31
  *
32
32
  * Available throttler state properties:
33
- * - `canLeadingExecute`: Whether the throttler can execute on the leading edge
34
- * - `canTrailingExecute`: Whether the throttler can execute on the trailing edge
35
33
  * - `executionCount`: Number of function executions that have been completed
36
34
  * - `isPending`: Whether the throttler is waiting for the timeout to trigger trailing execution
37
35
  * - `lastArgs`: The arguments from the most recent call to maybeExecute
@@ -61,7 +59,5 @@ import { ThrottlerState } from "@tanstack/pacer/throttler";
61
59
  * throttler.cancel(); // Cancel any pending updates
62
60
  * ```
63
61
  */
64
- declare function createThrottledValue<TValue, TSelected = {}>(value: Accessor<TValue>, initialOptions: SolidThrottlerOptions<Setter<TValue>, TSelected>, selector?: (state: ThrottlerState<Setter<TValue>>) => TSelected): [Accessor<TValue>, SolidThrottler<Setter<TValue>, TSelected>];
65
- //#endregion
66
- export { createThrottledValue };
67
- //# sourceMappingURL=createThrottledValue.d.ts.map
62
+ export declare function createThrottledValue<TValue, TSelected = {}>(value: Accessor<TValue>, initialOptions: SolidThrottlerOptions<Setter<TValue>, TSelected>, selector?: (state: ThrottlerState<Setter<TValue>>) => TSelected): [Accessor<TValue>, SolidThrottler<Setter<TValue>, TSelected>];
63
+ //#endregion
@@ -30,8 +30,6 @@ import { createEffect } from "solid-js";
30
30
  * the reactive system track the selected state values.
31
31
  *
32
32
  * Available throttler state properties:
33
- * - `canLeadingExecute`: Whether the throttler can execute on the leading edge
34
- * - `canTrailingExecute`: Whether the throttler can execute on the trailing edge
35
33
  * - `executionCount`: Number of function executions that have been completed
36
34
  * - `isPending`: Whether the throttler is waiting for the timeout to trigger trailing execution
37
35
  * - `lastArgs`: The arguments from the most recent call to maybeExecute
@@ -70,5 +68,4 @@ function createThrottledValue(value, initialOptions, selector) {
70
68
  }
71
69
 
72
70
  //#endregion
73
- export { createThrottledValue };
74
- //# sourceMappingURL=createThrottledValue.js.map
71
+ export { createThrottledValue };
@@ -3,14 +3,14 @@ import { Store } from "@tanstack/solid-store";
3
3
  import { Throttler, ThrottlerOptions, ThrottlerState } from "@tanstack/pacer/throttler";
4
4
  import { AnyFunction } from "@tanstack/pacer/types";
5
5
  //#region src/throttler/createThrottler.d.ts
6
- interface SolidThrottlerOptions<TFn extends AnyFunction, TSelected = {}> extends ThrottlerOptions<TFn> {
6
+ export interface SolidThrottlerOptions<TFn extends AnyFunction, TSelected = {}> extends ThrottlerOptions<TFn> {
7
7
  /**
8
8
  * Optional callback invoked when the owning component unmounts. Receives the throttler instance.
9
9
  * When provided, replaces the default cleanup (cancel); use it to call flush(), reset(), cancel(), add logging, etc.
10
10
  */
11
11
  onUnmount?: (throttler: SolidThrottler<TFn, TSelected>) => void;
12
12
  }
13
- interface SolidThrottler<TFn extends AnyFunction, TSelected = {}> extends Omit<Throttler<TFn>, 'store'> {
13
+ export interface SolidThrottler<TFn extends AnyFunction, TSelected = {}> extends Omit<Throttler<TFn>, 'store'> {
14
14
  /**
15
15
  * A Solid component that allows you to subscribe to the throttler state.
16
16
  *
@@ -74,8 +74,6 @@ interface SolidThrottler<TFn extends AnyFunction, TSelected = {}> extends Omit<T
74
74
  * updates and gives you full control over when your component tracks state changes.
75
75
  *
76
76
  * Available state properties:
77
- * - `canLeadingExecute`: Whether the throttler can execute on the leading edge
78
- * - `canTrailingExecute`: Whether the throttler can execute on the trailing edge
79
77
  * - `executionCount`: Number of function executions that have been completed
80
78
  * - `isPending`: Whether the throttler is waiting for the timeout to trigger execution
81
79
  * - `lastArgs`: The arguments from the most recent call to maybeExecute
@@ -141,7 +139,5 @@ interface SolidThrottler<TFn extends AnyFunction, TSelected = {}> extends Omit<T
141
139
  * const { isPending, executionCount } = throttler.state();
142
140
  * ```
143
141
  */
144
- declare function createThrottler<TFn extends AnyFunction, TSelected = {}>(fn: TFn, options: SolidThrottlerOptions<TFn, TSelected>, selector?: (state: ThrottlerState<TFn>) => TSelected): SolidThrottler<TFn, TSelected>;
145
- //#endregion
146
- export { SolidThrottler, SolidThrottlerOptions, createThrottler };
147
- //# sourceMappingURL=createThrottler.d.ts.map
142
+ export declare function createThrottler<TFn extends AnyFunction, TSelected = {}>(fn: TFn, options: SolidThrottlerOptions<TFn, TSelected>, selector?: (state: ThrottlerState<TFn>) => TSelected): SolidThrottler<TFn, TSelected>;
143
+ //#endregion
@@ -37,8 +37,6 @@ import { Throttler } from "@tanstack/pacer/throttler";
37
37
  * updates and gives you full control over when your component tracks state changes.
38
38
  *
39
39
  * Available state properties:
40
- * - `canLeadingExecute`: Whether the throttler can execute on the leading edge
41
- * - `canTrailingExecute`: Whether the throttler can execute on the trailing edge
42
40
  * - `executionCount`: Number of function executions that have been completed
43
41
  * - `isPending`: Whether the throttler is waiting for the timeout to trigger execution
44
42
  * - `lastArgs`: The arguments from the most recent call to maybeExecute
@@ -128,5 +126,4 @@ function createThrottler(fn, options, selector = () => ({})) {
128
126
  }
129
127
 
130
128
  //#endregion
131
- export { createThrottler };
132
- //# sourceMappingURL=createThrottler.js.map
129
+ export { createThrottler };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/solid-pacer",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "Utilities for debouncing and throttling functions in Solid.",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -23,82 +23,37 @@
23
23
  "async"
24
24
  ],
25
25
  "type": "module",
26
- "main": "./dist/index.cjs",
27
- "module": "./dist/index.js",
28
- "types": "./dist/index.d.cts",
26
+ "types": "./dist/index.d.ts",
29
27
  "exports": {
30
- ".": {
31
- "import": "./dist/index.js",
32
- "require": "./dist/index.cjs"
33
- },
34
- "./async-batcher": {
35
- "import": "./dist/async-batcher/index.js",
36
- "require": "./dist/async-batcher/index.cjs"
37
- },
38
- "./async-debouncer": {
39
- "import": "./dist/async-debouncer/index.js",
40
- "require": "./dist/async-debouncer/index.cjs"
41
- },
42
- "./async-queuer": {
43
- "import": "./dist/async-queuer/index.js",
44
- "require": "./dist/async-queuer/index.cjs"
45
- },
46
- "./async-rate-limiter": {
47
- "import": "./dist/async-rate-limiter/index.js",
48
- "require": "./dist/async-rate-limiter/index.cjs"
49
- },
50
- "./async-throttler": {
51
- "import": "./dist/async-throttler/index.js",
52
- "require": "./dist/async-throttler/index.cjs"
53
- },
54
- "./batcher": {
55
- "import": "./dist/batcher/index.js",
56
- "require": "./dist/batcher/index.cjs"
57
- },
58
- "./debouncer": {
59
- "import": "./dist/debouncer/index.js",
60
- "require": "./dist/debouncer/index.cjs"
61
- },
62
- "./provider": {
63
- "import": "./dist/provider/index.js",
64
- "require": "./dist/provider/index.cjs"
65
- },
66
- "./queuer": {
67
- "import": "./dist/queuer/index.js",
68
- "require": "./dist/queuer/index.cjs"
69
- },
70
- "./rate-limiter": {
71
- "import": "./dist/rate-limiter/index.js",
72
- "require": "./dist/rate-limiter/index.cjs"
73
- },
74
- "./throttler": {
75
- "import": "./dist/throttler/index.js",
76
- "require": "./dist/throttler/index.cjs"
77
- },
78
- "./types": {
79
- "import": "./dist/types/index.js",
80
- "require": "./dist/types/index.cjs"
81
- },
82
- "./utils": {
83
- "import": "./dist/utils/index.js",
84
- "require": "./dist/utils/index.cjs"
85
- },
28
+ ".": "./dist/index.js",
29
+ "./async-batcher": "./dist/async-batcher/index.js",
30
+ "./async-debouncer": "./dist/async-debouncer/index.js",
31
+ "./async-queuer": "./dist/async-queuer/index.js",
32
+ "./async-rate-limiter": "./dist/async-rate-limiter/index.js",
33
+ "./async-throttler": "./dist/async-throttler/index.js",
34
+ "./batcher": "./dist/batcher/index.js",
35
+ "./debouncer": "./dist/debouncer/index.js",
36
+ "./provider": "./dist/provider/index.js",
37
+ "./queuer": "./dist/queuer/index.js",
38
+ "./rate-limiter": "./dist/rate-limiter/index.js",
39
+ "./throttler": "./dist/throttler/index.js",
40
+ "./types": "./dist/types/index.js",
41
+ "./utils": "./dist/utils/index.js",
86
42
  "./package.json": "./package.json"
87
43
  },
88
44
  "sideEffects": false,
89
45
  "engines": {
90
- "node": ">=18"
46
+ "node": ">=20"
91
47
  },
92
48
  "files": [
93
- "dist",
94
- "src"
49
+ "dist"
95
50
  ],
96
51
  "dependencies": {
97
- "@tanstack/solid-store": "^0.11.1",
98
- "@tanstack/pacer": "0.22.0"
52
+ "@tanstack/pacer": "0.23.0",
53
+ "@tanstack/solid-store": "^0.11.1"
99
54
  },
100
55
  "devDependencies": {
101
- "solid-js": "^1.9.14",
56
+ "solid-js": "^1.9.15",
102
57
  "vite-plugin-solid": "^2.11.14"
103
58
  },
104
59
  "peerDependencies": {
@@ -111,6 +66,7 @@
111
66
  "test:lib": "vitest --passWithNoTests",
112
67
  "test:lib:dev": "pnpm test:lib --watch",
113
68
  "test:types": "tsc",
114
- "build": "tsdown"
69
+ "build": "tsdown",
70
+ "test:build": "publint --strict && node ../../scripts/verify-package.ts"
115
71
  }
116
72
  }