wrolpi/app/package.json
Roland 20d2bb8717
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>
2026-06-22 15:21:25 -06:00

76 lines
2 KiB
JSON

{
"name": "wrolpi-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@acalcutt/maplibre-contour-pmtiles": "^0.1.2",
"@artsy/fresnel": "^6.1.0",
"@cypress/react18": "^2.0.1",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"cypress": "^13.15.2",
"lodash": "^4.18.1",
"maplibre-gl": "^5.24.0",
"mathjs": "^15.2.0",
"pmtiles": "^4.4.1",
"protomaps-themes-base": "^4.5.0",
"query-string": "^9.4.0",
"react": "^18.2.0",
"react-colorful": "^5.7.0",
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
"react-hotkeys-hook": "^5.3.2",
"react-qr-code": "^2.0.21",
"react-router": "^7.16.0",
"react-scripts": "5.0.1",
"react-semantic-toasts-2": "^0.6.7",
"react-stl-viewer": "^2.5.0",
"semantic-ui-offline": "^2.5.0",
"semantic-ui-react": "^2.1.5",
"three": "^0.184",
"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",
"build": "BROWSERSLIST_IGNORE_OLD_DATA=true react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"cy:run": "cypress run",
"cy:open": "cypress open"
},
"eslintConfig": {
"extends": [
"react-app"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@testing-library/jest-dom": "^6.9.1",
"@types/lodash": "^4.17.24",
"@types/node": "^25.9.1",
"@types/react": "^18.3.17",
"@types/react-dom": "^18.3.5",
"typescript": "^4.9.5"
},
"jest": {
"transformIgnorePatterns": [
"node_modules/(?!(react-hotkeys-hook)/)"
]
}
}