import { createSidecarProxy } from '@@/sidecar/create-proxy'; import { mountPrefix } from '@@/plugins/manifest'; import { manifest } from '../manifest'; // /api/minesweeper/* — authenticate, then forward to officer-minesweeper. Three routes, no logic: // // GET /status { installed, running, window } // POST /start brings the session up (idempotent) // POST /stop takes it down // // The pixels do not come through here. They come through `/api/plugin-ws/minesweeper`, which the platform // relays onto the same sidecar's `/ws` — the socket and these routes share one listener and one announced // port, which is the whole reason a plugin can have both. // // The prefix is DERIVED rather than written. `mountPrefix` returns `/minesweeper` for a first-party // publisher, but published by anyone else this mounts at `/api/p//minesweeper`, and the proxy // strips exactly `prefix.length` characters to build the sidecar's path. A literal would forward // `/alice/minesweeper/status` to a sidecar expecting `/status`. const proxy = createSidecarProxy({ name: 'minesweeper', prefix: `/api${mountPrefix({ appName: 'minesweeper', manifest })}`, // Building the wine prefix on a cold install fetches and unpacks the VB6 runtime. It happens once, inside // POST /start, and it is minutes rather than seconds. timeoutSeconds: 600, }); export const router = proxy.router;