@nitra/zebra 6.2.0 → 7.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/NitraZebra.podspec +16 -13
- package/Package.swift +28 -0
- package/README.md +72 -0
- package/android/build.gradle +16 -14
- package/android/src/main/AndroidManifest.xml +2 -22
- package/android/src/main/java/dev/nitra/zebra/Zebra.java +11 -0
- package/android/src/main/java/dev/nitra/zebra/ZebraPlugin.java +22 -0
- package/dist/plugin.js +842 -1296
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/ZebraPlugin/Zebra.swift +8 -0
- package/ios/Sources/ZebraPlugin/ZebraPlugin.swift +23 -0
- package/ios/Tests/ZebraPluginTests/ZebraTests.swift +15 -0
- package/package.json +46 -54
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.project +0 -28
- package/android/capacitor.settings.gradle +0 -3
- package/android/gradle.properties +0 -19
- package/android/proguard-rules.pro +0 -21
- package/android/src/main/java/com/nitra/zebra_printer_plugin/ZebraPrinter.java +0 -1418
- package/android/src/main/res/xml/capacitor_plugins.xml +0 -4
- package/android/variables.gradle +0 -14
- package/ios/Info.plist +0 -36
- package/ios/Plugin/ZebraPrinterPlugin.m +0 -16
- package/ios/Plugin/ZebraPrinterPlugin.swift +0 -465
- /package/android/{.gradle/8.9/dependencies-accessors/gc.properties → src/main/res/.gitkeep} +0 -0
package/NitraZebra.podspec
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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 = 'NitraZebra'
|
|
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'
|
|
14
17
|
end
|
package/Package.swift
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// swift-tools-version: 5.9
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "NitraZebra",
|
|
6
|
+
platforms: [.iOS(.v15)],
|
|
7
|
+
products: [
|
|
8
|
+
.library(
|
|
9
|
+
name: "NitraZebra",
|
|
10
|
+
targets: ["ZebraPlugin"])
|
|
11
|
+
],
|
|
12
|
+
dependencies: [
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0")
|
|
14
|
+
],
|
|
15
|
+
targets: [
|
|
16
|
+
.target(
|
|
17
|
+
name: "ZebraPlugin",
|
|
18
|
+
dependencies: [
|
|
19
|
+
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
20
|
+
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
21
|
+
],
|
|
22
|
+
path: "ios/Sources/ZebraPlugin"),
|
|
23
|
+
.testTarget(
|
|
24
|
+
name: "ZebraPluginTests",
|
|
25
|
+
dependencies: ["ZebraPlugin"],
|
|
26
|
+
path: "ios/Tests/ZebraPluginTests")
|
|
27
|
+
]
|
|
28
|
+
)
|
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# @nitra/zebra
|
|
2
|
+
|
|
3
|
+
Capacitor-плагін для друку ZPL на принтерах Zebra з підтримкою веб (Web Serial API), iOS та Android.
|
|
4
|
+
|
|
5
|
+
## Вимоги
|
|
6
|
+
|
|
7
|
+
- **Capacitor** 7.0.0 або новіший
|
|
8
|
+
- **Веб**: браузер з підтримкою [Web Serial API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API) (Chrome, Edge, Opera)
|
|
9
|
+
- **Android**: minSdk 23, targetSdk 35
|
|
10
|
+
- **iOS**: 14.0+
|
|
11
|
+
|
|
12
|
+
## Встановлення
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @nitra/zebra
|
|
16
|
+
npx cap sync
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## API
|
|
20
|
+
|
|
21
|
+
### `print(value: string): Promise<boolean>`
|
|
22
|
+
|
|
23
|
+
Відправляє ZPL-команду на принтер Zebra.
|
|
24
|
+
|
|
25
|
+
| Платформа | Поведінка |
|
|
26
|
+
| ----------- | --------------------------------------------------------------------------------------------------------------- |
|
|
27
|
+
| **Web** | Запитує порт через Web Serial API, відкриває з'єднання (9600 baud) і відправляє рядок ZPL на вибраний пристрій. |
|
|
28
|
+
| **iOS** | Нативна реалізація (через плагін). |
|
|
29
|
+
| **Android** | Нативна реалізація (через плагін). |
|
|
30
|
+
|
|
31
|
+
**Параметри:**
|
|
32
|
+
|
|
33
|
+
- `value` — рядок з ZPL-командами (наприклад, `^XA^FO50,50^A0N,28,28^FDHello^FS^XZ`).
|
|
34
|
+
|
|
35
|
+
**Приклад:**
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
import { Zebra } from "@nitra/zebra";
|
|
39
|
+
|
|
40
|
+
const zpl = "^XA^FO50,50^A0N,28,28^FDHello World^FS^XZ";
|
|
41
|
+
await Zebra.print(zpl);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Веб (Web Serial API)
|
|
45
|
+
|
|
46
|
+
На веб-платформі плагін використовує Web Serial API:
|
|
47
|
+
|
|
48
|
+
1. При виклику `print()` користувачу показується діалог вибору послідовного порту (принтер, підключений через USB).
|
|
49
|
+
2. Відкривається з'єднання з параметрами: 9600 baud, 8 data bits, no parity, 1 stop bit.
|
|
50
|
+
3. ZPL-рядок відправляється на пристрій.
|
|
51
|
+
|
|
52
|
+
**Обмеження:** Web Serial API працює лише в підтримуваних браузерах (Chrome, Edge, Opera) і зазвичай лише через HTTPS або localhost.
|
|
53
|
+
|
|
54
|
+
## Структура пакету
|
|
55
|
+
|
|
56
|
+
- `dist/` — зібраний JS-плагін (rolldown)
|
|
57
|
+
- `src/` — вихідний код: `index.js`, `definitions.js`, `web.js` (Web Serial реалізація)
|
|
58
|
+
- `ios/` — нативний iOS-плагін (Swift)
|
|
59
|
+
- `android/` — нативний Android-плагін (Java)
|
|
60
|
+
|
|
61
|
+
## Скрипти
|
|
62
|
+
|
|
63
|
+
| Команда | Опис |
|
|
64
|
+
| ---------------- | ----------------------------------------------- |
|
|
65
|
+
| `npm run build` | Збірка плагіну (rolldown) |
|
|
66
|
+
| `npm run verify` | Перевірка iOS, Android та веб-збірки |
|
|
67
|
+
| `npm run fmt` | Форматування коду (ESLint, Prettier, SwiftLint) |
|
|
68
|
+
| `npm run lint` | Перевірка стилю коду |
|
|
69
|
+
|
|
70
|
+
## Ліцензія
|
|
71
|
+
|
|
72
|
+
MIT
|
package/android/build.gradle
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
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
|
+
|
|
1
8
|
buildscript {
|
|
2
9
|
repositories {
|
|
3
10
|
google()
|
|
4
11
|
mavenCentral()
|
|
5
|
-
maven {
|
|
6
|
-
url "https://plugins.gradle.org/m2/"
|
|
7
|
-
}
|
|
8
12
|
}
|
|
9
13
|
dependencies {
|
|
10
|
-
classpath 'com.android.tools.build:gradle:8.
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.13.0'
|
|
11
15
|
}
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
apply plugin: 'com.android.library'
|
|
15
|
-
apply from: 'variables.gradle'
|
|
16
19
|
|
|
17
20
|
android {
|
|
18
|
-
namespace "
|
|
19
|
-
|
|
21
|
+
namespace = "dev.nitra.zebra"
|
|
22
|
+
compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
|
|
20
23
|
defaultConfig {
|
|
21
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
22
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion :
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
|
|
23
26
|
versionCode 1
|
|
24
27
|
versionName "1.0"
|
|
25
28
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
@@ -31,11 +34,11 @@ android {
|
|
|
31
34
|
}
|
|
32
35
|
}
|
|
33
36
|
lintOptions {
|
|
34
|
-
abortOnError false
|
|
37
|
+
abortOnError = false
|
|
35
38
|
}
|
|
36
39
|
compileOptions {
|
|
37
|
-
sourceCompatibility JavaVersion.
|
|
38
|
-
targetCompatibility JavaVersion.
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_21
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_21
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
|
|
@@ -44,13 +47,12 @@ repositories {
|
|
|
44
47
|
mavenCentral()
|
|
45
48
|
}
|
|
46
49
|
|
|
50
|
+
|
|
47
51
|
dependencies {
|
|
48
52
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
49
53
|
implementation project(':capacitor-android')
|
|
50
54
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
51
|
-
implementation "androidx.core:core:$androidxCoreVersion"
|
|
52
55
|
testImplementation "junit:junit:$junitVersion"
|
|
53
56
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
54
57
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
55
58
|
}
|
|
56
|
-
|
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
package="com.nitra.zebra_printer_plugin">
|
|
4
|
-
|
|
5
|
-
<!-- Bluetooth permissions -->
|
|
6
|
-
<uses-permission android:name="android.permission.BLUETOOTH" />
|
|
7
|
-
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
|
8
|
-
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
|
9
|
-
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
|
|
10
|
-
|
|
11
|
-
<!-- Location permissions (required for BLE scanning on Android) -->
|
|
12
|
-
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
13
|
-
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
|
14
|
-
|
|
15
|
-
<!-- Wi-Fi info (SSID) on Android 13+ -->
|
|
16
|
-
<uses-permission android:name="android.permission.NEARBY_WIFI_DEVICES" />
|
|
17
|
-
|
|
18
|
-
<!-- Feature declarations -->
|
|
19
|
-
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true" />
|
|
20
|
-
<uses-feature android:name="android.hardware.bluetooth" android:required="true" />
|
|
21
|
-
|
|
22
|
-
</manifest>
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
|
+
</manifest>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package dev.nitra.zebra;
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.JSObject;
|
|
4
|
+
import com.getcapacitor.Plugin;
|
|
5
|
+
import com.getcapacitor.PluginCall;
|
|
6
|
+
import com.getcapacitor.PluginMethod;
|
|
7
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
8
|
+
|
|
9
|
+
@CapacitorPlugin(name = "Zebra")
|
|
10
|
+
public class ZebraPlugin extends Plugin {
|
|
11
|
+
|
|
12
|
+
private Zebra implementation = new Zebra();
|
|
13
|
+
|
|
14
|
+
@PluginMethod
|
|
15
|
+
public void echo(PluginCall call) {
|
|
16
|
+
String value = call.getString("value");
|
|
17
|
+
|
|
18
|
+
JSObject ret = new JSObject();
|
|
19
|
+
ret.put("value", implementation.echo(value));
|
|
20
|
+
call.resolve(ret);
|
|
21
|
+
}
|
|
22
|
+
}
|