@thermal-label/brother-ql-core 0.3.0 → 0.4.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 (54) hide show
  1. package/README.md +1 -1
  2. package/data/devices.json +823 -0
  3. package/data/media.json +823 -0
  4. package/dist/__tests__/devices.test.js +112 -31
  5. package/dist/__tests__/devices.test.js.map +1 -1
  6. package/dist/__tests__/media.test.js +251 -1
  7. package/dist/__tests__/media.test.js.map +1 -1
  8. package/dist/__tests__/protocol.test.js +168 -1
  9. package/dist/__tests__/protocol.test.js.map +1 -1
  10. package/dist/__tests__/status.test.js +71 -0
  11. package/dist/__tests__/status.test.js.map +1 -1
  12. package/dist/devices.d.ts +13 -270
  13. package/dist/devices.d.ts.map +1 -1
  14. package/dist/devices.generated.d.ts +696 -0
  15. package/dist/devices.generated.d.ts.map +1 -0
  16. package/dist/devices.generated.js +831 -0
  17. package/dist/devices.generated.js.map +1 -0
  18. package/dist/devices.js +28 -272
  19. package/dist/devices.js.map +1 -1
  20. package/dist/index.d.ts +6 -5
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +3 -3
  23. package/dist/index.js.map +1 -1
  24. package/dist/media.d.ts +37 -22
  25. package/dist/media.d.ts.map +1 -1
  26. package/dist/media.generated.d.ts +4 -0
  27. package/dist/media.generated.d.ts.map +1 -0
  28. package/dist/media.generated.js +1640 -0
  29. package/dist/media.generated.js.map +1 -0
  30. package/dist/media.js +74 -281
  31. package/dist/media.js.map +1 -1
  32. package/dist/protocol.d.ts +54 -3
  33. package/dist/protocol.d.ts.map +1 -1
  34. package/dist/protocol.js +117 -18
  35. package/dist/protocol.js.map +1 -1
  36. package/dist/status.d.ts +4 -1
  37. package/dist/status.d.ts.map +1 -1
  38. package/dist/status.js +6 -2
  39. package/dist/status.js.map +1 -1
  40. package/dist/types.d.ts +92 -27
  41. package/dist/types.d.ts.map +1 -1
  42. package/package.json +13 -9
  43. package/src/__tests__/devices.test.ts +122 -32
  44. package/src/__tests__/media.test.ts +287 -1
  45. package/src/__tests__/protocol.test.ts +209 -0
  46. package/src/__tests__/status.test.ts +87 -0
  47. package/src/devices.generated.ts +840 -0
  48. package/src/devices.ts +30 -272
  49. package/src/index.ts +20 -4
  50. package/src/media.generated.ts +1644 -0
  51. package/src/media.ts +86 -282
  52. package/src/protocol.ts +196 -18
  53. package/src/status.ts +10 -3
  54. package/src/types.ts +93 -27
package/src/devices.ts CHANGED
@@ -1,280 +1,38 @@
1
1
  import type { BrotherQLDevice } from './types.js';
2
+ import { DEVICES, DEVICE_REGISTRY } from './devices.generated.js';
2
3
 
3
- const MASS_STORAGE_PIDS = new Set([0x20aa, 0x20ab]);
4
+ // Mass-storage PIDs aligned to Linux usb-ids (gowdy.us / linux-usb.org).
5
+ // Each large-format printer with Editor Lite enumerates as USB Mass
6
+ // Storage Class on this alternate PID until the user holds the Editor
7
+ // Lite button to switch back to printer-class. Aggregated from each
8
+ // device entry's `capabilities.massStoragePid`.
9
+ const MASS_STORAGE_PIDS = new Set<number>(
10
+ Object.values(DEVICES).flatMap(d => {
11
+ const pid = d.capabilities?.massStoragePid;
12
+ return typeof pid === 'string' ? [parseInt(pid, 16)] : [];
13
+ }),
14
+ );
4
15
 
5
- export const DEVICES = {
6
- QL_820NWB: {
7
- name: 'QL-820NWB',
8
- family: 'brother-ql',
9
- transports: ['usb', 'webusb', 'tcp', 'serial', 'web-serial'],
10
- vid: 0x04f9,
11
- pid: 0x20a7,
12
- headPins: 720,
13
- bytesPerRow: 90,
14
- twoColor: true,
15
- network: 'wifi+wired',
16
- autocut: true,
17
- compression: true,
18
- editorLite: true,
19
- },
20
- QL_820NWBc: {
21
- name: 'QL-820NWBc',
22
- family: 'brother-ql',
23
- transports: ['usb', 'webusb', 'tcp', 'serial', 'web-serial'],
24
- vid: 0x04f9,
25
- pid: 0x209d,
26
- headPins: 720,
27
- bytesPerRow: 90,
28
- twoColor: true,
29
- network: 'wifi+wired',
30
- autocut: true,
31
- compression: true,
32
- editorLite: true,
33
- },
34
- QL_810W: {
35
- name: 'QL-810W',
36
- family: 'brother-ql',
37
- transports: ['usb', 'webusb', 'tcp'],
38
- vid: 0x04f9,
39
- pid: 0x209c,
40
- headPins: 720,
41
- bytesPerRow: 90,
42
- twoColor: true,
43
- network: 'wifi',
44
- autocut: true,
45
- compression: true,
46
- editorLite: true,
47
- },
48
- QL_800: {
49
- name: 'QL-800',
50
- family: 'brother-ql',
51
- transports: ['usb', 'webusb'],
52
- vid: 0x04f9,
53
- pid: 0x209b,
54
- headPins: 720,
55
- bytesPerRow: 90,
56
- twoColor: true,
57
- network: 'none',
58
- autocut: true,
59
- compression: true,
60
- editorLite: true,
61
- },
62
- QL_720NW: {
63
- name: 'QL-720NW',
64
- family: 'brother-ql',
65
- transports: ['usb', 'webusb', 'tcp'],
66
- vid: 0x04f9,
67
- pid: 0x2045,
68
- headPins: 720,
69
- bytesPerRow: 90,
70
- twoColor: false,
71
- network: 'wired',
72
- autocut: true,
73
- compression: true,
74
- editorLite: false,
75
- },
76
- QL_710W: {
77
- name: 'QL-710W',
78
- family: 'brother-ql',
79
- transports: ['usb', 'webusb', 'tcp'],
80
- vid: 0x04f9,
81
- pid: 0x2044,
82
- headPins: 720,
83
- bytesPerRow: 90,
84
- twoColor: false,
85
- network: 'wifi',
86
- autocut: true,
87
- compression: true,
88
- editorLite: true,
89
- },
90
- QL_700: {
91
- name: 'QL-700',
92
- family: 'brother-ql',
93
- transports: ['usb', 'webusb'],
94
- vid: 0x04f9,
95
- pid: 0x2042,
96
- headPins: 720,
97
- bytesPerRow: 90,
98
- twoColor: false,
99
- network: 'none',
100
- autocut: true,
101
- compression: true,
102
- editorLite: true,
103
- },
104
- QL_600: {
105
- name: 'QL-600',
106
- family: 'brother-ql',
107
- transports: ['usb', 'webusb'],
108
- vid: 0x04f9,
109
- pid: 0x2100,
110
- headPins: 720,
111
- bytesPerRow: 90,
112
- twoColor: false,
113
- network: 'none',
114
- autocut: true,
115
- compression: true,
116
- editorLite: false,
117
- },
118
- QL_580N: {
119
- name: 'QL-580N',
120
- family: 'brother-ql',
121
- transports: ['usb', 'webusb', 'tcp'],
122
- vid: 0x04f9,
123
- pid: 0x201b,
124
- headPins: 720,
125
- bytesPerRow: 90,
126
- twoColor: false,
127
- network: 'wired',
128
- autocut: true,
129
- compression: true,
130
- editorLite: false,
131
- },
132
- QL_570: {
133
- name: 'QL-570',
134
- family: 'brother-ql',
135
- transports: ['usb', 'webusb'],
136
- vid: 0x04f9,
137
- pid: 0x2019,
138
- headPins: 720,
139
- bytesPerRow: 90,
140
- twoColor: false,
141
- network: 'none',
142
- autocut: true,
143
- compression: true,
144
- editorLite: false,
145
- },
146
- QL_560: {
147
- name: 'QL-560',
148
- family: 'brother-ql',
149
- transports: ['usb', 'webusb'],
150
- vid: 0x04f9,
151
- pid: 0x2018,
152
- headPins: 720,
153
- bytesPerRow: 90,
154
- twoColor: false,
155
- network: 'none',
156
- autocut: true,
157
- compression: false,
158
- editorLite: false,
159
- },
160
- QL_550: {
161
- name: 'QL-550',
162
- family: 'brother-ql',
163
- transports: ['usb', 'webusb'],
164
- vid: 0x04f9,
165
- pid: 0x2016,
166
- headPins: 720,
167
- bytesPerRow: 90,
168
- twoColor: false,
169
- network: 'none',
170
- autocut: false,
171
- compression: false,
172
- editorLite: false,
173
- },
174
- QL_500: {
175
- name: 'QL-500',
176
- family: 'brother-ql',
177
- transports: ['usb', 'webusb'],
178
- vid: 0x04f9,
179
- pid: 0x2013,
180
- headPins: 720,
181
- bytesPerRow: 90,
182
- twoColor: false,
183
- network: 'none',
184
- autocut: false,
185
- compression: false,
186
- editorLite: false,
187
- },
188
- QL_650TD: {
189
- name: 'QL-650TD',
190
- family: 'brother-ql',
191
- transports: ['usb', 'webusb'],
192
- vid: 0x04f9,
193
- pid: 0x201c,
194
- headPins: 720,
195
- bytesPerRow: 90,
196
- twoColor: false,
197
- network: 'none',
198
- autocut: true,
199
- compression: true,
200
- editorLite: false,
201
- },
202
- QL_1100: {
203
- name: 'QL-1100',
204
- family: 'brother-ql',
205
- transports: ['usb', 'webusb'],
206
- vid: 0x04f9,
207
- pid: 0x20a8,
208
- headPins: 1296,
209
- bytesPerRow: 162,
210
- twoColor: false,
211
- network: 'none',
212
- autocut: true,
213
- compression: true,
214
- editorLite: true,
215
- massStoragePid: 0x20aa,
216
- },
217
- QL_1110NWB: {
218
- name: 'QL-1110NWB',
219
- family: 'brother-ql',
220
- transports: ['usb', 'webusb', 'tcp'],
221
- vid: 0x04f9,
222
- pid: 0x20a9,
223
- headPins: 1296,
224
- bytesPerRow: 162,
225
- twoColor: false,
226
- network: 'wifi+wired',
227
- autocut: true,
228
- compression: true,
229
- editorLite: true,
230
- massStoragePid: 0x20ab,
231
- },
232
- QL_1115NWB: {
233
- name: 'QL-1115NWB',
234
- family: 'brother-ql',
235
- transports: ['usb', 'webusb', 'tcp'],
236
- vid: 0x04f9,
237
- pid: 0x20ac,
238
- headPins: 1296,
239
- bytesPerRow: 162,
240
- twoColor: false,
241
- network: 'wifi+wired',
242
- autocut: true,
243
- compression: true,
244
- editorLite: true,
245
- },
246
- QL_1050: {
247
- name: 'QL-1050',
248
- family: 'brother-ql',
249
- transports: ['usb', 'webusb'],
250
- vid: 0x04f9,
251
- pid: 0x2027,
252
- headPins: 1296,
253
- bytesPerRow: 162,
254
- twoColor: false,
255
- network: 'none',
256
- autocut: true,
257
- compression: true,
258
- editorLite: false,
259
- },
260
- QL_1060N: {
261
- name: 'QL-1060N',
262
- family: 'brother-ql',
263
- transports: ['usb', 'webusb', 'tcp'],
264
- vid: 0x04f9,
265
- pid: 0x2028,
266
- headPins: 1296,
267
- bytesPerRow: 162,
268
- twoColor: false,
269
- network: 'wired',
270
- autocut: true,
271
- compression: true,
272
- editorLite: false,
273
- },
274
- } as const satisfies Record<string, BrotherQLDevice>;
16
+ export { DEVICE_REGISTRY, DEVICES };
17
+
18
+ /**
19
+ * Numeric VID/PID extracted from a device's USB transport.
20
+ *
21
+ * Returns `undefined` when the device has no USB transport. Hex
22
+ * strings on the registry (`'0x04f9'`) are parsed at this boundary so
23
+ * runtime callers stay numeric.
24
+ */
25
+ export function getUsbIds(device: BrotherQLDevice): { vid: number; pid: number } | undefined {
26
+ const usb = device.transports.usb;
27
+ if (!usb) return undefined;
28
+ return { vid: parseInt(usb.vid, 16), pid: parseInt(usb.pid, 16) };
29
+ }
275
30
 
276
31
  export function findDevice(vid: number, pid: number): BrotherQLDevice | undefined {
277
- return Object.values(DEVICES).find(d => d.vid === vid && d.pid === pid);
32
+ return Object.values(DEVICES).find(d => {
33
+ const ids = getUsbIds(d);
34
+ return ids?.vid === vid && ids.pid === pid;
35
+ });
278
36
  }
279
37
 
280
38
  export function isMassStorageMode(pid: number): boolean {
package/src/index.ts CHANGED
@@ -8,11 +8,15 @@ export {
8
8
  } from '@mbtech-nl/bitmap';
9
9
 
10
10
  export type {
11
- DeviceDescriptor,
11
+ DeviceEntry,
12
+ DeviceRegistry,
13
+ DeviceTransports,
12
14
  MediaDescriptor,
13
15
  PreviewOptions,
14
16
  PreviewPlane,
15
17
  PreviewResult,
18
+ PrintEngine,
19
+ PrintEngineCapabilities,
16
20
  PrintOptions,
17
21
  PrinterAdapter,
18
22
  PrinterError,
@@ -20,6 +24,7 @@ export type {
20
24
  RotateDirection,
21
25
  Transport,
22
26
  TransportType,
27
+ UsbTransport,
23
28
  } from '@thermal-label/contracts';
24
29
 
25
30
  export {
@@ -28,20 +33,30 @@ export {
28
33
  UnsupportedOperationError,
29
34
  } from '@thermal-label/contracts';
30
35
 
31
- export { DEVICES, findDevice, isMassStorageMode } from './devices.js';
36
+ export { DEVICE_REGISTRY, DEVICES, findDevice, getUsbIds, isMassStorageMode } from './devices.js';
32
37
  export {
33
38
  DEFAULT_MEDIA,
39
+ DEFAULT_PT_MEDIA,
34
40
  MEDIA,
41
+ defaultMediaForEngine,
35
42
  findMedia,
36
43
  findMediaByDimensions,
37
44
  findMediaByWidth,
45
+ resolveTapeGeometry,
38
46
  } from './media.js';
39
47
  export { ROTATE_DIRECTION } from './orientation.js';
40
- export { encodeJob } from './protocol.js';
48
+ export {
49
+ encodeJob,
50
+ encodeJobForEngine,
51
+ PT_PROTOCOL_CONFIG,
52
+ QL_PROTOCOL_CONFIG,
53
+ } from './protocol.js';
54
+ export type { EncoderEngine, RasterProtocolConfig } from './protocol.js';
41
55
  export { parseStatus, STATUS_REQUEST } from './status.js';
42
56
  export { createPreviewOffline } from './preview.js';
43
57
 
44
58
  export type {
59
+ BrotherEngineCapabilities,
45
60
  BrotherQLDevice,
46
61
  BrotherQLMedia,
47
62
  BrotherQLPrintOptions,
@@ -50,7 +65,8 @@ export type {
50
65
  HeadWidth,
51
66
  JobOptions,
52
67
  MediaType,
53
- NetworkSupport,
54
68
  PageData,
55
69
  PageOptions,
70
+ TapeGeometry,
71
+ TapeSystem,
56
72
  } from './types.js';