@hadoku/game-ui 0.1.257 → 0.1.259

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.
@@ -0,0 +1,43 @@
1
+ import { type Fetch } from '../http.js';
2
+ import type { RoomViewBase } from './game-setup.js';
3
+ type StreamMember = RoomViewBase['members'][number];
4
+ /**
5
+ * Where one seat's stream lives: the server's room-keyed stream route.
6
+ *
7
+ * One expression, in one file, on purpose: the path shape is a contract with the server's `stream/`
8
+ * module and repointing it must stay a one-line edit. `base` is the app's deploy prefix, so this is
9
+ * same-origin by construction and no host is ever written down here.
10
+ */
11
+ export declare function streamRoot(roomId: string, seat: number, base?: string): string;
12
+ /**
13
+ * The page a seat actually shows, and probes.
14
+ *
15
+ * **Not the seat's root.** websockify answers `/` with its own DIRECTORY LISTING (`vnc.html`,
16
+ * `vnc_lite.html`, a few folders): a 200 with no noVNC in it, so a seat pointed at the root would
17
+ * frame a file listing and probe as unreachable forever with a healthy container behind it.
18
+ * `e2e/streamed-live.spec.ts` drives a real container through this path.
19
+ *
20
+ * `path` tells noVNC where its websocket lives, RELATIVE to the origin and with no leading slash,
21
+ * because the app is served under a base prefix. `autoconnect` so a player sees the client rather
22
+ * than a Connect button; `resize=scale` so the 1280x800 desktop fits the seat it is drawn in.
23
+ */
24
+ export declare function streamPath(roomId: string, seat: number, base?: string): string;
25
+ /**
26
+ * A string that appears in noVNC's page and in nothing this app serves.
27
+ *
28
+ * The reachability probe below needs POSITIVE evidence, because a 200 proves nothing here: with no
29
+ * containers the server's SPA fallback answers every `/stream/**` path with the app's own
30
+ * `index.html` and HTTP 200, so `res.ok` is true for a stream that does not exist, and a frame on it
31
+ * renders this app inside itself. Asking "does this look like noVNC" is false for our page, false for
32
+ * an error page and false for no answer at all, and each of those gets the stated waiting state
33
+ * instead of a frame that lies.
34
+ */
35
+ export declare const STREAM_MARK = "noVNC";
36
+ /** True only when the seat's page really is the stream's. Never throws. */
37
+ export declare function streamReachable(url: string, fetchImpl?: Fetch): Promise<boolean>;
38
+ export declare function StreamedSeats({ roomId, members, streamFetch }: {
39
+ roomId: string;
40
+ members: readonly StreamMember[];
41
+ streamFetch?: Fetch | undefined;
42
+ }): import("react").JSX.Element;
43
+ export {};
@@ -0,0 +1,107 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * A streamed room's body: one seat per member, each seat one stream of the game's own desktop client,
4
+ * running in a container per seat and served through the server's room-keyed `/stream/**` route.
5
+ *
6
+ * The seat number is the member's place in the room's own member list: the same order the server
7
+ * hands out and the same number its stream route is keyed by. Nothing here draws any of a game's own
8
+ * art: it is text, boxes and a frame, and the pixels inside the frame are the client's own.
9
+ */
10
+ import { useEffect, useState } from 'react';
11
+ import { appBase } from "../http.js";
12
+ import { PlayerName } from "../room/look.js";
13
+ /** How often a seat that has no stream yet asks again. */
14
+ const STREAM_PROBE_MS = 5000;
15
+ /**
16
+ * Where one seat's stream lives: the server's room-keyed stream route.
17
+ *
18
+ * One expression, in one file, on purpose: the path shape is a contract with the server's `stream/`
19
+ * module and repointing it must stay a one-line edit. `base` is the app's deploy prefix, so this is
20
+ * same-origin by construction and no host is ever written down here.
21
+ */
22
+ export function streamRoot(roomId, seat, base = appBase()) {
23
+ const prefix = base === '' ? '/' : base;
24
+ const root = prefix.endsWith('/') ? prefix : `${prefix}/`;
25
+ return `${root}stream/${encodeURIComponent(roomId)}/${seat}/`;
26
+ }
27
+ /**
28
+ * The page a seat actually shows, and probes.
29
+ *
30
+ * **Not the seat's root.** websockify answers `/` with its own DIRECTORY LISTING (`vnc.html`,
31
+ * `vnc_lite.html`, a few folders): a 200 with no noVNC in it, so a seat pointed at the root would
32
+ * frame a file listing and probe as unreachable forever with a healthy container behind it.
33
+ * `e2e/streamed-live.spec.ts` drives a real container through this path.
34
+ *
35
+ * `path` tells noVNC where its websocket lives, RELATIVE to the origin and with no leading slash,
36
+ * because the app is served under a base prefix. `autoconnect` so a player sees the client rather
37
+ * than a Connect button; `resize=scale` so the 1280x800 desktop fits the seat it is drawn in.
38
+ */
39
+ export function streamPath(roomId, seat, base = appBase()) {
40
+ const root = streamRoot(roomId, seat, base);
41
+ const socket = `${root}websockify`.replace(/^\//, '');
42
+ return `${root}vnc.html?path=${encodeURIComponent(socket)}&autoconnect=true&resize=scale`;
43
+ }
44
+ /**
45
+ * A string that appears in noVNC's page and in nothing this app serves.
46
+ *
47
+ * The reachability probe below needs POSITIVE evidence, because a 200 proves nothing here: with no
48
+ * containers the server's SPA fallback answers every `/stream/**` path with the app's own
49
+ * `index.html` and HTTP 200, so `res.ok` is true for a stream that does not exist, and a frame on it
50
+ * renders this app inside itself. Asking "does this look like noVNC" is false for our page, false for
51
+ * an error page and false for no answer at all, and each of those gets the stated waiting state
52
+ * instead of a frame that lies.
53
+ */
54
+ export const STREAM_MARK = 'noVNC';
55
+ /** True only when the seat's page really is the stream's. Never throws. */
56
+ export async function streamReachable(url, fetchImpl = (i, init) => fetch(i, init)) {
57
+ let res;
58
+ try {
59
+ res = await fetchImpl(url, { credentials: 'same-origin' });
60
+ }
61
+ catch {
62
+ // Not reachable IS the answer this returns; there is nothing being
63
+ // swallowed here, and the caller renders the waiting state either way.
64
+ return false;
65
+ }
66
+ if (!res.ok)
67
+ return false;
68
+ try {
69
+ return (await res.text()).includes(STREAM_MARK);
70
+ }
71
+ catch {
72
+ return false;
73
+ }
74
+ }
75
+ export function StreamedSeats({ roomId, members, streamFetch }) {
76
+ return (_jsxs("section", { className: "lobby__card streams", "data-testid": "room-streams", children: [_jsx("h2", { children: "One screen each" }), members.length === 0 ? (_jsx("p", { className: "lobby__note", "data-testid": "stream-nobody", children: "Nobody has joined yet." })) : (_jsx("ul", { className: "streams__grid", "data-testid": "stream-seats", children: members.map((member, seat) => (_jsx(StreamSeat, { roomId: roomId, seat: seat, member: member, streamFetch: streamFetch }, member.id))) }))] }));
77
+ }
78
+ /**
79
+ * One seat's screen, or the honest reason there is not one.
80
+ *
81
+ * The frame is mounted only once the seat's page has been fetched and proved to be the stream's
82
+ * (`streamReachable`). Anything else (no containers, a container still starting, the route not
83
+ * there) is the stated waiting line. It is never a spinner: a spinner says "nearly", and until a
84
+ * container exists nobody knows that. Once a seat is up it stays up and the probe stops.
85
+ */
86
+ function StreamSeat({ roomId, seat, member, streamFetch }) {
87
+ const url = streamPath(roomId, seat);
88
+ const [up, setUp] = useState(false);
89
+ useEffect(() => {
90
+ if (up)
91
+ return;
92
+ let live = true;
93
+ const probe = () => {
94
+ void streamReachable(url, streamFetch).then((ok) => {
95
+ if (live && ok)
96
+ setUp(true);
97
+ });
98
+ };
99
+ probe();
100
+ const timer = setInterval(probe, STREAM_PROBE_MS);
101
+ return () => {
102
+ live = false;
103
+ clearInterval(timer);
104
+ };
105
+ }, [url, up, streamFetch]);
106
+ return (_jsxs("li", { className: "streams__seat", "data-testid": "stream-seat", "data-seat": seat, children: [_jsx("span", { className: "streams__who", "data-testid": "stream-seat-who", children: _jsx(PlayerName, { name: member.name }) }), up ? (_jsx("iframe", { className: "streams__frame", "data-testid": "stream-frame", title: `${member.name}’s screen`, src: url })) : (_jsx("p", { className: "streams__waiting", "data-testid": "stream-waiting", children: "No screen yet." }))] }));
107
+ }
@@ -0,0 +1,9 @@
1
+ /** What to do with a read's answer, asked when it lands. */
2
+ export type ReadVerdict = 'keep' | 'drop' | 'reread';
3
+ export interface LatestReads {
4
+ /** A read is being sent: the returned function says, once it answers, what to do with the answer. */
5
+ read(): () => ReadVerdict;
6
+ /** A write's answer, carrying the same state, has just landed. */
7
+ wrote(): void;
8
+ }
9
+ export declare function latestReads(): LatestReads;
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Latest-wins for state a screen reads again and again — a room's record, its
3
+ * table, a game's own state, a pod's context — on every ping of the room's feed
4
+ * (`./feed.ts`). Two reads issued close together can answer out of order, and
5
+ * an older answer landing last would put the older state back, so a read only
6
+ * lands if no newer read was issued after it.
7
+ *
8
+ * The screen's own writes answer with the same state, so a read issued before
9
+ * a write's answer landed may hold the state from before the write: such a read
10
+ * is asked again rather than landed.
11
+ *
12
+ * A dropped read decides NOTHING, opening a screen's body included: a dropped
13
+ * room read that opened it would draw the screen with no room record.
14
+ */
15
+ export function latestReads() {
16
+ let issued = 0;
17
+ let writes = 0;
18
+ return {
19
+ read() {
20
+ const mine = (issued += 1);
21
+ const sentAfter = writes;
22
+ return () => (mine !== issued ? 'drop' : sentAfter !== writes ? 'reread' : 'keep');
23
+ },
24
+ wrote() {
25
+ writes += 1;
26
+ },
27
+ };
28
+ }
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * Identity, the gate and the seal are the server's own `relay-socket.ts`'s job, exactly as the
9
9
  * play socket's own `attachPlay` — nothing here carries a credential of its own, same as
10
- * `play/live/match.ts`'s `socketIoMatchTransport`, whose connection shape this one mirrors.
10
+ * `play/live/transport.ts`'s `socketIoMatchTransport`, whose connection shape this one mirrors.
11
11
  *
12
12
  * Ordering and at-most-once delivery are `runtimes/relay.ts`'s `RelaySession`'s own guarantees;
13
13
  * this file adds nothing to either — it only opens the connection, joins, rejoins on every
@@ -0,0 +1,24 @@
1
+ import type { RoomFeed } from '../feed.js';
2
+ import { type LatestReads } from '../latest.js';
3
+ import type { RoomJoinOutcome } from '../room-core-client.js';
4
+ /** A join that did not go through. */
5
+ export type RoomJoinRefused = Exclude<RoomJoinOutcome<unknown>, {
6
+ ok: true;
7
+ }>;
8
+ export interface RoomRead<T> {
9
+ feed: Pick<RoomFeed, 'follow'>;
10
+ /** The feed key whose pings read again. */
11
+ key: string;
12
+ read: () => Promise<T>;
13
+ /** The latest-wins guard, when the screen's own writes call `wrote()` on it; a fresh one otherwise. */
14
+ reads?: LatestReads;
15
+ /** A kept answer. True asks the loop to join; `joined` says this follow has joined already, and then it does not again. */
16
+ land: (answer: T, joined: boolean) => boolean;
17
+ join: () => Promise<RoomJoinOutcome<unknown>>;
18
+ /** The join was refused (or could not be sent): the reads stop. */
19
+ onRefused: (refused: RoomJoinRefused) => void;
20
+ /** A read that failed and that no newer read overtook. Without it, the failure is the caller's unhandled rejection. */
21
+ failed?: (err: unknown) => void;
22
+ }
23
+ /** Follow the room and read it; the answer stops following. */
24
+ export declare function followRoomRead<T>({ feed, key, read, reads, land, join, onRefused, failed }: RoomRead<T>): () => void;
@@ -0,0 +1,66 @@
1
+ /*
2
+ * The one loop a room screen reads its room with: the room's record (`useRoomJoin`) or a game's own
3
+ * read of the room (Magic's table), on the room's feed.
4
+ *
5
+ * The read is sent once when the loop starts following, then on every ping (`../feed.ts`). An answer
6
+ * a newer read overtook is dropped, and one sent before one of the screen's own writes answered is
7
+ * read again (`latestReads`): an older answer never puts older state back.
8
+ *
9
+ * What a kept answer means is the screen's (`land`), and so is whether it asks to join: the record
10
+ * not naming the viewer, a table read refused. The loop joins at most once per follow and reads again
11
+ * when the join goes through. A refused join stops the reads: retrying a locked room on every ping is
12
+ * a rate-limit trip and a password guessing loop nobody asked for. The screen's next attempt (a
13
+ * password submitted) is a new follow.
14
+ */
15
+ import { messageOf } from "../../load.js";
16
+ import { latestReads } from "../latest.js";
17
+ /** Follow the room and read it; the answer stops following. */
18
+ export function followRoomRead({ feed, key, read, reads = latestReads(), land, join, onRefused, failed }) {
19
+ let live = true;
20
+ let joined = false;
21
+ let stop = false;
22
+ const refuse = (refused) => {
23
+ stop = true;
24
+ onRefused(refused);
25
+ };
26
+ const next = () => {
27
+ if (stop)
28
+ return;
29
+ const landed = reads.read();
30
+ void read().then((answer) => {
31
+ if (!live)
32
+ return;
33
+ const verdict = landed();
34
+ if (verdict === 'drop')
35
+ return;
36
+ if (verdict === 'reread') {
37
+ next();
38
+ return;
39
+ }
40
+ if (!land(answer, joined) || joined)
41
+ return;
42
+ joined = true;
43
+ void join().then((outcome) => {
44
+ if (!live)
45
+ return;
46
+ if (outcome.ok)
47
+ next();
48
+ else
49
+ refuse(outcome);
50
+ }, (err) => {
51
+ if (live)
52
+ refuse({ ok: false, reason: 'error', message: messageOf(err) });
53
+ });
54
+ }, failed === undefined
55
+ ? undefined
56
+ : (err) => {
57
+ if (live && landed() !== 'drop')
58
+ failed(err);
59
+ });
60
+ };
61
+ const stopFollowing = feed.follow({ room: key }, next);
62
+ return () => {
63
+ live = false;
64
+ stopFollowing();
65
+ };
66
+ }
@@ -1,12 +1,10 @@
1
1
  import type { RoomFeed } from '../feed.js';
2
2
  import type { RoomViewBase } from '../game-setup.js';
3
- import type { RoomCoreClient, RoomJoinOutcome } from '../room-core-client.js';
3
+ import type { RoomCoreClient } from '../room-core-client.js';
4
+ import { type RoomJoinRefused } from './followRoomRead.js';
5
+ export type { RoomJoinRefused };
4
6
  /** Why the room's password gate is up: none was sent, the one sent was refused, or too many were. */
5
7
  export type RoomLock = 'need' | 'wrong' | 'rate-limited';
6
- /** A join that did not go through. */
7
- export type RoomJoinRefused = Exclude<RoomJoinOutcome<unknown>, {
8
- ok: true;
9
- }>;
10
8
  /**
11
9
  * Where a refused join leaves the room's screen. room-core refuses a wrong password and a missing room
12
10
  * with the same answer, on purpose, so both ask for the password: `need` when none was sent, `wrong`
@@ -1,10 +1,9 @@
1
1
  /*
2
2
  * A room screen's own read of its room record, and the join that makes the viewer a member.
3
3
  *
4
- * The record is read on the room's feed (`../feed.ts`): once when the screen starts following, then
5
- * on every ping. Two reads close together can answer out of order, so a read lands only if no newer
6
- * one was sent after it, and a read sent before one of the screen's own writes answered is sent
7
- * again rather than landed (`wrote`): an older answer never puts older state back.
4
+ * The record is read on the room's feed by the one room read loop (`followRoomRead`): an older
5
+ * answer never puts older state back, and a read sent before one of the screen's own writes answered
6
+ * (`wrote`) is sent again rather than landed.
8
7
  *
9
8
  * `GET /api/rooms/:id` answers any caller, member or not, so a refusal never says "join me". What
10
9
  * says it is the member list not naming `you.id` yet: true for a fresh invite link, false forever
@@ -19,7 +18,8 @@
19
18
  * is gone (`onGone`). One room per mount: a host showing another room mounts the hook again.
20
19
  */
21
20
  import { useCallback, useEffect, useRef, useState } from 'react';
22
- import { messageOf } from "../../load.js";
21
+ import { latestReads } from "../latest.js";
22
+ import { followRoomRead } from "./followRoomRead.js";
23
23
  /**
24
24
  * Where a refused join leaves the room's screen. room-core refuses a wrong password and a missing room
25
25
  * with the same answer, on purpose, so both ask for the password: `need` when none was sent, `wrong`
@@ -44,71 +44,36 @@ export function useRoomJoin(roomId, options) {
44
44
  // The latest callbacks, read when a read lands: the host's fresh closures every render never re-follow the feed.
45
45
  const callbacks = useRef(options);
46
46
  callbacks.current = options;
47
- const sent = useRef({ reads: 0, writes: 0 });
48
- useEffect(() => {
49
- let live = true;
50
- let joined = false;
51
- let stop = false;
52
- const read = () => {
53
- if (stop)
54
- return;
55
- const mine = (sent.current.reads += 1);
56
- const writesBefore = sent.current.writes;
57
- const verdict = () => (mine !== sent.current.reads ? 'drop' : writesBefore !== sent.current.writes ? 'reread' : 'keep');
58
- void core.get(roomId).then((room) => {
59
- if (!live)
60
- return;
61
- const landed = verdict();
62
- if (landed === 'drop')
63
- return;
64
- if (room === null) {
65
- setResolved(true);
66
- callbacks.current.onGone?.();
67
- return;
68
- }
69
- if (landed === 'reread') {
70
- read();
71
- return;
72
- }
73
- callbacks.current.onRead?.(room);
74
- setView(room);
47
+ const [reads] = useState(latestReads);
48
+ useEffect(() => followRoomRead({
49
+ feed,
50
+ key: feedKey,
51
+ reads,
52
+ read: () => core.get(roomId),
53
+ land: (room, joined) => {
54
+ if (room === null) {
75
55
  setResolved(true);
76
- setJoinError(null);
77
- if (joined || room.members.some((m) => m.id === room.you.id) || callbacks.current.shouldJoin?.(room) === false)
78
- return;
79
- joined = true;
80
- void core.join(roomId, attempt.password === '' ? undefined : attempt.password).then((join) => {
81
- if (!live)
82
- return;
83
- if (join.ok) {
84
- read();
85
- return;
86
- }
87
- stop = true;
88
- const refused = joinRefusal(join, attempt.password);
89
- if ('locked' in refused)
90
- setLocked(refused.locked);
91
- else
92
- setJoinError(refused.message);
93
- }, (err) => {
94
- if (!live)
95
- return;
96
- stop = true;
97
- setJoinError(messageOf(err));
98
- });
99
- }, () => {
100
- // The record could not be read. The host's other reads say why in words; what this must
101
- // not do is keep the body hidden as well, so the gate opens.
102
- if (live && verdict() !== 'drop')
103
- setResolved(true);
104
- });
105
- };
106
- const stopFollowing = feed.follow({ room: feedKey }, read);
107
- return () => {
108
- live = false;
109
- stopFollowing();
110
- };
111
- }, [core, feed, roomId, feedKey, attempt]);
56
+ callbacks.current.onGone?.();
57
+ return false;
58
+ }
59
+ callbacks.current.onRead?.(room);
60
+ setView(room);
61
+ setResolved(true);
62
+ setJoinError(null);
63
+ return !joined && !room.members.some((m) => m.id === room.you.id) && callbacks.current.shouldJoin?.(room) !== false;
64
+ },
65
+ join: () => core.join(roomId, attempt.password === '' ? undefined : attempt.password),
66
+ onRefused: (join) => {
67
+ const refused = joinRefusal(join, attempt.password);
68
+ if ('locked' in refused)
69
+ setLocked(refused.locked);
70
+ else
71
+ setJoinError(refused.message);
72
+ },
73
+ // The record could not be read. The host's other reads say why in words; what this must not
74
+ // do is keep the body hidden as well, so the gate opens.
75
+ failed: () => setResolved(true),
76
+ }), [core, feed, roomId, feedKey, attempt, reads]);
112
77
  const submitPassword = useCallback(() => {
113
78
  setLocked(null);
114
79
  setJoinError(null);
@@ -123,9 +88,9 @@ export function useRoomJoin(roomId, options) {
123
88
  return null;
124
89
  }, [sentPassword]);
125
90
  const wrote = useCallback((room) => {
126
- sent.current.writes += 1;
91
+ reads.wrote();
127
92
  setView(room);
128
- }, []);
93
+ }, [reads]);
129
94
  return {
130
95
  view,
131
96
  resolved,
@@ -0,0 +1,8 @@
1
+ export interface RoomWrites {
2
+ /**
3
+ * Send `write` now, or once the write in flight has answered. `settled` runs once `write` has
4
+ * answered, after the next queued write has gone out.
5
+ */
6
+ send(write: () => Promise<unknown>, settled?: () => void): void;
7
+ }
8
+ export declare function useRoomWrites(): RoomWrites;
@@ -0,0 +1,24 @@
1
+ /*
2
+ * A room screen's writes, one at a time, held here and never drawn: greying every control for the
3
+ * round trip makes the room blink on each press. A press while a write is in flight waits its turn and
4
+ * goes out once that write has answered, in the order the presses were made.
5
+ */
6
+ import { useRef } from 'react';
7
+ export function useRoomWrites() {
8
+ const queue = useRef({ busy: false, later: [] });
9
+ const send = (write, settled) => {
10
+ const q = queue.current;
11
+ if (q.busy) {
12
+ q.later.push(() => send(write, settled));
13
+ return;
14
+ }
15
+ q.busy = true;
16
+ void write().finally(() => {
17
+ q.busy = false;
18
+ while (!q.busy && q.later.length > 0)
19
+ q.later.shift()();
20
+ settled?.();
21
+ });
22
+ };
23
+ return { send };
24
+ }
@@ -9,6 +9,10 @@ export declare function trackConnection(transport: Parameters<typeof watchRestar
9
9
  serverUpdating: boolean;
10
10
  /** 1 for the caller's first join, one more for each rejoin. */
11
11
  joins: number;
12
+ /** The latest connect came back from a planned restart's drop (`watchRestart`'s `back`), until the next drop. */
13
+ backFromRestart: boolean;
14
+ /** Why the socket last dropped, as socket.io said it (`transport close`, `ping timeout`, …); null before any drop. */
15
+ dropReason: string | null;
12
16
  /** Told after every change, the rejoin already sent. Returns the unsubscribe. */
13
17
  subscribe(fn: () => void): () => void;
14
18
  };
@@ -11,6 +11,10 @@ export function trackConnection(transport, { onRejoin } = {}) {
11
11
  serverUpdating: false,
12
12
  /** 1 for the caller's first join, one more for each rejoin. */
13
13
  joins: 1,
14
+ /** The latest connect came back from a planned restart's drop (`watchRestart`'s `back`), until the next drop. */
15
+ backFromRestart: false,
16
+ /** Why the socket last dropped, as socket.io said it (`transport close`, `ping timeout`, …); null before any drop. */
17
+ dropReason: null,
14
18
  /** Told after every change, the rejoin already sent. Returns the unsubscribe. */
15
19
  subscribe(fn) {
16
20
  listeners.add(fn);
@@ -21,6 +25,8 @@ export function trackConnection(transport, { onRejoin } = {}) {
21
25
  // tells anyone; only the quiet window running out is told from here.
22
26
  watchRestart(transport, (updating, back) => {
23
27
  state.serverUpdating = updating;
28
+ if (back)
29
+ state.backFromRestart = true;
24
30
  if (!state.connected && !back)
25
31
  tell();
26
32
  });
@@ -33,8 +39,10 @@ export function trackConnection(transport, { onRejoin } = {}) {
33
39
  }
34
40
  tell();
35
41
  });
36
- transport.on('disconnect', () => {
42
+ transport.on('disconnect', (reason) => {
37
43
  state.connected = false;
44
+ state.backFromRestart = false;
45
+ state.dropReason = String(reason);
38
46
  tell();
39
47
  });
40
48
  return state;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/game-ui",
3
- "version": "0.1.257",
4
- "gitHead": "7e3e0ac34dfe7b42abbd7510cb776534a2688248",
3
+ "version": "0.1.259",
4
+ "gitHead": "83a30a8c2ea27adc8f2b19f28ba472f2fc8774fe",
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.",
@@ -53,8 +53,8 @@
53
53
  "react-dom": "^19.2.8"
54
54
  },
55
55
  "dependencies": {
56
- "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.261",
57
- "@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.261",
56
+ "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.263",
57
+ "@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.263",
58
58
  "@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.4",
59
59
  "@wolffm/rooms-client": "npm:@hadoku/rooms-client@^0.45.158",
60
60
  "@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.158",