@hadoku/game-ui 0.1.146 → 0.1.148
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/session.d.ts +7 -0
- package/dist/room/session.js +24 -1
- package/dist/room/whoami.d.ts +5 -0
- package/dist/room/whoami.js +7 -0
- package/package.json +4 -4
package/dist/room/session.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { type SessionClaimStatus } from '@wolffm/rooms-protocol';
|
|
2
|
+
/**
|
|
3
|
+
* While asked (`held`), how often the tab claims again by itself. The server replaces a holder that has
|
|
4
|
+
* answered nothing for its `IDLE_MS` (15 s) without asking, but only when asked: a holder that is a socket
|
|
5
|
+
* a reload or a server restart left behind goes quiet, and this lets the question go away once it has.
|
|
6
|
+
* The server's beat interval, so a stale holder is noticed within one beat of going stale.
|
|
7
|
+
*/
|
|
8
|
+
export declare const HELD_RECLAIM_MS = 5000;
|
|
2
9
|
/** `pending` until the first answer; `taken` once another tab of this account took the room. */
|
|
3
10
|
export type SessionState = 'pending' | SessionClaimStatus | 'taken';
|
|
4
11
|
/** The part of a socket.io client this file uses. */
|
package/dist/room/session.js
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
*
|
|
9
9
|
* - one socket per room screen, opened when the screen has a room, which sends `session:claim`
|
|
10
10
|
* with this tab's settled id (`./tab-id.ts`) on every connect;
|
|
11
|
-
* - its answer is the state: `granted` and `watcher` play on, `held` asks
|
|
11
|
+
* - its answer is the state: `granted` and `watcher` play on, `held` asks (and claims again every
|
|
12
|
+
* `HELD_RECLAIM_MS` while unanswered, so a holder that has gone stale is replaced), and `refused` (a request
|
|
12
13
|
* the server could not read) plays on as before rather than lock a player out;
|
|
13
14
|
* - `taken` (told, or closed by the server, which is how a take ends a tab's sockets) stops the
|
|
14
15
|
* screen and offers to take it back; that and the ask's yes are the same claim with `take`;
|
|
@@ -22,6 +23,13 @@
|
|
|
22
23
|
import { SESSION_EVENTS, parseSessionAnswer, parseSessionTaken } from '@wolffm/rooms-protocol';
|
|
23
24
|
import { openSocket } from "./socket-options.js";
|
|
24
25
|
import { settledTabId } from "./tab-id.js";
|
|
26
|
+
/**
|
|
27
|
+
* While asked (`held`), how often the tab claims again by itself. The server replaces a holder that has
|
|
28
|
+
* answered nothing for its `IDLE_MS` (15 s) without asking, but only when asked: a holder that is a socket
|
|
29
|
+
* a reload or a server restart left behind goes quiet, and this lets the question go away once it has.
|
|
30
|
+
* The server's beat interval, so a stale holder is noticed within one beat of going stale.
|
|
31
|
+
*/
|
|
32
|
+
export const HELD_RECLAIM_MS = 5_000;
|
|
25
33
|
export function roomSession(room, deps = {}) {
|
|
26
34
|
const listeners = new Set();
|
|
27
35
|
let state = 'pending';
|
|
@@ -29,6 +37,7 @@ export function roomSession(room, deps = {}) {
|
|
|
29
37
|
let wantTake = false;
|
|
30
38
|
let socket = null;
|
|
31
39
|
let tabId = null;
|
|
40
|
+
let again = null;
|
|
32
41
|
const set = (next) => {
|
|
33
42
|
if (closed || next === state)
|
|
34
43
|
return;
|
|
@@ -51,8 +60,20 @@ export function roomSession(room, deps = {}) {
|
|
|
51
60
|
if (take && answer.status !== 'held')
|
|
52
61
|
wantTake = false;
|
|
53
62
|
set(answer.status);
|
|
63
|
+
if (answer.status === 'held')
|
|
64
|
+
askAgain();
|
|
54
65
|
});
|
|
55
66
|
};
|
|
67
|
+
/** Held: claim again in a while, unless something else has answered for this tab by then. */
|
|
68
|
+
const askAgain = () => {
|
|
69
|
+
if (again !== null)
|
|
70
|
+
clearTimeout(again);
|
|
71
|
+
again = setTimeout(() => {
|
|
72
|
+
again = null;
|
|
73
|
+
if (state === 'held')
|
|
74
|
+
claim();
|
|
75
|
+
}, HELD_RECLAIM_MS);
|
|
76
|
+
};
|
|
56
77
|
const open = (id) => {
|
|
57
78
|
if (closed)
|
|
58
79
|
return;
|
|
@@ -100,6 +121,8 @@ export function roomSession(room, deps = {}) {
|
|
|
100
121
|
},
|
|
101
122
|
close() {
|
|
102
123
|
closed = true;
|
|
124
|
+
if (again !== null)
|
|
125
|
+
clearTimeout(again);
|
|
103
126
|
socket?.close();
|
|
104
127
|
listeners.clear();
|
|
105
128
|
},
|
package/dist/room/whoami.d.ts
CHANGED
|
@@ -26,6 +26,11 @@ export declare const registerWhoamiTier: (value: (r: Pick<WhoamiAnswer, "userTyp
|
|
|
26
26
|
export declare function tierOfWhoami(r: Pick<WhoamiAnswer, 'userType'>): Who['tier'];
|
|
27
27
|
/** Whether the fleet names this viewer friend or above — the server's own friends-only floor (`packages/game-server/src/room/tier-floor.ts`). */
|
|
28
28
|
export declare function atLeastFriend(who: WhoState): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the fleet names this viewer wife or admin: an operator, with the room leader's tools in every
|
|
31
|
+
* room (the server's `isOperator`, read from the raw edge tier, never the member-promoting one).
|
|
32
|
+
*/
|
|
33
|
+
export declare function isOperatorViewer(who: WhoState): boolean;
|
|
29
34
|
/** Hands `who` to every `useWhoami` below, which then asks nothing of its own. */
|
|
30
35
|
export declare function WhoProvider({ who, children }: {
|
|
31
36
|
who: WhoState;
|
package/dist/room/whoami.js
CHANGED
|
@@ -34,6 +34,13 @@ export function tierOfWhoami(r) {
|
|
|
34
34
|
export function atLeastFriend(who) {
|
|
35
35
|
return who !== null && who !== 'pending' && rankOf(who.edgeTier) >= rankOf('friend');
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether the fleet names this viewer wife or admin: an operator, with the room leader's tools in every
|
|
39
|
+
* room (the server's `isOperator`, read from the raw edge tier, never the member-promoting one).
|
|
40
|
+
*/
|
|
41
|
+
export function isOperatorViewer(who) {
|
|
42
|
+
return who !== null && who !== 'pending' && rankOf(who.edgeTier) >= rankOf('wife');
|
|
43
|
+
}
|
|
37
44
|
/** The page's one resolution, when an app shell above has made it (`../app/GameAppShell.tsx`). */
|
|
38
45
|
const WhoContext = createContext(undefined);
|
|
39
46
|
/** Hands `who` to every `useWhoami` below, which then asks nothing of its own. */
|
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.148",
|
|
4
|
+
"gitHead": "6a384c4363e40e9f65aea9c1c5f2ecb719434aa1",
|
|
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.152",
|
|
58
|
+
"@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.152",
|
|
59
59
|
"@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.2",
|
|
60
60
|
"@wolffm/rooms-client": "npm:@hadoku/rooms-client@^0.45.143",
|
|
61
61
|
"@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.143",
|