mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-25 09:26:17 -05:00
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>
|
||
|---|---|---|
| .. | ||
| epub | ||
| android-chrome-192x192.png | ||
| android-chrome-512x512.png | ||
| apple-touch-icon.png | ||
| favicon-16x16.png | ||
| favicon-32x32.png | ||
| favicon-blue.svg | ||
| favicon-brown.svg | ||
| favicon-green.svg | ||
| favicon-grey.svg | ||
| favicon-olive.svg | ||
| favicon-orange.svg | ||
| favicon-pink.svg | ||
| favicon-purple.svg | ||
| favicon-red.svg | ||
| favicon-teal.svg | ||
| favicon-violet.svg | ||
| favicon-yellow.svg | ||
| favicon.ico | ||
| icon-transparent.png | ||
| icon.svg | ||
| index.html | ||
| logo192.png | ||
| logo512.png | ||
| manifest.json | ||
| mstile-150x150.png | ||
| one-time-pad-cheat-sheet.pdf | ||
| robots.txt | ||