atom.io 0.30.1 → 0.30.2
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.js +18 -16
- package/data/src/join.ts +18 -16
- package/dist/{chunk-SMKF3ZNG.js → chunk-LSCRHXLI.js} +22 -5
- package/internal/dist/index.d.ts +3 -1
- package/internal/dist/index.js +1 -1
- package/internal/src/junction.ts +23 -7
- package/json/dist/index.js +1 -1
- package/package.json +1 -1
- package/realtime-server/dist/index.d.ts +2 -2
- package/realtime-server/src/realtime-server-stores/server-user-store.ts +4 -4
- package/realtime-testing/dist/index.js +6 -2
- package/realtime-testing/src/setup-realtime-test.tsx +4 -2
package/data/dist/index.js
CHANGED
|
@@ -332,17 +332,18 @@ var Join = class _Join {
|
|
|
332
332
|
store,
|
|
333
333
|
{
|
|
334
334
|
key: `${options.key}/singleRelatedEntry`,
|
|
335
|
-
get: (
|
|
336
|
-
const relatedKeysState = this.retrieve(relatedKeysAtoms,
|
|
335
|
+
get: (x) => ({ get }) => {
|
|
336
|
+
const relatedKeysState = this.retrieve(relatedKeysAtoms, x);
|
|
337
337
|
const relatedKeys = get(relatedKeysState);
|
|
338
|
-
for (const
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
338
|
+
for (const y of relatedKeys) {
|
|
339
|
+
let a = relations.isAType?.(x) ? x : void 0;
|
|
340
|
+
let b = a === void 0 ? x : void 0;
|
|
341
|
+
a ??= y;
|
|
342
|
+
b ??= y;
|
|
343
|
+
const contentKey = relations.makeContentKey(a, b);
|
|
343
344
|
const contentState = this.retrieve(contentAtoms, contentKey);
|
|
344
345
|
const content = get(contentState);
|
|
345
|
-
return [
|
|
346
|
+
return [y, content];
|
|
346
347
|
}
|
|
347
348
|
return null;
|
|
348
349
|
}
|
|
@@ -353,18 +354,19 @@ var Join = class _Join {
|
|
|
353
354
|
store,
|
|
354
355
|
{
|
|
355
356
|
key: `${options.key}/multipleRelatedEntries`,
|
|
356
|
-
get: (
|
|
357
|
+
get: (x) => ({ get }) => {
|
|
357
358
|
const jsonFamily = getJsonFamily(relatedKeysAtoms, store);
|
|
358
|
-
const jsonState = this.retrieve(jsonFamily,
|
|
359
|
+
const jsonState = this.retrieve(jsonFamily, x);
|
|
359
360
|
const json = get(jsonState);
|
|
360
|
-
return json.members.map((
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
361
|
+
return json.members.map((y) => {
|
|
362
|
+
let a = relations.isAType?.(x) ? x : void 0;
|
|
363
|
+
let b = a === void 0 ? x : void 0;
|
|
364
|
+
a ??= y;
|
|
365
|
+
b ??= y;
|
|
366
|
+
const contentKey = relations.makeContentKey(a, b);
|
|
365
367
|
const contentState = this.retrieve(contentAtoms, contentKey);
|
|
366
368
|
const content = get(contentState);
|
|
367
|
-
return [
|
|
369
|
+
return [y, content];
|
|
368
370
|
});
|
|
369
371
|
}
|
|
370
372
|
},
|
package/data/src/join.ts
CHANGED
|
@@ -556,18 +556,19 @@ export class Join<
|
|
|
556
556
|
{
|
|
557
557
|
key: `${options.key}/singleRelatedEntry`,
|
|
558
558
|
get:
|
|
559
|
-
(
|
|
559
|
+
(x) =>
|
|
560
560
|
({ get }) => {
|
|
561
|
-
const relatedKeysState = this.retrieve(relatedKeysAtoms,
|
|
561
|
+
const relatedKeysState = this.retrieve(relatedKeysAtoms, x)
|
|
562
562
|
const relatedKeys = get(relatedKeysState)
|
|
563
|
-
for (const
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
563
|
+
for (const y of relatedKeys) {
|
|
564
|
+
let a = relations.isAType?.(x) ? x : undefined
|
|
565
|
+
let b = a === undefined ? (x as BType) : undefined
|
|
566
|
+
a ??= y as AType
|
|
567
|
+
b ??= y as BType
|
|
568
|
+
const contentKey = relations.makeContentKey(a, b)
|
|
568
569
|
const contentState = this.retrieve(contentAtoms, contentKey)
|
|
569
570
|
const content = get(contentState)
|
|
570
|
-
return [
|
|
571
|
+
return [y, content]
|
|
571
572
|
}
|
|
572
573
|
return null
|
|
573
574
|
},
|
|
@@ -580,19 +581,20 @@ export class Join<
|
|
|
580
581
|
{
|
|
581
582
|
key: `${options.key}/multipleRelatedEntries`,
|
|
582
583
|
get:
|
|
583
|
-
(
|
|
584
|
+
(x) =>
|
|
584
585
|
({ get }) => {
|
|
585
586
|
const jsonFamily = getJsonFamily(relatedKeysAtoms, store)
|
|
586
|
-
const jsonState = this.retrieve(jsonFamily,
|
|
587
|
+
const jsonState = this.retrieve(jsonFamily, x)
|
|
587
588
|
const json = get(jsonState)
|
|
588
|
-
return json.members.map((
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
589
|
+
return json.members.map((y) => {
|
|
590
|
+
let a = relations.isAType?.(x) ? x : undefined
|
|
591
|
+
let b = a === undefined ? (x as BType) : undefined
|
|
592
|
+
a ??= y as AType
|
|
593
|
+
b ??= y as BType
|
|
594
|
+
const contentKey = relations.makeContentKey(a, b)
|
|
593
595
|
const contentState = this.retrieve(contentAtoms, contentKey)
|
|
594
596
|
const content = get(contentState)
|
|
595
|
-
return [
|
|
597
|
+
return [y, content]
|
|
596
598
|
})
|
|
597
599
|
},
|
|
598
600
|
},
|
|
@@ -121,6 +121,8 @@ var Junction = class {
|
|
|
121
121
|
cardinality;
|
|
122
122
|
relations = /* @__PURE__ */ new Map();
|
|
123
123
|
contents = /* @__PURE__ */ new Map();
|
|
124
|
+
isAType;
|
|
125
|
+
isBType;
|
|
124
126
|
isContent;
|
|
125
127
|
makeContentKey = (a, b) => `${a}:${b}`;
|
|
126
128
|
warn;
|
|
@@ -168,8 +170,12 @@ var Junction = class {
|
|
|
168
170
|
}
|
|
169
171
|
replaceRelationsSafely(x, ys) {
|
|
170
172
|
const xRelationsPrev = this.relations.get(x);
|
|
173
|
+
let a = this.isAType?.(x) ? x : void 0;
|
|
174
|
+
let b = a === void 0 ? x : void 0;
|
|
171
175
|
if (xRelationsPrev) {
|
|
172
176
|
for (const y of xRelationsPrev) {
|
|
177
|
+
a ??= y;
|
|
178
|
+
b ??= y;
|
|
173
179
|
const yRelations = this.relations.get(y);
|
|
174
180
|
if (yRelations) {
|
|
175
181
|
if (yRelations.size === 1) {
|
|
@@ -177,7 +183,7 @@ var Junction = class {
|
|
|
177
183
|
} else {
|
|
178
184
|
yRelations.delete(x);
|
|
179
185
|
}
|
|
180
|
-
this.contents.delete(this.makeContentKey(
|
|
186
|
+
this.contents.delete(this.makeContentKey(a, b));
|
|
181
187
|
}
|
|
182
188
|
}
|
|
183
189
|
}
|
|
@@ -211,6 +217,8 @@ var Junction = class {
|
|
|
211
217
|
);
|
|
212
218
|
this.contents = new Map(data.contents);
|
|
213
219
|
}
|
|
220
|
+
this.isAType = config?.isAType ?? null;
|
|
221
|
+
this.isBType = config?.isBType ?? null;
|
|
214
222
|
this.isContent = config?.isContent ?? null;
|
|
215
223
|
if (config?.makeContentKey) {
|
|
216
224
|
this.makeContentKey = config.makeContentKey;
|
|
@@ -245,7 +253,13 @@ var Junction = class {
|
|
|
245
253
|
};
|
|
246
254
|
}
|
|
247
255
|
for (const [x, ys] of data.relations ?? []) {
|
|
248
|
-
|
|
256
|
+
let a = this.isAType?.(x) ? x : void 0;
|
|
257
|
+
let b = a === void 0 ? x : void 0;
|
|
258
|
+
for (const y of ys) {
|
|
259
|
+
a ??= y;
|
|
260
|
+
b ??= y;
|
|
261
|
+
this.addRelation(a, b);
|
|
262
|
+
}
|
|
249
263
|
}
|
|
250
264
|
for (const [contentKey, content] of data.contents ?? []) {
|
|
251
265
|
this.setContent(contentKey, content);
|
|
@@ -326,9 +340,12 @@ var Junction = class {
|
|
|
326
340
|
].map((k) => `"${k}"`).join(`, `)}). Only one related key was expected.`
|
|
327
341
|
);
|
|
328
342
|
}
|
|
343
|
+
let singleRelation;
|
|
329
344
|
for (const relation of relations) {
|
|
330
|
-
|
|
345
|
+
singleRelation = relation;
|
|
346
|
+
break;
|
|
331
347
|
}
|
|
348
|
+
return singleRelation;
|
|
332
349
|
}
|
|
333
350
|
}
|
|
334
351
|
replaceRelations(x, relations, config) {
|
|
@@ -359,7 +376,7 @@ var Junction = class {
|
|
|
359
376
|
const aRelations = this.getRelatedKeys(a);
|
|
360
377
|
if (aRelations) {
|
|
361
378
|
return [...aRelations].map((aRelation) => {
|
|
362
|
-
return [aRelation, this.getContent(a, aRelation)
|
|
379
|
+
return [aRelation, this.getContent(a, aRelation)];
|
|
363
380
|
});
|
|
364
381
|
}
|
|
365
382
|
}
|
|
@@ -367,7 +384,7 @@ var Junction = class {
|
|
|
367
384
|
const bRelations = this.getRelatedKeys(b);
|
|
368
385
|
if (bRelations) {
|
|
369
386
|
return [...bRelations].map((bRelation) => {
|
|
370
|
-
return [bRelation, this.getContent(bRelation, b)
|
|
387
|
+
return [bRelation, this.getContent(bRelation, b)];
|
|
371
388
|
});
|
|
372
389
|
}
|
|
373
390
|
}
|
package/internal/dist/index.d.ts
CHANGED
|
@@ -66,6 +66,8 @@ declare class Junction<const ASide extends string, const AType extends string, c
|
|
|
66
66
|
readonly cardinality: `1:1` | `1:n` | `n:n`;
|
|
67
67
|
readonly relations: Map<AType | BType, Set<AType> | Set<BType>>;
|
|
68
68
|
readonly contents: Map<string, Content>;
|
|
69
|
+
isAType?: Refinement<string, AType> | null;
|
|
70
|
+
isBType?: Refinement<string, BType> | null;
|
|
69
71
|
isContent: Refinement<unknown, Content> | null;
|
|
70
72
|
makeContentKey: (a: AType, b: BType) => string;
|
|
71
73
|
warn?: (...args: any[]) => void;
|
|
@@ -81,7 +83,7 @@ declare class Junction<const ASide extends string, const AType extends string, c
|
|
|
81
83
|
protected getContentInternal(contentKey: string): Content | undefined;
|
|
82
84
|
protected setContent(contentKey: string, content: Content): void;
|
|
83
85
|
protected deleteContent(contentKey: string): void;
|
|
84
|
-
constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<AType
|
|
86
|
+
constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<NoInfer<AType>, NoInfer<BType>, Content>>, config?: JunctionAdvancedConfiguration<AType, BType, Content>);
|
|
85
87
|
toJSON(): JunctionJSON<ASide, AType, BSide, BType, Content>;
|
|
86
88
|
set(a: AType, ...rest: Content extends null ? [b: BType] : [b: BType, content: Content]): this;
|
|
87
89
|
set(relation: {
|
package/internal/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, Future, IMPLICIT, Junction, LazyMap, Molecule, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, counterfeit, createAtomFamily, createMoleculeFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deposit, disposeAtom, disposeFromStore, disposeMolecule, disposeSelector, eldest, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateFamily, getUpdateToken, growMoleculeInStore, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, prettyPrintTokenType, readCachedValue, readOrComputeValue, recallState, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw } from '../../dist/chunk-
|
|
1
|
+
export { FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, Future, IMPLICIT, Junction, LazyMap, Molecule, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, counterfeit, createAtomFamily, createMoleculeFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deposit, disposeAtom, disposeFromStore, disposeMolecule, disposeSelector, eldest, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateFamily, getUpdateToken, growMoleculeInStore, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, prettyPrintTokenType, readCachedValue, readOrComputeValue, recallState, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw } from '../../dist/chunk-LSCRHXLI.js';
|
|
2
2
|
import '../../dist/chunk-ADMEAXYU.js';
|
|
3
3
|
import '../../dist/chunk-XWL6SNVU.js';
|
package/internal/src/junction.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Refinement } from "atom.io/introspection"
|
|
2
2
|
import type { Json } from "atom.io/json"
|
|
3
|
-
import { B } from "vitest/dist/chunks/benchmark.JVlTzojj.js"
|
|
4
3
|
|
|
5
4
|
export type JunctionEntriesBase<
|
|
6
5
|
AType extends string,
|
|
@@ -86,6 +85,8 @@ export class Junction<
|
|
|
86
85
|
public readonly relations = new Map<AType | BType, Set<AType> | Set<BType>>()
|
|
87
86
|
public readonly contents = new Map<string, Content>()
|
|
88
87
|
|
|
88
|
+
public isAType?: Refinement<string, AType> | null
|
|
89
|
+
public isBType?: Refinement<string, BType> | null
|
|
89
90
|
public isContent: Refinement<unknown, Content> | null
|
|
90
91
|
public makeContentKey = (a: AType, b: BType): string => `${a}:${b}`
|
|
91
92
|
|
|
@@ -151,8 +152,12 @@ export class Junction<
|
|
|
151
152
|
YType extends XType extends AType ? BType : AType,
|
|
152
153
|
>(x: XType, ys: YType[]): void {
|
|
153
154
|
const xRelationsPrev = this.relations.get(x)
|
|
155
|
+
let a: AType | undefined = this.isAType?.(x) ? x : undefined
|
|
156
|
+
let b: BType | undefined = a === undefined ? (x as BType) : undefined
|
|
154
157
|
if (xRelationsPrev) {
|
|
155
158
|
for (const y of xRelationsPrev) {
|
|
159
|
+
a ??= y as AType
|
|
160
|
+
b ??= y as BType
|
|
156
161
|
const yRelations = this.relations.get(y) as Set<XType> | undefined
|
|
157
162
|
if (yRelations) {
|
|
158
163
|
if (yRelations.size === 1) {
|
|
@@ -160,7 +165,7 @@ export class Junction<
|
|
|
160
165
|
} else {
|
|
161
166
|
yRelations.delete(x)
|
|
162
167
|
}
|
|
163
|
-
this.contents.delete(this.makeContentKey(
|
|
168
|
+
this.contents.delete(this.makeContentKey(a, b))
|
|
164
169
|
}
|
|
165
170
|
}
|
|
166
171
|
}
|
|
@@ -188,7 +193,7 @@ export class Junction<
|
|
|
188
193
|
|
|
189
194
|
public constructor(
|
|
190
195
|
data: JunctionSchema<ASide, BSide> &
|
|
191
|
-
Partial<JunctionEntries<AType
|
|
196
|
+
Partial<JunctionEntries<NoInfer<AType>, NoInfer<BType>, Content>>,
|
|
192
197
|
config?: JunctionAdvancedConfiguration<AType, BType, Content>,
|
|
193
198
|
) {
|
|
194
199
|
this.a = data.between[0]
|
|
@@ -201,6 +206,8 @@ export class Junction<
|
|
|
201
206
|
)
|
|
202
207
|
this.contents = new Map(data.contents)
|
|
203
208
|
}
|
|
209
|
+
this.isAType = config?.isAType ?? null
|
|
210
|
+
this.isBType = config?.isBType ?? null
|
|
204
211
|
this.isContent = config?.isContent ?? null
|
|
205
212
|
if (config?.makeContentKey) {
|
|
206
213
|
this.makeContentKey = config.makeContentKey
|
|
@@ -236,7 +243,13 @@ export class Junction<
|
|
|
236
243
|
}
|
|
237
244
|
}
|
|
238
245
|
for (const [x, ys] of data.relations ?? []) {
|
|
239
|
-
|
|
246
|
+
let a = this.isAType?.(x) ? x : undefined
|
|
247
|
+
let b = a === undefined ? (x as BType) : undefined
|
|
248
|
+
for (const y of ys) {
|
|
249
|
+
a ??= y as AType
|
|
250
|
+
b ??= y as BType
|
|
251
|
+
this.addRelation(a, b)
|
|
252
|
+
}
|
|
240
253
|
}
|
|
241
254
|
for (const [contentKey, content] of data.contents ?? []) {
|
|
242
255
|
this.setContent(contentKey, content)
|
|
@@ -359,9 +372,12 @@ export class Junction<
|
|
|
359
372
|
.join(`, `)}). Only one related key was expected.`,
|
|
360
373
|
)
|
|
361
374
|
}
|
|
375
|
+
let singleRelation: AType | BType | undefined
|
|
362
376
|
for (const relation of relations) {
|
|
363
|
-
|
|
377
|
+
singleRelation = relation
|
|
378
|
+
break
|
|
364
379
|
}
|
|
380
|
+
return singleRelation
|
|
365
381
|
}
|
|
366
382
|
}
|
|
367
383
|
|
|
@@ -416,7 +432,7 @@ export class Junction<
|
|
|
416
432
|
const aRelations = this.getRelatedKeys(a)
|
|
417
433
|
if (aRelations) {
|
|
418
434
|
return [...aRelations].map((aRelation) => {
|
|
419
|
-
return [aRelation, this.getContent(a, aRelation)
|
|
435
|
+
return [aRelation, this.getContent(a, aRelation) as Content]
|
|
420
436
|
})
|
|
421
437
|
}
|
|
422
438
|
}
|
|
@@ -424,7 +440,7 @@ export class Junction<
|
|
|
424
440
|
const bRelations = this.getRelatedKeys(b)
|
|
425
441
|
if (bRelations) {
|
|
426
442
|
return [...bRelations].map((bRelation) => {
|
|
427
|
-
return [bRelation, this.getContent(bRelation, b)
|
|
443
|
+
return [bRelation, this.getContent(bRelation, b) as Content]
|
|
428
444
|
})
|
|
429
445
|
}
|
|
430
446
|
}
|
package/json/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createWritableSelectorFamily } from '../../dist/chunk-
|
|
1
|
+
import { createWritableSelectorFamily } from '../../dist/chunk-LSCRHXLI.js';
|
|
2
2
|
import '../../dist/chunk-ADMEAXYU.js';
|
|
3
3
|
import '../../dist/chunk-XWL6SNVU.js';
|
|
4
4
|
import { createStandaloneSelector, IMPLICIT, growMoleculeInStore, initFamilyMemberInStore, withdraw, seekInStore } from 'atom.io/internal';
|
package/package.json
CHANGED
|
@@ -122,8 +122,8 @@ type SocketSystemHierarchy = Hierarchy<[
|
|
|
122
122
|
}
|
|
123
123
|
]>;
|
|
124
124
|
declare const socketAtoms: AtomIO.RegularAtomFamilyToken<Socket | null, `socket::${string}`>;
|
|
125
|
-
declare const socketIndex: AtomIO.MutableAtomToken<SetRTX
|
|
126
|
-
declare const userIndex: AtomIO.MutableAtomToken<SetRTX
|
|
125
|
+
declare const socketIndex: AtomIO.MutableAtomToken<SetRTX<`socket::${string}`>, SetRTXJson<`socket::${string}`>>;
|
|
126
|
+
declare const userIndex: AtomIO.MutableAtomToken<SetRTX<`user::${string}`>, SetRTXJson<`user::${string}`>>;
|
|
127
127
|
declare const usersOfSockets: atom_io_data.JoinToken<"user", `user::${string}`, "socket", `socket::${string}`, "1:1", null>;
|
|
128
128
|
|
|
129
129
|
type StateProvider = ReturnType<typeof realtimeStateProvider>;
|
|
@@ -24,17 +24,17 @@ export const socketAtoms = atomFamily<Socket | null, SocketKey>({
|
|
|
24
24
|
default: null,
|
|
25
25
|
})
|
|
26
26
|
|
|
27
|
-
export const socketIndex = atom<SetRTX<
|
|
27
|
+
export const socketIndex = atom<SetRTX<SocketKey>, SetRTXJson<SocketKey>>({
|
|
28
28
|
key: `socketsIndex`,
|
|
29
29
|
mutable: true,
|
|
30
|
-
default: () => new SetRTX
|
|
30
|
+
default: () => new SetRTX(),
|
|
31
31
|
toJson: (set) => set.toJSON(),
|
|
32
32
|
fromJson: (json) => SetRTX.fromJSON(json),
|
|
33
33
|
})
|
|
34
|
-
export const userIndex = atom<SetRTX<
|
|
34
|
+
export const userIndex = atom<SetRTX<UserKey>, SetRTXJson<UserKey>>({
|
|
35
35
|
key: `usersIndex`,
|
|
36
36
|
mutable: true,
|
|
37
|
-
default: () => new SetRTX
|
|
37
|
+
default: () => new SetRTX(),
|
|
38
38
|
toJson: (set) => set.toJSON(),
|
|
39
39
|
fromJson: (json) => SetRTX.fromJSON(json),
|
|
40
40
|
})
|
|
@@ -58,8 +58,12 @@ var setupRealtimeTestServer = (options) => {
|
|
|
58
58
|
},
|
|
59
59
|
silo.store
|
|
60
60
|
);
|
|
61
|
-
setIntoStore(silo.store, RTS.userIndex, (index) => index.add(
|
|
62
|
-
setIntoStore(
|
|
61
|
+
setIntoStore(silo.store, RTS.userIndex, (index) => index.add(userClaim));
|
|
62
|
+
setIntoStore(
|
|
63
|
+
silo.store,
|
|
64
|
+
RTS.socketIndex,
|
|
65
|
+
(index) => index.add(socketClaim)
|
|
66
|
+
);
|
|
63
67
|
console.log(`${username} connected on ${socket.id}`);
|
|
64
68
|
next();
|
|
65
69
|
} else {
|
|
@@ -127,8 +127,10 @@ export const setupRealtimeTestServer = (
|
|
|
127
127
|
},
|
|
128
128
|
silo.store,
|
|
129
129
|
)
|
|
130
|
-
setIntoStore(silo.store, RTS.userIndex, (index) => index.add(
|
|
131
|
-
setIntoStore(silo.store, RTS.socketIndex, (index) =>
|
|
130
|
+
setIntoStore(silo.store, RTS.userIndex, (index) => index.add(userClaim))
|
|
131
|
+
setIntoStore(silo.store, RTS.socketIndex, (index) =>
|
|
132
|
+
index.add(socketClaim),
|
|
133
|
+
)
|
|
132
134
|
console.log(`${username} connected on ${socket.id}`)
|
|
133
135
|
next()
|
|
134
136
|
} else {
|