@tanstack/solid-pacer 0.15.3 → 0.16.1
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.
- package/README.md +165 -0
- package/dist/async-batcher/createAsyncBatcher.cjs +122 -0
- package/dist/async-batcher/createAsyncBatcher.cjs.map +1 -0
- package/dist/{cjs/async-batcher → async-batcher}/createAsyncBatcher.d.cts +22 -17
- package/dist/{esm/async-batcher → async-batcher}/createAsyncBatcher.d.ts +22 -17
- package/dist/async-batcher/createAsyncBatcher.js +122 -0
- package/dist/async-batcher/createAsyncBatcher.js.map +1 -0
- package/dist/async-batcher/index.cjs +10 -0
- package/dist/async-batcher/index.d.cts +3 -0
- package/dist/async-batcher/index.d.ts +3 -0
- package/dist/async-batcher/index.js +5 -0
- package/dist/async-debouncer/createAsyncDebouncer.cjs +114 -0
- package/dist/async-debouncer/createAsyncDebouncer.cjs.map +1 -0
- package/dist/{cjs/async-debouncer → async-debouncer}/createAsyncDebouncer.d.cts +23 -18
- package/dist/{esm/async-debouncer → async-debouncer}/createAsyncDebouncer.d.ts +23 -18
- package/dist/async-debouncer/createAsyncDebouncer.js +114 -0
- package/dist/async-debouncer/createAsyncDebouncer.js.map +1 -0
- package/dist/async-debouncer/index.cjs +10 -0
- package/dist/async-debouncer/index.d.cts +3 -0
- package/dist/async-debouncer/index.d.ts +3 -0
- package/dist/async-debouncer/index.js +5 -0
- package/dist/async-queuer/createAsyncQueuer.cjs +114 -0
- package/dist/async-queuer/createAsyncQueuer.cjs.map +1 -0
- package/dist/{cjs/async-queuer → async-queuer}/createAsyncQueuer.d.cts +22 -17
- package/dist/{esm/async-queuer → async-queuer}/createAsyncQueuer.d.ts +22 -17
- package/dist/async-queuer/createAsyncQueuer.js +114 -0
- package/dist/async-queuer/createAsyncQueuer.js.map +1 -0
- package/dist/async-queuer/index.cjs +10 -0
- package/dist/async-queuer/index.d.cts +3 -0
- package/dist/async-queuer/index.d.ts +3 -0
- package/dist/async-queuer/index.js +5 -0
- package/dist/async-rate-limiter/createAsyncRateLimiter.cjs +120 -0
- package/dist/async-rate-limiter/createAsyncRateLimiter.cjs.map +1 -0
- package/dist/{cjs/async-rate-limiter → async-rate-limiter}/createAsyncRateLimiter.d.cts +23 -18
- package/dist/{esm/async-rate-limiter → async-rate-limiter}/createAsyncRateLimiter.d.ts +23 -18
- package/dist/async-rate-limiter/createAsyncRateLimiter.js +120 -0
- package/dist/async-rate-limiter/createAsyncRateLimiter.js.map +1 -0
- package/dist/async-rate-limiter/index.cjs +10 -0
- package/dist/async-rate-limiter/index.d.cts +3 -0
- package/dist/async-rate-limiter/index.d.ts +3 -0
- package/dist/async-rate-limiter/index.js +5 -0
- package/dist/async-throttler/createAsyncThrottler.cjs +108 -0
- package/dist/async-throttler/createAsyncThrottler.cjs.map +1 -0
- package/dist/{cjs/async-throttler → async-throttler}/createAsyncThrottler.d.cts +23 -18
- package/dist/{esm/async-throttler → async-throttler}/createAsyncThrottler.d.ts +23 -18
- package/dist/async-throttler/createAsyncThrottler.js +108 -0
- package/dist/async-throttler/createAsyncThrottler.js.map +1 -0
- package/dist/async-throttler/index.cjs +10 -0
- package/dist/async-throttler/index.d.cts +3 -0
- package/dist/async-throttler/index.d.ts +3 -0
- package/dist/async-throttler/index.js +5 -0
- package/dist/batcher/createBatcher.cjs +97 -0
- package/dist/batcher/createBatcher.cjs.map +1 -0
- package/dist/{cjs/batcher → batcher}/createBatcher.d.cts +22 -17
- package/dist/{esm/batcher → batcher}/createBatcher.d.ts +22 -17
- package/dist/batcher/createBatcher.js +97 -0
- package/dist/batcher/createBatcher.js.map +1 -0
- package/dist/batcher/index.cjs +10 -0
- package/dist/batcher/index.d.cts +3 -0
- package/dist/batcher/index.d.ts +3 -0
- package/dist/batcher/index.js +5 -0
- package/dist/debouncer/createDebouncedSignal.cjs +88 -0
- package/dist/debouncer/createDebouncedSignal.cjs.map +1 -0
- package/dist/{cjs/debouncer → debouncer}/createDebouncedSignal.d.cts +10 -8
- package/dist/{esm/debouncer → debouncer}/createDebouncedSignal.d.ts +10 -8
- package/dist/debouncer/createDebouncedSignal.js +88 -0
- package/dist/debouncer/createDebouncedSignal.js.map +1 -0
- package/dist/debouncer/createDebouncedValue.cjs +77 -0
- package/dist/debouncer/createDebouncedValue.cjs.map +1 -0
- package/dist/{cjs/debouncer → debouncer}/createDebouncedValue.d.cts +10 -4
- package/dist/{esm/debouncer → debouncer}/createDebouncedValue.d.ts +10 -4
- package/dist/debouncer/createDebouncedValue.js +77 -0
- package/dist/debouncer/createDebouncedValue.js.map +1 -0
- package/dist/debouncer/createDebouncer.cjs +101 -0
- package/dist/debouncer/createDebouncer.cjs.map +1 -0
- package/dist/{cjs/debouncer → debouncer}/createDebouncer.d.cts +23 -18
- package/dist/{esm/debouncer → debouncer}/createDebouncer.d.ts +23 -18
- package/dist/debouncer/createDebouncer.js +101 -0
- package/dist/debouncer/createDebouncer.js.map +1 -0
- package/dist/debouncer/index.cjs +14 -0
- package/dist/debouncer/index.d.cts +5 -0
- package/dist/debouncer/index.d.ts +5 -0
- package/dist/{esm/debouncer → debouncer}/index.js +5 -8
- package/dist/index.cjs +46 -0
- package/dist/index.d.cts +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/{esm/index.js → index.js} +8 -22
- package/dist/provider/PacerProvider.cjs +27 -0
- package/dist/provider/PacerProvider.cjs.map +1 -0
- package/dist/provider/PacerProvider.d.cts +29 -0
- package/dist/provider/PacerProvider.d.ts +29 -0
- package/dist/provider/PacerProvider.js +25 -0
- package/dist/provider/PacerProvider.js.map +1 -0
- package/dist/provider/index.cjs +5 -0
- package/dist/provider/index.d.cts +2 -0
- package/dist/provider/index.d.ts +2 -0
- package/dist/provider/index.js +3 -0
- package/dist/queuer/createQueuedSignal.cjs +129 -0
- package/dist/queuer/createQueuedSignal.cjs.map +1 -0
- package/dist/queuer/createQueuedSignal.d.cts +123 -0
- package/dist/queuer/createQueuedSignal.d.ts +123 -0
- package/dist/queuer/createQueuedSignal.js +129 -0
- package/dist/queuer/createQueuedSignal.js.map +1 -0
- package/dist/queuer/createQueuer.cjs +98 -0
- package/dist/queuer/createQueuer.cjs.map +1 -0
- package/dist/{cjs/queuer → queuer}/createQueuer.d.cts +22 -17
- package/dist/{esm/queuer → queuer}/createQueuer.d.ts +22 -17
- package/dist/queuer/createQueuer.js +98 -0
- package/dist/queuer/createQueuer.js.map +1 -0
- package/dist/queuer/index.cjs +12 -0
- package/dist/queuer/index.d.cts +4 -0
- package/dist/queuer/index.d.ts +4 -0
- package/dist/queuer/index.js +6 -0
- package/dist/rate-limiter/createRateLimitedSignal.cjs +102 -0
- package/dist/rate-limiter/createRateLimitedSignal.cjs.map +1 -0
- package/dist/{cjs/rate-limiter → rate-limiter}/createRateLimitedSignal.d.cts +10 -8
- package/dist/{esm/rate-limiter → rate-limiter}/createRateLimitedSignal.d.ts +10 -8
- package/dist/rate-limiter/createRateLimitedSignal.js +102 -0
- package/dist/rate-limiter/createRateLimitedSignal.js.map +1 -0
- package/dist/rate-limiter/createRateLimitedValue.cjs +102 -0
- package/dist/rate-limiter/createRateLimitedValue.cjs.map +1 -0
- package/dist/{cjs/rate-limiter → rate-limiter}/createRateLimitedValue.d.cts +40 -20
- package/dist/{esm/rate-limiter → rate-limiter}/createRateLimitedValue.d.ts +40 -20
- package/dist/rate-limiter/createRateLimitedValue.js +102 -0
- package/dist/rate-limiter/createRateLimitedValue.js.map +1 -0
- package/dist/rate-limiter/createRateLimiter.cjs +95 -0
- package/dist/rate-limiter/createRateLimiter.cjs.map +1 -0
- package/dist/{cjs/rate-limiter → rate-limiter}/createRateLimiter.d.cts +23 -18
- package/dist/{esm/rate-limiter → rate-limiter}/createRateLimiter.d.ts +23 -18
- package/dist/rate-limiter/createRateLimiter.js +95 -0
- package/dist/rate-limiter/createRateLimiter.js.map +1 -0
- package/dist/rate-limiter/index.cjs +14 -0
- package/dist/rate-limiter/index.d.cts +5 -0
- package/dist/rate-limiter/index.d.ts +5 -0
- package/dist/{esm/rate-limiter → rate-limiter}/index.js +4 -7
- package/dist/throttler/createThrottledSignal.cjs +79 -0
- package/dist/throttler/createThrottledSignal.cjs.map +1 -0
- package/dist/{cjs/throttler → throttler}/createThrottledSignal.d.cts +10 -8
- package/dist/{esm/throttler → throttler}/createThrottledSignal.d.ts +10 -8
- package/dist/throttler/createThrottledSignal.js +79 -0
- package/dist/throttler/createThrottledSignal.js.map +1 -0
- package/dist/throttler/createThrottledValue.cjs +74 -0
- package/dist/throttler/createThrottledValue.cjs.map +1 -0
- package/dist/{cjs/throttler → throttler}/createThrottledValue.d.cts +10 -4
- package/dist/{esm/throttler → throttler}/createThrottledValue.d.ts +10 -4
- package/dist/throttler/createThrottledValue.js +74 -0
- package/dist/throttler/createThrottledValue.js.map +1 -0
- package/dist/throttler/createThrottler.cjs +97 -0
- package/dist/throttler/createThrottler.cjs.map +1 -0
- package/dist/{cjs/throttler → throttler}/createThrottler.d.cts +23 -18
- package/dist/{esm/throttler → throttler}/createThrottler.d.ts +23 -18
- package/dist/throttler/createThrottler.js +97 -0
- package/dist/throttler/createThrottler.js.map +1 -0
- package/dist/throttler/index.cjs +14 -0
- package/dist/throttler/index.d.cts +5 -0
- package/dist/throttler/index.d.ts +5 -0
- package/dist/{esm/throttler → throttler}/index.js +5 -8
- package/dist/types/index.cjs +9 -0
- package/dist/types/index.d.cts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +3 -0
- package/dist/utils/index.cjs +9 -0
- package/dist/utils/index.d.cts +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +3 -0
- package/package.json +37 -106
- package/src/async-batcher/createAsyncBatcher.ts +12 -4
- package/src/async-debouncer/createAsyncDebouncer.ts +8 -2
- package/src/async-queuer/createAsyncQueuer.ts +12 -4
- package/src/async-rate-limiter/createAsyncRateLimiter.ts +8 -2
- package/src/async-throttler/createAsyncThrottler.ts +8 -2
- package/src/batcher/createBatcher.ts +12 -4
- package/src/debouncer/createDebouncer.ts +12 -4
- package/src/index.ts +4 -0
- package/src/provider/PacerProvider.tsx +63 -0
- package/src/provider/index.ts +1 -0
- package/src/queuer/createQueuedSignal.ts +138 -0
- package/src/queuer/createQueuer.ts +12 -4
- package/src/queuer/index.ts +1 -0
- package/src/rate-limiter/createRateLimitedValue.ts +30 -16
- package/src/rate-limiter/createRateLimiter.ts +12 -4
- package/src/throttler/createThrottler.ts +12 -4
- package/dist/cjs/async-batcher/createAsyncBatcher.cjs +0 -14
- package/dist/cjs/async-batcher/createAsyncBatcher.cjs.map +0 -1
- package/dist/cjs/async-batcher/index.cjs +0 -12
- package/dist/cjs/async-batcher/index.cjs.map +0 -1
- package/dist/cjs/async-batcher/index.d.cts +0 -2
- package/dist/cjs/async-debouncer/createAsyncDebouncer.cjs +0 -20
- package/dist/cjs/async-debouncer/createAsyncDebouncer.cjs.map +0 -1
- package/dist/cjs/async-debouncer/index.cjs +0 -12
- package/dist/cjs/async-debouncer/index.cjs.map +0 -1
- package/dist/cjs/async-debouncer/index.d.cts +0 -2
- package/dist/cjs/async-queuer/createAsyncQueuer.cjs +0 -14
- package/dist/cjs/async-queuer/createAsyncQueuer.cjs.map +0 -1
- package/dist/cjs/async-queuer/index.cjs +0 -12
- package/dist/cjs/async-queuer/index.cjs.map +0 -1
- package/dist/cjs/async-queuer/index.d.cts +0 -2
- package/dist/cjs/async-rate-limiter/createAsyncRateLimiter.cjs +0 -14
- package/dist/cjs/async-rate-limiter/createAsyncRateLimiter.cjs.map +0 -1
- package/dist/cjs/async-rate-limiter/index.cjs +0 -12
- package/dist/cjs/async-rate-limiter/index.cjs.map +0 -1
- package/dist/cjs/async-rate-limiter/index.d.cts +0 -2
- package/dist/cjs/async-throttler/createAsyncThrottler.cjs +0 -14
- package/dist/cjs/async-throttler/createAsyncThrottler.cjs.map +0 -1
- package/dist/cjs/async-throttler/index.cjs +0 -12
- package/dist/cjs/async-throttler/index.cjs.map +0 -1
- package/dist/cjs/async-throttler/index.d.cts +0 -2
- package/dist/cjs/batcher/createBatcher.cjs +0 -14
- package/dist/cjs/batcher/createBatcher.cjs.map +0 -1
- package/dist/cjs/batcher/index.cjs +0 -12
- package/dist/cjs/batcher/index.cjs.map +0 -1
- package/dist/cjs/batcher/index.d.cts +0 -2
- package/dist/cjs/debouncer/createDebouncedSignal.cjs +0 -11
- package/dist/cjs/debouncer/createDebouncedSignal.cjs.map +0 -1
- package/dist/cjs/debouncer/createDebouncedValue.cjs +0 -17
- package/dist/cjs/debouncer/createDebouncedValue.cjs.map +0 -1
- package/dist/cjs/debouncer/createDebouncer.cjs +0 -20
- package/dist/cjs/debouncer/createDebouncer.cjs.map +0 -1
- package/dist/cjs/debouncer/index.cjs +0 -16
- package/dist/cjs/debouncer/index.cjs.map +0 -1
- package/dist/cjs/debouncer/index.d.cts +0 -4
- package/dist/cjs/index.cjs +0 -42
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/index.d.cts +0 -20
- package/dist/cjs/queuer/createQueuer.cjs +0 -14
- package/dist/cjs/queuer/createQueuer.cjs.map +0 -1
- package/dist/cjs/queuer/index.cjs +0 -12
- package/dist/cjs/queuer/index.cjs.map +0 -1
- package/dist/cjs/queuer/index.d.cts +0 -2
- package/dist/cjs/rate-limiter/createRateLimitedSignal.cjs +0 -19
- package/dist/cjs/rate-limiter/createRateLimitedSignal.cjs.map +0 -1
- package/dist/cjs/rate-limiter/createRateLimitedValue.cjs +0 -13
- package/dist/cjs/rate-limiter/createRateLimitedValue.cjs.map +0 -1
- package/dist/cjs/rate-limiter/createRateLimiter.cjs +0 -14
- package/dist/cjs/rate-limiter/createRateLimiter.cjs.map +0 -1
- package/dist/cjs/rate-limiter/index.cjs +0 -16
- package/dist/cjs/rate-limiter/index.cjs.map +0 -1
- package/dist/cjs/rate-limiter/index.d.cts +0 -4
- package/dist/cjs/throttler/createThrottledSignal.cjs +0 -11
- package/dist/cjs/throttler/createThrottledSignal.cjs.map +0 -1
- package/dist/cjs/throttler/createThrottledValue.cjs +0 -17
- package/dist/cjs/throttler/createThrottledValue.cjs.map +0 -1
- package/dist/cjs/throttler/createThrottler.cjs +0 -20
- package/dist/cjs/throttler/createThrottler.cjs.map +0 -1
- package/dist/cjs/throttler/index.cjs +0 -16
- package/dist/cjs/throttler/index.cjs.map +0 -1
- package/dist/cjs/throttler/index.d.cts +0 -4
- package/dist/cjs/types/index.cjs +0 -10
- package/dist/cjs/types/index.cjs.map +0 -1
- package/dist/cjs/types/index.d.cts +0 -1
- package/dist/cjs/utils/index.cjs +0 -10
- package/dist/cjs/utils/index.cjs.map +0 -1
- package/dist/cjs/utils/index.d.cts +0 -1
- package/dist/esm/async-batcher/createAsyncBatcher.js +0 -14
- package/dist/esm/async-batcher/createAsyncBatcher.js.map +0 -1
- package/dist/esm/async-batcher/index.d.ts +0 -2
- package/dist/esm/async-batcher/index.js +0 -6
- package/dist/esm/async-batcher/index.js.map +0 -1
- package/dist/esm/async-debouncer/createAsyncDebouncer.js +0 -20
- package/dist/esm/async-debouncer/createAsyncDebouncer.js.map +0 -1
- package/dist/esm/async-debouncer/index.d.ts +0 -2
- package/dist/esm/async-debouncer/index.js +0 -6
- package/dist/esm/async-debouncer/index.js.map +0 -1
- package/dist/esm/async-queuer/createAsyncQueuer.js +0 -14
- package/dist/esm/async-queuer/createAsyncQueuer.js.map +0 -1
- package/dist/esm/async-queuer/index.d.ts +0 -2
- package/dist/esm/async-queuer/index.js +0 -6
- package/dist/esm/async-queuer/index.js.map +0 -1
- package/dist/esm/async-rate-limiter/createAsyncRateLimiter.js +0 -14
- package/dist/esm/async-rate-limiter/createAsyncRateLimiter.js.map +0 -1
- package/dist/esm/async-rate-limiter/index.d.ts +0 -2
- package/dist/esm/async-rate-limiter/index.js +0 -6
- package/dist/esm/async-rate-limiter/index.js.map +0 -1
- package/dist/esm/async-throttler/createAsyncThrottler.js +0 -14
- package/dist/esm/async-throttler/createAsyncThrottler.js.map +0 -1
- package/dist/esm/async-throttler/index.d.ts +0 -2
- package/dist/esm/async-throttler/index.js +0 -6
- package/dist/esm/async-throttler/index.js.map +0 -1
- package/dist/esm/batcher/createBatcher.js +0 -14
- package/dist/esm/batcher/createBatcher.js.map +0 -1
- package/dist/esm/batcher/index.d.ts +0 -2
- package/dist/esm/batcher/index.js +0 -6
- package/dist/esm/batcher/index.js.map +0 -1
- package/dist/esm/debouncer/createDebouncedSignal.js +0 -11
- package/dist/esm/debouncer/createDebouncedSignal.js.map +0 -1
- package/dist/esm/debouncer/createDebouncedValue.js +0 -17
- package/dist/esm/debouncer/createDebouncedValue.js.map +0 -1
- package/dist/esm/debouncer/createDebouncer.js +0 -20
- package/dist/esm/debouncer/createDebouncer.js.map +0 -1
- package/dist/esm/debouncer/index.d.ts +0 -4
- package/dist/esm/debouncer/index.js.map +0 -1
- package/dist/esm/index.d.ts +0 -20
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/queuer/createQueuer.js +0 -14
- package/dist/esm/queuer/createQueuer.js.map +0 -1
- package/dist/esm/queuer/index.d.ts +0 -2
- package/dist/esm/queuer/index.js +0 -6
- package/dist/esm/queuer/index.js.map +0 -1
- package/dist/esm/rate-limiter/createRateLimitedSignal.js +0 -19
- package/dist/esm/rate-limiter/createRateLimitedSignal.js.map +0 -1
- package/dist/esm/rate-limiter/createRateLimitedValue.js +0 -13
- package/dist/esm/rate-limiter/createRateLimitedValue.js.map +0 -1
- package/dist/esm/rate-limiter/createRateLimiter.js +0 -14
- package/dist/esm/rate-limiter/createRateLimiter.js.map +0 -1
- package/dist/esm/rate-limiter/index.d.ts +0 -4
- package/dist/esm/rate-limiter/index.js.map +0 -1
- package/dist/esm/throttler/createThrottledSignal.js +0 -11
- package/dist/esm/throttler/createThrottledSignal.js.map +0 -1
- package/dist/esm/throttler/createThrottledValue.js +0 -17
- package/dist/esm/throttler/createThrottledValue.js.map +0 -1
- package/dist/esm/throttler/createThrottler.js +0 -20
- package/dist/esm/throttler/createThrottler.js.map +0 -1
- package/dist/esm/throttler/index.d.ts +0 -4
- package/dist/esm/throttler/index.js.map +0 -1
- package/dist/esm/types/index.d.ts +0 -1
- package/dist/esm/types/index.js +0 -2
- package/dist/esm/types/index.js.map +0 -1
- package/dist/esm/utils/index.d.ts +0 -1
- package/dist/esm/utils/index.js +0 -2
- package/dist/esm/utils/index.js.map +0 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createComponent } from "solid-js/web";
|
|
2
|
+
import { createContext, useContext } from "solid-js";
|
|
3
|
+
|
|
4
|
+
//#region src/provider/PacerProvider.tsx
|
|
5
|
+
const PacerContext = createContext(null);
|
|
6
|
+
const DEFAULT_OPTIONS = {};
|
|
7
|
+
function PacerProvider(props) {
|
|
8
|
+
const contextValue = { defaultOptions: props.defaultOptions ?? DEFAULT_OPTIONS };
|
|
9
|
+
return createComponent(PacerContext.Provider, {
|
|
10
|
+
value: contextValue,
|
|
11
|
+
get children() {
|
|
12
|
+
return props.children;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function usePacerContext() {
|
|
17
|
+
return useContext(PacerContext);
|
|
18
|
+
}
|
|
19
|
+
function useDefaultPacerOptions() {
|
|
20
|
+
return useContext(PacerContext)?.defaultOptions ?? {};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { PacerProvider, useDefaultPacerOptions, usePacerContext };
|
|
25
|
+
//# sourceMappingURL=PacerProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PacerProvider.js","names":["createContext","useContext","JSX","AnyAsyncFunction","AnyFunction","AsyncBatcherOptions","AsyncDebouncerOptions","AsyncQueuerOptions","AsyncRateLimiterOptions","AsyncThrottlerOptions","BatcherOptions","DebouncerOptions","QueuerOptions","RateLimiterOptions","ThrottlerOptions","PacerProviderOptions","asyncBatcher","Partial","asyncDebouncer","asyncQueuer","asyncRateLimiter","asyncThrottler","batcher","debouncer","queuer","rateLimiter","throttler","PacerContextValue","defaultOptions","PacerContext","PacerProviderProps","children","Element","DEFAULT_OPTIONS","PacerProvider","props","contextValue","_$createComponent","Provider","value","usePacerContext","useDefaultPacerOptions","context"],"sources":["../../src/provider/PacerProvider.tsx"],"sourcesContent":["import { createContext, useContext } from 'solid-js'\nimport type { JSX } from 'solid-js'\nimport type {\n AnyAsyncFunction,\n AnyFunction,\n AsyncBatcherOptions,\n AsyncDebouncerOptions,\n AsyncQueuerOptions,\n AsyncRateLimiterOptions,\n AsyncThrottlerOptions,\n BatcherOptions,\n DebouncerOptions,\n QueuerOptions,\n RateLimiterOptions,\n ThrottlerOptions,\n} from '@tanstack/pacer'\n\nexport interface PacerProviderOptions {\n asyncBatcher?: Partial<AsyncBatcherOptions<any>>\n asyncDebouncer?: Partial<AsyncDebouncerOptions<AnyAsyncFunction>>\n asyncQueuer?: Partial<AsyncQueuerOptions<any>>\n asyncRateLimiter?: Partial<AsyncRateLimiterOptions<AnyAsyncFunction>>\n asyncThrottler?: Partial<AsyncThrottlerOptions<AnyAsyncFunction>>\n batcher?: Partial<BatcherOptions<any>>\n debouncer?: Partial<DebouncerOptions<AnyFunction>>\n queuer?: Partial<QueuerOptions<any>>\n rateLimiter?: Partial<RateLimiterOptions<AnyFunction>>\n throttler?: Partial<ThrottlerOptions<AnyFunction>>\n}\n\ninterface PacerContextValue {\n defaultOptions: PacerProviderOptions\n}\n\nconst PacerContext = createContext<PacerContextValue | null>(null)\n\nexport interface PacerProviderProps {\n children: JSX.Element\n defaultOptions?: PacerProviderOptions\n}\n\nconst DEFAULT_OPTIONS: PacerProviderOptions = {}\n\nexport function PacerProvider(props: PacerProviderProps) {\n const contextValue: PacerContextValue = {\n defaultOptions: props.defaultOptions ?? DEFAULT_OPTIONS,\n }\n\n return (\n <PacerContext.Provider value={contextValue}>\n {props.children}\n </PacerContext.Provider>\n )\n}\n\nexport function usePacerContext() {\n return useContext(PacerContext)\n}\n\nexport function useDefaultPacerOptions() {\n const context = useContext(PacerContext)\n return context?.defaultOptions ?? {}\n}\n"],"mappings":";;;;AAkCA,MAAM6B,eAAe7B,cAAwC,KAAK;AAOlE,MAAMiC,kBAAwC,EAAE;AAEhD,SAAgBC,cAAcC,OAA2B;CACvD,MAAMC,eAAkC,EACtCR,gBAAgBO,MAAMP,kBAAkBK,iBACzC;AAED,QAAAI,gBACGR,aAAaS,UAAQ;EAACC,OAAOH;EAAY,IAAAL,WAAA;AAAA,UACvCI,MAAMJ;;EAAQ,CAAA;;AAKrB,SAAgBS,kBAAkB;AAChC,QAAOvC,WAAW4B,aAAa;;AAGjC,SAAgBY,yBAAyB;AAEvC,QADgBxC,WAAW4B,aAAa,EACxBD,kBAAkB,EAAE"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const require_PacerProvider = require('./PacerProvider.cjs');
|
|
2
|
+
|
|
3
|
+
exports.PacerProvider = require_PacerProvider.PacerProvider;
|
|
4
|
+
exports.useDefaultPacerOptions = require_PacerProvider.useDefaultPacerOptions;
|
|
5
|
+
exports.usePacerContext = require_PacerProvider.usePacerContext;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
const require_createQueuer = require('./createQueuer.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/queuer/createQueuedSignal.ts
|
|
4
|
+
/**
|
|
5
|
+
* A Solid primitive that creates a queuer with managed state, combining Solid's signals with queuing functionality.
|
|
6
|
+
* This primitive provides both the current queue state and queue control methods.
|
|
7
|
+
*
|
|
8
|
+
* The queue state is automatically updated whenever items are added, removed, or reordered in the queue.
|
|
9
|
+
* All queue operations are reflected in the state array returned by the primitive.
|
|
10
|
+
*
|
|
11
|
+
* The queue can be started and stopped to automatically process items at a specified interval,
|
|
12
|
+
* making it useful as a scheduler. When started, it will process one item per tick, with an
|
|
13
|
+
* optional wait time between ticks.
|
|
14
|
+
*
|
|
15
|
+
* The primitive returns a tuple containing:
|
|
16
|
+
* - The current queue state as an array
|
|
17
|
+
* - The queue instance with methods for queue manipulation
|
|
18
|
+
*
|
|
19
|
+
* ## State Management and Selector
|
|
20
|
+
*
|
|
21
|
+
* The primitive uses Solid's reactive state management via the underlying queuer instance.
|
|
22
|
+
* The `selector` parameter allows you to specify which queuer state changes will trigger a re-render,
|
|
23
|
+
* optimizing performance by preventing unnecessary re-renders when irrelevant state changes occur.
|
|
24
|
+
*
|
|
25
|
+
* **By default, there will be no reactive state subscriptions** and you must opt-in to state
|
|
26
|
+
* tracking by providing a selector function. This prevents unnecessary re-renders and gives you
|
|
27
|
+
* full control over when your component updates. Only when you provide a selector will the
|
|
28
|
+
* component re-render when the selected state values change.
|
|
29
|
+
*
|
|
30
|
+
* Available queuer state properties:
|
|
31
|
+
* - `executionCount`: Number of items that have been processed by the queuer
|
|
32
|
+
* - `expirationCount`: Number of items that have been removed due to expiration
|
|
33
|
+
* - `isEmpty`: Whether the queuer has no items to process
|
|
34
|
+
* - `isFull`: Whether the queuer has reached its maximum capacity
|
|
35
|
+
* - `isIdle`: Whether the queuer is not currently processing any items
|
|
36
|
+
* - `isRunning`: Whether the queuer is active and will process items automatically
|
|
37
|
+
* - `items`: Array of items currently waiting to be processed
|
|
38
|
+
* - `itemTimestamps`: Timestamps when items were added for expiration tracking
|
|
39
|
+
* - `pendingTick`: Whether the queuer has a pending timeout for processing the next item
|
|
40
|
+
* - `rejectionCount`: Number of items that have been rejected from being added
|
|
41
|
+
* - `size`: Number of items currently in the queue
|
|
42
|
+
* - `status`: Current processing status ('idle' | 'running' | 'stopped')
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* // Default behavior - no reactive state subscriptions
|
|
47
|
+
* const [items, addItem, queue] = createQueuedSignal(
|
|
48
|
+
* (item) => console.log('Processing:', item),
|
|
49
|
+
* {
|
|
50
|
+
* initialItems: ['item1', 'item2'],
|
|
51
|
+
* started: true,
|
|
52
|
+
* wait: 1000,
|
|
53
|
+
* getPriority: (item) => item.priority
|
|
54
|
+
* }
|
|
55
|
+
* );
|
|
56
|
+
*
|
|
57
|
+
* // Opt-in to re-render when queue contents change (optimized for displaying queue items)
|
|
58
|
+
* const [items, addItem, queue] = createQueuedSignal(
|
|
59
|
+
* (item) => console.log('Processing:', item),
|
|
60
|
+
* { started: true, wait: 1000 },
|
|
61
|
+
* (state) => ({
|
|
62
|
+
* items: state.items,
|
|
63
|
+
* size: state.size,
|
|
64
|
+
* isEmpty: state.isEmpty
|
|
65
|
+
* })
|
|
66
|
+
* );
|
|
67
|
+
*
|
|
68
|
+
* // Opt-in to re-render when processing state changes (optimized for loading indicators)
|
|
69
|
+
* const [items, addItem, queue] = createQueuedSignal(
|
|
70
|
+
* (item) => console.log('Processing:', item),
|
|
71
|
+
* { started: true, wait: 1000 },
|
|
72
|
+
* (state) => ({
|
|
73
|
+
* isRunning: state.isRunning,
|
|
74
|
+
* isIdle: state.isIdle,
|
|
75
|
+
* status: state.status,
|
|
76
|
+
* pendingTick: state.pendingTick
|
|
77
|
+
* })
|
|
78
|
+
* );
|
|
79
|
+
*
|
|
80
|
+
* // Opt-in to re-render when execution metrics change (optimized for stats display)
|
|
81
|
+
* const [items, addItem, queue] = createQueuedSignal(
|
|
82
|
+
* (item) => console.log('Processing:', item),
|
|
83
|
+
* { started: true, wait: 1000 },
|
|
84
|
+
* (state) => ({
|
|
85
|
+
* executionCount: state.executionCount,
|
|
86
|
+
* expirationCount: state.expirationCount,
|
|
87
|
+
* rejectionCount: state.rejectionCount
|
|
88
|
+
* })
|
|
89
|
+
* );
|
|
90
|
+
*
|
|
91
|
+
* // Add items to queue
|
|
92
|
+
* const handleAdd = (item) => {
|
|
93
|
+
* addItem(item);
|
|
94
|
+
* };
|
|
95
|
+
*
|
|
96
|
+
* // Start automatic processing
|
|
97
|
+
* const startProcessing = () => {
|
|
98
|
+
* queue.start();
|
|
99
|
+
* };
|
|
100
|
+
*
|
|
101
|
+
* // Stop automatic processing
|
|
102
|
+
* const stopProcessing = () => {
|
|
103
|
+
* queue.stop();
|
|
104
|
+
* };
|
|
105
|
+
*
|
|
106
|
+
* // Manual processing still available
|
|
107
|
+
* const handleProcess = () => {
|
|
108
|
+
* const nextItem = queue.getNextItem();
|
|
109
|
+
* if (nextItem) {
|
|
110
|
+
* processItem(nextItem);
|
|
111
|
+
* }
|
|
112
|
+
* };
|
|
113
|
+
*
|
|
114
|
+
* // Access the selected queuer state (will be empty object {} unless selector provided)
|
|
115
|
+
* const { size, isRunning, executionCount } = queue.state;
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
function createQueuedSignal(fn, options = {}, selector = (state) => ({ items: state.items })) {
|
|
119
|
+
const queue = require_createQueuer.createQueuer(fn, options, selector);
|
|
120
|
+
return [
|
|
121
|
+
() => queue.state().items,
|
|
122
|
+
queue.addItem,
|
|
123
|
+
queue
|
|
124
|
+
];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
exports.createQueuedSignal = createQueuedSignal;
|
|
129
|
+
//# sourceMappingURL=createQueuedSignal.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createQueuedSignal.cjs","names":["createQueuer"],"sources":["../../src/queuer/createQueuedSignal.ts"],"sourcesContent":["import { createQueuer } from './createQueuer'\nimport type { SolidQueuer } from './createQueuer'\nimport type { QueuerOptions, QueuerState } from '@tanstack/pacer/queuer'\n\n/**\n * A Solid primitive that creates a queuer with managed state, combining Solid's signals with queuing functionality.\n * This primitive provides both the current queue state and queue control methods.\n *\n * The queue state is automatically updated whenever items are added, removed, or reordered in the queue.\n * All queue operations are reflected in the state array returned by the primitive.\n *\n * The queue can be started and stopped to automatically process items at a specified interval,\n * making it useful as a scheduler. When started, it will process one item per tick, with an\n * optional wait time between ticks.\n *\n * The primitive returns a tuple containing:\n * - The current queue state as an array\n * - The queue instance with methods for queue manipulation\n *\n * ## State Management and Selector\n *\n * The primitive uses Solid's reactive state management via the underlying queuer instance.\n * The `selector` parameter allows you to specify which queuer state changes will trigger a re-render,\n * optimizing performance by preventing unnecessary re-renders 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 re-renders and gives you\n * full control over when your component updates. Only when you provide a selector will the\n * component re-render when the selected state values change.\n *\n * Available queuer state properties:\n * - `executionCount`: Number of items that have been processed by the queuer\n * - `expirationCount`: Number of items that have been removed due to expiration\n * - `isEmpty`: Whether the queuer has no items to process\n * - `isFull`: Whether the queuer has reached its maximum capacity\n * - `isIdle`: Whether the queuer is not currently processing any items\n * - `isRunning`: Whether the queuer is active and will process items automatically\n * - `items`: Array of items currently waiting to be processed\n * - `itemTimestamps`: Timestamps when items were added for expiration tracking\n * - `pendingTick`: Whether the queuer has a pending timeout for processing the next item\n * - `rejectionCount`: Number of items that have been rejected from being added\n * - `size`: Number of items currently in the queue\n * - `status`: Current processing status ('idle' | 'running' | 'stopped')\n *\n * @example\n * ```tsx\n * // Default behavior - no reactive state subscriptions\n * const [items, addItem, queue] = createQueuedSignal(\n * (item) => console.log('Processing:', item),\n * {\n * initialItems: ['item1', 'item2'],\n * started: true,\n * wait: 1000,\n * getPriority: (item) => item.priority\n * }\n * );\n *\n * // Opt-in to re-render when queue contents change (optimized for displaying queue items)\n * const [items, addItem, queue] = createQueuedSignal(\n * (item) => console.log('Processing:', item),\n * { started: true, wait: 1000 },\n * (state) => ({\n * items: state.items,\n * size: state.size,\n * isEmpty: state.isEmpty\n * })\n * );\n *\n * // Opt-in to re-render when processing state changes (optimized for loading indicators)\n * const [items, addItem, queue] = createQueuedSignal(\n * (item) => console.log('Processing:', item),\n * { started: true, wait: 1000 },\n * (state) => ({\n * isRunning: state.isRunning,\n * isIdle: state.isIdle,\n * status: state.status,\n * pendingTick: state.pendingTick\n * })\n * );\n *\n * // Opt-in to re-render when execution metrics change (optimized for stats display)\n * const [items, addItem, queue] = createQueuedSignal(\n * (item) => console.log('Processing:', item),\n * { started: true, wait: 1000 },\n * (state) => ({\n * executionCount: state.executionCount,\n * expirationCount: state.expirationCount,\n * rejectionCount: state.rejectionCount\n * })\n * );\n *\n * // Add items to queue\n * const handleAdd = (item) => {\n * addItem(item);\n * };\n *\n * // Start automatic processing\n * const startProcessing = () => {\n * queue.start();\n * };\n *\n * // Stop automatic processing\n * const stopProcessing = () => {\n * queue.stop();\n * };\n *\n * // Manual processing still available\n * const handleProcess = () => {\n * const nextItem = queue.getNextItem();\n * if (nextItem) {\n * processItem(nextItem);\n * }\n * };\n *\n * // Access the selected queuer state (will be empty object {} unless selector provided)\n * const { size, isRunning, executionCount } = queue.state;\n * ```\n */\nexport function createQueuedSignal<\n TValue,\n TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<\n QueuerState<TValue>,\n 'items'\n >,\n>(\n fn: (item: TValue) => void,\n options: QueuerOptions<TValue> = {},\n selector: (state: QueuerState<TValue>) => TSelected = (state) =>\n ({ items: state.items }) as TSelected,\n): [\n () => Array<TValue>,\n SolidQueuer<TValue, TSelected>['addItem'],\n SolidQueuer<TValue, TSelected>,\n] {\n const queue = createQueuer(fn, options, selector)\n\n return [() => queue.state().items, queue.addItem, queue]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsHA,SAAgB,mBAOd,IACA,UAAiC,EAAE,EACnC,YAAuD,WACpD,EAAE,OAAO,MAAM,OAAO,GAKzB;CACA,MAAM,QAAQA,kCAAa,IAAI,SAAS,SAAS;AAEjD,QAAO;QAAO,MAAM,OAAO,CAAC;EAAO,MAAM;EAAS;EAAM"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { SolidQueuer } from "./createQueuer.cjs";
|
|
2
|
+
import { QueuerOptions, QueuerState } from "@tanstack/pacer/queuer";
|
|
3
|
+
|
|
4
|
+
//#region src/queuer/createQueuedSignal.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A Solid primitive that creates a queuer with managed state, combining Solid's signals with queuing functionality.
|
|
8
|
+
* This primitive provides both the current queue state and queue control methods.
|
|
9
|
+
*
|
|
10
|
+
* The queue state is automatically updated whenever items are added, removed, or reordered in the queue.
|
|
11
|
+
* All queue operations are reflected in the state array returned by the primitive.
|
|
12
|
+
*
|
|
13
|
+
* The queue can be started and stopped to automatically process items at a specified interval,
|
|
14
|
+
* making it useful as a scheduler. When started, it will process one item per tick, with an
|
|
15
|
+
* optional wait time between ticks.
|
|
16
|
+
*
|
|
17
|
+
* The primitive returns a tuple containing:
|
|
18
|
+
* - The current queue state as an array
|
|
19
|
+
* - The queue instance with methods for queue manipulation
|
|
20
|
+
*
|
|
21
|
+
* ## State Management and Selector
|
|
22
|
+
*
|
|
23
|
+
* The primitive uses Solid's reactive state management via the underlying queuer instance.
|
|
24
|
+
* The `selector` parameter allows you to specify which queuer state changes will trigger a re-render,
|
|
25
|
+
* optimizing performance by preventing unnecessary re-renders when irrelevant state changes occur.
|
|
26
|
+
*
|
|
27
|
+
* **By default, there will be no reactive state subscriptions** and you must opt-in to state
|
|
28
|
+
* tracking by providing a selector function. This prevents unnecessary re-renders and gives you
|
|
29
|
+
* full control over when your component updates. Only when you provide a selector will the
|
|
30
|
+
* component re-render when the selected state values change.
|
|
31
|
+
*
|
|
32
|
+
* Available queuer state properties:
|
|
33
|
+
* - `executionCount`: Number of items that have been processed by the queuer
|
|
34
|
+
* - `expirationCount`: Number of items that have been removed due to expiration
|
|
35
|
+
* - `isEmpty`: Whether the queuer has no items to process
|
|
36
|
+
* - `isFull`: Whether the queuer has reached its maximum capacity
|
|
37
|
+
* - `isIdle`: Whether the queuer is not currently processing any items
|
|
38
|
+
* - `isRunning`: Whether the queuer is active and will process items automatically
|
|
39
|
+
* - `items`: Array of items currently waiting to be processed
|
|
40
|
+
* - `itemTimestamps`: Timestamps when items were added for expiration tracking
|
|
41
|
+
* - `pendingTick`: Whether the queuer has a pending timeout for processing the next item
|
|
42
|
+
* - `rejectionCount`: Number of items that have been rejected from being added
|
|
43
|
+
* - `size`: Number of items currently in the queue
|
|
44
|
+
* - `status`: Current processing status ('idle' | 'running' | 'stopped')
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```tsx
|
|
48
|
+
* // Default behavior - no reactive state subscriptions
|
|
49
|
+
* const [items, addItem, queue] = createQueuedSignal(
|
|
50
|
+
* (item) => console.log('Processing:', item),
|
|
51
|
+
* {
|
|
52
|
+
* initialItems: ['item1', 'item2'],
|
|
53
|
+
* started: true,
|
|
54
|
+
* wait: 1000,
|
|
55
|
+
* getPriority: (item) => item.priority
|
|
56
|
+
* }
|
|
57
|
+
* );
|
|
58
|
+
*
|
|
59
|
+
* // Opt-in to re-render when queue contents change (optimized for displaying queue items)
|
|
60
|
+
* const [items, addItem, queue] = createQueuedSignal(
|
|
61
|
+
* (item) => console.log('Processing:', item),
|
|
62
|
+
* { started: true, wait: 1000 },
|
|
63
|
+
* (state) => ({
|
|
64
|
+
* items: state.items,
|
|
65
|
+
* size: state.size,
|
|
66
|
+
* isEmpty: state.isEmpty
|
|
67
|
+
* })
|
|
68
|
+
* );
|
|
69
|
+
*
|
|
70
|
+
* // Opt-in to re-render when processing state changes (optimized for loading indicators)
|
|
71
|
+
* const [items, addItem, queue] = createQueuedSignal(
|
|
72
|
+
* (item) => console.log('Processing:', item),
|
|
73
|
+
* { started: true, wait: 1000 },
|
|
74
|
+
* (state) => ({
|
|
75
|
+
* isRunning: state.isRunning,
|
|
76
|
+
* isIdle: state.isIdle,
|
|
77
|
+
* status: state.status,
|
|
78
|
+
* pendingTick: state.pendingTick
|
|
79
|
+
* })
|
|
80
|
+
* );
|
|
81
|
+
*
|
|
82
|
+
* // Opt-in to re-render when execution metrics change (optimized for stats display)
|
|
83
|
+
* const [items, addItem, queue] = createQueuedSignal(
|
|
84
|
+
* (item) => console.log('Processing:', item),
|
|
85
|
+
* { started: true, wait: 1000 },
|
|
86
|
+
* (state) => ({
|
|
87
|
+
* executionCount: state.executionCount,
|
|
88
|
+
* expirationCount: state.expirationCount,
|
|
89
|
+
* rejectionCount: state.rejectionCount
|
|
90
|
+
* })
|
|
91
|
+
* );
|
|
92
|
+
*
|
|
93
|
+
* // Add items to queue
|
|
94
|
+
* const handleAdd = (item) => {
|
|
95
|
+
* addItem(item);
|
|
96
|
+
* };
|
|
97
|
+
*
|
|
98
|
+
* // Start automatic processing
|
|
99
|
+
* const startProcessing = () => {
|
|
100
|
+
* queue.start();
|
|
101
|
+
* };
|
|
102
|
+
*
|
|
103
|
+
* // Stop automatic processing
|
|
104
|
+
* const stopProcessing = () => {
|
|
105
|
+
* queue.stop();
|
|
106
|
+
* };
|
|
107
|
+
*
|
|
108
|
+
* // Manual processing still available
|
|
109
|
+
* const handleProcess = () => {
|
|
110
|
+
* const nextItem = queue.getNextItem();
|
|
111
|
+
* if (nextItem) {
|
|
112
|
+
* processItem(nextItem);
|
|
113
|
+
* }
|
|
114
|
+
* };
|
|
115
|
+
*
|
|
116
|
+
* // Access the selected queuer state (will be empty object {} unless selector provided)
|
|
117
|
+
* const { size, isRunning, executionCount } = queue.state;
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
declare function createQueuedSignal<TValue, TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<QueuerState<TValue>, 'items'>>(fn: (item: TValue) => void, options?: QueuerOptions<TValue>, selector?: (state: QueuerState<TValue>) => TSelected): [() => Array<TValue>, SolidQueuer<TValue, TSelected>['addItem'], SolidQueuer<TValue, TSelected>];
|
|
121
|
+
//#endregion
|
|
122
|
+
export { createQueuedSignal };
|
|
123
|
+
//# sourceMappingURL=createQueuedSignal.d.cts.map
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { SolidQueuer } from "./createQueuer.js";
|
|
2
|
+
import { QueuerOptions, QueuerState } from "@tanstack/pacer/queuer";
|
|
3
|
+
|
|
4
|
+
//#region src/queuer/createQueuedSignal.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A Solid primitive that creates a queuer with managed state, combining Solid's signals with queuing functionality.
|
|
8
|
+
* This primitive provides both the current queue state and queue control methods.
|
|
9
|
+
*
|
|
10
|
+
* The queue state is automatically updated whenever items are added, removed, or reordered in the queue.
|
|
11
|
+
* All queue operations are reflected in the state array returned by the primitive.
|
|
12
|
+
*
|
|
13
|
+
* The queue can be started and stopped to automatically process items at a specified interval,
|
|
14
|
+
* making it useful as a scheduler. When started, it will process one item per tick, with an
|
|
15
|
+
* optional wait time between ticks.
|
|
16
|
+
*
|
|
17
|
+
* The primitive returns a tuple containing:
|
|
18
|
+
* - The current queue state as an array
|
|
19
|
+
* - The queue instance with methods for queue manipulation
|
|
20
|
+
*
|
|
21
|
+
* ## State Management and Selector
|
|
22
|
+
*
|
|
23
|
+
* The primitive uses Solid's reactive state management via the underlying queuer instance.
|
|
24
|
+
* The `selector` parameter allows you to specify which queuer state changes will trigger a re-render,
|
|
25
|
+
* optimizing performance by preventing unnecessary re-renders when irrelevant state changes occur.
|
|
26
|
+
*
|
|
27
|
+
* **By default, there will be no reactive state subscriptions** and you must opt-in to state
|
|
28
|
+
* tracking by providing a selector function. This prevents unnecessary re-renders and gives you
|
|
29
|
+
* full control over when your component updates. Only when you provide a selector will the
|
|
30
|
+
* component re-render when the selected state values change.
|
|
31
|
+
*
|
|
32
|
+
* Available queuer state properties:
|
|
33
|
+
* - `executionCount`: Number of items that have been processed by the queuer
|
|
34
|
+
* - `expirationCount`: Number of items that have been removed due to expiration
|
|
35
|
+
* - `isEmpty`: Whether the queuer has no items to process
|
|
36
|
+
* - `isFull`: Whether the queuer has reached its maximum capacity
|
|
37
|
+
* - `isIdle`: Whether the queuer is not currently processing any items
|
|
38
|
+
* - `isRunning`: Whether the queuer is active and will process items automatically
|
|
39
|
+
* - `items`: Array of items currently waiting to be processed
|
|
40
|
+
* - `itemTimestamps`: Timestamps when items were added for expiration tracking
|
|
41
|
+
* - `pendingTick`: Whether the queuer has a pending timeout for processing the next item
|
|
42
|
+
* - `rejectionCount`: Number of items that have been rejected from being added
|
|
43
|
+
* - `size`: Number of items currently in the queue
|
|
44
|
+
* - `status`: Current processing status ('idle' | 'running' | 'stopped')
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```tsx
|
|
48
|
+
* // Default behavior - no reactive state subscriptions
|
|
49
|
+
* const [items, addItem, queue] = createQueuedSignal(
|
|
50
|
+
* (item) => console.log('Processing:', item),
|
|
51
|
+
* {
|
|
52
|
+
* initialItems: ['item1', 'item2'],
|
|
53
|
+
* started: true,
|
|
54
|
+
* wait: 1000,
|
|
55
|
+
* getPriority: (item) => item.priority
|
|
56
|
+
* }
|
|
57
|
+
* );
|
|
58
|
+
*
|
|
59
|
+
* // Opt-in to re-render when queue contents change (optimized for displaying queue items)
|
|
60
|
+
* const [items, addItem, queue] = createQueuedSignal(
|
|
61
|
+
* (item) => console.log('Processing:', item),
|
|
62
|
+
* { started: true, wait: 1000 },
|
|
63
|
+
* (state) => ({
|
|
64
|
+
* items: state.items,
|
|
65
|
+
* size: state.size,
|
|
66
|
+
* isEmpty: state.isEmpty
|
|
67
|
+
* })
|
|
68
|
+
* );
|
|
69
|
+
*
|
|
70
|
+
* // Opt-in to re-render when processing state changes (optimized for loading indicators)
|
|
71
|
+
* const [items, addItem, queue] = createQueuedSignal(
|
|
72
|
+
* (item) => console.log('Processing:', item),
|
|
73
|
+
* { started: true, wait: 1000 },
|
|
74
|
+
* (state) => ({
|
|
75
|
+
* isRunning: state.isRunning,
|
|
76
|
+
* isIdle: state.isIdle,
|
|
77
|
+
* status: state.status,
|
|
78
|
+
* pendingTick: state.pendingTick
|
|
79
|
+
* })
|
|
80
|
+
* );
|
|
81
|
+
*
|
|
82
|
+
* // Opt-in to re-render when execution metrics change (optimized for stats display)
|
|
83
|
+
* const [items, addItem, queue] = createQueuedSignal(
|
|
84
|
+
* (item) => console.log('Processing:', item),
|
|
85
|
+
* { started: true, wait: 1000 },
|
|
86
|
+
* (state) => ({
|
|
87
|
+
* executionCount: state.executionCount,
|
|
88
|
+
* expirationCount: state.expirationCount,
|
|
89
|
+
* rejectionCount: state.rejectionCount
|
|
90
|
+
* })
|
|
91
|
+
* );
|
|
92
|
+
*
|
|
93
|
+
* // Add items to queue
|
|
94
|
+
* const handleAdd = (item) => {
|
|
95
|
+
* addItem(item);
|
|
96
|
+
* };
|
|
97
|
+
*
|
|
98
|
+
* // Start automatic processing
|
|
99
|
+
* const startProcessing = () => {
|
|
100
|
+
* queue.start();
|
|
101
|
+
* };
|
|
102
|
+
*
|
|
103
|
+
* // Stop automatic processing
|
|
104
|
+
* const stopProcessing = () => {
|
|
105
|
+
* queue.stop();
|
|
106
|
+
* };
|
|
107
|
+
*
|
|
108
|
+
* // Manual processing still available
|
|
109
|
+
* const handleProcess = () => {
|
|
110
|
+
* const nextItem = queue.getNextItem();
|
|
111
|
+
* if (nextItem) {
|
|
112
|
+
* processItem(nextItem);
|
|
113
|
+
* }
|
|
114
|
+
* };
|
|
115
|
+
*
|
|
116
|
+
* // Access the selected queuer state (will be empty object {} unless selector provided)
|
|
117
|
+
* const { size, isRunning, executionCount } = queue.state;
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
declare function createQueuedSignal<TValue, TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<QueuerState<TValue>, 'items'>>(fn: (item: TValue) => void, options?: QueuerOptions<TValue>, selector?: (state: QueuerState<TValue>) => TSelected): [() => Array<TValue>, SolidQueuer<TValue, TSelected>['addItem'], SolidQueuer<TValue, TSelected>];
|
|
121
|
+
//#endregion
|
|
122
|
+
export { createQueuedSignal };
|
|
123
|
+
//# sourceMappingURL=createQueuedSignal.d.ts.map
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { createQueuer } from "./createQueuer.js";
|
|
2
|
+
|
|
3
|
+
//#region src/queuer/createQueuedSignal.ts
|
|
4
|
+
/**
|
|
5
|
+
* A Solid primitive that creates a queuer with managed state, combining Solid's signals with queuing functionality.
|
|
6
|
+
* This primitive provides both the current queue state and queue control methods.
|
|
7
|
+
*
|
|
8
|
+
* The queue state is automatically updated whenever items are added, removed, or reordered in the queue.
|
|
9
|
+
* All queue operations are reflected in the state array returned by the primitive.
|
|
10
|
+
*
|
|
11
|
+
* The queue can be started and stopped to automatically process items at a specified interval,
|
|
12
|
+
* making it useful as a scheduler. When started, it will process one item per tick, with an
|
|
13
|
+
* optional wait time between ticks.
|
|
14
|
+
*
|
|
15
|
+
* The primitive returns a tuple containing:
|
|
16
|
+
* - The current queue state as an array
|
|
17
|
+
* - The queue instance with methods for queue manipulation
|
|
18
|
+
*
|
|
19
|
+
* ## State Management and Selector
|
|
20
|
+
*
|
|
21
|
+
* The primitive uses Solid's reactive state management via the underlying queuer instance.
|
|
22
|
+
* The `selector` parameter allows you to specify which queuer state changes will trigger a re-render,
|
|
23
|
+
* optimizing performance by preventing unnecessary re-renders when irrelevant state changes occur.
|
|
24
|
+
*
|
|
25
|
+
* **By default, there will be no reactive state subscriptions** and you must opt-in to state
|
|
26
|
+
* tracking by providing a selector function. This prevents unnecessary re-renders and gives you
|
|
27
|
+
* full control over when your component updates. Only when you provide a selector will the
|
|
28
|
+
* component re-render when the selected state values change.
|
|
29
|
+
*
|
|
30
|
+
* Available queuer state properties:
|
|
31
|
+
* - `executionCount`: Number of items that have been processed by the queuer
|
|
32
|
+
* - `expirationCount`: Number of items that have been removed due to expiration
|
|
33
|
+
* - `isEmpty`: Whether the queuer has no items to process
|
|
34
|
+
* - `isFull`: Whether the queuer has reached its maximum capacity
|
|
35
|
+
* - `isIdle`: Whether the queuer is not currently processing any items
|
|
36
|
+
* - `isRunning`: Whether the queuer is active and will process items automatically
|
|
37
|
+
* - `items`: Array of items currently waiting to be processed
|
|
38
|
+
* - `itemTimestamps`: Timestamps when items were added for expiration tracking
|
|
39
|
+
* - `pendingTick`: Whether the queuer has a pending timeout for processing the next item
|
|
40
|
+
* - `rejectionCount`: Number of items that have been rejected from being added
|
|
41
|
+
* - `size`: Number of items currently in the queue
|
|
42
|
+
* - `status`: Current processing status ('idle' | 'running' | 'stopped')
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* // Default behavior - no reactive state subscriptions
|
|
47
|
+
* const [items, addItem, queue] = createQueuedSignal(
|
|
48
|
+
* (item) => console.log('Processing:', item),
|
|
49
|
+
* {
|
|
50
|
+
* initialItems: ['item1', 'item2'],
|
|
51
|
+
* started: true,
|
|
52
|
+
* wait: 1000,
|
|
53
|
+
* getPriority: (item) => item.priority
|
|
54
|
+
* }
|
|
55
|
+
* );
|
|
56
|
+
*
|
|
57
|
+
* // Opt-in to re-render when queue contents change (optimized for displaying queue items)
|
|
58
|
+
* const [items, addItem, queue] = createQueuedSignal(
|
|
59
|
+
* (item) => console.log('Processing:', item),
|
|
60
|
+
* { started: true, wait: 1000 },
|
|
61
|
+
* (state) => ({
|
|
62
|
+
* items: state.items,
|
|
63
|
+
* size: state.size,
|
|
64
|
+
* isEmpty: state.isEmpty
|
|
65
|
+
* })
|
|
66
|
+
* );
|
|
67
|
+
*
|
|
68
|
+
* // Opt-in to re-render when processing state changes (optimized for loading indicators)
|
|
69
|
+
* const [items, addItem, queue] = createQueuedSignal(
|
|
70
|
+
* (item) => console.log('Processing:', item),
|
|
71
|
+
* { started: true, wait: 1000 },
|
|
72
|
+
* (state) => ({
|
|
73
|
+
* isRunning: state.isRunning,
|
|
74
|
+
* isIdle: state.isIdle,
|
|
75
|
+
* status: state.status,
|
|
76
|
+
* pendingTick: state.pendingTick
|
|
77
|
+
* })
|
|
78
|
+
* );
|
|
79
|
+
*
|
|
80
|
+
* // Opt-in to re-render when execution metrics change (optimized for stats display)
|
|
81
|
+
* const [items, addItem, queue] = createQueuedSignal(
|
|
82
|
+
* (item) => console.log('Processing:', item),
|
|
83
|
+
* { started: true, wait: 1000 },
|
|
84
|
+
* (state) => ({
|
|
85
|
+
* executionCount: state.executionCount,
|
|
86
|
+
* expirationCount: state.expirationCount,
|
|
87
|
+
* rejectionCount: state.rejectionCount
|
|
88
|
+
* })
|
|
89
|
+
* );
|
|
90
|
+
*
|
|
91
|
+
* // Add items to queue
|
|
92
|
+
* const handleAdd = (item) => {
|
|
93
|
+
* addItem(item);
|
|
94
|
+
* };
|
|
95
|
+
*
|
|
96
|
+
* // Start automatic processing
|
|
97
|
+
* const startProcessing = () => {
|
|
98
|
+
* queue.start();
|
|
99
|
+
* };
|
|
100
|
+
*
|
|
101
|
+
* // Stop automatic processing
|
|
102
|
+
* const stopProcessing = () => {
|
|
103
|
+
* queue.stop();
|
|
104
|
+
* };
|
|
105
|
+
*
|
|
106
|
+
* // Manual processing still available
|
|
107
|
+
* const handleProcess = () => {
|
|
108
|
+
* const nextItem = queue.getNextItem();
|
|
109
|
+
* if (nextItem) {
|
|
110
|
+
* processItem(nextItem);
|
|
111
|
+
* }
|
|
112
|
+
* };
|
|
113
|
+
*
|
|
114
|
+
* // Access the selected queuer state (will be empty object {} unless selector provided)
|
|
115
|
+
* const { size, isRunning, executionCount } = queue.state;
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
function createQueuedSignal(fn, options = {}, selector = (state) => ({ items: state.items })) {
|
|
119
|
+
const queue = createQueuer(fn, options, selector);
|
|
120
|
+
return [
|
|
121
|
+
() => queue.state().items,
|
|
122
|
+
queue.addItem,
|
|
123
|
+
queue
|
|
124
|
+
];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
export { createQueuedSignal };
|
|
129
|
+
//# sourceMappingURL=createQueuedSignal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createQueuedSignal.js","names":[],"sources":["../../src/queuer/createQueuedSignal.ts"],"sourcesContent":["import { createQueuer } from './createQueuer'\nimport type { SolidQueuer } from './createQueuer'\nimport type { QueuerOptions, QueuerState } from '@tanstack/pacer/queuer'\n\n/**\n * A Solid primitive that creates a queuer with managed state, combining Solid's signals with queuing functionality.\n * This primitive provides both the current queue state and queue control methods.\n *\n * The queue state is automatically updated whenever items are added, removed, or reordered in the queue.\n * All queue operations are reflected in the state array returned by the primitive.\n *\n * The queue can be started and stopped to automatically process items at a specified interval,\n * making it useful as a scheduler. When started, it will process one item per tick, with an\n * optional wait time between ticks.\n *\n * The primitive returns a tuple containing:\n * - The current queue state as an array\n * - The queue instance with methods for queue manipulation\n *\n * ## State Management and Selector\n *\n * The primitive uses Solid's reactive state management via the underlying queuer instance.\n * The `selector` parameter allows you to specify which queuer state changes will trigger a re-render,\n * optimizing performance by preventing unnecessary re-renders 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 re-renders and gives you\n * full control over when your component updates. Only when you provide a selector will the\n * component re-render when the selected state values change.\n *\n * Available queuer state properties:\n * - `executionCount`: Number of items that have been processed by the queuer\n * - `expirationCount`: Number of items that have been removed due to expiration\n * - `isEmpty`: Whether the queuer has no items to process\n * - `isFull`: Whether the queuer has reached its maximum capacity\n * - `isIdle`: Whether the queuer is not currently processing any items\n * - `isRunning`: Whether the queuer is active and will process items automatically\n * - `items`: Array of items currently waiting to be processed\n * - `itemTimestamps`: Timestamps when items were added for expiration tracking\n * - `pendingTick`: Whether the queuer has a pending timeout for processing the next item\n * - `rejectionCount`: Number of items that have been rejected from being added\n * - `size`: Number of items currently in the queue\n * - `status`: Current processing status ('idle' | 'running' | 'stopped')\n *\n * @example\n * ```tsx\n * // Default behavior - no reactive state subscriptions\n * const [items, addItem, queue] = createQueuedSignal(\n * (item) => console.log('Processing:', item),\n * {\n * initialItems: ['item1', 'item2'],\n * started: true,\n * wait: 1000,\n * getPriority: (item) => item.priority\n * }\n * );\n *\n * // Opt-in to re-render when queue contents change (optimized for displaying queue items)\n * const [items, addItem, queue] = createQueuedSignal(\n * (item) => console.log('Processing:', item),\n * { started: true, wait: 1000 },\n * (state) => ({\n * items: state.items,\n * size: state.size,\n * isEmpty: state.isEmpty\n * })\n * );\n *\n * // Opt-in to re-render when processing state changes (optimized for loading indicators)\n * const [items, addItem, queue] = createQueuedSignal(\n * (item) => console.log('Processing:', item),\n * { started: true, wait: 1000 },\n * (state) => ({\n * isRunning: state.isRunning,\n * isIdle: state.isIdle,\n * status: state.status,\n * pendingTick: state.pendingTick\n * })\n * );\n *\n * // Opt-in to re-render when execution metrics change (optimized for stats display)\n * const [items, addItem, queue] = createQueuedSignal(\n * (item) => console.log('Processing:', item),\n * { started: true, wait: 1000 },\n * (state) => ({\n * executionCount: state.executionCount,\n * expirationCount: state.expirationCount,\n * rejectionCount: state.rejectionCount\n * })\n * );\n *\n * // Add items to queue\n * const handleAdd = (item) => {\n * addItem(item);\n * };\n *\n * // Start automatic processing\n * const startProcessing = () => {\n * queue.start();\n * };\n *\n * // Stop automatic processing\n * const stopProcessing = () => {\n * queue.stop();\n * };\n *\n * // Manual processing still available\n * const handleProcess = () => {\n * const nextItem = queue.getNextItem();\n * if (nextItem) {\n * processItem(nextItem);\n * }\n * };\n *\n * // Access the selected queuer state (will be empty object {} unless selector provided)\n * const { size, isRunning, executionCount } = queue.state;\n * ```\n */\nexport function createQueuedSignal<\n TValue,\n TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<\n QueuerState<TValue>,\n 'items'\n >,\n>(\n fn: (item: TValue) => void,\n options: QueuerOptions<TValue> = {},\n selector: (state: QueuerState<TValue>) => TSelected = (state) =>\n ({ items: state.items }) as TSelected,\n): [\n () => Array<TValue>,\n SolidQueuer<TValue, TSelected>['addItem'],\n SolidQueuer<TValue, TSelected>,\n] {\n const queue = createQueuer(fn, options, selector)\n\n return [() => queue.state().items, queue.addItem, queue]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsHA,SAAgB,mBAOd,IACA,UAAiC,EAAE,EACnC,YAAuD,WACpD,EAAE,OAAO,MAAM,OAAO,GAKzB;CACA,MAAM,QAAQ,aAAa,IAAI,SAAS,SAAS;AAEjD,QAAO;QAAO,MAAM,OAAO,CAAC;EAAO,MAAM;EAAS;EAAM"}
|