@thermal-print/escpos 0.3.1-beta.7 → 0.4.0-beta.1
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/LICENSE +21 -0
- package/dist/converter.d.ts +2 -2
- package/dist/converter.d.ts.map +1 -1
- package/dist/converter.js +1 -1
- package/dist/generator.d.ts +3 -3
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js +32 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/styles.d.ts +12 -0
- package/dist/styles.d.ts.map +1 -1
- package/dist/styles.js +77 -1
- package/dist/traverser.d.ts.map +1 -1
- package/dist/traverser.js +7 -8
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +12 -12
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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.
|
package/dist/converter.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export interface PrintNodeToESCPOSOptions {
|
|
|
46
46
|
*
|
|
47
47
|
* @param printNode - Root PrintNode of the tree to convert
|
|
48
48
|
* @param options - Conversion options
|
|
49
|
-
* @returns
|
|
49
|
+
* @returns Uint8Array containing ESC/POS commands ready to be sent to printer
|
|
50
50
|
*
|
|
51
51
|
* @example
|
|
52
52
|
* ```typescript
|
|
@@ -70,5 +70,5 @@ export interface PrintNodeToESCPOSOptions {
|
|
|
70
70
|
* });
|
|
71
71
|
* ```
|
|
72
72
|
*/
|
|
73
|
-
export declare function printNodesToESCPOS(printNode: PrintNode, options?: PrintNodeToESCPOSOptions): Promise<
|
|
73
|
+
export declare function printNodesToESCPOS(printNode: PrintNode, options?: PrintNodeToESCPOSOptions): Promise<Uint8Array>;
|
|
74
74
|
//# sourceMappingURL=converter.d.ts.map
|
package/dist/converter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.d.ts","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD,OAAO,EAAE,cAAc,EAAmD,MAAM,oBAAoB,CAAC;AAErG;;GAEG;AACH;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE1C;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE1C,MAAM,WAAW,wBAAwB;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EA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;;;;;;;;GA+BG;AACH,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,SAAS,EACpB,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,UAAU,CAAC,CA8DrB"}
|
package/dist/converter.js
CHANGED
|
@@ -31,7 +31,7 @@ function createCommandAdapter(config) {
|
|
|
31
31
|
*
|
|
32
32
|
* @param printNode - Root PrintNode of the tree to convert
|
|
33
33
|
* @param options - Conversion options
|
|
34
|
-
* @returns
|
|
34
|
+
* @returns Uint8Array containing ESC/POS commands ready to be sent to printer
|
|
35
35
|
*
|
|
36
36
|
* @example
|
|
37
37
|
* ```typescript
|
package/dist/generator.d.ts
CHANGED
|
@@ -194,13 +194,13 @@ export declare class ESCPOSGenerator {
|
|
|
194
194
|
cutPartialWithFeed(lines?: number): void;
|
|
195
195
|
/**
|
|
196
196
|
* Add raw ESC/POS command
|
|
197
|
-
* @param data - Raw
|
|
197
|
+
* @param data - Raw bytes to send to printer
|
|
198
198
|
*/
|
|
199
|
-
addRawCommand(data:
|
|
199
|
+
addRawCommand(data: Uint8Array): void;
|
|
200
200
|
/**
|
|
201
201
|
* Get the final buffer
|
|
202
202
|
*/
|
|
203
|
-
getBuffer():
|
|
203
|
+
getBuffer(): Uint8Array;
|
|
204
204
|
/**
|
|
205
205
|
* Get paper width
|
|
206
206
|
*/
|
package/dist/generator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AACA,OAAO,EAQL,SAAS,EAOV,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAwB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AACA,OAAO,EAQL,SAAS,EAOV,MAAM,UAA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,CAAA;KAAE,GACxE,IAAI;IAqBP;;;OAGG;IACH,gBAAgB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS;IAkBtE,sDAAsD;IACtD,YAAY,IAAI,SAAS;IAIzB,gEAAgE;IAChE,gBAAgB,IAAI,SAAS;IAI7B,gFAAgF;IAChF,eAAe,IAAI,OAAO;IAI1B;;OAEG;IACH,gBAAgB,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI;IAuB5D;;OAEG;IACH,OAAO,IAAI,IAAI;IAKf;;OAEG;IACH,UAAU,IAAI,IAAI;IAKlB;;;OAGG;IACH,eAAe,CAAC,KAAK,SAAI,GAAG,IAAI;IAMhC;;;OAGG;IACH,kBAAkB,CAAC,KAAK,SAAI,GAAG,IAAI;IAMnC;;;OAGG;IACH,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAIrC;;OAEG;IACH,SAAS,IAAI,UAAU;IAevB;;OAEG;IACH,aAAa,IAAI,MAAM;CAGxB"}
|
package/dist/generator.js
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import { encodeText } from "./commands/escpos";
|
|
2
2
|
import { baseFontLevel, calculateSpacing, columnsForLevel, extractTextStyle, extractViewStyle, FONT_LEVEL_COLUMN_UNITS, FONT_LEVEL_SIZES, generateDividerLine, isBold, isDashedBorder, mapTextAlign, resolveFontLevel, wrapText, } from "./styles";
|
|
3
3
|
import { ESCPOSCommandAdapter } from "./command-adapters";
|
|
4
|
+
/**
|
|
5
|
+
* Decodes base64 without Buffer, so the generator also runs in the browser.
|
|
6
|
+
* `atob` is a global in browsers and in Node >= 16.
|
|
7
|
+
*/
|
|
8
|
+
function base64ToBytes(base64) {
|
|
9
|
+
const decode = globalThis.atob;
|
|
10
|
+
if (typeof decode !== "function") {
|
|
11
|
+
throw new Error("base64 decoding requires a global atob() (browser, or Node >= 16)");
|
|
12
|
+
}
|
|
13
|
+
const binary = decode(base64);
|
|
14
|
+
const bytes = new Uint8Array(binary.length);
|
|
15
|
+
for (let i = 0; i < binary.length; i++) {
|
|
16
|
+
bytes[i] = binary.charCodeAt(i);
|
|
17
|
+
}
|
|
18
|
+
return bytes;
|
|
19
|
+
}
|
|
4
20
|
/**
|
|
5
21
|
* Simple buffer implementation for accumulating ESC/POS commands
|
|
6
22
|
*/
|
|
@@ -21,10 +37,15 @@ class ESCPOSBuffer {
|
|
|
21
37
|
this.buffer.push(...bytes);
|
|
22
38
|
}
|
|
23
39
|
/**
|
|
24
|
-
* Get the
|
|
40
|
+
* Get the accumulated bytes.
|
|
41
|
+
*
|
|
42
|
+
* Uint8Array, not Buffer: the generator runs in the browser too (the pdv-web
|
|
43
|
+
* inside the Android WebView), where `Buffer` does not exist. A Node Buffer
|
|
44
|
+
* IS a Uint8Array, so consumers that already fed the result to a serial port
|
|
45
|
+
* or an IPC channel keep working.
|
|
25
46
|
*/
|
|
26
|
-
|
|
27
|
-
return
|
|
47
|
+
toUint8Array() {
|
|
48
|
+
return Uint8Array.from(this.buffer);
|
|
28
49
|
}
|
|
29
50
|
/**
|
|
30
51
|
* Get buffer size
|
|
@@ -366,10 +387,12 @@ export class ESCPOSGenerator {
|
|
|
366
387
|
base64Data = base64Match[1];
|
|
367
388
|
}
|
|
368
389
|
}
|
|
369
|
-
// Convert base64 to
|
|
370
|
-
const
|
|
371
|
-
// Load image with Jimp (v1.x API)
|
|
372
|
-
|
|
390
|
+
// Convert base64 to bytes (isomorphic: no Buffer)
|
|
391
|
+
const imageBytes = base64ToBytes(base64Data);
|
|
392
|
+
// Load image with Jimp (v1.x API). Jimp.read accepts an ArrayBuffer, and
|
|
393
|
+
// `imageBytes` owns its buffer exactly, so handing over `.buffer` is a
|
|
394
|
+
// zero-copy pass of the same bytes.
|
|
395
|
+
const image = await Jimp.read(imageBytes.buffer);
|
|
373
396
|
// Get paper width in pixels (assuming 8 dots per mm for 80mm thermal printer)
|
|
374
397
|
// Standard 80mm paper = ~576 pixels at 8 dots/mm (72 dpi)
|
|
375
398
|
// We'll use 384 pixels as max width (48 chars * 8 pixels per char)
|
|
@@ -533,7 +556,7 @@ export class ESCPOSGenerator {
|
|
|
533
556
|
}
|
|
534
557
|
/**
|
|
535
558
|
* Add raw ESC/POS command
|
|
536
|
-
* @param data - Raw
|
|
559
|
+
* @param data - Raw bytes to send to printer
|
|
537
560
|
*/
|
|
538
561
|
addRawCommand(data) {
|
|
539
562
|
this.buffer.pushArray(Array.from(data));
|
|
@@ -542,7 +565,7 @@ export class ESCPOSGenerator {
|
|
|
542
565
|
* Get the final buffer
|
|
543
566
|
*/
|
|
544
567
|
getBuffer() {
|
|
545
|
-
const buffer = this.buffer.
|
|
568
|
+
const buffer = this.buffer.toUint8Array();
|
|
546
569
|
// Defensive: drop leading line feeds so a receipt could never start with
|
|
547
570
|
// blank paper. The buffer opens with the adapter's init command, so in
|
|
548
571
|
// practice nothing is ever stripped here — in particular a marginTop on the
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* ESC/POS command generation and thermal printer control
|
|
5
5
|
*
|
|
6
|
-
* Main API: printNodesToESCPOS(printNode, options) ->
|
|
6
|
+
* Main API: printNodesToESCPOS(printNode, options) -> Uint8Array
|
|
7
7
|
*/
|
|
8
8
|
export { printNodesToESCPOS } from './converter';
|
|
9
9
|
export type { PrintNodeToESCPOSOptions, FontMode, StyleMode } from './converter';
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* ESC/POS command generation and thermal printer control
|
|
5
5
|
*
|
|
6
|
-
* Main API: printNodesToESCPOS(printNode, options) ->
|
|
6
|
+
* Main API: printNodesToESCPOS(printNode, options) -> Uint8Array
|
|
7
7
|
*/
|
|
8
8
|
// Main conversion function
|
|
9
9
|
export { printNodesToESCPOS } from './converter';
|
package/dist/styles.d.ts
CHANGED
|
@@ -126,6 +126,18 @@ export declare function distributeGaps(contentWidth: number, totalWidth: number,
|
|
|
126
126
|
* Aligns text within a column width (using CP860 byte length for accurate padding)
|
|
127
127
|
*/
|
|
128
128
|
export declare function alignTextInColumn(text: string, width: number, align: "left" | "center" | "right"): string;
|
|
129
|
+
/**
|
|
130
|
+
* Lays out one line of a space-between row as the printed lines.
|
|
131
|
+
*
|
|
132
|
+
* A row that fits is spread across the paper as always. A row that does not
|
|
133
|
+
* fit used to go out longer than the paper, and the printer wrapped it
|
|
134
|
+
* wherever column `totalWidth` fell — splitting "R$ 4,50" into "R$ 4" and
|
|
135
|
+
* ",50". Now the last cell (the amount) stays whole and right-aligned, and the
|
|
136
|
+
* cells before it wrap by word in the width the amount leaves free, the amount
|
|
137
|
+
* sharing the last line of that label. When even that is impossible, the label
|
|
138
|
+
* takes its own line(s) and the amount goes right-aligned on the next one.
|
|
139
|
+
*/
|
|
140
|
+
export declare function layoutSpaceBetweenLine(parts: string[], totalWidth: number): string[];
|
|
129
141
|
/**
|
|
130
142
|
* Splits text into multiple lines if it exceeds width
|
|
131
143
|
*/
|
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,CAqBtD;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAOhD;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,E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B,MAAM,EAAE,CAgCV;AAcD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAYnG;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;AAgCD;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAuCpF;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAqC9D"}
|
package/dist/styles.js
CHANGED
|
@@ -294,6 +294,82 @@ export function alignTextInColumn(text, width, align) {
|
|
|
294
294
|
return truncatedText + " ".repeat(padding);
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
|
+
/** Tokens that belong to the amount after them: "R$ 4,50", "+ 2", "- R$ 1,00". */
|
|
298
|
+
const AMOUNT_PREFIXES = new Set(["R$", "+", "-"]);
|
|
299
|
+
const AMOUNT_START = /^(?:[-+]?\d|R\$)/;
|
|
300
|
+
/**
|
|
301
|
+
* The words wrapText breaks on. A currency sign or a sign glued to the amount
|
|
302
|
+
* after it by a space is one token, so a wrap never leaves "R$" at the end of
|
|
303
|
+
* one line and "4,50" at the start of the next. A group wider than the column
|
|
304
|
+
* stays apart: breaking it at its space beats slicing the number.
|
|
305
|
+
*/
|
|
306
|
+
function wrapTokens(text, width) {
|
|
307
|
+
const words = text.split(" ");
|
|
308
|
+
const tokens = [];
|
|
309
|
+
for (let i = words.length - 1; i >= 0; i--) {
|
|
310
|
+
const word = words[i];
|
|
311
|
+
const next = tokens[0];
|
|
312
|
+
if (AMOUNT_PREFIXES.has(word) &&
|
|
313
|
+
next !== undefined &&
|
|
314
|
+
AMOUNT_START.test(next) &&
|
|
315
|
+
word.length + 1 + next.length <= width) {
|
|
316
|
+
tokens[0] = word + " " + next;
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
tokens.unshift(word);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return tokens;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Lays out one line of a space-between row as the printed lines.
|
|
326
|
+
*
|
|
327
|
+
* A row that fits is spread across the paper as always. A row that does not
|
|
328
|
+
* fit used to go out longer than the paper, and the printer wrapped it
|
|
329
|
+
* wherever column `totalWidth` fell — splitting "R$ 4,50" into "R$ 4" and
|
|
330
|
+
* ",50". Now the last cell (the amount) stays whole and right-aligned, and the
|
|
331
|
+
* cells before it wrap by word in the width the amount leaves free, the amount
|
|
332
|
+
* sharing the last line of that label. When even that is impossible, the label
|
|
333
|
+
* takes its own line(s) and the amount goes right-aligned on the next one.
|
|
334
|
+
*/
|
|
335
|
+
export function layoutSpaceBetweenLine(parts, totalWidth) {
|
|
336
|
+
const used = parts.reduce((sum, part) => sum + part.length, 0);
|
|
337
|
+
const gapCount = parts.length - 1;
|
|
338
|
+
if (gapCount <= 0 || used + gapCount <= totalWidth) {
|
|
339
|
+
const gaps = distributeGaps(used, totalWidth, gapCount);
|
|
340
|
+
let rowText = parts[0] ?? "";
|
|
341
|
+
for (let i = 1; i < parts.length; i++) {
|
|
342
|
+
rowText += " ".repeat(gaps[i - 1]) + parts[i];
|
|
343
|
+
}
|
|
344
|
+
return [rowText];
|
|
345
|
+
}
|
|
346
|
+
const value = parts[parts.length - 1];
|
|
347
|
+
const label = parts
|
|
348
|
+
.slice(0, -1)
|
|
349
|
+
.filter((part) => part.length > 0)
|
|
350
|
+
.join(" ");
|
|
351
|
+
if (value.length === 0)
|
|
352
|
+
return wrapText(label, totalWidth);
|
|
353
|
+
const labelAlone = label.length === 0 ? [] : wrapText(label, totalWidth);
|
|
354
|
+
// An amount wider than the paper cannot stay whole; wrap it here instead of
|
|
355
|
+
// letting the printer cut it at an arbitrary column.
|
|
356
|
+
if (value.length > totalWidth) {
|
|
357
|
+
const valueLines = wrapText(value, totalWidth);
|
|
358
|
+
return [...labelAlone, ...valueLines.map((line) => " ".repeat(totalWidth - line.length) + line)];
|
|
359
|
+
}
|
|
360
|
+
const rightAligned = " ".repeat(totalWidth - value.length) + value;
|
|
361
|
+
if (label.length === 0)
|
|
362
|
+
return [rightAligned];
|
|
363
|
+
const labelWidth = totalWidth - value.length - 1;
|
|
364
|
+
// Breaking a word of the label in the middle is worse than giving the amount
|
|
365
|
+
// a line of its own.
|
|
366
|
+
const fitsBeside = labelWidth > 0 && wrapTokens(label, labelWidth).every((word) => word.length <= labelWidth);
|
|
367
|
+
if (!fitsBeside)
|
|
368
|
+
return [...labelAlone, rightAligned];
|
|
369
|
+
const labelLines = wrapText(label, labelWidth);
|
|
370
|
+
const last = labelLines.pop() ?? "";
|
|
371
|
+
return [...labelLines, last + " ".repeat(totalWidth - last.length - value.length) + value];
|
|
372
|
+
}
|
|
297
373
|
/**
|
|
298
374
|
* Splits text into multiple lines if it exceeds width
|
|
299
375
|
*/
|
|
@@ -311,7 +387,7 @@ export function wrapText(text, width) {
|
|
|
311
387
|
currentLine = "";
|
|
312
388
|
}
|
|
313
389
|
};
|
|
314
|
-
for (const word of text
|
|
390
|
+
for (const word of wrapTokens(text, width)) {
|
|
315
391
|
if ((currentLine + " " + word).trim().length <= width) {
|
|
316
392
|
currentLine = (currentLine + " " + word).trim();
|
|
317
393
|
continue;
|
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;AA6B9C;;;GAGG;AACH,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CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { alignTextInColumn, calculateHorizontalSpacing, distributeColumnWidths,
|
|
1
|
+
import { alignTextInColumn, calculateHorizontalSpacing, distributeColumnWidths, extractTextStyle, extractViewStyle, FONT_LEVEL_COLUMN_UNITS, isBold, layoutSpaceBetweenLine, mapTextAlign, mergeStyles, parsePercentageWidth, parseSize, wrapText, } from "./styles";
|
|
2
2
|
/**
|
|
3
3
|
* Tree Traverser
|
|
4
4
|
* Walks through the element tree and generates ESC/POS commands
|
|
@@ -223,13 +223,12 @@ export class TreeTraverser {
|
|
|
223
223
|
}
|
|
224
224
|
else if (isSpaceBetween) {
|
|
225
225
|
const parts = columnLines.map((lines) => lines[lineIdx] || "");
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
this.generator.addTextLine(rowText);
|
|
226
|
+
const rowLines = layoutSpaceBetweenLine(parts, paperWidth);
|
|
227
|
+
rowLines.forEach((rowText, i) => {
|
|
228
|
+
if (i > 0)
|
|
229
|
+
this.generator.addNewline();
|
|
230
|
+
this.generator.addTextLine(rowText);
|
|
231
|
+
});
|
|
233
232
|
}
|
|
234
233
|
else {
|
|
235
234
|
const parts = columnLines.map((lines) => lines[lineIdx] || "");
|
package/dist/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
export interface ESCPOSCommand {
|
|
5
5
|
type: 'raw' | 'text' | 'feed' | 'cut' | 'image' | 'qr';
|
|
6
6
|
data?: any;
|
|
7
|
-
buffer?:
|
|
7
|
+
buffer?: Uint8Array;
|
|
8
8
|
}
|
|
9
9
|
export interface ConversionContext {
|
|
10
10
|
/** Characters that fit on a line at the CURRENT font level, minus horizontal padding. */
|
|
@@ -21,6 +21,6 @@ export interface ConversionContext {
|
|
|
21
21
|
currentBold: boolean;
|
|
22
22
|
encoding: string;
|
|
23
23
|
debug: boolean;
|
|
24
|
-
buffer:
|
|
24
|
+
buffer: Uint8Array[];
|
|
25
25
|
}
|
|
26
26
|
//# sourceMappingURL=types.d.ts.map
|
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,
|
|
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,UAAU,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,yFAAyF;IACzF,UAAU,EAAE,MAAM,CAAC;IACnB,wFAAwF;IACxF,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,0DAA0D;IAC1D,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,UAAU,EAAE,CAAC;CACtB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thermal-print/escpos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "ESC/POS command generation and thermal printer control",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -13,12 +13,6 @@
|
|
|
13
13
|
"require": "./dist/index.js"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"build": "tsc --build",
|
|
18
|
-
"build:watch": "tsc --build --watch",
|
|
19
|
-
"test": "tsx --test test/*.test.ts",
|
|
20
|
-
"typecheck": "tsc -p tsconfig.test.json"
|
|
21
|
-
},
|
|
22
16
|
"keywords": [
|
|
23
17
|
"thermal-printer",
|
|
24
18
|
"escpos",
|
|
@@ -28,16 +22,22 @@
|
|
|
28
22
|
"author": "",
|
|
29
23
|
"license": "MIT",
|
|
30
24
|
"dependencies": {
|
|
31
|
-
"
|
|
32
|
-
"
|
|
25
|
+
"jimp": "1.6.0",
|
|
26
|
+
"@thermal-print/core": "0.3.1-beta.7"
|
|
33
27
|
},
|
|
34
28
|
"devDependencies": {
|
|
35
|
-
"typescript": "5.
|
|
29
|
+
"typescript": "5.9.3"
|
|
36
30
|
},
|
|
37
31
|
"publishConfig": {
|
|
38
32
|
"access": "public"
|
|
39
33
|
},
|
|
40
34
|
"files": [
|
|
41
35
|
"dist"
|
|
42
|
-
]
|
|
43
|
-
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsc --build",
|
|
39
|
+
"build:watch": "tsc --build --watch",
|
|
40
|
+
"test": "tsx --test test/*.test.ts",
|
|
41
|
+
"typecheck": "tsc -p tsconfig.test.json"
|
|
42
|
+
}
|
|
43
|
+
}
|