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

@bobfrankston/label-core

v0.1.11

Published

Shared rendering, CLI, and printer-handling primitives for label printers (used by brother-label and dymo-print)

Readme

@bobfrankston/label-core

Shared printer-agnostic primitives for label printers. Used by:

This package is a library, not a CLI. It exports the LabelPrinter interface, content-rendering primitives (text, QR, HTML), Windows printer-status helpers, clipboard accessors, and the CLI argument-parsing primitives both drivers share.

Why a single core?

Brother and Dymo printers use very different drivers, paper systems, and OS plumbing — but the user-facing surface is nearly identical: render some text/HTML/QR/image to a bitmap and send it to a printer. By extracting the shared parts here, both drivers get the same behavior and bug fixes for free, and consumers can program against one interface (LabelPrinter) and switch drivers without code changes.

Installation

npm install @bobfrankston/label-core

You usually don't install this directly — install the driver package for your printer (brother-label or dymo-print), which depends on this.

The unified interface

Every driver exports a singleton implementing this:

interface LabelPrinter {
    readonly driverName: string;

    render(opts: PrintOptions): Promise<Buffer>;
    print(opts: PrintOptions): Promise<PrintResult>;
    renderSegments(segments: Segment[], opts?: SegmentOptions): Promise<Buffer>;
    printSegments(segments: Segment[], opts?: SegmentOptions): Promise<PrintResult>;

    listPrinters(): Promise<PrinterInfo[]>;
    getStatus(printerName?: string): Promise<PrinterStatus>;
    waitOnline(printerName?: string, opts?: WaitOptions): Promise<PrinterStatus>;

    listMedia(): MediaInfo[];
    getMedia(id: string): MediaInfo;
    detectMedia(printerName?: string): Promise<MediaInfo>;

    getConfig(): PrinterConfig;
    setConfig(config: Partial<PrinterConfig>): void;
    getConfigPath(): string;
}

Cross-driver example:

import type { LabelPrinter } from "@bobfrankston/label-core";
import { brotherPrinter } from "@bobfrankston/brother-label";
import { dymoPrinter } from "@bobfrankston/dymo-print";

async function printOnEither(p: LabelPrinter) {
    await p.print({ text: "Hello world", media: "12" });   // 12mm tape on Brother, label 12 on Dymo
}
await printOnEither(brotherPrinter);
await printOnEither(dymoPrinter);

What's in here

| Module | Exports | Purpose | |---|---|---| | types.ts | LabelPrinter, PrintOptions, PrinterStatus, MediaInfo, etc. | The unified interface and shared types | | render.ts | renderHtmlString, renderHtmlFile, renderHtmlUrl, closeBrowser | Puppeteer HTML→PNG with <img qr="..."> inlining | | segments.ts | renderText, renderQr, renderSegments | Jimp text/QR rendering, side-by-side composition | | content.ts | resolveContent, validateContent, mmToPx, pxToMm | Dispatch PrintOptions to a PNG buffer | | clipboard.ts | getClipboard, getClipboardText, getClipboardImage | Windows clipboard via PowerShell | | printer.ts | getPrinterStatus, listPrinters, waitOnline, listPrinterStatuses | Windows print queue status & online wait | | parse.ts | parseSize, parseTextHeight, parseAspect, preprocessSingleQuotes, parseArgs | CLI primitives | | powershell.ts | runPowerShell, runPowerShellOrThrow | Spawn-based PS invocation (uses -EncodedCommand to sidestep quoting) | | config.ts | readJsonConfig, writeJsonConfig, mergeJsonConfig | File-backed JSON config |

Library conventions

  • No console.* output. Errors throw. Diagnostic messages go through an injected log: (msg: string) => void callback (see PrintOptions.log, WaitOptions.log).
  • Windows-only currently (PowerShell + WMI under the hood).
  • Spawn with arg arrays, never exec — handles paths/names with spaces.
  • All input sizing accepts 12px, 1mm, .2in, 50%.

Offline waiting

The most common Dymo gripe ("printer is asleep, jobs vanish") is handled at the core level:

import { waitOnline, getPrinterStatus } from "@bobfrankston/label-core";

const status = await getPrinterStatus("DymoBlack");
if (!status.online) {
    await waitOnline("DymoBlack", {
        timeoutMs: 60_000,
        intervalMs: 2_000,
        onWaiting: (s, elapsed, alts) => {
            console.log(`Still waiting (${s.statusText}); ${elapsed/1000}s elapsed`);
            if (alts.length) console.log(`Alternatives online now: ${alts.map(a => a.name).join(", ")}`);
        },
    });
}

The driver wrappers call this automatically when you print() — set wait: false in PrintOptions to opt out.

Clipboard

import { getClipboard } from "@bobfrankston/label-core";

const c = await getClipboard();
if (c.kind === "image") {
    // c.image is a Buffer (PNG)
} else if (c.kind === "text") {
    console.log(c.text);
} else {
    console.log("Clipboard is empty");
}

License

MIT