40 lines
980 B
JavaScript
40 lines
980 B
JavaScript
// This was created/generated by Claude AI LLM there may be errors present.
|
|
|
|
const CACHE_NAME = 'sentinel-v1';
|
|
const ASSETS = [
|
|
'/',
|
|
'/html/home.html',
|
|
'/html/login.html',
|
|
'/html/transport.html',
|
|
'/app.js',
|
|
'/manifest.json',
|
|
'/css/styles.css',
|
|
'/css/loader.css',
|
|
'/assets/icons/favicon.ico',
|
|
'/assets/images/sentinelLogo.png',
|
|
];
|
|
|
|
// Install — cache your core assets
|
|
self.addEventListener('install', event => {
|
|
event.waitUntil(
|
|
caches.open(CACHE_NAME).then(cache => cache.addAll(ASSETS))
|
|
);
|
|
});
|
|
|
|
// Activate — clean up old caches
|
|
self.addEventListener('activate', event => {
|
|
event.waitUntil(
|
|
caches.keys().then(keys =>
|
|
Promise.all(
|
|
keys.filter(key => key !== CACHE_NAME).map(key => caches.delete(key))
|
|
)
|
|
)
|
|
);
|
|
});
|
|
|
|
// Fetch — serve from cache, fall back to network
|
|
self.addEventListener('fetch', event => {
|
|
event.respondWith(
|
|
caches.match(event.request).then(cached => cached || fetch(event.request))
|
|
);
|
|
}); |