@sincpro/printer-expo 0.1.2 → 1.0.1

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 (72) hide show
  1. package/README.md +589 -415
  2. package/android/.editorconfig +20 -0
  3. package/android/README.md +103 -0
  4. package/android/build.gradle +36 -34
  5. package/android/libs/pdf/Bixolon_pdf.aar +0 -0
  6. package/android/libs/{jniLibs/x86_64/libbxl_common.so → sincpro-printer-sdk.aar} +0 -0
  7. package/android/src/main/java/sincpro/expo/printer/entrypoint/PrinterModule.kt +387 -0
  8. package/build/SincproPrinter.d.ts +191 -0
  9. package/build/SincproPrinter.d.ts.map +1 -0
  10. package/build/SincproPrinter.js +120 -0
  11. package/build/SincproPrinter.js.map +1 -0
  12. package/build/index.d.ts +11 -3
  13. package/build/index.d.ts.map +1 -1
  14. package/build/index.js +13 -3
  15. package/build/index.js.map +1 -1
  16. package/build/types/bluetooth.types.d.ts +19 -0
  17. package/build/types/bluetooth.types.d.ts.map +1 -0
  18. package/build/types/bluetooth.types.js +5 -0
  19. package/build/types/bluetooth.types.js.map +1 -0
  20. package/build/types/index.d.ts +7 -0
  21. package/build/types/index.d.ts.map +1 -0
  22. package/build/types/index.js +7 -0
  23. package/build/types/index.js.map +1 -0
  24. package/build/types/printer.types.d.ts +118 -0
  25. package/build/types/printer.types.d.ts.map +1 -0
  26. package/build/types/printer.types.js +5 -0
  27. package/build/types/printer.types.js.map +1 -0
  28. package/build/types/receipt.types.d.ts +96 -0
  29. package/build/types/receipt.types.d.ts.map +1 -0
  30. package/build/types/receipt.types.js +5 -0
  31. package/build/types/receipt.types.js.map +1 -0
  32. package/expo-module.config.json +2 -5
  33. package/package.json +6 -7
  34. package/android/libs/BixolonLabelPrinterLibrary_V2.0.9.jar +0 -0
  35. package/android/libs/jniLibs/arm64-v8a/libbxl_common.so +0 -0
  36. package/android/libs/jniLibs/armeabi-v7a/libbxl_common.so +0 -0
  37. package/android/libs/jniLibs/x86/libbxl_common.so +0 -0
  38. package/android/libs/libcommon_V1.4.0.jar +0 -0
  39. package/android/src/main/java/expo/sincpro/ExpoBixolonModule.kt +0 -271
  40. package/android/src/main/java/expo/sincpro/bixolon/BixolonQRPrinter.kt +0 -423
  41. package/android/src/main/java/expo/sincpro/managers/BluetoothManager.kt +0 -139
  42. package/android/src/main/java/expo/sincpro/managers/ConnectionManager.kt +0 -124
  43. package/android/src/main/java/expo/sincpro/managers/PermissionManager.kt +0 -122
  44. package/android/src/main/java/expo/sincpro/managers/PrinterManager.kt +0 -396
  45. package/android/src/main/jniLibs/arm64-v8a/libbxl_common.so +0 -0
  46. package/android/src/main/jniLibs/armeabi-v7a/libbxl_common.so +0 -0
  47. package/android/src/main/jniLibs/x86/libbxl_common.so +0 -0
  48. package/android/src/main/jniLibs/x86_64/libbxl_common.so +0 -0
  49. package/build/BixolonPrinter.d.ts +0 -4
  50. package/build/BixolonPrinter.d.ts.map +0 -1
  51. package/build/BixolonPrinter.js +0 -12
  52. package/build/BixolonPrinter.js.map +0 -1
  53. package/build/ExpoBixolon.types.d.ts +0 -45
  54. package/build/ExpoBixolon.types.d.ts.map +0 -1
  55. package/build/ExpoBixolon.types.js +0 -2
  56. package/build/ExpoBixolon.types.js.map +0 -1
  57. package/build/ExpoBixolonModule.d.ts +0 -24
  58. package/build/ExpoBixolonModule.d.ts.map +0 -1
  59. package/build/ExpoBixolonModule.js +0 -3
  60. package/build/ExpoBixolonModule.js.map +0 -1
  61. package/build/QrCodePrinter.d.ts +0 -45
  62. package/build/QrCodePrinter.d.ts.map +0 -1
  63. package/build/QrCodePrinter.js +0 -118
  64. package/build/QrCodePrinter.js.map +0 -1
  65. package/ios/ExpoBixolon.podspec +0 -29
  66. package/ios/ExpoBixolonModule.swift +0 -33
  67. package/ios/ExpoBixolonView.swift +0 -36
  68. package/src/BixolonPrinter.ts +0 -16
  69. package/src/ExpoBixolon.types.ts +0 -60
  70. package/src/ExpoBixolonModule.ts +0 -38
  71. package/src/QrCodePrinter.ts +0 -201
  72. package/src/index.ts +0 -3
@@ -1,45 +0,0 @@
1
- export interface QRCodeOptions {
2
- data: string;
3
- size?: number;
4
- }
5
- export interface QRCodeConstants {
6
- QR_CODE_MODEL1: number;
7
- QR_CODE_MODEL2: number;
8
- ECC_LEVEL_7: number;
9
- ECC_LEVEL_15: number;
10
- ECC_LEVEL_25: number;
11
- ECC_LEVEL_30: number;
12
- ROTATION_NONE: number;
13
- ROTATION_90_DEGREES: number;
14
- ROTATION_180_DEGREES: number;
15
- ROTATION_270_DEGREES: number;
16
- }
17
- export declare class QrCodePrinter {
18
- private static instance;
19
- private isInitialized;
20
- private constructor();
21
- static getInstance(): QrCodePrinter;
22
- initialize(): Promise<boolean>;
23
- printQRCode(options: QRCodeOptions): Promise<boolean>;
24
- printSimpleQRCode(data: string, size?: number): Promise<boolean>;
25
- printURLQRCode(url: string, size?: number): Promise<boolean>;
26
- printContactQRCode(contact: {
27
- name: string;
28
- phone?: string;
29
- email?: string;
30
- company?: string;
31
- title?: string;
32
- }, size?: number): Promise<boolean>;
33
- printWiFiQRCode(ssid: string, password: string, encryption?: 'WPA' | 'WEP' | 'nopass', size?: number): Promise<boolean>;
34
- printPaymentQRCode(paymentData: {
35
- amount: number;
36
- currency: string;
37
- description?: string;
38
- merchantName?: string;
39
- }, size?: number): Promise<boolean>;
40
- private generateVCard;
41
- private generatePaymentString;
42
- getConstants(): QRCodeConstants;
43
- }
44
- export default QrCodePrinter;
45
- //# sourceMappingURL=QrCodePrinter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"QrCodePrinter.d.ts","sourceRoot":"","sources":["../src/QrCodePrinter.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IAEvB,WAA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QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,EACD,IAAI,GAAE,MAAU,GACf,OAAO,CAAC,OAAO,CAAC;IAQnB,OAAO,CAAC,aAAa;IA8BrB,OAAO,CAAC,qBAAqB;IAWtB,YAAY,IAAI,eAAe;CAcvC;AAED,eAAe,aAAa,CAAC"}
@@ -1,118 +0,0 @@
1
- import ExpoBixolonModule from './ExpoBixolonModule';
2
- export class QrCodePrinter {
3
- static instance;
4
- isInitialized = false;
5
- constructor() { }
6
- static getInstance() {
7
- if (!QrCodePrinter.instance) {
8
- QrCodePrinter.instance = new QrCodePrinter();
9
- }
10
- return QrCodePrinter.instance;
11
- }
12
- async initialize() {
13
- try {
14
- if (!this.isInitialized) {
15
- const result = await ExpoBixolonModule.initializePrinter();
16
- this.isInitialized = result;
17
- return result;
18
- }
19
- return true;
20
- }
21
- catch (error) {
22
- console.error('Error initializing QR code printer:', error);
23
- throw error;
24
- }
25
- }
26
- async printQRCode(options) {
27
- try {
28
- if (!this.isInitialized) {
29
- await this.initialize();
30
- }
31
- const { data, size = 9 } = options;
32
- if (!data || data.trim().length === 0) {
33
- throw new Error('QR code data cannot be empty');
34
- }
35
- if (size < 1 || size > 10) {
36
- throw new Error('QR code size must be between 1 and 10');
37
- }
38
- return await ExpoBixolonModule.printQRCodeAdvanced(data, 200, 100, 'MODEL2', 'ECC_LEVEL_7', size, 'NONE');
39
- }
40
- catch (error) {
41
- console.error('Error printing QR code:', error);
42
- throw error;
43
- }
44
- }
45
- async printSimpleQRCode(data, size = 9) {
46
- return this.printQRCode({
47
- data,
48
- size,
49
- });
50
- }
51
- async printURLQRCode(url, size = 9) {
52
- if (!url.startsWith('http://') && !url.startsWith('https://')) {
53
- url = 'https://' + url;
54
- }
55
- return this.printQRCode({
56
- data: url,
57
- size,
58
- });
59
- }
60
- async printContactQRCode(contact, size = 9) {
61
- const vCard = this.generateVCard(contact);
62
- return this.printQRCode({
63
- data: vCard,
64
- size,
65
- });
66
- }
67
- async printWiFiQRCode(ssid, password, encryption = 'WPA', size = 9) {
68
- const wifiString = `WIFI:T:${encryption};S:${ssid};P:${password};;`;
69
- return this.printQRCode({
70
- data: wifiString,
71
- size,
72
- });
73
- }
74
- async printPaymentQRCode(paymentData, size = 0) {
75
- const paymentString = this.generatePaymentString(paymentData);
76
- return this.printQRCode({
77
- data: paymentString,
78
- size,
79
- });
80
- }
81
- generateVCard(contact) {
82
- let vCard = 'BEGIN:VCARD\nVERSION:3.0\n';
83
- vCard += `FN:${contact.name}\n`;
84
- if (contact.phone) {
85
- vCard += `TEL:${contact.phone}\n`;
86
- }
87
- if (contact.email) {
88
- vCard += `EMAIL:${contact.email}\n`;
89
- }
90
- if (contact.company) {
91
- vCard += `ORG:${contact.company}\n`;
92
- }
93
- if (contact.title) {
94
- vCard += `TITLE:${contact.title}\n`;
95
- }
96
- vCard += 'END:VCARD';
97
- return vCard;
98
- }
99
- generatePaymentString(paymentData) {
100
- return `PAYMENT:${paymentData.amount}${paymentData.currency}${paymentData.description ? ':' + paymentData.description : ''}`;
101
- }
102
- getConstants() {
103
- return {
104
- QR_CODE_MODEL1: 1,
105
- QR_CODE_MODEL2: 2,
106
- ECC_LEVEL_7: 7,
107
- ECC_LEVEL_15: 15,
108
- ECC_LEVEL_25: 25,
109
- ECC_LEVEL_30: 30,
110
- ROTATION_NONE: 0,
111
- ROTATION_90_DEGREES: 90,
112
- ROTATION_180_DEGREES: 180,
113
- ROTATION_270_DEGREES: 270,
114
- };
115
- }
116
- }
117
- export default QrCodePrinter;
118
- //# sourceMappingURL=QrCodePrinter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"QrCodePrinter.js","sourceRoot":"","sources":["../src/QrCodePrinter.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAsBpD,MAAM,OAAO,aAAa;IAChB,MAAM,CAAC,QAAQ,CAAgB;IAC/B,aAAa,GAAG,KAAK,CAAC;IAE9B,gBAAuB,CAAC;IAEjB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AED,eAAe,aAAa,CAAC","sourcesContent":["import ExpoBixolonModule from './ExpoBixolonModule';\n\nexport interface QRCodeOptions {\n data: string;\n size?: number;\n}\n\nexport interface QRCodeConstants {\n QR_CODE_MODEL1: number;\n QR_CODE_MODEL2: number;\n\n ECC_LEVEL_7: number;\n ECC_LEVEL_15: number;\n ECC_LEVEL_25: number;\n ECC_LEVEL_30: number;\n\n ROTATION_NONE: number;\n ROTATION_90_DEGREES: number;\n ROTATION_180_DEGREES: number;\n ROTATION_270_DEGREES: number;\n}\n\nexport class QrCodePrinter {\n private static instance: QrCodePrinter;\n private isInitialized = false;\n\n private constructor() {}\n\n public static getInstance(): QrCodePrinter {\n if (!QrCodePrinter.instance) {\n QrCodePrinter.instance = new QrCodePrinter();\n }\n return QrCodePrinter.instance;\n }\n\n public async initialize(): Promise<boolean> {\n try {\n if (!this.isInitialized) {\n const result = await ExpoBixolonModule.initializePrinter();\n this.isInitialized = result;\n return result;\n }\n return true;\n } catch (error) {\n console.error('Error initializing QR code printer:', error);\n throw error;\n }\n }\n\n public async printQRCode(options: QRCodeOptions): Promise<boolean> {\n try {\n if (!this.isInitialized) {\n await this.initialize();\n }\n\n const { data, size = 9 } = options;\n\n if (!data || data.trim().length === 0) {\n throw new Error('QR code data cannot be empty');\n }\n\n if (size < 1 || size > 10) {\n throw new Error('QR code size must be between 1 and 10');\n }\n\n return await ExpoBixolonModule.printQRCodeAdvanced(\n data,\n 200,\n 100,\n 'MODEL2',\n 'ECC_LEVEL_7',\n size,\n 'NONE'\n );\n } catch (error) {\n console.error('Error printing QR code:', error);\n throw error;\n }\n }\n\n public async printSimpleQRCode(data: string, size: number = 9): Promise<boolean> {\n return this.printQRCode({\n data,\n size,\n });\n }\n\n public async printURLQRCode(url: string, size: number = 9): Promise<boolean> {\n if (!url.startsWith('http://') && !url.startsWith('https://')) {\n url = 'https://' + url;\n }\n return this.printQRCode({\n data: url,\n size,\n });\n }\n\n public async printContactQRCode(\n contact: {\n name: string;\n phone?: string;\n email?: string;\n company?: string;\n title?: string;\n },\n size: number = 9\n ): Promise<boolean> {\n const vCard = this.generateVCard(contact);\n return this.printQRCode({\n data: vCard,\n size,\n });\n }\n\n public async printWiFiQRCode(\n ssid: string,\n password: string,\n encryption: 'WPA' | 'WEP' | 'nopass' = 'WPA',\n size: number = 9\n ): Promise<boolean> {\n const wifiString = `WIFI:T:${encryption};S:${ssid};P:${password};;`;\n return this.printQRCode({\n data: wifiString,\n size,\n });\n }\n\n public async printPaymentQRCode(\n paymentData: {\n amount: number;\n currency: string;\n description?: string;\n merchantName?: string;\n },\n size: number = 0\n ): Promise<boolean> {\n const paymentString = this.generatePaymentString(paymentData);\n return this.printQRCode({\n data: paymentString,\n size,\n });\n }\n\n private generateVCard(contact: {\n name: string;\n phone?: string;\n email?: string;\n company?: string;\n title?: string;\n }): string {\n let vCard = 'BEGIN:VCARD\\nVERSION:3.0\\n';\n vCard += `FN:${contact.name}\\n`;\n\n if (contact.phone) {\n vCard += `TEL:${contact.phone}\\n`;\n }\n\n if (contact.email) {\n vCard += `EMAIL:${contact.email}\\n`;\n }\n\n if (contact.company) {\n vCard += `ORG:${contact.company}\\n`;\n }\n\n if (contact.title) {\n vCard += `TITLE:${contact.title}\\n`;\n }\n\n vCard += 'END:VCARD';\n return vCard;\n }\n\n private generatePaymentString(paymentData: {\n amount: number;\n currency: string;\n description?: string;\n merchantName?: string;\n }): string {\n return `PAYMENT:${paymentData.amount}${paymentData.currency}${\n paymentData.description ? ':' + paymentData.description : ''\n }`;\n }\n\n public getConstants(): QRCodeConstants {\n return {\n QR_CODE_MODEL1: 1,\n QR_CODE_MODEL2: 2,\n ECC_LEVEL_7: 7,\n ECC_LEVEL_15: 15,\n ECC_LEVEL_25: 25,\n ECC_LEVEL_30: 30,\n ROTATION_NONE: 0,\n ROTATION_90_DEGREES: 90,\n ROTATION_180_DEGREES: 180,\n ROTATION_270_DEGREES: 270,\n };\n }\n}\n\nexport default QrCodePrinter;\n"]}
@@ -1,29 +0,0 @@
1
- require 'json'
2
-
3
- package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
4
-
5
- Pod::Spec.new do |s|
6
- s.name = 'ExpoBixolon'
7
- s.version = package['version']
8
- s.summary = package['description']
9
- s.description = package['description']
10
- s.license = package['license']
11
- s.author = package['author']
12
- s.homepage = package['homepage']
13
- s.platforms = {
14
- :ios => '15.1',
15
- :tvos => '15.1'
16
- }
17
- s.swift_version = '5.4'
18
- s.source = { git: 'https://github.com/LuisJSincpro/expo-bixlon' }
19
- s.static_framework = true
20
-
21
- s.dependency 'ExpoModulesCore'
22
-
23
- # Swift/Objective-C compatibility
24
- s.pod_target_xcconfig = {
25
- 'DEFINES_MODULE' => 'YES',
26
- }
27
-
28
- s.source_files = "**/*.{h,m,mm,swift,hpp,cpp}"
29
- end
@@ -1,33 +0,0 @@
1
- import ExpoModulesCore
2
-
3
- public class ExpoBixolonModule: Module {
4
- public func definition() -> ModuleDefinition {
5
- Name("ExpoBixolon")
6
-
7
- Constants([
8
- "PI": Double.pi
9
- ])
10
-
11
- Events("onChange")
12
-
13
- Function("hello") {
14
- return "Hello world! 👋"
15
- }
16
-
17
- AsyncFunction("setValueAsync") { (value: String) in
18
- self.sendEvent("onChange", [
19
- "value": value
20
- ])
21
- }
22
-
23
- View(ExpoBixolonView.self) {
24
- Prop("url") { (view: ExpoBixolonView, url: URL) in
25
- if view.webView.url != url {
26
- view.webView.load(URLRequest(url: url))
27
- }
28
- }
29
-
30
- Events("onLoad")
31
- }
32
- }
33
- }
@@ -1,36 +0,0 @@
1
- import ExpoModulesCore
2
- import WebKit
3
-
4
- class ExpoBixolonView: ExpoView {
5
- let webView = WKWebView()
6
- let onLoad = EventDispatcher()
7
- var delegate: WebViewDelegate?
8
-
9
- required init(appContext: AppContext? = nil) {
10
- super.init(appContext: appContext)
11
- clipsToBounds = true
12
- delegate = WebViewDelegate { url in
13
- self.onLoad(["url": url])
14
- }
15
- webView.navigationDelegate = delegate
16
- addSubview(webView)
17
- }
18
-
19
- override func layoutSubviews() {
20
- webView.frame = bounds
21
- }
22
- }
23
-
24
- class WebViewDelegate: NSObject, WKNavigationDelegate {
25
- let onUrlChange: (String) -> Void
26
-
27
- init(onUrlChange: @escaping (String) -> Void) {
28
- self.onUrlChange = onUrlChange
29
- }
30
-
31
- func webView(_ webView: WKWebView, didFinish navigation: WKNavigation) {
32
- if let url = webView.url {
33
- onUrlChange(url.absoluteString)
34
- }
35
- }
36
- }
@@ -1,16 +0,0 @@
1
- import { NativeEventEmitter } from 'react-native';
2
- import ExpoBixolonModule from './ExpoBixolonModule';
3
- import type { BixolonPrinterInterface } from './ExpoBixolon.types';
4
-
5
- const eventEmitter = new NativeEventEmitter(ExpoBixolonModule as any);
6
-
7
- if (!eventEmitter.addListener) {
8
- (eventEmitter as any).addListener = () => ({ remove: () => {} });
9
- }
10
- if (!eventEmitter.removeAllListeners) {
11
- (eventEmitter as any).removeAllListeners = () => {};
12
- }
13
-
14
- export const BixolonPrinter: BixolonPrinterInterface = ExpoBixolonModule;
15
-
16
- export default BixolonPrinter;
@@ -1,60 +0,0 @@
1
- export interface BluetoothDevice {
2
- name: string;
3
- address: string;
4
- type: 'CLASSIC' | 'LE' | 'DUAL' | 'UNKNOWN';
5
- isPrinter: boolean;
6
- }
7
-
8
- export interface BluetoothPermissions {
9
- ACCESS_FINE_LOCATION: boolean;
10
- ACCESS_COARSE_LOCATION: boolean;
11
- BLUETOOTH_SCAN?: boolean;
12
- BLUETOOTH_CONNECT?: boolean;
13
- }
14
-
15
- export interface InvoiceItem {
16
- description: string;
17
- quantity: number;
18
- price: number;
19
- }
20
-
21
- export interface BixolonPrinterInterface {
22
- initializePrinter(): Promise<boolean>;
23
- connectPrinter(interfaceType: string, address: string, port: number): Promise<boolean>;
24
- disconnectPrinter(): Promise<boolean>;
25
- executeCommand(command: string): Promise<boolean>;
26
-
27
- testPlainText(text: string): Promise<boolean>;
28
-
29
- printInvoice(invoiceText: string): Promise<boolean>;
30
-
31
- printQRCode(text: string, size?: number): Promise<boolean>;
32
- printQRCodeAdvanced(
33
- data: string,
34
- horizontalPosition: number,
35
- verticalPosition: number,
36
- model: string,
37
- eccLevel: string,
38
- size: number,
39
- rotation: string
40
- ): Promise<boolean>;
41
- printFormattedText(text: string, fontSize?: number): Promise<boolean>;
42
- printTextSimple(text: string): Promise<boolean>;
43
- printTextInPages(text: string): Promise<boolean>;
44
-
45
- requestBluetoothPermissions(): Promise<boolean>;
46
- checkBluetoothPermissions(): Promise<BluetoothPermissions>;
47
- discoverBluetoothDevices(): Promise<BluetoothDevice[]>;
48
- startBluetoothDiscovery(): Promise<boolean>;
49
- stopBluetoothDiscovery(): Promise<boolean>;
50
- isBluetoothEnabled(): Promise<boolean>;
51
- }
52
-
53
- export type ExpoBixolonModuleEvents = {
54
- onBluetoothDeviceDiscovered: (device: BluetoothDevice) => void;
55
- onBluetoothDiscoveryStarted: () => void;
56
- onBluetoothDiscoveryStopped: () => void;
57
- onPrinterConnected: () => void;
58
- onPrinterDisconnected: () => void;
59
- onPrintComplete: (success: boolean) => void;
60
- };
@@ -1,38 +0,0 @@
1
- import { NativeModule, requireNativeModule } from 'expo';
2
- import { ExpoBixolonModuleEvents, BixolonPrinterInterface } from './ExpoBixolon.types';
3
-
4
- declare class ExpoBixolonModule
5
- extends NativeModule<ExpoBixolonModuleEvents>
6
- implements BixolonPrinterInterface
7
- {
8
- printQRCode(text: string, size?: number): Promise<boolean>;
9
- printQRCodeAdvanced(
10
- data: string,
11
- horizontalPosition: number,
12
- verticalPosition: number,
13
- model: string,
14
- eccLevel: string,
15
- size: number,
16
- rotation: string
17
- ): Promise<boolean>;
18
- printFormattedText(text: string, fontSize?: number): Promise<boolean>;
19
- printTextSimple(text: string): Promise<boolean>;
20
- printTextInPages(text: string): Promise<boolean>;
21
- initializePrinter(): Promise<boolean>;
22
- connectPrinter(interfaceType: string, address: string, port: number): Promise<boolean>;
23
- disconnectPrinter(): Promise<boolean>;
24
- executeCommand(command: string): Promise<boolean>;
25
-
26
- testPlainText(text: string): Promise<boolean>;
27
-
28
- printInvoice(invoiceText: string): Promise<boolean>;
29
-
30
- requestBluetoothPermissions(): Promise<boolean>;
31
- checkBluetoothPermissions(): Promise<any>;
32
- discoverBluetoothDevices(): Promise<any[]>;
33
- startBluetoothDiscovery(): Promise<boolean>;
34
- stopBluetoothDiscovery(): Promise<boolean>;
35
- isBluetoothEnabled(): Promise<boolean>;
36
- }
37
-
38
- export default requireNativeModule<ExpoBixolonModule>('ExpoBixolon');
@@ -1,201 +0,0 @@
1
- import ExpoBixolonModule from './ExpoBixolonModule';
2
-
3
- export interface QRCodeOptions {
4
- data: string;
5
- size?: number;
6
- }
7
-
8
- export interface QRCodeConstants {
9
- QR_CODE_MODEL1: number;
10
- QR_CODE_MODEL2: number;
11
-
12
- ECC_LEVEL_7: number;
13
- ECC_LEVEL_15: number;
14
- ECC_LEVEL_25: number;
15
- ECC_LEVEL_30: number;
16
-
17
- ROTATION_NONE: number;
18
- ROTATION_90_DEGREES: number;
19
- ROTATION_180_DEGREES: number;
20
- ROTATION_270_DEGREES: number;
21
- }
22
-
23
- export class QrCodePrinter {
24
- private static instance: QrCodePrinter;
25
- private isInitialized = false;
26
-
27
- private constructor() {}
28
-
29
- public static getInstance(): QrCodePrinter {
30
- if (!QrCodePrinter.instance) {
31
- QrCodePrinter.instance = new QrCodePrinter();
32
- }
33
- return QrCodePrinter.instance;
34
- }
35
-
36
- public async initialize(): Promise<boolean> {
37
- try {
38
- if (!this.isInitialized) {
39
- const result = await ExpoBixolonModule.initializePrinter();
40
- this.isInitialized = result;
41
- return result;
42
- }
43
- return true;
44
- } catch (error) {
45
- console.error('Error initializing QR code printer:', error);
46
- throw error;
47
- }
48
- }
49
-
50
- public async printQRCode(options: QRCodeOptions): Promise<boolean> {
51
- try {
52
- if (!this.isInitialized) {
53
- await this.initialize();
54
- }
55
-
56
- const { data, size = 9 } = options;
57
-
58
- if (!data || data.trim().length === 0) {
59
- throw new Error('QR code data cannot be empty');
60
- }
61
-
62
- if (size < 1 || size > 10) {
63
- throw new Error('QR code size must be between 1 and 10');
64
- }
65
-
66
- return await ExpoBixolonModule.printQRCodeAdvanced(
67
- data,
68
- 200,
69
- 100,
70
- 'MODEL2',
71
- 'ECC_LEVEL_7',
72
- size,
73
- 'NONE'
74
- );
75
- } catch (error) {
76
- console.error('Error printing QR code:', error);
77
- throw error;
78
- }
79
- }
80
-
81
- public async printSimpleQRCode(data: string, size: number = 9): Promise<boolean> {
82
- return this.printQRCode({
83
- data,
84
- size,
85
- });
86
- }
87
-
88
- public async printURLQRCode(url: string, size: number = 9): Promise<boolean> {
89
- if (!url.startsWith('http://') && !url.startsWith('https://')) {
90
- url = 'https://' + url;
91
- }
92
- return this.printQRCode({
93
- data: url,
94
- size,
95
- });
96
- }
97
-
98
- public async printContactQRCode(
99
- contact: {
100
- name: string;
101
- phone?: string;
102
- email?: string;
103
- company?: string;
104
- title?: string;
105
- },
106
- size: number = 9
107
- ): Promise<boolean> {
108
- const vCard = this.generateVCard(contact);
109
- return this.printQRCode({
110
- data: vCard,
111
- size,
112
- });
113
- }
114
-
115
- public async printWiFiQRCode(
116
- ssid: string,
117
- password: string,
118
- encryption: 'WPA' | 'WEP' | 'nopass' = 'WPA',
119
- size: number = 9
120
- ): Promise<boolean> {
121
- const wifiString = `WIFI:T:${encryption};S:${ssid};P:${password};;`;
122
- return this.printQRCode({
123
- data: wifiString,
124
- size,
125
- });
126
- }
127
-
128
- public async printPaymentQRCode(
129
- paymentData: {
130
- amount: number;
131
- currency: string;
132
- description?: string;
133
- merchantName?: string;
134
- },
135
- size: number = 0
136
- ): Promise<boolean> {
137
- const paymentString = this.generatePaymentString(paymentData);
138
- return this.printQRCode({
139
- data: paymentString,
140
- size,
141
- });
142
- }
143
-
144
- private generateVCard(contact: {
145
- name: string;
146
- phone?: string;
147
- email?: string;
148
- company?: string;
149
- title?: string;
150
- }): string {
151
- let vCard = 'BEGIN:VCARD\nVERSION:3.0\n';
152
- vCard += `FN:${contact.name}\n`;
153
-
154
- if (contact.phone) {
155
- vCard += `TEL:${contact.phone}\n`;
156
- }
157
-
158
- if (contact.email) {
159
- vCard += `EMAIL:${contact.email}\n`;
160
- }
161
-
162
- if (contact.company) {
163
- vCard += `ORG:${contact.company}\n`;
164
- }
165
-
166
- if (contact.title) {
167
- vCard += `TITLE:${contact.title}\n`;
168
- }
169
-
170
- vCard += 'END:VCARD';
171
- return vCard;
172
- }
173
-
174
- private generatePaymentString(paymentData: {
175
- amount: number;
176
- currency: string;
177
- description?: string;
178
- merchantName?: string;
179
- }): string {
180
- return `PAYMENT:${paymentData.amount}${paymentData.currency}${
181
- paymentData.description ? ':' + paymentData.description : ''
182
- }`;
183
- }
184
-
185
- public getConstants(): QRCodeConstants {
186
- return {
187
- QR_CODE_MODEL1: 1,
188
- QR_CODE_MODEL2: 2,
189
- ECC_LEVEL_7: 7,
190
- ECC_LEVEL_15: 15,
191
- ECC_LEVEL_25: 25,
192
- ECC_LEVEL_30: 30,
193
- ROTATION_NONE: 0,
194
- ROTATION_90_DEGREES: 90,
195
- ROTATION_180_DEGREES: 180,
196
- ROTATION_270_DEGREES: 270,
197
- };
198
- }
199
- }
200
-
201
- export default QrCodePrinter;
package/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export { default } from './ExpoBixolonModule';
2
- export * from './ExpoBixolon.types';
3
- export { default as BixolonPrinter } from './BixolonPrinter';