atom.io 0.6.7 → 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 +241 -263
- package/dist/index.d.ts +241 -263
- package/dist/index.js +28 -1911
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -1871
- package/dist/index.mjs.map +1 -1
- package/introspection/dist/index.d.mts +121 -176
- package/introspection/dist/index.d.ts +121 -176
- 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 +37 -8
- package/json/dist/index.d.ts +37 -8
- 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 +30 -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 -42
- package/react-devtools/dist/index.css.map +1 -1
- package/react-devtools/dist/index.d.mts +128 -193
- package/react-devtools/dist/index.d.ts +128 -193
- package/react-devtools/dist/index.js +56 -4154
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/index.mjs +19 -4117
- package/react-devtools/dist/index.mjs.map +1 -1
- package/realtime/dist/index.d.mts +7 -11
- package/realtime/dist/index.d.ts +7 -11
- package/realtime/dist/index.js +26 -185
- package/realtime/dist/index.js.map +1 -1
- package/realtime/dist/index.mjs +4 -149
- package/realtime/dist/index.mjs.map +1 -1
- package/realtime-react/dist/index.d.mts +12 -16
- package/realtime-react/dist/index.d.ts +12 -16
- 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 +7 -6
- package/src/index.ts +12 -9
- package/src/logger.ts +5 -5
- package/src/selector.ts +16 -14
- package/src/silo.ts +36 -39
- package/src/subscribe.ts +25 -20
- 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 -141
- 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 -66
- package/src/internal/selector/create-readonly-selector.ts +0 -46
- 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/subject.ts +0 -24
- 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 -70
- package/src/react-devtools/StateIndex.tsx +0 -153
- 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 -311
- 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 -22
- package/src/realtime-react/use-push.ts +0 -25
- 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/web-effects/index.ts +0 -1
- package/src/web-effects/storage.ts +0 -30
package/dist/index.d.mts
CHANGED
|
@@ -1,173 +1,78 @@
|
|
|
1
|
-
|
|
1
|
+
type primitive = boolean | number | string | null;
|
|
2
2
|
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
type JsonInterface<T, J extends Json = Json> = {
|
|
6
|
-
toJson: (t: T) => J;
|
|
7
|
-
fromJson: (json: J) => T;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
type Primitive = boolean | number | string | null;
|
|
11
|
-
type Serializable = Primitive | Readonly<{
|
|
3
|
+
type Serializable = primitive | Readonly<{
|
|
12
4
|
[key: string]: Serializable;
|
|
13
5
|
}> | ReadonlyArray<Serializable>;
|
|
14
|
-
type
|
|
15
|
-
type
|
|
16
|
-
type Json = JsonArr | JsonObj | Primitive;
|
|
17
|
-
|
|
18
|
-
type Identified = {
|
|
19
|
-
id: string;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
declare const RELATION_TYPES: readonly ["1:1", "1:n", "n:n"];
|
|
23
|
-
type RelationType = typeof RELATION_TYPES[number];
|
|
24
|
-
type RelationData<CONTENT extends JsonObj | null = null, A extends string = `from`, B extends string = `to`> = {
|
|
25
|
-
contents: JsonObj<string, CONTENT>;
|
|
26
|
-
relations: JsonObj<string, string[]>;
|
|
27
|
-
relationType: RelationType;
|
|
28
|
-
a: A;
|
|
29
|
-
b: B;
|
|
30
|
-
};
|
|
31
|
-
type IsRelationDataOptions<CONTENT extends JsonObj | null = null, A extends string = `from`, B extends string = `to`> = {
|
|
32
|
-
from?: A;
|
|
33
|
-
to?: B;
|
|
34
|
-
isContent?: (json: Json) => json is CONTENT;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
type NullSafeUnion<Base, Extension> = Extension extends null ? Base : Base & Extension;
|
|
38
|
-
type NullSafeRest<MaybeArg> = MaybeArg extends null ? [] | [undefined] : [MaybeArg];
|
|
39
|
-
|
|
40
|
-
declare class Join<CONTENT extends JsonObj | null = null, A extends string = `from`, B extends string = `to`> implements RelationData<CONTENT, A, B> {
|
|
41
|
-
readonly relationType: `1:1` | `1:n` | `n:n`;
|
|
42
|
-
readonly a: A;
|
|
43
|
-
readonly b: B;
|
|
44
|
-
readonly relations: Record<string, string[]>;
|
|
45
|
-
readonly contents: Record<string, CONTENT>;
|
|
46
|
-
constructor(json?: Partial<RelationData<CONTENT, A, B>>);
|
|
47
|
-
toJSON(): RelationData<CONTENT, A, B>;
|
|
48
|
-
static fromJSON<CONTENT extends JsonObj | null, A extends string, B extends string>(json: Json, options?: IsRelationDataOptions<CONTENT, A, B>): Join<CONTENT, A, B>;
|
|
49
|
-
from<AA extends string>(newA: AA): Join<CONTENT, AA, B>;
|
|
50
|
-
to<BB extends string>(newB: BB): Join<CONTENT, A, BB>;
|
|
51
|
-
makeJsonInterface: (...params: CONTENT extends null ? [
|
|
52
|
-
] : [Refinement<unknown, CONTENT>]) => JsonInterface<Join<CONTENT, A, B>, RelationData<CONTENT, A, B>>;
|
|
53
|
-
getRelatedId(id: string): string | undefined;
|
|
54
|
-
getRelatedIds(id: string): string[];
|
|
55
|
-
getContent(idA: string, idB: string): CONTENT | undefined;
|
|
56
|
-
getRelationEntries(id: string): [string, CONTENT][];
|
|
57
|
-
getRelationRecord(id: string): Record<string, CONTENT>;
|
|
58
|
-
getRelation(id: string): NullSafeUnion<Identified, CONTENT> | undefined;
|
|
59
|
-
getRelations(id: string): NullSafeUnion<Identified, CONTENT>[];
|
|
60
|
-
setRelations(subject: {
|
|
61
|
-
[from in A]: string;
|
|
62
|
-
} | {
|
|
63
|
-
[to in B]: string;
|
|
64
|
-
}, relations: NullSafeUnion<Identified, CONTENT>[]): Join<CONTENT, A, B>;
|
|
65
|
-
set(relation: {
|
|
66
|
-
[key in A | B]: string;
|
|
67
|
-
}, ...rest: NullSafeRest<CONTENT>): Join<CONTENT, A, B>;
|
|
68
|
-
remove(relation: Partial<Record<A | B, string>>): Join<CONTENT, A, B>;
|
|
69
|
-
}
|
|
6
|
+
type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
|
|
7
|
+
type Array<Element extends Serializable = Serializable> = ReadonlyArray<Element>;
|
|
70
8
|
|
|
71
|
-
type
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}>;
|
|
80
|
-
selectors: Map<string, Selector<any>>;
|
|
81
|
-
timelineAtoms: Join<null, `timelineKey`, `atomKey`>;
|
|
82
|
-
timelines: Map<string, Timeline>;
|
|
83
|
-
transactions: Map<string, Transaction<any>>;
|
|
84
|
-
valueMap: Map<string, any>;
|
|
85
|
-
subject: {
|
|
86
|
-
atomCreation: Subject<AtomToken<unknown>>;
|
|
87
|
-
selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
88
|
-
transactionCreation: Subject<TransactionToken<ƒn>>;
|
|
89
|
-
timelineCreation: Subject<TimelineToken>;
|
|
90
|
-
operationStatus: Subject<OperationProgress>;
|
|
91
|
-
};
|
|
92
|
-
operation: OperationProgress;
|
|
93
|
-
transactionStatus: TransactionStatus<ƒn>;
|
|
94
|
-
config: {
|
|
95
|
-
name: string;
|
|
96
|
-
logger: Logger | null;
|
|
97
|
-
logger__INTERNAL: Logger;
|
|
98
|
-
};
|
|
9
|
+
type json_Array<Element extends Serializable = Serializable> = Array<Element>;
|
|
10
|
+
type json_Serializable = Serializable;
|
|
11
|
+
declare namespace json {
|
|
12
|
+
export {
|
|
13
|
+
json_Array as Array,
|
|
14
|
+
Object$1 as Object,
|
|
15
|
+
json_Serializable as Serializable,
|
|
16
|
+
};
|
|
99
17
|
}
|
|
100
|
-
declare const createStore: (name: string, store?: Store | null) => Store;
|
|
101
|
-
declare const IMPLICIT: {
|
|
102
|
-
STORE_INTERNAL: Store | undefined;
|
|
103
|
-
readonly STORE: Store;
|
|
104
|
-
};
|
|
105
|
-
declare const clearStore: (store?: Store) => void;
|
|
106
|
-
|
|
107
|
-
type Effectors<T> = {
|
|
108
|
-
setSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void;
|
|
109
|
-
onSet: (callback: (options: {
|
|
110
|
-
newValue: T;
|
|
111
|
-
oldValue: T;
|
|
112
|
-
}) => void) => void;
|
|
113
|
-
};
|
|
114
|
-
type AtomEffect<T> = (tools: Effectors<T>) => void;
|
|
115
|
-
type AtomOptions<T> = {
|
|
116
|
-
key: string;
|
|
117
|
-
default: T | (() => T);
|
|
118
|
-
effects?: AtomEffect<T>[];
|
|
119
|
-
};
|
|
120
|
-
declare function atom<T>(options: AtomOptions<T>): AtomToken<T>;
|
|
121
|
-
type AtomFamilyOptions<T, K extends Serializable> = {
|
|
122
|
-
key: string;
|
|
123
|
-
default: T | ((key: K) => T);
|
|
124
|
-
effects?: (key: K) => AtomEffect<T>[];
|
|
125
|
-
};
|
|
126
|
-
type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomToken<T>) & {
|
|
127
|
-
key: string;
|
|
128
|
-
type: `atom_family`;
|
|
129
|
-
subject: Subject<AtomToken<T>>;
|
|
130
|
-
};
|
|
131
|
-
declare function atomFamily<T, K extends Serializable>(options: AtomFamilyOptions<T, K>): AtomFamily<T, K>;
|
|
132
18
|
|
|
133
|
-
type
|
|
134
|
-
|
|
135
|
-
type: `atom`;
|
|
136
|
-
family?: FamilyMetadata;
|
|
137
|
-
subject: Subject<{
|
|
138
|
-
newValue: T;
|
|
139
|
-
oldValue: T;
|
|
140
|
-
}>;
|
|
141
|
-
default: T;
|
|
142
|
-
};
|
|
143
|
-
declare function atom__INTERNAL<T>(options: AtomOptions<T>, family?: FamilyMetadata, store?: Store): AtomToken<T>;
|
|
19
|
+
type Refinement<Unrefined, Refined extends Unrefined> = (value: Unrefined) => value is Refined;
|
|
20
|
+
type Cardinality = `1:1` | `1:n` | `n:n`;
|
|
144
21
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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;
|
|
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;
|
|
75
|
+
}
|
|
171
76
|
|
|
172
77
|
type OperationProgress = {
|
|
173
78
|
open: false;
|
|
@@ -182,15 +87,18 @@ declare const openOperation: (token: StateToken<any>, store: Store) => void;
|
|
|
182
87
|
declare const closeOperation: (store: Store) => void;
|
|
183
88
|
declare const isDone: (key: string, store?: Store) => boolean;
|
|
184
89
|
declare const markDone: (key: string, store?: Store) => void;
|
|
185
|
-
|
|
186
|
-
declare const
|
|
187
|
-
|
|
188
|
-
declare const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
declare
|
|
192
|
-
|
|
193
|
-
|
|
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
|
+
}
|
|
194
102
|
|
|
195
103
|
type Selector<T> = {
|
|
196
104
|
key: string;
|
|
@@ -218,70 +126,16 @@ type ReadonlySelector<T> = {
|
|
|
218
126
|
declare function selector__INTERNAL<T>(options: SelectorOptions<T>, family?: FamilyMetadata, store?: Store): SelectorToken<T>;
|
|
219
127
|
declare function selector__INTERNAL<T>(options: ReadonlySelectorOptions<T>, family?: FamilyMetadata, store?: Store): ReadonlySelectorToken<T>;
|
|
220
128
|
|
|
221
|
-
declare const lookupSelectorSources: (key: string, store: Store) => (AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>)[];
|
|
222
|
-
|
|
223
|
-
type TransactionToken<_> = {
|
|
224
|
-
key: string;
|
|
225
|
-
type: `transaction`;
|
|
226
|
-
__brand?: _;
|
|
227
|
-
};
|
|
228
|
-
type TransactionUpdate<ƒ extends ƒn> = {
|
|
229
|
-
key: string;
|
|
230
|
-
atomUpdates: KeyedStateUpdate<unknown>[];
|
|
231
|
-
params: Parameters<ƒ>;
|
|
232
|
-
output: ReturnType<ƒ>;
|
|
233
|
-
};
|
|
234
|
-
type Transactors = {
|
|
235
|
-
get: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S;
|
|
236
|
-
set: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void;
|
|
237
|
-
};
|
|
238
|
-
type ReadonlyTransactors = Pick<Transactors, `get`>;
|
|
239
|
-
type Read<ƒ extends ƒn> = (transactors: ReadonlyTransactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
240
|
-
type Write<ƒ extends ƒn> = (transactors: Transactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
241
|
-
type TransactionOptions<ƒ extends ƒn> = {
|
|
242
|
-
key: string;
|
|
243
|
-
do: Write<ƒ>;
|
|
244
|
-
};
|
|
245
|
-
type TransactionIO<Token extends TransactionToken<any>> = Token extends TransactionToken<infer ƒ> ? ƒ : never;
|
|
246
|
-
declare function transaction<ƒ extends ƒn>(options: TransactionOptions<ƒ>): TransactionToken<ƒ>;
|
|
247
|
-
declare const runTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, store?: Store) => (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
248
|
-
|
|
249
|
-
declare const registerSelector: (selectorKey: string, store?: Store) => Transactors;
|
|
250
|
-
|
|
251
129
|
declare const traceSelectorAtoms: (selectorKey: string, dependency: ReadonlySelectorToken<unknown> | StateToken<unknown>, store: Store) => AtomToken<unknown>[];
|
|
252
130
|
declare const traceAllSelectorAtoms: (selectorKey: string, store: Store) => AtomToken<unknown>[];
|
|
253
131
|
|
|
254
132
|
declare const updateSelectorAtoms: (selectorKey: string, dependency: ReadonlySelectorToken<unknown> | StateToken<unknown>, store: Store) => void;
|
|
255
133
|
|
|
256
|
-
declare const evictDownStream: <T>(state: Atom<T>, store?: Store) => void;
|
|
257
|
-
declare const setAtomState: <T>(atom: Atom<T>, next: T | ((oldValue: T) => T), store?: Store) => void;
|
|
258
|
-
declare const setSelectorState: <T>(selector: Selector<T>, next: T | ((oldValue: T) => T), store?: Store) => void;
|
|
259
|
-
declare const setState__INTERNAL: <T>(state: Atom<T> | Selector<T>, value: T | ((oldValue: T) => T), store?: Store) => void;
|
|
260
|
-
|
|
261
|
-
type Subscriber<T> = (value: T) => void;
|
|
262
|
-
declare class Subject<T> {
|
|
263
|
-
subscribers: Subscriber<T>[];
|
|
264
|
-
subscribe(subscriber: Subscriber<T>): {
|
|
265
|
-
unsubscribe: () => void;
|
|
266
|
-
};
|
|
267
|
-
private unsubscribe;
|
|
268
|
-
next(value: T): void;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
declare const prepareUpdate: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, store: Store) => StateUpdate<T>;
|
|
272
|
-
declare const stowUpdate: <T>(state: Atom<T>, update: StateUpdate<T>, store: Store) => void;
|
|
273
|
-
declare const emitUpdate: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, update: StateUpdate<T>, store: Store) => void;
|
|
274
|
-
declare const subscribeToRootAtoms: <T>(state: ReadonlySelector<T> | Selector<T>, store: Store) => {
|
|
275
|
-
unsubscribe: () => void;
|
|
276
|
-
}[] | null;
|
|
277
|
-
|
|
278
|
-
declare const redo__INTERNAL: (token: TimelineToken, store?: Store) => void;
|
|
279
|
-
declare const undo__INTERNAL: (token: TimelineToken, store?: Store) => void;
|
|
280
|
-
|
|
281
134
|
type TimelineAtomUpdate = StateUpdate<unknown> & {
|
|
282
135
|
key: string;
|
|
283
136
|
type: `atom_update`;
|
|
284
137
|
timestamp: number;
|
|
138
|
+
family?: FamilyMetadata;
|
|
285
139
|
};
|
|
286
140
|
type TimelineSelectorUpdate = {
|
|
287
141
|
key: string;
|
|
@@ -295,9 +149,10 @@ type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
|
|
|
295
149
|
timestamp: number;
|
|
296
150
|
};
|
|
297
151
|
type Timeline = {
|
|
152
|
+
type: `timeline`;
|
|
298
153
|
key: string;
|
|
299
154
|
at: number;
|
|
300
|
-
timeTraveling:
|
|
155
|
+
timeTraveling: `into_future` | `into_past` | null;
|
|
301
156
|
history: TimelineUpdate[];
|
|
302
157
|
selectorTime: number | null;
|
|
303
158
|
transactionKey: string | null;
|
|
@@ -306,6 +161,11 @@ type Timeline = {
|
|
|
306
161
|
};
|
|
307
162
|
declare function timeline__INTERNAL(options: TimelineOptions, store?: Store, data?: Timeline | null): TimelineToken;
|
|
308
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
|
+
|
|
309
169
|
type Transaction<ƒ extends ƒn> = {
|
|
310
170
|
key: string;
|
|
311
171
|
type: `transaction`;
|
|
@@ -338,12 +198,100 @@ type TransactionIdle = {
|
|
|
338
198
|
};
|
|
339
199
|
type TransactionStatus<ƒ extends ƒn> = TransactionIdle | TransactionUpdateInProgress<ƒ>;
|
|
340
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
|
+
|
|
341
288
|
type index_Atom<T> = Atom<T>;
|
|
342
289
|
declare const index_IMPLICIT: typeof IMPLICIT;
|
|
343
290
|
type index_OperationProgress = OperationProgress;
|
|
344
291
|
type index_ReadonlySelector<T> = ReadonlySelector<T>;
|
|
345
292
|
type index_Selector<T> = Selector<T>;
|
|
346
293
|
type index_Store = Store;
|
|
294
|
+
declare const index_Store: typeof Store;
|
|
347
295
|
type index_StoreCore = StoreCore;
|
|
348
296
|
type index_Subject<T> = Subject<T>;
|
|
349
297
|
declare const index_Subject: typeof Subject;
|
|
@@ -358,6 +306,7 @@ type index_TransactionPhase = TransactionPhase;
|
|
|
358
306
|
type index_TransactionStatus<ƒ extends ƒn> = TransactionStatus<ƒ>;
|
|
359
307
|
type index_TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdateInProgress<ƒ>;
|
|
360
308
|
declare const index_abortTransaction: typeof abortTransaction;
|
|
309
|
+
declare const index_addAtomToTimeline: typeof addAtomToTimeline;
|
|
361
310
|
declare const index_applyTransaction: typeof applyTransaction;
|
|
362
311
|
declare const index_atomFamily__INTERNAL: typeof atomFamily__INTERNAL;
|
|
363
312
|
declare const index_atom__INTERNAL: typeof atom__INTERNAL;
|
|
@@ -365,14 +314,8 @@ declare const index_buildTransaction: typeof buildTransaction;
|
|
|
365
314
|
declare const index_cacheValue: typeof cacheValue;
|
|
366
315
|
declare const index_clearStore: typeof clearStore;
|
|
367
316
|
declare const index_closeOperation: typeof closeOperation;
|
|
368
|
-
declare const index_computeSelectorState: typeof computeSelectorState;
|
|
369
|
-
declare const index_createStore: typeof createStore;
|
|
370
317
|
declare const index_deposit: typeof deposit;
|
|
371
|
-
declare const index_emitUpdate: typeof emitUpdate;
|
|
372
|
-
declare const index_evictCachedValue: typeof evictCachedValue;
|
|
373
|
-
declare const index_evictDownStream: typeof evictDownStream;
|
|
374
318
|
declare const index_getState__INTERNAL: typeof getState__INTERNAL;
|
|
375
|
-
declare const index_hasKeyBeenUsed: typeof hasKeyBeenUsed;
|
|
376
319
|
declare const index_isAtomDefault: typeof isAtomDefault;
|
|
377
320
|
declare const index_isDone: typeof isDone;
|
|
378
321
|
declare const index_isSelectorDefault: typeof isSelectorDefault;
|
|
@@ -383,22 +326,14 @@ declare const index_markAtomAsDefault: typeof markAtomAsDefault;
|
|
|
383
326
|
declare const index_markAtomAsNotDefault: typeof markAtomAsNotDefault;
|
|
384
327
|
declare const index_markDone: typeof markDone;
|
|
385
328
|
declare const index_openOperation: typeof openOperation;
|
|
386
|
-
declare const index_prepareUpdate: typeof prepareUpdate;
|
|
387
329
|
declare const index_readCachedValue: typeof readCachedValue;
|
|
388
330
|
declare const index_readonlySelectorFamily__INTERNAL: typeof readonlySelectorFamily__INTERNAL;
|
|
389
|
-
declare const index_recallState: typeof recallState;
|
|
390
331
|
declare const index_redoTransactionUpdate: typeof redoTransactionUpdate;
|
|
391
332
|
declare const index_redo__INTERNAL: typeof redo__INTERNAL;
|
|
392
333
|
declare const index_registerSelector: typeof registerSelector;
|
|
393
334
|
declare const index_selectorFamily__INTERNAL: typeof selectorFamily__INTERNAL;
|
|
394
335
|
declare const index_selector__INTERNAL: typeof selector__INTERNAL;
|
|
395
|
-
declare const index_setAtomState: typeof setAtomState;
|
|
396
|
-
declare const index_setSelectorState: typeof setSelectorState;
|
|
397
336
|
declare const index_setState__INTERNAL: typeof setState__INTERNAL;
|
|
398
|
-
declare const index_storeAtom: typeof storeAtom;
|
|
399
|
-
declare const index_storeReadonlySelector: typeof storeReadonlySelector;
|
|
400
|
-
declare const index_storeSelector: typeof storeSelector;
|
|
401
|
-
declare const index_stowUpdate: typeof stowUpdate;
|
|
402
337
|
declare const index_subscribeToRootAtoms: typeof subscribeToRootAtoms;
|
|
403
338
|
declare const index_target: typeof target;
|
|
404
339
|
declare const index_timeline__INTERNAL: typeof timeline__INTERNAL;
|
|
@@ -430,6 +365,7 @@ declare namespace index {
|
|
|
430
365
|
index_TransactionStatus as TransactionStatus,
|
|
431
366
|
index_TransactionUpdateInProgress as TransactionUpdateInProgress,
|
|
432
367
|
index_abortTransaction as abortTransaction,
|
|
368
|
+
index_addAtomToTimeline as addAtomToTimeline,
|
|
433
369
|
index_applyTransaction as applyTransaction,
|
|
434
370
|
index_atomFamily__INTERNAL as atomFamily__INTERNAL,
|
|
435
371
|
index_atom__INTERNAL as atom__INTERNAL,
|
|
@@ -437,14 +373,8 @@ declare namespace index {
|
|
|
437
373
|
index_cacheValue as cacheValue,
|
|
438
374
|
index_clearStore as clearStore,
|
|
439
375
|
index_closeOperation as closeOperation,
|
|
440
|
-
index_computeSelectorState as computeSelectorState,
|
|
441
|
-
index_createStore as createStore,
|
|
442
376
|
index_deposit as deposit,
|
|
443
|
-
index_emitUpdate as emitUpdate,
|
|
444
|
-
index_evictCachedValue as evictCachedValue,
|
|
445
|
-
index_evictDownStream as evictDownStream,
|
|
446
377
|
index_getState__INTERNAL as getState__INTERNAL,
|
|
447
|
-
index_hasKeyBeenUsed as hasKeyBeenUsed,
|
|
448
378
|
index_isAtomDefault as isAtomDefault,
|
|
449
379
|
index_isDone as isDone,
|
|
450
380
|
index_isSelectorDefault as isSelectorDefault,
|
|
@@ -455,22 +385,14 @@ declare namespace index {
|
|
|
455
385
|
index_markAtomAsNotDefault as markAtomAsNotDefault,
|
|
456
386
|
index_markDone as markDone,
|
|
457
387
|
index_openOperation as openOperation,
|
|
458
|
-
index_prepareUpdate as prepareUpdate,
|
|
459
388
|
index_readCachedValue as readCachedValue,
|
|
460
389
|
index_readonlySelectorFamily__INTERNAL as readonlySelectorFamily__INTERNAL,
|
|
461
|
-
index_recallState as recallState,
|
|
462
390
|
index_redoTransactionUpdate as redoTransactionUpdate,
|
|
463
391
|
index_redo__INTERNAL as redo__INTERNAL,
|
|
464
392
|
index_registerSelector as registerSelector,
|
|
465
393
|
index_selectorFamily__INTERNAL as selectorFamily__INTERNAL,
|
|
466
394
|
index_selector__INTERNAL as selector__INTERNAL,
|
|
467
|
-
index_setAtomState as setAtomState,
|
|
468
|
-
index_setSelectorState as setSelectorState,
|
|
469
395
|
index_setState__INTERNAL as setState__INTERNAL,
|
|
470
|
-
index_storeAtom as storeAtom,
|
|
471
|
-
index_storeReadonlySelector as storeReadonlySelector,
|
|
472
|
-
index_storeSelector as storeSelector,
|
|
473
|
-
index_stowUpdate as stowUpdate,
|
|
474
396
|
index_subscribeToRootAtoms as subscribeToRootAtoms,
|
|
475
397
|
index_target as target,
|
|
476
398
|
index_timeline__INTERNAL as timeline__INTERNAL,
|
|
@@ -484,11 +406,66 @@ declare namespace index {
|
|
|
484
406
|
};
|
|
485
407
|
}
|
|
486
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
|
+
|
|
487
438
|
type Logger = Pick<Console, `error` | `info` | `warn`>;
|
|
488
439
|
declare const LOG_LEVELS: ReadonlyArray<keyof Logger>;
|
|
489
440
|
declare const setLogLevel: (preferredLevel: `error` | `info` | `warn` | null, store?: Store) => void;
|
|
490
441
|
declare const useLogger: (logger: Logger, store?: Store) => void;
|
|
491
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
|
+
|
|
492
469
|
type SelectorOptions<T> = {
|
|
493
470
|
key: string;
|
|
494
471
|
get: Read<() => T>;
|
|
@@ -522,8 +499,7 @@ type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K
|
|
|
522
499
|
declare function selectorFamily<T, K extends Serializable>(options: SelectorFamilyOptions<T, K>): SelectorFamily<T, K>;
|
|
523
500
|
declare function selectorFamily<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamily<T, K>;
|
|
524
501
|
|
|
525
|
-
|
|
526
|
-
declare const silo: (name: string, fromStore?: Store | null) => {
|
|
502
|
+
declare class Silo {
|
|
527
503
|
store: Store;
|
|
528
504
|
atom: typeof atom;
|
|
529
505
|
atomFamily: typeof atomFamily;
|
|
@@ -536,7 +512,8 @@ declare const silo: (name: string, fromStore?: Store | null) => {
|
|
|
536
512
|
subscribe: typeof subscribe;
|
|
537
513
|
undo: typeof undo;
|
|
538
514
|
redo: typeof redo;
|
|
539
|
-
|
|
515
|
+
constructor(name: string, fromStore?: Store | null);
|
|
516
|
+
}
|
|
540
517
|
|
|
541
518
|
type StateUpdate<T> = {
|
|
542
519
|
newValue: T;
|
|
@@ -544,12 +521,13 @@ type StateUpdate<T> = {
|
|
|
544
521
|
};
|
|
545
522
|
type KeyedStateUpdate<T> = StateUpdate<T> & {
|
|
546
523
|
key: string;
|
|
524
|
+
family?: FamilyMetadata;
|
|
547
525
|
};
|
|
548
526
|
type UpdateHandler<T> = (update: StateUpdate<T>) => void;
|
|
549
|
-
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);
|
|
550
528
|
type TransactionUpdateHandler<ƒ extends ƒn> = (data: TransactionUpdate<ƒ>) => void;
|
|
551
|
-
declare const subscribeToTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, handleUpdate: TransactionUpdateHandler<ƒ>, store?: Store) => (() => void);
|
|
552
|
-
declare const subscribeToTimeline: (token: TimelineToken, handleUpdate: (update: TimelineUpdate) => 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);
|
|
553
531
|
|
|
554
532
|
type TimelineToken = {
|
|
555
533
|
key: string;
|
|
@@ -591,4 +569,4 @@ declare const getState: <T>(token: ReadonlySelectorToken<T> | StateToken<T>, sto
|
|
|
591
569
|
declare const setState: <T, New extends T>(token: StateToken<T>, value: New | ((oldValue: T) => New), store?: Store) => void;
|
|
592
570
|
declare const isDefault: (token: ReadonlySelectorToken<unknown> | StateToken<unknown>, store?: Store) => boolean;
|
|
593
571
|
|
|
594
|
-
export { AtomEffect, AtomFamily, AtomFamilyOptions, AtomOptions, AtomToken, Effectors, FamilyMetadata, KeyedStateUpdate, LOG_LEVELS, Logger, Read, ReadonlySelectorFamily, ReadonlySelectorFamilyOptions, ReadonlySelectorOptions, ReadonlySelectorToken, ReadonlyTransactors, SelectorFamily, SelectorFamilyOptions, SelectorOptions, SelectorToken,
|
|
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 };
|