@hoangnh0099/react-native-sunmi-printer 0.4.1 → 0.6.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/README.md +157 -67
- package/android/build.gradle +6 -1
- package/android/src/main/java/com/sunmiprinter/SunmiPrinterModule.kt +126 -3
- package/android/src/main/java/com/sunmiprinter/SunmiPrinterPackage.kt +1 -1
- package/lib/module/NativeSunmiPrinter.js.map +1 -1
- package/lib/module/index.js +31 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NativeSunmiPrinter.d.ts +6 -0
- package/lib/typescript/src/NativeSunmiPrinter.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +6 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/NativeSunmiPrinter.ts +8 -0
- package/src/index.tsx +49 -1
package/README.md
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@hoangnh0099/react-native-sunmi-printer)
|
|
4
4
|
[](https://github.com/ngxhuyhoang/react-native-sunmi-printer/blob/main/LICENSE)
|
|
5
5
|
[](#supported-devices)
|
|
6
|
-
[](#architecture-support)
|
|
7
7
|
|
|
8
8
|
React Native library for Sunmi built-in printers. Supports Sunmi V2S and newer devices (Android 11+).
|
|
9
9
|
|
|
10
|
-
Built
|
|
10
|
+
Built on the **Sunmi PrinterX SDK**, with first-class support for both the **New Architecture** (TurboModule) and the **Old Architecture** (bridge).
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
@@ -23,6 +23,19 @@ yarn add @hoangnh0099/react-native-sunmi-printer
|
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
26
|
+
## Architecture Support
|
|
27
|
+
|
|
28
|
+
Works out of the box on both architectures — no extra configuration needed:
|
|
29
|
+
|
|
30
|
+
| Architecture | Status | How it works |
|
|
31
|
+
| ------------------------------ | --------- | ------------------------------------------------------------------------------------ |
|
|
32
|
+
| New Architecture (TurboModule) | Supported | Loaded via `TurboModuleRegistry` when `newArchEnabled=true` |
|
|
33
|
+
| Old Architecture (Bridge) | Supported | Falls back to `NativeModules.SunmiPrinter` when the TurboModule proxy is unavailable |
|
|
34
|
+
|
|
35
|
+
The library auto-detects the active architecture at runtime, so the same JS API is used in either case.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
26
39
|
## Usage
|
|
27
40
|
|
|
28
41
|
### Print Text
|
|
@@ -54,9 +67,10 @@ import {
|
|
|
54
67
|
} from '@hoangnh0099/react-native-sunmi-printer';
|
|
55
68
|
|
|
56
69
|
// setPrinterStyle(key, value)
|
|
57
|
-
// Keys: 0=Bold, 1=Underline, 2=AntiWhite, 3=Strikethrough,
|
|
58
|
-
//
|
|
59
|
-
//
|
|
70
|
+
// Keys: 0=Bold, 1=Underline, 2=AntiWhite, 3=Strikethrough, 4=Italic,
|
|
71
|
+
// 5=Invert, 6=RightSpacing(px), 9=LineSpacing(px, currently a no-op — see full table below),
|
|
72
|
+
// 14=DoubleWidth, 15=DoubleHeight
|
|
73
|
+
// Value: 1=Enable, 0=Disable (px keys take the pixel value directly)
|
|
60
74
|
await setPrinterStyle(0, 1); // Bold ON
|
|
61
75
|
await setPrinterStyle(1, 1); // Underline ON
|
|
62
76
|
await printText('Bold & Underlined\n');
|
|
@@ -162,8 +176,10 @@ await exitPrinterBuffer(true); // resolves when printing completes
|
|
|
162
176
|
import { updatePrinterState } from '@hoangnh0099/react-native-sunmi-printer';
|
|
163
177
|
|
|
164
178
|
const state = await updatePrinterState();
|
|
165
|
-
//
|
|
166
|
-
//
|
|
179
|
+
// 0 = ready
|
|
180
|
+
// negative values = errors that block printing (e.g. -1000 = out of paper)
|
|
181
|
+
// positive values = warnings that do not block printing (e.g. 1000 = paper running low)
|
|
182
|
+
// See the full status code table under "Printer Status Codes" in the API Reference below.
|
|
167
183
|
```
|
|
168
184
|
|
|
169
185
|
---
|
|
@@ -173,18 +189,58 @@ const state = await updatePrinterState();
|
|
|
173
189
|
<details>
|
|
174
190
|
<summary><b>Printer Info</b></summary>
|
|
175
191
|
|
|
176
|
-
| Method | Return | Description
|
|
177
|
-
| ---------------------- | ----------------- |
|
|
178
|
-
| `getPrinterSerialNo()` | `Promise<string>` | Printer
|
|
179
|
-
| `getPrinterVersion()` | `Promise<string>` | Firmware version
|
|
180
|
-
| `getPrinterModal()` | `Promise<string>` | Device model
|
|
181
|
-
| `getPrinterPaper()` | `Promise<number>` | Paper width in mm (58 or 80)
|
|
192
|
+
| Method | Return | Description |
|
|
193
|
+
| ---------------------- | ----------------- | --------------------------------------- |
|
|
194
|
+
| `getPrinterSerialNo()` | `Promise<string>` | Printer hardware version no. (see note) |
|
|
195
|
+
| `getPrinterVersion()` | `Promise<string>` | Firmware version |
|
|
196
|
+
| `getPrinterModal()` | `Promise<string>` | Device model |
|
|
197
|
+
| `getPrinterPaper()` | `Promise<number>` | Paper width in mm (58 or 80) |
|
|
182
198
|
| `getPrinterMode()` | `Promise<number>` | Mode (0=thermal, 1=black mark, 2=label) |
|
|
183
|
-
| `getServiceVersion()` | `Promise<string>` |
|
|
184
|
-
| `getFirmwareStatus()` | `Promise<number>` |
|
|
185
|
-
| `updatePrinterState()` | `Promise<number>` | Current printer state
|
|
186
|
-
| `getPrintedLength()` | `Promise<string>` | Print distance since boot
|
|
187
|
-
| `getPrinterFactory()` | `Promise<string>` |
|
|
199
|
+
| `getServiceVersion()` | `Promise<string>` | Same value as `getPrinterVersion()` (see note) |
|
|
200
|
+
| `getFirmwareStatus()` | `Promise<number>` | Not supported by PrinterX SDK — always resolves `0` |
|
|
201
|
+
| `updatePrinterState()` | `Promise<number>` | Current printer state code — see "Printer Status Codes" below |
|
|
202
|
+
| `getPrintedLength()` | `Promise<string>` | Print distance since boot, in mm (same counter as `getPrinterBBMDistance()`) |
|
|
203
|
+
| `getPrinterFactory()` | `Promise<string>` | Static `"SUNMI"` — this library only targets Sunmi hardware, not a live device query |
|
|
204
|
+
|
|
205
|
+
> **Note:** The PrinterX SDK (`com.sunmi:printerx:1.0.20`) has no dedicated serial-number query. `getPrinterSerialNo()` returns `PrinterInfo.ID`, which Sunmi's own SDK reference documents as "printer hardware version no.", not a unique serial number. `getServiceVersion()` and `getPrinterVersion()` both read `PrinterInfo.VERSION` — the SDK does not expose a separate print-service-version field, so the two are currently equivalent.
|
|
206
|
+
|
|
207
|
+
</details>
|
|
208
|
+
|
|
209
|
+
<details>
|
|
210
|
+
<summary><b>Printer Status Codes</b></summary>
|
|
211
|
+
|
|
212
|
+
Codes returned by `updatePrinterState()`. Negative codes are errors (block printing); positive codes are warnings (printing continues). Sourced from the `com.sunmi.printerx.enums.Status` enum in `com.sunmi:printerx:1.0.20` and cross-checked against Sunmi's SDK reference docs.
|
|
213
|
+
|
|
214
|
+
| Code | Constant | Description |
|
|
215
|
+
| ----- | ------------------------ | ----------------------------------------------------------- |
|
|
216
|
+
| 0 | `READY` | The printer is ready for printing. |
|
|
217
|
+
| -1 | `OFFLINE` | The printer is offline / printer failure. |
|
|
218
|
+
| -2 | `COMM` | Printer communication error. |
|
|
219
|
+
| -3 | `UNKNOWN` | Unknown/undocumented state. |
|
|
220
|
+
| -1000 | `ERR_PAPER_OUT` | Printer out of paper. |
|
|
221
|
+
| -1001 | `ERR_PAPER_JAM` | Printer paper jam. |
|
|
222
|
+
| -1002 | `ERR_PAPER_MISMATCH` | Paper mismatch. |
|
|
223
|
+
| -1010 | `ERR_PRINTER_HOT` | Printhead overheated. |
|
|
224
|
+
| -1011 | `ERR_MOTOR_HOT` | Motor overheated. |
|
|
225
|
+
| -1020 | `ERR_COVER` | Paper bin cover open. |
|
|
226
|
+
| -1021 | `ERR_COVER_INCOMPLETE` | Paper bin cover not completely closed. |
|
|
227
|
+
| -1030 | `ERR_CUTTER` | Cutter error (printers with a cutter only). |
|
|
228
|
+
| -1040 | `ERR_CARTRIDGE_LOSS` | Ink cartridge not installed (laser printers only). |
|
|
229
|
+
| -1041 | `ERR_CARTRIDGE_MISMATCH` | Ink cartridge mismatch (laser printers only). |
|
|
230
|
+
| -1042 | `ERR_CARTRIDGE_EMPTY` | Printer ink has run out (laser printers only). |
|
|
231
|
+
| -1050 | `ERR_DUPLEX_LOSS` | Duplex unit not installed (laser printers only). |
|
|
232
|
+
| -1060 | `ERR_CARTON_LOSS` | Paper tray not installed (laser printers only). |
|
|
233
|
+
| -1061 | `ERR_CARTON_MISMATCH` | Paper tray mismatch (laser printers only). |
|
|
234
|
+
| -1062 | `ERR_CARTON_EMPTY` | Paper tray out of paper (laser printers only). |
|
|
235
|
+
| -1070 | `ERR_DRUM_LOSS` | Drum not installed (laser printers only). |
|
|
236
|
+
| -1071 | `ERR_DRUM_MISMATCH` | Drum mismatch (laser printers only). |
|
|
237
|
+
| -1072 | `ERR_DRUM_EMPTY` | Printer drum has run out (laser printers only). |
|
|
238
|
+
| -1080 | `ERR_STEP` | Printer carriage failure (laser printers only). |
|
|
239
|
+
| 1000 | `WARN_THERMAL_PAPER` | Thermal paper running low. |
|
|
240
|
+
| 1001 | `WARN_PICK_PAPER` | Printed paper not removed (devices with a value sensor only). |
|
|
241
|
+
| 1002 | `WARN_STANDARD_PAPER` | Standard paper running low (laser printers only). |
|
|
242
|
+
| 1003 | `WARN_SPECIAL_PAPER` | Special paper running low (laser printers only). |
|
|
243
|
+
| 1010 | `WARN_CARTRIDGE` | Ink running low (laser printers only). |
|
|
188
244
|
|
|
189
245
|
</details>
|
|
190
246
|
|
|
@@ -210,33 +266,35 @@ const state = await updatePrinterState();
|
|
|
210
266
|
|
|
211
267
|
**`setPrinterStyle` Keys:**
|
|
212
268
|
|
|
213
|
-
| Key | Constant
|
|
214
|
-
| --- |
|
|
215
|
-
| 0 | `ENABLE_BOLD`
|
|
216
|
-
| 1 | `ENABLE_UNDERLINE`
|
|
217
|
-
| 2 | `ENABLE_ANTI_WHITE`
|
|
218
|
-
| 3 | `ENABLE_STRIKETHROUGH`
|
|
219
|
-
| 4 | `ENABLE_ITALIC`
|
|
220
|
-
| 5 | `ENABLE_INVERT`
|
|
221
|
-
| 6 | `SET_TEXT_RIGHT_SPACING` | pixels
|
|
222
|
-
| 9 | `SET_LINE_SPACING`
|
|
223
|
-
| 14 | `ENABLE_DOUBLE_WIDTH`
|
|
224
|
-
| 15 | `ENABLE_DOUBLE_HEIGHT`
|
|
269
|
+
| Key | Constant | Values |
|
|
270
|
+
| --- | ------------------------ | ----------- |
|
|
271
|
+
| 0 | `ENABLE_BOLD` | 0=off, 1=on |
|
|
272
|
+
| 1 | `ENABLE_UNDERLINE` | 0=off, 1=on |
|
|
273
|
+
| 2 | `ENABLE_ANTI_WHITE` | 0=off, 1=on |
|
|
274
|
+
| 3 | `ENABLE_STRIKETHROUGH` | 0=off, 1=on |
|
|
275
|
+
| 4 | `ENABLE_ITALIC` | 0=off, 1=on |
|
|
276
|
+
| 5 | `ENABLE_INVERT` | 0=off, 1=on |
|
|
277
|
+
| 6 | `SET_TEXT_RIGHT_SPACING` | pixels |
|
|
278
|
+
| 9 | `SET_LINE_SPACING` | pixels (stored/readable via `getForcedRowHeight()`, but currently has **no effect** on printed output — see note) |
|
|
279
|
+
| 14 | `ENABLE_DOUBLE_WIDTH` | 0=off, 1=on |
|
|
280
|
+
| 15 | `ENABLE_DOUBLE_HEIGHT` | 0=off, 1=on |
|
|
281
|
+
|
|
282
|
+
> **Note:** The underlying PrinterX SDK's `TextStyle` has no line-spacing setter, so key `9` is tracked internally but does not change how text actually prints. Keys 7, 8, and 10–13 are reserved/unused.
|
|
225
283
|
|
|
226
284
|
</details>
|
|
227
285
|
|
|
228
286
|
<details>
|
|
229
287
|
<summary><b>Print Style Query</b></summary>
|
|
230
288
|
|
|
231
|
-
| Method
|
|
232
|
-
|
|
|
233
|
-
| `getForcedDouble()`
|
|
234
|
-
| `isForcedBold()`
|
|
235
|
-
| `isForcedUnderline()`
|
|
236
|
-
| `isForcedAntiWhite()`
|
|
237
|
-
| `getForcedRowHeight()` | `Promise<number>` |
|
|
238
|
-
| `getCurrentFontName()` | `Promise<string>` | Current font name (empty=default)
|
|
239
|
-
| `getPrinterDensity()`
|
|
289
|
+
| Method | Return | Description |
|
|
290
|
+
| ---------------------- | ------------------ | --------------------------------------- |
|
|
291
|
+
| `getForcedDouble()` | `Promise<number>` | 0=none, 1=width, 2=height, 3=both |
|
|
292
|
+
| `isForcedBold()` | `Promise<boolean>` | Whether bold is currently enabled |
|
|
293
|
+
| `isForcedUnderline()` | `Promise<boolean>` | Whether underline is currently enabled |
|
|
294
|
+
| `isForcedAntiWhite()` | `Promise<boolean>` | Whether anti-white is currently enabled |
|
|
295
|
+
| `getForcedRowHeight()` | `Promise<number>` | Last value set via `setPrinterStyle` key 9 (-1=default); stored only, not applied to prints |
|
|
296
|
+
| `getCurrentFontName()` | `Promise<string>` | Current font name (empty=default) |
|
|
297
|
+
| `getPrinterDensity()` | `Promise<number>` | Print density level |
|
|
240
298
|
|
|
241
299
|
</details>
|
|
242
300
|
|
|
@@ -254,12 +312,12 @@ const state = await updatePrinterState();
|
|
|
254
312
|
<details>
|
|
255
313
|
<summary><b>Image</b></summary>
|
|
256
314
|
|
|
257
|
-
| Method | Description
|
|
258
|
-
| --------------------------------- |
|
|
259
|
-
| `printImage(base64)` | Print base64-encoded image
|
|
315
|
+
| Method | Description |
|
|
316
|
+
| --------------------------------- | --------------------------------------------- |
|
|
317
|
+
| `printImage(base64)` | Print base64-encoded image |
|
|
260
318
|
| `printBitmapCustom(base64, type)` | Print with mode (0=binarization, 1=dithering) |
|
|
261
319
|
|
|
262
|
-
>
|
|
320
|
+
> Images wider than the connected printer's paper (384px for 58mm, 576px for 80mm) are automatically scaled down to fit, preserving aspect ratio — the PrinterX SDK does **not** scale bitmaps on its own (`BitmapStyle`'s width/height default to "no scaling"), so without this an oversized image used to print truncated. Auto-fit only applies for the two paper widths this library detects (58mm/80mm); other paper widths print unscaled, same as before. Call `lineWrap()` after printing to feed paper.
|
|
263
321
|
|
|
264
322
|
</details>
|
|
265
323
|
|
|
@@ -268,10 +326,24 @@ const state = await updatePrinterState();
|
|
|
268
326
|
|
|
269
327
|
| Method | Description |
|
|
270
328
|
| ------------------------------------------------------------ | ----------------------------------------------- |
|
|
271
|
-
| `printBarCode(data, symbology, height, width, textPosition)` | Print 1D barcode
|
|
329
|
+
| `printBarCode(data, symbology, height, width, textPosition)` | Print 1D barcode (symbology values below) |
|
|
272
330
|
| `printQRCode(data, moduleSize, errorLevel)` | Print QR code |
|
|
273
331
|
| `print2DCode(data, symbology, moduleSize, errorLevel)` | Print 2D barcode (1=QR, 2=PDF417, 3=DataMatrix) |
|
|
274
332
|
|
|
333
|
+
**`printBarCode` extended symbologies** (beyond the primary 9 listed in [Usage](#print-barcode)), supported by the SDK's composite/add-on barcode formats:
|
|
334
|
+
|
|
335
|
+
| Symbology | Format | Symbology | Format |
|
|
336
|
+
| --------- | -------------------------- | --------- | -------------- |
|
|
337
|
+
| 9 | EAN128 | 16 | UPC-A + 5 |
|
|
338
|
+
| 10 | CODE128 (alternate encoding)| 17 | EAN13 + 5 |
|
|
339
|
+
| 11 | ITF (compressed) | 18 | EAN8 + 2 |
|
|
340
|
+
| 12 | CODE39 (space) | 19 | EAN8 + 5 |
|
|
341
|
+
| 13 | CODE39 (compressed) | 20 | UPC-E + 2 |
|
|
342
|
+
| 14 | EAN13 + 2 | 21 | UPC-E + 5 |
|
|
343
|
+
| 15 | UPC-A + 2 | | |
|
|
344
|
+
|
|
345
|
+
> **Note:** `print2DCode`'s `errorLevel` parameter is only honored for `symbology=1` (QR) and `symbology=2` (PDF417); DataMatrix (`symbology=3`) uses a fixed error-correction level and ignores it.
|
|
346
|
+
|
|
275
347
|
</details>
|
|
276
348
|
|
|
277
349
|
<details>
|
|
@@ -287,13 +359,13 @@ const state = await updatePrinterState();
|
|
|
287
359
|
<details>
|
|
288
360
|
<summary><b>Raw / Paper</b></summary>
|
|
289
361
|
|
|
290
|
-
| Method
|
|
291
|
-
|
|
|
292
|
-
| `sendRAWData(data)`
|
|
293
|
-
| `lineWrap(lines)`
|
|
294
|
-
| `cutPaper()`
|
|
295
|
-
| `autoOutPaper()`
|
|
296
|
-
| `getCutPaperTimes()`
|
|
362
|
+
| Method | Return | Description |
|
|
363
|
+
| ------------------------- | ----------------- | ---------------------------------- |
|
|
364
|
+
| `sendRAWData(data)` | `Promise<void>` | Send raw ESC/POS byte array |
|
|
365
|
+
| `lineWrap(lines)` | `Promise<void>` | Feed paper by N lines |
|
|
366
|
+
| `cutPaper()` | `Promise<void>` | Cut paper (if cutter available) |
|
|
367
|
+
| `autoOutPaper()` | `Promise<void>` | Auto feed paper to tear position |
|
|
368
|
+
| `getCutPaperTimes()` | `Promise<number>` | Get total cutter usage count |
|
|
297
369
|
| `getPrinterBBMDistance()` | `Promise<number>` | Get black mark paper feed distance |
|
|
298
370
|
|
|
299
371
|
</details>
|
|
@@ -301,21 +373,21 @@ const state = await updatePrinterState();
|
|
|
301
373
|
<details>
|
|
302
374
|
<summary><b>Cash Drawer</b></summary>
|
|
303
375
|
|
|
304
|
-
| Method
|
|
305
|
-
|
|
|
306
|
-
| `openDrawer()`
|
|
307
|
-
| `getDrawerStatus()`
|
|
308
|
-
| `getOpenDrawerTimes()` | `Promise<number>` | Total drawer open count
|
|
376
|
+
| Method | Return | Description |
|
|
377
|
+
| ---------------------- | ----------------- | ------------------------------- |
|
|
378
|
+
| `openDrawer()` | `Promise<void>` | Open cash drawer (if available) |
|
|
379
|
+
| `getDrawerStatus()` | `Promise<number>` | Drawer state (0=closed, 1=open) |
|
|
380
|
+
| `getOpenDrawerTimes()` | `Promise<number>` | Total drawer open count |
|
|
309
381
|
|
|
310
382
|
</details>
|
|
311
383
|
|
|
312
384
|
<details>
|
|
313
385
|
<summary><b>Label</b></summary>
|
|
314
386
|
|
|
315
|
-
| Method | Description
|
|
316
|
-
| --------------- |
|
|
387
|
+
| Method | Description |
|
|
388
|
+
| --------------- | -------------------------------------------------------- |
|
|
317
389
|
| `labelLocate()` | Position the next label (set device to Label Mode first) |
|
|
318
|
-
| `labelOutput()` | Output the label to the cutting position
|
|
390
|
+
| `labelOutput()` | Output the label to the cutting position |
|
|
319
391
|
|
|
320
392
|
> **Note:** Enable Label Mode in device settings: Print Settings > Built-in Setting > Printer Mode > Label Mode.
|
|
321
393
|
|
|
@@ -324,14 +396,14 @@ const state = await updatePrinterState();
|
|
|
324
396
|
<details>
|
|
325
397
|
<summary><b>LCD Customer Display</b></summary>
|
|
326
398
|
|
|
327
|
-
| Method
|
|
328
|
-
|
|
|
329
|
-
| `sendLCDCommand(flag)`
|
|
330
|
-
| `sendLCDString(text)`
|
|
331
|
-
| `sendLCDDoubleString(topText, bottomText)` | Display two lines on LCD
|
|
332
|
-
| `sendLCDFillString(text, size, fill)`
|
|
333
|
-
| `sendLCDMultiString(texts, align)`
|
|
334
|
-
| `sendLCDBitmap(base64)`
|
|
399
|
+
| Method | Description |
|
|
400
|
+
| ------------------------------------------ | --------------------------------------------------- |
|
|
401
|
+
| `sendLCDCommand(flag)` | LCD command (1=init, 2=wake, 3=sleep, 4=clear) |
|
|
402
|
+
| `sendLCDString(text)` | Display single-line text on LCD |
|
|
403
|
+
| `sendLCDDoubleString(topText, bottomText)` | Display two lines on LCD |
|
|
404
|
+
| `sendLCDFillString(text, size, fill)` | Display text with custom size (fill=stretch to fit) |
|
|
405
|
+
| `sendLCDMultiString(texts, align)` | Display multi-line text (auto-sized by weight) |
|
|
406
|
+
| `sendLCDBitmap(base64)` | Display image on LCD (max 128x40px) |
|
|
335
407
|
|
|
336
408
|
> Only available on mini-series desktop devices with a customer display (T1mini, T2mini, etc.).
|
|
337
409
|
|
|
@@ -350,6 +422,24 @@ const state = await updatePrinterState();
|
|
|
350
422
|
|
|
351
423
|
</details>
|
|
352
424
|
|
|
425
|
+
<details>
|
|
426
|
+
<summary><b>Global Settings</b></summary>
|
|
427
|
+
|
|
428
|
+
These write to the device's system-level printer settings (not per-print-call state like `setPrinterStyle`), so changes persist across app restarts and overwrite whatever the user configured manually. Requires Sunmi print service version 6.11.23+ (`setPrinterDensity`/`setPrinterFontType`/`setPrinterSpeed`/`setPrinterAlert`/`setPrinterBootAlert`) or 6.6.32+ (`openPrinterSettings`); calls silently no-op on older print service versions.
|
|
429
|
+
|
|
430
|
+
| Method | Return | Description |
|
|
431
|
+
| --------------------------- | ------------------ | -------------------------------------------------------- |
|
|
432
|
+
| `setPrinterDensity(percent)` | `Promise<void>` | Set print density, 70-130 in steps of 5 (e.g. 100) |
|
|
433
|
+
| `setPrinterFontType(fontType)` | `Promise<void>` | Set built-in font (0=Default, 1=SunmiFont1, 2=SunmiFont2, 3=SunmiFont3) |
|
|
434
|
+
| `setPrinterSpeed(speed)` | `Promise<void>` | Set print speed (0=Low, 1=Medium, 2=High) — financial devices only |
|
|
435
|
+
| `setPrinterAlert(enabled)` | `Promise<void>` | Toggle the printer's abnormal-status alert popup |
|
|
436
|
+
| `setPrinterBootAlert(enabled)` | `Promise<void>` | Toggle the printer's boot/power-on alert prompt |
|
|
437
|
+
| `openPrinterSettings(item)` | `Promise<boolean>` | Jump to a system printer settings screen (0=All, 1=Type, 2=Density, 3=Paper, 4=Font); resolves `false` if unsupported or no foreground activity |
|
|
438
|
+
|
|
439
|
+
> **Note:** Added in `com.sunmi:printerx:1.0.20` — not available if you're pinned to an older SDK version. `setPrinterDensity` is not supported on S2LCC devices. `setPrinterSpeed` currently only applies to financial devices.
|
|
440
|
+
|
|
441
|
+
</details>
|
|
442
|
+
|
|
353
443
|
---
|
|
354
444
|
|
|
355
445
|
## Supported Devices
|
package/android/build.gradle
CHANGED
|
@@ -14,6 +14,10 @@ buildscript {
|
|
|
14
14
|
return SunmiPrinter[prop]
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
ext.isNewArchitectureEnabled = {
|
|
18
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.newArchEnabled == "true"
|
|
19
|
+
}
|
|
20
|
+
|
|
17
21
|
repositories {
|
|
18
22
|
google()
|
|
19
23
|
mavenCentral()
|
|
@@ -40,6 +44,7 @@ android {
|
|
|
40
44
|
defaultConfig {
|
|
41
45
|
minSdkVersion getExtOrDefault("minSdkVersion")
|
|
42
46
|
targetSdkVersion getExtOrDefault("targetSdkVersion")
|
|
47
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
buildFeatures {
|
|
@@ -64,5 +69,5 @@ android {
|
|
|
64
69
|
|
|
65
70
|
dependencies {
|
|
66
71
|
implementation "com.facebook.react:react-android"
|
|
67
|
-
implementation "com.sunmi:printerx:1.0.
|
|
72
|
+
implementation "com.sunmi:printerx:1.0.20"
|
|
68
73
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.sunmiprinter
|
|
2
2
|
|
|
3
|
+
import android.graphics.Bitmap
|
|
3
4
|
import android.graphics.BitmapFactory
|
|
4
5
|
import android.util.Base64
|
|
5
6
|
import com.facebook.react.bridge.Promise
|
|
@@ -10,12 +11,17 @@ import com.sunmi.printerx.PrinterSdk.Printer
|
|
|
10
11
|
import com.sunmi.printerx.api.PrintResult
|
|
11
12
|
import com.sunmi.printerx.enums.Align
|
|
12
13
|
import com.sunmi.printerx.enums.Command
|
|
14
|
+
import com.sunmi.printerx.enums.Density
|
|
13
15
|
import com.sunmi.printerx.enums.DividingLine
|
|
14
16
|
import com.sunmi.printerx.enums.ErrorLevel
|
|
17
|
+
import com.sunmi.printerx.enums.FontType
|
|
15
18
|
import com.sunmi.printerx.enums.HumanReadable
|
|
16
19
|
import com.sunmi.printerx.enums.ImageAlgorithm
|
|
17
20
|
import com.sunmi.printerx.enums.PrinterInfo
|
|
18
21
|
import com.sunmi.printerx.enums.PrinterType
|
|
22
|
+
import com.sunmi.printerx.enums.SettingItem
|
|
23
|
+
import com.sunmi.printerx.enums.Speed
|
|
24
|
+
import com.sunmi.printerx.enums.Symbology
|
|
19
25
|
import com.sunmi.printerx.style.BaseStyle
|
|
20
26
|
import com.sunmi.printerx.style.BarcodeStyle
|
|
21
27
|
import com.sunmi.printerx.style.BitmapStyle
|
|
@@ -88,6 +94,28 @@ class SunmiPrinterModule(reactContext: ReactApplicationContext) :
|
|
|
88
94
|
}
|
|
89
95
|
}
|
|
90
96
|
|
|
97
|
+
// The SDK does not auto-scale bitmaps to the paper width (BitmapStyle.setWidth/setHeight
|
|
98
|
+
// default to "No scaling" per the SDK docs) — an image wider than the physical paper prints
|
|
99
|
+
// truncated. Only the two paper widths this library documents (58mm/80mm) are mapped; unknown
|
|
100
|
+
// sizes fall back to the previous unscaled behavior rather than guessing a conversion factor.
|
|
101
|
+
private fun getMaxPrintableWidthPx(p: Printer): Int? {
|
|
102
|
+
return try {
|
|
103
|
+
when (p.queryApi().getInfo(PrinterInfo.PAPER)?.replace("mm", "")?.trim()?.toIntOrNull()) {
|
|
104
|
+
58 -> 384
|
|
105
|
+
80 -> 576
|
|
106
|
+
else -> null
|
|
107
|
+
}
|
|
108
|
+
} catch (e: Exception) {
|
|
109
|
+
null
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private fun fitBitmapStyle(style: BitmapStyle, bitmap: Bitmap, maxWidthPx: Int?): BitmapStyle {
|
|
114
|
+
if (maxWidthPx == null || bitmap.width <= maxWidthPx) return style
|
|
115
|
+
val scaledHeight = (bitmap.height.toDouble() * maxWidthPx / bitmap.width).toInt().coerceAtLeast(1)
|
|
116
|
+
return style.setWidth(maxWidthPx).setHeight(scaledHeight)
|
|
117
|
+
}
|
|
118
|
+
|
|
91
119
|
private fun toAlign(value: Int): Align = when (value) {
|
|
92
120
|
0 -> Align.LEFT
|
|
93
121
|
1 -> Align.CENTER
|
|
@@ -190,7 +218,9 @@ class SunmiPrinterModule(reactContext: ReactApplicationContext) :
|
|
|
190
218
|
override fun updatePrinterState(promise: Promise) {
|
|
191
219
|
val p = getPrinter(promise) ?: return
|
|
192
220
|
try {
|
|
193
|
-
|
|
221
|
+
// Status.code carries the SDK-defined state code; Status.ordinal is just
|
|
222
|
+
// declaration order and does not match any documented value.
|
|
223
|
+
promise.resolve(p.queryApi().status.code)
|
|
194
224
|
} catch (e: Exception) {
|
|
195
225
|
promise.reject("PRINTER_ERROR", e.message, e)
|
|
196
226
|
}
|
|
@@ -362,8 +392,9 @@ class SunmiPrinterModule(reactContext: ReactApplicationContext) :
|
|
|
362
392
|
val p = getPrinter(promise) ?: return
|
|
363
393
|
try {
|
|
364
394
|
val bitmap = decodeBitmap(base64, promise) ?: return
|
|
395
|
+
val maxWidth = getMaxPrintableWidthPx(p)
|
|
365
396
|
p.lineApi()?.run {
|
|
366
|
-
printBitmap(bitmap, BitmapStyle.getStyle().setAlign(currentAlignment))
|
|
397
|
+
printBitmap(bitmap, fitBitmapStyle(BitmapStyle.getStyle().setAlign(currentAlignment), bitmap, maxWidth))
|
|
367
398
|
if (!isTransMode) autoOut()
|
|
368
399
|
}
|
|
369
400
|
promise.resolve(null)
|
|
@@ -381,8 +412,12 @@ class SunmiPrinterModule(reactContext: ReactApplicationContext) :
|
|
|
381
412
|
1 -> ImageAlgorithm.DITHERING
|
|
382
413
|
else -> ImageAlgorithm.BINARIZATION
|
|
383
414
|
}
|
|
415
|
+
val maxWidth = getMaxPrintableWidthPx(p)
|
|
384
416
|
p.lineApi()?.run {
|
|
385
|
-
printBitmap(
|
|
417
|
+
printBitmap(
|
|
418
|
+
bitmap,
|
|
419
|
+
fitBitmapStyle(BitmapStyle.getStyle().setAlign(currentAlignment).setAlgorithm(algorithm), bitmap, maxWidth)
|
|
420
|
+
)
|
|
386
421
|
if (!isTransMode) autoOut()
|
|
387
422
|
}
|
|
388
423
|
promise.resolve(null)
|
|
@@ -480,9 +515,15 @@ class SunmiPrinterModule(reactContext: ReactApplicationContext) :
|
|
|
480
515
|
3 -> HumanReadable.POS_THREE
|
|
481
516
|
else -> HumanReadable.POS_TWO
|
|
482
517
|
}
|
|
518
|
+
val symbol = Symbology.values().find { it.code == symbology.toInt() }
|
|
519
|
+
if (symbol == null) {
|
|
520
|
+
promise.reject("PRINTER_ERROR", "Unsupported barcode symbology: ${symbology.toInt()}")
|
|
521
|
+
return
|
|
522
|
+
}
|
|
483
523
|
p.lineApi()?.run {
|
|
484
524
|
initLine(BaseStyle.getStyle().setAlign(currentAlignment))
|
|
485
525
|
printBarCode(data, BarcodeStyle.getStyle()
|
|
526
|
+
.setSymbology(symbol)
|
|
486
527
|
.setAlign(currentAlignment)
|
|
487
528
|
.setBarHeight(height.toInt())
|
|
488
529
|
.setDotWidth(width.toInt())
|
|
@@ -878,6 +919,88 @@ class SunmiPrinterModule(reactContext: ReactApplicationContext) :
|
|
|
878
919
|
|
|
879
920
|
// endregion
|
|
880
921
|
|
|
922
|
+
// region Global Settings
|
|
923
|
+
|
|
924
|
+
override fun setPrinterDensity(percent: Double, promise: Promise) {
|
|
925
|
+
try {
|
|
926
|
+
val density = Density.values().find { it.name == "P${percent.toInt()}" }
|
|
927
|
+
if (density == null) {
|
|
928
|
+
promise.reject("PRINTER_ERROR", "Unsupported density: ${percent.toInt()} (must be 70-130 in steps of 5)")
|
|
929
|
+
return
|
|
930
|
+
}
|
|
931
|
+
PrinterSdk.getInstance().setSunmiPrinterDensity(reactApplicationContext, density)
|
|
932
|
+
promise.resolve(null)
|
|
933
|
+
} catch (e: Exception) {
|
|
934
|
+
promise.reject("PRINTER_ERROR", e.message, e)
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
override fun setPrinterFontType(fontType: Double, promise: Promise) {
|
|
939
|
+
try {
|
|
940
|
+
val type = FontType.values().getOrNull(fontType.toInt())
|
|
941
|
+
if (type == null) {
|
|
942
|
+
promise.reject("PRINTER_ERROR", "Unsupported font type: ${fontType.toInt()}")
|
|
943
|
+
return
|
|
944
|
+
}
|
|
945
|
+
PrinterSdk.getInstance().setSunmiPrinterFontType(reactApplicationContext, type)
|
|
946
|
+
promise.resolve(null)
|
|
947
|
+
} catch (e: Exception) {
|
|
948
|
+
promise.reject("PRINTER_ERROR", e.message, e)
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
override fun setPrinterSpeed(speed: Double, promise: Promise) {
|
|
953
|
+
try {
|
|
954
|
+
val s = Speed.values().getOrNull(speed.toInt())
|
|
955
|
+
if (s == null) {
|
|
956
|
+
promise.reject("PRINTER_ERROR", "Unsupported speed: ${speed.toInt()}")
|
|
957
|
+
return
|
|
958
|
+
}
|
|
959
|
+
PrinterSdk.getInstance().setSunmiPrinterSpeed(reactApplicationContext, s)
|
|
960
|
+
promise.resolve(null)
|
|
961
|
+
} catch (e: Exception) {
|
|
962
|
+
promise.reject("PRINTER_ERROR", e.message, e)
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
override fun setPrinterAlert(enabled: Boolean, promise: Promise) {
|
|
967
|
+
try {
|
|
968
|
+
PrinterSdk.getInstance().setSunmiPrinterAlert(reactApplicationContext, enabled)
|
|
969
|
+
promise.resolve(null)
|
|
970
|
+
} catch (e: Exception) {
|
|
971
|
+
promise.reject("PRINTER_ERROR", e.message, e)
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
override fun setPrinterBootAlert(enabled: Boolean, promise: Promise) {
|
|
976
|
+
try {
|
|
977
|
+
PrinterSdk.getInstance().setSunmiPrinterBootAlert(reactApplicationContext, enabled)
|
|
978
|
+
promise.resolve(null)
|
|
979
|
+
} catch (e: Exception) {
|
|
980
|
+
promise.reject("PRINTER_ERROR", e.message, e)
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
override fun openPrinterSettings(item: Double, promise: Promise) {
|
|
985
|
+
try {
|
|
986
|
+
val settingItem = SettingItem.values().getOrNull(item.toInt())
|
|
987
|
+
if (settingItem == null) {
|
|
988
|
+
promise.reject("PRINTER_ERROR", "Unsupported setting item: ${item.toInt()}")
|
|
989
|
+
return
|
|
990
|
+
}
|
|
991
|
+
val activity = reactApplicationContext.currentActivity
|
|
992
|
+
if (activity == null) {
|
|
993
|
+
promise.reject("NO_ACTIVITY", "No current activity available")
|
|
994
|
+
return
|
|
995
|
+
}
|
|
996
|
+
promise.resolve(PrinterSdk.getInstance().startSettings(activity, settingItem))
|
|
997
|
+
} catch (e: Exception) {
|
|
998
|
+
promise.reject("PRINTER_ERROR", e.message, e)
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
// endregion
|
|
1003
|
+
|
|
881
1004
|
override fun invalidate() {
|
|
882
1005
|
super.invalidate()
|
|
883
1006
|
PrinterSdk.getInstance().destroy()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeSunmiPrinter.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAA0B,cAAc;
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeSunmiPrinter.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAA0B,cAAc;AA4HpE,eAAeA,mBAAmB,CAACC,YAAY,CAAO,cAAc,CAAC","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { NativeModules } from 'react-native';
|
|
4
|
+
const LINKING_ERROR = `The package '@hoangnh0099/react-native-sunmi-printer' doesn't seem to be linked. Make sure: \n\n` + `- You rebuilt the app after installing the package\n` + `- You are not using Expo Go\n`;
|
|
5
|
+
|
|
6
|
+
// @ts-expect-error global.__turboModuleProxy is set when the New Architecture is on
|
|
7
|
+
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
8
|
+
const SunmiPrinterModule = isTurboModuleEnabled ? require('./NativeSunmiPrinter').default : NativeModules.SunmiPrinter;
|
|
9
|
+
const SunmiPrinter = SunmiPrinterModule ? SunmiPrinterModule : new Proxy({}, {
|
|
10
|
+
get() {
|
|
11
|
+
throw new Error(LINKING_ERROR);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
4
14
|
|
|
5
15
|
// Printer Info
|
|
6
16
|
export function getPrinterSerialNo() {
|
|
@@ -194,4 +204,24 @@ export function exitPrinterBufferWithCallback(commit) {
|
|
|
194
204
|
export function commitPrinterBufferWithCallback() {
|
|
195
205
|
return SunmiPrinter.commitPrinterBufferWithCallback();
|
|
196
206
|
}
|
|
207
|
+
|
|
208
|
+
// Global Settings
|
|
209
|
+
export function setPrinterDensity(percent) {
|
|
210
|
+
return SunmiPrinter.setPrinterDensity(percent);
|
|
211
|
+
}
|
|
212
|
+
export function setPrinterFontType(fontType) {
|
|
213
|
+
return SunmiPrinter.setPrinterFontType(fontType);
|
|
214
|
+
}
|
|
215
|
+
export function setPrinterSpeed(speed) {
|
|
216
|
+
return SunmiPrinter.setPrinterSpeed(speed);
|
|
217
|
+
}
|
|
218
|
+
export function setPrinterAlert(enabled) {
|
|
219
|
+
return SunmiPrinter.setPrinterAlert(enabled);
|
|
220
|
+
}
|
|
221
|
+
export function setPrinterBootAlert(enabled) {
|
|
222
|
+
return SunmiPrinter.setPrinterBootAlert(enabled);
|
|
223
|
+
}
|
|
224
|
+
export function openPrinterSettings(item) {
|
|
225
|
+
return SunmiPrinter.openPrinterSettings(item);
|
|
226
|
+
}
|
|
197
227
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SunmiPrinter","getPrinterSerialNo","getPrinterVersion","getPrinterModal","getPrinterPaper","getPrinterMode","getServiceVersion","getFirmwareStatus","updatePrinterState","getPrintedLength","getPrinterFactory","printerInit","printerSelfChecking","setAlignment","alignment","setFontName","typeface","setFontSize","fontsize","setPrinterStyle","key","value","getForcedDouble","isForcedBold","isForcedUnderline","isForcedAntiWhite","getPrinterDensity","getForcedRowHeight","getCurrentFontName","printText","text","printTextWithFont","printOriginalText","printImage","base64","printBitmapCustom","type","printBarCode","data","symbology","height","width","textposition","printQRCode","modulesize","errorlevel","print2DCode","printColumnsText","texts","widths","aligns","printColumnsString","sendRAWData","lineWrap","lines","cutPaper","getCutPaperTimes","getPrinterBBMDistance","autoOutPaper","openDrawer","getDrawerStatus","getOpenDrawerTimes","labelLocate","labelOutput","sendLCDCommand","flag","sendLCDString","sendLCDDoubleString","topText","bottomText","sendLCDFillString","size","fill","sendLCDMultiString","align","sendLCDBitmap","enterPrinterBuffer","clean","exitPrinterBuffer","commit","commitPrinterBuffer","exitPrinterBufferWithCallback","commitPrinterBufferWithCallback"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"names":["NativeModules","LINKING_ERROR","isTurboModuleEnabled","global","__turboModuleProxy","SunmiPrinterModule","require","default","SunmiPrinter","Proxy","get","Error","getPrinterSerialNo","getPrinterVersion","getPrinterModal","getPrinterPaper","getPrinterMode","getServiceVersion","getFirmwareStatus","updatePrinterState","getPrintedLength","getPrinterFactory","printerInit","printerSelfChecking","setAlignment","alignment","setFontName","typeface","setFontSize","fontsize","setPrinterStyle","key","value","getForcedDouble","isForcedBold","isForcedUnderline","isForcedAntiWhite","getPrinterDensity","getForcedRowHeight","getCurrentFontName","printText","text","printTextWithFont","printOriginalText","printImage","base64","printBitmapCustom","type","printBarCode","data","symbology","height","width","textposition","printQRCode","modulesize","errorlevel","print2DCode","printColumnsText","texts","widths","aligns","printColumnsString","sendRAWData","lineWrap","lines","cutPaper","getCutPaperTimes","getPrinterBBMDistance","autoOutPaper","openDrawer","getDrawerStatus","getOpenDrawerTimes","labelLocate","labelOutput","sendLCDCommand","flag","sendLCDString","sendLCDDoubleString","topText","bottomText","sendLCDFillString","size","fill","sendLCDMultiString","align","sendLCDBitmap","enterPrinterBuffer","clean","exitPrinterBuffer","commit","commitPrinterBuffer","exitPrinterBufferWithCallback","commitPrinterBufferWithCallback","setPrinterDensity","percent","setPrinterFontType","fontType","setPrinterSpeed","speed","setPrinterAlert","enabled","setPrinterBootAlert","openPrinterSettings","item"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,cAAc;AAE5C,MAAMC,aAAa,GACjB,kGAAkG,GAClG,sDAAsD,GACtD,+BAA+B;;AAEjC;AACA,MAAMC,oBAAoB,GAAGC,MAAM,CAACC,kBAAkB,IAAI,IAAI;AAE9D,MAAMC,kBAAkB,GAAGH,oBAAoB,GAC3CI,OAAO,CAAC,sBAAsB,CAAC,CAACC,OAAO,GACvCP,aAAa,CAACQ,YAAY;AAE9B,MAAMA,YAAY,GAAGH,kBAAkB,GACnCA,kBAAkB,GAClB,IAAII,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACV,aAAa,CAAC;EAChC;AACF,CACF,CAAC;;AAEL;AACA,OAAO,SAASW,kBAAkBA,CAAA,EAAoB;EACpD,OAAOJ,YAAY,CAACI,kBAAkB,CAAC,CAAC;AAC1C;AAEA,OAAO,SAASC,iBAAiBA,CAAA,EAAoB;EACnD,OAAOL,YAAY,CAACK,iBAAiB,CAAC,CAAC;AACzC;AAEA,OAAO,SAASC,eAAeA,CAAA,EAAoB;EACjD,OAAON,YAAY,CAACM,eAAe,CAAC,CAAC;AACvC;AAEA,OAAO,SAASC,eAAeA,CAAA,EAAoB;EACjD,OAAOP,YAAY,CAACO,eAAe,CAAC,CAAC;AACvC;AAEA,OAAO,SAASC,cAAcA,CAAA,EAAoB;EAChD,OAAOR,YAAY,CAACQ,cAAc,CAAC,CAAC;AACtC;AAEA,OAAO,SAASC,iBAAiBA,CAAA,EAAoB;EACnD,OAAOT,YAAY,CAACS,iBAAiB,CAAC,CAAC;AACzC;AAEA,OAAO,SAASC,iBAAiBA,CAAA,EAAoB;EACnD,OAAOV,YAAY,CAACU,iBAAiB,CAAC,CAAC;AACzC;AAEA,OAAO,SAASC,kBAAkBA,CAAA,EAAoB;EACpD,OAAO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OAAOhF,YAAY,CAAC+E,kBAAkB,CAACC,KAAK,CAAC;AAC/C;AAEA,OAAO,SAASC,iBAAiBA,CAACC,MAAe,EAAiB;EAChE,OAAOlF,YAAY,CAACiF,iBAAiB,CAACC,MAAM,CAAC;AAC/C;AAEA,OAAO,SAASC,mBAAmBA,CAAA,EAAkB;EACnD,OAAOnF,YAAY,CAACmF,mBAAmB,CAAC,CAAC;AAC3C;AAEA,OAAO,SAASC,6BAA6BA,CAACF,MAAe,EAAiB;EAC5E,OAAOlF,YAAY,CAACoF,6BAA6B,CAACF,MAAM,CAAC;AAC3D;AAEA,OAAO,SAASG,+BAA+BA,CAAA,EAAkB;EAC/D,OAAOrF,YAAY,CAACqF,+BAA+B,CAAC,CAAC;AACvD;;AAEA;AACA,OAAO,SAASC,iBAAiBA,CAACC,OAAe,EAAiB;EAChE,OAAOvF,YAAY,CAACsF,iBAAiB,CAACC,OAAO,CAAC;AAChD;AAEA,OAAO,SAASC,kBAAkBA,CAACC,QAAgB,EAAiB;EAClE,OAAOzF,YAAY,CAACwF,kBAAkB,CAACC,QAAQ,CAAC;AAClD;AAEA,OAAO,SAASC,eAAeA,CAACC,KAAa,EAAiB;EAC5D,OAAO3F,YAAY,CAAC0F,eAAe,CAACC,KAAK,CAAC;AAC5C;AAEA,OAAO,SAASC,eAAeA,CAACC,OAAgB,EAAiB;EAC/D,OAAO7F,YAAY,CAAC4F,eAAe,CAACC,OAAO,CAAC;AAC9C;AAEA,OAAO,SAASC,mBAAmBA,CAACD,OAAgB,EAAiB;EACnE,OAAO7F,YAAY,CAAC8F,mBAAmB,CAACD,OAAO,CAAC;AAClD;AAEA,OAAO,SAASE,mBAAmBA,CAACC,IAAY,EAAoB;EAClE,OAAOhG,YAAY,CAAC+F,mBAAmB,CAACC,IAAI,CAAC;AAC/C","ignoreList":[]}
|
|
@@ -55,6 +55,12 @@ export interface Spec extends TurboModule {
|
|
|
55
55
|
commitPrinterBuffer(): Promise<void>;
|
|
56
56
|
exitPrinterBufferWithCallback(commit: boolean): Promise<void>;
|
|
57
57
|
commitPrinterBufferWithCallback(): Promise<void>;
|
|
58
|
+
setPrinterDensity(percent: number): Promise<void>;
|
|
59
|
+
setPrinterFontType(fontType: number): Promise<void>;
|
|
60
|
+
setPrinterSpeed(speed: number): Promise<void>;
|
|
61
|
+
setPrinterAlert(enabled: boolean): Promise<void>;
|
|
62
|
+
setPrinterBootAlert(enabled: boolean): Promise<void>;
|
|
63
|
+
openPrinterSettings(item: number): Promise<boolean>;
|
|
58
64
|
}
|
|
59
65
|
declare const _default: Spec;
|
|
60
66
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeSunmiPrinter.d.ts","sourceRoot":"","sources":["../../../src/NativeSunmiPrinter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAErE,MAAM,WAAW,IAAK,SAAQ,WAAW;IAEvC,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACtC,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACrC,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACrC,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACrC,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACtC,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACpC,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAGrC,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAGrC,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,O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,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACrD;;AAED,wBAAsE"}
|
|
@@ -53,4 +53,10 @@ export declare function exitPrinterBuffer(commit: boolean): Promise<void>;
|
|
|
53
53
|
export declare function commitPrinterBuffer(): Promise<void>;
|
|
54
54
|
export declare function exitPrinterBufferWithCallback(commit: boolean): Promise<void>;
|
|
55
55
|
export declare function commitPrinterBufferWithCallback(): Promise<void>;
|
|
56
|
+
export declare function setPrinterDensity(percent: number): Promise<void>;
|
|
57
|
+
export declare function setPrinterFontType(fontType: number): Promise<void>;
|
|
58
|
+
export declare function setPrinterSpeed(speed: number): Promise<void>;
|
|
59
|
+
export declare function setPrinterAlert(enabled: boolean): Promise<void>;
|
|
60
|
+
export declare function setPrinterBootAlert(enabled: boolean): Promise<void>;
|
|
61
|
+
export declare function openPrinterSettings(item: number): Promise<boolean>;
|
|
56
62
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AA0BA,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CAEpD;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CA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AAE,MAAM,EAAE,EACf,KAAK,EAAE,MAAM,EAAE,GACd,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3D;AAGD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhE;AAED,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEnD;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5E;AAED,wBAAgB,+BAA+B,IAAI,OAAO,CAAC,IAAI,CAAC,CAE/D;AAGD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhE;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAElE;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5D;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/D;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnE;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAElE"}
|
package/package.json
CHANGED
|
@@ -112,6 +112,14 @@ export interface Spec extends TurboModule {
|
|
|
112
112
|
commitPrinterBuffer(): Promise<void>;
|
|
113
113
|
exitPrinterBufferWithCallback(commit: boolean): Promise<void>;
|
|
114
114
|
commitPrinterBufferWithCallback(): Promise<void>;
|
|
115
|
+
|
|
116
|
+
// Global Settings
|
|
117
|
+
setPrinterDensity(percent: number): Promise<void>;
|
|
118
|
+
setPrinterFontType(fontType: number): Promise<void>;
|
|
119
|
+
setPrinterSpeed(speed: number): Promise<void>;
|
|
120
|
+
setPrinterAlert(enabled: boolean): Promise<void>;
|
|
121
|
+
setPrinterBootAlert(enabled: boolean): Promise<void>;
|
|
122
|
+
openPrinterSettings(item: number): Promise<boolean>;
|
|
115
123
|
}
|
|
116
124
|
|
|
117
125
|
export default TurboModuleRegistry.getEnforcing<Spec>('SunmiPrinter');
|
package/src/index.tsx
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { NativeModules } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const LINKING_ERROR =
|
|
4
|
+
`The package '@hoangnh0099/react-native-sunmi-printer' doesn't seem to be linked. Make sure: \n\n` +
|
|
5
|
+
`- You rebuilt the app after installing the package\n` +
|
|
6
|
+
`- You are not using Expo Go\n`;
|
|
7
|
+
|
|
8
|
+
// @ts-expect-error global.__turboModuleProxy is set when the New Architecture is on
|
|
9
|
+
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
10
|
+
|
|
11
|
+
const SunmiPrinterModule = isTurboModuleEnabled
|
|
12
|
+
? require('./NativeSunmiPrinter').default
|
|
13
|
+
: NativeModules.SunmiPrinter;
|
|
14
|
+
|
|
15
|
+
const SunmiPrinter = SunmiPrinterModule
|
|
16
|
+
? SunmiPrinterModule
|
|
17
|
+
: new Proxy(
|
|
18
|
+
{},
|
|
19
|
+
{
|
|
20
|
+
get() {
|
|
21
|
+
throw new Error(LINKING_ERROR);
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
);
|
|
2
25
|
|
|
3
26
|
// Printer Info
|
|
4
27
|
export function getPrinterSerialNo(): Promise<string> {
|
|
@@ -276,3 +299,28 @@ export function exitPrinterBufferWithCallback(commit: boolean): Promise<void> {
|
|
|
276
299
|
export function commitPrinterBufferWithCallback(): Promise<void> {
|
|
277
300
|
return SunmiPrinter.commitPrinterBufferWithCallback();
|
|
278
301
|
}
|
|
302
|
+
|
|
303
|
+
// Global Settings
|
|
304
|
+
export function setPrinterDensity(percent: number): Promise<void> {
|
|
305
|
+
return SunmiPrinter.setPrinterDensity(percent);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export function setPrinterFontType(fontType: number): Promise<void> {
|
|
309
|
+
return SunmiPrinter.setPrinterFontType(fontType);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export function setPrinterSpeed(speed: number): Promise<void> {
|
|
313
|
+
return SunmiPrinter.setPrinterSpeed(speed);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export function setPrinterAlert(enabled: boolean): Promise<void> {
|
|
317
|
+
return SunmiPrinter.setPrinterAlert(enabled);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export function setPrinterBootAlert(enabled: boolean): Promise<void> {
|
|
321
|
+
return SunmiPrinter.setPrinterBootAlert(enabled);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export function openPrinterSettings(item: number): Promise<boolean> {
|
|
325
|
+
return SunmiPrinter.openPrinterSettings(item);
|
|
326
|
+
}
|