@rejaul/react-native-printer-kit 0.3.3 → 0.4.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.
@@ -25,16 +25,43 @@ export function requestBluetoothPermission() {
25
25
  }
26
26
 
27
27
  /**
28
- * Get all Bluetooth devices already paired (bonded) with this device.
28
+ * Get the Bluetooth devices already paired (bonded) with this device, best printer
29
+ * matches first. Every device carries a `confidence`. Pass
30
+ * `{ filter: 'LIKELY_PRINTERS' }` to hide devices that do not look like printers
31
+ * (headphones, watches...), or `extraNameKeywords` for a printer with an unusual name.
29
32
  */
30
- export function getBondedBluetoothPrinters() {
31
- return ReactNativePrinterKit.getBondedBluetoothPrinters();
33
+ export function getBondedBluetoothPrinters(params = {}) {
34
+ return ReactNativePrinterKit.getBondedBluetoothPrinters(params);
32
35
  }
33
36
 
34
37
  /**
35
- * Connect to a paired Bluetooth printer by its MAC address. The connection
36
- * survives the app being swiped from Recents, and is reconnected to
37
- * automatically the next time the app starts.
38
+ * USB printers currently plugged in. Needs a phone with USB host (OTG).
39
+ */
40
+ export function getUsbPrinters() {
41
+ return ReactNativePrinterKit.getUsbPrinters();
42
+ }
43
+
44
+ /**
45
+ * Whether the user already granted this app access to that USB printer.
46
+ */
47
+ export function hasUsbPermission(params) {
48
+ return ReactNativePrinterKit.hasUsbPermission(params);
49
+ }
50
+
51
+ /**
52
+ * Shows the system USB permission dialog. Call before `connectPrinter` with
53
+ * `type: 'USB'`. The grant is lost when the app is reinstalled.
54
+ */
55
+ export function requestUsbPermission(params) {
56
+ return ReactNativePrinterKit.requestUsbPermission(params);
57
+ }
58
+
59
+ /**
60
+ * Connect to a printer over Bluetooth (default; paired printer's MAC address),
61
+ * Wi-Fi/LAN (`type: 'NETWORK'`, `address` = IP) or USB (`type: 'USB'` with
62
+ * `vendorId`/`productId`). The connection survives the app being swiped from
63
+ * Recents, and is reconnected to automatically the next time the app starts.
64
+ * Resolves `false` if it could not connect.
38
65
  */
39
66
  export function connectPrinter(params) {
40
67
  return ReactNativePrinterKit.connectPrinter(params);
@@ -61,6 +88,39 @@ export function getConnectedPrinter() {
61
88
  return ReactNativePrinterKit.getConnectedPrinter();
62
89
  }
63
90
 
91
+ /**
92
+ * Whether a printer is connected and currently accepts data. Does not check
93
+ * paper or cover - use `getPrinterStatus()`.
94
+ */
95
+ export function isPrinterReady() {
96
+ return ReactNativePrinterKit.isPrinterReady();
97
+ }
98
+
99
+ /**
100
+ * Asks the printer for its state (online / paper out / cover open / error).
101
+ * Many printers do not answer: then `responded` is `false` and the other fields
102
+ * are `null` (unknown, not "ok"). Some printers report an open cover as
103
+ * `paperOut`, so treat `paperOut: true` as "no paper or cover open".
104
+ */
105
+ export function getPrinterStatus(params = {}) {
106
+ return ReactNativePrinterKit.getPrinterStatus(params);
107
+ }
108
+
109
+ /**
110
+ * Prints a short ASCII test page.
111
+ */
112
+ export function printTestPage() {
113
+ return ReactNativePrinterKit.printTestPage();
114
+ }
115
+
116
+ /**
117
+ * Copies a file (e.g. the PDF from `htmlToPdf`) to cache, app storage, public
118
+ * Downloads/Documents or a chosen folder. Never rejects: check `result.success`.
119
+ */
120
+ export function saveFile(params) {
121
+ return ReactNativePrinterKit.saveFile(params);
122
+ }
123
+
64
124
  /**
65
125
  * Print raw text using the printer's built-in font (ASCII only - use
66
126
  * printHtml() for Bangla or other non-Latin scripts).
@@ -114,6 +174,19 @@ export function printHtml(params) {
114
174
  return ReactNativePrinterKit.printHtml(params);
115
175
  }
116
176
 
177
+ /**
178
+ * Opens a file with whatever app the user has installed that can handle its
179
+ * type (e.g. a PDF viewer) - shows the system's "Open with" chooser if more
180
+ * than one app matches. Returns false if the file doesn't exist or no app
181
+ * can open it.
182
+ */
183
+ export function openFile(params) {
184
+ return ReactNativePrinterKit.openFile(params);
185
+ }
186
+
187
+ // Export enum-like constants (usable at runtime, and as types of the same name)
188
+ export { FileLocation, PrinterConfidence, PrinterConnectionType, PrinterFilter, PrinterImageType } from "./enums.js";
189
+
117
190
  // Export types
118
191
 
119
192
  // Export native module
@@ -1 +1 @@
1
- {"version":3,"names":["ReactNativePrinterKit","isBluetoothEnabled","hasBluetoothPermission","requestBluetoothPermission","getBondedBluetoothPrinters","connectPrinter","params","disconnectPrinter","isConnectedPrinter","getConnectedPrinter","printText","printImage","printImageBase64","pdfToImage","printPdf","htmlToPdf","printHtml"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,qBAAqB,MAWrB,kCAA+B;;AAEtC;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAA,EAAY;EAC5C,OAAOD,qBAAqB,CAACC,kBAAkB,CAAC,CAAC;AACnD;;AAEA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CAAA,EAAY;EAChD,OAAOF,qBAAqB,CAACE,sBAAsB,CAAC,CAAC;AACvD;;AAEA;AACA;AACA;AACA,OAAO,SAASC,0BAA0BA,CAAA,EAAqB;EAC7D,OAAOH,qBAAqB,CAACG,0BAA0B,CAAC,CAAC;AAC3D;;AAEA;AACA;AACA;AACA,OAAO,SAASC,0BAA0BA,CAAA,EAA6B;EACrE,OAAOJ,qBAAqB,CAACI,0BAA0B,CAAC,CAAC;AAC3D;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,MAA4B,EAAoB;EAC7E,OAAON,qBAAqB,CAACK,cAAc,CAACC,MAAM,CAAC;AACrD;;AAEA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAAA,EAAkB;EACjD,OAAOP,qBAAqB,CAACO,iBAAiB,CAAC,CAAC;AAClD;;AAEA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAA,EAAqB;EACrD,OAAOR,qBAAqB,CAACQ,kBAAkB,CAAC,CAAC;AACnD;;AAEA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAA,EAA2C;EAC5E,OAAOT,qBAAqB,CAACS,mBAAmB,CAAC,CAAC;AACpD;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAASA,CAACJ,MAAuB,EAAiB;EAChE,OAAON,qBAAqB,CAACU,SAAS,CAACJ,MAAM,CAAC;AAChD;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASK,UAAUA,CAACL,MAAwB,EAAiB;EAClE,OAAON,qBAAqB,CAACW,UAAU,CAACL,MAAM,CAAC;AACjD;;AAEA;AACA;AACA;AACA,OAAO,SAASM,gBAAgBA,CAACN,MAA8B,EAAiB;EAC9E,OAAON,qBAAqB,CAACY,gBAAgB,CAACN,MAAM,CAAC;AACvD;;AAEA;AACA;AACA;AACA,OAAO,SAASO,UAAUA,CAACP,MAAwB,EAAmB;EACpE,OAAON,qBAAqB,CAACa,UAAU,CAACP,MAAM,CAAC;AACjD;;AAEA;AACA;AACA;AACA,OAAO,SAASQ,QAAQA,CAACR,MAAsB,EAAiB;EAC9D,OAAON,qBAAqB,CAACc,QAAQ,CAACR,MAAM,CAAC;AAC/C;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASS,SAASA,CAACT,MAAuB,EAA0B;EACzE,OAAON,qBAAqB,CAACe,SAAS,CAACT,MAAM,CAAC;AAChD;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASU,SAASA,CAACV,MAAuB,EAAoB;EACnE,OAAON,qBAAqB,CAACgB,SAAS,CAACV,MAAM,CAAC;AAChD;;AAEA;;AAcA;AACA,eAAeN,qBAAqB","ignoreList":[]}
1
+ {"version":3,"names":["ReactNativePrinterKit","isBluetoothEnabled","hasBluetoothPermission","requestBluetoothPermission","getBondedBluetoothPrinters","params","getUsbPrinters","hasUsbPermission","requestUsbPermission","connectPrinter","disconnectPrinter","isConnectedPrinter","getConnectedPrinter","isPrinterReady","getPrinterStatus","printTestPage","saveFile","printText","printImage","printImageBase64","pdfToImage","printPdf","htmlToPdf","printHtml","openFile","FileLocation","PrinterConfidence","PrinterConnectionType","PrinterFilter","PrinterImageType"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":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B,QAAQ,CAAChB,MAAM,CAAC;AAC/C;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASiB,SAASA,CAACjB,MAAuB,EAA0B;EACzE,OAAOL,qBAAqB,CAACsB,SAAS,CAACjB,MAAM,CAAC;AAChD;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASkB,SAASA,CAAClB,MAAuB,EAAoB;EACnE,OAAOL,qBAAqB,CAACuB,SAAS,CAAClB,MAAM,CAAC;AAChD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASmB,QAAQA,CAACnB,MAAsB,EAAW;EACxD,OAAOL,qBAAqB,CAACwB,QAAQ,CAACnB,MAAM,CAAC;AAC/C;;AAEA;AACA,SACEoB,YAAY,EACZC,iBAAiB,EACjBC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,QACX,YAAS;;AAEhB;;AAqBA;AACA,eAAe7B,qBAAqB","ignoreList":[]}
@@ -1,11 +1,90 @@
1
1
  import { type TurboModule } from 'react-native';
2
+ /** How sure the library is that a paired Bluetooth device is a printer. */
3
+ export type PrinterConfidence = 'CONFIDENT' | 'LIKELY' | 'UNKNOWN';
4
+ /** `ALL` lists every paired device, `LIKELY_PRINTERS` hides non-printers, `STRICT` keeps only certain ones. */
5
+ export type PrinterFilter = 'ALL' | 'LIKELY_PRINTERS' | 'STRICT';
6
+ export type PrinterConnectionType = 'BLUETOOTH' | 'NETWORK' | 'USB';
2
7
  export type BluetoothPrinterDevice = {
8
+ /** `null` for a Wi-Fi/LAN printer. */
3
9
  name: string | null;
10
+ /** Bluetooth MAC, the host for a Wi-Fi/LAN printer, or `"vendorId:productId"` for a USB printer. */
4
11
  address: string;
12
+ confidence: PrinterConfidence;
13
+ /** Why it got that confidence, e.g. "Printer-like name + SPP service". May be `null`. */
14
+ reason: string | null;
15
+ };
16
+ export type GetBondedPrintersParams = {
17
+ filter?: PrinterFilter;
18
+ /** Extra name fragments to treat as printers, for printers with unusual names. */
19
+ extraNameKeywords?: string[];
20
+ };
21
+ export type UsbPrinterDevice = {
22
+ name: string | null;
23
+ vendorId: number;
24
+ productId: number;
25
+ deviceName: string;
26
+ };
27
+ export type UsbDeviceParams = {
28
+ vendorId: number;
29
+ productId: number;
5
30
  };
6
31
  export type PrinterImageType = 'PNG' | 'JPEG';
7
32
  export type ConnectPrinterParams = {
33
+ /** Bluetooth MAC address, or the IP/host for `NETWORK`. Ignored (use `""`) for `USB`. */
8
34
  address: string;
35
+ /** Default `BLUETOOTH`. */
36
+ type?: PrinterConnectionType;
37
+ /** `NETWORK` only. Default 9100. */
38
+ port?: number;
39
+ /** `NETWORK` connect timeout in ms. Default 5000. */
40
+ timeoutMs?: number;
41
+ /** `USB` only, from `getUsbPrinters()`. */
42
+ vendorId?: number;
43
+ /** `USB` only, from `getUsbPrinters()`. */
44
+ productId?: number;
45
+ /** Title of the ongoing "connected" notification. Default "Printer connected". */
46
+ notificationTitle?: string;
47
+ /** Title of the notification shown if the printer drops later. Default "Printer disconnected". */
48
+ disconnectedNotificationTitle?: string;
49
+ };
50
+ export type PrinterStatusParams = {
51
+ /** How long to wait for the printer to answer, in ms. Default 800. */
52
+ timeoutMs?: number;
53
+ };
54
+ /**
55
+ * `null` means "unknown" - the printer did not answer or does not report that condition. It is NOT "ok".
56
+ */
57
+ export type PrinterStatus = {
58
+ connected: boolean;
59
+ /** `false` means the printer ignored the status request and every field below is `null`. */
60
+ responded: boolean;
61
+ online: boolean | null;
62
+ paperOut: boolean | null;
63
+ paperNearEnd: boolean | null;
64
+ coverOpen: boolean | null;
65
+ hasError: boolean | null;
66
+ };
67
+ export type FileLocation = 'CACHE' | 'APP_FILES' | 'DOWNLOADS' | 'DOCUMENTS' | 'CUSTOM_FOLDER';
68
+ export type SaveFileParams = {
69
+ sourcePath: string;
70
+ /** Defaults to the source file's name. */
71
+ fileName?: string;
72
+ /** Default `DOWNLOADS`. */
73
+ location?: FileLocation;
74
+ /** Required for `CUSTOM_FOLDER`: a `content://` tree Uri string or a directory path. */
75
+ customFolder?: string;
76
+ subFolder?: string;
77
+ /** Guessed from the file extension when not given. */
78
+ mimeType?: string;
79
+ overwrite?: boolean;
80
+ deleteSource?: boolean;
81
+ };
82
+ export type SaveFileResult = {
83
+ success: boolean;
84
+ path: string | null;
85
+ uri: string | null;
86
+ fileName: string | null;
87
+ error: string | null;
9
88
  };
10
89
  export type PrintTextParams = {
11
90
  text: string;
@@ -62,6 +141,11 @@ export type PrintHtmlParams = {
62
141
  /** See PrintImageParams.bandDelayMs. */
63
142
  bandDelayMs?: number;
64
143
  };
144
+ export type OpenFileParams = {
145
+ path: string;
146
+ /** Inferred from the file extension if not given. */
147
+ mimeType?: string;
148
+ };
65
149
  export interface Spec extends TurboModule {
66
150
  /**
67
151
  * Whether the device's Bluetooth adapter itself is turned on. Needs no runtime
@@ -80,15 +164,29 @@ export interface Spec extends TurboModule {
80
164
  */
81
165
  requestBluetoothPermission(): Promise<boolean>;
82
166
  /**
83
- * Returns all Bluetooth devices already paired (bonded) with this device.
167
+ * Returns the Bluetooth devices already paired (bonded) with this device, best printer matches first.
84
168
  * On Android 12+ this requires the BLUETOOTH_CONNECT permission to be granted.
169
+ * Pass `{}` for every paired device, or `{ filter: 'LIKELY_PRINTERS' }` to hide non-printers.
170
+ */
171
+ getBondedBluetoothPrinters(params: GetBondedPrintersParams): BluetoothPrinterDevice[];
172
+ /**
173
+ * USB printers currently plugged in (USB printer class). Needs a phone with USB host (OTG).
174
+ */
175
+ getUsbPrinters(): UsbPrinterDevice[];
176
+ /**
177
+ * Whether the user already granted this app access to that USB printer.
85
178
  */
86
- getBondedBluetoothPrinters(): BluetoothPrinterDevice[];
179
+ hasUsbPermission(params: UsbDeviceParams): boolean;
87
180
  /**
88
- * Opens a Bluetooth SPP connection to the paired printer at the given address.
89
- * Closes any existing printer connection first. Remembers the address so the
181
+ * Shows the system USB permission dialog and resolves with the user's answer.
182
+ * Call this before `connectPrinter` with `type: 'USB'`. The grant is lost when the app is reinstalled.
183
+ */
184
+ requestUsbPermission(params: UsbDeviceParams): Promise<boolean>;
185
+ /**
186
+ * Connects over Bluetooth (default), Wi-Fi/LAN or USB depending on `params.type`.
187
+ * Closes any existing printer connection first. Remembers the printer so the
90
188
  * app reconnects automatically next time it's opened (see the README's
91
- * "Persistent connection" section).
189
+ * "Persistent connection" section). Resolves `false` (does not reject) if it could not connect.
92
190
  */
93
191
  connectPrinter(params: ConnectPrinterParams): Promise<boolean>;
94
192
  /**
@@ -103,6 +201,25 @@ export interface Spec extends TurboModule {
103
201
  * Get the currently connected printer, if any.
104
202
  */
105
203
  getConnectedPrinter(): Promise<BluetoothPrinterDevice | null>;
204
+ /**
205
+ * Whether a printer is connected AND currently accepts data (it may be switched off or out of range).
206
+ * Does not check paper or the cover - use `getPrinterStatus` for that.
207
+ */
208
+ isPrinterReady(): Promise<boolean>;
209
+ /**
210
+ * Asks the printer for its state (online, paper, cover, error). Many cheap printers do not answer:
211
+ * then `responded` is `false` and every other field is `null` (unknown, NOT ok).
212
+ */
213
+ getPrinterStatus(params: PrinterStatusParams): Promise<PrinterStatus>;
214
+ /**
215
+ * Prints a short ASCII test page (connection type, printer, address, time).
216
+ */
217
+ printTestPage(): Promise<void>;
218
+ /**
219
+ * Copies a finished file (e.g. the PDF from `htmlToPdf`) to cache, app storage, public
220
+ * Downloads/Documents or a chosen folder. Never rejects: check `result.success`.
221
+ */
222
+ saveFile(params: SaveFileParams): Promise<SaveFileResult>;
106
223
  /**
107
224
  * Print raw text using the printer's built-in font. ASCII only - not
108
225
  * suitable for Bangla or other non-Latin scripts, use printHtml() instead.
@@ -144,6 +261,13 @@ export interface Spec extends TurboModule {
144
261
  * content with Bangla or other non-Latin text, or any real HTML/CSS layout.
145
262
  */
146
263
  printHtml(params: PrintHtmlParams): Promise<boolean>;
264
+ /**
265
+ * Opens a file with whatever app the user has installed that can handle its
266
+ * type (e.g. a PDF viewer) - shows the system's "Open with" chooser if more
267
+ * than one app matches. `mimeType` is inferred from the file extension if
268
+ * not given. Returns false if the file doesn't exist or no app can open it.
269
+ */
270
+ openFile(params: OpenFileParams): boolean;
147
271
  }
148
272
  declare const _default: Spec;
149
273
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"NativeReactNativePrinterKit.d.ts","sourceRoot":"","sources":["../../../src/NativeReactNativePrinterKit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,WAAW,EAAY,MAAM,cAAc,CAAC;AAE/E,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,MAAM,CAAC;AAE9C,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kKAAkK;IAClK,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wFAAwF;IACxF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,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;IACH,gBAAgB,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAEtE;;OAEG;IACH,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/B;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAE1D;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElD;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD;;OAEG;IACH,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhE;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEtD;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhD;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAE3D;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAErD;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC;CAC3C;;AAQD,wBAA2B"}
@@ -0,0 +1,34 @@
1
+ /** How sure the library is that a paired Bluetooth device is a printer. */
2
+ export declare const PrinterConfidence: {
3
+ readonly CONFIDENT: "CONFIDENT";
4
+ readonly LIKELY: "LIKELY";
5
+ readonly UNKNOWN: "UNKNOWN";
6
+ };
7
+ export type PrinterConfidence = (typeof PrinterConfidence)[keyof typeof PrinterConfidence];
8
+ /** `ALL` lists every paired device, `LIKELY_PRINTERS` hides non-printers, `STRICT` keeps only certain ones. */
9
+ export declare const PrinterFilter: {
10
+ readonly ALL: "ALL";
11
+ readonly LIKELY_PRINTERS: "LIKELY_PRINTERS";
12
+ readonly STRICT: "STRICT";
13
+ };
14
+ export type PrinterFilter = (typeof PrinterFilter)[keyof typeof PrinterFilter];
15
+ export declare const PrinterConnectionType: {
16
+ readonly BLUETOOTH: "BLUETOOTH";
17
+ readonly NETWORK: "NETWORK";
18
+ readonly USB: "USB";
19
+ };
20
+ export type PrinterConnectionType = (typeof PrinterConnectionType)[keyof typeof PrinterConnectionType];
21
+ export declare const PrinterImageType: {
22
+ readonly PNG: "PNG";
23
+ readonly JPEG: "JPEG";
24
+ };
25
+ export type PrinterImageType = (typeof PrinterImageType)[keyof typeof PrinterImageType];
26
+ export declare const FileLocation: {
27
+ readonly CACHE: "CACHE";
28
+ readonly APP_FILES: "APP_FILES";
29
+ readonly DOWNLOADS: "DOWNLOADS";
30
+ readonly DOCUMENTS: "DOCUMENTS";
31
+ readonly CUSTOM_FOLDER: "CUSTOM_FOLDER";
32
+ };
33
+ export type FileLocation = (typeof FileLocation)[keyof typeof FileLocation];
34
+ //# sourceMappingURL=enums.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../src/enums.ts"],"names":[],"mappings":"AAaA,2EAA2E;AAC3E,eAAO,MAAM,iBAAiB;;;;CAI6C,CAAC;AAC5E,MAAM,MAAM,iBAAiB,GAC3B,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAE7D,+GAA+G;AAC/G,eAAO,MAAM,aAAa;;;;CAIyC,CAAC;AACpE,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE/E,eAAO,MAAM,qBAAqB;;;;CAOjC,CAAC;AACF,MAAM,MAAM,qBAAqB,GAC/B,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,OAAO,qBAAqB,CAAC,CAAC;AAErE,eAAO,MAAM,gBAAgB;;;CAG4C,CAAC;AAC1E,MAAM,MAAM,gBAAgB,GAC1B,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAE3D,eAAO,MAAM,YAAY;;;;;;CAMwC,CAAC;AAClE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import ReactNativePrinterKit, { type BluetoothPrinterDevice, type ConnectPrinterParams, type HtmlToPdfParams, type PdfToImageParams, type PrinterImageType, type PrintHtmlParams, type PrintImageBase64Params, type PrintImageParams, type PrintPdfParams, type PrintTextParams } from './NativeReactNativePrinterKit.js';
1
+ import ReactNativePrinterKit, { type BluetoothPrinterDevice, type ConnectPrinterParams, type GetBondedPrintersParams, type HtmlToPdfParams, type OpenFileParams, type PdfToImageParams, type PrinterStatus, type PrinterStatusParams, type PrintHtmlParams, type PrintImageBase64Params, type PrintImageParams, type PrintPdfParams, type PrintTextParams, type SaveFileParams, type SaveFileResult, type UsbDeviceParams, type UsbPrinterDevice } from './NativeReactNativePrinterKit.js';
2
2
  /**
3
3
  * Whether the device's Bluetooth adapter itself is turned on. Needs no runtime
4
4
  * permission - check this before `hasBluetoothPermission`/`requestBluetoothPermission`.
@@ -13,13 +13,31 @@ export declare function hasBluetoothPermission(): boolean;
13
13
  */
14
14
  export declare function requestBluetoothPermission(): Promise<boolean>;
15
15
  /**
16
- * Get all Bluetooth devices already paired (bonded) with this device.
16
+ * Get the Bluetooth devices already paired (bonded) with this device, best printer
17
+ * matches first. Every device carries a `confidence`. Pass
18
+ * `{ filter: 'LIKELY_PRINTERS' }` to hide devices that do not look like printers
19
+ * (headphones, watches...), or `extraNameKeywords` for a printer with an unusual name.
17
20
  */
18
- export declare function getBondedBluetoothPrinters(): BluetoothPrinterDevice[];
21
+ export declare function getBondedBluetoothPrinters(params?: GetBondedPrintersParams): BluetoothPrinterDevice[];
19
22
  /**
20
- * Connect to a paired Bluetooth printer by its MAC address. The connection
21
- * survives the app being swiped from Recents, and is reconnected to
22
- * automatically the next time the app starts.
23
+ * USB printers currently plugged in. Needs a phone with USB host (OTG).
24
+ */
25
+ export declare function getUsbPrinters(): UsbPrinterDevice[];
26
+ /**
27
+ * Whether the user already granted this app access to that USB printer.
28
+ */
29
+ export declare function hasUsbPermission(params: UsbDeviceParams): boolean;
30
+ /**
31
+ * Shows the system USB permission dialog. Call before `connectPrinter` with
32
+ * `type: 'USB'`. The grant is lost when the app is reinstalled.
33
+ */
34
+ export declare function requestUsbPermission(params: UsbDeviceParams): Promise<boolean>;
35
+ /**
36
+ * Connect to a printer over Bluetooth (default; paired printer's MAC address),
37
+ * Wi-Fi/LAN (`type: 'NETWORK'`, `address` = IP) or USB (`type: 'USB'` with
38
+ * `vendorId`/`productId`). The connection survives the app being swiped from
39
+ * Recents, and is reconnected to automatically the next time the app starts.
40
+ * Resolves `false` if it could not connect.
23
41
  */
24
42
  export declare function connectPrinter(params: ConnectPrinterParams): Promise<boolean>;
25
43
  /**
@@ -34,6 +52,27 @@ export declare function isConnectedPrinter(): Promise<boolean>;
34
52
  * Get the currently connected printer, if any.
35
53
  */
36
54
  export declare function getConnectedPrinter(): Promise<BluetoothPrinterDevice | null>;
55
+ /**
56
+ * Whether a printer is connected and currently accepts data. Does not check
57
+ * paper or cover - use `getPrinterStatus()`.
58
+ */
59
+ export declare function isPrinterReady(): Promise<boolean>;
60
+ /**
61
+ * Asks the printer for its state (online / paper out / cover open / error).
62
+ * Many printers do not answer: then `responded` is `false` and the other fields
63
+ * are `null` (unknown, not "ok"). Some printers report an open cover as
64
+ * `paperOut`, so treat `paperOut: true` as "no paper or cover open".
65
+ */
66
+ export declare function getPrinterStatus(params?: PrinterStatusParams): Promise<PrinterStatus>;
67
+ /**
68
+ * Prints a short ASCII test page.
69
+ */
70
+ export declare function printTestPage(): Promise<void>;
71
+ /**
72
+ * Copies a file (e.g. the PDF from `htmlToPdf`) to cache, app storage, public
73
+ * Downloads/Documents or a chosen folder. Never rejects: check `result.success`.
74
+ */
75
+ export declare function saveFile(params: SaveFileParams): Promise<SaveFileResult>;
37
76
  /**
38
77
  * Print raw text using the printer's built-in font (ASCII only - use
39
78
  * printHtml() for Bangla or other non-Latin scripts).
@@ -66,6 +105,14 @@ export declare function htmlToPdf(params: HtmlToPdfParams): Promise<string | nul
66
105
  * (or other non-Latin) text or any real HTML/CSS layout.
67
106
  */
68
107
  export declare function printHtml(params: PrintHtmlParams): Promise<boolean>;
69
- export type { BluetoothPrinterDevice, ConnectPrinterParams, HtmlToPdfParams, PdfToImageParams, PrinterImageType, PrintHtmlParams, PrintImageBase64Params, PrintImageParams, PrintPdfParams, PrintTextParams, };
108
+ /**
109
+ * Opens a file with whatever app the user has installed that can handle its
110
+ * type (e.g. a PDF viewer) - shows the system's "Open with" chooser if more
111
+ * than one app matches. Returns false if the file doesn't exist or no app
112
+ * can open it.
113
+ */
114
+ export declare function openFile(params: OpenFileParams): boolean;
115
+ export { FileLocation, PrinterConfidence, PrinterConnectionType, PrinterFilter, PrinterImageType, } from './enums.js';
116
+ export type { BluetoothPrinterDevice, ConnectPrinterParams, GetBondedPrintersParams, HtmlToPdfParams, OpenFileParams, PdfToImageParams, PrinterStatus, PrinterStatusParams, PrintHtmlParams, PrintImageBase64Params, PrintImageParams, PrintPdfParams, PrintTextParams, SaveFileParams, SaveFileResult, UsbDeviceParams, UsbPrinterDevice, };
70
117
  export default ReactNativePrinterKit;
71
118
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,EAAE,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK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AAC,MAAM,GAAG,IAAI,CAAC,CAEzE;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAEnE;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAExD;AAGD,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,EACb,gBAAgB,GACjB,MAAM,YAAS,CAAC;AAGjB,YAAY,EACV,sBAAsB,EACtB,oBAAoB,EACpB,uBAAuB,EACvB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,GACjB,CAAC;AAGF,eAAe,qBAAqB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rejaul/react-native-printer-kit",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "description": "Direct Bluetooth POS/thermal (ESC/POS) printer integration for React Native on Android — print raw text, images, PDFs, and full HTML/CSS content including Bangla and other non-Latin scripts.",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",