@casoon/castwright
v0.4.0
Published
Declarative terminal demos for the web — DSL parser, compiler to asciicast v2, CLI, and Vite plugin.
Maintainers
Readme
@casoon/castwright
The DSL parser, the compiler to asciicast v2,
the castwright CLI and the Vite plugin.
Part of castwright — see the repository README for the
full picture, and @casoon/castwright-player
for playing the result in a browser.
Install
pnpm add -D @casoon/castwrightCLI
castwright build demo.terminal.yaml -o dist/demo.cast # compile to asciicast v2
castwright validate demos/*.terminal.yaml # check without writing
castwright dev demo.terminal.yaml # watch + live previewcastwright dev additionally needs vite and @casoon/castwright-player installed — both are
optional peer dependencies, so build and validate work without them.
Vite plugin
// vite.config.js
import { castwright } from '@casoon/castwright/vite';
export default { plugins: [castwright()] };A *.terminal.yaml import then evaluates to { cast, finalFrame }: the compiled cast for the
player, and the end state as plain text for the no-JavaScript fallback.
Programmatic use
import { compile, parse, serializeCast } from '@casoon/castwright';
const cast = compile(parse(source, 'demo.terminal.yaml'));
await writeFile('demo.cast', serializeCast(cast));serializeCast writes the spec's own field names (fg, bg, a colon-joined palette), so the
output is readable by asciinema play, agg and svg-term-cli. toWireHeader/fromWireHeader
expose that conversion if you need it directly.
Licence
MIT
