atom.io 0.3.0 → 0.4.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 +14 -8
- package/dist/index.d.ts +117 -62
- package/dist/index.js +577 -287
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +574 -285
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -6
- package/react/dist/index.d.ts +12 -17
- package/react/dist/index.js +25 -34
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs +21 -34
- package/react/dist/index.mjs.map +1 -1
- package/react-devtools/dist/index.css +26 -0
- package/react-devtools/dist/index.css.map +1 -0
- package/react-devtools/dist/index.d.ts +15 -0
- package/react-devtools/dist/index.js +1579 -0
- package/react-devtools/dist/index.js.map +1 -0
- package/react-devtools/dist/index.mjs +1551 -0
- package/react-devtools/dist/index.mjs.map +1 -0
- package/react-devtools/package.json +15 -0
- package/src/index.ts +14 -8
- package/src/internal/atom-internal.ts +10 -5
- package/src/internal/families-internal.ts +7 -7
- package/src/internal/get.ts +9 -9
- package/src/internal/index.ts +2 -1
- package/src/internal/meta/attach-meta.ts +17 -0
- package/src/internal/meta/index.ts +4 -0
- package/src/internal/meta/meta-state.ts +135 -0
- package/src/internal/meta/meta-timelines.ts +1 -0
- package/src/internal/meta/meta-transactions.ts +1 -0
- package/src/internal/operation.ts +14 -3
- package/src/internal/selector-internal.ts +37 -15
- package/src/internal/store.ts +35 -6
- package/src/internal/time-travel-internal.ts +89 -0
- package/src/internal/timeline-internal.ts +110 -93
- package/src/internal/transaction-internal.ts +14 -5
- package/src/{internal/logger.ts → logger.ts} +2 -2
- package/src/react/index.ts +28 -46
- package/src/react-devtools/AtomIODevtools.tsx +107 -0
- package/src/react-devtools/StateEditor.tsx +73 -0
- package/src/react-devtools/TokenList.tsx +49 -0
- package/src/react-devtools/devtools.scss +130 -0
- package/src/react-devtools/index.ts +1 -0
- package/src/react-explorer/AtomIOExplorer.tsx +208 -0
- package/src/react-explorer/explorer-effects.ts +20 -0
- package/src/react-explorer/explorer-states.ts +224 -0
- package/src/react-explorer/index.ts +23 -0
- package/src/react-explorer/space-states.ts +73 -0
- package/src/react-explorer/view-states.ts +43 -0
- package/src/selector.ts +11 -11
- package/src/subscribe.ts +3 -3
- package/src/timeline.ts +3 -12
- package/src/transaction.ts +9 -4
- package/src/web-effects/index.ts +1 -0
- package/src/web-effects/storage.ts +30 -0
package/README.md
CHANGED
|
@@ -14,18 +14,21 @@
|
|
|
14
14
|
- [x] atom default as function
|
|
15
15
|
- [x] check whether an atom is "default" (never set)
|
|
16
16
|
- [x] customizable logging
|
|
17
|
+
- [x] subscribe to transactions
|
|
18
|
+
- [x] timelines
|
|
19
|
+
- [x] subscribe to families
|
|
17
20
|
|
|
18
21
|
# atom.io
|
|
19
22
|
## upcoming features
|
|
20
|
-
- [ ]
|
|
21
|
-
- [
|
|
22
|
-
- [
|
|
23
|
+
- [ ] store observation api
|
|
24
|
+
- [x] subscribe to creation of atom tokens
|
|
25
|
+
- [x] subscribe to creation of selector tokens
|
|
26
|
+
- [x] subscribe to creation of readonly selector tokens
|
|
27
|
+
- [ ] subscribe to creation of transaction tokens
|
|
28
|
+
- [ ] subscribe to creation of timeline tokens
|
|
29
|
+
- [ ] subscribe to changes in store configuration
|
|
23
30
|
- [ ] resettable atoms
|
|
24
31
|
- [ ] resettable selectors
|
|
25
|
-
- [ ] store observation api
|
|
26
|
-
|
|
27
|
-
## fixes & improvements
|
|
28
|
-
- [ ] apply and emit transactions all at once
|
|
29
32
|
|
|
30
33
|
## documentation
|
|
31
34
|
- [ ] document atom and selector families
|
|
@@ -34,8 +37,11 @@
|
|
|
34
37
|
|
|
35
38
|
# /react
|
|
36
39
|
## features
|
|
37
|
-
- [x] useSubject
|
|
38
40
|
- [x] useStore
|
|
41
|
+
- [x] useI, useO, useIO
|
|
42
|
+
- [ ] useTimeline
|
|
43
|
+
- [ ] useStoreIndex
|
|
44
|
+
- [ ] useTransactionIO
|
|
39
45
|
|
|
40
46
|
# /effects
|
|
41
47
|
## features
|
package/dist/index.d.ts
CHANGED
|
@@ -16,22 +16,28 @@ type Identified = {
|
|
|
16
16
|
|
|
17
17
|
declare const RELATION_TYPES: readonly ["1:1", "1:n", "n:n"];
|
|
18
18
|
type RelationType = (typeof RELATION_TYPES)[number];
|
|
19
|
-
type RelationData<CONTENT extends JsonObj | null = null
|
|
19
|
+
type RelationData<CONTENT extends JsonObj | null = null, A extends string = `from`, B extends string = `to`> = {
|
|
20
20
|
contents: JsonObj<string, CONTENT>;
|
|
21
21
|
relations: JsonObj<string, string[]>;
|
|
22
22
|
relationType: RelationType;
|
|
23
|
+
a: A;
|
|
24
|
+
b: B;
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
type NullSafeUnion<Base, Extension> = Extension extends null ? Base : Base & Extension;
|
|
26
28
|
type NullSafeRest<MaybeArg> = MaybeArg extends null ? [] | [undefined] : [MaybeArg];
|
|
27
29
|
|
|
28
|
-
declare class Join<CONTENT extends JsonObj | null = null
|
|
30
|
+
declare class Join<CONTENT extends JsonObj | null = null, A extends string = `from`, B extends string = `to`> implements RelationData<CONTENT, A, B> {
|
|
29
31
|
readonly relationType: `1:1` | `1:n` | `n:n`;
|
|
32
|
+
readonly a: A;
|
|
33
|
+
readonly b: B;
|
|
30
34
|
readonly relations: Record<string, string[]>;
|
|
31
35
|
readonly contents: Record<string, CONTENT>;
|
|
32
|
-
constructor(json?: Partial<RelationData<CONTENT>>);
|
|
33
|
-
toJSON(): RelationData<CONTENT>;
|
|
34
|
-
static fromJSON<CONTENT extends JsonObj | null
|
|
36
|
+
constructor(json?: Partial<RelationData<CONTENT, A, B>>);
|
|
37
|
+
toJSON(): RelationData<CONTENT, A, B>;
|
|
38
|
+
static fromJSON<CONTENT extends JsonObj | null, A extends string, B extends string>(json: Json, isContent?: Refinement<unknown, CONTENT>, a?: A, b?: B): Join<CONTENT, A, B>;
|
|
39
|
+
from<AA extends string>(newA: AA): Join<CONTENT, AA, B>;
|
|
40
|
+
to<BB extends string>(newB: BB): Join<CONTENT, A, BB>;
|
|
35
41
|
getRelatedId(id: string): string | undefined;
|
|
36
42
|
getRelatedIds(id: string): string[];
|
|
37
43
|
getContent(idA: string, idB: string): CONTENT | undefined;
|
|
@@ -39,9 +45,15 @@ declare class Join<CONTENT extends JsonObj | null = null> implements RelationDat
|
|
|
39
45
|
getRelationRecord(id: string): Record<string, CONTENT>;
|
|
40
46
|
getRelation(id: string): NullSafeUnion<Identified, CONTENT> | undefined;
|
|
41
47
|
getRelations(id: string): NullSafeUnion<Identified, CONTENT>[];
|
|
42
|
-
setRelations(
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
setRelations(subject: {
|
|
49
|
+
[from in A]: string;
|
|
50
|
+
} | {
|
|
51
|
+
[to in B]: string;
|
|
52
|
+
}, relations: NullSafeUnion<Identified, CONTENT>[]): Join<CONTENT, A, B>;
|
|
53
|
+
set(relation: {
|
|
54
|
+
[key in A | B]: string;
|
|
55
|
+
}, ...rest: NullSafeRest<CONTENT>): Join<CONTENT, A, B>;
|
|
56
|
+
remove(relation: Partial<Record<A | B, string>>): Join<CONTENT, A, B>;
|
|
45
57
|
}
|
|
46
58
|
|
|
47
59
|
type StoreCore = Pick<Store, `atoms` | `atomsThatAreDefault` | `operation` | `readonlySelectors` | `selectorAtoms` | `selectorGraph` | `selectors` | `timelineAtoms` | `timelines` | `transactions` | `valueMap`>;
|
|
@@ -49,16 +61,22 @@ interface Store {
|
|
|
49
61
|
atoms: Hamt<Atom<any>, string>;
|
|
50
62
|
atomsThatAreDefault: Set<string>;
|
|
51
63
|
readonlySelectors: Hamt<ReadonlySelector<any>, string>;
|
|
52
|
-
selectorAtoms: Join
|
|
64
|
+
selectorAtoms: Join<null, `selectorKey`, `atomKey`>;
|
|
53
65
|
selectorGraph: Join<{
|
|
54
66
|
source: string;
|
|
55
67
|
}>;
|
|
56
68
|
selectors: Hamt<Selector<any>, string>;
|
|
57
69
|
timelines: Hamt<Timeline, string>;
|
|
58
|
-
timelineAtoms: Join
|
|
70
|
+
timelineAtoms: Join<null, `timelineKey`, `atomKey`>;
|
|
59
71
|
timelineStore: Hamt<TimelineData, string>;
|
|
60
72
|
transactions: Hamt<Transaction<any>, string>;
|
|
61
73
|
valueMap: Hamt<any, string>;
|
|
74
|
+
subject: {
|
|
75
|
+
atomCreation: Rx.Subject<AtomToken<unknown>>;
|
|
76
|
+
selectorCreation: Rx.Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
77
|
+
transactionCreation: Rx.Subject<TransactionToken<unknown>>;
|
|
78
|
+
timelineCreation: Rx.Subject<TimelineToken>;
|
|
79
|
+
};
|
|
62
80
|
operation: OperationProgress;
|
|
63
81
|
transactionStatus: TransactionStatus<ƒn>;
|
|
64
82
|
config: {
|
|
@@ -118,19 +136,19 @@ declare function selectorFamily__INTERNAL<T, K extends Serializable>(options: Se
|
|
|
118
136
|
declare function selectorFamily__INTERNAL<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>, store?: Store): ReadonlySelectorFamily<T, K>;
|
|
119
137
|
|
|
120
138
|
declare const computeSelectorState: <T>(selector: ReadonlySelector<T> | Selector<T>) => T;
|
|
121
|
-
declare function lookup(key: string, store: Store): AtomToken<unknown> |
|
|
139
|
+
declare function lookup(key: string, store: Store): AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>;
|
|
122
140
|
declare function withdraw<T>(token: AtomToken<T>, store: Store): Atom<T>;
|
|
123
141
|
declare function withdraw<T>(token: SelectorToken<T>, store: Store): Selector<T>;
|
|
124
142
|
declare function withdraw<T>(token: StateToken<T>, store: Store): Atom<T> | Selector<T>;
|
|
125
|
-
declare function withdraw<T>(token:
|
|
143
|
+
declare function withdraw<T>(token: ReadonlySelectorToken<T>, store: Store): ReadonlySelector<T>;
|
|
126
144
|
declare function withdraw<T>(token: TransactionToken<T>, store: Store): Transaction<T extends ƒn ? T : never>;
|
|
127
|
-
declare function withdraw<T>(token:
|
|
145
|
+
declare function withdraw<T>(token: ReadonlySelectorToken<T> | StateToken<T>, store: Store): Atom<T> | ReadonlySelector<T> | Selector<T>;
|
|
128
146
|
declare function deposit<T>(state: Atom<T>): AtomToken<T>;
|
|
129
147
|
declare function deposit<T>(state: Selector<T>): SelectorToken<T>;
|
|
130
148
|
declare function deposit<T>(state: Atom<T> | Selector<T>): StateToken<T>;
|
|
131
|
-
declare function deposit<T>(state: ReadonlySelector<T>):
|
|
149
|
+
declare function deposit<T>(state: ReadonlySelector<T>): ReadonlySelectorToken<T>;
|
|
132
150
|
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>):
|
|
151
|
+
declare function deposit<T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>): ReadonlySelectorToken<T> | StateToken<T>;
|
|
134
152
|
declare const getState__INTERNAL: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, store?: Store) => T;
|
|
135
153
|
|
|
136
154
|
declare const isAtomDefault: (key: string, store?: Store) => boolean;
|
|
@@ -138,10 +156,36 @@ declare const markAtomAsDefault: (key: string, store?: Store) => void;
|
|
|
138
156
|
declare const markAtomAsNotDefault: (key: string, store?: Store) => void;
|
|
139
157
|
declare const isSelectorDefault: (key: string, store?: Store) => boolean;
|
|
140
158
|
|
|
141
|
-
type
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
159
|
+
type StateTokenIndex<Token extends AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>> = Record<string, Token | {
|
|
160
|
+
key: string;
|
|
161
|
+
familyMembers: Record<string, Token>;
|
|
162
|
+
}>;
|
|
163
|
+
type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>;
|
|
164
|
+
type SelectorTokenIndex = StateTokenIndex<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
165
|
+
declare const attachMetaAtoms: (store?: Store) => ReadonlySelectorToken<AtomTokenIndex>;
|
|
166
|
+
declare const attachMetaSelectors: (store?: Store) => ReadonlySelectorToken<SelectorTokenIndex>;
|
|
167
|
+
|
|
168
|
+
declare const attachMetaState: (store?: Store) => {
|
|
169
|
+
atomTokenIndexState: ReadonlySelectorToken<AtomTokenIndex>;
|
|
170
|
+
selectorTokenIndexState: ReadonlySelectorToken<SelectorTokenIndex>;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
type index$1_AtomTokenIndex = AtomTokenIndex;
|
|
174
|
+
type index$1_SelectorTokenIndex = SelectorTokenIndex;
|
|
175
|
+
type index$1_StateTokenIndex<Token extends AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>> = StateTokenIndex<Token>;
|
|
176
|
+
declare const index$1_attachMetaAtoms: typeof attachMetaAtoms;
|
|
177
|
+
declare const index$1_attachMetaSelectors: typeof attachMetaSelectors;
|
|
178
|
+
declare const index$1_attachMetaState: typeof attachMetaState;
|
|
179
|
+
declare namespace index$1 {
|
|
180
|
+
export {
|
|
181
|
+
index$1_AtomTokenIndex as AtomTokenIndex,
|
|
182
|
+
index$1_SelectorTokenIndex as SelectorTokenIndex,
|
|
183
|
+
index$1_StateTokenIndex as StateTokenIndex,
|
|
184
|
+
index$1_attachMetaAtoms as attachMetaAtoms,
|
|
185
|
+
index$1_attachMetaSelectors as attachMetaSelectors,
|
|
186
|
+
index$1_attachMetaState as attachMetaState,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
145
189
|
|
|
146
190
|
type OperationProgress = {
|
|
147
191
|
open: false;
|
|
@@ -149,8 +193,10 @@ type OperationProgress = {
|
|
|
149
193
|
open: true;
|
|
150
194
|
done: Set<string>;
|
|
151
195
|
prev: Hamt<any, string>;
|
|
196
|
+
time: number;
|
|
197
|
+
token: StateToken<any>;
|
|
152
198
|
};
|
|
153
|
-
declare const openOperation: (store: Store) => void;
|
|
199
|
+
declare const openOperation: (token: StateToken<any>, store: Store) => void;
|
|
154
200
|
declare const closeOperation: (store: Store) => void;
|
|
155
201
|
declare const isDone: (key: string, store?: Store) => boolean;
|
|
156
202
|
declare const markDone: (key: string, store?: Store) => void;
|
|
@@ -166,14 +212,15 @@ declare const hasKeyBeenUsed: (key: string, store?: Store) => boolean;
|
|
|
166
212
|
|
|
167
213
|
type ƒn = (...parameters: any[]) => any;
|
|
168
214
|
type Transactors = {
|
|
169
|
-
get: <S>(state:
|
|
215
|
+
get: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S;
|
|
170
216
|
set: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void;
|
|
171
217
|
};
|
|
172
218
|
type ReadonlyTransactors = Pick<Transactors, `get`>;
|
|
173
|
-
type
|
|
219
|
+
type Read<ƒ extends ƒn> = (transactors: ReadonlyTransactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
220
|
+
type Write<ƒ extends ƒn> = (transactors: Transactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
174
221
|
type TransactionOptions<ƒ extends ƒn> = {
|
|
175
222
|
key: string;
|
|
176
|
-
do:
|
|
223
|
+
do: Write<ƒ>;
|
|
177
224
|
};
|
|
178
225
|
type Transaction<ƒ extends ƒn> = {
|
|
179
226
|
key: string;
|
|
@@ -205,13 +252,13 @@ type ReadonlySelector<T> = {
|
|
|
205
252
|
}>;
|
|
206
253
|
get: () => T;
|
|
207
254
|
};
|
|
208
|
-
declare const lookupSelectorSources: (key: string, store: Store) => (AtomToken<unknown> |
|
|
209
|
-
declare const traceSelectorAtoms: (selectorKey: string, dependency:
|
|
255
|
+
declare const lookupSelectorSources: (key: string, store: Store) => (AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>)[];
|
|
256
|
+
declare const traceSelectorAtoms: (selectorKey: string, dependency: ReadonlySelectorToken<unknown> | StateToken<unknown>, store: Store) => AtomToken<unknown>[];
|
|
210
257
|
declare const traceAllSelectorAtoms: (selectorKey: string, store: Store) => AtomToken<unknown>[];
|
|
211
|
-
declare const updateSelectorAtoms: (selectorKey: string, dependency:
|
|
258
|
+
declare const updateSelectorAtoms: (selectorKey: string, dependency: ReadonlySelectorToken<unknown> | StateToken<unknown>, store: Store) => void;
|
|
212
259
|
declare const registerSelector: (selectorKey: string, store?: Store) => Transactors;
|
|
213
260
|
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):
|
|
261
|
+
declare function selector__INTERNAL<T>(options: ReadonlySelectorOptions<T>, family?: FamilyMetadata, store?: Store): ReadonlySelectorToken<T>;
|
|
215
262
|
|
|
216
263
|
declare const evictDownStream: <T>(state: Atom<T>, store?: Store) => void;
|
|
217
264
|
declare const setAtomState: <T>(atom: Atom<T>, next: T | ((oldValue: T) => T), store?: Store) => void;
|
|
@@ -225,14 +272,22 @@ declare const subscribeToRootAtoms: <T>(state: ReadonlySelector<T> | Selector<T>
|
|
|
225
272
|
unsubscribe: () => void;
|
|
226
273
|
}[] | null;
|
|
227
274
|
|
|
275
|
+
declare const redo__INTERNAL: (token: TimelineToken, store?: Store) => void;
|
|
276
|
+
declare const undo__INTERNAL: (token: TimelineToken, store?: Store) => void;
|
|
277
|
+
|
|
228
278
|
type Timeline = {
|
|
229
279
|
key: string;
|
|
230
280
|
type: `timeline`;
|
|
231
281
|
next: () => void;
|
|
232
282
|
prev: () => void;
|
|
233
283
|
};
|
|
234
|
-
type
|
|
235
|
-
type: `
|
|
284
|
+
type TimelineAtomUpdate = KeyedStateUpdate<unknown> & {
|
|
285
|
+
type: `atom_update`;
|
|
286
|
+
};
|
|
287
|
+
type TimelineSelectorUpdate = {
|
|
288
|
+
key: string;
|
|
289
|
+
type: `selector_update`;
|
|
290
|
+
atomUpdates: TimelineAtomUpdate[];
|
|
236
291
|
};
|
|
237
292
|
type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
|
|
238
293
|
type: `transaction_update`;
|
|
@@ -240,11 +295,11 @@ type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
|
|
|
240
295
|
type TimelineData = {
|
|
241
296
|
at: number;
|
|
242
297
|
timeTraveling: boolean;
|
|
243
|
-
history: (
|
|
298
|
+
history: (TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate)[];
|
|
299
|
+
selectorTime: number | null;
|
|
300
|
+
transactionKey: string | null;
|
|
244
301
|
};
|
|
245
302
|
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
303
|
|
|
249
304
|
declare const TRANSACTION_PHASES: readonly ["idle", "building", "applying"];
|
|
250
305
|
type TransactionPhase = (typeof TRANSACTION_PHASES)[number];
|
|
@@ -276,8 +331,6 @@ declare const target: (store?: Store) => StoreCore;
|
|
|
276
331
|
type index_Atom<T> = Atom<T>;
|
|
277
332
|
declare const index_IMPLICIT: typeof IMPLICIT;
|
|
278
333
|
type index_KeyedStateUpdate<T> = KeyedStateUpdate<T>;
|
|
279
|
-
declare const index_LOG_LEVELS: typeof LOG_LEVELS;
|
|
280
|
-
type index_Logger = Logger;
|
|
281
334
|
type index_OperationProgress = OperationProgress;
|
|
282
335
|
type index_ReadonlySelector<T> = ReadonlySelector<T>;
|
|
283
336
|
type index_Selector<T> = Selector<T>;
|
|
@@ -285,8 +338,9 @@ type index_Store = Store;
|
|
|
285
338
|
type index_StoreCore = StoreCore;
|
|
286
339
|
declare const index_TRANSACTION_PHASES: typeof TRANSACTION_PHASES;
|
|
287
340
|
type index_Timeline = Timeline;
|
|
341
|
+
type index_TimelineAtomUpdate = TimelineAtomUpdate;
|
|
288
342
|
type index_TimelineData = TimelineData;
|
|
289
|
-
type
|
|
343
|
+
type index_TimelineSelectorUpdate = TimelineSelectorUpdate;
|
|
290
344
|
type index_TimelineTransactionUpdate = TimelineTransactionUpdate;
|
|
291
345
|
type index_TransactionIdle = TransactionIdle;
|
|
292
346
|
type index_TransactionPhase = TransactionPhase;
|
|
@@ -329,7 +383,6 @@ declare const index_registerSelector: typeof registerSelector;
|
|
|
329
383
|
declare const index_selectorFamily__INTERNAL: typeof selectorFamily__INTERNAL;
|
|
330
384
|
declare const index_selector__INTERNAL: typeof selector__INTERNAL;
|
|
331
385
|
declare const index_setAtomState: typeof setAtomState;
|
|
332
|
-
declare const index_setLogLevel: typeof setLogLevel;
|
|
333
386
|
declare const index_setSelectorState: typeof setSelectorState;
|
|
334
387
|
declare const index_setState__INTERNAL: typeof setState__INTERNAL;
|
|
335
388
|
declare const index_storeAtom: typeof storeAtom;
|
|
@@ -345,15 +398,13 @@ declare const index_transaction__INTERNAL: typeof transaction__INTERNAL;
|
|
|
345
398
|
declare const index_undoTransactionUpdate: typeof undoTransactionUpdate;
|
|
346
399
|
declare const index_undo__INTERNAL: typeof undo__INTERNAL;
|
|
347
400
|
declare const index_updateSelectorAtoms: typeof updateSelectorAtoms;
|
|
348
|
-
declare const index_useLogger: typeof useLogger;
|
|
349
401
|
declare const index_withdraw: typeof withdraw;
|
|
350
402
|
declare namespace index {
|
|
351
403
|
export {
|
|
352
404
|
index_Atom as Atom,
|
|
353
405
|
index_IMPLICIT as IMPLICIT,
|
|
354
406
|
index_KeyedStateUpdate as KeyedStateUpdate,
|
|
355
|
-
|
|
356
|
-
index_Logger as Logger,
|
|
407
|
+
index$1 as META,
|
|
357
408
|
index_OperationProgress as OperationProgress,
|
|
358
409
|
index_ReadonlySelector as ReadonlySelector,
|
|
359
410
|
index_Selector as Selector,
|
|
@@ -361,8 +412,9 @@ declare namespace index {
|
|
|
361
412
|
index_StoreCore as StoreCore,
|
|
362
413
|
index_TRANSACTION_PHASES as TRANSACTION_PHASES,
|
|
363
414
|
index_Timeline as Timeline,
|
|
415
|
+
index_TimelineAtomUpdate as TimelineAtomUpdate,
|
|
364
416
|
index_TimelineData as TimelineData,
|
|
365
|
-
|
|
417
|
+
index_TimelineSelectorUpdate as TimelineSelectorUpdate,
|
|
366
418
|
index_TimelineTransactionUpdate as TimelineTransactionUpdate,
|
|
367
419
|
index_TransactionIdle as TransactionIdle,
|
|
368
420
|
index_TransactionPhase as TransactionPhase,
|
|
@@ -405,7 +457,6 @@ declare namespace index {
|
|
|
405
457
|
index_selectorFamily__INTERNAL as selectorFamily__INTERNAL,
|
|
406
458
|
index_selector__INTERNAL as selector__INTERNAL,
|
|
407
459
|
index_setAtomState as setAtomState,
|
|
408
|
-
index_setLogLevel as setLogLevel,
|
|
409
460
|
index_setSelectorState as setSelectorState,
|
|
410
461
|
index_setState__INTERNAL as setState__INTERNAL,
|
|
411
462
|
index_storeAtom as storeAtom,
|
|
@@ -421,23 +472,27 @@ declare namespace index {
|
|
|
421
472
|
index_undoTransactionUpdate as undoTransactionUpdate,
|
|
422
473
|
index_undo__INTERNAL as undo__INTERNAL,
|
|
423
474
|
index_updateSelectorAtoms as updateSelectorAtoms,
|
|
424
|
-
index_useLogger as useLogger,
|
|
425
475
|
index_withdraw as withdraw,
|
|
426
476
|
};
|
|
427
477
|
}
|
|
428
478
|
|
|
479
|
+
type Logger = Pick<Console, `error` | `info` | `warn`>;
|
|
480
|
+
declare const LOG_LEVELS: ReadonlyArray<keyof Logger>;
|
|
481
|
+
declare const setLogLevel: (preferredLevel: `error` | `info` | `warn` | null, store?: Store) => void;
|
|
482
|
+
declare const useLogger: (logger: Logger, store?: Store) => void;
|
|
483
|
+
|
|
429
484
|
type SelectorOptions<T> = {
|
|
430
485
|
key: string;
|
|
431
|
-
get: (
|
|
432
|
-
set: (
|
|
486
|
+
get: Read<() => T>;
|
|
487
|
+
set: Write<(newValue: T) => void>;
|
|
433
488
|
};
|
|
434
489
|
type ReadonlySelectorOptions<T> = Omit<SelectorOptions<T>, `set`>;
|
|
490
|
+
declare function selector<T>(options: ReadonlySelectorOptions<T>): ReadonlySelectorToken<T>;
|
|
435
491
|
declare function selector<T>(options: SelectorOptions<T>): SelectorToken<T>;
|
|
436
|
-
declare function selector<T>(options: ReadonlySelectorOptions<T>): ReadonlyValueToken<T>;
|
|
437
492
|
type SelectorFamilyOptions<T, K extends Serializable> = {
|
|
438
493
|
key: string;
|
|
439
|
-
get: (key: K) => (
|
|
440
|
-
set: (key: K) => (
|
|
494
|
+
get: (key: K) => Read<() => T>;
|
|
495
|
+
set: (key: K) => Write<(newValue: T) => void>;
|
|
441
496
|
};
|
|
442
497
|
type ReadonlySelectorFamilyOptions<T, K extends Serializable> = Omit<SelectorFamilyOptions<T, K>, `set`>;
|
|
443
498
|
type SelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => SelectorToken<T>) & {
|
|
@@ -445,14 +500,23 @@ type SelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => Sel
|
|
|
445
500
|
type: `selector_family`;
|
|
446
501
|
subject: Rx.Subject<SelectorToken<T>>;
|
|
447
502
|
};
|
|
448
|
-
type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K) =>
|
|
503
|
+
type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
|
|
449
504
|
key: string;
|
|
450
505
|
type: `readonly_selector_family`;
|
|
451
|
-
subject: Rx.Subject<
|
|
506
|
+
subject: Rx.Subject<ReadonlySelectorToken<T>>;
|
|
452
507
|
};
|
|
453
508
|
declare function selectorFamily<T, K extends Serializable>(options: SelectorFamilyOptions<T, K>): SelectorFamily<T, K>;
|
|
454
509
|
declare function selectorFamily<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamily<T, K>;
|
|
455
510
|
|
|
511
|
+
type StateUpdate<T> = {
|
|
512
|
+
newValue: T;
|
|
513
|
+
oldValue: T;
|
|
514
|
+
};
|
|
515
|
+
type UpdateHandler<T> = (update: StateUpdate<T>) => void;
|
|
516
|
+
declare const subscribe: <T>(token: ReadonlySelectorToken<T> | StateToken<T>, handleUpdate: UpdateHandler<T>, store?: Store) => (() => void);
|
|
517
|
+
type TransactionUpdateHandler<ƒ extends ƒn> = (data: TransactionUpdate<ƒ>) => void;
|
|
518
|
+
declare const subscribeToTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, handleUpdate: TransactionUpdateHandler<ƒ>, store?: Store) => (() => void);
|
|
519
|
+
|
|
456
520
|
type TimelineToken = {
|
|
457
521
|
key: string;
|
|
458
522
|
type: `timeline`;
|
|
@@ -465,15 +529,6 @@ declare const timeline: (options: TimelineOptions) => TimelineToken;
|
|
|
465
529
|
declare const redo: (token: TimelineToken) => void;
|
|
466
530
|
declare const undo: (token: TimelineToken) => void;
|
|
467
531
|
|
|
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
532
|
type AtomToken<_> = {
|
|
478
533
|
key: string;
|
|
479
534
|
type: `atom`;
|
|
@@ -485,7 +540,7 @@ type SelectorToken<_> = {
|
|
|
485
540
|
family?: FamilyMetadata;
|
|
486
541
|
};
|
|
487
542
|
type StateToken<T> = AtomToken<T> | SelectorToken<T>;
|
|
488
|
-
type
|
|
543
|
+
type ReadonlySelectorToken<_> = {
|
|
489
544
|
key: string;
|
|
490
545
|
type: `readonly_selector`;
|
|
491
546
|
family?: FamilyMetadata;
|
|
@@ -498,8 +553,8 @@ type TransactionToken<_> = {
|
|
|
498
553
|
key: string;
|
|
499
554
|
type: `transaction`;
|
|
500
555
|
};
|
|
501
|
-
declare const getState: <T>(token:
|
|
556
|
+
declare const getState: <T>(token: ReadonlySelectorToken<T> | StateToken<T>, store?: Store) => T;
|
|
502
557
|
declare const setState: <T, New extends T>(token: StateToken<T>, value: New | ((oldValue: T) => New), store?: Store) => void;
|
|
503
|
-
declare const isDefault: (token:
|
|
558
|
+
declare const isDefault: (token: ReadonlySelectorToken<unknown> | StateToken<unknown>, store?: Store) => boolean;
|
|
504
559
|
|
|
505
|
-
export {
|
|
560
|
+
export { AtomEffect, AtomFamily, AtomFamilyOptions, AtomOptions, AtomToken, Effectors, FamilyMetadata, LOG_LEVELS, Logger, Read, ReadonlySelectorFamily, ReadonlySelectorFamilyOptions, ReadonlySelectorOptions, ReadonlySelectorToken, ReadonlyTransactors, SelectorFamily, SelectorFamilyOptions, SelectorOptions, SelectorToken, Serializable, StateToken, StateUpdate, TimelineOptions, TimelineToken, Transaction, TransactionOptions, TransactionToken, TransactionUpdateHandler, Transactors, UpdateHandler, Write, index as __INTERNAL__, atom, atomFamily, getState, isDefault, redo, runTransaction, selector, selectorFamily, setLogLevel, setState, subscribe, subscribeToTransaction, timeline, transaction, undo, useLogger, ƒn };
|