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.
- package/data/dist/index.d.ts +11 -186
- package/dist/index.d.ts +245 -0
- package/internal/dist/index.d.ts +20 -18
- package/introspection/dist/index.d.ts +4 -249
- package/json/dist/index.d.ts +3 -243
- package/package.json +3 -2
- package/react/dist/index.cjs +4 -4
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.d.ts +4 -249
- package/react/dist/index.js +4 -4
- package/react/dist/index.js.map +1 -1
- package/react/src/store-hooks.ts +4 -4
- package/react-devtools/dist/index.d.ts +4 -3
- package/realtime-client/dist/index.d.ts +9 -254
- package/realtime-react/dist/index.d.ts +7 -19
- package/realtime-server/dist/index.d.ts +9 -254
- package/transceivers/set-rtx/dist/index.d.ts +3 -29
- package/data/dist/index.d.cts +0 -333
- package/internal/dist/index.d.cts +0 -419
- package/introspection/dist/index.d.cts +0 -269
- package/json/dist/index.d.cts +0 -291
- package/react/dist/index.d.cts +0 -268
- package/react-devtools/dist/index.d.cts +0 -341
- package/realtime-client/dist/index.d.cts +0 -267
- package/realtime-react/dist/index.d.cts +0 -39
- package/realtime-server/dist/index.d.cts +0 -270
- package/realtime-testing/dist/index.d.cts +0 -49
- package/transceivers/set-rtx/dist/index.d.cts +0 -66
|
@@ -1,267 +0,0 @@
|
|
|
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';
|
|
3
|
-
import { Socket } from 'socket.io-client';
|
|
4
|
-
|
|
5
|
-
declare const myIdState__INTERNAL: AtomIO.AtomToken<string | null>;
|
|
6
|
-
declare const myIdState: AtomIO.ReadonlySelectorToken<string | null>;
|
|
7
|
-
|
|
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
|
-
}
|
|
20
|
-
|
|
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
|
-
};
|
|
44
|
-
|
|
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
|
-
};
|
|
52
|
-
|
|
53
|
-
type TransactionMeta<ƒ extends ƒn> = {
|
|
54
|
-
phase: `applying` | `building`;
|
|
55
|
-
time: number;
|
|
56
|
-
update: TransactionUpdate<ƒ>;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
type primitive = boolean | number | string | null;
|
|
60
|
-
|
|
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;
|
|
266
|
-
|
|
267
|
-
export { myIdState, myIdState__INTERNAL, pullFamilyMember, pullMutableFamilyMember, pullMutableState, pullState, pushState, synchronizeTransactionResults };
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Socket } from 'socket.io-client';
|
|
3
|
-
import * as AtomIO from 'atom.io';
|
|
4
|
-
|
|
5
|
-
declare const RealtimeContext: React.Context<{
|
|
6
|
-
socket: Socket;
|
|
7
|
-
}>;
|
|
8
|
-
declare const RealtimeProvider: React.FC<{
|
|
9
|
-
children: React.ReactNode;
|
|
10
|
-
socket: Socket;
|
|
11
|
-
}>;
|
|
12
|
-
|
|
13
|
-
type primitive = boolean | number | string | null;
|
|
14
|
-
|
|
15
|
-
type Serializable = primitive | Readonly<{
|
|
16
|
-
[key: string]: Serializable;
|
|
17
|
-
}> | ReadonlyArray<Serializable>;
|
|
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
|
-
}
|
|
26
|
-
|
|
27
|
-
declare function usePull<J extends Serializable>(token: AtomIO.StateToken<J>): void;
|
|
28
|
-
|
|
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;
|
|
36
|
-
|
|
37
|
-
declare function useServerAction<ƒ extends AtomIO.ƒn>(token: AtomIO.TransactionToken<ƒ>): (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
38
|
-
|
|
39
|
-
export { RealtimeContext, RealtimeProvider, usePull, usePullFamilyMember, usePullMutable, usePullMutableFamilyMember, usePush, useServerAction };
|
|
@@ -1,270 +0,0 @@
|
|
|
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';
|
|
3
|
-
import * as SocketIO from 'socket.io';
|
|
4
|
-
|
|
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;
|
|
253
|
-
|
|
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;
|
|
255
|
-
|
|
256
|
-
declare const useExposeMutable: ({ socket, store, }: ServerConfig) => <Core extends Transceiver<Serializable>, SerializableCore extends Serializable>(token: AtomIO.MutableAtomToken<Core, SerializableCore>) => () => void;
|
|
257
|
-
|
|
258
|
-
declare const useExposeMutableFamily: ({ socket, store, }: ServerConfig) => <Family extends AtomIO.MutableAtomFamily<Transceiver<Serializable>, Serializable, Serializable>>(family: Family, index: AtomIO.StateToken<Set<string>>) => () => void;
|
|
259
|
-
|
|
260
|
-
declare const useReceiveTransaction: ({ socket, store }: ServerConfig) => <ƒ extends AtomIO.ƒn>(tx: AtomIO.TransactionToken<ƒ>) => () => void;
|
|
261
|
-
declare function useSyncTransaction({ socket, store, }: ServerConfig): <ƒ extends AtomIO.ƒn>(tx: AtomIO.TransactionToken<ƒ>) => () => void;
|
|
262
|
-
|
|
263
|
-
declare const useReceiveState: ({ socket, store }: ServerConfig) => <J extends Serializable>(token: StateToken<J>) => () => void;
|
|
264
|
-
|
|
265
|
-
type ServerConfig = {
|
|
266
|
-
socket: SocketIO.Socket;
|
|
267
|
-
store?: Store;
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
export { type ServerConfig, useExposeFamily, useExposeMutable, useExposeMutableFamily, useExposeSingle, useReceiveState, useReceiveTransaction, useSyncTransaction };
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { RenderResult } from '@testing-library/react';
|
|
2
|
-
import * as AtomIO from 'atom.io';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import * as SocketIO from 'socket.io';
|
|
5
|
-
|
|
6
|
-
type TestSetupOptions = {
|
|
7
|
-
server: (tools: {
|
|
8
|
-
socket: SocketIO.Socket;
|
|
9
|
-
silo: AtomIO.Silo;
|
|
10
|
-
}) => void;
|
|
11
|
-
};
|
|
12
|
-
type TestSetupOptions__SingleClient = TestSetupOptions & {
|
|
13
|
-
client: React.FC;
|
|
14
|
-
};
|
|
15
|
-
type TestSetupOptions__MultiClient<ClientNames extends string> = TestSetupOptions & {
|
|
16
|
-
clients: {
|
|
17
|
-
[K in ClientNames]: React.FC;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
type RealtimeTestTools = {
|
|
21
|
-
name: string;
|
|
22
|
-
silo: AtomIO.Silo;
|
|
23
|
-
dispose: () => void;
|
|
24
|
-
};
|
|
25
|
-
type RealtimeTestClient = RealtimeTestTools & {
|
|
26
|
-
renderResult: RenderResult;
|
|
27
|
-
prettyPrint: () => void;
|
|
28
|
-
reconnect: () => void;
|
|
29
|
-
disconnect: () => void;
|
|
30
|
-
};
|
|
31
|
-
type RealtimeTestServer = RealtimeTestTools & {
|
|
32
|
-
port: number;
|
|
33
|
-
};
|
|
34
|
-
type RealtimeTestAPI = {
|
|
35
|
-
server: RealtimeTestServer;
|
|
36
|
-
teardown: () => void;
|
|
37
|
-
};
|
|
38
|
-
type RealtimeTestAPI__SingleClient = RealtimeTestAPI & {
|
|
39
|
-
client: RealtimeTestClient;
|
|
40
|
-
};
|
|
41
|
-
type RealtimeTestAPI__MultiClient<ClientNames extends string> = RealtimeTestAPI & {
|
|
42
|
-
clients: Record<ClientNames, RealtimeTestClient>;
|
|
43
|
-
};
|
|
44
|
-
declare const setupRealtimeTestServer: (options: TestSetupOptions) => RealtimeTestServer;
|
|
45
|
-
declare const setupRealtimeTestClient: (options: TestSetupOptions__SingleClient, name: string, port: number) => RealtimeTestClient;
|
|
46
|
-
declare const singleClient: (options: TestSetupOptions__SingleClient) => RealtimeTestAPI__SingleClient;
|
|
47
|
-
declare const multiClient: <ClientNames extends string>(options: TestSetupOptions__MultiClient<ClientNames>) => RealtimeTestAPI__MultiClient<ClientNames>;
|
|
48
|
-
|
|
49
|
-
export { type RealtimeTestAPI, type RealtimeTestAPI__MultiClient, type RealtimeTestAPI__SingleClient, type RealtimeTestClient, type RealtimeTestServer, type RealtimeTestTools, type TestSetupOptions, type TestSetupOptions__MultiClient, type TestSetupOptions__SingleClient, multiClient, setupRealtimeTestClient, setupRealtimeTestServer, singleClient };
|
|
@@ -1,66 +0,0 @@
|
|
|
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`;
|
|
29
|
-
|
|
30
|
-
type SetUpdate = `add:${string}` | `clear:${string}` | `del:${string}` | `tx:${string}`;
|
|
31
|
-
type NumberedSetUpdate = `${number}=${SetUpdate}`;
|
|
32
|
-
interface SetRTXJson<P extends primitive> extends Object$1 {
|
|
33
|
-
members: P[];
|
|
34
|
-
cache: (NumberedSetUpdate | null)[];
|
|
35
|
-
cacheLimit: number;
|
|
36
|
-
cacheIdx: number;
|
|
37
|
-
cacheUpdateNumber: number;
|
|
38
|
-
}
|
|
39
|
-
declare class SetRTX<P extends primitive> extends Set<P> implements Transceiver<NumberedSetUpdate>, Lineage {
|
|
40
|
-
mode: TransceiverMode;
|
|
41
|
-
readonly subject: Subject<SetUpdate>;
|
|
42
|
-
cacheLimit: number;
|
|
43
|
-
cache: (NumberedSetUpdate | null)[];
|
|
44
|
-
cacheIdx: number;
|
|
45
|
-
cacheUpdateNumber: number;
|
|
46
|
-
constructor(values?: Iterable<P>, cacheLimit?: number);
|
|
47
|
-
toJSON(): SetRTXJson<P>;
|
|
48
|
-
static fromJSON<P extends primitive>(json: SetRTXJson<P>): SetRTX<P>;
|
|
49
|
-
add(value: P): this;
|
|
50
|
-
clear(): void;
|
|
51
|
-
delete(value: P): boolean;
|
|
52
|
-
readonly parent: SetRTX<P> | null;
|
|
53
|
-
child: SetRTX<P> | null;
|
|
54
|
-
transactionUpdates: SetUpdate[] | null;
|
|
55
|
-
transaction(run: (child: SetRTX<P>) => boolean): void;
|
|
56
|
-
protected _subscribe(key: string, fn: (update: SetUpdate) => void): () => void;
|
|
57
|
-
subscribe(key: string, fn: (update: NumberedSetUpdate) => void): () => void;
|
|
58
|
-
emit(update: SetUpdate): void;
|
|
59
|
-
private doStep;
|
|
60
|
-
getUpdateNumber(update: NumberedSetUpdate): number;
|
|
61
|
-
do(update: NumberedSetUpdate): number | `OUT_OF_RANGE` | null;
|
|
62
|
-
undoStep(update: SetUpdate): void;
|
|
63
|
-
undo(update: NumberedSetUpdate): number | null;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export { type NumberedSetUpdate, SetRTX, type SetRTXJson, type SetUpdate };
|