atom.io 0.34.0 → 0.34.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eslint-plugin/index.js +1 -2
- package/dist/eslint-plugin/index.js.map +1 -1
- package/dist/internal/index.d.ts +6 -1
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +26 -22
- package/dist/internal/index.js.map +1 -1
- package/dist/json/index.d.ts +3 -0
- package/dist/json/index.d.ts.map +1 -1
- package/dist/json/index.js.map +1 -1
- package/dist/main/index.d.ts +405 -23
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +107 -11
- package/dist/main/index.js.map +1 -1
- package/dist/realtime-client/index.js +4 -8
- package/dist/realtime-client/index.js.map +1 -1
- package/dist/realtime-server/index.js +1 -1
- package/dist/realtime-server/index.js.map +1 -1
- package/package.json +6 -6
- package/src/internal/join/create-join.ts +27 -0
- package/src/internal/join/index.ts +1 -0
- package/src/internal/junction.ts +2 -0
- package/src/json/index.ts +3 -0
- package/src/main/atom.ts +54 -13
- package/src/main/dispose-state.ts +8 -2
- package/src/main/find-state.ts +44 -14
- package/src/main/get-state.ts +2 -2
- package/src/main/index.ts +8 -0
- package/src/main/join.ts +79 -22
- package/src/main/realm.ts +50 -4
- package/src/main/selector.ts +116 -6
- package/src/main/subscribe.ts +31 -1
- package/src/main/timeline.ts +17 -0
- package/src/main/transaction.ts +39 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["event: string","emit: <Event extends keyof I>(\n\t\t\tevent: Event,\n\t\t\t...args: I[Event]\n\t\t) => CustomSocket<I, O>","event: Event","listener: (...args: O[Event]) => void","listener: (event: string, ...args: Json.Array) => void","listener?: (...args: O[Event]) => void","arg: Json.Serializable","process: ChildProcessWithoutNullStreams","key: string","logger?: Pick<Console, `error` | `info` | `warn`>","err: { code: string }","process","buffer: EventBuffer<string, I[Event]>","id: string","buffer: EventBuffer<string, I[Event]>","attachServices: (socket: SubjectSocket<any, any>) => (() => void) | void","roomArgumentsAtoms: RegularAtomFamilyToken<RoomArguments, string>","roomSelectors: ReadonlyPureSelectorFamilyToken<\n\tLoadable<ChildSocket<any, any>>,\n\tstring\n>","data: Buffer","createRoomTX: AtomIO.TransactionToken<\n\t(\n\t\troomId: string,\n\t\tscript: string,\n\t\toptions?: string[],\n\t) => Loadable<ChildSocket<any, any>>\n>","args: RoomArguments","joinRoomTX: AtomIO.TransactionToken<\n\t(roomId: string, userId: string, enteredAtEpoch: number) => UserInRoomMeta\n>","leaveRoomTX: AtomIO.TransactionToken<\n\t(roomId: string, userId: string) => void\n>","destroyRoomTX: AtomIO.TransactionToken<(roomId: string) => void>","visibleStateKeys: string[]","updates: TransactionUpdateContent[]","redactorAtoms: RegularAtomFamilyToken<\n\t{\n\t\tocclude: (updates: TransactionUpdateContent[]) => TransactionUpdateContent[]\n\t},\n\tUserKey\n>","userUnacknowledgedQueues: RegularAtomFamilyToken<\n\tContinuitySyncTransactionUpdate[],\n\tUserKey\n>","socketAtoms: RegularAtomFamilyToken<Socket | null, SocketKey>","socketIndex: MutableAtomToken<\n\tSetRTX<SocketKey>,\n\tSetRTXJson<SocketKey>\n>","userIndex: MutableAtomToken<\n\tSetRTX<UserKey>,\n\tSetRTXJson<UserKey>\n>","usersOfSockets: JoinToken<\n\t`user`,\n\tUserKey,\n\t`socket`,\n\tSocketKey,\n\t`1:1`\n>","store: Store","continuity: ContinuityToken","userKey: UserKey","socket: Socket | null","initialPayload: Json.Serializable[]","atom","store: Store","continuity: ContinuityToken","userKey: string","store: Store","continuity: ContinuityToken","userKey: string","userUnacknowledgedUpdates: ContinuitySyncTransactionUpdate[]","store: Store","continuity: ContinuityToken","userKey: UserKey","socket: Socket | null","unsubscribeFunctions: (() => void)[]","atom","store: Store","continuity: ContinuityToken","userKey: UserKey","socket: Socket | null","unsubFns: (() => void)[]","socket: Socket | null","unsubscribeFunctions: (() => void)[]","tx: AtomIO.TransactionToken<F>","update: Pick<AtomIO.TransactionUpdate<F>, `id` | `params`>","family: AtomIO.RegularAtomFamilyToken<J, K>","index: AtomIO.ReadableToken<Iterable<K>>","key: string","subKey: K","family: AtomIO.MutableAtomFamilyToken<T, J, K>","index: AtomIO.ReadableToken<Iterable<K>>","key: string","subKey: K","token: AtomIO.MutableAtomToken<Core, SerializableCore>","unsubscribeFromStateUpdates: (() => void) | null","token: AtomIO.WritableToken<J>","unsubscribeFromStateUpdates: (() => void) | undefined","token: WritableToken<J>","newValue: J"],"sources":["../../src/realtime-server/ipc-sockets/custom-socket.ts","../../src/realtime-server/ipc-sockets/child-socket.ts","../../src/realtime-server/ipc-sockets/parent-socket.ts","../../src/realtime-server/realtime-server-stores/server-room-external-store.ts","../../src/realtime-server/realtime-server-stores/server-room-external-actions.ts","../../src/realtime-server/realtime-server-stores/server-sync-store.ts","../../src/realtime-server/realtime-server-stores/server-user-store.ts","../../src/realtime-server/continuity/prepare-to-send-initial-payload.ts","../../src/realtime-server/continuity/prepare-to-serve-transaction-request.ts","../../src/realtime-server/continuity/prepare-to-track-client-acknowledgement.ts","../../src/realtime-server/continuity/subscribe-to-continuity-actions.ts","../../src/realtime-server/continuity/subscribe-to-continuity-perpectives.ts","../../src/realtime-server/continuity/prepare-to-sync-realtime-continuity.ts","../../src/realtime-server/realtime-action-receiver.ts","../../src/realtime-server/realtime-family-provider.ts","../../src/realtime-server/realtime-mutable-family-provider.ts","../../src/realtime-server/realtime-mutable-provider.ts","../../src/realtime-server/realtime-state-provider.ts","../../src/realtime-server/realtime-state-receiver.ts"],"sourcesContent":["import type { Json, stringified } from \"atom.io/json\"\n\nimport type { Socket } from \"..\"\n\nexport type Events = Json.Object<string, Json.Serializable[]>\n\nexport type StringifiedEvent<\n\tKey extends string,\n\tParams extends Json.Serializable[],\n> = stringified<[Key, ...Params]>\n\nexport interface EventBuffer<\n\tKey extends string,\n\tParams extends Json.Serializable[],\n> extends Buffer {\n\ttoString(): StringifiedEvent<Key, Params>\n}\n\nexport class CustomSocket<I extends Events, O extends Events> implements Socket {\n\tprotected listeners: Map<keyof O, Set<(...args: Json.Array) => void>>\n\tprotected globalListeners: Set<(event: string, ...args: Json.Array) => void>\n\tprotected handleEvent<Event extends keyof I>(\n\t\tevent: string,\n\t\t...args: I[Event]\n\t): void {\n\t\tfor (const listener of this.globalListeners) {\n\t\t\tlistener(event, ...args)\n\t\t}\n\t\tconst listeners = this.listeners.get(event)\n\t\tif (listeners) {\n\t\t\tfor (const listener of listeners) {\n\t\t\t\tlistener(...args)\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic id = `no_id_retrieved`\n\tpublic emit: <Event extends keyof I>(\n\t\tevent: Event,\n\t\t...args: I[Event]\n\t) => CustomSocket<I, O>\n\n\tpublic constructor(\n\t\temit: <Event extends keyof I>(\n\t\t\tevent: Event,\n\t\t\t...args: I[Event]\n\t\t) => CustomSocket<I, O>,\n\t) {\n\t\tthis.emit = emit\n\t\tthis.listeners = new Map()\n\t\tthis.globalListeners = new Set()\n\t}\n\n\tpublic on<Event extends keyof O>(\n\t\tevent: Event,\n\t\tlistener: (...args: O[Event]) => void,\n\t): this {\n\t\tconst listeners = this.listeners.get(event)\n\t\tif (listeners) {\n\t\t\tlisteners.add(listener)\n\t\t} else {\n\t\t\tthis.listeners.set(event, new Set([listener]))\n\t\t}\n\t\treturn this\n\t}\n\n\tpublic onAny(listener: (event: string, ...args: Json.Array) => void): this {\n\t\tthis.globalListeners.add(listener)\n\t\treturn this\n\t}\n\n\tpublic off<Event extends keyof O>(\n\t\tevent: Event,\n\t\tlistener?: (...args: O[Event]) => void,\n\t): this {\n\t\tconst listeners = this.listeners.get(event)\n\t\tif (listeners) {\n\t\t\tif (listener) {\n\t\t\t\tlisteners.delete(listener)\n\t\t\t} else {\n\t\t\t\tthis.listeners.delete(event)\n\t\t\t}\n\t\t}\n\t\treturn this\n\t}\n\n\tpublic offAny(listener: (event: string, ...args: Json.Array) => void): this {\n\t\tthis.globalListeners.delete(listener)\n\t\treturn this\n\t}\n}\n","import type { ChildProcessWithoutNullStreams } from \"node:child_process\"\n\nimport type { Json } from \"atom.io/json\"\nimport { parseJson } from \"atom.io/json\"\n\nimport type { EventBuffer, Events } from \"./custom-socket\"\nimport { CustomSocket } from \"./custom-socket\"\n\n/* eslint-disable no-console */\n\nexport class ChildSocket<\n\tI extends Events,\n\tO extends Events,\n> extends CustomSocket<I, O> {\n\tprotected incompleteData = ``\n\tprotected unprocessedEvents: string[] = []\n\tprotected incompleteLog = ``\n\tprotected unprocessedLogs: string[] = []\n\n\tpublic id = `#####`\n\n\tpublic process: ChildProcessWithoutNullStreams\n\tpublic key: string\n\tpublic logger: Pick<Console, `error` | `info` | `warn`>\n\n\tprotected handleLog(arg: Json.Serializable): void {\n\t\tif (Array.isArray(arg)) {\n\t\t\tconst [level, ...rest] = arg\n\t\t\tswitch (level) {\n\t\t\t\tcase `i`:\n\t\t\t\t\tthis.logger.info(...rest)\n\t\t\t\t\tbreak\n\t\t\t\tcase `w`:\n\t\t\t\t\tthis.logger.warn(...rest)\n\t\t\t\t\tbreak\n\t\t\t\tcase `e`:\n\t\t\t\t\tthis.logger.error(...rest)\n\t\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic constructor(\n\t\tprocess: ChildProcessWithoutNullStreams,\n\t\tkey: string,\n\t\tlogger?: Pick<Console, `error` | `info` | `warn`>,\n\t) {\n\t\tsuper((event, ...args) => {\n\t\t\tconst stringifiedEvent = JSON.stringify([event, ...args]) + `\\x03`\n\t\t\tconst errorHandler = (err: { code: string }) => {\n\t\t\t\tif (err.code === `EPIPE`) {\n\t\t\t\t\tconsole.error(`EPIPE error during write`, this.process.stdin)\n\t\t\t\t}\n\t\t\t\tthis.process.stdin.removeListener(`error`, errorHandler)\n\t\t\t}\n\n\t\t\tthis.process.stdin.once(`error`, errorHandler)\n\t\t\tthis.process.stdin.write(stringifiedEvent)\n\n\t\t\treturn this\n\t\t})\n\t\tthis.process = process\n\t\tthis.key = key\n\t\tthis.logger = logger ?? {\n\t\t\tinfo: (...args: unknown[]) => {\n\t\t\t\tconsole.info(this.id, this.key, ...args)\n\t\t\t},\n\t\t\twarn: (...args: unknown[]) => {\n\t\t\t\tconsole.warn(this.id, this.key, ...args)\n\t\t\t},\n\t\t\terror: (...args: unknown[]) => {\n\t\t\t\tconsole.error(this.id, this.key, ...args)\n\t\t\t},\n\t\t}\n\t\tthis.process.stdout.on(\n\t\t\t`data`,\n\t\t\t<Event extends keyof I>(buffer: EventBuffer<string, I[Event]>) => {\n\t\t\t\tconst chunk = buffer.toString()\n\n\t\t\t\tif (chunk === `ALIVE`) {\n\t\t\t\t\t// console.log(chunk)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.unprocessedEvents.push(...chunk.split(`\\x03`))\n\t\t\t\t// console.log(`🤓`, chunk.length)\n\t\t\t\t// console.log(`🤓`, this.unprocessedEvents.length)\n\t\t\t\t// console.log(`🤓`, ...this.unprocessedEvents.map((x) => x.length))\n\t\t\t\tconst newInput = this.unprocessedEvents.shift()\n\t\t\t\tthis.incompleteData += newInput ?? ``\n\t\t\t\ttry {\n\t\t\t\t\tif (this.incompleteData.startsWith(`error`)) {\n\t\t\t\t\t\tconsole.log(`❗`, this.incompleteData)\n\t\t\t\t\t}\n\t\t\t\t\tlet parsedEvent = parseJson(this.incompleteData)\n\t\t\t\t\tthis.handleEvent(...(parsedEvent as [string, ...I[keyof I]]))\n\t\t\t\t\twhile (this.unprocessedEvents.length > 0) {\n\t\t\t\t\t\tconst event = this.unprocessedEvents.shift()\n\t\t\t\t\t\tif (event) {\n\t\t\t\t\t\t\tif (this.unprocessedEvents.length === 0) {\n\t\t\t\t\t\t\t\tthis.incompleteData = event\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tparsedEvent = parseJson(event)\n\t\t\t\t\t\t\tthis.handleEvent(...(parsedEvent as [string, ...I[keyof I]]))\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthis.incompleteData = ``\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.warn(`⚠️----------------⚠️`)\n\t\t\t\t\tconsole.warn(this.incompleteData)\n\t\t\t\t\tconsole.warn(`⚠️----------------⚠️`)\n\t\t\t\t\tconsole.error(error)\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\t\tthis.process.stderr.on(`data`, (buf) => {\n\t\t\tconst chunk = buf.toString()\n\t\t\tthis.unprocessedLogs.push(...chunk.split(`\\x03`))\n\t\t\t// console.log(`🤫`, chunk.length)\n\t\t\t// console.log(`🤫`, this.unprocessedLogs.length)\n\t\t\t// console.log(`🤫`, ...this.unprocessedLogs.map((x) => x.length))\n\t\t\tconst newInput = this.unprocessedLogs.shift()\n\t\t\tthis.incompleteLog += newInput ?? ``\n\t\t\ttry {\n\t\t\t\tlet parsedLog = parseJson(this.incompleteLog)\n\t\t\t\t// console.log(`🤫`, parsedLog)\n\t\t\t\tthis.handleLog(parsedLog)\n\t\t\t\twhile (this.unprocessedLogs.length > 0) {\n\t\t\t\t\tthis.incompleteLog = this.unprocessedLogs.shift() ?? ``\n\t\t\t\t\tif (this.incompleteLog) {\n\t\t\t\t\t\tparsedLog = parseJson(this.incompleteLog)\n\t\t\t\t\t\tthis.handleLog(parsedLog)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(`❌❌❌`)\n\t\t\t\tconsole.error(this.incompleteLog)\n\t\t\t\tconsole.error(error)\n\t\t\t\tconsole.error(`❌❌❌️`)\n\t\t\t}\n\t\t})\n\t\tif (process.pid) {\n\t\t\tthis.id = process.pid.toString()\n\t\t}\n\t}\n}\n","import { Subject } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport { parseJson, stringifyJson } from \"atom.io/json\"\nimport { SetRTX } from \"atom.io/transceivers/set-rtx\"\n\nimport type { EventBuffer, Events } from \"./custom-socket\"\nimport { CustomSocket } from \"./custom-socket\"\n\nexport class SubjectSocket<\n\tI extends Events,\n\tO extends Events,\n> extends CustomSocket<I, O> {\n\tpublic in: Subject<[string, ...Json.Serializable[]]>\n\tpublic out: Subject<[string, ...Json.Serializable[]]>\n\tpublic id = `no_id_retrieved`\n\tpublic disposalFunctions: (() => void)[] = []\n\n\tpublic constructor(id: string) {\n\t\tsuper((...args) => {\n\t\t\tthis.out.next(args as any)\n\t\t\treturn this\n\t\t})\n\t\tthis.id = id\n\t\tthis.in = new Subject()\n\t\tthis.out = new Subject()\n\t\tthis.in.subscribe(`socket`, (event) => {\n\t\t\tthis.handleEvent(...(event as [string, ...I[keyof I]]))\n\t\t})\n\t}\n\n\tpublic dispose(): void {\n\t\tfor (const dispose of this.disposalFunctions) {\n\t\t\tdispose()\n\t\t}\n\t}\n}\n\nexport class ParentSocket<\n\tI extends Events & {\n\t\t[id in string as `relay:${id}`]: [string, ...Json.Serializable[]]\n\t},\n\tO extends Events & {\n\t\t[id in string as `user:${id}`]: [string, ...Json.Serializable[]]\n\t} & {\n\t\t/* eslint-disable quotes */\n\t\t\"user-joins\": [string]\n\t\t\"user-leaves\": [string]\n\t\t/* eslint-enable quotes */\n\t},\n> extends CustomSocket<I, O> {\n\tprotected incompleteData = ``\n\tprotected unprocessedEvents: string[] = []\n\tprotected relays: Map<string, SubjectSocket<any, any>>\n\tprotected relayServices: ((\n\t\tsocket: SubjectSocket<any, any>,\n\t) => (() => void) | void)[]\n\tprotected process: NodeJS.Process\n\n\tpublic id = `#####`\n\n\tprotected log(...args: any[]): void {\n\t\tthis.process.stderr.write(\n\t\t\tstringifyJson(\n\t\t\t\targs.map((arg) =>\n\t\t\t\t\targ instanceof SetRTX\n\t\t\t\t\t\t? `{ ${arg.toJSON().members.join(` | `)} }`\n\t\t\t\t\t\t: arg,\n\t\t\t\t),\n\t\t\t) + `\\x03`,\n\t\t)\n\t}\n\tpublic logger = {\n\t\tinfo: (...args: any[]): void => {\n\t\t\tthis.log(`i`, ...args)\n\t\t},\n\t\twarn: (...args: any[]): void => {\n\t\t\tthis.log(`w`, ...args)\n\t\t},\n\t\terror: (...args: any[]): void => {\n\t\t\tthis.log(`e`, ...args)\n\t\t},\n\t}\n\n\tpublic constructor() {\n\t\tsuper((event, ...args) => {\n\t\t\tconst stringifiedEvent = JSON.stringify([event, ...args])\n\t\t\tthis.process.stdout.write(stringifiedEvent + `\\x03`)\n\t\t\treturn this\n\t\t})\n\t\tthis.process = process\n\t\tthis.process.stdin.resume()\n\t\tthis.relays = new Map()\n\t\tthis.relayServices = []\n\t\t// this.logger.info(`🔗`, `uplink`, process.pid)\n\n\t\tthis.process.stdin.on(\n\t\t\t`data`,\n\t\t\t<Event extends keyof I>(buffer: EventBuffer<string, I[Event]>) => {\n\t\t\t\tconst chunk = buffer.toString()\n\t\t\t\tthis.unprocessedEvents.push(...chunk.split(`\\x03`))\n\t\t\t\tconst newInput = this.unprocessedEvents.shift()\n\t\t\t\tthis.incompleteData += newInput ?? ``\n\n\t\t\t\ttry {\n\t\t\t\t\tconst parsedData = parseJson(this.incompleteData)\n\t\t\t\t\tthis.logger.info(`🎰`, `received`, parsedData)\n\t\t\t\t\tthis.handleEvent(...(parsedData as [string, ...I[keyof I]]))\n\t\t\t\t\twhile (this.unprocessedEvents.length > 0) {\n\t\t\t\t\t\tconst event = this.unprocessedEvents.shift()\n\t\t\t\t\t\tif (event) {\n\t\t\t\t\t\t\tif (this.unprocessedEvents.length === 0) {\n\t\t\t\t\t\t\t\tthis.incompleteData = event\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst parsedEvent = parseJson(event)\n\t\t\t\t\t\t\tthis.handleEvent(...(parsedEvent as [string, ...I[keyof I]]))\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthis.incompleteData = ``\n\t\t\t\t} catch (thrown) {\n\t\t\t\t\tif (thrown instanceof Error) {\n\t\t\t\t\t\tthis.logger.error(`❗`, thrown.message, thrown.cause, thrown.stack)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\n\t\tthis.on(`exit`, () => {\n\t\t\tthis.logger.info(`🔥`, this.id, `received \"exit\"`)\n\t\t\tprocess.exit(0)\n\t\t})\n\t\tprocess.on(`exit`, (code) => {\n\t\t\tthis.logger.info(`🔥`, this.id, `exited with code ${code}`)\n\t\t})\n\t\tprocess.on(`end`, () => {\n\t\t\tthis.logger.info(`🔥`, this.id, `ended`)\n\t\t\tprocess.exit(0)\n\t\t})\n\t\tprocess.on(`SIGTERM`, () => {\n\t\t\tthis.logger.error(`🔥`, this.id, `terminated`)\n\t\t\tprocess.exit(0)\n\t\t})\n\t\tprocess.on(`SIGINT`, () => {\n\t\t\tthis.logger.error(`🔥`, this.id, `interrupted`)\n\t\t\tprocess.exit(0)\n\t\t})\n\n\t\tif (process.pid) {\n\t\t\tthis.id = process.pid?.toString()\n\t\t}\n\n\t\tthis.on(`user-joins`, (username) => {\n\t\t\tthis.logger.info(`👤`, `user`, username, `joined`)\n\t\t\tconst relay = new SubjectSocket(`user:${username}`)\n\t\t\tthis.relays.set(username, relay)\n\t\t\tthis.logger.info(\n\t\t\t\t`🔗`,\n\t\t\t\t`attaching services:`,\n\t\t\t\t`[${[...this.relayServices.keys()].join(`, `)}]`,\n\t\t\t)\n\t\t\tfor (const attachServices of this.relayServices) {\n\t\t\t\tconst cleanup = attachServices(relay)\n\t\t\t\tif (cleanup) {\n\t\t\t\t\trelay.disposalFunctions.push(cleanup)\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.on(`user:${username}`, (...data) => {\n\t\t\t\trelay.in.next(data)\n\t\t\t})\n\t\t\trelay.out.subscribe(`socket`, (data) => {\n\t\t\t\tthis.emit(...(data as [string, ...I[keyof I]]))\n\t\t\t})\n\t\t})\n\n\t\tthis.on(`user-leaves`, (username) => {\n\t\t\tconst relay = this.relays.get(username)\n\t\t\tthis.off(`relay:${username}`)\n\t\t\tif (relay) {\n\t\t\t\trelay.dispose()\n\t\t\t\tthis.relays.delete(username)\n\t\t\t}\n\t\t})\n\n\t\tprocess.stdout.write(`ALIVE`)\n\t}\n\n\tpublic relay(\n\t\tattachServices: (socket: SubjectSocket<any, any>) => (() => void) | void,\n\t): void {\n\t\tthis.logger.info(`🔗`, `running relay method`)\n\t\tthis.relayServices.push(attachServices)\n\t}\n}\n","import type { ChildProcessWithoutNullStreams } from \"node:child_process\"\nimport { spawn } from \"node:child_process\"\n\nimport type {\n\tLoadable,\n\tReadonlyPureSelectorFamilyToken,\n\tRegularAtomFamilyToken,\n} from \"atom.io\"\nimport { atomFamily, selectorFamily } from \"atom.io\"\n\nimport { ChildSocket } from \"../ipc-sockets\"\n\nexport type RoomArguments =\n\t| [script: string, options: string[]]\n\t| [script: string]\n\nexport const roomArgumentsAtoms: RegularAtomFamilyToken<RoomArguments, string> =\n\tatomFamily<RoomArguments, string>({\n\t\tkey: `roomArguments`,\n\t\tdefault: [`echo`, [`Hello World!`]],\n\t})\n\nexport const roomSelectors: ReadonlyPureSelectorFamilyToken<\n\tLoadable<ChildSocket<any, any>>,\n\tstring\n> = selectorFamily<Loadable<ChildSocket<any, any>>, string>({\n\tkey: `room`,\n\tget:\n\t\t(roomId) =>\n\t\tasync ({ get, find }) => {\n\t\t\tconst argumentsState = find(roomArgumentsAtoms, roomId)\n\t\t\tconst args = get(argumentsState)\n\t\t\tconst [script, options] = args\n\t\t\tconst child = await new Promise<ChildProcessWithoutNullStreams>(\n\t\t\t\t(resolve) => {\n\t\t\t\t\tconst room = spawn(script, options, { env: process.env })\n\t\t\t\t\tconst resolver = (data: Buffer) => {\n\t\t\t\t\t\tif (data.toString() === `ALIVE`) {\n\t\t\t\t\t\t\troom.stdout.off(`data`, resolver)\n\t\t\t\t\t\t\tresolve(room)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\troom.stdout.on(`data`, resolver)\n\t\t\t\t},\n\t\t\t)\n\t\t\treturn new ChildSocket(child, roomId)\n\t\t},\n})\n","import type { Loadable } from \"atom.io\"\nimport * as AtomIO from \"atom.io\"\nimport { editRelationsInStore } from \"atom.io/internal\"\nimport type { UserInRoomMeta } from \"atom.io/realtime\"\nimport { roomIndex, usersInRooms } from \"atom.io/realtime\"\n\nimport type { ChildSocket } from \"../ipc-sockets\"\nimport type { RoomArguments } from \"./server-room-external-store\"\nimport { roomArgumentsAtoms, roomSelectors } from \"./server-room-external-store\"\n\nexport const createRoomTX: AtomIO.TransactionToken<\n\t(\n\t\troomId: string,\n\t\tscript: string,\n\t\toptions?: string[],\n\t) => Loadable<ChildSocket<any, any>>\n> = AtomIO.transaction({\n\tkey: `createRoom`,\n\tdo: ({ get, set, find }, roomId, script, options) => {\n\t\tconst args: RoomArguments = options ? [script, options] : [script]\n\t\tconst roomArgumentsState = find(roomArgumentsAtoms, roomId)\n\t\tset(roomArgumentsState, args)\n\t\tset(roomIndex, (s) => s.add(roomId))\n\t\tconst roomState = find(roomSelectors, roomId)\n\t\tconst room = get(roomState)\n\t\treturn room\n\t},\n})\nexport type CreateRoomIO = AtomIO.TransactionIO<typeof createRoomTX>\n\nexport const joinRoomTX: AtomIO.TransactionToken<\n\t(roomId: string, userId: string, enteredAtEpoch: number) => UserInRoomMeta\n> = AtomIO.transaction({\n\tkey: `joinRoom`,\n\tdo: (tools, roomId, userId, enteredAtEpoch) => {\n\t\tconst meta = { enteredAtEpoch }\n\t\teditRelationsInStore(\n\t\t\tusersInRooms,\n\t\t\t(relations) => {\n\t\t\t\trelations.set({ room: roomId, user: userId }, meta)\n\t\t\t},\n\t\t\ttools.env().store,\n\t\t)\n\t\treturn meta\n\t},\n})\nexport type JoinRoomIO = AtomIO.TransactionIO<typeof joinRoomTX>\n\nexport const leaveRoomTX: AtomIO.TransactionToken<\n\t(roomId: string, userId: string) => void\n> = AtomIO.transaction({\n\tkey: `leaveRoom`,\n\tdo: (tools, roomId, userId) => {\n\t\teditRelationsInStore(\n\t\t\tusersInRooms,\n\t\t\t(relations) => {\n\t\t\t\trelations.delete({ room: roomId, user: userId })\n\t\t\t},\n\t\t\ttools.env().store,\n\t\t)\n\t},\n})\nexport type LeaveRoomIO = AtomIO.TransactionIO<typeof leaveRoomTX>\n\nexport const destroyRoomTX: AtomIO.TransactionToken<(roomId: string) => void> =\n\tAtomIO.transaction({\n\t\tkey: `destroyRoom`,\n\t\tdo: (tools, roomId) => {\n\t\t\teditRelationsInStore(\n\t\t\t\tusersInRooms,\n\t\t\t\t(relations) => {\n\t\t\t\t\trelations.delete({ room: roomId })\n\t\t\t\t},\n\t\t\t\ttools.env().store,\n\t\t\t)\n\t\t\ttools.set(roomIndex, (s) => (s.delete(roomId), s))\n\t\t},\n\t})\n","import type {\n\tRegularAtomFamilyToken,\n\tTransactionUpdate,\n\tTransactionUpdateContent,\n} from \"atom.io\"\nimport { atomFamily } from \"atom.io\"\n\nimport type { UserKey } from \"./server-user-store\"\n\n// export const completeUpdateAtoms = atomFamily<\n// \tTransactionUpdate<any> | null,\n// \tstring\n// >({\n// \tkey: `completeUpdate`,\n// \tdefault: null,\n// })\n\nexport function redactTransactionUpdateContent(\n\tvisibleStateKeys: string[],\n\tupdates: TransactionUpdateContent[],\n): TransactionUpdateContent[] {\n\treturn updates\n\t\t.map((update): TransactionUpdateContent => {\n\t\t\tswitch (update.type) {\n\t\t\t\tcase `transaction_update`: {\n\t\t\t\t\tconst redacted = redactTransactionUpdateContent(\n\t\t\t\t\t\tvisibleStateKeys,\n\t\t\t\t\t\tupdate.updates,\n\t\t\t\t\t)\n\t\t\t\t\treturn { ...update, updates: redacted }\n\t\t\t\t}\n\t\t\t\tcase `atom_update`:\n\t\t\t\tcase `selector_update`:\n\t\t\t\tcase `molecule_creation`:\n\t\t\t\tcase `molecule_disposal`:\n\t\t\t\tcase `molecule_transfer`:\n\t\t\t\tcase `state_creation`:\n\t\t\t\tcase `state_disposal`:\n\t\t\t\t\treturn update\n\t\t\t}\n\t\t})\n\t\t.filter((update) => {\n\t\t\tswitch (update.type) {\n\t\t\t\tcase `atom_update`:\n\t\t\t\tcase `selector_update`:\n\t\t\t\t\treturn visibleStateKeys.includes(update.key)\n\t\t\t\tcase `state_creation`:\n\t\t\t\tcase `state_disposal`:\n\t\t\t\t\treturn visibleStateKeys.includes(update.token.key)\n\t\t\t\tcase `molecule_creation`:\n\t\t\t\tcase `transaction_update`:\n\t\t\t\tcase `molecule_disposal`:\n\t\t\t\tcase `molecule_transfer`:\n\t\t\t\t\treturn true\n\t\t\t}\n\t\t})\n}\n\nexport const redactorAtoms: RegularAtomFamilyToken<\n\t{\n\t\tocclude: (updates: TransactionUpdateContent[]) => TransactionUpdateContent[]\n\t},\n\tUserKey\n> = atomFamily<\n\t{\n\t\tocclude: (updates: TransactionUpdateContent[]) => TransactionUpdateContent[]\n\t},\n\tUserKey\n>({\n\tkey: `redactor`,\n\tdefault: { occlude: (updates) => updates },\n})\n// export const redactedUpdateSelectors = selectorFamily<\n// \tTransactionUpdate<any> | null,\n// \t[transactionKey: string, updateId: string]\n// >({\n// \tkey: `redactedUpdate`,\n// \tget:\n// \t\t([transactionKey, updateId]) =>\n// \t\t({ get, find }) => {\n// \t\t\tconst update = get(find(completeUpdateAtoms, updateId))\n// \t\t\tconst { filter } = get(find(transactionRedactorAtoms, transactionKey))\n\n// \t\t\tif (update && filter) {\n// \t\t\t\treturn { ...update, updates: filter(update.updates) }\n// \t\t\t}\n// \t\t\treturn null\n// \t\t},\n// })\n\nexport type ContinuitySyncTransactionUpdate = Pick<\n\tTransactionUpdate<any>,\n\t`epoch` | `id` | `key` | `output` | `updates`\n>\nexport const userUnacknowledgedQueues: RegularAtomFamilyToken<\n\tContinuitySyncTransactionUpdate[],\n\tUserKey\n> = atomFamily<ContinuitySyncTransactionUpdate[], UserKey>({\n\tkey: `unacknowledgedUpdates`,\n\tdefault: () => [],\n})\n","import type {\n\tHierarchy,\n\tJoinToken,\n\tMutableAtomToken,\n\tRegularAtomFamilyToken,\n} from \"atom.io\"\nimport { atom, atomFamily, join } from \"atom.io\"\nimport type { SetRTXJson } from \"atom.io/transceivers/set-rtx\"\nimport { SetRTX } from \"atom.io/transceivers/set-rtx\"\n\nimport type { Socket } from \"..\"\n\nexport type SocketKey = `socket::${string}`\nexport type UserKey = `user::${string}`\nexport type RoomKey = `room::${string}`\n\nexport type SocketSystemHierarchy = Hierarchy<\n\t[\n\t\t{\n\t\t\tabove: `root`\n\t\t\tbelow: [UserKey, SocketKey, RoomKey]\n\t\t},\n\t]\n>\n\nexport const socketAtoms: RegularAtomFamilyToken<Socket | null, SocketKey> =\n\tatomFamily<Socket | null, SocketKey>({\n\t\tkey: `sockets`,\n\t\tdefault: null,\n\t})\n\nexport const socketIndex: MutableAtomToken<\n\tSetRTX<SocketKey>,\n\tSetRTXJson<SocketKey>\n> = atom<SetRTX<SocketKey>, SetRTXJson<SocketKey>>({\n\tkey: `socketsIndex`,\n\tmutable: true,\n\tdefault: () => new SetRTX(),\n\ttoJson: (set) => set.toJSON(),\n\tfromJson: (json) => SetRTX.fromJSON(json),\n})\nexport const userIndex: MutableAtomToken<\n\tSetRTX<UserKey>,\n\tSetRTXJson<UserKey>\n> = atom<SetRTX<UserKey>, SetRTXJson<UserKey>>({\n\tkey: `usersIndex`,\n\tmutable: true,\n\tdefault: () => new SetRTX(),\n\ttoJson: (set) => set.toJSON(),\n\tfromJson: (json) => SetRTX.fromJSON(json),\n})\nexport const usersOfSockets: JoinToken<\n\t`user`,\n\tUserKey,\n\t`socket`,\n\tSocketKey,\n\t`1:1`\n> = join({\n\tkey: `usersOfSockets`,\n\tbetween: [`user`, `socket`],\n\tcardinality: `1:1`,\n\tisAType: (s): s is UserKey => s.startsWith(`user::`),\n\tisBType: (s): s is SocketKey => s.startsWith(`socket::`),\n})\n","import type { Store } from \"atom.io/internal\"\nimport {\n\tfindInStore,\n\tgetFromStore,\n\tgetJsonToken,\n\tisRootStore,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { ContinuityToken } from \"atom.io/realtime\"\n\nimport type { Socket, UserKey } from \"..\"\n\nexport function prepareToSendInitialPayload(\n\tstore: Store,\n\tcontinuity: ContinuityToken,\n\tuserKey: UserKey,\n\tsocket: Socket | null,\n): () => void {\n\tconst continuityKey = continuity.key\n\treturn function sendInitialPayload(): void {\n\t\tconst initialPayload: Json.Serializable[] = []\n\t\tfor (const atom of continuity.globals) {\n\t\t\tconst resourceToken =\n\t\t\t\tatom.type === `mutable_atom` ? getJsonToken(store, atom) : atom\n\t\t\tconst resource = getFromStore(store, resourceToken)\n\t\t\tinitialPayload.push(resourceToken, resource)\n\t\t}\n\t\tfor (const perspective of continuity.perspectives) {\n\t\t\tconst { viewAtoms, resourceAtoms } = perspective\n\t\t\tconst userViewState = findInStore(store, viewAtoms, userKey)\n\t\t\tconst userView = getFromStore(store, userViewState)\n\t\t\tstore.logger.info(`👁`, `atom`, resourceAtoms.key, `${userKey} can see`, {\n\t\t\t\tviewAtoms,\n\t\t\t\tresourceAtoms,\n\t\t\t\tuserView,\n\t\t\t})\n\t\t\tfor (const visibleToken of userView) {\n\t\t\t\tconst resourceToken =\n\t\t\t\t\tvisibleToken.type === `mutable_atom`\n\t\t\t\t\t\t? getJsonToken(store, visibleToken)\n\t\t\t\t\t\t: visibleToken\n\t\t\t\tconst resource = getFromStore(store, resourceToken)\n\n\t\t\t\tinitialPayload.push(resourceToken, resource)\n\t\t\t}\n\t\t}\n\n\t\tconst epoch = isRootStore(store)\n\t\t\t? (store.transactionMeta.epoch.get(continuityKey) ?? null)\n\t\t\t: null\n\n\t\tsocket?.emit(`continuity-init:${continuityKey}`, epoch, initialPayload)\n\t}\n}\n","import type { TransactionUpdate } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { actUponStore } from \"atom.io/internal\"\nimport type { JsonIO } from \"atom.io/json\"\nimport type { ContinuityToken } from \"atom.io/realtime\"\n\nexport function prepareToServeTransactionRequest(\n\tstore: Store,\n\tcontinuity: ContinuityToken,\n\tuserKey: string,\n): (update: Pick<TransactionUpdate<JsonIO>, `id` | `key` | `params`>) => void {\n\tconst continuityKey = continuity.key\n\treturn function serveTransactionRequest(update) {\n\t\tstore.logger.info(`🛎️`, `continuity`, continuityKey, `received`, update)\n\t\tconst transactionKey = update.key\n\t\tconst updateId = update.id\n\t\tconst performanceKey = `tx-run:${transactionKey}:${updateId}`\n\t\tconst performanceKeyStart = `${performanceKey}:start`\n\t\tconst performanceKeyEnd = `${performanceKey}:end`\n\t\tperformance.mark(performanceKeyStart)\n\t\ttry {\n\t\t\tactUponStore(\n\t\t\t\tstore,\n\t\t\t\t{ type: `transaction`, key: transactionKey },\n\t\t\t\tupdateId,\n\t\t\t)(...update.params)\n\t\t} catch (thrown) {\n\t\t\tif (thrown instanceof Error) {\n\t\t\t\tstore.logger.error(\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`failed to run transaction ${transactionKey} from ${userKey} with update ${updateId}`,\n\t\t\t\t\tthrown.message,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tperformance.mark(performanceKeyEnd)\n\t\tconst metric = performance.measure(\n\t\t\tperformanceKey,\n\t\t\tperformanceKeyStart,\n\t\t\tperformanceKeyEnd,\n\t\t)\n\t\tstore?.logger.info(\n\t\t\t`🚀`,\n\t\t\t`transaction`,\n\t\t\ttransactionKey,\n\t\t\tupdateId,\n\t\t\tuserKey,\n\t\t\tmetric.duration,\n\t\t)\n\t}\n}\n","import type { Store } from \"atom.io/internal\"\nimport { setIntoStore } from \"atom.io/internal\"\nimport type { ContinuityToken } from \"atom.io/realtime\"\n\nimport type { ContinuitySyncTransactionUpdate } from \"../realtime-server-stores\"\nimport { userUnacknowledgedQueues } from \"../realtime-server-stores\"\n\nexport function prepareToTrackClientAcknowledgement(\n\tstore: Store,\n\tcontinuity: ContinuityToken,\n\tuserKey: string,\n\tuserUnacknowledgedUpdates: ContinuitySyncTransactionUpdate[],\n): (epoch: number) => void {\n\tconst continuityKey = continuity.key\n\treturn function trackClientAcknowledgement(epoch) {\n\t\tstore.logger.info(\n\t\t\t`👍`,\n\t\t\t`continuity`,\n\t\t\tcontinuityKey,\n\t\t\t`${userKey} acknowledged epoch ${epoch}`,\n\t\t)\n\t\tconst isUnacknowledged = userUnacknowledgedUpdates[0]?.epoch === epoch\n\t\tif (isUnacknowledged) {\n\t\t\tsetIntoStore(store, userUnacknowledgedQueues, userKey, (updates) => {\n\t\t\t\tupdates.shift()\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`${userKey} unacknowledged update queue now has`,\n\t\t\t\t\tupdates.length,\n\t\t\t\t\t`items`,\n\t\t\t\t)\n\t\t\t\treturn updates\n\t\t\t})\n\t\t}\n\t}\n}\n","import type { Store } from \"atom.io/internal\"\nimport {\n\tfindInStore,\n\tgetFromStore,\n\tgetUpdateToken,\n\tsetIntoStore,\n\tsubscribeToTransaction,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { ContinuityToken } from \"atom.io/realtime\"\n\nimport type { Socket, UserKey } from \"..\"\nimport {\n\tredactTransactionUpdateContent,\n\tuserUnacknowledgedQueues,\n} from \"../realtime-server-stores\"\n\nexport function subscribeToContinuityActions(\n\tstore: Store,\n\tcontinuity: ContinuityToken,\n\tuserKey: UserKey,\n\tsocket: Socket | null,\n): (() => void)[] {\n\tconst continuityKey = continuity.key\n\tconst unsubscribeFunctions: (() => void)[] = []\n\n\tfor (const transaction of continuity.actions) {\n\t\tconst unsubscribeFromTransaction = subscribeToTransaction(\n\t\t\tstore,\n\t\t\ttransaction,\n\t\t\t`sync-continuity:${continuityKey}:${userKey}`,\n\t\t\t(update) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst visibleKeys = continuity.globals\n\t\t\t\t\t\t.map((atom) => {\n\t\t\t\t\t\t\tif (atom.type === `atom`) {\n\t\t\t\t\t\t\t\treturn atom.key\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn getUpdateToken(atom).key\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.concat(\n\t\t\t\t\t\t\tcontinuity.perspectives.flatMap((perspective) => {\n\t\t\t\t\t\t\t\tconst { viewAtoms } = perspective\n\t\t\t\t\t\t\t\tconst userPerspectiveTokenState = findInStore(\n\t\t\t\t\t\t\t\t\tstore,\n\t\t\t\t\t\t\t\t\tviewAtoms,\n\t\t\t\t\t\t\t\t\tuserKey,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tconst visibleTokens = getFromStore(\n\t\t\t\t\t\t\t\t\tstore,\n\t\t\t\t\t\t\t\t\tuserPerspectiveTokenState,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\treturn visibleTokens.map((token) => {\n\t\t\t\t\t\t\t\t\tconst key =\n\t\t\t\t\t\t\t\t\t\ttoken.type === `mutable_atom` ? `*` + token.key : token.key\n\t\t\t\t\t\t\t\t\treturn key\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)\n\t\t\t\t\tconst redactedUpdates = redactTransactionUpdateContent(\n\t\t\t\t\t\tvisibleKeys,\n\t\t\t\t\t\tupdate.updates,\n\t\t\t\t\t)\n\t\t\t\t\tconst redactedUpdate = {\n\t\t\t\t\t\t...update,\n\t\t\t\t\t\tupdates: redactedUpdates,\n\t\t\t\t\t}\n\t\t\t\t\tsetIntoStore(store, userUnacknowledgedQueues, userKey, (updates) => {\n\t\t\t\t\t\tif (redactedUpdate) {\n\t\t\t\t\t\t\tupdates.push(redactedUpdate)\n\t\t\t\t\t\t\tupdates.sort((a, b) => a.epoch - b.epoch)\n\t\t\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t\t\t`👍`,\n\t\t\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t\t\t`${userKey} unacknowledged update queue now has`,\n\t\t\t\t\t\t\t\tupdates.length,\n\t\t\t\t\t\t\t\t`items`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn updates\n\t\t\t\t\t})\n\n\t\t\t\t\tsocket?.emit(\n\t\t\t\t\t\t`tx-new:${continuityKey}`,\n\t\t\t\t\t\tredactedUpdate as Json.Serializable,\n\t\t\t\t\t)\n\t\t\t\t} catch (thrown) {\n\t\t\t\t\tif (thrown instanceof Error) {\n\t\t\t\t\t\tstore.logger.error(\n\t\t\t\t\t\t\t`❌`,\n\t\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t\t`${userKey} failed to send update from transaction ${transaction.key} to ${userKey}`,\n\t\t\t\t\t\t\tthrown.message,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\t\tunsubscribeFunctions.push(unsubscribeFromTransaction)\n\t}\n\treturn unsubscribeFunctions\n}\n","import type { Store } from \"atom.io/internal\"\nimport {\n\tfindInStore,\n\tgetFromStore,\n\tgetJsonToken,\n\tsubscribeToState,\n} from \"atom.io/internal\"\nimport type { ContinuityToken } from \"atom.io/realtime\"\n\nimport type { Socket } from \"..\"\nimport type { UserKey } from \"../realtime-server-stores\"\n\nexport function subscribeToContinuityPerspectives(\n\tstore: Store,\n\tcontinuity: ContinuityToken,\n\tuserKey: UserKey,\n\tsocket: Socket | null,\n): (() => void)[] {\n\tconst continuityKey = continuity.key\n\tconst unsubFns: (() => void)[] = []\n\tfor (const perspective of continuity.perspectives) {\n\t\tconst { viewAtoms } = perspective\n\t\tconst userViewState = findInStore(store, viewAtoms, userKey)\n\t\tconst unsubscribeFromUserView = subscribeToState(\n\t\t\tstore,\n\t\t\tuserViewState,\n\t\t\t`sync-continuity:${continuityKey}:${userKey}:perspective:${perspective.resourceAtoms.key}`,\n\t\t\t({ oldValue, newValue }) => {\n\t\t\t\tconst oldKeys = oldValue.map((token) => token.key)\n\t\t\t\tconst newKeys = newValue.map((token) => token.key)\n\t\t\t\tconst concealed = oldValue.filter(\n\t\t\t\t\t(token) => !newKeys.includes(token.key),\n\t\t\t\t)\n\t\t\t\tconst revealed = newValue\n\t\t\t\t\t.filter((token) => !oldKeys.includes(token.key))\n\t\t\t\t\t.flatMap((token) => {\n\t\t\t\t\t\tconst resourceToken =\n\t\t\t\t\t\t\ttoken.type === `mutable_atom` ? getJsonToken(store, token) : token\n\t\t\t\t\t\tconst resource = getFromStore(store, resourceToken)\n\t\t\t\t\t\treturn [resourceToken, resource]\n\t\t\t\t\t})\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`👁`,\n\t\t\t\t\t`atom`,\n\t\t\t\t\tperspective.resourceAtoms.key,\n\t\t\t\t\t`${userKey} has a new perspective`,\n\t\t\t\t\t{ oldKeys, newKeys, revealed, concealed },\n\t\t\t\t)\n\t\t\t\tif (revealed.length > 0) {\n\t\t\t\t\tsocket?.emit(`reveal:${continuityKey}`, revealed)\n\t\t\t\t}\n\t\t\t\tif (concealed.length > 0) {\n\t\t\t\t\tsocket?.emit(`conceal:${continuityKey}`, concealed)\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\t\tunsubFns.push(unsubscribeFromUserView)\n\t}\n\treturn unsubFns\n}\n","import {\n\tfindInStore,\n\tfindRelationsInStore,\n\tgetFromStore,\n\tIMPLICIT,\n\tsubscribeToState,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { ContinuityToken } from \"atom.io/realtime\"\n\nimport type { ServerConfig, Socket } from \"..\"\nimport { socketAtoms, usersOfSockets } from \"..\"\nimport { userUnacknowledgedQueues } from \"../realtime-server-stores\"\nimport { prepareToSendInitialPayload } from \"./prepare-to-send-initial-payload\"\nimport { prepareToServeTransactionRequest } from \"./prepare-to-serve-transaction-request\"\nimport { prepareToTrackClientAcknowledgement } from \"./prepare-to-track-client-acknowledgement\"\nimport { subscribeToContinuityActions } from \"./subscribe-to-continuity-actions\"\nimport { subscribeToContinuityPerspectives } from \"./subscribe-to-continuity-perpectives\"\n\nexport type ExposeRealtimeContinuity = (\n\tcontinuity: ContinuityToken,\n) => () => void\nexport function prepareToExposeRealtimeContinuity({\n\tsocket: initialSocket,\n\tstore = IMPLICIT.STORE,\n}: ServerConfig): ExposeRealtimeContinuity {\n\treturn function syncRealtimeContinuity(continuity) {\n\t\tlet socket: Socket | null = initialSocket\n\n\t\tconst continuityKey = continuity.key\n\t\tconst userKeyState = findRelationsInStore(\n\t\t\tusersOfSockets,\n\t\t\t`socket::${socket.id}`,\n\t\t\tstore,\n\t\t).userKeyOfSocket\n\t\tconst userKey = getFromStore(store, userKeyState)\n\t\tif (!userKey) {\n\t\t\tstore.logger.error(\n\t\t\t\t`❌`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`Tried to create a synchronizer for a socket (${socket.id}) that is not connected to a user.`,\n\t\t\t)\n\t\t\treturn () => {}\n\t\t}\n\n\t\tconst socketKeyState = findRelationsInStore(\n\t\t\tusersOfSockets,\n\t\t\tuserKey,\n\t\t\tstore,\n\t\t).socketKeyOfUser\n\t\tconst _unsubscribeFromSocketTracking = subscribeToState(\n\t\t\tstore,\n\t\t\tsocketKeyState,\n\t\t\t`sync-continuity:${continuityKey}:${userKey}`,\n\t\t\t({ newValue: newSocketKey }) => {\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`seeing ${userKey} on new socket ${newSocketKey}`,\n\t\t\t\t)\n\t\t\t\tif (newSocketKey === null) {\n\t\t\t\t\tstore.logger.warn(\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`User (${userKey}) is not connected to a socket, waiting for them to reappear.`,\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tconst newSocketState = findInStore(store, socketAtoms, newSocketKey)\n\t\t\t\tconst newSocket = getFromStore(store, newSocketState)\n\t\t\t\tsocket = newSocket\n\t\t\t\tfor (const unacknowledgedUpdate of userUnacknowledgedUpdates) {\n\t\t\t\t\tsocket?.emit(\n\t\t\t\t\t\t`tx-new:${continuityKey}`,\n\t\t\t\t\t\tunacknowledgedUpdate as Json.Serializable,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\n\t\tconst userUnacknowledgedUpdates = getFromStore(\n\t\t\tstore,\n\t\t\tuserUnacknowledgedQueues,\n\t\t\tuserKey,\n\t\t)\n\n\t\tconst unsubscribeFunctions: (() => void)[] = []\n\n\t\tconst unsubscribeFromPerspectives = subscribeToContinuityPerspectives(\n\t\t\tstore,\n\t\t\tcontinuity,\n\t\t\tuserKey,\n\t\t\tsocket,\n\t\t)\n\t\tconst unsubscribeFromTransactions = subscribeToContinuityActions(\n\t\t\tstore,\n\t\t\tcontinuity,\n\t\t\tuserKey,\n\t\t\tsocket,\n\t\t)\n\t\tunsubscribeFunctions.push(\n\t\t\t...unsubscribeFromPerspectives,\n\t\t\t...unsubscribeFromTransactions,\n\t\t)\n\n\t\tconst sendInitialPayload = prepareToSendInitialPayload(\n\t\t\tstore,\n\t\t\tcontinuity,\n\t\t\tuserKey,\n\t\t\tinitialSocket,\n\t\t)\n\n\t\tsocket.off(`get:${continuityKey}`, sendInitialPayload)\n\t\tsocket.on(`get:${continuityKey}`, sendInitialPayload)\n\n\t\tconst fillTransactionRequest = prepareToServeTransactionRequest(\n\t\t\tstore,\n\t\t\tcontinuity,\n\t\t\tuserKey,\n\t\t)\n\n\t\tsocket.off(`tx-run:${continuityKey}`, fillTransactionRequest)\n\t\tsocket.on(`tx-run:${continuityKey}`, fillTransactionRequest)\n\n\t\tconst trackClientAcknowledgement = prepareToTrackClientAcknowledgement(\n\t\t\tstore,\n\t\t\tcontinuity,\n\t\t\tuserKey,\n\t\t\tuserUnacknowledgedUpdates,\n\t\t)\n\n\t\tsocket?.on(`ack:${continuityKey}`, trackClientAcknowledgement)\n\n\t\treturn () => {\n\t\t\t// clearInterval(retryTimeout)\n\t\t\tfor (const unsubscribe of unsubscribeFunctions) unsubscribe()\n\t\t\tsocket?.off(`ack:${continuityKey}`, trackClientAcknowledgement)\n\t\t\tsocket?.off(`get:${continuityKey}`, sendInitialPayload)\n\t\t\tsocket?.off(`tx-run:${continuityKey}`, fillTransactionRequest)\n\t\t}\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport { actUponStore, IMPLICIT } from \"atom.io/internal\"\nimport type { JsonIO } from \"atom.io/json\"\n\nimport type { ServerConfig } from \".\"\n\nexport type ActionReceiver = ReturnType<typeof realtimeActionReceiver>\nexport function realtimeActionReceiver({\n\tsocket,\n\tstore = IMPLICIT.STORE,\n}: ServerConfig) {\n\treturn function actionReceiver<F extends JsonIO>(\n\t\ttx: AtomIO.TransactionToken<F>,\n\t): () => void {\n\t\tconst fillTransactionRequest = (\n\t\t\tupdate: Pick<AtomIO.TransactionUpdate<F>, `id` | `params`>,\n\t\t) => {\n\t\t\tconst performanceKey = `tx-run:${tx.key}:${update.id}`\n\t\t\tconst performanceKeyStart = `${performanceKey}:start`\n\t\t\tconst performanceKeyEnd = `${performanceKey}:end`\n\t\t\tperformance.mark(performanceKeyStart)\n\t\t\tactUponStore<F>(store, tx, update.id)(...update.params)\n\t\t\tperformance.mark(performanceKeyEnd)\n\t\t\tconst metric = performance.measure(\n\t\t\t\tperformanceKey,\n\t\t\t\tperformanceKeyStart,\n\t\t\t\tperformanceKeyEnd,\n\t\t\t)\n\t\t\tstore?.logger.info(`🚀`, `transaction`, tx.key, update.id, metric.duration)\n\t\t}\n\t\tsocket.on(`tx-run:${tx.key}`, fillTransactionRequest)\n\n\t\treturn () => {\n\t\t\tsocket.off(`tx-run:${tx.key}`, fillTransactionRequest)\n\t\t}\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport {\n\tfindInStore,\n\tgetFromStore,\n\tIMPLICIT,\n\tsubscribeToState,\n} from \"atom.io/internal\"\nimport type { Canonical, Json } from \"atom.io/json\"\nimport { stringifyJson } from \"atom.io/json\"\n\nimport type { ServerConfig } from \".\"\n\nexport type FamilyProvider = ReturnType<typeof realtimeAtomFamilyProvider>\nexport function realtimeAtomFamilyProvider({\n\tsocket,\n\tstore = IMPLICIT.STORE,\n}: ServerConfig) {\n\treturn function familyProvider<\n\t\tJ extends Json.Serializable,\n\t\tK extends Canonical,\n\t>(\n\t\tfamily: AtomIO.RegularAtomFamilyToken<J, K>,\n\t\tindex: AtomIO.ReadableToken<Iterable<K>>,\n\t): () => void {\n\t\tconst unsubCallbacksByKey = new Map<string, () => void>()\n\n\t\tconst fillUnsubRequest = (key: string) => {\n\t\t\tsocket.off(`unsub:${key}`, fillUnsubRequest)\n\t\t\tconst unsub = unsubCallbacksByKey.get(key)\n\t\t\tif (unsub) {\n\t\t\t\tunsub()\n\t\t\t\tunsubCallbacksByKey.delete(key)\n\t\t\t}\n\t\t}\n\n\t\tconst fillSubRequest = (subKey: K) => {\n\t\t\tconst exposedSubKeys = getFromStore(store, index)\n\t\t\tfor (const exposedSubKey of exposedSubKeys) {\n\t\t\t\tif (stringifyJson(exposedSubKey) === stringifyJson(subKey)) {\n\t\t\t\t\tconst token = findInStore(store, family, subKey)\n\t\t\t\t\tsocket.emit(`serve:${token.key}`, getFromStore(store, token))\n\t\t\t\t\tconst unsubscribe = subscribeToState(\n\t\t\t\t\t\tstore,\n\t\t\t\t\t\ttoken,\n\t\t\t\t\t\t`expose-family:${family.key}:${socket.id}`,\n\t\t\t\t\t\t({ newValue }) => {\n\t\t\t\t\t\t\tsocket.emit(`serve:${token.key}`, newValue)\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t\tunsubCallbacksByKey.set(token.key, unsubscribe)\n\t\t\t\t\tsocket.on(`unsub:${token.key}`, () => {\n\t\t\t\t\t\tfillUnsubRequest(token.key)\n\t\t\t\t\t})\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tsocket.on(`sub:${family.key}`, fillSubRequest)\n\n\t\treturn () => {\n\t\t\tsocket.off(`sub:${family.key}`, fillSubRequest)\n\n\t\t\tfor (const [, unsub] of unsubCallbacksByKey) {\n\t\t\t\tunsub()\n\t\t\t}\n\t\t\tunsubCallbacksByKey.clear()\n\t\t}\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Transceiver } from \"atom.io/internal\"\nimport {\n\tfindInStore,\n\tgetFromStore,\n\tgetJsonToken,\n\tgetUpdateToken,\n\tIMPLICIT,\n\tsubscribeToState,\n} from \"atom.io/internal\"\nimport type { Canonical, Json } from \"atom.io/json\"\nimport { stringifyJson } from \"atom.io/json\"\n\nimport type { ServerConfig } from \".\"\n\nexport type MutableFamilyProvider = ReturnType<\n\ttypeof realtimeMutableFamilyProvider\n>\nexport function realtimeMutableFamilyProvider({\n\tsocket,\n\tstore = IMPLICIT.STORE,\n}: ServerConfig) {\n\treturn function mutableFamilyProvider<\n\t\tT extends Transceiver<any>,\n\t\tJ extends Json.Serializable,\n\t\tK extends Canonical,\n\t>(\n\t\tfamily: AtomIO.MutableAtomFamilyToken<T, J, K>,\n\t\tindex: AtomIO.ReadableToken<Iterable<K>>,\n\t): () => void {\n\t\tconst unsubCallbacksByKey = new Map<string, () => void>()\n\n\t\tconst fillUnsubRequest = (key: string) => {\n\t\t\tsocket.off(`unsub:${key}`, fillUnsubRequest)\n\t\t\tconst unsub = unsubCallbacksByKey.get(key)\n\t\t\tif (unsub) {\n\t\t\t\tunsub()\n\t\t\t\tunsubCallbacksByKey.delete(key)\n\t\t\t}\n\t\t}\n\n\t\tconst fillSubRequest = (subKey: K) => {\n\t\t\tconst exposedSubKeys = getFromStore(store, index)\n\t\t\tfor (const exposedSubKey of exposedSubKeys) {\n\t\t\t\tif (stringifyJson(exposedSubKey) === stringifyJson(subKey)) {\n\t\t\t\t\tconst token = findInStore(store, family, subKey)\n\t\t\t\t\tgetFromStore(store, token)\n\t\t\t\t\tconst jsonToken = getJsonToken(store, token)\n\t\t\t\t\tconst updateToken = getUpdateToken(token)\n\t\t\t\t\tsocket.emit(`init:${token.key}`, getFromStore(store, jsonToken))\n\t\t\t\t\tconst unsubscribe = subscribeToState(\n\t\t\t\t\t\tstore,\n\t\t\t\t\t\tupdateToken,\n\t\t\t\t\t\t`expose-family:${family.key}:${socket.id}`,\n\t\t\t\t\t\t({ newValue }) => {\n\t\t\t\t\t\t\tsocket.emit(`next:${token.key}`, newValue)\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t\tunsubCallbacksByKey.set(token.key, unsubscribe)\n\t\t\t\t\tsocket.on(`unsub:${token.key}`, () => {\n\t\t\t\t\t\tfillUnsubRequest(token.key)\n\t\t\t\t\t})\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tsocket.on(`sub:${family.key}`, fillSubRequest)\n\n\t\treturn () => {\n\t\t\tsocket.off(`sub:${family.key}`, fillSubRequest)\n\t\t\tfor (const [, unsub] of unsubCallbacksByKey) {\n\t\t\t\tunsub()\n\t\t\t}\n\t\t\tunsubCallbacksByKey.clear()\n\t\t}\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Transceiver } from \"atom.io/internal\"\nimport {\n\tgetFromStore,\n\tgetJsonToken,\n\tgetUpdateToken,\n\tIMPLICIT,\n\tsubscribeToState,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\n\nimport type { ServerConfig } from \".\"\n\nexport type MutableProvider = ReturnType<typeof realtimeMutableProvider>\nexport function realtimeMutableProvider({\n\tsocket,\n\tstore = IMPLICIT.STORE,\n}: ServerConfig) {\n\treturn function mutableProvider<\n\t\tCore extends Transceiver<Json.Serializable>,\n\t\tSerializableCore extends Json.Serializable,\n\t>(token: AtomIO.MutableAtomToken<Core, SerializableCore>): () => void {\n\t\tlet unsubscribeFromStateUpdates: (() => void) | null = null\n\n\t\tconst jsonToken = getJsonToken(store, token)\n\t\tconst trackerToken = getUpdateToken(token)\n\n\t\tconst fillUnsubRequest = () => {\n\t\t\tsocket.off(`unsub:${token.key}`, fillUnsubRequest)\n\t\t\tunsubscribeFromStateUpdates?.()\n\t\t\tunsubscribeFromStateUpdates = null\n\t\t}\n\n\t\tconst fillSubRequest = () => {\n\t\t\tsocket.emit(`init:${token.key}`, getFromStore(store, jsonToken))\n\t\t\tunsubscribeFromStateUpdates = subscribeToState(\n\t\t\t\tstore,\n\t\t\t\ttrackerToken,\n\t\t\t\t`expose-single:${socket.id}`,\n\t\t\t\t({ newValue }) => {\n\t\t\t\t\tsocket.emit(`next:${token.key}`, newValue)\n\t\t\t\t},\n\t\t\t)\n\t\t\tsocket.on(`unsub:${token.key}`, fillUnsubRequest)\n\t\t}\n\n\t\tsocket.on(`sub:${token.key}`, fillSubRequest)\n\n\t\treturn () => {\n\t\t\tsocket.off(`sub:${token.key}`, fillSubRequest)\n\t\t\tunsubscribeFromStateUpdates?.()\n\t\t}\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport { getFromStore, IMPLICIT, subscribeToState } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\n\nimport type { ServerConfig } from \".\"\n\nexport type StateProvider = ReturnType<typeof realtimeStateProvider>\nexport function realtimeStateProvider({\n\tsocket,\n\tstore = IMPLICIT.STORE,\n}: ServerConfig) {\n\treturn function stateProvider<J extends Json.Serializable>(\n\t\ttoken: AtomIO.WritableToken<J>,\n\t): () => void {\n\t\tlet unsubscribeFromStateUpdates: (() => void) | undefined\n\n\t\tconst fillSubRequest = () => {\n\t\t\tsocket.emit(`serve:${token.key}`, getFromStore(store, token))\n\n\t\t\tunsubscribeFromStateUpdates = subscribeToState(\n\t\t\t\tstore,\n\t\t\t\ttoken,\n\t\t\t\t`expose-single:${socket.id}`,\n\t\t\t\t({ newValue }) => {\n\t\t\t\t\tsocket.emit(`serve:${token.key}`, newValue)\n\t\t\t\t},\n\t\t\t)\n\n\t\t\tconst fillUnsubRequest = () => {\n\t\t\t\tsocket.off(`unsub:${token.key}`, fillUnsubRequest)\n\t\t\t\tif (unsubscribeFromStateUpdates) {\n\t\t\t\t\tunsubscribeFromStateUpdates()\n\t\t\t\t\tunsubscribeFromStateUpdates = undefined\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tsocket.on(`unsub:${token.key}`, fillUnsubRequest)\n\t\t}\n\n\t\tsocket.on(`sub:${token.key}`, fillSubRequest)\n\n\t\treturn () => {\n\t\t\tsocket.off(`sub:${token.key}`, fillSubRequest)\n\t\t\tif (unsubscribeFromStateUpdates) {\n\t\t\t\tunsubscribeFromStateUpdates()\n\t\t\t\tunsubscribeFromStateUpdates = undefined\n\t\t\t}\n\t\t}\n\t}\n}\n","import type { WritableToken } from \"atom.io\"\nimport { IMPLICIT, setIntoStore } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\n\nimport type { ServerConfig } from \".\"\n\nexport type StateReceiver = ReturnType<typeof realtimeStateReceiver>\nexport function realtimeStateReceiver({\n\tsocket,\n\tstore = IMPLICIT.STORE,\n}: ServerConfig) {\n\treturn function stateReceiver<J extends Json.Serializable>(\n\t\ttoken: WritableToken<J>,\n\t): () => void {\n\t\tconst publish = (newValue: J) => {\n\t\t\tsetIntoStore(store, token, newValue)\n\t\t}\n\n\t\tconst fillPubUnclaim = () => {\n\t\t\tsocket.off(`pub:${token.key}`, publish)\n\t\t\tsocket.off(`unclaim:${token.key}`, fillPubUnclaim)\n\t\t}\n\t\tconst fillPubClaim = () => {\n\t\t\tsocket.on(`pub:${token.key}`, publish)\n\t\t\tsocket.on(`unclaim:${token.key}`, fillPubUnclaim)\n\t\t}\n\n\t\tsocket.on(`claim:${token.key}`, fillPubClaim)\n\n\t\treturn () => {\n\t\t\tsocket.off(`claim:${token.key}`, fillPubClaim)\n\t\t\tsocket.off(`pub:${token.key}`, publish)\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;AAkBA,IAAa,eAAb,MAAgF;CAC/E,AAAU;CACV,AAAU;CACV,AAAU,YACT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string","emit: <Event extends keyof I>(\n\t\t\tevent: Event,\n\t\t\t...args: I[Event]\n\t\t) => CustomSocket<I, O>","event: Event","listener: (...args: O[Event]) => void","listener: (event: string, ...args: Json.Array) => void","listener?: (...args: O[Event]) => void","arg: Json.Serializable","process: ChildProcessWithoutNullStreams","key: string","logger?: Pick<Console, `error` | `info` | `warn`>","err: { code: string }","process","buffer: EventBuffer<string, I[Event]>","id: string","buffer: EventBuffer<string, I[Event]>","attachServices: (socket: SubjectSocket<any, any>) => (() => void) | void","roomArgumentsAtoms: RegularAtomFamilyToken<RoomArguments, string>","roomSelectors: ReadonlyPureSelectorFamilyToken<\n\tLoadable<ChildSocket<any, any>>,\n\tstring\n>","data: Buffer","createRoomTX: AtomIO.TransactionToken<\n\t(\n\t\troomId: string,\n\t\tscript: string,\n\t\toptions?: string[],\n\t) => Loadable<ChildSocket<any, any>>\n>","args: RoomArguments","joinRoomTX: AtomIO.TransactionToken<\n\t(roomId: string, userId: string, enteredAtEpoch: number) => UserInRoomMeta\n>","leaveRoomTX: AtomIO.TransactionToken<\n\t(roomId: string, userId: string) => void\n>","destroyRoomTX: AtomIO.TransactionToken<(roomId: string) => void>","visibleStateKeys: string[]","updates: TransactionUpdateContent[]","redactorAtoms: RegularAtomFamilyToken<\n\t{\n\t\tocclude: (updates: TransactionUpdateContent[]) => TransactionUpdateContent[]\n\t},\n\tUserKey\n>","userUnacknowledgedQueues: RegularAtomFamilyToken<\n\tContinuitySyncTransactionUpdate[],\n\tUserKey\n>","socketAtoms: RegularAtomFamilyToken<Socket | null, SocketKey>","socketIndex: MutableAtomToken<\n\tSetRTX<SocketKey>,\n\tSetRTXJson<SocketKey>\n>","userIndex: MutableAtomToken<\n\tSetRTX<UserKey>,\n\tSetRTXJson<UserKey>\n>","usersOfSockets: JoinToken<\n\t`user`,\n\tUserKey,\n\t`socket`,\n\tSocketKey,\n\t`1:1`\n>","store: Store","continuity: ContinuityToken","userKey: UserKey","socket: Socket | null","initialPayload: Json.Serializable[]","atom","store: Store","continuity: ContinuityToken","userKey: string","store: Store","continuity: ContinuityToken","userKey: string","userUnacknowledgedUpdates: ContinuitySyncTransactionUpdate[]","store: Store","continuity: ContinuityToken","userKey: UserKey","socket: Socket | null","unsubscribeFunctions: (() => void)[]","atom","store: Store","continuity: ContinuityToken","userKey: UserKey","socket: Socket | null","unsubFns: (() => void)[]","socket: Socket | null","unsubscribeFunctions: (() => void)[]","tx: AtomIO.TransactionToken<F>","update: Pick<AtomIO.TransactionUpdate<F>, `id` | `params`>","family: AtomIO.RegularAtomFamilyToken<J, K>","index: AtomIO.ReadableToken<Iterable<K>>","key: string","subKey: K","family: AtomIO.MutableAtomFamilyToken<T, J, K>","index: AtomIO.ReadableToken<Iterable<K>>","key: string","subKey: K","token: AtomIO.MutableAtomToken<Core, SerializableCore>","unsubscribeFromStateUpdates: (() => void) | null","token: AtomIO.WritableToken<J>","unsubscribeFromStateUpdates: (() => void) | undefined","token: WritableToken<J>","newValue: J"],"sources":["../../src/realtime-server/ipc-sockets/custom-socket.ts","../../src/realtime-server/ipc-sockets/child-socket.ts","../../src/realtime-server/ipc-sockets/parent-socket.ts","../../src/realtime-server/realtime-server-stores/server-room-external-store.ts","../../src/realtime-server/realtime-server-stores/server-room-external-actions.ts","../../src/realtime-server/realtime-server-stores/server-sync-store.ts","../../src/realtime-server/realtime-server-stores/server-user-store.ts","../../src/realtime-server/continuity/prepare-to-send-initial-payload.ts","../../src/realtime-server/continuity/prepare-to-serve-transaction-request.ts","../../src/realtime-server/continuity/prepare-to-track-client-acknowledgement.ts","../../src/realtime-server/continuity/subscribe-to-continuity-actions.ts","../../src/realtime-server/continuity/subscribe-to-continuity-perpectives.ts","../../src/realtime-server/continuity/prepare-to-sync-realtime-continuity.ts","../../src/realtime-server/realtime-action-receiver.ts","../../src/realtime-server/realtime-family-provider.ts","../../src/realtime-server/realtime-mutable-family-provider.ts","../../src/realtime-server/realtime-mutable-provider.ts","../../src/realtime-server/realtime-state-provider.ts","../../src/realtime-server/realtime-state-receiver.ts"],"sourcesContent":["import type { Json, stringified } from \"atom.io/json\"\n\nimport type { Socket } from \"..\"\n\nexport type Events = Json.Object<string, Json.Serializable[]>\n\nexport type StringifiedEvent<\n\tKey extends string,\n\tParams extends Json.Serializable[],\n> = stringified<[Key, ...Params]>\n\nexport interface EventBuffer<\n\tKey extends string,\n\tParams extends Json.Serializable[],\n> extends Buffer {\n\ttoString(): StringifiedEvent<Key, Params>\n}\n\nexport class CustomSocket<I extends Events, O extends Events> implements Socket {\n\tprotected listeners: Map<keyof O, Set<(...args: Json.Array) => void>>\n\tprotected globalListeners: Set<(event: string, ...args: Json.Array) => void>\n\tprotected handleEvent<Event extends keyof I>(\n\t\tevent: string,\n\t\t...args: I[Event]\n\t): void {\n\t\tfor (const listener of this.globalListeners) {\n\t\t\tlistener(event, ...args)\n\t\t}\n\t\tconst listeners = this.listeners.get(event)\n\t\tif (listeners) {\n\t\t\tfor (const listener of listeners) {\n\t\t\t\tlistener(...args)\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic id = `no_id_retrieved`\n\tpublic emit: <Event extends keyof I>(\n\t\tevent: Event,\n\t\t...args: I[Event]\n\t) => CustomSocket<I, O>\n\n\tpublic constructor(\n\t\temit: <Event extends keyof I>(\n\t\t\tevent: Event,\n\t\t\t...args: I[Event]\n\t\t) => CustomSocket<I, O>,\n\t) {\n\t\tthis.emit = emit\n\t\tthis.listeners = new Map()\n\t\tthis.globalListeners = new Set()\n\t}\n\n\tpublic on<Event extends keyof O>(\n\t\tevent: Event,\n\t\tlistener: (...args: O[Event]) => void,\n\t): this {\n\t\tconst listeners = this.listeners.get(event)\n\t\tif (listeners) {\n\t\t\tlisteners.add(listener)\n\t\t} else {\n\t\t\tthis.listeners.set(event, new Set([listener]))\n\t\t}\n\t\treturn this\n\t}\n\n\tpublic onAny(listener: (event: string, ...args: Json.Array) => void): this {\n\t\tthis.globalListeners.add(listener)\n\t\treturn this\n\t}\n\n\tpublic off<Event extends keyof O>(\n\t\tevent: Event,\n\t\tlistener?: (...args: O[Event]) => void,\n\t): this {\n\t\tconst listeners = this.listeners.get(event)\n\t\tif (listeners) {\n\t\t\tif (listener) {\n\t\t\t\tlisteners.delete(listener)\n\t\t\t} else {\n\t\t\t\tthis.listeners.delete(event)\n\t\t\t}\n\t\t}\n\t\treturn this\n\t}\n\n\tpublic offAny(listener: (event: string, ...args: Json.Array) => void): this {\n\t\tthis.globalListeners.delete(listener)\n\t\treturn this\n\t}\n}\n","import type { ChildProcessWithoutNullStreams } from \"node:child_process\"\n\nimport type { Json } from \"atom.io/json\"\nimport { parseJson } from \"atom.io/json\"\n\nimport type { EventBuffer, Events } from \"./custom-socket\"\nimport { CustomSocket } from \"./custom-socket\"\n\n/* eslint-disable no-console */\n\nexport class ChildSocket<\n\tI extends Events,\n\tO extends Events,\n> extends CustomSocket<I, O> {\n\tprotected incompleteData = ``\n\tprotected unprocessedEvents: string[] = []\n\tprotected incompleteLog = ``\n\tprotected unprocessedLogs: string[] = []\n\n\tpublic id = `#####`\n\n\tpublic process: ChildProcessWithoutNullStreams\n\tpublic key: string\n\tpublic logger: Pick<Console, `error` | `info` | `warn`>\n\n\tprotected handleLog(arg: Json.Serializable): void {\n\t\tif (Array.isArray(arg)) {\n\t\t\tconst [level, ...rest] = arg\n\t\t\tswitch (level) {\n\t\t\t\tcase `i`:\n\t\t\t\t\tthis.logger.info(...rest)\n\t\t\t\t\tbreak\n\t\t\t\tcase `w`:\n\t\t\t\t\tthis.logger.warn(...rest)\n\t\t\t\t\tbreak\n\t\t\t\tcase `e`:\n\t\t\t\t\tthis.logger.error(...rest)\n\t\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic constructor(\n\t\tprocess: ChildProcessWithoutNullStreams,\n\t\tkey: string,\n\t\tlogger?: Pick<Console, `error` | `info` | `warn`>,\n\t) {\n\t\tsuper((event, ...args) => {\n\t\t\tconst stringifiedEvent = JSON.stringify([event, ...args]) + `\\x03`\n\t\t\tconst errorHandler = (err: { code: string }) => {\n\t\t\t\tif (err.code === `EPIPE`) {\n\t\t\t\t\tconsole.error(`EPIPE error during write`, this.process.stdin)\n\t\t\t\t}\n\t\t\t\tthis.process.stdin.removeListener(`error`, errorHandler)\n\t\t\t}\n\n\t\t\tthis.process.stdin.once(`error`, errorHandler)\n\t\t\tthis.process.stdin.write(stringifiedEvent)\n\n\t\t\treturn this\n\t\t})\n\t\tthis.process = process\n\t\tthis.key = key\n\t\tthis.logger = logger ?? {\n\t\t\tinfo: (...args: unknown[]) => {\n\t\t\t\tconsole.info(this.id, this.key, ...args)\n\t\t\t},\n\t\t\twarn: (...args: unknown[]) => {\n\t\t\t\tconsole.warn(this.id, this.key, ...args)\n\t\t\t},\n\t\t\terror: (...args: unknown[]) => {\n\t\t\t\tconsole.error(this.id, this.key, ...args)\n\t\t\t},\n\t\t}\n\t\tthis.process.stdout.on(\n\t\t\t`data`,\n\t\t\t<Event extends keyof I>(buffer: EventBuffer<string, I[Event]>) => {\n\t\t\t\tconst chunk = buffer.toString()\n\n\t\t\t\tif (chunk === `ALIVE`) {\n\t\t\t\t\t// console.log(chunk)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.unprocessedEvents.push(...chunk.split(`\\x03`))\n\t\t\t\t// console.log(`🤓`, chunk.length)\n\t\t\t\t// console.log(`🤓`, this.unprocessedEvents.length)\n\t\t\t\t// console.log(`🤓`, ...this.unprocessedEvents.map((x) => x.length))\n\t\t\t\tconst newInput = this.unprocessedEvents.shift()\n\t\t\t\tthis.incompleteData += newInput ?? ``\n\t\t\t\ttry {\n\t\t\t\t\tif (this.incompleteData.startsWith(`error`)) {\n\t\t\t\t\t\tconsole.log(`❗`, this.incompleteData)\n\t\t\t\t\t}\n\t\t\t\t\tlet parsedEvent = parseJson(this.incompleteData)\n\t\t\t\t\tthis.handleEvent(...(parsedEvent as [string, ...I[keyof I]]))\n\t\t\t\t\twhile (this.unprocessedEvents.length > 0) {\n\t\t\t\t\t\tconst event = this.unprocessedEvents.shift()\n\t\t\t\t\t\tif (event) {\n\t\t\t\t\t\t\tif (this.unprocessedEvents.length === 0) {\n\t\t\t\t\t\t\t\tthis.incompleteData = event\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tparsedEvent = parseJson(event)\n\t\t\t\t\t\t\tthis.handleEvent(...(parsedEvent as [string, ...I[keyof I]]))\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthis.incompleteData = ``\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.warn(`⚠️----------------⚠️`)\n\t\t\t\t\tconsole.warn(this.incompleteData)\n\t\t\t\t\tconsole.warn(`⚠️----------------⚠️`)\n\t\t\t\t\tconsole.error(error)\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\t\tthis.process.stderr.on(`data`, (buf) => {\n\t\t\tconst chunk = buf.toString()\n\t\t\tthis.unprocessedLogs.push(...chunk.split(`\\x03`))\n\t\t\t// console.log(`🤫`, chunk.length)\n\t\t\t// console.log(`🤫`, this.unprocessedLogs.length)\n\t\t\t// console.log(`🤫`, ...this.unprocessedLogs.map((x) => x.length))\n\t\t\tconst newInput = this.unprocessedLogs.shift()\n\t\t\tthis.incompleteLog += newInput ?? ``\n\t\t\ttry {\n\t\t\t\tlet parsedLog = parseJson(this.incompleteLog)\n\t\t\t\t// console.log(`🤫`, parsedLog)\n\t\t\t\tthis.handleLog(parsedLog)\n\t\t\t\twhile (this.unprocessedLogs.length > 0) {\n\t\t\t\t\tthis.incompleteLog = this.unprocessedLogs.shift() ?? ``\n\t\t\t\t\tif (this.incompleteLog) {\n\t\t\t\t\t\tparsedLog = parseJson(this.incompleteLog)\n\t\t\t\t\t\tthis.handleLog(parsedLog)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(`❌❌❌`)\n\t\t\t\tconsole.error(this.incompleteLog)\n\t\t\t\tconsole.error(error)\n\t\t\t\tconsole.error(`❌❌❌️`)\n\t\t\t}\n\t\t})\n\t\tif (process.pid) {\n\t\t\tthis.id = process.pid.toString()\n\t\t}\n\t}\n}\n","import { Subject } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport { parseJson, stringifyJson } from \"atom.io/json\"\nimport { SetRTX } from \"atom.io/transceivers/set-rtx\"\n\nimport type { EventBuffer, Events } from \"./custom-socket\"\nimport { CustomSocket } from \"./custom-socket\"\n\nexport class SubjectSocket<\n\tI extends Events,\n\tO extends Events,\n> extends CustomSocket<I, O> {\n\tpublic in: Subject<[string, ...Json.Serializable[]]>\n\tpublic out: Subject<[string, ...Json.Serializable[]]>\n\tpublic id = `no_id_retrieved`\n\tpublic disposalFunctions: (() => void)[] = []\n\n\tpublic constructor(id: string) {\n\t\tsuper((...args) => {\n\t\t\tthis.out.next(args as any)\n\t\t\treturn this\n\t\t})\n\t\tthis.id = id\n\t\tthis.in = new Subject()\n\t\tthis.out = new Subject()\n\t\tthis.in.subscribe(`socket`, (event) => {\n\t\t\tthis.handleEvent(...(event as [string, ...I[keyof I]]))\n\t\t})\n\t}\n\n\tpublic dispose(): void {\n\t\tfor (const dispose of this.disposalFunctions) {\n\t\t\tdispose()\n\t\t}\n\t}\n}\n\nexport class ParentSocket<\n\tI extends Events & {\n\t\t[id in string as `relay:${id}`]: [string, ...Json.Serializable[]]\n\t},\n\tO extends Events & {\n\t\t[id in string as `user:${id}`]: [string, ...Json.Serializable[]]\n\t} & {\n\t\t/* eslint-disable quotes */\n\t\t\"user-joins\": [string]\n\t\t\"user-leaves\": [string]\n\t\t/* eslint-enable quotes */\n\t},\n> extends CustomSocket<I, O> {\n\tprotected incompleteData = ``\n\tprotected unprocessedEvents: string[] = []\n\tprotected relays: Map<string, SubjectSocket<any, any>>\n\tprotected relayServices: ((\n\t\tsocket: SubjectSocket<any, any>,\n\t) => (() => void) | void)[]\n\tprotected process: NodeJS.Process\n\n\tpublic id = `#####`\n\n\tprotected log(...args: any[]): void {\n\t\tthis.process.stderr.write(\n\t\t\tstringifyJson(\n\t\t\t\targs.map((arg) =>\n\t\t\t\t\targ instanceof SetRTX\n\t\t\t\t\t\t? `{ ${arg.toJSON().members.join(` | `)} }`\n\t\t\t\t\t\t: arg,\n\t\t\t\t),\n\t\t\t) + `\\x03`,\n\t\t)\n\t}\n\tpublic logger = {\n\t\tinfo: (...args: any[]): void => {\n\t\t\tthis.log(`i`, ...args)\n\t\t},\n\t\twarn: (...args: any[]): void => {\n\t\t\tthis.log(`w`, ...args)\n\t\t},\n\t\terror: (...args: any[]): void => {\n\t\t\tthis.log(`e`, ...args)\n\t\t},\n\t}\n\n\tpublic constructor() {\n\t\tsuper((event, ...args) => {\n\t\t\tconst stringifiedEvent = JSON.stringify([event, ...args])\n\t\t\tthis.process.stdout.write(stringifiedEvent + `\\x03`)\n\t\t\treturn this\n\t\t})\n\t\tthis.process = process\n\t\tthis.process.stdin.resume()\n\t\tthis.relays = new Map()\n\t\tthis.relayServices = []\n\t\t// this.logger.info(`🔗`, `uplink`, process.pid)\n\n\t\tthis.process.stdin.on(\n\t\t\t`data`,\n\t\t\t<Event extends keyof I>(buffer: EventBuffer<string, I[Event]>) => {\n\t\t\t\tconst chunk = buffer.toString()\n\t\t\t\tthis.unprocessedEvents.push(...chunk.split(`\\x03`))\n\t\t\t\tconst newInput = this.unprocessedEvents.shift()\n\t\t\t\tthis.incompleteData += newInput ?? ``\n\n\t\t\t\ttry {\n\t\t\t\t\tconst parsedData = parseJson(this.incompleteData)\n\t\t\t\t\tthis.logger.info(`🎰`, `received`, parsedData)\n\t\t\t\t\tthis.handleEvent(...(parsedData as [string, ...I[keyof I]]))\n\t\t\t\t\twhile (this.unprocessedEvents.length > 0) {\n\t\t\t\t\t\tconst event = this.unprocessedEvents.shift()\n\t\t\t\t\t\tif (event) {\n\t\t\t\t\t\t\tif (this.unprocessedEvents.length === 0) {\n\t\t\t\t\t\t\t\tthis.incompleteData = event\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst parsedEvent = parseJson(event)\n\t\t\t\t\t\t\tthis.handleEvent(...(parsedEvent as [string, ...I[keyof I]]))\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthis.incompleteData = ``\n\t\t\t\t} catch (thrown) {\n\t\t\t\t\tif (thrown instanceof Error) {\n\t\t\t\t\t\tthis.logger.error(`❗`, thrown.message, thrown.cause, thrown.stack)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\n\t\tthis.on(`exit`, () => {\n\t\t\tthis.logger.info(`🔥`, this.id, `received \"exit\"`)\n\t\t\tprocess.exit(0)\n\t\t})\n\t\tprocess.on(`exit`, (code) => {\n\t\t\tthis.logger.info(`🔥`, this.id, `exited with code ${code}`)\n\t\t})\n\t\tprocess.on(`end`, () => {\n\t\t\tthis.logger.info(`🔥`, this.id, `ended`)\n\t\t\tprocess.exit(0)\n\t\t})\n\t\tprocess.on(`SIGTERM`, () => {\n\t\t\tthis.logger.error(`🔥`, this.id, `terminated`)\n\t\t\tprocess.exit(0)\n\t\t})\n\t\tprocess.on(`SIGINT`, () => {\n\t\t\tthis.logger.error(`🔥`, this.id, `interrupted`)\n\t\t\tprocess.exit(0)\n\t\t})\n\n\t\tif (process.pid) {\n\t\t\tthis.id = process.pid?.toString()\n\t\t}\n\n\t\tthis.on(`user-joins`, (username) => {\n\t\t\tthis.logger.info(`👤`, `user`, username, `joined`)\n\t\t\tconst relay = new SubjectSocket(`user:${username}`)\n\t\t\tthis.relays.set(username, relay)\n\t\t\tthis.logger.info(\n\t\t\t\t`🔗`,\n\t\t\t\t`attaching services:`,\n\t\t\t\t`[${[...this.relayServices.keys()].join(`, `)}]`,\n\t\t\t)\n\t\t\tfor (const attachServices of this.relayServices) {\n\t\t\t\tconst cleanup = attachServices(relay)\n\t\t\t\tif (cleanup) {\n\t\t\t\t\trelay.disposalFunctions.push(cleanup)\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.on(`user:${username}`, (...data) => {\n\t\t\t\trelay.in.next(data)\n\t\t\t})\n\t\t\trelay.out.subscribe(`socket`, (data) => {\n\t\t\t\tthis.emit(...(data as [string, ...I[keyof I]]))\n\t\t\t})\n\t\t})\n\n\t\tthis.on(`user-leaves`, (username) => {\n\t\t\tconst relay = this.relays.get(username)\n\t\t\tthis.off(`relay:${username}`)\n\t\t\tif (relay) {\n\t\t\t\trelay.dispose()\n\t\t\t\tthis.relays.delete(username)\n\t\t\t}\n\t\t})\n\n\t\tprocess.stdout.write(`ALIVE`)\n\t}\n\n\tpublic relay(\n\t\tattachServices: (socket: SubjectSocket<any, any>) => (() => void) | void,\n\t): void {\n\t\tthis.logger.info(`🔗`, `running relay method`)\n\t\tthis.relayServices.push(attachServices)\n\t}\n}\n","import type { ChildProcessWithoutNullStreams } from \"node:child_process\"\nimport { spawn } from \"node:child_process\"\n\nimport type {\n\tLoadable,\n\tReadonlyPureSelectorFamilyToken,\n\tRegularAtomFamilyToken,\n} from \"atom.io\"\nimport { atomFamily, selectorFamily } from \"atom.io\"\n\nimport { ChildSocket } from \"../ipc-sockets\"\n\nexport type RoomArguments =\n\t| [script: string, options: string[]]\n\t| [script: string]\n\nexport const roomArgumentsAtoms: RegularAtomFamilyToken<RoomArguments, string> =\n\tatomFamily<RoomArguments, string>({\n\t\tkey: `roomArguments`,\n\t\tdefault: [`echo`, [`Hello World!`]],\n\t})\n\nexport const roomSelectors: ReadonlyPureSelectorFamilyToken<\n\tLoadable<ChildSocket<any, any>>,\n\tstring\n> = selectorFamily<Loadable<ChildSocket<any, any>>, string>({\n\tkey: `room`,\n\tget:\n\t\t(roomId) =>\n\t\tasync ({ get, find }) => {\n\t\t\tconst argumentsState = find(roomArgumentsAtoms, roomId)\n\t\t\tconst args = get(argumentsState)\n\t\t\tconst [script, options] = args\n\t\t\tconst child = await new Promise<ChildProcessWithoutNullStreams>(\n\t\t\t\t(resolve) => {\n\t\t\t\t\tconst room = spawn(script, options, { env: process.env })\n\t\t\t\t\tconst resolver = (data: Buffer) => {\n\t\t\t\t\t\tif (data.toString() === `ALIVE`) {\n\t\t\t\t\t\t\troom.stdout.off(`data`, resolver)\n\t\t\t\t\t\t\tresolve(room)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\troom.stdout.on(`data`, resolver)\n\t\t\t\t},\n\t\t\t)\n\t\t\treturn new ChildSocket(child, roomId)\n\t\t},\n})\n","import type { Loadable } from \"atom.io\"\nimport * as AtomIO from \"atom.io\"\nimport { editRelationsInStore } from \"atom.io/internal\"\nimport type { UserInRoomMeta } from \"atom.io/realtime\"\nimport { roomIndex, usersInRooms } from \"atom.io/realtime\"\n\nimport type { ChildSocket } from \"../ipc-sockets\"\nimport type { RoomArguments } from \"./server-room-external-store\"\nimport { roomArgumentsAtoms, roomSelectors } from \"./server-room-external-store\"\n\nexport const createRoomTX: AtomIO.TransactionToken<\n\t(\n\t\troomId: string,\n\t\tscript: string,\n\t\toptions?: string[],\n\t) => Loadable<ChildSocket<any, any>>\n> = AtomIO.transaction({\n\tkey: `createRoom`,\n\tdo: ({ get, set, find }, roomId, script, options) => {\n\t\tconst args: RoomArguments = options ? [script, options] : [script]\n\t\tconst roomArgumentsState = find(roomArgumentsAtoms, roomId)\n\t\tset(roomArgumentsState, args)\n\t\tset(roomIndex, (s) => s.add(roomId))\n\t\tconst roomState = find(roomSelectors, roomId)\n\t\tconst room = get(roomState)\n\t\treturn room\n\t},\n})\nexport type CreateRoomIO = AtomIO.TransactionIO<typeof createRoomTX>\n\nexport const joinRoomTX: AtomIO.TransactionToken<\n\t(roomId: string, userId: string, enteredAtEpoch: number) => UserInRoomMeta\n> = AtomIO.transaction({\n\tkey: `joinRoom`,\n\tdo: (tools, roomId, userId, enteredAtEpoch) => {\n\t\tconst meta = { enteredAtEpoch }\n\t\teditRelationsInStore(\n\t\t\tusersInRooms,\n\t\t\t(relations) => {\n\t\t\t\trelations.set({ room: roomId, user: userId }, meta)\n\t\t\t},\n\t\t\ttools.env().store,\n\t\t)\n\t\treturn meta\n\t},\n})\nexport type JoinRoomIO = AtomIO.TransactionIO<typeof joinRoomTX>\n\nexport const leaveRoomTX: AtomIO.TransactionToken<\n\t(roomId: string, userId: string) => void\n> = AtomIO.transaction({\n\tkey: `leaveRoom`,\n\tdo: (tools, roomId, userId) => {\n\t\teditRelationsInStore(\n\t\t\tusersInRooms,\n\t\t\t(relations) => {\n\t\t\t\trelations.delete({ room: roomId, user: userId })\n\t\t\t},\n\t\t\ttools.env().store,\n\t\t)\n\t},\n})\nexport type LeaveRoomIO = AtomIO.TransactionIO<typeof leaveRoomTX>\n\nexport const destroyRoomTX: AtomIO.TransactionToken<(roomId: string) => void> =\n\tAtomIO.transaction({\n\t\tkey: `destroyRoom`,\n\t\tdo: (tools, roomId) => {\n\t\t\teditRelationsInStore(\n\t\t\t\tusersInRooms,\n\t\t\t\t(relations) => {\n\t\t\t\t\trelations.delete({ room: roomId })\n\t\t\t\t},\n\t\t\t\ttools.env().store,\n\t\t\t)\n\t\t\ttools.set(roomIndex, (s) => (s.delete(roomId), s))\n\t\t},\n\t})\n","import type {\n\tRegularAtomFamilyToken,\n\tTransactionUpdate,\n\tTransactionUpdateContent,\n} from \"atom.io\"\nimport { atomFamily } from \"atom.io\"\n\nimport type { UserKey } from \"./server-user-store\"\n\n// export const completeUpdateAtoms = atomFamily<\n// \tTransactionUpdate<any> | null,\n// \tstring\n// >({\n// \tkey: `completeUpdate`,\n// \tdefault: null,\n// })\n\nexport function redactTransactionUpdateContent(\n\tvisibleStateKeys: string[],\n\tupdates: TransactionUpdateContent[],\n): TransactionUpdateContent[] {\n\treturn updates\n\t\t.map((update): TransactionUpdateContent => {\n\t\t\tswitch (update.type) {\n\t\t\t\tcase `transaction_update`: {\n\t\t\t\t\tconst redacted = redactTransactionUpdateContent(\n\t\t\t\t\t\tvisibleStateKeys,\n\t\t\t\t\t\tupdate.updates,\n\t\t\t\t\t)\n\t\t\t\t\treturn { ...update, updates: redacted }\n\t\t\t\t}\n\t\t\t\tcase `atom_update`:\n\t\t\t\tcase `selector_update`:\n\t\t\t\tcase `molecule_creation`:\n\t\t\t\tcase `molecule_disposal`:\n\t\t\t\tcase `molecule_transfer`:\n\t\t\t\tcase `state_creation`:\n\t\t\t\tcase `state_disposal`:\n\t\t\t\t\treturn update\n\t\t\t}\n\t\t})\n\t\t.filter((update) => {\n\t\t\tswitch (update.type) {\n\t\t\t\tcase `atom_update`:\n\t\t\t\tcase `selector_update`:\n\t\t\t\t\treturn visibleStateKeys.includes(update.key)\n\t\t\t\tcase `state_creation`:\n\t\t\t\tcase `state_disposal`:\n\t\t\t\t\treturn visibleStateKeys.includes(update.token.key)\n\t\t\t\tcase `molecule_creation`:\n\t\t\t\tcase `transaction_update`:\n\t\t\t\tcase `molecule_disposal`:\n\t\t\t\tcase `molecule_transfer`:\n\t\t\t\t\treturn true\n\t\t\t}\n\t\t})\n}\n\nexport const redactorAtoms: RegularAtomFamilyToken<\n\t{\n\t\tocclude: (updates: TransactionUpdateContent[]) => TransactionUpdateContent[]\n\t},\n\tUserKey\n> = atomFamily<\n\t{\n\t\tocclude: (updates: TransactionUpdateContent[]) => TransactionUpdateContent[]\n\t},\n\tUserKey\n>({\n\tkey: `redactor`,\n\tdefault: { occlude: (updates) => updates },\n})\n// export const redactedUpdateSelectors = selectorFamily<\n// \tTransactionUpdate<any> | null,\n// \t[transactionKey: string, updateId: string]\n// >({\n// \tkey: `redactedUpdate`,\n// \tget:\n// \t\t([transactionKey, updateId]) =>\n// \t\t({ get, find }) => {\n// \t\t\tconst update = get(find(completeUpdateAtoms, updateId))\n// \t\t\tconst { filter } = get(find(transactionRedactorAtoms, transactionKey))\n\n// \t\t\tif (update && filter) {\n// \t\t\t\treturn { ...update, updates: filter(update.updates) }\n// \t\t\t}\n// \t\t\treturn null\n// \t\t},\n// })\n\nexport type ContinuitySyncTransactionUpdate = Pick<\n\tTransactionUpdate<any>,\n\t`epoch` | `id` | `key` | `output` | `updates`\n>\nexport const userUnacknowledgedQueues: RegularAtomFamilyToken<\n\tContinuitySyncTransactionUpdate[],\n\tUserKey\n> = atomFamily<ContinuitySyncTransactionUpdate[], UserKey>({\n\tkey: `unacknowledgedUpdates`,\n\tdefault: () => [],\n})\n","import type {\n\tHierarchy,\n\tJoinToken,\n\tMutableAtomToken,\n\tRegularAtomFamilyToken,\n} from \"atom.io\"\nimport { atom, atomFamily, join } from \"atom.io\"\nimport type { SetRTXJson } from \"atom.io/transceivers/set-rtx\"\nimport { SetRTX } from \"atom.io/transceivers/set-rtx\"\n\nimport type { Socket } from \"..\"\n\nexport type SocketKey = `socket::${string}`\nexport type UserKey = `user::${string}`\nexport type RoomKey = `room::${string}`\n\nexport type SocketSystemHierarchy = Hierarchy<\n\t[\n\t\t{\n\t\t\tabove: `root`\n\t\t\tbelow: [UserKey, SocketKey, RoomKey]\n\t\t},\n\t]\n>\n\nexport const socketAtoms: RegularAtomFamilyToken<Socket | null, SocketKey> =\n\tatomFamily<Socket | null, SocketKey>({\n\t\tkey: `sockets`,\n\t\tdefault: null,\n\t})\n\nexport const socketIndex: MutableAtomToken<\n\tSetRTX<SocketKey>,\n\tSetRTXJson<SocketKey>\n> = atom<SetRTX<SocketKey>, SetRTXJson<SocketKey>>({\n\tkey: `socketsIndex`,\n\tmutable: true,\n\tdefault: () => new SetRTX(),\n\ttoJson: (set) => set.toJSON(),\n\tfromJson: (json) => SetRTX.fromJSON(json),\n})\nexport const userIndex: MutableAtomToken<\n\tSetRTX<UserKey>,\n\tSetRTXJson<UserKey>\n> = atom<SetRTX<UserKey>, SetRTXJson<UserKey>>({\n\tkey: `usersIndex`,\n\tmutable: true,\n\tdefault: () => new SetRTX(),\n\ttoJson: (set) => set.toJSON(),\n\tfromJson: (json) => SetRTX.fromJSON(json),\n})\nexport const usersOfSockets: JoinToken<\n\t`user`,\n\tUserKey,\n\t`socket`,\n\tSocketKey,\n\t`1:1`\n> = join({\n\tkey: `usersOfSockets`,\n\tbetween: [`user`, `socket`],\n\tcardinality: `1:1`,\n\tisAType: (s): s is UserKey => s.startsWith(`user::`),\n\tisBType: (s): s is SocketKey => s.startsWith(`socket::`),\n})\n","import type { Store } from \"atom.io/internal\"\nimport {\n\tfindInStore,\n\tgetFromStore,\n\tgetJsonToken,\n\tisRootStore,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { ContinuityToken } from \"atom.io/realtime\"\n\nimport type { Socket, UserKey } from \"..\"\n\nexport function prepareToSendInitialPayload(\n\tstore: Store,\n\tcontinuity: ContinuityToken,\n\tuserKey: UserKey,\n\tsocket: Socket | null,\n): () => void {\n\tconst continuityKey = continuity.key\n\treturn function sendInitialPayload(): void {\n\t\tconst initialPayload: Json.Serializable[] = []\n\t\tfor (const atom of continuity.globals) {\n\t\t\tconst resourceToken =\n\t\t\t\tatom.type === `mutable_atom` ? getJsonToken(store, atom) : atom\n\t\t\tconst resource = getFromStore(store, resourceToken)\n\t\t\tinitialPayload.push(resourceToken, resource)\n\t\t}\n\t\tfor (const perspective of continuity.perspectives) {\n\t\t\tconst { viewAtoms, resourceAtoms } = perspective\n\t\t\tconst userViewState = findInStore(store, viewAtoms, userKey)\n\t\t\tconst userView = getFromStore(store, userViewState)\n\t\t\tstore.logger.info(`👁`, `atom`, resourceAtoms.key, `${userKey} can see`, {\n\t\t\t\tviewAtoms,\n\t\t\t\tresourceAtoms,\n\t\t\t\tuserView,\n\t\t\t})\n\t\t\tfor (const visibleToken of userView) {\n\t\t\t\tconst resourceToken =\n\t\t\t\t\tvisibleToken.type === `mutable_atom`\n\t\t\t\t\t\t? getJsonToken(store, visibleToken)\n\t\t\t\t\t\t: visibleToken\n\t\t\t\tconst resource = getFromStore(store, resourceToken)\n\n\t\t\t\tinitialPayload.push(resourceToken, resource)\n\t\t\t}\n\t\t}\n\n\t\tconst epoch = isRootStore(store)\n\t\t\t? (store.transactionMeta.epoch.get(continuityKey) ?? null)\n\t\t\t: null\n\n\t\tsocket?.emit(`continuity-init:${continuityKey}`, epoch, initialPayload)\n\t}\n}\n","import type { TransactionUpdate } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { actUponStore } from \"atom.io/internal\"\nimport type { JsonIO } from \"atom.io/json\"\nimport type { ContinuityToken } from \"atom.io/realtime\"\n\nexport function prepareToServeTransactionRequest(\n\tstore: Store,\n\tcontinuity: ContinuityToken,\n\tuserKey: string,\n): (update: Pick<TransactionUpdate<JsonIO>, `id` | `key` | `params`>) => void {\n\tconst continuityKey = continuity.key\n\treturn function serveTransactionRequest(update) {\n\t\tstore.logger.info(`🛎️`, `continuity`, continuityKey, `received`, update)\n\t\tconst transactionKey = update.key\n\t\tconst updateId = update.id\n\t\tconst performanceKey = `tx-run:${transactionKey}:${updateId}`\n\t\tconst performanceKeyStart = `${performanceKey}:start`\n\t\tconst performanceKeyEnd = `${performanceKey}:end`\n\t\tperformance.mark(performanceKeyStart)\n\t\ttry {\n\t\t\tactUponStore(\n\t\t\t\tstore,\n\t\t\t\t{ type: `transaction`, key: transactionKey },\n\t\t\t\tupdateId,\n\t\t\t)(...update.params)\n\t\t} catch (thrown) {\n\t\t\tif (thrown instanceof Error) {\n\t\t\t\tstore.logger.error(\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`failed to run transaction ${transactionKey} from ${userKey} with update ${updateId}`,\n\t\t\t\t\tthrown.message,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tperformance.mark(performanceKeyEnd)\n\t\tconst metric = performance.measure(\n\t\t\tperformanceKey,\n\t\t\tperformanceKeyStart,\n\t\t\tperformanceKeyEnd,\n\t\t)\n\t\tstore?.logger.info(\n\t\t\t`🚀`,\n\t\t\t`transaction`,\n\t\t\ttransactionKey,\n\t\t\tupdateId,\n\t\t\tuserKey,\n\t\t\tmetric.duration,\n\t\t)\n\t}\n}\n","import type { Store } from \"atom.io/internal\"\nimport { setIntoStore } from \"atom.io/internal\"\nimport type { ContinuityToken } from \"atom.io/realtime\"\n\nimport type { ContinuitySyncTransactionUpdate } from \"../realtime-server-stores\"\nimport { userUnacknowledgedQueues } from \"../realtime-server-stores\"\n\nexport function prepareToTrackClientAcknowledgement(\n\tstore: Store,\n\tcontinuity: ContinuityToken,\n\tuserKey: string,\n\tuserUnacknowledgedUpdates: ContinuitySyncTransactionUpdate[],\n): (epoch: number) => void {\n\tconst continuityKey = continuity.key\n\treturn function trackClientAcknowledgement(epoch) {\n\t\tstore.logger.info(\n\t\t\t`👍`,\n\t\t\t`continuity`,\n\t\t\tcontinuityKey,\n\t\t\t`${userKey} acknowledged epoch ${epoch}`,\n\t\t)\n\t\tconst isUnacknowledged = userUnacknowledgedUpdates[0]?.epoch === epoch\n\t\tif (isUnacknowledged) {\n\t\t\tsetIntoStore(store, userUnacknowledgedQueues, userKey, (updates) => {\n\t\t\t\tupdates.shift()\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`${userKey} unacknowledged update queue now has`,\n\t\t\t\t\tupdates.length,\n\t\t\t\t\t`items`,\n\t\t\t\t)\n\t\t\t\treturn updates\n\t\t\t})\n\t\t}\n\t}\n}\n","import type { Store } from \"atom.io/internal\"\nimport {\n\tfindInStore,\n\tgetFromStore,\n\tgetUpdateToken,\n\tsetIntoStore,\n\tsubscribeToTransaction,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { ContinuityToken } from \"atom.io/realtime\"\n\nimport type { Socket, UserKey } from \"..\"\nimport {\n\tredactTransactionUpdateContent,\n\tuserUnacknowledgedQueues,\n} from \"../realtime-server-stores\"\n\nexport function subscribeToContinuityActions(\n\tstore: Store,\n\tcontinuity: ContinuityToken,\n\tuserKey: UserKey,\n\tsocket: Socket | null,\n): (() => void)[] {\n\tconst continuityKey = continuity.key\n\tconst unsubscribeFunctions: (() => void)[] = []\n\n\tfor (const transaction of continuity.actions) {\n\t\tconst unsubscribeFromTransaction = subscribeToTransaction(\n\t\t\tstore,\n\t\t\ttransaction,\n\t\t\t`sync-continuity:${continuityKey}:${userKey}`,\n\t\t\t(update) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst visibleKeys = continuity.globals\n\t\t\t\t\t\t.map((atom) => {\n\t\t\t\t\t\t\tif (atom.type === `atom`) {\n\t\t\t\t\t\t\t\treturn atom.key\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn getUpdateToken(atom).key\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.concat(\n\t\t\t\t\t\t\tcontinuity.perspectives.flatMap((perspective) => {\n\t\t\t\t\t\t\t\tconst { viewAtoms } = perspective\n\t\t\t\t\t\t\t\tconst userPerspectiveTokenState = findInStore(\n\t\t\t\t\t\t\t\t\tstore,\n\t\t\t\t\t\t\t\t\tviewAtoms,\n\t\t\t\t\t\t\t\t\tuserKey,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tconst visibleTokens = getFromStore(\n\t\t\t\t\t\t\t\t\tstore,\n\t\t\t\t\t\t\t\t\tuserPerspectiveTokenState,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\treturn visibleTokens.map((token) => {\n\t\t\t\t\t\t\t\t\tconst key =\n\t\t\t\t\t\t\t\t\t\ttoken.type === `mutable_atom` ? `*` + token.key : token.key\n\t\t\t\t\t\t\t\t\treturn key\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)\n\t\t\t\t\tconst redactedUpdates = redactTransactionUpdateContent(\n\t\t\t\t\t\tvisibleKeys,\n\t\t\t\t\t\tupdate.updates,\n\t\t\t\t\t)\n\t\t\t\t\tconst redactedUpdate = {\n\t\t\t\t\t\t...update,\n\t\t\t\t\t\tupdates: redactedUpdates,\n\t\t\t\t\t}\n\t\t\t\t\tsetIntoStore(store, userUnacknowledgedQueues, userKey, (updates) => {\n\t\t\t\t\t\tif (redactedUpdate) {\n\t\t\t\t\t\t\tupdates.push(redactedUpdate)\n\t\t\t\t\t\t\tupdates.sort((a, b) => a.epoch - b.epoch)\n\t\t\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t\t\t`👍`,\n\t\t\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t\t\t`${userKey} unacknowledged update queue now has`,\n\t\t\t\t\t\t\t\tupdates.length,\n\t\t\t\t\t\t\t\t`items`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn updates\n\t\t\t\t\t})\n\n\t\t\t\t\tsocket?.emit(\n\t\t\t\t\t\t`tx-new:${continuityKey}`,\n\t\t\t\t\t\tredactedUpdate as Json.Serializable,\n\t\t\t\t\t)\n\t\t\t\t} catch (thrown) {\n\t\t\t\t\tif (thrown instanceof Error) {\n\t\t\t\t\t\tstore.logger.error(\n\t\t\t\t\t\t\t`❌`,\n\t\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t\t`${userKey} failed to send update from transaction ${transaction.key} to ${userKey}`,\n\t\t\t\t\t\t\tthrown.message,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\t\tunsubscribeFunctions.push(unsubscribeFromTransaction)\n\t}\n\treturn unsubscribeFunctions\n}\n","import type { Store } from \"atom.io/internal\"\nimport {\n\tfindInStore,\n\tgetFromStore,\n\tgetJsonToken,\n\tsubscribeToState,\n} from \"atom.io/internal\"\nimport type { ContinuityToken } from \"atom.io/realtime\"\n\nimport type { Socket } from \"..\"\nimport type { UserKey } from \"../realtime-server-stores\"\n\nexport function subscribeToContinuityPerspectives(\n\tstore: Store,\n\tcontinuity: ContinuityToken,\n\tuserKey: UserKey,\n\tsocket: Socket | null,\n): (() => void)[] {\n\tconst continuityKey = continuity.key\n\tconst unsubFns: (() => void)[] = []\n\tfor (const perspective of continuity.perspectives) {\n\t\tconst { viewAtoms } = perspective\n\t\tconst userViewState = findInStore(store, viewAtoms, userKey)\n\t\tconst unsubscribeFromUserView = subscribeToState(\n\t\t\tstore,\n\t\t\tuserViewState,\n\t\t\t`sync-continuity:${continuityKey}:${userKey}:perspective:${perspective.resourceAtoms.key}`,\n\t\t\t({ oldValue, newValue }) => {\n\t\t\t\tconst oldKeys = oldValue.map((token) => token.key)\n\t\t\t\tconst newKeys = newValue.map((token) => token.key)\n\t\t\t\tconst concealed = oldValue.filter(\n\t\t\t\t\t(token) => !newKeys.includes(token.key),\n\t\t\t\t)\n\t\t\t\tconst revealed = newValue\n\t\t\t\t\t.filter((token) => !oldKeys.includes(token.key))\n\t\t\t\t\t.flatMap((token) => {\n\t\t\t\t\t\tconst resourceToken =\n\t\t\t\t\t\t\ttoken.type === `mutable_atom` ? getJsonToken(store, token) : token\n\t\t\t\t\t\tconst resource = getFromStore(store, resourceToken)\n\t\t\t\t\t\treturn [resourceToken, resource]\n\t\t\t\t\t})\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`👁`,\n\t\t\t\t\t`atom`,\n\t\t\t\t\tperspective.resourceAtoms.key,\n\t\t\t\t\t`${userKey} has a new perspective`,\n\t\t\t\t\t{ oldKeys, newKeys, revealed, concealed },\n\t\t\t\t)\n\t\t\t\tif (revealed.length > 0) {\n\t\t\t\t\tsocket?.emit(`reveal:${continuityKey}`, revealed)\n\t\t\t\t}\n\t\t\t\tif (concealed.length > 0) {\n\t\t\t\t\tsocket?.emit(`conceal:${continuityKey}`, concealed)\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\t\tunsubFns.push(unsubscribeFromUserView)\n\t}\n\treturn unsubFns\n}\n","import {\n\tfindInStore,\n\tfindRelationsInStore,\n\tgetFromStore,\n\tIMPLICIT,\n\tsubscribeToState,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { ContinuityToken } from \"atom.io/realtime\"\n\nimport type { ServerConfig, Socket } from \"..\"\nimport { socketAtoms, usersOfSockets } from \"..\"\nimport { userUnacknowledgedQueues } from \"../realtime-server-stores\"\nimport { prepareToSendInitialPayload } from \"./prepare-to-send-initial-payload\"\nimport { prepareToServeTransactionRequest } from \"./prepare-to-serve-transaction-request\"\nimport { prepareToTrackClientAcknowledgement } from \"./prepare-to-track-client-acknowledgement\"\nimport { subscribeToContinuityActions } from \"./subscribe-to-continuity-actions\"\nimport { subscribeToContinuityPerspectives } from \"./subscribe-to-continuity-perpectives\"\n\nexport type ExposeRealtimeContinuity = (\n\tcontinuity: ContinuityToken,\n) => () => void\nexport function prepareToExposeRealtimeContinuity({\n\tsocket: initialSocket,\n\tstore = IMPLICIT.STORE,\n}: ServerConfig): ExposeRealtimeContinuity {\n\treturn function syncRealtimeContinuity(continuity) {\n\t\tlet socket: Socket | null = initialSocket\n\n\t\tconst continuityKey = continuity.key\n\t\tconst userKeyState = findRelationsInStore(\n\t\t\tusersOfSockets,\n\t\t\t`socket::${socket.id}`,\n\t\t\tstore,\n\t\t).userKeyOfSocket\n\t\tconst userKey = getFromStore(store, userKeyState)\n\t\tif (!userKey) {\n\t\t\tstore.logger.error(\n\t\t\t\t`❌`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`Tried to create a synchronizer for a socket (${socket.id}) that is not connected to a user.`,\n\t\t\t)\n\t\t\treturn () => {}\n\t\t}\n\n\t\tconst socketKeyState = findRelationsInStore(\n\t\t\tusersOfSockets,\n\t\t\tuserKey,\n\t\t\tstore,\n\t\t).socketKeyOfUser\n\t\tconst _unsubscribeFromSocketTracking = subscribeToState(\n\t\t\tstore,\n\t\t\tsocketKeyState,\n\t\t\t`sync-continuity:${continuityKey}:${userKey}`,\n\t\t\t({ newValue: newSocketKey }) => {\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`seeing ${userKey} on new socket ${newSocketKey}`,\n\t\t\t\t)\n\t\t\t\tif (newSocketKey === null) {\n\t\t\t\t\tstore.logger.warn(\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`User (${userKey}) is not connected to a socket, waiting for them to reappear.`,\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tconst newSocketState = findInStore(store, socketAtoms, newSocketKey)\n\t\t\t\tconst newSocket = getFromStore(store, newSocketState)\n\t\t\t\tsocket = newSocket\n\t\t\t\tfor (const unacknowledgedUpdate of userUnacknowledgedUpdates) {\n\t\t\t\t\tsocket?.emit(\n\t\t\t\t\t\t`tx-new:${continuityKey}`,\n\t\t\t\t\t\tunacknowledgedUpdate as Json.Serializable,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\n\t\tconst userUnacknowledgedUpdates = getFromStore(\n\t\t\tstore,\n\t\t\tuserUnacknowledgedQueues,\n\t\t\tuserKey,\n\t\t)\n\n\t\tconst unsubscribeFunctions: (() => void)[] = []\n\n\t\tconst unsubscribeFromPerspectives = subscribeToContinuityPerspectives(\n\t\t\tstore,\n\t\t\tcontinuity,\n\t\t\tuserKey,\n\t\t\tsocket,\n\t\t)\n\t\tconst unsubscribeFromTransactions = subscribeToContinuityActions(\n\t\t\tstore,\n\t\t\tcontinuity,\n\t\t\tuserKey,\n\t\t\tsocket,\n\t\t)\n\t\tunsubscribeFunctions.push(\n\t\t\t...unsubscribeFromPerspectives,\n\t\t\t...unsubscribeFromTransactions,\n\t\t)\n\n\t\tconst sendInitialPayload = prepareToSendInitialPayload(\n\t\t\tstore,\n\t\t\tcontinuity,\n\t\t\tuserKey,\n\t\t\tinitialSocket,\n\t\t)\n\n\t\tsocket.off(`get:${continuityKey}`, sendInitialPayload)\n\t\tsocket.on(`get:${continuityKey}`, sendInitialPayload)\n\n\t\tconst fillTransactionRequest = prepareToServeTransactionRequest(\n\t\t\tstore,\n\t\t\tcontinuity,\n\t\t\tuserKey,\n\t\t)\n\n\t\tsocket.off(`tx-run:${continuityKey}`, fillTransactionRequest)\n\t\tsocket.on(`tx-run:${continuityKey}`, fillTransactionRequest)\n\n\t\tconst trackClientAcknowledgement = prepareToTrackClientAcknowledgement(\n\t\t\tstore,\n\t\t\tcontinuity,\n\t\t\tuserKey,\n\t\t\tuserUnacknowledgedUpdates,\n\t\t)\n\n\t\tsocket?.on(`ack:${continuityKey}`, trackClientAcknowledgement)\n\n\t\treturn () => {\n\t\t\t// clearInterval(retryTimeout)\n\t\t\tfor (const unsubscribe of unsubscribeFunctions) unsubscribe()\n\t\t\tsocket?.off(`ack:${continuityKey}`, trackClientAcknowledgement)\n\t\t\tsocket?.off(`get:${continuityKey}`, sendInitialPayload)\n\t\t\tsocket?.off(`tx-run:${continuityKey}`, fillTransactionRequest)\n\t\t}\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport { actUponStore, IMPLICIT } from \"atom.io/internal\"\nimport type { JsonIO } from \"atom.io/json\"\n\nimport type { ServerConfig } from \".\"\n\nexport type ActionReceiver = ReturnType<typeof realtimeActionReceiver>\nexport function realtimeActionReceiver({\n\tsocket,\n\tstore = IMPLICIT.STORE,\n}: ServerConfig) {\n\treturn function actionReceiver<F extends JsonIO>(\n\t\ttx: AtomIO.TransactionToken<F>,\n\t): () => void {\n\t\tconst fillTransactionRequest = (\n\t\t\tupdate: Pick<AtomIO.TransactionUpdate<F>, `id` | `params`>,\n\t\t) => {\n\t\t\tconst performanceKey = `tx-run:${tx.key}:${update.id}`\n\t\t\tconst performanceKeyStart = `${performanceKey}:start`\n\t\t\tconst performanceKeyEnd = `${performanceKey}:end`\n\t\t\tperformance.mark(performanceKeyStart)\n\t\t\tactUponStore<F>(store, tx, update.id)(...update.params)\n\t\t\tperformance.mark(performanceKeyEnd)\n\t\t\tconst metric = performance.measure(\n\t\t\t\tperformanceKey,\n\t\t\t\tperformanceKeyStart,\n\t\t\t\tperformanceKeyEnd,\n\t\t\t)\n\t\t\tstore?.logger.info(`🚀`, `transaction`, tx.key, update.id, metric.duration)\n\t\t}\n\t\tsocket.on(`tx-run:${tx.key}`, fillTransactionRequest)\n\n\t\treturn () => {\n\t\t\tsocket.off(`tx-run:${tx.key}`, fillTransactionRequest)\n\t\t}\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport {\n\tfindInStore,\n\tgetFromStore,\n\tIMPLICIT,\n\tsubscribeToState,\n} from \"atom.io/internal\"\nimport type { Canonical, Json } from \"atom.io/json\"\nimport { stringifyJson } from \"atom.io/json\"\n\nimport type { ServerConfig } from \".\"\n\nexport type FamilyProvider = ReturnType<typeof realtimeAtomFamilyProvider>\nexport function realtimeAtomFamilyProvider({\n\tsocket,\n\tstore = IMPLICIT.STORE,\n}: ServerConfig) {\n\treturn function familyProvider<\n\t\tJ extends Json.Serializable,\n\t\tK extends Canonical,\n\t>(\n\t\tfamily: AtomIO.RegularAtomFamilyToken<J, K>,\n\t\tindex: AtomIO.ReadableToken<Iterable<K>>,\n\t): () => void {\n\t\tconst unsubCallbacksByKey = new Map<string, () => void>()\n\n\t\tconst fillUnsubRequest = (key: string) => {\n\t\t\tsocket.off(`unsub:${key}`, fillUnsubRequest)\n\t\t\tconst unsub = unsubCallbacksByKey.get(key)\n\t\t\tif (unsub) {\n\t\t\t\tunsub()\n\t\t\t\tunsubCallbacksByKey.delete(key)\n\t\t\t}\n\t\t}\n\n\t\tconst fillSubRequest = (subKey: K) => {\n\t\t\tconst exposedSubKeys = getFromStore(store, index)\n\t\t\tfor (const exposedSubKey of exposedSubKeys) {\n\t\t\t\tif (stringifyJson(exposedSubKey) === stringifyJson(subKey)) {\n\t\t\t\t\tconst token = findInStore(store, family, subKey)\n\t\t\t\t\tsocket.emit(`serve:${token.key}`, getFromStore(store, token))\n\t\t\t\t\tconst unsubscribe = subscribeToState(\n\t\t\t\t\t\tstore,\n\t\t\t\t\t\ttoken,\n\t\t\t\t\t\t`expose-family:${family.key}:${socket.id}`,\n\t\t\t\t\t\t({ newValue }) => {\n\t\t\t\t\t\t\tsocket.emit(`serve:${token.key}`, newValue)\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t\tunsubCallbacksByKey.set(token.key, unsubscribe)\n\t\t\t\t\tsocket.on(`unsub:${token.key}`, () => {\n\t\t\t\t\t\tfillUnsubRequest(token.key)\n\t\t\t\t\t})\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tsocket.on(`sub:${family.key}`, fillSubRequest)\n\n\t\treturn () => {\n\t\t\tsocket.off(`sub:${family.key}`, fillSubRequest)\n\n\t\t\tfor (const [, unsub] of unsubCallbacksByKey) {\n\t\t\t\tunsub()\n\t\t\t}\n\t\t\tunsubCallbacksByKey.clear()\n\t\t}\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Transceiver } from \"atom.io/internal\"\nimport {\n\tfindInStore,\n\tgetFromStore,\n\tgetJsonToken,\n\tgetUpdateToken,\n\tIMPLICIT,\n\tsubscribeToState,\n} from \"atom.io/internal\"\nimport type { Canonical, Json } from \"atom.io/json\"\nimport { stringifyJson } from \"atom.io/json\"\n\nimport type { ServerConfig } from \".\"\n\nexport type MutableFamilyProvider = ReturnType<\n\ttypeof realtimeMutableFamilyProvider\n>\nexport function realtimeMutableFamilyProvider({\n\tsocket,\n\tstore = IMPLICIT.STORE,\n}: ServerConfig) {\n\treturn function mutableFamilyProvider<\n\t\tT extends Transceiver<any>,\n\t\tJ extends Json.Serializable,\n\t\tK extends Canonical,\n\t>(\n\t\tfamily: AtomIO.MutableAtomFamilyToken<T, J, K>,\n\t\tindex: AtomIO.ReadableToken<Iterable<K>>,\n\t): () => void {\n\t\tconst unsubCallbacksByKey = new Map<string, () => void>()\n\n\t\tconst fillUnsubRequest = (key: string) => {\n\t\t\tsocket.off(`unsub:${key}`, fillUnsubRequest)\n\t\t\tconst unsub = unsubCallbacksByKey.get(key)\n\t\t\tif (unsub) {\n\t\t\t\tunsub()\n\t\t\t\tunsubCallbacksByKey.delete(key)\n\t\t\t}\n\t\t}\n\n\t\tconst fillSubRequest = (subKey: K) => {\n\t\t\tconst exposedSubKeys = getFromStore(store, index)\n\t\t\tfor (const exposedSubKey of exposedSubKeys) {\n\t\t\t\tif (stringifyJson(exposedSubKey) === stringifyJson(subKey)) {\n\t\t\t\t\tconst token = findInStore(store, family, subKey)\n\t\t\t\t\tgetFromStore(store, token)\n\t\t\t\t\tconst jsonToken = getJsonToken(store, token)\n\t\t\t\t\tconst updateToken = getUpdateToken(token)\n\t\t\t\t\tsocket.emit(`init:${token.key}`, getFromStore(store, jsonToken))\n\t\t\t\t\tconst unsubscribe = subscribeToState(\n\t\t\t\t\t\tstore,\n\t\t\t\t\t\tupdateToken,\n\t\t\t\t\t\t`expose-family:${family.key}:${socket.id}`,\n\t\t\t\t\t\t({ newValue }) => {\n\t\t\t\t\t\t\tsocket.emit(`next:${token.key}`, newValue)\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t\tunsubCallbacksByKey.set(token.key, unsubscribe)\n\t\t\t\t\tsocket.on(`unsub:${token.key}`, () => {\n\t\t\t\t\t\tfillUnsubRequest(token.key)\n\t\t\t\t\t})\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tsocket.on(`sub:${family.key}`, fillSubRequest)\n\n\t\treturn () => {\n\t\t\tsocket.off(`sub:${family.key}`, fillSubRequest)\n\t\t\tfor (const [, unsub] of unsubCallbacksByKey) {\n\t\t\t\tunsub()\n\t\t\t}\n\t\t\tunsubCallbacksByKey.clear()\n\t\t}\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Transceiver } from \"atom.io/internal\"\nimport {\n\tgetFromStore,\n\tgetJsonToken,\n\tgetUpdateToken,\n\tIMPLICIT,\n\tsubscribeToState,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\n\nimport type { ServerConfig } from \".\"\n\nexport type MutableProvider = ReturnType<typeof realtimeMutableProvider>\nexport function realtimeMutableProvider({\n\tsocket,\n\tstore = IMPLICIT.STORE,\n}: ServerConfig) {\n\treturn function mutableProvider<\n\t\tCore extends Transceiver<Json.Serializable>,\n\t\tSerializableCore extends Json.Serializable,\n\t>(token: AtomIO.MutableAtomToken<Core, SerializableCore>): () => void {\n\t\tlet unsubscribeFromStateUpdates: (() => void) | null = null\n\n\t\tconst jsonToken = getJsonToken(store, token)\n\t\tconst trackerToken = getUpdateToken(token)\n\n\t\tconst fillUnsubRequest = () => {\n\t\t\tsocket.off(`unsub:${token.key}`, fillUnsubRequest)\n\t\t\tunsubscribeFromStateUpdates?.()\n\t\t\tunsubscribeFromStateUpdates = null\n\t\t}\n\n\t\tconst fillSubRequest = () => {\n\t\t\tsocket.emit(`init:${token.key}`, getFromStore(store, jsonToken))\n\t\t\tunsubscribeFromStateUpdates = subscribeToState(\n\t\t\t\tstore,\n\t\t\t\ttrackerToken,\n\t\t\t\t`expose-single:${socket.id}`,\n\t\t\t\t({ newValue }) => {\n\t\t\t\t\tsocket.emit(`next:${token.key}`, newValue)\n\t\t\t\t},\n\t\t\t)\n\t\t\tsocket.on(`unsub:${token.key}`, fillUnsubRequest)\n\t\t}\n\n\t\tsocket.on(`sub:${token.key}`, fillSubRequest)\n\n\t\treturn () => {\n\t\t\tsocket.off(`sub:${token.key}`, fillSubRequest)\n\t\t\tunsubscribeFromStateUpdates?.()\n\t\t}\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport { getFromStore, IMPLICIT, subscribeToState } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\n\nimport type { ServerConfig } from \".\"\n\nexport type StateProvider = ReturnType<typeof realtimeStateProvider>\nexport function realtimeStateProvider({\n\tsocket,\n\tstore = IMPLICIT.STORE,\n}: ServerConfig) {\n\treturn function stateProvider<J extends Json.Serializable>(\n\t\ttoken: AtomIO.WritableToken<J>,\n\t): () => void {\n\t\tlet unsubscribeFromStateUpdates: (() => void) | undefined\n\n\t\tconst fillSubRequest = () => {\n\t\t\tsocket.emit(`serve:${token.key}`, getFromStore(store, token))\n\n\t\t\tunsubscribeFromStateUpdates = subscribeToState(\n\t\t\t\tstore,\n\t\t\t\ttoken,\n\t\t\t\t`expose-single:${socket.id}`,\n\t\t\t\t({ newValue }) => {\n\t\t\t\t\tsocket.emit(`serve:${token.key}`, newValue)\n\t\t\t\t},\n\t\t\t)\n\n\t\t\tconst fillUnsubRequest = () => {\n\t\t\t\tsocket.off(`unsub:${token.key}`, fillUnsubRequest)\n\t\t\t\tif (unsubscribeFromStateUpdates) {\n\t\t\t\t\tunsubscribeFromStateUpdates()\n\t\t\t\t\tunsubscribeFromStateUpdates = undefined\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tsocket.on(`unsub:${token.key}`, fillUnsubRequest)\n\t\t}\n\n\t\tsocket.on(`sub:${token.key}`, fillSubRequest)\n\n\t\treturn () => {\n\t\t\tsocket.off(`sub:${token.key}`, fillSubRequest)\n\t\t\tif (unsubscribeFromStateUpdates) {\n\t\t\t\tunsubscribeFromStateUpdates()\n\t\t\t\tunsubscribeFromStateUpdates = undefined\n\t\t\t}\n\t\t}\n\t}\n}\n","import type { WritableToken } from \"atom.io\"\nimport { IMPLICIT, setIntoStore } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\n\nimport type { ServerConfig } from \".\"\n\nexport type StateReceiver = ReturnType<typeof realtimeStateReceiver>\nexport function realtimeStateReceiver({\n\tsocket,\n\tstore = IMPLICIT.STORE,\n}: ServerConfig) {\n\treturn function stateReceiver<J extends Json.Serializable>(\n\t\ttoken: WritableToken<J>,\n\t): () => void {\n\t\tconst publish = (newValue: J) => {\n\t\t\tsetIntoStore(store, token, newValue)\n\t\t}\n\n\t\tconst fillPubUnclaim = () => {\n\t\t\tsocket.off(`pub:${token.key}`, publish)\n\t\t\tsocket.off(`unclaim:${token.key}`, fillPubUnclaim)\n\t\t}\n\t\tconst fillPubClaim = () => {\n\t\t\tsocket.on(`pub:${token.key}`, publish)\n\t\t\tsocket.on(`unclaim:${token.key}`, fillPubUnclaim)\n\t\t}\n\n\t\tsocket.on(`claim:${token.key}`, fillPubClaim)\n\n\t\treturn () => {\n\t\t\tsocket.off(`claim:${token.key}`, fillPubClaim)\n\t\t\tsocket.off(`pub:${token.key}`, publish)\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;AAkBA,IAAa,eAAb,MAAgF;CAC/E,AAAU;CACV,AAAU;CACV,AAAU,YACTA,OACA,GAAG,MACI;AACP,OAAK,MAAM,YAAY,KAAK,iBAC3B,SAAS,OAAO,GAAG,KAAK;EAEzB,MAAM,YAAY,KAAK,UAAU,IAAI,MAAM;AAC3C,MAAI,UACH,MAAK,MAAM,YAAY,WACtB,SAAS,GAAG,KAAK;CAGnB;CAED,AAAO,KAAK,CAAC,eAAe,CAAC;CAC7B,AAAO;CAKP,AAAO,YACNC,MAIC;EACD,KAAK,OAAO;EACZ,KAAK,4BAAY,IAAI;EACrB,KAAK,kCAAkB,IAAI;CAC3B;CAED,AAAO,GACNC,OACAC,UACO;EACP,MAAM,YAAY,KAAK,UAAU,IAAI,MAAM;AAC3C,MAAI,WACH,UAAU,IAAI,SAAS;OAEvB,KAAK,UAAU,IAAI,OAAO,IAAI,IAAI,CAAC,QAAS,GAAE;AAE/C,SAAO;CACP;CAED,AAAO,MAAMC,UAA8D;EAC1E,KAAK,gBAAgB,IAAI,SAAS;AAClC,SAAO;CACP;CAED,AAAO,IACNF,OACAG,UACO;EACP,MAAM,YAAY,KAAK,UAAU,IAAI,MAAM;AAC3C,MAAI,UACH,KAAI,UACH,UAAU,OAAO,SAAS;OAE1B,KAAK,UAAU,OAAO,MAAM;AAG9B,SAAO;CACP;CAED,AAAO,OAAOD,UAA8D;EAC3E,KAAK,gBAAgB,OAAO,SAAS;AACrC,SAAO;CACP;AACD;;;;AChFD,IAAa,cAAb,cAGU,aAAmB;CAC5B,AAAU,iBAAiB,EAAE;CAC7B,AAAU,oBAA8B,CAAE;CAC1C,AAA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K,EAAE,eAAe;EACjD;EAED,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,EAAE,aAAa;AAE7C,SAAO,MAAM;GACZ,OAAO,IAAI,CAAC,MAAM,EAAE,MAAM,KAAK,EAAE,aAAa;GAC9C,OAAO,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,EAAE,QAAQ;EACvC;CACD;AACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atom.io",
|
|
3
|
-
"version": "0.34.
|
|
3
|
+
"version": "0.34.1",
|
|
4
4
|
"description": "Composable and testable reactive data library.",
|
|
5
5
|
"homepage": "https://atom.io.fyi",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@eslint/core": "0.15.1",
|
|
64
|
-
"@storybook/addon-docs": "9.0
|
|
65
|
-
"@storybook/addon-onboarding": "9.0
|
|
66
|
-
"@storybook/react-vite": "9.0
|
|
64
|
+
"@storybook/addon-docs": "9.1.0",
|
|
65
|
+
"@storybook/addon-onboarding": "9.1.0",
|
|
66
|
+
"@storybook/react-vite": "9.1.0",
|
|
67
67
|
"@testing-library/react": "16.3.0",
|
|
68
68
|
"@types/bun": "npm:bun-types@1.2.19",
|
|
69
69
|
"@types/eslint": "9.6.1",
|
|
@@ -94,11 +94,11 @@
|
|
|
94
94
|
"recoverage": "0.1.11",
|
|
95
95
|
"socket.io": "4.8.1",
|
|
96
96
|
"socket.io-client": "4.8.1",
|
|
97
|
-
"storybook": "9.0
|
|
97
|
+
"storybook": "9.1.0",
|
|
98
98
|
"tmp": "0.2.3",
|
|
99
99
|
"tsdown": "0.13.0",
|
|
100
100
|
"tsx": "4.20.3",
|
|
101
|
-
"typescript": "5.
|
|
101
|
+
"typescript": "5.9.2",
|
|
102
102
|
"vite": "7.0.6",
|
|
103
103
|
"vite-tsconfig-paths": "5.1.4",
|
|
104
104
|
"vitest": "3.2.4",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { JoinOptions, JoinToken } from "atom.io"
|
|
2
|
+
import type { Store } from "atom.io/internal"
|
|
3
|
+
import { Join } from "atom.io/internal"
|
|
4
|
+
import type { Json } from "atom.io/json"
|
|
5
|
+
|
|
6
|
+
export function createJoin<
|
|
7
|
+
ASide extends string,
|
|
8
|
+
AType extends string,
|
|
9
|
+
BSide extends string,
|
|
10
|
+
BType extends string,
|
|
11
|
+
Cardinality extends `1:1` | `1:n` | `n:n`,
|
|
12
|
+
Content extends Json.Object,
|
|
13
|
+
>(
|
|
14
|
+
store: Store,
|
|
15
|
+
options: JoinOptions<ASide, AType, BSide, BType, Cardinality, Content>,
|
|
16
|
+
defaultContent: Content | undefined,
|
|
17
|
+
): JoinToken<ASide, AType, BSide, BType, Cardinality, Content> {
|
|
18
|
+
store.joins.set(options.key, new Join(options, defaultContent, store))
|
|
19
|
+
const token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content> = {
|
|
20
|
+
key: options.key,
|
|
21
|
+
type: `join`,
|
|
22
|
+
a: options.between[0],
|
|
23
|
+
b: options.between[1],
|
|
24
|
+
cardinality: options.cardinality,
|
|
25
|
+
}
|
|
26
|
+
return token
|
|
27
|
+
}
|
package/src/internal/junction.ts
CHANGED
|
@@ -18,7 +18,9 @@ export interface JunctionEntries<
|
|
|
18
18
|
JunctionEntriesBase<AType, BType, Content> {}
|
|
19
19
|
|
|
20
20
|
export type JunctionSchemaBase<ASide extends string, BSide extends string> = {
|
|
21
|
+
/** Description of the relationship between the two sides */
|
|
21
22
|
readonly between: [a: ASide, b: BSide]
|
|
23
|
+
/** How many relations are allowed in each direction? */
|
|
22
24
|
readonly cardinality: `1:1` | `1:n` | `n:n`
|
|
23
25
|
}
|
|
24
26
|
export interface JunctionSchema<ASide extends string, BSide extends string>
|
package/src/json/index.ts
CHANGED
|
@@ -51,6 +51,9 @@ export const stringifyJson = <J extends Json.Serializable>(
|
|
|
51
51
|
json: J,
|
|
52
52
|
): stringified<J> => JSON.stringify(json) as stringified<J>
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Always serializes to the same string.
|
|
56
|
+
*/
|
|
54
57
|
export type Canonical = primitive | ReadonlyArray<Canonical>
|
|
55
58
|
|
|
56
59
|
export type JsonIO = (...params: Json.Serializable[]) => Json.Serializable | void
|
package/src/main/atom.ts
CHANGED
|
@@ -22,7 +22,6 @@ import type { AtomToken, MutableAtomToken, RegularAtomToken, Setter } from "."
|
|
|
22
22
|
export function atom<T extends Transceiver<any>, J extends Json.Serializable>(
|
|
23
23
|
options: MutableAtomOptions<T, J>,
|
|
24
24
|
): MutableAtomToken<T, J>
|
|
25
|
-
|
|
26
25
|
/**
|
|
27
26
|
* @public
|
|
28
27
|
* Create a regular atom, a global reactive variable in the implicit store
|
|
@@ -71,14 +70,24 @@ export type RegularAtomOptions<T> = {
|
|
|
71
70
|
/** Hooks used to run side effects when the atom is set */
|
|
72
71
|
effects?: AtomEffect<T>[]
|
|
73
72
|
}
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
|
|
74
|
+
/** @public */
|
|
75
|
+
// biome-ignore format: intersection
|
|
76
|
+
export type MutableAtomOptions<
|
|
77
|
+
T extends Transceiver<any>,
|
|
78
|
+
J extends Json.Serializable,
|
|
79
|
+
> =
|
|
76
80
|
& JsonInterface<T, J>
|
|
77
|
-
&
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
& {
|
|
82
|
+
/** Used to signal that the atom is mutable */
|
|
83
|
+
mutable: true
|
|
84
|
+
/** The unique identifier of the atom */
|
|
85
|
+
key: string
|
|
86
|
+
/** A function to create an initial value for the atom */
|
|
87
|
+
default: () => T
|
|
88
|
+
/** Hooks used to run side effects when the atom is set */
|
|
89
|
+
effects?: AtomEffect<T>[]
|
|
90
|
+
}
|
|
82
91
|
|
|
83
92
|
/** @public */
|
|
84
93
|
export type RegularAtomFamilyOptions<T, K extends Canonical> = {
|
|
@@ -91,24 +100,33 @@ export type RegularAtomFamilyOptions<T, K extends Canonical> = {
|
|
|
91
100
|
}
|
|
92
101
|
|
|
93
102
|
export type RegularAtomFamilyToken<T, K extends Canonical> = {
|
|
103
|
+
/** The unique identifier of the atom family */
|
|
94
104
|
key: string
|
|
105
|
+
/** Discriminator */
|
|
95
106
|
type: `atom_family`
|
|
107
|
+
/** Never present. This is a marker that preserves the type of atoms in this family */
|
|
96
108
|
__T?: T
|
|
109
|
+
/** Never present. This is a marker that preserves the type of keys used for atoms in this family */
|
|
97
110
|
__K?: K
|
|
98
111
|
}
|
|
99
112
|
|
|
113
|
+
/** @public */
|
|
100
114
|
// biome-ignore format: intersection
|
|
101
115
|
export type MutableAtomFamilyOptions<
|
|
102
116
|
T extends Transceiver<any>,
|
|
103
117
|
J extends Json.Serializable,
|
|
104
118
|
K extends Canonical,
|
|
105
|
-
> =
|
|
106
|
-
& JsonInterface<T, J>
|
|
107
|
-
& {
|
|
119
|
+
> =
|
|
120
|
+
& JsonInterface<T, J>
|
|
121
|
+
& {
|
|
122
|
+
/** Used to signal that the atoms created from this family are mutable */
|
|
123
|
+
mutable: true
|
|
124
|
+
/** The unique identifier of the atom family */
|
|
108
125
|
key: string
|
|
126
|
+
/** A function to create an initial value for each atom in the family */
|
|
109
127
|
default: (key: K) => T
|
|
128
|
+
/** Hooks used to run side effects when an atom in the family is set */
|
|
110
129
|
effects?: (key: K) => AtomEffect<T>[]
|
|
111
|
-
mutable: true,
|
|
112
130
|
}
|
|
113
131
|
|
|
114
132
|
export type MutableAtomFamilyToken<
|
|
@@ -116,22 +134,45 @@ export type MutableAtomFamilyToken<
|
|
|
116
134
|
J extends Json.Serializable,
|
|
117
135
|
K extends Canonical,
|
|
118
136
|
> = {
|
|
137
|
+
/** The unique identifier of the atom family */
|
|
119
138
|
key: string
|
|
139
|
+
/** Discriminator */
|
|
120
140
|
type: `mutable_atom_family`
|
|
141
|
+
/** Never present. This is a marker that preserves the type of atoms in this family */
|
|
121
142
|
__T?: T
|
|
143
|
+
/** Never present. This is a marker that preserves the type of the JSON form of atoms in this family */
|
|
122
144
|
__J?: J
|
|
145
|
+
/** Never present. This is a marker that preserves the type of keys used for atoms in this family */
|
|
123
146
|
__K?: K
|
|
124
147
|
}
|
|
125
|
-
|
|
126
148
|
export type AtomFamilyToken<T, K extends Canonical = Canonical> =
|
|
127
149
|
| MutableAtomFamilyToken<T extends Transceiver<any> ? T : never, any, K>
|
|
128
150
|
| RegularAtomFamilyToken<T, K>
|
|
129
151
|
|
|
152
|
+
/**
|
|
153
|
+
* @public
|
|
154
|
+
* Create a family of mutable atoms, allowing for the dynamic creation and disposal of atoms.
|
|
155
|
+
*
|
|
156
|
+
* The value of a mutable atom must be some kind of {@link Transceiver}.
|
|
157
|
+
*
|
|
158
|
+
* @param options - {@link MutableAtomFamilyOptions}
|
|
159
|
+
* @returns
|
|
160
|
+
* A reference to the atom family created: a {@link MutableAtomFamilyToken}
|
|
161
|
+
* @overload Mutable
|
|
162
|
+
*/
|
|
130
163
|
export function atomFamily<
|
|
131
164
|
T extends Transceiver<any>,
|
|
132
165
|
J extends Json.Serializable,
|
|
133
166
|
K extends Canonical,
|
|
134
167
|
>(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamilyToken<T, J, K>
|
|
168
|
+
/**
|
|
169
|
+
* @public
|
|
170
|
+
* Create a family of regular atoms, allowing for the dynamic creation and disposal of atoms.
|
|
171
|
+
* @param options - {@link RegularAtomFamilyOptions}
|
|
172
|
+
* @returns
|
|
173
|
+
* A reference to the atom family created: a {@link RegularAtomFamilyToken}
|
|
174
|
+
* @overload Regular
|
|
175
|
+
*/
|
|
135
176
|
export function atomFamily<T, K extends Canonical>(
|
|
136
177
|
options: RegularAtomFamilyOptions<T, K>,
|
|
137
178
|
): RegularAtomFamilyToken<T, K>
|
|
@@ -5,14 +5,20 @@ import type { ReadableFamilyToken, ReadableToken } from "."
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @public
|
|
8
|
-
* Disposes of a state in the implicit store
|
|
8
|
+
* Disposes of a state in the implicit store.
|
|
9
|
+
*
|
|
10
|
+
* Only family members can be disposed of.
|
|
11
|
+
*
|
|
9
12
|
* @param token - The token of the state to dispose
|
|
10
13
|
* @overload Default
|
|
11
14
|
*/
|
|
12
15
|
export function disposeState(token: ReadableToken<any>): void
|
|
13
16
|
/**
|
|
14
17
|
* @public
|
|
15
|
-
* Disposes of a state
|
|
18
|
+
* Disposes of a state in the implicit store.
|
|
19
|
+
*
|
|
20
|
+
* Only family members can be disposed of.
|
|
21
|
+
*
|
|
16
22
|
* @param token - The token of the state family to dispose
|
|
17
23
|
* @param key - The unique key of the state to dispose
|
|
18
24
|
*/
|