diff --git a/public/manifest.json b/public/manifest.json new file mode 100644 index 0000000..fda51f1 --- /dev/null +++ b/public/manifest.json @@ -0,0 +1,22 @@ +{ + "name": "EuchreCamp", + "short_name": "EuchreCamp", + "description": "Track your Euchre games and tournaments", + "start_url": "/", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#2d5a27", + "orientation": "portrait-primary", + "icons": [ + { + "src": "/icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "/icon-512.png", + "sizes": "512x512", + "type": "image/png" + } + ] +} \ No newline at end of file diff --git a/public/service-worker.js b/public/service-worker.js new file mode 100644 index 0000000..1ced5c2 --- /dev/null +++ b/public/service-worker.js @@ -0,0 +1,46 @@ +// EuchreCamp Service Worker +const CACHE_NAME = 'euchrecamp-v1'; +const urlsToCache = [ + '/', + '/rankings', + '/app.css', + '/app.js' +]; + +// Install event - cache resources +self.addEventListener('install', event => { + event.waitUntil( + caches.open(CACHE_NAME) + .then(cache => { + return cache.addAll(urlsToCache); + }) + ); + self.skipWaiting(); +}); + +// Activate event - clean up old caches +self.addEventListener('activate', event => { + event.waitUntil( + caches.keys().then(cacheNames => { + return Promise.all( + cacheNames.map(cacheName => { + if (cacheName !== CACHE_NAME) { + return caches.delete(cacheName); + } + }) + ); + }) + ); + self.clients.claim(); +}); + +// Fetch event - serve from cache, fallback to network +self.addEventListener('fetch', event => { + event.respondWith( + caches.match(event.request) + .then(response => { + // Return cached version or fetch from network + return response || fetch(event.request); + }) + ); +}); \ No newline at end of file