@sincpro/printer-expo 1.0.0 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sincpro/printer-expo",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Expo module for controlling Bixolon thermal printers with Bluetooth connectivity",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -26,8 +26,6 @@
26
26
  "files": [
27
27
  "build",
28
28
  "android",
29
- "ios",
30
- "src",
31
29
  "expo-module.config.json",
32
30
  "README.md",
33
31
  "LICENSE"
@@ -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,208 +0,0 @@
1
- import { requireNativeModule } from 'expo-modules-core';
2
- import type {
3
- BluetoothDevice,
4
- PairedPrinter,
5
- PrinterStatus,
6
- PrinterInfo,
7
- PrintTextOptions,
8
- PrintTextsOptions,
9
- PrintQROptions,
10
- PrintBarcodeOptions,
11
- PrintImageOptions,
12
- PrintPdfOptions,
13
- PrintKeyValueOptions,
14
- PrintReceiptOptions,
15
- Receipt,
16
- } from './types';
17
-
18
- /**
19
- * Native module interface matching PrinterModule.kt
20
- */
21
- interface SincproPrinterNativeModule {
22
- // Bluetooth
23
- getPairedDevices(): BluetoothDevice[];
24
- getPairedPrinters(): PairedPrinter[];
25
-
26
- // Connection
27
- connectBluetooth(address: string, timeoutMs?: number): Promise<void>;
28
- connectWifi(ip: string, port?: number, timeoutMs?: number): Promise<void>;
29
- connectUsb(): Promise<void>;
30
- disconnect(): Promise<void>;
31
- isConnected(): boolean;
32
- getStatus(): Promise<PrinterStatus>;
33
- getInfo(): Promise<PrinterInfo>;
34
- getDpi(): number;
35
-
36
- // Print - Text
37
- printText(text: string, options?: PrintTextOptions): Promise<void>;
38
- printTexts(texts: string[], options?: PrintTextsOptions): Promise<void>;
39
-
40
- // Print - QR & Barcode
41
- printQR(data: string, options?: PrintQROptions): Promise<void>;
42
- printBarcode(data: string, options?: PrintBarcodeOptions): Promise<void>;
43
-
44
- // Print - Images & PDF
45
- printImageBase64(base64Data: string, options?: PrintImageOptions): Promise<void>;
46
- printPdfBase64(base64Data: string, options?: PrintPdfOptions): Promise<void>;
47
- getPdfPageCount(base64Data: string): number;
48
-
49
- // Print - Receipt
50
- printReceipt(receipt: Receipt, options?: PrintReceiptOptions): Promise<void>;
51
-
52
- // Print - Key-Value
53
- printKeyValue(key: string, value: string, options?: PrintKeyValueOptions): Promise<void>;
54
- }
55
-
56
- const NativeModule = requireNativeModule<SincproPrinterNativeModule>('SincproPrinter');
57
-
58
- // ============================================================
59
- // BLUETOOTH API
60
- // ============================================================
61
-
62
- /**
63
- * Bluetooth API for device discovery
64
- */
65
- export const bluetooth = {
66
- /**
67
- * Get all paired/bonded Bluetooth devices
68
- */
69
- getPairedDevices: (): BluetoothDevice[] => NativeModule.getPairedDevices(),
70
-
71
- /**
72
- * Get paired devices that are printers
73
- */
74
- getPairedPrinters: (): PairedPrinter[] => NativeModule.getPairedPrinters(),
75
- };
76
-
77
- // ============================================================
78
- // CONNECTION API
79
- // ============================================================
80
-
81
- /**
82
- * Connection API for printer connectivity
83
- */
84
- export const connection = {
85
- /**
86
- * Connect to printer via Bluetooth
87
- * @param address MAC address (e.g., "00:11:22:33:44:55")
88
- * @param timeoutMs Connection timeout in milliseconds (default: 10000)
89
- */
90
- connectBluetooth: (address: string, timeoutMs?: number): Promise<void> =>
91
- NativeModule.connectBluetooth(address, timeoutMs),
92
-
93
- /**
94
- * Connect to printer via WiFi
95
- * @param ip IP address (e.g., "192.168.1.100")
96
- * @param port TCP port (default: 9100)
97
- * @param timeoutMs Connection timeout in milliseconds (default: 10000)
98
- */
99
- connectWifi: (ip: string, port?: number, timeoutMs?: number): Promise<void> =>
100
- NativeModule.connectWifi(ip, port, timeoutMs),
101
-
102
- /**
103
- * Connect to printer via USB
104
- */
105
- connectUsb: (): Promise<void> => NativeModule.connectUsb(),
106
-
107
- /**
108
- * Disconnect from current printer
109
- */
110
- disconnect: (): Promise<void> => NativeModule.disconnect(),
111
-
112
- /**
113
- * Check if currently connected
114
- */
115
- isConnected: (): boolean => NativeModule.isConnected(),
116
-
117
- /**
118
- * Get printer status (paper, cover, errors)
119
- */
120
- getStatus: (): Promise<PrinterStatus> => NativeModule.getStatus(),
121
-
122
- /**
123
- * Get printer info (model, firmware, serial)
124
- */
125
- getInfo: (): Promise<PrinterInfo> => NativeModule.getInfo(),
126
-
127
- /**
128
- * Get printer DPI
129
- */
130
- getDpi: (): number => NativeModule.getDpi(),
131
- };
132
-
133
- // ============================================================
134
- // PRINT API
135
- // ============================================================
136
-
137
- /**
138
- * Print API for all printing operations
139
- */
140
- export const print = {
141
- /**
142
- * Print a single line of text
143
- */
144
- text: (text: string, options?: PrintTextOptions): Promise<void> =>
145
- NativeModule.printText(text, options),
146
-
147
- /**
148
- * Print multiple lines of text
149
- */
150
- texts: (texts: string[], options?: PrintTextsOptions): Promise<void> =>
151
- NativeModule.printTexts(texts, options),
152
-
153
- /**
154
- * Print a QR code
155
- */
156
- qr: (data: string, options?: PrintQROptions): Promise<void> =>
157
- NativeModule.printQR(data, options),
158
-
159
- /**
160
- * Print a barcode
161
- */
162
- barcode: (data: string, options?: PrintBarcodeOptions): Promise<void> =>
163
- NativeModule.printBarcode(data, options),
164
-
165
- /**
166
- * Print an image from base64
167
- */
168
- imageBase64: (base64Data: string, options?: PrintImageOptions): Promise<void> =>
169
- NativeModule.printImageBase64(base64Data, options),
170
-
171
- /**
172
- * Print a PDF page from base64
173
- */
174
- pdfBase64: (base64Data: string, options?: PrintPdfOptions): Promise<void> =>
175
- NativeModule.printPdfBase64(base64Data, options),
176
-
177
- /**
178
- * Get page count from a PDF (base64)
179
- */
180
- getPdfPageCount: (base64Data: string): number => NativeModule.getPdfPageCount(base64Data),
181
-
182
- /**
183
- * Print a complete receipt with header, body, footer
184
- */
185
- receipt: (receipt: Receipt, options?: PrintReceiptOptions): Promise<void> =>
186
- NativeModule.printReceipt(receipt, options),
187
-
188
- /**
189
- * Print a key-value pair (two columns)
190
- */
191
- keyValue: (key: string, value: string, options?: PrintKeyValueOptions): Promise<void> =>
192
- NativeModule.printKeyValue(key, value, options),
193
- };
194
-
195
- // ============================================================
196
- // DEFAULT EXPORT
197
- // ============================================================
198
-
199
- /**
200
- * Sincpro Printer SDK for Expo
201
- */
202
- const SincproPrinter = {
203
- bluetooth,
204
- connection,
205
- print,
206
- };
207
-
208
- export default SincproPrinter;
package/src/index.ts DELETED
@@ -1,15 +0,0 @@
1
- /**
2
- * @sincpro/printer-expo
3
- *
4
- * Expo module for Bluetooth/WiFi/USB thermal printers.
5
- * Supports Bixolon label printers.
6
- *
7
- * @packageDocumentation
8
- */
9
-
10
- // Main module export
11
- export { default } from './SincproPrinter';
12
- export { bluetooth, connection, print } from './SincproPrinter';
13
-
14
- // Type exports
15
- export * from './types';
@@ -1,20 +0,0 @@
1
- /**
2
- * Bluetooth types for @sincpro/printer-expo
3
- */
4
-
5
- /**
6
- * Bluetooth device information
7
- */
8
- export interface BluetoothDevice {
9
- name: string;
10
- address: string;
11
- isPrinter: boolean;
12
- }
13
-
14
- /**
15
- * Paired printer (simplified device)
16
- */
17
- export interface PairedPrinter {
18
- name: string;
19
- address: string;
20
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Type exports for @sincpro/printer-expo
3
- */
4
-
5
- export * from './bluetooth.types';
6
- export * from './printer.types';
7
- export * from './receipt.types';
@@ -1,141 +0,0 @@
1
- /**
2
- * Printer types for @sincpro/printer-expo
3
- */
4
-
5
- /**
6
- * Printer status from getStatus()
7
- */
8
- export interface PrinterStatus {
9
- connectionState: ConnectionState;
10
- hasPaper: boolean;
11
- isCoverOpen: boolean;
12
- isOverheated: boolean;
13
- hasError: boolean;
14
- errorMessage: string | null;
15
- }
16
-
17
- /**
18
- * Connection state
19
- */
20
- export type ConnectionState = 'DISCONNECTED' | 'CONNECTING' | 'CONNECTED' | 'ERROR';
21
-
22
- /**
23
- * Printer info from getInfo()
24
- */
25
- export interface PrinterInfo {
26
- model: string;
27
- firmware: string;
28
- serial: string;
29
- dpi: number;
30
- }
31
-
32
- /**
33
- * Media configuration
34
- */
35
- export interface MediaConfig {
36
- /** Use preset instead of manual widthDots/heightDots */
37
- preset?: MediaPreset;
38
- /** Width in dots (ignored if preset is set) */
39
- widthDots?: number;
40
- /** Height in dots (ignored if preset is set) */
41
- heightDots?: number;
42
- }
43
-
44
- /**
45
- * Media presets
46
- */
47
- export type MediaPreset = 'continuous58mm' | 'continuous80mm';
48
-
49
- /**
50
- * Font size options
51
- */
52
- export type FontSize = 'small' | 'medium' | 'large' | 'xlarge';
53
-
54
- /**
55
- * Alignment options
56
- */
57
- export type Alignment = 'left' | 'center' | 'right';
58
-
59
- /**
60
- * Barcode types
61
- */
62
- export type BarcodeType =
63
- | 'CODE128'
64
- | 'CODE39'
65
- | 'EAN13'
66
- | 'EAN8'
67
- | 'UPCA'
68
- | 'UPCE'
69
- | 'CODE93'
70
- | 'CODABAR';
71
-
72
- /**
73
- * Print text options
74
- */
75
- export interface PrintTextOptions {
76
- fontSize?: FontSize;
77
- alignment?: Alignment;
78
- bold?: boolean;
79
- media?: MediaConfig;
80
- }
81
-
82
- /**
83
- * Print texts options (multiple lines)
84
- */
85
- export interface PrintTextsOptions {
86
- fontSize?: FontSize;
87
- media?: MediaConfig;
88
- }
89
-
90
- /**
91
- * Print QR options
92
- */
93
- export interface PrintQROptions {
94
- size?: number;
95
- alignment?: Alignment;
96
- media?: MediaConfig;
97
- }
98
-
99
- /**
100
- * Print barcode options
101
- */
102
- export interface PrintBarcodeOptions {
103
- type?: BarcodeType;
104
- height?: number;
105
- alignment?: Alignment;
106
- media?: MediaConfig;
107
- }
108
-
109
- /**
110
- * Print image options
111
- */
112
- export interface PrintImageOptions {
113
- alignment?: Alignment;
114
- media?: MediaConfig;
115
- }
116
-
117
- /**
118
- * Print PDF options
119
- */
120
- export interface PrintPdfOptions {
121
- page?: number;
122
- alignment?: Alignment;
123
- media?: MediaConfig;
124
- }
125
-
126
- /**
127
- * Print key-value options
128
- */
129
- export interface PrintKeyValueOptions {
130
- fontSize?: FontSize;
131
- bold?: boolean;
132
- media?: MediaConfig;
133
- }
134
-
135
- /**
136
- * Print receipt options
137
- */
138
- export interface PrintReceiptOptions {
139
- media?: MediaConfig;
140
- copies?: number;
141
- }
@@ -1,115 +0,0 @@
1
- /**
2
- * Receipt types for @sincpro/printer-expo
3
- */
4
-
5
- import type { FontSize, Alignment, BarcodeType } from './printer.types';
6
-
7
- /**
8
- * Receipt structure with header, body, and footer sections
9
- */
10
- export interface Receipt {
11
- header?: ReceiptLine[];
12
- body?: ReceiptLine[];
13
- footer?: ReceiptLine[];
14
- }
15
-
16
- /**
17
- * Receipt line types (discriminated union)
18
- */
19
- export type ReceiptLine =
20
- | TextLine
21
- | KeyValueLine
22
- | QRLine
23
- | BarcodeLine
24
- | ImageLine
25
- | SeparatorLine
26
- | SpaceLine
27
- | ColumnsLine;
28
-
29
- /**
30
- * Text line
31
- */
32
- export interface TextLine {
33
- type: 'text';
34
- content: string;
35
- fontSize?: FontSize;
36
- bold?: boolean;
37
- alignment?: Alignment;
38
- }
39
-
40
- /**
41
- * Key-value pair line
42
- */
43
- export interface KeyValueLine {
44
- type: 'keyValue';
45
- key: string;
46
- value: string;
47
- fontSize?: FontSize;
48
- bold?: boolean;
49
- }
50
-
51
- /**
52
- * QR code line
53
- */
54
- export interface QRLine {
55
- type: 'qr';
56
- data: string;
57
- size?: number;
58
- alignment?: Alignment;
59
- }
60
-
61
- /**
62
- * Barcode line
63
- */
64
- export interface BarcodeLine {
65
- type: 'barcode';
66
- data: string;
67
- barcodeType?: BarcodeType;
68
- height?: number;
69
- alignment?: Alignment;
70
- }
71
-
72
- /**
73
- * Image line (base64)
74
- */
75
- export interface ImageLine {
76
- type: 'image';
77
- base64: string;
78
- alignment?: Alignment;
79
- }
80
-
81
- /**
82
- * Separator line
83
- */
84
- export interface SeparatorLine {
85
- type: 'separator';
86
- char?: string;
87
- length?: number;
88
- }
89
-
90
- /**
91
- * Space/blank line
92
- */
93
- export interface SpaceLine {
94
- type: 'space';
95
- lines?: number;
96
- }
97
-
98
- /**
99
- * Column definition
100
- */
101
- export interface Column {
102
- text: string;
103
- widthRatio?: number;
104
- alignment?: Alignment;
105
- }
106
-
107
- /**
108
- * Columns line (multiple columns in one row)
109
- */
110
- export interface ColumnsLine {
111
- type: 'columns';
112
- columns: Column[];
113
- fontSize?: FontSize;
114
- bold?: boolean;
115
- }