@hadoku/game-ui 0.0.0-stage → 0.1.6
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/LICENSE +21 -0
- package/dist/chrome/HeaderLinks.d.ts +16 -0
- package/dist/chrome/HeaderLinks.js +24 -0
- package/dist/components/ActionButton.d.ts +9 -0
- package/dist/components/ActionButton.js +49 -0
- package/dist/components/Avatar.d.ts +43 -0
- package/dist/components/Avatar.js +53 -0
- package/dist/components/ConnectionBanner.css +77 -0
- package/dist/components/ConnectionBanner.d.ts +33 -0
- package/dist/components/ConnectionBanner.js +33 -0
- package/dist/components/Modal.css +69 -0
- package/dist/components/Modal.d.ts +12 -0
- package/dist/components/Modal.js +31 -0
- package/dist/components/OverPage.d.ts +4 -0
- package/dist/components/OverPage.js +21 -0
- package/dist/components/Popover.css +58 -0
- package/dist/components/Popover.d.ts +20 -0
- package/dist/components/Popover.js +63 -0
- package/dist/components/RadioCards.css +178 -0
- package/dist/components/RadioCards.d.ts +33 -0
- package/dist/components/RadioCards.js +41 -0
- package/dist/components/StatusPill.d.ts +16 -0
- package/dist/components/StatusPill.js +17 -0
- package/dist/components/connection-state.d.ts +32 -0
- package/dist/components/connection-state.js +5 -0
- package/dist/dom.d.ts +17 -0
- package/dist/dom.js +57 -0
- package/dist/front/Gallery.d.ts +22 -0
- package/dist/front/Gallery.js +48 -0
- package/dist/front/PatchNotesCard.d.ts +1 -0
- package/dist/front/PatchNotesCard.js +59 -0
- package/dist/front/camera.d.ts +80 -0
- package/dist/front/camera.js +120 -0
- package/dist/front/countdown.d.ts +2 -0
- package/dist/front/countdown.js +16 -0
- package/dist/front/discordChat.d.ts +22 -0
- package/dist/front/discordChat.js +52 -0
- package/dist/front/gallery.d.ts +13 -0
- package/dist/front/gallery.js +32 -0
- package/dist/front/gate.d.ts +23 -0
- package/dist/front/gate.js +55 -0
- package/dist/front/icons.d.ts +43 -0
- package/dist/front/icons.js +99 -0
- package/dist/front/patchNotes.d.ts +37 -0
- package/dist/front/patchNotes.js +95 -0
- package/dist/front/polls.d.ts +24 -0
- package/dist/front/polls.js +95 -0
- package/dist/front/shape.d.ts +11 -0
- package/dist/front/shape.js +52 -0
- package/dist/http.d.ts +28 -0
- package/dist/http.js +83 -0
- package/dist/idle.d.ts +2 -0
- package/dist/idle.js +7 -0
- package/dist/lazy.d.ts +9 -0
- package/dist/lazy.js +63 -0
- package/dist/popover.d.ts +13 -0
- package/dist/popover.js +39 -0
- package/dist/registered.d.ts +5 -0
- package/dist/registered.js +6 -0
- package/dist/restart-notice.d.ts +20 -0
- package/dist/restart-notice.js +54 -0
- package/dist/room/RoomShell.d.ts +116 -0
- package/dist/room/RoomShell.js +222 -0
- package/dist/room/SessionPrompt.d.ts +12 -0
- package/dist/room/SessionPrompt.js +54 -0
- package/dist/room/avatar.d.ts +31 -0
- package/dist/room/avatar.js +60 -0
- package/dist/room/look.css +13 -0
- package/dist/room/look.d.ts +35 -0
- package/dist/room/look.js +189 -0
- package/dist/room/seatsOpen.d.ts +7 -0
- package/dist/room/seatsOpen.js +37 -0
- package/dist/room/session.d.ts +26 -0
- package/dist/room/session.js +108 -0
- package/dist/room/socket-options.d.ts +33 -0
- package/dist/room/socket-options.js +40 -0
- package/dist/room/tab-id.d.ts +6 -0
- package/dist/room/tab-id.js +90 -0
- package/dist/room/whoami.d.ts +15 -0
- package/dist/room/whoami.js +48 -0
- package/dist/rooms/bundle-slot.fixture.d.ts +11 -0
- package/dist/rooms/bundle-slot.fixture.js +21 -0
- package/dist/rooms/game-clients.d.ts +12 -0
- package/dist/rooms/game-clients.js +30 -0
- package/dist/rooms/game-setup.d.ts +63 -0
- package/dist/rooms/game-setup.js +33 -0
- package/dist/rooms/relay-channel.d.ts +29 -0
- package/dist/rooms/relay-channel.js +123 -0
- package/dist/rooms/screen/RoomShell.d.ts +33 -0
- package/dist/rooms/screen/RoomShell.js +7 -0
- package/dist/screens/route.d.ts +143 -0
- package/dist/screens/route.js +359 -0
- package/dist/settings/Settings.d.ts +39 -0
- package/dist/settings/Settings.js +131 -0
- package/dist/settings/TrimScreen.d.ts +2 -0
- package/dist/settings/TrimScreen.js +29 -0
- package/dist/settings/settings.css +116 -0
- package/dist/settings/siteTrim.d.ts +3 -0
- package/dist/settings/siteTrim.js +9 -0
- package/dist/settings/trim-screen.css +30 -0
- package/dist/sound/index.d.ts +12 -0
- package/dist/sound/index.js +34 -0
- package/dist/stale-build.d.ts +16 -0
- package/dist/stale-build.js +59 -0
- package/dist/top-layer.css +22 -0
- package/dist/topLayer.d.ts +19 -0
- package/dist/topLayer.js +44 -0
- package/dist/usage.d.ts +5 -0
- package/dist/usage.js +17 -0
- package/dist/visible.d.ts +14 -0
- package/dist/visible.js +35 -0
- package/package.json +41 -4
- package/README.md +0 -3
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ComponentType } from 'react';
|
|
2
|
+
import type { AppSettingsTab } from '@wolffm/task-ui-components';
|
|
3
|
+
import type { PrefsClient } from '@wolffm/prefs-client';
|
|
4
|
+
import './settings.css';
|
|
5
|
+
/** The game's own sections, where its UI scale is saved (and the scale before anything is), and what a new scale makes stale. */
|
|
6
|
+
export interface SettingsParts {
|
|
7
|
+
Game: ComponentType;
|
|
8
|
+
Sound: ComponentType;
|
|
9
|
+
prefs: () => PrefsClient<{
|
|
10
|
+
uiScale?: number;
|
|
11
|
+
}>;
|
|
12
|
+
defaultScale: number;
|
|
13
|
+
onScaled: () => void;
|
|
14
|
+
}
|
|
15
|
+
export declare const registerSettings: (value: SettingsParts) => void;
|
|
16
|
+
/** The settings as tabs, in the order a player looks for them: how the game plays first, one slider last. */
|
|
17
|
+
export declare const CARDTABLE_SETTINGS_TABS: AppSettingsTab[];
|
|
18
|
+
/** Every tab's sections one under another, for a popout with no tabs of its own. */
|
|
19
|
+
export declare function CardtableSettings(): import("react").JSX.Element;
|
|
20
|
+
export declare const HostDrawsSettingsProvider: import("react").Provider<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* Reads the same flag `SettingsGear` itself reads — exported for a screen that needs the FACT (not
|
|
23
|
+
* just a gear it can toggle), rather than sniffing the DOM for whatever visible proxy the host's own
|
|
24
|
+
* gear happens to be today. Wave 89 §B: `LiveBoard.tsx` hides the fleet header in portrait during a
|
|
25
|
+
* match, and reads this to know whether that header WOULD have drawn the gear, so it can put a second
|
|
26
|
+
* `SettingsGear` (under its own `HostDrawsSettingsProvider value={false}` override) in its menu only
|
|
27
|
+
* where the header held the only route to one.
|
|
28
|
+
*/
|
|
29
|
+
export declare function useHostDrawsSettings(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The saved UI scale, written where the stylesheet's tokens resolve (shell's `ui-scale.ts`). Called
|
|
32
|
+
* once per app — the standalone page's and the embed's — with the element that is. Until prefs
|
|
33
|
+
* answer, the scale this browser applied last: a layout effect, so the first frame is drawn at it.
|
|
34
|
+
*/
|
|
35
|
+
export declare function useUiScale(root: () => HTMLElement | null): void;
|
|
36
|
+
/** Our own way in, where no host draws the settings: a gear in a screen's head row, or beside the board's Log button. */
|
|
37
|
+
export declare function SettingsGear({ className }: {
|
|
38
|
+
className?: string;
|
|
39
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Cardtable's own settings: one panel, drawn by whichever host is around the game.
|
|
4
|
+
*
|
|
5
|
+
* The operator, 2026-10-30, after two players could not find the settings mid-match (they were
|
|
6
|
+
* behind your own avatar): *"the right way to do this is to have hadoku_site prefs handle as much
|
|
7
|
+
* as possible … we can utilize the generic 'site settings' section that already exists in that
|
|
8
|
+
* settings modal and shove everything in there."* So:
|
|
9
|
+
*
|
|
10
|
+
* - **Standalone**, `CARDTABLE_SETTINGS_TABS` are the `appTabs` of the fleet's `AppHeader`: tabs
|
|
11
|
+
* of their own after the site's Profile, Content and Account, in the one gear at the top of
|
|
12
|
+
* every screen, a match included (`../App.tsx`). `HostDrawsSettings` tells the screens so, and
|
|
13
|
+
* their own gear draws nothing.
|
|
14
|
+
* - **Inside a watchparty room** there is no fleet header yet, so `SettingsGear` draws our own,
|
|
15
|
+
* in each screen's head row and beside the board's Log button, with the same tabs' contents
|
|
16
|
+
* one under another (`CardtableSettings`), as watchparty's own popout draws a game's settings:
|
|
17
|
+
* one panel in its App tab.
|
|
18
|
+
* `docs/requests/SETTINGS_WATCHPARTY_SLOT.md` asks watchparty for a popout and a
|
|
19
|
+
* `mountSettings` hook that will put this same panel in it.
|
|
20
|
+
*
|
|
21
|
+
* Every value is a preference in the fleet's service (`../play/live/prefs.ts`,
|
|
22
|
+
* `../sound/mute.ts`), so whichever host draws a control, the board reads the change from the
|
|
23
|
+
* service and applies it. Only "This match" is not a preference: the board publishes it
|
|
24
|
+
* (`./liveMatch.ts`). The Game and Sound tabs are the game's own, handed in by `../composition.tsx`.
|
|
25
|
+
*/
|
|
26
|
+
import { createContext, createElement, Fragment, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
27
|
+
import { Icon } from '@wolffm/themes';
|
|
28
|
+
import { usePrefs } from '@wolffm/prefs-client/react';
|
|
29
|
+
import { applyUiScale, clampUiScale, rememberedUiScale, rememberUiScale, UI_SCALE, uiLength } from '@wolffm/ui-shell/settings';
|
|
30
|
+
import { Popover, usePopover } from "../components/Popover.js";
|
|
31
|
+
import { registered } from "../registered.js";
|
|
32
|
+
import './settings.css';
|
|
33
|
+
const parts = registered('settings');
|
|
34
|
+
export const registerSettings = parts.set;
|
|
35
|
+
/** The settings as tabs, in the order a player looks for them: how the game plays first, one slider last. */
|
|
36
|
+
export const CARDTABLE_SETTINGS_TABS = [
|
|
37
|
+
{
|
|
38
|
+
id: 'game',
|
|
39
|
+
label: 'Game',
|
|
40
|
+
render: () => _jsx("div", { className: "ct-settings__tab", children: createElement(parts.get().Game) }),
|
|
41
|
+
},
|
|
42
|
+
{ id: 'sound', label: 'Sound', render: () => _jsx("div", { className: "ct-settings__tab", children: createElement(parts.get().Sound) }) },
|
|
43
|
+
{ id: 'display', label: 'Display', render: () => _jsx("div", { className: "ct-settings__tab", children: _jsx(DisplaySettings, {}) }) },
|
|
44
|
+
];
|
|
45
|
+
/** Every tab's sections one under another, for a popout with no tabs of its own. */
|
|
46
|
+
export function CardtableSettings() {
|
|
47
|
+
return (_jsx(_Fragment, { children: CARDTABLE_SETTINGS_TABS.map((tab) => (_jsx(Fragment, { children: tab.render() }, tab.id))) }));
|
|
48
|
+
}
|
|
49
|
+
/** True where the page's host draws `CardtableSettings` itself: the screens then draw no gear of their own. */
|
|
50
|
+
const HostDrawsSettings = createContext(false);
|
|
51
|
+
export const HostDrawsSettingsProvider = HostDrawsSettings.Provider;
|
|
52
|
+
/**
|
|
53
|
+
* Reads the same flag `SettingsGear` itself reads — exported for a screen that needs the FACT (not
|
|
54
|
+
* just a gear it can toggle), rather than sniffing the DOM for whatever visible proxy the host's own
|
|
55
|
+
* gear happens to be today. Wave 89 §B: `LiveBoard.tsx` hides the fleet header in portrait during a
|
|
56
|
+
* match, and reads this to know whether that header WOULD have drawn the gear, so it can put a second
|
|
57
|
+
* `SettingsGear` (under its own `HostDrawsSettingsProvider value={false}` override) in its menu only
|
|
58
|
+
* where the header held the only route to one.
|
|
59
|
+
*/
|
|
60
|
+
export function useHostDrawsSettings() {
|
|
61
|
+
return useContext(HostDrawsSettings);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The UI scale, the slider the sound levels' own design is (`ct-settings__level`), with no number
|
|
65
|
+
* beside it as they have none (the operator, 2026-10-21). Saved once the
|
|
66
|
+
* thumb is let go, not on every step of a drag: the whole page re-scales on a save, and a slider
|
|
67
|
+
* that moves under the pointer while it is held is a slider that cannot be aimed.
|
|
68
|
+
*
|
|
69
|
+
* Let go is the input's own `change`, not `pointerup`: `pointerup` is dispatched before the
|
|
70
|
+
* browser has finished the press, and a save there re-scaled the slider while the browser was
|
|
71
|
+
* still reading the pointer against it — a click on 110% came back as 90%.
|
|
72
|
+
*/
|
|
73
|
+
function DisplaySettings() {
|
|
74
|
+
const { prefs: client, defaultScale } = parts.get();
|
|
75
|
+
const { prefs, save } = usePrefs(client());
|
|
76
|
+
const saved = clampUiScale(prefs?.uiScale ?? defaultScale);
|
|
77
|
+
const [held, setHeld] = useState(null);
|
|
78
|
+
const shown = held ?? saved;
|
|
79
|
+
const slider = useRef(null);
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
const el = slider.current;
|
|
82
|
+
if (el === null)
|
|
83
|
+
return undefined;
|
|
84
|
+
// The native `change` is the one sent on let go; React's onChange also runs for every `input`.
|
|
85
|
+
const commit = () => {
|
|
86
|
+
setHeld(null);
|
|
87
|
+
const chosen = clampUiScale(Number(el.value) / 100);
|
|
88
|
+
if (chosen !== saved)
|
|
89
|
+
void save({ uiScale: chosen });
|
|
90
|
+
};
|
|
91
|
+
el.addEventListener('change', commit);
|
|
92
|
+
return () => el.removeEventListener('change', commit);
|
|
93
|
+
}, [saved, save]);
|
|
94
|
+
return (_jsxs("fieldset", { className: "ct-settings__section", "data-testid": "settings-display", children: [_jsx("legend", { children: "Display" }), _jsxs("label", { className: "ct-settings__level", children: [_jsx("span", { children: "UI scale" }), _jsx("input", { type: "range", min: UI_SCALE.min * 100, max: UI_SCALE.max * 100, step: UI_SCALE.step * 100, value: Math.round(shown * 100), "data-testid": "settings-ui-scale", ref: slider, onChange: (event) => {
|
|
95
|
+
// React runs this for the let-go `change` too, after it has been saved; only a step is held.
|
|
96
|
+
if (event.nativeEvent.type === 'input')
|
|
97
|
+
setHeld(clampUiScale(Number(event.currentTarget.value) / 100));
|
|
98
|
+
} })] })] }));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The saved UI scale, written where the stylesheet's tokens resolve (shell's `ui-scale.ts`). Called
|
|
102
|
+
* once per app — the standalone page's and the embed's — with the element that is. Until prefs
|
|
103
|
+
* answer, the scale this browser applied last: a layout effect, so the first frame is drawn at it.
|
|
104
|
+
*/
|
|
105
|
+
export function useUiScale(root) {
|
|
106
|
+
const { prefs: client, defaultScale, onScaled } = parts.get();
|
|
107
|
+
const { prefs } = usePrefs(client());
|
|
108
|
+
const [remembered] = useState(rememberedUiScale);
|
|
109
|
+
const scale = prefs?.uiScale ?? remembered ?? defaultScale;
|
|
110
|
+
useLayoutEffect(() => {
|
|
111
|
+
const el = root();
|
|
112
|
+
if (el === null)
|
|
113
|
+
return undefined;
|
|
114
|
+
applyUiScale(el, scale);
|
|
115
|
+
// Every card width the board kept was measured at the old scale.
|
|
116
|
+
onScaled();
|
|
117
|
+
return () => applyUiScale(el, 1);
|
|
118
|
+
}, [root, scale, onScaled]);
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
if (prefs !== null)
|
|
121
|
+
rememberUiScale(scale);
|
|
122
|
+
}, [prefs, scale]);
|
|
123
|
+
}
|
|
124
|
+
/** Our own way in, where no host draws the settings: a gear in a screen's head row, or beside the board's Log button. */
|
|
125
|
+
export function SettingsGear({ className }) {
|
|
126
|
+
return useContext(HostDrawsSettings) ? null : _jsx(OwnSettingsGear, { className: className });
|
|
127
|
+
}
|
|
128
|
+
function OwnSettingsGear({ className }) {
|
|
129
|
+
const { trigger, toggle, close } = usePopover();
|
|
130
|
+
return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: className === undefined ? 'ct-round-button' : `ct-round-button ${className}`, "aria-label": "Settings", "aria-expanded": trigger !== null, "data-testid": "settings-gear", onClick: (event) => toggle(event.currentTarget), children: _jsx(Icon, { name: "gear", size: uiLength('1.15rem') }) }), trigger !== null && (_jsx(Popover, { trigger: trigger, onClose: close, title: "Settings", testId: "settings", children: _jsx(CardtableSettings, {}) }))] }));
|
|
131
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* `#/ui` — the trim composer (the operator, 2026-10-21: "the UI selection stuff should land behind
|
|
4
|
+
* 'https://hadoku.me/cardtable/#/ui' not exposed to all players", then "make it set the look for
|
|
5
|
+
* every player").
|
|
6
|
+
*
|
|
7
|
+
* The site's trim, for everyone (`./siteTrim.ts`). Linked from nowhere, and drawn only for a viewer
|
|
8
|
+
* the server says may edit it (`canEdit`, the admin tier it reads from the edge); anyone else is
|
|
9
|
+
* sent to the lobby. Each choice saves at once, and this page and every player's screens redraw.
|
|
10
|
+
*/
|
|
11
|
+
import { useEffect } from 'react';
|
|
12
|
+
import { navigate } from "../screens/route.js";
|
|
13
|
+
import { saveSiteTrim, useSiteTrim } from "./siteTrim.js";
|
|
14
|
+
import { TRIM_FAMILIES, TRIM_FAMILY_IDS } from '@wolffm/ui-shell/trim';
|
|
15
|
+
import './trim-screen.css';
|
|
16
|
+
export function TrimScreen() {
|
|
17
|
+
const { loaded, canEdit, trim } = useSiteTrim();
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (loaded && !canEdit)
|
|
20
|
+
navigate({ kind: 'lobby' });
|
|
21
|
+
}, [loaded, canEdit]);
|
|
22
|
+
if (!canEdit)
|
|
23
|
+
return null;
|
|
24
|
+
return (_jsx("div", { className: "shell", "data-testid": "trim-screen", children: _jsxs("section", { className: "ui-trim ct-panel", "aria-labelledby": "ui-trim-title", children: [_jsx("h2", { id: "ui-trim-title", className: "ui-trim__title ct-panel__title", children: "Trim" }), TRIM_FAMILY_IDS.map((family) => (_jsxs("label", { className: "ui-trim__row", children: [_jsx("span", { children: TRIM_FAMILIES[family].label }), _jsxs("select", { value: trim[family] ?? '', "data-testid": `trim-${family}`, onChange: (event) => {
|
|
25
|
+
const { [family]: _was, ...rest } = trim;
|
|
26
|
+
const value = event.currentTarget.value;
|
|
27
|
+
void saveSiteTrim((value === '' ? rest : { ...rest, [family]: value }));
|
|
28
|
+
}, children: [_jsx("option", { value: "", children: "None" }), Object.entries(TRIM_FAMILIES[family].options).map(([value, label]) => (_jsx("option", { value: value, children: label }, value)))] })] }, family)))] }) }));
|
|
29
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Cardtable's own settings and its gear (`Settings.tsx`), drawn in a `components/Popover.tsx`.
|
|
3
|
+
*
|
|
4
|
+
* Painted only from `@wolffm/themes` tokens — no literal colour anywhere; its
|
|
5
|
+
* native controls take the theme's accent from the fleet's `controls.css`
|
|
6
|
+
* (`main.tsx`), which reaches it in the header's popout too: inside a match it sits in the
|
|
7
|
+
* `.live` island, outside it on the themed screens, and either way it reads as
|
|
8
|
+
* a card over the page.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
.ct-settings__close {
|
|
12
|
+
display: inline-flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
padding: 4px;
|
|
16
|
+
border: 1px solid transparent;
|
|
17
|
+
border-radius: var(--hdk-radius-sm);
|
|
18
|
+
background: transparent;
|
|
19
|
+
color: inherit;
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.ct-settings__close:hover,
|
|
24
|
+
.ct-settings__close:focus-visible {
|
|
25
|
+
border-color: var(--color-border);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.ct-settings__section {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
gap: 6px;
|
|
32
|
+
margin: 0;
|
|
33
|
+
padding: 8px 0 0;
|
|
34
|
+
border: 0;
|
|
35
|
+
border-top: 1px solid var(--color-border);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* A tab's first section opens under the tab strip: no second line, and no heading repeating the tab's name. */
|
|
39
|
+
.ct-settings__tab > .ct-settings__section:first-child {
|
|
40
|
+
padding-top: 0;
|
|
41
|
+
border-top: 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.settings-popout__tabpanel .ct-settings__tab > .ct-settings__section:first-child > legend {
|
|
45
|
+
display: none;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.ct-settings__section + .ct-settings__section,
|
|
49
|
+
.ct-settings__tab + .ct-settings__tab {
|
|
50
|
+
margin-top: 10px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.ct-settings__section > legend {
|
|
54
|
+
float: left;
|
|
55
|
+
width: 100%;
|
|
56
|
+
margin-bottom: 2px;
|
|
57
|
+
padding: 0;
|
|
58
|
+
color: var(--color-text-secondary);
|
|
59
|
+
font-size: 11px;
|
|
60
|
+
font-weight: 600;
|
|
61
|
+
letter-spacing: 0.06em;
|
|
62
|
+
text-transform: uppercase;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.ct-settings__option {
|
|
66
|
+
display: flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
gap: 6px;
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.ct-settings__triggers {
|
|
73
|
+
display: flex;
|
|
74
|
+
flex-direction: column;
|
|
75
|
+
gap: 2px;
|
|
76
|
+
margin: 0;
|
|
77
|
+
padding: 0;
|
|
78
|
+
list-style: none;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.ct-settings__trigger {
|
|
82
|
+
display: flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
justify-content: space-between;
|
|
85
|
+
gap: 6px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.ct-settings__choices {
|
|
89
|
+
display: flex;
|
|
90
|
+
flex-direction: column;
|
|
91
|
+
gap: 4px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.ct-settings__level {
|
|
95
|
+
display: grid;
|
|
96
|
+
grid-template-columns: 4rem 1fr;
|
|
97
|
+
align-items: center;
|
|
98
|
+
gap: 8px;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* A slider that reads its value back beside it. */
|
|
102
|
+
.ct-settings__level:has(> input + output) {
|
|
103
|
+
grid-template-columns: 4rem 1fr 2.75rem;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.ct-settings__level input,
|
|
107
|
+
.ct-settings__level select {
|
|
108
|
+
width: 100%;
|
|
109
|
+
min-width: 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.ct-settings__level output {
|
|
113
|
+
overflow: hidden;
|
|
114
|
+
text-overflow: ellipsis;
|
|
115
|
+
white-space: nowrap;
|
|
116
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The site's trim store, moved to `@hadoku/ui-shell/trim` (wave 92 §A): game-neutral apart from where
|
|
3
|
+
* the server lives, which this file wires once, before anything below here renders — every importer
|
|
4
|
+
* of this path (`screens/LobbyScreen.tsx`, `embed/EmbedApp.tsx`) keeps the same names and signatures.
|
|
5
|
+
*/
|
|
6
|
+
import { apiUrl } from "../http.js";
|
|
7
|
+
import { configureSiteTrim, knownTrim, resetSiteTrimForTests, saveSiteTrim, useSiteTrim, useTrim } from '@wolffm/ui-shell/trim';
|
|
8
|
+
configureSiteTrim({ apiUrl: apiUrl('trim') });
|
|
9
|
+
export { knownTrim, resetSiteTrimForTests, saveSiteTrim, useSiteTrim, useTrim };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* `#/ui`, the trim composer (`TrimScreen.tsx`). */
|
|
2
|
+
|
|
3
|
+
.ui-trim {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
gap: 10px;
|
|
7
|
+
width: min(26rem, 100%);
|
|
8
|
+
padding: 16px 20px 20px;
|
|
9
|
+
border: 1px solid var(--color-border);
|
|
10
|
+
border-radius: var(--hdk-radius);
|
|
11
|
+
background: var(--color-bg-card);
|
|
12
|
+
color: var(--color-text);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.ui-trim__title {
|
|
16
|
+
margin: 0 0 4px;
|
|
17
|
+
font-size: 1.1rem;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.ui-trim__row {
|
|
21
|
+
display: grid;
|
|
22
|
+
grid-template-columns: 9rem 1fr;
|
|
23
|
+
align-items: center;
|
|
24
|
+
gap: 10px;
|
|
25
|
+
font-size: 0.9rem;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.ui-trim__row select {
|
|
29
|
+
min-width: 0;
|
|
30
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type SoundConfig } from '@wolffm/ui-shell/sound';
|
|
2
|
+
export declare const registerSound: (config: SoundConfig<string>) => void;
|
|
3
|
+
export declare const setRolePlayer: (player: import("@wolffm/ui-shell/sound").RolePlayer | null) => void, resetRolePlayerForTests: () => void, takeUiTally: () => Record<string, number>, holdMatchQuiet: () => () => void, playRole: (role: string) => void, playSoundEvents: (events: readonly import("@wolffm/ui-shell/sound").DelayedSoundEvent[]) => void, setTrackNames: (names: Readonly<Record<string, string>>) => void, getMusicTrack: () => import("@wolffm/ui-shell/sound").MusicTrack | null, subscribeMusicTrack: (fn: () => void) => () => void, setScreenMusic: (role: string | null) => void, setMatchMusic: (roles: readonly string[] | null) => void, roleHandler: (role: string) => () => void;
|
|
4
|
+
/**
|
|
5
|
+
* For a screen's `onPointerOver`: the pointer arriving on an enabled button plays the card hover. One sound for
|
|
6
|
+
* both (the operator, 2026-10-16: "drop hover a button. make it the same as hover a card"). A card tile that is a
|
|
7
|
+
* button plays its own hover, and moving between a button's children is not arriving.
|
|
8
|
+
*/
|
|
9
|
+
export declare function hoverControl(event: {
|
|
10
|
+
target: EventTarget | null;
|
|
11
|
+
relatedTarget: EventTarget | null;
|
|
12
|
+
}): void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The app's sound, behind roles — `SOUND_ROLES` (`@hadoku/shared`). Which
|
|
3
|
+
* take plays, how loud, and whether a colour layer sits on top is the
|
|
4
|
+
* operator's assignment (`#/sounds`), loaded on first play; a role nobody
|
|
5
|
+
* has assigned plays nothing, the normal state of a fresh install.
|
|
6
|
+
*
|
|
7
|
+
* The mixer, mute store, queue mechanics and gain slider are generic
|
|
8
|
+
* (`@hadoku/ui-shell/sound`, w92-C). This file is the one place that hands
|
|
9
|
+
* them a game's role registry and server client through `createSound`,
|
|
10
|
+
* registered once by the composition root (`../composition.tsx`), and
|
|
11
|
+
* re-exports its instance under the same flat names every importer
|
|
12
|
+
* already uses — nothing above this file changed. `setRolePlayer` swaps
|
|
13
|
+
* the mixer for a recorder, so a test asserts raised events without audio.
|
|
14
|
+
*/
|
|
15
|
+
import { createSound } from '@wolffm/ui-shell/sound';
|
|
16
|
+
import { registered } from "../registered.js";
|
|
17
|
+
const sound = registered('sound');
|
|
18
|
+
export const registerSound = (config) => sound.set(createSound(config));
|
|
19
|
+
/** Each name calls the registered instance when it is called, so an importer can bind it before the composition root runs. */
|
|
20
|
+
const live = new Proxy({}, { get: (_, name) => (...args) => sound.get()[name](...args) });
|
|
21
|
+
export const { setRolePlayer, resetRolePlayerForTests, takeUiTally, holdMatchQuiet, playRole, playSoundEvents, setTrackNames, getMusicTrack, subscribeMusicTrack, setScreenMusic, setMatchMusic, roleHandler, } = live;
|
|
22
|
+
/**
|
|
23
|
+
* For a screen's `onPointerOver`: the pointer arriving on an enabled button plays the card hover. One sound for
|
|
24
|
+
* both (the operator, 2026-10-16: "drop hover a button. make it the same as hover a card"). A card tile that is a
|
|
25
|
+
* button plays its own hover, and moving between a button's children is not arriving.
|
|
26
|
+
*/
|
|
27
|
+
export function hoverControl(event) {
|
|
28
|
+
const button = event.target instanceof Element ? event.target.closest('button') : null;
|
|
29
|
+
if (button === null || button.disabled || button.hasAttribute('data-card-id'))
|
|
30
|
+
return;
|
|
31
|
+
if (event.relatedTarget instanceof Node && button.contains(event.relatedTarget))
|
|
32
|
+
return;
|
|
33
|
+
playRole('ui.hover-card');
|
|
34
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** `[major, minor, patch]` of a build, or null for a build that is not a release's (`unknown`, a named CI build). */
|
|
2
|
+
export declare function releaseOf(build: string): [number, number, number] | null;
|
|
3
|
+
/** The server runs a later release than this page was built from. */
|
|
4
|
+
export declare function serverReleaseIsNewer(page: string, server: string): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* What the server sent did not parse here: is a reload a fix? Yes unless the server is known to run
|
|
7
|
+
* this very build, when the failure is a bug a reload would only repeat. `null` is a server that
|
|
8
|
+
* never said (one older than `forge:build`).
|
|
9
|
+
*/
|
|
10
|
+
export declare function unreadableMeansStale(page: string, server: string | null): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Claims this tab's one reload for `target`, the server build it reloads to meet. False when this
|
|
13
|
+
* tab already reloaded for that build (the new bundle still could not read it, so a second reload
|
|
14
|
+
* would loop) or there is no session storage to remember the reload in.
|
|
15
|
+
*/
|
|
16
|
+
export declare function claimReload(target: string, storage?: () => Storage): boolean;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* A page left open across a release, talking to the newer server.
|
|
3
|
+
*
|
|
4
|
+
* The server tells every socket its build on connect (`forge:build`). A release that adds a field to
|
|
5
|
+
* the wire makes an older page's strict schemas refuse what the newer server sends: match
|
|
6
|
+
* m-13e598202544 (2026-11-07), a v0.56.0 tab under a v0.57.0 server, refused every frame that held
|
|
7
|
+
* a card face, resynced into the same refusal three times and stopped drawing a game that went on.
|
|
8
|
+
* A reload fetches the bundle the server is serving now, and the seat rejoins on the same tab id.
|
|
9
|
+
*
|
|
10
|
+
* Builds are `vX.Y.Z+<sha>` or `CARDTABLE_VERSION` as it stands (`packages/devkit/src/release/build-version.ts`).
|
|
11
|
+
* Only a newer RELEASE reloads on sight: main past a release (PPE, a dev server, e2e) builds as the
|
|
12
|
+
* same release with another sha, and a stale `dist/version.txt` under a dev server is common, so a
|
|
13
|
+
* sha alone is no reason to reload a page that reads everything. A page that cannot read what the
|
|
14
|
+
* server sent is a different matter, and reloads for any build other than its own.
|
|
15
|
+
*/
|
|
16
|
+
const RELEASE = /^v(\d+)\.(\d+)\.(\d+)(?:\+.*)?$/;
|
|
17
|
+
/** `[major, minor, patch]` of a build, or null for a build that is not a release's (`unknown`, a named CI build). */
|
|
18
|
+
export function releaseOf(build) {
|
|
19
|
+
const m = RELEASE.exec(build);
|
|
20
|
+
return m === null ? null : [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
21
|
+
}
|
|
22
|
+
/** The server runs a later release than this page was built from. */
|
|
23
|
+
export function serverReleaseIsNewer(page, server) {
|
|
24
|
+
const ours = releaseOf(page);
|
|
25
|
+
const theirs = releaseOf(server);
|
|
26
|
+
if (ours === null || theirs === null)
|
|
27
|
+
return false;
|
|
28
|
+
for (let i = 0; i < 3; i++)
|
|
29
|
+
if (theirs[i] !== ours[i])
|
|
30
|
+
return theirs[i] > ours[i];
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* What the server sent did not parse here: is a reload a fix? Yes unless the server is known to run
|
|
35
|
+
* this very build, when the failure is a bug a reload would only repeat. `null` is a server that
|
|
36
|
+
* never said (one older than `forge:build`).
|
|
37
|
+
*/
|
|
38
|
+
export function unreadableMeansStale(page, server) {
|
|
39
|
+
return server === null || server === 'unknown' || server !== page;
|
|
40
|
+
}
|
|
41
|
+
const RELOADED_FOR = 'cardtable:reloaded-for-build';
|
|
42
|
+
/**
|
|
43
|
+
* Claims this tab's one reload for `target`, the server build it reloads to meet. False when this
|
|
44
|
+
* tab already reloaded for that build (the new bundle still could not read it, so a second reload
|
|
45
|
+
* would loop) or there is no session storage to remember the reload in.
|
|
46
|
+
*/
|
|
47
|
+
export function claimReload(target, storage = () => sessionStorage) {
|
|
48
|
+
try {
|
|
49
|
+
const store = storage();
|
|
50
|
+
if (store.getItem(RELOADED_FOR) === target)
|
|
51
|
+
return false;
|
|
52
|
+
store.setItem(RELOADED_FOR, target);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
console.warn('[cardtable] no session storage to guard a reload for a new build with', err);
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The screen's top layer (`./topLayer.tsx`). The inspector's enlarged card and
|
|
3
|
+
* the board's tooltip draw here and nowhere else, so they are above every other
|
|
4
|
+
* layer — on the table the phase rail and the controls (`--z-overlay`) and a
|
|
5
|
+
* decision window (`--z-popover`) — by this one declaration, not by a number
|
|
6
|
+
* each of them carries. On the board it is a sibling of the overlay, not inside
|
|
7
|
+
* it: inside, any z-index only ranks within the overlay's own layer.
|
|
8
|
+
*/
|
|
9
|
+
.top-layer {
|
|
10
|
+
position: absolute;
|
|
11
|
+
inset: 0;
|
|
12
|
+
z-index: var(--z-zoom, 60);
|
|
13
|
+
pointer-events: none;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.top-layer[data-fixed] {
|
|
17
|
+
position: fixed;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.top-layer[data-clip] {
|
|
21
|
+
overflow: clip;
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import './top-layer.css';
|
|
2
|
+
/**
|
|
3
|
+
* The layer itself. `fixed` on a screen with no box of its own to be absolute
|
|
4
|
+
* in (the draft, a peek); `clip` where what is drawn must stay inside the
|
|
5
|
+
* screen's box (the board, whose canvas no zone may scroll).
|
|
6
|
+
*/
|
|
7
|
+
export declare function TopLayer({ fixed, clip }: {
|
|
8
|
+
fixed?: boolean;
|
|
9
|
+
clip?: boolean;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
11
|
+
/** The top layer inside `root`, if it has one. */
|
|
12
|
+
export declare function topLayerIn(root: ParentNode): HTMLElement | null;
|
|
13
|
+
/** The top layer of the screen `el` is on: the nearest one inside any of its ancestors. */
|
|
14
|
+
export declare function topLayerOf(el: Element): HTMLElement | null;
|
|
15
|
+
/** Where `anchor`'s top-left corner is in `layer`'s own coordinates. */
|
|
16
|
+
export declare function originIn(layer: Element, anchor: Element): {
|
|
17
|
+
left: number;
|
|
18
|
+
top: number;
|
|
19
|
+
};
|
package/dist/topLayer.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* A screen's top layer: the one place everything that floats over the page is drawn.
|
|
4
|
+
*
|
|
5
|
+
* Each screen that shows cards mounts one empty `<TopLayer>` at `--z-zoom`
|
|
6
|
+
* (`./top-layer.css`), `pointer-events: none`, as the screen's last child. The
|
|
7
|
+
* inspector, the board's tooltip and the fan's related row draw into it, placed
|
|
8
|
+
* in its own coordinates from the measured rect of what they belong to.
|
|
9
|
+
*
|
|
10
|
+
* Drawing there rather than beside the anchor is the whole point: a z-index only
|
|
11
|
+
* orders an element inside its nearest stacking context, so an overlay drawn
|
|
12
|
+
* inside a pack, a pile or a seat can never rise above the page regions beside
|
|
13
|
+
* that ancestor however large its number. In this layer nothing is above it.
|
|
14
|
+
*/
|
|
15
|
+
import './top-layer.css';
|
|
16
|
+
/**
|
|
17
|
+
* The layer itself. `fixed` on a screen with no box of its own to be absolute
|
|
18
|
+
* in (the draft, a peek); `clip` where what is drawn must stay inside the
|
|
19
|
+
* screen's box (the board, whose canvas no zone may scroll).
|
|
20
|
+
*/
|
|
21
|
+
export function TopLayer({ fixed = false, clip = false }) {
|
|
22
|
+
return _jsx("div", { className: "top-layer", "data-board-zoom": "", "data-fixed": fixed ? '' : undefined, "data-clip": clip ? '' : undefined });
|
|
23
|
+
}
|
|
24
|
+
/** The selector of a screen's top layer. */
|
|
25
|
+
const TOP_LAYER = '[data-board-zoom]';
|
|
26
|
+
/** The top layer inside `root`, if it has one. */
|
|
27
|
+
export function topLayerIn(root) {
|
|
28
|
+
return root.querySelector(TOP_LAYER);
|
|
29
|
+
}
|
|
30
|
+
/** The top layer of the screen `el` is on: the nearest one inside any of its ancestors. */
|
|
31
|
+
export function topLayerOf(el) {
|
|
32
|
+
for (let at = el.parentElement; at !== null; at = at.parentElement) {
|
|
33
|
+
const layer = topLayerIn(at);
|
|
34
|
+
if (layer !== null)
|
|
35
|
+
return layer;
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
/** Where `anchor`'s top-left corner is in `layer`'s own coordinates. */
|
|
40
|
+
export function originIn(layer, anchor) {
|
|
41
|
+
const a = anchor.getBoundingClientRect();
|
|
42
|
+
const l = layer.getBoundingClientRect();
|
|
43
|
+
return { left: a.left - l.left, top: a.top - l.top };
|
|
44
|
+
}
|
package/dist/usage.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { targetName, type UsageDeps as ShellUsageDeps } from '@wolffm/ui-shell/usage';
|
|
2
|
+
export { targetName };
|
|
3
|
+
/** The screen a hash shows, by its route's kind; a room's table is its own screen. */
|
|
4
|
+
export declare function screenOf(hash: string): string;
|
|
5
|
+
export declare function startUsage(deps?: Partial<ShellUsageDeps>): () => void;
|
package/dist/usage.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cardtable's own wiring for the shell's generic usage counter (`@hadoku/ui-shell/usage`): the URL
|
|
3
|
+
* to post to and how a route hash names a screen, a room's table counted apart from its room.
|
|
4
|
+
*/
|
|
5
|
+
import { USAGE_BATCH_MAX, USAGE_PATH } from '@wolffm/platform-wire/telemetry';
|
|
6
|
+
import { startUsage as startUsageShell, targetName } from '@wolffm/ui-shell/usage';
|
|
7
|
+
import { apiUrl } from "./http.js";
|
|
8
|
+
import { parseRoute } from "./screens/route.js";
|
|
9
|
+
export { targetName };
|
|
10
|
+
/** The screen a hash shows, by its route's kind; a room's table is its own screen. */
|
|
11
|
+
export function screenOf(hash) {
|
|
12
|
+
const route = parseRoute(hash);
|
|
13
|
+
return route.kind === 'room' && route.tableId !== undefined ? 'room/table' : route.kind;
|
|
14
|
+
}
|
|
15
|
+
export function startUsage(deps = {}) {
|
|
16
|
+
return startUsageShell({ url: apiUrl(USAGE_PATH), screenOf, batchMax: USAGE_BATCH_MAX, ...deps });
|
|
17
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The tab's visibility. */
|
|
2
|
+
export interface PageVisibility {
|
|
3
|
+
hidden(): boolean;
|
|
4
|
+
/** Called on every visibility change. Returns the unsubscribe. */
|
|
5
|
+
onChange(listener: () => void): () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function documentVisibility(doc?: Document | undefined): PageVisibility;
|
|
8
|
+
export interface RereadDeps {
|
|
9
|
+
page?: PageVisibility;
|
|
10
|
+
setInterval?: (fn: () => void, ms: number) => unknown;
|
|
11
|
+
clearInterval?: (handle: unknown) => void;
|
|
12
|
+
}
|
|
13
|
+
/** Calls `read` now, every `ms` while the tab is shown, and once whenever it is shown again. Returns the stop. */
|
|
14
|
+
export declare function rereadWhileVisible(read: () => void, ms: number, deps?: RereadDeps): () => void;
|