atom.io 0.31.0 → 0.31.1

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.
Files changed (36) hide show
  1. package/dist/{chunk-42UH5F5Q.js → chunk-Y5MBNTVU.js} +240 -32
  2. package/dist/index.d.ts +236 -104
  3. package/dist/index.js +90 -5
  4. package/ephemeral/dist/index.d.ts +35 -25
  5. package/ephemeral/src/find-state.ts +35 -25
  6. package/internal/dist/index.d.ts +15 -10
  7. package/internal/dist/index.js +1 -2
  8. package/internal/src/families/find-in-store.ts +1 -6
  9. package/internal/src/index.ts +17 -9
  10. package/internal/src/ingest-updates/ingest-creation-disposal.ts +2 -3
  11. package/internal/src/install-into-store.ts +48 -0
  12. package/internal/src/molecule.ts +299 -0
  13. package/internal/src/not-found-error.ts +8 -30
  14. package/internal/src/pretty-print.ts +1 -12
  15. package/internal/src/selector/register-selector.ts +1 -8
  16. package/internal/src/store/deposit.ts +10 -8
  17. package/internal/src/store/withdraw.ts +15 -34
  18. package/json/dist/index.js +1 -2
  19. package/package.json +5 -5
  20. package/realtime-server/src/ipc-sockets/child-socket.ts +0 -1
  21. package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +1 -1
  22. package/realtime-testing/dist/index.js +3 -4
  23. package/realtime-testing/src/setup-realtime-test.tsx +4 -4
  24. package/src/atom.ts +53 -29
  25. package/src/dispose-state.ts +12 -2
  26. package/src/get-state.ts +16 -0
  27. package/src/index.ts +73 -3
  28. package/src/realm.ts +169 -0
  29. package/src/selector.ts +20 -0
  30. package/src/set-state.ts +16 -8
  31. package/src/silo.ts +9 -3
  32. package/transceivers/set-rtx/dist/index.js +4 -1
  33. package/transceivers/set-rtx/src/set-rtx.ts +4 -1
  34. package/dist/chunk-ICGFFQ3H.js +0 -272
  35. package/src/allocate.ts +0 -443
  36. package/src/molecule.ts +0 -16
@@ -1,7 +1,306 @@
1
+ import type {
2
+ Above,
3
+ Claim,
4
+ CompoundFrom,
5
+ CompoundTypedKey,
6
+ Hierarchy,
7
+ MoleculeCreation,
8
+ MoleculeDisposal,
9
+ MoleculeTransfer,
10
+ SingularTypedKey,
11
+ Vassal,
12
+ } from "atom.io"
1
13
  import type { Canonical, stringified } from "atom.io/json"
14
+ import { parseJson, stringifyJson } from "atom.io/json"
15
+
16
+ import { disposeFromStore, findInStore } from "./families"
17
+ import { getTrace } from "./get-trace"
18
+ import { newest } from "./lineage"
19
+ import type { Store } from "./store"
20
+ import { IMPLICIT } from "./store"
21
+ import { isChildStore } from "./transaction"
2
22
 
3
23
  export type Molecule<K extends Canonical> = {
4
24
  readonly key: K
5
25
  readonly stringKey: stringified<K>
6
26
  readonly dependsOn: `all` | `any`
7
27
  }
28
+
29
+ export function makeRootMoleculeInStore<S extends string>(
30
+ key: S,
31
+ store: Store = IMPLICIT.STORE,
32
+ ): S {
33
+ const molecule = {
34
+ key,
35
+ stringKey: stringifyJson(key),
36
+ dependsOn: `any`,
37
+ } satisfies Molecule<S>
38
+ store.molecules.set(stringifyJson(key), molecule)
39
+ return key
40
+ }
41
+
42
+ export function allocateIntoStore<
43
+ H extends Hierarchy,
44
+ V extends Vassal<H>,
45
+ A extends Above<V, H>,
46
+ >(
47
+ store: Store,
48
+ provenance: A,
49
+ key: V,
50
+ dependsOn: `all` | `any` = `any`,
51
+ ): Claim<V> {
52
+ const origin = provenance as Canonical | [Canonical, Canonical]
53
+ const stringKey = stringifyJson(key)
54
+ const invalidKeys: stringified<Canonical>[] = []
55
+ const target = newest(store)
56
+
57
+ if (Array.isArray(origin)) {
58
+ for (const formerClaim of origin) {
59
+ const claimString = stringifyJson(formerClaim)
60
+ const claim = target.molecules.get(claimString)
61
+ if (claim) {
62
+ store.moleculeGraph.set(claimString, stringKey, { source: claimString })
63
+ } else {
64
+ invalidKeys.push(claimString)
65
+ }
66
+ }
67
+ } else {
68
+ const claimString = stringifyJson(origin)
69
+ const claim = target.molecules.get(claimString)
70
+ if (claim) {
71
+ store.moleculeGraph.set(claimString, stringKey, { source: claimString })
72
+ } else {
73
+ invalidKeys.push(claimString)
74
+ }
75
+ }
76
+ if (invalidKeys.length === 0) {
77
+ target.molecules.set(stringKey, { key, stringKey, dependsOn })
78
+ }
79
+
80
+ const creationEvent: MoleculeCreation = {
81
+ type: `molecule_creation`,
82
+ key,
83
+ provenance: origin,
84
+ }
85
+ const isTransaction =
86
+ isChildStore(target) && target.transactionMeta.phase === `building`
87
+ if (isTransaction) {
88
+ target.transactionMeta.update.updates.push(creationEvent)
89
+ } else {
90
+ target.on.moleculeCreation.next(creationEvent)
91
+ }
92
+
93
+ for (const claim of invalidKeys) {
94
+ const disposal = store.disposalTraces.buffer.find(
95
+ (item) => item?.key === claim,
96
+ )
97
+ store.logger.error(
98
+ `❌`,
99
+ `molecule`,
100
+ key,
101
+ `allocation failed:`,
102
+ `Could not allocate to ${claim} in store "${store.config.name}".`,
103
+ disposal
104
+ ? `\n ${claim} was most recently disposed\n${disposal.trace}`
105
+ : `No previous disposal trace for ${claim} was found.`,
106
+ )
107
+ }
108
+
109
+ return key as Claim<V>
110
+ }
111
+
112
+ export function fuseWithinStore<
113
+ H extends Hierarchy,
114
+ C extends CompoundFrom<H>,
115
+ T extends C extends CompoundTypedKey<infer t, any, any> ? t : never,
116
+ A extends C extends CompoundTypedKey<any, infer a, any> ? a : never,
117
+ B extends C extends CompoundTypedKey<any, any, infer b> ? b : never,
118
+ >(
119
+ store: Store,
120
+ type: T,
121
+ sideA: SingularTypedKey<A>,
122
+ sideB: SingularTypedKey<B>,
123
+ ): Claim<CompoundTypedKey<T, A, B>> {
124
+ const compoundKey: CompoundTypedKey<T, A, B> =
125
+ `T$--${type}==${sideA}++${sideB}`
126
+ const above = [sideA, sideB] as Above<Vassal<H>, H>
127
+ allocateIntoStore<H, Vassal<H>, Above<Vassal<H>, H>>(
128
+ store,
129
+ above,
130
+ compoundKey as Vassal<H>,
131
+ `all`,
132
+ )
133
+ return compoundKey
134
+ }
135
+
136
+ export function deallocateFromStore<H extends Hierarchy, V extends Vassal<H>>(
137
+ store: Store,
138
+ claim: Claim<V>,
139
+ ): void {
140
+ const stringKey = stringifyJson(claim)
141
+
142
+ const molecule = store.molecules.get(stringKey)
143
+ if (!molecule) {
144
+ const disposal = store.disposalTraces.buffer.find(
145
+ (item) => item?.key === stringKey,
146
+ )
147
+ store.logger.error(
148
+ `❌`,
149
+ `molecule`,
150
+ claim,
151
+ `deallocation failed:`,
152
+ `Could not find allocation for ${stringKey} in store "${store.config.name}".`,
153
+ disposal
154
+ ? `\n This state was most recently deallocated\n${disposal.trace}`
155
+ : `No previous disposal trace for ${stringKey} was found.`,
156
+ )
157
+ return
158
+ }
159
+
160
+ const joinKeys = store.moleculeJoins.getRelatedKeys(
161
+ molecule.key as string /* 💥 RECONCILE */,
162
+ )
163
+ if (joinKeys) {
164
+ for (const joinKey of joinKeys) {
165
+ const join = store.joins.get(joinKey)
166
+ if (join) {
167
+ join.relations.delete(molecule.key)
168
+ join.molecules.delete(molecule.stringKey) // get rid of
169
+ }
170
+ }
171
+ }
172
+ store.moleculeJoins.delete(molecule.stringKey)
173
+
174
+ const provenance: stringified<Canonical>[] = []
175
+
176
+ const values: [string, any][] = []
177
+ const disposalEvent: MoleculeDisposal = {
178
+ type: `molecule_disposal`,
179
+ key: molecule.key,
180
+ values,
181
+ provenance,
182
+ }
183
+ const target = newest(store)
184
+ target.molecules.delete(stringKey)
185
+ const isTransaction =
186
+ isChildStore(target) && target.transactionMeta.phase === `building`
187
+ if (isTransaction) {
188
+ target.transactionMeta.update.updates.push(disposalEvent)
189
+ }
190
+ const relatedMolecules = store.moleculeGraph.getRelationEntries({
191
+ downstreamMoleculeKey: molecule.stringKey,
192
+ })
193
+ if (relatedMolecules) {
194
+ for (const [relatedStringKey, { source }] of relatedMolecules) {
195
+ if (source === molecule.stringKey) {
196
+ const relatedKey = parseJson(relatedStringKey)
197
+ deallocateFromStore<any, any>(store, relatedKey)
198
+ } else {
199
+ provenance.push(source)
200
+ }
201
+ }
202
+ }
203
+ const familyKeys = target.moleculeData.getRelatedKeys(molecule.stringKey)
204
+ if (familyKeys) {
205
+ for (const familyKey of familyKeys) {
206
+ // biome-ignore lint/style/noNonNullAssertion: tokens of molecules must have a family
207
+ const family = target.families.get(familyKey)!
208
+ const token = findInStore(store, family, molecule.key)
209
+ values.push([family.key, token])
210
+ disposeFromStore(store, token)
211
+ }
212
+ }
213
+
214
+ target.moleculeGraph.delete(molecule.stringKey)
215
+ target.moleculeJoins.delete(molecule.stringKey)
216
+ target.moleculeData.delete(molecule.stringKey)
217
+
218
+ if (!isTransaction) {
219
+ target.on.moleculeDisposal.next(disposalEvent)
220
+ }
221
+ target.molecules.delete(molecule.stringKey)
222
+
223
+ const trace = getTrace(new Error())
224
+ store.disposalTraces.add({ key: stringKey, trace })
225
+ }
226
+ export function claimWithinStore<
227
+ H extends Hierarchy,
228
+ V extends Exclude<Vassal<H>, CompoundTypedKey>,
229
+ A extends Above<V, H>,
230
+ >(
231
+ store: Store,
232
+ newProvenance: A,
233
+ claim: Claim<V>,
234
+ exclusive?: `exclusive`,
235
+ ): Claim<V> {
236
+ const stringKey = stringifyJson(claim)
237
+ const target = newest(store)
238
+ const molecule = target.molecules.get(stringKey)
239
+ if (!molecule) {
240
+ const disposal = store.disposalTraces.buffer.find(
241
+ (item) => item?.key === stringKey,
242
+ )
243
+ store.logger.error(
244
+ `❌`,
245
+ `molecule`,
246
+ claim,
247
+ `claim failed:`,
248
+ `Could not allocate to ${stringKey} in store "${store.config.name}".`,
249
+ disposal
250
+ ? `\n ${stringKey} was most recently disposed\n${disposal.trace}`
251
+ : `No previous disposal trace for ${stringKey} was found.`,
252
+ )
253
+ return claim
254
+ }
255
+
256
+ const newProvenanceKey = stringifyJson(newProvenance as Canonical)
257
+ const newProvenanceMolecule = target.molecules.get(newProvenanceKey)
258
+ if (!newProvenanceMolecule) {
259
+ const disposal = store.disposalTraces.buffer.find(
260
+ (item) => item?.key === newProvenanceKey,
261
+ )
262
+ store.logger.error(
263
+ `❌`,
264
+ `molecule`,
265
+ claim,
266
+ `claim failed:`,
267
+ `Could not allocate to ${newProvenanceKey} in store "${store.config.name}".`,
268
+ disposal
269
+ ? `\n ${newProvenanceKey} was most recently disposed\n${disposal.trace}`
270
+ : `No previous disposal trace for ${newProvenanceKey} was found.`,
271
+ )
272
+ return claim
273
+ }
274
+
275
+ const priorProvenance = store.moleculeGraph
276
+ .getRelationEntries({
277
+ downstreamMoleculeKey: molecule.stringKey,
278
+ })
279
+ .filter(([, { source }]) => source !== stringKey)
280
+ .map(([key]) => parseJson(key))
281
+ if (exclusive) {
282
+ target.moleculeGraph.delete(stringKey)
283
+ }
284
+ target.moleculeGraph.set(
285
+ {
286
+ upstreamMoleculeKey: newProvenanceMolecule.stringKey,
287
+ downstreamMoleculeKey: molecule.stringKey,
288
+ },
289
+ {
290
+ source: newProvenanceMolecule.stringKey,
291
+ },
292
+ )
293
+ const transferEvent: MoleculeTransfer = {
294
+ type: `molecule_transfer`,
295
+ key: molecule.key,
296
+ from: priorProvenance,
297
+ to: [newProvenanceMolecule.key],
298
+ }
299
+ const isTransaction =
300
+ isChildStore(target) && target.transactionMeta.phase === `building`
301
+ if (isTransaction) {
302
+ target.transactionMeta.update.updates.push(transferEvent)
303
+ }
304
+
305
+ return claim
306
+ }
@@ -1,37 +1,15 @@
1
- import { type Json, stringifyJson } from "atom.io/json"
1
+ import type { AtomIOToken } from "atom.io"
2
+ import { stringifyJson } from "atom.io/json"
2
3
 
3
- import type { AtomIOToken } from "./pretty-print"
4
4
  import { prettyPrintTokenType } from "./pretty-print"
5
5
  import type { Store } from "./store"
6
6
 
7
7
  export class NotFoundError extends Error {
8
- public constructor(token: AtomIOToken, store: Store)
9
- public constructor(
10
- familyToken: AtomIOToken,
11
- key: Json.Serializable,
12
- store: Store,
13
- )
14
- public constructor(
15
- ...params:
16
- | [token: AtomIOToken, key: Json.Serializable, store: Store]
17
- | [token: AtomIOToken, store: Store]
18
- ) {
19
- const token: AtomIOToken = params[0]
20
- const store: Store = params.length === 2 ? params[1] : params[2]
21
-
22
- if (params.length === 2) {
23
- super(
24
- `${prettyPrintTokenType(token)} ${stringifyJson(token.key)} not found in store "${
25
- store.config.name
26
- }".`,
27
- )
28
- } else {
29
- const key = params[1]
30
- super(
31
- `${prettyPrintTokenType(token)} "${token.key}" member ${stringifyJson(key)} not found in store "${
32
- store.config.name
33
- }".`,
34
- )
35
- }
8
+ public constructor(token: AtomIOToken, store: Store) {
9
+ super(
10
+ `${prettyPrintTokenType(token)} ${stringifyJson(token.key)} not found in store "${
11
+ store.config.name
12
+ }".`,
13
+ )
36
14
  }
37
15
  }
@@ -1,18 +1,7 @@
1
- import type {
2
- ReadableFamilyToken,
3
- ReadableToken,
4
- TimelineToken,
5
- TransactionToken,
6
- } from "atom.io"
1
+ import type { AtomIOToken } from "atom.io"
7
2
 
8
3
  const capitalize = (str: string) => str[0].toUpperCase() + str.slice(1)
9
4
 
10
- export type AtomIOToken =
11
- | ReadableFamilyToken<any, any>
12
- | ReadableToken<any>
13
- | TimelineToken<any>
14
- | TransactionToken<any>
15
-
16
5
  export function prettyPrintTokenType(token: AtomIOToken): string {
17
6
  return token.type.split(`_`).map(capitalize).join(` `)
18
7
  }
@@ -82,14 +82,7 @@ export const registerSelector = (
82
82
  const family = params[0]
83
83
  const key = params[1]
84
84
  value = params[2]
85
- const maybeToken =
86
- store.config.lifespan === `ephemeral`
87
- ? findInStore(store, family, key)
88
- : seekInStore(store, family, key)
89
- if (!maybeToken) {
90
- throw new NotFoundError(family, key, store)
91
- }
92
- token = maybeToken
85
+ token = findInStore(store, family, key)
93
86
  }
94
87
  const target = newest(store)
95
88
  const state = withdraw(token, target)
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  AtomFamilyToken,
3
+ AtomIOToken,
3
4
  AtomToken,
4
5
  MutableAtomFamilyToken,
5
6
  MutableAtomToken,
@@ -11,6 +12,8 @@ import type {
11
12
  RegularAtomToken,
12
13
  SelectorFamilyToken,
13
14
  SelectorToken,
15
+ TimelineManageable,
16
+ TimelineToken,
14
17
  TransactionToken,
15
18
  WritableFamilyToken,
16
19
  WritableSelectorFamilyToken,
@@ -22,6 +25,7 @@ import type { Canonical, Json } from "atom.io/json"
22
25
  import type {
23
26
  Atom,
24
27
  AtomFamily,
28
+ AtomIOInternalResource,
25
29
  Func,
26
30
  MutableAtom,
27
31
  MutableAtomFamily,
@@ -33,6 +37,7 @@ import type {
33
37
  RegularAtomFamily,
34
38
  Selector,
35
39
  SelectorFamily,
40
+ Timeline,
36
41
  Transceiver,
37
42
  WritableFamily,
38
43
  WritableSelector,
@@ -80,16 +85,13 @@ export function deposit<T>(
80
85
  export function deposit<T extends Func>(
81
86
  state: Transaction<T>,
82
87
  ): TransactionToken<T>
88
+ export function deposit<M extends TimelineManageable>(
89
+ state: Timeline<M>,
90
+ ): TimelineToken<M>
83
91
 
84
- export function deposit(state: ReadableState<any>): ReadableToken<any>
92
+ export function deposit(resource: AtomIOInternalResource): AtomIOToken
85
93
 
86
- export function deposit(
87
- state: ReadableFamily<any, any> | ReadableState<any> | Transaction<Func>,
88
- ): ReadableFamilyToken<any, any> | ReadableToken<any> | TransactionToken<Func>
89
-
90
- export function deposit(
91
- state: ReadableFamily<any, any> | ReadableState<any> | Transaction<Func>,
92
- ): ReadableFamilyToken<any, any> | ReadableToken<any> | TransactionToken<Func> {
94
+ export function deposit(state: AtomIOInternalResource): AtomIOToken {
93
95
  const token = {
94
96
  key: state.key,
95
97
  type: state.type,
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  AtomFamilyToken,
3
+ AtomIOToken,
3
4
  AtomToken,
4
5
  MutableAtomFamilyToken,
5
6
  MutableAtomToken,
@@ -24,8 +25,8 @@ import type { Canonical, Json } from "atom.io/json"
24
25
  import type {
25
26
  Atom,
26
27
  AtomFamily,
28
+ AtomIOInternalResource,
27
29
  Func,
28
- Molecule,
29
30
  MutableAtom,
30
31
  MutableAtomFamily,
31
32
  ReadableFamily,
@@ -47,27 +48,6 @@ import type { Timeline } from "../timeline"
47
48
  import type { Transaction } from "../transaction"
48
49
  import type { Store } from "./store"
49
50
 
50
- export type Withdrawable =
51
- | Atom<any>
52
- | AtomFamily<any, any>
53
- | Molecule<any>
54
- | MutableAtom<any, any>
55
- | MutableAtomFamily<any, any, any>
56
- | ReadableFamily<any, any>
57
- | ReadableState<any>
58
- | ReadonlySelector<any>
59
- | ReadonlySelectorFamily<any, any>
60
- | RegularAtom<any>
61
- | RegularAtomFamily<any, any>
62
- | Selector<any>
63
- | SelectorFamily<any, any>
64
- | Timeline<any>
65
- | Transaction<any>
66
- | WritableFamily<any, any>
67
- | WritableSelector<any>
68
- | WritableSelectorFamily<any, any>
69
- | WritableState<any>
70
-
71
51
  export function withdraw<T>(
72
52
  token: RegularAtomToken<T>,
73
53
  store: Store,
@@ -141,24 +121,25 @@ export function withdraw<T>(
141
121
  store: Store,
142
122
  ): Timeline<T extends TimelineManageable ? T : never>
143
123
 
124
+ export function withdraw<T>(
125
+ token: WritableToken<T>,
126
+ store: Store,
127
+ ): WritableState<T>
144
128
  export function withdraw<T>(
145
129
  token: ReadableToken<T>,
146
130
  store: Store,
147
131
  ): ReadableState<T>
148
132
 
149
133
  export function withdraw(
150
- token:
151
- | MutableAtomFamilyToken<any, any, any>
152
- | MutableAtomToken<any, any>
153
- | RegularAtomFamilyToken<any, any>
154
- | RegularAtomToken<any>
155
- | SelectorFamilyToken<any, any>
156
- | SelectorToken<any>
157
- | TimelineToken<any>
158
- | TransactionToken<any>,
159
- store: Store,
160
- ): Withdrawable {
161
- let withdrawn: Withdrawable | undefined
134
+ token: AtomIOToken,
135
+ store: Store,
136
+ ): AtomIOInternalResource
137
+
138
+ export function withdraw(
139
+ token: AtomIOToken,
140
+ store: Store,
141
+ ): AtomIOInternalResource {
142
+ let withdrawn: AtomIOInternalResource | undefined
162
143
  let target: Store | null = store
163
144
  while (target !== null) {
164
145
  switch (token.type) {
@@ -1,5 +1,4 @@
1
- import { createWritableSelectorFamily } from '../../dist/chunk-42UH5F5Q.js';
2
- import '../../dist/chunk-ICGFFQ3H.js';
1
+ import { createWritableSelectorFamily } from '../../dist/chunk-Y5MBNTVU.js';
3
2
  import '../../dist/chunk-XWL6SNVU.js';
4
3
  import { createStandaloneSelector, IMPLICIT, withdraw, seekInStore } from 'atom.io/internal';
5
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atom.io",
3
- "version": "0.31.0",
3
+ "version": "0.31.1",
4
4
  "description": "Composable and testable reactive data library.",
5
5
  "homepage": "https://atom.io.fyi",
6
6
  "sideEffects": false,
@@ -64,12 +64,12 @@
64
64
  "@typescript-eslint/utils": "8.24.1",
65
65
  "@vitest/coverage-v8": "3.0.6",
66
66
  "@vitest/ui": "3.0.6",
67
- "bun-types": "1.2.2",
67
+ "bun-types": "1.2.3",
68
68
  "concurrently": "9.1.2",
69
69
  "drizzle-kit": "0.30.4",
70
70
  "drizzle-orm": "0.39.3",
71
- "eslint": "9.20.1",
72
- "happy-dom": "17.1.1",
71
+ "eslint": "9.21.0",
72
+ "happy-dom": "17.1.4",
73
73
  "http-proxy": "1.18.1",
74
74
  "motion": "12.4.7",
75
75
  "npmlog": "7.0.1",
@@ -90,7 +90,7 @@
90
90
  "vitest": "3.0.6",
91
91
  "zod": "3.24.2",
92
92
  "break-check": "0.6.6",
93
- "recoverage": "0.0.6"
93
+ "recoverage": "0.0.7"
94
94
  },
95
95
  "main": "dist/index.js",
96
96
  "types": "dist/index.d.ts",
@@ -1,5 +1,4 @@
1
1
  import type { ChildProcessWithoutNullStreams } from "node:child_process"
2
- import type { Console } from "node:console"
3
2
 
4
3
  import type { Json } from "atom.io/json"
5
4
  import { parseJson } from "atom.io/json"
@@ -1,5 +1,5 @@
1
1
  import * as AtomIO from "atom.io"
2
- import { editRelations, editRelationsInStore, type Loadable } from "atom.io/data"
2
+ import { editRelationsInStore, type Loadable } from "atom.io/data"
3
3
  import type { UserInRoomMeta } from "atom.io/realtime"
4
4
  import { roomIndex, usersInRooms } from "atom.io/realtime"
5
5
 
@@ -63,7 +63,6 @@ var setupRealtimeTestServer = (options) => {
63
63
  RTS.socketIndex,
64
64
  (index) => index.add(socketClaim)
65
65
  );
66
- console.log(`${username} connected on ${socket.id}`);
67
66
  next();
68
67
  } else {
69
68
  next(new Error(`Authentication error`));
@@ -85,11 +84,11 @@ var setupRealtimeTestServer = (options) => {
85
84
  socket.onAnyOutgoing((event, ...args) => {
86
85
  console.log(`\u{1F6F0} >>`, userKey, event, ...args);
87
86
  });
87
+ socket.on(`disconnect`, () => {
88
+ console.log(`${userKey} disconnected`);
89
+ });
88
90
  }
89
91
  options.server({ socket, enableLogging, silo });
90
- socket.on(`disconnect`, () => {
91
- console.log(`${userKey} disconnected`);
92
- });
93
92
  });
94
93
  const dispose = async () => {
95
94
  await server.close();
@@ -130,7 +130,7 @@ export const setupRealtimeTestServer = (
130
130
  setIntoStore(silo.store, RTS.socketIndex, (index) =>
131
131
  index.add(socketClaim),
132
132
  )
133
- console.log(`${username} connected on ${socket.id}`)
133
+ // console.log(`${username} connected on ${socket.id}`)
134
134
  next()
135
135
  } else {
136
136
  next(new Error(`Authentication error`))
@@ -153,11 +153,11 @@ export const setupRealtimeTestServer = (
153
153
  socket.onAnyOutgoing((event, ...args) => {
154
154
  console.log(`🛰 >>`, userKey, event, ...args)
155
155
  })
156
+ socket.on(`disconnect`, () => {
157
+ console.log(`${userKey} disconnected`)
158
+ })
156
159
  }
157
160
  options.server({ socket, enableLogging, silo })
158
- socket.on(`disconnect`, () => {
159
- console.log(`${userKey} disconnected`)
160
- })
161
161
  })
162
162
 
163
163
  const dispose = async () => {