windsor-bot 0.2.13 → 0.2.14
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/bot.js +2 -1
- package/dist/printing/escp.js +2 -16
- package/package.json +1 -1
package/dist/bot.js
CHANGED
|
@@ -471,6 +471,7 @@ export function createWindsorBot() {
|
|
|
471
471
|
}
|
|
472
472
|
const job = {
|
|
473
473
|
lines: [textWithLinkLabels],
|
|
474
|
+
fontSize: 'double',
|
|
474
475
|
urls,
|
|
475
476
|
};
|
|
476
477
|
if (config.header)
|
|
@@ -616,7 +617,7 @@ export function createWindsorBot() {
|
|
|
616
617
|
await replySafe(message, '⁉️ This message is too long to print.');
|
|
617
618
|
return;
|
|
618
619
|
}
|
|
619
|
-
const job = { lines: [text], urls };
|
|
620
|
+
const job = { lines: [text], fontSize: 'double', urls };
|
|
620
621
|
if (config.header)
|
|
621
622
|
job.header = config.header;
|
|
622
623
|
if (config.footer)
|
package/dist/printing/escp.js
CHANGED
|
@@ -24,23 +24,12 @@ function wrapText(text, width) {
|
|
|
24
24
|
lines.push(current);
|
|
25
25
|
return lines.length > 0 ? lines : [''];
|
|
26
26
|
}
|
|
27
|
-
function chooseFontForLines(totalLines) {
|
|
28
|
-
if (totalLines <= 8) {
|
|
29
|
-
return { fontSize: 'tall', cols: COLS_NORMAL };
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
return { fontSize: 'normal', cols: COLS_NORMAL };
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function countLayoutLines(lines) {
|
|
36
|
-
return lines.length <= 2 ? 2 : lines.length;
|
|
37
|
-
}
|
|
38
27
|
export async function buildEscpBuffer(job) {
|
|
39
28
|
const conn = new InMemory();
|
|
40
29
|
const printer = await Printer.CONNECT('TM-T20', conn);
|
|
41
30
|
// Reset state that may persist between direct USB/serial jobs.
|
|
42
31
|
await conn.write(Buffer.from(PRINTER_INIT, 'ascii'));
|
|
43
|
-
const
|
|
32
|
+
const fontSize = job.fontSize ?? 'normal';
|
|
44
33
|
// Header
|
|
45
34
|
if (job.header) {
|
|
46
35
|
const headerLines = wrapText(job.header, COLS_DOUBLE);
|
|
@@ -74,10 +63,7 @@ export async function buildEscpBuffer(job) {
|
|
|
74
63
|
? Style.DoubleHeight
|
|
75
64
|
: 0;
|
|
76
65
|
for (const line of job.lines) {
|
|
77
|
-
|
|
78
|
-
for (const l of wrapped) {
|
|
79
|
-
await printer.writeln(l, widthStyle);
|
|
80
|
-
}
|
|
66
|
+
await printer.writeln(line, widthStyle);
|
|
81
67
|
}
|
|
82
68
|
await printer.feed(1);
|
|
83
69
|
}
|