@esslassi/electron-printer 0.0.7 → 0.0.9
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 +318 -318
- package/binding.gyp +57 -57
- package/lib/electronPrinter.js +17 -18
- package/lib/native.d.ts +2 -0
- package/lib/native.js +12 -0
- package/package.json +10 -3
- package/src/linux_printer.cpp +370 -370
- package/src/linux_printer.h +30 -30
- package/src/mac_printer.cpp +372 -372
- package/src/mac_printer.h +30 -30
- package/src/main.cpp +50 -50
- package/src/print.cpp +352 -352
- package/src/printer_factory.cpp +19 -19
- package/src/printer_factory.h +12 -12
- package/src/printer_interface.h +66 -66
- package/src/windows_printer.cpp +346 -346
- package/src/windows_printer.h +63 -63
- package/test.js +0 -120
package/binding.gyp
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
{
|
|
2
|
-
"targets": [
|
|
3
|
-
{
|
|
4
|
-
"target_name": "electron_printer",
|
|
5
|
-
"sources": [
|
|
6
|
-
"src/main.cpp",
|
|
7
|
-
"src/print.cpp",
|
|
8
|
-
"src/printer_factory.cpp"
|
|
9
|
-
],
|
|
10
|
-
"include_dirs": [
|
|
11
|
-
"<!@(node -p \"require('node-addon-api').include\")"
|
|
12
|
-
],
|
|
13
|
-
"dependencies": [
|
|
14
|
-
"<!(node -p \"require('node-addon-api').gyp\")"
|
|
15
|
-
],
|
|
16
|
-
"defines": [ "NAPI_CPP_EXCEPTIONS" ],
|
|
17
|
-
"conditions": [
|
|
18
|
-
['OS=="win"', {
|
|
19
|
-
"sources": ["src/windows_printer.cpp"],
|
|
20
|
-
"libraries": ["winspool.lib"],
|
|
21
|
-
"msvs_settings": {
|
|
22
|
-
"VCCLCompilerTool": {
|
|
23
|
-
"ExceptionHandling": 1
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}],
|
|
27
|
-
['OS=="mac"', {
|
|
28
|
-
"sources": ["src/mac_printer.cpp"],
|
|
29
|
-
"libraries": ["-lcups"],
|
|
30
|
-
"include_dirs": [
|
|
31
|
-
"/usr/include/cups"
|
|
32
|
-
],
|
|
33
|
-
"xcode_settings": {
|
|
34
|
-
"OTHER_CFLAGS": ["-Wall"],
|
|
35
|
-
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
|
|
36
|
-
"CLANG_CXX_LIBRARY": "libc++",
|
|
37
|
-
"MACOSX_DEPLOYMENT_TARGET": "10.7"
|
|
38
|
-
}
|
|
39
|
-
}],
|
|
40
|
-
['OS=="linux"', {
|
|
41
|
-
"sources": ["src/linux_printer.cpp"],
|
|
42
|
-
"libraries": ["-lcups"],
|
|
43
|
-
"include_dirs": [
|
|
44
|
-
"/usr/include/cups"
|
|
45
|
-
],
|
|
46
|
-
"cflags": [
|
|
47
|
-
"-Wall",
|
|
48
|
-
"-fexceptions"
|
|
49
|
-
],
|
|
50
|
-
"cflags_cc": [
|
|
51
|
-
"-fexceptions"
|
|
52
|
-
]
|
|
53
|
-
}]
|
|
54
|
-
]
|
|
55
|
-
}
|
|
56
|
-
]
|
|
57
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"targets": [
|
|
3
|
+
{
|
|
4
|
+
"target_name": "electron_printer",
|
|
5
|
+
"sources": [
|
|
6
|
+
"src/main.cpp",
|
|
7
|
+
"src/print.cpp",
|
|
8
|
+
"src/printer_factory.cpp"
|
|
9
|
+
],
|
|
10
|
+
"include_dirs": [
|
|
11
|
+
"<!@(node -p \"require('node-addon-api').include\")"
|
|
12
|
+
],
|
|
13
|
+
"dependencies": [
|
|
14
|
+
"<!(node -p \"require('node-addon-api').gyp\")"
|
|
15
|
+
],
|
|
16
|
+
"defines": [ "NAPI_CPP_EXCEPTIONS" ],
|
|
17
|
+
"conditions": [
|
|
18
|
+
['OS=="win"', {
|
|
19
|
+
"sources": ["src/windows_printer.cpp"],
|
|
20
|
+
"libraries": ["winspool.lib"],
|
|
21
|
+
"msvs_settings": {
|
|
22
|
+
"VCCLCompilerTool": {
|
|
23
|
+
"ExceptionHandling": 1
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}],
|
|
27
|
+
['OS=="mac"', {
|
|
28
|
+
"sources": ["src/mac_printer.cpp"],
|
|
29
|
+
"libraries": ["-lcups"],
|
|
30
|
+
"include_dirs": [
|
|
31
|
+
"/usr/include/cups"
|
|
32
|
+
],
|
|
33
|
+
"xcode_settings": {
|
|
34
|
+
"OTHER_CFLAGS": ["-Wall"],
|
|
35
|
+
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
|
|
36
|
+
"CLANG_CXX_LIBRARY": "libc++",
|
|
37
|
+
"MACOSX_DEPLOYMENT_TARGET": "10.7"
|
|
38
|
+
}
|
|
39
|
+
}],
|
|
40
|
+
['OS=="linux"', {
|
|
41
|
+
"sources": ["src/linux_printer.cpp"],
|
|
42
|
+
"libraries": ["-lcups"],
|
|
43
|
+
"include_dirs": [
|
|
44
|
+
"/usr/include/cups"
|
|
45
|
+
],
|
|
46
|
+
"cflags": [
|
|
47
|
+
"-Wall",
|
|
48
|
+
"-fexceptions"
|
|
49
|
+
],
|
|
50
|
+
"cflags_cc": [
|
|
51
|
+
"-fexceptions"
|
|
52
|
+
]
|
|
53
|
+
}]
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
package/lib/electronPrinter.js
CHANGED
|
@@ -19,50 +19,49 @@ exports.printFileAsync = printFileAsync;
|
|
|
19
19
|
exports.getJobAsync = getJobAsync;
|
|
20
20
|
exports.getPrintersAsync = getPrintersAsync;
|
|
21
21
|
exports.getPrinterAsync = getPrinterAsync;
|
|
22
|
-
const
|
|
23
|
-
const native = (0, bindings_1.default)('electron_printer');
|
|
22
|
+
const native_1 = __importDefault(require("./native"));
|
|
24
23
|
/* ===========================
|
|
25
24
|
DIRECT NATIVE EXPORTS
|
|
26
25
|
=========================== */
|
|
27
26
|
function getPrinters() {
|
|
28
|
-
return
|
|
27
|
+
return native_1.default.getPrinters();
|
|
29
28
|
}
|
|
30
29
|
function getPrinter(printerName) {
|
|
31
|
-
return
|
|
30
|
+
return native_1.default.getPrinter(printerName);
|
|
32
31
|
}
|
|
33
32
|
function getPrinterDriverOptions(printerName) {
|
|
34
|
-
return
|
|
33
|
+
return native_1.default.getPrinterDriverOptions(printerName);
|
|
35
34
|
}
|
|
36
35
|
function getSelectedPaperSize(printerName) {
|
|
37
|
-
return
|
|
36
|
+
return native_1.default.getSelectedPaperSize(printerName);
|
|
38
37
|
}
|
|
39
38
|
function getDefaultPrinterName() {
|
|
40
|
-
return
|
|
39
|
+
return native_1.default.getDefaultPrinterName();
|
|
41
40
|
}
|
|
42
41
|
function printDirect(options) {
|
|
43
|
-
|
|
42
|
+
native_1.default.printDirect(options);
|
|
44
43
|
}
|
|
45
44
|
function printFile(options) {
|
|
46
|
-
|
|
45
|
+
native_1.default.printFile(options);
|
|
47
46
|
}
|
|
48
47
|
function getSupportedPrintFormats() {
|
|
49
|
-
return
|
|
48
|
+
return native_1.default.getSupportedPrintFormats();
|
|
50
49
|
}
|
|
51
50
|
function getJob(printerName, jobId) {
|
|
52
|
-
return
|
|
51
|
+
return native_1.default.getJob(printerName, jobId);
|
|
53
52
|
}
|
|
54
53
|
function setJob(printerName, jobId, command) {
|
|
55
|
-
|
|
54
|
+
native_1.default.setJob(printerName, jobId, command);
|
|
56
55
|
}
|
|
57
56
|
function getSupportedJobCommands() {
|
|
58
|
-
return
|
|
57
|
+
return native_1.default.getSupportedJobCommands();
|
|
59
58
|
}
|
|
60
59
|
/* ==================================================
|
|
61
60
|
PROMISE WRAPPERS (Async/Await Friendly)
|
|
62
61
|
================================================== */
|
|
63
62
|
function printDirectAsync(options) {
|
|
64
63
|
return new Promise((resolve, reject) => {
|
|
65
|
-
|
|
64
|
+
native_1.default.printDirect({
|
|
66
65
|
...options,
|
|
67
66
|
success: (jobId) => resolve(jobId),
|
|
68
67
|
error: (err) => reject(err)
|
|
@@ -71,7 +70,7 @@ function printDirectAsync(options) {
|
|
|
71
70
|
}
|
|
72
71
|
function printFileAsync(options) {
|
|
73
72
|
return new Promise((resolve, reject) => {
|
|
74
|
-
|
|
73
|
+
native_1.default.printFile({
|
|
75
74
|
...options,
|
|
76
75
|
success: (jobId) => resolve(jobId),
|
|
77
76
|
error: (err) => reject(err)
|
|
@@ -79,11 +78,11 @@ function printFileAsync(options) {
|
|
|
79
78
|
});
|
|
80
79
|
}
|
|
81
80
|
function getJobAsync(printerName, jobId) {
|
|
82
|
-
return Promise.resolve(
|
|
81
|
+
return Promise.resolve(native_1.default.getJob(printerName, jobId));
|
|
83
82
|
}
|
|
84
83
|
function getPrintersAsync() {
|
|
85
|
-
return Promise.resolve(
|
|
84
|
+
return Promise.resolve(native_1.default.getPrinters());
|
|
86
85
|
}
|
|
87
86
|
function getPrinterAsync(printerName) {
|
|
88
|
-
return Promise.resolve(
|
|
87
|
+
return Promise.resolve(native_1.default.getPrinter(printerName));
|
|
89
88
|
}
|
package/lib/native.d.ts
ADDED
package/lib/native.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
// Support Electron + Webpack + normal Node
|
|
8
|
+
const req = typeof global.__non_webpack_require__ === 'function'
|
|
9
|
+
? global.__non_webpack_require__
|
|
10
|
+
: require;
|
|
11
|
+
const native = req('node-gyp-build')(path_1.default.join(__dirname, '..'));
|
|
12
|
+
exports.default = native;
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esslassi/electron-printer",
|
|
3
3
|
"description": "Node.js and Electron bindings",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.9",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
|
+
"types": "./lib/index.d.ts",
|
|
6
7
|
"private": false,
|
|
7
8
|
"scripts": {
|
|
8
9
|
"install": "node-gyp rebuild",
|
|
@@ -36,11 +37,17 @@
|
|
|
36
37
|
},
|
|
37
38
|
"license": "MIT",
|
|
38
39
|
"gypfile": true,
|
|
40
|
+
"files": [
|
|
41
|
+
"lib",
|
|
42
|
+
"prebuilds",
|
|
43
|
+
"binding.gyp",
|
|
44
|
+
"src"
|
|
45
|
+
],
|
|
39
46
|
"dependencies": {
|
|
40
|
-
"bindings": "1.5.0",
|
|
41
47
|
"dotenv": "17.2.3",
|
|
42
48
|
"node-addon-api": "8.5.0",
|
|
43
|
-
"node-gyp": "12.1.0"
|
|
49
|
+
"node-gyp": "12.1.0",
|
|
50
|
+
"node-gyp-build": "^4.8.4"
|
|
44
51
|
},
|
|
45
52
|
"devDependencies": {
|
|
46
53
|
"@semantic-release/changelog": "6.0.3",
|