@risleylima/escpos 0.2.1 → 1.0.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 +116 -755
- 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 +21 -0
- package/dist/serial-adapter/index.d.ts.map +1 -0
- package/dist/serial-adapter/index.js +180 -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,331 +0,0 @@
|
|
|
1
|
-
# Pre-Publish Checklist
|
|
2
|
-
|
|
3
|
-
This document lists all additional checks possible before publishing a new version to NPM.
|
|
4
|
-
|
|
5
|
-
## ✅ Basic Checks (Already Done)
|
|
6
|
-
|
|
7
|
-
- [x] Tests passing (145 tests, 100% coverage)
|
|
8
|
-
- [x] Exports working correctly
|
|
9
|
-
- [x] Essential files present (index.js, README.md, LICENSE)
|
|
10
|
-
- [x] Valid package.json
|
|
11
|
-
- [x] CHANGELOG.md created
|
|
12
|
-
|
|
13
|
-
## 🔍 Additional Recommended Checks
|
|
14
|
-
|
|
15
|
-
### 1. NPM Package Verification
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
# Simulate what will be published
|
|
19
|
-
npm pack --dry-run
|
|
20
|
-
|
|
21
|
-
# Check package size
|
|
22
|
-
npm pack
|
|
23
|
-
tar -tzf *.tgz | wc -l # Count files
|
|
24
|
-
du -h *.tgz # Tarball size
|
|
25
|
-
rm *.tgz # Clean up
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
**What to check:**
|
|
29
|
-
- ✅ Only necessary files are included
|
|
30
|
-
- ✅ `node_modules` is not included
|
|
31
|
-
- ✅ Build/test files are not included
|
|
32
|
-
- ✅ `.git` is not included
|
|
33
|
-
- ✅ Reasonable package size
|
|
34
|
-
|
|
35
|
-
### 2. Dependencies Verification
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
# Check installed dependencies
|
|
39
|
-
yarn list --depth=0
|
|
40
|
-
|
|
41
|
-
# Check vulnerabilities
|
|
42
|
-
npm audit
|
|
43
|
-
# or
|
|
44
|
-
yarn audit
|
|
45
|
-
|
|
46
|
-
# Check outdated dependencies
|
|
47
|
-
npm outdated
|
|
48
|
-
# or
|
|
49
|
-
yarn outdated
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
**What to check:**
|
|
53
|
-
- ✅ No known vulnerabilities
|
|
54
|
-
- ✅ Dependencies are at correct versions
|
|
55
|
-
- ✅ Peer dependencies documented (if any)
|
|
56
|
-
|
|
57
|
-
### 3. Code Verification
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
# Check syntax (if using linter)
|
|
61
|
-
npm run lint # if configured
|
|
62
|
-
|
|
63
|
-
# Check types (if using TypeScript)
|
|
64
|
-
npm run type-check # if configured
|
|
65
|
-
|
|
66
|
-
# Check formatting
|
|
67
|
-
npm run format:check # if configured
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
**What to check:**
|
|
71
|
-
- ✅ No syntax errors
|
|
72
|
-
- ✅ No critical warnings
|
|
73
|
-
- ✅ Code consistently formatted
|
|
74
|
-
|
|
75
|
-
### 4. Test Verification
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
# Run all tests
|
|
79
|
-
yarn test
|
|
80
|
-
|
|
81
|
-
# Run tests with coverage
|
|
82
|
-
yarn test:coverage
|
|
83
|
-
|
|
84
|
-
# Check if coverage is above threshold
|
|
85
|
-
# (if configured in jest.config.js)
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
**What to check:**
|
|
89
|
-
- ✅ All tests passing
|
|
90
|
-
- ✅ Adequate coverage (100% in our case)
|
|
91
|
-
- ✅ Integration tests passing
|
|
92
|
-
- ✅ Tests on different Node.js versions (if applicable)
|
|
93
|
-
|
|
94
|
-
### 5. Compatibility Verification
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
# Test on different Node.js versions
|
|
98
|
-
nvm use 18
|
|
99
|
-
yarn test
|
|
100
|
-
|
|
101
|
-
nvm use 20
|
|
102
|
-
yarn test
|
|
103
|
-
|
|
104
|
-
# Check engines in package.json
|
|
105
|
-
node -e "console.log(require('./package.json').engines)"
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
**What to check:**
|
|
109
|
-
- ✅ Compatible with Node.js >= 18.0.0 (as per package.json)
|
|
110
|
-
- ✅ Tested on minimum supported version
|
|
111
|
-
- ✅ Tested on current LTS version
|
|
112
|
-
|
|
113
|
-
### 6. Documentation Verification
|
|
114
|
-
|
|
115
|
-
```bash
|
|
116
|
-
# Check if README is updated
|
|
117
|
-
# Check if CHANGELOG is updated
|
|
118
|
-
# Check if examples work
|
|
119
|
-
node examples/printTest.js # (without connecting real hardware)
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
**What to check:**
|
|
123
|
-
- ✅ README.md complete and updated
|
|
124
|
-
- ✅ CHANGELOG.md with all changes
|
|
125
|
-
- ✅ Code examples work
|
|
126
|
-
- ✅ API documentation is correct
|
|
127
|
-
- ✅ Links working
|
|
128
|
-
|
|
129
|
-
### 7. Git Verification
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
# Check git status
|
|
133
|
-
git status
|
|
134
|
-
|
|
135
|
-
# Check for uncommitted changes
|
|
136
|
-
git diff
|
|
137
|
-
|
|
138
|
-
# Check existing tags
|
|
139
|
-
git tag -l
|
|
140
|
-
|
|
141
|
-
# Check last commit
|
|
142
|
-
git log -1
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
**What to check:**
|
|
146
|
-
- ✅ All changes committed (or intentionally uncommitted)
|
|
147
|
-
- ✅ Correct branch (usually `main` or `master`)
|
|
148
|
-
- ✅ No sensitive files (tokens, passwords, etc.)
|
|
149
|
-
- ✅ `.gitignore` properly configured
|
|
150
|
-
|
|
151
|
-
### 8. Build Verification (if applicable)
|
|
152
|
-
|
|
153
|
-
```bash
|
|
154
|
-
# If there's a build step
|
|
155
|
-
npm run build
|
|
156
|
-
|
|
157
|
-
# Check if build files were generated
|
|
158
|
-
ls -la dist/ # or build folder
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
**What to check:**
|
|
162
|
-
- ✅ Build completes without errors
|
|
163
|
-
- ✅ Build files generated correctly
|
|
164
|
-
- ✅ Build files included in package (if necessary)
|
|
165
|
-
|
|
166
|
-
### 9. Local Publication Verification
|
|
167
|
-
|
|
168
|
-
```bash
|
|
169
|
-
# Install package locally to test
|
|
170
|
-
npm link
|
|
171
|
-
# or
|
|
172
|
-
cd /tmp
|
|
173
|
-
npm install /path/to/escpos
|
|
174
|
-
|
|
175
|
-
# Test import
|
|
176
|
-
node -e "const { USB, Serial, Printer } = require('@risleylima/escpos'); console.log('OK')"
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
**What to check:**
|
|
180
|
-
- ✅ Package can be installed
|
|
181
|
-
- ✅ Exports work after installation
|
|
182
|
-
- ✅ Dependencies are installed correctly
|
|
183
|
-
|
|
184
|
-
### 10. Versioning Verification
|
|
185
|
-
|
|
186
|
-
```bash
|
|
187
|
-
# Check current version
|
|
188
|
-
node -e "console.log(require('./package.json').version)"
|
|
189
|
-
|
|
190
|
-
# Check if version follows semantic versioning
|
|
191
|
-
# MAJOR.MINOR.PATCH
|
|
192
|
-
# 0.0.14 -> 0.1.0 (minor update)
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
**What to check:**
|
|
196
|
-
- ✅ Version follows Semantic Versioning
|
|
197
|
-
- ✅ Version in package.json is correct
|
|
198
|
-
- ✅ Version in CHANGELOG is correct
|
|
199
|
-
- ✅ Breaking changes documented (if any)
|
|
200
|
-
|
|
201
|
-
### 11. Package Metadata Verification
|
|
202
|
-
|
|
203
|
-
```bash
|
|
204
|
-
# Check package.json
|
|
205
|
-
node -e "const pkg = require('./package.json'); console.log(JSON.stringify({
|
|
206
|
-
name: pkg.name,
|
|
207
|
-
version: pkg.version,
|
|
208
|
-
description: pkg.description,
|
|
209
|
-
main: pkg.main,
|
|
210
|
-
keywords: pkg.keywords,
|
|
211
|
-
author: pkg.author,
|
|
212
|
-
license: pkg.license,
|
|
213
|
-
repository: pkg.repository,
|
|
214
|
-
bugs: pkg.bugs,
|
|
215
|
-
homepage: pkg.homepage
|
|
216
|
-
}, null, 2))"
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
**What to check:**
|
|
220
|
-
- ✅ Package name correct
|
|
221
|
-
- ✅ Clear and updated description
|
|
222
|
-
- ✅ Relevant keywords
|
|
223
|
-
- ✅ Correct author and license
|
|
224
|
-
- ✅ Repository, bugs, and homepage links working
|
|
225
|
-
|
|
226
|
-
### 12. Security Verification
|
|
227
|
-
|
|
228
|
-
```bash
|
|
229
|
-
# Check vulnerabilities
|
|
230
|
-
npm audit
|
|
231
|
-
yarn audit
|
|
232
|
-
|
|
233
|
-
# Check for sensitive files
|
|
234
|
-
grep -r "password\|secret\|token\|api_key" --exclude-dir=node_modules .
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
**What to check:**
|
|
238
|
-
- ✅ No known vulnerabilities
|
|
239
|
-
- ✅ No hardcoded credentials
|
|
240
|
-
- ✅ No tokens or API keys in code
|
|
241
|
-
|
|
242
|
-
### 13. Performance Verification (Optional)
|
|
243
|
-
|
|
244
|
-
```bash
|
|
245
|
-
# Test load time
|
|
246
|
-
time node -e "require('./index.js')"
|
|
247
|
-
|
|
248
|
-
# Check bundle size (if applicable)
|
|
249
|
-
npm run build:analyze # if configured
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
**What to check:**
|
|
253
|
-
- ✅ Reasonable load time
|
|
254
|
-
- ✅ Optimized package size
|
|
255
|
-
- ✅ No unnecessary dependencies
|
|
256
|
-
|
|
257
|
-
### 14. Accessibility Verification (Optional)
|
|
258
|
-
|
|
259
|
-
```bash
|
|
260
|
-
# Check if README is readable
|
|
261
|
-
# Check if examples are clear
|
|
262
|
-
# Check if documentation is complete
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
**What to check:**
|
|
266
|
-
- ✅ README well formatted
|
|
267
|
-
- ✅ Clear and functional examples
|
|
268
|
-
- ✅ Complete documentation
|
|
269
|
-
|
|
270
|
-
## 🚀 `np` Commands
|
|
271
|
-
|
|
272
|
-
The `np` tool automatically performs many of these checks:
|
|
273
|
-
|
|
274
|
-
```bash
|
|
275
|
-
npx np minor
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
**What `np` automatically checks:**
|
|
279
|
-
- ✅ Git status (uncommitted changes)
|
|
280
|
-
- ✅ Correct branch
|
|
281
|
-
- ✅ Tests (if configured)
|
|
282
|
-
- ✅ Build (if configured)
|
|
283
|
-
- ✅ Versioning
|
|
284
|
-
- ✅ Git tag
|
|
285
|
-
- ✅ NPM publication
|
|
286
|
-
|
|
287
|
-
## 📋 Final Checklist Before Publishing
|
|
288
|
-
|
|
289
|
-
- [ ] All tests passing
|
|
290
|
-
- [ ] Adequate test coverage
|
|
291
|
-
- [ ] CHANGELOG.md updated
|
|
292
|
-
- [ ] README.md updated
|
|
293
|
-
- [ ] No known vulnerabilities
|
|
294
|
-
- [ ] Dependencies updated
|
|
295
|
-
- [ ] Code reviewed
|
|
296
|
-
- [ ] Git status clean (or intentional changes)
|
|
297
|
-
- [ ] Correct version in package.json
|
|
298
|
-
- [ ] Correct version in CHANGELOG
|
|
299
|
-
- [ ] Package metadata correct
|
|
300
|
-
- [ ] Examples tested (if possible)
|
|
301
|
-
- [ ] Compatibility verified
|
|
302
|
-
|
|
303
|
-
## 🎯 Specific Recommendations for This Version
|
|
304
|
-
|
|
305
|
-
For v0.1.0, check especially:
|
|
306
|
-
|
|
307
|
-
1. **Major Dependency Updates:**
|
|
308
|
-
- [x] `usb@^2.16.0` - Promise-based API working
|
|
309
|
-
- [x] `serialport@^13.0.0` - Promise-based API working
|
|
310
|
-
- [x] Tests updated for new APIs
|
|
311
|
-
|
|
312
|
-
2. **Documentation:**
|
|
313
|
-
- [x] Complete README
|
|
314
|
-
- [x] CHANGELOG created
|
|
315
|
-
- [x] Complete JSDoc
|
|
316
|
-
|
|
317
|
-
3. **Tests:**
|
|
318
|
-
- [x] 100% coverage
|
|
319
|
-
- [x] All tests passing
|
|
320
|
-
|
|
321
|
-
4. **Compatibility:**
|
|
322
|
-
- [x] Public API maintained (no breaking changes)
|
|
323
|
-
- [x] Exports working
|
|
324
|
-
|
|
325
|
-
## ⚠️ Important Notes
|
|
326
|
-
|
|
327
|
-
- **Internal Breaking Changes**: The `usb` and `serialport` updates are major, but the library's public API has not changed. It's safe to publish as a minor update.
|
|
328
|
-
|
|
329
|
-
- **Hardware Testing**: If possible, test with real hardware before publishing, especially after the `usb` and `serialport` updates.
|
|
330
|
-
|
|
331
|
-
- **Rollback Plan**: Have a rollback plan in case something goes wrong after publication.
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
# Public API Analysis - Breaking Changes Impact
|
|
2
|
-
|
|
3
|
-
## 📦 What the Library Exports
|
|
4
|
-
|
|
5
|
-
### Main Exports (`index.js`)
|
|
6
|
-
```javascript
|
|
7
|
-
module.exports = {
|
|
8
|
-
USB, // USB Adapter instance
|
|
9
|
-
Serial, // Serial Adapter instance
|
|
10
|
-
Printer, // Printer class
|
|
11
|
-
Adapter, // Base Adapter class
|
|
12
|
-
Image // Image class
|
|
13
|
-
}
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## 🔌 Public API - Adapters
|
|
17
|
-
|
|
18
|
-
### USB Adapter Public Methods
|
|
19
|
-
```javascript
|
|
20
|
-
USB.connect(vid, pid) // Returns: Promise<boolean>
|
|
21
|
-
USB.open() // Returns: Promise<boolean>
|
|
22
|
-
USB.write(data) // Returns: Promise<boolean>
|
|
23
|
-
USB.close() // Returns: Promise<boolean>
|
|
24
|
-
USB.disconnect() // Returns: Promise<boolean>
|
|
25
|
-
USB.listUSB() // Returns: Promise<Device[]>
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### Serial Adapter Public Methods
|
|
29
|
-
```javascript
|
|
30
|
-
Serial.connect(port, options) // Returns: Promise<boolean>
|
|
31
|
-
Serial.open() // Returns: Promise<boolean>
|
|
32
|
-
Serial.write(data) // Returns: Promise<boolean>
|
|
33
|
-
Serial.close(timeout) // Returns: Promise<boolean>
|
|
34
|
-
Serial.disconnect(timeout) // Returns: Promise<boolean>
|
|
35
|
-
Serial.read() // Returns: Promise<Buffer>
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### Printer Public Methods
|
|
39
|
-
```javascript
|
|
40
|
-
// Constructor
|
|
41
|
-
new Printer(adapter, options)
|
|
42
|
-
|
|
43
|
-
// Text operations
|
|
44
|
-
printer.text(content, encoding)
|
|
45
|
-
printer.textln(content, encoding)
|
|
46
|
-
printer.print(content)
|
|
47
|
-
printer.println(content)
|
|
48
|
-
|
|
49
|
-
// Formatting
|
|
50
|
-
printer.align('lt'|'ct'|'rt')
|
|
51
|
-
printer.size(width, height)
|
|
52
|
-
printer.font('A'|'B'|'C')
|
|
53
|
-
printer.style('B'|'I'|'U'|'NORMAL'|...)
|
|
54
|
-
printer.encode(encoding)
|
|
55
|
-
|
|
56
|
-
// Paper control
|
|
57
|
-
printer.feed(n)
|
|
58
|
-
printer.drawLine(character)
|
|
59
|
-
printer.cut(partial, feed)
|
|
60
|
-
|
|
61
|
-
// Hardware
|
|
62
|
-
printer.hardware('init'|'select'|'reset')
|
|
63
|
-
printer.beep(n, t)
|
|
64
|
-
printer.cashdraw(pin)
|
|
65
|
-
|
|
66
|
-
// Barcodes
|
|
67
|
-
printer.barcode(code, type, options)
|
|
68
|
-
|
|
69
|
-
// Images
|
|
70
|
-
printer.image(image, density)
|
|
71
|
-
printer.raster(image, mode)
|
|
72
|
-
|
|
73
|
-
// Colors
|
|
74
|
-
printer.color(0|1)
|
|
75
|
-
printer.setReverseColors(bool)
|
|
76
|
-
|
|
77
|
-
// Raw commands
|
|
78
|
-
printer.raw(data)
|
|
79
|
-
|
|
80
|
-
// Control
|
|
81
|
-
printer.flush() // Returns: Promise<Printer>
|
|
82
|
-
printer.close() // Returns: Promise<Printer>
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
## 🔍 Impact Analysis
|
|
86
|
-
|
|
87
|
-
### ✅ GOOD NEWS: No Breaking Changes to Public API!
|
|
88
|
-
|
|
89
|
-
#### 1. Adapter Interface Remains the Same
|
|
90
|
-
- **USB Adapter**: All methods already return Promises
|
|
91
|
-
- **Serial Adapter**: All methods already return Promises
|
|
92
|
-
- **Method signatures**: Unchanged
|
|
93
|
-
- **Return types**: Unchanged (all Promises)
|
|
94
|
-
|
|
95
|
-
#### 2. Internal Implementation Changes Only
|
|
96
|
-
- **USB v2 migration**: Internal implementation changed (callbacks → Promises)
|
|
97
|
-
- **SerialPort v13 migration**: Internal implementation will change (callbacks → Promises)
|
|
98
|
-
- **Public API**: Remains exactly the same
|
|
99
|
-
|
|
100
|
-
#### 3. Printer Class Unaffected
|
|
101
|
-
- Printer class doesn't directly use USB/SerialPort
|
|
102
|
-
- Uses adapters through the Adapter interface
|
|
103
|
-
- No changes needed
|
|
104
|
-
|
|
105
|
-
### 📊 Compatibility Matrix
|
|
106
|
-
|
|
107
|
-
| Component | Internal Change | Public API Change | Breaking Change? |
|
|
108
|
-
|-----------|----------------|-------------------|------------------|
|
|
109
|
-
| USB Adapter | ✅ v1 → v2 (callbacks → Promises) | ❌ None | ❌ **NO** |
|
|
110
|
-
| Serial Adapter | ✅ v12 → v13 (callbacks → Promises) | ❌ None | ❌ **NO** |
|
|
111
|
-
| Printer | ❌ None | ❌ None | ❌ **NO** |
|
|
112
|
-
| Adapter Base | ❌ None | ❌ None | ❌ **NO** |
|
|
113
|
-
| Image | ❌ None | ❌ None | ❌ **NO** |
|
|
114
|
-
|
|
115
|
-
## 🎯 User Code Examples
|
|
116
|
-
|
|
117
|
-
### Example 1: USB Usage (Won't Change)
|
|
118
|
-
```javascript
|
|
119
|
-
const { USB, Printer } = require('@risleylima/escpos');
|
|
120
|
-
|
|
121
|
-
// This code will work EXACTLY the same after updates
|
|
122
|
-
await USB.connect(1046, 20497);
|
|
123
|
-
const printer = new Printer(USB);
|
|
124
|
-
await USB.open();
|
|
125
|
-
printer.textln('Hello');
|
|
126
|
-
await printer.flush();
|
|
127
|
-
await USB.close();
|
|
128
|
-
await USB.disconnect();
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### Example 2: Serial Usage (Won't Change)
|
|
132
|
-
```javascript
|
|
133
|
-
const { Serial, Printer } = require('@risleylima/escpos');
|
|
134
|
-
|
|
135
|
-
// This code will work EXACTLY the same after updates
|
|
136
|
-
await Serial.connect('/dev/ttyUSB0');
|
|
137
|
-
const printer = new Printer(Serial);
|
|
138
|
-
await Serial.open();
|
|
139
|
-
printer.textln('Hello');
|
|
140
|
-
await printer.flush();
|
|
141
|
-
await Serial.close();
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
### Example 3: Printer Usage (Won't Change)
|
|
145
|
-
```javascript
|
|
146
|
-
const { Printer } = require('@risleylima/escpos');
|
|
147
|
-
|
|
148
|
-
// All Printer methods remain the same
|
|
149
|
-
printer
|
|
150
|
-
.align('ct')
|
|
151
|
-
.size(2, 2)
|
|
152
|
-
.textln('Title')
|
|
153
|
-
.cut(true);
|
|
154
|
-
await printer.flush();
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
## ✅ Conclusion
|
|
158
|
-
|
|
159
|
-
### **NO BREAKING CHANGES FOR USERS!**
|
|
160
|
-
|
|
161
|
-
1. **Public API**: Completely unchanged
|
|
162
|
-
2. **Method signatures**: Identical
|
|
163
|
-
3. **Return types**: Same (all Promises)
|
|
164
|
-
4. **Usage patterns**: No changes needed
|
|
165
|
-
5. **Backward compatibility**: 100% maintained
|
|
166
|
-
|
|
167
|
-
### Why No Breaking Changes?
|
|
168
|
-
|
|
169
|
-
1. **Abstraction Layer**: Adapters abstract away the underlying libraries
|
|
170
|
-
2. **Promise-based API**: Public API was already Promise-based
|
|
171
|
-
3. **Internal Only**: Changes are purely internal implementation
|
|
172
|
-
4. **Interface Contract**: Adapter interface contract remains the same
|
|
173
|
-
|
|
174
|
-
### What Users Need to Know
|
|
175
|
-
|
|
176
|
-
#### ✅ No Action Required
|
|
177
|
-
- Existing code will continue to work
|
|
178
|
-
- No code changes needed
|
|
179
|
-
- No API changes
|
|
180
|
-
|
|
181
|
-
#### ⚠️ Potential Considerations
|
|
182
|
-
- **Node.js version**: Ensure Node.js >= 18.0.0 (already required)
|
|
183
|
-
- **Native modules**: May need rebuild after `npm install`
|
|
184
|
-
- **Dependencies**: Will get updated versions automatically
|
|
185
|
-
|
|
186
|
-
### Version Strategy
|
|
187
|
-
|
|
188
|
-
Since there are **NO breaking changes** to the public API:
|
|
189
|
-
- **Minor version bump**: `0.0.14` → `0.1.0` (published)
|
|
190
|
-
|
|
191
|
-
**NOT a major version** because public API is unchanged.
|
|
192
|
-
|
|
193
|
-
## 📝 Migration Notes for Library Maintainers
|
|
194
|
-
|
|
195
|
-
### Internal Changes Summary
|
|
196
|
-
|
|
197
|
-
1. **USB Adapter** (`src/usb-adapter/index.js`)
|
|
198
|
-
- ✅ Updated to use `usb@^2.16.0`
|
|
199
|
-
- ✅ Converted callbacks to async/await
|
|
200
|
-
- ✅ Public API unchanged
|
|
201
|
-
|
|
202
|
-
2. **Serial Adapter** (`src/serial-adapter/index.js`) - To be done
|
|
203
|
-
- ⏳ Will update to `serialport@^13.0.0`
|
|
204
|
-
- ⏳ Will convert callbacks to async/await
|
|
205
|
-
- ✅ Public API will remain unchanged
|
|
206
|
-
|
|
207
|
-
3. **Printer** (`src/printer/index.js`)
|
|
208
|
-
- ✅ No changes needed
|
|
209
|
-
- ✅ Uses adapters through interface
|
|
210
|
-
|
|
211
|
-
### Testing Strategy
|
|
212
|
-
|
|
213
|
-
1. ✅ Unit tests updated for new implementations
|
|
214
|
-
2. ✅ Integration tests verify public API
|
|
215
|
-
3. ⚠️ Test with real hardware (recommended)
|
|
216
|
-
4. ✅ Backward compatibility verified
|
|
217
|
-
|
|
218
|
-
## 🎉 Summary
|
|
219
|
-
|
|
220
|
-
**Users can update with confidence!**
|
|
221
|
-
|
|
222
|
-
The library maintains 100% backward compatibility. All changes are internal improvements that don't affect the public API. Existing code will work without any modifications.
|
|
223
|
-
|
package/docs/README.md
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# Documentation
|
|
2
|
-
|
|
3
|
-
This directory contains additional documentation for the EscPos library.
|
|
4
|
-
|
|
5
|
-
## Available Documents
|
|
6
|
-
|
|
7
|
-
### [Library Overview](./LIBRARY_OVERVIEW.md) ⭐
|
|
8
|
-
Comprehensive overview of the library including architecture, features, test coverage, dependencies, and recent improvements.
|
|
9
|
-
|
|
10
|
-
### [USB v2 Review](./USB_V2_REVIEW.md)
|
|
11
|
-
Complete review of codebase compatibility with USB v2, including all changes made, test updates, and verification checklist.
|
|
12
|
-
|
|
13
|
-
### [SerialPort v13 Migration](./SERIALPORT_V13_MIGRATION_COMPLETE.md)
|
|
14
|
-
Documentation about the migration from `serialport@^12.0.0` to `serialport@^13.0.0`, including API changes and implementation details.
|
|
15
|
-
|
|
16
|
-
### [Dependencies Review](./DEPENDENCIES_REVIEW.md)
|
|
17
|
-
Current status of all dependencies, update history, and recommendations.
|
|
18
|
-
|
|
19
|
-
### [Tests Implementation](./TESTS_IMPLEMENTED.md)
|
|
20
|
-
Complete documentation about the test suite implementation, coverage, and testing strategy.
|
|
21
|
-
|
|
22
|
-
### [Test Coverage Analysis](./COVERAGE_ANALYSIS.md)
|
|
23
|
-
Detailed analysis of test coverage, including branch coverage and steps taken to achieve 100% coverage.
|
|
24
|
-
|
|
25
|
-
### [JSDoc Review](./JSDOC_REVIEW.md)
|
|
26
|
-
Complete review of JSDoc documentation coverage across the library.
|
|
27
|
-
|
|
28
|
-
### [Public API Analysis](./PUBLIC_API_ANALYSIS.md)
|
|
29
|
-
Detailed analysis of the public API and exported modules, including breaking changes impact assessment.
|
|
30
|
-
|
|
31
|
-
### [Versioning Rules](./VERSIONING.md) ⚠️
|
|
32
|
-
Explicit semantic versioning rules for the project. **Read this before publishing any version update.**
|
|
33
|
-
|
|
34
|
-
## Main Documentation
|
|
35
|
-
|
|
36
|
-
- **README.md** (root) - Main project documentation with installation, usage examples, and API reference
|
|
37
|
-
- **tests/README.md** - Test suite documentation
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
# SerialPort v13 Migration - Complete
|
|
2
|
-
|
|
3
|
-
## ✅ Migration Executed
|
|
4
|
-
|
|
5
|
-
Successfully migrated from `serialport@^12.0.0` to `serialport@^13.0.0`.
|
|
6
|
-
|
|
7
|
-
## Changes Made
|
|
8
|
-
|
|
9
|
-
### 1. Package Update
|
|
10
|
-
- ✅ Updated `package.json`: `"serialport": "^12.0.0"` → `"serialport": "^13.0.0"`
|
|
11
|
-
|
|
12
|
-
### 2. Code Migration (`src/serial-adapter/index.js`)
|
|
13
|
-
|
|
14
|
-
#### Constructor Changes
|
|
15
|
-
**Before (v12):**
|
|
16
|
-
```javascript
|
|
17
|
-
scope.port = new SerialPort({ path, autoOpen: true }, (err) => {
|
|
18
|
-
// callback
|
|
19
|
-
});
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
**After (v13):**
|
|
23
|
-
```javascript
|
|
24
|
-
scope.port = new SerialPort({ path, autoOpen: false });
|
|
25
|
-
// Handle errors via events
|
|
26
|
-
scope.port.on('error', (err) => { /* ... */ });
|
|
27
|
-
await scope.port.open(); // Open manually
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
#### Method Conversions
|
|
31
|
-
|
|
32
|
-
| Method | v12 (Callback) | v13 (Promise) |
|
|
33
|
-
|--------|----------------|---------------|
|
|
34
|
-
| `connect()` | Callback-based | ✅ `async/await` |
|
|
35
|
-
| `open()` | `port.open(callback)` | ✅ `await port.open()` |
|
|
36
|
-
| `write()` | `port.write(data, callback)` | ✅ `await port.write(data)` |
|
|
37
|
-
| `close()` | Nested callbacks | ✅ `async/await` chain |
|
|
38
|
-
| `flush()` | `port.flush(callback)` | ✅ `await port.flush()` |
|
|
39
|
-
| `drain()` | `port.drain(callback)` | ✅ `await port.drain()` |
|
|
40
|
-
|
|
41
|
-
### 3. Test Updates (`tests/unit/adapters/serial-adapter.test.js`)
|
|
42
|
-
|
|
43
|
-
- ✅ Updated mocks to return Promises
|
|
44
|
-
- ✅ Changed callback-based mocks to async functions
|
|
45
|
-
- ✅ Updated test expectations
|
|
46
|
-
- ✅ Added verification of method calls
|
|
47
|
-
|
|
48
|
-
## Key Improvements
|
|
49
|
-
|
|
50
|
-
### 1. Cleaner Code
|
|
51
|
-
- Removed nested callbacks
|
|
52
|
-
- Modern async/await syntax
|
|
53
|
-
- Better error handling with try/catch
|
|
54
|
-
|
|
55
|
-
### 2. Better Error Handling
|
|
56
|
-
- Errors now propagate via exceptions
|
|
57
|
-
- Try/catch blocks for cleaner error handling
|
|
58
|
-
- Proper cleanup on errors
|
|
59
|
-
|
|
60
|
-
### 3. Consistent API
|
|
61
|
-
- All methods now use async/await consistently
|
|
62
|
-
- Matches USB adapter pattern (already migrated)
|
|
63
|
-
|
|
64
|
-
## Public API - No Breaking Changes
|
|
65
|
-
|
|
66
|
-
✅ **All public methods maintain the same signature:**
|
|
67
|
-
- `Serial.connect(port, options)` → `Promise<boolean>`
|
|
68
|
-
- `Serial.open()` → `Promise<boolean>`
|
|
69
|
-
- `Serial.write(data)` → `Promise<boolean>`
|
|
70
|
-
- `Serial.close(timeout)` → `Promise<boolean>`
|
|
71
|
-
- `Serial.disconnect(timeout)` → `Promise<boolean>`
|
|
72
|
-
- `Serial.read()` → `Promise<Buffer>`
|
|
73
|
-
|
|
74
|
-
## Files Modified
|
|
75
|
-
|
|
76
|
-
1. ✅ `package.json` - Version updated
|
|
77
|
-
2. ✅ `src/serial-adapter/index.js` - Complete migration
|
|
78
|
-
3. ✅ `tests/unit/adapters/serial-adapter.test.js` - Tests updated
|
|
79
|
-
|
|
80
|
-
## Testing
|
|
81
|
-
|
|
82
|
-
### Unit Tests
|
|
83
|
-
- ✅ All tests updated for v13 API
|
|
84
|
-
- ✅ Mocks properly simulate Promise-based API
|
|
85
|
-
- ✅ Test expectations verified
|
|
86
|
-
|
|
87
|
-
### Next Steps
|
|
88
|
-
1. Run tests: `npm test`
|
|
89
|
-
2. Test with real hardware (if available)
|
|
90
|
-
3. Verify all functionality works as expected
|
|
91
|
-
|
|
92
|
-
## Compatibility
|
|
93
|
-
|
|
94
|
-
### ✅ Backward Compatible
|
|
95
|
-
- Public API unchanged
|
|
96
|
-
- Method signatures identical
|
|
97
|
-
- Return types unchanged (all Promises)
|
|
98
|
-
- No breaking changes for users
|
|
99
|
-
|
|
100
|
-
### Requirements
|
|
101
|
-
- Node.js >= 18.0.0 (already specified)
|
|
102
|
-
- Native module compilation may be required
|
|
103
|
-
|
|
104
|
-
## Migration Summary
|
|
105
|
-
|
|
106
|
-
| Aspect | Status |
|
|
107
|
-
|--------|--------|
|
|
108
|
-
| Package Update | ✅ Complete |
|
|
109
|
-
| Code Migration | ✅ Complete |
|
|
110
|
-
| Test Updates | ✅ Complete |
|
|
111
|
-
| Public API | ✅ Unchanged |
|
|
112
|
-
| Breaking Changes | ❌ None |
|
|
113
|
-
|
|
114
|
-
## Notes
|
|
115
|
-
|
|
116
|
-
- Constructor no longer accepts callback (v13 change)
|
|
117
|
-
- `autoOpen: false` now required, open manually
|
|
118
|
-
- All methods return Promises (consistent with v13)
|
|
119
|
-
- Error handling via try/catch instead of callbacks
|
|
120
|
-
- Event-based error handling for constructor errors
|
|
121
|
-
|
|
122
|
-
## References
|
|
123
|
-
|
|
124
|
-
- [SerialPort Documentation](https://serialport.io/)
|
|
125
|
-
- [Migration Plan](./SERIALPORT_V13_MIGRATION_PLAN.md)
|
|
126
|
-
- [Public API Analysis](./PUBLIC_API_ANALYSIS.md)
|
|
127
|
-
|