atom.io 0.18.2 → 0.19.0

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 (78) hide show
  1. package/data/dist/index.cjs +173 -3
  2. package/data/dist/index.d.ts +52 -21
  3. package/data/dist/index.js +13 -334
  4. package/data/src/join.ts +309 -41
  5. package/dist/chunk-7ZR244C2.js +489 -0
  6. package/dist/{chunk-A4ZCNKWQ.js → chunk-BWWVY5O5.js} +0 -2
  7. package/dist/{chunk-NYCVSXQB.js → chunk-CVBEVTM5.js} +0 -2
  8. package/dist/{chunk-3J2EGSBE.js → chunk-O47EQUM6.js} +1 -3
  9. package/dist/{chunk-PZLG2HP3.js → chunk-U2IICNHQ.js} +0 -2
  10. package/dist/{chunk-XACXFU3B.js → chunk-VAE5OCKN.js} +0 -2
  11. package/dist/{chunk-NYTGCPHB.js → chunk-WX2NCOZR.js} +0 -2
  12. package/dist/{chunk-IZHOMSXA.js → chunk-YDOGCZ53.js} +0 -2
  13. package/dist/index.cjs +0 -2
  14. package/dist/index.js +1 -3
  15. package/internal/dist/index.cjs +0 -2
  16. package/internal/dist/index.js +2 -4
  17. package/introspection/dist/index.cjs +0 -2
  18. package/introspection/dist/index.js +1 -3
  19. package/json/dist/index.cjs +0 -2
  20. package/json/dist/index.js +3 -5
  21. package/package.json +3 -3
  22. package/react/dist/index.cjs +0 -2
  23. package/react/dist/index.js +1 -3
  24. package/react-devtools/dist/index.cjs +0 -2
  25. package/react-devtools/dist/index.css +0 -1
  26. package/react-devtools/dist/index.js +4 -6
  27. package/realtime/dist/index.cjs +4 -4
  28. package/realtime/dist/index.d.ts +1 -96
  29. package/realtime/dist/index.js +6 -6
  30. package/realtime/src/shared-room-store.ts +5 -3
  31. package/realtime-client/dist/index.cjs +0 -2
  32. package/realtime-client/dist/index.js +4 -6
  33. package/realtime-react/dist/index.cjs +0 -2
  34. package/realtime-react/dist/index.js +2 -4
  35. package/realtime-server/dist/index.cjs +162 -20
  36. package/realtime-server/dist/index.d.ts +1 -91
  37. package/realtime-server/dist/index.js +32 -20
  38. package/realtime-server/src/realtime-continuity-synchronizer.ts +8 -6
  39. package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +22 -10
  40. package/realtime-testing/dist/index.cjs +48 -8
  41. package/realtime-testing/dist/index.js +13 -8
  42. package/realtime-testing/src/setup-realtime-test.tsx +8 -2
  43. package/transceivers/set-rtx/dist/index.cjs +0 -2
  44. package/transceivers/set-rtx/dist/index.js +1 -3
  45. package/data/dist/index.cjs.map +0 -1
  46. package/data/dist/index.js.map +0 -1
  47. package/dist/chunk-3J2EGSBE.js.map +0 -1
  48. package/dist/chunk-A4ZCNKWQ.js.map +0 -1
  49. package/dist/chunk-IZHOMSXA.js.map +0 -1
  50. package/dist/chunk-NYCVSXQB.js.map +0 -1
  51. package/dist/chunk-NYTGCPHB.js.map +0 -1
  52. package/dist/chunk-PZLG2HP3.js.map +0 -1
  53. package/dist/chunk-XACXFU3B.js.map +0 -1
  54. package/dist/index.cjs.map +0 -1
  55. package/dist/index.js.map +0 -1
  56. package/internal/dist/index.cjs.map +0 -1
  57. package/internal/dist/index.js.map +0 -1
  58. package/introspection/dist/index.cjs.map +0 -1
  59. package/introspection/dist/index.js.map +0 -1
  60. package/json/dist/index.cjs.map +0 -1
  61. package/json/dist/index.js.map +0 -1
  62. package/react/dist/index.cjs.map +0 -1
  63. package/react/dist/index.js.map +0 -1
  64. package/react-devtools/dist/index.cjs.map +0 -1
  65. package/react-devtools/dist/index.css.map +0 -1
  66. package/react-devtools/dist/index.js.map +0 -1
  67. package/realtime/dist/index.cjs.map +0 -1
  68. package/realtime/dist/index.js.map +0 -1
  69. package/realtime-client/dist/index.cjs.map +0 -1
  70. package/realtime-client/dist/index.js.map +0 -1
  71. package/realtime-react/dist/index.cjs.map +0 -1
  72. package/realtime-react/dist/index.js.map +0 -1
  73. package/realtime-server/dist/index.cjs.map +0 -1
  74. package/realtime-server/dist/index.js.map +0 -1
  75. package/realtime-testing/dist/index.cjs.map +0 -1
  76. package/realtime-testing/dist/index.js.map +0 -1
  77. package/transceivers/set-rtx/dist/index.cjs.map +0 -1
  78. package/transceivers/set-rtx/dist/index.js.map +0 -1
@@ -2852,5 +2852,3 @@ exports.primitiveRefinery = primitiveRefinery;
2852
2852
  exports.selectorIndex = selectorIndex;
2853
2853
  exports.timelineIndex = timelineIndex;
2854
2854
  exports.transactionIndex = transactionIndex;
2855
- //# sourceMappingURL=out.js.map
2856
- //# sourceMappingURL=index.cjs.map
@@ -326,4 +326,3 @@ main.atom_io_devtools {
326
326
  }
327
327
  }
328
328
  }
329
- /*# sourceMappingURL=index.css.map */
@@ -1,7 +1,7 @@
1
- import { treeShake, isEmptyArray, pipe, ifDefined, isArray, isRecord, doesExtend, isModifier, isPlainObject, raiseError, sprawl, recordToEntries, fallback, hasExactProperties, isEmptyObject, doNothing, isOneOf, map, entriesToRecord, comprises, addTo, become, mapObject, delve } from '../../dist/chunk-NYCVSXQB.js';
2
- import { lazyLocalStorageEffect } from '../../dist/chunk-A4ZCNKWQ.js';
3
- import { JSON_TYPE_NAMES, isString, isNumber, isBoolean, stringifyJson, JSON_DEFAULTS } from '../../dist/chunk-XACXFU3B.js';
4
- import { __spreadProps, __spreadValues, __objRest, __restKey } from '../../dist/chunk-PZLG2HP3.js';
1
+ import { treeShake, isEmptyArray, pipe, ifDefined, isArray, isRecord, doesExtend, isModifier, isPlainObject, raiseError, sprawl, recordToEntries, fallback, hasExactProperties, isEmptyObject, doNothing, isOneOf, map, entriesToRecord, comprises, addTo, become, mapObject, delve } from '../../dist/chunk-CVBEVTM5.js';
2
+ import { lazyLocalStorageEffect } from '../../dist/chunk-BWWVY5O5.js';
3
+ import { JSON_TYPE_NAMES, isString, isNumber, isBoolean, stringifyJson, JSON_DEFAULTS } from '../../dist/chunk-VAE5OCKN.js';
4
+ import { __spreadProps, __spreadValues, __objRest, __restKey } from '../../dist/chunk-U2IICNHQ.js';
5
5
  import { selectorFamily, atom, atomFamily, findState, undo, redo, getState } from 'atom.io';
6
6
  import { attachIntrospectionStates } from 'atom.io/introspection';
7
7
  import { useI, useO } from 'atom.io/react';
@@ -2566,5 +2566,3 @@ var prettyJson = new Differ(primitiveRefinery, jsonTreeRefinery, {
2566
2566
  });
2567
2567
 
2568
2568
  export { AtomIODevtools, atomIndex, devtoolsAreOpenState, devtoolsViewOptionsState, devtoolsViewSelectionState, findTimelineState, findTransactionLogState, findViewIsOpenState, jsonTreeRefinery, prettyJson, primitiveRefinery, selectorIndex, timelineIndex, transactionIndex };
2569
- //# sourceMappingURL=out.js.map
2570
- //# sourceMappingURL=index.js.map
@@ -103,8 +103,10 @@ var usersInRooms = data.join(
103
103
  );
104
104
  var usersInMyRoomView = atom_io.selectorFamily({
105
105
  key: `usersInMyRoomView`,
106
- get: (username) => ({ find }) => {
107
- return [find(usersInRooms.core.findRelatedKeysState, username)];
106
+ get: (myUsername) => ({ find }) => {
107
+ const usersInRoomsAtoms = data.getInternalRelations(usersInRooms);
108
+ const myRoomIndex = find(usersInRoomsAtoms, myUsername);
109
+ return [myRoomIndex];
108
110
  }
109
111
  });
110
112
 
@@ -116,5 +118,3 @@ exports.roomIndex = roomIndex;
116
118
  exports.usersInMyRoomView = usersInMyRoomView;
117
119
  exports.usersInRooms = usersInRooms;
118
120
  exports.usersInThisRoomIndex = usersInThisRoomIndex;
119
- //# sourceMappingURL=out.js.map
120
- //# sourceMappingURL=index.cjs.map
@@ -2,7 +2,6 @@ import * as atom_io from 'atom.io';
2
2
  import { AtomFamilyToken, ReadableFamilyToken, ReadableToken, AtomToken, TransactionToken, MutableAtomToken } from 'atom.io';
3
3
  import { Json } from 'atom.io/json';
4
4
  import * as atom_io_data from 'atom.io/data';
5
- import * as atom_io_internal from 'atom.io/internal';
6
5
  import { SetRTX, SetRTXJson } from 'atom.io/transceivers/set-rtx';
7
6
 
8
7
  declare class InvariantMap<K, V> extends Map<K, V> {
@@ -40,107 +39,13 @@ type ContinuityOptions = {
40
39
  };
41
40
  declare function continuity(options: ContinuityOptions): ContinuityToken;
42
41
 
43
- type primitive = boolean | number | string | null;
44
-
45
- type Serializable = primitive | Readonly<{
46
- [key: string]: Serializable;
47
- }> | ReadonlyArray<Serializable>;
48
- type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
49
-
50
- type Refinement<Unrefined, Refined extends Unrefined> = (value: Unrefined) => value is Refined;
51
- type Cardinality = `1:1` | `1:n` | `n:n`;
52
-
53
- interface JunctionEntries<Content extends Object$1 | null> extends Object$1 {
54
- readonly relations: [string, string[]][];
55
- readonly contents: [string, Content][];
56
- }
57
- interface JunctionSchema<ASide extends string, BSide extends string> extends Object$1 {
58
- readonly between: [a: ASide, b: BSide];
59
- readonly cardinality: Cardinality;
60
- }
61
- type BaseExternalStoreConfiguration = {
62
- addRelation: (a: string, b: string) => void;
63
- deleteRelation: (a: string, b: string) => void;
64
- replaceRelationsSafely: (a: string, bs: string[]) => void;
65
- replaceRelationsUnsafely: (a: string, bs: string[]) => void;
66
- getRelatedKeys: (key: string) => Set<string> | undefined;
67
- has: (a: string, b?: string) => boolean;
68
- };
69
- type ExternalStoreWithContentConfiguration<Content extends Object$1> = {
70
- getContent: (contentKey: string) => Content | undefined;
71
- setContent: (contentKey: string, content: Content) => void;
72
- deleteContent: (contentKey: string) => void;
73
- };
74
- type Empty<Obj extends object> = {
75
- [Key in keyof Obj]?: undefined;
76
- };
77
- type ExternalStoreConfiguration<Content extends Object$1 | null> = Content extends Object$1 ? BaseExternalStoreConfiguration & ExternalStoreWithContentConfiguration<Content> : BaseExternalStoreConfiguration & Empty<ExternalStoreWithContentConfiguration<Object$1>>;
78
- type JunctionAdvancedConfiguration<Content extends Object$1 | null> = {
79
- externalStore?: ExternalStoreConfiguration<Content>;
80
- isContent?: Refinement<unknown, Content>;
81
- makeContentKey?: (a: string, b: string) => string;
82
- };
83
- type JunctionJSON<ASide extends string, BSide extends string, Content extends Object$1 | null> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>;
84
- declare class Junction<const ASide extends string, const BSide extends string, const Content extends Object$1 | null = null> {
85
- readonly a: ASide;
86
- readonly b: BSide;
87
- readonly cardinality: Cardinality;
88
- readonly relations: Map<string, Set<string>>;
89
- readonly contents: Map<string, Content>;
90
- isContent: Refinement<unknown, Content> | null;
91
- makeContentKey: (a: string, b: string) => string;
92
- getRelatedKeys(key: string): Set<string> | undefined;
93
- protected addRelation(a: string, b: string): void;
94
- protected deleteRelation(a: string, b: string): void;
95
- protected replaceRelationsUnsafely(a: string, bs: string[]): void;
96
- protected replaceRelationsSafely(a: string, bs: string[]): void;
97
- protected getContentInternal(contentKey: string): Content | undefined;
98
- protected setContent(contentKey: string, content: Content): void;
99
- protected deleteContent(contentKey: string): void;
100
- constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<Content>>, config?: JunctionAdvancedConfiguration<Content>);
101
- toJSON(): JunctionJSON<ASide, BSide, Content>;
102
- set(a: string, ...rest: Content extends null ? [b: string] : [b: string, content: Content]): this;
103
- set(relation: {
104
- [Key in ASide | BSide]: string;
105
- }, ...rest: Content extends null ? [] | [b?: undefined] : [content: Content]): this;
106
- delete(a: string, b?: string): this;
107
- delete(relation: Record<ASide | BSide, string> | Record<ASide, string> | Record<BSide, string>, b?: undefined): this;
108
- getRelatedKey(key: string): string | undefined;
109
- replaceRelations(a: string, relations: Content extends null ? string[] : Record<string, Content>, config?: {
110
- reckless: boolean;
111
- }): this;
112
- getContent(a: string, b: string): Content | undefined;
113
- getRelationEntries(input: Record<ASide, string> | Record<BSide, string>): [string, Content][];
114
- has(a: string, b?: string): boolean;
115
- }
116
-
117
42
  declare const usersInThisRoomIndex: MutableAtomToken<SetRTX<string>, SetRTXJson<string>>;
118
43
  declare const roomIndex: MutableAtomToken<SetRTX<string>, SetRTXJson<string>>;
119
44
  type UserInRoomMeta = {
120
45
  enteredAtEpoch: number;
121
46
  };
122
47
  declare const DEFAULT_USER_IN_ROOM_META: UserInRoomMeta;
123
- declare const usersInRooms: {
124
- readonly relations: Junction<"room", "user", UserInRoomMeta>;
125
- readonly states: {
126
- readonly roomEntryOfUser: atom_io.ReadonlySelectorFamily<[string, UserInRoomMeta] | null, string>;
127
- } & {
128
- readonly userEntriesOfRoom: atom_io.ReadonlySelectorFamily<[string, UserInRoomMeta][], string>;
129
- } & {
130
- readonly roomKeyOfUser: atom_io.ReadonlySelectorFamily<string | null, string>;
131
- } & {
132
- readonly userKeysOfRoom: atom_io.ReadonlySelectorFamily<string[], string>;
133
- };
134
- readonly in: (store: atom_io_internal.Store) => atom_io_data.Join<"room", "user", "1:n", UserInRoomMeta>;
135
- readonly transact: (transactors: Readonly<{
136
- get: <S>(state: atom_io.ReadonlySelectorToken<S> | atom_io.WritableToken<S>) => S;
137
- set: <S_1, New extends S_1>(state: atom_io.WritableToken<S_1>, newValue: New | ((oldValue: S_1) => New)) => void;
138
- find: typeof atom_io.findState;
139
- }>, run: (join: atom_io_data.Join<"room", "user", "1:n", UserInRoomMeta>) => void) => void;
140
- readonly core: {
141
- readonly findRelatedKeysState: atom_io.MutableAtomFamily<SetRTX<string>, SetRTXJson<string>, string>;
142
- };
143
- };
48
+ declare const usersInRooms: atom_io_data.JoinToken<"room", "user", "1:n", UserInRoomMeta>;
144
49
  declare const usersInMyRoomView: atom_io.ReadonlySelectorFamilyTokenWithCall<MutableAtomToken<SetRTX<string>, SetRTXJson<string>>[], string>;
145
50
 
146
51
  export { type ContinuityOptions, type ContinuityToken, DEFAULT_USER_IN_ROOM_META, InvariantMap, type PerspectiveToken, SyncGroup, type UserInRoomMeta, continuity, roomIndex, usersInMyRoomView, usersInRooms, usersInThisRoomIndex };
@@ -1,7 +1,7 @@
1
- import '../../dist/chunk-PZLG2HP3.js';
1
+ import '../../dist/chunk-U2IICNHQ.js';
2
2
  import { assignTransactionToContinuity, IMPLICIT, setEpochNumberOfContinuity, getUpdateToken } from 'atom.io/internal';
3
3
  import { atom, selectorFamily } from 'atom.io';
4
- import { join } from 'atom.io/data';
4
+ import { join, getInternalRelations } from 'atom.io/data';
5
5
  import { SetRTX } from 'atom.io/transceivers/set-rtx';
6
6
 
7
7
  var InvariantMap = class extends Map {
@@ -101,11 +101,11 @@ var usersInRooms = join(
101
101
  );
102
102
  var usersInMyRoomView = selectorFamily({
103
103
  key: `usersInMyRoomView`,
104
- get: (username) => ({ find }) => {
105
- return [find(usersInRooms.core.findRelatedKeysState, username)];
104
+ get: (myUsername) => ({ find }) => {
105
+ const usersInRoomsAtoms = getInternalRelations(usersInRooms);
106
+ const myRoomIndex = find(usersInRoomsAtoms, myUsername);
107
+ return [myRoomIndex];
106
108
  }
107
109
  });
108
110
 
109
111
  export { DEFAULT_USER_IN_ROOM_META, InvariantMap, SyncGroup, continuity, roomIndex, usersInMyRoomView, usersInRooms, usersInThisRoomIndex };
110
- //# sourceMappingURL=out.js.map
111
- //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  import type { MutableAtomToken } from "atom.io"
2
2
  import { atom, selectorFamily } from "atom.io"
3
- import { join } from "atom.io/data"
3
+ import { getInternalRelations, join } from "atom.io/data"
4
4
  import type { SetRTXJson } from "atom.io/transceivers/set-rtx"
5
5
  import { SetRTX } from "atom.io/transceivers/set-rtx"
6
6
 
@@ -41,8 +41,10 @@ export const usersInMyRoomView = selectorFamily<
41
41
  >({
42
42
  key: `usersInMyRoomView`,
43
43
  get:
44
- (username) =>
44
+ (myUsername) =>
45
45
  ({ find }) => {
46
- return [find(usersInRooms.core.findRelatedKeysState, username)]
46
+ const usersInRoomsAtoms = getInternalRelations(usersInRooms)
47
+ const myRoomIndex = find(usersInRoomsAtoms, myUsername)
48
+ return [myRoomIndex]
47
49
  },
48
50
  })
@@ -569,5 +569,3 @@ exports.pullSelectorFamilyMember = pullSelectorFamilyMember;
569
569
  exports.pushState = pushState;
570
570
  exports.serverAction = serverAction;
571
571
  exports.syncContinuity = syncContinuity;
572
- //# sourceMappingURL=out.js.map
573
- //# sourceMappingURL=index.cjs.map
@@ -1,7 +1,7 @@
1
- export { syncContinuity } from '../../dist/chunk-IZHOMSXA.js';
2
- export { confirmedUpdateQueue, myIdState, myIdState__INTERNAL, myUsernameState, optimisticUpdateQueue } from '../../dist/chunk-3J2EGSBE.js';
3
- import '../../dist/chunk-A4ZCNKWQ.js';
4
- import '../../dist/chunk-PZLG2HP3.js';
1
+ export { syncContinuity } from '../../dist/chunk-YDOGCZ53.js';
2
+ export { confirmedUpdateQueue, myIdState, myIdState__INTERNAL, myUsernameState, optimisticUpdateQueue } from '../../dist/chunk-O47EQUM6.js';
3
+ import '../../dist/chunk-BWWVY5O5.js';
4
+ import '../../dist/chunk-U2IICNHQ.js';
5
5
  import * as Internal from 'atom.io/internal';
6
6
  import { setIntoStore, getJsonToken, getUpdateToken } from 'atom.io/internal';
7
7
  import { parseJson } from 'atom.io/json';
@@ -171,5 +171,3 @@ function serverAction(token, socket, store) {
171
171
  }
172
172
 
173
173
  export { pullAtom, pullAtomFamilyMember, pullMutableAtom, pullMutableAtomFamilyMember, pullSelector, pullSelectorFamilyMember, pushState, serverAction };
174
- //# sourceMappingURL=out.js.map
175
- //# sourceMappingURL=index.js.map
@@ -512,5 +512,3 @@ exports.usePullSelectorFamilyMember = usePullSelectorFamilyMember;
512
512
  exports.usePush = usePush;
513
513
  exports.useServerAction = useServerAction;
514
514
  exports.useSyncContinuity = useSyncContinuity;
515
- //# sourceMappingURL=out.js.map
516
- //# sourceMappingURL=index.cjs.map
@@ -1,5 +1,5 @@
1
- import { syncContinuity } from '../../dist/chunk-IZHOMSXA.js';
2
- import '../../dist/chunk-PZLG2HP3.js';
1
+ import { syncContinuity } from '../../dist/chunk-YDOGCZ53.js';
2
+ import '../../dist/chunk-U2IICNHQ.js';
3
3
  import { useI, StoreContext, useO } from 'atom.io/react';
4
4
  import * as RTC from 'atom.io/realtime-client';
5
5
  import * as React from 'react';
@@ -155,5 +155,3 @@ function useSyncContinuity(token) {
155
155
  }
156
156
 
157
157
  export { RealtimeContext, RealtimeProvider, usePullAtom, usePullAtomFamilyMember, usePullMutable, usePullMutableAtomFamilyMember, usePullSelector, usePullSelectorFamilyMember, usePush, useServerAction, useSyncContinuity };
158
- //# sourceMappingURL=out.js.map
159
- //# sourceMappingURL=index.js.map
@@ -5,8 +5,8 @@ var internal = require('atom.io/internal');
5
5
  var setRtx = require('atom.io/transceivers/set-rtx');
6
6
  var AtomIO = require('atom.io');
7
7
  var realtime = require('atom.io/realtime');
8
- var child_process = require('child_process');
9
8
  var data = require('atom.io/data');
9
+ var child_process = require('child_process');
10
10
 
11
11
  function _interopNamespace(e) {
12
12
  if (e && e.__esModule) return e;
@@ -216,8 +216,8 @@ var SubjectSocket = class extends CustomSocket {
216
216
  });
217
217
  }
218
218
  dispose() {
219
- for (const dispose of this.disposalFunctions) {
220
- dispose();
219
+ for (const dispose2 of this.disposalFunctions) {
220
+ dispose2();
221
221
  }
222
222
  }
223
223
  };
@@ -338,6 +338,138 @@ var ParentSocket = class extends CustomSocket {
338
338
  this.relayServices.push(attachServices);
339
339
  }
340
340
  };
341
+ function capitalize(string) {
342
+ return string[0].toUpperCase() + string.slice(1);
343
+ }
344
+ function getJoinMap(store) {
345
+ if (`joins` in store && store.joins instanceof Map) {
346
+ return store.joins;
347
+ }
348
+ const joins = /* @__PURE__ */ new Map();
349
+ store.joins = joins;
350
+ return joins;
351
+ }
352
+ function getJoin(token, store) {
353
+ var _a;
354
+ const joinMap = getJoinMap(store);
355
+ let join2 = joinMap.get(token.key);
356
+ if (join2 === void 0) {
357
+ const rootJoinMap = getJoinMap(internal.IMPLICIT.STORE);
358
+ join2 = (_a = rootJoinMap.get(token.key)) == null ? void 0 : _a.in(store);
359
+ if (join2 === void 0) {
360
+ throw new Error(
361
+ `Join "${token.key}" not found in store "${store.config.name}"`
362
+ );
363
+ }
364
+ joinMap.set(token.key, join2);
365
+ }
366
+ return join2;
367
+ }
368
+ function findRelationsInStore(token, key, store) {
369
+ const join2 = getJoin(token, store);
370
+ let relations;
371
+ switch (token.cardinality) {
372
+ case `1:1`: {
373
+ const keyAB = `${token.a}KeyOf${capitalize(token.b)}`;
374
+ const keyBA = `${token.b}KeyOf${capitalize(token.a)}`;
375
+ relations = {
376
+ get [keyAB]() {
377
+ const familyAB = join2.states[keyAB];
378
+ const state = internal.findInStore(familyAB, key, store);
379
+ return state;
380
+ },
381
+ get [keyBA]() {
382
+ const familyBA = join2.states[keyBA];
383
+ const state = internal.findInStore(familyBA, key, store);
384
+ return state;
385
+ }
386
+ };
387
+ const entryAB = `${token.a}EntryOf${capitalize(token.b)}`;
388
+ if (entryAB in join2.states) {
389
+ const entryBA = `${token.b}EntryOf${capitalize(token.a)}`;
390
+ Object.assign(relations, {
391
+ get [entryAB]() {
392
+ const familyAB = join2.states[entryAB];
393
+ const state = internal.findInStore(familyAB, key, store);
394
+ return state;
395
+ },
396
+ get [entryBA]() {
397
+ const familyBA = join2.states[entryBA];
398
+ const state = internal.findInStore(familyBA, key, store);
399
+ return state;
400
+ }
401
+ });
402
+ }
403
+ break;
404
+ }
405
+ case `1:n`: {
406
+ const keyAB = `${token.a}KeyOf${capitalize(token.b)}`;
407
+ const keysBA = `${token.b}KeysOf${capitalize(token.a)}`;
408
+ relations = {
409
+ get [keyAB]() {
410
+ const familyAB = join2.states[keyAB];
411
+ const state = internal.findInStore(familyAB, key, store);
412
+ return state;
413
+ },
414
+ get [keysBA]() {
415
+ const familyBA = join2.states[keysBA];
416
+ const state = internal.findInStore(familyBA, key, store);
417
+ return state;
418
+ }
419
+ };
420
+ const entryAB = `${token.a}EntryOf${capitalize(token.b)}`;
421
+ if (entryAB in join2.states) {
422
+ const entriesBA = `${token.b}EntriesOf${capitalize(token.a)}`;
423
+ Object.assign(relations, {
424
+ get [entryAB]() {
425
+ const familyAB = join2.states[entryAB];
426
+ const state = internal.findInStore(familyAB, key, store);
427
+ return state;
428
+ },
429
+ get [entriesBA]() {
430
+ const familyBA = join2.states[entriesBA];
431
+ const state = internal.findInStore(familyBA, key, store);
432
+ return state;
433
+ }
434
+ });
435
+ }
436
+ break;
437
+ }
438
+ case `n:n`: {
439
+ const keysAB = `${token.a}KeysOf${capitalize(token.b)}`;
440
+ const keysBA = `${token.b}KeysOf${capitalize(token.a)}`;
441
+ relations = {
442
+ get [keysAB]() {
443
+ const familyAB = join2.states[keysAB];
444
+ const state = internal.findInStore(familyAB, key, store);
445
+ return state;
446
+ },
447
+ get [keysBA]() {
448
+ const familyBA = join2.states[keysBA];
449
+ const state = internal.findInStore(familyBA, key, store);
450
+ return state;
451
+ }
452
+ };
453
+ const entriesAB = `${token.a}EntriesOf${capitalize(token.b)}`;
454
+ if (entriesAB in join2.states) {
455
+ const entriesBA = `${token.b}EntriesOf${capitalize(token.a)}`;
456
+ Object.assign(relations, {
457
+ get [entriesAB]() {
458
+ const familyAB = join2.states[entriesAB];
459
+ const state = internal.findInStore(familyAB, key, store);
460
+ return state;
461
+ },
462
+ get [entriesBA]() {
463
+ const familyBA = join2.states[entriesBA];
464
+ const state = internal.findInStore(familyBA, key, store);
465
+ return state;
466
+ }
467
+ });
468
+ }
469
+ }
470
+ }
471
+ return relations;
472
+ }
341
473
  AtomIO.selectorFamily({
342
474
  key: `perspectiveRedactor`,
343
475
  get: ({ userId, syncGroupKey }) => ({ get, find }) => {
@@ -442,26 +574,38 @@ var joinRoomTX = AtomIO__namespace.transaction({
442
574
  key: `joinRoom`,
443
575
  do: (transactors, roomId, userId, enteredAtEpoch) => {
444
576
  const meta = { enteredAtEpoch };
445
- realtime.usersInRooms.transact(transactors, ({ relations }) => {
446
- relations.set(roomId, userId, meta);
447
- });
577
+ data.editRelationsInStore(
578
+ realtime.usersInRooms,
579
+ (relations) => {
580
+ relations.set({ room: roomId, user: userId }, meta);
581
+ },
582
+ transactors.env().store
583
+ );
448
584
  return meta;
449
585
  }
450
586
  });
451
587
  var leaveRoomTX = AtomIO__namespace.transaction({
452
588
  key: `leaveRoom`,
453
589
  do: (transactors, roomId, userId) => {
454
- realtime.usersInRooms.transact(transactors, ({ relations }) => {
455
- relations.delete({ room: roomId, user: userId });
456
- });
590
+ data.editRelationsInStore(
591
+ realtime.usersInRooms,
592
+ (relations) => {
593
+ relations.delete({ room: roomId, user: userId });
594
+ },
595
+ transactors.env().store
596
+ );
457
597
  }
458
598
  });
459
599
  var destroyRoomTX = AtomIO__namespace.transaction({
460
600
  key: `destroyRoom`,
461
601
  do: (transactors, roomId) => {
462
- realtime.usersInRooms.transact(transactors, ({ relations }) => {
463
- relations.delete({ room: roomId });
464
- });
602
+ data.editRelationsInStore(
603
+ realtime.usersInRooms,
604
+ (relations) => {
605
+ relations.delete({ room: roomId });
606
+ },
607
+ transactors.env().store
608
+ );
465
609
  transactors.set(realtime.roomIndex, (s) => (s.delete(roomId), s));
466
610
  }
467
611
  });
@@ -522,11 +666,11 @@ function realtimeContinuitySynchronizer({
522
666
  return function synchronizer(continuity) {
523
667
  let socket = initialSocket;
524
668
  const continuityKey = continuity.key;
525
- const userKeyState = internal.findInStore(
526
- usersOfSockets.states.userKeyOfSocket,
669
+ const userKeyState = findRelationsInStore(
670
+ usersOfSockets,
527
671
  socket.id,
528
672
  store
529
- );
673
+ ).userKeyOfSocket;
530
674
  const userKey = internal.getFromStore(userKeyState, store);
531
675
  if (!userKey) {
532
676
  store.logger.error(
@@ -538,11 +682,11 @@ function realtimeContinuitySynchronizer({
538
682
  return () => {
539
683
  };
540
684
  }
541
- const socketKeyState = internal.findInStore(
542
- usersOfSockets.states.socketKeyOfUser,
685
+ const socketKeyState = findRelationsInStore(
686
+ usersOfSockets,
543
687
  userKey,
544
688
  store
545
- );
689
+ ).socketKeyOfUser;
546
690
  internal.subscribeToState(
547
691
  socketKeyState,
548
692
  ({ newValue: newSocketKey }) => {
@@ -1008,5 +1152,3 @@ exports.socketIndex = socketIndex;
1008
1152
  exports.userIndex = userIndex;
1009
1153
  exports.userUnacknowledgedQueues = userUnacknowledgedQueues;
1010
1154
  exports.usersOfSockets = usersOfSockets;
1011
- //# sourceMappingURL=out.js.map
1012
- //# sourceMappingURL=index.cjs.map
@@ -1,4 +1,3 @@
1
- import * as atom_io_internal from 'atom.io/internal';
2
1
  import { Subject, Transceiver, Store } from 'atom.io/internal';
3
2
  import { Json, Stringified, JsonIO } from 'atom.io/json';
4
3
  import { ChildProcessWithoutNullStreams } from 'child_process';
@@ -104,99 +103,10 @@ declare const actionOcclusionAtoms: AtomIO.RegularAtomFamilyTokenWithCall<{
104
103
  }, string>;
105
104
  declare const userUnacknowledgedQueues: AtomIO.RegularAtomFamilyTokenWithCall<Pick<TransactionUpdate<any>, "key" | "epoch" | "id" | "updates" | "output">[], string>;
106
105
 
107
- type primitive = boolean | number | string | null;
108
-
109
- type Serializable = primitive | Readonly<{
110
- [key: string]: Serializable;
111
- }> | ReadonlyArray<Serializable>;
112
- type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
113
-
114
- type Refinement<Unrefined, Refined extends Unrefined> = (value: Unrefined) => value is Refined;
115
- type Cardinality = `1:1` | `1:n` | `n:n`;
116
-
117
- interface JunctionEntries<Content extends Object$1 | null> extends Object$1 {
118
- readonly relations: [string, string[]][];
119
- readonly contents: [string, Content][];
120
- }
121
- interface JunctionSchema<ASide extends string, BSide extends string> extends Object$1 {
122
- readonly between: [a: ASide, b: BSide];
123
- readonly cardinality: Cardinality;
124
- }
125
- type BaseExternalStoreConfiguration = {
126
- addRelation: (a: string, b: string) => void;
127
- deleteRelation: (a: string, b: string) => void;
128
- replaceRelationsSafely: (a: string, bs: string[]) => void;
129
- replaceRelationsUnsafely: (a: string, bs: string[]) => void;
130
- getRelatedKeys: (key: string) => Set<string> | undefined;
131
- has: (a: string, b?: string) => boolean;
132
- };
133
- type ExternalStoreWithContentConfiguration<Content extends Object$1> = {
134
- getContent: (contentKey: string) => Content | undefined;
135
- setContent: (contentKey: string, content: Content) => void;
136
- deleteContent: (contentKey: string) => void;
137
- };
138
- type Empty<Obj extends object> = {
139
- [Key in keyof Obj]?: undefined;
140
- };
141
- type ExternalStoreConfiguration<Content extends Object$1 | null> = Content extends Object$1 ? BaseExternalStoreConfiguration & ExternalStoreWithContentConfiguration<Content> : BaseExternalStoreConfiguration & Empty<ExternalStoreWithContentConfiguration<Object$1>>;
142
- type JunctionAdvancedConfiguration<Content extends Object$1 | null> = {
143
- externalStore?: ExternalStoreConfiguration<Content>;
144
- isContent?: Refinement<unknown, Content>;
145
- makeContentKey?: (a: string, b: string) => string;
146
- };
147
- type JunctionJSON<ASide extends string, BSide extends string, Content extends Object$1 | null> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>;
148
- declare class Junction<const ASide extends string, const BSide extends string, const Content extends Object$1 | null = null> {
149
- readonly a: ASide;
150
- readonly b: BSide;
151
- readonly cardinality: Cardinality;
152
- readonly relations: Map<string, Set<string>>;
153
- readonly contents: Map<string, Content>;
154
- isContent: Refinement<unknown, Content> | null;
155
- makeContentKey: (a: string, b: string) => string;
156
- getRelatedKeys(key: string): Set<string> | undefined;
157
- protected addRelation(a: string, b: string): void;
158
- protected deleteRelation(a: string, b: string): void;
159
- protected replaceRelationsUnsafely(a: string, bs: string[]): void;
160
- protected replaceRelationsSafely(a: string, bs: string[]): void;
161
- protected getContentInternal(contentKey: string): Content | undefined;
162
- protected setContent(contentKey: string, content: Content): void;
163
- protected deleteContent(contentKey: string): void;
164
- constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<Content>>, config?: JunctionAdvancedConfiguration<Content>);
165
- toJSON(): JunctionJSON<ASide, BSide, Content>;
166
- set(a: string, ...rest: Content extends null ? [b: string] : [b: string, content: Content]): this;
167
- set(relation: {
168
- [Key in ASide | BSide]: string;
169
- }, ...rest: Content extends null ? [] | [b?: undefined] : [content: Content]): this;
170
- delete(a: string, b?: string): this;
171
- delete(relation: Record<ASide | BSide, string> | Record<ASide, string> | Record<BSide, string>, b?: undefined): this;
172
- getRelatedKey(key: string): string | undefined;
173
- replaceRelations(a: string, relations: Content extends null ? string[] : Record<string, Content>, config?: {
174
- reckless: boolean;
175
- }): this;
176
- getContent(a: string, b: string): Content | undefined;
177
- getRelationEntries(input: Record<ASide, string> | Record<BSide, string>): [string, Content][];
178
- has(a: string, b?: string): boolean;
179
- }
180
-
181
106
  declare const socketAtoms: AtomIO.RegularAtomFamilyTokenWithCall<Socket | null, string>;
182
107
  declare const socketIndex: AtomIO.MutableAtomToken<SetRTX<string>, atom_io_transceivers_set_rtx.SetRTXJson<string>>;
183
108
  declare const userIndex: AtomIO.MutableAtomToken<SetRTX<string>, atom_io_transceivers_set_rtx.SetRTXJson<string>>;
184
- declare const usersOfSockets: {
185
- readonly relations: Junction<"user", "socket", null>;
186
- readonly states: {
187
- readonly socketKeyOfUser: AtomIO.ReadonlySelectorFamily<string | null, string>;
188
- readonly userKeyOfSocket: AtomIO.ReadonlySelectorFamily<string | null, string>;
189
- };
190
- readonly in: (store: atom_io_internal.Store) => atom_io_data.Join<"user", "socket", "1:1", null>;
191
- readonly transact: (transactors: Readonly<{
192
- get: <S>(state: AtomIO.ReadonlySelectorToken<S> | AtomIO.WritableToken<S>) => S;
193
- set: <S_1, New extends S_1>(state: AtomIO.WritableToken<S_1>, newValue: New | ((oldValue: S_1) => New)) => void;
194
- find: typeof AtomIO.findState;
195
- }>, run: (join: atom_io_data.Join<"user", "socket", "1:1", null>) => void) => void;
196
- readonly core: {
197
- readonly findRelatedKeysState: AtomIO.MutableAtomFamily<SetRTX<string>, atom_io_transceivers_set_rtx.SetRTXJson<string>, string>;
198
- };
199
- };
109
+ declare const usersOfSockets: atom_io_data.JoinToken<"user", "socket", "1:1", null>;
200
110
 
201
111
  type StateProvider = ReturnType<typeof realtimeStateProvider>;
202
112
  declare function realtimeStateProvider({ socket, store, }: ServerConfig): <J extends Json.Serializable>(token: AtomIO.WritableToken<J>) => () => void;