@hadoku/game-ui 0.1.160 → 0.1.162
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/room/RoomShell.d.ts
CHANGED
|
@@ -109,13 +109,9 @@ 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,
|
|
112
|
+
export declare function RoomShell({ roomId, 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
|
-
/** `false` keeps the chat open with no Hide chat button — the room's lobby,
|
|
116
|
-
* where the chat is the point. A viewer's saved collapse is ignored there,
|
|
117
|
-
* not cleared, so the match still opens the way they left it. */
|
|
118
|
-
collapsible?: boolean;
|
|
119
115
|
/** Behind a question the page must answer first (`./SessionPrompt.tsx`): the chat cannot be reached. */
|
|
120
116
|
inert?: boolean;
|
|
121
117
|
/** What a room's route shows while it waits, before its content first mounts. Default: nothing. */
|
package/dist/room/RoomShell.js
CHANGED
|
@@ -211,7 +211,7 @@ export function appOrigin() {
|
|
|
211
211
|
* before they have first mounted, they wait for it, showing `fallback`: their first frame is already
|
|
212
212
|
* inside. After that, they show bare while the chrome is not drawn.
|
|
213
213
|
*/
|
|
214
|
-
export function RoomShell({ roomId,
|
|
214
|
+
export function RoomShell({ roomId, inert = false, fallback = null, requireIdentified = false, toolbar, pending = false, children, }) {
|
|
215
215
|
const who = useWhoami();
|
|
216
216
|
const RoomChrome = useRoomChrome();
|
|
217
217
|
// Always inside `AppChrome`'s `HadokuThemeRoot` — see chrome/AppChrome.tsx,
|
|
@@ -241,18 +241,11 @@ export function RoomShell({ roomId, collapsible = true, inert = false, fallback
|
|
|
241
241
|
return (_jsxs(_Fragment, { children: [_jsx(Slot, { host: host }, "bare"), content] }));
|
|
242
242
|
return (
|
|
243
243
|
/*
|
|
244
|
-
*
|
|
245
|
-
* `RoomChrome`
|
|
246
|
-
*
|
|
247
|
-
* outside. `live.css`'s portrait rules key the chat-sheet behaviour off
|
|
248
|
-
* this attribute rather than off `collapsible` turning the chrome's own
|
|
249
|
-
* "Hide chat" button on or off, because `collapsible` is a prop value, not
|
|
250
|
-
* a selector a stylesheet in another file can see — and only present at
|
|
251
|
-
* all when `collapsible` is true, i.e. a match route (`App.tsx`'s
|
|
252
|
-
* `route.kind !== 'room'`), never the room lobby (Settled 10: "the room
|
|
253
|
-
* lobby is unchanged").
|
|
244
|
+
* The chat hides and shows with the chrome's own Hide chat in every phase of a room (the lobby,
|
|
245
|
+
* the draft, the builder, the podium and the match): `RoomChrome`'s `collapsible` stays at its
|
|
246
|
+
* default everywhere, so the control and the viewer's saved choice are the same on every screen.
|
|
254
247
|
*/
|
|
255
|
-
_jsxs(_Fragment, { children: [_jsx("div", { className: "room-shell", "data-testid": "room-shell",
|
|
248
|
+
_jsxs(_Fragment, { children: [_jsx("div", { className: "room-shell", "data-testid": "room-shell", inert: inert || undefined, children: _jsxs(RoomChrome, { roomKey: key, serverOrigin: watchpartyOrigin(), roomOrigin: appOrigin(), userType: who.tier, userId: who.userId, theme: watchpartyTheme(theme), toolbar: toolbarPage ? toolbar : undefined, children: [_jsx(Slot, { host: host }), _jsx("span", { hidden: true, ref: roomFrameRef })] }) }, "chrome"), content] }));
|
|
256
249
|
}
|
|
257
250
|
/** The node {@link RoomShell}'s children are drawn into: it takes no box of its own, so they lay out as its parent's. */
|
|
258
251
|
function createHost() {
|
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,
|
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.162",
|
|
4
|
+
"gitHead": "f4e92f118d1150aa86793fe34d82f5a3bf199a87",
|
|
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.166",
|
|
58
|
+
"@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.166",
|
|
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",
|