forked from januslo/react-native-bluetooth-escpos-printer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreact-native-bluetooth-escpos-printer.d.ts
More file actions
317 lines (281 loc) · 7.48 KB
/
Copy pathreact-native-bluetooth-escpos-printer.d.ts
File metadata and controls
317 lines (281 loc) · 7.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
declare module 'react-native-bluetooth-escpos-printer' {
namespace BluetoothEscposPrinter {
enum DEVICE_WIDTH {
WIDTH_58 = 384,
WIDTH_80 = 576,
}
enum ERROR_CORRECTION {
L = 1,
M = 0,
Q = 3,
H = 2,
}
enum BARCODETYPE {
UPC_A = 65, // 11<=n<=12
UPC_E = 66, // 11<=n<=12
JAN13 = 67, // 12<=n<=12
JAN8 = 68, // 7<=n<=8
CODE39 = 69, // 1<=n<=255
ITF = 70, // 1<=n<=255(even numbers)
CODABAR = 71, // 1<=n<=255
CODE93 = 72, // 1<=n<=255
CODE128 = 73, // 2<=n<=255
}
enum ROTATION {
OFF = 0,
ON = 1,
}
enum ALIGN {
LEFT = 0,
CENTER = 1,
RIGHT = 2,
}
interface IPrintTextOptions {
encoding?: string; // Text encoding. Default: GBK
codepage?: number; // Codepage using. Default 0
widthtimes?: number; // Text font mul times in width. Default 0
heigthtimes?: number; // Text font mul times in height. Default 0
fonttype?: number; // Text font type. Default 0
}
interface IPrintPicOptions {
width: number;
left: number;
}
function printerInit(): Promise<void>;
/**
* Printer the buffer data and feed (feed lines).
*/
function printAndFeed(feed: number): Promise<void>;
/**
* Set the printer left spaces.
*/
function printerLeftSpace(space: number): Promise<void>;
/**
* Set the spaces between lines.
*/
function printerLineSpace(space: number): Promise<void>;
/**
* Set the spaces between lines.
*/
function printerLineSpace(space: number): Promise<void>;
/**
* Set the underline of the text
*
* @param line 0: off, 1: on, 2: deeper.
*/
function printerUnderLine(line: 0 | 1 | 2): Promise<void>;
function selfTest(callback: (isConnected: boolean) => void): void;
/**
* Set the printer alignment.
* Does not work on printPic() method.
*/
function printerAlign(align: ALIGN): Promise<void>;
function printText(text: string, options: IPrintTextOptions): Promise<void>;
/**
* @param columnWidths Configs the width of each column, calculate by english character length.
* Ex: the width of 'abcdef' is 5, the width of '中文' is 4.
* @param columnAligns => Alignment of each column.
* @param columnTexts => The texts of each colunm to print.
* @param options text print config options, the same of printText() options.
*/
function printColumn(
columnWidths: Array<number>,
columnAligns: Array<ALIGN>,
columnTexts: Array<string>,
options: IPrintTextOptions
): Promise<void>;
function setWidth(width: number): Promise<void>;
/**
* Prints the image which is encoded by base64, without schema.
* options: contains the params that may use in printing pic.
*
* width: the pic width, basic on devices width(dots, 58mm-384);
* left: the left padding of the pic for the printing position adjustment.
*/
function printPic(base64encodeStr: string, options: IPrintPicOptions): Promise<void>;
function rotate(): Promise<void>;
function setBlob(weight: number): Promise<void>;
function printQRCode(content: string, size: number, correctionLevel: number): Promise<void>;
function printBarCode(
str: string,
nType: number,
nWidthX: number,
nHeight: number,
nHriFontType: number,
nHriFontPosition: number
): Promise<void>;
function openDrawer(nMode: number, nTime1: number, nTime2: number): Promise<void>;
function cutOnePoint(): Promise<void>;
}
namespace BluetoothManager {
const EVENT_DEVICE_ALREADY_PAIRED = 'EVENT_DEVICE_ALREADY_PAIRED';
const EVENT_DEVICE_FOUND = 'EVENT_DEVICE_FOUND';
const EVENT_CONNECTION_LOST = 'EVENT_CONNECTION_LOST';
const EVENT_BLUETOOTH_NOT_SUPPORT = 'EVENT_BLUETOOTH_NOT_SUPPORT';
function isBluetoothEnabled(): Promise<boolean>;
function enableBluetooth(): Promise<string[] | null>;
function disableBluetooth(): Promise<boolean>;
/**
* Return the address of the currently connected device
*/
function getConnectedDeviceAddress(): Promise<void>;
// TODO: change string to object
function scanDevices(): Promise<string>; // '{found:[],paired:[]}'
function connect(address: string): Promise<string>;
function disconnect(address: string): Promise<void>;
}
namespace BluetoothTscPrinter {
enum DIRECTION {
FORWARD = 0,
BACKWARD = 1,
}
enum DENSITY {
DNESITY0 = 0,
DNESITY1 = 1,
DNESITY2 = 2,
DNESITY3 = 3,
DNESITY4 = 4,
DNESITY5 = 5,
DNESITY6 = 6,
DNESITY7 = 7,
DNESITY8 = 8,
DNESITY9 = 9,
DNESITY10 = 10,
DNESITY11 = 11,
DNESITY12 = 12,
DNESITY13 = 13,
DNESITY14 = 14,
DNESITY15 = 15,
}
enum BARCODETYPE {
CODE128 = '128',
CODE128M = '128M',
EAN128 = 'EAN128',
ITF25 = '25',
ITF25C = '25C',
CODE39 = '39',
CODE39C = '39C',
CODE39S = '39S',
CODE93 = '93',
EAN13 = 'EAN13',
EAN13_2 = 'EAN13+2',
EAN13_5 = 'EAN13+5',
EAN8 = 'EAN8',
EAN8_2 = 'EAN8+2',
EAN8_5 = 'EAN8+5',
CODABAR = 'CODA',
POST = 'POST',
UPCA = 'EAN13',
UPCA_2 = 'EAN13+2',
UPCA_5 = 'EAN13+5',
UPCE = 'EAN13',
UPCE_2 = 'EAN13+2',
UPCE_5 = 'EAN13+5',
CPOST = 'CPOST',
MSI = 'MSI',
MSIC = 'MSIC',
PLESSEY = 'PLESSEY',
ITF14 = 'ITF14',
EAN14 = 'EAN14',
}
enum FONTTYPE {
FONT_1 = '1',
FONT_2 = '2',
FONT_3 = '3',
FONT_4 = '4',
FONT_5 = '5',
FONT_6 = '6',
FONT_7 = '7',
FONT_8 = '8',
SIMPLIFIED_CHINESE = 'TSS24.BF2',
TRADITIONAL_CHINESE = 'TST24.BF2',
KOREAN = 'K',
}
enum EEC {
LEVEL_L = 'L',
LEVEL_M = 'M',
LEVEL_Q = 'Q',
LEVEL_H = 'H',
}
enum ROTATION {
ROTATION_0 = 0,
ROTATION_90 = 90,
ROTATION_180 = 180,
ROTATION_270 = 270,
}
enum FONTMUL {
MUL_1 = 1,
MUL_2 = 2,
MUL_3 = 3,
MUL_4 = 4,
MUL_5 = 5,
MUL_6 = 6,
MUL_7 = 7,
MUL_8 = 8,
MUL_9 = 9,
MUL_10 = 10,
}
enum BITMAP_MODE {
OVERWRITE = 0,
OR = 1,
XOR = 2,
}
enum PRINT_SPEED {
SPEED1DIV5 = 1,
SPEED2 = 2,
SPEED3 = 3,
SPEED4 = 4,
}
enum TEAR {
ON = 'ON',
OFF = 'OFF',
}
enum READABLE {
DISABLE = 0,
ENABLE = 1,
}
interface IPrintLabelOptions {
width?: number;
height?: number;
gap?: number;
direction?: DIRECTION;
reference?: [number, number];
tear?: TEAR;
sound?: number;
text?: Array<{
text: string;
x: number;
y: number;
fonttype: FONTTYPE;
rotation: ROTATION;
xscal: FONTMUL;
yscal: FONTMUL;
}>;
qrcode?: Array<{
x: number;
y: number;
level: EEC;
width: number;
rotation: ROTATION;
code: string;
}>;
barcode?: Array<{
x: number;
y: number;
type: BARCODETYPE;
height: number;
readable: number;
rotation: ROTATION;
code: string;
}>;
image?: Array<{
x: number;
y: number;
mode: BITMAP_MODE;
width: number;
image: string;
}>;
}
function printLabel(options: IPrintLabelOptions): Promise<void>;
}
}