mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-25 09:26:17 -05:00
Add PWA: installable app, offline calculators, read-only Inventory
Make the React app an installable PWA whose app shell, calculators
(incl. the One Time Pad), and Inventory work offline. Driving use case:
reference an inventory (e.g. Fasteners) from an iPhone with no connection.
Phase 1 — service worker (Workbox InjectManifest, production build only):
- service-worker.js: precache the shell (calculators work offline),
NavigationRoute for deep links, NetworkFirst cache of GET /api/inventory
and /api/inventory/catalog (wrolpi-inventory), NetworkOnly /api/status.
- serviceWorkerRegistration.js + registration in index.js.
- Add workbox-* runtime deps (pinned 6.5.4 to match CRA's bundled plugin).
Phase 2 — offline hardening + read-only Inventory:
- api.js maps offline fetch failures (TypeError / timeout / !navigator.onLine)
to ApiDownError so the existing nav apiDown indicator lights up.
- toast.js wrapper swallows error toasts while offline; repoint the toast
import in the 13 files that raise them (App.js container left as-is).
- PwaContext (usePwa() -> {offline, isStandalone}), provider mounted in
App.js inside StatusProvider. Default offline:false so components render
without the provider in tests.
- Inventory is read-only offline: InventoryRoute disables the edit buttons
and shows a banner; InventoryTable hides the new-item row, checkboxes and
delete, and disables click-to-edit. Values stay visible for reference.
Phase 3 — iOS Add-to-Home-Screen meta tags in public/index.html.
Verified end-to-end against the real API: SW caches the inventory, then with
the origin stopped the cached inventory still renders read-only (reactively
and on cold reload). All 676 Jest tests pass (incl. new InventoryTable
offline tests).
Media "Save for offline" + a Downloads list are intentionally deferred.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
36b29afef7
commit
20d2bb8717
25 changed files with 472 additions and 62 deletions
|
|
@ -28,7 +28,12 @@
|
|||
"semantic-ui-offline": "^2.5.0",
|
||||
"semantic-ui-react": "^2.1.5",
|
||||
"three": "^0.184",
|
||||
"web-vitals": "^5.3.0"
|
||||
"web-vitals": "^5.3.0",
|
||||
"workbox-cacheable-response": "^6.5.4",
|
||||
"workbox-core": "^6.5.4",
|
||||
"workbox-precaching": "^6.5.4",
|
||||
"workbox-routing": "^6.5.4",
|
||||
"workbox-strategies": "^6.5.4"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue