1// Minimal service worker for PWA installability only. 2// Provides "Add to Home Screen" functionality without caching overhead. 3// Version bumped to force update: v3 4 5const VERSION = 'jd-minimal-v3'; 6 7// Install: activate immediately 8self.addEventListener('install', () => { 9 console.log(`[SW ${VERSION}] Installing...`); 10 self.skipWaiting(); 11}); 12 13// Activate: claim all clients and clean up old caches 14self.addEventListener('activate', (event) => { 15 console.log(`[SW ${VERSION}] Activating...`); 16 event.waitUntil( 17 (async () => { 18 // Clean up ALL old caches from previous versions 19 const keys = await caches.keys(); 20 await Promise.all(keys.map((key) => caches.delete(key))); 21 await self.clients.claim(); 22 console.log(`[SW ${VERSION}] Active and controlling all clients`); 23 })(), 24 ); 25}); 26 27// Fetch: required for service worker but does nothing 28// All requests pass through to the network naturally 29self.addEventListener('fetch', () => { 30 // Intentionally empty - no interception, no caching 31 // Browser handles all requests natively for maximum performance 32}); 33 34// Push notifications support (skeleton for future use) 35self.addEventListener('push', (event) => { 36 if (!event.data) return; 37 try { 38 const data = event.data.json(); 39 const title = data.title || 'Notification'; 40 const options = { 41 body: data.body, 42 icon: data.icon || '/android-chrome-192x192.png', 43 badge: data.badge || '/favicon-32x32.png', 44 data: data.data || {}, 45 }; 46 event.waitUntil(self.registration.showNotification(title, options)); 47 } catch (err) { 48 console.error('[SW] Push notification error:', err); 49 } 50}); 51 52self.addEventListener('notificationclick', (event) => { 53 event.notification.close(); 54 const target = (event.notification?.data?.url) || '/'; 55 event.waitUntil(self.clients.openWindow(target)); 56});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.