Repository navigation
Expand file tree
/
Copy pathsw.min.js
More file actions
1 lines (1 loc) · 2.84 KB
/
Copy pathsw.min.js
File metadata and controls
1 lines (1 loc) · 2.84 KB
1
!function o(i,c,a){function s(t,e){if(!c[t]){if(!i[t]){var r="function"==typeof require&&require;if(!e&&r)return r(t,!0);if(p)return p(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var u=c[t]={exports:{}};i[t][0].call(u.exports,function(e){return s(i[t][1][e]||e)},u,u.exports,o,i,c,a)}return c[t].exports}for(var p="function"==typeof require&&require,e=0;e<a.length;e++)s(a[e]);return s}({1:[function(e,t,r){t.exports={Server:"http://localhost:5897",StaticServer:"http://localhost:5897",StaticResourceVersion:"1543454226297",RuntimeMode:"dev",AxiosBaseURL:"/api",MockServer:"http://localhost:8888"}},{}],2:[function(e,t,r){"use strict";var n,u=(n=e("../pipe.json"))&&n.__esModule?n:{default:n};function a(e,t,r,n,u,o,i){try{var c=e[o](i),a=c.value}catch(e){return void r(e)}c.done?t(a):Promise.resolve(a).then(n,u)}var o=u.default.StaticResourceVersion,i=u.default.StaticServer||u.default.Server,c=u.default.Server;self.addEventListener("activate",function(e){e.waitUntil(caches.keys().then(function(e){return Promise.all(e.map(function(){var c,t=(c=regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,navigator.storage.estimate();case 2:if(r=e.sent,"pipe-html"!==t&&"pipe-image"!==t&&t!=="pipe-static-"+o)return e.abrupt("return",caches.delete(t));e.next=7;break;case 7:if(.8<r.usage/r.quota&&("pipe-html"===t||"pipe-image"===t))return console.log("clear ".concat(t," cache")),e.abrupt("return",caches.delete(t));e.next=10;break;case 10:case"end":return e.stop()}},e,this)}),function(){var e=this,i=arguments;return new Promise(function(t,r){var n=c.apply(e,i);function u(e){a(n,t,r,u,o,"next",e)}function o(e){a(n,t,r,u,o,"throw",e)}u(void 0)})});return function(e){return t.apply(this,arguments)}}()))}))}),self.addEventListener("fetch",function(r){0===r.request.headers.get("accept").indexOf("text/html")||"*/*"===r.request.headers.get("accept")&&-1===r.request.url.indexOf("/js/")&&!r.request.url.endsWith(".js")||0===r.request.headers.get("accept").indexOf("application/json")&&0===r.request.url.indexOf(c+"/api")?r.respondWith(fetch(r.request).then(function(t){return-1===r.request.url.indexOf(c)?t:caches.open("pipe-html").then(function(e){return"POST"!==r.request.method&&"DELETE"!==r.request.method&&"PUT"!==r.request.method&&e.put(r.request,t.clone()),t})}).catch(function(){return caches.match(r.request)})):r.respondWith(caches.match(r.request).then(function(e){return e||fetch(r.request).then(function(t){return-1<r.request.url.indexOf("https://img.hacpai.com/")?caches.open("pipe-image").then(function(e){return e.put(r.request,t.clone()),t}):-1<r.request.url.indexOf(i)?caches.open("pipe-static-"+o).then(function(e){return e.put(r.request,t.clone()),t}):t}).catch(function(){console.log("fetch ".concat(r.request.url," error"))})}))})},{"../pipe.json":1}]},{},[2]);