RaMemory/build/sw.js

1 line
1.9 KiB
JavaScript

const swName="RaMemoryMM",addResourcesToCache=async function(a){await(await caches.open(swName)).addAll(a)},putInCache=async function(a,n){await(await caches.open(swName)).put(a,n)},enableNavigationPreload=async function(){self.registration.navigationPreload&&await self.registration.navigationPreload.enable()},limitCacheSize=(self.addEventListener("activate",function(a){a.waitUntil(enableNavigationPreload())}),self.addEventListener("install",function(a){a.waitUntil(addResourcesToCache(["./index.html","./JavaScript/Css.min.js","./JavaScript/PWA.min.js","./JavaScript/Firework.min.js","./JavaScript/Memory.min.js","./JavaScript/main.min.js","./Css/Firework.min.css","./Css/main.min.css","./fonts/TextMeOne-Regular.ttf","./config/emoji-categories.min.json","./config/emojis.min.json","./config/images.json","./media/frog512x512.png","./media/altogether-logo.png","./media/altogether-logo-inverted.png","./media/light_emoji.png","./favicon/site.webmanifest","./media/green_string.png","./favicon/favicon.ico","./favicon/favicon-32x32.png","./favicon/favicon-16x16.png","./favicon/android-chrome-192x192.png","./favicon/android-chrome-512x512.png","./favicon/maskable/maskable_icon.png","./favicon/maskable/maskable_icon_x48.png","./favicon/maskable/maskable_icon_x72.png","./favicon/maskable/maskable_icon_x96.png","./favicon/maskable/maskable_icon_x128.png","./favicon/maskable/maskable_icon_x192.png","./favicon/maskable/maskable_icon_x384.png","./favicon/maskable/maskable_icon_x512.png"]))}),self.addEventListener("fetch",function(e){0===e.request.url.indexOf("http")&&e.respondWith(caches.match(e.request).then(function(a){return a||fetch(e.request).then(function(n){cache.open(swName).then(function(a){return a.put(e.request.url,n.clone()),limitCacheSize(swName,200),n})})}).catch(function(){caches.match("/fallback")}))}),function(e,i){caches.open(e).then(function(n){n.keys().then(function(a){a.length>i&&n.delete(a[0]).then(limitCacheSize(e,i))})})});