-
Notifications
You must be signed in to change notification settings - Fork 0
/
service-worker.js
1 lines (1 loc) · 3.92 KB
/
service-worker.js
1
"use strict";function setOfCachedUrls(e){return e.keys().then(function(e){return e.map(function(e){return e.url})}).then(function(e){return new Set(e)})}var precacheConfig=[["/index.html","4959e35fd1c826e62e514941e6afccc9"],["/static/css/main.857dd64a.css","857dd64ad1150b8c1db7b28ab099f94c"],["/static/css/main.857dd64a.css.gz","2e277efaa73258eaedfbd0706805a4e6"],["/static/js/main.5ad8afad.js","15ec566c56e1fc85917564f7c0793f25"],["/static/js/main.5ad8afad.js.gz","9da289a41fec89d3cea645bb00b0d1a2"],["/static/js/manifest.9185a40f.js","6878a8fbe72bde4a3f8ecf5b16523972"],["/static/js/vendor.e84c9ae1.js","b7ea1a20d7a94d05caa9527b3e3e083f"],["/static/js/vendor.e84c9ae1.js.gz","362b1646f4e2b6522acae6fc68446798"],["/static/media/arrow.c09cc582.svg","c09cc5824dc3588a7e1bd63c6fd71078"],["/static/media/move.7d5eff42.mp3","7d5eff42a3e4c04c0cb2addc72a79d88"],["/static/media/popup.4af4d408.mp3","4af4d408da57cd7e27d7293569b8a2be"],["/static/media/reset.dcb49b60.svg","dcb49b60f1fd629fa4269db1102c5e76"],["/static/media/speaker-off.f3229a5e.svg","f3229a5e7f0b002eec67386c2e2664e4"],["/static/media/speaker-on.4eeb33a4.svg","4eeb33a4e2342aae68b06ed7a13fd15b"],["/static/media/undo.a4228579.svg","a42285790f72e639af925279dc5f899c"]],cacheName="sw-precache-v3-sw-precache-webpack-plugin-"+(self.registration?self.registration.scope:""),ignoreUrlParametersMatching=[/^utm_/],addDirectoryIndex=function(e,t){var a=new URL(e);return"/"===a.pathname.slice(-1)&&(a.pathname+=t),a.toString()},cleanResponse=function(e){return e.redirected?("body"in e?Promise.resolve(e.body):e.blob()).then(function(t){return new Response(t,{headers:e.headers,status:e.status,statusText:e.statusText})}):Promise.resolve(e)},createCacheKey=function(e,t,a,n){var r=new URL(e);return n&&r.pathname.match(n)||(r.search+=(r.search?"&":"")+encodeURIComponent(t)+"="+encodeURIComponent(a)),r.toString()},isPathWhitelisted=function(e,t){if(0===e.length)return!0;var a=new URL(t).pathname;return e.some(function(e){return a.match(e)})},stripIgnoredUrlParameters=function(e,t){var a=new URL(e);return a.hash="",a.search=a.search.slice(1).split("&").map(function(e){return e.split("=")}).filter(function(e){return t.every(function(t){return!t.test(e[0])})}).map(function(e){return e.join("=")}).join("&"),a.toString()},hashParamName="_sw-precache",urlsToCacheKeys=new Map(precacheConfig.map(function(e){var t=e[0],a=e[1],n=new URL(t,self.location),r=createCacheKey(n,hashParamName,a,/\.\w{8}\./);return[n.toString(),r]}));self.addEventListener("install",function(e){e.waitUntil(caches.open(cacheName).then(function(e){return setOfCachedUrls(e).then(function(t){return Promise.all(Array.from(urlsToCacheKeys.values()).map(function(a){if(!t.has(a)){var n=new Request(a,{credentials:"same-origin"});return fetch(n).then(function(t){if(!t.ok)throw new Error("Request for "+a+" returned a response with status "+t.status);return cleanResponse(t).then(function(t){return e.put(a,t)})})}}))})}).then(function(){return self.skipWaiting()}))}),self.addEventListener("activate",function(e){var t=new Set(urlsToCacheKeys.values());e.waitUntil(caches.open(cacheName).then(function(e){return e.keys().then(function(a){return Promise.all(a.map(function(a){if(!t.has(a.url))return e.delete(a)}))})}).then(function(){return self.clients.claim()}))}),self.addEventListener("fetch",function(e){if("GET"===e.request.method){var t,a=stripIgnoredUrlParameters(e.request.url,ignoreUrlParametersMatching);(t=urlsToCacheKeys.has(a))||(a=addDirectoryIndex(a,"index.html"),t=urlsToCacheKeys.has(a));!t&&"navigate"===e.request.mode&&isPathWhitelisted(["^(?!\\/__).*"],e.request.url)&&(a=new URL("/index.html",self.location).toString(),t=urlsToCacheKeys.has(a)),t&&e.respondWith(caches.open(cacheName).then(function(e){return e.match(urlsToCacheKeys.get(a)).then(function(e){if(e)return e;throw Error("The cached response that was expected is missing.")})}).catch(function(t){return console.warn('Couldn\'t serve response for "%s" from cache: %O',e.request.url,t),fetch(e.request)}))}});