@levischuck/receiptline 0.0.5 → 0.1.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 +315 -278
- package/dist/index.d.ts +8 -5
- package/dist/index.js +1777 -444
- package/dist/parse.d.ts +1 -1
- package/dist/targets/audit.d.ts +157 -0
- package/dist/targets/base.d.ts +68 -48
- package/dist/targets/html.d.ts +72 -0
- package/dist/targets/index.d.ts +4 -0
- package/dist/targets/svg.d.ts +24 -24
- package/dist/types.d.ts +27 -24
- package/package.json +6 -4
package/dist/parse.d.ts
CHANGED
|
@@ -69,5 +69,5 @@ export declare function parseLine(columns: string, state: ParseState): ParsedCol
|
|
|
69
69
|
* @param state state variables
|
|
70
70
|
* @returns printer command fragment or SVG image fragment
|
|
71
71
|
*/
|
|
72
|
-
export declare function createLine(line: ParsedColumn[], printer: ParsedPrinter, state: ParseState): string
|
|
72
|
+
export declare function createLine(line: ParsedColumn[], printer: ParsedPrinter, state: ParseState): Promise<string>;
|
|
73
73
|
export {};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { BaseTarget } from './base.ts';
|
|
2
|
+
import { Encoding, ParsedPrinter, QRCode, Barcode } from '../types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Audit target class for ReceiptLine commands.
|
|
5
|
+
* Logs all method calls instead of implementing them.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AuditTarget extends BaseTarget {
|
|
8
|
+
private logs;
|
|
9
|
+
/**
|
|
10
|
+
* Start printing.
|
|
11
|
+
* @param {object} printer printer configuration
|
|
12
|
+
* @returns {Promise<string>} empty string
|
|
13
|
+
*/
|
|
14
|
+
open(printer: ParsedPrinter): Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Finish printing.
|
|
17
|
+
* @returns {Promise<string>} all logs joined with newlines
|
|
18
|
+
*/
|
|
19
|
+
close(): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Set print area.
|
|
22
|
+
* @param {number} left left margin (unit: characters)
|
|
23
|
+
* @param {number} width print area (unit: characters)
|
|
24
|
+
* @param {number} right right margin (unit: characters)
|
|
25
|
+
* @returns {Promise<string>} empty string
|
|
26
|
+
*/
|
|
27
|
+
area(left: number, width: number, right: number): Promise<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Set line alignment.
|
|
30
|
+
* @param {number} align line alignment (0: left, 1: center, 2: right)
|
|
31
|
+
* @returns {Promise<string>} empty string
|
|
32
|
+
*/
|
|
33
|
+
align(align: number): Promise<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Set absolute print position.
|
|
36
|
+
* @param {number} position absolute position (unit: characters)
|
|
37
|
+
* @returns {Promise<string>} empty string
|
|
38
|
+
*/
|
|
39
|
+
absolute(position: number): Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Set relative print position.
|
|
42
|
+
* @param {number} position relative position (unit: characters)
|
|
43
|
+
* @returns {Promise<string>} empty string
|
|
44
|
+
*/
|
|
45
|
+
relative(position: number): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Print horizontal rule.
|
|
48
|
+
* @param {number} width line width (unit: characters)
|
|
49
|
+
* @returns {Promise<string>} empty string
|
|
50
|
+
*/
|
|
51
|
+
hr(width: number): Promise<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Print vertical rules.
|
|
54
|
+
* @param {number[]} widths vertical line spacing
|
|
55
|
+
* @param {number} height text height (1-6)
|
|
56
|
+
* @returns {Promise<string>} empty string
|
|
57
|
+
*/
|
|
58
|
+
vr(widths: number[], height: number): Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Start rules.
|
|
61
|
+
* @param {number[]} widths vertical line spacing
|
|
62
|
+
* @returns {Promise<string>} empty string
|
|
63
|
+
*/
|
|
64
|
+
vrstart(widths: number[]): Promise<string>;
|
|
65
|
+
/**
|
|
66
|
+
* Stop rules.
|
|
67
|
+
* @param {number[]} widths vertical line spacing
|
|
68
|
+
* @returns {Promise<string>} empty string
|
|
69
|
+
*/
|
|
70
|
+
vrstop(widths: number[]): Promise<string>;
|
|
71
|
+
/**
|
|
72
|
+
* Print vertical and horizontal rules.
|
|
73
|
+
* @param {number[]} widths1 vertical line spacing (stop)
|
|
74
|
+
* @param {number[]} widths2 vertical line spacing (start)
|
|
75
|
+
* @param {number} dl difference in left position
|
|
76
|
+
* @param {number} dr difference in right position
|
|
77
|
+
* @returns {Promise<string>} empty string
|
|
78
|
+
*/
|
|
79
|
+
vrhr(widths1: number[], widths2: number[], dl: number, dr: number): Promise<string>;
|
|
80
|
+
/**
|
|
81
|
+
* Set line spacing and feed new line.
|
|
82
|
+
* @param {boolean} vr whether vertical ruled lines are printed
|
|
83
|
+
* @returns {Promise<string>} empty string
|
|
84
|
+
*/
|
|
85
|
+
vrlf(vr: boolean): Promise<string>;
|
|
86
|
+
/**
|
|
87
|
+
* Cut paper.
|
|
88
|
+
* @returns {Promise<string>} empty string
|
|
89
|
+
*/
|
|
90
|
+
cut(): Promise<string>;
|
|
91
|
+
/**
|
|
92
|
+
* Underline text.
|
|
93
|
+
* @returns {Promise<string>} empty string
|
|
94
|
+
*/
|
|
95
|
+
ul(): Promise<string>;
|
|
96
|
+
/**
|
|
97
|
+
* Emphasize text.
|
|
98
|
+
* @returns {Promise<string>} empty string
|
|
99
|
+
*/
|
|
100
|
+
em(): Promise<string>;
|
|
101
|
+
/**
|
|
102
|
+
* Invert text.
|
|
103
|
+
* @returns {Promise<string>} empty string
|
|
104
|
+
*/
|
|
105
|
+
iv(): Promise<string>;
|
|
106
|
+
/**
|
|
107
|
+
* Scale up text.
|
|
108
|
+
* @param {number} wh number of special character '^' (1-7)
|
|
109
|
+
* @returns {Promise<string>} empty string
|
|
110
|
+
*/
|
|
111
|
+
wh(wh: number): Promise<string>;
|
|
112
|
+
/**
|
|
113
|
+
* Cancel text decoration.
|
|
114
|
+
* @returns {Promise<string>} empty string
|
|
115
|
+
*/
|
|
116
|
+
normal(): Promise<string>;
|
|
117
|
+
/**
|
|
118
|
+
* Print text.
|
|
119
|
+
* @param {string} text string to print
|
|
120
|
+
* @param {string} encoding codepage
|
|
121
|
+
* @returns {Promise<string>} empty string
|
|
122
|
+
*/
|
|
123
|
+
text(text: string, encoding: Encoding): Promise<string>;
|
|
124
|
+
/**
|
|
125
|
+
* Feed new line.
|
|
126
|
+
* @returns {Promise<string>} empty string
|
|
127
|
+
*/
|
|
128
|
+
lf(): Promise<string>;
|
|
129
|
+
/**
|
|
130
|
+
* Insert commands.
|
|
131
|
+
* @param {string} command commands to insert
|
|
132
|
+
* @returns {Promise<string>} empty string
|
|
133
|
+
*/
|
|
134
|
+
command(command: string): Promise<string>;
|
|
135
|
+
/**
|
|
136
|
+
* Print image.
|
|
137
|
+
* @param {string} image image data (base64 png format)
|
|
138
|
+
* @returns {Promise<string>} empty string
|
|
139
|
+
*/
|
|
140
|
+
image(image: string): Promise<string>;
|
|
141
|
+
/**
|
|
142
|
+
* Print QR Code.
|
|
143
|
+
* @param {object} symbol QR Code information (data, type, cell, level)
|
|
144
|
+
* @param {string} encoding codepage
|
|
145
|
+
* @returns {Promise<string>} empty string
|
|
146
|
+
*/
|
|
147
|
+
qrcode(symbol: QRCode, encoding: Encoding): Promise<string>;
|
|
148
|
+
/**
|
|
149
|
+
* Print barcode.
|
|
150
|
+
* @param {object} symbol barcode information (data, type, width, height, hri)
|
|
151
|
+
* @param {string} encoding codepage
|
|
152
|
+
* @returns {Promise<string>} empty string
|
|
153
|
+
*/
|
|
154
|
+
barcode(symbol: Barcode, encoding: Encoding): Promise<string>;
|
|
155
|
+
calculatedWidth(): number;
|
|
156
|
+
calculatedHeight(): number;
|
|
157
|
+
}
|
package/dist/targets/base.d.ts
CHANGED
|
@@ -3,6 +3,26 @@ import { Encoding, ParsedPrinter, QRCode, Barcode, BaseTargetInterface } from '.
|
|
|
3
3
|
* Base target class for ReceiptLine commands.
|
|
4
4
|
*/
|
|
5
5
|
export declare class BaseTarget implements BaseTargetInterface {
|
|
6
|
+
private locked;
|
|
7
|
+
private lockPromise;
|
|
8
|
+
private lockResolve;
|
|
9
|
+
protected _cpl: number;
|
|
10
|
+
/**
|
|
11
|
+
* Get characters per line.
|
|
12
|
+
* @returns {number} characters per line
|
|
13
|
+
*/
|
|
14
|
+
get cpl(): number;
|
|
15
|
+
/**
|
|
16
|
+
* Lock the target for exclusive use.
|
|
17
|
+
* @param {number} [timeout] timeout in milliseconds (default: 5000)
|
|
18
|
+
* @returns {Promise<void>} resolves when lock is acquired
|
|
19
|
+
* @throws {Error} if timeout occurs
|
|
20
|
+
*/
|
|
21
|
+
lock(timeout?: number): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Unlock the target.
|
|
24
|
+
*/
|
|
25
|
+
unlock(): void;
|
|
6
26
|
/**
|
|
7
27
|
* Measure text width.
|
|
8
28
|
* @param {string} text string to measure
|
|
@@ -20,149 +40,149 @@ export declare class BaseTarget implements BaseTargetInterface {
|
|
|
20
40
|
/**
|
|
21
41
|
* Start printing.
|
|
22
42
|
* @param {object} printer printer configuration
|
|
23
|
-
* @returns {string} commands
|
|
43
|
+
* @returns {Promise<string>} commands
|
|
24
44
|
*/
|
|
25
|
-
open(printer: ParsedPrinter): string
|
|
45
|
+
open(printer: ParsedPrinter): Promise<string>;
|
|
26
46
|
/**
|
|
27
47
|
* Finish printing.
|
|
28
|
-
* @returns {string} commands
|
|
48
|
+
* @returns {Promise<string>} commands
|
|
29
49
|
*/
|
|
30
|
-
close(): string
|
|
50
|
+
close(): Promise<string>;
|
|
31
51
|
/**
|
|
32
52
|
* Set print area.
|
|
33
53
|
* @param {number} left left margin (unit: characters)
|
|
34
54
|
* @param {number} width print area (unit: characters)
|
|
35
55
|
* @param {number} right right margin (unit: characters)
|
|
36
|
-
* @returns {string} commands
|
|
56
|
+
* @returns {Promise<string>} commands
|
|
37
57
|
*/
|
|
38
|
-
area(left: number, width: number, right: number): string
|
|
58
|
+
area(left: number, width: number, right: number): Promise<string>;
|
|
39
59
|
/**
|
|
40
60
|
* Set line alignment.
|
|
41
61
|
* @param {number} align line alignment (0: left, 1: center, 2: right)
|
|
42
|
-
* @returns {string} commands
|
|
62
|
+
* @returns {Promise<string>} commands
|
|
43
63
|
*/
|
|
44
|
-
align(align: number): string
|
|
64
|
+
align(align: number): Promise<string>;
|
|
45
65
|
/**
|
|
46
66
|
* Set absolute print position.
|
|
47
67
|
* @param {number} position absolute position (unit: characters)
|
|
48
|
-
* @returns {string} commands
|
|
68
|
+
* @returns {Promise<string>} commands
|
|
49
69
|
*/
|
|
50
|
-
absolute(position: number): string
|
|
70
|
+
absolute(position: number): Promise<string>;
|
|
51
71
|
/**
|
|
52
72
|
* Set relative print position.
|
|
53
73
|
* @param {number} position relative position (unit: characters)
|
|
54
|
-
* @returns {string} commands
|
|
74
|
+
* @returns {Promise<string>} commands
|
|
55
75
|
*/
|
|
56
|
-
relative(position: number): string
|
|
76
|
+
relative(position: number): Promise<string>;
|
|
57
77
|
/**
|
|
58
78
|
* Print horizontal rule.
|
|
59
79
|
* @param {number} width line width (unit: characters)
|
|
60
|
-
* @returns {string} commands
|
|
80
|
+
* @returns {Promise<string>} commands
|
|
61
81
|
*/
|
|
62
|
-
hr(width: number): string
|
|
82
|
+
hr(width: number): Promise<string>;
|
|
63
83
|
/**
|
|
64
84
|
* Print vertical rules.
|
|
65
85
|
* @param {number[]} widths vertical line spacing
|
|
66
86
|
* @param {number} height text height (1-6)
|
|
67
|
-
* @returns {string} commands
|
|
87
|
+
* @returns {Promise<string>} commands
|
|
68
88
|
*/
|
|
69
|
-
vr(widths: number[], height: number): string
|
|
89
|
+
vr(widths: number[], height: number): Promise<string>;
|
|
70
90
|
/**
|
|
71
91
|
* Start rules.
|
|
72
92
|
* @param {number[]} widths vertical line spacing
|
|
73
|
-
* @returns {string} commands
|
|
93
|
+
* @returns {Promise<string>} commands
|
|
74
94
|
*/
|
|
75
|
-
vrstart(widths: number[]): string
|
|
95
|
+
vrstart(widths: number[]): Promise<string>;
|
|
76
96
|
/**
|
|
77
97
|
* Stop rules.
|
|
78
98
|
* @param {number[]} widths vertical line spacing
|
|
79
|
-
* @returns {string} commands
|
|
99
|
+
* @returns {Promise<string>} commands
|
|
80
100
|
*/
|
|
81
|
-
vrstop(widths: number[]): string
|
|
101
|
+
vrstop(widths: number[]): Promise<string>;
|
|
82
102
|
/**
|
|
83
103
|
* Print vertical and horizontal rules.
|
|
84
104
|
* @param {number[]} widths1 vertical line spacing (stop)
|
|
85
105
|
* @param {number[]} widths2 vertical line spacing (start)
|
|
86
106
|
* @param {number} dl difference in left position
|
|
87
107
|
* @param {number} dr difference in right position
|
|
88
|
-
* @returns {string} commands
|
|
108
|
+
* @returns {Promise<string>} commands
|
|
89
109
|
*/
|
|
90
|
-
vrhr(widths1: number[], widths2: number[], dl: number, dr: number): string
|
|
110
|
+
vrhr(widths1: number[], widths2: number[], dl: number, dr: number): Promise<string>;
|
|
91
111
|
/**
|
|
92
112
|
* Set line spacing and feed new line.
|
|
93
113
|
* @param {boolean} vr whether vertical ruled lines are printed
|
|
94
|
-
* @returns {string} commands
|
|
114
|
+
* @returns {Promise<string>} commands
|
|
95
115
|
*/
|
|
96
|
-
vrlf(vr: boolean): string
|
|
116
|
+
vrlf(vr: boolean): Promise<string>;
|
|
97
117
|
/**
|
|
98
118
|
* Cut paper.
|
|
99
|
-
* @returns {string} commands
|
|
119
|
+
* @returns {Promise<string>} commands
|
|
100
120
|
*/
|
|
101
|
-
cut(): string
|
|
121
|
+
cut(): Promise<string>;
|
|
102
122
|
/**
|
|
103
123
|
* Underline text.
|
|
104
|
-
* @returns {string} commands
|
|
124
|
+
* @returns {Promise<string>} commands
|
|
105
125
|
*/
|
|
106
|
-
ul(): string
|
|
126
|
+
ul(): Promise<string>;
|
|
107
127
|
/**
|
|
108
128
|
* Emphasize text.
|
|
109
|
-
* @returns {string} commands
|
|
129
|
+
* @returns {Promise<string>} commands
|
|
110
130
|
*/
|
|
111
|
-
em(): string
|
|
131
|
+
em(): Promise<string>;
|
|
112
132
|
/**
|
|
113
133
|
* Invert text.
|
|
114
|
-
* @returns {string} commands
|
|
134
|
+
* @returns {Promise<string>} commands
|
|
115
135
|
*/
|
|
116
|
-
iv(): string
|
|
136
|
+
iv(): Promise<string>;
|
|
117
137
|
/**
|
|
118
138
|
* Scale up text.
|
|
119
139
|
* @param {number} wh number of special character '^' (1-7)
|
|
120
|
-
* @returns {string} commands
|
|
140
|
+
* @returns {Promise<string>} commands
|
|
121
141
|
*/
|
|
122
|
-
wh(wh: number): string
|
|
142
|
+
wh(wh: number): Promise<string>;
|
|
123
143
|
/**
|
|
124
144
|
* Cancel text decoration.
|
|
125
|
-
* @returns {string} commands
|
|
145
|
+
* @returns {Promise<string>} commands
|
|
126
146
|
*/
|
|
127
|
-
normal(): string
|
|
147
|
+
normal(): Promise<string>;
|
|
128
148
|
/**
|
|
129
149
|
* Print text.
|
|
130
150
|
* @param {string} text string to print
|
|
131
151
|
* @param {string} encoding codepage
|
|
132
|
-
* @returns {string} commands
|
|
152
|
+
* @returns {Promise<string>} commands
|
|
133
153
|
*/
|
|
134
|
-
text(text: string, encoding: Encoding): string
|
|
154
|
+
text(text: string, encoding: Encoding): Promise<string>;
|
|
135
155
|
/**
|
|
136
156
|
* Feed new line.
|
|
137
|
-
* @returns {string} commands
|
|
157
|
+
* @returns {Promise<string>} commands
|
|
138
158
|
*/
|
|
139
|
-
lf(): string
|
|
159
|
+
lf(): Promise<string>;
|
|
140
160
|
/**
|
|
141
161
|
* Insert commands.
|
|
142
162
|
* @param {string} command commands to insert
|
|
143
|
-
* @returns {string} commands
|
|
163
|
+
* @returns {Promise<string>} commands
|
|
144
164
|
*/
|
|
145
|
-
command(command: string): string
|
|
165
|
+
command(command: string): Promise<string>;
|
|
146
166
|
/**
|
|
147
167
|
* Print image.
|
|
148
168
|
* @param {string} image image data (base64 png format)
|
|
149
|
-
* @returns {string} commands
|
|
169
|
+
* @returns {Promise<string>} commands
|
|
150
170
|
*/
|
|
151
|
-
image(image: string): string
|
|
171
|
+
image(image: string): Promise<string>;
|
|
152
172
|
/**
|
|
153
173
|
* Print QR Code.
|
|
154
174
|
* @param {object} symbol QR Code information (data, type, cell, level)
|
|
155
175
|
* @param {string} encoding codepage
|
|
156
|
-
* @returns {string} commands
|
|
176
|
+
* @returns {Promise<string>} commands
|
|
157
177
|
*/
|
|
158
|
-
qrcode(symbol: QRCode, encoding: Encoding): string
|
|
178
|
+
qrcode(symbol: QRCode, encoding: Encoding): Promise<string>;
|
|
159
179
|
/**
|
|
160
180
|
* Print barcode.
|
|
161
181
|
* @param {object} symbol barcode information (data, type, width, height, hri)
|
|
162
182
|
* @param {string} encoding codepage
|
|
163
|
-
* @returns {string} commands
|
|
183
|
+
* @returns {Promise<string>} commands
|
|
164
184
|
*/
|
|
165
|
-
barcode(symbol: Barcode, encoding: Encoding): string
|
|
185
|
+
barcode(symbol: Barcode, encoding: Encoding): Promise<string>;
|
|
166
186
|
calculatedWidth(): number;
|
|
167
187
|
calculatedHeight(): number;
|
|
168
188
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { BaseTarget } from './base.ts';
|
|
2
|
+
import { Encoding, ParsedPrinter, QRCode, Barcode } from '../types.ts';
|
|
3
|
+
import { HtmlNode, HtmlStyle, HtmlElement } from '@levischuck/tiny-html';
|
|
4
|
+
/**
|
|
5
|
+
* Represents a text segment queued for rendering on a line.
|
|
6
|
+
* Receipt printers accumulate positioning and text commands, then render on linefeed.
|
|
7
|
+
*/
|
|
8
|
+
interface LineSegment {
|
|
9
|
+
position: number;
|
|
10
|
+
text: string;
|
|
11
|
+
styles: HtmlStyle;
|
|
12
|
+
scale: number;
|
|
13
|
+
charWidth: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* HTML target class for ReceiptLine commands.
|
|
17
|
+
* Uses CSS for natural text flow and word wrapping instead of absolute positioning.
|
|
18
|
+
*/
|
|
19
|
+
export declare class HtmlTarget extends BaseTarget {
|
|
20
|
+
charWidth: number;
|
|
21
|
+
charHeight: number;
|
|
22
|
+
containerWidth: number;
|
|
23
|
+
estimatedHeight: number;
|
|
24
|
+
lineMargin: number;
|
|
25
|
+
lineAlign: number;
|
|
26
|
+
lineWidth: number;
|
|
27
|
+
lineHeight: number;
|
|
28
|
+
textEncoding: Encoding;
|
|
29
|
+
feedMinimum: number;
|
|
30
|
+
spacing: boolean;
|
|
31
|
+
defaultFont: string;
|
|
32
|
+
actualFontCharacterWidth: number | undefined;
|
|
33
|
+
private explicitCharHeight;
|
|
34
|
+
contentNodes: HtmlNode[];
|
|
35
|
+
currentStyles: HtmlStyle;
|
|
36
|
+
textScale: number;
|
|
37
|
+
currentPosition: number;
|
|
38
|
+
lineSegments: LineSegment[];
|
|
39
|
+
pendingVrSvg: HtmlElement | null;
|
|
40
|
+
open(printer: ParsedPrinter): Promise<string>;
|
|
41
|
+
setDefaultFont(font: string): string;
|
|
42
|
+
setActualFontCharacterWidth(width: number | undefined): void;
|
|
43
|
+
setCharHeight(height: number | undefined): void;
|
|
44
|
+
close(): Promise<string>;
|
|
45
|
+
area(left: number, width: number, _right: number): Promise<string>;
|
|
46
|
+
align(align: number): Promise<string>;
|
|
47
|
+
absolute(position: number): Promise<string>;
|
|
48
|
+
relative(position: number): Promise<string>;
|
|
49
|
+
hr(width: number): Promise<string>;
|
|
50
|
+
vr(widths: number[], height: number): Promise<string>;
|
|
51
|
+
vrstart(widths: number[]): Promise<string>;
|
|
52
|
+
private buildVrStartPath;
|
|
53
|
+
vrstop(widths: number[]): Promise<string>;
|
|
54
|
+
private buildVrStopPath;
|
|
55
|
+
vrhr(widths1: number[], widths2: number[], dl: number, dr: number): Promise<string>;
|
|
56
|
+
vrlf(vr: boolean): Promise<string>;
|
|
57
|
+
cut(): Promise<string>;
|
|
58
|
+
ul(): Promise<string>;
|
|
59
|
+
em(): Promise<string>;
|
|
60
|
+
iv(): Promise<string>;
|
|
61
|
+
wh(wh: number): Promise<string>;
|
|
62
|
+
normal(): Promise<string>;
|
|
63
|
+
text(text: string, encoding: Encoding): Promise<string>;
|
|
64
|
+
lf(): Promise<string>;
|
|
65
|
+
command(_command: string): Promise<string>;
|
|
66
|
+
image(image: string): Promise<string>;
|
|
67
|
+
qrcode(symbol: QRCode, _encoding: Encoding): Promise<string>;
|
|
68
|
+
barcode(symbol: Barcode, _encoding: Encoding): Promise<string>;
|
|
69
|
+
calculatedWidth(): number;
|
|
70
|
+
calculatedHeight(): number;
|
|
71
|
+
}
|
|
72
|
+
export {};
|
package/dist/targets/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { BaseTarget } from './base.ts';
|
|
2
2
|
import { SvgTarget } from './svg.ts';
|
|
3
|
+
import { HtmlTarget } from './html.ts';
|
|
4
|
+
import { AuditTarget } from './audit.ts';
|
|
3
5
|
declare const _default: {
|
|
4
6
|
base: BaseTarget;
|
|
5
7
|
svg: SvgTarget;
|
|
8
|
+
html: HtmlTarget;
|
|
9
|
+
audit: AuditTarget;
|
|
6
10
|
};
|
|
7
11
|
export default _default;
|
package/dist/targets/svg.d.ts
CHANGED
|
@@ -22,31 +22,31 @@ export declare class SvgTarget extends BaseTarget {
|
|
|
22
22
|
spacing: boolean;
|
|
23
23
|
defaultFont: string;
|
|
24
24
|
fontSize: number;
|
|
25
|
-
open(printer: ParsedPrinter): string
|
|
25
|
+
open(printer: ParsedPrinter): Promise<string>;
|
|
26
26
|
setDefaultFont(font: string): string;
|
|
27
|
-
close(): string
|
|
28
|
-
area(left: number, width: number, right: number): string
|
|
29
|
-
align(align: number): string
|
|
30
|
-
absolute(position: number): string
|
|
31
|
-
relative(position: number): string
|
|
32
|
-
hr(width: number): string
|
|
33
|
-
vr(widths: number[], height: number): string
|
|
34
|
-
vrstart(widths: number[]): string
|
|
35
|
-
vrstop(widths: number[]): string
|
|
36
|
-
vrhr(widths1: number[], widths2: number[], dl: number, dr: number): string
|
|
37
|
-
vrlf(vr: boolean): string
|
|
38
|
-
cut(): string
|
|
39
|
-
ul(): string
|
|
40
|
-
em(): string
|
|
41
|
-
iv(): string
|
|
42
|
-
wh(wh: number): string
|
|
43
|
-
normal(): string
|
|
44
|
-
text(text: string, encoding: Encoding): string
|
|
45
|
-
lf(): string
|
|
46
|
-
command(command: string): string
|
|
47
|
-
image(image: string): string
|
|
48
|
-
qrcode(symbol: QRCode, _encoding: Encoding): string
|
|
49
|
-
barcode(symbol: Barcode, encoding: Encoding): string
|
|
27
|
+
close(): Promise<string>;
|
|
28
|
+
area(left: number, width: number, right: number): Promise<string>;
|
|
29
|
+
align(align: number): Promise<string>;
|
|
30
|
+
absolute(position: number): Promise<string>;
|
|
31
|
+
relative(position: number): Promise<string>;
|
|
32
|
+
hr(width: number): Promise<string>;
|
|
33
|
+
vr(widths: number[], height: number): Promise<string>;
|
|
34
|
+
vrstart(widths: number[]): Promise<string>;
|
|
35
|
+
vrstop(widths: number[]): Promise<string>;
|
|
36
|
+
vrhr(widths1: number[], widths2: number[], dl: number, dr: number): Promise<string>;
|
|
37
|
+
vrlf(vr: boolean): Promise<string>;
|
|
38
|
+
cut(): Promise<string>;
|
|
39
|
+
ul(): Promise<string>;
|
|
40
|
+
em(): Promise<string>;
|
|
41
|
+
iv(): Promise<string>;
|
|
42
|
+
wh(wh: number): Promise<string>;
|
|
43
|
+
normal(): Promise<string>;
|
|
44
|
+
text(text: string, encoding: Encoding): Promise<string>;
|
|
45
|
+
lf(): Promise<string>;
|
|
46
|
+
command(command: string): Promise<string>;
|
|
47
|
+
image(image: string): Promise<string>;
|
|
48
|
+
qrcode(symbol: QRCode, _encoding: Encoding): Promise<string>;
|
|
49
|
+
barcode(symbol: Barcode, encoding: Encoding): Promise<string>;
|
|
50
50
|
calculatedWidth(): number;
|
|
51
51
|
calculatedHeight(): number;
|
|
52
52
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -9,32 +9,35 @@ export type ParsedPrinter = {
|
|
|
9
9
|
target: BaseTargetInterface;
|
|
10
10
|
};
|
|
11
11
|
export interface BaseTargetInterface {
|
|
12
|
+
readonly cpl: number;
|
|
13
|
+
lock(timeout?: number): Promise<void>;
|
|
14
|
+
unlock(): void;
|
|
12
15
|
measureText(text: string, encoding: Encoding): number;
|
|
13
16
|
arrayFrom(text: string, encoding: Encoding): string[];
|
|
14
|
-
open(printer: ParsedPrinter): string
|
|
15
|
-
close(): string
|
|
16
|
-
area(left: number, width: number, right: number): string
|
|
17
|
-
align(align: number): string
|
|
18
|
-
absolute(position: number): string
|
|
19
|
-
relative(position: number): string
|
|
20
|
-
hr(width: number): string
|
|
21
|
-
vr(widths: number[], height: number): string
|
|
22
|
-
vrstart(widths: number[]): string
|
|
23
|
-
vrstop(widths: number[]): string
|
|
24
|
-
vrhr(widths1: number[], widths2: number[], dl: number, dr: number): string
|
|
25
|
-
vrlf(vr: boolean): string
|
|
26
|
-
cut(): string
|
|
27
|
-
ul(): string
|
|
28
|
-
em(): string
|
|
29
|
-
iv(): string
|
|
30
|
-
wh(wh: number): string
|
|
31
|
-
normal(): string
|
|
32
|
-
text(text: string, encoding: Encoding): string
|
|
33
|
-
lf(): string
|
|
34
|
-
command(command: string): string
|
|
35
|
-
image(image: string): string
|
|
36
|
-
qrcode(symbol: QRCode, encoding: Encoding): string
|
|
37
|
-
barcode(symbol: Barcode, encoding: Encoding): string
|
|
17
|
+
open(printer: ParsedPrinter): Promise<string>;
|
|
18
|
+
close(): Promise<string>;
|
|
19
|
+
area(left: number, width: number, right: number): Promise<string>;
|
|
20
|
+
align(align: number): Promise<string>;
|
|
21
|
+
absolute(position: number): Promise<string>;
|
|
22
|
+
relative(position: number): Promise<string>;
|
|
23
|
+
hr(width: number): Promise<string>;
|
|
24
|
+
vr(widths: number[], height: number): Promise<string>;
|
|
25
|
+
vrstart(widths: number[]): Promise<string>;
|
|
26
|
+
vrstop(widths: number[]): Promise<string>;
|
|
27
|
+
vrhr(widths1: number[], widths2: number[], dl: number, dr: number): Promise<string>;
|
|
28
|
+
vrlf(vr: boolean): Promise<string>;
|
|
29
|
+
cut(): Promise<string>;
|
|
30
|
+
ul(): Promise<string>;
|
|
31
|
+
em(): Promise<string>;
|
|
32
|
+
iv(): Promise<string>;
|
|
33
|
+
wh(wh: number): Promise<string>;
|
|
34
|
+
normal(): Promise<string>;
|
|
35
|
+
text(text: string, encoding: Encoding): Promise<string>;
|
|
36
|
+
lf(): Promise<string>;
|
|
37
|
+
command(command: string): Promise<string>;
|
|
38
|
+
image(image: string): Promise<string>;
|
|
39
|
+
qrcode(symbol: QRCode, encoding: Encoding): Promise<string>;
|
|
40
|
+
barcode(symbol: Barcode, encoding: Encoding): Promise<string>;
|
|
38
41
|
calculatedWidth(): number;
|
|
39
42
|
calculatedHeight(): number;
|
|
40
43
|
}
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"author": "Open Foodservice System Consortium, Levi Schuck",
|
|
8
|
-
"version": "0.0
|
|
8
|
+
"version": "0.1.0",
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@types/bun": "latest",
|
|
11
11
|
"unplugin-dts": "^1.0.0-beta.6",
|
|
@@ -16,8 +16,10 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@levischuck/tiny-encodings": "^0.2.11",
|
|
19
|
-
"@levischuck/tiny-
|
|
20
|
-
"@levischuck/tiny-qr
|
|
19
|
+
"@levischuck/tiny-html": "^0.1.1",
|
|
20
|
+
"@levischuck/tiny-qr": "^0.0.8",
|
|
21
|
+
"@levischuck/tiny-qr-png": "^0.0.10",
|
|
22
|
+
"@levischuck/tiny-qr-svg": "^0.0.8"
|
|
21
23
|
},
|
|
22
24
|
"keywords": [
|
|
23
25
|
"kiosk",
|
|
@@ -39,7 +41,7 @@
|
|
|
39
41
|
},
|
|
40
42
|
"scripts": {
|
|
41
43
|
"build": "vite build",
|
|
42
|
-
"type-check": "tsc --noEmit"
|
|
44
|
+
"type-check": "tsc --noEmit && echo 'Type checking examples/react-receiptline' && cd examples/react-receiptline && bun type-check"
|
|
43
45
|
},
|
|
44
46
|
"exports": {
|
|
45
47
|
".": {
|