Types
Commands
interface Commands
From @phaser-ae/kernel
Standing commands: the controls a page around the game wires to its buttons (pause, mute, fullscreen,
screenshot). They always exist, whatever was composed, and one no pack has claimed silently does nothing, so a
host wires its buttons once for every game. Each command has at most one claimer: a second claim throws at
compose. The kernel claims pause, resume and fullscreen itself.
screenshot(opts?: { scale?: number }): Promise<Blob | null>— Capture what the game shows as an image Blob, through the backend that claimed it;scaleasks for a multiple of the logical size. Resolves null when no backend claimed it.startRecording(opts?: { bitrate?: number }): void— Start recording video;bitratein bits per second, the claimer's default when omitted. No-op when unclaimed.stopRecording(): Promise<Blob | null>— Stop recording and resolve the video Blob; null when nothing was recording or nothing claimed it.pause(): void— Hold the game: the host's pause button. The kernel claims it ontoclock.pause(). Before the game is ready (game.ready) a pause or resume is remembered, the latest winning, and applied at that moment: pausing while it loads means the game starts paused.resume(): void— Resume afterpause. Remembered likepausebefore the game is ready.mute(bus?: 'master' | 'music' | 'sfx'): void— Silence a bus; defaultmaster. Claimed by the audio pack; no-op without one. Applies at once, even before the game is ready.unmute(bus?: 'master' | 'music' | 'sfx'): void— Undomuteon a bus; defaultmaster.fullscreen(on?: boolean): Promise<void>— Toggle fullscreen, or set it withon. The kernel claims it: the Fullscreen API on the canvas's parent, or on iOS (which has none) the canvas raised to a fixed full-viewport layer. Needs a user gesture; no-op headless.readonly isFullscreen: boolean— True while the document has a fullscreen element or the iOS fallback is up; always false headless.loseDevice(): void— Destroy the GPU device ON PURPOSE so the real loss-and-rebuild path runs (boot.contextLost→boot.contextRestored). A dev tool; claimed by the backend, no-op headless.claim<K extends keyof Commands>(name: K, impl: Commands[K]): void— Pack side: fulfil a command, at attach. Throws if another pack has claimed it, naming both.
