atom.io 0.6.8 → 0.7.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 +21 -2
- package/dist/index.d.mts +42 -461
- package/dist/index.d.ts +42 -461
- package/dist/index.js +128 -1792
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +75 -1742
- package/dist/index.mjs.map +1 -1
- package/internal/dist/index.d.mts +342 -0
- package/internal/dist/index.d.ts +342 -0
- package/internal/dist/index.js +1873 -0
- package/internal/dist/index.js.map +1 -0
- package/internal/dist/index.mjs +1798 -0
- package/internal/dist/index.mjs.map +1 -0
- package/internal/package.json +15 -0
- package/internal/src/atom/create-atom.ts +75 -0
- package/internal/src/atom/delete-atom.ts +10 -0
- package/internal/src/atom/index.ts +3 -0
- package/{src/internal → internal/src/atom}/is-default.ts +4 -2
- package/internal/src/caching.ts +21 -0
- package/internal/src/families/create-atom-family.ts +59 -0
- package/internal/src/families/create-readonly-selector-family.ts +45 -0
- package/internal/src/families/create-selector-family.ts +67 -0
- package/internal/src/families/index.ts +3 -0
- package/internal/src/get-state-internal.ts +23 -0
- package/internal/src/index.ts +13 -0
- package/internal/src/mutable/create-mutable-atom-family.ts +25 -0
- package/internal/src/mutable/create-mutable-atom.ts +49 -0
- package/internal/src/mutable/get-json-token.ts +22 -0
- package/internal/src/mutable/get-update-token.ts +20 -0
- package/internal/src/mutable/index.ts +17 -0
- package/internal/src/mutable/is-atom-token-mutable.ts +7 -0
- package/internal/src/mutable/tracker-family.ts +61 -0
- package/internal/src/mutable/tracker.ts +164 -0
- package/internal/src/mutable/transceiver.ts +110 -0
- package/internal/src/operation.ts +68 -0
- package/{src/internal → internal/src}/selector/create-read-write-selector.ts +10 -13
- package/{src/internal → internal/src}/selector/create-readonly-selector.ts +9 -8
- package/internal/src/selector/create-selector.ts +65 -0
- package/{src/internal → internal/src}/selector/index.ts +1 -0
- package/internal/src/selector/lookup-selector-sources.ts +20 -0
- package/{src/internal → internal/src}/selector/register-selector.ts +13 -9
- package/{src/internal → internal/src}/selector/trace-selector-atoms.ts +4 -2
- package/{src/internal → internal/src}/selector/update-selector-atoms.ts +4 -3
- package/internal/src/set-state/become.ts +10 -0
- package/internal/src/set-state/copy-mutable-if-needed.ts +23 -0
- package/internal/src/set-state/copy-mutable-in-transaction.ts +59 -0
- package/internal/src/set-state/copy-mutable-into-new-store.ts +34 -0
- package/internal/src/set-state/emit-update.ts +23 -0
- package/internal/src/set-state/evict-downstream.ts +39 -0
- package/internal/src/set-state/index.ts +2 -0
- package/internal/src/set-state/set-atom-state.ts +38 -0
- package/internal/src/set-state/set-selector-state.ts +19 -0
- package/internal/src/set-state/set-state-internal.ts +18 -0
- package/internal/src/set-state/stow-update.ts +42 -0
- package/internal/src/store/deposit.ts +43 -0
- package/internal/src/store/index.ts +5 -0
- package/internal/src/store/lookup.ts +26 -0
- package/internal/src/store/store.ts +154 -0
- package/internal/src/store/withdraw-new-family-member.ts +53 -0
- package/internal/src/store/withdraw.ts +113 -0
- package/internal/src/subject.ts +21 -0
- package/internal/src/subscribe/index.ts +1 -0
- package/internal/src/subscribe/recall-state.ts +19 -0
- package/internal/src/subscribe/subscribe-to-root-atoms.ts +47 -0
- package/{src/internal → internal/src}/timeline/add-atom-to-timeline.ts +50 -29
- package/internal/src/timeline/index.ts +3 -0
- package/{src/internal → internal/src/timeline}/time-travel-internal.ts +6 -6
- package/{src/internal → internal/src/timeline}/timeline-internal.ts +20 -12
- package/{src/internal → internal/src}/transaction/abort-transaction.ts +1 -1
- package/{src/internal → internal/src}/transaction/apply-transaction.ts +25 -18
- package/{src/internal → internal/src}/transaction/build-transaction.ts +12 -6
- package/{src/internal → internal/src}/transaction/index.ts +3 -2
- package/{src/internal → internal/src}/transaction/redo-transaction.ts +4 -5
- package/{src/internal → internal/src/transaction}/transaction-internal.ts +16 -13
- package/{src/internal → internal/src}/transaction/undo-transaction.ts +4 -5
- package/introspection/dist/index.d.mts +12 -260
- package/introspection/dist/index.d.ts +12 -260
- package/introspection/dist/index.js +125 -140
- package/introspection/dist/index.js.map +1 -1
- package/introspection/dist/index.mjs +103 -116
- package/introspection/dist/index.mjs.map +1 -1
- package/{src/introspection → introspection/src}/attach-atom-index.ts +41 -30
- package/{src/introspection → introspection/src}/attach-introspection-states.ts +6 -10
- package/introspection/src/attach-selector-index.ts +90 -0
- package/{src/introspection → introspection/src}/attach-timeline-family.ts +16 -16
- package/introspection/src/attach-timeline-index.ts +38 -0
- package/introspection/src/attach-transaction-index.ts +40 -0
- package/{src/introspection → introspection/src}/attach-transaction-logs.ts +11 -8
- package/json/dist/index.d.mts +41 -2
- package/json/dist/index.d.ts +41 -2
- package/json/dist/index.js +88 -48
- package/json/dist/index.js.map +1 -1
- package/json/dist/index.mjs +76 -13
- package/json/dist/index.mjs.map +1 -1
- package/json/src/index.ts +5 -0
- package/json/src/select-json-family.ts +35 -0
- package/json/src/select-json.ts +22 -0
- package/package.json +105 -57
- package/react/dist/index.d.mts +9 -17
- package/react/dist/index.d.ts +9 -17
- package/react/dist/index.js +45 -77
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs +18 -34
- package/react/dist/index.mjs.map +1 -1
- package/react/src/store-context.tsx +12 -0
- package/react/src/store-hooks.ts +36 -0
- package/react-devtools/dist/index.css +1 -1
- package/react-devtools/dist/index.css.map +1 -1
- package/react-devtools/dist/index.d.mts +199 -230
- package/react-devtools/dist/index.d.ts +199 -230
- package/react-devtools/dist/index.js +610 -2466
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/index.mjs +543 -2401
- package/react-devtools/dist/index.mjs.map +1 -1
- package/{src/react-devtools → react-devtools/src}/AtomIODevtools.tsx +5 -3
- package/{src/react-devtools → react-devtools/src}/Button.tsx +2 -3
- package/{src/react-devtools → react-devtools/src}/StateEditor.tsx +3 -2
- package/{src/react-devtools → react-devtools/src}/StateIndex.tsx +7 -4
- package/{src/react-devtools → react-devtools/src}/TimelineIndex.tsx +7 -11
- package/{src/react-devtools → react-devtools/src}/TransactionIndex.tsx +4 -4
- package/{src/react-devtools → react-devtools/src}/Updates.tsx +9 -4
- package/{src/react-devtools → react-devtools/src}/index.ts +5 -5
- package/realtime-react/dist/index.d.mts +9 -25
- package/realtime-react/dist/index.d.ts +9 -25
- package/realtime-react/dist/index.js +75 -193
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/dist/index.mjs +44 -148
- package/realtime-react/dist/index.mjs.map +1 -1
- package/realtime-react/src/index.ts +7 -0
- package/{src/realtime-react → realtime-react/src}/realtime-context.tsx +3 -4
- package/realtime-react/src/use-pull-family-member.ts +15 -0
- package/realtime-react/src/use-pull-mutable-family-member.ts +20 -0
- package/realtime-react/src/use-pull-mutable.ts +17 -0
- package/realtime-react/src/use-pull.ts +15 -0
- package/realtime-react/src/use-push.ts +19 -0
- package/realtime-react/src/use-server-action.ts +18 -0
- package/realtime-testing/dist/index.d.mts +49 -0
- package/realtime-testing/dist/index.d.ts +49 -0
- package/realtime-testing/dist/index.js +147 -0
- package/realtime-testing/dist/index.js.map +1 -0
- package/realtime-testing/dist/index.mjs +116 -0
- package/realtime-testing/dist/index.mjs.map +1 -0
- package/{src/realtime-testing → realtime-testing/src}/setup-realtime-test.tsx +10 -8
- package/src/atom.ts +64 -8
- package/src/index.ts +36 -29
- package/src/logger.ts +7 -7
- package/src/selector.ts +5 -5
- package/src/silo.ts +49 -43
- package/src/subscribe.ts +27 -22
- package/src/timeline.ts +9 -4
- package/src/transaction.ts +3 -4
- package/transceivers/set-rtx/dist/index.d.mts +39 -0
- package/transceivers/set-rtx/dist/index.d.ts +39 -0
- package/transceivers/set-rtx/dist/index.js +213 -0
- package/transceivers/set-rtx/dist/index.js.map +1 -0
- package/transceivers/set-rtx/dist/index.mjs +211 -0
- package/transceivers/set-rtx/dist/index.mjs.map +1 -0
- package/{realtime → transceivers/set-rtx}/package.json +1 -1
- package/transceivers/set-rtx/src/index.ts +1 -0
- package/transceivers/set-rtx/src/set-rtx.ts +242 -0
- package/realtime/dist/index.d.mts +0 -25
- package/realtime/dist/index.d.ts +0 -25
- package/realtime/dist/index.js +0 -190
- package/realtime/dist/index.js.map +0 -1
- package/realtime/dist/index.mjs +0 -151
- package/realtime/dist/index.mjs.map +0 -1
- package/src/internal/atom-internal.ts +0 -54
- package/src/internal/families-internal.ts +0 -144
- package/src/internal/get.ts +0 -129
- package/src/internal/index.ts +0 -15
- package/src/internal/operation.ts +0 -139
- package/src/internal/selector/lookup-selector-sources.ts +0 -16
- package/src/internal/selector-internal.ts +0 -58
- package/src/internal/set.ts +0 -99
- package/src/internal/store.ts +0 -151
- package/src/internal/subscribe-internal.ts +0 -88
- package/src/internal/timeline/index.ts +0 -1
- package/src/introspection/attach-selector-index.ts +0 -77
- package/src/introspection/attach-timeline-index.ts +0 -36
- package/src/introspection/attach-transaction-index.ts +0 -38
- package/src/json/index.ts +0 -1
- package/src/json/select-json.ts +0 -18
- package/src/react/store-context.tsx +0 -13
- package/src/react/store-hooks.ts +0 -47
- package/src/react-explorer/AtomIOExplorer.tsx +0 -218
- package/src/react-explorer/explorer-effects.ts +0 -20
- package/src/react-explorer/explorer-states.ts +0 -217
- package/src/react-explorer/index.ts +0 -23
- package/src/react-explorer/space-states.ts +0 -72
- package/src/react-explorer/view-states.ts +0 -41
- package/src/realtime/README.md +0 -33
- package/src/realtime/hook-composition/expose-family.ts +0 -101
- package/src/realtime/hook-composition/expose-single.ts +0 -38
- package/src/realtime/hook-composition/expose-timeline.ts +0 -60
- package/src/realtime/hook-composition/index.ts +0 -12
- package/src/realtime/hook-composition/receive-state.ts +0 -29
- package/src/realtime/hook-composition/receive-transaction.ts +0 -18
- package/src/realtime/index.ts +0 -1
- package/src/realtime-react/index.ts +0 -3
- package/src/realtime-react/realtime-hooks.ts +0 -39
- package/src/realtime-react/realtime-state.ts +0 -10
- package/src/realtime-react/use-pull-family-member.ts +0 -26
- package/src/realtime-react/use-pull-family.ts +0 -24
- package/src/realtime-react/use-pull.ts +0 -24
- package/src/realtime-react/use-push.ts +0 -27
- package/src/realtime-react/use-server-action.ts +0 -33
- package/src/tracker/index.ts +0 -3
- package/src/tracker/tracker.ts +0 -61
- package/src/web-effects/index.ts +0 -1
- package/src/web-effects/storage.ts +0 -30
- /package/{src/introspection → introspection/src}/index.ts +0 -0
- /package/{src/react → react/src}/index.ts +0 -0
- /package/{src/react-devtools → react-devtools/src}/devtools.scss +0 -0
- /package/{src/realtime-testing → realtime-testing/src}/index.ts +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,118 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type ƒn = (...parameters: any[]) => any;
|
|
4
|
-
|
|
5
|
-
type JsonInterface<T, J extends Serializable = Serializable> = {
|
|
6
|
-
toJson: (t: T) => J;
|
|
7
|
-
fromJson: (json: J) => T;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
type primitive = boolean | number | string | null;
|
|
11
|
-
|
|
12
|
-
type Serializable = primitive | Readonly<{
|
|
13
|
-
[key: string]: Serializable;
|
|
14
|
-
}> | ReadonlyArray<Serializable>;
|
|
15
|
-
type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
|
|
16
|
-
type Array<Element extends Serializable = Serializable> = ReadonlyArray<Element>;
|
|
17
|
-
|
|
18
|
-
type json_Array<Element extends Serializable = Serializable> = Array<Element>;
|
|
19
|
-
type json_Serializable = Serializable;
|
|
20
|
-
declare namespace json {
|
|
21
|
-
export {
|
|
22
|
-
json_Array as Array,
|
|
23
|
-
Object$1 as Object,
|
|
24
|
-
json_Serializable as Serializable,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
type Identified = {
|
|
29
|
-
id: string;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
declare const RELATION_TYPES: readonly ["1:1", "1:n", "n:n"];
|
|
33
|
-
type RelationType = typeof RELATION_TYPES[number];
|
|
34
|
-
type RelationData<CONTENT extends Object$1 | null = null, A extends string = `from`, B extends string = `to`> = {
|
|
35
|
-
contents: Object$1<string, CONTENT>;
|
|
36
|
-
relations: Object$1<string, string[]>;
|
|
37
|
-
relationType: RelationType;
|
|
38
|
-
a: A;
|
|
39
|
-
b: B;
|
|
40
|
-
};
|
|
41
|
-
type IsRelationDataOptions<CONTENT extends Object$1 | null = null, A extends string = `from`, B extends string = `to`> = {
|
|
42
|
-
from?: A;
|
|
43
|
-
to?: B;
|
|
44
|
-
isContent?: (json: Serializable) => json is CONTENT;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
type NullSafeUnion<Base, Extension> = Extension extends null ? Base : Base & Extension;
|
|
48
|
-
type NullSafeRest<MaybeArg, IfArg = MaybeArg> = MaybeArg extends null ? [] | [undefined] : [IfArg];
|
|
49
|
-
|
|
50
|
-
declare class Join<CONTENT extends Object$1 | null = null, A extends string = `from`, B extends string = `to`> implements RelationData<CONTENT, A, B> {
|
|
51
|
-
readonly relationType: `1:1` | `1:n` | `n:n`;
|
|
52
|
-
readonly a: A;
|
|
53
|
-
readonly b: B;
|
|
54
|
-
readonly relations: Record<string, string[]>;
|
|
55
|
-
readonly contents: Record<string, CONTENT>;
|
|
56
|
-
constructor(json?: Partial<RelationData<CONTENT, A, B>>);
|
|
57
|
-
toJSON(): RelationData<CONTENT, A, B>;
|
|
58
|
-
static fromJSON<CONTENT extends Object$1 | null, A extends string, B extends string>(json: Serializable, options?: IsRelationDataOptions<CONTENT, A, B>): Join<CONTENT, A, B>;
|
|
59
|
-
from<AA extends string>(newA: AA): Join<CONTENT, AA, B>;
|
|
60
|
-
to<BB extends string>(newB: BB): Join<CONTENT, A, BB>;
|
|
61
|
-
makeJsonInterface: (...params: CONTENT extends null ? [
|
|
62
|
-
] : [Refinement<unknown, CONTENT>]) => JsonInterface<Join<CONTENT, A, B>, RelationData<CONTENT, A, B>>;
|
|
63
|
-
getRelatedId(id: string): string | undefined;
|
|
64
|
-
getRelatedIds(id: string): string[];
|
|
65
|
-
getContent(idA: string, idB: string): CONTENT | undefined;
|
|
66
|
-
getRelationEntries(id: string): [string, CONTENT][];
|
|
67
|
-
getRelationRecord(id: string): Record<string, CONTENT>;
|
|
68
|
-
getRelation(id: string): NullSafeUnion<Identified, CONTENT> | undefined;
|
|
69
|
-
getRelations(id: string): NullSafeUnion<Identified, CONTENT>[];
|
|
70
|
-
setRelations(subject: {
|
|
71
|
-
[from in A]: string;
|
|
72
|
-
} | {
|
|
73
|
-
[to in B]: string;
|
|
74
|
-
}, relations: NullSafeUnion<Identified, CONTENT>[]): Join<CONTENT, A, B>;
|
|
75
|
-
set(relation: {
|
|
76
|
-
[key in A | B]: string;
|
|
77
|
-
}, ...rest: NullSafeRest<CONTENT>): Join<CONTENT, A, B>;
|
|
78
|
-
remove(relation: Partial<Record<A | B, string>>): Join<CONTENT, A, B>;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
type StoreCore = Pick<Store, `atoms` | `atomsThatAreDefault` | `operation` | `readonlySelectors` | `selectorAtoms` | `selectorGraph` | `selectors` | `timelineAtoms` | `timelines` | `transactions` | `valueMap`>;
|
|
82
|
-
interface Store {
|
|
83
|
-
atoms: Map<string, Atom<any>>;
|
|
84
|
-
atomsThatAreDefault: Set<string>;
|
|
85
|
-
readonlySelectors: Map<string, ReadonlySelector<any>>;
|
|
86
|
-
selectorAtoms: Join<null, `selectorKey`, `atomKey`>;
|
|
87
|
-
selectorGraph: Join<{
|
|
88
|
-
source: string;
|
|
89
|
-
}>;
|
|
90
|
-
selectors: Map<string, Selector<any>>;
|
|
91
|
-
timelineAtoms: Join<null, `timelineKey`, `atomKey`>;
|
|
92
|
-
timelines: Map<string, Timeline>;
|
|
93
|
-
transactions: Map<string, Transaction<any>>;
|
|
94
|
-
valueMap: Map<string, any>;
|
|
95
|
-
subject: {
|
|
96
|
-
atomCreation: Subject<AtomToken<unknown>>;
|
|
97
|
-
selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
98
|
-
transactionCreation: Subject<TransactionToken<ƒn>>;
|
|
99
|
-
timelineCreation: Subject<TimelineToken>;
|
|
100
|
-
operationStatus: Subject<OperationProgress>;
|
|
101
|
-
};
|
|
102
|
-
operation: OperationProgress;
|
|
103
|
-
transactionStatus: TransactionStatus<ƒn>;
|
|
104
|
-
config: {
|
|
105
|
-
name: string;
|
|
106
|
-
logger: Logger | null;
|
|
107
|
-
logger__INTERNAL: Logger;
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
declare const createStore: (name: string, store?: Store | null) => Store;
|
|
111
|
-
declare const IMPLICIT: {
|
|
112
|
-
STORE_INTERNAL: Store | undefined;
|
|
113
|
-
readonly STORE: Store;
|
|
114
|
-
};
|
|
115
|
-
declare const clearStore: (store?: Store) => void;
|
|
1
|
+
import { Transceiver, Subject, Store, TimelineAtomUpdate, TimelineSelectorUpdate, TimelineTransactionUpdate } from 'atom.io/internal';
|
|
2
|
+
import { Json, JsonInterface } from 'atom.io/json';
|
|
116
3
|
|
|
117
4
|
type Effectors<T> = {
|
|
118
5
|
setSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void;
|
|
@@ -127,108 +14,38 @@ type AtomOptions<T> = {
|
|
|
127
14
|
default: T | (() => T);
|
|
128
15
|
effects?: AtomEffect<T>[];
|
|
129
16
|
};
|
|
17
|
+
type MutableAtomOptions<T extends Transceiver<any>, J extends Json.Serializable> = JsonInterface<T, J> & Omit<AtomOptions<T>, `default`> & {
|
|
18
|
+
default: () => T;
|
|
19
|
+
mutable: true;
|
|
20
|
+
};
|
|
21
|
+
declare function atom<T extends Transceiver<any>, J extends Json.Serializable>(options: MutableAtomOptions<T, J>): MutableAtomToken<T, J>;
|
|
130
22
|
declare function atom<T>(options: AtomOptions<T>): AtomToken<T>;
|
|
131
|
-
type AtomFamilyOptions<T, K extends Serializable> = {
|
|
23
|
+
type AtomFamilyOptions<T, K extends Json.Serializable> = {
|
|
132
24
|
key: string;
|
|
133
25
|
default: T | ((key: K) => T);
|
|
134
26
|
effects?: (key: K) => AtomEffect<T>[];
|
|
135
27
|
};
|
|
136
|
-
type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomToken<T>) & {
|
|
28
|
+
type AtomFamily<T, K extends Json.Serializable = Json.Serializable> = ((key: K) => AtomToken<T>) & {
|
|
137
29
|
key: string;
|
|
138
30
|
type: `atom_family`;
|
|
139
31
|
subject: Subject<AtomToken<T>>;
|
|
140
32
|
};
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
type Atom<T> = {
|
|
144
|
-
key: string;
|
|
145
|
-
type: `atom`;
|
|
146
|
-
family?: FamilyMetadata;
|
|
147
|
-
subject: Subject<{
|
|
148
|
-
newValue: T;
|
|
149
|
-
oldValue: T;
|
|
150
|
-
}>;
|
|
151
|
-
default: T;
|
|
152
|
-
};
|
|
153
|
-
declare function atom__INTERNAL<T>(options: AtomOptions<T>, family?: FamilyMetadata, store?: Store): AtomToken<T>;
|
|
154
|
-
|
|
155
|
-
declare function atomFamily__INTERNAL<T, K extends Serializable>(options: AtomFamilyOptions<T, K>, store?: Store): AtomFamily<T, K>;
|
|
156
|
-
declare function readonlySelectorFamily__INTERNAL<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>, store?: Store): ReadonlySelectorFamily<T, K>;
|
|
157
|
-
declare function selectorFamily__INTERNAL<T, K extends Serializable>(options: SelectorFamilyOptions<T, K>, store?: Store): SelectorFamily<T, K>;
|
|
158
|
-
declare function selectorFamily__INTERNAL<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>, store?: Store): ReadonlySelectorFamily<T, K>;
|
|
159
|
-
|
|
160
|
-
declare const computeSelectorState: <T>(selector: ReadonlySelector<T> | Selector<T>) => T;
|
|
161
|
-
declare function lookup(key: string, store: Store): AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>;
|
|
162
|
-
declare function withdraw<T>(token: AtomToken<T>, store: Store): Atom<T> | null;
|
|
163
|
-
declare function withdraw<T>(token: SelectorToken<T>, store: Store): Selector<T> | null;
|
|
164
|
-
declare function withdraw<T>(token: StateToken<T>, store: Store): Atom<T> | Selector<T> | null;
|
|
165
|
-
declare function withdraw<T>(token: ReadonlySelectorToken<T>, store: Store): ReadonlySelector<T> | null;
|
|
166
|
-
declare function withdraw<T>(token: TransactionToken<T>, store: Store): Transaction<T extends ƒn ? T : never> | null;
|
|
167
|
-
declare function withdraw<T>(token: ReadonlySelectorToken<T> | StateToken<T>, store: Store): Atom<T> | ReadonlySelector<T> | Selector<T> | null;
|
|
168
|
-
declare function withdraw<T>(token: TimelineToken, store: Store): Timeline | null;
|
|
169
|
-
declare function deposit<T>(state: Atom<T>): AtomToken<T>;
|
|
170
|
-
declare function deposit<T>(state: Selector<T>): SelectorToken<T>;
|
|
171
|
-
declare function deposit<T>(state: Atom<T> | Selector<T>): StateToken<T>;
|
|
172
|
-
declare function deposit<T>(state: ReadonlySelector<T>): ReadonlySelectorToken<T>;
|
|
173
|
-
declare function deposit<T>(state: Transaction<T extends ƒn ? T : never>): TransactionToken<T>;
|
|
174
|
-
declare function deposit<T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>): ReadonlySelectorToken<T> | StateToken<T>;
|
|
175
|
-
declare const getState__INTERNAL: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, store?: Store) => T;
|
|
176
|
-
|
|
177
|
-
declare const isAtomDefault: (key: string, store?: Store) => boolean;
|
|
178
|
-
declare const markAtomAsDefault: (key: string, store?: Store) => void;
|
|
179
|
-
declare const markAtomAsNotDefault: (key: string, store?: Store) => void;
|
|
180
|
-
declare const isSelectorDefault: (key: string, store?: Store) => boolean;
|
|
181
|
-
|
|
182
|
-
type OperationProgress = {
|
|
183
|
-
open: false;
|
|
184
|
-
} | {
|
|
185
|
-
open: true;
|
|
186
|
-
done: Set<string>;
|
|
187
|
-
prev: Map<string, any>;
|
|
188
|
-
time: number;
|
|
189
|
-
token: StateToken<any>;
|
|
190
|
-
};
|
|
191
|
-
declare const openOperation: (token: StateToken<any>, store: Store) => void;
|
|
192
|
-
declare const closeOperation: (store: Store) => void;
|
|
193
|
-
declare const isDone: (key: string, store?: Store) => boolean;
|
|
194
|
-
declare const markDone: (key: string, store?: Store) => void;
|
|
195
|
-
declare const recallState: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, store?: Store) => T;
|
|
196
|
-
declare const cacheValue: (key: string, value: unknown, store?: Store) => void;
|
|
197
|
-
declare const evictCachedValue: (key: string, store?: Store) => void;
|
|
198
|
-
declare const readCachedValue: <T>(key: string, store?: Store) => T;
|
|
199
|
-
declare const isValueCached: (key: string, store?: Store) => boolean;
|
|
200
|
-
declare const storeAtom: (atom: Atom<any>, store?: Store) => void;
|
|
201
|
-
declare const storeSelector: (selector: Selector<any>, store?: Store) => void;
|
|
202
|
-
declare const storeReadonlySelector: (selector: ReadonlySelector<any>, store?: Store) => void;
|
|
203
|
-
declare const hasKeyBeenUsed: (key: string, store?: Store) => boolean;
|
|
204
|
-
|
|
205
|
-
type Selector<T> = {
|
|
206
|
-
key: string;
|
|
207
|
-
type: `selector`;
|
|
208
|
-
family?: FamilyMetadata;
|
|
209
|
-
install: (store: Store) => void;
|
|
210
|
-
subject: Subject<{
|
|
211
|
-
newValue: T;
|
|
212
|
-
oldValue: T;
|
|
213
|
-
}>;
|
|
214
|
-
get: () => T;
|
|
215
|
-
set: (newValue: T | ((oldValue: T) => T)) => void;
|
|
33
|
+
type MutableAtomFamilyOptions<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable> = AtomFamilyOptions<T, K> & JsonInterface<T, J> & {
|
|
34
|
+
mutable: true;
|
|
216
35
|
};
|
|
217
|
-
type
|
|
218
|
-
key: string
|
|
219
|
-
type: `
|
|
220
|
-
|
|
221
|
-
install: (store: Store) => void;
|
|
222
|
-
subject: Subject<{
|
|
223
|
-
newValue: T;
|
|
224
|
-
oldValue: T;
|
|
225
|
-
}>;
|
|
226
|
-
get: () => T;
|
|
36
|
+
type MutableAtomFamily<Core extends Transceiver<any>, SerializableCore extends Json.Serializable, Key extends Json.Serializable> = JsonInterface<Core, SerializableCore> & ((key: Key) => MutableAtomToken<Core, SerializableCore>) & {
|
|
37
|
+
key: `${string}::mutable`;
|
|
38
|
+
type: `atom_family`;
|
|
39
|
+
subject: Subject<MutableAtomToken<Core, SerializableCore>>;
|
|
227
40
|
};
|
|
228
|
-
declare function
|
|
229
|
-
declare function
|
|
41
|
+
declare function atomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable>(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamily<T, J, K>;
|
|
42
|
+
declare function atomFamily<T, K extends Json.Serializable>(options: AtomFamilyOptions<T, K>): AtomFamily<T, K>;
|
|
230
43
|
|
|
231
|
-
declare const
|
|
44
|
+
declare const NO_OP: () => void;
|
|
45
|
+
type Logger = Pick<Console, `error` | `info` | `warn`>;
|
|
46
|
+
declare const LOG_LEVELS: ReadonlyArray<keyof Logger>;
|
|
47
|
+
declare const setLogLevel: (preferredLevel: `error` | `info` | `warn` | null, store?: Store) => void;
|
|
48
|
+
declare const useLogger: (logger: Logger, store?: Store) => void;
|
|
232
49
|
|
|
233
50
|
type TransactionToken<_> = {
|
|
234
51
|
key: string;
|
|
@@ -256,249 +73,6 @@ type TransactionIO<Token extends TransactionToken<any>> = Token extends Transact
|
|
|
256
73
|
declare function transaction<ƒ extends ƒn>(options: TransactionOptions<ƒ>): TransactionToken<ƒ>;
|
|
257
74
|
declare const runTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, store?: Store) => (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
258
75
|
|
|
259
|
-
declare const registerSelector: (selectorKey: string, store?: Store) => Transactors;
|
|
260
|
-
|
|
261
|
-
declare const traceSelectorAtoms: (selectorKey: string, dependency: ReadonlySelectorToken<unknown> | StateToken<unknown>, store: Store) => AtomToken<unknown>[];
|
|
262
|
-
declare const traceAllSelectorAtoms: (selectorKey: string, store: Store) => AtomToken<unknown>[];
|
|
263
|
-
|
|
264
|
-
declare const updateSelectorAtoms: (selectorKey: string, dependency: ReadonlySelectorToken<unknown> | StateToken<unknown>, store: Store) => void;
|
|
265
|
-
|
|
266
|
-
declare const evictDownStream: <T>(state: Atom<T>, store?: Store) => void;
|
|
267
|
-
declare const setAtomState: <T>(atom: Atom<T>, next: T | ((oldValue: T) => T), store?: Store) => void;
|
|
268
|
-
declare const setSelectorState: <T>(selector: Selector<T>, next: T | ((oldValue: T) => T), store?: Store) => void;
|
|
269
|
-
declare const setState__INTERNAL: <T>(state: Atom<T> | Selector<T>, value: T | ((oldValue: T) => T), store?: Store) => void;
|
|
270
|
-
|
|
271
|
-
type Subscriber<T> = (value: T) => void;
|
|
272
|
-
declare class Subject<T> {
|
|
273
|
-
subscribers: Subscriber<T>[];
|
|
274
|
-
subscribe(subscriber: Subscriber<T>): {
|
|
275
|
-
unsubscribe: () => void;
|
|
276
|
-
};
|
|
277
|
-
private unsubscribe;
|
|
278
|
-
next(value: T): void;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
declare const prepareUpdate: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, store: Store) => StateUpdate<T>;
|
|
282
|
-
declare const stowUpdate: <T>(state: Atom<T>, update: StateUpdate<T>, store: Store) => void;
|
|
283
|
-
declare const emitUpdate: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, update: StateUpdate<T>, store: Store) => void;
|
|
284
|
-
declare const subscribeToRootAtoms: <T>(state: ReadonlySelector<T> | Selector<T>, store: Store) => {
|
|
285
|
-
unsubscribe: () => void;
|
|
286
|
-
}[] | null;
|
|
287
|
-
|
|
288
|
-
declare const redo__INTERNAL: (token: TimelineToken, store?: Store) => void;
|
|
289
|
-
declare const undo__INTERNAL: (token: TimelineToken, store?: Store) => void;
|
|
290
|
-
|
|
291
|
-
type TimelineAtomUpdate = StateUpdate<unknown> & {
|
|
292
|
-
key: string;
|
|
293
|
-
type: `atom_update`;
|
|
294
|
-
timestamp: number;
|
|
295
|
-
};
|
|
296
|
-
type TimelineSelectorUpdate = {
|
|
297
|
-
key: string;
|
|
298
|
-
type: `selector_update`;
|
|
299
|
-
timestamp: number;
|
|
300
|
-
atomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[];
|
|
301
|
-
};
|
|
302
|
-
type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
|
|
303
|
-
key: string;
|
|
304
|
-
type: `transaction_update`;
|
|
305
|
-
timestamp: number;
|
|
306
|
-
};
|
|
307
|
-
type Timeline = {
|
|
308
|
-
key: string;
|
|
309
|
-
at: number;
|
|
310
|
-
timeTraveling: `into_future` | `into_past` | null;
|
|
311
|
-
history: TimelineUpdate[];
|
|
312
|
-
selectorTime: number | null;
|
|
313
|
-
transactionKey: string | null;
|
|
314
|
-
install: (store: Store) => void;
|
|
315
|
-
subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
|
|
316
|
-
};
|
|
317
|
-
declare function timeline__INTERNAL(options: TimelineOptions, store?: Store, data?: Timeline | null): TimelineToken;
|
|
318
|
-
|
|
319
|
-
type Transaction<ƒ extends ƒn> = {
|
|
320
|
-
key: string;
|
|
321
|
-
type: `transaction`;
|
|
322
|
-
install: (store: Store) => void;
|
|
323
|
-
subject: Subject<TransactionUpdate<ƒ>>;
|
|
324
|
-
run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
325
|
-
};
|
|
326
|
-
declare function transaction__INTERNAL<ƒ extends ƒn>(options: TransactionOptions<ƒ>, store?: Store): TransactionToken<ƒ>;
|
|
327
|
-
declare const target: (store?: Store) => StoreCore;
|
|
328
|
-
|
|
329
|
-
declare const abortTransaction: (store: Store) => void;
|
|
330
|
-
|
|
331
|
-
declare const applyTransaction: <ƒ extends ƒn>(output: ReturnType<ƒ>, store: Store) => void;
|
|
332
|
-
|
|
333
|
-
declare const buildTransaction: (key: string, params: any[], store: Store) => void;
|
|
334
|
-
|
|
335
|
-
declare const redoTransactionUpdate: <ƒ extends ƒn>(update: TransactionUpdate<ƒ>, store: Store) => void;
|
|
336
|
-
|
|
337
|
-
declare const undoTransactionUpdate: <ƒ extends ƒn>(update: TransactionUpdate<ƒ>, store: Store) => void;
|
|
338
|
-
|
|
339
|
-
declare const TRANSACTION_PHASES: readonly ["idle", "building", "applying"];
|
|
340
|
-
type TransactionPhase = typeof TRANSACTION_PHASES[number];
|
|
341
|
-
type TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdate<ƒ> & {
|
|
342
|
-
phase: `applying` | `building`;
|
|
343
|
-
time: number;
|
|
344
|
-
core: StoreCore;
|
|
345
|
-
};
|
|
346
|
-
type TransactionIdle = {
|
|
347
|
-
phase: `idle`;
|
|
348
|
-
};
|
|
349
|
-
type TransactionStatus<ƒ extends ƒn> = TransactionIdle | TransactionUpdateInProgress<ƒ>;
|
|
350
|
-
|
|
351
|
-
type index_Atom<T> = Atom<T>;
|
|
352
|
-
declare const index_IMPLICIT: typeof IMPLICIT;
|
|
353
|
-
type index_OperationProgress = OperationProgress;
|
|
354
|
-
type index_ReadonlySelector<T> = ReadonlySelector<T>;
|
|
355
|
-
type index_Selector<T> = Selector<T>;
|
|
356
|
-
type index_Store = Store;
|
|
357
|
-
type index_StoreCore = StoreCore;
|
|
358
|
-
type index_Subject<T> = Subject<T>;
|
|
359
|
-
declare const index_Subject: typeof Subject;
|
|
360
|
-
declare const index_TRANSACTION_PHASES: typeof TRANSACTION_PHASES;
|
|
361
|
-
type index_Timeline = Timeline;
|
|
362
|
-
type index_TimelineAtomUpdate = TimelineAtomUpdate;
|
|
363
|
-
type index_TimelineSelectorUpdate = TimelineSelectorUpdate;
|
|
364
|
-
type index_TimelineTransactionUpdate = TimelineTransactionUpdate;
|
|
365
|
-
type index_Transaction<ƒ extends ƒn> = Transaction<ƒ>;
|
|
366
|
-
type index_TransactionIdle = TransactionIdle;
|
|
367
|
-
type index_TransactionPhase = TransactionPhase;
|
|
368
|
-
type index_TransactionStatus<ƒ extends ƒn> = TransactionStatus<ƒ>;
|
|
369
|
-
type index_TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdateInProgress<ƒ>;
|
|
370
|
-
declare const index_abortTransaction: typeof abortTransaction;
|
|
371
|
-
declare const index_applyTransaction: typeof applyTransaction;
|
|
372
|
-
declare const index_atomFamily__INTERNAL: typeof atomFamily__INTERNAL;
|
|
373
|
-
declare const index_atom__INTERNAL: typeof atom__INTERNAL;
|
|
374
|
-
declare const index_buildTransaction: typeof buildTransaction;
|
|
375
|
-
declare const index_cacheValue: typeof cacheValue;
|
|
376
|
-
declare const index_clearStore: typeof clearStore;
|
|
377
|
-
declare const index_closeOperation: typeof closeOperation;
|
|
378
|
-
declare const index_computeSelectorState: typeof computeSelectorState;
|
|
379
|
-
declare const index_createStore: typeof createStore;
|
|
380
|
-
declare const index_deposit: typeof deposit;
|
|
381
|
-
declare const index_emitUpdate: typeof emitUpdate;
|
|
382
|
-
declare const index_evictCachedValue: typeof evictCachedValue;
|
|
383
|
-
declare const index_evictDownStream: typeof evictDownStream;
|
|
384
|
-
declare const index_getState__INTERNAL: typeof getState__INTERNAL;
|
|
385
|
-
declare const index_hasKeyBeenUsed: typeof hasKeyBeenUsed;
|
|
386
|
-
declare const index_isAtomDefault: typeof isAtomDefault;
|
|
387
|
-
declare const index_isDone: typeof isDone;
|
|
388
|
-
declare const index_isSelectorDefault: typeof isSelectorDefault;
|
|
389
|
-
declare const index_isValueCached: typeof isValueCached;
|
|
390
|
-
declare const index_lookup: typeof lookup;
|
|
391
|
-
declare const index_lookupSelectorSources: typeof lookupSelectorSources;
|
|
392
|
-
declare const index_markAtomAsDefault: typeof markAtomAsDefault;
|
|
393
|
-
declare const index_markAtomAsNotDefault: typeof markAtomAsNotDefault;
|
|
394
|
-
declare const index_markDone: typeof markDone;
|
|
395
|
-
declare const index_openOperation: typeof openOperation;
|
|
396
|
-
declare const index_prepareUpdate: typeof prepareUpdate;
|
|
397
|
-
declare const index_readCachedValue: typeof readCachedValue;
|
|
398
|
-
declare const index_readonlySelectorFamily__INTERNAL: typeof readonlySelectorFamily__INTERNAL;
|
|
399
|
-
declare const index_recallState: typeof recallState;
|
|
400
|
-
declare const index_redoTransactionUpdate: typeof redoTransactionUpdate;
|
|
401
|
-
declare const index_redo__INTERNAL: typeof redo__INTERNAL;
|
|
402
|
-
declare const index_registerSelector: typeof registerSelector;
|
|
403
|
-
declare const index_selectorFamily__INTERNAL: typeof selectorFamily__INTERNAL;
|
|
404
|
-
declare const index_selector__INTERNAL: typeof selector__INTERNAL;
|
|
405
|
-
declare const index_setAtomState: typeof setAtomState;
|
|
406
|
-
declare const index_setSelectorState: typeof setSelectorState;
|
|
407
|
-
declare const index_setState__INTERNAL: typeof setState__INTERNAL;
|
|
408
|
-
declare const index_storeAtom: typeof storeAtom;
|
|
409
|
-
declare const index_storeReadonlySelector: typeof storeReadonlySelector;
|
|
410
|
-
declare const index_storeSelector: typeof storeSelector;
|
|
411
|
-
declare const index_stowUpdate: typeof stowUpdate;
|
|
412
|
-
declare const index_subscribeToRootAtoms: typeof subscribeToRootAtoms;
|
|
413
|
-
declare const index_target: typeof target;
|
|
414
|
-
declare const index_timeline__INTERNAL: typeof timeline__INTERNAL;
|
|
415
|
-
declare const index_traceAllSelectorAtoms: typeof traceAllSelectorAtoms;
|
|
416
|
-
declare const index_traceSelectorAtoms: typeof traceSelectorAtoms;
|
|
417
|
-
declare const index_transaction__INTERNAL: typeof transaction__INTERNAL;
|
|
418
|
-
declare const index_undoTransactionUpdate: typeof undoTransactionUpdate;
|
|
419
|
-
declare const index_undo__INTERNAL: typeof undo__INTERNAL;
|
|
420
|
-
declare const index_updateSelectorAtoms: typeof updateSelectorAtoms;
|
|
421
|
-
declare const index_withdraw: typeof withdraw;
|
|
422
|
-
declare namespace index {
|
|
423
|
-
export {
|
|
424
|
-
index_Atom as Atom,
|
|
425
|
-
index_IMPLICIT as IMPLICIT,
|
|
426
|
-
index_OperationProgress as OperationProgress,
|
|
427
|
-
index_ReadonlySelector as ReadonlySelector,
|
|
428
|
-
index_Selector as Selector,
|
|
429
|
-
index_Store as Store,
|
|
430
|
-
index_StoreCore as StoreCore,
|
|
431
|
-
index_Subject as Subject,
|
|
432
|
-
index_TRANSACTION_PHASES as TRANSACTION_PHASES,
|
|
433
|
-
index_Timeline as Timeline,
|
|
434
|
-
index_TimelineAtomUpdate as TimelineAtomUpdate,
|
|
435
|
-
index_TimelineSelectorUpdate as TimelineSelectorUpdate,
|
|
436
|
-
index_TimelineTransactionUpdate as TimelineTransactionUpdate,
|
|
437
|
-
index_Transaction as Transaction,
|
|
438
|
-
index_TransactionIdle as TransactionIdle,
|
|
439
|
-
index_TransactionPhase as TransactionPhase,
|
|
440
|
-
index_TransactionStatus as TransactionStatus,
|
|
441
|
-
index_TransactionUpdateInProgress as TransactionUpdateInProgress,
|
|
442
|
-
index_abortTransaction as abortTransaction,
|
|
443
|
-
index_applyTransaction as applyTransaction,
|
|
444
|
-
index_atomFamily__INTERNAL as atomFamily__INTERNAL,
|
|
445
|
-
index_atom__INTERNAL as atom__INTERNAL,
|
|
446
|
-
index_buildTransaction as buildTransaction,
|
|
447
|
-
index_cacheValue as cacheValue,
|
|
448
|
-
index_clearStore as clearStore,
|
|
449
|
-
index_closeOperation as closeOperation,
|
|
450
|
-
index_computeSelectorState as computeSelectorState,
|
|
451
|
-
index_createStore as createStore,
|
|
452
|
-
index_deposit as deposit,
|
|
453
|
-
index_emitUpdate as emitUpdate,
|
|
454
|
-
index_evictCachedValue as evictCachedValue,
|
|
455
|
-
index_evictDownStream as evictDownStream,
|
|
456
|
-
index_getState__INTERNAL as getState__INTERNAL,
|
|
457
|
-
index_hasKeyBeenUsed as hasKeyBeenUsed,
|
|
458
|
-
index_isAtomDefault as isAtomDefault,
|
|
459
|
-
index_isDone as isDone,
|
|
460
|
-
index_isSelectorDefault as isSelectorDefault,
|
|
461
|
-
index_isValueCached as isValueCached,
|
|
462
|
-
index_lookup as lookup,
|
|
463
|
-
index_lookupSelectorSources as lookupSelectorSources,
|
|
464
|
-
index_markAtomAsDefault as markAtomAsDefault,
|
|
465
|
-
index_markAtomAsNotDefault as markAtomAsNotDefault,
|
|
466
|
-
index_markDone as markDone,
|
|
467
|
-
index_openOperation as openOperation,
|
|
468
|
-
index_prepareUpdate as prepareUpdate,
|
|
469
|
-
index_readCachedValue as readCachedValue,
|
|
470
|
-
index_readonlySelectorFamily__INTERNAL as readonlySelectorFamily__INTERNAL,
|
|
471
|
-
index_recallState as recallState,
|
|
472
|
-
index_redoTransactionUpdate as redoTransactionUpdate,
|
|
473
|
-
index_redo__INTERNAL as redo__INTERNAL,
|
|
474
|
-
index_registerSelector as registerSelector,
|
|
475
|
-
index_selectorFamily__INTERNAL as selectorFamily__INTERNAL,
|
|
476
|
-
index_selector__INTERNAL as selector__INTERNAL,
|
|
477
|
-
index_setAtomState as setAtomState,
|
|
478
|
-
index_setSelectorState as setSelectorState,
|
|
479
|
-
index_setState__INTERNAL as setState__INTERNAL,
|
|
480
|
-
index_storeAtom as storeAtom,
|
|
481
|
-
index_storeReadonlySelector as storeReadonlySelector,
|
|
482
|
-
index_storeSelector as storeSelector,
|
|
483
|
-
index_stowUpdate as stowUpdate,
|
|
484
|
-
index_subscribeToRootAtoms as subscribeToRootAtoms,
|
|
485
|
-
index_target as target,
|
|
486
|
-
index_timeline__INTERNAL as timeline__INTERNAL,
|
|
487
|
-
index_traceAllSelectorAtoms as traceAllSelectorAtoms,
|
|
488
|
-
index_traceSelectorAtoms as traceSelectorAtoms,
|
|
489
|
-
index_transaction__INTERNAL as transaction__INTERNAL,
|
|
490
|
-
index_undoTransactionUpdate as undoTransactionUpdate,
|
|
491
|
-
index_undo__INTERNAL as undo__INTERNAL,
|
|
492
|
-
index_updateSelectorAtoms as updateSelectorAtoms,
|
|
493
|
-
index_withdraw as withdraw,
|
|
494
|
-
};
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
type Logger = Pick<Console, `error` | `info` | `warn`>;
|
|
498
|
-
declare const LOG_LEVELS: ReadonlyArray<keyof Logger>;
|
|
499
|
-
declare const setLogLevel: (preferredLevel: `error` | `info` | `warn` | null, store?: Store) => void;
|
|
500
|
-
declare const useLogger: (logger: Logger, store?: Store) => void;
|
|
501
|
-
|
|
502
76
|
type SelectorOptions<T> = {
|
|
503
77
|
key: string;
|
|
504
78
|
get: Read<() => T>;
|
|
@@ -510,30 +84,29 @@ type ReadonlySelectorOptions<T> = {
|
|
|
510
84
|
};
|
|
511
85
|
declare function selector<T>(options: SelectorOptions<T>): SelectorToken<T>;
|
|
512
86
|
declare function selector<T>(options: ReadonlySelectorOptions<T>): ReadonlySelectorToken<T>;
|
|
513
|
-
type SelectorFamilyOptions<T, K extends Serializable> = {
|
|
87
|
+
type SelectorFamilyOptions<T, K extends Json.Serializable> = {
|
|
514
88
|
key: string;
|
|
515
89
|
get: (key: K) => Read<() => T>;
|
|
516
90
|
set: (key: K) => Write<(newValue: T) => void>;
|
|
517
91
|
};
|
|
518
|
-
type ReadonlySelectorFamilyOptions<T, K extends Serializable> = {
|
|
92
|
+
type ReadonlySelectorFamilyOptions<T, K extends Json.Serializable> = {
|
|
519
93
|
key: string;
|
|
520
94
|
get: (key: K) => Read<() => T>;
|
|
521
95
|
};
|
|
522
|
-
type SelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => SelectorToken<T>) & {
|
|
96
|
+
type SelectorFamily<T, K extends Json.Serializable = Json.Serializable> = ((key: K) => SelectorToken<T>) & {
|
|
523
97
|
key: string;
|
|
524
98
|
type: `selector_family`;
|
|
525
99
|
subject: Subject<SelectorToken<T>>;
|
|
526
100
|
};
|
|
527
|
-
type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
|
|
101
|
+
type ReadonlySelectorFamily<T, K extends Json.Serializable = Json.Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
|
|
528
102
|
key: string;
|
|
529
103
|
type: `readonly_selector_family`;
|
|
530
104
|
subject: Subject<ReadonlySelectorToken<T>>;
|
|
531
105
|
};
|
|
532
|
-
declare function selectorFamily<T, K extends Serializable>(options: SelectorFamilyOptions<T, K>): SelectorFamily<T, K>;
|
|
533
|
-
declare function selectorFamily<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamily<T, K>;
|
|
106
|
+
declare function selectorFamily<T, K extends Json.Serializable>(options: SelectorFamilyOptions<T, K>): SelectorFamily<T, K>;
|
|
107
|
+
declare function selectorFamily<T, K extends Json.Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamily<T, K>;
|
|
534
108
|
|
|
535
|
-
|
|
536
|
-
declare const silo: (name: string, fromStore?: Store | null) => {
|
|
109
|
+
declare class Silo {
|
|
537
110
|
store: Store;
|
|
538
111
|
atom: typeof atom;
|
|
539
112
|
atomFamily: typeof atomFamily;
|
|
@@ -546,7 +119,8 @@ declare const silo: (name: string, fromStore?: Store | null) => {
|
|
|
546
119
|
subscribe: typeof subscribe;
|
|
547
120
|
undo: typeof undo;
|
|
548
121
|
redo: typeof redo;
|
|
549
|
-
|
|
122
|
+
constructor(name: string, fromStore?: Store | null);
|
|
123
|
+
}
|
|
550
124
|
|
|
551
125
|
type StateUpdate<T> = {
|
|
552
126
|
newValue: T;
|
|
@@ -554,12 +128,13 @@ type StateUpdate<T> = {
|
|
|
554
128
|
};
|
|
555
129
|
type KeyedStateUpdate<T> = StateUpdate<T> & {
|
|
556
130
|
key: string;
|
|
131
|
+
family?: FamilyMetadata;
|
|
557
132
|
};
|
|
558
133
|
type UpdateHandler<T> = (update: StateUpdate<T>) => void;
|
|
559
|
-
declare
|
|
134
|
+
declare function subscribe<T>(token: ReadonlySelectorToken<T> | StateToken<T>, handleUpdate: UpdateHandler<T>, key?: string, store?: Store): () => void;
|
|
560
135
|
type TransactionUpdateHandler<ƒ extends ƒn> = (data: TransactionUpdate<ƒ>) => void;
|
|
561
|
-
declare const subscribeToTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, handleUpdate: TransactionUpdateHandler<ƒ>, store?: Store) => (() => void);
|
|
562
|
-
declare const subscribeToTimeline: (token: TimelineToken, handleUpdate: (update: TimelineUpdate | `redo` | `undo`) => void, store?: Store) => (() => void);
|
|
136
|
+
declare const subscribeToTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, handleUpdate: TransactionUpdateHandler<ƒ>, key?: string, store?: Store) => (() => void);
|
|
137
|
+
declare const subscribeToTimeline: (token: TimelineToken, handleUpdate: (update: TimelineUpdate | `redo` | `undo`) => void, key?: string, store?: Store) => (() => void);
|
|
563
138
|
|
|
564
139
|
type TimelineToken = {
|
|
565
140
|
key: string;
|
|
@@ -574,12 +149,17 @@ declare const timeline: (options: TimelineOptions) => TimelineToken;
|
|
|
574
149
|
declare const redo: (token: TimelineToken) => void;
|
|
575
150
|
declare const undo: (token: TimelineToken) => void;
|
|
576
151
|
|
|
152
|
+
type ƒn = (...parameters: any[]) => any;
|
|
577
153
|
type AtomToken<_> = {
|
|
578
154
|
key: string;
|
|
579
155
|
type: `atom`;
|
|
580
156
|
family?: FamilyMetadata;
|
|
581
157
|
__brand?: _;
|
|
582
158
|
};
|
|
159
|
+
interface MutableAtomToken<T extends Transceiver<any>, J extends Json.Serializable> extends AtomToken<T> {
|
|
160
|
+
__asJSON?: J;
|
|
161
|
+
__update?: T extends Transceiver<infer Update> ? Update : never;
|
|
162
|
+
}
|
|
583
163
|
type SelectorToken<_> = {
|
|
584
164
|
key: string;
|
|
585
165
|
type: `selector`;
|
|
@@ -597,8 +177,9 @@ type FamilyMetadata = {
|
|
|
597
177
|
key: string;
|
|
598
178
|
subKey: string;
|
|
599
179
|
};
|
|
180
|
+
declare const capitalize: (str: string) => string;
|
|
600
181
|
declare const getState: <T>(token: ReadonlySelectorToken<T> | StateToken<T>, store?: Store) => T;
|
|
601
182
|
declare const setState: <T, New extends T>(token: StateToken<T>, value: New | ((oldValue: T) => New), store?: Store) => void;
|
|
602
183
|
declare const isDefault: (token: ReadonlySelectorToken<unknown> | StateToken<unknown>, store?: Store) => boolean;
|
|
603
184
|
|
|
604
|
-
export { AtomEffect, AtomFamily, AtomFamilyOptions, AtomOptions, AtomToken, Effectors, FamilyMetadata,
|
|
185
|
+
export { AtomEffect, AtomFamily, AtomFamilyOptions, AtomOptions, AtomToken, Effectors, FamilyMetadata, KeyedStateUpdate, LOG_LEVELS, Logger, MutableAtomFamily, MutableAtomFamilyOptions, MutableAtomOptions, MutableAtomToken, NO_OP, Read, ReadonlySelectorFamily, ReadonlySelectorFamilyOptions, ReadonlySelectorOptions, ReadonlySelectorToken, ReadonlyTransactors, SelectorFamily, SelectorFamilyOptions, SelectorOptions, SelectorToken, Silo, StateToken, StateUpdate, TimelineOptions, TimelineToken, TimelineUpdate, TransactionIO, TransactionOptions, TransactionToken, TransactionUpdate, Transactors, UpdateHandler, Write, atom, atomFamily, capitalize, getState, isDefault, redo, runTransaction, selector, selectorFamily, setLogLevel, setState, subscribe, subscribeToTimeline, subscribeToTransaction, timeline, transaction, undo, useLogger, ƒn };
|