atom.io 0.40.7 → 0.40.9
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/{chunk-Cl8Af3a2.js → chunk-CTAAG5j7.js} +3 -1
- package/dist/data/index.js +1 -2
- package/dist/data/index.js.map +1 -1
- package/dist/eslint-plugin/index.js +2 -3
- package/dist/eslint-plugin/index.js.map +1 -1
- package/dist/internal/index.d.ts +4 -3
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +1231 -176
- package/dist/internal/index.js.map +1 -1
- package/dist/introspection/index.d.ts.map +1 -1
- package/dist/introspection/index.js +13 -32
- package/dist/introspection/index.js.map +1 -1
- package/dist/json/index.d.ts.map +1 -1
- package/dist/json/index.js.map +1 -1
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +1 -2
- package/dist/main/index.js.map +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react-devtools/index.d.ts.map +1 -1
- package/dist/react-devtools/index.js +2 -4
- package/dist/react-devtools/index.js.map +1 -1
- package/dist/realtime/index.d.ts +29 -5
- package/dist/realtime/index.d.ts.map +1 -1
- package/dist/realtime/index.js +47 -5
- package/dist/realtime/index.js.map +1 -1
- package/dist/realtime-client/index.d.ts +2 -6
- package/dist/realtime-client/index.d.ts.map +1 -1
- package/dist/realtime-client/index.js +6 -22
- package/dist/realtime-client/index.js.map +1 -1
- package/dist/realtime-react/index.d.ts +6 -9
- package/dist/realtime-react/index.d.ts.map +1 -1
- package/dist/realtime-react/index.js +4 -16
- package/dist/realtime-react/index.js.map +1 -1
- package/dist/realtime-server/index.d.ts +38 -57
- package/dist/realtime-server/index.d.ts.map +1 -1
- package/dist/realtime-server/index.js +128 -178
- package/dist/realtime-server/index.js.map +1 -1
- package/dist/realtime-testing/index.d.ts +2 -0
- package/dist/realtime-testing/index.d.ts.map +1 -1
- package/dist/realtime-testing/index.js +15 -9
- package/dist/realtime-testing/index.js.map +1 -1
- package/dist/transceivers/set-rtx/index.d.ts +1 -1
- package/dist/transceivers/set-rtx/index.d.ts.map +1 -1
- package/dist/transceivers/set-rtx/index.js +5 -9
- package/dist/transceivers/set-rtx/index.js.map +1 -1
- package/dist/transceivers/u-list/index.d.ts +29 -0
- package/dist/transceivers/u-list/index.d.ts.map +1 -0
- package/dist/transceivers/u-list/index.js +87 -0
- package/dist/transceivers/u-list/index.js.map +1 -0
- package/dist/web/index.js.map +1 -1
- package/package.json +17 -13
- package/src/internal/mutable/tracker.ts +61 -46
- package/src/internal/mutable/transceiver.ts +4 -4
- package/src/internal/set-state/index.ts +1 -0
- package/src/internal/subscribe/subscribe-to-state.ts +9 -0
- package/src/{realtime-server → realtime}/employ-socket.ts +2 -2
- package/src/realtime/index.ts +2 -0
- package/src/realtime/shared-room-store.ts +12 -11
- package/src/realtime-client/continuity/register-and-attempt-confirmed-update.ts +1 -1
- package/src/realtime-client/index.ts +0 -1
- package/src/realtime-client/push-state.ts +1 -2
- package/src/realtime-react/index.ts +0 -1
- package/src/realtime-react/use-single-effect.ts +1 -1
- package/src/realtime-server/continuity/continuity-store.ts +2 -27
- package/src/realtime-server/continuity/provide-continuity.ts +50 -0
- package/src/realtime-server/continuity/{subscribe-to-continuity-actions.ts → provide-outcomes.ts} +16 -14
- package/src/realtime-server/continuity/{subscribe-to-continuity-perpectives.ts → provide-perspectives.ts} +11 -10
- package/src/realtime-server/continuity/{prepare-to-send-initial-payload.ts → provide-startup-payloads.ts} +8 -6
- package/src/realtime-server/continuity/receive-action-requests.ts +66 -0
- package/src/realtime-server/continuity/{prepare-to-track-client-acknowledgement.ts → track-acknowledgements.ts} +15 -9
- package/src/realtime-server/index.ts +1 -3
- package/src/realtime-server/ipc-sockets/custom-socket.ts +4 -5
- package/src/realtime-server/ipc-sockets/parent-socket.ts +21 -17
- package/src/realtime-server/realtime-family-provider.ts +1 -1
- package/src/realtime-server/realtime-mutable-family-provider.ts +1 -1
- package/src/realtime-server/realtime-mutable-provider.ts +1 -1
- package/src/realtime-server/realtime-server-stores/server-room-external-store.ts +2 -2
- package/src/realtime-server/realtime-server-stores/server-user-store.ts +8 -9
- package/src/realtime-server/realtime-state-provider.ts +1 -1
- package/src/realtime-server/realtime-state-receiver.ts +3 -6
- package/src/realtime-server/server-config.ts +1 -3
- package/src/realtime-testing/setup-realtime-test.tsx +23 -18
- package/src/transceivers/set-rtx/set-rtx.ts +3 -3
- package/src/transceivers/u-list/index.ts +1 -0
- package/src/transceivers/u-list/u-list.ts +123 -0
- package/dist/employ-socket-D6wgByWh.js +0 -12
- package/dist/employ-socket-D6wgByWh.js.map +0 -1
- package/dist/has-role-hv4-hJMw.js +0 -1149
- package/dist/has-role-hv4-hJMw.js.map +0 -1
- package/dist/is-fn-DY1wZ-md.js +0 -10
- package/dist/is-fn-DY1wZ-md.js.map +0 -1
- package/dist/mutex-store-CSvxY9i3.js +0 -11
- package/dist/mutex-store-CSvxY9i3.js.map +0 -1
- package/dist/shared-room-store-COGGKqes.js +0 -32
- package/dist/shared-room-store-COGGKqes.js.map +0 -1
- package/dist/shared-room-store-D2o4ZLjC.d.ts +0 -15
- package/dist/shared-room-store-D2o4ZLjC.d.ts.map +0 -1
- package/src/realtime-client/server-action.ts +0 -23
- package/src/realtime-react/use-server-action.ts +0 -19
- package/src/realtime-server/continuity/prepare-to-serve-transaction-request.ts +0 -59
- package/src/realtime-server/continuity/prepare-to-sync-realtime-continuity.ts +0 -145
- package/src/realtime-server/realtime-action-receiver.ts +0 -40
- /package/src/{realtime-server → realtime}/socket-interface.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["mutexAtoms: AtomFamilyToken<boolean, Canonical>"],"sources":["../../src/realtime/mutex-store.ts","../../src/realtime/realtime-continuity.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["mutexAtoms: AtomFamilyToken<boolean, Canonical>","usersInThisRoomIndex: MutableAtomToken<UList<string>>","roomIndex: MutableAtomToken<UList<string>>","DEFAULT_USER_IN_ROOM_META: UserInRoomMeta","usersInRooms: JoinToken<\n\t`room`,\n\tstring,\n\t`user`,\n\tstring,\n\t`1:n`,\n\tUserInRoomMeta\n>","usersInMyRoomView: ReadonlyPureSelectorFamilyToken<\n\tMutableAtomToken<UList<string>>[],\n\tstring\n>"],"sources":["../../src/realtime/employ-socket.ts","../../src/realtime/mutex-store.ts","../../src/realtime/realtime-continuity.ts","../../src/realtime/shared-room-store.ts","../../src/realtime/socket-interface.ts"],"sourcesContent":[],"mappings":";;;;;;;iBAGgB,uBAAuB,iCAAiC,WAC/D,iBACD,0BACgB,EAAE;;;cCFbA,YAAY,yBAAyB;;;cCcrC,2BAA2B,IAAI,GAAG,cAAc,YAAY,GAAG;EFf5E,GAAgB,CAAA,GAAA,EEgBC,CFhBD,EAAA,KAAA,EEgBW,CFhBX,CAAA,EAAA,IAAA;;AAAuB,KE4B3B,gBF5B2B,CAAA,UE4BA,eF5BA,CAAA,GAAA,CAAA,CAAA,GAAA;QAAiC,sBAAA;eAC/D,EE6BO,CF7BP;WACD,EE6BI,mBF7BJ,CE6BwB,aF7BxB,CE6BsC,SF7BtC,CE6BgD,CF7BhD,CAAA,CAAA,EAAA,EE6BuD,OF7BvD,CAAA;;AACkB,KE+Bd,eAAA,GF/Bc;EAAA,SAAA,IAAA,EAAA,YAAA;;oBEkCP;oBACA;EDrCnB,SAAaA,YAAqC,ECsC1B,gBDtC0B,CCsCT,eDtCS,CAAA,GAAA,ECsCY,SDtCZ,CAAA,CAAA,EAAA;CAAA;AAAA,cCyCrC,SAAA,CDzCqC;QAAzB,YAAA;EAAA,UAAA,OAAA,EC4CL,SD5CK,CAAA,GAAA,CAAA,EAAA;qBC6CL;0BACK;;EAhCzB,UAAa,WAAA,CAAA,GAAA,EAAA,MAAA;EAAA,OAAA,QAAA,EAuCY,YAvCZ,CAAA,MAAA,EAuCiC,eAvCjC,CAAA;SAA+B,MAA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KAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EISgB,IAAA,CAAK,YJTrB,EAAA,EAAA,GAAA,IAAA;CAAA"}
|
package/dist/realtime/index.js
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
|
-
import { mutexAtoms } from "../mutex-store-CSvxY9i3.js";
|
|
2
|
-
import { DEFAULT_USER_IN_ROOM_META, roomIndex, usersInMyRoomView, usersInRooms, usersInThisRoomIndex } from "../shared-room-store-COGGKqes.js";
|
|
3
1
|
import { IMPLICIT, assignTransactionToContinuity, setEpochNumberOfContinuity } from "atom.io/internal";
|
|
2
|
+
import { atomFamily, getInternalRelations, join, mutableAtom, selectorFamily } from "atom.io";
|
|
3
|
+
import { UList } from "atom.io/transceivers/u-list";
|
|
4
4
|
|
|
5
|
+
//#region src/realtime/employ-socket.ts
|
|
6
|
+
function employSocket(socket, event, handleEvent) {
|
|
7
|
+
socket.on(event, handleEvent);
|
|
8
|
+
const retireSocket = () => {
|
|
9
|
+
socket.off(event, handleEvent);
|
|
10
|
+
};
|
|
11
|
+
return retireSocket;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/realtime/mutex-store.ts
|
|
16
|
+
const mutexAtoms = atomFamily({
|
|
17
|
+
key: `mutex`,
|
|
18
|
+
default: false
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
5
22
|
//#region src/realtime/realtime-continuity.ts
|
|
6
23
|
var InvariantMap = class extends Map {
|
|
7
24
|
set(key, value) {
|
|
@@ -39,8 +56,7 @@ var SyncGroup = class SyncGroup {
|
|
|
39
56
|
return token;
|
|
40
57
|
}
|
|
41
58
|
add(...args) {
|
|
42
|
-
|
|
43
|
-
switch (zeroth.type) {
|
|
59
|
+
switch (args[0].type) {
|
|
44
60
|
case `atom`:
|
|
45
61
|
case `mutable_atom`:
|
|
46
62
|
this.globals.push(...args);
|
|
@@ -73,5 +89,31 @@ function continuity(options) {
|
|
|
73
89
|
}
|
|
74
90
|
|
|
75
91
|
//#endregion
|
|
76
|
-
|
|
92
|
+
//#region src/realtime/shared-room-store.ts
|
|
93
|
+
const usersInThisRoomIndex = mutableAtom({
|
|
94
|
+
key: `usersInRoomIndex`,
|
|
95
|
+
class: UList
|
|
96
|
+
});
|
|
97
|
+
const roomIndex = mutableAtom({
|
|
98
|
+
key: `roomIndex`,
|
|
99
|
+
class: UList
|
|
100
|
+
});
|
|
101
|
+
const DEFAULT_USER_IN_ROOM_META = { enteredAtEpoch: 0 };
|
|
102
|
+
const usersInRooms = join({
|
|
103
|
+
key: `usersInRooms`,
|
|
104
|
+
between: [`room`, `user`],
|
|
105
|
+
cardinality: `1:n`,
|
|
106
|
+
isAType: (input) => typeof input === `string`,
|
|
107
|
+
isBType: (input) => typeof input === `string`
|
|
108
|
+
}, DEFAULT_USER_IN_ROOM_META);
|
|
109
|
+
const usersInMyRoomView = selectorFamily({
|
|
110
|
+
key: `usersInMyRoomView`,
|
|
111
|
+
get: (myUsername) => ({ find }) => {
|
|
112
|
+
const usersInRoomsAtoms = getInternalRelations(usersInRooms);
|
|
113
|
+
return [find(usersInRoomsAtoms, myUsername)];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
//#endregion
|
|
118
|
+
export { DEFAULT_USER_IN_ROOM_META, InvariantMap, SyncGroup, continuity, employSocket, mutexAtoms, roomIndex, usersInMyRoomView, usersInRooms, usersInThisRoomIndex };
|
|
77
119
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/realtime/realtime-continuity.ts"],"sourcesContent":["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\"\nimport type { UserKey } from \"atom.io/realtime-server\"\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"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.js","names":["mutexAtoms: AtomFamilyToken<boolean, Canonical>","usersInThisRoomIndex: MutableAtomToken<UList<string>>","roomIndex: MutableAtomToken<UList<string>>","DEFAULT_USER_IN_ROOM_META: UserInRoomMeta","usersInRooms: JoinToken<\n\t`room`,\n\tstring,\n\t`user`,\n\tstring,\n\t`1:n`,\n\tUserInRoomMeta\n>","usersInMyRoomView: ReadonlyPureSelectorFamilyToken<\n\tMutableAtomToken<UList<string>>[],\n\tstring\n>"],"sources":["../../src/realtime/employ-socket.ts","../../src/realtime/mutex-store.ts","../../src/realtime/realtime-continuity.ts","../../src/realtime/shared-room-store.ts"],"sourcesContent":["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\tboolean,\n\tCanonical\n>({\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\"\nimport type { UserKey } from \"atom.io/realtime-server\"\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","import type {\n\tJoinToken,\n\tMutableAtomToken,\n\tReadonlyPureSelectorFamilyToken,\n} from \"atom.io\"\nimport { getInternalRelations, join, mutableAtom, selectorFamily } from \"atom.io\"\nimport { UList } from \"atom.io/transceivers/u-list\"\n\nexport const usersInThisRoomIndex: MutableAtomToken<UList<string>> = mutableAtom<\n\tUList<string>\n>({\n\tkey: `usersInRoomIndex`,\n\tclass: UList,\n})\n\nexport const roomIndex: MutableAtomToken<UList<string>> = mutableAtom<\n\tUList<string>\n>({\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<\n\t`room`,\n\tstring,\n\t`user`,\n\tstring,\n\t`1:n`,\n\tUserInRoomMeta\n> = join(\n\t{\n\t\tkey: `usersInRooms`,\n\t\tbetween: [`room`, `user`],\n\t\tcardinality: `1:n`,\n\t\tisAType: (input): input is string => typeof input === `string`,\n\t\tisBType: (input): input is string => typeof input === `string`,\n\t},\n\tDEFAULT_USER_IN_ROOM_META,\n)\n\nexport const usersInMyRoomView: ReadonlyPureSelectorFamilyToken<\n\tMutableAtomToken<UList<string>>[],\n\tstring\n> = selectorFamily<MutableAtomToken<UList<string>>[], string>({\n\tkey: `usersInMyRoomView`,\n\tget:\n\t\t(myUsername) =>\n\t\t({ find }) => {\n\t\t\tconst usersInRoomsAtoms = getInternalRelations(usersInRooms)\n\t\t\tconst myRoomIndex = find(usersInRoomsAtoms, myUsername)\n\t\t\treturn [myRoomIndex]\n\t\t},\n})\n"],"mappings":";;;;;AAGA,SAAgB,aACf,QACA,OACA,aACa;AACb,QAAO,GAAG,OAAO,YAAY;CAC7B,MAAM,qBAAqB;AAC1B,SAAO,IAAI,OAAO,YAAY;;AAE/B,QAAO;;;;;ACRR,MAAaA,aAAkD,WAG7D;CACD,KAAK;CACL,SAAS;CACT,CAAC;;;;ACQF,IAAa,eAAb,cAAwC,IAAuC;CAC9E,AAAO,IAAI,KAAQ,OAAgB;AAClC,MAAI,KAAK,IAAI,IAAI,EAAE;AAClB,WAAQ,KAAK,6DAA6D;IACzE;IACA;IACA,CAAC;AACF,UAAO;;AAER,SAAO,MAAM,IAAI,KAAK,MAAM;;;AAkB9B,IAAa,YAAb,MAAa,UAAU;CACtB,AAAO,OAAO;CAEd,AAAU,UAA4B,EAAE;CACxC,AAAU,UAAmC,EAAE;CAC/C,AAAU,eAAwC,EAAE;CACpD,AAAmB;CAEnB,AAAU,YAAY,KAAa;AAClC,OAAK,MAAM;;CAGZ,OAAc,WACb,IAAI,cAAc;CACnB,OAAc,OACb,KACA,SACkB;EAClB,MAAM,QAAQ,IAAI,UAAU,IAAI;EAChC,MAAM,EAAE,MAAM,SAAS,SAAS,iBAAiB,QAAQ,MAAM;EAC/D,MAAM,QAAQ;GAAE;GAAM;GAAK;GAAS;GAAS;GAAc;AAC3D,YAAU,SAAS,IAAI,KAAK,MAAM;AAClC,SAAO;;CAYR,AAAO,IACN,GAAG,MAII;AAEP,UADe,KAAK,GACL,MAAf;GACC,KAAK;GACL,KAAK;AACJ,SAAK,QAAQ,KAAK,GAAI,KAA0B;AAChD;GACD,KAAK;AACJ,SAAK,QAAQ,KAAK,GAAI,KAAiC;AACvD;GACD,KAAK;GACL,KAAK;IACJ;KACC,MAAM,CAAC,QAAQ,SAAS;AAIxB,UAAK,aAAa,KAAK;MACtB,MAAM;MACN,eAAe;MACf,WAAW;MACX,CAAC;;AAEH;;AAGF,SAAO;;;AAST,SAAgB,WAAW,SAA6C;CACvE,MAAM,EAAE,KAAK,WAAW;CACxB,MAAM,QAAQ,UAAU,OAAO,KAAK,OAAO;CAC3C,MAAM,EAAE,YAAY;AACpB,MAAK,MAAM,UAAU,QACpB,+BAA8B,SAAS,OAAO,KAAK,OAAO,IAAI;AAE/D,4BAA2B,SAAS,OAAO,KAAK,GAAG;AACnD,QAAO;;;;;ACvHR,MAAaC,uBAAwD,YAEnE;CACD,KAAK;CACL,OAAO;CACP,CAAC;AAEF,MAAaC,YAA6C,YAExD;CACD,KAAK;CACL,OAAO;CACP,CAAC;AAKF,MAAaC,4BAA4C,EACxD,gBAAgB,GAChB;AACD,MAAaC,eAOT,KACH;CACC,KAAK;CACL,SAAS,CAAC,QAAQ,OAAO;CACzB,aAAa;CACb,UAAU,UAA2B,OAAO,UAAU;CACtD,UAAU,UAA2B,OAAO,UAAU;CACtD,EACD,0BACA;AAED,MAAaC,oBAGT,eAA0D;CAC7D,KAAK;CACL,MACE,gBACA,EAAE,WAAW;EACb,MAAM,oBAAoB,qBAAqB,aAAa;AAE5D,SAAO,CADa,KAAK,mBAAmB,WAAW,CACnC;;CAEtB,CAAC"}
|
|
@@ -2,8 +2,7 @@ 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 } from "atom.io/realtime";
|
|
6
|
-
import { Socket } from "atom.io/realtime-server";
|
|
5
|
+
import { ContinuityToken, Socket } from "atom.io/realtime";
|
|
7
6
|
import { Socket as Socket$1 } from "socket.io-client";
|
|
8
7
|
|
|
9
8
|
//#region src/realtime-client/continuity/register-and-attempt-confirmed-update.d.ts
|
|
@@ -45,11 +44,8 @@ declare const myUsernameState: AtomIO.RegularAtomToken<string | null>;
|
|
|
45
44
|
declare const optimisticUpdateQueue: AtomIO.RegularAtomToken<AtomIO.TransactionOutcomeEvent<any>[]>;
|
|
46
45
|
declare const confirmedUpdateQueue: AtomIO.RegularAtomToken<AtomIO.TransactionOutcomeEvent<any>[]>;
|
|
47
46
|
//#endregion
|
|
48
|
-
//#region src/realtime-client/server-action.d.ts
|
|
49
|
-
declare function serverAction<F extends Fn>(store: Store, socket: Socket$1, token: AtomIO.TransactionToken<F>): () => void;
|
|
50
|
-
//#endregion
|
|
51
47
|
//#region src/realtime-client/sync-continuity.d.ts
|
|
52
48
|
declare function syncContinuity(store: RootStore, socket: Socket$1, continuity: ContinuityToken): () => void;
|
|
53
49
|
//#endregion
|
|
54
|
-
export { confirmedUpdateQueue, myIdState, myIdState__INTERNAL, myUsernameState, optimisticUpdateQueue, pullAtom, pullAtomFamilyMember, pullMutableAtom, pullMutableAtomFamilyMember, pullSelector, pullSelectorFamilyMember, pushState,
|
|
50
|
+
export { confirmedUpdateQueue, myIdState, myIdState__INTERNAL, myUsernameState, optimisticUpdateQueue, pullAtom, pullAtomFamilyMember, pullMutableAtom, pullMutableAtomFamilyMember, pullSelector, pullSelectorFamilyMember, pushState, syncContinuity, useConcealState, useRegisterAndAttemptConfirmedUpdate, useRevealState };
|
|
55
51
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["myIdState__INTERNAL: AtomIO.RegularAtomToken<string | undefined>","myIdState: AtomIO.ReadonlyPureSelectorToken<string | undefined>","myUsernameState: AtomIO.RegularAtomToken<string | null>","optimisticUpdateQueue: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n>","confirmedUpdateQueue: 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/
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["myIdState__INTERNAL: AtomIO.RegularAtomToken<string | undefined>","myIdState: AtomIO.ReadonlyPureSelectorToken<string | undefined>","myUsernameState: AtomIO.RegularAtomToken<string | null>","optimisticUpdateQueue: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n>","confirmedUpdateQueue: 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":";;;;;;;;cAea,8CAEJ,0CAEC,2BACW,MAAA,CAAO,wBACzB,MAAA,CAAO,iBAAiB,0BAEP,MAAA,CAAO,wBACxB,MAAA,CAAO,iBAAiB,uBAId,MAAA,CAAO,wBAAwB,MAAA,CAAO,iBAAiB;;;iBCxBpD,eAAA,QAAuB,oBACnB;;;iBCFJ,cAAA,QAAsB,mBACnB,IAAA,CAAK;;;iBCCR,mBAAmB,IAAA,CAAK,qBAChC,eACC,iBACD,MAAA,CAAO,iBAAiB;;;iBCHhB,+BACL,IAAA,CAAK,wBACL,kBAEH,eACC,kBACA,MAAA,CAAO,gBAAgB,GAAG,cAC7B,QAAQ;;;iBCPE,0BAA0B,mCAClC,eACC,iBACD,MAAA,CAAO,iBAAiB;;;iBCGhB,sCACL,sCACA,kBAEH,eACC,kBACA,MAAA,CAAO,uBAAuB,GAAG,SACpC,QAAQ;;;iBCZE,uBACR,eACC,iBACD,MAAA,CAAO,cAAc;;;iBCDb,sCAAsC,kBAC9C,eACC,uBACK,MAAA,CAAO,oBAAoB,GAAG,SACtC,QAAQ;;;iBCLE,oBAAoB,IAAA,CAAK,qBACjC,eACC,iBACD,cAAc;;;cCPTA,qBAAqB,MAAA,CAAO;cAK5BC,WAAW,MAAA,CAAO;cAMlBC,iBAAiB,MAAA,CAAO;;;cCZxBC,uBAAuB,MAAA,CAAO,iBAC1C,MAAA,CAAO;cAMKC,sBAAsB,MAAA,CAAO,iBACzC,MAAA,CAAO;;;iBCWQ,cAAA,QACR,mBACC,sBACI"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { mutexAtoms } from "../mutex-store-CSvxY9i3.js";
|
|
2
|
-
import { employSocket } from "../employ-socket-D6wgByWh.js";
|
|
3
1
|
import { actUponStore, assignTransactionToContinuity, disposeAtom, findInStore, getEpochNumberOfContinuity, getFamilyOfToken, getFromStore, getJsonToken, getUpdateToken, ingestTransactionOutcomeEvent, setEpochNumberOfContinuity, setIntoStore, subscribeToState, subscribeToTransaction } from "atom.io/internal";
|
|
4
2
|
import * as AtomIO from "atom.io";
|
|
5
3
|
import { parseJson } from "atom.io/json";
|
|
6
4
|
import { storageSync } from "atom.io/web";
|
|
7
5
|
import { confirmedUpdateQueue as confirmedUpdateQueue$1, optimisticUpdateQueue as optimisticUpdateQueue$1 } from "atom.io/realtime-client";
|
|
6
|
+
import { employSocket, mutexAtoms } from "atom.io/realtime";
|
|
8
7
|
|
|
9
8
|
//#region src/realtime-client/continuity/register-and-attempt-confirmed-update.ts
|
|
10
9
|
const useRegisterAndAttemptConfirmedUpdate = (store, continuityKey, socket, optimisticUpdates, confirmedUpdates) => (confirmed) => {
|
|
@@ -60,8 +59,7 @@ const useRegisterAndAttemptConfirmedUpdate = (store, continuityKey, socket, opti
|
|
|
60
59
|
}
|
|
61
60
|
} else {
|
|
62
61
|
store.logger.info(`🧑⚖️`, `continuity`, continuityKey, `epoch of confirmed update #${confirmed.epoch} does not match zeroth optimistic update #${zerothOptimisticUpdate.epoch}`);
|
|
63
|
-
|
|
64
|
-
if (!confirmedUpdateIsAlreadyEnqueued) {
|
|
62
|
+
if (!confirmedUpdates.some((update) => update.epoch === confirmed.epoch)) {
|
|
65
63
|
store.logger.info(`👈`, `continuity`, continuityKey, `pushing confirmed update to queue`, confirmed);
|
|
66
64
|
setIntoStore(store, confirmedUpdateQueue$1, (queue) => {
|
|
67
65
|
queue.push(confirmed);
|
|
@@ -72,8 +70,7 @@ const useRegisterAndAttemptConfirmedUpdate = (store, continuityKey, socket, opti
|
|
|
72
70
|
}
|
|
73
71
|
} else {
|
|
74
72
|
store.logger.info(`🧑⚖️`, `continuity`, continuityKey, `has no optimistic updates to deal with`);
|
|
75
|
-
let continuityEpoch;
|
|
76
|
-
continuityEpoch = getEpochNumberOfContinuity(store, continuityKey);
|
|
73
|
+
let continuityEpoch = getEpochNumberOfContinuity(store, continuityKey);
|
|
77
74
|
if (continuityEpoch === confirmed.epoch - 1) {
|
|
78
75
|
store.logger.info(`✅`, `continuity`, continuityKey, `integrating update #${confirmed.epoch} (${confirmed.token.key} ${confirmed.id})`);
|
|
79
76
|
ingestTransactionOutcomeEvent(store, confirmed, `newValue`);
|
|
@@ -84,8 +81,7 @@ const useRegisterAndAttemptConfirmedUpdate = (store, continuityKey, socket, opti
|
|
|
84
81
|
clientEpoch: continuityEpoch,
|
|
85
82
|
serverEpoch: confirmed.epoch
|
|
86
83
|
});
|
|
87
|
-
|
|
88
|
-
if (confirmedUpdateIsAlreadyEnqueued) store.logger.info(`👍`, `continuity`, continuityKey, `confirmed update #${confirmed.epoch} is already enqueued`);
|
|
84
|
+
if (confirmedUpdates.some((update) => update.epoch === confirmed.epoch)) store.logger.info(`👍`, `continuity`, continuityKey, `confirmed update #${confirmed.epoch} is already enqueued`);
|
|
89
85
|
else {
|
|
90
86
|
store.logger.info(`👈`, `continuity`, continuityKey, `pushing confirmed update #${confirmed.epoch} to queue`);
|
|
91
87
|
setIntoStore(store, confirmedUpdateQueue$1, (queue) => {
|
|
@@ -309,17 +305,6 @@ const confirmedUpdateQueue = AtomIO.atom({
|
|
|
309
305
|
default: () => []
|
|
310
306
|
});
|
|
311
307
|
|
|
312
|
-
//#endregion
|
|
313
|
-
//#region src/realtime-client/server-action.ts
|
|
314
|
-
function serverAction(store, socket, token) {
|
|
315
|
-
const unsubscribeFromLocalUpdates = subscribeToTransaction(store, token, `tx-run:${token.key}:${socket.id}`, (clientUpdate) => {
|
|
316
|
-
socket.emit(`tx-run:${token.key}`, clientUpdate);
|
|
317
|
-
});
|
|
318
|
-
return () => {
|
|
319
|
-
unsubscribeFromLocalUpdates();
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
|
|
323
308
|
//#endregion
|
|
324
309
|
//#region src/realtime-client/sync-continuity.ts
|
|
325
310
|
function syncContinuity(store, socket, continuity) {
|
|
@@ -349,7 +334,7 @@ function syncContinuity(store, socket, continuity) {
|
|
|
349
334
|
socket.on(`tx-new:${continuityKey}`, registerAndAttemptConfirmedUpdate);
|
|
350
335
|
const unsubscribeFunctions = continuity.actions.map((transaction$1) => {
|
|
351
336
|
assignTransactionToContinuity(store, continuityKey, transaction$1.key);
|
|
352
|
-
|
|
337
|
+
return subscribeToTransaction(store, transaction$1, `tx-run:${continuityKey}`, (clientUpdate) => {
|
|
353
338
|
store.logger.info(`🤞`, `continuity`, continuityKey, `enqueuing optimistic update`);
|
|
354
339
|
const optimisticUpdateIndex = optimisticUpdates.findIndex((update) => update.id === clientUpdate.id);
|
|
355
340
|
if (optimisticUpdateIndex === -1) {
|
|
@@ -372,7 +357,6 @@ function syncContinuity(store, socket, continuity) {
|
|
|
372
357
|
params: clientUpdate.params
|
|
373
358
|
});
|
|
374
359
|
});
|
|
375
|
-
return unsubscribeFromTransactionUpdates;
|
|
376
360
|
});
|
|
377
361
|
const revealState = useRevealState(store);
|
|
378
362
|
const concealState = useConcealState(store);
|
|
@@ -387,5 +371,5 @@ function syncContinuity(store, socket, continuity) {
|
|
|
387
371
|
}
|
|
388
372
|
|
|
389
373
|
//#endregion
|
|
390
|
-
export { confirmedUpdateQueue, myIdState, myIdState__INTERNAL, myUsernameState, optimisticUpdateQueue, pullAtom, pullAtomFamilyMember, pullMutableAtom, pullMutableAtomFamilyMember, pullSelector, pullSelectorFamilyMember, pushState,
|
|
374
|
+
export { confirmedUpdateQueue, myIdState, myIdState__INTERNAL, myUsernameState, optimisticUpdateQueue, pullAtom, pullAtomFamilyMember, pullMutableAtom, pullMutableAtomFamilyMember, pullSelector, pullSelectorFamilyMember, pushState, syncContinuity, useConcealState, useRegisterAndAttemptConfirmedUpdate, useRevealState };
|
|
391
375
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["optimisticUpdateQueue","confirmedUpdateQueue","continuityEpoch: number | undefined","k: any","v: any","myIdState__INTERNAL: AtomIO.RegularAtomToken<string | undefined>","myIdState: AtomIO.ReadonlyPureSelectorToken<string | undefined>","myUsernameState: AtomIO.RegularAtomToken<string | null>","optimisticUpdateQueue: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n>","confirmedUpdateQueue: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n>","optimisticUpdateQueue","confirmedUpdateQueue","k: any","v: any","transaction"],"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-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/realtime-client-stores/client-main-store.ts","../../src/realtime-client/realtime-client-stores/client-sync-store.ts","../../src/realtime-client/server-action.ts","../../src/realtime-client/sync-continuity.ts"],"sourcesContent":["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 {\n\tconfirmedUpdateQueue,\n\toptimisticUpdateQueue,\n} from \"atom.io/realtime-client\"\nimport type { Socket } from \"atom.io/realtime-server\"\n\nexport const useRegisterAndAttemptConfirmedUpdate =\n\t(\n\t\tstore: RootStore,\n\t\tcontinuityKey: string,\n\t\tsocket: Socket,\n\t\toptimisticUpdates: AtomIO.TransactionOutcomeEvent<\n\t\t\tAtomIO.TransactionToken<Fn>\n\t\t>[],\n\t\tconfirmedUpdates: 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, optimisticUpdateQueue, (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, confirmedUpdateQueue, (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, confirmedUpdateQueue, (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 { mutexAtoms } from \"atom.io/realtime/mutex-store\"\nimport { employSocket } from \"atom.io/realtime-server/employ-socket\"\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 * as AtomIO from \"atom.io\"\nimport { storageSync } from \"atom.io/web\"\n\nexport const myIdState__INTERNAL: AtomIO.RegularAtomToken<string | undefined> =\n\tAtomIO.atom<string | undefined>({\n\t\tkey: `mySocketId__INTERNAL`,\n\t\tdefault: undefined,\n\t})\nexport const myIdState: AtomIO.ReadonlyPureSelectorToken<string | undefined> =\n\tAtomIO.selector<string | undefined>({\n\t\tkey: `mySocketId`,\n\t\tget: ({ get }) => get(myIdState__INTERNAL),\n\t})\n\nexport const myUsernameState: AtomIO.RegularAtomToken<string | null> =\n\tAtomIO.atom<string | null>({\n\t\tkey: `myName`,\n\t\tdefault: null,\n\t\teffects: [storageSync(globalThis.localStorage, JSON, `myUsername`)],\n\t})\n","import * as AtomIO from \"atom.io\"\n\nexport const optimisticUpdateQueue: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n> = AtomIO.atom<AtomIO.TransactionOutcomeEvent<any>[]>({\n\tkey: `updateQueue`,\n\tdefault: () => [],\n})\n\nexport const confirmedUpdateQueue: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n> = AtomIO.atom<AtomIO.TransactionOutcomeEvent<any>[]>({\n\tkey: `serverConfirmedUpdateQueue`,\n\tdefault: () => [],\n})\n","import type * as AtomIO from \"atom.io\"\nimport type { Fn, Store } from \"atom.io/internal\"\nimport { subscribeToTransaction } from \"atom.io/internal\"\nimport type { Socket } from \"socket.io-client\"\n\nexport function serverAction<F extends Fn>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: AtomIO.TransactionToken<F>,\n): () => void {\n\tconst unsubscribeFromLocalUpdates = subscribeToTransaction(\n\t\tstore,\n\t\ttoken,\n\t\t`tx-run:${token.key}:${socket.id}`,\n\t\t(clientUpdate) => {\n\t\t\tsocket.emit(`tx-run:${token.key}`, clientUpdate)\n\t\t},\n\t)\n\n\treturn () => {\n\t\tunsubscribeFromLocalUpdates()\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 {\n\tconfirmedUpdateQueue,\n\toptimisticUpdateQueue,\n} from \"atom.io/realtime-client\"\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\"\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, optimisticUpdateQueue)\n\tconst confirmedUpdates = getFromStore(store, confirmedUpdateQueue)\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, optimisticUpdateQueue, (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, optimisticUpdateQueue, (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":";;;;;;;;;AAeA,MAAa,wCAEX,OACA,eACA,QACA,mBAGA,sBAKA,cACU;CACV,SAAS,eACR,kBAGA,iBAGO;AACP,QAAM,OAAO,KACZ,SACA,cACA,eACA;AAED,eAAa,OAAOA,0BAAwB,UAAU;AACrD,SAAM;AACN,UAAO;;AAER,MAAI,iBAAiB,OAAO,gBAAgB,IAAI;GAC/C,MAAM,eAAe,KAAK,UAAU,iBAAiB;GACrD,MAAM,eAAe,KAAK,UAAU,gBAAgB;AACpD,OAAI,iBAAiB,cAAc;AAClC,UAAM,OAAO,KACZ,KACA,cACA,eACA,eAAe,iBAAiB,G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;CAGR,MAAM,cAAc,eAAe;CACnC,MAAM,eAAe,gBAAgB;AACrC,QAAO,GAAG,UAAU,iBAAiB;AACrC,QAAO,GAAG,WAAW,iBAAiB;AAEtC,QAAO,KAAK,OAAO;AACnB,cAAa;AACZ,SAAO,IAAI,mBAAmB;AAC9B,SAAO,IAAI,UAAU;AACrB,OAAK,MAAM,eAAe,qBAAsB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["optimisticUpdateQueue","confirmedUpdateQueue","continuityEpoch: number | undefined","k: any","v: any","myIdState__INTERNAL: AtomIO.RegularAtomToken<string | undefined>","myIdState: AtomIO.ReadonlyPureSelectorToken<string | undefined>","myUsernameState: AtomIO.RegularAtomToken<string | null>","optimisticUpdateQueue: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n>","confirmedUpdateQueue: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n>","optimisticUpdateQueue","confirmedUpdateQueue","k: any","v: any","transaction"],"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-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/realtime-client-stores/client-main-store.ts","../../src/realtime-client/realtime-client-stores/client-sync-store.ts","../../src/realtime-client/sync-continuity.ts"],"sourcesContent":["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\"\nimport {\n\tconfirmedUpdateQueue,\n\toptimisticUpdateQueue,\n} from \"atom.io/realtime-client\"\n\nexport const useRegisterAndAttemptConfirmedUpdate =\n\t(\n\t\tstore: RootStore,\n\t\tcontinuityKey: string,\n\t\tsocket: Socket,\n\t\toptimisticUpdates: AtomIO.TransactionOutcomeEvent<\n\t\t\tAtomIO.TransactionToken<Fn>\n\t\t>[],\n\t\tconfirmedUpdates: 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, optimisticUpdateQueue, (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, confirmedUpdateQueue, (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, confirmedUpdateQueue, (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 * as AtomIO from \"atom.io\"\nimport { storageSync } from \"atom.io/web\"\n\nexport const myIdState__INTERNAL: AtomIO.RegularAtomToken<string | undefined> =\n\tAtomIO.atom<string | undefined>({\n\t\tkey: `mySocketId__INTERNAL`,\n\t\tdefault: undefined,\n\t})\nexport const myIdState: AtomIO.ReadonlyPureSelectorToken<string | undefined> =\n\tAtomIO.selector<string | undefined>({\n\t\tkey: `mySocketId`,\n\t\tget: ({ get }) => get(myIdState__INTERNAL),\n\t})\n\nexport const myUsernameState: AtomIO.RegularAtomToken<string | null> =\n\tAtomIO.atom<string | null>({\n\t\tkey: `myName`,\n\t\tdefault: null,\n\t\teffects: [storageSync(globalThis.localStorage, JSON, `myUsername`)],\n\t})\n","import * as AtomIO from \"atom.io\"\n\nexport const optimisticUpdateQueue: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n> = AtomIO.atom<AtomIO.TransactionOutcomeEvent<any>[]>({\n\tkey: `updateQueue`,\n\tdefault: () => [],\n})\n\nexport const confirmedUpdateQueue: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n> = AtomIO.atom<AtomIO.TransactionOutcomeEvent<any>[]>({\n\tkey: `serverConfirmedUpdateQueue`,\n\tdefault: () => [],\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 {\n\tconfirmedUpdateQueue,\n\toptimisticUpdateQueue,\n} from \"atom.io/realtime-client\"\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\"\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, optimisticUpdateQueue)\n\tconst confirmedUpdates = getFromStore(store, confirmedUpdateQueue)\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, optimisticUpdateQueue, (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, optimisticUpdateQueue, (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":";;;;;;;;AAeA,MAAa,wCAEX,OACA,eACA,QACA,mBAGA,sBAKA,cACU;CACV,SAAS,eACR,kBAGA,iBAGO;AACP,QAAM,OAAO,KACZ,SACA,cACA,eACA,sBACA;AACD,eAAa,OAAOA,0BAAwB,UAAU;AACrD,SAAM,OAAO;AACb,UAAO;IACN;AACF,M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-
import {
|
|
1
|
+
import { Transceiver } from "atom.io/internal";
|
|
2
2
|
import * as AtomIO from "atom.io";
|
|
3
3
|
import { Canonical, Json } from "atom.io/json";
|
|
4
4
|
import * as React$1 from "react";
|
|
5
5
|
import { ContinuityToken } from "atom.io/realtime";
|
|
6
|
-
import { Socket } from "socket.io-client";
|
|
6
|
+
import { Socket as Socket$1 } from "socket.io-client";
|
|
7
7
|
|
|
8
8
|
//#region src/realtime-react/realtime-context.d.ts
|
|
9
9
|
type RealtimeServiceCounter = {
|
|
@@ -11,13 +11,13 @@ type RealtimeServiceCounter = {
|
|
|
11
11
|
dispose: () => void;
|
|
12
12
|
};
|
|
13
13
|
type RealtimeReactStore = {
|
|
14
|
-
socket: Socket | null;
|
|
14
|
+
socket: Socket$1 | null;
|
|
15
15
|
services: Map<string, RealtimeServiceCounter> | null;
|
|
16
16
|
};
|
|
17
17
|
declare const RealtimeContext: React$1.Context<RealtimeReactStore>;
|
|
18
18
|
declare const RealtimeProvider: React$1.FC<{
|
|
19
19
|
children: React$1.ReactNode;
|
|
20
|
-
socket: Socket | null;
|
|
20
|
+
socket: Socket$1 | null;
|
|
21
21
|
}>;
|
|
22
22
|
//#endregion
|
|
23
23
|
//#region src/realtime-react/use-pull-atom.d.ts
|
|
@@ -42,10 +42,7 @@ declare function usePullSelectorFamilyMember<T, K extends Canonical>(familyToken
|
|
|
42
42
|
declare function usePush<J extends Json.Serializable>(token: AtomIO.WritableToken<J>): (<New extends J>(next: New | ((old: J) => New)) => void) | null;
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region src/realtime-react/use-realtime-service.d.ts
|
|
45
|
-
declare function useRealtimeService(key: string, create: (socket: Socket) => () => void): void;
|
|
46
|
-
//#endregion
|
|
47
|
-
//#region src/realtime-react/use-server-action.d.ts
|
|
48
|
-
declare function useServerAction<F extends Fn>(token: AtomIO.TransactionToken<F>): (...parameters: Parameters<F>) => ReturnType<F>;
|
|
45
|
+
declare function useRealtimeService(key: string, create: (socket: Socket$1) => () => void): void;
|
|
49
46
|
//#endregion
|
|
50
47
|
//#region src/realtime-react/use-single-effect.d.ts
|
|
51
48
|
declare function useSingleEffect(effect: () => (() => void) | undefined | void, deps: unknown[]): void;
|
|
@@ -53,5 +50,5 @@ declare function useSingleEffect(effect: () => (() => void) | undefined | void,
|
|
|
53
50
|
//#region src/realtime-react/use-sync-continuity.d.ts
|
|
54
51
|
declare function useSyncContinuity(token: ContinuityToken): void;
|
|
55
52
|
//#endregion
|
|
56
|
-
export { RealtimeContext, RealtimeProvider, RealtimeReactStore, RealtimeServiceCounter, usePullAtom, usePullAtomFamilyMember, usePullMutable, usePullMutableAtomFamilyMember, usePullSelector, usePullSelectorFamilyMember, usePush, useRealtimeService,
|
|
53
|
+
export { RealtimeContext, RealtimeProvider, RealtimeReactStore, RealtimeServiceCounter, usePullAtom, usePullAtomFamilyMember, usePullMutable, usePullMutableAtomFamilyMember, usePullSelector, usePullSelectorFamilyMember, usePush, useRealtimeService, useSingleEffect, useSyncContinuity };
|
|
57
54
|
//# 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-service.ts","../../src/realtime-react/use-
|
|
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-service.ts","../../src/realtime-react/use-single-effect.ts","../../src/realtime-react/use-sync-continuity.ts"],"sourcesContent":[],"mappings":";;;;;;;;KAKY,sBAAA;;;;KAKA,kBAAA;UACH;EANT,QAAY,EAOD,GAPC,CAAA,MAAA,EAOW,sBAPX,CAAA,GAAA,IAAA;AAKZ,CAAA;AAAY,cAKCA,eALD,EAKkB,OAAA,CAAM,OALxB,CAKgC,kBALhC,CAAA;AACH,cAUIC,gBAVJ,EAUsB,OAAA,CAAM,EAV5B,CAAA;UACc,EAUZ,OAAA,CAAM,SAVM;QAAZ,EAWF,QAXE,GAAA,IAAA;CAAA,CAAA;;;iBCJK,sBAAsB,IAAA,CAAK,qBACnC,MAAA,CAAO,iBAAiB,KAC7B;;;iBCDa,kCACL,IAAA,CAAK,wBACL,mBACD,MAAA,CAAO,uBAAuB,GAAG,YAAY,QAAQ,KAAK;;;iBCJpD,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;;;iBCDa,yCAAyC,wBAC3C,MAAA,CAAO,oBAAoB,GAAG,SACtC,QAAQ,KACX;;;iBCHa,kBAAkB,IAAA,CAAK,qBAC/B,MAAA,CAAO,cAAc,mBACZ,SAAS,aAAa,MAAM;;;iBCL7B,kBAAA,+BAEE;;;iBCHF,eAAA;;;iBCEA,iBAAA,QAAyB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { isFn } from "
|
|
2
|
-
import { actUponStore, arbitrary, findInStore } from "atom.io/internal";
|
|
1
|
+
import { findInStore, isFn } from "atom.io/internal";
|
|
3
2
|
import * as React$1 from "react";
|
|
4
3
|
import { jsx } from "react/jsx-runtime";
|
|
5
4
|
import { StoreContext, useI, useO } from "atom.io/react";
|
|
@@ -36,9 +35,7 @@ const RealtimeProvider = ({ children, socket }) => {
|
|
|
36
35
|
//#endregion
|
|
37
36
|
//#region src/realtime-react/use-single-effect.ts
|
|
38
37
|
function useSingleEffect(effect, deps) {
|
|
39
|
-
|
|
40
|
-
const isInDev = globalEnv?.NODE_ENV === `development`;
|
|
41
|
-
if (isInDev) {
|
|
38
|
+
if (globalThis[`env`]?.NODE_ENV === `development`) {
|
|
42
39
|
const cleanupRef = React$1.useRef(false);
|
|
43
40
|
React$1.useEffect(() => {
|
|
44
41
|
let cleanupFn = cleanupRef.current;
|
|
@@ -61,10 +58,9 @@ function useRealtimeService(key, create) {
|
|
|
61
58
|
let service = services?.get(key);
|
|
62
59
|
if (service) ++service.consumerCount;
|
|
63
60
|
else if (socket) {
|
|
64
|
-
const dispose = create(socket);
|
|
65
61
|
service = {
|
|
66
62
|
consumerCount: 1,
|
|
67
|
-
dispose
|
|
63
|
+
dispose: create(socket)
|
|
68
64
|
};
|
|
69
65
|
services?.set(key, service);
|
|
70
66
|
}
|
|
@@ -141,14 +137,6 @@ function usePush(token) {
|
|
|
141
137
|
return mutex ? setter : null;
|
|
142
138
|
}
|
|
143
139
|
|
|
144
|
-
//#endregion
|
|
145
|
-
//#region src/realtime-react/use-server-action.ts
|
|
146
|
-
function useServerAction(token) {
|
|
147
|
-
const store = React$1.useContext(StoreContext);
|
|
148
|
-
useRealtimeService(`tx:${token.key}`, (socket) => RTC.serverAction(store, socket, token));
|
|
149
|
-
return actUponStore(store, token, arbitrary());
|
|
150
|
-
}
|
|
151
|
-
|
|
152
140
|
//#endregion
|
|
153
141
|
//#region src/realtime-react/use-sync-continuity.ts
|
|
154
142
|
function useSyncContinuity(token) {
|
|
@@ -159,5 +147,5 @@ function useSyncContinuity(token) {
|
|
|
159
147
|
}
|
|
160
148
|
|
|
161
149
|
//#endregion
|
|
162
|
-
export { RealtimeContext, RealtimeProvider, usePullAtom, usePullAtomFamilyMember, usePullMutable, usePullMutableAtomFamilyMember, usePullSelector, usePullSelectorFamilyMember, usePush, useRealtimeService,
|
|
150
|
+
export { RealtimeContext, RealtimeProvider, usePullAtom, usePullAtomFamilyMember, usePullMutable, usePullMutableAtomFamilyMember, usePullSelector, usePullSelectorFamilyMember, usePush, useRealtimeService, useSingleEffect, useSyncContinuity };
|
|
163
151
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["RealtimeContext: React.Context<RealtimeReactStore>","React","RealtimeProvider: React.FC<{\n\tchildren: React.ReactNode\n\tsocket: Socket | null\n}>","React","React","React","React","React","React","React","React","React","React","React"],"sources":["../../src/realtime-react/realtime-context.tsx","../../src/realtime-react/use-single-effect.ts","../../src/realtime-react/use-realtime-service.ts","../../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-server-action.ts","../../src/realtime-react/use-sync-continuity.ts"],"sourcesContent":["import { useI } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\nimport type { Socket } from \"socket.io-client\"\n\nexport type RealtimeServiceCounter = {\n\tconsumerCount: number\n\tdispose: () => void\n}\n\nexport type RealtimeReactStore = {\n\tsocket: Socket | null\n\tservices: Map<string, RealtimeServiceCounter> | null\n}\n\nexport const RealtimeContext: React.Context<RealtimeReactStore> =\n\tReact.createContext({\n\t\tsocket: null,\n\t\tservices: null,\n\t})\n\nexport const RealtimeProvider: React.FC<{\n\tchildren: React.ReactNode\n\tsocket: Socket | null\n}> = ({ children, socket }) => {\n\tconst services = React.useRef(\n\t\tnew Map<string, RealtimeServiceCounter>(),\n\t).current\n\tconst setMyId = useI(RTC.myIdState__INTERNAL)\n\tReact.useEffect(() => {\n\t\tsetMyId(socket?.id)\n\t\tsocket?.on(`connect`, () => {\n\t\t\tsetMyId(socket.id)\n\t\t})\n\t\tsocket?.on(`disconnect`, () => {\n\t\t\tsetMyId(undefined)\n\t\t})\n\t}, [socket, setMyId])\n\treturn (\n\t\t<RealtimeContext.Provider value={{ socket, services }}>\n\t\t\t{children}\n\t\t</RealtimeContext.Provider>\n\t)\n}\n","/** biome-ignore-all lint/correctness/useHookAtTopLevel: intentional */\n\nimport { isFn } from \"atom.io/internal/is-fn\"\nimport * as React from \"react\"\n\nexport function useSingleEffect(\n\teffect: () => (() => void) | undefined | void,\n\tdeps: unknown[],\n): void {\n\tconst globalEnv = (globalThis as unknown as { env: any })[`env`]\n\tconst isInDev = globalEnv?.NODE_ENV === `development`\n\tif (isInDev) {\n\t\tconst cleanupRef = React.useRef<boolean | (() => void)>(false)\n\t\tReact.useEffect(() => {\n\t\t\tlet cleanupFn = cleanupRef.current\n\t\t\tif (cleanupFn === false) {\n\t\t\t\tcleanupFn = effect() ?? true\n\t\t\t\tcleanupRef.current = cleanupFn\n\t\t\t} else {\n\t\t\t\treturn () => {\n\t\t\t\t\tif (isFn(cleanupFn)) cleanupFn()\n\t\t\t\t\tcleanupRef.current = false\n\t\t\t\t}\n\t\t\t}\n\t\t}, deps)\n\t} else {\n\t\tReact.useEffect(effect, deps)\n\t}\n}\n","import * as React from \"react\"\nimport type { Socket } from \"socket.io-client\"\n\nimport { RealtimeContext } from \"./realtime-context\"\nimport { useSingleEffect } from \"./use-single-effect\"\n\nexport function useRealtimeService(\n\tkey: string,\n\tcreate: (socket: Socket) => () => void,\n): void {\n\tconst { socket, services } = React.useContext(RealtimeContext)\n\tuseSingleEffect(() => {\n\t\tlet service = services?.get(key)\n\t\tif (service) {\n\t\t\t++service.consumerCount\n\t\t} else if (socket) {\n\t\t\tconst dispose = create(socket)\n\t\t\tservice = { consumerCount: 1, dispose }\n\t\t\tservices?.set(key, service)\n\t\t}\n\t\treturn () => {\n\t\t\tif (service) {\n\t\t\t\t--service.consumerCount\n\t\t\t\tif (service.consumerCount === 0) {\n\t\t\t\t\tservice.dispose?.()\n\t\t\t\t\tservices?.delete(key)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [socket, key])\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\nimport { StoreContext, useO } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { useRealtimeService } from \"./use-realtime-service\"\n\nexport function usePullAtom<J extends Json.Serializable>(\n\ttoken: AtomIO.RegularAtomToken<J>,\n): J {\n\tconst store = React.useContext(StoreContext)\n\tuseRealtimeService(`pull:${token.key}`, (socket) =>\n\t\tRTC.pullAtom(store, socket, token),\n\t)\n\treturn useO(token)\n}\n","import type * as AtomIO from \"atom.io\"\nimport { findInStore } from \"atom.io/internal\"\nimport type { Canonical, Json } from \"atom.io/json\"\nimport { StoreContext, useO } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { useRealtimeService } from \"./use-realtime-service\"\n\nexport function usePullAtomFamilyMember<\n\tJ extends Json.Serializable,\n\tK extends Canonical,\n>(family: AtomIO.RegularAtomFamilyToken<J, K>, subKey: NoInfer<K>): J {\n\tconst store = React.useContext(StoreContext)\n\tconst token = findInStore(store, family, subKey)\n\tuseRealtimeService(`pull:${token.key}`, (socket) =>\n\t\tRTC.pullAtomFamilyMember(store, socket, family, subKey),\n\t)\n\treturn useO(token)\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Transceiver } from \"atom.io/internal\"\nimport { StoreContext, useO } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { useRealtimeService } from \"./use-realtime-service\"\n\nexport function usePullMutable<T extends Transceiver<any, any, any>>(\n\ttoken: AtomIO.MutableAtomToken<T>,\n): T {\n\tconst store = React.useContext(StoreContext)\n\tuseRealtimeService(`pull:${token.key}`, (socket) =>\n\t\tRTC.pullMutableAtom(store, socket, token),\n\t)\n\treturn useO(token)\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Transceiver } from \"atom.io/internal\"\nimport { findInStore } from \"atom.io/internal\"\nimport type { Canonical } from \"atom.io/json\"\nimport { StoreContext, useO } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { useRealtimeService } from \"./use-realtime-service\"\n\nexport function usePullMutableAtomFamilyMember<\n\tT extends Transceiver<any, any, any>,\n\tK extends Canonical,\n>(familyToken: AtomIO.MutableAtomFamilyToken<T, K>, key: NoInfer<K>): T {\n\tconst store = React.useContext(StoreContext)\n\tconst token = findInStore(store, familyToken, key)\n\tuseRealtimeService(`pull:${token.key}`, (socket) =>\n\t\tRTC.pullMutableAtomFamilyMember(store, socket, familyToken, key),\n\t)\n\treturn useO(token)\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\nimport { StoreContext, useO } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { useRealtimeService } from \"./use-realtime-service\"\n\nexport function usePullSelector<J extends Json.Serializable>(\n\ttoken: AtomIO.SelectorToken<J>,\n): J {\n\tconst store = React.useContext(StoreContext)\n\tuseRealtimeService(`pull:${token.key}`, (socket) =>\n\t\tRTC.pullSelector(store, socket, token),\n\t)\n\treturn useO(token)\n}\n","import type * as AtomIO from \"atom.io\"\nimport { findInStore } from \"atom.io/internal\"\nimport type { Canonical } from \"atom.io/json\"\nimport { StoreContext, useO } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { useRealtimeService } from \"./use-realtime-service\"\n\nexport function usePullSelectorFamilyMember<T, K extends Canonical>(\n\tfamilyToken: AtomIO.SelectorFamilyToken<T, K>,\n\tkey: NoInfer<K>,\n): T {\n\tconst store = React.useContext(StoreContext)\n\tconst token = findInStore(store, familyToken, key)\n\tuseRealtimeService(`pull:${token.key}`, (socket) =>\n\t\tRTC.pullSelectorFamilyMember(store, socket, familyToken, key),\n\t)\n\n\treturn useO(token)\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\nimport { StoreContext, useI, useO } from \"atom.io/react\"\nimport * as RT from \"atom.io/realtime\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { useRealtimeService } from \"./use-realtime-service\"\n\nexport function usePush<J extends Json.Serializable>(\n\ttoken: AtomIO.WritableToken<J>,\n): (<New extends J>(next: New | ((old: J) => New)) => void) | null {\n\tconst store = React.useContext(StoreContext)\n\tuseRealtimeService(`push:${token.key}`, (socket) =>\n\t\tRTC.pushState(store, socket, token),\n\t)\n\tconst mutex = useO(RT.mutexAtoms, token.key)\n\tconst setter = useI(token)\n\n\treturn mutex ? setter : null\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Fn } from \"atom.io/internal\"\nimport { actUponStore, arbitrary } from \"atom.io/internal\"\nimport { StoreContext } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { useRealtimeService } from \"./use-realtime-service\"\n\nexport function useServerAction<F extends Fn>(\n\ttoken: AtomIO.TransactionToken<F>,\n): (...parameters: Parameters<F>) => ReturnType<F> {\n\tconst store = React.useContext(StoreContext)\n\n\tuseRealtimeService(`tx:${token.key}`, (socket) =>\n\t\tRTC.serverAction(store, socket, token),\n\t)\n\treturn actUponStore(store, token, arbitrary())\n}\n","import { StoreContext } from \"atom.io/react\"\nimport type { ContinuityToken } from \"atom.io/realtime\"\nimport { syncContinuity } from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { useRealtimeService } from \"./use-realtime-service\"\n\nexport function useSyncContinuity(token: ContinuityToken): void {\n\tconst store = React.useContext(StoreContext)\n\tuseRealtimeService(`tx-sync:${token.key}`, (socket) => {\n\t\treturn syncContinuity(store, socket, token)\n\t})\n}\n"],"mappings":";;;;;;;;;;AAeA,MAAaA,kBACZC,QAAM,cAAc;CACnB,QAAQ;CACR,UAAU;;AAGZ,MAAaC,oBAGP,EAAE,UAAU,aAAa;CAC9B,MAAM,WAAWD,QAAM,uBACtB,IAAI,OACH;CACF,MAAM,UAAU,KAAK,IAAI;AACzB,SAAM,gBAAgB;AACrB,UAAQ,QAAQ;AAChB,UAAQ,GAAG,iBAAiB;AAC3B,WAAQ,OAAO;;AAEhB,UAAQ,GAAG,oBAAoB;AAC9B,WAAQ;;IAEP,CAAC,QAAQ;AACZ,QACC,oBAAC,gBAAgB;EAAS,OAAO;GAAE;GAAQ;;EACzC;;;;;;ACnCJ,SAAgB,gBACf,QACA,MACO;CACP,MAAM,YAAa,WAAuC;CAC1D,MAAM,UAAU,WAAW,aAAa;AACxC,KAAI,SAAS;EACZ,MAAM,aAAaE,QAAM,OAA+B;AACxD,UAAM,gBAAgB;GACrB,IAAI,YAAY,WAAW;AAC3B,OAAI,cAAc,OAAO;AACxB,gBAAY,YAAY;AACxB,eAAW,UAAU;SAErB,cAAa;AACZ,QAAI,KAAK,WAAY;AACrB,eAAW,UAAU;;KAGrB;OAEH,SAAM,UAAU,QAAQ;;;;;ACpB1B,SAAgB,mBACf,KACA,QACO;CACP,MAAM,EAAE,QAAQ,aAAaC,QAAM,WAAW;AAC9C,uBAAsB;EACrB,IAAI,UAAU,UAAU,IAAI;AAC5B,MAAI,QACH,GAAE,QAAQ;WACA,QAAQ;GAClB,MAAM,UAAU,OAAO;AACvB,aAAU;IAAE,eAAe;IAAG;;AAC9B,aAAU,IAAI,KAAK;;AAEpB,eAAa;AACZ,OAAI,SAAS;AACZ,MAAE,QAAQ;AACV,QAAI,QAAQ,kBAAkB,GAAG;AAChC,aAAQ;AACR,e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,KAAK,GAAG,YAAY,MAAM;CACxC,MAAM,SAAS,KAAK;AAEpB,QAAO,QAAQ,SAAS;;;;;ACVzB,SAAgB,gBACf,OACkD;CAClD,MAAM,QAAQC,QAAM,WAAW;AAE/B,oBAAmB,MAAM,MAAM,QAAQ,WACtC,IAAI,aAAa,OAAO,QAAQ;AAEjC,QAAO,aAAa,OAAO,OAAO;;;;;ACVnC,SAAgB,kBAAkB,OAA8B;CAC/D,MAAM,QAAQC,QAAM,WAAW;AAC/B,oBAAmB,WAAW,MAAM,QAAQ,WAAW;AACtD,SAAO,eAAe,OAAO,QAAQ"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["RealtimeContext: React.Context<RealtimeReactStore>","React","RealtimeProvider: React.FC<{\n\tchildren: React.ReactNode\n\tsocket: Socket | null\n}>","React","React","React","React","React","React","React","React","React","React"],"sources":["../../src/realtime-react/realtime-context.tsx","../../src/realtime-react/use-single-effect.ts","../../src/realtime-react/use-realtime-service.ts","../../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-sync-continuity.ts"],"sourcesContent":["import { useI } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\nimport type { Socket } from \"socket.io-client\"\n\nexport type RealtimeServiceCounter = {\n\tconsumerCount: number\n\tdispose: () => void\n}\n\nexport type RealtimeReactStore = {\n\tsocket: Socket | null\n\tservices: Map<string, RealtimeServiceCounter> | null\n}\n\nexport const RealtimeContext: React.Context<RealtimeReactStore> =\n\tReact.createContext({\n\t\tsocket: null,\n\t\tservices: null,\n\t})\n\nexport const RealtimeProvider: React.FC<{\n\tchildren: React.ReactNode\n\tsocket: Socket | null\n}> = ({ children, socket }) => {\n\tconst services = React.useRef(\n\t\tnew Map<string, RealtimeServiceCounter>(),\n\t).current\n\tconst setMyId = useI(RTC.myIdState__INTERNAL)\n\tReact.useEffect(() => {\n\t\tsetMyId(socket?.id)\n\t\tsocket?.on(`connect`, () => {\n\t\t\tsetMyId(socket.id)\n\t\t})\n\t\tsocket?.on(`disconnect`, () => {\n\t\t\tsetMyId(undefined)\n\t\t})\n\t}, [socket, setMyId])\n\treturn (\n\t\t<RealtimeContext.Provider value={{ socket, services }}>\n\t\t\t{children}\n\t\t</RealtimeContext.Provider>\n\t)\n}\n","/** biome-ignore-all lint/correctness/useHookAtTopLevel: intentional */\n\nimport { isFn } from \"atom.io/internal\"\nimport * as React from \"react\"\n\nexport function useSingleEffect(\n\teffect: () => (() => void) | undefined | void,\n\tdeps: unknown[],\n): void {\n\tconst globalEnv = (globalThis as unknown as { env: any })[`env`]\n\tconst isInDev = globalEnv?.NODE_ENV === `development`\n\tif (isInDev) {\n\t\tconst cleanupRef = React.useRef<boolean | (() => void)>(false)\n\t\tReact.useEffect(() => {\n\t\t\tlet cleanupFn = cleanupRef.current\n\t\t\tif (cleanupFn === false) {\n\t\t\t\tcleanupFn = effect() ?? true\n\t\t\t\tcleanupRef.current = cleanupFn\n\t\t\t} else {\n\t\t\t\treturn () => {\n\t\t\t\t\tif (isFn(cleanupFn)) cleanupFn()\n\t\t\t\t\tcleanupRef.current = false\n\t\t\t\t}\n\t\t\t}\n\t\t}, deps)\n\t} else {\n\t\tReact.useEffect(effect, deps)\n\t}\n}\n","import * as React from \"react\"\nimport type { Socket } from \"socket.io-client\"\n\nimport { RealtimeContext } from \"./realtime-context\"\nimport { useSingleEffect } from \"./use-single-effect\"\n\nexport function useRealtimeService(\n\tkey: string,\n\tcreate: (socket: Socket) => () => void,\n): void {\n\tconst { socket, services } = React.useContext(RealtimeContext)\n\tuseSingleEffect(() => {\n\t\tlet service = services?.get(key)\n\t\tif (service) {\n\t\t\t++service.consumerCount\n\t\t} else if (socket) {\n\t\t\tconst dispose = create(socket)\n\t\t\tservice = { consumerCount: 1, dispose }\n\t\t\tservices?.set(key, service)\n\t\t}\n\t\treturn () => {\n\t\t\tif (service) {\n\t\t\t\t--service.consumerCount\n\t\t\t\tif (service.consumerCount === 0) {\n\t\t\t\t\tservice.dispose?.()\n\t\t\t\t\tservices?.delete(key)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [socket, key])\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\nimport { StoreContext, useO } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { useRealtimeService } from \"./use-realtime-service\"\n\nexport function usePullAtom<J extends Json.Serializable>(\n\ttoken: AtomIO.RegularAtomToken<J>,\n): J {\n\tconst store = React.useContext(StoreContext)\n\tuseRealtimeService(`pull:${token.key}`, (socket) =>\n\t\tRTC.pullAtom(store, socket, token),\n\t)\n\treturn useO(token)\n}\n","import type * as AtomIO from \"atom.io\"\nimport { findInStore } from \"atom.io/internal\"\nimport type { Canonical, Json } from \"atom.io/json\"\nimport { StoreContext, useO } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { useRealtimeService } from \"./use-realtime-service\"\n\nexport function usePullAtomFamilyMember<\n\tJ extends Json.Serializable,\n\tK extends Canonical,\n>(family: AtomIO.RegularAtomFamilyToken<J, K>, subKey: NoInfer<K>): J {\n\tconst store = React.useContext(StoreContext)\n\tconst token = findInStore(store, family, subKey)\n\tuseRealtimeService(`pull:${token.key}`, (socket) =>\n\t\tRTC.pullAtomFamilyMember(store, socket, family, subKey),\n\t)\n\treturn useO(token)\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Transceiver } from \"atom.io/internal\"\nimport { StoreContext, useO } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { useRealtimeService } from \"./use-realtime-service\"\n\nexport function usePullMutable<T extends Transceiver<any, any, any>>(\n\ttoken: AtomIO.MutableAtomToken<T>,\n): T {\n\tconst store = React.useContext(StoreContext)\n\tuseRealtimeService(`pull:${token.key}`, (socket) =>\n\t\tRTC.pullMutableAtom(store, socket, token),\n\t)\n\treturn useO(token)\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Transceiver } from \"atom.io/internal\"\nimport { findInStore } from \"atom.io/internal\"\nimport type { Canonical } from \"atom.io/json\"\nimport { StoreContext, useO } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { useRealtimeService } from \"./use-realtime-service\"\n\nexport function usePullMutableAtomFamilyMember<\n\tT extends Transceiver<any, any, any>,\n\tK extends Canonical,\n>(familyToken: AtomIO.MutableAtomFamilyToken<T, K>, key: NoInfer<K>): T {\n\tconst store = React.useContext(StoreContext)\n\tconst token = findInStore(store, familyToken, key)\n\tuseRealtimeService(`pull:${token.key}`, (socket) =>\n\t\tRTC.pullMutableAtomFamilyMember(store, socket, familyToken, key),\n\t)\n\treturn useO(token)\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\nimport { StoreContext, useO } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { useRealtimeService } from \"./use-realtime-service\"\n\nexport function usePullSelector<J extends Json.Serializable>(\n\ttoken: AtomIO.SelectorToken<J>,\n): J {\n\tconst store = React.useContext(StoreContext)\n\tuseRealtimeService(`pull:${token.key}`, (socket) =>\n\t\tRTC.pullSelector(store, socket, token),\n\t)\n\treturn useO(token)\n}\n","import type * as AtomIO from \"atom.io\"\nimport { findInStore } from \"atom.io/internal\"\nimport type { Canonical } from \"atom.io/json\"\nimport { StoreContext, useO } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { useRealtimeService } from \"./use-realtime-service\"\n\nexport function usePullSelectorFamilyMember<T, K extends Canonical>(\n\tfamilyToken: AtomIO.SelectorFamilyToken<T, K>,\n\tkey: NoInfer<K>,\n): T {\n\tconst store = React.useContext(StoreContext)\n\tconst token = findInStore(store, familyToken, key)\n\tuseRealtimeService(`pull:${token.key}`, (socket) =>\n\t\tRTC.pullSelectorFamilyMember(store, socket, familyToken, key),\n\t)\n\n\treturn useO(token)\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\nimport { StoreContext, useI, useO } from \"atom.io/react\"\nimport * as RT from \"atom.io/realtime\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { useRealtimeService } from \"./use-realtime-service\"\n\nexport function usePush<J extends Json.Serializable>(\n\ttoken: AtomIO.WritableToken<J>,\n): (<New extends J>(next: New | ((old: J) => New)) => void) | null {\n\tconst store = React.useContext(StoreContext)\n\tuseRealtimeService(`push:${token.key}`, (socket) =>\n\t\tRTC.pushState(store, socket, token),\n\t)\n\tconst mutex = useO(RT.mutexAtoms, token.key)\n\tconst setter = useI(token)\n\n\treturn mutex ? setter : null\n}\n","import { StoreContext } from \"atom.io/react\"\nimport type { ContinuityToken } from \"atom.io/realtime\"\nimport { syncContinuity } from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { useRealtimeService } from \"./use-realtime-service\"\n\nexport function useSyncContinuity(token: ContinuityToken): void {\n\tconst store = React.useContext(StoreContext)\n\tuseRealtimeService(`tx-sync:${token.key}`, (socket) => {\n\t\treturn syncContinuity(store, socket, token)\n\t})\n}\n"],"mappings":";;;;;;;;;AAeA,MAAaA,kBACZC,QAAM,cAAc;CACnB,QAAQ;CACR,UAAU;CACV,CAAC;AAEH,MAAaC,oBAGP,EAAE,UAAU,aAAa;CAC9B,MAAM,WAAWD,QAAM,uBACtB,IAAI,KAAqC,CACzC,CAAC;CACF,MAAM,UAAU,KAAK,IAAI,oBAAoB;AAC7C,SAAM,gBAAgB;AACrB,UAAQ,QAAQ,GAAG;AACnB,UAAQ,GAAG,iBAAiB;AAC3B,WAAQ,OAAO,GAAG;IAC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