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

@uniview/tui-core

v0.0.3

Published

Framework-neutral TUI core: scene, cell buffer, text engine, layout, paint, diff, surfaces

Readme

@uniview/tui-core

The framework-neutral terminal engine: layout → paint → buffer → diff → surface. It powers the React and Solid bindings without depending on either framework.

@uniview/tui-core has runtime dependencies for Unicode cell widths and the optional Yoga layout adapter; it is framework-neutral, not dependency-free.

If you are authoring React or Solid UI, install @uniview/tui-react or @uniview/tui-solid instead. Each binding includes the usual terminal lifecycle and re-exports common core facilities. Install this package directly when you are building a custom surface or a no-framework terminal UI.

Direct mode (no framework)

pnpm add @uniview/tui-core
import { createTuiApp, type RenderNode } from "@uniview/tui-core";

const scene: RenderNode = {
  type: "box",
  style: { flexDirection: "column", padding: 1, border: "rounded", width: 40 },
  children: [
    {
      type: "text",
      text: "Hello from Uniview",
      textStyle: { fg: "cyan", bold: true },
    },
    { type: "text", text: "No React or Solid required." },
  ],
};

const app = createTuiApp({ input: process.stdin, output: process.stdout });
app.render(scene);

process.on("SIGINT", () => {
  app.destroy();
  process.exit(0);
});

createTuiApp() owns the renderer and terminal as one session. If renderer cleanup fails, the driver releases terminal resources best-effort but keeps both stream identities reserved; destroy() or the next owner of either stream retries the same cleanup before acquiring the terminal.

When composing TerminalDriver with a custom renderer, register that renderer's cleanup with driver.start({ cleanup }) and let driver.stop() tear down the whole session. The optional retainSessionOnError predicate is only for a typed error that guarantees cleanup made no mutation; returning true leaves the live session untouched.

Renderer teardown is durable. As soon as TuiRenderer.destroy() begins, queued frames are invalidated and setRoot(), resize(), setCursor(), and flush() reject permanently—even if the surface cleanup must be retried. Public renderer/host handles from an old app therefore cannot write into a replacement terminal session.

The pipeline

RenderNode tree
   → computeLayout()      resolve geometry (flexbox-ish)
   → renderToBuffer()     paint cells + record ownership
   → diffFrames()         emit only what changed
   → CellSurface          write it out

TuiRenderer drives that loop and schedules frames; createTuiApp() wires it to a terminal.

Surfaces

| | | | ------------------- | ----------------------------------------------------- | | AnsiCellSurface | a real terminal (truecolor, cursor, partial repaints) | | MemoryCellSurface | in-memory — what tests assert against | | SvgCellSurface | render a frame to SVG (docs, screenshots) |

MemoryCellSurface + frameToText() is the reason the whole TUI stack is testable without a TTY.

CellSurface is deliberately synchronous: mount(), resize(), and destroy() return void, while present() returns PresentStats immediately. A custom surface must finish its observable work during that call. If it needs asynchronous I/O, enqueue it internally without returning a Promise or thenable; TuiRenderer rejects those results and invalidates the session so an asynchronous operation cannot race a replacement renderer. Teardown is also reentrancy-safe: a surface may trigger renderer destruction from resize(), present(), or its own destroy() without recommitting work or recursively calling surface cleanup. Once teardown starts, renderer mutations remain unavailable; an external destroy() may retry a cleanup call that threw.

What's in here

LayoutcomputeLayout, customLayoutEngine, and yogaLayoutEngine. LayoutEngine is an interface, so another engine can be supplied.

PaintrenderToBuffer, CellBuffer, StyleTable (interned styles), OwnerTable (which node painted which cell — this is what makes hit-testing possible), borderGlyphs/BORDER_PRESETS.

Diff / outputdiffFrames, buildFrameUpdate, frameToText, serializeFrame.

CanvasVERTICAL_BLOCKS/HORIZONTAL_BLOCKS + verticalBarColumn (eighth-block bars), and SubcellCanvas (braille 2×4 sub-cell plotting).

InputTerminalDriver (raw mode, mouse, resize), InputParser, FocusManager, hitTest, plus state machines: TextInputMachine, PressableMachine, CheckboxMachine, TabsMachine.

StylingdefaultTheme, resolveColorCss, nearestNamedColor, rgbToAnsi256. Color is string | RgbColor, so truecolor works.

UI helpers — pure and framework-neutral helpers including nextFocus, listCounter, clampScroll, filterCommands, and computeVirtualWindow.

Known limitation

A height: "100%" child under a flexGrow ancestor resolves against the grandparent's size rather than the flexGrow parent's final size, and overflows. Demos avoid percentage heights under flexGrow. A characterization test pins the current behavior — fixing it is the job of the Yoga layout adapter, not a patch here.

Development

pnpm test          # vitest
pnpm check-types   # tsc --noEmit — vitest and tsdown do NOT type-check
pnpm build         # tsdown