@thermal-label/brother-ql-web 0.5.0 → 0.6.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 +37 -0
- package/dist/__tests__/printer-read-loop.test.d.ts +2 -0
- package/dist/__tests__/printer-read-loop.test.d.ts.map +1 -0
- package/dist/__tests__/printer-read-loop.test.js +173 -0
- package/dist/__tests__/printer-read-loop.test.js.map +1 -0
- package/dist/__tests__/printer.test.js +182 -58
- package/dist/__tests__/printer.test.js.map +1 -1
- package/dist/__tests__/request-printers.test.d.ts +2 -0
- package/dist/__tests__/request-printers.test.d.ts.map +1 -0
- package/dist/__tests__/request-printers.test.js +250 -0
- package/dist/__tests__/request-printers.test.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/printer.d.ts +77 -4
- package/dist/printer.d.ts.map +1 -1
- package/dist/printer.js +138 -22
- package/dist/printer.js.map +1 -1
- package/dist/request-printers.d.ts +31 -0
- package/dist/request-printers.d.ts.map +1 -0
- package/dist/request-printers.js +109 -0
- package/dist/request-printers.js.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { DeviceIdentificationRequiredError } from '@thermal-label/contracts';
|
|
3
|
+
import { DEVICES } from '@thermal-label/brother-ql-core';
|
|
4
|
+
import { devicesForTransport, requestPrinters } from '../request-printers.js';
|
|
5
|
+
import { createMockUSBDevice } from './webusb-mock.js';
|
|
6
|
+
/**
|
|
7
|
+
* Minimal Web Serial `SerialPort` double for the Web Serial picker
|
|
8
|
+
* path. Typed structurally (not as the DOM `SerialPort`) because the
|
|
9
|
+
* web package only pulls in `w3c-web-usb`, not `w3c-web-serial`.
|
|
10
|
+
*
|
|
11
|
+
* `WebSerialTransport.fromPort` opens the port and locks a
|
|
12
|
+
* reader/writer; its pump loop awaits `reader.read()` indefinitely.
|
|
13
|
+
* This double's reader hangs until `cancel()` fires (mirroring a real
|
|
14
|
+
* idle SPP link) so `close()` can unwind the pump cleanly.
|
|
15
|
+
*/
|
|
16
|
+
function createMockSerialPort() {
|
|
17
|
+
let cancelReader;
|
|
18
|
+
const reader = {
|
|
19
|
+
read: () => new Promise(resolve => {
|
|
20
|
+
cancelReader = () => {
|
|
21
|
+
resolve({ value: new Uint8Array(0), done: true });
|
|
22
|
+
};
|
|
23
|
+
}),
|
|
24
|
+
cancel: () => {
|
|
25
|
+
cancelReader?.();
|
|
26
|
+
return Promise.resolve();
|
|
27
|
+
},
|
|
28
|
+
releaseLock: () => {
|
|
29
|
+
/* no-op */
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
const writer = {
|
|
33
|
+
write: () => Promise.resolve(),
|
|
34
|
+
close: () => Promise.resolve(),
|
|
35
|
+
releaseLock: () => {
|
|
36
|
+
/* no-op */
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
open: vi.fn(() => Promise.resolve()),
|
|
41
|
+
close: vi.fn(() => Promise.resolve()),
|
|
42
|
+
readable: { getReader: () => reader },
|
|
43
|
+
writable: { getWriter: () => writer },
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
describe('requestPrinters(opts) — brother-ql generic factory', () => {
|
|
47
|
+
afterEach(() => {
|
|
48
|
+
vi.restoreAllMocks();
|
|
49
|
+
});
|
|
50
|
+
describe('transport: bluetooth-spp', () => {
|
|
51
|
+
it('throws DeviceIdentificationRequiredError when deviceKey omitted (no picker open)', async () => {
|
|
52
|
+
// No navigator.serial stubbed — a picker call would TypeError.
|
|
53
|
+
await expect(requestPrinters({ transport: 'bluetooth-spp' })).rejects.toBeInstanceOf(DeviceIdentificationRequiredError);
|
|
54
|
+
});
|
|
55
|
+
it('candidates are filtered to bluetooth-spp-capable entries (QL_820NWBc, PT_P910BT)', async () => {
|
|
56
|
+
try {
|
|
57
|
+
await requestPrinters({ transport: 'bluetooth-spp' });
|
|
58
|
+
throw new Error('expected DeviceIdentificationRequiredError');
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
if (!(err instanceof DeviceIdentificationRequiredError))
|
|
62
|
+
throw err;
|
|
63
|
+
const keys = err.candidates.map(c => c.key);
|
|
64
|
+
// Bench-confirmed SPP-capable models in the brother-ql registry.
|
|
65
|
+
expect(keys).toContain(DEVICES.QL_820NWBc.key);
|
|
66
|
+
expect(keys).toContain(DEVICES.PT_P910BT.key);
|
|
67
|
+
for (const candidate of err.candidates) {
|
|
68
|
+
expect(candidate.transports['bluetooth-spp']).toBeDefined();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
it('rejects an unknown deviceKey on bluetooth-spp', async () => {
|
|
73
|
+
await expect(requestPrinters({ transport: 'bluetooth-spp', deviceKey: 'NOT_A_KEY' })).rejects.toThrow(/unknown deviceKey/);
|
|
74
|
+
});
|
|
75
|
+
it('rejects a deviceKey for a model that does not declare bluetooth-spp', async () => {
|
|
76
|
+
// PT_P750W is a registered USB-only model — no bluetooth-spp entry.
|
|
77
|
+
expect(DEVICES.PT_P750W.transports['bluetooth-spp']).toBeUndefined();
|
|
78
|
+
await expect(requestPrinters({ transport: 'bluetooth-spp', deviceKey: DEVICES.PT_P750W.key })).rejects.toThrow(/does not declare bluetooth-spp/);
|
|
79
|
+
});
|
|
80
|
+
it('opens the Web Serial picker and returns a 1-key adapter map for a known SPP model', async () => {
|
|
81
|
+
const port = createMockSerialPort();
|
|
82
|
+
const requestPort = vi.fn().mockResolvedValue(port);
|
|
83
|
+
vi.stubGlobal('navigator', { serial: { requestPort } });
|
|
84
|
+
const printers = await requestPrinters({
|
|
85
|
+
transport: 'bluetooth-spp',
|
|
86
|
+
deviceKey: DEVICES.QL_820NWBc.key,
|
|
87
|
+
});
|
|
88
|
+
const roles = Object.keys(printers);
|
|
89
|
+
expect(roles).toHaveLength(1);
|
|
90
|
+
expect(roles[0]).toBe(DEVICES.QL_820NWBc.engines[0].role);
|
|
91
|
+
expect(printers[roles[0]].family).toBe('brother-ql');
|
|
92
|
+
expect(requestPort).toHaveBeenCalledOnce();
|
|
93
|
+
await printers[roles[0]].close();
|
|
94
|
+
});
|
|
95
|
+
it('continueWith opens the Web Serial picker with the operator-chosen SPP model', async () => {
|
|
96
|
+
const port = createMockSerialPort();
|
|
97
|
+
const requestPort = vi.fn().mockResolvedValue(port);
|
|
98
|
+
vi.stubGlobal('navigator', { serial: { requestPort } });
|
|
99
|
+
try {
|
|
100
|
+
await requestPrinters({ transport: 'bluetooth-spp' });
|
|
101
|
+
throw new Error('expected DeviceIdentificationRequiredError');
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
if (!(err instanceof DeviceIdentificationRequiredError))
|
|
105
|
+
throw err;
|
|
106
|
+
// No picker is opened until the operator resolves the choice.
|
|
107
|
+
expect(requestPort).not.toHaveBeenCalled();
|
|
108
|
+
const printers = await err.continueWith(DEVICES.PT_P910BT.key);
|
|
109
|
+
const roles = Object.keys(printers);
|
|
110
|
+
expect(roles).toHaveLength(1);
|
|
111
|
+
expect(requestPort).toHaveBeenCalledOnce();
|
|
112
|
+
await printers[roles[0]].close();
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
it('continueWith rejects an unknown deviceKey', async () => {
|
|
116
|
+
try {
|
|
117
|
+
await requestPrinters({ transport: 'bluetooth-spp' });
|
|
118
|
+
throw new Error('expected DeviceIdentificationRequiredError');
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
if (!(err instanceof DeviceIdentificationRequiredError))
|
|
122
|
+
throw err;
|
|
123
|
+
await expect(err.continueWith('NOT_A_KEY')).rejects.toThrow(/unknown deviceKey/);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
describe('transport: serial', () => {
|
|
128
|
+
it('throws because brother-ql does not declare serial', async () => {
|
|
129
|
+
await expect(requestPrinters({ transport: 'serial' })).rejects.toThrow(/not declared/);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
describe('transport: bluetooth-gatt', () => {
|
|
133
|
+
it('throws because brother-ql does not declare bluetooth-gatt', async () => {
|
|
134
|
+
await expect(requestPrinters({ transport: 'bluetooth-gatt' })).rejects.toThrow(/not declared/);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
describe('transport: usb — auto-identify', () => {
|
|
138
|
+
it('returns a 1-key adapter map when the picked USBDevice matches a registry entry', async () => {
|
|
139
|
+
// QL_820NWBc canonical VID/PID — registered.
|
|
140
|
+
const known = DEVICES.QL_820NWBc.transports.usb;
|
|
141
|
+
if (!known)
|
|
142
|
+
throw new Error('QL_820NWBc missing usb transport in registry');
|
|
143
|
+
const device = createMockUSBDevice({
|
|
144
|
+
vendorId: Number.parseInt(known.vid, 16),
|
|
145
|
+
productId: Number.parseInt(known.pid, 16),
|
|
146
|
+
});
|
|
147
|
+
const usbStub = {
|
|
148
|
+
requestDevice: vi.fn().mockResolvedValue(device),
|
|
149
|
+
getDevices: vi.fn().mockResolvedValue([device]),
|
|
150
|
+
};
|
|
151
|
+
vi.stubGlobal('navigator', { usb: usbStub });
|
|
152
|
+
const printers = await requestPrinters({ transport: 'usb' });
|
|
153
|
+
const roles = Object.keys(printers);
|
|
154
|
+
expect(roles).toHaveLength(1);
|
|
155
|
+
const printer = printers[roles[0]];
|
|
156
|
+
expect(printer.family).toBe('brother-ql');
|
|
157
|
+
await printer.close();
|
|
158
|
+
});
|
|
159
|
+
it('uses an explicit deviceKey to wrap the picked USBDevice without registry auto-match', async () => {
|
|
160
|
+
// Pass a deviceKey alongside a device whose VID/PID would NOT
|
|
161
|
+
// auto-match — the explicit key takes the priority branch.
|
|
162
|
+
const device = createMockUSBDevice({ vendorId: 0x04f9, productId: 0xabcd });
|
|
163
|
+
const usbStub = {
|
|
164
|
+
requestDevice: vi.fn().mockResolvedValue(device),
|
|
165
|
+
getDevices: vi.fn().mockResolvedValue([device]),
|
|
166
|
+
};
|
|
167
|
+
vi.stubGlobal('navigator', { usb: usbStub });
|
|
168
|
+
const printers = await requestPrinters({
|
|
169
|
+
transport: 'usb',
|
|
170
|
+
deviceKey: DEVICES.QL_820NWBc.key,
|
|
171
|
+
});
|
|
172
|
+
const roles = Object.keys(printers);
|
|
173
|
+
expect(roles).toHaveLength(1);
|
|
174
|
+
expect(roles[0]).toBe(DEVICES.QL_820NWBc.engines[0].role);
|
|
175
|
+
await printers[roles[0]].close();
|
|
176
|
+
});
|
|
177
|
+
it('rejects an explicit unknown deviceKey on usb', async () => {
|
|
178
|
+
const device = createMockUSBDevice({ vendorId: 0x04f9, productId: 0x209d });
|
|
179
|
+
const usbStub = {
|
|
180
|
+
requestDevice: vi.fn().mockResolvedValue(device),
|
|
181
|
+
getDevices: vi.fn().mockResolvedValue([device]),
|
|
182
|
+
};
|
|
183
|
+
vi.stubGlobal('navigator', { usb: usbStub });
|
|
184
|
+
await expect(requestPrinters({ transport: 'usb', deviceKey: 'NOT_A_KEY' })).rejects.toThrow(/unknown deviceKey/);
|
|
185
|
+
});
|
|
186
|
+
it('continueWith rejects an unknown deviceKey on the usb path', async () => {
|
|
187
|
+
const device = createMockUSBDevice({ vendorId: 0x04f9, productId: 0xabcd });
|
|
188
|
+
const usbStub = {
|
|
189
|
+
requestDevice: vi.fn().mockResolvedValue(device),
|
|
190
|
+
getDevices: vi.fn().mockResolvedValue([device]),
|
|
191
|
+
};
|
|
192
|
+
vi.stubGlobal('navigator', { usb: usbStub });
|
|
193
|
+
try {
|
|
194
|
+
await requestPrinters({ transport: 'usb' });
|
|
195
|
+
throw new Error('expected DeviceIdentificationRequiredError');
|
|
196
|
+
}
|
|
197
|
+
catch (err) {
|
|
198
|
+
if (!(err instanceof DeviceIdentificationRequiredError))
|
|
199
|
+
throw err;
|
|
200
|
+
await expect(err.continueWith('NOT_A_KEY')).rejects.toThrow(/unknown deviceKey/);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
it('throws DeviceIdentificationRequiredError when the picked device has unknown VID/PID', async () => {
|
|
204
|
+
const device = createMockUSBDevice({ vendorId: 0xdead, productId: 0xbeef });
|
|
205
|
+
const usbStub = {
|
|
206
|
+
requestDevice: vi.fn().mockResolvedValue(device),
|
|
207
|
+
getDevices: vi.fn().mockResolvedValue([device]),
|
|
208
|
+
};
|
|
209
|
+
vi.stubGlobal('navigator', { usb: usbStub });
|
|
210
|
+
await expect(requestPrinters({ transport: 'usb' })).rejects.toBeInstanceOf(DeviceIdentificationRequiredError);
|
|
211
|
+
});
|
|
212
|
+
it('continueWith resumes with the chosen deviceKey reusing the picked USBDevice', async () => {
|
|
213
|
+
// Use a real Brother VID with an unknown PID — the registry
|
|
214
|
+
// won't match, the picker fires once, and continueWith wraps
|
|
215
|
+
// the same device with the operator's choice.
|
|
216
|
+
const device = createMockUSBDevice({ vendorId: 0x04f9, productId: 0xabcd });
|
|
217
|
+
const requestDevice = vi.fn().mockResolvedValue(device);
|
|
218
|
+
const usbStub = {
|
|
219
|
+
requestDevice,
|
|
220
|
+
getDevices: vi.fn().mockResolvedValue([device]),
|
|
221
|
+
};
|
|
222
|
+
vi.stubGlobal('navigator', { usb: usbStub });
|
|
223
|
+
try {
|
|
224
|
+
await requestPrinters({ transport: 'usb' });
|
|
225
|
+
throw new Error('expected DeviceIdentificationRequiredError');
|
|
226
|
+
}
|
|
227
|
+
catch (err) {
|
|
228
|
+
if (!(err instanceof DeviceIdentificationRequiredError))
|
|
229
|
+
throw err;
|
|
230
|
+
const printers = await err.continueWith(DEVICES.QL_820NWBc.key);
|
|
231
|
+
const roles = Object.keys(printers);
|
|
232
|
+
expect(roles).toHaveLength(1);
|
|
233
|
+
// continueWith must not open the picker a second time.
|
|
234
|
+
expect(requestDevice).toHaveBeenCalledTimes(1);
|
|
235
|
+
await printers[roles[0]].close();
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
describe('devicesForTransport — brother-ql', () => {
|
|
241
|
+
it('returns only entries declaring the given transport', () => {
|
|
242
|
+
for (const entry of devicesForTransport('usb')) {
|
|
243
|
+
expect(entry.transports.usb).toBeDefined();
|
|
244
|
+
}
|
|
245
|
+
for (const entry of devicesForTransport('bluetooth-spp')) {
|
|
246
|
+
expect(entry.transports['bluetooth-spp']).toBeDefined();
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
//# sourceMappingURL=request-printers.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-printers.test.js","sourceRoot":"","sources":["../../src/__tests__/request-printers.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;;;;;;GASG;AACH,SAAS,oBAAoB;IAC3B,IAAI,YAAsC,CAAC;IAC3C,MAAM,MAAM,GAAG;QACb,IAAI,EAAE,GAAG,EAAE,CACT,IAAI,OAAO,CAAuC,OAAO,CAAC,EAAE;YAC1D,YAAY,GAAG,GAAG,EAAE;gBAClB,OAAO,CAAC,EAAE,KAAK,EAAE,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YACpD,CAAC,CAAC;QACJ,CAAC,CAAC;QACJ,MAAM,EAAE,GAAG,EAAE;YACX,YAAY,EAAE,EAAE,CAAC;YACjB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC;QACD,WAAW,EAAE,GA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AC/C,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;QAC7C,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,mBAAmB,CAAC,eAAe,CAAC,EAAE,CAAC;YACzD,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1D,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export { DEFAULT_FILTERS, WebBrotherQLPrinter,
|
|
1
|
+
export { DEFAULT_FILTERS, WebBrotherQLPrinter, type RequestOptions } from './printer.js';
|
|
2
|
+
export { fromUSBDevice, fromUSBDeviceAll, requestPrinter, requestPrintersUsbLegacy, } from './printer.js';
|
|
3
|
+
export { devicesForTransport, requestPrinters } from './request-printers.js';
|
|
4
|
+
export type { ConnectOptions, PrinterAdapterMap } from '@thermal-label/contracts';
|
|
5
|
+
export { DeviceIdentificationRequiredError } from '@thermal-label/contracts';
|
|
2
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAGzF,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,wBAAwB,GACzB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7E,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAE,iCAAiC,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
export { DEFAULT_FILTERS, WebBrotherQLPrinter
|
|
1
|
+
export { DEFAULT_FILTERS, WebBrotherQLPrinter } from './printer.js';
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-deprecated -- legacy factories re-exported during plan-10 transition */
|
|
3
|
+
export { fromUSBDevice, fromUSBDeviceAll, requestPrinter, requestPrintersUsbLegacy, } from './printer.js';
|
|
4
|
+
/* eslint-enable @typescript-eslint/no-deprecated */
|
|
5
|
+
export { devicesForTransport, requestPrinters } from './request-printers.js';
|
|
6
|
+
export { DeviceIdentificationRequiredError } from '@thermal-label/contracts';
|
|
2
7
|
//# 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,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAuB,MAAM,cAAc,CAAC;AAEzF,+GAA+G;AAC/G,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,wBAAwB,GACzB,MAAM,cAAc,CAAC;AACtB,oDAAoD;AAEpD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7E,OAAO,EAAE,iCAAiC,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/printer.d.ts
CHANGED
|
@@ -18,6 +18,27 @@ export declare class WebBrotherQLPrinter implements PrinterAdapter {
|
|
|
18
18
|
private readonly statusListeners;
|
|
19
19
|
private readLoopStarted;
|
|
20
20
|
private readLoopStopped;
|
|
21
|
+
/**
|
|
22
|
+
* Serialises every bulk-OUT operation (print + getStatus). Required
|
|
23
|
+
* because `getStatus()` may write the QL preamble (`buildInvalidate` —
|
|
24
|
+
* 200×0x00 + `ESC @`) to put the parser in a known state, and the
|
|
25
|
+
* preamble's "invalidate" cancels any in-flight print job. Polling
|
|
26
|
+
* concurrently with a print would shred the raster stream.
|
|
27
|
+
*
|
|
28
|
+
* Plan 15 A4: this was a hand-rolled `writeLock`/`runLocked` pair;
|
|
29
|
+
* it is now the shared `WriteSerializer` from `@thermal-label/contracts`
|
|
30
|
+
* so all four drivers serialise identically. Behaviour is unchanged —
|
|
31
|
+
* `WriteSerializer.run()` is exactly the old `runLocked` semantics.
|
|
32
|
+
*/
|
|
33
|
+
private readonly serializer;
|
|
34
|
+
/**
|
|
35
|
+
* Whether the printer's command parser is in a known-clean state.
|
|
36
|
+
* Set to `true` after a successful `getStatus()`; flipped back to
|
|
37
|
+
* `false` on timeout so the next attempt re-sends the preamble. The
|
|
38
|
+
* preamble (200-byte invalidate + `ESC @`) is only needed once per
|
|
39
|
+
* session unless the parser falls back into a confused state.
|
|
40
|
+
*/
|
|
41
|
+
private parserReady;
|
|
21
42
|
constructor(device: BrotherQLDevice, transport: Transport);
|
|
22
43
|
get model(): string;
|
|
23
44
|
get connected(): boolean;
|
|
@@ -30,13 +51,28 @@ export declare class WebBrotherQLPrinter implements PrinterAdapter {
|
|
|
30
51
|
* `getStatus()` subscribes transiently, writes the request, and the
|
|
31
52
|
* subscription receives the response (alongside any spontaneous
|
|
32
53
|
* frames; see `onStatus()`).
|
|
54
|
+
*
|
|
55
|
+
* The QL preamble (200×0x00 invalidate + `ESC @` initialize) is
|
|
56
|
+
* sent only when the parser hasn't been confirmed clean — first
|
|
57
|
+
* call of the session, or after a previous timeout. Steady-state
|
|
58
|
+
* polls send bare `ESC iS`. Bench observation: a freshly-opened QL
|
|
59
|
+
* doesn't reply to bare `ESC iS` until the invalidate flushes any
|
|
60
|
+
* stale parser state from a prior session.
|
|
33
61
|
*/
|
|
34
62
|
getStatus(): Promise<BrotherQLStatus>;
|
|
35
63
|
/**
|
|
36
|
-
* Subscribe to
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
64
|
+
* Subscribe to status updates. A polling shim built on
|
|
65
|
+
* `pollingOnStatus` from contracts — it calls `getStatus()` on first
|
|
66
|
+
* subscribe and then every `DEFAULT_POLLING_INTERVAL_MS`, matching the
|
|
67
|
+
* labelwriter and labelmanager web drivers (plan 11 §`onStatus`
|
|
68
|
+
* parity).
|
|
69
|
+
*
|
|
70
|
+
* An earlier revision skipped polling and relied solely on the
|
|
71
|
+
* printer's unsolicited frames. That was a workaround for the Chromium
|
|
72
|
+
* WebUSB sub-packet stall — `getStatus()`'s `read()` would hang, so
|
|
73
|
+
* polling looked unreliable and was dropped. `WebUsbTransport.read()`
|
|
74
|
+
* now rounds reads up to the endpoint packet size, so `getStatus()` is
|
|
75
|
+
* dependable and polling is restored.
|
|
40
76
|
*/
|
|
41
77
|
onStatus(cb: (status: BrotherQLStatus) => void): () => void;
|
|
42
78
|
private nextStatusFrame;
|
|
@@ -50,12 +86,49 @@ export declare const DEFAULT_FILTERS: USBDeviceFilter[];
|
|
|
50
86
|
*
|
|
51
87
|
* Requires a user gesture. Opens the device and claims interface 0 via
|
|
52
88
|
* `WebUsbTransport.fromDevice()`.
|
|
89
|
+
*
|
|
90
|
+
* Single-instance entry point — preserved for back-compat with existing
|
|
91
|
+
* consumers (CLIs, ad-hoc scripts). For the symmetric driver-web shape
|
|
92
|
+
* (1-key map keyed by engine role) call `requestPrinters()` instead;
|
|
93
|
+
* the harness shell uses that path.
|
|
94
|
+
*
|
|
95
|
+
* @deprecated Use `requestPrinters({ transport: 'usb' })` from
|
|
96
|
+
* `./request-printers.ts`. Removed once consumers migrate (plan 11).
|
|
53
97
|
*/
|
|
54
98
|
export declare function requestPrinter(options?: RequestOptions): Promise<WebBrotherQLPrinter>;
|
|
99
|
+
/**
|
|
100
|
+
* Show the browser's USB picker and return one `PrinterAdapter` per
|
|
101
|
+
* drivable engine on the selected device, keyed by engine role.
|
|
102
|
+
*
|
|
103
|
+
* Brother QL devices are always single-engine — this returns a 1-key
|
|
104
|
+
* record keyed by the device's `engines[0].role` (typically `'primary'`).
|
|
105
|
+
*
|
|
106
|
+
* @deprecated Use the generic `requestPrinters({ transport: 'usb' })`
|
|
107
|
+
* from `./request-printers.ts` — the legacy USB-only name is preserved
|
|
108
|
+
* as `requestPrintersUsbLegacy` for back-compat. Removed once
|
|
109
|
+
* consumers migrate (plan 11).
|
|
110
|
+
*/
|
|
111
|
+
export declare function requestPrintersUsbLegacy(options?: RequestOptions): Promise<Record<string, WebBrotherQLPrinter>>;
|
|
55
112
|
/**
|
|
56
113
|
* Wrap an already-selected `USBDevice`.
|
|
57
114
|
*
|
|
58
115
|
* @throws when the VID/PID is not in the Brother QL registry.
|
|
116
|
+
*
|
|
117
|
+
* @deprecated Use `requestPrinters({ transport: 'usb' })` from
|
|
118
|
+
* `./request-printers.ts`. Removed once consumers migrate (plan 11).
|
|
59
119
|
*/
|
|
60
120
|
export declare function fromUSBDevice(usbDevice: USBDevice): Promise<WebBrotherQLPrinter>;
|
|
121
|
+
/**
|
|
122
|
+
* Wrap an already-selected `USBDevice` and return a 1-key adapter map
|
|
123
|
+
* keyed by the device's `engines[0].role`. Public surface for
|
|
124
|
+
* `requestPrinters()`; exported so harnesses that already hold a
|
|
125
|
+
* `USBDevice` (e.g. picked-up via `navigator.usb.getDevices()` on a
|
|
126
|
+
* returning visit) can skip the picker.
|
|
127
|
+
*
|
|
128
|
+
* Brother QL is single-engine and single-interface (IF 0).
|
|
129
|
+
*
|
|
130
|
+
* @deprecated Use `requestPrinters({ transport: 'usb' })` from
|
|
131
|
+
* `./request-printers.ts`. Removed once consumers migrate (plan 11).
|
|
132
|
+
*/
|
|
133
|
+
export declare function fromUSBDeviceAll(usbDevice: USBDevice): Promise<Record<string, WebBrotherQLPrinter>>;
|
|
61
134
|
//# sourceMappingURL=printer.d.ts.map
|
package/dist/printer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,eAAe,EAEf,qBAAqB,EACrB,eAAe,EAEf,eAAe,EAEf,cAAc,EACd,aAAa,EACb,cAAc,EACd,YAAY,EACZ,SAAS,EACV,MAAM,gCAAgC,CAAC;AA4BxC,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,qBAAa,mBAAoB,YAAW,cAAc;IACxD,QAAQ,CAAC,MAAM,eAAyB;IACxC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IAEjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,UAAU,CAA8B;IAChD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAgD;IAChF,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,eAAe,CAAS;IAChC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAyB;IACpD;;;;;;OAMG;IACH,OAAO,CAAC,WAAW,CAAS;gBAEhB,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS;IAMzD,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;YAgDF,YAAY;IAU1B,aAAa,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAWpF;;;;;;;;;;;;;OAaG;IACG,SAAS,IAAI,OAAO,CAAC,eAAe,CA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