atom.io 0.14.3 → 0.14.5
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.cjs +47 -1416
- package/data/dist/index.cjs.map +1 -1
- package/data/dist/index.d.cts +8 -134
- package/data/dist/index.d.ts +8 -134
- package/data/dist/index.js +4 -6
- package/data/dist/index.js.map +1 -1
- package/dist/chunk-NYTGCPHB.js +261 -0
- package/dist/chunk-NYTGCPHB.js.map +1 -0
- package/dist/chunk-PZLG2HP3.js +36 -0
- package/dist/chunk-PZLG2HP3.js.map +1 -0
- package/dist/chunk-XACXFU3B.js +46 -0
- package/dist/chunk-XACXFU3B.js.map +1 -0
- package/dist/index.cjs +55 -2330
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +152 -1
- package/dist/index.js.map +1 -1
- package/internal/dist/index.cjs +30 -159
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.cts +8 -211
- package/internal/dist/index.d.ts +8 -211
- package/internal/dist/index.js +2027 -1
- package/internal/dist/index.js.map +1 -1
- package/introspection/dist/index.cjs +45 -1565
- package/introspection/dist/index.cjs.map +1 -1
- package/introspection/dist/index.d.cts +2 -129
- package/introspection/dist/index.d.ts +2 -129
- package/introspection/dist/index.js +298 -2
- package/introspection/dist/index.js.map +1 -1
- package/json/dist/index.cjs +5 -1502
- package/json/dist/index.cjs.map +1 -1
- package/json/dist/index.d.cts +5 -131
- package/json/dist/index.d.ts +5 -131
- package/json/dist/index.js +37 -1
- package/json/dist/index.js.map +1 -1
- package/package.json +1 -2
- package/react/dist/index.cjs +30 -1571
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.d.cts +8 -136
- package/react/dist/index.d.ts +8 -136
- package/react/dist/index.js +62 -2
- package/react/dist/index.js.map +1 -1
- package/react/src/store-hooks.ts +18 -20
- package/react-devtools/dist/index.cjs +135 -2153
- package/react-devtools/dist/index.cjs.map +1 -1
- package/react-devtools/dist/index.d.cts +20 -146
- package/react-devtools/dist/index.d.ts +20 -146
- package/react-devtools/dist/index.js +5 -3
- package/react-devtools/dist/index.js.map +1 -1
- package/realtime-client/dist/index.cjs +34 -1529
- package/realtime-client/dist/index.cjs.map +1 -1
- package/realtime-client/dist/index.d.cts +11 -138
- package/realtime-client/dist/index.d.ts +11 -138
- package/realtime-client/dist/index.js +165 -2
- package/realtime-client/dist/index.js.map +1 -1
- package/realtime-react/dist/index.cjs +35 -1727
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.d.cts +7 -35
- package/realtime-react/dist/index.d.ts +7 -35
- package/realtime-react/dist/index.js +66 -4
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-server/dist/index.cjs +57 -1548
- package/realtime-server/dist/index.cjs.map +1 -1
- package/realtime-server/dist/index.d.cts +15 -153
- package/realtime-server/dist/index.d.ts +15 -153
- package/realtime-server/dist/index.js +21 -27
- package/realtime-server/dist/index.js.map +1 -1
- package/realtime-testing/dist/index.cjs +15 -2376
- package/realtime-testing/dist/index.cjs.map +1 -1
- package/realtime-testing/dist/index.d.cts +3 -489
- package/realtime-testing/dist/index.d.ts +3 -489
- package/realtime-testing/dist/index.js +10 -9
- package/realtime-testing/dist/index.js.map +1 -1
- package/transceivers/set-rtx/dist/index.cjs +9 -31
- package/transceivers/set-rtx/dist/index.cjs.map +1 -1
- package/transceivers/set-rtx/dist/index.d.cts +7 -7
- package/transceivers/set-rtx/dist/index.d.ts +7 -7
- package/transceivers/set-rtx/dist/index.js +3 -2
- package/transceivers/set-rtx/dist/index.js.map +1 -1
- package/dist/chunk-C4YZZNRH.js +0 -67
- package/dist/chunk-C4YZZNRH.js.map +0 -1
- package/dist/chunk-CWKKQKVQ.js +0 -68
- package/dist/chunk-CWKKQKVQ.js.map +0 -1
- package/dist/chunk-GMN5KH6A.js +0 -309
- package/dist/chunk-GMN5KH6A.js.map +0 -1
- package/dist/chunk-N7ADBQJG.js +0 -176
- package/dist/chunk-N7ADBQJG.js.map +0 -1
- package/dist/chunk-PURABO5G.js +0 -2581
- package/dist/chunk-PURABO5G.js.map +0 -1
- package/dist/index.d.cts +0 -493
- package/dist/index.d.ts +0 -493
- package/dist/metafile-cjs.json +0 -1
- package/dist/metafile-esm.json +0 -1
|
@@ -1,498 +1,12 @@
|
|
|
1
1
|
import { RenderResult } from '@testing-library/react';
|
|
2
|
+
import * as AtomIO from 'atom.io';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import * as SocketIO from 'socket.io';
|
|
4
5
|
|
|
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
|
-
type JsonInterface<T, J extends Serializable = Serializable> = {
|
|
136
|
-
toJson: (t: T) => J;
|
|
137
|
-
fromJson: (json: J) => T;
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
interface Transceiver<Signal extends Serializable> {
|
|
141
|
-
do: (update: Signal) => void;
|
|
142
|
-
undo: (update: Signal) => void;
|
|
143
|
-
subscribe: (key: string, fn: (update: Signal) => void) => () => void;
|
|
144
|
-
cacheUpdateNumber: number;
|
|
145
|
-
getUpdateNumber: (update: Signal) => number;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* @internal Give the tracker a transceiver state and a store, and it will
|
|
150
|
-
* subscribe to the transceiver's inner value. When the inner value changes,
|
|
151
|
-
* the tracker will update its own state to reflect the change.
|
|
152
|
-
*/
|
|
153
|
-
declare class Tracker<Mutable extends Transceiver<any>> {
|
|
154
|
-
private Update;
|
|
155
|
-
private initializeState;
|
|
156
|
-
private unsubscribeFromInnerValue;
|
|
157
|
-
private observeCore;
|
|
158
|
-
private updateCore;
|
|
159
|
-
mutableState: MutableAtomToken<Mutable, Serializable>;
|
|
160
|
-
latestUpdateState: AtomToken<typeof this.Update | null>;
|
|
161
|
-
constructor(mutableState: MutableAtomToken<Mutable, Serializable>, store: Store);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
interface MutableAtom<T> extends Atom<T> {
|
|
165
|
-
mutable: true;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
type OperationProgress = {
|
|
169
|
-
open: false;
|
|
170
|
-
} | {
|
|
171
|
-
open: true;
|
|
172
|
-
done: Set<string>;
|
|
173
|
-
prev: Map<string, any>;
|
|
174
|
-
time: number;
|
|
175
|
-
token: StateToken<any>;
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
type TimelineAtomUpdate = StateUpdate<unknown> & {
|
|
179
|
-
key: string;
|
|
180
|
-
type: `atom_update`;
|
|
181
|
-
timestamp: number;
|
|
182
|
-
family?: FamilyMetadata;
|
|
183
|
-
};
|
|
184
|
-
type TimelineSelectorUpdate = {
|
|
185
|
-
key: string;
|
|
186
|
-
type: `selector_update`;
|
|
187
|
-
timestamp: number;
|
|
188
|
-
atomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[];
|
|
189
|
-
};
|
|
190
|
-
type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
|
|
191
|
-
key: string;
|
|
192
|
-
type: `transaction_update`;
|
|
193
|
-
timestamp: number;
|
|
194
|
-
};
|
|
195
|
-
type Timeline = {
|
|
196
|
-
type: `timeline`;
|
|
197
|
-
key: string;
|
|
198
|
-
at: number;
|
|
199
|
-
shouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean;
|
|
200
|
-
timeTraveling: `into_future` | `into_past` | null;
|
|
201
|
-
history: TimelineUpdate[];
|
|
202
|
-
selectorTime: number | null;
|
|
203
|
-
transactionKey: string | null;
|
|
204
|
-
install: (store: Store) => void;
|
|
205
|
-
subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
declare class Store implements Lineage {
|
|
209
|
-
parent: Store | null;
|
|
210
|
-
child: Store | null;
|
|
211
|
-
valueMap: Map<string, any>;
|
|
212
|
-
atoms: Map<string, Atom<any> | MutableAtom<any>>;
|
|
213
|
-
selectors: Map<string, Selector<any>>;
|
|
214
|
-
readonlySelectors: Map<string, ReadonlySelector<any>>;
|
|
215
|
-
trackers: Map<string, Tracker<Transceiver<any>>>;
|
|
216
|
-
families: Map<string, AtomFamily<any, any> | ReadonlySelectorFamily<any, any> | SelectorFamily<any, any>>;
|
|
217
|
-
timelines: Map<string, Timeline>;
|
|
218
|
-
transactions: Map<string, Transaction<ƒn>>;
|
|
219
|
-
atomsThatAreDefault: Set<string>;
|
|
220
|
-
timelineAtoms: Junction<"timelineKey", "atomKey", null>;
|
|
221
|
-
selectorAtoms: Junction<"selectorKey", "atomKey", null>;
|
|
222
|
-
selectorGraph: Junction<"upstreamSelectorKey", "downstreamSelectorKey", {
|
|
223
|
-
source: string;
|
|
224
|
-
}>;
|
|
225
|
-
subject: {
|
|
226
|
-
atomCreation: Subject<AtomToken<unknown>>;
|
|
227
|
-
selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
228
|
-
transactionCreation: Subject<TransactionToken<ƒn>>;
|
|
229
|
-
timelineCreation: Subject<TimelineToken>;
|
|
230
|
-
transactionApplying: StatefulSubject<TransactionMeta<ƒn> | null>;
|
|
231
|
-
operationStatus: Subject<OperationProgress>;
|
|
232
|
-
};
|
|
233
|
-
operation: OperationProgress;
|
|
234
|
-
transactionMeta: TransactionMeta<ƒn> | null;
|
|
235
|
-
config: {
|
|
236
|
-
name: string;
|
|
237
|
-
};
|
|
238
|
-
loggers: AtomIOLogger[];
|
|
239
|
-
logger: Logger;
|
|
240
|
-
constructor(name: string, store?: Store | null);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
type Atom<T> = {
|
|
244
|
-
key: string;
|
|
245
|
-
type: `atom`;
|
|
246
|
-
mutable?: boolean;
|
|
247
|
-
family?: FamilyMetadata;
|
|
248
|
-
install: (store: Store) => void;
|
|
249
|
-
subject: Subject<{
|
|
250
|
-
newValue: T;
|
|
251
|
-
oldValue: T;
|
|
252
|
-
}>;
|
|
253
|
-
default: T | (() => T);
|
|
254
|
-
cleanup?: () => void;
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
type Effectors<T> = {
|
|
258
|
-
setSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void;
|
|
259
|
-
onSet: (callback: (options: {
|
|
260
|
-
newValue: T;
|
|
261
|
-
oldValue: T;
|
|
262
|
-
}) => void) => void;
|
|
263
|
-
};
|
|
264
|
-
type AtomEffect<T> = (tools: Effectors<T>) => (() => void) | void;
|
|
265
|
-
type AtomOptions<T> = {
|
|
266
|
-
key: string;
|
|
267
|
-
default: T | (() => T);
|
|
268
|
-
effects?: AtomEffect<T>[];
|
|
269
|
-
};
|
|
270
|
-
type MutableAtomOptions<T extends Transceiver<any>, J extends Serializable> = JsonInterface<T, J> & Omit<AtomOptions<T>, `default`> & {
|
|
271
|
-
default: () => T;
|
|
272
|
-
mutable: true;
|
|
273
|
-
};
|
|
274
|
-
declare function atom<T extends Transceiver<any>, J extends Serializable>(options: MutableAtomOptions<T, J>): MutableAtomToken<T, J>;
|
|
275
|
-
declare function atom<T>(options: AtomOptions<T>): AtomToken<T>;
|
|
276
|
-
type AtomFamilyOptions<T, K extends Serializable> = {
|
|
277
|
-
key: string;
|
|
278
|
-
default: T | ((key: K) => T);
|
|
279
|
-
effects?: (key: K) => AtomEffect<T>[];
|
|
280
|
-
};
|
|
281
|
-
type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomToken<T>) & {
|
|
282
|
-
key: string;
|
|
283
|
-
type: `atom_family`;
|
|
284
|
-
subject: Subject<AtomToken<T>>;
|
|
285
|
-
mutable?: boolean;
|
|
286
|
-
};
|
|
287
|
-
type MutableAtomFamilyOptions<T extends Transceiver<any>, J extends Serializable, K extends Serializable> = AtomFamilyOptions<T, K> & JsonInterface<T, J> & {
|
|
288
|
-
mutable: true;
|
|
289
|
-
};
|
|
290
|
-
type MutableAtomFamily<Core extends Transceiver<any>, SerializableCore extends Serializable, Key extends Serializable> = JsonInterface<Core, SerializableCore> & ((key: Key) => MutableAtomToken<Core, SerializableCore>) & {
|
|
291
|
-
key: `${string}`;
|
|
292
|
-
type: `atom_family`;
|
|
293
|
-
subject: Subject<MutableAtomToken<Core, SerializableCore>>;
|
|
294
|
-
mutable: true;
|
|
295
|
-
};
|
|
296
|
-
declare function atomFamily<T extends Transceiver<any>, J extends Serializable, K extends Serializable>(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamily<T, J, K>;
|
|
297
|
-
declare function atomFamily<T, K extends Serializable>(options: AtomFamilyOptions<T, K>): AtomFamily<T, K>;
|
|
298
|
-
|
|
299
|
-
declare function getState<T>(token: ReadonlySelectorToken<T> | StateToken<T>, store?: Store): T;
|
|
300
|
-
|
|
301
|
-
declare const LoggerIconDictionary: {
|
|
302
|
-
readonly "\u231B": "Timeline event fully captured";
|
|
303
|
-
readonly "\u23E9": "Timeline redo";
|
|
304
|
-
readonly "\u23EA": "Timeline undo";
|
|
305
|
-
readonly "\u23ED\uFE0F": "Transaction redo";
|
|
306
|
-
readonly "\u23EE\uFE0F": "Transaction undo";
|
|
307
|
-
readonly "\u23F3": "Timeline event partially captured";
|
|
308
|
-
readonly "\u23F9\uFE0F": "Time-travel complete";
|
|
309
|
-
readonly "\uD83D\uDC81": "Notice";
|
|
310
|
-
readonly "\uD83D\uDD04": "Realtime transaction synchronized";
|
|
311
|
-
readonly "\u2705": "Realtime transaction success";
|
|
312
|
-
readonly "\u2728": "Computation complete";
|
|
313
|
-
readonly "\u274C": "Conflict prevents attempted action";
|
|
314
|
-
readonly "\u2B55": "Operation start";
|
|
315
|
-
readonly "\uD83D\uDC1E": "Possible bug in AtomIO";
|
|
316
|
-
readonly "\uD83D\uDC40": "Subscription added";
|
|
317
|
-
readonly "\uD83D\uDC6A": "Family member added";
|
|
318
|
-
readonly "\uD83D\uDCC1": "Stow update";
|
|
319
|
-
readonly "\uD83D\uDCC3": "Copy mutable";
|
|
320
|
-
readonly "\uD83D\uDCD6": "Read state";
|
|
321
|
-
readonly "\uD83D\uDCDD": "Write state";
|
|
322
|
-
readonly "\uD83D\uDCE2": "Notify subscribers";
|
|
323
|
-
readonly "\uD83D\uDD0C": "Register dependency";
|
|
324
|
-
readonly "\uD83D\uDD0D": "Discover root";
|
|
325
|
-
readonly "\uD83D\uDD25": "Delete state";
|
|
326
|
-
readonly "\uD83D\uDD27": "Create mutable atom";
|
|
327
|
-
readonly "\uD83D\uDD28": "Create immutable atom";
|
|
328
|
-
readonly "\uD83D\uDD34": "Operation complete";
|
|
329
|
-
readonly "\uD83D\uDDD1": "Evict cached value";
|
|
330
|
-
readonly "\uD83D\uDCA5": "Caught";
|
|
331
|
-
readonly "\uD83D\uDE48": "Subscription canceled";
|
|
332
|
-
readonly "\uD83D\uDEC4": "Apply transaction";
|
|
333
|
-
readonly "\uD83D\uDEE0\uFE0F": "Install atom into store";
|
|
334
|
-
readonly "\uD83D\uDEEB": "Begin transaction";
|
|
335
|
-
readonly "\uD83D\uDEEC": "Complete transaction";
|
|
336
|
-
readonly "\uD83E\uDDEE": "Computing selector";
|
|
337
|
-
readonly "\uD83E\uDDF9": "Prepare to evict";
|
|
338
|
-
readonly "\uD83E\uDE82": "Abort transaction";
|
|
339
|
-
};
|
|
340
|
-
type LoggerIcon = keyof typeof LoggerIconDictionary;
|
|
341
|
-
declare const LOG_LEVELS: readonly ["info", "warn", "error"];
|
|
342
|
-
type LogLevel = (typeof LOG_LEVELS)[number];
|
|
343
|
-
type LogFn = (icon: LoggerIcon, tokenType: `atom` | `readonly_selector` | `selector` | `state` | `timeline` | `transaction` | `unknown`, tokenKey: string, message: string, ...rest: unknown[]) => void;
|
|
344
|
-
type LogFilter = (...params: Parameters<LogFn>) => boolean;
|
|
345
|
-
type Logger = Record<LogLevel, LogFn>;
|
|
346
|
-
declare class AtomIOLogger implements Logger {
|
|
347
|
-
logLevel: `error` | `info` | `warn` | null;
|
|
348
|
-
private readonly filter?;
|
|
349
|
-
private readonly logger;
|
|
350
|
-
constructor(logLevel: `error` | `info` | `warn` | null, filter?: LogFilter | undefined, logger?: Logger);
|
|
351
|
-
error: LogFn;
|
|
352
|
-
info: LogFn;
|
|
353
|
-
warn: LogFn;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
type TransactionToken<_> = {
|
|
357
|
-
key: string;
|
|
358
|
-
type: `transaction`;
|
|
359
|
-
__brand?: _;
|
|
360
|
-
};
|
|
361
|
-
type TransactionUpdate<ƒ extends ƒn> = {
|
|
362
|
-
key: string;
|
|
363
|
-
updates: (KeyedStateUpdate<unknown> | TransactionUpdate<ƒn>)[];
|
|
364
|
-
params: Parameters<ƒ>;
|
|
365
|
-
output: ReturnType<ƒ>;
|
|
366
|
-
};
|
|
367
|
-
type Transactors = {
|
|
368
|
-
get: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S;
|
|
369
|
-
set: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void;
|
|
370
|
-
};
|
|
371
|
-
type ReadonlyTransactors = Pick<Transactors, `get`>;
|
|
372
|
-
type Read<ƒ extends ƒn> = (transactors: ReadonlyTransactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
373
|
-
type Write<ƒ extends ƒn> = (transactors: Transactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
374
|
-
type Act<ƒ extends ƒn> = (transactors: Transactors & {
|
|
375
|
-
run: typeof runTransaction;
|
|
376
|
-
}, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
377
|
-
type TransactionOptions<ƒ extends ƒn> = {
|
|
378
|
-
key: string;
|
|
379
|
-
do: Act<ƒ>;
|
|
380
|
-
};
|
|
381
|
-
declare function transaction<ƒ extends ƒn>(options: TransactionOptions<ƒ>): TransactionToken<ƒ>;
|
|
382
|
-
declare const runTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, store?: Store) => (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
383
|
-
|
|
384
|
-
type SelectorOptions<T> = {
|
|
385
|
-
key: string;
|
|
386
|
-
get: Read<() => T>;
|
|
387
|
-
set: Write<(newValue: T) => void>;
|
|
388
|
-
};
|
|
389
|
-
type ReadonlySelectorOptions<T> = {
|
|
390
|
-
key: string;
|
|
391
|
-
get: Read<() => T>;
|
|
392
|
-
};
|
|
393
|
-
declare function selector<T>(options: SelectorOptions<T>): SelectorToken<T>;
|
|
394
|
-
declare function selector<T>(options: ReadonlySelectorOptions<T>): ReadonlySelectorToken<T>;
|
|
395
|
-
type SelectorFamilyOptions<T, K extends Serializable> = {
|
|
396
|
-
key: string;
|
|
397
|
-
get: (key: K) => Read<() => T>;
|
|
398
|
-
set: (key: K) => Write<(newValue: T) => void>;
|
|
399
|
-
};
|
|
400
|
-
type ReadonlySelectorFamilyOptions<T, K extends Serializable> = {
|
|
401
|
-
key: string;
|
|
402
|
-
get: (key: K) => Read<() => T>;
|
|
403
|
-
};
|
|
404
|
-
type SelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => SelectorToken<T>) & {
|
|
405
|
-
key: string;
|
|
406
|
-
type: `selector_family`;
|
|
407
|
-
subject: Subject<SelectorToken<T>>;
|
|
408
|
-
};
|
|
409
|
-
type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
|
|
410
|
-
key: string;
|
|
411
|
-
type: `readonly_selector_family`;
|
|
412
|
-
subject: Subject<ReadonlySelectorToken<T>>;
|
|
413
|
-
};
|
|
414
|
-
declare function selectorFamily<T, K extends Serializable>(options: SelectorFamilyOptions<T, K>): SelectorFamily<T, K>;
|
|
415
|
-
declare function selectorFamily<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamily<T, K>;
|
|
416
|
-
|
|
417
|
-
declare function setState<T, New extends T>(token: StateToken<T>, value: New | ((oldValue: T) => New), store?: Store): void;
|
|
418
|
-
|
|
419
|
-
declare class Silo {
|
|
420
|
-
store: Store;
|
|
421
|
-
atom: typeof atom;
|
|
422
|
-
atomFamily: typeof atomFamily;
|
|
423
|
-
selector: typeof selector;
|
|
424
|
-
selectorFamily: typeof selectorFamily;
|
|
425
|
-
transaction: typeof transaction;
|
|
426
|
-
timeline: typeof timeline;
|
|
427
|
-
getState: typeof getState;
|
|
428
|
-
setState: typeof setState;
|
|
429
|
-
subscribe: typeof subscribe;
|
|
430
|
-
undo: typeof undo;
|
|
431
|
-
redo: typeof redo;
|
|
432
|
-
constructor(name: string, fromStore?: Store | null);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
type StateUpdate<T> = {
|
|
436
|
-
newValue: T;
|
|
437
|
-
oldValue: T;
|
|
438
|
-
};
|
|
439
|
-
type KeyedStateUpdate<T> = StateUpdate<T> & {
|
|
440
|
-
key: string;
|
|
441
|
-
family?: FamilyMetadata;
|
|
442
|
-
};
|
|
443
|
-
type UpdateHandler<T> = (update: StateUpdate<T>) => void;
|
|
444
|
-
type TransactionUpdateHandler<ƒ extends ƒn> = (data: TransactionUpdate<ƒ>) => void;
|
|
445
|
-
declare function subscribe<T>(token: ReadonlySelectorToken<T> | StateToken<T>, handleUpdate: UpdateHandler<T>, key?: string, store?: Store): () => void;
|
|
446
|
-
declare function subscribe<ƒ extends ƒn>(token: TransactionToken<ƒ>, handleUpdate: TransactionUpdateHandler<ƒ>, key?: string, store?: Store): () => void;
|
|
447
|
-
declare function subscribe(token: TimelineToken, handleUpdate: (update: TimelineUpdate | `redo` | `undo`) => void, key?: string, store?: Store): () => void;
|
|
448
|
-
|
|
449
|
-
type TimelineToken = {
|
|
450
|
-
key: string;
|
|
451
|
-
type: `timeline`;
|
|
452
|
-
};
|
|
453
|
-
type TimelineOptions = {
|
|
454
|
-
key: string;
|
|
455
|
-
atoms: (AtomFamily<any, any> | AtomToken<any>)[];
|
|
456
|
-
shouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean;
|
|
457
|
-
};
|
|
458
|
-
type TimelineUpdate = TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate;
|
|
459
|
-
declare const timeline: (options: TimelineOptions) => TimelineToken;
|
|
460
|
-
declare const redo: (timeline: TimelineToken) => void;
|
|
461
|
-
declare const undo: (timeline: TimelineToken) => void;
|
|
462
|
-
|
|
463
|
-
type ƒn = (...parameters: any[]) => any;
|
|
464
|
-
type AtomToken<_> = {
|
|
465
|
-
key: string;
|
|
466
|
-
type: `atom`;
|
|
467
|
-
family?: FamilyMetadata;
|
|
468
|
-
__brand?: _;
|
|
469
|
-
};
|
|
470
|
-
interface MutableAtomToken<T extends Transceiver<any>, J extends Serializable> extends AtomToken<T> {
|
|
471
|
-
__asJSON?: J;
|
|
472
|
-
__update?: T extends Transceiver<infer Update> ? Update : never;
|
|
473
|
-
}
|
|
474
|
-
type SelectorToken<_> = {
|
|
475
|
-
key: string;
|
|
476
|
-
type: `selector`;
|
|
477
|
-
family?: FamilyMetadata;
|
|
478
|
-
__brand?: _;
|
|
479
|
-
};
|
|
480
|
-
type StateToken<T> = AtomToken<T> | SelectorToken<T>;
|
|
481
|
-
type ReadonlySelectorToken<_> = {
|
|
482
|
-
key: string;
|
|
483
|
-
type: `readonly_selector`;
|
|
484
|
-
family?: FamilyMetadata;
|
|
485
|
-
__brand?: _;
|
|
486
|
-
};
|
|
487
|
-
type FamilyMetadata = {
|
|
488
|
-
key: string;
|
|
489
|
-
subKey: string;
|
|
490
|
-
};
|
|
491
|
-
|
|
492
6
|
type TestSetupOptions = {
|
|
493
7
|
server: (tools: {
|
|
494
8
|
socket: SocketIO.Socket;
|
|
495
|
-
silo: Silo;
|
|
9
|
+
silo: AtomIO.Silo;
|
|
496
10
|
}) => void;
|
|
497
11
|
};
|
|
498
12
|
type TestSetupOptions__SingleClient = TestSetupOptions & {
|
|
@@ -505,7 +19,7 @@ type TestSetupOptions__MultiClient<ClientNames extends string> = TestSetupOption
|
|
|
505
19
|
};
|
|
506
20
|
type RealtimeTestTools = {
|
|
507
21
|
name: string;
|
|
508
|
-
silo: Silo;
|
|
22
|
+
silo: AtomIO.Silo;
|
|
509
23
|
dispose: () => void;
|
|
510
24
|
};
|
|
511
25
|
type RealtimeTestClient = RealtimeTestTools & {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { RealtimeProvider } from '../../dist/chunk-C4YZZNRH.js';
|
|
2
1
|
import { recordToEntries } from '../../dist/chunk-NYCVSXQB.js';
|
|
3
|
-
import {
|
|
4
|
-
import '../../dist/chunk-N7ADBQJG.js';
|
|
5
|
-
import { Silo, IMPLICIT, __spreadProps, __spreadValues, clearStore } from '../../dist/chunk-PURABO5G.js';
|
|
2
|
+
import { __spreadProps, __spreadValues } from '../../dist/chunk-PZLG2HP3.js';
|
|
6
3
|
import * as http from 'http';
|
|
7
4
|
import { render, prettyDOM } from '@testing-library/react';
|
|
5
|
+
import * as AtomIO from 'atom.io';
|
|
6
|
+
import * as Internal from 'atom.io/internal';
|
|
7
|
+
import * as AR from 'atom.io/react';
|
|
8
|
+
import * as RTC from 'atom.io/realtime-react';
|
|
8
9
|
import * as Happy from 'happy-dom';
|
|
9
10
|
import * as SocketIO from 'socket.io';
|
|
10
11
|
import { io } from 'socket.io-client';
|
|
@@ -17,13 +18,13 @@ var setupRealtimeTestServer = (options) => {
|
|
|
17
18
|
if (port === null)
|
|
18
19
|
throw new Error(`Could not determine port for test server`);
|
|
19
20
|
const server = new SocketIO.Server(httpServer);
|
|
20
|
-
const silo = new Silo(`SERVER`, IMPLICIT.STORE);
|
|
21
|
+
const silo = new AtomIO.Silo(`SERVER`, Internal.IMPLICIT.STORE);
|
|
21
22
|
server.on(`connection`, (socket) => {
|
|
22
23
|
options.server({ socket, silo });
|
|
23
24
|
});
|
|
24
25
|
const dispose = () => {
|
|
25
26
|
server.close();
|
|
26
|
-
clearStore(silo.store);
|
|
27
|
+
Internal.clearStore(silo.store);
|
|
27
28
|
};
|
|
28
29
|
return {
|
|
29
30
|
name: `SERVER`,
|
|
@@ -34,11 +35,11 @@ var setupRealtimeTestServer = (options) => {
|
|
|
34
35
|
};
|
|
35
36
|
var setupRealtimeTestClient = (options, name, port) => {
|
|
36
37
|
const socket = io(`http://localhost:${port}/`);
|
|
37
|
-
const silo = new Silo(name, IMPLICIT.STORE);
|
|
38
|
+
const silo = new AtomIO.Silo(name, Internal.IMPLICIT.STORE);
|
|
38
39
|
const { document } = new Happy.Window();
|
|
39
40
|
document.body.innerHTML = `<div id="app"></div>`;
|
|
40
41
|
const renderResult = render(
|
|
41
|
-
/* @__PURE__ */ jsx(StoreProvider, { store: silo.store, children: /* @__PURE__ */ jsx(RealtimeProvider, { socket, children: /* @__PURE__ */ jsx(options.client, {}) }) }),
|
|
42
|
+
/* @__PURE__ */ jsx(AR.StoreProvider, { store: silo.store, children: /* @__PURE__ */ jsx(RTC.RealtimeProvider, { socket, children: /* @__PURE__ */ jsx(options.client, {}) }) }),
|
|
42
43
|
{
|
|
43
44
|
container: document.querySelector(`#app`)
|
|
44
45
|
}
|
|
@@ -48,7 +49,7 @@ var setupRealtimeTestClient = (options, name, port) => {
|
|
|
48
49
|
const reconnect = () => socket.connect();
|
|
49
50
|
const dispose = () => {
|
|
50
51
|
socket.disconnect();
|
|
51
|
-
clearStore(silo.store);
|
|
52
|
+
Internal.clearStore(silo.store);
|
|
52
53
|
};
|
|
53
54
|
return {
|
|
54
55
|
name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/setup-realtime-test.tsx"],"names":["clients"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/setup-realtime-test.tsx"],"names":["clients"],"mappings":";;;;;;;;;AAAA,YAAY,UAAU;AAEtB,SAA4B,WAAW,cAAc;AACrD,YAAY,YAAY;AACxB,YAAY,cAAc;AAC1B,YAAY,QAAQ;AACpB,YAAY,SAAS;AACrB,YAAY,WAAW;AAEvB,YAAY,cAAc;AAE1B,SAAS,UAAU;AAoFf;AAxCG,IAAM,0BAA0B,CACtC,YACwB;AACxB,QAAM,aAAkB,kBAAa,CAAC,GAAG,QAAQ,IAAI,IAAI,cAAc,CAAC;AACxE,QAAM,UAAU,WAAW,OAAO,EAAE,QAAQ;AAC5C,QAAM,OACL,OAAO,YAAY,WAAW,KAAK,YAAY,OAAO,OAAO,QAAQ;AACtE,MAAI,SAAS;AAAM,UAAM,IAAI,MAAM,0CAA0C;AAC7E,QAAM,SAAS,IAAa,gBAAO,UAAU;AAC7C,QAAM,OAAO,IAAW,YAAK,UAAmB,kBAAS,KAAK;AAE9D,SAAO,GAAG,cAAc,CAAC,WAA4B;AACpD,YAAQ,OAAO,EAAE,QAAQ,KAAK,CAAC;AAAA,EAChC,CAAC;AAED,QAAM,UAAU,MAAM;AACrB,WAAO,MAAM;AACb,IAAS,oBAAW,KAAK,KAAK;AAAA,EAC/B;AAEA,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AACO,IAAM,0BAA0B,CACtC,SACA,MACA,SACwB;AACxB,QAAM,SAAuB,GAAG,oBAAoB,IAAI,GAAG;AAC3D,QAAM,OAAO,IAAW,YAAK,MAAe,kBAAS,KAAK;AAE1D,QAAM,EAAE,SAAS,IAAI,IAAU,aAAO;AACtC,WAAS,KAAK,YAAY;AAC1B,QAAM,eAAe;AAAA,IACpB,oBAAI,kBAAH,EAAiB,OAAO,KAAK,OAC7B,8BAAK,sBAAJ,EAAqB,QACrB,8BAAC,QAAQ,QAAR,EAAe,GACjB,GACD;AAAA,IACA;AAAA,MACC,WAAW,SAAS,cAAc,MAAM;AAAA,IACzC;AAAA,EACD;AAEA,QAAM,cAAc,MAAM,QAAQ,IAAI,UAAU,aAAa,SAAS,CAAC;AAEvE,QAAM,aAAa,MAAM,OAAO,WAAW;AAC3C,QAAM,YAAY,MAAM,OAAO,QAAQ;AAEvC,QAAM,UAAU,MAAM;AACrB,WAAO,WAAW;AAClB,IAAS,oBAAW,KAAK,KAAK;AAAA,EAC/B;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAEO,IAAM,eAAe,CAC3B,YACmC;AACnC,QAAM,SAAS,wBAAwB,OAAO;AAC9C,QAAM,SAAS,wBAAwB,SAAS,UAAU,OAAO,IAAI;AAErE,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA,UAAU,MAAM;AACf,aAAO,QAAQ;AACf,aAAO,QAAQ;AAAA,IAChB;AAAA,EACD;AACD;AAEO,IAAM,cAAc,CAC1B,YAC+C;AAC/C,QAAM,SAAS,wBAAwB,OAAO;AAC9C,QAAM,UAAU,gBAAgB,QAAQ,OAAO,EAAE;AAAA,IAChD,CAACA,UAAS,CAAC,MAAM,MAAM,MAAM;AAC5B,MAAAA,SAAQ,IAAI,IAAI;AAAA,QACf,iCAAK,UAAL,EAAc,OAAO;AAAA,QACrB;AAAA,QACA,OAAO;AAAA,MACR;AACA,aAAOA;AAAA,IACR;AAAA,IACA,CAAC;AAAA,EACF;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA,UAAU,MAAM;AACf,iBAAW,CAAC,EAAE,MAAM,KAAK,gBAAgB,OAAO,GAAG;AAClD,eAAO,QAAQ;AAAA,MAChB;AACA,aAAO,QAAQ;AAAA,IAChB;AAAA,EACD;AACD","sourcesContent":["import * as http from \"http\"\n\nimport { type RenderResult, prettyDOM, render } from \"@testing-library/react\"\nimport * as AtomIO from \"atom.io\"\nimport * as Internal from \"atom.io/internal\"\nimport * as AR from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-react\"\nimport * as Happy from \"happy-dom\"\nimport * as React from \"react\"\nimport * as SocketIO from \"socket.io\"\nimport type { Socket as ClientSocket } from \"socket.io-client\"\nimport { io } from \"socket.io-client\"\n\nimport { recordToEntries } from \"~/packages/anvl/src/object\"\n\nexport type TestSetupOptions = {\n\tserver: (tools: { socket: SocketIO.Socket; silo: AtomIO.Silo }) => void\n}\nexport type TestSetupOptions__SingleClient = TestSetupOptions & {\n\tclient: React.FC\n}\nexport type TestSetupOptions__MultiClient<ClientNames extends string> =\n\tTestSetupOptions & {\n\t\tclients: {\n\t\t\t[K in ClientNames]: React.FC\n\t\t}\n\t}\n\nexport type RealtimeTestTools = {\n\tname: string\n\tsilo: AtomIO.Silo\n\tdispose: () => void\n}\nexport type RealtimeTestClient = RealtimeTestTools & {\n\trenderResult: RenderResult\n\tprettyPrint: () => void\n\treconnect: () => void\n\tdisconnect: () => void\n}\nexport type RealtimeTestServer = RealtimeTestTools & {\n\tport: number\n}\n\nexport type RealtimeTestAPI = {\n\tserver: RealtimeTestServer\n\tteardown: () => void\n}\nexport type RealtimeTestAPI__SingleClient = RealtimeTestAPI & {\n\tclient: RealtimeTestClient\n}\nexport type RealtimeTestAPI__MultiClient<ClientNames extends string> =\n\tRealtimeTestAPI & {\n\t\tclients: Record<ClientNames, RealtimeTestClient>\n\t}\n\nexport const setupRealtimeTestServer = (\n\toptions: TestSetupOptions,\n): RealtimeTestServer => {\n\tconst httpServer = http.createServer((_, res) => res.end(`Hello World!`))\n\tconst address = httpServer.listen().address()\n\tconst port =\n\t\ttypeof address === `string` ? 80 : address === null ? null : address.port\n\tif (port === null) throw new Error(`Could not determine port for test server`)\n\tconst server = new SocketIO.Server(httpServer)\n\tconst silo = new AtomIO.Silo(`SERVER`, Internal.IMPLICIT.STORE)\n\n\tserver.on(`connection`, (socket: SocketIO.Socket) => {\n\t\toptions.server({ socket, silo })\n\t})\n\n\tconst dispose = () => {\n\t\tserver.close()\n\t\tInternal.clearStore(silo.store)\n\t}\n\n\treturn {\n\t\tname: `SERVER`,\n\t\tsilo,\n\t\tdispose,\n\t\tport,\n\t}\n}\nexport const setupRealtimeTestClient = (\n\toptions: TestSetupOptions__SingleClient,\n\tname: string,\n\tport: number,\n): RealtimeTestClient => {\n\tconst socket: ClientSocket = io(`http://localhost:${port}/`)\n\tconst silo = new AtomIO.Silo(name, Internal.IMPLICIT.STORE)\n\n\tconst { document } = new Happy.Window()\n\tdocument.body.innerHTML = `<div id=\"app\"></div>`\n\tconst renderResult = render(\n\t\t<AR.StoreProvider store={silo.store}>\n\t\t\t<RTC.RealtimeProvider socket={socket}>\n\t\t\t\t<options.client />\n\t\t\t</RTC.RealtimeProvider>\n\t\t</AR.StoreProvider>,\n\t\t{\n\t\t\tcontainer: document.querySelector(`#app`) as unknown as HTMLElement,\n\t\t},\n\t)\n\n\tconst prettyPrint = () => console.log(prettyDOM(renderResult.container))\n\n\tconst disconnect = () => socket.disconnect()\n\tconst reconnect = () => socket.connect()\n\n\tconst dispose = () => {\n\t\tsocket.disconnect()\n\t\tInternal.clearStore(silo.store)\n\t}\n\n\treturn {\n\t\tname,\n\t\tsilo,\n\t\trenderResult,\n\t\tprettyPrint,\n\t\tdisconnect,\n\t\treconnect,\n\t\tdispose,\n\t}\n}\n\nexport const singleClient = (\n\toptions: TestSetupOptions__SingleClient,\n): RealtimeTestAPI__SingleClient => {\n\tconst server = setupRealtimeTestServer(options)\n\tconst client = setupRealtimeTestClient(options, `CLIENT`, server.port)\n\n\treturn {\n\t\tclient,\n\t\tserver,\n\t\tteardown: () => {\n\t\t\tclient.dispose()\n\t\t\tserver.dispose()\n\t\t},\n\t}\n}\n\nexport const multiClient = <ClientNames extends string>(\n\toptions: TestSetupOptions__MultiClient<ClientNames>,\n): RealtimeTestAPI__MultiClient<ClientNames> => {\n\tconst server = setupRealtimeTestServer(options)\n\tconst clients = recordToEntries(options.clients).reduce(\n\t\t(clients, [name, client]) => {\n\t\t\tclients[name] = setupRealtimeTestClient(\n\t\t\t\t{ ...options, client },\n\t\t\t\tname,\n\t\t\t\tserver.port,\n\t\t\t)\n\t\t\treturn clients\n\t\t},\n\t\t{} as Record<ClientNames, RealtimeTestClient>,\n\t)\n\n\treturn {\n\t\tclients,\n\t\tserver,\n\t\tteardown: () => {\n\t\t\tfor (const [, client] of recordToEntries(clients)) {\n\t\t\t\tclient.dispose()\n\t\t\t}\n\t\t\tserver.dispose()\n\t\t},\n\t}\n}\n"]}
|
|
@@ -1,36 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
var stringifyJson = (json) => JSON.stringify(json);
|
|
6
|
-
|
|
7
|
-
// internal/src/subject.ts
|
|
8
|
-
var Subject = class {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.subscribers = /* @__PURE__ */ new Map();
|
|
11
|
-
}
|
|
12
|
-
subscribe(key, subscriber) {
|
|
13
|
-
this.subscribers.set(key, subscriber);
|
|
14
|
-
const unsubscribe = () => this.unsubscribe(key);
|
|
15
|
-
return unsubscribe;
|
|
16
|
-
}
|
|
17
|
-
unsubscribe(key) {
|
|
18
|
-
this.subscribers.delete(key);
|
|
19
|
-
}
|
|
20
|
-
next(value) {
|
|
21
|
-
const subscribers = this.subscribers.values();
|
|
22
|
-
for (const subscriber of subscribers) {
|
|
23
|
-
subscriber(value);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
};
|
|
3
|
+
var internal = require('atom.io/internal');
|
|
4
|
+
var json = require('atom.io/json');
|
|
27
5
|
|
|
28
6
|
// transceivers/set-rtx/src/set-rtx.ts
|
|
29
7
|
var SetRTX = class _SetRTX extends Set {
|
|
30
8
|
constructor(values, cacheLimit = 0) {
|
|
31
9
|
super(values);
|
|
32
10
|
this.mode = `record`;
|
|
33
|
-
this.subject = new Subject();
|
|
11
|
+
this.subject = new internal.Subject();
|
|
34
12
|
this.cacheLimit = 0;
|
|
35
13
|
this.cache = [];
|
|
36
14
|
this.cacheIdx = -1;
|
|
@@ -70,7 +48,7 @@ var SetRTX = class _SetRTX extends Set {
|
|
|
70
48
|
add(value) {
|
|
71
49
|
if (this.mode === `record`) {
|
|
72
50
|
this.cacheUpdateNumber++;
|
|
73
|
-
this.emit(`add:${stringifyJson(value)}`);
|
|
51
|
+
this.emit(`add:${json.stringifyJson(value)}`);
|
|
74
52
|
}
|
|
75
53
|
return super.add(value);
|
|
76
54
|
}
|
|
@@ -84,7 +62,7 @@ var SetRTX = class _SetRTX extends Set {
|
|
|
84
62
|
delete(value) {
|
|
85
63
|
if (this.mode === `record`) {
|
|
86
64
|
this.cacheUpdateNumber++;
|
|
87
|
-
this.emit(`del:${stringifyJson(value)}`);
|
|
65
|
+
this.emit(`del:${json.stringifyJson(value)}`);
|
|
88
66
|
}
|
|
89
67
|
return super.delete(value);
|
|
90
68
|
}
|
|
@@ -132,13 +110,13 @@ var SetRTX = class _SetRTX extends Set {
|
|
|
132
110
|
const value = update.substring(typeValueBreak + 1);
|
|
133
111
|
switch (type) {
|
|
134
112
|
case `add`:
|
|
135
|
-
this.add(parseJson(value));
|
|
113
|
+
this.add(json.parseJson(value));
|
|
136
114
|
break;
|
|
137
115
|
case `clear`:
|
|
138
116
|
this.clear();
|
|
139
117
|
break;
|
|
140
118
|
case `del`:
|
|
141
|
-
this.delete(parseJson(value));
|
|
119
|
+
this.delete(json.parseJson(value));
|
|
142
120
|
break;
|
|
143
121
|
case `tx`:
|
|
144
122
|
for (const update2 of value.split(`;`)) {
|
|
@@ -198,10 +176,10 @@ var SetRTX = class _SetRTX extends Set {
|
|
|
198
176
|
const value = update.substring(breakpoint + 1);
|
|
199
177
|
switch (type) {
|
|
200
178
|
case `add`:
|
|
201
|
-
this.delete(parseJson(value));
|
|
179
|
+
this.delete(json.parseJson(value));
|
|
202
180
|
break;
|
|
203
181
|
case `del`:
|
|
204
|
-
this.add(parseJson(value));
|
|
182
|
+
this.add(json.parseJson(value));
|
|
205
183
|
break;
|
|
206
184
|
case `clear`: {
|
|
207
185
|
const values = JSON.parse(value);
|