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

@alphinex/printing

v1.1.1

Published

Thermal (58mm/80mm) and A4 print rendering, barcode/QR generation, and the usePrint() hook. See ADR-0008.

Readme

@alphinex/printing

Thermal (58mm/80mm) and A4 print rendering, barcode/QR generation, the usePrint() hook, and direct ESC/POS hardware printing over WebUSB/Web Serial.

<PrintFrame> + usePrint()

import { PrintFrame, usePrint } from "@alphinex/printing";

function InvoicePrintButton({
  invoiceNumber,
  children,
}: {
  invoiceNumber: string;
  children: React.ReactNode;
}) {
  const { print } = usePrint({ documentTitle: `Invoice-${invoiceNumber}` });
  return (
    <>
      <button onClick={print}>Print</button>
      <PrintFrame paperSize="a4">{children}</PrintFrame>
    </>
  );
}

<PrintFrame> hides everything else on the page under @media print and sizes the @page box to paperSize ("a4" | "80mm" | "58mm"). usePrint() just triggers window.print() and optionally swaps document.title for the print job's default filename.

Known constraint: the visibility rule is class-based (.aui-print-frame), not scoped per instance. If more than one <PrintFrame>/<PrintLayout> is mounted at the same time, printing will make all of them visible at once, overlapping. Only mount one active print frame at a time (e.g. behind a tab/toggle for "which document is currently the print target").

<Barcode> / <QRCode>

import { Barcode, QRCode } from "@alphinex/printing";

<Barcode value="4006381333931" format="EAN13" />;
<QRCode value="https://alphinex.example/invoice/1042" size={96} />;

Both render pure SVG (no canvas/raster assets) via jsbarcode/qrcode-generator — see ADR-0008 for why those two libraries were chosen.

Direct hardware printing: EscPosBuilder + useThermalPrinter

A second, independent printing path from <PrintFrame>/usePrint() — direct byte-level ESC/POS output to real thermal-printer hardware, for receipts needing a cut command, cash-drawer kick, or narrower control than a full-page browser print gives you.

import {
  EscPosBuilder,
  MockTransport,
  useThermalPrinter,
  WebUSBTransport,
} from "@alphinex/printing";
import { useMemo } from "react";

function ReceiptPrintButton() {
  // Swap MockTransport for WebUSBTransport/WebSerialTransport against real hardware.
  const transport = useMemo(() => new WebUSBTransport({ vendorId: 0x04b8 }), []);
  const printer = useThermalPrinter({ transport });

  const printReceipt = async () => {
    if (printer.status !== "connected") {
      await printer.connect();
    }
    const bytes = new EscPosBuilder()
      .initialize()
      .align("center")
      .bold(true)
      .line("RECEIPT")
      .bold(false)
      .align("left")
      .line("1x Widget — $9.99")
      .feed(2)
      .cut()
      .build();
    await printer.print(bytes);
  };

  return <button onClick={printReceipt}>Print receipt</button>;
}

WebUSBTransport/WebSerialTransport/MockTransport all implement the same ThermalPrinterTransport interface (connect/write/disconnect), so useThermalPrinter never branches on which one is in use — use MockTransport in your own tests and demos.

Important — hardware verification gap: WebUSBTransport and WebSerialTransport are implemented against the published WebUSB/Web Serial specs and unit-tested for the exact API call sequence and bytes written, but have not been verified against real thermal-printer hardware in this environment (no physical device available). Test against your actual printer before shipping — see ADR-0014 for the full rationale and the trigger for closing this gap. WebUSB/Web Serial themselves are Chromium-only browser APIs (not Firefox/Safari as of this writing).

EscPosBuilder's text() encodes via TextEncoder (UTF-8) — it does not select or convert to a printer-specific codepage. ASCII text prints correctly on any codepage; non-ASCII characters may not render as expected depending on the printer's default codepage.

See documentation/PRODUCT-RESEARCH-MASTER-PLAN.md §8.3 for the full package contract.