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

@m-scan/device-kit-web

v0.0.1

Published

Browser-native printer access via Web Bluetooth and WebUSB — for PWAs on tablets/phones where a local agent isn't possible

Readme

@m-scan/device-kit-web

Accès imprimante directement depuis le navigateur, via Web Bluetooth et WebUSB — pour une PWA sur tablette/téléphone, où @m-scan/device-kit-agent (Node.js) ne peut pas tourner. Fait partie du SDK @m-scan/device-kit.

Installation

npm install @m-scan/device-kit-web

Contrainte du navigateur : pas de scan silencieux

Contrairement à NetworkScanner/UsbScanner (agent), Web Bluetooth/WebUSB exigent un clic utilisateur — il n'existe pas de scan() silencieux qui retourne une liste d'appareils. requestDevice() ouvre la boîte de dialogue native du navigateur, où l'utilisateur choisit lui-même l'appareil ; c'est une restriction de sécurité du navigateur, pas une limitation de ce package.

import { requestUsbPrinter, requestBluetoothPrinter } from '@m-scan/device-kit-web'

// Doit être appelé depuis un gestionnaire de clic (geste utilisateur)
button.addEventListener('click', async () => {
  const printer = await requestUsbPrinter() // ouvre le sélecteur USB natif
  await printer.connect()
  await printer.print(bytes) // Uint8Array de commandes ESC/POS
})
button.addEventListener('click', async () => {
  const printer = await requestBluetoothPrinter() // ouvre le sélecteur Bluetooth natif
  await printer.connect()
  await printer.print(bytes)
})

Le générateur ESC/POS (@m-scan/device-kit-escpos) fonctionne tel quel dans un navigateur pour construire bytes — image()/sharp est Node.js uniquement, mais qrCode() (génération depuis texte/URL, sans sharp) fonctionne en navigateur.

Support navigateur

| API | Chrome/Edge (desktop) | Chrome (Android) | Safari (iOS) | Firefox | |---|---|---|---|---| | WebUSB | ✅ | ✅ | ❌ | ❌ | | Web Bluetooth | ✅ | ✅ | ❌ | ❌ |

Nécessite un contexte sécurisé (HTTPS, ou http://localhost en dev). iOS Safari ne supporte ni l'une ni l'autre API (restriction Apple) — aucune solution navigateur n'existe pour iOS ; iOS resterait à couvrir par une app native si nécessaire un jour.

Limitation importante testée : imprimante déjà pilotée par l'OS

Sur Windows, si l'imprimante a déjà un pilote installé (queue d'impression classique — ce qui est le cas courant sur PC), WebUSB échoue à device.open() avec SecurityError: Access denied — testé avec une imprimante USB réelle (Xprinter POS-80, pilote "Generic / Text Only"). C'est le même verrou système que rencontré côté @m-scan/device-kit-usb avec node-usb/claimInterface : l'OS refuse l'accès USB bas niveau à un périphérique déjà revendiqué par un pilote installé, peu importe la bibliothèque utilisée (node-usb, WebUSB — même cause, même blocage).

Sur Android, où une imprimante thermique USB générique n'a généralement aucun pilote OS préinstallé, WebUSB devrait fonctionner normalement — c'est le scénario visé par ce package (PWA sur tablette), pas encore testé sur un vrai appareil Android.

En pratique :

  • Poste de caisse PC → utiliser @m-scan/device-kit-agent (queue d'impression du système, contourne ce blocage).
  • Tablette/téléphone (PWA) → ce package, en connectant l'imprimante directement sans pilote OS préalable.

API

requestUsbPrinter(options?)

interface RequestUsbPrinterOptions {
  filters?: USBDeviceFilter[] // restreint le sélecteur à des vendorId/productId précis
  interfaceNumber?: number // défaut 0
}

requestBluetoothPrinter(options?)

interface RequestBluetoothPrinterOptions {
  serviceUuid?: string // défaut '000018f0-0000-1000-8000-00805f9b34fb'
  characteristicUuid?: string // défaut '00002af1-0000-1000-8000-00805f9b34fb'
  additionalServiceUuids?: string[]
  chunkSize?: number // défaut 180 — bytes par écriture BLE
}

Les UUID par défaut sont largement utilisés par les imprimantes ESC/POS Bluetooth génériques (marques chinoises courantes), mais pas un standard universel comme SPP l'est pour le Bluetooth classique — vérifier la documentation du modèle précis si la connexion échoue, et passer serviceUuid/characteristicUuid different si besoin.

Statut

WebUsbPrinter/requestUsbPrinter testés avec une imprimante USB réelle (sélection confirmée fonctionnelle ; connexion bloquée par un pilote OS Windows préexistant — voir limitation ci-dessus). WebBluetoothPrinter/ requestBluetoothPrinter pas encore testés avec du matériel réel.

Licence

MIT