From 518717f8206258dcddf3afa731feca3f9628b450 Mon Sep 17 00:00:00 2001 From: Google AI Agent Date: Wed, 25 Mar 2026 03:02:46 +0000 Subject: [PATCH] [gemini] Feat: Re-implement Service Worker and PWA Manifest (#485) (#491) --- icons/icon-192x192.png | 1 + icons/icon-512x512.png | 1 + index.html | 15 ++++++++++++++ manifest.json | 21 ++++++++++++++++++++ service-worker.js | 45 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 83 insertions(+) create mode 100644 icons/icon-192x192.png create mode 100644 icons/icon-512x512.png create mode 100644 manifest.json create mode 100644 service-worker.js diff --git a/icons/icon-192x192.png b/icons/icon-192x192.png new file mode 100644 index 0000000..8a099df --- /dev/null +++ b/icons/icon-192x192.png @@ -0,0 +1 @@ +placeholder 192x192 \ No newline at end of file diff --git a/icons/icon-512x512.png b/icons/icon-512x512.png new file mode 100644 index 0000000..0cc22bc --- /dev/null +++ b/icons/icon-512x512.png @@ -0,0 +1 @@ +placeholder 512x512 \ No newline at end of file diff --git a/index.html b/index.html index dd4d42d..8031a64 100644 --- a/index.html +++ b/index.html @@ -23,6 +23,7 @@ + + +
{ + event.waitUntil( + caches.open(CACHE_NAME) + .then((cache) => { + console.log('Opened cache'); + return cache.addAll(urlsToCache); + }) + ); +}); + +self.addEventListener('fetch', (event) => { + event.respondWith( + caches.match(event.request) + .then((response) => { + if (response) { + return response; + } + return fetch(event.request); + }) + ); +}); + +self.addEventListener('activate', (event) => { + const cacheWhitelist = [CACHE_NAME]; + event.waitUntil( + caches.keys().then((cacheNames) => { + return Promise.all( + cacheNames.map((cacheName) => { + if (cacheWhitelist.indexOf(cacheName) === -1) { + return caches.delete(cacheName); + } + }) + ); + }) + ); +}); \ No newline at end of file