@thermal-label/brother-ql-core 0.0.1

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 (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +23 -0
  3. package/dist/__tests__/devices.test.d.ts +2 -0
  4. package/dist/__tests__/devices.test.d.ts.map +1 -0
  5. package/dist/__tests__/devices.test.js +63 -0
  6. package/dist/__tests__/devices.test.js.map +1 -0
  7. package/dist/__tests__/media.test.d.ts +2 -0
  8. package/dist/__tests__/media.test.d.ts.map +1 -0
  9. package/dist/__tests__/media.test.js +62 -0
  10. package/dist/__tests__/media.test.js.map +1 -0
  11. package/dist/__tests__/protocol.test.d.ts +2 -0
  12. package/dist/__tests__/protocol.test.d.ts.map +1 -0
  13. package/dist/__tests__/protocol.test.js +202 -0
  14. package/dist/__tests__/protocol.test.js.map +1 -0
  15. package/dist/__tests__/status.test.d.ts +2 -0
  16. package/dist/__tests__/status.test.d.ts.map +1 -0
  17. package/dist/__tests__/status.test.js +74 -0
  18. package/dist/__tests__/status.test.js.map +1 -0
  19. package/dist/devices.d.ts +255 -0
  20. package/dist/devices.d.ts.map +1 -0
  21. package/dist/devices.js +260 -0
  22. package/dist/devices.js.map +1 -0
  23. package/dist/index.d.ts +8 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +6 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/media.d.ts +5 -0
  28. package/dist/media.d.ts.map +1 -0
  29. package/dist/media.js +247 -0
  30. package/dist/media.js.map +1 -0
  31. package/dist/protocol.d.ts +17 -0
  32. package/dist/protocol.d.ts.map +1 -0
  33. package/dist/protocol.js +173 -0
  34. package/dist/protocol.js.map +1 -0
  35. package/dist/status.d.ts +4 -0
  36. package/dist/status.d.ts.map +1 -0
  37. package/dist/status.js +61 -0
  38. package/dist/status.js.map +1 -0
  39. package/dist/types.d.ts +69 -0
  40. package/dist/types.d.ts.map +1 -0
  41. package/dist/types.js +2 -0
  42. package/dist/types.js.map +1 -0
  43. package/package.json +71 -0
  44. package/src/__tests__/devices.test.ts +73 -0
  45. package/src/__tests__/media.test.ts +70 -0
  46. package/src/__tests__/protocol.test.ts +241 -0
  47. package/src/__tests__/status.test.ts +95 -0
  48. package/src/devices.ts +263 -0
  49. package/src/index.ts +22 -0
  50. package/src/media.ts +250 -0
  51. package/src/protocol.ts +213 -0
  52. package/src/status.ts +67 -0
  53. package/src/types.ts +77 -0
package/src/devices.ts ADDED
@@ -0,0 +1,263 @@
1
+ import { type DeviceDescriptor } from './types.js';
2
+
3
+ const MASS_STORAGE_PIDS = new Set([0x20aa, 0x20ab]);
4
+
5
+ export const DEVICES = {
6
+ QL_820NWB: {
7
+ name: 'QL-820NWB',
8
+ vid: 0x04f9,
9
+ pid: 0x20a7,
10
+ headPins: 720,
11
+ bytesPerRow: 90,
12
+ twoColor: true,
13
+ network: 'wifi+wired',
14
+ bluetooth: false,
15
+ autocut: true,
16
+ compression: true,
17
+ editorLite: true,
18
+ },
19
+ QL_820NWBc: {
20
+ name: 'QL-820NWBc',
21
+ vid: 0x04f9,
22
+ pid: 0x209d,
23
+ headPins: 720,
24
+ bytesPerRow: 90,
25
+ twoColor: true,
26
+ network: 'wifi+wired',
27
+ bluetooth: false,
28
+ autocut: true,
29
+ compression: true,
30
+ editorLite: true,
31
+ },
32
+ QL_810W: {
33
+ name: 'QL-810W',
34
+ vid: 0x04f9,
35
+ pid: 0x209c,
36
+ headPins: 720,
37
+ bytesPerRow: 90,
38
+ twoColor: true,
39
+ network: 'wifi',
40
+ bluetooth: false,
41
+ autocut: true,
42
+ compression: true,
43
+ editorLite: true,
44
+ },
45
+ QL_800: {
46
+ name: 'QL-800',
47
+ vid: 0x04f9,
48
+ pid: 0x209b,
49
+ headPins: 720,
50
+ bytesPerRow: 90,
51
+ twoColor: true,
52
+ network: 'none',
53
+ bluetooth: false,
54
+ autocut: true,
55
+ compression: true,
56
+ editorLite: true,
57
+ },
58
+ QL_720NW: {
59
+ name: 'QL-720NW',
60
+ vid: 0x04f9,
61
+ pid: 0x2045,
62
+ headPins: 720,
63
+ bytesPerRow: 90,
64
+ twoColor: false,
65
+ network: 'wired',
66
+ bluetooth: false,
67
+ autocut: true,
68
+ compression: true,
69
+ editorLite: false,
70
+ },
71
+ QL_710W: {
72
+ name: 'QL-710W',
73
+ vid: 0x04f9,
74
+ pid: 0x2044,
75
+ headPins: 720,
76
+ bytesPerRow: 90,
77
+ twoColor: false,
78
+ network: 'wifi',
79
+ bluetooth: false,
80
+ autocut: true,
81
+ compression: true,
82
+ editorLite: true,
83
+ },
84
+ QL_700: {
85
+ name: 'QL-700',
86
+ vid: 0x04f9,
87
+ pid: 0x2042,
88
+ headPins: 720,
89
+ bytesPerRow: 90,
90
+ twoColor: false,
91
+ network: 'none',
92
+ bluetooth: false,
93
+ autocut: true,
94
+ compression: true,
95
+ editorLite: true,
96
+ },
97
+ QL_600: {
98
+ name: 'QL-600',
99
+ vid: 0x04f9,
100
+ pid: 0x2100,
101
+ headPins: 720,
102
+ bytesPerRow: 90,
103
+ twoColor: false,
104
+ network: 'none',
105
+ bluetooth: false,
106
+ autocut: true,
107
+ compression: true,
108
+ editorLite: false,
109
+ },
110
+ QL_580N: {
111
+ name: 'QL-580N',
112
+ vid: 0x04f9,
113
+ pid: 0x201b,
114
+ headPins: 720,
115
+ bytesPerRow: 90,
116
+ twoColor: false,
117
+ network: 'wired',
118
+ bluetooth: false,
119
+ autocut: true,
120
+ compression: true,
121
+ editorLite: false,
122
+ },
123
+ QL_570: {
124
+ name: 'QL-570',
125
+ vid: 0x04f9,
126
+ pid: 0x2019,
127
+ headPins: 720,
128
+ bytesPerRow: 90,
129
+ twoColor: false,
130
+ network: 'none',
131
+ bluetooth: false,
132
+ autocut: true,
133
+ compression: true,
134
+ editorLite: false,
135
+ },
136
+ QL_560: {
137
+ name: 'QL-560',
138
+ vid: 0x04f9,
139
+ pid: 0x2018,
140
+ headPins: 720,
141
+ bytesPerRow: 90,
142
+ twoColor: false,
143
+ network: 'none',
144
+ bluetooth: false,
145
+ autocut: true,
146
+ compression: false,
147
+ editorLite: false,
148
+ },
149
+ QL_550: {
150
+ name: 'QL-550',
151
+ vid: 0x04f9,
152
+ pid: 0x2016,
153
+ headPins: 720,
154
+ bytesPerRow: 90,
155
+ twoColor: false,
156
+ network: 'none',
157
+ bluetooth: false,
158
+ autocut: false,
159
+ compression: false,
160
+ editorLite: false,
161
+ },
162
+ QL_500: {
163
+ name: 'QL-500',
164
+ vid: 0x04f9,
165
+ pid: 0x2013,
166
+ headPins: 720,
167
+ bytesPerRow: 90,
168
+ twoColor: false,
169
+ network: 'none',
170
+ bluetooth: false,
171
+ autocut: false,
172
+ compression: false,
173
+ editorLite: false,
174
+ },
175
+ QL_650TD: {
176
+ name: 'QL-650TD',
177
+ vid: 0x04f9,
178
+ pid: 0x201c,
179
+ headPins: 720,
180
+ bytesPerRow: 90,
181
+ twoColor: false,
182
+ network: 'none',
183
+ bluetooth: false,
184
+ autocut: true,
185
+ compression: true,
186
+ editorLite: false,
187
+ },
188
+ QL_1100: {
189
+ name: 'QL-1100',
190
+ vid: 0x04f9,
191
+ pid: 0x20a8,
192
+ headPins: 1296,
193
+ bytesPerRow: 162,
194
+ twoColor: false,
195
+ network: 'none',
196
+ bluetooth: false,
197
+ autocut: true,
198
+ compression: true,
199
+ editorLite: true,
200
+ massStoragePid: 0x20aa,
201
+ },
202
+ QL_1110NWB: {
203
+ name: 'QL-1110NWB',
204
+ vid: 0x04f9,
205
+ pid: 0x20a9,
206
+ headPins: 1296,
207
+ bytesPerRow: 162,
208
+ twoColor: false,
209
+ network: 'wifi+wired',
210
+ bluetooth: false,
211
+ autocut: true,
212
+ compression: true,
213
+ editorLite: true,
214
+ massStoragePid: 0x20ab,
215
+ },
216
+ QL_1115NWB: {
217
+ name: 'QL-1115NWB',
218
+ vid: 0x04f9,
219
+ pid: 0x20ac,
220
+ headPins: 1296,
221
+ bytesPerRow: 162,
222
+ twoColor: false,
223
+ network: 'wifi+wired',
224
+ bluetooth: false,
225
+ autocut: true,
226
+ compression: true,
227
+ editorLite: true,
228
+ },
229
+ QL_1050: {
230
+ name: 'QL-1050',
231
+ vid: 0x04f9,
232
+ pid: 0x2027,
233
+ headPins: 1296,
234
+ bytesPerRow: 162,
235
+ twoColor: false,
236
+ network: 'none',
237
+ bluetooth: false,
238
+ autocut: true,
239
+ compression: true,
240
+ editorLite: false,
241
+ },
242
+ QL_1060N: {
243
+ name: 'QL-1060N',
244
+ vid: 0x04f9,
245
+ pid: 0x2028,
246
+ headPins: 1296,
247
+ bytesPerRow: 162,
248
+ twoColor: false,
249
+ network: 'wired',
250
+ bluetooth: false,
251
+ autocut: true,
252
+ compression: true,
253
+ editorLite: false,
254
+ },
255
+ } as const satisfies Record<string, DeviceDescriptor>;
256
+
257
+ export function findDevice(vid: number, pid: number): DeviceDescriptor | undefined {
258
+ return Object.values(DEVICES).find(d => d.vid === vid && d.pid === pid);
259
+ }
260
+
261
+ export function isMassStorageMode(pid: number): boolean {
262
+ return MASS_STORAGE_PIDS.has(pid);
263
+ }
package/src/index.ts ADDED
@@ -0,0 +1,22 @@
1
+ export type { LabelBitmap, RawImageData } from '@mbtech-nl/bitmap';
2
+ export { renderText, renderImage, rotateBitmap, flipHorizontal } from '@mbtech-nl/bitmap';
3
+
4
+ export { DEVICES, findDevice, isMassStorageMode } from './devices.js';
5
+ export { MEDIA, findMedia, findMediaByWidth } from './media.js';
6
+ export { encodeJob } from './protocol.js';
7
+ export { parseStatus, STATUS_REQUEST } from './status.js';
8
+
9
+ export type {
10
+ MediaType,
11
+ HeadWidth,
12
+ ColorMode,
13
+ NetworkSupport,
14
+ DeviceDescriptor,
15
+ MediaDescriptor,
16
+ PageData,
17
+ PageOptions,
18
+ JobOptions,
19
+ PrinterStatus,
20
+ TextPrintOptions,
21
+ ImagePrintOptions,
22
+ } from './types.js';
package/src/media.ts ADDED
@@ -0,0 +1,250 @@
1
+ import { type MediaDescriptor, type MediaType } from './types.js';
2
+
3
+ export const MEDIA: Record<number, MediaDescriptor> = {
4
+ // Continuous length tape
5
+ 257: {
6
+ id: 257,
7
+ name: '12mm continuous',
8
+ type: 'continuous',
9
+ widthMm: 12,
10
+ lengthMm: 0,
11
+ printAreaDots: 106,
12
+ leftMarginPins: 585,
13
+ rightMarginPins: 29,
14
+ },
15
+ 258: {
16
+ id: 258,
17
+ name: '29mm continuous (DK-22210)',
18
+ type: 'continuous',
19
+ widthMm: 29,
20
+ lengthMm: 0,
21
+ printAreaDots: 306,
22
+ leftMarginPins: 408,
23
+ rightMarginPins: 6,
24
+ },
25
+ 264: {
26
+ id: 264,
27
+ name: '38mm continuous (DK-22225)',
28
+ type: 'continuous',
29
+ widthMm: 38,
30
+ lengthMm: 0,
31
+ printAreaDots: 413,
32
+ leftMarginPins: 295,
33
+ rightMarginPins: 12,
34
+ },
35
+ 262: {
36
+ id: 262,
37
+ name: '50mm continuous (DK-22246)',
38
+ type: 'continuous',
39
+ widthMm: 50,
40
+ lengthMm: 0,
41
+ printAreaDots: 554,
42
+ leftMarginPins: 154,
43
+ rightMarginPins: 12,
44
+ },
45
+ 261: {
46
+ id: 261,
47
+ name: '54mm continuous (DK-22214)',
48
+ type: 'continuous',
49
+ widthMm: 54,
50
+ lengthMm: 0,
51
+ printAreaDots: 590,
52
+ leftMarginPins: 130,
53
+ rightMarginPins: 0,
54
+ },
55
+ 259: {
56
+ id: 259,
57
+ name: '62mm continuous (DK-22205)',
58
+ type: 'continuous',
59
+ widthMm: 62,
60
+ lengthMm: 0,
61
+ printAreaDots: 696,
62
+ leftMarginPins: 12,
63
+ rightMarginPins: 12,
64
+ },
65
+ 251: {
66
+ id: 251,
67
+ name: '62mm continuous two-color (DK-22251)',
68
+ type: 'continuous',
69
+ widthMm: 62,
70
+ lengthMm: 0,
71
+ printAreaDots: 696,
72
+ leftMarginPins: 12,
73
+ rightMarginPins: 12,
74
+ twoColorTape: true,
75
+ },
76
+ 260: {
77
+ id: 260,
78
+ name: '102mm continuous (DK-22243)',
79
+ type: 'continuous',
80
+ widthMm: 102,
81
+ lengthMm: 0,
82
+ printAreaDots: 1164,
83
+ leftMarginPins: 76,
84
+ rightMarginPins: 56,
85
+ },
86
+
87
+ // Die-cut labels
88
+ 269: {
89
+ id: 269,
90
+ name: '17×54mm die-cut (DK-11204)',
91
+ type: 'die-cut',
92
+ widthMm: 17,
93
+ lengthMm: 54,
94
+ printAreaDots: 165,
95
+ leftMarginPins: 0,
96
+ rightMarginPins: 0,
97
+ dieCutMaskedAreaDots: 566,
98
+ },
99
+ 270: {
100
+ id: 270,
101
+ name: '17×87mm die-cut (DK-11203)',
102
+ type: 'die-cut',
103
+ widthMm: 17,
104
+ lengthMm: 87,
105
+ printAreaDots: 165,
106
+ leftMarginPins: 0,
107
+ rightMarginPins: 0,
108
+ dieCutMaskedAreaDots: 956,
109
+ },
110
+ 370: {
111
+ id: 370,
112
+ name: '23×23mm die-cut',
113
+ type: 'die-cut',
114
+ widthMm: 23,
115
+ lengthMm: 23,
116
+ printAreaDots: 236,
117
+ leftMarginPins: 0,
118
+ rightMarginPins: 0,
119
+ dieCutMaskedAreaDots: 202,
120
+ },
121
+ 271: {
122
+ id: 271,
123
+ name: '29×90mm die-cut (DK-11201)',
124
+ type: 'die-cut',
125
+ widthMm: 29,
126
+ lengthMm: 90,
127
+ printAreaDots: 306,
128
+ leftMarginPins: 0,
129
+ rightMarginPins: 0,
130
+ dieCutMaskedAreaDots: 991,
131
+ },
132
+ 272: {
133
+ id: 272,
134
+ name: '38×90mm die-cut (DK-11218)',
135
+ type: 'die-cut',
136
+ widthMm: 38,
137
+ lengthMm: 90,
138
+ printAreaDots: 413,
139
+ leftMarginPins: 0,
140
+ rightMarginPins: 0,
141
+ dieCutMaskedAreaDots: 991,
142
+ },
143
+ 367: {
144
+ id: 367,
145
+ name: '39×48mm die-cut (DK-11219)',
146
+ type: 'die-cut',
147
+ widthMm: 39,
148
+ lengthMm: 48,
149
+ printAreaDots: 425,
150
+ leftMarginPins: 0,
151
+ rightMarginPins: 0,
152
+ dieCutMaskedAreaDots: 495,
153
+ },
154
+ 374: {
155
+ id: 374,
156
+ name: '52×29mm die-cut',
157
+ type: 'die-cut',
158
+ widthMm: 52,
159
+ lengthMm: 29,
160
+ printAreaDots: 578,
161
+ leftMarginPins: 0,
162
+ rightMarginPins: 0,
163
+ dieCutMaskedAreaDots: 271,
164
+ },
165
+ 274: {
166
+ id: 274,
167
+ name: '62×29mm die-cut (DK-11209)',
168
+ type: 'die-cut',
169
+ widthMm: 62,
170
+ lengthMm: 29,
171
+ printAreaDots: 696,
172
+ leftMarginPins: 0,
173
+ rightMarginPins: 0,
174
+ dieCutMaskedAreaDots: 271,
175
+ },
176
+ 275: {
177
+ id: 275,
178
+ name: '62×100mm die-cut (DK-11202)',
179
+ type: 'die-cut',
180
+ widthMm: 62,
181
+ lengthMm: 100,
182
+ printAreaDots: 696,
183
+ leftMarginPins: 0,
184
+ rightMarginPins: 0,
185
+ dieCutMaskedAreaDots: 1109,
186
+ },
187
+ 365: {
188
+ id: 365,
189
+ name: '102×51mm die-cut (DK-11240)',
190
+ type: 'die-cut',
191
+ widthMm: 102,
192
+ lengthMm: 51,
193
+ printAreaDots: 1164,
194
+ leftMarginPins: 0,
195
+ rightMarginPins: 0,
196
+ dieCutMaskedAreaDots: 526,
197
+ },
198
+ 366: {
199
+ id: 366,
200
+ name: '102×152mm die-cut (DK-11241)',
201
+ type: 'die-cut',
202
+ widthMm: 102,
203
+ lengthMm: 152,
204
+ printAreaDots: 1164,
205
+ leftMarginPins: 0,
206
+ rightMarginPins: 0,
207
+ dieCutMaskedAreaDots: 1660,
208
+ },
209
+ 362: {
210
+ id: 362,
211
+ name: '12mm Ø die-cut',
212
+ type: 'die-cut',
213
+ widthMm: 12,
214
+ lengthMm: 12,
215
+ printAreaDots: 94,
216
+ leftMarginPins: 0,
217
+ rightMarginPins: 0,
218
+ dieCutMaskedAreaDots: 94,
219
+ },
220
+ 363: {
221
+ id: 363,
222
+ name: '24mm Ø die-cut (DK-11221)',
223
+ type: 'die-cut',
224
+ widthMm: 24,
225
+ lengthMm: 24,
226
+ printAreaDots: 236,
227
+ leftMarginPins: 0,
228
+ rightMarginPins: 0,
229
+ dieCutMaskedAreaDots: 236,
230
+ },
231
+ 273: {
232
+ id: 273,
233
+ name: '58mm Ø die-cut (DK-11207)',
234
+ type: 'die-cut',
235
+ widthMm: 58,
236
+ lengthMm: 58,
237
+ printAreaDots: 618,
238
+ leftMarginPins: 0,
239
+ rightMarginPins: 0,
240
+ dieCutMaskedAreaDots: 618,
241
+ },
242
+ };
243
+
244
+ export function findMedia(id: number): MediaDescriptor | undefined {
245
+ return MEDIA[id];
246
+ }
247
+
248
+ export function findMediaByWidth(widthMm: number, type: MediaType): MediaDescriptor[] {
249
+ return Object.values(MEDIA).filter(m => m.widthMm === widthMm && m.type === type);
250
+ }