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

sunmi-printer-expo

v1.0.0

Published

Expo module for Sunmi thermal printers integration

Readme

Sunmi Printer Expo

🇺🇸 English version

Un módulo de Expo para integración con impresoras térmicas Sunmi en aplicaciones React Native.

Características

  • ✅ Inicialización de impresora
  • ✅ Impresión de texto con diferentes tamaños
  • ✅ Códigos de barras y QR
  • ✅ Impresión de imágenes (desde assets y base64)
  • ✅ Control de salto de línea y corte de papel
  • ✅ Soporte completo para TypeScript

Instalación

npm install sunmi-printer-expo
# o
yarn add sunmi-printer-expo

Configuración en Expo

Si usas Expo managed workflow, necesitarás usar un custom development client:

expo install expo-dev-client

Uso

import {
  initPrinter,
  printText,
  printTextWithSize,
  printBarcode,
  printQRCode,
  printImage,
  printImageBase64,
  lineWrap,
  cutPaper
} from 'sunmi-printer-expo';

// Inicializar la impresora
const success = await initPrinter();
if (success) {
  console.log('Impresora inicializada correctamente');
}

// Imprimir texto simple
await printText('¡Hola mundo!');

// Imprimir texto con tamaño específico
await printTextWithSize('Texto grande', 24);

// Saltar líneas
await lineWrap(2);

// Imprimir código de barras
await printBarcode('1234567890');

// Imprimir código QR
await printQRCode('https://ejemplo.com');

// Imprimir imagen desde assets
await printImage('logo.png');

// Imprimir imagen desde base64
const base64Image = 'iVBORw0KGgoAAAANSUhEUgAA...';
await printImageBase64(base64Image);

// Cortar papel
await cutPaper();

API

initPrinter(): Promise<boolean>

Inicializa la impresora Sunmi. Retorna true si la inicialización fue exitosa.

printText(text: string): Promise<void>

Imprime texto simple con el tamaño por defecto.

printTextWithSize(text: string, size: number): Promise<void>

Imprime texto con un tamaño específico de fuente.

lineWrap(lines: number): Promise<void>

Agrega saltos de línea (espacios en blanco).

printBarcode(data: string): Promise<void>

Imprime un código de barras con los datos proporcionados.

printQRCode(data: string): Promise<void>

Imprime un código QR con los datos proporcionados.

printImage(assetName: string): Promise<void>

Imprime una imagen desde los assets de la aplicación.

printImageBase64(base64String: string): Promise<void>

Imprime una imagen desde una cadena base64.

cutPaper(): Promise<void>

Corta el papel (si la impresora soporta esta función).

Compatibilidad

  • ✅ Android (Impresoras Sunmi)
  • ❌ iOS (No soportado - específico para Sunmi)
  • ✅ Expo SDK 49+
  • ✅ React Native 0.70+

Ejemplo completo

import React from 'react';
import { View, Button, Alert } from 'react-native';
import {
  initPrinter,
  printText,
  printTextWithSize,
  lineWrap,
  cutPaper
} from 'sunmi-printer-expo';

export default function App() {
  const handlePrint = async () => {
    try {
      // Inicializar impresora
      const success = await initPrinter();
      if (!success) {
        Alert.alert('Error', 'No se pudo inicializar la impresora');
        return;
      }

      // Imprimir recibo de ejemplo
      await printTextWithSize('MI TIENDA', 28);
      await lineWrap(1);
      await printText('Fecha: ' + new Date().toLocaleDateString());
      await printText('--------------------------------');
      await printText('Producto 1          $10.00');
      await printText('Producto 2          $15.50');
      await printText('--------------------------------');
      await printTextWithSize('TOTAL: $25.50', 24);
      await lineWrap(2);
      await printText('¡Gracias por su compra!');
      await lineWrap(2);
      
      // Cortar papel
      await cutPaper();
      
    } catch (error) {
      Alert.alert('Error', 'Error al imprimir: ' + error.message);
    }
  };

  return (
    <View style={{ flex: 1, justifyContent: 'center', padding: 20 }}>
      <Button title="Imprimir Recibo de Prueba" onPress={handlePrint} />
    </View>
  );
}

Contribuir

Las contribuciones son bienvenidas. Por favor:

  1. Fork el repositorio
  2. Crea tu branch de feature (git checkout -b feature/AmazingFeature)
  3. Commit tus cambios (git commit -m 'Add some AmazingFeature')
  4. Push al branch (git push origin feature/AmazingFeature)
  5. Abre un Pull Request

Licencia

Este proyecto está licenciado bajo la Licencia MIT - ver el archivo LICENSE para más detalles.

Soporte

Si encuentras algún problema o tienes preguntas:

  1. Revisa los Issues existentes
  2. Crea un nuevo issue si no encuentras tu problema
  3. Proporciona toda la información relevante (versión de Expo, modelo de impresora, etc.)