Adding a driver
Want to add support for a printer family that isn't already in the ecosystem? The full walkthrough lives in the contributor guide on the .github repo — this page is a one-screen orientation.
What you'd be building
Every driver follows the same layered split. Three published packages:
@thermal-label/<name>-core Pure protocol layer. No I/O. Encodes job bytes, parses status.
@thermal-label/<name>-node Node integration. Composes core + @thermal-label/transport/node.
@thermal-label/<name>-web Browser integration. Composes core + @thermal-label/transport/web.Plus a docs/ folder the org docs site picks up automatically — no per-repo VitePress config required.
What you get for free
@thermal-label/contractsgives youTransport,PrinterAdapter,PrinterDiscovery,MediaDescriptor,PrinterStatus, structured errors, andpickRotation()for orientation logic.@thermal-label/transportgives you ready-to-useUsbTransport,TcpTransport(Node) andWebUsbTransport,WebBluetoothTransport,WebSerialTransport(browser). You don't reimplement USB plumbing.thermal-label-cliauto-discovers your driver via a singletondiscovery: PrinterDiscoveryexport — no CLI change required after publish.- The docs site mounts your
docs/under/<repo>/and picks uppnpm docs:apitypedoc output too. Just commit the markdown.
Conformance contract
A driver is "thermal-label-shaped" when:
coreonly depends on@thermal-label/contractsand your protocol logic.nodeexports aPrinterAdapterclass plus a singletondiscovery: PrinterDiscovery.webexports a similar adapter using the appropriate browser transport; browser packages do not implementPrinterDiscovery(pairing is user-gesture only).- The adapter returns a
PrinterStatuswithready,mediaLoaded,errors[], and optionaldetectedMedia. - Driver-specific media types extend
MediaDescriptor; orientation goes throughpickRotation().
Existing drivers as worked examples
Read these in parallel before starting:
thermal-label/brother-ql— the most elaborate example (multi-color, two-plane preview, large media registry).thermal-label/labelmanager— the smallest example (D1 tape, single-color).thermal-label/labelwriter— middle ground (status bytes, NFC-locked media on 550-series).
The shared playbook these three were built against is captured in plans/implemented/driver-retrofit.md in the org .github repo.
Read next
The full contributor guide expands every section above into a concrete walkthrough with skeleton code. Pre-1.0, it is still a stub being grown — open issues on .github if you find gaps while writing your driver, and we'll fold the answers back into the guide.