Skip to content
This repository was archived by the owner on Feb 11, 2022. It is now read-only.

Commit 35c6589

Browse files
committed
Merge branch 'release/1.0.0'
2 parents bda9648 + d5b2657 commit 35c6589

22 files changed

+6774
-1
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["env"]
3+
}

.eslintrc

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"extends": ["standard"],
3+
"env": {
4+
"browser": true,
5+
"mocha": true
6+
},
7+
"plugins": ["import", "html"],
8+
"parserOptions": {
9+
"ecmaVersion": 8
10+
},
11+
"settings": {
12+
"html/indent": "+4",
13+
"html/html-extensions": [".html"]
14+
},
15+
"globals": {
16+
"Recta": true
17+
},
18+
"rules": {
19+
"curly": ["error", "multi-or-nest"],
20+
"comma-dangle": ["error", "always-multiline"],
21+
"no-console": "error",
22+
"prefer-const": "error",
23+
"prefer-template": "error",
24+
"import/extensions": "off",
25+
"import/order": ["error", { "newlines-between": "never" }],
26+
"import/no-extraneous-dependencies": "off",
27+
"import/no-unresolved": ["error"],
28+
"linebreak-style": "off",
29+
"key-spacing": ["error", {
30+
"align": {
31+
"beforeColon": false,
32+
"afterColon": true,
33+
"on": "colon"
34+
},
35+
}]
36+
}
37+
}

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Runtime data
7+
pids
8+
*.pid
9+
*.seed
10+
11+
# Directory for instrumented libs generated by jscoverage/JSCover
12+
lib-cov
13+
14+
# Coverage directory used by tools like istanbul
15+
coverage
16+
17+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
18+
.grunt
19+
20+
# node-waf configuration
21+
.lock-wscript
22+
23+
# Compiled binary addons (http://nodejs.org/api/addons.html)
24+
build/Release
25+
26+
# Dependency directory
27+
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
28+
node_modules
29+
dist/

.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Ignore All
2+
*
3+
// Except dist
4+
!dist/

.travis.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
os:
2+
- linux
3+
dist: trusty
4+
sudo: false
5+
language: node_js
6+
node_js:
7+
- lts/*
8+
matrix:
9+
include:
10+
- env: BROWSER=Chrome
11+
addons:
12+
chrome: stable
13+
- env: BROWSER=Firefox
14+
addons:
15+
firefox: latest
16+
cache:
17+
directories:
18+
- $HOME/.npm
19+
- $(npm config get prefix)/lib/node_modules
20+
- $(npm config get prefix)/bin/karma
21+
- node_modules
22+
install:
23+
- karma --version || npm install -g karma-cli
24+
- yarn
25+
before_script:
26+
- "export DISPLAY=:99.0"
27+
- "sh -e /etc/init.d/xvfb start"
28+
- sleep 3
29+
script:
30+
- npm run lint
31+
- npm run build
32+
- karma start --single-run --browsers $BROWSER
33+
notifications:
34+
slack: recta-project:vrt37eDk30kgeyJ24LKGrjID
35+
deploy:
36+
- provider: npm
37+
38+
api_key:
39+
secure: urRk3z3aNOXVvc/lffjK+6N4olN1lwMUi/lMjvLF4hScIIkz4WYx1TEeoJsO0vEmVRmCvuHZkLYPuMx1/onmCifBST8eZRdX2mqMows+dN1V9PxLvCEFmzq+3XublCu1Rtn2PD9XVaSUjunKMve8sNHsEciv98TWVmNjyq6qzkqQpSmcW38y5VTwz+Yv0XdZahWTY0XPQtxaCyGFUYvuBFGafIC1ufdSj4cA0uRXzRWOdxnRC+rNnPYP1dO+utGNg8iV9wlzKUlFOHsJtlX4eKQGQsbfDzCdkgjb1U/I8ESsiwGcwZpJGNAKPGjMOqCWcI8VLq3ZnVeuE6l13IoMZk817Gzh8D2IVmsRyqwRaLq2sJY3iCVkWUVoiybkDp92VhAWhu5TkgoOOpK9DirNRjIjbdgFb9BB3k//9Vj2t5NAKiSmkIqWhK2LLXhT9hLquJ90bMadJzg+RYUS7Gt4vgMpvisZ2G/kQGq06qqwj5tV2r7KiewGxUh6A/4VOTWp8Eog2t5xx4nCeGbiMwKEX8P82fDe4+IV0ILhzT/OCj4rYHDIGUUSWA827pLt+Xp8wTA6s4RxopS8EAJsbRjmmdCC1otEzj/+qWVe58phOtkeoj028KYjGVTamBti0SfMuFuyx3PQzsKMRrmnob2U9J56kFGcJkgwa4XwnW7xluk=
40+
skip_cleanup: true
41+
on:
42+
tags: true
43+
condition: $BROWSER = Chrome
44+
- provider: releases
45+
api_key:
46+
secure: LQzEmTzd99jDTTgvPnf/pdTG+PTumDsWt1UohecoXs/VRE3hWnOMzYtBjCtuS4QLaa/emClFAHmB4NnGwzjtEHcCgPxot1726YxQHpVjuyRHH/jeaHlHHhDLHNgjJBP0i/CjF0u6j6FK36fq3khnyz9BJXjLilUM3jEWFp9CWXMPcmZ7+jAzDc5ck9LlEJCLimumtEPt87KBdnwHk8/mrOOhjuppXmapSLrBjKAyOoqiKedeP+j5/zIVxXBkpxOrRK7LQjNdNO9idNGQ29iMX/iZ5WWjSBw2cyRBXstivIwkXV1ExN5pznds6XQdWQkKhQ3CNaiPOZ/Zk6EZGX9EfI1kyfr7NEKmonhtxDVh92RLcIX/mQjpReDc6GqsmRwyovG44NZLagQGryN3gWlE13OD0/vEiU66zPKi3MDHuGaEuxtkUgsLC/ZzKbnCeqCiX77gZFQKIV5IJNJy2l/tIG6LpMH39000MjOIoEWw5ap+pPgTE7HLoD0r5v5HzuWmYx0rUXxGqJjiWkQuTE7ZVMpXGVVp38uV1oyEVuLLp1s33s/nqqvPRKU52fW9GdCcLIekhlnNyD98WOUOmztNM2wdIUSjqJLhILoyeUN2rgXudE0k9Q7ScSBvyD0vbOagZGQEAMD3Slv9PS2TZQBJBfIKnscInKpAauOk47O0BOg=
47+
file: dist/recta.js
48+
draft: true
49+
tag_name: $TRAVIS_TAG
50+
skip_cleanup: true
51+
on:
52+
tags: true
53+
condition: $BROWSER = Chrome

LICENSE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2017 Ade Novid
2+
3+
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:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
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.

README.md

Lines changed: 192 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,192 @@
1-
recta
1+
# Recta
2+
3+
> Direct printing from Browser
4+
5+
[![Build Status](https://travis-ci.org/adenvt/recta.svg?branch=master)](https://travis-ci.org/adenvt/recta)
6+
[![npm version](https://badge.fury.io/js/recta.svg)](https://badge.fury.io/js/recta)
7+
8+
## Introduction
9+
10+
### Reason
11+
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.
12+
13+
### How it work
14+
Recta need desktop software called [Recta Host][recta-host], it serve all hardware connection and bridge with Browser via Websocket
15+
16+
## How to use
17+
18+
### Requirement
19+
* You need to install [Recta Host][recta-host] on every host that will be used for print, checkout [here][recta-host] to more information.
20+
21+
### Standalone
22+
Just include it like other JS library
23+
```html
24+
...
25+
<script src="https://cdn.jsdelivr.net/npm/recta/dist/recta.js"></script>
26+
...
27+
```
28+
29+
### Using Webpack or Browserify
30+
Recta support commonjs module, so if you using webpack for your project. you can easly using it like other module
31+
32+
1. Install package
33+
```bash
34+
$ npm install --save recta
35+
```
36+
2. Import in your code
37+
```js
38+
// using CommonJS
39+
var Recta = require('recta')
40+
// using ES6 style
41+
import Recta from 'recta'
42+
```
43+
44+
## Example
45+
46+
```html
47+
<script type="text/javascript">
48+
// ...
49+
var printer = new Recta('APPKEY', '1811')
50+
51+
function onClick () {
52+
printer.open().then(function () {
53+
printer.align('center')
54+
.text('Hello World !!')
55+
.bold(true)
56+
.text('This is bold text')
57+
.bold(false)
58+
.underline(true)
59+
.text('This is underline text')
60+
.underline(false)
61+
.barcode('CODE39', '123456789')
62+
.cut()
63+
.print()
64+
})
65+
}
66+
// ...
67+
</script>
68+
```
69+
70+
## API
71+
72+
### Class
73+
74+
#### *new* Recta(key, port)
75+
Create a new Recta object, parameter:
76+
77+
* Key: APPKEY used to authentication with Host, You can see on your [Recta Host][recta-host] Configuration
78+
* Port: port of host, *default*: 1811
79+
80+
### Methods
81+
82+
### .open()
83+
open connection to printer host.
84+
85+
*return* **Promise**
86+
87+
### .text('string')
88+
print text.
89+
90+
note: it automaticaly add linefeed *(`\n`)* use `.raw()` instead if you wouldn’t add linefeed.
91+
92+
### .align('align')
93+
set horizontal text align, parameter value can be:
94+
95+
* LEFT
96+
* CENTER
97+
* RIGHT
98+
99+
### .bold(true|false)
100+
turn emphasized mode on / off, **default**: true
101+
102+
### .underline(true|false|2)
103+
turn underline mode on / off, set `2` for set 2-dot width underline, **default**: true
104+
105+
### .font('A'|'B')
106+
select character font `'A'` or `'B'`
107+
108+
### .mode(font, emphasized, doubleHeight, doubleWidth, underline)
109+
select print modes, parameter:
110+
111+
* **font**: select character font, value: `'A'` or `'B'`, *default*: `'A'`
112+
* **emphasized**: turn on / off emphasized / bold mode, value: `true` or `false`, *default*: `false`
113+
* **doubleHeight**: turn on / off double height mode, value: `true` or `false`, *default*: `false`
114+
* **doubleWidth**: turn on / off double width mode, value: `true` or `false`, *default*: `false`
115+
* **underline**: turn on / off underline mode, value: `true` or `false`, *default*: `false`
116+
117+
### .cut(partial, linefeed)
118+
cut paper, parameter:
119+
120+
* **partial**: if `true` execute partial cut (one point left uncut) else cut paper completely (full cut), value: `true` or `false`, *default*: `false`
121+
* **linefeed**: add linefeed, value: **integer**, *default*: 4
122+
123+
### .barcode(type, barcode, barcodeHeight)
124+
print barcode, parameter
125+
126+
* **type**: type of Barcode, value:
127+
* UPC-A
128+
* UPC-E
129+
* EAN13
130+
* EAN8
131+
* CODE39
132+
* ITF
133+
* CODABAR
134+
* CODE93
135+
* CODE128
136+
* **barcode**: content barcode, value: **string**
137+
* **barcodeHeight**: set barcode height *(optional)*, value: **integer**
138+
139+
### .barcodeHeight(height)
140+
set barcode height, value can be range: 1 ≤ n ≤ 255
141+
142+
### .feed(n)
143+
add linefeed as much as n, *default*: 4
144+
145+
### .raw(raw)
146+
print raw text / buffer
147+
148+
### .print()
149+
send print command to printer. ***printer wouldn’t execute until you call this***
150+
151+
### .reset()
152+
send reset instruction to printer
153+
154+
### .flush()
155+
return a sliced Buffer instance and clear buffer
156+
157+
*return* **Buffer**
158+
159+
### .clearBuffer()
160+
clear buffer
161+
162+
### .close()
163+
close connection to host
164+
165+
*return* **Promise**
166+
167+
## Events
168+
169+
### .on('open', function() {})
170+
Fired upon successful connection
171+
172+
### .on('close', function() {})
173+
Fired upon disconnected
174+
175+
### .on('error', function(error) {})
176+
Fired when an error occurs
177+
178+
## Contributing
179+
180+
* Fork this repo
181+
* Clone your repo
182+
* Install dependencies
183+
* Checkout a feature branch
184+
* Feel free to add your features
185+
* Make sure your features are fully tested
186+
* Open a pull request, and enjoy <3
187+
188+
## License
189+
190+
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
191+
192+
[recta-host]: http://github.com/adenvt/recta-host

dev/css/main.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[v-cloak] {
2+
display: none;
3+
}

0 commit comments

Comments
 (0)