atom.io 0.25.2 → 0.25.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +38 -13
- package/ephemeral/dist/index.d.ts +45 -0
- package/ephemeral/src/find-state.ts +45 -5
- package/internal/dist/index.cjs +7 -6
- package/internal/dist/index.d.ts +12 -6
- package/internal/dist/index.js +7 -6
- package/internal/src/index.ts +1 -0
- package/internal/src/ingest-updates/index.ts +1 -1
- package/internal/src/molecule/make-molecule-in-store.ts +2 -3
- package/internal/src/molecule/molecule-internal.ts +2 -2
- package/internal/src/store/deposit.ts +1 -1
- package/internal/src/store/store.ts +6 -7
- package/internal/src/store/withdraw.ts +1 -1
- package/internal/src/subscribe/subscribe-to-transaction.ts +2 -2
- package/internal/src/timeline/create-timeline.ts +1 -2
- package/internal/src/transaction/act-upon-store.ts +2 -1
- package/internal/src/transaction/apply-transaction.ts +1 -2
- package/internal/src/transaction/build-transaction.ts +2 -1
- package/internal/src/transaction/create-transaction.ts +1 -1
- package/internal/src/transaction/index.ts +3 -1
- package/internal/src/transaction/is-root-store.ts +1 -2
- package/internal/src/utility-types.ts +5 -0
- package/introspection/dist/index.d.ts +2 -2
- package/introspection/src/attach-introspection-states.ts +1 -2
- package/introspection/src/attach-transaction-index.ts +2 -2
- package/introspection/src/attach-transaction-logs.ts +2 -6
- package/package.json +18 -19
- package/react/dist/index.cjs +29 -11
- package/react/dist/index.js +30 -12
- package/react/src/parse-state-overloads.ts +43 -0
- package/react/src/use-i.ts +6 -11
- package/react/src/use-o.ts +7 -21
- package/react-devtools/dist/index.d.ts +2 -2
- package/react-devtools/src/TransactionIndex.tsx +1 -1
- package/react-devtools/src/Updates.tsx +1 -1
- package/realtime-client/dist/index.d.ts +3 -3
- package/realtime-client/src/server-action.ts +1 -1
- package/realtime-client/src/sync-continuity.ts +2 -2
- package/realtime-react/dist/index.d.ts +2 -2
- package/realtime-react/src/use-server-action.ts +2 -1
- package/src/atom.ts +17 -0
- package/src/index.ts +0 -6
- package/src/molecule.ts +2 -4
- package/src/set-state.ts +16 -0
- package/src/subscribe.ts +1 -3
- package/src/transaction.ts +1 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Transceiver, Subject, Store, EnvironmentData, Timeline, TimelineAtomUpdate, TimelineMoleculeCreation, TimelineMoleculeDisposal, TimelineSelectorUpdate, TimelineStateCreation, TimelineStateDisposal, TimelineTransactionUpdate } from 'atom.io/internal';
|
|
1
|
+
import { Transceiver, Subject, Store, Func, EnvironmentData, Flat, Timeline, TimelineAtomUpdate, TimelineMoleculeCreation, TimelineMoleculeDisposal, TimelineSelectorUpdate, TimelineStateCreation, TimelineStateDisposal, TimelineTransactionUpdate } from 'atom.io/internal';
|
|
2
2
|
import { Json, JsonInterface } from 'atom.io/json';
|
|
3
|
-
import { MoleculeConstructor as MoleculeConstructor$1, MoleculeToken as MoleculeToken$1, MoleculeFamilyToken as MoleculeFamilyToken$1, MoleculeParams as MoleculeParams$1, getState as getState$1, setState as setState$1, makeMolecule as makeMolecule$1,
|
|
3
|
+
import { MoleculeConstructor as MoleculeConstructor$1, MoleculeToken as MoleculeToken$1, MoleculeFamilyToken as MoleculeFamilyToken$1, MoleculeParams as MoleculeParams$1, getState as getState$1, setState as setState$1, makeMolecule as makeMolecule$1, ActorToolkit as ActorToolkit$1, MutableAtomFamilyToken as MutableAtomFamilyToken$1, MutableAtomToken as MutableAtomToken$1, RegularAtomFamilyToken as RegularAtomFamilyToken$1, RegularAtomToken as RegularAtomToken$1, WritableSelectorFamilyToken as WritableSelectorFamilyToken$1, WritableSelectorToken as WritableSelectorToken$1, ReadonlySelectorFamilyToken as ReadonlySelectorFamilyToken$1, ReadonlySelectorToken as ReadonlySelectorToken$1, WritableFamilyToken as WritableFamilyToken$1, WritableToken as WritableToken$1, ReadableFamilyToken as ReadableFamilyToken$1, ReadableToken as ReadableToken$1, MoleculeCreation as MoleculeCreation$1, MoleculeDisposal as MoleculeDisposal$1 } from 'atom.io';
|
|
4
4
|
import { findState } from 'atom.io/ephemeral';
|
|
5
5
|
import { seekState } from 'atom.io/immortal';
|
|
6
6
|
import { JoinToken } from 'atom.io/data';
|
|
@@ -22,7 +22,23 @@ type MutableAtomOptions<T extends Transceiver<any>, J extends Json.Serializable>
|
|
|
22
22
|
default: () => T;
|
|
23
23
|
mutable: true;
|
|
24
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* @public
|
|
27
|
+
* Declare a mutable global reactive variable.
|
|
28
|
+
* @param options - Configuration for this mutable atom.
|
|
29
|
+
* @returns
|
|
30
|
+
* The token for your mutable atom.
|
|
31
|
+
* @overload Mutable
|
|
32
|
+
*/
|
|
25
33
|
declare function atom<T extends Transceiver<any>, J extends Json.Serializable>(options: MutableAtomOptions<T, J>): MutableAtomToken<T, J>;
|
|
34
|
+
/**
|
|
35
|
+
* @public
|
|
36
|
+
* Declare a regular global reactive variable.
|
|
37
|
+
* @param options - Configuration for this regular atom.
|
|
38
|
+
* @returns
|
|
39
|
+
* The token for your regular atom.
|
|
40
|
+
* @overload Regular
|
|
41
|
+
*/
|
|
26
42
|
declare function atom<T>(options: RegularAtomOptions<T>): RegularAtomToken<T>;
|
|
27
43
|
type RegularAtomFamilyOptions<T, K extends Json.Serializable> = {
|
|
28
44
|
key: string;
|
|
@@ -197,7 +213,7 @@ type SelectorFamilyToken<T, K extends Json.Serializable> = ReadonlySelectorFamil
|
|
|
197
213
|
declare function selectorFamily<T, K extends Json.Serializable>(options: WritableSelectorFamilyOptions<T, K>): WritableSelectorFamilyTokenWithCall<T, K>;
|
|
198
214
|
declare function selectorFamily<T, K extends Json.Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamilyTokenWithCall<T, K>;
|
|
199
215
|
|
|
200
|
-
type CtorToolkit<K extends Json.Serializable> = Flat
|
|
216
|
+
type CtorToolkit<K extends Json.Serializable> = Flat<Omit<ActorToolkit$1, `find`> & {
|
|
201
217
|
bond<T extends Transceiver<any>, J extends Json.Serializable>(family: MutableAtomFamilyToken$1<T, J, K>): MutableAtomToken$1<T, J>;
|
|
202
218
|
bond<T>(family: RegularAtomFamilyToken$1<T, K>): RegularAtomToken$1<T>;
|
|
203
219
|
bond<T>(family: WritableSelectorFamilyToken$1<T, K>): WritableSelectorToken$1<T>;
|
|
@@ -234,13 +250,13 @@ type MoleculeFamilyToken<M extends MoleculeConstructor> = {
|
|
|
234
250
|
dependsOn: `all` | `any`;
|
|
235
251
|
__M?: M;
|
|
236
252
|
};
|
|
237
|
-
type MoleculeFamily<M extends MoleculeConstructor> = Flat
|
|
253
|
+
type MoleculeFamily<M extends MoleculeConstructor> = Flat<MoleculeFamilyToken<M> & {
|
|
238
254
|
subject: Subject<MoleculeCreation$1<M> | MoleculeDisposal$1>;
|
|
239
255
|
dependsOn: `all` | `any`;
|
|
240
256
|
new: M;
|
|
241
257
|
}>;
|
|
242
258
|
type MoleculeToken<M extends MoleculeConstructor> = {
|
|
243
|
-
key:
|
|
259
|
+
key: MoleculeKey<M>;
|
|
244
260
|
type: `molecule`;
|
|
245
261
|
family?: MoleculeFamilyToken<M>;
|
|
246
262
|
__M?: M;
|
|
@@ -249,7 +265,6 @@ declare function moleculeFamily<M extends MoleculeConstructor>(options: Molecule
|
|
|
249
265
|
declare function makeMolecule<M extends MoleculeConstructor>(context: MoleculeToken<any> | MoleculeToken<any>[], family: MoleculeFamilyToken<M>, key: MoleculeKey<M>, ...params: MoleculeParams<M>): MoleculeToken<M>;
|
|
250
266
|
type MoleculeType<T extends MoleculeFamilyToken<any>> = T extends MoleculeFamilyToken<infer M> ? M : T extends MoleculeToken<infer M> ? M : never;
|
|
251
267
|
type MoleculeKey<M extends MoleculeConstructor> = InstanceType<M>[`key`];
|
|
252
|
-
type MK<M extends MoleculeConstructor> = MoleculeKey<M>;
|
|
253
268
|
declare function makeRootMolecule(key: string, store?: Store): MoleculeToken<ObjectConstructor>;
|
|
254
269
|
|
|
255
270
|
declare function disposeState(token: MoleculeToken<any> | ReadableToken<any>): void;
|
|
@@ -337,7 +352,23 @@ type Serializable = primitive | Readonly<{
|
|
|
337
352
|
[key: string]: Serializable;
|
|
338
353
|
}> | ReadonlyArray<Serializable>;
|
|
339
354
|
|
|
355
|
+
/**
|
|
356
|
+
* @public
|
|
357
|
+
* Set the value of a state into the implicit store.
|
|
358
|
+
* @param token - The unique identifier of the state to set.
|
|
359
|
+
* @param value - The new value of the state.
|
|
360
|
+
* @overload Default
|
|
361
|
+
* @default
|
|
362
|
+
*/
|
|
340
363
|
declare function setState<T, New extends T>(token: WritableToken<T>, value: New | ((oldValue: T) => New)): void;
|
|
364
|
+
/**
|
|
365
|
+
* @public
|
|
366
|
+
* Set the value of a state into the implicit store.
|
|
367
|
+
* @param token - The unique identifier of a state family.
|
|
368
|
+
* @param key - The key of the state to set.
|
|
369
|
+
* @param value - The new value of the state.
|
|
370
|
+
* @overload Streamlined
|
|
371
|
+
*/
|
|
341
372
|
declare function setState<T, K extends Serializable, New extends T>(token: WritableFamilyToken<T, K>, key: K, value: New | ((oldValue: T) => New)): void;
|
|
342
373
|
|
|
343
374
|
declare class Silo {
|
|
@@ -404,12 +435,6 @@ declare function belongsTo<Family extends ReadonlySelectorFamilyToken$1<any, any
|
|
|
404
435
|
declare function belongsTo<Family extends WritableFamilyToken$1<any, any>>(family: Family, unknownToken: ReadableToken$1<any>): unknownToken is WritableToken$1<TokenType<Family>>;
|
|
405
436
|
declare function belongsTo<Family extends ReadableFamilyToken$1<any, any>>(family: Family, unknownToken: ReadableToken$1<any>): unknownToken is ReadableToken$1<TokenType<Family>>;
|
|
406
437
|
|
|
407
|
-
type Func = (...parameters: any[]) => any;
|
|
408
|
-
type Flat<R extends {
|
|
409
|
-
[K in PropertyKey]: any;
|
|
410
|
-
}> = {
|
|
411
|
-
[K in keyof R]: R[K];
|
|
412
|
-
};
|
|
413
438
|
type RegularAtomToken<T> = {
|
|
414
439
|
key: string;
|
|
415
440
|
type: `atom`;
|
|
@@ -448,4 +473,4 @@ type FamilyMetadata = {
|
|
|
448
473
|
subKey: string;
|
|
449
474
|
};
|
|
450
475
|
|
|
451
|
-
export { type ActorToolkit, type AtomEffect, type AtomFamily, type AtomFamilyToken, AtomIOLogger, type AtomOnly, type AtomToken, type CtorToolkit, type Effectors, type FamilyMetadata, type
|
|
476
|
+
export { type ActorToolkit, type AtomEffect, type AtomFamily, type AtomFamilyToken, AtomIOLogger, type AtomOnly, type AtomToken, type CtorToolkit, type Effectors, type FamilyMetadata, type GetterToolkit, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MoleculeConstructor, type MoleculeCreation, type MoleculeDisposal, type MoleculeFamily, type MoleculeFamilyOptions, type MoleculeFamilyToken, type MoleculeKey, type MoleculeParams, type MoleculeToken, type MoleculeType, type MutableAtomFamily, type MutableAtomFamilyOptions, type MutableAtomFamilyToken, type MutableAtomFamilyTokenWithCall, type MutableAtomOptions, type MutableAtomToken, type Read, type ReadableFamily, type ReadableFamilyToken, type ReadableToken, type ReadonlySelectorFamily, type ReadonlySelectorFamilyOptions, type ReadonlySelectorFamilyToken, type ReadonlySelectorFamilyTokenWithCall, type ReadonlySelectorOptions, type ReadonlySelectorToken, type RegularAtomFamily, type RegularAtomFamilyOptions, type RegularAtomFamilyToken, type RegularAtomFamilyTokenWithCall, type RegularAtomOptions, type RegularAtomToken, type SelectorFamily, type SelectorFamilyToken, type SelectorToken, type SetterToolkit, Silo, type StateCreation, type StateDisposal, type StateUpdate, type TimelineManageable, type TimelineOptions, type TimelineToken, type TimelineUpdate, type TokenDenomination, type TokenType, type Transact, type TransactionIO, type TransactionOptions, type TransactionToken, type TransactionUpdate, type TransactionUpdateContent, type TransactionUpdateHandler, type UpdateHandler, type WritableFamily, type WritableFamilyToken, type WritableSelectorFamily, type WritableSelectorFamilyOptions, type WritableSelectorFamilyToken, type WritableSelectorFamilyTokenWithCall, type WritableSelectorOptions, type WritableSelectorToken, type WritableToken, type Write, atom, atomFamily, belongsTo, disposeState, getState, isToken, makeMolecule, makeRootMolecule, moleculeFamily, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
|
|
@@ -2,11 +2,56 @@ import { MutableAtomFamilyToken, MutableAtomToken, RegularAtomFamilyToken, Regul
|
|
|
2
2
|
import { Transceiver } from 'atom.io/internal';
|
|
3
3
|
import { Json } from 'atom.io/json';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @overload Mutable Atom
|
|
7
|
+
* Finds a {@link MutableAtomToken} in the store.
|
|
8
|
+
* @param token - A {@link MutableAtomFamilyToken}.
|
|
9
|
+
* @param key - The key of the state.
|
|
10
|
+
* @returns
|
|
11
|
+
* The current value of the state.
|
|
12
|
+
*/
|
|
5
13
|
declare function findState<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable, Key extends K>(token: MutableAtomFamilyToken<T, J, K>, key: Key): MutableAtomToken<T, J>;
|
|
14
|
+
/**
|
|
15
|
+
* Finds a state in the store.
|
|
16
|
+
* @param token - The token of the state family.
|
|
17
|
+
* @param key - The key of the state.
|
|
18
|
+
* @returns
|
|
19
|
+
* The current value of the state.
|
|
20
|
+
*/
|
|
6
21
|
declare function findState<T, K extends Json.Serializable, Key extends K>(token: RegularAtomFamilyToken<T, K>, key: Key): RegularAtomToken<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Finds a state in the store.
|
|
24
|
+
* @param token - The token of the state family.
|
|
25
|
+
* @param key - The key of the state.
|
|
26
|
+
* @returns
|
|
27
|
+
* The current value of the state.
|
|
28
|
+
*/
|
|
7
29
|
declare function findState<T, K extends Json.Serializable, Key extends K>(token: WritableSelectorFamilyToken<T, K>, key: Key): WritableSelectorToken<T>;
|
|
30
|
+
/**
|
|
31
|
+
* Finds a state in the store.
|
|
32
|
+
* @param token - The token of the state family.
|
|
33
|
+
* @param key - The key of the state.
|
|
34
|
+
* @returns
|
|
35
|
+
* The current value of the state.
|
|
36
|
+
*/
|
|
8
37
|
declare function findState<T, K extends Json.Serializable, Key extends K>(token: ReadonlySelectorFamilyToken<T, K>, key: Key): ReadonlySelectorToken<T>;
|
|
38
|
+
/**
|
|
39
|
+
* Finds a state in the store.
|
|
40
|
+
* @param token - The token of the state family.
|
|
41
|
+
* @param key - The key of the state.
|
|
42
|
+
* @returns
|
|
43
|
+
* The current value of the state.
|
|
44
|
+
*/
|
|
9
45
|
declare function findState<T, K extends Json.Serializable, Key extends K>(token: WritableFamilyToken<T, K>, key: Key): WritableToken<T>;
|
|
46
|
+
/**
|
|
47
|
+
* @public
|
|
48
|
+
* Finds a {@link ReadableToken} in the store.
|
|
49
|
+
* @param token - A {@link ReadableFamilyToken}.
|
|
50
|
+
* @param key - The key of the state.
|
|
51
|
+
* @returns
|
|
52
|
+
* The current value of the state.
|
|
53
|
+
* @overload Unknown
|
|
54
|
+
*/
|
|
10
55
|
declare function findState<T, K extends Json.Serializable, Key extends K>(token: ReadableFamilyToken<T, K>, key: Key): ReadableToken<T>;
|
|
11
56
|
|
|
12
57
|
export { findState };
|
|
@@ -16,33 +16,73 @@ import type { Transceiver } from "atom.io/internal"
|
|
|
16
16
|
import { findInStore, IMPLICIT } from "atom.io/internal"
|
|
17
17
|
import type { Json } from "atom.io/json"
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @overload Mutable Atom
|
|
21
|
+
* Finds a {@link MutableAtomToken} in the store.
|
|
22
|
+
* @param token - A {@link MutableAtomFamilyToken}.
|
|
23
|
+
* @param key - The key of the state.
|
|
24
|
+
* @returns
|
|
25
|
+
* The current value of the state.
|
|
26
|
+
*/
|
|
19
27
|
export function findState<
|
|
20
28
|
T extends Transceiver<any>,
|
|
21
29
|
J extends Json.Serializable,
|
|
22
30
|
K extends Json.Serializable,
|
|
23
31
|
Key extends K,
|
|
24
32
|
>(token: MutableAtomFamilyToken<T, J, K>, key: Key): MutableAtomToken<T, J>
|
|
25
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Finds a state in the store.
|
|
35
|
+
* @param token - The token of the state family.
|
|
36
|
+
* @param key - The key of the state.
|
|
37
|
+
* @returns
|
|
38
|
+
* The current value of the state.
|
|
39
|
+
*/
|
|
26
40
|
export function findState<T, K extends Json.Serializable, Key extends K>(
|
|
27
41
|
token: RegularAtomFamilyToken<T, K>,
|
|
28
42
|
key: Key,
|
|
29
43
|
): RegularAtomToken<T>
|
|
30
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Finds a state in the store.
|
|
46
|
+
* @param token - The token of the state family.
|
|
47
|
+
* @param key - The key of the state.
|
|
48
|
+
* @returns
|
|
49
|
+
* The current value of the state.
|
|
50
|
+
*/
|
|
31
51
|
export function findState<T, K extends Json.Serializable, Key extends K>(
|
|
32
52
|
token: WritableSelectorFamilyToken<T, K>,
|
|
33
53
|
key: Key,
|
|
34
54
|
): WritableSelectorToken<T>
|
|
35
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Finds a state in the store.
|
|
57
|
+
* @param token - The token of the state family.
|
|
58
|
+
* @param key - The key of the state.
|
|
59
|
+
* @returns
|
|
60
|
+
* The current value of the state.
|
|
61
|
+
*/
|
|
36
62
|
export function findState<T, K extends Json.Serializable, Key extends K>(
|
|
37
63
|
token: ReadonlySelectorFamilyToken<T, K>,
|
|
38
64
|
key: Key,
|
|
39
65
|
): ReadonlySelectorToken<T>
|
|
40
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Finds a state in the store.
|
|
68
|
+
* @param token - The token of the state family.
|
|
69
|
+
* @param key - The key of the state.
|
|
70
|
+
* @returns
|
|
71
|
+
* The current value of the state.
|
|
72
|
+
*/
|
|
41
73
|
export function findState<T, K extends Json.Serializable, Key extends K>(
|
|
42
74
|
token: WritableFamilyToken<T, K>,
|
|
43
75
|
key: Key,
|
|
44
76
|
): WritableToken<T>
|
|
45
|
-
|
|
77
|
+
/**
|
|
78
|
+
* @public
|
|
79
|
+
* Finds a {@link ReadableToken} in the store.
|
|
80
|
+
* @param token - A {@link ReadableFamilyToken}.
|
|
81
|
+
* @param key - The key of the state.
|
|
82
|
+
* @returns
|
|
83
|
+
* The current value of the state.
|
|
84
|
+
* @overload Unknown
|
|
85
|
+
*/
|
|
46
86
|
export function findState<T, K extends Json.Serializable, Key extends K>(
|
|
47
87
|
token: ReadableFamilyToken<T, K>,
|
|
48
88
|
key: Key,
|
package/internal/dist/index.cjs
CHANGED
|
@@ -2065,13 +2065,14 @@ var Store = class {
|
|
|
2065
2065
|
}
|
|
2066
2066
|
};
|
|
2067
2067
|
var IMPLICIT = {
|
|
2068
|
-
STORE_INTERNAL: void 0,
|
|
2069
2068
|
get STORE() {
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2069
|
+
if (!globalThis.ATOM_IO_IMPLICIT_STORE) {
|
|
2070
|
+
globalThis.ATOM_IO_IMPLICIT_STORE = new Store({
|
|
2071
|
+
name: `IMPLICIT_STORE`,
|
|
2072
|
+
lifespan: `ephemeral`
|
|
2073
|
+
});
|
|
2074
|
+
}
|
|
2075
|
+
return globalThis.ATOM_IO_IMPLICIT_STORE;
|
|
2075
2076
|
}
|
|
2076
2077
|
};
|
|
2077
2078
|
var clearStore = (store) => {
|
package/internal/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as atom_io from 'atom.io';
|
|
2
|
-
import {
|
|
2
|
+
import { TransactionToken, TransactionUpdate, TransactionOptions, ActorToolkit, RegularAtomToken, MutableAtomToken, AtomToken, WritableSelectorToken, ReadonlySelectorToken, SelectorToken, WritableToken, MoleculeToken, MoleculeFamily, MoleculeFamilyToken, ReadableToken, TimelineManageable, StateUpdate, TokenType, FamilyMetadata, StateCreation, StateDisposal, MoleculeConstructor, MoleculeCreation, MoleculeDisposal, TimelineUpdate, TimelineOptions, TimelineToken, WritableSelectorFamily, MutableAtomFamily, RegularAtomFamily, ReadonlySelectorFamily, AtomIOLogger, Logger, AtomFamily, ReadableFamily, SelectorFamily, WritableFamily, RegularAtomFamilyToken, MutableAtomFamilyToken, AtomFamilyToken, ReadonlySelectorFamilyToken, WritableSelectorFamilyToken, SelectorFamilyToken, ReadableFamilyToken, WritableFamilyToken, MutableAtomOptions, MutableAtomFamilyOptions, RegularAtomOptions, RegularAtomFamilyOptions, ReadonlySelectorFamilyOptions, WritableSelectorFamilyOptions, MoleculeKey, KeyedStateUpdate, MoleculeFamilyOptions, MoleculeParams, ReadonlySelectorOptions, WritableSelectorOptions, SetterToolkit, UpdateHandler, TransactionUpdateHandler } from 'atom.io';
|
|
3
3
|
import { Json, JsonInterface } from 'atom.io/json';
|
|
4
4
|
import { Join } from 'atom.io/data';
|
|
5
5
|
|
|
@@ -77,6 +77,13 @@ declare class Junction<const ASide extends string, const BSide extends string, c
|
|
|
77
77
|
has(a: string, b?: string): boolean;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
type Func = (...parameters: any[]) => any;
|
|
81
|
+
type Flat<R extends {
|
|
82
|
+
[K in PropertyKey]: any;
|
|
83
|
+
}> = {
|
|
84
|
+
[K in keyof R]: R[K];
|
|
85
|
+
};
|
|
86
|
+
|
|
80
87
|
declare const abortTransaction: (store: Store) => void;
|
|
81
88
|
|
|
82
89
|
declare function actUponStore<F extends Func>(token: TransactionToken<F>, id: string, store: Store): (...parameters: Parameters<F>) => ReturnType<F>;
|
|
@@ -245,7 +252,7 @@ declare class Store implements Lineage {
|
|
|
245
252
|
topicType: `atom_family` | `atom` | `molecule_family` | `molecule`;
|
|
246
253
|
}>;
|
|
247
254
|
molecules: Map<string, Molecule<any>>;
|
|
248
|
-
moleculeFamilies: Map<string,
|
|
255
|
+
moleculeFamilies: Map<string, Flat<atom_io.MoleculeFamilyToken<any> & {
|
|
249
256
|
subject: Subject<atom_io.MoleculeDisposal | atom_io.MoleculeCreation<any>>;
|
|
250
257
|
dependsOn: `all` | `any`;
|
|
251
258
|
new: any;
|
|
@@ -275,7 +282,6 @@ declare class Store implements Lineage {
|
|
|
275
282
|
constructor(config: Store[`config`], store?: Store | null);
|
|
276
283
|
}
|
|
277
284
|
declare const IMPLICIT: {
|
|
278
|
-
STORE_INTERNAL: Store | undefined;
|
|
279
285
|
readonly STORE: Store;
|
|
280
286
|
};
|
|
281
287
|
declare const clearStore: (store: Store) => void;
|
|
@@ -487,7 +493,7 @@ declare function createMoleculeFamily<M extends MoleculeConstructor>(options: Mo
|
|
|
487
493
|
declare function disposeMolecule<M extends MoleculeConstructor>(token: MoleculeToken<M>, store: Store): void;
|
|
488
494
|
|
|
489
495
|
declare class Molecule<M extends MoleculeConstructor> implements MoleculeToken<M> {
|
|
490
|
-
readonly key:
|
|
496
|
+
readonly key: MoleculeKey<M>;
|
|
491
497
|
readonly type = "molecule";
|
|
492
498
|
stringKey: string;
|
|
493
499
|
family?: MoleculeFamilyToken<M>;
|
|
@@ -497,7 +503,7 @@ declare class Molecule<M extends MoleculeConstructor> implements MoleculeToken<M
|
|
|
497
503
|
below: Map<string, Molecule<any>>;
|
|
498
504
|
joins: Map<string, Join<any, any, any, any>>;
|
|
499
505
|
instance: InstanceType<M>;
|
|
500
|
-
constructor(ctx: Molecule<any> | Molecule<any>[] | undefined, key:
|
|
506
|
+
constructor(ctx: Molecule<any> | Molecule<any>[] | undefined, key: MoleculeKey<M>, family?: MoleculeFamilyToken<M>);
|
|
501
507
|
}
|
|
502
508
|
|
|
503
509
|
declare function growMoleculeInStore<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable>(molecule: Molecule<any>, family: MutableAtomFamily<T, J, K>, store: Store): MutableAtomToken<T, J>;
|
|
@@ -584,4 +590,4 @@ type Selector<T> = ReadonlySelector<T> | WritableSelector<T>;
|
|
|
584
590
|
type WritableState<T> = Atom<T> | WritableSelector<T>;
|
|
585
591
|
type ReadableState<T> = Atom<T> | Selector<T>;
|
|
586
592
|
|
|
587
|
-
export { type Atom, type AtomIOState, type AtomKey, type ChildStore, type EnvironmentData, FamilyTracker, Future, IMPLICIT, LazyMap, type Lineage, type Modify, Molecule, type MutableAtom, NotFoundError, type OperationProgress, type ReadableState, type ReadonlySelector, type ReadonlySelectorKey, type RegularAtom, type RootStore, type Selector, type SelectorKey, type Signal, type StateKey, StatefulSubject, Store, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineMoleculeCreation, type TimelineMoleculeDisposal, type TimelineSelectorUpdate, type TimelineStateCreation, type TimelineStateDisposal, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionEpoch, type TransactionPhase, type TransactionProgress, type Transceiver, type TransceiverMode, type Withdrawable, type WritableSelector, type WritableState, abortTransaction, actUponStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtomFamily, createMoleculeFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deposit, disposeAtom, disposeFromStore, disposeMolecule, disposeSelector, eldest, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateToken, growMoleculeInStore, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isMutable, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, readCachedValue, readOrComputeValue, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw };
|
|
593
|
+
export { type Atom, type AtomIOState, type AtomKey, type ChildStore, type EnvironmentData, FamilyTracker, type Flat, type Func, Future, IMPLICIT, LazyMap, type Lineage, type Modify, Molecule, type MutableAtom, NotFoundError, type OperationProgress, type ReadableState, type ReadonlySelector, type ReadonlySelectorKey, type RegularAtom, type RootStore, type Selector, type SelectorKey, type Signal, type StateKey, StatefulSubject, Store, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineMoleculeCreation, type TimelineMoleculeDisposal, type TimelineSelectorUpdate, type TimelineStateCreation, type TimelineStateDisposal, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionEpoch, type TransactionPhase, type TransactionProgress, type Transceiver, type TransceiverMode, type Withdrawable, type WritableSelector, type WritableState, abortTransaction, actUponStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtomFamily, createMoleculeFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deposit, disposeAtom, disposeFromStore, disposeMolecule, disposeSelector, eldest, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateToken, growMoleculeInStore, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isMutable, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, readCachedValue, readOrComputeValue, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw };
|
package/internal/dist/index.js
CHANGED
|
@@ -1790,13 +1790,14 @@ var Store = class {
|
|
|
1790
1790
|
}
|
|
1791
1791
|
};
|
|
1792
1792
|
var IMPLICIT = {
|
|
1793
|
-
STORE_INTERNAL: void 0,
|
|
1794
1793
|
get STORE() {
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1794
|
+
if (!globalThis.ATOM_IO_IMPLICIT_STORE) {
|
|
1795
|
+
globalThis.ATOM_IO_IMPLICIT_STORE = new Store({
|
|
1796
|
+
name: `IMPLICIT_STORE`,
|
|
1797
|
+
lifespan: `ephemeral`
|
|
1798
|
+
});
|
|
1799
|
+
}
|
|
1800
|
+
return globalThis.ATOM_IO_IMPLICIT_STORE;
|
|
1800
1801
|
}
|
|
1801
1802
|
};
|
|
1802
1803
|
var clearStore = (store) => {
|
package/internal/src/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
CtorToolkit,
|
|
3
3
|
getState,
|
|
4
|
-
MK,
|
|
5
4
|
MoleculeConstructor,
|
|
6
5
|
MoleculeCreation,
|
|
7
6
|
MoleculeFamilyToken,
|
|
@@ -128,7 +127,7 @@ export function makeMoleculeInStore<M extends MoleculeConstructor>(
|
|
|
128
127
|
withdraw(token, rootStore),
|
|
129
128
|
newest(rootStore),
|
|
130
129
|
)
|
|
131
|
-
}) as CtorToolkit<
|
|
130
|
+
}) as CtorToolkit<MoleculeKey<M>>[`bond`],
|
|
132
131
|
claim: (below, options) => {
|
|
133
132
|
const { exclusive } = options
|
|
134
133
|
const belowMolecule = newest(store).molecules.get(stringifyJson(below.key))
|
|
@@ -154,7 +153,7 @@ export function makeMoleculeInStore<M extends MoleculeConstructor>(
|
|
|
154
153
|
k,
|
|
155
154
|
...p,
|
|
156
155
|
),
|
|
157
|
-
} satisfies CtorToolkit<
|
|
156
|
+
} satisfies CtorToolkit<MoleculeKey<M>>
|
|
158
157
|
|
|
159
158
|
const family = withdraw(familyToken, store)
|
|
160
159
|
const Constructor = family.new
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
MK,
|
|
3
2
|
MoleculeConstructor,
|
|
4
3
|
MoleculeFamilyToken,
|
|
4
|
+
MoleculeKey,
|
|
5
5
|
MoleculeToken,
|
|
6
6
|
ReadableToken,
|
|
7
7
|
StateCreation,
|
|
@@ -28,7 +28,7 @@ export class Molecule<M extends MoleculeConstructor>
|
|
|
28
28
|
public instance: InstanceType<M>
|
|
29
29
|
public constructor(
|
|
30
30
|
ctx: Molecule<any> | Molecule<any>[] | undefined,
|
|
31
|
-
public readonly key:
|
|
31
|
+
public readonly key: MoleculeKey<M>,
|
|
32
32
|
family?: MoleculeFamilyToken<M>,
|
|
33
33
|
) {
|
|
34
34
|
this.stringKey = stringifyJson(key)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AtomToken,
|
|
3
|
-
Func,
|
|
4
3
|
Logger,
|
|
5
4
|
MoleculeFamily,
|
|
6
5
|
MoleculeToken,
|
|
@@ -19,6 +18,7 @@ import { Junction } from "~/packages/rel8/junction/src"
|
|
|
19
18
|
|
|
20
19
|
import type {
|
|
21
20
|
Atom,
|
|
21
|
+
Func,
|
|
22
22
|
Molecule,
|
|
23
23
|
ReadonlySelector,
|
|
24
24
|
Tracker,
|
|
@@ -195,15 +195,14 @@ export class Store implements Lineage {
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
export const IMPLICIT = {
|
|
198
|
-
STORE_INTERNAL: undefined as Store | undefined,
|
|
199
198
|
get STORE(): Store {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
(this.STORE_INTERNAL = new Store({
|
|
199
|
+
if (!globalThis.ATOM_IO_IMPLICIT_STORE) {
|
|
200
|
+
globalThis.ATOM_IO_IMPLICIT_STORE = new Store({
|
|
203
201
|
name: `IMPLICIT_STORE`,
|
|
204
202
|
lifespan: `ephemeral`,
|
|
205
|
-
})
|
|
206
|
-
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
return globalThis.ATOM_IO_IMPLICIT_STORE as Store
|
|
207
206
|
},
|
|
208
207
|
}
|
|
209
208
|
|
|
@@ -2,7 +2,6 @@ import type {
|
|
|
2
2
|
AtomFamily,
|
|
3
3
|
AtomFamilyToken,
|
|
4
4
|
AtomToken,
|
|
5
|
-
Func,
|
|
6
5
|
MoleculeConstructor,
|
|
7
6
|
MoleculeFamily,
|
|
8
7
|
MoleculeFamilyToken,
|
|
@@ -36,6 +35,7 @@ import { type Json, stringifyJson } from "atom.io/json"
|
|
|
36
35
|
|
|
37
36
|
import type {
|
|
38
37
|
Atom,
|
|
38
|
+
Func,
|
|
39
39
|
Molecule,
|
|
40
40
|
MutableAtom,
|
|
41
41
|
ReadableState,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TransactionToken, TransactionUpdateHandler } from "atom.io"
|
|
2
2
|
|
|
3
|
-
import type { Store } from ".."
|
|
3
|
+
import type { Func, Store } from ".."
|
|
4
4
|
import { withdraw } from ".."
|
|
5
5
|
|
|
6
6
|
export const subscribeToTransaction = <F extends Func>(
|
|
@@ -2,8 +2,6 @@ import type {
|
|
|
2
2
|
AtomFamilyToken,
|
|
3
3
|
AtomToken,
|
|
4
4
|
FamilyMetadata,
|
|
5
|
-
Flat,
|
|
6
|
-
Func,
|
|
7
5
|
MoleculeConstructor,
|
|
8
6
|
MoleculeCreation,
|
|
9
7
|
MoleculeDisposal,
|
|
@@ -27,6 +25,7 @@ import { newest } from "../lineage"
|
|
|
27
25
|
import { getUpdateToken } from "../mutable"
|
|
28
26
|
import { type Store, withdraw } from "../store"
|
|
29
27
|
import { Subject } from "../subject"
|
|
28
|
+
import type { Flat, Func } from "../utility-types"
|
|
30
29
|
|
|
31
30
|
export type TimelineAtomUpdate<ManagedAtom extends TimelineManageable> = Flat<
|
|
32
31
|
StateUpdate<TokenType<ManagedAtom>> & {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TransactionToken } from "atom.io"
|
|
2
2
|
|
|
3
3
|
import { NotFoundError } from "../not-found-error"
|
|
4
4
|
import type { Store } from "../store"
|
|
5
5
|
import { withdraw } from "../store"
|
|
6
|
+
import type { Func } from "../utility-types"
|
|
6
7
|
|
|
7
8
|
export function actUponStore<F extends Func>(
|
|
8
9
|
token: TransactionToken<F>,
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { Func } from "atom.io"
|
|
2
|
-
|
|
3
1
|
import { ingestTransactionUpdate } from "../ingest-updates"
|
|
4
2
|
import { newest } from "../lineage"
|
|
5
3
|
import type { Store } from "../store"
|
|
6
4
|
import { withdraw } from "../store"
|
|
5
|
+
import type { Func } from "../utility-types"
|
|
7
6
|
import { isChildStore, isRootStore } from "./is-root-store"
|
|
8
7
|
import { setEpochNumberOfAction } from "./set-epoch-number"
|
|
9
8
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { disposeState,
|
|
1
|
+
import type { disposeState, getState, setState } from "atom.io"
|
|
2
2
|
import type { findState } from "atom.io/ephemeral"
|
|
3
3
|
import type { seekState } from "atom.io/immortal"
|
|
4
4
|
|
|
@@ -14,6 +14,7 @@ import { makeMoleculeInStore } from "../molecule"
|
|
|
14
14
|
import { getJsonToken } from "../mutable"
|
|
15
15
|
import { setIntoStore } from "../set-state"
|
|
16
16
|
import type { Store } from "../store"
|
|
17
|
+
import type { Func } from "../utility-types"
|
|
17
18
|
import type { TransactionProgress } from "."
|
|
18
19
|
import { actUponStore, getEpochNumberOfAction } from "."
|
|
19
20
|
import type { ChildStore, RootStore } from "./is-root-store"
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
Func,
|
|
3
2
|
TransactionOptions,
|
|
4
3
|
TransactionToken,
|
|
5
4
|
TransactionUpdate,
|
|
@@ -9,6 +8,7 @@ import { newest } from "../lineage"
|
|
|
9
8
|
import type { Store } from "../store"
|
|
10
9
|
import { deposit } from "../store"
|
|
11
10
|
import { Subject } from "../subject"
|
|
11
|
+
import type { Func } from "../utility-types"
|
|
12
12
|
import { abortTransaction } from "./abort-transaction"
|
|
13
13
|
import { applyTransaction } from "./apply-transaction"
|
|
14
14
|
import { buildTransaction } from "./build-transaction"
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { ActorToolkit,
|
|
1
|
+
import type { ActorToolkit, TransactionUpdate } from "atom.io"
|
|
2
2
|
import type { Junction } from "rel8/junction"
|
|
3
3
|
|
|
4
|
+
import type { Func } from "../utility-types"
|
|
5
|
+
|
|
4
6
|
export * from "./abort-transaction"
|
|
5
7
|
export * from "./act-upon-store"
|
|
6
8
|
export * from "./apply-transaction"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AtomToken, SelectorToken, ReadonlySelectorToken, TransactionToken,
|
|
1
|
+
import { AtomToken, SelectorToken, ReadonlySelectorToken, TransactionToken, ReadonlySelectorFamilyToken, TransactionUpdate, TimelineToken, ReadableToken } from 'atom.io';
|
|
2
2
|
import * as Internal from 'atom.io/internal';
|
|
3
|
-
import { Timeline } from 'atom.io/internal';
|
|
3
|
+
import { Func, Timeline } from 'atom.io/internal';
|
|
4
4
|
|
|
5
5
|
type AtomTokenIndex = WritableTokenIndex<AtomToken<unknown>>;
|
|
6
6
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
Func,
|
|
3
2
|
ReadonlySelectorFamilyToken,
|
|
4
3
|
ReadonlySelectorToken,
|
|
5
4
|
TimelineToken,
|
|
6
5
|
TransactionToken,
|
|
7
6
|
TransactionUpdate,
|
|
8
7
|
} from "atom.io"
|
|
9
|
-
import type { Timeline } from "atom.io/internal"
|
|
8
|
+
import type { Func, Timeline } from "atom.io/internal"
|
|
10
9
|
import * as Internal from "atom.io/internal"
|
|
11
10
|
|
|
12
11
|
import { type AtomTokenIndex, attachAtomIndex } from "./attach-atom-index"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Store } from "atom.io/internal"
|
|
1
|
+
import type { ReadonlySelectorToken, TransactionToken } from "atom.io"
|
|
2
|
+
import type { Func, Store } from "atom.io/internal"
|
|
3
3
|
import {
|
|
4
4
|
createRegularAtom,
|
|
5
5
|
createStandaloneSelector,
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
ReadonlySelectorFamilyToken,
|
|
4
|
-
TransactionUpdate,
|
|
5
|
-
} from "atom.io"
|
|
6
|
-
import type { Store } from "atom.io/internal"
|
|
1
|
+
import type { ReadonlySelectorFamilyToken, TransactionUpdate } from "atom.io"
|
|
2
|
+
import type { Func, Store } from "atom.io/internal"
|
|
7
3
|
import {
|
|
8
4
|
createRegularAtomFamily,
|
|
9
5
|
createSelectorFamily,
|