@hadoku/game-ui 0.1.217 → 0.1.219

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.
@@ -26,9 +26,8 @@ export interface GameSetupProps {
26
26
  /** The caller's own member id (`view.you.id`), or `''` while `view` is null. */
27
27
  userId: string;
28
28
  /**
29
- * The caller's seat NUMBER at the table (`table.players[].seat`, 2-max, Magic's), or null
30
- * while unseated or for a game type with no 2-seat table at all. A non-Magic game type reads
31
- * its own seat list off `view`'s generic member data instead of this field.
29
+ * The caller's seat number where the host keeps a table of its own, or null. The platform
30
+ * screen keeps none and passes null: a game reads its seats off `view.seats`.
32
31
  */
33
32
  seat: number | null;
34
33
  isLeader: boolean;
@@ -52,14 +51,13 @@ export interface GameSetupProps {
52
51
  * What a game type renders inside the platform room screen: its setup before the start, its game
53
52
  * after.
54
53
  *
55
- * `setup` is what a player sees ABOVE the seats before the room is underway — Magic's format,
56
- * mode and deck chooser. A game type that offers no pre-start configuration (today, none) leaves
57
- * it absent, and the room screen draws nothing in its place.
54
+ * `setup` is what a player sees before the room is underway: the game's own options, seats and
55
+ * ready. A game type with nothing to set up leaves it absent, and the room screen draws nothing in
56
+ * its place.
58
57
  *
59
- * `game` is the game type's own placeholder for "the game" once the room is playing it — Magic's
60
- * board/pod card inside the room (the actual match is a screen of its own, reached by
61
- * navigation); Bomberman's `<BundleSlot>`. Required: every registered game type draws SOMETHING
62
- * once underway, even if it is nothing more than a status line.
58
+ * `game` is what the game type draws for "the game": an external game's `<BundleSlot>`, which
59
+ * plays the match in the room itself. Required: every registered game type draws SOMETHING, even
60
+ * if it is nothing more than a status line.
63
61
  */
64
62
  export interface GameRoomUi {
65
63
  setup?: (p: GameSetupProps) => ReactNode;
@@ -67,8 +65,7 @@ export interface GameRoomUi {
67
65
  }
68
66
  /**
69
67
  * Registers (or replaces) the UI a `gameType` renders inside the room screen. Called once, at
70
- * module scope, from the game type's own module — every registrant, Magic's `draft` and
71
- * `constructed-1v1` included.
68
+ * module scope, from the game type's own module.
72
69
  */
73
70
  export declare function registerGameRoomUi(gameType: string, ui: GameRoomUi): void;
74
71
  /** The UI registered for a `gameType`, or null for one nothing has registered. */
@@ -1,28 +1,24 @@
1
1
  /*
2
2
  * The seam between the platform room screen and a game type's own UI.
3
3
  *
4
- * The room screen owns join, password, leader, members, spectators, seats, ready and start —
5
- * every room, whatever it plays. What a game type draws INSIDE that room is registered here, by
6
- * its `gameType` string, so the screen never imports a game's own file to find out what to
7
- * render.
4
+ * The platform room screen (`screen/PlatformRoomScreen.tsx`) owns what every room has: the read of
5
+ * the room record and the join, the password gate, the title, Leave and the host's tools. What a
6
+ * game type draws INSIDE that room is registered here, by its `gameType` string, so the screen
7
+ * never imports a game's own file to find out what to render. The screen is the registry's reader;
8
+ * its registrants are the external games (`external-games.tsx`, one per game the site hosts) and any
9
+ * second game, each calling `registerGameRoomUi` from ITS OWN module, once, at import, and reading
10
+ * the room's injected clients from `game-clients.tsx` rather than closing over the screen's props.
8
11
  *
9
- * `view` is nullable because the room record and the room's table are two separate reads: a
10
- * table can answer before the room record does, or the room record can fail while the table
11
- * still holds a seat list. A game's `setup`/`game` must handle `view === null` exactly as the
12
- * room screen already does elsewhere (optional chaining, never a crash) rather than assume the
13
- * two reads land together.
12
+ * `view` is nullable: a room whose record could not be read still draws its game's parts once the
13
+ * screen has stopped waiting, so a game's `setup`/`game` handles `view === null` (optional
14
+ * chaining, never a crash) rather than assume the record is there.
14
15
  *
15
- * This file is `platform`: it imports no game's own code, Magic's included. A game registers
16
- * itself by calling `registerGameRoomUi` from ITS OWN module, once, at import — Magic's `draft`
17
- * and `constructed-1v1` do this from `screens/magic-room-ui.tsx`, the same way bomberman's own
18
- * module does, reading the room's injected clients from `rooms/game-clients.tsx` rather than
19
- * closing over `RoomTableScreen`'s props.
16
+ * This file is `platform`: it imports no game's own code.
20
17
  */
21
18
  const registry = new Map();
22
19
  /**
23
20
  * Registers (or replaces) the UI a `gameType` renders inside the room screen. Called once, at
24
- * module scope, from the game type's own module — every registrant, Magic's `draft` and
25
- * `constructed-1v1` included.
21
+ * module scope, from the game type's own module.
26
22
  */
27
23
  export function registerGameRoomUi(gameType, ui) {
28
24
  registry.set(gameType, ui);
@@ -0,0 +1,15 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type RoomViewBase } from '../game-setup.js';
3
+ import { type LeaveRoom } from './room-exit.js';
4
+ import type { RoomJoin } from './useRoomJoin.js';
5
+ export interface PlatformRoomScreenProps<R extends RoomViewBase> {
6
+ /** The host's read of the room. */
7
+ join: RoomJoin<R>;
8
+ /** What the host draws in the head row beside Leave: Close, Settings. */
9
+ headerTools?: ReactNode;
10
+ /** The game's `/leave` for this room; absent, the head row draws no Leave. */
11
+ leave?: LeaveRoom;
12
+ /** Told each time the game says a match is, or is no longer, live. */
13
+ onLive?: (live: boolean) => void;
14
+ }
15
+ export declare function PlatformRoomScreen<R extends RoomViewBase>({ join, headerTools, leave, onLive }: PlatformRoomScreenProps<R>): import("react").JSX.Element;
@@ -0,0 +1,39 @@
1
+ import { jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * The room screen for a game type the platform hosts: the shell every room has (`RoomShell`), drawn
4
+ * from the host's one read of the room (`useRoomJoin`), with the game type's own parts from the
5
+ * registry (`../game-setup.ts`) in its body.
6
+ *
7
+ * What it draws: the room's name, Leave (where the host has a way home), the host's tools, the
8
+ * password gate while the join is refused, the join's refusal in words, and the registered `setup`
9
+ * and `game` for the room's `gameType`. Seats, spectators and options are the game's own, drawn in
10
+ * its `setup`. The host calls `useRoomJoin` itself and passes the result, so it can decide which
11
+ * screen to draw from the same read.
12
+ *
13
+ * While the game says a match is live (`GameSetupProps.onLive`), the head row steps aside; the game
14
+ * offers the way out itself (`GameSetupProps.leave`).
15
+ */
16
+ import { useState } from 'react';
17
+ import { useChromeShell } from '@wolffm/ui-shell/chrome/shell';
18
+ import { gameRoomUiFor } from "../game-setup.js";
19
+ import { leaveRoomThen, useRoomHome } from "./room-exit.js";
20
+ import { RoomShell } from "./RoomShell.js";
21
+ export function PlatformRoomScreen({ join, headerTools, leave, onLive }) {
22
+ const shellRef = useChromeShell('fit');
23
+ const home = useRoomHome();
24
+ const [live, setLive] = useState(false);
25
+ const { view } = join;
26
+ const ui = view === null ? null : gameRoomUiFor(view.gameType);
27
+ const gameProps = {
28
+ view,
29
+ me: { userId: view?.you.id ?? '', seat: null, isLeader: view?.you.leader === true },
30
+ // The room record says nothing of a match: a game that plays one knows it itself, and says so through `onLive`.
31
+ underway: false,
32
+ onLive: (next) => {
33
+ setLive(next);
34
+ onLive?.(next);
35
+ },
36
+ ...(home === null ? {} : { leave: () => void leaveRoomThen(home) }),
37
+ };
38
+ return (_jsxs(RoomShell, { shellRef: shellRef, dataMembers: view?.members.length, roomTitle: view?.name, settled: join.settled, leave: leave, headerTools: headerTools, resolved: join.resolved, pending: !join.resolved && !join.settled, locked: join.locked, password: join.password, onPasswordChange: join.setPassword, onPasswordSubmit: join.submitPassword, roomMissingMessage: join.joinError, live: live, children: [ui?.setup?.(gameProps), ui?.game(gameProps)] }));
39
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/game-ui",
3
- "version": "0.1.217",
4
- "gitHead": "dab0c78b4ce593a14647007bd9d8a374952a0f4e",
3
+ "version": "0.1.219",
4
+ "gitHead": "14b716659caabca197ae7ab2d1c613ccb6e05397",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "description": "The browser parts any hosted game shares, above ui-shell: the room shell and session, seats and looks, the room route, the front page's generic pieces (gate, polls, gallery, patch notes), the bundle slot and relay channel a game's client mounts in, settings and trim screens, the HTTP and socket helpers, and the generic components (modal, popover, avatar, action button, radio cards). Knows no game; Magic's UI (games/magic/ui) plugs in, composed by the site (apps/ui). MIT; imports only react, react-dom, socket.io-client, @wolffm/* and the platform packages.",
@@ -53,8 +53,8 @@
53
53
  "react-dom": "^19.2.8"
54
54
  },
55
55
  "dependencies": {
56
- "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.221",
57
- "@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.221",
56
+ "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.223",
57
+ "@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.223",
58
58
  "@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.3",
59
59
  "@wolffm/rooms-client": "npm:@hadoku/rooms-client@^0.45.152",
60
60
  "@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.152",