retail-print-kit 0.2.3 → 0.3.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +45 -1
  3. package/dist/label-design/builtins-data.d.ts +2 -0
  4. package/dist/label-design/builtins-data.js +1631 -0
  5. package/dist/label-design/builtins.d.ts +13 -0
  6. package/dist/label-design/builtins.js +124 -0
  7. package/dist/label-design/encode.d.ts +11 -0
  8. package/dist/label-design/encode.js +151 -0
  9. package/dist/label-design/fields.d.ts +30 -0
  10. package/dist/label-design/fields.js +115 -0
  11. package/dist/label-design/fonts.d.ts +6 -0
  12. package/dist/label-design/fonts.js +35 -0
  13. package/dist/label-design/image.d.ts +4 -0
  14. package/dist/label-design/image.js +48 -0
  15. package/dist/label-design/index.d.ts +12 -0
  16. package/dist/label-design/index.js +72 -0
  17. package/dist/label-design/printer-text.d.ts +12 -0
  18. package/dist/label-design/printer-text.js +18 -0
  19. package/dist/label-design/render.d.ts +30 -0
  20. package/dist/label-design/render.js +419 -0
  21. package/dist/label-design/types.d.ts +137 -0
  22. package/dist/label-design/types.js +2 -0
  23. package/dist/label-design/units.d.ts +5 -0
  24. package/dist/label-design/units.js +17 -0
  25. package/dist/label-design/validate.d.ts +15 -0
  26. package/dist/label-design/validate.js +97 -0
  27. package/dist/label-designer/designer.d.ts +26 -0
  28. package/dist/label-designer/designer.js +1349 -0
  29. package/dist/label-designer/index.d.ts +4 -0
  30. package/dist/label-designer/index.js +10 -0
  31. package/dist/label-designer/preview.d.ts +14 -0
  32. package/dist/label-designer/preview.js +73 -0
  33. package/dist/label-designer/styles.d.ts +1 -0
  34. package/dist/label-designer/styles.js +4 -0
  35. package/dist/label-fonts/FONTS.md +11 -0
  36. package/dist/label-fonts/archivo-narrow-400.woff2 +0 -0
  37. package/dist/label-fonts/archivo-narrow-700.woff2 +0 -0
  38. package/dist/label-fonts/archivo-narrow-OFL.txt +93 -0
  39. package/dist/label-fonts/arimo-400-italic.woff2 +0 -0
  40. package/dist/label-fonts/arimo-400.woff2 +0 -0
  41. package/dist/label-fonts/arimo-700.woff2 +0 -0
  42. package/dist/label-fonts/arimo-OFL.txt +93 -0
  43. package/dist/label-fonts/oswald-500.woff2 +0 -0
  44. package/dist/label-fonts/oswald-700.woff2 +0 -0
  45. package/dist/label-fonts/oswald-OFL.txt +93 -0
  46. package/dist/label-fonts/roboto-slab-400.woff2 +0 -0
  47. package/dist/label-fonts/roboto-slab-700.woff2 +0 -0
  48. package/dist/label-fonts/roboto-slab-LICENSE.txt +202 -0
  49. package/package.json +34 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.1 (2026-10-17)
4
+
5
+ * `<rpk-label-designer>`: a clearer left bar. The search field keeps its full height and matches the other inputs, item fields and basic elements show icons, sections show their counts, the drag tip sits in its own box and layers show the element icon with an accent bar on the selected one. The left bar is a little wider so field names are not cut.
6
+
7
+ ## 0.3.0 (2026-10-17)
8
+
9
+ * `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/`.
10
+ * `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.
11
+ * `typesVersions` so TypeScript projects using `moduleResolution: node` find the types of every subpath.
12
+ * Guide on the website: shelf labels from a label design.
13
+
3
14
  ## 0.2.3 (2026-10-05)
4
15
 
5
16
  * 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).
package/README.md CHANGED
@@ -85,6 +85,7 @@ const { SerialTransport } = require('retail-print-kit/serial'); // new SerialTra
85
85
  * [Print to a Star TSP100 or TSP143](https://arka162.github.io/retail-print-kit/guides/star-tsp100-nodejs.html)
86
86
  * [Print ZPL, TSPL and EZPL labels](https://arka162.github.io/retail-print-kit/guides/zpl-tspl-ezpl-label-printing-nodejs.html)
87
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)
88
89
  * [QR codes and barcodes](https://arka162.github.io/retail-print-kit/guides/print-qr-code-barcode-receipt.html)
89
90
  * [Print a logo or image](https://arka162.github.io/retail-print-kit/guides/print-logo-image-thermal-printer.html)
90
91
  * [Find printers on the network and read status](https://arka162.github.io/retail-print-kit/guides/network-printer-discovery-status.html)
@@ -170,6 +171,49 @@ const label = renderLabel(labelTemplate, data); // from a designer JSON
170
171
 
171
172
  ![Label designer](https://raw.githubusercontent.com/arka162/retail-print-kit/main/docs/images/designer-label.png)
172
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
+
173
217
  ## Designer
174
218
 
175
219
  **https://arka162.github.io/retail-print-kit/designer/** edits receipt and label templates in the browser:
@@ -232,7 +276,7 @@ previews show the result.
232
276
 
233
277
  Encoders are covered by byte-exact tests. Items still to be confirmed on real units are listed in
234
278
  the [hardware checklist](docs/hardware-checklist.md): Star raster cut modes, Star status bits,
235
- Godex font sizes, and QR syntax on EZPL and TSPL. Reports from the field are welcome as issues.
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.
236
280
 
237
281
  ## License
238
282
 
@@ -0,0 +1,2 @@
1
+ import { BuiltinTemplate } from './types';
2
+ export declare const BUILTIN_TEMPLATES: BuiltinTemplate[];