atom.io 0.14.5 → 0.14.7

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.
@@ -1,56 +1,11 @@
1
1
  import * as AtomIO from 'atom.io';
2
- import { FamilyMetadata, ƒn, TransactionUpdate, MutableAtomToken, AtomToken, StateToken, TimelineUpdate, StateUpdate, AtomFamily, ReadonlySelectorFamily, SelectorFamily, ReadonlySelectorToken, SelectorToken, TransactionToken, TimelineToken, AtomIOLogger, Logger } from 'atom.io';
2
+ import { SelectorFamily } from 'atom.io';
3
+ import { Store } from 'atom.io/internal';
4
+ import { Json, Stringified } from 'atom.io/json';
3
5
 
4
- declare class Subject<T> {
5
- Subscriber: (value: T) => void;
6
- subscribers: Map<string, this[`Subscriber`]>;
7
- subscribe(key: string, subscriber: this[`Subscriber`]): () => void;
8
- private unsubscribe;
9
- next(value: T): void;
10
- }
11
- declare class StatefulSubject<T> extends Subject<T> {
12
- state: T;
13
- constructor(initialState: T);
14
- next(value: T): void;
15
- }
16
-
17
- type Selector<T> = {
18
- key: string;
19
- type: `selector`;
20
- family?: FamilyMetadata;
21
- install: (store: Store) => void;
22
- subject: Subject<{
23
- newValue: T;
24
- oldValue: T;
25
- }>;
26
- get: () => T;
27
- set: (newValue: T | ((oldValue: T) => T)) => void;
28
- };
29
- type ReadonlySelector<T> = {
30
- key: string;
31
- type: `readonly_selector`;
32
- family?: FamilyMetadata;
33
- install: (store: Store) => void;
34
- subject: Subject<{
35
- newValue: T;
36
- oldValue: T;
37
- }>;
38
- get: () => T;
39
- };
40
-
41
- type Transaction<ƒ extends ƒn> = {
42
- key: string;
43
- type: `transaction`;
44
- install: (store: Store) => void;
45
- subject: Subject<TransactionUpdate<ƒ>>;
46
- run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
47
- };
48
-
49
- type TransactionMeta<ƒ extends ƒn> = {
50
- phase: `applying` | `building`;
51
- time: number;
52
- update: TransactionUpdate<ƒ>;
53
- };
6
+ declare function dict<State, Key extends Json.Serializable>(findState: AtomIO.AtomFamily<State, Key> | AtomIO.ReadonlySelectorFamily<State, Key> | AtomIO.SelectorFamily<State, Key>, index: AtomIO.AtomToken<Key[]> | AtomIO.ReadonlySelectorToken<Key[]> | AtomIO.SelectorToken<Key[]>, store?: Store): AtomIO.ReadonlySelectorToken<{
7
+ [K in Stringified<Key>]: State;
8
+ }>;
54
9
 
55
10
  type primitive = boolean | number | string | null;
56
11
 
@@ -126,148 +81,18 @@ declare class Junction<const ASide extends string, const BSide extends string, c
126
81
  has(a: string, b?: string): boolean;
127
82
  }
128
83
 
129
- interface Lineage {
130
- parent: typeof this | null;
131
- child: typeof this | null;
132
- }
133
-
134
- type Stringified<J extends Serializable> = string & {
135
- __json: J;
136
- };
137
-
138
- interface Transceiver<Signal extends Serializable> {
139
- do: (update: Signal) => void;
140
- undo: (update: Signal) => void;
141
- subscribe: (key: string, fn: (update: Signal) => void) => () => void;
142
- cacheUpdateNumber: number;
143
- getUpdateNumber: (update: Signal) => number;
144
- }
145
-
146
- /**
147
- * @internal Give the tracker a transceiver state and a store, and it will
148
- * subscribe to the transceiver's inner value. When the inner value changes,
149
- * the tracker will update its own state to reflect the change.
150
- */
151
- declare class Tracker<Mutable extends Transceiver<any>> {
152
- private Update;
153
- private initializeState;
154
- private unsubscribeFromInnerValue;
155
- private observeCore;
156
- private updateCore;
157
- mutableState: MutableAtomToken<Mutable, Serializable>;
158
- latestUpdateState: AtomToken<typeof this.Update | null>;
159
- constructor(mutableState: MutableAtomToken<Mutable, Serializable>, store: Store);
160
- }
161
-
162
- interface MutableAtom<T> extends Atom<T> {
163
- mutable: true;
164
- }
165
-
166
- type OperationProgress = {
167
- open: false;
168
- } | {
169
- open: true;
170
- done: Set<string>;
171
- prev: Map<string, any>;
172
- time: number;
173
- token: StateToken<any>;
174
- };
175
-
176
- type TimelineAtomUpdate = StateUpdate<unknown> & {
177
- key: string;
178
- type: `atom_update`;
179
- timestamp: number;
180
- family?: FamilyMetadata;
181
- };
182
- type TimelineSelectorUpdate = {
183
- key: string;
184
- type: `selector_update`;
185
- timestamp: number;
186
- atomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[];
187
- };
188
- type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
189
- key: string;
190
- type: `transaction_update`;
191
- timestamp: number;
192
- };
193
- type Timeline = {
194
- type: `timeline`;
195
- key: string;
196
- at: number;
197
- shouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean;
198
- timeTraveling: `into_future` | `into_past` | null;
199
- history: TimelineUpdate[];
200
- selectorTime: number | null;
201
- transactionKey: string | null;
202
- install: (store: Store) => void;
203
- subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
204
- };
205
-
206
- declare class Store implements Lineage {
207
- parent: Store | null;
208
- child: Store | null;
209
- valueMap: Map<string, any>;
210
- atoms: Map<string, Atom<any> | MutableAtom<any>>;
211
- selectors: Map<string, Selector<any>>;
212
- readonlySelectors: Map<string, ReadonlySelector<any>>;
213
- trackers: Map<string, Tracker<Transceiver<any>>>;
214
- families: Map<string, AtomFamily<any, any> | ReadonlySelectorFamily<any, any> | SelectorFamily<any, any>>;
215
- timelines: Map<string, Timeline>;
216
- transactions: Map<string, Transaction<ƒn>>;
217
- atomsThatAreDefault: Set<string>;
218
- timelineAtoms: Junction<"timelineKey", "atomKey", null>;
219
- selectorAtoms: Junction<"selectorKey", "atomKey", null>;
220
- selectorGraph: Junction<"upstreamSelectorKey", "downstreamSelectorKey", {
221
- source: string;
222
- }>;
223
- subject: {
224
- atomCreation: Subject<AtomToken<unknown>>;
225
- selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
226
- transactionCreation: Subject<TransactionToken<ƒn>>;
227
- timelineCreation: Subject<TimelineToken>;
228
- transactionApplying: StatefulSubject<TransactionMeta<ƒn> | null>;
229
- operationStatus: Subject<OperationProgress>;
230
- };
231
- operation: OperationProgress;
232
- transactionMeta: TransactionMeta<ƒn> | null;
233
- config: {
234
- name: string;
235
- };
236
- loggers: AtomIOLogger[];
237
- logger: Logger;
238
- constructor(name: string, store?: Store | null);
239
- }
240
-
241
- type Atom<T> = {
242
- key: string;
243
- type: `atom`;
244
- mutable?: boolean;
245
- family?: FamilyMetadata;
246
- install: (store: Store) => void;
247
- subject: Subject<{
248
- newValue: T;
249
- oldValue: T;
250
- }>;
251
- default: T | (() => T);
252
- cleanup?: () => void;
253
- };
254
-
255
- declare function dict<State, Key extends Serializable>(findState: AtomIO.AtomFamily<State, Key> | AtomIO.ReadonlySelectorFamily<State, Key> | AtomIO.SelectorFamily<State, Key>, index: AtomIO.AtomToken<Key[]> | AtomIO.ReadonlySelectorToken<Key[]> | AtomIO.SelectorToken<Key[]>, store?: Store): AtomIO.ReadonlySelectorToken<{
256
- [K in Stringified<Key>]: State;
257
- }>;
258
-
259
- interface JoinOptions<ASide extends string, BSide extends string, Cardinality extends Cardinality, Content extends Object$1 | null> extends Object$1, JunctionSchema<ASide, BSide>, Partial<JunctionEntries<Content>> {
84
+ interface JoinOptions<ASide extends string, BSide extends string, Cardinality extends Cardinality, Content extends Json.Object | null> extends Json.Object, JunctionSchema<ASide, BSide>, Partial<JunctionEntries<Content>> {
260
85
  readonly key: string;
261
86
  readonly cardinality: Cardinality;
262
87
  }
263
- type JoinState<ASide extends string, BSide extends string, Cardinality extends Cardinality, Content extends Object$1 | null> = Cardinality extends `1:1` ? (Content extends Object$1 ? {
88
+ type JoinState<ASide extends string, BSide extends string, Cardinality extends Cardinality, Content extends Json.Object | null> = Cardinality extends `1:1` ? (Content extends Json.Object ? {
264
89
  readonly [AB in ASide | BSide as AB extends ASide ? `${AB}EntryOf${Capitalize<BSide>}` : `${AB}EntryOf${Capitalize<ASide>}`]: SelectorFamily<[
265
90
  string,
266
91
  Content
267
92
  ] | undefined, string>;
268
93
  } : {}) & {
269
94
  readonly [AB in ASide | BSide as AB extends ASide ? `${AB}KeyOf${Capitalize<BSide>}` : `${AB}KeyOf${Capitalize<ASide>}`]: SelectorFamily<string | undefined, string>;
270
- } : Cardinality extends `1:n` ? (Content extends Object$1 ? {
95
+ } : Cardinality extends `1:n` ? (Content extends Json.Object ? {
271
96
  readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: SelectorFamily<[
272
97
  string,
273
98
  Content
@@ -281,7 +106,7 @@ type JoinState<ASide extends string, BSide extends string, Cardinality extends C
281
106
  readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: SelectorFamily<string | undefined, string>;
282
107
  } & {
283
108
  readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: SelectorFamily<string[], string>;
284
- } : Cardinality extends `n:n` ? (Content extends Object$1 ? {
109
+ } : Cardinality extends `n:n` ? (Content extends Json.Object ? {
285
110
  readonly [AB in ASide | BSide as AB extends ASide ? `${AB}EntriesOf${Capitalize<BSide>}` : `${AB}EntriesOf${Capitalize<ASide>}`]: SelectorFamily<[
286
111
  string,
287
112
  Content
@@ -293,7 +118,7 @@ declare function join<const ASide extends string, const BSide extends string, co
293
118
  relations: Junction<ASide, BSide>;
294
119
  findState: JoinState<ASide, BSide, Cardinality, null>;
295
120
  };
296
- declare function join<const ASide extends string, const Cardinality extends `1:1` | `1:n` | `n:n`, const BSide extends string, const Content extends Object$1>(options: JoinOptions<ASide, BSide, Cardinality, Content>, defaultContent: Content, store?: Store): {
121
+ declare function join<const ASide extends string, const Cardinality extends `1:1` | `1:n` | `n:n`, const BSide extends string, const Content extends Json.Object>(options: JoinOptions<ASide, BSide, Cardinality, Content>, defaultContent: Content, store?: Store): {
297
122
  relations: Junction<ASide, BSide, Content>;
298
123
  findState: JoinState<ASide, BSide, Cardinality, Content>;
299
124
  };
@@ -0,0 +1,245 @@
1
+ import * as Internal from 'atom.io/internal';
2
+ import { Transceiver, Subject, Store, Timeline, TimelineAtomUpdate, TimelineSelectorUpdate, TimelineTransactionUpdate } from 'atom.io/internal';
3
+ import { Json, JsonInterface } from 'atom.io/json';
4
+
5
+ type Effectors<T> = {
6
+ setSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void;
7
+ onSet: (callback: (options: {
8
+ newValue: T;
9
+ oldValue: T;
10
+ }) => void) => void;
11
+ };
12
+ type AtomEffect<T> = (tools: Effectors<T>) => (() => void) | void;
13
+ type AtomOptions<T> = {
14
+ key: string;
15
+ default: T | (() => T);
16
+ effects?: AtomEffect<T>[];
17
+ };
18
+ type MutableAtomOptions<T extends Transceiver<any>, J extends Json.Serializable> = JsonInterface<T, J> & Omit<AtomOptions<T>, `default`> & {
19
+ default: () => T;
20
+ mutable: true;
21
+ };
22
+ declare function atom<T extends Transceiver<any>, J extends Json.Serializable>(options: MutableAtomOptions<T, J>): MutableAtomToken<T, J>;
23
+ declare function atom<T>(options: AtomOptions<T>): AtomToken<T>;
24
+ type AtomFamilyOptions<T, K extends Json.Serializable> = {
25
+ key: string;
26
+ default: T | ((key: K) => T);
27
+ effects?: (key: K) => AtomEffect<T>[];
28
+ };
29
+ type AtomFamily<T, K extends Json.Serializable = Json.Serializable> = ((key: K) => AtomToken<T>) & {
30
+ key: string;
31
+ type: `atom_family`;
32
+ subject: Subject<AtomToken<T>>;
33
+ mutable?: boolean;
34
+ };
35
+ type MutableAtomFamilyOptions<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable> = AtomFamilyOptions<T, K> & JsonInterface<T, J> & {
36
+ mutable: true;
37
+ };
38
+ type MutableAtomFamily<Core extends Transceiver<any>, SerializableCore extends Json.Serializable, Key extends Json.Serializable> = JsonInterface<Core, SerializableCore> & ((key: Key) => MutableAtomToken<Core, SerializableCore>) & {
39
+ key: `${string}`;
40
+ type: `atom_family`;
41
+ subject: Subject<MutableAtomToken<Core, SerializableCore>>;
42
+ mutable: true;
43
+ };
44
+ declare function atomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable>(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamily<T, J, K>;
45
+ declare function atomFamily<T, K extends Json.Serializable>(options: AtomFamilyOptions<T, K>): AtomFamily<T, K>;
46
+
47
+ declare function dispose(token: ReadonlySelectorToken<any> | StateToken<any>, store?: Internal.Store): void;
48
+
49
+ declare function getState<T>(token: ReadonlySelectorToken<T> | StateToken<T>, store?: Internal.Store): T;
50
+
51
+ declare const LoggerIconDictionary: {
52
+ readonly "\u231B": "Timeline event fully captured";
53
+ readonly "\u23E9": "Timeline redo";
54
+ readonly "\u23EA": "Timeline undo";
55
+ readonly "\u23ED\uFE0F": "Transaction redo";
56
+ readonly "\u23EE\uFE0F": "Transaction undo";
57
+ readonly "\u23F3": "Timeline event partially captured";
58
+ readonly "\u23F9\uFE0F": "Time-travel complete";
59
+ readonly "\uD83D\uDC81": "Notice";
60
+ readonly "\uD83D\uDD04": "Realtime transaction synchronized";
61
+ readonly "\u2705": "Realtime transaction success";
62
+ readonly "\u2728": "Computation complete";
63
+ readonly "\u274C": "Conflict prevents attempted action";
64
+ readonly "\u2B55": "Operation start";
65
+ readonly "\uD83D\uDC1E": "Possible bug in AtomIO";
66
+ readonly "\uD83D\uDC40": "Subscription added";
67
+ readonly "\uD83D\uDC6A": "Family member added";
68
+ readonly "\uD83D\uDCC1": "Stow update";
69
+ readonly "\uD83D\uDCC3": "Copy mutable";
70
+ readonly "\uD83D\uDCD6": "Read state";
71
+ readonly "\uD83D\uDCDD": "Write state";
72
+ readonly "\uD83D\uDCE2": "Notify subscribers";
73
+ readonly "\uD83D\uDD0C": "Register dependency";
74
+ readonly "\uD83D\uDD0D": "Discover root";
75
+ readonly "\uD83D\uDD25": "Delete state";
76
+ readonly "\uD83D\uDD27": "Create mutable atom";
77
+ readonly "\uD83D\uDD28": "Create immutable atom";
78
+ readonly "\uD83D\uDD34": "Operation complete";
79
+ readonly "\uD83D\uDDD1": "Evict cached value";
80
+ readonly "\uD83D\uDCA5": "Caught";
81
+ readonly "\uD83D\uDE48": "Subscription canceled";
82
+ readonly "\uD83D\uDEC4": "Apply transaction";
83
+ readonly "\uD83D\uDEE0\uFE0F": "Install atom into store";
84
+ readonly "\uD83D\uDEEB": "Begin transaction";
85
+ readonly "\uD83D\uDEEC": "Complete transaction";
86
+ readonly "\uD83E\uDDEE": "Computing selector";
87
+ readonly "\uD83E\uDDF9": "Prepare to evict";
88
+ readonly "\uD83E\uDE82": "Abort transaction";
89
+ };
90
+ type LoggerIcon = keyof typeof LoggerIconDictionary;
91
+ declare const LOG_LEVELS: readonly ["info", "warn", "error"];
92
+ type LogLevel = (typeof LOG_LEVELS)[number];
93
+ type LogFn = (icon: LoggerIcon, tokenType: `atom` | `readonly_selector` | `selector` | `state` | `timeline` | `transaction` | `unknown`, tokenKey: string, message: string, ...rest: unknown[]) => void;
94
+ type LogFilter = (...params: Parameters<LogFn>) => boolean;
95
+ type Logger = Record<LogLevel, LogFn>;
96
+ declare const simpleLog: (logLevel: keyof Logger) => LogFn;
97
+ declare const simpleLogger: Logger;
98
+ declare class AtomIOLogger implements Logger {
99
+ logLevel: `error` | `info` | `warn` | null;
100
+ private readonly filter?;
101
+ private readonly logger;
102
+ constructor(logLevel: `error` | `info` | `warn` | null, filter?: LogFilter | undefined, logger?: Logger);
103
+ error: LogFn;
104
+ info: LogFn;
105
+ warn: LogFn;
106
+ }
107
+
108
+ type TransactionToken<_> = {
109
+ key: string;
110
+ type: `transaction`;
111
+ __brand?: _;
112
+ };
113
+ type TransactionUpdate<ƒ extends ƒn> = {
114
+ key: string;
115
+ updates: (KeyedStateUpdate<unknown> | TransactionUpdate<ƒn>)[];
116
+ params: Parameters<ƒ>;
117
+ output: ReturnType<ƒ>;
118
+ };
119
+ type Transactors = {
120
+ get: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S;
121
+ set: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void;
122
+ };
123
+ type ReadonlyTransactors = Pick<Transactors, `get`>;
124
+ type Read<ƒ extends ƒn> = (transactors: ReadonlyTransactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
125
+ type Write<ƒ extends ƒn> = (transactors: Transactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
126
+ type Act<ƒ extends ƒn> = (transactors: Transactors & {
127
+ run: typeof runTransaction;
128
+ }, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
129
+ type TransactionOptions<ƒ extends ƒn> = {
130
+ key: string;
131
+ do: Act<ƒ>;
132
+ };
133
+ type TransactionIO<Token extends TransactionToken<any>> = Token extends TransactionToken<infer ƒ> ? ƒ : never;
134
+ declare function transaction<ƒ extends ƒn>(options: TransactionOptions<ƒ>): TransactionToken<ƒ>;
135
+ declare const runTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, store?: Store) => (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
136
+
137
+ type SelectorOptions<T> = {
138
+ key: string;
139
+ get: Read<() => T>;
140
+ set: Write<(newValue: T) => void>;
141
+ };
142
+ type ReadonlySelectorOptions<T> = {
143
+ key: string;
144
+ get: Read<() => T>;
145
+ };
146
+ declare function selector<T>(options: SelectorOptions<T>): SelectorToken<T>;
147
+ declare function selector<T>(options: ReadonlySelectorOptions<T>): ReadonlySelectorToken<T>;
148
+ type SelectorFamilyOptions<T, K extends Json.Serializable> = {
149
+ key: string;
150
+ get: (key: K) => Read<() => T>;
151
+ set: (key: K) => Write<(newValue: T) => void>;
152
+ };
153
+ type ReadonlySelectorFamilyOptions<T, K extends Json.Serializable> = {
154
+ key: string;
155
+ get: (key: K) => Read<() => T>;
156
+ };
157
+ type SelectorFamily<T, K extends Json.Serializable = Json.Serializable> = ((key: K) => SelectorToken<T>) & {
158
+ key: string;
159
+ type: `selector_family`;
160
+ subject: Subject<SelectorToken<T>>;
161
+ };
162
+ type ReadonlySelectorFamily<T, K extends Json.Serializable = Json.Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
163
+ key: string;
164
+ type: `readonly_selector_family`;
165
+ subject: Subject<ReadonlySelectorToken<T>>;
166
+ };
167
+ declare function selectorFamily<T, K extends Json.Serializable>(options: SelectorFamilyOptions<T, K>): SelectorFamily<T, K>;
168
+ declare function selectorFamily<T, K extends Json.Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamily<T, K>;
169
+
170
+ declare function setState<T, New extends T>(token: StateToken<T>, value: New | ((oldValue: T) => New), store?: Internal.Store): void;
171
+
172
+ declare class Silo {
173
+ store: Store;
174
+ atom: typeof atom;
175
+ atomFamily: typeof atomFamily;
176
+ selector: typeof selector;
177
+ selectorFamily: typeof selectorFamily;
178
+ transaction: typeof transaction;
179
+ timeline: typeof timeline;
180
+ getState: typeof getState;
181
+ setState: typeof setState;
182
+ subscribe: typeof subscribe;
183
+ undo: typeof undo;
184
+ redo: typeof redo;
185
+ constructor(name: string, fromStore?: Store | null);
186
+ }
187
+
188
+ type StateUpdate<T> = {
189
+ newValue: T;
190
+ oldValue: T;
191
+ };
192
+ type KeyedStateUpdate<T> = StateUpdate<T> & {
193
+ key: string;
194
+ family?: FamilyMetadata;
195
+ };
196
+ type UpdateHandler<T> = (update: StateUpdate<T>) => void;
197
+ type TransactionUpdateHandler<ƒ extends ƒn> = (data: TransactionUpdate<ƒ>) => void;
198
+ declare function subscribe<T>(token: ReadonlySelectorToken<T> | StateToken<T>, handleUpdate: UpdateHandler<T>, key?: string, store?: Store): () => void;
199
+ declare function subscribe<ƒ extends ƒn>(token: TransactionToken<ƒ>, handleUpdate: TransactionUpdateHandler<ƒ>, key?: string, store?: Store): () => void;
200
+ declare function subscribe(token: TimelineToken, handleUpdate: (update: TimelineUpdate | `redo` | `undo`) => void, key?: string, store?: Store): () => void;
201
+
202
+ type TimelineToken = {
203
+ key: string;
204
+ type: `timeline`;
205
+ };
206
+ type TimelineOptions = {
207
+ key: string;
208
+ atoms: (AtomFamily<any, any> | AtomToken<any>)[];
209
+ shouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean;
210
+ };
211
+ type TimelineUpdate = TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate;
212
+ declare const timeline: (options: TimelineOptions) => TimelineToken;
213
+ declare const redo: (timeline: TimelineToken) => void;
214
+ declare const undo: (timeline: TimelineToken) => void;
215
+
216
+ type ƒn = (...parameters: any[]) => any;
217
+ type AtomToken<_> = {
218
+ key: string;
219
+ type: `atom`;
220
+ family?: FamilyMetadata;
221
+ __brand?: _;
222
+ };
223
+ interface MutableAtomToken<T extends Transceiver<any>, J extends Json.Serializable> extends AtomToken<T> {
224
+ __asJSON?: J;
225
+ __update?: T extends Transceiver<infer Update> ? Update : never;
226
+ }
227
+ type SelectorToken<_> = {
228
+ key: string;
229
+ type: `selector`;
230
+ family?: FamilyMetadata;
231
+ __brand?: _;
232
+ };
233
+ type StateToken<T> = AtomToken<T> | SelectorToken<T>;
234
+ type ReadonlySelectorToken<_> = {
235
+ key: string;
236
+ type: `readonly_selector`;
237
+ family?: FamilyMetadata;
238
+ __brand?: _;
239
+ };
240
+ type FamilyMetadata = {
241
+ key: string;
242
+ subKey: string;
243
+ };
244
+
245
+ export { type Act, type AtomEffect, type AtomFamily, type AtomFamilyOptions, AtomIOLogger, type AtomOptions, type AtomToken, type Effectors, type FamilyMetadata, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MutableAtomFamily, type MutableAtomFamilyOptions, type MutableAtomOptions, type MutableAtomToken, type Read, type ReadonlySelectorFamily, type ReadonlySelectorFamilyOptions, type ReadonlySelectorOptions, type ReadonlySelectorToken, type ReadonlyTransactors, type SelectorFamily, type SelectorFamilyOptions, type SelectorOptions, type SelectorToken, Silo, type StateToken, type StateUpdate, type TimelineOptions, type TimelineToken, type TimelineUpdate, type TransactionIO, type TransactionOptions, type TransactionToken, type TransactionUpdate, type TransactionUpdateHandler, type Transactors, type UpdateHandler, type Write, atom, atomFamily, dispose, getState, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo, type ƒn };
@@ -1,4 +1,6 @@
1
1
  import { FamilyMetadata, SelectorOptions, SelectorToken, ReadonlySelectorOptions, ReadonlySelectorToken, Transactors, StateToken, ƒn, TransactionUpdate, TransactionOptions, TransactionToken, AtomToken, MutableAtomOptions, MutableAtomToken, MutableAtomFamilyOptions, MutableAtomFamily, SelectorFamily, AtomFamily, StateUpdate, TimelineUpdate, TimelineOptions, TimelineToken, ReadonlySelectorFamily, AtomIOLogger, Logger, AtomOptions, AtomFamilyOptions, ReadonlySelectorFamilyOptions, SelectorFamilyOptions, UpdateHandler, TransactionUpdateHandler } from 'atom.io';
2
+ import { Json } from 'atom.io/json';
3
+ import { Store as Store$1 } from 'atom.io/internal';
2
4
 
3
5
  declare class Subject<T> {
4
6
  Subscriber: (value: T) => void;
@@ -183,28 +185,28 @@ interface Lineage {
183
185
  declare function newest<T extends Lineage>(scion: T): T;
184
186
  declare function eldest<T extends Lineage>(scion: T): T;
185
187
 
186
- interface Transceiver<Signal extends Serializable> {
188
+ interface Transceiver<Signal extends Json.Serializable> {
187
189
  do: (update: Signal) => void;
188
190
  undo: (update: Signal) => void;
189
191
  subscribe: (key: string, fn: (update: Signal) => void) => () => void;
190
192
  cacheUpdateNumber: number;
191
193
  getUpdateNumber: (update: Signal) => number;
192
194
  }
193
- declare function isTransceiver(value: unknown): value is Transceiver<Serializable>;
195
+ declare function isTransceiver(value: unknown): value is Transceiver<Json.Serializable>;
194
196
  type TransceiverMode = `playback` | `record` | `transaction`;
195
197
  type Signal<TVR extends Transceiver<any>> = TVR extends Transceiver<infer Signal> ? Signal : never;
196
198
 
197
- declare function createMutableAtom<Core extends Transceiver<any>, SerializableCore extends Serializable>(options: MutableAtomOptions<Core, SerializableCore>, store: Store): MutableAtomToken<Core, SerializableCore>;
199
+ declare function createMutableAtom<Core extends Transceiver<any>, SerializableCore extends Json.Serializable>(options: MutableAtomOptions<Core, SerializableCore>, store: Store): MutableAtomToken<Core, SerializableCore>;
198
200
 
199
- declare function createMutableAtomFamily<Core extends Transceiver<any>, SerializableCore extends Serializable, Key extends string>(options: MutableAtomFamilyOptions<Core, SerializableCore, Key>, store: Store): MutableAtomFamily<Core, SerializableCore, Key>;
201
+ declare function createMutableAtomFamily<Core extends Transceiver<any>, SerializableCore extends Json.Serializable, Key extends string>(options: MutableAtomFamilyOptions<Core, SerializableCore, Key>, store: Store): MutableAtomFamily<Core, SerializableCore, Key>;
200
202
 
201
- declare const getJsonFamily: <Core extends Transceiver<Serializable>, SerializableCore extends Serializable, Key extends string>(mutableAtomFamily: MutableAtomFamily<Core, SerializableCore, Key>, store: Store) => SelectorFamily<SerializableCore, Key>;
203
+ declare const getJsonFamily: <Core extends Transceiver<Json.Serializable>, SerializableCore extends Json.Serializable, Key extends string>(mutableAtomFamily: MutableAtomFamily<Core, SerializableCore, Key>, store: Store) => SelectorFamily<SerializableCore, Key>;
202
204
 
203
- declare const getJsonToken: <Core extends Transceiver<Serializable>, SerializableCore extends Serializable>(mutableAtomToken: MutableAtomToken<Core, SerializableCore>) => SelectorToken<SerializableCore>;
205
+ declare const getJsonToken: <Core extends Transceiver<Json.Serializable>, SerializableCore extends Json.Serializable>(mutableAtomToken: MutableAtomToken<Core, SerializableCore>) => SelectorToken<SerializableCore>;
204
206
 
205
- declare const getUpdateToken: <Core extends Transceiver<Serializable>, SerializableCore extends Serializable>(mutableAtomToken: MutableAtomToken<Core, SerializableCore>) => AtomToken<Signal<Core>>;
207
+ declare const getUpdateToken: <Core extends Transceiver<Json.Serializable>, SerializableCore extends Json.Serializable>(mutableAtomToken: MutableAtomToken<Core, SerializableCore>) => AtomToken<Signal<Core>>;
206
208
 
207
- declare const getUpdateFamily: <Core extends Transceiver<Serializable>, SerializableCore extends Serializable, Key extends string>(mutableAtomFamily: MutableAtomFamily<Core, SerializableCore, Key>, store: Store) => AtomFamily<Signal<Core> | null, Key>;
209
+ declare const getUpdateFamily: <Core extends Transceiver<Json.Serializable>, SerializableCore extends Json.Serializable, Key extends string>(mutableAtomFamily: MutableAtomFamily<Core, SerializableCore, Key>, store: Store) => AtomFamily<Signal<Core> | null, Key>;
208
210
 
209
211
  /**
210
212
  * @internal Give the tracker a transceiver state and a store, and it will
@@ -217,12 +219,12 @@ declare class Tracker<Mutable extends Transceiver<any>> {
217
219
  private unsubscribeFromInnerValue;
218
220
  private observeCore;
219
221
  private updateCore;
220
- mutableState: MutableAtomToken<Mutable, Serializable>;
222
+ mutableState: MutableAtomToken<Mutable, Json.Serializable>;
221
223
  latestUpdateState: AtomToken<typeof this.Update | null>;
222
- constructor(mutableState: MutableAtomToken<Mutable, Serializable>, store: Store);
224
+ constructor(mutableState: MutableAtomToken<Mutable, Json.Serializable>, store: Store);
223
225
  }
224
226
 
225
- declare class FamilyTracker<Core extends Transceiver<any>, FamilyMemberKey extends Serializable> {
227
+ declare class FamilyTracker<Core extends Transceiver<any>, FamilyMemberKey extends Json.Serializable> {
226
228
  private readonly Update;
227
229
  readonly findLatestUpdateState: AtomFamily<typeof this.Update | null, FamilyMemberKey>;
228
230
  readonly findMutableState: AtomFamily<Core, FamilyMemberKey>;
@@ -379,12 +381,12 @@ declare const readCachedValue: <T>(key: string, store: Store) => T;
379
381
  declare const isValueCached: (key: string, store: Store) => boolean;
380
382
  declare const evictCachedValue: (key: string, store: Store) => void;
381
383
 
382
- declare function createAtomFamily<T, K extends Serializable>(options: AtomFamilyOptions<T, K>, store: Store): AtomFamily<T, K>;
384
+ declare function createAtomFamily<T, K extends Json.Serializable>(options: AtomFamilyOptions<T, K>, store: Store): AtomFamily<T, K>;
383
385
 
384
- declare function createReadonlySelectorFamily<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>, store: Store): ReadonlySelectorFamily<T, K>;
386
+ declare function createReadonlySelectorFamily<T, K extends Json.Serializable>(options: ReadonlySelectorFamilyOptions<T, K>, store: Store): ReadonlySelectorFamily<T, K>;
385
387
 
386
- declare function createSelectorFamily<T, K extends Serializable>(options: SelectorFamilyOptions<T, K>, store: Store): SelectorFamily<T, K>;
387
- declare function createSelectorFamily<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>, store: Store): ReadonlySelectorFamily<T, K>;
388
+ declare function createSelectorFamily<T, K extends Json.Serializable>(options: SelectorFamilyOptions<T, K>, store: Store): SelectorFamily<T, K>;
389
+ declare function createSelectorFamily<T, K extends Json.Serializable>(options: ReadonlySelectorFamilyOptions<T, K>, store: Store): ReadonlySelectorFamily<T, K>;
388
390
 
389
391
  declare class LazyMap<K, V> extends Map<K, V> {
390
392
  protected readonly source: Map<K, V>;
@@ -410,10 +412,10 @@ declare const setAtomOrSelector: <T>(state: Atom<T> | Selector<T>, value: T | ((
410
412
 
411
413
  declare const subscribeToRootAtoms: <T>(state: ReadonlySelector<T> | Selector<T>, store: Store) => (() => void)[] | null;
412
414
 
413
- declare function subscribeToState<T>(token: ReadonlySelectorToken<T> | StateToken<T>, handleUpdate: UpdateHandler<T>, key: string, store: Store): () => void;
415
+ declare function subscribeToState<T>(token: ReadonlySelectorToken<T> | StateToken<T>, handleUpdate: UpdateHandler<T>, key: string, store: Store$1): () => void;
414
416
 
415
- declare const subscribeToTimeline: (token: TimelineToken, handleUpdate: (update: TimelineUpdate | `redo` | `undo`) => void, key: string, store: Store) => (() => void);
417
+ declare const subscribeToTimeline: (token: TimelineToken, handleUpdate: (update: TimelineUpdate | `redo` | `undo`) => void, key: string, store: Store$1) => (() => void);
416
418
 
417
- declare const subscribeToTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, handleUpdate: TransactionUpdateHandler<ƒ>, key: string, store: Store) => (() => void);
419
+ declare const subscribeToTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, handleUpdate: TransactionUpdateHandler<ƒ>, key: string, store: Store$1) => (() => void);
418
420
 
419
421
  export { type Atom, type AtomKey, FamilyTracker, Future, IMPLICIT, LazyMap, type Lineage, type Modify, type MutableAtom, NotFoundError, type OperationProgress, type ReadonlySelector, type ReadonlySelectorKey, type Selector, type SelectorKey, type Signal, type StateKey, StatefulSubject, Store, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineSelectorUpdate, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionMeta, type TransactionPhase, type Transceiver, type TransceiverMode, abortTransaction, addAtomToTimeline, applyTransaction, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtom, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelectorFamily, createSelector, createSelectorFamily, createTimeline, createTransaction, deleteAtom, deleteSelector, deposit, eldest, evictCachedValue, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateFamily, getUpdateToken, isAtomDefault, isAtomKey, isDone, isReadonlySelectorKey, isSelectorDefault, isSelectorKey, isStateKey, isTransceiver, isValueCached, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, readCachedValue, readOrComputeValue, redoTransactionUpdate, registerSelector, setAtomOrSelector, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, undoTransactionUpdate, updateSelectorAtoms, withdraw, withdrawNewFamilyMember };