taro-bluetooth-print 2.3.0 → 2.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 (57) hide show
  1. package/CHANGELOG.md +73 -195
  2. package/README.md +134 -386
  3. package/dist/index.cjs.js +1 -1
  4. package/dist/index.es.js +1 -1
  5. package/dist/index.umd.js +1 -1
  6. package/dist/types/config/PrinterConfigManager.d.ts +206 -0
  7. package/dist/types/config/index.d.ts +8 -0
  8. package/dist/types/core/BluetoothPrinter.d.ts +1 -1
  9. package/dist/types/core/EventEmitter.d.ts +6 -26
  10. package/dist/types/core/index.d.ts +6 -0
  11. package/dist/types/device/MultiPrinterManager.d.ts +164 -0
  12. package/dist/types/device/index.d.ts +2 -0
  13. package/dist/types/drivers/CpclDriver.d.ts +304 -0
  14. package/dist/types/drivers/GPrinterDriver.d.ts +63 -0
  15. package/dist/types/drivers/ZplDriver.d.ts +325 -0
  16. package/dist/types/drivers/index.d.ts +9 -0
  17. package/dist/types/encoding/gbk-lite.d.ts +8 -0
  18. package/dist/types/encoding/gbk-table.d.ts +8 -30
  19. package/dist/types/index.d.ts +12 -8
  20. package/dist/types/services/BatchPrintManager.d.ts +205 -0
  21. package/dist/types/services/ConnectionManager.d.ts +1 -1
  22. package/dist/types/services/PrintHistory.d.ts +142 -0
  23. package/dist/types/services/PrintJobManager.d.ts +28 -4
  24. package/dist/types/services/PrinterStatus.d.ts +97 -0
  25. package/dist/types/services/index.d.ts +11 -0
  26. package/package.json +25 -7
  27. package/src/adapters/AlipayAdapter.ts +1 -0
  28. package/src/adapters/BaiduAdapter.ts +1 -0
  29. package/src/adapters/BaseAdapter.ts +6 -8
  30. package/src/adapters/ByteDanceAdapter.ts +1 -0
  31. package/src/adapters/TaroAdapter.ts +1 -0
  32. package/src/adapters/WebBluetoothAdapter.ts +1 -1
  33. package/src/config/PrinterConfigManager.ts +519 -0
  34. package/src/config/index.ts +15 -0
  35. package/src/core/BluetoothPrinter.ts +15 -15
  36. package/src/core/EventEmitter.ts +15 -15
  37. package/src/core/index.ts +7 -0
  38. package/src/device/MultiPrinterManager.ts +470 -0
  39. package/src/device/index.ts +8 -0
  40. package/src/drivers/CpclDriver.ts +549 -0
  41. package/src/drivers/GPrinterDriver.ts +115 -0
  42. package/src/drivers/TsplDriver.ts +9 -21
  43. package/src/drivers/ZplDriver.ts +543 -0
  44. package/src/drivers/index.ts +37 -0
  45. package/src/encoding/gbk-lite.ts +113 -0
  46. package/src/encoding/gbk-table.ts +80 -58
  47. package/src/index.ts +40 -35
  48. package/src/plugins/PluginManager.ts +3 -1
  49. package/src/plugins/builtin/LoggingPlugin.ts +4 -2
  50. package/src/plugins/builtin/RetryPlugin.ts +8 -14
  51. package/src/services/BatchPrintManager.ts +500 -0
  52. package/src/services/ConnectionManager.ts +25 -22
  53. package/src/services/PrintHistory.ts +336 -0
  54. package/src/services/PrintJobManager.ts +69 -9
  55. package/src/services/PrinterStatus.ts +267 -0
  56. package/src/services/index.ts +22 -0
  57. package/src/template/TemplateEngine.ts +4 -1
@@ -0,0 +1,304 @@
1
+ /**
2
+ * CPCL Driver
3
+ * PCL commands for Compact Print Language - HP/Honeywell/Toddler printers
4
+ *
5
+ * CPCL is commonly used in mobile/portable thermal printers
6
+ */
7
+ /**
8
+ * CPCL page size presets
9
+ */
10
+ export type CPCLPageSize = 'A4' | 'A5' | 'LETTER' | '4X6' | '4X2' | '4X4' | '2.25X1.25' | 'CUSTOM';
11
+ /**
12
+ * CPCL Text options
13
+ */
14
+ export interface CpclTextOptions {
15
+ /** X position in dots */
16
+ x?: number;
17
+ /** Y position in dots */
18
+ y?: number;
19
+ /** Font type: 0-6 (0=OCR, 1=OCR-B, 2=CG Triumvirate, etc.) */
20
+ font?: number;
21
+ /** Horizontal multiplier (1-8) */
22
+ xMulti?: number;
23
+ /** Vertical multiplier (1-8) */
24
+ yMulti?: number;
25
+ /** Rotation: 0, 90, 180, 270 */
26
+ rotation?: 0 | 90 | 180 | 270;
27
+ }
28
+ /**
29
+ * CPCL Barcode options
30
+ */
31
+ export interface CpclBarcodeOptions {
32
+ /** X position in dots */
33
+ x?: number;
34
+ /** Y position in dots */
35
+ y?: number;
36
+ /** Barcode type */
37
+ type: '128' | '39' | 'EAN13' | 'EAN8' | 'UPCA' | 'UPCE' | 'MSI' | 'PLESSEY' | 'PDF417' | 'DATAMATRIX' | 'QR';
38
+ /** Barcode height in dots (default: 50) */
39
+ height?: number;
40
+ /** Wide bar width for 39 (default: 2) */
41
+ wide?: number;
42
+ /** Narrow bar width (default: 1) */
43
+ narrow?: number;
44
+ /** Show human-readable text (default: true) */
45
+ readable?: boolean;
46
+ }
47
+ /**
48
+ * CPCL QR Code options
49
+ */
50
+ export interface CpclQRCodeOptions {
51
+ /** X position in dots */
52
+ x?: number;
53
+ /** Y position in dots */
54
+ y?: number;
55
+ /** Model (default: 2) */
56
+ model?: 1 | 2;
57
+ /** Error correction level: L, M, Q, H */
58
+ errorCorrection?: 'L' | 'M' | 'Q' | 'H';
59
+ /** Cell size (default: 4) */
60
+ cellSize?: number;
61
+ }
62
+ /**
63
+ * CPCL Line options
64
+ */
65
+ export interface CpclLineOptions {
66
+ /** Start X position */
67
+ x1: number;
68
+ /** Start Y position */
69
+ y1: number;
70
+ /** End X position */
71
+ x2: number;
72
+ /** End Y position */
73
+ y2: number;
74
+ /** Line width/thickness */
75
+ width?: number;
76
+ }
77
+ /**
78
+ * CPCL Box options
79
+ */
80
+ export interface CpclBoxOptions {
81
+ /** X position */
82
+ x: number;
83
+ /** Y position */
84
+ y: number;
85
+ /** Width */
86
+ width: number;
87
+ /** Height */
88
+ height: number;
89
+ /** Border thickness */
90
+ thickness?: number;
91
+ }
92
+ /**
93
+ * CPCL Driver for HP, Honeywell, and Toddler portable printers
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * const cpcl = new CpclDriver();
98
+ *
99
+ * const commands = cpcl
100
+ * .pageStart()
101
+ * .text('Hello World!', { x: 50, y: 50 })
102
+ * .barcode('1234567890', { x: 50, y: 150, type: '128' })
103
+ * .qrcode('https://example.com', { x: 300, y: 50 })
104
+ * .pageEnd()
105
+ * .getCommands();
106
+ * ```
107
+ */
108
+ export declare class CpclDriver {
109
+ private commands;
110
+ private readonly logger;
111
+ private pageWidth;
112
+ private pageHeight;
113
+ /**
114
+ * Initialize CPCL driver
115
+ * @param width - Page width in dots
116
+ * @param height - Page height in dots (0 = continuous)
117
+ */
118
+ constructor(width?: number, height?: number);
119
+ /**
120
+ * Set page size
121
+ * @param width - Width in dots
122
+ * @param height - Height in dots (0 = continuous)
123
+ */
124
+ setPageSize(width: number, height?: number): this;
125
+ /**
126
+ * Use standard page size
127
+ * @param size - Preset size name
128
+ */
129
+ usePageSize(size: CPCLPageSize): this;
130
+ /**
131
+ * Start a new page
132
+ */
133
+ pageStart(): this;
134
+ /**
135
+ * End current page
136
+ */
137
+ pageEnd(): this;
138
+ /**
139
+ * Form feed to next label
140
+ */
141
+ formFeed(): this;
142
+ /**
143
+ * Set line print mode
144
+ * @param font - Font number (0-6)
145
+ * @param xMulti - Horizontal multiplier
146
+ * @param yMulti - Vertical multiplier
147
+ */
148
+ setLinePrint(font?: number, xMulti?: number, yMulti?: number): this;
149
+ /**
150
+ * Set text font
151
+ * @param font - Font: 0=OCR, 1=OCR-B, 2=CG Triumvirate Bold, 3-6=Various sizes
152
+ * @param xMulti - Horizontal multiplier (1-8)
153
+ * @param yMulti - Vertical multiplier (1-8)
154
+ * @param rotation - Rotation angle
155
+ */
156
+ setFont(font?: number, xMulti?: number, yMulti?: number, rotation?: 0 | 90 | 180 | 270): this;
157
+ /**
158
+ * Add text at current position
159
+ * @param content - Text content
160
+ */
161
+ text(content: string): this;
162
+ /**
163
+ * Add positioned text
164
+ * @param content - Text content
165
+ * @param options - Text options
166
+ */
167
+ textAt(content: string, options: CpclTextOptions): this;
168
+ /**
169
+ * Add text using legacy command
170
+ * @param content - Text content
171
+ * @param x - X position
172
+ * @param y - Y position
173
+ * @param font - Font number
174
+ */
175
+ legacyText(content: string, x: number, y: number, font?: number): this;
176
+ /**
177
+ * Add barcode at position
178
+ * @param content - Barcode content
179
+ * @param options - Barcode options
180
+ */
181
+ barcode(content: string, options: CpclBarcodeOptions): this;
182
+ /**
183
+ * Add Code 128 barcode (most common)
184
+ * @param content - Barcode content
185
+ * @param x - X position
186
+ * @param y - Y position
187
+ * @param height - Barcode height
188
+ */
189
+ code128(content: string, x?: number, y?: number, height?: number): this;
190
+ /**
191
+ * Add Code 39 barcode
192
+ * @param content - Barcode content
193
+ * @param x - X position
194
+ * @param y - Y position
195
+ * @param height - Barcode height
196
+ */
197
+ code39(content: string, x?: number, y?: number, height?: number): this;
198
+ /**
199
+ * Add QR code
200
+ * @param content - QR code content
201
+ * @param options - QR options
202
+ */
203
+ qrcode(content: string, options?: CpclQRCodeOptions): this;
204
+ /**
205
+ * Add 2D barcode (PDF417 or DataMatrix)
206
+ * @param content - Content
207
+ * @param type - Type: PDF417 or DATAMATRIX
208
+ * @param x - X position
209
+ * @param y - Y position
210
+ * @param height - Height
211
+ */
212
+ twoDBarcode(content: string, type: 'PDF417' | 'DATAMATRIX', x?: number, y?: number, height?: number): this;
213
+ /**
214
+ * Add line
215
+ * @param options - Line options
216
+ */
217
+ line(options: CpclLineOptions): this;
218
+ /**
219
+ * Add box/rectangle
220
+ * @param options - Box options
221
+ */
222
+ box(options: CpclBoxOptions): this;
223
+ /**
224
+ * Add inverse area (white on black)
225
+ * @param x - X position
226
+ * @param y - Y position
227
+ * @param width - Width
228
+ * @param height - Height
229
+ */
230
+ inverse(x: number, y: number, width: number, height: number): this;
231
+ /**
232
+ * Set print density
233
+ * @param density - Density value (-50 to +50)
234
+ */
235
+ setDensity(density: number): this;
236
+ /**
237
+ * Set speed
238
+ * @param speed - Speed: 2-6 (2=50%, 3=75%, 4=100%, 5=125%, 6=150%)
239
+ */
240
+ setSpeed(speed: number): this;
241
+ /**
242
+ * Cut paper (if cutter installed)
243
+ */
244
+ cut(): this;
245
+ /**
246
+ * Partial cut
247
+ */
248
+ partialCut(): this;
249
+ /**
250
+ * Feed and cut
251
+ */
252
+ feedCut(): this;
253
+ /**
254
+ * Sound beep
255
+ * @param count - Number of beeps
256
+ * @param duration - Duration in 10ms units
257
+ */
258
+ beep(count?: number, duration?: number): this;
259
+ /**
260
+ * Add logo/image
261
+ * @param x - X position
262
+ * @param y - Y position
263
+ * @param logoName - Stored logo name
264
+ */
265
+ logo(x: number, y: number, logoName: string): this;
266
+ /**
267
+ * Download logo to printer (store in memory)
268
+ * Note: This is a placeholder for future implementation
269
+ * @param logoName - Name to store logo as
270
+ * @param _bitmap - Logo bitmap data (placeholder)
271
+ */
272
+ downloadLogo(logoName: string, _bitmap: Uint8Array): this;
273
+ /**
274
+ * Print stored logo
275
+ * @param logoName - Logo name
276
+ * @param x - X position
277
+ * @param y - Y position
278
+ */
279
+ printLogo(logoName: string, x?: number, y?: number): this;
280
+ /**
281
+ * Get all commands as string
282
+ */
283
+ getCommands(): string;
284
+ /**
285
+ * Get commands as buffer for sending to printer
286
+ */
287
+ getBuffer(): Uint8Array;
288
+ /**
289
+ * Get raw command list
290
+ */
291
+ getCommandList(): string[];
292
+ /**
293
+ * Clear all commands
294
+ */
295
+ reset(): this;
296
+ /**
297
+ * Get page width
298
+ */
299
+ getPageWidth(): number;
300
+ /**
301
+ * Escape special characters in text
302
+ */
303
+ private escapeText;
304
+ }
@@ -0,0 +1,63 @@
1
+ import { EscPos, EscPosOptions } from './EscPos';
2
+ /**
3
+ * GPrinter Driver for GiaoBao (佳博) thermal printers
4
+ *
5
+ * 佳博打印机基于 ESC/POS 指令集,此驱动扩展了标准 EscPos
6
+ * 添加了佳博特定的命令支持
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { GPrinterDriver } from 'taro-bluetooth-print';
11
+ *
12
+ * const driver = new GPrinterDriver();
13
+ * let commands = driver.init();
14
+ * commands = driver.text('Hello 佳博!', 'GBK');
15
+ * commands = driver.cut();
16
+ * ```
17
+ */
18
+ /**
19
+ * GPrinter options (same as EscPosOptions)
20
+ */
21
+ export type GPrinterOptions = EscPosOptions;
22
+ export declare class GPrinterDriver extends EscPos {
23
+ /**
24
+ * 佳博打印机特定: 打开钱箱
25
+ * @param pin 钱箱引脚 (0 或 1, 默认 0)
26
+ */
27
+ openCashDrawer(pin?: number): Uint8Array[];
28
+ /**
29
+ * 佳博打印机特定: 发送声响
30
+ * @param times 次数 (1-9)
31
+ * @param duration 持续时间
32
+ */
33
+ beep(times?: number, duration?: number): Uint8Array[];
34
+ /**
35
+ * 佳博打印机特定: 打印自检页
36
+ */
37
+ selfTest(): Uint8Array[];
38
+ /**
39
+ * 佳博打印机特定: 获取状态
40
+ * 返回打印机状态字节
41
+ */
42
+ getStatus(): Uint8Array[];
43
+ /**
44
+ * 佳博打印机特定: 设置字符代码页
45
+ * @param codePage 代码页编号
46
+ */
47
+ setCodePage(codePage: number): Uint8Array[];
48
+ /**
49
+ * 佳博打印机特定: 打印并走纸
50
+ * @param lines 走纸行数
51
+ */
52
+ printAndFeed(lines: number): Uint8Array[];
53
+ /**
54
+ * 佳博打印机特定: 设置左边界
55
+ * @param n 左边界字符数
56
+ */
57
+ setLeftMargin(n: number): Uint8Array[];
58
+ /**
59
+ * 佳博打印机特定: 设置打印区域宽度
60
+ * @param n 宽度 (字符数)
61
+ */
62
+ setPrintWidth(n: number): Uint8Array[];
63
+ }
@@ -0,0 +1,325 @@
1
+ /**
2
+ * ZPL Driver
3
+ * Zebra Printer Language driver for Zebra label printers
4
+ *
5
+ * ZPL is the industry standard for industrial label printing
6
+ */
7
+ /**
8
+ * ZPL Label size configuration
9
+ */
10
+ export interface ZplLabelSize {
11
+ /** Label width in dots */
12
+ width: number;
13
+ /** Label height in dots */
14
+ height: number;
15
+ /** Label gap in dots (default: 0) */
16
+ gap?: number;
17
+ }
18
+ /**
19
+ * Text format options
20
+ */
21
+ export interface ZplTextOptions {
22
+ /** X position in dots */
23
+ x: number;
24
+ /** Y position in dots */
25
+ y: number;
26
+ /** Font name (default: 0 for built-in) */
27
+ font?: string;
28
+ /** Font rotation: N=0, R=90, I=270, B=180 (default: N) */
29
+ rotation?: 'N' | 'R' | 'I' | 'B';
30
+ /** Horizontal magnification (1-10, default: 1) */
31
+ xMultiplier?: number;
32
+ /** Vertical magnification (1-10, default: 1) */
33
+ yMultiplier?: number;
34
+ /** Field orientation: N=normal, R=rotated, I=inverted, B=bottom-up */
35
+ orientation?: 'N' | 'R' | 'I' | 'B';
36
+ }
37
+ /**
38
+ * Barcode options
39
+ */
40
+ export interface ZplBarcodeOptions {
41
+ /** X position in dots */
42
+ x: number;
43
+ /** Y position in dots */
44
+ y: number;
45
+ /** Barcode type: 128, 39, 93, EAN13, EAN8, UPCE, CODE51, etc. */
46
+ type: '128' | '39' | '93' | 'EAN13' | 'EAN8' | 'UPCA' | 'UPCE' | 'CODE51' | 'MSI' | 'PLESSEY';
47
+ /** Barcode height in dots (default: 50) */
48
+ height?: number;
49
+ /** Show human-readable text (default: Y) */
50
+ showText?: 'Y' | 'N';
51
+ /** Check digit: Y=validate, N=no check (default: Y) */
52
+ checkDigit?: 'Y' | 'N';
53
+ /** Interpretation line: Y=print, N=omit (default: Y) */
54
+ interpretLine?: 'Y' | 'N';
55
+ /** Interpretation line above: Y=above, N=below (default: N) */
56
+ interpretLineAbove?: 'Y' | 'N';
57
+ }
58
+ /**
59
+ * QR Code options
60
+ */
61
+ export interface ZplQRCodeOptions {
62
+ /** X position in dots */
63
+ x: number;
64
+ /** Y position in dots */
65
+ y: number;
66
+ /** Model: 2 (default) or 1 */
67
+ model?: 1 | 2;
68
+ /** Magnification factor 1-10 (default: 4) */
69
+ magnification?: number;
70
+ /** Error correction level: L(~7%), M(~15%), Q(~25%), H(~30%) */
71
+ errorCorrection?: 'L' | 'M' | 'Q' | 'H';
72
+ }
73
+ /**
74
+ * Box/Rectangle options
75
+ */
76
+ export interface ZplBoxOptions {
77
+ /** X position in dots */
78
+ x: number;
79
+ /** Y position in dots */
80
+ y: number;
81
+ /** Width in dots */
82
+ width: number;
83
+ /** Height in dots */
84
+ height: number;
85
+ /** Border thickness (default: 2) */
86
+ borderThickness?: number;
87
+ /** Corner rounding (0-10, default: 0) */
88
+ cornerRounding?: number;
89
+ }
90
+ /**
91
+ * ZPL Driver for Zebra label printers
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * const zpl = new ZplDriver();
96
+ *
97
+ * const commands = zpl
98
+ * .startFormat()
99
+ * .labelHome(10, 10)
100
+ * .text('Product Name', { x: 50, y: 50 })
101
+ * .barcode('1234567890', { x: 50, y: 150, type: '128' })
102
+ * .qrcode('https://example.com', { x: 300, y: 50 })
103
+ * .print()
104
+ * .getCommands();
105
+ * ```
106
+ */
107
+ export declare class ZplDriver {
108
+ private commands;
109
+ private readonly logger;
110
+ /**
111
+ * Initialize ZPL driver with default settings
112
+ */
113
+ constructor();
114
+ /**
115
+ * Start label format (^XA)
116
+ */
117
+ startFormat(): this;
118
+ /**
119
+ * End label format (^XZ)
120
+ */
121
+ endFormat(): this;
122
+ /**
123
+ * Set label home position
124
+ * @param x - X position in dots
125
+ * @param y - Y position in dots
126
+ */
127
+ labelHome(x: number, y: number): this;
128
+ /**
129
+ * Set field data (^FD)
130
+ * @param content - Field content
131
+ */
132
+ fieldData(content: string): this;
133
+ /**
134
+ * Set field origin
135
+ * @param x - X position in dots
136
+ * @param y - Y position in dots
137
+ */
138
+ fieldOrigin(x: number, y: number): this;
139
+ /**
140
+ * Set print width
141
+ * @param width - Width in dots
142
+ */
143
+ printWidth(width: number): this;
144
+ /**
145
+ * Set label length
146
+ * @param length - Length in dots
147
+ */
148
+ labelLength(length: number): this;
149
+ /**
150
+ * Set label gap
151
+ * @param gap - Gap in dots
152
+ */
153
+ labelGap(gap: number): this;
154
+ /**
155
+ * Set print quantity
156
+ * @param quantity - Number of labels
157
+ */
158
+ quantity(quantity: number): this;
159
+ /**
160
+ * Add text to label
161
+ * @param content - Text content
162
+ * @param options - Text options
163
+ */
164
+ text(content: string, options?: ZplTextOptions): this;
165
+ /**
166
+ * Add text with explicit field origin
167
+ * @param content - Text content
168
+ * @param x - X position
169
+ * @param y - Y position
170
+ * @param font - Font name (default: 0)
171
+ * @param rotation - Rotation
172
+ */
173
+ textAt(content: string, x: number, y: number, font?: string, rotation?: 'N' | 'R' | 'I' | 'B'): this;
174
+ /**
175
+ * Use built-in font
176
+ * @param content - Text content
177
+ * @param x - X position
178
+ * @param y - Y position
179
+ * @param height - Character height (40-400)
180
+ * @param width - Character width (30-300)
181
+ */
182
+ font(content: string, x: number, y: number, height?: number, width?: number): this;
183
+ /**
184
+ * Add scalable font
185
+ * @param content - Text content
186
+ * @param x - X position
187
+ * @param y - Y position
188
+ * @param fontName - Font name (e.g., "0" for built-in, or loaded font name)
189
+ * @param fontHeight - Height multiplier
190
+ * @param fontWidth - Width multiplier
191
+ */
192
+ scalableText(content: string, x: number, y: number, fontName?: string, fontHeight?: number, fontWidth?: number): this;
193
+ /**
194
+ * Add barcode
195
+ * @param content - Barcode content
196
+ * @param options - Barcode options
197
+ */
198
+ barcode(content: string, options: ZplBarcodeOptions): this;
199
+ /**
200
+ * Add Code 128 barcode
201
+ * @param content - Barcode content
202
+ * @param x - X position
203
+ * @param y - Y position
204
+ * @param height - Barcode height
205
+ */
206
+ code128(content: string, x?: number, y?: number, height?: number): this;
207
+ /**
208
+ * Add Code 39 barcode
209
+ * @param content - Barcode content
210
+ * @param x - X position
211
+ * @param y - Y position
212
+ * @param height - Barcode height
213
+ */
214
+ code39(content: string, x?: number, y?: number, height?: number): this;
215
+ /**
216
+ * Add EAN-13 barcode
217
+ * @param content - Barcode content (12 or 13 digits)
218
+ * @param x - X position
219
+ * @param y - Y position
220
+ * @param height - Barcode height
221
+ */
222
+ ean13(content: string, x?: number, y?: number, height?: number): this;
223
+ /**
224
+ * Add QR code
225
+ * @param content - QR code content
226
+ * @param options - QR code options
227
+ */
228
+ qrcode(content: string, options?: ZplQRCodeOptions): this;
229
+ /**
230
+ * Add rectangle/border
231
+ * @param options - Box options
232
+ */
233
+ box(options: ZplBoxOptions): this;
234
+ /**
235
+ * Add line
236
+ * @param x1 - Start X
237
+ * @param y1 - Start Y
238
+ * @param x2 - End X
239
+ * @param y2 - End Y
240
+ * @param thickness - Line thickness
241
+ */
242
+ line(x1: number, y1: number, x2: number, y2: number, thickness?: number): this;
243
+ /**
244
+ * Add circle
245
+ * @param x - Center X
246
+ * @param y - Center Y
247
+ * @param diameter - Diameter in dots
248
+ * @param borderThickness - Border thickness
249
+ */
250
+ circle(x: number, y: number, diameter: number, borderThickness?: number): this;
251
+ /**
252
+ * Add diagonal line
253
+ * @param x - Start X
254
+ * @param y - Start Y
255
+ * @param width - Width
256
+ * @param height - Height
257
+ * @param thickness - Line thickness
258
+ */
259
+ diagonal(x: number, y: number, width: number, height: number, thickness?: number): this;
260
+ /**
261
+ * Add ellipse
262
+ * @param x - Center X
263
+ * @param y - Center Y
264
+ * @param width - Width
265
+ * @param height - Height
266
+ * @param borderThickness - Border thickness
267
+ */
268
+ ellipse(x: number, y: number, width: number, height: number, borderThickness?: number): this;
269
+ /**
270
+ * Add image from raw bitmap
271
+ * Note: For best results, use pre-processed images. This is a placeholder for future implementation.
272
+ * @param _x - X position (placeholder)
273
+ * @param _y - Y position (placeholder)
274
+ * @param _width - Image width (placeholder)
275
+ * @param _height - Image height (placeholder)
276
+ * @param _bitmap - Binary bitmap data (placeholder)
277
+ */
278
+ image(_x: number, _y: number, _width: number, _height: number, _bitmap: Uint8Array): this;
279
+ /**
280
+ * Set darkness/print density
281
+ * @param value - Darkness value (0-30, default: 15)
282
+ */
283
+ setDarkness(value?: number): this;
284
+ /**
285
+ * Set print speed
286
+ * @param speed - Speed: 1=slowest, 2-5=medium, 6-13=fast, 14=max
287
+ */
288
+ setSpeed(speed: number): this;
289
+ /**
290
+ * Print configuration label (useful for testing)
291
+ */
292
+ printConfigLabel(): this;
293
+ /**
294
+ * Calibrate sensors
295
+ */
296
+ calibrate(): this;
297
+ /**
298
+ * Reset printer
299
+ */
300
+ reset(): this;
301
+ /**
302
+ * Get all commands as string
303
+ */
304
+ getCommands(): string;
305
+ /**
306
+ * Get commands as buffer for sending to printer
307
+ */
308
+ getBuffer(): Uint8Array;
309
+ /**
310
+ * Get raw command list
311
+ */
312
+ getCommandList(): string[];
313
+ /**
314
+ * Clear all commands
315
+ */
316
+ resetCommands(): this;
317
+ /**
318
+ * Print label (end format)
319
+ */
320
+ print(quantity?: number): this;
321
+ /**
322
+ * Escape special characters in field data
323
+ */
324
+ private escapeField;
325
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Printer Drivers Module
3
+ * 打印机驱动模块 - 支持多种打印机协议
4
+ */
5
+ export { EscPos, type EscPosOptions } from './EscPos';
6
+ export { GPrinterDriver, type GPrinterOptions } from './GPrinterDriver';
7
+ export { TsplDriver, type LabelSize, type TextOptions, type BarcodeOptions, type QRCodeOptions, type BoxOptions, type LineOptions, } from './TsplDriver';
8
+ export { ZplDriver, type ZplLabelSize, type ZplTextOptions, type ZplBarcodeOptions, type ZplQRCodeOptions, type ZplBoxOptions, } from './ZplDriver';
9
+ export { CpclDriver, type CPCLPageSize, type CpclTextOptions, type CpclBarcodeOptions, type CpclQRCodeOptions, type CpclLineOptions, type CpclBoxOptions, } from './CpclDriver';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 精简版 GBK 编码数据
3
+ * 包含约 3500 个最常用汉字,覆盖 99% 日常使用场景
4
+ * 使用二分查找,内存占用极低
5
+ */
6
+ export declare const GBK_LITE: number[];
7
+ export declare function binarySearchGbk(unicode: number): number | null;
8
+ export declare function isInCommonRange(unicode: number): boolean;