@rdlabo/capacitor-brotherprint 8.2.0 → 8.2.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 +7 -0
- package/dist/esm/index.d.ts +49 -0
- package/dist/esm/index.js +184 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/models.d.ts +2 -0
- package/dist/esm/models.js +10 -0
- package/dist/esm/models.js.map +1 -0
- package/dist/esm/printer.d.ts +9 -0
- package/dist/esm/printer.js +46 -0
- package/dist/esm/printer.js.map +1 -0
- package/dist/plugin.cjs.js +274 -34
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +274 -34
- package/dist/plugin.js.map +1 -1
- package/docs/connection-management.md +151 -0
- package/docs/helper-design.md +42 -0
- package/package.json +4 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Design decisions
|
|
2
|
+
|
|
3
|
+
These helpers extract recurring connection work from label-printing applications.
|
|
4
|
+
They use the plugin bundled in this package and keep the existing native contract.
|
|
5
|
+
|
|
6
|
+
| Observed application work | Shared behavior | Application responsibility |
|
|
7
|
+
| --- | --- | --- |
|
|
8
|
+
| Screens repeat platform and model connection checks | Read the Capacitor platform, filter supported ports and resolve the saved/default connection | Present connection choices |
|
|
9
|
+
| A second scan arrives while the first is running | Serialize helper calls until native completion and listener removal; recover after failure | Choose when to scan and present loading UI |
|
|
10
|
+
| A remembered network printer may have disconnected | Check a matching previous channel and rediscover if unavailable | Supply storage callbacks and decide whether fallback is appropriate |
|
|
11
|
+
| A printer is entered manually rather than discovered | Check an explicit port/address without discovery metadata or fallback | Supply the real model, choose the port and handle unavailable results |
|
|
12
|
+
| Discovery events repeat or use product-name aliases | Collect results and match existing model enums | Choose one printer or cancel the selection |
|
|
13
|
+
| Screens attach listeners and later close | A session owns results, print listeners and a terminal closed state; skip queued native work and discard late results | Create one session per screen, dispose on exit, and check `closed` before showing UI after asynchronous image generation |
|
|
14
|
+
|
|
15
|
+
The distinction between preparation and explicit checking is intentional. A previous
|
|
16
|
+
printer is a convenience that may fall back to discovery. An explicitly chosen address
|
|
17
|
+
is a destination: a failed check must not silently choose a different printer.
|
|
18
|
+
|
|
19
|
+
Actual application code used both short preliminary scans and longer user-requested
|
|
20
|
+
scans, so duration remains an explicit native search option. Fixed JavaScript timers
|
|
21
|
+
are not used to infer SDK completion. Multiple ports can be searched by awaiting one
|
|
22
|
+
helper call after another; no automatic scan schedule or transport inference is added.
|
|
23
|
+
|
|
24
|
+
Selection dialogs, storage implementation, hidden-device lists, analytics, image generation,
|
|
25
|
+
fonts, label layouts and user-facing messages belong to applications. Native SDK
|
|
26
|
+
changes and automatic print retries are not part of these helpers. Existing native
|
|
27
|
+
errors and availability results are preserved rather than reclassified.
|
|
28
|
+
|
|
29
|
+
The tests exercise these connection flows through the built package using Node's
|
|
30
|
+
standard test runner. They do not establish physical printer compatibility or model
|
|
31
|
+
identity from an availability check.
|
|
32
|
+
|
|
33
|
+
`BrotherPrinterSession` is the stateful boundary for a print screen. It shares the
|
|
34
|
+
same native connection queue as the stateless helpers, so creating a new screen
|
|
35
|
+
cannot overlap a previous screen's unfinished discovery. Disposal does not claim
|
|
36
|
+
to abort a native operation: an active search completes and removes its listener;
|
|
37
|
+
an already started print is still awaited. The application does not need its own
|
|
38
|
+
search queue, listener list or cancellation generation counter.
|
|
39
|
+
|
|
40
|
+
Optional session storage owns connection keys and JSON serialization through `get`,
|
|
41
|
+
`set` and `remove` callbacks. Applications supply the store; printer preparation and
|
|
42
|
+
remembering the selected destination do not need separate app persistence code.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rdlabo/capacitor-brotherprint",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "8.2.
|
|
4
|
+
"version": "8.2.1",
|
|
5
5
|
"description": "Capacitor plugin for Brother Print SDK",
|
|
6
6
|
"main": "dist/plugin.cjs.js",
|
|
7
7
|
"module": "dist/esm/index.js",
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
"release": "np --no-tests --no-publish",
|
|
29
29
|
"replace:production": "ts-node -P scripts/tsconfig.json scripts/release -- production",
|
|
30
30
|
"replace:development": "ts-node -P scripts/tsconfig.json scripts/release -- development",
|
|
31
|
-
"prepare": "husky"
|
|
31
|
+
"prepare": "husky",
|
|
32
|
+
"test:types": "tsc -p tsconfig.test.json",
|
|
33
|
+
"test": "npm run build && npm run test:types && node --test tests/printer.test.cjs"
|
|
32
34
|
},
|
|
33
35
|
"author": "Masahiko Sakakibara<sakakibara@rdlabo.jp>",
|
|
34
36
|
"license": "MIT",
|