@createstore/createstore 1.1.0 → 1.1.2
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 +10 -0
- package/dist/cjs/createStore.cjs +32 -2
- package/dist/cjs/createStore.cjs.map +1 -1
- package/dist/esm/createStore.js +32 -2
- package/dist/esm/createStore.js.map +1 -1
- package/dist/types/createStore.d.cts +25 -4
- package/dist/types/createStore.d.ts +25 -4
- package/package.json +1 -1
|
@@ -389,14 +389,35 @@ export declare function query<T, R = T, P = undefined, A extends WhenAborted | u
|
|
|
389
389
|
* It only carries the type; nothing happens at runtime.
|
|
390
390
|
*/
|
|
391
391
|
export declare function defineEvents<E extends object>(): E;
|
|
392
|
-
type
|
|
393
|
-
type
|
|
392
|
+
type Vals = Record<string, unknown>;
|
|
393
|
+
type Layer<C, V> = {
|
|
394
|
+
[K in keyof C]: (get: StateReader<V>) => C[K];
|
|
395
|
+
};
|
|
396
|
+
type V0<S> = Values<S>;
|
|
397
|
+
type V1<S, C1> = V0<S> & C1;
|
|
398
|
+
type V2<S, C1, C2> = V1<S, C1> & C2;
|
|
399
|
+
type V3<S, C1, C2, C3> = V2<S, C1, C2> & C3;
|
|
400
|
+
type V4<S, C1, C2, C3, C4> = V3<S, C1, C2, C3> & C4;
|
|
401
|
+
type V5<S, C1, C2, C3, C4, C5> = V4<S, C1, C2, C3, C4> & C5;
|
|
402
|
+
type V6<S, C1, C2, C3, C4, C5, C6> = V5<S, C1, C2, C3, C4, C5> & C6;
|
|
403
|
+
type V7<S, C1, C2, C3, C4, C5, C6, C7> = V6<S, C1, C2, C3, C4, C5, C6> & C7;
|
|
404
|
+
type T1<S, C1> = [Layer<C1, V0<S>>];
|
|
405
|
+
type T2<S, C1, C2> = [...T1<S, C1>, Layer<C2, V1<S, C1>>];
|
|
406
|
+
type T3<S, C1, C2, C3> = [...T2<S, C1, C2>, Layer<C3, V2<S, C1, C2>>];
|
|
407
|
+
type T4<S, C1, C2, C3, C4> = [...T3<S, C1, C2, C3>, Layer<C4, V3<S, C1, C2, C3>>];
|
|
408
|
+
type T5<S, C1, C2, C3, C4, C5> = [...T4<S, C1, C2, C3, C4>, Layer<C5, V4<S, C1, C2, C3, C4>>];
|
|
409
|
+
type T6<S, C1, C2, C3, C4, C5, C6> = [...T5<S, C1, C2, C3, C4, C5>, Layer<C6, V5<S, C1, C2, C3, C4, C5>>];
|
|
410
|
+
type T7<S, C1, C2, C3, C4, C5, C6, C7> = [...T6<S, C1, C2, C3, C4, C5, C6>, Layer<C7, V6<S, C1, C2, C3, C4, C5, C6>>];
|
|
411
|
+
type T8<S, C1, C2, C3, C4, C5, C6, C7, C8> = [...T7<S, C1, C2, C3, C4, C5, C6, C7>, Layer<C8, V7<S, C1, C2, C3, C4, C5, C6, C7>>];
|
|
412
|
+
type ComputedOption<S, C1, C2, C3, C4, C5, C6, C7, C8> = T1<S, C1> | T2<S, C1, C2> | T3<S, C1, C2, C3> | T4<S, C1, C2, C3, C4> | T5<S, C1, C2, C3, C4, C5> | T6<S, C1, C2, C3, C4, C5, C6> | T7<S, C1, C2, C3, C4, C5, C6, C7> | T8<S, C1, C2, C3, C4, C5, C6, C7, C8>;
|
|
413
|
+
type Added<C> = string extends keyof C ? NoKeys : C;
|
|
414
|
+
type AllComputed<C1, C2, C3, C4, C5, C6, C7, C8> = Added<C1> & Added<C2> & Added<C3> & Added<C4> & Added<C5> & Added<C6> & Added<C7> & Added<C8>;
|
|
394
415
|
/**
|
|
395
416
|
* `computed` is a list of layers (up to 8). A layer's functions can read state and every
|
|
396
417
|
* earlier layer, so a value that reads another computed value goes in a later layer.
|
|
397
418
|
*/
|
|
398
|
-
export declare function createStore<S extends object, C1 extends
|
|
399
|
-
computed?:
|
|
419
|
+
export declare function createStore<S extends object, C1 extends Vals, C2 extends Vals, C3 extends Vals, C4 extends Vals, C5 extends Vals, C6 extends Vals, C7 extends Vals, C8 extends Vals, KA extends KeyActionsMap<S> & NoExtraKeys<KA, S>, A extends Record<string, (...args: never[]) => unknown> = NoKeys, E extends object = AnyEvents>(initialState: S, options?: StoreOptions<S, A, KA, E> & {
|
|
420
|
+
computed?: ComputedOption<S, C1, C2, C3, C4, C5, C6, C7, C8>;
|
|
400
421
|
}): Store<S, A, KA, AllComputed<C1, C2, C3, C4, C5, C6, C7, C8>, E> & ScopeApi<S, Store<S, A, KA, AllComputed<C1, C2, C3, C4, C5, C6, C7, C8>, E>>;
|
|
401
422
|
/**
|
|
402
423
|
* What `snapshot()` returns and `hydrate()` takes: plain values of state keys, plus `$queries`,
|
|
@@ -389,14 +389,35 @@ export declare function query<T, R = T, P = undefined, A extends WhenAborted | u
|
|
|
389
389
|
* It only carries the type; nothing happens at runtime.
|
|
390
390
|
*/
|
|
391
391
|
export declare function defineEvents<E extends object>(): E;
|
|
392
|
-
type
|
|
393
|
-
type
|
|
392
|
+
type Vals = Record<string, unknown>;
|
|
393
|
+
type Layer<C, V> = {
|
|
394
|
+
[K in keyof C]: (get: StateReader<V>) => C[K];
|
|
395
|
+
};
|
|
396
|
+
type V0<S> = Values<S>;
|
|
397
|
+
type V1<S, C1> = V0<S> & C1;
|
|
398
|
+
type V2<S, C1, C2> = V1<S, C1> & C2;
|
|
399
|
+
type V3<S, C1, C2, C3> = V2<S, C1, C2> & C3;
|
|
400
|
+
type V4<S, C1, C2, C3, C4> = V3<S, C1, C2, C3> & C4;
|
|
401
|
+
type V5<S, C1, C2, C3, C4, C5> = V4<S, C1, C2, C3, C4> & C5;
|
|
402
|
+
type V6<S, C1, C2, C3, C4, C5, C6> = V5<S, C1, C2, C3, C4, C5> & C6;
|
|
403
|
+
type V7<S, C1, C2, C3, C4, C5, C6, C7> = V6<S, C1, C2, C3, C4, C5, C6> & C7;
|
|
404
|
+
type T1<S, C1> = [Layer<C1, V0<S>>];
|
|
405
|
+
type T2<S, C1, C2> = [...T1<S, C1>, Layer<C2, V1<S, C1>>];
|
|
406
|
+
type T3<S, C1, C2, C3> = [...T2<S, C1, C2>, Layer<C3, V2<S, C1, C2>>];
|
|
407
|
+
type T4<S, C1, C2, C3, C4> = [...T3<S, C1, C2, C3>, Layer<C4, V3<S, C1, C2, C3>>];
|
|
408
|
+
type T5<S, C1, C2, C3, C4, C5> = [...T4<S, C1, C2, C3, C4>, Layer<C5, V4<S, C1, C2, C3, C4>>];
|
|
409
|
+
type T6<S, C1, C2, C3, C4, C5, C6> = [...T5<S, C1, C2, C3, C4, C5>, Layer<C6, V5<S, C1, C2, C3, C4, C5>>];
|
|
410
|
+
type T7<S, C1, C2, C3, C4, C5, C6, C7> = [...T6<S, C1, C2, C3, C4, C5, C6>, Layer<C7, V6<S, C1, C2, C3, C4, C5, C6>>];
|
|
411
|
+
type T8<S, C1, C2, C3, C4, C5, C6, C7, C8> = [...T7<S, C1, C2, C3, C4, C5, C6, C7>, Layer<C8, V7<S, C1, C2, C3, C4, C5, C6, C7>>];
|
|
412
|
+
type ComputedOption<S, C1, C2, C3, C4, C5, C6, C7, C8> = T1<S, C1> | T2<S, C1, C2> | T3<S, C1, C2, C3> | T4<S, C1, C2, C3, C4> | T5<S, C1, C2, C3, C4, C5> | T6<S, C1, C2, C3, C4, C5, C6> | T7<S, C1, C2, C3, C4, C5, C6, C7> | T8<S, C1, C2, C3, C4, C5, C6, C7, C8>;
|
|
413
|
+
type Added<C> = string extends keyof C ? NoKeys : C;
|
|
414
|
+
type AllComputed<C1, C2, C3, C4, C5, C6, C7, C8> = Added<C1> & Added<C2> & Added<C3> & Added<C4> & Added<C5> & Added<C6> & Added<C7> & Added<C8>;
|
|
394
415
|
/**
|
|
395
416
|
* `computed` is a list of layers (up to 8). A layer's functions can read state and every
|
|
396
417
|
* earlier layer, so a value that reads another computed value goes in a later layer.
|
|
397
418
|
*/
|
|
398
|
-
export declare function createStore<S extends object, C1 extends
|
|
399
|
-
computed?:
|
|
419
|
+
export declare function createStore<S extends object, C1 extends Vals, C2 extends Vals, C3 extends Vals, C4 extends Vals, C5 extends Vals, C6 extends Vals, C7 extends Vals, C8 extends Vals, KA extends KeyActionsMap<S> & NoExtraKeys<KA, S>, A extends Record<string, (...args: never[]) => unknown> = NoKeys, E extends object = AnyEvents>(initialState: S, options?: StoreOptions<S, A, KA, E> & {
|
|
420
|
+
computed?: ComputedOption<S, C1, C2, C3, C4, C5, C6, C7, C8>;
|
|
400
421
|
}): Store<S, A, KA, AllComputed<C1, C2, C3, C4, C5, C6, C7, C8>, E> & ScopeApi<S, Store<S, A, KA, AllComputed<C1, C2, C3, C4, C5, C6, C7, C8>, E>>;
|
|
401
422
|
/**
|
|
402
423
|
* What `snapshot()` returns and `hydrate()` takes: plain values of state keys, plus `$queries`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@createstore/createstore",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Global state that works like useState: no provider, no reducers. Optional queries, persist, offline, history, tab sync and server rendering.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Gaurav Asawa",
|