@hadoku/game-ui 0.1.161 → 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.
- package/dist/app/GameAppShell.d.ts +0 -2
- package/dist/app/GameAppShell.js +5 -16
- package/dist/chrome/pageToolbar.d.ts +3 -0
- package/dist/chrome/pageToolbar.js +12 -0
- package/dist/chrome/toolbarPage.d.ts +1 -4
- package/dist/chrome/toolbarPage.js +1 -13
- package/dist/screens/route.d.ts +3 -1
- package/dist/screens/route.js +3 -1
- package/dist/screens/router.d.ts +6 -0
- package/dist/screens/router.js +28 -0
- package/dist/settings/chatSound.d.ts +13 -0
- package/dist/settings/chatSound.js +26 -0
- package/package.json +4 -4
|
@@ -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";
|
package/dist/app/GameAppShell.js
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
51
|
-
|
|
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:
|
|
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 {
|
|
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
|
|
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
|
-
};
|
package/dist/screens/route.d.ts
CHANGED
|
@@ -128,7 +128,9 @@ export declare function canonicalAddress(location: {
|
|
|
128
128
|
search: string;
|
|
129
129
|
hash: string;
|
|
130
130
|
}, base: string): string | null;
|
|
131
|
-
export declare const useRoute: () => Route, currentRoute: () => Route, routeInMemory: (start: Route) => () => void, canonicalizeAddress: () => void
|
|
131
|
+
export declare const useRoute: () => Route, currentRoute: () => Route, routeInMemory: (start: Route) => () => void, canonicalizeAddress: () => void,
|
|
132
|
+
/** Where this page was before the route it is on (`./router.ts`): a screen's way back. */
|
|
133
|
+
cameFrom: (skip?: ((route: Route) => boolean) | undefined) => Route | null;
|
|
132
134
|
/**
|
|
133
135
|
* Go somewhere: a history entry standalone (`replace` swaps the current one, for a screen that
|
|
134
136
|
* forwards on its own), the in-memory route embedded.
|
package/dist/screens/route.js
CHANGED
|
@@ -279,7 +279,9 @@ const router = createHashRouter({
|
|
|
279
279
|
});
|
|
280
280
|
export const { useRoute, currentRoute, routeInMemory,
|
|
281
281
|
/** Puts this page on its route's own address, before anything reads the route and after each move. */
|
|
282
|
-
canonicalize: canonicalizeAddress,
|
|
282
|
+
canonicalize: canonicalizeAddress,
|
|
283
|
+
/** Where this page was before the route it is on (`./router.ts`): a screen's way back. */
|
|
284
|
+
cameFrom, } = router;
|
|
283
285
|
/**
|
|
284
286
|
* Go somewhere: a history entry standalone (`replace` swaps the current one, for a screen that
|
|
285
287
|
* forwards on its own), the in-memory route embedded.
|
package/dist/screens/router.d.ts
CHANGED
|
@@ -44,6 +44,12 @@ export interface HashRouter<R> {
|
|
|
44
44
|
canonicalize(): void;
|
|
45
45
|
/** Whether the route is in memory now (an embed is mounted). */
|
|
46
46
|
inMemory(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* The newest route this page was on before the one it is on now, skipping any `skip` names:
|
|
49
|
+
* where a screen's way out goes back to. A route a screen forwarded away from (`replace`) is
|
|
50
|
+
* not one the page came from. Null when the page came from nowhere `skip` lets through.
|
|
51
|
+
*/
|
|
52
|
+
cameFrom(skip?: (route: R) => boolean): R | null;
|
|
47
53
|
/** Subscribes to route changes; returns the unsubscribe. */
|
|
48
54
|
subscribe(listener: () => void): () => void;
|
|
49
55
|
parse(hash: string): R;
|
package/dist/screens/router.js
CHANGED
|
@@ -35,6 +35,28 @@ export function createHashRouter({ parse, toHash, paths, base = bundlerBase }) {
|
|
|
35
35
|
for (const listener of [...listeners])
|
|
36
36
|
listener();
|
|
37
37
|
};
|
|
38
|
+
/** The routes this page has been on, as hashes, oldest first; the last is where it is now. */
|
|
39
|
+
const trail = [];
|
|
40
|
+
const TRAIL_MAX = 20;
|
|
41
|
+
/** The page is on `hash` now: a new place, or (`replace`) the same place under a new name. */
|
|
42
|
+
const arrived = (hash, replace) => {
|
|
43
|
+
if (trail.at(-1) === hash)
|
|
44
|
+
return;
|
|
45
|
+
if (replace && trail.length > 0)
|
|
46
|
+
trail[trail.length - 1] = hash;
|
|
47
|
+
else
|
|
48
|
+
trail.push(hash);
|
|
49
|
+
if (trail.length > TRAIL_MAX)
|
|
50
|
+
trail.shift();
|
|
51
|
+
};
|
|
52
|
+
const cameFrom = (skip = () => false) => {
|
|
53
|
+
for (let i = trail.length - 2; i >= 0; i--) {
|
|
54
|
+
const route = parse(trail[i]);
|
|
55
|
+
if (trail[i] !== trail.at(-1) && !skip(route))
|
|
56
|
+
return route;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
};
|
|
38
60
|
const canonicalize = () => {
|
|
39
61
|
const location = globalThis.location;
|
|
40
62
|
if (paths?.canonical === undefined || location === undefined)
|
|
@@ -46,6 +68,7 @@ export function createHashRouter({ parse, toHash, paths, base = bundlerBase }) {
|
|
|
46
68
|
/** The address bar moved on its own (Back, Forward, a `#` link): correct it, then re-read it. */
|
|
47
69
|
const moved = () => {
|
|
48
70
|
canonicalize();
|
|
71
|
+
arrived(currentHash(), false);
|
|
49
72
|
notify();
|
|
50
73
|
};
|
|
51
74
|
// Subscribed to the window only while the address bar is ours and somebody is listening.
|
|
@@ -62,6 +85,8 @@ export function createHashRouter({ parse, toHash, paths, base = bundlerBase }) {
|
|
|
62
85
|
}
|
|
63
86
|
};
|
|
64
87
|
const subscribe = (listener) => {
|
|
88
|
+
if (trail.length === 0)
|
|
89
|
+
arrived(currentHash(), false);
|
|
65
90
|
listeners.add(listener);
|
|
66
91
|
syncWindow();
|
|
67
92
|
return () => {
|
|
@@ -85,6 +110,7 @@ export function createHashRouter({ parse, toHash, paths, base = bundlerBase }) {
|
|
|
85
110
|
return `${path}${location.search}${hash}`;
|
|
86
111
|
};
|
|
87
112
|
const navigate = (route, { replace = false } = {}) => {
|
|
113
|
+
arrived(currentHash(), false);
|
|
88
114
|
if (memory !== null)
|
|
89
115
|
memory.hash = toHash(route);
|
|
90
116
|
else {
|
|
@@ -98,6 +124,7 @@ export function createHashRouter({ parse, toHash, paths, base = bundlerBase }) {
|
|
|
98
124
|
globalThis.history.pushState(null, '', next);
|
|
99
125
|
}
|
|
100
126
|
}
|
|
127
|
+
arrived(currentHash(), replace);
|
|
101
128
|
notify();
|
|
102
129
|
};
|
|
103
130
|
const routeInMemory = (start) => {
|
|
@@ -125,6 +152,7 @@ export function createHashRouter({ parse, toHash, paths, base = bundlerBase }) {
|
|
|
125
152
|
navigate,
|
|
126
153
|
routeInMemory,
|
|
127
154
|
canonicalize,
|
|
155
|
+
cameFrom,
|
|
128
156
|
inMemory: () => memory !== null,
|
|
129
157
|
subscribe,
|
|
130
158
|
parse,
|
|
@@ -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.
|
|
4
|
-
"gitHead": "
|
|
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.
|
|
58
|
-
"@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.
|
|
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",
|