@hadoku/game-ui 0.1.82 → 0.1.83
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.
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
3
|
-
* looking-for-game), then the source on GitHub.
|
|
2
|
+
* The page's outbound links: the Discord server (patch notes, scheduled tournaments,
|
|
3
|
+
* looking-for-game), then the source on GitHub. ONE list, drawn in two places: the top bar
|
|
4
|
+
* (`HeaderLinks`) and, on a page with no top bar, the chat toolbar (`./toolbarPage.tsx`).
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
* the theme picker. The operator asked for Discord between the theme and
|
|
7
|
-
* header's `links` slot (docs/requests/HADOKU_SITE_HEADER_LINKS.md,
|
|
8
|
-
* there when it ships. `.app-header__icon-btn` is the fleet's
|
|
6
|
+
* In the top bar they ride `AppHeader`'s `status` slot, which renders first in the actions row, so
|
|
7
|
+
* they sit just left of the theme picker. The operator asked for Discord between the theme and
|
|
8
|
+
* settings icons; that needs the header's `links` slot (docs/requests/HADOKU_SITE_HEADER_LINKS.md,
|
|
9
|
+
* with hadoku-task), and these move there when it ships. `.app-header__icon-btn` is the fleet's
|
|
10
|
+
* round button and is made for an <a>.
|
|
9
11
|
*
|
|
10
12
|
* The invite is permanent. ArchiveBot's original (`/setup cardtable`) stopped accepting joins once the
|
|
11
13
|
* server became a Community server (2026-11-05); this one is the operator's.
|
|
12
14
|
* Both glyphs are Simple Icons' marks (CC0-1.0).
|
|
13
15
|
*/
|
|
16
|
+
import type { ReactNode } from 'react';
|
|
14
17
|
export declare const DISCORD_INVITE_URL = "https://discord.gg/tfRddmWkDv";
|
|
15
18
|
export declare const GITHUB_REPO_URL = "https://github.com/WolffM/hadoku-cardtable";
|
|
19
|
+
/** A link out of the page: the shape watchparty's chat toolbar takes as one of a host's own buttons. */
|
|
20
|
+
export interface PageLink {
|
|
21
|
+
id: string;
|
|
22
|
+
label: string;
|
|
23
|
+
href: string;
|
|
24
|
+
icon: ReactNode;
|
|
25
|
+
}
|
|
26
|
+
export declare const PAGE_LINKS: readonly PageLink[];
|
|
16
27
|
export declare function HeaderLinks(): import("react").JSX.Element;
|
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment
|
|
2
|
-
/**
|
|
3
|
-
* The header's outbound links: the Discord server (patch notes, scheduled tournaments,
|
|
4
|
-
* looking-for-game), then the source on GitHub.
|
|
5
|
-
*
|
|
6
|
-
* Rides `AppHeader`'s `status` slot, which renders first in the actions row, so they sit just left of
|
|
7
|
-
* the theme picker. The operator asked for Discord between the theme and settings icons; that needs the
|
|
8
|
-
* header's `links` slot (docs/requests/HADOKU_SITE_HEADER_LINKS.md, with hadoku-task), and these move
|
|
9
|
-
* there when it ships. `.app-header__icon-btn` is the fleet's round button and is made for an <a>.
|
|
10
|
-
*
|
|
11
|
-
* The invite is permanent. ArchiveBot's original (`/setup cardtable`) stopped accepting joins once the
|
|
12
|
-
* server became a Community server (2026-11-05); this one is the operator's.
|
|
13
|
-
* Both glyphs are Simple Icons' marks (CC0-1.0).
|
|
14
|
-
*/
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
15
2
|
export const DISCORD_INVITE_URL = 'https://discord.gg/tfRddmWkDv';
|
|
16
3
|
export const GITHUB_REPO_URL = 'https://github.com/WolffM/hadoku-cardtable';
|
|
17
4
|
const DISCORD_PATH = 'M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z';
|
|
18
5
|
const GITHUB_PATH = 'M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12';
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
6
|
+
const glyph = (path) => (_jsx("svg", { viewBox: "0 0 24 24", width: "18", height: "18", fill: "currentColor", "aria-hidden": "true", children: _jsx("path", { d: path }) }));
|
|
7
|
+
export const PAGE_LINKS = [
|
|
8
|
+
{ id: 'discord', label: 'Discord', href: DISCORD_INVITE_URL, icon: glyph(DISCORD_PATH) },
|
|
9
|
+
{ id: 'github', label: 'GitHub', href: GITHUB_REPO_URL, icon: glyph(GITHUB_PATH) },
|
|
10
|
+
];
|
|
22
11
|
export function HeaderLinks() {
|
|
23
|
-
return (
|
|
12
|
+
return (_jsx(_Fragment, { children: PAGE_LINKS.map(({ id, label, href, icon }) => (_jsx("a", { className: "app-header__icon-btn", href: href, target: "_blank", rel: "noopener noreferrer", "aria-label": label, title: label, "data-testid": `header-${id}`, children: icon }, id))) }));
|
|
24
13
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { RoomChromeToolbar } from '@wolffm/watchparty-ui/room-chrome';
|
|
3
|
+
import { type Route } from '../screens/route.js';
|
|
4
|
+
/** Whether the page is drawn without its top bar. */
|
|
5
|
+
export declare function toolbarPageOn(held: number, noChat: boolean): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* The routes that are toolbar pages whatever their screen has loaded: the game, a table's
|
|
8
|
+
* full-screen step (the sideboard) and the deck builder. The operator, 2026-11-19: *"i wanted the
|
|
9
|
+
* top bar to be gone when in: draft, sideboarding, playing the game, deck construction. only when
|
|
10
|
+
* looking at the room or frontpage would i want the top bar to stay."* The draft is a room's state,
|
|
11
|
+
* not a route, and asks from its screen.
|
|
12
|
+
*/
|
|
13
|
+
export declare function toolbarRoute(route: Route): boolean;
|
|
14
|
+
/** This screen is a toolbar page for as long as it is drawn with `on`. */
|
|
15
|
+
export declare function useToolbarPage(on?: boolean): void;
|
|
16
|
+
/** `RoomShell`'s word on whether a chat can draw on this page at all. */
|
|
17
|
+
export declare function useChatless(noChat: boolean): void;
|
|
18
|
+
/** True while a drawn screen has opted in and the chat can carry the toolbar. */
|
|
19
|
+
export declare function useToolbarPageOn(): boolean;
|
|
20
|
+
/** The app's header: not drawn on a toolbar page. */
|
|
21
|
+
export declare function TopBar({ children }: {
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
}): ReactNode;
|
|
24
|
+
/** What the chat toolbar carries for the page: the top bar's own Home, settings and links. */
|
|
25
|
+
export declare const PAGE_TOOLBAR: RoomChromeToolbar;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* The page layout with no top bar: Home, the theme picker, the settings and the page's links are in
|
|
4
|
+
* the room chat's toolbar instead (watchparty's own, `RoomChrome`'s `toolbar`), and the screen takes
|
|
5
|
+
* the whole height.
|
|
6
|
+
*
|
|
7
|
+
* A screen opts in by calling `useToolbarPage()`, or its route does (`toolbarRoute`); nothing else
|
|
8
|
+
* about it changes. The page's two
|
|
9
|
+
* halves read the same answer: `TopBar` (around the app's header) draws nothing, and `RoomShell`
|
|
10
|
+
* hands the chrome `PAGE_TOOLBAR`. They are never both drawn — the toolbar's settings gear and the
|
|
11
|
+
* header's are the same fleet control, and a page must mount one.
|
|
12
|
+
*
|
|
13
|
+
* Where no chat can draw (no room, or a viewer the fleet could not name) the top bar stays: it is
|
|
14
|
+
* then the only way to those controls. With the chat hidden the chrome draws no toolbar either, only
|
|
15
|
+
* its own Show chat button, which brings both back.
|
|
16
|
+
*
|
|
17
|
+
* The opt-in is taken in a layout effect and read through an external store, so the page is redrawn
|
|
18
|
+
* before the browser paints: a screen's first frame already has no top bar.
|
|
19
|
+
*/
|
|
20
|
+
import { useLayoutEffect, useSyncExternalStore } from 'react';
|
|
21
|
+
import { navigate } from "../screens/route.js";
|
|
22
|
+
import { CardtableSettings } from "../settings/Settings.js";
|
|
23
|
+
import { PAGE_LINKS } from "./HeaderLinks.js";
|
|
24
|
+
let holders = 0;
|
|
25
|
+
let chatless = false;
|
|
26
|
+
const watchers = new Set();
|
|
27
|
+
function changed() {
|
|
28
|
+
for (const watcher of watchers)
|
|
29
|
+
watcher();
|
|
30
|
+
}
|
|
31
|
+
function watch(watcher) {
|
|
32
|
+
watchers.add(watcher);
|
|
33
|
+
return () => {
|
|
34
|
+
watchers.delete(watcher);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** Whether the page is drawn without its top bar. */
|
|
38
|
+
export function toolbarPageOn(held, noChat) {
|
|
39
|
+
return held > 0 && !noChat;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The routes that are toolbar pages whatever their screen has loaded: the game, a table's
|
|
43
|
+
* full-screen step (the sideboard) and the deck builder. The operator, 2026-11-19: *"i wanted the
|
|
44
|
+
* top bar to be gone when in: draft, sideboarding, playing the game, deck construction. only when
|
|
45
|
+
* looking at the room or frontpage would i want the top bar to stay."* The draft is a room's state,
|
|
46
|
+
* not a route, and asks from its screen.
|
|
47
|
+
*/
|
|
48
|
+
export function toolbarRoute(route) {
|
|
49
|
+
return route.kind === 'match' || route.kind === 'deck' || (route.kind === 'room' && route.step !== undefined);
|
|
50
|
+
}
|
|
51
|
+
/** This screen is a toolbar page for as long as it is drawn with `on`. */
|
|
52
|
+
export function useToolbarPage(on = true) {
|
|
53
|
+
useLayoutEffect(() => {
|
|
54
|
+
if (!on)
|
|
55
|
+
return undefined;
|
|
56
|
+
holders += 1;
|
|
57
|
+
changed();
|
|
58
|
+
return () => {
|
|
59
|
+
holders -= 1;
|
|
60
|
+
changed();
|
|
61
|
+
};
|
|
62
|
+
}, [on]);
|
|
63
|
+
}
|
|
64
|
+
/** `RoomShell`'s word on whether a chat can draw on this page at all. */
|
|
65
|
+
export function useChatless(noChat) {
|
|
66
|
+
useLayoutEffect(() => {
|
|
67
|
+
if (chatless === noChat)
|
|
68
|
+
return;
|
|
69
|
+
chatless = noChat;
|
|
70
|
+
changed();
|
|
71
|
+
}, [noChat]);
|
|
72
|
+
}
|
|
73
|
+
/** True while a drawn screen has opted in and the chat can carry the toolbar. */
|
|
74
|
+
export function useToolbarPageOn() {
|
|
75
|
+
return useSyncExternalStore(watch, () => toolbarPageOn(holders, chatless));
|
|
76
|
+
}
|
|
77
|
+
/** The app's header: not drawn on a toolbar page. */
|
|
78
|
+
export function TopBar({ children }) {
|
|
79
|
+
return useToolbarPageOn() ? null : children;
|
|
80
|
+
}
|
|
81
|
+
/** What the chat toolbar carries for the page: the top bar's own Home, settings and links. */
|
|
82
|
+
export const PAGE_TOOLBAR = {
|
|
83
|
+
onHome: () => navigate({ kind: 'lobby' }),
|
|
84
|
+
settings: { section: _jsx(CardtableSettings, {}) },
|
|
85
|
+
extra: PAGE_LINKS,
|
|
86
|
+
};
|
package/dist/room/RoomShell.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
import type { RoomChrome as RoomChromeComponent } from '@wolffm/watchparty-ui/room-chrome';
|
|
2
|
+
import type { RoomChrome as RoomChromeComponent, RoomChromeToolbar } from '@wolffm/watchparty-ui/room-chrome';
|
|
3
3
|
import '@wolffm/watchparty-ui/room-chrome.css';
|
|
4
4
|
import { type Theme } from '@wolffm/themes';
|
|
5
5
|
type RoomChromeType = typeof RoomChromeComponent;
|
|
@@ -109,7 +109,7 @@ export declare function appOrigin(): string;
|
|
|
109
109
|
* before they have first mounted, they wait for it, showing `fallback`: their first frame is already
|
|
110
110
|
* inside. After that, they show bare while the chrome is not drawn.
|
|
111
111
|
*/
|
|
112
|
-
export declare function RoomShell({ roomId, collapsible, inert, fallback, requireIdentified, children, }: {
|
|
112
|
+
export declare function RoomShell({ roomId, collapsible, inert, fallback, requireIdentified, toolbar, pending, children, }: {
|
|
113
113
|
/** The room this viewer is in: the chat and roster the chrome joins, and where their avatar is asserted. */
|
|
114
114
|
roomId: string | null;
|
|
115
115
|
/** `false` keeps the chat open with no Hide chat button — the room's lobby,
|
|
@@ -125,6 +125,10 @@ export declare function RoomShell({ roomId, collapsible, inert, fallback, requir
|
|
|
125
125
|
* anonymous join away, and a chat column that can only fail reads as a broken room. Default off.
|
|
126
126
|
*/
|
|
127
127
|
requireIdentified?: boolean;
|
|
128
|
+
/** The chat's toolbar on a page with no top bar (`../chrome/toolbarPage.tsx`): drawn only while a screen has opted in. */
|
|
129
|
+
toolbar?: RoomChromeToolbar;
|
|
130
|
+
/** The page does not know its room yet: `roomId` is null for now, and says nothing about whether a chat will draw. */
|
|
131
|
+
pending?: boolean;
|
|
128
132
|
children: ReactNode;
|
|
129
133
|
}): import("react").JSX.Element;
|
|
130
134
|
export {};
|
package/dist/room/RoomShell.js
CHANGED
|
@@ -59,6 +59,7 @@ import { useRoomFrame } from '@wolffm/ui-shell/chrome/shell';
|
|
|
59
59
|
// of one origin is how the chrome and the faces come to disagree about it.
|
|
60
60
|
import { watchpartyOrigin } from "./avatar.js";
|
|
61
61
|
import { useWhoami } from "./whoami.js";
|
|
62
|
+
import { useChatless, useToolbarPageOn } from "../chrome/toolbarPage.js";
|
|
62
63
|
/*
|
|
63
64
|
* Their chrome, in its own chunk: only a room needs it, and a game's front door is lighter by the
|
|
64
65
|
* whole of it. Loaded as soon as a RoomShell first draws (one per page, from the app's root), so by
|
|
@@ -210,7 +211,7 @@ export function appOrigin() {
|
|
|
210
211
|
* before they have first mounted, they wait for it, showing `fallback`: their first frame is already
|
|
211
212
|
* inside. After that, they show bare while the chrome is not drawn.
|
|
212
213
|
*/
|
|
213
|
-
export function RoomShell({ roomId, collapsible = true, inert = false, fallback = null, requireIdentified = false, children, }) {
|
|
214
|
+
export function RoomShell({ roomId, collapsible = true, inert = false, fallback = null, requireIdentified = false, toolbar, pending = false, children, }) {
|
|
214
215
|
const who = useWhoami();
|
|
215
216
|
const RoomChrome = useRoomChrome();
|
|
216
217
|
// Always inside `AppChrome`'s `HadokuThemeRoot` — see chrome/AppChrome.tsx,
|
|
@@ -223,6 +224,9 @@ export function RoomShell({ roomId, collapsible = true, inert = false, fallback
|
|
|
223
224
|
const [host] = useState(createHost);
|
|
224
225
|
const mounted = useRef(false);
|
|
225
226
|
const unknown = who === null || (requireIdentified && who !== 'pending' && who.userId === ANON_USER_ID);
|
|
227
|
+
// No chat will draw here, so the page keeps its top bar whatever its screen asked for.
|
|
228
|
+
useChatless(!pending && (key === null || unknown));
|
|
229
|
+
const toolbarPage = useToolbarPageOn();
|
|
226
230
|
const waiting = key !== null && !unknown && (who === 'pending' || RoomChrome === null);
|
|
227
231
|
// Waiting before the first mount shows the fallback; after it, the content stays where it is.
|
|
228
232
|
const holding = waiting && !mounted.current;
|
|
@@ -248,7 +252,7 @@ export function RoomShell({ roomId, collapsible = true, inert = false, fallback
|
|
|
248
252
|
* `route.kind !== 'room'`), never the room lobby (Settled 10: "the room
|
|
249
253
|
* lobby is unchanged").
|
|
250
254
|
*/
|
|
251
|
-
_jsxs(_Fragment, { children: [_jsx("div", { className: "room-shell", "data-testid": "room-shell", "data-collapsible": collapsible ? '' : undefined, inert: inert || undefined, children: _jsxs(RoomChrome, { roomKey: key, serverOrigin: watchpartyOrigin(), roomOrigin: appOrigin(), userType: who.tier, userId: who.userId, theme: watchpartyTheme(theme), collapsible: collapsible, children: [_jsx(Slot, { host: host }), _jsx("span", { hidden: true, ref: roomFrameRef })] }) }, "chrome"), content] }));
|
|
255
|
+
_jsxs(_Fragment, { children: [_jsx("div", { className: "room-shell", "data-testid": "room-shell", "data-collapsible": collapsible ? '' : undefined, inert: inert || undefined, children: _jsxs(RoomChrome, { roomKey: key, serverOrigin: watchpartyOrigin(), roomOrigin: appOrigin(), userType: who.tier, userId: who.userId, theme: watchpartyTheme(theme), collapsible: collapsible, toolbar: toolbarPage ? toolbar : undefined, children: [_jsx(Slot, { host: host }), _jsx("span", { hidden: true, ref: roomFrameRef })] }) }, "chrome"), content] }));
|
|
252
256
|
}
|
|
253
257
|
/** The node {@link RoomShell}'s children are drawn into: it takes no box of its own, so they lay out as its parent's. */
|
|
254
258
|
function createHost() {
|
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.83",
|
|
4
|
+
"gitHead": "f1b45b326bfd4a1d2babd183ad145a927e09bb5b",
|
|
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.",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"react-dom": "^19.2.8"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.
|
|
53
|
-
"@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.
|
|
52
|
+
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.87",
|
|
53
|
+
"@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.87",
|
|
54
54
|
"@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.1.31",
|
|
55
55
|
"@wolffm/rooms-client": "npm:@hadoku/rooms-client@^0.45.125",
|
|
56
56
|
"@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.125",
|