atom.io 0.6.8 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +226 -258
- package/dist/index.d.ts +226 -258
- package/dist/index.js +28 -1917
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -1877
- package/dist/index.mjs.map +1 -1
- package/introspection/dist/index.d.mts +117 -171
- package/introspection/dist/index.d.ts +117 -171
- package/introspection/dist/index.js +6 -346
- package/introspection/dist/index.js.map +1 -1
- package/introspection/dist/index.mjs +5 -324
- package/introspection/dist/index.mjs.map +1 -1
- package/json/dist/index.d.mts +32 -1
- package/json/dist/index.d.ts +32 -1
- package/json/dist/index.js +31 -48
- package/json/dist/index.js.map +1 -1
- package/json/dist/index.mjs +6 -14
- package/json/dist/index.mjs.map +1 -1
- package/package.json +22 -14
- package/react/dist/index.js +34 -83
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs +7 -43
- package/react/dist/index.mjs.map +1 -1
- package/react-devtools/dist/index.css +1 -50
- package/react-devtools/dist/index.css.map +1 -1
- package/react-devtools/dist/index.d.mts +124 -188
- package/react-devtools/dist/index.d.ts +124 -188
- package/react-devtools/dist/index.js +56 -4674
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/index.mjs +19 -4642
- package/react-devtools/dist/index.mjs.map +1 -1
- package/realtime/dist/index.d.mts +1 -3
- package/realtime/dist/index.d.ts +1 -3
- package/realtime/dist/index.js +26 -184
- package/realtime/dist/index.js.map +1 -1
- package/realtime/dist/index.mjs +4 -148
- package/realtime/dist/index.mjs.map +1 -1
- package/realtime-react/dist/index.d.mts +2 -4
- package/realtime-react/dist/index.d.ts +2 -4
- package/realtime-react/dist/index.js +41 -214
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/dist/index.mjs +9 -169
- package/realtime-react/dist/index.mjs.map +1 -1
- package/src/atom.ts +4 -3
- package/src/index.ts +12 -9
- package/src/logger.ts +5 -5
- package/src/selector.ts +3 -3
- package/src/silo.ts +36 -39
- package/src/subscribe.ts +24 -19
- package/src/timeline.ts +9 -4
- package/src/transaction.ts +3 -4
- 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/is-default.ts +0 -35
- package/src/internal/operation.ts +0 -139
- package/src/internal/selector/create-read-write-selector.ts +0 -68
- package/src/internal/selector/create-readonly-selector.ts +0 -48
- package/src/internal/selector/index.ts +0 -4
- package/src/internal/selector/lookup-selector-sources.ts +0 -16
- package/src/internal/selector/register-selector.ts +0 -57
- package/src/internal/selector/trace-selector-atoms.ts +0 -43
- package/src/internal/selector/update-selector-atoms.ts +0 -33
- 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/time-travel-internal.ts +0 -91
- package/src/internal/timeline/add-atom-to-timeline.ts +0 -168
- package/src/internal/timeline/index.ts +0 -1
- package/src/internal/timeline-internal.ts +0 -107
- package/src/internal/transaction/abort-transaction.ts +0 -12
- package/src/internal/transaction/apply-transaction.ts +0 -57
- package/src/internal/transaction/build-transaction.ts +0 -33
- package/src/internal/transaction/index.ts +0 -25
- package/src/internal/transaction/redo-transaction.ts +0 -23
- package/src/internal/transaction/undo-transaction.ts +0 -23
- package/src/internal/transaction-internal.ts +0 -61
- package/src/introspection/attach-atom-index.ts +0 -73
- package/src/introspection/attach-introspection-states.ts +0 -42
- package/src/introspection/attach-selector-index.ts +0 -77
- package/src/introspection/attach-timeline-family.ts +0 -59
- package/src/introspection/attach-timeline-index.ts +0 -36
- package/src/introspection/attach-transaction-index.ts +0 -38
- package/src/introspection/attach-transaction-logs.ts +0 -40
- package/src/introspection/index.ts +0 -20
- package/src/json/index.ts +0 -1
- package/src/json/select-json.ts +0 -18
- package/src/react/index.ts +0 -2
- package/src/react/store-context.tsx +0 -13
- package/src/react/store-hooks.ts +0 -47
- package/src/react-devtools/AtomIODevtools.tsx +0 -107
- package/src/react-devtools/Button.tsx +0 -24
- package/src/react-devtools/StateEditor.tsx +0 -74
- package/src/react-devtools/StateIndex.tsx +0 -156
- package/src/react-devtools/TimelineIndex.tsx +0 -92
- package/src/react-devtools/TransactionIndex.tsx +0 -70
- package/src/react-devtools/Updates.tsx +0 -145
- package/src/react-devtools/devtools.scss +0 -310
- package/src/react-devtools/index.ts +0 -72
- 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-context.tsx +0 -30
- 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/realtime-testing/index.ts +0 -1
- package/src/realtime-testing/setup-realtime-test.tsx +0 -159
- 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/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import { Refinement } from 'fp-ts/Refinement';
|
|
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
1
|
type primitive = boolean | number | string | null;
|
|
11
2
|
|
|
12
3
|
type Serializable = primitive | Readonly<{
|
|
@@ -25,159 +16,63 @@ declare namespace json {
|
|
|
25
16
|
};
|
|
26
17
|
}
|
|
27
18
|
|
|
28
|
-
type
|
|
29
|
-
|
|
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
|
-
}
|
|
19
|
+
type Refinement<Unrefined, Refined extends Unrefined> = (value: Unrefined) => value is Refined;
|
|
20
|
+
type Cardinality = `1:1` | `1:n` | `n:n`;
|
|
80
21
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
transactionStatus: TransactionStatus<ƒn>;
|
|
104
|
-
config: {
|
|
105
|
-
name: string;
|
|
106
|
-
logger: Logger | null;
|
|
107
|
-
logger__INTERNAL: Logger;
|
|
22
|
+
interface JunctionEntries<Content extends Object$1 | null> extends Object$1 {
|
|
23
|
+
readonly relations: [string, string[]][];
|
|
24
|
+
readonly contents: [string, Content][];
|
|
25
|
+
}
|
|
26
|
+
interface JunctionSchema<ASide extends string, BSide extends string> extends Object$1 {
|
|
27
|
+
readonly between: [a: ASide, b: BSide];
|
|
28
|
+
readonly cardinality: Cardinality;
|
|
29
|
+
}
|
|
30
|
+
type JunctionAdvancedConfiguration<Content extends Object$1 | null> = {
|
|
31
|
+
externalStore?: (Content extends null ? {
|
|
32
|
+
getContent?: undefined;
|
|
33
|
+
setContent?: undefined;
|
|
34
|
+
deleteContent?: undefined;
|
|
35
|
+
} : {
|
|
36
|
+
getContent: (contentKey: string) => Content | undefined;
|
|
37
|
+
setContent: (contentKey: string, content: Content) => void;
|
|
38
|
+
deleteContent: (g: any) => void;
|
|
39
|
+
}) & {
|
|
40
|
+
addRelation: (a: string, b: string) => void;
|
|
41
|
+
deleteRelation: (a: string, b: string) => void;
|
|
42
|
+
getRelatedKeys: (key: string) => Set<string> | undefined;
|
|
43
|
+
has: (a: string, b?: string) => boolean;
|
|
108
44
|
};
|
|
45
|
+
isContent?: Refinement<unknown, Content>;
|
|
46
|
+
makeContentKey?: (a: string, b: string) => string;
|
|
47
|
+
};
|
|
48
|
+
type JunctionJSON<ASide extends string, BSide extends string, Content extends Object$1 | null> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>;
|
|
49
|
+
declare class Junction<ASide extends string, BSide extends string, Content extends Object$1 | null = null> {
|
|
50
|
+
readonly a: ASide;
|
|
51
|
+
readonly b: BSide;
|
|
52
|
+
readonly cardinality: Cardinality;
|
|
53
|
+
readonly relations: Map<string, Set<string>>;
|
|
54
|
+
readonly contents: Map<string, Content>;
|
|
55
|
+
isContent: Refinement<unknown, Content> | null;
|
|
56
|
+
makeContentKey: (a: string, b: string) => string;
|
|
57
|
+
getRelatedKeys(key: string): Set<string> | undefined;
|
|
58
|
+
protected addRelation(a: string, b: string): void;
|
|
59
|
+
protected deleteRelation(a: string, b: string): void;
|
|
60
|
+
protected getContentInternal(contentKey: string): Content | undefined;
|
|
61
|
+
protected setContent(contentKey: string, content: Content): void;
|
|
62
|
+
protected deleteContent(contentKey: string): void;
|
|
63
|
+
constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<Content>>, config?: JunctionAdvancedConfiguration<Content>);
|
|
64
|
+
toJSON(): JunctionJSON<ASide, BSide, Content>;
|
|
65
|
+
set(a: string, ...rest: Content extends null ? [b: string] : [b: string, content: Content]): this;
|
|
66
|
+
set(relation: {
|
|
67
|
+
[Key in ASide | BSide]: string;
|
|
68
|
+
}, ...rest: Content extends null ? [] | [b?: undefined] : [content: Content]): this;
|
|
69
|
+
delete(a: string, b?: string): this;
|
|
70
|
+
delete(relation: Record<ASide | BSide, string> | Record<ASide, string> | Record<BSide, string>, b?: undefined): this;
|
|
71
|
+
getRelatedKey(key: string): string | undefined;
|
|
72
|
+
getContent(a: string, b: string): Content | undefined;
|
|
73
|
+
getRelationEntries(input: Record<ASide, string> | Record<BSide, string>): [string, Content][];
|
|
74
|
+
has(a: string, b?: string): boolean;
|
|
109
75
|
}
|
|
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;
|
|
116
|
-
|
|
117
|
-
type Effectors<T> = {
|
|
118
|
-
setSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void;
|
|
119
|
-
onSet: (callback: (options: {
|
|
120
|
-
newValue: T;
|
|
121
|
-
oldValue: T;
|
|
122
|
-
}) => void) => void;
|
|
123
|
-
};
|
|
124
|
-
type AtomEffect<T> = (tools: Effectors<T>) => void;
|
|
125
|
-
type AtomOptions<T> = {
|
|
126
|
-
key: string;
|
|
127
|
-
default: T | (() => T);
|
|
128
|
-
effects?: AtomEffect<T>[];
|
|
129
|
-
};
|
|
130
|
-
declare function atom<T>(options: AtomOptions<T>): AtomToken<T>;
|
|
131
|
-
type AtomFamilyOptions<T, K extends Serializable> = {
|
|
132
|
-
key: string;
|
|
133
|
-
default: T | ((key: K) => T);
|
|
134
|
-
effects?: (key: K) => AtomEffect<T>[];
|
|
135
|
-
};
|
|
136
|
-
type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomToken<T>) & {
|
|
137
|
-
key: string;
|
|
138
|
-
type: `atom_family`;
|
|
139
|
-
subject: Subject<AtomToken<T>>;
|
|
140
|
-
};
|
|
141
|
-
declare function atomFamily<T, K extends Serializable>(options: AtomFamilyOptions<T, K>): AtomFamily<T, K>;
|
|
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
76
|
|
|
182
77
|
type OperationProgress = {
|
|
183
78
|
open: false;
|
|
@@ -192,15 +87,18 @@ declare const openOperation: (token: StateToken<any>, store: Store) => void;
|
|
|
192
87
|
declare const closeOperation: (store: Store) => void;
|
|
193
88
|
declare const isDone: (key: string, store?: Store) => boolean;
|
|
194
89
|
declare const markDone: (key: string, store?: Store) => void;
|
|
195
|
-
|
|
196
|
-
declare const
|
|
197
|
-
|
|
198
|
-
declare const
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
declare
|
|
202
|
-
|
|
203
|
-
|
|
90
|
+
|
|
91
|
+
declare const lookupSelectorSources: (key: string, store: Store) => (AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>)[];
|
|
92
|
+
|
|
93
|
+
declare const registerSelector: (selectorKey: string, store?: Store) => Transactors;
|
|
94
|
+
|
|
95
|
+
type Subscriber<T> = (value: T) => void;
|
|
96
|
+
declare class Subject<T> {
|
|
97
|
+
subscribers: Map<string, Subscriber<T>>;
|
|
98
|
+
subscribe(key: string, subscriber: Subscriber<T>): () => void;
|
|
99
|
+
private unsubscribe;
|
|
100
|
+
next(value: T): void;
|
|
101
|
+
}
|
|
204
102
|
|
|
205
103
|
type Selector<T> = {
|
|
206
104
|
key: string;
|
|
@@ -228,70 +126,16 @@ type ReadonlySelector<T> = {
|
|
|
228
126
|
declare function selector__INTERNAL<T>(options: SelectorOptions<T>, family?: FamilyMetadata, store?: Store): SelectorToken<T>;
|
|
229
127
|
declare function selector__INTERNAL<T>(options: ReadonlySelectorOptions<T>, family?: FamilyMetadata, store?: Store): ReadonlySelectorToken<T>;
|
|
230
128
|
|
|
231
|
-
declare const lookupSelectorSources: (key: string, store: Store) => (AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>)[];
|
|
232
|
-
|
|
233
|
-
type TransactionToken<_> = {
|
|
234
|
-
key: string;
|
|
235
|
-
type: `transaction`;
|
|
236
|
-
__brand?: _;
|
|
237
|
-
};
|
|
238
|
-
type TransactionUpdate<ƒ extends ƒn> = {
|
|
239
|
-
key: string;
|
|
240
|
-
atomUpdates: KeyedStateUpdate<unknown>[];
|
|
241
|
-
params: Parameters<ƒ>;
|
|
242
|
-
output: ReturnType<ƒ>;
|
|
243
|
-
};
|
|
244
|
-
type Transactors = {
|
|
245
|
-
get: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S;
|
|
246
|
-
set: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void;
|
|
247
|
-
};
|
|
248
|
-
type ReadonlyTransactors = Pick<Transactors, `get`>;
|
|
249
|
-
type Read<ƒ extends ƒn> = (transactors: ReadonlyTransactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
250
|
-
type Write<ƒ extends ƒn> = (transactors: Transactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
251
|
-
type TransactionOptions<ƒ extends ƒn> = {
|
|
252
|
-
key: string;
|
|
253
|
-
do: Write<ƒ>;
|
|
254
|
-
};
|
|
255
|
-
type TransactionIO<Token extends TransactionToken<any>> = Token extends TransactionToken<infer ƒ> ? ƒ : never;
|
|
256
|
-
declare function transaction<ƒ extends ƒn>(options: TransactionOptions<ƒ>): TransactionToken<ƒ>;
|
|
257
|
-
declare const runTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, store?: Store) => (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
258
|
-
|
|
259
|
-
declare const registerSelector: (selectorKey: string, store?: Store) => Transactors;
|
|
260
|
-
|
|
261
129
|
declare const traceSelectorAtoms: (selectorKey: string, dependency: ReadonlySelectorToken<unknown> | StateToken<unknown>, store: Store) => AtomToken<unknown>[];
|
|
262
130
|
declare const traceAllSelectorAtoms: (selectorKey: string, store: Store) => AtomToken<unknown>[];
|
|
263
131
|
|
|
264
132
|
declare const updateSelectorAtoms: (selectorKey: string, dependency: ReadonlySelectorToken<unknown> | StateToken<unknown>, store: Store) => void;
|
|
265
133
|
|
|
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
134
|
type TimelineAtomUpdate = StateUpdate<unknown> & {
|
|
292
135
|
key: string;
|
|
293
136
|
type: `atom_update`;
|
|
294
137
|
timestamp: number;
|
|
138
|
+
family?: FamilyMetadata;
|
|
295
139
|
};
|
|
296
140
|
type TimelineSelectorUpdate = {
|
|
297
141
|
key: string;
|
|
@@ -305,6 +149,7 @@ type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
|
|
|
305
149
|
timestamp: number;
|
|
306
150
|
};
|
|
307
151
|
type Timeline = {
|
|
152
|
+
type: `timeline`;
|
|
308
153
|
key: string;
|
|
309
154
|
at: number;
|
|
310
155
|
timeTraveling: `into_future` | `into_past` | null;
|
|
@@ -316,6 +161,11 @@ type Timeline = {
|
|
|
316
161
|
};
|
|
317
162
|
declare function timeline__INTERNAL(options: TimelineOptions, store?: Store, data?: Timeline | null): TimelineToken;
|
|
318
163
|
|
|
164
|
+
declare const addAtomToTimeline: (atomToken: AtomToken<any>, tl: Timeline, store?: Store) => void;
|
|
165
|
+
|
|
166
|
+
declare const redo__INTERNAL: (token: TimelineToken, store?: Store) => void;
|
|
167
|
+
declare const undo__INTERNAL: (token: TimelineToken, store?: Store) => void;
|
|
168
|
+
|
|
319
169
|
type Transaction<ƒ extends ƒn> = {
|
|
320
170
|
key: string;
|
|
321
171
|
type: `transaction`;
|
|
@@ -348,12 +198,100 @@ type TransactionIdle = {
|
|
|
348
198
|
};
|
|
349
199
|
type TransactionStatus<ƒ extends ƒn> = TransactionIdle | TransactionUpdateInProgress<ƒ>;
|
|
350
200
|
|
|
201
|
+
declare function deposit<T>(state: Atom<T>): AtomToken<T>;
|
|
202
|
+
declare function deposit<T>(state: Selector<T>): SelectorToken<T>;
|
|
203
|
+
declare function deposit<T>(state: Atom<T> | Selector<T>): StateToken<T>;
|
|
204
|
+
declare function deposit<T>(state: ReadonlySelector<T>): ReadonlySelectorToken<T>;
|
|
205
|
+
declare function deposit<T>(state: Transaction<T extends ƒn ? T : never>): TransactionToken<T>;
|
|
206
|
+
declare function deposit<T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>): ReadonlySelectorToken<T> | StateToken<T>;
|
|
207
|
+
|
|
208
|
+
declare function lookup(key: string, store: Store): AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>;
|
|
209
|
+
|
|
210
|
+
declare function withdraw<T>(token: AtomToken<T>, store: Store): Atom<T> | null;
|
|
211
|
+
declare function withdraw<T>(token: SelectorToken<T>, store: Store): Selector<T> | null;
|
|
212
|
+
declare function withdraw<T>(token: StateToken<T>, store: Store): Atom<T> | Selector<T> | null;
|
|
213
|
+
declare function withdraw<T>(token: ReadonlySelectorToken<T>, store: Store): ReadonlySelector<T> | null;
|
|
214
|
+
declare function withdraw<T>(token: TransactionToken<T>, store: Store): Transaction<T extends ƒn ? T : never> | null;
|
|
215
|
+
declare function withdraw<T>(token: ReadonlySelectorToken<T> | StateToken<T>, store: Store): Atom<T> | ReadonlySelector<T> | Selector<T> | null;
|
|
216
|
+
declare function withdraw<T>(token: TimelineToken, store: Store): Timeline | null;
|
|
217
|
+
|
|
218
|
+
type StoreCore = Pick<Store, `atoms` | `atomsThatAreDefault` | `operation` | `readonlySelectors` | `selectorAtoms` | `selectorGraph` | `selectors` | `timelineAtoms` | `timelines` | `transactions` | `valueMap`>;
|
|
219
|
+
declare class Store {
|
|
220
|
+
valueMap: Map<string, any>;
|
|
221
|
+
atoms: Map<string, Atom<any>>;
|
|
222
|
+
selectors: Map<string, Selector<any>>;
|
|
223
|
+
readonlySelectors: Map<string, ReadonlySelector<any>>;
|
|
224
|
+
timelines: Map<string, Timeline>;
|
|
225
|
+
transactions: Map<string, Transaction<ƒn>>;
|
|
226
|
+
atomsThatAreDefault: Set<string>;
|
|
227
|
+
timelineAtoms: Junction<"timelineKey", "atomKey", null>;
|
|
228
|
+
selectorAtoms: Junction<"selectorKey", "atomKey", null>;
|
|
229
|
+
selectorGraph: Junction<"upstreamSelectorKey", "downstreamSelectorKey", {
|
|
230
|
+
source: string;
|
|
231
|
+
}>;
|
|
232
|
+
subject: {
|
|
233
|
+
atomCreation: Subject<AtomToken<unknown>>;
|
|
234
|
+
selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
235
|
+
transactionCreation: Subject<TransactionToken<ƒn>>;
|
|
236
|
+
timelineCreation: Subject<TimelineToken>;
|
|
237
|
+
operationStatus: Subject<OperationProgress>;
|
|
238
|
+
};
|
|
239
|
+
operation: OperationProgress;
|
|
240
|
+
transactionStatus: TransactionStatus<ƒn>;
|
|
241
|
+
config: {
|
|
242
|
+
name: string;
|
|
243
|
+
logger: Logger | null;
|
|
244
|
+
logger__INTERNAL: Logger;
|
|
245
|
+
};
|
|
246
|
+
constructor(name: string, store?: Store | null);
|
|
247
|
+
}
|
|
248
|
+
declare const IMPLICIT: {
|
|
249
|
+
STORE_INTERNAL: Store | undefined;
|
|
250
|
+
readonly STORE: Store;
|
|
251
|
+
};
|
|
252
|
+
declare const clearStore: (store?: Store) => void;
|
|
253
|
+
|
|
254
|
+
type Atom<T> = {
|
|
255
|
+
key: string;
|
|
256
|
+
type: `atom`;
|
|
257
|
+
family?: FamilyMetadata;
|
|
258
|
+
subject: Subject<{
|
|
259
|
+
newValue: T;
|
|
260
|
+
oldValue: T;
|
|
261
|
+
}>;
|
|
262
|
+
default: T;
|
|
263
|
+
};
|
|
264
|
+
declare function atom__INTERNAL<T>(options: AtomOptions<T>, family?: FamilyMetadata, store?: Store): AtomToken<T>;
|
|
265
|
+
|
|
266
|
+
declare const isAtomDefault: (key: string, store?: Store) => boolean;
|
|
267
|
+
declare const markAtomAsDefault: (key: string, store?: Store) => void;
|
|
268
|
+
declare const markAtomAsNotDefault: (key: string, store?: Store) => void;
|
|
269
|
+
declare const isSelectorDefault: (key: string, store?: Store) => boolean;
|
|
270
|
+
|
|
271
|
+
declare const cacheValue: (key: string, value: unknown, store?: Store) => void;
|
|
272
|
+
declare const readCachedValue: <T>(key: string, store?: Store) => T;
|
|
273
|
+
declare const isValueCached: (key: string, store?: Store) => boolean;
|
|
274
|
+
|
|
275
|
+
declare function atomFamily__INTERNAL<T, K extends Serializable>(options: AtomFamilyOptions<T, K>, store?: Store): AtomFamily<T, K>;
|
|
276
|
+
|
|
277
|
+
declare function readonlySelectorFamily__INTERNAL<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>, store?: Store): ReadonlySelectorFamily<T, K>;
|
|
278
|
+
|
|
279
|
+
declare function selectorFamily__INTERNAL<T, K extends Serializable>(options: SelectorFamilyOptions<T, K>, store?: Store): SelectorFamily<T, K>;
|
|
280
|
+
declare function selectorFamily__INTERNAL<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>, store?: Store): ReadonlySelectorFamily<T, K>;
|
|
281
|
+
|
|
282
|
+
declare const getState__INTERNAL: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, store?: Store) => T;
|
|
283
|
+
|
|
284
|
+
declare const setState__INTERNAL: <T>(state: Atom<T> | Selector<T>, value: T | ((oldValue: T) => T), store?: Store) => void;
|
|
285
|
+
|
|
286
|
+
declare const subscribeToRootAtoms: <T>(state: ReadonlySelector<T> | Selector<T>, store: Store) => (() => void)[] | null;
|
|
287
|
+
|
|
351
288
|
type index_Atom<T> = Atom<T>;
|
|
352
289
|
declare const index_IMPLICIT: typeof IMPLICIT;
|
|
353
290
|
type index_OperationProgress = OperationProgress;
|
|
354
291
|
type index_ReadonlySelector<T> = ReadonlySelector<T>;
|
|
355
292
|
type index_Selector<T> = Selector<T>;
|
|
356
293
|
type index_Store = Store;
|
|
294
|
+
declare const index_Store: typeof Store;
|
|
357
295
|
type index_StoreCore = StoreCore;
|
|
358
296
|
type index_Subject<T> = Subject<T>;
|
|
359
297
|
declare const index_Subject: typeof Subject;
|
|
@@ -368,6 +306,7 @@ type index_TransactionPhase = TransactionPhase;
|
|
|
368
306
|
type index_TransactionStatus<ƒ extends ƒn> = TransactionStatus<ƒ>;
|
|
369
307
|
type index_TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdateInProgress<ƒ>;
|
|
370
308
|
declare const index_abortTransaction: typeof abortTransaction;
|
|
309
|
+
declare const index_addAtomToTimeline: typeof addAtomToTimeline;
|
|
371
310
|
declare const index_applyTransaction: typeof applyTransaction;
|
|
372
311
|
declare const index_atomFamily__INTERNAL: typeof atomFamily__INTERNAL;
|
|
373
312
|
declare const index_atom__INTERNAL: typeof atom__INTERNAL;
|
|
@@ -375,14 +314,8 @@ declare const index_buildTransaction: typeof buildTransaction;
|
|
|
375
314
|
declare const index_cacheValue: typeof cacheValue;
|
|
376
315
|
declare const index_clearStore: typeof clearStore;
|
|
377
316
|
declare const index_closeOperation: typeof closeOperation;
|
|
378
|
-
declare const index_computeSelectorState: typeof computeSelectorState;
|
|
379
|
-
declare const index_createStore: typeof createStore;
|
|
380
317
|
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
318
|
declare const index_getState__INTERNAL: typeof getState__INTERNAL;
|
|
385
|
-
declare const index_hasKeyBeenUsed: typeof hasKeyBeenUsed;
|
|
386
319
|
declare const index_isAtomDefault: typeof isAtomDefault;
|
|
387
320
|
declare const index_isDone: typeof isDone;
|
|
388
321
|
declare const index_isSelectorDefault: typeof isSelectorDefault;
|
|
@@ -393,22 +326,14 @@ declare const index_markAtomAsDefault: typeof markAtomAsDefault;
|
|
|
393
326
|
declare const index_markAtomAsNotDefault: typeof markAtomAsNotDefault;
|
|
394
327
|
declare const index_markDone: typeof markDone;
|
|
395
328
|
declare const index_openOperation: typeof openOperation;
|
|
396
|
-
declare const index_prepareUpdate: typeof prepareUpdate;
|
|
397
329
|
declare const index_readCachedValue: typeof readCachedValue;
|
|
398
330
|
declare const index_readonlySelectorFamily__INTERNAL: typeof readonlySelectorFamily__INTERNAL;
|
|
399
|
-
declare const index_recallState: typeof recallState;
|
|
400
331
|
declare const index_redoTransactionUpdate: typeof redoTransactionUpdate;
|
|
401
332
|
declare const index_redo__INTERNAL: typeof redo__INTERNAL;
|
|
402
333
|
declare const index_registerSelector: typeof registerSelector;
|
|
403
334
|
declare const index_selectorFamily__INTERNAL: typeof selectorFamily__INTERNAL;
|
|
404
335
|
declare const index_selector__INTERNAL: typeof selector__INTERNAL;
|
|
405
|
-
declare const index_setAtomState: typeof setAtomState;
|
|
406
|
-
declare const index_setSelectorState: typeof setSelectorState;
|
|
407
336
|
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
337
|
declare const index_subscribeToRootAtoms: typeof subscribeToRootAtoms;
|
|
413
338
|
declare const index_target: typeof target;
|
|
414
339
|
declare const index_timeline__INTERNAL: typeof timeline__INTERNAL;
|
|
@@ -440,6 +365,7 @@ declare namespace index {
|
|
|
440
365
|
index_TransactionStatus as TransactionStatus,
|
|
441
366
|
index_TransactionUpdateInProgress as TransactionUpdateInProgress,
|
|
442
367
|
index_abortTransaction as abortTransaction,
|
|
368
|
+
index_addAtomToTimeline as addAtomToTimeline,
|
|
443
369
|
index_applyTransaction as applyTransaction,
|
|
444
370
|
index_atomFamily__INTERNAL as atomFamily__INTERNAL,
|
|
445
371
|
index_atom__INTERNAL as atom__INTERNAL,
|
|
@@ -447,14 +373,8 @@ declare namespace index {
|
|
|
447
373
|
index_cacheValue as cacheValue,
|
|
448
374
|
index_clearStore as clearStore,
|
|
449
375
|
index_closeOperation as closeOperation,
|
|
450
|
-
index_computeSelectorState as computeSelectorState,
|
|
451
|
-
index_createStore as createStore,
|
|
452
376
|
index_deposit as deposit,
|
|
453
|
-
index_emitUpdate as emitUpdate,
|
|
454
|
-
index_evictCachedValue as evictCachedValue,
|
|
455
|
-
index_evictDownStream as evictDownStream,
|
|
456
377
|
index_getState__INTERNAL as getState__INTERNAL,
|
|
457
|
-
index_hasKeyBeenUsed as hasKeyBeenUsed,
|
|
458
378
|
index_isAtomDefault as isAtomDefault,
|
|
459
379
|
index_isDone as isDone,
|
|
460
380
|
index_isSelectorDefault as isSelectorDefault,
|
|
@@ -465,22 +385,14 @@ declare namespace index {
|
|
|
465
385
|
index_markAtomAsNotDefault as markAtomAsNotDefault,
|
|
466
386
|
index_markDone as markDone,
|
|
467
387
|
index_openOperation as openOperation,
|
|
468
|
-
index_prepareUpdate as prepareUpdate,
|
|
469
388
|
index_readCachedValue as readCachedValue,
|
|
470
389
|
index_readonlySelectorFamily__INTERNAL as readonlySelectorFamily__INTERNAL,
|
|
471
|
-
index_recallState as recallState,
|
|
472
390
|
index_redoTransactionUpdate as redoTransactionUpdate,
|
|
473
391
|
index_redo__INTERNAL as redo__INTERNAL,
|
|
474
392
|
index_registerSelector as registerSelector,
|
|
475
393
|
index_selectorFamily__INTERNAL as selectorFamily__INTERNAL,
|
|
476
394
|
index_selector__INTERNAL as selector__INTERNAL,
|
|
477
|
-
index_setAtomState as setAtomState,
|
|
478
|
-
index_setSelectorState as setSelectorState,
|
|
479
395
|
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
396
|
index_subscribeToRootAtoms as subscribeToRootAtoms,
|
|
485
397
|
index_target as target,
|
|
486
398
|
index_timeline__INTERNAL as timeline__INTERNAL,
|
|
@@ -494,11 +406,66 @@ declare namespace index {
|
|
|
494
406
|
};
|
|
495
407
|
}
|
|
496
408
|
|
|
409
|
+
type ƒn = (...parameters: any[]) => any;
|
|
410
|
+
|
|
411
|
+
type Effectors<T> = {
|
|
412
|
+
setSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void;
|
|
413
|
+
onSet: (callback: (options: {
|
|
414
|
+
newValue: T;
|
|
415
|
+
oldValue: T;
|
|
416
|
+
}) => void) => void;
|
|
417
|
+
};
|
|
418
|
+
type AtomEffect<T> = (tools: Effectors<T>) => void;
|
|
419
|
+
type AtomOptions<T> = {
|
|
420
|
+
key: string;
|
|
421
|
+
default: T | (() => T);
|
|
422
|
+
effects?: AtomEffect<T>[];
|
|
423
|
+
mutable?: boolean;
|
|
424
|
+
};
|
|
425
|
+
declare function atom<T>(options: AtomOptions<T>): AtomToken<T>;
|
|
426
|
+
type AtomFamilyOptions<T, K extends Serializable> = {
|
|
427
|
+
key: string;
|
|
428
|
+
default: T | ((key: K) => T);
|
|
429
|
+
effects?: (key: K) => AtomEffect<T>[];
|
|
430
|
+
};
|
|
431
|
+
type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomToken<T>) & {
|
|
432
|
+
key: string;
|
|
433
|
+
type: `atom_family`;
|
|
434
|
+
subject: Subject<AtomToken<T>>;
|
|
435
|
+
};
|
|
436
|
+
declare function atomFamily<T, K extends Serializable>(options: AtomFamilyOptions<T, K>): AtomFamily<T, K>;
|
|
437
|
+
|
|
497
438
|
type Logger = Pick<Console, `error` | `info` | `warn`>;
|
|
498
439
|
declare const LOG_LEVELS: ReadonlyArray<keyof Logger>;
|
|
499
440
|
declare const setLogLevel: (preferredLevel: `error` | `info` | `warn` | null, store?: Store) => void;
|
|
500
441
|
declare const useLogger: (logger: Logger, store?: Store) => void;
|
|
501
442
|
|
|
443
|
+
type TransactionToken<_> = {
|
|
444
|
+
key: string;
|
|
445
|
+
type: `transaction`;
|
|
446
|
+
__brand?: _;
|
|
447
|
+
};
|
|
448
|
+
type TransactionUpdate<ƒ extends ƒn> = {
|
|
449
|
+
key: string;
|
|
450
|
+
atomUpdates: KeyedStateUpdate<unknown>[];
|
|
451
|
+
params: Parameters<ƒ>;
|
|
452
|
+
output: ReturnType<ƒ>;
|
|
453
|
+
};
|
|
454
|
+
type Transactors = {
|
|
455
|
+
get: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S;
|
|
456
|
+
set: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void;
|
|
457
|
+
};
|
|
458
|
+
type ReadonlyTransactors = Pick<Transactors, `get`>;
|
|
459
|
+
type Read<ƒ extends ƒn> = (transactors: ReadonlyTransactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
460
|
+
type Write<ƒ extends ƒn> = (transactors: Transactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
461
|
+
type TransactionOptions<ƒ extends ƒn> = {
|
|
462
|
+
key: string;
|
|
463
|
+
do: Write<ƒ>;
|
|
464
|
+
};
|
|
465
|
+
type TransactionIO<Token extends TransactionToken<any>> = Token extends TransactionToken<infer ƒ> ? ƒ : never;
|
|
466
|
+
declare function transaction<ƒ extends ƒn>(options: TransactionOptions<ƒ>): TransactionToken<ƒ>;
|
|
467
|
+
declare const runTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, store?: Store) => (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
468
|
+
|
|
502
469
|
type SelectorOptions<T> = {
|
|
503
470
|
key: string;
|
|
504
471
|
get: Read<() => T>;
|
|
@@ -532,8 +499,7 @@ type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K
|
|
|
532
499
|
declare function selectorFamily<T, K extends Serializable>(options: SelectorFamilyOptions<T, K>): SelectorFamily<T, K>;
|
|
533
500
|
declare function selectorFamily<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamily<T, K>;
|
|
534
501
|
|
|
535
|
-
|
|
536
|
-
declare const silo: (name: string, fromStore?: Store | null) => {
|
|
502
|
+
declare class Silo {
|
|
537
503
|
store: Store;
|
|
538
504
|
atom: typeof atom;
|
|
539
505
|
atomFamily: typeof atomFamily;
|
|
@@ -546,7 +512,8 @@ declare const silo: (name: string, fromStore?: Store | null) => {
|
|
|
546
512
|
subscribe: typeof subscribe;
|
|
547
513
|
undo: typeof undo;
|
|
548
514
|
redo: typeof redo;
|
|
549
|
-
|
|
515
|
+
constructor(name: string, fromStore?: Store | null);
|
|
516
|
+
}
|
|
550
517
|
|
|
551
518
|
type StateUpdate<T> = {
|
|
552
519
|
newValue: T;
|
|
@@ -554,12 +521,13 @@ type StateUpdate<T> = {
|
|
|
554
521
|
};
|
|
555
522
|
type KeyedStateUpdate<T> = StateUpdate<T> & {
|
|
556
523
|
key: string;
|
|
524
|
+
family?: FamilyMetadata;
|
|
557
525
|
};
|
|
558
526
|
type UpdateHandler<T> = (update: StateUpdate<T>) => void;
|
|
559
|
-
declare const subscribe: <T>(token: ReadonlySelectorToken<T> | StateToken<T>, handleUpdate: UpdateHandler<T>, store?: Store) => (() => void);
|
|
527
|
+
declare const subscribe: <T>(token: ReadonlySelectorToken<T> | StateToken<T>, handleUpdate: UpdateHandler<T>, key?: string, store?: Store) => (() => void);
|
|
560
528
|
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);
|
|
529
|
+
declare const subscribeToTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, handleUpdate: TransactionUpdateHandler<ƒ>, key?: string, store?: Store) => (() => void);
|
|
530
|
+
declare const subscribeToTimeline: (token: TimelineToken, handleUpdate: (update: TimelineUpdate | `redo` | `undo`) => void, key?: string, store?: Store) => (() => void);
|
|
563
531
|
|
|
564
532
|
type TimelineToken = {
|
|
565
533
|
key: string;
|
|
@@ -601,4 +569,4 @@ declare const getState: <T>(token: ReadonlySelectorToken<T> | StateToken<T>, sto
|
|
|
601
569
|
declare const setState: <T, New extends T>(token: StateToken<T>, value: New | ((oldValue: T) => New), store?: Store) => void;
|
|
602
570
|
declare const isDefault: (token: ReadonlySelectorToken<unknown> | StateToken<unknown>, store?: Store) => boolean;
|
|
603
571
|
|
|
604
|
-
export { AtomEffect, AtomFamily, AtomFamilyOptions, AtomOptions, AtomToken, Effectors, FamilyMetadata, json as Json, KeyedStateUpdate, LOG_LEVELS, Logger, Read, ReadonlySelectorFamily, ReadonlySelectorFamilyOptions, ReadonlySelectorOptions, ReadonlySelectorToken, ReadonlyTransactors, SelectorFamily, SelectorFamilyOptions, SelectorOptions, SelectorToken, Silo, StateToken, StateUpdate, Store, TimelineOptions, TimelineToken, TimelineUpdate, TransactionIO, TransactionOptions, TransactionToken, TransactionUpdate, TransactionUpdateHandler, Transactors, UpdateHandler, Write, index as __INTERNAL__, atom, atomFamily, getState, isDefault, redo, runTransaction, selector, selectorFamily, setLogLevel, setState,
|
|
572
|
+
export { AtomEffect, AtomFamily, AtomFamilyOptions, AtomOptions, AtomToken, Effectors, FamilyMetadata, json as Json, KeyedStateUpdate, LOG_LEVELS, Logger, Read, ReadonlySelectorFamily, ReadonlySelectorFamilyOptions, ReadonlySelectorOptions, ReadonlySelectorToken, ReadonlyTransactors, SelectorFamily, SelectorFamilyOptions, SelectorOptions, SelectorToken, Silo, StateToken, StateUpdate, Store, TimelineOptions, TimelineToken, TimelineUpdate, TransactionIO, TransactionOptions, TransactionToken, TransactionUpdate, TransactionUpdateHandler, Transactors, UpdateHandler, Write, index as __INTERNAL__, atom, atomFamily, getState, isDefault, redo, runTransaction, selector, selectorFamily, setLogLevel, setState, subscribe, subscribeToTimeline, subscribeToTransaction, timeline, transaction, undo, useLogger, ƒn };
|