- Remove executable permissions from configuration files (.editorconfig, .env.example, .gitignore) - Remove executable permissions from documentation files (README.md, LICENSE, SECURITY.md) - Remove executable permissions from web assets (HTML, CSS, JS files) - Remove executable permissions from data files (JSON, SQL, YAML, requirements.txt) - Remove executable permissions from source code files across all apps - Add executable permissions to Python
70 lines
1.8 KiB
JavaScript
70 lines
1.8 KiB
JavaScript
const CACHE_NAME = 'aitbc-v1';
|
|
const urlsToCache = [
|
|
'/',
|
|
'/index.html',
|
|
'/assets/css/main.css',
|
|
'/assets/css/font-awesome.min.css',
|
|
'/assets/js/main.js',
|
|
'/favicon.ico',
|
|
'/explorer/',
|
|
'/marketplace/',
|
|
'/docs/'
|
|
];
|
|
|
|
// Install event - cache assets
|
|
self.addEventListener('install', event => {
|
|
event.waitUntil(
|
|
caches.open(CACHE_NAME)
|
|
.then(cache => {
|
|
console.log('Caching assets...');
|
|
return cache.addAll(urlsToCache);
|
|
})
|
|
.catch(err => console.log('Cache failed:', err))
|
|
);
|
|
self.skipWaiting();
|
|
});
|
|
|
|
// Fetch event - serve from cache or network
|
|
self.addEventListener('fetch', event => {
|
|
event.respondWith(
|
|
caches.match(event.request)
|
|
.then(response => {
|
|
// Return cached version or fetch from network
|
|
if (response) {
|
|
return response;
|
|
}
|
|
return fetch(event.request)
|
|
.then(networkResponse => {
|
|
// Cache successful network responses
|
|
if (networkResponse && networkResponse.status === 200) {
|
|
const clonedResponse = networkResponse.clone();
|
|
caches.open(CACHE_NAME).then(cache => {
|
|
cache.put(event.request, clonedResponse);
|
|
});
|
|
}
|
|
return networkResponse;
|
|
})
|
|
.catch(() => {
|
|
// Return offline fallback for HTML requests
|
|
if (event.request.mode === 'navigate') {
|
|
return caches.match('/index.html');
|
|
}
|
|
});
|
|
})
|
|
);
|
|
});
|
|
|
|
// Activate event - clean up old caches
|
|
self.addEventListener('activate', event => {
|
|
event.waitUntil(
|
|
caches.keys().then(cacheNames => {
|
|
return Promise.all(
|
|
cacheNames
|
|
.filter(name => name !== CACHE_NAME)
|
|
.map(name => caches.delete(name))
|
|
);
|
|
})
|
|
);
|
|
self.clients.claim();
|
|
});
|