From 2ea76f9d9ad4bc277c17a58eab02036012e5159b Mon Sep 17 00:00:00 2001 From: Dave Date: Thu, 3 Sep 2026 17:52:39 +0200 Subject: [PATCH] feat(pos): add printer settings persistence for network printing --- public/pos/epos-print.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 public/pos/epos-print.js diff --git a/public/pos/epos-print.js b/public/pos/epos-print.js new file mode 100644 index 0000000..ce78a98 --- /dev/null +++ b/public/pos/epos-print.js @@ -0,0 +1,28 @@ +// Network (ePOS-Print) thermal printing for Epson TM-series Ethernet +// printers. Runs alongside the existing Web Bluetooth path in +// receipt.html — the till picks a transport in Printer settings. +// +// The printer's ePOS-Print endpoint is served over HTTPS with a +// self-signed cert and open CORS (`Access-Control-Allow-Origin: *`), +// confirmed by direct testing against the shop's TM-T20II. Each till +// device must visit `https://` once in its browser and +// accept the certificate warning before fetch() calls here succeed. +window.EposPrint = (function () { + 'use strict'; + + const SETTINGS_KEY = 'pos.printerSettings'; + + function getSettings() { + try { + return JSON.parse(localStorage.getItem(SETTINGS_KEY)) || { type: 'bluetooth', ip: '' }; + } catch (e) { + return { type: 'bluetooth', ip: '' }; + } + } + + function setSettings(settings) { + localStorage.setItem(SETTINGS_KEY, JSON.stringify(settings)); + } + + return { getSettings, setSettings }; +})();