atom.io 0.30.7 → 0.31.1

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 (92) hide show
  1. package/data/dist/index.d.ts +20 -18
  2. package/data/dist/index.js +104 -172
  3. package/data/src/join.ts +138 -210
  4. package/dist/{chunk-UDHCFTYT.js → chunk-Y5MBNTVU.js} +582 -762
  5. package/dist/index.d.ts +254 -173
  6. package/dist/index.js +91 -14
  7. package/ephemeral/dist/index.d.ts +35 -25
  8. package/ephemeral/src/find-state.ts +35 -25
  9. package/eslint-plugin/dist/index.d.ts +22 -3
  10. package/eslint-plugin/dist/index.js +7 -7
  11. package/immortal/dist/index.d.ts +1 -2
  12. package/immortal/dist/index.js +0 -3
  13. package/immortal/src/seek-state.ts +2 -14
  14. package/internal/dist/index.d.ts +57 -88
  15. package/internal/dist/index.js +1 -2
  16. package/internal/src/atom/dispose-atom.ts +31 -15
  17. package/internal/src/families/dispose-from-store.ts +15 -44
  18. package/internal/src/families/find-in-store.ts +9 -7
  19. package/internal/src/families/init-family-member.ts +1 -1
  20. package/internal/src/families/seek-in-store.ts +2 -14
  21. package/internal/src/get-state/get-from-store.ts +13 -79
  22. package/internal/src/get-trace.ts +7 -0
  23. package/internal/src/index.ts +17 -8
  24. package/internal/src/ingest-updates/ingest-creation-disposal.ts +65 -73
  25. package/internal/src/ingest-updates/ingest-transaction-update.ts +4 -0
  26. package/internal/src/install-into-store.ts +48 -0
  27. package/internal/src/junction.ts +52 -12
  28. package/internal/src/lineage.ts +0 -7
  29. package/internal/src/molecule.ts +306 -0
  30. package/internal/src/mutable/transceiver.ts +5 -5
  31. package/internal/src/not-found-error.ts +8 -30
  32. package/internal/src/pretty-print.ts +1 -16
  33. package/internal/src/selector/dispose-selector.ts +3 -5
  34. package/internal/src/selector/register-selector.ts +3 -34
  35. package/internal/src/set-state/set-into-store.ts +3 -2
  36. package/internal/src/store/counterfeit.ts +11 -25
  37. package/internal/src/store/deposit.ts +10 -42
  38. package/internal/src/store/store.ts +51 -12
  39. package/internal/src/store/withdraw.ts +18 -60
  40. package/internal/src/timeline/create-timeline.ts +133 -237
  41. package/internal/src/timeline/time-travel.ts +1 -8
  42. package/internal/src/transaction/build-transaction.ts +10 -5
  43. package/internal/src/transaction/index.ts +1 -1
  44. package/internal/src/utility-types.ts +2 -0
  45. package/introspection/dist/index.d.ts +2 -3
  46. package/introspection/dist/index.js +9 -9
  47. package/introspection/src/refinery.ts +1 -3
  48. package/json/dist/index.js +8 -40
  49. package/json/src/index.ts +2 -0
  50. package/json/src/select-json-family.ts +7 -44
  51. package/package.json +33 -28
  52. package/react/dist/index.js +2 -10
  53. package/react/src/parse-state-overloads.ts +3 -11
  54. package/react-devtools/dist/index.js +13 -13
  55. package/react-devtools/src/Updates.tsx +2 -0
  56. package/realtime-client/dist/index.d.ts +20 -12
  57. package/realtime-client/dist/index.js +241 -244
  58. package/realtime-client/src/continuity/index.ts +3 -0
  59. package/realtime-client/src/continuity/register-and-attempt-confirmed-update.ts +231 -0
  60. package/realtime-client/src/continuity/use-conceal-state.ts +11 -0
  61. package/realtime-client/src/continuity/use-reveal-state.ts +19 -0
  62. package/realtime-client/src/index.ts +1 -0
  63. package/realtime-client/src/sync-continuity.ts +18 -262
  64. package/realtime-react/dist/index.js +2 -2
  65. package/realtime-server/dist/index.d.ts +1 -1
  66. package/realtime-server/dist/index.js +2 -2
  67. package/realtime-server/src/index.ts +1 -1
  68. package/realtime-server/src/ipc-sockets/child-socket.ts +0 -1
  69. package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +1 -1
  70. package/realtime-testing/dist/index.js +5 -7
  71. package/realtime-testing/src/setup-realtime-test.tsx +5 -6
  72. package/src/atom.ts +53 -29
  73. package/src/dispose-state.ts +17 -23
  74. package/src/get-state.ts +19 -21
  75. package/src/index.ts +73 -3
  76. package/src/realm.ts +169 -0
  77. package/src/selector.ts +20 -0
  78. package/src/set-state.ts +16 -8
  79. package/src/silo.ts +9 -14
  80. package/src/timeline.ts +2 -3
  81. package/src/transaction.ts +25 -38
  82. package/transceivers/set-rtx/dist/index.js +4 -1
  83. package/transceivers/set-rtx/src/set-rtx.ts +4 -1
  84. package/dist/chunk-ADMEAXYU.js +0 -167
  85. package/internal/src/molecule/create-molecule-family.ts +0 -30
  86. package/internal/src/molecule/dispose-molecule.ts +0 -79
  87. package/internal/src/molecule/grow-molecule-in-store.ts +0 -95
  88. package/internal/src/molecule/index.ts +0 -5
  89. package/internal/src/molecule/make-molecule-in-store.ts +0 -191
  90. package/internal/src/molecule/molecule-internal.ts +0 -52
  91. package/src/allocate.ts +0 -277
  92. package/src/molecule.ts +0 -138
package/dist/index.d.ts CHANGED
@@ -1,48 +1,71 @@
1
- import { Transceiver, Func, EnvironmentData, Flat, Subject, Store, Each, Timeline, TimelineAtomUpdate, TimelineMoleculeCreation, TimelineMoleculeDisposal, TimelineSelectorUpdate, TimelineStateCreation, TimelineStateDisposal, TimelineTransactionUpdate } from 'atom.io/internal';
1
+ import { Transceiver, Func, EnvironmentData, Timeline, TimelineAtomUpdate, TimelineMoleculeCreation, TimelineMoleculeDisposal, TimelineSelectorUpdate, TimelineStateCreation, TimelineStateDisposal, TimelineTransactionUpdate, Store, Each, Flat } from 'atom.io/internal';
2
2
  import { Json, JsonInterface, Canonical, stringified } 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, 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, MoleculeCreationClassic as MoleculeCreationClassic$1, MoleculeDisposalClassic as MoleculeDisposalClassic$1 } from 'atom.io';
3
+ import { getState as getState$1, setState as setState$1, ReadableFamilyToken as ReadableFamilyToken$1, ReadableToken as ReadableToken$1, RegularAtomToken as RegularAtomToken$1, MutableAtomToken as MutableAtomToken$1, WritableSelectorToken as WritableSelectorToken$1, ReadonlySelectorToken as ReadonlySelectorToken$1, WritableToken as WritableToken$1, RegularAtomFamilyToken as RegularAtomFamilyToken$1, MutableAtomFamilyToken as MutableAtomFamilyToken$1, WritableSelectorFamilyToken as WritableSelectorFamilyToken$1, ReadonlySelectorFamilyToken as ReadonlySelectorFamilyToken$1, WritableFamilyToken as WritableFamilyToken$1 } from 'atom.io';
4
4
  import { findState } from 'atom.io/ephemeral';
5
5
  import { seekState } from 'atom.io/immortal';
6
- import { JoinToken } from 'atom.io/data';
7
6
 
7
+ /**
8
+ * @public
9
+ * Create a mutable atom, a global reactive variable in the implicit store
10
+ *
11
+ * The value of a mutable atom must be some kind of {@link Transceiver}.
12
+ *
13
+ * @param options - {@link MutableAtomOptions}.
14
+ * @returns
15
+ * A reference to the atom created: a {@link MutableAtomToken}
16
+ * @overload Mutable
17
+ */
18
+ declare function atom<T extends Transceiver<any>, J extends Json.Serializable>(options: MutableAtomOptions<T, J>): MutableAtomToken<T, J>;
19
+ /**
20
+ * @public
21
+ * Create a regular atom, a global reactive variable in the implicit store
22
+ * @param options - {@link RegularAtomOptions}.
23
+ * @returns
24
+ * A reference to the atom created: a {@link RegularAtomToken}
25
+ * @overload Regular
26
+ */
27
+ declare function atom<T>(options: RegularAtomOptions<T>): RegularAtomToken<T>;
28
+ /** @public */
8
29
  type Effectors<T> = {
9
- setSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void;
30
+ /**
31
+ * Set the value of the atom
32
+ * @param next - The new value of the atom, or a setter function
33
+ */
34
+ setSelf: <New extends T>(next: New | Setter<T, New>) => void;
35
+ /** Subscribe to changes to the atom */
10
36
  onSet: (callback: (options: {
11
37
  newValue: T;
12
38
  oldValue: T;
13
39
  }) => void) => void;
14
40
  };
41
+ /**
42
+ * @public
43
+ * A function that runs side effects when the atom is set
44
+ * @param tools - {@link Effectors} that can be used to run side effects
45
+ * @returns
46
+ * Optionally, a cleanup function that will be called when the atom is disposed
47
+ */
15
48
  type AtomEffect<T> = (tools: Effectors<T>) => (() => void) | void;
49
+ /** @public */
16
50
  type RegularAtomOptions<T> = {
51
+ /** The unique identifier of the atom */
17
52
  key: string;
53
+ /** The starting value of the atom */
18
54
  default: T | (() => T);
55
+ /** Hooks used to run side effects when the atom is set */
19
56
  effects?: AtomEffect<T>[];
20
57
  };
21
58
  type MutableAtomOptions<T extends Transceiver<any>, J extends Json.Serializable> = JsonInterface<T, J> & Omit<RegularAtomOptions<T>, `default`> & {
22
59
  default: () => T;
23
60
  mutable: true;
24
61
  };
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
- */
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
- */
42
- declare function atom<T>(options: RegularAtomOptions<T>): RegularAtomToken<T>;
62
+ /** @public */
43
63
  type RegularAtomFamilyOptions<T, K extends Canonical> = {
64
+ /** The unique identifier of the atom family */
44
65
  key: string;
66
+ /** The starting value of the atom family */
45
67
  default: T | ((key: K) => T);
68
+ /** Hooks used to run side effects when an atom in the family is set */
46
69
  effects?: (key: K) => AtomEffect<T>[];
47
70
  };
48
71
  type RegularAtomFamilyToken<T, K extends Canonical> = {
@@ -77,43 +100,36 @@ type StateCreation<Token extends ReadableToken<any>> = {
77
100
  type: `state_creation`;
78
101
  token: Token;
79
102
  };
80
- type StateDisposal<Token extends ReadableToken<any>> = {
103
+ type AtomDisposal<Token extends ReadableToken<any>> = {
81
104
  type: `state_disposal`;
105
+ subType: `atom`;
82
106
  token: Token;
83
- value?: TokenType<Token>;
107
+ value: TokenType<Token>;
84
108
  };
85
- type MoleculeCreationClassic<M extends MoleculeConstructor$1> = {
86
- type: `molecule_creation`;
87
- subType: `classic`;
88
- token: MoleculeToken$1<M>;
89
- family: MoleculeFamilyToken$1<M>;
90
- context: MoleculeToken$1<any>[];
91
- params: MoleculeParams$1<M>;
109
+ type SelectorDisposal<Token extends ReadableToken<any>> = {
110
+ type: `state_disposal`;
111
+ subType: `selector`;
112
+ token: Token;
92
113
  };
93
- type MoleculeCreationModern = {
114
+ type StateDisposal<Token extends ReadableToken<any>> = AtomDisposal<Token> | SelectorDisposal<Token>;
115
+ type MoleculeCreation = {
94
116
  type: `molecule_creation`;
95
- subType: `modern`;
96
117
  key: Canonical;
97
118
  provenance: Canonical;
98
119
  };
99
- type MoleculeCreation<M extends MoleculeConstructor$1> = MoleculeCreationClassic<M> | MoleculeCreationModern;
100
- type MoleculeDisposalClassic = {
120
+ type MoleculeDisposal = {
101
121
  type: `molecule_disposal`;
102
- subType: `classic`;
103
- token: MoleculeToken$1<any>;
104
- family: MoleculeFamilyToken$1<any>;
105
- context: MoleculeToken$1<any>[];
122
+ key: Canonical;
123
+ provenance: stringified<Canonical>[];
106
124
  values: [key: string, value: any][];
107
125
  };
108
- type MoleculeDisposalModern = {
109
- type: `molecule_disposal`;
110
- subType: `modern`;
126
+ type MoleculeTransfer = {
127
+ type: `molecule_transfer`;
111
128
  key: Canonical;
112
- provenance: Canonical;
113
- values: [key: string, value: any][];
129
+ from: Canonical[];
130
+ to: Canonical[];
114
131
  };
115
- type MoleculeDisposal = MoleculeDisposalClassic | MoleculeDisposalModern;
116
- type TransactionUpdateContent = KeyedStateUpdate<unknown> | MoleculeCreation<any> | MoleculeDisposal | StateCreation<ReadableToken<unknown>> | StateDisposal<ReadableToken<unknown>> | TransactionUpdate<Func>;
132
+ type TransactionUpdateContent = KeyedStateUpdate<unknown> | MoleculeCreation | MoleculeDisposal | MoleculeTransfer | StateCreation<ReadableToken<unknown>> | StateDisposal<ReadableToken<unknown>> | TransactionUpdate<Func>;
117
133
  type TransactionUpdate<F extends Func> = {
118
134
  type: `transaction_update`;
119
135
  key: string;
@@ -137,7 +153,6 @@ type ActorToolkit = Readonly<{
137
153
  find: typeof findState;
138
154
  seek: typeof seekState;
139
155
  json: <T extends Transceiver<any>, J extends Json.Serializable>(state: MutableAtomToken<T, J>) => WritableSelectorToken<J>;
140
- make: typeof makeMolecule$1;
141
156
  dispose: typeof disposeState;
142
157
  run: typeof runTransaction;
143
158
  env: () => EnvironmentData;
@@ -162,7 +177,26 @@ type ReadonlySelectorOptions<T> = {
162
177
  key: string;
163
178
  get: Read<() => T>;
164
179
  };
180
+ /**
181
+ * @public
182
+ * Declare a selector. The value of a selector should depend
183
+ * on the value of atoms or other selectors in the store.
184
+ *
185
+ * A writable selector can be "set" to a new value.
186
+ * It is advised to set its dependencies to values
187
+ * that would produce the new value of the selector.
188
+ * @param options - {@link WritableSelectorOptions}.
189
+ * @returns
190
+ * The token for your selector.
191
+ * @overload Writable
192
+ */
165
193
  declare function selector<T>(options: WritableSelectorOptions<T>): WritableSelectorToken<T>;
194
+ /**
195
+ * @public
196
+ * Declare a selector. The value of a selector should depend
197
+ * on the value of atoms or other selectors in the store.
198
+ * @param options - {@link ReadonlySelectorOptions}.
199
+ */
166
200
  declare function selector<T>(options: ReadonlySelectorOptions<T>): ReadonlySelectorToken<T>;
167
201
  type WritableSelectorFamilyOptions<T, K extends Canonical> = {
168
202
  key: string;
@@ -189,116 +223,56 @@ type SelectorFamilyToken<T, K extends Canonical> = ReadonlySelectorFamilyToken<T
189
223
  declare function selectorFamily<T, K extends Canonical>(options: WritableSelectorFamilyOptions<T, K>): WritableSelectorFamilyToken<T, K>;
190
224
  declare function selectorFamily<T, K extends Canonical>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamilyToken<T, K>;
191
225
 
192
- type CtorToolkit<K extends Canonical> = Flat<Omit<ActorToolkit$1, `find`> & {
193
- bond<T extends Transceiver<any>, J extends Json.Serializable>(family: MutableAtomFamilyToken$1<T, J, K>): MutableAtomToken$1<T, J>;
194
- bond<T>(family: RegularAtomFamilyToken$1<T, K>): RegularAtomToken$1<T>;
195
- bond<T>(family: WritableSelectorFamilyToken$1<T, K>): WritableSelectorToken$1<T>;
196
- bond<T>(family: ReadonlySelectorFamilyToken$1<T, K>): ReadonlySelectorToken$1<T>;
197
- bond<T>(family: WritableFamilyToken$1<T, K>): WritableToken$1<T>;
198
- bond<T>(family: ReadableFamilyToken$1<T, K>): ReadableToken$1<T>;
199
- bond<J extends JoinToken<any, any, any, any, any, any>>(joinToken: J, role: {
200
- as: J extends JoinToken<infer A, string, infer B, string, any, any> ? A | B : never;
201
- }): J extends JoinToken<any, any, any, any, any, infer Content> ? Content extends null ? {
202
- relatedKeys: ReadonlySelectorToken$1<string[]>;
203
- } : {
204
- relatedKeys: ReadonlySelectorToken$1<string[]>;
205
- relatedEntries: ReadonlySelectorToken$1<[
206
- key: string,
207
- value: Content
208
- ][]>;
209
- } : never;
210
- claim(below: MoleculeToken<any>, options: {
211
- exclusive: boolean;
212
- }): void;
213
- spawn<Key extends Canonical, Ctor extends MoleculeConstructor>(family: MoleculeFamilyToken<Ctor>, key: Key, ...params: MoleculeParams<Ctor>): MoleculeToken<Ctor>;
214
- }>;
215
- type MoleculeConstructor = new (toolkit: CtorToolkit<any>, key: any, ...params: any) => any;
216
- type Tail<T extends any[]> = T extends [any, ...infer Rest] ? Rest : any[];
217
- type MoleculeParams<M extends MoleculeConstructor> = Tail<Tail<ConstructorParameters<M>>>;
218
- type MoleculeFamilyOptions<M extends MoleculeConstructor> = {
219
- key: string;
220
- dependsOn?: `all` | `any`;
221
- new: M;
222
- };
223
- type MoleculeFamilyToken<M extends MoleculeConstructor> = {
226
+ type TimelineManageable = AtomFamilyToken<any, any> | AtomToken<any>;
227
+ type AtomOnly<M extends TimelineManageable> = M extends AtomFamilyToken<any, any> ? AtomToken<any> : M extends AtomToken<any> ? M : never;
228
+ type TimelineToken<M> = {
224
229
  key: string;
225
- type: `molecule_family`;
226
- dependsOn: `all` | `any`;
227
- __M?: M;
228
- };
229
- type MoleculeFamily<M extends MoleculeConstructor> = Flat<MoleculeFamilyToken<M> & {
230
- subject: Subject<MoleculeCreationClassic$1<M> | MoleculeDisposalClassic$1>;
231
- dependsOn: `all` | `any`;
232
- new: M;
233
- }>;
234
- type MoleculeToken<M extends MoleculeConstructor> = {
235
- key: MoleculeKey<M>;
236
- type: `molecule`;
237
- family?: MoleculeFamilyToken<M>;
230
+ type: `timeline`;
238
231
  __M?: M;
239
232
  };
240
- declare function moleculeFamily<M extends MoleculeConstructor>(options: MoleculeFamilyOptions<M>): MoleculeFamilyToken<M>;
241
- declare function makeMolecule<M extends MoleculeConstructor>(context: MoleculeToken<any> | MoleculeToken<any>[], family: MoleculeFamilyToken<M>, key: MoleculeKey<M>, ...params: MoleculeParams<M>): MoleculeToken<M>;
242
- type MoleculeType<T extends MoleculeFamilyToken<any>> = T extends MoleculeFamilyToken<infer M> ? M : T extends MoleculeToken<infer M> ? M : never;
243
- type MoleculeKey<M extends MoleculeConstructor> = InstanceType<M>[`key`];
244
- declare function makeRootMoleculeInStore(key: string, store?: Store): MoleculeToken<ObjectConstructor>;
245
-
246
- declare const $provenance: unique symbol;
247
- type Claim<H extends Hierarchy, V extends Vassal<H>, A extends Above<V, H>> = V & {
248
- [$provenance]?: A;
249
- };
250
- declare function allocateIntoStore<H extends Hierarchy, V extends Vassal<H>, A extends Above<V, H>>(store: Store, provenance: A, key: V): Claim<H, V, A>;
251
- declare function deallocateFromStore<H extends Hierarchy, V extends Vassal<H>, A extends Above<V, H>>(store: Store, claim: Claim<H, V, A>): void;
252
- declare function realm<H extends Hierarchy>(store: Store): {
253
- root: MoleculeToken<ObjectConstructor>;
254
- allocate: <V extends Vassal<H>, A extends Above<V, H>>(provenance: A, key: V) => Claim<H, V, A>;
255
- deallocate: <V extends Vassal<H>, A extends Above<V, H>>(claim: Claim<H, V, A>) => void;
256
- };
257
- declare const T$ = "T$";
258
- type T$ = typeof T$;
259
- type TypeTag<T extends string> = `${T$}--${T}`;
260
- type SingularTypedKey<T extends string = string> = `${T}::${string}`;
261
- type CompoundTypedKey<A extends string = string, B extends string = string, C extends string = string> = `${TypeTag<A>}==${SingularTypedKey<B>}++${SingularTypedKey<C>}`;
262
- type TypedKey<A extends string = string, B extends string = string, C extends string = string> = CompoundTypedKey<A, B, C> | SingularTypedKey<A>;
263
- type Scope = SingularTypedKey[];
264
- type MutualFealty = {
265
- above: Scope;
266
- below: CompoundTypedKey;
267
- style: `all` | `any`;
268
- };
269
- type ExclusiveFealty = {
270
- above: TypedKey | `root`;
271
- below: Scope;
233
+ type TimelineOptions<ManagedAtom extends TimelineManageable> = {
234
+ key: string;
235
+ scope: ManagedAtom[];
236
+ shouldCapture?: (update: TimelineUpdate<ManagedAtom>, timeline: Timeline<TimelineManageable>) => boolean;
272
237
  };
273
- type Fealty = ExclusiveFealty | MutualFealty;
274
- type Hierarchy<F extends Fealty[] = Fealty[]> = Each<F>;
275
- type Vassal<H extends Hierarchy> = {
276
- [K in keyof H]: H[K] extends MutualFealty ? H[K][`below`] : H[K] extends {
277
- below: Array<infer V>;
278
- } ? V extends TypedKey ? V : never : never;
279
- }[keyof H];
280
- type Above<TK extends TypedKey, H extends Hierarchy> = {
281
- [K in keyof H]: H[K] extends MutualFealty ? TK extends H[K][`below`] ? H[K][`above`] : never : H[K] extends {
282
- below: Array<infer V>;
283
- } ? TK extends V ? H[K] extends ExclusiveFealty ? H[K][`above`] : never : never : never;
284
- }[keyof H];
285
- type Below<TK extends TypedKey | TypedKey[], H extends Hierarchy> = {
286
- [K in keyof H]: H[K] extends MutualFealty ? TK extends H[K][`above`] ? H[K][`below`] : TK extends H[K][`above`][number] ? H[K][`below`] : never : H[K] extends {
287
- above: infer V;
288
- } ? TK extends V ? H[K] extends ExclusiveFealty ? H[K][`below`][number] : never : never : never;
289
- }[keyof H];
290
- type Mutuals<TK extends TypedKey | TypedKey[], H extends Hierarchy> = {
291
- [K in keyof H]: H[K] extends MutualFealty ? TK extends H[K][`above`][number] ? [mutual: Exclude<H[K][`above`][number], TK>, below: H[K][`below`]] : never : never;
292
- }[keyof H];
238
+ type TimelineUpdate<ManagedAtom extends TimelineManageable> = TimelineAtomUpdate<ManagedAtom> | TimelineMoleculeCreation | TimelineMoleculeDisposal | TimelineSelectorUpdate<ManagedAtom> | TimelineStateCreation<AtomOnly<ManagedAtom>> | TimelineStateDisposal<AtomOnly<ManagedAtom>> | TimelineTransactionUpdate;
239
+ declare const timeline: <ManagedAtom extends TimelineManageable>(options: TimelineOptions<ManagedAtom>) => TimelineToken<ManagedAtom>;
240
+ declare const redo: (tl: TimelineToken<any>) => void;
241
+ declare const undo: (tl: TimelineToken<any>) => void;
293
242
 
294
- declare function disposeState(token: MoleculeToken<any> | ReadableToken<any>): void;
243
+ /**
244
+ * @public
245
+ * Disposes of a state in the implicit store
246
+ * @param token - The token of the state to dispose
247
+ * @overload Default
248
+ */
249
+ declare function disposeState(token: ReadableToken<any>): void;
250
+ /**
251
+ * @public
252
+ * Disposes of a state family in the implicit store
253
+ * @param token - The token of the state family to dispose
254
+ * @param key - The unique key of the state to dispose
255
+ */
295
256
  declare function disposeState<K extends Canonical>(token: ReadableFamilyToken<any, K>, key: K): void;
296
- declare function disposeState<M extends MoleculeConstructor>(token: MoleculeFamilyToken<M>, key: MoleculeKey<M>): void;
297
257
 
258
+ /**
259
+ * @public
260
+ * Get the current value of a state
261
+ * @param token - The token of the state to get
262
+ * @return The current value of the state
263
+ * @overload Default
264
+ * @default
265
+ */
298
266
  declare function getState<T>(token: ReadableToken<T>): T;
299
- declare function getState<M extends MoleculeConstructor>(token: MoleculeToken<M>): InstanceType<M>;
267
+ /**
268
+ * @public
269
+ * Get the current value of a state family
270
+ * @param token - The token of a state family
271
+ * @param key - The unique key of the state to get
272
+ * @return The current value of the state
273
+ * @overload Streamlined
274
+ */
300
275
  declare function getState<T, K extends Canonical, Key extends K>(token: ReadableFamilyToken<T, K>, key: Key): T;
301
- declare function getState<M extends MoleculeConstructor>(token: MoleculeFamilyToken<M>, key: Canonical): InstanceType<M>;
302
276
 
303
277
  declare const LoggerIconDictionary: {
304
278
  readonly "\u231B": "Timeline event fully captured";
@@ -370,24 +344,91 @@ declare class AtomIOLogger implements Logger {
370
344
  warn: LogFn;
371
345
  }
372
346
 
347
+ declare const $claim: unique symbol;
348
+ type Claim<K extends Canonical> = K & {
349
+ [$claim]?: true;
350
+ };
351
+ declare class Realm<H extends Hierarchy> {
352
+ store: Store;
353
+ constructor(store?: Store);
354
+ allocate<V extends Vassal<H>, A extends Above<V, H>>(provenance: A, key: V, attachmentStyle?: `all` | `any`): Claim<V>;
355
+ fuse<C extends CompoundFrom<H>, T extends C extends CompoundTypedKey<infer t, any, any> ? t : never, A extends C extends CompoundTypedKey<any, infer v, any> ? v : never, B extends C extends CompoundTypedKey<any, any, infer m> ? m : never>(type: T, reagentA: SingularTypedKey<A>, reagentB: SingularTypedKey<B>): Claim<CompoundTypedKey<T, A, B>>;
356
+ deallocate<V extends Vassal<H>>(claim: Claim<V>): void;
357
+ claim<V extends Exclude<Vassal<H>, CompoundTypedKey>, A extends Above<V, H>>(newProvenance: A, claim: Claim<V>, exclusive?: `exclusive`): Claim<V>;
358
+ }
359
+ declare class Anarchy {
360
+ store: Store;
361
+ realm: Realm<any>;
362
+ constructor(store?: Store);
363
+ allocate(provenance: Canonical, key: Canonical, attachmentStyle?: `all` | `any`): void;
364
+ deallocate(key: Canonical): void;
365
+ claim(newProvenance: Canonical, key: Canonical, exclusive?: `exclusive`): void;
366
+ }
367
+ declare const T$ = "T$";
368
+ type T$ = typeof T$;
369
+ type TypeTag<T extends string> = `${T$}--${T}`;
370
+ type SingularTypedKey<T extends string = string> = `${T}::${string}`;
371
+ type CompoundTypedKey<A extends string = string, B extends string = string, C extends string = string> = `${TypeTag<A>}==${SingularTypedKey<B>}++${SingularTypedKey<C>}`;
372
+ type TypedKey<A extends string = string, B extends string = string, C extends string = string> = CompoundTypedKey<A, B, C> | SingularTypedKey<A>;
373
+ type Scope = SingularTypedKey[];
374
+ type MutualFealty = {
375
+ above: Scope;
376
+ below: CompoundTypedKey;
377
+ };
378
+ type ExclusiveFealty = {
379
+ above: TypedKey | `root`;
380
+ below: Scope;
381
+ };
382
+ type Fealty = ExclusiveFealty | MutualFealty;
383
+ type Hierarchy<F extends Fealty[] = Fealty[]> = Each<F>;
384
+ type Vassal<H extends Hierarchy> = {
385
+ [K in keyof H]: H[K] extends MutualFealty ? H[K][`below`] : H[K] extends {
386
+ below: Array<infer V>;
387
+ } ? V extends TypedKey ? V : never : never;
388
+ }[keyof H];
389
+ type Above<TK extends TypedKey, H extends Hierarchy> = {
390
+ [K in keyof H]: H[K] extends MutualFealty ? TK extends H[K][`below`] ? H[K][`above`] : never : H[K] extends {
391
+ below: Array<infer V>;
392
+ } ? TK extends V ? H[K] extends ExclusiveFealty ? H[K][`above`] : never : never : never;
393
+ }[keyof H];
394
+ type Below<TK extends TypedKey | TypedKey[], H extends Hierarchy> = {
395
+ [K in keyof H]: H[K] extends MutualFealty ? TK extends H[K][`above`] ? H[K][`below`] : TK extends H[K][`above`][number] ? H[K][`below`] : never : H[K] extends {
396
+ above: infer V;
397
+ } ? TK extends V ? H[K] extends ExclusiveFealty ? H[K][`below`][number] : never : never : never;
398
+ }[keyof H];
399
+ type Mutuals<TK extends TypedKey | TypedKey[], H extends Hierarchy> = {
400
+ [K in keyof H]: H[K] extends MutualFealty ? TK extends H[K][`above`][number] ? [mutual: Exclude<H[K][`above`][number], TK>, below: H[K][`below`]] : never : never;
401
+ }[keyof H];
402
+ type CompoundFrom<H extends Hierarchy> = {
403
+ [K in keyof H]: H[K] extends MutualFealty ? H[K][`below`] : never;
404
+ }[keyof H];
405
+
406
+ /**
407
+ * @public
408
+ * A function that sets the value of a state.
409
+ * @param oldValue - The current value of the state.
410
+ * @returns
411
+ * The new value of the state.
412
+ */
413
+ type Setter<T, New extends T> = (oldValue: T) => New;
373
414
  /**
374
415
  * @public
375
416
  * Set the value of a state into the implicit store.
376
- * @param token - The unique identifier of the state to set.
417
+ * @param token - An atom or writable selector token.
377
418
  * @param value - The new value of the state.
378
419
  * @overload Default
379
420
  * @default
380
421
  */
381
- declare function setState<T, New extends T>(token: WritableToken<T>, value: New | ((oldValue: T) => New)): void;
422
+ declare function setState<T, New extends T>(token: WritableToken<T>, value: New | Setter<T, New>): void;
382
423
  /**
383
424
  * @public
384
425
  * Set the value of a state into the implicit store.
385
- * @param token - The unique identifier of a state family.
386
- * @param key - The key of the state to set.
426
+ * @param token - An atom family or writable selector family token.
427
+ * @param key - The unique key of the state to set.
387
428
  * @param value - The new value of the state.
388
429
  * @overload Streamlined
389
430
  */
390
- declare function setState<T, K extends Canonical, New extends T, Key extends K>(token: WritableFamilyToken<T, K>, key: Key, value: New | ((oldValue: T) => New)): void;
431
+ declare function setState<T, K extends Canonical, New extends T, Key extends K>(token: WritableFamilyToken<T, K>, key: Key, value: New | Setter<T, New>): void;
391
432
 
392
433
  declare class Silo {
393
434
  store: Store;
@@ -404,9 +445,8 @@ declare class Silo {
404
445
  subscribe: typeof subscribe;
405
446
  undo: typeof undo;
406
447
  redo: typeof redo;
407
- moleculeFamily: typeof moleculeFamily;
408
- makeMolecule: typeof makeMolecule;
409
448
  runTransaction: typeof runTransaction;
449
+ install: (tokens: AtomIOToken[], store?: Store) => void;
410
450
  constructor(config: Store[`config`], fromStore?: Store | null);
411
451
  }
412
452
 
@@ -425,23 +465,6 @@ declare function subscribe<T>(token: ReadableToken<T>, handleUpdate: UpdateHandl
425
465
  declare function subscribe<F extends Func>(token: TransactionToken<F>, handleUpdate: TransactionUpdateHandler<F>, key?: string): () => void;
426
466
  declare function subscribe<M extends TimelineManageable>(token: TimelineToken<M>, handleUpdate: (update: TimelineUpdate<M> | `redo` | `undo`) => void, key?: string): () => void;
427
467
 
428
- type TimelineManageable = AtomFamilyToken<any, any> | AtomToken<any>;
429
- type AtomOnly<M extends TimelineManageable> = M extends AtomFamilyToken<any, any> ? AtomToken<any> : M extends AtomToken<any> ? M : never;
430
- type TimelineToken<M> = {
431
- key: string;
432
- type: `timeline`;
433
- __M?: M;
434
- };
435
- type TimelineOptions<ManagedAtom extends TimelineManageable> = {
436
- key: string;
437
- scope: (ManagedAtom | MoleculeFamilyToken$1<any>)[];
438
- shouldCapture?: (update: TimelineUpdate<ManagedAtom>, timeline: Timeline<TimelineManageable>) => boolean;
439
- };
440
- type TimelineUpdate<ManagedAtom extends TimelineManageable> = TimelineAtomUpdate<ManagedAtom> | TimelineMoleculeCreation<any> | TimelineMoleculeDisposal | TimelineSelectorUpdate<ManagedAtom> | TimelineStateCreation<AtomOnly<ManagedAtom>> | TimelineStateDisposal<AtomOnly<ManagedAtom>> | TimelineTransactionUpdate;
441
- declare const timeline: <ManagedAtom extends TimelineManageable>(options: TimelineOptions<ManagedAtom>) => TimelineToken<ManagedAtom>;
442
- declare const redo: (tl: TimelineToken<any>) => void;
443
- declare const undo: (tl: TimelineToken<any>) => void;
444
-
445
468
  type TokenType<Comparison extends ReadableFamilyToken$1<any, any> | ReadableToken$1<any>> = Comparison extends ReadableToken$1<infer RepresentedValue> ? RepresentedValue : Comparison extends ReadableFamilyToken$1<infer RepresentedValue, any> ? RepresentedValue : never;
446
469
  declare function isToken<KnownToken extends RegularAtomToken$1<any>>(knownToken: KnownToken, unknownToken: ReadableToken$1<any>): unknownToken is RegularAtomToken$1<TokenType<KnownToken>>;
447
470
  declare function isToken<KnownToken extends MutableAtomToken$1<any, any>>(knownToken: KnownToken, unknownToken: ReadableToken$1<any>): unknownToken is MutableAtomToken$1<TokenType<KnownToken>, any>;
@@ -456,40 +479,98 @@ declare function belongsTo<Family extends ReadonlySelectorFamilyToken$1<any, any
456
479
  declare function belongsTo<Family extends WritableFamilyToken$1<any, any>>(family: Family, unknownToken: ReadableToken$1<any>): unknownToken is WritableToken$1<TokenType<Family>>;
457
480
  declare function belongsTo<Family extends ReadableFamilyToken$1<any, any>>(family: Family, unknownToken: ReadableToken$1<any>): unknownToken is ReadableToken$1<TokenType<Family>>;
458
481
 
482
+ /**
483
+ * @public
484
+ * A token is an object that uniquely identifies a particular state, family, timeline, or transaction.
485
+ *
486
+ * While they represent one of these resources, they are not the resource itself. Think of them like paper currency representing money in the bank.
487
+ *
488
+ * Tokens are returned from resource creation functions, such as {@link atom} and {@link transaction}.
489
+ *
490
+ * Tokens can be used as parameters to functions that take a token, such as {@link getState}, {@link setState}, or {@link runTransaction}.
491
+ *
492
+ * Tokens are fully serializable, so they can be passed between processes.
493
+ */
494
+ type AtomIOToken = ReadableFamilyToken<any, any> | ReadableToken<any> | TimelineToken<any> | TransactionToken<any>;
495
+ /** @public */
459
496
  type RegularAtomToken<T, K extends Canonical = any> = {
497
+ /** The unique identifier of the atom. */
460
498
  key: string;
499
+ /** Discriminator. */
461
500
  type: `atom`;
501
+ /** Present if the atom belongs to a family. */
462
502
  family?: FamilyMetadata<K>;
503
+ /** Never present. This is a marker that preserves the type of the atom's value. */
463
504
  __T?: T;
464
505
  };
506
+ /** @public */
465
507
  type MutableAtomToken<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical = any> = {
508
+ /** The unique identifier of the atom. */
466
509
  key: string;
510
+ /** Discriminator. */
467
511
  type: `mutable_atom`;
512
+ /** Present if the atom belongs to a family. */
468
513
  family?: FamilyMetadata<K>;
514
+ /** Never present. This is a marker that preserves the JSON form of the atom's transceiver value. */
469
515
  __J?: J;
516
+ /** Never present. This is a marker that preserves the type of the atom's transceiver value. */
470
517
  __U?: T extends Transceiver<infer Update> ? Update : never;
471
518
  };
519
+ /** @public */
472
520
  type AtomToken<T, K extends Canonical = any> = MutableAtomToken<T extends Transceiver<any> ? T : never, any, K> | RegularAtomToken<T, K>;
521
+ /** @public */
473
522
  type WritableSelectorToken<T, K extends Canonical = any> = {
523
+ /** The unique identifier of the selector. */
474
524
  key: string;
525
+ /** Discriminator. */
475
526
  type: `selector`;
527
+ /** Present if the selector belongs to a family. */
476
528
  family?: FamilyMetadata<K>;
529
+ /** Never present. This is a marker that preserves the type of the selector's value. */
477
530
  __T?: T;
478
531
  };
532
+ /** @public */
479
533
  type ReadonlySelectorToken<T, K extends Canonical = any> = {
534
+ /** The unique identifier of the selector. */
480
535
  key: string;
536
+ /** Discriminator. */
481
537
  type: `readonly_selector`;
538
+ /** Present if the selector belongs to a family. */
482
539
  family?: FamilyMetadata<K>;
540
+ /** Never present. This is a marker that preserves the type of the selector's value. */
483
541
  __T?: T;
484
542
  };
543
+ /** @public */
485
544
  type SelectorToken<T, K extends Canonical = any> = ReadonlySelectorToken<T, K> | WritableSelectorToken<T, K>;
545
+ /**
546
+ * @public
547
+ * These states can be set.
548
+ */
486
549
  type WritableToken<T, K extends Canonical = any> = AtomToken<T, K> | WritableSelectorToken<T, K>;
550
+ /**
551
+ * @public
552
+ * These states cannot be set.
553
+ */
487
554
  type ReadableToken<T, K extends Canonical = any> = AtomToken<T, K> | SelectorToken<T, K>;
555
+ /**
556
+ * @public
557
+ * States belonging to this family can be set.
558
+ */
488
559
  type WritableFamilyToken<T, K extends Canonical> = AtomFamilyToken<T, K> | WritableSelectorFamilyToken<T, K>;
560
+ /**
561
+ * @public
562
+ * States belonging to this family cannot be set.
563
+ */
489
564
  type ReadableFamilyToken<T, K extends Canonical> = AtomFamilyToken<T, K> | SelectorFamilyToken<T, K>;
565
+ /**
566
+ * @public
567
+ * Identifies a state's connection to its family.
568
+ */
490
569
  type FamilyMetadata<K extends Canonical = any> = {
570
+ /** The family's unique key. */
491
571
  key: string;
572
+ /** The family member's unique identifier, in the form of a string. */
492
573
  subKey: stringified<K>;
493
574
  };
494
575
 
495
- export { $provenance, type Above, type ActorToolkit, type AtomEffect, type AtomFamilyToken, AtomIOLogger, type AtomOnly, type AtomToken, type Below, type Claim, type CompoundTypedKey, type CtorToolkit, type Effectors, type FamilyMetadata, type GetterToolkit, type Hierarchy, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MoleculeConstructor, type MoleculeCreation, type MoleculeCreationClassic, type MoleculeCreationModern, type MoleculeDisposal, type MoleculeDisposalClassic, type MoleculeDisposalModern, type MoleculeFamily, type MoleculeFamilyOptions, type MoleculeFamilyToken, type MoleculeKey, type MoleculeParams, type MoleculeToken, type MoleculeType, type MutableAtomFamilyOptions, type MutableAtomFamilyToken, type MutableAtomOptions, type MutableAtomToken, type Mutuals, type Read, type ReadableFamilyToken, type ReadableToken, type ReadonlySelectorFamilyOptions, type ReadonlySelectorFamilyToken, type ReadonlySelectorOptions, type ReadonlySelectorToken, type RegularAtomFamilyOptions, type RegularAtomFamilyToken, type RegularAtomOptions, type RegularAtomToken, type SelectorFamilyToken, type SelectorToken, type SetterToolkit, Silo, type SingularTypedKey, type StateCreation, type StateDisposal, type StateUpdate, T$, 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 TypeTag, type TypedKey, type UpdateHandler, type Vassal, type WritableFamilyToken, type WritableSelectorFamilyOptions, type WritableSelectorFamilyToken, type WritableSelectorOptions, type WritableSelectorToken, type WritableToken, type Write, allocateIntoStore, atom, atomFamily, belongsTo, deallocateFromStore, disposeState, getState, isToken, makeMolecule, makeRootMoleculeInStore, moleculeFamily, realm, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
576
+ export { $claim, type Above, type ActorToolkit, Anarchy, type AtomDisposal, type AtomEffect, type AtomFamilyToken, AtomIOLogger, type AtomIOToken, type AtomOnly, type AtomToken, type Below, type Claim, type CompoundFrom, type CompoundTypedKey, type Effectors, type FamilyMetadata, type GetterToolkit, type Hierarchy, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MoleculeCreation, type MoleculeDisposal, type MoleculeTransfer, type MutableAtomFamilyOptions, type MutableAtomFamilyToken, type MutableAtomOptions, type MutableAtomToken, type Mutuals, type Read, type ReadableFamilyToken, type ReadableToken, type ReadonlySelectorFamilyOptions, type ReadonlySelectorFamilyToken, type ReadonlySelectorOptions, type ReadonlySelectorToken, Realm, type RegularAtomFamilyOptions, type RegularAtomFamilyToken, type RegularAtomOptions, type RegularAtomToken, type SelectorDisposal, type SelectorFamilyToken, type SelectorToken, type Setter, type SetterToolkit, Silo, type SingularTypedKey, type StateCreation, type StateDisposal, type StateUpdate, T$, 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 TypeTag, type TypedKey, type UpdateHandler, type Vassal, type WritableFamilyToken, type WritableSelectorFamilyOptions, type WritableSelectorFamilyToken, type WritableSelectorOptions, type WritableSelectorToken, type WritableToken, type Write, atom, atomFamily, belongsTo, disposeState, getState, isToken, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };