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

@tern-tui/node

v0.2.0

Published

tern napi binding: Deno/Node.js -> tern-core bridge (native addon)

Readme

tern-node

The napi binding between Deno/Node.js and tern-core. JS code (the reconciler in packages/core) constructs a scene with create_node / NodeHandle, and a TuiRenderer owns the terminal lifecycle and paint loop.

Building

The binding is a Rust cdylib compiled by napi-rs v3 (napi + napi-derive), built with @napi-rs/cli:

cd src/bindings/tern-node
npm install              # fetches @napi-rs/cli
npm run build            # release profile (default): napi build --platform --release && node fix-dts.mjs
npm run build:debug      # debug profile, fast local iteration: napi build --platform && node fix-dts.mjs

This produces, in this directory:

  • index.js — the JS loader that requires the platform addon
  • index.d.ts — TypeScript declarations for the exported surface
  • tern-node.<platform>-<arch>.node — the native addon (e.g. tern-node.darwin-arm64.node on macOS arm64)

API surface

class TuiRenderer {
  constructor(options?: { exit_on_ctrl_c?: boolean });
  root(): NodeHandle;
  poll_events(timeout_ms: number): KeyEvent[]; // { name, char?, ctrl, alt, shift }
  render(): void;
  destroy(): void;
  get destroyed(): boolean;
}

function create_node(type: "box" | "text", props?: Record<string, unknown>): NodeHandle;

class NodeHandle {
  add_child(child: NodeHandle): NodeHandle;
  remove(): boolean;
  set_props(props: Record<string, unknown>): void;
  set_prop(key: string, value: unknown): void; // single-key (style keys merge)
}

TuiRenderer enters raw mode + the alternate screen on construction and restores the terminal on destroy() (or automatically on Ctrl+C when exit_on_ctrl_c: true).

Smoke test

Deno-first (the primary runtime target): the addon is loaded through node:module createRequire, which Deno 2.x supports for Node-API addons with --allow-all (includes --allow-ffi). If Deno addon loading fails, the smoke falls back to node and prints the limitation.

# inside this directory (built addon required):
printf 'q' | script -q /dev/null deno run --allow-all smoke.mjs   # PTY smoke: renders, quits on 'q'
# from the repo root:
printf 'q' | script -q /dev/null deno run --allow-all src/bindings/tern-node/smoke.mjs

Exit code 0 means: addon loaded, typeof TuiRenderer === 'function', the scene rendered, and the piped 'q' was received as a key event.