Skip to content

@thermal-label/contracts

Classes

ClassDescription
DeviceIdentificationRequiredErrorA 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.
DeviceNotFoundErrorNo device matching the requested filter was found on the host.
EngineRequiredErrorPrinterAdapter.print() was called on a multi-engine device whose protocol does not support firmware-side auto-routing, without an explicit engine in PrintOptions.
MediaNotSpecifiedErrorPrinterAdapter.print() or createPreview() was called without a media argument and no detected media was available.
TransportClosedErrorThe transport was closed while a read or write was in flight, or a new operation was attempted on a closed transport.
TransportErrorBase class for transport-layer errors.
TransportTimeoutErrorA read timed out waiting for bytes from the printer.
UnsupportedOperationErrorThe requested operation is not supported by this driver, printer, or media.
WriteSerializerA job-scoped write serializer for driver transport access.

Interfaces

InterfaceDescription
BatteryStatusBattery state of a printer, when the device exposes one.
BluetoothGattTransportBluetooth Low Energy GATT.
BluetoothSppTransportBluetooth SPP (Serial Port Profile, classic Bluetooth).
DeviceEntryA device entry in a driver's registry.
DeviceRegistryA driver's full device registry.
DeviceReportA single accepted verification report against a device.
DeviceSupportVerification state for a device.
DeviceTransportsPer-transport schema for a device.
DiscoveredPrinterA printer that was discovered on one of the supported transports.
EngineBindPer-engine routing hints.
EngineDescriptorA PrintEngine enriched with whether the host runtime has a registered protocol implementation for it. Returned per-engine by resolveSupportedDevices.
ExpandedCellDerived per-cell view emitted by expandVerifications.
ExpandedDeviceEntryOne device after expansion: original entry plus the derived grid and the rolled-up supportStatus (worst-case across declared transports, mapped to EffectiveStatus).
ExpandedRegistryRegistry projection emitted by expandVerifications.
LabelBitmapA 1-bit-per-pixel bitmap. Row-major, MSB-first within each byte.
MediaDescriptorBase media descriptor.
OpenOptionsOptions for PrinterDiscovery.openPrinter().
PaletteEntryOne ink/foil colour the printer can place on the substrate.
PreviewOptionsOptions for PrinterAdapter.createPreview().
PreviewPlaneA single colour plane in a preview.
PreviewResultResult of PrinterAdapter.createPreview().
PrintableAreaChassis-physical dead-zone insets around the printable rectangle.
PrintEngineA print engine — one printhead with one protocol.
PrintEngineCapabilitiesEngine-level capability flags.
PrinterAdapterHigh-level printer interface implemented by each driver family.
PrinterDiscoveryInterface for discovering available printers.
PrinterErrorA single error reported by the printer.
PrinterStatusRuntime status of a printer.
PrintOptionsOptions for a single PrinterAdapter.print() call.
RawImageDataRaw RGBA image data, compatible with browser ImageData and @napi-rs/canvas ImageData.
SerialTransportPhysical serial transport parameters (UART / USB-serial).
StatusDetailA driver-formatted diagnostic row.
SupportedDeviceA device entry resolved against the host runtime's protocol and transport implementations.
TcpTransportTCP transport parameters.
TransportA bidirectional byte channel to a printer.
UsbTransportUSB transport parameters.
VerificationCellOne cell of the verification grid — direct observation against one transport on one device.

Type Aliases

Type AliasDescription
ConnectOptionsOptions for the unified driver-web requestPrinters(opts) factory.
DeviceVerificationsPer-device authoring block.
EffectiveStatusRender-time status surfaced after expandVerifications.
EngineCompatEngine 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.
ExpandedVerificationGridPer-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' }.
LegacySupportStatusLegacy four-state verification status backing DeviceSupport.status and DeviceReport.result.
PrinterAdapterMapMap from engine role → PrinterAdapter for a connected device.
RotateDirectionDirection the printer family rotates landscape input.
SupportStatusStored verification rung — what a maintainer has directly observed.
TransportTypeWire-protocol-only transport types.

Variables

VariableDescription
DEFAULT_POLLING_INTERVAL_MSDefault 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_AREAThe all-zero PrintableArea returned by getPrintableArea when neither the engine nor the media carries dead-zone data.

Functions

FunctionDescription
compatibleMediaForFilter a media list to entries this engine accepts.
expandVerificationsExpand a registry's verifications blocks into a derived grid per device.
getForcedTrailingFeedMmResolve the post-print forced trailing feed for an engine.
getPrintableAreaResolve the chassis dead-zone for a print, with the standard precedence: per-roll media tag (when present) > engine-level field > zeros.
mapLegacyStatusMap a legacy DeviceSupport.status value to a stored SupportStatus. Returns undefined for 'untested' (= absent in the new shape).
mediaCompatibleWithReturns true iff the media is compatible with the engine.
mediaIdentitiesMatchReturns true iff two media descriptors describe the same physical media.
pickRotationPick the rotation value to pass to renderImage / renderMultiPlaneImage.
pollingOnStatusBuild 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).
resolveSupportedDevicesFilter a registry down to the devices a host runtime can actually drive, given the set of registered protocols and transport implementations.