@thermal-print/escpos 0.1.0 → 0.3.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/LICENSE +21 -21
- package/dist/command-adapters/escbematech-adapter.js +2 -39
- package/dist/command-adapters/escpos-adapter.js +2 -39
- package/dist/command-adapters/index.d.ts +1 -1
- package/dist/command-adapters/index.d.ts.map +1 -1
- package/dist/command-adapters/index.js +2 -7
- package/dist/command-adapters/types.js +1 -2
- package/dist/commands/escbematech.js +217 -306
- package/dist/commands/escpos.js +193 -264
- package/dist/converter.js +10 -13
- package/dist/encodings/cp860.js +3 -8
- package/dist/generator.js +15 -52
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -44
- package/dist/styles.d.ts.map +1 -1
- package/dist/styles.js +17 -35
- package/dist/traverser.d.ts.map +1 -1
- package/dist/traverser.js +30 -19
- package/dist/types.js +1 -2
- package/package.json +12 -2
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* ESC/Bematech Command Set
|
|
4
3
|
*
|
|
@@ -8,39 +7,34 @@
|
|
|
8
7
|
* This file contains all documented ESC/Bematech commands organized by category.
|
|
9
8
|
* Commands follow the Bematech-specific implementation which differs from standard ESC/POS.
|
|
10
9
|
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.PrinterLanguage = exports.setPrintingIntensityAlt = exports.setPrintingIntensity = exports.setPrinterMode = exports.PrinterMode = exports.selectDrawerSensor = exports.selectPaperSensor = exports.disablePaperNearEndSensor = exports.enablePaperNearEndSensor = exports.setPaperWidth = exports.PaperWidth = exports.printUnicodeSet = exports.PRINT_UNICODE_SETS = exports.setInternationalCharset = exports.setIdeogramMode = exports.setDefaultCodePage = exports.setCodePage = exports.CodePage = exports.GET_CURRENT_MODE = exports.returnToPreviousMode = exports.selectESCPOSModeTemp = exports.selectESCBemaModeTemp = exports.selectESCPOSMode = exports.selectESCBemaMode = exports.INIT = exports.DEL = exports.GS = exports.FS = exports.ESC = exports.CAN = exports.ETB = exports.SYN = exports.NAK = exports.DC4 = exports.DC2 = exports.SI = exports.SO = exports.CR = exports.FF = exports.LF = exports.HT = exports.BS = exports.BEL = exports.ACK = exports.ENQ = exports.EOT = exports.ETX = exports.STX = exports.SOH = exports.NUL = void 0;
|
|
13
|
-
exports.DOUBLE_HEIGHT_ONLINE = exports.DOUBLE_HEIGHT_OFF = exports.DOUBLE_HEIGHT_ON = exports.calculatePrintMode = exports.SCRIPT_OFF = exports.SUBSCRIPT_ON = exports.SUPERSCRIPT_ON = exports.UPSIDE_DOWN_OFF = exports.UPSIDE_DOWN_ON = exports.ITALIC_OFF = exports.ITALIC_ON = exports.UNDERLINE_OFF = exports.UNDERLINE_ON = exports.BOLD_OFF = exports.BOLD_ON = exports.ALIGN_RIGHT = exports.ALIGN_CENTER = exports.ALIGN_LEFT = exports.CLEAR_TABS = exports.setTabPositions = exports.TAB = exports.setLeftMargin = exports.setRightMargin = exports.disableAutoLineFeed = exports.enableAutoLineFeed = exports.setPageSizeMM = exports.setPageSizeLines = exports.horizontalSkip = exports.verticalSkip = exports.setLineSpacing = exports.SET_LINE_HEIGHT_DEFAULT = exports.feedPaper = exports.fineFeed = exports.FEED_PAGE = exports.FEED_LINE = exports.activateBuzzer = exports.disableBuzzerOnCut = exports.setBuzzerOnCut = exports.CUT_FULL_ALT = exports.CUT_FULL = exports.activateDrawer2 = exports.activateDrawer1 = exports.ENABLE_DUMP_MODE = exports.disablePanelKeys = exports.enablePanelKeys = exports.RESET_PRINTER = exports.PRINT_CONFIG = exports.LOAD_DEFAULT_CONFIG = exports.getPrinterInfo = exports.setPrinterLanguage = void 0;
|
|
14
|
-
exports.CLEAR_BUFFER = exports.EXTENDED_STATUS = exports.STATUS_ENQUIRY = exports.printBarcodePLESSEYAlt = exports.printBarcodePLESSEY = exports.printBarcodeMSIAlt = exports.printBarcodeMSI = exports.printBarcodeISBN = exports.printBarcodePDF417 = exports.printBarcodeCODE128 = exports.printBarcodeCODE93 = exports.printBarcodeCODABARAlt = exports.printBarcodeCODABAR = exports.printBarcodeITFAlt = exports.printBarcodeITF = exports.printBarcodeCODE39Alt = exports.printBarcodeCODE39 = exports.printBarcodeEAN8Alt = exports.printBarcodeEAN8 = exports.printBarcodeEAN13Alt = exports.printBarcodeEAN13 = exports.printBarcodeUPCEAlt = exports.printBarcodeUPCE = exports.printBarcodeUPCAAlt = exports.printBarcodeUPCA = exports.setBarcodeLeftMargin = exports.setBarcodeHRIFont = exports.setBarcodeHRI = exports.BarcodeHRIPosition = exports.setBarcodeWidth = exports.setBarcodeHeight = exports.printNVBitImage = exports.defineNVBitImage = exports.printDownloadedBitImage = exports.defineDownloadedBitImage = exports.printRasterBitmap = exports.RasterMode = exports.print8BitGraphics = exports.print24BitGraphics = exports.fillBlankColumns = exports.CONDENSED_OFF_DC2 = exports.CONDENSED_OFF_ALT = exports.CONDENSED_OFF = exports.CONDENSED_ON_ALT = exports.CONDENSED_ON = exports.EXPANDED_OFF = exports.EXPANDED_ONLINE_ALT = exports.EXPANDED_ONLINE = exports.DOUBLE_WIDTH_OFF = exports.DOUBLE_WIDTH_ON = void 0;
|
|
15
|
-
exports.validateBarcodeData = exports.encodeText = exports.setWiFi = exports.setSNMP = exports.disableDHCP = exports.enableDHCP = exports.setGateway = exports.setIPAddress = exports.CANCEL_CHAR = exports.CANCEL_LINE = exports.END_BUFFER = void 0;
|
|
16
10
|
// ============================================================================
|
|
17
11
|
// CONTROL CHARACTERS
|
|
18
12
|
// ============================================================================
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
13
|
+
export const NUL = 0x00; // Null
|
|
14
|
+
export const SOH = 0x01; // Start of Heading
|
|
15
|
+
export const STX = 0x02; // Start of Text - Clear buffer
|
|
16
|
+
export const ETX = 0x03; // End of Text - End buffer
|
|
17
|
+
export const EOT = 0x04; // End of Transmission
|
|
18
|
+
export const ENQ = 0x05; // Enquiry - Printer status
|
|
19
|
+
export const ACK = 0x06; // Acknowledge
|
|
20
|
+
export const BEL = 0x07; // Bell
|
|
21
|
+
export const BS = 0x08; // Backspace
|
|
22
|
+
export const HT = 0x09; // Horizontal Tab
|
|
23
|
+
export const LF = 0x0a; // Line Feed
|
|
24
|
+
export const FF = 0x0c; // Form Feed
|
|
25
|
+
export const CR = 0x0d; // Carriage Return
|
|
26
|
+
export const SO = 0x0e; // Shift Out - Enable on-line expanded mode
|
|
27
|
+
export const SI = 0x0f; // Shift In - Enable condensed mode
|
|
28
|
+
export const DC2 = 0x12; // Device Control 2 - Disable condensed mode
|
|
29
|
+
export const DC4 = 0x14; // Device Control 4 - Disable on-line expanded print
|
|
30
|
+
export const NAK = 0x15; // Negative Acknowledge
|
|
31
|
+
export const SYN = 0x16; // Synchronous Idle
|
|
32
|
+
export const ETB = 0x17; // End of Transmission Block
|
|
33
|
+
export const CAN = 0x18; // Cancel - Cancel last line
|
|
34
|
+
export const ESC = 0x1b; // Escape
|
|
35
|
+
export const FS = 0x1c; // File Separator
|
|
36
|
+
export const GS = 0x1d; // Group Separator
|
|
37
|
+
export const DEL = 0x7f; // Delete - Cancel last character
|
|
44
38
|
// ============================================================================
|
|
45
39
|
// INITIALIZATION & CONFIGURATION
|
|
46
40
|
// ============================================================================
|
|
@@ -52,7 +46,7 @@ exports.DEL = 0x7f; // Delete - Cancel last character
|
|
|
52
46
|
* Cancels all printer settings including character font, line spacing,
|
|
53
47
|
* margins, and returns printer to initial state.
|
|
54
48
|
*/
|
|
55
|
-
|
|
49
|
+
export const INIT = [ESC, 0x40];
|
|
56
50
|
// ============================================================================
|
|
57
51
|
// MODE SELECTION
|
|
58
52
|
// ============================================================================
|
|
@@ -62,38 +56,33 @@ exports.INIT = [exports.ESC, 0x40];
|
|
|
62
56
|
* n = 0 or 48: ESC/Bema mode
|
|
63
57
|
* n = 1 or 49: ESC/POS mode
|
|
64
58
|
*/
|
|
65
|
-
const selectESCBemaMode = () => [
|
|
66
|
-
|
|
67
|
-
const selectESCPOSMode = () => [exports.GS, 0xF9, 0x35, 0x01];
|
|
68
|
-
exports.selectESCPOSMode = selectESCPOSMode;
|
|
59
|
+
export const selectESCBemaMode = () => [GS, 0xF9, 0x35, 0x00];
|
|
60
|
+
export const selectESCPOSMode = () => [GS, 0xF9, 0x35, 0x01];
|
|
69
61
|
/**
|
|
70
62
|
* GS F9h SP n - Select printer operating mode temporarily
|
|
71
63
|
* Does NOT save to memory
|
|
72
64
|
* n = 0 or 48: ESC/Bema mode
|
|
73
65
|
* n = 1 or 49: ESC/POS mode
|
|
74
66
|
*/
|
|
75
|
-
const selectESCBemaModeTemp = () => [
|
|
76
|
-
|
|
77
|
-
const selectESCPOSModeTemp = () => [exports.GS, 0xF9, 0x20, 0x01];
|
|
78
|
-
exports.selectESCPOSModeTemp = selectESCPOSModeTemp;
|
|
67
|
+
export const selectESCBemaModeTemp = () => [GS, 0xF9, 0x20, 0x00];
|
|
68
|
+
export const selectESCPOSModeTemp = () => [GS, 0xF9, 0x20, 0x01];
|
|
79
69
|
/**
|
|
80
70
|
* GS F9h 1Fh 1 - Return to previously set mode
|
|
81
71
|
* Hexadecimal: 1D F9 1F 31
|
|
82
72
|
*/
|
|
83
|
-
const returnToPreviousMode = () => [
|
|
84
|
-
exports.returnToPreviousMode = returnToPreviousMode;
|
|
73
|
+
export const returnToPreviousMode = () => [GS, 0xF9, 0x1F, 0x31];
|
|
85
74
|
/**
|
|
86
75
|
* GS F9h C 00h - Get printer current command set
|
|
87
76
|
* Returns: 0 = ESC/Bema, 1 = ESC/POS
|
|
88
77
|
*/
|
|
89
|
-
|
|
78
|
+
export const GET_CURRENT_MODE = [GS, 0xF9, 0x43, 0x00];
|
|
90
79
|
// ============================================================================
|
|
91
80
|
// CODE PAGES & CHARACTER ENCODING
|
|
92
81
|
// ============================================================================
|
|
93
82
|
/**
|
|
94
83
|
* Code page identifiers
|
|
95
84
|
*/
|
|
96
|
-
var CodePage;
|
|
85
|
+
export var CodePage;
|
|
97
86
|
(function (CodePage) {
|
|
98
87
|
CodePage[CodePage["CP850"] = 2] = "CP850";
|
|
99
88
|
CodePage[CodePage["CP437"] = 3] = "CP437";
|
|
@@ -108,20 +97,18 @@ var CodePage;
|
|
|
108
97
|
CodePage[CodePage["GB2312"] = 12] = "GB2312";
|
|
109
98
|
CodePage[CodePage["EUC_CN"] = 14] = "EUC_CN";
|
|
110
99
|
CodePage[CodePage["CP862"] = 21] = "CP862"; // CODEPAGE 862 (15h)
|
|
111
|
-
})(CodePage || (
|
|
100
|
+
})(CodePage || (CodePage = {}));
|
|
112
101
|
/**
|
|
113
102
|
* ESC t n - Select code page
|
|
114
103
|
* Hexadecimal: 1B 74 n
|
|
115
104
|
* Default: CP850
|
|
116
105
|
*/
|
|
117
|
-
const setCodePage = (codePage) => [
|
|
118
|
-
exports.setCodePage = setCodePage;
|
|
106
|
+
export const setCodePage = (codePage) => [ESC, 0x74, codePage];
|
|
119
107
|
/**
|
|
120
108
|
* GS F9h 7 n - Set and save printer default code page
|
|
121
109
|
* Saves to non-volatile memory
|
|
122
110
|
*/
|
|
123
|
-
const setDefaultCodePage = (codePage) => [
|
|
124
|
-
exports.setDefaultCodePage = setDefaultCodePage;
|
|
111
|
+
export const setDefaultCodePage = (codePage) => [GS, 0xF9, 0x37, codePage];
|
|
125
112
|
/**
|
|
126
113
|
* GS F9h 8 n - Set and save ESC/POS ideogram mode
|
|
127
114
|
* n = 0: UTF8 (Unicode)
|
|
@@ -129,31 +116,28 @@ exports.setDefaultCodePage = setDefaultCodePage;
|
|
|
129
116
|
* n = 2: ESC/POS Simplified Chinese
|
|
130
117
|
* n = 3: ESC/POS Traditional Chinese
|
|
131
118
|
*/
|
|
132
|
-
const setIdeogramMode = (mode) => [
|
|
133
|
-
exports.setIdeogramMode = setIdeogramMode;
|
|
119
|
+
export const setIdeogramMode = (mode) => [GS, 0xF9, 0x38, mode];
|
|
134
120
|
/**
|
|
135
121
|
* ESC R n - Select international character set
|
|
136
122
|
* n = 0: CODEPAGE 437
|
|
137
123
|
* n = 1-11: CODEPAGE 858
|
|
138
124
|
* n = 12: CODEPAGE 850 (default)
|
|
139
125
|
*/
|
|
140
|
-
const setInternationalCharset = (n) => {
|
|
126
|
+
export const setInternationalCharset = (n) => {
|
|
141
127
|
if (n < 0 || n > 12)
|
|
142
128
|
n = 12;
|
|
143
|
-
return [
|
|
129
|
+
return [ESC, 0x52, n];
|
|
144
130
|
};
|
|
145
|
-
exports.setInternationalCharset = setInternationalCharset;
|
|
146
131
|
/**
|
|
147
132
|
* ESC Z - Print supported Unicode sets
|
|
148
133
|
* Prints a chart showing all supported Unicode character sets
|
|
149
134
|
*/
|
|
150
|
-
|
|
135
|
+
export const PRINT_UNICODE_SETS = [ESC, 0x5A];
|
|
151
136
|
/**
|
|
152
137
|
* ESC [ n - Print specific Unicode set
|
|
153
138
|
* Range: 0 ≤ n ≤ 255
|
|
154
139
|
*/
|
|
155
|
-
const printUnicodeSet = (n) => [
|
|
156
|
-
exports.printUnicodeSet = printUnicodeSet;
|
|
140
|
+
export const printUnicodeSet = (n) => [ESC, 0x5B, Math.max(0, Math.min(255, n))];
|
|
157
141
|
// ============================================================================
|
|
158
142
|
// PAPER CONFIGURATION
|
|
159
143
|
// ============================================================================
|
|
@@ -161,7 +145,7 @@ exports.printUnicodeSet = printUnicodeSet;
|
|
|
161
145
|
* Paper width presets (ESC/Bema mode only)
|
|
162
146
|
* Format: [paper width in mm, printing width in mm]
|
|
163
147
|
*/
|
|
164
|
-
var PaperWidth;
|
|
148
|
+
export var PaperWidth;
|
|
165
149
|
(function (PaperWidth) {
|
|
166
150
|
PaperWidth[PaperWidth["WIDTH_58_48"] = 0] = "WIDTH_58_48";
|
|
167
151
|
PaperWidth[PaperWidth["WIDTH_76_72"] = 1] = "WIDTH_76_72";
|
|
@@ -170,65 +154,57 @@ var PaperWidth;
|
|
|
170
154
|
PaperWidth[PaperWidth["WIDTH_82_72"] = 4] = "WIDTH_82_72";
|
|
171
155
|
PaperWidth[PaperWidth["WIDTH_82_76"] = 5] = "WIDTH_82_76";
|
|
172
156
|
PaperWidth[PaperWidth["WIDTH_82_80"] = 6] = "WIDTH_82_80"; // 82.5mm paper, 80mm print width
|
|
173
|
-
})(PaperWidth || (
|
|
157
|
+
})(PaperWidth || (PaperWidth = {}));
|
|
174
158
|
/**
|
|
175
159
|
* GS F9h ! n - Set and save paper width
|
|
176
160
|
* Only effective in ESC/Bema mode
|
|
177
161
|
* In ESC/POS mode, paper width is always 80mm/73.5mm
|
|
178
162
|
*/
|
|
179
|
-
const setPaperWidth = (width) => [
|
|
180
|
-
exports.setPaperWidth = setPaperWidth;
|
|
163
|
+
export const setPaperWidth = (width) => [GS, 0xF9, 0x21, width];
|
|
181
164
|
/**
|
|
182
165
|
* GS F9h , n - Enable/disable paper near-end sensor (PNES)
|
|
183
166
|
* n = 0 or 48: Disable PNES
|
|
184
167
|
* n = 1 or 49: Enable PNES (default)
|
|
185
168
|
* Saves to non-volatile memory
|
|
186
169
|
*/
|
|
187
|
-
const enablePaperNearEndSensor = () => [
|
|
188
|
-
|
|
189
|
-
const disablePaperNearEndSensor = () => [exports.GS, 0xF9, 0x2C, 0x00];
|
|
190
|
-
exports.disablePaperNearEndSensor = disablePaperNearEndSensor;
|
|
170
|
+
export const enablePaperNearEndSensor = () => [GS, 0xF9, 0x2C, 0x01];
|
|
171
|
+
export const disablePaperNearEndSensor = () => [GS, 0xF9, 0x2C, 0x00];
|
|
191
172
|
/**
|
|
192
173
|
* ESC b n - Select paper sensor to output paper-end signal
|
|
193
174
|
* n = 0 or 48: PE reflects paper sensor (default)
|
|
194
175
|
* n = 1 or 49: PE reflects drawer sensor
|
|
195
176
|
*/
|
|
196
|
-
const selectPaperSensor = () => [
|
|
197
|
-
|
|
198
|
-
const selectDrawerSensor = () => [exports.ESC, 0x62, 0x01];
|
|
199
|
-
exports.selectDrawerSensor = selectDrawerSensor;
|
|
177
|
+
export const selectPaperSensor = () => [ESC, 0x62, 0x00];
|
|
178
|
+
export const selectDrawerSensor = () => [ESC, 0x62, 0x01];
|
|
200
179
|
// ============================================================================
|
|
201
180
|
// PRINTER QUALITY & MODE
|
|
202
181
|
// ============================================================================
|
|
203
182
|
/**
|
|
204
183
|
* Printer quality modes
|
|
205
184
|
*/
|
|
206
|
-
var PrinterMode;
|
|
185
|
+
export var PrinterMode;
|
|
207
186
|
(function (PrinterMode) {
|
|
208
187
|
PrinterMode[PrinterMode["NORMAL"] = 0] = "NORMAL";
|
|
209
188
|
PrinterMode[PrinterMode["HIGH_QUALITY"] = 1] = "HIGH_QUALITY";
|
|
210
189
|
PrinterMode[PrinterMode["HIGH_SPEED"] = 2] = "HIGH_SPEED"; // High speed mode
|
|
211
|
-
})(PrinterMode || (
|
|
190
|
+
})(PrinterMode || (PrinterMode = {}));
|
|
212
191
|
/**
|
|
213
192
|
* GS F9h - n - Set and save printer mode
|
|
214
193
|
* Sets printing priority to high quality or high speed
|
|
215
194
|
*/
|
|
216
|
-
const setPrinterMode = (mode) => [
|
|
217
|
-
exports.setPrinterMode = setPrinterMode;
|
|
195
|
+
export const setPrinterMode = (mode) => [GS, 0xF9, 0x2D, mode];
|
|
218
196
|
/**
|
|
219
197
|
* ESC N n - Select printing intensity (OBSOLETE)
|
|
220
198
|
* Kept for compatibility with earlier Bematech products
|
|
221
199
|
* Command is ignored by MP-4200 TH
|
|
222
200
|
*/
|
|
223
|
-
const setPrintingIntensity = (n) => [
|
|
224
|
-
exports.setPrintingIntensity = setPrintingIntensity;
|
|
201
|
+
export const setPrintingIntensity = (n) => [ESC, 0x4E, Math.max(0, Math.min(4, n))];
|
|
225
202
|
/**
|
|
226
203
|
* GS F9h + n - Set and save printing intensity (OBSOLETE)
|
|
227
204
|
* Kept for compatibility with earlier Bematech products
|
|
228
205
|
* Command is ignored by MP-4200 TH
|
|
229
206
|
*/
|
|
230
|
-
const setPrintingIntensityAlt = (n) => [
|
|
231
|
-
exports.setPrintingIntensityAlt = setPrintingIntensityAlt;
|
|
207
|
+
export const setPrintingIntensityAlt = (n) => [GS, 0xF9, 0x2B, n];
|
|
232
208
|
// ============================================================================
|
|
233
209
|
// PRINTER LANGUAGE
|
|
234
210
|
// ============================================================================
|
|
@@ -239,15 +215,14 @@ exports.setPrintingIntensityAlt = setPrintingIntensityAlt;
|
|
|
239
215
|
* n = 2 or 50: Spanish
|
|
240
216
|
* n = 3 or 51: German
|
|
241
217
|
*/
|
|
242
|
-
var PrinterLanguage;
|
|
218
|
+
export var PrinterLanguage;
|
|
243
219
|
(function (PrinterLanguage) {
|
|
244
220
|
PrinterLanguage[PrinterLanguage["ENGLISH"] = 0] = "ENGLISH";
|
|
245
221
|
PrinterLanguage[PrinterLanguage["PORTUGUESE"] = 1] = "PORTUGUESE";
|
|
246
222
|
PrinterLanguage[PrinterLanguage["SPANISH"] = 2] = "SPANISH";
|
|
247
223
|
PrinterLanguage[PrinterLanguage["GERMAN"] = 3] = "GERMAN";
|
|
248
|
-
})(PrinterLanguage || (
|
|
249
|
-
const setPrinterLanguage = (lang) => [
|
|
250
|
-
exports.setPrinterLanguage = setPrinterLanguage;
|
|
224
|
+
})(PrinterLanguage || (PrinterLanguage = {}));
|
|
225
|
+
export const setPrinterLanguage = (lang) => [GS, 0xFA, lang];
|
|
251
226
|
// ============================================================================
|
|
252
227
|
// PRINTER INFORMATION & CONFIGURATION
|
|
253
228
|
// ============================================================================
|
|
@@ -261,23 +236,22 @@ exports.setPrinterLanguage = setPrinterLanguage;
|
|
|
261
236
|
* n = 5 or 53: Manufacturing timestamp (17 bytes, "dd/mm/yy hh:mm:ss")
|
|
262
237
|
* n = 8 or 56: Interface type (1 byte: 0=None, 1=Serial DB-9, 2=Serial DB-25, 3=Ethernet, -1=Unknown)
|
|
263
238
|
*/
|
|
264
|
-
const getPrinterInfo = (infoType) => [
|
|
265
|
-
exports.getPrinterInfo = getPrinterInfo;
|
|
239
|
+
export const getPrinterInfo = (infoType) => [GS, 0xF9, 0x27, infoType];
|
|
266
240
|
/**
|
|
267
241
|
* GS F9h ( 0 - Load default user configuration
|
|
268
242
|
* Reloads all configurations from non-volatile memory and dipswitches
|
|
269
243
|
*/
|
|
270
|
-
|
|
244
|
+
export const LOAD_DEFAULT_CONFIG = [GS, 0xF9, 0x28, 0x30];
|
|
271
245
|
/**
|
|
272
246
|
* GS F9h ) 0 - Print user configuration
|
|
273
247
|
* Prints current user configuration on paper
|
|
274
248
|
*/
|
|
275
|
-
|
|
249
|
+
export const PRINT_CONFIG = [GS, 0xF9, 0x29, 0x30];
|
|
276
250
|
/**
|
|
277
251
|
* GS F8h F - Printer reset
|
|
278
252
|
* Forces a hardware reset
|
|
279
253
|
*/
|
|
280
|
-
|
|
254
|
+
export const RESET_PRINTER = [GS, 0xF8, 0x46];
|
|
281
255
|
// ============================================================================
|
|
282
256
|
// PANEL CONTROL
|
|
283
257
|
// ============================================================================
|
|
@@ -286,16 +260,14 @@ exports.RESET_PRINTER = [exports.GS, 0xF8, 0x46];
|
|
|
286
260
|
* n = 0 or 48: Disable panel keys
|
|
287
261
|
* n = 1 or 49: Enable panel keys (default)
|
|
288
262
|
*/
|
|
289
|
-
const enablePanelKeys = () => [
|
|
290
|
-
|
|
291
|
-
const disablePanelKeys = () => [exports.ESC, 0x79, 0x00];
|
|
292
|
-
exports.disablePanelKeys = disablePanelKeys;
|
|
263
|
+
export const enablePanelKeys = () => [ESC, 0x79, 0x01];
|
|
264
|
+
export const disablePanelKeys = () => [ESC, 0x79, 0x00];
|
|
293
265
|
/**
|
|
294
266
|
* ESC x - Enable dump mode
|
|
295
267
|
* Prints data in hexadecimal for debugging
|
|
296
268
|
* WARNING: Only way to exit dump mode is to turn off printer
|
|
297
269
|
*/
|
|
298
|
-
|
|
270
|
+
export const ENABLE_DUMP_MODE = [ESC, 0x78];
|
|
299
271
|
// ============================================================================
|
|
300
272
|
// DRAWER CONTROL
|
|
301
273
|
// ============================================================================
|
|
@@ -303,20 +275,18 @@ exports.ENABLE_DUMP_MODE = [exports.ESC, 0x78];
|
|
|
303
275
|
* ESC v n - Activate drawer #1 for n milliseconds
|
|
304
276
|
* Range: 50 ≤ n ≤ 250 (actual: 50ms ≤ n ≤ 200ms)
|
|
305
277
|
*/
|
|
306
|
-
const activateDrawer1 = (milliseconds) => {
|
|
278
|
+
export const activateDrawer1 = (milliseconds) => {
|
|
307
279
|
const n = Math.max(50, Math.min(250, milliseconds));
|
|
308
|
-
return [
|
|
280
|
+
return [ESC, 0x76, n];
|
|
309
281
|
};
|
|
310
|
-
exports.activateDrawer1 = activateDrawer1;
|
|
311
282
|
/**
|
|
312
283
|
* ESC 80h n - Activate drawer #2 for n milliseconds
|
|
313
284
|
* Range: 50 ≤ n ≤ 250 (actual: 50ms ≤ n ≤ 200ms)
|
|
314
285
|
*/
|
|
315
|
-
const activateDrawer2 = (milliseconds) => {
|
|
286
|
+
export const activateDrawer2 = (milliseconds) => {
|
|
316
287
|
const n = Math.max(50, Math.min(250, milliseconds));
|
|
317
|
-
return [
|
|
288
|
+
return [ESC, 0x80, n];
|
|
318
289
|
};
|
|
319
|
-
exports.activateDrawer2 = activateDrawer2;
|
|
320
290
|
// ============================================================================
|
|
321
291
|
// PAPER CUTTING
|
|
322
292
|
// ============================================================================
|
|
@@ -324,25 +294,23 @@ exports.activateDrawer2 = activateDrawer2;
|
|
|
324
294
|
* ESC i - Perform full paper cut
|
|
325
295
|
* Hexadecimal: 1B 69
|
|
326
296
|
*/
|
|
327
|
-
|
|
297
|
+
export const CUT_FULL = [ESC, 0x69];
|
|
328
298
|
/**
|
|
329
299
|
* ESC w - Perform full paper cut (alternate command)
|
|
330
300
|
* Hexadecimal: 1B 77
|
|
331
301
|
*/
|
|
332
|
-
|
|
302
|
+
export const CUT_FULL_ALT = [ESC, 0x77];
|
|
333
303
|
/**
|
|
334
304
|
* GS F9h D m n - Activate buzzer on cut
|
|
335
305
|
* m: Buzzer selection (0=none, 1=internal, 2=external)
|
|
336
306
|
* n: Activation time (n × 100ms)
|
|
337
307
|
* Default: m=0, n=200
|
|
338
308
|
*/
|
|
339
|
-
const setBuzzerOnCut = (buzzer, time) => {
|
|
309
|
+
export const setBuzzerOnCut = (buzzer, time) => {
|
|
340
310
|
const n = Math.max(0, Math.min(255, time));
|
|
341
|
-
return [
|
|
311
|
+
return [GS, 0xF9, 0x44, buzzer, n];
|
|
342
312
|
};
|
|
343
|
-
|
|
344
|
-
const disableBuzzerOnCut = () => [exports.GS, 0xF9, 0x44, 0x00, 0x00];
|
|
345
|
-
exports.disableBuzzerOnCut = disableBuzzerOnCut;
|
|
313
|
+
export const disableBuzzerOnCut = () => [GS, 0xF9, 0x44, 0x00, 0x00];
|
|
346
314
|
// ============================================================================
|
|
347
315
|
// BUZZER CONTROL
|
|
348
316
|
// ============================================================================
|
|
@@ -354,12 +322,11 @@ exports.disableBuzzerOnCut = disableBuzzerOnCut;
|
|
|
354
322
|
* n = (n1 + n2 × 256): Time in milliseconds
|
|
355
323
|
* vol = 0, 1, 48, or 49: Volume (unused)
|
|
356
324
|
*/
|
|
357
|
-
const activateBuzzer = (milliseconds) => {
|
|
325
|
+
export const activateBuzzer = (milliseconds) => {
|
|
358
326
|
const n1 = milliseconds & 0xFF;
|
|
359
327
|
const n2 = (milliseconds >> 8) & 0xFF;
|
|
360
|
-
return [
|
|
328
|
+
return [ESC, 0x28, 0x41, 0x04, 0x00, 0x01, n1, n2, 0x00];
|
|
361
329
|
};
|
|
362
|
-
exports.activateBuzzer = activateBuzzer;
|
|
363
330
|
// ============================================================================
|
|
364
331
|
// PAPER FEEDING
|
|
365
332
|
// ============================================================================
|
|
@@ -367,71 +334,66 @@ exports.activateBuzzer = activateBuzzer;
|
|
|
367
334
|
* LF - Feed one line
|
|
368
335
|
* Prints buffer contents and feeds one line according to default line spacing
|
|
369
336
|
*/
|
|
370
|
-
|
|
337
|
+
export const FEED_LINE = [LF];
|
|
371
338
|
/**
|
|
372
339
|
* FF - Feed one page
|
|
373
340
|
* Moves from current position to top of next page
|
|
374
341
|
* Can be disabled by setting page size to zero
|
|
375
342
|
*/
|
|
376
|
-
|
|
343
|
+
export const FEED_PAGE = [FF];
|
|
377
344
|
/**
|
|
378
345
|
* ESC J n - Perform fine line feed
|
|
379
346
|
* Range: 48 ≤ n ≤ 255
|
|
380
347
|
* Feed: (n - 48) × 0.125mm
|
|
381
348
|
* Widely used for graphics printing
|
|
382
349
|
*/
|
|
383
|
-
const fineFeed = (n) => {
|
|
350
|
+
export const fineFeed = (n) => {
|
|
384
351
|
const value = Math.max(48, Math.min(255, n));
|
|
385
|
-
return [
|
|
352
|
+
return [ESC, 0x4A, value];
|
|
386
353
|
};
|
|
387
|
-
exports.fineFeed = fineFeed;
|
|
388
354
|
/**
|
|
389
355
|
* ESC A n - Feed paper by [n × 0.375]mm
|
|
390
356
|
* Range: 0 ≤ n ≤ 255
|
|
391
357
|
* Notes: n < 17 → 0mm, n > 85 → 32mm, else n × 0.375mm
|
|
392
358
|
*/
|
|
393
|
-
const feedPaper = (n) => {
|
|
359
|
+
export const feedPaper = (n) => {
|
|
394
360
|
const value = Math.max(0, Math.min(255, n));
|
|
395
|
-
return [
|
|
361
|
+
return [ESC, 0x41, value];
|
|
396
362
|
};
|
|
397
|
-
exports.feedPaper = feedPaper;
|
|
398
363
|
/**
|
|
399
364
|
* ESC 2 - Set text line height to 1/6 inches (default)
|
|
400
365
|
* Hexadecimal: 1B 32
|
|
401
366
|
*/
|
|
402
|
-
|
|
367
|
+
export const SET_LINE_HEIGHT_DEFAULT = [ESC, 0x32];
|
|
403
368
|
/**
|
|
404
369
|
* ESC 3 n - Set line feed to n/144 inches
|
|
405
370
|
* Range: 18 ≤ n ≤ 255
|
|
406
371
|
* Takes effect immediately
|
|
407
372
|
*/
|
|
408
|
-
const setLineSpacing = (n) => {
|
|
373
|
+
export const setLineSpacing = (n) => {
|
|
409
374
|
const value = Math.max(18, Math.min(255, n));
|
|
410
|
-
return [
|
|
375
|
+
return [ESC, 0x33, value];
|
|
411
376
|
};
|
|
412
|
-
exports.setLineSpacing = setLineSpacing;
|
|
413
377
|
/**
|
|
414
378
|
* ESC f 1 n - Vertical skipping
|
|
415
379
|
* Range: 0 ≤ n ≤ 255
|
|
416
380
|
* Performs vertical skipping of n characters
|
|
417
381
|
* Alternate: 1B 66 01 n (same effect)
|
|
418
382
|
*/
|
|
419
|
-
const verticalSkip = (n) => {
|
|
383
|
+
export const verticalSkip = (n) => {
|
|
420
384
|
const value = Math.max(0, Math.min(255, n));
|
|
421
|
-
return [
|
|
385
|
+
return [ESC, 0x66, 0x31, value];
|
|
422
386
|
};
|
|
423
|
-
exports.verticalSkip = verticalSkip;
|
|
424
387
|
/**
|
|
425
388
|
* ESC f 0 n - Horizontal skipping
|
|
426
389
|
* Range: 0 ≤ n ≤ 255
|
|
427
390
|
* Performs horizontal skipping of n characters
|
|
428
391
|
* Alternate: 1B 66 00 n (same effect)
|
|
429
392
|
*/
|
|
430
|
-
const horizontalSkip = (n) => {
|
|
393
|
+
export const horizontalSkip = (n) => {
|
|
431
394
|
const value = Math.max(0, Math.min(255, n));
|
|
432
|
-
return [
|
|
395
|
+
return [ESC, 0x66, 0x30, value];
|
|
433
396
|
};
|
|
434
|
-
exports.horizontalSkip = horizontalSkip;
|
|
435
397
|
// ============================================================================
|
|
436
398
|
// PAGE CONFIGURATION
|
|
437
399
|
// ============================================================================
|
|
@@ -441,22 +403,20 @@ exports.horizontalSkip = horizontalSkip;
|
|
|
441
403
|
* Default: n = 12
|
|
442
404
|
* n represents number of single-height lines
|
|
443
405
|
*/
|
|
444
|
-
const setPageSizeLines = (lines) => {
|
|
406
|
+
export const setPageSizeLines = (lines) => {
|
|
445
407
|
const n = Math.max(1, Math.min(255, lines));
|
|
446
|
-
return [
|
|
408
|
+
return [ESC, 0x43, n];
|
|
447
409
|
};
|
|
448
|
-
exports.setPageSizeLines = setPageSizeLines;
|
|
449
410
|
/**
|
|
450
411
|
* ESC c n1 n2 - Set page size in millimeters
|
|
451
412
|
* Range: 0 ≤ n1 ≤ 255, 0 ≤ n2 ≤ 255
|
|
452
413
|
* Page size = 0.125mm × [n1 + (256 × n2)]
|
|
453
414
|
*/
|
|
454
|
-
const setPageSizeMM = (n1, n2) => {
|
|
415
|
+
export const setPageSizeMM = (n1, n2) => {
|
|
455
416
|
const v1 = Math.max(0, Math.min(255, n1));
|
|
456
417
|
const v2 = Math.max(0, Math.min(255, n2));
|
|
457
|
-
return [
|
|
418
|
+
return [ESC, 0x63, v1, v2];
|
|
458
419
|
};
|
|
459
|
-
exports.setPageSizeMM = setPageSizeMM;
|
|
460
420
|
// ============================================================================
|
|
461
421
|
// AUTOMATIC LINE FEED
|
|
462
422
|
// ============================================================================
|
|
@@ -466,10 +426,8 @@ exports.setPageSizeMM = setPageSizeMM;
|
|
|
466
426
|
* n = 1 or 49: Enable
|
|
467
427
|
* When enabled, printer performs LF after receiving CR
|
|
468
428
|
*/
|
|
469
|
-
const enableAutoLineFeed = () => [
|
|
470
|
-
|
|
471
|
-
const disableAutoLineFeed = () => [exports.ESC, 0x7A, 0x00];
|
|
472
|
-
exports.disableAutoLineFeed = disableAutoLineFeed;
|
|
429
|
+
export const enableAutoLineFeed = () => [ESC, 0x7A, 0x01];
|
|
430
|
+
export const disableAutoLineFeed = () => [ESC, 0x7A, 0x00];
|
|
473
431
|
// ============================================================================
|
|
474
432
|
// MARGINS & TABS
|
|
475
433
|
// ============================================================================
|
|
@@ -479,28 +437,26 @@ exports.disableAutoLineFeed = disableAutoLineFeed;
|
|
|
479
437
|
* Sets right margin in number of characters from default left margin
|
|
480
438
|
* New margin becomes valid only on next line if on right side of current position
|
|
481
439
|
*/
|
|
482
|
-
const setRightMargin = (chars) => {
|
|
440
|
+
export const setRightMargin = (chars) => {
|
|
483
441
|
const n = Math.max(0, Math.min(255, chars));
|
|
484
|
-
return [
|
|
442
|
+
return [ESC, 0x51, n];
|
|
485
443
|
};
|
|
486
|
-
exports.setRightMargin = setRightMargin;
|
|
487
444
|
/**
|
|
488
445
|
* ESC l n - Set left margin
|
|
489
446
|
* Range: 0 ≤ n ≤ 255
|
|
490
447
|
* Sets left margin in number of characters from default left margin
|
|
491
448
|
* New margin becomes valid only on next line if on left side of current position
|
|
492
449
|
*/
|
|
493
|
-
const setLeftMargin = (chars) => {
|
|
450
|
+
export const setLeftMargin = (chars) => {
|
|
494
451
|
const n = Math.max(0, Math.min(255, chars));
|
|
495
|
-
return [
|
|
452
|
+
return [ESC, 0x6C, n];
|
|
496
453
|
};
|
|
497
|
-
exports.setLeftMargin = setLeftMargin;
|
|
498
454
|
/**
|
|
499
455
|
* HT - Horizontal tab
|
|
500
456
|
* Moves print position to next tab mark
|
|
501
457
|
* Default: tabs at every 8 character columns (9, 17, 25, ...)
|
|
502
458
|
*/
|
|
503
|
-
|
|
459
|
+
export const TAB = [HT];
|
|
504
460
|
/**
|
|
505
461
|
* ESC D n1 ... nk NUL - Set horizontal tab marks
|
|
506
462
|
* Range: 1 ≤ n ≤ 255, 0 ≤ k ≤ 32
|
|
@@ -509,18 +465,17 @@ exports.TAB = [exports.HT];
|
|
|
509
465
|
* Example: setTabPositions([8, 16, 24]) sets tabs at columns 9, 17, 25
|
|
510
466
|
* Must be in ascending order and terminated with NUL
|
|
511
467
|
*/
|
|
512
|
-
const setTabPositions = (positions) => {
|
|
468
|
+
export const setTabPositions = (positions) => {
|
|
513
469
|
const validPositions = positions
|
|
514
470
|
.filter(p => p >= 1 && p <= 255)
|
|
515
471
|
.slice(0, 32)
|
|
516
472
|
.sort((a, b) => a - b);
|
|
517
|
-
return [
|
|
473
|
+
return [ESC, 0x44, ...validPositions, NUL];
|
|
518
474
|
};
|
|
519
|
-
exports.setTabPositions = setTabPositions;
|
|
520
475
|
/**
|
|
521
476
|
* ESC D NUL - Cancel all horizontal tab marks
|
|
522
477
|
*/
|
|
523
|
-
|
|
478
|
+
export const CLEAR_TABS = [ESC, 0x44, NUL];
|
|
524
479
|
// ============================================================================
|
|
525
480
|
// TEXT ALIGNMENT
|
|
526
481
|
// ============================================================================
|
|
@@ -530,9 +485,9 @@ exports.CLEAR_TABS = [exports.ESC, 0x44, exports.NUL];
|
|
|
530
485
|
* n = 1 or 49: Center justified
|
|
531
486
|
* n = 2 or 50: Right justified
|
|
532
487
|
*/
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
488
|
+
export const ALIGN_LEFT = [ESC, 0x61, 0x00];
|
|
489
|
+
export const ALIGN_CENTER = [ESC, 0x61, 0x01];
|
|
490
|
+
export const ALIGN_RIGHT = [ESC, 0x61, 0x02];
|
|
536
491
|
// ============================================================================
|
|
537
492
|
// TEXT FORMATTING - BOLD/EMPHASIZED
|
|
538
493
|
// ============================================================================
|
|
@@ -541,12 +496,12 @@ exports.ALIGN_RIGHT = [exports.ESC, 0x61, 0x02];
|
|
|
541
496
|
* Hexadecimal: 1B 45
|
|
542
497
|
* Emphasized mode is bolder than normal print
|
|
543
498
|
*/
|
|
544
|
-
|
|
499
|
+
export const BOLD_ON = [ESC, 0x45];
|
|
545
500
|
/**
|
|
546
501
|
* ESC F - Disable emphasized print mode (bold)
|
|
547
502
|
* Hexadecimal: 1B 46
|
|
548
503
|
*/
|
|
549
|
-
|
|
504
|
+
export const BOLD_OFF = [ESC, 0x46];
|
|
550
505
|
// ============================================================================
|
|
551
506
|
// TEXT FORMATTING - UNDERLINE
|
|
552
507
|
// ============================================================================
|
|
@@ -556,8 +511,8 @@ exports.BOLD_OFF = [exports.ESC, 0x46];
|
|
|
556
511
|
* n = 1 or 49: Enable
|
|
557
512
|
* Underlines every character and space
|
|
558
513
|
*/
|
|
559
|
-
|
|
560
|
-
|
|
514
|
+
export const UNDERLINE_ON = [ESC, 0x2D, 0x01];
|
|
515
|
+
export const UNDERLINE_OFF = [ESC, 0x2D, 0x00];
|
|
561
516
|
// ============================================================================
|
|
562
517
|
// TEXT FORMATTING - ITALIC
|
|
563
518
|
// ============================================================================
|
|
@@ -566,12 +521,12 @@ exports.UNDERLINE_OFF = [exports.ESC, 0x2D, 0x00];
|
|
|
566
521
|
* Hexadecimal: 1B 34
|
|
567
522
|
* Available in all other print modes
|
|
568
523
|
*/
|
|
569
|
-
|
|
524
|
+
export const ITALIC_ON = [ESC, 0x34];
|
|
570
525
|
/**
|
|
571
526
|
* ESC 5 - Disable italic print mode
|
|
572
527
|
* Hexadecimal: 1B 35
|
|
573
528
|
*/
|
|
574
|
-
|
|
529
|
+
export const ITALIC_OFF = [ESC, 0x35];
|
|
575
530
|
// ============================================================================
|
|
576
531
|
// TEXT FORMATTING - UPSIDE DOWN
|
|
577
532
|
// ============================================================================
|
|
@@ -580,8 +535,8 @@ exports.ITALIC_OFF = [exports.ESC, 0x35];
|
|
|
580
535
|
* n = 0 or 48: Disable (default)
|
|
581
536
|
* n = 1 or 49: Enable
|
|
582
537
|
*/
|
|
583
|
-
|
|
584
|
-
|
|
538
|
+
export const UPSIDE_DOWN_ON = [ESC, 0x7D, 0x01];
|
|
539
|
+
export const UPSIDE_DOWN_OFF = [ESC, 0x7D, 0x00];
|
|
585
540
|
// ============================================================================
|
|
586
541
|
// TEXT FORMATTING - SUPERSCRIPT/SUBSCRIPT
|
|
587
542
|
// ============================================================================
|
|
@@ -590,13 +545,13 @@ exports.UPSIDE_DOWN_OFF = [exports.ESC, 0x7D, 0x00];
|
|
|
590
545
|
* n = 0 or 48: Superscript (print on upper side of line)
|
|
591
546
|
* n = 1 or 49: Subscript (print on bottom side of line)
|
|
592
547
|
*/
|
|
593
|
-
|
|
594
|
-
|
|
548
|
+
export const SUPERSCRIPT_ON = [ESC, 0x53, 0x00];
|
|
549
|
+
export const SUBSCRIPT_ON = [ESC, 0x53, 0x01];
|
|
595
550
|
/**
|
|
596
551
|
* ESC T - Disable superscript and subscript print modes
|
|
597
552
|
* Hexadecimal: 1B 54
|
|
598
553
|
*/
|
|
599
|
-
|
|
554
|
+
export const SCRIPT_OFF = [ESC, 0x54];
|
|
600
555
|
// ============================================================================
|
|
601
556
|
// TEXT FORMATTING - COMBINED MODE (ESC !)
|
|
602
557
|
// ============================================================================
|
|
@@ -611,7 +566,7 @@ exports.SCRIPT_OFF = [exports.ESC, 0x54];
|
|
|
611
566
|
* 6: Undefined
|
|
612
567
|
* 7: Underline (0=clear, 1=set)
|
|
613
568
|
*/
|
|
614
|
-
const calculatePrintMode = (options) => {
|
|
569
|
+
export const calculatePrintMode = (options) => {
|
|
615
570
|
// Use Font B (narrower, 9×17 dots) for consistency with ESC/POS
|
|
616
571
|
// Font B fits more characters per line (better for 48-char receipts)
|
|
617
572
|
let n = 0x01; // Bit 0 - Font B
|
|
@@ -623,9 +578,8 @@ const calculatePrintMode = (options) => {
|
|
|
623
578
|
n |= 0x20; // Bit 5
|
|
624
579
|
if (options.underline)
|
|
625
580
|
n |= 0x80; // Bit 7
|
|
626
|
-
return [
|
|
581
|
+
return [ESC, 0x21, n];
|
|
627
582
|
};
|
|
628
|
-
exports.calculatePrintMode = calculatePrintMode;
|
|
629
583
|
// ============================================================================
|
|
630
584
|
// CHARACTER SIZING - DOUBLE HEIGHT
|
|
631
585
|
// ============================================================================
|
|
@@ -636,15 +590,15 @@ exports.calculatePrintMode = calculatePrintMode;
|
|
|
636
590
|
*
|
|
637
591
|
* IMPORTANT: This is different from ESC/POS where ESC d is used for line feed
|
|
638
592
|
*/
|
|
639
|
-
|
|
640
|
-
|
|
593
|
+
export const DOUBLE_HEIGHT_ON = [ESC, 0x64, 0x01];
|
|
594
|
+
export const DOUBLE_HEIGHT_OFF = [ESC, 0x64, 0x00];
|
|
641
595
|
/**
|
|
642
596
|
* ESC V - Enable on-line double height mode
|
|
643
597
|
* If received at beginning of line: valid for whole line
|
|
644
598
|
* Otherwise: valid only for next incoming characters
|
|
645
599
|
* Returns to normal mode on next line
|
|
646
600
|
*/
|
|
647
|
-
|
|
601
|
+
export const DOUBLE_HEIGHT_ONLINE = [ESC, 0x56];
|
|
648
602
|
// ============================================================================
|
|
649
603
|
// CHARACTER SIZING - DOUBLE WIDTH (EXPANDED)
|
|
650
604
|
// ============================================================================
|
|
@@ -654,8 +608,8 @@ exports.DOUBLE_HEIGHT_ONLINE = [exports.ESC, 0x56];
|
|
|
654
608
|
* n = 1 or 49: Enable
|
|
655
609
|
* Takes effect immediately
|
|
656
610
|
*/
|
|
657
|
-
|
|
658
|
-
|
|
611
|
+
export const DOUBLE_WIDTH_ON = [ESC, 0x57, 0x01];
|
|
612
|
+
export const DOUBLE_WIDTH_OFF = [ESC, 0x57, 0x00];
|
|
659
613
|
/**
|
|
660
614
|
* ESC SO - Enable on-line expanded mode
|
|
661
615
|
* Hexadecimal: 1B 0E
|
|
@@ -663,19 +617,19 @@ exports.DOUBLE_WIDTH_OFF = [exports.ESC, 0x57, 0x00];
|
|
|
663
617
|
* Otherwise: valid only for next incoming characters
|
|
664
618
|
* Returns to normal mode on next line
|
|
665
619
|
*/
|
|
666
|
-
|
|
620
|
+
export const EXPANDED_ONLINE = [ESC, SO];
|
|
667
621
|
/**
|
|
668
622
|
* SO - Enable on-line expanded mode (alternate)
|
|
669
623
|
* Hexadecimal: 0E
|
|
670
624
|
* Same as ESC SO
|
|
671
625
|
*/
|
|
672
|
-
|
|
626
|
+
export const EXPANDED_ONLINE_ALT = [SO];
|
|
673
627
|
/**
|
|
674
628
|
* DC4 - Disable on-line expanded print
|
|
675
629
|
* Hexadecimal: 14
|
|
676
630
|
* Disables expanded mode if previously set by ESC SO or SO
|
|
677
631
|
*/
|
|
678
|
-
|
|
632
|
+
export const EXPANDED_OFF = [DC4];
|
|
679
633
|
// ============================================================================
|
|
680
634
|
// CHARACTER SIZING - CONDENSED
|
|
681
635
|
// ============================================================================
|
|
@@ -683,31 +637,31 @@ exports.EXPANDED_OFF = [exports.DC4];
|
|
|
683
637
|
* ESC SI - Enable condensed mode
|
|
684
638
|
* Hexadecimal: 1B 0F
|
|
685
639
|
*/
|
|
686
|
-
|
|
640
|
+
export const CONDENSED_ON = [ESC, SI];
|
|
687
641
|
/**
|
|
688
642
|
* SI - Enable condensed mode (alternate)
|
|
689
643
|
* Hexadecimal: 0F
|
|
690
644
|
* Same as ESC SI
|
|
691
645
|
*/
|
|
692
|
-
|
|
646
|
+
export const CONDENSED_ON_ALT = [SI];
|
|
693
647
|
/**
|
|
694
648
|
* ESC H - Disable condensed mode
|
|
695
649
|
* Hexadecimal: 1B 48
|
|
696
650
|
* Same as DC2 or ESC P
|
|
697
651
|
*/
|
|
698
|
-
|
|
652
|
+
export const CONDENSED_OFF = [ESC, 0x48];
|
|
699
653
|
/**
|
|
700
654
|
* ESC P - Disable condensed mode (alternate)
|
|
701
655
|
* Hexadecimal: 1B 50
|
|
702
656
|
* Same as DC2 or ESC H
|
|
703
657
|
*/
|
|
704
|
-
|
|
658
|
+
export const CONDENSED_OFF_ALT = [ESC, 0x50];
|
|
705
659
|
/**
|
|
706
660
|
* DC2 - Disable condensed mode (alternate)
|
|
707
661
|
* Hexadecimal: 12
|
|
708
662
|
* Same as ESC H or ESC P
|
|
709
663
|
*/
|
|
710
|
-
|
|
664
|
+
export const CONDENSED_OFF_DC2 = [DC2];
|
|
711
665
|
// ============================================================================
|
|
712
666
|
// GRAPHICS - BIT IMAGES
|
|
713
667
|
// ============================================================================
|
|
@@ -716,12 +670,11 @@ exports.CONDENSED_OFF_DC2 = [exports.DC2];
|
|
|
716
670
|
* Fills blank bit columns from current column to column (n1 + n2 × 256)
|
|
717
671
|
* Must be ≤ printing width N
|
|
718
672
|
*/
|
|
719
|
-
const fillBlankColumns = (columns) => {
|
|
673
|
+
export const fillBlankColumns = (columns) => {
|
|
720
674
|
const n1 = columns & 0xFF;
|
|
721
675
|
const n2 = (columns >> 8) & 0xFF;
|
|
722
|
-
return [
|
|
676
|
+
return [ESC, 0x24, n1, n2];
|
|
723
677
|
};
|
|
724
|
-
exports.fillBlankColumns = fillBlankColumns;
|
|
725
678
|
/**
|
|
726
679
|
* ESC * ! n1 n2 b1 ... bn - 24-bit graphics
|
|
727
680
|
* Hexadecimal: 1B 2A 21 n1 n2 b1 ... bn
|
|
@@ -729,12 +682,11 @@ exports.fillBlankColumns = fillBlankColumns;
|
|
|
729
682
|
* Each column = 3 bytes (24 bits height)
|
|
730
683
|
* Total bytes needed = columns × 3
|
|
731
684
|
*/
|
|
732
|
-
const print24BitGraphics = (columns, data) => {
|
|
685
|
+
export const print24BitGraphics = (columns, data) => {
|
|
733
686
|
const n1 = columns & 0xFF;
|
|
734
687
|
const n2 = (columns >> 8) & 0xFF;
|
|
735
|
-
return [
|
|
688
|
+
return [ESC, 0x2A, 0x21, n1, n2, ...data];
|
|
736
689
|
};
|
|
737
|
-
exports.print24BitGraphics = print24BitGraphics;
|
|
738
690
|
/**
|
|
739
691
|
* ESC K n1 n2 b1 ... bn - 8-bit graphics
|
|
740
692
|
* Hexadecimal: 1B 4B n1 n2 b1 ... bn
|
|
@@ -742,25 +694,24 @@ exports.print24BitGraphics = print24BitGraphics;
|
|
|
742
694
|
* Columns = n1 + (n2 × 256), each column = 1 byte
|
|
743
695
|
* Low resolution (expanded to 3 bytes internally)
|
|
744
696
|
*/
|
|
745
|
-
const print8BitGraphics = (columns, data) => {
|
|
697
|
+
export const print8BitGraphics = (columns, data) => {
|
|
746
698
|
const n1 = columns & 0xFF;
|
|
747
699
|
const n2 = (columns >> 8) & 0xFF;
|
|
748
|
-
return [
|
|
700
|
+
return [ESC, 0x4B, n1, n2, ...data];
|
|
749
701
|
};
|
|
750
|
-
exports.print8BitGraphics = print8BitGraphics;
|
|
751
702
|
// ============================================================================
|
|
752
703
|
// GRAPHICS - RASTER BITMAP
|
|
753
704
|
// ============================================================================
|
|
754
705
|
/**
|
|
755
706
|
* Raster bitmap print modes
|
|
756
707
|
*/
|
|
757
|
-
var RasterMode;
|
|
708
|
+
export var RasterMode;
|
|
758
709
|
(function (RasterMode) {
|
|
759
710
|
RasterMode[RasterMode["NORMAL"] = 0] = "NORMAL";
|
|
760
711
|
RasterMode[RasterMode["DOUBLE_WIDTH"] = 1] = "DOUBLE_WIDTH";
|
|
761
712
|
RasterMode[RasterMode["DOUBLE_HEIGHT"] = 2] = "DOUBLE_HEIGHT";
|
|
762
713
|
RasterMode[RasterMode["QUADRUPLE"] = 3] = "QUADRUPLE"; // 101 dpi × 101 dpi
|
|
763
|
-
})(RasterMode || (
|
|
714
|
+
})(RasterMode || (RasterMode = {}));
|
|
764
715
|
/**
|
|
765
716
|
* GS v 0 m xL xH yL yH d1 ... dk - Print raster bitmap
|
|
766
717
|
* m: Mode (0-3 or 48-51)
|
|
@@ -771,14 +722,13 @@ var RasterMode;
|
|
|
771
722
|
* Data outside printing area is discarded
|
|
772
723
|
* Affected by HT, ESC $, ESC \, GS L, and ESC a
|
|
773
724
|
*/
|
|
774
|
-
const printRasterBitmap = (mode, width, height, data) => {
|
|
725
|
+
export const printRasterBitmap = (mode, width, height, data) => {
|
|
775
726
|
const xL = width & 0xFF;
|
|
776
727
|
const xH = (width >> 8) & 0xFF;
|
|
777
728
|
const yL = height & 0xFF;
|
|
778
729
|
const yH = (height >> 8) & 0xFF;
|
|
779
|
-
return [
|
|
730
|
+
return [GS, 0x76, 0x30, mode, xL, xH, yL, yH, ...data];
|
|
780
731
|
};
|
|
781
|
-
exports.printRasterBitmap = printRasterBitmap;
|
|
782
732
|
// ============================================================================
|
|
783
733
|
// GRAPHICS - DOWNLOADED BIT IMAGE
|
|
784
734
|
// ============================================================================
|
|
@@ -790,19 +740,17 @@ exports.printRasterBitmap = printRasterBitmap;
|
|
|
790
740
|
*
|
|
791
741
|
* Cleared by: ESC @, FS q, printer restart, or power cycle
|
|
792
742
|
*/
|
|
793
|
-
const defineDownloadedBitImage = (x, y, data) => {
|
|
743
|
+
export const defineDownloadedBitImage = (x, y, data) => {
|
|
794
744
|
const xVal = Math.max(1, Math.min(255, x));
|
|
795
745
|
const yVal = Math.max(1, Math.min(64, y));
|
|
796
|
-
return [
|
|
746
|
+
return [GS, 0x2A, xVal, yVal, ...data];
|
|
797
747
|
};
|
|
798
|
-
exports.defineDownloadedBitImage = defineDownloadedBitImage;
|
|
799
748
|
/**
|
|
800
749
|
* GS / m - Print downloaded bit image
|
|
801
750
|
* m: Mode (0-3 or 48-51) - same as RasterMode
|
|
802
751
|
* No effect if downloaded image not defined
|
|
803
752
|
*/
|
|
804
|
-
const printDownloadedBitImage = (mode) => [
|
|
805
|
-
exports.printDownloadedBitImage = printDownloadedBitImage;
|
|
753
|
+
export const printDownloadedBitImage = (mode) => [GS, 0x2F, mode];
|
|
806
754
|
// ============================================================================
|
|
807
755
|
// GRAPHICS - NON-VOLATILE (NV) BIT IMAGE
|
|
808
756
|
// ============================================================================
|
|
@@ -816,8 +764,8 @@ exports.printDownloadedBitImage = printDownloadedBitImage;
|
|
|
816
764
|
*
|
|
817
765
|
* Erases all previously defined NV images
|
|
818
766
|
*/
|
|
819
|
-
const defineNVBitImage = (images) => {
|
|
820
|
-
const result = [
|
|
767
|
+
export const defineNVBitImage = (images) => {
|
|
768
|
+
const result = [FS, 0x71, images.length];
|
|
821
769
|
for (const img of images) {
|
|
822
770
|
const xL = img.width & 0xFF;
|
|
823
771
|
const xH = (img.width >> 8) & 0xFF;
|
|
@@ -827,15 +775,13 @@ const defineNVBitImage = (images) => {
|
|
|
827
775
|
}
|
|
828
776
|
return result;
|
|
829
777
|
};
|
|
830
|
-
exports.defineNVBitImage = defineNVBitImage;
|
|
831
778
|
/**
|
|
832
779
|
* FS p n m - Print non-volatile (NV) bit image
|
|
833
780
|
* n: NV bit image number (as defined by FS q)
|
|
834
781
|
* m: Mode (0-3 or 48-51) - same as RasterMode
|
|
835
782
|
* No effect if n-th NV image not defined
|
|
836
783
|
*/
|
|
837
|
-
const printNVBitImage = (imageNumber, mode) => [
|
|
838
|
-
exports.printNVBitImage = printNVBitImage;
|
|
784
|
+
export const printNVBitImage = (imageNumber, mode) => [FS, 0x70, imageNumber, mode];
|
|
839
785
|
// ============================================================================
|
|
840
786
|
// BARCODES - CONFIGURATION
|
|
841
787
|
// ============================================================================
|
|
@@ -845,11 +791,10 @@ exports.printNVBitImage = printNVBitImage;
|
|
|
845
791
|
* Default: n = 162
|
|
846
792
|
* Height = n × 0.125mm
|
|
847
793
|
*/
|
|
848
|
-
const setBarcodeHeight = (n) => {
|
|
794
|
+
export const setBarcodeHeight = (n) => {
|
|
849
795
|
const height = Math.max(1, Math.min(255, n));
|
|
850
|
-
return [
|
|
796
|
+
return [GS, 0x68, height];
|
|
851
797
|
};
|
|
852
|
-
exports.setBarcodeHeight = setBarcodeHeight;
|
|
853
798
|
/**
|
|
854
799
|
* GS w n - Set barcode width
|
|
855
800
|
* Range: 2 ≤ n ≤ 4
|
|
@@ -858,42 +803,38 @@ exports.setBarcodeHeight = setBarcodeHeight;
|
|
|
858
803
|
* n = 3: Double width
|
|
859
804
|
* n = 4: Quadruple width
|
|
860
805
|
*/
|
|
861
|
-
const setBarcodeWidth = (width) => [
|
|
862
|
-
exports.setBarcodeWidth = setBarcodeWidth;
|
|
806
|
+
export const setBarcodeWidth = (width) => [GS, 0x77, width];
|
|
863
807
|
/**
|
|
864
808
|
* Human Readable Information (HRI) position
|
|
865
809
|
*/
|
|
866
|
-
var BarcodeHRIPosition;
|
|
810
|
+
export var BarcodeHRIPosition;
|
|
867
811
|
(function (BarcodeHRIPosition) {
|
|
868
812
|
BarcodeHRIPosition[BarcodeHRIPosition["NONE"] = 0] = "NONE";
|
|
869
813
|
BarcodeHRIPosition[BarcodeHRIPosition["TOP"] = 1] = "TOP";
|
|
870
814
|
BarcodeHRIPosition[BarcodeHRIPosition["BOTTOM"] = 2] = "BOTTOM";
|
|
871
815
|
BarcodeHRIPosition[BarcodeHRIPosition["BOTH"] = 3] = "BOTH"; // HRI on both top and bottom
|
|
872
|
-
})(BarcodeHRIPosition || (
|
|
816
|
+
})(BarcodeHRIPosition || (BarcodeHRIPosition = {}));
|
|
873
817
|
/**
|
|
874
818
|
* GS H n - Choose HRI position in barcode
|
|
875
819
|
* Range: 0 ≤ n ≤ 3
|
|
876
820
|
* Default: n = 1 (top)
|
|
877
821
|
*/
|
|
878
|
-
const setBarcodeHRI = (position) => [
|
|
879
|
-
exports.setBarcodeHRI = setBarcodeHRI;
|
|
822
|
+
export const setBarcodeHRI = (position) => [GS, 0x48, position];
|
|
880
823
|
/**
|
|
881
824
|
* GS f n - Set HRI font
|
|
882
825
|
* n = 0 or 48: Normal font (default)
|
|
883
826
|
* n = 1 or 49: Condensed font
|
|
884
827
|
*/
|
|
885
|
-
const setBarcodeHRIFont = (condensed) => [
|
|
886
|
-
exports.setBarcodeHRIFont = setBarcodeHRIFont;
|
|
828
|
+
export const setBarcodeHRIFont = (condensed) => [GS, 0x66, condensed ? 0x01 : 0x00];
|
|
887
829
|
/**
|
|
888
830
|
* GS k 84h n1 n2 - Program barcode left margin
|
|
889
831
|
* Margin position = n1 + n2 × 256
|
|
890
832
|
*/
|
|
891
|
-
const setBarcodeLeftMargin = (position) => {
|
|
833
|
+
export const setBarcodeLeftMargin = (position) => {
|
|
892
834
|
const n1 = position & 0xFF;
|
|
893
835
|
const n2 = (position >> 8) & 0xFF;
|
|
894
|
-
return [
|
|
836
|
+
return [GS, 0x6B, 0x84, n1, n2];
|
|
895
837
|
};
|
|
896
|
-
exports.setBarcodeLeftMargin = setBarcodeLeftMargin;
|
|
897
838
|
// ============================================================================
|
|
898
839
|
// BARCODES - UPC-A
|
|
899
840
|
// ============================================================================
|
|
@@ -902,26 +843,24 @@ exports.setBarcodeLeftMargin = setBarcodeLeftMargin;
|
|
|
902
843
|
* Range: 48 ≤ dn ≤ 57 (ASCII digits '0'-'9')
|
|
903
844
|
* Requires exactly 11 digits, checksum generated automatically
|
|
904
845
|
*/
|
|
905
|
-
const printBarcodeUPCA = (data) => {
|
|
846
|
+
export const printBarcodeUPCA = (data) => {
|
|
906
847
|
if (data.length !== 11 || !/^\d{11}$/.test(data)) {
|
|
907
848
|
throw new Error('UPC-A requires exactly 11 digits');
|
|
908
849
|
}
|
|
909
850
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
910
|
-
return [
|
|
851
|
+
return [GS, 0x6B, NUL, ...bytes, NUL];
|
|
911
852
|
};
|
|
912
|
-
exports.printBarcodeUPCA = printBarcodeUPCA;
|
|
913
853
|
/**
|
|
914
854
|
* GS k A VT d1 ... d11 - Print UPC-A barcode (alternate)
|
|
915
855
|
* Same as GS k NUL variant
|
|
916
856
|
*/
|
|
917
|
-
const printBarcodeUPCAAlt = (data) => {
|
|
857
|
+
export const printBarcodeUPCAAlt = (data) => {
|
|
918
858
|
if (data.length !== 11 || !/^\d{11}$/.test(data)) {
|
|
919
859
|
throw new Error('UPC-A requires exactly 11 digits');
|
|
920
860
|
}
|
|
921
861
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
922
|
-
return [
|
|
862
|
+
return [GS, 0x6B, 0x41, 0x0B, ...bytes];
|
|
923
863
|
};
|
|
924
|
-
exports.printBarcodeUPCAAlt = printBarcodeUPCAAlt;
|
|
925
864
|
// ============================================================================
|
|
926
865
|
// BARCODES - UPC-E
|
|
927
866
|
// ============================================================================
|
|
@@ -930,25 +869,23 @@ exports.printBarcodeUPCAAlt = printBarcodeUPCAAlt;
|
|
|
930
869
|
* Range: 48 ≤ dn ≤ 57 (ASCII digits '0'-'9')
|
|
931
870
|
* Requires exactly 6 digits, checksum generated automatically
|
|
932
871
|
*/
|
|
933
|
-
const printBarcodeUPCE = (data) => {
|
|
872
|
+
export const printBarcodeUPCE = (data) => {
|
|
934
873
|
if (data.length !== 6 || !/^\d{6}$/.test(data)) {
|
|
935
874
|
throw new Error('UPC-E requires exactly 6 digits');
|
|
936
875
|
}
|
|
937
876
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
938
|
-
return [
|
|
877
|
+
return [GS, 0x6B, SOH, ...bytes, NUL];
|
|
939
878
|
};
|
|
940
|
-
exports.printBarcodeUPCE = printBarcodeUPCE;
|
|
941
879
|
/**
|
|
942
880
|
* GS k B ACK d1 ... d6 - Print UPC-E barcode (alternate)
|
|
943
881
|
*/
|
|
944
|
-
const printBarcodeUPCEAlt = (data) => {
|
|
882
|
+
export const printBarcodeUPCEAlt = (data) => {
|
|
945
883
|
if (data.length !== 6 || !/^\d{6}$/.test(data)) {
|
|
946
884
|
throw new Error('UPC-E requires exactly 6 digits');
|
|
947
885
|
}
|
|
948
886
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
949
|
-
return [
|
|
887
|
+
return [GS, 0x6B, 0x42, 0x06, ...bytes];
|
|
950
888
|
};
|
|
951
|
-
exports.printBarcodeUPCEAlt = printBarcodeUPCEAlt;
|
|
952
889
|
// ============================================================================
|
|
953
890
|
// BARCODES - EAN-13
|
|
954
891
|
// ============================================================================
|
|
@@ -957,25 +894,23 @@ exports.printBarcodeUPCEAlt = printBarcodeUPCEAlt;
|
|
|
957
894
|
* Range: 48 ≤ dn ≤ 57 (ASCII digits '0'-'9')
|
|
958
895
|
* Requires exactly 12 digits, 13th digit generated automatically
|
|
959
896
|
*/
|
|
960
|
-
const printBarcodeEAN13 = (data) => {
|
|
897
|
+
export const printBarcodeEAN13 = (data) => {
|
|
961
898
|
if (data.length !== 12 || !/^\d{12}$/.test(data)) {
|
|
962
899
|
throw new Error('EAN-13 requires exactly 12 digits');
|
|
963
900
|
}
|
|
964
901
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
965
|
-
return [
|
|
902
|
+
return [GS, 0x6B, STX, ...bytes, NUL];
|
|
966
903
|
};
|
|
967
|
-
exports.printBarcodeEAN13 = printBarcodeEAN13;
|
|
968
904
|
/**
|
|
969
905
|
* GS k C FF d1 ... d12 - Print EAN-13 barcode (alternate)
|
|
970
906
|
*/
|
|
971
|
-
const printBarcodeEAN13Alt = (data) => {
|
|
907
|
+
export const printBarcodeEAN13Alt = (data) => {
|
|
972
908
|
if (data.length !== 12 || !/^\d{12}$/.test(data)) {
|
|
973
909
|
throw new Error('EAN-13 requires exactly 12 digits');
|
|
974
910
|
}
|
|
975
911
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
976
|
-
return [
|
|
912
|
+
return [GS, 0x6B, 0x43, 0x0C, ...bytes];
|
|
977
913
|
};
|
|
978
|
-
exports.printBarcodeEAN13Alt = printBarcodeEAN13Alt;
|
|
979
914
|
// ============================================================================
|
|
980
915
|
// BARCODES - EAN-8
|
|
981
916
|
// ============================================================================
|
|
@@ -984,25 +919,23 @@ exports.printBarcodeEAN13Alt = printBarcodeEAN13Alt;
|
|
|
984
919
|
* Range: 48 ≤ dn ≤ 57 (ASCII digits '0'-'9')
|
|
985
920
|
* Requires exactly 7 digits, 8th digit generated automatically
|
|
986
921
|
*/
|
|
987
|
-
const printBarcodeEAN8 = (data) => {
|
|
922
|
+
export const printBarcodeEAN8 = (data) => {
|
|
988
923
|
if (data.length !== 7 || !/^\d{7}$/.test(data)) {
|
|
989
924
|
throw new Error('EAN-8 requires exactly 7 digits');
|
|
990
925
|
}
|
|
991
926
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
992
|
-
return [
|
|
927
|
+
return [GS, 0x6B, ETX, ...bytes, NUL];
|
|
993
928
|
};
|
|
994
|
-
exports.printBarcodeEAN8 = printBarcodeEAN8;
|
|
995
929
|
/**
|
|
996
930
|
* GS k D BEL d1 ... d7 - Print EAN-8 barcode (alternate)
|
|
997
931
|
*/
|
|
998
|
-
const printBarcodeEAN8Alt = (data) => {
|
|
932
|
+
export const printBarcodeEAN8Alt = (data) => {
|
|
999
933
|
if (data.length !== 7 || !/^\d{7}$/.test(data)) {
|
|
1000
934
|
throw new Error('EAN-8 requires exactly 7 digits');
|
|
1001
935
|
}
|
|
1002
936
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
1003
|
-
return [
|
|
937
|
+
return [GS, 0x6B, 0x44, 0x07, ...bytes];
|
|
1004
938
|
};
|
|
1005
|
-
exports.printBarcodeEAN8Alt = printBarcodeEAN8Alt;
|
|
1006
939
|
// ============================================================================
|
|
1007
940
|
// BARCODES - CODE 39
|
|
1008
941
|
// ============================================================================
|
|
@@ -1012,25 +945,23 @@ exports.printBarcodeEAN8Alt = printBarcodeEAN8Alt;
|
|
|
1012
945
|
* Checksum generated automatically
|
|
1013
946
|
* Length limited by physical print width and barcode width setting
|
|
1014
947
|
*/
|
|
1015
|
-
const printBarcodeCODE39 = (data) => {
|
|
948
|
+
export const printBarcodeCODE39 = (data) => {
|
|
1016
949
|
if (!/^[ $%*+\-./0-9A-Z]+$/.test(data)) {
|
|
1017
950
|
throw new Error('CODE 39 supports: space, $%*+-./, 0-9, A-Z');
|
|
1018
951
|
}
|
|
1019
952
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
1020
|
-
return [
|
|
953
|
+
return [GS, 0x6B, EOT, ...bytes, NUL];
|
|
1021
954
|
};
|
|
1022
|
-
exports.printBarcodeCODE39 = printBarcodeCODE39;
|
|
1023
955
|
/**
|
|
1024
956
|
* GS k E n d1 ... dn - Print CODE 39 barcode (alternate)
|
|
1025
957
|
*/
|
|
1026
|
-
const printBarcodeCODE39Alt = (data) => {
|
|
958
|
+
export const printBarcodeCODE39Alt = (data) => {
|
|
1027
959
|
if (!/^[ $%*+\-./0-9A-Z]+$/.test(data)) {
|
|
1028
960
|
throw new Error('CODE 39 supports: space, $%*+-./, 0-9, A-Z');
|
|
1029
961
|
}
|
|
1030
962
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
1031
|
-
return [
|
|
963
|
+
return [GS, 0x6B, 0x45, bytes.length, ...bytes];
|
|
1032
964
|
};
|
|
1033
|
-
exports.printBarcodeCODE39Alt = printBarcodeCODE39Alt;
|
|
1034
965
|
// ============================================================================
|
|
1035
966
|
// BARCODES - ITF (Interleaved 2 of 5)
|
|
1036
967
|
// ============================================================================
|
|
@@ -1039,25 +970,23 @@ exports.printBarcodeCODE39Alt = printBarcodeCODE39Alt;
|
|
|
1039
970
|
* Range: 48 ≤ dn ≤ 57 (ASCII digits '0'-'9')
|
|
1040
971
|
* Length limited by physical print width and barcode width setting
|
|
1041
972
|
*/
|
|
1042
|
-
const printBarcodeITF = (data) => {
|
|
973
|
+
export const printBarcodeITF = (data) => {
|
|
1043
974
|
if (!/^\d+$/.test(data)) {
|
|
1044
975
|
throw new Error('ITF requires only digits 0-9');
|
|
1045
976
|
}
|
|
1046
977
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
1047
|
-
return [
|
|
978
|
+
return [GS, 0x6B, ENQ, ...bytes, NUL];
|
|
1048
979
|
};
|
|
1049
|
-
exports.printBarcodeITF = printBarcodeITF;
|
|
1050
980
|
/**
|
|
1051
981
|
* GS k F n d1 ... dn - Print ITF barcode (alternate)
|
|
1052
982
|
*/
|
|
1053
|
-
const printBarcodeITFAlt = (data) => {
|
|
983
|
+
export const printBarcodeITFAlt = (data) => {
|
|
1054
984
|
if (!/^\d+$/.test(data)) {
|
|
1055
985
|
throw new Error('ITF requires only digits 0-9');
|
|
1056
986
|
}
|
|
1057
987
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
1058
|
-
return [
|
|
988
|
+
return [GS, 0x6B, 0x46, bytes.length, ...bytes];
|
|
1059
989
|
};
|
|
1060
|
-
exports.printBarcodeITFAlt = printBarcodeITFAlt;
|
|
1061
990
|
// ============================================================================
|
|
1062
991
|
// BARCODES - CODABAR
|
|
1063
992
|
// ============================================================================
|
|
@@ -1067,25 +996,23 @@ exports.printBarcodeITFAlt = printBarcodeITFAlt;
|
|
|
1067
996
|
* Cannot mix uppercase and lowercase letters
|
|
1068
997
|
* If d1 is letter, dn must also be letter
|
|
1069
998
|
*/
|
|
1070
|
-
const printBarcodeCODABAR = (data) => {
|
|
999
|
+
export const printBarcodeCODABAR = (data) => {
|
|
1071
1000
|
if (!/^[$+\-./0-9A-D]+$/.test(data) && !/^[$+\-./0-9a-d]+$/.test(data)) {
|
|
1072
1001
|
throw new Error('CODABAR supports: $+-./, 0-9, A-D (or a-d, not mixed)');
|
|
1073
1002
|
}
|
|
1074
1003
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
1075
|
-
return [
|
|
1004
|
+
return [GS, 0x6B, ACK, ...bytes, NUL];
|
|
1076
1005
|
};
|
|
1077
|
-
exports.printBarcodeCODABAR = printBarcodeCODABAR;
|
|
1078
1006
|
/**
|
|
1079
1007
|
* GS k G n d1 ... dn - Print CODABAR barcode (alternate)
|
|
1080
1008
|
*/
|
|
1081
|
-
const printBarcodeCODABARAlt = (data) => {
|
|
1009
|
+
export const printBarcodeCODABARAlt = (data) => {
|
|
1082
1010
|
if (!/^[$+\-./0-9A-D]+$/.test(data) && !/^[$+\-./0-9a-d]+$/.test(data)) {
|
|
1083
1011
|
throw new Error('CODABAR supports: $+-./, 0-9, A-D (or a-d, not mixed)');
|
|
1084
1012
|
}
|
|
1085
1013
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
1086
|
-
return [
|
|
1014
|
+
return [GS, 0x6B, 0x47, bytes.length, ...bytes];
|
|
1087
1015
|
};
|
|
1088
|
-
exports.printBarcodeCODABARAlt = printBarcodeCODABARAlt;
|
|
1089
1016
|
// ============================================================================
|
|
1090
1017
|
// BARCODES - CODE 93
|
|
1091
1018
|
// ============================================================================
|
|
@@ -1094,14 +1021,13 @@ exports.printBarcodeCODABARAlt = printBarcodeCODABARAlt;
|
|
|
1094
1021
|
* Range: 0 ≤ dn ≤ 127 (all ASCII characters)
|
|
1095
1022
|
* Checksum generated automatically
|
|
1096
1023
|
*/
|
|
1097
|
-
const printBarcodeCODE93 = (data) => {
|
|
1024
|
+
export const printBarcodeCODE93 = (data) => {
|
|
1098
1025
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
1099
1026
|
if (bytes.some(b => b > 127)) {
|
|
1100
1027
|
throw new Error('CODE 93 supports ASCII 0-127');
|
|
1101
1028
|
}
|
|
1102
|
-
return [
|
|
1029
|
+
return [GS, 0x6B, 0x48, bytes.length, ...bytes];
|
|
1103
1030
|
};
|
|
1104
|
-
exports.printBarcodeCODE93 = printBarcodeCODE93;
|
|
1105
1031
|
// ============================================================================
|
|
1106
1032
|
// BARCODES - CODE 128
|
|
1107
1033
|
// ============================================================================
|
|
@@ -1110,14 +1036,13 @@ exports.printBarcodeCODE93 = printBarcodeCODE93;
|
|
|
1110
1036
|
* Range: 0 ≤ dn ≤ 127 (all ASCII characters)
|
|
1111
1037
|
* Checksum generated automatically
|
|
1112
1038
|
*/
|
|
1113
|
-
const printBarcodeCODE128 = (data) => {
|
|
1039
|
+
export const printBarcodeCODE128 = (data) => {
|
|
1114
1040
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
1115
1041
|
if (bytes.some(b => b > 127)) {
|
|
1116
1042
|
throw new Error('CODE 128 supports ASCII 0-127');
|
|
1117
1043
|
}
|
|
1118
|
-
return [
|
|
1044
|
+
return [GS, 0x6B, 0x49, bytes.length, ...bytes];
|
|
1119
1045
|
};
|
|
1120
|
-
exports.printBarcodeCODE128 = printBarcodeCODE128;
|
|
1121
1046
|
// ============================================================================
|
|
1122
1047
|
// BARCODES - PDF-417
|
|
1123
1048
|
// ============================================================================
|
|
@@ -1129,7 +1054,7 @@ exports.printBarcodeCODE128 = printBarcodeCODE128;
|
|
|
1129
1054
|
* n4: Codewords per row (0 = max for pitch width)
|
|
1130
1055
|
* n5, n6: Byte count (n5 + n6 × 256, must be < 900)
|
|
1131
1056
|
*/
|
|
1132
|
-
const printBarcodePDF417 = (eccLevel, pitchHeight, pitchWidth, codewordsPerRow, data) => {
|
|
1057
|
+
export const printBarcodePDF417 = (eccLevel, pitchHeight, pitchWidth, codewordsPerRow, data) => {
|
|
1133
1058
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
1134
1059
|
const totalBytes = bytes.length;
|
|
1135
1060
|
if (totalBytes >= 900) {
|
|
@@ -1141,9 +1066,8 @@ const printBarcodePDF417 = (eccLevel, pitchHeight, pitchWidth, codewordsPerRow,
|
|
|
1141
1066
|
const n4 = Math.max(0, Math.min(255, codewordsPerRow));
|
|
1142
1067
|
const n5 = totalBytes & 0xFF;
|
|
1143
1068
|
const n6 = (totalBytes >> 8) & 0xFF;
|
|
1144
|
-
return [
|
|
1069
|
+
return [GS, 0x6B, 0x80, n1, n2, n3, n4, n5, n6, ...bytes];
|
|
1145
1070
|
};
|
|
1146
|
-
exports.printBarcodePDF417 = printBarcodePDF417;
|
|
1147
1071
|
// ============================================================================
|
|
1148
1072
|
// BARCODES - ISBN
|
|
1149
1073
|
// ============================================================================
|
|
@@ -1153,16 +1077,15 @@ exports.printBarcodePDF417 = printBarcodePDF417;
|
|
|
1153
1077
|
* Last char before space: 'X' (88) or digit
|
|
1154
1078
|
* After hyphen+X/digit: optional space + 5 more digits
|
|
1155
1079
|
*/
|
|
1156
|
-
const printBarcodeISBN = (data) => {
|
|
1080
|
+
export const printBarcodeISBN = (data) => {
|
|
1157
1081
|
// Remove hyphens for validation
|
|
1158
1082
|
const clean = data.replace(/-/g, '');
|
|
1159
1083
|
if (!/^[\dX][\d ]+$/.test(clean)) {
|
|
1160
1084
|
throw new Error('ISBN format: digits, optional X, optional space + 5 digits');
|
|
1161
1085
|
}
|
|
1162
1086
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
1163
|
-
return [
|
|
1087
|
+
return [GS, 0x6B, NAK, ...bytes, NUL];
|
|
1164
1088
|
};
|
|
1165
|
-
exports.printBarcodeISBN = printBarcodeISBN;
|
|
1166
1089
|
// ============================================================================
|
|
1167
1090
|
// BARCODES - MSI
|
|
1168
1091
|
// ============================================================================
|
|
@@ -1171,25 +1094,23 @@ exports.printBarcodeISBN = printBarcodeISBN;
|
|
|
1171
1094
|
* Range: 48 ≤ dn ≤ 57 (ASCII digits '0'-'9')
|
|
1172
1095
|
* Checksum generated automatically
|
|
1173
1096
|
*/
|
|
1174
|
-
const printBarcodeMSI = (data) => {
|
|
1097
|
+
export const printBarcodeMSI = (data) => {
|
|
1175
1098
|
if (!/^\d+$/.test(data)) {
|
|
1176
1099
|
throw new Error('MSI requires only digits 0-9');
|
|
1177
1100
|
}
|
|
1178
1101
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
1179
|
-
return [
|
|
1102
|
+
return [GS, 0x6B, SYN, ...bytes, NUL];
|
|
1180
1103
|
};
|
|
1181
|
-
exports.printBarcodeMSI = printBarcodeMSI;
|
|
1182
1104
|
/**
|
|
1183
1105
|
* GS k 82h n d1 ... dn - Print MSI barcode (alternate)
|
|
1184
1106
|
*/
|
|
1185
|
-
const printBarcodeMSIAlt = (data) => {
|
|
1107
|
+
export const printBarcodeMSIAlt = (data) => {
|
|
1186
1108
|
if (!/^\d+$/.test(data)) {
|
|
1187
1109
|
throw new Error('MSI requires only digits 0-9');
|
|
1188
1110
|
}
|
|
1189
1111
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
1190
|
-
return [
|
|
1112
|
+
return [GS, 0x6B, 0x82, bytes.length, ...bytes];
|
|
1191
1113
|
};
|
|
1192
|
-
exports.printBarcodeMSIAlt = printBarcodeMSIAlt;
|
|
1193
1114
|
// ============================================================================
|
|
1194
1115
|
// BARCODES - PLESSEY
|
|
1195
1116
|
// ============================================================================
|
|
@@ -1199,25 +1120,23 @@ exports.printBarcodeMSIAlt = printBarcodeMSIAlt;
|
|
|
1199
1120
|
* Cannot mix uppercase and lowercase letters
|
|
1200
1121
|
* Checksum generated automatically
|
|
1201
1122
|
*/
|
|
1202
|
-
const printBarcodePLESSEY = (data) => {
|
|
1123
|
+
export const printBarcodePLESSEY = (data) => {
|
|
1203
1124
|
if (!/^[0-9A-F]+$/.test(data) && !/^[0-9a-f]+$/.test(data)) {
|
|
1204
1125
|
throw new Error('PLESSEY supports: 0-9, A-F (or a-f, not mixed)');
|
|
1205
1126
|
}
|
|
1206
1127
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
1207
|
-
return [
|
|
1128
|
+
return [GS, 0x6B, ETB, ...bytes, NUL];
|
|
1208
1129
|
};
|
|
1209
|
-
exports.printBarcodePLESSEY = printBarcodePLESSEY;
|
|
1210
1130
|
/**
|
|
1211
1131
|
* GS k 83h n d1 ... dn - Print PLESSEY barcode (alternate)
|
|
1212
1132
|
*/
|
|
1213
|
-
const printBarcodePLESSEYAlt = (data) => {
|
|
1133
|
+
export const printBarcodePLESSEYAlt = (data) => {
|
|
1214
1134
|
if (!/^[0-9A-F]+$/.test(data) && !/^[0-9a-f]+$/.test(data)) {
|
|
1215
1135
|
throw new Error('PLESSEY supports: 0-9, A-F (or a-f, not mixed)');
|
|
1216
1136
|
}
|
|
1217
1137
|
const bytes = data.split('').map(c => c.charCodeAt(0));
|
|
1218
|
-
return [
|
|
1138
|
+
return [GS, 0x6B, 0x83, bytes.length, ...bytes];
|
|
1219
1139
|
};
|
|
1220
|
-
exports.printBarcodePLESSEYAlt = printBarcodePLESSEYAlt;
|
|
1221
1140
|
// ============================================================================
|
|
1222
1141
|
// STATUS QUERIES
|
|
1223
1142
|
// ============================================================================
|
|
@@ -1232,12 +1151,12 @@ exports.printBarcodePLESSEYAlt = printBarcodePLESSEYAlt;
|
|
|
1232
1151
|
* Bit 5: 0=command not executed, 1=command executed
|
|
1233
1152
|
* Bits 6-7: Unused (always 0)
|
|
1234
1153
|
*/
|
|
1235
|
-
|
|
1154
|
+
export const STATUS_ENQUIRY = [ENQ];
|
|
1236
1155
|
/**
|
|
1237
1156
|
* GS F8h 1 - Printer extended status enquiry
|
|
1238
1157
|
* Returns 5 status bytes with detailed printer information
|
|
1239
1158
|
*/
|
|
1240
|
-
|
|
1159
|
+
export const EXTENDED_STATUS = [GS, 0xF8, 0x31];
|
|
1241
1160
|
// ============================================================================
|
|
1242
1161
|
// BUFFER CONTROL
|
|
1243
1162
|
// ============================================================================
|
|
@@ -1245,25 +1164,25 @@ exports.EXTENDED_STATUS = [exports.GS, 0xF8, 0x31];
|
|
|
1245
1164
|
* STX - Clear buffer
|
|
1246
1165
|
* Clears print buffer without restoring default printer conditions
|
|
1247
1166
|
*/
|
|
1248
|
-
|
|
1167
|
+
export const CLEAR_BUFFER = [STX];
|
|
1249
1168
|
/**
|
|
1250
1169
|
* ETX - End buffer
|
|
1251
1170
|
* Printer remains in BUSY state until print buffer becomes empty
|
|
1252
1171
|
* DTR (RTS) remains deactivated while printing on serial interfaces
|
|
1253
1172
|
*/
|
|
1254
|
-
|
|
1173
|
+
export const END_BUFFER = [ETX];
|
|
1255
1174
|
/**
|
|
1256
1175
|
* CAN - Cancel last line
|
|
1257
1176
|
* Clears last line sent to printer
|
|
1258
1177
|
* No action if data already dispatched to print head
|
|
1259
1178
|
*/
|
|
1260
|
-
|
|
1179
|
+
export const CANCEL_LINE = [CAN];
|
|
1261
1180
|
/**
|
|
1262
1181
|
* DEL - Cancel last character
|
|
1263
1182
|
* Clears last character sent to printer
|
|
1264
1183
|
* No action if already dispatched to print head
|
|
1265
1184
|
*/
|
|
1266
|
-
|
|
1185
|
+
export const CANCEL_CHAR = [DEL];
|
|
1267
1186
|
// ============================================================================
|
|
1268
1187
|
// NETWORK CONFIGURATION - IP ADDRESS
|
|
1269
1188
|
// ============================================================================
|
|
@@ -1277,10 +1196,9 @@ exports.CANCEL_CHAR = [exports.DEL];
|
|
|
1277
1196
|
*
|
|
1278
1197
|
* Valid only for ethernet or wi-fi interface
|
|
1279
1198
|
*/
|
|
1280
|
-
const setIPAddress = (ip, subnet) => {
|
|
1281
|
-
return [
|
|
1199
|
+
export const setIPAddress = (ip, subnet) => {
|
|
1200
|
+
return [GS, 0xF7, 0x08, 0x00, 0x22, ...ip, ...subnet];
|
|
1282
1201
|
};
|
|
1283
|
-
exports.setIPAddress = setIPAddress;
|
|
1284
1202
|
/**
|
|
1285
1203
|
* GS F7h EOT NUL ' g1 g2 g3 g4 - Set default gateway IP address
|
|
1286
1204
|
* g1-g4: Gateway IP address octets
|
|
@@ -1289,10 +1207,9 @@ exports.setIPAddress = setIPAddress;
|
|
|
1289
1207
|
* Example: Gateway 192.168.1.2
|
|
1290
1208
|
* Command: 1D F7 04 00 27 C0 A8 01 02
|
|
1291
1209
|
*/
|
|
1292
|
-
const setGateway = (gateway) => {
|
|
1293
|
-
return [
|
|
1210
|
+
export const setGateway = (gateway) => {
|
|
1211
|
+
return [GS, 0xF7, 0x04, 0x00, 0x27, ...gateway];
|
|
1294
1212
|
};
|
|
1295
|
-
exports.setGateway = setGateway;
|
|
1296
1213
|
// ============================================================================
|
|
1297
1214
|
// NETWORK CONFIGURATION - DHCP
|
|
1298
1215
|
// ============================================================================
|
|
@@ -1302,10 +1219,8 @@ exports.setGateway = setGateway;
|
|
|
1302
1219
|
* Saves to non-volatile memory
|
|
1303
1220
|
* Valid only for ethernet or wi-fi interface
|
|
1304
1221
|
*/
|
|
1305
|
-
const enableDHCP = () => [
|
|
1306
|
-
|
|
1307
|
-
const disableDHCP = () => [exports.GS, 0xF9, 0x45, 0x00];
|
|
1308
|
-
exports.disableDHCP = disableDHCP;
|
|
1222
|
+
export const enableDHCP = () => [GS, 0xF9, 0x45, 0x01];
|
|
1223
|
+
export const disableDHCP = () => [GS, 0xF9, 0x45, 0x00];
|
|
1309
1224
|
// ============================================================================
|
|
1310
1225
|
// NETWORK CONFIGURATION - SNMP
|
|
1311
1226
|
// ============================================================================
|
|
@@ -1318,11 +1233,10 @@ exports.disableDHCP = disableDHCP;
|
|
|
1318
1233
|
*
|
|
1319
1234
|
* Valid only for ethernet or wi-fi interface
|
|
1320
1235
|
*/
|
|
1321
|
-
const setSNMP = (enabled, ip, community) => {
|
|
1236
|
+
export const setSNMP = (enabled, ip, community) => {
|
|
1322
1237
|
const communityBytes = community.split('').map(c => c.charCodeAt(0)).slice(0, 64);
|
|
1323
|
-
return [
|
|
1238
|
+
return [GS, 0xF9, 0x53, enabled ? 0x01 : 0x00, ...ip, communityBytes.length, ...communityBytes];
|
|
1324
1239
|
};
|
|
1325
|
-
exports.setSNMP = setSNMP;
|
|
1326
1240
|
// ============================================================================
|
|
1327
1241
|
// NETWORK CONFIGURATION - WI-FI
|
|
1328
1242
|
// ============================================================================
|
|
@@ -1338,12 +1252,12 @@ exports.setSNMP = setSNMP;
|
|
|
1338
1252
|
*
|
|
1339
1253
|
* Valid only for wi-fi interface
|
|
1340
1254
|
*/
|
|
1341
|
-
const setWiFi = (accessMode, securityMode, channel, essid, passphrase) => {
|
|
1255
|
+
export const setWiFi = (accessMode, securityMode, channel, essid, passphrase) => {
|
|
1342
1256
|
const essidBytes = essid.split('').map(c => c.charCodeAt(0)).slice(0, 32);
|
|
1343
1257
|
const passphraseBytes = passphrase.split('').map(c => c.charCodeAt(0)).slice(0, 63);
|
|
1344
1258
|
const c = Math.max(0, Math.min(13, channel));
|
|
1345
1259
|
return [
|
|
1346
|
-
|
|
1260
|
+
GS, 0xF9, 0x57,
|
|
1347
1261
|
accessMode,
|
|
1348
1262
|
securityMode,
|
|
1349
1263
|
c,
|
|
@@ -1353,7 +1267,6 @@ const setWiFi = (accessMode, securityMode, channel, essid, passphrase) => {
|
|
|
1353
1267
|
...passphraseBytes
|
|
1354
1268
|
];
|
|
1355
1269
|
};
|
|
1356
|
-
exports.setWiFi = setWiFi;
|
|
1357
1270
|
// ============================================================================
|
|
1358
1271
|
// UTILITY FUNCTIONS
|
|
1359
1272
|
// ============================================================================
|
|
@@ -1361,18 +1274,17 @@ exports.setWiFi = setWiFi;
|
|
|
1361
1274
|
* Convert string to code page bytes
|
|
1362
1275
|
* Uses CP860 encoding by default (Portuguese)
|
|
1363
1276
|
*/
|
|
1364
|
-
const encodeText = (text, codePage = CodePage.CP860) => {
|
|
1277
|
+
export const encodeText = (text, codePage = CodePage.CP860) => {
|
|
1365
1278
|
// Basic ASCII conversion - full implementation would require proper code page mapping
|
|
1366
1279
|
return text.split('').map(c => {
|
|
1367
1280
|
const code = c.charCodeAt(0);
|
|
1368
1281
|
return code <= 127 ? code : 0x3F; // Replace non-ASCII with '?'
|
|
1369
1282
|
});
|
|
1370
1283
|
};
|
|
1371
|
-
exports.encodeText = encodeText;
|
|
1372
1284
|
/**
|
|
1373
1285
|
* Validate barcode data
|
|
1374
1286
|
*/
|
|
1375
|
-
const validateBarcodeData = (data, type) => {
|
|
1287
|
+
export const validateBarcodeData = (data, type) => {
|
|
1376
1288
|
switch (type) {
|
|
1377
1289
|
case 'numeric':
|
|
1378
1290
|
return /^\d+$/.test(data);
|
|
@@ -1384,4 +1296,3 @@ const validateBarcodeData = (data, type) => {
|
|
|
1384
1296
|
return false;
|
|
1385
1297
|
}
|
|
1386
1298
|
};
|
|
1387
|
-
exports.validateBarcodeData = validateBarcodeData;
|