@sincpro/printer-expo 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +917 -0
  2. package/android/build.gradle +52 -0
  3. package/android/libs/BixolonLabelPrinterLibrary_V2.0.9.jar +0 -0
  4. package/android/libs/jniLibs/arm64-v8a/libbxl_common.so +0 -0
  5. package/android/libs/jniLibs/armeabi-v7a/libbxl_common.so +0 -0
  6. package/android/libs/jniLibs/x86/libbxl_common.so +0 -0
  7. package/android/libs/jniLibs/x86_64/libbxl_common.so +0 -0
  8. package/android/libs/libcommon_V1.4.0.jar +0 -0
  9. package/android/libs/pdf/Bixolon_pdf.aar +0 -0
  10. package/android/src/main/AndroidManifest.xml +2 -0
  11. package/android/src/main/java/expo/sincpro/ExpoBixolonModule.kt +271 -0
  12. package/android/src/main/java/expo/sincpro/bixolon/BixolonQRPrinter.kt +423 -0
  13. package/android/src/main/java/expo/sincpro/managers/BluetoothManager.kt +139 -0
  14. package/android/src/main/java/expo/sincpro/managers/ConnectionManager.kt +124 -0
  15. package/android/src/main/java/expo/sincpro/managers/PermissionManager.kt +122 -0
  16. package/android/src/main/java/expo/sincpro/managers/PrinterManager.kt +396 -0
  17. package/android/src/main/jniLibs/arm64-v8a/libbxl_common.so +0 -0
  18. package/android/src/main/jniLibs/armeabi-v7a/libbxl_common.so +0 -0
  19. package/android/src/main/jniLibs/x86/libbxl_common.so +0 -0
  20. package/android/src/main/jniLibs/x86_64/libbxl_common.so +0 -0
  21. package/build/BixolonPrinter.d.ts +4 -0
  22. package/build/BixolonPrinter.d.ts.map +1 -0
  23. package/build/BixolonPrinter.js +12 -0
  24. package/build/BixolonPrinter.js.map +1 -0
  25. package/build/ExpoBixolon.types.d.ts +45 -0
  26. package/build/ExpoBixolon.types.d.ts.map +1 -0
  27. package/build/ExpoBixolon.types.js +2 -0
  28. package/build/ExpoBixolon.types.js.map +1 -0
  29. package/build/ExpoBixolonModule.d.ts +24 -0
  30. package/build/ExpoBixolonModule.d.ts.map +1 -0
  31. package/build/ExpoBixolonModule.js +3 -0
  32. package/build/ExpoBixolonModule.js.map +1 -0
  33. package/build/QrCodePrinter.d.ts +45 -0
  34. package/build/QrCodePrinter.d.ts.map +1 -0
  35. package/build/QrCodePrinter.js +118 -0
  36. package/build/QrCodePrinter.js.map +1 -0
  37. package/build/index.d.ts +4 -0
  38. package/build/index.d.ts.map +1 -0
  39. package/build/index.js +4 -0
  40. package/build/index.js.map +1 -0
  41. package/expo-module.config.json +9 -0
  42. package/ios/ExpoBixolon.podspec +29 -0
  43. package/ios/ExpoBixolonModule.swift +33 -0
  44. package/ios/ExpoBixolonView.swift +36 -0
  45. package/package.json +63 -0
  46. package/src/BixolonPrinter.ts +16 -0
  47. package/src/ExpoBixolon.types.ts +60 -0
  48. package/src/ExpoBixolonModule.ts +38 -0
  49. package/src/QrCodePrinter.ts +201 -0
  50. package/src/index.ts +3 -0
@@ -0,0 +1,52 @@
1
+ apply plugin: 'com.android.library'
2
+
3
+ group = 'expo.sincpro.bixolon'
4
+ version = '0.1.0'
5
+
6
+ def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
7
+ apply from: expoModulesCorePlugin
8
+ applyKotlinExpoModulesCorePlugin()
9
+ useCoreDependencies()
10
+ useExpoPublishing()
11
+
12
+ // If you want to use the managed Android SDK versions from expo-modules-core, set this to true.
13
+ // The Android SDK versions will be bumped from time to time in SDK releases and may introduce breaking changes in your module code.
14
+ // Most of the time, you may like to manage the Android SDK versions yourself.
15
+ def useManagedAndroidSdkVersions = false
16
+ if (useManagedAndroidSdkVersions) {
17
+ useDefaultAndroidSdkVersions()
18
+ } else {
19
+ buildscript {
20
+ // Simple helper that allows the root project to override versions declared by this library.
21
+ ext.safeExtGet = { prop, fallback ->
22
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
23
+ }
24
+ }
25
+ project.android {
26
+ compileSdkVersion safeExtGet("compileSdkVersion", 34)
27
+ defaultConfig {
28
+ minSdkVersion safeExtGet("minSdkVersion", 21)
29
+ targetSdkVersion safeExtGet("targetSdkVersion", 34)
30
+ }
31
+ }
32
+ }
33
+
34
+ android {
35
+ namespace "expo.sincpro.bixolon"
36
+ defaultConfig {
37
+ versionCode 1
38
+ versionName "0.1.0"
39
+ }
40
+ lintOptions {
41
+ abortOnError false
42
+ }
43
+ }
44
+
45
+ dependencies {
46
+ // Bixolon printer libraries
47
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
48
+
49
+ // Bluetooth and permissions
50
+ implementation 'androidx.core:core-ktx:1.12.0'
51
+ implementation 'androidx.appcompat:appcompat:1.6.1'
52
+ }
Binary file
@@ -0,0 +1,2 @@
1
+ <manifest>
2
+ </manifest>
@@ -0,0 +1,271 @@
1
+ package expo.sincpro
2
+
3
+ import android.util.Log
4
+ import expo.modules.kotlin.modules.Module
5
+ import expo.modules.kotlin.modules.ModuleDefinition
6
+ import expo.sincpro.bixolon.BixolonQRPrinter
7
+ import expo.sincpro.managers.BluetoothManager
8
+ import expo.sincpro.managers.ConnectionManager
9
+ import expo.sincpro.managers.PermissionManager
10
+ import expo.sincpro.managers.PrinterManager
11
+
12
+ class ExpoBixolonModule : Module() {
13
+ private val TAG = "ExpoBixolonModule"
14
+
15
+ private var bixolonQRPrinter: BixolonQRPrinter? = null
16
+ private var bluetoothManager: BluetoothManager? = null
17
+ private var connectionManager: ConnectionManager? = null
18
+ private var printerManager: PrinterManager? = null
19
+ private var permissionManager: PermissionManager? = null
20
+
21
+ override fun definition() = ModuleDefinition {
22
+ Name("ExpoBixolon")
23
+
24
+ AsyncFunction("initializePrinter") {
25
+ try {
26
+ Log.d(TAG, "Initializing printer with Bixolon libraries")
27
+
28
+ if (bixolonQRPrinter == null) {
29
+ bixolonQRPrinter = BixolonQRPrinter(appContext.reactContext!!)
30
+ connectionManager = ConnectionManager(bixolonQRPrinter!!)
31
+ printerManager = PrinterManager(bixolonQRPrinter!!)
32
+ }
33
+
34
+ return@AsyncFunction connectionManager!!.initialize()
35
+ } catch (e: Exception) {
36
+ Log.e(TAG, "Error initializing printer: ${e.message}")
37
+ throw e
38
+ }
39
+ }
40
+
41
+ AsyncFunction("connectPrinter") { interfaceType: String, address: String, port: Int ->
42
+ try {
43
+ if (connectionManager == null || !connectionManager!!.isInitialized()) {
44
+ throw Exception("Printer not initialized. Call initializePrinter() first.")
45
+ }
46
+
47
+ if (bluetoothManager == null) {
48
+ bluetoothManager = BluetoothManager(appContext.reactContext!!)
49
+ }
50
+
51
+ return@AsyncFunction connectionManager!!.connect(interfaceType, address, port, bluetoothManager!!)
52
+ } catch (e: Exception) {
53
+ Log.e(TAG, "Error connecting to printer: ${e.message}")
54
+ throw e
55
+ }
56
+ }
57
+
58
+ AsyncFunction("disconnectPrinter") {
59
+ try {
60
+ if (connectionManager == null) {
61
+ return@AsyncFunction true
62
+ }
63
+
64
+ return@AsyncFunction connectionManager!!.disconnect()
65
+ } catch (e: Exception) {
66
+ Log.e(TAG, "Error disconnecting from printer: ${e.message}")
67
+ throw e
68
+ }
69
+ }
70
+
71
+ AsyncFunction("executeCommand") { command: String ->
72
+ try {
73
+ if (connectionManager == null || !connectionManager!!.isConnected()) {
74
+ throw Exception("Printer not connected")
75
+ }
76
+
77
+ return@AsyncFunction connectionManager!!.executeCommand(command)
78
+ } catch (e: Exception) {
79
+ Log.e(TAG, "Error executing command: ${e.message}")
80
+ throw e
81
+ }
82
+ }
83
+
84
+ AsyncFunction("testPlainText") { text: String ->
85
+ try {
86
+ if (connectionManager == null || !connectionManager!!.isConnected()) {
87
+ throw Exception("Printer not connected")
88
+ }
89
+
90
+ return@AsyncFunction printerManager!!.printPlainText(text)
91
+ } catch (e: Exception) {
92
+ Log.e(TAG, "Error sending plain text: ${e.message}")
93
+ throw e
94
+ }
95
+ }
96
+
97
+ AsyncFunction("printInvoice") { invoiceText: String ->
98
+ try {
99
+ if (connectionManager == null || !connectionManager!!.isConnected()) {
100
+ throw Exception("Printer not connected")
101
+ }
102
+
103
+ return@AsyncFunction printerManager!!.printInvoice(invoiceText)
104
+ } catch (e: Exception) {
105
+ Log.e(TAG, "Error printing invoice: ${e.message}")
106
+ throw e
107
+ }
108
+ }
109
+
110
+ AsyncFunction("printQRCode") { text: String, size: Int ->
111
+ try {
112
+ if (connectionManager == null || !connectionManager!!.isConnected()) {
113
+ throw Exception("Printer not connected")
114
+ }
115
+
116
+ return@AsyncFunction printerManager!!.printQRCode(text, size)
117
+ } catch (e: Exception) {
118
+ Log.e(TAG, "Error printing QR code: ${e.message}")
119
+ throw e
120
+ }
121
+ }
122
+
123
+ AsyncFunction("printQRCodeAdvanced") {
124
+ data: String,
125
+ horizontalPosition: Int,
126
+ verticalPosition: Int,
127
+ model: String,
128
+ eccLevel: String,
129
+ size: Int,
130
+ rotation: String
131
+ ->
132
+ try {
133
+ if (connectionManager == null || !connectionManager!!.isConnected()) {
134
+ throw Exception("Printer not connected")
135
+ }
136
+
137
+ return@AsyncFunction printerManager!!.printQRCodeAdvanced(data, size)
138
+ } catch (e: Exception) {
139
+ Log.e(TAG, "Error printing QR code: ${e.message}")
140
+ throw e
141
+ }
142
+ }
143
+
144
+ AsyncFunction("printFormattedText") { text: String, fontSize: Int? ->
145
+ try {
146
+ if (connectionManager == null || !connectionManager!!.isConnected()) {
147
+ throw Exception("Printer not connected")
148
+ }
149
+
150
+ val actualFontSize = fontSize ?: 10
151
+ return@AsyncFunction printerManager!!.printFormattedText(text, actualFontSize)
152
+ } catch (e: Exception) {
153
+ Log.e(TAG, "Error printing formatted text: ${e.message}")
154
+ throw e
155
+ }
156
+ }
157
+
158
+ AsyncFunction("printTextSimple") { text: String ->
159
+ try {
160
+ if (connectionManager == null || !connectionManager!!.isConnected()) {
161
+ throw Exception("Printer not connected")
162
+ }
163
+
164
+ return@AsyncFunction printerManager!!.printTextSimple(text)
165
+ } catch (e: Exception) {
166
+ Log.e(TAG, "Error printing simple text: ${e.message}")
167
+ throw e
168
+ }
169
+ }
170
+
171
+ AsyncFunction("printTextInPages") { text: String ->
172
+ try {
173
+ if (connectionManager == null || !connectionManager!!.isConnected()) {
174
+ throw Exception("Printer not connected")
175
+ }
176
+
177
+ return@AsyncFunction printerManager!!.printTextInPages(text)
178
+ } catch (e: Exception) {
179
+ Log.e(TAG, "Error printing text in pages: ${e.message}")
180
+ throw e
181
+ }
182
+ }
183
+
184
+
185
+ AsyncFunction("requestBluetoothPermissions") {
186
+ try {
187
+ if (permissionManager == null) {
188
+ permissionManager = PermissionManager(appContext.reactContext!!)
189
+ }
190
+
191
+ return@AsyncFunction permissionManager!!.requestBluetoothPermissions(appContext.currentActivity)
192
+ } catch (e: Exception) {
193
+ Log.e(TAG, "Error requesting Bluetooth permissions: ${e.message}")
194
+ return@AsyncFunction false
195
+ }
196
+ }
197
+
198
+ AsyncFunction("checkBluetoothPermissions") {
199
+ try {
200
+ if (permissionManager == null) {
201
+ permissionManager = PermissionManager(appContext.reactContext!!)
202
+ }
203
+
204
+ return@AsyncFunction permissionManager!!.checkBluetoothPermissions()
205
+ } catch (e: Exception) {
206
+ Log.e(TAG, "Error checking Bluetooth permissions: ${e.message}")
207
+ throw e
208
+ }
209
+ }
210
+
211
+ AsyncFunction("discoverBluetoothDevices") {
212
+ try {
213
+ if (bluetoothManager == null) {
214
+ bluetoothManager = BluetoothManager(appContext.reactContext!!)
215
+ }
216
+
217
+ if (permissionManager == null) {
218
+ permissionManager = PermissionManager(appContext.reactContext!!)
219
+ }
220
+
221
+ if (!permissionManager!!.hasRequiredPermissions()) {
222
+ throw Exception("Required permissions not granted. Call requestBluetoothPermissions() first.")
223
+ }
224
+
225
+ return@AsyncFunction bluetoothManager!!.discoverBluetoothDevices()
226
+ } catch (e: Exception) {
227
+ Log.e(TAG, "Error discovering Bluetooth devices: ${e.message}")
228
+ throw e
229
+ }
230
+ }
231
+
232
+ AsyncFunction("startBluetoothDiscovery") {
233
+ try {
234
+ if (bluetoothManager == null) {
235
+ bluetoothManager = BluetoothManager(appContext.reactContext!!)
236
+ }
237
+
238
+ return@AsyncFunction bluetoothManager!!.startBluetoothDiscovery()
239
+ } catch (e: Exception) {
240
+ Log.e(TAG, "Error starting Bluetooth discovery: ${e.message}")
241
+ throw e
242
+ }
243
+ }
244
+
245
+ AsyncFunction("stopBluetoothDiscovery") {
246
+ try {
247
+ if (bluetoothManager == null) {
248
+ bluetoothManager = BluetoothManager(appContext.reactContext!!)
249
+ }
250
+
251
+ return@AsyncFunction bluetoothManager!!.stopBluetoothDiscovery()
252
+ } catch (e: Exception) {
253
+ Log.e(TAG, "Error stopping Bluetooth discovery: ${e.message}")
254
+ throw e
255
+ }
256
+ }
257
+
258
+ AsyncFunction("isBluetoothEnabled") {
259
+ try {
260
+ if (bluetoothManager == null) {
261
+ bluetoothManager = BluetoothManager(appContext.reactContext!!)
262
+ }
263
+
264
+ return@AsyncFunction bluetoothManager!!.isBluetoothEnabled()
265
+ } catch (e: Exception) {
266
+ Log.e(TAG, "Error checking Bluetooth status: ${e.message}")
267
+ throw e
268
+ }
269
+ }
270
+ }
271
+ }