atom.io 0.46.4 → 0.46.6
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/dist/realtime/index.d.ts +7 -6
- package/dist/realtime/index.d.ts.map +1 -1
- package/dist/realtime/index.js +19 -10
- package/dist/realtime/index.js.map +1 -1
- package/dist/realtime-client/index.d.ts +13 -13
- package/dist/realtime-client/index.d.ts.map +1 -1
- package/dist/realtime-client/index.js +10 -3
- package/dist/realtime-client/index.js.map +1 -1
- package/dist/realtime-react/index.d.ts +12 -3
- package/dist/realtime-react/index.d.ts.map +1 -1
- package/dist/realtime-react/index.js +26 -3
- package/dist/realtime-react/index.js.map +1 -1
- package/dist/realtime-server/index.d.ts +50 -42
- package/dist/realtime-server/index.d.ts.map +1 -1
- package/dist/realtime-server/index.js +132 -101
- package/dist/realtime-server/index.js.map +1 -1
- package/dist/realtime-testing/index.js +2 -2
- package/dist/realtime-testing/index.js.map +1 -1
- package/package.json +20 -19
- package/src/realtime/realtime-continuity.ts +2 -2
- package/src/realtime/shared-room-store.ts +38 -17
- package/src/realtime/socket-interface.ts +1 -1
- package/src/realtime-client/continuity/register-and-attempt-confirmed-update.ts +3 -1
- package/src/realtime-client/continuity/use-conceal-state.ts +2 -1
- package/src/realtime-client/pull-atom-family-member.ts +1 -1
- package/src/realtime-client/pull-atom.ts +1 -1
- package/src/realtime-client/pull-mutable-atom-family-member.ts +1 -1
- package/src/realtime-client/pull-mutable-atom.ts +1 -1
- package/src/realtime-client/pull-selector-family-member.ts +1 -1
- package/src/realtime-client/pull-selector-roots.ts +1 -1
- package/src/realtime-client/pull-selector.ts +1 -1
- package/src/realtime-client/push-state.ts +1 -1
- package/src/realtime-client/realtime-client-stores/client-main-store.ts +16 -3
- package/src/realtime-client/sync-continuity.ts +1 -2
- package/src/realtime-react/use-realtime-rooms.ts +54 -6
- package/src/realtime-server/continuity/provide-outcomes.ts +1 -1
- package/src/realtime-server/ipc-sockets/parent-socket.ts +11 -15
- package/src/realtime-server/provide-rooms.ts +64 -16
- package/src/realtime-server/realtime-family-provider.ts +51 -35
- package/src/realtime-server/realtime-mutable-family-provider.ts +50 -34
- package/src/realtime-server/realtime-mutable-provider.ts +4 -4
- package/src/realtime-server/realtime-state-provider.ts +7 -7
- package/src/realtime-server/realtime-state-receiver.ts +2 -2
- package/src/realtime-server/server-config.ts +20 -13
- package/src/realtime-server/server-socket-state.ts +3 -3
- package/src/realtime-testing/setup-realtime-test.tsx +2 -2
package/dist/realtime/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AtomFamilyToken, AtomToken, JoinToken, Loadable, MutableAtomToken, PureSelectorFamilyToken, ReadableFamilyToken, ReadableToken, ReadonlyPureSelectorFamilyToken, TokenType, TransactionToken } from "atom.io";
|
|
2
|
-
import { Canonical, Json } from "atom.io/json";
|
|
2
|
+
import { Canonical, Json, JsonIO } from "atom.io/json";
|
|
3
3
|
import { UList } from "atom.io/transceivers/u-list";
|
|
4
4
|
import { Socket as Socket$1 } from "atom.io/realtime";
|
|
5
5
|
import { Events } from "atom.io/realtime-server";
|
|
@@ -26,7 +26,7 @@ type Socket = {
|
|
|
26
26
|
on: (event: string, listener: (...args: Json.Serializable[]) => void) => void;
|
|
27
27
|
onAny: (listener: (event: string, ...args: Json.Serializable[]) => void) => void;
|
|
28
28
|
onAnyOutgoing: (listener: (event: string, ...args: Json.Serializable[]) => void) => void;
|
|
29
|
-
off: (event: string, listener
|
|
29
|
+
off: (event: string, listener?: (...args: Json.Serializable[]) => void) => void;
|
|
30
30
|
offAny: (listener: (event: string, ...args: Json.Serializable[]) => void) => void;
|
|
31
31
|
emit: (event: string, ...args: Json.Serializable[]) => void;
|
|
32
32
|
};
|
|
@@ -121,7 +121,7 @@ type ContinuityToken = {
|
|
|
121
121
|
readonly type: `continuity`;
|
|
122
122
|
readonly key: string;
|
|
123
123
|
readonly globals: AtomToken<any>[];
|
|
124
|
-
readonly actions: TransactionToken<
|
|
124
|
+
readonly actions: (Json.Serializable & TransactionToken<JsonIO>)[];
|
|
125
125
|
readonly perspectives: PerspectiveToken<AtomFamilyToken<any, Canonical>>[];
|
|
126
126
|
};
|
|
127
127
|
declare class SyncGroup {
|
|
@@ -156,9 +156,10 @@ type UserInRoomMeta = {
|
|
|
156
156
|
};
|
|
157
157
|
declare const DEFAULT_USER_IN_ROOM_META: UserInRoomMeta;
|
|
158
158
|
declare const usersInRooms: JoinToken<`room`, RoomKey, `user`, UserKey, `1:n`>;
|
|
159
|
-
declare const visibleUsersInRoomsSelector: PureSelectorFamilyToken<
|
|
159
|
+
declare const visibleUsersInRoomsSelector: PureSelectorFamilyToken<[self: UserKey, ...RoomKey[]], UserKey>;
|
|
160
|
+
declare const visibilityFromRoomSelector: PureSelectorFamilyToken<[self: RoomKey, ...UserKey[]], RoomKey>;
|
|
161
|
+
declare const mutualUsersSelector: ReadonlyPureSelectorFamilyToken<UserKey[], UserKey>;
|
|
160
162
|
declare const ownersOfRooms: JoinToken<`user`, UserKey, `room`, RoomKey, `1:n`>;
|
|
161
|
-
declare const usersInMyRoomView: ReadonlyPureSelectorFamilyToken<MutableAtomToken<UList<RoomKey>>[], UserKey>;
|
|
162
163
|
//#endregion
|
|
163
|
-
export { AllEventsListener, ContinuityOptions, ContinuityToken, DEFAULT_USER_IN_ROOM_META, EventEmitter, EventListener, EventsMap, InvariantMap, Loaded, ParticularEventListener, PerspectiveToken, RoomKey, RoomSocketInterface, Socket, SocketGuard, SocketKey, SocketListeners, StandardSchemaV1, SyncGroup, TypedSocket, UserInRoomMeta, UserKey, castSocket, continuity, employSocket, isRoomKey, isSocketKey, isUserKey, mutexAtoms, ownersOfRooms, roomKeysAtom,
|
|
164
|
+
export { AllEventsListener, ContinuityOptions, ContinuityToken, DEFAULT_USER_IN_ROOM_META, EventEmitter, EventListener, EventsMap, InvariantMap, Loaded, ParticularEventListener, PerspectiveToken, RoomKey, RoomSocketInterface, Socket, SocketGuard, SocketKey, SocketListeners, StandardSchemaV1, SyncGroup, TypedSocket, UserInRoomMeta, UserKey, castSocket, continuity, employSocket, isRoomKey, isSocketKey, isUserKey, mutexAtoms, mutualUsersSelector, ownersOfRooms, roomKeysAtom, usersInRooms, visibilityFromRoomSelector, visibleUsersInRoomsSelector };
|
|
164
165
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["mutexAtoms: AtomFamilyToken<boolean, Canonical>","roomKeysAtom: MutableAtomToken<UList<RoomKey>>","DEFAULT_USER_IN_ROOM_META: UserInRoomMeta","usersInRooms: JoinToken<`room`, RoomKey, `user`, UserKey, `1:n`>","visibleUsersInRoomsSelector: PureSelectorFamilyToken<\n\t
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["mutexAtoms: AtomFamilyToken<boolean, Canonical>","roomKeysAtom: MutableAtomToken<UList<RoomKey>>","DEFAULT_USER_IN_ROOM_META: UserInRoomMeta","usersInRooms: JoinToken<`room`, RoomKey, `user`, UserKey, `1:n`>","visibleUsersInRoomsSelector: PureSelectorFamilyToken<\n\t[self: UserKey, ...RoomKey[]],\n\tUserKey\n>","visibilityFromRoomSelector: PureSelectorFamilyToken<\n\t[self: RoomKey, ...UserKey[]],\n\tRoomKey\n>","mutualUsersSelector: ReadonlyPureSelectorFamilyToken<\n\tUserKey[],\n\tUserKey\n>","ownersOfRooms: JoinToken<`user`, UserKey, `room`, RoomKey, `1:n`>"],"sources":["../../src/realtime/socket-interface.ts","../../src/realtime/standard-schema.ts","../../src/realtime/cast-socket.ts","../../src/realtime/employ-socket.ts","../../src/realtime/mutex-store.ts","../../src/realtime/realtime-key-types.ts","../../src/realtime/realtime-continuity.ts","../../src/realtime/shared-room-store.ts"],"sourcesContent":[],"mappings":";;;;;;;KAEY,aAAA,aAA0B,IAAA,CAAK;KAE/B,SAAA;mBACM;;KAGN,6CAA6C,YAAY,uCAC1C,qBAClB,aACG,aAAa;KAGb,uCAAuC,YAAY,uCAC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GOgDL,OPhDK,EAAA,CAAA,EOiDxB,OPjDwB,CAAA;AAGb,cO0DCC,mBP1DD,EO0DsB,+BP1DtB,CO2DX,OP3DW,EAAA,EO4DX,OP5DW,CAAA;AAAuC,cO+EtCC,aP/EsC,EO+EvB,SP/EuB,CAAA,MAAA,EO+EL,OP/EK,EAAA,MAAA,EO+EY,OP/EZ,EAAA,KAAA,CAAA"}
|
package/dist/realtime/index.js
CHANGED
|
@@ -130,7 +130,7 @@ const isRoomKey = (key) => key.startsWith(`room::`);
|
|
|
130
130
|
//#endregion
|
|
131
131
|
//#region src/realtime/shared-room-store.ts
|
|
132
132
|
const roomKeysAtom = mutableAtom({
|
|
133
|
-
key: `
|
|
133
|
+
key: `roomKeys`,
|
|
134
134
|
class: UList
|
|
135
135
|
});
|
|
136
136
|
const DEFAULT_USER_IN_ROOM_META = { enteredAtEpoch: 0 };
|
|
@@ -142,12 +142,28 @@ const usersInRooms = join({
|
|
|
142
142
|
isBType: isUserKey
|
|
143
143
|
});
|
|
144
144
|
const visibleUsersInRoomsSelector = selectorFamily({
|
|
145
|
-
key: `
|
|
145
|
+
key: `visibleUsersInRooms`,
|
|
146
146
|
get: (userKey) => ({ get }) => {
|
|
147
147
|
const [, roomsOfUsersAtoms] = getInternalRelations(usersInRooms, `split`);
|
|
148
148
|
return [userKey, ...get(roomsOfUsersAtoms, userKey)];
|
|
149
149
|
}
|
|
150
150
|
});
|
|
151
|
+
const visibilityFromRoomSelector = selectorFamily({
|
|
152
|
+
key: `visibilityFromRoom`,
|
|
153
|
+
get: (roomKey) => ({ get }) => {
|
|
154
|
+
const [usersOfRoomsAtoms] = getInternalRelations(usersInRooms, `split`);
|
|
155
|
+
return [roomKey, ...get(usersOfRoomsAtoms, roomKey)];
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
const mutualUsersSelector = selectorFamily({
|
|
159
|
+
key: `mutualUsers`,
|
|
160
|
+
get: (userKey) => ({ get }) => {
|
|
161
|
+
const [usersOfRoomsAtoms, roomsOfUsersAtoms] = getInternalRelations(usersInRooms, `split`);
|
|
162
|
+
const rooms = get(roomsOfUsersAtoms, userKey);
|
|
163
|
+
for (const room of rooms) return [...get(usersOfRoomsAtoms, room)];
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
});
|
|
151
167
|
const ownersOfRooms = join({
|
|
152
168
|
key: `ownersOfRooms`,
|
|
153
169
|
between: [`user`, `room`],
|
|
@@ -155,14 +171,7 @@ const ownersOfRooms = join({
|
|
|
155
171
|
isAType: isUserKey,
|
|
156
172
|
isBType: isRoomKey
|
|
157
173
|
});
|
|
158
|
-
const usersInMyRoomView = selectorFamily({
|
|
159
|
-
key: `usersInMyRoomView`,
|
|
160
|
-
get: (myUsername) => ({ find }) => {
|
|
161
|
-
const [, roomsOfUsersAtoms] = getInternalRelations(usersInRooms, `split`);
|
|
162
|
-
return [find(roomsOfUsersAtoms, myUsername)];
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
174
|
|
|
166
175
|
//#endregion
|
|
167
|
-
export { DEFAULT_USER_IN_ROOM_META, InvariantMap, SyncGroup, castSocket, continuity, employSocket, isRoomKey, isSocketKey, isUserKey, mutexAtoms, ownersOfRooms, roomKeysAtom,
|
|
176
|
+
export { DEFAULT_USER_IN_ROOM_META, InvariantMap, SyncGroup, castSocket, continuity, employSocket, isRoomKey, isSocketKey, isUserKey, mutexAtoms, mutualUsersSelector, ownersOfRooms, roomKeysAtom, usersInRooms, visibilityFromRoomSelector, visibleUsersInRoomsSelector };
|
|
168
177
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["mutexAtoms: AtomFamilyToken<boolean, Canonical>","roomKeysAtom: MutableAtomToken<UList<RoomKey>>","DEFAULT_USER_IN_ROOM_META: UserInRoomMeta","usersInRooms: JoinToken<`room`, RoomKey, `user`, UserKey, `1:n`>","visibleUsersInRoomsSelector: PureSelectorFamilyToken<\n\t(RoomKey | UserKey)[],\n\tUserKey\n>","ownersOfRooms: JoinToken<`user`, UserKey, `room`, RoomKey, `1:n`>","usersInMyRoomView: ReadonlyPureSelectorFamilyToken<\n\tMutableAtomToken<UList<RoomKey>>[],\n\tUserKey\n>"],"sources":["../../src/realtime/cast-socket.ts","../../src/realtime/employ-socket.ts","../../src/realtime/mutex-store.ts","../../src/realtime/realtime-continuity.ts","../../src/realtime/realtime-key-types.ts","../../src/realtime/shared-room-store.ts"],"sourcesContent":["import type { Loadable } from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\n\nimport type { EventsMap, Socket, TypedSocket } from \"./socket-interface\"\nimport type { StandardSchemaV1 } from \"./standard-schema\"\n\nexport type SocketListeners<T extends TypedSocket> =\n\tT extends TypedSocket<infer ListenEvents> ? ListenEvents : never\n\nexport type SocketGuard<L extends EventsMap> = {\n\t[K in keyof L]: StandardSchemaV1<Json.Array, Parameters<L[K]>>\n}\n\nexport type Loaded<L extends Loadable<any>> =\n\tL extends Loadable<infer T> ? T : never\n\nfunction onLoad<L extends Loadable<any>>(\n\tloadable: L,\n\tfn: (loaded: Loaded<L>) => any,\n): void {\n\tif (loadable instanceof Promise) {\n\t\tvoid loadable.then(fn)\n\t} else {\n\t\tfn(loadable as Loaded<L>)\n\t}\n}\n\nexport function castSocket<T extends TypedSocket>(\n\tsocket: Socket,\n\tguard: SocketGuard<SocketListeners<T>> | `TRUST`,\n\tlogError?: (error: unknown) => void,\n): T {\n\tif (guard === `TRUST`) {\n\t\treturn socket as T\n\t}\n\tconst guardedSocket: Socket = {\n\t\tid: socket.id,\n\t\ton: (event, listener) => {\n\t\t\tconst schema = guard[event] as StandardSchemaV1<Json.Array, Json.Array>\n\t\t\tsocket.on(event, (...args) => {\n\t\t\t\tconst loadableResult = schema[`~standard`].validate(args)\n\t\t\t\tonLoad(loadableResult, (result) => {\n\t\t\t\t\tif (result.issues) {\n\t\t\t\t\t\tlogError?.(result.issues)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlistener(...result.value)\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t})\n\t\t},\n\t\tonAny: (listener) => {\n\t\t\tsocket.onAny((event, ...args) => {\n\t\t\t\tconst schema = guard[event] as StandardSchemaV1<unknown, Json.Array>\n\t\t\t\tconst loadableResult = schema[`~standard`].validate(args)\n\t\t\t\tonLoad(loadableResult, (result) => {\n\t\t\t\t\tif (result.issues) {\n\t\t\t\t\t\tlogError?.(result.issues)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlistener(event, ...result.value)\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t})\n\t\t},\n\t\tonAnyOutgoing: socket.onAnyOutgoing.bind(socket),\n\t\toff: socket.off.bind(socket),\n\t\toffAny: socket.offAny.bind(socket),\n\t\temit: socket.emit.bind(socket),\n\t}\n\treturn guardedSocket as T\n}\n","import type { Socket } from \"atom.io/realtime\"\nimport type { Events } from \"atom.io/realtime-server\"\n\nexport function employSocket<I extends Events, K extends string & keyof I>(\n\tsocket: Socket,\n\tevent: K,\n\thandleEvent: (...data: I[K]) => void,\n): () => void {\n\tsocket.on(event, handleEvent)\n\tconst retireSocket = () => {\n\t\tsocket.off(event, handleEvent)\n\t}\n\treturn retireSocket\n}\n","import type { AtomFamilyToken } from \"atom.io\"\nimport { atomFamily } from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\n\nexport const mutexAtoms: AtomFamilyToken<boolean, Canonical> = atomFamily({\n\tkey: `mutex`,\n\tdefault: false,\n})\n","import type {\n\tAtomFamilyToken,\n\tAtomToken,\n\tReadableFamilyToken,\n\tReadableToken,\n\tTokenType,\n\tTransactionToken,\n} from \"atom.io\"\nimport {\n\tassignTransactionToContinuity,\n\tIMPLICIT,\n\tsetEpochNumberOfContinuity,\n} from \"atom.io/internal\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport type { UserKey } from \"./realtime-key-types\"\n\n/* eslint-disable no-console */\n\nexport class InvariantMap<K, V> extends Map<K, V> implements ReadonlyMap<K, V> {\n\tpublic set(key: K, value: V): this {\n\t\tif (this.has(key)) {\n\t\t\tconsole.warn(`Tried to set a key that already exists in an InvariantMap`, {\n\t\t\t\tkey,\n\t\t\t\tvalue,\n\t\t\t})\n\t\t\treturn this\n\t\t}\n\t\treturn super.set(key, value)\n\t}\n}\n\nexport type PerspectiveToken<F extends AtomFamilyToken<any>> = {\n\ttype: `realtime_perspective`\n\tresourceAtoms: F\n\tviewAtoms: ReadableFamilyToken<ReadableToken<TokenType<F>>[], UserKey>\n}\n\nexport type ContinuityToken = {\n\treadonly type: `continuity`\n\treadonly key: string\n\treadonly globals: AtomToken<any>[]\n\treadonly actions: TransactionToken<any>[]\n\treadonly perspectives: PerspectiveToken<AtomFamilyToken<any, Canonical>>[]\n}\n\nexport class SyncGroup {\n\tpublic type = `continuity` as const\n\n\tprotected globals: AtomToken<any>[] = []\n\tprotected actions: TransactionToken<any>[] = []\n\tprotected perspectives: PerspectiveToken<any>[] = []\n\tprotected readonly key: string\n\n\tprotected constructor(key: string) {\n\t\tthis.key = key\n\t}\n\n\tpublic static existing: InvariantMap<string, ContinuityToken> =\n\t\tnew InvariantMap()\n\tpublic static create(\n\t\tkey: string,\n\t\tbuilder: (group: SyncGroup) => SyncGroup,\n\t): ContinuityToken {\n\t\tconst group = new SyncGroup(key)\n\t\tconst { type, globals, actions, perspectives } = builder(group)\n\t\tconst token = { type, key, globals, actions, perspectives }\n\t\tSyncGroup.existing.set(key, token)\n\t\treturn token\n\t}\n\n\tpublic add(...atoms: AtomToken<any>[]): SyncGroup\n\tpublic add(...args: TransactionToken<any>[]): SyncGroup\n\tpublic add<\n\t\tF extends AtomFamilyToken<any>,\n\t\tT extends F extends AtomFamilyToken<infer U> ? U : never,\n\t>(\n\t\tfamily: AtomFamilyToken<T, any>,\n\t\tindex: ReadableFamilyToken<Iterable<AtomToken<T>>, string>,\n\t): SyncGroup\n\tpublic add(\n\t\t...args:\n\t\t\t| readonly AtomToken<any>[]\n\t\t\t| readonly TransactionToken<any>[]\n\t\t\t| [AtomFamilyToken<any, any>, ReadableFamilyToken<Iterable<any>, string>]\n\t): this {\n\t\tconst zeroth = args[0]\n\t\tswitch (zeroth.type) {\n\t\t\tcase `atom`:\n\t\t\tcase `mutable_atom`:\n\t\t\t\tthis.globals.push(...(args as AtomToken<any>[]))\n\t\t\t\tbreak\n\t\t\tcase `transaction`:\n\t\t\t\tthis.actions.push(...(args as TransactionToken<any>[]))\n\t\t\t\tbreak\n\t\t\tcase `atom_family`:\n\t\t\tcase `mutable_atom_family`:\n\t\t\t\t{\n\t\t\t\t\tconst [family, index] = args as [\n\t\t\t\t\t\tAtomFamilyToken<any, any>,\n\t\t\t\t\t\tReadableFamilyToken<ReadableToken<any>[], UserKey>,\n\t\t\t\t\t]\n\t\t\t\t\tthis.perspectives.push({\n\t\t\t\t\t\ttype: `realtime_perspective`,\n\t\t\t\t\t\tresourceAtoms: family,\n\t\t\t\t\t\tviewAtoms: index,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t}\n\n\t\treturn this\n\t}\n}\n\nexport type ContinuityOptions = {\n\tkey: string\n\tconfig: (group: SyncGroup) => SyncGroup\n}\n\nexport function continuity(options: ContinuityOptions): ContinuityToken {\n\tconst { key, config } = options\n\tconst token = SyncGroup.create(key, config)\n\tconst { actions } = token\n\tfor (const action of actions) {\n\t\tassignTransactionToContinuity(IMPLICIT.STORE, key, action.key)\n\t}\n\tsetEpochNumberOfContinuity(IMPLICIT.STORE, key, -1)\n\treturn token\n}\n\n// const counterStates = atomFamily<number, { c: string }>({\n// \tkey: `counter`,\n// \tdefault: 0,\n// })\n// const counterIndices = atomFamily<{ c: string }[], string>({\n// \tkey: `counterIndex`,\n// \tdefault: [],\n// })\n// const nameStates = atomFamily<number, { n: string }>({\n// \tkey: `name`,\n// \tdefault: 0,\n// })\n// const nameIndices = atomFamily<{ n: string }[], string>({\n// \tkey: `nameIndex`,\n// \tdefault: [],\n// })\n\n// const counterContinuity = continuity({\n// \tkey: `counter`,\n// \tconfig: (group) =>\n// \t\tgroup\n// \t\t\t.add(counterStates, counterIndices)\n// \t\t\t.add(nameStates, nameIndices)\n// \t\t\t.add(nameStates, nameIndices)\n// \t\t\t.add(nameStates, nameIndices),\n// })\n","export type SocketKey = `socket::${string}`\nexport const isSocketKey = (key: string): key is SocketKey =>\n\tkey.startsWith(`socket::`)\n\nexport type UserKey = `user::${string}`\nexport const isUserKey = (key: string): key is UserKey =>\n\tkey.startsWith(`user::`)\n\nexport type RoomKey = `room::${string}`\nexport const isRoomKey = (key: string): key is RoomKey =>\n\tkey.startsWith(`room::`)\n","import type {\n\tJoinToken,\n\tMutableAtomToken,\n\tPureSelectorFamilyToken,\n\tReadonlyPureSelectorFamilyToken,\n} from \"atom.io\"\nimport { getInternalRelations, join, mutableAtom, selectorFamily } from \"atom.io\"\nimport { UList } from \"atom.io/transceivers/u-list\"\n\nimport {\n\tisRoomKey,\n\tisUserKey,\n\ttype RoomKey,\n\ttype UserKey,\n} from \"./realtime-key-types\"\n\nexport type RoomSocketInterface<RoomNames extends string> = {\n\tcreateRoom: (roomName: RoomNames) => void\n\tjoinRoom: (roomKey: RoomKey) => void\n\tdeleteRoom: (roomKey: RoomKey) => void\n\tleaveRoom: () => void\n\t// [leaveRoom: `leaveRoom:${string}`]: () => void\n}\n\nexport const roomKeysAtom: MutableAtomToken<UList<RoomKey>> = mutableAtom({\n\tkey: `roomIndex`,\n\tclass: UList,\n})\n\nexport type UserInRoomMeta = {\n\tenteredAtEpoch: number\n}\nexport const DEFAULT_USER_IN_ROOM_META: UserInRoomMeta = {\n\tenteredAtEpoch: 0,\n}\nexport const usersInRooms: JoinToken<`room`, RoomKey, `user`, UserKey, `1:n`> =\n\tjoin({\n\t\tkey: `usersInRooms`,\n\t\tbetween: [`room`, `user`],\n\t\tcardinality: `1:n`,\n\t\tisAType: isRoomKey,\n\t\tisBType: isUserKey,\n\t})\n\nexport const visibleUsersInRoomsSelector: PureSelectorFamilyToken<\n\t(RoomKey | UserKey)[],\n\tUserKey\n> = selectorFamily({\n\tkey: `selfList`,\n\tget:\n\t\t(userKey) =>\n\t\t({ get }) => {\n\t\t\tconst [, roomsOfUsersAtoms] = getInternalRelations(usersInRooms, `split`)\n\t\t\tconst rooms = get(roomsOfUsersAtoms, userKey)\n\t\t\treturn [userKey, ...rooms]\n\t\t},\n})\n\nexport const ownersOfRooms: JoinToken<`user`, UserKey, `room`, RoomKey, `1:n`> =\n\tjoin({\n\t\tkey: `ownersOfRooms`,\n\t\tbetween: [`user`, `room`],\n\t\tcardinality: `1:n`,\n\t\tisAType: isUserKey,\n\t\tisBType: isRoomKey,\n\t})\n\nexport const usersInMyRoomView: ReadonlyPureSelectorFamilyToken<\n\tMutableAtomToken<UList<RoomKey>>[],\n\tUserKey\n> = selectorFamily({\n\tkey: `usersInMyRoomView`,\n\tget:\n\t\t(myUsername) =>\n\t\t({ find }) => {\n\t\t\tconst [, roomsOfUsersAtoms] = getInternalRelations(usersInRooms, `split`)\n\t\t\tconst myRoomIndex = find(roomsOfUsersAtoms, myUsername)\n\t\t\treturn [myRoomIndex]\n\t\t},\n})\n"],"mappings":";;;;;AAgBA,SAAS,OACR,UACA,IACO;AACP,KAAI,oBAAoB,QACvB,CAAK,SAAS,KAAK,GAAG;KAEtB,IAAG,SAAsB;;AAI3B,SAAgB,WACf,QACA,OACA,UACI;AACJ,KAAI,UAAU,QACb,QAAO;AAmCR,QAjC8B;EAC7B,IAAI,OAAO;EACX,KAAK,OAAO,aAAa;GACxB,MAAM,SAAS,MAAM;AACrB,UAAO,GAAG,QAAQ,GAAG,SAAS;AAE7B,WADuB,OAAO,aAAa,SAAS,KAAK,GACjC,WAAW;AAClC,SAAI,OAAO,OACV,YAAW,OAAO,OAAO;SAEzB,UAAS,GAAG,OAAO,MAAM;MAEzB;KACD;;EAEH,QAAQ,aAAa;AACpB,UAAO,OAAO,OAAO,GAAG,SAAS;AAGhC,WAFe,MAAM,OACS,aAAa,SAAS,KAAK,GACjC,WAAW;AA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C"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["mutexAtoms: AtomFamilyToken<boolean, Canonical>","roomKeysAtom: MutableAtomToken<UList<RoomKey>>","DEFAULT_USER_IN_ROOM_META: UserInRoomMeta","usersInRooms: JoinToken<`room`, RoomKey, `user`, UserKey, `1:n`>","visibleUsersInRoomsSelector: PureSelectorFamilyToken<\n\t[self: UserKey, ...RoomKey[]],\n\tUserKey\n>","visibilityFromRoomSelector: PureSelectorFamilyToken<\n\t[self: RoomKey, ...UserKey[]],\n\tRoomKey\n>","mutualUsersSelector: ReadonlyPureSelectorFamilyToken<\n\tUserKey[],\n\tUserKey\n>","ownersOfRooms: JoinToken<`user`, UserKey, `room`, RoomKey, `1:n`>"],"sources":["../../src/realtime/cast-socket.ts","../../src/realtime/employ-socket.ts","../../src/realtime/mutex-store.ts","../../src/realtime/realtime-continuity.ts","../../src/realtime/realtime-key-types.ts","../../src/realtime/shared-room-store.ts"],"sourcesContent":["import type { Loadable } from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\n\nimport type { EventsMap, Socket, TypedSocket } from \"./socket-interface\"\nimport type { StandardSchemaV1 } from \"./standard-schema\"\n\nexport type SocketListeners<T extends TypedSocket> =\n\tT extends TypedSocket<infer ListenEvents> ? ListenEvents : never\n\nexport type SocketGuard<L extends EventsMap> = {\n\t[K in keyof L]: StandardSchemaV1<Json.Array, Parameters<L[K]>>\n}\n\nexport type Loaded<L extends Loadable<any>> =\n\tL extends Loadable<infer T> ? T : never\n\nfunction onLoad<L extends Loadable<any>>(\n\tloadable: L,\n\tfn: (loaded: Loaded<L>) => any,\n): void {\n\tif (loadable instanceof Promise) {\n\t\tvoid loadable.then(fn)\n\t} else {\n\t\tfn(loadable as Loaded<L>)\n\t}\n}\n\nexport function castSocket<T extends TypedSocket>(\n\tsocket: Socket,\n\tguard: SocketGuard<SocketListeners<T>> | `TRUST`,\n\tlogError?: (error: unknown) => void,\n): T {\n\tif (guard === `TRUST`) {\n\t\treturn socket as T\n\t}\n\tconst guardedSocket: Socket = {\n\t\tid: socket.id,\n\t\ton: (event, listener) => {\n\t\t\tconst schema = guard[event] as StandardSchemaV1<Json.Array, Json.Array>\n\t\t\tsocket.on(event, (...args) => {\n\t\t\t\tconst loadableResult = schema[`~standard`].validate(args)\n\t\t\t\tonLoad(loadableResult, (result) => {\n\t\t\t\t\tif (result.issues) {\n\t\t\t\t\t\tlogError?.(result.issues)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlistener(...result.value)\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t})\n\t\t},\n\t\tonAny: (listener) => {\n\t\t\tsocket.onAny((event, ...args) => {\n\t\t\t\tconst schema = guard[event] as StandardSchemaV1<unknown, Json.Array>\n\t\t\t\tconst loadableResult = schema[`~standard`].validate(args)\n\t\t\t\tonLoad(loadableResult, (result) => {\n\t\t\t\t\tif (result.issues) {\n\t\t\t\t\t\tlogError?.(result.issues)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlistener(event, ...result.value)\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t})\n\t\t},\n\t\tonAnyOutgoing: socket.onAnyOutgoing.bind(socket),\n\t\toff: socket.off.bind(socket),\n\t\toffAny: socket.offAny.bind(socket),\n\t\temit: socket.emit.bind(socket),\n\t}\n\treturn guardedSocket as T\n}\n","import type { Socket } from \"atom.io/realtime\"\nimport type { Events } from \"atom.io/realtime-server\"\n\nexport function employSocket<I extends Events, K extends string & keyof I>(\n\tsocket: Socket,\n\tevent: K,\n\thandleEvent: (...data: I[K]) => void,\n): () => void {\n\tsocket.on(event, handleEvent)\n\tconst retireSocket = () => {\n\t\tsocket.off(event, handleEvent)\n\t}\n\treturn retireSocket\n}\n","import type { AtomFamilyToken } from \"atom.io\"\nimport { atomFamily } from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\n\nexport const mutexAtoms: AtomFamilyToken<boolean, Canonical> = atomFamily({\n\tkey: `mutex`,\n\tdefault: false,\n})\n","import type {\n\tAtomFamilyToken,\n\tAtomToken,\n\tReadableFamilyToken,\n\tReadableToken,\n\tTokenType,\n\tTransactionToken,\n} from \"atom.io\"\nimport {\n\tassignTransactionToContinuity,\n\tIMPLICIT,\n\tsetEpochNumberOfContinuity,\n} from \"atom.io/internal\"\nimport type { Canonical, Json, JsonIO } from \"atom.io/json\"\n\nimport type { UserKey } from \"./realtime-key-types\"\n\n/* eslint-disable no-console */\n\nexport class InvariantMap<K, V> extends Map<K, V> implements ReadonlyMap<K, V> {\n\tpublic set(key: K, value: V): this {\n\t\tif (this.has(key)) {\n\t\t\tconsole.warn(`Tried to set a key that already exists in an InvariantMap`, {\n\t\t\t\tkey,\n\t\t\t\tvalue,\n\t\t\t})\n\t\t\treturn this\n\t\t}\n\t\treturn super.set(key, value)\n\t}\n}\n\nexport type PerspectiveToken<F extends AtomFamilyToken<any>> = {\n\ttype: `realtime_perspective`\n\tresourceAtoms: F\n\tviewAtoms: ReadableFamilyToken<ReadableToken<TokenType<F>>[], UserKey>\n}\n\nexport type ContinuityToken = {\n\treadonly type: `continuity`\n\treadonly key: string\n\treadonly globals: AtomToken<any>[]\n\treadonly actions: (Json.Serializable & TransactionToken<JsonIO>)[]\n\treadonly perspectives: PerspectiveToken<AtomFamilyToken<any, Canonical>>[]\n}\n\nexport class SyncGroup {\n\tpublic type = `continuity` as const\n\n\tprotected globals: AtomToken<any>[] = []\n\tprotected actions: TransactionToken<any>[] = []\n\tprotected perspectives: PerspectiveToken<any>[] = []\n\tprotected readonly key: string\n\n\tprotected constructor(key: string) {\n\t\tthis.key = key\n\t}\n\n\tpublic static existing: InvariantMap<string, ContinuityToken> =\n\t\tnew InvariantMap()\n\tpublic static create(\n\t\tkey: string,\n\t\tbuilder: (group: SyncGroup) => SyncGroup,\n\t): ContinuityToken {\n\t\tconst group = new SyncGroup(key)\n\t\tconst { type, globals, actions, perspectives } = builder(group)\n\t\tconst token = { type, key, globals, actions, perspectives }\n\t\tSyncGroup.existing.set(key, token)\n\t\treturn token\n\t}\n\n\tpublic add(...atoms: AtomToken<any>[]): SyncGroup\n\tpublic add(...args: TransactionToken<any>[]): SyncGroup\n\tpublic add<\n\t\tF extends AtomFamilyToken<any>,\n\t\tT extends F extends AtomFamilyToken<infer U> ? U : never,\n\t>(\n\t\tfamily: AtomFamilyToken<T, any>,\n\t\tindex: ReadableFamilyToken<Iterable<AtomToken<T>>, string>,\n\t): SyncGroup\n\tpublic add(\n\t\t...args:\n\t\t\t| readonly AtomToken<any>[]\n\t\t\t| readonly TransactionToken<any>[]\n\t\t\t| [AtomFamilyToken<any, any>, ReadableFamilyToken<Iterable<any>, string>]\n\t): this {\n\t\tconst zeroth = args[0]\n\t\tswitch (zeroth.type) {\n\t\t\tcase `atom`:\n\t\t\tcase `mutable_atom`:\n\t\t\t\tthis.globals.push(...(args as AtomToken<any>[]))\n\t\t\t\tbreak\n\t\t\tcase `transaction`:\n\t\t\t\tthis.actions.push(...(args as TransactionToken<any>[]))\n\t\t\t\tbreak\n\t\t\tcase `atom_family`:\n\t\t\tcase `mutable_atom_family`:\n\t\t\t\t{\n\t\t\t\t\tconst [family, index] = args as [\n\t\t\t\t\t\tAtomFamilyToken<any, any>,\n\t\t\t\t\t\tReadableFamilyToken<ReadableToken<any>[], UserKey>,\n\t\t\t\t\t]\n\t\t\t\t\tthis.perspectives.push({\n\t\t\t\t\t\ttype: `realtime_perspective`,\n\t\t\t\t\t\tresourceAtoms: family,\n\t\t\t\t\t\tviewAtoms: index,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t}\n\n\t\treturn this\n\t}\n}\n\nexport type ContinuityOptions = {\n\tkey: string\n\tconfig: (group: SyncGroup) => SyncGroup\n}\n\nexport function continuity(options: ContinuityOptions): ContinuityToken {\n\tconst { key, config } = options\n\tconst token = SyncGroup.create(key, config)\n\tconst { actions } = token\n\tfor (const action of actions) {\n\t\tassignTransactionToContinuity(IMPLICIT.STORE, key, action.key)\n\t}\n\tsetEpochNumberOfContinuity(IMPLICIT.STORE, key, -1)\n\treturn token\n}\n\n// const counterStates = atomFamily<number, { c: string }>({\n// \tkey: `counter`,\n// \tdefault: 0,\n// })\n// const counterIndices = atomFamily<{ c: string }[], string>({\n// \tkey: `counterIndex`,\n// \tdefault: [],\n// })\n// const nameStates = atomFamily<number, { n: string }>({\n// \tkey: `name`,\n// \tdefault: 0,\n// })\n// const nameIndices = atomFamily<{ n: string }[], string>({\n// \tkey: `nameIndex`,\n// \tdefault: [],\n// })\n\n// const counterContinuity = continuity({\n// \tkey: `counter`,\n// \tconfig: (group) =>\n// \t\tgroup\n// \t\t\t.add(counterStates, counterIndices)\n// \t\t\t.add(nameStates, nameIndices)\n// \t\t\t.add(nameStates, nameIndices)\n// \t\t\t.add(nameStates, nameIndices),\n// })\n","export type SocketKey = `socket::${string}`\nexport const isSocketKey = (key: string): key is SocketKey =>\n\tkey.startsWith(`socket::`)\n\nexport type UserKey = `user::${string}`\nexport const isUserKey = (key: string): key is UserKey =>\n\tkey.startsWith(`user::`)\n\nexport type RoomKey = `room::${string}`\nexport const isRoomKey = (key: string): key is RoomKey =>\n\tkey.startsWith(`room::`)\n","import type {\n\tJoinToken,\n\tMutableAtomToken,\n\tPureSelectorFamilyToken,\n\tReadonlyPureSelectorFamilyToken,\n} from \"atom.io\"\nimport { getInternalRelations, join, mutableAtom, selectorFamily } from \"atom.io\"\nimport { UList } from \"atom.io/transceivers/u-list\"\n\nimport {\n\tisRoomKey,\n\tisUserKey,\n\ttype RoomKey,\n\ttype UserKey,\n} from \"./realtime-key-types\"\n\nexport type RoomSocketInterface<RoomNames extends string> = {\n\tcreateRoom: (roomName: RoomNames) => void\n\tjoinRoom: (roomKey: RoomKey) => void\n\tdeleteRoom: (roomKey: RoomKey) => void\n\tleaveRoom: () => void\n\t// [leaveRoom: `leaveRoom:${string}`]: () => void\n}\n\nexport const roomKeysAtom: MutableAtomToken<UList<RoomKey>> = mutableAtom({\n\tkey: `roomKeys`,\n\tclass: UList,\n})\n\nexport type UserInRoomMeta = {\n\tenteredAtEpoch: number\n}\nexport const DEFAULT_USER_IN_ROOM_META: UserInRoomMeta = {\n\tenteredAtEpoch: 0,\n}\nexport const usersInRooms: JoinToken<`room`, RoomKey, `user`, UserKey, `1:n`> =\n\tjoin({\n\t\tkey: `usersInRooms`,\n\t\tbetween: [`room`, `user`],\n\t\tcardinality: `1:n`,\n\t\tisAType: isRoomKey,\n\t\tisBType: isUserKey,\n\t})\n\nexport const visibleUsersInRoomsSelector: PureSelectorFamilyToken<\n\t[self: UserKey, ...RoomKey[]],\n\tUserKey\n> = selectorFamily({\n\tkey: `visibleUsersInRooms`,\n\tget:\n\t\t(userKey) =>\n\t\t({ get }) => {\n\t\t\tconst [, roomsOfUsersAtoms] = getInternalRelations(usersInRooms, `split`)\n\t\t\tconst rooms = get(roomsOfUsersAtoms, userKey)\n\t\t\treturn [userKey, ...rooms]\n\t\t},\n})\n\nexport const visibilityFromRoomSelector: PureSelectorFamilyToken<\n\t[self: RoomKey, ...UserKey[]],\n\tRoomKey\n> = selectorFamily({\n\tkey: `visibilityFromRoom`,\n\tget:\n\t\t(roomKey) =>\n\t\t({ get }) => {\n\t\t\tconst [usersOfRoomsAtoms] = getInternalRelations(usersInRooms, `split`)\n\t\t\tconst users = get(usersOfRoomsAtoms, roomKey)\n\t\t\treturn [roomKey, ...users]\n\t\t},\n})\n\nexport const mutualUsersSelector: ReadonlyPureSelectorFamilyToken<\n\tUserKey[],\n\tUserKey\n> = selectorFamily({\n\tkey: `mutualUsers`,\n\tget:\n\t\t(userKey) =>\n\t\t({ get }) => {\n\t\t\tconst [usersOfRoomsAtoms, roomsOfUsersAtoms] = getInternalRelations(\n\t\t\t\tusersInRooms,\n\t\t\t\t`split`,\n\t\t\t)\n\t\t\tconst rooms = get(roomsOfUsersAtoms, userKey)\n\t\t\tfor (const room of rooms) {\n\t\t\t\tconst users = get(usersOfRoomsAtoms, room)\n\t\t\t\treturn [...users]\n\t\t\t}\n\t\t\treturn []\n\t\t},\n})\n\nexport const ownersOfRooms: JoinToken<`user`, UserKey, `room`, RoomKey, `1:n`> =\n\tjoin({\n\t\tkey: `ownersOfRooms`,\n\t\tbetween: [`user`, `room`],\n\t\tcardinality: `1:n`,\n\t\tisAType: isUserKey,\n\t\tisBType: isRoomKey,\n\t})\n"],"mappings":";;;;;AAgBA,SAAS,OACR,UACA,IACO;AACP,KAAI,oBAAoB,QACvB,CAAK,SAAS,KAAK,GAAG;KAEtB,IAAG,SAAsB;;AAI3B,SAAgB,WACf,QACA,OACA,UACI;AACJ,KAAI,UAAU,QACb,QAAO;AAmCR,QAjC8B;EAC7B,IAAI,OAAO;EACX,KAAK,OAAO,aAAa;GACxB,MAAM,SAAS,MAAM;AACrB,UAAO,GAAG,QAAQ,GAAG,SAAS;AAE7B,WADuB,OAAO,aAAa,SAAS,KAAK,GACjC,WAAW;AAClC,SAAI,OAAO,OACV,YAAW,OAAO,OAAO;SAEzB,UAAS,GAAG,OAAO,MAAM;MAEzB;KACD;;EAEH,QAAQ,aAAa;AACpB,UAAO,OAAO,OAAO,GAAG,SAAS;AAGhC,WAFe,MAAM,OACS,aAAa,SAAS,KAAK,GACjC,WAAW;AAClC,SAAI,OAAO,OACV,YAAW,OAAO,OAAO;SAEzB,UAAS,OAAO,GAAG,OAAO,MAAM;MAEhC;KACD;;EAEH,eAAe,OAAO,cAAc,KAAK,OAAO;EAChD,KAAK,OAAO,IAAI,KAAK,OAAO;EAC5B,QAAQ,OAAO,OAAO,KAAK,OAAO;EAClC,MAAM,OAAO,KAAK,KAAK,OAAO;EAC9B;;;;;AChEF,SAAgB,aACf,QACA,OACA,aACa;AACb,QAAO,GAAG,OAAO,YAAY;CAC7B,MAAM,qBAAqB;AAC1B,SAAO,IAAI,OAAO,YAAY;;AAE/B,QAAO;;;;;ACRR,MAAaA,aAAkD,WAAW;CACzE,KAAK;CACL,SAAS;CACT,CAAC;;;;ACYF,IAAa,eAAb,cAAwC,IAAuC;CAC9E,AAAO,IAAI,KAAQ,OAAg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B,MAAa,aAAa,QACzB,IAAI,WAAW,SAAS;;;;ACczB,MAAaC,eAAiD,YAAY;CACzE,KAAK;CACL,OAAO;CACP,CAAC;AAKF,MAAaC,4BAA4C,EACxD,gBAAgB,GAChB;AACD,MAAaC,eACZ,KAAK;CACJ,KAAK;CACL,SAAS,CAAC,QAAQ,OAAO;CACzB,aAAa;CACb,SAAS;CACT,SAAS;CACT,CAAC;AAEH,MAAaC,8BAGT,eAAe;CAClB,KAAK;CACL,MACE,aACA,EAAE,UAAU;EACZ,MAAM,GAAG,qBAAqB,qBAAqB,cAAc,QAAQ;AAEzE,SAAO,CAAC,SAAS,GADH,IAAI,mBAAmB,QAAQ,CACnB;;CAE5B,CAAC;AAEF,MAAaC,6BAGT,eAAe;CAClB,KAAK;CACL,MACE,aACA,EAAE,UAAU;EACZ,MAAM,CAAC,qBAAqB,qBAAqB,cAAc,QAAQ;AAEvE,SAAO,CAAC,SAAS,GADH,IAAI,mBAAmB,QAAQ,CACnB;;CAE5B,CAAC;AAEF,MAAaC,sBAGT,eAAe;CAClB,KAAK;CACL,MACE,aACA,EAAE,UAAU;EACZ,MAAM,CAAC,mBAAmB,qBAAqB,qBAC9C,cACA,QACA;EACD,MAAM,QAAQ,IAAI,mBAAmB,QAAQ;AAC7C,OAAK,MAAM,QAAQ,MAElB,QAAO,CAAC,GADM,IAAI,mBAAmB,KAAK,CACzB;AAElB,SAAO,EAAE;;CAEX,CAAC;AAEF,MAAaC,gBACZ,KAAK;CACJ,KAAK;CACL,SAAS,CAAC,QAAQ,OAAO;CACzB,aAAa;CACb,SAAS;CACT,SAAS;CACT,CAAC"}
|
|
@@ -2,49 +2,49 @@ import { Fn, RootStore, Store, Transceiver } from "atom.io/internal";
|
|
|
2
2
|
import * as AtomIO from "atom.io";
|
|
3
3
|
import { AtomToken, WritableToken } from "atom.io";
|
|
4
4
|
import { Canonical, Json } from "atom.io/json";
|
|
5
|
-
import { ContinuityToken, Socket, SocketKey, UserKey } from "atom.io/realtime";
|
|
6
|
-
import { Socket as Socket$1 } from "socket.io-client";
|
|
5
|
+
import { ContinuityToken, RoomKey, Socket, SocketKey, UserKey } from "atom.io/realtime";
|
|
7
6
|
|
|
8
7
|
//#region src/realtime-client/continuity/register-and-attempt-confirmed-update.d.ts
|
|
9
|
-
declare const useRegisterAndAttemptConfirmedUpdate: (store: RootStore, continuityKey: string, socket: Socket, optimisticUpdates: readonly AtomIO.TransactionOutcomeEvent<AtomIO.TransactionToken<Fn>>[], confirmedUpdates: readonly AtomIO.TransactionOutcomeEvent<AtomIO.TransactionToken<Fn>>[]) => (confirmed: AtomIO.TransactionOutcomeEvent<AtomIO.TransactionToken<Fn>>) => void;
|
|
8
|
+
declare const useRegisterAndAttemptConfirmedUpdate: (store: RootStore, continuityKey: string, socket: Socket, optimisticUpdates: readonly AtomIO.TransactionOutcomeEvent<AtomIO.TransactionToken<Fn>>[], confirmedUpdates: readonly AtomIO.TransactionOutcomeEvent<AtomIO.TransactionToken<Fn>>[]) => (confirmed: AtomIO.TransactionOutcomeEvent<AtomIO.TransactionToken<Fn>> & Json.Serializable) => void;
|
|
10
9
|
//#endregion
|
|
11
10
|
//#region src/realtime-client/continuity/use-conceal-state.d.ts
|
|
12
|
-
declare function useConcealState(store: Store): (concealed: AtomToken<
|
|
11
|
+
declare function useConcealState(store: Store): (concealed: AtomToken<Json.Serializable>[]) => void;
|
|
13
12
|
//#endregion
|
|
14
13
|
//#region src/realtime-client/continuity/use-reveal-state.d.ts
|
|
15
14
|
declare function useRevealState(store: Store): (revealed: Json.Array) => void;
|
|
16
15
|
//#endregion
|
|
17
16
|
//#region src/realtime-client/pull-atom.d.ts
|
|
18
|
-
declare function pullAtom<J extends Json.Serializable>(store: Store, socket: Socket
|
|
17
|
+
declare function pullAtom<J extends Json.Serializable>(store: Store, socket: Socket, token: AtomIO.RegularAtomToken<J, any, any>): () => void;
|
|
19
18
|
//#endregion
|
|
20
19
|
//#region src/realtime-client/pull-atom-family-member.d.ts
|
|
21
|
-
declare function pullAtomFamilyMember<J extends Json.Serializable, K extends Canonical>(store: Store, socket: Socket
|
|
20
|
+
declare function pullAtomFamilyMember<J extends Json.Serializable, K extends Canonical>(store: Store, socket: Socket, family: AtomIO.AtomFamilyToken<J, K, any>, key: NoInfer<K>): () => void;
|
|
22
21
|
//#endregion
|
|
23
22
|
//#region src/realtime-client/pull-mutable-atom.d.ts
|
|
24
|
-
declare function pullMutableAtom<T extends Transceiver<any, any, any>>(store: Store, socket: Socket
|
|
23
|
+
declare function pullMutableAtom<T extends Transceiver<any, any, any>>(store: Store, socket: Socket, token: AtomIO.MutableAtomToken<T>): () => void;
|
|
25
24
|
//#endregion
|
|
26
25
|
//#region src/realtime-client/pull-mutable-atom-family-member.d.ts
|
|
27
|
-
declare function pullMutableAtomFamilyMember<T extends Transceiver<any, any, any>, K extends Canonical>(store: Store, socket: Socket
|
|
26
|
+
declare function pullMutableAtomFamilyMember<T extends Transceiver<any, any, any>, K extends Canonical>(store: Store, socket: Socket, family: AtomIO.MutableAtomFamilyToken<T, K>, key: NoInfer<K>): () => void;
|
|
28
27
|
//#endregion
|
|
29
28
|
//#region src/realtime-client/pull-selector.d.ts
|
|
30
|
-
declare function pullSelector<T>(store: Store, socket: Socket
|
|
29
|
+
declare function pullSelector<T>(store: Store, socket: Socket, token: AtomIO.SelectorToken<T>): () => void;
|
|
31
30
|
//#endregion
|
|
32
31
|
//#region src/realtime-client/pull-selector-family-member.d.ts
|
|
33
|
-
declare function pullSelectorFamilyMember<T, K extends Canonical>(store: Store, socket: Socket
|
|
32
|
+
declare function pullSelectorFamilyMember<T, K extends Canonical>(store: Store, socket: Socket, familyToken: AtomIO.SelectorFamilyToken<T, K>, key: NoInfer<K>): () => void;
|
|
34
33
|
//#endregion
|
|
35
34
|
//#region src/realtime-client/push-state.d.ts
|
|
36
|
-
declare function pushState<J extends Json.Serializable>(store: Store, socket: Socket
|
|
35
|
+
declare function pushState<J extends Json.Serializable>(store: Store, socket: Socket, token: WritableToken<J>): () => void;
|
|
37
36
|
//#endregion
|
|
38
37
|
//#region src/realtime-client/realtime-client-stores/client-main-store.d.ts
|
|
39
38
|
declare const mySocketKeyAtom: AtomIO.RegularAtomToken<SocketKey | undefined>;
|
|
40
39
|
declare const myUserKeyAtom: AtomIO.RegularAtomToken<UserKey | null>;
|
|
40
|
+
declare const myRoomKeyAtom: AtomIO.RegularAtomToken<RoomKey | null>;
|
|
41
41
|
//#endregion
|
|
42
42
|
//#region src/realtime-client/realtime-client-stores/client-sync-store.d.ts
|
|
43
43
|
declare const optimisticUpdateQueueAtom: AtomIO.RegularAtomToken<AtomIO.TransactionOutcomeEvent<any>[]>;
|
|
44
44
|
declare const confirmedUpdateQueueAtom: AtomIO.RegularAtomToken<AtomIO.TransactionOutcomeEvent<any>[]>;
|
|
45
45
|
//#endregion
|
|
46
46
|
//#region src/realtime-client/sync-continuity.d.ts
|
|
47
|
-
declare function syncContinuity(store: RootStore, socket: Socket
|
|
47
|
+
declare function syncContinuity(store: RootStore, socket: Socket, continuity: ContinuityToken): () => void;
|
|
48
48
|
//#endregion
|
|
49
|
-
export { confirmedUpdateQueueAtom, mySocketKeyAtom, myUserKeyAtom, optimisticUpdateQueueAtom, pullAtom, pullAtomFamilyMember, pullMutableAtom, pullMutableAtomFamilyMember, pullSelector, pullSelectorFamilyMember, pushState, syncContinuity, useConcealState, useRegisterAndAttemptConfirmedUpdate, useRevealState };
|
|
49
|
+
export { confirmedUpdateQueueAtom, myRoomKeyAtom, mySocketKeyAtom, myUserKeyAtom, optimisticUpdateQueueAtom, pullAtom, pullAtomFamilyMember, pullMutableAtom, pullMutableAtomFamilyMember, pullSelector, pullSelectorFamilyMember, pushState, syncContinuity, useConcealState, useRegisterAndAttemptConfirmedUpdate, useRevealState };
|
|
50
50
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["mySocketKeyAtom: AtomIO.RegularAtomToken<SocketKey | undefined>","myUserKeyAtom: AtomIO.RegularAtomToken<UserKey | null>","optimisticUpdateQueueAtom: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n>","confirmedUpdateQueueAtom: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n>"],"sources":["../../src/realtime-client/continuity/register-and-attempt-confirmed-update.ts","../../src/realtime-client/continuity/use-conceal-state.ts","../../src/realtime-client/continuity/use-reveal-state.ts","../../src/realtime-client/pull-atom.ts","../../src/realtime-client/pull-atom-family-member.ts","../../src/realtime-client/pull-mutable-atom.ts","../../src/realtime-client/pull-mutable-atom-family-member.ts","../../src/realtime-client/pull-selector.ts","../../src/realtime-client/pull-selector-family-member.ts","../../src/realtime-client/push-state.ts","../../src/realtime-client/realtime-client-stores/client-main-store.ts","../../src/realtime-client/realtime-client-stores/client-sync-store.ts","../../src/realtime-client/sync-continuity.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["mySocketKeyAtom: AtomIO.RegularAtomToken<SocketKey | undefined>","myUserKeyAtom: AtomIO.RegularAtomToken<UserKey | null>","myRoomKeyAtom: AtomIO.RegularAtomToken<RoomKey | null>","optimisticUpdateQueueAtom: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n>","confirmedUpdateQueueAtom: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n>"],"sources":["../../src/realtime-client/continuity/register-and-attempt-confirmed-update.ts","../../src/realtime-client/continuity/use-conceal-state.ts","../../src/realtime-client/continuity/use-reveal-state.ts","../../src/realtime-client/pull-atom.ts","../../src/realtime-client/pull-atom-family-member.ts","../../src/realtime-client/pull-mutable-atom.ts","../../src/realtime-client/pull-mutable-atom-family-member.ts","../../src/realtime-client/pull-selector.ts","../../src/realtime-client/pull-selector-family-member.ts","../../src/realtime-client/push-state.ts","../../src/realtime-client/realtime-client-stores/client-main-store.ts","../../src/realtime-client/realtime-client-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AAoB,IAAA,CAAK,qBACjC,eACC,eACD,cAAc;;;cCPTA,iBAAiB,MAAA,CAAO,iBAAiB;cAMzCC,eAAe,MAAA,CAAO,iBAAiB;cAevCC,eAAe,MAAA,CAAO,iBAAiB;;;cCtBvCC,2BAA2B,MAAA,CAAO,iBAC9C,MAAA,CAAO;cAMKC,0BAA0B,MAAA,CAAO,iBAC7C,MAAA,CAAO;;;iBCUQ,cAAA,QACR,mBACC,oBACI"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { actUponStore, assignTransactionToContinuity, disposeAtom, findInStore, getEpochNumberOfContinuity, getFamilyOfToken, getFromStore, getJsonToken, getUpdateToken, ingestTransactionOutcomeEvent, setEpochNumberOfContinuity, setIntoStore, subscribeToState, subscribeToTransaction } from "atom.io/internal";
|
|
2
2
|
import * as AtomIO from "atom.io";
|
|
3
3
|
import { parseJson } from "atom.io/json";
|
|
4
|
-
import { storageSync } from "atom.io/web";
|
|
5
4
|
import { employSocket, mutexAtoms } from "atom.io/realtime";
|
|
6
5
|
|
|
7
6
|
//#region src/realtime-client/realtime-client-stores/client-main-store.ts
|
|
@@ -12,7 +11,15 @@ const mySocketKeyAtom = AtomIO.atom({
|
|
|
12
11
|
const myUserKeyAtom = AtomIO.atom({
|
|
13
12
|
key: `myUserKey`,
|
|
14
13
|
default: null,
|
|
15
|
-
effects: [
|
|
14
|
+
effects: [(userKey) => {
|
|
15
|
+
if (typeof window !== `undefined`) import(`atom.io/web`).then(({ storageSync }) => {
|
|
16
|
+
storageSync(globalThis.localStorage, JSON, `myUserKey`)(userKey);
|
|
17
|
+
});
|
|
18
|
+
}]
|
|
19
|
+
});
|
|
20
|
+
const myRoomKeyAtom = AtomIO.atom({
|
|
21
|
+
key: `myRoomKey`,
|
|
22
|
+
default: null
|
|
16
23
|
});
|
|
17
24
|
|
|
18
25
|
//#endregion
|
|
@@ -362,5 +369,5 @@ function syncContinuity(store, socket, continuity) {
|
|
|
362
369
|
}
|
|
363
370
|
|
|
364
371
|
//#endregion
|
|
365
|
-
export { confirmedUpdateQueueAtom, mySocketKeyAtom, myUserKeyAtom, optimisticUpdateQueueAtom, pullAtom, pullAtomFamilyMember, pullMutableAtom, pullMutableAtomFamilyMember, pullSelector, pullSelectorFamilyMember, pushState, syncContinuity, useConcealState, useRegisterAndAttemptConfirmedUpdate, useRevealState };
|
|
372
|
+
export { confirmedUpdateQueueAtom, myRoomKeyAtom, mySocketKeyAtom, myUserKeyAtom, optimisticUpdateQueueAtom, pullAtom, pullAtomFamilyMember, pullMutableAtom, pullMutableAtomFamilyMember, pullSelector, pullSelectorFamilyMember, pushState, syncContinuity, useConcealState, useRegisterAndAttemptConfirmedUpdate, useRevealState };
|
|
366
373
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["mySocketKeyAtom: AtomIO.RegularAtomToken<SocketKey | undefined>","myUserKeyAtom: AtomIO.RegularAtomToken<UserKey | null>","optimisticUpdateQueueAtom: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n>","confirmedUpdateQueueAtom: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n>","continuityEpoch: number | undefined","k: any","v: any","k: any","v: any"],"sources":["../../src/realtime-client/realtime-client-stores/client-main-store.ts","../../src/realtime-client/realtime-client-stores/client-sync-store.ts","../../src/realtime-client/continuity/register-and-attempt-confirmed-update.ts","../../src/realtime-client/continuity/use-conceal-state.ts","../../src/realtime-client/continuity/use-reveal-state.ts","../../src/realtime-client/pull-atom.ts","../../src/realtime-client/pull-atom-family-member.ts","../../src/realtime-client/pull-mutable-atom.ts","../../src/realtime-client/pull-mutable-atom-family-member.ts","../../src/realtime-client/pull-selector-roots.ts","../../src/realtime-client/pull-selector.ts","../../src/realtime-client/pull-selector-family-member.ts","../../src/realtime-client/push-state.ts","../../src/realtime-client/sync-continuity.ts"],"sourcesContent":["import * as AtomIO from \"atom.io\"\nimport type { SocketKey, UserKey } from \"atom.io/realtime\"\nimport { storageSync } from \"atom.io/web\"\n\nexport const mySocketKeyAtom: AtomIO.RegularAtomToken<SocketKey | undefined> =\n\tAtomIO.atom<SocketKey | undefined>({\n\t\tkey: `mySocketKey`,\n\t\tdefault: undefined,\n\t})\n\nexport const myUserKeyAtom: AtomIO.RegularAtomToken<UserKey | null> =\n\tAtomIO.atom<UserKey | null>({\n\t\tkey: `myUserKey`,\n\t\tdefault: null,\n\t\teffects: [storageSync(globalThis.localStorage, JSON, `myUserKey`)],\n\t})\n","import * as AtomIO from \"atom.io\"\n\nexport const optimisticUpdateQueueAtom: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n> = AtomIO.atom<AtomIO.TransactionOutcomeEvent<any>[]>({\n\tkey: `optimisticUpdateQueue`,\n\tdefault: () => [],\n})\n\nexport const confirmedUpdateQueueAtom: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n> = AtomIO.atom<AtomIO.TransactionOutcomeEvent<any>[]>({\n\tkey: `confirmedUpdateQueue`,\n\tdefault: () => [],\n})\n","import type * as AtomIO from \"atom.io\"\nimport type { Fn, RootStore } from \"atom.io/internal\"\nimport {\n\tactUponStore,\n\tgetEpochNumberOfContinuity,\n\tingestTransactionOutcomeEvent,\n\tsetEpochNumberOfContinuity,\n\tsetIntoStore,\n} from \"atom.io/internal\"\nimport type { Socket } from \"atom.io/realtime\"\n\nimport {\n\tconfirmedUpdateQueueAtom,\n\toptimisticUpdateQueueAtom,\n} from \"../realtime-client-stores\"\n\nexport const useRegisterAndAttemptConfirmedUpdate =\n\t(\n\t\tstore: RootStore,\n\t\tcontinuityKey: string,\n\t\tsocket: Socket,\n\t\toptimisticUpdates: readonly AtomIO.TransactionOutcomeEvent<\n\t\t\tAtomIO.TransactionToken<Fn>\n\t\t>[],\n\t\tconfirmedUpdates: readonly AtomIO.TransactionOutcomeEvent<\n\t\t\tAtomIO.TransactionToken<Fn>\n\t\t>[],\n\t) =>\n\t(\n\t\tconfirmed: AtomIO.TransactionOutcomeEvent<AtomIO.TransactionToken<Fn>>,\n\t): void => {\n\t\tfunction reconcileEpoch(\n\t\t\toptimisticUpdate: AtomIO.TransactionOutcomeEvent<\n\t\t\t\tAtomIO.TransactionToken<Fn>\n\t\t\t>,\n\t\t\tconfirmedUpdate: AtomIO.TransactionOutcomeEvent<\n\t\t\t\tAtomIO.TransactionToken<Fn>\n\t\t\t>,\n\t\t): void {\n\t\t\tstore.logger.info(\n\t\t\t\t`🧑⚖️`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`reconciling updates`,\n\t\t\t)\n\t\t\tsetIntoStore(store, optimisticUpdateQueueAtom, (queue) => {\n\t\t\t\tqueue.shift()\n\t\t\t\treturn queue\n\t\t\t})\n\t\t\tif (optimisticUpdate.id === confirmedUpdate.id) {\n\t\t\t\tconst clientResult = JSON.stringify(optimisticUpdate.subEvents)\n\t\t\t\tconst serverResult = JSON.stringify(confirmedUpdate.subEvents)\n\t\t\t\tif (clientResult === serverResult) {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`✅`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`results for ${optimisticUpdate.id} match between client and server`,\n\t\t\t\t\t)\n\t\t\t\t\tsocket.emit(`ack:${continuityKey}`, confirmedUpdate.epoch)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// id mismatch\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`❌`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`thought update #${confirmedUpdate.epoch} was ${optimisticUpdate.token.key}:${optimisticUpdate.id}, but it was actually ${confirmedUpdate.token.key}:${confirmedUpdate.id}`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tstore.logger.info(\n\t\t\t\t`🧑⚖️`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`updates do not match`,\n\t\t\t\toptimisticUpdate,\n\t\t\t\tconfirmedUpdate,\n\t\t\t)\n\t\t\tconst reversedOptimisticUpdates = optimisticUpdates.toReversed()\n\t\t\tfor (const subsequentOptimistic of reversedOptimisticUpdates) {\n\t\t\t\tingestTransactionOutcomeEvent(store, subsequentOptimistic, `oldValue`)\n\t\t\t}\n\t\t\tstore.logger.info(\n\t\t\t\t`⏪`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`undid optimistic updates:`,\n\t\t\t\treversedOptimisticUpdates,\n\t\t\t)\n\t\t\tingestTransactionOutcomeEvent(store, optimisticUpdate, `oldValue`)\n\t\t\tstore.logger.info(\n\t\t\t\t`⏪`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`undid zeroth optimistic update`,\n\t\t\t\toptimisticUpdate,\n\t\t\t)\n\t\t\tingestTransactionOutcomeEvent(store, confirmedUpdate, `newValue`)\n\t\t\tstore.logger.info(\n\t\t\t\t`⏩`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`applied confirmed update`,\n\t\t\t\tconfirmedUpdate,\n\t\t\t)\n\t\t\tsocket.emit(`ack:${continuityKey}`, confirmedUpdate.epoch)\n\n\t\t\tfor (const subsequentOptimistic of optimisticUpdates) {\n\t\t\t\tconst token = {\n\t\t\t\t\ttype: `transaction`,\n\t\t\t\t\tkey: subsequentOptimistic.token.key,\n\t\t\t\t} as const\n\t\t\t\tconst { id, params } = subsequentOptimistic\n\t\t\t\tactUponStore(store, token, id)(...params)\n\t\t\t}\n\t\t\tstore.logger.info(\n\t\t\t\t`⏩`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`reapplied subsequent optimistic updates:`,\n\t\t\t\toptimisticUpdates,\n\t\t\t)\n\t\t}\n\n\t\tstore.logger.info(\n\t\t\t`🧑⚖️`,\n\t\t\t`continuity`,\n\t\t\tcontinuityKey,\n\t\t\t`integrating confirmed update`,\n\t\t\t{ confirmedUpdate: confirmed, confirmedUpdates, optimisticUpdates },\n\t\t)\n\t\tconst zerothOptimisticUpdate = optimisticUpdates[0]\n\t\tif (zerothOptimisticUpdate) {\n\t\t\tstore.logger.info(\n\t\t\t\t`🧑⚖️`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`has optimistic updates to reconcile`,\n\t\t\t)\n\t\t\tif (confirmed.epoch === zerothOptimisticUpdate.epoch) {\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`🧑⚖️`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`epoch of confirmed update #${confirmed.epoch} matches zeroth optimistic update`,\n\t\t\t\t)\n\t\t\t\treconcileEpoch(zerothOptimisticUpdate, confirmed)\n\t\t\t\tfor (const nextConfirmed of confirmedUpdates) {\n\t\t\t\t\tconst nextOptimistic = optimisticUpdates[0]\n\t\t\t\t\tif (nextConfirmed.epoch === nextOptimistic?.epoch) {\n\t\t\t\t\t\treconcileEpoch(nextOptimistic, nextConfirmed)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// epoch mismatch\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`🧑⚖️`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`epoch of confirmed update #${confirmed.epoch} does not match zeroth optimistic update #${zerothOptimisticUpdate.epoch}`,\n\t\t\t\t)\n\t\t\t\tconst confirmedUpdateIsAlreadyEnqueued = confirmedUpdates.some(\n\t\t\t\t\t(update) => update.epoch === confirmed.epoch,\n\t\t\t\t)\n\t\t\t\tif (!confirmedUpdateIsAlreadyEnqueued) {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`👈`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`pushing confirmed update to queue`,\n\t\t\t\t\t\tconfirmed,\n\t\t\t\t\t)\n\t\t\t\t\tsetIntoStore(store, confirmedUpdateQueueAtom, (queue) => {\n\t\t\t\t\t\tqueue.push(confirmed)\n\t\t\t\t\t\tqueue.sort((a, b) => a.epoch - b.epoch)\n\t\t\t\t\t\treturn queue\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tstore.logger.info(\n\t\t\t\t`🧑⚖️`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`has no optimistic updates to deal with`,\n\t\t\t)\n\t\t\tlet continuityEpoch: number | undefined\n\t\t\tcontinuityEpoch = getEpochNumberOfContinuity(store, continuityKey)\n\n\t\t\tif (continuityEpoch === confirmed.epoch - 1) {\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`✅`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`integrating update #${confirmed.epoch} (${confirmed.token.key} ${confirmed.id})`,\n\t\t\t\t)\n\t\t\t\tingestTransactionOutcomeEvent(store, confirmed, `newValue`)\n\t\t\t\tsocket.emit(`ack:${continuityKey}`, confirmed.epoch)\n\t\t\t\tsetEpochNumberOfContinuity(store, continuityKey, confirmed.epoch)\n\t\t\t} else if (continuityEpoch !== undefined) {\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`🧑⚖️`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`received update #${confirmed.epoch} but still waiting for update #${\n\t\t\t\t\t\tcontinuityEpoch + 1\n\t\t\t\t\t}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tclientEpoch: continuityEpoch,\n\t\t\t\t\t\tserverEpoch: confirmed.epoch,\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\tconst confirmedUpdateIsAlreadyEnqueued = confirmedUpdates.some(\n\t\t\t\t\t(update) => update.epoch === confirmed.epoch,\n\t\t\t\t)\n\t\t\t\tif (confirmedUpdateIsAlreadyEnqueued) {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`👍`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`confirmed update #${confirmed.epoch} is already enqueued`,\n\t\t\t\t\t)\n\t\t\t\t} else {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`👈`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`pushing confirmed update #${confirmed.epoch} to queue`,\n\t\t\t\t\t)\n\t\t\t\t\tsetIntoStore(store, confirmedUpdateQueueAtom, (queue) => {\n\t\t\t\t\t\tqueue.push(confirmed)\n\t\t\t\t\t\tqueue.sort((a, b) => a.epoch - b.epoch)\n\t\t\t\t\t\treturn queue\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n","import type { AtomToken } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { disposeAtom } from \"atom.io/internal\"\n\nexport function useConcealState(store: Store) {\n\treturn (concealed: AtomToken<unknown>[]): void => {\n\t\tfor (const token of concealed) {\n\t\t\tdisposeAtom(store, token)\n\t\t}\n\t}\n}\n","import { setIntoStore, type Store } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\n\nexport function useRevealState(store: Store) {\n\treturn (revealed: Json.Array): void => {\n\t\tlet i = 0\n\t\tlet k: any\n\t\tlet v: any\n\t\tfor (const x of revealed) {\n\t\t\tif (i % 2 === 0) {\n\t\t\t\tk = x\n\t\t\t} else {\n\t\t\t\tv = x\n\t\t\t\tsetIntoStore(store, k, v)\n\t\t\t}\n\t\t\ti++\n\t\t}\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport { setIntoStore, type Store } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { Socket } from \"socket.io-client\"\n\nexport function pullAtom<J extends Json.Serializable>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: AtomIO.RegularAtomToken<J, any, any>,\n): () => void {\n\tconst setServedValue = (data: J) => {\n\t\tsetIntoStore(store, token, data)\n\t}\n\tsocket.on(`serve:${token.key}`, setServedValue)\n\tsocket.emit(`sub:${token.key}`)\n\treturn () => {\n\t\tsocket.off(`serve:${token.key}`, setServedValue)\n\t\tsocket.emit(`unsub:${token.key}`)\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport { findInStore, setIntoStore, type Store } from \"atom.io/internal\"\nimport type { Canonical, Json } from \"atom.io/json\"\nimport type { Socket } from \"socket.io-client\"\n\nexport function pullAtomFamilyMember<\n\tJ extends Json.Serializable,\n\tK extends Canonical,\n>(\n\tstore: Store,\n\tsocket: Socket,\n\tfamily: AtomIO.AtomFamilyToken<J, K, any>,\n\tkey: NoInfer<K>,\n): () => void {\n\tconst token = findInStore(store, family, key)\n\tconst setServedValue = (data: J) => {\n\t\tsetIntoStore(store, token, data)\n\t}\n\tsocket?.on(`serve:${token.key}`, setServedValue)\n\tsocket?.emit(`sub:${family.key}`, key)\n\treturn () => {\n\t\tsocket?.off(`serve:${token.key}`, setServedValue)\n\t\tsocket?.emit(`unsub:${token.key}`)\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { AsJSON, SignalFrom, Store, Transceiver } from \"atom.io/internal\"\nimport { getJsonToken, getUpdateToken, setIntoStore } from \"atom.io/internal\"\nimport type { Socket } from \"socket.io-client\"\n\nexport function pullMutableAtom<T extends Transceiver<any, any, any>>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: AtomIO.MutableAtomToken<T>,\n): () => void {\n\tconst jsonToken = getJsonToken(store, token)\n\tconst updateToken = getUpdateToken(token)\n\tsocket.on(`init:${token.key}`, (data: AsJSON<T>) => {\n\t\tsetIntoStore(store, jsonToken, data)\n\t})\n\tsocket.on(`next:${token.key}`, (data: SignalFrom<T>) => {\n\t\tsetIntoStore(store, updateToken, data)\n\t})\n\tsocket.emit(`sub:${token.key}`)\n\treturn () => {\n\t\tsocket.off(`init:${token.key}`)\n\t\tsocket.off(`next:${token.key}`)\n\t\tsocket.emit(`unsub:${token.key}`)\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { AsJSON, SignalFrom, Store, Transceiver } from \"atom.io/internal\"\nimport {\n\tfindInStore,\n\tgetJsonToken,\n\tgetUpdateToken,\n\tsetIntoStore,\n} from \"atom.io/internal\"\nimport type { Canonical } from \"atom.io/json\"\nimport type { Socket } from \"socket.io-client\"\n\nexport function pullMutableAtomFamilyMember<\n\tT extends Transceiver<any, any, any>,\n\tK extends Canonical,\n>(\n\tstore: Store,\n\tsocket: Socket,\n\tfamily: AtomIO.MutableAtomFamilyToken<T, K>,\n\tkey: NoInfer<K>,\n): () => void {\n\tconst token = findInStore(store, family, key)\n\tsocket.on(`init:${token.key}`, (data: AsJSON<T>) => {\n\t\tconst jsonToken = getJsonToken(store, token)\n\t\tsetIntoStore(store, jsonToken, data)\n\t})\n\tsocket.on(`next:${token.key}`, (data: SignalFrom<T>) => {\n\t\tconst trackerToken = getUpdateToken(token)\n\t\tsetIntoStore(store, trackerToken, data)\n\t})\n\tsocket.emit(`sub:${family.key}`, key)\n\treturn () => {\n\t\tsocket.off(`serve:${token.key}`)\n\t\tsocket.emit(`unsub:${token.key}`)\n\t}\n}\n","import type { AtomToken, SelectorToken } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { getFamilyOfToken, subscribeToState } from \"atom.io/internal\"\nimport { parseJson } from \"atom.io/json\"\nimport type { Socket } from \"socket.io-client\"\n\nimport { pullAtom } from \"./pull-atom\"\nimport { pullAtomFamilyMember } from \"./pull-atom-family-member\"\nimport { pullMutableAtom } from \"./pull-mutable-atom\"\nimport { pullMutableAtomFamilyMember } from \"./pull-mutable-atom-family-member\"\n\nexport function pullSelectorRoots(\n\tstore: Store,\n\tsocket: Socket,\n\tselectorToken: SelectorToken<any>,\n): () => void {\n\tconst atomSubscriptions = new Map<string, () => void>()\n\tconst clearAtomSubscriptions = () => {\n\t\tfor (const [, unsub] of atomSubscriptions) unsub()\n\t\tatomSubscriptions.clear()\n\t}\n\n\tconst start = () => {\n\t\tconst atomKeys = store.selectorAtoms.getRelatedKeys(selectorToken.key)\n\t\tif (atomKeys) {\n\t\t\tfor (const [atomKey, unsub] of atomSubscriptions) {\n\t\t\t\tif (!atomKeys.has(atomKey)) {\n\t\t\t\t\tunsub()\n\t\t\t\t\tatomSubscriptions.delete(atomKey)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const atomKey of atomKeys) {\n\t\t\t\tif (atomSubscriptions.has(atomKey)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst atom = store.atoms.get(atomKey) as AtomToken<any, any>\n\t\t\t\tswitch (atom.type) {\n\t\t\t\t\tcase `atom`: {\n\t\t\t\t\t\tif (atom.family) {\n\t\t\t\t\t\t\tconst { subKey: serializedSubKey } = atom.family\n\t\t\t\t\t\t\tconst subKey = parseJson(serializedSubKey)\n\t\t\t\t\t\t\tconst family = getFamilyOfToken(store, atom)\n\t\t\t\t\t\t\tatomSubscriptions.set(\n\t\t\t\t\t\t\t\tatomKey,\n\t\t\t\t\t\t\t\tpullAtomFamilyMember(store, socket, family, subKey),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tatomSubscriptions.set(atomKey, pullAtom(store, socket, atom))\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase `mutable_atom`: {\n\t\t\t\t\t\tif (atom.family) {\n\t\t\t\t\t\t\tconst { subKey: serializedSubKey } = atom.family\n\t\t\t\t\t\t\tconst subKey = parseJson(serializedSubKey)\n\t\t\t\t\t\t\tconst family = getFamilyOfToken(store, atom)\n\t\t\t\t\t\t\tatomSubscriptions.set(\n\t\t\t\t\t\t\t\tatomKey,\n\t\t\t\t\t\t\t\tpullMutableAtomFamilyMember(store, socket, family, subKey),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tatomSubscriptions.set(\n\t\t\t\t\t\t\t\tatomKey,\n\t\t\t\t\t\t\t\tpullMutableAtom(store, socket, atom),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tconst unsubFromSelector = subscribeToState(\n\t\tstore,\n\t\tselectorToken,\n\t\t`pull-watches-dependencies`,\n\t\t() => {\n\t\t\tstart()\n\t\t},\n\t)\n\n\tstart()\n\n\treturn () => {\n\t\tclearAtomSubscriptions()\n\t\tunsubFromSelector()\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport type { Socket } from \"socket.io-client\"\n\nimport { pullSelectorRoots } from \"./pull-selector-roots\"\n\nexport function pullSelector<T>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: AtomIO.SelectorToken<T>,\n): () => void {\n\treturn pullSelectorRoots(store, socket, token)\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { findInStore } from \"atom.io/internal\"\nimport type { Canonical } from \"atom.io/json\"\nimport type { Socket } from \"socket.io-client\"\n\nimport { pullSelectorRoots } from \"./pull-selector-roots\"\n\nexport function pullSelectorFamilyMember<T, K extends Canonical>(\n\tstore: Store,\n\tsocket: Socket,\n\tfamilyToken: AtomIO.SelectorFamilyToken<T, K>,\n\tkey: NoInfer<K>,\n): () => void {\n\tconst token = findInStore(store, familyToken, key)\n\treturn pullSelectorRoots(store, socket, token)\n}\n","import type { WritableToken } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { setIntoStore, subscribeToState } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport { employSocket, mutexAtoms } from \"atom.io/realtime\"\nimport type { Socket } from \"socket.io-client\"\n\nexport function pushState<J extends Json.Serializable>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: WritableToken<J>,\n): () => void {\n\tconst publish = (newValue: J) => {\n\t\tsocket.emit(`pub:${token.key}`, newValue)\n\t}\n\n\tconst subscriptions = new Set<() => void>()\n\tconst clearSubscriptions = () => {\n\t\tfor (const unsub of subscriptions) unsub()\n\t\tsubscriptions.clear()\n\t}\n\n\tconst init = () => {\n\t\tsubscriptions.add(\n\t\t\temploySocket(socket, `claim-result:${token.key}`, (success: boolean) => {\n\t\t\t\tif (!success) return\n\n\t\t\t\tclearSubscriptions()\n\t\t\t\tsetIntoStore(store, mutexAtoms, token.key, true)\n\t\t\t\tsubscriptions.add(\n\t\t\t\t\tsubscribeToState(store, token, `push`, ({ newValue }) => {\n\t\t\t\t\t\tpublish(newValue)\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t}),\n\t\t)\n\n\t\tsocket.emit(`claim:${token.key}`)\n\t}\n\n\tinit()\n\n\treturn () => {\n\t\tclearSubscriptions()\n\t\tsocket.emit(`unclaim:${token.key}`)\n\t}\n}\n","import type { RootStore } from \"atom.io/internal\"\nimport {\n\tassignTransactionToContinuity,\n\tgetFromStore,\n\tgetJsonToken,\n\tsetEpochNumberOfContinuity,\n\tsetIntoStore,\n\tsubscribeToTransaction,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { ContinuityToken } from \"atom.io/realtime\"\nimport type { Socket } from \"socket.io-client\"\n\nimport { useRegisterAndAttemptConfirmedUpdate } from \"./continuity/register-and-attempt-confirmed-update\"\nimport { useConcealState } from \"./continuity/use-conceal-state\"\nimport { useRevealState } from \"./continuity/use-reveal-state\"\nimport {\n\tconfirmedUpdateQueueAtom,\n\toptimisticUpdateQueueAtom,\n} from \"./realtime-client-stores\"\n\nexport function syncContinuity(\n\tstore: RootStore,\n\tsocket: Socket,\n\tcontinuity: ContinuityToken,\n): () => void {\n\tconst continuityKey = continuity.key\n\tconst optimisticUpdates = getFromStore(store, optimisticUpdateQueueAtom)\n\tconst confirmedUpdates = getFromStore(store, confirmedUpdateQueueAtom)\n\n\tconst initializeContinuity = (epoch: number, payload: Json.Array) => {\n\t\tsocket.off(`continuity-init:${continuityKey}`, initializeContinuity)\n\t\tlet i = 0\n\t\tlet k: any\n\t\tlet v: any\n\t\tfor (const x of payload) {\n\t\t\tif (i % 2 === 0) {\n\t\t\t\tk = x\n\t\t\t} else {\n\t\t\t\tv = x\n\t\t\t\tif (`type` in k && k.type === `mutable_atom`) {\n\t\t\t\t\tk = getJsonToken(store, k)\n\t\t\t\t}\n\t\t\t\tsetIntoStore(store, k, v)\n\t\t\t}\n\t\t\ti++\n\t\t}\n\t\tsetEpochNumberOfContinuity(store, continuityKey, epoch)\n\t}\n\tsocket.off(`continuity-init:${continuityKey}`)\n\tsocket.on(`continuity-init:${continuityKey}`, initializeContinuity)\n\n\tconst registerAndAttemptConfirmedUpdate = useRegisterAndAttemptConfirmedUpdate(\n\t\tstore,\n\t\tcontinuityKey,\n\t\tsocket,\n\t\toptimisticUpdates,\n\t\tconfirmedUpdates,\n\t)\n\tsocket.off(`tx-new:${continuityKey}`)\n\tsocket.on(`tx-new:${continuityKey}`, registerAndAttemptConfirmedUpdate)\n\n\tconst unsubscribeFunctions = continuity.actions.map((transaction) => {\n\t\tassignTransactionToContinuity(store, continuityKey, transaction.key)\n\t\tconst unsubscribeFromTransactionUpdates = subscribeToTransaction(\n\t\t\tstore,\n\t\t\ttransaction,\n\t\t\t`tx-run:${continuityKey}`,\n\t\t\t(clientUpdate) => {\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`🤞`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`enqueuing optimistic update`,\n\t\t\t\t)\n\t\t\t\tconst optimisticUpdateIndex = optimisticUpdates.findIndex(\n\t\t\t\t\t(update) => update.id === clientUpdate.id,\n\t\t\t\t)\n\t\t\t\tif (optimisticUpdateIndex === -1) {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`🤞`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`enqueuing new optimistic update`,\n\t\t\t\t\t)\n\t\t\t\t\tsetIntoStore(store, optimisticUpdateQueueAtom, (queue) => {\n\t\t\t\t\t\tqueue.push(clientUpdate)\n\t\t\t\t\t\tqueue.sort((a, b) => a.epoch - b.epoch)\n\t\t\t\t\t\treturn queue\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`🤞`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`replacing existing optimistic update at index ${optimisticUpdateIndex}`,\n\t\t\t\t\t)\n\t\t\t\t\tsetIntoStore(store, optimisticUpdateQueueAtom, (queue) => {\n\t\t\t\t\t\tqueue[optimisticUpdateIndex] = clientUpdate\n\t\t\t\t\t\treturn queue\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tsocket.emit(`tx-run:${continuityKey}`, {\n\t\t\t\t\tid: clientUpdate.id,\n\t\t\t\t\ttoken: transaction,\n\t\t\t\t\tparams: clientUpdate.params,\n\t\t\t\t})\n\t\t\t},\n\t\t)\n\t\treturn unsubscribeFromTransactionUpdates\n\t})\n\n\tconst revealState = useRevealState(store)\n\tconst concealState = useConcealState(store)\n\tsocket.on(`reveal:${continuityKey}`, revealState)\n\tsocket.on(`conceal:${continuityKey}`, concealState)\n\n\tsocket.emit(`get:${continuityKey}`)\n\treturn () => {\n\t\tsocket.off(`continuity-init:${continuityKey}`)\n\t\tsocket.off(`tx-new:${continuityKey}`)\n\t\tfor (const unsubscribe of unsubscribeFunctions) unsubscribe()\n\t\t// socket.emit(`unsub:${continuityKey}`)\n\t}\n}\n"],"mappings":";;;;;;;AAIA,MAAaA,kBACZ,OAAO,KAA4B;CAClC,KAAK;CACL,SAA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AAG,mBAAmB,iBAAiB,qBAAqB;CAEnE,MAAM,oCAAoC,qCACzC,OACA,eACA,QACA,mBACA,iBACA;AACD,QAAO,IAAI,UAAU,gBAAgB;AACrC,QAAO,GAAG,UAAU,iBAAiB,kCAAkC;CAEvE,MAAM,uBAAuB,WAAW,QAAQ,KAAK,gBAAgB;AACpE,gCAA8B,OAAO,eAAe,YAAY,IAAI;AA8CpE,SA7C0C,uBACzC,OACA,aACA,UAAU,kBACT,iBAAiB;AACjB,SAAM,OAAO,KACZ,MACA,cACA,eACA,8BACA;GACD,MAAM,wBAAwB,kBAAkB,WAC9C,WAAW,OAAO,OAAO,aAAa,GACvC;AACD,OAAI,0BAA0B,IAAI;AACjC,UAAM,OAAO,KACZ,MACA,cACA,eACA,kCACA;AACD,iBAAa,OAAO,4BAA4B,UAAU;AACzD,WAAM,KAAK,aAAa;AACxB,WAAM,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,MAAM;AACvC,YAAO;MACN;UACI;AACN,UAAM,OAAO,KACZ,MACA,cACA,eACA,iDAAiD,wBACjD;AACD,iBAAa,OAAO,4BAA4B,UAAU;AACzD,WAAM,yBAAyB;AAC/B,YAAO;MACN;;AAEH,UAAO,KAAK,UAAU,iBAAiB;IACtC,IAAI,aAAa;IACjB,OAAO;IACP,QAAQ,aAAa;IACrB,CAAC;IAEH;GAEA;CAEF,MAAM,cAAc,eAAe,MAAM;CACzC,MAAM,eAAe,gBAAgB,MAAM;AAC3C,QAAO,GAAG,UAAU,iBAAiB,YAAY;AACjD,QAAO,GAAG,WAAW,iBAAiB,aAAa;AAEnD,QAAO,KAAK,OAAO,gBAAgB;AACnC,cAAa;AACZ,SAAO,IAAI,mBAAmB,gBAAgB;AAC9C,SAAO,IAAI,UAAU,gBAAgB;AACrC,OAAK,MAAM,eAAe,qBAAsB,cAAa"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["mySocketKeyAtom: AtomIO.RegularAtomToken<SocketKey | undefined>","myUserKeyAtom: AtomIO.RegularAtomToken<UserKey | null>","myRoomKeyAtom: AtomIO.RegularAtomToken<RoomKey | null>","optimisticUpdateQueueAtom: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n>","confirmedUpdateQueueAtom: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n>","continuityEpoch: number | undefined","k: any","v: any","k: any","v: any"],"sources":["../../src/realtime-client/realtime-client-stores/client-main-store.ts","../../src/realtime-client/realtime-client-stores/client-sync-store.ts","../../src/realtime-client/continuity/register-and-attempt-confirmed-update.ts","../../src/realtime-client/continuity/use-conceal-state.ts","../../src/realtime-client/continuity/use-reveal-state.ts","../../src/realtime-client/pull-atom.ts","../../src/realtime-client/pull-atom-family-member.ts","../../src/realtime-client/pull-mutable-atom.ts","../../src/realtime-client/pull-mutable-atom-family-member.ts","../../src/realtime-client/pull-selector-roots.ts","../../src/realtime-client/pull-selector.ts","../../src/realtime-client/pull-selector-family-member.ts","../../src/realtime-client/push-state.ts","../../src/realtime-client/sync-continuity.ts"],"sourcesContent":["import * as AtomIO from \"atom.io\"\nimport type { RoomKey, SocketKey, UserKey } from \"atom.io/realtime\"\n\nexport const mySocketKeyAtom: AtomIO.RegularAtomToken<SocketKey | undefined> =\n\tAtomIO.atom<SocketKey | undefined>({\n\t\tkey: `mySocketKey`,\n\t\tdefault: undefined,\n\t})\n\nexport const myUserKeyAtom: AtomIO.RegularAtomToken<UserKey | null> =\n\tAtomIO.atom<UserKey | null>({\n\t\tkey: `myUserKey`,\n\t\tdefault: null,\n\t\teffects: [\n\t\t\t(userKey) => {\n\t\t\t\tif (typeof window !== `undefined`) {\n\t\t\t\t\tvoid import(`atom.io/web`).then(({ storageSync }) => {\n\t\t\t\t\t\tstorageSync(globalThis.localStorage, JSON, `myUserKey`)(userKey)\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t},\n\t\t],\n\t})\n\nexport const myRoomKeyAtom: AtomIO.RegularAtomToken<RoomKey | null> =\n\tAtomIO.atom<RoomKey | null>({\n\t\tkey: `myRoomKey`,\n\t\tdefault: null,\n\t})\n","import * as AtomIO from \"atom.io\"\n\nexport const optimisticUpdateQueueAtom: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n> = AtomIO.atom<AtomIO.TransactionOutcomeEvent<any>[]>({\n\tkey: `optimisticUpdateQueue`,\n\tdefault: () => [],\n})\n\nexport const confirmedUpdateQueueAtom: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n> = AtomIO.atom<AtomIO.TransactionOutcomeEvent<any>[]>({\n\tkey: `confirmedUpdateQueue`,\n\tdefault: () => [],\n})\n","import type * as AtomIO from \"atom.io\"\nimport type { Fn, RootStore } from \"atom.io/internal\"\nimport {\n\tactUponStore,\n\tgetEpochNumberOfContinuity,\n\tingestTransactionOutcomeEvent,\n\tsetEpochNumberOfContinuity,\n\tsetIntoStore,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { Socket } from \"atom.io/realtime\"\n\nimport {\n\tconfirmedUpdateQueueAtom,\n\toptimisticUpdateQueueAtom,\n} from \"../realtime-client-stores\"\n\nexport const useRegisterAndAttemptConfirmedUpdate =\n\t(\n\t\tstore: RootStore,\n\t\tcontinuityKey: string,\n\t\tsocket: Socket,\n\t\toptimisticUpdates: readonly AtomIO.TransactionOutcomeEvent<\n\t\t\tAtomIO.TransactionToken<Fn>\n\t\t>[],\n\t\tconfirmedUpdates: readonly AtomIO.TransactionOutcomeEvent<\n\t\t\tAtomIO.TransactionToken<Fn>\n\t\t>[],\n\t) =>\n\t(\n\t\tconfirmed: AtomIO.TransactionOutcomeEvent<AtomIO.TransactionToken<Fn>> &\n\t\t\tJson.Serializable,\n\t): void => {\n\t\tfunction reconcileEpoch(\n\t\t\toptimisticUpdate: AtomIO.TransactionOutcomeEvent<\n\t\t\t\tAtomIO.TransactionToken<Fn>\n\t\t\t>,\n\t\t\tconfirmedUpdate: AtomIO.TransactionOutcomeEvent<\n\t\t\t\tAtomIO.TransactionToken<Fn>\n\t\t\t>,\n\t\t): void {\n\t\t\tstore.logger.info(\n\t\t\t\t`🧑⚖️`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`reconciling updates`,\n\t\t\t)\n\t\t\tsetIntoStore(store, optimisticUpdateQueueAtom, (queue) => {\n\t\t\t\tqueue.shift()\n\t\t\t\treturn queue\n\t\t\t})\n\t\t\tif (optimisticUpdate.id === confirmedUpdate.id) {\n\t\t\t\tconst clientResult = JSON.stringify(optimisticUpdate.subEvents)\n\t\t\t\tconst serverResult = JSON.stringify(confirmedUpdate.subEvents)\n\t\t\t\tif (clientResult === serverResult) {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`✅`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`results for ${optimisticUpdate.id} match between client and server`,\n\t\t\t\t\t)\n\t\t\t\t\tsocket.emit(`ack:${continuityKey}`, confirmedUpdate.epoch)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// id mismatch\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`❌`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`thought update #${confirmedUpdate.epoch} was ${optimisticUpdate.token.key}:${optimisticUpdate.id}, but it was actually ${confirmedUpdate.token.key}:${confirmedUpdate.id}`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tstore.logger.info(\n\t\t\t\t`🧑⚖️`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`updates do not match`,\n\t\t\t\toptimisticUpdate,\n\t\t\t\tconfirmedUpdate,\n\t\t\t)\n\t\t\tconst reversedOptimisticUpdates = optimisticUpdates.toReversed()\n\t\t\tfor (const subsequentOptimistic of reversedOptimisticUpdates) {\n\t\t\t\tingestTransactionOutcomeEvent(store, subsequentOptimistic, `oldValue`)\n\t\t\t}\n\t\t\tstore.logger.info(\n\t\t\t\t`⏪`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`undid optimistic updates:`,\n\t\t\t\treversedOptimisticUpdates,\n\t\t\t)\n\t\t\tingestTransactionOutcomeEvent(store, optimisticUpdate, `oldValue`)\n\t\t\tstore.logger.info(\n\t\t\t\t`⏪`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`undid zeroth optimistic update`,\n\t\t\t\toptimisticUpdate,\n\t\t\t)\n\t\t\tingestTransactionOutcomeEvent(store, confirmedUpdate, `newValue`)\n\t\t\tstore.logger.info(\n\t\t\t\t`⏩`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`applied confirmed update`,\n\t\t\t\tconfirmedUpdate,\n\t\t\t)\n\t\t\tsocket.emit(`ack:${continuityKey}`, confirmedUpdate.epoch)\n\n\t\t\tfor (const subsequentOptimistic of optimisticUpdates) {\n\t\t\t\tconst token = {\n\t\t\t\t\ttype: `transaction`,\n\t\t\t\t\tkey: subsequentOptimistic.token.key,\n\t\t\t\t} as const\n\t\t\t\tconst { id, params } = subsequentOptimistic\n\t\t\t\tactUponStore(store, token, id)(...params)\n\t\t\t}\n\t\t\tstore.logger.info(\n\t\t\t\t`⏩`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`reapplied subsequent optimistic updates:`,\n\t\t\t\toptimisticUpdates,\n\t\t\t)\n\t\t}\n\n\t\tstore.logger.info(\n\t\t\t`🧑⚖️`,\n\t\t\t`continuity`,\n\t\t\tcontinuityKey,\n\t\t\t`integrating confirmed update`,\n\t\t\t{ confirmedUpdate: confirmed, confirmedUpdates, optimisticUpdates },\n\t\t)\n\t\tconst zerothOptimisticUpdate = optimisticUpdates[0]\n\t\tif (zerothOptimisticUpdate) {\n\t\t\tstore.logger.info(\n\t\t\t\t`🧑⚖️`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`has optimistic updates to reconcile`,\n\t\t\t)\n\t\t\tif (confirmed.epoch === zerothOptimisticUpdate.epoch) {\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`🧑⚖️`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`epoch of confirmed update #${confirmed.epoch} matches zeroth optimistic update`,\n\t\t\t\t)\n\t\t\t\treconcileEpoch(zerothOptimisticUpdate, confirmed)\n\t\t\t\tfor (const nextConfirmed of confirmedUpdates) {\n\t\t\t\t\tconst nextOptimistic = optimisticUpdates[0]\n\t\t\t\t\tif (nextConfirmed.epoch === nextOptimistic?.epoch) {\n\t\t\t\t\t\treconcileEpoch(nextOptimistic, nextConfirmed)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// epoch mismatch\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`🧑⚖️`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`epoch of confirmed update #${confirmed.epoch} does not match zeroth optimistic update #${zerothOptimisticUpdate.epoch}`,\n\t\t\t\t)\n\t\t\t\tconst confirmedUpdateIsAlreadyEnqueued = confirmedUpdates.some(\n\t\t\t\t\t(update) => update.epoch === confirmed.epoch,\n\t\t\t\t)\n\t\t\t\tif (!confirmedUpdateIsAlreadyEnqueued) {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`👈`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`pushing confirmed update to queue`,\n\t\t\t\t\t\tconfirmed,\n\t\t\t\t\t)\n\t\t\t\t\tsetIntoStore(store, confirmedUpdateQueueAtom, (queue) => {\n\t\t\t\t\t\tqueue.push(confirmed)\n\t\t\t\t\t\tqueue.sort((a, b) => a.epoch - b.epoch)\n\t\t\t\t\t\treturn queue\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tstore.logger.info(\n\t\t\t\t`🧑⚖️`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`has no optimistic updates to deal with`,\n\t\t\t)\n\t\t\tlet continuityEpoch: number | undefined\n\t\t\tcontinuityEpoch = getEpochNumberOfContinuity(store, continuityKey)\n\n\t\t\tif (continuityEpoch === confirmed.epoch - 1) {\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`✅`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`integrating update #${confirmed.epoch} (${confirmed.token.key} ${confirmed.id})`,\n\t\t\t\t)\n\t\t\t\tingestTransactionOutcomeEvent(store, confirmed, `newValue`)\n\t\t\t\tsocket.emit(`ack:${continuityKey}`, confirmed.epoch)\n\t\t\t\tsetEpochNumberOfContinuity(store, continuityKey, confirmed.epoch)\n\t\t\t} else if (continuityEpoch !== undefined) {\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`🧑⚖️`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`received update #${confirmed.epoch} but still waiting for update #${\n\t\t\t\t\t\tcontinuityEpoch + 1\n\t\t\t\t\t}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tclientEpoch: continuityEpoch,\n\t\t\t\t\t\tserverEpoch: confirmed.epoch,\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\tconst confirmedUpdateIsAlreadyEnqueued = confirmedUpdates.some(\n\t\t\t\t\t(update) => update.epoch === confirmed.epoch,\n\t\t\t\t)\n\t\t\t\tif (confirmedUpdateIsAlreadyEnqueued) {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`👍`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`confirmed update #${confirmed.epoch} is already enqueued`,\n\t\t\t\t\t)\n\t\t\t\t} else {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`👈`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`pushing confirmed update #${confirmed.epoch} to queue`,\n\t\t\t\t\t)\n\t\t\t\t\tsetIntoStore(store, confirmedUpdateQueueAtom, (queue) => {\n\t\t\t\t\t\tqueue.push(confirmed)\n\t\t\t\t\t\tqueue.sort((a, b) => a.epoch - b.epoch)\n\t\t\t\t\t\treturn queue\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n","import type { AtomToken } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { disposeAtom } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\n\nexport function useConcealState(store: Store) {\n\treturn (concealed: AtomToken<Json.Serializable>[]): void => {\n\t\tfor (const token of concealed) {\n\t\t\tdisposeAtom(store, token)\n\t\t}\n\t}\n}\n","import { setIntoStore, type Store } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\n\nexport function useRevealState(store: Store) {\n\treturn (revealed: Json.Array): void => {\n\t\tlet i = 0\n\t\tlet k: any\n\t\tlet v: any\n\t\tfor (const x of revealed) {\n\t\t\tif (i % 2 === 0) {\n\t\t\t\tk = x\n\t\t\t} else {\n\t\t\t\tv = x\n\t\t\t\tsetIntoStore(store, k, v)\n\t\t\t}\n\t\t\ti++\n\t\t}\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport { setIntoStore, type Store } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { Socket } from \"atom.io/realtime\"\n\nexport function pullAtom<J extends Json.Serializable>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: AtomIO.RegularAtomToken<J, any, any>,\n): () => void {\n\tconst setServedValue = (data: J) => {\n\t\tsetIntoStore(store, token, data)\n\t}\n\tsocket.on(`serve:${token.key}`, setServedValue)\n\tsocket.emit(`sub:${token.key}`)\n\treturn () => {\n\t\tsocket.off(`serve:${token.key}`, setServedValue)\n\t\tsocket.emit(`unsub:${token.key}`)\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport { findInStore, setIntoStore, type Store } from \"atom.io/internal\"\nimport type { Canonical, Json } from \"atom.io/json\"\nimport type { Socket } from \"atom.io/realtime\"\n\nexport function pullAtomFamilyMember<\n\tJ extends Json.Serializable,\n\tK extends Canonical,\n>(\n\tstore: Store,\n\tsocket: Socket,\n\tfamily: AtomIO.AtomFamilyToken<J, K, any>,\n\tkey: NoInfer<K>,\n): () => void {\n\tconst token = findInStore(store, family, key)\n\tconst setServedValue = (data: J) => {\n\t\tsetIntoStore(store, token, data)\n\t}\n\tsocket?.on(`serve:${token.key}`, setServedValue)\n\tsocket?.emit(`sub:${family.key}`, key)\n\treturn () => {\n\t\tsocket?.off(`serve:${token.key}`, setServedValue)\n\t\tsocket?.emit(`unsub:${token.key}`)\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { AsJSON, SignalFrom, Store, Transceiver } from \"atom.io/internal\"\nimport { getJsonToken, getUpdateToken, setIntoStore } from \"atom.io/internal\"\nimport type { Socket } from \"atom.io/realtime\"\n\nexport function pullMutableAtom<T extends Transceiver<any, any, any>>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: AtomIO.MutableAtomToken<T>,\n): () => void {\n\tconst jsonToken = getJsonToken(store, token)\n\tconst updateToken = getUpdateToken(token)\n\tsocket.on(`init:${token.key}`, (data: AsJSON<T>) => {\n\t\tsetIntoStore(store, jsonToken, data)\n\t})\n\tsocket.on(`next:${token.key}`, (data: SignalFrom<T>) => {\n\t\tsetIntoStore(store, updateToken, data)\n\t})\n\tsocket.emit(`sub:${token.key}`)\n\treturn () => {\n\t\tsocket.off(`init:${token.key}`)\n\t\tsocket.off(`next:${token.key}`)\n\t\tsocket.emit(`unsub:${token.key}`)\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { AsJSON, SignalFrom, Store, Transceiver } from \"atom.io/internal\"\nimport {\n\tfindInStore,\n\tgetJsonToken,\n\tgetUpdateToken,\n\tsetIntoStore,\n} from \"atom.io/internal\"\nimport type { Canonical } from \"atom.io/json\"\nimport type { Socket } from \"atom.io/realtime\"\n\nexport function pullMutableAtomFamilyMember<\n\tT extends Transceiver<any, any, any>,\n\tK extends Canonical,\n>(\n\tstore: Store,\n\tsocket: Socket,\n\tfamily: AtomIO.MutableAtomFamilyToken<T, K>,\n\tkey: NoInfer<K>,\n): () => void {\n\tconst token = findInStore(store, family, key)\n\tsocket.on(`init:${token.key}`, (data: AsJSON<T>) => {\n\t\tconst jsonToken = getJsonToken(store, token)\n\t\tsetIntoStore(store, jsonToken, data)\n\t})\n\tsocket.on(`next:${token.key}`, (data: SignalFrom<T>) => {\n\t\tconst trackerToken = getUpdateToken(token)\n\t\tsetIntoStore(store, trackerToken, data)\n\t})\n\tsocket.emit(`sub:${family.key}`, key)\n\treturn () => {\n\t\tsocket.off(`serve:${token.key}`)\n\t\tsocket.emit(`unsub:${token.key}`)\n\t}\n}\n","import type { AtomToken, SelectorToken } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { getFamilyOfToken, subscribeToState } from \"atom.io/internal\"\nimport { parseJson } from \"atom.io/json\"\nimport type { Socket } from \"atom.io/realtime\"\n\nimport { pullAtom } from \"./pull-atom\"\nimport { pullAtomFamilyMember } from \"./pull-atom-family-member\"\nimport { pullMutableAtom } from \"./pull-mutable-atom\"\nimport { pullMutableAtomFamilyMember } from \"./pull-mutable-atom-family-member\"\n\nexport function pullSelectorRoots(\n\tstore: Store,\n\tsocket: Socket,\n\tselectorToken: SelectorToken<any>,\n): () => void {\n\tconst atomSubscriptions = new Map<string, () => void>()\n\tconst clearAtomSubscriptions = () => {\n\t\tfor (const [, unsub] of atomSubscriptions) unsub()\n\t\tatomSubscriptions.clear()\n\t}\n\n\tconst start = () => {\n\t\tconst atomKeys = store.selectorAtoms.getRelatedKeys(selectorToken.key)\n\t\tif (atomKeys) {\n\t\t\tfor (const [atomKey, unsub] of atomSubscriptions) {\n\t\t\t\tif (!atomKeys.has(atomKey)) {\n\t\t\t\t\tunsub()\n\t\t\t\t\tatomSubscriptions.delete(atomKey)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const atomKey of atomKeys) {\n\t\t\t\tif (atomSubscriptions.has(atomKey)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst atom = store.atoms.get(atomKey) as AtomToken<any, any>\n\t\t\t\tswitch (atom.type) {\n\t\t\t\t\tcase `atom`: {\n\t\t\t\t\t\tif (atom.family) {\n\t\t\t\t\t\t\tconst { subKey: serializedSubKey } = atom.family\n\t\t\t\t\t\t\tconst subKey = parseJson(serializedSubKey)\n\t\t\t\t\t\t\tconst family = getFamilyOfToken(store, atom)\n\t\t\t\t\t\t\tatomSubscriptions.set(\n\t\t\t\t\t\t\t\tatomKey,\n\t\t\t\t\t\t\t\tpullAtomFamilyMember(store, socket, family, subKey),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tatomSubscriptions.set(atomKey, pullAtom(store, socket, atom))\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase `mutable_atom`: {\n\t\t\t\t\t\tif (atom.family) {\n\t\t\t\t\t\t\tconst { subKey: serializedSubKey } = atom.family\n\t\t\t\t\t\t\tconst subKey = parseJson(serializedSubKey)\n\t\t\t\t\t\t\tconst family = getFamilyOfToken(store, atom)\n\t\t\t\t\t\t\tatomSubscriptions.set(\n\t\t\t\t\t\t\t\tatomKey,\n\t\t\t\t\t\t\t\tpullMutableAtomFamilyMember(store, socket, family, subKey),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tatomSubscriptions.set(\n\t\t\t\t\t\t\t\tatomKey,\n\t\t\t\t\t\t\t\tpullMutableAtom(store, socket, atom),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tconst unsubFromSelector = subscribeToState(\n\t\tstore,\n\t\tselectorToken,\n\t\t`pull-watches-dependencies`,\n\t\t() => {\n\t\t\tstart()\n\t\t},\n\t)\n\n\tstart()\n\n\treturn () => {\n\t\tclearAtomSubscriptions()\n\t\tunsubFromSelector()\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport type { Socket } from \"atom.io/realtime\"\n\nimport { pullSelectorRoots } from \"./pull-selector-roots\"\n\nexport function pullSelector<T>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: AtomIO.SelectorToken<T>,\n): () => void {\n\treturn pullSelectorRoots(store, socket, token)\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { findInStore } from \"atom.io/internal\"\nimport type { Canonical } from \"atom.io/json\"\nimport type { Socket } from \"atom.io/realtime\"\n\nimport { pullSelectorRoots } from \"./pull-selector-roots\"\n\nexport function pullSelectorFamilyMember<T, K extends Canonical>(\n\tstore: Store,\n\tsocket: Socket,\n\tfamilyToken: AtomIO.SelectorFamilyToken<T, K>,\n\tkey: NoInfer<K>,\n): () => void {\n\tconst token = findInStore(store, familyToken, key)\n\treturn pullSelectorRoots(store, socket, token)\n}\n","import type { WritableToken } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { setIntoStore, subscribeToState } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { Socket } from \"atom.io/realtime\"\nimport { employSocket, mutexAtoms } from \"atom.io/realtime\"\n\nexport function pushState<J extends Json.Serializable>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: WritableToken<J>,\n): () => void {\n\tconst publish = (newValue: J) => {\n\t\tsocket.emit(`pub:${token.key}`, newValue)\n\t}\n\n\tconst subscriptions = new Set<() => void>()\n\tconst clearSubscriptions = () => {\n\t\tfor (const unsub of subscriptions) unsub()\n\t\tsubscriptions.clear()\n\t}\n\n\tconst init = () => {\n\t\tsubscriptions.add(\n\t\t\temploySocket(socket, `claim-result:${token.key}`, (success: boolean) => {\n\t\t\t\tif (!success) return\n\n\t\t\t\tclearSubscriptions()\n\t\t\t\tsetIntoStore(store, mutexAtoms, token.key, true)\n\t\t\t\tsubscriptions.add(\n\t\t\t\t\tsubscribeToState(store, token, `push`, ({ newValue }) => {\n\t\t\t\t\t\tpublish(newValue)\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t}),\n\t\t)\n\n\t\tsocket.emit(`claim:${token.key}`)\n\t}\n\n\tinit()\n\n\treturn () => {\n\t\tclearSubscriptions()\n\t\tsocket.emit(`unclaim:${token.key}`)\n\t}\n}\n","import type { RootStore } from \"atom.io/internal\"\nimport {\n\tassignTransactionToContinuity,\n\tgetFromStore,\n\tgetJsonToken,\n\tsetEpochNumberOfContinuity,\n\tsetIntoStore,\n\tsubscribeToTransaction,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { ContinuityToken, Socket } from \"atom.io/realtime\"\n\nimport { useRegisterAndAttemptConfirmedUpdate } from \"./continuity/register-and-attempt-confirmed-update\"\nimport { useConcealState } from \"./continuity/use-conceal-state\"\nimport { useRevealState } from \"./continuity/use-reveal-state\"\nimport {\n\tconfirmedUpdateQueueAtom,\n\toptimisticUpdateQueueAtom,\n} from \"./realtime-client-stores\"\n\nexport function syncContinuity(\n\tstore: RootStore,\n\tsocket: Socket,\n\tcontinuity: ContinuityToken,\n): () => void {\n\tconst continuityKey = continuity.key\n\tconst optimisticUpdates = getFromStore(store, optimisticUpdateQueueAtom)\n\tconst confirmedUpdates = getFromStore(store, confirmedUpdateQueueAtom)\n\n\tconst initializeContinuity = (epoch: number, payload: Json.Array) => {\n\t\tsocket.off(`continuity-init:${continuityKey}`, initializeContinuity)\n\t\tlet i = 0\n\t\tlet k: any\n\t\tlet v: any\n\t\tfor (const x of payload) {\n\t\t\tif (i % 2 === 0) {\n\t\t\t\tk = x\n\t\t\t} else {\n\t\t\t\tv = x\n\t\t\t\tif (`type` in k && k.type === `mutable_atom`) {\n\t\t\t\t\tk = getJsonToken(store, k)\n\t\t\t\t}\n\t\t\t\tsetIntoStore(store, k, v)\n\t\t\t}\n\t\t\ti++\n\t\t}\n\t\tsetEpochNumberOfContinuity(store, continuityKey, epoch)\n\t}\n\tsocket.off(`continuity-init:${continuityKey}`)\n\tsocket.on(`continuity-init:${continuityKey}`, initializeContinuity)\n\n\tconst registerAndAttemptConfirmedUpdate = useRegisterAndAttemptConfirmedUpdate(\n\t\tstore,\n\t\tcontinuityKey,\n\t\tsocket,\n\t\toptimisticUpdates,\n\t\tconfirmedUpdates,\n\t)\n\tsocket.off(`tx-new:${continuityKey}`)\n\tsocket.on(`tx-new:${continuityKey}`, registerAndAttemptConfirmedUpdate)\n\n\tconst unsubscribeFunctions = continuity.actions.map((transaction) => {\n\t\tassignTransactionToContinuity(store, continuityKey, transaction.key)\n\t\tconst unsubscribeFromTransactionUpdates = subscribeToTransaction(\n\t\t\tstore,\n\t\t\ttransaction,\n\t\t\t`tx-run:${continuityKey}`,\n\t\t\t(clientUpdate) => {\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`🤞`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`enqueuing optimistic update`,\n\t\t\t\t)\n\t\t\t\tconst optimisticUpdateIndex = optimisticUpdates.findIndex(\n\t\t\t\t\t(update) => update.id === clientUpdate.id,\n\t\t\t\t)\n\t\t\t\tif (optimisticUpdateIndex === -1) {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`🤞`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`enqueuing new optimistic update`,\n\t\t\t\t\t)\n\t\t\t\t\tsetIntoStore(store, optimisticUpdateQueueAtom, (queue) => {\n\t\t\t\t\t\tqueue.push(clientUpdate)\n\t\t\t\t\t\tqueue.sort((a, b) => a.epoch - b.epoch)\n\t\t\t\t\t\treturn queue\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`🤞`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`replacing existing optimistic update at index ${optimisticUpdateIndex}`,\n\t\t\t\t\t)\n\t\t\t\t\tsetIntoStore(store, optimisticUpdateQueueAtom, (queue) => {\n\t\t\t\t\t\tqueue[optimisticUpdateIndex] = clientUpdate\n\t\t\t\t\t\treturn queue\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tsocket.emit(`tx-run:${continuityKey}`, {\n\t\t\t\t\tid: clientUpdate.id,\n\t\t\t\t\ttoken: transaction,\n\t\t\t\t\tparams: clientUpdate.params,\n\t\t\t\t})\n\t\t\t},\n\t\t)\n\t\treturn unsubscribeFromTransactionUpdates\n\t})\n\n\tconst revealState = useRevealState(store)\n\tconst concealState = useConcealState(store)\n\tsocket.on(`reveal:${continuityKey}`, revealState)\n\tsocket.on(`conceal:${continuityKey}`, concealState)\n\n\tsocket.emit(`get:${continuityKey}`)\n\treturn () => {\n\t\tsocket.off(`continuity-init:${continuityKey}`)\n\t\tsocket.off(`tx-new:${continuityKey}`)\n\t\tfor (const unsubscribe of unsubscribeFunctions) unsubscribe()\n\t\t// socket.emit(`unsub:${continuityKey}`)\n\t}\n}\n"],"mappings":";;;;;;AAGA,MAAaA,kBACZ,OAAO,KAA4B;CAClC,KAAK;CACL,SAAS;CACT,CAAC;AAEH,MAAaC,gBACZ,OAAO,KAAqB;CAC3B,KAAK;CACL,SAAS;CACT,SAAS,EACP,YAAY;AACZ,MAAI,OAAO,WAAW,YACrB,CAAK,OAAO,eAAe,MAAM,EAAE,kBAAkB;AACpD,eAAY,WAAW,cAAc,MAAM,YAAY,CAAC,QAA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,MAAM,oCAAoC,qCACzC,OACA,eACA,QACA,mBACA,iBACA;AACD,QAAO,IAAI,UAAU,gBAAgB;AACrC,QAAO,GAAG,UAAU,iBAAiB,kCAAkC;CAEvE,MAAM,uBAAuB,WAAW,QAAQ,KAAK,gBAAgB;AACpE,gCAA8B,OAAO,eAAe,YAAY,IAAI;AA8CpE,SA7C0C,uBACzC,OACA,aACA,UAAU,kBACT,iBAAiB;AACjB,SAAM,OAAO,KACZ,MACA,cACA,eACA,8BACA;GACD,MAAM,wBAAwB,kBAAkB,WAC9C,WAAW,OAAO,OAAO,aAAa,GACvC;AACD,OAAI,0BAA0B,IAAI;AACjC,UAAM,OAAO,KACZ,MACA,cACA,eACA,kCACA;AACD,iBAAa,OAAO,4BAA4B,UAAU;AACzD,WAAM,KAAK,aAAa;AACxB,WAAM,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,MAAM;AACvC,YAAO;MACN;UACI;AACN,UAAM,OAAO,KACZ,MACA,cACA,eACA,iDAAiD,wBACjD;AACD,iBAAa,OAAO,4BAA4B,UAAU;AACzD,WAAM,yBAAyB;AAC/B,YAAO;MACN;;AAEH,UAAO,KAAK,UAAU,iBAAiB;IACtC,IAAI,aAAa;IACjB,OAAO;IACP,QAAQ,aAAa;IACrB,CAAC;IAEH;GAEA;CAEF,MAAM,cAAc,eAAe,MAAM;CACzC,MAAM,eAAe,gBAAgB,MAAM;AAC3C,QAAO,GAAG,UAAU,iBAAiB,YAAY;AACjD,QAAO,GAAG,WAAW,iBAAiB,aAAa;AAEnD,QAAO,KAAK,OAAO,gBAAgB;AACnC,cAAa;AACZ,SAAO,IAAI,mBAAmB,gBAAgB;AAC9C,SAAO,IAAI,UAAU,gBAAgB;AACrC,OAAK,MAAM,eAAe,qBAAsB,cAAa"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Transceiver } from "atom.io/internal";
|
|
2
2
|
import * as AtomIO from "atom.io";
|
|
3
|
+
import { MutableAtomToken } from "atom.io";
|
|
3
4
|
import { Canonical, Json } from "atom.io/json";
|
|
5
|
+
import { UList } from "atom.io/transceivers/u-list";
|
|
4
6
|
import * as React from "react";
|
|
5
|
-
import { ContinuityToken, RoomSocketInterface } from "atom.io/realtime";
|
|
7
|
+
import { ContinuityToken, RoomKey, RoomSocketInterface, UserKey } from "atom.io/realtime";
|
|
6
8
|
import { Socket as Socket$1 } from "socket.io-client";
|
|
7
9
|
|
|
8
10
|
//#region src/realtime-react/realtime-context.d.ts
|
|
@@ -42,7 +44,14 @@ declare function usePullSelectorFamilyMember<T, K extends Canonical>(familyToken
|
|
|
42
44
|
declare function usePush<J extends Json.Serializable>(token: AtomIO.WritableToken<J>): (<New extends J>(next: New | ((old: J) => New)) => void) | null;
|
|
43
45
|
//#endregion
|
|
44
46
|
//#region src/realtime-react/use-realtime-rooms.d.ts
|
|
45
|
-
|
|
47
|
+
type RealtimeRoomsTools = {
|
|
48
|
+
socket: Socket$1<{}, RoomSocketInterface<string>>;
|
|
49
|
+
myRoomKey: RoomKey | undefined;
|
|
50
|
+
myMutualsAtom: MutableAtomToken<UList<UserKey>>;
|
|
51
|
+
myOwnedRoomsAtom: MutableAtomToken<UList<RoomKey>>;
|
|
52
|
+
allRoomKeysAtom: MutableAtomToken<UList<RoomKey>>;
|
|
53
|
+
};
|
|
54
|
+
declare function useRealtimeRooms<RoomNames extends string>(userKey: UserKey): RealtimeRoomsTools;
|
|
46
55
|
//#endregion
|
|
47
56
|
//#region src/realtime-react/use-realtime-service.d.ts
|
|
48
57
|
declare function useRealtimeService(key: string, create: (socket: Socket$1) => () => void): void;
|
|
@@ -50,5 +59,5 @@ declare function useRealtimeService(key: string, create: (socket: Socket$1) => (
|
|
|
50
59
|
//#region src/realtime-react/use-sync-continuity.d.ts
|
|
51
60
|
declare function useSyncContinuity(token: ContinuityToken): void;
|
|
52
61
|
//#endregion
|
|
53
|
-
export { RealtimeContext, RealtimeProvider, RealtimeReactStore, RealtimeServiceCounter, usePullAtom, usePullAtomFamilyMember, usePullMutable, usePullMutableAtomFamilyMember, usePullSelector, usePullSelectorFamilyMember, usePush, useRealtimeRooms, useRealtimeService, useSyncContinuity };
|
|
62
|
+
export { RealtimeContext, RealtimeProvider, RealtimeReactStore, RealtimeRoomsTools, RealtimeServiceCounter, usePullAtom, usePullAtomFamilyMember, usePullMutable, usePullMutableAtomFamilyMember, usePullSelector, usePullSelectorFamilyMember, usePush, useRealtimeRooms, useRealtimeService, useSyncContinuity };
|
|
54
63
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["RealtimeContext: React.Context<RealtimeReactStore>","RealtimeProvider: React.FC<{\n\tchildren: React.ReactNode\n\tsocket: Socket | null\n}>"],"sources":["../../src/realtime-react/realtime-context.tsx","../../src/realtime-react/use-pull-atom.ts","../../src/realtime-react/use-pull-atom-family-member.ts","../../src/realtime-react/use-pull-mutable-atom.ts","../../src/realtime-react/use-pull-mutable-family-member.ts","../../src/realtime-react/use-pull-selector.ts","../../src/realtime-react/use-pull-selector-family-member.ts","../../src/realtime-react/use-push.ts","../../src/realtime-react/use-realtime-rooms.ts","../../src/realtime-react/use-realtime-service.ts","../../src/realtime-react/use-sync-continuity.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["RealtimeContext: React.Context<RealtimeReactStore>","RealtimeProvider: React.FC<{\n\tchildren: React.ReactNode\n\tsocket: Socket | null\n}>"],"sources":["../../src/realtime-react/realtime-context.tsx","../../src/realtime-react/use-pull-atom.ts","../../src/realtime-react/use-pull-atom-family-member.ts","../../src/realtime-react/use-pull-mutable-atom.ts","../../src/realtime-react/use-pull-mutable-family-member.ts","../../src/realtime-react/use-pull-selector.ts","../../src/realtime-react/use-pull-selector-family-member.ts","../../src/realtime-react/use-push.ts","../../src/realtime-react/use-realtime-rooms.ts","../../src/realtime-react/use-realtime-service.ts","../../src/realtime-react/use-sync-continuity.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;KAKY,sBAAA;;;;KAKA,kBAAA;UACH;YACE,YAAY;;AAPX,cAUCA,eAVD,EAUkB,KAAA,CAAM,OAVxB,CAUgC,kBAVhC,CAAA;AAKA,cAWCC,gBAXD,EAWmB,KAAA,CAAM,EAXzB,CAAA;EACH,QAAA,EAWE,KAAA,CAAM,SAXR;EACc,MAAA,EAWd,QAXc,GAAA,IAAA;CAAZ,CAAA;;;iBCJK,sBAAsB,IAAA,CAAK,qBACnC,MAAA,CAAO,iBAAiB,KAC7B,MAAA,CAAO,OAAO;;;iBCDD,kCACL,IAAA,CAAK,wBACL,mBAEF,MAAA,CAAO,uBAAuB,GAAG,YACjC,QAAQ,KACd,MAAA,CAAO,OAAO;;;iBCPD,yBAAyB,mCACjC,MAAA,CAAO,iBAAiB,KAC7B;;;iBCAa,yCACL,sCACA,wBACI,MAAA,CAAO,uBAAuB,GAAG,SAAS,QAAQ,KAAK;;;iBCLtD,0BAA0B,IAAA,CAAK,qBACvC,MAAA,CAAO,cAAc,KAC1B,MAAA,CAAO,OAAO;;;iBCDD,yCAAyC,wBAC3C,MAAA,CAAO,oBAAoB,GAAG,SACtC,QAAQ,KACX,MAAA,CAAO,OAAO;;;iBCHD,kBAAkB,IAAA,CAAK,qBAC/B,MAAA,CAAO,cAAc,mBACZ,SAAS,aAAa,MAAM;;;KCEjC,kBAAA;UACH,aAAW;aACR;iBACI,iBAAiB,MAAM;oBACpB,iBAAiB,MAAM;mBACxB,iBAAiB,MAAM;ARbzC,CAAA;AAKY,iBQUI,gBRVJ,CAAA,kBAAA,MAAA,CAAA,CAAA,OAAA,EQWF,ORXE,CAAA,EQYT,kBRZS;;;iBSJI,kBAAA,+BAEE;;;iBCDF,iBAAA,QAAyB"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { findInStore } from "atom.io/internal";
|
|
1
|
+
import { findInStore, getInternalRelationsFromStore } from "atom.io/internal";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { StoreContext, useI, useO, useSingleEffect } from "atom.io/react";
|
|
5
5
|
import * as RT from "atom.io/realtime";
|
|
6
|
+
import { ownersOfRooms, roomKeysAtom, usersInRooms } from "atom.io/realtime";
|
|
6
7
|
import * as RTC from "atom.io/realtime-client";
|
|
7
8
|
import { syncContinuity } from "atom.io/realtime-client";
|
|
8
9
|
|
|
@@ -121,9 +122,31 @@ function usePush(token) {
|
|
|
121
122
|
|
|
122
123
|
//#endregion
|
|
123
124
|
//#region src/realtime-react/use-realtime-rooms.ts
|
|
124
|
-
function useRealtimeRooms() {
|
|
125
|
+
function useRealtimeRooms(userKey) {
|
|
126
|
+
const store = React.useContext(StoreContext);
|
|
125
127
|
const { socket } = React.useContext(RealtimeContext);
|
|
126
|
-
|
|
128
|
+
usePullMutable(roomKeysAtom);
|
|
129
|
+
const [userKeysFamily, roomKeysFamily] = getInternalRelationsFromStore(store, usersInRooms, `split`);
|
|
130
|
+
usePullMutableAtomFamilyMember(roomKeysFamily, userKey);
|
|
131
|
+
const myJoinedRoomKeys = useO(roomKeysFamily, userKey);
|
|
132
|
+
let myRoomKey;
|
|
133
|
+
for (const roomKey$1 of myJoinedRoomKeys) {
|
|
134
|
+
myRoomKey = roomKey$1;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
const roomKey = myRoomKey ?? `room::$_NONE_$`;
|
|
138
|
+
const myMutualsAtom = findInStore(store, userKeysFamily, roomKey);
|
|
139
|
+
usePullMutableAtomFamilyMember(userKeysFamily, roomKey);
|
|
140
|
+
const [ownedRoomsFamily] = getInternalRelationsFromStore(store, ownersOfRooms, `split`);
|
|
141
|
+
const myOwnedRoomsAtom = findInStore(store, ownedRoomsFamily, userKey);
|
|
142
|
+
usePullMutableAtomFamilyMember(ownedRoomsFamily, userKey);
|
|
143
|
+
return {
|
|
144
|
+
socket,
|
|
145
|
+
myRoomKey,
|
|
146
|
+
allRoomKeysAtom: roomKeysAtom,
|
|
147
|
+
myMutualsAtom,
|
|
148
|
+
myOwnedRoomsAtom
|
|
149
|
+
};
|
|
127
150
|
}
|
|
128
151
|
|
|
129
152
|
//#endregion
|