@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,160 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConnectStatus,
|
|
3
|
+
type DeviceConnectStatusChangeEvent,
|
|
4
|
+
DeviceType,
|
|
5
|
+
NativeXPrinterPrinter,
|
|
6
|
+
type NetDevice,
|
|
7
|
+
PCLType,
|
|
8
|
+
type Spec,
|
|
9
|
+
type UpdateUdpNetConfigRequest,
|
|
10
|
+
} from './NativeXPrinterPrinter';
|
|
11
|
+
import { XPrinterPCLExecutor } from '../type';
|
|
12
|
+
import { XPrinterESCExecutor } from '../esc';
|
|
13
|
+
import { XPrinterTSPLExecutor } from '../tspl';
|
|
14
|
+
|
|
15
|
+
export class XPrinterPrinter
|
|
16
|
+
implements
|
|
17
|
+
Omit<
|
|
18
|
+
Spec,
|
|
19
|
+
'getConstants' | 'onDeviceConnectStatusChange' | 'onSearchNetDeviceFound'
|
|
20
|
+
>
|
|
21
|
+
{
|
|
22
|
+
private readonly module: Spec;
|
|
23
|
+
|
|
24
|
+
constructor(module: Spec) {
|
|
25
|
+
this.module = module;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getUsbDevices = async () => {
|
|
29
|
+
return this.module.getUsbDevices();
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
searchNetDevice = async () => {
|
|
33
|
+
return this.module.searchNetDevice();
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
udpNetConfig = async (request: UpdateUdpNetConfigRequest) => {
|
|
37
|
+
return this.module.udpNetConfig(request);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
connect = async (
|
|
41
|
+
connectInfo: string,
|
|
42
|
+
deviceType: DeviceType,
|
|
43
|
+
sync: boolean
|
|
44
|
+
) => {
|
|
45
|
+
let handleStatusChangeAction:
|
|
46
|
+
| ((info: DeviceConnectStatusChangeEvent) => void)
|
|
47
|
+
| undefined;
|
|
48
|
+
const pendingPromise = new Promise((resolve, reject) => {
|
|
49
|
+
handleStatusChangeAction = (info: DeviceConnectStatusChangeEvent) => {
|
|
50
|
+
if (info.code === ConnectStatus.CONNECT_SUCCESS) {
|
|
51
|
+
resolve(null);
|
|
52
|
+
} else {
|
|
53
|
+
reject(new Error(info.msg ?? 'Connect Error'));
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
const subscription = this.addDeviceConnectStatusChangeListener((info) => {
|
|
58
|
+
if (handleStatusChangeAction && info.connectInfo === connectInfo) {
|
|
59
|
+
handleStatusChangeAction(info);
|
|
60
|
+
handleStatusChangeAction = undefined;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
try {
|
|
64
|
+
await this.module.connect(connectInfo, deviceType, sync);
|
|
65
|
+
await pendingPromise;
|
|
66
|
+
} finally {
|
|
67
|
+
subscription.remove();
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
disconnect = async (connectInfo: string) => {
|
|
72
|
+
return this.module.disconnect(connectInfo);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
isConnect = async (connectInfo: string) => {
|
|
76
|
+
return this.module.isConnect(connectInfo);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
setPrinterPCL = (connectInfo: string, pcl: PCLType) => {
|
|
80
|
+
return this.module.setPrinterPCL(connectInfo, pcl);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
getPrinterPCL = (connectInfo: string) => {
|
|
84
|
+
return this.module.getPrinterPCL(connectInfo);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
readonly addDeviceConnectStatusChangeListener = (
|
|
88
|
+
listener: (event: DeviceConnectStatusChangeEvent) => void
|
|
89
|
+
) => {
|
|
90
|
+
return this.module.onDeviceConnectStatusChange(listener);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
readonly addSearchNetDeviceFoundListener = (
|
|
94
|
+
listener: (device: NetDevice) => void
|
|
95
|
+
) => {
|
|
96
|
+
return this.module.onSearchNetDeviceFound(listener);
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export const xPrinterPrinter = new XPrinterPrinter(NativeXPrinterPrinter);
|
|
101
|
+
|
|
102
|
+
export class XPrinterDevice {
|
|
103
|
+
readonly connectInfo: string;
|
|
104
|
+
private _pcl: PCLType | null = null;
|
|
105
|
+
private _executor: XPrinterPCLExecutor | null = null;
|
|
106
|
+
|
|
107
|
+
constructor(connectInfo: string, pclType?: PCLType) {
|
|
108
|
+
this.connectInfo = connectInfo;
|
|
109
|
+
if (pclType) {
|
|
110
|
+
this._pcl = pclType;
|
|
111
|
+
this.setupExecutor();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
get pcl(): PCLType | null {
|
|
116
|
+
return this._pcl;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
get executor(): XPrinterPCLExecutor | null {
|
|
120
|
+
return this._executor;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
connect = async (deviceType: DeviceType, sync: boolean) => {
|
|
124
|
+
return xPrinterPrinter.connect(this.connectInfo, deviceType, sync);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
disconnect = async () => {
|
|
128
|
+
return xPrinterPrinter.disconnect(this.connectInfo);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
isConnect = async () => {
|
|
132
|
+
return xPrinterPrinter.isConnect(this.connectInfo);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
setPCL = async (pcl: PCLType) => {
|
|
136
|
+
await xPrinterPrinter.setPrinterPCL(this.connectInfo, pcl);
|
|
137
|
+
this._pcl = pcl;
|
|
138
|
+
this.setupExecutor();
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
readonly addConnectStatusChangeListener = (
|
|
142
|
+
listener: (event: DeviceConnectStatusChangeEvent) => void
|
|
143
|
+
) => {
|
|
144
|
+
return xPrinterPrinter.addDeviceConnectStatusChangeListener((event) => {
|
|
145
|
+
if (event.connectInfo === this.connectInfo) {
|
|
146
|
+
listener(event);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
private setupExecutor = () => {
|
|
152
|
+
if (this._pcl === PCLType.ESC) {
|
|
153
|
+
this._executor = new XPrinterESCExecutor(this.connectInfo);
|
|
154
|
+
} else if (this._pcl === PCLType.TSPL) {
|
|
155
|
+
this._executor = new XPrinterTSPLExecutor(this.connectInfo);
|
|
156
|
+
} else {
|
|
157
|
+
this._executor = null;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { type TurboModule, TurboModuleRegistry } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export interface Spec extends TurboModule {
|
|
4
|
+
sizeInch(connectInfo: string, width: number, height: number): Promise<void>;
|
|
5
|
+
|
|
6
|
+
sizeMm(connectInfo: string, width: number, height: number): Promise<void>;
|
|
7
|
+
|
|
8
|
+
gapInch(connectInfo: string, m: number, n: number): Promise<void>;
|
|
9
|
+
|
|
10
|
+
gapMm(connectInfo: string, m: number, n: number): Promise<void>;
|
|
11
|
+
|
|
12
|
+
speed(connectInfo: string, speed: number): Promise<void>;
|
|
13
|
+
|
|
14
|
+
density(
|
|
15
|
+
connectInfo: string,
|
|
16
|
+
//0-15
|
|
17
|
+
density: number
|
|
18
|
+
): Promise<void>;
|
|
19
|
+
|
|
20
|
+
direction(
|
|
21
|
+
connectInfo: string,
|
|
22
|
+
direction: Direction,
|
|
23
|
+
//android only
|
|
24
|
+
isMirror: boolean
|
|
25
|
+
): Promise<void>;
|
|
26
|
+
|
|
27
|
+
cls(connectInfo: string): Promise<void>;
|
|
28
|
+
|
|
29
|
+
box(connectInfo: string, payload: BoxRequest): Promise<void>;
|
|
30
|
+
|
|
31
|
+
bar(connectInfo: string, payload: BarRequest): Promise<void>;
|
|
32
|
+
|
|
33
|
+
barcode(connectInfo: string, payload: BarcodeRequest): Promise<void>;
|
|
34
|
+
|
|
35
|
+
text(connectInfo: string, payload: TextRequest): Promise<void>;
|
|
36
|
+
|
|
37
|
+
offsetInch(connectInfo: string, offset: number): Promise<void>;
|
|
38
|
+
|
|
39
|
+
offsetMm(connectInfo: string, offset: number): Promise<void>;
|
|
40
|
+
|
|
41
|
+
reference(connectInfo: string, x: number, y: number): Promise<void>;
|
|
42
|
+
|
|
43
|
+
qrcode(connectInfo: string, payload: QRCodeRequest): Promise<void>;
|
|
44
|
+
|
|
45
|
+
print(connectInfo: string, count: number): Promise<void>;
|
|
46
|
+
|
|
47
|
+
//only android
|
|
48
|
+
printWithResponse(
|
|
49
|
+
connectInfo: string,
|
|
50
|
+
count: number,
|
|
51
|
+
timeout: number
|
|
52
|
+
): Promise<number>;
|
|
53
|
+
|
|
54
|
+
feed(
|
|
55
|
+
connectInfo: string,
|
|
56
|
+
//1-9999
|
|
57
|
+
length: number
|
|
58
|
+
): Promise<void>;
|
|
59
|
+
|
|
60
|
+
backFeed(
|
|
61
|
+
connectInfo: string,
|
|
62
|
+
//1-9999
|
|
63
|
+
length: number
|
|
64
|
+
): Promise<void>;
|
|
65
|
+
|
|
66
|
+
formFeed(connectInfo: string): Promise<void>;
|
|
67
|
+
|
|
68
|
+
limitFeedMm(connectInfo: string, length: number): Promise<void>;
|
|
69
|
+
|
|
70
|
+
limitFeedInch(connectInfo: string, length: number): Promise<void>;
|
|
71
|
+
|
|
72
|
+
home(connectInfo: string): Promise<void>;
|
|
73
|
+
|
|
74
|
+
codePage(
|
|
75
|
+
connectInfo: string,
|
|
76
|
+
//见文档
|
|
77
|
+
page: string
|
|
78
|
+
): Promise<void>;
|
|
79
|
+
|
|
80
|
+
sound(
|
|
81
|
+
connectInfo: string,
|
|
82
|
+
//0-9
|
|
83
|
+
level: number,
|
|
84
|
+
//ms, 1-4096
|
|
85
|
+
interval: number
|
|
86
|
+
): Promise<void>;
|
|
87
|
+
|
|
88
|
+
bitmap(connectInfo: string, payload: BitmapRequest): Promise<void>;
|
|
89
|
+
|
|
90
|
+
bitmapCompression(
|
|
91
|
+
connectInfo: string,
|
|
92
|
+
payload: BitmapCompressionRequest
|
|
93
|
+
): Promise<void>;
|
|
94
|
+
|
|
95
|
+
//only android
|
|
96
|
+
pdfBase64(connectInfo: string, payload: PDFBase64Request): Promise<void>;
|
|
97
|
+
|
|
98
|
+
erase(connectInfo: string, payload: EraseRequest): Promise<void>;
|
|
99
|
+
|
|
100
|
+
reverse(connectInfo: string, payload: ReverseRequest): Promise<void>;
|
|
101
|
+
|
|
102
|
+
cut(connectInfo: string): Promise<void>;
|
|
103
|
+
|
|
104
|
+
setPeel(connectInfo: string, isOpen: boolean): Promise<void>;
|
|
105
|
+
|
|
106
|
+
setTear(connectInfo: string, isOpen: boolean): Promise<void>;
|
|
107
|
+
|
|
108
|
+
//only android
|
|
109
|
+
setCutter(connectInfo: string, pieces: number): Promise<void>;
|
|
110
|
+
|
|
111
|
+
putBMP(connectInfo: string, payload: PutBMPRequest): Promise<void>;
|
|
112
|
+
|
|
113
|
+
blineInch(
|
|
114
|
+
connectInfo: string,
|
|
115
|
+
//0.1-1
|
|
116
|
+
m: number,
|
|
117
|
+
//0-label length
|
|
118
|
+
n: number
|
|
119
|
+
): Promise<void>;
|
|
120
|
+
|
|
121
|
+
blineMm(
|
|
122
|
+
connectInfo: string,
|
|
123
|
+
//2.54 25.4
|
|
124
|
+
m: number,
|
|
125
|
+
//0-label length
|
|
126
|
+
n: number
|
|
127
|
+
): Promise<void>;
|
|
128
|
+
|
|
129
|
+
//only android
|
|
130
|
+
setPrinterModel(connectInfo: string, model: string): Promise<void>;
|
|
131
|
+
|
|
132
|
+
//only android
|
|
133
|
+
getPrinterModel(connectInfo: string): Promise<string>;
|
|
134
|
+
|
|
135
|
+
printerStatus(
|
|
136
|
+
connectInfo: string,
|
|
137
|
+
//only android
|
|
138
|
+
timeout: number
|
|
139
|
+
): Promise<{
|
|
140
|
+
status: number;
|
|
141
|
+
debugCode?: number;
|
|
142
|
+
}>;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export const NativeXPrinterTSPL =
|
|
146
|
+
TurboModuleRegistry.getEnforcing<Spec>('NativeXPrinterTSPL');
|
|
147
|
+
|
|
148
|
+
export enum Direction {
|
|
149
|
+
DIRECTION_FORWARD = 'DIRECTION_FORWARD',
|
|
150
|
+
DIRECTION_REVERSE = 'DIRECTION_REVERSE',
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export enum BarcodeType {
|
|
154
|
+
CODE_TYPE_12 = 'CODE_TYPE_128',
|
|
155
|
+
CODE_TYPE_128M = 'CODE_TYPE_128M',
|
|
156
|
+
CODE_TYPE_EAN128 = 'CODE_TYPE_EAN128',
|
|
157
|
+
CODE_TYPE_25 = 'CODE_TYPE_25',
|
|
158
|
+
CODE_TYPE_25C = 'CODE_TYPE_25C',
|
|
159
|
+
CODE_TYPE_39 = 'CODE_TYPE_39',
|
|
160
|
+
CODE_TYPE_39C = 'CODE_TYPE_39C',
|
|
161
|
+
CODE_TYPE_93 = 'CODE_TYPE_93',
|
|
162
|
+
CODE_TYPE_EAN13 = 'CODE_TYPE_EAN13',
|
|
163
|
+
CODE_TYPE_EAN13_2 = 'CODE_TYPE_EAN13_2',
|
|
164
|
+
CODE_TYPE_EAN13_5 = 'CODE_TYPE_EAN13_5',
|
|
165
|
+
CODE_TYPE_EAN8 = 'CODE_TYPE_EAN8',
|
|
166
|
+
CODE_TYPE_EAN8_2 = 'CODE_TYPE_EAN8_2',
|
|
167
|
+
CODE_TYPE_EAN8_5 = 'CODE_TYPE_EAN8_5',
|
|
168
|
+
CODE_TYPE_CODA = 'CODE_TYPE_CODA',
|
|
169
|
+
CODE_TYPE_POST = 'CODE_TYPE_POST',
|
|
170
|
+
CODE_TYPE_UPCA = 'CODE_TYPE_UPCA',
|
|
171
|
+
CODE_TYPE_UPCA_2 = 'CODE_TYPE_UPCA_2',
|
|
172
|
+
CODE_TYPE_UPCA_5 = 'CODE_TYPE_UPCA_5',
|
|
173
|
+
CODE_TYPE_UPCE = 'CODE_TYPE_UPCE',
|
|
174
|
+
CODE_TYPE_UPCE_2 = 'CODE_TYPE_UPCE_2',
|
|
175
|
+
CODE_TYPE_UPCE_5 = 'CODE_TYPE_UPCE_5',
|
|
176
|
+
CODE_TYPE_CPOST = 'CODE_TYPE_CPOST',
|
|
177
|
+
CODE_TYPE_MSI = 'CODE_TYPE_MSI',
|
|
178
|
+
CODE_TYPE_MSIC = 'CODE_TYPE_MSIC',
|
|
179
|
+
CODE_TYPE_PLESSE = 'CODE_TYPE_PLESSEY',
|
|
180
|
+
CODE_TYPE_ITF14 = 'CODE_TYPE_ITF14',
|
|
181
|
+
CODE_TYPE_EAN14 = 'CODE_TYPE_EAN14',
|
|
182
|
+
CODE_TYPE_11 = 'CODE_TYPE_11',
|
|
183
|
+
CODE_TYPE_TELEPEN = 'CODE_TYPE_TELEPEN',
|
|
184
|
+
CODE_TYPE_TELEPENN = 'CODE_TYPE_TELEPENN',
|
|
185
|
+
CODE_TYPE_PLANET = 'CODE_TYPE_PLANET',
|
|
186
|
+
CODE_TYPE_CODE49 = 'CODE_TYPE_CODE49',
|
|
187
|
+
CODE_TYPE_DPI = 'CODE_TYPE_DPI',
|
|
188
|
+
CODE_TYPE_DPL = 'CODE_TYPE_DPL',
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export enum Readable {
|
|
192
|
+
READABLE_NONE = 'READABLE_NONE',
|
|
193
|
+
READABLE_LEFT = 'READABLE_LEFT',
|
|
194
|
+
READABLE_CENTER = 'READABLE_CENTER',
|
|
195
|
+
READABLE_RIGHT = 'READABLE_RIGHT',
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export enum Rotation {
|
|
199
|
+
ROTATION_0 = 'ROTATION_0',
|
|
200
|
+
ROTATION_90 = 'ROTATION_90',
|
|
201
|
+
ROTATION_180 = 'ROTATION_180',
|
|
202
|
+
ROTATION_270 = 'ROTATION_270',
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export enum Font {
|
|
206
|
+
FNT_8_12 = 'FNT_8_12',
|
|
207
|
+
FNT_12_20 = 'FNT_12_20',
|
|
208
|
+
FNT_16_24 = 'FNT_16_24',
|
|
209
|
+
FNT_24_32 = 'FNT_24_32',
|
|
210
|
+
FNT_32_48 = 'FNT_32_48',
|
|
211
|
+
FNT_14_19 = 'FNT_14_19',
|
|
212
|
+
FNT_14_25 = 'FNT_14_25',
|
|
213
|
+
FNT_21_27 = 'FNT_21_27',
|
|
214
|
+
FNT_SIMPLIFIED_CHINESE = 'FNT_SIMPLIFIED_CHINESE',
|
|
215
|
+
FNT_TRADITIONAL_CHINESE = 'FNT_TRADITIONAL_CHINESE',
|
|
216
|
+
FNT_KOREAN = 'FNT_KOREAN',
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export enum ECLevel {
|
|
220
|
+
EC_LEVEL_L = 'EC_LEVEL_L',
|
|
221
|
+
EC_LEVEL_M = 'EC_LEVEL_M',
|
|
222
|
+
EC_LEVEL_Q = 'EC_LEVEL_Q',
|
|
223
|
+
EC_LEVEL_H = 'EC_LEVEL_H',
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export enum QRCodeMode {
|
|
227
|
+
QRCODE_MODE_AUTO = 'QRCODE_MODE_AUTO',
|
|
228
|
+
QRCODE_MODE_MANUAL = 'QRCODE_MODE_MANUAL',
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export enum QRCodeModel {
|
|
232
|
+
QRCODE_MODEL_M1 = 'QRCODE_MODEL_M1',
|
|
233
|
+
QRCODE_MODEL_M2 = 'QRCODE_MODE_MANUAL',
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export enum BitmapMode {
|
|
237
|
+
BMP_MODE_OVERWRITE = 'BMP_MODE_OVERWRITE',
|
|
238
|
+
BMP_MODE_OR = 'BMP_MODE_OR',
|
|
239
|
+
BMP_MODE_XOR = 'BMP_MODE_XOR',
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export enum BitmapAlgorithmType {
|
|
243
|
+
THRESHOLD = 'THRESHOLD',
|
|
244
|
+
DITHERING = 'DITHERING',
|
|
245
|
+
NONE = 'NONE',
|
|
246
|
+
DIFFUSION = 'DIFFUSION',
|
|
247
|
+
HALFTONE = 'HALFTONE',
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export enum BitmapCompressionMode {
|
|
251
|
+
BMP_MODE_OVERWRITE_C = 'BMP_MODE_OVERWRITE_C',
|
|
252
|
+
BMP_MODE_OR_C = 'BMP_MODE_OR_C',
|
|
253
|
+
BMP_MODE_XOR_C = 'BMP_MODE_XOR_C',
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export enum PrinterStatus {
|
|
257
|
+
PRINTER_STATUS_NORMAL = 'PRINTER_STATUS_NORMAL',
|
|
258
|
+
PRINTER_STATUS_COVER_OPEN = 'PRINTER_STATUS_COVER_OPEN',
|
|
259
|
+
PRINTER_STATUS_PAPER_JAM = 'PRINTER_STATUS_PAPER_JAM',
|
|
260
|
+
PRINTER_STATUS_PAPER_JAM_AND_COVER_OPEN = 'PRINTER_STATUS_PAPER_JAM_AND_COVER_OPEN',
|
|
261
|
+
PRINTER_STATUS_OUT_OF_PAPER = 'PRINTER_STATUS_OUT_OF_PAPER',
|
|
262
|
+
PRINTER_STATUS_OUT_OF_PAPER_AND_COVER_OPEN = 'PRINTER_STATUS_OUT_OF_PAPER_AND_COVER_OPEN',
|
|
263
|
+
PRINTER_STATUS_NO_RIBBON = 'PRINTER_STATUS_NO_RIBBON',
|
|
264
|
+
PRINTER_STATUS_NO_RIBBON_AND_COVER_OPEN = 'PRINTER_STATUS_NO_RIBBON_AND_COVER_OPEN',
|
|
265
|
+
PRINTER_STATUS_NO_RIBBON_AND_PAPER_JAM = 'PRINTER_STATUS_NO_RIBBON_AND_PAPER_JAM',
|
|
266
|
+
PRINTER_STATUS_NO_RIBBON_AND_PAPER_JAM_AND_COVER_OPEN = 'PRINTER_STATUS_NO_RIBBON_AND_PAPER_JAM_AND_COVER_OPEN',
|
|
267
|
+
PRINTER_STATUS_NO_RIBBON_AND_OUT_OF_PAPER = 'PRINTER_STATUS_NO_RIBBON_AND_OUT_OF_PAPER',
|
|
268
|
+
PRINTER_STATUS_NO_RIBBON_AND_OUT_OF_PAPER_AND_COVER_OPEN = 'PRINTER_STATUS_NO_RIBBON_AND_OUT_OF_PAPER_AND_COVER_OPEN',
|
|
269
|
+
PRINTER_STATUS_PAUSED = 'PRINTER_STATUS_PAUSED',
|
|
270
|
+
PRINTER_STATUS_PRINTING = 'PRINTER_STATUS_PRINTING',
|
|
271
|
+
PRINTER_STATUS_OTHER_ERROR = 'PRINTER_STATUS_OTHER_ERROR',
|
|
272
|
+
PRINTER_STATUS_TIMOUT_OR_DATA_ERROR = 'PRINTER_STATUS_TIMOUT_OR_DATA_ERROR',
|
|
273
|
+
PRINTER_STATUS_UNKNOWN = 'PRINTER_STATUS_UNKNOWN',
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export interface BoxRequest {
|
|
277
|
+
x: number;
|
|
278
|
+
y: number;
|
|
279
|
+
width: number;
|
|
280
|
+
height: number;
|
|
281
|
+
thickness: number;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export interface BarRequest {
|
|
285
|
+
x: number;
|
|
286
|
+
y: number;
|
|
287
|
+
width: number;
|
|
288
|
+
height: number;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export interface BarcodeRequest {
|
|
292
|
+
x: number;
|
|
293
|
+
y: number;
|
|
294
|
+
codeType: BarcodeType;
|
|
295
|
+
height: number;
|
|
296
|
+
readable: Readable;
|
|
297
|
+
rotation: Rotation;
|
|
298
|
+
narrow: number;
|
|
299
|
+
wide: number;
|
|
300
|
+
content: string;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export interface TextRequest {
|
|
304
|
+
x: number;
|
|
305
|
+
y: number;
|
|
306
|
+
font: Font;
|
|
307
|
+
rotation: Rotation;
|
|
308
|
+
//1-10
|
|
309
|
+
xRatio: number;
|
|
310
|
+
//1-10
|
|
311
|
+
yRatio: number;
|
|
312
|
+
content: string;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export interface QRCodeRequest {
|
|
316
|
+
x: number;
|
|
317
|
+
y: number;
|
|
318
|
+
ecLevel: ECLevel;
|
|
319
|
+
//1-10
|
|
320
|
+
cellWidth: number;
|
|
321
|
+
mode: QRCodeMode;
|
|
322
|
+
rotation: Rotation;
|
|
323
|
+
//only android
|
|
324
|
+
model: QRCodeModel;
|
|
325
|
+
//S0-S8
|
|
326
|
+
mask: string;
|
|
327
|
+
data: string;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export type BitmapRequest = {
|
|
331
|
+
x: number;
|
|
332
|
+
y: number;
|
|
333
|
+
mode: BitmapMode;
|
|
334
|
+
width: number;
|
|
335
|
+
bitmapPath: string | null;
|
|
336
|
+
bitmapContent: string | null;
|
|
337
|
+
//only android
|
|
338
|
+
algorithmType?: BitmapAlgorithmType;
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
export type BitmapCompressionRequest = {
|
|
342
|
+
x: number;
|
|
343
|
+
y: number;
|
|
344
|
+
mode: BitmapCompressionMode;
|
|
345
|
+
width: number;
|
|
346
|
+
bitmapPath: string | null;
|
|
347
|
+
bitmapContent: string | null;
|
|
348
|
+
algorithmType?: BitmapAlgorithmType;
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
export interface PDFBase64Request {
|
|
352
|
+
x: number;
|
|
353
|
+
y: number;
|
|
354
|
+
pageWidth: number;
|
|
355
|
+
base64String: string;
|
|
356
|
+
algorithmType: BitmapAlgorithmType;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export interface EraseRequest {
|
|
360
|
+
x: number;
|
|
361
|
+
y: number;
|
|
362
|
+
width: number;
|
|
363
|
+
height: number;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export interface ReverseRequest {
|
|
367
|
+
x: number;
|
|
368
|
+
y: number;
|
|
369
|
+
width: number;
|
|
370
|
+
height: number;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export interface PutBMPRequest {
|
|
374
|
+
x: number;
|
|
375
|
+
y: number;
|
|
376
|
+
fileName: string;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
export const DEFAULT_READABLE = Readable.READABLE_LEFT;
|
|
380
|
+
export const DEFAULT_ROTATION = Rotation.ROTATION_0;
|
|
381
|
+
export const DEFAULT_NARROW = 2;
|
|
382
|
+
export const DEFAULT_WIDE = 2;
|
|
383
|
+
export const DEFAULT_EC_LEVEL = ECLevel.EC_LEVEL_L;
|
|
384
|
+
export const DEFAULT_QR_MASK = 'S7';
|
|
385
|
+
export const DEFAULT_QR_MODE = QRCodeMode.QRCODE_MODE_AUTO;
|
|
386
|
+
export const DEFAULT_QR_MODEL = QRCodeModel.QRCODE_MODEL_M1;
|
|
387
|
+
export const DEFAULT_BITMAP_ALGORITHM_TYPE = BitmapAlgorithmType.THRESHOLD;
|
|
388
|
+
export const DEFAULT_PRINT_STATUS_TIMEOUT = 5000;
|