@rdlabo/capacitor-brotherprint 8.1.1-beta.pr40.shae90134023d21 → 8.1.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/README.md CHANGED
@@ -1,55 +1,272 @@
1
1
  # @rdlabo/capacitor-brotherprint
2
2
 
3
- Capacitor Brother Print binds the native Brother Print SDK for iOS and Android so you can search supported Brother label printers and print images from a Capacitor app.
3
+ Capacitor Brother Print is a native Brother Print SDK implementation for iOS & Android. Support These models.
4
4
 
5
- **This plugin is still in the RC (release candidate) phase.** iOS requires **Swift Package Manager** and a minimum of **iOS 15**. The Brother Print SDK is not compatible with CocoaPods for this plugin.
5
+ **This plugin is still in the RC (release candidate) phase.**
6
6
 
7
- <!-- rdlabo-docs-omit -->
8
- **Documentation:** [Read the full documentation](https://docs.rdlabo.dev/projects/capacitor-brotherprint)
9
- <!-- /rdlabo-docs-omit -->
10
-
11
- ## Install
12
-
13
- ```
14
- npm install @rdlabo/capacitor-brotherprint
15
- ```
16
-
17
- For SDK placement, SPM layout, and permissions, see [Installation](https://docs.rdlabo.dev/projects/capacitor-brotherprint/docs/installation).
18
-
19
- ## Print your first label
20
-
21
- 1. [Installation](https://docs.rdlabo.dev/projects/capacitor-brotherprint/docs/installation) — npm install, place the Brother SDK, permissions, then `npx cap sync`.
22
- 2. [Search](https://docs.rdlabo.dev/projects/capacitor-brotherprint/docs/search) — register `onPrinterAvailable`, keep the discovered channel, run Wi-Fi (or other) search.
23
- 3. [Print](https://docs.rdlabo.dev/projects/capacitor-brotherprint/docs/print) — print with that channel, a supported model/label, and a real base64 image you prepare.
24
- 4. [Events](https://docs.rdlabo.dev/projects/capacitor-brotherprint/docs/events) — print success and error listeners in more detail.
7
+ **Brother Print SDK is incompatible with CocoaPods and Minimum Developments iOS 14 and is not working at this time, please use Swift Package Manager.**
25
8
 
26
9
  ## Supported models
27
10
 
28
- Each product link is an Amazon affiliate link. Purchases through these links help support development costs.
11
+ Each product link is an Amazon affiliate link. If you choose to make a purchase through these links, it would be greatly appreciated and **would help** support development costs. Thank you!
29
12
 
30
13
  | Product | Model | iOS/WiFi | iOS/BT | iOS/BLE | Android/USB | Android/WiFi | Android/BT | Android/BLE |
31
14
  | ------------------------------------- | ------------ | -------- | ------ | ------- | ----------- | ------------ | ---------- | ----------- |
32
- | QL-810W | QL_810W | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ |
33
- | [QL-820NWB](https://amzn.to/3BXQ1aj) | QL_820NWB | ✅ | ※1 | ❌ | △ | ✅ | △ | ❌ |
34
- | [QL-820NWBc](https://amzn.to/4fjhUIe) | QL_820NWB | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ❌ |
35
- | [TD-2320D](https://amzn.to/48EFCN3) | TD_2320D_203 | ❌ | ❌ | ❌ | △ | ❌ | ❌ | ❌ |
36
- | [TD-2350D](https://amzn.to/48ma6TK) | TD_2350D_300 | ✅ | △ | △ | ✅ | ✅ | ✅ | △ |
15
+ | QL-810W | QL_810W | ✗ | ✗ | ✗ | ◯ | ✗ | ✗ | ✗ |
16
+ | [QL-820NWB](https://amzn.to/3BXQ1aj) | QL_820NWB | ◯ | ※1 | ✗ | △ | ◯ | △ | ✗ |
17
+ | [QL-820NWBc](https://amzn.to/4fjhUIe) | QL_820NWB | ◯ | ※2 | ✗ | ✗ | ◯ | ◯ | ✗ |
18
+ | [TD-2320D](https://amzn.to/48EFCN3) | TD_2320D_203 | ✗ | ✗ | ✗ | △ | ✗ | ✗ | ✗ |
19
+ | [TD-2350D](https://amzn.to/48ma6TK) | TD_2350D_300 | ◯ | △ | △ | ◯ | ◯ | ◯ | △ |
37
20
 
38
- Amazon Affiliate Links: **https://amzn.to/3AiiOFT**
21
+ Amazon Affiliate Links: **https://amzn.to/3AiiOFT**
39
22
 
40
23
  **Supplement**
41
24
 
42
25
  | | description |
43
26
  | --- | -------------------------- |
44
- | ✅ | Supported and tested |
27
+ | ◯ | Supported and tested |
45
28
  | △ | Implemented but not tested |
46
29
  | - | Plugin is not supported |
47
- | ❌ | Device is not supported |
30
+ | ✗ | Device is not supported |
48
31
  | BT | Bluetooth |
49
32
  | BLE | Bluetooth Low Energy |
50
33
 
51
34
  ※1 Due to low Bluetooth version, connection is not possible with iOS. Ref: https://okbizcs.okwave.jp/brother/qa/q9932082.html
52
35
 
36
+ ※2 The iOS/BT implementation for the QL-820NWBc is in place, but it’s uncertain if it functions correctly. It’s unclear whether this is an implementation issue, as Brother’s official app also doesn’t work well.
37
+
38
+ ## How to install
39
+
40
+ ```
41
+ % npm install @rdlabo/capacitor-brotherprint
42
+ ```
43
+
44
+ ## Initialize the Brother SDK
45
+
46
+ ### Android configuration
47
+
48
+ 1. Place the following files in the android folder of your Capacitor project:
49
+
50
+ - `android/BrotherPrintLibrary/BrotherPrintLibrary.aar`
51
+ - `android/BrotherPrintLibrary/build.gradle`
52
+
53
+ The `BrotherPrintLibrary.aar` file is the Brother Print SDK library, which you can download from the Brother website: https://support.brother.co.jp/j/s/es/dev/ja/mobilesdk/android/index.html?c=jp&lang=ja&navi=offall&comple=on&redirect=on#ver4
54
+
55
+ 2. In the `android/BrotherPrintLibrary/build.gradle file`, include the following content:
56
+
57
+ ```
58
+ configurations.maybeCreate(“default”)
59
+ artifacts.add(“default”, file('BrotherPrintLibrary.aar'))
60
+ ```
61
+
62
+ 3. Open `android/settings.gradle` and add the following lines:
63
+
64
+ ```
65
+ include ':BrotherPrintLibrary'
66
+ project(':BrotherPrintLibrary').projectDir = new File('./BrotherPrintLibrary/')
67
+ ```
68
+
69
+ These steps will integrate the Brother Print SDK with your Capacitor Android project.
70
+
71
+ ### iOS configuration
72
+
73
+ 1. Place the following files in the ios folder of your Capacitor project:
74
+
75
+ - `ios/LocalPackages/BRLMPrinterKit/Sources/BRLMPrinterKit.xcframework`
76
+ - `ios/LocalPackages/BRLMPrinterKit/BRLMPrinterKit.podspec`
77
+ - `ios/LocalPackages/BRLMPrinterKit/Package.swift`
78
+
79
+ The `BRLMPrinterKit.xcframework` file is the Brother Print SDK library, which you can download from the Brother website: https://support.brother.co.jp/j/s/es/dev/ja/mobilesdk/android/index.html?c=jp&lang=ja&navi=offall&comple=on&redirect=on#ver4
80
+
81
+ `BRLMPrinterKit.podspec` content is here:
82
+
83
+ ```podspec
84
+ Pod::Spec.new do |s|
85
+ s.name = 'BRLMPrinterKit'
86
+ s.version = '4.12.0'
87
+ s.homepage = 'https://support.brother.co.jp/j/s/support/html/mobilesdk/index.html'
88
+ s.source = { :path => './Sources' }
89
+ s.summary = "Pod for the BRLMPrinterKit / Brother's printers"
90
+ s.description = "This project is only a Pod for the Brother SDK v#{s.version}"
91
+ s.license = { :type => 'MIT', :file => 'LICENSE' }
92
+ s.author = { 'Masahiko Sakakibara' => 'sakakibara@rdlabo.jp' }
93
+ s.ios.deployment_target = '11.0'
94
+ s.ios.vendored_frameworks = 'Sources/BRLMPrinterKit.xcframework'
95
+ s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
96
+ s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
97
+ end
98
+ ```
99
+
100
+ `Package.swift` content is here:
101
+
102
+ ```swift
103
+ // swift-tools-version: 5.9
104
+ import PackageDescription
105
+
106
+ let package = Package(
107
+ name: "BRLMPrinterKit",
108
+ platforms: [
109
+ .iOS(.v13)
110
+ ],
111
+ products: [
112
+ .library(name: "BRLMPrinterKit", targets: ["BRLMPrinterKit"])
113
+ ],
114
+ targets: [
115
+ .binaryTarget(
116
+ name: "BRLMPrinterKit",
117
+ path: "Sources/BRLMPrinterKit.xcframework"
118
+ )
119
+ ]
120
+ )
121
+ ```
122
+
123
+ 2. Update the `ios/App/Podfile` file at your project.
124
+
125
+ ```diff
126
+ target 'App' do
127
+ capacitor_pods
128
+ # Add your Pods here
129
+ + pod 'BRLMPrinterKit', :path => '../LocalPackages/BRLMPrinterKit'
130
+ end
131
+ ```
132
+
133
+ After set, run `pod update` in the `ios` directory.
134
+
135
+ ## Permission configuration
136
+
137
+ ### Android configuration
138
+
139
+ Update `AndroidManifest.xml` to include the following permissions:
140
+
141
+ ```diff
142
+ - <manifest xmlns:android="http://schemas.android.com/apk/res/android">
143
+ + <manifest xmlns:android="http://schemas.android.com/apk/res/android"
144
+ + xmlns:tools="http://schemas.android.com/tools">
145
+ ...
146
+ + <!-- For Bluetooth -->
147
+ + <uses-permission android:name="android.permission.BLUETOOTH" />
148
+ + <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
149
+ + <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
150
+
151
+ + <!-- For Bluetooth Low Energy, Android 11 and earlier-->
152
+ + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
153
+ + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
154
+
155
+ + <!-- For Bluetooth Low Energy, Android 12 and later -->
156
+ + <uses-permission android:name="android.permission.BLUETOOTH_SCAN"
157
+ + android:usesPermissionFlags="neverForLocation"
158
+ + tools:targetApi="s" />
159
+ ```
160
+
161
+ More information is here: https://support.brother.co.jp/j/s/support/html/mobilesdk/guide/getting-started/getting-started-android.html
162
+
163
+ ### iOS configuration
164
+
165
+ Update `Info.plist` to include the following permissions:
166
+
167
+ ```diff
168
+ + <key>NSBluetoothAlwaysUsageDescription</key>
169
+ + <string>【Why use Bluetooth for your app.】</string>
170
+ + <key>NSBluetoothPeripheralUsageDescription</key>
171
+ + <string>【Why use Bluetooth for your app.】</string>
172
+ + <key>NSBonjourServices</key>
173
+ + <array>
174
+ + <string>_pdl-datastream._tcp</string>
175
+ + <string>_printer._tcp</string>
176
+ + <string>_ipp._tcp</string>
177
+ + </array>
178
+ + <key>NSLocalNetworkUsageDescription</key>
179
+ + <string>【Why use WiFi for your app.】</string>
180
+ + <key>UISupportedExternalAccessoryProtocols</key>
181
+ + <string>com.brother.ptcbp</string>
182
+ ```
183
+
184
+ More information is here: https://support.brother.co.jp/j/s/support/html/mobilesdk/guide/getting-started/getting-started-ios.html
185
+
186
+ ## How to use
187
+
188
+ ```typescript
189
+ @Component({
190
+ selector: 'brother-print',
191
+ templateUrl: 'brother.component.html',
192
+ styleUrls: ['brother.component.scss'],
193
+ })
194
+ export class BrotherComponent implements OnInit, OnDestroy {
195
+ readonly #listenerHandlers: PluginListenerHandle[] = [];
196
+ readonly printers = signal<BRLMChannelResult[]>([]);
197
+
198
+ async ngOnInit() {
199
+ this.#listenerHandlers.push(
200
+ await BrotherPrint.addListener(BrotherPrintEventsEnum.onPrint, () => {
201
+ console.log('onPrint');
202
+ }),
203
+ );
204
+ this.#listenerHandlers.push(
205
+ await BrotherPrint.addListener(
206
+ BrotherPrintEventsEnum.onPrintError,
207
+ info => {
208
+ console.log('onPrintError');
209
+ },
210
+ ),
211
+ );
212
+ this.#listenerHandlers.push(
213
+ await BrotherPrint.addListener(
214
+ BrotherPrintEventsEnum.onPrintFailedCommunication,
215
+ info => {
216
+ console.log('onPrintFailedCommunication');
217
+ },
218
+ ),
219
+ );
220
+ this.#listenerHandlers.push(
221
+ await BrotherPrint.addListener(
222
+ BrotherPrintEventsEnum.onPrinterAvailable,
223
+ printer => {
224
+ this.printers.update(prev => [...prev, printer]);
225
+ },
226
+ ),
227
+ );
228
+ }
229
+
230
+ async ngOnDestroy() {
231
+ this.#listenerHandlers.forEach(handler => handler.remove());
232
+ }
233
+
234
+ async searchPrinter(port: BRKMPrinterPort) {
235
+ // This method return void. Get the printer list by listening to the event.
236
+ await BrotherPrint.search({
237
+ port,
238
+ searchDuration: 15, // seconds
239
+ });
240
+ }
241
+
242
+ print() {
243
+ if (this.printers().length === 0) {
244
+ console.error('No printer found');
245
+ return;
246
+ }
247
+
248
+ const defaultPrintSettings: BRLMPrintOptions = {
249
+ modelName: BRLMPrinterModelName.QL_820NWB,
250
+ labelName: BRLMPrinterLabelName.RollW62,
251
+ encodedImage: 'base64 removed mime-type', // base64
252
+ numberOfCopies: 1, // default 1
253
+ autoCut: true, // default true
254
+ };
255
+
256
+ BrotherPrint.printImage({
257
+ ...defaultPrintSettings,
258
+ ...{
259
+ port: this.printers()[0].port,
260
+ channelInfo: this.printers()[0].channelInfo,
261
+ },
262
+ });
263
+ }
264
+ }
265
+ ```
266
+
267
+ See demo for complete code:
268
+ https://github.com/rdlabo-team/capacitor-brotherprint/blob/main/demo/src/app/home/home.page.ts
269
+
53
270
  ## API
54
271
 
55
272
  <docgen-index>
@@ -124,7 +341,7 @@ you can use it to verify whether it is currently usable.
124
341
  cancelSearchWiFiPrinter() => Promise<void>
125
342
  ```
126
343
 
127
- Stop an active search before its timeout, including when leaving the screen.
344
+ Basically, it times out, so there is no need to use it. Use it when you want to run multiple connectType searches at the same time and time out any of them manually.
128
345
 
129
346
  --------------------
130
347
 
@@ -135,7 +352,7 @@ Stop an active search before its timeout, including when leaving the screen.
135
352
  cancelSearchBluetoothPrinter() => Promise<void>
136
353
  ```
137
354
 
138
- Stop an active search before its timeout, including when leaving the screen.
355
+ Basically, it times out, so there is no need to use it. Use it when you want to run multiple connectType searches at the same time and time out any of them manually.
139
356
 
140
357
  --------------------
141
358
 
@@ -282,7 +499,7 @@ These are optional. If these are not set, default values are assigned by the pri
282
499
 
283
500
  #### BRLMSearchOption
284
501
 
285
- <code>{ /** * 'usb' is android only, and now developing. */ port: <a href="#brlmprinterport">BRLMPrinterPort</a>; /** * searchDuration is the time to end search for devices. * default is 15 seconds. * use only port is 'wifi' or 'bluetoothLowEnergy'. */ searchDuration: number; /** * Android Bluetooth Classic only. Include only devices whose Bluetooth class * reports a printer. Defaults to false; ignored for other ports and on iOS. * This does not identify Brother devices. Devices with an unknown class are excluded when true. */ bluetoothPrintersOnly?: boolean; }</code>
502
+ <code>{ /** * 'usb' is android only, and now developing. */ port: <a href="#brlmprinterport">BRLMPrinterPort</a>; /** * searchDuration is the time to end search for devices. * default is 15 seconds. * use only port is 'wifi' or 'bluetoothLowEnergy'. */ searchDuration: number; }</code>
286
503
 
287
504
 
288
505
  #### isChannelAvailableResult
@@ -459,31 +676,3 @@ These are optional. If these are not set, default values are assigned by the pri
459
676
  | **`onPrintError`** | <code>'onPrintError'</code> |
460
677
 
461
678
  </docgen-api>
462
-
463
- <!-- rdlabo-docs-omit -->
464
- ## Prerelease channels
465
-
466
- An open, non-draft pull request can be published to the npm `beta` dist-tag after its `Validation` and `Package Candidate` workflows pass. A repository owner or maintainer must add a comment whose entire body is:
467
-
468
- ```text
469
- /beta
470
- ```
471
-
472
- The request authorizes only the pull request head SHA that existed when the comment was added. The workflow revalidates the owner or maintainer permission and head SHA immediately before publishing. Any new commit requires CI to pass again and a fresh owner or maintainer `/beta` comment. Fork pull requests are supported. Pull requests that change a release-gating workflow cannot be beta-published until those workflow changes land on `main`.
473
-
474
- Beta versions use `<base>-beta.pr<PR number>.sha<12-character SHA>`. The candidate is built in a read-only workflow without npm publishing credentials. The privileged release workflow publishes only the validated immutable package artifact with lifecycle scripts disabled. A notification failure cannot invalidate a successful npm publish.
475
-
476
- When a pull request is merged into `main`, it is automatically published to `beta` only after the required CI and `Package Candidate` succeed for that exact merge commit. Direct pushes to `main` do not publish a candidate.
477
-
478
- Only `npm run release` creates a release tag. Stable `vX.Y.Z` tags publish to npm `latest`; revision/prerelease tags publish to `next`. Neither `beta` nor `next` publishing changes the npm `latest` dist-tag.
479
-
480
- ## Maintainers
481
-
482
- - [rdlabo](https://rdlabo.dev/)
483
- <!-- /rdlabo-docs-omit -->
484
-
485
- <!-- rdlabo-docs-omit -->
486
- ## License
487
-
488
- MIT
489
- <!-- /rdlabo-docs-omit -->