1const CACHE_NAME = 'life-tracker-v1'; 2const urlsToCache = [ 3 './', 4 './index.html', 5 './styles.css', 6 './app.js', 7 './manifest.json', 8 './icon-192.png', 9 './icon-512.png' 10]; 11 12// Install 13self.addEventListener('install', event => { 14 event.waitUntil( 15 caches.open(CACHE_NAME) 16 .then(cache => cache.addAll(urlsToCache)) 17 ); 18 self.skipWaiting(); 19}); 20 21// Activate 22self.addEventListener('activate', event => { 23 event.waitUntil( 24 caches.keys().then(cacheNames => { 25 return Promise.all( 26 cacheNames.filter(name => name !== CACHE_NAME) 27 .map(name => caches.delete(name)) 28 ); 29 }) 30 ); 31 self.clients.claim(); 32}); 33 34// Fetch 35self.addEventListener('fetch', event => { 36 event.respondWith( 37 caches.match(event.request) 38 .then(response => response || fetch(event.request)) 39 ); 40}); 41 42// Notification click 43self.addEventListener('notificationclick', event => { 44 event.notification.close(); 45 event.waitUntil( 46 clients.openWindow('/') 47 ); 48});
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.