This repository has been archived by the owner on Feb 11, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Showing
22 changed files
with
6,774 additions
and
1 deletion.
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 @@ | ||
{ | ||
"presets": ["env"] | ||
} |
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,37 @@ | ||
{ | ||
"extends": ["standard"], | ||
"env": { | ||
"browser": true, | ||
"mocha": true | ||
}, | ||
"plugins": ["import", "html"], | ||
"parserOptions": { | ||
"ecmaVersion": 8 | ||
}, | ||
"settings": { | ||
"html/indent": "+4", | ||
"html/html-extensions": [".html"] | ||
}, | ||
"globals": { | ||
"Recta": true | ||
}, | ||
"rules": { | ||
"curly": ["error", "multi-or-nest"], | ||
"comma-dangle": ["error", "always-multiline"], | ||
"no-console": "error", | ||
"prefer-const": "error", | ||
"prefer-template": "error", | ||
"import/extensions": "off", | ||
"import/order": ["error", { "newlines-between": "never" }], | ||
"import/no-extraneous-dependencies": "off", | ||
"import/no-unresolved": ["error"], | ||
"linebreak-style": "off", | ||
"key-spacing": ["error", { | ||
"align": { | ||
"beforeColon": false, | ||
"afterColon": true, | ||
"on": "colon" | ||
}, | ||
}] | ||
} | ||
} |
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,29 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git | ||
node_modules | ||
dist/ |
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,4 @@ | ||
// Ignore All | ||
* | ||
// Except dist | ||
!dist/ |
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,53 @@ | ||
os: | ||
- linux | ||
dist: trusty | ||
sudo: false | ||
language: node_js | ||
node_js: | ||
- lts/* | ||
matrix: | ||
include: | ||
- env: BROWSER=Chrome | ||
addons: | ||
chrome: stable | ||
- env: BROWSER=Firefox | ||
addons: | ||
firefox: latest | ||
cache: | ||
directories: | ||
- $HOME/.npm | ||
- $(npm config get prefix)/lib/node_modules | ||
- $(npm config get prefix)/bin/karma | ||
- node_modules | ||
install: | ||
- karma --version || npm install -g karma-cli | ||
- yarn | ||
before_script: | ||
- "export DISPLAY=:99.0" | ||
- "sh -e /etc/init.d/xvfb start" | ||
- sleep 3 | ||
script: | ||
- npm run lint | ||
- npm run build | ||
- karma start --single-run --browsers $BROWSER | ||
notifications: | ||
slack: recta-project:vrt37eDk30kgeyJ24LKGrjID | ||
deploy: | ||
- provider: npm | ||
email: "[email protected]" | ||
api_key: | ||
secure: urRk3z3aNOXVvc/lffjK+6N4olN1lwMUi/lMjvLF4hScIIkz4WYx1TEeoJsO0vEmVRmCvuHZkLYPuMx1/onmCifBST8eZRdX2mqMows+dN1V9PxLvCEFmzq+3XublCu1Rtn2PD9XVaSUjunKMve8sNHsEciv98TWVmNjyq6qzkqQpSmcW38y5VTwz+Yv0XdZahWTY0XPQtxaCyGFUYvuBFGafIC1ufdSj4cA0uRXzRWOdxnRC+rNnPYP1dO+utGNg8iV9wlzKUlFOHsJtlX4eKQGQsbfDzCdkgjb1U/I8ESsiwGcwZpJGNAKPGjMOqCWcI8VLq3ZnVeuE6l13IoMZk817Gzh8D2IVmsRyqwRaLq2sJY3iCVkWUVoiybkDp92VhAWhu5TkgoOOpK9DirNRjIjbdgFb9BB3k//9Vj2t5NAKiSmkIqWhK2LLXhT9hLquJ90bMadJzg+RYUS7Gt4vgMpvisZ2G/kQGq06qqwj5tV2r7KiewGxUh6A/4VOTWp8Eog2t5xx4nCeGbiMwKEX8P82fDe4+IV0ILhzT/OCj4rYHDIGUUSWA827pLt+Xp8wTA6s4RxopS8EAJsbRjmmdCC1otEzj/+qWVe58phOtkeoj028KYjGVTamBti0SfMuFuyx3PQzsKMRrmnob2U9J56kFGcJkgwa4XwnW7xluk= | ||
skip_cleanup: true | ||
on: | ||
tags: true | ||
condition: $BROWSER = Chrome | ||
- provider: releases | ||
api_key: | ||
secure: LQzEmTzd99jDTTgvPnf/pdTG+PTumDsWt1UohecoXs/VRE3hWnOMzYtBjCtuS4QLaa/emClFAHmB4NnGwzjtEHcCgPxot1726YxQHpVjuyRHH/jeaHlHHhDLHNgjJBP0i/CjF0u6j6FK36fq3khnyz9BJXjLilUM3jEWFp9CWXMPcmZ7+jAzDc5ck9LlEJCLimumtEPt87KBdnwHk8/mrOOhjuppXmapSLrBjKAyOoqiKedeP+j5/zIVxXBkpxOrRK7LQjNdNO9idNGQ29iMX/iZ5WWjSBw2cyRBXstivIwkXV1ExN5pznds6XQdWQkKhQ3CNaiPOZ/Zk6EZGX9EfI1kyfr7NEKmonhtxDVh92RLcIX/mQjpReDc6GqsmRwyovG44NZLagQGryN3gWlE13OD0/vEiU66zPKi3MDHuGaEuxtkUgsLC/ZzKbnCeqCiX77gZFQKIV5IJNJy2l/tIG6LpMH39000MjOIoEWw5ap+pPgTE7HLoD0r5v5HzuWmYx0rUXxGqJjiWkQuTE7ZVMpXGVVp38uV1oyEVuLLp1s33s/nqqvPRKU52fW9GdCcLIekhlnNyD98WOUOmztNM2wdIUSjqJLhILoyeUN2rgXudE0k9Q7ScSBvyD0vbOagZGQEAMD3Slv9PS2TZQBJBfIKnscInKpAauOk47O0BOg= | ||
file: dist/recta.js | ||
draft: true | ||
tag_name: $TRAVIS_TAG | ||
skip_cleanup: true | ||
on: | ||
tags: true | ||
condition: $BROWSER = Chrome |
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,7 @@ | ||
Copyright 2017 Ade Novid | ||
|
||
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 |
---|---|---|
@@ -1 +1,192 @@ | ||
recta | ||
# Recta | ||
|
||
> Direct printing from Browser | ||
[![Build Status](https://travis-ci.org/adenvt/recta.svg?branch=master)](https://travis-ci.org/adenvt/recta) | ||
[![npm version](https://badge.fury.io/js/recta.svg)](https://badge.fury.io/js/recta) | ||
|
||
## Introduction | ||
|
||
### Reason | ||
I'm web developer, and get project to make some Point Of Sale (POS) software. I have trouble when i need print some receipt especially with POS printer, so i make this project. | ||
|
||
### How it work | ||
Recta need desktop software called [Recta Host][recta-host], it serve all hardware connection and bridge with Browser via Websocket | ||
|
||
## How to use | ||
|
||
### Requirement | ||
* You need to install [Recta Host][recta-host] on every host that will be used for print, checkout [here][recta-host] to more information. | ||
|
||
### Standalone | ||
Just include it like other JS library | ||
```html | ||
... | ||
<script src="https://cdn.jsdelivr.net/npm/recta/dist/recta.js"></script> | ||
... | ||
``` | ||
|
||
### Using Webpack or Browserify | ||
Recta support commonjs module, so if you using webpack for your project. you can easly using it like other module | ||
|
||
1. Install package | ||
```bash | ||
$ npm install --save recta | ||
``` | ||
2. Import in your code | ||
```js | ||
// using CommonJS | ||
var Recta = require('recta') | ||
// using ES6 style | ||
import Recta from 'recta' | ||
``` | ||
|
||
## Example | ||
|
||
```html | ||
<script type="text/javascript"> | ||
// ... | ||
var printer = new Recta('APPKEY', '1811') | ||
function onClick () { | ||
printer.open().then(function () { | ||
printer.align('center') | ||
.text('Hello World !!') | ||
.bold(true) | ||
.text('This is bold text') | ||
.bold(false) | ||
.underline(true) | ||
.text('This is underline text') | ||
.underline(false) | ||
.barcode('CODE39', '123456789') | ||
.cut() | ||
.print() | ||
}) | ||
} | ||
// ... | ||
</script> | ||
``` | ||
|
||
## API | ||
|
||
### Class | ||
|
||
#### *new* Recta(key, port) | ||
Create a new Recta object, parameter: | ||
|
||
* Key: APPKEY used to authentication with Host, You can see on your [Recta Host][recta-host] Configuration | ||
* Port: port of host, *default*: 1811 | ||
|
||
### Methods | ||
|
||
### .open() | ||
open connection to printer host. | ||
|
||
*return* **Promise** | ||
|
||
### .text('string') | ||
print text. | ||
|
||
note: it automaticaly add linefeed *(`\n`)* use `.raw()` instead if you wouldn’t add linefeed. | ||
|
||
### .align('align') | ||
set horizontal text align, parameter value can be: | ||
|
||
* LEFT | ||
* CENTER | ||
* RIGHT | ||
|
||
### .bold(true|false) | ||
turn emphasized mode on / off, **default**: true | ||
|
||
### .underline(true|false|2) | ||
turn underline mode on / off, set `2` for set 2-dot width underline, **default**: true | ||
|
||
### .font('A'|'B') | ||
select character font `'A'` or `'B'` | ||
|
||
### .mode(font, emphasized, doubleHeight, doubleWidth, underline) | ||
select print modes, parameter: | ||
|
||
* **font**: select character font, value: `'A'` or `'B'`, *default*: `'A'` | ||
* **emphasized**: turn on / off emphasized / bold mode, value: `true` or `false`, *default*: `false` | ||
* **doubleHeight**: turn on / off double height mode, value: `true` or `false`, *default*: `false` | ||
* **doubleWidth**: turn on / off double width mode, value: `true` or `false`, *default*: `false` | ||
* **underline**: turn on / off underline mode, value: `true` or `false`, *default*: `false` | ||
|
||
### .cut(partial, linefeed) | ||
cut paper, parameter: | ||
|
||
* **partial**: if `true` execute partial cut (one point left uncut) else cut paper completely (full cut), value: `true` or `false`, *default*: `false` | ||
* **linefeed**: add linefeed, value: **integer**, *default*: 4 | ||
|
||
### .barcode(type, barcode, barcodeHeight) | ||
print barcode, parameter | ||
|
||
* **type**: type of Barcode, value: | ||
* UPC-A | ||
* UPC-E | ||
* EAN13 | ||
* EAN8 | ||
* CODE39 | ||
* ITF | ||
* CODABAR | ||
* CODE93 | ||
* CODE128 | ||
* **barcode**: content barcode, value: **string** | ||
* **barcodeHeight**: set barcode height *(optional)*, value: **integer** | ||
|
||
### .barcodeHeight(height) | ||
set barcode height, value can be range: 1 ≤ n ≤ 255 | ||
|
||
### .feed(n) | ||
add linefeed as much as n, *default*: 4 | ||
|
||
### .raw(raw) | ||
print raw text / buffer | ||
|
||
### .print() | ||
send print command to printer. ***printer wouldn’t execute until you call this*** | ||
|
||
### .reset() | ||
send reset instruction to printer | ||
|
||
### .flush() | ||
return a sliced Buffer instance and clear buffer | ||
|
||
*return* **Buffer** | ||
|
||
### .clearBuffer() | ||
clear buffer | ||
|
||
### .close() | ||
close connection to host | ||
|
||
*return* **Promise** | ||
|
||
## Events | ||
|
||
### .on('open', function() {}) | ||
Fired upon successful connection | ||
|
||
### .on('close', function() {}) | ||
Fired upon disconnected | ||
|
||
### .on('error', function(error) {}) | ||
Fired when an error occurs | ||
|
||
## 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 | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details | ||
|
||
[recta-host]: http://github.com/adenvt/recta-host |
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 @@ | ||
[v-cloak] { | ||
display: none; | ||
} |
Oops, something went wrong.