feat(pwa): harden the auto-update chain and add a version tool

- ui/pwa.js: register with updateViaCache:'none', check for updates on load, every
  30 min, on tab focus and on 'online'; controllerchange reloads the page itself but
  waits while the user is typing in a form (admin edits survive), retrying on blur/hide
- sw.js: precache the maskable icon; bump VERSION -> 2026.11.24.2
- scripts/bump-version.mjs: bump sw.js VERSION + <meta app-version> together, --check
  fails on drift; wired into
> [email protected] check
> node --check ui/app.js && node --check ui/data.js && node --check ui/router.js && node --check ui/ui.js && node --check ui/pwa.js && node --check ui/views/home.js && node --check ui/views/admin.js && node --check sw.js && node --check server/publish.mjs && node --check server/db.mjs && node --check scripts/bump-version.mjs && node scripts/bump-version.mjs --check

[version] ตรงกันที่ 2026.11.24.2, exposed as
> [email protected] version
> node scripts/bump-version.mjs

[version] ตั้งเป็น 2026.11.24.3 แล้ว (sw.js + index.html)
- README/AGENTS: document the PWA behaviour and the bump workflow

Verified in Chrome: SPA route changes keep timeOrigin and navigation count at 1 (no
reload), a simulated deploy (version bump -> reg.update) replaced the cache from
hobbypj-2026.11.24.1 to .2 with the old cache deleted and the page reloading by
itself, Page.getAppManifest errors: [], and with the network emulated offline the
shell + 6 cards still render while an uncached file fails.
This commit is contained in:
Bkk1234 committed 2026-11-24 14:52:50 +07:00
1 parent 9258cdd09e
commit 634dc3ae3c
7 files changed
+173 -13

No files matched your search

+2 -1
View File
@@ -2,7 +2,7 @@
กติกา: bump VERSION เฉพาะเมื่อแก้ไฟล์นี้หรือรายการ PRECACHE
เนื้อหา (HTML/CSS/JS/JSON) ใช้ network-first จึงไม่ต้อง bump */
const VERSION = "2026.11.19.4";
const VERSION = "2026.11.24.2";
const CACHE = `hobbypj-${VERSION}`;
const PRECACHE = [
@@ -26,6 +26,7 @@ const PRECACHE = [
"./config/admin-credentials.json",
"./icons/icon-192.png",
"./icons/icon-512.png",
"./icons/icon-512-maskable.png",
"./fonts/k2d-400-thai.woff2",
"./fonts/k2d-700-thai.woff2",
];