Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"spec:lint": "pnpm --filter @wifilabel/codegen spec:lint",
"build": "turbo run build",
"typecheck": "turbo run typecheck",
"lint": "eslint . && prettier --check . && pnpm spec:lint",
"lint": "eslint . && prettier --check . && pnpm spec:lint && node scripts/check-package-readmes.mjs",
"test": "vitest run && pnpm test:c",
"test:c": "cmake -S c -B c/build-host && cmake --build c/build-host && ctest --test-dir c/build-host --output-on-failure",
"preview:labelary": "node scripts/preview-labelary.mjs"
Expand Down
9 changes: 9 additions & 0 deletions packages/epl2/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @wifilabel/epl2

## 0.1.1

### Patch Changes

- Document each package on npm.
- Updated dependencies
- @wifilabel/[email protected]
39 changes: 39 additions & 0 deletions packages/epl2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# @wifilabel/epl2

A short EPL2 setup sequence, plus the bitmap wrappers the firmware uses for EPL `GW` and TSPL `BITMAP`.

## Install

```bash
npm install @wifilabel/epl2
```

## Example

```ts
import { epl } from "@wifilabel/epl2";

const setup = [
epl.clearBuffer(),
epl.width(812),
epl.length(1218, 24),
epl.density(8),
epl.print(1),
].join("");
```

Each call returns one command and a newline. `812` by `1218` is a 4 inch by 6 inch label at 203 dpi. A number outside the spec range throws.

## What you get

`clearBuffer`, `width`, `length`, `speed`, `density`, `bottomFirst`, `topFirst`, `queryConfig`, `print`, `graphicWrite`, and `tsplBitmap`.

`graphicWrite` builds `N`, `GW`, and `P1` around a packed bitmap. `tsplBitmap` builds a TSPL job whose `SIZE` is fixed at 4x6 inches, the same helper the firmware uses.

## Limits

This is not a full EPL or TSPL language. There is no text, barcode, or font API. For ZPL, use [@wifilabel/zpl](https://www.npmjs.com/package/@wifilabel/zpl). Ranges come from [@wifilabel/printer-spec](https://www.npmjs.com/package/@wifilabel/printer-spec).

Zebra, ZPL, and Link-OS are trademarks of Zebra Technologies Corporation. This project is not affiliated with, endorsed by, or sponsored by Zebra Technologies.

Prefer a ready box? [wifilabel.com](https://wifilabel.com)
15 changes: 13 additions & 2 deletions packages/epl2/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
{
"name": "@wifilabel/epl2",
"version": "0.1.0",
"description": "Small EPL2 builders for legacy desktop label printers.",
"version": "0.1.1",
"description": "EPL2 setup commands and a TSPL bitmap wrapper for desktop label printers.",
"keywords": [
"epl2",
"epl",
"tspl",
"label-printer",
"thermal-printer"
],
"homepage": "https://wifilabel.com/",
"bugs": {
"url": "https://github.com/WiFiLabel/label-toolkit/issues"
},
"license": "MIT",
"author": "WiFiLabel <[email protected]>",
"type": "module",
Expand Down
7 changes: 7 additions & 0 deletions packages/spec/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @wifilabel/printer-spec

## 0.1.1

### Patch Changes

- Document each package on npm.
39 changes: 39 additions & 0 deletions packages/spec/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# @wifilabel/printer-spec

Typed ZPL commands, EPL2 commands, SGD settings, status layouts, and printer profiles. The YAML under `spec/` in the label-toolkit repo is the source. Codegen writes this package.

## Install

```bash
npm install @wifilabel/printer-spec
```

## Example

```ts
import { printers, settingByKey, zplCommandById } from "@wifilabel/printer-spec";

const ids = printers.map((printer) => printer.id);
const printWidth = zplCommandById.PW;
const darkness = settingByKey["media.darkness"];
```

## What you get

`zplCommands`, `eplCommands`, `settings`, `statuses`, and `printers`, plus the lookup maps `zplCommandById`, `eplCommandById`, and `settingByKey`.

Printer ids in this release: `gk420d`, `gx420d`, `lp2844`, `lp2844-z`, `zd410`, `zd420`, `zd421`, `zp450`.

Edit the YAML in the [label-toolkit repo](https://github.com/WiFiLabel/label-toolkit/tree/main/spec), then run codegen. Do not hand-edit the generated TypeScript or the JSON under `packages/spec/data/`.

The YAML shape is described at <https://github.com/WiFiLabel/label-toolkit/blob/main/docs/spec-format.md>.

## Limits

This package does not build printer bytes. Use [@wifilabel/zpl](https://www.npmjs.com/package/@wifilabel/zpl) or [@wifilabel/epl2](https://www.npmjs.com/package/@wifilabel/epl2) for that.

A printer field with `verified: false` is a starting point, not a measurement from that model. Read `notes` before you lock dpi, width, or top speed.

Zebra, ZPL, and Link-OS are trademarks of Zebra Technologies Corporation. This project is not affiliated with, endorsed by, or sponsored by Zebra Technologies.

Prefer a ready box? [wifilabel.com](https://wifilabel.com)
16 changes: 14 additions & 2 deletions packages/spec/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
{
"name": "@wifilabel/printer-spec",
"version": "0.1.0",
"description": "Generated command, SGD, status, and printer profiles for thermal label printers.",
"version": "0.1.1",
"description": "ZPL, EPL2, SGD, status, and printer profiles for thermal label printers.",
"keywords": [
"zpl",
"epl2",
"sgd",
"zebra",
"label-printer",
"thermal-printer"
],
"homepage": "https://wifilabel.com/",
"bugs": {
"url": "https://github.com/WiFiLabel/label-toolkit/issues"
},
"license": "MIT",
"author": "WiFiLabel <[email protected]>",
"type": "module",
Expand Down
9 changes: 9 additions & 0 deletions packages/transport-box/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @wifilabel/box-client

## 0.1.1

### Patch Changes

- Document each package on npm.
- Updated dependencies
- @wifilabel/[email protected]
37 changes: 37 additions & 0 deletions packages/transport-box/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# @wifilabel/box-client

A stub client for a WiFiLabel box on the local network. `write` holds bytes, and `read` posts them to the box.

## Install

```bash
npm install @wifilabel/box-client
```

## Example

```ts
import { BoxClient } from "@wifilabel/box-client";

const bytes = new Uint8Array([0x7e, 0x48, 0x49]);
const box = BoxClient.connect("http://192.168.1.20");
await box.write(bytes);
const reply = await box.read(4000);
const info = await box.info();
```

`read` POSTs the pending bytes to `/api/raw` and returns the body. `info` GETs `/api/info`.

## What you get

`BoxClient.connect` runs the address through `boxOrigin` first. The host has to be a private IPv4 address, a local IPv6 address, or `wifilabel-*.local`. The scheme has to be `http://`. A username, a password, or a public hostname throws.

Requests set `targetAddressSpace: "local"` so Chrome can show the local-network prompt.

## Limits

The client is the stub. The box has to serve those routes. The contract is <https://github.com/WiFiLabel/label-toolkit/blob/main/docs/box-api.md>.

It uses the same `write` / `read` / `close` shape as [@wifilabel/transport](https://www.npmjs.com/package/@wifilabel/transport). USB from the browser is [@wifilabel/webusb](https://www.npmjs.com/package/@wifilabel/webusb).

Prefer a ready box? [wifilabel.com](https://wifilabel.com)
11 changes: 10 additions & 1 deletion packages/transport-box/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
{
"name": "@wifilabel/box-client",
"version": "0.1.0",
"version": "0.1.1",
"description": "Stub client for a WiFiLabel box on the local network.",
"keywords": [
"label-printer",
"print-server",
"thermal-printer"
],
"homepage": "https://wifilabel.com/",
"bugs": {
"url": "https://github.com/WiFiLabel/label-toolkit/issues"
},
"license": "MIT",
"author": "WiFiLabel <[email protected]>",
"type": "module",
Expand Down
9 changes: 9 additions & 0 deletions packages/transport-webusb/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @wifilabel/webusb

## 0.1.1

### Patch Changes

- Document each package on npm.
- Updated dependencies
- @wifilabel/[email protected]
39 changes: 39 additions & 0 deletions packages/transport-webusb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# @wifilabel/webusb

Open a USB label printer from Chrome or Edge and use it as a [`Transport`](https://www.npmjs.com/package/@wifilabel/transport).

## Install

```bash
npm install @wifilabel/webusb
```

## Example

```ts
import { requestPrinter, WebUsbTransport } from "@wifilabel/webusb";

const bytes = new Uint8Array([0x7e, 0x48, 0x49]);
const device = await requestPrinter(navigator.usb);
const transport = await WebUsbTransport.open(device);
await transport.write(bytes);
const chunk = await transport.read(2000);
```

`bytes` here is `~HI`. There is no public constructor. `open` claims the bulk in and out endpoints.

## What you get

`requestPrinter` filters on Zebra's vendor id (`0x0a5f`) or USB printer class `0x07`. `permittedDevices` lists devices this origin already may use. `watchUsb` subscribes to connect and disconnect. `webUsbSupport` reports when `navigator.usb` is missing. `guidanceForUsbError` maps a failed claim to a short note for the current operating system.

The same browser flow is on <https://wifilabel.com/tools>.

## Limits

Safari and Firefox do not implement WebUSB. The page has to be a secure context, https or localhost. On Windows the Zebra driver can keep the interface, so the claim fails until that driver lets go. Use `guidanceForUsbError` for the text this package shows. It does not swap the OS driver for you.

Build the bytes with [@wifilabel/zpl](https://www.npmjs.com/package/@wifilabel/zpl) or [@wifilabel/epl2](https://www.npmjs.com/package/@wifilabel/epl2).

Zebra, ZPL, and Link-OS are trademarks of Zebra Technologies Corporation. This project is not affiliated with, endorsed by, or sponsored by Zebra Technologies.

Prefer a ready box? [wifilabel.com](https://wifilabel.com)
15 changes: 13 additions & 2 deletions packages/transport-webusb/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
{
"name": "@wifilabel/webusb",
"version": "0.1.0",
"description": "WebUSB transport for thermal label printers. Chromium only.",
"version": "0.1.1",
"description": "WebUSB transport for USB label printers. Chrome and Edge only.",
"keywords": [
"webusb",
"zebra",
"zpl",
"label-printer",
"thermal-printer"
],
"homepage": "https://wifilabel.com/",
"bugs": {
"url": "https://github.com/WiFiLabel/label-toolkit/issues"
},
"license": "MIT",
"author": "WiFiLabel <[email protected]>",
"type": "module",
Expand Down
7 changes: 7 additions & 0 deletions packages/transport/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @wifilabel/transport

## 0.1.1

### Patch Changes

- Document each package on npm.
35 changes: 35 additions & 0 deletions packages/transport/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# @wifilabel/transport

A `write` / `read` / `close` pipe for one label-printer session, a mock that scripts the replies, and a helper that reads until the line goes quiet.

## Install

```bash
npm install @wifilabel/transport
```

## Example

```ts
import { decodeLatin1, encodeAscii, MockTransport, readUntilQuiet } from "@wifilabel/transport";

const transport = new MockTransport(["ok"]);
await transport.write(encodeAscii("~HI"));
const reply = decodeLatin1(await readUntilQuiet(transport));
```

`MockTransport` records each write and returns the next scripted response on the following read. An empty read after that lets `readUntilQuiet` stop.

## What you get

`Transport` is three methods. `write` takes a `Uint8Array`. `read(timeoutMs)` resolves with bytes, or an empty array when that timeout elapsed with nothing new. `close` ends the session.

`readUntilQuiet` keeps calling `read` until a timeout comes back empty after some data, or the overall budget runs out. Defaults are 2000 ms total and 200 ms of quiet.

`encodeAscii` copies a string into bytes. A code point above 255 throws. `decodeLatin1` turns bytes back into a string.

## Limits

No USB and no sockets. Those adapters are [@wifilabel/webusb](https://www.npmjs.com/package/@wifilabel/webusb) and [@wifilabel/box-client](https://www.npmjs.com/package/@wifilabel/box-client). Command text comes from [@wifilabel/zpl](https://www.npmjs.com/package/@wifilabel/zpl) or [@wifilabel/epl2](https://www.npmjs.com/package/@wifilabel/epl2).

Prefer a ready box? [wifilabel.com](https://wifilabel.com)
10 changes: 9 additions & 1 deletion packages/transport/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
{
"name": "@wifilabel/transport",
"version": "0.1.0",
"version": "0.1.1",
"description": "Byte transport interface for thermal printer sessions. No network and no USB driver.",
"keywords": [
"label-printer",
"thermal-printer"
],
"homepage": "https://wifilabel.com/",
"bugs": {
"url": "https://github.com/WiFiLabel/label-toolkit/issues"
},
"license": "MIT",
"author": "WiFiLabel <[email protected]>",
"type": "module",
Expand Down
10 changes: 10 additions & 0 deletions packages/zpl/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# @wifilabel/zpl

## 0.1.1

### Patch Changes

- Document each package on npm.
- Updated dependencies
- @wifilabel/[email protected]
- @wifilabel/[email protected]
Loading
Loading