@rejaul/react-native-printer-kit 0.3.4 → 0.4.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 +293 -14
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/rejaul/reactnativeprinterkit/ReactNativePrinterKitModule.kt +267 -31
- package/lib/module/NativeReactNativePrinterKit.js +19 -0
- package/lib/module/NativeReactNativePrinterKit.js.map +1 -1
- package/lib/module/enums.js +45 -0
- package/lib/module/enums.js.map +1 -0
- package/lib/module/index.js +107 -6
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NativeReactNativePrinterKit.d.ts +241 -5
- package/lib/typescript/src/NativeReactNativePrinterKit.d.ts.map +1 -1
- package/lib/typescript/src/enums.d.ts +44 -0
- package/lib/typescript/src/enums.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +73 -7
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/NativeReactNativePrinterKit.ts +280 -5
- package/src/enums.ts +69 -0
- package/src/index.tsx +155 -9
|
@@ -1,11 +1,102 @@
|
|
|
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
|
+
/**
|
|
68
|
+
* `PICTURES` is the public Pictures folder, so the image also shows in the Gallery app; it accepts images
|
|
69
|
+
* only (a `.png`/`.jpg` file name or an `image/...` `mimeType`) and refuses anything else.
|
|
70
|
+
*/
|
|
71
|
+
export type FileLocation = 'CACHE' | 'APP_FILES' | 'DOWNLOADS' | 'DOCUMENTS' | 'PICTURES' | 'CUSTOM_FOLDER';
|
|
72
|
+
export type SaveFileParams = {
|
|
73
|
+
/** Path of an existing file to copy. Give exactly one of `sourcePath`, `text` or `base64`. */
|
|
74
|
+
sourcePath?: string;
|
|
75
|
+
/** Content to save as UTF-8 text, instead of `sourcePath`. Needs `fileName`. */
|
|
76
|
+
text?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Content to save as bytes (base64 encoded; a `data:...;base64,` prefix is fine), instead of
|
|
79
|
+
* `sourcePath`. Needs `fileName`. Use it for images, PDFs and other binary data.
|
|
80
|
+
*/
|
|
81
|
+
base64?: string;
|
|
82
|
+
/** Defaults to the source file's name. Required with `text` or `base64`. */
|
|
83
|
+
fileName?: string;
|
|
84
|
+
/** Default `DOWNLOADS`. */
|
|
85
|
+
location?: FileLocation;
|
|
86
|
+
/** Required for `CUSTOM_FOLDER`: a `content://` tree Uri string or a directory path. */
|
|
87
|
+
customFolder?: string;
|
|
88
|
+
subFolder?: string;
|
|
89
|
+
/** Guessed from the file extension when not given. */
|
|
90
|
+
mimeType?: string;
|
|
91
|
+
overwrite?: boolean;
|
|
92
|
+
deleteSource?: boolean;
|
|
93
|
+
};
|
|
94
|
+
export type SaveFileResult = {
|
|
95
|
+
success: boolean;
|
|
96
|
+
path: string | null;
|
|
97
|
+
uri: string | null;
|
|
98
|
+
fileName: string | null;
|
|
99
|
+
error: string | null;
|
|
9
100
|
};
|
|
10
101
|
export type PrintTextParams = {
|
|
11
102
|
text: string;
|
|
@@ -47,6 +138,15 @@ export type PrintPdfParams = {
|
|
|
47
138
|
};
|
|
48
139
|
export type HtmlToPdfParams = {
|
|
49
140
|
html: string;
|
|
141
|
+
/**
|
|
142
|
+
* Full path of the PDF to write, file name included (e.g.
|
|
143
|
+
* `/data/user/0/<your.app>/files/invoice.pdf`). Leave it out to get a fresh file with a
|
|
144
|
+
* generated name in the app's cache folder. The folder must already exist and be one the
|
|
145
|
+
* app may write to (its own files/cache folders); an existing file is overwritten. To put
|
|
146
|
+
* the PDF in a public folder such as Downloads, convert first and then call `saveFile`.
|
|
147
|
+
* The path that was written is returned.
|
|
148
|
+
*/
|
|
149
|
+
outputPath?: string;
|
|
50
150
|
pageWidthDp?: number;
|
|
51
151
|
heightDp?: number;
|
|
52
152
|
minPageHeightDp?: number;
|
|
@@ -62,6 +162,84 @@ export type PrintHtmlParams = {
|
|
|
62
162
|
/** See PrintImageParams.bandDelayMs. */
|
|
63
163
|
bandDelayMs?: number;
|
|
64
164
|
};
|
|
165
|
+
export type RemoveFileParams = {
|
|
166
|
+
/**
|
|
167
|
+
* What to delete: an absolute file path, or the `content://` Uri that `saveFile` returned (for
|
|
168
|
+
* a file in Downloads/Documents on Android 10+, which only works for files your app created).
|
|
169
|
+
*/
|
|
170
|
+
path: string;
|
|
171
|
+
};
|
|
172
|
+
export type RemoveFileResult = {
|
|
173
|
+
success: boolean;
|
|
174
|
+
path: string | null;
|
|
175
|
+
uri: string | null;
|
|
176
|
+
fileName: string | null;
|
|
177
|
+
error: string | null;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* The shape `readFile` returns the content in: `base64` (plain), `dataUri` (`data:<type>;base64,...`), `text`
|
|
181
|
+
* (decoded string), `hex` (two lower-case digits per byte) or `bytes` (array of numbers 0..255, max 1 MB).
|
|
182
|
+
*/
|
|
183
|
+
export type ReadFileFormat = 'base64' | 'dataUri' | 'text' | 'hex' | 'bytes';
|
|
184
|
+
export type ReadFileParams = {
|
|
185
|
+
/** An absolute file path, or the `content://` Uri that `saveFile` returned. */
|
|
186
|
+
path: string;
|
|
187
|
+
/** Default `base64`. */
|
|
188
|
+
format?: ReadFileFormat;
|
|
189
|
+
/** Only for `text`: `UTF-8` (default), `UTF-16`, `ISO-8859-1`, ... */
|
|
190
|
+
encoding?: string;
|
|
191
|
+
/** Files bigger than this are refused instead of loaded. Default 10 MB; `bytes` is always capped at 1 MB. */
|
|
192
|
+
maxBytes?: number;
|
|
193
|
+
};
|
|
194
|
+
export type ReadFileResult = {
|
|
195
|
+
success: boolean;
|
|
196
|
+
format: ReadFileFormat | null;
|
|
197
|
+
/** Set for `base64`, `dataUri`, `text` and `hex`. */
|
|
198
|
+
content: string | null;
|
|
199
|
+
/** Set for `bytes`. */
|
|
200
|
+
bytes: number[] | null;
|
|
201
|
+
sizeBytes: number | null;
|
|
202
|
+
/** From the file extension, or the content provider's answer for a Uri. */
|
|
203
|
+
mimeType: string | null;
|
|
204
|
+
error: string | null;
|
|
205
|
+
};
|
|
206
|
+
export type HtmlToImageParams = {
|
|
207
|
+
html: string;
|
|
208
|
+
/** Full path of the image to write, file name included (folder must exist). Default: generated name in the cache folder. */
|
|
209
|
+
outputPath?: string;
|
|
210
|
+
/** Default `PNG`. */
|
|
211
|
+
imageType?: PrinterImageType;
|
|
212
|
+
/** Width of the image in pixels. Default: twice the page width. */
|
|
213
|
+
targetWidthPx?: number;
|
|
214
|
+
pageWidthDp?: number;
|
|
215
|
+
heightDp?: number;
|
|
216
|
+
minPageHeightDp?: number;
|
|
217
|
+
};
|
|
218
|
+
export type ReadDirParams = {
|
|
219
|
+
/**
|
|
220
|
+
* The folder to read: an absolute folder path, or a `content://` Uri of a folder the user picked
|
|
221
|
+
* with the system folder picker (or the `path` of a sub-folder returned by an earlier call).
|
|
222
|
+
*/
|
|
223
|
+
path: string;
|
|
224
|
+
};
|
|
225
|
+
export type DirEntry = {
|
|
226
|
+
name: string;
|
|
227
|
+
/** Pass it to `removeFile` (a file) or to `readDir` again (a folder). */
|
|
228
|
+
path: string;
|
|
229
|
+
isDirectory: boolean;
|
|
230
|
+
/** `null` for a folder. */
|
|
231
|
+
sizeBytes: number | null;
|
|
232
|
+
/** Milliseconds since 1970, `null` if unknown. */
|
|
233
|
+
lastModified: number | null;
|
|
234
|
+
};
|
|
235
|
+
export type ReadDirResult = {
|
|
236
|
+
success: boolean;
|
|
237
|
+
path: string | null;
|
|
238
|
+
/** Just the names, in the same order as `entries`. */
|
|
239
|
+
names: string[];
|
|
240
|
+
entries: DirEntry[];
|
|
241
|
+
error: string | null;
|
|
242
|
+
};
|
|
65
243
|
export type OpenFileParams = {
|
|
66
244
|
path: string;
|
|
67
245
|
/** Inferred from the file extension if not given. */
|
|
@@ -85,15 +263,29 @@ export interface Spec extends TurboModule {
|
|
|
85
263
|
*/
|
|
86
264
|
requestBluetoothPermission(): Promise<boolean>;
|
|
87
265
|
/**
|
|
88
|
-
* Returns
|
|
266
|
+
* Returns the Bluetooth devices already paired (bonded) with this device, best printer matches first.
|
|
89
267
|
* On Android 12+ this requires the BLUETOOTH_CONNECT permission to be granted.
|
|
268
|
+
* Pass `{}` for every paired device, or `{ filter: 'LIKELY_PRINTERS' }` to hide non-printers.
|
|
269
|
+
*/
|
|
270
|
+
getBondedBluetoothPrinters(params: GetBondedPrintersParams): BluetoothPrinterDevice[];
|
|
271
|
+
/**
|
|
272
|
+
* USB printers currently plugged in (USB printer class). Needs a phone with USB host (OTG).
|
|
273
|
+
*/
|
|
274
|
+
getUsbPrinters(): UsbPrinterDevice[];
|
|
275
|
+
/**
|
|
276
|
+
* Whether the user already granted this app access to that USB printer.
|
|
90
277
|
*/
|
|
91
|
-
|
|
278
|
+
hasUsbPermission(params: UsbDeviceParams): boolean;
|
|
92
279
|
/**
|
|
93
|
-
*
|
|
94
|
-
*
|
|
280
|
+
* Shows the system USB permission dialog and resolves with the user's answer.
|
|
281
|
+
* Call this before `connectPrinter` with `type: 'USB'`. The grant is lost when the app is reinstalled.
|
|
282
|
+
*/
|
|
283
|
+
requestUsbPermission(params: UsbDeviceParams): Promise<boolean>;
|
|
284
|
+
/**
|
|
285
|
+
* Connects over Bluetooth (default), Wi-Fi/LAN or USB depending on `params.type`.
|
|
286
|
+
* Closes any existing printer connection first. Remembers the printer so the
|
|
95
287
|
* app reconnects automatically next time it's opened (see the README's
|
|
96
|
-
* "Persistent connection" section).
|
|
288
|
+
* "Persistent connection" section). Resolves `false` (does not reject) if it could not connect.
|
|
97
289
|
*/
|
|
98
290
|
connectPrinter(params: ConnectPrinterParams): Promise<boolean>;
|
|
99
291
|
/**
|
|
@@ -108,6 +300,26 @@ export interface Spec extends TurboModule {
|
|
|
108
300
|
* Get the currently connected printer, if any.
|
|
109
301
|
*/
|
|
110
302
|
getConnectedPrinter(): Promise<BluetoothPrinterDevice | null>;
|
|
303
|
+
/**
|
|
304
|
+
* Whether a printer is connected AND currently accepts data (it may be switched off or out of range).
|
|
305
|
+
* Does not check paper or the cover - use `getPrinterStatus` for that.
|
|
306
|
+
*/
|
|
307
|
+
isPrinterReady(): Promise<boolean>;
|
|
308
|
+
/**
|
|
309
|
+
* Asks the printer for its state (online, paper, cover, error). Many cheap printers do not answer:
|
|
310
|
+
* then `responded` is `false` and every other field is `null` (unknown, NOT ok).
|
|
311
|
+
*/
|
|
312
|
+
getPrinterStatus(params: PrinterStatusParams): Promise<PrinterStatus>;
|
|
313
|
+
/**
|
|
314
|
+
* Prints a short ASCII test page (connection type, printer, address, time).
|
|
315
|
+
*/
|
|
316
|
+
printTestPage(): Promise<void>;
|
|
317
|
+
/**
|
|
318
|
+
* Saves a file to cache, app storage, public Downloads/Documents or a chosen folder: either
|
|
319
|
+
* copies an existing file (`sourcePath`, e.g. the PDF from `htmlToPdf`) or writes content you
|
|
320
|
+
* pass directly (`text` or `base64`, with a `fileName`). Never rejects: check `result.success`.
|
|
321
|
+
*/
|
|
322
|
+
saveFile(params: SaveFileParams): Promise<SaveFileResult>;
|
|
111
323
|
/**
|
|
112
324
|
* Print raw text using the printer's built-in font. ASCII only - not
|
|
113
325
|
* suitable for Bangla or other non-Latin scripts, use printHtml() instead.
|
|
@@ -149,6 +361,30 @@ export interface Spec extends TurboModule {
|
|
|
149
361
|
* content with Bangla or other non-Latin text, or any real HTML/CSS layout.
|
|
150
362
|
*/
|
|
151
363
|
printHtml(params: PrintHtmlParams): Promise<boolean>;
|
|
364
|
+
/**
|
|
365
|
+
* Deletes ONE file (what `saveFile` wrote, or any file your app may delete). Never a folder, never a
|
|
366
|
+
* pattern; cannot be undone. A missing file is reported as a failure ("File not found").
|
|
367
|
+
* Never rejects: check `result.success`.
|
|
368
|
+
*/
|
|
369
|
+
removeFile(params: RemoveFileParams): Promise<RemoveFileResult>;
|
|
370
|
+
/**
|
|
371
|
+
* Reads ONE file and returns its content in the shape `format` asks for (`base64`, `dataUri`, `text`,
|
|
372
|
+
* `hex` or `bytes`). Read-only. A file over `maxBytes` (default 10 MB) is refused instead of loaded.
|
|
373
|
+
* Never rejects: check `result.success`.
|
|
374
|
+
*/
|
|
375
|
+
readFile(params: ReadFileParams): Promise<ReadFileResult>;
|
|
376
|
+
/**
|
|
377
|
+
* Renders HTML to ONE image file (PNG or JPEG) and returns its absolute path, or `null` on failure.
|
|
378
|
+
* It is `htmlToPdf` plus one rendered page, so a very tall page makes a very large bitmap and can run
|
|
379
|
+
* out of memory (then the result is `null`). For base64 pass the path to `readFile`.
|
|
380
|
+
*/
|
|
381
|
+
htmlToImage(params: HtmlToImageParams): Promise<string | null>;
|
|
382
|
+
/**
|
|
383
|
+
* Reads ONE folder: the files and folders directly inside it (not their contents), folders first and
|
|
384
|
+
* then A-Z. Read-only. A path that is a file, missing or relative is refused. Never rejects: check
|
|
385
|
+
* `result.success`.
|
|
386
|
+
*/
|
|
387
|
+
readDir(params: ReadDirParams): Promise<ReadDirResult>;
|
|
152
388
|
/**
|
|
153
389
|
* Opens a file with whatever app the user has installed that can handle its
|
|
154
390
|
* type (e.g. a PDF viewer) - shows the system's "Open with" chooser if more
|
|
@@ -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;
|
|
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,2EAA2E;AAC3E,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEnE,+GAA+G;AAC/G,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,iBAAiB,GAAG,QAAQ,CAAC;AAEjE,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG,SAAS,GAAG,KAAK,CAAC;AAEpE,MAAM,MAAM,sBAAsB,GAAG;IACnC,sCAAsC;IACtC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,oGAAoG;IACpG,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,yFAAyF;IACzF,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,kFAAk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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;;;;OAIG;IACH,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAEhE;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAE1D;;;;OAIG;IACH,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAE/D;;;;OAIG;IACH,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAEvD;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC;CAC3C;;AAQD,wBAA2B"}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 PICTURES: "PICTURES";
|
|
32
|
+
readonly CUSTOM_FOLDER: "CUSTOM_FOLDER";
|
|
33
|
+
};
|
|
34
|
+
export type FileLocation = (typeof FileLocation)[keyof typeof FileLocation];
|
|
35
|
+
/** The shape `readFile` returns the content in. */
|
|
36
|
+
export declare const ReadFileFormat: {
|
|
37
|
+
readonly BASE64: "base64";
|
|
38
|
+
readonly DATA_URI: "dataUri";
|
|
39
|
+
readonly TEXT: "text";
|
|
40
|
+
readonly HEX: "hex";
|
|
41
|
+
readonly BYTES: "bytes";
|
|
42
|
+
};
|
|
43
|
+
export type ReadFileFormat = (typeof ReadFileFormat)[keyof typeof ReadFileFormat];
|
|
44
|
+
//# sourceMappingURL=enums.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../src/enums.ts"],"names":[],"mappings":"AAcA,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;;;;;;;CAOwC,CAAC;AAClE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE5E,mDAAmD;AACnD,eAAO,MAAM,cAAc;;;;;;CAM6B,CAAC;AACzD,MAAM,MAAM,cAAc,GACxB,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ReactNativePrinterKit, { type BluetoothPrinterDevice, type ConnectPrinterParams, type HtmlToPdfParams, type OpenFileParams, type PdfToImageParams, type
|
|
1
|
+
import ReactNativePrinterKit, { type BluetoothPrinterDevice, type ConnectPrinterParams, type DirEntry, type HtmlToImageParams, type GetBondedPrintersParams, type HtmlToPdfParams, type OpenFileParams, type PdfToImageParams, type PrinterStatus, type PrinterStatusParams, type PrintHtmlParams, type PrintImageBase64Params, type PrintImageParams, type PrintPdfParams, type PrintTextParams, type ReadDirParams, type ReadDirResult, type ReadFileParams, type ReadFileResult, type RemoveFileParams, type RemoveFileResult, 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
|
|
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
|
-
*
|
|
21
|
-
|
|
22
|
-
|
|
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,53 @@ 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>;
|
|
76
|
+
/**
|
|
77
|
+
* Reads ONE file and returns its content in the shape `format` asks for: `base64` (default), `dataUri`
|
|
78
|
+
* (`data:<type>;base64,...`), `text` (optionally with an `encoding`), `hex` or `bytes` (array of numbers,
|
|
79
|
+
* max 1 MB). `path` is an absolute path or the `content://` Uri `saveFile` returned. A file over `maxBytes`
|
|
80
|
+
* (default 10 MB) is refused instead of loaded. Never rejects: check `result.success`.
|
|
81
|
+
*/
|
|
82
|
+
export declare function readFile(params: ReadFileParams): Promise<ReadFileResult>;
|
|
83
|
+
/**
|
|
84
|
+
* Renders HTML to ONE image file (PNG, or JPEG with `imageType: 'JPEG'`) and returns its path, or `null`
|
|
85
|
+
* on failure. Pass `outputPath` to choose the file name. A very tall page can run out of memory (then
|
|
86
|
+
* `null`). For base64 pass the returned path to `readFile`.
|
|
87
|
+
*/
|
|
88
|
+
export declare function htmlToImage(params: HtmlToImageParams): Promise<string | null>;
|
|
89
|
+
/**
|
|
90
|
+
* Reads ONE folder: the files and folders directly inside it, folders first and then A-Z (it does not
|
|
91
|
+
* go into sub-folders; call it again with an entry's `path` to go deeper). `result.names` is just the
|
|
92
|
+
* names, `result.entries` has `name`, `path`, `isDirectory`, `sizeBytes` and `lastModified`. A path that
|
|
93
|
+
* is a file, missing or relative is refused. Never rejects: check `result.success`.
|
|
94
|
+
*/
|
|
95
|
+
export declare function readDir(params: ReadDirParams): Promise<ReadDirResult>;
|
|
96
|
+
/**
|
|
97
|
+
* Deletes ONE file: an absolute path, or the `content://` Uri `saveFile` returned. Never a folder or a
|
|
98
|
+
* pattern; cannot be undone. A missing file is a failure ("File not found"). Never rejects: check
|
|
99
|
+
* `result.success`.
|
|
100
|
+
*/
|
|
101
|
+
export declare function removeFile(params: RemoveFileParams): Promise<RemoveFileResult>;
|
|
37
102
|
/**
|
|
38
103
|
* Print raw text using the printer's built-in font (ASCII only - use
|
|
39
104
|
* printHtml() for Bangla or other non-Latin scripts).
|
|
@@ -73,6 +138,7 @@ export declare function printHtml(params: PrintHtmlParams): Promise<boolean>;
|
|
|
73
138
|
* can open it.
|
|
74
139
|
*/
|
|
75
140
|
export declare function openFile(params: OpenFileParams): boolean;
|
|
76
|
-
export
|
|
141
|
+
export { FileLocation, PrinterConfidence, PrinterConnectionType, PrinterFilter, PrinterImageType, ReadFileFormat, } from './enums.js';
|
|
142
|
+
export type { BluetoothPrinterDevice, ConnectPrinterParams, DirEntry, GetBondedPrintersParams, HtmlToImageParams, HtmlToPdfParams, OpenFileParams, PdfToImageParams, PrinterStatus, PrinterStatusParams, PrintHtmlParams, PrintImageBase64Params, PrintImageParams, PrintPdfParams, PrintTextParams, ReadDirParams, ReadDirResult, ReadFileParams, ReadFileResult, RemoveFileParams, RemoveFileResult, SaveFileParams, SaveFileResult, UsbDeviceParams, UsbPrinterDevice, };
|
|
77
143
|
export default ReactNativePrinterKit;
|
|
78
144
|
//# 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,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,
|
|
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,QAAQ,EACb,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACtB,MA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V,sBAAsB,EACtB,oBAAoB,EACpB,QAAQ,EACR,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,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
|
+
"version": "0.4.1",
|
|
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",
|