npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

termvision

v0.1.8

Published

Semantic reconstruction and reflow for rendered terminal grids.

Downloads

1,392

Readme

termvision

Semantic reconstruction and reflow for rendered terminal grids.

termvision takes a terminal screen that has already been rendered into cells, detects common semantic structures, and produces a new grid for a different viewport size without re-running the original TUI process.

Status: early 0.1.x package. The public API is intentionally small while the detection heuristics are still being validated.

Why

Terminal sharing and multiplexing tools often fall back to the smallest connected viewport. Re-rendering a full-screen TUI at a different size is hard because the byte stream has already been baked for the source PTY. termvision works from the rendered grid instead: it treats borders, prompts, status bars, progress bars, tree output, and columnar output as layout signals.

Install

pnpm add termvision

termvision is ESM-only and targets Node.js 20 or newer.

Usage

import { gridFromText, gridToText, reflow } from "termvision";

const source = gridFromText(`
┌──────────────────────┐
│ hello world          │
│ from termvision      │
└──────────────────────┘
`);

const result = reflow({
  source,
  target: { cols: 40, rows: 8 },
  confidenceThreshold: 0.6,
});

console.log(result.fallback);   // "none" | "viewport-pan"
console.log(result.confidence); // 0..1
console.log(gridToText(result.grid));

ANSI-colored text can be parsed and rendered back to HTML:

import { gridFromAnsi, gridToHtml } from "termvision";

const grid = gridFromAnsi("\x1b[32mready\x1b[0m");
console.log(gridToHtml(grid));

Current Scope

Implemented:

  • Box-drawing rectangle detection for single, double, rounded, and heavy borders.
  • Text-grid reflow with top and bottom anchoring.
  • Heuristic classification for prompts, status bars, separators, progress bars, tree output, and columnar output.
  • Basic ANSI SGR parsing for foreground/background colors and bold text.
  • viewport-pan fallback for dense table-like screens where semantic reflow is risky.
  • Optional classified-line wide block preservation for code and diff content that should be panned on narrow viewports instead of hard-wrapped.
  • Horizontal fill-line projection for separators and rule-filled footer rows, while leaving box/table borders untouched.

Not implemented yet:

  • Cursor-aware input field reconstruction.
  • Nested layout tree solving beyond simple stacked border regions.
  • Full terminal escape sequence emulation in the public API.
  • Stable table schema inference.

API Surface

The package exports:

  • Grid helpers: createGrid, gridFromText, gridFromAnsi, gridToText, gridToHtml, getCell, setCell, copyRect.
  • Reflow: reflow, ReflowOptions, ReflowResult, FallbackMode.
  • Detection and rendering internals that are useful for experiments: detectBorders, buildWidgetTree, renderWidgetTree, classifyLines, reflowClassifiedLines, reflowClassifiedLineRecords, resizeHorizontalFillLineCells.
  • Types: Grid, Cell, DetectedRect, Widget, WidgetTree, BorderStyle, ClassifiedLine, LineKind, Anchor, ReflowClassifiedLinesOptions, ReflowedLine, ReflowedLineWideBlockKind, WideBlockStrategy, AnsiAttrs.

See docs/API.md for contract details.

Development

pnpm install
pnpm typecheck
pnpm test
pnpm build
pnpm pack:dry

Tooling is centralized through Vite+: pnpm test uses vp test, pnpm demo uses vp dev, and pnpm build uses vp pack backed by tsdown to create the publishable ESM bundle and declarations.

Run the demo:

pnpm demo

Inspect a fixture:

pnpm inspect test/fixtures/asciinema/vim-editor.json 100 30

Documentation

Recording and replay utilities use @aitty/wterm-core for terminal capture; termvision itself does not ship or depend on a local wasm binary.

License

Apache-2.0.