LifeMate — Personal, Family & Learning Companion
feat/flutter-mobile-navigation
chore/phase1-repository-cleanup
deploy/stable-web-apk
deployment-static
design/mobile-accessibility-v2
design/mobile-navigation-review
docs/child-education-access-decision
docs/offline-data-rescue-options
docs/owner-guide-and-delivery-plan
docs/phase1-policy-options
docs/public-review-live-2026-10-15
feat/aparat-learning-library
feat/child-device-safety
feat/child-identity-schema
feat/flutter-mobile-navigation
feat/learning-content-operations
feat/local-signing-preflight
feat/online-family-stage0
feat/personal-encrypted-recovery
feat/private-planner-series-api
feat/public-review-page
feat/standalone-weekly-planner
feat/weekly-planner-android
final-feature-1/iran-family-school
fix/auth-abuse-expiry-safety
fix/auth-expiry-after-lock
fix/backend-request-safety
fix/lifeguide-bootstrap-naming-ci
fix/lifeguide-pages-qa-base-preflight
fix/lifeguide-qa-pages-env-deployment
fix/local-task-persistence
fix/managed-child-session-boundary
fix/personal-jalali-dates
fix/personal-notification-controls
fix/personal-upgrade-delivery-guard
fix/sms-approval-gates
fix/study-duration-display
infra/cloudflare-neon-migration
infra/lifeguide-cloudflare-qa
infra/lifeguide-github-pages-qa
infra/lifeguide-supabase-qa
main
phase-1/foundation-completion
phase-2/product-foundation-identity
phase-3/planner-school-family-core
phase-4/ai-learning-wellbeing
phase-5/hardening-observability-release
test/android-reminder-acceptance
test/personal-notification-settings
test/personal-recovery-acceptance
test/role-entry-apk
| 1 | // Current code/settings use the network. A cold disconnected navigation may |
| 2 | // show only a public notice, never cached login, permissions or personal data. |
| 3 | const CACHE = 'lifeguide-static-v0.7.1-7'; |
| 4 | const BASE_PATH = new URL('.', self.location.href).pathname; |
| 5 | const OFFLINE_URL = new URL('offline.html', self.location.href).href; |
| 6 | const RETRY_URL = new URL('offline-retry.js', self.location.href).href; |
| 7 | const STATIC_PATH = /^(?:(?:assets|canvaskit|icons)\/|offline-retry\.js$)/; |
| 8 | self.addEventListener('install', (event) => { |
| 9 | event.waitUntil((async () => { |
| 10 | const cache = await caches.open(CACHE); |
| 11 | for (const url of [OFFLINE_URL, RETRY_URL]) { |
| 12 | const response = await fetch(new Request(url, {credentials: 'omit'}), {cache: 'no-store'}); |
| 13 | if (!response.ok) throw new Error('Offline notice unavailable'); |
| 14 | await cache.put(url, response); |
| 15 | } |
| 16 | await self.skipWaiting(); |
| 17 | })()); |
| 18 | }); |
| 19 | self.addEventListener('activate', (event) => { |
| 20 | event.waitUntil((async () => { |
| 21 | for (const key of await caches.keys()) { |
| 22 | if ((key.startsWith('lifeguide-static-') && key !== CACHE) || key.startsWith('flutter-')) { |
| 23 | await caches.delete(key); |
| 24 | } |
| 25 | } |
| 26 | await self.clients.claim(); |
| 27 | })()); |
| 28 | }); |
| 29 | self.addEventListener('fetch', (event) => { |
| 30 | const request = event.request; |
| 31 | const url = new URL(request.url); |
| 32 | if (request.method !== 'GET' || url.origin !== self.location.origin || |
| 33 | url.search || request.headers.has('authorization') || |
| 34 | !url.pathname.startsWith(BASE_PATH)) return; |
| 35 | const relative = url.pathname.slice(BASE_PATH.length); |
| 36 | if (request.mode === 'navigate' && (relative === '' || relative === 'index.html')) { |
| 37 | event.respondWith((async () => { |
| 38 | try { return await fetch(request, {cache: 'no-store'}); } |
| 39 | catch (error) { |
| 40 | const stored = await (await caches.open(CACHE)).match(OFFLINE_URL); |
| 41 | if (stored) return stored; |
| 42 | throw error; |
| 43 | } |
| 44 | })()); |
| 45 | return; |
| 46 | } |
| 47 | if ( |
| 48 | !STATIC_PATH.test(url.pathname.slice(BASE_PATH.length))) return; |
| 49 | event.respondWith((async () => { |
| 50 | const cache = await caches.open(CACHE); |
| 51 | try { |
| 52 | const response = await fetch(request, {cache: 'no-store'}); |
| 53 | if (response.ok) await cache.put(request, response.clone()); |
| 54 | return response; |
| 55 | } catch (error) { |
| 56 | const stored = await cache.match(request); |
| 57 | if (stored) return stored; |
| 58 | throw error; |
| 59 | } |
| 60 | })()); |
| 61 | }); |