react-native-printer-imin 0.2.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 ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 iminsoftware
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # react-native-printer-imin
2
+
3
+ Native Module For iMin Printer SDK Plugin
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install react-native-printer-imin
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```js
14
+ import PrinterImin from 'react-native-printer-imin';
15
+
16
+ // ...
17
+ PrinterImin.initPrinter();
18
+
19
+ PrinterImin.getPrinterStatus().then((info) => {
20
+ console.log(info);
21
+ });
22
+
23
+ PrinterImin.printText('hello world');
24
+ ```
25
+
26
+ ## Contributing
27
+
28
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
29
+
30
+ ## License
31
+
32
+ MIT
33
+
34
+ ---
35
+
36
+ Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
@@ -0,0 +1,101 @@
1
+ buildscript {
2
+ repositories {
3
+ google()
4
+ mavenCentral()
5
+ }
6
+
7
+ dependencies {
8
+ classpath "com.android.tools.build:gradle:7.2.1"
9
+ }
10
+ }
11
+
12
+ def isNewArchitectureEnabled() {
13
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
14
+ }
15
+
16
+ apply plugin: "com.android.library"
17
+
18
+ if (isNewArchitectureEnabled()) {
19
+ apply plugin: "com.facebook.react"
20
+ }
21
+
22
+ def getExtOrDefault(name) {
23
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["PrinterImin_" + name]
24
+ }
25
+
26
+ def getExtOrIntegerDefault(name) {
27
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["PrinterImin_" + name]).toInteger()
28
+ }
29
+
30
+ def supportsNamespace() {
31
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
32
+ def major = parsed[0].toInteger()
33
+ def minor = parsed[1].toInteger()
34
+
35
+ // Namespace support was added in 7.3.0
36
+ return (major == 7 && minor >= 3) || major >= 8
37
+ }
38
+
39
+ android {
40
+ if (supportsNamespace()) {
41
+ namespace "com.printerimin"
42
+
43
+ sourceSets {
44
+ main {
45
+ jniLibs.srcDirs = ['jniLibs']
46
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
47
+ }
48
+ }
49
+ }
50
+
51
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
52
+
53
+ defaultConfig {
54
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
55
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
56
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
57
+ ndk {
58
+ abiFilters "armeabi-v7a", "x86", "arm64-v8a"
59
+ }
60
+ }
61
+
62
+ buildTypes {
63
+ release {
64
+ minifyEnabled false
65
+ }
66
+ }
67
+
68
+ lintOptions {
69
+ disable "GradleCompatible"
70
+ }
71
+
72
+ compileOptions {
73
+ sourceCompatibility JavaVersion.VERSION_1_8
74
+ targetCompatibility JavaVersion.VERSION_1_8
75
+ }
76
+ }
77
+
78
+ repositories {
79
+ mavenCentral()
80
+ google()
81
+ }
82
+
83
+
84
+ dependencies {
85
+ // For < 0.71, this will be from the local maven repo
86
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
87
+ //noinspection GradleDynamicVersion
88
+ implementation "com.facebook.react:react-native:+"
89
+ implementation files('libs/iminPrinterSDK.jar')
90
+ implementation files('libs/IminLibs1.0.15.jar')
91
+ implementation files('libs/IminStraElectronicSDK_V1.2.jar')
92
+ implementation 'com.github.bumptech.glide:glide:4.16.0'
93
+ }
94
+
95
+ if (isNewArchitectureEnabled()) {
96
+ react {
97
+ jsRootDir = file("../src/")
98
+ libraryName = "iminprinter"
99
+ codegenJavaPackageName = "com.iminprinter"
100
+ }
101
+ }
@@ -0,0 +1,5 @@
1
+ PrinterImin_kotlinVersion=1.7.0
2
+ PrinterImin_minSdkVersion=21
3
+ PrinterImin_targetSdkVersion=31
4
+ PrinterImin_compileSdkVersion=31
5
+ PrinterImin_ndkversion=21.4.7075529
Binary file
Binary file
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.printerimin"></manifest>
@@ -0,0 +1,5 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <queries>
3
+ <package android:name="woyou.aidlservice.jiuiv5" />
4
+ </queries>
5
+ </manifest>
@@ -0,0 +1,107 @@
1
+ package com.printerimin;
2
+
3
+ import androidx.annotation.NonNull;
4
+
5
+ import com.facebook.react.bridge.Promise;
6
+ import com.facebook.react.bridge.ReactApplicationContext;
7
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
8
+ import com.facebook.react.bridge.ReactMethod;
9
+ import com.facebook.react.module.annotations.ReactModule;
10
+
11
+ import com.imin.library.IminSDKManager;
12
+ import com.imin.library.SystemPropManager;
13
+ import com.imin.printerlib.Callback;
14
+ import com.imin.printerlib.IminPrintUtils;
15
+ import com.imin.printerlib.print.PrintUtils;
16
+
17
+ @ReactModule(name = PrinterIminModule.NAME)
18
+ public class PrinterIminModule extends ReactContextBaseJavaModule {
19
+ private final ReactApplicationContext reactContext;
20
+ public static final String NAME = "PrinterImin";
21
+ private IminPrintUtils iminPrintUtils;
22
+ private IminPrintUtils.PrintConnectType connectType = IminPrintUtils.PrintConnectType.SPI;
23
+
24
+ public PrinterIminModule(ReactApplicationContext reactContext) {
25
+ super(reactContext);
26
+ this.reactContext = reactContext;
27
+ iminPrintUtils = IminPrintUtils.getInstance(reactContext);
28
+ String deviceModel = SystemPropManager.getModel();
29
+ if (deviceModel.contains("M2-203") || deviceModel.contains("M2-202") || deviceModel.contains("M2-Pro")) {
30
+ connectType = IminPrintUtils.PrintConnectType.SPI;
31
+ } else {
32
+ connectType = IminPrintUtils.PrintConnectType.USB;
33
+ }
34
+ iminPrintUtils.resetDevice();
35
+ }
36
+
37
+ @Override
38
+ @NonNull
39
+ public String getName() {
40
+ return NAME;
41
+ }
42
+
43
+
44
+ @ReactMethod
45
+ public void initPrinter(final Promise promise) {
46
+ try {
47
+ iminPrintUtils.initPrinter(connectType);
48
+ promise.resolve(true);
49
+ } catch (Exception e) {
50
+ promise.reject("ININTPRINTER_FAILED", e.getMessage());
51
+ }
52
+ }
53
+
54
+ @ReactMethod
55
+ public void getPrinterStatus(final Promise promise) {
56
+ WritableMap payload = Arguments.createMap();
57
+ if (connectType.equals(IminPrintUtils.PrintConnectType.SPI)) {
58
+ iminPrintUtils.getPrinterStatus(connectType, new Callback() {
59
+ @Override
60
+ public void callback(int status) {
61
+ payload.putString("message", getPrinterStatusText(status));
62
+ payload.putString("code", String.format("%d", status));
63
+ promise.resolve(payload);
64
+ }
65
+ });
66
+ } else {
67
+ int status = iminPrintUtils.getPrinterStatus(connectType);
68
+ payload.putString("message", getPrinterStatusText(status));
69
+ payload.putString("code", String.format("%d", status));
70
+ promise.resolve(payload);
71
+ }
72
+ }
73
+
74
+ @ReactMethod
75
+ public void printText(String text, final Promise promise) {
76
+ try {
77
+ iminPrintUtils.printText(text);
78
+ promise.resolve(null);
79
+ } catch (Exception e) {
80
+ promise.reject("printText_failed", e.getMessage());
81
+ }
82
+ }
83
+
84
+ private String getPrinterStatusText(int code) {
85
+ if (code == 0) {
86
+ return "Printer is normal!";
87
+ } else if (code == 1) {
88
+ return "The printer and call library do not match!";
89
+ } else if (code == 3) {
90
+ return "Print head open!";
91
+ } else if (code == 4) {
92
+ return "The cutter is not reset!!";
93
+ } else if (code == 5) {
94
+ return "Overheated!";
95
+ } else if (code == 6) {
96
+ return "Black label error!";
97
+ } else if (code == 7) {
98
+ return "Paper Jam!";
99
+ } else if (code == 8) {
100
+ return "Paper Out!";
101
+ } else if (code == 99) {
102
+ return "Other errors!";
103
+ } else {
104
+ return "Printer is not connected or powered on!";
105
+ }
106
+ }
107
+ }
@@ -0,0 +1,28 @@
1
+ package com.printerimin;
2
+
3
+ import androidx.annotation.NonNull;
4
+
5
+ import com.facebook.react.ReactPackage;
6
+ import com.facebook.react.bridge.NativeModule;
7
+ import com.facebook.react.bridge.ReactApplicationContext;
8
+ import com.facebook.react.uimanager.ViewManager;
9
+
10
+ import java.util.ArrayList;
11
+ import java.util.Collections;
12
+ import java.util.List;
13
+
14
+ public class PrinterIminPackage implements ReactPackage {
15
+ @NonNull
16
+ @Override
17
+ public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
18
+ List<NativeModule> modules = new ArrayList<>();
19
+ modules.add(new PrinterIminModule(reactContext));
20
+ return modules;
21
+ }
22
+
23
+ @NonNull
24
+ @Override
25
+ public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
26
+ return Collections.emptyList();
27
+ }
28
+ }
@@ -0,0 +1,2 @@
1
+ #import <React/RCTBridgeModule.h>
2
+ #import <React/RCTViewManager.h>
@@ -0,0 +1,14 @@
1
+ #import <React/RCTBridgeModule.h>
2
+
3
+ @interface RCT_EXTERN_MODULE(PrinterImin, NSObject)
4
+
5
+ RCT_EXTERN_METHOD(multiply:(float)a withB:(float)b
6
+ withResolver:(RCTPromiseResolveBlock)resolve
7
+ withRejecter:(RCTPromiseRejectBlock)reject)
8
+
9
+ + (BOOL)requiresMainQueueSetup
10
+ {
11
+ return NO;
12
+ }
13
+
14
+ @end
@@ -0,0 +1,8 @@
1
+ @objc(PrinterImin)
2
+ class PrinterImin: NSObject {
3
+
4
+ @objc(multiply:withB:withResolver:withRejecter:)
5
+ func multiply(a: Float, b: Float, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) -> Void {
6
+ resolve(a*b)
7
+ }
8
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "IminPrintAlign", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _typing.IminPrintAlign;
10
+ }
11
+ });
12
+ exports.default = void 0;
13
+ var _reactNative = require("react-native");
14
+ var _typing = require("./typing");
15
+ const LINKING_ERROR = `The package 'react-native-printer-imin' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
16
+ ios: "- You have run 'pod install'\n",
17
+ default: ''
18
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
19
+ const PrinterImin = _reactNative.NativeModules.PrinterImin ? _reactNative.NativeModules.PrinterImin : new Proxy({}, {
20
+ get() {
21
+ throw new Error(LINKING_ERROR);
22
+ }
23
+ });
24
+ const PrinterSDK = {
25
+ initPrinter: PrinterImin.initPrinter,
26
+ getPrinterStatus: PrinterImin.getPrinterStatus,
27
+ printText: PrinterImin.printText
28
+ };
29
+ var _default = exports.default = PrinterSDK;
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_typing","LINKING_ERROR","Platform","select","ios","default","PrinterImin","NativeModules","Proxy","get","Error","PrinterSDK","initPrinter","getPrinterStatus","printText","_default","exports"],"sourceRoot":"..\\..\\src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,MAAME,aAAa,GAChB,oFAAmF,GACpFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,WAAW,GAAGC,0BAAa,CAACD,WAAW,GACzCC,0BAAa,CAACD,WAAW,GACzB,IAAIE,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,MAAMU,UAA2B,GAAG;EAClCC,WAAW,EAAEN,WAAW,CAACM,WAAW;EACpCC,gBAAgB,EAAEP,WAAW,CAACO,gBAAgB;EAC9CC,SAAS,EAAER,WAAW,CAACQ;AACzB,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAX,OAAA,GAEaM,UAAU"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.IminPrintAlign = void 0;
7
+ // enum IminTypeface {
8
+ // Default = 0,
9
+ // Monospace = 1,
10
+ // DefaultBold = 2,
11
+ // SansSerif = 3,
12
+ // Serif = 4,
13
+ // }
14
+ // enum IminFontStyle {
15
+ // normal = 0,
16
+ // bold = 1,
17
+ // italic = 2,
18
+ // boldItalic = 3,
19
+ // }
20
+ let IminPrintAlign = exports.IminPrintAlign = /*#__PURE__*/function (IminPrintAlign) {
21
+ IminPrintAlign[IminPrintAlign["left"] = 0] = "left";
22
+ IminPrintAlign[IminPrintAlign["center"] = 1] = "center";
23
+ IminPrintAlign[IminPrintAlign["right"] = 2] = "right";
24
+ return IminPrintAlign;
25
+ }({}); // enum IminQrcodeCorrectionLevel {
26
+ // levelL = 48,
27
+ // levelM = 49,
28
+ // levelQ = 50,
29
+ // levelH = 51,
30
+ // }
31
+ // enum IminBarcodeTextPos {
32
+ // none = 0,
33
+ // aboveText = 1,
34
+ // belowText = 2,
35
+ // both = 3,
36
+ // }
37
+ // enum IminBarcodeType {
38
+ // upcA = 0,
39
+ // upcE = 1,
40
+ // jan13 = 2,
41
+ // jan8 = 3,
42
+ // code39 = 4,
43
+ // itf = 5,
44
+ // codabar = 6,
45
+ // code128 = 73,
46
+ // }
47
+ // interface TextStyle {
48
+ // wordWrap: boolean;
49
+ // fontSize: number;
50
+ // space: number;
51
+ // width: number;
52
+ // typeface: IminTypeface;
53
+ // fontStyle: IminFontStyle;
54
+ // align: IminPrintAlign;
55
+ // }
56
+ //# sourceMappingURL=typing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["IminPrintAlign","exports"],"sourceRoot":"..\\..\\src","sources":["typing.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,IAEYA,cAAc,GAAAC,OAAA,CAAAD,cAAA,0BAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA,OAK1B;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -0,0 +1,18 @@
1
+ import { NativeModules, Platform } from 'react-native';
2
+ export { IminPrintAlign } from './typing';
3
+ const LINKING_ERROR = `The package 'react-native-printer-imin' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
4
+ ios: "- You have run 'pod install'\n",
5
+ default: ''
6
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
7
+ const PrinterImin = NativeModules.PrinterImin ? NativeModules.PrinterImin : new Proxy({}, {
8
+ get() {
9
+ throw new Error(LINKING_ERROR);
10
+ }
11
+ });
12
+ const PrinterSDK = {
13
+ initPrinter: PrinterImin.initPrinter,
14
+ getPrinterStatus: PrinterImin.getPrinterStatus,
15
+ printText: PrinterImin.printText
16
+ };
17
+ export default PrinterSDK;
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeModules","Platform","IminPrintAlign","LINKING_ERROR","select","ios","default","PrinterImin","Proxy","get","Error","PrinterSDK","initPrinter","getPrinterStatus","printText"],"sourceRoot":"..\\..\\src","sources":["index.tsx"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,SAASC,cAAc,QAAQ,UAAU;AACzC,MAAMC,aAAa,GAChB,oFAAmF,GACpFF,QAAQ,CAACG,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,WAAW,GAAGP,aAAa,CAACO,WAAW,GACzCP,aAAa,CAACO,WAAW,GACzB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,MAAMQ,UAA2B,GAAG;EAClCC,WAAW,EAAEL,WAAW,CAACK,WAAW;EACpCC,gBAAgB,EAAEN,WAAW,CAACM,gBAAgB;EAC9CC,SAAS,EAAEP,WAAW,CAACO;AACzB,CAAC;AAED,eAAeH,UAAU"}
@@ -0,0 +1,54 @@
1
+ // enum IminTypeface {
2
+ // Default = 0,
3
+ // Monospace = 1,
4
+ // DefaultBold = 2,
5
+ // SansSerif = 3,
6
+ // Serif = 4,
7
+ // }
8
+ // enum IminFontStyle {
9
+ // normal = 0,
10
+ // bold = 1,
11
+ // italic = 2,
12
+ // boldItalic = 3,
13
+ // }
14
+
15
+ export let IminPrintAlign = /*#__PURE__*/function (IminPrintAlign) {
16
+ IminPrintAlign[IminPrintAlign["left"] = 0] = "left";
17
+ IminPrintAlign[IminPrintAlign["center"] = 1] = "center";
18
+ IminPrintAlign[IminPrintAlign["right"] = 2] = "right";
19
+ return IminPrintAlign;
20
+ }({});
21
+ // enum IminQrcodeCorrectionLevel {
22
+ // levelL = 48,
23
+ // levelM = 49,
24
+ // levelQ = 50,
25
+ // levelH = 51,
26
+ // }
27
+
28
+ // enum IminBarcodeTextPos {
29
+ // none = 0,
30
+ // aboveText = 1,
31
+ // belowText = 2,
32
+ // both = 3,
33
+ // }
34
+ // enum IminBarcodeType {
35
+ // upcA = 0,
36
+ // upcE = 1,
37
+ // jan13 = 2,
38
+ // jan8 = 3,
39
+ // code39 = 4,
40
+ // itf = 5,
41
+ // codabar = 6,
42
+ // code128 = 73,
43
+ // }
44
+
45
+ // interface TextStyle {
46
+ // wordWrap: boolean;
47
+ // fontSize: number;
48
+ // space: number;
49
+ // width: number;
50
+ // typeface: IminTypeface;
51
+ // fontStyle: IminFontStyle;
52
+ // align: IminPrintAlign;
53
+ // }
54
+ //# sourceMappingURL=typing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["IminPrintAlign"],"sourceRoot":"..\\..\\src","sources":["typing.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,WAAYA,cAAc,0BAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;AAK1B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -0,0 +1,5 @@
1
+ import type { IminPrinterType } from './typing';
2
+ export { IminPrintAlign } from './typing';
3
+ declare const PrinterSDK: IminPrinterType;
4
+ export default PrinterSDK;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAkB1C,QAAA,MAAM,UAAU,EAAE,eAIjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,14 @@
1
+ export declare enum IminPrintAlign {
2
+ left = 0,
3
+ center = 1,
4
+ right = 2
5
+ }
6
+ export type IminPrinterType = {
7
+ initPrinter: () => Promise<string>;
8
+ getPrinterStatus: () => Promise<{
9
+ code: number;
10
+ message: string;
11
+ }>;
12
+ printText: (text: string) => Promise<void>;
13
+ };
14
+ //# sourceMappingURL=typing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typing.d.ts","sourceRoot":"","sources":["../../../src/typing.ts"],"names":[],"mappings":"AAcA,oBAAY,cAAc;IACxB,IAAI,IAAI;IACR,MAAM,IAAI;IACV,KAAK,IAAI;CACV;AAmCD,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,gBAAgB,EAAE,MAAM,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnE,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C,CAAC"}
package/package.json ADDED
@@ -0,0 +1,162 @@
1
+ {
2
+ "name": "react-native-printer-imin",
3
+ "version": "0.2.0",
4
+ "description": "Native Module For iMin Printer SDK Plugin",
5
+ "main": "lib/commonjs/index",
6
+ "module": "lib/module/index",
7
+ "types": "lib/typescript/src/index.d.ts",
8
+ "react-native": "src/index",
9
+ "source": "src/index",
10
+ "files": [
11
+ "src",
12
+ "lib",
13
+ "android",
14
+ "ios",
15
+ "cpp",
16
+ "*.podspec",
17
+ "!ios/build",
18
+ "!android/build",
19
+ "!android/gradle",
20
+ "!android/gradlew",
21
+ "!android/gradlew.bat",
22
+ "!android/local.properties",
23
+ "!**/__tests__",
24
+ "!**/__fixtures__",
25
+ "!**/__mocks__",
26
+ "!**/.*"
27
+ ],
28
+ "scripts": {
29
+ "example": "yarn workspace react-native-printer-imin-example",
30
+ "test": "jest",
31
+ "typecheck": "tsc --noEmit",
32
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
33
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
34
+ "prepare": "bob build",
35
+ "release": "release-it"
36
+ },
37
+ "keywords": [
38
+ "react-native",
39
+ "ios",
40
+ "android"
41
+ ],
42
+ "repository": "https://github.com/iminsoftware/react-native-printer-imin",
43
+ "author": "iminsoftware <softwareteam@imin.sg> (https://github.com/iminsoftware)",
44
+ "license": "MIT",
45
+ "bugs": {
46
+ "url": "https://github.com/iminsoftware/react-native-printer-imin/issues"
47
+ },
48
+ "homepage": "https://github.com/iminsoftware/react-native-printer-imin#readme",
49
+ "publishConfig": {
50
+ "registry": "https://registry.npmjs.org/"
51
+ },
52
+ "devDependencies": {
53
+ "@commitlint/config-conventional": "^17.0.2",
54
+ "@evilmartians/lefthook": "^1.5.0",
55
+ "@react-native/eslint-config": "^0.72.2",
56
+ "@release-it/conventional-changelog": "^5.0.0",
57
+ "@types/jest": "^28.1.2",
58
+ "@types/react": "~17.0.21",
59
+ "@types/react-native": "0.70.0",
60
+ "commitlint": "^17.0.2",
61
+ "del-cli": "^5.0.0",
62
+ "eslint": "^8.4.1",
63
+ "eslint-config-prettier": "^8.5.0",
64
+ "eslint-plugin-prettier": "^4.0.0",
65
+ "jest": "^28.1.1",
66
+ "pod-install": "^0.1.0",
67
+ "prettier": "^2.0.5",
68
+ "react": "18.2.0",
69
+ "react-native": "0.72.6",
70
+ "react-native-builder-bob": "^0.20.0",
71
+ "release-it": "^15.0.0",
72
+ "turbo": "^1.10.7",
73
+ "typescript": "^5.0.2"
74
+ },
75
+ "resolutions": {
76
+ "@types/react": "17.0.21"
77
+ },
78
+ "peerDependencies": {
79
+ "react": "*",
80
+ "react-native": "*"
81
+ },
82
+ "workspaces": [
83
+ "example"
84
+ ],
85
+ "packageManager": "yarn@3.6.1",
86
+ "engines": {
87
+ "node": ">= 18.0.0"
88
+ },
89
+ "jest": {
90
+ "preset": "react-native",
91
+ "modulePathIgnorePatterns": [
92
+ "<rootDir>/example/node_modules",
93
+ "<rootDir>/lib/"
94
+ ]
95
+ },
96
+ "commitlint": {
97
+ "extends": [
98
+ "@commitlint/config-conventional"
99
+ ]
100
+ },
101
+ "release-it": {
102
+ "git": {
103
+ "commitMessage": "chore: release ${version}",
104
+ "tagName": "v${version}"
105
+ },
106
+ "npm": {
107
+ "publish": true
108
+ },
109
+ "github": {
110
+ "release": true
111
+ },
112
+ "plugins": {
113
+ "@release-it/conventional-changelog": {
114
+ "preset": "angular"
115
+ }
116
+ }
117
+ },
118
+ "eslintConfig": {
119
+ "root": true,
120
+ "extends": [
121
+ "@react-native",
122
+ "prettier"
123
+ ],
124
+ "rules": {
125
+ "prettier/prettier": [
126
+ "error",
127
+ {
128
+ "quoteProps": "consistent",
129
+ "singleQuote": true,
130
+ "tabWidth": 2,
131
+ "trailingComma": "es5",
132
+ "useTabs": false
133
+ }
134
+ ]
135
+ }
136
+ },
137
+ "eslintIgnore": [
138
+ "node_modules/",
139
+ "lib/"
140
+ ],
141
+ "prettier": {
142
+ "quoteProps": "consistent",
143
+ "singleQuote": true,
144
+ "tabWidth": 2,
145
+ "trailingComma": "es5",
146
+ "useTabs": false
147
+ },
148
+ "react-native-builder-bob": {
149
+ "source": "src",
150
+ "output": "lib",
151
+ "targets": [
152
+ "commonjs",
153
+ "module",
154
+ [
155
+ "typescript",
156
+ {
157
+ "project": "tsconfig.build.json"
158
+ }
159
+ ]
160
+ ]
161
+ }
162
+ }
@@ -0,0 +1,41 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = "react-native-printer-imin"
8
+ s.version = package["version"]
9
+ s.summary = package["description"]
10
+ s.homepage = package["homepage"]
11
+ s.license = package["license"]
12
+ s.authors = package["author"]
13
+
14
+ s.platforms = { :ios => "11.0" }
15
+ s.source = { :git => "https://github.com/iminsoftware/react-native-printer-imin.git", :tag => "#{s.version}" }
16
+
17
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
18
+
19
+ # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
20
+ # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
21
+ if respond_to?(:install_modules_dependencies, true)
22
+ install_modules_dependencies(s)
23
+ else
24
+ s.dependency "React-Core"
25
+
26
+ # Don't install the dependencies when we run `pod install` in the old architecture.
27
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
28
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
29
+ s.pod_target_xcconfig = {
30
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
31
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
32
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
33
+ }
34
+ s.dependency "React-Codegen"
35
+ s.dependency "RCT-Folly"
36
+ s.dependency "RCTRequired"
37
+ s.dependency "RCTTypeSafety"
38
+ s.dependency "ReactCommon/turbomodule/core"
39
+ end
40
+ end
41
+ end
package/src/index.tsx ADDED
@@ -0,0 +1,27 @@
1
+ import { NativeModules, Platform } from 'react-native';
2
+ import type { IminPrinterType } from './typing';
3
+ export { IminPrintAlign } from './typing';
4
+ const LINKING_ERROR =
5
+ `The package 'react-native-printer-imin' doesn't seem to be linked. Make sure: \n\n` +
6
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
7
+ '- You rebuilt the app after installing the package\n' +
8
+ '- You are not using Expo Go\n';
9
+
10
+ const PrinterImin = NativeModules.PrinterImin
11
+ ? NativeModules.PrinterImin
12
+ : new Proxy(
13
+ {},
14
+ {
15
+ get() {
16
+ throw new Error(LINKING_ERROR);
17
+ },
18
+ }
19
+ );
20
+
21
+ const PrinterSDK: IminPrinterType = {
22
+ initPrinter: PrinterImin.initPrinter,
23
+ getPrinterStatus: PrinterImin.getPrinterStatus,
24
+ printText: PrinterImin.printText,
25
+ };
26
+
27
+ export default PrinterSDK;
package/src/typing.ts ADDED
@@ -0,0 +1,58 @@
1
+ // enum IminTypeface {
2
+ // Default = 0,
3
+ // Monospace = 1,
4
+ // DefaultBold = 2,
5
+ // SansSerif = 3,
6
+ // Serif = 4,
7
+ // }
8
+ // enum IminFontStyle {
9
+ // normal = 0,
10
+ // bold = 1,
11
+ // italic = 2,
12
+ // boldItalic = 3,
13
+ // }
14
+
15
+ export enum IminPrintAlign {
16
+ left = 0,
17
+ center = 1,
18
+ right = 2,
19
+ }
20
+ // enum IminQrcodeCorrectionLevel {
21
+ // levelL = 48,
22
+ // levelM = 49,
23
+ // levelQ = 50,
24
+ // levelH = 51,
25
+ // }
26
+
27
+ // enum IminBarcodeTextPos {
28
+ // none = 0,
29
+ // aboveText = 1,
30
+ // belowText = 2,
31
+ // both = 3,
32
+ // }
33
+ // enum IminBarcodeType {
34
+ // upcA = 0,
35
+ // upcE = 1,
36
+ // jan13 = 2,
37
+ // jan8 = 3,
38
+ // code39 = 4,
39
+ // itf = 5,
40
+ // codabar = 6,
41
+ // code128 = 73,
42
+ // }
43
+
44
+ // interface TextStyle {
45
+ // wordWrap: boolean;
46
+ // fontSize: number;
47
+ // space: number;
48
+ // width: number;
49
+ // typeface: IminTypeface;
50
+ // fontStyle: IminFontStyle;
51
+ // align: IminPrintAlign;
52
+ // }
53
+
54
+ export type IminPrinterType = {
55
+ initPrinter: () => Promise<string>;
56
+ getPrinterStatus: () => Promise<{ code: number; message: string }>;
57
+ printText: (text: string) => Promise<void>;
58
+ };