@hadoku/game-ui 0.1.250 → 0.1.251
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/components/RoomSettings.css +1 -13
- package/dist/components/RoomSettings.d.ts +2 -3
- package/dist/components/RoomSettings.js +2 -10
- package/dist/rooms/game-setup.d.ts +3 -1
- package/dist/rooms/game-setup.js +13 -6
- package/dist/rooms/hosted-games.d.ts +6 -0
- package/dist/rooms/hosted-games.js +35 -0
- package/package.json +4 -4
- package/dist/rooms/external-games-config.d.ts +0 -54
- package/dist/rooms/external-games-config.js +0 -27
|
@@ -67,23 +67,11 @@
|
|
|
67
67
|
border-color: var(--color-primary);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
.room-settings__toggle:disabled
|
|
71
|
-
.room-settings__number:disabled {
|
|
70
|
+
.room-settings__toggle:disabled {
|
|
72
71
|
cursor: default;
|
|
73
72
|
opacity: 0.6;
|
|
74
73
|
}
|
|
75
74
|
|
|
76
|
-
.room-settings__number {
|
|
77
|
-
width: 5rem;
|
|
78
|
-
padding: 0.3rem 0.5rem;
|
|
79
|
-
background: var(--color-bg-alt);
|
|
80
|
-
color: var(--color-text);
|
|
81
|
-
border: 1px solid var(--color-border-light);
|
|
82
|
-
border-radius: var(--hdk-radius);
|
|
83
|
-
font: inherit;
|
|
84
|
-
font-size: 12px;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
75
|
/* A choice whose words are longer than the panel is wide (Clock start's) wraps its words, not off the panel's edge. */
|
|
88
76
|
.room-settings__list .radio-cards .radio-cards__card {
|
|
89
77
|
white-space: normal;
|
|
@@ -33,9 +33,8 @@ export declare function SettingToggle({ on, onPress, disabled, testId, className
|
|
|
33
33
|
};
|
|
34
34
|
}): import("react").JSX.Element;
|
|
35
35
|
/**
|
|
36
|
-
* A declared field's control: a toggle, a row of cards for a choice
|
|
37
|
-
*
|
|
38
|
-
* toggle's classes.
|
|
36
|
+
* A declared field's control: a toggle, or a row of cards for a choice. Null for a `custom` field,
|
|
37
|
+
* which its game draws itself. `toggleClassName` adds to a toggle's classes.
|
|
39
38
|
*/
|
|
40
39
|
export declare function SettingControl({ field, name, value, disabled, onChange, testId, toggleClassName, }: {
|
|
41
40
|
field: SettingField;
|
|
@@ -24,9 +24,8 @@ export function SettingToggle({ on, onPress, disabled, testId, className, action
|
|
|
24
24
|
return (_jsx(ActionButton, { action: on ? (actions?.off ?? `${testId}-off`) : (actions?.on ?? `${testId}-on`), className: ['room-settings__toggle room-settings__switch', className].filter(Boolean).join(' '), "aria-pressed": on, "data-testid": testId, disabled: disabled, onPress: onPress, children: on ? 'On' : 'Off' }));
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* A declared field's control: a toggle, a row of cards for a choice
|
|
28
|
-
*
|
|
29
|
-
* toggle's classes.
|
|
27
|
+
* A declared field's control: a toggle, or a row of cards for a choice. Null for a `custom` field,
|
|
28
|
+
* which its game draws itself. `toggleClassName` adds to a toggle's classes.
|
|
30
29
|
*/
|
|
31
30
|
export function SettingControl({ field, name, value, disabled, onChange, testId, toggleClassName, }) {
|
|
32
31
|
if (field.kind === 'toggle') {
|
|
@@ -36,13 +35,6 @@ export function SettingControl({ field, name, value, disabled, onChange, testId,
|
|
|
36
35
|
if (field.kind === 'choice') {
|
|
37
36
|
return (_jsx(RadioCards, { name: name, label: field.label, options: field.choices, value: typeof value === 'string' ? value : null, disabled: disabled, onChange: onChange, testId: testId, className: "room-settings__switch" }));
|
|
38
37
|
}
|
|
39
|
-
if (field.kind === 'number') {
|
|
40
|
-
return (_jsx("input", { type: "number", className: "room-settings__number room-settings__switch", "aria-label": field.label, "data-testid": testId, min: field.min, max: field.max, step: field.step, value: typeof value === 'number' ? value : field.default, disabled: disabled, onChange: (event) => {
|
|
41
|
-
const next = event.currentTarget.valueAsNumber;
|
|
42
|
-
if (Number.isFinite(next) && next >= field.min && next <= field.max)
|
|
43
|
-
onChange(next);
|
|
44
|
-
} }));
|
|
45
|
-
}
|
|
46
38
|
return null;
|
|
47
39
|
}
|
|
48
40
|
/** A key as a test id: `pickTimer` → `pick-timer`. */
|
|
@@ -68,5 +68,7 @@ export interface GameRoomUi {
|
|
|
68
68
|
* module scope, from the game type's own module.
|
|
69
69
|
*/
|
|
70
70
|
export declare function registerGameRoomUi(gameType: string, ui: GameRoomUi): void;
|
|
71
|
-
/**
|
|
71
|
+
/** Registers (or replaces) the UI for every room type nothing registered by name. Called once, at module scope. */
|
|
72
|
+
export declare function registerHostedGameRoomUi(ui: GameRoomUi): void;
|
|
73
|
+
/** The UI registered for a `gameType`, else the hosted games' UI, else null. */
|
|
72
74
|
export declare function gameRoomUiFor(gameType: string): GameRoomUi | null;
|
package/dist/rooms/game-setup.js
CHANGED
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
* The platform room screen (`screen/PlatformRoomScreen.tsx`) owns what every room has: the read of
|
|
5
5
|
* the room record and the join, the password gate, the title, Leave and the host's tools. What a
|
|
6
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
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* the room's injected clients from `game-clients.tsx`
|
|
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 any second game, calling `registerGameRoomUi` from ITS OWN module, once, at
|
|
9
|
+
* import, and the hosted games (`external-games.tsx`), one UI for every type nothing registered by
|
|
10
|
+
* name (`registerHostedGameRoomUi`). Each reads the room's injected clients from `game-clients.tsx`
|
|
11
|
+
* rather than closing over the screen's props.
|
|
11
12
|
*
|
|
12
13
|
* `view` is nullable: a room whose record could not be read still draws its game's parts once the
|
|
13
14
|
* screen has stopped waiting, so a game's `setup`/`game` handles `view === null` (optional
|
|
@@ -23,7 +24,13 @@ const registry = new Map();
|
|
|
23
24
|
export function registerGameRoomUi(gameType, ui) {
|
|
24
25
|
registry.set(gameType, ui);
|
|
25
26
|
}
|
|
26
|
-
/**
|
|
27
|
+
/** What draws a room of any type nothing registered: a game the site hosts from its list. */
|
|
28
|
+
let hosted = null;
|
|
29
|
+
/** Registers (or replaces) the UI for every room type nothing registered by name. Called once, at module scope. */
|
|
30
|
+
export function registerHostedGameRoomUi(ui) {
|
|
31
|
+
hosted = ui;
|
|
32
|
+
}
|
|
33
|
+
/** The UI registered for a `gameType`, else the hosted games' UI, else null. */
|
|
27
34
|
export function gameRoomUiFor(gameType) {
|
|
28
|
-
return registry.get(gameType) ??
|
|
35
|
+
return registry.get(gameType) ?? hosted;
|
|
29
36
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type HostedGameEntry } from '@wolffm/platform-wire/external-game-spec';
|
|
2
|
+
import { type Fetch } from '../http.js';
|
|
3
|
+
/** The hosted games this caller may play, or none when the list cannot be read. */
|
|
4
|
+
export declare function loadHostedGames(fetchImpl?: Fetch, base?: string): Promise<readonly HostedGameEntry[]>;
|
|
5
|
+
/** `gameType`'s entry, once a read has answered it; undefined before, or for a game not listed. */
|
|
6
|
+
export declare function hostedGame(gameType: string): HostedGameEntry | undefined;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The games this site hosts besides its own, as its server lists them (`GET /api/external-games`):
|
|
3
|
+
* each one's name, bundle and how it plays. The list is the server's, which reads it from the
|
|
4
|
+
* site's own data and offers each caller only what their tier may play, so a browser never carries
|
|
5
|
+
* a copy of it.
|
|
6
|
+
*
|
|
7
|
+
* Read once per page (`readOnce`) and shared by every reader: the room screen's hosted slot, the
|
|
8
|
+
* create form's radio, the room cards' names. A list that cannot be read is an empty one, with a
|
|
9
|
+
* warning, and is read again by the next caller.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import { HostedGameEntrySchema } from '@wolffm/platform-wire/external-game-spec';
|
|
13
|
+
import { apiBase, pageFetch, readJson, readOnce } from "../http.js";
|
|
14
|
+
const ListSchema = z.object({ games: z.array(HostedGameEntrySchema) });
|
|
15
|
+
const WORDING = { failed: 'Could not load the games', miss: 'Could not load the games: the server sent something that is not a list of games.' };
|
|
16
|
+
/** Every entry any read has answered, by id: what `hostedGame` reads. */
|
|
17
|
+
const known = new Map();
|
|
18
|
+
/** The hosted games this caller may play, or none when the list cannot be read. */
|
|
19
|
+
export async function loadHostedGames(fetchImpl = pageFetch, base = apiBase()) {
|
|
20
|
+
const url = `${base}external-games`;
|
|
21
|
+
try {
|
|
22
|
+
const { games } = await readOnce(fetchImpl, url, () => readJson(url, ListSchema, WORDING, fetchImpl));
|
|
23
|
+
for (const game of games)
|
|
24
|
+
known.set(game.id, game);
|
|
25
|
+
return games;
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
console.warn('[rooms] external games not loaded:', err instanceof Error ? err.message : err);
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** `gameType`'s entry, once a read has answered it; undefined before, or for a game not listed. */
|
|
33
|
+
export function hostedGame(gameType) {
|
|
34
|
+
return known.get(gameType);
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hadoku/game-ui",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "0.1.251",
|
|
4
|
+
"gitHead": "bd56441796a344d86f4ec3864896652db6ef01b5",
|
|
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.
|
|
57
|
-
"@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.
|
|
56
|
+
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.255",
|
|
57
|
+
"@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.255",
|
|
58
58
|
"@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.4",
|
|
59
59
|
"@wolffm/rooms-client": "npm:@hadoku/rooms-client@^0.45.158",
|
|
60
60
|
"@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.158",
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The ONE config for every external game cardtable may host as a room type: the HOST's half of
|
|
3
|
-
* each, pure data. "Deleting that one entry removes bomberman from cardtable" (wave 119's settled
|
|
4
|
-
* rule): an entry names the game's id, whether it runs on cardtable's relay, where its same-origin
|
|
5
|
-
* embed bundle is, and who may play it. Nothing here is the game's to decide: its name, seat range
|
|
6
|
-
* and seat hold are in the `manifest.json` it publishes beside its embed entry
|
|
7
|
-
* (`@hadoku/platform-wire/external-game-manifest`, `docs/GAME_AUTHORS.md`), which the server reads.
|
|
8
|
-
*
|
|
9
|
-
* Read by both sides, which never import each other:
|
|
10
|
-
* - `apps/server/src/plugins/external-games.ts` (the site) reads each entry's manifest, builds the
|
|
11
|
-
* pair into a `GameTypeSpec` (`@hadoku/platform-wire`'s `externalGameSpec`) and registers it, gated on
|
|
12
|
-
* `CARDTABLE_EXPERIMENTAL_GAMES=1`, and answers `GET /api/external-games` with the labels.
|
|
13
|
-
* - `./external-games.tsx` (platform) registers each entry's room UI, a `BundleSlot` (on the relay
|
|
14
|
-
* for a `runtime: 'relay'` entry), unconditionally: a room already made keeps rendering whatever today's deployment flag says.
|
|
15
|
-
*/
|
|
16
|
-
import type { ExternalGameManifestInput } from '@wolffm/platform-wire/external-game-manifest';
|
|
17
|
-
import type { RoomFloorTier } from '@wolffm/platform-wire/tiers';
|
|
18
|
-
export interface ExternalGameConfig {
|
|
19
|
-
/** The room's wire `gameType`. */
|
|
20
|
-
id: string;
|
|
21
|
-
/**
|
|
22
|
-
* `'relay'`: this game type's match runs on cardtable's relay (`RelaySession`): the host has no
|
|
23
|
-
* engine of its own for it, only seats, watchers and a channel each seat's bundle speaks over.
|
|
24
|
-
* Absent: the game runs its own match on its own server, and the host only gives its bundle the
|
|
25
|
-
* room (`ctx.roomKey`, who is looking, the room's seats) — no relay match is opened behind the
|
|
26
|
-
* room and the bundle gets no `ctx.channel`.
|
|
27
|
-
*/
|
|
28
|
-
runtime?: 'relay';
|
|
29
|
-
/** The same-origin path the client's `BundleSlot` loads this game's bundle from; its `manifest.json` is beside it. */
|
|
30
|
-
embedSrc: string;
|
|
31
|
-
/**
|
|
32
|
-
* Every room of this game is friends-only (`GameTypeSpec.minTier`): the server hides and refuses
|
|
33
|
-
* it below friend tier, as the edge names it, and lists it only to a friend or above.
|
|
34
|
-
*/
|
|
35
|
-
minTier?: RoomFloorTier;
|
|
36
|
-
/**
|
|
37
|
-
* An entry that proves the GENERIC mechanism rather than any one real game (wave 120 §F:
|
|
38
|
-
* "deleting the `bomberman` entry deletes nothing else" — `e2e/external-game-room.spec.ts` rides
|
|
39
|
-
* on this one, never on `bomberman` by name). `apps/server/src/plugins/external-games.ts`'s
|
|
40
|
-
* `setup()` filters an `e2eOnly` entry out of its registration loop unless
|
|
41
|
-
* `CARDTABLE_E2E_TOY_GAMES=1` — a SECOND, dedicated gate on top of the shared
|
|
42
|
-
* `CARDTABLE_EXPERIMENTAL_GAMES` every entry already has, so this one stays unregistered even
|
|
43
|
-
* where a real external game is turned on. The e2e spec's own `startPlayStack` sets both.
|
|
44
|
-
*/
|
|
45
|
-
e2eOnly?: boolean;
|
|
46
|
-
/** An `e2eOnly` fixture's manifest, since no publisher serves one for it. A real game's is always its own file. */
|
|
47
|
-
manifest?: ExternalGameManifestInput;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* One entry per external game cardtable may host, plus one e2e-only fixture entry. Bomberman's own
|
|
51
|
-
* repo serves `/bomberman/embed/bomberman-embed.js` same-origin, the same path watchparty loads it
|
|
52
|
-
* from; its bundle binds a room on bomberman's own server from `ctx.roomKey`, so it takes no relay.
|
|
53
|
-
*/
|
|
54
|
-
export declare const EXTERNAL_GAMES: readonly ExternalGameConfig[];
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* One entry per external game cardtable may host, plus one e2e-only fixture entry. Bomberman's own
|
|
3
|
-
* repo serves `/bomberman/embed/bomberman-embed.js` same-origin, the same path watchparty loads it
|
|
4
|
-
* from; its bundle binds a room on bomberman's own server from `ctx.roomKey`, so it takes no relay.
|
|
5
|
-
*/
|
|
6
|
-
export const EXTERNAL_GAMES = [
|
|
7
|
-
{
|
|
8
|
-
id: 'bomberman',
|
|
9
|
-
embedSrc: '/bomberman/embed/bomberman-embed.js',
|
|
10
|
-
},
|
|
11
|
-
// An outside author's game (Cozmiverse/crossover-cards), served friends-only from
|
|
12
|
-
// `/games/crossover-cards/` by hadoku_site's game-bundles.json row. Its rooms are friends-only
|
|
13
|
-
// too, whatever the app's floor: it carries other publishers' card data.
|
|
14
|
-
{
|
|
15
|
-
id: 'crossover-cards',
|
|
16
|
-
runtime: 'relay',
|
|
17
|
-
embedSrc: '/games/crossover-cards/embed.js',
|
|
18
|
-
minTier: 'friend',
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
id: 'e2e-toy-relay',
|
|
22
|
-
runtime: 'relay',
|
|
23
|
-
embedSrc: '/e2e/toy-relay-embed.js',
|
|
24
|
-
e2eOnly: true,
|
|
25
|
-
manifest: { label: 'Toy Relay Game', seats: { min: 2, max: 4 }, seatRejoinGraceMs: 120_000 },
|
|
26
|
-
},
|
|
27
|
-
];
|