atom.io 0.44.0 → 0.44.2
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/eslint-plugin/index.d.ts +0 -1
- package/dist/eslint-plugin/index.d.ts.map +1 -1
- package/dist/internal/index.d.ts +269 -269
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +20 -4
- package/dist/internal/index.js.map +1 -1
- package/dist/introspection/index.d.ts +3 -3
- package/dist/introspection/index.d.ts.map +1 -1
- package/dist/json/index.d.ts +10 -10
- package/dist/json/index.d.ts.map +1 -1
- package/dist/main/index.d.ts +146 -146
- package/dist/main/index.d.ts.map +1 -1
- package/dist/react/index.js +4 -3
- package/dist/react/index.js.map +1 -1
- package/dist/react-devtools/index.d.ts +12 -12
- package/dist/react-devtools/index.d.ts.map +1 -1
- package/dist/realtime/index.d.ts +3 -3
- package/dist/realtime/index.d.ts.map +1 -1
- package/dist/realtime-react/index.js +1 -0
- package/dist/realtime-react/index.js.map +1 -1
- package/dist/realtime-server/index.d.ts +3 -3
- package/dist/realtime-server/index.d.ts.map +1 -1
- package/dist/realtime-testing/index.d.ts +4 -4
- package/dist/realtime-testing/index.d.ts.map +1 -1
- package/dist/web/index.d.ts +3 -3
- package/dist/web/index.d.ts.map +1 -1
- package/package.json +24 -24
- package/src/internal/set-state/dispatch-state-update.ts +13 -4
- package/src/internal/set-state/operate-on-store.ts +1 -1
- package/src/internal/set-state/set-atom.ts +25 -4
- package/src/react/use-loadable.ts +4 -3
package/dist/main/index.d.ts
CHANGED
|
@@ -16,11 +16,11 @@ declare const redo: (timeline: TimelineToken<any>) => void;
|
|
|
16
16
|
* @param timeline - A {@link TimelineToken}
|
|
17
17
|
*/
|
|
18
18
|
declare const undo: (timeline: TimelineToken<any>) => void;
|
|
19
|
-
type TimelineOptions<ManagedAtom
|
|
19
|
+
type TimelineOptions<ManagedAtom extends TimelineManageable> = {
|
|
20
20
|
/** The unique identifier of the timeline */
|
|
21
21
|
key: string;
|
|
22
22
|
/** The managed atoms (and families of atoms) to record */
|
|
23
|
-
scope: ManagedAtom
|
|
23
|
+
scope: ManagedAtom[];
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
26
|
* Create a timeline, a mechanism for recording, undoing, and replaying changes to groups of atoms
|
|
@@ -42,16 +42,16 @@ declare const timeline: <ManagedAtom extends TimelineManageable>(options: Timeli
|
|
|
42
42
|
* Tokens are fully serializable, so they can be passed between processes.
|
|
43
43
|
*/
|
|
44
44
|
type AtomIOToken = ReadableFamilyToken<any, any, any> | ReadableToken<any, any, any> | TimelineToken<any> | TransactionToken<any>;
|
|
45
|
-
type ReadableToken<T
|
|
46
|
-
type WritableToken<T
|
|
45
|
+
type ReadableToken<T, K$1 extends Canonical = any, E = never> = AtomToken<T, K$1, E> | SelectorToken<T, K$1, E>;
|
|
46
|
+
type WritableToken<T, K$1 extends Canonical = any, E = never> = AtomToken<T, K$1, E> | WritableSelectorToken<T, K$1, E>;
|
|
47
47
|
/**
|
|
48
48
|
* States belonging to this family can be read from the store.
|
|
49
49
|
*/
|
|
50
|
-
type ReadableFamilyToken<T
|
|
50
|
+
type ReadableFamilyToken<T, K$1 extends Canonical, E = never> = AtomFamilyToken<T, K$1, E> | SelectorFamilyToken<T, K$1, E>;
|
|
51
51
|
/**
|
|
52
52
|
* States belonging to this family can be written directly.
|
|
53
53
|
*/
|
|
54
|
-
type WritableFamilyToken<T
|
|
54
|
+
type WritableFamilyToken<T, K$1 extends Canonical, E = never> = AtomFamilyToken<T, K$1, E> | WritableSelectorFamilyToken<T, K$1, E>;
|
|
55
55
|
type TimelineToken<M> = {
|
|
56
56
|
/** The unique identifier of the timeline */
|
|
57
57
|
key: string;
|
|
@@ -68,8 +68,8 @@ type TransactionToken<F$1 extends Fn$1> = {
|
|
|
68
68
|
/** Never present. This is a marker that preserves the type of the transaction function */
|
|
69
69
|
__F?: F$1;
|
|
70
70
|
};
|
|
71
|
-
type AtomToken<T
|
|
72
|
-
type RegularAtomToken<T
|
|
71
|
+
type AtomToken<T, K$1 extends Canonical = any, E = never> = MutableAtomToken<T extends Transceiver<any, any, any> ? T : never, K$1> | RegularAtomToken<T, K$1, E>;
|
|
72
|
+
type RegularAtomToken<T, K$1 extends Canonical = any, E = never> = {
|
|
73
73
|
/** The unique identifier of the atom. */
|
|
74
74
|
key: string;
|
|
75
75
|
/** Discriminator. */
|
|
@@ -77,11 +77,11 @@ type RegularAtomToken<T$1, K$1 extends Canonical = any, E = never> = {
|
|
|
77
77
|
/** Present if the atom belongs to a family. */
|
|
78
78
|
family?: FamilyMetadata<K$1>;
|
|
79
79
|
/** Never present. This is a marker that preserves the type of the atom's value. */
|
|
80
|
-
__T?: T
|
|
80
|
+
__T?: T;
|
|
81
81
|
/** Never present. This is a marker that preserves the type of errors this atom is capable of catching and setting as its value. */
|
|
82
82
|
__E?: E;
|
|
83
83
|
};
|
|
84
|
-
type MutableAtomToken<T
|
|
84
|
+
type MutableAtomToken<T extends Transceiver<any, any, any>, K$1 extends Canonical = any> = {
|
|
85
85
|
/** The unique identifier of the atom. */
|
|
86
86
|
key: string;
|
|
87
87
|
/** Discriminator. */
|
|
@@ -89,14 +89,14 @@ type MutableAtomToken<T$1 extends Transceiver<any, any, any>, K$1 extends Canoni
|
|
|
89
89
|
/** Present if the atom belongs to a family. */
|
|
90
90
|
family?: FamilyMetadata<K$1>;
|
|
91
91
|
/** Never present. This is a marker that preserves the JSON form of the atom's transceiver value. */
|
|
92
|
-
__J?: AsJSON<T
|
|
92
|
+
__J?: AsJSON<T>;
|
|
93
93
|
};
|
|
94
|
-
type SelectorToken<T
|
|
95
|
-
type ReadonlySelectorToken<T
|
|
96
|
-
type WritableSelectorToken<T
|
|
97
|
-
type PureSelectorToken<T
|
|
98
|
-
type HeldSelectorToken<T
|
|
99
|
-
type WritablePureSelectorToken<T
|
|
94
|
+
type SelectorToken<T, K$1 extends Canonical = any, E = never> = ReadonlySelectorToken<T, K$1, E> | WritableSelectorToken<T, K$1, E>;
|
|
95
|
+
type ReadonlySelectorToken<T, K$1 extends Canonical = any, E = never> = ReadonlyHeldSelectorToken<T, K$1> | ReadonlyPureSelectorToken<T, K$1, E>;
|
|
96
|
+
type WritableSelectorToken<T, K$1 extends Canonical = any, E = never> = WritableHeldSelectorToken<T, K$1> | WritablePureSelectorToken<T, K$1, E>;
|
|
97
|
+
type PureSelectorToken<T, K$1 extends Canonical = any, E = never> = ReadonlyPureSelectorToken<T, K$1, E> | WritablePureSelectorToken<T, K$1, E>;
|
|
98
|
+
type HeldSelectorToken<T, K$1 extends Canonical = any> = ReadonlyHeldSelectorToken<T, K$1> | WritableHeldSelectorToken<T, K$1>;
|
|
99
|
+
type WritablePureSelectorToken<T, K$1 extends Canonical = any, E = never> = {
|
|
100
100
|
/** The unique identifier of the selector. */
|
|
101
101
|
key: string;
|
|
102
102
|
/** Discriminator. */
|
|
@@ -104,11 +104,11 @@ type WritablePureSelectorToken<T$1, K$1 extends Canonical = any, E = never> = {
|
|
|
104
104
|
/** Present if the selector belongs to a family. */
|
|
105
105
|
family?: FamilyMetadata<K$1>;
|
|
106
106
|
/** Never present. This is a marker that preserves the type of the selector's value. */
|
|
107
|
-
__T?: T
|
|
107
|
+
__T?: T;
|
|
108
108
|
/** Never present. This is a marker that preserves the type of errors this selector is capable of catching and setting as its value. */
|
|
109
109
|
__E?: E;
|
|
110
110
|
};
|
|
111
|
-
type WritableHeldSelectorToken<T
|
|
111
|
+
type WritableHeldSelectorToken<T, K$1 extends Canonical = any> = {
|
|
112
112
|
/** The unique identifier of the selector. */
|
|
113
113
|
key: string;
|
|
114
114
|
/** Discriminator. */
|
|
@@ -116,9 +116,9 @@ type WritableHeldSelectorToken<T$1, K$1 extends Canonical = any> = {
|
|
|
116
116
|
/** Present if the selector belongs to a family. */
|
|
117
117
|
family?: FamilyMetadata<K$1>;
|
|
118
118
|
/** Never present. This is a marker that preserves the type of the selector's value. */
|
|
119
|
-
__T?: T
|
|
119
|
+
__T?: T;
|
|
120
120
|
};
|
|
121
|
-
type ReadonlyPureSelectorToken<T
|
|
121
|
+
type ReadonlyPureSelectorToken<T, K$1 extends Canonical = any, E = never> = {
|
|
122
122
|
/** The unique identifier of the selector. */
|
|
123
123
|
key: string;
|
|
124
124
|
/** Discriminator. */
|
|
@@ -126,11 +126,11 @@ type ReadonlyPureSelectorToken<T$1, K$1 extends Canonical = any, E = never> = {
|
|
|
126
126
|
/** Present if the selector belongs to a family. */
|
|
127
127
|
family?: FamilyMetadata<K$1>;
|
|
128
128
|
/** Never present. This is a marker that preserves the type of the selector's value. */
|
|
129
|
-
__T?: T
|
|
129
|
+
__T?: T;
|
|
130
130
|
/** Never present. This is a marker that preserves the type of errors this selector is capable of catching and setting as its value. */
|
|
131
131
|
__E?: E;
|
|
132
132
|
};
|
|
133
|
-
type ReadonlyHeldSelectorToken<T
|
|
133
|
+
type ReadonlyHeldSelectorToken<T, K$1 extends Canonical = any> = {
|
|
134
134
|
/** The unique identifier of the selector. */
|
|
135
135
|
key: string;
|
|
136
136
|
/** Discriminator. */
|
|
@@ -138,7 +138,7 @@ type ReadonlyHeldSelectorToken<T$1, K$1 extends Canonical = any> = {
|
|
|
138
138
|
/** Present if the selector belongs to a family. */
|
|
139
139
|
family?: FamilyMetadata<K$1>;
|
|
140
140
|
/** Never present. This is a marker that preserves the type of the selector's value. */
|
|
141
|
-
__T?: T
|
|
141
|
+
__T?: T;
|
|
142
142
|
};
|
|
143
143
|
/**
|
|
144
144
|
* Identifies a state's connection to its family.
|
|
@@ -149,75 +149,75 @@ type FamilyMetadata<K$1 extends Canonical = any> = {
|
|
|
149
149
|
/** The family member's unique identifier, in the form of a string. */
|
|
150
150
|
subKey: stringified<K$1>;
|
|
151
151
|
};
|
|
152
|
-
type AtomFamilyToken<T
|
|
153
|
-
type RegularAtomFamilyToken<T
|
|
152
|
+
type AtomFamilyToken<T, K$1 extends Canonical = Canonical, E = never> = MutableAtomFamilyToken<T extends Transceiver<any, any, any> ? T : never, K$1> | RegularAtomFamilyToken<T, K$1, E>;
|
|
153
|
+
type RegularAtomFamilyToken<T, K$1 extends Canonical, E = never> = {
|
|
154
154
|
/** The unique identifier of the atom family */
|
|
155
155
|
key: string;
|
|
156
156
|
/** Discriminator */
|
|
157
157
|
type: `atom_family`;
|
|
158
158
|
/** Never present. This is a marker that preserves the type of atoms in this family */
|
|
159
|
-
__T?: T
|
|
159
|
+
__T?: T;
|
|
160
160
|
/** Never present. This is a marker that preserves the type of keys used for atoms in this family */
|
|
161
161
|
__K?: K$1;
|
|
162
162
|
/** Never present. This is a marker that preserves the type of errors this family is capable of catching and setting as its value. */
|
|
163
163
|
__E?: E;
|
|
164
164
|
};
|
|
165
|
-
type MutableAtomFamilyToken<T
|
|
165
|
+
type MutableAtomFamilyToken<T extends Transceiver<any, any, any>, K$1 extends Canonical> = {
|
|
166
166
|
/** The unique identifier of the atom family */
|
|
167
167
|
key: string;
|
|
168
168
|
/** Discriminator */
|
|
169
169
|
type: `mutable_atom_family`;
|
|
170
170
|
/** Never present. This is a marker that preserves the type of atoms in this family */
|
|
171
|
-
__T?: T
|
|
171
|
+
__T?: T;
|
|
172
172
|
/** Never present. This is a marker that preserves the type of keys used for atoms in this family */
|
|
173
173
|
__K?: K$1;
|
|
174
174
|
};
|
|
175
|
-
type SelectorFamilyToken<T
|
|
176
|
-
type ReadonlySelectorFamilyToken<T
|
|
177
|
-
type WritableSelectorFamilyToken<T
|
|
178
|
-
type PureSelectorFamilyToken<T
|
|
179
|
-
type HeldSelectorFamilyToken<T
|
|
180
|
-
type WritablePureSelectorFamilyToken<T
|
|
175
|
+
type SelectorFamilyToken<T, K$1 extends Canonical, E = never> = ReadonlySelectorFamilyToken<T, K$1, E> | WritableSelectorFamilyToken<T, K$1, E>;
|
|
176
|
+
type ReadonlySelectorFamilyToken<T, K$1 extends Canonical, E = never> = ReadonlyHeldSelectorFamilyToken<T, K$1> | ReadonlyPureSelectorFamilyToken<T, K$1, E>;
|
|
177
|
+
type WritableSelectorFamilyToken<T, K$1 extends Canonical, E = never> = WritableHeldSelectorFamilyToken<T, K$1> | WritablePureSelectorFamilyToken<T, K$1, E>;
|
|
178
|
+
type PureSelectorFamilyToken<T, K$1 extends Canonical, E = never> = ReadonlyPureSelectorFamilyToken<T, K$1, E> | WritablePureSelectorFamilyToken<T, K$1, E>;
|
|
179
|
+
type HeldSelectorFamilyToken<T, K$1 extends Canonical> = ReadonlyHeldSelectorFamilyToken<T, K$1> | WritableHeldSelectorFamilyToken<T, K$1>;
|
|
180
|
+
type WritablePureSelectorFamilyToken<T, K$1 extends Canonical, E = never> = {
|
|
181
181
|
/** The unique identifier of the family */
|
|
182
182
|
key: string;
|
|
183
183
|
/** Discriminator */
|
|
184
184
|
type: `writable_pure_selector_family`;
|
|
185
185
|
/** Never present. This is a marker that preserves the type of the value of each family member */
|
|
186
|
-
__T?: T
|
|
186
|
+
__T?: T;
|
|
187
187
|
/** Never present. This is a marker that preserves the type of keys used for each family member */
|
|
188
188
|
__K?: K$1;
|
|
189
189
|
/** Never present. This is a marker that preserves the type of errors this family is capable of catching and setting as its value. */
|
|
190
190
|
__E?: E;
|
|
191
191
|
};
|
|
192
|
-
type ReadonlyPureSelectorFamilyToken<T
|
|
192
|
+
type ReadonlyPureSelectorFamilyToken<T, K$1 extends Canonical, E = never> = {
|
|
193
193
|
/** The unique identifier of the family */
|
|
194
194
|
key: string;
|
|
195
195
|
/** Discriminator */
|
|
196
196
|
type: `readonly_pure_selector_family`;
|
|
197
197
|
/** Never present. This is a marker that preserves the type of the value of each family member */
|
|
198
|
-
__T?: T
|
|
198
|
+
__T?: T;
|
|
199
199
|
/** Never present. This is a marker that preserves the type of keys used for each family member */
|
|
200
200
|
__K?: K$1;
|
|
201
201
|
/** Never present. This is a marker that preserves the type of errors this family is capable of catching and setting as its value. */
|
|
202
202
|
__E?: E;
|
|
203
203
|
};
|
|
204
|
-
type WritableHeldSelectorFamilyToken<T
|
|
204
|
+
type WritableHeldSelectorFamilyToken<T, K$1 extends Canonical> = {
|
|
205
205
|
/** The unique identifier of the family */
|
|
206
206
|
key: string;
|
|
207
207
|
/** Discriminator */
|
|
208
208
|
type: `writable_held_selector_family`;
|
|
209
209
|
/** Never present. This is a marker that preserves the type of the value of each family member */
|
|
210
|
-
__T?: T
|
|
210
|
+
__T?: T;
|
|
211
211
|
/** Never present. This is a marker that preserves the type of keys used for each family member */
|
|
212
212
|
__K?: K$1;
|
|
213
213
|
};
|
|
214
|
-
type ReadonlyHeldSelectorFamilyToken<T
|
|
214
|
+
type ReadonlyHeldSelectorFamilyToken<T, K$1 extends Canonical> = {
|
|
215
215
|
/** The unique identifier of the family */
|
|
216
216
|
key: string;
|
|
217
217
|
/** Discriminator */
|
|
218
218
|
type: `readonly_held_selector_family`;
|
|
219
219
|
/** Never present. This is a marker that preserves the type of the value of each family member */
|
|
220
|
-
__T?: T
|
|
220
|
+
__T?: T;
|
|
221
221
|
/** Never present. This is a marker that preserves the type of keys used for each family member */
|
|
222
222
|
__K?: K$1;
|
|
223
223
|
};
|
|
@@ -238,21 +238,21 @@ declare function belongsTo<Family extends WritableFamilyToken<any, any>>(family:
|
|
|
238
238
|
declare function belongsTo<Family extends ReadableFamilyToken<any, any>>(family: Family, unknownToken: ReadableToken<any>): unknownToken is ReadableToken<TokenType<Family>>;
|
|
239
239
|
//#endregion
|
|
240
240
|
//#region src/main/events.d.ts
|
|
241
|
-
type StateUpdate<T
|
|
242
|
-
readonly oldValue?: ViewOf$1<T
|
|
243
|
-
readonly newValue: ViewOf$1<T
|
|
241
|
+
type StateUpdate<T> = {
|
|
242
|
+
readonly oldValue?: ViewOf$1<T>;
|
|
243
|
+
readonly newValue: ViewOf$1<T>;
|
|
244
244
|
};
|
|
245
|
-
type AtomUpdateEvent<A
|
|
245
|
+
type AtomUpdateEvent<A extends AtomToken<any, any, any>> = {
|
|
246
246
|
type: `atom_update`;
|
|
247
|
-
token: A
|
|
248
|
-
update: StateUpdate<TokenType<A
|
|
247
|
+
token: A;
|
|
248
|
+
update: StateUpdate<TokenType<A>>;
|
|
249
249
|
timestamp: number;
|
|
250
250
|
};
|
|
251
|
-
type SelectorUpdateSubEvent<A
|
|
252
|
-
type TimelineSelectorUpdateEvent<A
|
|
251
|
+
type SelectorUpdateSubEvent<A extends AtomToken<any, any, any>> = AtomUpdateEvent<A> | StateCreationEvent<any>;
|
|
252
|
+
type TimelineSelectorUpdateEvent<A extends TimelineManageable> = {
|
|
253
253
|
type: `selector_update`;
|
|
254
254
|
token: SelectorToken<any>;
|
|
255
|
-
subEvents: SelectorUpdateSubEvent<AtomOnly<A
|
|
255
|
+
subEvents: SelectorUpdateSubEvent<AtomOnly<A>>[];
|
|
256
256
|
timestamp: number;
|
|
257
257
|
};
|
|
258
258
|
type StateLifecycleEvent<R extends ReadableToken<any, any, any>> = StateCreationEvent<R> | StateDisposalEvent<R>;
|
|
@@ -306,28 +306,28 @@ type MoleculeTransferEvent = {
|
|
|
306
306
|
timestamp: number;
|
|
307
307
|
};
|
|
308
308
|
type TransactionSubEvent = AtomUpdateEvent<AtomToken<any, any, any>> | MoleculeCreationEvent | MoleculeDisposalEvent | MoleculeTransferEvent | StateCreationEvent<ReadableToken<unknown, any, any>> | StateDisposalEvent<ReadableToken<unknown, any, any>> | TransactionOutcomeEvent<TransactionToken<any>>;
|
|
309
|
-
type TransactionOutcomeEvent<T
|
|
309
|
+
type TransactionOutcomeEvent<T extends TransactionToken<any>> = {
|
|
310
310
|
type: `transaction_outcome`;
|
|
311
|
-
token: T
|
|
311
|
+
token: T;
|
|
312
312
|
id: string;
|
|
313
313
|
epoch: number;
|
|
314
314
|
timestamp: number;
|
|
315
315
|
subEvents: TransactionSubEvent[];
|
|
316
|
-
params: Parameters<TokenType<T
|
|
317
|
-
output: ReturnType<TokenType<T
|
|
316
|
+
params: Parameters<TokenType<T>>;
|
|
317
|
+
output: ReturnType<TokenType<T>>;
|
|
318
318
|
};
|
|
319
|
-
type TimelineEvent<ManagedAtom
|
|
319
|
+
type TimelineEvent<ManagedAtom extends TimelineManageable> = {
|
|
320
320
|
checkpoint?: true;
|
|
321
|
-
} & (AtomUpdateEvent<AtomOnly<ManagedAtom
|
|
321
|
+
} & (AtomUpdateEvent<AtomOnly<ManagedAtom>> | StateCreationEvent<AtomOnly<ManagedAtom>> | StateDisposalEvent<AtomOnly<ManagedAtom>> | TimelineSelectorUpdateEvent<ManagedAtom> | TransactionOutcomeEvent<TransactionToken<any>>);
|
|
322
322
|
//#endregion
|
|
323
323
|
//#region src/main/atom.d.ts
|
|
324
|
-
type RegularAtomOptions<T
|
|
324
|
+
type RegularAtomOptions<T, E = never> = {
|
|
325
325
|
/** The unique identifier of the atom */
|
|
326
326
|
key: string;
|
|
327
327
|
/** The starting value of the atom */
|
|
328
|
-
default: T
|
|
328
|
+
default: T | (() => T);
|
|
329
329
|
/** Hooks used to run side effects when the atom is set */
|
|
330
|
-
effects?: readonly AtomEffect<T
|
|
330
|
+
effects?: readonly AtomEffect<T, E>[];
|
|
331
331
|
/** The classes of errors that might be thrown when deriving the atom's default value */
|
|
332
332
|
catch?: readonly Ctor<E>[];
|
|
333
333
|
};
|
|
@@ -337,14 +337,14 @@ type RegularAtomOptions<T$1, E = never> = {
|
|
|
337
337
|
* @returns
|
|
338
338
|
* A reference to the atom created: a {@link RegularAtomToken}
|
|
339
339
|
*/
|
|
340
|
-
declare function atom<T
|
|
341
|
-
type MutableAtomOptions<T
|
|
340
|
+
declare function atom<T, E = never>(options: RegularAtomOptions<T, E>): RegularAtomToken<T, any, E>;
|
|
341
|
+
type MutableAtomOptions<T extends Transceiver<any, any, any>> = {
|
|
342
342
|
/** The unique identifier of the atom */
|
|
343
343
|
key: string;
|
|
344
344
|
/** A constructor for the atom's value */
|
|
345
|
-
class: ConstructorOf<T
|
|
345
|
+
class: ConstructorOf<T>;
|
|
346
346
|
/** Hooks used to run side effects when the atom is set */
|
|
347
|
-
effects?: readonly AtomEffect<T
|
|
347
|
+
effects?: readonly AtomEffect<T>[];
|
|
348
348
|
};
|
|
349
349
|
/**
|
|
350
350
|
* Create a mutable atom, a global reactive variable in the implicit store
|
|
@@ -355,15 +355,15 @@ type MutableAtomOptions<T$1 extends Transceiver<any, any, any>> = {
|
|
|
355
355
|
* @returns
|
|
356
356
|
* A reference to the atom created: a {@link MutableAtomToken}
|
|
357
357
|
*/
|
|
358
|
-
declare function mutableAtom<T
|
|
358
|
+
declare function mutableAtom<T extends Transceiver<any, any, any>>(options: MutableAtomOptions<T>): MutableAtomToken<T>;
|
|
359
359
|
/**
|
|
360
360
|
* A function that runs side effects when the atom is set
|
|
361
361
|
* @param tools - {@link Effectors} that can be used to run side effects
|
|
362
362
|
* @returns
|
|
363
363
|
* Optionally, a cleanup function that will be called when the atom is disposed
|
|
364
364
|
*/
|
|
365
|
-
type AtomEffect<T
|
|
366
|
-
type Effectors<T
|
|
365
|
+
type AtomEffect<T, E = never> = (tools: Effectors<T, E>) => (() => void) | void;
|
|
366
|
+
type Effectors<T, E = never> = {
|
|
367
367
|
/**
|
|
368
368
|
* Reset the value of the atom to its default
|
|
369
369
|
*/
|
|
@@ -372,21 +372,21 @@ type Effectors<T$1, E = never> = {
|
|
|
372
372
|
* Set the value of the atom
|
|
373
373
|
* @param next - The new value of the atom, or a setter function
|
|
374
374
|
*/
|
|
375
|
-
setSelf: <New extends T
|
|
375
|
+
setSelf: <New extends T>(next: New | ((old: T) => New)) => void;
|
|
376
376
|
/** Subscribe to changes to the atom */
|
|
377
|
-
onSet: (callback: (options: StateUpdate<E | T
|
|
377
|
+
onSet: (callback: (options: StateUpdate<E | T>) => void) => void;
|
|
378
378
|
/** The token of the atom */
|
|
379
|
-
token: T
|
|
379
|
+
token: T extends Transceiver<any, any, any> ? MutableAtomToken<T> : AtomToken<T, any, E>;
|
|
380
380
|
/** The store in which the atom exists */
|
|
381
381
|
store: Store;
|
|
382
382
|
};
|
|
383
|
-
type RegularAtomFamilyOptions<T
|
|
383
|
+
type RegularAtomFamilyOptions<T, K$1 extends Canonical, E = never> = {
|
|
384
384
|
/** The unique identifier of the atom family */
|
|
385
385
|
key: string;
|
|
386
386
|
/** The starting value of the atom family */
|
|
387
|
-
default: T
|
|
387
|
+
default: T | ((key: K$1) => T);
|
|
388
388
|
/** Hooks used to run side effects when an atom in the family is set */
|
|
389
|
-
effects?: (key: K$1) => AtomEffect<T
|
|
389
|
+
effects?: (key: K$1) => AtomEffect<T, E>[];
|
|
390
390
|
/** The classes of errors that might be thrown when deriving the atom's default value */
|
|
391
391
|
catch?: readonly Ctor<E>[];
|
|
392
392
|
};
|
|
@@ -396,14 +396,14 @@ type RegularAtomFamilyOptions<T$1, K$1 extends Canonical, E = never> = {
|
|
|
396
396
|
* @returns
|
|
397
397
|
* A reference to the atom family created: a {@link RegularAtomFamilyToken}
|
|
398
398
|
*/
|
|
399
|
-
declare function atomFamily<T
|
|
400
|
-
type MutableAtomFamilyOptions<T
|
|
399
|
+
declare function atomFamily<T, K$1 extends Canonical, E = never>(options: RegularAtomFamilyOptions<T, K$1, E>): RegularAtomFamilyToken<T, K$1, E>;
|
|
400
|
+
type MutableAtomFamilyOptions<T extends Transceiver<any, any, any>, K$1 extends Canonical> = {
|
|
401
401
|
/** The unique identifier of the atom family */
|
|
402
402
|
key: string;
|
|
403
403
|
/** The class of the transceiver to be created */
|
|
404
|
-
class: ConstructorOf<T
|
|
404
|
+
class: ConstructorOf<T>;
|
|
405
405
|
/** Hooks used to run side effects when an atom in the family is set */
|
|
406
|
-
effects?: (key: K$1) => AtomEffect<T
|
|
406
|
+
effects?: (key: K$1) => AtomEffect<T>[];
|
|
407
407
|
};
|
|
408
408
|
/**
|
|
409
409
|
* Create a family of mutable atoms, allowing for the dynamic creation and disposal of atoms.
|
|
@@ -414,7 +414,7 @@ type MutableAtomFamilyOptions<T$1 extends Transceiver<any, any, any>, K$1 extend
|
|
|
414
414
|
* @returns
|
|
415
415
|
* A reference to the atom family created: a {@link MutableAtomFamilyToken}
|
|
416
416
|
*/
|
|
417
|
-
declare function mutableAtomFamily<T
|
|
417
|
+
declare function mutableAtomFamily<T extends Transceiver<any, any, any>, K$1 extends Canonical>(options: MutableAtomFamilyOptions<T, K$1>): MutableAtomFamilyToken<T, K$1>;
|
|
418
418
|
//#endregion
|
|
419
419
|
//#region src/main/dispose-state.d.ts
|
|
420
420
|
/**
|
|
@@ -451,7 +451,7 @@ declare function disposeState<K$1 extends Canonical>(token: ReadableFamilyToken<
|
|
|
451
451
|
* The current value of the state
|
|
452
452
|
* @overload Mutable Atom
|
|
453
453
|
*/
|
|
454
|
-
declare function findState<T
|
|
454
|
+
declare function findState<T extends Transceiver<any, any, any>, K$1 extends Canonical, Key extends K$1>(token: MutableAtomFamilyToken<T, K$1>, key: Key): MutableAtomToken$1<T, K$1>;
|
|
455
455
|
/**
|
|
456
456
|
* Finds a {@link RegularAtomToken} in the store, without accessing its value.
|
|
457
457
|
*
|
|
@@ -465,7 +465,7 @@ declare function findState<T$1 extends Transceiver<any, any, any>, K$1 extends C
|
|
|
465
465
|
* The current value of the state
|
|
466
466
|
* @overload Regular Atom
|
|
467
467
|
*/
|
|
468
|
-
declare function findState<T
|
|
468
|
+
declare function findState<T, K$1 extends Canonical, Key extends K$1>(token: RegularAtomFamilyToken<T, K$1>, key: Key): RegularAtomToken$1<T, Key>;
|
|
469
469
|
/**
|
|
470
470
|
* Finds a {@link WritableSelectorToken} in the store, without accessing its value.
|
|
471
471
|
*
|
|
@@ -479,7 +479,7 @@ declare function findState<T$1, K$1 extends Canonical, Key extends K$1>(token: R
|
|
|
479
479
|
* The current value of the state
|
|
480
480
|
* @overload Writable Selector
|
|
481
481
|
*/
|
|
482
|
-
declare function findState<T
|
|
482
|
+
declare function findState<T, K$1 extends Canonical, Key extends K$1>(token: WritableSelectorFamilyToken$1<T, K$1>, key: Key): WritableSelectorToken$1<T, Key>;
|
|
483
483
|
/**
|
|
484
484
|
* Finds a {@link ReadonlySelectorToken} in the store, without accessing its value.
|
|
485
485
|
*
|
|
@@ -493,7 +493,7 @@ declare function findState<T$1, K$1 extends Canonical, Key extends K$1>(token: W
|
|
|
493
493
|
* The current value of the state
|
|
494
494
|
* @overload Readonly Selector
|
|
495
495
|
*/
|
|
496
|
-
declare function findState<T
|
|
496
|
+
declare function findState<T, K$1 extends Canonical, Key extends K$1>(token: ReadonlySelectorFamilyToken$1<T, K$1>, key: Key): ReadonlySelectorToken$1<T, Key>;
|
|
497
497
|
/**
|
|
498
498
|
* Finds a {@link WritableToken} in the store, without accessing its value.
|
|
499
499
|
*
|
|
@@ -507,7 +507,7 @@ declare function findState<T$1, K$1 extends Canonical, Key extends K$1>(token: R
|
|
|
507
507
|
* The current value of the state
|
|
508
508
|
* @overload Writable State
|
|
509
509
|
*/
|
|
510
|
-
declare function findState<T
|
|
510
|
+
declare function findState<T, K$1 extends Canonical, Key extends K$1>(token: WritableFamilyToken$1<T, K$1>, key: Key): WritableToken$1<T, Key>;
|
|
511
511
|
/**
|
|
512
512
|
* Finds a {@link MutableAtomToken} in the store, without accessing its value.
|
|
513
513
|
*
|
|
@@ -522,7 +522,7 @@ declare function findState<T$1, K$1 extends Canonical, Key extends K$1>(token: W
|
|
|
522
522
|
* @overload Unknown
|
|
523
523
|
* @default
|
|
524
524
|
*/
|
|
525
|
-
declare function findState<T
|
|
525
|
+
declare function findState<T, K$1 extends Canonical, Key extends K$1>(token: ReadableFamilyToken$1<T, K$1>, key: Key): ReadableToken$1<T, Key>;
|
|
526
526
|
//#endregion
|
|
527
527
|
//#region src/main/get-state.d.ts
|
|
528
528
|
/**
|
|
@@ -532,7 +532,7 @@ declare function findState<T$1, K$1 extends Canonical, Key extends K$1>(token: R
|
|
|
532
532
|
* @overload Default
|
|
533
533
|
* @default
|
|
534
534
|
*/
|
|
535
|
-
declare function getState<T
|
|
535
|
+
declare function getState<T, E = never>(token: ReadableToken<T, any, E>): ViewOf$1<E | T>;
|
|
536
536
|
/**
|
|
537
537
|
* Read or compute the current value of a state
|
|
538
538
|
* @param token - The token of a state family
|
|
@@ -540,20 +540,20 @@ declare function getState<T$1, E = never>(token: ReadableToken<T$1, any, E>): Vi
|
|
|
540
540
|
* @return The current value of the state
|
|
541
541
|
* @overload Streamlined
|
|
542
542
|
*/
|
|
543
|
-
declare function getState<T
|
|
543
|
+
declare function getState<T, K$1 extends Canonical, E = never>(token: ReadableFamilyToken<T, K$1, E>, key: NoInfer<K$1>): ViewOf$1<E | T>;
|
|
544
544
|
//#endregion
|
|
545
545
|
//#region src/main/join.d.ts
|
|
546
|
-
type JoinOptions<AName extends string, A
|
|
546
|
+
type JoinOptions<AName extends string, A extends string, BName extends string, B extends string, Cardinality extends `1:1` | `1:n` | `n:n`> = Flat<JunctionSchemaBase<AName, BName> & {
|
|
547
547
|
/** Unique identifier of the join */
|
|
548
548
|
readonly key: string;
|
|
549
549
|
/** How many relations are allowed in each direction? */
|
|
550
550
|
readonly cardinality: Cardinality;
|
|
551
551
|
/** Type guard for the type of the left side */
|
|
552
|
-
readonly isAType: Refinement<string, A
|
|
552
|
+
readonly isAType: Refinement<string, A>;
|
|
553
553
|
/** Type guard for the type of the right side */
|
|
554
|
-
readonly isBType: Refinement<string, B
|
|
555
|
-
}> & Partial<JunctionEntriesBase<A
|
|
556
|
-
type JoinToken<AName extends string, A
|
|
554
|
+
readonly isBType: Refinement<string, B>;
|
|
555
|
+
}> & Partial<JunctionEntriesBase<A, B, null>>;
|
|
556
|
+
type JoinToken<AName extends string, A extends string, BName extends string, B extends string, Cardinality extends `1:1` | `1:n` | `n:n`> = {
|
|
557
557
|
/** Unique identifier of the join */
|
|
558
558
|
key: string;
|
|
559
559
|
/** Discriminator */
|
|
@@ -565,9 +565,9 @@ type JoinToken<AName extends string, A$1 extends string, BName extends string, B
|
|
|
565
565
|
/** Name of the join's right side */
|
|
566
566
|
b: BName;
|
|
567
567
|
/** Never present. This is a marker that preserves the type of the left side's keys */
|
|
568
|
-
__aType?: A
|
|
568
|
+
__aType?: A;
|
|
569
569
|
/** Never present. This is a marker that preserves the type of the right side's keys */
|
|
570
|
-
__bType?: B
|
|
570
|
+
__bType?: B;
|
|
571
571
|
};
|
|
572
572
|
/**
|
|
573
573
|
* Create a join, an interface for managing relations between two sets of keys.
|
|
@@ -580,8 +580,8 @@ type JoinToken<AName extends string, A$1 extends string, BName extends string, B
|
|
|
580
580
|
* @returns
|
|
581
581
|
* A reference to the join created: a {@link JoinToken}
|
|
582
582
|
*/
|
|
583
|
-
declare function join<const AName extends string, const A
|
|
584
|
-
type JoinStates<AName extends string, A
|
|
583
|
+
declare function join<const AName extends string, const A extends string, const BName extends string, const B extends string, const Cardinality extends `1:1` | `1:n` | `n:n`>(options: JoinOptions<AName, A, BName, B, Cardinality>): JoinToken<AName, A, BName, B, Cardinality>;
|
|
584
|
+
type JoinStates<AName extends string, A extends string, BName extends string, B extends string, Cardinality extends `1:1` | `1:n` | `n:n`> = Cardinality extends `1:1` ? { readonly [N in AName as `${N}KeyOf${Capitalize<BName>}`]: ReadonlyPureSelectorToken$1<A | null, B> } & { readonly [N in BName as `${N}KeyOf${Capitalize<AName>}`]: ReadonlyPureSelectorToken$1<B | null, A> } : Cardinality extends `1:n` ? { readonly [N in AName as `${N}KeyOf${Capitalize<BName>}`]: ReadonlyPureSelectorToken$1<A | null, B> } & { readonly [N in BName as `${N}KeysOf${Capitalize<AName>}`]: ReadonlyPureSelectorToken$1<B[], A> } : Cardinality extends `n:n` ? { readonly [N in AName as `${N}KeysOf${Capitalize<BName>}`]: ReadonlyPureSelectorToken$1<A[], B> } & { readonly [N in BName as `${N}KeysOf${Capitalize<AName>}`]: ReadonlyPureSelectorToken$1<B[], A> } : never;
|
|
585
585
|
/**
|
|
586
586
|
* Find the current value of a relation owned by a {@link join}
|
|
587
587
|
* @param token - The token of the join
|
|
@@ -590,19 +590,19 @@ type JoinStates<AName extends string, A$1 extends string, BName extends string,
|
|
|
590
590
|
* A {@link JoinStates} interface to access the relation
|
|
591
591
|
* @overload Default
|
|
592
592
|
*/
|
|
593
|
-
declare function findRelations<AName extends string, A
|
|
593
|
+
declare function findRelations<AName extends string, A extends string, BName extends string, B extends string, Cardinality extends `1:1` | `1:n` | `n:n`>(token: JoinToken<AName, A, BName, B, Cardinality>, key: A | B): JoinStates<AName, A, BName, B, Cardinality>;
|
|
594
594
|
/**
|
|
595
595
|
* Change one or multiple relations owned by a {@link join}
|
|
596
596
|
* @param token - The token of the join
|
|
597
597
|
* @param change - A function that takes a {@link Junction} interface to edit the relations
|
|
598
598
|
*/
|
|
599
|
-
declare function editRelations<AName extends string, A
|
|
599
|
+
declare function editRelations<AName extends string, A extends string, BName extends string, B extends string, Cardinality extends `1:1` | `1:n` | `n:n`>(token: JoinToken<AName, A, BName, B, Cardinality>, change: (relations: Junction<AName, A, BName, B>) => void): void;
|
|
600
600
|
/**
|
|
601
601
|
* @param token - The token of the join
|
|
602
602
|
* @returns
|
|
603
603
|
* A {@link MutableAtomFamilyToken} to access the internal relations
|
|
604
604
|
*/
|
|
605
|
-
declare function getInternalRelations<AName extends string, A
|
|
605
|
+
declare function getInternalRelations<AName extends string, A extends string, BName extends string, B extends string, Cardinality extends `1:1` | `1:n` | `n:n`>(token: JoinToken<AName, A, BName, B, Cardinality>): MutableAtomFamilyToken$1<UList<A> | UList<B>, string>;
|
|
606
606
|
//#endregion
|
|
607
607
|
//#region src/main/logger.d.ts
|
|
608
608
|
declare const LOGGER_ICON_DICTIONARY: {
|
|
@@ -688,7 +688,7 @@ declare function simpleCompound(a: string, b: string): string;
|
|
|
688
688
|
declare class Realm<H extends Hierarchy> {
|
|
689
689
|
store: RootStore;
|
|
690
690
|
deallocateTX: TransactionToken<(claim: ValidKey<Vassal<H>>) => void>;
|
|
691
|
-
claimTX: TransactionToken<<V extends Exclude<Vassal<H>, CompoundTypedKey>, A extends Above<V, H>>(newProvenance: A, claim: ValidKey<V>, exclusive?: `exclusive`) => void>;
|
|
691
|
+
claimTX: TransactionToken<<V$1 extends Exclude<Vassal<H>, CompoundTypedKey>, A extends Above<V$1, H>>(newProvenance: A, claim: ValidKey<V$1>, exclusive?: `exclusive`) => void>;
|
|
692
692
|
/**
|
|
693
693
|
* @param store - The store to which the realm will be attached
|
|
694
694
|
*/
|
|
@@ -701,7 +701,7 @@ declare class Realm<H extends Hierarchy> {
|
|
|
701
701
|
* @returns
|
|
702
702
|
* The subject's key, given status as a true {@link ValidKey}
|
|
703
703
|
*/
|
|
704
|
-
allocate<V extends Vassal<H>, A extends Above<V, H>>(provenance: A, key: V, attachmentStyle?: `all` | `any`): ValidKey<V>;
|
|
704
|
+
allocate<V$1 extends Vassal<H>, A extends Above<V$1, H>>(provenance: A, key: V$1, attachmentStyle?: `all` | `any`): ValidKey<V$1>;
|
|
705
705
|
/**
|
|
706
706
|
* Fuse two reagents into a compound
|
|
707
707
|
* @param type - the name of the compound that is being fused
|
|
@@ -715,7 +715,7 @@ declare class Realm<H extends Hierarchy> {
|
|
|
715
715
|
* Remove a subject from the realm
|
|
716
716
|
* @param claim - The subject to be deallocated
|
|
717
717
|
*/
|
|
718
|
-
deallocate<V extends Vassal<H>>(claim: ValidKey<V>): void;
|
|
718
|
+
deallocate<V$1 extends Vassal<H>>(claim: ValidKey<V$1>): void;
|
|
719
719
|
/**
|
|
720
720
|
* Transfer a subject of the realm from one owner to another
|
|
721
721
|
* @param newProvenance - A key for an owner {@link Above} the new subject in the realm's {@link Hierarchy}
|
|
@@ -724,7 +724,7 @@ declare class Realm<H extends Hierarchy> {
|
|
|
724
724
|
* @returns
|
|
725
725
|
* The subject's key, given status as a true {@link ValidKey}
|
|
726
726
|
*/
|
|
727
|
-
claim<V extends Exclude<Vassal<H>, CompoundTypedKey>, A extends Above<V, H>>(newProvenance: A, claim: ValidKey<V>, exclusive?: `exclusive`): void;
|
|
727
|
+
claim<V$1 extends Exclude<Vassal<H>, CompoundTypedKey>, A extends Above<V$1, H>>(newProvenance: A, claim: ValidKey<V$1>, exclusive?: `exclusive`): void;
|
|
728
728
|
}
|
|
729
729
|
declare class Anarchy {
|
|
730
730
|
store: RootStore;
|
|
@@ -765,10 +765,10 @@ declare class Anarchy {
|
|
|
765
765
|
}
|
|
766
766
|
declare function decomposeCompound(compound: Canonical): [type: string, a: string, b: string] | null;
|
|
767
767
|
type T$ = `T$`;
|
|
768
|
-
type TypeTag<T
|
|
769
|
-
type SingularTypedKey<T
|
|
770
|
-
type CompoundTypedKey<T
|
|
771
|
-
type TypedKey<T
|
|
768
|
+
type TypeTag<T extends string> = `${T$}--${T}`;
|
|
769
|
+
type SingularTypedKey<T extends string = string> = `${T}::${string}`;
|
|
770
|
+
type CompoundTypedKey<T extends string = string, A extends string = string, B extends string = string> = `${TypeTag<T>}==${SingularTypedKey<A>}++${SingularTypedKey<B>}`;
|
|
771
|
+
type TypedKey<T extends string = string, A extends string = string, B extends string = string> = CompoundTypedKey<T, A, B> | SingularTypedKey<T>;
|
|
772
772
|
type Scope = SingularTypedKey[];
|
|
773
773
|
type MutualFealty = {
|
|
774
774
|
above: Scope;
|
|
@@ -815,7 +815,7 @@ declare function resetState<K$1 extends Canonical>(token: WritableFamilyToken<an
|
|
|
815
815
|
* @returns
|
|
816
816
|
* The new value of the state.
|
|
817
817
|
*/
|
|
818
|
-
type Setter<T
|
|
818
|
+
type Setter<T> = (oldValue: T) => T;
|
|
819
819
|
/**
|
|
820
820
|
* Set the value of a state into the implicit store.
|
|
821
821
|
* @param token - An atom or writable selector token.
|
|
@@ -823,7 +823,7 @@ type Setter<T$1> = (oldValue: T$1) => T$1;
|
|
|
823
823
|
* @overload Default
|
|
824
824
|
* @default
|
|
825
825
|
*/
|
|
826
|
-
declare function setState<T
|
|
826
|
+
declare function setState<T, TT extends T>(token: WritableToken<T, any, any>, value: Setter<TT> | TT): void;
|
|
827
827
|
/**
|
|
828
828
|
* Set the value of a state into the implicit store.
|
|
829
829
|
* @param token - An atom family or writable selector family token.
|
|
@@ -831,7 +831,7 @@ declare function setState<T$1, TT extends T$1>(token: WritableToken<T$1, any, an
|
|
|
831
831
|
* @param value - The new value of the state.
|
|
832
832
|
* @overload Streamlined
|
|
833
833
|
*/
|
|
834
|
-
declare function setState<T
|
|
834
|
+
declare function setState<T, TT extends T, K$1 extends Canonical>(token: WritableFamilyToken<T, K$1, any>, key: NoInfer<K$1>, value: Setter<TT> | TT): void;
|
|
835
835
|
//#endregion
|
|
836
836
|
//#region src/main/transaction.d.ts
|
|
837
837
|
type ReaderToolkit = Pick<ActorToolkit, `find` | `get` | `json`>;
|
|
@@ -871,41 +871,41 @@ declare function transaction<F$1 extends Fn$1>(options: TransactionOptions<F$1>)
|
|
|
871
871
|
declare function runTransaction<F$1 extends Fn$1>(token: TransactionToken<F$1>, id?: string): (...parameters: Parameters<F$1>) => ReturnType<F$1>;
|
|
872
872
|
//#endregion
|
|
873
873
|
//#region src/main/selector.d.ts
|
|
874
|
-
type WritablePureSelectorOptions<T
|
|
874
|
+
type WritablePureSelectorOptions<T, E = never> = {
|
|
875
875
|
/** The unique identifier of the selector */
|
|
876
876
|
key: string;
|
|
877
877
|
/** For each instantiated selector, a function that computes its value */
|
|
878
|
-
get: Read<() => T
|
|
878
|
+
get: Read<() => T>;
|
|
879
879
|
/** For each instantiated selector, a function that sets its value */
|
|
880
|
-
set: Write<(newValue: T
|
|
880
|
+
set: Write<(newValue: T) => void>;
|
|
881
881
|
/** The classes of errors that might be thrown when deriving the atom's default value */
|
|
882
882
|
catch?: readonly Ctor<E>[];
|
|
883
883
|
};
|
|
884
|
-
type ReadonlyPureSelectorOptions<T
|
|
884
|
+
type ReadonlyPureSelectorOptions<T, E = never> = {
|
|
885
885
|
/** The unique identifier of the selector */
|
|
886
886
|
key: string;
|
|
887
887
|
/** For each instantiated selector, a function that computes its value */
|
|
888
|
-
get: Read<() => T
|
|
888
|
+
get: Read<() => T>;
|
|
889
889
|
/** The classes of errors that might be thrown when deriving the atom's default value */
|
|
890
890
|
catch?: readonly Ctor<E>[];
|
|
891
891
|
};
|
|
892
|
-
type ReadonlyHeldSelectorOptions<T
|
|
892
|
+
type ReadonlyHeldSelectorOptions<T extends object> = {
|
|
893
893
|
/** The unique identifier of the selector */
|
|
894
894
|
key: string;
|
|
895
895
|
/** For each instantiated selector, a constant reference to a value that will not be replaced */
|
|
896
|
-
const: T
|
|
896
|
+
const: T;
|
|
897
897
|
/** For each instantiated selector, a function that computes its value */
|
|
898
|
-
get: Read<(permanent: T
|
|
898
|
+
get: Read<(permanent: T) => void>;
|
|
899
899
|
};
|
|
900
|
-
type WritableHeldSelectorOptions<T
|
|
900
|
+
type WritableHeldSelectorOptions<T extends object> = {
|
|
901
901
|
/** The unique identifier of the selector */
|
|
902
902
|
key: string;
|
|
903
903
|
/** For each instantiated selector, a constant reference to a value that will not be replaced */
|
|
904
|
-
const: T
|
|
904
|
+
const: T;
|
|
905
905
|
/** For each instantiated selector, a function that computes its value */
|
|
906
|
-
get: Read<(permanent: T
|
|
906
|
+
get: Read<(permanent: T) => void>;
|
|
907
907
|
/** For each instantiated selector, a function that sets its value */
|
|
908
|
-
set: Write<(newValue: T
|
|
908
|
+
set: Write<(newValue: T) => void>;
|
|
909
909
|
};
|
|
910
910
|
/**
|
|
911
911
|
* Declare a selector. The value of a selector should depend
|
|
@@ -924,7 +924,7 @@ type WritableHeldSelectorOptions<T$1 extends object> = {
|
|
|
924
924
|
* The token for your selector.
|
|
925
925
|
* @overload WritableHeld
|
|
926
926
|
*/
|
|
927
|
-
declare function selector<T
|
|
927
|
+
declare function selector<T extends object>(options: WritableHeldSelectorOptions<T>): WritableHeldSelectorToken<T>;
|
|
928
928
|
/**
|
|
929
929
|
* Declare a selector. The value of a selector should depend
|
|
930
930
|
* on the value of atoms or other selectors in the store,
|
|
@@ -940,7 +940,7 @@ declare function selector<T$1 extends object>(options: WritableHeldSelectorOptio
|
|
|
940
940
|
* The token for your selector.
|
|
941
941
|
* @overload ReadonlyHeld
|
|
942
942
|
*/
|
|
943
|
-
declare function selector<T
|
|
943
|
+
declare function selector<T extends object>(options: ReadonlyHeldSelectorOptions<T>): ReadonlyHeldSelectorToken<T>;
|
|
944
944
|
/**
|
|
945
945
|
* Declare a selector. The value of a selector should depend
|
|
946
946
|
* on the value of atoms or other selectors in the store.
|
|
@@ -957,7 +957,7 @@ declare function selector<T$1 extends object>(options: ReadonlyHeldSelectorOptio
|
|
|
957
957
|
* The token for your selector.
|
|
958
958
|
* @overload WritablePure
|
|
959
959
|
*/
|
|
960
|
-
declare function selector<T
|
|
960
|
+
declare function selector<T, E = never>(options: WritablePureSelectorOptions<T, E>): WritablePureSelectorToken<T, any, E>;
|
|
961
961
|
/**
|
|
962
962
|
* Declare a selector. The value of a selector should depend
|
|
963
963
|
* on the value of atoms or other selectors in the store.
|
|
@@ -972,42 +972,42 @@ declare function selector<T$1, E = never>(options: WritablePureSelectorOptions<T
|
|
|
972
972
|
* The token for your selector.
|
|
973
973
|
* @overload ReadonlyPure
|
|
974
974
|
*/
|
|
975
|
-
declare function selector<T
|
|
976
|
-
type WritablePureSelectorFamilyOptions<T
|
|
975
|
+
declare function selector<T, E = never>(options: ReadonlyPureSelectorOptions<T, E>): ReadonlyPureSelectorToken<T, any, E>;
|
|
976
|
+
type WritablePureSelectorFamilyOptions<T, K$1 extends Canonical, E = never> = {
|
|
977
977
|
/** The unique identifier of the family */
|
|
978
978
|
key: string;
|
|
979
979
|
/** For each instantiated family member, a function that computes its value */
|
|
980
|
-
get: (key: K$1) => Read<() => T
|
|
980
|
+
get: (key: K$1) => Read<() => T>;
|
|
981
981
|
/** For each instantiated family member, a function that sets its value */
|
|
982
|
-
set: (key: K$1) => Write<(newValue: T
|
|
982
|
+
set: (key: K$1) => Write<(newValue: T) => void>;
|
|
983
983
|
/** The classes of errors that might be thrown when deriving the atom's default value */
|
|
984
984
|
catch?: readonly Ctor<E>[];
|
|
985
985
|
};
|
|
986
|
-
type ReadonlyPureSelectorFamilyOptions<T
|
|
986
|
+
type ReadonlyPureSelectorFamilyOptions<T, K$1 extends Canonical, E = never> = {
|
|
987
987
|
/** The unique identifier of the family */
|
|
988
988
|
key: string;
|
|
989
989
|
/** For each instantiated family member, a function that computes its value */
|
|
990
|
-
get: (key: K$1) => Read<() => T
|
|
990
|
+
get: (key: K$1) => Read<() => T>;
|
|
991
991
|
/** The classes of errors that might be thrown when deriving the atom's default value */
|
|
992
992
|
catch?: readonly Ctor<E>[];
|
|
993
993
|
};
|
|
994
|
-
type WritableHeldSelectorFamilyOptions<T
|
|
994
|
+
type WritableHeldSelectorFamilyOptions<T extends object, K$1 extends Canonical> = {
|
|
995
995
|
/** The unique identifier of the family */
|
|
996
996
|
key: string;
|
|
997
997
|
/** For each instantiated family member, a constant reference to a value that will not be replaced */
|
|
998
|
-
const: (key: K$1) => T
|
|
998
|
+
const: (key: K$1) => T;
|
|
999
999
|
/** For each instantiated family member, a function that computes its value */
|
|
1000
|
-
get: (key: K$1) => Read<(permanent: T
|
|
1000
|
+
get: (key: K$1) => Read<(permanent: T) => void>;
|
|
1001
1001
|
/** For each instantiated family member, a function that sets its value */
|
|
1002
|
-
set: (key: K$1) => Write<(newValue: T
|
|
1002
|
+
set: (key: K$1) => Write<(newValue: T) => void>;
|
|
1003
1003
|
};
|
|
1004
|
-
type ReadonlyHeldSelectorFamilyOptions<T
|
|
1004
|
+
type ReadonlyHeldSelectorFamilyOptions<T extends object, K$1 extends Canonical> = {
|
|
1005
1005
|
/** The unique identifier of the family */
|
|
1006
1006
|
key: string;
|
|
1007
1007
|
/** For each instantiated family member, a constant reference to a value that will not be replaced */
|
|
1008
|
-
const: (key: K$1) => T
|
|
1008
|
+
const: (key: K$1) => T;
|
|
1009
1009
|
/** For each instantiated family member, a function that computes its value */
|
|
1010
|
-
get: (key: K$1) => Read<(permanent: T
|
|
1010
|
+
get: (key: K$1) => Read<(permanent: T) => void>;
|
|
1011
1011
|
};
|
|
1012
1012
|
/**
|
|
1013
1013
|
* Create a family of selectors, allowing for the dynamic creation and disposal of selectors.
|
|
@@ -1027,7 +1027,7 @@ type ReadonlyHeldSelectorFamilyOptions<T$1 extends object, K$1 extends Canonical
|
|
|
1027
1027
|
* A reference to the selector family created: a {@link WritableHeldSelectorFamilyToken}
|
|
1028
1028
|
* @overload WritableHeld
|
|
1029
1029
|
*/
|
|
1030
|
-
declare function selectorFamily<T
|
|
1030
|
+
declare function selectorFamily<T extends object, K$1 extends Canonical>(options: WritableHeldSelectorFamilyOptions<T, K$1>): WritableHeldSelectorFamilyToken<T, K$1>;
|
|
1031
1031
|
/**
|
|
1032
1032
|
* Create a family of selectors, allowing for the dynamic creation and disposal of selectors.
|
|
1033
1033
|
*
|
|
@@ -1044,7 +1044,7 @@ declare function selectorFamily<T$1 extends object, K$1 extends Canonical>(optio
|
|
|
1044
1044
|
* A reference to the selector family created: a {@link ReadonlyHeldSelectorFamilyToken}
|
|
1045
1045
|
* @overload ReadonlyHeld
|
|
1046
1046
|
*/
|
|
1047
|
-
declare function selectorFamily<T
|
|
1047
|
+
declare function selectorFamily<T extends object, K$1 extends Canonical>(options: ReadonlyHeldSelectorFamilyOptions<T, K$1>): ReadonlyHeldSelectorFamilyToken<T, K$1>;
|
|
1048
1048
|
/**
|
|
1049
1049
|
* Create a family of selectors, allowing for the dynamic creation and disposal of selectors.
|
|
1050
1050
|
*
|
|
@@ -1062,7 +1062,7 @@ declare function selectorFamily<T$1 extends object, K$1 extends Canonical>(optio
|
|
|
1062
1062
|
* A reference to the selector family created: a {@link TransientWritableSelectorFamilyToken}
|
|
1063
1063
|
* @overload WritablePure
|
|
1064
1064
|
*/
|
|
1065
|
-
declare function selectorFamily<T
|
|
1065
|
+
declare function selectorFamily<T, K$1 extends Canonical, E = never>(options: WritablePureSelectorFamilyOptions<T, K$1, E>): WritablePureSelectorFamilyToken<T, K$1, E>;
|
|
1066
1066
|
/**
|
|
1067
1067
|
* Create a family of selectors, allowing for the dynamic creation and disposal of selectors.
|
|
1068
1068
|
*
|
|
@@ -1078,7 +1078,7 @@ declare function selectorFamily<T$1, K$1 extends Canonical, E = never>(options:
|
|
|
1078
1078
|
* A reference to the selector family created: a {@link ReadonlyPureSelectorFamilyToken}
|
|
1079
1079
|
* @overload ReadonlyPure
|
|
1080
1080
|
*/
|
|
1081
|
-
declare function selectorFamily<T
|
|
1081
|
+
declare function selectorFamily<T, K$1 extends Canonical, E = never>(options: ReadonlyPureSelectorFamilyOptions<T, K$1, E>): ReadonlyPureSelectorFamilyToken<T, K$1, E>;
|
|
1082
1082
|
//#endregion
|
|
1083
1083
|
//#region src/main/silo.d.ts
|
|
1084
1084
|
declare class Silo {
|
|
@@ -1105,7 +1105,7 @@ declare class Silo {
|
|
|
1105
1105
|
}
|
|
1106
1106
|
//#endregion
|
|
1107
1107
|
//#region src/main/subscribe.d.ts
|
|
1108
|
-
type UpdateHandler<T
|
|
1108
|
+
type UpdateHandler<T> = (update: StateUpdate<T>) => void;
|
|
1109
1109
|
type TransactionUpdateHandler<F$1 extends Fn$1> = (data: TransactionOutcomeEvent<TransactionToken<F$1>>) => void;
|
|
1110
1110
|
/**
|
|
1111
1111
|
* Subscribe to a state in the implicit store
|
|
@@ -1115,7 +1115,7 @@ type TransactionUpdateHandler<F$1 extends Fn$1> = (data: TransactionOutcomeEvent
|
|
|
1115
1115
|
* @returns A function that can be called to unsubscribe from the state
|
|
1116
1116
|
* @overload State
|
|
1117
1117
|
*/
|
|
1118
|
-
declare function subscribe<T
|
|
1118
|
+
declare function subscribe<T>(token: ReadableToken<T>, handleUpdate: UpdateHandler<T>, key?: string): () => void;
|
|
1119
1119
|
/**
|
|
1120
1120
|
* Subscribe to a transaction in the implicit store
|
|
1121
1121
|
* @param token - The token of the transaction to subscribe to
|
|
@@ -1143,10 +1143,10 @@ declare function subscribe<M extends TimelineManageable>(token: TimelineToken<M>
|
|
|
1143
1143
|
*
|
|
1144
1144
|
* As a result, we consider any state that can be a set to a Promise to be a "loadable" state, whose value may or may not be a Promise at any given time.
|
|
1145
1145
|
*/
|
|
1146
|
-
type Loadable<T
|
|
1147
|
-
type ViewOf<T
|
|
1146
|
+
type Loadable<T> = Promise<T> | T;
|
|
1147
|
+
type ViewOf<T> = T extends {
|
|
1148
1148
|
READONLY_VIEW: infer View;
|
|
1149
|
-
} ? View : T
|
|
1149
|
+
} ? View : T;
|
|
1150
1150
|
//#endregion
|
|
1151
1151
|
export { $validatedKey, Above, ActorToolkit, Anarchy, AtomDisposalEvent, AtomEffect, AtomFamilyToken, AtomIOLogger, AtomIOToken, AtomOnly, AtomToken, AtomUpdateEvent, Below, CompoundFrom, CompoundTypedKey, Effectors, FamilyMetadata, HeldSelectorFamilyToken, HeldSelectorToken, Hierarchy, JoinOptions, JoinStates, JoinToken, LOG_LEVELS, Loadable, LogFilter, LogFn, LogLevel, Logger, LoggerIcon, MoleculeCreationEvent, MoleculeDisposalEvent, MoleculeTransferEvent, MutableAtomFamilyOptions, MutableAtomFamilyToken, MutableAtomOptions, MutableAtomToken, Mutuals, PRETTY_TOKEN_TYPES, PureSelectorFamilyToken, PureSelectorToken, Read, ReadableFamilyToken, ReadableStateCreationEvent, ReadableToken, ReaderToolkit, ReadonlyHeldSelectorFamilyOptions, ReadonlyHeldSelectorFamilyToken, ReadonlyHeldSelectorOptions, ReadonlyHeldSelectorToken, ReadonlyPureSelectorFamilyOptions, ReadonlyPureSelectorFamilyToken, ReadonlyPureSelectorOptions, ReadonlyPureSelectorToken, ReadonlySelectorFamilyToken, ReadonlySelectorToken, Realm, RegularAtomFamilyOptions, RegularAtomFamilyToken, RegularAtomOptions, RegularAtomToken, SelectorDisposalEvent, SelectorFamilyToken, SelectorToken, SelectorUpdateSubEvent, Setter, Silo, SingularTypedKey, StateCreationEvent, StateDisposalEvent, StateLifecycleEvent, StateUpdate, T$, TimelineEvent, TimelineManageable, TimelineOptions, TimelineSelectorUpdateEvent, TimelineToken, TokenDenomination, TokenType, Transact, TransactionIO, TransactionOptions, TransactionOutcomeEvent, TransactionSubEvent, TransactionToken, TransactionUpdateHandler, TypeTag, TypedKey, UpdateHandler, ValidKey, Vassal, ViewOf, WritableFamilyToken, WritableHeldSelectorFamilyOptions, WritableHeldSelectorFamilyToken, WritableHeldSelectorOptions, WritableHeldSelectorToken, WritablePureSelectorFamilyOptions, WritablePureSelectorFamilyToken, WritablePureSelectorOptions, WritablePureSelectorToken, WritableSelectorFamilyToken, WritableSelectorToken, WritableStateCreationEvent, WritableToken, Write, WriterToolkit, atom, atomFamily, belongsTo, decomposeCompound, disposeState, editRelations, findRelations, findState, getInternalRelations, getState, isToken, join, mutableAtom, mutableAtomFamily, redo, resetState, runTransaction, selector, selectorFamily, setState, simpleCompound, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
|
|
1152
1152
|
//# sourceMappingURL=index.d.ts.map
|