@rejaul/react-native-printer-kit 0.2.0 → 0.3.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 +24 -3
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/rejaul/reactnativeprinterkit/ReactNativePrinterKitModule.kt +16 -4
- package/lib/module/NativeReactNativePrinterKit.js.map +1 -1
- package/lib/typescript/src/NativeReactNativePrinterKit.d.ts +16 -0
- package/lib/typescript/src/NativeReactNativePrinterKit.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/NativeReactNativePrinterKit.ts +16 -0
package/README.md
CHANGED
|
@@ -169,9 +169,21 @@ type ConnectPrinterParams = { address: string };
|
|
|
169
169
|
|
|
170
170
|
type PrintTextParams = { text: string; feedLines?: number };
|
|
171
171
|
|
|
172
|
-
type PrintImageParams = {
|
|
172
|
+
type PrintImageParams = {
|
|
173
|
+
imagePath: string;
|
|
174
|
+
printerWidthDots?: number;
|
|
175
|
+
feedLines?: number;
|
|
176
|
+
bandHeightDots?: number; // default 16 - lower for printers that drop/garble large images
|
|
177
|
+
bandDelayMs?: number; // default 60 - raise for printers that drop/garble large images
|
|
178
|
+
};
|
|
173
179
|
|
|
174
|
-
type PrintImageBase64Params = {
|
|
180
|
+
type PrintImageBase64Params = {
|
|
181
|
+
base64: string;
|
|
182
|
+
printerWidthDots?: number;
|
|
183
|
+
feedLines?: number;
|
|
184
|
+
bandHeightDots?: number;
|
|
185
|
+
bandDelayMs?: number;
|
|
186
|
+
};
|
|
175
187
|
|
|
176
188
|
type PdfToImageParams = {
|
|
177
189
|
pdfPath: string;
|
|
@@ -180,7 +192,14 @@ type PdfToImageParams = {
|
|
|
180
192
|
targetWidthPx?: number;
|
|
181
193
|
};
|
|
182
194
|
|
|
183
|
-
type PrintPdfParams = {
|
|
195
|
+
type PrintPdfParams = {
|
|
196
|
+
pdfPath: string;
|
|
197
|
+
printerWidthDots?: number;
|
|
198
|
+
page?: number;
|
|
199
|
+
feedLines?: number;
|
|
200
|
+
bandHeightDots?: number;
|
|
201
|
+
bandDelayMs?: number;
|
|
202
|
+
};
|
|
184
203
|
|
|
185
204
|
type HtmlToPdfParams = {
|
|
186
205
|
html: string;
|
|
@@ -195,6 +214,8 @@ type PrintHtmlParams = {
|
|
|
195
214
|
pageWidthDp?: number;
|
|
196
215
|
heightDp?: number;
|
|
197
216
|
minPageHeightDp?: number;
|
|
217
|
+
bandHeightDots?: number;
|
|
218
|
+
bandDelayMs?: number;
|
|
198
219
|
};
|
|
199
220
|
```
|
|
200
221
|
|
package/android/build.gradle
CHANGED
package/android/src/main/java/com/rejaul/reactnativeprinterkit/ReactNativePrinterKitModule.kt
CHANGED
|
@@ -37,6 +37,10 @@ private fun ReadableMap.optInt(key: String, default: Int): Int =
|
|
|
37
37
|
private fun ReadableMap.optIntOrNull(key: String): Int? =
|
|
38
38
|
if (hasKey(key) && !isNull(key)) getDouble(key).toInt() else null
|
|
39
39
|
|
|
40
|
+
/** Reads an optional numeric field as a Long, falling back to [default] if absent/null. */
|
|
41
|
+
private fun ReadableMap.optLong(key: String, default: Long): Long =
|
|
42
|
+
if (hasKey(key) && !isNull(key)) getDouble(key).toLong() else default
|
|
43
|
+
|
|
40
44
|
/**
|
|
41
45
|
* Bridges [com.rezaul.printerkit.BluetoothPrinter] to React Native.
|
|
42
46
|
*
|
|
@@ -233,7 +237,9 @@ class ReactNativePrinterKitModule(reactContext: ReactApplicationContext) :
|
|
|
233
237
|
PrintImageFileParams(
|
|
234
238
|
imagePath = imagePath,
|
|
235
239
|
printerWidthDots = params.optInt("printerWidthDots", 384),
|
|
236
|
-
feedLines = params.optInt("feedLines", 3)
|
|
240
|
+
feedLines = params.optInt("feedLines", 3),
|
|
241
|
+
bandHeightDots = params.optInt("bandHeightDots", 16),
|
|
242
|
+
bandDelayMs = params.optLong("bandDelayMs", 60L)
|
|
237
243
|
)
|
|
238
244
|
)
|
|
239
245
|
promise.resolve(null)
|
|
@@ -257,7 +263,9 @@ class ReactNativePrinterKitModule(reactContext: ReactApplicationContext) :
|
|
|
257
263
|
PrintImageBase64Params(
|
|
258
264
|
base64 = base64,
|
|
259
265
|
printerWidthDots = params.optInt("printerWidthDots", 384),
|
|
260
|
-
feedLines = params.optInt("feedLines", 3)
|
|
266
|
+
feedLines = params.optInt("feedLines", 3),
|
|
267
|
+
bandHeightDots = params.optInt("bandHeightDots", 16),
|
|
268
|
+
bandDelayMs = params.optLong("bandDelayMs", 60L)
|
|
261
269
|
)
|
|
262
270
|
)
|
|
263
271
|
promise.resolve(null)
|
|
@@ -312,7 +320,9 @@ class ReactNativePrinterKitModule(reactContext: ReactApplicationContext) :
|
|
|
312
320
|
pdfPath = pdfPath,
|
|
313
321
|
printerWidthDots = params.optInt("printerWidthDots", 384),
|
|
314
322
|
page = params.optInt("page", 0),
|
|
315
|
-
feedLines = params.optInt("feedLines", 3)
|
|
323
|
+
feedLines = params.optInt("feedLines", 3),
|
|
324
|
+
bandHeightDots = params.optInt("bandHeightDots", 16),
|
|
325
|
+
bandDelayMs = params.optLong("bandDelayMs", 60L)
|
|
316
326
|
)
|
|
317
327
|
)
|
|
318
328
|
promise.resolve(null)
|
|
@@ -356,7 +366,9 @@ class ReactNativePrinterKitModule(reactContext: ReactApplicationContext) :
|
|
|
356
366
|
printerWidthDots = params.optInt("printerWidthDots", 384),
|
|
357
367
|
pageWidthDp = params.optInt("pageWidthDp", 412),
|
|
358
368
|
heightDp = params.optIntOrNull("heightDp"),
|
|
359
|
-
minPageHeightDp = params.optInt("minPageHeightDp", 1000)
|
|
369
|
+
minPageHeightDp = params.optInt("minPageHeightDp", 1000),
|
|
370
|
+
bandHeightDots = params.optInt("bandHeightDots", 16),
|
|
371
|
+
bandDelayMs = params.optLong("bandDelayMs", 60L)
|
|
360
372
|
)
|
|
361
373
|
) { ok ->
|
|
362
374
|
promise.resolve(ok)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","Platform","getModule","OS","getEnforcing"],"sourceRoot":"../../src","sources":["NativeReactNativePrinterKit.ts"],"mappings":";;AAAA,SAASA,mBAAmB,EAAoBC,QAAQ,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","Platform","getModule","OS","getEnforcing"],"sourceRoot":"../../src","sources":["NativeReactNativePrinterKit.ts"],"mappings":";;AAAA,SAASA,mBAAmB,EAAoBC,QAAQ,QAAQ,cAAc;AAqK9E,SAASC,SAASA,CAAA,EAAS;EACzB,OAAOD,QAAQ,CAACE,EAAE,KAAK,SAAS,GAC5BH,mBAAmB,CAACI,YAAY,CAAO,uBAAuB,CAAC,GAC9D,CAAC,CAAU;AAClB;AAEA,eAAeF,SAAS,CAAC,CAAC","ignoreList":[]}
|
|
@@ -15,11 +15,19 @@ export type PrintImageParams = {
|
|
|
15
15
|
imagePath: string;
|
|
16
16
|
printerWidthDots?: number;
|
|
17
17
|
feedLines?: number;
|
|
18
|
+
/** Height (in dots) of each raster band sent to the printer. Lower this for printers with a small receive buffer that drop or garble large images. Default 16. */
|
|
19
|
+
bandHeightDots?: number;
|
|
20
|
+
/** Pause (ms) between raster bands, giving the printer time to catch up. Default 60. */
|
|
21
|
+
bandDelayMs?: number;
|
|
18
22
|
};
|
|
19
23
|
export type PrintImageBase64Params = {
|
|
20
24
|
base64: string;
|
|
21
25
|
printerWidthDots?: number;
|
|
22
26
|
feedLines?: number;
|
|
27
|
+
/** See PrintImageParams.bandHeightDots. */
|
|
28
|
+
bandHeightDots?: number;
|
|
29
|
+
/** See PrintImageParams.bandDelayMs. */
|
|
30
|
+
bandDelayMs?: number;
|
|
23
31
|
};
|
|
24
32
|
export type PdfToImageParams = {
|
|
25
33
|
pdfPath: string;
|
|
@@ -32,6 +40,10 @@ export type PrintPdfParams = {
|
|
|
32
40
|
printerWidthDots?: number;
|
|
33
41
|
page?: number;
|
|
34
42
|
feedLines?: number;
|
|
43
|
+
/** See PrintImageParams.bandHeightDots. */
|
|
44
|
+
bandHeightDots?: number;
|
|
45
|
+
/** See PrintImageParams.bandDelayMs. */
|
|
46
|
+
bandDelayMs?: number;
|
|
35
47
|
};
|
|
36
48
|
export type HtmlToPdfParams = {
|
|
37
49
|
html: string;
|
|
@@ -45,6 +57,10 @@ export type PrintHtmlParams = {
|
|
|
45
57
|
pageWidthDp?: number;
|
|
46
58
|
heightDp?: number;
|
|
47
59
|
minPageHeightDp?: number;
|
|
60
|
+
/** See PrintImageParams.bandHeightDots. */
|
|
61
|
+
bandHeightDots?: number;
|
|
62
|
+
/** See PrintImageParams.bandDelayMs. */
|
|
63
|
+
bandDelayMs?: number;
|
|
48
64
|
};
|
|
49
65
|
export interface Spec extends TurboModule {
|
|
50
66
|
/**
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"NativeReactNativePrinterKit.d.ts","sourceRoot":"","sources":["../../../src/NativeReactNativePrinterKit.ts"],"names":[],"mappings":"AAAA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,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;CACtD;;AAQD,wBAA2B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rejaul/react-native-printer-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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",
|
|
@@ -20,12 +20,20 @@ export type PrintImageParams = {
|
|
|
20
20
|
imagePath: string;
|
|
21
21
|
printerWidthDots?: number;
|
|
22
22
|
feedLines?: number;
|
|
23
|
+
/** Height (in dots) of each raster band sent to the printer. Lower this for printers with a small receive buffer that drop or garble large images. Default 16. */
|
|
24
|
+
bandHeightDots?: number;
|
|
25
|
+
/** Pause (ms) between raster bands, giving the printer time to catch up. Default 60. */
|
|
26
|
+
bandDelayMs?: number;
|
|
23
27
|
};
|
|
24
28
|
|
|
25
29
|
export type PrintImageBase64Params = {
|
|
26
30
|
base64: string;
|
|
27
31
|
printerWidthDots?: number;
|
|
28
32
|
feedLines?: number;
|
|
33
|
+
/** See PrintImageParams.bandHeightDots. */
|
|
34
|
+
bandHeightDots?: number;
|
|
35
|
+
/** See PrintImageParams.bandDelayMs. */
|
|
36
|
+
bandDelayMs?: number;
|
|
29
37
|
};
|
|
30
38
|
|
|
31
39
|
export type PdfToImageParams = {
|
|
@@ -40,6 +48,10 @@ export type PrintPdfParams = {
|
|
|
40
48
|
printerWidthDots?: number;
|
|
41
49
|
page?: number;
|
|
42
50
|
feedLines?: number;
|
|
51
|
+
/** See PrintImageParams.bandHeightDots. */
|
|
52
|
+
bandHeightDots?: number;
|
|
53
|
+
/** See PrintImageParams.bandDelayMs. */
|
|
54
|
+
bandDelayMs?: number;
|
|
43
55
|
};
|
|
44
56
|
|
|
45
57
|
export type HtmlToPdfParams = {
|
|
@@ -55,6 +67,10 @@ export type PrintHtmlParams = {
|
|
|
55
67
|
pageWidthDp?: number;
|
|
56
68
|
heightDp?: number;
|
|
57
69
|
minPageHeightDp?: number;
|
|
70
|
+
/** See PrintImageParams.bandHeightDots. */
|
|
71
|
+
bandHeightDots?: number;
|
|
72
|
+
/** See PrintImageParams.bandDelayMs. */
|
|
73
|
+
bandDelayMs?: number;
|
|
58
74
|
};
|
|
59
75
|
|
|
60
76
|
export interface Spec extends TurboModule {
|