@aglyn/plugins-commerce 1.0.0-beta.230 → 1.0.0-beta.232

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 (609) hide show
  1. package/package.json +13 -13
  2. package/src/index.d.ts +0 -1
  3. package/src/index.js +0 -1
  4. package/src/index.js.map +1 -1
  5. package/src/lib/barcode/barcode-decode.d.ts +71 -0
  6. package/src/lib/barcode/barcode-decode.js +498 -0
  7. package/src/lib/barcode/barcode-decode.js.map +1 -0
  8. package/src/lib/barcode/barcode-encode.d.ts +44 -0
  9. package/src/lib/barcode/barcode-encode.js +138 -0
  10. package/src/lib/barcode/barcode-encode.js.map +1 -0
  11. package/src/lib/barcode/barcode-scanner.component.d.ts +23 -0
  12. package/src/lib/barcode/barcode-scanner.component.js +260 -0
  13. package/src/lib/barcode/barcode-scanner.component.js.map +1 -0
  14. package/src/lib/barcode/scan-button.component.d.ts +10 -0
  15. package/src/lib/barcode/scan-button.component.js +62 -0
  16. package/src/lib/barcode/scan-button.component.js.map +1 -0
  17. package/src/lib/barcode/scanner-wedge.d.ts +35 -0
  18. package/src/lib/barcode/scanner-wedge.js +108 -0
  19. package/src/lib/barcode/scanner-wedge.js.map +1 -0
  20. package/src/lib/components/account.js +10 -1
  21. package/src/lib/components/account.js.map +1 -1
  22. package/src/lib/components/cart-extras.d.ts +45 -0
  23. package/src/lib/components/cart-extras.js +127 -0
  24. package/src/lib/components/cart-extras.js.map +1 -0
  25. package/src/lib/components/cart.js +82 -15
  26. package/src/lib/components/cart.js.map +1 -1
  27. package/src/lib/components/checkout-return-notice.d.ts +26 -0
  28. package/src/lib/components/checkout-return-notice.js +48 -0
  29. package/src/lib/components/checkout-return-notice.js.map +1 -0
  30. package/src/lib/components/commerce-console-page.js +124 -0
  31. package/src/lib/components/commerce-console-page.js.map +1 -1
  32. package/src/lib/components/commerce-console-sections.d.ts +1 -1
  33. package/src/lib/components/commerce-console-sections.js +4 -0
  34. package/src/lib/components/commerce-console-sections.js.map +1 -1
  35. package/src/lib/components/console/bulk-fulfill.d.ts +44 -0
  36. package/src/lib/components/console/bulk-fulfill.js +84 -0
  37. package/src/lib/components/console/bulk-fulfill.js.map +1 -0
  38. package/src/lib/components/console/catalog-organization-card.component.js +1 -0
  39. package/src/lib/components/console/catalog-organization-card.component.js.map +1 -1
  40. package/src/lib/components/console/customer-notifications-card.component.d.ts +19 -0
  41. package/src/lib/components/console/customer-notifications-card.component.js +149 -0
  42. package/src/lib/components/console/customer-notifications-card.component.js.map +1 -0
  43. package/src/lib/components/console/host-orders-card.component.js +88 -6
  44. package/src/lib/components/console/host-orders-card.component.js.map +1 -1
  45. package/src/lib/components/console/locations-card.component.js +164 -57
  46. package/src/lib/components/console/locations-card.component.js.map +1 -1
  47. package/src/lib/components/console/order-detail-dialog.component.js +209 -61
  48. package/src/lib/components/console/order-detail-dialog.component.js.map +1 -1
  49. package/src/lib/components/console/order-fulfillment-panel.component.d.ts +48 -0
  50. package/src/lib/components/console/order-fulfillment-panel.component.js +542 -0
  51. package/src/lib/components/console/order-fulfillment-panel.component.js.map +1 -0
  52. package/src/lib/components/console/order-invoice.component.d.ts +33 -0
  53. package/src/lib/components/console/order-invoice.component.js +81 -0
  54. package/src/lib/components/console/order-invoice.component.js.map +1 -0
  55. package/src/lib/components/console/order-receipt-resend.component.d.ts +21 -0
  56. package/src/lib/components/console/order-receipt-resend.component.js +203 -0
  57. package/src/lib/components/console/order-receipt-resend.component.js.map +1 -0
  58. package/src/lib/components/console/order-returns.component.d.ts +36 -0
  59. package/src/lib/components/console/order-returns.component.js +142 -0
  60. package/src/lib/components/console/order-returns.component.js.map +1 -0
  61. package/src/lib/components/console/order-shipping-actions.component.d.ts +54 -0
  62. package/src/lib/components/console/order-shipping-actions.component.js +149 -0
  63. package/src/lib/components/console/order-shipping-actions.component.js.map +1 -0
  64. package/src/lib/components/console/order-webhooks-card.component.d.ts +50 -0
  65. package/src/lib/components/console/order-webhooks-card.component.js +623 -0
  66. package/src/lib/components/console/order-webhooks-card.component.js.map +1 -0
  67. package/src/lib/components/console/order-zones.d.ts +155 -0
  68. package/src/lib/components/console/order-zones.js +40 -0
  69. package/src/lib/components/console/order-zones.js.map +1 -0
  70. package/src/lib/components/console/payment-methods-card.component.d.ts +67 -0
  71. package/src/lib/components/console/payment-methods-card.component.js +395 -0
  72. package/src/lib/components/console/payment-methods-card.component.js.map +1 -0
  73. package/src/lib/components/console/pos/pos-api.d.ts +124 -0
  74. package/src/lib/components/console/pos/pos-api.js +101 -0
  75. package/src/lib/components/console/pos/pos-api.js.map +1 -0
  76. package/src/lib/components/console/pos/pos-cart-panel.component.d.ts +36 -0
  77. package/src/lib/components/console/pos/pos-cart-panel.component.js +160 -0
  78. package/src/lib/components/console/pos/pos-cart-panel.component.js.map +1 -0
  79. package/src/lib/components/console/pos/pos-item-dialog.component.d.ts +39 -0
  80. package/src/lib/components/console/pos/pos-item-dialog.component.js +352 -0
  81. package/src/lib/components/console/pos/pos-item-dialog.component.js.map +1 -0
  82. package/src/lib/components/console/pos/pos-product-grid.component.d.ts +47 -0
  83. package/src/lib/components/console/pos/pos-product-grid.component.js +272 -0
  84. package/src/lib/components/console/pos/pos-product-grid.component.js.map +1 -0
  85. package/src/lib/components/console/pos/pos-receipt-panel.component.d.ts +27 -0
  86. package/src/lib/components/console/pos/pos-receipt-panel.component.js +282 -0
  87. package/src/lib/components/console/pos/pos-receipt-panel.component.js.map +1 -0
  88. package/src/lib/components/console/pos/pos-tender-dialogs.component.d.ts +53 -0
  89. package/src/lib/components/console/pos/pos-tender-dialogs.component.js +445 -0
  90. package/src/lib/components/console/pos/pos-tender-dialogs.component.js.map +1 -0
  91. package/src/lib/components/console/pos/pos-tender-panel.component.d.ts +31 -0
  92. package/src/lib/components/console/pos/pos-tender-panel.component.js +640 -0
  93. package/src/lib/components/console/pos/pos-tender-panel.component.js.map +1 -0
  94. package/src/lib/components/console/pos/use-pos-display.d.ts +43 -0
  95. package/src/lib/components/console/pos/use-pos-display.js +161 -0
  96. package/src/lib/components/console/pos/use-pos-display.js.map +1 -0
  97. package/src/lib/components/console/pos-devices-card.component.d.ts +14 -0
  98. package/src/lib/components/console/pos-devices-card.component.js +546 -0
  99. package/src/lib/components/console/pos-devices-card.component.js.map +1 -0
  100. package/src/lib/components/console/pos-display/brand-screen.d.ts +33 -0
  101. package/src/lib/components/console/pos-display/brand-screen.js +85 -0
  102. package/src/lib/components/console/pos-display/brand-screen.js.map +1 -0
  103. package/src/lib/components/console/pos-display/cart-screen.d.ts +29 -0
  104. package/src/lib/components/console/pos-display/cart-screen.js +166 -0
  105. package/src/lib/components/console/pos-display/cart-screen.js.map +1 -0
  106. package/src/lib/components/console/pos-display/pairing-screen.d.ts +24 -0
  107. package/src/lib/components/console/pos-display/pairing-screen.js +127 -0
  108. package/src/lib/components/console/pos-display/pairing-screen.js.map +1 -0
  109. package/src/lib/components/console/pos-display/pos-display-api.d.ts +90 -0
  110. package/src/lib/components/console/pos-display/pos-display-api.js +140 -0
  111. package/src/lib/components/console/pos-display/pos-display-api.js.map +1 -0
  112. package/src/lib/components/console/pos-display/receipt-screen.d.ts +35 -0
  113. package/src/lib/components/console/pos-display/receipt-screen.js +200 -0
  114. package/src/lib/components/console/pos-display/receipt-screen.js.map +1 -0
  115. package/src/lib/components/console/pos-display/tip-screen.d.ts +36 -0
  116. package/src/lib/components/console/pos-display/tip-screen.js +211 -0
  117. package/src/lib/components/console/pos-display/tip-screen.js.map +1 -0
  118. package/src/lib/components/console/pos-display-page.component.d.ts +16 -0
  119. package/src/lib/components/console/pos-display-page.component.js +407 -0
  120. package/src/lib/components/console/pos-display-page.component.js.map +1 -0
  121. package/src/lib/components/console/pos-ops/pos-customer-lookup.component.d.ts +40 -0
  122. package/src/lib/components/console/pos-ops/pos-customer-lookup.component.js +289 -0
  123. package/src/lib/components/console/pos-ops/pos-customer-lookup.component.js.map +1 -0
  124. package/src/lib/components/console/pos-ops/pos-last-receipt.component.d.ts +34 -0
  125. package/src/lib/components/console/pos-ops/pos-last-receipt.component.js +61 -0
  126. package/src/lib/components/console/pos-ops/pos-last-receipt.component.js.map +1 -0
  127. package/src/lib/components/console/pos-ops/pos-operations-bar.component.d.ts +38 -0
  128. package/src/lib/components/console/pos-ops/pos-operations-bar.component.js +129 -0
  129. package/src/lib/components/console/pos-ops/pos-operations-bar.component.js.map +1 -0
  130. package/src/lib/components/console/pos-ops/pos-ops-api.d.ts +37 -0
  131. package/src/lib/components/console/pos-ops/pos-ops-api.js +60 -0
  132. package/src/lib/components/console/pos-ops/pos-ops-api.js.map +1 -0
  133. package/src/lib/components/console/pos-ops/pos-pin-pad.component.d.ts +48 -0
  134. package/src/lib/components/console/pos-ops/pos-pin-pad.component.js +220 -0
  135. package/src/lib/components/console/pos-ops/pos-pin-pad.component.js.map +1 -0
  136. package/src/lib/components/console/pos-ops/pos-receipt-actions.component.d.ts +63 -0
  137. package/src/lib/components/console/pos-ops/pos-receipt-actions.component.js +186 -0
  138. package/src/lib/components/console/pos-ops/pos-receipt-actions.component.js.map +1 -0
  139. package/src/lib/components/console/pos-ops/pos-receipt.d.ts +39 -0
  140. package/src/lib/components/console/pos-ops/pos-receipt.js +182 -0
  141. package/src/lib/components/console/pos-ops/pos-receipt.js.map +1 -0
  142. package/src/lib/components/console/pos-ops/pos-return-dialog.component.d.ts +40 -0
  143. package/src/lib/components/console/pos-ops/pos-return-dialog.component.js +465 -0
  144. package/src/lib/components/console/pos-ops/pos-return-dialog.component.js.map +1 -0
  145. package/src/lib/components/console/pos-ops/pos-shift-history-card.component.d.ts +29 -0
  146. package/src/lib/components/console/pos-ops/pos-shift-history-card.component.js +253 -0
  147. package/src/lib/components/console/pos-ops/pos-shift-history-card.component.js.map +1 -0
  148. package/src/lib/components/console/pos-ops/pos-shift-panel.component.d.ts +34 -0
  149. package/src/lib/components/console/pos-ops/pos-shift-panel.component.js +494 -0
  150. package/src/lib/components/console/pos-ops/pos-shift-panel.component.js.map +1 -0
  151. package/src/lib/components/console/pos-ops/pos-shift-report.component.d.ts +37 -0
  152. package/src/lib/components/console/pos-ops/pos-shift-report.component.js +102 -0
  153. package/src/lib/components/console/pos-ops/pos-shift-report.component.js.map +1 -0
  154. package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.d.ts +30 -0
  155. package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.js +277 -0
  156. package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.js.map +1 -0
  157. package/src/lib/components/console/pos-ops/register-ops.d.ts +28 -0
  158. package/src/lib/components/console/pos-ops/register-ops.js +28 -0
  159. package/src/lib/components/console/pos-ops/register-ops.js.map +1 -0
  160. package/src/lib/components/console/pos-ops/use-pos-cashier.d.ts +46 -0
  161. package/src/lib/components/console/pos-ops/use-pos-cashier.js +128 -0
  162. package/src/lib/components/console/pos-ops/use-pos-cashier.js.map +1 -0
  163. package/src/lib/components/console/pos-ops/use-pos-sale-receipt.d.ts +36 -0
  164. package/src/lib/components/console/pos-ops/use-pos-sale-receipt.js +64 -0
  165. package/src/lib/components/console/pos-ops/use-pos-sale-receipt.js.map +1 -0
  166. package/src/lib/components/console/pos-page.component.d.ts +13 -5
  167. package/src/lib/components/console/pos-page.component.js +756 -654
  168. package/src/lib/components/console/pos-page.component.js.map +1 -1
  169. package/src/lib/components/console/pos-zones.d.ts +23 -0
  170. package/src/lib/components/console/pos-zones.js +31 -0
  171. package/src/lib/components/console/pos-zones.js.map +1 -0
  172. package/src/lib/components/console/product-editor-dialog.component.js +61 -71
  173. package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
  174. package/src/lib/components/console/product-labels-dialog.component.d.ts +13 -0
  175. package/src/lib/components/console/product-labels-dialog.component.js +197 -0
  176. package/src/lib/components/console/product-labels-dialog.component.js.map +1 -0
  177. package/src/lib/components/console/product-register-fields.component.d.ts +19 -0
  178. package/src/lib/components/console/product-register-fields.component.js +241 -0
  179. package/src/lib/components/console/product-register-fields.component.js.map +1 -0
  180. package/src/lib/components/console/product-zones.d.ts +44 -0
  181. package/src/lib/components/console/product-zones.js.map +1 -1
  182. package/src/lib/components/console/products-hub-card.component.js +23 -20
  183. package/src/lib/components/console/products-hub-card.component.js.map +1 -1
  184. package/src/lib/components/console/register-hardware-card.component.d.ts +33 -0
  185. package/src/lib/components/console/register-hardware-card.component.js +826 -0
  186. package/src/lib/components/console/register-hardware-card.component.js.map +1 -0
  187. package/src/lib/components/console/registers-card.component.js +24 -5
  188. package/src/lib/components/console/registers-card.component.js.map +1 -1
  189. package/src/lib/components/console/return-actions.d.ts +38 -0
  190. package/src/lib/components/console/return-actions.js +76 -0
  191. package/src/lib/components/console/return-actions.js.map +1 -0
  192. package/src/lib/components/console/return-detail-dialog.component.d.ts +34 -0
  193. package/src/lib/components/console/return-detail-dialog.component.js +718 -0
  194. package/src/lib/components/console/return-detail-dialog.component.js.map +1 -0
  195. package/src/lib/components/console/return-settings-card.component.d.ts +34 -0
  196. package/src/lib/components/console/return-settings-card.component.js +195 -0
  197. package/src/lib/components/console/return-settings-card.component.js.map +1 -0
  198. package/src/lib/components/console/return-zones.d.ts +87 -0
  199. package/src/lib/components/console/return-zones.js +31 -0
  200. package/src/lib/components/console/return-zones.js.map +1 -0
  201. package/src/lib/components/console/returns-card.component.d.ts +45 -0
  202. package/src/lib/components/console/returns-card.component.js +159 -0
  203. package/src/lib/components/console/returns-card.component.js.map +1 -0
  204. package/src/lib/components/console/shipping-settings-card.component.js +161 -5
  205. package/src/lib/components/console/shipping-settings-card.component.js.map +1 -1
  206. package/src/lib/components/console/shippingeasy-card.component.d.ts +59 -0
  207. package/src/lib/components/console/shippingeasy-card.component.js +378 -0
  208. package/src/lib/components/console/shippingeasy-card.component.js.map +1 -0
  209. package/src/lib/components/console/shipstation-card.component.d.ts +35 -0
  210. package/src/lib/components/console/shipstation-card.component.js +345 -0
  211. package/src/lib/components/console/shipstation-card.component.js.map +1 -0
  212. package/src/lib/components/console/start-return-dialog.component.d.ts +40 -0
  213. package/src/lib/components/console/start-return-dialog.component.js +243 -0
  214. package/src/lib/components/console/start-return-dialog.component.js.map +1 -0
  215. package/src/lib/components/console/stock-movements-card.component.js +2 -1
  216. package/src/lib/components/console/stock-movements-card.component.js.map +1 -1
  217. package/src/lib/components/console/store-settings-card.component.js +2 -66
  218. package/src/lib/components/console/store-settings-card.component.js.map +1 -1
  219. package/src/lib/components/console/store-zones.d.ts +42 -0
  220. package/src/lib/components/console/store-zones.js +39 -0
  221. package/src/lib/components/console/store-zones.js.map +1 -0
  222. package/src/lib/components/console/storefront-tax-summary-card.component.js +1 -0
  223. package/src/lib/components/console/storefront-tax-summary-card.component.js.map +1 -1
  224. package/src/lib/components/order-status.d.ts +36 -0
  225. package/src/lib/components/order-status.js +502 -0
  226. package/src/lib/components/order-status.js.map +1 -0
  227. package/src/lib/components/product-detail.js +41 -2
  228. package/src/lib/components/product-detail.js.map +1 -1
  229. package/src/lib/components/return-request.d.ts +32 -0
  230. package/src/lib/components/return-request.js +576 -0
  231. package/src/lib/components/return-request.js.map +1 -0
  232. package/src/lib/components/storefront-payment-appearance.d.ts +32 -0
  233. package/src/lib/components/storefront-payment-appearance.js +114 -0
  234. package/src/lib/components/storefront-payment-appearance.js.map +1 -0
  235. package/src/lib/components/storefront-payment-element.d.ts +57 -1
  236. package/src/lib/components/storefront-payment-element.js +332 -33
  237. package/src/lib/components/storefront-payment-element.js.map +1 -1
  238. package/src/lib/constants/order-status.d.ts +22 -0
  239. package/src/lib/constants/order-status.js +22 -0
  240. package/src/lib/constants/order-status.js.map +1 -0
  241. package/src/lib/constants/return-request.d.ts +27 -0
  242. package/src/lib/constants/return-request.js +32 -0
  243. package/src/lib/constants/return-request.js.map +1 -0
  244. package/src/lib/constants/stock-movement-query.js +2 -1
  245. package/src/lib/constants/stock-movement-query.js.map +1 -1
  246. package/src/lib/declarations.console-server.js +9 -0
  247. package/src/lib/declarations.console-server.js.map +1 -1
  248. package/src/lib/declarations.server.d.ts +2 -1
  249. package/src/lib/declarations.server.js +68 -1
  250. package/src/lib/declarations.server.js.map +1 -1
  251. package/src/lib/model/buyer-notifications.d.ts +59 -0
  252. package/src/lib/model/buyer-notifications.js +97 -0
  253. package/src/lib/model/buyer-notifications.js.map +1 -0
  254. package/src/lib/model/commerce-orders.d.ts +171 -2
  255. package/src/lib/model/commerce-orders.js +26 -16
  256. package/src/lib/model/commerce-orders.js.map +1 -1
  257. package/src/lib/model/commerce-payment-methods.d.ts +146 -0
  258. package/src/lib/model/commerce-payment-methods.js +247 -0
  259. package/src/lib/model/commerce-payment-methods.js.map +1 -0
  260. package/src/lib/model/commerce-pos-ops.d.ts +437 -0
  261. package/src/lib/model/commerce-pos-ops.js +721 -0
  262. package/src/lib/model/commerce-pos-ops.js.map +1 -0
  263. package/src/lib/model/commerce-pos.d.ts +263 -0
  264. package/src/lib/model/commerce-pos.js +375 -0
  265. package/src/lib/model/commerce-pos.js.map +1 -0
  266. package/src/lib/model/commerce-printers.d.ts +211 -0
  267. package/src/lib/model/commerce-printers.js +181 -0
  268. package/src/lib/model/commerce-printers.js.map +1 -0
  269. package/src/lib/model/commerce-receipt.d.ts +97 -0
  270. package/src/lib/model/commerce-receipt.js +180 -0
  271. package/src/lib/model/commerce-receipt.js.map +1 -0
  272. package/src/lib/model/commerce-returns.d.ts +207 -0
  273. package/src/lib/model/commerce-returns.js +300 -0
  274. package/src/lib/model/commerce-returns.js.map +1 -0
  275. package/src/lib/model/commerce-shipping.d.ts +44 -1
  276. package/src/lib/model/commerce-shipping.js +53 -9
  277. package/src/lib/model/commerce-shipping.js.map +1 -1
  278. package/src/lib/model/commerce-tax-engine.d.ts +90 -0
  279. package/src/lib/model/commerce-tax-engine.js +129 -0
  280. package/src/lib/model/commerce-tax-engine.js.map +1 -0
  281. package/src/lib/model/commerce.d.ts +91 -2
  282. package/src/lib/model/commerce.js +89 -1
  283. package/src/lib/model/commerce.js.map +1 -1
  284. package/src/lib/model/index.d.ts +16 -0
  285. package/src/lib/model/index.js +16 -0
  286. package/src/lib/model/index.js.map +1 -1
  287. package/src/lib/model/order-events.d.ts +154 -0
  288. package/src/lib/model/order-events.js +153 -0
  289. package/src/lib/model/order-events.js.map +1 -0
  290. package/src/lib/model/order-fulfillment.d.ts +117 -0
  291. package/src/lib/model/order-fulfillment.js +217 -0
  292. package/src/lib/model/order-fulfillment.js.map +1 -0
  293. package/src/lib/model/order-history.d.ts +58 -0
  294. package/src/lib/model/order-history.js +22 -0
  295. package/src/lib/model/order-history.js.map +1 -0
  296. package/src/lib/model/order-list-fields.d.ts +9 -1
  297. package/src/lib/model/order-list-fields.js +7 -1
  298. package/src/lib/model/order-list-fields.js.map +1 -1
  299. package/src/lib/model/order-shipping-export.d.ts +91 -0
  300. package/src/lib/model/order-shipping-export.js +192 -0
  301. package/src/lib/model/order-shipping-export.js.map +1 -0
  302. package/src/lib/model/order-status-view.d.ts +103 -0
  303. package/src/lib/model/order-status-view.js +156 -0
  304. package/src/lib/model/order-status-view.js.map +1 -0
  305. package/src/lib/model/order-webhooks.d.ts +142 -0
  306. package/src/lib/model/order-webhooks.js +91 -0
  307. package/src/lib/model/order-webhooks.js.map +1 -0
  308. package/src/lib/model/product-channel.d.ts +56 -0
  309. package/src/lib/model/product-channel.js +86 -0
  310. package/src/lib/model/product-channel.js.map +1 -0
  311. package/src/lib/model/product-modifiers.d.ts +80 -0
  312. package/src/lib/model/product-modifiers.js +140 -0
  313. package/src/lib/model/product-modifiers.js.map +1 -0
  314. package/src/lib/model/product-write.d.ts +186 -0
  315. package/src/lib/model/product-write.js +116 -0
  316. package/src/lib/model/product-write.js.map +1 -0
  317. package/src/lib/model/shippingeasy.d.ts +94 -0
  318. package/src/lib/model/shippingeasy.js +267 -0
  319. package/src/lib/model/shippingeasy.js.map +1 -0
  320. package/src/lib/model/shipstation.d.ts +125 -0
  321. package/src/lib/model/shipstation.js +399 -0
  322. package/src/lib/model/shipstation.js.map +1 -0
  323. package/src/lib/model/smart-collection-reads.d.ts +32 -0
  324. package/src/lib/model/smart-collection-reads.js +63 -0
  325. package/src/lib/model/smart-collection-reads.js.map +1 -0
  326. package/src/lib/model/tracking-url.d.ts +74 -0
  327. package/src/lib/model/tracking-url.js +159 -0
  328. package/src/lib/model/tracking-url.js.map +1 -0
  329. package/src/lib/plugin-config.d.ts +13 -0
  330. package/src/lib/plugin-config.js +77 -5
  331. package/src/lib/plugin-config.js.map +1 -1
  332. package/src/lib/plugin.js +26 -0
  333. package/src/lib/plugin.js.map +1 -1
  334. package/src/lib/pos-ops-config.d.ts +39 -0
  335. package/src/lib/pos-ops-config.js +88 -0
  336. package/src/lib/pos-ops-config.js.map +1 -0
  337. package/src/lib/printing/print-document.d.ts +106 -0
  338. package/src/lib/printing/print-document.js +464 -0
  339. package/src/lib/printing/print-document.js.map +1 -0
  340. package/src/lib/printing/product-labels.d.ts +58 -0
  341. package/src/lib/printing/product-labels.js +116 -0
  342. package/src/lib/printing/product-labels.js.map +1 -0
  343. package/src/lib/printing/render-epson.d.ts +57 -0
  344. package/src/lib/printing/render-epson.js +135 -0
  345. package/src/lib/printing/render-epson.js.map +1 -0
  346. package/src/lib/printing/render-star.d.ts +45 -0
  347. package/src/lib/printing/render-star.js +100 -0
  348. package/src/lib/printing/render-star.js.map +1 -0
  349. package/src/lib/printing/render-text.d.ts +25 -0
  350. package/src/lib/printing/render-text.js +53 -0
  351. package/src/lib/printing/render-text.js.map +1 -0
  352. package/src/lib/server/api-v1/openapi.js +27 -4
  353. package/src/lib/server/api-v1/openapi.js.map +1 -1
  354. package/src/lib/server/api-v1/order-view.d.ts +67 -0
  355. package/src/lib/server/api-v1/order-view.js +120 -0
  356. package/src/lib/server/api-v1/order-view.js.map +1 -0
  357. package/src/lib/server/api-v1/orders-and-products.js +58 -65
  358. package/src/lib/server/api-v1/orders-and-products.js.map +1 -1
  359. package/src/lib/server/billing-webhook.js +135 -28
  360. package/src/lib/server/billing-webhook.js.map +1 -1
  361. package/src/lib/server/cancel-order.js +29 -0
  362. package/src/lib/server/cancel-order.js.map +1 -1
  363. package/src/lib/server/carrier-rates-availability.d.ts +26 -0
  364. package/src/lib/server/carrier-rates-availability.js +76 -0
  365. package/src/lib/server/carrier-rates-availability.js.map +1 -0
  366. package/src/lib/server/carrier-shipping.d.ts +84 -0
  367. package/src/lib/server/carrier-shipping.js +135 -0
  368. package/src/lib/server/carrier-shipping.js.map +1 -0
  369. package/src/lib/server/cart-checkout.d.ts +2 -0
  370. package/src/lib/server/cart-checkout.js +226 -22
  371. package/src/lib/server/cart-checkout.js.map +1 -1
  372. package/src/lib/server/channel-order-updates.d.ts +50 -0
  373. package/src/lib/server/channel-order-updates.js +290 -0
  374. package/src/lib/server/channel-order-updates.js.map +1 -0
  375. package/src/lib/server/channel-orders.d.ts +85 -0
  376. package/src/lib/server/channel-orders.js +543 -0
  377. package/src/lib/server/channel-orders.js.map +1 -0
  378. package/src/lib/server/checkout-extras.d.ts +64 -0
  379. package/src/lib/server/checkout-extras.js +157 -0
  380. package/src/lib/server/checkout-extras.js.map +1 -0
  381. package/src/lib/server/{feed.d.ts → checkout-status.d.ts} +2 -7
  382. package/src/lib/server/checkout-status.js +111 -0
  383. package/src/lib/server/checkout-status.js.map +1 -0
  384. package/src/lib/server/checkout.js +86 -9
  385. package/src/lib/server/checkout.js.map +1 -1
  386. package/src/lib/server/draft-order.js +34 -5
  387. package/src/lib/server/draft-order.js.map +1 -1
  388. package/src/lib/server/fulfill-order.d.ts +127 -10
  389. package/src/lib/server/fulfill-order.js +451 -49
  390. package/src/lib/server/fulfill-order.js.map +1 -1
  391. package/src/lib/server/legacy-feed.d.ts +28 -0
  392. package/src/lib/server/legacy-feed.js +52 -0
  393. package/src/lib/server/legacy-feed.js.map +1 -0
  394. package/src/lib/server/native-checkout.d.ts +34 -15
  395. package/src/lib/server/native-checkout.js +32 -17
  396. package/src/lib/server/native-checkout.js.map +1 -1
  397. package/src/lib/server/order-event-host-emit.d.ts +23 -0
  398. package/src/lib/server/order-event-host-emit.js +30 -0
  399. package/src/lib/server/order-event-host-emit.js.map +1 -0
  400. package/src/lib/server/order-event-triggers.d.ts +37 -0
  401. package/src/lib/server/order-event-triggers.js +119 -0
  402. package/src/lib/server/order-event-triggers.js.map +1 -0
  403. package/src/lib/server/order-events.d.ts +62 -0
  404. package/src/lib/server/order-events.js +109 -0
  405. package/src/lib/server/order-events.js.map +1 -0
  406. package/src/lib/server/order-history.d.ts +23 -0
  407. package/src/lib/server/order-history.js +65 -0
  408. package/src/lib/server/order-history.js.map +1 -0
  409. package/src/lib/server/order-notifications.d.ts +185 -0
  410. package/src/lib/server/order-notifications.js +567 -0
  411. package/src/lib/server/order-notifications.js.map +1 -0
  412. package/src/lib/server/order-receipt-send.d.ts +39 -0
  413. package/src/lib/server/order-receipt-send.js +151 -0
  414. package/src/lib/server/order-receipt-send.js.map +1 -0
  415. package/src/lib/server/order-status-token.d.ts +31 -0
  416. package/src/lib/server/order-status-token.js +75 -0
  417. package/src/lib/server/order-status-token.js.map +1 -0
  418. package/src/lib/server/order-status.d.ts +58 -0
  419. package/src/lib/server/order-status.js +141 -0
  420. package/src/lib/server/order-status.js.map +1 -0
  421. package/src/lib/server/order-webhooks.d.ts +108 -0
  422. package/src/lib/server/order-webhooks.js +622 -0
  423. package/src/lib/server/order-webhooks.js.map +1 -0
  424. package/src/lib/server/orders-shipping-prepare.d.ts +26 -0
  425. package/src/lib/server/orders-shipping-prepare.js +121 -0
  426. package/src/lib/server/orders-shipping-prepare.js.map +1 -0
  427. package/src/lib/server/payment-method-domains.d.ts +209 -0
  428. package/src/lib/server/payment-method-domains.js +444 -0
  429. package/src/lib/server/payment-method-domains.js.map +1 -0
  430. package/src/lib/server/payment-methods.d.ts +77 -0
  431. package/src/lib/server/payment-methods.js +284 -0
  432. package/src/lib/server/payment-methods.js.map +1 -0
  433. package/src/lib/server/pos-auth.d.ts +50 -0
  434. package/src/lib/server/pos-auth.js +121 -0
  435. package/src/lib/server/pos-auth.js.map +1 -0
  436. package/src/lib/server/pos-customer.d.ts +49 -0
  437. package/src/lib/server/pos-customer.js +257 -0
  438. package/src/lib/server/pos-customer.js.map +1 -0
  439. package/src/lib/server/pos-display.d.ts +57 -0
  440. package/src/lib/server/pos-display.js +419 -0
  441. package/src/lib/server/pos-display.js.map +1 -0
  442. package/src/lib/server/pos-fee-month.d.ts +34 -0
  443. package/src/lib/server/pos-fee-month.js +36 -0
  444. package/src/lib/server/pos-fee-month.js.map +1 -0
  445. package/src/lib/server/pos-ops-gate.d.ts +161 -0
  446. package/src/lib/server/pos-ops-gate.js +295 -0
  447. package/src/lib/server/pos-ops-gate.js.map +1 -0
  448. package/src/lib/server/pos-ops-routes.d.ts +22 -0
  449. package/src/lib/server/pos-ops-routes.js +36 -0
  450. package/src/lib/server/pos-ops-routes.js.map +1 -0
  451. package/src/lib/server/pos-order.d.ts +1 -18
  452. package/src/lib/server/pos-order.js +222 -42
  453. package/src/lib/server/pos-order.js.map +1 -1
  454. package/src/lib/server/pos-payment.d.ts +39 -0
  455. package/src/lib/server/pos-payment.js +922 -0
  456. package/src/lib/server/pos-payment.js.map +1 -0
  457. package/src/lib/server/pos-print.d.ts +82 -0
  458. package/src/lib/server/pos-print.js +193 -0
  459. package/src/lib/server/pos-print.js.map +1 -0
  460. package/src/lib/server/pos-readers.d.ts +27 -0
  461. package/src/lib/server/pos-readers.js +276 -0
  462. package/src/lib/server/pos-readers.js.map +1 -0
  463. package/src/lib/server/pos-refund-authority.d.ts +60 -0
  464. package/src/lib/server/pos-refund-authority.js +72 -0
  465. package/src/lib/server/pos-refund-authority.js.map +1 -0
  466. package/src/lib/server/pos-return.d.ts +58 -0
  467. package/src/lib/server/pos-return.js +891 -0
  468. package/src/lib/server/pos-return.js.map +1 -0
  469. package/src/lib/server/pos-sale-stamp.d.ts +66 -0
  470. package/src/lib/server/pos-sale-stamp.js +84 -0
  471. package/src/lib/server/pos-sale-stamp.js.map +1 -0
  472. package/src/lib/server/pos-sale.d.ts +170 -0
  473. package/src/lib/server/pos-sale.js +461 -0
  474. package/src/lib/server/pos-sale.js.map +1 -0
  475. package/src/lib/server/pos-shift.d.ts +45 -0
  476. package/src/lib/server/pos-shift.js +484 -0
  477. package/src/lib/server/pos-shift.js.map +1 -0
  478. package/src/lib/server/pos-staff-pin.d.ts +26 -0
  479. package/src/lib/server/pos-staff-pin.js +339 -0
  480. package/src/lib/server/pos-staff-pin.js.map +1 -0
  481. package/src/lib/server/pos-stripe.d.ts +91 -0
  482. package/src/lib/server/pos-stripe.js +129 -0
  483. package/src/lib/server/pos-stripe.js.map +1 -0
  484. package/src/lib/server/pos-terminal-connection-token.d.ts +48 -0
  485. package/src/lib/server/pos-terminal-connection-token.js +166 -0
  486. package/src/lib/server/pos-terminal-connection-token.js.map +1 -0
  487. package/src/lib/server/pos-terminal.d.ts +218 -0
  488. package/src/lib/server/pos-terminal.js +1014 -0
  489. package/src/lib/server/pos-terminal.js.map +1 -0
  490. package/src/lib/server/print-queue.d.ts +124 -0
  491. package/src/lib/server/print-queue.js +301 -0
  492. package/src/lib/server/print-queue.js.map +1 -0
  493. package/src/lib/server/printer-poll.d.ts +75 -0
  494. package/src/lib/server/printer-poll.js +325 -0
  495. package/src/lib/server/printer-poll.js.map +1 -0
  496. package/src/lib/server/printer-secret.d.ts +39 -0
  497. package/src/lib/server/printer-secret.js +56 -0
  498. package/src/lib/server/printer-secret.js.map +1 -0
  499. package/src/lib/server/printers.d.ts +114 -0
  500. package/src/lib/server/printers.js +546 -0
  501. package/src/lib/server/printers.js.map +1 -0
  502. package/src/lib/server/product-catalog.d.ts +42 -0
  503. package/src/lib/server/product-catalog.js +309 -0
  504. package/src/lib/server/product-catalog.js.map +1 -0
  505. package/src/lib/server/product-drafts.d.ts +5 -1
  506. package/src/lib/server/product-drafts.js +3 -3
  507. package/src/lib/server/product-drafts.js.map +1 -1
  508. package/src/lib/server/product-writer.d.ts +19 -0
  509. package/src/lib/server/product-writer.js +261 -0
  510. package/src/lib/server/product-writer.js.map +1 -0
  511. package/src/lib/server/products-write.d.ts +61 -0
  512. package/src/lib/server/products-write.js +375 -0
  513. package/src/lib/server/products-write.js.map +1 -0
  514. package/src/lib/server/refund.js +110 -45
  515. package/src/lib/server/refund.js.map +1 -1
  516. package/src/lib/server/reserve.js +2 -0
  517. package/src/lib/server/reserve.js.map +1 -1
  518. package/src/lib/server/return-status-action.d.ts +37 -0
  519. package/src/lib/server/return-status-action.js +57 -0
  520. package/src/lib/server/return-status-action.js.map +1 -0
  521. package/src/lib/server/returns.d.ts +119 -0
  522. package/src/lib/server/returns.js +938 -0
  523. package/src/lib/server/returns.js.map +1 -0
  524. package/src/lib/server/shipment-records.d.ts +36 -0
  525. package/src/lib/server/shipment-records.js +289 -0
  526. package/src/lib/server/shipment-records.js.map +1 -0
  527. package/src/lib/server/shipping-connector-gates.d.ts +40 -0
  528. package/src/lib/server/shipping-connector-gates.js +97 -0
  529. package/src/lib/server/shipping-connector-gates.js.map +1 -0
  530. package/src/lib/server/shipping-connectors.d.ts +29 -0
  531. package/src/lib/server/shipping-connectors.js +236 -0
  532. package/src/lib/server/shipping-connectors.js.map +1 -0
  533. package/src/lib/server/shippingeasy.d.ts +238 -0
  534. package/src/lib/server/shippingeasy.js +787 -0
  535. package/src/lib/server/shippingeasy.js.map +1 -0
  536. package/src/lib/server/shipstation.d.ts +129 -0
  537. package/src/lib/server/shipstation.js +483 -0
  538. package/src/lib/server/shipstation.js.map +1 -0
  539. package/src/lib/server/site-page-resolver.d.ts +5 -0
  540. package/src/lib/server/site-page-resolver.js +156 -1
  541. package/src/lib/server/site-page-resolver.js.map +1 -1
  542. package/src/lib/server/stock-levels.d.ts +21 -0
  543. package/src/lib/server/stock-levels.js +263 -0
  544. package/src/lib/server/stock-levels.js.map +1 -0
  545. package/src/lib/server/stripe-refund.d.ts +47 -0
  546. package/src/lib/server/stripe-refund.js +87 -0
  547. package/src/lib/server/stripe-refund.js.map +1 -0
  548. package/src/lib/server/supplier-update.js +46 -5
  549. package/src/lib/server/supplier-update.js.map +1 -1
  550. package/src/lib/server/tax-engine-quote.d.ts +47 -0
  551. package/src/lib/server/tax-engine-quote.js +105 -0
  552. package/src/lib/server/tax-engine-quote.js.map +1 -0
  553. package/src/lib/server.js +143 -2
  554. package/src/lib/server.js.map +1 -1
  555. package/src/lib/site.js +12 -0
  556. package/src/lib/site.js.map +1 -1
  557. package/src/lib/subprocessors.d.ts +26 -0
  558. package/src/lib/subprocessors.js +50 -0
  559. package/src/lib/subprocessors.js.map +1 -0
  560. package/src/lib/tenant-emails.js +461 -3
  561. package/src/lib/tenant-emails.js.map +1 -1
  562. package/src/lib/testing/fake-firestore.d.ts +45 -0
  563. package/src/lib/testing/fake-firestore.js +189 -0
  564. package/src/lib/testing/fake-firestore.js.map +1 -0
  565. package/src/lib/testing/memory-firestore.d.ts +136 -0
  566. package/src/lib/testing/memory-firestore.js +282 -0
  567. package/src/lib/testing/memory-firestore.js.map +1 -0
  568. package/src/lib/testing/pos-ops-harness.d.ts +50 -0
  569. package/src/lib/testing/pos-ops-harness.js +184 -0
  570. package/src/lib/testing/pos-ops-harness.js.map +1 -0
  571. package/src/lib/testing/pos-ops-memory-firestore.d.ts +55 -0
  572. package/src/lib/testing/pos-ops-memory-firestore.js +376 -0
  573. package/src/lib/testing/pos-ops-memory-firestore.js.map +1 -0
  574. package/src/lib/transfer/products.server.d.ts +5 -0
  575. package/src/lib/transfer/products.server.js +2 -2
  576. package/src/lib/transfer/products.server.js.map +1 -1
  577. package/src/lib/transfer/records-transfer.d.ts +11 -1
  578. package/src/lib/transfer/records-transfer.js +127 -5
  579. package/src/lib/transfer/records-transfer.js.map +1 -1
  580. package/src/lib/transfer/records.server.d.ts +9 -2
  581. package/src/lib/transfer/records.server.js +58 -7
  582. package/src/lib/transfer/records.server.js.map +1 -1
  583. package/src/lib/transfer/register-transfer-resources.js +40 -1
  584. package/src/lib/transfer/register-transfer-resources.js.map +1 -1
  585. package/src/lib/transfer/register-transfer-ui.js +4 -1
  586. package/src/lib/transfer/register-transfer-ui.js.map +1 -1
  587. package/src/lib/transfer/shipping-presets.d.ts +23 -0
  588. package/src/lib/transfer/shipping-presets.js +156 -0
  589. package/src/lib/transfer/shipping-presets.js.map +1 -0
  590. package/src/lib/transfer/tracking-transfer.d.ts +101 -0
  591. package/src/lib/transfer/tracking-transfer.js +546 -0
  592. package/src/lib/transfer/tracking-transfer.js.map +1 -0
  593. package/src/lib/transfer/tracking.server.d.ts +37 -0
  594. package/src/lib/transfer/tracking.server.js +393 -0
  595. package/src/lib/transfer/tracking.server.js.map +1 -0
  596. package/src/lib/transfer/transfer-keys.d.ts +2 -1
  597. package/src/lib/transfer/transfer-keys.js +6 -2
  598. package/src/lib/transfer/transfer-keys.js.map +1 -1
  599. package/src/lib/utils/code128.d.ts +37 -0
  600. package/src/lib/utils/code128.js +199 -0
  601. package/src/lib/utils/code128.js.map +1 -0
  602. package/src/lib/utils/order-invoice.d.ts +55 -0
  603. package/src/lib/utils/order-invoice.js +127 -0
  604. package/src/lib/utils/order-invoice.js.map +1 -0
  605. package/src/lib/utils/use-checkout-return-notice.d.ts +34 -0
  606. package/src/lib/utils/use-checkout-return-notice.js +78 -0
  607. package/src/lib/utils/use-checkout-return-notice.js.map +1 -0
  608. package/src/lib/server/feed.js +0 -69
  609. package/src/lib/server/feed.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/printing/print-document.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n formatReceiptMoney,\n formatReceiptTime,\n type ReceiptData,\n} from '../model/commerce-receipt'\nimport type { PrintReport } from '../model/commerce-printers'\n\n/**\n * A printer-neutral document (AGL-3619): what a receipt, a test page or a\n * drawer kick IS, laid out in fixed columns, before any vendor's bytes. Each\n * renderer (`render-star.ts`, `render-epson.ts`, `render-text.ts`) translates\n * these operations one for one, so the layout is decided once and a Star and\n * an Epson print the same receipt.\n *\n * Text operations are one printed LINE each and already fit the paper: the\n * layout wraps and pads here, because a thermal printer's own wrapping breaks\n * mid-word and cannot right-align a price.\n */\nexport type PrintAlign = 'left' | 'center' | 'right'\n\nexport type PrintOp =\n | { op: 'text'; text: string; align?: PrintAlign; bold?: boolean; size?: 1 | 2 }\n | { op: 'feed'; lines: number }\n | { op: 'barcode'; data: string }\n | { op: 'logo' }\n | { op: 'drawer' }\n | { op: 'cut' }\n\nexport interface PrintDocument {\n /** Characters per line at size 1. */\n columns: number\n ops: PrintOp[]\n}\n\nconst SYMBOLS: Record<string, string> = {\n '•': '*', // bullet\n '·': '*',\n '–': '-',\n '—': '-',\n '‘': \"'\",\n '’': \"'\",\n '“': '\"',\n '”': '\"',\n '…': '...',\n ' ': ' ',\n ' ': ' ',\n '€': 'EUR',\n '£': 'GBP',\n '¥': 'JPY',\n '₹': 'INR',\n}\n\n/**\n * Text as the printer's built-in ASCII font can print it. Accents are folded\n * (`Crème brûlée` → `Creme brulee`), the punctuation a product name or a money\n * format carries is spelled in ASCII, and anything left becomes `?` rather\n * than the mojibake a raw UTF-8 byte prints as on a code-page printer.\n */\nexport function toPrintable(value: unknown): string {\n return String(value ?? '')\n .normalize('NFKD')\n .replace(/[̀-ͯ]/g, '')\n .replace(/[^\\x20-\\x7e]/g, (char) => SYMBOLS[char] ?? (/\\s/.test(char) ? ' ' : '?'))\n}\n\n/** Words wrapped to `width`, breaking a word only when it alone is too long. */\nexport function wrapText(text: string, width: number): string[] {\n const lines: string[] = []\n let current = ''\n for (const word of toPrintable(text).split(/\\s+/).filter(Boolean)) {\n let rest = word\n while (rest.length > width) {\n if (current) {\n lines.push(current)\n current = ''\n }\n lines.push(rest.slice(0, width))\n rest = rest.slice(width)\n }\n if (!rest) continue\n if (!current) current = rest\n else if (current.length + 1 + rest.length <= width) current += ` ${rest}`\n else {\n lines.push(current)\n current = rest\n }\n }\n if (current) lines.push(current)\n return lines.length ? lines : ['']\n}\n\n/**\n * A left label and a right amount on one line; a label too long to share the\n * line wraps above, so the amount always lands flush right.\n */\nexport function twoColumnLines(left: string, right: string, width: number): string[] {\n const amount = toPrintable(right)\n const room = Math.max(1, width - amount.length - 1)\n const wrapped = wrapText(left, room)\n const last = wrapped.pop() ?? ''\n return [...wrapped, `${last}${' '.repeat(Math.max(1, width - last.length - amount.length))}${amount}`]\n}\n\nconst rule = (columns: number): PrintOp => ({ op: 'text', text: '-'.repeat(columns) })\n\nexport interface LayoutOptions {\n columns: number\n /** Print the logo stored in the printer. */\n logo?: boolean\n /** Kick the cash drawer as the receipt starts printing. */\n openDrawer?: boolean\n}\n\n/** The customer receipt. */\nexport function layoutReceipt(receipt: ReceiptData, options: LayoutOptions): PrintDocument {\n const { columns } = options\n const money = (cents: number) => formatReceiptMoney(cents, receipt.currency)\n const ops: PrintOp[] = []\n const line = (left: string, right: string, bold = false) => {\n for (const text of twoColumnLines(left, right, columns)) ops.push({ op: 'text', text, bold })\n }\n // The drawer first: the cashier makes change while the receipt prints.\n if (options.openDrawer) ops.push({ op: 'drawer' })\n if (options.logo) ops.push({ op: 'logo' })\n if (receipt.banner) {\n ops.push({ op: 'text', text: toPrintable(receipt.banner).slice(0, Math.floor(columns / 2)), align: 'center', bold: true, size: 2 })\n }\n for (const text of wrapText(receipt.storeName, Math.floor(columns / 2))) {\n ops.push({ op: 'text', text, align: 'center', bold: true, size: 2 })\n }\n for (const storeLine of receipt.storeLines ?? []) {\n for (const text of wrapText(storeLine, columns)) ops.push({ op: 'text', text, align: 'center' })\n }\n ops.push({ op: 'feed', lines: 1 })\n line(`Order #${receipt.orderNumber}`, formatReceiptTime(receipt.createdAtMs, receipt.timeZone))\n const who = [receipt.registerName, receipt.cashierName].filter(Boolean).join(' - ')\n if (who) for (const text of wrapText(who, columns)) ops.push({ op: 'text', text })\n ops.push(rule(columns))\n for (const item of receipt.lines) {\n const label = item.quantity > 1 ? `${item.quantity} x ${item.name}` : item.name\n line(label, money(item.totalCents))\n if (item.detail) {\n for (const text of wrapText(item.detail, columns - 2)) ops.push({ op: 'text', text: ` ${text}` })\n }\n if (item.quantity > 1) {\n ops.push({ op: 'text', text: toPrintable(` @ ${money(item.unitCents)} each`).slice(0, columns) })\n }\n }\n ops.push(rule(columns))\n line('Subtotal', money(receipt.subtotalCents))\n if (receipt.discountCents) line('Discount', `-${money(receipt.discountCents)}`)\n if (receipt.shippingCents) line('Shipping', money(receipt.shippingCents))\n if (receipt.taxCents) line('Tax', money(receipt.taxCents))\n if (receipt.tipCents) line('Tip', money(receipt.tipCents))\n for (const text of twoColumnLines('TOTAL', money(receipt.totalCents), Math.floor(columns / 2))) {\n ops.push({ op: 'text', text, bold: true, size: 2 })\n }\n if (receipt.tenders?.length || receipt.changeCents) ops.push({ op: 'feed', lines: 1 })\n for (const tender of receipt.tenders ?? []) line(tender.label, money(tender.amountCents))\n if (receipt.changeCents) line('Change', money(receipt.changeCents), true)\n if (receipt.refundedCents) line('Refunded', `-${money(receipt.refundedCents)}`)\n const barcode = code128Printable(receipt.barcode ?? receipt.orderNumber)\n if (barcode) {\n ops.push({ op: 'feed', lines: 1 })\n ops.push({ op: 'barcode', data: barcode })\n }\n if (receipt.footer) {\n ops.push({ op: 'feed', lines: 1 })\n for (const text of wrapText(receipt.footer, columns)) ops.push({ op: 'text', text, align: 'center' })\n }\n ops.push({ op: 'feed', lines: 2 })\n ops.push({ op: 'cut' })\n return { columns, ops }\n}\n\n/**\n * The ticket the kitchen, the bar or the packing bench works from: the order\n * number large enough to call out, when it was rung and on which register,\n * then each item with its quantity and options. No prices, no tenders and no\n * barcode: the people reading it are making the order, not paying for it.\n */\nexport function layoutKitchenTicket(receipt: ReceiptData, options: { columns: number }): PrintDocument {\n const { columns } = options\n const half = Math.floor(columns / 2)\n const ops: PrintOp[] = []\n if (receipt.banner) {\n ops.push({ op: 'text', text: toPrintable(receipt.banner).slice(0, half), align: 'center', bold: true, size: 2 })\n }\n ops.push({ op: 'text', text: toPrintable(`#${receipt.orderNumber}`).slice(0, half), align: 'center', bold: true, size: 2 })\n for (const text of twoColumnLines(\n receipt.registerName ?? '',\n formatReceiptTime(receipt.createdAtMs, receipt.timeZone),\n columns,\n )) {\n ops.push({ op: 'text', text })\n }\n ops.push(rule(columns))\n for (const item of receipt.lines) {\n // Quantity first and large: \"2 x Latte\" read across a kitchen.\n for (const text of wrapText(`${item.quantity} x ${item.name}`, half)) {\n ops.push({ op: 'text', text, bold: true, size: 2 })\n }\n if (item.detail) {\n for (const text of wrapText(item.detail, columns - 2)) ops.push({ op: 'text', text: ` ${text}` })\n }\n }\n ops.push(rule(columns))\n const count = receipt.lines.reduce((sum, item) => sum + item.quantity, 0)\n ops.push({ op: 'text', text: `${count} ${count === 1 ? 'item' : 'items'}`, align: 'right' })\n ops.push({ op: 'feed', lines: 2 })\n ops.push({ op: 'cut' })\n return { columns, ops }\n}\n\n/**\n * Code128 code set B carries printable ASCII, and a scanner reads a short\n * symbol more reliably than a long one, so the data is the order number\n * reduced to those characters and capped well under a receipt's width.\n */\nexport function code128Printable(value: unknown): string {\n return toPrintable(value).replace(/[^\\x21-\\x7e]/g, '').slice(0, 20)\n}\n\n/** The page \"Print test\" sends: proves the URL, the paper, the cutter and, if asked, the drawer. */\nexport function layoutTestPage(input: {\n columns: number\n printerName: string\n storeName: string\n atMs: number\n timeZone?: string\n logo?: boolean\n openDrawer?: boolean\n}): PrintDocument {\n const { columns } = input\n const ops: PrintOp[] = []\n if (input.openDrawer) ops.push({ op: 'drawer' })\n if (input.logo) ops.push({ op: 'logo' })\n ops.push({ op: 'text', text: 'TEST PRINT', align: 'center', bold: true, size: 2 })\n for (const text of wrapText(input.storeName, columns)) ops.push({ op: 'text', text, align: 'center' })\n ops.push({ op: 'feed', lines: 1 })\n for (const text of twoColumnLines('Printer', input.printerName, columns)) ops.push({ op: 'text', text })\n for (const text of twoColumnLines('Sent', formatReceiptTime(input.atMs, input.timeZone), columns)) {\n ops.push({ op: 'text', text })\n }\n ops.push({ op: 'text', text: '-'.repeat(columns) })\n ops.push({ op: 'text', text: 'Left aligned' })\n ops.push({ op: 'text', text: 'Centered', align: 'center' })\n ops.push({ op: 'text', text: 'Right aligned', align: 'right' })\n ops.push({ op: 'text', text: 'Bold text', bold: true })\n ops.push({ op: 'text', text: 'Large', size: 2 })\n ops.push({ op: 'text', text: '0123456789'.repeat(Math.ceil(columns / 10)).slice(0, columns) })\n ops.push({ op: 'feed', lines: 1 })\n ops.push({ op: 'barcode', data: 'TEST-PRINT' })\n ops.push({ op: 'feed', lines: 1 })\n for (const text of wrapText('If you can read this, receipts will print here.', columns)) {\n ops.push({ op: 'text', text, align: 'center' })\n }\n ops.push({ op: 'feed', lines: 2 })\n ops.push({ op: 'cut' })\n return { columns, ops }\n}\n\n/** A titled report on the receipt roll: a shift's X or Z report (AGL-3609). */\nexport function layoutReport(report: PrintReport, options: Pick<LayoutOptions, 'columns' | 'logo'>): PrintDocument {\n const { columns } = options\n const ops: PrintOp[] = []\n if (options.logo) ops.push({ op: 'logo' })\n for (const text of wrapText(report.storeName, Math.floor(columns / 2))) {\n ops.push({ op: 'text', text, align: 'center', bold: true, size: 2 })\n }\n for (const text of wrapText(report.title, Math.floor(columns / 2))) {\n ops.push({ op: 'text', text, align: 'center', bold: true, size: 2 })\n }\n if (report.subtitle) {\n for (const text of wrapText(report.subtitle, columns)) ops.push({ op: 'text', text, align: 'center' })\n }\n for (const section of report.sections) {\n ops.push(rule(columns))\n ops.push({ op: 'text', text: toPrintable(section.section.toUpperCase()).slice(0, columns), bold: true })\n for (const row of section.rows) {\n for (const text of twoColumnLines(row.label, row.value, columns)) {\n ops.push({ op: 'text', text, bold: row.strong === true })\n }\n }\n }\n ops.push({ op: 'feed', lines: 2 })\n ops.push({ op: 'cut' })\n return { columns, ops }\n}\n\n/** A drawer kick with nothing printed: a paid-out, a cash refund, \"Open drawer\". */\nexport function layoutDrawerKick(columns: number): PrintDocument {\n return { columns, ops: [{ op: 'drawer' }] }\n}\n"],"names":["formatReceiptMoney","formatReceiptTime","SYMBOLS","toPrintable","value","String","normalize","replace","char","test","wrapText","text","width","lines","current","word","split","filter","Boolean","rest","length","push","slice","twoColumnLines","left","right","wrapped","amount","room","Math","max","last","pop","repeat","rule","columns","op","layoutReceipt","receipt","options","money","cents","currency","ops","line","bold","openDrawer","logo","banner","floor","align","size","storeName","storeLine","storeLines","orderNumber","createdAtMs","timeZone","who","registerName","cashierName","join","item","label","quantity","name","totalCents","detail","unitCents","subtotalCents","discountCents","shippingCents","taxCents","tipCents","tenders","changeCents","tender","amountCents","refundedCents","barcode","code128Printable","data","footer","layoutKitchenTicket","half","count","reduce","sum","layoutTestPage","input","printerName","atMs","ceil","layoutReport","report","title","subtitle","section","sections","toUpperCase","row","rows","strong","layoutDrawerKick"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,kBAAkB,EAClBC,iBAAiB,QAEZ,+BAA2B;AA8BlC,MAAMC,UAAkC;IACtC,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;AACP;AAEA;;;;;CAKC,GACD,OAAO,SAASC,YAAYC,KAAc;IACxC,OAAOC,OAAOD,gBAAAA,QAAS,IACpBE,SAAS,CAAC,QACVC,OAAO,CAAC,UAAU,IAClBA,OAAO,CAAC,iBAAiB,CAACC;YAASN;gBAAAA,gBAAAA,OAAO,CAACM,KAAK,YAAbN,gBAAkB,KAAKO,IAAI,CAACD,QAAQ,MAAM;;AAClF;AAEA,8EAA8E,GAC9E,OAAO,SAASE,SAASC,IAAY,EAAEC,KAAa;IAClD,MAAMC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gBAChEQ,IAAItB,IAAI,CAAC;oBAAEe,IAAI;oBAAQzB;oBAAMkC,MAAMuD,IAAIE,MAAM,KAAK;gBAAK;YACzD;QACF;IACF;IACA3D,IAAItB,IAAI,CAAC;QAAEe,IAAI;QAAQvB,OAAO;IAAE;IAChC8B,IAAItB,IAAI,CAAC;QAAEe,IAAI;IAAM;IACrB,OAAO;QAAED;QAASQ;IAAI;AACxB;AAEA,kFAAkF,GAClF,OAAO,SAAS4D,iBAAiBpE,OAAe;IAC9C,OAAO;QAAEA;QAASQ,KAAK;YAAC;gBAAEP,IAAI;YAAS;SAAE;IAAC;AAC5C"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Product and shelf labels (AGL-3619): a product's name, its options, its
19
+ * price and a barcode the register scans back, on the small thermal labels
20
+ * a Zebra, Rollo, DYMO or Brother label printer takes.
21
+ *
22
+ * Two outputs from one description. A printable page (one label per page,
23
+ * the page sized to the label) prints through the label printer's own
24
+ * driver from any browser. ZPL is the Zebra printer language, sent to a
25
+ * Zebra as a file; it prints sharper and faster and needs no driver
26
+ * settings, so a store with a Zebra can skip the print dialog altogether.
27
+ */
28
+ export interface ProductLabel {
29
+ name: string;
30
+ /** A variant's options, e.g. `Large / Blue`. */
31
+ detail?: string;
32
+ priceCents?: number;
33
+ currency?: string;
34
+ /** The variant's barcode, else its SKU: what the register looks up. */
35
+ code: string;
36
+ copies: number;
37
+ }
38
+ export interface LabelSize {
39
+ id: string;
40
+ label: string;
41
+ widthIn: number;
42
+ heightIn: number;
43
+ }
44
+ /** The two sizes almost every label printer stocks for product labels. */
45
+ export declare const LABEL_SIZES: readonly LabelSize[];
46
+ /** One print run is capped; a typo of 5000 copies should not drain a roll. */
47
+ export declare const MAX_LABEL_COPIES = 500;
48
+ export declare function labelSize(id: string | undefined): LabelSize;
49
+ export declare function productLabelsHtml(labels: ProductLabel[], sizeId?: string): string;
50
+ /** Zebra's desktop printers print at 203 dpi; the 300 dpi models are listed by name. */
51
+ export type ZplDpi = 203 | 300;
52
+ /**
53
+ * Field text for ZPL. `^FH` makes `_` the escape, so the three characters
54
+ * ZPL treats as commands or that escape (`^`, `~`, `_`) are written as hex,
55
+ * and the rest is folded to the printer's ASCII font.
56
+ */
57
+ export declare function zplText(value: unknown): string;
58
+ export declare function productLabelsZpl(labels: ProductLabel[], sizeId?: string, dpi?: ZplDpi): string;
@@ -0,0 +1,116 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ import { escapeHtml } from "../utils/escape-html.js";
17
+ import { barcodeSvg, encodeBarcode } from "../barcode/barcode-encode.js";
18
+ import { formatReceiptMoney } from "../model/commerce-receipt.js";
19
+ import { toPrintable } from "./print-document.js";
20
+ /** The two sizes almost every label printer stocks for product labels. */ export const LABEL_SIZES = [
21
+ {
22
+ id: '2.25x1.25',
23
+ label: '2.25 x 1.25 in (57 x 32 mm)',
24
+ widthIn: 2.25,
25
+ heightIn: 1.25
26
+ },
27
+ {
28
+ id: '2x1',
29
+ label: '2 x 1 in (51 x 25 mm)',
30
+ widthIn: 2,
31
+ heightIn: 1
32
+ }
33
+ ];
34
+ /** One print run is capped; a typo of 5000 copies should not drain a roll. */ export const MAX_LABEL_COPIES = 500;
35
+ export function labelSize(id) {
36
+ var _LABEL_SIZES_find;
37
+ return (_LABEL_SIZES_find = LABEL_SIZES.find((size)=>size.id === id)) != null ? _LABEL_SIZES_find : LABEL_SIZES[0];
38
+ }
39
+ const copiesOf = (label)=>Math.max(0, Math.min(MAX_LABEL_COPIES, Math.floor(Number(label.copies) || 0)));
40
+ const priceText = (label)=>{
41
+ var _label_currency;
42
+ return label.priceCents != null && Number.isFinite(label.priceCents) ? formatReceiptMoney(Math.round(label.priceCents), (_label_currency = label.currency) != null ? _label_currency : 'usd') : '';
43
+ };
44
+ /*==========================================
45
+ * The printable page
46
+ *=========================================*/ export function productLabelsHtml(labels, sizeId) {
47
+ const size = labelSize(sizeId);
48
+ const pages = [];
49
+ for (const label of labels){
50
+ const encoded = encodeBarcode(label.code);
51
+ const page = '<section class="label">' + `<div class="name">${escapeHtml(label.name)}</div>` + (label.detail ? `<div class="detail">${escapeHtml(label.detail)}</div>` : '') + (priceText(label) ? `<div class="price">${escapeHtml(priceText(label))}</div>` : '') + (encoded ? `<div class="bars">${barcodeSvg(encoded)}</div><div class="code">${escapeHtml(encoded.text)}</div>` : '') + '</section>';
52
+ for(let copy = 0; copy < copiesOf(label); copy += 1)pages.push(page);
53
+ }
54
+ const width = `${size.widthIn}in`;
55
+ const height = `${size.heightIn}in`;
56
+ return '<!doctype html><html><head><meta charset="utf-8"><title>Labels</title><style>' + `@page{size:${width} ${height};margin:0}` + '*{box-sizing:border-box}html,body{margin:0;padding:0;font-family:Arial,Helvetica,sans-serif}' + `.label{width:${width};height:${height};padding:0.06in 0.08in;overflow:hidden;display:flex;flex-direction:column;page-break-after:always;break-after:page}` + '.label:last-child{page-break-after:auto;break-after:auto}' + '.name{font-size:9pt;font-weight:700;line-height:1.1;max-height:2.2em;overflow:hidden}' + '.detail{font-size:7pt;line-height:1.1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}' + '.price{font-size:11pt;font-weight:700;line-height:1.2}' + '.bars{flex:1;min-height:0.3in}.bars svg{width:100%;height:100%;display:block}' + '.code{font-size:7pt;text-align:center;letter-spacing:0.05em}' + '</style></head><body>' + pages.join('') + '</body></html>';
57
+ }
58
+ /**
59
+ * Field text for ZPL. `^FH` makes `_` the escape, so the three characters
60
+ * ZPL treats as commands or that escape (`^`, `~`, `_`) are written as hex,
61
+ * and the rest is folded to the printer's ASCII font.
62
+ */ export function zplText(value) {
63
+ return toPrintable(value).replace(/[_^~]/g, (char)=>`_${char.charCodeAt(0).toString(16).toUpperCase()}`);
64
+ }
65
+ function zplBarcode(encoded, x, y, height, moduleDots) {
66
+ const at = `^FO${x},${y}^BY${moduleDots}`;
67
+ switch(encoded.format){
68
+ case 'ean_13':
69
+ // ZPL takes the 12 data digits and adds the check digit itself.
70
+ return `${at}^BEN,${height},Y,N^FD${encoded.text.slice(0, 12)}^FS`;
71
+ case 'upc_a':
72
+ return `${at}^BUN,${height},Y,N,Y^FD${encoded.text.slice(0, 11)}^FS`;
73
+ case 'ean_8':
74
+ return `${at}^B8N,${height},Y,N^FD${encoded.text.slice(0, 7)}^FS`;
75
+ default:
76
+ // Mode A: the printer picks sets B and C itself, as the page does.
77
+ return `${at}^BCN,${height},Y,N,N,A^FH^FD${zplText(encoded.text)}^FS`;
78
+ }
79
+ }
80
+ export function productLabelsZpl(labels, sizeId, dpi = 203) {
81
+ const size = labelSize(sizeId);
82
+ const width = Math.round(size.widthIn * dpi);
83
+ const height = Math.round(size.heightIn * dpi);
84
+ const margin = Math.round(0.08 * dpi);
85
+ const font = Math.round(dpi / 9);
86
+ const small = Math.round(dpi / 12);
87
+ const moduleDots = dpi >= 300 ? 3 : 2;
88
+ const out = [];
89
+ for (const label of labels){
90
+ const copies = copiesOf(label);
91
+ if (!copies) continue;
92
+ const encoded = encodeBarcode(label.code);
93
+ let y = margin;
94
+ const fields = [];
95
+ fields.push(`^FO${margin},${y}^A0N,${font},${font}^FB${width - margin * 2},2,0,L^FH^FD${zplText(label.name)}^FS`);
96
+ y += font * 2 + 2;
97
+ if (label.detail) {
98
+ fields.push(`^FO${margin},${y}^A0N,${small},${small}^FB${width - margin * 2},1,0,L^FH^FD${zplText(label.detail)}^FS`);
99
+ y += small + 2;
100
+ }
101
+ const price = priceText(label);
102
+ if (price) {
103
+ fields.push(`^FO${margin},${y}^A0N,${font},${font}^FH^FD${zplText(price)}^FS`);
104
+ y += font + 4;
105
+ }
106
+ if (encoded) {
107
+ // What is left of the label, less the printed digits under the bars.
108
+ const barHeight = Math.max(Math.round(dpi * 0.2), height - y - margin - small - 4);
109
+ fields.push(zplBarcode(encoded, margin, y, barHeight, moduleDots));
110
+ }
111
+ out.push(`^XA^CI0^PW${width}^LL${height}^LH0,0${fields.join('')}^PQ${copies},0,1,Y^XZ`);
112
+ }
113
+ return out.join('\n');
114
+ }
115
+
116
+ //# sourceMappingURL=product-labels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/printing/product-labels.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { escapeHtml } from '../utils/escape-html'\nimport { barcodeSvg, encodeBarcode, type EncodedBarcode } from '../barcode/barcode-encode'\nimport { formatReceiptMoney } from '../model/commerce-receipt'\nimport { toPrintable } from './print-document'\n\n/**\n * Product and shelf labels (AGL-3619): a product's name, its options, its\n * price and a barcode the register scans back, on the small thermal labels\n * a Zebra, Rollo, DYMO or Brother label printer takes.\n *\n * Two outputs from one description. A printable page (one label per page,\n * the page sized to the label) prints through the label printer's own\n * driver from any browser. ZPL is the Zebra printer language, sent to a\n * Zebra as a file; it prints sharper and faster and needs no driver\n * settings, so a store with a Zebra can skip the print dialog altogether.\n */\n\nexport interface ProductLabel {\n name: string\n /** A variant's options, e.g. `Large / Blue`. */\n detail?: string\n priceCents?: number\n currency?: string\n /** The variant's barcode, else its SKU: what the register looks up. */\n code: string\n copies: number\n}\n\nexport interface LabelSize {\n id: string\n label: string\n widthIn: number\n heightIn: number\n}\n\n/** The two sizes almost every label printer stocks for product labels. */\nexport const LABEL_SIZES: readonly LabelSize[] = [\n { id: '2.25x1.25', label: '2.25 x 1.25 in (57 x 32 mm)', widthIn: 2.25, heightIn: 1.25 },\n { id: '2x1', label: '2 x 1 in (51 x 25 mm)', widthIn: 2, heightIn: 1 },\n]\n\n/** One print run is capped; a typo of 5000 copies should not drain a roll. */\nexport const MAX_LABEL_COPIES = 500\n\nexport function labelSize(id: string | undefined): LabelSize {\n return LABEL_SIZES.find((size) => size.id === id) ?? LABEL_SIZES[0]\n}\n\nconst copiesOf = (label: ProductLabel) => Math.max(0, Math.min(MAX_LABEL_COPIES, Math.floor(Number(label.copies) || 0)))\n\nconst priceText = (label: ProductLabel) =>\n label.priceCents != null && Number.isFinite(label.priceCents)\n ? formatReceiptMoney(Math.round(label.priceCents), label.currency ?? 'usd')\n : ''\n\n/*==========================================\n * The printable page\n *=========================================*/\n\nexport function productLabelsHtml(labels: ProductLabel[], sizeId?: string): string {\n const size = labelSize(sizeId)\n const pages: string[] = []\n for (const label of labels) {\n const encoded = encodeBarcode(label.code)\n const page =\n '<section class=\"label\">' +\n `<div class=\"name\">${escapeHtml(label.name)}</div>` +\n (label.detail ? `<div class=\"detail\">${escapeHtml(label.detail)}</div>` : '') +\n (priceText(label) ? `<div class=\"price\">${escapeHtml(priceText(label))}</div>` : '') +\n (encoded\n ? `<div class=\"bars\">${barcodeSvg(encoded)}</div><div class=\"code\">${escapeHtml(encoded.text)}</div>`\n : '') +\n '</section>'\n for (let copy = 0; copy < copiesOf(label); copy += 1) pages.push(page)\n }\n const width = `${size.widthIn}in`\n const height = `${size.heightIn}in`\n return (\n '<!doctype html><html><head><meta charset=\"utf-8\"><title>Labels</title><style>' +\n `@page{size:${width} ${height};margin:0}` +\n '*{box-sizing:border-box}html,body{margin:0;padding:0;font-family:Arial,Helvetica,sans-serif}' +\n `.label{width:${width};height:${height};padding:0.06in 0.08in;overflow:hidden;display:flex;flex-direction:column;page-break-after:always;break-after:page}` +\n '.label:last-child{page-break-after:auto;break-after:auto}' +\n '.name{font-size:9pt;font-weight:700;line-height:1.1;max-height:2.2em;overflow:hidden}' +\n '.detail{font-size:7pt;line-height:1.1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}' +\n '.price{font-size:11pt;font-weight:700;line-height:1.2}' +\n '.bars{flex:1;min-height:0.3in}.bars svg{width:100%;height:100%;display:block}' +\n '.code{font-size:7pt;text-align:center;letter-spacing:0.05em}' +\n '</style></head><body>' +\n pages.join('') +\n '</body></html>'\n )\n}\n\n/*==========================================\n * ZPL\n *=========================================*/\n\n/** Zebra's desktop printers print at 203 dpi; the 300 dpi models are listed by name. */\nexport type ZplDpi = 203 | 300\n\n/**\n * Field text for ZPL. `^FH` makes `_` the escape, so the three characters\n * ZPL treats as commands or that escape (`^`, `~`, `_`) are written as hex,\n * and the rest is folded to the printer's ASCII font.\n */\nexport function zplText(value: unknown): string {\n return toPrintable(value).replace(/[_^~]/g, (char) => `_${char.charCodeAt(0).toString(16).toUpperCase()}`)\n}\n\nfunction zplBarcode(encoded: EncodedBarcode, x: number, y: number, height: number, moduleDots: number): string {\n const at = `^FO${x},${y}^BY${moduleDots}`\n switch (encoded.format) {\n case 'ean_13':\n // ZPL takes the 12 data digits and adds the check digit itself.\n return `${at}^BEN,${height},Y,N^FD${encoded.text.slice(0, 12)}^FS`\n case 'upc_a':\n return `${at}^BUN,${height},Y,N,Y^FD${encoded.text.slice(0, 11)}^FS`\n case 'ean_8':\n return `${at}^B8N,${height},Y,N^FD${encoded.text.slice(0, 7)}^FS`\n default:\n // Mode A: the printer picks sets B and C itself, as the page does.\n return `${at}^BCN,${height},Y,N,N,A^FH^FD${zplText(encoded.text)}^FS`\n }\n}\n\nexport function productLabelsZpl(labels: ProductLabel[], sizeId?: string, dpi: ZplDpi = 203): string {\n const size = labelSize(sizeId)\n const width = Math.round(size.widthIn * dpi)\n const height = Math.round(size.heightIn * dpi)\n const margin = Math.round(0.08 * dpi)\n const font = Math.round(dpi / 9)\n const small = Math.round(dpi / 12)\n const moduleDots = dpi >= 300 ? 3 : 2\n const out: string[] = []\n for (const label of labels) {\n const copies = copiesOf(label)\n if (!copies) continue\n const encoded = encodeBarcode(label.code)\n let y = margin\n const fields: string[] = []\n fields.push(`^FO${margin},${y}^A0N,${font},${font}^FB${width - margin * 2},2,0,L^FH^FD${zplText(label.name)}^FS`)\n y += font * 2 + 2\n if (label.detail) {\n fields.push(`^FO${margin},${y}^A0N,${small},${small}^FB${width - margin * 2},1,0,L^FH^FD${zplText(label.detail)}^FS`)\n y += small + 2\n }\n const price = priceText(label)\n if (price) {\n fields.push(`^FO${margin},${y}^A0N,${font},${font}^FH^FD${zplText(price)}^FS`)\n y += font + 4\n }\n if (encoded) {\n // What is left of the label, less the printed digits under the bars.\n const barHeight = Math.max(Math.round(dpi * 0.2), height - y - margin - small - 4)\n fields.push(zplBarcode(encoded, margin, y, barHeight, moduleDots))\n }\n out.push(`^XA^CI0^PW${width}^LL${height}^LH0,0${fields.join('')}^PQ${copies},0,1,Y^XZ`)\n }\n return out.join('\\n')\n}\n"],"names":["escapeHtml","barcodeSvg","encodeBarcode","formatReceiptMoney","toPrintable","LABEL_SIZES","id","label","widthIn","heightIn","MAX_LABEL_COPIES","labelSize","find","size","copiesOf","Math","max","min","floor","Number","copies","priceText","priceCents","isFinite","round","currency","productLabelsHtml","labels","sizeId","pages","encoded","code","page","name","detail","text","copy","push","width","height","join","zplText","value","replace","char","charCodeAt","toString","toUpperCase","zplBarcode","x","y","moduleDots","at","format","slice","productLabelsZpl","dpi","margin","font","small","out","fields","price","barHeight"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,UAAU,QAAQ,0BAAsB;AACjD,SAASC,UAAU,EAAEC,aAAa,QAA6B,+BAA2B;AAC1F,SAASC,kBAAkB,QAAQ,+BAA2B;AAC9D,SAASC,WAAW,QAAQ,sBAAkB;AAgC9C,wEAAwE,GACxE,OAAO,MAAMC,cAAoC;IAC/C;QAAEC,IAAI;QAAaC,OAAO;QAA+BC,SAAS;QAAMC,UAAU;IAAK;IACvF;QAAEH,IAAI;QAAOC,OAAO;QAAyBC,SAAS;QAAGC,UAAU;IAAE;CACtE,CAAA;AAED,4EAA4E,GAC5E,OAAO,MAAMC,mBAAmB,IAAG;AAEnC,OAAO,SAASC,UAAUL,EAAsB;QACvCD;IAAP,QAAOA,oBAAAA,YAAYO,IAAI,CAAC,CAACC,OAASA,KAAKP,EAAE,KAAKA,eAAvCD,oBAA8CA,WAAW,CAAC,EAAE;AACrE;AAEA,MAAMS,WAAW,CAACP,QAAwBQ,KAAKC,GAAG,CAAC,GAAGD,KAAKE,GAAG,CAACP,kBAAkBK,KAAKG,KAAK,CAACC,OAAOZ,MAAMa,MAAM,KAAK;AAEpH,MAAMC,YAAY,CAACd;QAEoCA;WADrDA,MAAMe,UAAU,IAAI,QAAQH,OAAOI,QAAQ,CAAChB,MAAMe,UAAU,IACxDnB,mBAAmBY,KAAKS,KAAK,CAACjB,MAAMe,UAAU,IAAGf,kBAAAA,MAAMkB,QAAQ,YAAdlB,kBAAkB,SACnE;;AAEN;;2CAE2C,GAE3C,OAAO,SAASmB,kBAAkBC,MAAsB,EAAEC,MAAe;IACvE,MAAMf,OAAOF,UAAUiB;IACvB,MAAMC,QAAkB,EAAE;IAC1B,KAAK,MAAMt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IAAI,CAAC,CAAC,GAAG,EAAEoB,OAAO,CAAC,EAAEP,EAAE,KAAK,EAAEQ,KAAK,CAAC,EAAEA,KAAK,GAAG,EAAEpB,QAAQmB,SAAS,EAAE,YAAY,EAAEhB,QAAQlC,MAAM0B,IAAI,EAAE,GAAG,CAAC;QAChHiB,KAAKQ,OAAO,IAAI;QAChB,IAAInD,MAAM2B,MAAM,EAAE;YAChB2B,OAAOxB,IAAI,CAAC,CAAC,GAAG,EAAEoB,OAAO,CAAC,EAAEP,EAAE,KAAK,EAAES,MAAM,CAAC,EAAEA,MAAM,GAAG,EAAErB,QAAQmB,SAAS,EAAE,YAAY,EAAEhB,QAAQlC,MAAM2B,MAAM,EAAE,GAAG,CAAC;YACpHgB,KAAKS,QAAQ;QACf;QACA,MAAMG,QAAQzC,UAAUd;QACxB,IAAIuD,OAAO;YACTD,OAAOxB,IAAI,CAAC,CAAC,GAAG,EAAEoB,OAAO,CAAC,EAAEP,EAAE,KAAK,EAAEQ,KAAK,CAAC,EAAEA,KAAK,MAAM,EAAEjB,QAAQqB,OAAO,GAAG,CAAC;YAC7EZ,KAAKQ,OAAO;QACd;QACA,IAAI5B,SAAS;YACX,qEAAqE;YACrE,MAAMiC,YAAYhD,KAAKC,GAAG,CAACD,KAAKS,KAAK,CAACgC,MAAM,MAAMjB,SAASW,IAAIO,SAASE,QAAQ;YAChFE,OAAOxB,IAAI,CAACW,WAAWlB,SAAS2B,QAAQP,GAAGa,WAAWZ;QACxD;QACAS,IAAIvB,IAAI,CAAC,CAAC,UAAU,EAAEC,MAAM,GAAG,EAAEC,OAAO,MAAM,EAAEsB,OAAOrB,IAAI,CAAC,IAAI,GAAG,EAAEpB,OAAO,SAAS,CAAC;IACxF;IACA,OAAOwC,IAAIpB,IAAI,CAAC;AAClB"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { type PrintDocument } from './print-document';
18
+ /**
19
+ * ePOS-Print XML for a {@link PrintDocument} (AGL-3619), wrapped in the
20
+ * Server Direct Print response an Epson TM printer receives when it polls.
21
+ *
22
+ * `<PrintRequestInfo Version="2.00">` so the job carries a `printjobid` that
23
+ * the printer echoes back in its result: the only way to tell which job a
24
+ * `SetResponse` is about when a printer has had more than one.
25
+ */
26
+ export declare const EPOS_PRINT_NAMESPACE = "http://www.epson-pos.com/schemas/2011/03/epos-print";
27
+ /** The drawer kick on its own: pin 2, a 100 ms pulse. */
28
+ export declare const EPSON_DRAWER_KICK = "<pulse drawer=\"drawer_1\" time=\"pulse_100\"/>";
29
+ /** Print job ids are 1-30 of `A-Z a-z 0-9 - _ .`; a Firestore id is 20 of them. */
30
+ export declare function epsonJobId(jobId: string): string;
31
+ export declare function escapeXml(value: string): string;
32
+ /** Epson's two-byte NV logo key, `48,48` → `[48, 48]`; anything else prints no logo. */
33
+ export declare function epsonLogoKeys(logoKey: string | undefined): [number, number] | null;
34
+ /** The `<epos-print>` element alone. */
35
+ export declare function renderEposPrint(document: PrintDocument, options?: {
36
+ logoKey?: string;
37
+ }): string;
38
+ /** The whole Server Direct Print response body for one job. */
39
+ export declare function renderEpsonServerDirectPrint(document: PrintDocument, options: {
40
+ jobId: string;
41
+ logoKey?: string;
42
+ timeoutMs?: number;
43
+ }): string;
44
+ export interface EpsonPrintResult {
45
+ jobId: string;
46
+ success: boolean;
47
+ code: string;
48
+ status?: number;
49
+ }
50
+ /**
51
+ * The results in a printer's `ResponseFile` (`<PrintResponseInfo>`), one per
52
+ * `<ePOSPrint>`. Read with patterns rather than an XML parser: the document is
53
+ * small, machine-written and fixed in shape, and nothing in it is trusted
54
+ * beyond the job id (looked up under the printer that posted it) and the
55
+ * result it reports for that job.
56
+ */
57
+ export declare function parseEpsonPrintResults(responseFile: string): EpsonPrintResult[];
@@ -0,0 +1,135 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ /**
3
+ * @license
4
+ * Copyright 2026 Aglyn LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */ import { toPrintable } from "./print-document.js";
18
+ /**
19
+ * ePOS-Print XML for a {@link PrintDocument} (AGL-3619), wrapped in the
20
+ * Server Direct Print response an Epson TM printer receives when it polls.
21
+ *
22
+ * `<PrintRequestInfo Version="2.00">` so the job carries a `printjobid` that
23
+ * the printer echoes back in its result: the only way to tell which job a
24
+ * `SetResponse` is about when a printer has had more than one.
25
+ */ export const EPOS_PRINT_NAMESPACE = 'http://www.epson-pos.com/schemas/2011/03/epos-print';
26
+ /** The drawer kick on its own: pin 2, a 100 ms pulse. */ export const EPSON_DRAWER_KICK = '<pulse drawer="drawer_1" time="pulse_100"/>';
27
+ /** Print job ids are 1-30 of `A-Z a-z 0-9 - _ .`; a Firestore id is 20 of them. */ export function epsonJobId(jobId) {
28
+ return String(jobId).replace(/[^A-Za-z0-9._-]/g, '').slice(0, 30);
29
+ }
30
+ export function escapeXml(value) {
31
+ return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&apos;');
32
+ }
33
+ /** Epson's two-byte NV logo key, `48,48` → `[48, 48]`; anything else prints no logo. */ export function epsonLogoKeys(logoKey) {
34
+ const parts = String(logoKey != null ? logoKey : '').split(/[\s,]+/).filter(Boolean).map(Number);
35
+ if (parts.length !== 2) return null;
36
+ return parts.every((part)=>Number.isInteger(part) && part >= 32 && part <= 126) ? [
37
+ parts[0],
38
+ parts[1]
39
+ ] : null;
40
+ }
41
+ /** The `<epos-print>` element alone. */ export function renderEposPrint(document, options = {}) {
42
+ const parts = [
43
+ `<epos-print xmlns="${EPOS_PRINT_NAMESPACE}">`,
44
+ '<text lang="en" smooth="true"/>'
45
+ ];
46
+ const logo = epsonLogoKeys(options.logoKey);
47
+ let align = 'left';
48
+ let bold = false;
49
+ let size = 1;
50
+ const setAlign = (next)=>{
51
+ if (next === align) return;
52
+ parts.push(`<text align="${next}"/>`);
53
+ align = next;
54
+ };
55
+ for (const op of document.ops){
56
+ switch(op.op){
57
+ case 'text':
58
+ {
59
+ var _op_align;
60
+ setAlign((_op_align = op.align) != null ? _op_align : 'left');
61
+ const nextSize = op.size === 2 ? 2 : 1;
62
+ if (nextSize !== size) {
63
+ parts.push(`<text width="${nextSize}" height="${nextSize}"/>`);
64
+ size = nextSize;
65
+ }
66
+ const nextBold = Boolean(op.bold);
67
+ if (nextBold !== bold) {
68
+ parts.push(`<text em="${nextBold}"/>`);
69
+ bold = nextBold;
70
+ }
71
+ parts.push(`<text>${escapeXml(toPrintable(op.text))}&#10;</text>`);
72
+ break;
73
+ }
74
+ case 'feed':
75
+ parts.push(`<feed line="${Math.max(1, Math.min(10, op.lines))}"/>`);
76
+ break;
77
+ case 'barcode':
78
+ setAlign('center');
79
+ // `{B` selects code set B, which carries printable ASCII.
80
+ parts.push(`<barcode type="code128" hri="below" font="font_a" width="2" height="64">` + `${escapeXml(`{B${toPrintable(op.data)}`)}</barcode>`, '<feed/>');
81
+ break;
82
+ case 'logo':
83
+ if (logo) {
84
+ setAlign('center');
85
+ parts.push(`<logo key1="${logo[0]}" key2="${logo[1]}"/>`);
86
+ }
87
+ break;
88
+ case 'drawer':
89
+ parts.push(EPSON_DRAWER_KICK);
90
+ break;
91
+ case 'cut':
92
+ parts.push('<cut type="feed"/>');
93
+ break;
94
+ }
95
+ }
96
+ parts.push('</epos-print>');
97
+ return parts.join('');
98
+ }
99
+ /** The whole Server Direct Print response body for one job. */ export function renderEpsonServerDirectPrint(document, options) {
100
+ var _options_timeoutMs;
101
+ return '<?xml version="1.0" encoding="utf-8"?>' + '<PrintRequestInfo Version="2.00">' + '<ePOSPrint>' + '<Parameter>' + '<devid>local_printer</devid>' + `<timeout>${Math.round((_options_timeoutMs = options.timeoutMs) != null ? _options_timeoutMs : 10000)}</timeout>` + `<printjobid>${escapeXml(epsonJobId(options.jobId))}</printjobid>` + '</Parameter>' + `<PrintData>${renderEposPrint(document, options)}</PrintData>` + '</ePOSPrint>' + '</PrintRequestInfo>';
102
+ }
103
+ const attribute = (tag, name)=>{
104
+ var _tag_match;
105
+ return (_tag_match = tag.match(new RegExp(`\\b${name}\\s*=\\s*"([^"]*)"`))) == null ? void 0 : _tag_match[1];
106
+ };
107
+ /**
108
+ * The results in a printer's `ResponseFile` (`<PrintResponseInfo>`), one per
109
+ * `<ePOSPrint>`. Read with patterns rather than an XML parser: the document is
110
+ * small, machine-written and fixed in shape, and nothing in it is trusted
111
+ * beyond the job id (looked up under the printer that posted it) and the
112
+ * result it reports for that job.
113
+ */ export function parseEpsonPrintResults(responseFile) {
114
+ var _xml_match;
115
+ const xml = String(responseFile != null ? responseFile : '').slice(0, 64 * 1024);
116
+ const results = [];
117
+ for (const block of (_xml_match = xml.match(/<ePOSPrint\b[\s\S]*?<\/ePOSPrint>/g)) != null ? _xml_match : []){
118
+ var _ref, _attribute, _attribute1;
119
+ var _block_match, _block_match1;
120
+ const jobId = (_ref = (_block_match = block.match(/<printjobid>\s*([^<]*?)\s*<\/printjobid>/)) == null ? void 0 : _block_match[1]) != null ? _ref : '';
121
+ const response = (_block_match1 = block.match(/<response\b[^>]*>/)) == null ? void 0 : _block_match1[0];
122
+ if (!jobId || !response) continue;
123
+ const status = Number(attribute(response, 'status'));
124
+ results.push(_extends({
125
+ jobId,
126
+ success: /^(true|1)$/i.test((_attribute = attribute(response, 'success')) != null ? _attribute : ''),
127
+ code: (_attribute1 = attribute(response, 'code')) != null ? _attribute1 : ''
128
+ }, Number.isFinite(status) ? {
129
+ status
130
+ } : {}));
131
+ }
132
+ return results;
133
+ }
134
+
135
+ //# sourceMappingURL=render-epson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/printing/render-epson.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { toPrintable, type PrintDocument } from './print-document'\n\n/**\n * ePOS-Print XML for a {@link PrintDocument} (AGL-3619), wrapped in the\n * Server Direct Print response an Epson TM printer receives when it polls.\n *\n * `<PrintRequestInfo Version=\"2.00\">` so the job carries a `printjobid` that\n * the printer echoes back in its result: the only way to tell which job a\n * `SetResponse` is about when a printer has had more than one.\n */\nexport const EPOS_PRINT_NAMESPACE = 'http://www.epson-pos.com/schemas/2011/03/epos-print'\n\n/** The drawer kick on its own: pin 2, a 100 ms pulse. */\nexport const EPSON_DRAWER_KICK = '<pulse drawer=\"drawer_1\" time=\"pulse_100\"/>'\n\n/** Print job ids are 1-30 of `A-Z a-z 0-9 - _ .`; a Firestore id is 20 of them. */\nexport function epsonJobId(jobId: string): string {\n return String(jobId).replace(/[^A-Za-z0-9._-]/g, '').slice(0, 30)\n}\n\nexport function escapeXml(value: string): string {\n return value\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&apos;')\n}\n\n/** Epson's two-byte NV logo key, `48,48` → `[48, 48]`; anything else prints no logo. */\nexport function epsonLogoKeys(logoKey: string | undefined): [number, number] | null {\n const parts = String(logoKey ?? '')\n .split(/[\\s,]+/)\n .filter(Boolean)\n .map(Number)\n if (parts.length !== 2) return null\n return parts.every((part) => Number.isInteger(part) && part >= 32 && part <= 126)\n ? [parts[0], parts[1]]\n : null\n}\n\n/** The `<epos-print>` element alone. */\nexport function renderEposPrint(document: PrintDocument, options: { logoKey?: string } = {}): string {\n const parts: string[] = [`<epos-print xmlns=\"${EPOS_PRINT_NAMESPACE}\">`, '<text lang=\"en\" smooth=\"true\"/>']\n const logo = epsonLogoKeys(options.logoKey)\n let align = 'left'\n let bold = false\n let size = 1\n const setAlign = (next: string) => {\n if (next === align) return\n parts.push(`<text align=\"${next}\"/>`)\n align = next\n }\n for (const op of document.ops) {\n switch (op.op) {\n case 'text': {\n setAlign(op.align ?? 'left')\n const nextSize = op.size === 2 ? 2 : 1\n if (nextSize !== size) {\n parts.push(`<text width=\"${nextSize}\" height=\"${nextSize}\"/>`)\n size = nextSize\n }\n const nextBold = Boolean(op.bold)\n if (nextBold !== bold) {\n parts.push(`<text em=\"${nextBold}\"/>`)\n bold = nextBold\n }\n parts.push(`<text>${escapeXml(toPrintable(op.text))}&#10;</text>`)\n break\n }\n case 'feed':\n parts.push(`<feed line=\"${Math.max(1, Math.min(10, op.lines))}\"/>`)\n break\n case 'barcode':\n setAlign('center')\n // `{B` selects code set B, which carries printable ASCII.\n parts.push(\n `<barcode type=\"code128\" hri=\"below\" font=\"font_a\" width=\"2\" height=\"64\">` +\n `${escapeXml(`{B${toPrintable(op.data)}`)}</barcode>`,\n '<feed/>',\n )\n break\n case 'logo':\n if (logo) {\n setAlign('center')\n parts.push(`<logo key1=\"${logo[0]}\" key2=\"${logo[1]}\"/>`)\n }\n break\n case 'drawer':\n parts.push(EPSON_DRAWER_KICK)\n break\n case 'cut':\n parts.push('<cut type=\"feed\"/>')\n break\n }\n }\n parts.push('</epos-print>')\n return parts.join('')\n}\n\n/** The whole Server Direct Print response body for one job. */\nexport function renderEpsonServerDirectPrint(\n document: PrintDocument,\n options: { jobId: string; logoKey?: string; timeoutMs?: number },\n): string {\n return (\n '<?xml version=\"1.0\" encoding=\"utf-8\"?>' +\n '<PrintRequestInfo Version=\"2.00\">' +\n '<ePOSPrint>' +\n '<Parameter>' +\n '<devid>local_printer</devid>' +\n `<timeout>${Math.round(options.timeoutMs ?? 10000)}</timeout>` +\n `<printjobid>${escapeXml(epsonJobId(options.jobId))}</printjobid>` +\n '</Parameter>' +\n `<PrintData>${renderEposPrint(document, options)}</PrintData>` +\n '</ePOSPrint>' +\n '</PrintRequestInfo>'\n )\n}\n\nexport interface EpsonPrintResult {\n jobId: string\n success: boolean\n code: string\n status?: number\n}\n\nconst attribute = (tag: string, name: string): string | undefined =>\n tag.match(new RegExp(`\\\\b${name}\\\\s*=\\\\s*\"([^\"]*)\"`))?.[1]\n\n/**\n * The results in a printer's `ResponseFile` (`<PrintResponseInfo>`), one per\n * `<ePOSPrint>`. Read with patterns rather than an XML parser: the document is\n * small, machine-written and fixed in shape, and nothing in it is trusted\n * beyond the job id (looked up under the printer that posted it) and the\n * result it reports for that job.\n */\nexport function parseEpsonPrintResults(responseFile: string): EpsonPrintResult[] {\n const xml = String(responseFile ?? '').slice(0, 64 * 1024)\n const results: EpsonPrintResult[] = []\n for (const block of xml.match(/<ePOSPrint\\b[\\s\\S]*?<\\/ePOSPrint>/g) ?? []) {\n const jobId = block.match(/<printjobid>\\s*([^<]*?)\\s*<\\/printjobid>/)?.[1] ?? ''\n const response = block.match(/<response\\b[^>]*>/)?.[0]\n if (!jobId || !response) continue\n const status = Number(attribute(response, 'status'))\n results.push({\n jobId,\n success: /^(true|1)$/i.test(attribute(response, 'success') ?? ''),\n code: attribute(response, 'code') ?? '',\n ...(Number.isFinite(status) ? { status } : {}),\n })\n }\n return results\n}\n"],"names":["toPrintable","EPOS_PRINT_NAMESPACE","EPSON_DRAWER_KICK","epsonJobId","jobId","String","replace","slice","escapeXml","value","epsonLogoKeys","logoKey","parts","split","filter","Boolean","map","Number","length","every","part","isInteger","renderEposPrint","document","options","logo","align","bold","size","setAlign","next","push","op","ops","nextSize","nextBold","text","Math","max","min","lines","data","join","renderEpsonServerDirectPrint","round","timeoutMs","attribute","tag","name","match","RegExp","parseEpsonPrintResults","responseFile","xml","results","block","response","status","success","test","code","isFinite"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,WAAW,QAA4B,sBAAkB;AAElE;;;;;;;CAOC,GACD,OAAO,MAAMC,uBAAuB,sDAAqD;AAEzF,uDAAuD,GACvD,OAAO,MAAMC,oBAAoB,8CAA6C;AAE9E,iFAAiF,GACjF,OAAO,SAASC,WAAWC,KAAa;IACtC,OAAOC,OAAOD,OAAOE,OAAO,CAAC,oBAAoB,IAAIC,KAAK,CAAC,GAAG;AAChE;AAEA,OAAO,SAASC,UAAUC,KAAa;IACrC,OAAOA,MACJH,OAAO,CAAC,MAAM,SACdA,OAAO,CAAC,MAAM,QACdA,OAAO,CAAC,MAAM,QACdA,OAAO,CAAC,MAAM,UACdA,OAAO,CAAC,MAAM;AACnB;AAEA,sFAAsF,GACtF,OAAO,SAASI,cAAcC,OAA2B;IACvD,MAAMC,QAAQP,OAAOM,kBAAAA,UAAW,IAC7BE,KAAK,CAAC,UACNC,MAAM,CAACC,SACPC,GAAG,CAACC;IACP,IAAIL,MAAMM,MAAM,KAAK,GAAG,OAAO;IAC/B,OAAON,MAAMO,KAAK,CAAC,CAACC,OAASH,OAAOI,SAAS,CAACD,SAASA,QAAQ,MAAMA,QAAQ,OACzE;QAACR,KAAK,CAAC,EAAE;QAAEA,KAAK,CAAC,EAAE;KAAC,GACpB;AACN;AAEA,sCAAsC,GACt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tBA;YAPMS,cACGA;QADjB,MAAMnD,iBAAQmD,eAAAA,MAAMN,KAAK,CAAC,gEAAZM,YAAyD,CAAC,EAAE,mBAAI;QAC9E,MAAMC,YAAWD,gBAAAA,MAAMN,KAAK,CAAC,yCAAZM,aAAkC,CAAC,EAAE;QACtD,IAAI,CAACnD,SAAS,CAACoD,UAAU;QACzB,MAAMC,SAASxC,OAAO6B,UAAUU,UAAU;QAC1CF,QAAQvB,IAAI,CAAC;YACX3B;YACAsD,SAAS,cAAcC,IAAI,EAACb,aAAAA,UAAUU,UAAU,sBAApBV,aAAkC;YAC9Dc,IAAI,GAAEd,cAAAA,UAAUU,UAAU,mBAApBV,cAA+B;WACjC7B,OAAO4C,QAAQ,CAACJ,UAAU;YAAEA;QAAO,IAAI,CAAC;IAEhD;IACA,OAAOH;AACT"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { type PrintDocument } from './print-document';
18
+ /**
19
+ * Star command bytes for a {@link PrintDocument} (AGL-3619), served to a
20
+ * CloudPRNT printer as `application/vnd.star.starprntcore`: the subset of
21
+ * StarPRNT that both Star Line Mode and StarPRNT emulation execute, so one
22
+ * job prints on an mC-Print3, a TSP143IV and a legacy TSP650II alike.
23
+ *
24
+ * Every command used here is in that common subset:
25
+ *
26
+ * | bytes | command |
27
+ * | --------------------- | ----------------------------------------- |
28
+ * | `1B 40` | initialize |
29
+ * | `1B 1D 61 n` | alignment (0 left, 1 center, 2 right) |
30
+ * | `1B 45` / `1B 46` | emphasis on / off |
31
+ * | `1B 69 h w` | character expansion (0 = normal, 1 = 2x) |
32
+ * | `1B 62 06 02 02 h d… 1E` | Code128, text below, 3-dot module, `h` dots tall |
33
+ * | `1B 1C 70 n 00` | print NV logo `n` |
34
+ * | `07` | drive external device 1 (the cash drawer) |
35
+ * | `1B 64 03` | feed to the cutter and partial cut |
36
+ * | `0A` | line feed |
37
+ */
38
+ export declare const STAR_MEDIA_TYPE = "application/vnd.star.starprntcore";
39
+ /** The drawer kick on its own, the bytes a "paid out" job sends: BEL drives drawer 1. */
40
+ export declare const STAR_DRAWER_KICK: readonly [7];
41
+ /** Star's NV logo number, 1-255; anything else prints no logo. */
42
+ export declare function starLogoNumber(logoKey: string | undefined): number | null;
43
+ export declare function renderStar(document: PrintDocument, options?: {
44
+ logoKey?: string;
45
+ }): Uint8Array;
@@ -0,0 +1,100 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ import { toPrintable } from "./print-document.js";
17
+ /**
18
+ * Star command bytes for a {@link PrintDocument} (AGL-3619), served to a
19
+ * CloudPRNT printer as `application/vnd.star.starprntcore`: the subset of
20
+ * StarPRNT that both Star Line Mode and StarPRNT emulation execute, so one
21
+ * job prints on an mC-Print3, a TSP143IV and a legacy TSP650II alike.
22
+ *
23
+ * Every command used here is in that common subset:
24
+ *
25
+ * | bytes | command |
26
+ * | --------------------- | ----------------------------------------- |
27
+ * | `1B 40` | initialize |
28
+ * | `1B 1D 61 n` | alignment (0 left, 1 center, 2 right) |
29
+ * | `1B 45` / `1B 46` | emphasis on / off |
30
+ * | `1B 69 h w` | character expansion (0 = normal, 1 = 2x) |
31
+ * | `1B 62 06 02 02 h d… 1E` | Code128, text below, 3-dot module, `h` dots tall |
32
+ * | `1B 1C 70 n 00` | print NV logo `n` |
33
+ * | `07` | drive external device 1 (the cash drawer) |
34
+ * | `1B 64 03` | feed to the cutter and partial cut |
35
+ * | `0A` | line feed |
36
+ */ export const STAR_MEDIA_TYPE = 'application/vnd.star.starprntcore';
37
+ const ESC = 0x1b;
38
+ const GS = 0x1d;
39
+ const LF = 0x0a;
40
+ /** The drawer kick on its own, the bytes a "paid out" job sends: BEL drives drawer 1. */ export const STAR_DRAWER_KICK = [
41
+ 0x07
42
+ ];
43
+ const BARCODE_HEIGHT_DOTS = 80;
44
+ function ascii(text) {
45
+ return Array.from(toPrintable(text), (char)=>char.charCodeAt(0));
46
+ }
47
+ /** Star's NV logo number, 1-255; anything else prints no logo. */ export function starLogoNumber(logoKey) {
48
+ const value = Number(String(logoKey != null ? logoKey : '').trim());
49
+ return Number.isInteger(value) && value >= 1 && value <= 255 ? value : null;
50
+ }
51
+ export function renderStar(document, options = {}) {
52
+ const bytes = [
53
+ ESC,
54
+ 0x40
55
+ ];
56
+ const logo = starLogoNumber(options.logoKey);
57
+ let align = 0;
58
+ const setAlign = (next)=>{
59
+ if (next === align) return;
60
+ bytes.push(ESC, GS, 0x61, next);
61
+ align = next;
62
+ };
63
+ for (const op of document.ops){
64
+ switch(op.op){
65
+ case 'text':
66
+ {
67
+ setAlign(op.align === 'center' ? 1 : op.align === 'right' ? 2 : 0);
68
+ const expand = op.size === 2 ? 1 : 0;
69
+ if (expand) bytes.push(ESC, 0x69, expand, expand);
70
+ if (op.bold) bytes.push(ESC, 0x45);
71
+ bytes.push(...ascii(op.text), LF);
72
+ if (op.bold) bytes.push(ESC, 0x46);
73
+ if (expand) bytes.push(ESC, 0x69, 0, 0);
74
+ break;
75
+ }
76
+ case 'feed':
77
+ for(let index = 0; index < Math.max(0, Math.min(10, op.lines)); index += 1)bytes.push(LF);
78
+ break;
79
+ case 'barcode':
80
+ setAlign(1);
81
+ bytes.push(ESC, 0x62, 0x06, 0x02, 0x02, BARCODE_HEIGHT_DOTS, ...ascii(op.data), 0x1e, LF);
82
+ break;
83
+ case 'logo':
84
+ if (logo !== null) {
85
+ setAlign(1);
86
+ bytes.push(ESC, 0x1c, 0x70, logo, 0x00);
87
+ }
88
+ break;
89
+ case 'drawer':
90
+ bytes.push(...STAR_DRAWER_KICK);
91
+ break;
92
+ case 'cut':
93
+ bytes.push(ESC, 0x64, 0x03);
94
+ break;
95
+ }
96
+ }
97
+ return Uint8Array.from(bytes);
98
+ }
99
+
100
+ //# sourceMappingURL=render-star.js.map