@thermal-label/contracts
Classes
| Class | Description |
|---|---|
| DeviceIdentificationRequiredError | A driver-web requestPrinters(opts) factory opened the browser picker and got a port/device back, but couldn't decide which registry entry it corresponds to. The picker may have offered an unidentifiable serial port (Web Serial doesn't expose BT device names) or the picked USB device's VID/PID didn't match anything in the driver's registry. |
| DeviceNotFoundError | No device matching the requested filter was found on the host. |
| EngineRequiredError | PrinterAdapter.print() was called on a multi-engine device whose protocol does not support firmware-side auto-routing, without an explicit engine in PrintOptions. |
| MediaNotSpecifiedError | PrinterAdapter.print() or createPreview() was called without a media argument and no detected media was available. |
| TransportClosedError | The transport was closed while a read or write was in flight, or a new operation was attempted on a closed transport. |
| TransportError | Base class for transport-layer errors. |
| TransportTimeoutError | A read timed out waiting for bytes from the printer. |
| UnsupportedOperationError | The requested operation is not supported by this driver, printer, or media. |
| WriteSerializer | A job-scoped write serializer for driver transport access. |
Interfaces
| Interface | Description |
|---|---|
| BatteryStatus | Battery state of a printer, when the device exposes one. |
| BluetoothGattTransport | Bluetooth Low Energy GATT. |
| BluetoothSppTransport | Bluetooth SPP (Serial Port Profile, classic Bluetooth). |
| DeviceEntry | A device entry in a driver's registry. |
| DeviceRegistry | A driver's full device registry. |
| A single accepted verification report against a device. | |
| Verification state for a device. | |
| DeviceTransports | Per-transport schema for a device. |
| DiscoveredPrinter | A printer that was discovered on one of the supported transports. |
| EngineBind | Per-engine routing hints. |
| EngineDescriptor | A PrintEngine enriched with whether the host runtime has a registered protocol implementation for it. Returned per-engine by resolveSupportedDevices. |
| ExpandedCell | Derived per-cell view emitted by expandVerifications. |
| ExpandedDeviceEntry | One device after expansion: original entry plus the derived grid and the rolled-up supportStatus (worst-case across declared transports, mapped to EffectiveStatus). |
| ExpandedRegistry | Registry projection emitted by expandVerifications. |
| LabelBitmap | A 1-bit-per-pixel bitmap. Row-major, MSB-first within each byte. |
| MediaDescriptor | Base media descriptor. |
| OpenOptions | Options for PrinterDiscovery.openPrinter(). |
| PaletteEntry | One ink/foil colour the printer can place on the substrate. |
| PreviewOptions | Options for PrinterAdapter.createPreview(). |
| PreviewPlane | A single colour plane in a preview. |
| PreviewResult | Result of PrinterAdapter.createPreview(). |
| PrintableArea | Chassis-physical dead-zone insets around the printable rectangle. |
| PrintEngine | A print engine — one printhead with one protocol. |
| PrintEngineCapabilities | Engine-level capability flags. |
| PrinterAdapter | High-level printer interface implemented by each driver family. |
| PrinterDiscovery | Interface for discovering available printers. |
| PrinterError | A single error reported by the printer. |
| PrinterStatus | Runtime status of a printer. |
| PrintOptions | Options for a single PrinterAdapter.print() call. |
| RawImageData | Raw RGBA image data, compatible with browser ImageData and @napi-rs/canvas ImageData. |
| SerialTransport | Physical serial transport parameters (UART / USB-serial). |
| StatusDetail | A driver-formatted diagnostic row. |
| SupportedDevice | A device entry resolved against the host runtime's protocol and transport implementations. |
| TcpTransport | TCP transport parameters. |
| Transport | A bidirectional byte channel to a printer. |
| UsbTransport | USB transport parameters. |
| VerificationCell | One cell of the verification grid — direct observation against one transport on one device. |
Type Aliases
| Type Alias | Description |
|---|---|
| ConnectOptions | Options for the unified driver-web requestPrinters(opts) factory. |
| DeviceVerifications | Per-device authoring block. |
| EffectiveStatus | Render-time status surfaced after expandVerifications. |
| EngineCompat | Engine acceptance is described by PrintEngine.mediaCompatibility (which media classes the head accepts) and media advertise which device classes they fit via MediaDescriptor.targetModels. Both are driver-defined string sets, matched as set intersection. |
| ExpandedVerificationGrid | Per-device expanded grid: transport → ExpandedCell. Only transports the device declares appear; any cell with no direct observation and no propagation lift surfaces as { status: 'unverified' }. |
Legacy four-state verification status backing DeviceSupport.status and DeviceReport.result. | |
| PrinterAdapterMap | Map from engine role → PrinterAdapter for a connected device. |
| RotateDirection | Direction the printer family rotates landscape input. |
| SupportStatus | Stored verification rung — what a maintainer has directly observed. |
| TransportType | Wire-protocol-only transport types. |
Variables
| Variable | Description |
|---|---|
| DEFAULT_POLLING_INTERVAL_MS | Default poll cadence used by pollingOnStatus. Picked to match the harness shell's pre-refactor setInterval cadence so the visible status-pill freshness stays the same. |
| ZERO_PRINTABLE_AREA | The all-zero PrintableArea returned by getPrintableArea when neither the engine nor the media carries dead-zone data. |
Functions
| Function | Description |
|---|---|
| compatibleMediaFor | Filter a media list to entries this engine accepts. |
| expandVerifications | Expand a registry's verifications blocks into a derived grid per device. |
| getForcedTrailingFeedMm | Resolve the post-print forced trailing feed for an engine. |
| getPrintableArea | Resolve the chassis dead-zone for a print, with the standard precedence: per-roll media tag (when present) > engine-level field > zeros. |
| mapLegacyStatus | Map a legacy DeviceSupport.status value to a stored SupportStatus. Returns undefined for 'untested' (= absent in the new shape). |
| mediaCompatibleWith | Returns true iff the media is compatible with the engine. |
| mediaIdentitiesMatch | Returns true iff two media descriptors describe the same physical media. |
| pickRotation | Pick the rotation value to pass to renderImage / renderMultiPlaneImage. |
| pollingOnStatus | Build an onStatus implementation for drivers whose printers don't push spontaneous status frames (LM / LW today; anything where getStatus() is a discrete request/response cycle). |
| resolveSupportedDevices | Filter a registry down to the devices a host runtime can actually drive, given the set of registered protocols and transport implementations. |