31 lines
762 B
JavaScript
31 lines
762 B
JavaScript
// BitSage Service Worker
|
|
const CACHE_NAME = 'bitsage-v1';
|
|
const ASSETS_TO_CACHE = [
|
|
'/',
|
|
'/index.html',
|
|
'/index.tsx'
|
|
];
|
|
|
|
self.addEventListener('install', (event) => {
|
|
self.skipWaiting();
|
|
event.waitUntil(
|
|
caches.open(CACHE_NAME).then((cache) => {
|
|
// Best effort caching
|
|
return cache.addAll(ASSETS_TO_CACHE).catch(() => {});
|
|
})
|
|
);
|
|
});
|
|
|
|
self.addEventListener('activate', (event) => {
|
|
event.waitUntil(self.clients.claim());
|
|
});
|
|
|
|
self.addEventListener('fetch', (event) => {
|
|
// Simple pass-through fetch handler to satisfy PWA requirements
|
|
// In a full production app, you might want more robust offline caching
|
|
event.respondWith(
|
|
fetch(event.request).catch(() => {
|
|
return caches.match(event.request);
|
|
})
|
|
);
|
|
}); |