atom.io 0.34.0 → 0.34.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.js +1 -2
- package/dist/eslint-plugin/index.js.map +1 -1
- package/dist/internal/index.d.ts +6 -1
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +26 -22
- package/dist/internal/index.js.map +1 -1
- package/dist/json/index.d.ts +19 -4
- package/dist/json/index.d.ts.map +1 -1
- package/dist/json/index.js +4 -0
- package/dist/json/index.js.map +1 -1
- package/dist/main/index.d.ts +431 -26
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +109 -17
- package/dist/main/index.js.map +1 -1
- package/dist/realtime-client/index.js +4 -8
- package/dist/realtime-client/index.js.map +1 -1
- package/dist/realtime-server/index.js +1 -1
- package/dist/realtime-server/index.js.map +1 -1
- package/package.json +10 -10
- package/src/internal/join/create-join.ts +27 -0
- package/src/internal/join/index.ts +1 -0
- package/src/internal/junction.ts +2 -0
- package/src/json/entries.ts +10 -3
- package/src/json/index.ts +40 -14
- package/src/main/atom.ts +53 -12
- package/src/main/dispose-state.ts +8 -2
- package/src/main/find-state.ts +44 -14
- package/src/main/get-state.ts +2 -2
- package/src/main/index.ts +8 -0
- package/src/main/join.ts +78 -22
- package/src/main/realm.ts +50 -4
- package/src/main/selector.ts +116 -6
- package/src/main/subscribe.ts +31 -1
- package/src/main/timeline.ts +41 -15
- package/src/main/transaction.ts +39 -3
package/dist/main/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Each, EnvironmentData, Flat, Func, Junction, JunctionEntriesBase, JunctionSchemaBase, Refinement, Store, Timeline, TimelineAtomUpdate, TimelineMoleculeCreation, TimelineMoleculeDisposal, TimelineSelectorUpdate, TimelineStateCreation, TimelineStateDisposal, TimelineTransactionUpdate, Transceiver } from "atom.io/internal";
|
|
2
2
|
import { Canonical, Json, JsonInterface, stringified } from "atom.io/json";
|
|
3
|
-
import { MutableAtomFamilyToken as MutableAtomFamilyToken$1, MutableAtomToken as MutableAtomToken$1, ReadableFamilyToken as ReadableFamilyToken$1, ReadableToken as ReadableToken$1, ReadonlyPureSelectorFamilyToken as ReadonlyPureSelectorFamilyToken$1, ReadonlyPureSelectorToken as ReadonlyPureSelectorToken$1, RegularAtomFamilyToken as RegularAtomFamilyToken$1, RegularAtomToken as RegularAtomToken$1, WritableFamilyToken as WritableFamilyToken$1, WritablePureSelectorFamilyToken as WritablePureSelectorFamilyToken$1, WritablePureSelectorToken as WritablePureSelectorToken$1, WritableToken as WritableToken$1, findState as findState$1, getState as getState$1, setState as setState$1 } from "atom.io";
|
|
3
|
+
import { MutableAtomFamilyToken as MutableAtomFamilyToken$1, MutableAtomToken as MutableAtomToken$1, ReadableFamilyToken as ReadableFamilyToken$1, ReadableToken as ReadableToken$1, ReadonlyPureSelectorFamilyToken as ReadonlyPureSelectorFamilyToken$1, ReadonlyPureSelectorToken as ReadonlyPureSelectorToken$1, ReadonlySelectorFamilyToken as ReadonlySelectorFamilyToken$1, ReadonlySelectorToken as ReadonlySelectorToken$1, RegularAtomFamilyToken as RegularAtomFamilyToken$1, RegularAtomToken as RegularAtomToken$1, WritableFamilyToken as WritableFamilyToken$1, WritablePureSelectorFamilyToken as WritablePureSelectorFamilyToken$1, WritablePureSelectorToken as WritablePureSelectorToken$1, WritableSelectorFamilyToken as WritableSelectorFamilyToken$1, WritableSelectorToken as WritableSelectorToken$1, WritableToken as WritableToken$1, findState as findState$1, getState as getState$1, setState as setState$1 } from "atom.io";
|
|
4
4
|
import { SetRTX, SetRTXJson } from "atom.io/transceivers/set-rtx";
|
|
5
5
|
|
|
6
6
|
//#region src/main/atom.d.ts
|
|
@@ -60,9 +60,16 @@ type RegularAtomOptions<T> = {
|
|
|
60
60
|
/** Hooks used to run side effects when the atom is set */
|
|
61
61
|
effects?: AtomEffect<T>[];
|
|
62
62
|
};
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
/** @public */
|
|
64
|
+
type MutableAtomOptions<T extends Transceiver<any>, J extends Json.Serializable> = JsonInterface<T, J> & {
|
|
65
|
+
/** Used to signal that the atom is mutable */
|
|
65
66
|
mutable: true;
|
|
67
|
+
/** The unique identifier of the atom */
|
|
68
|
+
key: string;
|
|
69
|
+
/** A function to create an initial value for the atom */
|
|
70
|
+
default: () => T;
|
|
71
|
+
/** Hooks used to run side effects when the atom is set */
|
|
72
|
+
effects?: AtomEffect<T>[];
|
|
66
73
|
};
|
|
67
74
|
/** @public */
|
|
68
75
|
type RegularAtomFamilyOptions<T, K extends Canonical> = {
|
|
@@ -74,26 +81,59 @@ type RegularAtomFamilyOptions<T, K extends Canonical> = {
|
|
|
74
81
|
effects?: (key: K) => AtomEffect<T>[];
|
|
75
82
|
};
|
|
76
83
|
type RegularAtomFamilyToken<T, K extends Canonical> = {
|
|
84
|
+
/** The unique identifier of the atom family */
|
|
77
85
|
key: string;
|
|
86
|
+
/** Discriminator */
|
|
78
87
|
type: `atom_family`;
|
|
88
|
+
/** Never present. This is a marker that preserves the type of atoms in this family */
|
|
79
89
|
__T?: T;
|
|
90
|
+
/** Never present. This is a marker that preserves the type of keys used for atoms in this family */
|
|
80
91
|
__K?: K;
|
|
81
92
|
};
|
|
93
|
+
/** @public */
|
|
82
94
|
type MutableAtomFamilyOptions<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical> = JsonInterface<T, J> & {
|
|
95
|
+
/** Used to signal that the atoms created from this family are mutable */
|
|
96
|
+
mutable: true;
|
|
97
|
+
/** The unique identifier of the atom family */
|
|
83
98
|
key: string;
|
|
99
|
+
/** A function to create an initial value for each atom in the family */
|
|
84
100
|
default: (key: K) => T;
|
|
101
|
+
/** Hooks used to run side effects when an atom in the family is set */
|
|
85
102
|
effects?: (key: K) => AtomEffect<T>[];
|
|
86
|
-
mutable: true;
|
|
87
103
|
};
|
|
88
104
|
type MutableAtomFamilyToken<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical> = {
|
|
105
|
+
/** The unique identifier of the atom family */
|
|
89
106
|
key: string;
|
|
107
|
+
/** Discriminator */
|
|
90
108
|
type: `mutable_atom_family`;
|
|
109
|
+
/** Never present. This is a marker that preserves the type of atoms in this family */
|
|
91
110
|
__T?: T;
|
|
111
|
+
/** Never present. This is a marker that preserves the type of the JSON form of atoms in this family */
|
|
92
112
|
__J?: J;
|
|
113
|
+
/** Never present. This is a marker that preserves the type of keys used for atoms in this family */
|
|
93
114
|
__K?: K;
|
|
94
115
|
};
|
|
95
116
|
type AtomFamilyToken<T, K extends Canonical = Canonical> = MutableAtomFamilyToken<T extends Transceiver<any> ? T : never, any, K> | RegularAtomFamilyToken<T, K>;
|
|
117
|
+
/**
|
|
118
|
+
* @public
|
|
119
|
+
* Create a family of mutable atoms, allowing for the dynamic creation and disposal of atoms.
|
|
120
|
+
*
|
|
121
|
+
* The value of a mutable atom must be some kind of {@link Transceiver}.
|
|
122
|
+
*
|
|
123
|
+
* @param options - {@link MutableAtomFamilyOptions}
|
|
124
|
+
* @returns
|
|
125
|
+
* A reference to the atom family created: a {@link MutableAtomFamilyToken}
|
|
126
|
+
* @overload Mutable
|
|
127
|
+
*/
|
|
96
128
|
declare function atomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical>(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamilyToken<T, J, K>;
|
|
129
|
+
/**
|
|
130
|
+
* @public
|
|
131
|
+
* Create a family of regular atoms, allowing for the dynamic creation and disposal of atoms.
|
|
132
|
+
* @param options - {@link RegularAtomFamilyOptions}
|
|
133
|
+
* @returns
|
|
134
|
+
* A reference to the atom family created: a {@link RegularAtomFamilyToken}
|
|
135
|
+
* @overload Regular
|
|
136
|
+
*/
|
|
97
137
|
declare function atomFamily<T, K extends Canonical>(options: RegularAtomFamilyOptions<T, K>): RegularAtomFamilyToken<T, K>;
|
|
98
138
|
//#endregion
|
|
99
139
|
//#region src/main/reset-state.d.ts
|
|
@@ -115,45 +155,58 @@ declare function resetState(token: WritableToken<any>): void;
|
|
|
115
155
|
declare function resetState<K extends Canonical>(token: WritableFamilyToken<any, K>, key: K): void;
|
|
116
156
|
//#endregion
|
|
117
157
|
//#region src/main/transaction.d.ts
|
|
158
|
+
/** @public */
|
|
118
159
|
type TransactionToken<F extends Func> = {
|
|
160
|
+
/** The unique identifier of the transaction */
|
|
119
161
|
key: string;
|
|
162
|
+
/** Discriminator */
|
|
120
163
|
type: `transaction`;
|
|
164
|
+
/** Never present. This is a marker that preserves the type of the transaction function */
|
|
121
165
|
__F?: F;
|
|
122
166
|
};
|
|
167
|
+
/** @public */
|
|
123
168
|
type StateCreation<Token extends ReadableToken<any>> = {
|
|
124
169
|
type: `state_creation`;
|
|
125
170
|
token: Token;
|
|
126
171
|
};
|
|
172
|
+
/** @public */
|
|
127
173
|
type AtomDisposal<Token extends ReadableToken<any>> = {
|
|
128
174
|
type: `state_disposal`;
|
|
129
175
|
subType: `atom`;
|
|
130
176
|
token: Token;
|
|
131
177
|
value: TokenType<Token>;
|
|
132
178
|
};
|
|
179
|
+
/** @public */
|
|
133
180
|
type SelectorDisposal<Token extends ReadableToken<any>> = {
|
|
134
181
|
type: `state_disposal`;
|
|
135
182
|
subType: `selector`;
|
|
136
183
|
token: Token;
|
|
137
184
|
};
|
|
185
|
+
/** @public */
|
|
138
186
|
type StateDisposal<Token extends ReadableToken<any>> = AtomDisposal<Token> | SelectorDisposal<Token>;
|
|
187
|
+
/** @public */
|
|
139
188
|
type MoleculeCreation = {
|
|
140
189
|
type: `molecule_creation`;
|
|
141
190
|
key: Canonical;
|
|
142
191
|
provenance: Canonical;
|
|
143
192
|
};
|
|
193
|
+
/** @public */
|
|
144
194
|
type MoleculeDisposal = {
|
|
145
195
|
type: `molecule_disposal`;
|
|
146
196
|
key: Canonical;
|
|
147
197
|
provenance: stringified<Canonical>[];
|
|
148
198
|
values: [key: string, value: any][];
|
|
149
199
|
};
|
|
200
|
+
/** @public */
|
|
150
201
|
type MoleculeTransfer = {
|
|
151
202
|
type: `molecule_transfer`;
|
|
152
203
|
key: Canonical;
|
|
153
204
|
from: Canonical[];
|
|
154
205
|
to: Canonical[];
|
|
155
206
|
};
|
|
207
|
+
/** @public */
|
|
156
208
|
type TransactionUpdateContent = KeyedStateUpdate<unknown> | MoleculeCreation | MoleculeDisposal | MoleculeTransfer | StateCreation<ReadableToken<unknown>> | StateDisposal<ReadableToken<unknown>> | TransactionUpdate<Func>;
|
|
209
|
+
/** @public */
|
|
157
210
|
type TransactionUpdate<F extends Func> = {
|
|
158
211
|
type: `transaction_update`;
|
|
159
212
|
key: string;
|
|
@@ -163,13 +216,16 @@ type TransactionUpdate<F extends Func> = {
|
|
|
163
216
|
params: Parameters<F>;
|
|
164
217
|
output: ReturnType<F>;
|
|
165
218
|
};
|
|
219
|
+
/** @public */
|
|
166
220
|
type GetterToolkit = Pick<SetterToolkit, `find` | `get` | `json`>;
|
|
221
|
+
/** @public */
|
|
167
222
|
type SetterToolkit = Readonly<{
|
|
168
223
|
get: typeof getState$1;
|
|
169
224
|
set: typeof setState$1;
|
|
170
225
|
find: typeof findState$1;
|
|
171
226
|
json: <T extends Transceiver<any>, J extends Json.Serializable>(state: MutableAtomToken<T, J>) => WritablePureSelectorToken<J>;
|
|
172
227
|
}>;
|
|
228
|
+
/** @public */
|
|
173
229
|
type ActorToolkit = Readonly<{
|
|
174
230
|
get: typeof getState$1;
|
|
175
231
|
set: typeof setState$1;
|
|
@@ -180,36 +236,68 @@ type ActorToolkit = Readonly<{
|
|
|
180
236
|
run: typeof runTransaction;
|
|
181
237
|
env: () => EnvironmentData;
|
|
182
238
|
}>;
|
|
239
|
+
/** @public */
|
|
183
240
|
type Read<F extends Func> = (toolkit: GetterToolkit, ...parameters: Parameters<F>) => ReturnType<F>;
|
|
241
|
+
/** @public */
|
|
184
242
|
type Write<F extends Func> = (toolkit: SetterToolkit, ...parameters: Parameters<F>) => ReturnType<F>;
|
|
243
|
+
/** @public */
|
|
185
244
|
type Transact<F extends Func> = (toolkit: ActorToolkit, ...parameters: Parameters<F>) => ReturnType<F>;
|
|
245
|
+
/** @public */
|
|
246
|
+
type TransactionIO<Token extends TransactionToken<any>> = Token extends TransactionToken<infer F> ? F : never;
|
|
247
|
+
/** @public */
|
|
186
248
|
type TransactionOptions<F extends Func> = {
|
|
249
|
+
/** The unique identifier of the transaction */
|
|
187
250
|
key: string;
|
|
251
|
+
/** The operation to perform */
|
|
188
252
|
do: Transact<F>;
|
|
189
253
|
};
|
|
190
|
-
|
|
254
|
+
/**
|
|
255
|
+
* @public
|
|
256
|
+
* Create a transaction, a mechanism for batching updates multiple states in a single, all-or-nothing operation
|
|
257
|
+
* @param options - {@link TransactionOptions}
|
|
258
|
+
* @returns A reference to the transaction created: a {@link TransactionToken}
|
|
259
|
+
*/
|
|
191
260
|
declare function transaction<F extends Func>(options: TransactionOptions<F>): TransactionToken<F>;
|
|
261
|
+
/**
|
|
262
|
+
* @public
|
|
263
|
+
* Execute a {@link transaction}
|
|
264
|
+
* @param token - A {@link TransactionToken}
|
|
265
|
+
* @param id - A unique identifier for the transaction. If not provided, a random identifier will be generated
|
|
266
|
+
* @returns A function that can be called to run the transaction with its {@link TransactionIO} parameters
|
|
267
|
+
*/
|
|
192
268
|
declare function runTransaction<F extends Func>(token: TransactionToken<F>, id?: string): (...parameters: Parameters<F>) => ReturnType<F>;
|
|
193
269
|
//#endregion
|
|
194
270
|
//#region src/main/selector.d.ts
|
|
195
271
|
type WritablePureSelectorOptions<T> = {
|
|
272
|
+
/** The unique identifier of the selector */
|
|
196
273
|
key: string;
|
|
274
|
+
/** For each instantiated selector, a function that computes its value */
|
|
197
275
|
get: Read<() => T>;
|
|
276
|
+
/** For each instantiated selector, a function that sets its value */
|
|
198
277
|
set: Write<(newValue: T) => void>;
|
|
199
278
|
};
|
|
200
279
|
type ReadonlyPureSelectorOptions<T> = {
|
|
280
|
+
/** The unique identifier of the selector */
|
|
201
281
|
key: string;
|
|
282
|
+
/** For each instantiated selector, a function that computes its value */
|
|
202
283
|
get: Read<() => T>;
|
|
203
284
|
};
|
|
204
285
|
type ReadonlyHeldSelectorOptions<T extends object> = {
|
|
286
|
+
/** The unique identifier of the selector */
|
|
205
287
|
key: string;
|
|
288
|
+
/** For each instantiated selector, a constant reference to a value that will not be replaced */
|
|
206
289
|
const: T;
|
|
290
|
+
/** For each instantiated selector, a function that computes its value */
|
|
207
291
|
get: Read<(permanent: T) => void>;
|
|
208
292
|
};
|
|
209
293
|
type WritableHeldSelectorOptions<T extends object> = {
|
|
294
|
+
/** The unique identifier of the selector */
|
|
210
295
|
key: string;
|
|
296
|
+
/** For each instantiated selector, a constant reference to a value that will not be replaced */
|
|
211
297
|
const: T;
|
|
298
|
+
/** For each instantiated selector, a function that computes its value */
|
|
212
299
|
get: Read<(permanent: T) => void>;
|
|
300
|
+
/** For each instantiated selector, a function that sets its value */
|
|
213
301
|
set: Write<(newValue: T) => void>;
|
|
214
302
|
};
|
|
215
303
|
/**
|
|
@@ -222,7 +310,7 @@ type WritableHeldSelectorOptions<T extends object> = {
|
|
|
222
310
|
* The reference to that object is permanent and will not be replaced.
|
|
223
311
|
*
|
|
224
312
|
* A writable selector can be "set" to a new value.
|
|
225
|
-
* It is advised to set its dependencies to values
|
|
313
|
+
* It is strongly advised to set its dependencies to values
|
|
226
314
|
* that would produce the new value of the selector.
|
|
227
315
|
*
|
|
228
316
|
* @param options - {@link WritableHeldSelectorOptions}.
|
|
@@ -257,7 +345,7 @@ declare function selector<T extends object>(options: ReadonlyHeldSelectorOptions
|
|
|
257
345
|
* in order to be garbage collected when a root atom of the selector is set.
|
|
258
346
|
*
|
|
259
347
|
* A writable selector can be "set" to a new value.
|
|
260
|
-
* It is advised to set its dependencies to values
|
|
348
|
+
* It is strongly advised to set its dependencies to values
|
|
261
349
|
* that would produce the new value of the selector.
|
|
262
350
|
*
|
|
263
351
|
* @param options - {@link TransientWritableSelectorOptions}.
|
|
@@ -282,48 +370,80 @@ declare function selector<T>(options: WritablePureSelectorOptions<T>): WritableP
|
|
|
282
370
|
* @overload ReadonlyPure
|
|
283
371
|
*/
|
|
284
372
|
declare function selector<T>(options: ReadonlyPureSelectorOptions<T>): ReadonlyPureSelectorToken<T>;
|
|
373
|
+
/** @public */
|
|
285
374
|
type WritablePureSelectorFamilyOptions<T, K extends Canonical> = {
|
|
375
|
+
/** The unique identifier of the family */
|
|
286
376
|
key: string;
|
|
377
|
+
/** For each instantiated family member, a function that computes its value */
|
|
287
378
|
get: (key: K) => Read<() => T>;
|
|
379
|
+
/** For each instantiated family member, a function that sets its value */
|
|
288
380
|
set: (key: K) => Write<(newValue: T) => void>;
|
|
289
381
|
};
|
|
382
|
+
/** @public */
|
|
290
383
|
type ReadonlyPureSelectorFamilyOptions<T, K extends Canonical> = {
|
|
384
|
+
/** The unique identifier of the family */
|
|
291
385
|
key: string;
|
|
386
|
+
/** For each instantiated family member, a function that computes its value */
|
|
292
387
|
get: (key: K) => Read<() => T>;
|
|
293
388
|
};
|
|
389
|
+
/** @public */
|
|
294
390
|
type WritableHeldSelectorFamilyOptions<T extends object, K extends Canonical> = {
|
|
391
|
+
/** The unique identifier of the family */
|
|
295
392
|
key: string;
|
|
393
|
+
/** For each instantiated family member, a constant reference to a value that will not be replaced */
|
|
296
394
|
const: (key: K) => T;
|
|
395
|
+
/** For each instantiated family member, a function that computes its value */
|
|
297
396
|
get: (key: K) => Read<(permanent: T) => void>;
|
|
397
|
+
/** For each instantiated family member, a function that sets its value */
|
|
298
398
|
set: (key: K) => Write<(newValue: T) => void>;
|
|
299
399
|
};
|
|
400
|
+
/** @public */
|
|
300
401
|
type ReadonlyHeldSelectorFamilyOptions<T extends object, K extends Canonical> = {
|
|
402
|
+
/** The unique identifier of the family */
|
|
301
403
|
key: string;
|
|
404
|
+
/** For each instantiated family member, a constant reference to a value that will not be replaced */
|
|
302
405
|
const: (key: K) => T;
|
|
406
|
+
/** For each instantiated family member, a function that computes its value */
|
|
303
407
|
get: (key: K) => Read<(permanent: T) => void>;
|
|
304
408
|
};
|
|
305
409
|
type WritablePureSelectorFamilyToken<T, K extends Canonical> = {
|
|
410
|
+
/** The unique identifier of the family */
|
|
306
411
|
key: string;
|
|
412
|
+
/** Discriminator */
|
|
307
413
|
type: `writable_pure_selector_family`;
|
|
414
|
+
/** Never present. This is a marker that preserves the type of the value of each family member */
|
|
308
415
|
__T?: T;
|
|
416
|
+
/** Never present. This is a marker that preserves the type of keys used for each family member */
|
|
309
417
|
__K?: K;
|
|
310
418
|
};
|
|
311
419
|
type ReadonlyPureSelectorFamilyToken<T, K extends Canonical> = {
|
|
420
|
+
/** The unique identifier of the family */
|
|
312
421
|
key: string;
|
|
422
|
+
/** Discriminator */
|
|
313
423
|
type: `readonly_pure_selector_family`;
|
|
424
|
+
/** Never present. This is a marker that preserves the type of the value of each family member */
|
|
314
425
|
__T?: T;
|
|
426
|
+
/** Never present. This is a marker that preserves the type of keys used for each family member */
|
|
315
427
|
__K?: K;
|
|
316
428
|
};
|
|
317
429
|
type WritableHeldSelectorFamilyToken<T, K extends Canonical> = {
|
|
430
|
+
/** The unique identifier of the family */
|
|
318
431
|
key: string;
|
|
432
|
+
/** Discriminator */
|
|
319
433
|
type: `writable_held_selector_family`;
|
|
434
|
+
/** Never present. This is a marker that preserves the type of the value of each family member */
|
|
320
435
|
__T?: T;
|
|
436
|
+
/** Never present. This is a marker that preserves the type of keys used for each family member */
|
|
321
437
|
__K?: K;
|
|
322
438
|
};
|
|
323
439
|
type ReadonlyHeldSelectorFamilyToken<T, K extends Canonical> = {
|
|
440
|
+
/** The unique identifier of the family */
|
|
324
441
|
key: string;
|
|
442
|
+
/** Discriminator */
|
|
325
443
|
type: `readonly_held_selector_family`;
|
|
444
|
+
/** Never present. This is a marker that preserves the type of the value of each family member */
|
|
326
445
|
__T?: T;
|
|
446
|
+
/** Never present. This is a marker that preserves the type of keys used for each family member */
|
|
327
447
|
__K?: K;
|
|
328
448
|
};
|
|
329
449
|
type PureSelectorFamilyToken<T, K extends Canonical> = ReadonlyPureSelectorFamilyToken<T, K> | WritablePureSelectorFamilyToken<T, K>;
|
|
@@ -331,40 +451,143 @@ type HeldSelectorFamilyToken<T, K extends Canonical> = ReadonlyHeldSelectorFamil
|
|
|
331
451
|
type ReadonlySelectorFamilyToken<T, K extends Canonical> = ReadonlyHeldSelectorFamilyToken<T, K> | ReadonlyPureSelectorFamilyToken<T, K>;
|
|
332
452
|
type WritableSelectorFamilyToken<T, K extends Canonical> = WritableHeldSelectorFamilyToken<T, K> | WritablePureSelectorFamilyToken<T, K>;
|
|
333
453
|
type SelectorFamilyToken<T, K extends Canonical> = HeldSelectorFamilyToken<T, K> | PureSelectorFamilyToken<T, K>;
|
|
454
|
+
/**
|
|
455
|
+
* @public
|
|
456
|
+
* Create a family of selectors, allowing for the dynamic creation and disposal of selectors.
|
|
457
|
+
*
|
|
458
|
+
* The value of a held selector should depend on the value of atoms or other selectors in the store,
|
|
459
|
+
* and should be recycled when a root atom of the selector is set.
|
|
460
|
+
*
|
|
461
|
+
* A held selector's value must be some object.
|
|
462
|
+
* The reference to that object is permanent and will not be replaced.
|
|
463
|
+
*
|
|
464
|
+
* A writable selector can be "set" to a new value.
|
|
465
|
+
* It is advised to set its dependencies to values
|
|
466
|
+
* that would produce the new value of the selector.
|
|
467
|
+
*
|
|
468
|
+
* @param options - {@link WritableHeldSelectorFamilyOptions}.
|
|
469
|
+
* @returns
|
|
470
|
+
* A reference to the selector family created: a {@link WritableHeldSelectorFamilyToken}
|
|
471
|
+
* @overload WritableHeld
|
|
472
|
+
*/
|
|
334
473
|
declare function selectorFamily<T extends object, K extends Canonical>(options: WritableHeldSelectorFamilyOptions<T, K>): WritableHeldSelectorFamilyToken<T, K>;
|
|
474
|
+
/**
|
|
475
|
+
* @public
|
|
476
|
+
* Create a family of selectors, allowing for the dynamic creation and disposal of selectors.
|
|
477
|
+
*
|
|
478
|
+
* The value of a held selector should depend on the value of atoms or other selectors in the store,
|
|
479
|
+
* and should be recycled when a root atom of the selector is set.
|
|
480
|
+
*
|
|
481
|
+
* A held selector's value must be some object.
|
|
482
|
+
* The reference to that object is permanent and will not be replaced.
|
|
483
|
+
*
|
|
484
|
+
* A readonly selector can be "gotten" but not "set".
|
|
485
|
+
*
|
|
486
|
+
* @param options - {@link ReadonlyHeldSelectorFamilyOptions}.
|
|
487
|
+
* @returns
|
|
488
|
+
* A reference to the selector family created: a {@link ReadonlyHeldSelectorFamilyToken}
|
|
489
|
+
* @overload ReadonlyHeld
|
|
490
|
+
*/
|
|
335
491
|
declare function selectorFamily<T extends object, K extends Canonical>(options: ReadonlyHeldSelectorFamilyOptions<T, K>): ReadonlyHeldSelectorFamilyToken<T, K>;
|
|
492
|
+
/**
|
|
493
|
+
* @public
|
|
494
|
+
* Create a family of selectors, allowing for the dynamic creation and disposal of selectors.
|
|
495
|
+
*
|
|
496
|
+
* The value of a selector should depend on the value of atoms or other selectors in the store.
|
|
497
|
+
*
|
|
498
|
+
* A pure selector's current value is evicted from the store
|
|
499
|
+
* in order to be garbage collected when a root atom of the selector is set.
|
|
500
|
+
*
|
|
501
|
+
* A writable selector can be "set" to a new value.
|
|
502
|
+
* It is advised to set its dependencies to values
|
|
503
|
+
* that would produce the new value of the selector.
|
|
504
|
+
*
|
|
505
|
+
* @param options - {@link TransientWritableSelectorFamilyOptions}.
|
|
506
|
+
* @returns
|
|
507
|
+
* A reference to the selector family created: a {@link TransientWritableSelectorFamilyToken}
|
|
508
|
+
* @overload WritablePure
|
|
509
|
+
*/
|
|
336
510
|
declare function selectorFamily<T, K extends Canonical>(options: WritablePureSelectorFamilyOptions<T, K>): WritablePureSelectorFamilyToken<T, K>;
|
|
511
|
+
/**
|
|
512
|
+
* @public
|
|
513
|
+
* Create a family of selectors, allowing for the dynamic creation and disposal of selectors.
|
|
514
|
+
*
|
|
515
|
+
* The value of a selector should depend on the value of atoms or other selectors in the store.
|
|
516
|
+
*
|
|
517
|
+
* A pure selector's current value is evicted from the store
|
|
518
|
+
* in order to be garbage collected when a root atom of the selector is set.
|
|
519
|
+
*
|
|
520
|
+
* A readonly selector can be "gotten" but not "set".
|
|
521
|
+
*
|
|
522
|
+
* @param options - {@link ReadonlyPureSelectorFamilyOptions}.
|
|
523
|
+
* @returns
|
|
524
|
+
* A reference to the selector family created: a {@link ReadonlyPureSelectorFamilyToken}
|
|
525
|
+
* @overload ReadonlyPure
|
|
526
|
+
*/
|
|
337
527
|
declare function selectorFamily<T, K extends Canonical>(options: ReadonlyPureSelectorFamilyOptions<T, K>): ReadonlyPureSelectorFamilyToken<T, K>;
|
|
338
528
|
//#endregion
|
|
339
529
|
//#region src/main/timeline.d.ts
|
|
530
|
+
/** @public */
|
|
340
531
|
type TimelineManageable = AtomFamilyToken<any, any> | AtomToken<any>;
|
|
532
|
+
/** @public */
|
|
341
533
|
type AtomOnly<M extends TimelineManageable> = M extends AtomFamilyToken<any, any> ? AtomToken<any> : M extends AtomToken<any> ? M : never;
|
|
534
|
+
/** @public */
|
|
342
535
|
type TimelineToken<M> = {
|
|
536
|
+
/** The unique identifier of the timeline */
|
|
343
537
|
key: string;
|
|
538
|
+
/** Discriminator */
|
|
344
539
|
type: `timeline`;
|
|
540
|
+
/** Never present. This is a marker that preserves the type of the managed atoms */
|
|
345
541
|
__M?: M;
|
|
346
542
|
};
|
|
543
|
+
/**
|
|
544
|
+
* @public
|
|
545
|
+
* If there is an update ahead of the cursor (in the future of this {@link timeline}), apply it and move the cursor to the next update
|
|
546
|
+
* @param timeline - A {@link TimelineToken}
|
|
547
|
+
*/
|
|
548
|
+
declare const redo: (timeline: TimelineToken<any>) => void;
|
|
549
|
+
/**
|
|
550
|
+
* @public
|
|
551
|
+
* Reverse the last update on the {@link timeline} and move the cursor to the previous update
|
|
552
|
+
* @param timeline - A {@link TimelineToken}
|
|
553
|
+
*/
|
|
554
|
+
declare const undo: (timeline: TimelineToken<any>) => void;
|
|
555
|
+
/** @public */
|
|
556
|
+
type TimelineUpdate<ManagedAtom extends TimelineManageable> = TimelineAtomUpdate<ManagedAtom> | TimelineMoleculeCreation | TimelineMoleculeDisposal | TimelineSelectorUpdate<ManagedAtom> | TimelineStateCreation<AtomOnly<ManagedAtom>> | TimelineStateDisposal<AtomOnly<ManagedAtom>> | TimelineTransactionUpdate;
|
|
557
|
+
/** @public */
|
|
347
558
|
type TimelineOptions<ManagedAtom extends TimelineManageable> = {
|
|
559
|
+
/** The unique identifier of the timeline */
|
|
348
560
|
key: string;
|
|
561
|
+
/** The managed atoms (and families of atoms) to record */
|
|
349
562
|
scope: ManagedAtom[];
|
|
563
|
+
/** A function that determines whether a given update should be recorded */
|
|
350
564
|
shouldCapture?: (update: TimelineUpdate<ManagedAtom>, timeline: Timeline<TimelineManageable>) => boolean;
|
|
351
565
|
};
|
|
352
|
-
|
|
566
|
+
/**
|
|
567
|
+
* @public
|
|
568
|
+
* Create a timeline, a mechanism for recording, undoing, and replaying changes to groups of atoms
|
|
569
|
+
* @param options - {@link TimelineOptions}
|
|
570
|
+
* @returns A reference to the timeline created: a {@link TimelineToken}
|
|
571
|
+
*/
|
|
353
572
|
declare const timeline: <ManagedAtom extends TimelineManageable>(options: TimelineOptions<ManagedAtom>) => TimelineToken<ManagedAtom>;
|
|
354
|
-
declare const redo: (tl: TimelineToken<any>) => void;
|
|
355
|
-
declare const undo: (tl: TimelineToken<any>) => void;
|
|
356
573
|
//#endregion
|
|
357
574
|
//#region src/main/dispose-state.d.ts
|
|
358
575
|
/**
|
|
359
576
|
* @public
|
|
360
|
-
* Disposes of a state in the implicit store
|
|
577
|
+
* Disposes of a state in the implicit store.
|
|
578
|
+
*
|
|
579
|
+
* Only family members can be disposed of.
|
|
580
|
+
*
|
|
361
581
|
* @param token - The token of the state to dispose
|
|
362
582
|
* @overload Default
|
|
363
583
|
*/
|
|
364
584
|
declare function disposeState(token: ReadableToken<any>): void;
|
|
365
585
|
/**
|
|
366
586
|
* @public
|
|
367
|
-
* Disposes of a state
|
|
587
|
+
* Disposes of a state in the implicit store.
|
|
588
|
+
*
|
|
589
|
+
* Only family members can be disposed of.
|
|
590
|
+
*
|
|
368
591
|
* @param token - The token of the state family to dispose
|
|
369
592
|
* @param key - The unique key of the state to dispose
|
|
370
593
|
*/
|
|
@@ -373,7 +596,12 @@ declare function disposeState<K extends Canonical>(token: ReadableFamilyToken<an
|
|
|
373
596
|
//#region src/main/find-state.d.ts
|
|
374
597
|
/**
|
|
375
598
|
* @public
|
|
376
|
-
* Finds a {@link MutableAtomToken} in the store
|
|
599
|
+
* Finds a {@link MutableAtomToken} in the store, without accessing its value.
|
|
600
|
+
*
|
|
601
|
+
* In an ephemeral store, this will create a new atom if one does not exist with the given key.
|
|
602
|
+
*
|
|
603
|
+
* In an immortal store, a "counterfeit" atom token will be returned in this case and a warning will be logged.
|
|
604
|
+
*
|
|
377
605
|
* @param token - A {@link MutableAtomFamilyToken}
|
|
378
606
|
* @param key - The key of the state
|
|
379
607
|
* @returns
|
|
@@ -383,7 +611,12 @@ declare function disposeState<K extends Canonical>(token: ReadableFamilyToken<an
|
|
|
383
611
|
declare function findState<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical, Key extends K>(token: MutableAtomFamilyToken$1<T, J, K>, key: Key): MutableAtomToken$1<T, J, K>;
|
|
384
612
|
/**
|
|
385
613
|
* @public
|
|
386
|
-
* Finds a
|
|
614
|
+
* Finds a {@link RegularAtomToken} in the store, without accessing its value.
|
|
615
|
+
*
|
|
616
|
+
* In an ephemeral store, this will create a new atom if one does not exist with the given key.
|
|
617
|
+
*
|
|
618
|
+
* In an immortal store, a "counterfeit" atom token will be returned in this case and a warning will be logged.
|
|
619
|
+
*
|
|
387
620
|
* @param token - The token of the state family
|
|
388
621
|
* @param key - The key of the state
|
|
389
622
|
* @returns
|
|
@@ -393,27 +626,42 @@ declare function findState<T extends Transceiver<any>, J extends Json.Serializab
|
|
|
393
626
|
declare function findState<T, K extends Canonical, Key extends K>(token: RegularAtomFamilyToken$1<T, K>, key: Key): RegularAtomToken$1<T, K>;
|
|
394
627
|
/**
|
|
395
628
|
* @public
|
|
396
|
-
* Finds a
|
|
629
|
+
* Finds a {@link WritableSelectorToken} in the store, without accessing its value.
|
|
630
|
+
*
|
|
631
|
+
* In an ephemeral store, this will create a new selector if one does not exist with the given key.
|
|
632
|
+
*
|
|
633
|
+
* In an immortal store, a "counterfeit" selector token will be returned in this case and a warning will be logged.
|
|
634
|
+
*
|
|
397
635
|
* @param token - The token of the state family
|
|
398
636
|
* @param key - The key of the state
|
|
399
637
|
* @returns
|
|
400
638
|
* The current value of the state
|
|
401
639
|
* @overload Writable Selector
|
|
402
640
|
*/
|
|
403
|
-
declare function findState<T, K extends Canonical, Key extends K>(token:
|
|
641
|
+
declare function findState<T, K extends Canonical, Key extends K>(token: WritableSelectorFamilyToken$1<T, K>, key: Key): WritableSelectorToken$1<T, K>;
|
|
404
642
|
/**
|
|
405
643
|
* @public
|
|
406
|
-
* Finds a
|
|
644
|
+
* Finds a {@link ReadonlySelectorToken} in the store, without accessing its value.
|
|
645
|
+
*
|
|
646
|
+
* In an ephemeral store, this will create a new selector if one does not exist with the given key.
|
|
647
|
+
*
|
|
648
|
+
* In an immortal store, a "counterfeit" selector token will be returned in this case and a warning will be logged.
|
|
649
|
+
*
|
|
407
650
|
* @param token - The token of the state family
|
|
408
651
|
* @param key - The key of the state
|
|
409
652
|
* @returns
|
|
410
653
|
* The current value of the state
|
|
411
654
|
* @overload Readonly Selector
|
|
412
655
|
*/
|
|
413
|
-
declare function findState<T, K extends Canonical, Key extends K>(token:
|
|
656
|
+
declare function findState<T, K extends Canonical, Key extends K>(token: ReadonlySelectorFamilyToken$1<T, K>, key: Key): ReadonlySelectorToken$1<T, K>;
|
|
414
657
|
/**
|
|
415
658
|
* @public
|
|
416
|
-
* Finds a
|
|
659
|
+
* Finds a {@link WritableToken} in the store, without accessing its value.
|
|
660
|
+
*
|
|
661
|
+
* In an ephemeral store, this will create a new atom or selector if one does not exist with the given key.
|
|
662
|
+
*
|
|
663
|
+
* In an immortal store, a "counterfeit" token will be returned in this case and a warning will be logged.
|
|
664
|
+
*
|
|
417
665
|
* @param token - The token of the state family
|
|
418
666
|
* @param key - The key of the state
|
|
419
667
|
* @returns
|
|
@@ -423,7 +671,12 @@ declare function findState<T, K extends Canonical, Key extends K>(token: Readonl
|
|
|
423
671
|
declare function findState<T, K extends Canonical, Key extends K>(token: WritableFamilyToken$1<T, K>, key: Key): WritableToken$1<T, K>;
|
|
424
672
|
/**
|
|
425
673
|
* @public
|
|
426
|
-
* Finds a {@link
|
|
674
|
+
* Finds a {@link MutableAtomToken} in the store, without accessing its value.
|
|
675
|
+
*
|
|
676
|
+
* In an ephemeral store, this will create a new atom or selector if one does not exist with the given key.
|
|
677
|
+
*
|
|
678
|
+
* In an immortal store, a "counterfeit" token will be returned in this case and a warning will be logged.
|
|
679
|
+
*
|
|
427
680
|
* @param token - A {@link ReadableFamilyToken}
|
|
428
681
|
* @param key - The key of the state
|
|
429
682
|
* @returns
|
|
@@ -436,7 +689,7 @@ declare function findState<T, K extends Canonical, Key extends K>(token: Readabl
|
|
|
436
689
|
//#region src/main/get-state.d.ts
|
|
437
690
|
/**
|
|
438
691
|
* @public
|
|
439
|
-
*
|
|
692
|
+
* Read or compute the current value of a state
|
|
440
693
|
* @param token - The token of the state to get
|
|
441
694
|
* @return The current value of the state
|
|
442
695
|
* @overload Default
|
|
@@ -445,7 +698,7 @@ declare function findState<T, K extends Canonical, Key extends K>(token: Readabl
|
|
|
445
698
|
declare function getState<T>(token: ReadableToken<T>): T;
|
|
446
699
|
/**
|
|
447
700
|
* @public
|
|
448
|
-
*
|
|
701
|
+
* Read or compute the current value of a state
|
|
449
702
|
* @param token - The token of a state family
|
|
450
703
|
* @param key - The unique key of the state to get
|
|
451
704
|
* @return The current value of the state
|
|
@@ -454,27 +707,90 @@ declare function getState<T>(token: ReadableToken<T>): T;
|
|
|
454
707
|
declare function getState<T, K extends Canonical, Key extends K>(token: ReadableFamilyToken<T, K>, key: Key): T;
|
|
455
708
|
//#endregion
|
|
456
709
|
//#region src/main/join.d.ts
|
|
457
|
-
|
|
710
|
+
/** @public */
|
|
711
|
+
type JoinOptions<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null> = Flat<JunctionSchemaBase<ASide, BSide> & {
|
|
712
|
+
/** Unique identifier of the join */
|
|
458
713
|
readonly key: string;
|
|
714
|
+
/** How many relations are allowed in each direction? */
|
|
459
715
|
readonly cardinality: Cardinality;
|
|
716
|
+
/** Type guard for the type of the left side */
|
|
460
717
|
readonly isAType: Refinement<string, AType>;
|
|
718
|
+
/** Type guard for the type of the right side */
|
|
461
719
|
readonly isBType: Refinement<string, BType>;
|
|
462
|
-
}
|
|
720
|
+
}> & Partial<JunctionEntriesBase<AType, BType, Content>>;
|
|
721
|
+
/** @public */
|
|
463
722
|
type JoinToken<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null = null> = {
|
|
723
|
+
/** Unique identifier of the join */
|
|
464
724
|
key: string;
|
|
725
|
+
/** Discriminator */
|
|
465
726
|
type: `join`;
|
|
727
|
+
/** How many relations are allowed in each direction? */
|
|
466
728
|
cardinality: Cardinality;
|
|
729
|
+
/** Name of the join's left side */
|
|
467
730
|
a: ASide;
|
|
731
|
+
/** Name of the join's right side */
|
|
468
732
|
b: BSide;
|
|
733
|
+
/** Never present. This is a marker that preserves the type of the left side's keys */
|
|
469
734
|
__aType?: AType;
|
|
735
|
+
/** Never present. This is a marker that preserves the type of the right side's keys */
|
|
470
736
|
__bType?: BType;
|
|
737
|
+
/** Never present. This is a marker that preserves the type of the data present for each relation */
|
|
471
738
|
__content?: Content;
|
|
472
739
|
};
|
|
473
|
-
|
|
474
|
-
|
|
740
|
+
/**
|
|
741
|
+
* @public
|
|
742
|
+
* Create a join, an interface for managing relations between two sets of keys.
|
|
743
|
+
*
|
|
744
|
+
* Use joins when it is important to view relationships from either side.
|
|
745
|
+
*
|
|
746
|
+
* Under the hood, joins coordinate changes of multiple atoms to support that the desired relationships stay consistent.
|
|
747
|
+
*
|
|
748
|
+
* @param options - {@link JoinOptions}
|
|
749
|
+
* @param defaultContent - (undefined)
|
|
750
|
+
* @returns
|
|
751
|
+
* A reference to the join created: a {@link JoinToken}
|
|
752
|
+
* @overload No Content
|
|
753
|
+
*/
|
|
754
|
+
declare function join<const ASide extends string, const AType extends string, const BSide extends string, const BType extends string, const Cardinality extends `1:1` | `1:n` | `n:n`>(options: JoinOptions<ASide, AType, BSide, BType, Cardinality, null>, defaultContent?: undefined): JoinToken<ASide, AType, BSide, BType, Cardinality, null>;
|
|
755
|
+
/**
|
|
756
|
+
* @public
|
|
757
|
+
* Create a join, an interface for managing relations between two sets of keys.
|
|
758
|
+
*
|
|
759
|
+
* Use joins when it is important to view relationships from either side.
|
|
760
|
+
*
|
|
761
|
+
* Under the hood, joins coordinate changes of multiple atoms to support that the desired relationships stay consistent.
|
|
762
|
+
*
|
|
763
|
+
* @param options - {@link JoinOptions}
|
|
764
|
+
* @param defaultContent - The default value for the content of each relation
|
|
765
|
+
* @returns
|
|
766
|
+
* A reference to the join created: a {@link JoinToken}
|
|
767
|
+
* @overload With Content
|
|
768
|
+
*/
|
|
769
|
+
declare function join<const ASide extends string, const AType extends string, const BSide extends string, const BType extends string, const Cardinality extends `1:1` | `1:n` | `n:n`, const Content extends Json.Object>(options: JoinOptions<ASide, AType, BSide, BType, Cardinality, Content>, defaultContent: Content): JoinToken<ASide, AType, BSide, BType, Cardinality, Content>;
|
|
475
770
|
type JoinStates<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null> = Cardinality extends `1:1` ? (Content extends Json.Object ? { readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlyPureSelectorToken$1<[AType, Content] | null, BType> } & { readonly [B in BSide as `${B}EntryOf${Capitalize<ASide>}`]: ReadonlyPureSelectorToken$1<[BType, Content] | null, AType> } : {}) & { readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlyPureSelectorToken$1<AType | null, BType> } & { readonly [B in BSide as `${B}KeyOf${Capitalize<ASide>}`]: ReadonlyPureSelectorToken$1<BType | null, AType> } : Cardinality extends `1:n` ? (Content extends Json.Object ? { readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlyPureSelectorToken$1<[AType, Content] | null, BType> } & { readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: ReadonlyPureSelectorToken$1<[BType, Content][], AType> } : {}) & { readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlyPureSelectorToken$1<AType | null, BType> } & { readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlyPureSelectorToken$1<BType[], AType> } : Cardinality extends `n:n` ? (Content extends Json.Object ? { readonly [A in ASide as `${A}EntriesOf${Capitalize<BSide>}`]: ReadonlyPureSelectorToken$1<[AType, Content][], BType> } & { readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: ReadonlyPureSelectorToken$1<[BType, Content][], AType> } : {}) & { readonly [A in ASide as `${A}KeysOf${Capitalize<BSide>}`]: ReadonlyPureSelectorToken$1<AType[], BType> } & { readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlyPureSelectorToken$1<BType[], AType> } : never;
|
|
771
|
+
/**
|
|
772
|
+
* @public
|
|
773
|
+
* Find the current value of a relation owned by a {@link join}
|
|
774
|
+
* @param token - The token of the join
|
|
775
|
+
* @param key - The key of the relation to find
|
|
776
|
+
* @returns
|
|
777
|
+
* A {@link JoinStates} interface to access the relation
|
|
778
|
+
* @overload Default
|
|
779
|
+
*/
|
|
476
780
|
declare function findRelations<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content>, key: AType | BType): JoinStates<ASide, AType, BSide, BType, Cardinality, Content>;
|
|
781
|
+
/**
|
|
782
|
+
* @public
|
|
783
|
+
* Change one or multiple relations owned by a {@link join}
|
|
784
|
+
* @param token - The token of the join
|
|
785
|
+
* @param change - A function that takes a {@link Junction} interface to edit the relations
|
|
786
|
+
*/
|
|
477
787
|
declare function editRelations<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content>, change: (relations: Junction<ASide, AType, BSide, BType, Content>) => void): void;
|
|
788
|
+
/**
|
|
789
|
+
* @public
|
|
790
|
+
* @param token - The token of the join
|
|
791
|
+
* @returns
|
|
792
|
+
* A {@link MutableAtomFamilyToken} to access the internal relations
|
|
793
|
+
*/
|
|
478
794
|
declare function getInternalRelations<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content>): MutableAtomFamilyToken$1<SetRTX<string>, SetRTXJson<string>, string>;
|
|
479
795
|
//#endregion
|
|
480
796
|
//#region src/main/logger.d.ts
|
|
@@ -555,18 +871,68 @@ type Claim<K extends Canonical> = K & {
|
|
|
555
871
|
};
|
|
556
872
|
declare class Realm<H extends Hierarchy> {
|
|
557
873
|
store: Store;
|
|
874
|
+
/**
|
|
875
|
+
* @param store - The store to which the realm will be attached
|
|
876
|
+
*/
|
|
558
877
|
constructor(store?: Store);
|
|
878
|
+
/**
|
|
879
|
+
* Make space for a new subject of the realm
|
|
880
|
+
* @param provenance - A key for an owner {@link Above} the new subject in the realm's {@link Hierarchy}
|
|
881
|
+
* @param key - A unique identifier for the new subject
|
|
882
|
+
* @param attachmentStyle - The attachment style of new subject to its owner(s). `any` means that if any owners remain, the subject will be retained. `all` means that the subject be retained only if all owners remain .
|
|
883
|
+
* @returns
|
|
884
|
+
* The subject's key, given status as a true {@link Claim}
|
|
885
|
+
*/
|
|
559
886
|
allocate<V extends Vassal<H>, A extends Above<V, H>>(provenance: A, key: V, attachmentStyle?: `all` | `any`): Claim<V>;
|
|
887
|
+
/**
|
|
888
|
+
* Fuse two reagents into a compound
|
|
889
|
+
* @param type - the name of the compound that is being fused
|
|
890
|
+
* @param reagentA - the left reagent of the compound
|
|
891
|
+
* @param reagentB - the right reagent of the compound
|
|
892
|
+
* @returns
|
|
893
|
+
* The compound's key, given status as a true {@link Claim}
|
|
894
|
+
*/
|
|
560
895
|
fuse<C extends CompoundFrom<H>, T extends (C extends CompoundTypedKey<infer t, any, any> ? t : never), A extends (C extends CompoundTypedKey<any, infer v, any> ? v : never), B extends (C extends CompoundTypedKey<any, any, infer m> ? m : never)>(type: T, reagentA: SingularTypedKey<A>, reagentB: SingularTypedKey<B>): Claim<CompoundTypedKey<T, A, B>>;
|
|
896
|
+
/**
|
|
897
|
+
* Remove a subject from the realm
|
|
898
|
+
* @param claim - The subject to be deallocated
|
|
899
|
+
*/
|
|
561
900
|
deallocate<V extends Vassal<H>>(claim: Claim<V>): void;
|
|
901
|
+
/**
|
|
902
|
+
* Transfer a subject of the realm from one owner to another
|
|
903
|
+
* @param newProvenance - A key for an owner {@link Above} the new subject in the realm's {@link Hierarchy}
|
|
904
|
+
* @param claim - The subject to be claimed
|
|
905
|
+
* @param exclusive - Whether the subjects previous owners should be detached from it
|
|
906
|
+
* @returns
|
|
907
|
+
* The subject's key, given status as a true {@link Claim}
|
|
908
|
+
*/
|
|
562
909
|
claim<V extends Exclude<Vassal<H>, CompoundTypedKey>, A extends Above<V, H>>(newProvenance: A, claim: Claim<V>, exclusive?: `exclusive`): Claim<V>;
|
|
563
910
|
}
|
|
564
911
|
declare class Anarchy {
|
|
565
912
|
store: Store;
|
|
566
913
|
realm: Realm<any>;
|
|
914
|
+
/**
|
|
915
|
+
* @param store - The store to which the anarchy-realm will be attached
|
|
916
|
+
*/
|
|
567
917
|
constructor(store?: Store);
|
|
918
|
+
/**
|
|
919
|
+
* Declare a new entity
|
|
920
|
+
* @param provenance - A key for an owner of the entity
|
|
921
|
+
* @param key - A unique identifier for the new entity
|
|
922
|
+
* @param attachmentStyle - The attachment style of new entity to its owner(s). `any` means that if any owners remain, the subject will be retained. `all` means that the subject be retained only if all owners remain .
|
|
923
|
+
*/
|
|
568
924
|
allocate(provenance: Canonical, key: Canonical, attachmentStyle?: `all` | `any`): void;
|
|
925
|
+
/**
|
|
926
|
+
* Remove an entity
|
|
927
|
+
* @param key - The entity to be deallocated
|
|
928
|
+
*/
|
|
569
929
|
deallocate(key: Canonical): void;
|
|
930
|
+
/**
|
|
931
|
+
* Transfer an entity from one owner to another
|
|
932
|
+
* @param newProvenance - A key for an owner of the entity
|
|
933
|
+
* @param key - The entity to be claimed
|
|
934
|
+
* @param exclusive - Whether the entity's previous owners should be detached from it
|
|
935
|
+
*/
|
|
570
936
|
claim(newProvenance: Canonical, key: Canonical, exclusive?: `exclusive`): void;
|
|
571
937
|
}
|
|
572
938
|
declare const T$ = "T$";
|
|
@@ -649,19 +1015,50 @@ declare class Silo {
|
|
|
649
1015
|
}
|
|
650
1016
|
//#endregion
|
|
651
1017
|
//#region src/main/subscribe.d.ts
|
|
1018
|
+
/** @public */
|
|
652
1019
|
type StateUpdate<T> = {
|
|
653
1020
|
newValue: T;
|
|
654
1021
|
oldValue: T;
|
|
655
1022
|
};
|
|
1023
|
+
/** @public */
|
|
656
1024
|
type KeyedStateUpdate<T> = Flat<StateUpdate<T> & {
|
|
657
1025
|
key: string;
|
|
658
1026
|
type: `atom_update` | `selector_update`;
|
|
659
1027
|
family?: FamilyMetadata;
|
|
660
1028
|
}>;
|
|
1029
|
+
/** @public */
|
|
661
1030
|
type UpdateHandler<T> = (update: StateUpdate<T>) => void;
|
|
1031
|
+
/** @public */
|
|
662
1032
|
type TransactionUpdateHandler<F extends Func> = (data: TransactionUpdate<F>) => void;
|
|
1033
|
+
/**
|
|
1034
|
+
* @public
|
|
1035
|
+
* Subscribe to a state in the implicit store
|
|
1036
|
+
* @param token - The token of the state to subscribe to
|
|
1037
|
+
* @param handleUpdate - A function that will be called when the state is updated
|
|
1038
|
+
* @param key - A unique key for the subscription. If not provided, a random key will be generated.
|
|
1039
|
+
* @returns A function that can be called to unsubscribe from the state
|
|
1040
|
+
* @overload State
|
|
1041
|
+
*/
|
|
663
1042
|
declare function subscribe<T>(token: ReadableToken<T>, handleUpdate: UpdateHandler<T>, key?: string): () => void;
|
|
1043
|
+
/**
|
|
1044
|
+
* @public
|
|
1045
|
+
* Subscribe to a transaction in the implicit store
|
|
1046
|
+
* @param token - The token of the transaction to subscribe to
|
|
1047
|
+
* @param handleUpdate - A function that will be called when the transaction succeeds
|
|
1048
|
+
* @param key - A unique key for the subscription. If not provided, a random key will be generated.
|
|
1049
|
+
* @returns A function that can be called to unsubscribe from the transaction
|
|
1050
|
+
* @overload Transaction
|
|
1051
|
+
*/
|
|
664
1052
|
declare function subscribe<F extends Func>(token: TransactionToken<F>, handleUpdate: TransactionUpdateHandler<F>, key?: string): () => void;
|
|
1053
|
+
/**
|
|
1054
|
+
* @public
|
|
1055
|
+
* Subscribe to a timeline in the implicit store
|
|
1056
|
+
* @param token - The token of the timeline to subscribe to
|
|
1057
|
+
* @param handleUpdate - A function that will be called when a new update is available
|
|
1058
|
+
* @param key - A unique key for the subscription. If not provided, a random key will be generated.
|
|
1059
|
+
* @returns A function that can be called to unsubscribe from the timeline
|
|
1060
|
+
* @overload Timeline
|
|
1061
|
+
*/
|
|
665
1062
|
declare function subscribe<M extends TimelineManageable>(token: TimelineToken<M>, handleUpdate: (update: TimelineUpdate<M> | `redo` | `undo`) => void, key?: string): () => void;
|
|
666
1063
|
//#endregion
|
|
667
1064
|
//#region src/main/validators.d.ts
|
|
@@ -803,6 +1200,14 @@ type FamilyMetadata<K extends Canonical = any> = {
|
|
|
803
1200
|
/** The family member's unique identifier, in the form of a string. */
|
|
804
1201
|
subKey: stringified<K>;
|
|
805
1202
|
};
|
|
1203
|
+
/**
|
|
1204
|
+
* @public
|
|
1205
|
+
* Loadable is used to type atoms or selectors that may at some point be initialized to or set to a {@link Promise}.
|
|
1206
|
+
*
|
|
1207
|
+
* When a Promise is cached as the value of a state in atom.io, that state will be automatically set to the resolved value of the Promise when it is resolved.
|
|
1208
|
+
*
|
|
1209
|
+
* 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.
|
|
1210
|
+
*/
|
|
806
1211
|
type Loadable<T> = Promise<T> | T;
|
|
807
1212
|
//#endregion
|
|
808
1213
|
export { $claim, Above, ActorToolkit, Anarchy, AtomDisposal, AtomEffect, AtomFamilyToken, AtomIOLogger, AtomIOToken, AtomOnly, AtomToken, Below, Claim, CompoundFrom, CompoundTypedKey, Effectors, FamilyMetadata, GetterToolkit, HeldSelectorFamilyToken, HeldSelectorToken, Hierarchy, JoinOptions, JoinStates, JoinToken, KeyedStateUpdate, LOG_LEVELS, Loadable, LogFilter, LogFn, LogLevel, Logger, LoggerIcon, MoleculeCreation, MoleculeDisposal, MoleculeTransfer, MutableAtomFamilyOptions, MutableAtomFamilyToken, MutableAtomOptions, MutableAtomToken, Mutuals, PureSelectorFamilyToken, PureSelectorToken, Read, ReadableFamilyToken, ReadableToken, ReadonlyHeldSelectorFamilyOptions, ReadonlyHeldSelectorFamilyToken, ReadonlyHeldSelectorOptions, ReadonlyHeldSelectorToken, ReadonlyPureSelectorFamilyOptions, ReadonlyPureSelectorFamilyToken, ReadonlyPureSelectorOptions, ReadonlyPureSelectorToken, ReadonlySelectorFamilyToken, ReadonlySelectorToken, Realm, RegularAtomFamilyOptions, RegularAtomFamilyToken, RegularAtomOptions, RegularAtomToken, SelectorDisposal, SelectorFamilyToken, SelectorToken, Setter, SetterToolkit, Silo, SingularTypedKey, StateCreation, StateDisposal, StateUpdate, T$, TimelineManageable, TimelineOptions, TimelineToken, TimelineUpdate, TokenDenomination, TokenType, Transact, TransactionIO, TransactionOptions, TransactionToken, TransactionUpdate, TransactionUpdateContent, TransactionUpdateHandler, TypeTag, TypedKey, UpdateHandler, Vassal, WritableFamilyToken, WritableHeldSelectorFamilyOptions, WritableHeldSelectorFamilyToken, WritableHeldSelectorOptions, WritableHeldSelectorToken, WritablePureSelectorFamilyOptions, WritablePureSelectorFamilyToken, WritablePureSelectorOptions, WritablePureSelectorToken, WritableSelectorFamilyToken, WritableSelectorToken, WritableToken, Write, atom, atomFamily, belongsTo, disposeState, editRelations, findRelations, findState, getInternalRelations, getState, isToken, join, redo, resetState, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
|