valdres 0.2.0-alpha.7 → 0.2.0-alpha.8
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/dist/index.d.ts +21 -0
- package/dist/src/atom.d.ts +8 -0
- package/dist/src/atomFamily.d.ts +4 -0
- package/dist/src/createStore.d.ts +2 -0
- package/dist/src/createStoreWithSelectorSet.d.ts +2 -0
- package/dist/src/getDefaultStore.d.ts +2 -0
- package/dist/src/lib/createStoreData.d.ts +2 -0
- package/dist/src/lib/getState.d.ts +7 -0
- package/dist/src/lib/initAtom.d.ts +4 -0
- package/dist/src/lib/initSelector.d.ts +4 -0
- package/dist/src/lib/propagateUpdatedAtoms.d.ts +3 -0
- package/dist/src/lib/resetAtom.d.ts +3 -0
- package/dist/src/lib/setAtom.d.ts +3 -0
- package/dist/src/lib/setAtoms.d.ts +3 -0
- package/dist/src/lib/stableStringify.d.ts +1 -0
- package/dist/src/lib/storeFromStoreData.d.ts +3 -0
- package/dist/src/lib/subscribe.d.ts +4 -0
- package/dist/src/lib/transaction.d.ts +9 -0
- package/dist/src/lib/unsubscribe.d.ts +5 -0
- package/dist/src/lib/updateSelectorSubscribers.d.ts +3 -0
- package/dist/src/lib/updateStateSubscribers.d.ts +3 -0
- package/dist/src/selector.d.ts +3 -0
- package/dist/src/selectorFamily.d.ts +2 -0
- package/dist/src/types/Atom.d.ts +9 -0
- package/dist/src/types/AtomFamily.d.ts +5 -0
- package/dist/src/types/Family.d.ts +3 -0
- package/dist/src/types/GetValue.d.ts +8 -0
- package/dist/src/types/ResetAtom.d.ts +2 -0
- package/dist/src/types/Selector.d.ts +9 -0
- package/dist/src/types/SelectorFamily.d.ts +5 -0
- package/dist/src/types/SetAtom.d.ts +3 -0
- package/dist/src/types/SetAtomValue.d.ts +1 -0
- package/dist/src/types/State.d.ts +3 -0
- package/dist/src/types/Store.d.ts +14 -0
- package/dist/src/types/StoreData.d.ts +9 -0
- package/dist/src/types/SubscribeFn.d.ts +2 -0
- package/dist/src/types/Subscription.d.ts +1 -0
- package/dist/src/types/TransactionFn.d.ts +4 -0
- package/dist/src/utils/isAtom.d.ts +2 -0
- package/dist/src/utils/isFamily.d.ts +1 -0
- package/dist/src/utils/isPromiseLike.d.ts +1 -0
- package/dist/src/utils/isSelector.d.ts +2 -0
- package/package.json +2 -2
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { atom } from "./src/atom";
|
|
2
|
+
export { atomFamily } from "./src/atomFamily";
|
|
3
|
+
export { createStore } from "./src/createStore";
|
|
4
|
+
export { createStoreWithSelectorSet } from "./src/createStoreWithSelectorSet";
|
|
5
|
+
export { getDefaultStore, resetDefaultStore } from "./src/getDefaultStore";
|
|
6
|
+
export { selector } from "./src/selector";
|
|
7
|
+
export { selectorFamily } from "./src/selectorFamily";
|
|
8
|
+
export { isAtom } from "./src/utils/isAtom";
|
|
9
|
+
export { isSelector } from "./src/utils/isSelector";
|
|
10
|
+
export { isFamily } from "./src/utils/isFamily";
|
|
11
|
+
export { isPromiseLike } from "./src/utils/isPromiseLike";
|
|
12
|
+
export type { Atom } from "./src/types/Atom";
|
|
13
|
+
export type { AtomFamily } from "./src/types/AtomFamily";
|
|
14
|
+
export type { GetValue } from "./src/types/GetValue";
|
|
15
|
+
export type { Selector } from "./src/types/Selector";
|
|
16
|
+
export type { SelectorFamily } from "./src/types/SelectorFamily";
|
|
17
|
+
export type { SetAtom } from "./src/types/SetAtom";
|
|
18
|
+
export type { SetAtomValue } from "./src/types/SetAtomValue";
|
|
19
|
+
export type { State } from "./src/types/State";
|
|
20
|
+
export type { Store } from "./src/types/Store";
|
|
21
|
+
export type { StoreData } from "./src/types/StoreData";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Atom } from "./types/Atom";
|
|
2
|
+
type AtomOptions<Value> = {
|
|
3
|
+
label?: string;
|
|
4
|
+
onInit?: (setSelf: (value: Value) => void) => void;
|
|
5
|
+
onMount?: () => () => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const atom: <Value, FamilyKey = undefined>(defaultValue?: Value | (() => Value | Promise<Value>), options?: AtomOptions<Value>) => Atom<Value, FamilyKey>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AtomFamily } from "./types/AtomFamily";
|
|
2
|
+
type DefaultValueCallback<Key, Value> = (arg: Key) => Value | Promise<Value>;
|
|
3
|
+
export declare const atomFamily: <Value = unknown, Key = unknown>(defaultValue?: Value | DefaultValueCallback<Key, Value>, debugLabel?: string) => AtomFamily<Value, Key>;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { StoreData } from "../types/StoreData";
|
|
2
|
+
import type { Atom } from "../types/Atom";
|
|
3
|
+
import type { AtomFamily } from "../types/AtomFamily";
|
|
4
|
+
import type { Selector } from "../types/Selector";
|
|
5
|
+
export declare function getState<V, K>(atom: Atom<V>, data: StoreData): V;
|
|
6
|
+
export declare function getState<V, K>(selector: Selector<V>, data: StoreData): V;
|
|
7
|
+
export declare function getState<V, K>(family: AtomFamily<V, K>, data: StoreData): K[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { StoreData } from "../types/StoreData";
|
|
2
|
+
import type { Selector } from "../types/Selector";
|
|
3
|
+
export declare const reEvaluateSelector: <V>(selector: Selector<V>, data: StoreData) => void;
|
|
4
|
+
export declare const initSelector: <V>(selector: Selector<V>, data: StoreData) => V | Promise<V>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const stableStringify: (x: any) => string | number | boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Family } from "../types/Family";
|
|
2
|
+
import type { State } from "../types/State";
|
|
3
|
+
import type { StoreData } from "../types/StoreData";
|
|
4
|
+
export declare const subscribe: <V>(state: State<V> | Family<V>, callback: any, requireDeepEqualCheckBeforeCallback: boolean, data: StoreData) => () => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { State } from "../types/State";
|
|
2
|
+
import type { StoreData } from "../types/StoreData";
|
|
3
|
+
import type { Atom } from "../types/Atom";
|
|
4
|
+
type GetValdresValue = <V>(state: State<V>) => V;
|
|
5
|
+
type SetValdresValue = <V>(state: State<V>, value: V) => void;
|
|
6
|
+
type ResetValdresValue = <V>(atom: Atom<V>) => V;
|
|
7
|
+
type TransactionInterface = (set: SetValdresValue, get: GetValdresValue, reset: ResetValdresValue, commit: () => void) => void;
|
|
8
|
+
export declare const transaction: (callback: TransactionInterface, data: StoreData) => void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Family } from "../types/Family";
|
|
2
|
+
import type { State } from "../types/State";
|
|
3
|
+
import type { StoreData } from "../types/StoreData";
|
|
4
|
+
import type { Subscription } from "../types/Subscription";
|
|
5
|
+
export declare const unsubscribe: <V>(state: State<V> | Family<V>, subscription: Subscription, data: StoreData, mount?: any) => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AtomFamily } from "./AtomFamily";
|
|
2
|
+
export type Atom<Value = unknown, FamilyKey = undefined> = {
|
|
3
|
+
defaultValue?: Value | (() => Value | Promise<Value>);
|
|
4
|
+
label?: string;
|
|
5
|
+
family?: AtomFamily<Value, FamilyKey>;
|
|
6
|
+
familyKey?: FamilyKey;
|
|
7
|
+
onInit?: (setSelf: (value: Value) => void) => void;
|
|
8
|
+
onMount?: () => void | (() => void);
|
|
9
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Atom } from "./Atom";
|
|
2
|
+
import type { AtomFamily } from "./AtomFamily";
|
|
3
|
+
import type { Selector } from "./Selector";
|
|
4
|
+
export type GetValue = {
|
|
5
|
+
<V, K>(atom: Atom<V>): V;
|
|
6
|
+
<V, K>(selector: Selector<V>): V;
|
|
7
|
+
<V, K>(family: AtomFamily<V, K>): K[];
|
|
8
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GetValue } from "./GetValue";
|
|
2
|
+
import type { SelectorFamily } from "./SelectorFamily";
|
|
3
|
+
export type Selector<Value = unknown, FamilyKey = undefined> = {
|
|
4
|
+
get: (get: GetValue) => Value;
|
|
5
|
+
debugLabel?: string;
|
|
6
|
+
family?: SelectorFamily<Value, FamilyKey>;
|
|
7
|
+
familyKey?: FamilyKey;
|
|
8
|
+
onMount?: () => void | (() => void);
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type SetAtomValue<V> = V | ((current: V) => V);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { GetValue } from "./GetValue";
|
|
2
|
+
import type { ResetAtom } from "./ResetAtom";
|
|
3
|
+
import type { SetAtom } from "./SetAtom";
|
|
4
|
+
import type { StoreData } from "./StoreData";
|
|
5
|
+
import type { SubscribeFn } from "./SubscribeFn";
|
|
6
|
+
import type { TransactionFn } from "./TransactionFn";
|
|
7
|
+
export type Store = {
|
|
8
|
+
data: StoreData;
|
|
9
|
+
get: GetValue;
|
|
10
|
+
set: SetAtom;
|
|
11
|
+
sub: SubscribeFn;
|
|
12
|
+
reset: ResetAtom;
|
|
13
|
+
txn: (callback: TransactionFn) => void;
|
|
14
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type StoreData = {
|
|
2
|
+
id: string;
|
|
3
|
+
values: WeakMap<WeakKey, any>;
|
|
4
|
+
expiredValues: WeakMap<WeakKey, any>;
|
|
5
|
+
subscriptions: WeakMap<WeakKey, Set<any>>;
|
|
6
|
+
subscriptionsRequireEqualCheck: WeakMap<WeakKey, boolean>;
|
|
7
|
+
stateConsumers: WeakMap<WeakKey, any>;
|
|
8
|
+
stateDependencies: WeakMap<WeakKey, any>;
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Subscription = {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isFamily: (state: any) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isPromiseLike: <T>(object: any) => object is Promise<T>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valdres",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Eigil Sagafos"
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"access": "public",
|
|
40
40
|
"registry": "https://registry.npmjs.org/"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "c7f6e2d76adc15985444d02244522841d52aa233"
|
|
43
43
|
}
|