@hadoku/game-ui 0.0.0-stage → 0.1.5

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.
Files changed (113) hide show
  1. package/LICENSE +21 -0
  2. package/dist/chrome/HeaderLinks.d.ts +16 -0
  3. package/dist/chrome/HeaderLinks.js +24 -0
  4. package/dist/components/ActionButton.d.ts +9 -0
  5. package/dist/components/ActionButton.js +49 -0
  6. package/dist/components/Avatar.d.ts +43 -0
  7. package/dist/components/Avatar.js +53 -0
  8. package/dist/components/ConnectionBanner.css +77 -0
  9. package/dist/components/ConnectionBanner.d.ts +33 -0
  10. package/dist/components/ConnectionBanner.js +33 -0
  11. package/dist/components/Modal.css +69 -0
  12. package/dist/components/Modal.d.ts +12 -0
  13. package/dist/components/Modal.js +31 -0
  14. package/dist/components/OverPage.d.ts +4 -0
  15. package/dist/components/OverPage.js +21 -0
  16. package/dist/components/Popover.css +58 -0
  17. package/dist/components/Popover.d.ts +20 -0
  18. package/dist/components/Popover.js +63 -0
  19. package/dist/components/RadioCards.css +178 -0
  20. package/dist/components/RadioCards.d.ts +33 -0
  21. package/dist/components/RadioCards.js +41 -0
  22. package/dist/components/StatusPill.d.ts +16 -0
  23. package/dist/components/StatusPill.js +17 -0
  24. package/dist/components/connection-state.d.ts +32 -0
  25. package/dist/components/connection-state.js +5 -0
  26. package/dist/dom.d.ts +17 -0
  27. package/dist/dom.js +57 -0
  28. package/dist/front/Gallery.d.ts +22 -0
  29. package/dist/front/Gallery.js +48 -0
  30. package/dist/front/PatchNotesCard.d.ts +1 -0
  31. package/dist/front/PatchNotesCard.js +59 -0
  32. package/dist/front/camera.d.ts +80 -0
  33. package/dist/front/camera.js +120 -0
  34. package/dist/front/countdown.d.ts +2 -0
  35. package/dist/front/countdown.js +16 -0
  36. package/dist/front/discordChat.d.ts +22 -0
  37. package/dist/front/discordChat.js +52 -0
  38. package/dist/front/gallery.d.ts +13 -0
  39. package/dist/front/gallery.js +32 -0
  40. package/dist/front/gate.d.ts +23 -0
  41. package/dist/front/gate.js +55 -0
  42. package/dist/front/icons.d.ts +43 -0
  43. package/dist/front/icons.js +99 -0
  44. package/dist/front/patchNotes.d.ts +37 -0
  45. package/dist/front/patchNotes.js +95 -0
  46. package/dist/front/polls.d.ts +24 -0
  47. package/dist/front/polls.js +95 -0
  48. package/dist/front/shape.d.ts +11 -0
  49. package/dist/front/shape.js +52 -0
  50. package/dist/http.d.ts +28 -0
  51. package/dist/http.js +83 -0
  52. package/dist/idle.d.ts +2 -0
  53. package/dist/idle.js +7 -0
  54. package/dist/lazy.d.ts +9 -0
  55. package/dist/lazy.js +63 -0
  56. package/dist/popover.d.ts +13 -0
  57. package/dist/popover.js +39 -0
  58. package/dist/registered.d.ts +5 -0
  59. package/dist/registered.js +6 -0
  60. package/dist/restart-notice.d.ts +20 -0
  61. package/dist/restart-notice.js +54 -0
  62. package/dist/room/RoomShell.d.ts +116 -0
  63. package/dist/room/RoomShell.js +222 -0
  64. package/dist/room/SessionPrompt.d.ts +12 -0
  65. package/dist/room/SessionPrompt.js +54 -0
  66. package/dist/room/avatar.d.ts +31 -0
  67. package/dist/room/avatar.js +60 -0
  68. package/dist/room/look.css +13 -0
  69. package/dist/room/look.d.ts +35 -0
  70. package/dist/room/look.js +189 -0
  71. package/dist/room/seatsOpen.d.ts +7 -0
  72. package/dist/room/seatsOpen.js +37 -0
  73. package/dist/room/session.d.ts +26 -0
  74. package/dist/room/session.js +108 -0
  75. package/dist/room/socket-options.d.ts +33 -0
  76. package/dist/room/socket-options.js +40 -0
  77. package/dist/room/tab-id.d.ts +6 -0
  78. package/dist/room/tab-id.js +90 -0
  79. package/dist/room/whoami.d.ts +15 -0
  80. package/dist/room/whoami.js +48 -0
  81. package/dist/rooms/bundle-slot.fixture.d.ts +11 -0
  82. package/dist/rooms/bundle-slot.fixture.js +21 -0
  83. package/dist/rooms/game-clients.d.ts +12 -0
  84. package/dist/rooms/game-clients.js +30 -0
  85. package/dist/rooms/game-setup.d.ts +63 -0
  86. package/dist/rooms/game-setup.js +33 -0
  87. package/dist/rooms/relay-channel.d.ts +29 -0
  88. package/dist/rooms/relay-channel.js +123 -0
  89. package/dist/rooms/screen/RoomShell.d.ts +33 -0
  90. package/dist/rooms/screen/RoomShell.js +7 -0
  91. package/dist/screens/route.d.ts +143 -0
  92. package/dist/screens/route.js +359 -0
  93. package/dist/settings/Settings.d.ts +39 -0
  94. package/dist/settings/Settings.js +131 -0
  95. package/dist/settings/TrimScreen.d.ts +2 -0
  96. package/dist/settings/TrimScreen.js +29 -0
  97. package/dist/settings/settings.css +116 -0
  98. package/dist/settings/siteTrim.d.ts +3 -0
  99. package/dist/settings/siteTrim.js +9 -0
  100. package/dist/settings/trim-screen.css +30 -0
  101. package/dist/sound/index.d.ts +12 -0
  102. package/dist/sound/index.js +34 -0
  103. package/dist/stale-build.d.ts +16 -0
  104. package/dist/stale-build.js +59 -0
  105. package/dist/top-layer.css +22 -0
  106. package/dist/topLayer.d.ts +19 -0
  107. package/dist/topLayer.js +44 -0
  108. package/dist/usage.d.ts +5 -0
  109. package/dist/usage.js +17 -0
  110. package/dist/visible.d.ts +14 -0
  111. package/dist/visible.js +35 -0
  112. package/package.json +42 -4
  113. package/README.md +0 -3
@@ -0,0 +1,120 @@
1
+ /*
2
+ * The front card's camera: which square of the board the card shows (`FeaturedMatch.tsx`).
3
+ *
4
+ * The operator, 2026-10-29: *"a default capture region in the bottom left corner, and then
5
+ * temporary capture regions for when the cursor exits the default region"* — because *"the player
6
+ * might have their mouse cursor parked somewhere outside of view of the bottom left box because they
7
+ * are reading something or maybe are afk. in that case we should move the camera to center on their
8
+ * cursor and eventually reset back to the standard box once the cursor spends time in there again"*.
9
+ *
10
+ * - The default capture region is the board's bottom-left {@link CameraConfig.corner} square: the active player's
11
+ * avatar, life, graveyard and the near half of their hand and battlefield.
12
+ * - The cursor outside the default region's inner square ({@link inDefaultRegion}: its outer
13
+ * {@link CameraConfig.edgeBand} counts as outside) for {@link CameraConfig.temporaryAfterMs} straight: a temporary
14
+ * capture region opens, the same square centred on the cursor (kept on the board), and follows the
15
+ * cursor while it stays out. A stroke or a drag that comes back sooner opens none.
16
+ * - The cursor back inside that inner square (or gone) for {@link CameraConfig.defaultAfterMs} straight: the
17
+ * temporary region retires, and the camera returns to the default one.
18
+ * - Every move is a pan ({@link panStep}): from rest, pulled toward its region harder the further it
19
+ * is, never past it — never a jump, except a turn change: the board flips to the new active player,
20
+ * and the camera starts on their default region.
21
+ *
22
+ * Every number above is a field of {@link CAMERA}, and a viewer can override it from the hash.
23
+ *
24
+ * Board coordinates throughout: pixels of `LiveBoard`'s own 1280×800, origin top-left.
25
+ */
26
+ export const BOARD_WIDTH = 1280;
27
+ export const BOARD_HEIGHT = 800;
28
+ export const CAMERA = Object.freeze({
29
+ temporaryAfterMs: 500,
30
+ defaultAfterMs: 1000,
31
+ edgeBand: 0.2,
32
+ panSettleMs: 975,
33
+ corner: 540,
34
+ });
35
+ /**
36
+ * The hash keys a viewer can set, each with its config field and the range it is clamped to:
37
+ * `#cam=after:400,back:800,band:0.25,t95:900,corner:600` (any subset, any order).
38
+ */
39
+ const HASH_KEYS = {
40
+ after: { field: 'temporaryAfterMs', min: 0, max: 10_000 },
41
+ back: { field: 'defaultAfterMs', min: 0, max: 10_000 },
42
+ band: { field: 'edgeBand', min: 0, max: 0.45 },
43
+ t95: { field: 'panSettleMs', min: 50, max: 10_000 },
44
+ corner: { field: 'corner', min: 300, max: BOARD_HEIGHT },
45
+ };
46
+ /**
47
+ * {@link CAMERA}, with whatever the page's hash overrides for this viewer only: `cam=` followed by
48
+ * `key:value` pairs joined by commas, anywhere in the hash (`#cam=…`, `#/?cam=…`). Unknown keys and
49
+ * values that are not numbers are ignored; the rest are clamped to their range.
50
+ */
51
+ export function cameraConfigFromHash(hash) {
52
+ const config = { ...CAMERA };
53
+ const spec = /(?:^|[#?&/])cam=([^&#]*)/.exec(hash)?.[1];
54
+ if (spec === undefined)
55
+ return config;
56
+ for (const pair of decodeURIComponent(spec).split(',')) {
57
+ const [key, raw] = pair.split(':').map((part) => part.trim());
58
+ const known = key === undefined ? undefined : HASH_KEYS[key];
59
+ const value = raw === undefined || raw === '' ? NaN : Number(raw);
60
+ if (known === undefined || !Number.isFinite(value))
61
+ continue;
62
+ config[known.field] = clamp(value, known.min, known.max);
63
+ }
64
+ return config;
65
+ }
66
+ /** A critically damped spring from rest covers 95% of the way when ωt ≈ 4.744. */
67
+ const SPRING_95 = 4.744;
68
+ /** The default capture region's top-left corner. */
69
+ export const defaultRegion = (config = CAMERA) => ({ x: 0, y: BOARD_HEIGHT - config.corner });
70
+ export function initialCamera(now, bottom, config = CAMERA) {
71
+ return { at: defaultRegion(config), vel: { x: 0, y: 0 }, region: 'default', since: null, bottom, now };
72
+ }
73
+ /**
74
+ * Whether `p` is home: inside the default capture region's inner square, the {@link CameraConfig.edgeBand} at its
75
+ * open edges counting as outside. The same test both ways, so a cursor resting in the band never
76
+ * swings the camera out and back.
77
+ */
78
+ export function inDefaultRegion(p, config = CAMERA) {
79
+ const inner = config.corner * (1 - config.edgeBand);
80
+ return p.x < inner && p.y > BOARD_HEIGHT - inner;
81
+ }
82
+ /** A temporary capture region: the square centred on `p`, kept on the board. */
83
+ export function temporaryRegion(p, config = CAMERA) {
84
+ const side = config.corner;
85
+ return { x: clamp(p.x - side / 2, 0, BOARD_WIDTH - side), y: clamp(p.y - side / 2, 0, BOARD_HEIGHT - side) };
86
+ }
87
+ /**
88
+ * One axis of a pan, `dt` ms on: a critically damped spring toward `target` (acceleration
89
+ * ω²·(target − pos) − 2ω·vel), so it starts from rest, pulls harder the further it has to go, and
90
+ * comes to rest on the target without passing it. Its exact solution over the step, not an
91
+ * integration, so no frame rate can make it overshoot; a target that moves between steps keeps the
92
+ * velocity it had, so a pan following a moving cursor never restarts.
93
+ */
94
+ export function panStep(pos, vel, target, dt, settleMs = CAMERA.panSettleMs) {
95
+ const omega = SPRING_95 / settleMs;
96
+ const e = pos - target;
97
+ const b = vel + omega * e;
98
+ const decay = Math.exp(-omega * dt);
99
+ return { pos: target + (e + b * dt) * decay, vel: (vel - omega * b * dt) * decay };
100
+ }
101
+ /** One step: `cursor` is the active player's cursor as the board draws it now (null when none is drawn). */
102
+ export function stepCamera(state, now, cursor, bottom, config = CAMERA) {
103
+ if (bottom !== state.bottom)
104
+ return initialCamera(now, bottom, config);
105
+ const outside = cursor !== null && !inDefaultRegion(cursor, config);
106
+ const calling = state.region === 'default' ? outside : !outside;
107
+ const since = calling ? (state.since ?? now) : null;
108
+ let region = state.region;
109
+ if (since !== null && now - since >= (region === 'default' ? config.temporaryAfterMs : config.defaultAfterMs))
110
+ region = region === 'default' ? 'temporary' : 'default';
111
+ // A temporary region follows the cursor; with the cursor gone it holds where it is until it retires.
112
+ const target = region === 'default' ? defaultRegion(config) : cursor !== null ? temporaryRegion(cursor, config) : state.at;
113
+ const dt = Math.max(0, now - state.now);
114
+ const x = panStep(state.at.x, state.vel.x, target.x, dt, config.panSettleMs);
115
+ const y = panStep(state.at.y, state.vel.y, target.y, dt, config.panSettleMs);
116
+ return { at: { x: x.pos, y: y.pos }, vel: { x: x.vel, y: y.vel }, region, since: region === state.region ? since : null, bottom, now };
117
+ }
118
+ function clamp(v, lo, hi) {
119
+ return Math.max(lo, Math.min(hi, v));
120
+ }
@@ -0,0 +1,2 @@
1
+ /** `in 2d 4h`, `in 3h 10m`, `in 25m`, or `now` once it has started. */
2
+ export declare function countdown(startsAt: string, now: number): string;
@@ -0,0 +1,16 @@
1
+ /* How long until an event starts, as the Upcoming card, the calendar and a scheduled room's card all say it. */
2
+ /** `in 2d 4h`, `in 3h 10m`, `in 25m`, or `now` once it has started. */
3
+ export function countdown(startsAt, now) {
4
+ const ms = Date.parse(startsAt) - now;
5
+ if (!(ms > 0))
6
+ return 'now';
7
+ const minutes = Math.ceil(ms / 60_000);
8
+ const days = Math.floor(minutes / (24 * 60));
9
+ const hours = Math.floor((minutes % (24 * 60)) / 60);
10
+ const mins = minutes % 60;
11
+ if (days > 0)
12
+ return hours > 0 ? `in ${days}d ${hours}h` : `in ${days}d`;
13
+ if (hours > 0)
14
+ return mins > 0 ? `in ${hours}h ${mins}m` : `in ${hours}h`;
15
+ return `in ${mins}m`;
16
+ }
@@ -0,0 +1,22 @@
1
+ import type { DiscordMessage } from '@wolffm/platform-wire/discord';
2
+ /** Discord starts a new header after this long, even for the same author. */
3
+ export declare const GROUP_GAP_MS: number;
4
+ export interface ChatGroup {
5
+ author: string;
6
+ /** The first message's avatar and name colour: Discord draws the header from it. */
7
+ avatar: string | null;
8
+ color: string | null;
9
+ /** The first message's `at`, for the header's timestamp. */
10
+ at: string;
11
+ texts: string[];
12
+ }
13
+ /** `messages` (newest last) as Discord groups them. */
14
+ export declare function groupMessages(messages: readonly DiscordMessage[]): ChatGroup[];
15
+ /** `Today at 3:14 PM`, `Yesterday at 3:14 PM`, or `10/27/2026 3:14 PM` — Discord's header wording, in the viewer's own time zone. */
16
+ export declare function discordTime(at: string, now?: Date, locale?: string): string;
17
+ /** How many default-avatar colours `.discord-chat__avatar--N` in `front.css` defines. */
18
+ export declare const AVATAR_COLOURS = 6;
19
+ /** Which default-avatar colour `author` gets: the same one every visit. */
20
+ export declare function avatarColour(author: string): number;
21
+ /** The letter on the avatar: the name's first letter or digit, upper-cased; `?` for a name without one. */
22
+ export declare function avatarInitial(author: string): string;
@@ -0,0 +1,52 @@
1
+ /*
2
+ * The wildcard's Discord chat (`./WildcardCard.tsx`), laid out the way Discord's own client lays out
3
+ * a channel: consecutive messages from one author within seven minutes share a header, and each
4
+ * header carries Discord's own timestamp wording. Avatars and name colours are the real ones, from
5
+ * ArchiveBot (`@hadoku/platform-wire/discord`); only when it could not read an avatar does the author
6
+ * get their initial on one of Discord's default-avatar colours, picked from their name.
7
+ */
8
+ /** Discord starts a new header after this long, even for the same author. */
9
+ export const GROUP_GAP_MS = 7 * 60_000;
10
+ /** `messages` (newest last) as Discord groups them. */
11
+ export function groupMessages(messages) {
12
+ const groups = [];
13
+ let lastAt = Number.NaN;
14
+ for (const m of messages) {
15
+ const at = Date.parse(m.at);
16
+ const prev = groups.at(-1);
17
+ if (prev !== undefined && prev.author === m.author && at - lastAt < GROUP_GAP_MS)
18
+ prev.texts.push(m.text);
19
+ else
20
+ groups.push({ author: m.author, avatar: m.avatar, color: m.color, at: m.at, texts: [m.text] });
21
+ lastAt = at;
22
+ }
23
+ return groups;
24
+ }
25
+ /** `Today at 3:14 PM`, `Yesterday at 3:14 PM`, or `10/27/2026 3:14 PM` — Discord's header wording, in the viewer's own time zone. */
26
+ export function discordTime(at, now = new Date(), locale) {
27
+ const when = new Date(at);
28
+ if (Number.isNaN(when.getTime()))
29
+ return '';
30
+ const time = when.toLocaleTimeString(locale, { hour: 'numeric', minute: '2-digit' });
31
+ const day = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
32
+ const days = Math.round((day(now) - day(when)) / 86_400_000);
33
+ if (days === 0)
34
+ return `Today at ${time}`;
35
+ if (days === 1)
36
+ return `Yesterday at ${time}`;
37
+ return `${when.toLocaleDateString(locale)} ${time}`;
38
+ }
39
+ /** How many default-avatar colours `.discord-chat__avatar--N` in `front.css` defines. */
40
+ export const AVATAR_COLOURS = 6;
41
+ /** Which default-avatar colour `author` gets: the same one every visit. */
42
+ export function avatarColour(author) {
43
+ let hash = 0;
44
+ for (const ch of author)
45
+ hash = (hash * 31 + (ch.codePointAt(0) ?? 0)) >>> 0;
46
+ return hash % AVATAR_COLOURS;
47
+ }
48
+ /** The letter on the avatar: the name's first letter or digit, upper-cased; `?` for a name without one. */
49
+ export function avatarInitial(author) {
50
+ const first = /[\p{L}\p{N}]/u.exec(author);
51
+ return first === null ? '?' : first[0].toUpperCase();
52
+ }
@@ -0,0 +1,13 @@
1
+ /** How far a sideways drag must travel to turn the page. */
2
+ export declare const SWIPE_PX = 40;
3
+ /** One page on from `index` (`delta` ±1), wrapping at both ends. */
4
+ export declare function stepPage(index: number, delta: number, count: number): number;
5
+ /** A drag of `dx`×`dy` px as a page step: ±1 past the threshold, 0 for a short or mostly vertical one (scrolling a list). */
6
+ export declare function swipeStep(dx: number, dy: number): -1 | 0 | 1;
7
+ /**
8
+ * The Upcoming card's page as the front page opens: Polls when it has something and Calendar has
9
+ * nothing (the operator, 2026-11-04), else Calendar.
10
+ */
11
+ export declare function upcomingOpensOn(calendar: number, polls: number): 'calendar' | 'polls';
12
+ /** Where the reader is once the pages change: the page they were on (`key`), else `fallback`. */
13
+ export declare function keepPage(keys: readonly string[], key: string | null, fallback: number): number;
@@ -0,0 +1,32 @@
1
+ /*
2
+ * The front cards' manual gallery (`./Gallery.tsx`): pages the reader flips with the arrows, the
3
+ * dots or a swipe, and never on a timer. The pure steps, so they are tested without mounting it.
4
+ */
5
+ /** How far a sideways drag must travel to turn the page. */
6
+ export const SWIPE_PX = 40;
7
+ /** One page on from `index` (`delta` ±1), wrapping at both ends. */
8
+ export function stepPage(index, delta, count) {
9
+ if (count <= 1)
10
+ return 0;
11
+ return (((index + delta) % count) + count) % count;
12
+ }
13
+ /** A drag of `dx`×`dy` px as a page step: ±1 past the threshold, 0 for a short or mostly vertical one (scrolling a list). */
14
+ export function swipeStep(dx, dy) {
15
+ if (Math.abs(dx) < SWIPE_PX || Math.abs(dy) > Math.abs(dx))
16
+ return 0;
17
+ return dx < 0 ? 1 : -1;
18
+ }
19
+ /**
20
+ * The Upcoming card's page as the front page opens: Polls when it has something and Calendar has
21
+ * nothing (the operator, 2026-11-04), else Calendar.
22
+ */
23
+ export function upcomingOpensOn(calendar, polls) {
24
+ return calendar === 0 && polls > 0 ? 'polls' : 'calendar';
25
+ }
26
+ /** Where the reader is once the pages change: the page they were on (`key`), else `fallback`. */
27
+ export function keepPage(keys, key, fallback) {
28
+ const at = key === null ? -1 : keys.indexOf(key);
29
+ if (at >= 0)
30
+ return at;
31
+ return keys.length === 0 ? 0 : Math.min(fallback, keys.length - 1);
32
+ }
@@ -0,0 +1,23 @@
1
+ import { type FrontShape } from './shape.js';
2
+ /**
3
+ * The parts that read before they can draw. Patch notes ship in the bundle and never wait. `trim` is
4
+ * the site's look (`../settings/siteTrim.ts`), drawn on the whole page: the page is not shown before it.
5
+ */
6
+ export type FrontPart = 'rooms' | 'live' | 'upcoming' | 'wildcard' | 'trim';
7
+ /** The longest the page waits on a slow part before showing the rest. The wildcard's own wait is 2 s. */
8
+ export declare const HOLD_MS = 2500;
9
+ export interface FrontGate {
10
+ /** The page has shown itself: a ready part may draw. */
11
+ revealed: boolean;
12
+ /** A part has its answer. */
13
+ settle: (part: FrontPart) => void;
14
+ /** The page's shape last visit (`./shape.ts`): what the skeleton draws. */
15
+ shape: FrontShape;
16
+ /** A part says what it drew this time, for the next visit's skeleton. */
17
+ remember: (seen: Partial<FrontShape>) => void;
18
+ }
19
+ export declare const FrontGateContext: import("react").Context<FrontGate>;
20
+ /** The gate itself, held by the front page: revealed once every part has settled, or `HOLD_MS` has passed. */
21
+ export declare function useFrontGateState(holdMs?: number): FrontGate;
22
+ /** Whether `part` draws its content now: it is ready, and the page has shown itself. */
23
+ export declare function usePartShown(part: FrontPart, ready: boolean): boolean;
@@ -0,0 +1,55 @@
1
+ /*
2
+ * The front page shows itself once: every part that reads something stands as its skeleton until
3
+ * every one of them has its answer, then they all crossfade in together (`../components/Reveal.tsx`)
4
+ * — the operator, 2026-10-31: *"a loading skeleton … that waits for things to be ready"*. Measured
5
+ * before: the parts arrived one at a time over two seconds, and the live slot's late answer moved
6
+ * every card beside it (`e2e/front-skeleton.spec.ts`).
7
+ *
8
+ * A slow part never holds the page past `HOLD_MS`: the page shows what it has, and the late part
9
+ * stays a skeleton in its own box until its answer lands, then fades in there alone.
10
+ *
11
+ * Outside the front page (a test mounting one card, a card on another screen) there is no gate: a
12
+ * part shows the moment it is ready.
13
+ */
14
+ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
15
+ import { FIRST_VISIT, loadFrontShape, saveFrontShape } from "./shape.js";
16
+ const PARTS = ['rooms', 'live', 'upcoming', 'wildcard', 'trim'];
17
+ /** The longest the page waits on a slow part before showing the rest. The wildcard's own wait is 2 s. */
18
+ export const HOLD_MS = 2_500;
19
+ const UNGATED = { revealed: true, settle: () => undefined, shape: FIRST_VISIT, remember: () => undefined };
20
+ export const FrontGateContext = createContext(UNGATED);
21
+ /** The gate itself, held by the front page: revealed once every part has settled, or `HOLD_MS` has passed. */
22
+ export function useFrontGateState(holdMs = HOLD_MS) {
23
+ const [waiting, setWaiting] = useState(() => new Set(PARTS));
24
+ const [held, setHeld] = useState(false);
25
+ useEffect(() => {
26
+ const timer = setTimeout(() => setHeld(true), holdMs);
27
+ return () => clearTimeout(timer);
28
+ }, [holdMs]);
29
+ const settle = useCallback((part) => {
30
+ setWaiting((prev) => {
31
+ if (!prev.has(part))
32
+ return prev;
33
+ const next = new Set(prev);
34
+ next.delete(part);
35
+ return next;
36
+ });
37
+ }, []);
38
+ const shape = useState(loadFrontShape)[0];
39
+ const seen = useRef(shape);
40
+ const remember = useCallback((next) => {
41
+ seen.current = { ...seen.current, ...next };
42
+ saveFrontShape(seen.current);
43
+ }, []);
44
+ const revealed = held || waiting.size === 0;
45
+ return useMemo(() => ({ revealed, settle, shape, remember }), [revealed, settle, shape, remember]);
46
+ }
47
+ /** Whether `part` draws its content now: it is ready, and the page has shown itself. */
48
+ export function usePartShown(part, ready) {
49
+ const { revealed, settle } = useContext(FrontGateContext);
50
+ useEffect(() => {
51
+ if (ready)
52
+ settle(part);
53
+ }, [ready, part, settle]);
54
+ return revealed && ready;
55
+ }
@@ -0,0 +1,43 @@
1
+ /** A draft room: pick and pass — a card with the pass arrows round it. */
2
+ export declare function DraftIcon({ size }: {
3
+ size?: number;
4
+ }): import("react").JSX.Element;
5
+ /** A constructed room: a deck, stacked. */
6
+ export declare function ConstructedIcon({ size }: {
7
+ size?: number;
8
+ }): import("react").JSX.Element;
9
+ /** A tournament, drawn solid gold by its own CSS rather than stroke-only, so it reads at a glance. */
10
+ export declare function TrophyIcon({ size }: {
11
+ size?: number;
12
+ }): import("react").JSX.Element;
13
+ /** A password-protected room: a padlock. */
14
+ export declare function LockIcon({ size }: {
15
+ size?: number;
16
+ }): import("react").JSX.Element;
17
+ /** A seat count. */
18
+ export declare function PersonIcon({ size }: {
19
+ size?: number;
20
+ }): import("react").JSX.Element;
21
+ /** Classic: crossed swords — blade, point, guard, grip and pommel each. */
22
+ export declare function SwordsIcon({ size }: {
23
+ size?: number;
24
+ }): import("react").JSX.Element;
25
+ /** Gauntlet: a staircase of eras. */
26
+ export declare function StaircaseIcon({ size }: {
27
+ size?: number;
28
+ }): import("react").JSX.Element;
29
+ /** All Random: a die. */
30
+ export declare function DieIcon({ size }: {
31
+ size?: number;
32
+ }): import("react").JSX.Element;
33
+ /** A draft room's background: the pod — eight seats round a table, each passing its pack on. */
34
+ export declare function PodScene({ size }: {
35
+ size?: number;
36
+ }): import("react").JSX.Element;
37
+ /**
38
+ * A constructed room's background: two decks across the table, a spark between them. Every card is
39
+ * masked by the cards on top of it, so a stack reads as solid cards rather than a tangle of outlines.
40
+ */
41
+ export declare function DecksFacingScene({ size }: {
42
+ size?: number;
43
+ }): import("react").JSX.Element;
@@ -0,0 +1,99 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * The front page's own glyphs — inline stroke SVGs, never a card image and never a WotC mark
4
+ * (AGENTS.md). Each one is `aria-label` AND `title`-ed, so a screen reader and a mouse hover both
5
+ * learn the same word, and no caption is written beside it (`no-explanatory-ui-text`).
6
+ *
7
+ * Kept to exactly the set the room card and the banner draw (`docs/planning/wave77-2026-10-27.md`
8
+ * §A): a draft is a card with the pass arrows round it, a constructed table is a stacked deck, a
9
+ * tournament is a trophy, a seat count is a person, and each Constructed mode has its own mark —
10
+ * Classic crossed swords, Gauntlet a staircase, All Random a die. The carousel's arrows and dot are
11
+ * drawn here too, since the wildcard card (`./WildcardCard.tsx`) is the only other place that needs one.
12
+ *
13
+ * The room card's large faint background is a scene of its own, not a glyph scaled up (the operator
14
+ * picked them, 2026-10-27): a draft is the pod passing packs, a constructed room two decks across the
15
+ * table.
16
+ */
17
+ import { useId } from 'react';
18
+ /** Every glyph's own box, so a row of them lines up without each caller picking a size. */
19
+ function Glyph({ label, size, children }) {
20
+ return (_jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", role: "img", "aria-label": label, children: [_jsx("title", { children: label }), children] }));
21
+ }
22
+ /** A draft room: pick and pass — a card with the pass arrows round it. */
23
+ export function DraftIcon({ size = 18 }) {
24
+ return (_jsxs(Glyph, { label: "Draft", size: size, children: [_jsx("rect", { x: "8.5", y: "7", width: "7", height: "10", rx: "1" }), _jsx("path", { d: "M19.5 9.5A8 8 0 0 0 6 5.6" }), _jsx("path", { d: "M6 2.6v3h3" }), _jsx("path", { d: "M4.5 14.5A8 8 0 0 0 18 18.4" }), _jsx("path", { d: "M18 21.4v-3h-3" })] }));
25
+ }
26
+ /** A constructed room: a deck, stacked. */
27
+ export function ConstructedIcon({ size = 18 }) {
28
+ return (_jsxs(Glyph, { label: "Constructed", size: size, children: [_jsx("rect", { x: "3.5", y: "8", width: "11", height: "13", rx: "1.2" }), _jsx("path", { d: "M5.5 8V6.2A1.2 1.2 0 0 1 6.7 5h9.6a1.2 1.2 0 0 1 1.2 1.2v11.6a1.2 1.2 0 0 1-1.2 1.2h-1.8" }), _jsx("path", { d: "M8 5V3.2A1.2 1.2 0 0 1 9.2 2h9.6A1.2 1.2 0 0 1 20 3.2v11.6a1.2 1.2 0 0 1-1.2 1.2h-1.3" })] }));
29
+ }
30
+ /** A tournament, drawn solid gold by its own CSS rather than stroke-only, so it reads at a glance. */
31
+ export function TrophyIcon({ size = 16 }) {
32
+ return (_jsxs(Glyph, { label: "Tournament", size: size, children: [_jsx("path", { d: "M8 4h8v5a4 4 0 0 1-8 0V4Z" }), _jsx("path", { d: "M8 5H5.5A1.5 1.5 0 0 0 4 6.5 3.5 3.5 0 0 0 7.5 10H8" }), _jsx("path", { d: "M16 5h2.5A1.5 1.5 0 0 1 20 6.5 3.5 3.5 0 0 1 16.5 10H16" }), _jsx("path", { d: "M12 13v3" }), _jsx("path", { d: "M8.5 20h7" }), _jsx("path", { d: "M9.5 20c0-1.8.9-2.7 2.5-3 1.6.3 2.5 1.2 2.5 3" })] }));
33
+ }
34
+ /** A password-protected room: a padlock. */
35
+ export function LockIcon({ size = 15 }) {
36
+ return (_jsxs(Glyph, { label: "Locked", size: size, children: [_jsx("rect", { x: "5", y: "11", width: "14", height: "10", rx: "2" }), _jsx("path", { d: "M8 11V7a4 4 0 0 1 8 0v4" })] }));
37
+ }
38
+ /** A seat count. */
39
+ export function PersonIcon({ size = 14 }) {
40
+ return (_jsxs(Glyph, { label: "Seats", size: size, children: [_jsx("circle", { cx: "12", cy: "8", r: "3.2" }), _jsx("path", { d: "M5.5 20c0-3.6 2.9-6 6.5-6s6.5 2.4 6.5 6" })] }));
41
+ }
42
+ /** Classic: crossed swords — blade, point, guard, grip and pommel each. */
43
+ export function SwordsIcon({ size = 14 }) {
44
+ return (_jsxs(Glyph, { label: "Classic", size: size, children: [_jsx("path", { d: "M20 4L9 15M20 4h-3.2M20 4v3.2M6.4 12.4l5.2 5.2M9 15l-4 4" }), _jsx("circle", { cx: "4.3", cy: "19.7", r: "0.9" }), _jsx("path", { d: "M4 4l11 11M4 4h3.2M4 4v3.2M17.6 12.4l-5.2 5.2M15 15l4 4" }), _jsx("circle", { cx: "19.7", cy: "19.7", r: "0.9" })] }));
45
+ }
46
+ /** Gauntlet: a staircase of eras. */
47
+ export function StaircaseIcon({ size = 14 }) {
48
+ return (_jsx(Glyph, { label: "Gauntlet", size: size, children: _jsx("path", { d: "M4 20v-4h4v-4h4v-4h4v-4h4" }) }));
49
+ }
50
+ /** All Random: a die. */
51
+ export function DieIcon({ size = 14 }) {
52
+ return (_jsxs(Glyph, { label: "All Random", size: size, children: [_jsx("rect", { x: "4", y: "4", width: "16", height: "16", rx: "2.5" }), _jsx("circle", { cx: "9", cy: "9", r: "1", fill: "currentColor", stroke: "none" }), _jsx("circle", { cx: "15", cy: "9", r: "1", fill: "currentColor", stroke: "none" }), _jsx("circle", { cx: "12", cy: "12", r: "1", fill: "currentColor", stroke: "none" }), _jsx("circle", { cx: "9", cy: "15", r: "1", fill: "currentColor", stroke: "none" }), _jsx("circle", { cx: "15", cy: "15", r: "1", fill: "currentColor", stroke: "none" })] }));
53
+ }
54
+ /** A scene's own box: 160 units square, thin strokes, drawn large and faint behind a room card. */
55
+ function Scene({ size, children }) {
56
+ return (_jsx("svg", { width: size, height: size, viewBox: "0 0 160 160", fill: "none", stroke: "currentColor", strokeWidth: 1.6, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: children }));
57
+ }
58
+ const POD_SEATS = 8;
59
+ const POD_SEAT_R = 56;
60
+ const POD_ARROW_R = 41;
61
+ const at = (r, a) => `${(80 + r * Math.cos(a)).toFixed(1)} ${(80 + r * Math.sin(a)).toFixed(1)}`;
62
+ /** Each seat of the pod: a card turned to face the table, and the arc that passes its pack on. */
63
+ const POD = Array.from({ length: POD_SEATS }, (_, i) => {
64
+ const a = (i / POD_SEATS) * Math.PI * 2 - Math.PI / 2;
65
+ const [cx, cy] = [80 + POD_SEAT_R * Math.cos(a), 80 + POD_SEAT_R * Math.sin(a)];
66
+ const end = a + (Math.PI * 2) / POD_SEATS - 0.26;
67
+ const head = end - 0.12;
68
+ return {
69
+ seat: { x: cx - 8, y: cy - 11, turn: `rotate(${((a * 180) / Math.PI + 90).toFixed(1)} ${cx.toFixed(1)} ${cy.toFixed(1)})`, line: `M${(cx - 5).toFixed(1)} ${(cy - 6).toFixed(1)}h10` },
70
+ pass: `M${at(POD_ARROW_R, a + 0.26)}A${POD_ARROW_R} ${POD_ARROW_R} 0 0 1 ${at(POD_ARROW_R, end)}`,
71
+ head: `M${at(POD_ARROW_R + 3.5, head)}L${at(POD_ARROW_R, end)}L${at(POD_ARROW_R - 3.5, head)}`,
72
+ };
73
+ });
74
+ /** A draft room's background: the pod — eight seats round a table, each passing its pack on. */
75
+ export function PodScene({ size = 170 }) {
76
+ return (_jsxs(Scene, { size: size, children: [_jsx("circle", { cx: "80", cy: "80", r: "26" }), POD.map(({ seat, pass, head }) => (_jsxs("g", { children: [_jsxs("g", { transform: seat.turn, children: [_jsx("rect", { x: seat.x, y: seat.y, width: "16", height: "22", rx: "1.6" }), _jsx("path", { d: seat.line })] }), _jsx("path", { d: pass }), _jsx("path", { d: head })] }, pass)))] }));
77
+ }
78
+ const DECK_CARD = { w: 54, h: 76 };
79
+ /** Four cards squared up, each nudged up and along `dir` from the one under it. */
80
+ const deck = (x, y, r, dir) => [0, 1, 2, 3].map((k) => ({ x: x + k * 2.6 * dir, y: y - k * 3, r }));
81
+ /** Both decks, bottom card first: the near one low left, the far one high right. */
82
+ const FACING = [...deck(6, 78, -10, 1), ...deck(98, 22, 10, -1)];
83
+ const turnOf = ({ x, y, r }) => `rotate(${r} ${x + DECK_CARD.w / 2} ${y + DECK_CARD.h / 2})`;
84
+ /** A card's face: its outline, the art window and three lines of text. */
85
+ function SceneCardFace({ card }) {
86
+ const { w, h } = DECK_CARD;
87
+ const pad = w * 0.09;
88
+ const artH = h * 0.42;
89
+ return (_jsxs("g", { transform: turnOf(card), children: [_jsx("rect", { x: card.x, y: card.y, width: w, height: h, rx: w * 0.07 }), _jsx("rect", { x: card.x + pad, y: card.y + pad, width: w - 2 * pad, height: artH, rx: w * 0.03 }), [1, 1, 0.6].map((len, i) => (_jsx("path", { d: `M${card.x + pad} ${card.y + pad + artH + h * 0.12 + i * h * 0.09}h${(w - 2 * pad) * len}` }, i)))] }));
90
+ }
91
+ /**
92
+ * A constructed room's background: two decks across the table, a spark between them. Every card is
93
+ * masked by the cards on top of it, so a stack reads as solid cards rather than a tangle of outlines.
94
+ */
95
+ export function DecksFacingScene({ size = 170 }) {
96
+ const id = useId();
97
+ const { w, h } = DECK_CARD;
98
+ return (_jsxs(Scene, { size: size, children: [_jsx("defs", { children: FACING.slice(0, -1).map((_, i) => (_jsxs("mask", { id: `${id}-${i}`, maskUnits: "userSpaceOnUse", x: "-20", y: "-20", width: "200", height: "200", children: [_jsx("rect", { x: "-20", y: "-20", width: "200", height: "200", fill: "white" }), FACING.slice(i + 1).map((c, j) => (_jsx("rect", { x: c.x - 1, y: c.y - 1, width: w + 2, height: h + 2, rx: w * 0.07, transform: turnOf(c), fill: "black", stroke: "none" }, j)))] }, i))) }), FACING.map((card, i) => (_jsx("g", { mask: i < FACING.length - 1 ? `url(#${id}-${i})` : undefined, children: _jsx(SceneCardFace, { card: card }) }, i))), _jsx("path", { d: "M86 48l-12 26h14l-12 26" }), _jsx("path", { d: "M68 58l-7-5M96 90l7 5M66 84l-8 2M100 62l8-2" })] }));
99
+ }
@@ -0,0 +1,37 @@
1
+ export interface ParsedRelease {
2
+ /** `vX.Y.Z`, read off the filename (`v0.36.0.md`) — the one piece the heading does not repeat reliably. */
3
+ version: string;
4
+ /** The text after the em dash on the `#` heading; the bare version when there is none. */
5
+ title: string;
6
+ /** Every bullet under `## New`, `## Changed` then `## Fixed`, in that order, markdown emphasis stripped: the card draws as many as fit. */
7
+ bullets: string[];
8
+ /** The paragraph between the heading and the first section; empty when there is none. */
9
+ summary: string;
10
+ /** Every `##` section in the file's order, its bullets with their markdown kept (the full notes draw `**bold**`). */
11
+ sections: ReleaseSection[];
12
+ }
13
+ export interface ReleaseSection {
14
+ heading: string;
15
+ bullets: string[];
16
+ }
17
+ /** `text` cut into runs of plain text and credited names, in order, so the full notes can mark each name. */
18
+ export declare function creditRuns(text: string): {
19
+ text: string;
20
+ credit: boolean;
21
+ }[];
22
+ /**
23
+ * `markdown` is one release file's whole text, `version` its filename's `vX.Y.Z`. `null` when the
24
+ * file has no heading at all — not expected of a real release, but never thrown over one.
25
+ */
26
+ export declare function parseReleaseNotes(markdown: string, version: string): ParsedRelease | null;
27
+ /**
28
+ * How many bullets, from the first, sit wholly inside a list whose bottom edge is `limit`; `bottoms` are
29
+ * each bullet's bottom edge in the same coordinates. The card hides the rest rather than cut one in half.
30
+ */
31
+ export declare function fittingBullets(bottoms: readonly number[], limit: number): number;
32
+ /** `v0.36.0.md` → `v0.36.0`. `null` for a name this does not recognise as a release's. */
33
+ export declare function versionOfPath(path: string): string | null;
34
+ /** Releases newest first, by semantic order (`v` + three dot-separated integers, each a number). */
35
+ export declare function newestFirst<T extends {
36
+ version: string;
37
+ }>(releases: readonly T[]): T[];
@@ -0,0 +1,95 @@
1
+ /*
2
+ * The patch-notes card's own parser — pure, and tested on a REAL release file rather than a
3
+ * fixture, because `docs/releases/*.md`'s own shape (`# vX.Y.Z — Title`, then `## New` / `## Changed`
4
+ * / `## Fixed` / `## Under the hood`, each a flat bullet list) is the contract this reads, not one
5
+ * this file gets to invent (`docs/planning/wave77-2026-10-27.md` §A: "the newest release's title and
6
+ * its first bullets"). The player's own sections only: `## Under the hood` / `## Fixes` stay in the full notes.
7
+ */
8
+ /** A credit in a notes bullet: `@name`, the Discord username of whoever reported or asked for it (docs/RELEASE.md § "Attribution"). */
9
+ const CREDIT = /(?<![\w@/])@([A-Za-z0-9_.-]*[A-Za-z0-9_])/g;
10
+ /** One bullet's text with any `**bold**`/`*em*` markers stripped and each credit as the bare name — a card draws plain text. */
11
+ function plainBullet(text) {
12
+ return text
13
+ .replace(/\*\*(.+?)\*\*/g, '$1')
14
+ .replace(/\*(.+?)\*/g, '$1')
15
+ .replace(CREDIT, '$1')
16
+ .trim();
17
+ }
18
+ /** `text` cut into runs of plain text and credited names, in order, so the full notes can mark each name. */
19
+ export function creditRuns(text) {
20
+ return text.split(new RegExp(CREDIT.source)).map((part, i) => ({ text: part, credit: i % 2 === 1 })).filter((run) => run.text !== '');
21
+ }
22
+ /**
23
+ * `markdown` is one release file's whole text, `version` its filename's `vX.Y.Z`. `null` when the
24
+ * file has no heading at all — not expected of a real release, but never thrown over one.
25
+ */
26
+ export function parseReleaseNotes(markdown, version) {
27
+ const lines = markdown.split('\n');
28
+ const headingLine = lines.find((l) => l.startsWith('# '));
29
+ if (headingLine === undefined)
30
+ return null;
31
+ const heading = headingLine.slice(2).trim();
32
+ const dash = heading.indexOf('—'); // em dash
33
+ const title = dash === -1 ? heading : heading.slice(dash + 1).trim();
34
+ const { summary, sections } = sectionsOf(lines.slice(lines.indexOf(headingLine) + 1));
35
+ // New's bullets, then Changed's, then Fixed's, each in the file's own order — the card shows what
36
+ // shipped before what merely changed or was mended, and draws down the list as far as it has room.
37
+ const named = (target) => sections.find((s) => s.heading.toLowerCase() === target)?.bullets ?? [];
38
+ const bullets = [...named('new'), ...named('changed'), ...named('fixed')].map(plainBullet);
39
+ return { version, title, bullets, summary, sections };
40
+ }
41
+ /**
42
+ * A release file wraps a long bullet onto an indented continuation line (no leading `-`), so this
43
+ * joins every continuation onto its bullet. Lines before the first `##` are the summary paragraph.
44
+ */
45
+ function sectionsOf(lines) {
46
+ const summary = [];
47
+ const sections = [];
48
+ for (const line of lines) {
49
+ const heading = /^##\s+(.+)/.exec(line);
50
+ if (heading !== null) {
51
+ sections.push({ heading: heading[1].trim(), bullets: [] });
52
+ continue;
53
+ }
54
+ const current = sections.at(-1);
55
+ if (current === undefined) {
56
+ if (line.trim() !== '')
57
+ summary.push(line.trim());
58
+ continue;
59
+ }
60
+ const bullet = /^[-*]\s+(.*)/.exec(line);
61
+ if (bullet !== null) {
62
+ current.bullets.push(bullet[1].trim());
63
+ }
64
+ else if (/^\s+\S/.test(line) && current.bullets.length > 0) {
65
+ current.bullets[current.bullets.length - 1] = `${current.bullets.at(-1)} ${line.trim()}`;
66
+ }
67
+ }
68
+ return { summary: summary.join(' '), sections: sections.filter((s) => s.bullets.length > 0) };
69
+ }
70
+ /**
71
+ * How many bullets, from the first, sit wholly inside a list whose bottom edge is `limit`; `bottoms` are
72
+ * each bullet's bottom edge in the same coordinates. The card hides the rest rather than cut one in half.
73
+ */
74
+ export function fittingBullets(bottoms, limit) {
75
+ const over = bottoms.findIndex((b) => b > limit + 0.5);
76
+ return over === -1 ? bottoms.length : over;
77
+ }
78
+ /** `v0.36.0.md` → `v0.36.0`. `null` for a name this does not recognise as a release's. */
79
+ export function versionOfPath(path) {
80
+ const m = /([^/]+)\.md$/.exec(path);
81
+ return m === null ? null : m[1];
82
+ }
83
+ /** Releases newest first, by semantic order (`v` + three dot-separated integers, each a number). */
84
+ export function newestFirst(releases) {
85
+ const parts = (v) => v.replace(/^v/, '').split('.').map(Number);
86
+ return [...releases].sort((a, b) => compareVersions(parts(b.version), parts(a.version)));
87
+ }
88
+ function compareVersions(a, b) {
89
+ for (let i = 0; i < Math.max(a.length, b.length); i++) {
90
+ const diff = (a[i] ?? 0) - (b[i] ?? 0);
91
+ if (diff !== 0)
92
+ return diff;
93
+ }
94
+ return 0;
95
+ }