atom.io 0.14.5 → 0.14.6

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,267 +1,22 @@
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 * as Internal from 'atom.io/internal';
3
+ import { Store, Transceiver } from 'atom.io/internal';
4
+ import { Json } from 'atom.io/json';
3
5
  import { Socket } from 'socket.io-client';
4
6
 
5
7
  declare const myIdState__INTERNAL: AtomIO.AtomToken<string | null>;
6
8
  declare const myIdState: AtomIO.ReadonlySelectorToken<string | null>;
7
9
 
8
- declare class Subject<T> {
9
- Subscriber: (value: T) => void;
10
- subscribers: Map<string, this[`Subscriber`]>;
11
- subscribe(key: string, subscriber: this[`Subscriber`]): () => void;
12
- private unsubscribe;
13
- next(value: T): void;
14
- }
15
- declare class StatefulSubject<T> extends Subject<T> {
16
- state: T;
17
- constructor(initialState: T);
18
- next(value: T): void;
19
- }
10
+ declare function pullState<J extends Json.Serializable>(token: AtomIO.StateToken<J>, socket: Socket, store: Store): () => void;
20
11
 
21
- type Selector<T> = {
22
- key: string;
23
- type: `selector`;
24
- family?: FamilyMetadata;
25
- install: (store: Store) => void;
26
- subject: Subject<{
27
- newValue: T;
28
- oldValue: T;
29
- }>;
30
- get: () => T;
31
- set: (newValue: T | ((oldValue: T) => T)) => void;
32
- };
33
- type ReadonlySelector<T> = {
34
- key: string;
35
- type: `readonly_selector`;
36
- family?: FamilyMetadata;
37
- install: (store: Store) => void;
38
- subject: Subject<{
39
- newValue: T;
40
- oldValue: T;
41
- }>;
42
- get: () => T;
43
- };
12
+ declare function pullFamilyMember<J extends Json.Serializable>(token: AtomIO.AtomToken<J>, socket: Socket, store: Store): () => void;
44
13
 
45
- type Transaction<ƒ extends ƒn> = {
46
- key: string;
47
- type: `transaction`;
48
- install: (store: Store) => void;
49
- subject: Subject<TransactionUpdate<ƒ>>;
50
- run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
51
- };
14
+ declare function pullMutableState<T extends Transceiver<Json.Serializable>, J extends Json.Serializable>(token: AtomIO.MutableAtomToken<T, J>, socket: Socket, store: Store): () => void;
52
15
 
53
- type TransactionMeta<ƒ extends ƒn> = {
54
- phase: `applying` | `building`;
55
- time: number;
56
- update: TransactionUpdate<ƒ>;
57
- };
16
+ declare function pullMutableFamilyMember<T extends Transceiver<Json.Serializable>, J extends Json.Serializable>(token: AtomIO.MutableAtomToken<T, J>, socket: Socket, store: Store): () => void;
58
17
 
59
- type primitive = boolean | number | string | null;
18
+ declare function pushState<J extends Json.Serializable>(token: AtomIO.StateToken<J>, socket: Socket, subscriptionKey: string, store: Internal.Store): () => void;
60
19
 
61
- type Serializable = primitive | Readonly<{
62
- [key: string]: Serializable;
63
- }> | ReadonlyArray<Serializable>;
64
- type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
65
-
66
- type Refinement<Unrefined, Refined extends Unrefined> = (value: Unrefined) => value is Refined;
67
- type Cardinality = `1:1` | `1:n` | `n:n`;
68
-
69
- interface JunctionEntries<Content extends Object$1 | null> extends Object$1 {
70
- readonly relations: [string, string[]][];
71
- readonly contents: [string, Content][];
72
- }
73
- interface JunctionSchema<ASide extends string, BSide extends string> extends Object$1 {
74
- readonly between: [a: ASide, b: BSide];
75
- readonly cardinality: Cardinality;
76
- }
77
- type BaseExternalStoreConfiguration = {
78
- addRelation: (a: string, b: string) => void;
79
- deleteRelation: (a: string, b: string) => void;
80
- replaceRelationsSafely: (a: string, bs: string[]) => void;
81
- replaceRelationsUnsafely: (a: string, bs: string[]) => void;
82
- getRelatedKeys: (key: string) => Set<string> | undefined;
83
- has: (a: string, b?: string) => boolean;
84
- };
85
- type ExternalStoreWithContentConfiguration<Content extends Object$1> = {
86
- getContent: (contentKey: string) => Content | undefined;
87
- setContent: (contentKey: string, content: Content) => void;
88
- deleteContent: (contentKey: string) => void;
89
- };
90
- type Empty<Obj extends object> = {
91
- [Key in keyof Obj]?: undefined;
92
- };
93
- type ExternalStoreConfiguration<Content extends Object$1 | null> = Content extends Object$1 ? BaseExternalStoreConfiguration & ExternalStoreWithContentConfiguration<Content> : BaseExternalStoreConfiguration & Empty<ExternalStoreWithContentConfiguration<Object$1>>;
94
- type JunctionAdvancedConfiguration<Content extends Object$1 | null> = {
95
- externalStore?: ExternalStoreConfiguration<Content>;
96
- isContent?: Refinement<unknown, Content>;
97
- makeContentKey?: (a: string, b: string) => string;
98
- };
99
- type JunctionJSON<ASide extends string, BSide extends string, Content extends Object$1 | null> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>;
100
- declare class Junction<const ASide extends string, const BSide extends string, const Content extends Object$1 | null = null> {
101
- readonly a: ASide;
102
- readonly b: BSide;
103
- readonly cardinality: Cardinality;
104
- readonly relations: Map<string, Set<string>>;
105
- readonly contents: Map<string, Content>;
106
- isContent: Refinement<unknown, Content> | null;
107
- makeContentKey: (a: string, b: string) => string;
108
- getRelatedKeys(key: string): Set<string> | undefined;
109
- protected addRelation(a: string, b: string): void;
110
- protected deleteRelation(a: string, b: string): void;
111
- protected replaceRelationsUnsafely(a: string, bs: string[]): void;
112
- protected replaceRelationsSafely(a: string, bs: string[]): void;
113
- protected getContentInternal(contentKey: string): Content | undefined;
114
- protected setContent(contentKey: string, content: Content): void;
115
- protected deleteContent(contentKey: string): void;
116
- constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<Content>>, config?: JunctionAdvancedConfiguration<Content>);
117
- toJSON(): JunctionJSON<ASide, BSide, Content>;
118
- set(a: string, ...rest: Content extends null ? [b: string] : [b: string, content: Content]): this;
119
- set(relation: {
120
- [Key in ASide | BSide]: string;
121
- }, ...rest: Content extends null ? [] | [b?: undefined] : [content: Content]): this;
122
- delete(a: string, b?: string): this;
123
- delete(relation: Record<ASide | BSide, string> | Record<ASide, string> | Record<BSide, string>, b?: undefined): this;
124
- getRelatedKey(key: string): string | undefined;
125
- replaceRelations(a: string, relations: Content extends null ? string[] : Record<string, Content>, config?: {
126
- reckless: boolean;
127
- }): this;
128
- getContent(a: string, b: string): Content | undefined;
129
- getRelationEntries(input: Record<ASide, string> | Record<BSide, string>): [string, Content][];
130
- has(a: string, b?: string): boolean;
131
- }
132
-
133
- interface Lineage {
134
- parent: typeof this | null;
135
- child: typeof this | null;
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 pullState<J extends Serializable>(token: AtomIO.StateToken<J>, socket: Socket, store: Store): () => void;
256
-
257
- declare function pullFamilyMember<J extends Serializable>(token: AtomIO.AtomToken<J>, socket: Socket, store: Store): () => void;
258
-
259
- declare function pullMutableState<T extends Transceiver<Serializable>, J extends Serializable>(token: AtomIO.MutableAtomToken<T, J>, socket: Socket, store: Store): () => void;
260
-
261
- declare function pullMutableFamilyMember<T extends Transceiver<Serializable>, J extends Serializable>(token: AtomIO.MutableAtomToken<T, J>, socket: Socket, store: Store): () => void;
262
-
263
- declare function pushState<J extends Serializable>(token: AtomIO.StateToken<J>, socket: Socket, subscriptionKey: string, store: Store): () => void;
264
-
265
- declare function synchronizeTransactionResults(token: AtomIO.TransactionToken<any>, socket: Socket, store: Store): () => void;
20
+ declare function synchronizeTransactionResults(token: AtomIO.TransactionToken<any>, socket: Socket, store: Internal.Store): () => void;
266
21
 
267
22
  export { myIdState, myIdState__INTERNAL, pullFamilyMember, pullMutableFamilyMember, pullMutableState, pullState, pushState, synchronizeTransactionResults };
@@ -1,267 +1,22 @@
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 * as Internal from 'atom.io/internal';
3
+ import { Store, Transceiver } from 'atom.io/internal';
4
+ import { Json } from 'atom.io/json';
3
5
  import { Socket } from 'socket.io-client';
4
6
 
5
7
  declare const myIdState__INTERNAL: AtomIO.AtomToken<string | null>;
6
8
  declare const myIdState: AtomIO.ReadonlySelectorToken<string | null>;
7
9
 
8
- declare class Subject<T> {
9
- Subscriber: (value: T) => void;
10
- subscribers: Map<string, this[`Subscriber`]>;
11
- subscribe(key: string, subscriber: this[`Subscriber`]): () => void;
12
- private unsubscribe;
13
- next(value: T): void;
14
- }
15
- declare class StatefulSubject<T> extends Subject<T> {
16
- state: T;
17
- constructor(initialState: T);
18
- next(value: T): void;
19
- }
10
+ declare function pullState<J extends Json.Serializable>(token: AtomIO.StateToken<J>, socket: Socket, store: Store): () => void;
20
11
 
21
- type Selector<T> = {
22
- key: string;
23
- type: `selector`;
24
- family?: FamilyMetadata;
25
- install: (store: Store) => void;
26
- subject: Subject<{
27
- newValue: T;
28
- oldValue: T;
29
- }>;
30
- get: () => T;
31
- set: (newValue: T | ((oldValue: T) => T)) => void;
32
- };
33
- type ReadonlySelector<T> = {
34
- key: string;
35
- type: `readonly_selector`;
36
- family?: FamilyMetadata;
37
- install: (store: Store) => void;
38
- subject: Subject<{
39
- newValue: T;
40
- oldValue: T;
41
- }>;
42
- get: () => T;
43
- };
12
+ declare function pullFamilyMember<J extends Json.Serializable>(token: AtomIO.AtomToken<J>, socket: Socket, store: Store): () => void;
44
13
 
45
- type Transaction<ƒ extends ƒn> = {
46
- key: string;
47
- type: `transaction`;
48
- install: (store: Store) => void;
49
- subject: Subject<TransactionUpdate<ƒ>>;
50
- run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
51
- };
14
+ declare function pullMutableState<T extends Transceiver<Json.Serializable>, J extends Json.Serializable>(token: AtomIO.MutableAtomToken<T, J>, socket: Socket, store: Store): () => void;
52
15
 
53
- type TransactionMeta<ƒ extends ƒn> = {
54
- phase: `applying` | `building`;
55
- time: number;
56
- update: TransactionUpdate<ƒ>;
57
- };
16
+ declare function pullMutableFamilyMember<T extends Transceiver<Json.Serializable>, J extends Json.Serializable>(token: AtomIO.MutableAtomToken<T, J>, socket: Socket, store: Store): () => void;
58
17
 
59
- type primitive = boolean | number | string | null;
18
+ declare function pushState<J extends Json.Serializable>(token: AtomIO.StateToken<J>, socket: Socket, subscriptionKey: string, store: Internal.Store): () => void;
60
19
 
61
- type Serializable = primitive | Readonly<{
62
- [key: string]: Serializable;
63
- }> | ReadonlyArray<Serializable>;
64
- type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
65
-
66
- type Refinement<Unrefined, Refined extends Unrefined> = (value: Unrefined) => value is Refined;
67
- type Cardinality = `1:1` | `1:n` | `n:n`;
68
-
69
- interface JunctionEntries<Content extends Object$1 | null> extends Object$1 {
70
- readonly relations: [string, string[]][];
71
- readonly contents: [string, Content][];
72
- }
73
- interface JunctionSchema<ASide extends string, BSide extends string> extends Object$1 {
74
- readonly between: [a: ASide, b: BSide];
75
- readonly cardinality: Cardinality;
76
- }
77
- type BaseExternalStoreConfiguration = {
78
- addRelation: (a: string, b: string) => void;
79
- deleteRelation: (a: string, b: string) => void;
80
- replaceRelationsSafely: (a: string, bs: string[]) => void;
81
- replaceRelationsUnsafely: (a: string, bs: string[]) => void;
82
- getRelatedKeys: (key: string) => Set<string> | undefined;
83
- has: (a: string, b?: string) => boolean;
84
- };
85
- type ExternalStoreWithContentConfiguration<Content extends Object$1> = {
86
- getContent: (contentKey: string) => Content | undefined;
87
- setContent: (contentKey: string, content: Content) => void;
88
- deleteContent: (contentKey: string) => void;
89
- };
90
- type Empty<Obj extends object> = {
91
- [Key in keyof Obj]?: undefined;
92
- };
93
- type ExternalStoreConfiguration<Content extends Object$1 | null> = Content extends Object$1 ? BaseExternalStoreConfiguration & ExternalStoreWithContentConfiguration<Content> : BaseExternalStoreConfiguration & Empty<ExternalStoreWithContentConfiguration<Object$1>>;
94
- type JunctionAdvancedConfiguration<Content extends Object$1 | null> = {
95
- externalStore?: ExternalStoreConfiguration<Content>;
96
- isContent?: Refinement<unknown, Content>;
97
- makeContentKey?: (a: string, b: string) => string;
98
- };
99
- type JunctionJSON<ASide extends string, BSide extends string, Content extends Object$1 | null> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>;
100
- declare class Junction<const ASide extends string, const BSide extends string, const Content extends Object$1 | null = null> {
101
- readonly a: ASide;
102
- readonly b: BSide;
103
- readonly cardinality: Cardinality;
104
- readonly relations: Map<string, Set<string>>;
105
- readonly contents: Map<string, Content>;
106
- isContent: Refinement<unknown, Content> | null;
107
- makeContentKey: (a: string, b: string) => string;
108
- getRelatedKeys(key: string): Set<string> | undefined;
109
- protected addRelation(a: string, b: string): void;
110
- protected deleteRelation(a: string, b: string): void;
111
- protected replaceRelationsUnsafely(a: string, bs: string[]): void;
112
- protected replaceRelationsSafely(a: string, bs: string[]): void;
113
- protected getContentInternal(contentKey: string): Content | undefined;
114
- protected setContent(contentKey: string, content: Content): void;
115
- protected deleteContent(contentKey: string): void;
116
- constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<Content>>, config?: JunctionAdvancedConfiguration<Content>);
117
- toJSON(): JunctionJSON<ASide, BSide, Content>;
118
- set(a: string, ...rest: Content extends null ? [b: string] : [b: string, content: Content]): this;
119
- set(relation: {
120
- [Key in ASide | BSide]: string;
121
- }, ...rest: Content extends null ? [] | [b?: undefined] : [content: Content]): this;
122
- delete(a: string, b?: string): this;
123
- delete(relation: Record<ASide | BSide, string> | Record<ASide, string> | Record<BSide, string>, b?: undefined): this;
124
- getRelatedKey(key: string): string | undefined;
125
- replaceRelations(a: string, relations: Content extends null ? string[] : Record<string, Content>, config?: {
126
- reckless: boolean;
127
- }): this;
128
- getContent(a: string, b: string): Content | undefined;
129
- getRelationEntries(input: Record<ASide, string> | Record<BSide, string>): [string, Content][];
130
- has(a: string, b?: string): boolean;
131
- }
132
-
133
- interface Lineage {
134
- parent: typeof this | null;
135
- child: typeof this | null;
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 pullState<J extends Serializable>(token: AtomIO.StateToken<J>, socket: Socket, store: Store): () => void;
256
-
257
- declare function pullFamilyMember<J extends Serializable>(token: AtomIO.AtomToken<J>, socket: Socket, store: Store): () => void;
258
-
259
- declare function pullMutableState<T extends Transceiver<Serializable>, J extends Serializable>(token: AtomIO.MutableAtomToken<T, J>, socket: Socket, store: Store): () => void;
260
-
261
- declare function pullMutableFamilyMember<T extends Transceiver<Serializable>, J extends Serializable>(token: AtomIO.MutableAtomToken<T, J>, socket: Socket, store: Store): () => void;
262
-
263
- declare function pushState<J extends Serializable>(token: AtomIO.StateToken<J>, socket: Socket, subscriptionKey: string, store: Store): () => void;
264
-
265
- declare function synchronizeTransactionResults(token: AtomIO.TransactionToken<any>, socket: Socket, store: Store): () => void;
20
+ declare function synchronizeTransactionResults(token: AtomIO.TransactionToken<any>, socket: Socket, store: Internal.Store): () => void;
266
21
 
267
22
  export { myIdState, myIdState__INTERNAL, pullFamilyMember, pullMutableFamilyMember, pullMutableState, pullState, pushState, synchronizeTransactionResults };
@@ -1,6 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { Socket } from 'socket.io-client';
3
3
  import * as AtomIO from 'atom.io';
4
+ import { Json } from 'atom.io/json';
5
+ import { Transceiver } from 'atom.io/internal';
4
6
 
5
7
  declare const RealtimeContext: React.Context<{
6
8
  socket: Socket;
@@ -10,29 +12,15 @@ declare const RealtimeProvider: React.FC<{
10
12
  socket: Socket;
11
13
  }>;
12
14
 
13
- type primitive = boolean | number | string | null;
15
+ declare function usePull<J extends Json.Serializable>(token: AtomIO.StateToken<J>): void;
14
16
 
15
- type Serializable = primitive | Readonly<{
16
- [key: string]: Serializable;
17
- }> | ReadonlyArray<Serializable>;
17
+ declare function usePullFamilyMember<J extends Json.Serializable>(token: AtomIO.AtomToken<J>): void;
18
18
 
19
- interface Transceiver<Signal extends Serializable> {
20
- do: (update: Signal) => void;
21
- undo: (update: Signal) => void;
22
- subscribe: (key: string, fn: (update: Signal) => void) => () => void;
23
- cacheUpdateNumber: number;
24
- getUpdateNumber: (update: Signal) => number;
25
- }
19
+ declare function usePullMutable<T extends Transceiver<Json.Serializable>, J extends Json.Serializable>(token: AtomIO.MutableAtomToken<T, J>): void;
26
20
 
27
- declare function usePull<J extends Serializable>(token: AtomIO.StateToken<J>): void;
21
+ declare function usePullMutableFamilyMember<T extends Transceiver<Json.Serializable>, J extends Json.Serializable>(token: AtomIO.MutableAtomToken<T, J>): void;
28
22
 
29
- declare function usePullFamilyMember<J extends Serializable>(token: AtomIO.AtomToken<J>): void;
30
-
31
- declare function usePullMutable<T extends Transceiver<Serializable>, J extends Serializable>(token: AtomIO.MutableAtomToken<T, J>): void;
32
-
33
- declare function usePullMutableFamilyMember<T extends Transceiver<Serializable>, J extends Serializable>(token: AtomIO.MutableAtomToken<T, J>): void;
34
-
35
- declare function usePush<J extends Serializable>(token: AtomIO.StateToken<J>): void;
23
+ declare function usePush<J extends Json.Serializable>(token: AtomIO.StateToken<J>): void;
36
24
 
37
25
  declare function useServerAction<ƒ extends AtomIO.ƒn>(token: AtomIO.TransactionToken<ƒ>): (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
38
26
 
@@ -1,6 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { Socket } from 'socket.io-client';
3
3
  import * as AtomIO from 'atom.io';
4
+ import { Json } from 'atom.io/json';
5
+ import { Transceiver } from 'atom.io/internal';
4
6
 
5
7
  declare const RealtimeContext: React.Context<{
6
8
  socket: Socket;
@@ -10,29 +12,15 @@ declare const RealtimeProvider: React.FC<{
10
12
  socket: Socket;
11
13
  }>;
12
14
 
13
- type primitive = boolean | number | string | null;
15
+ declare function usePull<J extends Json.Serializable>(token: AtomIO.StateToken<J>): void;
14
16
 
15
- type Serializable = primitive | Readonly<{
16
- [key: string]: Serializable;
17
- }> | ReadonlyArray<Serializable>;
17
+ declare function usePullFamilyMember<J extends Json.Serializable>(token: AtomIO.AtomToken<J>): void;
18
18
 
19
- interface Transceiver<Signal extends Serializable> {
20
- do: (update: Signal) => void;
21
- undo: (update: Signal) => void;
22
- subscribe: (key: string, fn: (update: Signal) => void) => () => void;
23
- cacheUpdateNumber: number;
24
- getUpdateNumber: (update: Signal) => number;
25
- }
19
+ declare function usePullMutable<T extends Transceiver<Json.Serializable>, J extends Json.Serializable>(token: AtomIO.MutableAtomToken<T, J>): void;
26
20
 
27
- declare function usePull<J extends Serializable>(token: AtomIO.StateToken<J>): void;
21
+ declare function usePullMutableFamilyMember<T extends Transceiver<Json.Serializable>, J extends Json.Serializable>(token: AtomIO.MutableAtomToken<T, J>): void;
28
22
 
29
- declare function usePullFamilyMember<J extends Serializable>(token: AtomIO.AtomToken<J>): void;
30
-
31
- declare function usePullMutable<T extends Transceiver<Serializable>, J extends Serializable>(token: AtomIO.MutableAtomToken<T, J>): void;
32
-
33
- declare function usePullMutableFamilyMember<T extends Transceiver<Serializable>, J extends Serializable>(token: AtomIO.MutableAtomToken<T, J>): void;
34
-
35
- declare function usePush<J extends Serializable>(token: AtomIO.StateToken<J>): void;
23
+ declare function usePush<J extends Json.Serializable>(token: AtomIO.StateToken<J>): void;
36
24
 
37
25
  declare function useServerAction<ƒ extends AtomIO.ƒn>(token: AtomIO.TransactionToken<ƒ>): (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
38
26