#!/usr/bin/env bun /** * Render each screen to plain text and print it, without a terminal. * * This is a development aid, not a test — it exists so a change to the layout * can be eyeballed in one command (`bun run scripts/preview.ts`) instead of * being driven by hand over SSH. src/ui.test.ts asserts the parts that matter. */ import { createTestRenderer } from "@opentui/core/testing" import { Store } from "../src/state.ts" import { UI } from "../src/ui.ts" import { sampleDoc } from "../src/fixtures.ts" import type { Screen } from "../src/state.ts" const SCREENS: Screen[] = ["menu", "cameras", "layouts", "layoutEdit", "cameraPicker", "setActive"] const setup = await createTestRenderer({ width: 96, height: 30 }) try { const store = new Store() store.hydrate(sampleDoc()) const ui = new UI(setup.renderer, store) store.subscribe(() => ui.render()) for (const screen of SCREENS) { if (screen === "layoutEdit" || screen === "cameraPicker") { // Land on a layout with spanning tiles so the interesting case is shown. store.openEditor(0) store.setCell(3, 1) store.screen = screen } else { store.screen = screen } store.cursor = 0 ui.render() await setup.flush() console.log(`\n===== ${screen} =====`) console.log(setup.captureCharFrame().replace(/ +$/gm, "")) } } finally { setup.renderer.destroy() }