@thermal-print/escpos 0.1.0 → 0.2.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/styles.d.ts.map +1 -1
- package/dist/styles.js +2 -6
- package/dist/traverser.d.ts.map +1 -1
- package/dist/traverser.js +15 -0
- package/package.json +3 -2
package/dist/styles.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,SAAS,CAOtD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,SAAS,CAoBtD;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAOhD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,SAAS,CAOtD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,SAAS,CAoBtD;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAOhD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAYA;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAI5E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAIvD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,UAAQ,GAAG,MAAM,CAGzE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,CAEjD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EAClC,UAAU,EAAE,MAAM,GACjB,MAAM,CAaR;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GACjC,MAAM,CA8BR;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAyB9D"}
|
package/dist/styles.js
CHANGED
|
@@ -81,17 +81,13 @@ function mapFontSizeToESCPOS(fontSize) {
|
|
|
81
81
|
// Default to 1x1 (normal size)
|
|
82
82
|
if (!fontSize)
|
|
83
83
|
return { width: 1, height: 1 };
|
|
84
|
-
// Parse fontSize if it's a string
|
|
84
|
+
// Parse fontSize if it's a string (e.g., "8.28px")
|
|
85
85
|
const size = typeof fontSize === "string" ? parseFloat(fontSize) : fontSize;
|
|
86
86
|
if (isNaN(size))
|
|
87
87
|
return { width: 1, height: 1 };
|
|
88
88
|
// Map font size to character multipliers (max 2x2 for ESC ! compatibility)
|
|
89
|
-
if (size >=
|
|
89
|
+
if (size >= 20)
|
|
90
90
|
return { width: 2, height: 2 }; // 25+px → 2x2 (maximum)
|
|
91
|
-
if (size >= 19)
|
|
92
|
-
return { width: 2, height: 1 }; // 19-24px → 2x1
|
|
93
|
-
if (size >= 13)
|
|
94
|
-
return { width: 1, height: 2 }; // 13-18px → 1x2
|
|
95
91
|
return { width: 1, height: 1 }; // 8-12px → 1x1 (normal)
|
|
96
92
|
}
|
|
97
93
|
/**
|
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;IAiH7B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAczB;;OAEG;YACW,kBAAkB;IAmBhC;;OAEG;YACW,UAAU;IAgCxB;;OAEG;YACW,cAAc;IAM5B;;OAEG;YACW,WAAW;IA+BzB;;OAEG;YACW,gBAAgB;CAK/B"}
|
package/dist/traverser.js
CHANGED
|
@@ -110,6 +110,13 @@ class TreeTraverser {
|
|
|
110
110
|
const isCentered = viewStyle.justifyContent === "center";
|
|
111
111
|
// Calculate column widths
|
|
112
112
|
const columns = [];
|
|
113
|
+
// Extract text style from the first Text node for the entire row
|
|
114
|
+
// This preserves formatting like bold, fontSize across all columns
|
|
115
|
+
let rowTextStyle = null;
|
|
116
|
+
const firstTextNode = this.findFirstTextNode(children[0]);
|
|
117
|
+
if (firstTextNode && firstTextNode.style) {
|
|
118
|
+
rowTextStyle = (0, styles_1.mergeStyles)(firstTextNode.style);
|
|
119
|
+
}
|
|
113
120
|
for (const child of children) {
|
|
114
121
|
const childStyle = (0, styles_1.extractViewStyle)(child.style);
|
|
115
122
|
const width = (0, styles_1.parseWidth)(childStyle.width, paperWidth);
|
|
@@ -173,8 +180,16 @@ class TreeTraverser {
|
|
|
173
180
|
rowText += cellText;
|
|
174
181
|
}
|
|
175
182
|
}
|
|
183
|
+
// Apply text style (bold, fontSize) before adding the row text
|
|
184
|
+
if (rowTextStyle) {
|
|
185
|
+
this.generator.applyTextStyle(rowTextStyle);
|
|
186
|
+
}
|
|
176
187
|
this.generator.addText(rowText);
|
|
177
188
|
this.generator.addNewline();
|
|
189
|
+
// Reset formatting after the row
|
|
190
|
+
if (rowTextStyle) {
|
|
191
|
+
this.generator.resetFormatting();
|
|
192
|
+
}
|
|
178
193
|
}
|
|
179
194
|
/**
|
|
180
195
|
* Find the first Text node in a tree
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thermal-print/escpos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "ESC/POS command generation and thermal printer control",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"author": "",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"
|
|
16
|
+
"jimp": "^1.6.0",
|
|
17
|
+
"@thermal-print/core": "0.2.0"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {
|
|
19
20
|
"typescript": "^5.0.0"
|