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.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -803,11 +803,12 @@ declare namespace index$1 {
|
|
|
803
803
|
export { index$1_BarCode as BarCode, index$1_Image as Image, index$1_Label as Label, index$1_LabelField as LabelField, index$1_Line as Line, index$1_QRCode as QRCode, index$1_Table as Table, index$1_Text as Text };
|
|
804
804
|
}
|
|
805
805
|
|
|
806
|
+
type PrinterStatus = "normal" | "head_opened" | "paper_jam" | "paper_jam_head_opened" | "out_of_paper" | "out_of_paper_head_opened" | "out_of_ribbon" | "out_of_ribbon_head_opened" | "out_of_ribbon_paper_jam" | "out_of_ribbon_paper_jam_head_opened" | "out_of_ribbon_out_of_paper" | "out_of_ribbon_out_of_paper_head_opened" | "paused" | "printing" | "other_error";
|
|
806
807
|
/**
|
|
807
808
|
* Base class that encapsulates functionality of all printers
|
|
808
809
|
*/
|
|
809
810
|
declare abstract class Printer {
|
|
810
|
-
|
|
811
|
+
protected readonly device: Device;
|
|
811
812
|
/**
|
|
812
813
|
* Printer language used by the type of printer the subclass represents
|
|
813
814
|
*/
|
|
@@ -816,6 +817,8 @@ declare abstract class Printer {
|
|
|
816
817
|
* When called, it will feed the labels to the beginig of the next label
|
|
817
818
|
*/
|
|
818
819
|
abstract feedLabel(): Promise<void>;
|
|
820
|
+
abstract getModelname(): Promise<string>;
|
|
821
|
+
abstract getStatus(): Promise<PrinterStatus>;
|
|
819
822
|
constructor(device: Device);
|
|
820
823
|
/**
|
|
821
824
|
* Close the printer USB
|
package/dist/index.d.ts
CHANGED
|
@@ -803,11 +803,12 @@ declare namespace index$1 {
|
|
|
803
803
|
export { index$1_BarCode as BarCode, index$1_Image as Image, index$1_Label as Label, index$1_LabelField as LabelField, index$1_Line as Line, index$1_QRCode as QRCode, index$1_Table as Table, index$1_Text as Text };
|
|
804
804
|
}
|
|
805
805
|
|
|
806
|
+
type PrinterStatus = "normal" | "head_opened" | "paper_jam" | "paper_jam_head_opened" | "out_of_paper" | "out_of_paper_head_opened" | "out_of_ribbon" | "out_of_ribbon_head_opened" | "out_of_ribbon_paper_jam" | "out_of_ribbon_paper_jam_head_opened" | "out_of_ribbon_out_of_paper" | "out_of_ribbon_out_of_paper_head_opened" | "paused" | "printing" | "other_error";
|
|
806
807
|
/**
|
|
807
808
|
* Base class that encapsulates functionality of all printers
|
|
808
809
|
*/
|
|
809
810
|
declare abstract class Printer {
|
|
810
|
-
|
|
811
|
+
protected readonly device: Device;
|
|
811
812
|
/**
|
|
812
813
|
* Printer language used by the type of printer the subclass represents
|
|
813
814
|
*/
|
|
@@ -816,6 +817,8 @@ declare abstract class Printer {
|
|
|
816
817
|
* When called, it will feed the labels to the beginig of the next label
|
|
817
818
|
*/
|
|
818
819
|
abstract feedLabel(): Promise<void>;
|
|
820
|
+
abstract getModelname(): Promise<string>;
|
|
821
|
+
abstract getStatus(): Promise<PrinterStatus>;
|
|
819
822
|
constructor(device: Device);
|
|
820
823
|
/**
|
|
821
824
|
* Close the printer USB
|
package/dist/index.js
CHANGED
|
@@ -1755,6 +1755,45 @@ var TSPLPrinter = class _TSPLPrinter extends Printer {
|
|
|
1755
1755
|
yield this.writeCommand(feedCommand);
|
|
1756
1756
|
});
|
|
1757
1757
|
}
|
|
1758
|
+
getModelname() {
|
|
1759
|
+
return __async(this, null, function* () {
|
|
1760
|
+
if (!this.device.opened) yield this.device.openAndConfigure();
|
|
1761
|
+
const command = new TSPLRawCommand("~!T");
|
|
1762
|
+
yield command.writeTo(this.device);
|
|
1763
|
+
const response = yield this.device.readString(256);
|
|
1764
|
+
return (response != null ? response : "").trim();
|
|
1765
|
+
});
|
|
1766
|
+
}
|
|
1767
|
+
getStatus() {
|
|
1768
|
+
return __async(this, null, function* () {
|
|
1769
|
+
if (!this.device.opened) yield this.device.openAndConfigure();
|
|
1770
|
+
yield this.device.writeData(new Uint8Array([27, 33, 63, 10]));
|
|
1771
|
+
const data = yield this.device.readData(1);
|
|
1772
|
+
const raw = data ? data.getUint8(0) : 128;
|
|
1773
|
+
return _TSPLPrinter.statusFor(raw);
|
|
1774
|
+
});
|
|
1775
|
+
}
|
|
1776
|
+
static statusFor(code) {
|
|
1777
|
+
var _a;
|
|
1778
|
+
const map = {
|
|
1779
|
+
0: "normal",
|
|
1780
|
+
1: "head_opened",
|
|
1781
|
+
2: "paper_jam",
|
|
1782
|
+
3: "paper_jam_head_opened",
|
|
1783
|
+
4: "out_of_paper",
|
|
1784
|
+
5: "out_of_paper_head_opened",
|
|
1785
|
+
8: "out_of_ribbon",
|
|
1786
|
+
9: "out_of_ribbon_head_opened",
|
|
1787
|
+
10: "out_of_ribbon_paper_jam",
|
|
1788
|
+
11: "out_of_ribbon_paper_jam_head_opened",
|
|
1789
|
+
12: "out_of_ribbon_out_of_paper",
|
|
1790
|
+
13: "out_of_ribbon_out_of_paper_head_opened",
|
|
1791
|
+
16: "paused",
|
|
1792
|
+
32: "printing",
|
|
1793
|
+
128: "other_error"
|
|
1794
|
+
};
|
|
1795
|
+
return (_a = map[code]) != null ? _a : "other_error";
|
|
1796
|
+
}
|
|
1758
1797
|
static try(device) {
|
|
1759
1798
|
return __async(this, null, function* () {
|
|
1760
1799
|
if (!device.opened) yield device.openAndConfigure();
|