@thermal-print/escpos 0.2.0 → 0.3.1-beta.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/dist/command-adapters/escbematech-adapter.d.ts +1 -1
- package/dist/command-adapters/escbematech-adapter.d.ts.map +1 -1
- package/dist/command-adapters/escbematech-adapter.js +3 -40
- package/dist/command-adapters/escpos-adapter.d.ts +1 -1
- package/dist/command-adapters/escpos-adapter.d.ts.map +1 -1
- package/dist/command-adapters/escpos-adapter.js +5 -42
- package/dist/command-adapters/index.d.ts +1 -1
- package/dist/command-adapters/index.d.ts.map +1 -1
- package/dist/command-adapters/index.js +2 -7
- package/dist/command-adapters/types.d.ts +2 -1
- package/dist/command-adapters/types.d.ts.map +1 -1
- package/dist/command-adapters/types.js +1 -2
- package/dist/commands/escbematech.js +217 -306
- package/dist/commands/escpos.d.ts +2 -1
- package/dist/commands/escpos.d.ts.map +1 -1
- package/dist/commands/escpos.js +195 -268
- package/dist/converter.js +10 -13
- package/dist/encodings/cp860.js +3 -8
- package/dist/generator.d.ts +11 -5
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js +50 -64
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -44
- package/dist/styles.d.ts +14 -19
- package/dist/styles.d.ts.map +1 -1
- package/dist/styles.js +32 -52
- package/dist/traverser.d.ts.map +1 -1
- package/dist/traverser.js +55 -32
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -2
- package/package.json +18 -9
- package/LICENSE +0 -21
package/dist/styles.js
CHANGED
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractTextStyle = extractTextStyle;
|
|
4
|
-
exports.extractViewStyle = extractViewStyle;
|
|
5
|
-
exports.isBold = isBold;
|
|
6
|
-
exports.mapFontSizeToESCPOS = mapFontSizeToESCPOS;
|
|
7
|
-
exports.mapTextAlign = mapTextAlign;
|
|
8
|
-
exports.calculateSpacing = calculateSpacing;
|
|
9
|
-
exports.isDashedBorder = isDashedBorder;
|
|
10
|
-
exports.generateDividerLine = generateDividerLine;
|
|
11
|
-
exports.mergeStyles = mergeStyles;
|
|
12
|
-
exports.parseWidth = parseWidth;
|
|
13
|
-
exports.alignTextInColumn = alignTextInColumn;
|
|
14
|
-
exports.wrapText = wrapText;
|
|
15
|
-
const cp860_1 = require("./encodings/cp860");
|
|
1
|
+
import { encodeCP860 } from "./encodings/cp860";
|
|
16
2
|
/**
|
|
17
3
|
* Extracts text style from a style object
|
|
18
4
|
*/
|
|
19
|
-
function extractTextStyle(style) {
|
|
5
|
+
export function extractTextStyle(style) {
|
|
20
6
|
return {
|
|
21
7
|
fontSize: style?.fontSize,
|
|
22
8
|
fontWeight: style?.fontWeight,
|
|
@@ -27,7 +13,7 @@ function extractTextStyle(style) {
|
|
|
27
13
|
/**
|
|
28
14
|
* Extracts view/layout style from a style object
|
|
29
15
|
*/
|
|
30
|
-
function extractViewStyle(style) {
|
|
16
|
+
export function extractViewStyle(style) {
|
|
31
17
|
return {
|
|
32
18
|
display: style?.display,
|
|
33
19
|
flexDirection: style?.flexDirection || "column",
|
|
@@ -51,49 +37,43 @@ function extractViewStyle(style) {
|
|
|
51
37
|
/**
|
|
52
38
|
* Determines if text should be bold
|
|
53
39
|
*/
|
|
54
|
-
function isBold(style) {
|
|
40
|
+
export function isBold(style) {
|
|
55
41
|
return (style.fontWeight === "bold" ||
|
|
56
42
|
style.fontWeight === 700 ||
|
|
57
43
|
style.fontWeight === "Helvetica-Bold" ||
|
|
58
44
|
style.fontFamily === "Helvetica-Bold");
|
|
59
45
|
}
|
|
60
46
|
/**
|
|
61
|
-
* Maps fontSize to ESC/POS
|
|
47
|
+
* Maps fontSize to ESC/POS font selection + character size multipliers
|
|
62
48
|
*
|
|
63
|
-
*
|
|
64
|
-
* -
|
|
65
|
-
* -
|
|
66
|
-
* -
|
|
67
|
-
* - 25+px → 2x2 (double width, double height)
|
|
49
|
+
* Three visual levels using standard ESC/POS fonts:
|
|
50
|
+
* - Condensada: Font B 1x1 (9x17, 64 cols) — fontSize <= 10
|
|
51
|
+
* - Normal: Font A 1x1 (12x24, 48 cols) — fontSize 11-19
|
|
52
|
+
* - Expandida: Font A 2x2 (12x24, 24 cols) — fontSize >= 20
|
|
68
53
|
*
|
|
69
54
|
* Note: ESC ! command only supports up to 2x2 character size.
|
|
70
|
-
* Larger sizes (3x, 4x, etc.) would require GS ! command which may not
|
|
71
|
-
* be supported on all thermal printers (e.g., Bematech MP-4200 TH).
|
|
72
|
-
*
|
|
73
|
-
* PDF uses zoom factor (default 0.46), so actual sizes are smaller:
|
|
74
|
-
* - 16 * 0.46 = 7.36 (normal text)
|
|
75
|
-
* - 18 * 0.46 = 8.28 (medium text)
|
|
76
|
-
* - 20 * 0.46 = 9.2 (title text)
|
|
77
|
-
*
|
|
78
|
-
* We use raw fontSize values (ignoring zoom) for better differentiation
|
|
79
55
|
*/
|
|
80
|
-
function mapFontSizeToESCPOS(fontSize) {
|
|
81
|
-
// Default
|
|
56
|
+
export function mapFontSizeToESCPOS(fontSize) {
|
|
57
|
+
// Default: Font A normal (48 cols)
|
|
82
58
|
if (!fontSize)
|
|
83
|
-
return { width: 1, height: 1 };
|
|
84
|
-
// Parse fontSize if it's a string
|
|
59
|
+
return { font: 0, width: 1, height: 1 };
|
|
60
|
+
// Parse fontSize if it's a string (e.g., "8.28px")
|
|
85
61
|
const size = typeof fontSize === "string" ? parseFloat(fontSize) : fontSize;
|
|
86
62
|
if (isNaN(size))
|
|
87
|
-
return { width: 1, height: 1 };
|
|
88
|
-
//
|
|
89
|
-
if (size
|
|
90
|
-
return { width:
|
|
91
|
-
|
|
63
|
+
return { font: 0, width: 1, height: 1 };
|
|
64
|
+
// Condensada: Font B (64 cols) — fontSize <= 10
|
|
65
|
+
if (size <= 10)
|
|
66
|
+
return { font: 1, width: 1, height: 1 };
|
|
67
|
+
// Normal: Font A (48 cols) — fontSize 11-19
|
|
68
|
+
if (size <= 19)
|
|
69
|
+
return { font: 0, width: 1, height: 1 };
|
|
70
|
+
// Expandida: Font A 2x2 (24 cols) — fontSize >= 20
|
|
71
|
+
return { font: 0, width: 2, height: 2 };
|
|
92
72
|
}
|
|
93
73
|
/**
|
|
94
74
|
* Maps textAlign to ESC/POS alignment
|
|
95
75
|
*/
|
|
96
|
-
function mapTextAlign(textAlign) {
|
|
76
|
+
export function mapTextAlign(textAlign) {
|
|
97
77
|
if (textAlign === "center")
|
|
98
78
|
return "center";
|
|
99
79
|
if (textAlign === "right")
|
|
@@ -104,7 +84,7 @@ function mapTextAlign(textAlign) {
|
|
|
104
84
|
* Calculates spacing (margin/padding) in lines
|
|
105
85
|
* Approximates pixels to line feeds
|
|
106
86
|
*/
|
|
107
|
-
function calculateSpacing(value) {
|
|
87
|
+
export function calculateSpacing(value) {
|
|
108
88
|
if (!value)
|
|
109
89
|
return 0;
|
|
110
90
|
// Rough approximation: ~20 pixels = 1 line feed
|
|
@@ -113,27 +93,27 @@ function calculateSpacing(value) {
|
|
|
113
93
|
/**
|
|
114
94
|
* Determines if a border is dashed
|
|
115
95
|
*/
|
|
116
|
-
function isDashedBorder(border) {
|
|
96
|
+
export function isDashedBorder(border) {
|
|
117
97
|
return border?.includes("dashed") ?? false;
|
|
118
98
|
}
|
|
119
99
|
/**
|
|
120
100
|
* Generates a divider line based on border style
|
|
121
101
|
*/
|
|
122
|
-
function generateDividerLine(width, dashed = false) {
|
|
102
|
+
export function generateDividerLine(width, dashed = false) {
|
|
123
103
|
const char = dashed ? "-" : "─";
|
|
124
104
|
return char.repeat(width);
|
|
125
105
|
}
|
|
126
106
|
/**
|
|
127
107
|
* Merges multiple style objects (handles spread syntax)
|
|
128
108
|
*/
|
|
129
|
-
function mergeStyles(...styles) {
|
|
109
|
+
export function mergeStyles(...styles) {
|
|
130
110
|
return Object.assign({}, ...styles.filter((s) => s));
|
|
131
111
|
}
|
|
132
112
|
/**
|
|
133
113
|
* Parses width percentage to column width in characters
|
|
134
114
|
* Uses Math.round() to minimize rounding errors
|
|
135
115
|
*/
|
|
136
|
-
function parseWidth(width, totalWidth) {
|
|
116
|
+
export function parseWidth(width, totalWidth) {
|
|
137
117
|
if (!width)
|
|
138
118
|
return totalWidth;
|
|
139
119
|
if (typeof width === "number")
|
|
@@ -149,14 +129,14 @@ function parseWidth(width, totalWidth) {
|
|
|
149
129
|
/**
|
|
150
130
|
* Aligns text within a column width (using CP860 byte length for accurate padding)
|
|
151
131
|
*/
|
|
152
|
-
function alignTextInColumn(text, width, align) {
|
|
132
|
+
export function alignTextInColumn(text, width, align) {
|
|
153
133
|
// Get actual byte length when encoded to CP860
|
|
154
|
-
let encodedLength =
|
|
134
|
+
let encodedLength = encodeCP860(text).length;
|
|
155
135
|
let truncatedText = text;
|
|
156
136
|
// Truncate if too long (character by character until it fits)
|
|
157
137
|
while (encodedLength > width && truncatedText.length > 0) {
|
|
158
138
|
truncatedText = truncatedText.substring(0, truncatedText.length - 1);
|
|
159
|
-
encodedLength =
|
|
139
|
+
encodedLength = encodeCP860(truncatedText).length;
|
|
160
140
|
}
|
|
161
141
|
// Calculate padding based on actual encoded byte length
|
|
162
142
|
const padding = width - encodedLength;
|
|
@@ -181,7 +161,7 @@ function alignTextInColumn(text, width, align) {
|
|
|
181
161
|
/**
|
|
182
162
|
* Splits text into multiple lines if it exceeds width
|
|
183
163
|
*/
|
|
184
|
-
function wrapText(text, width) {
|
|
164
|
+
export function wrapText(text, width) {
|
|
185
165
|
if (text.length <= width) {
|
|
186
166
|
return [text];
|
|
187
167
|
}
|
package/dist/traverser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverser.d.ts","sourceRoot":"","sources":["../src/traverser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C;;;GAGG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,SAAS,CAAkB;gBAEvB,SAAS,EAAE,eAAe;IAItC;;OAEG;IACG,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IA+BvD;;OAEG;YACW,cAAc;IAO5B;;OAEG;YACW,UAAU;IAIxB;;OAEG;YACW,UAAU;IAkBxB;;;OAGG;YACW,kBAAkB;IAchC;;OAEG;YACW,eAAe;
|
|
1
|
+
{"version":3,"file":"traverser.d.ts","sourceRoot":"","sources":["../src/traverser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C;;;GAGG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,SAAS,CAAkB;gBAEvB,SAAS,EAAE,eAAe;IAItC;;OAEG;IACG,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IA+BvD;;OAEG;YACW,cAAc;IAO5B;;OAEG;YACW,UAAU;IAIxB;;OAEG;YACW,UAAU;IAkBxB;;;OAGG;YACW,kBAAkB;IAchC;;OAEG;YACW,eAAe;IA0I7B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAczB;;OAEG;YACW,kBAAkB;IAmBhC;;OAEG;YACW,UAAU;IAiCxB;;OAEG;YACW,cAAc;IAM5B;;OAEG;YACW,WAAW;IA+BzB;;OAEG;YACW,gBAAgB;CAK/B"}
|
package/dist/traverser.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TreeTraverser = void 0;
|
|
4
|
-
const styles_1 = require("./styles");
|
|
1
|
+
import { alignTextInColumn, extractTextStyle, extractViewStyle, mapFontSizeToESCPOS, mapTextAlign, mergeStyles, parseWidth } from "./styles";
|
|
5
2
|
/**
|
|
6
3
|
* Tree Traverser
|
|
7
4
|
* Walks through the element tree and generates ESC/POS commands
|
|
8
5
|
*/
|
|
9
|
-
class TreeTraverser {
|
|
6
|
+
export class TreeTraverser {
|
|
10
7
|
constructor(generator) {
|
|
11
8
|
this.generator = generator;
|
|
12
9
|
}
|
|
@@ -61,7 +58,7 @@ class TreeTraverser {
|
|
|
61
58
|
* Handle View element (container with layout)
|
|
62
59
|
*/
|
|
63
60
|
async handleView(node) {
|
|
64
|
-
const viewStyle =
|
|
61
|
+
const viewStyle = extractViewStyle(node.style);
|
|
65
62
|
// Apply spacing before
|
|
66
63
|
this.generator.applyViewSpacing(node.style, "before");
|
|
67
64
|
// Handle different layout modes
|
|
@@ -103,8 +100,7 @@ class TreeTraverser {
|
|
|
103
100
|
await this.traverse(children[0]);
|
|
104
101
|
return;
|
|
105
102
|
}
|
|
106
|
-
const viewStyle =
|
|
107
|
-
const paperWidth = this.generator.getPaperWidth();
|
|
103
|
+
const viewStyle = extractViewStyle(node.style);
|
|
108
104
|
// Check layout justification mode
|
|
109
105
|
const isSpaceBetween = viewStyle.justifyContent === "space-between";
|
|
110
106
|
const isCentered = viewStyle.justifyContent === "center";
|
|
@@ -115,23 +111,42 @@ class TreeTraverser {
|
|
|
115
111
|
let rowTextStyle = null;
|
|
116
112
|
const firstTextNode = this.findFirstTextNode(children[0]);
|
|
117
113
|
if (firstTextNode && firstTextNode.style) {
|
|
118
|
-
rowTextStyle =
|
|
114
|
+
rowTextStyle = mergeStyles(firstTextNode.style);
|
|
119
115
|
}
|
|
116
|
+
// Calculate effective paper width based on the row's font/size
|
|
117
|
+
let paperWidth = this.generator.getPaperWidth();
|
|
118
|
+
if (rowTextStyle) {
|
|
119
|
+
const rowFontSize = mapFontSizeToESCPOS(rowTextStyle.fontSize);
|
|
120
|
+
if (rowFontSize.font === 1) {
|
|
121
|
+
paperWidth = 64; // Font B: 64 cols
|
|
122
|
+
}
|
|
123
|
+
else if (rowFontSize.width >= 2) {
|
|
124
|
+
paperWidth = Math.floor(this.generator.getPaperWidth() / 2); // Font A 2x: 24 cols
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
paperWidth = 48; // Font A normal: 48 cols
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// First pass: calculate explicit widths and track remaining space
|
|
131
|
+
let usedWidth = 0;
|
|
132
|
+
let columnsWithoutWidth = 0;
|
|
133
|
+
const childData = [];
|
|
120
134
|
for (const child of children) {
|
|
121
|
-
const childStyle =
|
|
122
|
-
const
|
|
123
|
-
|
|
135
|
+
const childStyle = extractViewStyle(child.style);
|
|
136
|
+
const hasWidth = childStyle.width !== undefined;
|
|
137
|
+
const explicitWidth = hasWidth ? parseWidth(childStyle.width, paperWidth) : 0;
|
|
138
|
+
if (hasWidth)
|
|
139
|
+
usedWidth += explicitWidth;
|
|
140
|
+
else
|
|
141
|
+
columnsWithoutWidth++;
|
|
124
142
|
const content = await this.collectTextContent(child);
|
|
125
|
-
// Determine alignment - check for Text node textAlign first
|
|
126
143
|
let align = "left";
|
|
127
|
-
// Look for Text element with textAlign
|
|
128
144
|
const textNode = this.findFirstTextNode(child);
|
|
129
145
|
if (textNode && textNode.style) {
|
|
130
|
-
const textStyle =
|
|
131
|
-
align =
|
|
146
|
+
const textStyle = extractTextStyle(textNode.style);
|
|
147
|
+
align = mapTextAlign(textStyle.textAlign);
|
|
132
148
|
}
|
|
133
149
|
else {
|
|
134
|
-
// Fall back to View alignment
|
|
135
150
|
if (childStyle.alignItems === "center" || childStyle.justifyContent === "center") {
|
|
136
151
|
align = "center";
|
|
137
152
|
}
|
|
@@ -139,18 +154,26 @@ class TreeTraverser {
|
|
|
139
154
|
align = "right";
|
|
140
155
|
}
|
|
141
156
|
}
|
|
142
|
-
|
|
157
|
+
childData.push({ childStyle, hasWidth, explicitWidth, content, align, node: child });
|
|
158
|
+
}
|
|
159
|
+
// Second pass: distribute remaining width to columns without explicit widths
|
|
160
|
+
const remainingWidth = Math.max(0, paperWidth - usedWidth);
|
|
161
|
+
const autoWidth = columnsWithoutWidth > 0 ? Math.floor(remainingWidth / columnsWithoutWidth) : paperWidth;
|
|
162
|
+
for (const data of childData) {
|
|
163
|
+
const width = data.hasWidth ? data.explicitWidth : autoWidth;
|
|
164
|
+
columns.push({ node: data.node, width, content: data.content, align: data.align });
|
|
143
165
|
}
|
|
144
166
|
// Build row text
|
|
145
167
|
let rowText = "";
|
|
146
168
|
// Check if columns have explicit widths (table layout) or should use space-between
|
|
147
169
|
const hasExplicitWidths = columns.some((col) => {
|
|
148
|
-
const childStyle =
|
|
170
|
+
const childStyle = extractViewStyle(col.node.style);
|
|
149
171
|
return childStyle.width !== undefined;
|
|
150
172
|
});
|
|
151
|
-
if (
|
|
152
|
-
//
|
|
153
|
-
//
|
|
173
|
+
if (columns.length === 2 && !hasExplicitWidths) {
|
|
174
|
+
// 2-column layout without explicit widths: treat as space-between
|
|
175
|
+
// This covers both explicit space-between and flexGrow patterns
|
|
176
|
+
// (common receipt pattern: label on left, value on right)
|
|
154
177
|
const usedSpace = columns[0].content.length + columns[1].content.length;
|
|
155
178
|
const gap = Math.max(1, paperWidth - usedSpace);
|
|
156
179
|
rowText = columns[0].content + " ".repeat(gap) + columns[1].content;
|
|
@@ -176,7 +199,7 @@ class TreeTraverser {
|
|
|
176
199
|
// Normal column layout OR space-between with explicit widths (use column padding)
|
|
177
200
|
for (let i = 0; i < columns.length; i++) {
|
|
178
201
|
const col = columns[i];
|
|
179
|
-
const cellText =
|
|
202
|
+
const cellText = alignTextInColumn(col.content, col.width, col.align);
|
|
180
203
|
rowText += cellText;
|
|
181
204
|
}
|
|
182
205
|
}
|
|
@@ -229,7 +252,7 @@ class TreeTraverser {
|
|
|
229
252
|
*/
|
|
230
253
|
async handleText(node) {
|
|
231
254
|
// Merge styles from parent if needed
|
|
232
|
-
const style =
|
|
255
|
+
const style = mergeStyles(node.style);
|
|
233
256
|
// Apply text styling (sets alignment, bold, size)
|
|
234
257
|
this.generator.applyTextStyle(style);
|
|
235
258
|
// Get text content
|
|
@@ -246,10 +269,11 @@ class TreeTraverser {
|
|
|
246
269
|
}
|
|
247
270
|
// Traverse children (nested Text elements)
|
|
248
271
|
await this.traverseChildren(node);
|
|
249
|
-
//
|
|
250
|
-
|
|
251
|
-
// Add newline after text element
|
|
272
|
+
// Add newline BEFORE resetting formatting so alignment takes effect at LF
|
|
273
|
+
// (ESC/POS applies alignment at print time, i.e. when LF is sent)
|
|
252
274
|
this.generator.addNewline();
|
|
275
|
+
// Reset formatting after the line is printed
|
|
276
|
+
this.generator.resetFormatting();
|
|
253
277
|
}
|
|
254
278
|
/**
|
|
255
279
|
* Handle TextNode (raw text)
|
|
@@ -266,13 +290,13 @@ class TreeTraverser {
|
|
|
266
290
|
const source = node.props.source || node.props.src;
|
|
267
291
|
if (source) {
|
|
268
292
|
// Apply alignment from style (check both node style and parent style)
|
|
269
|
-
const style =
|
|
270
|
-
const viewStyle =
|
|
271
|
-
const textStyle =
|
|
293
|
+
const style = mergeStyles(node.style);
|
|
294
|
+
const viewStyle = extractViewStyle(style);
|
|
295
|
+
const textStyle = extractTextStyle(style);
|
|
272
296
|
// Determine alignment from textAlign or justifyContent
|
|
273
297
|
let align = "left";
|
|
274
298
|
if (textStyle.textAlign) {
|
|
275
|
-
align =
|
|
299
|
+
align = mapTextAlign(textStyle.textAlign);
|
|
276
300
|
}
|
|
277
301
|
else if (viewStyle.justifyContent === "center" || viewStyle.alignItems === "center") {
|
|
278
302
|
align = "center";
|
|
@@ -297,4 +321,3 @@ class TreeTraverser {
|
|
|
297
321
|
}
|
|
298
322
|
}
|
|
299
323
|
}
|
|
300
|
-
exports.TreeTraverser = TreeTraverser;
|
package/dist/types.d.ts
CHANGED
|
@@ -8,11 +8,13 @@ export interface ESCPOSCommand {
|
|
|
8
8
|
}
|
|
9
9
|
export interface ConversionContext {
|
|
10
10
|
paperWidth: number;
|
|
11
|
+
basePaperWidth: number;
|
|
11
12
|
currentAlign: 'left' | 'center' | 'right';
|
|
12
13
|
currentSize: {
|
|
13
14
|
width: number;
|
|
14
15
|
height: number;
|
|
15
16
|
};
|
|
17
|
+
currentFont: 0 | 1;
|
|
16
18
|
currentBold: boolean;
|
|
17
19
|
encoding: string;
|
|
18
20
|
debug: boolean;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,IAAI,CAAC;IACvD,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC1C,WAAW,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,IAAI,CAAC;IACvD,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC1C,WAAW,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB"}
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thermal-print/escpos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1-beta.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "ESC/POS command generation and thermal printer control",
|
|
5
6
|
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
6
8
|
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc --build",
|
|
18
|
+
"build:watch": "tsc --build --watch"
|
|
19
|
+
},
|
|
7
20
|
"keywords": [
|
|
8
21
|
"thermal-printer",
|
|
9
22
|
"escpos",
|
|
@@ -13,8 +26,8 @@
|
|
|
13
26
|
"author": "",
|
|
14
27
|
"license": "MIT",
|
|
15
28
|
"dependencies": {
|
|
16
|
-
"
|
|
17
|
-
"
|
|
29
|
+
"@thermal-print/core": "0.3.1-beta.0",
|
|
30
|
+
"jimp": "^1.6.0"
|
|
18
31
|
},
|
|
19
32
|
"devDependencies": {
|
|
20
33
|
"typescript": "^5.0.0"
|
|
@@ -24,9 +37,5 @@
|
|
|
24
37
|
},
|
|
25
38
|
"files": [
|
|
26
39
|
"dist"
|
|
27
|
-
]
|
|
28
|
-
|
|
29
|
-
"build": "tsc --build",
|
|
30
|
-
"build:watch": "tsc --build --watch"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
40
|
+
]
|
|
41
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 NUVEL
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|