@esslassi/electron-printer 0.0.5 → 0.0.6

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.
@@ -0,0 +1,33 @@
1
+ export interface PrintOptions {
2
+ printerName: string;
3
+ data: string | Buffer;
4
+ dataType?: 'RAW' | 'TEXT' | 'COMMAND' | 'AUTO' | undefined;
5
+ }
6
+ export interface Printer {
7
+ name: string;
8
+ isDefault: boolean;
9
+ status: string;
10
+ details: {
11
+ location?: string;
12
+ comment?: string;
13
+ driver?: string;
14
+ port?: string;
15
+ [key: string]: string | undefined;
16
+ };
17
+ }
18
+ export interface PrintDirectOptions {
19
+ printerName: string;
20
+ data: string | Buffer;
21
+ dataType?: 'RAW' | 'TEXT' | 'COMMAND' | 'AUTO' | undefined;
22
+ }
23
+ export interface GetStatusPrinterOptions {
24
+ printerName: string;
25
+ }
26
+ export interface PrintDirectOutput {
27
+ name: string;
28
+ status: 'success' | 'failed';
29
+ }
30
+ export declare function printDirect(printOptions: PrintOptions): Promise<PrintDirectOutput>;
31
+ export declare function getStatusPrinter(printOptions: GetStatusPrinterOptions): Promise<Printer>;
32
+ export declare function getPrinters(): Promise<Printer[]>;
33
+ export declare function getDefaultPrinter(): Promise<Printer>;
@@ -0,0 +1,38 @@
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
+ exports.printDirect = printDirect;
7
+ exports.getStatusPrinter = getStatusPrinter;
8
+ exports.getPrinters = getPrinters;
9
+ exports.getDefaultPrinter = getDefaultPrinter;
10
+ const bindings_1 = __importDefault(require("bindings"));
11
+ const electronPrinter = (0, bindings_1.default)('electron_printer');
12
+ async function printDirect(printOptions) {
13
+ const input = {
14
+ ...printOptions,
15
+ printerName: normalizeString(printOptions.printerName)
16
+ };
17
+ const printer = await electronPrinter.printDirect(input);
18
+ return printer;
19
+ }
20
+ async function getStatusPrinter(printOptions) {
21
+ const input = {
22
+ ...printOptions,
23
+ printerName: normalizeString(printOptions.printerName)
24
+ };
25
+ const printer = await electronPrinter.getStatusPrinter(input);
26
+ return printer;
27
+ }
28
+ async function getPrinters() {
29
+ const printers = await electronPrinter.getPrinters();
30
+ return printers;
31
+ }
32
+ async function getDefaultPrinter() {
33
+ const printer = await electronPrinter.getDefaultPrinter();
34
+ return printer;
35
+ }
36
+ function normalizeString(str) {
37
+ return String.raw `${str}`;
38
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './electronPrinter';
package/lib/index.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./electronPrinter"), exports);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@esslassi/electron-printer",
3
3
  "description": "Node.js and Electron bindings",
4
- "version": "0.0.5",
4
+ "version": "0.0.6",
5
5
  "main": "./lib/index.js",
6
6
  "private": false,
7
7
  "scripts": {