UNPKG

2.94 kBJavaScriptView Raw
1parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"AaGI":[function(require,module,exports) {
2var e="cache-v4",t=["./","./index.html","./manifest.webmanifest"];self.addEventListener("install",n=>{console.info("Event: Install"),n.waitUntil(caches.open(e).then(e=>e.addAll(t).then(()=>(console.info("All files are cached"),self.skipWaiting())).catch(e=>{console.error("Failed to cache",e)})))}),self.addEventListener("fetch",t=>{console.info("Event: Fetch");var n=t.request;t.respondWith(caches.match(n).then(t=>t||fetch(n).then(t=>{var o=t.clone();return caches.open(e).then(e=>{e.put(n,o).catch(e=>{console.warn(n.url+": "+e.message)})}),t})))}),self.addEventListener("activate",t=>{console.info("Event: Activate"),t.waitUntil(caches.keys().then(t=>Promise.all(t.map(t=>{if(t!==e)return caches.delete(t)}))).then(function(){return console.info("Old caches are cleared!"),self.clients.claim()}))}),self.addEventListener("push",e=>{console.info("Event: Push");e.waitUntil(self.registration.showNotification("Push notification demo",{body:"click to return to application",tag:"demo",icon:"./images/icons/apple-touch-icon.png",badge:"./images/icons/apple-touch-icon.png",actions:[{action:"yes",title:"I ♥ this app!"},{action:"no",title:"I don't like this app"}]}))}),self.addEventListener("sync",e=>{console.info("Event: Sync"),"github"!==e.tag&&"test-tag-from-devtools"!==e.tag||e.waitUntil(self.clients.matchAll().then(e=>e.map(e=>e.postMessage("online"))).catch(e=>{console.error(e)}))}),self.addEventListener("notificationclick",e=>{"yes"===e.action?console.log("I ♥ this app!"):"no"===e.action&&console.warn("I don't like this app"),e.notification.close(),e.waitUntil(clients.matchAll({type:"window"}).then(e=>{for(var t=0;t<e.length;t++){var n=e[t];if("https://demopwa.in/"===n.url&&"focus"in n)return n.focus()}if(e.openWindow)return e.openWindow("/")}).catch(e=>{console.error(e)}))});
3},{}]},{},["AaGI"], null)
4//# sourceMappingURL=/service-worker.js.map
\No newline at end of file