- Add Gitea Actions workflow; point README to gitea.d-bis.org/Sankofa_Phoenix/SMOA - Expand .gitignore for Spring H2 data, secrets, Kotlin .kotlin/, tooling - Track docs/api/generated ReDoc bundle; refresh api docs README - Android: network/auth/sync, UI shell, tests; backend credentials/integrity APIs - Docs, scripts (generate-api-docs), modules and core updates Made-with: Cursor
28 lines
1.1 KiB
JavaScript
28 lines
1.1 KiB
JavaScript
/* SMOA web scaffold – minimal offline shell (cache static assets only). */
|
||
const CACHE = 'smoa-web-v1';
|
||
const ASSETS = ['./index.html', './manifest.webmanifest', './sw.js', './offline-queue.js'];
|
||
|
||
self.addEventListener('install', (event) => {
|
||
event.waitUntil(caches.open(CACHE).then((c) => c.addAll(ASSETS)).then(() => self.skipWaiting()));
|
||
});
|
||
|
||
self.addEventListener('activate', (event) => {
|
||
event.waitUntil(
|
||
caches.keys().then((keys) =>
|
||
Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))
|
||
).then(() => self.clients.claim())
|
||
);
|
||
});
|
||
|
||
self.addEventListener('fetch', (event) => {
|
||
const url = new URL(event.request.url);
|
||
if (url.origin === self.location.origin && ASSETS.some((p) => url.pathname.endsWith(p.replace('./', '/')))) {
|
||
event.respondWith(caches.match(event.request).then((r) => r || fetch(event.request)));
|
||
return;
|
||
}
|
||
// API calls: network-first (no offline queue in this scaffold)
|
||
if (event.request.method === 'GET') {
|
||
event.respondWith(fetch(event.request).catch(() => caches.match('./index.html')));
|
||
}
|
||
});
|