tickflare 0.2.0 → 0.3.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 (58) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +3 -2
  3. package/dist/client/buffered.d.ts +25 -5
  4. package/dist/client/buffered.js +30 -7
  5. package/dist/client/buffered.js.map +1 -1
  6. package/dist/client/index.d.ts +62 -5
  7. package/dist/client/index.js +193 -14
  8. package/dist/client/index.js.map +1 -1
  9. package/dist/client/interpolate.d.ts +6 -5
  10. package/dist/client/interpolate.js +6 -5
  11. package/dist/client/interpolate.js.map +1 -1
  12. package/dist/client/lockstep.d.ts +23 -4
  13. package/dist/client/lockstep.js +47 -4
  14. package/dist/client/lockstep.js.map +1 -1
  15. package/dist/client/predict.js +16 -3
  16. package/dist/client/predict.js.map +1 -1
  17. package/dist/lockstep.d.ts +43 -4
  18. package/dist/lockstep.js +33 -0
  19. package/dist/lockstep.js.map +1 -1
  20. package/dist/protocol.d.ts +93 -5
  21. package/dist/protocol.js +12 -3
  22. package/dist/protocol.js.map +1 -1
  23. package/dist/server/gateway.d.ts +5 -0
  24. package/dist/server/gateway.js +14 -0
  25. package/dist/server/gateway.js.map +1 -1
  26. package/dist/server/index.d.ts +4 -3
  27. package/dist/server/index.js +3 -2
  28. package/dist/server/index.js.map +1 -1
  29. package/dist/server/lockstep.d.ts +29 -4
  30. package/dist/server/lockstep.js +72 -5
  31. package/dist/server/lockstep.js.map +1 -1
  32. package/dist/server/room.d.ts +118 -1
  33. package/dist/server/room.js +557 -30
  34. package/dist/server/room.js.map +1 -1
  35. package/dist/server/schema.d.ts +67 -0
  36. package/dist/server/schema.js +44 -0
  37. package/dist/server/schema.js.map +1 -0
  38. package/dist/server/spectators.d.ts +74 -0
  39. package/dist/server/spectators.js +190 -0
  40. package/dist/server/spectators.js.map +1 -0
  41. package/dist/server/storage.d.ts +13 -1
  42. package/dist/server/storage.js +23 -5
  43. package/dist/server/storage.js.map +1 -1
  44. package/package.json +1 -1
  45. package/src/client/buffered.ts +43 -13
  46. package/src/client/index.ts +237 -14
  47. package/src/client/interpolate.ts +6 -5
  48. package/src/client/lockstep.ts +68 -7
  49. package/src/client/predict.ts +16 -3
  50. package/src/lockstep.ts +67 -4
  51. package/src/protocol.ts +94 -4
  52. package/src/server/gateway.ts +14 -0
  53. package/src/server/index.ts +6 -0
  54. package/src/server/lockstep.ts +70 -6
  55. package/src/server/room.ts +589 -31
  56. package/src/server/schema.ts +101 -0
  57. package/src/server/spectators.ts +221 -0
  58. package/src/server/storage.ts +33 -6
package/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  How versions work before 1.0: a new minor version (0.2, 0.3) can change the API in ways that need changes in your code, and each such change is listed here with what to change. A patch version (0.1.1) fixes things and changes nothing you call. The [protocol](https://tickflare.gridpaper.dev/reference/protocol) has a version of its own: the room says which one it speaks, and keeps answering clients of older ones.
4
4
 
5
+ ## 0.3.0
6
+
7
+ - A command is no longer lost, or applied twice, when the connection drops on its way. `RoomClient` names itself when it connects and numbers its commands; the room remembers how far it got with them, in the same write as the state, and says so when the client is back (protocol version 5: `c`, `from` and `refused` in `welcome`). The client settles the commands the room handled and sends the others again, so the promise from `send()` resolves or rejects as if the connection had held, through a deploy or a restart of the room too. A command waits for at most `keepCommandsMs`, ten seconds by default. It costs no rows beyond the saves a room makes anyway, but for one when a page is loaded again while its player holds a seat. Lockstep rooms and the Godot and Unity clients do not take part yet, and a room opts out with `rememberCommands = false`. See [When the connection drops](https://tickflare.gridpaper.dev/guide/client#when-the-connection-drops).
8
+
9
+ - A ticking room can simulate more often than it sends. Set `patchRate` below `tickRate` (60 ticks and 20 patches a second, say) and the room runs every tick but sends each player what changed only that many times a second, in one patch for the ticks in between. What a patch costs, `view()` for every player, the comparison and the bytes, is paid that much less often. A command is acknowledged with the patch that shows it, and messages sent from `onTick` wait for it too; nothing waits when the simulation stops. `RoomClient.patchRate` says how often patches come, `BufferedInterpolator` keeps one patch more of a delay by itself, and an `Interpolator` should glide for `1000 / room.patchRate` ms. The Godot and Unity clients work with such a room but do not read the rate yet. See [Sending less often than you simulate](https://tickflare.gridpaper.dev/guide/state-sync#sending-less-often-than-you-simulate).
10
+ - `parseWith(schema, raw)` checks a command against a schema from any library that implements Standard Schema, such as Zod, Valibot or ArkType: `protected parseCommand(raw: unknown) { return parseWith(Command, raw); }`. The room gets what the schema gives back, and what does not fit is refused with the first thing the schema found wrong and where, as `invalid_command: Expected number (at x)`. It works for `parseInput` in a lockstep room too, and Tickflare depends on none of the libraries. See [Checking commands with a schema](https://tickflare.gridpaper.dev/guide/rooms#checking-commands-with-a-schema).
11
+ - A lockstep desync now says whose simulations differed and where. `desync.players` in the view names the two players whose hashes differed, and `onDesync` gets them, on the server as `onDesync(turn, players)` and in `LockstepClient` as `onDesync(turn, desync)`. With a simulation that has `save`, the two clients then send the room what they had saved at that turn, and the room puts the first eight places where the two differ in `desync.differs`, as a path into what `save` returns and the two values: `units.tank.x`, `"14"` and `"14.5"`. `onDesyncExplained` runs on the server and in every client when it is known. A client with a `hash` of its own takes part with `explainDesyncs: true`. `differences(a, b)`, the comparison itself, is exported for tests of your own. See [Finding a desync](https://tickflare.gridpaper.dev/guide/lockstep#finding-a-desync).
12
+ - A ticking room can keep the state of its last ticks and judge a command by the one its player was looking at, which is what lag compensation needs. Set `historyTicks` (12 at 60 ticks a second is 200 ms) and `stateAt(tick)` returns the state as that tick left it, or `undefined` when the room does not have it. On the client, `BufferedInterpolator.drawnTick()` says which tick is on screen, to send with the command. Keeping the ticks costs no work in a tick, only memory, and `historyTicks` is also as far back as a client can claim to have seen. See [Judging a command by what its player saw](https://tickflare.gridpaper.dev/guide/state-sync#judging-a-command-by-what-its-player-saw).
13
+ - Spectators: connections that watch a room without a seat in it. Set `maxSpectators` on the room and connect with `new RoomClient(url, { spectate: true })`. A spectator is sent the room's `spectatorView()`, kept up to date like a player's view, with who is here and what the room broadcasts; they are not among `players`, no seat hook runs for them, and what they send is refused. `spectatorDelayMs` keeps them that far behind the players, in everything, so that watching is no help to someone who plays. `onSpectate(player)` decides who may watch, and a room with a `view()` of its own takes no spectators until it has a `spectatorView()`. Not for lockstep rooms, and not yet in the Godot and Unity clients. On the wire a spectator asks with `spectate=1` and is answered with a `spectating` frame in place of `welcome`; a gateway of your own should hand such a request to the room under `x-tickflare-spectator`, as `routeToRoom` does. See [Spectators](https://tickflare.gridpaper.dev/guide/spectators).
14
+ - `RoomClient.send()` and `leave()` wait for a connection instead of rejecting with `not_connected` at once. A command sent while the client is connecting, the first time or again, is held, shows in `unconfirmed`, and goes out when the room answers; it rejects with `not_connected` only after `keepCommandsMs` without one. A command that was in flight when the connection dropped rejects with `disconnected` only when the client could not find out what became of it, and no longer at the moment of the drop. Pass `keepCommandsMs: 0` to keep the old behaviour.
15
+
5
16
  ## 0.2.0
6
17
 
7
18
  - `BufferedInterpolator` draws what moves at the room's own pace: it keeps the last few states of each thing by tick and draws a moment a little behind the room's clock, with a delay that adapts to the jitter it measures. When updates stop it carries things on at their last speed for a few ticks, it draws a jump as one (`snap(id)` or `snapDistance`), and it turns angles the short way round. It has the same `update` and `at` as `Interpolator`, which stays for a player's own predicted moves. See [Drawing at the room's pace](https://tickflare.gridpaper.dev/guide/state-sync#drawing-at-the-room-s-pace).
package/README.md CHANGED
@@ -59,16 +59,17 @@ The room saves every change before anyone hears about it, rolls back what `rejec
59
59
  ## What's in it
60
60
 
61
61
  - **Three sync modes** on one room kernel: [event mode](docs/guide/rooms.md) for turn-based games, [state sync](docs/guide/state-sync.md) for real-time ones, [lockstep](docs/guide/lockstep.md) for strategy games with many units.
62
- - **Patches, not snapshots**: a player is sent what changed in their own [view](docs/guide/state-and-views.md) of the state, after a move as after a tick.
62
+ - **Patches, not snapshots**: a player is sent what changed in their own [view](docs/guide/state-and-views.md) of the state, after a move as after a tick, and a room can [simulate more often than it sends](docs/guide/state-sync.md#sending-less-often-than-you-simulate).
63
63
  - **[Lockstep snapshots](docs/guide/lockstep.md#snapshots)**: a player who joins or reloads late starts from a simulation the other players' clients saved and agreed on, not from the first turn.
64
64
  - **[Rooms that end](docs/guide/rooms.md#when-a-room-is-over)**: a hook for when the last player is gone, rooms that delete themselves with their storage, and matches that [play on](docs/guide/state-sync.md#playing-on-with-nobody-connected) with nobody connected.
65
+ - **[Spectators](docs/guide/spectators.md)**: connections that watch without a seat, with a view of their own, kept as many seconds behind the players as the room says.
65
66
  - **[Identity](docs/guide/identity.md)** decided once, at the gateway, with signed join tokens.
66
67
  - **[Accounts](docs/guide/accounts.md)** on D1: guests, sign-up, sessions, password recovery, player data, stats and leaderboards.
67
68
  - **[Matchmaking](docs/guide/matchmaking.md)** by skill and region, with parties and teams, which reserves a room near its players, and **[match results](docs/guide/match-results.md)** through a Queue into D1, with replays in R2.
68
69
  - **[Worlds across rooms](docs/guide/worlds.md)**: handover between rooms and seeing across borders.
69
70
  - **[A report of what each room cost](docs/guide/costs.md#checking-what-you-are-billed-for)**, from Cloudflare's own analytics, which marks rooms that stayed awake with nobody in them.
70
71
  - **[Clients for Godot and Unity](docs/guide/engines.md)**, with the browser client's interpolation and prediction, and **[a written-down protocol](docs/reference/protocol.md)** for other engines, with binary patches for those whose WebSocket is not compressed.
71
- - **[A client](docs/guide/client.md)** for browsers and Node that reconnects on its own, and **[prediction](docs/guide/state-sync.md#showing-a-players-own-moves-at-once)**: a player's own move shows on the click and is corrected by the room.
72
+ - **[A client](docs/guide/client.md)** for browsers and Node that reconnects on its own, with [no command lost or applied twice](docs/guide/client.md#when-the-connection-drops) on the way, and **[prediction](docs/guide/state-sync.md#showing-a-players-own-moves-at-once)**: a player's own move shows on the click and is corrected by the room. For shots, the room can [judge a command by the tick its player was looking at](docs/guide/state-sync.md#judging-a-command-by-what-its-player-saw).
72
73
  - **[Measured on Cloudflare](docs/guide/limits.md#the-same-rooms-on-cloudflare)**: what a room holds, such as five hundred players who each see their own part of the world at ten ticks a second, with every run written down, the ones that fell short included.
73
74
 
74
75
  ## Install
@@ -4,6 +4,8 @@ export interface TickSource {
4
4
  readonly tick: number;
5
5
  /** Ticks a second; 0 in event mode. */
6
6
  readonly tickRate: number;
7
+ /** Patches a second, when the room sends less often than it ticks: `RoomClient.patchRate`. */
8
+ readonly patchRate?: number;
7
9
  /** The tick the room is on at `now`, by estimate, as `RoomClient.serverTick` gives it. */
8
10
  serverTick?(now?: number): number | undefined;
9
11
  }
@@ -11,14 +13,18 @@ export interface TickSource {
11
13
  export interface BufferedInterpolatorOptions<Field extends string> {
12
14
  /**
13
15
  * How far behind the newest state it expects to have, in ticks, before the
14
- * margin for jitter is added. 2 by default: a patch can be a tick late, or
15
- * cover two ticks, without anything having to be guessed.
16
+ * margin for jitter is added. By default one tick more than there are
17
+ * between two patches, so that there are always two to draw between: 2
18
+ * for a room that sends after every tick, where a patch can then be a tick
19
+ * late or cover two ticks without anything having to be guessed, and 4
20
+ * for one that ticks 60 times a second and sends 20 times.
16
21
  */
17
22
  delayTicks?: number;
18
23
  /**
19
24
  * For how many ticks a thing keeps moving at its last speed when no newer
20
- * state has arrived for it, before it stops where it got to. 3 by default;
21
- * 0 stops it at its last known place.
25
+ * state has arrived for it, before it stops where it got to. By default
26
+ * two ticks more than there are between two patches, which is 3 for a
27
+ * room that sends after every tick; 0 stops it at its last known place.
22
28
  */
23
29
  maxExtrapolationTicks?: number;
24
30
  /**
@@ -42,7 +48,9 @@ export interface BufferedInterpolatorOptions<Field extends string> {
42
48
  * is on (`RoomClient.serverTick()`), blending the states on either side.
43
49
  * Motion then keeps the pace of the room, whatever the network does to the
44
50
  * patches, at the cost of the delay: two ticks and a margin for the jitter
45
- * it measures, which it keeps adjusting.
51
+ * it measures, which it keeps adjusting. Against a room that sends less
52
+ * often than it ticks (`patchRate`), the two ticks become one more than
53
+ * there are between two patches.
46
54
  *
47
55
  * When the newest state is older than the moment it draws, it carries each
48
56
  * thing on at its last speed for up to `maxExtrapolationTicks`, then holds
@@ -83,6 +91,18 @@ export declare class BufferedInterpolator<Field extends string> {
83
91
  snap(id: string): void;
84
92
  /** The values to draw for `id` right now, or undefined if it is not known. */
85
93
  at(id: string, now?: number): Record<Field, number> | undefined;
94
+ /**
95
+ * The tick it draws at `now`, with its fraction: the moment of the room's
96
+ * time that `at` shows. Send it with a command that depends on what the
97
+ * player was looking at, a shot for one, and the room can judge the
98
+ * command by the state of that tick, which it keeps with `historyTicks`
99
+ * and reads with `stateAt(tick)`.
100
+ *
101
+ * While there is no clock to go by, and when the simulation has stopped,
102
+ * it is the tick of the latest state, since that is what `at` shows then.
103
+ * Undefined before the first `update`.
104
+ */
105
+ drawnTick(now?: number): number | undefined;
86
106
  /** Forget everything, e.g. after moving to another room. */
87
107
  clear(): void;
88
108
  }
@@ -12,7 +12,9 @@ const MAX_SNAPSHOTS = 64;
12
12
  * is on (`RoomClient.serverTick()`), blending the states on either side.
13
13
  * Motion then keeps the pace of the room, whatever the network does to the
14
14
  * patches, at the cost of the delay: two ticks and a margin for the jitter
15
- * it measures, which it keeps adjusting.
15
+ * it measures, which it keeps adjusting. Against a room that sends less
16
+ * often than it ticks (`patchRate`), the two ticks become one more than
17
+ * there are between two patches.
16
18
  *
17
19
  * When the newest state is older than the moment it draws, it carries each
18
20
  * thing on at its last speed for up to `maxExtrapolationTicks`, then holds
@@ -52,13 +54,18 @@ export class BufferedInterpolator {
52
54
  this.#source = source;
53
55
  this.#fields = fields;
54
56
  this.#angles = new Set(options.angles ?? []);
55
- this.#delayTicks = Math.max(0, options.delayTicks ?? 2);
56
- this.#maxExtrapolation = Math.max(0, options.maxExtrapolationTicks ?? 3);
57
+ this.#delayTicks = options.delayTicks === undefined ? undefined : Math.max(0, options.delayTicks);
58
+ this.#maxExtrapolation = options.maxExtrapolationTicks === undefined ? undefined : Math.max(0, options.maxExtrapolationTicks);
57
59
  this.#snapDistance = options.snapDistance ?? Infinity;
58
60
  }
59
61
  /** The delay it draws at right now, in ticks behind the room's clock: see the class. */
60
62
  get delay() {
61
- return (this.#lateness ?? 0) + this.#delayTicks + 2 * this.#jitter;
63
+ return (this.#lateness ?? 0) + (this.#delayTicks ?? 1 + this.#ticksAPatch()) + 2 * this.#jitter;
64
+ }
65
+ /** How many ticks there are between two patches: 1, unless the room sends less often than it ticks. */
66
+ #ticksAPatch() {
67
+ const { tickRate, patchRate } = this.#source;
68
+ return patchRate !== undefined && patchRate > 0 && patchRate < tickRate ? Math.ceil(tickRate / patchRate) : 1;
62
69
  }
63
70
  /**
64
71
  * Feed the latest values, keyed by id, as of tick `tick`: the source's
@@ -123,12 +130,12 @@ export class BufferedInterpolator {
123
130
  if (!track || track.length === 0)
124
131
  return undefined;
125
132
  const newest = track[track.length - 1];
126
- const tick = this.#drawnTick(now);
133
+ const tick = this.#moment(now);
127
134
  if (tick === undefined)
128
135
  return { ...newest.values };
129
136
  if (tick >= newest.tick) {
130
137
  const before = track[track.length - 2];
131
- const ahead = Math.min(tick - newest.tick, this.#maxExtrapolation);
138
+ const ahead = Math.min(tick - newest.tick, this.#maxExtrapolation ?? 2 + this.#ticksAPatch());
132
139
  if (!before || newest.snap || ahead <= 0)
133
140
  return { ...newest.values };
134
141
  // Carried on at the speed it last had, for as long as that is allowed.
@@ -146,6 +153,22 @@ export class BufferedInterpolator {
146
153
  return { ...from.values };
147
154
  return this.#blend(from.values, to.values, (tick - from.tick) / (to.tick - from.tick));
148
155
  }
156
+ /**
157
+ * The tick it draws at `now`, with its fraction: the moment of the room's
158
+ * time that `at` shows. Send it with a command that depends on what the
159
+ * player was looking at, a shot for one, and the room can judge the
160
+ * command by the state of that tick, which it keeps with `historyTicks`
161
+ * and reads with `stateAt(tick)`.
162
+ *
163
+ * While there is no clock to go by, and when the simulation has stopped,
164
+ * it is the tick of the latest state, since that is what `at` shows then.
165
+ * Undefined before the first `update`.
166
+ */
167
+ drawnTick(now = localNow()) {
168
+ if (this.#newestTick === -Infinity)
169
+ return undefined;
170
+ return this.#moment(now) ?? this.#newestTick;
171
+ }
149
172
  /** Forget everything, e.g. after moving to another room. */
150
173
  clear() {
151
174
  this.#tracks.clear();
@@ -186,7 +209,7 @@ export class BufferedInterpolator {
186
209
  this.#lateness += (late - this.#lateness) / 8;
187
210
  }
188
211
  /** The tick drawn at `now`, with its fraction. Undefined when there is no clock to go by. */
189
- #drawnTick(now) {
212
+ #moment(now) {
190
213
  if (!(this.#source.tickRate > 0))
191
214
  return undefined;
192
215
  const clock = this.#clockTick(now);
@@ -1 +1 @@
1
- {"version":3,"file":"buffered.js","sourceRoot":"","sources":["../../src/client/buffered.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA4CnD,6DAA6D;AAC7D,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,oBAAoB;IACtB,OAAO,CAAa;IACpB,OAAO,CAAmB;IAC1B,OAAO,CAAqB;IAC5B,WAAW,CAAS;IACpB,iBAAiB,CAAS;IAC1B,aAAa,CAAS;IAC/B,OAAO,GAAG,IAAI,GAAG,EAA6B,CAAC;IAC/C,yFAAyF;IACzF,SAAS,GAAG,IAAI,WAAW,EAAE,CAAC;IAC9B,kGAAkG;IAClG,SAAS,CAAqB;IAC9B,OAAO,GAAG,CAAC,CAAC;IACZ,WAAW,GAAG,CAAC,QAAQ,CAAC;IACxB,yFAAyF;IACzF,MAAM,CAA4C;IAElD;;;;OAIG;IACH,YAAY,MAAkB,EAAE,MAAwB,EAAE,OAAO,GAAuC,EAAE;QACxG,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC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IAAI,IAAI,CAAC,aAAa,KAAK,QAAQ;YAAE,OAAO,CAAC,CAAC;QAC9C,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;gBAAE,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;CACF;AAED,iDAAiD;AACjD,SAAS,IAAI,CAAC,KAAa;IACzB,MAAM,MAAM,GAAG,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACnF,OAAO,MAAM,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AAChD,CAAC"}
@@ -11,7 +11,7 @@ export { Predictor, type PredictorOptions } from "./predict.js";
11
11
  export { produce } from "./draft.js";
12
12
  export { decodePatchFrame } from "../binary.js";
13
13
  export { LockstepClient, type LockstepClientOptions } from "./lockstep.js";
14
- export { fingerprint, runReplay, seededRandom, stepThrough, type CatchUp, type LockstepView, type TurnsMessage, type Replay, type SeededRandom, type Simulation, type Snapshot, type TurnEntry, } from "../lockstep.js";
14
+ export { differences, fingerprint, runReplay, seededRandom, stepThrough, type CatchUp, type Desync, type DesyncDifference, type LockstepView, type TurnsMessage, type Replay, type SeededRandom, type Simulation, type Snapshot, type TurnEntry, } from "../lockstep.js";
15
15
  /**
16
16
  * Where a connection stands. `connecting` covers the first attempt and every
17
17
  * reconnect; `closed` is final.
@@ -75,6 +75,18 @@ export interface RoomClientOptions<View> {
75
75
  token?: TokenSource;
76
76
  /** The room handed this player to another room, and the client is now connecting there. */
77
77
  onMoved?(roomId: string): void;
78
+ /**
79
+ * Watch the room without taking a seat in it, if it takes spectators
80
+ * (`maxSpectators`). `state` is then what the room shows its spectators,
81
+ * kept up to date like a player's view; `players`, `onPresence` and
82
+ * `onMessage` work as for a player, the last for what the room broadcasts.
83
+ * A spectator sends nothing: `send` and `leave` reject with `spectator`.
84
+ *
85
+ * A room may keep its spectators behind its players (`spectatorDelayMs`):
86
+ * `delayMs` says by how much. The first to watch such a room is connected
87
+ * at once, and has no `state` until that long has passed.
88
+ */
89
+ spectate?: boolean;
78
90
  /** Reconnect after an unexpected close. Defaults to true. */
79
91
  reconnect?: boolean;
80
92
  /**
@@ -93,6 +105,25 @@ export interface RoomClientOptions<View> {
93
105
  * for dead and replaced.
94
106
  */
95
107
  pingIntervalMs?: number;
108
+ /**
109
+ * How long a command may wait for a connection, in milliseconds. Defaults
110
+ * to 10 seconds.
111
+ *
112
+ * A command sent while the client is connecting, the first time or again,
113
+ * is held and sent as soon as the room answers. A command that was on its
114
+ * way when the connection dropped is kept too: when the client is back,
115
+ * the room says which of them it handled, the client sends the others
116
+ * again, and none is applied twice. Either way the promise `send` returned
117
+ * settles as if nothing had happened.
118
+ *
119
+ * A command that has waited this long is given up: its promise rejects
120
+ * with `not_connected` if it was never sent, and `disconnected` if it was.
121
+ * Keep it short in a game where a late command is worse than a lost one.
122
+ *
123
+ * 0 keeps nothing: `send` rejects at once while there is no connection,
124
+ * and whatever is in flight when one drops rejects with `disconnected`.
125
+ */
126
+ keepCommandsMs?: number;
96
127
  }
97
128
  /** A command on its way: sent, and not yet shown by the room's state. */
98
129
  export interface SentCommand<Command = unknown> {
@@ -101,16 +132,23 @@ export interface SentCommand<Command = unknown> {
101
132
  /** The command. */
102
133
  command: Command;
103
134
  }
104
- /** A command or leave the room refused, or one that was in flight when the connection dropped. */
135
+ /** A command or leave the room refused, or one the client gave up on for want of a connection. */
105
136
  export declare class CommandRejected extends Error {
106
- /** What the room passed to `reject()`, or `not_connected` or `disconnected`. */
137
+ /**
138
+ * What the room passed to `reject()`. Or `not_connected`: the command never
139
+ * left this client, and was not applied. Or `disconnected`: it was sent,
140
+ * the connection dropped, and the client could not learn what became of
141
+ * it. It may or may not have been applied. Or `spectator`: this client
142
+ * watches the room, and has no seat to send from.
143
+ */
107
144
  readonly reason: string;
108
145
  constructor(reason: string);
109
146
  }
110
147
  /**
111
148
  * A connection to one room. Holds the latest state the server sent and
112
149
  * reconnects on its own; after a reconnect the server sends the current state
113
- * again, so there is nothing to replay.
150
+ * again, so there is nothing to replay. Commands that were on their way when
151
+ * the connection dropped are settled then too: see `keepCommandsMs`.
114
152
  */
115
153
  export declare class RoomClient<View = unknown, Command = unknown> {
116
154
  #private;
@@ -123,6 +161,12 @@ export declare class RoomClient<View = unknown, Command = unknown> {
123
161
  get tick(): number;
124
162
  /** The room's simulation rate in ticks per second; 0 in event mode. */
125
163
  get tickRate(): number;
164
+ /**
165
+ * How many times a second the room sends what changed while it ticks: its
166
+ * `patchRate` if it has one, and otherwise `tickRate`. 0 in event mode.
167
+ * It is what to set the duration of an `Interpolator` from.
168
+ */
169
+ get patchRate(): number;
126
170
  /**
127
171
  * The tick the room is on right now, by estimate, with the fraction of the
128
172
  * next that has passed: for drawing the game in step with the room, or
@@ -142,6 +186,14 @@ export declare class RoomClient<View = unknown, Command = unknown> {
142
186
  * client measures it every few seconds; otherwise with the keepalive.
143
187
  */
144
188
  get rtt(): number | undefined;
189
+ /** Whether this client watches the room without a seat: it was made with `spectate`. */
190
+ get spectating(): boolean;
191
+ /**
192
+ * For a spectator: how far behind the room everything this client is sent
193
+ * is, in milliseconds. 0 when the room does not delay its spectators, and
194
+ * for a player.
195
+ */
196
+ get delayMs(): number;
145
197
  /** This player's id, as the server knows it. Set once connected. */
146
198
  get you(): string | undefined;
147
199
  /** Everyone with a seat in the room, in join order. */
@@ -168,7 +220,12 @@ export declare class RoomClient<View = unknown, Command = unknown> {
168
220
  * Send a command. Resolves once the room applied it, by which time `state`
169
221
  * already reflects it: at once in event mode, and with the next tick in a
170
222
  * room that is ticking. Rejects with `CommandRejected` if the room refused
171
- * it or the connection dropped first.
223
+ * it.
224
+ *
225
+ * A connection that drops on the way does not lose the command, or apply
226
+ * it twice: the client learns what became of it when it is back, and sends
227
+ * it again if it never arrived. Without a connection the command waits for
228
+ * one. Both for at most `keepCommandsMs`, after which it rejects.
172
229
  */
173
230
  send(command: Command): Promise<void>;
174
231
  /**