@simplymobile/capacitor-bixolon-sdk-printer 8.0.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/Package.swift ADDED
@@ -0,0 +1,28 @@
1
+ // swift-tools-version: 5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "SimplymobileCapacitorBixolonSdkPrinter",
6
+ platforms: [.iOS(.v15)],
7
+ products: [
8
+ .library(
9
+ name: "SimplymobileCapacitorBixolonSdkPrinter",
10
+ targets: ["BixolonSdkPrinterPlugin"])
11
+ ],
12
+ dependencies: [
13
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0")
14
+ ],
15
+ targets: [
16
+ .target(
17
+ name: "BixolonSdkPrinterPlugin",
18
+ dependencies: [
19
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
20
+ .product(name: "Cordova", package: "capacitor-swift-pm")
21
+ ],
22
+ path: "ios/Sources/BixolonSdkPrinterPlugin"),
23
+ .testTarget(
24
+ name: "BixolonSdkPrinterPluginTests",
25
+ dependencies: ["BixolonSdkPrinterPlugin"],
26
+ path: "ios/Tests/BixolonSdkPrinterPluginTests")
27
+ ]
28
+ )
package/README.md ADDED
@@ -0,0 +1,411 @@
1
+ # @simplymobile/capacitor-bixolon-sdk-printer
2
+
3
+ Capacitor plugin for Bixolon printers built on the official Bixolon Android SDK
4
+ (`BixolonPrinter.jar`). Android-only; on iOS and web every method is unimplemented.
5
+
6
+ Supports text printing (with per-line alignment / size / font), 1D bar codes, QR codes, bitmap
7
+ images, paper cut, printer status, reconnect/disconnect, and MSR (magnetic stripe reader) and
8
+ connection-state listeners emitted as Capacitor events (`msrData`, `connectionChanged`).
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ npm install @simplymobile/capacitor-bixolon-sdk-printer
14
+ npx cap sync
15
+ ```
16
+
17
+ ## API
18
+
19
+ <docgen-index>
20
+
21
+ * [`checkPermissions()`](#checkpermissions)
22
+ * [`requestPermissions()`](#requestpermissions)
23
+ * [`printText(...)`](#printtext)
24
+ * [`printBarCode(...)`](#printbarcode)
25
+ * [`printQRCode(...)`](#printqrcode)
26
+ * [`printBitmap(...)`](#printbitmap)
27
+ * [`cutPaper(...)`](#cutpaper)
28
+ * [`getStatus(...)`](#getstatus)
29
+ * [`reconnect()`](#reconnect)
30
+ * [`disconnect()`](#disconnect)
31
+ * [`startMsrReaderListener()`](#startmsrreaderlistener)
32
+ * [`stopMsrReaderListener()`](#stopmsrreaderlistener)
33
+ * [`startConnectionListener()`](#startconnectionlistener)
34
+ * [`stopConnectionListener()`](#stopconnectionlistener)
35
+ * [`addListener('msrData', ...)`](#addlistenermsrdata-)
36
+ * [`addListener('connectionChanged', ...)`](#addlistenerconnectionchanged-)
37
+ * [`removeAllListeners()`](#removealllisteners)
38
+ * [Interfaces](#interfaces)
39
+ * [Type Aliases](#type-aliases)
40
+
41
+ </docgen-index>
42
+
43
+ <docgen-api>
44
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
45
+
46
+ ### checkPermissions()
47
+
48
+ ```typescript
49
+ checkPermissions() => Promise<PermissionStatus>
50
+ ```
51
+
52
+ Check the current Bluetooth permission status.
53
+
54
+ **Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>
55
+
56
+ --------------------
57
+
58
+
59
+ ### requestPermissions()
60
+
61
+ ```typescript
62
+ requestPermissions() => Promise<PermissionStatus>
63
+ ```
64
+
65
+ Request the Bluetooth permissions required to connect to printers.
66
+
67
+ **Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>
68
+
69
+ --------------------
70
+
71
+
72
+ ### printText(...)
73
+
74
+ ```typescript
75
+ printText(options: { lines: TextLine[]; config?: BixolonSettings; }) => Promise<{ message: string; }>
76
+ ```
77
+
78
+ Print a list of text lines. Connects to the printer, prints, cuts the paper and disconnects.
79
+
80
+ | Param | Type |
81
+ | ------------- | -------------------------------------------------------------------------------------------- |
82
+ | **`options`** | <code>{ lines: TextLine[]; config?: <a href="#bixolonsettings">BixolonSettings</a>; }</code> |
83
+
84
+ **Returns:** <code>Promise&lt;{ message: string; }&gt;</code>
85
+
86
+ --------------------
87
+
88
+
89
+ ### printBarCode(...)
90
+
91
+ ```typescript
92
+ printBarCode(options: { data: BarCodeData; config?: BixolonSettings; }) => Promise<{ message: string; }>
93
+ ```
94
+
95
+ Print a 1D bar code.
96
+
97
+ | Param | Type |
98
+ | ------------- | ----------------------------------------------------------------------------------------------------------------------- |
99
+ | **`options`** | <code>{ data: <a href="#barcodedata">BarCodeData</a>; config?: <a href="#bixolonsettings">BixolonSettings</a>; }</code> |
100
+
101
+ **Returns:** <code>Promise&lt;{ message: string; }&gt;</code>
102
+
103
+ --------------------
104
+
105
+
106
+ ### printQRCode(...)
107
+
108
+ ```typescript
109
+ printQRCode(options: { data: QRCodeData; config?: BixolonSettings; }) => Promise<{ message: string; }>
110
+ ```
111
+
112
+ Print a QR code.
113
+
114
+ | Param | Type |
115
+ | ------------- | --------------------------------------------------------------------------------------------------------------------- |
116
+ | **`options`** | <code>{ data: <a href="#qrcodedata">QRCodeData</a>; config?: <a href="#bixolonsettings">BixolonSettings</a>; }</code> |
117
+
118
+ **Returns:** <code>Promise&lt;{ message: string; }&gt;</code>
119
+
120
+ --------------------
121
+
122
+
123
+ ### printBitmap(...)
124
+
125
+ ```typescript
126
+ printBitmap(options: { base64Image: string; width?: number; brightness?: number; alignment?: number; }) => Promise<{ message: string; }>
127
+ ```
128
+
129
+ Print a Base64-encoded bitmap image.
130
+
131
+ | Param | Type |
132
+ | ------------- | ---------------------------------------------------------------------------------------------- |
133
+ | **`options`** | <code>{ base64Image: string; width?: number; brightness?: number; alignment?: number; }</code> |
134
+
135
+ **Returns:** <code>Promise&lt;{ message: string; }&gt;</code>
136
+
137
+ --------------------
138
+
139
+
140
+ ### cutPaper(...)
141
+
142
+ ```typescript
143
+ cutPaper(options?: { config?: BixolonSettings | undefined; } | undefined) => Promise<{ message: string; }>
144
+ ```
145
+
146
+ Feed/form-feed and cut the paper.
147
+
148
+ | Param | Type |
149
+ | ------------- | ------------------------------------------------------------------------- |
150
+ | **`options`** | <code>{ config?: <a href="#bixolonsettings">BixolonSettings</a>; }</code> |
151
+
152
+ **Returns:** <code>Promise&lt;{ message: string; }&gt;</code>
153
+
154
+ --------------------
155
+
156
+
157
+ ### getStatus(...)
158
+
159
+ ```typescript
160
+ getStatus(options?: { printStatus?: boolean | undefined; config?: BixolonSettings | undefined; } | undefined) => Promise<BixolonDeviceStatus>
161
+ ```
162
+
163
+ Return the connected printer status. When `printStatus` is `true` the status is also printed.
164
+
165
+ | Param | Type |
166
+ | ------------- | ------------------------------------------------------------------------------------------------ |
167
+ | **`options`** | <code>{ printStatus?: boolean; config?: <a href="#bixolonsettings">BixolonSettings</a>; }</code> |
168
+
169
+ **Returns:** <code>Promise&lt;<a href="#bixolondevicestatus">BixolonDeviceStatus</a>&gt;</code>
170
+
171
+ --------------------
172
+
173
+
174
+ ### reconnect()
175
+
176
+ ```typescript
177
+ reconnect() => Promise<{ message: string; }>
178
+ ```
179
+
180
+ Reconnect to the (first paired) printer.
181
+
182
+ **Returns:** <code>Promise&lt;{ message: string; }&gt;</code>
183
+
184
+ --------------------
185
+
186
+
187
+ ### disconnect()
188
+
189
+ ```typescript
190
+ disconnect() => Promise<void>
191
+ ```
192
+
193
+ Disconnect from the currently connected printer.
194
+
195
+ --------------------
196
+
197
+
198
+ ### startMsrReaderListener()
199
+
200
+ ```typescript
201
+ startMsrReaderListener() => Promise<void>
202
+ ```
203
+
204
+ Start listening for magnetic-stripe-reader (MSR) data. Emits `msrData` events.
205
+
206
+ --------------------
207
+
208
+
209
+ ### stopMsrReaderListener()
210
+
211
+ ```typescript
212
+ stopMsrReaderListener() => Promise<void>
213
+ ```
214
+
215
+ Stop listening for MSR data.
216
+
217
+ --------------------
218
+
219
+
220
+ ### startConnectionListener()
221
+
222
+ ```typescript
223
+ startConnectionListener() => Promise<void>
224
+ ```
225
+
226
+ Start listening for connection-state changes. Emits `connectionChanged` events.
227
+
228
+ --------------------
229
+
230
+
231
+ ### stopConnectionListener()
232
+
233
+ ```typescript
234
+ stopConnectionListener() => Promise<void>
235
+ ```
236
+
237
+ Stop listening for connection-state changes.
238
+
239
+ --------------------
240
+
241
+
242
+ ### addListener('msrData', ...)
243
+
244
+ ```typescript
245
+ addListener(eventName: 'msrData', listenerFunc: (data: MsrData) => void) => Promise<PluginListenerHandle>
246
+ ```
247
+
248
+ Listen for MSR (magnetic stripe reader) track data.
249
+
250
+ | Param | Type |
251
+ | ------------------ | -------------------------------------------------------------- |
252
+ | **`eventName`** | <code>'msrData'</code> |
253
+ | **`listenerFunc`** | <code>(data: <a href="#msrdata">MsrData</a>) =&gt; void</code> |
254
+
255
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
256
+
257
+ --------------------
258
+
259
+
260
+ ### addListener('connectionChanged', ...)
261
+
262
+ ```typescript
263
+ addListener(eventName: 'connectionChanged', listenerFunc: (data: ConnectionData) => void) => Promise<PluginListenerHandle>
264
+ ```
265
+
266
+ Listen for printer connection-state changes.
267
+
268
+ | Param | Type |
269
+ | ------------------ | ---------------------------------------------------------------------------- |
270
+ | **`eventName`** | <code>'connectionChanged'</code> |
271
+ | **`listenerFunc`** | <code>(data: <a href="#connectiondata">ConnectionData</a>) =&gt; void</code> |
272
+
273
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
274
+
275
+ --------------------
276
+
277
+
278
+ ### removeAllListeners()
279
+
280
+ ```typescript
281
+ removeAllListeners() => Promise<void>
282
+ ```
283
+
284
+ Remove all registered listeners for this plugin.
285
+
286
+ --------------------
287
+
288
+
289
+ ### Interfaces
290
+
291
+
292
+ #### PermissionStatus
293
+
294
+ | Prop | Type | Description |
295
+ | --------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
296
+ | **`bluetooth`** | <code><a href="#bluetoothpermissionstate">BluetoothPermissionState</a></code> | Permission state for Bluetooth (BLUETOOTH_CONNECT / BLUETOOTH_SCAN on Android 12+). |
297
+
298
+
299
+ #### TextLine
300
+
301
+ A single line of text to print. Prefix `text` with `[hr]&lt;char&gt;` (e.g. `"[hr]="`) to draw a
302
+ horizontal rule filling the paper width.
303
+
304
+ | Prop | Type | Description |
305
+ | ---------------- | ----------------------------------------------- | -------------------------- |
306
+ | **`text`** | <code>string</code> | |
307
+ | **`textAlign`** | <code><a href="#textalign">TextAlign</a></code> | |
308
+ | **`textWidth`** | <code>number</code> | Horizontal text size, 0-7. |
309
+ | **`textHeight`** | <code>number</code> | Vertical text size, 0-7. |
310
+ | **`fontType`** | <code><a href="#fonttype">FontType</a></code> | |
311
+ | **`fontStyle`** | <code><a href="#fontstyle">FontStyle</a></code> | |
312
+
313
+
314
+ #### BixolonSettings
315
+
316
+ Shared print configuration. All fields are optional; sensible defaults are applied natively
317
+ (`lineFeed: 0`, `formFeed: true`, `autoConnect: true`, `toastMessage: true`, `codePage: 16`).
318
+
319
+ | Prop | Type | Description |
320
+ | ------------------ | -------------------- | ------------------------------------------------------------------------------------------------------------- |
321
+ | **`lineFeed`** | <code>number</code> | Number of empty lines to feed after printing (used when `formFeed` is `false`). |
322
+ | **`formFeed`** | <code>boolean</code> | Whether to perform a form feed after printing instead of a line feed. |
323
+ | **`autoConnect`** | <code>boolean</code> | Android only. When `true`, connect to the first paired printer automatically; otherwise show a picker dialog. |
324
+ | **`toastMessage`** | <code>boolean</code> | Android only. Whether the underlying SDK is allowed to show toast messages. |
325
+ | **`codePage`** | <code>number</code> | Single-byte code page used for text printing. |
326
+
327
+
328
+ #### BarCodeData
329
+
330
+ | Prop | Type | Description |
331
+ | ----------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------- |
332
+ | **`text`** | <code>string</code> | |
333
+ | **`alignment`** | <code><a href="#textalign">TextAlign</a></code> | |
334
+ | **`width`** | <code>number</code> | |
335
+ | **`height`** | <code>number</code> | |
336
+ | **`barcodeSystem`** | <code>number</code> | Bar-code symbology (e.g. `73` for CODE128). See `BarCodeSystem` in the README. |
337
+ | **`characterPosition`** | <code>number</code> | Position of the human-readable characters (0 = none, 1 = above, 2 = below, 3 = both). |
338
+
339
+
340
+ #### QRCodeData
341
+
342
+ | Prop | Type | Description |
343
+ | --------------- | ----------------------------------------------- | ------------------------------------------ |
344
+ | **`text`** | <code>string</code> | |
345
+ | **`alignment`** | <code><a href="#textalign">TextAlign</a></code> | |
346
+ | **`size`** | <code>number</code> | QR module size, 1-8. |
347
+ | **`model`** | <code>number</code> | QR model (`49` = model 1, `50` = model 2). |
348
+
349
+
350
+ #### BixolonDeviceStatus
351
+
352
+ | Prop | Type |
353
+ | --------------------- | ------------------- |
354
+ | **`printerName`** | <code>string</code> |
355
+ | **`printerAddress`** | <code>string</code> |
356
+ | **`cover`** | <code>string</code> |
357
+ | **`paper`** | <code>string</code> |
358
+ | **`battery`** | <code>string</code> |
359
+ | **`firmwareVersion`** | <code>string</code> |
360
+ | **`manufacturer`** | <code>string</code> |
361
+ | **`printerModel`** | <code>string</code> |
362
+ | **`codePage`** | <code>string</code> |
363
+
364
+
365
+ #### PluginListenerHandle
366
+
367
+ | Prop | Type |
368
+ | ------------ | ----------------------------------------- |
369
+ | **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |
370
+
371
+
372
+ #### MsrData
373
+
374
+ | Prop | Type |
375
+ | --------------- | ------------------- |
376
+ | **`msrTrack1`** | <code>string</code> |
377
+ | **`msrTrack2`** | <code>string</code> |
378
+ | **`msrTrack3`** | <code>string</code> |
379
+
380
+
381
+ #### ConnectionData
382
+
383
+ | Prop | Type |
384
+ | ----------------- | --------------------------- |
385
+ | **`isConnected`** | <code>boolean</code> |
386
+ | **`message`** | <code>string \| null</code> |
387
+
388
+
389
+ ### Type Aliases
390
+
391
+
392
+ #### BluetoothPermissionState
393
+
394
+ <code>'granted' | 'denied' | 'prompt' | 'prompt-with-rationale'</code>
395
+
396
+
397
+ #### TextAlign
398
+
399
+ <code>'left' | 'center' | 'right'</code>
400
+
401
+
402
+ #### FontType
403
+
404
+ <code>'A' | 'B' | 'C'</code>
405
+
406
+
407
+ #### FontStyle
408
+
409
+ <code>'default' | 'bold' | 'underline' | 'underline2' | 'reversed'</code>
410
+
411
+ </docgen-api>
@@ -0,0 +1,17 @@
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 = 'SimplymobileCapacitorBixolonSdkPrinter'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '15.0'
15
+ s.dependency 'Capacitor'
16
+ s.swift_version = '5.1'
17
+ end
@@ -0,0 +1,58 @@
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.1'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
6
+ }
7
+
8
+ buildscript {
9
+ repositories {
10
+ google()
11
+ mavenCentral()
12
+ }
13
+ dependencies {
14
+ classpath 'com.android.tools.build:gradle:8.13.0'
15
+ }
16
+ }
17
+
18
+ apply plugin: 'com.android.library'
19
+
20
+ android {
21
+ namespace = "pl.simplymobile.plugins.bixolonsdkprinter"
22
+ compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
23
+ defaultConfig {
24
+ minSdkVersion = project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
25
+ targetSdkVersion = project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
26
+ versionCode 1
27
+ versionName "1.0"
28
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
29
+ }
30
+ buildTypes {
31
+ release {
32
+ minifyEnabled false
33
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
34
+ }
35
+ }
36
+ lintOptions {
37
+ abortOnError = false
38
+ }
39
+ compileOptions {
40
+ sourceCompatibility JavaVersion.VERSION_21
41
+ targetCompatibility JavaVersion.VERSION_21
42
+ }
43
+ }
44
+
45
+ repositories {
46
+ google()
47
+ mavenCentral()
48
+ }
49
+
50
+
51
+ dependencies {
52
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
53
+ implementation project(':capacitor-android')
54
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
55
+ testImplementation "junit:junit:$junitVersion"
56
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
57
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
58
+ }
@@ -0,0 +1,19 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+
3
+ <!-- Legacy Bluetooth permissions (Android <= 11). -->
4
+ <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
5
+ <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
6
+
7
+ <!-- Runtime Bluetooth permissions (Android 12+). -->
8
+ <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
9
+ <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
10
+
11
+ <!-- Required by the Bixolon SDK. -->
12
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
13
+ <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
14
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
15
+
16
+ <uses-feature android:name="android.hardware.bluetooth" android:required="false" />
17
+ <uses-feature android:name="android.hardware.wifi" android:required="false" />
18
+
19
+ </manifest>