@hadoku/game-server 0.1.209 → 0.1.211
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/config.d.ts +1 -3
- package/dist/config.js +1 -2
- package/dist/play/host.d.ts +1 -0
- package/dist/play/host.js +1 -1
- package/dist/play/local-jvm.d.ts +3 -7
- package/dist/play/local-jvm.js +6 -8
- package/dist/relay-game.js +2 -2
- package/dist/stats/reporter.d.ts +3 -0
- package/dist/stats/reporter.js +4 -0
- package/package.json +5 -5
package/dist/config.d.ts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* test three hops away that never touches a field — ran the whole factory as a side effect.
|
|
19
19
|
*
|
|
20
20
|
* What is NOT here any more: Magic-only settings (catalog, art mirror, draft bot, tournaments,
|
|
21
|
-
* sounds, draft timing, the Forge-hosting envs, the room-stream envs
|
|
21
|
+
* sounds, draft timing, the Forge-hosting envs, the room-stream envs) moved to
|
|
22
22
|
* `games/magic/server/src/config.ts`'s `createMagicConfig`/`MAGIC_CONFIG` (itself lazy the same
|
|
23
23
|
* way) — a game with no Forge engine has no business reading `CARDTABLE_DRAFT_BOT_PICK_MS`.
|
|
24
24
|
* Cardtable's deployment-only ArchiveBot settings moved to `apps/server/src/plugins/archivebot.ts`
|
|
@@ -128,8 +128,6 @@ export interface GameServerConfig {
|
|
|
128
128
|
readonly watchpartyBaseUrl: string;
|
|
129
129
|
/** Every user id this server has admitted, so `caller-first-seen` fires once per account. */
|
|
130
130
|
readonly callersSeenFile: string;
|
|
131
|
-
/** The prefs mount the stats are reported to, without `/api/v1`. */
|
|
132
|
-
readonly statsBaseUrl: string;
|
|
133
131
|
/** The resolved state dir; empty when unset (the in-clone layout). */
|
|
134
132
|
readonly stateDir: string;
|
|
135
133
|
/** Structured access log destination (gitignored, created on boot). */
|
package/dist/config.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* test three hops away that never touches a field — ran the whole factory as a side effect.
|
|
19
19
|
*
|
|
20
20
|
* What is NOT here any more: Magic-only settings (catalog, art mirror, draft bot, tournaments,
|
|
21
|
-
* sounds, draft timing, the Forge-hosting envs, the room-stream envs
|
|
21
|
+
* sounds, draft timing, the Forge-hosting envs, the room-stream envs) moved to
|
|
22
22
|
* `games/magic/server/src/config.ts`'s `createMagicConfig`/`MAGIC_CONFIG` (itself lazy the same
|
|
23
23
|
* way) — a game with no Forge engine has no business reading `CARDTABLE_DRAFT_BOT_PICK_MS`.
|
|
24
24
|
* Cardtable's deployment-only ArchiveBot settings moved to `apps/server/src/plugins/archivebot.ts`
|
|
@@ -71,7 +71,6 @@ export function createConfig(options = {}) {
|
|
|
71
71
|
monitoringBaseUrl: read('MONITORING_BASE_URL') || 'https://hadoku.me',
|
|
72
72
|
watchpartyBaseUrl: read('WATCHPARTY_BASE_URL') || 'https://hadoku.me/watchparty',
|
|
73
73
|
callersSeenFile: resolveDir(read('CALLERS_SEEN_FILE') ?? join(dataDir, 'callers-seen.json')),
|
|
74
|
-
statsBaseUrl: read('STATS_BASE_URL') || 'https://hadoku.me/prefs',
|
|
75
74
|
stateDir,
|
|
76
75
|
logDir,
|
|
77
76
|
dataDir,
|
package/dist/play/host.d.ts
CHANGED
|
@@ -400,6 +400,7 @@ export declare const ORPHAN_MAX_MS: number;
|
|
|
400
400
|
export declare const ORPHAN_CLAIM_MS = 60000;
|
|
401
401
|
/** A match's stream: every line and command, in order, for a re-attach to replay. */
|
|
402
402
|
export declare function streamFile(dir: string, matchId: string): string;
|
|
403
|
+
export declare const LINE_TYPES: ReadonlySet<string>;
|
|
403
404
|
/**
|
|
404
405
|
* The `bridge.stderr.txt` of the local JVM that hosts `matchId`, found by the `match-placed`
|
|
405
406
|
* line the coordinator logged to that match's log. A JVM's run directory is named for the JVM,
|
package/dist/play/host.js
CHANGED
|
@@ -167,7 +167,7 @@ export function streamFile(dir, matchId) {
|
|
|
167
167
|
function brokenStreamFile(dir, matchId) {
|
|
168
168
|
return join(dir, `${matchId}.broken.jsonl`);
|
|
169
169
|
}
|
|
170
|
-
const LINE_TYPES = new Set(['ready', 'frame', 'probe', 'gameover', 'log', 'fatal', 'rejected', 'stale', 'unsupported', 'pace', 'pace-read', 'resent', 'applied', 'input', 'dropped', 'snapshot', 'impersonated', 'scan-overtaken', 'undo', 'rewind', 'rewound', 'log-truncated']);
|
|
170
|
+
export const LINE_TYPES = new Set(['ready', 'frame', 'probe', 'gameover', 'log', 'fatal', 'rejected', 'stale', 'unsupported', 'pace', 'pace-read', 'resent', 'applied', 'input', 'dropped', 'snapshot', 'impersonated', 'scan-overtaken', 'undo', 'rewind', 'rewound', 'log-truncated']);
|
|
171
171
|
/**
|
|
172
172
|
* The `bridge.stderr.txt` of the local JVM that hosts `matchId`, found by the `match-placed`
|
|
173
173
|
* line the coordinator logged to that match's log. A JVM's run directory is named for the JVM,
|
package/dist/play/local-jvm.d.ts
CHANGED
|
@@ -169,17 +169,13 @@ export type JvmAvailability = {
|
|
|
169
169
|
};
|
|
170
170
|
/** Where compiled bridges are kept, shared by every tree on the host (keyed by `bridgeVersion`). */
|
|
171
171
|
export declare function defaultBridgeCache(env?: NodeJS.ProcessEnv): string;
|
|
172
|
+
/** Where a Forge match's run directories go (`CARDTABLE_PLAY_WORK_DIR`). */
|
|
173
|
+
export declare function playWorkDir(env?: NodeJS.ProcessEnv): string;
|
|
172
174
|
/**
|
|
173
175
|
* Resolve the JVM host's configuration, or say exactly what is missing. `bridgeSource` is the game's
|
|
174
176
|
* own bridge (Magic's is `@hadoku/magic-server/root`'s `BRIDGE_SOURCE`): the platform knows no game's tree.
|
|
175
|
-
*
|
|
176
|
-
* `workDir`, when given, is INJECTED by the caller rather than read here (w120 §K: Magic's own
|
|
177
|
-
* `games/magic/server/src/config.ts` has its own `playWorkDir`, which every Magic caller —
|
|
178
|
-
* `plugins/library.ts`, `play/scenario.ts`, `play/recording/rebuild.ts` — passes through this
|
|
179
|
-
* param). Omitted, this file falls back to its own generic default, unchanged from before this
|
|
180
|
-
* param existed, for every other caller (scripts, the UI's jvm harness) that passes none.
|
|
181
177
|
*/
|
|
182
|
-
export declare function jvmHostConfig(bridgeSource: string, env?: NodeJS.ProcessEnv
|
|
178
|
+
export declare function jvmHostConfig(bridgeSource: string, env?: NodeJS.ProcessEnv): JvmAvailability;
|
|
183
179
|
/**
|
|
184
180
|
* A compiled bridge nobody has launched for this long is removed when the next
|
|
185
181
|
* one is compiled. Far past `ORPHAN_MAX_MS`, so no JVM that could still load a
|
package/dist/play/local-jvm.js
CHANGED
|
@@ -143,17 +143,15 @@ export const JVM_HEAP_MB = 2048;
|
|
|
143
143
|
export function defaultBridgeCache(env = process.env) {
|
|
144
144
|
return resolve(env.CARDTABLE_PLAY_BRIDGE_CACHE ?? join(env.XDG_CACHE_HOME ?? join(homedir(), '.cache'), 'cardtable', 'bridge'));
|
|
145
145
|
}
|
|
146
|
+
/** Where a Forge match's run directories go (`CARDTABLE_PLAY_WORK_DIR`). */
|
|
147
|
+
export function playWorkDir(env = process.env) {
|
|
148
|
+
return resolve(env.CARDTABLE_PLAY_WORK_DIR ?? join(tmpdir(), 'cardtable-play'));
|
|
149
|
+
}
|
|
146
150
|
/**
|
|
147
151
|
* Resolve the JVM host's configuration, or say exactly what is missing. `bridgeSource` is the game's
|
|
148
152
|
* own bridge (Magic's is `@hadoku/magic-server/root`'s `BRIDGE_SOURCE`): the platform knows no game's tree.
|
|
149
|
-
*
|
|
150
|
-
* `workDir`, when given, is INJECTED by the caller rather than read here (w120 §K: Magic's own
|
|
151
|
-
* `games/magic/server/src/config.ts` has its own `playWorkDir`, which every Magic caller —
|
|
152
|
-
* `plugins/library.ts`, `play/scenario.ts`, `play/recording/rebuild.ts` — passes through this
|
|
153
|
-
* param). Omitted, this file falls back to its own generic default, unchanged from before this
|
|
154
|
-
* param existed, for every other caller (scripts, the UI's jvm harness) that passes none.
|
|
155
153
|
*/
|
|
156
|
-
export function jvmHostConfig(bridgeSource, env = process.env
|
|
154
|
+
export function jvmHostConfig(bridgeSource, env = process.env) {
|
|
157
155
|
const jar = env.CARDTABLE_FORGE_JAR ?? '';
|
|
158
156
|
const res = env.CARDTABLE_FORGE_RES ?? '';
|
|
159
157
|
if (jar === '')
|
|
@@ -173,7 +171,7 @@ export function jvmHostConfig(bridgeSource, env = process.env, workDir) {
|
|
|
173
171
|
java: env.CARDTABLE_JAVA ?? defaultJava(env),
|
|
174
172
|
jar: resolve(jar),
|
|
175
173
|
res: resolve(res),
|
|
176
|
-
workDir:
|
|
174
|
+
workDir: playWorkDir(env),
|
|
177
175
|
jvmOpts: (env.CARDTABLE_PLAY_JVM_OPTS ?? '').split(/\s+/).filter((s) => s !== ''),
|
|
178
176
|
bridgeSource,
|
|
179
177
|
bridgeCache: defaultBridgeCache(env),
|
package/dist/relay-game.js
CHANGED
|
@@ -49,7 +49,7 @@ import { MATCH_LIVE, RoomLobby, plainRoomType } from './room/lobby.js';
|
|
|
49
49
|
import { attachServedRoom } from './room/serve.js';
|
|
50
50
|
import { COUNTDOWN_MS, createStarts } from './room/starts.js';
|
|
51
51
|
import { attachRoomFeed } from './room/watching.js';
|
|
52
|
-
import {
|
|
52
|
+
import { statsReporterFor } from './stats/reporter.js';
|
|
53
53
|
import { attachResultRoute } from './stats/relay-results.js';
|
|
54
54
|
/** The lobby a relay game's rooms live in: a room IS its match, and there is one game type. */
|
|
55
55
|
export class RelayLobby extends RoomLobby {
|
|
@@ -192,7 +192,7 @@ export async function startRelayGame(options) {
|
|
|
192
192
|
const results = options.results;
|
|
193
193
|
if (results !== undefined) {
|
|
194
194
|
const statsLog = jsonLogger(`${id}-stats`);
|
|
195
|
-
const stats =
|
|
195
|
+
const stats = statsReporterFor(config, `${envPrefix}_SERVICE_KEY`, id, statsLog);
|
|
196
196
|
attachResultRoute(ctx.api, {
|
|
197
197
|
lobby,
|
|
198
198
|
userKeys: ctx.state.userKeys,
|
package/dist/stats/reporter.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* match twice. Moved here from hadoku-bomberman; any game reporting matches uses it.
|
|
6
6
|
*/
|
|
7
7
|
import { type MatchReport, type RecordMatchOptions, type RecordMatchResult } from '@wolffm/prefs-client/games';
|
|
8
|
+
import type { GameServerConfig } from '../config.js';
|
|
8
9
|
export type RecordMatch = (opts: RecordMatchOptions, report: MatchReport) => Promise<RecordMatchResult>;
|
|
9
10
|
export interface StatsReporterOptions {
|
|
10
11
|
/** The store's game id: `/_games/<gameId>/*`. */
|
|
@@ -40,3 +41,5 @@ export declare const DEFAULT_RETRY_DELAYS_MS: readonly [2000, 10000, 60000];
|
|
|
40
41
|
* round twice.
|
|
41
42
|
*/
|
|
42
43
|
export declare function createStatsReporter(opts: StatsReporterOptions): StatsReporter;
|
|
44
|
+
/** A game's reporter from its server config: its service key, and the prefs mount the store is under. */
|
|
45
|
+
export declare function statsReporterFor({ serviceKey, prefsBaseUrl }: Pick<GameServerConfig, 'serviceKey' | 'prefsBaseUrl'>, serviceKeyEnvVar: string, gameId: string, log: (line: Record<string, unknown>) => void): StatsReporter;
|
package/dist/stats/reporter.js
CHANGED
|
@@ -85,3 +85,7 @@ export function createStatsReporter(opts) {
|
|
|
85
85
|
},
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
|
+
/** A game's reporter from its server config: its service key, and the prefs mount the store is under. */
|
|
89
|
+
export function statsReporterFor({ serviceKey, prefsBaseUrl }, serviceKeyEnvVar, gameId, log) {
|
|
90
|
+
return createStatsReporter({ gameId, serviceKey, serviceKeyEnvVar, baseUrl: prefsBaseUrl, log });
|
|
91
|
+
}
|
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.211",
|
|
4
|
+
"gitHead": "0ea202e41619bdb176bbbc6c030ed3940611a093",
|
|
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.",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"play/remote/"
|
|
18
18
|
],
|
|
19
19
|
"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.
|
|
20
|
+
"@wolffm/host-wire": "npm:@hadoku/host-wire@0.1.211",
|
|
21
|
+
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.211",
|
|
22
|
+
"@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.244",
|
|
23
23
|
"@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.3",
|
|
24
24
|
"@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.152",
|
|
25
25
|
"@wolffm/rooms-server": "npm:@hadoku/rooms-server@^0.45.152",
|