@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.
- package/LICENSE +20 -0
- package/NativeXPrinter.podspec +23 -0
- package/README.md +24 -0
- package/android/build.gradle +73 -0
- package/android/gradle.properties +5 -0
- package/android/libs/printer-lib-3.4.7.aar +0 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/connexup/xprinter/Errors.kt +11 -0
- package/android/src/main/java/com/connexup/xprinter/Util.kt +106 -0
- package/android/src/main/java/com/connexup/xprinter/XPrinterPackage.kt +77 -0
- package/android/src/main/java/com/connexup/xprinter/esc/Convert.kt +211 -0
- package/android/src/main/java/com/connexup/xprinter/esc/XPrinterESCModule.kt +1995 -0
- package/android/src/main/java/com/connexup/xprinter/printer/Convert.kt +46 -0
- package/android/src/main/java/com/connexup/xprinter/printer/DeviceConnection.kt +14 -0
- package/android/src/main/java/com/connexup/xprinter/printer/Printers.kt +153 -0
- package/android/src/main/java/com/connexup/xprinter/printer/XPrinterPrinterModule.kt +295 -0
- package/android/src/main/java/com/connexup/xprinter/tspl/Convert.kt +151 -0
- package/android/src/main/java/com/connexup/xprinter/tspl/XPrinterTSPLModule.kt +1408 -0
- package/android/src/main/java/com/connexup/xprinter/utils/XPrinterUtilsModule.kt +54 -0
- package/ios/ESC/ESCConvert.swift +283 -0
- package/ios/ESC/Models/RCTESCPrintBarCodeRequest.swift +23 -0
- package/ios/ESC/Models/RCTESCPrintBitmapRequest.swift +23 -0
- package/ios/ESC/Models/RCTESCPrintPDF417Request.swift +27 -0
- package/ios/ESC/Models/RCTESCPrintQRCodeRequest.swift +19 -0
- package/ios/ESC/Models/RCTESCPrintTableBarcode.swift +23 -0
- package/ios/ESC/Models/RCTESCPrintTableRequest.swift +19 -0
- package/ios/ESC/Models/RCTESCPrintTableRow.swift +19 -0
- package/ios/ESC/Models/RCTESCPrintTextRequest.swift +21 -0
- package/ios/ESC/Models/RCTESCPrintTextSizeRequest.swift +17 -0
- package/ios/ESC/Models/RCTESCSelectBitmapModelRequest.swift +17 -0
- package/ios/ESC/Models/RCTESCSetNetAllRequest.swift +19 -0
- package/ios/ESC/Models/RCTESCSetPrintAreaRequest.swift +19 -0
- package/ios/ESC/Models/RCTESCSetTextStyleRequest.swift +17 -0
- package/ios/ESC/Models/RCTESCWifiConfigRequest.swift +23 -0
- package/ios/ESC/NativeXPrinterESC.swift +1339 -0
- package/ios/ESC/RCTNativeXPrinterESC.h +10 -0
- package/ios/ESC/RCTNativeXPrinterESC.mm +541 -0
- package/ios/Errors.swift +11 -0
- package/ios/NativeErrorInfo.swift +21 -0
- package/ios/Printer/Connecter.swift +214 -0
- package/ios/Printer/Models/RCTDeviceConnectStatusChangeEvent.swift +19 -0
- package/ios/Printer/Models/RCTNetDevice.swift +21 -0
- package/ios/Printer/Models/RCTUSBDevice.swift +17 -0
- package/ios/Printer/Models/RCTUpdateUdpNetConfigRequest.swift +21 -0
- package/ios/Printer/NativeXPrinterPrinter.swift +209 -0
- package/ios/Printer/Printers.swift +59 -0
- package/ios/Printer/RCTNativeXPrinterPrinter.h +12 -0
- package/ios/Printer/RCTNativeXPrinterPrinter.mm +123 -0
- package/ios/PrinterSDK/Headers/CPCLCommand.h +324 -0
- package/ios/PrinterSDK/Headers/KDS_Log.h +47 -0
- package/ios/PrinterSDK/Headers/LabelDocument.h +32 -0
- package/ios/PrinterSDK/Headers/LabelImageTranster.h +19 -0
- package/ios/PrinterSDK/Headers/POSBLEManager.h +164 -0
- package/ios/PrinterSDK/Headers/POSCommand.h +760 -0
- package/ios/PrinterSDK/Headers/POSImageTranster.h +34 -0
- package/ios/PrinterSDK/Headers/POSPrinter.h +47 -0
- package/ios/PrinterSDK/Headers/POSPrinterSDK.h +13 -0
- package/ios/PrinterSDK/Headers/POSWIFIManager.h +162 -0
- package/ios/PrinterSDK/Headers/PTable.h +50 -0
- package/ios/PrinterSDK/Headers/PrinterProfile.h +28 -0
- package/ios/PrinterSDK/Headers/TSCBLEManager.h +142 -0
- package/ios/PrinterSDK/Headers/TSCCommand.h +701 -0
- package/ios/PrinterSDK/Headers/TSCPrinterSDK.h +15 -0
- package/ios/PrinterSDK/Headers/TSCWIFIManager.h +99 -0
- package/ios/PrinterSDK/Headers/WIFIConnecter.h +131 -0
- package/ios/PrinterSDK/Headers/ZPLCommand.h +372 -0
- package/ios/PrinterSDK/libPrinterSDK.a +0 -0
- package/ios/TSPL/Models/RCTTSPLBarRequest.swift +19 -0
- package/ios/TSPL/Models/RCTTSPLBarcodeRequest.swift +29 -0
- package/ios/TSPL/Models/RCTTSPLBitmapCompressionRequest.swift +25 -0
- package/ios/TSPL/Models/RCTTSPLBitmapRequest.swift +25 -0
- package/ios/TSPL/Models/RCTTSPLBoxRequest.swift +21 -0
- package/ios/TSPL/Models/RCTTSPLEraseRequest.swift +19 -0
- package/ios/TSPL/Models/RCTTSPLPDFBase64Request.swift +21 -0
- package/ios/TSPL/Models/RCTTSPLPutBMPRequest.swift +17 -0
- package/ios/TSPL/Models/RCTTSPLQRCodeRequest.swift +29 -0
- package/ios/TSPL/Models/RCTTSPLReverseRequest.swift +19 -0
- package/ios/TSPL/Models/RCTTSPLTextRequest.swift +25 -0
- package/ios/TSPL/NativeXPrinterTSPL.swift +831 -0
- package/ios/TSPL/RCTNativeXPrinterTSPL.h +10 -0
- package/ios/TSPL/RCTNativeXPrinterTSPL.mm +445 -0
- package/ios/TSPL/TSPLConvert.swift +140 -0
- package/ios/Utils/Models/RCTCheckIsPureWhiteImageRequest.swift +16 -0
- package/ios/Utils/NativeXPrinterUtils.swift +17 -0
- package/ios/Utils/RCTNativeXPrinterUtils.h +10 -0
- package/ios/Utils/RCTNativeXPrinterUtils.mm +38 -0
- package/ios/Utils.swift +126 -0
- package/lib/module/esc/NativeXPrinterESC.js +218 -0
- package/lib/module/esc/NativeXPrinterESC.js.map +1 -0
- package/lib/module/esc/index.js +324 -0
- package/lib/module/esc/index.js.map +1 -0
- package/lib/module/index.js +8 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/printer/NativeXPrinterPrinter.js +30 -0
- package/lib/module/printer/NativeXPrinterPrinter.js.map +1 -0
- package/lib/module/printer/index.js +110 -0
- package/lib/module/printer/index.js.map +1 -0
- package/lib/module/tspl/NativeXPrinterTSPL.js +143 -0
- package/lib/module/tspl/NativeXPrinterTSPL.js.map +1 -0
- package/lib/module/tspl/index.js +347 -0
- package/lib/module/tspl/index.js.map +1 -0
- package/lib/module/type.js +12 -0
- package/lib/module/type.js.map +1 -0
- package/lib/module/util.js +4 -0
- package/lib/module/util.js.map +1 -0
- package/lib/module/utils/NativeXPrinterUtils.js +5 -0
- package/lib/module/utils/NativeXPrinterUtils.js.map +1 -0
- package/lib/module/utils/index.js +17 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/esc/NativeXPrinterESC.d.ts +343 -0
- package/lib/typescript/src/esc/NativeXPrinterESC.d.ts.map +1 -0
- package/lib/typescript/src/esc/index.d.ts +122 -0
- package/lib/typescript/src/esc/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +6 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/printer/NativeXPrinterPrinter.d.ts +61 -0
- package/lib/typescript/src/printer/NativeXPrinterPrinter.d.ts.map +1 -0
- package/lib/typescript/src/printer/index.d.ts +32 -0
- package/lib/typescript/src/printer/index.d.ts.map +1 -0
- package/lib/typescript/src/tspl/NativeXPrinterTSPL.d.ts +261 -0
- package/lib/typescript/src/tspl/NativeXPrinterTSPL.d.ts.map +1 -0
- package/lib/typescript/src/tspl/index.d.ts +128 -0
- package/lib/typescript/src/tspl/index.d.ts.map +1 -0
- package/lib/typescript/src/type.d.ts +9 -0
- package/lib/typescript/src/type.d.ts.map +1 -0
- package/lib/typescript/src/util.d.ts +2 -0
- package/lib/typescript/src/util.d.ts.map +1 -0
- package/lib/typescript/src/utils/NativeXPrinterUtils.d.ts +10 -0
- package/lib/typescript/src/utils/NativeXPrinterUtils.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +9 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -0
- package/package.json +178 -0
- package/src/esc/NativeXPrinterESC.ts +516 -0
- package/src/esc/index.ts +489 -0
- package/src/index.ts +5 -0
- package/src/printer/NativeXPrinterPrinter.ts +84 -0
- package/src/printer/index.ts +160 -0
- package/src/tspl/NativeXPrinterTSPL.ts +388 -0
- package/src/tspl/index.ts +535 -0
- package/src/type.ts +11 -0
- package/src/util.ts +1 -0
- package/src/utils/NativeXPrinterUtils.ts +14 -0
- package/src/utils/index.ts +27 -0
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
#import "RCTNativeXPrinterESC.h"
|
|
2
|
+
#import "NativeXPrinter-Swift.h"
|
|
3
|
+
|
|
4
|
+
@implementation RCTNativeXPrinterESC {
|
|
5
|
+
NativeXPrinterESC* esc;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
- (id) init {
|
|
9
|
+
if (self = [super init]) {
|
|
10
|
+
esc = [NativeXPrinterESC new];
|
|
11
|
+
}
|
|
12
|
+
return self;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
- (void)dealloc {
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
- (void)clearNVImage:(nonnull NSString *)connectInfo resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
20
|
+
[esc clearNVImageWithConnectInfo:connectInfo completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
21
|
+
if(errorInfo){
|
|
22
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
23
|
+
}else{
|
|
24
|
+
resolve(nil);
|
|
25
|
+
}
|
|
26
|
+
}];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
- (void)compressionPrintBitmap:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterESC::PrintBitmapRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
30
|
+
RCTESCPrintBitmapRequest* request = [[RCTESCPrintBitmapRequest alloc] initWithAlignment:payload.alignment() width:payload.width() model:payload.model() type:payload.type() bitmapPath:payload.bitmapPath() bitmapContent:payload.bitmapContent()];
|
|
31
|
+
[esc compressionPrintBitmapWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
32
|
+
if(errorInfo){
|
|
33
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
34
|
+
}else{
|
|
35
|
+
resolve(nil);
|
|
36
|
+
}
|
|
37
|
+
}];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
- (void)cutHalfAndFeed:(nonnull NSString *)connectInfo distance:(double)distance resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
41
|
+
[esc cutHalfAndFeedWithConnectInfo:connectInfo distance:distance completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
42
|
+
if(errorInfo){
|
|
43
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
44
|
+
}else{
|
|
45
|
+
resolve(nil);
|
|
46
|
+
}
|
|
47
|
+
}];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
- (void)cutPaper:(nonnull NSString *)connectInfo model:(nonnull NSString *)model resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
51
|
+
[esc cutPaperWithConnectInfo:connectInfo model:model completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
52
|
+
if(errorInfo){
|
|
53
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
54
|
+
}else{
|
|
55
|
+
resolve(nil);
|
|
56
|
+
}
|
|
57
|
+
}];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
- (void)downloadNVImage:(nonnull NSString *)connectInfo imagePaths:(nonnull NSString *)imagePaths imageWidth:(double)imageWidth resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
61
|
+
[esc downloadNVImageWithConnectInfo:connectInfo imagePaths:imagePaths imageWidth:imageWidth completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
62
|
+
if(errorInfo){
|
|
63
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
64
|
+
}else{
|
|
65
|
+
resolve(nil);
|
|
66
|
+
}
|
|
67
|
+
}];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
- (void)feedDot:(nonnull NSString *)connectInfo dotCount:(double)dotCount resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
71
|
+
[esc feedDotWithConnectInfo:connectInfo dotCount:dotCount completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
72
|
+
if(errorInfo){
|
|
73
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
74
|
+
}else{
|
|
75
|
+
resolve(nil);
|
|
76
|
+
}
|
|
77
|
+
}];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
- (void)getSerialNumber:(nonnull NSString *)connectInfo resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
81
|
+
[esc getSerialNumberWithConnectInfo:connectInfo resolve:^(NSDictionary<NSString *,id> * _Nonnull value) {
|
|
82
|
+
resolve(value);
|
|
83
|
+
} reject:^(NativeErrorInfo * _Nonnull errorInfo) {
|
|
84
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
85
|
+
}];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
- (void)initializePrinter:(nonnull NSString *)connectInfo resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
89
|
+
[esc initializePrinterWithConnectInfo:connectInfo completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
90
|
+
if(errorInfo){
|
|
91
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
92
|
+
}else{
|
|
93
|
+
resolve(nil);
|
|
94
|
+
}
|
|
95
|
+
}];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
- (void)isConnect:(nonnull NSString *)connectInfo resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
99
|
+
[esc isConnectWithConnectInfo:connectInfo resolve:^(NSDictionary<NSString *,id> * _Nonnull value) {
|
|
100
|
+
resolve(nil);
|
|
101
|
+
} reject:^(NativeErrorInfo * _Nonnull errorInfo) {
|
|
102
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
103
|
+
}];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
- (void)lineFeed:(nonnull NSString *)connectInfo lineCount:(double)lineCount resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
107
|
+
[esc lineFeedWithConnectInfo:connectInfo lineCount:lineCount completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
108
|
+
if(errorInfo){
|
|
109
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
110
|
+
}else{
|
|
111
|
+
resolve(nil);
|
|
112
|
+
}
|
|
113
|
+
}];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
- (void)printBarCode:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterESC::PrintBarCodeRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
117
|
+
RCTESCPrintBarCodeRequest* request = [[RCTESCPrintBarCodeRequest alloc] initWithData:payload.data() codeType:payload.codeType() width:payload.width() height:payload.height() alignment:payload.alignment() textPosition:payload.textPosition()];
|
|
118
|
+
[esc printBarCodeWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
119
|
+
if(errorInfo){
|
|
120
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
121
|
+
}else{
|
|
122
|
+
resolve(nil);
|
|
123
|
+
}
|
|
124
|
+
}];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
- (void)printBitmap:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterESC::PrintBitmapRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
128
|
+
RCTESCPrintBitmapRequest* request = [[RCTESCPrintBitmapRequest alloc] initWithAlignment:payload.alignment() width:payload.width() model:payload.model() type:payload.type() bitmapPath:payload.bitmapPath() bitmapContent:payload.bitmapContent()];
|
|
129
|
+
[esc printBitmapWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
130
|
+
if(errorInfo){
|
|
131
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
132
|
+
}else{
|
|
133
|
+
resolve(nil);
|
|
134
|
+
}
|
|
135
|
+
}];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
- (void)printNVImage:(nonnull NSString *)connectInfo index:(double)index model:(nonnull NSString *)model resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
139
|
+
[esc printNVImageWithConnectInfo:connectInfo index:index model:model completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
140
|
+
if(errorInfo){
|
|
141
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
142
|
+
}else{
|
|
143
|
+
resolve(nil);
|
|
144
|
+
}
|
|
145
|
+
}];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
- (void)printPDF417:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterESC::PrintPDF417Request &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
149
|
+
RCTESCPrintPDF417Request* request = [[RCTESCPrintPDF417Request alloc] initWithData:payload.data() cellWidth:payload.cellWidth() cellHeightRatio:payload.cellHeightRatio() numberOfColumns:payload.numberOfColumns() numberOfRows:payload.numberOfRows() eclType:payload.eclType() eclValue:payload.eclValue() alignment:payload.alignment()];
|
|
150
|
+
[esc printPDF417WithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
151
|
+
if(errorInfo){
|
|
152
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
153
|
+
}else{
|
|
154
|
+
resolve(nil);
|
|
155
|
+
}
|
|
156
|
+
}];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
- (void)printPageModelData:(nonnull NSString *)connectInfo resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
160
|
+
[esc printPageModelDataWithConnectInfo:connectInfo completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
161
|
+
if(errorInfo){
|
|
162
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
163
|
+
}else{
|
|
164
|
+
resolve(nil);
|
|
165
|
+
}
|
|
166
|
+
}];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
- (void)printQRCode:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterESC::PrintQRCodeRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
170
|
+
RCTESCPrintQRCodeRequest* request = [[RCTESCPrintQRCodeRequest alloc] initWithData:payload.data() moduleSize:payload.moduleSize() ecLevel:payload.ecLevel() alignment:payload.alignment()];
|
|
171
|
+
[esc printQRCodeWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
172
|
+
if(errorInfo){
|
|
173
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
174
|
+
}else{
|
|
175
|
+
resolve(nil);
|
|
176
|
+
}
|
|
177
|
+
}];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
- (void)printString:(nonnull NSString *)connectInfo data:(nonnull NSString *)data resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
181
|
+
[esc printStringWithConnectInfo:connectInfo data:data completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
182
|
+
if(errorInfo){
|
|
183
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
184
|
+
}else{
|
|
185
|
+
resolve(nil);
|
|
186
|
+
}
|
|
187
|
+
}];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
- (void)printTable:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterESC::PrintTableRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
191
|
+
|
|
192
|
+
NSMutableArray *titles = [NSMutableArray arrayWithCapacity:payload.titles().size()];
|
|
193
|
+
for (int i = 0; i < payload.titles().size(); ++i) {
|
|
194
|
+
[titles addObject:payload.titles().at(i)];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
NSMutableArray *numberOfSingleBytesPerCol = [NSMutableArray arrayWithCapacity:payload.numberOfSingleBytesPerCol().size()];
|
|
198
|
+
for (int i = 0; i < payload.numberOfSingleBytesPerCol().size(); ++i) {
|
|
199
|
+
[numberOfSingleBytesPerCol addObject:@(payload.numberOfSingleBytesPerCol().at(i))];
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
NSMutableArray *align = [NSMutableArray arrayWithCapacity:payload.align().size()];
|
|
203
|
+
for (int i = 0; i < payload.align().size(); ++i) {
|
|
204
|
+
[align addObject:@(payload.align().at(i))];
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
NSMutableArray *rows = nil;
|
|
208
|
+
if (payload.rows().has_value()) {
|
|
209
|
+
rows = [NSMutableArray arrayWithCapacity:payload.rows().value().size()];
|
|
210
|
+
for (int i = 0; i < payload.rows().value().size(); ++i) {
|
|
211
|
+
JS::NativeXPrinterESC::PrintTableRow row = payload.rows().value().at(i);
|
|
212
|
+
|
|
213
|
+
NSMutableArray *rowData = [NSMutableArray arrayWithCapacity:row.data().size()];
|
|
214
|
+
for (int i = 0; i < row.data().size(); ++i) {
|
|
215
|
+
[rowData addObject:row.data().at(i)];
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
RCTESCPrintTableBarcode* rowBarcode = nil;
|
|
219
|
+
if (row.barcode().has_value()) {
|
|
220
|
+
JS::NativeXPrinterESC::PrintTableBarcode barcode = row.barcode().value();
|
|
221
|
+
rowBarcode = [[RCTESCPrintTableBarcode alloc] initWithData:barcode.data() codeType:barcode.codeType() width:barcode.width() height:barcode.height() alignment:barcode.alignment() textPosition:barcode.textPosition()];
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
RCTESCPrintTableRow* _row = [[RCTESCPrintTableRow alloc] initWithTitle:row.title() data:rowData remark:row.remark() barcode:rowBarcode];
|
|
225
|
+
[rows addObject:_row];
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
RCTESCPrintTableRequest *request = [[RCTESCPrintTableRequest alloc] initWithTitles:titles numberOfSingleBytesPerCol:numberOfSingleBytesPerCol align:align rows:nil];
|
|
230
|
+
[esc printTableWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
231
|
+
if(errorInfo){
|
|
232
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
233
|
+
}else{
|
|
234
|
+
resolve(nil);
|
|
235
|
+
}
|
|
236
|
+
}];
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
- (void)printText:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterESC::PrintTextRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
240
|
+
RCTESCPrintTextRequest* request = [[RCTESCPrintTextRequest alloc] initWithData:payload.data() alignment:payload.alignment() attribute:payload.attribute() textWidth:payload.textWidth() textHeight:payload.textHeight()];
|
|
241
|
+
[esc printTextWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
242
|
+
if(errorInfo){
|
|
243
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
244
|
+
}else{
|
|
245
|
+
resolve(nil);
|
|
246
|
+
}
|
|
247
|
+
}];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
- (void)printTextAlignment:(nonnull NSString *)connectInfo data:(nonnull NSString *)data alignment:(nonnull NSString *)alignment resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
251
|
+
[esc printTextAlignmentWithConnectInfo:connectInfo data:data alignment:alignment completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
252
|
+
if(errorInfo){
|
|
253
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
254
|
+
}else{
|
|
255
|
+
resolve(nil);
|
|
256
|
+
}
|
|
257
|
+
}];
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
- (void)printTextAttribute:(nonnull NSString *)connectInfo data:(nonnull NSString *)data attribute:(nonnull NSString *)attribute resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
261
|
+
[esc printTextAttributeWithConnectInfo:connectInfo data:data attribute:attribute completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
262
|
+
if(errorInfo){
|
|
263
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
264
|
+
}else{
|
|
265
|
+
resolve(nil);
|
|
266
|
+
}
|
|
267
|
+
}];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
- (void)printTextSize:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterESC::PrintTextSizeRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
271
|
+
RCTESCPrintTextSizeRequest* request =[[RCTESCPrintTextSizeRequest alloc] initWithData:payload.data() textWidth:payload.textWidth() textHeight:payload.textHeight()];
|
|
272
|
+
[esc printTextSizeWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
273
|
+
if(errorInfo){
|
|
274
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
275
|
+
}else{
|
|
276
|
+
resolve(nil);
|
|
277
|
+
}
|
|
278
|
+
}];
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
- (void)printerCheck:(nonnull NSString *)connectInfo type:(nonnull NSString *)type timeout:(double)timeout resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
282
|
+
[esc printerCheckWithConnectInfo:connectInfo type:type timeout:timeout resolve:^(NSDictionary<NSString *,id> * _Nonnull value) {
|
|
283
|
+
resolve(value);
|
|
284
|
+
} reject:^(NativeErrorInfo * _Nonnull errorInfo) {
|
|
285
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
286
|
+
}];
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
- (void)printerStatus:(nonnull NSString *)connectInfo resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
290
|
+
[esc printerStatusWithConnectInfo:connectInfo resolve:^(NSDictionary<NSString *,id> * _Nonnull value) {
|
|
291
|
+
resolve(value);
|
|
292
|
+
} reject:^(NativeErrorInfo * _Nonnull errorInfo) {
|
|
293
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
294
|
+
}];
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
- (void)printerStatusII:(nonnull NSString *)connectInfo resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
298
|
+
[esc printerStatusIIWithConnectInfo:connectInfo resolve:^(NSDictionary<NSString *,id> * _Nonnull value) {
|
|
299
|
+
resolve(value);
|
|
300
|
+
} reject:^(NativeErrorInfo * _Nonnull errorInfo) {
|
|
301
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
302
|
+
}];
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
- (void)selectBitmapModel:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterESC::SelectBitmapModelRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
306
|
+
RCTESCSelectBitmapModelRequest* request = [[RCTESCSelectBitmapModelRequest alloc] initWithBitmapPath:payload.bitmapPath() width:payload.width() model:payload.model()];
|
|
307
|
+
[esc selectBitmapModelWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
308
|
+
if(errorInfo){
|
|
309
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
310
|
+
}else{
|
|
311
|
+
resolve(nil);
|
|
312
|
+
}
|
|
313
|
+
}];
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
- (void)selectCharacterFont:(nonnull NSString *)connectInfo font:(nonnull NSString *)font resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
317
|
+
[esc selectCharacterFontWithConnectInfo:connectInfo font:font completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
318
|
+
if(errorInfo){
|
|
319
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
320
|
+
}else{
|
|
321
|
+
resolve(nil);
|
|
322
|
+
}
|
|
323
|
+
}];
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
- (void)selectCodePage:(nonnull NSString *)connectInfo page:(double)page resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
327
|
+
[esc selectCodePageWithConnectInfo:connectInfo page:page completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
328
|
+
if(errorInfo){
|
|
329
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
330
|
+
}else{
|
|
331
|
+
resolve(nil);
|
|
332
|
+
}
|
|
333
|
+
}];
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
- (void)selectInternationCharacterSets:(nonnull NSString *)connectInfo n:(nonnull NSString *)n resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
337
|
+
[esc selectInternationCharacterSetsWithConnectInfo:connectInfo n:n completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
338
|
+
if(errorInfo){
|
|
339
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
340
|
+
}else{
|
|
341
|
+
resolve(nil);
|
|
342
|
+
}
|
|
343
|
+
}];
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
- (void)setAbsoluteHorizontal:(nonnull NSString *)connectInfo position:(double)position resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
347
|
+
[esc setAbsoluteHorizontalWithConnectInfo:connectInfo position:position completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
348
|
+
if(errorInfo){
|
|
349
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
350
|
+
}else{
|
|
351
|
+
resolve(nil);
|
|
352
|
+
}
|
|
353
|
+
}];
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
- (void)setAbsoluteVertical:(nonnull NSString *)connectInfo position:(double)position resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
357
|
+
[esc setAbsoluteVerticalWithConnectInfo:connectInfo position:position completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
358
|
+
if(errorInfo){
|
|
359
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
360
|
+
}else{
|
|
361
|
+
resolve(nil);
|
|
362
|
+
}
|
|
363
|
+
}];
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
- (void)setAlignment:(nonnull NSString *)connectInfo alignment:(nonnull NSString *)alignment resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
367
|
+
[esc setAlignmentWithConnectInfo:connectInfo alignment:alignment completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
368
|
+
if(errorInfo){
|
|
369
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
370
|
+
}else{
|
|
371
|
+
resolve(nil);
|
|
372
|
+
}
|
|
373
|
+
}];
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
- (void)setBluetooth:(nonnull NSString *)connectInfo name:(nonnull NSString *)name pin:(nonnull NSString *)pin resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
377
|
+
[esc setBluetoothWithConnectInfo:connectInfo name:name pin:pin completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
378
|
+
if(errorInfo){
|
|
379
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
380
|
+
}else{
|
|
381
|
+
resolve(nil);
|
|
382
|
+
}
|
|
383
|
+
}];
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
- (void)setCharSet:(nonnull NSString *)connectInfo charSet:(nonnull NSString *)charSet resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
387
|
+
[esc setCharSetWithConnectInfo:connectInfo charSet:charSet completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
388
|
+
if(errorInfo){
|
|
389
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
390
|
+
}else{
|
|
391
|
+
resolve(nil);
|
|
392
|
+
}
|
|
393
|
+
}];
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
- (void)setGateway:(nonnull NSString *)connectInfo gateway:(nonnull NSString *)gateway resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
397
|
+
[esc setGatewayWithConnectInfo:connectInfo gateway:gateway completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
398
|
+
if(errorInfo){
|
|
399
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
400
|
+
}else{
|
|
401
|
+
resolve(nil);
|
|
402
|
+
}
|
|
403
|
+
}];
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
- (void)setIp:(nonnull NSString *)connectInfo ip:(nonnull NSString *)ip resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
407
|
+
[esc setIpWithConnectInfo:connectInfo ip:ip completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
408
|
+
if(errorInfo){
|
|
409
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
410
|
+
}else{
|
|
411
|
+
resolve(nil);
|
|
412
|
+
}
|
|
413
|
+
}];
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
- (void)setLineSpacing:(nonnull NSString *)connectInfo space:(double)space resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
417
|
+
[esc setLineSpacingWithConnectInfo:connectInfo space:space completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
418
|
+
if(errorInfo){
|
|
419
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
420
|
+
}else{
|
|
421
|
+
resolve(nil);
|
|
422
|
+
}
|
|
423
|
+
}];
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
- (void)setMask:(nonnull NSString *)connectInfo mask:(nonnull NSString *)mask resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
427
|
+
[esc setMaskWithConnectInfo:connectInfo mask:mask completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
428
|
+
if(errorInfo){
|
|
429
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
430
|
+
}else{
|
|
431
|
+
resolve(nil);
|
|
432
|
+
}
|
|
433
|
+
}];
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
- (void)setNetAll:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterESC::SetNetAllRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
437
|
+
RCTESCSetNetAllRequest* request = [[RCTESCSetNetAllRequest alloc] initWithIp:payload.ip() mask:payload.mask() gateway:payload.gateway() dhcpIsOpen:payload.dhcpIsOpen()];
|
|
438
|
+
[esc setNetAllWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
439
|
+
if(errorInfo){
|
|
440
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
441
|
+
}else{
|
|
442
|
+
resolve(nil);
|
|
443
|
+
}
|
|
444
|
+
}];
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
- (void)setPageModel:(nonnull NSString *)connectInfo isOpen:(BOOL)isOpen resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
448
|
+
[esc setPageModelWithConnectInfo:connectInfo isOpen:isOpen completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
449
|
+
if(errorInfo){
|
|
450
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
451
|
+
}else{
|
|
452
|
+
resolve(nil);
|
|
453
|
+
}
|
|
454
|
+
}];
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
- (void)setPrintArea:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterESC::SetPrintAreaRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
458
|
+
RCTESCSetPrintAreaRequest* request = [[RCTESCSetPrintAreaRequest alloc] initWithX:payload.x() y:payload.y() width:payload.width() height:payload.height()];
|
|
459
|
+
[esc setPrintAreaWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
460
|
+
if(errorInfo){
|
|
461
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
462
|
+
}else{
|
|
463
|
+
resolve(nil);
|
|
464
|
+
}
|
|
465
|
+
}];
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
- (void)setPrintDirection:(nonnull NSString *)connectInfo direction:(nonnull NSString *)direction resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
469
|
+
[esc setPrintDirectionWithConnectInfo:connectInfo direction:direction completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
470
|
+
if(errorInfo){
|
|
471
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
472
|
+
}else{
|
|
473
|
+
resolve(nil);
|
|
474
|
+
}
|
|
475
|
+
}];
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
- (void)setRelativeHorizontal:(nonnull NSString *)connectInfo position:(double)position resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
479
|
+
[esc setRelativeHorizontalWithConnectInfo:connectInfo position:position completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
480
|
+
if(errorInfo){
|
|
481
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
482
|
+
}else{
|
|
483
|
+
resolve(nil);
|
|
484
|
+
}
|
|
485
|
+
}];
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
- (void)setRelativeVertical:(nonnull NSString *)connectInfo position:(double)position resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
489
|
+
[esc setRelativeVerticalWithConnectInfo:connectInfo position:position completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
490
|
+
if(errorInfo){
|
|
491
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
492
|
+
}else{
|
|
493
|
+
resolve(nil);
|
|
494
|
+
}
|
|
495
|
+
}];
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
- (void)setTextStyle:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterESC::SetTextStyleRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
499
|
+
RCTESCSetTextStyleRequest* request = [[RCTESCSetTextStyleRequest alloc] initWithAttribute:payload.attribute() textWidth:payload.textWidth() textHeight:payload.textHeight()];
|
|
500
|
+
[esc setTextStyleWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
501
|
+
if(errorInfo){
|
|
502
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
503
|
+
}else{
|
|
504
|
+
resolve(nil);
|
|
505
|
+
}
|
|
506
|
+
}];
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
- (void)setTurnUpsideDownMode:(nonnull NSString *)connectInfo on:(BOOL)on resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
510
|
+
[esc setTurnUpsideDownModeWithConnectInfo:connectInfo on:on completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
511
|
+
if(errorInfo){
|
|
512
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
513
|
+
}else{
|
|
514
|
+
resolve(nil);
|
|
515
|
+
}
|
|
516
|
+
}];
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
- (void)wifiConfig:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterESC::WifiConfigRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
520
|
+
RCTESCWifiConfigRequest* request = [[RCTESCWifiConfigRequest alloc] initWithIp:payload.ip() mask:payload.mask() gateway:payload.gateway() ssid:payload.ssid() password:payload.password() encrypt:payload.encrypt()];
|
|
521
|
+
[esc wifiConfigWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
522
|
+
if(errorInfo){
|
|
523
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
524
|
+
}else{
|
|
525
|
+
resolve(nil);
|
|
526
|
+
}
|
|
527
|
+
}];
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
531
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
532
|
+
{
|
|
533
|
+
return std::make_shared<facebook::react::NativeXPrinterESCSpecJSI>(params);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
+ (NSString *)moduleName
|
|
537
|
+
{
|
|
538
|
+
return @"NativeXPrinterESC";
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
@end
|
package/ios/Errors.swift
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Errors.swift
|
|
3
|
+
// Created by chancetio on 2025/9/8.
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
enum PrinterErrors {
|
|
7
|
+
static let PARAMS_ERROR = "PARAMS_ERROR"
|
|
8
|
+
static let COMMON_ERROR = "COMMON_ERROR"
|
|
9
|
+
static let PRINTER_NOT_FOUND_ERROR = "PRINTER_NOT_FOUND_ERROR"
|
|
10
|
+
static let NOT_YET_IMPLEMENTED_ERROR = "NOT_YET_IMPLEMENTED_ERROR"
|
|
11
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//
|
|
2
|
+
// NativeErrorInfo.swift
|
|
3
|
+
// Created by chancetio on 2026/1/28.
|
|
4
|
+
//
|
|
5
|
+
@objcMembers
|
|
6
|
+
public class NativeErrorInfo: NSObject {
|
|
7
|
+
public let code: String?
|
|
8
|
+
public let message: String?
|
|
9
|
+
public let error: Error?
|
|
10
|
+
|
|
11
|
+
public init(code: String?, message: String?, error: Error?) {
|
|
12
|
+
self.code = code
|
|
13
|
+
self.message = message
|
|
14
|
+
self.error = error
|
|
15
|
+
super.init()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
override public var description: String {
|
|
19
|
+
"NativeErrorInfo(code=\(String(describing: code)), message=\(String(describing: message)), error=\(String(describing: error)))"
|
|
20
|
+
}
|
|
21
|
+
}
|