@zpl-toolchain/print 0.1.4 → 0.1.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.
- package/README.md +10 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,22 +13,22 @@ npm install @zpl-toolchain/print
|
|
|
13
13
|
## Quick Start
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
|
-
import { print, TcpPrinter
|
|
16
|
+
import { print, TcpPrinter } from "@zpl-toolchain/print";
|
|
17
17
|
|
|
18
18
|
// One-shot: send ZPL and disconnect
|
|
19
|
-
const result = await print({ host: "192.168.1.55" }
|
|
19
|
+
const result = await print("^XA^FDHello^FS^XZ", { host: "192.168.1.55" });
|
|
20
20
|
console.log(result); // { success: true, bytesWritten: 21 }
|
|
21
21
|
|
|
22
|
-
// Check if a printer is reachable
|
|
23
|
-
if (await isReachable({ host: "192.168.1.55" })) {
|
|
24
|
-
console.log("Printer is online");
|
|
25
|
-
}
|
|
26
|
-
|
|
27
22
|
// Persistent connection: reuse for multiple labels
|
|
28
23
|
const printer = new TcpPrinter({ host: "192.168.1.55" });
|
|
29
24
|
await printer.print("^XA^FDLabel 1^FS^XZ");
|
|
30
25
|
await printer.print("^XA^FDLabel 2^FS^XZ");
|
|
31
26
|
|
|
27
|
+
// Check if a printer is reachable
|
|
28
|
+
if (await printer.isReachable()) {
|
|
29
|
+
console.log("Printer is online");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
32
|
// Query printer status
|
|
33
33
|
const status = await printer.getStatus();
|
|
34
34
|
console.log(`Paper out: ${status.paperOut}, Paused: ${status.paused}`);
|
|
@@ -54,9 +54,8 @@ await printer.close();
|
|
|
54
54
|
|
|
55
55
|
| Function | Description |
|
|
56
56
|
|----------|-------------|
|
|
57
|
-
| `print(
|
|
58
|
-
| `printValidated(
|
|
59
|
-
| `isReachable(config)` | Check if a printer accepts TCP connections |
|
|
57
|
+
| `print(zpl, config)` | Send ZPL and disconnect |
|
|
58
|
+
| `printValidated(zpl, config, opts?)` | Validate then print (requires `@zpl-toolchain/core`) |
|
|
60
59
|
|
|
61
60
|
### `TcpPrinter` — persistent connection
|
|
62
61
|
|
|
@@ -64,6 +63,7 @@ await printer.close();
|
|
|
64
63
|
|--------|-------------|
|
|
65
64
|
| `new TcpPrinter(config)` | Create a printer (connects lazily on first call) |
|
|
66
65
|
| `print(zpl)` | Send ZPL over the persistent connection |
|
|
66
|
+
| `isReachable()` | Check if the printer accepts TCP connections |
|
|
67
67
|
| `getStatus()` | Query `~HS` host status (paper out, paused, labels remaining, etc.) |
|
|
68
68
|
| `printBatch(labels, opts?, onProgress?)` | Send multiple labels with optional status polling and progress callbacks |
|
|
69
69
|
| `waitForCompletion(timeoutMs?)` | Poll until all labels are printed or timeout |
|