@connexup/react-native-xprinter 0.1.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 (145) hide show
  1. package/LICENSE +20 -0
  2. package/NativeXPrinter.podspec +23 -0
  3. package/README.md +24 -0
  4. package/android/build.gradle +73 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/libs/printer-lib-3.4.7.aar +0 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/java/com/connexup/xprinter/Errors.kt +11 -0
  9. package/android/src/main/java/com/connexup/xprinter/Util.kt +106 -0
  10. package/android/src/main/java/com/connexup/xprinter/XPrinterPackage.kt +77 -0
  11. package/android/src/main/java/com/connexup/xprinter/esc/Convert.kt +211 -0
  12. package/android/src/main/java/com/connexup/xprinter/esc/XPrinterESCModule.kt +1995 -0
  13. package/android/src/main/java/com/connexup/xprinter/printer/Convert.kt +46 -0
  14. package/android/src/main/java/com/connexup/xprinter/printer/DeviceConnection.kt +14 -0
  15. package/android/src/main/java/com/connexup/xprinter/printer/Printers.kt +153 -0
  16. package/android/src/main/java/com/connexup/xprinter/printer/XPrinterPrinterModule.kt +295 -0
  17. package/android/src/main/java/com/connexup/xprinter/tspl/Convert.kt +151 -0
  18. package/android/src/main/java/com/connexup/xprinter/tspl/XPrinterTSPLModule.kt +1408 -0
  19. package/android/src/main/java/com/connexup/xprinter/utils/XPrinterUtilsModule.kt +54 -0
  20. package/ios/ESC/ESCConvert.swift +283 -0
  21. package/ios/ESC/Models/RCTESCPrintBarCodeRequest.swift +23 -0
  22. package/ios/ESC/Models/RCTESCPrintBitmapRequest.swift +23 -0
  23. package/ios/ESC/Models/RCTESCPrintPDF417Request.swift +27 -0
  24. package/ios/ESC/Models/RCTESCPrintQRCodeRequest.swift +19 -0
  25. package/ios/ESC/Models/RCTESCPrintTableBarcode.swift +23 -0
  26. package/ios/ESC/Models/RCTESCPrintTableRequest.swift +19 -0
  27. package/ios/ESC/Models/RCTESCPrintTableRow.swift +19 -0
  28. package/ios/ESC/Models/RCTESCPrintTextRequest.swift +21 -0
  29. package/ios/ESC/Models/RCTESCPrintTextSizeRequest.swift +17 -0
  30. package/ios/ESC/Models/RCTESCSelectBitmapModelRequest.swift +17 -0
  31. package/ios/ESC/Models/RCTESCSetNetAllRequest.swift +19 -0
  32. package/ios/ESC/Models/RCTESCSetPrintAreaRequest.swift +19 -0
  33. package/ios/ESC/Models/RCTESCSetTextStyleRequest.swift +17 -0
  34. package/ios/ESC/Models/RCTESCWifiConfigRequest.swift +23 -0
  35. package/ios/ESC/NativeXPrinterESC.swift +1339 -0
  36. package/ios/ESC/RCTNativeXPrinterESC.h +10 -0
  37. package/ios/ESC/RCTNativeXPrinterESC.mm +541 -0
  38. package/ios/Errors.swift +11 -0
  39. package/ios/NativeErrorInfo.swift +21 -0
  40. package/ios/Printer/Connecter.swift +214 -0
  41. package/ios/Printer/Models/RCTDeviceConnectStatusChangeEvent.swift +19 -0
  42. package/ios/Printer/Models/RCTNetDevice.swift +21 -0
  43. package/ios/Printer/Models/RCTUSBDevice.swift +17 -0
  44. package/ios/Printer/Models/RCTUpdateUdpNetConfigRequest.swift +21 -0
  45. package/ios/Printer/NativeXPrinterPrinter.swift +209 -0
  46. package/ios/Printer/Printers.swift +59 -0
  47. package/ios/Printer/RCTNativeXPrinterPrinter.h +12 -0
  48. package/ios/Printer/RCTNativeXPrinterPrinter.mm +123 -0
  49. package/ios/PrinterSDK/Headers/CPCLCommand.h +324 -0
  50. package/ios/PrinterSDK/Headers/KDS_Log.h +47 -0
  51. package/ios/PrinterSDK/Headers/LabelDocument.h +32 -0
  52. package/ios/PrinterSDK/Headers/LabelImageTranster.h +19 -0
  53. package/ios/PrinterSDK/Headers/POSBLEManager.h +164 -0
  54. package/ios/PrinterSDK/Headers/POSCommand.h +760 -0
  55. package/ios/PrinterSDK/Headers/POSImageTranster.h +34 -0
  56. package/ios/PrinterSDK/Headers/POSPrinter.h +47 -0
  57. package/ios/PrinterSDK/Headers/POSPrinterSDK.h +13 -0
  58. package/ios/PrinterSDK/Headers/POSWIFIManager.h +162 -0
  59. package/ios/PrinterSDK/Headers/PTable.h +50 -0
  60. package/ios/PrinterSDK/Headers/PrinterProfile.h +28 -0
  61. package/ios/PrinterSDK/Headers/TSCBLEManager.h +142 -0
  62. package/ios/PrinterSDK/Headers/TSCCommand.h +701 -0
  63. package/ios/PrinterSDK/Headers/TSCPrinterSDK.h +15 -0
  64. package/ios/PrinterSDK/Headers/TSCWIFIManager.h +99 -0
  65. package/ios/PrinterSDK/Headers/WIFIConnecter.h +131 -0
  66. package/ios/PrinterSDK/Headers/ZPLCommand.h +372 -0
  67. package/ios/PrinterSDK/libPrinterSDK.a +0 -0
  68. package/ios/TSPL/Models/RCTTSPLBarRequest.swift +19 -0
  69. package/ios/TSPL/Models/RCTTSPLBarcodeRequest.swift +29 -0
  70. package/ios/TSPL/Models/RCTTSPLBitmapCompressionRequest.swift +25 -0
  71. package/ios/TSPL/Models/RCTTSPLBitmapRequest.swift +25 -0
  72. package/ios/TSPL/Models/RCTTSPLBoxRequest.swift +21 -0
  73. package/ios/TSPL/Models/RCTTSPLEraseRequest.swift +19 -0
  74. package/ios/TSPL/Models/RCTTSPLPDFBase64Request.swift +21 -0
  75. package/ios/TSPL/Models/RCTTSPLPutBMPRequest.swift +17 -0
  76. package/ios/TSPL/Models/RCTTSPLQRCodeRequest.swift +29 -0
  77. package/ios/TSPL/Models/RCTTSPLReverseRequest.swift +19 -0
  78. package/ios/TSPL/Models/RCTTSPLTextRequest.swift +25 -0
  79. package/ios/TSPL/NativeXPrinterTSPL.swift +831 -0
  80. package/ios/TSPL/RCTNativeXPrinterTSPL.h +10 -0
  81. package/ios/TSPL/RCTNativeXPrinterTSPL.mm +445 -0
  82. package/ios/TSPL/TSPLConvert.swift +140 -0
  83. package/ios/Utils/Models/RCTCheckIsPureWhiteImageRequest.swift +16 -0
  84. package/ios/Utils/NativeXPrinterUtils.swift +17 -0
  85. package/ios/Utils/RCTNativeXPrinterUtils.h +10 -0
  86. package/ios/Utils/RCTNativeXPrinterUtils.mm +38 -0
  87. package/ios/Utils.swift +126 -0
  88. package/lib/module/esc/NativeXPrinterESC.js +218 -0
  89. package/lib/module/esc/NativeXPrinterESC.js.map +1 -0
  90. package/lib/module/esc/index.js +324 -0
  91. package/lib/module/esc/index.js.map +1 -0
  92. package/lib/module/index.js +8 -0
  93. package/lib/module/index.js.map +1 -0
  94. package/lib/module/package.json +1 -0
  95. package/lib/module/printer/NativeXPrinterPrinter.js +30 -0
  96. package/lib/module/printer/NativeXPrinterPrinter.js.map +1 -0
  97. package/lib/module/printer/index.js +110 -0
  98. package/lib/module/printer/index.js.map +1 -0
  99. package/lib/module/tspl/NativeXPrinterTSPL.js +143 -0
  100. package/lib/module/tspl/NativeXPrinterTSPL.js.map +1 -0
  101. package/lib/module/tspl/index.js +347 -0
  102. package/lib/module/tspl/index.js.map +1 -0
  103. package/lib/module/type.js +12 -0
  104. package/lib/module/type.js.map +1 -0
  105. package/lib/module/util.js +4 -0
  106. package/lib/module/util.js.map +1 -0
  107. package/lib/module/utils/NativeXPrinterUtils.js +5 -0
  108. package/lib/module/utils/NativeXPrinterUtils.js.map +1 -0
  109. package/lib/module/utils/index.js +17 -0
  110. package/lib/module/utils/index.js.map +1 -0
  111. package/lib/typescript/package.json +1 -0
  112. package/lib/typescript/src/esc/NativeXPrinterESC.d.ts +343 -0
  113. package/lib/typescript/src/esc/NativeXPrinterESC.d.ts.map +1 -0
  114. package/lib/typescript/src/esc/index.d.ts +122 -0
  115. package/lib/typescript/src/esc/index.d.ts.map +1 -0
  116. package/lib/typescript/src/index.d.ts +6 -0
  117. package/lib/typescript/src/index.d.ts.map +1 -0
  118. package/lib/typescript/src/printer/NativeXPrinterPrinter.d.ts +61 -0
  119. package/lib/typescript/src/printer/NativeXPrinterPrinter.d.ts.map +1 -0
  120. package/lib/typescript/src/printer/index.d.ts +32 -0
  121. package/lib/typescript/src/printer/index.d.ts.map +1 -0
  122. package/lib/typescript/src/tspl/NativeXPrinterTSPL.d.ts +261 -0
  123. package/lib/typescript/src/tspl/NativeXPrinterTSPL.d.ts.map +1 -0
  124. package/lib/typescript/src/tspl/index.d.ts +128 -0
  125. package/lib/typescript/src/tspl/index.d.ts.map +1 -0
  126. package/lib/typescript/src/type.d.ts +9 -0
  127. package/lib/typescript/src/type.d.ts.map +1 -0
  128. package/lib/typescript/src/util.d.ts +2 -0
  129. package/lib/typescript/src/util.d.ts.map +1 -0
  130. package/lib/typescript/src/utils/NativeXPrinterUtils.d.ts +10 -0
  131. package/lib/typescript/src/utils/NativeXPrinterUtils.d.ts.map +1 -0
  132. package/lib/typescript/src/utils/index.d.ts +9 -0
  133. package/lib/typescript/src/utils/index.d.ts.map +1 -0
  134. package/package.json +178 -0
  135. package/src/esc/NativeXPrinterESC.ts +516 -0
  136. package/src/esc/index.ts +489 -0
  137. package/src/index.ts +5 -0
  138. package/src/printer/NativeXPrinterPrinter.ts +84 -0
  139. package/src/printer/index.ts +160 -0
  140. package/src/tspl/NativeXPrinterTSPL.ts +388 -0
  141. package/src/tspl/index.ts +535 -0
  142. package/src/type.ts +11 -0
  143. package/src/util.ts +1 -0
  144. package/src/utils/NativeXPrinterUtils.ts +14 -0
  145. package/src/utils/index.ts +27 -0
@@ -0,0 +1,489 @@
1
+ import {
2
+ Alignment,
3
+ BMPModel,
4
+ BMPType,
5
+ CharSet,
6
+ CutModel,
7
+ DEFAULT_LINE_COUNT,
8
+ DEFAULT_TEXT_ALIGNMENT,
9
+ DEFAULT_TEXT_ATTRIBUTE,
10
+ Direction,
11
+ FontType,
12
+ InternationCharacterSet,
13
+ NativeXPrinterESC,
14
+ type PrintBarCodeRequest,
15
+ type PrintBitmapRequest,
16
+ PrinterCheckType,
17
+ type PrintPDF417Request,
18
+ type PrintQRCodeRequest,
19
+ type PrintTableRequest,
20
+ type PrintTextRequest,
21
+ type PrintTextSizeRequest,
22
+ type SelectBitmapModelRequest,
23
+ type SetNetAllRequest,
24
+ type SetPrintAreaRequest,
25
+ type SetTextStyleRequest,
26
+ type Spec,
27
+ TextAttribute,
28
+ type WifiConfigRequest,
29
+ } from './NativeXPrinterESC';
30
+ import { replaceImagePath } from '../util';
31
+ import { XPrinterPCLExecutor } from '../type';
32
+
33
+ export class XPrinterESC
34
+ implements Omit<Spec, 'getConstants' | 'downloadNVImage'>
35
+ {
36
+ private readonly module: Spec;
37
+
38
+ constructor(module: Spec) {
39
+ this.module = module;
40
+ }
41
+ setCharSet = async (connectInfo: string, charSet: CharSet) => {
42
+ return this.module.setCharSet(connectInfo, charSet);
43
+ };
44
+
45
+ selectInternationCharacterSets = async (
46
+ connectInfo: string,
47
+ n: InternationCharacterSet
48
+ ) => {
49
+ return this.module.selectInternationCharacterSets(connectInfo, n);
50
+ };
51
+
52
+ isConnect = async (connectInfo: string) => {
53
+ return this.module.isConnect(connectInfo);
54
+ };
55
+
56
+ initializePrinter = async (connectInfo: string) => {
57
+ return this.module.initializePrinter(connectInfo);
58
+ };
59
+
60
+ printString = async (connectInfo: string, data: string) => {
61
+ return this.module.printString(connectInfo, data);
62
+ };
63
+
64
+ printTextSize = async (
65
+ connectInfo: string,
66
+ payload: PrintTextSizeRequest
67
+ ) => {
68
+ return this.module.printTextSize(connectInfo, payload);
69
+ };
70
+
71
+ printTextAttribute = async (
72
+ connectInfo: string,
73
+ data: string,
74
+ attribute: TextAttribute = DEFAULT_TEXT_ATTRIBUTE
75
+ ) => {
76
+ return this.module.printTextAttribute(connectInfo, data, attribute);
77
+ };
78
+
79
+ printTextAlignment = async (
80
+ connectInfo: string,
81
+ data: string,
82
+ alignment: Alignment = DEFAULT_TEXT_ALIGNMENT
83
+ ) => {
84
+ return this.module.printTextAlignment(connectInfo, data, alignment);
85
+ };
86
+
87
+ printText = async (connectInfo: string, payload: PrintTextRequest) => {
88
+ return this.module.printText(connectInfo, payload);
89
+ };
90
+
91
+ printBitmap = async (connectInfo: string, payload: PrintBitmapRequest) => {
92
+ if (!payload.type) {
93
+ payload.type = BMPType.DITHERING;
94
+ }
95
+ if (payload.bitmapPath) {
96
+ payload.bitmapPath = replaceImagePath(payload.bitmapPath);
97
+ }
98
+ return this.module.printBitmap(connectInfo, payload);
99
+ };
100
+
101
+ compressionPrintBitmap = async (
102
+ connectInfo: string,
103
+ payload: PrintBitmapRequest
104
+ ) => {
105
+ if (!payload.type) {
106
+ payload.type = BMPType.DITHERING;
107
+ }
108
+ if (payload.bitmapPath) {
109
+ payload.bitmapPath = replaceImagePath(payload.bitmapPath);
110
+ }
111
+ return this.module.compressionPrintBitmap(connectInfo, payload);
112
+ };
113
+
114
+ printBarCode = async (connectInfo: string, payload: PrintBarCodeRequest) => {
115
+ return this.module.printBarCode(connectInfo, payload);
116
+ };
117
+
118
+ lineFeed = async (
119
+ connectInfo: string,
120
+ lineCount: number = DEFAULT_LINE_COUNT
121
+ ) => {
122
+ return this.module.lineFeed(connectInfo, lineCount);
123
+ };
124
+
125
+ feedDot = async (connectInfo: string, dotCount: number) => {
126
+ return this.module.feedDot(connectInfo, dotCount);
127
+ };
128
+
129
+ printerCheck = async (
130
+ connectInfo: string,
131
+ type: PrinterCheckType,
132
+ timeout: number
133
+ ) => {
134
+ return this.module.printerCheck(connectInfo, type, timeout);
135
+ };
136
+
137
+ printerStatus = async (connectInfo: string) => {
138
+ return this.module.printerStatus(connectInfo);
139
+ };
140
+
141
+ //only android
142
+ printerStatusII = async (connectInfo: string) => {
143
+ return this.module.printerStatusII(connectInfo);
144
+ };
145
+
146
+ printQRCode = async (connectInfo: string, payload: PrintQRCodeRequest) => {
147
+ return this.module.printQRCode(connectInfo, payload);
148
+ };
149
+
150
+ cutPaper = async (connectInfo: string, model: CutModel) => {
151
+ return this.module.cutPaper(connectInfo, model);
152
+ };
153
+
154
+ cutHalfAndFeed = async (connectInfo: string, distance: number) => {
155
+ return this.module.cutHalfAndFeed(connectInfo, distance);
156
+ };
157
+
158
+ setPrintArea = async (connectInfo: string, payload: SetPrintAreaRequest) => {
159
+ return this.module.setPrintArea(connectInfo, payload);
160
+ };
161
+
162
+ setPageModel = async (connectInfo: string, isOpen: boolean) => {
163
+ return this.module.setPageModel(connectInfo, isOpen);
164
+ };
165
+
166
+ printPageModelData = async (connectInfo: string) => {
167
+ return this.module.printPageModelData(connectInfo);
168
+ };
169
+
170
+ setPrintDirection = async (connectInfo: string, direction: Direction) => {
171
+ return this.module.setPrintDirection(connectInfo, direction);
172
+ };
173
+
174
+ setAbsoluteHorizontal = async (connectInfo: string, position: number) => {
175
+ return this.module.setAbsoluteHorizontal(connectInfo, position);
176
+ };
177
+
178
+ setRelativeHorizontal = async (connectInfo: string, position: number) => {
179
+ return this.module.setRelativeHorizontal(connectInfo, position);
180
+ };
181
+
182
+ setAbsoluteVertical = async (connectInfo: string, position: number) => {
183
+ return this.module.setAbsoluteVertical(connectInfo, position);
184
+ };
185
+
186
+ setRelativeVertical = async (connectInfo: string, position: number) => {
187
+ return this.module.setRelativeVertical(connectInfo, position);
188
+ };
189
+
190
+ setTextStyle = async (connectInfo: string, payload: SetTextStyleRequest) => {
191
+ return this.module.setTextStyle(connectInfo, payload);
192
+ };
193
+
194
+ setAlignment = async (connectInfo: string, alignment: Alignment) => {
195
+ return this.module.setAlignment(connectInfo, alignment);
196
+ };
197
+
198
+ downloadNVImage = async (
199
+ connectInfo: string,
200
+ imagePaths: string[],
201
+ imageWidth: number
202
+ ) => {
203
+ return this.module.downloadNVImage(
204
+ connectInfo,
205
+ imagePaths.map((path) => replaceImagePath(path)).join(','),
206
+ imageWidth
207
+ );
208
+ };
209
+
210
+ clearNVImage = async (connectInfo: string) => {
211
+ return this.module.clearNVImage(connectInfo);
212
+ };
213
+
214
+ printNVImage = async (
215
+ connectInfo: string,
216
+ index: number,
217
+ model: BMPModel
218
+ ) => {
219
+ return this.module.printNVImage(connectInfo, index, model);
220
+ };
221
+
222
+ selectBitmapModel = async (
223
+ connectInfo: string,
224
+ payload: SelectBitmapModelRequest
225
+ ) => {
226
+ return this.module.selectBitmapModel(connectInfo, payload);
227
+ };
228
+
229
+ setLineSpacing = async (connectInfo: string, space: number) => {
230
+ return this.module.setLineSpacing(connectInfo, space);
231
+ };
232
+
233
+ setTurnUpsideDownMode = async (connectInfo: string, on: boolean) => {
234
+ return this.module.setTurnUpsideDownMode(connectInfo, on);
235
+ };
236
+
237
+ selectCodePage = async (connectInfo: string, page: number) => {
238
+ return this.module.selectCodePage(connectInfo, page);
239
+ };
240
+
241
+ selectCharacterFont = async (connectInfo: string, font: FontType) => {
242
+ return this.module.selectCharacterFont(connectInfo, font);
243
+ };
244
+
245
+ printPDF417 = async (connectInfo: string, payload: PrintPDF417Request) => {
246
+ return this.module.printPDF417(connectInfo, payload);
247
+ };
248
+
249
+ printTable = async (connectInfo: string, payload: PrintTableRequest) => {
250
+ return this.module.printTable(connectInfo, payload);
251
+ };
252
+
253
+ wifiConfig = async (connectInfo: string, payload: WifiConfigRequest) => {
254
+ return this.module.wifiConfig(connectInfo, payload);
255
+ };
256
+
257
+ setIp = async (connectInfo: string, ip: string) => {
258
+ return this.module.setIp(connectInfo, ip);
259
+ };
260
+
261
+ setMask = async (connectInfo: string, mask: string) => {
262
+ return this.module.setMask(connectInfo, mask);
263
+ };
264
+
265
+ setGateway = async (connectInfo: string, gateway: string) => {
266
+ return this.module.setGateway(connectInfo, gateway);
267
+ };
268
+
269
+ setNetAll = async (connectInfo: string, payload: SetNetAllRequest) => {
270
+ return this.module.setNetAll(connectInfo, payload);
271
+ };
272
+
273
+ setBluetooth = async (connectInfo: string, name: string, pin: string) => {
274
+ return this.module.setBluetooth(connectInfo, name, pin);
275
+ };
276
+
277
+ getSerialNumber = async (connectInfo: string) => {
278
+ return this.module.getSerialNumber(connectInfo);
279
+ };
280
+ }
281
+
282
+ export const xPrinterESC = new XPrinterESC(NativeXPrinterESC);
283
+
284
+ export class XPrinterESCExecutor extends XPrinterPCLExecutor {
285
+ setCharSet = async (charSet: CharSet) => {
286
+ return xPrinterESC.setCharSet(this.connectInfo, charSet);
287
+ };
288
+
289
+ selectInternationCharacterSets = async (n: InternationCharacterSet) => {
290
+ return xPrinterESC.selectInternationCharacterSets(this.connectInfo, n);
291
+ };
292
+
293
+ isConnect = async () => {
294
+ return xPrinterESC.isConnect(this.connectInfo);
295
+ };
296
+
297
+ initializePrinter = async () => {
298
+ return xPrinterESC.initializePrinter(this.connectInfo);
299
+ };
300
+
301
+ printString = async (data: string) => {
302
+ return xPrinterESC.printString(this.connectInfo, data);
303
+ };
304
+
305
+ printTextSize = async (payload: PrintTextSizeRequest) => {
306
+ return xPrinterESC.printTextSize(this.connectInfo, payload);
307
+ };
308
+
309
+ printTextAttribute = async (data: string, attribute?: TextAttribute) => {
310
+ return xPrinterESC.printTextAttribute(this.connectInfo, data, attribute);
311
+ };
312
+
313
+ printTextAlignment = async (data: string, alignment?: Alignment) => {
314
+ return xPrinterESC.printTextAlignment(this.connectInfo, data, alignment);
315
+ };
316
+
317
+ printText = async (payload: PrintTextRequest) => {
318
+ return xPrinterESC.printText(this.connectInfo, payload);
319
+ };
320
+
321
+ printBitmap = async (payload: PrintBitmapRequest) => {
322
+ if (!payload.type) {
323
+ payload.type = BMPType.DITHERING;
324
+ }
325
+ if (payload.bitmapPath) {
326
+ payload.bitmapPath = replaceImagePath(payload.bitmapPath);
327
+ }
328
+ return xPrinterESC.printBitmap(this.connectInfo, payload);
329
+ };
330
+
331
+ compressionPrintBitmap = async (payload: PrintBitmapRequest) => {
332
+ if (!payload.type) {
333
+ payload.type = BMPType.DITHERING;
334
+ }
335
+ if (payload.bitmapPath) {
336
+ payload.bitmapPath = replaceImagePath(payload.bitmapPath);
337
+ }
338
+ return xPrinterESC.compressionPrintBitmap(this.connectInfo, payload);
339
+ };
340
+
341
+ printBarCode = async (payload: PrintBarCodeRequest) => {
342
+ return xPrinterESC.printBarCode(this.connectInfo, payload);
343
+ };
344
+
345
+ lineFeed = async (lineCount?: number) => {
346
+ return xPrinterESC.lineFeed(this.connectInfo, lineCount);
347
+ };
348
+
349
+ feedDot = async (dotCount: number) => {
350
+ return xPrinterESC.feedDot(this.connectInfo, dotCount);
351
+ };
352
+
353
+ printerCheck = async (type: PrinterCheckType, timeout: number) => {
354
+ return xPrinterESC.printerCheck(this.connectInfo, type, timeout);
355
+ };
356
+
357
+ printerStatus = async () => {
358
+ return xPrinterESC.printerStatus(this.connectInfo);
359
+ };
360
+
361
+ //only android
362
+ printerStatusII = async () => {
363
+ return xPrinterESC.printerStatusII(this.connectInfo);
364
+ };
365
+
366
+ printQRCode = async (payload: PrintQRCodeRequest) => {
367
+ return xPrinterESC.printQRCode(this.connectInfo, payload);
368
+ };
369
+
370
+ cutPaper = async (model: CutModel) => {
371
+ return xPrinterESC.cutPaper(this.connectInfo, model);
372
+ };
373
+
374
+ cutHalfAndFeed = async (distance: number) => {
375
+ return xPrinterESC.cutHalfAndFeed(this.connectInfo, distance);
376
+ };
377
+
378
+ setPrintArea = async (payload: SetPrintAreaRequest) => {
379
+ return xPrinterESC.setPrintArea(this.connectInfo, payload);
380
+ };
381
+
382
+ setPageModel = async (isOpen: boolean) => {
383
+ return xPrinterESC.setPageModel(this.connectInfo, isOpen);
384
+ };
385
+
386
+ printPageModelData = async () => {
387
+ return xPrinterESC.printPageModelData(this.connectInfo);
388
+ };
389
+
390
+ setPrintDirection = async (direction: Direction) => {
391
+ return xPrinterESC.setPrintDirection(this.connectInfo, direction);
392
+ };
393
+
394
+ setAbsoluteHorizontal = async (position: number) => {
395
+ return xPrinterESC.setAbsoluteHorizontal(this.connectInfo, position);
396
+ };
397
+
398
+ setRelativeHorizontal = async (position: number) => {
399
+ return xPrinterESC.setRelativeHorizontal(this.connectInfo, position);
400
+ };
401
+
402
+ setAbsoluteVertical = async (position: number) => {
403
+ return xPrinterESC.setAbsoluteVertical(this.connectInfo, position);
404
+ };
405
+
406
+ setRelativeVertical = async (position: number) => {
407
+ return xPrinterESC.setRelativeVertical(this.connectInfo, position);
408
+ };
409
+
410
+ setTextStyle = async (payload: SetTextStyleRequest) => {
411
+ return xPrinterESC.setTextStyle(this.connectInfo, payload);
412
+ };
413
+
414
+ setAlignment = async (alignment: Alignment) => {
415
+ return xPrinterESC.setAlignment(this.connectInfo, alignment);
416
+ };
417
+
418
+ downloadNVImage = async (imagePaths: string[], imageWidth: number) => {
419
+ return xPrinterESC.downloadNVImage(
420
+ this.connectInfo,
421
+ imagePaths,
422
+ imageWidth
423
+ );
424
+ };
425
+
426
+ clearNVImage = async () => {
427
+ return xPrinterESC.clearNVImage(this.connectInfo);
428
+ };
429
+
430
+ printNVImage = async (index: number, model: BMPModel) => {
431
+ return xPrinterESC.printNVImage(this.connectInfo, index, model);
432
+ };
433
+
434
+ selectBitmapModel = async (payload: SelectBitmapModelRequest) => {
435
+ return xPrinterESC.selectBitmapModel(this.connectInfo, payload);
436
+ };
437
+
438
+ setLineSpacing = async (space: number) => {
439
+ return xPrinterESC.setLineSpacing(this.connectInfo, space);
440
+ };
441
+
442
+ setTurnUpsideDownMode = async (on: boolean) => {
443
+ return xPrinterESC.setTurnUpsideDownMode(this.connectInfo, on);
444
+ };
445
+
446
+ selectCodePage = async (page: number) => {
447
+ return xPrinterESC.selectCodePage(this.connectInfo, page);
448
+ };
449
+
450
+ selectCharacterFont = async (font: FontType) => {
451
+ return xPrinterESC.selectCharacterFont(this.connectInfo, font);
452
+ };
453
+
454
+ printPDF417 = async (payload: PrintPDF417Request) => {
455
+ return xPrinterESC.printPDF417(this.connectInfo, payload);
456
+ };
457
+
458
+ printTable = async (payload: PrintTableRequest) => {
459
+ return xPrinterESC.printTable(this.connectInfo, payload);
460
+ };
461
+
462
+ wifiConfig = async (payload: WifiConfigRequest) => {
463
+ return xPrinterESC.wifiConfig(this.connectInfo, payload);
464
+ };
465
+
466
+ setIp = async (ip: string) => {
467
+ return xPrinterESC.setIp(this.connectInfo, ip);
468
+ };
469
+
470
+ setMask = async (mask: string) => {
471
+ return xPrinterESC.setMask(this.connectInfo, mask);
472
+ };
473
+
474
+ setGateway = async (gateway: string) => {
475
+ return xPrinterESC.setGateway(this.connectInfo, gateway);
476
+ };
477
+
478
+ setNetAll = async (payload: SetNetAllRequest) => {
479
+ return xPrinterESC.setNetAll(this.connectInfo, payload);
480
+ };
481
+
482
+ setBluetooth = async (name: string, pin: string) => {
483
+ return xPrinterESC.setBluetooth(this.connectInfo, name, pin);
484
+ };
485
+
486
+ getSerialNumber = async () => {
487
+ return xPrinterESC.getSerialNumber(this.connectInfo);
488
+ };
489
+ }
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ export { xPrinterUtils as XPrinterUtils } from './utils';
2
+ export { xPrinterPrinter as XPrinterPrinter, XPrinterDevice } from './printer';
3
+ export { xPrinterESC as XPrinterESC, XPrinterESCExecutor } from './esc';
4
+ export { xPrinterTSPL as XPrinterTSPL, XPrinterTSPLExecutor } from './tspl';
5
+ export { XPrinterPCLExecutor } from './type';
@@ -0,0 +1,84 @@
1
+ import {
2
+ type CodegenTypes,
3
+ type TurboModule,
4
+ TurboModuleRegistry,
5
+ } from 'react-native';
6
+
7
+ export interface Spec extends TurboModule {
8
+ //only android
9
+ getUsbDevices: () => Promise<USBDevice[]>;
10
+ searchNetDevice: () => Promise<void>;
11
+ udpNetConfig: (request: UpdateUdpNetConfigRequest) => Promise<void>;
12
+ //serial port,boudrate
13
+ connect: (
14
+ connectInfo: string,
15
+ deviceType: DeviceType,
16
+ //only android support sync
17
+ sync: boolean
18
+ ) => Promise<void>;
19
+ disconnect: (connectInfo: string) => Promise<void>;
20
+ isConnect: (connectInfo: string) => Promise<boolean>;
21
+ getPrinterPCL: (connectInfo: string) => Promise<PCLType>;
22
+ setPrinterPCL: (connectInfo: string, pcl: PCLType) => Promise<void>;
23
+ readonly onDeviceConnectStatusChange: CodegenTypes.EventEmitter<DeviceConnectStatusChangeEvent>;
24
+ readonly onSearchNetDeviceFound: CodegenTypes.EventEmitter<NetDevice>;
25
+ }
26
+
27
+ export const NativeXPrinterPrinter = TurboModuleRegistry.getEnforcing<Spec>(
28
+ 'NativeXPrinterPrinter'
29
+ );
30
+
31
+ export enum ConnectStatus {
32
+ CONNECT_SUCCESS = 'CONNECT_SUCCESS',
33
+ CONNECT_FAIL = 'CONNECT_FAIL',
34
+ DISCONNECT = 'DISCONNECT',
35
+ SEND_FAIL = 'SEND_FAIL',
36
+ CONNECT_INTERRUPT = 'CONNECT_INTERRUPT',
37
+ USB_ATTACHED = 'USB_ATTACHED',
38
+ USB_DETACHED = 'USB_DETACHED',
39
+ BLUETOOTH_INTERRUPT = 'BLUETOOTH_INTERRUPT',
40
+ UNKNOWN = 'UNKNOWN',
41
+ }
42
+
43
+ export enum DeviceType {
44
+ USB = 'USB',
45
+ BLUETOOTH = 'BLUETOOTH',
46
+ ETHERNET = 'ETHERNET',
47
+ SERIAL = 'SERIAL',
48
+ }
49
+
50
+ export enum PCLType {
51
+ ESC = 'ESC',
52
+ TSPL = 'TSPL',
53
+ // CPCL = 'CPCL',
54
+ // ZPL = 'ZPL',
55
+ }
56
+
57
+ export interface USBDevice {
58
+ deviceId: number;
59
+ deviceName: string;
60
+ manufacturerName: string | null;
61
+ }
62
+
63
+ export interface UpdateUdpNetConfigRequest {
64
+ macAddress: string;
65
+ ipAddress: string;
66
+ mask: string;
67
+ gateway: string;
68
+ dhcp: boolean;
69
+ }
70
+
71
+ export interface DeviceConnectStatusChangeEvent {
72
+ code: ConnectStatus;
73
+ connectInfo: string;
74
+ msg?: string;
75
+ debugCode?: number;
76
+ }
77
+
78
+ export interface NetDevice {
79
+ macAddress: string;
80
+ ipAddress: string;
81
+ mask: string;
82
+ gateway: string;
83
+ dhcp: boolean;
84
+ }