@joystyk/session 0.0.0-stage → 0.2.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 (55) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/LICENSE +21 -0
  3. package/NOTICE +36 -0
  4. package/README.md +266 -2
  5. package/dist/assistance.d.ts +3 -0
  6. package/dist/assistance.js +20 -0
  7. package/dist/assistance.js.map +1 -0
  8. package/dist/browser/audio-sounds.d.ts +19 -0
  9. package/dist/browser/audio-sounds.js +413 -0
  10. package/dist/browser/audio-sounds.js.map +1 -0
  11. package/dist/browser/audio.d.ts +16 -0
  12. package/dist/browser/audio.js +182 -0
  13. package/dist/browser/audio.js.map +1 -0
  14. package/dist/browser/index.d.ts +48 -0
  15. package/dist/browser/index.js +140 -0
  16. package/dist/browser/index.js.map +1 -0
  17. package/dist/browser/preparer.d.ts +3 -0
  18. package/dist/browser/preparer.js +73 -0
  19. package/dist/browser/preparer.js.map +1 -0
  20. package/dist/browser/rooms.d.ts +35 -0
  21. package/dist/browser/rooms.js +140 -0
  22. package/dist/browser/rooms.js.map +1 -0
  23. package/dist/fixed-step.d.ts +66 -0
  24. package/dist/fixed-step.js +280 -0
  25. package/dist/fixed-step.js.map +1 -0
  26. package/dist/index.d.ts +6 -0
  27. package/dist/index.js +7 -0
  28. package/dist/local.d.ts +130 -0
  29. package/dist/local.js +723 -0
  30. package/dist/local.js.map +1 -0
  31. package/dist/ports.d.ts +70 -0
  32. package/dist/ports.js +10 -0
  33. package/dist/ports.js.map +1 -0
  34. package/dist/publisher.d.ts +11 -0
  35. package/dist/publisher.js +44 -0
  36. package/dist/publisher.js.map +1 -0
  37. package/dist/remote.d.ts +128 -0
  38. package/dist/remote.js +474 -0
  39. package/dist/remote.js.map +1 -0
  40. package/dist/replay.d.ts +65 -0
  41. package/dist/replay.js +199 -0
  42. package/dist/replay.js.map +1 -0
  43. package/dist/rngs.d.ts +22 -0
  44. package/dist/rngs.js +34 -0
  45. package/dist/rngs.js.map +1 -0
  46. package/dist/saves.d.ts +20 -0
  47. package/dist/saves.js +59 -0
  48. package/dist/saves.js.map +1 -0
  49. package/dist/stopwatch.d.ts +22 -0
  50. package/dist/stopwatch.js +51 -0
  51. package/dist/stopwatch.js.map +1 -0
  52. package/dist/values.d.ts +19 -0
  53. package/dist/values.js +66 -0
  54. package/dist/values.js.map +1 -0
  55. package/package.json +56 -3
package/CHANGELOG.md ADDED
@@ -0,0 +1,26 @@
1
+ # @joystyk/session
2
+
3
+ ## 0.2.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [bb095c7]
8
+ - Updated dependencies [bb095c7]
9
+ - Updated dependencies [bb095c7]
10
+ - Updated dependencies [bb095c7]
11
+ - @joystyk/rooms@0.2.0
12
+ - @joystyk/contracts@0.2.0
13
+ - @joystyk/kit@0.2.0
14
+
15
+ ## 0.1.0
16
+
17
+ ### Minor Changes
18
+
19
+ - Prepare the first compiled library release: ESM and API declarations for every public entry point, runtime assets, and checks against installed npm tarballs. Games and applications remain private.
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies
24
+ - @joystyk/contracts@0.1.0
25
+ - @joystyk/kit@0.1.0
26
+ - @joystyk/rooms@0.1.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Joystyk contributors
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/NOTICE ADDED
@@ -0,0 +1,36 @@
1
+ Third-party material in the Joystyk library release
2
+
3
+ This notice preserves third-party attribution. Original Joystyk code in the 17
4
+ platform libraries under packages/ uses the MIT license in packages/LICENSE.
5
+ That choice does not license the private applications, games or other repository
6
+ material, and does not replace the third-party terms below.
7
+
8
+ @joystyk/contracts
9
+ ------------------
10
+ Standard Schema v1 type definitions from @standard-schema/spec 1.1.0:
11
+ https://github.com/standard-schema/standard-schema
12
+ https://standardschema.dev
13
+ Copyright (c) 2024 Colin McDonnell. MIT License.
14
+ The complete license and source/change notes accompany the distributed
15
+ dist/standard-schema.d.ts definitions. Changes: individually exported declarations
16
+ and formatting; the declarations themselves are unchanged.
17
+
18
+ @joystyk/identity and @joystyk/content
19
+ -----------------------------------
20
+ Word blocklists derived from List of Dirty, Naughty, Obscene, and Otherwise Bad
21
+ Words, copyright Shutterstock, Inc. and contributors:
22
+ https://github.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words
23
+ Licensed under Creative Commons Attribution 4.0 International:
24
+ https://creativecommons.org/licenses/by/4.0/
25
+ Identity uses the English list at commit
26
+ 5faf2ba42d7b1c0977169ec3611df25a3c08eb13. Changes include reducing or dropping
27
+ phrases, dropping words with everyday meanings, substituting stems for inflections
28
+ and adding entries. Identity's README and content's lists/blocklist.txt retain
29
+ their source-specific provenance and changes.
30
+
31
+ @joystyk/content
32
+ ---------------
33
+ SCOWL-derived common, vocabulary and ranked word lists use SCOWL 2020.12.07.
34
+ Their complete source licenses and attribution accompany the package in
35
+ lists/SCOWL-COPYRIGHT. Word-list transformations and build provenance are described
36
+ in the package README. Preserve that copyright file when redistributing the lists.
package/README.md CHANGED
@@ -1,3 +1,267 @@
1
- # Temporary Holding Version
1
+ # @joystyk/session
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The platform's session runners. They turn a game's pure rules into a Layer 1
4
+ `GameSession` the launcher can mount:
5
+
6
+ ## npm package
7
+
8
+ The first `0.1.0` release is being prepared; it has not been published. Once available:
9
+
10
+ ```sh
11
+ npm install @joystyk/session
12
+ ```
13
+
14
+ Node consumers require Node 24.15 or later. Browser entry points require a modern
15
+ browser and should be loaded in the browser.
16
+
17
+ | Import | Format |
18
+ | --- | --- |
19
+ | `@joystyk/session` | ES module and TypeScript declarations |
20
+ | `@joystyk/session/browser` | ES module and TypeScript declarations |
21
+ | `@joystyk/session/browser/rooms` | ES module and TypeScript declarations |
22
+
23
+ Only the entries listed above are public API. Installed packages contain compiled ESM,
24
+ type declarations and runtime assets. Repository-relative links describe the Joystyk
25
+ workspace and are not needed to use the npm package.
26
+
27
+ - `createLocalSession` plays a Layer 2 `DiscreteEngine` in the browser: solo, vs AI,
28
+ pass-and-play and daily modes.
29
+ - `createFixedStepRunner` runs a Layer 3 `FixedStepSimulation` against real time.
30
+ - `createRemoteSession` plays in a server room: the room server is the authority, and the
31
+ client speaks `@joystyk/rooms/protocol` over a WebSocket.
32
+
33
+ The interfaces they implement are in
34
+ game-contract.md (Joystyk host reference). A P2P client comes after launch
35
+ (host policy).
36
+
37
+ ## Headless core, browser adapters
38
+
39
+ The core imports only `@joystyk/contracts` and `@joystyk/kit` (for its seeded generator)
40
+ and touches no globals. Everything outside pure computation arrives through a port:
41
+
42
+ | Port | What it does | Browser adapter (`@joystyk/session/browser`) |
43
+ | --- | --- | --- |
44
+ | `Clock` | `now()` and `after(ms, fn)` | `browserClock()`: `performance.now`, `setTimeout` |
45
+ | `Visibility` | Is the page hidden, and changes | `documentVisibility()`: Page Visibility API plus `pagehide` |
46
+ | `FrameScheduler` | One callback per display frame | `animationFrames()`: `requestAnimationFrame` |
47
+ | `SaveStore` | Writes the save envelope | `webStorageSaveStore(key)`, until the `storage` package's IndexedDB store exists |
48
+ | `JobRunner` | Runs an engine job | `workerJobRunner(kind => new Worker(...))` |
49
+ | `AiRunner` | Chooses AI moves | Default: the engine's `ai.choose`, inline, after a delay; `workerAiRunner(() => new Worker(...))` for heavy AI |
50
+ | `RngFactory` | `(state) => Rng` | Default: `restoreRng` from `@joystyk/kit` |
51
+ | `Reporter` | Logs bugs the runner survived | `consoleReporter` |
52
+ | `SocketFactory` | Opens the room connection | `browserSocket(roomsSocketUrl(location.origin))` (`@joystyk/session/browser/rooms`) |
53
+ | `TokenStore` | Seat tokens by room code | `webStorageTokens()`: local storage, shared by every tab |
54
+
55
+ `browserPorts()` bundles the clock, visibility, frames and reporter. The core's
56
+ `tsconfig.json` has no DOM library, so a global creeping into the core fails the type
57
+ check; the adapters have their own `tsconfig.browser.json`.
58
+
59
+ The factory defaults to the kit's `restoreRng`. The runners use only the contracts' `Rng`
60
+ interface for the game's stream, so the tests pass a small Mulberry32 instead. The AI's
61
+ stream is always the kit's SFC32, forked with `forkRng`.
62
+
63
+ ## The local runner
64
+
65
+ ```ts
66
+ import { createLocalSession } from '@joystyk/session';
67
+ import { browserPorts, webStorageSaveStore, workerAiRunner, workerJobRunner } from '@joystyk/session/browser';
68
+
69
+ const result = createLocalSession(engine, {
70
+ ...browserPorts(),
71
+ manifest, // id, versions, undo, handoff, ai
72
+ mode: 'ai', // 'solo' | 'ai' | 'pass-and-play' | 'daily'
73
+ seats, // SeatInfo[], numbered from 0
74
+ config, // decoded with engine.schemas.config
75
+ seed, aiSeed, // RngState for the game and, separately, for the AI
76
+ storage: webStorageSaveStore(`save:${manifest.id}`),
77
+ jobs: workerJobRunner(createWorker),
78
+ ai: manifest.ai?.heavy ? workerAiRunner(createAiWorker) : undefined,
79
+ });
80
+ if (!result.ok) showProblem(result.error);
81
+ ```
82
+
83
+ Both `createLocalSession` and `restoreLocalSession` return a `Result`: invalid seats or
84
+ config, an `init` that refuses them, or an unusable save fail with a `GameError` instead of
85
+ throwing.
86
+
87
+ **Inputs** (`LocalInput`): `command` (from the viewer's seat, or from the `seat` it names:
88
+ in pass-and-play without a hand-off screen any pending human seat, so two people can make
89
+ simultaneous moves in either order; elsewhere only the viewer's own seat, never an AI's),
90
+ `resign` and `seat` (platform inputs, accepted off-turn, which may name another human
91
+ seat), `undo`, `reveal`
92
+ (ends the hand-off screen), `pause` and `resume`. Every input is checked at the boundary,
93
+ and commands go through `engine.schemas.command` before the engine sees them. A rejection
94
+ publishes a snapshot with `meta.notice` and the same revision.
95
+
96
+ **Snapshots** (`LocalSnapshot`) extend the contract's `EngineSnapshot` with `mode`,
97
+ `handoff`, `undo` (available, remaining, and what blocks it), `thinking` (AI seats choosing
98
+ now), `paused` and `elapsedMs`; `meta` adds `undosUsed` and `assists`. They follow the six
99
+ session rules:
100
+
101
+ 1. `get()` returns the latest snapshot.
102
+ 2. `subscribe()` delivers the current snapshot at once; unsubscribing twice is safe.
103
+ 3. `dispatch()` queues the input. All changes (inputs, AI moves, job results) run one at a
104
+ time on one queue, so a listener that dispatches never sees a torn state.
105
+ 4. Each snapshot is one object, published whole.
106
+ 5. Snapshots are deep-frozen unless `freeze: false` (pass `import.meta.env.DEV`).
107
+ 6. `dispose()` is idempotent; it cancels AI, jobs and timers, unsubscribes from visibility
108
+ and writes a last save. Nothing publishes afterwards.
109
+
110
+ A listener that throws is reported and skipped; the others still receive the snapshot.
111
+
112
+ ### Design choices
113
+
114
+ - **Engine errors.** A throwing `apply` becomes an `EngineThrew` notice and the previous
115
+ state. After any rejection the runner restores the `Rng`, so a rejection never consumes
116
+ randomness a replay would not.
117
+ - **AI seats** are driven when `pending()` lists a seat whose controller is `ai`. The AI
118
+ receives a JSON copy of `viewFor(state, seat)` and nothing else. A choice in flight is
119
+ cancelled when that seat's `decisionKey` (default: its view) changes, on pause, on undo
120
+ and on dispose, and a cancelled answer is dropped. Its command is validated like a
121
+ player's; an illegal one becomes an `AiFailed` notice rather than a retry loop.
122
+ - **The AI's stream** starts from `aiSeed` (default: forked from the game's random state)
123
+ and is saved as the envelope's `aiRng`. Each choice gets its own child, fork number
124
+ `seat` of the stream (`AiTask.rng`); the stream moves on only when an AI move is
125
+ accepted. A restored game, even one saved while the AI was thinking, makes the same
126
+ choices the original would have. Undo doesn't rewind it.
127
+ - **Heavy AI.** When the manifest declares `ai.heavy`, pass `workerAiRunner`; the worker
128
+ receives the `AiTask` and posts back the command. Without one, the runner reports it and
129
+ plays inline.
130
+ - **Undo** (host policy) returns to the start of the human's previous decision: it drops the
131
+ human seat's latest command and everything after it, then replays the rest from the seed,
132
+ random state included. The rule comes from `undoPolicyFor(manifest.undo, mode)`, so
133
+ pass-and-play has undo only when the manifest names it; there undo takes back the last
134
+ person's move. It is refused when the rule says `none`, with two human seats outside
135
+ pass-and-play, past an `undoBarrier`, beyond a `{ limited: n }` allowance, after the
136
+ outcome, or without history.
137
+ - **Assistance.** Every undo adds to `undosUsed` and puts `'undo'` in `assists`; a
138
+ transition's `assist` flag adds its kind. Both travel in the save, so a limited allowance
139
+ survives a reload, and the runner writes them into the outcome.
140
+ - **Pass-and-play** follows the human seat to act. With `handoff: true` (host policy) it first
141
+ publishes `handoff: { seat, name }` with no viewer and the spectator view; the beats
142
+ behind the screen are redacted for a spectator too. `reveal` shows that seat's view. A
143
+ new game and a restored one both start with a hand-off. AI seats never take the viewer.
144
+ When the outcome arrives, a hand-off game drops the viewer: the final snapshot, its beats
145
+ included, is the spectator's (`viewFor(state, null)`), so the last player's hand isn't
146
+ left on screen for whoever holds the device next. An engine whose rules show every hand
147
+ at the end (a Gin Rummy knock) reveals them in its spectator view.
148
+ - **Elapsed time** starts at the first accepted input, or, for an engine that declares
149
+ `clockStart: 'transition'`, at the first transition that sets `startsClock`. It pauses
150
+ while the page is hidden or the game paused, and stops at the outcome, whose `elapsedMs`
151
+ it fills. It travels in the save with `clockStarted`, so a resumed game neither starts the
152
+ clock early nor restarts it. `elapsedMs()` reads it live for a stopwatch.
153
+ - **Saves.** The runner writes the envelope (with its replay) at the start, after every
154
+ accepted change, when the page hides, on pause and on dispose, one write at a time. A
155
+ failed write shows `SaveFailed` and play goes on. A position the engine's `worthSaving`
156
+ rejects is never written, and the store's optional `clear` removes the save it would
157
+ have replaced, so an untouched game is never offered for resuming.
158
+ - **Restoring** parses the envelope, checks the game id and rules version (`RulesChanged`
159
+ means the game can't continue on this code), runs the migration chain, validates the
160
+ state, then replays the saved log. If the replay reproduces the saved state and random
161
+ state, undo and outstanding jobs carry on; otherwise the game resumes without history and
162
+ the reason goes to `report`. The undo count, the assistance and the AI stream come from
163
+ the envelope; a save without them starts with none and forks a new AI stream.
164
+ - **Jobs** start only after the transition that requested them is saved. The runner
165
+ validates the payload, enforces `timeoutMs`, parses the result with the job's schema
166
+ (anything invalid becomes `{ ok: false, reason: 'failed' }`), strips `presentation` into
167
+ the snapshot and feeds the rest to the engine as a `job` input. A result for a job the
168
+ game no longer awaits (undone, superseded, disposed) is dropped. `where: 'server'` jobs
169
+ and jobs without a runner fail at once, and the engine decides what that means.
170
+ - **Timeouts** never happen locally: solo, vs-AI and pass-and-play run no clock (host policy).
171
+
172
+ ## The fixed-step runner
173
+
174
+ ```ts
175
+ const result = createFixedStepRunner(simulation, {
176
+ ...browserPorts(), manifest, seats, config, seed, restoreRng, storage,
177
+ });
178
+ ```
179
+
180
+ - **Accumulator.** Each frame adds the elapsed time and runs one `step` per `1000 / stepHz`
181
+ milliseconds it covers. Catch-up is capped (`maxStepsPerFrame`, default a tenth of a
182
+ second's worth); after a stall the backlog is dropped rather than freezing the page.
183
+ - **Inputs** (`{ kind: 'input', input }`) are validated and queued; all queued inputs go to
184
+ the next tick that runs, in arrival order, and into the replay log with that tick.
185
+ - **Pause.** Hiding the page or `{ kind: 'pause' }` stops frames, resets the accumulator and
186
+ saves a checkpoint; resuming starts from a fresh frame, so paused time never becomes
187
+ ticks. Inputs while paused are rejected.
188
+ - **Snapshots** come at frame cadence: one per frame that ran ticks, with the tick events
189
+ since the last one. `alpha()` gives the fraction of the next tick for interpolation.
190
+ - **Time** is ticks: `elapsedMs` is `tick × step length`.
191
+ - **Checkpoints** (`save()`) carry the state, random state, tick and replay;
192
+ `restoreFixedStepRunner` resumes one, and running 500 ticks, saving, restoring and running
193
+ 500 more equals running 1,000.
194
+ - A `step` that throws is a bug: the runner keeps the last good tick, stops and shows an
195
+ `InternalError` notice.
196
+
197
+ ## The remote client
198
+
199
+ ```ts
200
+ import { createRemoteSession } from '@joystyk/session';
201
+ import { browserClock } from '@joystyk/session/browser';
202
+ import { browserSocket, createRoom, randomActionId, roomsSocketUrl, webStorageTokens } from '@joystyk/session/browser/rooms';
203
+
204
+ const tokens = webStorageTokens();
205
+ const created = await createRoom(location.origin, { game: manifest.id, name }); // POST /api/rooms
206
+ if (created.ok) tokens.set(created.value.room, created.value.token); // before the socket opens
207
+ const session = createRemoteSession({
208
+ game: { id: manifest.id, build: manifest.versions.build, rulesVersion: engine.rulesVersion, schemas: engine.schemas },
209
+ room: code, name, watch: false,
210
+ connect: browserSocket(roomsSocketUrl(location.origin)), tokens,
211
+ clock: browserClock(), actionId: randomActionId, random: Math.random,
212
+ });
213
+ ```
214
+
215
+ `@joystyk/session/browser/rooms` is its own entry, so a page that never opens a room never
216
+ loads the protocol's schemas. It also has `fetchRoomInfo` (`GET /api/rooms/:code`).
217
+
218
+ **Inputs** (`RemoteInput`): `command` (from the viewer's seat, checked with the game's command
219
+ schema before it is sent; a command that names another seat is refused with `wrong-seat`), `resign`, `control` (a room control: ready, settings,
220
+ fill-with-ai, remove-seat, start, rematch), `reconnect` (take the seat back after another tab
221
+ replaced this one), `leave` (give the seat up) and `resync`. The local runner's `pause`,
222
+ `resume`, `reveal` and `undo` mean nothing in a room and are ignored.
223
+
224
+ **Snapshots** (`RemoteSnapshot`) are the contract's `EngineSnapshot` with `view` null in a
225
+ lobby, plus `room`: the code, phase, host, public seats, settings, game pin, who is
226
+ connected, the spectator count, whether the room is frozen, a match counter that rises at
227
+ every start and rematch, and when the clocks were read. They follow the same six rules as the
228
+ local runner's.
229
+
230
+ - **The envelope.** Every message is decoded with the protocol's Zod schemas, then the view
231
+ and each event with the game's own schemas. Anything that fails is reported and dropped.
232
+ - **`meta`.** `connection` is `connecting`, `online`, `reconnecting` or `closed`; `seat` is
233
+ null for a spectator and follows the renumbering at `start`; `clocks` come from the room's
234
+ `presence`; `safePoint` is true outside a running match; `notice` carries rejections
235
+ (`game:NotYourTurn`), connection problems and the server's `name-replaced`.
236
+ - **Beats.** An update's beats are published with that update only; snapshots and presence
237
+ messages publish none, so a game plays every beat back exactly once.
238
+ - **Revisions.** Each action carries a fresh action ID and the revision the player saw. An
239
+ update whose `from` isn't the client's revision asks for a `resync`; an older snapshot of
240
+ the same epoch is ignored, and any snapshot of a new epoch (a restored backup) wins.
241
+ - **Reconnecting.** A dropped socket reconnects after `min(10 s, 500 ms · 2ⁿ)` plus up to
242
+ 250 ms of jitter (Greed's backoff), or after the server's `retryAfterMs` when it restarts,
243
+ and rejoins with the stored token. Actions without a receipt are resent with the same ID,
244
+ so the receipt answers them; actions while offline are refused with an `offline` notice.
245
+ A newer tab (4001), leaving (4002) and a closed room (4004, which also forgets the token)
246
+ stop it for good.
247
+ - **Versions.** A room on another rules version closes the session with an `update` notice.
248
+
249
+ ## Replays
250
+
251
+ `replayEngine` and `replaySimulation` rebuild a recorded game from its seed and inputs. The
252
+ runners use the same code for undo and restore; the `testing` package's conformance tests
253
+ will use it for replay equality.
254
+
255
+ ## Tests
256
+
257
+ - `local.test.ts` and `fixed-step.test.ts` run in Node with fake ports
258
+ (`fakes.test-util.ts`) and two fixture games (`fixtures.test-util.ts`): a Nim variant with
259
+ hidden numbers, a barrier, a dice job, a randomized and a throwing command, and a drifting
260
+ point simulation.
261
+ - `rngs.test.ts` checks how the AI stream forks and moves on.
262
+ - `remote.test.ts` drives the remote client with a fake socket: joining with a token,
263
+ snapshots and updates, action IDs and revisions, receipts and notices, backoff and close
264
+ codes, spectators and disposal. `apps/rooms/src/remote-session.test.ts` runs it against the
265
+ real room server and engines (two players and a spectator through a restart; Greed's throw).
266
+ - `browser/browser.browser.test.ts` runs the adapters, and both runners on them, in
267
+ Chromium.
@@ -0,0 +1,3 @@
1
+ import { type AssistCounts, type Validator } from '@joystyk/contracts';
2
+ /** Standard Schema boundary for the optional, extensible saved count map. */
3
+ export declare const assistCountsSchema: Validator<AssistCounts>;
@@ -0,0 +1,20 @@
1
+ import { isRecord } from "./values.js";
2
+ import { ASSIST_KINDS } from "@joystyk/contracts";
3
+ //#region src/assistance.ts
4
+ /** Standard Schema boundary for the optional, extensible saved count map. */
5
+ var assistCountsSchema = { "~standard": {
6
+ version: 1,
7
+ vendor: "joystyk",
8
+ validate: (raw) => {
9
+ if (!isRecord(raw)) return { issues: [{ message: "Assistance counts must be an object." }] };
10
+ for (const [kind, count] of Object.entries(raw)) if (!ASSIST_KINDS.includes(kind) || !Number.isSafeInteger(count) || count < 0) return { issues: [{
11
+ message: "Use a known assistance kind and a nonnegative safe integer.",
12
+ path: [kind]
13
+ }] };
14
+ return { value: { ...raw } };
15
+ }
16
+ } };
17
+ //#endregion
18
+ export { assistCountsSchema };
19
+
20
+ //# sourceMappingURL=assistance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assistance.js","names":[],"sources":["../src/assistance.ts"],"sourcesContent":["import { ASSIST_KINDS, type AssistCounts, type Validator } from '@joystyk/contracts';\nimport { isRecord } from './values.ts';\n/** Standard Schema boundary for the optional, extensible saved count map. */\nexport const assistCountsSchema: Validator<AssistCounts> = {\n '~standard': {\n version: 1,\n vendor: 'joystyk',\n validate: (raw) => {\n if (!isRecord(raw)) return { issues: [{ message: 'Assistance counts must be an object.' }] };\n for (const [kind, count] of Object.entries(raw))\n if (\n !(ASSIST_KINDS as readonly string[]).includes(kind) ||\n !Number.isSafeInteger(count) ||\n (count as number) < 0\n )\n return { issues: [{ message: 'Use a known assistance kind and a nonnegative safe integer.', path: [kind] }] };\n return { value: { ...raw } as AssistCounts };\n },\n },\n};\n"],"mappings":";;;;AAGA,IAAa,qBAA8C,EACzD,aAAa;CACX,SAAS;CACT,QAAQ;CACR,WAAW,QAAQ;EACjB,IAAI,CAAC,SAAS,GAAG,GAAG,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS,uCAAuC,CAAC,EAAE;EAC3F,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,GAAG,GAC5C,IACE,CAAE,aAAmC,SAAS,IAAI,KAClD,CAAC,OAAO,cAAc,KAAK,KAC1B,QAAmB,GAEpB,OAAO,EAAE,QAAQ,CAAC;GAAE,SAAS;GAA+D,MAAM,CAAC,IAAI;EAAE,CAAC,EAAE;EAChH,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,EAAkB;CAC7C;AACF,EACF"}
@@ -0,0 +1,19 @@
1
+ import type { SoundCue } from '@joystyk/contracts';
2
+ type Waveform = 'sine' | 'triangle' | 'square' | 'sawtooth';
3
+ export type SoundFamily = 'wood' | 'paper' | 'glass' | 'arcade' | 'terminal' | 'garden';
4
+ /** Deliberate palette per game; no samples, music, network downloads or third-party recordings. */
5
+ export declare const SOUND_PROFILES: Readonly<Record<string, SoundFamily>>;
6
+ /** Games which already select sound effects in their own controls and drivers. */
7
+ export declare const CUSTOM_AUDIO_GAMES: Set<string>;
8
+ export type Tone = {
9
+ readonly from: number;
10
+ readonly to: number;
11
+ readonly duration: number;
12
+ readonly wave: Waveform;
13
+ readonly delay: number;
14
+ readonly strength: number;
15
+ };
16
+ export declare const tonesFor: (family: SoundFamily, cue: SoundCue, variation?: number) => readonly Tone[];
17
+ /** Redacted, already-validated events only. This mapping never examines a hidden answer. */
18
+ export declare const eventCue: (gameId: string, type: string) => SoundCue | null;
19
+ export {};