Skip to content

thermal-label/contracts

Repository files navigation

@thermal-label/contracts

Shared TypeScript interfaces and types for the thermal-label printer ecosystem. Types only, zero runtime dependencies.

npm version CI License: MIT

Install

pnpm add @thermal-label/contracts

Quick example

import type {
  PrinterAdapter,
  MediaDescriptor,
  PrinterStatus,
  RawImageData,
} from '@thermal-label/contracts';
import { MediaNotSpecifiedError } from '@thermal-label/contracts';

export class MyPrinter implements PrinterAdapter {
  readonly family = 'my-driver';
  readonly model = 'XYZ-100';
  // ... implement print(), createPreview(), getStatus(), close() ...

  async print(image: RawImageData, media?: MediaDescriptor): Promise<void> {
    const m = media ?? this.lastStatus?.detectedMedia;
    if (!m) throw new MediaNotSpecifiedError();
    // render RGBA → native format, stream to the printer...
  }
}

Documentation

Full docs at https://thermal-label.github.io/contracts/.

  • Interface reference (Transport, PrinterAdapter, PrinterDiscovery, MediaDescriptor, PrinterStatus, errors)
  • Implementation sketches
  • Key design decisions

Compatibility

Runtime Node ≥ 20.9 (Node 24 LTS recommended), modern browsers (types only — no runtime gate)
Peer @mbtech-nl/bitmap for LabelBitmap / RawImageData re-exports
License MIT

Contributing

See CONTRIBUTING/ on the org .github repo.

About

Shared types and interfaces for thermal-label printer drivers

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors