UNPKG

3.37 kBJavaScriptView Raw
1this.workbox=this.workbox||{},this.workbox.strategies=function(e,t,r){"use strict";try{self.workbox.v["workbox:strategies:3.0.1"]=1}catch(e){}class s{constructor(t={}){this.e=e.cacheNames.getRuntimeName(t.cacheName),this.t=t.plugins||[],this.r=t.fetchOptions||null}handle({event:e}){var r=this;return babelHelpers.asyncToGenerator(function*(){let s,n=yield t.cacheWrapper.match(r.e,e.request,null,r.t);if(!n)try{n=yield r.s(e)}catch(e){s=e}if(s)throw s;return n})()}s(e){var s=this;return babelHelpers.asyncToGenerator(function*(){const n=yield r.fetchWrapper.fetch(e.request,s.r,s.t),i=n.clone();return e.waitUntil(t.cacheWrapper.put(s.e,e.request,i,s.t)),n})()}}class n{constructor(t={}){this.e=e.cacheNames.getRuntimeName(t.cacheName),this.t=t.plugins||[]}handle({event:e}){var r=this;return babelHelpers.asyncToGenerator(function*(){return yield t.cacheWrapper.match(r.e,e.request,null,r.t)})()}}var i={cacheWillUpdate:({response:e})=>e.ok||0===e.status?e:null};class l{constructor(t={}){if(this.e=e.cacheNames.getRuntimeName(t.cacheName),t.plugins){let e=t.plugins.some(e=>!!e.cacheWillUpdate);this.t=e?t.plugins:[i,...t.plugins]}else this.t=[i];this.n=t.networkTimeoutSeconds,this.r=t.fetchOptions||null}handle({event:e}){var t=this;return babelHelpers.asyncToGenerator(function*(){const r=[],s=[];let n;if(t.n){const{id:i,promise:l}=t.i(e,r);n=i,s.push(l)}const i=t.l(n,e,r);s.push(i);let l=yield Promise.race(s);return l||(l=yield i),l})()}i(e,t){var r=this;let s;const n=new Promise(t=>{const n=(()=>{var s=babelHelpers.asyncToGenerator(function*(){t(yield r.o(e.request))});return function(){return s.apply(this,arguments)}})();s=setTimeout(n,1e3*this.n)});return{promise:n,id:s}}l(e,s,n){var i=this;return babelHelpers.asyncToGenerator(function*(){let n,l;try{l=yield r.fetchWrapper.fetch(s.request,i.r,i.t)}catch(e){n=e}if(e&&clearTimeout(e),n||!l)l=yield i.o(s.request);else{const e=l.clone();s.waitUntil(t.cacheWrapper.put(i.e,s.request,e,i.t))}return l})()}o(e){return t.cacheWrapper.match(this.e,e,null,this.t)}}class o{constructor(t={}){this.e=e.cacheNames.getRuntimeName(t.cacheName),this.t=t.plugins||[],this.r=t.fetchOptions||null}handle({event:e}){var t=this;return babelHelpers.asyncToGenerator(function*(){let s,n;try{n=yield r.fetchWrapper.fetch(e.request,t.r,t.t)}catch(e){s=e}if(s)throw s;return n})()}}class c{constructor(t={}){if(this.e=e.cacheNames.getRuntimeName(t.cacheName),this.t=t.plugins||[],t.plugins){let e=t.plugins.some(e=>!!e.cacheWillUpdate);this.t=e?t.plugins:[i,...t.plugins]}else this.t=[i];this.r=t.fetchOptions||null}handle({event:e}){var r=this;return babelHelpers.asyncToGenerator(function*(){const s=r.s(e);let n=yield t.cacheWrapper.match(r.e,e.request,null,r.t);return n?e.waitUntil(s):n=yield s,n})()}s(e){var s=this;return babelHelpers.asyncToGenerator(function*(){const n=yield r.fetchWrapper.fetch(e.request,s.r,s.t);return e.waitUntil(t.cacheWrapper.put(s.e,e.request,n.clone(),s.t)),n})()}}var h=Object.freeze({CacheFirst:s,CacheOnly:n,NetworkFirst:l,NetworkOnly:o,StaleWhileRevalidate:c});const u={cacheFirst:s,cacheOnly:n,networkFirst:l,networkOnly:o,staleWhileRevalidate:c},a={};Object.keys(u).forEach(e=>{a[e]=((t={})=>{return new(0,u[e])(Object.assign(t))})});return Object.assign(a,h)}(workbox.core._private,workbox.core._private,workbox.core._private);
2
3//# sourceMappingURL=workbox-strategies.prod.js.map