@hadoku/game-ui 0.1.162 → 0.1.163

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.
@@ -21,5 +21,3 @@ export declare function GameAppShell(props: GameAppShellProps): import("react").
21
21
  * not assign: every gate that matters is enforced server-side off the edge-stamped tier.
22
22
  */
23
23
  export declare function GameHeader({ children, appTabs, ...props }: Omit<AppHeaderProps, 'settingsProps'>): import("react").JSX.Element;
24
- /** The `appTabs` id `GameHeader` adds the chat sound switch to. */
25
- export declare const SOUND_TAB_ID = "sound";
@@ -23,9 +23,10 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
23
23
  * This is the standalone page only. Embedded in a host's page the room and the theme are the host's,
24
24
  * and a game draws none of this (`@hadoku/ui-shell/embed`'s `mountEmbed`).
25
25
  */
26
- import { lazy, Suspense, useRef } from 'react';
26
+ import { useRef } from 'react';
27
27
  import { AppHeader, LoadingSkeleton } from '@wolffm/task-ui-components';
28
28
  import { HadokuThemeRoot, useHadokuTheme, usePlatform } from '@wolffm/themes';
29
+ import { withChatSound } from "../settings/chatSound.js";
29
30
  import { useResolvedWhoami, useWhoami, WhoProvider } from "../room/whoami.js";
30
31
  export function GameAppShell(props) {
31
32
  const containerRef = useRef(null);
@@ -47,20 +48,8 @@ function ShellInner({ containerRef, className, children }) {
47
48
  export function GameHeader({ children, appTabs, ...props }) {
48
49
  const who = useWhoami();
49
50
  const viewer = who === 'pending' ? null : who;
50
- // The room chat's sound switch goes beside the game's own sound settings when it has a Sound tab,
51
- // else in the App tab: never a tab of its own for one row.
52
- const soundTab = appTabs?.some((t) => t.id === SOUND_TAB_ID) ?? false;
53
- return (_jsx(AppHeader, { ...props, settingsProps: viewer === null ? undefined : { userType: viewer.edgeTier, name: viewer.name }, appTabs: soundTab ? appTabs.map((t) => (t.id === SOUND_TAB_ID ? { ...t, render: () => _jsxs(_Fragment, { children: [t.render(), chatSound] }) } : t)) : appTabs,
51
+ const settings = withChatSound(appTabs);
52
+ return (_jsx(AppHeader, { ...props, settingsProps: viewer === null ? undefined : { userType: viewer.edgeTier, name: viewer.name }, appTabs: settings.appTabs,
54
53
  // Passed only when it holds something: any `children` at all draws an App tab.
55
- children: soundTab ? children : _jsxs(_Fragment, { children: [children, chatSound] }) }));
54
+ children: settings.app === null ? children : _jsxs(_Fragment, { children: [children, settings.app] }) }));
56
55
  }
57
- /** The `appTabs` id `GameHeader` adds the chat sound switch to. */
58
- export const SOUND_TAB_ID = 'sound';
59
- /**
60
- * The room chat's "Chat sound" on/off (watchparty's chime after a quiet minute). It is watchparty's,
61
- * from the same room-chrome module `RoomShell` loads, so it writes the store that chrome's chime
62
- * reads. Lazy: the popout renders a tab only while it is open, so the chunk is fetched then (and
63
- * usually already is, for the room).
64
- */
65
- const ChatSoundSetting = lazy(() => import('@wolffm/watchparty-ui/room-chrome').then((m) => ({ default: m.ChatSoundSetting })));
66
- const chatSound = (_jsx(Suspense, { fallback: null, children: _jsx(ChatSoundSetting, {}) }));
@@ -0,0 +1,3 @@
1
+ import type { RoomChromeToolbar } from '@wolffm/watchparty-ui/room-chrome';
2
+ /** What the chat toolbar carries for the page: the top bar's own Home, settings and links; the settings are the top bar's tabs, so both popouts are one list. */
3
+ export declare const PAGE_TOOLBAR: RoomChromeToolbar;
@@ -0,0 +1,12 @@
1
+ import { navigate } from "../screens/route.js";
2
+ import { leaveRoomThen } from "../rooms/screen/room-exit.js";
3
+ import { withChatSound } from "../settings/chatSound.js";
4
+ import { CARDTABLE_SETTINGS_TABS } from "../settings/Settings.js";
5
+ import { PAGE_LINKS } from "./HeaderLinks.js";
6
+ /** What the chat toolbar carries for the page: the top bar's own Home, settings and links; the settings are the top bar's tabs, so both popouts are one list. */
7
+ export const PAGE_TOOLBAR = {
8
+ // Leaves the room drawn, if any, as the top bar's own Home does (`rooms/screen/room-exit.tsx`).
9
+ onHome: () => void leaveRoomThen(() => navigate({ kind: 'lobby' })),
10
+ settings: { appTabs: withChatSound(CARDTABLE_SETTINGS_TABS).appTabs },
11
+ extra: PAGE_LINKS,
12
+ };
@@ -1,6 +1,5 @@
1
1
  import { type ReactNode } from 'react';
2
- import type { RoomChromeToolbar } from '@wolffm/watchparty-ui/room-chrome';
3
- import { type Route } from '../screens/route.js';
2
+ import type { Route } from '../screens/route.js';
4
3
  /** Whether the page is drawn without its top bar. */
5
4
  export declare function toolbarPageOn(held: number, noChat: boolean): boolean;
6
5
  /**
@@ -21,5 +20,3 @@ export declare function useToolbarPageOn(): boolean;
21
20
  export declare function TopBar({ children }: {
22
21
  children: ReactNode;
23
22
  }): 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;
@@ -1,4 +1,3 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  /*
3
2
  * The page layout with no top bar: Home, the theme picker, the settings and the page's links are in
4
3
  * the room chat's toolbar instead (watchparty's own, `RoomChrome`'s `toolbar`), and the screen takes
@@ -7,7 +6,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
7
6
  * A screen opts in by calling `useToolbarPage()`, or its route does (`toolbarRoute`); nothing else
8
7
  * about it changes. The page's two
9
8
  * 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
9
+ * hands the chrome `PAGE_TOOLBAR` (`./pageToolbar.tsx`). They are never both drawn — the toolbar's settings gear and the
11
10
  * header's are the same fleet control, and a page must mount one.
12
11
  *
13
12
  * Where no chat can draw (no room, or a viewer the fleet could not name) the top bar stays: it is
@@ -18,10 +17,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
18
17
  * before the browser paints: a screen's first frame already has no top bar.
19
18
  */
20
19
  import { useLayoutEffect, useSyncExternalStore } from 'react';
21
- import { navigate } from "../screens/route.js";
22
- import { leaveRoomThen } from "../rooms/screen/room-exit.js";
23
- import { CardtableSettings } from "../settings/Settings.js";
24
- import { PAGE_LINKS } from "./HeaderLinks.js";
25
20
  let holders = 0;
26
21
  let chatless = false;
27
22
  const watchers = new Set();
@@ -79,10 +74,3 @@ export function useToolbarPageOn() {
79
74
  export function TopBar({ children }) {
80
75
  return useToolbarPageOn() ? null : children;
81
76
  }
82
- /** What the chat toolbar carries for the page: the top bar's own Home, settings and links. */
83
- export const PAGE_TOOLBAR = {
84
- // Leaves the room drawn, if any, as the top bar's own Home does (`rooms/screen/room-exit.tsx`).
85
- onHome: () => void leaveRoomThen(() => navigate({ kind: 'lobby' })),
86
- settings: { section: _jsx(CardtableSettings, {}) },
87
- extra: PAGE_LINKS,
88
- };
@@ -0,0 +1,13 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { AppSettingsTab } from '@wolffm/task-ui-components';
3
+ /** The `appTabs` id the chat sound switch goes in. */
4
+ export declare const SOUND_TAB_ID = "sound";
5
+ /**
6
+ * A game's settings tabs with the chat sound switch placed: beside the game's own sound settings when it has
7
+ * a Sound tab, else as `app`, for the App tab, never a tab of its own for one row. Every popout that draws
8
+ * the game's tabs (the header's, the room chat toolbar's) places it here.
9
+ */
10
+ export declare function withChatSound(appTabs: AppSettingsTab[] | undefined): {
11
+ appTabs: AppSettingsTab[] | undefined;
12
+ app: ReactNode | null;
13
+ };
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * The room chat's "Chat sound" on/off (watchparty's chime after a quiet minute), placed among a game's
4
+ * settings tabs. Its own module, apart from the fleet header, so the chat toolbar's popout can use it in a
5
+ * page that draws no header (the embed among them) without the header and its sheets coming along.
6
+ */
7
+ import { lazy, Suspense } from 'react';
8
+ /** The `appTabs` id the chat sound switch goes in. */
9
+ export const SOUND_TAB_ID = 'sound';
10
+ /**
11
+ * Watchparty's own switch, from the same room-chrome module `RoomShell` loads, so it writes the store that
12
+ * chrome's chime reads. Lazy: a popout renders a tab only while it is open, so the chunk is fetched then
13
+ * (and usually already is, for the room).
14
+ */
15
+ const ChatSoundSetting = lazy(() => import('@wolffm/watchparty-ui/room-chrome').then((m) => ({ default: m.ChatSoundSetting })));
16
+ const chatSound = (_jsx(Suspense, { fallback: null, children: _jsx(ChatSoundSetting, {}) }));
17
+ /**
18
+ * A game's settings tabs with the chat sound switch placed: beside the game's own sound settings when it has
19
+ * a Sound tab, else as `app`, for the App tab, never a tab of its own for one row. Every popout that draws
20
+ * the game's tabs (the header's, the room chat toolbar's) places it here.
21
+ */
22
+ export function withChatSound(appTabs) {
23
+ if (!(appTabs?.some((t) => t.id === SOUND_TAB_ID) ?? false))
24
+ return { appTabs, app: chatSound };
25
+ return { appTabs: appTabs.map((t) => (t.id === SOUND_TAB_ID ? { ...t, render: () => _jsxs(_Fragment, { children: [t.render(), chatSound] }) } : t)), app: null };
26
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/game-ui",
3
- "version": "0.1.162",
4
- "gitHead": "f4e92f118d1150aa86793fe34d82f5a3bf199a87",
3
+ "version": "0.1.163",
4
+ "gitHead": "46159021f289942131bbf7685e544208da2cc865",
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.",
@@ -54,8 +54,8 @@
54
54
  "react-dom": "^19.2.8"
55
55
  },
56
56
  "dependencies": {
57
- "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.166",
58
- "@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.166",
57
+ "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.167",
58
+ "@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.167",
59
59
  "@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.2",
60
60
  "@wolffm/rooms-client": "npm:@hadoku/rooms-client@^0.45.144",
61
61
  "@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.144",