@thermal-label/brother-ql-node 0.0.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/__tests__/discovery.test.js +141 -68
  2. package/dist/__tests__/discovery.test.js.map +1 -1
  3. package/dist/__tests__/integration/print.test.d.ts +2 -0
  4. package/dist/__tests__/integration/print.test.d.ts.map +1 -0
  5. package/dist/__tests__/integration/print.test.js +71 -0
  6. package/dist/__tests__/integration/print.test.js.map +1 -0
  7. package/dist/__tests__/printer.test.js +214 -208
  8. package/dist/__tests__/printer.test.js.map +1 -1
  9. package/dist/discovery.d.ts +39 -4
  10. package/dist/discovery.d.ts.map +1 -1
  11. package/dist/discovery.js +87 -14
  12. package/dist/discovery.js.map +1 -1
  13. package/dist/index.d.ts +3 -8
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +2 -6
  16. package/dist/index.js.map +1 -1
  17. package/dist/printer.d.ts +38 -15
  18. package/dist/printer.d.ts.map +1 -1
  19. package/dist/printer.js +108 -149
  20. package/dist/printer.js.map +1 -1
  21. package/package.json +7 -5
  22. package/dist/__tests__/errors.test.d.ts +0 -2
  23. package/dist/__tests__/errors.test.d.ts.map +0 -1
  24. package/dist/__tests__/errors.test.js +0 -20
  25. package/dist/__tests__/errors.test.js.map +0 -1
  26. package/dist/__tests__/integration/print-image.test.d.ts +0 -2
  27. package/dist/__tests__/integration/print-image.test.d.ts.map +0 -1
  28. package/dist/__tests__/integration/print-image.test.js +0 -22
  29. package/dist/__tests__/integration/print-image.test.js.map +0 -1
  30. package/dist/__tests__/integration/print-text.test.d.ts +0 -2
  31. package/dist/__tests__/integration/print-text.test.d.ts.map +0 -1
  32. package/dist/__tests__/integration/print-text.test.js +0 -25
  33. package/dist/__tests__/integration/print-text.test.js.map +0 -1
  34. package/dist/__tests__/integration/print-two-color.test.d.ts +0 -2
  35. package/dist/__tests__/integration/print-two-color.test.d.ts.map +0 -1
  36. package/dist/__tests__/integration/print-two-color.test.js +0 -28
  37. package/dist/__tests__/integration/print-two-color.test.js.map +0 -1
  38. package/dist/__tests__/integration/tcp.test.d.ts +0 -2
  39. package/dist/__tests__/integration/tcp.test.d.ts.map +0 -1
  40. package/dist/__tests__/integration/tcp.test.js +0 -20
  41. package/dist/__tests__/integration/tcp.test.js.map +0 -1
  42. package/dist/__tests__/tcp-transport.test.d.ts +0 -2
  43. package/dist/__tests__/tcp-transport.test.d.ts.map +0 -1
  44. package/dist/__tests__/tcp-transport.test.js +0 -115
  45. package/dist/__tests__/tcp-transport.test.js.map +0 -1
  46. package/dist/__tests__/usb-transport.test.d.ts +0 -2
  47. package/dist/__tests__/usb-transport.test.d.ts.map +0 -1
  48. package/dist/__tests__/usb-transport.test.js +0 -99
  49. package/dist/__tests__/usb-transport.test.js.map +0 -1
  50. package/dist/errors.d.ts +0 -8
  51. package/dist/errors.d.ts.map +0 -1
  52. package/dist/errors.js +0 -15
  53. package/dist/errors.js.map +0 -1
  54. package/dist/status.d.ts +0 -2
  55. package/dist/status.d.ts.map +0 -1
  56. package/dist/status.js +0 -2
  57. package/dist/status.js.map +0 -1
  58. package/dist/transport.d.ts +0 -32
  59. package/dist/transport.d.ts.map +0 -1
  60. package/dist/transport.js +0 -120
  61. package/dist/transport.js.map +0 -1
  62. package/dist/types.d.ts +0 -13
  63. package/dist/types.d.ts.map +0 -1
  64. package/dist/types.js +0 -2
  65. package/dist/types.js.map +0 -1
package/dist/discovery.js CHANGED
@@ -1,11 +1,19 @@
1
- import usb from 'usb';
2
1
  import { DEVICES, findDevice, isMassStorageMode } from '@thermal-label/brother-ql-core';
3
- import {} from './types.js';
2
+ import { SerialTransport, TcpTransport, UsbTransport } from '@thermal-label/transport/node';
3
+ import * as usb from 'usb';
4
+ import { BrotherQLPrinter } from './printer.js';
4
5
  const BROTHER_VID = 0x04f9;
5
- export function listPrinters() {
6
+ async function readSerialNumber(device, idx) {
7
+ return new Promise(resolve => {
8
+ device.getStringDescriptor(idx, (err, value) => {
9
+ resolve(err ? undefined : value);
10
+ });
11
+ });
12
+ }
13
+ async function enumerateUsbDevices() {
6
14
  const results = [];
7
- for (const usbDevice of usb.getDeviceList()) {
8
- const desc = usbDevice.deviceDescriptor;
15
+ for (const device of usb.getDeviceList()) {
16
+ const desc = device.deviceDescriptor;
9
17
  if (desc.idVendor !== BROTHER_VID)
10
18
  continue;
11
19
  if (isMassStorageMode(desc.idProduct)) {
@@ -14,18 +22,83 @@ export function listPrinters() {
14
22
  'Hold the Editor Lite button until the LED turns off to switch to printer mode.');
15
23
  continue;
16
24
  }
17
- const device = findDevice(desc.idVendor, desc.idProduct);
18
- if (!device)
25
+ const descriptor = findDevice(desc.idVendor, desc.idProduct);
26
+ if (!descriptor)
19
27
  continue;
20
- const path = `${usbDevice.busNumber.toString()}.${usbDevice.deviceAddress.toString()}`;
21
- results.push({
22
- device,
23
- serialNumber: undefined,
24
- path,
28
+ let serialNumber;
29
+ if (desc.iSerialNumber) {
30
+ device.open();
31
+ try {
32
+ serialNumber = await readSerialNumber(device, desc.iSerialNumber);
33
+ }
34
+ finally {
35
+ device.close();
36
+ }
37
+ }
38
+ results.push({ device, descriptor, serialNumber });
39
+ }
40
+ return results;
41
+ }
42
+ /**
43
+ * `PrinterDiscovery` implementation for Brother QL printers.
44
+ *
45
+ * `listPrinters()` enumerates USB and skips printers in Editor Lite
46
+ * mass-storage mode (a warning is logged — the user has to switch
47
+ * them out of Editor Lite manually). Network printers open via
48
+ * `openPrinter({ host, port })`; there is no mDNS implementation so
49
+ * `listPrinters()` never surfaces them.
50
+ */
51
+ export class BrotherQLDiscovery {
52
+ family = 'brother-ql';
53
+ async listPrinters() {
54
+ const found = await enumerateUsbDevices();
55
+ return found.map(({ device, descriptor, serialNumber }) => ({
56
+ device: descriptor,
57
+ ...(serialNumber === undefined ? {} : { serialNumber }),
25
58
  transport: 'usb',
59
+ connectionId: `${String(device.busNumber)}.${String(device.deviceAddress)}`,
60
+ }));
61
+ }
62
+ async openPrinter(options = {}) {
63
+ if (options.path !== undefined) {
64
+ const transport = await SerialTransport.open(options.path, options.baudRate);
65
+ // Serial (typically RFCOMM) carries no identifying metadata —
66
+ // fall back to the most capable descriptor with a serial
67
+ // transport tag. `getStatus()` still returns accurate
68
+ // detectedMedia regardless of which descriptor we attach.
69
+ const descriptor = Object.values(DEVICES).find(d => d.transports.includes('serial'));
70
+ /* v8 ignore next -- DEVICES always has QL_820NWB with 'serial' in transports */
71
+ if (!descriptor)
72
+ throw new Error('No serial-capable Brother QL descriptor found.');
73
+ return new BrotherQLPrinter(descriptor, transport, 'serial');
74
+ }
75
+ if (options.host !== undefined) {
76
+ const transport = await TcpTransport.connect(options.host, options.port);
77
+ const descriptor = Object.values(DEVICES).find(d => d.network !== 'none');
78
+ /* v8 ignore next -- DEVICES always has network-capable entries */
79
+ if (!descriptor)
80
+ throw new Error('No network-capable Brother QL descriptor found.');
81
+ return new BrotherQLPrinter(descriptor, transport, 'tcp');
82
+ }
83
+ const found = await enumerateUsbDevices();
84
+ const match = found.find(entry => {
85
+ if (options.vid !== undefined && entry.descriptor.vid !== options.vid)
86
+ return false;
87
+ if (options.pid !== undefined && entry.descriptor.pid !== options.pid)
88
+ return false;
89
+ if (options.serialNumber !== undefined && entry.serialNumber !== options.serialNumber)
90
+ return false;
91
+ return true;
26
92
  });
93
+ if (!match)
94
+ throw new Error('No compatible Brother QL printer found.');
95
+ const transport = await UsbTransport.open(match.descriptor.vid, match.descriptor.pid);
96
+ return new BrotherQLPrinter(match.descriptor, transport, 'usb');
27
97
  }
28
- return results;
29
98
  }
30
- export { DEVICES };
99
+ /**
100
+ * Named export discovered by the unified `thermal-label-cli` — the CLI
101
+ * walks installed drivers looking for `mod.discovery`.
102
+ */
103
+ export const discovery = new BrotherQLDiscovery();
31
104
  //# sourceMappingURL=discovery.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"discovery.js","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA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F,OAAO,KAAK,CAAC;YACf,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAEvE,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACtF,OAAO,IAAI,gBAAgB,CAAC,KAAK,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IAClE,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,kBAAkB,EAAE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,4 @@
1
- export { UsbTransport, TcpTransport } from './transport.js';
2
- export { BrotherQLPrinter, openPrinter, openPrinterTcp } from './printer.js';
3
- export { listPrinters } from './discovery.js';
4
- export { UnsupportedOperationError, PrinterError } from './errors.js';
5
- export type { Transport } from './transport.js';
6
- export type { OpenOptions, PrinterInfo } from './types.js';
7
- export { DEVICES, MEDIA, findDevice, findMedia, findMediaByWidth, encodeJob, renderText, renderImage, } from '@thermal-label/brother-ql-core';
8
- export type { DeviceDescriptor, MediaDescriptor, PageData, PageOptions, JobOptions, PrinterStatus, LabelBitmap, RawImageData, MediaType, TextPrintOptions, ImagePrintOptions, } from '@thermal-label/brother-ql-core';
1
+ export { BrotherQLDiscovery, discovery } from './discovery.js';
2
+ export type { BrotherQLOpenOptions } from './discovery.js';
3
+ export { BrotherQLPrinter } from './printer.js';
9
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEtE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG3D,OAAO,EACL,OAAO,EACP,KAAK,EACL,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,WAAW,GACZ,MAAM,gCAAgC,CAAC;AACxC,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,QAAQ,EACR,WAAW,EACX,UAAU,EACV,aAAa,EACb,WAAW,EACX,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC/D,YAAY,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,3 @@
1
- export { UsbTransport, TcpTransport } from './transport.js';
2
- export { BrotherQLPrinter, openPrinter, openPrinterTcp } from './printer.js';
3
- export { listPrinters } from './discovery.js';
4
- export { UnsupportedOperationError, PrinterError } from './errors.js';
5
- // Re-export core API so consumers only need one import
6
- export { DEVICES, MEDIA, findDevice, findMedia, findMediaByWidth, encodeJob, renderText, renderImage, } from '@thermal-label/brother-ql-core';
1
+ export { BrotherQLDiscovery, discovery } from './discovery.js';
2
+ export { BrotherQLPrinter } from './printer.js';
7
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKtE,uDAAuD;AACvD,OAAO,EACL,OAAO,EACP,KAAK,EACL,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,WAAW,GACZ,MAAM,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
package/dist/printer.d.ts CHANGED
@@ -1,18 +1,41 @@
1
- import { type DeviceDescriptor, type MediaDescriptor, type PageData, type PageOptions, type JobOptions, type PrinterStatus, type LabelBitmap, type TextPrintOptions, type ImagePrintOptions } from '@thermal-label/brother-ql-core';
2
- import { type Transport } from './transport.js';
3
- import { type OpenOptions } from './types.js';
4
- export declare class BrotherQLPrinter {
5
- readonly device: DeviceDescriptor;
6
- readonly transport: 'usb' | 'tcp';
7
- private readonly _transport;
8
- constructor(transport: Transport, device: DeviceDescriptor, transportType: 'usb' | 'tcp');
9
- getStatus(): Promise<PrinterStatus>;
10
- print(pages: PageData[], options?: JobOptions): Promise<void>;
11
- printText(text: string, media: MediaDescriptor, options?: TextPrintOptions): Promise<void>;
12
- printImage(image: Buffer | string, media: MediaDescriptor, options?: ImagePrintOptions): Promise<void>;
13
- printTwoColor(black: LabelBitmap, red: LabelBitmap, media: MediaDescriptor, options?: PageOptions): Promise<void>;
1
+ import type { BrotherQLDevice, BrotherQLPrintOptions, BrotherQLStatus, MediaDescriptor, PreviewOptions, PreviewResult, PrinterAdapter, RawImageData, Transport, TransportType } from '@thermal-label/brother-ql-core';
2
+ /**
3
+ * Node.js driver for Brother QL label printers.
4
+ *
5
+ * Implements `PrinterAdapter`. Callers get a printer instance from
6
+ * `discovery.openPrinter()` (USB or TCP) and interact solely through
7
+ * the adapter surface: `print(rgba, media?, options?)`, `createPreview`,
8
+ * `getStatus`, `close`.
9
+ *
10
+ * Multi-ink media (DK-22251) is handled transparently — when the
11
+ * resolved media carries a `palette`, the driver runs the bitmap
12
+ * library's `renderMultiPlaneImage()` internally before encoding.
13
+ *
14
+ * Orientation is auto-decided via `pickRotation`: landscape input on
15
+ * media tagged `defaultOrientation: 'horizontal'` rotates 90° CW so
16
+ * the visual reads along the tape feed direction. Override per-call
17
+ * with `options.rotate`.
18
+ */
19
+ export declare class BrotherQLPrinter implements PrinterAdapter {
20
+ readonly family: "brother-ql";
21
+ readonly device: BrotherQLDevice;
22
+ readonly transportType: TransportType;
23
+ private readonly transport;
24
+ private lastStatus;
25
+ constructor(device: BrotherQLDevice, transport: Transport, transportType: TransportType);
26
+ get model(): string;
27
+ get connected(): boolean;
28
+ print(image: RawImageData, media?: MediaDescriptor, options?: BrotherQLPrintOptions): Promise<void>;
29
+ private writeChunked;
30
+ createPreview(image: RawImageData, options?: PreviewOptions): Promise<PreviewResult>;
31
+ /**
32
+ * Poll the status endpoint until 32 bytes are available.
33
+ *
34
+ * The USB `transferAsync()` call resolves immediately with 0 bytes if
35
+ * the printer hasn't queued a response yet, so retry with a short
36
+ * delay up to `STATUS_POLL_ATTEMPTS` times.
37
+ */
38
+ getStatus(): Promise<BrotherQLStatus>;
14
39
  close(): Promise<void>;
15
40
  }
16
- export declare function openPrinter(options?: OpenOptions): Promise<BrotherQLPrinter>;
17
- export declare function openPrinterTcp(host: string, port?: number): Promise<BrotherQLPrinter>;
18
41
  //# sourceMappingURL=printer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"printer.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AED,wBAAsB,WAAW,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAgBlF;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,SAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAkBzF"}
1
+ {"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,eAAe,EAEf,qBAAqB,EACrB,eAAe,EAEf,eAAe,EAEf,cAAc,EACd,aAAa,EACb,cAAc,EACd,YAAY,EACZ,SAAS,EACT,aAAa,EACd,MAAM,gCAAgC,CAAC;AAoBxC;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,gBAAiB,YAAW,cAAc;IACrD,QAAQ,CAAC,MAAM,eAAyB;IACxC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IAEtC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,UAAU,CAA8B;gBAEpC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa;IAMvF,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,SAAS,IAAI,OAAO,CAEvB;IAEK,KAAK,CACT,KAAK,EAAE,YAAY,EACnB,KAAK,CAAC,EAAE,eAAe,EACvB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,IAAI,CAAC;YAgCF,YAAY;IAU1B,aAAa,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAWpF;;;;;;OAMG;IACG,SAAS,IAAI,OAAO,CAAC,eAAe,CAAC;IAcrC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
package/dist/printer.js CHANGED
@@ -1,167 +1,126 @@
1
- import { encodeJob, findDevice, renderText, renderImage, } from '@thermal-label/brother-ql-core';
2
- import { rotateBitmap } from '@mbtech-nl/bitmap';
3
- import { UsbTransport, TcpTransport } from './transport.js';
4
- import { parseStatus, STATUS_REQUEST } from './status.js';
5
- import { listPrinters } from './discovery.js';
6
- import { UnsupportedOperationError } from './errors.js';
7
- import {} from './types.js';
8
- const BROTHER_VID = 0x04f9;
1
+ import { DEFAULT_MEDIA, ROTATE_DIRECTION, STATUS_REQUEST, createPreviewOffline, encodeJob, flipHorizontal, parseStatus, pickRotation, renderImage, renderMultiPlaneImage, } from '@thermal-label/brother-ql-core';
2
+ import { MediaNotSpecifiedError } from '@thermal-label/contracts';
3
+ const STATUS_BYTE_COUNT = 32;
4
+ const STATUS_POLL_INTERVAL_MS = 150;
5
+ const STATUS_POLL_ATTEMPTS = 10;
6
+ // Empirical: a single libusb bulk transfer of an entire raster job (~50 kB
7
+ // uncompressed two-colour at 280 rows) reliably hangs the QL-820NWBc
8
+ // firmware mid-print. Chunking the OUT pipe to ~1 kB with a 20 ms gap
9
+ // keeps the printer's input ring buffer drained at roughly its raster
10
+ // processing rate (~175 bytes/ms at 80 mm/s feed). Adds about 1 s to a
11
+ // 50 kB job, which is negligible compared to physical print time.
12
+ //
13
+ // Python `brother_ql` users hit this less often because the typical CLI
14
+ // path writes through `/dev/usb/lpN` where the kernel's usblp driver
15
+ // provides flow control; libusb bypasses that.
16
+ const USB_CHUNK_SIZE = 1024;
17
+ const USB_CHUNK_DELAY_MS = 20;
18
+ /**
19
+ * Node.js driver for Brother QL label printers.
20
+ *
21
+ * Implements `PrinterAdapter`. Callers get a printer instance from
22
+ * `discovery.openPrinter()` (USB or TCP) and interact solely through
23
+ * the adapter surface: `print(rgba, media?, options?)`, `createPreview`,
24
+ * `getStatus`, `close`.
25
+ *
26
+ * Multi-ink media (DK-22251) is handled transparently — when the
27
+ * resolved media carries a `palette`, the driver runs the bitmap
28
+ * library's `renderMultiPlaneImage()` internally before encoding.
29
+ *
30
+ * Orientation is auto-decided via `pickRotation`: landscape input on
31
+ * media tagged `defaultOrientation: 'horizontal'` rotates 90° CW so
32
+ * the visual reads along the tape feed direction. Override per-call
33
+ * with `options.rotate`.
34
+ */
9
35
  export class BrotherQLPrinter {
36
+ family = 'brother-ql';
10
37
  device;
38
+ transportType;
11
39
  transport;
12
- _transport;
13
- constructor(transport, device, transportType) {
14
- this._transport = transport;
40
+ lastStatus;
41
+ constructor(device, transport, transportType) {
15
42
  this.device = device;
16
- this.transport = transportType;
43
+ this.transport = transport;
44
+ this.transportType = transportType;
17
45
  }
18
- async getStatus() {
19
- await this._transport.write(STATUS_REQUEST);
20
- // The USB IN endpoint (transferAsync) resolves immediately with 0 bytes if
21
- // the printer hasn't queued its response yet. Retry until we have 32 bytes.
22
- for (let attempt = 0; attempt < 10; attempt++) {
23
- await new Promise(r => setTimeout(r, 150));
24
- const bytes = await this._transport.read(32);
25
- if (bytes.length >= 32)
26
- return parseStatus(bytes);
27
- }
28
- throw new Error('Printer did not respond to status request within 1.5s');
46
+ get model() {
47
+ return this.device.name;
29
48
  }
30
- async print(pages, options) {
31
- const data = encodeJob(pages, options);
32
- await this._transport.write(data);
33
- }
34
- async printText(text, media, options) {
35
- const { invert, scaleX, scaleY, ...pageOptions } = options ?? {};
36
- // Scale so the label is roughly square: largest integer scale where neither the tape
37
- // width (base.heightPx axis) nor the label length (base.widthPx axis) exceeds printAreaDots.
38
- const base = renderText(text, { scaleX: 1, scaleY: 1 });
39
- const autoScale = Math.max(1, Math.floor(media.printAreaDots / Math.max(base.widthPx, base.heightPx)));
40
- const effectiveScaleY = scaleY ?? autoScale;
41
- const effectiveScaleX = scaleX ?? autoScale;
42
- const rawBitmap = renderText(text, {
43
- ...(invert !== undefined ? { invert } : {}),
44
- scaleX: effectiveScaleX,
45
- scaleY: effectiveScaleY,
46
- });
47
- const bitmap = rotateBitmap(rawBitmap, 270);
48
- const page = {
49
- bitmap,
50
- media,
51
- ...(Object.keys(pageOptions).length > 0 ? { options: pageOptions } : {}),
52
- };
53
- await this.print([page]);
49
+ get connected() {
50
+ return this.transport.connected;
54
51
  }
55
- async printImage(image, media, options) {
56
- const { threshold, dither, invert, rotate, ...pageOptions } = options ?? {};
57
- let rawImageData;
58
- if (typeof image === 'string') {
59
- rawImageData = await loadImageFile(image);
52
+ async print(image, media, options) {
53
+ const resolvedMedia = (media ?? this.lastStatus?.detectedMedia);
54
+ if (!resolvedMedia) {
55
+ throw new MediaNotSpecifiedError();
56
+ }
57
+ const rotate = pickRotation(image, resolvedMedia, ROTATE_DIRECTION, options?.rotate);
58
+ // Brother QL print head: pin 0 (the first pin in each raster row) sits
59
+ // on the right side of the printed face when the leading edge is held
60
+ // up. Mirror the rendered bitmap so the input image's x-axis matches
61
+ // the printed x-axis. Verified on QL-820NWBc + DK-22251.
62
+ let page;
63
+ if (resolvedMedia.palette) {
64
+ const { black, red } = renderMultiPlaneImage(image, {
65
+ palette: resolvedMedia.palette,
66
+ rotate,
67
+ });
68
+ page = {
69
+ bitmap: flipHorizontal(black),
70
+ redBitmap: flipHorizontal(red),
71
+ media: resolvedMedia,
72
+ };
60
73
  }
61
74
  else {
62
- rawImageData = await decodeBuffer(image);
75
+ const bitmap = flipHorizontal(renderImage(image, { dither: true, rotate }));
76
+ page = { bitmap, media: resolvedMedia };
63
77
  }
64
- const rawBitmap = renderImage(rawImageData, {
65
- ...(threshold !== undefined ? { threshold } : {}),
66
- ...(dither !== undefined ? { dither } : {}),
67
- ...(invert !== undefined ? { invert } : {}),
68
- ...(rotate !== undefined ? { rotate } : {}),
69
- });
70
- const bitmap = rotateBitmap(rawBitmap, 270);
71
- const page = {
72
- bitmap,
73
- media,
74
- ...(Object.keys(pageOptions).length > 0 ? { options: pageOptions } : {}),
75
- };
76
- await this.print([page]);
78
+ const bytes = encodeJob([page]);
79
+ await this.writeChunked(bytes);
77
80
  }
78
- async printTwoColor(black, red, media, options) {
79
- if (!this.device.twoColor) {
80
- throw new UnsupportedOperationError(`${this.device.name} does not support two-color printing. ` +
81
- 'Two-color printing requires a QL-800, QL-810W, or QL-820NWB with DK-22251 labels.');
81
+ async writeChunked(bytes) {
82
+ for (let off = 0; off < bytes.length; off += USB_CHUNK_SIZE) {
83
+ const end = Math.min(off + USB_CHUNK_SIZE, bytes.length);
84
+ await this.transport.write(bytes.subarray(off, end));
85
+ if (end < bytes.length) {
86
+ await new Promise(r => setTimeout(r, USB_CHUNK_DELAY_MS));
87
+ }
82
88
  }
83
- const page = {
84
- bitmap: black,
85
- redBitmap: red,
86
- media,
87
- ...(options !== undefined ? { options } : {}),
88
- };
89
- await this.print([page]);
90
- }
91
- async close() {
92
- await this._transport.close();
93
- }
94
- }
95
- export async function openPrinter(options) {
96
- const { vid = BROTHER_VID, pid } = options ?? {};
97
- if (pid) {
98
- const device = findDevice(vid, pid);
99
- if (!device)
100
- throw new Error(`Unknown device: ${vid.toString(16)}:${pid.toString(16)}`);
101
- const transport = await UsbTransport.open(vid, pid);
102
- return new BrotherQLPrinter(transport, device, 'usb');
103
89
  }
104
- const printers = listPrinters();
105
- if (printers.length === 0)
106
- throw new Error('No Brother QL printers found');
107
- const info = printers[0];
108
- if (!info)
109
- throw new Error('No Brother QL printers found');
110
- const transport = await UsbTransport.open(info.device.vid, info.device.pid);
111
- return new BrotherQLPrinter(transport, info.device, 'usb');
112
- }
113
- export async function openPrinterTcp(host, port = 9100) {
114
- const transport = await TcpTransport.connect(host, port);
115
- // We can't know the device descriptor from TCP alone — request status and detect
116
- // Fall back to a generic QL-820NWB descriptor (most capable, verified by maintainer)
117
- const status = await (async () => {
118
- await transport.write(new Uint8Array([0x1b, 0x69, 0x53]));
119
- return transport.read(32);
120
- })();
121
- const mediaWidthMm = status[10] ?? 0;
122
- // Try to find a matching device by network capability
123
- const { DEVICES } = await import('@thermal-label/brother-ql-core');
124
- const networkDevice = Object.values(DEVICES).find(d => d.network !== 'none');
125
- const device = networkDevice ?? DEVICES.QL_820NWB;
126
- void mediaWidthMm; // may be used for smarter detection in future
127
- return new BrotherQLPrinter(transport, device, 'tcp');
128
- }
129
- async function loadImageFile(filePath) {
130
- try {
131
- const canvas = await import('@napi-rs/canvas');
132
- const img = await canvas.loadImage(filePath);
133
- const canvasEl = canvas.createCanvas(img.width, img.height);
134
- const ctx = canvasEl.getContext('2d');
135
- ctx.drawImage(img, 0, 0);
136
- const imageData = ctx.getImageData(0, 0, img.width, img.height);
137
- return {
138
- width: img.width,
139
- height: img.height,
140
- data: new Uint8Array(imageData.data.buffer),
141
- };
142
- }
143
- catch {
144
- throw new Error('Cannot load image file: install @napi-rs/canvas for image file support, ' +
145
- 'or pass a pre-decoded RawImageData to print().');
90
+ createPreview(image, options) {
91
+ const override = options?.media;
92
+ const detected = this.lastStatus?.detectedMedia;
93
+ if (override)
94
+ return Promise.resolve(createPreviewOffline(image, override));
95
+ if (detected)
96
+ return Promise.resolve(createPreviewOffline(image, detected));
97
+ return Promise.resolve({
98
+ ...createPreviewOffline(image, DEFAULT_MEDIA),
99
+ assumed: true,
100
+ });
146
101
  }
147
- }
148
- async function decodeBuffer(buffer) {
149
- try {
150
- const canvas = await import('@napi-rs/canvas');
151
- const img = await canvas.loadImage(buffer);
152
- const canvasEl = canvas.createCanvas(img.width, img.height);
153
- const ctx = canvasEl.getContext('2d');
154
- ctx.drawImage(img, 0, 0);
155
- const imageData = ctx.getImageData(0, 0, img.width, img.height);
156
- return {
157
- width: img.width,
158
- height: img.height,
159
- data: new Uint8Array(imageData.data.buffer),
160
- };
102
+ /**
103
+ * Poll the status endpoint until 32 bytes are available.
104
+ *
105
+ * The USB `transferAsync()` call resolves immediately with 0 bytes if
106
+ * the printer hasn't queued a response yet, so retry with a short
107
+ * delay up to `STATUS_POLL_ATTEMPTS` times.
108
+ */
109
+ async getStatus() {
110
+ await this.transport.write(STATUS_REQUEST);
111
+ for (let attempt = 0; attempt < STATUS_POLL_ATTEMPTS; attempt++) {
112
+ await new Promise(r => setTimeout(r, STATUS_POLL_INTERVAL_MS));
113
+ const bytes = await this.transport.read(STATUS_BYTE_COUNT);
114
+ if (bytes.length >= STATUS_BYTE_COUNT) {
115
+ const status = parseStatus(bytes);
116
+ this.lastStatus = status;
117
+ return status;
118
+ }
119
+ }
120
+ throw new Error('Printer did not respond to status request within 1.5s');
161
121
  }
162
- catch {
163
- throw new Error('Cannot decode image buffer: install @napi-rs/canvas for PNG/JPEG decoding, ' +
164
- 'or pass a pre-decoded RawImageData to print().');
122
+ async close() {
123
+ await this.transport.close();
165
124
  }
166
125
  }
167
126
  //# sourceMappingURL=printer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"printer.js","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,WAAW,GAWZ,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAoB,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,GAAG,MAAM,CAAC;AAE3B,MAAM,OAAO,gBAAgB;IAClB,MAAM,CAAmB;IACzB,SAAS,CAAgB;IACjB,UAAU,CAAY;IAEvC,YAAY,SAAoB,EAAE,MAAwB,EAAE,aAA4B;QACtF,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,aAAa,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,SAAS;QACb,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAC5C,2EAA2E;QAC3E,4EAA4E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AAE,CAAC;gBACtC,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;gBAClC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;gBACzB,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thermal-label/brother-ql-node",
3
- "version": "0.0.1",
3
+ "version": "0.3.0",
4
4
  "description": "Node.js USB and TCP driver for Brother QL label printers",
5
5
  "keywords": [
6
6
  "brother",
@@ -45,17 +45,19 @@
45
45
  },
46
46
  "sideEffects": false,
47
47
  "main": "./dist/index.js",
48
- "types": "./src/index.ts",
48
+ "types": "./dist/index.d.ts",
49
49
  "exports": {
50
50
  ".": {
51
51
  "import": "./dist/index.js",
52
- "types": "./src/index.ts"
52
+ "types": "./dist/index.d.ts"
53
53
  }
54
54
  },
55
55
  "dependencies": {
56
- "@mbtech-nl/bitmap": "^0.1.0",
56
+ "@mbtech-nl/bitmap": "^1.2.1",
57
+ "@thermal-label/contracts": "^0.2.0",
58
+ "@thermal-label/transport": "^0.2.1",
57
59
  "usb": "^2.0.0",
58
- "@thermal-label/brother-ql-core": "0.0.1"
60
+ "@thermal-label/brother-ql-core": "0.3.0"
59
61
  },
60
62
  "optionalDependencies": {
61
63
  "@napi-rs/canvas": "^0.1.0"
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=errors.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/errors.test.ts"],"names":[],"mappings":""}
@@ -1,20 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { UnsupportedOperationError, PrinterError } from '../errors.js';
3
- describe('UnsupportedOperationError', () => {
4
- it('sets name and message', () => {
5
- const err = new UnsupportedOperationError('not supported');
6
- expect(err.name).toBe('UnsupportedOperationError');
7
- expect(err.message).toBe('not supported');
8
- expect(err).toBeInstanceOf(Error);
9
- });
10
- });
11
- describe('PrinterError', () => {
12
- it('sets name, message, and errors array', () => {
13
- const err = new PrinterError('printer failed', ['Cover open', 'No media']);
14
- expect(err.name).toBe('PrinterError');
15
- expect(err.message).toBe('printer failed');
16
- expect(err.errors).toEqual(['Cover open', 'No media']);
17
- expect(err).toBeInstanceOf(Error);
18
- });
19
- });
20
- //# sourceMappingURL=errors.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.test.js","sourceRoot":"","sources":["../../src/__tests__/errors.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEvE,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC/B,MAAM,GAAG,GAAG,IAAI,yBAAyB,CAAC,eAAe,CAAC,CAAC;QAC3D,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QACnD,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAC1C,MAAM,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,GAAG,GAAG,IAAI,YAAY,CAAC,gBAAgB,EAAE,CAAC,YAAY,EAAE,UAAU,CAAC,C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