@thermal-label/brother-ql-core 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 (68) hide show
  1. package/dist/__tests__/devices.test.js +16 -2
  2. package/dist/__tests__/devices.test.js.map +1 -1
  3. package/dist/__tests__/media.test.js +37 -6
  4. package/dist/__tests__/media.test.js.map +1 -1
  5. package/dist/__tests__/pack-bits.test.d.ts +2 -0
  6. package/dist/__tests__/pack-bits.test.d.ts.map +1 -0
  7. package/dist/__tests__/pack-bits.test.js +90 -0
  8. package/dist/__tests__/pack-bits.test.js.map +1 -0
  9. package/dist/__tests__/preview.test.d.ts +2 -0
  10. package/dist/__tests__/preview.test.d.ts.map +1 -0
  11. package/dist/__tests__/preview.test.js +41 -0
  12. package/dist/__tests__/preview.test.js.map +1 -0
  13. package/dist/__tests__/protocol.test.js +46 -1
  14. package/dist/__tests__/protocol.test.js.map +1 -1
  15. package/dist/__tests__/status.test.js +28 -22
  16. package/dist/__tests__/status.test.js.map +1 -1
  17. package/dist/devices.d.ts +40 -21
  18. package/dist/devices.d.ts.map +1 -1
  19. package/dist/devices.js +38 -20
  20. package/dist/devices.js.map +1 -1
  21. package/dist/index.d.ts +8 -4
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +5 -2
  24. package/dist/index.js.map +1 -1
  25. package/dist/media.d.ts +43 -4
  26. package/dist/media.d.ts.map +1 -1
  27. package/dist/media.js +92 -24
  28. package/dist/media.js.map +1 -1
  29. package/dist/orientation.d.ts +11 -0
  30. package/dist/orientation.d.ts.map +1 -0
  31. package/dist/orientation.js +10 -0
  32. package/dist/orientation.js.map +1 -0
  33. package/dist/pack-bits.d.ts +20 -0
  34. package/dist/pack-bits.d.ts.map +1 -0
  35. package/dist/pack-bits.js +61 -0
  36. package/dist/pack-bits.js.map +1 -0
  37. package/dist/preview.d.ts +13 -0
  38. package/dist/preview.d.ts.map +1 -0
  39. package/dist/preview.js +31 -0
  40. package/dist/preview.js.map +1 -0
  41. package/dist/protocol.d.ts +2 -2
  42. package/dist/protocol.d.ts.map +1 -1
  43. package/dist/protocol.js +14 -8
  44. package/dist/protocol.js.map +1 -1
  45. package/dist/status.d.ts +20 -2
  46. package/dist/status.d.ts.map +1 -1
  47. package/dist/status.js +59 -45
  48. package/dist/status.js.map +1 -1
  49. package/dist/types.d.ts +46 -30
  50. package/dist/types.d.ts.map +1 -1
  51. package/dist/types.js +1 -1
  52. package/dist/types.js.map +1 -1
  53. package/package.json +3 -2
  54. package/src/__tests__/devices.test.ts +18 -2
  55. package/src/__tests__/media.test.ts +39 -6
  56. package/src/__tests__/pack-bits.test.ts +92 -0
  57. package/src/__tests__/preview.test.ts +52 -0
  58. package/src/__tests__/protocol.test.ts +47 -1
  59. package/src/__tests__/status.test.ts +31 -22
  60. package/src/devices.ts +41 -22
  61. package/src/index.ts +45 -11
  62. package/src/media.ts +105 -27
  63. package/src/orientation.ts +11 -0
  64. package/src/pack-bits.ts +64 -0
  65. package/src/preview.ts +35 -0
  66. package/src/protocol.ts +16 -9
  67. package/src/status.ts +62 -47
  68. package/src/types.ts +52 -32
package/src/types.ts CHANGED
@@ -1,43 +1,74 @@
1
- import { type LabelBitmap } from '@mbtech-nl/bitmap';
1
+ import type { LabelBitmap } from '@mbtech-nl/bitmap';
2
+ import type {
3
+ DeviceDescriptor,
4
+ MediaDescriptor,
5
+ PrintOptions,
6
+ PrinterStatus,
7
+ } from '@thermal-label/contracts';
2
8
 
3
9
  export type MediaType = 'continuous' | 'die-cut';
4
10
  export type HeadWidth = 720 | 1296;
5
11
  export type ColorMode = 'single' | 'two-color';
6
12
  export type NetworkSupport = 'none' | 'wifi' | 'wired' | 'wifi+wired';
7
13
 
8
- export interface DeviceDescriptor {
9
- name: string;
14
+ /**
15
+ * Brother QL device descriptor.
16
+ *
17
+ * Extends the contracts base with QL-specific fields: head geometry,
18
+ * protocol feature flags, and the optional mass-storage PID for Editor
19
+ * Lite mode.
20
+ *
21
+ * **Bluetooth on the QL-820NWB / 820NWBc**: not exposed over GATT.
22
+ * Classic Bluetooth (SPP) is paired at the OS level; the kernel/driver
23
+ * exposes an RFCOMM serial port, reachable via the `'serial'` transport
24
+ * in Node.js and the `'web-serial'` transport in Chrome/Edge. macOS has
25
+ * dropped classic Bluetooth SPP — no serial route there.
26
+ */
27
+ export interface BrotherQLDevice extends DeviceDescriptor {
28
+ family: 'brother-ql';
10
29
  vid: number;
11
30
  pid: number;
12
31
  headPins: HeadWidth;
13
32
  bytesPerRow: number;
14
33
  twoColor: boolean;
15
34
  network: NetworkSupport;
16
- bluetooth: boolean;
17
35
  autocut: boolean;
18
36
  compression: boolean;
19
37
  editorLite: boolean;
38
+ /** Alternate PID seen when the printer is in Editor Lite mass-storage mode. */
20
39
  massStoragePid?: number;
21
40
  }
22
41
 
23
- export interface MediaDescriptor {
42
+ /**
43
+ * Brother QL media descriptor.
44
+ *
45
+ * Extends `MediaDescriptor` with the dots-based geometry the raster
46
+ * encoder needs. The base `palette` field flips the driver into
47
+ * multi-plane mode — only DK-22251 declares one in the registry.
48
+ */
49
+ export interface BrotherQLMedia extends MediaDescriptor {
24
50
  id: number;
25
- name: string;
26
51
  type: MediaType;
27
- widthMm: number;
28
- lengthMm: number;
29
52
  printAreaDots: number;
30
53
  leftMarginPins: number;
31
54
  rightMarginPins: number;
55
+ /** Die-cut masked area in dots (registration windows). */
32
56
  dieCutMaskedAreaDots?: number;
33
- /** True for DK-22251 and similar two-color tapes — printer rejects single-color jobs */
34
- twoColorTape?: boolean;
57
+ }
58
+
59
+ /**
60
+ * Brother QL status — contracts `PrinterStatus` plus the
61
+ * `editorLiteMode` flag (pre-paired QL-820NWB silently drops raster
62
+ * jobs when in Editor Lite mode; callers need to know).
63
+ */
64
+ export interface BrotherQLStatus extends PrinterStatus {
65
+ editorLiteMode: boolean;
35
66
  }
36
67
 
37
68
  export interface PageData {
38
69
  bitmap: LabelBitmap;
39
70
  redBitmap?: LabelBitmap;
40
- media: MediaDescriptor;
71
+ media: BrotherQLMedia;
41
72
  options?: PageOptions;
42
73
  }
43
74
 
@@ -53,25 +84,14 @@ export interface JobOptions {
53
84
  copies?: number;
54
85
  }
55
86
 
56
- export interface TextPrintOptions extends PageOptions {
57
- invert?: boolean;
58
- scaleX?: number;
59
- scaleY?: number;
60
- }
61
-
62
- export interface ImagePrintOptions extends PageOptions {
63
- threshold?: number;
64
- dither?: boolean;
65
- invert?: boolean;
66
- rotate?: 0 | 90 | 180 | 270;
67
- }
68
-
69
- export interface PrinterStatus {
70
- ready: boolean;
71
- mediaWidthMm: number;
72
- mediaLengthMm: number;
73
- mediaType: MediaType | null;
74
- errors: string[];
75
- editorLiteMode: boolean;
76
- rawBytes: Uint8Array;
87
+ /**
88
+ * Per-call print options for `BrotherQLPrinter.print()`.
89
+ *
90
+ * Extends the cross-driver `PrintOptions` with QL-specific knobs. The
91
+ * `rotate` override picks the rotation angle passed to
92
+ * `renderImage` / `renderMultiPlaneImage` — `'auto'` (the default)
93
+ * defers to the media's `defaultOrientation` heuristic.
94
+ */
95
+ export interface BrotherQLPrintOptions extends PrintOptions {
96
+ rotate?: 'auto' | 0 | 90 | 180 | 270;
77
97
  }