@hadoku/game-server 0.1.17 → 0.1.19
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 +41 -25
- package/dist/config.js +54 -28
- package/dist/play/host.d.ts +26 -56
- package/dist/play/local-jvm.d.ts +7 -1
- package/dist/play/local-jvm.js +9 -4
- package/dist/play/runtimes/relay-match.js +1 -1
- package/package.json +5 -5
package/dist/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Runtime config for a game-server app — the PLATFORM half (w119 §C).
|
|
2
|
+
* Runtime config for a game-server app — the PLATFORM half (w119 §C, w120 §K).
|
|
3
3
|
*
|
|
4
4
|
* `createConfig` is a factory: every value it returns comes from the `env` object and `envPrefix`
|
|
5
5
|
* it is called with (defaults: `process.env` and `'CARDTABLE'`), read when the factory RUNS, never
|
|
@@ -7,17 +7,25 @@
|
|
|
7
7
|
* env objects, build two independent configs — which is what lets a second game on
|
|
8
8
|
* `@hadoku/game-server` (bomberman) set its own `BOMBERMAN_*` variables instead of cardtable's.
|
|
9
9
|
*
|
|
10
|
-
* `export const CONFIG
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* `export const CONFIG` below is cardtable's own instance — kept for every file that already does
|
|
11
|
+
* `import { CONFIG } from '@wolffm/game-server/config'` and must keep working unchanged, field
|
|
12
|
+
* access and all (an `edge-auth.test.ts` case casts it to a mutable mapped type and swaps a field
|
|
13
|
+
* for the case, then restores it). w120 §K: it is no longer built "the moment this module is
|
|
14
|
+
* first imported" — {@link lazyConfig} defers the one `createConfig()` call (the tier floor's
|
|
15
|
+
* fail-closed check included) to the first property READ of any kind, which in production is the
|
|
16
|
+
* app's own boot (`apps/server/src/index.ts`'s first `CONFIG.host`), not merely the module graph
|
|
17
|
+
* happening to reach this file. Before this wave, importing `config.ts` for ANY reason — even a
|
|
18
|
+
* test three hops away that never touches a field — ran the whole factory as a side effect.
|
|
13
19
|
*
|
|
14
20
|
* What is NOT here any more: Magic-only settings (catalog, art mirror, draft bot, tournaments,
|
|
15
|
-
* sounds, draft timing, the Forge-hosting envs, the room-stream envs) moved to
|
|
16
|
-
* `games/magic/server/src/config.ts`'s `createMagicConfig`/`MAGIC_CONFIG`
|
|
17
|
-
* engine has no business reading `CARDTABLE_DRAFT_BOT_PICK_MS`.
|
|
18
|
-
*
|
|
19
|
-
* `games/magic/server/src/plugins/{listen,routes}.ts`, are in the
|
|
20
|
-
* import `apps/server` (the `site` layer) — see
|
|
21
|
+
* sounds, draft timing, the Forge-hosting envs, the room-stream envs, `playWorkDir`) moved to
|
|
22
|
+
* `games/magic/server/src/config.ts`'s `createMagicConfig`/`MAGIC_CONFIG` (itself lazy the same
|
|
23
|
+
* way) — a game with no Forge engine has no business reading `CARDTABLE_DRAFT_BOT_PICK_MS`.
|
|
24
|
+
* Cardtable's deployment-only ArchiveBot settings moved to `apps/server/src/plugins/archivebot.ts`
|
|
25
|
+
* (w120 §K): its two readers, `games/magic/server/src/plugins/{listen,routes}.ts`, are in the
|
|
26
|
+
* `magic` layer, which may not import `apps/server` (the `site` layer) — see
|
|
27
|
+
* `scripts/layers/layers.json`'s allowed directions; the site plugin injects the settings onto
|
|
28
|
+
* `ctx.state.archivebot` instead.
|
|
21
29
|
* Survey: `~/.cache/cardtable-manager/bomberman-survey-2026-11-16.md` §3 has the classification
|
|
22
30
|
* with the original line numbers.
|
|
23
31
|
*/
|
|
@@ -150,22 +158,30 @@ export interface GameServerConfig {
|
|
|
150
158
|
/** Everything a game-server app needs that is not specific to any one game (w119 §C). */
|
|
151
159
|
export declare function createConfig(options?: CreateConfigOptions): GameServerConfig;
|
|
152
160
|
/**
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
161
|
+
* Wraps `factory` so it runs on first property access instead of as a side effect of merely
|
|
162
|
+
* importing the module that calls this (w120 §K). Until then, `target` is an empty, extensible
|
|
163
|
+
* plain object: `materialize()` calls `factory()` exactly once (cached in `built`) and then
|
|
164
|
+
* delegates every trap straight to the real result through `Reflect`, so after the first access
|
|
165
|
+
* `target` behaves exactly like `factory()`'s own return value always did — a live getter on it
|
|
166
|
+
* (`MagicConfig.playSeed`'s "read this each time") stays live, and a plain field stays a plain,
|
|
167
|
+
* writable, enumerable one. Exported for `games/magic/server/src/config.ts`'s `MAGIC_CONFIG`,
|
|
168
|
+
* which wants the same deferral.
|
|
169
|
+
*/
|
|
170
|
+
export declare function lazyConfig<T extends object>(factory: () => T): T;
|
|
171
|
+
/**
|
|
172
|
+
* Cardtable's own instance (every existing `import { CONFIG } from '@wolffm/game-server/config'`
|
|
173
|
+
* keeps working unchanged) — built on first property access, not at import ({@link lazyConfig}).
|
|
174
|
+
* Not `as const`: several test suites (`edge-auth.test.ts`) cast this to a mutable mapped type and
|
|
175
|
+
* swap individual fields for a case, then restore them — that only works on a plain object, which
|
|
176
|
+
* this still is once materialized.
|
|
157
177
|
*/
|
|
158
178
|
export declare const CONFIG: GameServerConfig;
|
|
159
179
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
* module; moving it would break that file's import with no file in this wave's briefs allowed to
|
|
167
|
-
* fix it. `local-jvm.ts` itself is written generic over "any JVM-hosted engine", so this is
|
|
168
|
-
* defensible as the local JVM launcher's own platform-level default, not only Forge's.
|
|
180
|
+
* `webDir/index.html` — a function, not a plain constant, so reading it cannot itself be the
|
|
181
|
+
* thing that forces {@link CONFIG} to materialize merely by being imported (w120 §K: this was
|
|
182
|
+
* `export const INDEX_HTML = join(CONFIG.webDir, …)`, which read `CONFIG.webDir` the moment this
|
|
183
|
+
* module was first imported, defeating `lazyConfig` for every field, floor check included). Both
|
|
184
|
+
* readers (`apps/server/src/index.ts`, `games/magic/server/src/plugins/routes.ts`) call this from
|
|
185
|
+
* inside their own boot step, not at their own module's top level.
|
|
169
186
|
*/
|
|
170
|
-
export declare function
|
|
171
|
-
export declare const INDEX_HTML: string;
|
|
187
|
+
export declare function indexHtml(): string;
|
package/dist/config.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Runtime config for a game-server app — the PLATFORM half (w119 §C).
|
|
2
|
+
* Runtime config for a game-server app — the PLATFORM half (w119 §C, w120 §K).
|
|
3
3
|
*
|
|
4
4
|
* `createConfig` is a factory: every value it returns comes from the `env` object and `envPrefix`
|
|
5
5
|
* it is called with (defaults: `process.env` and `'CARDTABLE'`), read when the factory RUNS, never
|
|
@@ -7,21 +7,28 @@
|
|
|
7
7
|
* env objects, build two independent configs — which is what lets a second game on
|
|
8
8
|
* `@hadoku/game-server` (bomberman) set its own `BOMBERMAN_*` variables instead of cardtable's.
|
|
9
9
|
*
|
|
10
|
-
* `export const CONFIG
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* `export const CONFIG` below is cardtable's own instance — kept for every file that already does
|
|
11
|
+
* `import { CONFIG } from '@wolffm/game-server/config'` and must keep working unchanged, field
|
|
12
|
+
* access and all (an `edge-auth.test.ts` case casts it to a mutable mapped type and swaps a field
|
|
13
|
+
* for the case, then restores it). w120 §K: it is no longer built "the moment this module is
|
|
14
|
+
* first imported" — {@link lazyConfig} defers the one `createConfig()` call (the tier floor's
|
|
15
|
+
* fail-closed check included) to the first property READ of any kind, which in production is the
|
|
16
|
+
* app's own boot (`apps/server/src/index.ts`'s first `CONFIG.host`), not merely the module graph
|
|
17
|
+
* happening to reach this file. Before this wave, importing `config.ts` for ANY reason — even a
|
|
18
|
+
* test three hops away that never touches a field — ran the whole factory as a side effect.
|
|
13
19
|
*
|
|
14
20
|
* What is NOT here any more: Magic-only settings (catalog, art mirror, draft bot, tournaments,
|
|
15
|
-
* sounds, draft timing, the Forge-hosting envs, the room-stream envs) moved to
|
|
16
|
-
* `games/magic/server/src/config.ts`'s `createMagicConfig`/`MAGIC_CONFIG`
|
|
17
|
-
* engine has no business reading `CARDTABLE_DRAFT_BOT_PICK_MS`.
|
|
18
|
-
*
|
|
19
|
-
* `games/magic/server/src/plugins/{listen,routes}.ts`, are in the
|
|
20
|
-
* import `apps/server` (the `site` layer) — see
|
|
21
|
+
* sounds, draft timing, the Forge-hosting envs, the room-stream envs, `playWorkDir`) moved to
|
|
22
|
+
* `games/magic/server/src/config.ts`'s `createMagicConfig`/`MAGIC_CONFIG` (itself lazy the same
|
|
23
|
+
* way) — a game with no Forge engine has no business reading `CARDTABLE_DRAFT_BOT_PICK_MS`.
|
|
24
|
+
* Cardtable's deployment-only ArchiveBot settings moved to `apps/server/src/plugins/archivebot.ts`
|
|
25
|
+
* (w120 §K): its two readers, `games/magic/server/src/plugins/{listen,routes}.ts`, are in the
|
|
26
|
+
* `magic` layer, which may not import `apps/server` (the `site` layer) — see
|
|
27
|
+
* `scripts/layers/layers.json`'s allowed directions; the site plugin injects the settings onto
|
|
28
|
+
* `ctx.state.archivebot` instead.
|
|
21
29
|
* Survey: `~/.cache/cardtable-manager/bomberman-survey-2026-11-16.md` §3 has the classification
|
|
22
30
|
* with the original line numbers.
|
|
23
31
|
*/
|
|
24
|
-
import { tmpdir } from 'node:os';
|
|
25
32
|
import { fileURLToPath } from 'node:url';
|
|
26
33
|
import { basename, dirname, isAbsolute, join, resolve } from 'node:path';
|
|
27
34
|
import { assertFloor as kernelAssertFloor } from '@wolffm/service-kernel/auth';
|
|
@@ -79,24 +86,43 @@ export function createConfig(options = {}) {
|
|
|
79
86
|
};
|
|
80
87
|
}
|
|
81
88
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
89
|
+
* Wraps `factory` so it runs on first property access instead of as a side effect of merely
|
|
90
|
+
* importing the module that calls this (w120 §K). Until then, `target` is an empty, extensible
|
|
91
|
+
* plain object: `materialize()` calls `factory()` exactly once (cached in `built`) and then
|
|
92
|
+
* delegates every trap straight to the real result through `Reflect`, so after the first access
|
|
93
|
+
* `target` behaves exactly like `factory()`'s own return value always did — a live getter on it
|
|
94
|
+
* (`MagicConfig.playSeed`'s "read this each time") stays live, and a plain field stays a plain,
|
|
95
|
+
* writable, enumerable one. Exported for `games/magic/server/src/config.ts`'s `MAGIC_CONFIG`,
|
|
96
|
+
* which wants the same deferral.
|
|
86
97
|
*/
|
|
87
|
-
export
|
|
98
|
+
export function lazyConfig(factory) {
|
|
99
|
+
let built;
|
|
100
|
+
const materialize = () => (built ??= factory());
|
|
101
|
+
return new Proxy({}, {
|
|
102
|
+
get: (_t, prop) => Reflect.get(materialize(), prop),
|
|
103
|
+
set: (_t, prop, value) => Reflect.set(materialize(), prop, value),
|
|
104
|
+
has: (_t, prop) => Reflect.has(materialize(), prop),
|
|
105
|
+
ownKeys: () => Reflect.ownKeys(materialize()),
|
|
106
|
+
getOwnPropertyDescriptor: (_t, prop) => Reflect.getOwnPropertyDescriptor(materialize(), prop),
|
|
107
|
+
deleteProperty: (_t, prop) => Reflect.deleteProperty(materialize(), prop),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
88
110
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
*
|
|
111
|
+
* Cardtable's own instance (every existing `import { CONFIG } from '@wolffm/game-server/config'`
|
|
112
|
+
* keeps working unchanged) — built on first property access, not at import ({@link lazyConfig}).
|
|
113
|
+
* Not `as const`: several test suites (`edge-auth.test.ts`) cast this to a mutable mapped type and
|
|
114
|
+
* swap individual fields for a case, then restore them — that only works on a plain object, which
|
|
115
|
+
* this still is once materialized.
|
|
116
|
+
*/
|
|
117
|
+
export const CONFIG = lazyConfig(createConfig);
|
|
118
|
+
/**
|
|
119
|
+
* `webDir/index.html` — a function, not a plain constant, so reading it cannot itself be the
|
|
120
|
+
* thing that forces {@link CONFIG} to materialize merely by being imported (w120 §K: this was
|
|
121
|
+
* `export const INDEX_HTML = join(CONFIG.webDir, …)`, which read `CONFIG.webDir` the moment this
|
|
122
|
+
* module was first imported, defeating `lazyConfig` for every field, floor check included). Both
|
|
123
|
+
* readers (`apps/server/src/index.ts`, `games/magic/server/src/plugins/routes.ts`) call this from
|
|
124
|
+
* inside their own boot step, not at their own module's top level.
|
|
98
125
|
*/
|
|
99
|
-
export function
|
|
100
|
-
return
|
|
126
|
+
export function indexHtml() {
|
|
127
|
+
return join(CONFIG.webDir, 'index.html');
|
|
101
128
|
}
|
|
102
|
-
export const INDEX_HTML = join(CONFIG.webDir, 'index.html');
|
package/dist/play/host.d.ts
CHANGED
|
@@ -126,8 +126,6 @@ export interface SeatSpec {
|
|
|
126
126
|
/** Forge's player name. Shown to both seats, so never an identity. */
|
|
127
127
|
name: string;
|
|
128
128
|
ai: boolean;
|
|
129
|
-
/** `.dck` text, or null for a random Forge precon. */
|
|
130
|
-
deck: string | null;
|
|
131
129
|
}
|
|
132
130
|
/**
|
|
133
131
|
* A bot game: Forge's AI against Forge's AI, best of `bestOf`, each game drawn past `gameS` seconds
|
|
@@ -139,24 +137,27 @@ export interface HeadlessRules {
|
|
|
139
137
|
gameS: number;
|
|
140
138
|
}
|
|
141
139
|
/**
|
|
142
|
-
* What a match needs to start, generic over the game `G`'s own extra fields (w119 §C).
|
|
143
|
-
* `seats` (its length) and {@link MatchSpec.headless} (its presence) are read by this file's
|
|
144
|
-
* coordinator — everything else below is opaque to it: spread onto `config.json`
|
|
145
|
-
* and kept whole in `JvmRecord`, never interpreted here.
|
|
140
|
+
* What a match needs to start, generic over the game `G`'s own extra fields (w119 §C, w120 §K).
|
|
141
|
+
* Only `seats` (its length) and {@link MatchSpec.headless} (its presence) are read by this file's
|
|
142
|
+
* own coordinator — everything else below is opaque to it: spread onto `config.json`
|
|
143
|
+
* (`bridgeConfig`) and kept whole in `JvmRecord`, never interpreted here.
|
|
146
144
|
*
|
|
147
145
|
* `G`'s default, `unknown` (so `KnownFields & unknown` simplifies back to `KnownFields`), keeps every existing bare `MatchSpec` (no type
|
|
148
|
-
* argument) call site reading exactly the shape below
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
* `
|
|
159
|
-
*
|
|
146
|
+
* argument) call site reading exactly the shape below. w120 §K moved the four fields that were
|
|
147
|
+
* Forge-only in principle AND in practice — `.dck` text (off {@link SeatSpec}), puzzle scenarios
|
|
148
|
+
* (`scenario`/`skipOpening`/`restore`) and coin-toss rigging (`chooser`) — out of this base and
|
|
149
|
+
* into Magic's own `games/magic/server/src/play/forge-spec.ts` (`ForgeMatchSpec`/`ForgeSeatSpec`),
|
|
150
|
+
* which every Magic reader of a real match's spec now imports instead of this bare type:
|
|
151
|
+
* `match.ts` (`SeatSpecWithIdentity`/`MatchSpecWithIdentity`), `botgames.ts`, `parked.ts`,
|
|
152
|
+
* `deck-colors.ts`, `table-game.ts`, `art.ts`, `recording/{recorder,rebuild}.ts`,
|
|
153
|
+
* `match/{registry,forge-session}.ts`, `socket.ts`, `http/routes.ts`. `format`, `handSmoothing`,
|
|
154
|
+
* `clockMs`, `seed` and `headless` stay here: none of the four were named by the brief, each is
|
|
155
|
+
* arguably generic to any room-hosted game (a format id, a clock, a seed, a bot game), and
|
|
156
|
+
* `fixtures/toy-game/*` and `runtimes/relay-match.ts` build a bare `MatchSpec` directly, so moving
|
|
157
|
+
* them would widen this change past what was asked. `seats` is a plain array, not the old 2-tuple
|
|
158
|
+
* with "seat 0 is never AI" encoded in its type (that rule is `socket.ts`'s/the bridge's to
|
|
159
|
+
* enforce, not this type's) — so `runtimes/relay-match.ts`'s pod-sized, no-AI roster needs no
|
|
160
|
+
* `as unknown as MatchSpec` to fit it.
|
|
160
161
|
*/
|
|
161
162
|
export type MatchSpec<G = unknown> = {
|
|
162
163
|
/** Every seat this match starts with. */
|
|
@@ -166,31 +167,14 @@ export type MatchSpec<G = unknown> = {
|
|
|
166
167
|
/** Seeds Forge's shuffles and the precon pick, for a repeatable test run. Omitted in play. */
|
|
167
168
|
seed?: number;
|
|
168
169
|
/**
|
|
169
|
-
*
|
|
170
|
-
* `
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* `BridgeGui.hostMatch` applies it from `HostedMatch`'s own start-game hook —
|
|
176
|
-
* see that method's doc. Omitted in play: `socket.ts`'s `parseStartBody`
|
|
177
|
-
* accepts this key only behind `CARDTABLE_PLAY_PROBE=1` and refuses it
|
|
178
|
-
* otherwise, so production never sends one.
|
|
179
|
-
*/
|
|
180
|
-
scenario?: string;
|
|
181
|
-
/**
|
|
182
|
-
* Start on {@link scenario}'s board with no coin toss and no mulligan — Forge's
|
|
183
|
-
* own Puzzle game type, which skips both (`GameAction.startGame`). Set only by
|
|
184
|
-
* `socket.ts` for a board-state room's own scenario; a test's scenario keeps the
|
|
185
|
-
* ordinary opening its drivers click through.
|
|
170
|
+
* Opaque per-game resume text, opened and written by `G`'s own `GameAdapter.restoreSpec`
|
|
171
|
+
* (`game-adapter.ts`) — never read here. `fixtures/toy-game/rules.ts`'s `playToy` reads its own
|
|
172
|
+
* JSON-encoded checkpoint back from this; Magic's `ForgeMatchSpec.scenario`
|
|
173
|
+
* (`games/magic/server/src/play/forge-spec.ts`, w120 §K) is the Forge-shaped equivalent, kept
|
|
174
|
+
* apart from this generic field because `PlayBridge.java`'s `configFrom` reads `scenario` by
|
|
175
|
+
* that exact key, not whatever a non-Forge `G` happens to call its own resume data.
|
|
186
176
|
*/
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* {@link scenario} is this match's own turn-start snapshot (`restoredSpec`): its board goes back
|
|
190
|
-
* as it was, running no replacement effect ("enters tapped", "you may pay 2 life"), where a
|
|
191
|
-
* board room's scenario plays each permanent's entry. Implies {@link skipOpening}.
|
|
192
|
-
*/
|
|
193
|
-
restore?: boolean;
|
|
177
|
+
resumeData?: string;
|
|
194
178
|
/**
|
|
195
179
|
* The room's format id (`room/lobby.ts`'s `FormatId`): what a card-name ask is
|
|
196
180
|
* narrowed to (`names.ts`). Inert in the JVM — `configFrom` never reads it — and
|
|
@@ -205,20 +189,6 @@ export type MatchSpec<G = unknown> = {
|
|
|
205
189
|
* spec built directly, as the jvm suites build theirs, deals what it always did.
|
|
206
190
|
*/
|
|
207
191
|
handSmoothing?: boolean;
|
|
208
|
-
/**
|
|
209
|
-
* Wave 71 §E — names the seat Forge asks to choose play or draw. Every game we
|
|
210
|
-
* host is a fresh Forge `Match`, so Forge always treats it as the FIRST game of
|
|
211
|
-
* that match and tosses a coin (`GameAction.determineFirstTurnPlayer`,
|
|
212
|
-
* `forge/forge-game/src/main/java/forge/game/GameAction.java:2364-2416`) rather
|
|
213
|
-
* than asking the previous loser — this field is how the room still names that
|
|
214
|
-
* player. `PlayBridge.java`'s `startMatch` rigs the coin toss so the named seat
|
|
215
|
-
* is the one Forge asks (`SeatGui`'s `updateButtons` with `label1:'Play',
|
|
216
|
-
* label2:'Draw'`), which makes the published `coinToss.winner` (`match.ts:1055`)
|
|
217
|
-
* that seat too — the client's existing flip/notice needs no change. Omitted:
|
|
218
|
-
* byte-identical to today, an unrigged coin toss. Never set alongside a change
|
|
219
|
-
* to `forge/` — a fork change is a jar switch, and that switch is the operator's.
|
|
220
|
-
*/
|
|
221
|
-
chooser?: 0 | 1;
|
|
222
192
|
/**
|
|
223
193
|
* The chess clock: each seat's time left, in ms, when this game starts — a room
|
|
224
194
|
* with the clock on carries what the series' last game left (`play/clock.ts`).
|
package/dist/play/local-jvm.d.ts
CHANGED
|
@@ -161,8 +161,14 @@ export declare function defaultBridgeCache(env?: NodeJS.ProcessEnv): string;
|
|
|
161
161
|
/**
|
|
162
162
|
* Resolve the JVM host's configuration, or say exactly what is missing. `bridgeSource` is the game's
|
|
163
163
|
* own bridge (Magic's is `@hadoku/magic-server/root`'s `BRIDGE_SOURCE`): the platform knows no game's tree.
|
|
164
|
+
*
|
|
165
|
+
* `workDir`, when given, is INJECTED by the caller rather than read here (w120 §K: Magic's own
|
|
166
|
+
* `games/magic/server/src/config.ts` has its own `playWorkDir`, which every Magic caller —
|
|
167
|
+
* `plugins/library.ts`, `play/scenario.ts`, `play/recording/rebuild.ts` — passes through this
|
|
168
|
+
* param). Omitted, this file falls back to its own generic default, unchanged from before this
|
|
169
|
+
* param existed, for every other caller (scripts, the UI's jvm harness) that passes none.
|
|
164
170
|
*/
|
|
165
|
-
export declare function jvmHostConfig(bridgeSource: string, env?: NodeJS.ProcessEnv): JvmAvailability;
|
|
171
|
+
export declare function jvmHostConfig(bridgeSource: string, env?: NodeJS.ProcessEnv, workDir?: string): JvmAvailability;
|
|
166
172
|
/**
|
|
167
173
|
* A compiled bridge nobody has launched for this long is removed when the next
|
|
168
174
|
* one is compiled. Far past `ORPHAN_MAX_MS`, so no JVM that could still load a
|
package/dist/play/local-jvm.js
CHANGED
|
@@ -76,10 +76,9 @@
|
|
|
76
76
|
import { spawn, spawnSync } from 'node:child_process';
|
|
77
77
|
import { createHash, randomBytes } from 'node:crypto';
|
|
78
78
|
import { closeSync, existsSync, mkdirSync, openSync, readdirSync, readSync, readFileSync, realpathSync, renameSync, rmSync, statSync, symlinkSync, utimesSync, writeFileSync, } from 'node:fs';
|
|
79
|
-
import { homedir } from 'node:os';
|
|
79
|
+
import { homedir, tmpdir } from 'node:os';
|
|
80
80
|
import { basename, dirname, join, resolve } from 'node:path';
|
|
81
81
|
import { createInterface } from 'node:readline';
|
|
82
|
-
import { playWorkDir } from '../config.js';
|
|
83
82
|
import { bridgeDiagnostics } from './diagnostics.js';
|
|
84
83
|
import { CRASH_MARKER, IN_FIFO, JVM_TMP_DIR, OUT_FIFO, PID_POLL_MS, REAP_CONFIRM_MS, cwdIsUnder, defaultJava, killPid, makeFifos, openJvmIo, pidIsRunning, pidIsStandingIn, pidIsStandingInRun, positiveInt, processCwds, pruneCrashRecords, runDirs, sleepSync, wrapChildProcess, } from './engine-runtime.js';
|
|
85
84
|
/**
|
|
@@ -135,8 +134,14 @@ export function defaultBridgeCache(env = process.env) {
|
|
|
135
134
|
/**
|
|
136
135
|
* Resolve the JVM host's configuration, or say exactly what is missing. `bridgeSource` is the game's
|
|
137
136
|
* own bridge (Magic's is `@hadoku/magic-server/root`'s `BRIDGE_SOURCE`): the platform knows no game's tree.
|
|
137
|
+
*
|
|
138
|
+
* `workDir`, when given, is INJECTED by the caller rather than read here (w120 §K: Magic's own
|
|
139
|
+
* `games/magic/server/src/config.ts` has its own `playWorkDir`, which every Magic caller —
|
|
140
|
+
* `plugins/library.ts`, `play/scenario.ts`, `play/recording/rebuild.ts` — passes through this
|
|
141
|
+
* param). Omitted, this file falls back to its own generic default, unchanged from before this
|
|
142
|
+
* param existed, for every other caller (scripts, the UI's jvm harness) that passes none.
|
|
138
143
|
*/
|
|
139
|
-
export function jvmHostConfig(bridgeSource, env = process.env) {
|
|
144
|
+
export function jvmHostConfig(bridgeSource, env = process.env, workDir) {
|
|
140
145
|
const jar = env.CARDTABLE_FORGE_JAR ?? '';
|
|
141
146
|
const res = env.CARDTABLE_FORGE_RES ?? '';
|
|
142
147
|
if (jar === '')
|
|
@@ -156,7 +161,7 @@ export function jvmHostConfig(bridgeSource, env = process.env) {
|
|
|
156
161
|
java: env.CARDTABLE_JAVA ?? defaultJava(env),
|
|
157
162
|
jar: resolve(jar),
|
|
158
163
|
res: resolve(res),
|
|
159
|
-
workDir:
|
|
164
|
+
workDir: workDir ?? resolve(env.CARDTABLE_PLAY_WORK_DIR ?? join(tmpdir(), 'cardtable-play')),
|
|
160
165
|
jvmOpts: (env.CARDTABLE_PLAY_JVM_OPTS ?? '').split(/\s+/).filter((s) => s !== ''),
|
|
161
166
|
bridgeSource,
|
|
162
167
|
bridgeCache: defaultBridgeCache(env),
|
|
@@ -28,7 +28,7 @@ import { RelaySession } from './relay.js';
|
|
|
28
28
|
* like this one needs no `as unknown as MatchSpec` to fit it any more.
|
|
29
29
|
*/
|
|
30
30
|
function relaySpec(seatCount) {
|
|
31
|
-
const seats = Array.from({ length: seatCount }, (_, seat) => ({ ai: false, name: `Seat ${seat}
|
|
31
|
+
const seats = Array.from({ length: seatCount }, (_, seat) => ({ ai: false, name: `Seat ${seat}` }));
|
|
32
32
|
return { seats };
|
|
33
33
|
}
|
|
34
34
|
/**
|
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.19",
|
|
4
|
+
"gitHead": "3c76466409b427e612cf8a4e773a9ceccc3e2dc1",
|
|
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.",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"play/remote/"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@wolffm/host-wire": "npm:@hadoku/host-wire@0.1.
|
|
20
|
-
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.
|
|
21
|
-
"@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.
|
|
19
|
+
"@wolffm/host-wire": "npm:@hadoku/host-wire@0.1.19",
|
|
20
|
+
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.19",
|
|
21
|
+
"@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.52",
|
|
22
22
|
"@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.1.27",
|
|
23
23
|
"@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.99",
|
|
24
24
|
"@wolffm/rooms-server": "npm:@hadoku/rooms-server@^0.45.99",
|