@gitcode6/munbyn-pos-sdk 1.0.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 +225 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +2252 -0
- package/dist/index.d.ts +2252 -0
- package/dist/index.js +1 -0
- package/package.json +63 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESC/POS Steuerbyte-Konstanten.
|
|
3
|
+
* Alle Werte entsprechen direkt dem MUNBYN 80mm Programmer Manual.
|
|
4
|
+
*/
|
|
5
|
+
/** Null */
|
|
6
|
+
declare const NUL = 0;
|
|
7
|
+
/** Horizontal Tab */
|
|
8
|
+
declare const HT = 9;
|
|
9
|
+
/** Line Feed */
|
|
10
|
+
declare const LF = 10;
|
|
11
|
+
/** Form Feed */
|
|
12
|
+
declare const FF = 12;
|
|
13
|
+
/** Carriage Return */
|
|
14
|
+
declare const CR = 13;
|
|
15
|
+
/** Data Link Escape */
|
|
16
|
+
declare const DLE = 16;
|
|
17
|
+
/** Device Control 4 */
|
|
18
|
+
declare const DC4 = 20;
|
|
19
|
+
/** Cancel */
|
|
20
|
+
declare const CAN = 24;
|
|
21
|
+
/** Escape */
|
|
22
|
+
declare const ESC = 27;
|
|
23
|
+
/** File Separator */
|
|
24
|
+
declare const FS = 28;
|
|
25
|
+
/** Group Separator */
|
|
26
|
+
declare const GS = 29;
|
|
27
|
+
/** End of Transmission */
|
|
28
|
+
declare const EOT = 4;
|
|
29
|
+
/** Enquiry */
|
|
30
|
+
declare const ENQ = 5;
|
|
31
|
+
/** Space */
|
|
32
|
+
declare const SP = 32;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Veränderlicher Byte-Akkumulator.
|
|
36
|
+
* Wird intern von CommandSequence und ReceiptBuilder verwendet,
|
|
37
|
+
* um Byte-Folgen effizient zusammenzusetzen.
|
|
38
|
+
* @category Hilfsfunktionen
|
|
39
|
+
*/
|
|
40
|
+
declare class ByteBuilder {
|
|
41
|
+
private readonly chunks;
|
|
42
|
+
private totalLength;
|
|
43
|
+
/** Fügt einzelne Bytes oder Byte-Arrays hinzu. */
|
|
44
|
+
push(...bytes: (number | Uint8Array | number[])[]): this;
|
|
45
|
+
/** Fügt einen Text als CP1252-Bytes hinzu. */
|
|
46
|
+
text(str: string): this;
|
|
47
|
+
/** Gibt alle gesammelten Bytes als Uint8Array zurück. */
|
|
48
|
+
build(): Uint8Array;
|
|
49
|
+
/** Gibt die aktuelle Gesamtlänge zurück. */
|
|
50
|
+
get length(): number;
|
|
51
|
+
/** Setzt den Builder zurück. */
|
|
52
|
+
reset(): this;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Hilfsfunktionen für Little-Endian-Darstellungen
|
|
57
|
+
* wie sie ESC/POS-Befehle mit nL/nH-Parametern verwenden.
|
|
58
|
+
* @category Hilfsfunktionen
|
|
59
|
+
*/
|
|
60
|
+
/**
|
|
61
|
+
* Teilt eine Ganzzahl in zwei Bytes (nL, nH) auf.
|
|
62
|
+
* n = nL + nH × 256
|
|
63
|
+
* @category Hilfsfunktionen
|
|
64
|
+
*/
|
|
65
|
+
declare function toUint16LE(n: number): [nL: number, nH: number];
|
|
66
|
+
/**
|
|
67
|
+
* Berechnet das 16-Bit-Zweierkomplement für eine negative relative Position.
|
|
68
|
+
* ESC/POS: "Nach links N Einheiten" → 65536 − N
|
|
69
|
+
* @category Hilfsfunktionen
|
|
70
|
+
*/
|
|
71
|
+
declare function toComplement16(n: number): number;
|
|
72
|
+
/**
|
|
73
|
+
* Liest nL + nH × 256 zurück in eine Ganzzahl.
|
|
74
|
+
*/
|
|
75
|
+
declare function fromUint16LE(nL: number, nH: number): number;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* ESC a n — Textausrichtung
|
|
79
|
+
* @category Enumerationen
|
|
80
|
+
*/
|
|
81
|
+
declare enum Alignment {
|
|
82
|
+
Left = 0,
|
|
83
|
+
Center = 1,
|
|
84
|
+
Right = 2
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* ESC M n — Zeichenfont
|
|
89
|
+
* @category Enumerationen
|
|
90
|
+
*/
|
|
91
|
+
declare enum Font {
|
|
92
|
+
/** Font A: 12×24 Dots */
|
|
93
|
+
A = 0,
|
|
94
|
+
/** Font B: 9×17 Dots */
|
|
95
|
+
B = 1
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* ESC – n — Unterstreichungsmodus
|
|
100
|
+
* @category Enumerationen
|
|
101
|
+
*/
|
|
102
|
+
declare enum UnderlineMode {
|
|
103
|
+
Off = 0,
|
|
104
|
+
OneTick = 1,
|
|
105
|
+
TwoTicks = 2
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* GS k — Barcode-Systeme.
|
|
110
|
+
* Form ① (m = 0–6): NUL-terminiert.
|
|
111
|
+
* Form ② (m = 65–73): Länge vorangestellt.
|
|
112
|
+
* Hier verwenden wir die Form-②-Werte als kanonisch (Form ① offset = -65).
|
|
113
|
+
* @category Enumerationen
|
|
114
|
+
*/
|
|
115
|
+
declare enum BarcodeSystem {
|
|
116
|
+
UPC_A = 65,
|
|
117
|
+
UPC_E = 66,
|
|
118
|
+
EAN13 = 67,
|
|
119
|
+
EAN8 = 68,
|
|
120
|
+
CODE39 = 69,
|
|
121
|
+
ITF = 70,
|
|
122
|
+
CODABAR = 71,
|
|
123
|
+
CODE93 = 72,
|
|
124
|
+
CODE128 = 73
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* GS w n — Barcode-Breite (2–6)
|
|
129
|
+
* @category Enumerationen
|
|
130
|
+
*/
|
|
131
|
+
declare enum BarcodeWidth {
|
|
132
|
+
Narrow = 2,
|
|
133
|
+
Medium = 3,
|
|
134
|
+
Wide = 4,
|
|
135
|
+
Wider = 5,
|
|
136
|
+
Widest = 6
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* GS H n — Position der Human Readable Interpretation (HRI)
|
|
141
|
+
* @category Enumerationen
|
|
142
|
+
*/
|
|
143
|
+
declare enum HriPosition {
|
|
144
|
+
None = 0,
|
|
145
|
+
Above = 1,
|
|
146
|
+
Below = 2,
|
|
147
|
+
Both = 3
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* GS f n — Schriftart der HRI-Zeichen
|
|
152
|
+
* @category Enumerationen
|
|
153
|
+
*/
|
|
154
|
+
declare enum HriFont {
|
|
155
|
+
/** Standard ASCII (12×24) */
|
|
156
|
+
A = 0,
|
|
157
|
+
/** Komprimiertes ASCII (9×17) */
|
|
158
|
+
B = 1
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* GS V m — Schnittmodus
|
|
163
|
+
* @category Enumerationen
|
|
164
|
+
*/
|
|
165
|
+
declare enum CutMode {
|
|
166
|
+
/** Vollschnitt (ein Punkt bleibt) m=0 */
|
|
167
|
+
Full = 0,
|
|
168
|
+
/** Teilschnitt m=1 */
|
|
169
|
+
Partial = 1,
|
|
170
|
+
/** Teilschnitt nach Vorschub m=66, braucht zusätzliches n */
|
|
171
|
+
PartialAfterFeed = 66
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* ESC t n — Zeichencodetabelle
|
|
176
|
+
* @category Enumerationen
|
|
177
|
+
*/
|
|
178
|
+
declare enum CharacterCodeTable {
|
|
179
|
+
PC437 = 0,
|
|
180
|
+
Katakana = 1,
|
|
181
|
+
PC850 = 2,
|
|
182
|
+
PC860 = 3,
|
|
183
|
+
PC863 = 4,
|
|
184
|
+
PC865 = 5,
|
|
185
|
+
WestEurope = 6,
|
|
186
|
+
Greek = 7,
|
|
187
|
+
Hebrew = 8,
|
|
188
|
+
PC755 = 9,
|
|
189
|
+
Iran = 10,
|
|
190
|
+
WPC1252 = 16,
|
|
191
|
+
PC866 = 17,
|
|
192
|
+
PC852 = 18,
|
|
193
|
+
PC858 = 19,
|
|
194
|
+
IranII = 20,
|
|
195
|
+
Latvian = 21
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* ESC R n — Internationaler Zeichensatz
|
|
200
|
+
* @category Enumerationen
|
|
201
|
+
*/
|
|
202
|
+
declare enum InternationalCharacterSet {
|
|
203
|
+
USA = 0,
|
|
204
|
+
France = 1,
|
|
205
|
+
Germany = 2,
|
|
206
|
+
UK = 3,
|
|
207
|
+
Denmark = 4,
|
|
208
|
+
Sweden = 5,
|
|
209
|
+
Italy = 6,
|
|
210
|
+
Spain = 7,
|
|
211
|
+
Japan = 8,
|
|
212
|
+
Norway = 9,
|
|
213
|
+
Denmark2 = 10,
|
|
214
|
+
Spain2 = 11,
|
|
215
|
+
Latin = 12,
|
|
216
|
+
Korea = 13,
|
|
217
|
+
SloveniaCroatia = 14,
|
|
218
|
+
Chinese = 15
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* ESC T n — Druckrichtung im Page-Modus
|
|
223
|
+
* @category Enumerationen
|
|
224
|
+
*/
|
|
225
|
+
declare enum PrintDirection {
|
|
226
|
+
/** Links → Rechts, Startpunkt oben links */
|
|
227
|
+
LeftToRight = 0,
|
|
228
|
+
/** Unten → Oben, Startpunkt unten links */
|
|
229
|
+
BottomToTop = 1,
|
|
230
|
+
/** Rechts → Links, Startpunkt unten rechts */
|
|
231
|
+
RightToLeft = 2,
|
|
232
|
+
/** Oben → Unten, Startpunkt oben rechts */
|
|
233
|
+
TopToBottom = 3
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* ESC * m — Bit-Bild-Modus
|
|
238
|
+
* @category Enumerationen
|
|
239
|
+
*/
|
|
240
|
+
declare enum BitImageMode {
|
|
241
|
+
/** 8-Dot, einfache Dichte */
|
|
242
|
+
SingleDensity8 = 0,
|
|
243
|
+
/** 8-Dot, doppelte Dichte */
|
|
244
|
+
DoubleDensity8 = 1,
|
|
245
|
+
/** 24-Dot, einfache Dichte */
|
|
246
|
+
SingleDensity24 = 32,
|
|
247
|
+
/** 24-Dot, doppelte Dichte */
|
|
248
|
+
DoubleDensity24 = 33
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* GS v 0 m — Raster-Bit-Bild-Modus
|
|
253
|
+
* Auch für FS p und GS /
|
|
254
|
+
* @category Enumerationen
|
|
255
|
+
*/
|
|
256
|
+
declare enum RasterMode {
|
|
257
|
+
Normal = 0,
|
|
258
|
+
DoubleWidth = 1,
|
|
259
|
+
DoubleHeight = 2,
|
|
260
|
+
Quadruple = 3
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* ESC p m / DLE DC4 n m t — Schubladenimpuls-Pin
|
|
265
|
+
* @category Enumerationen
|
|
266
|
+
*/
|
|
267
|
+
declare enum DrawerPin {
|
|
268
|
+
/** Connector Pin 2 */
|
|
269
|
+
Pin2 = 0,
|
|
270
|
+
/** Connector Pin 5 */
|
|
271
|
+
Pin5 = 1
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* GS ( k — QR-Code-Fehlerkorrektur-Level.
|
|
276
|
+
*
|
|
277
|
+
* L = 7% Wiederherstellung
|
|
278
|
+
* M = 15% Wiederherstellung
|
|
279
|
+
* Q = 25% Wiederherstellung
|
|
280
|
+
* H = 30% Wiederherstellung
|
|
281
|
+
* @category Enumerationen
|
|
282
|
+
*/
|
|
283
|
+
declare enum QrCodeErrorCorrection {
|
|
284
|
+
L = 48,
|
|
285
|
+
M = 49,
|
|
286
|
+
Q = 50,
|
|
287
|
+
H = 51
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Das zentrale Command-Interface (Command-Pattern).
|
|
292
|
+
*
|
|
293
|
+
* Jeder ESC/POS-Befehl aus dem Handbuch wird als eigene Klasse implementiert,
|
|
294
|
+
* die dieses Interface erfüllt. Dadurch ist "was gedruckt wird" vollständig
|
|
295
|
+
* von "wie gesendet wird" entkoppelt.
|
|
296
|
+
* @category Befehle
|
|
297
|
+
*/
|
|
298
|
+
interface Command {
|
|
299
|
+
/** Menschenlesbarer Name des Befehls (z.B. "LineFeed", "PrintBarcode"). */
|
|
300
|
+
readonly name: string;
|
|
301
|
+
/**
|
|
302
|
+
* Kodiert den Befehl in seine ESC/POS-Byte-Repräsentation.
|
|
303
|
+
* Wirft RangeError wenn Parameter außerhalb der Handbuch-Bereiche liegen.
|
|
304
|
+
*/
|
|
305
|
+
encode(): Uint8Array;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Template-Method-Basisklasse für alle ESC/POS-Befehle.
|
|
310
|
+
*
|
|
311
|
+
* Definiert den Ablauf: validate() → encodeBody().
|
|
312
|
+
* Unterklassen implementieren nur encodeBody() (und optional validate()).
|
|
313
|
+
* @category Befehle
|
|
314
|
+
*/
|
|
315
|
+
declare abstract class AbstractCommand implements Command {
|
|
316
|
+
abstract readonly name: string;
|
|
317
|
+
/**
|
|
318
|
+
* Template Method: Validierung, dann Kodierung.
|
|
319
|
+
* Wirft RangeError wenn validate() fehlschlägt.
|
|
320
|
+
*/
|
|
321
|
+
encode(): Uint8Array;
|
|
322
|
+
/**
|
|
323
|
+
* Implementiert die eigentliche Byte-Erzeugung.
|
|
324
|
+
* Wird erst nach erfolgreicher Validierung aufgerufen.
|
|
325
|
+
*/
|
|
326
|
+
protected abstract encodeBody(): Uint8Array;
|
|
327
|
+
/**
|
|
328
|
+
* Überprüft Parameter-Bereiche. Wirft RangeError bei Verletzung.
|
|
329
|
+
* Standard-Implementierung: keine Prüfung (für parameterlose Befehle).
|
|
330
|
+
*/
|
|
331
|
+
protected validate(): void;
|
|
332
|
+
/**
|
|
333
|
+
* Hilfsmethode: Prüft, ob ein Wert im erlaubten Bereich liegt.
|
|
334
|
+
*/
|
|
335
|
+
protected assertRange(value: number, min: number, max: number, paramName?: string): void;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Composite + Iterator Pattern.
|
|
340
|
+
*
|
|
341
|
+
* Eine CommandSequence ist selbst ein Command (Composite) und enthält
|
|
342
|
+
* beliebig viele Kind-Commands. Ein kompletter Bon = eine CommandSequence.
|
|
343
|
+
* Ist iterierbar über alle enthaltenen Commands ([Symbol.iterator]).
|
|
344
|
+
* @category Befehle
|
|
345
|
+
*/
|
|
346
|
+
declare class CommandSequence implements Command {
|
|
347
|
+
readonly name = "CommandSequence";
|
|
348
|
+
private readonly commands;
|
|
349
|
+
constructor(...initial: Command[]);
|
|
350
|
+
/** Fügt einen oder mehrere Commands ans Ende hinzu. */
|
|
351
|
+
add(...cmds: Command[]): this;
|
|
352
|
+
/** Anzahl der enthaltenen Commands. */
|
|
353
|
+
get size(): number;
|
|
354
|
+
/**
|
|
355
|
+
* Iterator über alle Kind-Commands (Iterator-Pattern).
|
|
356
|
+
* Ermöglicht: for (const cmd of sequence) { ... }
|
|
357
|
+
*/
|
|
358
|
+
[Symbol.iterator](): Iterator<Command>;
|
|
359
|
+
/**
|
|
360
|
+
* Kodiert alle enthaltenen Commands zu einer einzigen Byte-Folge.
|
|
361
|
+
* Composite-Implementierung: encode() ruft encode() aller Kinder auf.
|
|
362
|
+
*/
|
|
363
|
+
encode(): Uint8Array;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Escape-Hatch: beliebige Byte-Folge als Command.
|
|
368
|
+
*
|
|
369
|
+
* Nützlich für vendor-spezifische Erweiterungen, die nicht im Handbuch
|
|
370
|
+
* dokumentiert sind, oder für direkte Byte-Eingaben aus externem Code.
|
|
371
|
+
* @category Befehle
|
|
372
|
+
*/
|
|
373
|
+
declare class RawCommand implements Command {
|
|
374
|
+
readonly name: string;
|
|
375
|
+
private readonly bytes;
|
|
376
|
+
constructor(bytes: Uint8Array | number[], name?: string);
|
|
377
|
+
encode(): Uint8Array;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Singleton-Registry aller bekannten Command-Typen.
|
|
382
|
+
*
|
|
383
|
+
* Ermöglicht Introspektion (z.B. für Hex-Dumps, Logging, Debugging).
|
|
384
|
+
* Externe Bibliotheken können eigene Command-Typen registrieren.
|
|
385
|
+
* @category Befehle
|
|
386
|
+
*/
|
|
387
|
+
/**
|
|
388
|
+
* Registrierungseintrag für einen Command-Typ.
|
|
389
|
+
* @category Befehle
|
|
390
|
+
*/
|
|
391
|
+
interface CommandRegistration {
|
|
392
|
+
name: string;
|
|
393
|
+
description: string;
|
|
394
|
+
escPosCommand: string;
|
|
395
|
+
}
|
|
396
|
+
declare class CommandRegistry {
|
|
397
|
+
private static instance;
|
|
398
|
+
private readonly registrations;
|
|
399
|
+
private constructor();
|
|
400
|
+
/** Gibt die einzige Instanz zurück (Singleton-Pattern). */
|
|
401
|
+
static getInstance(): CommandRegistry;
|
|
402
|
+
/** Registriert einen Command-Typ. */
|
|
403
|
+
register(reg: CommandRegistration): void;
|
|
404
|
+
/** Gibt alle Registrierungen zurück. */
|
|
405
|
+
getAll(): ReadonlyMap<string, CommandRegistration>;
|
|
406
|
+
/** Gibt eine Registrierung nach Name zurück. */
|
|
407
|
+
get(name: string): CommandRegistration | undefined;
|
|
408
|
+
/** Prüft ob ein Command-Typ registriert ist. */
|
|
409
|
+
has(name: string): boolean;
|
|
410
|
+
/** Nur für Tests — setzt den Singleton zurück. */
|
|
411
|
+
static _reset(): void;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* HT — Horizontaler Tabulator
|
|
416
|
+
* @category Einzelne Befehle
|
|
417
|
+
*/
|
|
418
|
+
declare class HorizontalTabCommand extends AbstractCommand {
|
|
419
|
+
readonly name = "HorizontalTab";
|
|
420
|
+
protected encodeBody(): Uint8Array;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* LF — Zeilenvorschub
|
|
425
|
+
* @category Einzelne Befehle
|
|
426
|
+
*/
|
|
427
|
+
declare class LineFeedCommand extends AbstractCommand {
|
|
428
|
+
readonly name = "LineFeed";
|
|
429
|
+
protected encodeBody(): Uint8Array;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* FF — Seitenvorschub / Rückkehr in Standard-Modus aus Page-Modus
|
|
434
|
+
* @category Einzelne Befehle
|
|
435
|
+
*/
|
|
436
|
+
declare class FormFeedCommand extends AbstractCommand {
|
|
437
|
+
readonly name = "FormFeed";
|
|
438
|
+
protected encodeBody(): Uint8Array;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* CR — Wagenrücklauf
|
|
443
|
+
* @category Einzelne Befehle
|
|
444
|
+
*/
|
|
445
|
+
declare class CarriageReturnCommand extends AbstractCommand {
|
|
446
|
+
readonly name = "CarriageReturn";
|
|
447
|
+
protected encodeBody(): Uint8Array;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* CAN — Druckdaten im Page-Modus löschen
|
|
452
|
+
* @category Einzelne Befehle
|
|
453
|
+
*/
|
|
454
|
+
declare class CancelPageDataCommand extends AbstractCommand {
|
|
455
|
+
readonly name = "CancelPageData";
|
|
456
|
+
protected encodeBody(): Uint8Array;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* DLE EOT n — Echtzeit-Status übertragen.
|
|
461
|
+
* n=1: Druckerstatus, n=2: Offline-Status, n=3: Fehlerstatus, n=4: Papiersensor-Status
|
|
462
|
+
* @category Einzelne Befehle
|
|
463
|
+
*/
|
|
464
|
+
declare class TransmitRealtimeStatusCommand extends AbstractCommand {
|
|
465
|
+
private readonly n;
|
|
466
|
+
readonly name = "TransmitRealtimeStatus";
|
|
467
|
+
constructor(n: 1 | 2 | 3 | 4);
|
|
468
|
+
protected validate(): void;
|
|
469
|
+
protected encodeBody(): Uint8Array;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* DLE ENQ n — Echtzeit-Anfrage an Drucker.
|
|
474
|
+
* n=1: Fehler-Wiederherstellung (neu drucken), n=2: Fehler-Wiederherstellung (Puffer löschen)
|
|
475
|
+
* @category Einzelne Befehle
|
|
476
|
+
*/
|
|
477
|
+
declare class RealtimeRequestCommand extends AbstractCommand {
|
|
478
|
+
private readonly n;
|
|
479
|
+
readonly name = "RealtimeRequest";
|
|
480
|
+
constructor(n: 1 | 2);
|
|
481
|
+
protected validate(): void;
|
|
482
|
+
protected encodeBody(): Uint8Array;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* DLE DC4 n m t — Impuls in Echtzeit erzeugen.
|
|
487
|
+
* n immer 1, m=Pin (0=Pin2, 1=Pin5), t=1–8 (Dauer t×100ms)
|
|
488
|
+
* @category Einzelne Befehle
|
|
489
|
+
*/
|
|
490
|
+
declare class GeneratePulseRealtimeCommand extends AbstractCommand {
|
|
491
|
+
private readonly pin;
|
|
492
|
+
private readonly t;
|
|
493
|
+
readonly name = "GeneratePulseRealtime";
|
|
494
|
+
constructor(pin: DrawerPin, t: number);
|
|
495
|
+
protected validate(): void;
|
|
496
|
+
protected encodeBody(): Uint8Array;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* ESC FF — Im Page-Modus drucken (Puffer nicht leeren)
|
|
501
|
+
* @category Einzelne Befehle
|
|
502
|
+
*/
|
|
503
|
+
declare class PrintPageModeCommand extends AbstractCommand {
|
|
504
|
+
readonly name = "PrintPageMode";
|
|
505
|
+
protected encodeBody(): Uint8Array;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* ESC SP n — Rechten Zeichenabstand setzen (0–255)
|
|
510
|
+
* @category Einzelne Befehle
|
|
511
|
+
*/
|
|
512
|
+
declare class SetRightCharacterSpacingCommand extends AbstractCommand {
|
|
513
|
+
private readonly n;
|
|
514
|
+
readonly name = "SetRightCharacterSpacing";
|
|
515
|
+
constructor(n: number);
|
|
516
|
+
protected validate(): void;
|
|
517
|
+
protected encodeBody(): Uint8Array;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Optionen für SelectPrintModesCommand.
|
|
522
|
+
* @category Einzelne Befehle
|
|
523
|
+
*/
|
|
524
|
+
interface PrintModesOptions {
|
|
525
|
+
/** Font B (9×17) statt Font A (12×24) */
|
|
526
|
+
fontB?: boolean;
|
|
527
|
+
/** Fett-Druck */
|
|
528
|
+
emphasized?: boolean;
|
|
529
|
+
/** Doppelte Höhe */
|
|
530
|
+
doubleHeight?: boolean;
|
|
531
|
+
/** Doppelte Breite */
|
|
532
|
+
doubleWidth?: boolean;
|
|
533
|
+
/** Unterstrichen */
|
|
534
|
+
underline?: boolean;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* ESC ! n — Druckmodus(e) auswählen.
|
|
538
|
+
* Bit 0: Font, Bit 3: Emphasized, Bit 4: DoubleHeight, Bit 5: DoubleWidth, Bit 7: Underline
|
|
539
|
+
* @category Einzelne Befehle
|
|
540
|
+
*/
|
|
541
|
+
declare class SelectPrintModesCommand extends AbstractCommand {
|
|
542
|
+
readonly name = "SelectPrintModes";
|
|
543
|
+
private readonly n;
|
|
544
|
+
constructor(opts?: PrintModesOptions);
|
|
545
|
+
protected encodeBody(): Uint8Array;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* ESC $ nL nH — Absolute Druckposition setzen
|
|
550
|
+
* @category Einzelne Befehle
|
|
551
|
+
*/
|
|
552
|
+
declare class SetAbsolutePositionCommand extends AbstractCommand {
|
|
553
|
+
private readonly n;
|
|
554
|
+
readonly name = "SetAbsolutePosition";
|
|
555
|
+
constructor(n: number);
|
|
556
|
+
protected validate(): void;
|
|
557
|
+
protected encodeBody(): Uint8Array;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* ESC % n — Benutzerdefinierter Zeichensatz ein/aus
|
|
562
|
+
* @category Einzelne Befehle
|
|
563
|
+
*/
|
|
564
|
+
declare class SelectUserCharSetCommand extends AbstractCommand {
|
|
565
|
+
private readonly enable;
|
|
566
|
+
readonly name = "SelectUserCharSet";
|
|
567
|
+
constructor(enable: boolean);
|
|
568
|
+
protected encodeBody(): Uint8Array;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* ESC & y c1 c2 [x1 d1...d(y×x1)]...[xk d1...d(y×xk)]
|
|
573
|
+
* Benutzerdefinierte Zeichen definieren.
|
|
574
|
+
* @category Einzelne Befehle
|
|
575
|
+
*/
|
|
576
|
+
declare class DefineUserCharsCommand extends AbstractCommand {
|
|
577
|
+
private readonly y;
|
|
578
|
+
private readonly c1;
|
|
579
|
+
private readonly c2;
|
|
580
|
+
private readonly data;
|
|
581
|
+
readonly name = "DefineUserChars";
|
|
582
|
+
constructor(y: number, c1: number, c2: number, data: Uint8Array);
|
|
583
|
+
protected validate(): void;
|
|
584
|
+
protected encodeBody(): Uint8Array;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* ESC * m nL nH d1...dk — Bit-Bild-Modus auswählen
|
|
589
|
+
* @category Einzelne Befehle
|
|
590
|
+
*/
|
|
591
|
+
declare class SelectBitImageModeCommand extends AbstractCommand {
|
|
592
|
+
private readonly mode;
|
|
593
|
+
private readonly nL;
|
|
594
|
+
private readonly nH;
|
|
595
|
+
private readonly data;
|
|
596
|
+
readonly name = "SelectBitImageMode";
|
|
597
|
+
constructor(mode: BitImageMode, nL: number, nH: number, data: Uint8Array);
|
|
598
|
+
protected validate(): void;
|
|
599
|
+
protected encodeBody(): Uint8Array;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* ESC – n — Unterstreichungsmodus ein/aus
|
|
604
|
+
* @category Einzelne Befehle
|
|
605
|
+
*/
|
|
606
|
+
declare class SetUnderlineCommand extends AbstractCommand {
|
|
607
|
+
private readonly mode;
|
|
608
|
+
readonly name = "SetUnderline";
|
|
609
|
+
constructor(mode: UnderlineMode);
|
|
610
|
+
protected validate(): void;
|
|
611
|
+
protected encodeBody(): Uint8Array;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* ESC 2 — Standard-Zeilenabstand (~4.23mm / 1/6 Zoll)
|
|
616
|
+
* @category Einzelne Befehle
|
|
617
|
+
*/
|
|
618
|
+
declare class SetDefaultLineSpacingCommand extends AbstractCommand {
|
|
619
|
+
readonly name = "SetDefaultLineSpacing";
|
|
620
|
+
protected encodeBody(): Uint8Array;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* ESC 3 n — Zeilenabstand setzen (0–255)
|
|
625
|
+
* @category Einzelne Befehle
|
|
626
|
+
*/
|
|
627
|
+
declare class SetLineSpacingCommand extends AbstractCommand {
|
|
628
|
+
private readonly n;
|
|
629
|
+
readonly name = "SetLineSpacing";
|
|
630
|
+
constructor(n: number);
|
|
631
|
+
protected validate(): void;
|
|
632
|
+
protected encodeBody(): Uint8Array;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* ESC = n — Peripheriegerät auswählen (Bit 0: Drucker aktiv)
|
|
637
|
+
* @category Einzelne Befehle
|
|
638
|
+
*/
|
|
639
|
+
declare class SetPeripheralDeviceCommand extends AbstractCommand {
|
|
640
|
+
private readonly n;
|
|
641
|
+
readonly name = "SetPeripheralDevice";
|
|
642
|
+
constructor(n: number);
|
|
643
|
+
protected validate(): void;
|
|
644
|
+
protected encodeBody(): Uint8Array;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* ESC ? n — Benutzerdefiniertes Zeichen löschen (32–126)
|
|
649
|
+
* @category Einzelne Befehle
|
|
650
|
+
*/
|
|
651
|
+
declare class CancelUserCharCommand extends AbstractCommand {
|
|
652
|
+
private readonly n;
|
|
653
|
+
readonly name = "CancelUserChar";
|
|
654
|
+
constructor(n: number);
|
|
655
|
+
protected validate(): void;
|
|
656
|
+
protected encodeBody(): Uint8Array;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* ESC @ — Drucker initialisieren (Puffer leeren, Modi zurücksetzen)
|
|
661
|
+
* @category Einzelne Befehle
|
|
662
|
+
*/
|
|
663
|
+
declare class InitializeCommand extends AbstractCommand {
|
|
664
|
+
readonly name = "Initialize";
|
|
665
|
+
protected encodeBody(): Uint8Array;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* ESC D n1...nk NUL — Horizontale Tabulatorpositionen setzen (max. 32)
|
|
670
|
+
* @category Einzelne Befehle
|
|
671
|
+
*/
|
|
672
|
+
declare class SetHorizontalTabPositionsCommand extends AbstractCommand {
|
|
673
|
+
private readonly positions;
|
|
674
|
+
readonly name = "SetHorizontalTabPositions";
|
|
675
|
+
constructor(positions: number[]);
|
|
676
|
+
protected validate(): void;
|
|
677
|
+
protected encodeBody(): Uint8Array;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* ESC E n — Fettdruck ein/aus (LSB entscheidet)
|
|
682
|
+
* @category Einzelne Befehle
|
|
683
|
+
*/
|
|
684
|
+
declare class SetEmphasizedCommand extends AbstractCommand {
|
|
685
|
+
private readonly on;
|
|
686
|
+
readonly name = "SetEmphasized";
|
|
687
|
+
constructor(on: boolean);
|
|
688
|
+
protected encodeBody(): Uint8Array;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* ESC G n — Doppeldruck ein/aus
|
|
693
|
+
* @category Einzelne Befehle
|
|
694
|
+
*/
|
|
695
|
+
declare class SetDoubleStrikeCommand extends AbstractCommand {
|
|
696
|
+
private readonly on;
|
|
697
|
+
readonly name = "SetDoubleStrike";
|
|
698
|
+
constructor(on: boolean);
|
|
699
|
+
protected encodeBody(): Uint8Array;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* ESC J n — Drucken und Papier vorschub um n × Bewegungseinheit
|
|
704
|
+
* @category Einzelne Befehle
|
|
705
|
+
*/
|
|
706
|
+
declare class PrintAndFeedPaperCommand extends AbstractCommand {
|
|
707
|
+
private readonly n;
|
|
708
|
+
readonly name = "PrintAndFeedPaper";
|
|
709
|
+
constructor(n: number);
|
|
710
|
+
protected validate(): void;
|
|
711
|
+
protected encodeBody(): Uint8Array;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* ESC L — In Page-Modus wechseln
|
|
716
|
+
* @category Einzelne Befehle
|
|
717
|
+
*/
|
|
718
|
+
declare class SelectPageModeCommand extends AbstractCommand {
|
|
719
|
+
readonly name = "SelectPageMode";
|
|
720
|
+
protected encodeBody(): Uint8Array;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* ESC M n — Zeichenzeichensatz auswählen (Font A / B)
|
|
725
|
+
* @category Einzelne Befehle
|
|
726
|
+
*/
|
|
727
|
+
declare class SelectCharacterFontCommand extends AbstractCommand {
|
|
728
|
+
private readonly font;
|
|
729
|
+
readonly name = "SelectCharacterFont";
|
|
730
|
+
constructor(font: Font);
|
|
731
|
+
protected validate(): void;
|
|
732
|
+
protected encodeBody(): Uint8Array;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* ESC R n — Internationalen Zeichensatz auswählen (0–15)
|
|
737
|
+
* @category Einzelne Befehle
|
|
738
|
+
*/
|
|
739
|
+
declare class SelectInternationalCharSetCommand extends AbstractCommand {
|
|
740
|
+
private readonly charSet;
|
|
741
|
+
readonly name = "SelectInternationalCharSet";
|
|
742
|
+
constructor(charSet: InternationalCharacterSet);
|
|
743
|
+
protected validate(): void;
|
|
744
|
+
protected encodeBody(): Uint8Array;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* ESC S — In Standard-Modus wechseln (aus Page-Modus)
|
|
749
|
+
* @category Einzelne Befehle
|
|
750
|
+
*/
|
|
751
|
+
declare class SelectStandardModeCommand extends AbstractCommand {
|
|
752
|
+
readonly name = "SelectStandardMode";
|
|
753
|
+
protected encodeBody(): Uint8Array;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* ESC T n — Druckrichtung im Page-Modus auswählen (0–3)
|
|
758
|
+
* @category Einzelne Befehle
|
|
759
|
+
*/
|
|
760
|
+
declare class SelectPrintDirectionCommand extends AbstractCommand {
|
|
761
|
+
private readonly direction;
|
|
762
|
+
readonly name = "SelectPrintDirection";
|
|
763
|
+
constructor(direction: PrintDirection);
|
|
764
|
+
protected validate(): void;
|
|
765
|
+
protected encodeBody(): Uint8Array;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* ESC V n — 90°-Drehung ein/aus
|
|
770
|
+
* @category Einzelne Befehle
|
|
771
|
+
*/
|
|
772
|
+
declare class SetRotationCommand extends AbstractCommand {
|
|
773
|
+
private readonly on;
|
|
774
|
+
readonly name = "SetRotation";
|
|
775
|
+
constructor(on: boolean);
|
|
776
|
+
protected encodeBody(): Uint8Array;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* ESC W xL xH yL yH dxL dxH dyL dyH — Druckbereich im Page-Modus setzen
|
|
781
|
+
* @category Einzelne Befehle
|
|
782
|
+
*/
|
|
783
|
+
declare class SetPrintingAreaPageModeCommand extends AbstractCommand {
|
|
784
|
+
private readonly xL;
|
|
785
|
+
private readonly xH;
|
|
786
|
+
private readonly yL;
|
|
787
|
+
private readonly yH;
|
|
788
|
+
private readonly dxL;
|
|
789
|
+
private readonly dxH;
|
|
790
|
+
private readonly dyL;
|
|
791
|
+
private readonly dyH;
|
|
792
|
+
readonly name = "SetPrintingAreaPageMode";
|
|
793
|
+
constructor(xL: number, xH: number, yL: number, yH: number, dxL: number, dxH: number, dyL: number, dyH: number);
|
|
794
|
+
protected validate(): void;
|
|
795
|
+
protected encodeBody(): Uint8Array;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* ESC \ nL nH — Relative Druckposition setzen.
|
|
800
|
+
* Positive Werte bewegen nach rechts, negative nach links (Zweierkomplement).
|
|
801
|
+
* @category Einzelne Befehle
|
|
802
|
+
*/
|
|
803
|
+
declare class SetRelativePositionCommand extends AbstractCommand {
|
|
804
|
+
private readonly n;
|
|
805
|
+
readonly name = "SetRelativePosition";
|
|
806
|
+
constructor(n: number);
|
|
807
|
+
protected validate(): void;
|
|
808
|
+
protected encodeBody(): Uint8Array;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* ESC a n — Textausrichtung (0=Links, 1=Mitte, 2=Rechts)
|
|
813
|
+
* @category Einzelne Befehle
|
|
814
|
+
*/
|
|
815
|
+
declare class SetJustificationCommand extends AbstractCommand {
|
|
816
|
+
private readonly alignment;
|
|
817
|
+
readonly name = "SetJustification";
|
|
818
|
+
constructor(alignment: Alignment);
|
|
819
|
+
protected validate(): void;
|
|
820
|
+
protected encodeBody(): Uint8Array;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* ESC c 3 n — Papierende-Sensoren für Signal-Ausgabe auswählen
|
|
825
|
+
* @category Einzelne Befehle
|
|
826
|
+
*/
|
|
827
|
+
declare class SelectPaperEndSensorsCommand extends AbstractCommand {
|
|
828
|
+
private readonly n;
|
|
829
|
+
readonly name = "SelectPaperEndSensors";
|
|
830
|
+
constructor(n: number);
|
|
831
|
+
protected validate(): void;
|
|
832
|
+
protected encodeBody(): Uint8Array;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* ESC c 4 n — Papierende-Sensoren für Druck-Stopp auswählen
|
|
837
|
+
* @category Einzelne Befehle
|
|
838
|
+
*/
|
|
839
|
+
declare class SelectPaperStopSensorsCommand extends AbstractCommand {
|
|
840
|
+
private readonly n;
|
|
841
|
+
readonly name = "SelectPaperStopSensors";
|
|
842
|
+
constructor(n: number);
|
|
843
|
+
protected validate(): void;
|
|
844
|
+
protected encodeBody(): Uint8Array;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* ESC c 5 n — Bedienfeld-Tasten aktivieren/deaktivieren
|
|
849
|
+
* @category Einzelne Befehle
|
|
850
|
+
*/
|
|
851
|
+
declare class EnablePanelButtonsCommand extends AbstractCommand {
|
|
852
|
+
private readonly enable;
|
|
853
|
+
readonly name = "EnablePanelButtons";
|
|
854
|
+
constructor(enable: boolean);
|
|
855
|
+
protected encodeBody(): Uint8Array;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
/**
|
|
859
|
+
* ESC d n — Drucken und n Zeilen vorschub
|
|
860
|
+
* @category Einzelne Befehle
|
|
861
|
+
*/
|
|
862
|
+
declare class PrintAndFeedLinesCommand extends AbstractCommand {
|
|
863
|
+
private readonly n;
|
|
864
|
+
readonly name = "PrintAndFeedLines";
|
|
865
|
+
constructor(n: number);
|
|
866
|
+
protected validate(): void;
|
|
867
|
+
protected encodeBody(): Uint8Array;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* ESC p m t1 t2 — Impuls erzeugen.
|
|
872
|
+
* ON-Zeit = t1×2ms, OFF-Zeit = t2×2ms (min. t1×2ms wenn t2<t1)
|
|
873
|
+
* @category Einzelne Befehle
|
|
874
|
+
*/
|
|
875
|
+
declare class GeneratePulseCommand extends AbstractCommand {
|
|
876
|
+
private readonly pin;
|
|
877
|
+
private readonly t1;
|
|
878
|
+
private readonly t2;
|
|
879
|
+
readonly name = "GeneratePulse";
|
|
880
|
+
constructor(pin: DrawerPin, t1: number, t2: number);
|
|
881
|
+
protected validate(): void;
|
|
882
|
+
protected encodeBody(): Uint8Array;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* ESC t n — Zeichencodetabelle auswählen
|
|
887
|
+
* @category Einzelne Befehle
|
|
888
|
+
*/
|
|
889
|
+
declare class SelectCharacterCodeTableCommand extends AbstractCommand {
|
|
890
|
+
private readonly table;
|
|
891
|
+
readonly name = "SelectCharacterCodeTable";
|
|
892
|
+
constructor(table: CharacterCodeTable);
|
|
893
|
+
protected validate(): void;
|
|
894
|
+
protected encodeBody(): Uint8Array;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
/**
|
|
898
|
+
* ESC { n — Kopfüber-Druck ein/aus
|
|
899
|
+
* @category Einzelne Befehle
|
|
900
|
+
*/
|
|
901
|
+
declare class SetUpsideDownCommand extends AbstractCommand {
|
|
902
|
+
private readonly on;
|
|
903
|
+
readonly name = "SetUpsideDown";
|
|
904
|
+
constructor(on: boolean);
|
|
905
|
+
protected encodeBody(): Uint8Array;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* ESC B n t — Einzelnen Piep ausgeben.
|
|
910
|
+
* n=Anzahl (1–9), t=Dauer je Ton (t×50ms, 1–9)
|
|
911
|
+
* @category Einzelne Befehle
|
|
912
|
+
*/
|
|
913
|
+
declare class BeepCommand extends AbstractCommand {
|
|
914
|
+
private readonly count;
|
|
915
|
+
private readonly duration;
|
|
916
|
+
readonly name = "Beep";
|
|
917
|
+
constructor(count: number, duration: number);
|
|
918
|
+
protected validate(): void;
|
|
919
|
+
protected encodeBody(): Uint8Array;
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
/**
|
|
923
|
+
* ESC C m t n — Piep und Alarmlampe blinken.
|
|
924
|
+
* m=Anzahl (1–20), t=Intervall (t×50ms, 1–20),
|
|
925
|
+
* n=0: nichts, 1: Piep, 2: Blinken, 3: beides
|
|
926
|
+
* @category Einzelne Befehle
|
|
927
|
+
*/
|
|
928
|
+
declare class BeepAndFlashCommand extends AbstractCommand {
|
|
929
|
+
private readonly count;
|
|
930
|
+
private readonly interval;
|
|
931
|
+
private readonly mode;
|
|
932
|
+
readonly name = "BeepAndFlash";
|
|
933
|
+
constructor(count: number, interval: number, mode: number);
|
|
934
|
+
protected validate(): void;
|
|
935
|
+
protected encodeBody(): Uint8Array;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* FS p n m — NV-Bit-Bild drucken
|
|
940
|
+
* @category Einzelne Befehle
|
|
941
|
+
*/
|
|
942
|
+
declare class PrintNvBitImageCommand extends AbstractCommand {
|
|
943
|
+
private readonly n;
|
|
944
|
+
private readonly mode;
|
|
945
|
+
readonly name = "PrintNvBitImage";
|
|
946
|
+
constructor(n: number, mode: RasterMode);
|
|
947
|
+
protected validate(): void;
|
|
948
|
+
protected encodeBody(): Uint8Array;
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
* Bilddaten für DefineNvBitImageCommand.
|
|
953
|
+
* @category Einzelne Befehle
|
|
954
|
+
*/
|
|
955
|
+
interface NvBitImageData {
|
|
956
|
+
xL: number;
|
|
957
|
+
xH: number;
|
|
958
|
+
yL: number;
|
|
959
|
+
yH: number;
|
|
960
|
+
data: Uint8Array;
|
|
961
|
+
}
|
|
962
|
+
/**
|
|
963
|
+
* FS q n [xL xH yL yH d1…dk]1…n — NV-Bit-Bilder definieren
|
|
964
|
+
* @category Einzelne Befehle
|
|
965
|
+
*/
|
|
966
|
+
declare class DefineNvBitImageCommand extends AbstractCommand {
|
|
967
|
+
private readonly n;
|
|
968
|
+
private readonly images;
|
|
969
|
+
readonly name = "DefineNvBitImage";
|
|
970
|
+
constructor(n: number, images: NvBitImageData[]);
|
|
971
|
+
protected validate(): void;
|
|
972
|
+
protected encodeBody(): Uint8Array;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* FS ! n — Kanji-Druckmodus setzen.
|
|
977
|
+
* Bit 2: DoppeltBreit, Bit 3: DoppeltHoch, Bit 7: Unterstrichen
|
|
978
|
+
* @category Einzelne Befehle
|
|
979
|
+
*/
|
|
980
|
+
declare class SetKanjiPrintModeCommand extends AbstractCommand {
|
|
981
|
+
private readonly n;
|
|
982
|
+
readonly name = "SetKanjiPrintMode";
|
|
983
|
+
constructor(n: number);
|
|
984
|
+
protected validate(): void;
|
|
985
|
+
protected encodeBody(): Uint8Array;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
* FS & — Kanji-Modus aktivieren
|
|
990
|
+
* @category Einzelne Befehle
|
|
991
|
+
*/
|
|
992
|
+
declare class SelectKanjiModeCommand extends AbstractCommand {
|
|
993
|
+
readonly name = "SelectKanjiMode";
|
|
994
|
+
protected encodeBody(): Uint8Array;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
/**
|
|
998
|
+
* FS – n — Kanji-Unterstreichungsmodus (0=aus, 1=1 Punkt, 2=2 Punkte)
|
|
999
|
+
* @category Einzelne Befehle
|
|
1000
|
+
*/
|
|
1001
|
+
declare class SetKanjiUnderlineCommand extends AbstractCommand {
|
|
1002
|
+
private readonly mode;
|
|
1003
|
+
readonly name = "SetKanjiUnderline";
|
|
1004
|
+
constructor(mode: UnderlineMode);
|
|
1005
|
+
protected validate(): void;
|
|
1006
|
+
protected encodeBody(): Uint8Array;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
/**
|
|
1010
|
+
* FS . — Kanji-Modus deaktivieren
|
|
1011
|
+
* @category Einzelne Befehle
|
|
1012
|
+
*/
|
|
1013
|
+
declare class CancelKanjiModeCommand extends AbstractCommand {
|
|
1014
|
+
readonly name = "CancelKanjiMode";
|
|
1015
|
+
protected encodeBody(): Uint8Array;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
/**
|
|
1019
|
+
* FS 2 c1 c2 d1...dk — Benutzerdefiniertes Kanji-Zeichen definieren.
|
|
1020
|
+
* k=72 (24×24 Dot, 3 Bytes vertikal × 24 Spalten)
|
|
1021
|
+
* @category Einzelne Befehle
|
|
1022
|
+
*/
|
|
1023
|
+
declare class DefineKanjiCommand extends AbstractCommand {
|
|
1024
|
+
private readonly c1;
|
|
1025
|
+
private readonly c2;
|
|
1026
|
+
private readonly data;
|
|
1027
|
+
readonly name = "DefineKanji";
|
|
1028
|
+
constructor(c1: number, c2: number, data: Uint8Array);
|
|
1029
|
+
protected validate(): void;
|
|
1030
|
+
protected encodeBody(): Uint8Array;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
/**
|
|
1034
|
+
* FS S n1 n2 — Linken und rechten Kanji-Zeichenabstand setzen
|
|
1035
|
+
* @category Einzelne Befehle
|
|
1036
|
+
*/
|
|
1037
|
+
declare class SetKanjiSpacingCommand extends AbstractCommand {
|
|
1038
|
+
private readonly n1;
|
|
1039
|
+
private readonly n2;
|
|
1040
|
+
readonly name = "SetKanjiSpacing";
|
|
1041
|
+
constructor(n1: number, n2: number);
|
|
1042
|
+
protected validate(): void;
|
|
1043
|
+
protected encodeBody(): Uint8Array;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* FS W n — Kanji-Vierfachgröße ein/aus
|
|
1048
|
+
* @category Einzelne Befehle
|
|
1049
|
+
*/
|
|
1050
|
+
declare class SetKanjiQuadrupleCommand extends AbstractCommand {
|
|
1051
|
+
private readonly on;
|
|
1052
|
+
readonly name = "SetKanjiQuadruple";
|
|
1053
|
+
constructor(on: boolean);
|
|
1054
|
+
protected encodeBody(): Uint8Array;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
/**
|
|
1058
|
+
* GS ! n — Zeichengröße auswählen.
|
|
1059
|
+
* heightTimes: 1–8 (vertikal), widthTimes: 1–8 (horizontal)
|
|
1060
|
+
* n = (widthTimes-1) << 4 | (heightTimes-1)
|
|
1061
|
+
* @category Einzelne Befehle
|
|
1062
|
+
*/
|
|
1063
|
+
declare class SelectCharacterSizeCommand extends AbstractCommand {
|
|
1064
|
+
private readonly heightTimes;
|
|
1065
|
+
private readonly widthTimes;
|
|
1066
|
+
readonly name = "SelectCharacterSize";
|
|
1067
|
+
constructor(heightTimes: number, widthTimes: number);
|
|
1068
|
+
protected validate(): void;
|
|
1069
|
+
protected encodeBody(): Uint8Array;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
/**
|
|
1073
|
+
* GS $ nL nH — Absolute vertikale Druckposition im Page-Modus setzen
|
|
1074
|
+
* @category Einzelne Befehle
|
|
1075
|
+
*/
|
|
1076
|
+
declare class SetAbsoluteVerticalPositionCommand extends AbstractCommand {
|
|
1077
|
+
private readonly n;
|
|
1078
|
+
readonly name = "SetAbsoluteVerticalPosition";
|
|
1079
|
+
constructor(n: number);
|
|
1080
|
+
protected validate(): void;
|
|
1081
|
+
protected encodeBody(): Uint8Array;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
/**
|
|
1085
|
+
* GS * x y d1...d(x×y×8) — Download-Bit-Bild definieren.
|
|
1086
|
+
* x: 1–255, y: 1–48, x×y ≤ 912
|
|
1087
|
+
* @category Einzelne Befehle
|
|
1088
|
+
*/
|
|
1089
|
+
declare class DefineDownloadedBitImageCommand extends AbstractCommand {
|
|
1090
|
+
private readonly x;
|
|
1091
|
+
private readonly y;
|
|
1092
|
+
private readonly data;
|
|
1093
|
+
readonly name = "DefineDownloadedBitImage";
|
|
1094
|
+
constructor(x: number, y: number, data: Uint8Array);
|
|
1095
|
+
protected validate(): void;
|
|
1096
|
+
protected encodeBody(): Uint8Array;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
/**
|
|
1100
|
+
* GS / m — Download-Bit-Bild drucken
|
|
1101
|
+
* @category Einzelne Befehle
|
|
1102
|
+
*/
|
|
1103
|
+
declare class PrintDownloadedBitImageCommand extends AbstractCommand {
|
|
1104
|
+
private readonly mode;
|
|
1105
|
+
readonly name = "PrintDownloadedBitImage";
|
|
1106
|
+
constructor(mode: RasterMode);
|
|
1107
|
+
protected validate(): void;
|
|
1108
|
+
protected encodeBody(): Uint8Array;
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
/**
|
|
1112
|
+
* GS : — Makrodefinition beginnen/beenden
|
|
1113
|
+
* @category Einzelne Befehle
|
|
1114
|
+
*/
|
|
1115
|
+
declare class MacroStartEndCommand extends AbstractCommand {
|
|
1116
|
+
readonly name = "MacroStartEnd";
|
|
1117
|
+
protected encodeBody(): Uint8Array;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* GS B n — Schwarz/Weiß-Umkehrdruck ein/aus
|
|
1122
|
+
* @category Einzelne Befehle
|
|
1123
|
+
*/
|
|
1124
|
+
declare class SetReverseCommand extends AbstractCommand {
|
|
1125
|
+
private readonly on;
|
|
1126
|
+
readonly name = "SetReverse";
|
|
1127
|
+
constructor(on: boolean);
|
|
1128
|
+
protected encodeBody(): Uint8Array;
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
1132
|
+
* GS H n — HRI-Zeichenposition für Barcodes auswählen
|
|
1133
|
+
* @category Einzelne Befehle
|
|
1134
|
+
*/
|
|
1135
|
+
declare class SetHriPositionCommand extends AbstractCommand {
|
|
1136
|
+
private readonly position;
|
|
1137
|
+
readonly name = "SetHriPosition";
|
|
1138
|
+
constructor(position: HriPosition);
|
|
1139
|
+
protected validate(): void;
|
|
1140
|
+
protected encodeBody(): Uint8Array;
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
* GS L nL nH — Linken Rand setzen
|
|
1145
|
+
* @category Einzelne Befehle
|
|
1146
|
+
*/
|
|
1147
|
+
declare class SetLeftMarginCommand extends AbstractCommand {
|
|
1148
|
+
private readonly n;
|
|
1149
|
+
readonly name = "SetLeftMargin";
|
|
1150
|
+
constructor(n: number);
|
|
1151
|
+
protected validate(): void;
|
|
1152
|
+
protected encodeBody(): Uint8Array;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
/**
|
|
1156
|
+
* GS P x y — Horizontale und vertikale Bewegungseinheiten setzen
|
|
1157
|
+
* @category Einzelne Befehle
|
|
1158
|
+
*/
|
|
1159
|
+
declare class SetMotionUnitsCommand extends AbstractCommand {
|
|
1160
|
+
private readonly x;
|
|
1161
|
+
private readonly y;
|
|
1162
|
+
readonly name = "SetMotionUnits";
|
|
1163
|
+
constructor(x: number, y: number);
|
|
1164
|
+
protected validate(): void;
|
|
1165
|
+
protected encodeBody(): Uint8Array;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* GS V m [n] — Papier schneiden.
|
|
1170
|
+
* Form ①: m=0 (voll) oder m=1 (teil), kein n
|
|
1171
|
+
* Form ②: m=66, n=Vorschubpunkte (0–255)
|
|
1172
|
+
* @category Einzelne Befehle
|
|
1173
|
+
*/
|
|
1174
|
+
declare class CutCommand extends AbstractCommand {
|
|
1175
|
+
private readonly mode;
|
|
1176
|
+
private readonly feedDots?;
|
|
1177
|
+
readonly name = "Cut";
|
|
1178
|
+
constructor(mode: CutMode, feedDots?: number | undefined);
|
|
1179
|
+
protected validate(): void;
|
|
1180
|
+
protected encodeBody(): Uint8Array;
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* GS W nL nH — Druckbereichsbreite setzen
|
|
1185
|
+
* @category Einzelne Befehle
|
|
1186
|
+
*/
|
|
1187
|
+
declare class SetPrintingAreaWidthCommand extends AbstractCommand {
|
|
1188
|
+
private readonly n;
|
|
1189
|
+
readonly name = "SetPrintingAreaWidth";
|
|
1190
|
+
constructor(n: number);
|
|
1191
|
+
protected validate(): void;
|
|
1192
|
+
protected encodeBody(): Uint8Array;
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
/**
|
|
1196
|
+
* GS \ nL nH — Relative vertikale Druckposition im Page-Modus setzen
|
|
1197
|
+
* @category Einzelne Befehle
|
|
1198
|
+
*/
|
|
1199
|
+
declare class SetRelativeVerticalPositionCommand extends AbstractCommand {
|
|
1200
|
+
private readonly n;
|
|
1201
|
+
readonly name = "SetRelativeVerticalPosition";
|
|
1202
|
+
constructor(n: number);
|
|
1203
|
+
protected validate(): void;
|
|
1204
|
+
protected encodeBody(): Uint8Array;
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
/**
|
|
1208
|
+
* GS ^ r t m — Makro ausführen.
|
|
1209
|
+
* r=Wiederholungen (0–255), t=Wartezeit (0–255), m=Modus (0=kontinuierlich, 1=FEED-Taste)
|
|
1210
|
+
* @category Einzelne Befehle
|
|
1211
|
+
*/
|
|
1212
|
+
declare class ExecuteMacroCommand extends AbstractCommand {
|
|
1213
|
+
private readonly r;
|
|
1214
|
+
private readonly t;
|
|
1215
|
+
private readonly m;
|
|
1216
|
+
readonly name = "ExecuteMacro";
|
|
1217
|
+
constructor(r: number, t: number, m: number);
|
|
1218
|
+
protected validate(): void;
|
|
1219
|
+
protected encodeBody(): Uint8Array;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
/**
|
|
1223
|
+
* GS a n — Automatischen Status-Rückkanal (ASB) aktivieren/deaktivieren
|
|
1224
|
+
* @category Einzelne Befehle
|
|
1225
|
+
*/
|
|
1226
|
+
declare class EnableAsbCommand extends AbstractCommand {
|
|
1227
|
+
private readonly n;
|
|
1228
|
+
readonly name = "EnableAsb";
|
|
1229
|
+
constructor(n: number);
|
|
1230
|
+
protected validate(): void;
|
|
1231
|
+
protected encodeBody(): Uint8Array;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
/**
|
|
1235
|
+
* GS f n — Schriftart für HRI-Zeichen auswählen
|
|
1236
|
+
* @category Einzelne Befehle
|
|
1237
|
+
*/
|
|
1238
|
+
declare class SetHriFontCommand extends AbstractCommand {
|
|
1239
|
+
private readonly font;
|
|
1240
|
+
readonly name = "SetHriFont";
|
|
1241
|
+
constructor(font: HriFont);
|
|
1242
|
+
protected validate(): void;
|
|
1243
|
+
protected encodeBody(): Uint8Array;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
/**
|
|
1247
|
+
* GS h n — Barcode-Höhe setzen (1–255 Dots)
|
|
1248
|
+
* @category Einzelne Befehle
|
|
1249
|
+
*/
|
|
1250
|
+
declare class SetBarcodeHeightCommand extends AbstractCommand {
|
|
1251
|
+
private readonly n;
|
|
1252
|
+
readonly name = "SetBarcodeHeight";
|
|
1253
|
+
constructor(n: number);
|
|
1254
|
+
protected validate(): void;
|
|
1255
|
+
protected encodeBody(): Uint8Array;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
/**
|
|
1259
|
+
* Strategy-Interface für die Barcode-Datenkodierung.
|
|
1260
|
+
*
|
|
1261
|
+
* Implementierungen kapseln das systemspezifische Codierungsprotokoll
|
|
1262
|
+
* (NUL-Terminierung vs. Längenpräfix, Zeichenvalidierung, CODE128-Subsets).
|
|
1263
|
+
* @category Barcode-Strategien
|
|
1264
|
+
*/
|
|
1265
|
+
interface BarcodeEncodingStrategy {
|
|
1266
|
+
readonly system: BarcodeSystem;
|
|
1267
|
+
/**
|
|
1268
|
+
* Kodiert Barcode-Daten in ESC/POS-Bytes (ohne GS k m Präfix).
|
|
1269
|
+
* Wirft Error/RangeError wenn Daten ungültig sind.
|
|
1270
|
+
*/
|
|
1271
|
+
encode(data: Uint8Array | string): Uint8Array;
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* GS k m n d1...dn — Barcode drucken (Form ②, Längenpräfix).
|
|
1276
|
+
*
|
|
1277
|
+
* Verwendet das Strategy-Pattern für systemspezifische Daten-Kodierung.
|
|
1278
|
+
* Eigene Strategien können von außen injiziert werden (Erweiterbarkeit).
|
|
1279
|
+
* @category Einzelne Befehle
|
|
1280
|
+
*/
|
|
1281
|
+
declare class PrintBarcodeCommand extends AbstractCommand {
|
|
1282
|
+
private readonly system;
|
|
1283
|
+
private readonly data;
|
|
1284
|
+
readonly name = "PrintBarcode";
|
|
1285
|
+
private readonly strategy;
|
|
1286
|
+
constructor(system: BarcodeSystem, data: Uint8Array | string, strategy?: BarcodeEncodingStrategy);
|
|
1287
|
+
protected encodeBody(): Uint8Array;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
/**
|
|
1291
|
+
* GS r n — Status übertragen.
|
|
1292
|
+
* n=1/49: Papiersensor-Status, n=2/50: Schubladen-Status
|
|
1293
|
+
* @category Einzelne Befehle
|
|
1294
|
+
*/
|
|
1295
|
+
declare class TransmitStatusCommand extends AbstractCommand {
|
|
1296
|
+
private readonly n;
|
|
1297
|
+
readonly name = "TransmitStatus";
|
|
1298
|
+
constructor(n: number);
|
|
1299
|
+
protected validate(): void;
|
|
1300
|
+
protected encodeBody(): Uint8Array;
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
/**
|
|
1304
|
+
* GS v 0 m xL xH yL yH d1...dk — Raster-Bit-Bild drucken.
|
|
1305
|
+
* k = (xL + xH×256) × (yL + yH×256)
|
|
1306
|
+
* @category Einzelne Befehle
|
|
1307
|
+
*/
|
|
1308
|
+
declare class PrintRasterBitImageCommand extends AbstractCommand {
|
|
1309
|
+
private readonly mode;
|
|
1310
|
+
private readonly xL;
|
|
1311
|
+
private readonly xH;
|
|
1312
|
+
private readonly yL;
|
|
1313
|
+
private readonly yH;
|
|
1314
|
+
private readonly data;
|
|
1315
|
+
readonly name = "PrintRasterBitImage";
|
|
1316
|
+
constructor(mode: RasterMode, xL: number, xH: number, yL: number, yH: number, data: Uint8Array);
|
|
1317
|
+
protected validate(): void;
|
|
1318
|
+
protected encodeBody(): Uint8Array;
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
/**
|
|
1322
|
+
* GS w n — Barcode-Breite setzen (2–6)
|
|
1323
|
+
* @category Einzelne Befehle
|
|
1324
|
+
*/
|
|
1325
|
+
declare class SetBarcodeWidthCommand extends AbstractCommand {
|
|
1326
|
+
private readonly width;
|
|
1327
|
+
readonly name = "SetBarcodeWidth";
|
|
1328
|
+
constructor(width: BarcodeWidth);
|
|
1329
|
+
protected validate(): void;
|
|
1330
|
+
protected encodeBody(): Uint8Array;
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
/**
|
|
1334
|
+
* GS ( A pL pH n m — Hex-Dump Testdruck ausführen
|
|
1335
|
+
* @category Einzelne Befehle
|
|
1336
|
+
*/
|
|
1337
|
+
declare class HexDumpCommand extends AbstractCommand {
|
|
1338
|
+
readonly name = "HexDump";
|
|
1339
|
+
protected encodeBody(): Uint8Array;
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
/**
|
|
1343
|
+
* Optionen für PrintQrCodeCommand.
|
|
1344
|
+
* @category Einzelne Befehle
|
|
1345
|
+
*/
|
|
1346
|
+
interface QrCodeOptions {
|
|
1347
|
+
/** Modulgröße 1–16 (Pixel pro Modul). Standard: 3 */
|
|
1348
|
+
moduleSize?: number;
|
|
1349
|
+
/** Fehlerkorrektur-Level. Standard: M */
|
|
1350
|
+
errorCorrection?: QrCodeErrorCorrection;
|
|
1351
|
+
/** QR-Code-Modell 1 oder 2. Standard: 2 (empfohlen) */
|
|
1352
|
+
model?: 1 | 2;
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
* GS ( k — QR-Code drucken.
|
|
1356
|
+
*
|
|
1357
|
+
* Sendet die vollständige 5-Schritt-Sequenz:
|
|
1358
|
+
* 1. Modell setzen
|
|
1359
|
+
* 2. Modulgröße setzen
|
|
1360
|
+
* 3. Fehlerkorrektur setzen
|
|
1361
|
+
* 4. Daten speichern
|
|
1362
|
+
* 5. QR-Code drucken
|
|
1363
|
+
* @category Einzelne Befehle
|
|
1364
|
+
*/
|
|
1365
|
+
declare class PrintQrCodeCommand extends AbstractCommand {
|
|
1366
|
+
readonly name = "PrintQrCode";
|
|
1367
|
+
private readonly data;
|
|
1368
|
+
private readonly moduleSize;
|
|
1369
|
+
private readonly errorCorrection;
|
|
1370
|
+
private readonly model;
|
|
1371
|
+
constructor(data: string | Uint8Array, options?: QrCodeOptions);
|
|
1372
|
+
protected encodeBody(): Uint8Array;
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
/**
|
|
1376
|
+
* Factory-Pattern: Erzeugt Command-Objekte nach Intention.
|
|
1377
|
+
*
|
|
1378
|
+
* Kapselt die Konstruktordetails aller Command-Klassen und bietet
|
|
1379
|
+
* eine semantisch sprechende API. Erlaubt auch Registrierung eigener
|
|
1380
|
+
* Command-Typen von außen (Erweiterbarkeit).
|
|
1381
|
+
* @category Befehle
|
|
1382
|
+
*/
|
|
1383
|
+
|
|
1384
|
+
type CustomFactory = (options?: Record<string, unknown>) => Command;
|
|
1385
|
+
declare class CommandFactory {
|
|
1386
|
+
private static readonly customFactories;
|
|
1387
|
+
/** Registriert eine eigene Command-Fabrik unter einem Namen. */
|
|
1388
|
+
static register(name: string, factory: CustomFactory): void;
|
|
1389
|
+
/** Erzeugt einen registrierten Custom-Command. */
|
|
1390
|
+
static createCustom(name: string, options?: Record<string, unknown>): Command;
|
|
1391
|
+
static horizontalTab(): HorizontalTabCommand;
|
|
1392
|
+
static lineFeed(): LineFeedCommand;
|
|
1393
|
+
static formFeed(): FormFeedCommand;
|
|
1394
|
+
static carriageReturn(): CarriageReturnCommand;
|
|
1395
|
+
static cancelPageData(): CancelPageDataCommand;
|
|
1396
|
+
static transmitRealtimeStatus(n: 1 | 2 | 3 | 4): TransmitRealtimeStatusCommand;
|
|
1397
|
+
static realtimeRequest(n: 1 | 2): RealtimeRequestCommand;
|
|
1398
|
+
static generatePulseRealtime(pin: DrawerPin, t: number): GeneratePulseRealtimeCommand;
|
|
1399
|
+
static printPageMode(): PrintPageModeCommand;
|
|
1400
|
+
static setRightCharacterSpacing(n: number): SetRightCharacterSpacingCommand;
|
|
1401
|
+
static selectPrintModes(opts: PrintModesOptions): SelectPrintModesCommand;
|
|
1402
|
+
static setAbsolutePosition(n: number): SetAbsolutePositionCommand;
|
|
1403
|
+
static selectUserCharSet(enable: boolean): SelectUserCharSetCommand;
|
|
1404
|
+
static defineUserChars(y: number, c1: number, c2: number, data: Uint8Array): DefineUserCharsCommand;
|
|
1405
|
+
static selectBitImageMode(mode: BitImageMode, nL: number, nH: number, data: Uint8Array): SelectBitImageModeCommand;
|
|
1406
|
+
static setUnderline(mode: UnderlineMode): SetUnderlineCommand;
|
|
1407
|
+
static setDefaultLineSpacing(): SetDefaultLineSpacingCommand;
|
|
1408
|
+
static setLineSpacing(n: number): SetLineSpacingCommand;
|
|
1409
|
+
static setPeripheralDevice(n: number): SetPeripheralDeviceCommand;
|
|
1410
|
+
static cancelUserChar(n: number): CancelUserCharCommand;
|
|
1411
|
+
static initialize(): InitializeCommand;
|
|
1412
|
+
static setHorizontalTabPositions(positions: number[]): SetHorizontalTabPositionsCommand;
|
|
1413
|
+
static setEmphasized(on: boolean): SetEmphasizedCommand;
|
|
1414
|
+
static setDoubleStrike(on: boolean): SetDoubleStrikeCommand;
|
|
1415
|
+
static printAndFeedPaper(n: number): PrintAndFeedPaperCommand;
|
|
1416
|
+
static selectPageMode(): SelectPageModeCommand;
|
|
1417
|
+
static selectCharacterFont(font: Font): SelectCharacterFontCommand;
|
|
1418
|
+
static selectInternationalCharSet(cs: InternationalCharacterSet): SelectInternationalCharSetCommand;
|
|
1419
|
+
static selectStandardMode(): SelectStandardModeCommand;
|
|
1420
|
+
static selectPrintDirection(dir: PrintDirection): SelectPrintDirectionCommand;
|
|
1421
|
+
static setRotation(on: boolean): SetRotationCommand;
|
|
1422
|
+
static setPrintingAreaPageMode(xL: number, xH: number, yL: number, yH: number, dxL: number, dxH: number, dyL: number, dyH: number): SetPrintingAreaPageModeCommand;
|
|
1423
|
+
static setRelativePosition(n: number): SetRelativePositionCommand;
|
|
1424
|
+
static setJustification(align: Alignment): SetJustificationCommand;
|
|
1425
|
+
static selectPaperEndSensors(n: number): SelectPaperEndSensorsCommand;
|
|
1426
|
+
static selectPaperStopSensors(n: number): SelectPaperStopSensorsCommand;
|
|
1427
|
+
static enablePanelButtons(enable: boolean): EnablePanelButtonsCommand;
|
|
1428
|
+
static printAndFeedLines(n: number): PrintAndFeedLinesCommand;
|
|
1429
|
+
static generatePulse(pin: DrawerPin, t1: number, t2: number): GeneratePulseCommand;
|
|
1430
|
+
static selectCharacterCodeTable(table: CharacterCodeTable): SelectCharacterCodeTableCommand;
|
|
1431
|
+
static setUpsideDown(on: boolean): SetUpsideDownCommand;
|
|
1432
|
+
static beep(count: number, duration: number): BeepCommand;
|
|
1433
|
+
static beepAndFlash(count: number, interval: number, mode: number): BeepAndFlashCommand;
|
|
1434
|
+
static printNvBitImage(n: number, mode: RasterMode): PrintNvBitImageCommand;
|
|
1435
|
+
static defineNvBitImage(n: number, images: Array<{
|
|
1436
|
+
xL: number;
|
|
1437
|
+
xH: number;
|
|
1438
|
+
yL: number;
|
|
1439
|
+
yH: number;
|
|
1440
|
+
data: Uint8Array;
|
|
1441
|
+
}>): DefineNvBitImageCommand;
|
|
1442
|
+
static setKanjiPrintMode(n: number): SetKanjiPrintModeCommand;
|
|
1443
|
+
static selectKanjiMode(): SelectKanjiModeCommand;
|
|
1444
|
+
static setKanjiUnderline(mode: UnderlineMode): SetKanjiUnderlineCommand;
|
|
1445
|
+
static cancelKanjiMode(): CancelKanjiModeCommand;
|
|
1446
|
+
static defineKanji(c1: number, c2: number, data: Uint8Array): DefineKanjiCommand;
|
|
1447
|
+
static setKanjiSpacing(n1: number, n2: number): SetKanjiSpacingCommand;
|
|
1448
|
+
static setKanjiQuadruple(on: boolean): SetKanjiQuadrupleCommand;
|
|
1449
|
+
static selectCharacterSize(heightTimes: number, widthTimes: number): SelectCharacterSizeCommand;
|
|
1450
|
+
static setAbsoluteVerticalPosition(n: number): SetAbsoluteVerticalPositionCommand;
|
|
1451
|
+
static defineDownloadedBitImage(x: number, y: number, data: Uint8Array): DefineDownloadedBitImageCommand;
|
|
1452
|
+
static printDownloadedBitImage(mode: RasterMode): PrintDownloadedBitImageCommand;
|
|
1453
|
+
static macroStartEnd(): MacroStartEndCommand;
|
|
1454
|
+
static setReverse(on: boolean): SetReverseCommand;
|
|
1455
|
+
static setHriPosition(pos: HriPosition): SetHriPositionCommand;
|
|
1456
|
+
static setLeftMargin(n: number): SetLeftMarginCommand;
|
|
1457
|
+
static setMotionUnits(x: number, y: number): SetMotionUnitsCommand;
|
|
1458
|
+
static cut(mode: CutMode, feedDots?: number): CutCommand;
|
|
1459
|
+
static setPrintingAreaWidth(n: number): SetPrintingAreaWidthCommand;
|
|
1460
|
+
static setRelativeVerticalPosition(n: number): SetRelativeVerticalPositionCommand;
|
|
1461
|
+
static executeMacro(r: number, t: number, m: number): ExecuteMacroCommand;
|
|
1462
|
+
static enableAsb(n: number): EnableAsbCommand;
|
|
1463
|
+
static setHriFont(font: HriFont): SetHriFontCommand;
|
|
1464
|
+
static setBarcodeHeight(n: number): SetBarcodeHeightCommand;
|
|
1465
|
+
static printBarcode(system: BarcodeSystem, data: Uint8Array | string, strategy?: BarcodeEncodingStrategy): PrintBarcodeCommand;
|
|
1466
|
+
static transmitStatus(n: number): TransmitStatusCommand;
|
|
1467
|
+
static printRasterBitImage(mode: RasterMode, xL: number, xH: number, yL: number, yH: number, data: Uint8Array): PrintRasterBitImageCommand;
|
|
1468
|
+
static setBarcodeWidth(width: BarcodeWidth): SetBarcodeWidthCommand;
|
|
1469
|
+
static hexDump(): HexDumpCommand;
|
|
1470
|
+
static printQrCode(data: string | Uint8Array, options?: QrCodeOptions): PrintQrCodeCommand;
|
|
1471
|
+
static raw(bytes: Uint8Array | number[], name?: string): RawCommand;
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
/**
|
|
1475
|
+
* Strategie für CODE128 — Form ② (Längenpräfix).
|
|
1476
|
+
*
|
|
1477
|
+
* Subset-Auswahl via Steuerzeichen laut Handbuch:
|
|
1478
|
+
* {A = Code Set A, {B = Code Set B, {C = Code Set C
|
|
1479
|
+
* {1–{4 = FNC1–FNC4, {S = SHIFT, {{ = literal "{"
|
|
1480
|
+
*
|
|
1481
|
+
* Der Eingabestring wird so wie er ist übergeben (inkl. {-Escapes).
|
|
1482
|
+
* Validation: Muss mit einem Subset-Selektor starten ({A, {B oder {C).
|
|
1483
|
+
* @category Barcode-Strategien
|
|
1484
|
+
*/
|
|
1485
|
+
declare class Code128Strategy implements BarcodeEncodingStrategy {
|
|
1486
|
+
readonly system = BarcodeSystem.CODE128;
|
|
1487
|
+
encode(data: Uint8Array | string): Uint8Array;
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
/**
|
|
1491
|
+
* Strategie für CODE39 — Form ② (Längenpräfix)
|
|
1492
|
+
* @category Barcode-Strategien
|
|
1493
|
+
*/
|
|
1494
|
+
declare class Code39Strategy implements BarcodeEncodingStrategy {
|
|
1495
|
+
readonly system = BarcodeSystem.CODE39;
|
|
1496
|
+
encode(data: Uint8Array | string): Uint8Array;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
/**
|
|
1500
|
+
* Strategie für ITF (Interleaved 2 of 5) — muss gerade Anzahl Ziffern haben
|
|
1501
|
+
* @category Barcode-Strategien
|
|
1502
|
+
*/
|
|
1503
|
+
declare class ItfStrategy implements BarcodeEncodingStrategy {
|
|
1504
|
+
readonly system = BarcodeSystem.ITF;
|
|
1505
|
+
encode(data: Uint8Array | string): Uint8Array;
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
/**
|
|
1509
|
+
* Strategie für CODABAR — Form ② (Längenpräfix)
|
|
1510
|
+
* @category Barcode-Strategien
|
|
1511
|
+
*/
|
|
1512
|
+
declare class CodabarStrategy implements BarcodeEncodingStrategy {
|
|
1513
|
+
readonly system = BarcodeSystem.CODABAR;
|
|
1514
|
+
encode(data: Uint8Array | string): Uint8Array;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
/**
|
|
1518
|
+
* Strategie für numerische Barcodes (UPC-A, UPC-E, EAN13, EAN8, ITF).
|
|
1519
|
+
* Verwendet Form ② (Längenpräfix).
|
|
1520
|
+
* @category Barcode-Strategien
|
|
1521
|
+
*/
|
|
1522
|
+
declare class SimpleNumericBarcodeStrategy implements BarcodeEncodingStrategy {
|
|
1523
|
+
readonly system: BarcodeSystem;
|
|
1524
|
+
private readonly minLen;
|
|
1525
|
+
private readonly maxLen;
|
|
1526
|
+
constructor(system: BarcodeSystem, minLen: number, maxLen: number);
|
|
1527
|
+
encode(data: Uint8Array | string): Uint8Array;
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
/**
|
|
1531
|
+
* Aktueller Formatierungszustand des ReceiptBuilders.
|
|
1532
|
+
* Wird als Memento gespeichert und wiederhergestellt.
|
|
1533
|
+
* @category Builder
|
|
1534
|
+
*/
|
|
1535
|
+
declare class PrintState {
|
|
1536
|
+
alignment: Alignment;
|
|
1537
|
+
font: Font;
|
|
1538
|
+
emphasized: boolean;
|
|
1539
|
+
doubleStrike: boolean;
|
|
1540
|
+
doubleHeight: boolean;
|
|
1541
|
+
doubleWidth: boolean;
|
|
1542
|
+
underline: UnderlineMode;
|
|
1543
|
+
rotation: boolean;
|
|
1544
|
+
upsideDown: boolean;
|
|
1545
|
+
reverse: boolean;
|
|
1546
|
+
codeTable: CharacterCodeTable;
|
|
1547
|
+
rightSpacing: number;
|
|
1548
|
+
lineSpacing: number | null;
|
|
1549
|
+
constructor(alignment?: Alignment, font?: Font, emphasized?: boolean, doubleStrike?: boolean, doubleHeight?: boolean, doubleWidth?: boolean, underline?: UnderlineMode, rotation?: boolean, upsideDown?: boolean, reverse?: boolean, codeTable?: CharacterCodeTable, rightSpacing?: number, lineSpacing?: number | null);
|
|
1550
|
+
/** Erstellt eine unabhängige Kopie des Zustands. */
|
|
1551
|
+
clone(): PrintState;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
/**
|
|
1555
|
+
* Builder-Pattern: Fluenter, zustandsbehafteter Bon-Aufbau.
|
|
1556
|
+
*
|
|
1557
|
+
* Baut intern eine CommandSequence auf. Jede Methode gibt `this` zurück
|
|
1558
|
+
* (Fluent Interface). Zustand kann via save()/restore() (Memento) gespeichert
|
|
1559
|
+
* und wiederhergestellt werden. Eigene Commands können via add() eingebettet
|
|
1560
|
+
* werden (Erweiterbarkeit).
|
|
1561
|
+
*
|
|
1562
|
+
* Auch ableitbar: Unterklassen können eigene, domänenspezifische Methoden
|
|
1563
|
+
* hinzufügen (z.B. `receipt.cashierLine(name)`).
|
|
1564
|
+
* @category Builder
|
|
1565
|
+
*/
|
|
1566
|
+
|
|
1567
|
+
declare class ReceiptBuilder {
|
|
1568
|
+
protected readonly sequence: CommandSequence;
|
|
1569
|
+
protected state: PrintState;
|
|
1570
|
+
private readonly mementoStack;
|
|
1571
|
+
/** Speichert den aktuellen Formatierungszustand auf dem Stack. */
|
|
1572
|
+
save(): this;
|
|
1573
|
+
/** Stellt den zuletzt gespeicherten Zustand wieder her und sendet die nötigen Befehle. */
|
|
1574
|
+
restore(): this;
|
|
1575
|
+
private _syncState;
|
|
1576
|
+
/** Fügt ein beliebiges Command hinzu (Erweiterungspunkt). */
|
|
1577
|
+
add(cmd: Command): this;
|
|
1578
|
+
/**
|
|
1579
|
+
* Wendet eine wiederverwendbare Funktion auf den Builder an.
|
|
1580
|
+
* Ermöglicht komposierbare, parametrisierbare Bon-Bausteine.
|
|
1581
|
+
*
|
|
1582
|
+
* @example builder.use(centerBold("KOPFZEILE"))
|
|
1583
|
+
*/
|
|
1584
|
+
use(fn: (builder: this) => void): this;
|
|
1585
|
+
initialize(): this;
|
|
1586
|
+
align(a: Alignment): this;
|
|
1587
|
+
left(): this;
|
|
1588
|
+
center(): this;
|
|
1589
|
+
right(): this;
|
|
1590
|
+
font(f: Font): this;
|
|
1591
|
+
bold(on?: boolean): this;
|
|
1592
|
+
doubleStrike(on?: boolean): this;
|
|
1593
|
+
underline(mode?: UnderlineMode): this;
|
|
1594
|
+
doubleHeight(on?: boolean): this;
|
|
1595
|
+
doubleWidth(on?: boolean): this;
|
|
1596
|
+
rotate(on?: boolean): this;
|
|
1597
|
+
upsideDown(on?: boolean): this;
|
|
1598
|
+
reverse(on?: boolean): this;
|
|
1599
|
+
codeTable(table: CharacterCodeTable): this;
|
|
1600
|
+
rightSpacing(n: number): this;
|
|
1601
|
+
lineSpacing(n: number): this;
|
|
1602
|
+
defaultLineSpacing(): this;
|
|
1603
|
+
/** Fügt Text direkt als Bytes ein. */
|
|
1604
|
+
text(str: string): this;
|
|
1605
|
+
/** Text mit anschließendem Zeilenvorschub. */
|
|
1606
|
+
textLine(str: string): this;
|
|
1607
|
+
/** Zeilenvorschub (LF). */
|
|
1608
|
+
feed(): this;
|
|
1609
|
+
/** Mehrere Zeilen vorschub. */
|
|
1610
|
+
feedLines(n: number): this;
|
|
1611
|
+
/** Papiervorsschub in Dots. */
|
|
1612
|
+
feedDots(n: number): this;
|
|
1613
|
+
/** Trennlinie aus dem Zeichen `char` (Standard: `-`), `cols` Mal. */
|
|
1614
|
+
divider(char?: string, cols?: number): this;
|
|
1615
|
+
absolutePosition(n: number): this;
|
|
1616
|
+
relativePosition(n: number): this;
|
|
1617
|
+
leftMargin(n: number): this;
|
|
1618
|
+
hriPosition(pos: HriPosition): this;
|
|
1619
|
+
hriFont(font: HriFont): this;
|
|
1620
|
+
barcodeHeight(n: number): this;
|
|
1621
|
+
barcode(system: BarcodeSystem, data: string | Uint8Array, strategy?: BarcodeEncodingStrategy): this;
|
|
1622
|
+
qrCode(data: string | Uint8Array, options?: QrCodeOptions): this;
|
|
1623
|
+
cut(mode?: CutMode, feedDots?: number): this;
|
|
1624
|
+
openDrawer(pin?: DrawerPin, t1?: number, t2?: number): this;
|
|
1625
|
+
rasterImage(mode: RasterMode, xL: number, xH: number, yL: number, yH: number, data: Uint8Array): this;
|
|
1626
|
+
beep(count?: number, duration?: number): this;
|
|
1627
|
+
/** Gibt die aufgebaute CommandSequence zurück. */
|
|
1628
|
+
build(): CommandSequence;
|
|
1629
|
+
/** Kodiert alles zu einem einzelnen Uint8Array. */
|
|
1630
|
+
encode(): Uint8Array;
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
/**
|
|
1634
|
+
* Strategy-Interface für Dithering-Algorithmen.
|
|
1635
|
+
*
|
|
1636
|
+
* Erhält ein Grauwert-Array (0=schwarz, 255=weiß) und liefert
|
|
1637
|
+
* ein Schwellwert-Array (true=Dot drucken, false=leer).
|
|
1638
|
+
* @category Bilder & Dithering
|
|
1639
|
+
*/
|
|
1640
|
+
interface DitherStrategy {
|
|
1641
|
+
readonly name: string;
|
|
1642
|
+
/**
|
|
1643
|
+
* Wendet das Dithering an.
|
|
1644
|
+
* @param gray Grauwert-Pixel-Array, row-major, Werte 0–255
|
|
1645
|
+
* @param width Breite in Pixeln
|
|
1646
|
+
* @param height Höhe in Pixeln
|
|
1647
|
+
* @returns Boolean-Array mit gleichem Layout (true = Punkt drucken)
|
|
1648
|
+
*/
|
|
1649
|
+
dither(gray: Uint8Array, width: number, height: number): Uint8Array;
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
/**
|
|
1653
|
+
* Spezialisierter Builder für strukturierte Kassenbons / Rechnungen.
|
|
1654
|
+
*
|
|
1655
|
+
* Erweitert ReceiptBuilder um fertige Blöcke:
|
|
1656
|
+
* - Logo (async, Bilddatei → Rasterdruck)
|
|
1657
|
+
* - Adressblock (Firma, Straße, PLZ Ort, Zusatzzeile)
|
|
1658
|
+
* - Artikel-Tabelle mit Menge und Sub-Zeilen (Rabatte, Notizen)
|
|
1659
|
+
* - Summenzeilen (Gesamt, MwSt, …)
|
|
1660
|
+
* - QR-Code (geerbt)
|
|
1661
|
+
* - Fußzeile
|
|
1662
|
+
*
|
|
1663
|
+
* Mengen-Anzeige (quantityDisplay):
|
|
1664
|
+
* "inline" → Menge wird in den Artikelnamen eingebettet: "2x Schnitzel"
|
|
1665
|
+
* "separate" → Menge erscheint als eigene Zeile darunter: " 2x à 12.50 EUR"
|
|
1666
|
+
*
|
|
1667
|
+
* @example
|
|
1668
|
+
* const b = new InvoiceBuilder({ quantityDisplay: "separate" });
|
|
1669
|
+
* await b.logo("./logo.png");
|
|
1670
|
+
* b.address({ company: "Muster GmbH", street: "Hauptstr. 1",
|
|
1671
|
+
* postalCity: "1010 Wien", extra: "UID: ATU12345678" })
|
|
1672
|
+
* .separator()
|
|
1673
|
+
* .itemsHeader()
|
|
1674
|
+
* .separator()
|
|
1675
|
+
* .item(1, "Schnitzel", "25.00 EUR", {
|
|
1676
|
+
* qty: 2, unitPrice: "12.50 EUR",
|
|
1677
|
+
* subLines: [{ label: "- Treuerabatt 10%", value: "-2.50 EUR" }],
|
|
1678
|
+
* })
|
|
1679
|
+
* .item(2, "Cola", "2.80 EUR")
|
|
1680
|
+
* .separator()
|
|
1681
|
+
* .total("GESAMT:", "27.80 EUR")
|
|
1682
|
+
* .taxLine("MwSt 20%:", " 4.63 EUR")
|
|
1683
|
+
* .qrCode("https://example.at/bon/42")
|
|
1684
|
+
* .footer(["Danke fuer Ihren Besuch!", "www.example.at"])
|
|
1685
|
+
* .cut();
|
|
1686
|
+
* await printer.print(b);
|
|
1687
|
+
* @category Builder
|
|
1688
|
+
*/
|
|
1689
|
+
|
|
1690
|
+
/**
|
|
1691
|
+
* Wo die Mengenzahl angezeigt wird.
|
|
1692
|
+
* @category Builder
|
|
1693
|
+
*/
|
|
1694
|
+
type QuantityDisplay = "inline" | "separate";
|
|
1695
|
+
/**
|
|
1696
|
+
* Optionen für den InvoiceBuilder.
|
|
1697
|
+
* @category Builder
|
|
1698
|
+
*/
|
|
1699
|
+
interface InvoiceBuilderOptions {
|
|
1700
|
+
/** Druckbreite in Dots. Standard: 576 (80 mm / 203 dpi) */
|
|
1701
|
+
printWidthDots?: number;
|
|
1702
|
+
/**
|
|
1703
|
+
* Zeichen pro Zeile (Font A).
|
|
1704
|
+
* Standard: 48 (80 mm-Papier). Für 58 mm-Papier: 32.
|
|
1705
|
+
*/
|
|
1706
|
+
charsPerLine?: number;
|
|
1707
|
+
/**
|
|
1708
|
+
* Standard-Anzeige für Mengen.
|
|
1709
|
+
* "inline" → "2x Schnitzel" in derselben Zeile (Standard)
|
|
1710
|
+
* "separate" → eigene Zeile darunter: " 2x à 12.50 EUR"
|
|
1711
|
+
*/
|
|
1712
|
+
quantityDisplay?: QuantityDisplay;
|
|
1713
|
+
}
|
|
1714
|
+
/**
|
|
1715
|
+
* Adressblock für den InvoiceBuilder.
|
|
1716
|
+
* @category Builder
|
|
1717
|
+
*/
|
|
1718
|
+
interface InvoiceAddress {
|
|
1719
|
+
/** Firmenname — wird fett gedruckt */
|
|
1720
|
+
company: string;
|
|
1721
|
+
/** Straße + Hausnummer */
|
|
1722
|
+
street: string;
|
|
1723
|
+
/** PLZ und Ort, z. B. "1010 Wien" */
|
|
1724
|
+
postalCity: string;
|
|
1725
|
+
/** Optionale 4. Zeile, z. B. UID-Nummer oder Telefon */
|
|
1726
|
+
extra?: string;
|
|
1727
|
+
}
|
|
1728
|
+
/**
|
|
1729
|
+
* Eine Subzeile unterhalb eines Artikels (Rabatt, Notiz, …).
|
|
1730
|
+
* @category Builder
|
|
1731
|
+
*/
|
|
1732
|
+
interface SubLine {
|
|
1733
|
+
/** Beschriftung, z. B. "- Treuerabatt 10%" oder "Anmerkung: ohne Sauce" */
|
|
1734
|
+
label: string;
|
|
1735
|
+
/** Optionaler rechtsbündiger Wert, z. B. "-1.25 EUR" */
|
|
1736
|
+
value?: string;
|
|
1737
|
+
}
|
|
1738
|
+
/**
|
|
1739
|
+
* Optionen für eine Artikelzeile im InvoiceBuilder.
|
|
1740
|
+
* @category Builder
|
|
1741
|
+
*/
|
|
1742
|
+
interface ItemOptions {
|
|
1743
|
+
/** Anzahl der gekauften Einheiten. Standard: 1 (keine Mengenanzeige). */
|
|
1744
|
+
qty?: number;
|
|
1745
|
+
/**
|
|
1746
|
+
* Einzelpreis pro Stück für den "separate"-Modus, z. B. "12.50 EUR".
|
|
1747
|
+
* Wird nur bei quantityDisplay === "separate" und qty > 1 angezeigt.
|
|
1748
|
+
*/
|
|
1749
|
+
unitPrice?: string;
|
|
1750
|
+
/**
|
|
1751
|
+
* Überschreibt den globalen quantityDisplay für diesen Artikel.
|
|
1752
|
+
* Wenn nicht gesetzt, gilt die Option aus InvoiceBuilderOptions.
|
|
1753
|
+
*/
|
|
1754
|
+
qtyDisplay?: QuantityDisplay;
|
|
1755
|
+
/** Subzeilen (Rabatte, Notizen) die eingerückt unter dem Artikel erscheinen. */
|
|
1756
|
+
subLines?: SubLine[];
|
|
1757
|
+
}
|
|
1758
|
+
declare class InvoiceBuilder extends ReceiptBuilder {
|
|
1759
|
+
readonly cols: number;
|
|
1760
|
+
private readonly printWidthDots;
|
|
1761
|
+
private readonly defaultQtyDisplay;
|
|
1762
|
+
/** Einrückung für Subzeilen und "separate"-Mengenzeilen (entspricht der Namens-Spalte). */
|
|
1763
|
+
private readonly subIndent;
|
|
1764
|
+
constructor(options?: InvoiceBuilderOptions);
|
|
1765
|
+
/**
|
|
1766
|
+
* Lädt eine Bilddatei, kodiert sie als ESC/POS-Rasterbild und druckt sie
|
|
1767
|
+
* zentriert. Muss mit await aufgerufen werden.
|
|
1768
|
+
*/
|
|
1769
|
+
logo(filePath: string, dither?: DitherStrategy): Promise<this>;
|
|
1770
|
+
/**
|
|
1771
|
+
* Druckt einen 3–4-zeiligen Adressblock zentriert.
|
|
1772
|
+
* Zeile 1: Firmenname (fett)
|
|
1773
|
+
* Zeile 2: Straße
|
|
1774
|
+
* Zeile 3: PLZ Ort
|
|
1775
|
+
* Zeile 4: extra (optional)
|
|
1776
|
+
*/
|
|
1777
|
+
address(addr: InvoiceAddress): this;
|
|
1778
|
+
/** Trennlinie über die volle Bon-Breite. */
|
|
1779
|
+
separator(char?: string): this;
|
|
1780
|
+
/** Spalten-Kopfzeile: Nr Artikel Preis */
|
|
1781
|
+
itemsHeader(): this;
|
|
1782
|
+
/**
|
|
1783
|
+
* Eine Artikel-Zeile mit optionaler Menge und Subzeilen.
|
|
1784
|
+
*
|
|
1785
|
+
* Inline-Modus (Standard / qtyDisplay: "inline"):
|
|
1786
|
+
* " 1 2x Schnitzel 25.00 EUR"
|
|
1787
|
+
*
|
|
1788
|
+
* Separate-Modus (qtyDisplay: "separate"):
|
|
1789
|
+
* " 1 Schnitzel 25.00 EUR"
|
|
1790
|
+
* " 2x à 12.50 EUR"
|
|
1791
|
+
*
|
|
1792
|
+
* Subzeilen (immer eingerückt):
|
|
1793
|
+
* " - Treuerabatt 10% -2.50 EUR"
|
|
1794
|
+
* " Anmerkung: ohne Sauce"
|
|
1795
|
+
*/
|
|
1796
|
+
item(pos: number | string, name: string, price: string, opts?: ItemOptions): this;
|
|
1797
|
+
/** Gesamtbetrag — fett gedruckt. */
|
|
1798
|
+
total(label: string, value: string): this;
|
|
1799
|
+
/** Steuerzusatzzeile, Rabattzeile o. Ä. — normal gedruckt. */
|
|
1800
|
+
taxLine(label: string, value: string): this;
|
|
1801
|
+
/**
|
|
1802
|
+
* Druckt eine Fußzeile mit optionaler Trennlinie davor.
|
|
1803
|
+
* Alle Zeilen werden zentriert ausgegeben.
|
|
1804
|
+
*/
|
|
1805
|
+
footer(lines: string[], { withSeparator }?: {
|
|
1806
|
+
withSeparator?: boolean;
|
|
1807
|
+
}): this;
|
|
1808
|
+
/** Hauptzeile: "Nr Name...........Preis" */
|
|
1809
|
+
private _mainRow;
|
|
1810
|
+
/** Subzeile: eingerückt, mit optionalem rechtsbündigen Wert. */
|
|
1811
|
+
private _subRow;
|
|
1812
|
+
/** Zweispaltige Zeile ohne Positions-Nummer (Summen, Steuer). */
|
|
1813
|
+
private _twoCol;
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
/**
|
|
1817
|
+
* Memento-Pattern: Speichert eine unveränderliche Momentaufnahme
|
|
1818
|
+
* des PrintState für spätere Wiederherstellung.
|
|
1819
|
+
* @category Builder
|
|
1820
|
+
*/
|
|
1821
|
+
declare class StateMemento {
|
|
1822
|
+
private readonly snapshot;
|
|
1823
|
+
constructor(state: PrintState);
|
|
1824
|
+
/** Gibt die gespeicherte Zustandskopie zurück. */
|
|
1825
|
+
getSnapshot(): PrintState;
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
/**
|
|
1829
|
+
* Observer-Pattern: PrinterObserver-Interface und Event-Typen.
|
|
1830
|
+
*
|
|
1831
|
+
* Implementierungen registrieren sich am Printer (Subject) und erhalten
|
|
1832
|
+
* typisierte Events über Zustands- und Datentransfer-Ereignisse.
|
|
1833
|
+
* @category Drucker
|
|
1834
|
+
*/
|
|
1835
|
+
type PrinterEventType = "written" | "opened" | "closed" | "error" | "statusChanged" | "paperOut" | "coverOpen";
|
|
1836
|
+
/**
|
|
1837
|
+
* Basis-Event des Druckers.
|
|
1838
|
+
* @category Drucker
|
|
1839
|
+
*/
|
|
1840
|
+
interface PrinterEvent {
|
|
1841
|
+
type: PrinterEventType;
|
|
1842
|
+
timestamp: Date;
|
|
1843
|
+
data?: unknown;
|
|
1844
|
+
}
|
|
1845
|
+
/**
|
|
1846
|
+
* Observer-Interface für Printer-Events.
|
|
1847
|
+
* @category Drucker
|
|
1848
|
+
*/
|
|
1849
|
+
interface PrinterObserver {
|
|
1850
|
+
/** Wird bei jedem Printer-Event aufgerufen. */
|
|
1851
|
+
onEvent(event: PrinterEvent): void;
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
/**
|
|
1855
|
+
* Wiederverwendbare Observer-Basis (Subject-Rolle).
|
|
1856
|
+
* Wird von Printer und AbstractConnection geerbt.
|
|
1857
|
+
* @category Drucker
|
|
1858
|
+
*/
|
|
1859
|
+
declare class Subject {
|
|
1860
|
+
private readonly observers;
|
|
1861
|
+
/** Registriert einen Observer. Gibt eine Abmelde-Funktion zurück. */
|
|
1862
|
+
subscribe(observer: PrinterObserver): () => void;
|
|
1863
|
+
/** Entfernt einen Observer. */
|
|
1864
|
+
unsubscribe(observer: PrinterObserver): void;
|
|
1865
|
+
/** Benachrichtigt alle Observer. */
|
|
1866
|
+
protected notify(event: PrinterEvent): void;
|
|
1867
|
+
protected makeEvent(type: PrinterEventType, data?: unknown): PrinterEvent;
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
/**
|
|
1871
|
+
* Connection-Interface (Adapter-Pattern).
|
|
1872
|
+
*
|
|
1873
|
+
* Alle Transport-Implementierungen (TCP, USB, Serial, In-Memory, ...)
|
|
1874
|
+
* erfüllen dieses Interface. Konsumenten können eigene Verbindungen
|
|
1875
|
+
* implementieren und im Printer verwenden (Erweiterbarkeit).
|
|
1876
|
+
* @category Verbindung
|
|
1877
|
+
*/
|
|
1878
|
+
interface Connection {
|
|
1879
|
+
/** Verbindung aufbauen. */
|
|
1880
|
+
open(): Promise<void>;
|
|
1881
|
+
/** Bytes an den Drucker senden. */
|
|
1882
|
+
write(data: Uint8Array): Promise<void>;
|
|
1883
|
+
/**
|
|
1884
|
+
* Optionales Lesen (für Status-Antworten des Druckers).
|
|
1885
|
+
* Nicht alle Transporte unterstützen bidirektionale Kommunikation.
|
|
1886
|
+
*/
|
|
1887
|
+
read?(timeout?: number): Promise<Uint8Array>;
|
|
1888
|
+
/** Verbindung schließen. */
|
|
1889
|
+
close(): Promise<void>;
|
|
1890
|
+
/** Gibt an, ob die Verbindung aktuell geöffnet ist. */
|
|
1891
|
+
readonly isOpen: boolean;
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
/**
|
|
1895
|
+
* Facade + Invoker.
|
|
1896
|
+
*
|
|
1897
|
+
* Kapselt ReceiptBuilder + CommandFactory + Connection + ImageEncoder
|
|
1898
|
+
* hinter einer einfachen API. Ist gleichzeitig Subject (Observer-Pattern):
|
|
1899
|
+
* registrierte Observer erhalten Events über geschriebene Bytes, Fehler etc.
|
|
1900
|
+
* @category Drucker
|
|
1901
|
+
*/
|
|
1902
|
+
|
|
1903
|
+
declare class Printer extends Subject {
|
|
1904
|
+
private readonly connection;
|
|
1905
|
+
constructor(connection: Connection);
|
|
1906
|
+
/** Erstellt einen neuen ReceiptBuilder (Builder-Einstiegspunkt). */
|
|
1907
|
+
createBuilder(): ReceiptBuilder;
|
|
1908
|
+
/**
|
|
1909
|
+
* Sendet eine bereits kodierte Byte-Folge an die Connection.
|
|
1910
|
+
* Feuert 'written'- bzw. 'error'-Events an Observer.
|
|
1911
|
+
*/
|
|
1912
|
+
write(bytes: Uint8Array): Promise<void>;
|
|
1913
|
+
/** Kodiert einen Command und sendet ihn. */
|
|
1914
|
+
send(cmd: Command): Promise<void>;
|
|
1915
|
+
/**
|
|
1916
|
+
* Sendet einen kompletten ReceiptBuilder-Inhalt an den Drucker.
|
|
1917
|
+
* Kurzform: printer.print(builder)
|
|
1918
|
+
*/
|
|
1919
|
+
print(builder: ReceiptBuilder | CommandSequence): Promise<void>;
|
|
1920
|
+
/** Öffnet die Connection und feuert 'opened'. */
|
|
1921
|
+
open(): Promise<void>;
|
|
1922
|
+
/** Schließt die Connection und feuert 'closed'. */
|
|
1923
|
+
close(): Promise<void>;
|
|
1924
|
+
initialize(): Promise<void>;
|
|
1925
|
+
cut(feedDots?: number): Promise<void>;
|
|
1926
|
+
openDrawer(pin?: number, t1?: number, t2?: number): Promise<void>;
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
/**
|
|
1930
|
+
* DLE EOT n=1 — Druckerstatus.
|
|
1931
|
+
* Bit-Tabelle gemäß Handbuch.
|
|
1932
|
+
* @category Status
|
|
1933
|
+
*/
|
|
1934
|
+
declare class PrinterStatus {
|
|
1935
|
+
private readonly byte;
|
|
1936
|
+
constructor(byte: number);
|
|
1937
|
+
get rawByte(): number;
|
|
1938
|
+
/** Bit 2: 0=Kassenschublade offen, 1=geschlossen */
|
|
1939
|
+
get isCashDrawerClosed(): boolean;
|
|
1940
|
+
/** Bit 3: 1=Offline */
|
|
1941
|
+
get isOffline(): boolean;
|
|
1942
|
+
get isOnline(): boolean;
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
/**
|
|
1946
|
+
* DLE EOT n=2 — Offline-Status.
|
|
1947
|
+
* @category Status
|
|
1948
|
+
*/
|
|
1949
|
+
declare class OfflineStatus {
|
|
1950
|
+
private readonly byte;
|
|
1951
|
+
constructor(byte: number);
|
|
1952
|
+
get rawByte(): number;
|
|
1953
|
+
/** Bit 2: Deckel offen */
|
|
1954
|
+
get isCoverOpen(): boolean;
|
|
1955
|
+
/** Bit 3: Papier wird über FEED-Taste vorgeschoben */
|
|
1956
|
+
get isPaperBeingFed(): boolean;
|
|
1957
|
+
/** Bit 5: Druck wird wegen Papierende gestoppt */
|
|
1958
|
+
get isPaperEndStop(): boolean;
|
|
1959
|
+
/** Bit 6: Fehler aufgetreten */
|
|
1960
|
+
get hasError(): boolean;
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1963
|
+
/**
|
|
1964
|
+
* DLE EOT n=3 — Fehlerstatus.
|
|
1965
|
+
* @category Status
|
|
1966
|
+
*/
|
|
1967
|
+
declare class ErrorStatus {
|
|
1968
|
+
private readonly byte;
|
|
1969
|
+
constructor(byte: number);
|
|
1970
|
+
get rawByte(): number;
|
|
1971
|
+
/** Bit 3: Auto-Schnitt-Fehler */
|
|
1972
|
+
get hasAutoCutterError(): boolean;
|
|
1973
|
+
/** Bit 5: Nicht behebbarer Fehler */
|
|
1974
|
+
get hasUnrecoverableError(): boolean;
|
|
1975
|
+
/** Bit 6: Automatisch behebbarer Fehler */
|
|
1976
|
+
get hasAutoRecoverableError(): boolean;
|
|
1977
|
+
get hasAnyError(): boolean;
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
/**
|
|
1981
|
+
* DLE EOT n=4 / GS r n=1,49 — Papiersensor-Status.
|
|
1982
|
+
* @category Status
|
|
1983
|
+
*/
|
|
1984
|
+
declare class PaperSensorStatus {
|
|
1985
|
+
private readonly byte;
|
|
1986
|
+
constructor(byte: number);
|
|
1987
|
+
get rawByte(): number;
|
|
1988
|
+
/** Bits 2,3: Papier fast aufgebraucht (Near-End) */
|
|
1989
|
+
get isPaperNearEnd(): boolean;
|
|
1990
|
+
/** Bits 5,6 (DLE EOT n=4): Papier leer */
|
|
1991
|
+
get isPaperEnd(): boolean;
|
|
1992
|
+
/** Bits 0,1 (GS r): Papier Near-End */
|
|
1993
|
+
get isNearEndGsr(): boolean;
|
|
1994
|
+
/** Bits 2,3 (GS r): Papier leer */
|
|
1995
|
+
get isPaperEndGsr(): boolean;
|
|
1996
|
+
get isPaperPresent(): boolean;
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
/**
|
|
2000
|
+
* GS r n=2,50 — Schubladen-Status.
|
|
2001
|
+
* @category Status
|
|
2002
|
+
*/
|
|
2003
|
+
declare class DrawerStatus {
|
|
2004
|
+
private readonly byte;
|
|
2005
|
+
constructor(byte: number);
|
|
2006
|
+
get rawByte(): number;
|
|
2007
|
+
/** Bit 0: 0=Schublade offen, 1=Schublade geschlossen */
|
|
2008
|
+
get isDrawerClosed(): boolean;
|
|
2009
|
+
get isDrawerOpen(): boolean;
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
/**
|
|
2013
|
+
* Factory Method Pattern: Dekodiert ein Roh-Byte in das passende Status-Objekt.
|
|
2014
|
+
* @category Status
|
|
2015
|
+
*/
|
|
2016
|
+
|
|
2017
|
+
/**
|
|
2018
|
+
* Status-Typen entsprechend DLE EOT n=1..4
|
|
2019
|
+
* @category Status
|
|
2020
|
+
*/
|
|
2021
|
+
type StatusType = "printer" | "offline" | "error" | "paper" | "drawer";
|
|
2022
|
+
/**
|
|
2023
|
+
* Union-Typ aller Status-Objekte.
|
|
2024
|
+
* @category Status
|
|
2025
|
+
*/
|
|
2026
|
+
type AnyStatus = PrinterStatus | OfflineStatus | ErrorStatus | PaperSensorStatus | DrawerStatus;
|
|
2027
|
+
declare class StatusDecoder {
|
|
2028
|
+
/** Dekodiert DLE EOT n=1 → PrinterStatus */
|
|
2029
|
+
static decodePrinterStatus(byte: number): PrinterStatus;
|
|
2030
|
+
/** Dekodiert DLE EOT n=2 → OfflineStatus */
|
|
2031
|
+
static decodeOfflineStatus(byte: number): OfflineStatus;
|
|
2032
|
+
/** Dekodiert DLE EOT n=3 → ErrorStatus */
|
|
2033
|
+
static decodeErrorStatus(byte: number): ErrorStatus;
|
|
2034
|
+
/** Dekodiert DLE EOT n=4 → PaperSensorStatus */
|
|
2035
|
+
static decodePaperSensorStatus(byte: number): PaperSensorStatus;
|
|
2036
|
+
/** Dekodiert GS r n=2,50 → DrawerStatus */
|
|
2037
|
+
static decodeDrawerStatus(byte: number): DrawerStatus;
|
|
2038
|
+
/**
|
|
2039
|
+
* Factory Method: Erstellt den passenden Status-Typ anhand des Typ-Bezeichners.
|
|
2040
|
+
* Entspricht DLE EOT n-Parametern.
|
|
2041
|
+
*/
|
|
2042
|
+
static decode(type: StatusType, byte: number): AnyStatus;
|
|
2043
|
+
/**
|
|
2044
|
+
* Konvertiert DLE EOT n (1–4) zum StatusType.
|
|
2045
|
+
*/
|
|
2046
|
+
static typeFromN(n: 1 | 2 | 3 | 4): StatusType;
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
/**
|
|
2050
|
+
* Template Method + Subject (Observer) für Transport-Adapter.
|
|
2051
|
+
*
|
|
2052
|
+
* Definiert den Ablauf von open/write/close; Unterklassen implementieren
|
|
2053
|
+
* die konkreten Operationen (_open, _write, _close).
|
|
2054
|
+
* Feuert write-Events an registrierte Observer.
|
|
2055
|
+
* @category Verbindung
|
|
2056
|
+
*/
|
|
2057
|
+
declare abstract class AbstractConnection extends Subject implements Connection {
|
|
2058
|
+
protected _isOpen: boolean;
|
|
2059
|
+
get isOpen(): boolean;
|
|
2060
|
+
/** Template Method: Validierung → _open → Event */
|
|
2061
|
+
open(): Promise<void>;
|
|
2062
|
+
/** Template Method: Validierung → _write → Event */
|
|
2063
|
+
write(data: Uint8Array): Promise<void>;
|
|
2064
|
+
/** Template Method: _close → Event */
|
|
2065
|
+
close(): Promise<void>;
|
|
2066
|
+
protected abstract _open(): Promise<void>;
|
|
2067
|
+
protected abstract _write(data: Uint8Array): Promise<void>;
|
|
2068
|
+
protected abstract _close(): Promise<void>;
|
|
2069
|
+
}
|
|
2070
|
+
|
|
2071
|
+
/**
|
|
2072
|
+
* In-Memory-Adapter — sammelt alle geschriebenen Bytes.
|
|
2073
|
+
* Perfekt für Tests und Dry-Run ohne Hardware.
|
|
2074
|
+
* Implementiert das Adapter-Pattern gegenüber dem Connection-Interface.
|
|
2075
|
+
* @category Verbindung
|
|
2076
|
+
*/
|
|
2077
|
+
declare class BufferConnection extends AbstractConnection {
|
|
2078
|
+
private readonly buffers;
|
|
2079
|
+
protected _open(): Promise<void>;
|
|
2080
|
+
protected _write(data: Uint8Array): Promise<void>;
|
|
2081
|
+
protected _close(): Promise<void>;
|
|
2082
|
+
/**
|
|
2083
|
+
* Gibt alle bisher geschriebenen Bytes als einzelnes Uint8Array zurück.
|
|
2084
|
+
*/
|
|
2085
|
+
getBuffer(): Uint8Array;
|
|
2086
|
+
/**
|
|
2087
|
+
* Gibt die Liste aller einzelnen Schreiboperationen zurück.
|
|
2088
|
+
*/
|
|
2089
|
+
getWrites(): readonly Uint8Array[];
|
|
2090
|
+
/** Löscht den Buffer. */
|
|
2091
|
+
clear(): void;
|
|
2092
|
+
/** Liest vom Buffer (letzter Write, optionaler Timeout). */
|
|
2093
|
+
read(_timeout?: number): Promise<Uint8Array>;
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2096
|
+
/**
|
|
2097
|
+
* TCP/Netzwerk-Adapter (Adapter-Pattern).
|
|
2098
|
+
* Verbindet via TCP — typisch für Ethernet-POS-Drucker.
|
|
2099
|
+
* Standard-Port: 9100
|
|
2100
|
+
* @category Verbindung
|
|
2101
|
+
*/
|
|
2102
|
+
declare class NetworkConnection extends AbstractConnection {
|
|
2103
|
+
private readonly host;
|
|
2104
|
+
private readonly port;
|
|
2105
|
+
private readonly connectTimeout;
|
|
2106
|
+
private socket;
|
|
2107
|
+
constructor(host: string, port?: number, connectTimeout?: number);
|
|
2108
|
+
protected _open(): Promise<void>;
|
|
2109
|
+
protected _write(data: Uint8Array): Promise<void>;
|
|
2110
|
+
protected _close(): Promise<void>;
|
|
2111
|
+
read(timeout?: number): Promise<Uint8Array>;
|
|
2112
|
+
}
|
|
2113
|
+
|
|
2114
|
+
/**
|
|
2115
|
+
* Optionaler USB-Adapter (Adapter-Pattern).
|
|
2116
|
+
* Verwendet lazy require('usb') — nur verfügbar wenn `usb` installiert ist.
|
|
2117
|
+
* Schlägt mit einer hilfreichen Fehlermeldung fehl wenn das Package fehlt.
|
|
2118
|
+
* @category Verbindung
|
|
2119
|
+
*/
|
|
2120
|
+
declare class UsbConnection extends AbstractConnection {
|
|
2121
|
+
private readonly vendorId;
|
|
2122
|
+
private readonly productId;
|
|
2123
|
+
private device;
|
|
2124
|
+
constructor(vendorId: number, productId: number);
|
|
2125
|
+
protected _open(): Promise<void>;
|
|
2126
|
+
protected _write(_data: Uint8Array): Promise<void>;
|
|
2127
|
+
protected _close(): Promise<void>;
|
|
2128
|
+
}
|
|
2129
|
+
|
|
2130
|
+
/**
|
|
2131
|
+
* Optionaler Serial/RS-232-Adapter (Adapter-Pattern).
|
|
2132
|
+
* Verwendet lazy require('serialport').
|
|
2133
|
+
* @category Verbindung
|
|
2134
|
+
*/
|
|
2135
|
+
declare class SerialConnection extends AbstractConnection {
|
|
2136
|
+
private readonly path;
|
|
2137
|
+
private readonly baudRate;
|
|
2138
|
+
private port;
|
|
2139
|
+
constructor(path: string, baudRate?: number);
|
|
2140
|
+
protected _open(): Promise<void>;
|
|
2141
|
+
protected _write(data: Uint8Array): Promise<void>;
|
|
2142
|
+
protected _close(): Promise<void>;
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
/**
|
|
2146
|
+
* Factory-Pattern: Erzeugt Connection-Adapter nach Typ oder URL.
|
|
2147
|
+
* Konsumenten können eigene Adapter-Typen registrieren (Erweiterbarkeit).
|
|
2148
|
+
* @category Verbindung
|
|
2149
|
+
*/
|
|
2150
|
+
|
|
2151
|
+
/**
|
|
2152
|
+
* Optionen für eine Connection-Fabrik.
|
|
2153
|
+
* @category Verbindung
|
|
2154
|
+
*/
|
|
2155
|
+
type ConnectionOptions = Record<string, unknown>;
|
|
2156
|
+
/**
|
|
2157
|
+
* Funktion die eine Connection erzeugt.
|
|
2158
|
+
* @category Verbindung
|
|
2159
|
+
*/
|
|
2160
|
+
type ConnectionCreator = (options: ConnectionOptions) => Connection;
|
|
2161
|
+
declare class ConnectionFactory {
|
|
2162
|
+
private static readonly creators;
|
|
2163
|
+
/**
|
|
2164
|
+
* Registriert einen eigenen Connection-Typ (Erweiterbarkeit).
|
|
2165
|
+
* @example ConnectionFactory.register("bluetooth", opts => new BluetoothConnection(opts.address))
|
|
2166
|
+
*/
|
|
2167
|
+
static register(type: string, creator: ConnectionCreator): void;
|
|
2168
|
+
/**
|
|
2169
|
+
* Erstellt eine Connection des gewünschten Typs.
|
|
2170
|
+
* @throws Error wenn der Typ nicht registriert ist.
|
|
2171
|
+
*/
|
|
2172
|
+
static create(type: string, options?: ConnectionOptions): Connection;
|
|
2173
|
+
/** Erstellt eine In-Memory-Connection (für Tests). */
|
|
2174
|
+
static createBuffer(): BufferConnection;
|
|
2175
|
+
/** Erstellt eine TCP-Connection. */
|
|
2176
|
+
static createNetwork(host: string, port?: number): NetworkConnection;
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
/**
|
|
2180
|
+
* Bild-Encoder: Lädt ein Bild via jimp, skaliert es auf Druckerbreite,
|
|
2181
|
+
* wandelt es in Grauwerte um, dithtert es und erzeugt ESC/POS-Raster-Bytes.
|
|
2182
|
+
*
|
|
2183
|
+
* Konfigurierbar mit eigener DitherStrategy (Strategy-Pattern).
|
|
2184
|
+
* @category Bilder & Dithering
|
|
2185
|
+
*/
|
|
2186
|
+
|
|
2187
|
+
/**
|
|
2188
|
+
* Optionen für den ImageEncoder.
|
|
2189
|
+
* @category Bilder & Dithering
|
|
2190
|
+
*/
|
|
2191
|
+
interface ImageEncodeOptions {
|
|
2192
|
+
/** Breite in Dots (Standard: 576 für 80mm / 200dpi) */
|
|
2193
|
+
printWidthDots?: number;
|
|
2194
|
+
/** Dither-Strategie (Standard: Floyd–Steinberg) */
|
|
2195
|
+
dither?: DitherStrategy;
|
|
2196
|
+
}
|
|
2197
|
+
/**
|
|
2198
|
+
* Ergebnis einer Raster-Bild-Kodierung.
|
|
2199
|
+
* @category Bilder & Dithering
|
|
2200
|
+
*/
|
|
2201
|
+
interface RasterImageResult {
|
|
2202
|
+
/** Raster-Bytes für GS v 0 */
|
|
2203
|
+
data: Uint8Array;
|
|
2204
|
+
/** Breite in Bytes (xL + xH×256) */
|
|
2205
|
+
widthBytes: number;
|
|
2206
|
+
/** Höhe in Dots */
|
|
2207
|
+
heightDots: number;
|
|
2208
|
+
/** nL, nH, yL, yH für den GS v 0 Befehl */
|
|
2209
|
+
xL: number;
|
|
2210
|
+
xH: number;
|
|
2211
|
+
yL: number;
|
|
2212
|
+
yH: number;
|
|
2213
|
+
}
|
|
2214
|
+
declare class ImageEncoder {
|
|
2215
|
+
private readonly dither;
|
|
2216
|
+
private readonly printWidthDots;
|
|
2217
|
+
constructor(options?: ImageEncodeOptions);
|
|
2218
|
+
/**
|
|
2219
|
+
* Lädt eine Bilddatei (PNG, JPG, BMP, ...) und konvertiert sie in
|
|
2220
|
+
* ESC/POS Raster-Bytes für GS v 0.
|
|
2221
|
+
*/
|
|
2222
|
+
encodeFile(filePath: string): Promise<RasterImageResult>;
|
|
2223
|
+
/**
|
|
2224
|
+
* Verarbeitet einen Uint8Array (Bild-Buffer) direkt.
|
|
2225
|
+
*/
|
|
2226
|
+
encodeBuffer(buffer: Uint8Array): Promise<RasterImageResult>;
|
|
2227
|
+
private _processImage;
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2230
|
+
/**
|
|
2231
|
+
* Einfache Schwellwert-Strategie.
|
|
2232
|
+
* Pixel unter dem Schwellwert werden als Druckpunkt gewertet.
|
|
2233
|
+
* @category Bilder & Dithering
|
|
2234
|
+
*/
|
|
2235
|
+
declare class ThresholdDither implements DitherStrategy {
|
|
2236
|
+
private readonly threshold;
|
|
2237
|
+
readonly name = "Threshold";
|
|
2238
|
+
constructor(threshold?: number);
|
|
2239
|
+
dither(gray: Uint8Array, _width: number, _height: number): Uint8Array;
|
|
2240
|
+
}
|
|
2241
|
+
|
|
2242
|
+
/**
|
|
2243
|
+
* Floyd–Steinberg Dithering.
|
|
2244
|
+
* Verteilt Quantisierungsfehler auf benachbarte Pixel für feinere Übergänge.
|
|
2245
|
+
* @category Bilder & Dithering
|
|
2246
|
+
*/
|
|
2247
|
+
declare class FloydSteinbergDither implements DitherStrategy {
|
|
2248
|
+
readonly name = "FloydSteinberg";
|
|
2249
|
+
dither(gray: Uint8Array, width: number, height: number): Uint8Array;
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2252
|
+
export { AbstractCommand, AbstractConnection, Alignment, type AnyStatus, type BarcodeEncodingStrategy, BarcodeSystem, BarcodeWidth, BeepAndFlashCommand, BeepCommand, BitImageMode, BufferConnection, ByteBuilder, CAN, CR, CancelKanjiModeCommand, CancelPageDataCommand, CarriageReturnCommand, CharacterCodeTable, CodabarStrategy, Code128Strategy, Code39Strategy, type Command, CommandFactory, type CommandRegistration, CommandRegistry, CommandSequence, type Connection, type ConnectionCreator, ConnectionFactory, type ConnectionOptions, CutCommand, CutMode, DC4, DLE, DefineDownloadedBitImageCommand, DefineKanjiCommand, DefineNvBitImageCommand, type DitherStrategy, DrawerPin, DrawerStatus, ENQ, EOT, ESC, EnableAsbCommand, ErrorStatus, ExecuteMacroCommand, FF, FS, FloydSteinbergDither, Font, FormFeedCommand, GS, GeneratePulseCommand, GeneratePulseRealtimeCommand, HT, HorizontalTabCommand, HriFont, HriPosition, type ImageEncodeOptions, ImageEncoder, InitializeCommand, InternationalCharacterSet, type InvoiceAddress, InvoiceBuilder, type InvoiceBuilderOptions, type ItemOptions, ItfStrategy, LF, LineFeedCommand, MacroStartEndCommand, NUL, NetworkConnection, type NvBitImageData, OfflineStatus, PaperSensorStatus, PrintAndFeedLinesCommand, PrintAndFeedPaperCommand, PrintBarcodeCommand, PrintDirection, PrintDownloadedBitImageCommand, type PrintModesOptions, PrintNvBitImageCommand, PrintQrCodeCommand, PrintRasterBitImageCommand, PrintState, Printer, type PrinterEvent, type PrinterEventType, type PrinterObserver, PrinterStatus, QrCodeErrorCorrection, type QrCodeOptions, type QuantityDisplay, type RasterImageResult, RasterMode, RawCommand, RealtimeRequestCommand, ReceiptBuilder, SP, SelectCharacterCodeTableCommand, SelectCharacterFontCommand, SelectCharacterSizeCommand, SelectInternationalCharSetCommand, SelectKanjiModeCommand, SelectPageModeCommand, SelectPrintDirectionCommand, SelectPrintModesCommand, SelectStandardModeCommand, SerialConnection, SetAbsolutePositionCommand, SetBarcodeHeightCommand, SetBarcodeWidthCommand, SetDefaultLineSpacingCommand, SetEmphasizedCommand, SetHorizontalTabPositionsCommand, SetHriFontCommand, SetHriPositionCommand, SetJustificationCommand, SetKanjiPrintModeCommand, SetKanjiQuadrupleCommand, SetKanjiSpacingCommand, SetKanjiUnderlineCommand, SetLeftMarginCommand, SetLineSpacingCommand, SetPrintingAreaPageModeCommand, SetPrintingAreaWidthCommand, SetRelativePositionCommand, SetReverseCommand, SetRotationCommand, SetUnderlineCommand, SetUpsideDownCommand, SimpleNumericBarcodeStrategy, StateMemento, StatusDecoder, type StatusType, type SubLine, Subject, ThresholdDither, TransmitRealtimeStatusCommand, TransmitStatusCommand, UnderlineMode, UsbConnection, fromUint16LE, toComplement16, toUint16LE };
|