feat: client shell, sign-in and protocol client (#67)

New `client/` package (Vite + TypeScript + PixiJS v8, plain DOM overlay):
the pure reducer seam (no Pixi import), an append-only slice registry
build-time glob, the `proto` 2 WS client with envelope/ack/closing mapping,
the sign-in door (`POST /join`, one "Key not recognised." for wrong and
unknown), the DOM shell/HUD and a minimal Pixi stage created only after a
live `hello`. `hello` resets every slice so a reconnect cannot show stale
state; `proto-mismatch` shows reload; `revoked` returns to the sign-in page
and stops.

The browser e2e moves into the client package (`client/e2e/`, owning
playwright-core) and runs the real Vite build through the TLS/HTTP2 test
nginx: join -> canvas -> hello/roster for GM and player, no data before
join, identical wrong/unknown key refusal, proto mismatch, revoked.
`devbox run client-test` adds the Vitest seam; `devbox run e2e` builds the
client first. The #66 stub dist stays local to `tools/vhost.test.mjs`, so
`devbox run test` still needs no npm install.

Refs #67
This commit is contained in:
2026-11-20 23:57:16 +01:00
parent 97f618c5ad
commit 3c0258ea31
37 changed files with 3439 additions and 178 deletions
+25
View File
@@ -0,0 +1,25 @@
// Roster slice (DESIGN 6.1 `roster`). Append-only registration: adding this file was enough; the
// reducer's glob picked it up and `hello` reset it with every other slice.
import type { ReducerEvent, RootState, Slice } from '../reducer.ts'
import type { RosterEntry } from '../protocol.ts'
export interface RosterState {
/** Always the full list the server sent; the client never merges (6.1). */
players: RosterEntry[]
}
function rosterList(value: unknown): RosterEntry[] | null {
if (!Array.isArray(value)) return null
return value as RosterEntry[]
}
export const slice: Slice<RosterState> = {
name: 'roster',
init: () => ({ players: [] }),
reduce(state: RosterState, event: ReducerEvent, _root: RootState): void {
if (event.type !== 'frame' || event.frame.t !== 'roster') return
const players = rosterList(event.frame['players'])
if (players) state.players = players
},
}