atom.io 0.25.3 → 0.25.5

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.
Files changed (45) hide show
  1. package/dist/index.cjs +6 -0
  2. package/dist/index.d.ts +40 -13
  3. package/dist/index.js +6 -0
  4. package/ephemeral/dist/index.d.ts +45 -0
  5. package/ephemeral/src/find-state.ts +45 -5
  6. package/internal/dist/index.cjs +17 -7
  7. package/internal/dist/index.d.ts +12 -6
  8. package/internal/dist/index.js +17 -7
  9. package/internal/src/index.ts +1 -0
  10. package/internal/src/ingest-updates/index.ts +1 -1
  11. package/internal/src/molecule/make-molecule-in-store.ts +2 -3
  12. package/internal/src/molecule/molecule-internal.ts +2 -2
  13. package/internal/src/selector/register-selector.ts +10 -1
  14. package/internal/src/store/deposit.ts +1 -1
  15. package/internal/src/store/store.ts +6 -7
  16. package/internal/src/store/withdraw.ts +1 -1
  17. package/internal/src/subscribe/subscribe-to-transaction.ts +2 -2
  18. package/internal/src/timeline/create-timeline.ts +1 -2
  19. package/internal/src/transaction/act-upon-store.ts +2 -1
  20. package/internal/src/transaction/apply-transaction.ts +1 -2
  21. package/internal/src/transaction/build-transaction.ts +2 -1
  22. package/internal/src/transaction/create-transaction.ts +1 -1
  23. package/internal/src/transaction/index.ts +3 -1
  24. package/internal/src/transaction/is-root-store.ts +1 -2
  25. package/internal/src/utility-types.ts +5 -0
  26. package/introspection/dist/index.d.ts +2 -2
  27. package/introspection/src/attach-introspection-states.ts +1 -2
  28. package/introspection/src/attach-transaction-index.ts +2 -2
  29. package/introspection/src/attach-transaction-logs.ts +2 -6
  30. package/package.json +18 -19
  31. package/react-devtools/dist/index.d.ts +2 -2
  32. package/react-devtools/src/TransactionIndex.tsx +1 -1
  33. package/react-devtools/src/Updates.tsx +1 -1
  34. package/realtime-client/dist/index.d.ts +3 -3
  35. package/realtime-client/src/server-action.ts +1 -1
  36. package/realtime-client/src/sync-continuity.ts +2 -2
  37. package/realtime-react/dist/index.d.ts +2 -2
  38. package/realtime-react/src/use-server-action.ts +2 -1
  39. package/src/atom.ts +17 -0
  40. package/src/index.ts +0 -6
  41. package/src/molecule.ts +2 -4
  42. package/src/set-state.ts +16 -0
  43. package/src/silo.ts +12 -0
  44. package/src/subscribe.ts +1 -3
  45. package/src/transaction.ts +1 -3
package/dist/index.cjs CHANGED
@@ -144,6 +144,12 @@ var Silo = class {
144
144
  this.redo = (token) => {
145
145
  Internal.timeTravel(`redo`, token, s);
146
146
  };
147
+ this.moleculeFamily = (...params) => {
148
+ return Internal.createMoleculeFamily(...params, s);
149
+ };
150
+ this.makeMolecule = (...params) => {
151
+ return Internal.makeMoleculeInStore(s, ...params);
152
+ };
147
153
  }
148
154
  };
149
155
  function subscribe(token, handleUpdate, key = Internal.arbitrary(), store = Internal.IMPLICIT.STORE) {
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, Flat as Flat$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';
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$1<Omit<ActorToolkit$1, `find`> & {
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$1<MoleculeFamilyToken<M> & {
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: MK<M>;
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 {
@@ -355,6 +386,8 @@ declare class Silo {
355
386
  subscribe: typeof subscribe;
356
387
  undo: typeof undo;
357
388
  redo: typeof redo;
389
+ moleculeFamily: typeof moleculeFamily;
390
+ makeMolecule: typeof makeMolecule;
358
391
  constructor(config: Store[`config`], fromStore?: Store | null);
359
392
  }
360
393
 
@@ -404,12 +437,6 @@ declare function belongsTo<Family extends ReadonlySelectorFamilyToken$1<any, any
404
437
  declare function belongsTo<Family extends WritableFamilyToken$1<any, any>>(family: Family, unknownToken: ReadableToken$1<any>): unknownToken is WritableToken$1<TokenType<Family>>;
405
438
  declare function belongsTo<Family extends ReadableFamilyToken$1<any, any>>(family: Family, unknownToken: ReadableToken$1<any>): unknownToken is ReadableToken$1<TokenType<Family>>;
406
439
 
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
440
  type RegularAtomToken<T> = {
414
441
  key: string;
415
442
  type: `atom`;
@@ -448,4 +475,4 @@ type FamilyMetadata = {
448
475
  subKey: string;
449
476
  };
450
477
 
451
- export { type ActorToolkit, type AtomEffect, type AtomFamily, type AtomFamilyToken, AtomIOLogger, type AtomOnly, type AtomToken, type CtorToolkit, type Effectors, type FamilyMetadata, type Flat, type Func, type GetterToolkit, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MK, 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 };
478
+ 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 };
package/dist/index.js CHANGED
@@ -123,6 +123,12 @@ var Silo = class {
123
123
  this.redo = (token) => {
124
124
  timeTravel(`redo`, token, s);
125
125
  };
126
+ this.moleculeFamily = (...params) => {
127
+ return createMoleculeFamily(...params, s);
128
+ };
129
+ this.makeMolecule = (...params) => {
130
+ return makeMoleculeInStore(s, ...params);
131
+ };
126
132
  }
127
133
  };
128
134
  function subscribe(token, handleUpdate, key = arbitrary(), store = IMPLICIT.STORE) {
@@ -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,
@@ -858,7 +858,16 @@ var registerSelector = (selectorKey, covered, store) => ({
858
858
  case `molecule_family`:
859
859
  return getFromStore(family, key, store);
860
860
  default:
861
- dependency = seekInStore(family, key, store);
861
+ if (store.config.lifespan === `ephemeral`) {
862
+ dependency = findInStore(family, key, store);
863
+ } else {
864
+ const maybeDependency = seekInStore(family, key, store);
865
+ if (maybeDependency) {
866
+ dependency = maybeDependency;
867
+ } else {
868
+ throw new NotFoundError(family, key, store);
869
+ }
870
+ }
862
871
  }
863
872
  } else {
864
873
  [dependency] = params;
@@ -2065,13 +2074,14 @@ var Store = class {
2065
2074
  }
2066
2075
  };
2067
2076
  var IMPLICIT = {
2068
- STORE_INTERNAL: void 0,
2069
2077
  get STORE() {
2070
- var _a;
2071
- return (_a = this.STORE_INTERNAL) != null ? _a : this.STORE_INTERNAL = new Store({
2072
- name: `IMPLICIT_STORE`,
2073
- lifespan: `ephemeral`
2074
- });
2078
+ if (!globalThis.ATOM_IO_IMPLICIT_STORE) {
2079
+ globalThis.ATOM_IO_IMPLICIT_STORE = new Store({
2080
+ name: `IMPLICIT_STORE`,
2081
+ lifespan: `ephemeral`
2082
+ });
2083
+ }
2084
+ return globalThis.ATOM_IO_IMPLICIT_STORE;
2075
2085
  }
2076
2086
  };
2077
2087
  var clearStore = (store) => {
@@ -1,5 +1,5 @@
1
1
  import * as atom_io from 'atom.io';
2
- import { Func, TransactionToken, TransactionUpdate, TransactionOptions, ActorToolkit, RegularAtomToken, MutableAtomToken, AtomToken, WritableSelectorToken, ReadonlySelectorToken, SelectorToken, WritableToken, MoleculeToken, MoleculeFamily, MoleculeFamilyToken, ReadableToken, TimelineManageable, Flat, 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, MK, MoleculeParams, ReadonlySelectorOptions, WritableSelectorOptions, SetterToolkit, UpdateHandler, TransactionUpdateHandler } from 'atom.io';
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, atom_io.Flat<atom_io.MoleculeFamilyToken<any> & {
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: MK<M>;
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: MK<M>, family?: MoleculeFamilyToken<M>);
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 };
@@ -583,7 +583,16 @@ var registerSelector = (selectorKey, covered, store) => ({
583
583
  case `molecule_family`:
584
584
  return getFromStore(family, key, store);
585
585
  default:
586
- dependency = seekInStore(family, key, store);
586
+ if (store.config.lifespan === `ephemeral`) {
587
+ dependency = findInStore(family, key, store);
588
+ } else {
589
+ const maybeDependency = seekInStore(family, key, store);
590
+ if (maybeDependency) {
591
+ dependency = maybeDependency;
592
+ } else {
593
+ throw new NotFoundError(family, key, store);
594
+ }
595
+ }
587
596
  }
588
597
  } else {
589
598
  [dependency] = params;
@@ -1790,13 +1799,14 @@ var Store = class {
1790
1799
  }
1791
1800
  };
1792
1801
  var IMPLICIT = {
1793
- STORE_INTERNAL: void 0,
1794
1802
  get STORE() {
1795
- var _a;
1796
- return (_a = this.STORE_INTERNAL) != null ? _a : this.STORE_INTERNAL = new Store({
1797
- name: `IMPLICIT_STORE`,
1798
- lifespan: `ephemeral`
1799
- });
1803
+ if (!globalThis.ATOM_IO_IMPLICIT_STORE) {
1804
+ globalThis.ATOM_IO_IMPLICIT_STORE = new Store({
1805
+ name: `IMPLICIT_STORE`,
1806
+ lifespan: `ephemeral`
1807
+ });
1808
+ }
1809
+ return globalThis.ATOM_IO_IMPLICIT_STORE;
1800
1810
  }
1801
1811
  };
1802
1812
  var clearStore = (store) => {
@@ -27,6 +27,7 @@ export * from "./subject"
27
27
  export * from "./subscribe"
28
28
  export * from "./timeline"
29
29
  export * from "./transaction"
30
+ export * from "./utility-types"
30
31
 
31
32
  export type AtomIOState = {
32
33
  key: string
@@ -1,4 +1,4 @@
1
1
  export * from "./ingest-atom-update"
2
- export * from "./ingest-creation-disposal.ts"
2
+ export * from "./ingest-creation-disposal"
3
3
  export * from "./ingest-selector-update"
4
4
  export * from "./ingest-transaction-update"
@@ -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<MK<M>>[`bond`],
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<MK<M>>
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: MK<M>,
31
+ public readonly key: MoleculeKey<M>,
32
32
  family?: MoleculeFamilyToken<M>,
33
33
  ) {
34
34
  this.stringKey = stringifyJson(key)
@@ -45,7 +45,16 @@ export const registerSelector = (
45
45
  case `molecule_family`:
46
46
  return getFromStore(family, key, store)
47
47
  default:
48
- dependency = seekInStore(family, key, store) as any
48
+ if (store.config.lifespan === `ephemeral`) {
49
+ dependency = findInStore(family, key, store)
50
+ } else {
51
+ const maybeDependency = seekInStore(family, key, store)
52
+ if (maybeDependency) {
53
+ dependency = maybeDependency
54
+ } else {
55
+ throw new NotFoundError(family, key, store)
56
+ }
57
+ }
49
58
  }
50
59
  } else {
51
60
  ;[dependency] = params
@@ -1,6 +1,5 @@
1
1
  import type {
2
2
  AtomToken,
3
- Func,
4
3
  MoleculeFamily,
5
4
  MoleculeFamilyToken,
6
5
  MoleculeToken,
@@ -17,6 +16,7 @@ import type { Json } from "atom.io/json"
17
16
 
18
17
  import type {
19
18
  Atom,
19
+ Func,
20
20
  Molecule,
21
21
  MutableAtom,
22
22
  ReadableState,
@@ -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
- return (
201
- this.STORE_INTERNAL ??
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 { Func, TransactionToken, TransactionUpdateHandler } from "atom.io"
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 { Func, TransactionToken } from "atom.io"
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, Func, getState, setState } from "atom.io"
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, Func, TransactionUpdate } from "atom.io"
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,5 @@
1
- import type { Func } from "atom.io"
2
-
3
1
  import type { Store } from "../store"
2
+ import type { Func } from "../utility-types"
4
3
  import type { TransactionEpoch, TransactionProgress } from "."
5
4
 
6
5
  export interface RootStore extends Store {
@@ -0,0 +1,5 @@
1
+ export type Func = (...parameters: any[]) => any
2
+
3
+ export type Flat<R extends { [K in PropertyKey]: any }> = {
4
+ [K in keyof R]: R[K]
5
+ }
@@ -1,6 +1,6 @@
1
- import { AtomToken, SelectorToken, ReadonlySelectorToken, TransactionToken, Func, ReadonlySelectorFamilyToken, TransactionUpdate, TimelineToken, ReadableToken } from 'atom.io';
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 { Func, ReadonlySelectorToken, TransactionToken } from "atom.io"
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
- Func,
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atom.io",
3
- "version": "0.25.3",
3
+ "version": "0.25.5",
4
4
  "description": "Composable and testable reactive data library.",
5
5
  "homepage": "https://atom.io.fyi",
6
6
  "sideEffects": false,
@@ -49,43 +49,42 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "@testing-library/react": "16.0.0",
52
- "@types/eslint": "npm:@types/eslint@8.56.10",
53
- "@types/eslint-v9": "npm:@types/eslint@8.56.10",
52
+ "@types/eslint": "npm:@types/eslint@9.6.0",
53
+ "@types/eslint-v9": "npm:@types/eslint@9.6.0",
54
54
  "@types/estree": "1.0.5",
55
55
  "@types/http-proxy": "1.17.14",
56
56
  "@types/npmlog": "7.0.0",
57
57
  "@types/react": "18.3.3",
58
58
  "@types/tmp": "0.2.6",
59
- "@typescript-eslint/parser": "7.15.0",
60
- "@typescript-eslint/rule-tester": "7.15.0",
61
- "@vitest/coverage-v8": "1.6.0",
62
- "@vitest/ui": "1.6.0",
59
+ "@typescript-eslint/parser": "7.17.0",
60
+ "@typescript-eslint/rule-tester": "7.17.0",
61
+ "@vitest/coverage-v8": "2.0.4",
62
+ "@vitest/ui": "2.0.4",
63
63
  "concurrently": "8.2.2",
64
- "drizzle-kit": "0.22.8",
65
- "drizzle-orm": "0.31.2",
64
+ "drizzle-kit": "0.23.0",
65
+ "drizzle-orm": "0.32.1",
66
66
  "eslint": "npm:eslint@8.57.0",
67
- "eslint-v9": "npm:eslint@9.6.0",
68
- "framer-motion": "11.2.12",
67
+ "eslint-v9": "npm:eslint@9.7.0",
68
+ "framer-motion": "11.3.17",
69
69
  "happy-dom": "14.12.3",
70
70
  "http-proxy": "1.18.1",
71
71
  "npmlog": "7.0.1",
72
72
  "postgres": "3.4.4",
73
- "preact": "10.22.1",
73
+ "preact": "10.23.1",
74
74
  "react": "18.3.1",
75
75
  "react-dom": "18.3.1",
76
- "react-router-dom": "6.24.0",
76
+ "react-router-dom": "6.25.1",
77
77
  "socket.io": "4.7.5",
78
78
  "socket.io-client": "4.7.5",
79
79
  "tmp": "0.2.3",
80
- "tsup": "8.1.0",
81
- "typescript": "5.5.3",
82
- "vite": "5.3.2",
80
+ "tsup": "8.2.3",
81
+ "typescript": "5.5.4",
82
+ "vite": "5.3.4",
83
83
  "vite-tsconfig-paths": "4.3.2",
84
- "vitest": "1.6.0"
84
+ "vitest": "2.0.4"
85
85
  },
86
86
  "main": "dist/index.js",
87
87
  "types": "dist/index.d.ts",
88
- "module": "dist/index.mjs",
89
88
  "files": [
90
89
  "dist",
91
90
  "src",
@@ -252,7 +251,7 @@
252
251
  "scripts": {
253
252
  "manifest": "tsx __scripts__/manifest-build.node.ts",
254
253
  "clean:build": "find . -type d -name 'dist' -not -path '*/node_modules/*' | xargs rm -rf",
255
- "build": "bun run clean:build && concurrently \"npm:build:*\"",
254
+ "build": "bun run clean:build && concurrently \"bun:build:*\"",
256
255
  "build:main": "tsup",
257
256
  "build:types": "tsup --dts",
258
257
  "build:data": "cd data && tsup",
@@ -61,8 +61,8 @@ declare const AtomIODevtools: () => JSX.Element;
61
61
 
62
62
  declare const atomIndex: atom_io.ReadonlySelectorToken<AtomTokenIndex>;
63
63
  declare const selectorIndex: atom_io.ReadonlySelectorToken<SelectorTokenIndex>;
64
- declare const transactionIndex: atom_io.ReadonlySelectorToken<atom_io.TransactionToken<atom_io.Func>[]>;
65
- declare const findTransactionLogState: atom_io.ReadonlySelectorFamilyToken<atom_io.TransactionUpdate<atom_io.Func>[], string>;
64
+ declare const transactionIndex: atom_io.ReadonlySelectorToken<atom_io.TransactionToken<Internal.Func>[]>;
65
+ declare const findTransactionLogState: atom_io.ReadonlySelectorFamilyToken<atom_io.TransactionUpdate<Internal.Func>[], string>;
66
66
  declare const timelineIndex: atom_io.ReadonlySelectorToken<atom_io.TimelineToken<any>[]>;
67
67
  declare const findTimelineState: atom_io.ReadonlySelectorFamilyToken<Internal.Timeline<any>, string>;
68
68
  declare const devtoolsAreOpenState: atom_io.RegularAtomToken<boolean>;
@@ -1,11 +1,11 @@
1
1
  import type {
2
- Func,
3
2
  ReadonlySelectorToken,
4
3
  RegularAtomToken,
5
4
  TransactionToken,
6
5
  TransactionUpdate,
7
6
  } from "atom.io"
8
7
  import { findState } from "atom.io/ephemeral"
8
+ import type { Func } from "atom.io/internal"
9
9
  import { useI, useO } from "atom.io/react"
10
10
  import type { FC } from "react"
11
11
 
@@ -1,9 +1,9 @@
1
1
  import type {
2
- Func,
3
2
  KeyedStateUpdate,
4
3
  TimelineUpdate,
5
4
  TransactionUpdate,
6
5
  } from "atom.io"
6
+ import type { Func } from "atom.io/internal"
7
7
  import * as React from "react"
8
8
 
9
9
  import { discoverType } from "~/packages/anvl/src/refinement/refinery"
@@ -1,6 +1,6 @@
1
1
  import * as AtomIO from 'atom.io';
2
2
  import * as Internal from 'atom.io/internal';
3
- import { Store, Transceiver } from 'atom.io/internal';
3
+ import { Store, Transceiver, Func } from 'atom.io/internal';
4
4
  import { Json } from 'atom.io/json';
5
5
  import { Socket } from 'socket.io-client';
6
6
  import { ContinuityToken } from 'atom.io/realtime';
@@ -26,8 +26,8 @@ declare const myUsernameState: AtomIO.RegularAtomToken<string | null>;
26
26
  declare const optimisticUpdateQueue: AtomIO.RegularAtomToken<AtomIO.TransactionUpdate<any>[]>;
27
27
  declare const confirmedUpdateQueue: AtomIO.RegularAtomToken<AtomIO.TransactionUpdate<any>[]>;
28
28
 
29
- declare function serverAction<F extends AtomIO.Func>(token: AtomIO.TransactionToken<F>, socket: Socket, store: Internal.Store): () => void;
29
+ declare function serverAction<F extends Internal.Func>(token: AtomIO.TransactionToken<F>, socket: Socket, store: Internal.Store): () => void;
30
30
 
31
- declare function syncContinuity<F extends AtomIO.Func>(continuity: ContinuityToken, socket: Socket, store: Store): () => void;
31
+ declare function syncContinuity<F extends Func>(continuity: ContinuityToken, socket: Socket, store: Store): () => void;
32
32
 
33
33
  export { confirmedUpdateQueue, myIdState, myIdState__INTERNAL, myUsernameState, optimisticUpdateQueue, pullAtom, pullAtomFamilyMember, pullMutableAtom, pullMutableAtomFamilyMember, pullSelector, pullSelectorFamilyMember, pushState, serverAction, syncContinuity };
@@ -2,7 +2,7 @@ import type * as AtomIO from "atom.io"
2
2
  import * as Internal from "atom.io/internal"
3
3
  import type { Socket } from "socket.io-client"
4
4
 
5
- export function serverAction<F extends AtomIO.Func>(
5
+ export function serverAction<F extends Internal.Func>(
6
6
  token: AtomIO.TransactionToken<F>,
7
7
  socket: Socket,
8
8
  store: Internal.Store,
@@ -1,5 +1,5 @@
1
1
  import type * as AtomIO from "atom.io"
2
- import type { Store } from "atom.io/internal"
2
+ import type { Func, Store } from "atom.io/internal"
3
3
  import {
4
4
  actUponStore,
5
5
  assignTransactionToContinuity,
@@ -21,7 +21,7 @@ import {
21
21
  } from "atom.io/realtime-client"
22
22
  import type { Socket } from "socket.io-client"
23
23
 
24
- export function syncContinuity<F extends AtomIO.Func>(
24
+ export function syncContinuity<F extends Func>(
25
25
  continuity: ContinuityToken,
26
26
  socket: Socket,
27
27
  store: Store,
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { Socket } from 'socket.io-client';
3
3
  import * as AtomIO from 'atom.io';
4
4
  import { Json } from 'atom.io/json';
5
- import { Transceiver } from 'atom.io/internal';
5
+ import { Transceiver, Func } from 'atom.io/internal';
6
6
  import { ContinuityToken } from 'atom.io/realtime';
7
7
 
8
8
  type RealtimeReactStore = {
@@ -32,7 +32,7 @@ declare function usePullSelectorFamilyMember<T, K extends Json.Serializable, Key
32
32
 
33
33
  declare function usePush<J extends Json.Serializable>(token: AtomIO.WritableToken<J>): <New extends J>(next: New | ((old: J) => New)) => void;
34
34
 
35
- declare function useServerAction<F extends AtomIO.Func>(token: AtomIO.TransactionToken<F>): (...parameters: Parameters<F>) => ReturnType<F>;
35
+ declare function useServerAction<F extends Func>(token: AtomIO.TransactionToken<F>): (...parameters: Parameters<F>) => ReturnType<F>;
36
36
 
37
37
  declare function useSyncContinuity(token: ContinuityToken): void;
38
38
 
@@ -1,4 +1,5 @@
1
1
  import type * as AtomIO from "atom.io"
2
+ import type { Func } from "atom.io/internal"
2
3
  import { actUponStore, arbitrary } from "atom.io/internal"
3
4
  import { StoreContext } from "atom.io/react"
4
5
  import * as RTC from "atom.io/realtime-client"
@@ -6,7 +7,7 @@ import * as React from "react"
6
7
 
7
8
  import { useRealtimeService } from "./use-realtime-service"
8
9
 
9
- export function useServerAction<F extends AtomIO.Func>(
10
+ export function useServerAction<F extends Func>(
10
11
  token: AtomIO.TransactionToken<F>,
11
12
  ): (...parameters: Parameters<F>) => ReturnType<F> {
12
13
  const store = React.useContext(StoreContext)
package/src/atom.ts CHANGED
@@ -35,10 +35,27 @@ export type MutableAtomOptions<T extends Transceiver<any>, J extends Json.Serial
35
35
  mutable: true
36
36
  }
37
37
 
38
+ /**
39
+ * @public
40
+ * Declare a mutable global reactive variable.
41
+ * @param options - Configuration for this mutable atom.
42
+ * @returns
43
+ * The token for your mutable atom.
44
+ * @overload Mutable
45
+ */
38
46
  export function atom<T extends Transceiver<any>, J extends Json.Serializable>(
39
47
  options: MutableAtomOptions<T, J>,
40
48
  ): MutableAtomToken<T, J>
49
+ /**
50
+ * @public
51
+ * Declare a regular global reactive variable.
52
+ * @param options - Configuration for this regular atom.
53
+ * @returns
54
+ * The token for your regular atom.
55
+ * @overload Regular
56
+ */
41
57
  export function atom<T>(options: RegularAtomOptions<T>): RegularAtomToken<T>
58
+
42
59
  export function atom(
43
60
  options: MutableAtomOptions<any, any> | RegularAtomOptions<any>,
44
61
  ): AtomToken<any> {
package/src/index.ts CHANGED
@@ -22,12 +22,6 @@ export * from "./timeline"
22
22
  export * from "./transaction"
23
23
  export * from "./validators"
24
24
 
25
- export type Func = (...parameters: any[]) => any
26
-
27
- export type Flat<R extends { [K in PropertyKey]: any }> = {
28
- [K in keyof R]: R[K]
29
- }
30
-
31
25
  export type RegularAtomToken<T> = {
32
26
  key: string
33
27
  type: `atom`
package/src/molecule.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import type {
2
2
  ActorToolkit,
3
- Flat,
4
3
  MoleculeCreation,
5
4
  MoleculeDisposal,
6
5
  MutableAtomFamilyToken,
@@ -17,7 +16,7 @@ import type {
17
16
  WritableToken,
18
17
  } from "atom.io"
19
18
  import type { JoinToken } from "atom.io/data"
20
- import type { Store, Subject, Transceiver } from "atom.io/internal"
19
+ import type { Flat, Store, Subject, Transceiver } from "atom.io/internal"
21
20
  import {
22
21
  createMoleculeFamily,
23
22
  IMPLICIT,
@@ -92,7 +91,7 @@ export type MoleculeFamily<M extends MoleculeConstructor> = Flat<
92
91
  }
93
92
  >
94
93
  export type MoleculeToken<M extends MoleculeConstructor> = {
95
- key: MK<M>
94
+ key: MoleculeKey<M>
96
95
  type: `molecule`
97
96
  family?: MoleculeFamilyToken<M>
98
97
  __M?: M
@@ -120,7 +119,6 @@ export type MoleculeType<T extends MoleculeFamilyToken<any>> =
120
119
  ? M
121
120
  : never
122
121
  export type MoleculeKey<M extends MoleculeConstructor> = InstanceType<M>[`key`]
123
- export type MK<M extends MoleculeConstructor> = MoleculeKey<M>
124
122
 
125
123
  export function makeRootMolecule(
126
124
  key: string,
package/src/set-state.ts CHANGED
@@ -3,11 +3,27 @@ import type { Json } from "rel8"
3
3
 
4
4
  import type { WritableFamilyToken, WritableToken } from "."
5
5
 
6
+ /**
7
+ * @public
8
+ * Set the value of a state into the implicit store.
9
+ * @param token - The unique identifier of the state to set.
10
+ * @param value - The new value of the state.
11
+ * @overload Default
12
+ * @default
13
+ */
6
14
  export function setState<T, New extends T>(
7
15
  token: WritableToken<T>,
8
16
  value: New | ((oldValue: T) => New),
9
17
  ): void
10
18
 
19
+ /**
20
+ * @public
21
+ * Set the value of a state into the implicit store.
22
+ * @param token - The unique identifier of a state family.
23
+ * @param key - The key of the state to set.
24
+ * @param value - The new value of the state.
25
+ * @overload Streamlined
26
+ */
11
27
  export function setState<T, K extends Json.Serializable, New extends T>(
12
28
  token: WritableFamilyToken<T, K>,
13
29
  key: K,
package/src/silo.ts CHANGED
@@ -2,6 +2,7 @@ import type { findState } from "atom.io/ephemeral"
2
2
  import type { Transceiver } from "atom.io/internal"
3
3
  import {
4
4
  createAtomFamily,
5
+ createMoleculeFamily,
5
6
  createSelectorFamily,
6
7
  createStandaloneAtom,
7
8
  createStandaloneSelector,
@@ -10,6 +11,7 @@ import {
10
11
  disposeFromStore,
11
12
  findInStore,
12
13
  getFromStore,
14
+ makeMoleculeInStore,
13
15
  setIntoStore,
14
16
  Store,
15
17
  timeTravel,
@@ -20,6 +22,8 @@ import type {
20
22
  AtomToken,
21
23
  disposeState,
22
24
  getState,
25
+ makeMolecule,
26
+ moleculeFamily,
23
27
  MutableAtomFamily,
24
28
  MutableAtomFamilyOptions,
25
29
  MutableAtomOptions,
@@ -53,6 +57,8 @@ export class Silo {
53
57
  public subscribe: typeof subscribe
54
58
  public undo: typeof undo
55
59
  public redo: typeof redo
60
+ public moleculeFamily: typeof moleculeFamily
61
+ public makeMolecule: typeof makeMolecule
56
62
  public constructor(config: Store[`config`], fromStore: Store | null = null) {
57
63
  const s = new Store(config, fromStore)
58
64
  function _atom<T>(options: RegularAtomOptions<T>): RegularAtomToken<T>
@@ -102,5 +108,11 @@ export class Silo {
102
108
  this.redo = (token) => {
103
109
  timeTravel(`redo`, token, s)
104
110
  }
111
+ this.moleculeFamily = ((...params: Parameters<typeof moleculeFamily>) => {
112
+ return createMoleculeFamily(...params, s)
113
+ }) as any
114
+ this.makeMolecule = ((...params: Parameters<typeof makeMolecule>) => {
115
+ return makeMoleculeInStore(s, ...params)
116
+ }) as any
105
117
  }
106
118
  }
package/src/subscribe.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Store } from "atom.io/internal"
1
+ import type { Flat, Func, Store } from "atom.io/internal"
2
2
  import {
3
3
  arbitrary,
4
4
  IMPLICIT,
@@ -9,8 +9,6 @@ import {
9
9
 
10
10
  import type {
11
11
  FamilyMetadata,
12
- Flat,
13
- Func,
14
12
  ReadableToken,
15
13
  TimelineManageable,
16
14
  TimelineToken,
@@ -9,7 +9,7 @@ import type {
9
9
  } from "atom.io"
10
10
  import type { findState } from "atom.io/ephemeral"
11
11
  import type { seekState } from "atom.io/immortal"
12
- import type { EnvironmentData, Transceiver } from "atom.io/internal"
12
+ import type { EnvironmentData, Func, Transceiver } from "atom.io/internal"
13
13
  import {
14
14
  actUponStore,
15
15
  arbitrary,
@@ -20,11 +20,9 @@ import type { Json } from "atom.io/json"
20
20
 
21
21
  import type {
22
22
  disposeState,
23
- Func,
24
23
  KeyedStateUpdate,
25
24
  MutableAtomToken,
26
25
  ReadableToken,
27
- ReadonlySelectorToken,
28
26
  TokenType,
29
27
  WritableSelectorToken,
30
28
  WritableToken,