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

@mostajs/ticket-print

v0.2.0

Published

Rendu HTML d'un ticket de file d'attente (impression locale) — lean, zéro-dép ; templates, code-barres Code 128 intégré, QR généré par composition (@mostajs/qrpanel).

Readme

@mostajs/ticket-print

Auteur : Dr Hamid MADANI [email protected] · Licence : AGPL-3.0-or-later

Rendu HTML d'un ticket de file d'attente prêt à imprimer (thermique 58/80 mm ou A4). Lean, zéro dépendance runtime.

Installation

npm i @mostajs/ticket-print
# peers OPTIONNELLES : @mostajs/themes (motif de forme), @mostajs/qrpanel (génération du QR)

Exemple

import { renderTicketHtml } from '@mostajs/ticket-print';
import { shapeMotifSvg } from '@mostajs/themes'; // optionnel — motif de forme

const html = renderTicketHtml(
  { number: 'A017', service: 'État civil', createdAt: Date.now(), serverName: 'Mairie' },
  {
    agency: { name: 'Mairie de Mostaganem', companySlogan: 'À votre service' },
    instruction: { ar: 'انتظر', fr: 'Patientez, vous serez appelé', en: 'Please wait' },
    paper: '80mm', locale: 'fr',
    template: 'standard',                       // 0.2.0 — voir ci-dessous
    barcode: true,                              // 0.2.0 — Code 128 du numéro
    motifSvg: shapeMotifSvg('cerises', '#000'), // 🍒 en filigrane
    motifMode: 'coin',                          // ou 'plein' (l'image porte le numéro)
  },
);

// Electron (impression silencieuse)
const win = new BrowserWindow({ show: false });
win.loadURL('data:text/html;charset=utf-8,' + encodeURIComponent(html));
win.webContents.on('did-finish-load', () => win.webContents.print({ silent: true }));

Templates (0.2.0)

opts.template : standard (défaut) · compact · premium · minimal · administrative.

Un template déclare les blocs affichés et pose un calque CSS — le HTML n'est pas dupliqué par template. Certains masquent des blocs : minimal retire logo, message, slogan, pied de page et QR ; administrative retire le QR ; compact retire logo, slogan et pied de page.

Code-barres (0.2.0)

opts.barcode : true (encode le numéro du ticket) ou une chaîne (donnée explicite). Code 128, sous-ensemble B (ASCII imprimable 32..126), rendu en SVG inline. Intégré, synchrone, sans dépendance.

QR (0.2.0)

Le QR se génère avec la variante asynchrone, opts.qr valant true (encode le numéro) ou une chaîne :

import { renderTicketHtmlAsync } from '@mostajs/ticket-print';
const html = await renderTicketHtmlAsync(ticket, { ...opts, qr: true, template: 'premium' });

L'encodage est délégué à @mostajs/qrpanel/qr-svg (peer optionnelle, elle-même sans dépendance), chargé en import dynamique : ce module reste zéro-dépendance pour qui n'utilise pas le QR, et personne ne réimplémente un encodeur QR. Si la peer est absente, le ticket s'imprime sans QR — une impression qui plante serait pire qu'un ticket sans QR.

renderTicketHtml reste synchrone et strictement rétrocompatible : opts.qrDataUri (QR déjà rendu, injecté) est toujours honoré.

Vérification

node examples/print-ticket/verify.mjs    # rendu de base (0.1)
node test-scripts/verify-0.2.mjs         # templates, code-barres, QR, non-régression

API

  • renderTicketHtml(ticket, opts) → string — synchrone, zéro-dép.
  • renderTicketHtmlAsync(ticket, opts) → Promise<string> — idem + génération du QR.
  • barcodeSvg(text, opts) → string — Code 128-B en SVG.
  • TEMPLATES — catalogue des templates. localized(value, locale) → string.

Signature complète : voir llms.txt.