node-thermal-printer-js 1.0.4 → 1.0.5
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/.env.example +16 -0
- package/app.js +6 -6
- package/package.json +4 -3
package/.env.example
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Default: COM5 for Windows serial port, or use BLE bridge
|
|
2
|
+
PRINTER_TRANSPORT=com
|
|
3
|
+
|
|
4
|
+
# COM mode settings
|
|
5
|
+
PRINTER_COM_PORT=COM5
|
|
6
|
+
|
|
7
|
+
# BLE mode settings (if using BLE bridge)
|
|
8
|
+
PRINTER_BLE_NAME=PSF588
|
|
9
|
+
# PRINTER_BLE_ADDRESS=AA:BB:CC:DD:EE:FF
|
|
10
|
+
PRINTER_BLE_CHAR_UUID=49535343-8841-43f4-a8d4-ecbe34729bb3
|
|
11
|
+
PRINTER_BLE_CONNECT_TIMEOUT=15
|
|
12
|
+
PRINTER_BLE_SCAN_TIMEOUT=10
|
|
13
|
+
PRINTER_BLE_PAIR=0
|
|
14
|
+
|
|
15
|
+
# Python command for BLE bridge (only needed for BLE mode)
|
|
16
|
+
# PRINTER_PYTHON_CMD=python
|
package/app.js
CHANGED
|
@@ -58,7 +58,7 @@ const runPythonProcess = ({ cmd, cmdArgs, scriptArgs }) =>
|
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
const printViaComPort = async (data, options = {}) => {
|
|
61
|
-
const portPath = options.portPath || process.env.PRINTER_COM_PORT;
|
|
61
|
+
const portPath = options.portPath || process.env.PRINTER_COM_PORT || "COM5";
|
|
62
62
|
const baudRate = options.baudRate || 9600;
|
|
63
63
|
|
|
64
64
|
// Dynamically import `serialport` only when COM transport is requested.
|
|
@@ -66,7 +66,7 @@ const printViaComPort = async (data, options = {}) => {
|
|
|
66
66
|
try {
|
|
67
67
|
const SerialPortModule = await import("serialport");
|
|
68
68
|
SerialPortCtor = SerialPortModule.SerialPort || SerialPortModule.default;
|
|
69
|
-
|
|
69
|
+
|
|
70
70
|
if (!SerialPortCtor) {
|
|
71
71
|
throw new Error("SerialPort constructor not found in module exports");
|
|
72
72
|
}
|
|
@@ -152,10 +152,10 @@ const printViaBleBridge = (data, options = {}) => {
|
|
|
152
152
|
const candidates = envCmd
|
|
153
153
|
? [{ cmd: envCmd, cmdArgs: [] }]
|
|
154
154
|
: [
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
{ cmd: "py", cmdArgs: ["-3.11"] },
|
|
156
|
+
{ cmd: "py", cmdArgs: ["-3"] },
|
|
157
|
+
{ cmd: "python", cmdArgs: [] },
|
|
158
|
+
];
|
|
159
159
|
|
|
160
160
|
return new Promise(async (resolve, reject) => {
|
|
161
161
|
const failures = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-thermal-printer-js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "ESC/POS printer helper for PSF588 Bluetooth and COM printing.",
|
|
5
5
|
"main": "app.js",
|
|
6
6
|
"exports": {
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"app.js",
|
|
11
11
|
"ble_print.py",
|
|
12
12
|
"ble_scan.py",
|
|
13
|
-
"README.md"
|
|
13
|
+
"README.md",
|
|
14
|
+
".env.example"
|
|
14
15
|
],
|
|
15
16
|
"scripts": {
|
|
16
17
|
"test": "node test-api.js",
|
|
@@ -34,4 +35,4 @@
|
|
|
34
35
|
"dotenv": "^16.6.1",
|
|
35
36
|
"serialport": "^13.0.0"
|
|
36
37
|
}
|
|
37
|
-
}
|
|
38
|
+
}
|