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