Skip to content

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";

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.

ModuleDescription
OpsUI directive builders: open, text, close, sizing, colors, transitions
TermRenderer: createTerm, render, pointer events, layout info
InputInput parser: createInput, scan, keyboard/mouse/resize events
SettingsTerminal mode helpers: alternate buffer, cursor, mouse tracking
TermcodesLow-level ANSI escape sequence bytes
  1. Apply settings to stdout (alternate buffer, cursor, mouse)
  2. Create a term and input instance
  3. Set stdin to raw mode
  4. On each frame: build opsterm.render() → write output
  5. On stdin data: input.scan() → handle events
  6. If renderResult.animating, schedule another frame
  7. On exit: revert settings and restore terminal state

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.