API Overview
@bomb.sh/tty exports five modules from a single entry point. Everything is available from @bomb.sh/tty:
import { function open(id: string, props?: Omit<OpenElement, "directive" | "id">): OpenElement
open, function text(content: string, props?: Omit<Text, "directive" | "content">): Text
text, function close(): CloseElement
close, function snapshot(ops: Op[]): Op
snapshot, function rgba(r: number, g: number, b: number, a?: number): number
rgba, const fit: (min?: number, max?: number) => SizingAxis
fit, const grow: (min?: number, max?: number) => SizingAxis
grow, const percent: (value: number) => SizingAxis
percent, const fixed: (value: number) => SizingAxis
fixed, function createTerm(options: TermOptions): Promise<Term>
createTerm, function createInput(options?: InputOptions): Promise<Input>
createInput, function settings(...sequence: Setting[]): Setting
settings, function alternateBuffer(options?: { clear?: boolean;}): Setting
alternateBuffer, function cursor(visible: boolean): Setting
cursor, function mouseTracking(): Setting
mouseTracking,} from "@bomb.sh/tty";Modules
Section titled “Modules”The module split mirrors the zero-I/O architecture: ops describe frames, term and input are the two pipelines, and settings/termcodes build the escape bytes you write to the terminal yourself.
| Module | Description |
|---|---|
| Ops | UI directive builders: open, text, close, sizing, colors, transitions |
| Term | Renderer: createTerm, render, pointer events, layout info |
| Input | Input parser: createInput, scan, keyboard/mouse/resize events |
| Settings | Terminal mode helpers: alternate buffer, cursor, mouse tracking |
| Termcodes | Low-level ANSI escape sequence bytes |
Typical app structure
Section titled “Typical app structure”- Apply settings to stdout (alternate buffer, cursor, mouse)
- Create a term and input instance
- Set stdin to raw mode
- On each frame: build ops →
term.render()→ writeoutput - On stdin data:
input.scan()→ handle events - If
renderResult.animating, schedule another frame - On exit: revert settings and restore terminal state
Deno-only exports
Section titled “Deno-only exports”The Deno source tree includes @bomb.sh/tty/validate with runtime op validation (validate, assert, validated). This subpath is not in the published npm exports map for v0.8.0.