@fuzdev/fuz_app 0.178.0 → 0.180.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/actions/CLAUDE.md +106 -0
  2. package/dist/actions/connection_registry.d.ts +18 -0
  3. package/dist/actions/connection_registry.d.ts.map +1 -1
  4. package/dist/actions/connection_registry.js +23 -0
  5. package/dist/actions/room_action_specs.d.ts +733 -0
  6. package/dist/actions/room_action_specs.d.ts.map +1 -0
  7. package/dist/actions/room_action_specs.js +506 -0
  8. package/dist/actions/room_actions.d.ts +276 -0
  9. package/dist/actions/room_actions.d.ts.map +1 -0
  10. package/dist/actions/room_actions.js +394 -0
  11. package/dist/actions/room_client.svelte.d.ts +399 -0
  12. package/dist/actions/room_client.svelte.d.ts.map +1 -0
  13. package/dist/actions/room_client.svelte.js +942 -0
  14. package/dist/actions/room_registry.d.ts +454 -0
  15. package/dist/actions/room_registry.d.ts.map +1 -0
  16. package/dist/actions/room_registry.js +927 -0
  17. package/dist/auth/role_grant_offer_action_specs.d.ts +1 -1
  18. package/dist/auth/role_grant_queries.d.ts +17 -0
  19. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  20. package/dist/auth/role_grant_queries.js +30 -0
  21. package/dist/rtc/rtc_mesh.svelte.d.ts +102 -0
  22. package/dist/rtc/rtc_mesh.svelte.d.ts.map +1 -0
  23. package/dist/rtc/rtc_mesh.svelte.js +232 -0
  24. package/dist/rtc/rtc_peer.svelte.d.ts +180 -0
  25. package/dist/rtc/rtc_peer.svelte.d.ts.map +1 -0
  26. package/dist/rtc/rtc_peer.svelte.js +397 -0
  27. package/dist/rtc/rtc_signal.d.ts +74 -0
  28. package/dist/rtc/rtc_signal.d.ts.map +1 -0
  29. package/dist/rtc/rtc_signal.js +87 -0
  30. package/dist/testing/CLAUDE.md +67 -13
  31. package/dist/testing/cross_backend/action_manifest.d.ts +34 -2
  32. package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
  33. package/dist/testing/cross_backend/action_manifest.js +33 -6
  34. package/dist/testing/cross_backend/capabilities.d.ts +22 -4
  35. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  36. package/dist/testing/cross_backend/capabilities.js +4 -1
  37. package/dist/testing/cross_backend/full_spine_mount.d.ts +31 -6
  38. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  39. package/dist/testing/cross_backend/full_spine_mount.js +45 -13
  40. package/dist/testing/cross_backend/rooms_ws.d.ts +20 -0
  41. package/dist/testing/cross_backend/rooms_ws.d.ts.map +1 -0
  42. package/dist/testing/cross_backend/rooms_ws.js +534 -0
  43. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
  44. package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +4 -1
  45. package/dist/testing/cross_backend/spine_suites.d.ts +5 -2
  46. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  47. package/dist/testing/cross_backend/spine_suites.js +24 -5
  48. package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
  49. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  50. package/dist/testing/cross_backend/spine_surface_constants.js +2 -1
  51. package/dist/testing/cross_backend/test_room_authorize.d.ts +47 -0
  52. package/dist/testing/cross_backend/test_room_authorize.d.ts.map +1 -0
  53. package/dist/testing/cross_backend/test_room_authorize.js +58 -0
  54. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  55. package/dist/testing/cross_backend/testing_backdoor.js +10 -4
  56. package/dist/testing/cross_backend/testing_reset_actions.d.ts +85 -1
  57. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  58. package/dist/testing/cross_backend/testing_reset_actions.js +57 -3
  59. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  60. package/dist/testing/cross_backend/ts_spine_backend_config.js +5 -2
  61. package/dist/ui/AccountSessions.svelte.d.ts.map +1 -1
  62. package/dist/ui/AdminAccounts.svelte.d.ts.map +1 -1
  63. package/dist/ui/AdminAuditLog.svelte.d.ts.map +1 -1
  64. package/dist/ui/AdminInvites.svelte.d.ts.map +1 -1
  65. package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
  66. package/dist/ui/AdminRoleGrantHistory.svelte.d.ts.map +1 -1
  67. package/dist/ui/AdminSessions.svelte.d.ts.map +1 -1
  68. package/dist/ui/AdminSettings.svelte.d.ts.map +1 -1
  69. package/dist/ui/AdminSurface.svelte.d.ts.map +1 -1
  70. package/dist/ui/BootstrapForm.svelte.d.ts.map +1 -1
  71. package/dist/ui/ConfirmButton.svelte.d.ts.map +1 -1
  72. package/dist/ui/Datatable.svelte.d.ts.map +1 -1
  73. package/dist/ui/LoginForm.svelte.d.ts.map +1 -1
  74. package/dist/ui/LogoutButton.svelte.d.ts.map +1 -1
  75. package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -1
  76. package/dist/ui/PopoverButton.svelte.d.ts.map +1 -1
  77. package/dist/ui/RoleGrantOfferForm.svelte.d.ts.map +1 -1
  78. package/dist/ui/RoleGrantOfferHistory.svelte.d.ts.map +1 -1
  79. package/dist/ui/RoleGrantOfferInbox.svelte.d.ts.map +1 -1
  80. package/dist/ui/SignupForm.svelte.d.ts.map +1 -1
  81. package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
  82. package/package.json +19 -19
@@ -0,0 +1,399 @@
1
+ /**
2
+ * The frontend side of rooms: `RoomClient` keeps, for each room a page joins
3
+ * or watches, a reactive `RoomState` — its members and their state, the
4
+ * caller's own seat — over the WS-only `room_*` verbs and the `room_*`
5
+ * notifications the server pushes (`actions/room_action_specs.ts`).
6
+ *
7
+ * ## Desired state, converged one request at a time
8
+ *
9
+ * `RoomState.join`, `leave`, `watch`, `unwatch`, and `set_state` record what
10
+ * the page wants; one runner per room then sends whatever requests close the
11
+ * gap, one at a time. The server dispatches a socket's requests concurrently,
12
+ * so a leave sent right after a join could otherwise reach the registry first
13
+ * (and refuse the join as superseded), and two state sets could land out of
14
+ * order. A burst of calls converges: join, leave, join while the first join is
15
+ * in flight sends that one join, whose seat stands; a leave while seated is
16
+ * sent before the next join. While the socket is down nothing is sent and the
17
+ * wants wait for it. `RoomState.send` is the exception: it goes out at once,
18
+ * since a caller that cares about the order of its sends (the WebRTC mesh,
19
+ * `rtc/rtc_mesh.svelte.ts`) serializes them itself.
20
+ *
21
+ * Every verb runs untracked, so a page may call `join` or `watch` from an
22
+ * `$effect` (with `leave` or `unwatch` in its teardown) without the effect
23
+ * depending on the room state the verb reads and writes.
24
+ *
25
+ * Listeners are isolated: one that throws is logged and the others still
26
+ * hear the event, and the join, replay, or teardown that called it carries on.
27
+ *
28
+ * ## `seq`
29
+ *
30
+ * Every member event carries its room's `seq`, and a join or watch answers the
31
+ * room as of a `seq`. Events can arrive before that answer, so while a room's
32
+ * first answer is outstanding they are buffered; the answer's members are
33
+ * applied, then the buffer replays, dropping every event at or below the
34
+ * answer's `seq`. Once a room is live, an event at or below the last applied
35
+ * `seq` is dropped, so a connection that both watches a room and sits in it,
36
+ * which the server tells each event once, applies it once. A later answer
37
+ * whose `seq` is behind the live stream is not applied over it. A message
38
+ * (which reaches only a seat) that arrives on a live watch while the join is
39
+ * in flight is held, and delivered once the seat is taken.
40
+ *
41
+ * ## Seats lost, and reconnects
42
+ *
43
+ * `room_seat_lost` ends a seat the server took: `moved` (a newer join of the
44
+ * same actor took over, `moved_to` naming its room), `evicted`, or
45
+ * `room_closed`. None is rejoined. A socket that closes loses every seat and
46
+ * watch with it, and the client tells them apart: a seat lost to the
47
+ * disconnect is rejoined on the next connection, naming the seat it held
48
+ * (`rejoin_of`), and a refusal as `room_seat_moved` — the actor took a seat
49
+ * elsewhere meanwhile — ends it as moved, so two tabs never trade a seat back
50
+ * and forth. A rejoin refused `rate_limited` is retried after the refusal's
51
+ * `retry_after`, still naming the seat, up to `ROOM_REJOIN_RATE_LIMITED_RETRIES_MAX`
52
+ * times. Watches are taken again.
53
+ *
54
+ * The client learns of a new connection through `RoomRpc.connection`, an
55
+ * identity that changes each time the socket opens. The client follows it on
56
+ * its own: its constructor makes an `$effect.root` whose effect reads it and
57
+ * calls `sync_connection`, so a close and a reopen are seen even when they
58
+ * land in one batch, and `dispose` ends it. On the server the compiler makes
59
+ * `$effect.root` a no-op, and nothing follows; `sync_connection` stays public
60
+ * for that case and for tests, and runs on its own before each request and
61
+ * notification.
62
+ *
63
+ * ```ts
64
+ * const rooms = new RoomClient(create_room_rpc(socket));
65
+ * ```
66
+ *
67
+ * Notifications reach the client through `receive`, from the RPC client's
68
+ * `lookup_action_handler` for the `'receive'` phase (with
69
+ * `room_notification_action_specs` among the RPC client's specs):
70
+ *
71
+ * ```ts
72
+ * lookup_action_handler: (method, phase) =>
73
+ * phase === 'receive' && is_room_notification_method(method)
74
+ * ? (event) => rooms.receive(method, event.data.input)
75
+ * : undefined
76
+ * ```
77
+ *
78
+ * `dispose` leaves every seat and drops every watch, for a clean teardown.
79
+ *
80
+ * @module
81
+ */
82
+ import type { Logger } from '@fuzdev/fuz_util/log.ts';
83
+ import type { Result } from '@fuzdev/fuz_util/result.ts';
84
+ import { SvelteMap } from 'svelte/reactivity';
85
+ import type { Uuid } from '../primitive_schemas.js';
86
+ import type { JsonrpcErrorObject, JsonrpcRequestId } from '../http/jsonrpc.js';
87
+ import { RoomJoinOutput, RoomLeaveOutput, RoomMemberJoinedParams, RoomMemberLeftParams, RoomMemberStateParams, RoomMessageParams, RoomOccupancy, RoomSeatLostParams, RoomStateSetOutput, RoomUnwatchOutput, RoomWatchEndedParams, type MemberId, type RoomEvictReason, type RoomId, type RoomIdInput, type RoomJoinInput, type RoomLeftReason, type RoomMember, type RoomSeatLostReason, type RoomSendInput, type RoomStateSetInput, type RoomTopology } from './room_action_specs.js';
88
+ /** A room verb's answer: its output, or the JSON-RPC error that refused it. */
89
+ export type RoomRpcResult<T> = Result<{
90
+ value: T;
91
+ }, {
92
+ error: JsonrpcErrorObject;
93
+ }>;
94
+ /**
95
+ * The room verbs over one socket, and the socket's identity — what
96
+ * `RoomClient` needs of the connection. `create_room_rpc` builds it over a
97
+ * `FrontendWebsocketClient`; a test passes a fake.
98
+ */
99
+ export interface RoomRpc {
100
+ room_join: (input: RoomJoinInput) => Promise<RoomRpcResult<RoomJoinOutput>>;
101
+ room_leave: (input: RoomIdInput) => Promise<RoomRpcResult<RoomLeaveOutput>>;
102
+ room_send: (input: RoomSendInput) => Promise<RoomRpcResult<null>>;
103
+ room_state_set: (input: RoomStateSetInput) => Promise<RoomRpcResult<RoomStateSetOutput>>;
104
+ room_watch: (input: RoomIdInput) => Promise<RoomRpcResult<RoomOccupancy>>;
105
+ room_unwatch: (input: RoomIdInput) => Promise<RoomRpcResult<RoomUnwatchOutput>>;
106
+ /**
107
+ * The open connection — a value that changes each time the socket opens,
108
+ * compared by identity — or `null` while the socket is down. Seats and
109
+ * watches belong to one connection; when this changes they are gone.
110
+ * Reactive when it reads reactive state, so an `$effect` calling
111
+ * `RoomClient.sync_connection` reruns on a change.
112
+ */
113
+ readonly connection: object | null;
114
+ }
115
+ /**
116
+ * What `create_room_rpc` needs of the socket — a `FrontendWebsocketClient`
117
+ * satisfies it. `ws` is the current `WebSocket`, a new one per connection.
118
+ */
119
+ export interface RoomRpcSocket {
120
+ readonly connected: boolean;
121
+ readonly ws: object | null;
122
+ request: (method: string, params: unknown, options?: {
123
+ signal?: AbortSignal;
124
+ queue?: boolean;
125
+ id?: JsonrpcRequestId;
126
+ }) => Promise<unknown>;
127
+ }
128
+ /**
129
+ * The room verbs straight over the socket's `request`, never through the RPC
130
+ * client's transports: those fall back to HTTP while the socket is down, and
131
+ * the room verbs are mounted only on a WebSocket endpoint. A request is never
132
+ * queued — while the socket is down it fails at once, and `RoomClient` sends
133
+ * it again on the next connection. Answers are parsed with the verbs' output
134
+ * schemas, forward-compatibly as the RPC client reads a remote result (keys a
135
+ * newer server added are dropped, `safe_parse_dropping_unknown_keys`); one
136
+ * that still doesn't parse is an `internal_error`.
137
+ *
138
+ * @param socket - the socket the room verbs go over
139
+ * @returns the verbs, and `connection` — the open `WebSocket`, else `null`
140
+ */
141
+ export declare const create_room_rpc: (socket: RoomRpcSocket) => RoomRpc;
142
+ /** Whether `method` is one of the `room_*` notifications `RoomClient.receive` takes. */
143
+ export declare const is_room_notification_method: (method: string) => boolean;
144
+ /** The caller's seat in a room, from the join's answer. */
145
+ export interface RoomSeat {
146
+ room_id: RoomId;
147
+ member_id: MemberId;
148
+ topology: RoomTopology;
149
+ /** The consumer's `join_extra` value (ICE servers, say), `null` without one. */
150
+ extra: unknown;
151
+ }
152
+ /** Why the server ended the caller's seat — `room_seat_lost`, or a rejoin refused as moved. */
153
+ export interface RoomSeatEnded {
154
+ reason: RoomSeatLostReason;
155
+ /** The room a `moved` seat moved to, `null` when not known (a rejoin refused as moved). */
156
+ moved_to: RoomId | null;
157
+ }
158
+ /**
159
+ * Why a seat ended, as `RoomListener.unseated` hears it: the caller left, the
160
+ * socket closed (`disconnected`, rejoined on the next connection), the server
161
+ * ended it (`RoomSeatLostReason`), or the client was disposed (`closed`).
162
+ */
163
+ export type RoomUnseatedReason = 'left' | 'disconnected' | 'closed' | RoomSeatLostReason;
164
+ /**
165
+ * Where a room's seat stands: `idle` (not wanted), `joining`, `rejoining` (a
166
+ * seat lost to a disconnect, waiting to be taken again), `joined`.
167
+ */
168
+ export type RoomSeatStatus = 'idle' | 'joining' | 'rejoining' | 'joined';
169
+ /**
170
+ * A subscriber to one room's events, in `seq` order, except a message held
171
+ * for a join in flight, which is heard once the seat is taken, after the
172
+ * member events that passed it. Member events come
173
+ * through a seat or a watch alike; `seated` and `unseated` bracket a seat, and
174
+ * `message` reaches only a seat. Every member is the room's own value, the
175
+ * same one `RoomState.members` holds.
176
+ */
177
+ export interface RoomListener {
178
+ /** A seat was taken — `RoomState.members` already holds the room as of the answer. */
179
+ seated?: (seat: RoomSeat) => void;
180
+ /** The seat ended. */
181
+ unseated?: (seat: RoomSeat, reason: RoomUnseatedReason) => void;
182
+ member_joined?: (member: RoomMember) => void;
183
+ member_left?: (member_id: MemberId, reason: RoomLeftReason) => void;
184
+ member_state?: (member: RoomMember) => void;
185
+ message?: (message: RoomMessageParams) => void;
186
+ }
187
+ /** Options for `RoomState.join`. */
188
+ export interface RoomJoinOptions {
189
+ /**
190
+ * The member state to join with, kept as `RoomState.local_state`; omitted,
191
+ * the state set last (or none).
192
+ */
193
+ state?: string;
194
+ }
195
+ /** Options for `RoomClient`. */
196
+ export interface RoomClientOptions {
197
+ /**
198
+ * The actor every verb acts as, on a multi-actor account (the `acting`
199
+ * selector); omitted, the account's default actor. One client serves one
200
+ * actor: the server tells a connection each event once, whichever of its
201
+ * actors it concerns.
202
+ */
203
+ acting?: Uuid;
204
+ /** Where dispatch diagnostics go; `null` or omitted, nowhere. */
205
+ log?: Logger | null;
206
+ /** `setTimeout`, for a rate-limited rejoin's wait; omitted, the global. */
207
+ set_timeout?: (callback: () => void, ms: number) => unknown;
208
+ /** `clearTimeout`, given what `set_timeout` returned; omitted, the global. */
209
+ clear_timeout?: (handle: unknown) => void;
210
+ }
211
+ /**
212
+ * How many times a rejoin refused `rate_limited` is retried, each after the
213
+ * refusal's `retry_after`, before the seat is given up as refused.
214
+ */
215
+ export declare const ROOM_REJOIN_RATE_LIMITED_RETRIES_MAX = 3;
216
+ /** A buffered or live member event. */
217
+ type RoomEvent = {
218
+ method: 'room_member_joined';
219
+ params: RoomMemberJoinedParams;
220
+ } | {
221
+ method: 'room_member_left';
222
+ params: RoomMemberLeftParams;
223
+ } | {
224
+ method: 'room_member_state';
225
+ params: RoomMemberStateParams;
226
+ } | {
227
+ method: 'room_message';
228
+ params: RoomMessageParams;
229
+ };
230
+ /** What a `RoomState` needs of its `RoomClient`. */
231
+ interface RoomHost {
232
+ readonly rpc: RoomRpc;
233
+ readonly acting: Uuid | undefined;
234
+ readonly log: Logger | null;
235
+ set_timeout: (callback: () => void, ms: number) => unknown;
236
+ clear_timeout: (handle: unknown) => void;
237
+ is_disposed: () => boolean;
238
+ /** The open connection the rooms live on, after a sync, or `null` while the socket is down. */
239
+ live_connection: () => object | null;
240
+ /** Hand the client the room's inbound side. */
241
+ attach: (room_id: RoomId, port: RoomPort) => void;
242
+ }
243
+ /** A room's inbound side, which only its `RoomClient` calls. */
244
+ interface RoomPort {
245
+ event: (event: RoomEvent) => void;
246
+ seat_lost: (params: RoomSeatLostParams) => void;
247
+ watch_ended: (params: RoomWatchEndedParams) => void;
248
+ /** The connection the seat and watch lived on is gone. */
249
+ connection_lost: () => void;
250
+ kick: () => void;
251
+ dispose: () => Promise<void>;
252
+ }
253
+ /**
254
+ * One room as the client sees it: the members (through a seat, a watch, or
255
+ * both), the caller's seat, and what the page wants of it. Built by
256
+ * `RoomClient.room`; every verb here records a want and lets the room's runner
257
+ * converge on it (see the module doc).
258
+ */
259
+ export declare class RoomState {
260
+ #private;
261
+ readonly room_id: RoomId;
262
+ /** The room's members in seating order, the caller's own seat included; empty until a seat or watch answers. */
263
+ members: ReadonlyArray<RoomMember>;
264
+ /** The caller's seat, or `null`. */
265
+ seat: RoomSeat | null;
266
+ /** Whether a watch is live — the server answered it and hasn't ended it. */
267
+ watching: boolean;
268
+ /** Why the server last ended the seat; cleared by the next `join`. */
269
+ ended: RoomSeatEnded | null;
270
+ /** Why the server last ended the watch; cleared by the next `watch`. */
271
+ watch_ended: RoomEvictReason | null;
272
+ /** The last refusal of a join, watch, or state set in this room; `null` once one succeeds, and cleared by the next `join`. */
273
+ error: JsonrpcErrorObject | null;
274
+ /** The member state the caller wants, sent with the join and with every change while seated. */
275
+ local_state: string | null;
276
+ /** Whether a seat is wanted. */
277
+ want_seat: boolean;
278
+ /** Whether a watch is wanted. */
279
+ want_watch: boolean;
280
+ /** The seat this room rejoins on the next connection, after a disconnect took it. */
281
+ rejoin_of: MemberId | null;
282
+ /**
283
+ * Where the seat stands. A getter, not a `$derived`: a room outlives the
284
+ * effect that first asked for it, and a `$derived` would freeze with it.
285
+ */
286
+ get seat_status(): RoomSeatStatus;
287
+ /** Built by `RoomClient.room`. */
288
+ constructor(host: RoomHost, room_id: RoomId);
289
+ /**
290
+ * Subscribe to the room's events.
291
+ *
292
+ * @returns the remover
293
+ */
294
+ add_listener(listener: RoomListener): () => void;
295
+ /**
296
+ * Want a seat. Resolves once it is taken (at once when it already is), or
297
+ * with the refusal; a `leave` before it is taken resolves it as
298
+ * `room_join_superseded`. While the socket is down it waits for the next
299
+ * connection.
300
+ *
301
+ * @returns the seat, or why there is none
302
+ */
303
+ join(options?: RoomJoinOptions): Promise<RoomRpcResult<RoomSeat>>;
304
+ /**
305
+ * Stop wanting the seat: it ends here at once (`unseated` with `left`), and
306
+ * the server hears a `room_leave` once the socket allows. A rejoin waiting
307
+ * on a reconnect is dropped.
308
+ *
309
+ * @returns resolves once the room's requests have settled
310
+ */
311
+ leave(): Promise<void>;
312
+ /**
313
+ * Want a watch: the members without a seat. A watch the server ends
314
+ * (`room_watch_ended`) is not taken again.
315
+ *
316
+ * @returns resolves once the room's requests have settled
317
+ */
318
+ watch(): Promise<void>;
319
+ /**
320
+ * Stop wanting the watch.
321
+ *
322
+ * @returns resolves once the room's requests have settled
323
+ */
324
+ unwatch(): Promise<void>;
325
+ /**
326
+ * Set the caller's member state: sent now when seated, else with the next
327
+ * join. Only the latest state is sent; a burst sends at most one per
328
+ * answer.
329
+ *
330
+ * @returns resolves once the room's requests have settled
331
+ */
332
+ set_state(state: string): Promise<void>;
333
+ /**
334
+ * Relay `payload` to one member (`to`), or to every other member (`null`).
335
+ * Sent at once, never ordered against other sends: a caller that needs an
336
+ * order waits for each answer before the next send.
337
+ *
338
+ * @returns `null`, or the refusal — `room_not_joined` without a seat
339
+ */
340
+ send(to: MemberId | null, payload: string): Promise<RoomRpcResult<null>>;
341
+ }
342
+ /**
343
+ * The rooms one page joins and watches over one socket, for one actor. See the
344
+ * module doc for the wiring: the client follows the connection on its own, and
345
+ * `receive` takes the RPC client's room notifications.
346
+ */
347
+ export declare class RoomClient {
348
+ #private;
349
+ readonly rpc: RoomRpc;
350
+ readonly acting: Uuid | undefined;
351
+ readonly log: Logger | null;
352
+ /** Every room this client has touched, by id. */
353
+ readonly rooms: SvelteMap<RoomId, RoomState>;
354
+ /** Whether `dispose` was called; the verbs then do nothing. */
355
+ disposed: boolean;
356
+ constructor(rpc: RoomRpc, options?: RoomClientOptions);
357
+ /**
358
+ * The room by id, created on first use. A `$derived` or a template may ask
359
+ * for one it hasn't made yet, but Svelte doesn't track state made in the
360
+ * reaction reading it: a `$derived` that makes the room and reads its state
361
+ * in one expression (`client.room(id).seat_status`) never updates. Ask in
362
+ * one `$derived` and read in another, or make the room beforehand.
363
+ *
364
+ * @returns the room's state
365
+ */
366
+ room(room_id: RoomId): RoomState;
367
+ /**
368
+ * Read `RoomRpc.connection`, and when it changed since the last read, drop
369
+ * every seat and watch the old connection held (seats lost this way are
370
+ * rejoined), then converge every room over the new one. The client's own
371
+ * effect calls it whenever the connection changes, and it runs on its own
372
+ * before each request and notification; only `rpc.connection` is read
373
+ * tracked.
374
+ *
375
+ * @mutates this - every room, when the connection changed
376
+ */
377
+ sync_connection(): void;
378
+ /**
379
+ * Take a pushed notification. A room notification is parsed with its
380
+ * params schema and routed to its room; one for a room this client doesn't
381
+ * hold is dropped.
382
+ *
383
+ * @param method - the notification's method
384
+ * @param params - its params, unparsed
385
+ * @returns whether `method` is a room notification
386
+ */
387
+ receive(method: string, params: unknown): boolean;
388
+ /**
389
+ * Leave every seat and drop every watch, stop following the connection,
390
+ * then refuse further use. The leaves still go out: each request syncs the
391
+ * connection on its own.
392
+ *
393
+ * @returns resolves once the leaves have been answered (or the socket is down)
394
+ * @mutates this - sets `disposed`
395
+ */
396
+ dispose(): Promise<void>;
397
+ }
398
+ export {};
399
+ //# sourceMappingURL=room_client.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"room_client.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/actions/room_client.svelte.ts"],"names":[],"mappings":"AAAA;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