@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/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
+ }
@@ -19,50 +19,49 @@ exports.printFileAsync = printFileAsync;
19
19
  exports.getJobAsync = getJobAsync;
20
20
  exports.getPrintersAsync = getPrintersAsync;
21
21
  exports.getPrinterAsync = getPrinterAsync;
22
- const bindings_1 = __importDefault(require("bindings"));
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 native.getPrinters();
27
+ return native_1.default.getPrinters();
29
28
  }
30
29
  function getPrinter(printerName) {
31
- return native.getPrinter(printerName);
30
+ return native_1.default.getPrinter(printerName);
32
31
  }
33
32
  function getPrinterDriverOptions(printerName) {
34
- return native.getPrinterDriverOptions(printerName);
33
+ return native_1.default.getPrinterDriverOptions(printerName);
35
34
  }
36
35
  function getSelectedPaperSize(printerName) {
37
- return native.getSelectedPaperSize(printerName);
36
+ return native_1.default.getSelectedPaperSize(printerName);
38
37
  }
39
38
  function getDefaultPrinterName() {
40
- return native.getDefaultPrinterName();
39
+ return native_1.default.getDefaultPrinterName();
41
40
  }
42
41
  function printDirect(options) {
43
- native.printDirect(options);
42
+ native_1.default.printDirect(options);
44
43
  }
45
44
  function printFile(options) {
46
- native.printFile(options);
45
+ native_1.default.printFile(options);
47
46
  }
48
47
  function getSupportedPrintFormats() {
49
- return native.getSupportedPrintFormats();
48
+ return native_1.default.getSupportedPrintFormats();
50
49
  }
51
50
  function getJob(printerName, jobId) {
52
- return native.getJob(printerName, jobId);
51
+ return native_1.default.getJob(printerName, jobId);
53
52
  }
54
53
  function setJob(printerName, jobId, command) {
55
- native.setJob(printerName, jobId, command);
54
+ native_1.default.setJob(printerName, jobId, command);
56
55
  }
57
56
  function getSupportedJobCommands() {
58
- return native.getSupportedJobCommands();
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
- native.printDirect({
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
- native.printFile({
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(native.getJob(printerName, jobId));
81
+ return Promise.resolve(native_1.default.getJob(printerName, jobId));
83
82
  }
84
83
  function getPrintersAsync() {
85
- return Promise.resolve(native.getPrinters());
84
+ return Promise.resolve(native_1.default.getPrinters());
86
85
  }
87
86
  function getPrinterAsync(printerName) {
88
- return Promise.resolve(native.getPrinter(printerName));
87
+ return Promise.resolve(native_1.default.getPrinter(printerName));
89
88
  }
@@ -0,0 +1,2 @@
1
+ declare const native: any;
2
+ export default native;
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.7",
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",