label-printer 0.7.0 → 0.7.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.mjs CHANGED
@@ -1730,6 +1730,45 @@ var TSPLPrinter = class _TSPLPrinter extends Printer {
1730
1730
  yield this.writeCommand(feedCommand);
1731
1731
  });
1732
1732
  }
1733
+ getModelname() {
1734
+ return __async(this, null, function* () {
1735
+ if (!this.device.opened) yield this.device.openAndConfigure();
1736
+ const command = new TSPLRawCommand("~!T");
1737
+ yield command.writeTo(this.device);
1738
+ const response = yield this.device.readString(256);
1739
+ return (response != null ? response : "").trim();
1740
+ });
1741
+ }
1742
+ getStatus() {
1743
+ return __async(this, null, function* () {
1744
+ if (!this.device.opened) yield this.device.openAndConfigure();
1745
+ yield this.device.writeData(new Uint8Array([27, 33, 63, 10]));
1746
+ const data = yield this.device.readData(1);
1747
+ const raw = data ? data.getUint8(0) : 128;
1748
+ return _TSPLPrinter.statusFor(raw);
1749
+ });
1750
+ }
1751
+ static statusFor(code) {
1752
+ var _a;
1753
+ const map = {
1754
+ 0: "normal",
1755
+ 1: "head_opened",
1756
+ 2: "paper_jam",
1757
+ 3: "paper_jam_head_opened",
1758
+ 4: "out_of_paper",
1759
+ 5: "out_of_paper_head_opened",
1760
+ 8: "out_of_ribbon",
1761
+ 9: "out_of_ribbon_head_opened",
1762
+ 10: "out_of_ribbon_paper_jam",
1763
+ 11: "out_of_ribbon_paper_jam_head_opened",
1764
+ 12: "out_of_ribbon_out_of_paper",
1765
+ 13: "out_of_ribbon_out_of_paper_head_opened",
1766
+ 16: "paused",
1767
+ 32: "printing",
1768
+ 128: "other_error"
1769
+ };
1770
+ return (_a = map[code]) != null ? _a : "other_error";
1771
+ }
1733
1772
  static try(device) {
1734
1773
  return __async(this, null, function* () {
1735
1774
  if (!device.opened) yield device.openAndConfigure();