@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,445 @@
|
|
|
1
|
+
#import "RCTNativeXPrinterTSPL.h"
|
|
2
|
+
#import "NativeXPrinter-Swift.h"
|
|
3
|
+
|
|
4
|
+
@implementation RCTNativeXPrinterTSPL {
|
|
5
|
+
NativeXPrinterTSPL* tspl;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
- (id) init {
|
|
9
|
+
if (self = [super init]) {
|
|
10
|
+
tspl = [NativeXPrinterTSPL new];
|
|
11
|
+
}
|
|
12
|
+
return self;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
- (void)dealloc {
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
- (void)backFeed:(nonnull NSString *)connectInfo length:(double)length resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
20
|
+
[tspl backFeedWithConnectInfo:connectInfo length:length 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)bar:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterTSPL::BarRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
30
|
+
RCTTSPLBarRequest *request = [[RCTTSPLBarRequest alloc] initWithX:payload.x() y:payload.y() width:payload.width() height:payload.height()];
|
|
31
|
+
[tspl barWithConnectInfo: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)barcode:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterTSPL::BarcodeRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
41
|
+
RCTTSPLBarcodeRequest *request = [[RCTTSPLBarcodeRequest alloc] initWithX:payload.x() y:payload.y() codeType:payload.codeType() height:payload.height() readable:payload.readable() rotation:payload.rotation() narrow:payload.narrow() wide:payload.wide() content:payload.content()];
|
|
42
|
+
[tspl barcodeWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
43
|
+
if(errorInfo){
|
|
44
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
45
|
+
}else{
|
|
46
|
+
resolve(nil);
|
|
47
|
+
}
|
|
48
|
+
}];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
- (void)bitmap:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterTSPL::BitmapRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
52
|
+
RCTTSPLBitmapRequest *request = [[RCTTSPLBitmapRequest alloc] initWithX:payload.x() y:payload.y() mode:payload.mode() width:payload.width() bitmapPath:payload.bitmapPath() bitmapContent:payload.bitmapContent() algorithmType:payload.algorithmType()];
|
|
53
|
+
[tspl bitmapWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
54
|
+
if(errorInfo){
|
|
55
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
56
|
+
}else{
|
|
57
|
+
resolve(nil);
|
|
58
|
+
}
|
|
59
|
+
}];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
- (void)bitmapCompression:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterTSPL::BitmapCompressionRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
63
|
+
RCTTSPLBitmapCompressionRequest *request = [[RCTTSPLBitmapCompressionRequest alloc] initWithX:payload.x() y:payload.y() mode:payload.mode() width:payload.width() bitmapPath:payload.bitmapPath() bitmapContent:payload.bitmapContent() algorithmType:payload.algorithmType()];
|
|
64
|
+
[tspl bitmapCompressionWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
65
|
+
if(errorInfo){
|
|
66
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
67
|
+
}else{
|
|
68
|
+
resolve(nil);
|
|
69
|
+
}
|
|
70
|
+
}];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
- (void)blineInch:(nonnull NSString *)connectInfo m:(double)m n:(double)n resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
74
|
+
[tspl blineInchWithConnectInfo:connectInfo m:m n:n completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
75
|
+
if(errorInfo){
|
|
76
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
77
|
+
}else{
|
|
78
|
+
resolve(nil);
|
|
79
|
+
}
|
|
80
|
+
}];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
- (void)blineMm:(nonnull NSString *)connectInfo m:(double)m n:(double)n resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
84
|
+
[tspl blineMmWithConnectInfo:connectInfo m:m n:n completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
85
|
+
if(errorInfo){
|
|
86
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
87
|
+
}else{
|
|
88
|
+
resolve(nil);
|
|
89
|
+
}
|
|
90
|
+
}];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
- (void)box:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterTSPL::BoxRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
94
|
+
RCTTSPLBoxRequest *request = [[RCTTSPLBoxRequest alloc] initWithX:payload.x() y:payload.y() width:payload.width() height:payload.height() thickness:payload.thickness()];
|
|
95
|
+
[tspl boxWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
96
|
+
if(errorInfo){
|
|
97
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
98
|
+
}else{
|
|
99
|
+
resolve(nil);
|
|
100
|
+
}
|
|
101
|
+
}];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
- (void)cls:(nonnull NSString *)connectInfo resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
105
|
+
[tspl clsWithConnectInfo:connectInfo completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
106
|
+
if(errorInfo){
|
|
107
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
108
|
+
}else{
|
|
109
|
+
resolve(nil);
|
|
110
|
+
}
|
|
111
|
+
}];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
- (void)codePage:(nonnull NSString *)connectInfo page:(nonnull NSString *)page resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
115
|
+
[tspl codePageWithConnectInfo:connectInfo page:page completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
116
|
+
if(errorInfo){
|
|
117
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
118
|
+
}else{
|
|
119
|
+
resolve(nil);
|
|
120
|
+
}
|
|
121
|
+
}];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
- (void)cut:(nonnull NSString *)connectInfo resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
125
|
+
[tspl cutWithConnectInfo:connectInfo completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
126
|
+
if(errorInfo){
|
|
127
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
128
|
+
}else{
|
|
129
|
+
resolve(nil);
|
|
130
|
+
}
|
|
131
|
+
}];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
- (void)density:(nonnull NSString *)connectInfo density:(double)density resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
135
|
+
[tspl densityWithConnectInfo:connectInfo density:density completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
136
|
+
if(errorInfo){
|
|
137
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
138
|
+
}else{
|
|
139
|
+
resolve(nil);
|
|
140
|
+
}
|
|
141
|
+
}];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
- (void)direction:(nonnull NSString *)connectInfo direction:(nonnull NSString *)direction isMirror:(BOOL)isMirror resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
145
|
+
[tspl directionWithConnectInfo:connectInfo direction:direction isMirror:isMirror completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
146
|
+
if(errorInfo){
|
|
147
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
148
|
+
}else{
|
|
149
|
+
resolve(nil);
|
|
150
|
+
}
|
|
151
|
+
}];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
- (void)erase:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterTSPL::EraseRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
155
|
+
RCTTSPLEraseRequest *request = [[RCTTSPLEraseRequest alloc] initWithX:payload.x() y:payload.y() width:payload.width() height:payload.height()];
|
|
156
|
+
[tspl eraseWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
157
|
+
if(errorInfo){
|
|
158
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
159
|
+
}else{
|
|
160
|
+
resolve(nil);
|
|
161
|
+
}
|
|
162
|
+
}];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
- (void)feed:(nonnull NSString *)connectInfo length:(double)length resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
166
|
+
[tspl feedWithConnectInfo:connectInfo length:length completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
167
|
+
if(errorInfo){
|
|
168
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
169
|
+
}else{
|
|
170
|
+
resolve(nil);
|
|
171
|
+
}
|
|
172
|
+
}];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
- (void)formFeed:(nonnull NSString *)connectInfo resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
176
|
+
[tspl formFeedWithConnectInfo:connectInfo completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
177
|
+
if(errorInfo){
|
|
178
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
179
|
+
}else{
|
|
180
|
+
resolve(nil);
|
|
181
|
+
}
|
|
182
|
+
}];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
- (void)gapInch:(nonnull NSString *)connectInfo m:(double)m n:(double)n resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
186
|
+
[tspl gapInchWithConnectInfo:connectInfo m:m n:n completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
187
|
+
if(errorInfo){
|
|
188
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
189
|
+
}else{
|
|
190
|
+
resolve(nil);
|
|
191
|
+
}
|
|
192
|
+
}];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
- (void)gapMm:(nonnull NSString *)connectInfo m:(double)m n:(double)n resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
196
|
+
[tspl gapMmWithConnectInfo:connectInfo m:m n:n completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
197
|
+
if(errorInfo){
|
|
198
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
199
|
+
}else{
|
|
200
|
+
resolve(nil);
|
|
201
|
+
}
|
|
202
|
+
}];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
- (void)getPrinterModel:(nonnull NSString *)connectInfo resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
206
|
+
[tspl getPrinterModelWithConnectInfo:connectInfo resolve:^(NSString * _Nonnull value) {
|
|
207
|
+
resolve(value);
|
|
208
|
+
} reject:^(NativeErrorInfo * _Nonnull errorInfo) {
|
|
209
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
210
|
+
}];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
- (void)home:(nonnull NSString *)connectInfo resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
214
|
+
[tspl homeWithConnectInfo:connectInfo completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
215
|
+
if(errorInfo){
|
|
216
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
217
|
+
}else{
|
|
218
|
+
resolve(nil);
|
|
219
|
+
}
|
|
220
|
+
}];
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
- (void)limitFeedInch:(nonnull NSString *)connectInfo length:(double)length resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
224
|
+
[tspl limitFeedInchWithConnectInfo:connectInfo length:length completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
225
|
+
if(errorInfo){
|
|
226
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
227
|
+
}else{
|
|
228
|
+
resolve(nil);
|
|
229
|
+
}
|
|
230
|
+
}];
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
- (void)limitFeedMm:(nonnull NSString *)connectInfo length:(double)length resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
234
|
+
[tspl limitFeedMmWithConnectInfo:connectInfo length:length completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
235
|
+
if(errorInfo){
|
|
236
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
237
|
+
}else{
|
|
238
|
+
resolve(nil);
|
|
239
|
+
}
|
|
240
|
+
}];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
- (void)offsetInch:(nonnull NSString *)connectInfo offset:(double)offset resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
244
|
+
[tspl offsetInchWithConnectInfo:connectInfo offset:offset completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
245
|
+
if(errorInfo){
|
|
246
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
247
|
+
}else{
|
|
248
|
+
resolve(nil);
|
|
249
|
+
}
|
|
250
|
+
}];
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
- (void)offsetMm:(nonnull NSString *)connectInfo offset:(double)offset resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
254
|
+
[tspl offsetMmWithConnectInfo:connectInfo offset:offset completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
255
|
+
if(errorInfo){
|
|
256
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
257
|
+
}else{
|
|
258
|
+
resolve(nil);
|
|
259
|
+
}
|
|
260
|
+
}];
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
- (void)pdfBase64:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterTSPL::PDFBase64Request &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
264
|
+
RCTTSPLPDFBase64Request* request = [[RCTTSPLPDFBase64Request alloc] initWithX:payload.x() y:payload.y() pageWidth:payload.pageWidth() base64String:payload.base64String() algorithmType:payload.algorithmType()];
|
|
265
|
+
[tspl pdfBase64WithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
266
|
+
if(errorInfo){
|
|
267
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
268
|
+
}else{
|
|
269
|
+
resolve(nil);
|
|
270
|
+
}
|
|
271
|
+
}];
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
- (void)print:(nonnull NSString *)connectInfo count:(double)count resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
275
|
+
[tspl printWithConnectInfo:connectInfo count:count completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
276
|
+
if(errorInfo){
|
|
277
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
278
|
+
}else{
|
|
279
|
+
resolve(nil);
|
|
280
|
+
}
|
|
281
|
+
}];
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
- (void)printWithResponse:(nonnull NSString *)connectInfo count:(double)count timeout:(double)timeout resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
285
|
+
[tspl printWithResponseWithConnectInfo:connectInfo count:count timeout:timeout resolve:^(double value) {
|
|
286
|
+
resolve(@(value));
|
|
287
|
+
} reject:^(NativeErrorInfo * _Nonnull errorInfo) {
|
|
288
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
289
|
+
}];
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
- (void)printerStatus:(nonnull NSString *)connectInfo timeout:(double)timeout resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
293
|
+
[tspl printerStatusWithConnectInfo:connectInfo timeout:timeout resolve:^(NSDictionary<NSString *,id> * _Nonnull value) {
|
|
294
|
+
resolve(value);
|
|
295
|
+
} reject:^(NativeErrorInfo * _Nonnull errorInfo) {
|
|
296
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
297
|
+
}];
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
- (void)putBMP:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterTSPL::PutBMPRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
301
|
+
RCTTSPLPutBMPRequest *request = [[RCTTSPLPutBMPRequest alloc] initWithX:payload.x() y:payload.y() fileName:payload.fileName()];
|
|
302
|
+
[tspl putBmpWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
303
|
+
if(errorInfo){
|
|
304
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
305
|
+
}else{
|
|
306
|
+
resolve(nil);
|
|
307
|
+
}
|
|
308
|
+
}];
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
- (void)qrcode:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterTSPL::QRCodeRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
312
|
+
RCTTSPLQRCodeRequest *request = [[RCTTSPLQRCodeRequest alloc] initWithX:payload.x() y:payload.y() ecLevel:payload.ecLevel() cellWidth:payload.cellWidth() mode:payload.mode() rotation:payload.rotation() model:payload.model() mask:payload.mask() data:payload.data()];
|
|
313
|
+
[tspl qrcodeWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
314
|
+
if(errorInfo){
|
|
315
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
316
|
+
}else{
|
|
317
|
+
resolve(nil);
|
|
318
|
+
}
|
|
319
|
+
}];
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
- (void)reference:(nonnull NSString *)connectInfo x:(double)x y:(double)y resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
323
|
+
[tspl referenceWithConnectInfo:connectInfo x:x y:y completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
324
|
+
if(errorInfo){
|
|
325
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
326
|
+
}else{
|
|
327
|
+
resolve(nil);
|
|
328
|
+
}
|
|
329
|
+
}];
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
- (void)reverse:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterTSPL::ReverseRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
333
|
+
RCTTSPLReverseRequest *request = [[RCTTSPLReverseRequest alloc] initWithX:payload.x() y:payload.y() width:payload.width() height:payload.height()];
|
|
334
|
+
[tspl reverseWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
335
|
+
if(errorInfo){
|
|
336
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
337
|
+
}else{
|
|
338
|
+
resolve(nil);
|
|
339
|
+
}
|
|
340
|
+
}];
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
- (void)setCutter:(nonnull NSString *)connectInfo pieces:(double)pieces resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
344
|
+
[tspl setCutterWithConnectInfo:connectInfo pieces:pieces completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
345
|
+
if(errorInfo){
|
|
346
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
347
|
+
}else{
|
|
348
|
+
resolve(nil);
|
|
349
|
+
}
|
|
350
|
+
}];
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
- (void)setPeel:(nonnull NSString *)connectInfo isOpen:(BOOL)isOpen resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
354
|
+
[tspl setPeelWithConnectInfo:connectInfo isOpen:isOpen completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
355
|
+
if(errorInfo){
|
|
356
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
357
|
+
}else{
|
|
358
|
+
resolve(nil);
|
|
359
|
+
}
|
|
360
|
+
}];
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
- (void)setPrinterModel:(nonnull NSString *)connectInfo model:(nonnull NSString *)model resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
364
|
+
[tspl setPrinterModelWithConnectInfo:connectInfo model:model completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
365
|
+
if(errorInfo){
|
|
366
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
367
|
+
}else{
|
|
368
|
+
resolve(nil);
|
|
369
|
+
}
|
|
370
|
+
}];
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
- (void)setTear:(nonnull NSString *)connectInfo isOpen:(BOOL)isOpen resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
374
|
+
[tspl setTearWithConnectInfo:connectInfo isOpen:isOpen completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
375
|
+
if(errorInfo){
|
|
376
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
377
|
+
}else{
|
|
378
|
+
resolve(nil);
|
|
379
|
+
}
|
|
380
|
+
}];
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
- (void)sizeInch:(nonnull NSString *)connectInfo width:(double)width height:(double)height resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
384
|
+
[tspl sizeInchWithConnectInfo:connectInfo width:width height:height completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
385
|
+
if(errorInfo){
|
|
386
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
387
|
+
}else{
|
|
388
|
+
resolve(nil);
|
|
389
|
+
}
|
|
390
|
+
}];
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
- (void)sizeMm:(nonnull NSString *)connectInfo width:(double)width height:(double)height resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
394
|
+
[tspl sizeMmWithConnectInfo:connectInfo width:width height:height completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
395
|
+
if(errorInfo){
|
|
396
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
397
|
+
}else{
|
|
398
|
+
resolve(nil);
|
|
399
|
+
}
|
|
400
|
+
}];
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
- (void)sound:(nonnull NSString *)connectInfo level:(double)level interval:(double)interval resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
404
|
+
[tspl soundWithConnectInfo:connectInfo level:level interval:interval completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
405
|
+
if(errorInfo){
|
|
406
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
407
|
+
}else{
|
|
408
|
+
resolve(nil);
|
|
409
|
+
}
|
|
410
|
+
}];
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
- (void)speed:(nonnull NSString *)connectInfo speed:(double)speed resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
414
|
+
[tspl speedWithConnectInfo:connectInfo speed:speed completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
415
|
+
if(errorInfo){
|
|
416
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
417
|
+
}else{
|
|
418
|
+
resolve(nil);
|
|
419
|
+
}
|
|
420
|
+
}];
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
- (void)text:(nonnull NSString *)connectInfo payload:(JS::NativeXPrinterTSPL::TextRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
424
|
+
RCTTSPLTextRequest *request = [[RCTTSPLTextRequest alloc] initWithX:payload.x() y:payload.y() font:payload.font() rotation:payload.rotation() xRatio:payload.xRatio() yRatio:payload.yRatio() content:payload.content()];
|
|
425
|
+
[tspl textWithConnectInfo:connectInfo payload:request completion:^(NativeErrorInfo * _Nullable errorInfo) {
|
|
426
|
+
if(errorInfo){
|
|
427
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
428
|
+
}else{
|
|
429
|
+
resolve(nil);
|
|
430
|
+
}
|
|
431
|
+
}];
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
435
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
436
|
+
{
|
|
437
|
+
return std::make_shared<facebook::react::NativeXPrinterTSPLSpecJSI>(params);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
+ (NSString *)moduleName
|
|
441
|
+
{
|
|
442
|
+
return @"NativeXPrinterTSPL";
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
@end
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Convert.swift
|
|
3
|
+
|
|
4
|
+
//
|
|
5
|
+
// Created by chancetio on 2025/9/9.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
extension String {
|
|
9
|
+
func toTSPLDirection() -> Int32? {
|
|
10
|
+
switch self {
|
|
11
|
+
case "DIRECTION_FORWARD": return 0
|
|
12
|
+
case "DIRECTION_REVERSE": return 1
|
|
13
|
+
default: return nil
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
func toTSPLReadable() -> Int32? {
|
|
18
|
+
switch self {
|
|
19
|
+
case "READABLE_NONE": return 0
|
|
20
|
+
case "READABLE_LEFT": return 1
|
|
21
|
+
case "READABLE_CENTER": return 2
|
|
22
|
+
case "READABLE_RIGHT": return 3
|
|
23
|
+
default: return nil
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
func toTSPLRotation() -> Int32? {
|
|
28
|
+
switch self {
|
|
29
|
+
case "ROTATION_0": return 0
|
|
30
|
+
case "ROTATION_90": return 90
|
|
31
|
+
case "ROTATION_180": return 180
|
|
32
|
+
case "ROTATION_270": return 270
|
|
33
|
+
default: return nil
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
func toTSPLBarcodeType() -> String? {
|
|
38
|
+
switch self {
|
|
39
|
+
case "CODE_TYPE_128": return "128"
|
|
40
|
+
case "CODE_TYPE_128M": return "128M"
|
|
41
|
+
case "CODE_TYPE_EAN128": return "EAN128"
|
|
42
|
+
case "CODE_TYPE_25": return "25"
|
|
43
|
+
case "CODE_TYPE_25C": return "25C"
|
|
44
|
+
case "CODE_TYPE_39": return "39"
|
|
45
|
+
case "CODE_TYPE_39C": return "39C"
|
|
46
|
+
case "CODE_TYPE_93": return "93"
|
|
47
|
+
case "CODE_TYPE_EAN13": return "EAN13"
|
|
48
|
+
case "CODE_TYPE_EAN13_2": return "EAN13+2"
|
|
49
|
+
case "CODE_TYPE_EAN13_5": return "EAN13+5"
|
|
50
|
+
case "CODE_TYPE_EAN8": return "EAN8"
|
|
51
|
+
case "CODE_TYPE_EAN8_2": return "EAN8+2"
|
|
52
|
+
case "CODE_TYPE_EAN8_5": return "EAN8+5"
|
|
53
|
+
case "CODE_TYPE_CODA": return "CODA"
|
|
54
|
+
case "CODE_TYPE_POST": return "POST"
|
|
55
|
+
case "CODE_TYPE_UPCA": return "UPCA"
|
|
56
|
+
case "CODE_TYPE_UPCA_2": return "UPCA+2"
|
|
57
|
+
case "CODE_TYPE_UPCA_5": return "UPCA+5"
|
|
58
|
+
case "CODE_TYPE_UPCE": return "UPCE"
|
|
59
|
+
case "CODE_TYPE_UPCE_2": return "UPCE+2"
|
|
60
|
+
case "CODE_TYPE_UPCE_5": return "UPCE+5"
|
|
61
|
+
case "CODE_TYPE_CPOST": return "CPOST"
|
|
62
|
+
case "CODE_TYPE_MSI": return "MSI"
|
|
63
|
+
case "CODE_TYPE_MSIC": return "MSIC"
|
|
64
|
+
case "CODE_TYPE_PLESSEY": return "PLESSEY"
|
|
65
|
+
case "CODE_TYPE_ITF14": return "ITF14"
|
|
66
|
+
case "CODE_TYPE_EAN14": return "EAN14"
|
|
67
|
+
case "CODE_TYPE_11": return "11"
|
|
68
|
+
case "CODE_TYPE_TELEPEN": return "TELEPEN"
|
|
69
|
+
case "CODE_TYPE_TELEPENN": return "TELEPENN"
|
|
70
|
+
case "CODE_TYPE_PLANET": return "PLANET"
|
|
71
|
+
case "CODE_TYPE_CODE49": return "CODE49"
|
|
72
|
+
case "CODE_TYPE_DPI": return "DPI"
|
|
73
|
+
case "CODE_TYPE_DPL": return "DPL"
|
|
74
|
+
default: return nil
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
func toTSPLFont() -> String? {
|
|
79
|
+
switch self {
|
|
80
|
+
case "FNT_MONOTYE_CG_TRIUMVIRATE_BOLD_CONDENSED": return "0"
|
|
81
|
+
case "FNT_8_12": return "1"
|
|
82
|
+
case "FNT_12_20": return "2"
|
|
83
|
+
case "FNT_16_24": return "3"
|
|
84
|
+
case "FNT_24_32": return "4"
|
|
85
|
+
case "FNT_32_48": return "5"
|
|
86
|
+
case "FNT_14_19": return "6"
|
|
87
|
+
case "FNT_14_25": return "8"
|
|
88
|
+
case "FNT_21_27": return "7"
|
|
89
|
+
case "FNT_SIMPLIFIED_CHINESE": return "TSS24.BF2"
|
|
90
|
+
case "FNT_TRADITIONAL_CHINESE": return "TST24.BF2"
|
|
91
|
+
case "FNT_KOREAN": return "K"
|
|
92
|
+
default: return nil
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
func toTSPLECLevel() -> String? {
|
|
97
|
+
switch self {
|
|
98
|
+
case "EC_LEVEL_L": return "L"
|
|
99
|
+
case "EC_LEVEL_M": return "M"
|
|
100
|
+
case "EC_LEVEL_Q": return "Q"
|
|
101
|
+
case "EC_LEVEL_H": return "H"
|
|
102
|
+
default: return nil
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
func toTSPLQrcodeMode() -> String? {
|
|
107
|
+
switch self {
|
|
108
|
+
case "QRCODE_MODE_AUTO": return "A"
|
|
109
|
+
case "QRCODE_MODE_MANUAL": return "M"
|
|
110
|
+
default: return nil
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
func toTSPLQrcodeModel() -> String? {
|
|
115
|
+
switch self {
|
|
116
|
+
case "QRCODE_MODEL_M1": return "M1"
|
|
117
|
+
case "QRCODE_MODEL_M2": return "M2"
|
|
118
|
+
default: return nil
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
func toTSPLBitmapMode() -> Int32? {
|
|
123
|
+
switch self {
|
|
124
|
+
case "BMP_MODE_OVERWRITE": return 0
|
|
125
|
+
case "BMP_MODE_OR": return 1
|
|
126
|
+
case "BMP_MODE_XOR": return 2
|
|
127
|
+
default: return nil
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
func toTSPLBitmapCompressionMode() -> Int32? {
|
|
132
|
+
switch self {
|
|
133
|
+
case "BMP_MODE_OVERWRITE_C": return 3
|
|
134
|
+
case "BMP_MODE_OR_C": return 4
|
|
135
|
+
case "BMP_MODE_XOR_C": return 5
|
|
136
|
+
default: return nil
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
@objcMembers
|
|
3
|
+
public class RCTCheckIsPureWhiteImageRequest: NSObject {
|
|
4
|
+
public let bitmapPath: String?
|
|
5
|
+
public let bitmapContent: String?
|
|
6
|
+
|
|
7
|
+
public init(bitmapPath: String?, bitmapContent: String?) {
|
|
8
|
+
self.bitmapPath = bitmapPath
|
|
9
|
+
self.bitmapContent = bitmapContent
|
|
10
|
+
super.init()
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override public var description: String {
|
|
14
|
+
"RCTCheckIsPureWhiteImageRequest(bitmapPath=\(String(describing: bitmapPath)), bitmapContent=\(String(describing: bitmapContent)))"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
@objcMembers
|
|
3
|
+
public class NativeXPrinterUtils: NSObject {
|
|
4
|
+
public func isPureWhiteImage(payload: RCTCheckIsPureWhiteImageRequest,
|
|
5
|
+
resolve: @escaping (_ value: Bool) -> Void,
|
|
6
|
+
reject: @escaping (_ error: NativeErrorInfo) -> Void)
|
|
7
|
+
{
|
|
8
|
+
DispatchQueue.main.async {
|
|
9
|
+
do {
|
|
10
|
+
let result = try Utils.isPureWhiteImage(bitmapContent: payload.bitmapContent, bitmapPath: payload.bitmapPath)
|
|
11
|
+
resolve(result)
|
|
12
|
+
} catch {
|
|
13
|
+
reject(NativeErrorInfo(code: PrinterErrors.PARAMS_ERROR, message: error.localizedDescription, error: error))
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#import "RCTNativeXPrinterUtils.h"
|
|
2
|
+
#import "NativeXPrinter-Swift.h"
|
|
3
|
+
|
|
4
|
+
@implementation RCTNativeXPrinterUtils {
|
|
5
|
+
NativeXPrinterUtils* utils;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
- (id) init {
|
|
9
|
+
if (self = [super init]) {
|
|
10
|
+
utils = [NativeXPrinterUtils new];
|
|
11
|
+
}
|
|
12
|
+
return self;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
- (void)dealloc {
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
- (void)isPureWhiteImage:(JS::NativeXPrinterUtils::CheckIsPureWhiteImageRequest &)payload resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
20
|
+
[utils isPureWhiteImageWithPayload:[[RCTCheckIsPureWhiteImageRequest alloc] initWithBitmapPath:payload.bitmapPath() bitmapContent:payload.bitmapContent()] resolve:^(BOOL value) {
|
|
21
|
+
resolve(@(value));
|
|
22
|
+
} reject:^(NativeErrorInfo * _Nonnull errorInfo) {
|
|
23
|
+
reject(errorInfo.code, errorInfo.message, errorInfo.error);
|
|
24
|
+
}];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
28
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
29
|
+
{
|
|
30
|
+
return std::make_shared<facebook::react::NativeXPrinterUtilsSpecJSI>(params);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
+ (NSString *)moduleName
|
|
34
|
+
{
|
|
35
|
+
return @"NativeXPrinterUtils";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@end
|