@hadoku/game-server 0.1.211 → 0.1.212
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/stream/alloc.d.ts +8 -15
- package/dist/stream/alloc.js +2 -33
- package/dist/stream/index.d.ts +6 -3
- package/dist/stream/index.js +6 -19
- package/dist/telemetry.d.ts +3 -30
- package/dist/telemetry.js +1 -16
- package/package.json +5 -6
- package/dist/base-path.d.ts +0 -25
- package/dist/base-path.js +0 -25
- package/dist/busy.d.ts +0 -39
- package/dist/busy.js +0 -22
- package/dist/capacity.d.ts +0 -9
- package/dist/capacity.js +0 -6
package/dist/stream/alloc.d.ts
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The first host port a room's seat may take, when `createRoomStreams`'s caller does not pass its
|
|
3
|
-
* own `basePort`.
|
|
4
|
-
*
|
|
5
|
-
* Deliberately clear of everything else on this host: 6080–6081 are the static
|
|
6
|
-
* bench, and the e2e harness picks its ports from 20000 up (`e2e/ports.ts`). `container.sh` refuses
|
|
7
|
-
* anything below 6100 a second time, in case this constant is ever loosened.
|
|
8
|
-
*
|
|
9
|
-
* A literal, not `CONFIG.roomStreamBasePort` (w119 §C): the room-stream ports are Forge/Magic-only
|
|
10
|
-
* (survey §3), so Magic's `MAGIC_CONFIG.roomStreamBasePort` is what `plugins/stream.ts` passes in
|
|
11
|
-
* as `basePort` — this platform file reads no `CARDTABLE_*` env var itself any more.
|
|
12
|
-
*/
|
|
13
|
-
export declare const ROOM_STREAM_BASE_PORT = 6100;
|
|
14
1
|
/** Seats in one room. A pod is 8; a constructed table is 2. */
|
|
15
2
|
export declare const MAX_ROOM_SEATS = 8;
|
|
16
3
|
/** No websocket attached for this long → the containers go. See the header. */
|
|
@@ -62,10 +49,16 @@ export interface RoomStreamsOptions {
|
|
|
62
49
|
script?: ContainerScript;
|
|
63
50
|
/** Injectable so the idle window is tested with a fake clock, not a wait. */
|
|
64
51
|
now?: () => number;
|
|
65
|
-
|
|
52
|
+
/** The first host port a room's seat may take; `container.sh` refuses anything below 6100. */
|
|
53
|
+
basePort: number;
|
|
66
54
|
poolSize?: number;
|
|
67
55
|
idleMs?: number;
|
|
68
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Container names are `<namePrefix>-<roomKey>-<seat>`. The prefix is this server's ownership
|
|
58
|
+
* claim: `sweepOrphans()` destroys every container with it that this process does not own, so
|
|
59
|
+
* two servers on one host (an e2e run beside production) must never share one.
|
|
60
|
+
*/
|
|
61
|
+
namePrefix: string;
|
|
69
62
|
log?: (entry: Record<string, unknown>) => void;
|
|
70
63
|
/**
|
|
71
64
|
* A room's containers actually came down — through `release()`, the idle sweep, or `sweep()`
|
package/dist/stream/alloc.js
CHANGED
|
@@ -42,19 +42,6 @@ import { existsSync } from 'node:fs';
|
|
|
42
42
|
import { dirname, join, resolve } from 'node:path';
|
|
43
43
|
import { fileURLToPath } from 'node:url';
|
|
44
44
|
import { ROOM_ID_RE } from '@wolffm/platform-wire/room-feed';
|
|
45
|
-
/**
|
|
46
|
-
* The first host port a room's seat may take, when `createRoomStreams`'s caller does not pass its
|
|
47
|
-
* own `basePort`.
|
|
48
|
-
*
|
|
49
|
-
* Deliberately clear of everything else on this host: 6080–6081 are the static
|
|
50
|
-
* bench, and the e2e harness picks its ports from 20000 up (`e2e/ports.ts`). `container.sh` refuses
|
|
51
|
-
* anything below 6100 a second time, in case this constant is ever loosened.
|
|
52
|
-
*
|
|
53
|
-
* A literal, not `CONFIG.roomStreamBasePort` (w119 §C): the room-stream ports are Forge/Magic-only
|
|
54
|
-
* (survey §3), so Magic's `MAGIC_CONFIG.roomStreamBasePort` is what `plugins/stream.ts` passes in
|
|
55
|
-
* as `basePort` — this platform file reads no `CARDTABLE_*` env var itself any more.
|
|
56
|
-
*/
|
|
57
|
-
export const ROOM_STREAM_BASE_PORT = 6100;
|
|
58
45
|
/**
|
|
59
46
|
* How many streamed seats may exist on this host AT ONCE, across all rooms.
|
|
60
47
|
*
|
|
@@ -68,24 +55,6 @@ const ROOM_STREAM_POOL = 8;
|
|
|
68
55
|
export const MAX_ROOM_SEATS = 8;
|
|
69
56
|
/** No websocket attached for this long → the containers go. See the header. */
|
|
70
57
|
export const IDLE_RECLAIM_MS = 30 * 60_000;
|
|
71
|
-
/**
|
|
72
|
-
* Container names: `<prefix>-<roomKey>-<seat>`. `container.sh` enforces it.
|
|
73
|
-
*
|
|
74
|
-
* **Env-settable because the prefix is this server's OWNERSHIP claim, and a
|
|
75
|
-
* host can run more than one cardtable.** `sweepOrphans()` destroys every
|
|
76
|
-
* container matching the prefix that this process's `live` map does not own —
|
|
77
|
-
* which is right for reclaiming what a restart of THIS server left behind, and
|
|
78
|
-
* catastrophic across two servers sharing one name. A `pnpm e2e` run boots a
|
|
79
|
-
* second server on the machine that runs production: with one prefix its boot
|
|
80
|
-
* sweep would delete a real player's containers mid-match. The e2e harness
|
|
81
|
-
* therefore sets its own prefix, and `container.sh` already reads the same
|
|
82
|
-
* variable, so the script and the server can never disagree about what this
|
|
83
|
-
* server may touch.
|
|
84
|
-
*
|
|
85
|
-
* A literal default, like {@link ROOM_STREAM_BASE_PORT} — `plugins/stream.ts` passes its own
|
|
86
|
-
* `namePrefix` from `MAGIC_CONFIG.streamNamePrefix` (`CARDTABLE_STREAM_NAME_PREFIX`).
|
|
87
|
-
*/
|
|
88
|
-
const CONTAINER_NAME_PREFIX = 'cardtable-room';
|
|
89
58
|
/**
|
|
90
59
|
* Where `scripts/stream/container.sh` is, found by walking up from this file.
|
|
91
60
|
*
|
|
@@ -147,10 +116,10 @@ export function isStaticIndexLike(roomKey) {
|
|
|
147
116
|
}
|
|
148
117
|
export function createRoomStreams(options) {
|
|
149
118
|
const now = options.now ?? Date.now;
|
|
150
|
-
const basePort = options.basePort
|
|
119
|
+
const basePort = options.basePort;
|
|
151
120
|
const poolSize = options.poolSize ?? ROOM_STREAM_POOL;
|
|
152
121
|
const idleMs = options.idleMs ?? IDLE_RECLAIM_MS;
|
|
153
|
-
const prefix = options.namePrefix
|
|
122
|
+
const prefix = options.namePrefix;
|
|
154
123
|
const log = options.log ?? (() => { });
|
|
155
124
|
const script = options.script ??
|
|
156
125
|
(() => {
|
package/dist/stream/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { Server } from 'node:http';
|
|
2
2
|
import type { Router } from 'express';
|
|
3
|
+
import type { gateUpgrade } from '../gate.js';
|
|
3
4
|
import { type RoomStreams } from './alloc.js';
|
|
4
5
|
export interface StreamDeps {
|
|
5
6
|
/** The tier floor. `CONFIG.minTier` — never lower, never a new tier. */
|
|
6
7
|
minTier: string;
|
|
8
|
+
/** The floor at the websocket upgrade: `@hadoku/game-server/gate`'s `gateUpgrade`. */
|
|
9
|
+
gateUpgrade: typeof gateUpgrade;
|
|
7
10
|
/** Container n's noVNC port is `streamBasePort + n`. */
|
|
8
11
|
streamBasePort: number;
|
|
9
12
|
/** How many STATIC stream containers to expose. 0 → attach none of them. */
|
|
@@ -39,13 +42,13 @@ export interface RoomStreamPath {
|
|
|
39
42
|
*/
|
|
40
43
|
export declare function roomStreamPathOf(url: string | undefined): RoomStreamPath | null;
|
|
41
44
|
/**
|
|
42
|
-
* How many containers to expose, read from
|
|
45
|
+
* How many containers to expose, read from `<dir>/STREAMS` on disk.
|
|
43
46
|
*
|
|
44
47
|
* A malformed count is zero containers, not a guess — each container is a
|
|
45
48
|
* proxy to a port, and guessing here is a port scan. Bounded because an
|
|
46
49
|
* unbounded count is the same scan with more steps.
|
|
47
50
|
*/
|
|
48
|
-
export declare function streamLayout(exists?: (p: string) => boolean, read?: (p: string) => string
|
|
51
|
+
export declare function streamLayout(dir: string, exists?: (p: string) => boolean, read?: (p: string) => string): {
|
|
49
52
|
streamCount: number;
|
|
50
53
|
};
|
|
51
54
|
/**
|
|
@@ -61,6 +64,6 @@ export declare function attachStreamRoutes(app: Router, deps: StreamDeps): boole
|
|
|
61
64
|
/**
|
|
62
65
|
* The websocket half: noVNC talks RFB over a websocket to websockify.
|
|
63
66
|
* express never sees an `upgrade`, so the tier floor is re-applied here by
|
|
64
|
-
* hand, with
|
|
67
|
+
* hand, with the injected `gateUpgrade`.
|
|
65
68
|
*/
|
|
66
69
|
export declare function attachStream(server: Server, deps: StreamDeps): StreamHandle | null;
|
package/dist/stream/index.js
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
* ## The gate
|
|
38
38
|
*
|
|
39
39
|
* The HTTP half is mounted below `requireMinTier`. The websocket half
|
|
40
|
-
* re-applies the floor itself —
|
|
40
|
+
* re-applies the floor itself — the injected `gateUpgrade` — because an
|
|
41
41
|
* `upgrade` event runs no express middleware.
|
|
42
42
|
*
|
|
43
43
|
* **404, never 403.** A different answer for "exists but you may not" tells
|
|
@@ -46,12 +46,10 @@
|
|
|
46
46
|
* the floor, so it tells a friend the truth and an outsider nothing.
|
|
47
47
|
*/
|
|
48
48
|
import { existsSync, readFileSync } from 'node:fs';
|
|
49
|
-
import { homedir } from 'node:os';
|
|
50
49
|
import { join } from 'node:path';
|
|
51
50
|
import { connect } from 'node:net';
|
|
52
51
|
import { request as httpRequest } from 'node:http';
|
|
53
52
|
import express from 'express';
|
|
54
|
-
import { gateUpgrade } from '../gate.js';
|
|
55
53
|
import { ROOM_ID_RE } from '@wolffm/platform-wire/room-feed';
|
|
56
54
|
import { isStaticIndexLike } from './alloc.js';
|
|
57
55
|
/** `/stream/3/websockify` → 3, or null when the path is not a stream path. */
|
|
@@ -85,25 +83,14 @@ export function roomStreamPathOf(url) {
|
|
|
85
83
|
return { roomKey, seat: Number(m[2]), rest: query === undefined ? rest : `${rest}?${query}` };
|
|
86
84
|
}
|
|
87
85
|
/**
|
|
88
|
-
*
|
|
89
|
-
* stream`, same as `CARDTABLE_STREAM_DIR`'s old default. A literal, not a `process.env` read (w119
|
|
90
|
-
* §C, same reasoning as `alloc.ts`'s `ROOM_STREAM_BASE_PORT`/`CONTAINER_NAME_PREFIX`): this
|
|
91
|
-
* platform file reads no `CARDTABLE_*` var itself any more. `games/magic/server/src/plugins/
|
|
92
|
-
* stream.ts` passes `MAGIC_CONFIG.streamDir` (`CARDTABLE_STREAM_DIR`, so a second server on the
|
|
93
|
-
* same machine still stays off this one's containers) as `streamLayout`'s `dir`.
|
|
94
|
-
*/
|
|
95
|
-
function streamsFile(dir) {
|
|
96
|
-
return join(dir ?? join(homedir(), '.local', 'share', 'cardtable', 'stream'), 'STREAMS');
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* How many containers to expose, read from `STREAMS` on disk.
|
|
86
|
+
* How many containers to expose, read from `<dir>/STREAMS` on disk.
|
|
100
87
|
*
|
|
101
88
|
* A malformed count is zero containers, not a guess — each container is a
|
|
102
89
|
* proxy to a port, and guessing here is a port scan. Bounded because an
|
|
103
90
|
* unbounded count is the same scan with more steps.
|
|
104
91
|
*/
|
|
105
|
-
export function streamLayout(exists = existsSync, read = (f) => readFileSync(f, 'utf8')
|
|
106
|
-
const streamsFilePath =
|
|
92
|
+
export function streamLayout(dir, exists = existsSync, read = (f) => readFileSync(f, 'utf8')) {
|
|
93
|
+
const streamsFilePath = join(dir, 'STREAMS');
|
|
107
94
|
try {
|
|
108
95
|
const raw = exists(streamsFilePath) ? read(streamsFilePath).trim() : '0';
|
|
109
96
|
const n = Number(raw);
|
|
@@ -229,7 +216,7 @@ export function attachStreamRoutes(app, deps) {
|
|
|
229
216
|
/**
|
|
230
217
|
* The websocket half: noVNC talks RFB over a websocket to websockify.
|
|
231
218
|
* express never sees an `upgrade`, so the tier floor is re-applied here by
|
|
232
|
-
* hand, with
|
|
219
|
+
* hand, with the injected `gateUpgrade`.
|
|
233
220
|
*/
|
|
234
221
|
export function attachStream(server, deps) {
|
|
235
222
|
const rooms = deps.rooms ?? null;
|
|
@@ -245,7 +232,7 @@ export function attachStream(server, deps) {
|
|
|
245
232
|
refuse(socket, 400, 'expected a version-13 websocket upgrade');
|
|
246
233
|
return;
|
|
247
234
|
}
|
|
248
|
-
const floor = gateUpgrade(req, { minTier: deps.minTier, surface: 'stream' });
|
|
235
|
+
const floor = deps.gateUpgrade(req, { minTier: deps.minTier, surface: 'stream' });
|
|
249
236
|
if (!floor.ok) {
|
|
250
237
|
refuse(socket, 404, 'not found');
|
|
251
238
|
return;
|
package/dist/telemetry.d.ts
CHANGED
|
@@ -1,42 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Adapter:
|
|
2
|
+
* Adapter: game-server's binding of `@hadoku/service-kernel/telemetry`.
|
|
3
3
|
*
|
|
4
4
|
* The plain re-exports stay because the published `@wolffm/game-server/telemetry` is a contract:
|
|
5
5
|
* bomberman's server imports `callerContext`, `report`, `installTelemetry` and `Report` from it.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* env var named in the disabled-reason log line (`CARDTABLE_SERVICE_KEY`), and the closed set of
|
|
9
|
-
* surfaces a seal refusal ever names — the kernel's own `reportSealRefused` takes an open string,
|
|
10
|
-
* since it knows no game's surface names.
|
|
6
|
+
* What is its own is the closed set of surfaces a seal refusal ever names — the kernel's own
|
|
7
|
+
* `reportSealRefused` takes an open string, since it knows no game's surface names.
|
|
11
8
|
*/
|
|
12
9
|
import type { Request } from 'express';
|
|
13
|
-
import type { JsonLog } from '@wolffm/service-kernel/log';
|
|
14
10
|
import { callerContext, installTelemetry, report, reportingAlerts, type Level, type Report, type TelemetryContext } from '@wolffm/service-kernel/telemetry';
|
|
15
11
|
export { callerContext, installTelemetry, report, reportingAlerts };
|
|
16
12
|
export type { Level, Report, TelemetryContext };
|
|
17
|
-
/**
|
|
18
|
-
* Which deployment a base path is: `/cardtable` is prod, `/cardtable-<site>` that site
|
|
19
|
-
* (`/cardtable-ppe` is ppe, as the PPE wrapper sets `CARDTABLE_BASE_PREFIX`). Any other
|
|
20
|
-
* prefix names itself.
|
|
21
|
-
*/
|
|
22
|
-
export declare function siteOf(basePrefix: string): string;
|
|
23
|
-
export interface SinkOptions {
|
|
24
|
-
/** `https://hadoku.me` — the telemetry route is `/health/api/telemetry` under it. */
|
|
25
|
-
baseUrl: string;
|
|
26
|
-
serviceKey: string;
|
|
27
|
-
log: JsonLog;
|
|
28
|
-
/** This deployment (`siteOf`), on every event. */
|
|
29
|
-
site: string;
|
|
30
|
-
/** One post per (event, caller, incident key) per this many ms. */
|
|
31
|
-
windowMs?: number;
|
|
32
|
-
now?: () => number;
|
|
33
|
-
fetch?: typeof fetch;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* A reporter that posts to monitoring-api. Without a service key it posts
|
|
37
|
-
* nothing and says so once, the way the stats reporter does.
|
|
38
|
-
*/
|
|
39
|
-
export declare function monitoringSink(opts: SinkOptions): Report;
|
|
40
13
|
type Headers = Request['headers'];
|
|
41
14
|
/**
|
|
42
15
|
* A seal below the edge refused a caller. With the edge in front this should
|
package/dist/telemetry.js
CHANGED
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
import { callerContext, installTelemetry,
|
|
1
|
+
import { callerContext, installTelemetry, report, reportingAlerts, reportSealRefused as kernelReportSealRefused, } from '@wolffm/service-kernel/telemetry';
|
|
2
2
|
export { callerContext, installTelemetry, report, reportingAlerts };
|
|
3
|
-
/**
|
|
4
|
-
* Which deployment a base path is: `/cardtable` is prod, `/cardtable-<site>` that site
|
|
5
|
-
* (`/cardtable-ppe` is ppe, as the PPE wrapper sets `CARDTABLE_BASE_PREFIX`). Any other
|
|
6
|
-
* prefix names itself.
|
|
7
|
-
*/
|
|
8
|
-
export function siteOf(basePrefix) {
|
|
9
|
-
return kernelSiteOf(basePrefix, 'cardtable');
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* A reporter that posts to monitoring-api. Without a service key it posts
|
|
13
|
-
* nothing and says so once, the way the stats reporter does.
|
|
14
|
-
*/
|
|
15
|
-
export function monitoringSink(opts) {
|
|
16
|
-
return kernelMonitoringSink({ ...opts, service: 'cardtable', serviceKeyEnvVar: 'CARDTABLE_SERVICE_KEY' });
|
|
17
|
-
}
|
|
18
3
|
/**
|
|
19
4
|
* A seal below the edge refused a caller. With the edge in front this should
|
|
20
5
|
* never fire: one means a direct hit on the tunnel host, or an edge rule wider
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hadoku/game-server",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "0.1.212",
|
|
4
|
+
"gitHead": "a9e2641a46c10f8803503badaf42ec88a15b23e9",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"description": "The server parts any hosted game shares, above the kernel: the app config and edge auth, the room core (identity, seats, sessions, membership, the room list, the generic room routes), match hosting (the host contract, local and remote JVMs, placement, the start queue, recordings, the in-process and relay runtimes), streams, erase, telemetry and usage. Knows no game; Magic plugs in from apps/server. MIT; imports only node built-ins, express, socket.io, @wolffm/* and the platform packages.",
|
|
@@ -12,14 +12,13 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"publishLeaveOut": [
|
|
15
|
-
"announce.ts",
|
|
16
15
|
"play/placement/",
|
|
17
16
|
"play/remote/"
|
|
18
17
|
],
|
|
19
18
|
"dependencies": {
|
|
20
|
-
"@wolffm/host-wire": "npm:@hadoku/host-wire@0.1.
|
|
21
|
-
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.
|
|
22
|
-
"@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.
|
|
19
|
+
"@wolffm/host-wire": "npm:@hadoku/host-wire@0.1.212",
|
|
20
|
+
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.212",
|
|
21
|
+
"@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.245",
|
|
23
22
|
"@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.3",
|
|
24
23
|
"@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.152",
|
|
25
24
|
"@wolffm/rooms-server": "npm:@hadoku/rooms-server@^0.45.152",
|
package/dist/base-path.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The base-path contract, checked at boot — cardtable's binding of the
|
|
3
|
-
* platform kernel (`@hadoku/service-kernel/http`).
|
|
4
|
-
*
|
|
5
|
-
* This is the one thing about a loopback-UI app that breaks SILENTLY, so it is
|
|
6
|
-
* the one thing this server refuses to guess about.
|
|
7
|
-
*
|
|
8
|
-
* The edge gives us stripPrefix: hadoku.me/cardtable/assets/x.js arrives here
|
|
9
|
-
* as /assets/x.js, which we serve happily. But the BROWSER is at
|
|
10
|
-
* hadoku.me/cardtable/, so a bundle built with the default base emits
|
|
11
|
-
* `src="/assets/x.js"` — an absolute URL with no prefix. The browser asks the
|
|
12
|
-
* edge for hadoku.me/assets/x.js, which is not this app's route, and the page
|
|
13
|
-
* renders blank with a 404 in the console and a 200 on every server-side probe.
|
|
14
|
-
* games-host shipped exactly this: its edge stripPrefix and its backend's base
|
|
15
|
-
* path are two independent declarations of one fact, and nothing compared them.
|
|
16
|
-
*
|
|
17
|
-
* So the kernel's `checkBundle` compares them once, at boot, and says precisely
|
|
18
|
-
* what to change. What is cardtable's own in that check is here.
|
|
19
|
-
*/
|
|
20
|
-
/**
|
|
21
|
-
* The embed bundle's two fixed-name files (D21): `apps/ui/vite.embed.config.ts`
|
|
22
|
-
* emits them, watchparty imports the `.js`. Every other file in the bundle is
|
|
23
|
-
* content-hashed; these are the only ones whose bytes change under one name.
|
|
24
|
-
*/
|
|
25
|
-
export declare const EMBED_ENTRIES: readonly ["cardtable-embed.js", "cardtable-embed.css"];
|
package/dist/base-path.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The base-path contract, checked at boot — cardtable's binding of the
|
|
3
|
-
* platform kernel (`@hadoku/service-kernel/http`).
|
|
4
|
-
*
|
|
5
|
-
* This is the one thing about a loopback-UI app that breaks SILENTLY, so it is
|
|
6
|
-
* the one thing this server refuses to guess about.
|
|
7
|
-
*
|
|
8
|
-
* The edge gives us stripPrefix: hadoku.me/cardtable/assets/x.js arrives here
|
|
9
|
-
* as /assets/x.js, which we serve happily. But the BROWSER is at
|
|
10
|
-
* hadoku.me/cardtable/, so a bundle built with the default base emits
|
|
11
|
-
* `src="/assets/x.js"` — an absolute URL with no prefix. The browser asks the
|
|
12
|
-
* edge for hadoku.me/assets/x.js, which is not this app's route, and the page
|
|
13
|
-
* renders blank with a 404 in the console and a 200 on every server-side probe.
|
|
14
|
-
* games-host shipped exactly this: its edge stripPrefix and its backend's base
|
|
15
|
-
* path are two independent declarations of one fact, and nothing compared them.
|
|
16
|
-
*
|
|
17
|
-
* So the kernel's `checkBundle` compares them once, at boot, and says precisely
|
|
18
|
-
* what to change. What is cardtable's own in that check is here.
|
|
19
|
-
*/
|
|
20
|
-
/**
|
|
21
|
-
* The embed bundle's two fixed-name files (D21): `apps/ui/vite.embed.config.ts`
|
|
22
|
-
* emits them, watchparty imports the `.js`. Every other file in the bundle is
|
|
23
|
-
* content-hashed; these are the only ones whose bytes change under one name.
|
|
24
|
-
*/
|
|
25
|
-
export const EMBED_ENTRIES = ['cardtable-embed.js', 'cardtable-embed.css'];
|
package/dist/busy.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adapter: cardtable's binding of `@hadoku/service-kernel/lifecycle`'s busy probe (w93-K2).
|
|
3
|
-
*
|
|
4
|
-
* The kernel knows only the report's shape, `isLocalProbe` and the HTTP plumbing (fail-safe on
|
|
5
|
-
* `report`'s own throw, 404 to anything proxied). What counts as cardtable's "destroyable work" —
|
|
6
|
-
* a live match or a drafting pod, never a warm JVM or an idle lobby — stays here, unchanged from
|
|
7
|
-
* before this moved (`docs` below is the same text as always).
|
|
8
|
-
*
|
|
9
|
-
* ## What counts as busy — destroyable work, not connections
|
|
10
|
-
*
|
|
11
|
-
* - a match that is `starting` or `running`: a Forge JVM with players seated;
|
|
12
|
-
* - a draft that is `drafting`: picks made, packs mid-pass, held in memory.
|
|
13
|
-
*
|
|
14
|
-
* NOT counted, deliberately:
|
|
15
|
-
*
|
|
16
|
-
* - a match that is `over`, `failed` or `stopped` — finished, nothing left to lose;
|
|
17
|
-
* - a `complete` draft;
|
|
18
|
-
* - **the warm JVM.** `liveJvmCount()` includes it and would report busy every
|
|
19
|
-
* minute of the day; it is a pre-booted process with nobody in it;
|
|
20
|
-
* - **connected-but-idle clients and open lobbies.** They reconnect fine, they
|
|
21
|
-
* never disconnect on their own, and counting them would make every deploy sit
|
|
22
|
-
* until its deadline — at which point the deadline kills the real match anyway.
|
|
23
|
-
*/
|
|
24
|
-
import type { BusyReport } from '@wolffm/service-kernel/lifecycle';
|
|
25
|
-
export interface BusySources {
|
|
26
|
-
matches(): ReadonlyArray<{
|
|
27
|
-
id: string;
|
|
28
|
-
status: string;
|
|
29
|
-
seats: ReadonlyArray<unknown>;
|
|
30
|
-
anyoneHere?: () => boolean;
|
|
31
|
-
}>;
|
|
32
|
-
drafts(): ReadonlyArray<{
|
|
33
|
-
id: string;
|
|
34
|
-
status: string | undefined;
|
|
35
|
-
packNumber?: number;
|
|
36
|
-
pickNumber?: number;
|
|
37
|
-
}>;
|
|
38
|
-
}
|
|
39
|
-
export declare function busyReport(src: BusySources): BusyReport;
|
package/dist/busy.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const BUSY_MATCH = new Set(['starting', 'running']);
|
|
2
|
-
export function busyReport(src) {
|
|
3
|
-
const runs = [];
|
|
4
|
-
for (const m of src.matches()) {
|
|
5
|
-
if (!BUSY_MATCH.has(m.status))
|
|
6
|
-
continue;
|
|
7
|
-
// A running match whose seats have all gone (past the grace) holds nobody's game:
|
|
8
|
-
// the zombie of m-09487f336215 held every deploy for hours on 2026-10-04.
|
|
9
|
-
if (m.status === 'running' && m.anyoneHere !== undefined && !m.anyoneHere())
|
|
10
|
-
continue;
|
|
11
|
-
runs.push({ id: m.id, kind: 'match', label: `${m.seats.length} seats, ${m.status}` });
|
|
12
|
-
}
|
|
13
|
-
for (const d of src.drafts()) {
|
|
14
|
-
if (d.status !== 'drafting')
|
|
15
|
-
continue;
|
|
16
|
-
const at = d.packNumber !== undefined && d.pickNumber !== undefined
|
|
17
|
-
? `pack ${d.packNumber} pick ${d.pickNumber}`
|
|
18
|
-
: 'in progress';
|
|
19
|
-
runs.push({ id: d.id, kind: 'draft', label: at });
|
|
20
|
-
}
|
|
21
|
-
return { busy: runs.length > 0, count: runs.length, runs };
|
|
22
|
-
}
|
package/dist/capacity.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cardtable's binding of the kernel's capacity sampler: a card image request (`http/card-art.ts`)
|
|
3
|
-
* is a redirect to the art host, one per card a page draws, so it is counted on its own as
|
|
4
|
-
* `artRedirects`, never timed nor logged a line each. `index.ts` hands it to `createGameServer`.
|
|
5
|
-
*/
|
|
6
|
-
export declare const ART_REDIRECTS: {
|
|
7
|
-
path: (path: string) => boolean;
|
|
8
|
-
field: string;
|
|
9
|
-
};
|
package/dist/capacity.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cardtable's binding of the kernel's capacity sampler: a card image request (`http/card-art.ts`)
|
|
3
|
-
* is a redirect to the art host, one per card a page draws, so it is counted on its own as
|
|
4
|
-
* `artRedirects`, never timed nor logged a line each. `index.ts` hands it to `createGameServer`.
|
|
5
|
-
*/
|
|
6
|
-
export const ART_REDIRECTS = { path: (path) => path.startsWith('/api/art/'), field: 'artRedirects' };
|