Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

workbox-strategies

Package Overview
Dependencies
Maintainers
4
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

workbox-strategies - npm Package Compare versions

Comparing version 6.0.0-alpha.0 to 6.0.0-alpha.1

2

_version.js
"use strict";
// @ts-ignore
try {
self['workbox:strategies:5.1.3'] && _();
self['workbox:strategies:6.0.0-alpha.0'] && _();
}
catch (e) { }

@@ -24,3 +24,3 @@ this.workbox = this.workbox || {};

try {
self['workbox:strategies:5.1.3'] && _();
self['workbox:strategies:6.0.0-alpha.0'] && _();
} catch (e) {}

@@ -27,0 +27,0 @@

@@ -1,2 +0,2 @@

this.workbox=this.workbox||{},this.workbox.strategies=function(t,e,s,r,a,i,n,o){"use strict";function c(){return(c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t}).apply(this,arguments)}try{self["workbox:strategies:5.1.3"]&&_()}catch(t){}function h(t){return"string"==typeof t?new Request(t):t}class l{constructor(t,e){Object.assign(this,e),this.event=e.event,this.t=t,this.s=new i.Deferred,this.i=[],this.o=[...t.plugins],this.h=new Map;for(const t of this.o)this.h.set(t,{});this.event.waitUntil(this.s.promise)}fetch(t){return this.waitUntil(this.l(t))}async fetchAndCachePut(t){const e=await this.fetch(t),s=e.clone();return this.waitUntil(this.cachePut(t,s)),e}cacheMatch(t){return this.waitUntil(this.u(t))}async cachePut(t,e){const r=h(t);await o.timeout(0);const i=await this.p(r,"write");if(!e)throw new s.WorkboxError("cache-put-with-no-response",{url:a.getFriendlyURL(i.url)});const c=await this.v(e);if(!c)return;const{cacheName:l}=this.t,u=await self.caches.open(l),w=this.hasCallback("cacheDidUpdate")?await this.cacheMatch(r):null;try{await u.put(i,c)}catch(t){throw"QuotaExceededError"===t.name&&await n.executeQuotaErrorCallbacks(),t}await this.runCallbacks("cacheDidUpdate",{cacheName:l,oldResponse:w,newResponse:c,request:i,event:this.event})}hasCallback(t){for(const e of this.t.plugins)if(t in e)return!0;return!1}async runCallbacks(t,e){for(const s of this.iterateCallbacks(t))await s(e)}*iterateCallbacks(t){for(const e of this.t.plugins)if("function"==typeof e[t]){const s=this.h.get(e),r=r=>{const a=c({},r,{state:s});return e[t](a)};yield r}}async l(t){const{event:e}=this;let r=h(t);if("navigate"===r.mode&&e instanceof FetchEvent&&e.preloadResponse){const t=await e.preloadResponse;if(t)return t}const a=this.hasCallback("fetchDidFail")?r.clone():null;try{for(const t of this.iterateCallbacks("requestWillFetch"))r=await t({request:r.clone(),event:e})}catch(t){throw new s.WorkboxError("plugin-error-request-will-fetch",{thrownError:t})}const i=r.clone();try{let t;t=await fetch(r,"navigate"===r.mode?void 0:this.t.fetchOptions);for(const s of this.iterateCallbacks("fetchDidSucceed"))t=await s({event:e,request:i,response:t});return t}catch(t){throw a&&await this.runCallbacks("fetchDidFail",{error:t,event:e,originalRequest:a.clone(),request:i.clone()}),t}}waitUntil(t){return this.i.push(t),t}async doneWaiting(){let t;for(;t=this.i.shift();)await t}destroy(){this.s.resolve()}async u(t){const e=h(t);let s;const{cacheName:r,matchOptions:a}=this.t,i=await this.p(e,"read");s=await caches.match(i,c({},a,{},{cacheName:r}));for(const t of this.iterateCallbacks("cachedResponseWillBeUsed"))s=await t({cacheName:r,matchOptions:a,cachedResponse:s,request:i,event:this.event})||void 0;return s}async p(t,e){let s=t;for(const t of this.iterateCallbacks("cacheKeyWillBeUsed"))s=h(await t({mode:e,request:s,event:this.event,params:this.params}));return s}async v(t){let e=t,s=!1;for(const t of this.iterateCallbacks("cacheWillUpdate"))if(e=await t({request:this.request,response:e,event:this.event})||void 0,s=!0,!e)break;return s||e&&200!==e.status&&(e=void 0),e}}class u{constructor(t={}){this.cacheName=r.cacheNames.getRuntimeName(t.cacheName),this.plugins=t.plugins||[],this.fetchOptions=t.fetchOptions,this.matchOptions=t.matchOptions}handle(t){const[e]=this.handleAll(t);return e}handleAll(t){t instanceof FetchEvent&&(t={event:t,request:t.request});const e=t.event,s="string"==typeof t.request?new Request(t.request):t.request,r="params"in t?t.params:void 0,a=new l(this,{event:e,request:s,params:r}),i=this.m(a,s,e);return[i,this.q(i,a,s,e)]}async m(t,e,r){await t.runCallbacks("handlerWillStart",{event:r,request:e});let a=void 0;try{if(a=await this.g(e,t),!a||"error"===a.type)throw new s.WorkboxError("no-response",{url:e.url})}catch(s){for(const i of t.iterateCallbacks("handlerDidError"))if(a=await i({error:s,event:r,request:e}),a)break;if(!a)throw s}for(const s of t.iterateCallbacks("handlerWillRespond"))a=await s({event:r,request:e,response:a});return a}async q(t,e,s,r){let a,i;try{a=await t}catch(i){}try{await e.runCallbacks("handlerDidRespond",{event:r,request:s,response:a}),await e.doneWaiting()}catch(t){i=t}if(await e.runCallbacks("handlerDidComplete",{event:r,request:s,response:a,error:i}),e.destroy(),i)throw i}}const w={cacheWillUpdate:async({response:t})=>200===t.status||0===t.status?t:null};return t.CacheFirst=class extends u{async g(t,e){let r,a=await e.cacheMatch(t);if(!a)try{a=await e.fetchAndCachePut(t)}catch(t){r=t}if(!a)throw new s.WorkboxError("no-response",{url:t.url,error:r});return a}},t.CacheOnly=class extends u{async g(t,e){const r=await e.cacheMatch(t);if(!r)throw new s.WorkboxError("no-response",{url:t.url});return r}},t.NetworkFirst=class extends u{constructor(t={}){super(t),this.plugins.some(t=>"cacheWillUpdate"in t)||this.plugins.unshift(w),this._=t.networkTimeoutSeconds||0}async g(t,e){const r=[],a=[];let i;if(this._){const{id:s,promise:n}=this.k({request:t,logs:r,handler:e});i=s,a.push(n)}const n=this.R({timeoutId:i,request:t,logs:r,handler:e});a.push(n);for(const t of a)e.waitUntil(t);let o=await Promise.race(a);if(o||(o=await n),!o)throw new s.WorkboxError("no-response",{url:t.url});return o}k({request:t,logs:e,handler:s}){let r;return{promise:new Promise(e=>{r=setTimeout(async()=>{e(await s.cacheMatch(t))},1e3*this._)}),id:r}}async R({timeoutId:t,request:e,logs:s,handler:r}){let a,i;try{i=await r.fetchAndCachePut(e)}catch(t){a=t}return t&&clearTimeout(t),!a&&i||(i=await r.cacheMatch(e)),i}},t.NetworkOnly=class extends u{async g(t,e){let r,a;try{a=await e.fetch(t)}catch(t){r=t}if(!a)throw new s.WorkboxError("no-response",{url:t.url,error:r});return a}},t.StaleWhileRevalidate=class extends u{constructor(t){super(t),this.plugins.some(t=>"cacheWillUpdate"in t)||this.plugins.unshift(w)}async g(t,e){const r=e.fetchAndCachePut(t).catch(()=>{});let a,i=await e.cacheMatch(t);if(i);else try{i=await r}catch(t){a=t}if(!i)throw new s.WorkboxError("no-response",{url:t.url,error:a});return i}},t.Strategy=u,t.StrategyHandler=l,t}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private);
this.workbox=this.workbox||{},this.workbox.strategies=function(t,e,s,r,a,i,n,o){"use strict";function c(){return(c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t}).apply(this,arguments)}try{self["workbox:strategies:6.0.0-alpha.0"]&&_()}catch(t){}function h(t){return"string"==typeof t?new Request(t):t}class l{constructor(t,e){Object.assign(this,e),this.event=e.event,this.t=t,this.s=new i.Deferred,this.i=[],this.o=[...t.plugins],this.h=new Map;for(const t of this.o)this.h.set(t,{});this.event.waitUntil(this.s.promise)}fetch(t){return this.waitUntil(this.l(t))}async fetchAndCachePut(t){const e=await this.fetch(t),s=e.clone();return this.waitUntil(this.cachePut(t,s)),e}cacheMatch(t){return this.waitUntil(this.u(t))}async cachePut(t,e){const r=h(t);await o.timeout(0);const i=await this.p(r,"write");if(!e)throw new s.WorkboxError("cache-put-with-no-response",{url:a.getFriendlyURL(i.url)});const c=await this.v(e);if(!c)return;const{cacheName:l}=this.t,u=await self.caches.open(l),w=this.hasCallback("cacheDidUpdate")?await this.cacheMatch(r):null;try{await u.put(i,c)}catch(t){throw"QuotaExceededError"===t.name&&await n.executeQuotaErrorCallbacks(),t}await this.runCallbacks("cacheDidUpdate",{cacheName:l,oldResponse:w,newResponse:c,request:i,event:this.event})}hasCallback(t){for(const e of this.t.plugins)if(t in e)return!0;return!1}async runCallbacks(t,e){for(const s of this.iterateCallbacks(t))await s(e)}*iterateCallbacks(t){for(const e of this.t.plugins)if("function"==typeof e[t]){const s=this.h.get(e),r=r=>{const a=c({},r,{state:s});return e[t](a)};yield r}}async l(t){const{event:e}=this;let r=h(t);if("navigate"===r.mode&&e instanceof FetchEvent&&e.preloadResponse){const t=await e.preloadResponse;if(t)return t}const a=this.hasCallback("fetchDidFail")?r.clone():null;try{for(const t of this.iterateCallbacks("requestWillFetch"))r=await t({request:r.clone(),event:e})}catch(t){throw new s.WorkboxError("plugin-error-request-will-fetch",{thrownError:t})}const i=r.clone();try{let t;t=await fetch(r,"navigate"===r.mode?void 0:this.t.fetchOptions);for(const s of this.iterateCallbacks("fetchDidSucceed"))t=await s({event:e,request:i,response:t});return t}catch(t){throw a&&await this.runCallbacks("fetchDidFail",{error:t,event:e,originalRequest:a.clone(),request:i.clone()}),t}}waitUntil(t){return this.i.push(t),t}async doneWaiting(){let t;for(;t=this.i.shift();)await t}destroy(){this.s.resolve()}async u(t){const e=h(t);let s;const{cacheName:r,matchOptions:a}=this.t,i=await this.p(e,"read");s=await caches.match(i,c({},a,{},{cacheName:r}));for(const t of this.iterateCallbacks("cachedResponseWillBeUsed"))s=await t({cacheName:r,matchOptions:a,cachedResponse:s,request:i,event:this.event})||void 0;return s}async p(t,e){let s=t;for(const t of this.iterateCallbacks("cacheKeyWillBeUsed"))s=h(await t({mode:e,request:s,event:this.event,params:this.params}));return s}async v(t){let e=t,s=!1;for(const t of this.iterateCallbacks("cacheWillUpdate"))if(e=await t({request:this.request,response:e,event:this.event})||void 0,s=!0,!e)break;return s||e&&200!==e.status&&(e=void 0),e}}class u{constructor(t={}){this.cacheName=r.cacheNames.getRuntimeName(t.cacheName),this.plugins=t.plugins||[],this.fetchOptions=t.fetchOptions,this.matchOptions=t.matchOptions}handle(t){const[e]=this.handleAll(t);return e}handleAll(t){t instanceof FetchEvent&&(t={event:t,request:t.request});const e=t.event,s="string"==typeof t.request?new Request(t.request):t.request,r="params"in t?t.params:void 0,a=new l(this,{event:e,request:s,params:r}),i=this.m(a,s,e);return[i,this.q(i,a,s,e)]}async m(t,e,r){await t.runCallbacks("handlerWillStart",{event:r,request:e});let a=void 0;try{if(a=await this.g(e,t),!a||"error"===a.type)throw new s.WorkboxError("no-response",{url:e.url})}catch(s){for(const i of t.iterateCallbacks("handlerDidError"))if(a=await i({error:s,event:r,request:e}),a)break;if(!a)throw s}for(const s of t.iterateCallbacks("handlerWillRespond"))a=await s({event:r,request:e,response:a});return a}async q(t,e,s,r){let a,i;try{a=await t}catch(i){}try{await e.runCallbacks("handlerDidRespond",{event:r,request:s,response:a}),await e.doneWaiting()}catch(t){i=t}if(await e.runCallbacks("handlerDidComplete",{event:r,request:s,response:a,error:i}),e.destroy(),i)throw i}}const w={cacheWillUpdate:async({response:t})=>200===t.status||0===t.status?t:null};return t.CacheFirst=class extends u{async g(t,e){let r,a=await e.cacheMatch(t);if(!a)try{a=await e.fetchAndCachePut(t)}catch(t){r=t}if(!a)throw new s.WorkboxError("no-response",{url:t.url,error:r});return a}},t.CacheOnly=class extends u{async g(t,e){const r=await e.cacheMatch(t);if(!r)throw new s.WorkboxError("no-response",{url:t.url});return r}},t.NetworkFirst=class extends u{constructor(t={}){super(t),this.plugins.some(t=>"cacheWillUpdate"in t)||this.plugins.unshift(w),this._=t.networkTimeoutSeconds||0}async g(t,e){const r=[],a=[];let i;if(this._){const{id:s,promise:n}=this.k({request:t,logs:r,handler:e});i=s,a.push(n)}const n=this.R({timeoutId:i,request:t,logs:r,handler:e});a.push(n);for(const t of a)e.waitUntil(t);let o=await Promise.race(a);if(o||(o=await n),!o)throw new s.WorkboxError("no-response",{url:t.url});return o}k({request:t,logs:e,handler:s}){let r;return{promise:new Promise(e=>{r=setTimeout(async()=>{e(await s.cacheMatch(t))},1e3*this._)}),id:r}}async R({timeoutId:t,request:e,logs:s,handler:r}){let a,i;try{i=await r.fetchAndCachePut(e)}catch(t){a=t}return t&&clearTimeout(t),!a&&i||(i=await r.cacheMatch(e)),i}},t.NetworkOnly=class extends u{async g(t,e){let r,a;try{a=await e.fetch(t)}catch(t){r=t}if(!a)throw new s.WorkboxError("no-response",{url:t.url,error:r});return a}},t.StaleWhileRevalidate=class extends u{constructor(t){super(t),this.plugins.some(t=>"cacheWillUpdate"in t)||this.plugins.unshift(w)}async g(t,e){const r=e.fetchAndCachePut(t).catch(()=>{});let a,i=await e.cacheMatch(t);if(i);else try{i=await r}catch(t){a=t}if(!i)throw new s.WorkboxError("no-response",{url:t.url,error:a});return i}},t.Strategy=u,t.StrategyHandler=l,t}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private);
//# sourceMappingURL=workbox-strategies.prod.js.map
{
"name": "workbox-strategies",
"version": "6.0.0-alpha.0",
"version": "6.0.0-alpha.1",
"license": "MIT",

@@ -26,5 +26,5 @@ "author": "Google's Web DevRel Team",

"dependencies": {
"workbox-core": "^6.0.0-alpha.0"
"workbox-core": "^6.0.0-alpha.1"
},
"gitHead": "3dfe1f4c5ed450bc4b7420321f1a113ff4382d1b"
"gitHead": "dd408f0c17a50fb68cac485133123775c3d4dfc2"
}
// @ts-ignore
try{self['workbox:strategies:5.1.3']&&_()}catch(e){}
try{self['workbox:strategies:6.0.0-alpha.0']&&_()}catch(e){}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc