workbox-expiration
Advanced tools
Comparing version 6.0.0 to 6.0.2
"use strict"; | ||
// @ts-ignore | ||
try { | ||
self['workbox:expiration:6.0.0-rc.0'] && _(); | ||
self['workbox:expiration:6.0.2'] && _(); | ||
} | ||
catch (e) { } |
@@ -6,3 +6,3 @@ this.workbox = this.workbox || {}; | ||
try { | ||
self['workbox:expiration:6.0.0-rc.0'] && _(); | ||
self['workbox:expiration:6.0.2'] && _(); | ||
} catch (e) {} | ||
@@ -9,0 +9,0 @@ |
@@ -1,2 +0,2 @@ | ||
this.workbox=this.workbox||{},this.workbox.expiration=function(t,s,e,i,a,n,h){"use strict";try{self["workbox:expiration:6.0.0-rc.0"]&&_()}catch(t){}const r="cache-entries",c=t=>{const s=new URL(t,location.href);return s.hash="",s.href};class o{constructor(t){this.t=t,this.i=new i.DBWrapper("workbox-expiration",1,{onupgradeneeded:t=>this.h(t)})}h(t){const s=t.target.result.createObjectStore(r,{keyPath:"id"});s.createIndex("cacheName","cacheName",{unique:!1}),s.createIndex("timestamp","timestamp",{unique:!1}),a.deleteDatabase(this.t)}async setTimestamp(t,s){const e={url:t=c(t),timestamp:s,cacheName:this.t,id:this.o(t)};await this.i.put(r,e)}async getTimestamp(t){return(await this.i.get(r,this.o(t))).timestamp}async expireEntries(t,s){const e=await this.i.transaction(r,"readwrite",((e,i)=>{const a=e.objectStore(r).index("timestamp").openCursor(null,"prev"),n=[];let h=0;a.onsuccess=()=>{const e=a.result;if(e){const i=e.value;i.cacheName===this.t&&(t&&i.timestamp<t||s&&h>=s?n.push(e.value):h++),e.continue()}else i(n)}})),i=[];for(const t of e)await this.i.delete(r,t.id),i.push(t.url);return i}o(t){return this.t+"|"+c(t)}}class u{constructor(t,s={}){this.u=!1,this.l=!1,this.m=s.maxEntries,this.p=s.maxAgeSeconds,this.k=s.matchOptions,this.t=t,this.D=new o(t)}async expireEntries(){if(this.u)return void(this.l=!0);this.u=!0;const t=this.p?Date.now()-1e3*this.p:0,e=await this.D.expireEntries(t,this.m),i=await self.caches.open(this.t);for(const t of e)await i.delete(t,this.k);this.u=!1,this.l&&(this.l=!1,s.dontWaitFor(this.expireEntries()))}async updateTimestamp(t){await this.D.setTimestamp(t,Date.now())}async isURLExpired(t){if(this.p){return await this.D.getTimestamp(t)<Date.now()-1e3*this.p}return!1}async delete(){this.l=!1,await this.D.expireEntries(1/0)}}return t.CacheExpiration=u,t.ExpirationPlugin=class{constructor(t={}){this.cachedResponseWillBeUsed=async({event:t,request:e,cacheName:i,cachedResponse:a})=>{if(!a)return null;const n=this.N(a),h=this.g(i);s.dontWaitFor(h.expireEntries());const r=h.updateTimestamp(e.url);if(t)try{t.waitUntil(r)}catch(t){}return n?a:null},this.cacheDidUpdate=async({cacheName:t,request:s})=>{const e=this.g(t);await e.updateTimestamp(s.url),await e.expireEntries()},this._=t,this.p=t.maxAgeSeconds,this.q=new Map,t.purgeOnQuotaError&&h.registerQuotaErrorCallback((()=>this.deleteCacheAndMetadata()))}g(t){if(t===n.cacheNames.getRuntimeName())throw new e.WorkboxError("expire-custom-caches-only");let s=this.q.get(t);return s||(s=new u(t,this._),this.q.set(t,s)),s}N(t){if(!this.p)return!0;const s=this.R(t);if(null===s)return!0;return s>=Date.now()-1e3*this.p}R(t){if(!t.headers.has("date"))return null;const s=t.headers.get("date"),e=new Date(s).getTime();return isNaN(e)?null:e}async deleteCacheAndMetadata(){for(const[t,s]of this.q)await self.caches.delete(t),await s.delete();this.q=new Map}},t}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core); | ||
this.workbox=this.workbox||{},this.workbox.expiration=function(t,s,e,i,a,n,h){"use strict";try{self["workbox:expiration:6.0.2"]&&_()}catch(t){}const r="cache-entries",c=t=>{const s=new URL(t,location.href);return s.hash="",s.href};class o{constructor(t){this.T=t,this.i=new i.DBWrapper("workbox-expiration",1,{onupgradeneeded:t=>this.M(t)})}M(t){const s=t.target.result.createObjectStore(r,{keyPath:"id"});s.createIndex("cacheName","cacheName",{unique:!1}),s.createIndex("timestamp","timestamp",{unique:!1}),a.deleteDatabase(this.T)}async setTimestamp(t,s){const e={url:t=c(t),timestamp:s,cacheName:this.T,id:this.F(t)};await this.i.put(r,e)}async getTimestamp(t){return(await this.i.get(r,this.F(t))).timestamp}async expireEntries(t,s){const e=await this.i.transaction(r,"readwrite",((e,i)=>{const a=e.objectStore(r).index("timestamp").openCursor(null,"prev"),n=[];let h=0;a.onsuccess=()=>{const e=a.result;if(e){const i=e.value;i.cacheName===this.T&&(t&&i.timestamp<t||s&&h>=s?n.push(e.value):h++),e.continue()}else i(n)}})),i=[];for(const t of e)await this.i.delete(r,t.id),i.push(t.url);return i}F(t){return this.T+"|"+c(t)}}class u{constructor(t,s={}){this.H=!1,this.I=!1,this.G=s.maxEntries,this.J=s.maxAgeSeconds,this.V=s.matchOptions,this.T=t,this.W=new o(t)}async expireEntries(){if(this.H)return void(this.I=!0);this.H=!0;const t=this.J?Date.now()-1e3*this.J:0,e=await this.W.expireEntries(t,this.G),i=await self.caches.open(this.T);for(const t of e)await i.delete(t,this.V);this.H=!1,this.I&&(this.I=!1,s.dontWaitFor(this.expireEntries()))}async updateTimestamp(t){await this.W.setTimestamp(t,Date.now())}async isURLExpired(t){if(this.J){return await this.W.getTimestamp(t)<Date.now()-1e3*this.J}return!1}async delete(){this.I=!1,await this.W.expireEntries(1/0)}}return t.CacheExpiration=u,t.ExpirationPlugin=class{constructor(t={}){this.cachedResponseWillBeUsed=async({event:t,request:e,cacheName:i,cachedResponse:a})=>{if(!a)return null;const n=this.X(a),h=this.Y(i);s.dontWaitFor(h.expireEntries());const r=h.updateTimestamp(e.url);if(t)try{t.waitUntil(r)}catch(t){}return n?a:null},this.cacheDidUpdate=async({cacheName:t,request:s})=>{const e=this.Y(t);await e.updateTimestamp(s.url),await e.expireEntries()},this.Z=t,this.J=t.maxAgeSeconds,this.$=new Map,t.purgeOnQuotaError&&h.registerQuotaErrorCallback((()=>this.deleteCacheAndMetadata()))}Y(t){if(t===n.cacheNames.getRuntimeName())throw new e.WorkboxError("expire-custom-caches-only");let s=this.$.get(t);return s||(s=new u(t,this.Z),this.$.set(t,s)),s}X(t){if(!this.J)return!0;const s=this.tt(t);if(null===s)return!0;return s>=Date.now()-1e3*this.J}tt(t){if(!t.headers.has("date"))return null;const s=t.headers.get("date"),e=new Date(s).getTime();return isNaN(e)?null:e}async deleteCacheAndMetadata(){for(const[t,s]of this.$)await self.caches.delete(t),await s.delete();this.$=new Map}},t}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core); | ||
//# sourceMappingURL=workbox-expiration.prod.js.map |
{ | ||
"name": "workbox-expiration", | ||
"version": "6.0.0", | ||
"version": "6.0.2", | ||
"license": "MIT", | ||
@@ -25,5 +25,5 @@ "author": "Google's Web DevRel Team", | ||
"dependencies": { | ||
"workbox-core": "^6.0.0" | ||
"workbox-core": "^6.0.2" | ||
}, | ||
"gitHead": "9cbed278b992717195406fe077933a578142f5ed" | ||
"gitHead": "025657cde5114bb301407d8e6bc546a21302c244" | ||
} |
// @ts-ignore | ||
try{self['workbox:expiration:6.0.0-rc.0']&&_()}catch(e){} | ||
try{self['workbox:expiration:6.0.2']&&_()}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
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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
226610
Updatedworkbox-core@^6.0.2