@hadoku/rooms-protocol 0.45.94 → 0.45.96
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/seats.d.ts +51 -0
- package/dist/seats.d.ts.map +1 -1
- package/dist/seats.js +60 -1
- package/package.json +2 -2
package/dist/seats.d.ts
CHANGED
|
@@ -199,6 +199,26 @@ export interface ReleaseOptions {
|
|
|
199
199
|
* Returns the vacated SeatId, or null if they held none.
|
|
200
200
|
*/
|
|
201
201
|
export declare function unseatParticipant(table: SeatTable, participantId: ParticipantId, opts?: ReleaseOptions): SeatId | null;
|
|
202
|
+
/**
|
|
203
|
+
* The LEADER removes a seated participant — stood up, not by their own choice.
|
|
204
|
+
*
|
|
205
|
+
* Differs from a bare `unseatParticipant(table, participantId)` in exactly one
|
|
206
|
+
* way: it always releases with `hold: false`, whatever the table's
|
|
207
|
+
* `reservationTtlMs`. A reservation exists for an absence nobody chose — a
|
|
208
|
+
* dropped connection, a suspended laptop — so the owner's own seat survives
|
|
209
|
+
* it. A leader's removal is the opposite: a deliberate decision to open the
|
|
210
|
+
* seat right now, so holding it against the very room the leader just opened
|
|
211
|
+
* it to would undo the point of the call.
|
|
212
|
+
*
|
|
213
|
+
* The seat stays STICKY (remembered), same as any other departure — this
|
|
214
|
+
* function has no opinion on whether the person may come back, only that if
|
|
215
|
+
* they do (via `seatParticipant`, called by whoever this module's caller lets
|
|
216
|
+
* call it), they land where they were rather than at the back of the line.
|
|
217
|
+
*
|
|
218
|
+
* Returns the vacated SeatId, or null if they held none — same contract as
|
|
219
|
+
* `unseatParticipant`.
|
|
220
|
+
*/
|
|
221
|
+
export declare function removeFromSeat(table: SeatTable, participantId: ParticipantId): SeatId | null;
|
|
202
222
|
/** Forget a participant entirely, so they get a fresh seat next time. */
|
|
203
223
|
export declare function forgetParticipant(table: SeatTable, participantId: ParticipantId): void;
|
|
204
224
|
/**
|
|
@@ -225,6 +245,19 @@ export declare function occupiedSeats(table: SeatTable): Array<{
|
|
|
225
245
|
* Returns the participants displaced — the caller decides what that means
|
|
226
246
|
* (they become spectators; a game in progress may prefer not to shrink at all).
|
|
227
247
|
* Their seat stays remembered, so growing the table again restores them.
|
|
248
|
+
*
|
|
249
|
+
* This IS "lower capacity under occupants, evicting someone" — there is no
|
|
250
|
+
* separate operation for it. Eviction is always from the HIGHEST seat down
|
|
251
|
+
* (`slice(capacity)`): the array can never hold more than `capacity` entries
|
|
252
|
+
* afterward, so nobody above the new line survives, and nobody below it is
|
|
253
|
+
* ever touched. A caller-chosen seat to sacrifice instead is deliberately not
|
|
254
|
+
* offered — this table has no concept of a specific seat that is "closed"
|
|
255
|
+
* while a higher one stays open (that would mean `seats.length` no longer
|
|
256
|
+
* bounding `capacity`, breaking `hasRoom` and `freeSeatCount`), and inventing
|
|
257
|
+
* one would be a second notion of "capacity" alongside this number. A caller
|
|
258
|
+
* that wants a specific seat gone can `unseatParticipant`/`removeFromSeat`
|
|
259
|
+
* that one SeatId and lower capacity by one separately — two calls, not a
|
|
260
|
+
* hidden extra state.
|
|
228
261
|
*/
|
|
229
262
|
export declare function setSeatCapacity(table: SeatTable, capacity: number | null): ParticipantId[];
|
|
230
263
|
/**
|
|
@@ -235,6 +268,24 @@ export declare function setSeatCapacity(table: SeatTable, capacity: number | nul
|
|
|
235
268
|
* Bot ids are positional (`bot:<n>` by seat) so a re-pad is deterministic.
|
|
236
269
|
*/
|
|
237
270
|
export declare function padWithBots(table: SeatTable, count: number): SeatId[];
|
|
271
|
+
/**
|
|
272
|
+
* Replace a SEATED human with a bot, in their own seat — the leader's "bot
|
|
273
|
+
* this person out" rather than padding an empty slot.
|
|
274
|
+
*
|
|
275
|
+
* What `padWithBots` deliberately refuses (it only fills EMPTY and
|
|
276
|
+
* already-bot seats, never a human's — see its header) is exactly what this
|
|
277
|
+
* exists to do: one specific occupied seat, by its SeatId, with everyone
|
|
278
|
+
* else's seat untouched.
|
|
279
|
+
*
|
|
280
|
+
* The displaced human stays remembered, exactly like any other departure, so
|
|
281
|
+
* `seatParticipant`'s existing "a human outranks a bot" rule (its step 1: the
|
|
282
|
+
* remembered seat displaces a bot even when nothing else would) is what lets
|
|
283
|
+
* them reclaim it later — this function needs no return path of its own,
|
|
284
|
+
* only to leave that memory behind.
|
|
285
|
+
*
|
|
286
|
+
* Returns the SeatId, or null if the participant held no seat to replace.
|
|
287
|
+
*/
|
|
288
|
+
export declare function replaceWithBot(table: SeatTable, participantId: ParticipantId): SeatId | null;
|
|
238
289
|
/** Free seats available to a new human right now. */
|
|
239
290
|
export declare function freeSeatCount(table: SeatTable): number;
|
|
240
291
|
/**
|
package/dist/seats.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seats.d.ts","sourceRoot":"","sources":["../src/seats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AAEH,+DAA+D;AAC/D,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B,uDAAuD;AACvD,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE9C,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,aAAa,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnC,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC;CAC/B;AAED,oEAAoE;AACpE,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,aAAa,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB;;;;;;;OAOG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unseatParticipant(table, participantId, opts = {}) {
|
|
|
152
152
|
// in. A mutation test proved the branch dead (removing it failed nothing).
|
|
153
153
|
return id;
|
|
154
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* The LEADER removes a seated participant — stood up, not by their own choice.
|
|
157
|
+
*
|
|
158
|
+
* Differs from a bare `unseatParticipant(table, participantId)` in exactly one
|
|
159
|
+
* way: it always releases with `hold: false`, whatever the table's
|
|
160
|
+
* `reservationTtlMs`. A reservation exists for an absence nobody chose — a
|
|
161
|
+
* dropped connection, a suspended laptop — so the owner's own seat survives
|
|
162
|
+
* it. A leader's removal is the opposite: a deliberate decision to open the
|
|
163
|
+
* seat right now, so holding it against the very room the leader just opened
|
|
164
|
+
* it to would undo the point of the call.
|
|
165
|
+
*
|
|
166
|
+
* The seat stays STICKY (remembered), same as any other departure — this
|
|
167
|
+
* function has no opinion on whether the person may come back, only that if
|
|
168
|
+
* they do (via `seatParticipant`, called by whoever this module's caller lets
|
|
169
|
+
* call it), they land where they were rather than at the back of the line.
|
|
170
|
+
*
|
|
171
|
+
* Returns the vacated SeatId, or null if they held none — same contract as
|
|
172
|
+
* `unseatParticipant`.
|
|
173
|
+
*/
|
|
174
|
+
export function removeFromSeat(table, participantId) {
|
|
175
|
+
return unseatParticipant(table, participantId, { hold: false });
|
|
176
|
+
}
|
|
155
177
|
/** Forget a participant entirely, so they get a fresh seat next time. */
|
|
156
178
|
export function forgetParticipant(table, participantId) {
|
|
157
179
|
unseatParticipant(table, participantId, { hold: false });
|
|
@@ -194,6 +216,19 @@ export function occupiedSeats(table) {
|
|
|
194
216
|
* Returns the participants displaced — the caller decides what that means
|
|
195
217
|
* (they become spectators; a game in progress may prefer not to shrink at all).
|
|
196
218
|
* Their seat stays remembered, so growing the table again restores them.
|
|
219
|
+
*
|
|
220
|
+
* This IS "lower capacity under occupants, evicting someone" — there is no
|
|
221
|
+
* separate operation for it. Eviction is always from the HIGHEST seat down
|
|
222
|
+
* (`slice(capacity)`): the array can never hold more than `capacity` entries
|
|
223
|
+
* afterward, so nobody above the new line survives, and nobody below it is
|
|
224
|
+
* ever touched. A caller-chosen seat to sacrifice instead is deliberately not
|
|
225
|
+
* offered — this table has no concept of a specific seat that is "closed"
|
|
226
|
+
* while a higher one stays open (that would mean `seats.length` no longer
|
|
227
|
+
* bounding `capacity`, breaking `hasRoom` and `freeSeatCount`), and inventing
|
|
228
|
+
* one would be a second notion of "capacity" alongside this number. A caller
|
|
229
|
+
* that wants a specific seat gone can `unseatParticipant`/`removeFromSeat`
|
|
230
|
+
* that one SeatId and lower capacity by one separately — two calls, not a
|
|
231
|
+
* hidden extra state.
|
|
197
232
|
*/
|
|
198
233
|
export function setSeatCapacity(table, capacity) {
|
|
199
234
|
table.capacity = capacity;
|
|
@@ -203,7 +238,6 @@ export function setSeatCapacity(table, capacity) {
|
|
|
203
238
|
for (const seat of table.seats.slice(capacity)) {
|
|
204
239
|
if (seat.occupant?.kind === 'human')
|
|
205
240
|
displaced.push(seat.occupant.participantId);
|
|
206
|
-
seat.occupant = null;
|
|
207
241
|
// A reservation on a seat that no longer exists can never be honoured and
|
|
208
242
|
// would keep `reservedSeatOf` pointing off the end of the table.
|
|
209
243
|
clearReservation(table, seat.id);
|
|
@@ -234,6 +268,31 @@ export function padWithBots(table, count) {
|
|
|
234
268
|
}
|
|
235
269
|
return filled;
|
|
236
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Replace a SEATED human with a bot, in their own seat — the leader's "bot
|
|
273
|
+
* this person out" rather than padding an empty slot.
|
|
274
|
+
*
|
|
275
|
+
* What `padWithBots` deliberately refuses (it only fills EMPTY and
|
|
276
|
+
* already-bot seats, never a human's — see its header) is exactly what this
|
|
277
|
+
* exists to do: one specific occupied seat, by its SeatId, with everyone
|
|
278
|
+
* else's seat untouched.
|
|
279
|
+
*
|
|
280
|
+
* The displaced human stays remembered, exactly like any other departure, so
|
|
281
|
+
* `seatParticipant`'s existing "a human outranks a bot" rule (its step 1: the
|
|
282
|
+
* remembered seat displaces a bot even when nothing else would) is what lets
|
|
283
|
+
* them reclaim it later — this function needs no return path of its own,
|
|
284
|
+
* only to leave that memory behind.
|
|
285
|
+
*
|
|
286
|
+
* Returns the SeatId, or null if the participant held no seat to replace.
|
|
287
|
+
*/
|
|
288
|
+
export function replaceWithBot(table, participantId) {
|
|
289
|
+
const id = seatOf(table, participantId);
|
|
290
|
+
if (id === null)
|
|
291
|
+
return null;
|
|
292
|
+
table.remembered[participantId] = id;
|
|
293
|
+
table.seats[id].occupant = { kind: 'bot', botId: `bot:${id}` };
|
|
294
|
+
return id;
|
|
295
|
+
}
|
|
237
296
|
/** Free seats available to a new human right now. */
|
|
238
297
|
export function freeSeatCount(table) {
|
|
239
298
|
const empty = table.seats.filter((s) => s.occupant === null).length;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hadoku/rooms-protocol",
|
|
3
|
-
"version": "0.45.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "0.45.96",
|
|
4
|
+
"gitHead": "06caa1612e1aa8332444b191a1141021e4035a44",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"description": "Room, identity and seating protocol — the wire contract shared by rooms-server and rooms-client.",
|