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,266 +1,21 @@
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';
1
+ import { Transceiver, Store } from 'atom.io/internal';
3
2
  import * as SocketIO from 'socket.io';
3
+ import * as AtomIO from 'atom.io';
4
+ import { StateToken } from 'atom.io';
5
+ import { Json } from 'atom.io/json';
4
6
 
5
- declare class Subject<T> {
6
- Subscriber: (value: T) => void;
7
- subscribers: Map<string, this[`Subscriber`]>;
8
- subscribe(key: string, subscriber: this[`Subscriber`]): () => void;
9
- private unsubscribe;
10
- next(value: T): void;
11
- }
12
- declare class StatefulSubject<T> extends Subject<T> {
13
- state: T;
14
- constructor(initialState: T);
15
- next(value: T): void;
16
- }
17
-
18
- type Selector<T> = {
19
- key: string;
20
- type: `selector`;
21
- family?: FamilyMetadata;
22
- install: (store: Store) => void;
23
- subject: Subject<{
24
- newValue: T;
25
- oldValue: T;
26
- }>;
27
- get: () => T;
28
- set: (newValue: T | ((oldValue: T) => T)) => void;
29
- };
30
- type ReadonlySelector<T> = {
31
- key: string;
32
- type: `readonly_selector`;
33
- family?: FamilyMetadata;
34
- install: (store: Store) => void;
35
- subject: Subject<{
36
- newValue: T;
37
- oldValue: T;
38
- }>;
39
- get: () => T;
40
- };
41
-
42
- type Transaction<ƒ extends ƒn> = {
43
- key: string;
44
- type: `transaction`;
45
- install: (store: Store) => void;
46
- subject: Subject<TransactionUpdate<ƒ>>;
47
- run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
48
- };
49
-
50
- type TransactionMeta<ƒ extends ƒn> = {
51
- phase: `applying` | `building`;
52
- time: number;
53
- update: TransactionUpdate<ƒ>;
54
- };
55
-
56
- type primitive = boolean | number | string | null;
57
-
58
- type Serializable = primitive | Readonly<{
59
- [key: string]: Serializable;
60
- }> | ReadonlyArray<Serializable>;
61
- type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
62
-
63
- type Refinement<Unrefined, Refined extends Unrefined> = (value: Unrefined) => value is Refined;
64
- type Cardinality = `1:1` | `1:n` | `n:n`;
65
-
66
- interface JunctionEntries<Content extends Object$1 | null> extends Object$1 {
67
- readonly relations: [string, string[]][];
68
- readonly contents: [string, Content][];
69
- }
70
- interface JunctionSchema<ASide extends string, BSide extends string> extends Object$1 {
71
- readonly between: [a: ASide, b: BSide];
72
- readonly cardinality: Cardinality;
73
- }
74
- type BaseExternalStoreConfiguration = {
75
- addRelation: (a: string, b: string) => void;
76
- deleteRelation: (a: string, b: string) => void;
77
- replaceRelationsSafely: (a: string, bs: string[]) => void;
78
- replaceRelationsUnsafely: (a: string, bs: string[]) => void;
79
- getRelatedKeys: (key: string) => Set<string> | undefined;
80
- has: (a: string, b?: string) => boolean;
81
- };
82
- type ExternalStoreWithContentConfiguration<Content extends Object$1> = {
83
- getContent: (contentKey: string) => Content | undefined;
84
- setContent: (contentKey: string, content: Content) => void;
85
- deleteContent: (contentKey: string) => void;
86
- };
87
- type Empty<Obj extends object> = {
88
- [Key in keyof Obj]?: undefined;
89
- };
90
- type ExternalStoreConfiguration<Content extends Object$1 | null> = Content extends Object$1 ? BaseExternalStoreConfiguration & ExternalStoreWithContentConfiguration<Content> : BaseExternalStoreConfiguration & Empty<ExternalStoreWithContentConfiguration<Object$1>>;
91
- type JunctionAdvancedConfiguration<Content extends Object$1 | null> = {
92
- externalStore?: ExternalStoreConfiguration<Content>;
93
- isContent?: Refinement<unknown, Content>;
94
- makeContentKey?: (a: string, b: string) => string;
95
- };
96
- type JunctionJSON<ASide extends string, BSide extends string, Content extends Object$1 | null> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>;
97
- declare class Junction<const ASide extends string, const BSide extends string, const Content extends Object$1 | null = null> {
98
- readonly a: ASide;
99
- readonly b: BSide;
100
- readonly cardinality: Cardinality;
101
- readonly relations: Map<string, Set<string>>;
102
- readonly contents: Map<string, Content>;
103
- isContent: Refinement<unknown, Content> | null;
104
- makeContentKey: (a: string, b: string) => string;
105
- getRelatedKeys(key: string): Set<string> | undefined;
106
- protected addRelation(a: string, b: string): void;
107
- protected deleteRelation(a: string, b: string): void;
108
- protected replaceRelationsUnsafely(a: string, bs: string[]): void;
109
- protected replaceRelationsSafely(a: string, bs: string[]): void;
110
- protected getContentInternal(contentKey: string): Content | undefined;
111
- protected setContent(contentKey: string, content: Content): void;
112
- protected deleteContent(contentKey: string): void;
113
- constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<Content>>, config?: JunctionAdvancedConfiguration<Content>);
114
- toJSON(): JunctionJSON<ASide, BSide, Content>;
115
- set(a: string, ...rest: Content extends null ? [b: string] : [b: string, content: Content]): this;
116
- set(relation: {
117
- [Key in ASide | BSide]: string;
118
- }, ...rest: Content extends null ? [] | [b?: undefined] : [content: Content]): this;
119
- delete(a: string, b?: string): this;
120
- delete(relation: Record<ASide | BSide, string> | Record<ASide, string> | Record<BSide, string>, b?: undefined): this;
121
- getRelatedKey(key: string): string | undefined;
122
- replaceRelations(a: string, relations: Content extends null ? string[] : Record<string, Content>, config?: {
123
- reckless: boolean;
124
- }): this;
125
- getContent(a: string, b: string): Content | undefined;
126
- getRelationEntries(input: Record<ASide, string> | Record<BSide, string>): [string, Content][];
127
- has(a: string, b?: string): boolean;
128
- }
129
-
130
- interface Lineage {
131
- parent: typeof this | null;
132
- child: typeof this | null;
133
- }
134
-
135
- interface Transceiver<Signal extends Serializable> {
136
- do: (update: Signal) => void;
137
- undo: (update: Signal) => void;
138
- subscribe: (key: string, fn: (update: Signal) => void) => () => void;
139
- cacheUpdateNumber: number;
140
- getUpdateNumber: (update: Signal) => number;
141
- }
142
-
143
- /**
144
- * @internal Give the tracker a transceiver state and a store, and it will
145
- * subscribe to the transceiver's inner value. When the inner value changes,
146
- * the tracker will update its own state to reflect the change.
147
- */
148
- declare class Tracker<Mutable extends Transceiver<any>> {
149
- private Update;
150
- private initializeState;
151
- private unsubscribeFromInnerValue;
152
- private observeCore;
153
- private updateCore;
154
- mutableState: MutableAtomToken<Mutable, Serializable>;
155
- latestUpdateState: AtomToken<typeof this.Update | null>;
156
- constructor(mutableState: MutableAtomToken<Mutable, Serializable>, store: Store);
157
- }
158
-
159
- interface MutableAtom<T> extends Atom<T> {
160
- mutable: true;
161
- }
162
-
163
- type OperationProgress = {
164
- open: false;
165
- } | {
166
- open: true;
167
- done: Set<string>;
168
- prev: Map<string, any>;
169
- time: number;
170
- token: StateToken<any>;
171
- };
172
-
173
- type TimelineAtomUpdate = StateUpdate<unknown> & {
174
- key: string;
175
- type: `atom_update`;
176
- timestamp: number;
177
- family?: FamilyMetadata;
178
- };
179
- type TimelineSelectorUpdate = {
180
- key: string;
181
- type: `selector_update`;
182
- timestamp: number;
183
- atomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[];
184
- };
185
- type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
186
- key: string;
187
- type: `transaction_update`;
188
- timestamp: number;
189
- };
190
- type Timeline = {
191
- type: `timeline`;
192
- key: string;
193
- at: number;
194
- shouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean;
195
- timeTraveling: `into_future` | `into_past` | null;
196
- history: TimelineUpdate[];
197
- selectorTime: number | null;
198
- transactionKey: string | null;
199
- install: (store: Store) => void;
200
- subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
201
- };
202
-
203
- declare class Store implements Lineage {
204
- parent: Store | null;
205
- child: Store | null;
206
- valueMap: Map<string, any>;
207
- atoms: Map<string, Atom<any> | MutableAtom<any>>;
208
- selectors: Map<string, Selector<any>>;
209
- readonlySelectors: Map<string, ReadonlySelector<any>>;
210
- trackers: Map<string, Tracker<Transceiver<any>>>;
211
- families: Map<string, AtomFamily<any, any> | ReadonlySelectorFamily<any, any> | SelectorFamily<any, any>>;
212
- timelines: Map<string, Timeline>;
213
- transactions: Map<string, Transaction<ƒn>>;
214
- atomsThatAreDefault: Set<string>;
215
- timelineAtoms: Junction<"timelineKey", "atomKey", null>;
216
- selectorAtoms: Junction<"selectorKey", "atomKey", null>;
217
- selectorGraph: Junction<"upstreamSelectorKey", "downstreamSelectorKey", {
218
- source: string;
219
- }>;
220
- subject: {
221
- atomCreation: Subject<AtomToken<unknown>>;
222
- selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
223
- transactionCreation: Subject<TransactionToken<ƒn>>;
224
- timelineCreation: Subject<TimelineToken>;
225
- transactionApplying: StatefulSubject<TransactionMeta<ƒn> | null>;
226
- operationStatus: Subject<OperationProgress>;
227
- };
228
- operation: OperationProgress;
229
- transactionMeta: TransactionMeta<ƒn> | null;
230
- config: {
231
- name: string;
232
- };
233
- loggers: AtomIOLogger[];
234
- logger: Logger;
235
- constructor(name: string, store?: Store | null);
236
- }
237
-
238
- type Atom<T> = {
239
- key: string;
240
- type: `atom`;
241
- mutable?: boolean;
242
- family?: FamilyMetadata;
243
- install: (store: Store) => void;
244
- subject: Subject<{
245
- newValue: T;
246
- oldValue: T;
247
- }>;
248
- default: T | (() => T);
249
- cleanup?: () => void;
250
- };
251
-
252
- declare const useExposeSingle: ({ socket, store, }: ServerConfig) => <J extends Serializable>(token: AtomIO.StateToken<J>) => () => void;
7
+ declare const useExposeSingle: ({ socket, store, }: ServerConfig) => <J extends Json.Serializable>(token: AtomIO.StateToken<J>) => () => void;
253
8
 
254
- declare const useExposeFamily: ({ socket, store, }: ServerConfig) => <J extends Serializable>(family: AtomIO.AtomFamily<J, Serializable> | AtomIO.SelectorFamily<J, Serializable>, index: AtomIO.StateToken<Set<string>>) => () => void;
9
+ declare const useExposeFamily: ({ socket, store, }: ServerConfig) => <J extends Json.Serializable>(family: AtomIO.AtomFamily<J, Json.Serializable> | AtomIO.SelectorFamily<J, Json.Serializable>, index: AtomIO.StateToken<Set<string>>) => () => void;
255
10
 
256
- declare const useExposeMutable: ({ socket, store, }: ServerConfig) => <Core extends Transceiver<Serializable>, SerializableCore extends Serializable>(token: AtomIO.MutableAtomToken<Core, SerializableCore>) => () => void;
11
+ declare const useExposeMutable: ({ socket, store, }: ServerConfig) => <Core extends Transceiver<Json.Serializable>, SerializableCore extends Json.Serializable>(token: AtomIO.MutableAtomToken<Core, SerializableCore>) => () => void;
257
12
 
258
- declare const useExposeMutableFamily: ({ socket, store, }: ServerConfig) => <Family extends AtomIO.MutableAtomFamily<Transceiver<Serializable>, Serializable, Serializable>>(family: Family, index: AtomIO.StateToken<Set<string>>) => () => void;
13
+ declare const useExposeMutableFamily: ({ socket, store, }: ServerConfig) => <Family extends AtomIO.MutableAtomFamily<Transceiver<Json.Serializable>, Json.Serializable, Json.Serializable>>(family: Family, index: AtomIO.StateToken<Set<string>>) => () => void;
259
14
 
260
15
  declare const useReceiveTransaction: ({ socket, store }: ServerConfig) => <ƒ extends AtomIO.ƒn>(tx: AtomIO.TransactionToken<ƒ>) => () => void;
261
16
  declare function useSyncTransaction({ socket, store, }: ServerConfig): <ƒ extends AtomIO.ƒn>(tx: AtomIO.TransactionToken<ƒ>) => () => void;
262
17
 
263
- declare const useReceiveState: ({ socket, store }: ServerConfig) => <J extends Serializable>(token: StateToken<J>) => () => void;
18
+ declare const useReceiveState: ({ socket, store }: ServerConfig) => <J extends Json.Serializable>(token: StateToken<J>) => () => void;
264
19
 
265
20
  type ServerConfig = {
266
21
  socket: SocketIO.Socket;
@@ -1,266 +1,21 @@
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';
1
+ import { Transceiver, Store } from 'atom.io/internal';
3
2
  import * as SocketIO from 'socket.io';
3
+ import * as AtomIO from 'atom.io';
4
+ import { StateToken } from 'atom.io';
5
+ import { Json } from 'atom.io/json';
4
6
 
5
- declare class Subject<T> {
6
- Subscriber: (value: T) => void;
7
- subscribers: Map<string, this[`Subscriber`]>;
8
- subscribe(key: string, subscriber: this[`Subscriber`]): () => void;
9
- private unsubscribe;
10
- next(value: T): void;
11
- }
12
- declare class StatefulSubject<T> extends Subject<T> {
13
- state: T;
14
- constructor(initialState: T);
15
- next(value: T): void;
16
- }
17
-
18
- type Selector<T> = {
19
- key: string;
20
- type: `selector`;
21
- family?: FamilyMetadata;
22
- install: (store: Store) => void;
23
- subject: Subject<{
24
- newValue: T;
25
- oldValue: T;
26
- }>;
27
- get: () => T;
28
- set: (newValue: T | ((oldValue: T) => T)) => void;
29
- };
30
- type ReadonlySelector<T> = {
31
- key: string;
32
- type: `readonly_selector`;
33
- family?: FamilyMetadata;
34
- install: (store: Store) => void;
35
- subject: Subject<{
36
- newValue: T;
37
- oldValue: T;
38
- }>;
39
- get: () => T;
40
- };
41
-
42
- type Transaction<ƒ extends ƒn> = {
43
- key: string;
44
- type: `transaction`;
45
- install: (store: Store) => void;
46
- subject: Subject<TransactionUpdate<ƒ>>;
47
- run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
48
- };
49
-
50
- type TransactionMeta<ƒ extends ƒn> = {
51
- phase: `applying` | `building`;
52
- time: number;
53
- update: TransactionUpdate<ƒ>;
54
- };
55
-
56
- type primitive = boolean | number | string | null;
57
-
58
- type Serializable = primitive | Readonly<{
59
- [key: string]: Serializable;
60
- }> | ReadonlyArray<Serializable>;
61
- type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
62
-
63
- type Refinement<Unrefined, Refined extends Unrefined> = (value: Unrefined) => value is Refined;
64
- type Cardinality = `1:1` | `1:n` | `n:n`;
65
-
66
- interface JunctionEntries<Content extends Object$1 | null> extends Object$1 {
67
- readonly relations: [string, string[]][];
68
- readonly contents: [string, Content][];
69
- }
70
- interface JunctionSchema<ASide extends string, BSide extends string> extends Object$1 {
71
- readonly between: [a: ASide, b: BSide];
72
- readonly cardinality: Cardinality;
73
- }
74
- type BaseExternalStoreConfiguration = {
75
- addRelation: (a: string, b: string) => void;
76
- deleteRelation: (a: string, b: string) => void;
77
- replaceRelationsSafely: (a: string, bs: string[]) => void;
78
- replaceRelationsUnsafely: (a: string, bs: string[]) => void;
79
- getRelatedKeys: (key: string) => Set<string> | undefined;
80
- has: (a: string, b?: string) => boolean;
81
- };
82
- type ExternalStoreWithContentConfiguration<Content extends Object$1> = {
83
- getContent: (contentKey: string) => Content | undefined;
84
- setContent: (contentKey: string, content: Content) => void;
85
- deleteContent: (contentKey: string) => void;
86
- };
87
- type Empty<Obj extends object> = {
88
- [Key in keyof Obj]?: undefined;
89
- };
90
- type ExternalStoreConfiguration<Content extends Object$1 | null> = Content extends Object$1 ? BaseExternalStoreConfiguration & ExternalStoreWithContentConfiguration<Content> : BaseExternalStoreConfiguration & Empty<ExternalStoreWithContentConfiguration<Object$1>>;
91
- type JunctionAdvancedConfiguration<Content extends Object$1 | null> = {
92
- externalStore?: ExternalStoreConfiguration<Content>;
93
- isContent?: Refinement<unknown, Content>;
94
- makeContentKey?: (a: string, b: string) => string;
95
- };
96
- type JunctionJSON<ASide extends string, BSide extends string, Content extends Object$1 | null> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>;
97
- declare class Junction<const ASide extends string, const BSide extends string, const Content extends Object$1 | null = null> {
98
- readonly a: ASide;
99
- readonly b: BSide;
100
- readonly cardinality: Cardinality;
101
- readonly relations: Map<string, Set<string>>;
102
- readonly contents: Map<string, Content>;
103
- isContent: Refinement<unknown, Content> | null;
104
- makeContentKey: (a: string, b: string) => string;
105
- getRelatedKeys(key: string): Set<string> | undefined;
106
- protected addRelation(a: string, b: string): void;
107
- protected deleteRelation(a: string, b: string): void;
108
- protected replaceRelationsUnsafely(a: string, bs: string[]): void;
109
- protected replaceRelationsSafely(a: string, bs: string[]): void;
110
- protected getContentInternal(contentKey: string): Content | undefined;
111
- protected setContent(contentKey: string, content: Content): void;
112
- protected deleteContent(contentKey: string): void;
113
- constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<Content>>, config?: JunctionAdvancedConfiguration<Content>);
114
- toJSON(): JunctionJSON<ASide, BSide, Content>;
115
- set(a: string, ...rest: Content extends null ? [b: string] : [b: string, content: Content]): this;
116
- set(relation: {
117
- [Key in ASide | BSide]: string;
118
- }, ...rest: Content extends null ? [] | [b?: undefined] : [content: Content]): this;
119
- delete(a: string, b?: string): this;
120
- delete(relation: Record<ASide | BSide, string> | Record<ASide, string> | Record<BSide, string>, b?: undefined): this;
121
- getRelatedKey(key: string): string | undefined;
122
- replaceRelations(a: string, relations: Content extends null ? string[] : Record<string, Content>, config?: {
123
- reckless: boolean;
124
- }): this;
125
- getContent(a: string, b: string): Content | undefined;
126
- getRelationEntries(input: Record<ASide, string> | Record<BSide, string>): [string, Content][];
127
- has(a: string, b?: string): boolean;
128
- }
129
-
130
- interface Lineage {
131
- parent: typeof this | null;
132
- child: typeof this | null;
133
- }
134
-
135
- interface Transceiver<Signal extends Serializable> {
136
- do: (update: Signal) => void;
137
- undo: (update: Signal) => void;
138
- subscribe: (key: string, fn: (update: Signal) => void) => () => void;
139
- cacheUpdateNumber: number;
140
- getUpdateNumber: (update: Signal) => number;
141
- }
142
-
143
- /**
144
- * @internal Give the tracker a transceiver state and a store, and it will
145
- * subscribe to the transceiver's inner value. When the inner value changes,
146
- * the tracker will update its own state to reflect the change.
147
- */
148
- declare class Tracker<Mutable extends Transceiver<any>> {
149
- private Update;
150
- private initializeState;
151
- private unsubscribeFromInnerValue;
152
- private observeCore;
153
- private updateCore;
154
- mutableState: MutableAtomToken<Mutable, Serializable>;
155
- latestUpdateState: AtomToken<typeof this.Update | null>;
156
- constructor(mutableState: MutableAtomToken<Mutable, Serializable>, store: Store);
157
- }
158
-
159
- interface MutableAtom<T> extends Atom<T> {
160
- mutable: true;
161
- }
162
-
163
- type OperationProgress = {
164
- open: false;
165
- } | {
166
- open: true;
167
- done: Set<string>;
168
- prev: Map<string, any>;
169
- time: number;
170
- token: StateToken<any>;
171
- };
172
-
173
- type TimelineAtomUpdate = StateUpdate<unknown> & {
174
- key: string;
175
- type: `atom_update`;
176
- timestamp: number;
177
- family?: FamilyMetadata;
178
- };
179
- type TimelineSelectorUpdate = {
180
- key: string;
181
- type: `selector_update`;
182
- timestamp: number;
183
- atomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[];
184
- };
185
- type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
186
- key: string;
187
- type: `transaction_update`;
188
- timestamp: number;
189
- };
190
- type Timeline = {
191
- type: `timeline`;
192
- key: string;
193
- at: number;
194
- shouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean;
195
- timeTraveling: `into_future` | `into_past` | null;
196
- history: TimelineUpdate[];
197
- selectorTime: number | null;
198
- transactionKey: string | null;
199
- install: (store: Store) => void;
200
- subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
201
- };
202
-
203
- declare class Store implements Lineage {
204
- parent: Store | null;
205
- child: Store | null;
206
- valueMap: Map<string, any>;
207
- atoms: Map<string, Atom<any> | MutableAtom<any>>;
208
- selectors: Map<string, Selector<any>>;
209
- readonlySelectors: Map<string, ReadonlySelector<any>>;
210
- trackers: Map<string, Tracker<Transceiver<any>>>;
211
- families: Map<string, AtomFamily<any, any> | ReadonlySelectorFamily<any, any> | SelectorFamily<any, any>>;
212
- timelines: Map<string, Timeline>;
213
- transactions: Map<string, Transaction<ƒn>>;
214
- atomsThatAreDefault: Set<string>;
215
- timelineAtoms: Junction<"timelineKey", "atomKey", null>;
216
- selectorAtoms: Junction<"selectorKey", "atomKey", null>;
217
- selectorGraph: Junction<"upstreamSelectorKey", "downstreamSelectorKey", {
218
- source: string;
219
- }>;
220
- subject: {
221
- atomCreation: Subject<AtomToken<unknown>>;
222
- selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
223
- transactionCreation: Subject<TransactionToken<ƒn>>;
224
- timelineCreation: Subject<TimelineToken>;
225
- transactionApplying: StatefulSubject<TransactionMeta<ƒn> | null>;
226
- operationStatus: Subject<OperationProgress>;
227
- };
228
- operation: OperationProgress;
229
- transactionMeta: TransactionMeta<ƒn> | null;
230
- config: {
231
- name: string;
232
- };
233
- loggers: AtomIOLogger[];
234
- logger: Logger;
235
- constructor(name: string, store?: Store | null);
236
- }
237
-
238
- type Atom<T> = {
239
- key: string;
240
- type: `atom`;
241
- mutable?: boolean;
242
- family?: FamilyMetadata;
243
- install: (store: Store) => void;
244
- subject: Subject<{
245
- newValue: T;
246
- oldValue: T;
247
- }>;
248
- default: T | (() => T);
249
- cleanup?: () => void;
250
- };
251
-
252
- declare const useExposeSingle: ({ socket, store, }: ServerConfig) => <J extends Serializable>(token: AtomIO.StateToken<J>) => () => void;
7
+ declare const useExposeSingle: ({ socket, store, }: ServerConfig) => <J extends Json.Serializable>(token: AtomIO.StateToken<J>) => () => void;
253
8
 
254
- declare const useExposeFamily: ({ socket, store, }: ServerConfig) => <J extends Serializable>(family: AtomIO.AtomFamily<J, Serializable> | AtomIO.SelectorFamily<J, Serializable>, index: AtomIO.StateToken<Set<string>>) => () => void;
9
+ declare const useExposeFamily: ({ socket, store, }: ServerConfig) => <J extends Json.Serializable>(family: AtomIO.AtomFamily<J, Json.Serializable> | AtomIO.SelectorFamily<J, Json.Serializable>, index: AtomIO.StateToken<Set<string>>) => () => void;
255
10
 
256
- declare const useExposeMutable: ({ socket, store, }: ServerConfig) => <Core extends Transceiver<Serializable>, SerializableCore extends Serializable>(token: AtomIO.MutableAtomToken<Core, SerializableCore>) => () => void;
11
+ declare const useExposeMutable: ({ socket, store, }: ServerConfig) => <Core extends Transceiver<Json.Serializable>, SerializableCore extends Json.Serializable>(token: AtomIO.MutableAtomToken<Core, SerializableCore>) => () => void;
257
12
 
258
- declare const useExposeMutableFamily: ({ socket, store, }: ServerConfig) => <Family extends AtomIO.MutableAtomFamily<Transceiver<Serializable>, Serializable, Serializable>>(family: Family, index: AtomIO.StateToken<Set<string>>) => () => void;
13
+ declare const useExposeMutableFamily: ({ socket, store, }: ServerConfig) => <Family extends AtomIO.MutableAtomFamily<Transceiver<Json.Serializable>, Json.Serializable, Json.Serializable>>(family: Family, index: AtomIO.StateToken<Set<string>>) => () => void;
259
14
 
260
15
  declare const useReceiveTransaction: ({ socket, store }: ServerConfig) => <ƒ extends AtomIO.ƒn>(tx: AtomIO.TransactionToken<ƒ>) => () => void;
261
16
  declare function useSyncTransaction({ socket, store, }: ServerConfig): <ƒ extends AtomIO.ƒn>(tx: AtomIO.TransactionToken<ƒ>) => () => void;
262
17
 
263
- declare const useReceiveState: ({ socket, store }: ServerConfig) => <J extends Serializable>(token: StateToken<J>) => () => void;
18
+ declare const useReceiveState: ({ socket, store }: ServerConfig) => <J extends Json.Serializable>(token: StateToken<J>) => () => void;
264
19
 
265
20
  type ServerConfig = {
266
21
  socket: SocketIO.Socket;
@@ -1,35 +1,9 @@
1
- declare class Subject<T> {
2
- Subscriber: (value: T) => void;
3
- subscribers: Map<string, this[`Subscriber`]>;
4
- subscribe(key: string, subscriber: this[`Subscriber`]): () => void;
5
- private unsubscribe;
6
- next(value: T): void;
7
- }
8
-
9
- type primitive = boolean | number | string | null;
10
-
11
- type Serializable = primitive | Readonly<{
12
- [key: string]: Serializable;
13
- }> | ReadonlyArray<Serializable>;
14
- type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
15
-
16
- interface Lineage {
17
- parent: typeof this | null;
18
- child: typeof this | null;
19
- }
20
-
21
- interface Transceiver<Signal extends Serializable> {
22
- do: (update: Signal) => void;
23
- undo: (update: Signal) => void;
24
- subscribe: (key: string, fn: (update: Signal) => void) => () => void;
25
- cacheUpdateNumber: number;
26
- getUpdateNumber: (update: Signal) => number;
27
- }
28
- type TransceiverMode = `playback` | `record` | `transaction`;
1
+ import { Transceiver, Lineage, TransceiverMode, Subject } from 'atom.io/internal';
2
+ import { primitive, Json } from 'atom.io/json';
29
3
 
30
4
  type SetUpdate = `add:${string}` | `clear:${string}` | `del:${string}` | `tx:${string}`;
31
5
  type NumberedSetUpdate = `${number}=${SetUpdate}`;
32
- interface SetRTXJson<P extends primitive> extends Object$1 {
6
+ interface SetRTXJson<P extends primitive> extends Json.Object {
33
7
  members: P[];
34
8
  cache: (NumberedSetUpdate | null)[];
35
9
  cacheLimit: number;
@@ -1,35 +1,9 @@
1
- declare class Subject<T> {
2
- Subscriber: (value: T) => void;
3
- subscribers: Map<string, this[`Subscriber`]>;
4
- subscribe(key: string, subscriber: this[`Subscriber`]): () => void;
5
- private unsubscribe;
6
- next(value: T): void;
7
- }
8
-
9
- type primitive = boolean | number | string | null;
10
-
11
- type Serializable = primitive | Readonly<{
12
- [key: string]: Serializable;
13
- }> | ReadonlyArray<Serializable>;
14
- type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
15
-
16
- interface Lineage {
17
- parent: typeof this | null;
18
- child: typeof this | null;
19
- }
20
-
21
- interface Transceiver<Signal extends Serializable> {
22
- do: (update: Signal) => void;
23
- undo: (update: Signal) => void;
24
- subscribe: (key: string, fn: (update: Signal) => void) => () => void;
25
- cacheUpdateNumber: number;
26
- getUpdateNumber: (update: Signal) => number;
27
- }
28
- type TransceiverMode = `playback` | `record` | `transaction`;
1
+ import { Transceiver, Lineage, TransceiverMode, Subject } from 'atom.io/internal';
2
+ import { primitive, Json } from 'atom.io/json';
29
3
 
30
4
  type SetUpdate = `add:${string}` | `clear:${string}` | `del:${string}` | `tx:${string}`;
31
5
  type NumberedSetUpdate = `${number}=${SetUpdate}`;
32
- interface SetRTXJson<P extends primitive> extends Object$1 {
6
+ interface SetRTXJson<P extends primitive> extends Json.Object {
33
7
  members: P[];
34
8
  cache: (NumberedSetUpdate | null)[];
35
9
  cacheLimit: number;