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

@rojonantenaina/expo-usb-printer

v0.1.1

Published

Direct USB ESC/POS thermal printing for Expo (Android dev build / CNG).

Readme

@rojonantenaina/expo-usb-printer

Impression USB directe (ESC/POS) pour Expo — Android uniquement. Parle au périphérique via UsbManager + bulkTransfer, sans app tierce ni service d'impression. Pensé pour les imprimantes thermiques USB (classe 07), y compris les imprimantes intégrées des tablettes POS.

Prérequis

  • Projet Expo avec dev build / CNG (expo-dev-client, expo prebuild). Ne fonctionne pas dans Expo Go (code natif).
  • L'imprimante doit apparaître sur le bus USB-host Android (vérifiable via getDeviceList()).

Installation

# via npm (recommandé)
npx expo install @rojonantenaina/expo-usb-printer

# ou via git
npx expo install git+https://github.com/rojonantenaina/expo-usb-printer.git

# ou en local pour le dev (tarball — évite les soucis de symlink Metro)
npm pack            # dans ce dossier -> .tgz
npm install ../expo-usb-printer/rojonantenaina-expo-usb-printer-0.1.0.tgz

Chemin local en symlink (npm install ../expo-usb-printer) : Metro ne résout pas un package situé hors de la racine du projet. Si vous y tenez, ajoutez le dossier à watchFolders dans metro.config.js. Le tarball (ci-dessus) ou l'install npm/git n'ont pas ce problème.

Pour formater des tickets, installez aussi esc-pos-encoder : npx expo install esc-pos-encoder

Puis régénérez le natif et rebuildez le dev client :

npx expo prebuild
npx expo run:android

API

import {
  getDeviceList,
  hasPermission,
  printRaw,
  printBytes,
} from "@rojonantenaina/expo-usb-printer";

// 1. Trouver l'imprimante (diagnostic)
const devices = getDeviceList();
// [{ deviceName, vendorId, productId, productName, manufacturerName, interfaceCount }]

// 2. Imprimer des octets ESC/POS (ex. via esc-pos-encoder)
import EscPosEncoder from "esc-pos-encoder";

const bytes = new EscPosEncoder()
  .initialize()
  .align("center")
  .line("Hello")
  .qrcode("https://example.com")
  .cut("full")
  .encode();

// vendorId / productId de VOTRE imprimante
await printBytes(0x0fe6, 0x811e, bytes);

Fonctions

| Fonction | Description | | --- | --- | | getDeviceList() | Liste les périphériques USB connectés. | | hasPermission(vid, pid) | true si la permission USB est déjà accordée. | | printRaw(vid, pid, base64) | Envoie des octets (base64) bruts. | | printBytes(vid, pid, Uint8Array) | Comme printRaw mais encode en base64 pour vous. |

Au premier envoi vers un périphérique, Android affiche une popup de permission USB à accepter.

Codes d'erreur (rejets de promesse)

E_NO_DEVICE, E_PERMISSION, E_NO_ENDPOINT, E_OPEN, E_CLAIM, E_TRANSFER, E_DECODE, E_PRINT.

Trouver le VID/PID

console.log(getDeviceList());

Ou via adb : adb shell 'cat /sys/bus/usb/devices/*/idVendor'.