// Typed API exposed to the renderer by the preload script. Type-only: shared by preload and renderer. import type { RgbaImage } from '../shared/maps/loader'; import type { Phase } from '../shared/protocol'; export interface MapFiles { /** Raw map.json, validated by the renderer with shared/maps/loader. */ definition: unknown; terrain: RgbaImage; /** background.png bytes. */ background: Uint8Array; } export interface HostResult { port: number; } /** A game seen on the LAN. */ export interface LanGame { serverId: string; name: string; mapId: string; players: number; maxPlayers: number; phase: Phase; version: number; address: string; port: number; } export interface LanApi { /** Starts the local authoritative server (once) and resolves once it listens. */ host(name: string): Promise; /** Starts listening for LAN games; `onGames` receives the full list about once per second. Returns a stop function. */ discover(onGames: (games: LanGame[]) => void): () => void; } export interface AssetsApi { materials(): Promise; /** Raw character.json of every playable character. */ characters(): Promise; map(mapId: string): Promise; } /** Where the self-update stands (src/main/updater.ts). */ export type UpdateStatus = | { state: 'idle' } | { state: 'downloading'; version: string; progress: number } /** Downloaded: runs on the next launch. */ | { state: 'ready'; version: string } /** Needs a new installer (different Electron runtime). */ | { state: 'manual'; version: string } | { state: 'error'; message: string }; export interface UpdatesApi { /** Version of the running game. */ version(): Promise; /** `onStatus` receives the current status at once, then every change. Returns an unsubscribe function. */ watch(onStatus: (status: UpdateStatus) => void): () => void; /** Restarts the app on the downloaded version. */ restart(): void; } declare global { interface Window { lan: LanApi; assets: AssetsApi; updates: UpdatesApi; } }