@risleylima/escpos 0.2.1 → 1.0.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 +94 -766
- package/dist/adapter/index.d.ts +29 -0
- package/dist/adapter/index.d.ts.map +1 -0
- package/dist/adapter/index.js +25 -0
- package/dist/adapter/index.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/network-adapter/index.d.ts +24 -0
- package/dist/network-adapter/index.d.ts.map +1 -0
- package/dist/network-adapter/index.js +263 -0
- package/dist/network-adapter/index.js.map +1 -0
- package/dist/printer/commands-types.d.ts +37 -0
- package/dist/printer/commands-types.d.ts.map +1 -0
- package/dist/printer/commands-types.js +63 -0
- package/dist/printer/commands-types.js.map +1 -0
- package/dist/printer/commands.d.ts +169 -0
- package/dist/printer/commands.d.ts.map +1 -0
- package/dist/printer/commands.js +192 -0
- package/dist/printer/commands.js.map +1 -0
- package/dist/printer/image-loader.d.ts +17 -0
- package/dist/printer/image-loader.d.ts.map +1 -0
- package/dist/printer/image-loader.js +462 -0
- package/dist/printer/image-loader.js.map +1 -0
- package/dist/printer/image.d.ts +43 -0
- package/dist/printer/image.d.ts.map +1 -0
- package/dist/printer/image.js +132 -0
- package/dist/printer/image.js.map +1 -0
- package/dist/printer/index.d.ts +158 -0
- package/dist/printer/index.d.ts.map +1 -0
- package/dist/printer/index.js +703 -0
- package/dist/printer/index.js.map +1 -0
- package/dist/printer/profiles/bematech/mp4200th.d.ts +13 -0
- package/dist/printer/profiles/bematech/mp4200th.d.ts.map +1 -0
- package/dist/printer/profiles/bematech/mp4200th.js +29 -0
- package/dist/printer/profiles/bematech/mp4200th.js.map +1 -0
- package/dist/printer/profiles/custom/bematech-mp4200th.d.ts +13 -0
- package/dist/printer/profiles/custom/bematech-mp4200th.d.ts.map +1 -0
- package/dist/printer/profiles/custom/bematech-mp4200th.js +21 -0
- package/dist/printer/profiles/custom/bematech-mp4200th.js.map +1 -0
- package/dist/printer/profiles/custom/vkp80iii.d.ts +19 -0
- package/dist/printer/profiles/custom/vkp80iii.d.ts.map +1 -0
- package/dist/printer/profiles/custom/vkp80iii.js +87 -0
- package/dist/printer/profiles/custom/vkp80iii.js.map +1 -0
- package/dist/printer/profiles/default.d.ts +7 -0
- package/dist/printer/profiles/default.d.ts.map +1 -0
- package/dist/printer/profiles/default.js +15 -0
- package/dist/printer/profiles/default.js.map +1 -0
- package/dist/printer/profiles/index.d.ts +41 -0
- package/dist/printer/profiles/index.d.ts.map +1 -0
- package/dist/printer/profiles/index.js +98 -0
- package/dist/printer/profiles/index.js.map +1 -0
- package/dist/printer/profiles/merge.d.ts +7 -0
- package/dist/printer/profiles/merge.d.ts.map +1 -0
- package/dist/printer/profiles/merge.js +58 -0
- package/dist/printer/profiles/merge.js.map +1 -0
- package/dist/printer/profiles/types.d.ts +99 -0
- package/dist/printer/profiles/types.d.ts.map +1 -0
- package/dist/printer/profiles/types.js +8 -0
- package/dist/printer/profiles/types.js.map +1 -0
- package/dist/printer/utils.d.ts +9 -0
- package/dist/printer/utils.d.ts.map +1 -0
- package/dist/printer/utils.js +54 -0
- package/dist/printer/utils.js.map +1 -0
- package/dist/serial-adapter/index.d.ts +17 -0
- package/dist/serial-adapter/index.d.ts.map +1 -0
- package/dist/serial-adapter/index.js +172 -0
- package/dist/serial-adapter/index.js.map +1 -0
- package/dist/usb-adapter/index.d.ts +20 -0
- package/dist/usb-adapter/index.d.ts.map +1 -0
- package/dist/usb-adapter/index.js +264 -0
- package/dist/usb-adapter/index.js.map +1 -0
- package/package.json +42 -15
- package/CHANGELOG.md +0 -74
- package/docs/COVERAGE_ANALYSIS.md +0 -98
- package/docs/DEPENDENCIES_REVIEW.md +0 -127
- package/docs/JSDOC_REVIEW.md +0 -122
- package/docs/LIBRARY_OVERVIEW.md +0 -383
- package/docs/PRE_PUBLISH_CHECKLIST.md +0 -331
- package/docs/PUBLIC_API_ANALYSIS.md +0 -223
- package/docs/README.md +0 -37
- package/docs/SERIALPORT_V13_MIGRATION_COMPLETE.md +0 -127
- package/docs/TESTS_IMPLEMENTED.md +0 -129
- package/docs/USB_V2_REVIEW.md +0 -148
- package/docs/VERIFICATION_RESULTS.md +0 -172
- package/docs/VERSIONING.md +0 -102
- package/examples/printTest.js +0 -59
- package/index.js +0 -7
- package/jest.config.js +0 -16
- package/src/adapter/index.js +0 -75
- package/src/printer/commands.js +0 -199
- package/src/printer/image.js +0 -159
- package/src/printer/index.js +0 -621
- package/src/printer/utils.js +0 -58
- package/src/serial-adapter/index.js +0 -198
- package/src/usb-adapter/index.js +0 -283
- package/tests/README.md +0 -67
- package/tests/integration/printer-flow.test.js +0 -128
- package/tests/unit/adapters/adapter.test.js +0 -49
- package/tests/unit/adapters/serial-adapter.test.js +0 -238
- package/tests/unit/adapters/usb-adapter.test.js +0 -319
- package/tests/unit/image/image.test.js +0 -157
- package/tests/unit/printer/buffer.test.js +0 -60
- package/tests/unit/printer/commands.test.js +0 -109
- package/tests/unit/printer/printer.test.js +0 -405
- package/tests/unit/utils/utils.test.js +0 -96
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
# ✅ Tests Implemented
|
|
2
|
-
|
|
3
|
-
## 📋 Summary
|
|
4
|
-
|
|
5
|
-
A complete test suite has been implemented for the EscPos library using Jest.
|
|
6
|
-
|
|
7
|
-
## 📁 Created Structure
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
tests/
|
|
11
|
-
├── unit/
|
|
12
|
-
│ ├── printer/
|
|
13
|
-
│ │ ├── buffer.test.js # SpecBuffer tests
|
|
14
|
-
│ │ └── printer.test.js # Printer class tests
|
|
15
|
-
│ ├── adapters/
|
|
16
|
-
│ │ ├── adapter.test.js # Base Adapter class tests
|
|
17
|
-
│ │ ├── usb-adapter.test.js # USB Adapter tests (mocked)
|
|
18
|
-
│ │ └── serial-adapter.test.js # Serial Adapter tests (mocked)
|
|
19
|
-
│ ├── image/
|
|
20
|
-
│ │ └── image.test.js # Image processing tests
|
|
21
|
-
│ └── utils/
|
|
22
|
-
│ └── utils.test.js # Utility functions tests
|
|
23
|
-
├── integration/
|
|
24
|
-
│ └── printer-flow.test.js # Complete flow tests
|
|
25
|
-
└── README.md # Test documentation
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## 🧪 Test Coverage
|
|
29
|
-
|
|
30
|
-
### ✅ SpecBuffer
|
|
31
|
-
- Empty buffer initialization
|
|
32
|
-
- Data writing (ASCII, hex)
|
|
33
|
-
- Multiple writes concatenation
|
|
34
|
-
- Flush and buffer clearing
|
|
35
|
-
|
|
36
|
-
### ✅ Printer
|
|
37
|
-
- **Constructor**: Initialization with adapter and options
|
|
38
|
-
- **Text**: print, println, text, textln, newLine
|
|
39
|
-
- **Alignment**: left, center, right
|
|
40
|
-
- **Formatting**: size, font, style (bold, italic, underline)
|
|
41
|
-
- **Paper**: feed, drawLine, cut (partial/full)
|
|
42
|
-
- **Hardware**: init, beep, cashdraw
|
|
43
|
-
- **Barcodes**: EAN13, EAN8, with validations
|
|
44
|
-
- **Raw Commands**: direct hex command writing
|
|
45
|
-
- **Method Chaining**: method chaining support
|
|
46
|
-
- **Flush/Close**: data sending and closing
|
|
47
|
-
- **Colors**: primary/secondary, reverse colors
|
|
48
|
-
|
|
49
|
-
### ✅ Utils
|
|
50
|
-
- `getParityBit`: parity bit calculation
|
|
51
|
-
- `codeLength`: hex length calculation
|
|
52
|
-
- `textLength`: character counting (ASCII and multi-byte)
|
|
53
|
-
- `textSubstring`: substring extraction considering multi-byte
|
|
54
|
-
|
|
55
|
-
### ✅ Image
|
|
56
|
-
- Image loading (with mock)
|
|
57
|
-
- Bitmap conversion (different densities)
|
|
58
|
-
- Raster conversion
|
|
59
|
-
- Pixel processing (black/white/transparent)
|
|
60
|
-
|
|
61
|
-
### ✅ Adapters
|
|
62
|
-
- **Base Adapter**: abstract methods validation
|
|
63
|
-
- **USB Adapter**: connect, open, write, close, disconnect (mocked)
|
|
64
|
-
- **Serial Adapter**: connect, open, write, close, read (mocked)
|
|
65
|
-
|
|
66
|
-
### ✅ Integration
|
|
67
|
-
- Complete receipt print flow
|
|
68
|
-
- Print with barcode
|
|
69
|
-
- Multiple sequential prints
|
|
70
|
-
- Complex formatting (mixed styles)
|
|
71
|
-
- Error handling
|
|
72
|
-
|
|
73
|
-
## 🚀 How to Run
|
|
74
|
-
|
|
75
|
-
### Install Jest
|
|
76
|
-
```bash
|
|
77
|
-
npm install --save-dev jest
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
**Note**: If there's an error compiling the `usb` module, don't worry - the tests use mocks and don't need the compiled module.
|
|
81
|
-
|
|
82
|
-
### Run Tests
|
|
83
|
-
```bash
|
|
84
|
-
# All tests
|
|
85
|
-
npm test
|
|
86
|
-
|
|
87
|
-
# Watch mode (re-runs on save)
|
|
88
|
-
npm run test:watch
|
|
89
|
-
|
|
90
|
-
# With coverage
|
|
91
|
-
npm run test:coverage
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
## 🎯 Mocking Strategy
|
|
95
|
-
|
|
96
|
-
The tests use mocks to isolate dependencies:
|
|
97
|
-
|
|
98
|
-
- **USB Adapter**: Mock of `usb` module (no hardware needed)
|
|
99
|
-
- **Serial Adapter**: Mock of `serialport` module (no hardware needed)
|
|
100
|
-
- **Image**: Mock of `get-pixels` module (no real files needed)
|
|
101
|
-
|
|
102
|
-
This allows:
|
|
103
|
-
- ✅ Running tests without hardware
|
|
104
|
-
- ✅ Fast tests
|
|
105
|
-
- ✅ Reliable and reproducible tests
|
|
106
|
-
- ✅ CI/CD without external dependencies
|
|
107
|
-
|
|
108
|
-
## 📊 Statistics
|
|
109
|
-
|
|
110
|
-
- **Total test files**: 8
|
|
111
|
-
- **Categories**: Unit + Integration
|
|
112
|
-
- **Mocks**: 3 main modules
|
|
113
|
-
- **Expected coverage**: 70-85%
|
|
114
|
-
|
|
115
|
-
## 🔄 Next Steps (Optional)
|
|
116
|
-
|
|
117
|
-
1. Add tests for QR Code (when implemented)
|
|
118
|
-
2. Add performance tests
|
|
119
|
-
3. Add E2E tests with real printer (optional)
|
|
120
|
-
4. Configure CI/CD (GitHub Actions, etc.)
|
|
121
|
-
5. Add snapshot tests for complex buffers
|
|
122
|
-
|
|
123
|
-
## 📝 Notes
|
|
124
|
-
|
|
125
|
-
- All tests are independent and can run in parallel
|
|
126
|
-
- Mocks ensure tests don't depend on real hardware
|
|
127
|
-
- The structure allows easy addition of new tests
|
|
128
|
-
- Tests also serve as API usage documentation
|
|
129
|
-
|
package/docs/USB_V2_REVIEW.md
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
# USB v2 Compatibility Review
|
|
2
|
-
|
|
3
|
-
## Review Summary
|
|
4
|
-
|
|
5
|
-
Complete review of the codebase to ensure compatibility with `usb@^2.16.0` (upgraded from `usb@^1.9.1`).
|
|
6
|
-
|
|
7
|
-
## Files Reviewed
|
|
8
|
-
|
|
9
|
-
### ✅ Core Code
|
|
10
|
-
- **`src/usb-adapter/index.js`** - Fully updated to v2 API
|
|
11
|
-
- All callbacks converted to Promises/async-await
|
|
12
|
-
- Interface access updated for v2 structure
|
|
13
|
-
- Improved error handling
|
|
14
|
-
- Better interface release logic
|
|
15
|
-
|
|
16
|
-
### ✅ Tests
|
|
17
|
-
- **`tests/unit/adapters/usb-adapter.test.js`** - Completely updated
|
|
18
|
-
- Mocks updated to reflect v2 Promise-based API
|
|
19
|
-
- Added comprehensive test cases
|
|
20
|
-
- Improved mock structure with proper endpoint-interface linking
|
|
21
|
-
- Added tests for error scenarios
|
|
22
|
-
|
|
23
|
-
### ✅ Examples
|
|
24
|
-
- **`examples/printTest.js`** - Compatible (uses adapter API, not direct USB)
|
|
25
|
-
- No changes needed - uses the adapter abstraction
|
|
26
|
-
|
|
27
|
-
### ✅ Package Configuration
|
|
28
|
-
- **`package.json`** - Updated dependency
|
|
29
|
-
- `"usb": "^2.16.0"` ✓
|
|
30
|
-
|
|
31
|
-
## Key Changes Made
|
|
32
|
-
|
|
33
|
-
### 1. USB Adapter Code Improvements
|
|
34
|
-
|
|
35
|
-
#### Interface Release Logic
|
|
36
|
-
- **Before**: Attempted to release all interfaces
|
|
37
|
-
- **After**: Prioritizes releasing the specific interface that was claimed
|
|
38
|
-
- **Fallback**: Releases all interfaces if endpoint.interface is not available
|
|
39
|
-
|
|
40
|
-
```javascript
|
|
41
|
-
// Improved release logic
|
|
42
|
-
if (scope.endpoint && scope.endpoint.interface) {
|
|
43
|
-
const interfaceObj = scope.endpoint.interface;
|
|
44
|
-
if (interfaceObj && typeof interfaceObj.release === 'function') {
|
|
45
|
-
await interfaceObj.release();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### 2. Test Improvements
|
|
51
|
-
|
|
52
|
-
#### Enhanced Mock Structure
|
|
53
|
-
- Added proper endpoint-interface linking (`endpoint.interface`)
|
|
54
|
-
- All async methods return Promises
|
|
55
|
-
- More realistic mock structure matching v2 API
|
|
56
|
-
|
|
57
|
-
#### Additional Test Cases
|
|
58
|
-
- Test for devices without descriptors
|
|
59
|
-
- Verification of interface claiming
|
|
60
|
-
- Verification of endpoint transfer calls
|
|
61
|
-
- Verification of interface release
|
|
62
|
-
|
|
63
|
-
### 3. Error Handling
|
|
64
|
-
- Better error messages with context
|
|
65
|
-
- Graceful handling of descriptor errors
|
|
66
|
-
- Proper cleanup on errors
|
|
67
|
-
|
|
68
|
-
## API Compatibility Checklist
|
|
69
|
-
|
|
70
|
-
### ✅ Device Operations
|
|
71
|
-
- [x] `device.open()` - Returns Promise
|
|
72
|
-
- [x] `device.close()` - Returns Promise
|
|
73
|
-
- [x] `device.getStringDescriptor()` - Returns Promise
|
|
74
|
-
- [x] `device.configDescriptor` - Accessible
|
|
75
|
-
- [x] `device.interfaces` - Array of Interface objects
|
|
76
|
-
|
|
77
|
-
### ✅ Interface Operations
|
|
78
|
-
- [x] `interface.claim()` - Returns Promise
|
|
79
|
-
- [x] `interface.release()` - Returns Promise
|
|
80
|
-
- [x] `interface.detachKernelDriver()` - Returns Promise
|
|
81
|
-
- [x] `interface.isKernelDriverActive()` - Returns boolean
|
|
82
|
-
- [x] `interface.descriptor` - Accessible
|
|
83
|
-
- [x] `interface.endpoints` - Array of Endpoint objects
|
|
84
|
-
|
|
85
|
-
### ✅ Endpoint Operations
|
|
86
|
-
- [x] `endpoint.transfer()` - Returns Promise
|
|
87
|
-
- [x] `endpoint.direction` - Accessible
|
|
88
|
-
- [x] `endpoint.interface` - Available (v2 feature)
|
|
89
|
-
|
|
90
|
-
### ✅ USB Module Operations
|
|
91
|
-
- [x] `usb.getDeviceList()` - Returns array
|
|
92
|
-
- [x] `usb.findByIds()` - Returns Device or undefined
|
|
93
|
-
- [x] `usb.on('detach')` - Event emitter
|
|
94
|
-
|
|
95
|
-
## Testing Status
|
|
96
|
-
|
|
97
|
-
All tests updated and verified:
|
|
98
|
-
- ✅ Unit tests for USB adapter
|
|
99
|
-
- ✅ Mock structure matches v2 API
|
|
100
|
-
- ✅ Error scenarios covered
|
|
101
|
-
- ✅ Integration tests compatible
|
|
102
|
-
|
|
103
|
-
## Breaking Changes Handled
|
|
104
|
-
|
|
105
|
-
1. **Callbacks → Promises**: All callback-based methods converted
|
|
106
|
-
2. **Interface Access**: Updated to use `device.interfaces` array
|
|
107
|
-
3. **Error Handling**: Changed from error-first callbacks to try/catch
|
|
108
|
-
4. **Endpoint Structure**: Added support for `endpoint.interface` property
|
|
109
|
-
|
|
110
|
-
## Remaining Considerations
|
|
111
|
-
|
|
112
|
-
### Platform-Specific Notes
|
|
113
|
-
- Windows: Interface claiming handled differently (no kernel driver)
|
|
114
|
-
- Linux/macOS: Kernel driver detach/attach properly handled
|
|
115
|
-
|
|
116
|
-
### Performance
|
|
117
|
-
- No performance degradation expected
|
|
118
|
-
- Promise-based code may be slightly more efficient
|
|
119
|
-
|
|
120
|
-
### Backward Compatibility
|
|
121
|
-
- **Not compatible** with v1 API
|
|
122
|
-
- Users must upgrade to v2 if using this library
|
|
123
|
-
|
|
124
|
-
## Verification Steps
|
|
125
|
-
|
|
126
|
-
To verify the update:
|
|
127
|
-
|
|
128
|
-
1. **Install dependencies**:
|
|
129
|
-
```bash
|
|
130
|
-
npm install
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
2. **Run tests**:
|
|
134
|
-
```bash
|
|
135
|
-
npm test
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
3. **Test with real hardware** (if available):
|
|
139
|
-
```bash
|
|
140
|
-
node examples/printTest.js
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
## References
|
|
144
|
-
|
|
145
|
-
- [node-usb v2 Documentation](https://node-usb.github.io/node-usb/)
|
|
146
|
-
- [node-usb GitHub](https://github.com/node-usb/node-usb)
|
|
147
|
-
- [Migration Guide](./USB_V2_MIGRATION.md)
|
|
148
|
-
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
# Pre-Publish Verification Results
|
|
2
|
-
|
|
3
|
-
Date: 2025-11-23
|
|
4
|
-
Version: 0.1.0 (published)
|
|
5
|
-
|
|
6
|
-
## ✅ All Verifications Passed
|
|
7
|
-
|
|
8
|
-
### 1. NPM Package Verification ✅
|
|
9
|
-
- **Status**: PASSED
|
|
10
|
-
- **Package Name**: `@risleylima/escpos`
|
|
11
|
-
- **Current Version**: `0.0.14`
|
|
12
|
-
- **Files Included**:
|
|
13
|
-
- ✅ Essential files (index.js, README.md, LICENSE, CHANGELOG.md)
|
|
14
|
-
- ✅ Source code (src/)
|
|
15
|
-
- ✅ Documentation (docs/)
|
|
16
|
-
- ✅ Examples (examples/)
|
|
17
|
-
- ✅ Configuration (package.json, jest.config.js)
|
|
18
|
-
- ✅ No node_modules included
|
|
19
|
-
- ✅ No test files included
|
|
20
|
-
- ✅ No .git included
|
|
21
|
-
- **Package Size**: Reasonable (all files listed correctly)
|
|
22
|
-
|
|
23
|
-
### 2. Dependencies Verification ✅
|
|
24
|
-
- **Status**: PASSED
|
|
25
|
-
- **Vulnerabilities**: 0 found (yarn audit)
|
|
26
|
-
- **Outdated Dependencies**:
|
|
27
|
-
- Only `get-pixels` shows as "exotic" (custom fork from GitHub - expected)
|
|
28
|
-
- All other dependencies are up to date
|
|
29
|
-
- **Dependency Versions**:
|
|
30
|
-
- `usb@^2.16.0` ✅
|
|
31
|
-
- `serialport@^13.0.0` ✅
|
|
32
|
-
- `debug@^4.4.3` ✅
|
|
33
|
-
- `iconv-lite@^0.7.0` ✅
|
|
34
|
-
- `jest@^30.2.0` ✅
|
|
35
|
-
|
|
36
|
-
### 3. Code Verification ✅
|
|
37
|
-
- **Status**: PASSED
|
|
38
|
-
- **Syntax**: No errors
|
|
39
|
-
- **Exports**: All working correctly
|
|
40
|
-
- **Load Time**: 0.083s (excellent performance)
|
|
41
|
-
|
|
42
|
-
### 4. Test Verification ✅
|
|
43
|
-
- **Status**: PASSED
|
|
44
|
-
- **Total Tests**: 145
|
|
45
|
-
- **Test Suites**: 9
|
|
46
|
-
- **All Tests**: ✅ PASSING
|
|
47
|
-
- **Coverage**:
|
|
48
|
-
- Statements: 100%
|
|
49
|
-
- Branches: 100%
|
|
50
|
-
- Functions: 100%
|
|
51
|
-
- Lines: 100%
|
|
52
|
-
- **Result**: Perfect coverage achieved
|
|
53
|
-
|
|
54
|
-
### 5. Compatibility Verification ✅
|
|
55
|
-
- **Status**: PASSED
|
|
56
|
-
- **Node.js Version**: v20.19.5 (current)
|
|
57
|
-
- **Required Version**: >=18.0.0
|
|
58
|
-
- **Compatibility**: ✅ Compatible
|
|
59
|
-
- **Note**: Should test on Node.js 18 (minimum version) if possible
|
|
60
|
-
|
|
61
|
-
### 6. Documentation Verification ✅
|
|
62
|
-
- **Status**: PASSED
|
|
63
|
-
- **README.md**: ✅ Complete and updated
|
|
64
|
-
- **CHANGELOG.md**: ✅ Created with all changes
|
|
65
|
-
- **JSDoc**: ✅ Complete (100% coverage)
|
|
66
|
-
- **Additional Docs**: ✅ All translated to English
|
|
67
|
-
- **Examples**: ✅ Present and documented
|
|
68
|
-
|
|
69
|
-
### 7. Git Verification ✅
|
|
70
|
-
- **Status**: PASSED
|
|
71
|
-
- **Current Branch**: `main`
|
|
72
|
-
- **Tags**: v0.0.5 through v0.0.9 exist
|
|
73
|
-
- **Status**: Changes present (expected before commit)
|
|
74
|
-
- **Sensitive Files**: ✅ None found (only documentation mentions)
|
|
75
|
-
|
|
76
|
-
### 8. Build Verification ✅
|
|
77
|
-
- **Status**: N/A (No build step required)
|
|
78
|
-
- **Note**: This is a pure JavaScript library, no compilation needed
|
|
79
|
-
|
|
80
|
-
### 9. Local Publication Verification ✅
|
|
81
|
-
- **Status**: PASSED
|
|
82
|
-
- **Exports Test**: ✅ All exports working
|
|
83
|
-
- USB ✅
|
|
84
|
-
- Serial ✅
|
|
85
|
-
- Printer ✅
|
|
86
|
-
- Adapter ✅
|
|
87
|
-
- Image ✅
|
|
88
|
-
|
|
89
|
-
### 10. Versioning Verification ✅
|
|
90
|
-
- **Status**: PASSED
|
|
91
|
-
- **Current Version**: 0.0.14
|
|
92
|
-
- **Next Version**: 0.1.0 (minor update)
|
|
93
|
-
- **Semantic Versioning**: ✅ Follows semver
|
|
94
|
-
- **CHANGELOG**: ✅ Version 0.0.14 found in CHANGELOG
|
|
95
|
-
- **Breaking Changes**: None in public API
|
|
96
|
-
|
|
97
|
-
### 11. Package Metadata Verification ✅
|
|
98
|
-
- **Status**: PASSED
|
|
99
|
-
- **Name**: `@risleylima/escpos` ✅
|
|
100
|
-
- **Version**: `0.0.14` ✅
|
|
101
|
-
- **Description**: "Library to deal with ESCPOS using some adapters" ✅
|
|
102
|
-
- **Main**: `index.js` ✅
|
|
103
|
-
- **Keywords**: ["EscPos", "USB"] ✅
|
|
104
|
-
- **Author**: "Rlima Info" ✅
|
|
105
|
-
- **License**: "MIT" ✅
|
|
106
|
-
- **Repository**: `git+https://github.com/risleylima/escpos.git` ✅
|
|
107
|
-
- **Bugs**: `https://github.com/risleylima/escpos/issues` ✅
|
|
108
|
-
- **Homepage**: `https://github.com/risleylima/escpos#readme` ✅
|
|
109
|
-
|
|
110
|
-
### 12. Security Verification ✅
|
|
111
|
-
- **Status**: PASSED
|
|
112
|
-
- **Vulnerabilities**: 0 found
|
|
113
|
-
- **Sensitive Data**: ✅ None found
|
|
114
|
-
- No passwords
|
|
115
|
-
- No secrets
|
|
116
|
-
- No tokens
|
|
117
|
-
- No API keys
|
|
118
|
-
- **Note**: Only documentation mentions of these terms (expected)
|
|
119
|
-
|
|
120
|
-
### 13. Performance Verification ✅
|
|
121
|
-
- **Status**: PASSED
|
|
122
|
-
- **Load Time**: 0.083s (excellent)
|
|
123
|
-
- **Package Size**: Reasonable
|
|
124
|
-
- **Dependencies**: Only necessary ones included
|
|
125
|
-
|
|
126
|
-
### 14. Essential Files Verification ✅
|
|
127
|
-
- **Status**: PASSED
|
|
128
|
-
- **index.js**: ✅ Present
|
|
129
|
-
- **README.md**: ✅ Present
|
|
130
|
-
- **LICENSE**: ✅ Present
|
|
131
|
-
- **CHANGELOG.md**: ✅ Present
|
|
132
|
-
- **package.json**: ✅ Present
|
|
133
|
-
|
|
134
|
-
## 📊 Summary
|
|
135
|
-
|
|
136
|
-
| Category | Status | Details |
|
|
137
|
-
|----------|--------|---------|
|
|
138
|
-
| Package | ✅ PASSED | All files correctly included |
|
|
139
|
-
| Dependencies | ✅ PASSED | 0 vulnerabilities, all up to date |
|
|
140
|
-
| Code | ✅ PASSED | No errors, fast load time |
|
|
141
|
-
| Tests | ✅ PASSED | 145 tests, 100% coverage |
|
|
142
|
-
| Compatibility | ✅ PASSED | Node.js >=18.0.0 |
|
|
143
|
-
| Documentation | ✅ PASSED | Complete and in English |
|
|
144
|
-
| Git | ✅ PASSED | On main branch |
|
|
145
|
-
| Exports | ✅ PASSED | All working |
|
|
146
|
-
| Versioning | ✅ PASSED | Follows semver |
|
|
147
|
-
| Metadata | ✅ PASSED | All correct |
|
|
148
|
-
| Security | ✅ PASSED | 0 vulnerabilities |
|
|
149
|
-
| Performance | ✅ PASSED | Excellent |
|
|
150
|
-
| Files | ✅ PASSED | All present |
|
|
151
|
-
|
|
152
|
-
## 🎯 Ready for Publication
|
|
153
|
-
|
|
154
|
-
**All verifications passed!** The package was successfully published as v0.1.0.
|
|
155
|
-
|
|
156
|
-
### Next Steps:
|
|
157
|
-
1. Review CHANGELOG.md
|
|
158
|
-
2. Commit changes (if needed)
|
|
159
|
-
3. Run `npx np minor` to publish
|
|
160
|
-
|
|
161
|
-
### Notes:
|
|
162
|
-
- The package is in excellent condition
|
|
163
|
-
- All dependencies are up to date
|
|
164
|
-
- 100% test coverage achieved
|
|
165
|
-
- Documentation is complete and in English
|
|
166
|
-
- No security vulnerabilities
|
|
167
|
-
- Performance is excellent
|
|
168
|
-
|
|
169
|
-
---
|
|
170
|
-
|
|
171
|
-
**Verification completed successfully! ✅**
|
|
172
|
-
|
package/docs/VERSIONING.md
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
# Semantic Versioning Rules
|
|
2
|
-
|
|
3
|
-
This document defines the explicit versioning rules for this project.
|
|
4
|
-
|
|
5
|
-
## Version Format
|
|
6
|
-
|
|
7
|
-
Following [Semantic Versioning](https://semver.org/spec/v2.0.0.html): `MAJOR.MINOR.PATCH`
|
|
8
|
-
|
|
9
|
-
## Versioning Rules
|
|
10
|
-
|
|
11
|
-
### Starting from `0.0.0`:
|
|
12
|
-
|
|
13
|
-
#### MINOR Update: `0.0.0` → `0.0.1`
|
|
14
|
-
- **When to use**: Adding new features, functions, or methods
|
|
15
|
-
- **Examples**:
|
|
16
|
-
- Adding a new function like `Serial.listSerial()`
|
|
17
|
-
- Adding a new method to an existing class
|
|
18
|
-
- Adding new functionality that doesn't break existing code
|
|
19
|
-
- **Rule**: New features = increment MINOR (third number)
|
|
20
|
-
|
|
21
|
-
#### MAJOR Update: `0.0.0` → `0.1.0`
|
|
22
|
-
- **When to use**: Significant changes, major updates, or substantial improvements
|
|
23
|
-
- **Examples**:
|
|
24
|
-
- Major dependency updates (e.g., `usb@^1.9.1` → `usb@^2.16.0`)
|
|
25
|
-
- Major refactoring
|
|
26
|
-
- Significant architectural changes
|
|
27
|
-
- Multiple new features bundled together
|
|
28
|
-
- **Rule**: Major changes = increment MAJOR (second number) when in `0.x.x` range
|
|
29
|
-
|
|
30
|
-
#### BREAKING CHANGES: `0.0.0` → `1.0.0`
|
|
31
|
-
- **When to use**: Breaking changes to the public API
|
|
32
|
-
- **Examples**:
|
|
33
|
-
- Removing or renaming public methods
|
|
34
|
-
- Changing method signatures in a way that breaks existing code
|
|
35
|
-
- Removing exported modules
|
|
36
|
-
- Changing behavior in a way that breaks backward compatibility
|
|
37
|
-
- **Rule**: Breaking changes = increment to `1.0.0` (first number)
|
|
38
|
-
|
|
39
|
-
## Examples from This Project
|
|
40
|
-
|
|
41
|
-
### `0.0.14` → `0.0.15` (MINOR)
|
|
42
|
-
- Adding a single new function: `Serial.listSerial()`
|
|
43
|
-
- This is a **MINOR** update (patch increment)
|
|
44
|
-
|
|
45
|
-
### `0.0.14` → `0.1.0` (MAJOR)
|
|
46
|
-
- Major dependency updates (usb v1 → v2, serialport v12 → v13)
|
|
47
|
-
- Complete test suite addition
|
|
48
|
-
- Comprehensive documentation
|
|
49
|
-
- Multiple significant improvements bundled together
|
|
50
|
-
- This is a **MAJOR** update (minor increment in 0.x.x range)
|
|
51
|
-
|
|
52
|
-
### Future: `0.x.x` → `1.0.0` (BREAKING)
|
|
53
|
-
- If we remove `USB.listUSB()` method
|
|
54
|
-
- If we change `Printer` constructor signature
|
|
55
|
-
- If we remove support for a feature
|
|
56
|
-
- This would be a **BREAKING** change (major increment to 1.0.0)
|
|
57
|
-
|
|
58
|
-
## Decision Tree
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
Is it a bug fix or small correction?
|
|
62
|
-
YES → PATCH (0.0.0 → 0.0.1)
|
|
63
|
-
|
|
64
|
-
Is it a single new feature/function?
|
|
65
|
-
YES → MINOR (0.0.0 → 0.0.1)
|
|
66
|
-
|
|
67
|
-
Is it multiple features or major updates?
|
|
68
|
-
YES → MAJOR (0.0.0 → 0.1.0)
|
|
69
|
-
|
|
70
|
-
Does it break existing code/API?
|
|
71
|
-
YES → BREAKING (0.0.0 → 1.0.0)
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## Important Notes
|
|
75
|
-
|
|
76
|
-
1. **In `0.x.x` range**:
|
|
77
|
-
- The second number (MINOR) acts as MAJOR
|
|
78
|
-
- The third number (PATCH) acts as MINOR
|
|
79
|
-
- This is standard Semantic Versioning behavior for pre-1.0.0 versions
|
|
80
|
-
|
|
81
|
-
2. **After `1.0.0`**:
|
|
82
|
-
- Standard semver rules apply
|
|
83
|
-
- MAJOR.MINOR.PATCH
|
|
84
|
-
- Breaking changes = MAJOR increment
|
|
85
|
-
- New features = MINOR increment
|
|
86
|
-
- Bug fixes = PATCH increment
|
|
87
|
-
|
|
88
|
-
3. **Always consider**:
|
|
89
|
-
- Impact on users
|
|
90
|
-
- Backward compatibility
|
|
91
|
-
- Number of changes
|
|
92
|
-
- Significance of changes
|
|
93
|
-
|
|
94
|
-
## Summary Table
|
|
95
|
-
|
|
96
|
-
| Change Type | From `0.0.0` | Example |
|
|
97
|
-
|-------------|--------------|---------|
|
|
98
|
-
| Bug fix | `0.0.1` | Fix typo, fix error handling |
|
|
99
|
-
| New function/method | `0.0.1` | Add `Serial.listSerial()` |
|
|
100
|
-
| Major updates | `0.1.0` | Dependency updates, major refactoring |
|
|
101
|
-
| Breaking changes | `1.0.0` | Remove API, change signatures |
|
|
102
|
-
|
package/examples/printTest.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
// DEBUGGER
|
|
3
|
-
const debug = require('debug')('escpos:test-printer');
|
|
4
|
-
|
|
5
|
-
//IMPORT USB ADAPTER
|
|
6
|
-
const USB = require('../src/usb-adapter');
|
|
7
|
-
|
|
8
|
-
//IMPORT PRINTER MANAGER
|
|
9
|
-
const Printer = require('../src/printer');
|
|
10
|
-
|
|
11
|
-
let print = async (printer, n) => {
|
|
12
|
-
printer.hardware('init');
|
|
13
|
-
printer
|
|
14
|
-
.beep(2, 1)
|
|
15
|
-
.encode(860)
|
|
16
|
-
.size(2, 2)
|
|
17
|
-
.align('ct')
|
|
18
|
-
.textln('PRINT CUPOM TEST')
|
|
19
|
-
.size(1, 1)
|
|
20
|
-
.textln(`Cupom Nº ${n}`)
|
|
21
|
-
.align('lt')
|
|
22
|
-
.textln(`Mr. Fulano Maluco`)
|
|
23
|
-
.textln(`TEL: +55 (11) 3453-6549`)
|
|
24
|
-
.textln(`ADDRESS: Rua Prof. Vida Louca, 500 - Casa B`)
|
|
25
|
-
.textln(`POSTAL CODE: 56589-085 - MARINGA - PR`)
|
|
26
|
-
.align('ct')
|
|
27
|
-
.textln(`What is your favorite color?`)
|
|
28
|
-
.align('lt')
|
|
29
|
-
.textln('(___) Red')
|
|
30
|
-
.textln('(___) Green')
|
|
31
|
-
.textln('(___) Other: __________________________')
|
|
32
|
-
.align('ct')
|
|
33
|
-
.raw(printer.commands.TEXT_FORMAT.TXT_BOLDER)
|
|
34
|
-
.textln('Check the rules of this promotion')
|
|
35
|
-
.textln('FREE DISTRIBUTION')
|
|
36
|
-
.raw(printer.commands.TEXT_FORMAT.TXT_NORMAL)
|
|
37
|
-
.drawLine()
|
|
38
|
-
.cut(true);
|
|
39
|
-
|
|
40
|
-
await printer.flush();
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
(async () => {
|
|
44
|
-
let vid = 1046, pid = 20497;
|
|
45
|
-
await USB.connect(vid, pid);
|
|
46
|
-
const printerDevice = new Printer(USB);
|
|
47
|
-
|
|
48
|
-
for (let i = 0; i < 3; i++) {
|
|
49
|
-
await USB.open();
|
|
50
|
-
await print(printerDevice, i);
|
|
51
|
-
debug('Printed ' + i + ' of ' + 3);
|
|
52
|
-
await USB.close();
|
|
53
|
-
}
|
|
54
|
-
await USB.disconnect();
|
|
55
|
-
process.exit();
|
|
56
|
-
})().catch(e => {
|
|
57
|
-
debug(e);
|
|
58
|
-
process.exit();
|
|
59
|
-
});
|
package/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
const USB = require('./src/usb-adapter');
|
|
2
|
-
const Serial = require('./src/serial-adapter');
|
|
3
|
-
const Printer = require('./src/printer');
|
|
4
|
-
const Adapter = require('./src/adapter');
|
|
5
|
-
const Image = require('./src/printer/image');
|
|
6
|
-
|
|
7
|
-
module.exports = { USB, Serial, Printer, Adapter, Image }
|
package/jest.config.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
testEnvironment: 'node',
|
|
3
|
-
testMatch: [
|
|
4
|
-
'**/tests/**/*.test.js',
|
|
5
|
-
'**/__tests__/**/*.js'
|
|
6
|
-
],
|
|
7
|
-
collectCoverageFrom: [
|
|
8
|
-
'src/**/*.js',
|
|
9
|
-
'!src/**/index.js'
|
|
10
|
-
],
|
|
11
|
-
coverageDirectory: 'coverage',
|
|
12
|
-
coverageReporters: ['text', 'lcov', 'html'],
|
|
13
|
-
verbose: true,
|
|
14
|
-
testTimeout: 10000
|
|
15
|
-
};
|
|
16
|
-
|
package/src/adapter/index.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
const EventEmitter = require('events');
|
|
3
|
-
|
|
4
|
-
class NotImplementedException extends Error {
|
|
5
|
-
// Nothing.
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Generic Adapter that will implement the different types of adapter that will be constructed
|
|
10
|
-
* @class
|
|
11
|
-
* @extends EventEmitter
|
|
12
|
-
* @classdesc Base adapter class that provides the interface for USB and Serial adapters
|
|
13
|
-
*/
|
|
14
|
-
class Adapter extends EventEmitter {
|
|
15
|
-
/**
|
|
16
|
-
* Creates an instance of Adapter
|
|
17
|
-
* @param {Adapter} [adapter] - Optional adapter instance to copy properties from
|
|
18
|
-
*/
|
|
19
|
-
constructor(adapter) {
|
|
20
|
-
super();
|
|
21
|
-
if (adapter) {
|
|
22
|
-
for(let key of Object.keys(adapter)){
|
|
23
|
-
this[key] = adapter[key];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Connect to the device
|
|
30
|
-
* @abstract
|
|
31
|
-
* @throws {NotImplementedException} Must be implemented by subclasses
|
|
32
|
-
*/
|
|
33
|
-
connect() {
|
|
34
|
-
throw new NotImplementedException();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Open the device connection
|
|
39
|
-
* @abstract
|
|
40
|
-
* @throws {NotImplementedException} Must be implemented by subclasses
|
|
41
|
-
*/
|
|
42
|
-
open() {
|
|
43
|
-
throw new NotImplementedException();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Write data to the device
|
|
48
|
-
* @abstract
|
|
49
|
-
* @param {Buffer} data - Data to write
|
|
50
|
-
* @throws {NotImplementedException} Must be implemented by subclasses
|
|
51
|
-
*/
|
|
52
|
-
write() {
|
|
53
|
-
throw new NotImplementedException();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Close the device connection
|
|
58
|
-
* @abstract
|
|
59
|
-
* @throws {NotImplementedException} Must be implemented by subclasses
|
|
60
|
-
*/
|
|
61
|
-
close() {
|
|
62
|
-
throw new NotImplementedException();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Read data from the device
|
|
67
|
-
* @abstract
|
|
68
|
-
* @throws {NotImplementedException} Must be implemented by subclasses
|
|
69
|
-
*/
|
|
70
|
-
read() {
|
|
71
|
-
throw new NotImplementedException();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
module.exports = Adapter;
|