label-printer 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +14 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -90,7 +90,12 @@ var Command = class {
|
|
|
90
90
|
*/
|
|
91
91
|
get commandBytes() {
|
|
92
92
|
const encoder = new TextEncoder();
|
|
93
|
-
|
|
93
|
+
const encoded = encoder.encode(this.commandString);
|
|
94
|
+
const terminator = this.commandTerminatorBytes;
|
|
95
|
+
const result = new Uint8Array(encoded.length + terminator.length);
|
|
96
|
+
result.set(encoded, 0);
|
|
97
|
+
result.set(terminator, encoded.length);
|
|
98
|
+
return result;
|
|
94
99
|
}
|
|
95
100
|
print(fn) {
|
|
96
101
|
fn(this.commandString);
|
|
@@ -167,14 +172,7 @@ var CommandGroup = class extends Command {
|
|
|
167
172
|
if (this.commands.length === 0) {
|
|
168
173
|
return new Uint8Array(0);
|
|
169
174
|
}
|
|
170
|
-
const
|
|
171
|
-
const byteArrays = [];
|
|
172
|
-
for (let i = 0; i < this.commands.length; i++) {
|
|
173
|
-
byteArrays.push(this.commands[i].commandBytes);
|
|
174
|
-
if (i < this.commands.length - 1) {
|
|
175
|
-
byteArrays.push(newlineBytes);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
175
|
+
const byteArrays = this.commands.map((c) => c.commandBytes);
|
|
178
176
|
const totalLength = byteArrays.reduce((sum, arr) => sum + arr.length, 0);
|
|
179
177
|
const result = new Uint8Array(totalLength);
|
|
180
178
|
let offset = 0;
|
|
@@ -1179,9 +1177,11 @@ var TSPLBitmapCommand = class _TSPLBitmapCommand extends TSPLVisualCommand {
|
|
|
1179
1177
|
get commandBytes() {
|
|
1180
1178
|
const encoder = new TextEncoder();
|
|
1181
1179
|
const commandBytes = encoder.encode(this.commandWithoutBytes);
|
|
1182
|
-
const
|
|
1180
|
+
const terminator = this.commandTerminatorBytes;
|
|
1181
|
+
const result = new Uint8Array(commandBytes.length + this.bitmap.bytes.length + terminator.length);
|
|
1183
1182
|
result.set(commandBytes, 0);
|
|
1184
1183
|
result.set(this.bitmap.bytes, commandBytes.length);
|
|
1184
|
+
result.set(terminator, commandBytes.length + this.bitmap.bytes.length);
|
|
1185
1185
|
return result;
|
|
1186
1186
|
}
|
|
1187
1187
|
writeTo(device) {
|
|
@@ -1369,9 +1369,11 @@ var TSPLDownload = class extends TSPLCommand {
|
|
|
1369
1369
|
const encoder = new TextEncoder();
|
|
1370
1370
|
const commandBytes = encoder.encode(this.commandString);
|
|
1371
1371
|
const dataBytes = this.data instanceof Uint8Array ? this.data : new Uint8Array(this.data);
|
|
1372
|
-
const
|
|
1372
|
+
const terminator = this.commandTerminatorBytes;
|
|
1373
|
+
const result = new Uint8Array(commandBytes.length + dataBytes.length + terminator.length);
|
|
1373
1374
|
result.set(commandBytes, 0);
|
|
1374
1375
|
result.set(dataBytes, commandBytes.length);
|
|
1376
|
+
result.set(terminator, commandBytes.length + dataBytes.length);
|
|
1375
1377
|
return result;
|
|
1376
1378
|
}
|
|
1377
1379
|
writeTo(device) {
|
|
@@ -2054,6 +2056,7 @@ var TSPLPrinter = class _TSPLPrinter extends Printer {
|
|
|
2054
2056
|
static try(device) {
|
|
2055
2057
|
return __async(this, null, function* () {
|
|
2056
2058
|
if (!device.opened) yield device.openAndConfigure();
|
|
2059
|
+
console.log("Response: ", device.opened);
|
|
2057
2060
|
const testCommand = new TSPLRawCommand("~!I");
|
|
2058
2061
|
yield testCommand.writeTo(device);
|
|
2059
2062
|
const response = yield device.readString(64);
|