room-kit 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,16 @@
1
+ name: Publish
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: read
13
+ id-token: write
14
+ steps:
15
+ - uses: actions/checkout@v6
16
+ - run: npx jsr publish
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Scott Lott
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,262 @@
1
+ # room-kit
2
+
3
+ [![GitHub Repo stars](https://img.shields.io/github/stars/only-cliches/room-kit)](https://github.com/only-cliches/room-kit)
4
+ [![NPM Version](https://img.shields.io/npm/v/room-kit)](https://www.npmjs.com/package/room-kit)
5
+ [![JSR Version](https://img.shields.io/jsr/v/%40onlycliches/room-kit)](https://jsr.io/@onlycliches/room-kit)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue.svg)](https://www.typescriptlang.org/)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+
9
+ Small and type-safe room membership, presence, and realtime messaging for Socket.IO.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install room-kit socket.io socket.io-client
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ```ts
20
+ // common.ts
21
+ import { defineRoomType } from "room-kit";
22
+
23
+ // Shared room schema used by both server and client.
24
+ type ChatMessage = {
25
+ id: string;
26
+ name: string;
27
+ text: string;
28
+ sentAt: string;
29
+ };
30
+
31
+ // The generic schema below drives the inferred server and client typing.
32
+ export const chatRoom = defineRoomType<{
33
+ // Data required from the client to join a room.
34
+ joinRequest: {
35
+ roomId: string;
36
+ roomKey: string;
37
+ userName: string;
38
+ };
39
+ // Per-member metadata stored by the server.
40
+ memberProfile: {
41
+ userId: string;
42
+ userName: string;
43
+ };
44
+ // Per-room metadata exposed to every joined client.
45
+ roomProfile: {
46
+ roomId: string;
47
+ created: string;
48
+ };
49
+ // Private mutable state that only lives on the server.
50
+ serverState: {
51
+ roomKey: string;
52
+ created: string;
53
+ history: ChatMessage[];
54
+ };
55
+ // Named events the server can emit to room members.
56
+ events: {
57
+ message: ChatMessage;
58
+ systemNotice: { text: string; sentAt: string };
59
+ };
60
+ // Typed request/response calls for validated mutations.
61
+ rpc: {
62
+ sendMessage: (input: { text: string }): Promise<{ id: string }>;
63
+ };
64
+ }>({ name: "chat", presence: "list" });
65
+ ```
66
+
67
+ ```ts
68
+ // server.ts
69
+ import { randomUUID } from "node:crypto";
70
+ import http from "node:http";
71
+ import { Server } from "socket.io";
72
+ import { ClientSafeError, serveRoomType } from "room-kit";
73
+ import { chatRoom } from "./common";
74
+
75
+ const httpServer = http.createServer();
76
+ const io = new Server(httpServer);
77
+
78
+ io.on("connection", (socket) => {
79
+ // Attach room behavior to each socket connection.
80
+ serveRoomType<typeof chatRoom, { userId: string }>(socket, chatRoom, {
81
+ onAuth: async () => {
82
+ // Replace with real session/JWT validation.
83
+ // This is your trusted identity source.
84
+ return { userId: socket.id };
85
+ },
86
+ initState: async (join) => ({
87
+ // Runs once per room instance (first successful join).
88
+ roomKey: join.roomKey,
89
+ created: new Date().toISOString(),
90
+ history: [],
91
+ }),
92
+ admit: async (join, ctx) => {
93
+ // Admission gate for private rooms.
94
+ // Throw ClientSafeError for messages safe to show users.
95
+ if (ctx.serverState.roomKey !== join.roomKey) {
96
+ throw new ClientSafeError("Invalid room key");
97
+ }
98
+
99
+ return {
100
+ roomId: join.roomId,
101
+ memberId: ctx.auth.userId,
102
+ // This profile is returned to the joining member and stored server-side.
103
+ memberProfile: {
104
+ userId: ctx.auth.userId,
105
+ userName: join.userName,
106
+ },
107
+ // Room metadata available to all joined members.
108
+ roomProfile: {
109
+ roomId: join.roomId,
110
+ created: ctx.serverState.created,
111
+ },
112
+ };
113
+ },
114
+ events: {
115
+ // Client emits are allowlisted by key in this object.
116
+ // If you don't need client-originated events, omit this.
117
+ message: async () => undefined,
118
+ },
119
+ rpc: {
120
+ sendMessage: async ({ text }, ctx) => {
121
+ // Prefer RPC for validated state-changing operations.
122
+ // Build the canonical message once, then persist and broadcast it.
123
+ const message = {
124
+ id: randomUUID(),
125
+ name: ctx.memberProfile.userName,
126
+ text,
127
+ sentAt: new Date().toISOString(),
128
+ };
129
+ ctx.serverState.history.push(message);
130
+ await ctx.emit.message(message);
131
+ return { id: message.id };
132
+ },
133
+ },
134
+ });
135
+ });
136
+
137
+ httpServer.listen(3000);
138
+ ```
139
+
140
+ ```ts
141
+ // client.ts
142
+ import { io } from "socket.io-client";
143
+ import { createRoomClient } from "room-kit";
144
+ import { chatRoom } from "./common";
145
+
146
+ // Create the socket transport and bind the typed room client to it.
147
+ const socket = io("http://127.0.0.1:3000");
148
+ const chatClient = createRoomClient(socket, chatRoom);
149
+
150
+ // Join returns a typed room handle with events, RPC, and leave().
151
+ const joined = await chatClient.join({
152
+ roomId: "team-alpha",
153
+ roomKey: "secret",
154
+ userName: "Ada",
155
+ });
156
+
157
+ // Event payload and metadata are both inferred from the room schema.
158
+ joined.on.message((payload, meta) => {
159
+ // meta.source.kind is "server" or "member".
160
+ console.log(payload.text, meta.source.kind);
161
+ });
162
+
163
+ // Fully typed request/response based on your room definition.
164
+ await joined.rpc.sendMessage({ text: "hello" });
165
+ // Cleanly leave the room when you're done.
166
+ await joined.leave();
167
+ ```
168
+
169
+ ## Room Schema
170
+
171
+ `defineRoomType<TSchema>(options)` takes a runtime options object. `TSchema` controls the inferred API surface:
172
+
173
+ - `joinRequest`: payload the client must send to join a room; it must include `roomId`.
174
+ - `memberProfile`: per-member metadata stored by the server and exposed in membership snapshots.
175
+ - `roomProfile`: per-room metadata returned on join and reused in server context; it must include `roomId`.
176
+ - `serverState`: private mutable state owned by the server for each room instance.
177
+ - `events`: named room events the server may emit and, if declared in handlers, accept from clients.
178
+ - `rpc`: named request/response methods exposed to joined clients.
179
+
180
+ Runtime presence mode is configured in the `defineRoomType` options:
181
+
182
+ - `"none"`: no presence query support.
183
+ - `"count"`: only count support.
184
+ - `"list"`: count + paginated members.
185
+ - default: `"list"` when `presence` is omitted.
186
+
187
+ ## Server Handlers
188
+
189
+ `serveRoomType(socket, roomType, handlers, adapter?)` accepts:
190
+
191
+ - `onAuth(socket)`: optional unless you type a non-`unknown` auth context.
192
+ - `onConnect(socket, auth)`: optional transport-connect hook attempted once when the socket handler is attached (after auth resolution).
193
+ - `revalidateAuth(socket, auth)`: optional per-request auth validation hook; return `{ kind: "ok", auth? }` to continue or `{ kind: "reject" }` to deny.
194
+ - `initState(joinRequest)`: initializes room server state on first join for a given room instance.
195
+ - `admit(joinRequest, ctx)`: required admission gate; returns `roomId`, `memberId`, `memberProfile`, and `roomProfile`.
196
+ - `onJoin(memberProfile, ctx)`: called after a successful join.
197
+ - `onLeave(memberProfile, ctx)`: called on leave and during socket disconnect cleanup for joined rooms when auth is available for cleanup.
198
+ - `onDisconnect(socket, auth)`: optional transport-disconnect hook.
199
+ - `presencePolicy(ctx)`: optional server-side override for presence queries; the returned policy is clamped by the room's configured presence mode.
200
+ - `events`: handlers for client-emitted events. Leave a key out to deny that client event.
201
+ - `rpc`: handlers for client RPC calls.
202
+
203
+ Server context (`ctx`) includes:
204
+
205
+ - `ctx.name`, `ctx.roomId`, `ctx.auth`, `ctx.memberId`, `ctx.memberProfile`
206
+ - `ctx.roomProfile`, `ctx.serverState`
207
+ - `ctx.emit.<event>(payload)` to emit to the current room
208
+ - `ctx.broadcast.emit.<event>(payload)` to emit across the namespace
209
+ - `ctx.broadcast.toRoom(roomId).emit.<event>(payload)` to target a room
210
+ - `ctx.broadcast.toMembers(memberIds).emit.<event>(payload)` to target specific members
211
+ - `ctx.getPresence()`, `ctx.getPresenceCount()`, `ctx.listPresenceMembers({ offset, limit })`
212
+
213
+ `serveRoomType` returns a handle:
214
+
215
+ - `stop()` unregisters listeners for that socket
216
+ - `stop.rooms()` returns snapshots for all rooms on the namespace
217
+ - `stop.room(roomId)` returns one room snapshot or `undefined`
218
+ - `stop.count(roomId)` returns the current member count for a room (`0` when the room does not exist; throws when room presence mode is `"none"`)
219
+ - `stop.members(roomId, query)` returns a paginated presence listing (`{ count: 0, offset: 0, limit: 0, members: [] }` when the room does not exist; throws when room presence mode is not `"list"`)
220
+
221
+ ## Client API
222
+
223
+ `createRoomClient(socket, roomType)` returns:
224
+
225
+ - `client.name`
226
+ - `client.connection.current` (`"connecting" | "connected" | "reconnecting" | "disconnected"`)
227
+ - `client.connection.onChange(handler)` subscribes to transport-state changes and returns an unsubscribe function.
228
+ - `client.join(joinRequest)` resolves to a `joinedRoom` handle.
229
+
230
+ `joinedRoom` includes:
231
+
232
+ - `joinedRoom.name`, `joinedRoom.roomId`, `joinedRoom.memberId`, `joinedRoom.roomProfile`
233
+ - `joinedRoom.rpc.<name>(...args)` for typed RPC calls
234
+ - `joinedRoom.emit.<event>(payload)` for client-emitted room events
235
+ - `joinedRoom.on.<event>((payload, meta) => {})` for room event subscriptions
236
+ - `joinedRoom.leave()` to leave the room and unregister the joined-room handle
237
+ - `joinedRoom.presence` is part of the typed API when room presence mode is `"count"` or `"list"`; it exposes `current`, `onChange(handler)`, `count()`, and `list({ offset, limit })` when presence mode is `"list"`.
238
+
239
+ ## Errors and Security
240
+
241
+ - Throw `ClientSafeError` for messages you want sent to clients.
242
+ - Non-`ClientSafeError` exceptions are sanitized to: `"An internal server error occurred."`
243
+ - RPC and event dispatch only allow own properties (`Object.hasOwn`) to prevent prototype-based handler access.
244
+ - Client event names are default-deny unless explicitly declared in `handlers.events`.
245
+ - Do not trust client payloads for authorization; derive identity in `onAuth`.
246
+ - Validate runtime payload shapes in your handlers. TypeScript types are compile-time only.
247
+
248
+ ## Reconnect Behavior
249
+
250
+ - Joined rooms are automatically replayed after socket reconnect.
251
+ - Replay uses the original `joinRequest` payload.
252
+ - If replay fails, that joined room is removed from the client registry.
253
+
254
+ ## Example App
255
+
256
+ A complete chat example is in the `example` directory:
257
+
258
+ ```bash
259
+ cd example
260
+ npm install
261
+ npm start
262
+ ```
package/changelog.md ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0
4
+
5
+ - Initial release of `room-kit`.
6
+ - Typed channel primitives for Socket.IO events, requests, streams, and room membership.
7
+ - Runtime protocol support for event, request/response, stream subscribe/publish, and room join/leave flows.
8
+ - Test coverage for runtime behavior and Socket.IO integration.
9
+ - Added first-class room membership flows with `channel(...).room(...)`.
10
+ - Added reconnect replay for active stream subscriptions and room memberships.
11
+ - Added Socket.IO client and server adapters for room-aware sends and membership mutation.
12
+ - Added a JSR-ready package entrypoint via `jsr.json`.
13
+ - Expanded the README with current client, server, and JSR examples.
@@ -0,0 +1,16 @@
1
+ import type { ClientSocketLike, RoomClient, RoomDefinition } from "./types";
2
+ /**
3
+ * Binds a client socket to a room type and returns a typed room client.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { io } from "socket.io-client";
8
+ * import { createRoomClient } from "room-kit";
9
+ *
10
+ * const socket = io("http://127.0.0.1:3000");
11
+ * const client = createRoomClient(socket, chatRoomType);
12
+ * const joined = await client.join({ roomId: "team", roomKey: "secret", userName: "Ada" });
13
+ * ```
14
+ */
15
+ export declare function createRoomClient<TRoom extends RoomDefinition<any>>(socket: ClientSocketLike, room: TRoom): RoomClient<TRoom>;
16
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAER,gBAAgB,EAUhB,UAAU,EACV,cAAc,EAKjB,MAAM,SAAS,CAAC;AAsCjB;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,SAAS,cAAc,CAAC,GAAG,CAAC,EAC9D,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,KAAK,GACZ,UAAU,CAAC,KAAK,CAAC,CA6CnB"}
package/dist/client.js ADDED
@@ -0,0 +1,317 @@
1
+ const JOIN_EVENT = "room-kit:join";
2
+ const LEAVE_EVENT = "room-kit:leave";
3
+ const RPC_EVENT = "room-kit:rpc";
4
+ const CLIENT_EVENT = "room-kit:client-event";
5
+ const SERVER_EVENT = "room-kit:server-event";
6
+ const PRESENCE_EVENT = "room-kit:presence";
7
+ const PRESENCE_QUERY_EVENT = "room-kit:presence-query";
8
+ const clientRegistries = new WeakMap();
9
+ /**
10
+ * Binds a client socket to a room type and returns a typed room client.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { io } from "socket.io-client";
15
+ * import { createRoomClient } from "room-kit";
16
+ *
17
+ * const socket = io("http://127.0.0.1:3000");
18
+ * const client = createRoomClient(socket, chatRoomType);
19
+ * const joined = await client.join({ roomId: "team", roomKey: "secret", userName: "Ada" });
20
+ * ```
21
+ */
22
+ export function createRoomClient(socket, room) {
23
+ return {
24
+ name: room.name,
25
+ get connection() {
26
+ const registry = getClientRegistry(socket);
27
+ return {
28
+ get current() {
29
+ return registry.connectionState;
30
+ },
31
+ onChange(handler) {
32
+ registry.connectionListeners.add(handler);
33
+ return () => {
34
+ registry.connectionListeners.delete(handler);
35
+ };
36
+ },
37
+ };
38
+ },
39
+ join(payload) {
40
+ const registry = getClientRegistry(socket);
41
+ return emitAck(socket, JOIN_EVENT, {
42
+ roomType: room.name,
43
+ payload,
44
+ }).then((value) => {
45
+ const state = {
46
+ name: room.name,
47
+ roomId: value.roomId,
48
+ memberId: value.memberId,
49
+ roomProfile: value.roomProfile,
50
+ presenceCurrent: value.presence,
51
+ joinRequest: payload,
52
+ eventListeners: new Map(),
53
+ presenceListeners: new Set(),
54
+ };
55
+ registry.joinedRooms.set(makeJoinedRoomKey(room.name, value.roomId), state);
56
+ return createJoinedRoom(socket, state);
57
+ });
58
+ },
59
+ };
60
+ }
61
+ function createJoinedRoom(socket, state) {
62
+ const rpc = new Proxy({}, {
63
+ get(_target, key) {
64
+ if (typeof key !== "string") {
65
+ return undefined;
66
+ }
67
+ return (...args) => {
68
+ return emitAck(socket, RPC_EVENT, {
69
+ roomType: state.name,
70
+ roomId: state.roomId,
71
+ name: key,
72
+ args,
73
+ });
74
+ };
75
+ },
76
+ });
77
+ const emit = new Proxy({}, {
78
+ get(_target, key) {
79
+ if (typeof key !== "string") {
80
+ return undefined;
81
+ }
82
+ return (payload) => {
83
+ return emitAck(socket, CLIENT_EVENT, {
84
+ roomType: state.name,
85
+ roomId: state.roomId,
86
+ name: key,
87
+ payload,
88
+ });
89
+ };
90
+ },
91
+ });
92
+ const on = new Proxy({}, {
93
+ get(_target, key) {
94
+ if (typeof key !== "string") {
95
+ return undefined;
96
+ }
97
+ return (handler) => {
98
+ const handlers = state.eventListeners.get(key) ?? new Set();
99
+ handlers.add(handler);
100
+ state.eventListeners.set(key, handlers);
101
+ return () => {
102
+ handlers.delete(handler);
103
+ if (handlers.size === 0) {
104
+ state.eventListeners.delete(key);
105
+ }
106
+ };
107
+ };
108
+ },
109
+ });
110
+ const base = {
111
+ name: state.name,
112
+ roomId: state.roomId,
113
+ memberId: state.memberId,
114
+ roomProfile: state.roomProfile,
115
+ rpc,
116
+ emit,
117
+ on,
118
+ async leave() {
119
+ await emitAck(socket, LEAVE_EVENT, {
120
+ roomType: state.name,
121
+ roomId: state.roomId,
122
+ });
123
+ const registry = getClientRegistry(socket);
124
+ registry.joinedRooms.delete(makeJoinedRoomKey(state.name, state.roomId));
125
+ },
126
+ };
127
+ return new Proxy(base, {
128
+ get(target, key, receiver) {
129
+ if (key === "presence") {
130
+ return {
131
+ get current() {
132
+ return state.presenceCurrent;
133
+ },
134
+ onChange(handler) {
135
+ state.presenceListeners.add(handler);
136
+ return () => {
137
+ state.presenceListeners.delete(handler);
138
+ };
139
+ },
140
+ count() {
141
+ return emitAck(socket, PRESENCE_QUERY_EVENT, {
142
+ roomType: state.name,
143
+ roomId: state.roomId,
144
+ kind: "count",
145
+ });
146
+ },
147
+ list(query = {}) {
148
+ return emitAck(socket, PRESENCE_QUERY_EVENT, {
149
+ roomType: state.name,
150
+ roomId: state.roomId,
151
+ kind: "list",
152
+ ...query,
153
+ });
154
+ },
155
+ };
156
+ }
157
+ return Reflect.get(target, key, receiver);
158
+ },
159
+ });
160
+ }
161
+ function getClientRegistry(socket) {
162
+ const existing = clientRegistries.get(socket);
163
+ if (existing) {
164
+ return existing;
165
+ }
166
+ const created = {
167
+ serverHandlerInstalled: false,
168
+ presenceHandlerInstalled: false,
169
+ reconnectHandlerInstalled: false,
170
+ disconnectHandlerInstalled: false,
171
+ connectErrorHandlerInstalled: false,
172
+ reconnectAttemptHandlerInstalled: false,
173
+ reconnectErrorHandlerInstalled: false,
174
+ reconnectFailedHandlerInstalled: false,
175
+ hasConnectedOnce: false,
176
+ connectionState: "connecting",
177
+ connectionListeners: new Set(),
178
+ joinedRooms: new Map(),
179
+ };
180
+ installClientHandlers(socket, created);
181
+ clientRegistries.set(socket, created);
182
+ return created;
183
+ }
184
+ function installClientHandlers(socket, registry) {
185
+ if (!registry.serverHandlerInstalled) {
186
+ const onServerEvent = (frame) => {
187
+ const state = registry.joinedRooms.get(makeJoinedRoomKey(frame.roomType, frame.roomId));
188
+ if (!state) {
189
+ return;
190
+ }
191
+ const handlers = state.eventListeners.get(frame.name);
192
+ if (!handlers || handlers.size === 0) {
193
+ return;
194
+ }
195
+ const meta = {
196
+ ...frame.meta,
197
+ sentAt: new Date(frame.meta.sentAt),
198
+ };
199
+ for (const handler of handlers) {
200
+ handler(frame.payload, meta);
201
+ }
202
+ };
203
+ socket.on(SERVER_EVENT, onServerEvent);
204
+ registry.serverHandlerInstalled = true;
205
+ }
206
+ if (!registry.presenceHandlerInstalled) {
207
+ const onPresence = (frame) => {
208
+ const state = registry.joinedRooms.get(makeJoinedRoomKey(frame.roomType, frame.roomId));
209
+ if (!state) {
210
+ return;
211
+ }
212
+ state.presenceCurrent = frame.presence;
213
+ if (state.presenceCurrent === undefined) {
214
+ return;
215
+ }
216
+ for (const handler of state.presenceListeners) {
217
+ handler(state.presenceCurrent);
218
+ }
219
+ };
220
+ socket.on(PRESENCE_EVENT, onPresence);
221
+ registry.presenceHandlerInstalled = true;
222
+ }
223
+ if (!registry.reconnectHandlerInstalled) {
224
+ const onConnect = () => {
225
+ registry.hasConnectedOnce = true;
226
+ setConnectionState(registry, "connected");
227
+ void replayJoinedRooms(socket, registry);
228
+ };
229
+ socket.on("connect", onConnect);
230
+ registry.reconnectHandlerInstalled = true;
231
+ }
232
+ if (!registry.disconnectHandlerInstalled) {
233
+ const onDisconnect = () => {
234
+ setConnectionState(registry, "disconnected");
235
+ };
236
+ socket.on("disconnect", onDisconnect);
237
+ registry.disconnectHandlerInstalled = true;
238
+ }
239
+ if (!registry.connectErrorHandlerInstalled) {
240
+ const onConnectError = () => {
241
+ setConnectionState(registry, registry.hasConnectedOnce ? "reconnecting" : "connecting");
242
+ };
243
+ socket.on("connect_error", onConnectError);
244
+ registry.connectErrorHandlerInstalled = true;
245
+ }
246
+ if (!registry.reconnectAttemptHandlerInstalled) {
247
+ const onReconnectAttempt = () => {
248
+ setConnectionState(registry, "reconnecting");
249
+ };
250
+ socket.on("reconnect_attempt", onReconnectAttempt);
251
+ registry.reconnectAttemptHandlerInstalled = true;
252
+ }
253
+ if (!registry.reconnectFailedHandlerInstalled) {
254
+ const onReconnectFailed = () => {
255
+ setConnectionState(registry, "disconnected");
256
+ };
257
+ socket.on("reconnect_failed", onReconnectFailed);
258
+ registry.reconnectFailedHandlerInstalled = true;
259
+ }
260
+ if (!registry.reconnectErrorHandlerInstalled) {
261
+ const onReconnectError = () => {
262
+ setConnectionState(registry, "reconnecting");
263
+ };
264
+ socket.on("reconnect_error", onReconnectError);
265
+ registry.reconnectErrorHandlerInstalled = true;
266
+ }
267
+ }
268
+ async function replayJoinedRooms(socket, registry) {
269
+ for (const [key, state] of Array.from(registry.joinedRooms.entries())) {
270
+ try {
271
+ const value = await emitAck(socket, JOIN_EVENT, {
272
+ roomType: state.name,
273
+ payload: state.joinRequest,
274
+ });
275
+ state.roomId = value.roomId;
276
+ state.memberId = value.memberId;
277
+ state.roomProfile = value.roomProfile;
278
+ state.presenceCurrent = value.presence;
279
+ const newKey = makeJoinedRoomKey(state.name, value.roomId);
280
+ if (newKey !== key) {
281
+ registry.joinedRooms.delete(key);
282
+ }
283
+ registry.joinedRooms.set(newKey, state);
284
+ }
285
+ catch {
286
+ registry.joinedRooms.delete(key);
287
+ }
288
+ }
289
+ }
290
+ function makeJoinedRoomKey(name, roomId) {
291
+ return `${name}:${roomId}`;
292
+ }
293
+ function emitAck(socket, eventName, payload) {
294
+ return new Promise((resolve, reject) => {
295
+ socket.emit(eventName, payload, (result) => {
296
+ if (!result || typeof result !== "object") {
297
+ reject(new Error("Invalid acknowledgement payload"));
298
+ return;
299
+ }
300
+ if (result.ok) {
301
+ resolve(result.value);
302
+ return;
303
+ }
304
+ reject(new Error(result.error));
305
+ });
306
+ });
307
+ }
308
+ function setConnectionState(registry, next) {
309
+ if (registry.connectionState === next) {
310
+ return;
311
+ }
312
+ registry.connectionState = next;
313
+ for (const listener of registry.connectionListeners) {
314
+ listener(next);
315
+ }
316
+ }
317
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAoBA,MAAM,UAAU,GAAG,eAAe,CAAC;AACnC,MAAM,WAAW,GAAG,gBAAgB,CAAC;AACrC,MAAM,SAAS,GAAG,cAAc,CAAC;AACjC,MAAM,YAAY,GAAG,uBAAuB,CAAC;AAC7C,MAAM,YAAY,GAAG,uBAAuB,CAAC;AAC7C,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAC3C,MAAM,oBAAoB,GAAG,yBAAyB,CAAC;AA4BvD,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAAoC,CAAC;AAEzE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAC5B,MAAwB,EACxB,IAAW;IAEX,OAAO;QACH,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,UAAU;YACV,MAAM,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;YAC3C,OAAO;gBACH,IAAI,OAAO;oBACP,OAAO,QAAQ,CAAC,eAAe,CAAC;gBACpC,CAAC;gBACD,QAAQ,CAAC,OAA+C;oBACpD,QAAQ,CAAC,mBAAmB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;oBAC1C,OAAO,GAAG,EAAE;wBACR,QAAQ,CAAC,mBAAmB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;oBACjD,CAAC,CAAC;gBACN,CAAC;aACJ,CAAC;QACN,CAAC;QACD,IAAI,CAAC,OAA2B;YAC5B,MAAM,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;YAE3C,OAAO,OAAO,CA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AAwB,EAAE,IAA2B;IAC7E,IAAI,QAAQ,CAAC,eAAe,KAAK,IAAI,EAAE,CAAC;QACpC,OAAO;IACX,CAAC;IAED,QAAQ,CAAC,eAAe,GAAG,IAAI,CAAC;IAChC,KAAK,MAAM,QAAQ,IAAI,QAAQ,CAAC,mBAAmB,EAAE,CAAC;QAClD,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;AACL,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { ClientSafeError } from "./types";
2
+ export { createRoomClient } from "./client";
3
+ export { defineRoomType } from "./room";
4
+ export { serveRoomType } from "./server";
5
+ export type { ClientConnectionState, ClientSocketLike, EventMetaFor, JoinRequest, JoinedRoom, MemberProfileFor, PresenceListQuery, PresenceFor, PresencePageFor, PresencePolicy, RoomMemberSnapshot, RoomClient, RoomDefinition, RoomEvents, RoomProfileFor, RoomRpc, RoomSchema, ServerStateFor, RoomServerAdapter, RoomServerBroadcastApi, RoomServerHandle, RoomServerContext, RoomServerHandlers, RoomSnapshot, ServerAdmission, ServerSocketLike, VisibleMemberFor, } from "./types";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,YAAY,EACR,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,cAAc,EACd,UAAU,EACV,cAAc,EACd,OAAO,EACP,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,gBAAgB,GACnB,MAAM,SAAS,CAAC"}