taro-bluetooth-print 2.8.4 → 2.9.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/CHANGELOG.md +18 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/types/core/BluetoothPrinter.d.ts +21 -4
- package/dist/types/errors/CommandBuildError.d.ts +40 -0
- package/dist/types/errors/ConnectionError.d.ts +45 -0
- package/dist/types/errors/PrintJobError.d.ts +42 -0
- package/dist/types/errors/index.d.ts +9 -0
- package/dist/types/factory/PrinterFactory.d.ts +108 -0
- package/dist/types/factory/index.d.ts +6 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/services/interfaces/ICommandBuilder.d.ts +123 -0
- package/dist/types/services/interfaces/IConnectionManager.d.ts +49 -0
- package/dist/types/services/interfaces/IPrintJobManager.d.ts +67 -0
- package/dist/types/services/interfaces/index.d.ts +6 -233
- package/package.json +1 -1
- package/src/core/BluetoothPrinter.ts +47 -50
- package/src/errors/CommandBuildError.ts +72 -0
- package/src/errors/ConnectionError.ts +78 -0
- package/src/errors/PrintJobError.ts +75 -0
- package/src/errors/index.ts +10 -0
- package/src/factory/PrinterFactory.ts +139 -0
- package/src/factory/index.ts +12 -0
- package/src/index.ts +11 -0
- package/src/services/interfaces/ICommandBuilder.ts +145 -0
- package/src/services/interfaces/IConnectionManager.ts +58 -0
- package/src/services/interfaces/IPrintJobManager.ts +83 -0
- package/src/services/interfaces/index.ts +5 -265
|
@@ -2,271 +2,11 @@
|
|
|
2
2
|
* Service Interfaces
|
|
3
3
|
*
|
|
4
4
|
* Defines the interfaces for the core services used by BluetoothPrinter
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { IAdapterOptions, IQrOptions, PrinterState, IPrinterAdapter } from '@/types';
|
|
8
|
-
import { TextAlign, TextStyle } from '@/formatter';
|
|
9
|
-
import { BarcodeOptions } from '@/barcode';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Connection Manager Interface
|
|
13
|
-
*
|
|
14
|
-
* Manages Bluetooth device connections
|
|
15
|
-
*/
|
|
16
|
-
export interface IConnectionManager {
|
|
17
|
-
/**
|
|
18
|
-
* Connects to a Bluetooth device
|
|
19
|
-
*
|
|
20
|
-
* @param deviceId - Bluetooth device ID
|
|
21
|
-
* @param options - Connection options
|
|
22
|
-
* @returns Promise<void>
|
|
23
|
-
*/
|
|
24
|
-
connect(deviceId: string, options?: { retries?: number; timeout?: number }): Promise<void>;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Disconnects from the current device
|
|
28
|
-
*
|
|
29
|
-
* @returns Promise<void>
|
|
30
|
-
*/
|
|
31
|
-
disconnect(): Promise<void>;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Checks if a device is connected
|
|
35
|
-
*
|
|
36
|
-
* @returns boolean - True if connected, false otherwise
|
|
37
|
-
*/
|
|
38
|
-
isConnected(): boolean;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Gets the current device ID
|
|
42
|
-
*
|
|
43
|
-
* @returns string | null - Device ID or null if not connected
|
|
44
|
-
*/
|
|
45
|
-
getDeviceId(): string | null;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Gets the current connection state
|
|
49
|
-
*
|
|
50
|
-
* @returns PrinterState - Current state
|
|
51
|
-
*/
|
|
52
|
-
getState(): PrinterState;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Gets the printer adapter instance
|
|
56
|
-
*
|
|
57
|
-
* @returns IPrinterAdapter - Printer adapter
|
|
58
|
-
*/
|
|
59
|
-
getAdapter(): IPrinterAdapter;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Print Job Manager Interface
|
|
64
|
-
*
|
|
65
|
-
* Manages print jobs, including pause/resume/cancel functionality
|
|
66
|
-
*/
|
|
67
|
-
export interface IPrintJobManager {
|
|
68
|
-
/**
|
|
69
|
-
* Starts a print job
|
|
70
|
-
*
|
|
71
|
-
* @param buffer - Print data buffer
|
|
72
|
-
* @returns Promise<void>
|
|
73
|
-
*/
|
|
74
|
-
start(buffer: Uint8Array, options?: { jobId?: string }): Promise<void>;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Pauses the current print job
|
|
78
|
-
*/
|
|
79
|
-
pause(): void;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Resumes a paused print job
|
|
83
|
-
*
|
|
84
|
-
* @returns Promise<void>
|
|
85
|
-
*/
|
|
86
|
-
resume(jobId?: string): Promise<void>;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Cancels the current print job
|
|
90
|
-
*/
|
|
91
|
-
cancel(): void;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Gets the number of bytes remaining to print
|
|
95
|
-
*
|
|
96
|
-
* @returns number - Bytes remaining
|
|
97
|
-
*/
|
|
98
|
-
remaining(): number;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Checks if the print job is paused
|
|
102
|
-
*
|
|
103
|
-
* @returns boolean - True if paused, false otherwise
|
|
104
|
-
*/
|
|
105
|
-
isPaused(): boolean;
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Checks if a print job is in progress
|
|
109
|
-
*
|
|
110
|
-
* @returns boolean - True if in progress, false otherwise
|
|
111
|
-
*/
|
|
112
|
-
isInProgress(): boolean;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Sets adapter options for write operations
|
|
116
|
-
*
|
|
117
|
-
* @param options - Adapter options
|
|
118
|
-
*/
|
|
119
|
-
setOptions(options: IAdapterOptions): void;
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Sets the progress callback
|
|
123
|
-
*
|
|
124
|
-
* @param callback - Progress callback function
|
|
125
|
-
*/
|
|
126
|
-
setProgressCallback(callback?: (sent: number, total: number) => void): void;
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Sets the job state change callback
|
|
130
|
-
*
|
|
131
|
-
* @param callback - Job state change callback function
|
|
132
|
-
*/
|
|
133
|
-
setJobStateCallback(
|
|
134
|
-
callback?: (state: 'in-progress' | 'paused' | 'completed' | 'cancelled') => void
|
|
135
|
-
): void;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Command Builder Interface
|
|
140
5
|
*
|
|
141
|
-
*
|
|
6
|
+
* @packageDocumentation
|
|
142
7
|
*/
|
|
143
|
-
export interface ICommandBuilder {
|
|
144
|
-
/**
|
|
145
|
-
* Adds text to the print queue
|
|
146
|
-
*
|
|
147
|
-
* @param content - Text content
|
|
148
|
-
* @param encoding - Text encoding
|
|
149
|
-
* @returns this - For method chaining
|
|
150
|
-
*/
|
|
151
|
-
text(content: string, encoding?: string): this;
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Adds line feeds to the print queue
|
|
155
|
-
*
|
|
156
|
-
* @param lines - Number of lines to feed
|
|
157
|
-
* @returns this - For method chaining
|
|
158
|
-
*/
|
|
159
|
-
feed(lines?: number): this;
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Adds a paper cut command to the print queue
|
|
163
|
-
*
|
|
164
|
-
* @returns this - For method chaining
|
|
165
|
-
*/
|
|
166
|
-
cut(): this;
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Adds an image to the print queue
|
|
170
|
-
*
|
|
171
|
-
* @param data - Image data as Uint8Array
|
|
172
|
-
* @param width - Image width
|
|
173
|
-
* @param height - Image height
|
|
174
|
-
* @returns this - For method chaining
|
|
175
|
-
*/
|
|
176
|
-
image(data: Uint8Array, width: number, height: number): this;
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Adds a QR code to the print queue
|
|
180
|
-
*
|
|
181
|
-
* @param content - QR code content
|
|
182
|
-
* @param options - QR code options
|
|
183
|
-
* @returns this - For method chaining
|
|
184
|
-
*/
|
|
185
|
-
qr(content: string, options?: IQrOptions): this;
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Clears the print queue
|
|
189
|
-
*
|
|
190
|
-
* @returns this - For method chaining
|
|
191
|
-
*/
|
|
192
|
-
clear(): this;
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Sets text alignment
|
|
196
|
-
*
|
|
197
|
-
* @param alignment - Text alignment (left, center, right)
|
|
198
|
-
* @returns this - For method chaining
|
|
199
|
-
*/
|
|
200
|
-
align(alignment: TextAlign): this;
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Sets character size (width and height scale)
|
|
204
|
-
*
|
|
205
|
-
* @param width - Width scale factor (1-8)
|
|
206
|
-
* @param height - Height scale factor (1-8)
|
|
207
|
-
* @returns this - For method chaining
|
|
208
|
-
*/
|
|
209
|
-
setSize(width: number, height: number): this;
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Sets bold text mode
|
|
213
|
-
*
|
|
214
|
-
* @param enabled - Enable or disable bold
|
|
215
|
-
* @returns this - For method chaining
|
|
216
|
-
*/
|
|
217
|
-
setBold(enabled: boolean): this;
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Sets underline text mode
|
|
221
|
-
*
|
|
222
|
-
* @param enabled - Enable or disable underline
|
|
223
|
-
* @returns this - For method chaining
|
|
224
|
-
*/
|
|
225
|
-
setUnderline(enabled: boolean): this;
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Sets inverse printing mode (white on black)
|
|
229
|
-
*
|
|
230
|
-
* @param enabled - Enable or disable inverse
|
|
231
|
-
* @returns this - For method chaining
|
|
232
|
-
*/
|
|
233
|
-
setInverse(enabled: boolean): this;
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Sets multiple text style properties at once
|
|
237
|
-
*
|
|
238
|
-
* @param style - Text style configuration
|
|
239
|
-
* @returns this - For method chaining
|
|
240
|
-
*/
|
|
241
|
-
setStyle(style: TextStyle): this;
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Resets all text formatting to default
|
|
245
|
-
*
|
|
246
|
-
* @returns this - For method chaining
|
|
247
|
-
*/
|
|
248
|
-
resetStyle(): this;
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Adds a 1D barcode to the print queue
|
|
252
|
-
*
|
|
253
|
-
* @param content - Barcode content/data
|
|
254
|
-
* @param options - Barcode options
|
|
255
|
-
* @returns this - For method chaining
|
|
256
|
-
*/
|
|
257
|
-
barcode(content: string, options: BarcodeOptions): this;
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Gets the current buffer
|
|
261
|
-
*
|
|
262
|
-
* @returns Uint8Array - Current print buffer
|
|
263
|
-
*/
|
|
264
|
-
getBuffer(): Uint8Array;
|
|
265
8
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
*/
|
|
271
|
-
getTotalBytes(): number;
|
|
272
|
-
}
|
|
9
|
+
// Re-export individual interfaces for tree-shaking and clear dependencies
|
|
10
|
+
export type { IConnectionManager } from './IConnectionManager';
|
|
11
|
+
export type { IPrintJobManager } from './IPrintJobManager';
|
|
12
|
+
export type { ICommandBuilder } from './ICommandBuilder';
|