retail-print-kit 0.2.2 → 0.3.0
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/CHANGELOG.md +41 -0
- package/README.md +74 -3
- package/dist/label-design/builtins-data.d.ts +2 -0
- package/dist/label-design/builtins-data.js +1631 -0
- package/dist/label-design/builtins.d.ts +13 -0
- package/dist/label-design/builtins.js +124 -0
- package/dist/label-design/encode.d.ts +11 -0
- package/dist/label-design/encode.js +151 -0
- package/dist/label-design/fields.d.ts +30 -0
- package/dist/label-design/fields.js +115 -0
- package/dist/label-design/fonts.d.ts +6 -0
- package/dist/label-design/fonts.js +35 -0
- package/dist/label-design/image.d.ts +4 -0
- package/dist/label-design/image.js +48 -0
- package/dist/label-design/index.d.ts +12 -0
- package/dist/label-design/index.js +72 -0
- package/dist/label-design/printer-text.d.ts +12 -0
- package/dist/label-design/printer-text.js +18 -0
- package/dist/label-design/render.d.ts +30 -0
- package/dist/label-design/render.js +419 -0
- package/dist/label-design/types.d.ts +137 -0
- package/dist/label-design/types.js +2 -0
- package/dist/label-design/units.d.ts +5 -0
- package/dist/label-design/units.js +17 -0
- package/dist/label-design/validate.d.ts +15 -0
- package/dist/label-design/validate.js +97 -0
- package/dist/label-designer/designer.d.ts +26 -0
- package/dist/label-designer/designer.js +1311 -0
- package/dist/label-designer/index.d.ts +4 -0
- package/dist/label-designer/index.js +10 -0
- package/dist/label-designer/preview.d.ts +14 -0
- package/dist/label-designer/preview.js +73 -0
- package/dist/label-designer/styles.d.ts +1 -0
- package/dist/label-designer/styles.js +4 -0
- package/dist/label-fonts/FONTS.md +11 -0
- package/dist/label-fonts/archivo-narrow-400.woff2 +0 -0
- package/dist/label-fonts/archivo-narrow-700.woff2 +0 -0
- package/dist/label-fonts/archivo-narrow-OFL.txt +93 -0
- package/dist/label-fonts/arimo-400-italic.woff2 +0 -0
- package/dist/label-fonts/arimo-400.woff2 +0 -0
- package/dist/label-fonts/arimo-700.woff2 +0 -0
- package/dist/label-fonts/arimo-OFL.txt +93 -0
- package/dist/label-fonts/oswald-500.woff2 +0 -0
- package/dist/label-fonts/oswald-700.woff2 +0 -0
- package/dist/label-fonts/oswald-OFL.txt +93 -0
- package/dist/label-fonts/roboto-slab-400.woff2 +0 -0
- package/dist/label-fonts/roboto-slab-700.woff2 +0 -0
- package/dist/label-fonts/roboto-slab-LICENSE.txt +202 -0
- package/package.json +39 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.3.0 (2026-10-17)
|
|
4
|
+
|
|
5
|
+
* `retail-print-kit/label-design`: label designs in millimetres (design JSON version 1) with validation, one canvas renderer for screen and print, an EZPL/ZPL encoder (printer-font elements as native commands, designer fonts, QR codes and logos as graphics), printer offsets, eleven built-in shelf-label layouts and the fonts with their licences in `dist/label-fonts/`.
|
|
6
|
+
* `retail-print-kit/label-designer`: the `<rpk-label-designer>` Web Component (palette, drag and resize, guides, undo/redo, properties, logo upload, printer view, check against real items) and `<rpk-label-preview>`. Defined only in a browser; requiring it in Node does nothing.
|
|
7
|
+
* `typesVersions` so TypeScript projects using `moduleResolution: node` find the types of every subpath.
|
|
8
|
+
* Guide on the website: shelf labels from a label design.
|
|
9
|
+
|
|
10
|
+
## 0.2.3 (2026-10-05)
|
|
11
|
+
|
|
12
|
+
* Website with a landing page and ten task guides (receipts, Electron, cash drawer, Star TSP100, labels, templates, QR and barcodes, logos, discovery and status, migration from escpos / node-thermal-printer).
|
|
13
|
+
* The designer moved to `/designer/` on the site; `sitemap.xml`, `robots.txt`, `llms.txt` and `llms-full.txt` are published.
|
|
14
|
+
* README: guides and FAQ sections. Package description leads with the printer families.
|
|
15
|
+
|
|
16
|
+
## 0.2.2 (2026-10-05)
|
|
17
|
+
|
|
18
|
+
* A plain install is now 4 packages and under 2 MB with no native modules (was 34 packages and 30 MB).
|
|
19
|
+
* `@napi-rs/canvas` is an optional peer, as intended; it was being installed for everyone.
|
|
20
|
+
* QR codes are generated with the dependency-free `qrcode-generator`; text is encoded as UTF-8.
|
|
21
|
+
|
|
22
|
+
## 0.2.1 (2026-10-03)
|
|
23
|
+
|
|
24
|
+
* The repository and the designer address were renamed to `retail-print-kit`; all links follow.
|
|
25
|
+
|
|
26
|
+
## 0.2.0 (2026-10-03)
|
|
27
|
+
|
|
28
|
+
* Images and logos: `loadImage` with optional Floyd-Steinberg dithering, `ditherRgba`, `serializeBitmap`, a template `image` block, logo upload in the designer.
|
|
29
|
+
* `discoverNetworkPrinters` finds raw-printing hosts on the local networks and can identify each.
|
|
30
|
+
* CLI: `verify`, `verify-label`, `discover`, `image`. A hardware checklist documents what to confirm on real units.
|
|
31
|
+
|
|
32
|
+
## 0.1.0 (2026-10-03)
|
|
33
|
+
|
|
34
|
+
First release.
|
|
35
|
+
|
|
36
|
+
* ESC/POS, Star Line Mode and Star raster encoders with printer profiles.
|
|
37
|
+
* Network, USB and serial transports; printer status and `identify`.
|
|
38
|
+
* Receipt templates, HTML and PNG previews.
|
|
39
|
+
* Label printing in ZPL, TSPL and EZPL with an SVG preview and label templates.
|
|
40
|
+
* Browser bundle and the template designer.
|
|
41
|
+
* CLI: `test`, `drawer`, `status`, `identify`, `preview`, `print`, `profiles`, `list`.
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ A modern replacement for `escpos` / `node-thermal-printer`: ESC/POS **and** Star
|
|
|
10
10
|
network / serial, printer profiles instead of model `if`s, receipt and label **templates**, live
|
|
11
11
|
**previews**, a visual **designer**, and a CLI for testing hardware in the field.
|
|
12
12
|
|
|
13
|
-
**[
|
|
13
|
+
**[Website](https://arka162.github.io/retail-print-kit/)** · **[Designer](https://arka162.github.io/retail-print-kit/designer/)** · [Guides](https://arka162.github.io/retail-print-kit/guides/) · [Printer matrix](docs/printer-matrix.md) · [Changelog](CHANGELOG.md)
|
|
14
14
|
|
|
15
15
|

|
|
16
16
|
|
|
@@ -77,6 +77,20 @@ const { UsbTransport } = require('retail-print-kit/usb'); // new UsbTransp
|
|
|
77
77
|
const { SerialTransport } = require('retail-print-kit/serial'); // new SerialTransport('COM3', { baudRate: 9600 })
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
+
## Guides
|
|
81
|
+
|
|
82
|
+
* [Print a receipt from Node.js on an ESC/POS thermal printer](https://arka162.github.io/retail-print-kit/guides/print-receipt-nodejs.html)
|
|
83
|
+
* [Print receipts from an Electron app](https://arka162.github.io/retail-print-kit/guides/electron-receipt-printing.html)
|
|
84
|
+
* [Open a cash drawer](https://arka162.github.io/retail-print-kit/guides/open-cash-drawer-nodejs.html)
|
|
85
|
+
* [Print to a Star TSP100 or TSP143](https://arka162.github.io/retail-print-kit/guides/star-tsp100-nodejs.html)
|
|
86
|
+
* [Print ZPL, TSPL and EZPL labels](https://arka162.github.io/retail-print-kit/guides/zpl-tspl-ezpl-label-printing-nodejs.html)
|
|
87
|
+
* [Receipt and label templates and the visual designer](https://arka162.github.io/retail-print-kit/guides/receipt-template-designer.html)
|
|
88
|
+
* [Design shelf labels in millimetres and print them on Godex or Zebra](https://arka162.github.io/retail-print-kit/guides/label-design-shelf-labels.html)
|
|
89
|
+
* [QR codes and barcodes](https://arka162.github.io/retail-print-kit/guides/print-qr-code-barcode-receipt.html)
|
|
90
|
+
* [Print a logo or image](https://arka162.github.io/retail-print-kit/guides/print-logo-image-thermal-printer.html)
|
|
91
|
+
* [Find printers on the network and read status](https://arka162.github.io/retail-print-kit/guides/network-printer-discovery-status.html)
|
|
92
|
+
* [Migrating from escpos or node-thermal-printer](https://arka162.github.io/retail-print-kit/guides/escpos-node-thermal-printer-alternative.html)
|
|
93
|
+
|
|
80
94
|
## Supported printers
|
|
81
95
|
|
|
82
96
|
| Family | Profile ids | Command set |
|
|
@@ -157,9 +171,52 @@ const label = renderLabel(labelTemplate, data); // from a designer JSON
|
|
|
157
171
|
|
|
158
172
|

|
|
159
173
|
|
|
174
|
+
## Label designs (`retail-print-kit/label-design`)
|
|
175
|
+
|
|
176
|
+
A label design is a JSON document in millimetres (`version: 1`) made of text, price, barcode, QR, line,
|
|
177
|
+
box, fill and image elements with `{{field}}` placeholders. One renderer draws it on screen and at
|
|
178
|
+
printer resolution, so the preview is the print; one encoder turns it into EZPL (Godex) or ZPL (Zebra).
|
|
179
|
+
Elements with a printer-font pattern print as native commands byte for byte; designer fonts, prices,
|
|
180
|
+
QR codes and logos go as graphics (ZPL `^GFA`, EZPL `Q`). Eleven classic shelf-label layouts ship as
|
|
181
|
+
built-ins.
|
|
182
|
+
|
|
183
|
+
```js
|
|
184
|
+
const ld = require('retail-print-kit/label-design');
|
|
185
|
+
|
|
186
|
+
ld.validateDesign(design); // null, or the first problem
|
|
187
|
+
const data = ld.labelDataFromItem(item, { storeName: 'Main' }); // itemName, price, barcode, ...
|
|
188
|
+
ld.drawLabel(canvas, design, data, { ppm: 8 }); // screen preview, returns warnings
|
|
189
|
+
const rasterize = ld.createRasterizer(); // browser canvas, or pass canvasFactory
|
|
190
|
+
const bytes = ld.encodeDesignLabel(design, 'zpl', data, rasterize, { x: 0, y: 0 });
|
|
191
|
+
|
|
192
|
+
const builtin = ld.findBuiltinTemplate('2 X 1', 'dual', 'ezpl');
|
|
193
|
+
ld.encodeBuiltinLabel(builtin, 'ezpl', data); // printer fonts only
|
|
194
|
+
ld.designFromBuiltin(builtin, 'ezpl'); // editable copy, prints the same
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
The import has no DOM access, so it runs in Node, Electron and the browser. The fonts the designer
|
|
198
|
+
uses are in `dist/label-fonts/` with their licences; serve them and call `ld.ensureLabelFonts(url)`.
|
|
199
|
+
|
|
200
|
+
### The label designer element (`retail-print-kit/label-designer`)
|
|
201
|
+
|
|
202
|
+
A framework-free Web Component for apps where people design labels: palette of item fields, drag and
|
|
203
|
+
resize with guides and snapping, undo and redo, properties per element, logo upload, printer view
|
|
204
|
+
and a check against real items. It works in any framework (Angular, React, plain pages) and in Electron.
|
|
205
|
+
|
|
206
|
+
```js
|
|
207
|
+
import 'retail-print-kit/label-designer'; // defines <rpk-label-designer> and <rpk-label-preview>
|
|
208
|
+
const el = document.querySelector('rpk-label-designer');
|
|
209
|
+
el.fontsUrl = '/assets/label-fonts/';
|
|
210
|
+
el.design = design; el.name = 'Shelf tag';
|
|
211
|
+
el.itemSource = { search: (q) => api.items(q), page: (offset, limit) => api.page(offset, limit) };
|
|
212
|
+
el.addEventListener('designsave', (e) => api.save(e.detail.name, e.detail.design).then(() => el.markSaved()));
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Put your own buttons in its toolbar with `slot="actions"`. Colours come from `--rpk-*` CSS variables.
|
|
216
|
+
|
|
160
217
|
## Designer
|
|
161
218
|
|
|
162
|
-
**https://arka162.github.io/retail-print-kit/** edits receipt and label templates in the browser:
|
|
219
|
+
**https://arka162.github.io/retail-print-kit/designer/** edits receipt and label templates in the browser:
|
|
163
220
|
block palette, nested `each` / `if`, property editor, sample data, live preview, drag-to-position
|
|
164
221
|
on labels, logo upload with dithering, JSON import and export. It runs entirely in the page from
|
|
165
222
|
the browser bundle (`retail-print-kit/browser`); nothing is uploaded.
|
|
@@ -201,11 +258,25 @@ npx retail-print-kit profiles
|
|
|
201
258
|
|
|
202
259
|
Add `--dry` to any printing command to dump the bytes as hex instead of sending them.
|
|
203
260
|
|
|
261
|
+
## FAQ
|
|
262
|
+
|
|
263
|
+
**Does it work in Electron?** Yes, in the main process; the renderer asks for prints over IPC and the
|
|
264
|
+
browser build renders previews.
|
|
265
|
+
|
|
266
|
+
**Does it need a printer driver?** No. It sends the printer's own commands over TCP, USB or serial,
|
|
267
|
+
so there is no OS print dialog and nothing to install on the machine.
|
|
268
|
+
|
|
269
|
+
**Why does a Star TSP100 print nothing with other libraries?** It is raster-only and ignores ESC/POS
|
|
270
|
+
text. Use the `star-tsp100` profile.
|
|
271
|
+
|
|
272
|
+
**Can I print without a printer attached?** `--dry` dumps the bytes, and the HTML, PNG and SVG
|
|
273
|
+
previews show the result.
|
|
274
|
+
|
|
204
275
|
## Status of hardware verification
|
|
205
276
|
|
|
206
277
|
Encoders are covered by byte-exact tests. Items still to be confirmed on real units are listed in
|
|
207
278
|
the [hardware checklist](docs/hardware-checklist.md): Star raster cut modes, Star status bits,
|
|
208
|
-
Godex font sizes,
|
|
279
|
+
Godex font sizes, QR syntax on EZPL and TSPL, and the `label-design` graphics commands (EZPL `Q`, ZPL `^GFA`). Reports from the field are welcome as issues.
|
|
209
280
|
|
|
210
281
|
## License
|
|
211
282
|
|