@simplymobile/capacitor-bixolon-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 +28 -0
- package/README.md +257 -0
- package/SimplymobileCapacitorBixolonPrinter.podspec +17 -0
- package/android/build.gradle +58 -0
- package/android/src/main/AndroidManifest.xml +11 -0
- package/android/src/main/java/pl/simplymobile/plugins/bixolonprinter/BixolonPrinterPlugin.java +725 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +315 -0
- package/dist/esm/definitions.d.ts +117 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +37 -0
- package/dist/esm/web.js +46 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +60 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +63 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/BixolonPrinterPlugin/BixolonPrinter.swift +8 -0
- package/ios/Sources/BixolonPrinterPlugin/BixolonPrinterPlugin.swift +73 -0
- package/ios/Tests/BixolonPrinterPluginTests/BixolonPrinterTests.swift +25 -0
- package/package.json +83 -0
package/Package.swift
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// swift-tools-version: 5.9
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "SimplymobileCapacitorBixolonPrinter",
|
|
6
|
+
platforms: [.iOS(.v15)],
|
|
7
|
+
products: [
|
|
8
|
+
.library(
|
|
9
|
+
name: "SimplymobileCapacitorBixolonPrinter",
|
|
10
|
+
targets: ["BixolonPrinterPlugin"])
|
|
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: "BixolonPrinterPlugin",
|
|
18
|
+
dependencies: [
|
|
19
|
+
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
20
|
+
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
21
|
+
],
|
|
22
|
+
path: "ios/Sources/BixolonPrinterPlugin"),
|
|
23
|
+
.testTarget(
|
|
24
|
+
name: "BixolonPrinterPluginTests",
|
|
25
|
+
dependencies: ["BixolonPrinterPlugin"],
|
|
26
|
+
path: "ios/Tests/BixolonPrinterPluginTests")
|
|
27
|
+
]
|
|
28
|
+
)
|
package/README.md
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
# @simplymobile/capacitor-bixolon-printer
|
|
2
|
+
|
|
3
|
+
Capacitor Bixolon Bluetooth printer plugin
|
|
4
|
+
|
|
5
|
+
Port of the legacy `cordova-bixolon-plugin` (Bluetooth ESC/POS printing) to a Capacitor 8 plugin.
|
|
6
|
+
Android is fully implemented; iOS is a stub.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @simplymobile/capacitor-bixolon-printer
|
|
12
|
+
npx cap sync
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## API
|
|
16
|
+
|
|
17
|
+
<docgen-index>
|
|
18
|
+
|
|
19
|
+
* [`checkPermissions()`](#checkpermissions)
|
|
20
|
+
* [`requestPermissions()`](#requestpermissions)
|
|
21
|
+
* [`list()`](#list)
|
|
22
|
+
* [`getStatus()`](#getstatus)
|
|
23
|
+
* [`connect(...)`](#connect)
|
|
24
|
+
* [`disconnect()`](#disconnect)
|
|
25
|
+
* [`printText(...)`](#printtext)
|
|
26
|
+
* [`printBase64(...)`](#printbase64)
|
|
27
|
+
* [`printImageUrl(...)`](#printimageurl)
|
|
28
|
+
* [`printPOSCommand(...)`](#printposcommand)
|
|
29
|
+
* [`printQRCode(...)`](#printqrcode)
|
|
30
|
+
* [`cutPaper()`](#cutpaper)
|
|
31
|
+
* [`setBrand(...)`](#setbrand)
|
|
32
|
+
* [Interfaces](#interfaces)
|
|
33
|
+
* [Type Aliases](#type-aliases)
|
|
34
|
+
|
|
35
|
+
</docgen-index>
|
|
36
|
+
|
|
37
|
+
<docgen-api>
|
|
38
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
39
|
+
|
|
40
|
+
### checkPermissions()
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
checkPermissions() => Promise<PermissionStatus>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Check the current Bluetooth permission status.
|
|
47
|
+
|
|
48
|
+
**Returns:** <code>Promise<<a href="#permissionstatus">PermissionStatus</a>></code>
|
|
49
|
+
|
|
50
|
+
--------------------
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### requestPermissions()
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
requestPermissions() => Promise<PermissionStatus>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Request the Bluetooth permissions required to discover and connect to printers.
|
|
60
|
+
|
|
61
|
+
**Returns:** <code>Promise<<a href="#permissionstatus">PermissionStatus</a>></code>
|
|
62
|
+
|
|
63
|
+
--------------------
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
### list()
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
list() => Promise<{ devices: BixolonDevice[]; }>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
List the Bluetooth devices that are already paired with the system.
|
|
73
|
+
|
|
74
|
+
**Returns:** <code>Promise<{ devices: BixolonDevice[]; }></code>
|
|
75
|
+
|
|
76
|
+
--------------------
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
### getStatus()
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
getStatus() => Promise<BixolonStatus>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Return the current adapter / connection status.
|
|
86
|
+
|
|
87
|
+
**Returns:** <code>Promise<<a href="#bixolonstatus">BixolonStatus</a>></code>
|
|
88
|
+
|
|
89
|
+
--------------------
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
### connect(...)
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
connect(options: { name: string; }) => Promise<{ message: string; }>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Connect to a paired printer by its Bluetooth friendly name.
|
|
99
|
+
|
|
100
|
+
| Param | Type |
|
|
101
|
+
| ------------- | ------------------------------ |
|
|
102
|
+
| **`options`** | <code>{ name: string; }</code> |
|
|
103
|
+
|
|
104
|
+
**Returns:** <code>Promise<{ message: string; }></code>
|
|
105
|
+
|
|
106
|
+
--------------------
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
### disconnect()
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
disconnect() => Promise<void>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Close the connection to the currently connected printer.
|
|
116
|
+
|
|
117
|
+
--------------------
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
### printText(...)
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
printText(options: { text: string; }) => Promise<void>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Send raw text to the printer.
|
|
127
|
+
|
|
128
|
+
| Param | Type |
|
|
129
|
+
| ------------- | ------------------------------ |
|
|
130
|
+
| **`options`** | <code>{ text: string; }</code> |
|
|
131
|
+
|
|
132
|
+
--------------------
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
### printBase64(...)
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
printBase64(options: { data: string; align?: number; }) => Promise<void>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Print an image provided as a Base64 string.
|
|
142
|
+
|
|
143
|
+
| Param | Type |
|
|
144
|
+
| ------------- | ---------------------------------------------- |
|
|
145
|
+
| **`options`** | <code>{ data: string; align?: number; }</code> |
|
|
146
|
+
|
|
147
|
+
--------------------
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
### printImageUrl(...)
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
printImageUrl(options: { url: string; align?: number; }) => Promise<void>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Print an image loaded from a local file path.
|
|
157
|
+
|
|
158
|
+
| Param | Type |
|
|
159
|
+
| ------------- | --------------------------------------------- |
|
|
160
|
+
| **`options`** | <code>{ url: string; align?: number; }</code> |
|
|
161
|
+
|
|
162
|
+
--------------------
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
### printPOSCommand(...)
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
printPOSCommand(options: { command: string; }) => Promise<void>
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Send a raw ESC/POS command encoded as a hex string.
|
|
172
|
+
|
|
173
|
+
| Param | Type |
|
|
174
|
+
| ------------- | --------------------------------- |
|
|
175
|
+
| **`options`** | <code>{ command: string; }</code> |
|
|
176
|
+
|
|
177
|
+
--------------------
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
### printQRCode(...)
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
printQRCode(options: { text: string; }) => Promise<void>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Print a QR code (currently sends the raw string to the printer).
|
|
187
|
+
|
|
188
|
+
| Param | Type |
|
|
189
|
+
| ------------- | ------------------------------ |
|
|
190
|
+
| **`options`** | <code>{ text: string; }</code> |
|
|
191
|
+
|
|
192
|
+
--------------------
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
### cutPaper()
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
cutPaper() => Promise<void>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Send the paper-cut command to the printer.
|
|
202
|
+
|
|
203
|
+
--------------------
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
### setBrand(...)
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
setBrand(options: { brand: string; }) => Promise<void>
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Set the printer brand. Use `bixolon` to skip alignment commands that some Bixolon models reject.
|
|
213
|
+
|
|
214
|
+
| Param | Type |
|
|
215
|
+
| ------------- | ------------------------------- |
|
|
216
|
+
| **`options`** | <code>{ brand: string; }</code> |
|
|
217
|
+
|
|
218
|
+
--------------------
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
### Interfaces
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
#### PermissionStatus
|
|
225
|
+
|
|
226
|
+
| Prop | Type | Description |
|
|
227
|
+
| --------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
|
|
228
|
+
| **`bluetooth`** | <code><a href="#bluetoothpermissionstate">BluetoothPermissionState</a></code> | Permission state for Bluetooth (BLUETOOTH_CONNECT / BLUETOOTH_SCAN on Android 12+). |
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
#### BixolonDevice
|
|
232
|
+
|
|
233
|
+
| Prop | Type | Description |
|
|
234
|
+
| ------------- | ------------------- | ------------------------------------------------------------------- |
|
|
235
|
+
| **`name`** | <code>string</code> | Bluetooth friendly name of the paired device. |
|
|
236
|
+
| **`address`** | <code>string</code> | Bluetooth MAC address of the paired device. |
|
|
237
|
+
| **`type`** | <code>number</code> | Bluetooth device type (see `BluetoothDevice.getType()` on Android). |
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
#### BixolonStatus
|
|
241
|
+
|
|
242
|
+
| Prop | Type | Description |
|
|
243
|
+
| --------------- | -------------------- | ------------------------------------------------------------------ |
|
|
244
|
+
| **`enabled`** | <code>boolean</code> | Whether the Bluetooth adapter is enabled. |
|
|
245
|
+
| **`connected`** | <code>boolean</code> | Whether there is an active connection to a printer. |
|
|
246
|
+
| **`name`** | <code>string</code> | Name of the connected device (only when `connected` is `true`). |
|
|
247
|
+
| **`address`** | <code>string</code> | Address of the connected device (only when `connected` is `true`). |
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
### Type Aliases
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
#### BluetoothPermissionState
|
|
254
|
+
|
|
255
|
+
<code>'granted' | 'denied' | 'prompt' | 'prompt-with-rationale'</code>
|
|
256
|
+
|
|
257
|
+
</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 = 'SimplymobileCapacitorBixolonPrinter'
|
|
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.bixolonprinter"
|
|
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,11 @@
|
|
|
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
|
+
</manifest>
|