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

@munchi_oy/sunmi-smart-terminal-printer-sdk

v1.0.1

Published

React Native bridge for the embedded printer on SUNMI smart terminals

Readme

@munchi_oy/sunmi-smart-terminal-printer-sdk

React Native bridge for the embedded printer on SUNMI smart terminals.

Scope

  • Supported hardware target: SUNMI terminals with an embedded printer.
  • Primary target validated for setup: SUNMI P2 SE.
  • Supported capability: embedded printer only.
  • External printers are not supported.
  • Non-printer terminal integrations are out of scope.

Install

pnpm add @munchi_oy/sunmi-smart-terminal-printer-sdk

Android

This package uses SUNMI's Android printer service dependency from Maven Central:

implementation "com.sunmi:printerlibrary:1.0.24"

The package's android/build.gradle already includes that dependency, so consumers do not need to manually copy any local .jar or .so files.

The Android manifest in this package also declares package visibility for the SUNMI printer service:

<queries>
  <package android:name="woyou.aidlservice.jiuiv5" />
</queries>

That matters for Android 11-based SUNMI devices such as P2 SE.

iOS

iOS is intentionally disabled. The module still links into a React Native app, but:

  • prepare() rejects with UnsupportedPlatform
  • print(), printText(), and cutPaper() reject with UnsupportedPlatform
  • getDeviceInfo() returns a safe fallback object

Usage

import {
  prepare,
  getDeviceInfo,
  getPrinterStatus,
  print,
  printText,
  cutPaper
} from "@munchi_oy/sunmi-smart-terminal-printer-sdk";

const device = await getDeviceInfo();
await prepare();
const status = await getPrinterStatus();
await print({
  commands: [
    { type: "align", align: "center" },
    { type: "text", text: "Hello Sunmi\n" }
  ]
});
await printText("Hello Sunmi");
await cutPaper();

Call prepare() before printing. initialize() is kept as an alias to prepare().

Smoke test screen

This package now exports a ready-made React Native screen for device validation:

import { SunmiPrinterSmokeTestScreen } from "@munchi_oy/sunmi-smart-terminal-printer-sdk";

export const PrinterTestRoute = () => <SunmiPrinterSmokeTestScreen />;

The screen includes buttons for:

  • getDeviceInfo()
  • prepare()
  • getPrinterStatus()
  • printText()
  • print(job) with a sample receipt
  • cutPaper()

Recommended real-device order on a P2 SE:

  1. Open the screen on the SUNMI device.
  2. Tap Get device info and confirm the model looks like P2 SE.
  3. Tap Prepare printer and confirm it resolves without error.
  4. Tap Get printer status and inspect the returned code.
  5. Tap Print text.
  6. Tap Print sample receipt.
  7. Tap Cut paper and see whether the device supports it.

If cutPaper() fails but text printing works, that usually means the handheld model does not expose cutter support rather than the whole bridge being broken.

Consumer compatibility helpers

For migration from stateful SUNMI printer libraries, this package now also exports:

  • setAlignment("left" | "center" | "right")
  • setFontSize(number)
  • lineWrap(number)

setAlignment() and setFontSize() are stored as JS-side defaults and automatically merged into subsequent printText() calls. That means consumer code shaped like this is supported:

await prepare();
await setAlignment("center");
await setFontSize(24);
await printText("Hello\n");
await lineWrap(3);

Current status

What is wired end to end today:

  • getDeviceInfo() returns normalized device identity data from the current platform.
  • prepare() and initialize() bind the SUNMI print service and initialize the printer session.
  • getPrinterStatus() is wired to updatePrinterState().
  • print(job) is wired to printerInit -> apply commands.
  • printText(text, options) is implemented as a convenience wrapper over print(job).
  • cutPaper() is wired to cutPaper() on the SUNMI service.

What to expect on each platform:

  • Android on supported SUNMI hardware: this package is intended to run for real.
  • iOS: the package should still build into the app, but printing is not supported.

What is not implemented as a feature:

  • no external printer support
  • no automatic retry or recovery
  • no cash drawer support
  • no guarantee of cross-app printer ownership beyond what the embedded SUNMI runtime already does

Runtime behavior

  • Call prepare() before print(), printText(), or cutPaper().
  • If prepare() has not succeeded yet, JS throws NotPrepared before going down to native.
  • print() and printText() are serialized in a native FIFO queue on a worker thread.
  • Printer status and callback failures are mapped into the package error model.

Print commands

print(job) currently accepts these command types:

  • align
  • text
  • bitmap
  • feed
  • font
  • fontScale
  • gray
  • spacing
  • indent
  • invert
  • cut

Some command types are translated approximately because SUNMI's public service API does not expose the same low-level font and spacing controls as lower-level vendor SDKs.

Development

pnpm install
pnpm validate

This package currently verifies:

  • TypeScript unit tests
  • package build
  • Android queue unit tests in source form

Real printer validation still requires a SUNMI device such as a P2 SE.