@roster-lock/match-agent 0.3.1 → 0.4.0

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.
Files changed (157) hide show
  1. package/client/dist/assets/index-D2395vmC.css +1 -0
  2. package/client/dist/assets/index-DcKsa72V.js +125 -0
  3. package/client/dist/index.html +2 -2
  4. package/client/e2e/lib/env.ts +50 -0
  5. package/client/e2e/lib/fileDialog.ts +31 -0
  6. package/client/e2e/lib/mockGamepad.ts +71 -0
  7. package/client/e2e/lib/onscreenKeyboard.ts +32 -0
  8. package/client/e2e/playwright.config.ts +48 -0
  9. package/client/e2e/tests/gamepad-only.spec.ts +274 -0
  10. package/client/e2e/tests/keyboard-only.spec.ts +67 -0
  11. package/client/e2e/tsconfig.json +15 -0
  12. package/client/node_modules/.bin/playwright +17 -0
  13. package/client/node_modules/.bin/roster-lock-plugin-manager +17 -0
  14. package/client/node_modules/.vite/deps/@roster-lock_ts-client.js +2 -2
  15. package/client/node_modules/.vite/deps/@roster-lock_types.js +1 -1
  16. package/client/node_modules/.vite/deps/@roster-lock_utils.js +1 -1
  17. package/client/node_modules/.vite/deps/_metadata.json +18 -18
  18. package/client/node_modules/.vite/deps/{chunk-CKYX73LL.js → chunk-3HBL6DQ6.js} +1 -1
  19. package/client/node_modules/.vite/deps/{chunk-CKYX73LL.js.map → chunk-3HBL6DQ6.js.map} +2 -2
  20. package/client/node_modules/.vite/deps/{chunk-EDVVVQBR.js → chunk-QTQN6EZX.js} +2 -2
  21. package/client/node_modules/.vite/deps/chunk-QTQN6EZX.js.map +7 -0
  22. package/client/package.json +4 -1
  23. package/client/src/App.tsx +23 -14
  24. package/client/src/NavBar.tsx +15 -5
  25. package/client/src/api/matchAgent.ts +193 -5
  26. package/client/src/bridge/hostBridge.ts +15 -5
  27. package/client/src/components/FullScreenMenu.tsx +32 -0
  28. package/client/src/components/GameLauncherSettingsForm.tsx +80 -5
  29. package/client/src/components/InputHints.tsx +37 -0
  30. package/client/src/components/OnScreenFileDialog.tsx +83 -0
  31. package/client/src/components/OnScreenKeyboard.tsx +75 -0
  32. package/client/src/components/Selection/PieceCard.tsx +29 -4
  33. package/client/src/components/Selection/PiecePreviewPanel.tsx +48 -0
  34. package/client/src/components/Selection/PieceTypeSection.tsx +124 -46
  35. package/client/src/components/Selection/PlayerSelectionPanel.tsx +1 -5
  36. package/client/src/components/Selection/index.tsx +72 -47
  37. package/client/src/context/GlobalNavContext.tsx +340 -0
  38. package/client/src/context/SelectionSourceContext.tsx +26 -0
  39. package/client/src/hooks/useCursorInput.ts +66 -24
  40. package/client/src/hooks/useDownloadedPieceVersions.ts +39 -0
  41. package/client/src/hooks/useGridColumns.ts +29 -0
  42. package/client/src/hooks/useInView.ts +32 -0
  43. package/client/src/hooks/usePiecePreview.ts +124 -0
  44. package/client/src/pages/Controls/index.tsx +126 -0
  45. package/client/src/pages/Game/index.tsx +11 -15
  46. package/client/src/pages/MatchMaking/index.tsx +6 -3
  47. package/client/src/pages/PreviewRoster/index.tsx +118 -0
  48. package/client/src/styles/global.css +355 -6
  49. package/client/src/utils/inputLabels.ts +25 -0
  50. package/client/test-results/.last-run.json +4 -0
  51. package/client/tsconfig.tsbuildinfo +1 -1
  52. package/dist/config/index.js +2 -0
  53. package/dist/config/index.js.map +1 -1
  54. package/dist/config/inputBindings.js +40 -0
  55. package/dist/config/inputBindings.js.map +1 -0
  56. package/dist/config/manage.js +1 -0
  57. package/dist/config/manage.js.map +1 -1
  58. package/dist/handle-room/version-1/game-launcher/binaries.js +36 -0
  59. package/dist/handle-room/version-1/game-launcher/binaries.js.map +1 -0
  60. package/dist/handle-room/version-1/game-launcher/listing.js +24 -0
  61. package/dist/handle-room/version-1/game-launcher/listing.js.map +1 -0
  62. package/dist/handle-room/version-1/game-launcher/preview.js +38 -0
  63. package/dist/handle-room/version-1/game-launcher/preview.js.map +1 -0
  64. package/dist/handle-room/version-1/game-launcher/process.js +52 -0
  65. package/dist/handle-room/version-1/game-launcher/process.js.map +1 -0
  66. package/dist/handle-room/version-1/game-launcher/router.js +32 -0
  67. package/dist/handle-room/version-1/game-launcher/router.js.map +1 -0
  68. package/dist/handle-room/version-1/game-launcher/settings.js +49 -0
  69. package/dist/handle-room/version-1/game-launcher/settings.js.map +1 -0
  70. package/dist/handle-room/version-1/game-launcher/shared.js +28 -0
  71. package/dist/handle-room/version-1/game-launcher/shared.js.map +1 -0
  72. package/dist/handle-room/version-1/game-launcher/start.js +76 -0
  73. package/dist/handle-room/version-1/game-launcher/start.js.map +1 -0
  74. package/dist/handle-room/version-1/game-launcher/version.js +63 -0
  75. package/dist/handle-room/version-1/game-launcher/version.js.map +1 -0
  76. package/dist/handle-room/version-1/globals/FolderDB/SQLFolderDB/ensurePieceExists.js +22 -9
  77. package/dist/handle-room/version-1/globals/FolderDB/SQLFolderDB/ensurePieceExists.js.map +1 -1
  78. package/dist/handle-room/version-1/globals/FolderDB/SQLFolderDB/schema.js +50 -1
  79. package/dist/handle-room/version-1/globals/FolderDB/SQLFolderDB/schema.js.map +1 -1
  80. package/dist/handle-room/version-1/index.js +15 -16
  81. package/dist/handle-room/version-1/index.js.map +1 -1
  82. package/dist/handle-room/version-1/input-bindings.js +22 -0
  83. package/dist/handle-room/version-1/input-bindings.js.map +1 -0
  84. package/dist/handle-room/version-1/room-handler-bridge/exchange-and-download-selections.js +2 -1
  85. package/dist/handle-room/version-1/room-handler-bridge/exchange-and-download-selections.js.map +1 -1
  86. package/dist/handle-room/version-1/room-handler-bridge/http-handler.js +1 -1
  87. package/dist/handle-room/version-1/room-handler-bridge/http-handler.js.map +1 -1
  88. package/dist/handle-room/version-1/room-handler-bridge/steps.js +2 -1
  89. package/dist/handle-room/version-1/room-handler-bridge/steps.js.map +1 -1
  90. package/dist/handle-room/version-1/room-handler-bridge/ws-handler.js +2 -2
  91. package/dist/handle-room/version-1/room-handler-bridge/ws-handler.js.map +1 -1
  92. package/dist/index.js +18 -4
  93. package/dist/index.js.map +1 -1
  94. package/dist/util-routers/file-system/env.js +3 -0
  95. package/dist/util-routers/file-system/env.js.map +1 -0
  96. package/dist/util-routers/file-system/index.js +31 -0
  97. package/dist/util-routers/file-system/index.js.map +1 -0
  98. package/dist/util-routers/file-system/list.js +50 -0
  99. package/dist/util-routers/file-system/list.js.map +1 -0
  100. package/dist/util-routers/file-system/resolve-within-root.js +18 -0
  101. package/dist/util-routers/file-system/resolve-within-root.js.map +1 -0
  102. package/dist/util-routers/file-system/roster-lock.js +56 -0
  103. package/dist/util-routers/file-system/roster-lock.js.map +1 -0
  104. package/dist/utils/pick-file.js +82 -0
  105. package/dist/utils/pick-file.js.map +1 -0
  106. package/dist/utils/pick-folder.js +84 -0
  107. package/dist/utils/pick-folder.js.map +1 -0
  108. package/package.json +9 -8
  109. package/src/config/index.ts +8 -3
  110. package/src/config/inputBindings.ts +56 -0
  111. package/src/config/manage.ts +7 -0
  112. package/src/handle-room/version-1/game-launcher/binaries.ts +52 -0
  113. package/src/handle-room/version-1/game-launcher/listing.ts +36 -0
  114. package/src/handle-room/version-1/game-launcher/preview.ts +54 -0
  115. package/src/handle-room/version-1/game-launcher/process.ts +75 -0
  116. package/src/handle-room/version-1/game-launcher/router.ts +42 -0
  117. package/src/handle-room/version-1/game-launcher/settings.ts +58 -0
  118. package/src/handle-room/version-1/game-launcher/shared.ts +34 -0
  119. package/src/handle-room/version-1/game-launcher/start.ts +113 -0
  120. package/src/handle-room/version-1/game-launcher/version.ts +85 -0
  121. package/src/handle-room/version-1/globals/FolderDB/SQLFolderDB/ensurePieceExists.ts +39 -14
  122. package/src/handle-room/version-1/globals/FolderDB/SQLFolderDB/schema.ts +83 -1
  123. package/src/handle-room/version-1/globals/FolderDB/types.ts +24 -0
  124. package/src/handle-room/version-1/globals/types.ts +24 -2
  125. package/src/handle-room/version-1/index.ts +27 -26
  126. package/src/handle-room/version-1/input-bindings.ts +19 -0
  127. package/src/handle-room/version-1/room-handler-bridge/exchange-and-download-selections.ts +4 -1
  128. package/src/handle-room/version-1/room-handler-bridge/http-handler.ts +4 -1
  129. package/src/handle-room/version-1/room-handler-bridge/steps.ts +8 -0
  130. package/src/handle-room/version-1/room-handler-bridge/ws-handler.ts +2 -2
  131. package/src/index.ts +42 -10
  132. package/src/util-routers/file-system/env.ts +7 -0
  133. package/src/util-routers/file-system/index.ts +23 -0
  134. package/src/util-routers/file-system/list.ts +62 -0
  135. package/src/util-routers/file-system/resolve-within-root.ts +25 -0
  136. package/src/util-routers/file-system/roster-lock.ts +74 -0
  137. package/src/utils/pick-file.ts +81 -0
  138. package/src/utils/pick-folder.ts +92 -0
  139. package/tests/integration/filesystem.test.ts +117 -0
  140. package/tests/integration/game-launcher-binaries.test.ts +263 -0
  141. package/tests/integration/game-launcher-game-complete.test.ts +111 -0
  142. package/tests/integration/game-launcher-preview.test.ts +107 -0
  143. package/tests/integration/game-launcher-settings.test.ts +123 -8
  144. package/tests/integration/game-processes-ws.test.ts +122 -0
  145. package/tests/integration/helpers/fakeFolderDB.ts +16 -0
  146. package/tests/integration/helpers/fakePluginRuntime.ts +10 -1
  147. package/tests/integration/helpers/server.ts +23 -3
  148. package/tests/integration/input-bindings.test.ts +94 -0
  149. package/tests/integration/piece-files.test.ts +1 -1
  150. package/tests/integration/roster-lock.test.ts +86 -0
  151. package/vitest.config.ts +7 -1
  152. package/client/dist/assets/index-CX6eCHuc.js +0 -125
  153. package/client/dist/assets/index-gxAuIfGQ.css +0 -1
  154. package/client/node_modules/.vite/deps/chunk-EDVVVQBR.js.map +0 -7
  155. package/dist/handle-room/version-1/game-launcher.js +0 -197
  156. package/dist/handle-room/version-1/game-launcher.js.map +0 -1
  157. package/src/handle-room/version-1/game-launcher.ts +0 -287
@@ -1,287 +0,0 @@
1
- import { randomUUID } from "node:crypto";
2
- import { ConnectionSetup, StartGameArgs, PlatformTarget } from "@roster-lock/types";
3
- import { GameLauncherLocalSettings } from "@roster-lock/plugin-runtime";
4
- import { jsonBody, HTTPRequestHandler, HTTPError } from "../../utils/http-router";
5
- import { V1Env } from "./globals/types";
6
- import { castLockConfig } from "./piece-sort";
7
- import z, { ZodType } from "zod";
8
-
9
- // One listing endpoint, mirroring /piece/sort-list/available - every installed
10
- // game-launcher plugin's full AvailableGameLauncher record in one response, rather
11
- // than splitting connection-mode support and gameConfigSchema into separate
12
- // per-plugin routes. Both are small, static JSON already computed by
13
- // listAvailable() from the plugin's own module fields, so there's no
14
- // fetch-cost reason to make a client ask for them separately, and nothing
15
- // else in this router splits a plugin's metadata that way either.
16
- export const listAvailableGameLaunchers: HTTPRequestHandler = async function(
17
- this: V1Env, { res }
18
- ){
19
- const available = await this.pluginRuntime.gameLauncher.listAvailable();
20
- res.writeHead(200, { "Content-Type": "application/json" });
21
- res.end(JSON.stringify(available));
22
- }
23
-
24
- function requirePluginName(routeInfo: { params: Record<string, string | undefined> }): string {
25
- const pluginName = routeInfo.params.pluginName;
26
- if(!pluginName) throw new HTTPError(400, "Missing pluginName");
27
- return pluginName;
28
- }
29
-
30
- async function requireBinaryLocation(env: V1Env, pluginName: string): Promise<string> {
31
- const settings = await env.pluginRuntime.gameLauncher.getLocalSettings(pluginName);
32
- if(!settings.binaryLocation){
33
- throw new HTTPError(400, `Game launcher "${pluginName}" has no binaryLocation configured`);
34
- }
35
- return settings.binaryLocation;
36
- }
37
-
38
- // See docs/v2/binary-location.md - every GameLauncherPlugin function that
39
- // resolves a concrete binary out of a (possibly multi-platform) binaryLocation
40
- // bundle takes a required target, with no implicit "current host" default at
41
- // that layer. match-agent is what decides the target value: it defaults to
42
- // its own process.platform/process.arch (the ordinary case - a client asking
43
- // match-agent to run/inspect the game it's about to run on this same host),
44
- // but a caller can override either via query params for the deliberate
45
- // exception (e.g. forcing a win32-x64 build under Wine on a Linux host).
46
- function resolveTarget(routeInfo: { url: URL }): PlatformTarget {
47
- const platform = routeInfo.url.searchParams.get("platform");
48
- const arch = routeInfo.url.searchParams.get("arch");
49
- return {
50
- platform: (platform || process.platform) as PlatformTarget["platform"],
51
- arch: (arch || process.arch) as PlatformTarget["arch"],
52
- };
53
- }
54
-
55
- export const getGameLauncherSettings: HTTPRequestHandler = async function(
56
- this: V1Env, { res }, routeInfo
57
- ){
58
- const pluginName = requirePluginName(routeInfo);
59
- const settings = await this.pluginRuntime.gameLauncher.getLocalSettings(pluginName);
60
- res.writeHead(200, { "Content-Type": "application/json" });
61
- res.end(JSON.stringify(settings));
62
- }
63
-
64
- const localSettingsBodySchema: ZodType<GameLauncherLocalSettings> = z.object({
65
- binaryLocation: z.string().optional(),
66
- localConfig: z.unknown().optional(),
67
- }).strict();
68
-
69
- export const setGameLauncherSettings: HTTPRequestHandler = async function(
70
- this: V1Env, { req, res }, routeInfo
71
- ){
72
- const pluginName = requirePluginName(routeInfo);
73
- const body = await jsonBody(req);
74
- const parseResult = localSettingsBodySchema.safeParse(body);
75
- if(!parseResult.success) throw new HTTPError(400, "Bad Form", parseResult.error);
76
-
77
- await this.pluginRuntime.gameLauncher.setLocalSettings(pluginName, parseResult.data);
78
- res.writeHead(200, { "Content-Type": "application/json" });
79
- res.end(JSON.stringify({ ok: true }));
80
- }
81
-
82
- // Installs the plugin *package* itself (registry/manifest-based, via
83
- // PluginManager - distinct from updateBinary below, which fetches a newer
84
- // engine binary for a plugin that's already installed).
85
- export const installGameLauncherPlugin: HTTPRequestHandler = async function(
86
- this: V1Env, { res }, routeInfo
87
- ){
88
- const pluginName = requirePluginName(routeInfo);
89
-
90
- try {
91
- await this.pluginRuntime.installPlugin(pluginName);
92
- } catch(e){
93
- throw new HTTPError(400, (e as Error).message);
94
- }
95
-
96
- res.writeHead(200, { "Content-Type": "application/json" });
97
- res.end(JSON.stringify({ ok: true }));
98
- }
99
-
100
- export const getGameLauncherVersion: HTTPRequestHandler = async function(
101
- this: V1Env, { res }, routeInfo
102
- ){
103
- const pluginName = requirePluginName(routeInfo);
104
- const binaryLocation = await requireBinaryLocation(this, pluginName);
105
- const target = resolveTarget(routeInfo);
106
-
107
- const [local, supported] = await Promise.all([
108
- this.pluginRuntime.gameLauncher.getLocalVersion(pluginName, binaryLocation, target),
109
- this.pluginRuntime.gameLauncher.getSupportedVersion(pluginName, binaryLocation),
110
- ]);
111
-
112
- res.writeHead(200, { "Content-Type": "application/json" });
113
- res.end(JSON.stringify({ local, supported }));
114
- }
115
-
116
- export const validateGameLauncherBinaryLocation: HTTPRequestHandler = async function(
117
- this: V1Env, { res }, routeInfo
118
- ){
119
- const pluginName = requirePluginName(routeInfo);
120
- const binaryLocation = await requireBinaryLocation(this, pluginName);
121
- const target = resolveTarget(routeInfo);
122
-
123
- const result = await this.pluginRuntime.gameLauncher.validateBinaryLocation(pluginName, binaryLocation, target);
124
-
125
- res.writeHead(200, { "Content-Type": "application/json" });
126
- res.end(JSON.stringify(result));
127
- }
128
-
129
- // No binaryLocation involved (unlike every other route above) - this is a pre-room-creation check,
130
- // not a local-machine one, so it's callable before a binaryLocation is even configured.
131
- export const validateGameLauncherGameConfig: HTTPRequestHandler = async function(
132
- this: V1Env, { req, res }, routeInfo
133
- ){
134
- const pluginName = requirePluginName(routeInfo);
135
- const body = await jsonBody(req);
136
- const parseResult = validateGameConfigBodySchema.safeParse(body);
137
- if(!parseResult.success) throw new HTTPError(400, "Bad Form", parseResult.error);
138
- const rosterConfig = castLockConfig(parseResult.data.rosterConfig);
139
-
140
- const problems = await this.pluginRuntime.gameLauncher.validateGameConfig(
141
- pluginName, parseResult.data.gameConfig, rosterConfig
142
- );
143
-
144
- res.writeHead(200, { "Content-Type": "application/json" });
145
- res.end(JSON.stringify({ problems }));
146
- }
147
-
148
- const validateGameConfigBodySchema = z.object({
149
- gameConfig: z.unknown(),
150
- rosterConfig: z.unknown(),
151
- }).strict();
152
-
153
- export const updateGameLauncherBinary: HTTPRequestHandler = async function(
154
- this: V1Env, { res }, routeInfo
155
- ){
156
- const pluginName = requirePluginName(routeInfo);
157
- const binaryLocation = await requireBinaryLocation(this, pluginName);
158
- const target = resolveTarget(routeInfo);
159
-
160
- try {
161
- await this.pluginRuntime.gameLauncher.updateBinary(pluginName, binaryLocation, target);
162
- } catch(e){
163
- // updateBinary throws a plain Error when a plugin doesn't declare one at
164
- // all (see GameLauncher.updateBinary) - that's a client-facing 400 ("this
165
- // runner can't be updated in-app"), not a server fault.
166
- throw new HTTPError(400, (e as Error).message);
167
- }
168
-
169
- res.writeHead(200, { "Content-Type": "application/json" });
170
- res.end(JSON.stringify({ ok: true }));
171
- }
172
-
173
- const coordinatorAddressSchema = z.object({ host: z.string(), port: z.number() }).strict();
174
-
175
- // This is what a caller sends match-agent, not what the plugin ends up
176
- // with - direct-tcp still carries a coordinator address here.
177
- // GameLauncher.startGame (plugin-runtime) resolves it into a ConnectionConfig
178
- // before ever invoking a plugin, so a plugin never has to know a coordinator
179
- // exists at all.
180
- const connectionSetupSchema: ZodType<ConnectionSetup> = z.union([
181
- z.object({
182
- type: z.literal("direct-tcp"), party: z.literal("host"), port: z.number(), coordinator: coordinatorAddressSchema,
183
- }).strict(),
184
- z.object({
185
- type: z.literal("direct-tcp"), party: z.literal("client"), port: z.number(), coordinator: coordinatorAddressSchema,
186
- }).strict(),
187
- z.object({ type: z.literal("room"), version: z.string(), url: z.string() }).strict(),
188
- z.object({ type: z.literal("internal") }).strict(),
189
- ]);
190
-
191
- // Everything StartGameArgs needs except currentMachine.privateKeyFile (a
192
- // match-agent-managed temp file, not something a caller ever supplies) and
193
- // matchAgent (match-agent knows its own port/authCode - trusting a caller's
194
- // claim about either would let it point a plugin at a different match-agent
195
- // entirely). currentMachine's raw privateKey *is* client-supplied here: only
196
- // the browser holds it, and GameLauncher.startGame is what turns it into the
197
- // restrictive-permission temp file plugins actually receive.
198
- type StartGameBody = {
199
- connectionConfig: ConnectionSetup,
200
- currentMachine: { machineId: string, publicKey: string, privateKey: string },
201
- allMachines: unknown,
202
- selectionResult: unknown,
203
- rosterConfig: unknown,
204
- gameConfig: unknown,
205
- relayRoomId: string,
206
- }
207
-
208
- const startGameBodySchema: ZodType<StartGameBody> = z.object({
209
- connectionConfig: connectionSetupSchema,
210
- currentMachine: z.object({
211
- machineId: z.string(), publicKey: z.string(), privateKey: z.string(),
212
- }).strict(),
213
- allMachines: z.unknown(),
214
- selectionResult: z.unknown(),
215
- rosterConfig: z.unknown(),
216
- gameConfig: z.unknown(),
217
- relayRoomId: z.string(),
218
- }).strict();
219
-
220
- export const startGameLauncher: HTTPRequestHandler = async function(
221
- this: V1Env, { req, res }, routeInfo
222
- ){
223
- const pluginName = requirePluginName(routeInfo);
224
- const binaryLocation = await requireBinaryLocation(this, pluginName);
225
- const target = resolveTarget(routeInfo);
226
-
227
- const body = await jsonBody(req);
228
- const parseResult = startGameBodySchema.safeParse(body);
229
- if(!parseResult.success) throw new HTTPError(400, "Bad Form", parseResult.error);
230
- const { connectionConfig, currentMachine, allMachines, selectionResult, gameConfig, relayRoomId } = parseResult.data;
231
- const rosterConfig = castLockConfig(parseResult.data.rosterConfig);
232
-
233
- const handle = await this.pluginRuntime.gameLauncher.startGame(pluginName, binaryLocation, target, connectionConfig, {
234
- currentMachine,
235
- allMachines: allMachines as StartGameArgs<unknown>["allMachines"],
236
- selectionResult: selectionResult as StartGameArgs<unknown>["selectionResult"],
237
- rosterConfig,
238
- gameConfig,
239
- relayRoomId,
240
- matchAgent: { port: this.matchAgent.getPort(), authCode: this.matchAgent.authCode },
241
- });
242
-
243
- const handleId = randomUUID();
244
- this.processHandles.set(handleId, { pluginName, handle });
245
-
246
- res.writeHead(200, { "Content-Type": "application/json" });
247
- res.end(JSON.stringify({ handleId }));
248
- }
249
-
250
- export const getGameProcessStatus: HTTPRequestHandler = async function(
251
- this: V1Env, { res }, routeInfo
252
- ){
253
- const handleId = routeInfo.params.handleId;
254
- const entry = handleId ? this.processHandles.get(handleId) : undefined;
255
- if(!entry) throw new HTTPError(404, "Unknown process handle");
256
-
257
- res.writeHead(200, { "Content-Type": "application/json" });
258
- res.end(JSON.stringify({ exited: entry.handle.exited }));
259
- }
260
-
261
- // Every process this match-agent has started, across every game-launcher
262
- // plugin - backs pages/Game in match-agent-client, which shows one row per
263
- // entry regardless of which plugin launched it.
264
- export const listGameProcesses: HTTPRequestHandler = async function(
265
- this: V1Env, { res }
266
- ){
267
- const processes = Array.from(this.processHandles.entries()).map(([handleId, entry]) => ({
268
- handleId, pluginName: entry.pluginName, exited: entry.handle.exited,
269
- }));
270
- res.writeHead(200, { "Content-Type": "application/json" });
271
- res.end(JSON.stringify(processes));
272
- }
273
-
274
- // Best-effort, same as GameProcessHandle.stop() itself - see that type's own
275
- // docs on why a plugin may not always be able to actually stop the game.
276
- export const stopGameProcess: HTTPRequestHandler = async function(
277
- this: V1Env, { res }, routeInfo
278
- ){
279
- const handleId = routeInfo.params.handleId;
280
- const entry = handleId ? this.processHandles.get(handleId) : undefined;
281
- if(!entry) throw new HTTPError(404, "Unknown process handle");
282
-
283
- await entry.handle.stop();
284
-
285
- res.writeHead(200, { "Content-Type": "application/json" });
286
- res.end(JSON.stringify({ ok: true }));
287
- }