@pisell/utils 3.0.4 → 3.0.6

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.
Files changed (160) hide show
  1. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
  2. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
  3. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
  4. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
  5. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
  6. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +11 -0
  7. package/es/arrayUtils.d.ts +76 -1
  8. package/es/arrayUtils.js +103 -24
  9. package/es/common/stateHelper.d.ts +22 -0
  10. package/es/common/stateHelper.js +23 -0
  11. package/es/common/types.d.ts +31 -0
  12. package/es/componentStorage.d.ts +38 -0
  13. package/es/componentStorage.js +106 -0
  14. package/es/constants/index.js +7 -9
  15. package/es/date.d.ts +6 -3
  16. package/es/date.js +36 -53
  17. package/es/document.d.ts +6 -3
  18. package/es/document.js +43 -67
  19. package/es/escPosPrinter/EscPosPrinter.js +353 -490
  20. package/es/escPosPrinter/index.d.ts +9 -9
  21. package/es/escPosPrinter/index.js +37 -52
  22. package/es/format.d.ts +29 -0
  23. package/es/format.js +90 -112
  24. package/es/image.d.ts +13 -10
  25. package/es/image.js +48 -60
  26. package/es/index.d.ts +39 -18
  27. package/es/index.js +40 -29
  28. package/es/jsBridge/index.d.ts +14 -106
  29. package/es/jsBridge/index.js +57 -40
  30. package/es/jsBridge/regDeviceApi.js +87 -126
  31. package/es/jsBridge/types.d.ts +129 -0
  32. package/es/locales.d.ts +11 -11
  33. package/es/locales.js +79 -69
  34. package/es/log.d.ts +11 -6
  35. package/es/log.js +37 -59
  36. package/es/miniRedux.d.ts +20 -13
  37. package/es/miniRedux.js +42 -71
  38. package/es/number-input/hooks/useNumberInputState.d.ts +29 -0
  39. package/es/number-input/hooks/useNumberInputState.js +72 -0
  40. package/es/number-input/types.d.ts +96 -0
  41. package/es/number-input/utils/formatter.d.ts +56 -0
  42. package/es/number-input/utils/formatter.js +56 -0
  43. package/es/number-input/utils/validation.d.ts +32 -0
  44. package/es/number-input/utils/validation.js +52 -0
  45. package/es/otherUtils.d.ts +12 -9
  46. package/es/otherUtils.js +71 -120
  47. package/es/platform.d.ts +12 -9
  48. package/es/platform.js +61 -85
  49. package/es/select/hooks/useDebouncedSearch.d.ts +23 -0
  50. package/es/select/hooks/useDebouncedSearch.js +41 -0
  51. package/es/select/hooks/useSelectState.d.ts +19 -0
  52. package/es/select/hooks/useSelectState.js +60 -0
  53. package/es/select/index.d.ts +7 -0
  54. package/es/select/types.d.ts +256 -0
  55. package/es/select/utils/filterOptions.d.ts +23 -0
  56. package/es/select/utils/filterOptions.js +29 -0
  57. package/es/select/utils/helpers.d.ts +43 -0
  58. package/es/select/utils/helpers.js +51 -0
  59. package/es/select/utils/index.d.ts +4 -0
  60. package/es/select/utils/sortOptions.d.ts +13 -0
  61. package/es/select/utils/sortOptions.js +20 -0
  62. package/es/select/utils/tagAggregation.d.ts +25 -0
  63. package/es/select/utils/tagAggregation.js +35 -0
  64. package/es/text-input/hooks/useTextInputState.d.ts +28 -0
  65. package/es/text-input/hooks/useTextInputState.js +70 -0
  66. package/es/text-input/types.d.ts +56 -0
  67. package/es/text-input/utils/validation.d.ts +28 -0
  68. package/es/text-input/utils/validation.js +51 -0
  69. package/es/typeUtils.d.ts +11 -8
  70. package/es/typeUtils.js +61 -84
  71. package/es/walletValidity.d.ts +57 -0
  72. package/es/walletValidity.js +404 -460
  73. package/es/weighing.d.ts +65 -0
  74. package/es/weighing.js +96 -0
  75. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
  76. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
  77. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
  78. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
  79. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
  80. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +16 -0
  81. package/lib/_virtual/_rolldown/runtime.js +23 -0
  82. package/lib/arrayUtils.d.ts +76 -1
  83. package/lib/arrayUtils.js +102 -37
  84. package/lib/common/stateHelper.d.ts +22 -0
  85. package/lib/common/stateHelper.js +23 -0
  86. package/lib/common/types.d.ts +31 -0
  87. package/lib/componentStorage.d.ts +38 -0
  88. package/lib/componentStorage.js +114 -0
  89. package/lib/constants/index.js +7 -36
  90. package/lib/date.d.ts +6 -3
  91. package/lib/date.js +43 -65
  92. package/lib/document.d.ts +6 -3
  93. package/lib/document.js +46 -62
  94. package/lib/escPosPrinter/EscPosPrinter.js +327 -403
  95. package/lib/escPosPrinter/index.d.ts +9 -9
  96. package/lib/escPosPrinter/index.js +38 -84
  97. package/lib/format.d.ts +29 -0
  98. package/lib/format.js +91 -93
  99. package/lib/image.d.ts +13 -10
  100. package/lib/image.js +48 -74
  101. package/lib/index.d.ts +39 -18
  102. package/lib/index.js +137 -68
  103. package/lib/jsBridge/index.d.ts +14 -106
  104. package/lib/jsBridge/index.js +60 -60
  105. package/lib/jsBridge/regDeviceApi.js +86 -133
  106. package/lib/jsBridge/types.d.ts +129 -0
  107. package/lib/locales.d.ts +11 -11
  108. package/lib/locales.js +79 -63
  109. package/lib/log.d.ts +11 -6
  110. package/lib/log.js +37 -61
  111. package/lib/miniRedux.d.ts +20 -13
  112. package/lib/miniRedux.js +43 -91
  113. package/lib/number-input/hooks/useNumberInputState.d.ts +29 -0
  114. package/lib/number-input/hooks/useNumberInputState.js +73 -0
  115. package/lib/number-input/types.d.ts +96 -0
  116. package/lib/number-input/utils/formatter.d.ts +56 -0
  117. package/lib/number-input/utils/formatter.js +58 -0
  118. package/lib/number-input/utils/validation.d.ts +32 -0
  119. package/lib/number-input/utils/validation.js +52 -0
  120. package/lib/otherUtils.d.ts +12 -9
  121. package/lib/otherUtils.js +86 -91
  122. package/lib/platform.d.ts +12 -9
  123. package/lib/platform.js +68 -123
  124. package/lib/select/hooks/useDebouncedSearch.d.ts +23 -0
  125. package/lib/select/hooks/useDebouncedSearch.js +42 -0
  126. package/lib/select/hooks/useSelectState.d.ts +19 -0
  127. package/lib/select/hooks/useSelectState.js +62 -0
  128. package/lib/select/index.d.ts +7 -0
  129. package/lib/select/types.d.ts +256 -0
  130. package/lib/select/utils/filterOptions.d.ts +23 -0
  131. package/lib/select/utils/filterOptions.js +30 -0
  132. package/lib/select/utils/helpers.d.ts +43 -0
  133. package/lib/select/utils/helpers.js +55 -0
  134. package/lib/select/utils/index.d.ts +4 -0
  135. package/lib/select/utils/sortOptions.d.ts +13 -0
  136. package/lib/select/utils/sortOptions.js +20 -0
  137. package/lib/select/utils/tagAggregation.d.ts +25 -0
  138. package/lib/select/utils/tagAggregation.js +35 -0
  139. package/lib/text-input/hooks/useTextInputState.d.ts +28 -0
  140. package/lib/text-input/hooks/useTextInputState.js +71 -0
  141. package/lib/text-input/types.d.ts +56 -0
  142. package/lib/text-input/utils/validation.d.ts +28 -0
  143. package/lib/text-input/utils/validation.js +51 -0
  144. package/lib/typeUtils.d.ts +11 -8
  145. package/lib/typeUtils.js +68 -73
  146. package/lib/walletValidity.d.ts +57 -0
  147. package/lib/walletValidity.js +420 -323
  148. package/lib/weighing.d.ts +65 -0
  149. package/lib/weighing.js +114 -0
  150. package/package.json +1 -1
  151. package/es/constants/index.d.ts +0 -7
  152. package/es/firebase/config/index.d.ts +0 -13
  153. package/es/firebase/config/index.js +0 -54
  154. package/es/firebase/index.d.ts +0 -28
  155. package/es/firebase/index.js +0 -232
  156. package/lib/constants/index.d.ts +0 -7
  157. package/lib/firebase/config/index.d.ts +0 -13
  158. package/lib/firebase/config/index.js +0 -79
  159. package/lib/firebase/index.d.ts +0 -28
  160. package/lib/firebase/index.js +0 -180
@@ -1,538 +1,401 @@
1
- // Maximum columns for printing in columns function
2
- export var MAX_COLUMNS = 6;
3
-
4
- // Left alignment
5
- export var ALIGN_LEFT = 0;
6
- // Center alignment
7
- export var ALIGN_CENTER = 1;
8
- // Right alignment
9
- export var ALIGN_RIGHT = 2;
10
-
11
- // HRI above the barcode
12
- export var HRI_POS_ABOVE = 1;
13
- // HRI below the barcode
14
- export var HRI_POS_BELOW = 2;
15
- var EscPosPrinter = function EscPosPrinter(dotsPerLine) {
16
- if (dotsPerLine != 384 && dotsPerLine != 576)
17
- // Print width in dots. 384 for 58mm and 576 for 80mm
18
- dotsPerLine = 384;
19
- this.widthOfColumns = new Array(MAX_COLUMNS);
20
- this.dotsPerLine = dotsPerLine;
21
- this.charHSize = 1;
22
- this.orderData = "";
1
+ const ALIGN_LEFT = 0;
2
+ const ALIGN_CENTER = 1;
3
+ const ALIGN_RIGHT = 2;
4
+ const EscPosPrinter = function(dotsPerLine) {
5
+ if (dotsPerLine != 384 && dotsPerLine != 576) dotsPerLine = 384;
6
+ this.widthOfColumns = new Array(6);
7
+ this.dotsPerLine = dotsPerLine;
8
+ this.charHSize = 1;
9
+ this.orderData = "";
23
10
  };
24
11
  function _numToHexStr(n, bytes) {
25
- var str = "";
26
- var v;
27
- for (var i = 0; i < bytes; i++) {
28
- v = n & 0xff;
29
- if (v < 0x10) str += "0" + v.toString(16);else str += v.toString(16);
30
- n >>= 8;
31
- }
32
- return str;
12
+ var str = "";
13
+ var v;
14
+ for (var i = 0; i < bytes; i++) {
15
+ v = n & 255;
16
+ if (v < 16) str += "0" + v.toString(16);
17
+ else str += v.toString(16);
18
+ n >>= 8;
19
+ }
20
+ return str;
33
21
  }
34
22
  function _unicodeToUtf8(unicode) {
35
- var c1, c2, c3, c4;
36
- if (unicode < 0) return "";
37
- if (unicode <= 0x7f) {
38
- c1 = unicode & 0x7f;
39
- return _numToHexStr(c1, 1);
40
- }
41
- if (unicode <= 0x7ff) {
42
- c1 = unicode >> 6 & 0x1f | 0xc0;
43
- c2 = unicode & 0x3f | 0x80;
44
- return _numToHexStr(c1, 1) + _numToHexStr(c2, 1);
45
- }
46
- if (unicode <= 0xffff) {
47
- c1 = unicode >> 12 & 0x0f | 0xe0;
48
- c2 = unicode >> 6 & 0x3f | 0x80;
49
- c3 = unicode & 0x3f | 0x80;
50
- return _numToHexStr(c1, 1) + _numToHexStr(c2, 1) + _numToHexStr(c3, 1);
51
- }
52
- if (unicode <= 0x10ffff) {
53
- c1 = unicode >> 18 & 0x07 | 0xf0;
54
- c2 = unicode >> 12 & 0x3f | 0x80;
55
- c3 = unicode >> 6 & 0x3f | 0x80;
56
- c4 = unicode & 0x3f | 0x80;
57
- return _numToHexStr(c1, 1) + _numToHexStr(c2, 1) + _numToHexStr(c3, 1) + _numToHexStr(c4, 1);
58
- }
59
- return "";
23
+ var c1, c2, c3, c4;
24
+ if (unicode < 0) return "";
25
+ if (unicode <= 127) {
26
+ c1 = unicode & 127;
27
+ return _numToHexStr(c1, 1);
28
+ }
29
+ if (unicode <= 2047) {
30
+ c1 = unicode >> 6 & 31 | 192;
31
+ c2 = unicode & 63 | 128;
32
+ return _numToHexStr(c1, 1) + _numToHexStr(c2, 1);
33
+ }
34
+ if (unicode <= 65535) {
35
+ c1 = unicode >> 12 & 15 | 224;
36
+ c2 = unicode >> 6 & 63 | 128;
37
+ c3 = unicode & 63 | 128;
38
+ return _numToHexStr(c1, 1) + _numToHexStr(c2, 1) + _numToHexStr(c3, 1);
39
+ }
40
+ if (unicode <= 1114111) {
41
+ c1 = unicode >> 18 & 7 | 240;
42
+ c2 = unicode >> 12 & 63 | 128;
43
+ c3 = unicode >> 6 & 63 | 128;
44
+ c4 = unicode & 63 | 128;
45
+ return _numToHexStr(c1, 1) + _numToHexStr(c2, 1) + _numToHexStr(c3, 1) + _numToHexStr(c4, 1);
46
+ }
47
+ return "";
60
48
  }
61
-
62
- // Clear the generated order data.
63
- EscPosPrinter.prototype.clear = function () {
64
- this.orderData = "";
49
+ EscPosPrinter.prototype.clear = function() {
50
+ this.orderData = "";
65
51
  };
66
-
67
- // Print the order data.
68
- EscPosPrinter.prototype.print = function (host, sn, copies) {
69
- var that = this;
70
- return new Promise(function (resolve, reject) {
71
- var xmlobj = new XMLHttpRequest();
72
- xmlobj.timeout = 10000;
73
- var url = "https://" + host + "/cgi-bin/print.cgi?sn=" + sn + "&copies=" + copies;
74
- xmlobj.open("POST", url, true);
75
- xmlobj.onreadystatechange = function () {
76
- if (xmlobj.readyState === XMLHttpRequest.DONE) {
77
- if (xmlobj.status.toString(10) === "200") {
78
- var re = /task_id: (\d+)/;
79
- var matches = re.exec(xmlobj.responseText);
80
- resolve(matches[1] || "");
81
- } else {
82
- reject(xmlobj.responseText);
83
- }
84
- }
85
- };
86
- xmlobj.setRequestHeader("Content-Type", "text/plain; charset=utf-8");
87
- xmlobj.send(that.orderData);
88
- });
52
+ EscPosPrinter.prototype.print = function(host, sn, copies) {
53
+ var that = this;
54
+ return new Promise(function(resolve, reject) {
55
+ var xmlobj = new XMLHttpRequest();
56
+ xmlobj.timeout = 1e4;
57
+ var url = "https://" + host + "/cgi-bin/print.cgi?sn=" + sn + "&copies=" + copies;
58
+ xmlobj.open("POST", url, true);
59
+ xmlobj.onreadystatechange = function() {
60
+ if (xmlobj.readyState === XMLHttpRequest.DONE) if (xmlobj.status.toString(10) === "200") resolve(/task_id: (\d+)/.exec(xmlobj.responseText)[1] || "");
61
+ else reject(xmlobj.responseText);
62
+ };
63
+ xmlobj.setRequestHeader("Content-Type", "text/plain; charset=utf-8");
64
+ xmlobj.send(that.orderData);
65
+ });
89
66
  };
90
-
91
- // Query print status.
92
- EscPosPrinter.prototype.queryStatus = function (host, sn, task_id) {
93
- return new Promise(function (resolve, reject) {
94
- var xmlobj = new XMLHttpRequest();
95
- xmlobj.timeout = 10000;
96
- var url = "https://" + host + "/cgi-bin/status.cgi?sn=" + sn + "&task_id=" + task_id;
97
- xmlobj.open("POST", url, true);
98
- xmlobj.onreadystatechange = function () {
99
- if (xmlobj.readyState === XMLHttpRequest.DONE) {
100
- if (xmlobj.status.toString(10) === "200") {
101
- resolve(xmlobj.responseText);
102
- } else {
103
- reject(xmlobj.responseText);
104
- }
105
- }
106
- };
107
- xmlobj.setRequestHeader("Content-Type", "text/plain; charset=utf-8");
108
- xmlobj.send();
109
- });
67
+ EscPosPrinter.prototype.queryStatus = function(host, sn, task_id) {
68
+ return new Promise(function(resolve, reject) {
69
+ var xmlobj = new XMLHttpRequest();
70
+ xmlobj.timeout = 1e4;
71
+ var url = "https://" + host + "/cgi-bin/status.cgi?sn=" + sn + "&task_id=" + task_id;
72
+ xmlobj.open("POST", url, true);
73
+ xmlobj.onreadystatechange = function() {
74
+ if (xmlobj.readyState === XMLHttpRequest.DONE) if (xmlobj.status.toString(10) === "200") resolve(xmlobj.responseText);
75
+ else reject(xmlobj.responseText);
76
+ };
77
+ xmlobj.setRequestHeader("Content-Type", "text/plain; charset=utf-8");
78
+ xmlobj.send();
79
+ });
110
80
  };
111
-
112
- //////////////////////////////////////////////////
113
- // Basic ESC/POS Commands
114
- //////////////////////////////////////////////////
115
-
116
- // Append text in the order.
117
- EscPosPrinter.prototype.appendText = function (str) {
118
- for (var i = 0; i < str.length; i++) this.orderData += _unicodeToUtf8(str.charCodeAt(i));
81
+ EscPosPrinter.prototype.appendText = function(str) {
82
+ for (var i = 0; i < str.length; i++) this.orderData += _unicodeToUtf8(str.charCodeAt(i));
119
83
  };
120
-
121
- // [LF] Print the contents in the buffer and feed n lines.
122
- EscPosPrinter.prototype.lineFeed = function (n) {
123
- for (var i = 0; i < n; i++) this.orderData += "0a";
84
+ EscPosPrinter.prototype.lineFeed = function(n) {
85
+ for (var i = 0; i < n; i++) this.orderData += "0a";
124
86
  };
125
-
126
- // [ESC @] Restore default settings (line spacing, print modes, etc).
127
- EscPosPrinter.prototype.restoreDefaultSettings = function () {
128
- this.charHSize = 1;
129
- this.orderData += "1b40";
87
+ EscPosPrinter.prototype.restoreDefaultSettings = function() {
88
+ this.charHSize = 1;
89
+ this.orderData += "1b40";
130
90
  };
131
-
132
- // [ESC 2] Restore default line spacing.
133
- EscPosPrinter.prototype.restoreDefaultLineSpacing = function () {
134
- this.orderData += "1b32";
91
+ EscPosPrinter.prototype.restoreDefaultLineSpacing = function() {
92
+ this.orderData += "1b32";
135
93
  };
136
-
137
- // [ESC 3] Set line spacing.
138
- EscPosPrinter.prototype.setLineSpacing = function (n) {
139
- if (n >= 0 && n <= 255) this.orderData += "1b33" + _numToHexStr(n, 1);
94
+ EscPosPrinter.prototype.setLineSpacing = function(n) {
95
+ if (n >= 0 && n <= 255) this.orderData += "1b33" + _numToHexStr(n, 1);
140
96
  };
141
-
142
- // [ESC !] Select print modes (double width/height or not, bold or not).
143
- EscPosPrinter.prototype.setPrintModes = function (bold, double_h, double_w) {
144
- var n = 0;
145
- if (bold) n |= 8;
146
- if (double_h) n |= 16;
147
- if (double_w) n |= 32;
148
- this.charHSize = double_w ? 2 : 1;
149
- this.orderData += "1b21" + _numToHexStr(n, 1);
97
+ EscPosPrinter.prototype.setPrintModes = function(bold, double_h, double_w) {
98
+ var n = 0;
99
+ if (bold) n |= 8;
100
+ if (double_h) n |= 16;
101
+ if (double_w) n |= 32;
102
+ this.charHSize = double_w ? 2 : 1;
103
+ this.orderData += "1b21" + _numToHexStr(n, 1);
150
104
  };
151
-
152
- // [GS !] Set character size (1~8 times of normal width or height).
153
- EscPosPrinter.prototype.setCharacterSize = function (h, w) {
154
- var n = 0;
155
- if (h >= 1 && h <= 8) n |= h - 1;
156
- if (w >= 1 && w <= 8) {
157
- n |= w - 1 << 4;
158
- this.charHSize = w;
159
- }
160
- this.orderData += "1d21" + _numToHexStr(n, 1);
105
+ EscPosPrinter.prototype.setCharacterSize = function(h, w) {
106
+ var n = 0;
107
+ if (h >= 1 && h <= 8) n |= h - 1;
108
+ if (w >= 1 && w <= 8) {
109
+ n |= w - 1 << 4;
110
+ this.charHSize = w;
111
+ }
112
+ this.orderData += "1d21" + _numToHexStr(n, 1);
161
113
  };
162
-
163
- // [HT] Jump to the next n TAB positions.
164
- EscPosPrinter.prototype.horizontalTab = function (n) {
165
- for (var i = 0; i < n; i++) this.orderData += "09";
114
+ EscPosPrinter.prototype.horizontalTab = function(n) {
115
+ for (var i = 0; i < n; i++) this.orderData += "09";
166
116
  };
167
-
168
- // [ESC $] Move to horizontal absolute position.
169
- EscPosPrinter.prototype.setAbsolutePrintPosition = function (n) {
170
- if (n >= 0 && n <= 65535) this.orderData += "1b24" + _numToHexStr(n, 2);
117
+ EscPosPrinter.prototype.setAbsolutePrintPosition = function(n) {
118
+ if (n >= 0 && n <= 65535) this.orderData += "1b24" + _numToHexStr(n, 2);
171
119
  };
172
-
173
- // [ESC \] Move to horizontal relative position.
174
- EscPosPrinter.prototype.setRelativePrintPosition = function (n) {
175
- if (n >= -32768 && n <= 32767) this.orderData += "1b5c" + _numToHexStr(n, 2);
120
+ EscPosPrinter.prototype.setRelativePrintPosition = function(n) {
121
+ if (n >= -32768 && n <= 32767) this.orderData += "1b5c" + _numToHexStr(n, 2);
176
122
  };
177
-
178
- // [ESC a] Set alignment.
179
- EscPosPrinter.prototype.setAlignment = function (n) {
180
- if (n >= 0 && n <= 2) this.orderData += "1b61" + _numToHexStr(n, 1);
123
+ EscPosPrinter.prototype.setAlignment = function(n) {
124
+ if (n >= 0 && n <= 2) this.orderData += "1b61" + _numToHexStr(n, 1);
181
125
  };
182
-
183
- // [GS V m] Cut paper.
184
- EscPosPrinter.prototype.cutPaper = function (fullCut) {
185
- this.orderData += "1d56" + (fullCut ? "30" : "31");
126
+ EscPosPrinter.prototype.cutPaper = function(fullCut) {
127
+ this.orderData += "1d56" + (fullCut ? "30" : "31");
186
128
  };
187
-
188
- // [GS V m n] Postponed cut paper.
189
- // After sending this command, the cutter will not cut until (76+n) dot lines are fed.
190
- EscPosPrinter.prototype.postponedCutPaper = function (fullCut, n) {
191
- if (n >= 0 && n <= 255) this.orderData += "1d56" + (fullCut ? "61" : "62") + _numToHexStr(n, 1);
129
+ EscPosPrinter.prototype.postponedCutPaper = function(fullCut, n) {
130
+ if (n >= 0 && n <= 255) this.orderData += "1d56" + (fullCut ? "61" : "62") + _numToHexStr(n, 1);
192
131
  };
193
-
194
- //////////////////////////////////////////////////
195
- // Print in Columns
196
- //////////////////////////////////////////////////
197
-
198
- // Return the width of a character.
199
132
  function _widthOfChar(c) {
200
- if (c >= 0x00020 && c <= 0x0036f || c >= 0x0ff61 && c <= 0x0ff9f) return 12;
201
- if (c == 0x02010 || c >= 0x02013 && c <= 0x02016 || c >= 0x02018 && c <= 0x02019 || c >= 0x0201c && c <= 0x0201d || c >= 0x02025 && c <= 0x02026 || c >= 0x02030 && c <= 0x02033 || c == 0x02035 || c == 0x0203b) return 24;
202
- if (c >= 0x01100 && c <= 0x011ff || c >= 0x02460 && c <= 0x024ff || c >= 0x025a0 && c <= 0x027bf || c >= 0x02e80 && c <= 0x02fdf || c >= 0x03000 && c <= 0x0318f || c >= 0x031a0 && c <= 0x031ef || c >= 0x03200 && c <= 0x09fff || c >= 0x0ac00 && c <= 0x0d7ff || c >= 0x0f900 && c <= 0x0faff || c >= 0x0fe30 && c <= 0x0fe4f || c >= 0x1f000 && c <= 0x1f9ff) return 24;
203
- if (c >= 0x0ff01 && c <= 0x0ff5e || c >= 0x0ffe0 && c <= 0x0ffe5) return 24;
204
- return 0;
133
+ if (c >= 32 && c <= 879 || c >= 65377 && c <= 65439) return 12;
134
+ if (c == 8208 || c >= 8211 && c <= 8214 || c >= 8216 && c <= 8217 || c >= 8220 && c <= 8221 || c >= 8229 && c <= 8230 || c >= 8240 && c <= 8243 || c == 8245 || c == 8251) return 24;
135
+ if (c >= 4352 && c <= 4607 || c >= 9312 && c <= 9471 || c >= 9632 && c <= 10175 || c >= 11904 && c <= 12255 || c >= 12288 && c <= 12687 || c >= 12704 && c <= 12783 || c >= 12800 && c <= 40959 || c >= 44032 && c <= 55295 || c >= 63744 && c <= 64255 || c >= 65072 && c <= 65103 || c >= 126976 && c <= 129535) return 24;
136
+ if (c >= 65281 && c <= 65374 || c >= 65504 && c <= 65509) return 24;
137
+ return 0;
205
138
  }
206
- export function columnWidthWithAlignment(width, alignment) {
207
- return width & 0xffff | (alignment & 3) << 16;
139
+ function columnWidthWithAlignment(width, alignment) {
140
+ return width & 65535 | (alignment & 3) << 16;
208
141
  }
209
142
  function _columnWidth(v) {
210
- return v & 0xffff;
143
+ return v & 65535;
211
144
  }
212
145
  function _columnAlignment(v) {
213
- return v >> 16 & 3;
146
+ return v >> 16 & 3;
214
147
  }
215
-
216
- // Set the width and alignment mode for each columns.
217
- EscPosPrinter.prototype.setColumnWidths = function /*...*/
218
- () {
219
- var i, remain, width, alignment;
220
- if (arguments.length == 0) return;
221
- for (i = 0; i < MAX_COLUMNS; i++) this.widthOfColumns[i] = 0;
222
- remain = this.dotsPerLine; // Dots not used
223
- for (i = 0; i < arguments.length; i++) {
224
- if (i == MAX_COLUMNS)
225
- // Maximum columns exceeded
226
- return;
227
- width = _columnWidth(arguments[i]);
228
- alignment = _columnAlignment(arguments[i]);
229
- if (width == 0 || width > remain) {
230
- // Use all free dots for the last column
231
- this.widthOfColumns[i] = columnWidthWithAlignment(remain, alignment);
232
- return;
233
- }
234
- this.widthOfColumns[i] = arguments[i];
235
- remain -= width;
236
- }
148
+ EscPosPrinter.prototype.setColumnWidths = function() {
149
+ var i, remain, width, alignment;
150
+ if (arguments.length == 0) return;
151
+ for (i = 0; i < 6; i++) this.widthOfColumns[i] = 0;
152
+ remain = this.dotsPerLine;
153
+ for (i = 0; i < arguments.length; i++) {
154
+ if (i == 6) return;
155
+ width = _columnWidth(arguments[i]);
156
+ alignment = _columnAlignment(arguments[i]);
157
+ if (width == 0 || width > remain) {
158
+ this.widthOfColumns[i] = columnWidthWithAlignment(remain, alignment);
159
+ return;
160
+ }
161
+ this.widthOfColumns[i] = arguments[i];
162
+ remain -= width;
163
+ }
237
164
  };
238
-
239
- // Print in columns with the current column settings.
240
- EscPosPrinter.prototype.printInColumns = function /*...*/
241
- () {
242
- var strcurr = new Array(MAX_COLUMNS);
243
- var strrem = new Array(MAX_COLUMNS);
244
- var strwidth = new Array(MAX_COLUMNS);
245
- var i, j, c, w, columns, width, alignment, pos;
246
- var done;
247
- if (arguments.length == 0) return;
248
- columns = 0;
249
- for (i = 0; i < arguments.length; i++) {
250
- if (i == MAX_COLUMNS || this.widthOfColumns[i] == 0) break;
251
- strcurr[i] = "";
252
- strrem[i] = arguments[i];
253
- columns++;
254
- }
255
- do {
256
- done = true;
257
- pos = 0;
258
- for (i = 0; i < columns; i++) {
259
- width = _columnWidth(this.widthOfColumns[i]);
260
- if (strrem[i].length == 0) {
261
- pos += width;
262
- continue;
263
- }
264
- done = false;
265
- strcurr[i] = "";
266
- strwidth[i] = 0;
267
- for (j = 0; j < strrem[i].length; j++) {
268
- c = strrem[i].charCodeAt(j);
269
- if (c == 0x0a) {
270
- j++; // Drop the '\n'
271
- break;
272
- } else {
273
- w = _widthOfChar(c);
274
- if (w == 0) {
275
- c = "?";
276
- w = 12;
277
- }
278
- w *= this.charHSize;
279
- if (strwidth[i] + w > width) {
280
- break;
281
- } else {
282
- strcurr[i] += String.fromCharCode(c);
283
- strwidth[i] += w;
284
- }
285
- }
286
- }
287
- if (j < strrem[i].length) strrem[i] = strrem[i].substring(j);else strrem[i] = "";
288
- alignment = _columnAlignment(this.widthOfColumns[i]);
289
- switch (alignment) {
290
- case ALIGN_CENTER:
291
- this.setAbsolutePrintPosition(pos + (width - strwidth[i]) / 2);
292
- break;
293
- case ALIGN_RIGHT:
294
- this.setAbsolutePrintPosition(pos + (width - strwidth[i]));
295
- break;
296
- default:
297
- this.setAbsolutePrintPosition(pos);
298
- break;
299
- }
300
- this.appendText(strcurr[i]);
301
- pos += width;
302
- }
303
- if (!done) this.lineFeed(1);
304
- } while (!done);
165
+ EscPosPrinter.prototype.printInColumns = function() {
166
+ var strcurr = new Array(6);
167
+ var strrem = new Array(6);
168
+ var strwidth = new Array(6);
169
+ var i, j, c, w, columns, width, alignment, pos;
170
+ var done;
171
+ if (arguments.length == 0) return;
172
+ columns = 0;
173
+ for (i = 0; i < arguments.length; i++) {
174
+ if (i == 6 || this.widthOfColumns[i] == 0) break;
175
+ strcurr[i] = "";
176
+ strrem[i] = arguments[i];
177
+ columns++;
178
+ }
179
+ do {
180
+ done = true;
181
+ pos = 0;
182
+ for (i = 0; i < columns; i++) {
183
+ width = _columnWidth(this.widthOfColumns[i]);
184
+ if (strrem[i].length == 0) {
185
+ pos += width;
186
+ continue;
187
+ }
188
+ done = false;
189
+ strcurr[i] = "";
190
+ strwidth[i] = 0;
191
+ for (j = 0; j < strrem[i].length; j++) {
192
+ c = strrem[i].charCodeAt(j);
193
+ if (c == 10) {
194
+ j++;
195
+ break;
196
+ } else {
197
+ w = _widthOfChar(c);
198
+ if (w == 0) {
199
+ c = "?";
200
+ w = 12;
201
+ }
202
+ w *= this.charHSize;
203
+ if (strwidth[i] + w > width) break;
204
+ else {
205
+ strcurr[i] += String.fromCharCode(c);
206
+ strwidth[i] += w;
207
+ }
208
+ }
209
+ }
210
+ if (j < strrem[i].length) strrem[i] = strrem[i].substring(j);
211
+ else strrem[i] = "";
212
+ alignment = _columnAlignment(this.widthOfColumns[i]);
213
+ switch (alignment) {
214
+ case 1:
215
+ this.setAbsolutePrintPosition(pos + (width - strwidth[i]) / 2);
216
+ break;
217
+ case 2:
218
+ this.setAbsolutePrintPosition(pos + (width - strwidth[i]));
219
+ break;
220
+ default:
221
+ this.setAbsolutePrintPosition(pos);
222
+ break;
223
+ }
224
+ this.appendText(strcurr[i]);
225
+ pos += width;
226
+ }
227
+ if (!done) this.lineFeed(1);
228
+ } while (!done);
305
229
  };
306
-
307
- //////////////////////////////////////////////////
308
- // Barcode / QR Code Printing
309
- //////////////////////////////////////////////////
310
-
311
- // Append barcode in the order.
312
- EscPosPrinter.prototype.appendBarcode = function (hri_pos, height, module_size, barcode_type, text) {
313
- var text_length = text.length;
314
- if (text_length == 0) return;
315
- if (text_length > 255) text_length = 255;
316
- if (height < 1) height = 1;else if (height > 255) height = 255;
317
- if (module_size < 1) module_size = 1;else if (module_size > 6) module_size = 6;
318
- this.orderData += "1d48" + _numToHexStr(hri_pos & 3, 1);
319
- this.orderData += "1d6600";
320
- this.orderData += "1d68" + _numToHexStr(height, 1);
321
- this.orderData += "1d77" + _numToHexStr(module_size, 1);
322
- this.orderData += "1d6b" + _numToHexStr(barcode_type, 1) + _numToHexStr(text_length, 1);
323
- for (var i = 0; i < text_length; i++) this.orderData += _numToHexStr(text.charCodeAt(i), 1);
230
+ EscPosPrinter.prototype.appendBarcode = function(hri_pos, height, module_size, barcode_type, text) {
231
+ var text_length = text.length;
232
+ if (text_length == 0) return;
233
+ if (text_length > 255) text_length = 255;
234
+ if (height < 1) height = 1;
235
+ else if (height > 255) height = 255;
236
+ if (module_size < 1) module_size = 1;
237
+ else if (module_size > 6) module_size = 6;
238
+ this.orderData += "1d48" + _numToHexStr(hri_pos & 3, 1);
239
+ this.orderData += "1d6600";
240
+ this.orderData += "1d68" + _numToHexStr(height, 1);
241
+ this.orderData += "1d77" + _numToHexStr(module_size, 1);
242
+ this.orderData += "1d6b" + _numToHexStr(barcode_type, 1) + _numToHexStr(text_length, 1);
243
+ for (var i = 0; i < text_length; i++) this.orderData += _numToHexStr(text.charCodeAt(i), 1);
324
244
  };
325
-
326
- // Append QR code in the order.
327
- EscPosPrinter.prototype.appendQRcode = function (module_size, ec_level, text) {
328
- var text_length = text.length;
329
- if (text_length == 0) return;
330
- if (text_length > 65535) text_length = 65535;
331
- if (module_size < 1) module_size = 1;else if (module_size > 16) module_size = 16;
332
- if (ec_level < 0) ec_level = 0;else if (ec_level > 3) ec_level = 3;
333
- this.orderData += "1d286b040031410000";
334
- this.orderData += "1d286b03003143" + _numToHexStr(module_size, 1);
335
- this.orderData += "1d286b03003145" + _numToHexStr(ec_level + 48, 1);
336
- this.orderData += "1d286b" + _numToHexStr(text_length + 3, 2) + "315030";
337
- for (var i = 0; i < text_length; i++) this.orderData += _numToHexStr(text.charCodeAt(i), 1);
338
- this.orderData += "1d286b0300315130";
245
+ EscPosPrinter.prototype.appendQRcode = function(module_size, ec_level, text) {
246
+ var text_length = text.length;
247
+ if (text_length == 0) return;
248
+ if (text_length > 65535) text_length = 65535;
249
+ if (module_size < 1) module_size = 1;
250
+ else if (module_size > 16) module_size = 16;
251
+ if (ec_level < 0) ec_level = 0;
252
+ else if (ec_level > 3) ec_level = 3;
253
+ this.orderData += "1d286b040031410000";
254
+ this.orderData += "1d286b03003143" + _numToHexStr(module_size, 1);
255
+ this.orderData += "1d286b03003145" + _numToHexStr(ec_level + 48, 1);
256
+ this.orderData += "1d286b" + _numToHexStr(text_length + 3, 2) + "315030";
257
+ for (var i = 0; i < text_length; i++) this.orderData += _numToHexStr(text.charCodeAt(i), 1);
258
+ this.orderData += "1d286b0300315130";
339
259
  };
340
-
341
- //////////////////////////////////////////////////
342
- // Image Printing
343
- //////////////////////////////////////////////////
344
-
345
- // Grayscale to mono - diffuse dithering.
346
260
  function _diffuseDither(src_data, width, height) {
347
- if (width <= 0 || height <= 0) return null;
348
- if (src_data.length < width * height) return null;
349
- var bmwidth = width + 7 >> 3;
350
- var dst_data = new Array(bmwidth * height);
351
- var line_buffer = new Array(2 * width);
352
- var i, p, q, x, y, mask;
353
- var line1, line2, b1, b2, tmp;
354
- var err, e1, e3, e5, e7;
355
- var not_last_line;
356
- line1 = 0;
357
- line2 = 1;
358
- for (i = 0; i < width; i++) {
359
- line_buffer[i] = 0;
360
- line_buffer[width + i] = src_data[i];
361
- }
362
- for (y = 0; y < height; y++) {
363
- tmp = line1;
364
- line1 = line2;
365
- line2 = tmp;
366
- not_last_line = y < height - 1;
367
- if (not_last_line) {
368
- p = (y + 1) * width;
369
- for (i = 0; i < width; i++) {
370
- line_buffer[line2 * width + i] = src_data[p];
371
- p++;
372
- }
373
- }
374
- q = y * bmwidth;
375
- for (i = 0; i < bmwidth; i++) {
376
- dst_data[q] = 0;
377
- q++;
378
- }
379
- b1 = 0;
380
- b2 = 0;
381
- q = y * bmwidth;
382
- mask = 0x80;
383
- for (x = 1; x <= width; x++) {
384
- var idx = line1 * width + b1;
385
- if (line_buffer[idx] < 128) {
386
- // Black pixel
387
- err = line_buffer[idx];
388
- dst_data[q] |= mask;
389
- } else {
390
- err = line_buffer[idx] - 255;
391
- }
392
- b1++;
393
- if (mask == 1) {
394
- q++;
395
- mask = 0x80;
396
- } else {
397
- mask >>= 1;
398
- }
399
- e7 = err * 7 + 8 >> 4;
400
- e5 = err * 5 + 8 >> 4;
401
- e3 = err * 3 + 8 >> 4;
402
- e1 = err - (e7 + e5 + e3);
403
- if (x < width) line_buffer[line1 * width + b1] += e7;
404
- if (not_last_line) {
405
- line_buffer[line2 * width + b2] += e5;
406
- if (x > 1) line_buffer[line2 * width + b2 - 1] += e3;
407
- if (x < width) line_buffer[line2 * width + b2 + 1] += e1;
408
- }
409
- b2++;
410
- }
411
- }
412
- return dst_data;
261
+ if (width <= 0 || height <= 0) return null;
262
+ if (src_data.length < width * height) return null;
263
+ var bmwidth = width + 7 >> 3;
264
+ var dst_data = new Array(bmwidth * height);
265
+ var line_buffer = new Array(2 * width);
266
+ var i, p, q, x, y, mask;
267
+ var line1, line2, b1, b2, tmp;
268
+ var err, e1, e3, e5, e7;
269
+ var not_last_line;
270
+ line1 = 0;
271
+ line2 = 1;
272
+ for (i = 0; i < width; i++) {
273
+ line_buffer[i] = 0;
274
+ line_buffer[width + i] = src_data[i];
275
+ }
276
+ for (y = 0; y < height; y++) {
277
+ tmp = line1;
278
+ line1 = line2;
279
+ line2 = tmp;
280
+ not_last_line = y < height - 1;
281
+ if (not_last_line) {
282
+ p = (y + 1) * width;
283
+ for (i = 0; i < width; i++) {
284
+ line_buffer[line2 * width + i] = src_data[p];
285
+ p++;
286
+ }
287
+ }
288
+ q = y * bmwidth;
289
+ for (i = 0; i < bmwidth; i++) {
290
+ dst_data[q] = 0;
291
+ q++;
292
+ }
293
+ b1 = 0;
294
+ b2 = 0;
295
+ q = y * bmwidth;
296
+ mask = 128;
297
+ for (x = 1; x <= width; x++) {
298
+ var idx = line1 * width + b1;
299
+ if (line_buffer[idx] < 128) {
300
+ err = line_buffer[idx];
301
+ dst_data[q] |= mask;
302
+ } else err = line_buffer[idx] - 255;
303
+ b1++;
304
+ if (mask == 1) {
305
+ q++;
306
+ mask = 128;
307
+ } else mask >>= 1;
308
+ e7 = err * 7 + 8 >> 4;
309
+ e5 = err * 5 + 8 >> 4;
310
+ e3 = err * 3 + 8 >> 4;
311
+ e1 = err - (e7 + e5 + e3);
312
+ if (x < width) line_buffer[line1 * width + b1] += e7;
313
+ if (not_last_line) {
314
+ line_buffer[line2 * width + b2] += e5;
315
+ if (x > 1) line_buffer[line2 * width + b2 - 1] += e3;
316
+ if (x < width) line_buffer[line2 * width + b2 + 1] += e1;
317
+ }
318
+ b2++;
319
+ }
320
+ }
321
+ return dst_data;
413
322
  }
414
-
415
- // Grayscale to mono - threshold dithering.
416
323
  function _thresholdDither(src_data, width, height) {
417
- if (width <= 0 || height <= 0) return null;
418
- if (src_data.length < width * height) return null;
419
- var bmwidth = width + 7 >> 3;
420
- var dst_data = new Array(bmwidth * height);
421
- var p, q, k, x, y, mask;
422
- p = 0;
423
- q = 0;
424
- for (y = 0; y < height; y++) {
425
- k = q;
426
- mask = 0x80;
427
- for (x = 0; x < width; x++) {
428
- if (src_data[p] < 128) {
429
- // Black pixel
430
- dst_data[k] |= mask;
431
- }
432
- p++;
433
- if (mask == 1) {
434
- k++;
435
- mask = 0x80;
436
- } else {
437
- mask >>= 1;
438
- }
439
- }
440
- q += bmwidth;
441
- }
442
- return dst_data;
324
+ if (width <= 0 || height <= 0) return null;
325
+ if (src_data.length < width * height) return null;
326
+ var bmwidth = width + 7 >> 3;
327
+ var dst_data = new Array(bmwidth * height);
328
+ var p = 0, q = 0, k, x, y, mask;
329
+ for (y = 0; y < height; y++) {
330
+ k = q;
331
+ mask = 128;
332
+ for (x = 0; x < width; x++) {
333
+ if (src_data[p] < 128) dst_data[k] |= mask;
334
+ p++;
335
+ if (mask == 1) {
336
+ k++;
337
+ mask = 128;
338
+ } else mask >>= 1;
339
+ }
340
+ q += bmwidth;
341
+ }
342
+ return dst_data;
443
343
  }
444
-
445
- // RGB to grayscale.
446
344
  function _convertToGray(imgdata, width, height) {
447
- var gray_data = new Array(width * height);
448
- var i = 0,
449
- j = 0,
450
- x,
451
- y,
452
- r,
453
- g,
454
- b;
455
- for (y = 0; y < height; y++) {
456
- for (x = 0; x < width; x++) {
457
- r = imgdata.data[j++] & 0xff;
458
- g = imgdata.data[j++] & 0xff;
459
- b = imgdata.data[j++] & 0xff;
460
- j++; // Skip the Alpha channel
461
- gray_data[i++] = r * 11 + g * 16 + b * 5 >> 5 & 0xff;
462
- }
463
- }
464
- return gray_data;
345
+ var gray_data = new Array(width * height);
346
+ var i = 0, j = 0, x, y, r, g, b;
347
+ for (y = 0; y < height; y++) for (x = 0; x < width; x++) {
348
+ r = imgdata.data[j++] & 255;
349
+ g = imgdata.data[j++] & 255;
350
+ b = imgdata.data[j++] & 255;
351
+ j++;
352
+ gray_data[i++] = r * 11 + g * 16 + b * 5 >> 5 & 255;
353
+ }
354
+ return gray_data;
465
355
  }
466
-
467
- // Append image in the order.
468
- EscPosPrinter.prototype.appendImage = function (imgdata, dither) {
469
- var gray_data, mono_data;
470
- var w = imgdata.width;
471
- var h = imgdata.height;
472
- gray_data = _convertToGray(imgdata, w, h);
473
- if (dither == "diffuse") mono_data = _diffuseDither(gray_data, w, h);
474
- /* if (dither == "threshold") */else mono_data = _thresholdDither(gray_data, w, h);
475
- w = w + 7 >> 3;
476
- this.orderData += "1d763000";
477
- this.orderData += _numToHexStr(w, 2);
478
- this.orderData += _numToHexStr(h, 2);
479
- for (var i = 0; i < mono_data.length; i++) this.orderData += _numToHexStr(mono_data[i] & 0xff, 1);
356
+ EscPosPrinter.prototype.appendImage = function(imgdata, dither) {
357
+ var gray_data, mono_data;
358
+ var w = imgdata.width;
359
+ var h = imgdata.height;
360
+ gray_data = _convertToGray(imgdata, w, h);
361
+ if (dither == "diffuse") mono_data = _diffuseDither(gray_data, w, h);
362
+ else mono_data = _thresholdDither(gray_data, w, h);
363
+ w = w + 7 >> 3;
364
+ this.orderData += "1d763000";
365
+ this.orderData += _numToHexStr(w, 2);
366
+ this.orderData += _numToHexStr(h, 2);
367
+ for (var i = 0; i < mono_data.length; i++) this.orderData += _numToHexStr(mono_data[i] & 255, 1);
480
368
  };
481
-
482
- //////////////////////////////////////////////////
483
- // Page Mode Commands
484
- //////////////////////////////////////////////////
485
-
486
- // Enter page mode.
487
- EscPosPrinter.prototype.enterPageMode = function () {
488
- this.orderData += "1b4c";
369
+ EscPosPrinter.prototype.enterPageMode = function() {
370
+ this.orderData += "1b4c";
489
371
  };
490
-
491
- // Set print area in page mode.
492
- // x, y: origin of the print area (the left-top corner of the print area)
493
- // w, h: width and height of the print area
494
- EscPosPrinter.prototype.setPrintAreaInPageMode = function (x, y, w, h) {
495
- this.orderData += "1b57";
496
- this.orderData += _numToHexStr(x, 2);
497
- this.orderData += _numToHexStr(y, 2);
498
- this.orderData += _numToHexStr(w, 2);
499
- this.orderData += _numToHexStr(h, 2);
372
+ EscPosPrinter.prototype.setPrintAreaInPageMode = function(x, y, w, h) {
373
+ this.orderData += "1b57";
374
+ this.orderData += _numToHexStr(x, 2);
375
+ this.orderData += _numToHexStr(y, 2);
376
+ this.orderData += _numToHexStr(w, 2);
377
+ this.orderData += _numToHexStr(h, 2);
500
378
  };
501
-
502
- // Set print direction in page mode.
503
- // dir: 0:not rotated; 1:90-degree clockwise rotated;
504
- // 2:180-degree clockwise rotated; 3:270-degree clockwise rotated
505
- EscPosPrinter.prototype.setPrintDirectionInPageMode = function (dir) {
506
- if (dir >= 0 && dir <= 3) this.orderData += "1b54" + _numToHexStr(dir, 1);
379
+ EscPosPrinter.prototype.setPrintDirectionInPageMode = function(dir) {
380
+ if (dir >= 0 && dir <= 3) this.orderData += "1b54" + _numToHexStr(dir, 1);
507
381
  };
508
-
509
- // Set absolute print position in page mode.
510
- EscPosPrinter.prototype.setAbsolutePrintPositionInPageMode = function (n) {
511
- if (n >= 0 && n <= 65535) this.orderData += "1d24" + _numToHexStr(n, 2);
382
+ EscPosPrinter.prototype.setAbsolutePrintPositionInPageMode = function(n) {
383
+ if (n >= 0 && n <= 65535) this.orderData += "1d24" + _numToHexStr(n, 2);
512
384
  };
513
-
514
- // Set relative print position in page mode.
515
- EscPosPrinter.prototype.setRelativePrintPositionInPageMode = function (n) {
516
- if (n >= -32768 && n <= 32767) this.orderData += "1d5c" + _numToHexStr(n, 2);
385
+ EscPosPrinter.prototype.setRelativePrintPositionInPageMode = function(n) {
386
+ if (n >= -32768 && n <= 32767) this.orderData += "1d5c" + _numToHexStr(n, 2);
517
387
  };
518
-
519
- // Print contents in the buffer and exit page mode.
520
- EscPosPrinter.prototype.printAndExitPageMode = function () {
521
- this.orderData += "0c";
388
+ EscPosPrinter.prototype.printAndExitPageMode = function() {
389
+ this.orderData += "0c";
522
390
  };
523
-
524
- // Print contents in the buffer and keep in page mode.
525
- EscPosPrinter.prototype.printInPageMode = function () {
526
- this.orderData += "1b0c";
391
+ EscPosPrinter.prototype.printInPageMode = function() {
392
+ this.orderData += "1b0c";
527
393
  };
528
-
529
- // Clear contents in the buffer and keep in page mode.
530
- EscPosPrinter.prototype.clearInPageMode = function () {
531
- this.orderData += "18";
394
+ EscPosPrinter.prototype.clearInPageMode = function() {
395
+ this.orderData += "18";
532
396
  };
533
-
534
- // Discard contents in the buffer and exit page mode.
535
- EscPosPrinter.prototype.exitPageMode = function () {
536
- this.orderData += "1b53";
397
+ EscPosPrinter.prototype.exitPageMode = function() {
398
+ this.orderData += "1b53";
537
399
  };
538
- export default EscPosPrinter;
400
+ //#endregion
401
+ export { ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, columnWidthWithAlignment, EscPosPrinter as default };