@risleylima/escpos 0.1.1 → 0.2.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/CHANGELOG.md +8 -0
- package/README.md +8 -0
- package/package.json +1 -1
- package/src/serial-adapter/index.js +16 -0
- package/tests/unit/adapters/serial-adapter.test.js +14 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.2.0] - 2025-11-23
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- `Serial.listSerial()` method to list all available serial ports
|
|
12
|
+
- Returns array of serial port objects with path, manufacturer, vendorId, productId, etc.
|
|
13
|
+
- Similar functionality to `USB.listUSB()` for consistency between adapters
|
|
14
|
+
|
|
8
15
|
## [0.1.0] - 2025-11-23
|
|
9
16
|
|
|
10
17
|
### Added
|
|
@@ -55,6 +62,7 @@ Initial stable release with USB and Serial adapter support.
|
|
|
55
62
|
|
|
56
63
|
## Version History
|
|
57
64
|
|
|
65
|
+
- **0.2.0** - Added `Serial.listSerial()` method for listing available serial ports
|
|
58
66
|
- **0.1.0** - Major dependency updates, 100% test coverage, complete documentation
|
|
59
67
|
- **0.0.14** - Initial stable release
|
|
60
68
|
|
package/README.md
CHANGED
|
@@ -215,6 +215,14 @@ await USB.disconnect();
|
|
|
215
215
|
|
|
216
216
|
#### Methods
|
|
217
217
|
|
|
218
|
+
##### `Serial.listSerial()`
|
|
219
|
+
List all available serial ports.
|
|
220
|
+
|
|
221
|
+
```javascript
|
|
222
|
+
const ports = await Serial.listSerial();
|
|
223
|
+
console.log(ports); // Array of serial port objects with path, manufacturer, vendorId, productId, etc.
|
|
224
|
+
```
|
|
225
|
+
|
|
218
226
|
##### `Serial.connect(port, options)`
|
|
219
227
|
Connect to a serial port printer.
|
|
220
228
|
|
package/package.json
CHANGED
|
@@ -26,6 +26,22 @@ const scope = {
|
|
|
26
26
|
// Create Adapter instance first, so it's the same object used internally and exported
|
|
27
27
|
const Serial = new Adapter();
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* List all available serial ports
|
|
31
|
+
* @async
|
|
32
|
+
* @returns {Promise<Array<Object>>} Array of serial port objects with properties like path, manufacturer, vendorId, productId, etc.
|
|
33
|
+
* @example
|
|
34
|
+
* const ports = await Serial.listSerial();
|
|
35
|
+
* console.log(ports);
|
|
36
|
+
* // [
|
|
37
|
+
* // { path: '/dev/ttyUSB0', manufacturer: 'FTDI', vendorId: '0403', productId: '6001' },
|
|
38
|
+
* // { path: '/dev/ttyUSB1', manufacturer: 'Prolific', vendorId: '067b', productId: '2303' }
|
|
39
|
+
* // ]
|
|
40
|
+
*/
|
|
41
|
+
Serial.listSerial = async () => {
|
|
42
|
+
return await SerialPort.list();
|
|
43
|
+
};
|
|
44
|
+
|
|
29
45
|
/**
|
|
30
46
|
* Connect to a serial port printer
|
|
31
47
|
* @async
|
|
@@ -49,6 +49,20 @@ describe('Serial Adapter', () => {
|
|
|
49
49
|
jest.clearAllMocks();
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
+
describe('listSerial', () => {
|
|
53
|
+
it('should list all available serial ports', async () => {
|
|
54
|
+
const ports = await Serial.listSerial();
|
|
55
|
+
expect(Array.isArray(ports)).toBe(true);
|
|
56
|
+
expect(SerialPort.list).toHaveBeenCalled();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should return port objects with path property', async () => {
|
|
60
|
+
const ports = await Serial.listSerial();
|
|
61
|
+
expect(ports.length).toBeGreaterThan(0);
|
|
62
|
+
expect(ports[0]).toHaveProperty('path');
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
52
66
|
describe('connect', () => {
|
|
53
67
|
it('should connect to serial port', async () => {
|
|
54
68
|
const result = await Serial.connect('/dev/ttyUSB0');
|