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

paintcannon

v0.0.15

Published

Very fast, Rust-based terminal rendering for JavaScript and TypeScript.

Downloads

1,794

Readme

paintcannon

Very fast, Rust-based terminal rendering for JavaScript and TypeScript.

paintcannon exposes a small DOM-like API over NAPI-RS bindings and renders to terminal backends from Rust. Think of it as a tiny browser that renders to a VT-style terminal instead of a GUI window.

A cannon shooting paint

Features

PaintCannon supports the following CSS layout and paint features:

  • Flexbox
  • Grid
  • Block layout
  • Inline layout
  • Margins and padding, including auto margins
  • Overflow hidden and scroll, with native mouse scrolling
  • visibility: hidden, which preserves layout space while suppressing paint and hit testing
  • 24-bit RGB background, border, text, placeholder, and selection coloring with 256-color and 16-color fallbacks
  • CSS transitions for color properties
  • Mouse pointer styling in supported terminals
  • Terminal focus detection via PaintCannon.hasFocus and app-level focus/blur events

PaintCannon also exposes terminal-specific border styles:

  • none
  • solid
  • double
  • heavy
  • rounded
  • chunky-rounded
  • ascii

Elements

The core DOM subset supports:

  • div
  • span
  • input with type: "text"
  • textarea
  • button
  • form
  • img via ANSI, ASCII, and half-block rendering
  • text nodes

Events

PaintCannon supports bubbling events with stopPropagation() and preventDefault():

  • Click events
  • Mouse enter and leave events
  • Keyboard events
  • Input change events
  • Form submit events
  • Focus and blur events
  • Transition start and end events
  • Scroll events
  • Resize events
  • App-level terminal focus and blur events

It also exposes requestAnimationFrame() and cancelAnimationFrame() so UI code can synchronize with PaintCannon's render loop.

Terminal focus detection is separate from element focus. PaintCannon enables xterm focus reporting from Rust, listens for terminal focus gain/loss reports, and exposes them through the PaintCannon instance:

pc.addEventListener("blur", () => {
  root.style.backgroundColor = "#27272a";
});

pc.addEventListener("focus", () => {
  root.style.backgroundColor = "#0f172a";
});

console.log(pc.hasFocus);

Inside tmux, enable focus reporting in tmux first:

set -g focus-events on

Usage

import { PaintCannon } from "paintcannon";

const pc = new PaintCannon({
  alternateScreen: true,
  captureMouse: true,
  fps: 60,
});

const root = pc.createElement("div");
pc.setRoot(root);

root.style.display = "flex";
root.style.width = "100%";
root.style.height = "100%";
root.style.alignItems = "center";
root.style.justifyContent = "center";
root.style.backgroundColor = "#020617";
root.style.color = "#e2e8f0";

const button = pc.createElement("button");
button.style.border = "chunky-rounded";
button.style.borderColor = "#fb923c";
button.style.backgroundColor = "#0f172a";
button.style.padding = "1 2";
button.style.cursor = "pointer";

const label = pc.createTextNode("Click me");
button.appendChild(label);

let count = 0;
button.addEventListener("click", () => {
  count += 1;
  label.nodeValue = `Clicked ${count} times`;
});

root.appendChild(button);

React

For React rendering on top of this DOM API, use paintcannon-react.