@hadoku/game-ui 0.1.179 → 0.1.180
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/front/Gallery.d.ts +10 -8
- package/dist/front/Gallery.js +8 -1
- package/dist/front/shape.js +5 -3
- package/dist/room/look.d.ts +1 -4
- package/dist/room/look.js +66 -16
- package/dist/stale-build.js +6 -4
- package/package.json +5 -6
package/dist/front/Gallery.d.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* The arrow inside a gallery's round button, drawn, not typed: a text ‹ › sits wherever its font
|
|
4
|
-
* puts the glyph in its line box (1.25 px low and 0.4 px aside, measured on Linux; it moves with the
|
|
5
|
-
* system font), so it never centred in the circle. The chevron's box is the viewBox's centre.
|
|
6
|
-
*/
|
|
7
|
-
export declare function ArrowGlyph({ dir }: {
|
|
8
|
-
dir: 'prev' | 'next';
|
|
9
|
-
}): import("react").JSX.Element;
|
|
10
2
|
export interface GalleryPage {
|
|
11
3
|
key: string;
|
|
12
4
|
title: string;
|
|
@@ -20,3 +12,13 @@ export declare function Gallery({ testId, pages, opening }: {
|
|
|
20
12
|
pages: readonly GalleryPage[];
|
|
21
13
|
opening?: string;
|
|
22
14
|
}): import("react").JSX.Element | null;
|
|
15
|
+
/**
|
|
16
|
+
* A gallery before it has its pages, standing in the boxes the gallery lands in: the head with `title`
|
|
17
|
+
* and both arrows, `children` as the page, and the foot with `dots` dots and `action`, as placeholders.
|
|
18
|
+
*/
|
|
19
|
+
export declare function GallerySkeleton({ title, dots, action, children }: {
|
|
20
|
+
title: ReactNode;
|
|
21
|
+
dots: number;
|
|
22
|
+
action?: ReactNode;
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
}): import("react").JSX.Element;
|
package/dist/front/Gallery.js
CHANGED
|
@@ -14,7 +14,7 @@ import { keepPage, stepPage } from "./gallery.js";
|
|
|
14
14
|
* puts the glyph in its line box (1.25 px low and 0.4 px aside, measured on Linux; it moves with the
|
|
15
15
|
* system font), so it never centred in the circle. The chevron's box is the viewBox's centre.
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
function ArrowGlyph({ dir }) {
|
|
18
18
|
return (_jsx("svg", { className: "gallery__chevron", viewBox: "0 0 24 24", "aria-hidden": "true", children: _jsx("path", { d: dir === 'prev' ? 'M15.5 5l-7 7 7 7' : 'M8.5 5l7 7-7 7' }) }));
|
|
19
19
|
}
|
|
20
20
|
/** `opening` is the page shown until the reader turns one; the first page without it. */
|
|
@@ -34,3 +34,10 @@ export function Gallery({ testId, pages, opening }) {
|
|
|
34
34
|
const many = pages.length > 1;
|
|
35
35
|
return (_jsxs(_Fragment, { children: [_jsxs("header", { className: "front-card__head", children: [_jsx("h3", { className: "front-card__title", "data-testid": `${testId}-title`, children: page.title }), many && (_jsxs("span", { className: "gallery__arrows", children: [_jsx("button", { type: "button", className: "gallery__arrow", "aria-label": "Previous", "data-testid": `${testId}-prev`, onClick: () => turn(stepPage(at, -1, pages.length)), children: _jsx(ArrowGlyph, { dir: "prev" }) }), _jsx("button", { type: "button", className: "gallery__arrow", "aria-label": "Next", "data-testid": `${testId}-next`, onClick: () => turn(stepPage(at, 1, pages.length)), children: _jsx(ArrowGlyph, { dir: "next" }) })] }))] }), _jsx("div", { className: "gallery__page", "data-testid": `${testId}-page`, "data-page": page.key, children: page.body }, page.key), (many || page.action !== undefined) && (_jsxs("div", { className: "front-card__foot", children: [many && (_jsx("span", { className: "gallery__dots", children: pages.map((p, i) => (_jsx("button", { type: "button", className: "gallery__dot", "aria-label": p.title, "aria-current": i === at ? 'true' : undefined, "data-testid": `${testId}-dot`, "data-page": p.key, onClick: () => turn(i) }, p.key))) })), page.action] }))] }));
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* A gallery before it has its pages, standing in the boxes the gallery lands in: the head with `title`
|
|
39
|
+
* and both arrows, `children` as the page, and the foot with `dots` dots and `action`, as placeholders.
|
|
40
|
+
*/
|
|
41
|
+
export function GallerySkeleton({ title, dots, action, children }) {
|
|
42
|
+
return (_jsxs(_Fragment, { children: [_jsxs("header", { className: "front-card__head", children: [_jsx("h3", { className: "front-card__title", children: title }), _jsxs("span", { className: "gallery__arrows", children: [_jsx("span", { className: "gallery__arrow ghost", children: _jsx(ArrowGlyph, { dir: "prev" }) }), _jsx("span", { className: "gallery__arrow ghost", children: _jsx(ArrowGlyph, { dir: "next" }) })] })] }), _jsx("div", { className: "gallery__page", children: children }), _jsxs("div", { className: "front-card__foot", children: [_jsx("span", { className: "gallery__dots", children: Array.from({ length: dots }, (_, i) => (_jsx("span", { className: "gallery__dot ghost" }, i))) }), action] })] }));
|
|
43
|
+
}
|
package/dist/front/shape.js
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
* time the page has shown itself. A first visit assumes the live slot is there, as it is whenever a
|
|
6
6
|
* replay is kept.
|
|
7
7
|
*/
|
|
8
|
+
import { appId } from '@wolffm/ui-shell/app-id';
|
|
8
9
|
/** The most room placeholders drawn: enough to fill any window; the rest of a long list is below the fold. */
|
|
9
10
|
export const MAX_ROOM_GHOSTS = 12;
|
|
10
|
-
|
|
11
|
+
/** Per game: bomberman mounts the same front page on this origin. Cardtable's key is the one it always had. */
|
|
12
|
+
const storageKey = () => `${appId()}:front-shape`;
|
|
11
13
|
export const FIRST_VISIT = { live: true, rooms: 6, events: 3 };
|
|
12
14
|
const count = (n, max, fallback) => (typeof n === 'number' && Number.isInteger(n) && n >= 0 ? Math.min(n, max) : fallback);
|
|
13
15
|
export function parseFrontShape(raw) {
|
|
@@ -36,7 +38,7 @@ export function parseFrontShape(raw) {
|
|
|
36
38
|
*/
|
|
37
39
|
export function loadFrontShape() {
|
|
38
40
|
try {
|
|
39
|
-
return parseFrontShape(globalThis.localStorage?.getItem(
|
|
41
|
+
return parseFrontShape(globalThis.localStorage?.getItem(storageKey()) ?? null);
|
|
40
42
|
}
|
|
41
43
|
catch {
|
|
42
44
|
return FIRST_VISIT;
|
|
@@ -44,7 +46,7 @@ export function loadFrontShape() {
|
|
|
44
46
|
}
|
|
45
47
|
export function saveFrontShape(shape) {
|
|
46
48
|
try {
|
|
47
|
-
globalThis.localStorage?.setItem(
|
|
49
|
+
globalThis.localStorage?.setItem(storageKey(), JSON.stringify(shape));
|
|
48
50
|
}
|
|
49
51
|
catch {
|
|
50
52
|
// Not remembered: the next visit draws the first visit's skeleton, and nothing else changes.
|
package/dist/room/look.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { type CSSProperties } from 'react';
|
|
2
1
|
import { type AvatarCosmetics } from '@wolffm/prefs-client/cosmetics';
|
|
3
2
|
import type { Look } from '@wolffm/platform-wire/look';
|
|
4
3
|
import './look.css';
|
|
5
4
|
/** What a person wears, safe to draw, or undefined. */
|
|
6
5
|
export declare function wornOf(look: Look | undefined): AvatarCosmetics | undefined;
|
|
7
|
-
/** `--hc-base` for someone, re-rendering once their colour is known. */
|
|
8
|
-
export declare function usePersonColour(avatarId: string | undefined, look: Look | undefined): CSSProperties;
|
|
9
6
|
/**
|
|
10
7
|
* The overlay a person wears, laid over the face drawn just before it.
|
|
11
8
|
*
|
|
@@ -14,7 +11,7 @@ export declare function usePersonColour(avatarId: string | undefined, look: Look
|
|
|
14
11
|
* the face, and the overlay is drawn beside it or outside its clipping ring
|
|
15
12
|
* (`decorHost`). The renderer places an overlay against a box of `--hc-sz`
|
|
16
13
|
* pixels; that is set from the face's laid-out size, again whenever it or the
|
|
17
|
-
* box around it resizes.
|
|
14
|
+
* box around it resizes, and whenever the face moves (`onceMoved`).
|
|
18
15
|
*/
|
|
19
16
|
export declare const FaceDecor: import("react").NamedExoticComponent<{
|
|
20
17
|
avatarId: string | undefined;
|
package/dist/room/look.js
CHANGED
|
@@ -77,7 +77,7 @@ function personColour(avatarId, picture) {
|
|
|
77
77
|
return (picture === undefined ? null : pictureColour(picture)) ?? (avatarId === undefined ? undefined : characterColours.get(avatarId));
|
|
78
78
|
}
|
|
79
79
|
/** `--hc-base` for someone, re-rendering once their colour is known. */
|
|
80
|
-
|
|
80
|
+
function usePersonColour(avatarId, look) {
|
|
81
81
|
const picture = look?.picture;
|
|
82
82
|
useEffect(() => {
|
|
83
83
|
askCharacters();
|
|
@@ -136,6 +136,49 @@ function anchorToScroller(el) {
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Calls `moved` once, the first time `face` moves on screen, whatever moved it. An overlay is placed by
|
|
141
|
+
* measuring its face, so each way a face can move without changing size left the overlay behind, found
|
|
142
|
+
* one at a time: a hidden member list, a scrolling list (2026-11-18), and petals over a face on the
|
|
143
|
+
* match screen again (2026-11-29), its cause not in the record. Anything that moves a face and resizes
|
|
144
|
+
* neither it, its parent nor its host does it: a flex order turned over, an offset, a sibling's margin.
|
|
145
|
+
* This watches the face itself rather than each cause: an IntersectionObserver
|
|
146
|
+
* whose root is the viewport cut down to the face's own box answers the moment the face leaves it (the
|
|
147
|
+
* technique of floating-ui's `autoUpdate`). A face partly out of sight is watched at the share of it
|
|
148
|
+
* that shows; one wholly out of sight, or not laid out yet, for coming into view.
|
|
149
|
+
*/
|
|
150
|
+
function onceMoved(face, moved) {
|
|
151
|
+
if (typeof IntersectionObserver === 'undefined')
|
|
152
|
+
return () => undefined;
|
|
153
|
+
let io;
|
|
154
|
+
const watch = (threshold) => {
|
|
155
|
+
io?.disconnect();
|
|
156
|
+
const at = face.getBoundingClientRect();
|
|
157
|
+
const page = document.documentElement;
|
|
158
|
+
const inSight = at.width > 0 && at.height > 0 && at.bottom > 0 && at.right > 0 && at.top < page.clientHeight && at.left < page.clientWidth;
|
|
159
|
+
let first = true;
|
|
160
|
+
io = new IntersectionObserver(([seen]) => {
|
|
161
|
+
const ratio = seen?.intersectionRatio ?? 0;
|
|
162
|
+
const settling = first;
|
|
163
|
+
first = false;
|
|
164
|
+
if (inSight && ratio === threshold)
|
|
165
|
+
return;
|
|
166
|
+
if (settling) {
|
|
167
|
+
// Partly clipped where it stands: watch that share.
|
|
168
|
+
if (inSight && ratio > 0 && threshold === 1)
|
|
169
|
+
watch(ratio);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (!inSight && ratio === 0)
|
|
173
|
+
return;
|
|
174
|
+
io?.disconnect();
|
|
175
|
+
moved();
|
|
176
|
+
}, inSight ? { rootMargin: [at.top, page.clientWidth - at.right, page.clientHeight - at.bottom, at.left].map((n) => `${-Math.floor(n)}px`).join(' '), threshold } : { threshold: 0 });
|
|
177
|
+
io.observe(face);
|
|
178
|
+
};
|
|
179
|
+
watch(1);
|
|
180
|
+
return () => io?.disconnect();
|
|
181
|
+
}
|
|
139
182
|
/**
|
|
140
183
|
* The overlay a person wears, laid over the face drawn just before it.
|
|
141
184
|
*
|
|
@@ -144,18 +187,21 @@ function anchorToScroller(el) {
|
|
|
144
187
|
* the face, and the overlay is drawn beside it or outside its clipping ring
|
|
145
188
|
* (`decorHost`). The renderer places an overlay against a box of `--hc-sz`
|
|
146
189
|
* pixels; that is set from the face's laid-out size, again whenever it or the
|
|
147
|
-
* box around it resizes.
|
|
190
|
+
* box around it resizes, and whenever the face moves (`onceMoved`).
|
|
148
191
|
*/
|
|
149
192
|
export const FaceDecor = memo(function FaceDecor({ avatarId, look }) {
|
|
193
|
+
const worn = wornOf(look);
|
|
194
|
+
// Nothing worn draws nothing and asks nothing: no colour is read for a face without an overlay.
|
|
195
|
+
return worn?.overlay === undefined ? null : _jsx(Overlay, { avatarId: avatarId, look: look, html: decorHtml(worn) });
|
|
196
|
+
});
|
|
197
|
+
function Overlay({ avatarId, look, html }) {
|
|
150
198
|
const anchor = useRef(null);
|
|
151
199
|
const ref = useRef(null);
|
|
152
200
|
const [host, setHost] = useState(null);
|
|
153
|
-
const worn = wornOf(look);
|
|
154
|
-
const html = worn?.overlay === undefined ? '' : decorHtml(worn);
|
|
155
201
|
const colour = usePersonColour(avatarId, look);
|
|
156
202
|
useLayoutEffect(() => {
|
|
157
203
|
const face = anchor.current?.previousElementSibling;
|
|
158
|
-
setHost(
|
|
204
|
+
setHost(face instanceof Element ? decorHost(face) : null);
|
|
159
205
|
}, [html]);
|
|
160
206
|
useLayoutEffect(() => {
|
|
161
207
|
const el = ref.current;
|
|
@@ -176,26 +222,30 @@ export const FaceDecor = memo(function FaceDecor({ avatarId, look }) {
|
|
|
176
222
|
el.style.top = `${(fr.top - pr.top) / scale - parent.clientTop + parent.scrollTop}px`;
|
|
177
223
|
el.style.setProperty('--hc-sz', `${fr.width / scale}px`);
|
|
178
224
|
};
|
|
179
|
-
|
|
225
|
+
// Placed again whenever the face moves or a box around it resizes, and watched again from where it is.
|
|
226
|
+
let stopMoves = () => undefined;
|
|
227
|
+
const follow = () => {
|
|
228
|
+
fit();
|
|
229
|
+
stopMoves();
|
|
230
|
+
stopMoves = onceMoved(face, follow);
|
|
231
|
+
};
|
|
232
|
+
follow();
|
|
180
233
|
const stopIdle = idleWhenHidden(el);
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const ro = new ResizeObserver(fit);
|
|
184
|
-
ro.observe(face);
|
|
234
|
+
const ro = typeof ResizeObserver === 'undefined' ? undefined : new ResizeObserver(follow);
|
|
235
|
+
ro?.observe(face);
|
|
185
236
|
if (face.parentElement !== null)
|
|
186
|
-
ro
|
|
237
|
+
ro?.observe(face.parentElement);
|
|
187
238
|
if (host !== null)
|
|
188
|
-
ro
|
|
239
|
+
ro?.observe(host);
|
|
189
240
|
return () => {
|
|
190
|
-
ro
|
|
241
|
+
ro?.disconnect();
|
|
242
|
+
stopMoves();
|
|
191
243
|
stopIdle();
|
|
192
244
|
};
|
|
193
245
|
}, [html, host]);
|
|
194
|
-
if (html === '')
|
|
195
|
-
return null;
|
|
196
246
|
const decor = _jsx("span", { ref: ref, className: "hc-av face-decor", style: colour, "aria-hidden": "true", "data-testid": "face-decor", dangerouslySetInnerHTML: { __html: html } });
|
|
197
247
|
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchor, hidden: true }), host === null ? decor : createPortal(decor, host)] }));
|
|
198
|
-
}
|
|
248
|
+
}
|
|
199
249
|
// ── A name ───────────────────────────────────────────────────────────────────
|
|
200
250
|
/**
|
|
201
251
|
* A person's name, plain, the same for everyone: their name's effect, gradient and font are the
|
package/dist/stale-build.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* sha alone is no reason to reload a page that reads everything. A page that cannot read what the
|
|
14
14
|
* server sent is a different matter, and reloads for any build other than its own.
|
|
15
15
|
*/
|
|
16
|
+
import { appId } from '@wolffm/ui-shell/app-id';
|
|
16
17
|
const RELEASE = /^v(\d+)\.(\d+)\.(\d+)(?:\+.*)?$/;
|
|
17
18
|
/** `[major, minor, patch]` of a build, or null for a build that is not a release's (`unknown`, a named CI build). */
|
|
18
19
|
export function releaseOf(build) {
|
|
@@ -38,7 +39,8 @@ export function serverReleaseIsNewer(page, server) {
|
|
|
38
39
|
export function unreadableMeansStale(page, server) {
|
|
39
40
|
return server === null || server === 'unknown' || server !== page;
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
+
/** Per game, like every key the shell writes: cardtable's is the one it always had. */
|
|
43
|
+
const reloadedFor = () => `${appId()}:reloaded-for-build`;
|
|
42
44
|
/**
|
|
43
45
|
* Claims this tab's one reload for `target`, the server build it reloads to meet. False when this
|
|
44
46
|
* tab already reloaded for that build (the new bundle still could not read it, so a second reload
|
|
@@ -47,13 +49,13 @@ const RELOADED_FOR = 'cardtable:reloaded-for-build';
|
|
|
47
49
|
export function claimReload(target, storage = () => sessionStorage) {
|
|
48
50
|
try {
|
|
49
51
|
const store = storage();
|
|
50
|
-
if (store.getItem(
|
|
52
|
+
if (store.getItem(reloadedFor()) === target)
|
|
51
53
|
return false;
|
|
52
|
-
store.setItem(
|
|
54
|
+
store.setItem(reloadedFor(), target);
|
|
53
55
|
return true;
|
|
54
56
|
}
|
|
55
57
|
catch (err) {
|
|
56
|
-
console.warn(
|
|
58
|
+
console.warn(`[${appId()}] no session storage to guard a reload for a new build with`, err);
|
|
57
59
|
return false;
|
|
58
60
|
}
|
|
59
61
|
}
|
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.180",
|
|
4
|
+
"gitHead": "ec6a435deb61ff7572038839996efa9e04e4a398",
|
|
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.",
|
|
@@ -46,16 +46,15 @@
|
|
|
46
46
|
},
|
|
47
47
|
"publishLeaveOut": [
|
|
48
48
|
"rooms/BundleSlot.tsx",
|
|
49
|
-
"rooms/external-games.tsx"
|
|
50
|
-
"rooms/relay-test-fixture.tsx"
|
|
49
|
+
"rooms/external-games.tsx"
|
|
51
50
|
],
|
|
52
51
|
"peerDependencies": {
|
|
53
52
|
"react": "^19.2.8",
|
|
54
53
|
"react-dom": "^19.2.8"
|
|
55
54
|
},
|
|
56
55
|
"dependencies": {
|
|
57
|
-
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.
|
|
58
|
-
"@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.
|
|
56
|
+
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.184",
|
|
57
|
+
"@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.184",
|
|
59
58
|
"@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.2",
|
|
60
59
|
"@wolffm/rooms-client": "npm:@hadoku/rooms-client@^0.45.145",
|
|
61
60
|
"@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.145",
|