Shared TypeScript interfaces and types for the thermal-label printer ecosystem. Types only, zero runtime dependencies.
pnpm add @thermal-label/contractsimport 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...
}
}Full docs at https://thermal-label.github.io/contracts/.
- Interface reference (Transport, PrinterAdapter, PrinterDiscovery, MediaDescriptor, PrinterStatus, errors)
- Implementation sketches
- Key design decisions
| 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 |
See CONTRIBUTING/
on the org .github repo.