tauri-plugin-thermal-printer 1.0.0
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 +1252 -0
- package/dist-js/index.cjs +21 -0
- package/dist-js/index.d.ts +160 -0
- package/dist-js/index.js +17 -0
- package/package.json +33 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@tauri-apps/api/core');
|
|
4
|
+
|
|
5
|
+
async function print_thermal_printer(printJobRequest) {
|
|
6
|
+
return await core.invoke('plugin:thermal-printer|print_thermal_printer', {
|
|
7
|
+
printJobRequest: printJobRequest,
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
async function list_thermal_printers() {
|
|
11
|
+
return await core.invoke('plugin:thermal-printer|list_thermal_printers');
|
|
12
|
+
}
|
|
13
|
+
async function test_thermal_printer(testPrintRequest) {
|
|
14
|
+
return await core.invoke('plugin:thermal-printer|test_thermal_printer', {
|
|
15
|
+
printTestRequest: testPrintRequest,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.list_thermal_printers = list_thermal_printers;
|
|
20
|
+
exports.print_thermal_printer = print_thermal_printer;
|
|
21
|
+
exports.test_thermal_printer = test_thermal_printer;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
export type PaperSize = 'Mm58' | 'Mm80';
|
|
2
|
+
export interface PrinterOptions {
|
|
3
|
+
cut_paper: boolean;
|
|
4
|
+
beep: boolean;
|
|
5
|
+
open_cash_drawer: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface GlobalStyles {
|
|
8
|
+
bold?: boolean;
|
|
9
|
+
underline?: boolean;
|
|
10
|
+
align?: 'left' | 'center' | 'right' | string;
|
|
11
|
+
italic?: boolean;
|
|
12
|
+
invert?: boolean;
|
|
13
|
+
font?: 'A' | 'B' | 'C' | 'D' | 'E' | string;
|
|
14
|
+
rotate?: boolean;
|
|
15
|
+
upside_down?: boolean;
|
|
16
|
+
size?: 'normal' | 'height' | 'width' | 'double' | string;
|
|
17
|
+
}
|
|
18
|
+
export interface Title {
|
|
19
|
+
text: string;
|
|
20
|
+
styles?: GlobalStyles;
|
|
21
|
+
}
|
|
22
|
+
export interface Subtitle {
|
|
23
|
+
text: string;
|
|
24
|
+
styles?: GlobalStyles;
|
|
25
|
+
}
|
|
26
|
+
export interface Text {
|
|
27
|
+
text: string;
|
|
28
|
+
styles?: GlobalStyles;
|
|
29
|
+
}
|
|
30
|
+
export interface Feed {
|
|
31
|
+
feed_type: 'lines' | 'pixels' | string;
|
|
32
|
+
value: number;
|
|
33
|
+
}
|
|
34
|
+
export interface Cut {
|
|
35
|
+
mode: 'full' | 'partial' | string;
|
|
36
|
+
feed: number;
|
|
37
|
+
}
|
|
38
|
+
export interface Beep {
|
|
39
|
+
times: number;
|
|
40
|
+
duration: number;
|
|
41
|
+
}
|
|
42
|
+
export interface Drawer {
|
|
43
|
+
pin: number;
|
|
44
|
+
pulse_time: number;
|
|
45
|
+
}
|
|
46
|
+
export interface Table {
|
|
47
|
+
columns: number;
|
|
48
|
+
column_widths?: number[];
|
|
49
|
+
header?: Text[];
|
|
50
|
+
body: Text[][];
|
|
51
|
+
truncate: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface Qr {
|
|
54
|
+
data: string;
|
|
55
|
+
size: number;
|
|
56
|
+
error_correction: 'L' | 'M' | 'Q' | 'H' | string;
|
|
57
|
+
model: number;
|
|
58
|
+
align?: 'left' | 'center' | 'right' | string;
|
|
59
|
+
}
|
|
60
|
+
export interface Barcode {
|
|
61
|
+
data: string;
|
|
62
|
+
barcode_type: 'UPCA' | 'UPCE' | 'EAN13' | 'EAN8' | 'CODE39' | 'ITF' | 'CODABAR' | 'CODE93' | 'CODE128' | string;
|
|
63
|
+
width: number;
|
|
64
|
+
height: number;
|
|
65
|
+
text_position: 'none' | 'above' | 'below' | 'both' | string;
|
|
66
|
+
}
|
|
67
|
+
export interface DataMatrixModel {
|
|
68
|
+
data: string;
|
|
69
|
+
size: number;
|
|
70
|
+
}
|
|
71
|
+
export interface Pdf417 {
|
|
72
|
+
data: string;
|
|
73
|
+
columns: number;
|
|
74
|
+
rows: number;
|
|
75
|
+
width: number;
|
|
76
|
+
height: number;
|
|
77
|
+
error_correction: number;
|
|
78
|
+
}
|
|
79
|
+
export interface Image {
|
|
80
|
+
data: string;
|
|
81
|
+
max_width: number;
|
|
82
|
+
align: 'left' | 'center' | 'right' | string;
|
|
83
|
+
dithering: boolean;
|
|
84
|
+
size: 'normal' | 'double_width' | 'double_height' | 'double' | string;
|
|
85
|
+
}
|
|
86
|
+
export interface Logo {
|
|
87
|
+
key_code: number;
|
|
88
|
+
mode: 'normal' | 'double_width' | 'double_height' | 'double' | string;
|
|
89
|
+
}
|
|
90
|
+
export interface Line {
|
|
91
|
+
character: string;
|
|
92
|
+
}
|
|
93
|
+
export type PrintSections = {
|
|
94
|
+
Title: Title;
|
|
95
|
+
} | {
|
|
96
|
+
Subtitle: Subtitle;
|
|
97
|
+
} | {
|
|
98
|
+
Text: Text;
|
|
99
|
+
} | {
|
|
100
|
+
Feed: Feed;
|
|
101
|
+
} | {
|
|
102
|
+
Cut: Cut;
|
|
103
|
+
} | {
|
|
104
|
+
Beep: Beep;
|
|
105
|
+
} | {
|
|
106
|
+
Drawer: Drawer;
|
|
107
|
+
} | {
|
|
108
|
+
GlobalStyles: GlobalStyles;
|
|
109
|
+
} | {
|
|
110
|
+
Qr: Qr;
|
|
111
|
+
} | {
|
|
112
|
+
Barcode: Barcode;
|
|
113
|
+
} | {
|
|
114
|
+
Table: Table;
|
|
115
|
+
} | {
|
|
116
|
+
DataMatrix: DataMatrixModel;
|
|
117
|
+
} | {
|
|
118
|
+
Pdf417: Pdf417;
|
|
119
|
+
} | {
|
|
120
|
+
Image: Image;
|
|
121
|
+
} | {
|
|
122
|
+
Logo: Logo;
|
|
123
|
+
} | {
|
|
124
|
+
Line: Line;
|
|
125
|
+
};
|
|
126
|
+
export interface PrintJobRequest {
|
|
127
|
+
printer: string;
|
|
128
|
+
sections: PrintSections[];
|
|
129
|
+
options: PrinterOptions;
|
|
130
|
+
paper_size: PaperSize;
|
|
131
|
+
}
|
|
132
|
+
export interface PrinterInfo {
|
|
133
|
+
name: string;
|
|
134
|
+
interface_type: string;
|
|
135
|
+
identifier: string;
|
|
136
|
+
status: string;
|
|
137
|
+
}
|
|
138
|
+
export interface TestPrintRequest {
|
|
139
|
+
printer_info: PrintJobRequest;
|
|
140
|
+
include_text?: boolean;
|
|
141
|
+
include_text_styles?: boolean;
|
|
142
|
+
include_alignment?: boolean;
|
|
143
|
+
include_columns?: boolean;
|
|
144
|
+
include_separators?: boolean;
|
|
145
|
+
include_barcode?: boolean;
|
|
146
|
+
include_barcode_types?: boolean;
|
|
147
|
+
include_qr?: boolean;
|
|
148
|
+
include_image?: boolean;
|
|
149
|
+
image_base64?: string | null;
|
|
150
|
+
include_beep?: boolean;
|
|
151
|
+
test_cash_drawer?: boolean;
|
|
152
|
+
cut_paper?: boolean;
|
|
153
|
+
test_feed?: boolean;
|
|
154
|
+
test_all_fonts?: boolean;
|
|
155
|
+
test_invert?: boolean;
|
|
156
|
+
test_rotate?: boolean;
|
|
157
|
+
}
|
|
158
|
+
export declare function print_thermal_printer(printJobRequest: PrintJobRequest): Promise<boolean>;
|
|
159
|
+
export declare function list_thermal_printers(): Promise<PrinterInfo[]>;
|
|
160
|
+
export declare function test_thermal_printer(testPrintRequest: TestPrintRequest): Promise<boolean>;
|
package/dist-js/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { invoke } from '@tauri-apps/api/core';
|
|
2
|
+
|
|
3
|
+
async function print_thermal_printer(printJobRequest) {
|
|
4
|
+
return await invoke('plugin:thermal-printer|print_thermal_printer', {
|
|
5
|
+
printJobRequest: printJobRequest,
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
async function list_thermal_printers() {
|
|
9
|
+
return await invoke('plugin:thermal-printer|list_thermal_printers');
|
|
10
|
+
}
|
|
11
|
+
async function test_thermal_printer(testPrintRequest) {
|
|
12
|
+
return await invoke('plugin:thermal-printer|test_thermal_printer', {
|
|
13
|
+
printTestRequest: testPrintRequest,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { list_thermal_printers, print_thermal_printer, test_thermal_printer };
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tauri-plugin-thermal-printer",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"author": "luis3132",
|
|
5
|
+
"description": "Plugin for Tauri to send esc/pos commands to thermal_printer",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"types": "./dist-js/index.d.ts",
|
|
8
|
+
"main": "./dist-js/index.cjs",
|
|
9
|
+
"module": "./dist-js/index.js",
|
|
10
|
+
"exports": {
|
|
11
|
+
"types": "./dist-js/index.d.ts",
|
|
12
|
+
"import": "./dist-js/index.js",
|
|
13
|
+
"require": "./dist-js/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist-js",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "rollup -c",
|
|
21
|
+
"prepublishOnly": "bun run build",
|
|
22
|
+
"pretest": "bun run build"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@tauri-apps/api": "^2.10.1"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
29
|
+
"rollup": "^4.57.1",
|
|
30
|
+
"typescript": "^5.9.3",
|
|
31
|
+
"tslib": "^2.8.1"
|
|
32
|
+
}
|
|
33
|
+
}
|