workbox-strategies
Advanced tools
Comparing version 3.0.0-beta.1 to 3.0.0-beta.2
@@ -6,3 +6,3 @@ this.workbox = this.workbox || {}; | ||
try { | ||
self.workbox.v['workbox:strategies:3.0.0-beta.1'] = 1; | ||
self.workbox.v['workbox:strategies:3.0.0-beta.2'] = 1; | ||
} catch (e) {} // eslint-disable-line | ||
@@ -79,2 +79,5 @@ | ||
* to use in conjunction with this caching strategy. | ||
* @param {Object} options.fetchOptions Values passed along to the | ||
* [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters) | ||
* of all fetch() requests made by this strategy. | ||
*/ | ||
@@ -84,2 +87,3 @@ constructor(options = {}) { | ||
this._plugins = options.plugins || []; | ||
this._fetchOptions = options.fetchOptions || null; | ||
} | ||
@@ -168,3 +172,3 @@ | ||
return babelHelpers.asyncToGenerator(function* () { | ||
const response = yield fetchWrapper_mjs.fetchWrapper.fetch(event.request, null, _this2._plugins); | ||
const response = yield fetchWrapper_mjs.fetchWrapper.fetch(event.request, _this2._fetchOptions, _this2._plugins); | ||
@@ -335,2 +339,5 @@ // Keep the service worker while we put the request to the cache | ||
* to use in conjunction with this caching strategy. | ||
* @param {Object} options.fetchOptions Values passed along to the | ||
* [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters) | ||
* of all fetch() requests made by this strategy. | ||
* @param {number} options.networkTimeoutSeconds If set, any network requests | ||
@@ -365,2 +372,4 @@ * that fail to respond within the timeout will fallback to the cache. | ||
} | ||
this._fetchOptions = options.fetchOptions || null; | ||
} | ||
@@ -478,3 +487,3 @@ | ||
try { | ||
response = yield fetchWrapper_mjs.fetchWrapper.fetch(event.request, _this3._plugins); | ||
response = yield fetchWrapper_mjs.fetchWrapper.fetch(event.request, _this3._fetchOptions, _this3._plugins); | ||
} catch (err) { | ||
@@ -564,2 +573,5 @@ error = err; | ||
* to use in conjunction with this caching strategy. | ||
* @param {Object} options.fetchOptions Values passed along to the | ||
* [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters) | ||
* of all fetch() requests made by this strategy. | ||
*/ | ||
@@ -569,2 +581,3 @@ constructor(options = {}) { | ||
this._plugins = options.plugins || []; | ||
this._fetchOptions = options.fetchOptions || null; | ||
} | ||
@@ -598,3 +611,3 @@ | ||
try { | ||
response = yield fetchWrapper_mjs.fetchWrapper.fetch(event.request, null, _this._plugins); | ||
response = yield fetchWrapper_mjs.fetchWrapper.fetch(event.request, _this._fetchOptions, _this._plugins); | ||
} catch (err) { | ||
@@ -670,2 +683,5 @@ error = err; | ||
* to use in conjunction with this caching strategy. | ||
* @param {Object} options.fetchOptions Values passed along to the | ||
* [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters) | ||
* of all fetch() requests made by this strategy. | ||
*/ | ||
@@ -683,2 +699,4 @@ constructor(options = {}) { | ||
} | ||
this._fetchOptions = options.fetchOptions || null; | ||
} | ||
@@ -749,3 +767,3 @@ | ||
return babelHelpers.asyncToGenerator(function* () { | ||
const response = yield fetchWrapper_mjs.fetchWrapper.fetch(event.request, null, _this2._plugins); | ||
const response = yield fetchWrapper_mjs.fetchWrapper.fetch(event.request, _this2._fetchOptions, _this2._plugins); | ||
@@ -801,3 +819,3 @@ event.waitUntil(cacheWrapper_mjs.cacheWrapper.put(_this2._cacheName, event.request, response.clone(), _this2._plugins)); | ||
* @function workbox.strategies.cacheFirst | ||
* @param {StrategyOptions} options | ||
* @param {workbox.strategies.StrategyOptions} options | ||
*/ | ||
@@ -807,3 +825,3 @@ | ||
* @function workbox.strategies.cacheOnly | ||
* @param {StrategyOptions} options | ||
* @param {workbox.strategies.StrategyOptions} options | ||
*/ | ||
@@ -813,3 +831,3 @@ | ||
* @function workbox.strategies.networkFirst | ||
* @param {StrategyOptions} options | ||
* @param {workbox.strategies.StrategyOptions} options | ||
*/ | ||
@@ -819,3 +837,3 @@ | ||
* @function workbox.strategies.networkOnly | ||
* @param {StrategyOptions} options | ||
* @param {workbox.strategies.StrategyOptions} options | ||
*/ | ||
@@ -825,3 +843,3 @@ | ||
* @function workbox.strategies.staleWhileRevalidate | ||
* @param {StrategyOptions} options | ||
* @param {workbox.strategies.StrategyOptions} options | ||
*/ | ||
@@ -828,0 +846,0 @@ |
@@ -1,3 +0,3 @@ | ||
this.workbox=this.workbox||{},this.workbox.strategies=function(e,t,r){"use strict";try{self.workbox.v["workbox:strategies:3.0.0-beta.1"]=1}catch(e){}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*(){let n,s=yield t.cacheWrapper.match(r.e,e.request,null,r.t);if(!s)try{s=yield r.r(e)}catch(e){n=e}if(n)throw n;return s})()}r(e){var n=this;return babelHelpers.asyncToGenerator(function*(){const s=yield r.fetchWrapper.fetch(e.request,null,n.t),l=s.clone();return e.waitUntil(t.cacheWrapper.put(n.e,e.request,l,n.t)),s})()}}class s{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 l={cacheWillUpdate:({response:e})=>e.ok||0===e.status?e:null};class i{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:[l,...t.plugins]}else this.t=[l];this.n=t.networkTimeoutSeconds}handle({event:e}){var t=this;return babelHelpers.asyncToGenerator(function*(){const r=[],n=[];let s;if(t.n){const{id:l,promise:i}=t.s(e,r);s=l,n.push(i)}const l=t.l(s,e,r);n.push(l);let i=yield Promise.race(n);return i||(i=yield l),i})()}s(e,t){var r=this;let n;const s=new Promise(t=>{const s=(()=>{var n=babelHelpers.asyncToGenerator(function*(){t(yield r.i(e.request))});return function(){return n.apply(this,arguments)}})();n=setTimeout(s,1e3*this.n)});return{promise:s,id:n}}l(e,n,s){var l=this;return babelHelpers.asyncToGenerator(function*(){let s,i;try{i=yield r.fetchWrapper.fetch(n.request,l.t)}catch(e){s=e}if(e&&clearTimeout(e),s||!i)i=yield l.i(n.request);else{const e=i.clone();n.waitUntil(t.cacheWrapper.put(l.e,n.request,e,l.t))}return i})()}i(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||[]}handle({event:e}){var t=this;return babelHelpers.asyncToGenerator(function*(){let n,s;try{s=yield r.fetchWrapper.fetch(e.request,null,t.t)}catch(e){n=e}if(n)throw n;return s})()}}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:[l,...t.plugins]}else this.t=[l]}handle({event:e}){var r=this;return babelHelpers.asyncToGenerator(function*(){const n=r.r(e);let s=yield t.cacheWrapper.match(r.e,e.request,null,r.t);return s?e.waitUntil(n):s=yield n,s})()}r(e){var n=this;return babelHelpers.asyncToGenerator(function*(){const s=yield r.fetchWrapper.fetch(e.request,null,n.t);return e.waitUntil(t.cacheWrapper.put(n.e,e.request,s.clone(),n.t)),s})()}}var u=Object.freeze({CacheFirst:n,CacheOnly:s,NetworkFirst:i,NetworkOnly:o,StaleWhileRevalidate:c});const a={cacheFirst:n,cacheOnly:s,networkFirst:i,networkOnly:o,staleWhileRevalidate:c},h={};Object.keys(a).forEach(e=>{h[e]=((t={})=>{return new(0,a[e])(Object.assign(t))})});return Object.assign(h,u)}(workbox.core._private,workbox.core._private,workbox.core._private); | ||
this.workbox=this.workbox||{},this.workbox.strategies=function(e,t,r){"use strict";try{self.workbox.v["workbox:strategies:3.0.0-beta.2"]=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); | ||
//# sourceMappingURL=workbox-strategies.prod.js.map |
{ | ||
"name": "workbox-strategies", | ||
"version": "3.0.0-beta.1", | ||
"version": "3.0.0-beta.2", | ||
"license": "Apache-2.0", | ||
@@ -30,4 +30,4 @@ "author": "Google's Web DevRel Team", | ||
"dependencies": { | ||
"workbox-core": "^3.0.0-beta.1" | ||
"workbox-core": "^3.0.0-beta.2" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100134
1659
Updatedworkbox-core@^3.0.0-beta.2