@thermal-label/brother-ql-core 0.3.0 → 0.5.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.
- package/README.md +1 -1
- package/data/devices.json +823 -0
- package/data/media.json +823 -0
- package/dist/__tests__/devices.test.js +112 -31
- package/dist/__tests__/devices.test.js.map +1 -1
- package/dist/__tests__/media.test.js +251 -1
- package/dist/__tests__/media.test.js.map +1 -1
- package/dist/__tests__/protocol.test.js +168 -1
- package/dist/__tests__/protocol.test.js.map +1 -1
- package/dist/__tests__/status.test.js +71 -0
- package/dist/__tests__/status.test.js.map +1 -1
- package/dist/devices.d.ts +13 -270
- package/dist/devices.d.ts.map +1 -1
- package/dist/devices.generated.d.ts +696 -0
- package/dist/devices.generated.d.ts.map +1 -0
- package/dist/devices.generated.js +831 -0
- package/dist/devices.generated.js.map +1 -0
- package/dist/devices.js +28 -272
- package/dist/devices.js.map +1 -1
- package/dist/index.d.ts +13 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/dist/media.d.ts +37 -22
- package/dist/media.d.ts.map +1 -1
- package/dist/media.generated.d.ts +4 -0
- package/dist/media.generated.d.ts.map +1 -0
- package/dist/media.generated.js +1640 -0
- package/dist/media.generated.js.map +1 -0
- package/dist/media.js +74 -281
- package/dist/media.js.map +1 -1
- package/dist/protocol.d.ts +54 -3
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +117 -18
- package/dist/protocol.js.map +1 -1
- package/dist/status.d.ts +4 -1
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +6 -2
- package/dist/status.js.map +1 -1
- package/dist/types.d.ts +92 -27
- package/dist/types.d.ts.map +1 -1
- package/package.json +13 -9
- package/src/__tests__/devices.test.ts +122 -32
- package/src/__tests__/media.test.ts +287 -1
- package/src/__tests__/protocol.test.ts +209 -0
- package/src/__tests__/status.test.ts +87 -0
- package/src/devices.generated.ts +840 -0
- package/src/devices.ts +30 -272
- package/src/index.ts +28 -4
- package/src/media.generated.ts +1644 -0
- package/src/media.ts +86 -282
- package/src/protocol.ts +196 -18
- package/src/status.ts +10 -3
- 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
|
-
|
|
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
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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 =>
|
|
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
|
-
|
|
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,38 @@ 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';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Protocols this core's encoder produces correct wire bytes for.
|
|
40
|
+
* Pair with `DEVICE_REGISTRY` and pass to `resolveSupportedDevices`
|
|
41
|
+
* from `@thermal-label/contracts` to filter a device list down to
|
|
42
|
+
* what this runtime can actually drive.
|
|
43
|
+
*/
|
|
44
|
+
export const PROTOCOLS: ReadonlySet<string> = new Set(['ql-raster', 'pt-raster']);
|
|
32
45
|
export {
|
|
33
46
|
DEFAULT_MEDIA,
|
|
47
|
+
DEFAULT_PT_MEDIA,
|
|
34
48
|
MEDIA,
|
|
49
|
+
defaultMediaForEngine,
|
|
35
50
|
findMedia,
|
|
36
51
|
findMediaByDimensions,
|
|
37
52
|
findMediaByWidth,
|
|
53
|
+
resolveTapeGeometry,
|
|
38
54
|
} from './media.js';
|
|
39
55
|
export { ROTATE_DIRECTION } from './orientation.js';
|
|
40
|
-
export {
|
|
56
|
+
export {
|
|
57
|
+
encodeJob,
|
|
58
|
+
encodeJobForEngine,
|
|
59
|
+
PT_PROTOCOL_CONFIG,
|
|
60
|
+
QL_PROTOCOL_CONFIG,
|
|
61
|
+
} from './protocol.js';
|
|
62
|
+
export type { EncoderEngine, RasterProtocolConfig } from './protocol.js';
|
|
41
63
|
export { parseStatus, STATUS_REQUEST } from './status.js';
|
|
42
64
|
export { createPreviewOffline } from './preview.js';
|
|
43
65
|
|
|
44
66
|
export type {
|
|
67
|
+
BrotherEngineCapabilities,
|
|
45
68
|
BrotherQLDevice,
|
|
46
69
|
BrotherQLMedia,
|
|
47
70
|
BrotherQLPrintOptions,
|
|
@@ -50,7 +73,8 @@ export type {
|
|
|
50
73
|
HeadWidth,
|
|
51
74
|
JobOptions,
|
|
52
75
|
MediaType,
|
|
53
|
-
NetworkSupport,
|
|
54
76
|
PageData,
|
|
55
77
|
PageOptions,
|
|
78
|
+
TapeGeometry,
|
|
79
|
+
TapeSystem,
|
|
56
80
|
} from './types.js';
|