packages/vishot-runner-browser/README.md
Browser-side capture tooling for Vishot scene rendering entrypoints.
This package is the browser capture engine used by scene packages such as @proj-airi/scenarios-stage-tamagotchi-browser. It provides:
src/index.tscaptureBrowserRoots() programmatic APIcapture CLI entry in src/cli/capture.tsdata-scenario-capture-root element as its own PNGimageTransformers pipeline for converting emitted PNG files into other final image artifacts such as AVIFpnpm -F @proj-airi/vishot-runner-browser capture -- ../scenarios-stage-tamagotchi-browser --output-dir ../scenarios-stage-tamagotchi-browser/artifacts/final
pnpm -F @proj-airi/scenarios-stage-tamagotchi-browser capture
The browser capture package can run directly against a scene package root, or indirectly through the consumer package's own capture script. In both cases it starts the scene package's Vite app, opens it in Chromium, waits for the frontend ready signal, and exports each capture root into packages/scenarios-stage-tamagotchi-browser/artifacts/final.
Programmatic usage from a scene package looks like this:
import path from 'node:path'
import { captureBrowserRoots } from '@proj-airi/vishot-runner-browser'
const sceneAppRoot = path.resolve(process.cwd())
const requestedFormat = 'avif'
await captureBrowserRoots({
sceneAppRoot,
routePath: '/docs/setup-and-use',
outputDir: path.resolve(sceneAppRoot, 'artifacts', 'final'),
imageTransformers: requestedFormat === 'avif'
? [avifTransformer]
: undefined,
})
The capture primitive is still PNG because Playwright screenshots write PNG files. If you want AVIF, WebP, or optimized PNG outputs, add an imageTransformers pipeline that rewrites the emitted files after capture.
captureBrowserRoots() accepts either sceneAppRoot or baseUrl.routePath to target a specific page when a scene app has multiple routes.window.__SCENARIO_CAPTURE_READY__.<render-entry> as the scene package root and captures the default / route.--root flags for named capture roots.