atom.io 0.2.0 → 0.3.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/README.md +6 -11
- package/dist/index.d.ts +505 -4
- package/dist/index.js +823 -360
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +813 -356
- package/dist/index.mjs.map +1 -1
- package/package.json +23 -5
- package/{dist/react → react/dist}/index.d.ts +2 -5
- package/react/dist/index.js +68 -0
- package/react/dist/index.js.map +1 -0
- package/react/dist/index.mjs +44 -0
- package/react/dist/index.mjs.map +1 -0
- package/react/package.json +12 -3
- package/src/atom.ts +18 -53
- package/src/index.ts +23 -37
- package/src/internal/atom-internal.ts +50 -0
- package/src/internal/families-internal.ts +142 -0
- package/src/internal/get.ts +40 -42
- package/src/internal/index.ts +6 -17
- package/src/internal/is-default.ts +20 -4
- package/src/internal/logger.ts +46 -0
- package/src/internal/operation.ts +97 -14
- package/src/internal/selector-internal.ts +113 -13
- package/src/internal/set.ts +31 -17
- package/src/internal/store.ts +58 -45
- package/src/internal/subscribe-internal.ts +55 -11
- package/src/internal/timeline-internal.ts +196 -0
- package/src/internal/transaction-internal.ts +157 -16
- package/src/react/index.ts +5 -6
- package/src/selector.ts +29 -99
- package/src/subscribe.ts +55 -0
- package/src/timeline.ts +34 -0
- package/src/transaction.ts +22 -34
- package/dist/index-9d9f5a05.d.ts +0 -293
- package/dist/react/index.js +0 -909
- package/dist/react/index.js.map +0 -1
- package/dist/react/index.mjs +0 -880
- package/dist/react/index.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
- [x] implicit store
|
|
4
4
|
- [x] readonly selectors
|
|
5
5
|
- [x] settable selectors
|
|
6
|
-
- [x] safe recursive update propagation
|
|
7
6
|
- [x] "tokens" safely expose atoms and selectors
|
|
8
7
|
- [x] give atoms and selectors separate types with a common base
|
|
9
8
|
- [x] utility function to pass logger to your store
|
|
@@ -11,25 +10,21 @@
|
|
|
11
10
|
- [x] atom and selector families
|
|
12
11
|
- [x] atom effects
|
|
13
12
|
- [x] transactions
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
# atom.io
|
|
17
|
-
## upcoming features
|
|
18
|
-
- [x] "lazy mode": only propagate updates downstream to selectors with an active subscription
|
|
19
13
|
- [x] async effects
|
|
20
14
|
- [x] atom default as function
|
|
21
15
|
- [x] check whether an atom is "default" (never set)
|
|
16
|
+
- [x] customizable logging
|
|
17
|
+
|
|
18
|
+
# atom.io
|
|
19
|
+
## upcoming features
|
|
20
|
+
- [ ] subscribe to token creation
|
|
21
|
+
- [ ] subscribe to transactions
|
|
22
22
|
- [ ] timelines
|
|
23
23
|
- [ ] resettable atoms
|
|
24
24
|
- [ ] resettable selectors
|
|
25
|
-
- [ ] subscribe to transactions
|
|
26
|
-
- [ ] subscribe to token creation
|
|
27
|
-
- [ ] logging levels (debug, info, warn, error)
|
|
28
25
|
- [ ] store observation api
|
|
29
26
|
|
|
30
27
|
## fixes & improvements
|
|
31
|
-
- [x] refactor selector dependencies to be asymmetrical
|
|
32
|
-
- [ ] tokens explicitly contain the key of their family
|
|
33
28
|
- [ ] apply and emit transactions all at once
|
|
34
29
|
|
|
35
30
|
## documentation
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,505 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
4
|
-
|
|
1
|
+
import * as Rx from 'rxjs';
|
|
2
|
+
import { Hamt } from 'hamt_plus';
|
|
3
|
+
import { Refinement } from 'fp-ts/Refinement';
|
|
4
|
+
|
|
5
|
+
type Primitive = boolean | number | string | null;
|
|
6
|
+
type Serializable = Primitive | Readonly<{
|
|
7
|
+
[key: string]: Serializable;
|
|
8
|
+
}> | ReadonlyArray<Serializable>;
|
|
9
|
+
type JsonObj<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
|
|
10
|
+
type JsonArr<Element extends Serializable = Serializable> = ReadonlyArray<Element>;
|
|
11
|
+
type Json = JsonArr | JsonObj | Primitive;
|
|
12
|
+
|
|
13
|
+
type Identified = {
|
|
14
|
+
id: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
declare const RELATION_TYPES: readonly ["1:1", "1:n", "n:n"];
|
|
18
|
+
type RelationType = (typeof RELATION_TYPES)[number];
|
|
19
|
+
type RelationData<CONTENT extends JsonObj | null = null> = {
|
|
20
|
+
contents: JsonObj<string, CONTENT>;
|
|
21
|
+
relations: JsonObj<string, string[]>;
|
|
22
|
+
relationType: RelationType;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type NullSafeUnion<Base, Extension> = Extension extends null ? Base : Base & Extension;
|
|
26
|
+
type NullSafeRest<MaybeArg> = MaybeArg extends null ? [] | [undefined] : [MaybeArg];
|
|
27
|
+
|
|
28
|
+
declare class Join<CONTENT extends JsonObj | null = null> implements RelationData<CONTENT> {
|
|
29
|
+
readonly relationType: `1:1` | `1:n` | `n:n`;
|
|
30
|
+
readonly relations: Record<string, string[]>;
|
|
31
|
+
readonly contents: Record<string, CONTENT>;
|
|
32
|
+
constructor(json?: Partial<RelationData<CONTENT>>);
|
|
33
|
+
toJSON(): RelationData<CONTENT>;
|
|
34
|
+
static fromJSON<CONTENT extends JsonObj | null = null>(json: Json, isContent?: Refinement<unknown, CONTENT>): Join<CONTENT>;
|
|
35
|
+
getRelatedId(id: string): string | undefined;
|
|
36
|
+
getRelatedIds(id: string): string[];
|
|
37
|
+
getContent(idA: string, idB: string): CONTENT | undefined;
|
|
38
|
+
getRelationEntries(id: string): [string, CONTENT][];
|
|
39
|
+
getRelationRecord(id: string): Record<string, CONTENT>;
|
|
40
|
+
getRelation(id: string): NullSafeUnion<Identified, CONTENT> | undefined;
|
|
41
|
+
getRelations(id: string): NullSafeUnion<Identified, CONTENT>[];
|
|
42
|
+
setRelations(id: string, relations: NullSafeUnion<Identified, CONTENT>[]): Join<CONTENT>;
|
|
43
|
+
set(idA: string, idB: string, ...rest: NullSafeRest<CONTENT>): Join<CONTENT>;
|
|
44
|
+
remove(idA: string, idB?: string): Join<CONTENT>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
type StoreCore = Pick<Store, `atoms` | `atomsThatAreDefault` | `operation` | `readonlySelectors` | `selectorAtoms` | `selectorGraph` | `selectors` | `timelineAtoms` | `timelines` | `transactions` | `valueMap`>;
|
|
48
|
+
interface Store {
|
|
49
|
+
atoms: Hamt<Atom<any>, string>;
|
|
50
|
+
atomsThatAreDefault: Set<string>;
|
|
51
|
+
readonlySelectors: Hamt<ReadonlySelector<any>, string>;
|
|
52
|
+
selectorAtoms: Join;
|
|
53
|
+
selectorGraph: Join<{
|
|
54
|
+
source: string;
|
|
55
|
+
}>;
|
|
56
|
+
selectors: Hamt<Selector<any>, string>;
|
|
57
|
+
timelines: Hamt<Timeline, string>;
|
|
58
|
+
timelineAtoms: Join;
|
|
59
|
+
timelineStore: Hamt<TimelineData, string>;
|
|
60
|
+
transactions: Hamt<Transaction<any>, string>;
|
|
61
|
+
valueMap: Hamt<any, string>;
|
|
62
|
+
operation: OperationProgress;
|
|
63
|
+
transactionStatus: TransactionStatus<ƒn>;
|
|
64
|
+
config: {
|
|
65
|
+
name: string;
|
|
66
|
+
logger: Logger | null;
|
|
67
|
+
logger__INTERNAL: Logger;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
declare const createStore: (name: string) => Store;
|
|
71
|
+
declare const IMPLICIT: {
|
|
72
|
+
STORE_INTERNAL: Store | undefined;
|
|
73
|
+
readonly STORE: Store;
|
|
74
|
+
};
|
|
75
|
+
declare const clearStore: (store?: Store) => void;
|
|
76
|
+
|
|
77
|
+
type Effectors<T> = {
|
|
78
|
+
setSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void;
|
|
79
|
+
onSet: (callback: (options: {
|
|
80
|
+
newValue: T;
|
|
81
|
+
oldValue: T;
|
|
82
|
+
}) => void) => void;
|
|
83
|
+
};
|
|
84
|
+
type AtomEffect<T> = (tools: Effectors<T>) => void;
|
|
85
|
+
type AtomOptions<T> = {
|
|
86
|
+
key: string;
|
|
87
|
+
default: T | (() => T);
|
|
88
|
+
effects?: AtomEffect<T>[];
|
|
89
|
+
};
|
|
90
|
+
declare function atom<T>(options: AtomOptions<T>): AtomToken<T>;
|
|
91
|
+
type AtomFamilyOptions<T, K extends Serializable> = {
|
|
92
|
+
key: string;
|
|
93
|
+
default: T | ((key: K) => T);
|
|
94
|
+
effects?: (key: K) => AtomEffect<T>[];
|
|
95
|
+
};
|
|
96
|
+
type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomToken<T>) & {
|
|
97
|
+
key: string;
|
|
98
|
+
type: `atom_family`;
|
|
99
|
+
subject: Rx.Subject<AtomToken<T>>;
|
|
100
|
+
};
|
|
101
|
+
declare function atomFamily<T, K extends Serializable>(options: AtomFamilyOptions<T, K>): AtomFamily<T, K>;
|
|
102
|
+
|
|
103
|
+
type Atom<T> = {
|
|
104
|
+
key: string;
|
|
105
|
+
type: `atom`;
|
|
106
|
+
family?: FamilyMetadata;
|
|
107
|
+
subject: Rx.Subject<{
|
|
108
|
+
newValue: T;
|
|
109
|
+
oldValue: T;
|
|
110
|
+
}>;
|
|
111
|
+
default: T;
|
|
112
|
+
};
|
|
113
|
+
declare function atom__INTERNAL<T>(options: AtomOptions<T>, family?: FamilyMetadata, store?: Store): AtomToken<T>;
|
|
114
|
+
|
|
115
|
+
declare function atomFamily__INTERNAL<T, K extends Serializable>(options: AtomFamilyOptions<T, K>, store?: Store): AtomFamily<T, K>;
|
|
116
|
+
declare function readonlySelectorFamily__INTERNAL<T, K extends Serializable>(options: SelectorFamilyOptions<T, K>, store?: Store): ReadonlySelectorFamily<T, K>;
|
|
117
|
+
declare function selectorFamily__INTERNAL<T, K extends Serializable>(options: SelectorFamilyOptions<T, K>, store?: Store): SelectorFamily<T, K>;
|
|
118
|
+
declare function selectorFamily__INTERNAL<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>, store?: Store): ReadonlySelectorFamily<T, K>;
|
|
119
|
+
|
|
120
|
+
declare const computeSelectorState: <T>(selector: ReadonlySelector<T> | Selector<T>) => T;
|
|
121
|
+
declare function lookup(key: string, store: Store): AtomToken<unknown> | ReadonlyValueToken<unknown> | SelectorToken<unknown>;
|
|
122
|
+
declare function withdraw<T>(token: AtomToken<T>, store: Store): Atom<T>;
|
|
123
|
+
declare function withdraw<T>(token: SelectorToken<T>, store: Store): Selector<T>;
|
|
124
|
+
declare function withdraw<T>(token: StateToken<T>, store: Store): Atom<T> | Selector<T>;
|
|
125
|
+
declare function withdraw<T>(token: ReadonlyValueToken<T>, store: Store): ReadonlySelector<T>;
|
|
126
|
+
declare function withdraw<T>(token: TransactionToken<T>, store: Store): Transaction<T extends ƒn ? T : never>;
|
|
127
|
+
declare function withdraw<T>(token: ReadonlyValueToken<T> | StateToken<T>, store: Store): Atom<T> | ReadonlySelector<T> | Selector<T>;
|
|
128
|
+
declare function deposit<T>(state: Atom<T>): AtomToken<T>;
|
|
129
|
+
declare function deposit<T>(state: Selector<T>): SelectorToken<T>;
|
|
130
|
+
declare function deposit<T>(state: Atom<T> | Selector<T>): StateToken<T>;
|
|
131
|
+
declare function deposit<T>(state: ReadonlySelector<T>): ReadonlyValueToken<T>;
|
|
132
|
+
declare function deposit<T>(state: Transaction<T extends ƒn ? T : never>): TransactionToken<T>;
|
|
133
|
+
declare function deposit<T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>): ReadonlyValueToken<T> | StateToken<T>;
|
|
134
|
+
declare const getState__INTERNAL: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, store?: Store) => T;
|
|
135
|
+
|
|
136
|
+
declare const isAtomDefault: (key: string, store?: Store) => boolean;
|
|
137
|
+
declare const markAtomAsDefault: (key: string, store?: Store) => void;
|
|
138
|
+
declare const markAtomAsNotDefault: (key: string, store?: Store) => void;
|
|
139
|
+
declare const isSelectorDefault: (key: string, store?: Store) => boolean;
|
|
140
|
+
|
|
141
|
+
type Logger = Pick<Console, `error` | `info` | `warn`>;
|
|
142
|
+
declare const LOG_LEVELS: ReadonlyArray<keyof Logger>;
|
|
143
|
+
declare const setLogLevel: (preferredLevel: `error` | `info` | `warn` | null, store?: Store) => void;
|
|
144
|
+
declare const useLogger: (logger: Logger, store?: Store) => void;
|
|
145
|
+
|
|
146
|
+
type OperationProgress = {
|
|
147
|
+
open: false;
|
|
148
|
+
} | {
|
|
149
|
+
open: true;
|
|
150
|
+
done: Set<string>;
|
|
151
|
+
prev: Hamt<any, string>;
|
|
152
|
+
};
|
|
153
|
+
declare const openOperation: (store: Store) => void;
|
|
154
|
+
declare const closeOperation: (store: Store) => void;
|
|
155
|
+
declare const isDone: (key: string, store?: Store) => boolean;
|
|
156
|
+
declare const markDone: (key: string, store?: Store) => void;
|
|
157
|
+
declare const recallState: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, store?: Store) => T;
|
|
158
|
+
declare const cacheValue: (key: string, value: unknown, store?: Store) => void;
|
|
159
|
+
declare const evictCachedValue: (key: string, store?: Store) => void;
|
|
160
|
+
declare const readCachedValue: <T>(key: string, store?: Store) => T;
|
|
161
|
+
declare const isValueCached: (key: string, store?: Store) => boolean;
|
|
162
|
+
declare const storeAtom: (atom: Atom<any>, store?: Store) => void;
|
|
163
|
+
declare const storeSelector: (selector: Selector<any>, store?: Store) => void;
|
|
164
|
+
declare const storeReadonlySelector: (selector: ReadonlySelector<any>, store?: Store) => void;
|
|
165
|
+
declare const hasKeyBeenUsed: (key: string, store?: Store) => boolean;
|
|
166
|
+
|
|
167
|
+
type ƒn = (...parameters: any[]) => any;
|
|
168
|
+
type Transactors = {
|
|
169
|
+
get: <S>(state: ReadonlyValueToken<S> | StateToken<S>) => S;
|
|
170
|
+
set: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void;
|
|
171
|
+
};
|
|
172
|
+
type ReadonlyTransactors = Pick<Transactors, `get`>;
|
|
173
|
+
type Action<ƒ extends ƒn> = (transactors: Transactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
174
|
+
type TransactionOptions<ƒ extends ƒn> = {
|
|
175
|
+
key: string;
|
|
176
|
+
do: Action<ƒ>;
|
|
177
|
+
};
|
|
178
|
+
type Transaction<ƒ extends ƒn> = {
|
|
179
|
+
key: string;
|
|
180
|
+
type: `transaction`;
|
|
181
|
+
run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
182
|
+
subject: Rx.Subject<TransactionUpdate<ƒ>>;
|
|
183
|
+
};
|
|
184
|
+
declare function transaction<ƒ extends ƒn>(options: TransactionOptions<ƒ>): TransactionToken<ƒ>;
|
|
185
|
+
declare const runTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, store?: Store) => (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
186
|
+
|
|
187
|
+
type Selector<T> = {
|
|
188
|
+
key: string;
|
|
189
|
+
type: `selector`;
|
|
190
|
+
family?: FamilyMetadata;
|
|
191
|
+
subject: Rx.Subject<{
|
|
192
|
+
newValue: T;
|
|
193
|
+
oldValue: T;
|
|
194
|
+
}>;
|
|
195
|
+
get: () => T;
|
|
196
|
+
set: (newValue: T | ((oldValue: T) => T)) => void;
|
|
197
|
+
};
|
|
198
|
+
type ReadonlySelector<T> = {
|
|
199
|
+
key: string;
|
|
200
|
+
type: `readonly_selector`;
|
|
201
|
+
family?: FamilyMetadata;
|
|
202
|
+
subject: Rx.Subject<{
|
|
203
|
+
newValue: T;
|
|
204
|
+
oldValue: T;
|
|
205
|
+
}>;
|
|
206
|
+
get: () => T;
|
|
207
|
+
};
|
|
208
|
+
declare const lookupSelectorSources: (key: string, store: Store) => (AtomToken<unknown> | ReadonlyValueToken<unknown> | SelectorToken<unknown>)[];
|
|
209
|
+
declare const traceSelectorAtoms: (selectorKey: string, dependency: ReadonlyValueToken<unknown> | StateToken<unknown>, store: Store) => AtomToken<unknown>[];
|
|
210
|
+
declare const traceAllSelectorAtoms: (selectorKey: string, store: Store) => AtomToken<unknown>[];
|
|
211
|
+
declare const updateSelectorAtoms: (selectorKey: string, dependency: ReadonlyValueToken<unknown> | StateToken<unknown>, store: Store) => void;
|
|
212
|
+
declare const registerSelector: (selectorKey: string, store?: Store) => Transactors;
|
|
213
|
+
declare function selector__INTERNAL<T>(options: SelectorOptions<T>, family?: FamilyMetadata, store?: Store): SelectorToken<T>;
|
|
214
|
+
declare function selector__INTERNAL<T>(options: ReadonlySelectorOptions<T>, family?: FamilyMetadata, store?: Store): ReadonlyValueToken<T>;
|
|
215
|
+
|
|
216
|
+
declare const evictDownStream: <T>(state: Atom<T>, store?: Store) => void;
|
|
217
|
+
declare const setAtomState: <T>(atom: Atom<T>, next: T | ((oldValue: T) => T), store?: Store) => void;
|
|
218
|
+
declare const setSelectorState: <T>(selector: Selector<T>, next: T | ((oldValue: T) => T), store?: Store) => void;
|
|
219
|
+
declare const setState__INTERNAL: <T>(state: Atom<T> | Selector<T>, value: T | ((oldValue: T) => T), store?: Store) => void;
|
|
220
|
+
|
|
221
|
+
declare const prepareUpdate: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, store: Store) => StateUpdate<T>;
|
|
222
|
+
declare const stowUpdate: <T>(state: Atom<T>, update: StateUpdate<T>, store: Store) => void;
|
|
223
|
+
declare const emitUpdate: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, update: StateUpdate<T>, store: Store) => void;
|
|
224
|
+
declare const subscribeToRootAtoms: <T>(state: ReadonlySelector<T> | Selector<T>, store: Store) => {
|
|
225
|
+
unsubscribe: () => void;
|
|
226
|
+
}[] | null;
|
|
227
|
+
|
|
228
|
+
type Timeline = {
|
|
229
|
+
key: string;
|
|
230
|
+
type: `timeline`;
|
|
231
|
+
next: () => void;
|
|
232
|
+
prev: () => void;
|
|
233
|
+
};
|
|
234
|
+
type TimelineStateUpdate = KeyedStateUpdate<unknown> & {
|
|
235
|
+
type: `state_update`;
|
|
236
|
+
};
|
|
237
|
+
type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
|
|
238
|
+
type: `transaction_update`;
|
|
239
|
+
};
|
|
240
|
+
type TimelineData = {
|
|
241
|
+
at: number;
|
|
242
|
+
timeTraveling: boolean;
|
|
243
|
+
history: (TimelineStateUpdate | TimelineTransactionUpdate)[];
|
|
244
|
+
};
|
|
245
|
+
declare function timeline__INTERNAL(options: TimelineOptions, store?: Store): TimelineToken;
|
|
246
|
+
declare const redo__INTERNAL: (token: TimelineToken, store?: Store) => void;
|
|
247
|
+
declare const undo__INTERNAL: (token: TimelineToken, store?: Store) => void;
|
|
248
|
+
|
|
249
|
+
declare const TRANSACTION_PHASES: readonly ["idle", "building", "applying"];
|
|
250
|
+
type TransactionPhase = (typeof TRANSACTION_PHASES)[number];
|
|
251
|
+
type KeyedStateUpdate<T> = StateUpdate<T> & {
|
|
252
|
+
key: string;
|
|
253
|
+
};
|
|
254
|
+
type TransactionUpdate<ƒ extends ƒn> = {
|
|
255
|
+
key: string;
|
|
256
|
+
atomUpdates: KeyedStateUpdate<unknown>[];
|
|
257
|
+
params: Parameters<ƒ>;
|
|
258
|
+
output: ReturnType<ƒ>;
|
|
259
|
+
};
|
|
260
|
+
type TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdate<ƒ> & {
|
|
261
|
+
phase: `applying` | `building`;
|
|
262
|
+
core: StoreCore;
|
|
263
|
+
};
|
|
264
|
+
type TransactionIdle = {
|
|
265
|
+
phase: `idle`;
|
|
266
|
+
};
|
|
267
|
+
type TransactionStatus<ƒ extends ƒn> = TransactionIdle | TransactionUpdateInProgress<ƒ>;
|
|
268
|
+
declare const buildTransaction: (key: string, params: any[], store: Store) => void;
|
|
269
|
+
declare const applyTransaction: <ƒ extends ƒn>(output: ReturnType<ƒ>, store: Store) => void;
|
|
270
|
+
declare const undoTransactionUpdate: <ƒ extends ƒn>(update: TransactionUpdate<ƒ>, store: Store) => void;
|
|
271
|
+
declare const redoTransactionUpdate: <ƒ extends ƒn>(update: TransactionUpdate<ƒ>, store: Store) => void;
|
|
272
|
+
declare const abortTransaction: (store: Store) => void;
|
|
273
|
+
declare function transaction__INTERNAL<ƒ extends ƒn>(options: TransactionOptions<ƒ>, store?: Store): TransactionToken<ƒ>;
|
|
274
|
+
declare const target: (store?: Store) => StoreCore;
|
|
275
|
+
|
|
276
|
+
type index_Atom<T> = Atom<T>;
|
|
277
|
+
declare const index_IMPLICIT: typeof IMPLICIT;
|
|
278
|
+
type index_KeyedStateUpdate<T> = KeyedStateUpdate<T>;
|
|
279
|
+
declare const index_LOG_LEVELS: typeof LOG_LEVELS;
|
|
280
|
+
type index_Logger = Logger;
|
|
281
|
+
type index_OperationProgress = OperationProgress;
|
|
282
|
+
type index_ReadonlySelector<T> = ReadonlySelector<T>;
|
|
283
|
+
type index_Selector<T> = Selector<T>;
|
|
284
|
+
type index_Store = Store;
|
|
285
|
+
type index_StoreCore = StoreCore;
|
|
286
|
+
declare const index_TRANSACTION_PHASES: typeof TRANSACTION_PHASES;
|
|
287
|
+
type index_Timeline = Timeline;
|
|
288
|
+
type index_TimelineData = TimelineData;
|
|
289
|
+
type index_TimelineStateUpdate = TimelineStateUpdate;
|
|
290
|
+
type index_TimelineTransactionUpdate = TimelineTransactionUpdate;
|
|
291
|
+
type index_TransactionIdle = TransactionIdle;
|
|
292
|
+
type index_TransactionPhase = TransactionPhase;
|
|
293
|
+
type index_TransactionStatus<ƒ extends ƒn> = TransactionStatus<ƒ>;
|
|
294
|
+
type index_TransactionUpdate<ƒ extends ƒn> = TransactionUpdate<ƒ>;
|
|
295
|
+
type index_TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdateInProgress<ƒ>;
|
|
296
|
+
declare const index_abortTransaction: typeof abortTransaction;
|
|
297
|
+
declare const index_applyTransaction: typeof applyTransaction;
|
|
298
|
+
declare const index_atomFamily__INTERNAL: typeof atomFamily__INTERNAL;
|
|
299
|
+
declare const index_atom__INTERNAL: typeof atom__INTERNAL;
|
|
300
|
+
declare const index_buildTransaction: typeof buildTransaction;
|
|
301
|
+
declare const index_cacheValue: typeof cacheValue;
|
|
302
|
+
declare const index_clearStore: typeof clearStore;
|
|
303
|
+
declare const index_closeOperation: typeof closeOperation;
|
|
304
|
+
declare const index_computeSelectorState: typeof computeSelectorState;
|
|
305
|
+
declare const index_createStore: typeof createStore;
|
|
306
|
+
declare const index_deposit: typeof deposit;
|
|
307
|
+
declare const index_emitUpdate: typeof emitUpdate;
|
|
308
|
+
declare const index_evictCachedValue: typeof evictCachedValue;
|
|
309
|
+
declare const index_evictDownStream: typeof evictDownStream;
|
|
310
|
+
declare const index_getState__INTERNAL: typeof getState__INTERNAL;
|
|
311
|
+
declare const index_hasKeyBeenUsed: typeof hasKeyBeenUsed;
|
|
312
|
+
declare const index_isAtomDefault: typeof isAtomDefault;
|
|
313
|
+
declare const index_isDone: typeof isDone;
|
|
314
|
+
declare const index_isSelectorDefault: typeof isSelectorDefault;
|
|
315
|
+
declare const index_isValueCached: typeof isValueCached;
|
|
316
|
+
declare const index_lookup: typeof lookup;
|
|
317
|
+
declare const index_lookupSelectorSources: typeof lookupSelectorSources;
|
|
318
|
+
declare const index_markAtomAsDefault: typeof markAtomAsDefault;
|
|
319
|
+
declare const index_markAtomAsNotDefault: typeof markAtomAsNotDefault;
|
|
320
|
+
declare const index_markDone: typeof markDone;
|
|
321
|
+
declare const index_openOperation: typeof openOperation;
|
|
322
|
+
declare const index_prepareUpdate: typeof prepareUpdate;
|
|
323
|
+
declare const index_readCachedValue: typeof readCachedValue;
|
|
324
|
+
declare const index_readonlySelectorFamily__INTERNAL: typeof readonlySelectorFamily__INTERNAL;
|
|
325
|
+
declare const index_recallState: typeof recallState;
|
|
326
|
+
declare const index_redoTransactionUpdate: typeof redoTransactionUpdate;
|
|
327
|
+
declare const index_redo__INTERNAL: typeof redo__INTERNAL;
|
|
328
|
+
declare const index_registerSelector: typeof registerSelector;
|
|
329
|
+
declare const index_selectorFamily__INTERNAL: typeof selectorFamily__INTERNAL;
|
|
330
|
+
declare const index_selector__INTERNAL: typeof selector__INTERNAL;
|
|
331
|
+
declare const index_setAtomState: typeof setAtomState;
|
|
332
|
+
declare const index_setLogLevel: typeof setLogLevel;
|
|
333
|
+
declare const index_setSelectorState: typeof setSelectorState;
|
|
334
|
+
declare const index_setState__INTERNAL: typeof setState__INTERNAL;
|
|
335
|
+
declare const index_storeAtom: typeof storeAtom;
|
|
336
|
+
declare const index_storeReadonlySelector: typeof storeReadonlySelector;
|
|
337
|
+
declare const index_storeSelector: typeof storeSelector;
|
|
338
|
+
declare const index_stowUpdate: typeof stowUpdate;
|
|
339
|
+
declare const index_subscribeToRootAtoms: typeof subscribeToRootAtoms;
|
|
340
|
+
declare const index_target: typeof target;
|
|
341
|
+
declare const index_timeline__INTERNAL: typeof timeline__INTERNAL;
|
|
342
|
+
declare const index_traceAllSelectorAtoms: typeof traceAllSelectorAtoms;
|
|
343
|
+
declare const index_traceSelectorAtoms: typeof traceSelectorAtoms;
|
|
344
|
+
declare const index_transaction__INTERNAL: typeof transaction__INTERNAL;
|
|
345
|
+
declare const index_undoTransactionUpdate: typeof undoTransactionUpdate;
|
|
346
|
+
declare const index_undo__INTERNAL: typeof undo__INTERNAL;
|
|
347
|
+
declare const index_updateSelectorAtoms: typeof updateSelectorAtoms;
|
|
348
|
+
declare const index_useLogger: typeof useLogger;
|
|
349
|
+
declare const index_withdraw: typeof withdraw;
|
|
350
|
+
declare namespace index {
|
|
351
|
+
export {
|
|
352
|
+
index_Atom as Atom,
|
|
353
|
+
index_IMPLICIT as IMPLICIT,
|
|
354
|
+
index_KeyedStateUpdate as KeyedStateUpdate,
|
|
355
|
+
index_LOG_LEVELS as LOG_LEVELS,
|
|
356
|
+
index_Logger as Logger,
|
|
357
|
+
index_OperationProgress as OperationProgress,
|
|
358
|
+
index_ReadonlySelector as ReadonlySelector,
|
|
359
|
+
index_Selector as Selector,
|
|
360
|
+
index_Store as Store,
|
|
361
|
+
index_StoreCore as StoreCore,
|
|
362
|
+
index_TRANSACTION_PHASES as TRANSACTION_PHASES,
|
|
363
|
+
index_Timeline as Timeline,
|
|
364
|
+
index_TimelineData as TimelineData,
|
|
365
|
+
index_TimelineStateUpdate as TimelineStateUpdate,
|
|
366
|
+
index_TimelineTransactionUpdate as TimelineTransactionUpdate,
|
|
367
|
+
index_TransactionIdle as TransactionIdle,
|
|
368
|
+
index_TransactionPhase as TransactionPhase,
|
|
369
|
+
index_TransactionStatus as TransactionStatus,
|
|
370
|
+
index_TransactionUpdate as TransactionUpdate,
|
|
371
|
+
index_TransactionUpdateInProgress as TransactionUpdateInProgress,
|
|
372
|
+
index_abortTransaction as abortTransaction,
|
|
373
|
+
index_applyTransaction as applyTransaction,
|
|
374
|
+
index_atomFamily__INTERNAL as atomFamily__INTERNAL,
|
|
375
|
+
index_atom__INTERNAL as atom__INTERNAL,
|
|
376
|
+
index_buildTransaction as buildTransaction,
|
|
377
|
+
index_cacheValue as cacheValue,
|
|
378
|
+
index_clearStore as clearStore,
|
|
379
|
+
index_closeOperation as closeOperation,
|
|
380
|
+
index_computeSelectorState as computeSelectorState,
|
|
381
|
+
index_createStore as createStore,
|
|
382
|
+
index_deposit as deposit,
|
|
383
|
+
index_emitUpdate as emitUpdate,
|
|
384
|
+
index_evictCachedValue as evictCachedValue,
|
|
385
|
+
index_evictDownStream as evictDownStream,
|
|
386
|
+
index_getState__INTERNAL as getState__INTERNAL,
|
|
387
|
+
index_hasKeyBeenUsed as hasKeyBeenUsed,
|
|
388
|
+
index_isAtomDefault as isAtomDefault,
|
|
389
|
+
index_isDone as isDone,
|
|
390
|
+
index_isSelectorDefault as isSelectorDefault,
|
|
391
|
+
index_isValueCached as isValueCached,
|
|
392
|
+
index_lookup as lookup,
|
|
393
|
+
index_lookupSelectorSources as lookupSelectorSources,
|
|
394
|
+
index_markAtomAsDefault as markAtomAsDefault,
|
|
395
|
+
index_markAtomAsNotDefault as markAtomAsNotDefault,
|
|
396
|
+
index_markDone as markDone,
|
|
397
|
+
index_openOperation as openOperation,
|
|
398
|
+
index_prepareUpdate as prepareUpdate,
|
|
399
|
+
index_readCachedValue as readCachedValue,
|
|
400
|
+
index_readonlySelectorFamily__INTERNAL as readonlySelectorFamily__INTERNAL,
|
|
401
|
+
index_recallState as recallState,
|
|
402
|
+
index_redoTransactionUpdate as redoTransactionUpdate,
|
|
403
|
+
index_redo__INTERNAL as redo__INTERNAL,
|
|
404
|
+
index_registerSelector as registerSelector,
|
|
405
|
+
index_selectorFamily__INTERNAL as selectorFamily__INTERNAL,
|
|
406
|
+
index_selector__INTERNAL as selector__INTERNAL,
|
|
407
|
+
index_setAtomState as setAtomState,
|
|
408
|
+
index_setLogLevel as setLogLevel,
|
|
409
|
+
index_setSelectorState as setSelectorState,
|
|
410
|
+
index_setState__INTERNAL as setState__INTERNAL,
|
|
411
|
+
index_storeAtom as storeAtom,
|
|
412
|
+
index_storeReadonlySelector as storeReadonlySelector,
|
|
413
|
+
index_storeSelector as storeSelector,
|
|
414
|
+
index_stowUpdate as stowUpdate,
|
|
415
|
+
index_subscribeToRootAtoms as subscribeToRootAtoms,
|
|
416
|
+
index_target as target,
|
|
417
|
+
index_timeline__INTERNAL as timeline__INTERNAL,
|
|
418
|
+
index_traceAllSelectorAtoms as traceAllSelectorAtoms,
|
|
419
|
+
index_traceSelectorAtoms as traceSelectorAtoms,
|
|
420
|
+
index_transaction__INTERNAL as transaction__INTERNAL,
|
|
421
|
+
index_undoTransactionUpdate as undoTransactionUpdate,
|
|
422
|
+
index_undo__INTERNAL as undo__INTERNAL,
|
|
423
|
+
index_updateSelectorAtoms as updateSelectorAtoms,
|
|
424
|
+
index_useLogger as useLogger,
|
|
425
|
+
index_withdraw as withdraw,
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
type SelectorOptions<T> = {
|
|
430
|
+
key: string;
|
|
431
|
+
get: (readonlyTransactors: ReadonlyTransactors) => T;
|
|
432
|
+
set: (transactors: Transactors, newValue: T) => void;
|
|
433
|
+
};
|
|
434
|
+
type ReadonlySelectorOptions<T> = Omit<SelectorOptions<T>, `set`>;
|
|
435
|
+
declare function selector<T>(options: SelectorOptions<T>): SelectorToken<T>;
|
|
436
|
+
declare function selector<T>(options: ReadonlySelectorOptions<T>): ReadonlyValueToken<T>;
|
|
437
|
+
type SelectorFamilyOptions<T, K extends Serializable> = {
|
|
438
|
+
key: string;
|
|
439
|
+
get: (key: K) => (readonlyTransactors: ReadonlyTransactors) => T;
|
|
440
|
+
set: (key: K) => (transactors: Transactors, newValue: T) => void;
|
|
441
|
+
};
|
|
442
|
+
type ReadonlySelectorFamilyOptions<T, K extends Serializable> = Omit<SelectorFamilyOptions<T, K>, `set`>;
|
|
443
|
+
type SelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => SelectorToken<T>) & {
|
|
444
|
+
key: string;
|
|
445
|
+
type: `selector_family`;
|
|
446
|
+
subject: Rx.Subject<SelectorToken<T>>;
|
|
447
|
+
};
|
|
448
|
+
type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => ReadonlyValueToken<T>) & {
|
|
449
|
+
key: string;
|
|
450
|
+
type: `readonly_selector_family`;
|
|
451
|
+
subject: Rx.Subject<ReadonlyValueToken<T>>;
|
|
452
|
+
};
|
|
453
|
+
declare function selectorFamily<T, K extends Serializable>(options: SelectorFamilyOptions<T, K>): SelectorFamily<T, K>;
|
|
454
|
+
declare function selectorFamily<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamily<T, K>;
|
|
455
|
+
|
|
456
|
+
type TimelineToken = {
|
|
457
|
+
key: string;
|
|
458
|
+
type: `timeline`;
|
|
459
|
+
};
|
|
460
|
+
type TimelineOptions = {
|
|
461
|
+
key: string;
|
|
462
|
+
atoms: (AtomFamily<any> | AtomToken<any>)[];
|
|
463
|
+
};
|
|
464
|
+
declare const timeline: (options: TimelineOptions) => TimelineToken;
|
|
465
|
+
declare const redo: (token: TimelineToken) => void;
|
|
466
|
+
declare const undo: (token: TimelineToken) => void;
|
|
467
|
+
|
|
468
|
+
type StateUpdate<T> = {
|
|
469
|
+
newValue: T;
|
|
470
|
+
oldValue: T;
|
|
471
|
+
};
|
|
472
|
+
type UpdateHandler<T> = (update: StateUpdate<T>) => void;
|
|
473
|
+
declare const subscribe: <T>(token: ReadonlyValueToken<T> | StateToken<T>, handleUpdate: UpdateHandler<T>, store?: Store) => (() => void);
|
|
474
|
+
type TransactionUpdateHandler<ƒ extends ƒn> = (data: TransactionUpdate<ƒ>) => void;
|
|
475
|
+
declare const subscribeToTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, handleUpdate: TransactionUpdateHandler<ƒ>, store?: Store) => (() => void);
|
|
476
|
+
|
|
477
|
+
type AtomToken<_> = {
|
|
478
|
+
key: string;
|
|
479
|
+
type: `atom`;
|
|
480
|
+
family?: FamilyMetadata;
|
|
481
|
+
};
|
|
482
|
+
type SelectorToken<_> = {
|
|
483
|
+
key: string;
|
|
484
|
+
type: `selector`;
|
|
485
|
+
family?: FamilyMetadata;
|
|
486
|
+
};
|
|
487
|
+
type StateToken<T> = AtomToken<T> | SelectorToken<T>;
|
|
488
|
+
type ReadonlyValueToken<_> = {
|
|
489
|
+
key: string;
|
|
490
|
+
type: `readonly_selector`;
|
|
491
|
+
family?: FamilyMetadata;
|
|
492
|
+
};
|
|
493
|
+
type FamilyMetadata = {
|
|
494
|
+
key: string;
|
|
495
|
+
subKey: string;
|
|
496
|
+
};
|
|
497
|
+
type TransactionToken<_> = {
|
|
498
|
+
key: string;
|
|
499
|
+
type: `transaction`;
|
|
500
|
+
};
|
|
501
|
+
declare const getState: <T>(token: ReadonlyValueToken<T> | StateToken<T>, store?: Store) => T;
|
|
502
|
+
declare const setState: <T, New extends T>(token: StateToken<T>, value: New | ((oldValue: T) => New), store?: Store) => void;
|
|
503
|
+
declare const isDefault: (token: ReadonlyValueToken<unknown> | StateToken<unknown>, store?: Store) => boolean;
|
|
504
|
+
|
|
505
|
+
export { Action, AtomEffect, AtomFamily, AtomFamilyOptions, AtomOptions, AtomToken, Effectors, FamilyMetadata, ReadonlySelectorFamily, ReadonlySelectorFamilyOptions, ReadonlySelectorOptions, ReadonlyTransactors, ReadonlyValueToken, SelectorFamily, SelectorFamilyOptions, SelectorOptions, SelectorToken, Serializable, StateToken, StateUpdate, TimelineOptions, TimelineToken, Transaction, TransactionOptions, TransactionToken, TransactionUpdateHandler, Transactors, UpdateHandler, index as __INTERNAL__, atom, atomFamily, getState, isDefault, redo, runTransaction, selector, selectorFamily, setLogLevel, setState, subscribe, subscribeToTransaction, timeline, transaction, undo, useLogger, ƒn };
|