atom.io 0.31.1 → 0.32.0

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 (155) hide show
  1. package/data/dist/index.d.ts +867 -101
  2. package/data/dist/index.js +10 -558
  3. package/data/src/index.ts +0 -2
  4. package/data/src/struct-family.ts +1 -1
  5. package/data/src/struct.ts +1 -2
  6. package/dist/chunk-354XQWHH.js +153 -0
  7. package/dist/chunk-4LWKCEW3.js +14 -0
  8. package/dist/chunk-5F2V7S3B.js +83 -0
  9. package/dist/chunk-ECOMOMUN.js +631 -0
  10. package/dist/{chunk-Y5MBNTVU.js → chunk-GY2XQYZY.js} +1791 -703
  11. package/dist/chunk-NF7FJKJD.js +107 -0
  12. package/dist/chunk-R3ZUK5EH.js +1024 -0
  13. package/dist/chunk-Z2UJW4NQ.js +523 -0
  14. package/dist/index.d.ts +622 -26
  15. package/dist/index.js +1 -228
  16. package/eslint-plugin/dist/index.d.ts +1 -30
  17. package/eslint-plugin/dist/index.js +0 -146
  18. package/eslint-plugin/src/index.ts +0 -1
  19. package/eslint-plugin/src/rules/index.ts +0 -1
  20. package/internal/dist/index.d.ts +783 -64
  21. package/internal/dist/index.js +1 -1
  22. package/internal/src/atom/create-regular-atom.ts +3 -3
  23. package/internal/src/atom/dispose-atom.ts +4 -13
  24. package/internal/src/atom/is-default.ts +3 -3
  25. package/internal/src/caching.ts +5 -5
  26. package/internal/src/capitalize.ts +3 -0
  27. package/internal/src/families/create-readonly-selector-family.ts +5 -6
  28. package/internal/src/families/create-writable-selector-family.ts +1 -4
  29. package/internal/src/families/dispose-from-store.ts +3 -13
  30. package/internal/src/get-state/get-from-store.ts +2 -2
  31. package/internal/src/get-state/read-or-compute-value.ts +1 -1
  32. package/internal/src/index.ts +2 -0
  33. package/internal/src/install-into-store.ts +1 -1
  34. package/internal/src/join/edit-relations-in-store.ts +32 -0
  35. package/internal/src/join/find-relations-in-store.ts +124 -0
  36. package/internal/src/join/get-internal-relations-from-store.ts +14 -0
  37. package/internal/src/join/get-join.ts +31 -0
  38. package/internal/src/join/index.ts +5 -0
  39. package/{data/src/join.ts → internal/src/join/join-internal.ts} +20 -429
  40. package/internal/src/keys.ts +7 -7
  41. package/internal/src/mutable/create-mutable-atom-family.ts +1 -1
  42. package/internal/src/mutable/create-mutable-atom.ts +3 -3
  43. package/internal/src/mutable/get-json-token.ts +1 -1
  44. package/internal/src/mutable/tracker-family.ts +19 -17
  45. package/internal/src/mutable/tracker.ts +8 -8
  46. package/internal/src/pretty-print.ts +1 -1
  47. package/internal/src/selector/create-readonly-selector.ts +3 -7
  48. package/internal/src/selector/create-writable-selector.ts +4 -4
  49. package/internal/src/selector/dispose-selector.ts +20 -11
  50. package/internal/src/selector/get-selector-dependency-keys.ts +1 -1
  51. package/internal/src/selector/register-selector.ts +6 -9
  52. package/internal/src/selector/trace-selector-atoms.ts +2 -2
  53. package/internal/src/set-state/copy-mutable-if-needed.ts +1 -1
  54. package/internal/src/set-state/emit-update.ts +1 -1
  55. package/internal/src/set-state/evict-downstream.ts +1 -1
  56. package/internal/src/set-state/set-atom-or-selector.ts +1 -1
  57. package/internal/src/set-state/set-atom.ts +10 -10
  58. package/internal/src/set-state/set-into-store.ts +2 -2
  59. package/internal/src/set-state/stow-update.ts +1 -1
  60. package/internal/src/store/store.ts +1 -1
  61. package/internal/src/store/withdraw.ts +22 -22
  62. package/internal/src/subscribe/recall-state.ts +1 -1
  63. package/internal/src/subscribe/subscribe-in-store.ts +3 -3
  64. package/internal/src/subscribe/subscribe-to-root-atoms.ts +3 -3
  65. package/internal/src/subscribe/subscribe-to-state.ts +5 -5
  66. package/internal/src/subscribe/subscribe-to-timeline.ts +3 -3
  67. package/internal/src/subscribe/subscribe-to-transaction.ts +3 -3
  68. package/internal/src/timeline/create-timeline.ts +17 -37
  69. package/internal/src/transaction/act-upon-store.ts +2 -2
  70. package/internal/src/transaction/apply-transaction.ts +5 -5
  71. package/internal/src/transaction/assign-transaction-to-continuity.ts +1 -1
  72. package/internal/src/transaction/build-transaction.ts +5 -8
  73. package/internal/src/transaction/create-transaction.ts +3 -3
  74. package/internal/src/transaction/get-epoch-number.ts +3 -3
  75. package/internal/src/transaction/set-epoch-number.ts +2 -2
  76. package/introspection/dist/index.d.ts +922 -6
  77. package/introspection/dist/index.js +2 -620
  78. package/json/dist/index.d.ts +899 -5
  79. package/json/dist/index.js +1 -80
  80. package/json/src/select-json-family.ts +3 -14
  81. package/package.json +24 -42
  82. package/react/dist/index.d.ts +921 -3
  83. package/react/dist/index.js +2 -82
  84. package/react/src/use-o.ts +1 -1
  85. package/react/src/use-tl.ts +2 -2
  86. package/react-devtools/dist/index.css +16 -14
  87. package/react-devtools/dist/index.d.ts +26 -1
  88. package/react-devtools/dist/index.js +6 -6
  89. package/react-devtools/src/devtools.scss +16 -14
  90. package/realtime/dist/index.d.ts +202 -8
  91. package/realtime/dist/index.js +2 -107
  92. package/realtime/src/realtime-continuity.ts +2 -2
  93. package/realtime/src/shared-room-store.ts +1 -2
  94. package/realtime-client/dist/index.d.ts +960 -22
  95. package/realtime-client/dist/index.js +3 -509
  96. package/realtime-client/src/continuity/register-and-attempt-confirmed-update.ts +3 -3
  97. package/realtime-client/src/continuity/use-conceal-state.ts +1 -1
  98. package/realtime-client/src/pull-atom-family-member.ts +2 -2
  99. package/realtime-client/src/pull-atom.ts +2 -2
  100. package/realtime-client/src/pull-mutable-atom-family-member.ts +2 -2
  101. package/realtime-client/src/pull-mutable-atom.ts +2 -2
  102. package/realtime-client/src/pull-selector-family-member.ts +4 -4
  103. package/realtime-client/src/pull-selector.ts +4 -4
  104. package/realtime-client/src/push-state.ts +5 -10
  105. package/realtime-client/src/server-action.ts +4 -4
  106. package/realtime-client/src/sync-continuity.ts +6 -6
  107. package/realtime-react/dist/index.d.ts +166 -12
  108. package/realtime-react/dist/index.js +5 -154
  109. package/realtime-react/src/use-pull-atom-family-member.ts +1 -1
  110. package/realtime-react/src/use-pull-atom.ts +1 -1
  111. package/realtime-react/src/use-pull-mutable-atom.ts +1 -1
  112. package/realtime-react/src/use-pull-mutable-family-member.ts +1 -1
  113. package/realtime-react/src/use-pull-selector-family-member.ts +1 -1
  114. package/realtime-react/src/use-pull-selector.ts +1 -1
  115. package/realtime-react/src/use-push.ts +1 -1
  116. package/realtime-react/src/use-server-action.ts +2 -2
  117. package/realtime-react/src/use-sync-continuity.ts +1 -1
  118. package/realtime-server/dist/index.d.ts +971 -28
  119. package/realtime-server/dist/index.js +3 -1001
  120. package/realtime-server/src/continuity/prepare-to-serve-transaction-request.ts +1 -1
  121. package/realtime-server/src/continuity/prepare-to-sync-realtime-continuity.ts +3 -3
  122. package/realtime-server/src/continuity/subscribe-to-continuity-actions.ts +2 -2
  123. package/realtime-server/src/continuity/subscribe-to-continuity-perpectives.ts +2 -2
  124. package/realtime-server/src/realtime-action-receiver.ts +1 -1
  125. package/realtime-server/src/realtime-family-provider.ts +2 -2
  126. package/realtime-server/src/realtime-mutable-family-provider.ts +2 -2
  127. package/realtime-server/src/realtime-mutable-provider.ts +2 -2
  128. package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +2 -1
  129. package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +1 -1
  130. package/realtime-server/src/realtime-server-stores/server-user-store.ts +1 -2
  131. package/realtime-server/src/realtime-state-provider.ts +2 -2
  132. package/realtime-testing/dist/index.d.ts +1091 -3
  133. package/realtime-testing/dist/index.js +20 -22
  134. package/realtime-testing/src/setup-realtime-test.tsx +2 -1
  135. package/src/index.ts +4 -0
  136. package/src/join.ts +218 -0
  137. package/src/silo.ts +4 -4
  138. package/src/timeline.ts +1 -1
  139. package/src/transaction.ts +4 -8
  140. package/transceivers/set-rtx/dist/index.d.ts +37 -2
  141. package/transceivers/set-rtx/dist/index.js +1 -215
  142. package/web/dist/index.d.ts +30 -1
  143. package/web/dist/index.js +1 -15
  144. package/data/src/until.ts +0 -15
  145. package/ephemeral/dist/index.d.ts +0 -67
  146. package/ephemeral/dist/index.js +0 -9
  147. package/ephemeral/package.json +0 -13
  148. package/ephemeral/src/index.ts +0 -1
  149. package/eslint-plugin/src/rules/lifespan.ts +0 -203
  150. package/immortal/dist/index.d.ts +0 -12
  151. package/immortal/dist/index.js +0 -9
  152. package/immortal/package.json +0 -13
  153. package/immortal/src/index.ts +0 -1
  154. package/immortal/src/seek-state.ts +0 -60
  155. /package/{ephemeral/src → src}/find-state.ts +0 -0
@@ -1,12 +1,955 @@
1
- import { Subject, Transceiver, Store } from 'atom.io/internal';
2
- import { Json, stringified, JsonIO, Canonical } from 'atom.io/json';
3
- import { ContinuityToken, UserInRoomMeta } from 'atom.io/realtime';
4
1
  import { ChildProcessWithoutNullStreams } from 'node:child_process';
5
- import * as AtomIO from 'atom.io';
6
- import { TransactionUpdateContent, TransactionUpdate, Hierarchy, WritableToken } from 'atom.io';
7
- import * as atom_io_data from 'atom.io/data';
8
- import { Loadable } from 'atom.io/data';
9
- import { SetRTX, SetRTXJson } from 'atom.io/transceivers/set-rtx';
2
+
3
+ type primitive = boolean | number | string | null;
4
+ declare namespace Json {
5
+ namespace Tree {
6
+ type Array<Element = unknown> = ReadonlyArray<Element>;
7
+ type Object<K extends string = string, V = unknown> = Record<K, V>;
8
+ type Fork = Array | Object;
9
+ type Leaf = primitive;
10
+ type Node = Fork | Leaf;
11
+ }
12
+ type Serializable = primitive | Readonly<{
13
+ [key: string]: Serializable;
14
+ }> | ReadonlyArray<Serializable>;
15
+ type Object<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
16
+ type Array<Element extends Serializable = Serializable> = ReadonlyArray<Element>;
17
+ }
18
+ type stringified<J extends Json.Serializable> = J extends string ? `"${J}"` : J extends number ? `${J}` : J extends true ? `true` : J extends false ? `false` : J extends boolean ? `false` | `true` : J extends null ? `null` : string & {
19
+ __json?: J;
20
+ };
21
+ type Canonical = primitive | ReadonlyArray<Canonical>;
22
+ type JsonIO = (...params: Json.Serializable[]) => Json.Serializable | void;
23
+ type JsonInterface<T, J extends Json.Serializable = Json.Serializable> = {
24
+ toJson: (t: T) => J;
25
+ fromJson: (json: J) => T;
26
+ };
27
+
28
+ type RegularAtomFamilyToken<T, K extends Canonical> = {
29
+ key: string;
30
+ type: `atom_family`;
31
+ __T?: T;
32
+ __K?: K;
33
+ };
34
+ type MutableAtomFamilyToken<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical> = {
35
+ key: string;
36
+ type: `mutable_atom_family`;
37
+ __T?: T;
38
+ __J?: J;
39
+ __K?: K;
40
+ };
41
+ type AtomFamilyToken<T, K extends Canonical = Canonical> = MutableAtomFamilyToken<T extends Transceiver<any> ? T : never, any, K> | RegularAtomFamilyToken<T, K>;
42
+
43
+ type TransactionToken<F extends Func> = {
44
+ key: string;
45
+ type: `transaction`;
46
+ __F?: F;
47
+ };
48
+ type StateCreation<Token extends ReadableToken<any>> = {
49
+ type: `state_creation`;
50
+ token: Token;
51
+ };
52
+ type AtomDisposal<Token extends ReadableToken<any>> = {
53
+ type: `state_disposal`;
54
+ subType: `atom`;
55
+ token: Token;
56
+ value: TokenType<Token>;
57
+ };
58
+ type SelectorDisposal<Token extends ReadableToken<any>> = {
59
+ type: `state_disposal`;
60
+ subType: `selector`;
61
+ token: Token;
62
+ };
63
+ type StateDisposal<Token extends ReadableToken<any>> = AtomDisposal<Token> | SelectorDisposal<Token>;
64
+ type MoleculeCreation = {
65
+ type: `molecule_creation`;
66
+ key: Canonical;
67
+ provenance: Canonical;
68
+ };
69
+ type MoleculeDisposal = {
70
+ type: `molecule_disposal`;
71
+ key: Canonical;
72
+ provenance: stringified<Canonical>[];
73
+ values: [key: string, value: any][];
74
+ };
75
+ type MoleculeTransfer = {
76
+ type: `molecule_transfer`;
77
+ key: Canonical;
78
+ from: Canonical[];
79
+ to: Canonical[];
80
+ };
81
+ type TransactionUpdateContent = KeyedStateUpdate<unknown> | MoleculeCreation | MoleculeDisposal | MoleculeTransfer | StateCreation<ReadableToken<unknown>> | StateDisposal<ReadableToken<unknown>> | TransactionUpdate<Func>;
82
+ type TransactionUpdate<F extends Func> = {
83
+ type: `transaction_update`;
84
+ key: string;
85
+ id: string;
86
+ epoch: number;
87
+ updates: TransactionUpdateContent[];
88
+ params: Parameters<F>;
89
+ output: ReturnType<F>;
90
+ };
91
+ type SetterToolkit = Readonly<{
92
+ get: typeof getState;
93
+ set: typeof setState;
94
+ find: typeof findState;
95
+ json: <T extends Transceiver<any>, J extends Json.Serializable>(state: MutableAtomToken<T, J>) => WritableSelectorToken<J>;
96
+ }>;
97
+ type ActorToolkit = Readonly<{
98
+ get: typeof getState;
99
+ set: typeof setState;
100
+ find: typeof findState;
101
+ json: <T extends Transceiver<any>, J extends Json.Serializable>(state: MutableAtomToken<T, J>) => WritableSelectorToken<J>;
102
+ dispose: typeof disposeState;
103
+ run: typeof runTransaction;
104
+ env: () => EnvironmentData;
105
+ }>;
106
+ type TransactionIO<Token extends TransactionToken<any>> = Token extends TransactionToken<infer F> ? F : never;
107
+ declare function runTransaction<F extends Func>(token: TransactionToken<F>, id?: string): (...parameters: Parameters<F>) => ReturnType<F>;
108
+
109
+ type WritableSelectorFamilyToken<T, K extends Canonical> = {
110
+ key: string;
111
+ type: `selector_family`;
112
+ __T?: T;
113
+ __K?: K;
114
+ };
115
+ type ReadonlySelectorFamilyToken<T, K extends Canonical> = {
116
+ key: string;
117
+ type: `readonly_selector_family`;
118
+ __T?: T;
119
+ __K?: K;
120
+ };
121
+ type SelectorFamilyToken<T, K extends Canonical> = ReadonlySelectorFamilyToken<T, K> | WritableSelectorFamilyToken<T, K>;
122
+
123
+ type TimelineManageable = AtomFamilyToken<any, any> | AtomToken<any>;
124
+ type AtomOnly<M extends TimelineManageable> = M extends AtomFamilyToken<any, any> ? AtomToken<any> : M extends AtomToken<any> ? M : never;
125
+ type TimelineToken<M> = {
126
+ key: string;
127
+ type: `timeline`;
128
+ __M?: M;
129
+ };
130
+ type TimelineUpdate<ManagedAtom extends TimelineManageable> = TimelineAtomUpdate<ManagedAtom> | TimelineMoleculeCreation | TimelineMoleculeDisposal | TimelineSelectorUpdate<ManagedAtom> | TimelineStateCreation<AtomOnly<ManagedAtom>> | TimelineStateDisposal<AtomOnly<ManagedAtom>> | TimelineTransactionUpdate;
131
+
132
+ /**
133
+ * @public
134
+ * Disposes of a state in the implicit store
135
+ * @param token - The token of the state to dispose
136
+ * @overload Default
137
+ */
138
+ declare function disposeState(token: ReadableToken<any>): void;
139
+ /**
140
+ * @public
141
+ * Disposes of a state family in the implicit store
142
+ * @param token - The token of the state family to dispose
143
+ * @param key - The unique key of the state to dispose
144
+ */
145
+ declare function disposeState<K extends Canonical>(token: ReadableFamilyToken<any, K>, key: K): void;
146
+
147
+ /**
148
+ * @public
149
+ * Finds a {@link MutableAtomToken} in the store
150
+ * @param token - A {@link MutableAtomFamilyToken}
151
+ * @param key - The key of the state
152
+ * @returns
153
+ * The current value of the state
154
+ * @overload Mutable Atom
155
+ */
156
+ declare function findState<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical, Key extends K>(token: MutableAtomFamilyToken<T, J, K>, key: Key): MutableAtomToken<T, J, K>;
157
+ /**
158
+ * @public
159
+ * Finds a state in the store
160
+ * @param token - The token of the state family
161
+ * @param key - The key of the state
162
+ * @returns
163
+ * The current value of the state
164
+ * @overload Regular Atom
165
+ */
166
+ declare function findState<T, K extends Canonical, Key extends K>(token: RegularAtomFamilyToken<T, K>, key: Key): RegularAtomToken<T, K>;
167
+ /**
168
+ * @public
169
+ * Finds a state in the store
170
+ * @param token - The token of the state family
171
+ * @param key - The key of the state
172
+ * @returns
173
+ * The current value of the state
174
+ * @overload Writable Selector
175
+ */
176
+ declare function findState<T, K extends Canonical, Key extends K>(token: WritableSelectorFamilyToken<T, K>, key: Key): WritableSelectorToken<T, K>;
177
+ /**
178
+ * @public
179
+ * Finds a state in the store
180
+ * @param token - The token of the state family
181
+ * @param key - The key of the state
182
+ * @returns
183
+ * The current value of the state
184
+ * @overload Readonly Selector
185
+ */
186
+ declare function findState<T, K extends Canonical, Key extends K>(token: ReadonlySelectorFamilyToken<T, K>, key: Key): ReadonlySelectorToken<T, K>;
187
+ /**
188
+ * @public
189
+ * Finds a state in the store
190
+ * @param token - The token of the state family
191
+ * @param key - The key of the state
192
+ * @returns
193
+ * The current value of the state
194
+ * @overload Writable State
195
+ */
196
+ declare function findState<T, K extends Canonical, Key extends K>(token: WritableFamilyToken<T, K>, key: Key): WritableToken<T, K>;
197
+ /**
198
+ * @public
199
+ * Finds a {@link ReadableToken} in the store
200
+ * @param token - A {@link ReadableFamilyToken}
201
+ * @param key - The key of the state
202
+ * @returns
203
+ * The current value of the state
204
+ * @overload Unknown
205
+ * @default
206
+ */
207
+ declare function findState<T, K extends Canonical, Key extends K>(token: ReadableFamilyToken<T, K>, key: Key): ReadableToken<T, K>;
208
+
209
+ /**
210
+ * @public
211
+ * Get the current value of a state
212
+ * @param token - The token of the state to get
213
+ * @return The current value of the state
214
+ * @overload Default
215
+ * @default
216
+ */
217
+ declare function getState<T>(token: ReadableToken<T>): T;
218
+ /**
219
+ * @public
220
+ * Get the current value of a state family
221
+ * @param token - The token of a state family
222
+ * @param key - The unique key of the state to get
223
+ * @return The current value of the state
224
+ * @overload Streamlined
225
+ */
226
+ declare function getState<T, K extends Canonical, Key extends K>(token: ReadableFamilyToken<T, K>, key: Key): T;
227
+
228
+ type SetUpdate = `add:${string}` | `clear:${string}` | `del:${string}` | `tx:${string}`;
229
+ type NumberedSetUpdate = `${number}=${SetUpdate}`;
230
+ interface SetRTXJson<P extends primitive> extends Json.Object {
231
+ members: P[];
232
+ cache: (NumberedSetUpdate | null)[];
233
+ cacheLimit: number;
234
+ cacheIdx: number;
235
+ cacheUpdateNumber: number;
236
+ }
237
+ declare class SetRTX<P extends primitive> extends Set<P> implements Transceiver<NumberedSetUpdate>, Lineage {
238
+ mode: TransceiverMode;
239
+ readonly subject: Subject<SetUpdate>;
240
+ cacheLimit: number;
241
+ cache: (NumberedSetUpdate | null)[];
242
+ cacheIdx: number;
243
+ cacheUpdateNumber: number;
244
+ constructor(values?: Iterable<P>, cacheLimit?: number);
245
+ toJSON(): SetRTXJson<P>;
246
+ static fromJSON<P extends primitive>(json: SetRTXJson<P>): SetRTX<P>;
247
+ add(value: P): this;
248
+ clear(): void;
249
+ delete(value: P): boolean;
250
+ readonly parent: SetRTX<P> | null;
251
+ child: SetRTX<P> | null;
252
+ transactionUpdates: SetUpdate[] | null;
253
+ transaction(run: (child: SetRTX<P>) => boolean): void;
254
+ protected _subscribe(key: string, fn: (update: SetUpdate) => void): () => void;
255
+ subscribe(key: string, fn: (update: NumberedSetUpdate) => void): () => void;
256
+ emit(update: SetUpdate): void;
257
+ private doStep;
258
+ getUpdateNumber(update: NumberedSetUpdate): number;
259
+ do(update: NumberedSetUpdate): number | `OUT_OF_RANGE` | null;
260
+ undoStep(update: SetUpdate): void;
261
+ undo(update: NumberedSetUpdate): number | null;
262
+ }
263
+
264
+ interface JoinOptions<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null> extends JunctionSchemaBase<ASide, BSide>, Partial<JunctionEntriesBase<AType, BType, Content>> {
265
+ readonly key: string;
266
+ readonly cardinality: Cardinality;
267
+ readonly isAType: Refinement<string, AType>;
268
+ readonly isBType: Refinement<string, BType>;
269
+ }
270
+ type JoinToken<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null = null> = {
271
+ key: string;
272
+ type: `join`;
273
+ cardinality: Cardinality;
274
+ a: ASide;
275
+ b: BSide;
276
+ __aType?: AType;
277
+ __bType?: BType;
278
+ __content?: Content;
279
+ };
280
+
281
+ declare const LoggerIconDictionary: {
282
+ readonly "\u231B": "Timeline event fully captured";
283
+ readonly "\u23E9": "Timeline redo";
284
+ readonly "\u23EA": "Timeline undo";
285
+ readonly "\u23ED\uFE0F": "Transaction redo";
286
+ readonly "\u23EE\uFE0F": "Transaction undo";
287
+ readonly "\u23F3": "Timeline event partially captured";
288
+ readonly "\u23F9\uFE0F": "Time-travel complete";
289
+ readonly "\u2705": "Realtime transaction success";
290
+ readonly "\u2728": "Computation complete";
291
+ readonly "\u274C": "Conflict prevents attempted action";
292
+ readonly "\u2B55": "Operation start";
293
+ readonly "\uD83D\uDD34": "Operation complete";
294
+ readonly "\u2757": "Operation blocked";
295
+ readonly "\uD83D\uDFE2": "Operation unblocked";
296
+ readonly "\uD83D\uDC1E": "Possible bug in AtomIO";
297
+ readonly "\uD83D\uDC40": "Subscription added";
298
+ readonly "\uD83D\uDC4B": "Greeting";
299
+ readonly "\uD83D\uDC4D": "Realtime acknowledgment";
300
+ readonly "\uD83D\uDC6A": "Family member added";
301
+ readonly "\uD83D\uDC81": "Notice";
302
+ readonly "\uD83D\uDCA5": "Caught";
303
+ readonly "\uD83D\uDCC1": "Stow update";
304
+ readonly "\uD83D\uDCC3": "Copy mutable";
305
+ readonly "\uD83D\uDCD6": "Read state";
306
+ readonly "\uD83D\uDCDD": "Write state";
307
+ readonly "\uD83D\uDCE2": "Notify subscribers";
308
+ readonly "\uD83D\uDD04": "Realtime transaction synchronized";
309
+ readonly "\uD83D\uDD0C": "Register dependency";
310
+ readonly "\uD83D\uDD0D": "Discover root";
311
+ readonly "\uD83D\uDD25": "Delete state";
312
+ readonly "\uD83D\uDD27": "Create mutable atom";
313
+ readonly "\uD83D\uDD28": "Create immutable atom";
314
+ readonly "\uD83D\uDDD1": "Evict cached value";
315
+ readonly "\uD83D\uDE48": "Subscription canceled";
316
+ readonly "\uD83D\uDE80": "Performance measure";
317
+ readonly "\uD83D\uDEC4": "Apply transaction";
318
+ readonly "\uD83D\uDEE0\uFE0F": "Install atom into store";
319
+ readonly "\uD83D\uDEEB": "Begin transaction";
320
+ readonly "\uD83D\uDEEC": "Complete transaction";
321
+ readonly "\uD83E\uDDEE": "Computing selector";
322
+ readonly "\uD83E\uDDF9": "Prepare to evict";
323
+ readonly "\uD83E\uDE82": "Abort transaction";
324
+ readonly "\uD83E\uDD1E": "Realtime optimistic update enqueued";
325
+ readonly "\uD83D\uDC48": "Realtime confirmed update enqueued";
326
+ readonly "\uD83E\uDDD1\u200D\u2696\uFE0F": "Realtime update beginning reconciliation";
327
+ readonly "\uD83D\uDECE\uFE0F": "Realtime transaction received";
328
+ readonly "\uD83D\uDD2D": "Determining realtime perspective";
329
+ readonly "\uD83D\uDD8C": "Redacting realtime update";
330
+ readonly "\uD83D\uDC41": "Determining perspective";
331
+ };
332
+ type LoggerIcon = keyof typeof LoggerIconDictionary;
333
+ type TokenDenomination = `atom_family` | `atom` | `continuity` | `molecule_family` | `molecule` | `mutable_atom_family` | `mutable_atom` | `readonly_selector_family` | `readonly_selector` | `selector_family` | `selector` | `state` | `timeline` | `transaction` | `unknown`;
334
+ declare const LOG_LEVELS: readonly ["info", "warn", "error"];
335
+ type LogLevel = (typeof LOG_LEVELS)[number];
336
+ type LogFn = (icon: LoggerIcon, denomination: TokenDenomination, tokenKey: string, message: string, ...rest: unknown[]) => void;
337
+ type LogFilter = (...params: Parameters<LogFn>) => boolean;
338
+ type Logger = Record<LogLevel, LogFn>;
339
+ declare class AtomIOLogger implements Logger {
340
+ logLevel: `error` | `info` | `warn` | null;
341
+ private readonly filter?;
342
+ private readonly logger;
343
+ constructor(logLevel: `error` | `info` | `warn` | null, filter?: LogFilter | undefined, logger?: Logger);
344
+ error: LogFn;
345
+ info: LogFn;
346
+ warn: LogFn;
347
+ }
348
+
349
+ declare const $claim: unique symbol;
350
+ type Claim<K extends Canonical> = K & {
351
+ [$claim]?: true;
352
+ };
353
+ declare class Realm<H extends Hierarchy> {
354
+ store: Store;
355
+ constructor(store?: Store);
356
+ allocate<V extends Vassal<H>, A extends Above<V, H>>(provenance: A, key: V, attachmentStyle?: `all` | `any`): Claim<V>;
357
+ 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>>;
358
+ deallocate<V extends Vassal<H>>(claim: Claim<V>): void;
359
+ claim<V extends Exclude<Vassal<H>, CompoundTypedKey>, A extends Above<V, H>>(newProvenance: A, claim: Claim<V>, exclusive?: `exclusive`): Claim<V>;
360
+ }
361
+ declare class Anarchy {
362
+ store: Store;
363
+ realm: Realm<any>;
364
+ constructor(store?: Store);
365
+ allocate(provenance: Canonical, key: Canonical, attachmentStyle?: `all` | `any`): void;
366
+ deallocate(key: Canonical): void;
367
+ claim(newProvenance: Canonical, key: Canonical, exclusive?: `exclusive`): void;
368
+ }
369
+ declare const T$ = "T$";
370
+ type T$ = typeof T$;
371
+ type TypeTag<T extends string> = `${T$}--${T}`;
372
+ type SingularTypedKey<T extends string = string> = `${T}::${string}`;
373
+ type CompoundTypedKey<A extends string = string, B extends string = string, C extends string = string> = `${TypeTag<A>}==${SingularTypedKey<B>}++${SingularTypedKey<C>}`;
374
+ type TypedKey<A extends string = string, B extends string = string, C extends string = string> = CompoundTypedKey<A, B, C> | SingularTypedKey<A>;
375
+ type Scope = SingularTypedKey[];
376
+ type MutualFealty = {
377
+ above: Scope;
378
+ below: CompoundTypedKey;
379
+ };
380
+ type ExclusiveFealty = {
381
+ above: TypedKey | `root`;
382
+ below: Scope;
383
+ };
384
+ type Fealty = ExclusiveFealty | MutualFealty;
385
+ type Hierarchy<F extends Fealty[] = Fealty[]> = Each<F>;
386
+ type Vassal<H extends Hierarchy> = {
387
+ [K in keyof H]: H[K] extends MutualFealty ? H[K][`below`] : H[K] extends {
388
+ below: Array<infer V>;
389
+ } ? V extends TypedKey ? V : never : never;
390
+ }[keyof H];
391
+ type Above<TK extends TypedKey, H extends Hierarchy> = {
392
+ [K in keyof H]: H[K] extends MutualFealty ? TK extends H[K][`below`] ? H[K][`above`] : never : H[K] extends {
393
+ below: Array<infer V>;
394
+ } ? TK extends V ? H[K] extends ExclusiveFealty ? H[K][`above`] : never : never : never;
395
+ }[keyof H];
396
+ type CompoundFrom<H extends Hierarchy> = {
397
+ [K in keyof H]: H[K] extends MutualFealty ? H[K][`below`] : never;
398
+ }[keyof H];
399
+
400
+ /**
401
+ * @public
402
+ * A function that sets the value of a state.
403
+ * @param oldValue - The current value of the state.
404
+ * @returns
405
+ * The new value of the state.
406
+ */
407
+ type Setter<T, New extends T> = (oldValue: T) => New;
408
+ /**
409
+ * @public
410
+ * Set the value of a state into the implicit store.
411
+ * @param token - An atom or writable selector token.
412
+ * @param value - The new value of the state.
413
+ * @overload Default
414
+ * @default
415
+ */
416
+ declare function setState<T, New extends T>(token: WritableToken<T>, value: New | Setter<T, New>): void;
417
+ /**
418
+ * @public
419
+ * Set the value of a state into the implicit store.
420
+ * @param token - An atom family or writable selector family token.
421
+ * @param key - The unique key of the state to set.
422
+ * @param value - The new value of the state.
423
+ * @overload Streamlined
424
+ */
425
+ 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;
426
+
427
+ type StateUpdate<T> = {
428
+ newValue: T;
429
+ oldValue: T;
430
+ };
431
+ type KeyedStateUpdate<T> = Flat<StateUpdate<T> & {
432
+ key: string;
433
+ type: `atom_update` | `selector_update`;
434
+ family?: FamilyMetadata;
435
+ }>;
436
+
437
+ type TokenType<Comparison extends ReadableFamilyToken<any, any> | ReadableToken<any>> = Comparison extends ReadableToken<infer RepresentedValue> ? RepresentedValue : Comparison extends ReadableFamilyToken<infer RepresentedValue, any> ? RepresentedValue : never;
438
+
439
+ /** @public */
440
+ type RegularAtomToken<T, K extends Canonical = any> = {
441
+ /** The unique identifier of the atom. */
442
+ key: string;
443
+ /** Discriminator. */
444
+ type: `atom`;
445
+ /** Present if the atom belongs to a family. */
446
+ family?: FamilyMetadata<K>;
447
+ /** Never present. This is a marker that preserves the type of the atom's value. */
448
+ __T?: T;
449
+ };
450
+ /** @public */
451
+ type MutableAtomToken<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical = any> = {
452
+ /** The unique identifier of the atom. */
453
+ key: string;
454
+ /** Discriminator. */
455
+ type: `mutable_atom`;
456
+ /** Present if the atom belongs to a family. */
457
+ family?: FamilyMetadata<K>;
458
+ /** Never present. This is a marker that preserves the JSON form of the atom's transceiver value. */
459
+ __J?: J;
460
+ /** Never present. This is a marker that preserves the type of the atom's transceiver value. */
461
+ __U?: T extends Transceiver<infer Update> ? Update : never;
462
+ };
463
+ /** @public */
464
+ type AtomToken<T, K extends Canonical = any> = MutableAtomToken<T extends Transceiver<any> ? T : never, any, K> | RegularAtomToken<T, K>;
465
+ /** @public */
466
+ type WritableSelectorToken<T, K extends Canonical = any> = {
467
+ /** The unique identifier of the selector. */
468
+ key: string;
469
+ /** Discriminator. */
470
+ type: `selector`;
471
+ /** Present if the selector belongs to a family. */
472
+ family?: FamilyMetadata<K>;
473
+ /** Never present. This is a marker that preserves the type of the selector's value. */
474
+ __T?: T;
475
+ };
476
+ /** @public */
477
+ type ReadonlySelectorToken<T, K extends Canonical = any> = {
478
+ /** The unique identifier of the selector. */
479
+ key: string;
480
+ /** Discriminator. */
481
+ type: `readonly_selector`;
482
+ /** Present if the selector belongs to a family. */
483
+ family?: FamilyMetadata<K>;
484
+ /** Never present. This is a marker that preserves the type of the selector's value. */
485
+ __T?: T;
486
+ };
487
+ /** @public */
488
+ type SelectorToken<T, K extends Canonical = any> = ReadonlySelectorToken<T, K> | WritableSelectorToken<T, K>;
489
+ /**
490
+ * @public
491
+ * These states can be set.
492
+ */
493
+ type WritableToken<T, K extends Canonical = any> = AtomToken<T, K> | WritableSelectorToken<T, K>;
494
+ /**
495
+ * @public
496
+ * These states cannot be set.
497
+ */
498
+ type ReadableToken<T, K extends Canonical = any> = AtomToken<T, K> | SelectorToken<T, K>;
499
+ /**
500
+ * @public
501
+ * States belonging to this family can be set.
502
+ */
503
+ type WritableFamilyToken<T, K extends Canonical> = AtomFamilyToken<T, K> | WritableSelectorFamilyToken<T, K>;
504
+ /**
505
+ * @public
506
+ * States belonging to this family cannot be set.
507
+ */
508
+ type ReadableFamilyToken<T, K extends Canonical> = AtomFamilyToken<T, K> | SelectorFamilyToken<T, K>;
509
+ /**
510
+ * @public
511
+ * Identifies a state's connection to its family.
512
+ */
513
+ type FamilyMetadata<K extends Canonical = any> = {
514
+ /** The family's unique key. */
515
+ key: string;
516
+ /** The family member's unique identifier, in the form of a string. */
517
+ subKey: stringified<K>;
518
+ };
519
+ type Loadable<T> = Promise<T> | T;
520
+
521
+ declare class CircularBuffer<T> {
522
+ protected _buffer: T[];
523
+ protected _index: number;
524
+ constructor(array: T[]);
525
+ constructor(length: number);
526
+ get buffer(): ReadonlyArray<T | undefined>;
527
+ get index(): number;
528
+ add(item: T): void;
529
+ copy(): CircularBuffer<T>;
530
+ }
531
+
532
+ type Func = (...parameters: any[]) => any;
533
+ type Flat<R extends {
534
+ [K in PropertyKey]: any;
535
+ }> = {
536
+ [K in keyof R]: R[K];
537
+ };
538
+ type Count<N extends number, A extends any[] = []> = [
539
+ ...A,
540
+ any
541
+ ][`length`] extends N ? A[`length`] : A[`length`] | Count<N, [...A, any]>;
542
+ type Each<E extends any[]> = {
543
+ [P in Count<E[`length`]>]: E[P];
544
+ };
545
+ type Refinement<A, B extends A> = (a: A) => a is B;
546
+
547
+ type JunctionEntriesBase<AType extends string, BType extends string, Content extends Json.Object | null> = {
548
+ readonly relations: ([AType, BType[]] | [BType, AType[]])[];
549
+ readonly contents: [string, Content][];
550
+ };
551
+ interface JunctionEntries<AType extends string, BType extends string, Content extends Json.Object | null> extends Json.Object, JunctionEntriesBase<AType, BType, Content> {
552
+ }
553
+ type JunctionSchemaBase<ASide extends string, BSide extends string> = {
554
+ readonly between: [a: ASide, b: BSide];
555
+ readonly cardinality: `1:1` | `1:n` | `n:n`;
556
+ };
557
+ interface JunctionSchema<ASide extends string, BSide extends string> extends Json.Object, JunctionSchemaBase<ASide, BSide> {
558
+ }
559
+ type BaseExternalStoreConfiguration = {
560
+ addRelation: (a: string, b: string) => void;
561
+ deleteRelation: (a: string, b: string) => void;
562
+ replaceRelationsSafely: (a: string, bs: string[]) => void;
563
+ replaceRelationsUnsafely: (a: string, bs: string[]) => void;
564
+ getRelatedKeys(key: string): Set<string> | undefined;
565
+ has: (a: string, b?: string) => boolean;
566
+ };
567
+ type ExternalStoreWithContentConfiguration<Content extends Json.Object> = {
568
+ getContent: (contentKey: string) => Content | undefined;
569
+ setContent: (contentKey: string, content: Content) => void;
570
+ deleteContent: (contentKey: string) => void;
571
+ };
572
+ type Empty<Obj extends object> = {
573
+ [Key in keyof Obj]?: undefined;
574
+ };
575
+ type ExternalStoreConfiguration<Content extends Json.Object | null> = Content extends Json.Object ? BaseExternalStoreConfiguration & ExternalStoreWithContentConfiguration<Content> : BaseExternalStoreConfiguration & Empty<ExternalStoreWithContentConfiguration<Json.Object>>;
576
+ type JunctionAdvancedConfiguration<AType extends string, BType extends string, Content extends Json.Object | null> = {
577
+ warn?: (...args: any[]) => void;
578
+ externalStore?: ExternalStoreConfiguration<Content>;
579
+ isAType?: Refinement<string, AType>;
580
+ isBType?: Refinement<string, BType>;
581
+ isContent?: Refinement<unknown, Content>;
582
+ makeContentKey?: (a: AType, b: BType) => string;
583
+ };
584
+ type JunctionJSON<ASide extends string, AType extends string, BSide extends string, BType extends string, Content extends Json.Object | null> = JunctionEntries<AType, BType, Content> & JunctionSchema<ASide, BSide>;
585
+ declare class Junction<const ASide extends string, const AType extends string, const BSide extends string, const BType extends string, const Content extends Json.Object | null = null> {
586
+ readonly a: ASide;
587
+ readonly b: BSide;
588
+ readonly cardinality: `1:1` | `1:n` | `n:n`;
589
+ readonly relations: Map<AType | BType, Set<AType> | Set<BType>>;
590
+ readonly contents: Map<string, Content>;
591
+ isAType?: Refinement<string, AType> | null;
592
+ isBType?: Refinement<string, BType> | null;
593
+ isContent: Refinement<unknown, Content> | null;
594
+ makeContentKey: (a: AType, b: BType) => string;
595
+ warn?: (...args: any[]) => void;
596
+ getRelatedKeys(key: AType): Set<BType> | undefined;
597
+ getRelatedKeys(key: BType): Set<AType> | undefined;
598
+ getRelatedKeys(key: AType | BType): Set<AType> | Set<BType> | undefined;
599
+ protected addRelation(a: AType, b: BType): void;
600
+ protected deleteRelation(a: AType, b: BType): void;
601
+ protected replaceRelationsUnsafely(a: AType, bs: BType[]): void;
602
+ protected replaceRelationsUnsafely(b: BType, as: AType[]): void;
603
+ protected replaceRelationsSafely(a: AType, bs: BType[]): void;
604
+ protected replaceRelationsSafely(b: BType, as: AType[]): void;
605
+ protected getContentInternal(contentKey: string): Content | undefined;
606
+ protected setContent(contentKey: string, content: Content): void;
607
+ protected deleteContent(contentKey: string): void;
608
+ constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<NoInfer<AType>, NoInfer<BType>, Content>>, config?: JunctionAdvancedConfiguration<AType, BType, Content>);
609
+ toJSON(): JunctionJSON<ASide, AType, BSide, BType, Content>;
610
+ set(a: AType, ...rest: Content extends null ? [b: BType] : [b: BType, content: Content]): this;
611
+ set(relation: {
612
+ [Key in ASide]: AType;
613
+ } & {
614
+ [Key in BSide]: BType;
615
+ }, ...rest: Content extends null ? [] | [void?: undefined] : [content: Content]): this;
616
+ delete(a: AType, b?: BType): this;
617
+ delete(b: BType, a?: AType): this;
618
+ delete(relation: {
619
+ [Key in ASide]: AType;
620
+ } | {
621
+ [Key in BSide]: BType;
622
+ } | ({
623
+ [Key in ASide]: AType;
624
+ } & {
625
+ [Key in BSide]: BType;
626
+ }), b?: undefined): this;
627
+ getRelatedKey(key: AType): BType | undefined;
628
+ getRelatedKey(key: BType): AType | undefined;
629
+ replaceRelations(a: AType, relations: Content extends null ? BType[] : Record<BType, Content>, config?: {
630
+ reckless: boolean;
631
+ }): this;
632
+ replaceRelations(b: BType, relations: Content extends null ? AType[] : Record<AType, Content>, config?: {
633
+ reckless: boolean;
634
+ }): this;
635
+ getContent(a: AType, b: BType): Content | undefined;
636
+ getRelationEntries(input: Record<ASide, AType>): [BType, Content][];
637
+ getRelationEntries(input: Record<BSide, BType>): [AType, Content][];
638
+ has(a: AType, b?: BType): boolean;
639
+ has(b: BType, a?: AType): boolean;
640
+ }
641
+
642
+ declare class Subject<T> {
643
+ Subscriber: (value: T) => void;
644
+ subscribers: Map<string, this[`Subscriber`]>;
645
+ subscribe(key: string, subscriber: this[`Subscriber`]): () => void;
646
+ private unsubscribe;
647
+ next(value: T): void;
648
+ }
649
+ declare class StatefulSubject<T> extends Subject<T> {
650
+ state: T;
651
+ constructor(initialState: T);
652
+ next(value: T): void;
653
+ }
654
+
655
+ type Transaction<F extends Func> = {
656
+ key: string;
657
+ type: `transaction`;
658
+ install: (store: Store) => void;
659
+ subject: Subject<TransactionUpdate<F>>;
660
+ run: (parameters: Parameters<F>, id?: string) => ReturnType<F>;
661
+ };
662
+
663
+ type TransactionProgress<F extends Func> = {
664
+ phase: `applying` | `building`;
665
+ update: TransactionUpdate<F>;
666
+ toolkit: ActorToolkit;
667
+ };
668
+ type TransactionEpoch = {
669
+ epoch: Map<string, number>;
670
+ actionContinuities: Junction<`continuity`, string, `action`, string>;
671
+ };
672
+
673
+ type Molecule<K extends Canonical> = {
674
+ readonly key: K;
675
+ readonly stringKey: stringified<K>;
676
+ readonly dependsOn: `all` | `any`;
677
+ };
678
+
679
+ type JoinStateFamilies<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null> = Cardinality extends `1:1` ? (Content extends Json.Object ? {
680
+ readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<[
681
+ AType,
682
+ Content
683
+ ] | null, BType>;
684
+ } & {
685
+ readonly [B in BSide as `${B}EntryOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<[
686
+ BType,
687
+ Content
688
+ ] | null, AType>;
689
+ } : {}) & {
690
+ readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<AType | null, BType>;
691
+ } & {
692
+ readonly [B in BSide as `${B}KeyOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<BType | null, AType>;
693
+ } : Cardinality extends `1:n` ? (Content extends Json.Object ? {
694
+ readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<[
695
+ AType,
696
+ Content
697
+ ] | null, BType>;
698
+ } & {
699
+ readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<[
700
+ BType,
701
+ Content
702
+ ][], AType>;
703
+ } : {}) & {
704
+ readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<AType | null, BType>;
705
+ } & {
706
+ readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<BType[], AType>;
707
+ } : Cardinality extends `n:n` ? (Content extends Json.Object ? {
708
+ readonly [A in ASide as `${A}EntriesOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<[
709
+ AType,
710
+ Content
711
+ ][], BType>;
712
+ } & {
713
+ readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<[
714
+ BType,
715
+ Content
716
+ ][], AType>;
717
+ } : {}) & {
718
+ readonly [A in ASide as `${A}KeysOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<AType[], BType>;
719
+ } & {
720
+ readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<BType[], AType>;
721
+ } : never;
722
+ declare class Join<const ASide extends string, const AType extends string, const BSide extends string, const BType extends string, const Cardinality extends `1:1` | `1:n` | `n:n`, const Content extends Json.Object | null = null, const ContentKey extends CompoundTypedKey<`content`, ASide, BSide> = CompoundTypedKey<`content`, ASide, BSide>> {
723
+ private toolkit;
724
+ options: JoinOptions<ASide, AType, BSide, BType, Cardinality, Content>;
725
+ defaultContent: Content | undefined;
726
+ molecules: Map<string, Molecule<any>>;
727
+ relations: Junction<ASide, AType, BSide, BType, Content>;
728
+ states: JoinStateFamilies<ASide, AType, BSide, BType, Cardinality, Content>;
729
+ core: {
730
+ relatedKeysAtoms: MutableAtomFamilyToken<SetRTX<string>, SetRTXJson<string>, string>;
731
+ };
732
+ transact(toolkit: SetterToolkit, run: (join: Join<ASide, AType, BSide, BType, Cardinality, Content>) => void): void;
733
+ store: Store;
734
+ realm: Anarchy;
735
+ [Symbol.dispose](): void;
736
+ constructor(options: JoinOptions<ASide, AType, BSide, BType, Cardinality, Content>, defaultContent: Content | undefined, store?: Store);
737
+ }
738
+
739
+ interface Lineage {
740
+ parent: typeof this | null;
741
+ child: typeof this | null;
742
+ }
743
+
744
+ type OperationProgress = {
745
+ open: false;
746
+ } | {
747
+ open: true;
748
+ done: Set<string>;
749
+ prev: Map<string, any>;
750
+ time: number;
751
+ token: WritableToken<any>;
752
+ };
753
+
754
+ type TimelineAtomUpdate<ManagedAtom extends TimelineManageable> = Flat<StateUpdate<TokenType<ManagedAtom>> & {
755
+ key: string;
756
+ type: `atom_update`;
757
+ timestamp: number;
758
+ family?: FamilyMetadata;
759
+ }>;
760
+ type TimelineSelectorUpdate<ManagedAtom extends TimelineManageable> = {
761
+ key: string;
762
+ type: `selector_update`;
763
+ timestamp: number;
764
+ atomUpdates: Omit<TimelineAtomUpdate<ManagedAtom>, `timestamp`>[];
765
+ };
766
+ type TimelineTransactionUpdate = Flat<TransactionUpdate<Func> & {
767
+ key: string;
768
+ type: `transaction_update`;
769
+ timestamp: number;
770
+ }>;
771
+ type TimelineStateCreation<T extends ReadableToken<any>> = Flat<StateCreation<T> & {
772
+ timestamp: number;
773
+ }>;
774
+ type TimelineStateDisposal<T extends ReadableToken<any>> = Flat<StateDisposal<T> & {
775
+ timestamp: number;
776
+ }>;
777
+ type TimelineMoleculeCreation = Flat<MoleculeCreation & {
778
+ timestamp: number;
779
+ }>;
780
+ type TimelineMoleculeDisposal = Flat<MoleculeDisposal & {
781
+ timestamp: number;
782
+ }>;
783
+ type Timeline<ManagedAtom extends TimelineManageable> = {
784
+ type: `timeline`;
785
+ key: string;
786
+ at: number;
787
+ shouldCapture?: (update: TimelineUpdate<ManagedAtom>, timeline: Timeline<ManagedAtom>) => boolean;
788
+ timeTraveling: `into_future` | `into_past` | null;
789
+ history: TimelineUpdate<ManagedAtom>[];
790
+ selectorTime: number | null;
791
+ transactionKey: string | null;
792
+ install: (store: Store) => void;
793
+ subject: Subject<TimelineUpdate<ManagedAtom> | `redo` | `undo`>;
794
+ subscriptions: Map<string, () => void>;
795
+ };
796
+
797
+ declare class Store implements Lineage {
798
+ parent: Store | null;
799
+ child: Store | null;
800
+ valueMap: Map<string, any>;
801
+ defaults: Map<string, any>;
802
+ atoms: Map<string, Atom<any>>;
803
+ selectors: Map<string, WritableSelector<any>>;
804
+ readonlySelectors: Map<string, ReadonlySelector<any>>;
805
+ atomsThatAreDefault: Set<string>;
806
+ selectorAtoms: Junction<"selectorKey", string, "atomKey", string, null>;
807
+ selectorGraph: Junction<"upstreamSelectorKey", string, "downstreamSelectorKey", string, {
808
+ source: string;
809
+ }>;
810
+ trackers: Map<string, Tracker<Transceiver<any>>>;
811
+ families: Map<string, MutableAtomFamily<any, any, any> | ReadonlySelectorFamily<any, any> | RegularAtomFamily<any, any> | WritableSelectorFamily<any, any>>;
812
+ joins: Map<string, Join<any, any, any, any, any, any, `T$--content==${any}::${string}++${any}::${string}`>>;
813
+ transactions: Map<string, Transaction<Func>>;
814
+ transactionMeta: TransactionEpoch | TransactionProgress<Func>;
815
+ timelines: Map<string, Timeline<any>>;
816
+ timelineTopics: Junction<"timelineKey", string, "topicKey", string, {
817
+ topicType: `atom_family` | `atom` | `molecule_family` | `molecule`;
818
+ }>;
819
+ disposalTraces: CircularBuffer<{
820
+ key: string;
821
+ trace: string;
822
+ }>;
823
+ molecules: Map<string, Molecule<Canonical>>;
824
+ moleculeJoins: Junction<"moleculeKey", stringified<Canonical>, "joinKey", string, null>;
825
+ moleculeGraph: Junction<"upstreamMoleculeKey", stringified<Canonical> | "root", "downstreamMoleculeKey", stringified<Canonical>, {
826
+ source: stringified<Canonical>;
827
+ }>;
828
+ moleculeData: Junction<"moleculeKey", stringified<Canonical>, "stateFamilyKey", string, null>;
829
+ miscResources: Map<string, Disposable>;
830
+ on: {
831
+ atomCreation: Subject<AtomToken<unknown>>;
832
+ atomDisposal: Subject<AtomToken<unknown>>;
833
+ selectorCreation: Subject<ReadonlySelectorToken<unknown> | WritableSelectorToken<unknown>>;
834
+ selectorDisposal: Subject<ReadonlySelectorToken<unknown> | WritableSelectorToken<unknown>>;
835
+ timelineCreation: Subject<TimelineToken<unknown>>;
836
+ transactionCreation: Subject<TransactionToken<Func>>;
837
+ transactionApplying: StatefulSubject<TransactionProgress<Func> | null>;
838
+ operationClose: Subject<OperationProgress>;
839
+ moleculeCreation: Subject<MoleculeCreation>;
840
+ moleculeDisposal: Subject<MoleculeDisposal>;
841
+ };
842
+ operation: OperationProgress;
843
+ config: {
844
+ name: string;
845
+ lifespan: `ephemeral` | `immortal`;
846
+ };
847
+ loggers: AtomIOLogger[];
848
+ logger: Logger;
849
+ constructor(config: Store[`config`], store?: Store | null);
850
+ }
851
+
852
+ interface Transceiver<S extends Json.Serializable> {
853
+ do: (update: S) => number | `OUT_OF_RANGE` | null;
854
+ undo: (update: S) => void;
855
+ subscribe: (key: string, fn: (update: S) => void) => () => void;
856
+ cacheUpdateNumber: number;
857
+ getUpdateNumber: (update: S) => number;
858
+ }
859
+ type TransceiverMode = `playback` | `record` | `transaction`;
860
+
861
+ /**
862
+ * @internal Give the tracker a transceiver state and a store, and it will
863
+ * subscribe to the transceiver's inner value. When the inner value changes,
864
+ * the tracker will update its own state to reflect the change.
865
+ */
866
+ declare class Tracker<Mutable extends Transceiver<any>> {
867
+ private Update;
868
+ private initializeState;
869
+ private unsubscribeFromInnerValue;
870
+ private unsubscribeFromState;
871
+ private observeCore;
872
+ private updateCore;
873
+ mutableState: MutableAtomToken<Mutable, Json.Serializable>;
874
+ latestUpdateState: RegularAtomToken<typeof this.Update | null>;
875
+ [Symbol.dispose]: () => void;
876
+ constructor(mutableState: MutableAtomToken<Mutable, Json.Serializable>, store: Store);
877
+ }
878
+
879
+ type EnvironmentData = {
880
+ store: Store;
881
+ };
882
+
883
+ type AtomIOState = {
884
+ key: string;
885
+ family?: FamilyMetadata;
886
+ install: (store: Store) => void;
887
+ subject: Subject<{
888
+ newValue: any;
889
+ oldValue: any;
890
+ }>;
891
+ };
892
+ type RegularAtom<T> = AtomIOState & {
893
+ type: `atom`;
894
+ default: T | (() => T);
895
+ cleanup?: () => void;
896
+ };
897
+ type MutableAtom<T extends Transceiver<any>, J extends Json.Serializable> = AtomIOState & JsonInterface<T, J> & {
898
+ type: `mutable_atom`;
899
+ default: T | (() => T);
900
+ cleanup?: () => void;
901
+ };
902
+ type Atom<T> = RegularAtom<T> | (T extends Transceiver<any> ? MutableAtom<T, any> : never);
903
+ type WritableSelector<T> = AtomIOState & {
904
+ type: `selector`;
905
+ get: () => T;
906
+ set: (newValue: T | ((oldValue: T) => T)) => void;
907
+ };
908
+ type ReadonlySelector<T> = AtomIOState & {
909
+ type: `readonly_selector`;
910
+ get: () => T;
911
+ };
912
+ type RegularAtomFamily<T, K extends Canonical> = RegularAtomFamilyToken<T, K> & {
913
+ (key: K): RegularAtomToken<T>;
914
+ subject: Subject<StateCreation<AtomToken<T>> | StateDisposal<AtomToken<T>>>;
915
+ install: (store: Store) => void;
916
+ internalRoles: string[] | undefined;
917
+ };
918
+ type MutableAtomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical> = JsonInterface<T, J> & MutableAtomFamilyToken<T, J, K> & {
919
+ (key: K): MutableAtomToken<T, J>;
920
+ subject: Subject<StateCreation<MutableAtomToken<T, J>> | StateDisposal<MutableAtomToken<T, J>>>;
921
+ install: (store: Store) => void;
922
+ internalRoles: string[] | undefined;
923
+ };
924
+ type WritableSelectorFamily<T, K extends Canonical> = WritableSelectorFamilyToken<T, K> & ((key: K) => WritableSelectorToken<T>) & {
925
+ default: (key: K) => T;
926
+ subject: Subject<StateCreation<WritableSelectorToken<T>> | StateDisposal<WritableSelectorToken<T>>>;
927
+ install: (store: Store) => void;
928
+ internalRoles: string[] | undefined;
929
+ };
930
+ type ReadonlySelectorFamily<T, K extends Canonical> = ReadonlySelectorFamilyToken<T, K> & ((key: K) => ReadonlySelectorToken<T>) & {
931
+ default: (key: K) => T;
932
+ subject: Subject<StateCreation<ReadonlySelectorToken<T>> | StateDisposal<ReadonlySelectorToken<T>>>;
933
+ install: (store: Store) => void;
934
+ internalRoles: string[] | undefined;
935
+ };
936
+
937
+ type PerspectiveToken<F extends AtomFamilyToken<any>> = {
938
+ type: `realtime_perspective`;
939
+ resourceAtoms: F;
940
+ viewAtoms: ReadableFamilyToken<ReadableToken<TokenType<F>>[], UserKey>;
941
+ };
942
+ type ContinuityToken = {
943
+ readonly type: `continuity`;
944
+ readonly key: string;
945
+ readonly globals: AtomToken<any>[];
946
+ readonly actions: TransactionToken<any>[];
947
+ readonly perspectives: PerspectiveToken<AtomFamilyToken<any, Canonical>>[];
948
+ };
949
+
950
+ type UserInRoomMeta = {
951
+ enteredAtEpoch: number;
952
+ };
10
953
 
11
954
  type ExposeRealtimeContinuity = (continuity: ContinuityToken) => () => void;
12
955
  declare function prepareToExposeRealtimeContinuity({ socket: initialSocket, store, }: ServerConfig): ExposeRealtimeContinuity;
@@ -75,35 +1018,35 @@ declare class ParentSocket<I extends Events & {
75
1018
  }
76
1019
 
77
1020
  type ActionReceiver = ReturnType<typeof realtimeActionReceiver>;
78
- declare function realtimeActionReceiver({ socket, store, }: ServerConfig): <F extends JsonIO>(tx: AtomIO.TransactionToken<F>) => () => void;
1021
+ declare function realtimeActionReceiver({ socket, store, }: ServerConfig): <F extends JsonIO>(tx: TransactionToken<F>) => () => void;
79
1022
 
80
1023
  type FamilyProvider = ReturnType<typeof realtimeAtomFamilyProvider>;
81
- declare function realtimeAtomFamilyProvider({ socket, store, }: ServerConfig): <J extends Json.Serializable, K extends Canonical>(family: AtomIO.RegularAtomFamilyToken<J, K>, index: AtomIO.ReadableToken<Iterable<K>>) => () => void;
1024
+ declare function realtimeAtomFamilyProvider({ socket, store, }: ServerConfig): <J extends Json.Serializable, K extends Canonical>(family: RegularAtomFamilyToken<J, K>, index: ReadableToken<Iterable<K>>) => () => void;
82
1025
 
83
1026
  type MutableFamilyProvider = ReturnType<typeof realtimeMutableFamilyProvider>;
84
- declare function realtimeMutableFamilyProvider({ socket, store, }: ServerConfig): <T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical>(family: AtomIO.MutableAtomFamilyToken<T, J, K>, index: AtomIO.ReadableToken<Iterable<K>>) => () => void;
1027
+ declare function realtimeMutableFamilyProvider({ socket, store, }: ServerConfig): <T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical>(family: MutableAtomFamilyToken<T, J, K>, index: ReadableToken<Iterable<K>>) => () => void;
85
1028
 
86
1029
  type MutableProvider = ReturnType<typeof realtimeMutableProvider>;
87
- declare function realtimeMutableProvider({ socket, store, }: ServerConfig): <Core extends Transceiver<Json.Serializable>, SerializableCore extends Json.Serializable>(token: AtomIO.MutableAtomToken<Core, SerializableCore>) => () => void;
1030
+ declare function realtimeMutableProvider({ socket, store, }: ServerConfig): <Core extends Transceiver<Json.Serializable>, SerializableCore extends Json.Serializable>(token: MutableAtomToken<Core, SerializableCore>) => () => void;
88
1031
 
89
- declare const createRoomTX: AtomIO.TransactionToken<(roomId: string, script: string, options?: string[]) => Loadable<ChildSocket<any, any>>>;
90
- type CreateRoomIO = AtomIO.TransactionIO<typeof createRoomTX>;
91
- declare const joinRoomTX: AtomIO.TransactionToken<(roomId: string, userId: string, enteredAtEpoch: number) => UserInRoomMeta>;
92
- type JoinRoomIO = AtomIO.TransactionIO<typeof joinRoomTX>;
93
- declare const leaveRoomTX: AtomIO.TransactionToken<(roomId: string, userId: string) => void>;
94
- type LeaveRoomIO = AtomIO.TransactionIO<typeof leaveRoomTX>;
95
- declare const destroyRoomTX: AtomIO.TransactionToken<(roomId: string) => void>;
1032
+ declare const createRoomTX: TransactionToken<(roomId: string, script: string, options?: string[]) => Loadable<ChildSocket<any, any>>>;
1033
+ type CreateRoomIO = TransactionIO<typeof createRoomTX>;
1034
+ declare const joinRoomTX: TransactionToken<(roomId: string, userId: string, enteredAtEpoch: number) => UserInRoomMeta>;
1035
+ type JoinRoomIO = TransactionIO<typeof joinRoomTX>;
1036
+ declare const leaveRoomTX: TransactionToken<(roomId: string, userId: string) => void>;
1037
+ type LeaveRoomIO = TransactionIO<typeof leaveRoomTX>;
1038
+ declare const destroyRoomTX: TransactionToken<(roomId: string) => void>;
96
1039
 
97
1040
  type RoomArguments = [script: string, options: string[]] | [script: string];
98
- declare const roomArgumentsAtoms: AtomIO.RegularAtomFamilyToken<RoomArguments, string>;
99
- declare const roomSelectors: AtomIO.ReadonlySelectorFamilyToken<Loadable<ChildSocket<any, any>>, string>;
1041
+ declare const roomArgumentsAtoms: RegularAtomFamilyToken<RoomArguments, string>;
1042
+ declare const roomSelectors: ReadonlySelectorFamilyToken<Loadable<ChildSocket<any, any>>, string>;
100
1043
 
101
1044
  declare function redactTransactionUpdateContent(visibleStateKeys: string[], updates: TransactionUpdateContent[]): TransactionUpdateContent[];
102
- declare const redactorAtoms: AtomIO.RegularAtomFamilyToken<{
1045
+ declare const redactorAtoms: RegularAtomFamilyToken<{
103
1046
  occlude: (updates: TransactionUpdateContent[]) => TransactionUpdateContent[];
104
1047
  }, `user::${string}`>;
105
1048
  type ContinuitySyncTransactionUpdate = Pick<TransactionUpdate<any>, `epoch` | `id` | `key` | `output` | `updates`>;
106
- declare const userUnacknowledgedQueues: AtomIO.RegularAtomFamilyToken<ContinuitySyncTransactionUpdate[], `user::${string}`>;
1049
+ declare const userUnacknowledgedQueues: RegularAtomFamilyToken<ContinuitySyncTransactionUpdate[], `user::${string}`>;
107
1050
 
108
1051
  type SocketKey = `socket::${string}`;
109
1052
  type UserKey = `user::${string}`;
@@ -114,13 +1057,13 @@ type SocketSystemHierarchy = Hierarchy<[
114
1057
  below: [UserKey, SocketKey, RoomKey];
115
1058
  }
116
1059
  ]>;
117
- declare const socketAtoms: AtomIO.RegularAtomFamilyToken<Socket | null, `socket::${string}`>;
118
- declare const socketIndex: AtomIO.MutableAtomToken<SetRTX<`socket::${string}`>, SetRTXJson<`socket::${string}`>>;
119
- declare const userIndex: AtomIO.MutableAtomToken<SetRTX<`user::${string}`>, SetRTXJson<`user::${string}`>>;
120
- declare const usersOfSockets: atom_io_data.JoinToken<"user", `user::${string}`, "socket", `socket::${string}`, "1:1", null>;
1060
+ declare const socketAtoms: RegularAtomFamilyToken<Socket | null, `socket::${string}`>;
1061
+ declare const socketIndex: MutableAtomToken<SetRTX<`socket::${string}`>, SetRTXJson<`socket::${string}`>>;
1062
+ declare const userIndex: MutableAtomToken<SetRTX<`user::${string}`>, SetRTXJson<`user::${string}`>>;
1063
+ declare const usersOfSockets: JoinToken<"user", `user::${string}`, "socket", `socket::${string}`, "1:1", null>;
121
1064
 
122
1065
  type StateProvider = ReturnType<typeof realtimeStateProvider>;
123
- declare function realtimeStateProvider({ socket, store, }: ServerConfig): <J extends Json.Serializable>(token: AtomIO.WritableToken<J>) => () => void;
1066
+ declare function realtimeStateProvider({ socket, store, }: ServerConfig): <J extends Json.Serializable>(token: WritableToken<J>) => () => void;
124
1067
 
125
1068
  type StateReceiver = ReturnType<typeof realtimeStateReceiver>;
126
1069
  declare function realtimeStateReceiver({ socket, store, }: ServerConfig): <J extends Json.Serializable>(token: WritableToken<J>) => () => void;