-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2ba4b18
Showing
98 changed files
with
9,328 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "@dohooo" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
github: [dohooo] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
|
||
- name: Setup | ||
run: npm i -g @antfu/ni | ||
|
||
- name: Install | ||
run: nci | ||
|
||
- name: Lint | ||
run: nr lint | ||
|
||
typecheck: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
|
||
- name: Setup | ||
run: npm i -g @antfu/ni | ||
|
||
- name: Install | ||
run: nci | ||
|
||
- name: Typecheck | ||
run: nr typecheck | ||
|
||
test: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
node: [14.x, 16.x] | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
fail-fast: false | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set node ${{ matrix.node }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
|
||
- name: Setup | ||
run: npm i -g @antfu/ni | ||
|
||
- name: Install | ||
run: nci | ||
|
||
- name: Build | ||
run: nr build | ||
|
||
- name: Test | ||
run: nr test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
|
||
- run: npx changelogithub | ||
env: | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.cache | ||
.DS_Store | ||
.idea | ||
*.log | ||
*.tgz | ||
coverage | ||
dist | ||
lib-cov | ||
logs | ||
node_modules | ||
temp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.DS_* | ||
node_modules | ||
*.sublime* | ||
psd | ||
thumb | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ignore-workspace-root-check=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["dohooo.gold-right"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"cSpell.words": [ | ||
"dohooo", | ||
"escpos" | ||
], | ||
"prettier.enable": false, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": true | ||
}, | ||
"editor.defaultFormatter": "dbaeumer.vscode-eslint", | ||
"goldRight.templateDirectoryPath": "./.vscode/templates" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"paths": [ | ||
{ | ||
"directory": "[directory]", | ||
"templates": [ | ||
"[template-name]" | ||
] | ||
} | ||
], | ||
"templatesConfig": [ | ||
{ | ||
"templateName": "[template-name]", | ||
"inputsVariables": [ | ||
{ | ||
"key": "[key]", | ||
"title": "[prompt-title]", | ||
"required": "[is-required]" | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Please refer to https://github.com/dohooo/contribute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2015 lsong | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
## ESCPOS PROJECT | ||
|
||
ESC/POS Printer driver for Node.js | ||
|
||
[](https://www.npmjs.com/package/escpos ) | ||
[](https://travis-ci.org/song940/node-escpos) | ||
|
||
[](https://npmjs.org/escpos ) | ||
|
||
Packages Available: | ||
|
||
+ [escpos Printer](packages/printer/README.md) | ||
+ [escpos Screen Display](packages/screen/README.md) | ||
+ [escpos USB Adapter](packages/usb/README.md) | ||
+ [escpos Network Adapter](packages/network/README.md) | ||
+ [escpos Bluetooth Adapter](packages/bluetooth/README.md) | ||
+ [escpos SerialPort Adapter](packages/serialport/README.md) | ||
|
||
## Example | ||
|
||
````javascript | ||
const escpos = require('escpos'); | ||
// install escpos-usb adapter module manually | ||
escpos.USB = require('escpos-usb'); | ||
// Select the adapter based on your printer type | ||
const device = new escpos.USB(); | ||
// const device = new escpos.Network('localhost'); | ||
// const device = new escpos.Serial('/dev/usb/lp0'); | ||
|
||
const options = { encoding: "GB18030" /* default */ } | ||
// encoding is optional | ||
|
||
const printer = new escpos.Printer(device, options); | ||
|
||
device.open(function(error){ | ||
printer | ||
.font('a') | ||
.align('ct') | ||
.style('bu') | ||
.size(1, 1) | ||
.text('The quick brown fox jumps over the lazy dog') | ||
.text('敏捷的棕色狐狸跳过懒狗') | ||
.barcode('1234567', 'EAN8') | ||
.table(["One", "Two", "Three"]) | ||
.tableCustom( | ||
[ | ||
{ text:"Left", align:"LEFT", width:0.33, style: 'B' }, | ||
{ text:"Center", align:"CENTER", width:0.33}, | ||
{ text:"Right", align:"RIGHT", width:0.33 } | ||
], | ||
{ encoding: 'cp857', size: [1, 1] } // Optional | ||
) | ||
.qrimage('https://github.com/song940/node-escpos', function(err){ | ||
this.cut(); | ||
this.close(); | ||
}); | ||
}); | ||
```` | ||
- See `./examples` for more examples. | ||
|
||
---- | ||
|
||
## Screencast | ||
|
||
 | ||
|
||
---- | ||
|
||
## Contributing | ||
- Fork this repo | ||
- Clone your repo | ||
- Install dependencies | ||
- Checkout a feature branch | ||
- Feel free to add your features | ||
- Make sure your features are fully tested | ||
- Open a pull request, and enjoy <3 | ||
|
||
---- | ||
|
||
## Contributors | ||
|
||
Thanks to our [contributors][contributors-href] 🎉👏 | ||
|
||
+ [Tao Yuan](https://github.com/taoyuan) | ||
+ [Jose Vera](https://github.com/jor3l) | ||
+ [Sébastien Vidal](https://github.com/Psychopoulet) | ||
+ [Yu Yongwoo](https://github.com/uyu423) | ||
+ [Attawit Kittikrairit](https://github.com/atton16) | ||
+ [Michael Kuenzli](https://github.com/pfirpfel) | ||
|
||
[][contributors-href] | ||
|
||
---- | ||
|
||
### MIT license | ||
Copyright (c) 2015 ~ now Lsong <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
|
||
--- | ||
|
||
[contributors-href]: https://github.com/song940/node-escpos/graphs/contributors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
const escpos = require('../'); | ||
|
||
const device = new escpos.USB(); | ||
|
||
const printer = new escpos.Printer(device); | ||
|
||
device.open(function() { | ||
printer | ||
.font('a') | ||
.align('ct') | ||
.size(1, 1) | ||
.text('EAN13 barcode example') | ||
.barcode('123456789012', 'EAN13') // code length 12 | ||
.barcode('109876543210') // default type 'EAN13' | ||
.barcode('7654321', 'EAN8') // The EAN parity bit is automatically added. | ||
.cut() | ||
.close(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const { Bluetooth } = require('..'); | ||
|
||
(async () => { | ||
|
||
const printers = await Bluetooth.findPrinters(); | ||
console.log(printers); | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const { Bluetooth, Printer } = require('..'); | ||
|
||
(async () => { | ||
|
||
try { | ||
const availablePrinters = await Bluetooth.findPrinters(); | ||
// Uncomment if you want to use a specific printer instead of the first bt device that responds: | ||
// const preferredPrinterName = 'MHT-P5801'; | ||
// const btPrinter = availablePrinters.filter(p => p && p.name === preferredPrinterName)[0]; | ||
const btPrinter = availablePrinters[0]; | ||
console.log('Connect to ' + btPrinter.name); | ||
const device = await Bluetooth.getDevice(btPrinter.address, btPrinter.channel); | ||
const printer = await Printer.create(device); | ||
|
||
await printer.text('hello'); | ||
await printer.cut(); | ||
await printer.close(); | ||
|
||
console.log('print job done'); | ||
} catch(error) { | ||
console.log('error', error); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
const escpos = require('../'); | ||
const path = require('path'); | ||
|
||
const device = new escpos.Serial('COM9', { baudRate: 9600, autoOpen: false }); | ||
// const device = new escpos.RawBT(); | ||
// const device = new escpos.Network('localhost'); | ||
// const device = new escpos.Serial('/dev/usb/lp0'); | ||
const printer = new escpos.Printer(device); | ||
|
||
device.open(function(err){ | ||
printer | ||
.encode('cp866') | ||
.setCharacterCodeTable(17) | ||
.text('Тест на кирилица.') | ||
.size(1, 1) | ||
.feed() | ||
.feed() | ||
.cut() | ||
.close(); | ||
}); |
Oops, something went wrong.