storion 0.9.0 → 0.10.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.
- package/CHANGELOG.md +62 -4
- package/README.md +42 -2021
- package/dist/async/abortable.d.ts +295 -0
- package/dist/async/abortable.d.ts.map +1 -0
- package/dist/async/async.d.ts +86 -5
- package/dist/async/async.d.ts.map +1 -1
- package/dist/async/context.d.ts +15 -0
- package/dist/async/context.d.ts.map +1 -0
- package/dist/async/index.d.ts +16 -3
- package/dist/async/index.d.ts.map +1 -1
- package/dist/async/index.js +407 -137
- package/dist/async/safe.d.ts +221 -0
- package/dist/async/safe.d.ts.map +1 -0
- package/dist/async/types.d.ts +77 -29
- package/dist/async/types.d.ts.map +1 -1
- package/dist/async/wrappers.d.ts +217 -0
- package/dist/async/wrappers.d.ts.map +1 -0
- package/dist/core/effect.d.ts +34 -26
- package/dist/core/effect.d.ts.map +1 -1
- package/dist/core/equality.d.ts +25 -0
- package/dist/core/equality.d.ts.map +1 -1
- package/dist/core/focus.d.ts +20 -0
- package/dist/core/focus.d.ts.map +1 -0
- package/dist/core/focusHelpers.d.ts +258 -0
- package/dist/core/focusHelpers.d.ts.map +1 -0
- package/dist/core/middleware.d.ts +4 -4
- package/dist/core/store.d.ts.map +1 -1
- package/dist/core/storeContext.d.ts +2 -9
- package/dist/core/storeContext.d.ts.map +1 -1
- package/dist/dev.d.ts +0 -10
- package/dist/dev.d.ts.map +1 -1
- package/dist/{index-C8B6Mo8r.js → effect-BDQU8Voz.js} +1241 -583
- package/dist/errors.d.ts +6 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/network/index.d.ts +69 -0
- package/dist/network/index.d.ts.map +1 -0
- package/dist/network/retry.d.ts +53 -0
- package/dist/network/retry.d.ts.map +1 -0
- package/dist/network/services.d.ts +58 -0
- package/dist/network/services.d.ts.map +1 -0
- package/dist/network/store.d.ts +36 -0
- package/dist/network/store.d.ts.map +1 -0
- package/dist/network/utils.d.ts +9 -0
- package/dist/network/utils.d.ts.map +1 -0
- package/dist/persist/index.d.ts +1 -1
- package/dist/persist/index.d.ts.map +1 -1
- package/dist/persist/index.js +11 -9
- package/dist/persist/persist.d.ts +14 -14
- package/dist/persist/persist.d.ts.map +1 -1
- package/dist/pool.d.ts +77 -0
- package/dist/pool.d.ts.map +1 -0
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +245 -244
- package/dist/react/stable.d.ts +27 -0
- package/dist/react/stable.d.ts.map +1 -0
- package/dist/react/useStore.d.ts +38 -13
- package/dist/react/useStore.d.ts.map +1 -1
- package/dist/react/withStore.d.ts.map +1 -1
- package/dist/storion.js +911 -37
- package/dist/trigger.d.ts +12 -7
- package/dist/trigger.d.ts.map +1 -1
- package/dist/types.d.ts +133 -22
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/storeTuple.d.ts +7 -0
- package/dist/utils/storeTuple.d.ts.map +1 -0
- package/package.json +5 -1
- package/dist/collection.d.ts +0 -34
- package/dist/collection.d.ts.map +0 -1
- package/dist/core/proxy.d.ts +0 -47
- package/dist/core/proxy.d.ts.map +0 -1
- package/dist/effect-C6h0PDDI.js +0 -446
- package/dist/isPromiseLike-bFkfHAbm.js +0 -6
- package/dist/react/useLocalStore.d.ts +0 -48
- package/dist/react/useLocalStore.d.ts.map +0 -1
package/dist/core/effect.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
+
import { SafeFnWithUtils } from '../async/safe';
|
|
2
|
+
import { RetryStrategyName } from '../async/types';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Effects run immediately and re-run when tracked dependencies change.
|
|
5
|
-
* Dependencies are automatically tracked when state properties are read.
|
|
5
|
+
* Retry delay: milliseconds, strategy name, or custom function.
|
|
6
6
|
*/
|
|
7
|
+
export type EffectRetryDelay = number | RetryStrategyName | ((attempt: number) => number);
|
|
7
8
|
/**
|
|
8
9
|
* Retry configuration for effects.
|
|
10
|
+
* Unified with async module retry options.
|
|
9
11
|
*/
|
|
10
12
|
export interface EffectRetryConfig {
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
/** Delay
|
|
14
|
-
delay?:
|
|
13
|
+
/** Number of retry attempts */
|
|
14
|
+
retries: number;
|
|
15
|
+
/** Delay between retries: ms, strategy name, or custom function (default: "backoff") */
|
|
16
|
+
delay?: EffectRetryDelay;
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
19
|
* Context passed to custom error handlers.
|
|
@@ -88,33 +90,39 @@ export interface EffectContext {
|
|
|
88
90
|
*/
|
|
89
91
|
onCleanup(listener: VoidFunction): VoidFunction;
|
|
90
92
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
+
* Safely execute operations that should be cancelled if effect becomes stale.
|
|
94
|
+
*
|
|
95
|
+
* Overloads:
|
|
96
|
+
* 1. `safe(promise)` - Wrap promise, never resolve/reject if stale
|
|
97
|
+
* 2. `safe(fn, ...args)` - Call function, wrap result if promise
|
|
98
|
+
* 3. `safe(Abortable, ...args)` - Call with signal, wrap result if promise
|
|
99
|
+
*
|
|
100
|
+
* Utilities:
|
|
101
|
+
* - `safe.all([...])` - Like Promise.all, cancellation-aware
|
|
102
|
+
* - `safe.race([...])` - Like Promise.race, cancellation-aware
|
|
103
|
+
* - `safe.any([...])` - Like Promise.any, cancellation-aware
|
|
104
|
+
* - `safe.settled([...])` - Like Promise.allSettled, cancellation-aware
|
|
105
|
+
* - `safe.callback(fn)` - Wrap callback to only execute if not stale
|
|
93
106
|
*
|
|
94
107
|
* @example
|
|
108
|
+
* ```ts
|
|
95
109
|
* effect((ctx) => {
|
|
110
|
+
* // Wrap a promise
|
|
96
111
|
* ctx.safe(fetchData()).then(data => {
|
|
97
|
-
* // Only runs if effect hasn't re-run
|
|
98
112
|
* state.data = data;
|
|
99
113
|
* });
|
|
100
|
-
* });
|
|
101
|
-
*/
|
|
102
|
-
safe<T>(promise: Promise<T>): Promise<T>;
|
|
103
|
-
/**
|
|
104
|
-
* Wrap a callback to not run if effect is stale/disposed.
|
|
105
|
-
* Useful for event handlers and timeouts.
|
|
106
114
|
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* // Only runs if effect is still active
|
|
111
|
-
* state.value = event.target.value;
|
|
115
|
+
* // Concurrent operations
|
|
116
|
+
* ctx.safe.all([fetchA(), fetchB()]).then(([a, b]) => {
|
|
117
|
+
* state.data = { a, b };
|
|
112
118
|
* });
|
|
113
|
-
*
|
|
114
|
-
*
|
|
119
|
+
*
|
|
120
|
+
* // Wrap event callback
|
|
121
|
+
* const onClick = ctx.safe.callback(() => state.clicked = true);
|
|
115
122
|
* });
|
|
123
|
+
* ```
|
|
116
124
|
*/
|
|
117
|
-
safe
|
|
125
|
+
safe: SafeFnWithUtils;
|
|
118
126
|
/**
|
|
119
127
|
* Manually trigger a re-run of the effect.
|
|
120
128
|
* Useful for async.derive pattern where thrown promises should trigger re-computation.
|
|
@@ -178,7 +186,7 @@ export type EffectFn = (ctx: EffectContext) => void;
|
|
|
178
186
|
* // With retry on error
|
|
179
187
|
* effect((ctx) => {
|
|
180
188
|
* fetchData();
|
|
181
|
-
* }, { onError: {
|
|
189
|
+
* }, { onError: { retries: 3, delay: 1000 } });
|
|
182
190
|
*
|
|
183
191
|
* @example
|
|
184
192
|
* // Custom error handler
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../../src/core/effect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../../src/core/effect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAiB,KAAK,iBAAiB,EAAE,MA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ACjB;AAsED;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,aAAa,KAAK,IAAI,CAAC;AAgCpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAgB,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,YAAY,CAyS1E"}
|
package/dist/core/equality.d.ts
CHANGED
|
@@ -36,4 +36,29 @@ export declare const deepEqual: (value: any, other: any) => boolean;
|
|
|
36
36
|
*/
|
|
37
37
|
export declare function resolveEquality<T>(e: Equality<T> | undefined): (a: T, b: T) => boolean;
|
|
38
38
|
export declare function equality(shorthand: EqualityShorthand): (a: unknown, b: unknown) => boolean;
|
|
39
|
+
export type StableFn<TArgs extends any[], TResult> = {
|
|
40
|
+
getOriginal: () => (...args: TArgs) => TResult;
|
|
41
|
+
getCurrent: () => (...args: TArgs) => TResult;
|
|
42
|
+
setCurrent: (newFn: (...args: TArgs) => TResult) => void;
|
|
43
|
+
};
|
|
44
|
+
export declare function createStableFn<TArgs extends any[], TResult>(fn: (...args: TArgs) => TResult): StableFn<TArgs, TResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Check if a value is a stable function wrapper.
|
|
47
|
+
*/
|
|
48
|
+
export declare function isStableFn<TArgs extends any[], TResult>(value: unknown): value is StableFn<TArgs, TResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Stabilize a value with automatic function wrapper support.
|
|
51
|
+
*
|
|
52
|
+
* - Functions: Creates/updates stable wrapper (reference never changes)
|
|
53
|
+
* - Date objects: Compared by timestamp (uses deepEqual)
|
|
54
|
+
* - Other values: Returns previous if equal per equalityFn
|
|
55
|
+
*
|
|
56
|
+
* @param prev - Previous value container (or undefined for first call)
|
|
57
|
+
* @param next - New value
|
|
58
|
+
* @param equalityFn - Equality function for non-function/non-date values
|
|
59
|
+
* @returns Tuple of [stabilized value, wasStable]
|
|
60
|
+
*/
|
|
61
|
+
export declare function tryStabilize<T>(prev: {
|
|
62
|
+
value: T;
|
|
63
|
+
} | undefined, next: T, equalityFn: (a: T, b: T) => boolean): [T, boolean];
|
|
39
64
|
//# sourceMappingURL=equality.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equality.d.ts","sourceRoot":"","sources":["../../src/core/equality.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"equality.d.ts","sourceRoot":"","sources":["../../src/core/equality.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAW,QAAQ,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAGrE;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,CAElD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,CAAC,EAAE,CAAC,EACJ,CAAC,EAAE,CAAC,EACJ,SAAS,GAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,KAAK,OAAmB,GACzD,OAAO,CAgBT;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,CAEpD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,CAEpD;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,qCAAU,CAAC;AAEjC;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,GACzB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,CAOzB;AAED,wBAAgB,QAAQ,CAAC,SAAS,EAAE,iBAAiB,+BATlC,OAAO,CAWzB;AAMD,MAAM,MAAM,QAAQ,CAAC,KAAK,SAAS,GAAG,EAAE,EAAE,OAAO,IAAI;IACnD,WAAW,EAAE,MAAM,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC;IAC/C,UAAU,EAAE,MAAM,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC;IAC9C,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,KAAK,IAAI,CAAC;CAC1D,CAAC;AAEF,wBAAgB,cAAc,CAAC,KAAK,SAAS,GAAG,EAAE,EAAE,OAAO,EACzD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,GAC9B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAe1B;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,SAAS,GAAG,EAAE,EAAE,OAAO,EACrD,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAOnC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,IAAI,EAAE;IAAE,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG,SAAS,EAC9B,IAAI,EAAE,CAAC,EACP,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,GAClC,CAAC,CAAC,EAAE,OAAO,CAAC,CAmCd"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { StoreContext, Resolver, Focus, FocusOptions, FocusContext } from '../types';
|
|
2
|
+
|
|
3
|
+
/** Track options for dev-mode warning */
|
|
4
|
+
type CachedFocusInfo = {
|
|
5
|
+
focus: Focus<any>;
|
|
6
|
+
options?: FocusOptions<any>;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Create a focus for a nested state path.
|
|
10
|
+
*
|
|
11
|
+
* @param storeContext - The store context
|
|
12
|
+
* @param resolver - The dependency resolver
|
|
13
|
+
* @param context - Focus context with state access
|
|
14
|
+
* @param segments - Path segments to focus on
|
|
15
|
+
* @param cache - Cache map for reusing focus objects by path
|
|
16
|
+
* @param options - Focus options (fallback, equality)
|
|
17
|
+
*/
|
|
18
|
+
export declare function createFocus<TValue>(storeContext: StoreContext<any>, resolver: Resolver, context: FocusContext, segments: string[], cache: Map<string, CachedFocusInfo>, options?: FocusOptions<TValue>): Focus<TValue>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=focus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus.d.ts","sourceRoot":"","sources":["../../src/core/focus.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,KAAK,EACV,KAAK,YAAY,EACjB,KAAK,YAAY,EAIlB,MAAM,UAAU,CAAC;AA+BlB,yCAAyC;AACzC,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAClB,OAAO,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;CAC7B,CAAC;AAsBF;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAChC,YAAY,EAAE,YAAY,CAAC,GAAG,CAAC,EAC/B,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,MAAM,EAAE,EAClB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EACnC,OAAO,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,GAC7B,KAAK,CAAC,MAAM,CAAC,CAwLf"}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { Focus, PickEquality } from '../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Toggle a boolean value. Works with undefined (treats as false).
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* list.set(0, toggle()); // toggles item at index 0
|
|
9
|
+
* map.set('active', toggle()); // toggles 'active' key
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function toggle(): (prev: boolean | undefined) => boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Increment a number by a given amount (default: 1).
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* map.set('count', increment()); // +1
|
|
19
|
+
* map.set('count', increment(5)); // +5
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function increment(amount?: number): (prev: number | undefined) => number;
|
|
23
|
+
/**
|
|
24
|
+
* Decrement a number by a given amount (default: 1).
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* map.set('count', decrement()); // -1
|
|
29
|
+
* map.set('count', decrement(5)); // -5
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function decrement(amount?: number): (prev: number | undefined) => number;
|
|
33
|
+
/**
|
|
34
|
+
* Multiply a number by a factor.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* map.set('price', multiply(1.1)); // increase by 10%
|
|
39
|
+
* map.set('price', multiply(2)); // double
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function multiply(factor: number): (prev: number | undefined) => number;
|
|
43
|
+
/**
|
|
44
|
+
* Divide a number by a divisor.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* map.set('price', divide(2)); // halve
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function divide(divisor: number): (prev: number | undefined) => number;
|
|
52
|
+
/**
|
|
53
|
+
* Clamp a number within min/max bounds.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* map.set('volume', clamp(0, 100)); // ensure 0-100
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function clamp(min: number, max: number): (prev: number | undefined) => number;
|
|
61
|
+
/**
|
|
62
|
+
* Append string to existing value.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* map.set('log', append('\n' + message));
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function append(suffix: string): (prev: string | undefined) => string;
|
|
70
|
+
/**
|
|
71
|
+
* Prepend string to existing value.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* map.set('path', prepend('/prefix'));
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare function prepend(prefix: string): (prev: string | undefined) => string;
|
|
79
|
+
/**
|
|
80
|
+
* Shallow merge object properties.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* map.set('user', merge({ name: 'John' }));
|
|
85
|
+
* map.set('settings', merge({ theme: 'dark' }));
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare function merge<T extends object>(partial: Partial<T>): (prev: T | undefined) => T;
|
|
89
|
+
/**
|
|
90
|
+
* Reset to a default value (ignores previous).
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* map.set('count', reset(0));
|
|
95
|
+
* map.set('items', reset([]));
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare function reset<T>(defaultValue: T): (prev: T | undefined) => T;
|
|
99
|
+
/**
|
|
100
|
+
* Options for the list helper.
|
|
101
|
+
*/
|
|
102
|
+
export interface ListOptions {
|
|
103
|
+
/** Auto-dispose items when removed. Defaults to false */
|
|
104
|
+
autoDispose?: boolean;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* List API returned by the list() helper.
|
|
108
|
+
*/
|
|
109
|
+
export interface FocusList<T> {
|
|
110
|
+
/** Get the current array (returns empty array if undefined/null) */
|
|
111
|
+
get(): T[];
|
|
112
|
+
/** Get item at index */
|
|
113
|
+
at(index: number): T | undefined;
|
|
114
|
+
/** Get the length of the array */
|
|
115
|
+
length(): number;
|
|
116
|
+
/** Check if array is empty */
|
|
117
|
+
isEmpty(): boolean;
|
|
118
|
+
/** Get the first item */
|
|
119
|
+
first(): T | undefined;
|
|
120
|
+
/** Get the last item */
|
|
121
|
+
last(): T | undefined;
|
|
122
|
+
/** Push item(s) to the end */
|
|
123
|
+
push(...items: T[]): void;
|
|
124
|
+
/** Add item(s) to the beginning */
|
|
125
|
+
unshift(...items: T[]): void;
|
|
126
|
+
/** Remove and return the last item (auto-disposes if enabled) */
|
|
127
|
+
pop(): T | undefined;
|
|
128
|
+
/** Remove and return the first item (auto-disposes if enabled) */
|
|
129
|
+
shift(): T | undefined;
|
|
130
|
+
/** Remove item(s) by reference (auto-disposes if enabled) */
|
|
131
|
+
remove(...items: T[]): number;
|
|
132
|
+
/** Remove item at index (auto-disposes if enabled) */
|
|
133
|
+
removeAt(index: number): T | undefined;
|
|
134
|
+
/** Remove items matching predicate (auto-disposes if enabled) */
|
|
135
|
+
removeWhere(predicate: (item: T, index: number) => boolean): number;
|
|
136
|
+
/** Insert item at index */
|
|
137
|
+
insert(index: number, ...items: T[]): void;
|
|
138
|
+
/**
|
|
139
|
+
* Set item at index (auto-disposes old item if enabled).
|
|
140
|
+
* Accepts direct value, reducer, or immer-style updater.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* items.set(0, newItem); // Direct value
|
|
144
|
+
* items.set(0, prev => ({ ...prev, done: true })); // Reducer
|
|
145
|
+
* items.set(0, draft => { draft.done = true }); // Updater (mutates draft)
|
|
146
|
+
*/
|
|
147
|
+
set(index: number, itemOrReducerOrUpdater: T | ((prev: T) => T | void)): void;
|
|
148
|
+
/** Clear all items (auto-disposes all if enabled) */
|
|
149
|
+
clear(): void;
|
|
150
|
+
/** Replace entire array (auto-disposes old items if enabled) */
|
|
151
|
+
replace(items: T[]): void;
|
|
152
|
+
/** Find item matching predicate */
|
|
153
|
+
find(predicate: (item: T, index: number) => boolean): T | undefined;
|
|
154
|
+
/** Find index of item matching predicate */
|
|
155
|
+
findIndex(predicate: (item: T, index: number) => boolean): number;
|
|
156
|
+
/** Check if item exists */
|
|
157
|
+
includes(item: T): boolean;
|
|
158
|
+
/** Map items (read-only, doesn't mutate) */
|
|
159
|
+
map<U>(fn: (item: T, index: number) => U): U[];
|
|
160
|
+
/** Filter items (read-only, doesn't mutate) */
|
|
161
|
+
filter(predicate: (item: T, index: number) => boolean): T[];
|
|
162
|
+
/** Create a pick selector for fine-grained reactivity */
|
|
163
|
+
pick(equality?: PickEquality<T[] | undefined | null>): T[];
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Create a list helper for array focus.
|
|
167
|
+
* Handles undefined/null arrays gracefully.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* const todoStore = store({
|
|
172
|
+
* name: 'todos',
|
|
173
|
+
* state: { items: [] as TodoItem[] },
|
|
174
|
+
* setup({ focus }) {
|
|
175
|
+
* const items = focus('items').as(list());
|
|
176
|
+
* return {
|
|
177
|
+
* addTodo: (text: string) => items.push({ id: Date.now(), text, done: false }),
|
|
178
|
+
* removeTodo: (todo: TodoItem) => items.remove(todo),
|
|
179
|
+
* clearDone: () => items.removeWhere(item => item.done),
|
|
180
|
+
* clearAll: () => items.clear(),
|
|
181
|
+
* };
|
|
182
|
+
* },
|
|
183
|
+
* });
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
export declare function list<T>(options?: ListOptions): (focus: Focus<T[] | undefined | null> | Focus<T[] | undefined> | Focus<T[] | null> | Focus<T[]>) => FocusList<T>;
|
|
187
|
+
/**
|
|
188
|
+
* Options for the map helper.
|
|
189
|
+
*/
|
|
190
|
+
export interface MapOptions {
|
|
191
|
+
/** Auto-dispose values when removed. Defaults to false */
|
|
192
|
+
autoDispose?: boolean;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Map API returned by the map() helper.
|
|
196
|
+
*/
|
|
197
|
+
export interface FocusMap<T> {
|
|
198
|
+
/** Get the current record (returns defaultValue if undefined/null) */
|
|
199
|
+
get(): Record<string, T>;
|
|
200
|
+
/** Get value by key */
|
|
201
|
+
at(key: string): T | undefined;
|
|
202
|
+
/** Get number of entries */
|
|
203
|
+
size(): number;
|
|
204
|
+
/** Check if record is empty */
|
|
205
|
+
isEmpty(): boolean;
|
|
206
|
+
/** Check if key exists */
|
|
207
|
+
has(key: string): boolean;
|
|
208
|
+
/**
|
|
209
|
+
* Set value at key (auto-disposes old value if enabled).
|
|
210
|
+
* Accepts direct value, reducer, or immer-style updater.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* cache.set('count', 10); // Direct value
|
|
214
|
+
* cache.set('count', prev => prev + 1); // Reducer (returns new value)
|
|
215
|
+
* cache.set('user', draft => { draft.age++ }); // Updater (mutates draft)
|
|
216
|
+
*/
|
|
217
|
+
set(key: string, valueOrReducerOrUpdater: T | ((prev: T) => T | void)): void;
|
|
218
|
+
/** Delete key(s) (auto-disposes values if enabled) */
|
|
219
|
+
delete(...keys: string[]): number;
|
|
220
|
+
/** Delete keys matching predicate (auto-disposes values if enabled) */
|
|
221
|
+
deleteWhere(predicate: (value: T, key: string) => boolean): number;
|
|
222
|
+
/** Clear all entries (auto-disposes all values if enabled) */
|
|
223
|
+
clear(): void;
|
|
224
|
+
/** Replace entire record (auto-disposes old values if enabled) */
|
|
225
|
+
replace(record: Record<string, T>): void;
|
|
226
|
+
/** Get all keys */
|
|
227
|
+
keys(): string[];
|
|
228
|
+
/** Get all values */
|
|
229
|
+
values(): T[];
|
|
230
|
+
/** Get all entries */
|
|
231
|
+
entries(): [string, T][];
|
|
232
|
+
/** Create a pick selector for fine-grained reactivity */
|
|
233
|
+
pick(equality?: PickEquality<Record<string, T> | undefined | null>): Record<string, T>;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Create a map helper for object/record focus.
|
|
237
|
+
* Handles undefined/null records gracefully.
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* const cacheStore = store({
|
|
242
|
+
* name: 'cache',
|
|
243
|
+
* state: { users: {} as Record<string, User> },
|
|
244
|
+
* setup({ focus }) {
|
|
245
|
+
* const users = focus('users').as(map());
|
|
246
|
+
* return {
|
|
247
|
+
* setUser: (id: string, user: User) => users.set(id, user),
|
|
248
|
+
* getUser: (id: string) => users.at(id),
|
|
249
|
+
* removeUser: (id: string) => users.delete(id),
|
|
250
|
+
* hasUser: (id: string) => users.has(id),
|
|
251
|
+
* clearUsers: () => users.clear(),
|
|
252
|
+
* };
|
|
253
|
+
* },
|
|
254
|
+
* });
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
export declare function map<T>(options?: MapOptions): (focus: Focus<Record<string, T> | undefined | null> | Focus<Record<string, T> | undefined> | Focus<Record<string, T> | null> | Focus<Record<string, T>>) => FocusMap<T>;
|
|
258
|
+
//# sourceMappingURL=focusHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focusHelpers.d.ts","sourceRoot":"","sources":["../../src/core/focusHelpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AA2GpD;;;;;;;;GAQG;AACH,wBAAgB,MAAM,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,KAAK,OAAO,CAE/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CACvB,MAAM,GAAE,MAAU,GACjB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,KAAK,MAAM,CAEtC;AAED;;;;;;;;G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;GAqBG;AACH,wBAAgB,GAAG,CAAC,CAAC,EACnB,OAAO,CAAC,EAAE,UAAU,GACnB,CACD,KAAK,EACD,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,GAC3C,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,GACpC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,GAC/B,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,KACzB,QAAQ,CAAC,CAAC,CAAC,CAsKf"}
|
|
@@ -44,7 +44,7 @@ export type MiddlewareMap = Record<string, StoreMiddleware | StoreMiddleware[]>;
|
|
|
44
44
|
* // Predicate function
|
|
45
45
|
* applyFor(
|
|
46
46
|
* (ctx) => ctx.type === "store" && ctx.spec.options.meta?.persist === true,
|
|
47
|
-
*
|
|
47
|
+
* persist
|
|
48
48
|
* );
|
|
49
49
|
*
|
|
50
50
|
* // Multiple middleware
|
|
@@ -81,14 +81,14 @@ export declare function applyFor(middlewareMap: MiddlewareMap): Middleware;
|
|
|
81
81
|
* );
|
|
82
82
|
*
|
|
83
83
|
* // Exclude exact names
|
|
84
|
-
* applyExcept(["tempStore", "cacheStore"],
|
|
84
|
+
* applyExcept(["tempStore", "cacheStore"], persist);
|
|
85
85
|
*
|
|
86
86
|
* // Exclude with wildcards
|
|
87
87
|
* applyExcept("_*", loggingMiddleware); // exclude _internal, _temp, etc.
|
|
88
|
-
* applyExcept("*Cache",
|
|
88
|
+
* applyExcept("*Cache", persist); // exclude userCache, dataCache, etc.
|
|
89
89
|
*
|
|
90
90
|
* // Exclude with RegExp
|
|
91
|
-
* applyExcept(/^(temp|cache)/,
|
|
91
|
+
* applyExcept(/^(temp|cache)/, persist);
|
|
92
92
|
* ```
|
|
93
93
|
*/
|
|
94
94
|
export declare function applyExcept(predicate: (ctx: MiddlewareContext) => boolean, middleware: Middleware | Middleware[]): Middleware;
|
package/dist/core/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/core/store.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,QAAQ,EAKb,KAAK,kBAAkB,EACxB,MAAM,UAAU,CAAC;AA0BlB;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CACnB,MAAM,SAAS,SAAS,GAAG,SAAS,EACpC,QAAQ,SAAS,WAAW,GAAG,WAAW,EAC1C,OAAO,EAAE,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CA2BtE;AAYD,0CAA0C;AAC1C,MAAM,WAAW,0BAA0B;IACzC,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,SAAS,SAAS,EACxB,QAAQ,SAAS,WAAW,EAE5B,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,EACjC,QAAQ,EAAE,QAAQ,EAClB,eAAe,GAAE,0BAA+B,GAC/C,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/core/store.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,QAAQ,EAKb,KAAK,kBAAkB,EACxB,MAAM,UAAU,CAAC;AA0BlB;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CACnB,MAAM,SAAS,SAAS,GAAG,SAAS,EACpC,QAAQ,SAAS,WAAW,GAAG,WAAW,EAC1C,OAAO,EAAE,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CA2BtE;AAYD,0CAA0C;AAC1C,MAAM,WAAW,0BAA0B;IACzC,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,SAAS,SAAS,EACxB,QAAQ,SAAS,WAAW,EAE5B,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,EACjC,QAAQ,EAAE,QAAQ,EAClB,eAAe,GAAE,0BAA+B,GAC/C,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CA8rBjC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { StateBase, ActionsBase, StoreSpec, StoreInstance, Resolver, StoreContext
|
|
1
|
+
import { StateBase, ActionsBase, StoreSpec, StoreInstance, Resolver, StoreContext } from '../types';
|
|
2
2
|
|
|
3
|
+
export { createFocus } from './focus';
|
|
3
4
|
/**
|
|
4
5
|
* Options for creating store context.
|
|
5
6
|
*/
|
|
@@ -27,14 +28,6 @@ export interface CreateStoreContextOptions<TState extends StateBase, TActions ex
|
|
|
27
28
|
/** Check if in setup phase */
|
|
28
29
|
isSetupPhase: () => boolean;
|
|
29
30
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Create a focus for a nested state path.
|
|
32
|
-
*
|
|
33
|
-
* @param context - Focus context with state access
|
|
34
|
-
* @param path - Dot-notation path to focus on
|
|
35
|
-
* @param options - Focus options (fallback, equality)
|
|
36
|
-
*/
|
|
37
|
-
export declare function createFocus<TValue>(context: FocusContext, segments: string[], isSetupPhase: () => boolean, options?: FocusOptions<TValue>): Focus<TValue>;
|
|
38
31
|
/**
|
|
39
32
|
* Create a store context for the setup function.
|
|
40
33
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storeContext.d.ts","sourceRoot":"","sources":["../../src/core/storeContext.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"storeContext.d.ts","sourceRoot":"","sources":["../../src/core/storeContext.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,YAAY,EAKlB,MAAM,UAAU,CAAC;AAMlB,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAOtC;;GAEG;AACH,MAAM,WAAW,yBAAyB,CACxC,MAAM,SAAS,SAAS,EACxB,QAAQ,SAAS,WAAW;IAE5B,8BAA8B;IAC9B,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAClC,oCAAoC;IACpC,QAAQ,EAAE,QAAQ,CAAC;IACnB,gCAAgC;IAChC,eAAe,EAAE,MAAM,MAAM,CAAC;IAC9B,+BAA+B;IAC/B,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;IACvE,iCAAiC;IACjC,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,YAAY,CAAC;IAClD,iCAAiC;IACjC,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,MAAM,KAAK,OAAO,CAAC;IACxC,6BAA6B;IAC7B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,wDAAwD;IACxD,WAAW,EAAE,MAAM,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC;IAC1D,2CAA2C;IAC3C,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAC3D,4DAA4D;IAC5D,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IAC3C,8BAA8B;IAC9B,YAAY,EAAE,MAAM,OAAO,CAAC;CAC7B;AA2CD;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,SAAS,SAAS,EACxB,QAAQ,SAAS,WAAW,EAC5B,OAAO,EAAE,yBAAyB,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,CAwI5E"}
|
package/dist/dev.d.ts
CHANGED
|
@@ -127,14 +127,4 @@ export declare namespace dev {
|
|
|
127
127
|
*/
|
|
128
128
|
function assert(condition: boolean, message: string): void;
|
|
129
129
|
}
|
|
130
|
-
/** @deprecated Use `dev.log()` instead */
|
|
131
|
-
export declare function devLog(message: string, ...args: any[]): void;
|
|
132
|
-
/** @deprecated Use `dev.warn()` instead */
|
|
133
|
-
export declare function devWarn(message: string, ...args: any[]): void;
|
|
134
|
-
/** @deprecated Use `dev.error()` instead */
|
|
135
|
-
export declare function devError(message: string, ...args: any[]): void;
|
|
136
|
-
/** @deprecated Use `dev()` with a function argument instead */
|
|
137
|
-
export declare function devOnly(fn: () => void): void;
|
|
138
|
-
/** @deprecated Use `dev.assert()` instead */
|
|
139
|
-
export declare function devAssert(condition: boolean, message: string): void;
|
|
140
130
|
//# sourceMappingURL=dev.d.ts.map
|
package/dist/dev.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAmCH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,GAAG,CAAC,EAAE,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAW5C;AAED;;GAEG;AACH,yBAAiB,GAAG,CAAC;IACnB;;;;;;;;;;;;;OAaG;IACH,SAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAIzD;IAED;;;;;;;;;;;;;OAaG;IACH,SAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAI1D;IAED;;;;;;;;;;;;;OAaG;IACH,SAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAI3D;IAED;;;;;;;;;;;;;OAaG;IACH,SAAgB,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAMhE;CACF"}
|