@risleylima/escpos 0.0.10 → 0.0.12
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/LICENSE +0 -0
- package/README.md +0 -0
- package/examples/printTest.js +0 -0
- package/index.js +0 -0
- package/package.json +3 -3
- package/src/adapter/index.js +0 -0
- package/src/printer/commands.js +0 -0
- package/src/printer/image.js +0 -0
- package/src/printer/index.js +0 -0
- package/src/printer/utils.js +0 -0
- package/src/serial-adapter/index.js +26 -22
- package/src/usb-adapter/index.js +0 -1
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
package/examples/printTest.js
CHANGED
|
File without changes
|
package/index.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@risleylima/escpos",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "Library to deal with ESCPOS using some adapters",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "Rlima Info",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"debug": "^4.3.1",
|
|
11
11
|
"get-pixels": "^3.3.2",
|
|
12
12
|
"iconv-lite": "^0.6.3",
|
|
13
|
-
"serialport": "^
|
|
14
|
-
"usb": "^1.
|
|
13
|
+
"serialport": "^11.0.0",
|
|
14
|
+
"usb": "^1.9.1"
|
|
15
15
|
},
|
|
16
16
|
"directories": {
|
|
17
17
|
"example": "examples"
|
package/src/adapter/index.js
CHANGED
|
File without changes
|
package/src/printer/commands.js
CHANGED
|
File without changes
|
package/src/printer/image.js
CHANGED
|
File without changes
|
package/src/printer/index.js
CHANGED
|
File without changes
|
package/src/printer/utils.js
CHANGED
|
File without changes
|
|
@@ -19,31 +19,35 @@ const scope = {
|
|
|
19
19
|
const Serial = new EventEmitter();
|
|
20
20
|
|
|
21
21
|
Serial.connect = (port, options) => {
|
|
22
|
-
return new Promise((resolve) => {
|
|
23
|
-
let connectListener =
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
let connectListener = () => {
|
|
24
24
|
Serial.removeListener('close', connectListener);
|
|
25
|
-
scope.
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
scope.verifyPort(port).catch(e => reject(e)).then((portVerified) => {
|
|
26
|
+
if (portVerified) {
|
|
27
|
+
scope.port = new SerialPort(portVerified, Object.assign(options || {}, { autoOpen: true }), (err) => {
|
|
28
|
+
if (err) {
|
|
29
|
+
debug('Error Opening the Selected Port: ', err);
|
|
30
|
+
if (scope.port) {
|
|
31
|
+
scope.port.close(async () => {
|
|
32
|
+
await connectListener();
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let clearPort = () => {
|
|
38
|
+
Serial.emit('disconnect', scope.port);
|
|
39
|
+
scope.port.removeListener('close', clearPort);
|
|
40
|
+
scope.port = null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
scope.port.on('close', clearPort);
|
|
44
|
+
|
|
45
|
+
debug('Device Connected and Open!');
|
|
46
|
+
Serial.emit('connect', scope.port);
|
|
34
47
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
scope.port.removeListener('close', clearPort);
|
|
38
|
-
scope.port = null;
|
|
48
|
+
resolve(true);
|
|
49
|
+
});
|
|
39
50
|
}
|
|
40
|
-
|
|
41
|
-
scope.port.on('close', clearPort);
|
|
42
|
-
|
|
43
|
-
debug('Device Connected and Open!');
|
|
44
|
-
Serial.emit('connect', scope.port);
|
|
45
|
-
|
|
46
|
-
resolve(true);
|
|
47
51
|
});
|
|
48
52
|
}
|
|
49
53
|
|