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

libtermy.js

v0.2.0

Published

Browser WASM build of libtermy with an xterm.js adapter

Readme

libtermy.js

Browser WASM build of libtermy with a first-party canvas renderer.

npm install libtermy.js
import { loadTermy, createTermyRenderer } from 'libtermy.js'

const termy = await loadTermy()
const renderer = createTermyRenderer(document.querySelector('#terminal')!, {
  termy,
})

renderer.onInput((data) => {
  socket.send(data)
})

socket.addEventListener('message', (event) => {
  renderer.write(event.data)
})

loadTermy() is self-contained by default. The npm package embeds the generated WASM bytes into dist/index.js, so apps do not need to copy .wasm files, configure public asset paths, or pass a wasmUrl.

createTermyRenderer owns rendering, keyboard input, selection, scrollback, and URL detection in a single pass. It supports canvas2d and headless backends today; WebGL and WebGPU backends will land in a future release.

Migration: from xterm.js to first-party rendering

The legacy attachTermyToXterm bridge double-parses every byte — once through xterm.js to render and again through core.feed() to keep libtermy's snapshot and search index in sync. The first-party createTermyRenderer API does both in one pass, removes the @xterm/xterm dependency, and exposes richer events (selection, links, resize) on a single object.

// Before — xterm.js adapter (deprecated, double-parses input)
import { Terminal } from '@xterm/xterm'
import { attachTermyToXterm, loadTermy } from 'libtermy.js'

const xterm = new Terminal()
xterm.open(document.querySelector('#terminal')!)

const termy = await loadTermy()
const bridge = attachTermyToXterm(xterm, {
  termy,
  onInput(data) {
    socket.send(data)
  },
})

socket.addEventListener('message', (event) => {
  bridge.write(event.data)
})
// After — first-party renderer (single-pass, no xterm.js needed)
import { createTermyRenderer, loadTermy } from 'libtermy.js'

const termy = await loadTermy()
const renderer = createTermyRenderer(document.querySelector('#terminal')!, {
  termy,
})

renderer.onInput((data) => {
  // data is Uint8Array — encode if your transport expects strings
  socket.send(data)
})

socket.addEventListener('message', (event) => {
  renderer.write(event.data)
})

Key differences:

  • renderer.onInput yields Uint8Array, not string. Use a TextDecoder if your transport requires UTF-8 strings.
  • renderer exposes onResize, onSelectionChange, onLink, fit, getSelection, copy, paste, scrollToBottom, and serialize directly.
  • Drop the @xterm/xterm dependency and any xterm theme wiring; pass configContents or renderConfig to createTermyRenderer instead.

Legacy: xterm.js adapter

Deprecated. attachTermyToXterm is retained for existing integrations but double-parses input and will emit a one-time console.warn on first use. Migrate to createTermyRenderer (see above). Pass { silenceDeprecation: true } to suppress the warning in test environments.

npm install libtermy.js @xterm/xterm
import { Terminal } from '@xterm/xterm'
import { attachTermyToXterm, loadTermy } from 'libtermy.js'

const xterm = new Terminal()
xterm.open(document.querySelector('#terminal')!)

const termy = await loadTermy()
const bridge = attachTermyToXterm(xterm, {
  termy,
  onInput(data) {
    socket.send(data)
  },
})

socket.addEventListener('message', (event) => {
  bridge.write(event.data)
})

bridge.write(...) writes data into xterm and feeds the same bytes through the WASM parser. The returned feed result includes runtime events and terminal responses that should be sent back to the backing PTY.

Build

Build from this package directory:

bun install
bun run build