workbox-expiration
Advanced tools
Comparing version 5.0.0-rc.1 to 5.0.0-rc.2
"use strict"; | ||
// @ts-ignore | ||
try { | ||
self['workbox:expiration:5.0.0-rc.1'] && _(); | ||
self['workbox:expiration:5.0.0-rc.2'] && _(); | ||
} | ||
catch (e) { } |
@@ -6,3 +6,3 @@ this.workbox = this.workbox || {}; | ||
try { | ||
self['workbox:expiration:5.0.0-rc.1'] && _(); | ||
self['workbox:expiration:5.0.0-rc.2'] && _(); | ||
} catch (e) {} | ||
@@ -206,3 +206,3 @@ | ||
* | ||
* @memberof workbox.expiration | ||
* @memberof module:workbox-expiration | ||
*/ | ||
@@ -393,3 +393,3 @@ | ||
* | ||
* @memberof workbox.expiration | ||
* @memberof module:workbox-expiration | ||
*/ | ||
@@ -410,3 +410,3 @@ | ||
* A "lifecycle" callback that will be triggered automatically by the | ||
* `workbox.strategies` handlers when a `Response` is about to be returned | ||
* `workbox-strategies` handlers when a `Response` is about to be returned | ||
* from a [Cache](https://developer.mozilla.org/en-US/docs/Web/API/Cache) to | ||
@@ -464,3 +464,3 @@ * the handler. It allows the `Response` to be inspected for freshness and | ||
* A "lifecycle" callback that will be triggered automatically by the | ||
* `workbox.strategies` handlers when an entry is added to a cache. | ||
* `workbox-strategies` handlers when an entry is added to a cache. | ||
* | ||
@@ -467,0 +467,0 @@ * @param {Object} options |
@@ -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:5.0.0-rc.1"]&&_()}catch(t){}const r="workbox-expiration",c="cache-entries",o=t=>{const s=new URL(t,location.href);return s.hash="",s.href};class u{constructor(t){this.t=t,this.s=new i.DBWrapper(r,1,{onupgradeneeded:t=>this.i(t)})}i(t){const s=t.target.result.createObjectStore(c,{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=o(t),timestamp:s,cacheName:this.t,id:this.h(t)};await this.s.put(c,e)}async getTimestamp(t){return(await this.s.get(c,this.h(t))).timestamp}async expireEntries(t,s){const e=await this.s.transaction(c,"readwrite",(e,i)=>{const a=e.objectStore(c).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.s.delete(c,t.id),i.push(t.url);return i}h(t){return this.t+"|"+o(t)}}class w{constructor(t,s={}){this.o=!1,this.u=!1,this.l=s.maxEntries,this.m=s.maxAgeSeconds,this.t=t,this.p=new u(t)}async expireEntries(){if(this.o)return void(this.u=!0);this.o=!0;const t=this.m?Date.now()-1e3*this.m:0,e=await this.p.expireEntries(t,this.l),i=await self.caches.open(this.t);for(const t of e)await i.delete(t);this.o=!1,this.u&&(this.u=!1,s.dontWaitFor(this.expireEntries()))}async updateTimestamp(t){await this.p.setTimestamp(t,Date.now())}async isURLExpired(t){if(this.m){return await this.p.getTimestamp(t)<Date.now()-1e3*this.m}return!1}async delete(){this.u=!1,await this.p.expireEntries(1/0)}}return t.CacheExpiration=w,t.ExpirationPlugin=class{constructor(t={}){this.cachedResponseWillBeUsed=(async({event:t,request:e,cacheName:i,cachedResponse:a})=>{if(!a)return null;let n=this.k(a);const h=this.D(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.D(t);await e.updateTimestamp(s.url),await e.expireEntries()}),this.N=t,this.m=t.maxAgeSeconds,this.g=new Map,t.purgeOnQuotaError&&h.registerQuotaErrorCallback(()=>this.deleteCacheAndMetadata())}D(t){if(t===n.cacheNames.getRuntimeName())throw new e.WorkboxError("expire-custom-caches-only");let s=this.g.get(t);return s||(s=new w(t,this.N),this.g.set(t,s)),s}k(t){if(!this.m)return!0;const s=this._(t);return null===s||s>=Date.now()-1e3*this.m}_(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.g)await self.caches.delete(t),await s.delete();this.g=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:5.0.0-rc.2"]&&_()}catch(t){}const r="workbox-expiration",c="cache-entries",o=t=>{const s=new URL(t,location.href);return s.hash="",s.href};class u{constructor(t){this.t=t,this.s=new i.DBWrapper(r,1,{onupgradeneeded:t=>this.i(t)})}i(t){const s=t.target.result.createObjectStore(c,{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=o(t),timestamp:s,cacheName:this.t,id:this.h(t)};await this.s.put(c,e)}async getTimestamp(t){return(await this.s.get(c,this.h(t))).timestamp}async expireEntries(t,s){const e=await this.s.transaction(c,"readwrite",(e,i)=>{const a=e.objectStore(c).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.s.delete(c,t.id),i.push(t.url);return i}h(t){return this.t+"|"+o(t)}}class w{constructor(t,s={}){this.o=!1,this.u=!1,this.l=s.maxEntries,this.m=s.maxAgeSeconds,this.t=t,this.p=new u(t)}async expireEntries(){if(this.o)return void(this.u=!0);this.o=!0;const t=this.m?Date.now()-1e3*this.m:0,e=await this.p.expireEntries(t,this.l),i=await self.caches.open(this.t);for(const t of e)await i.delete(t);this.o=!1,this.u&&(this.u=!1,s.dontWaitFor(this.expireEntries()))}async updateTimestamp(t){await this.p.setTimestamp(t,Date.now())}async isURLExpired(t){if(this.m){return await this.p.getTimestamp(t)<Date.now()-1e3*this.m}return!1}async delete(){this.u=!1,await this.p.expireEntries(1/0)}}return t.CacheExpiration=w,t.ExpirationPlugin=class{constructor(t={}){this.cachedResponseWillBeUsed=(async({event:t,request:e,cacheName:i,cachedResponse:a})=>{if(!a)return null;let n=this.k(a);const h=this.D(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.D(t);await e.updateTimestamp(s.url),await e.expireEntries()}),this.N=t,this.m=t.maxAgeSeconds,this.g=new Map,t.purgeOnQuotaError&&h.registerQuotaErrorCallback(()=>this.deleteCacheAndMetadata())}D(t){if(t===n.cacheNames.getRuntimeName())throw new e.WorkboxError("expire-custom-caches-only");let s=this.g.get(t);return s||(s=new w(t,this.N),this.g.set(t,s)),s}k(t){if(!this.m)return!0;const s=this._(t);return null===s||s>=Date.now()-1e3*this.m}_(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.g)await self.caches.delete(t),await s.delete();this.g=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 |
@@ -11,3 +11,3 @@ import './_version.js'; | ||
* | ||
* @memberof workbox.expiration | ||
* @memberof module:workbox-expiration | ||
*/ | ||
@@ -14,0 +14,0 @@ declare class CacheExpiration { |
@@ -19,3 +19,3 @@ /* | ||
* | ||
* @memberof workbox.expiration | ||
* @memberof module:workbox-expiration | ||
*/ | ||
@@ -22,0 +22,0 @@ class CacheExpiration { |
@@ -19,3 +19,3 @@ import { WorkboxPlugin } from 'workbox-core/types.js'; | ||
* | ||
* @memberof workbox.expiration | ||
* @memberof module:workbox-expiration | ||
*/ | ||
@@ -52,3 +52,3 @@ declare class ExpirationPlugin implements WorkboxPlugin { | ||
* A "lifecycle" callback that will be triggered automatically by the | ||
* `workbox.strategies` handlers when a `Response` is about to be returned | ||
* `workbox-strategies` handlers when a `Response` is about to be returned | ||
* from a [Cache](https://developer.mozilla.org/en-US/docs/Web/API/Cache) to | ||
@@ -88,3 +88,3 @@ * the handler. It allows the `Response` to be inspected for freshness and | ||
* A "lifecycle" callback that will be triggered automatically by the | ||
* `workbox.strategies` handlers when an entry is added to a cache. | ||
* `workbox-strategies` handlers when an entry is added to a cache. | ||
* | ||
@@ -91,0 +91,0 @@ * @param {Object} options |
@@ -33,3 +33,3 @@ /* | ||
* | ||
* @memberof workbox.expiration | ||
* @memberof module:workbox-expiration | ||
*/ | ||
@@ -49,3 +49,3 @@ class ExpirationPlugin { | ||
* A "lifecycle" callback that will be triggered automatically by the | ||
* `workbox.strategies` handlers when a `Response` is about to be returned | ||
* `workbox-strategies` handlers when a `Response` is about to be returned | ||
* from a [Cache](https://developer.mozilla.org/en-US/docs/Web/API/Cache) to | ||
@@ -96,3 +96,3 @@ * the handler. It allows the `Response` to be inspected for freshness and | ||
* A "lifecycle" callback that will be triggered automatically by the | ||
* `workbox.strategies` handlers when an entry is added to a cache. | ||
* `workbox-strategies` handlers when an entry is added to a cache. | ||
* | ||
@@ -99,0 +99,0 @@ * @param {Object} options |
@@ -5,4 +5,4 @@ import { CacheExpiration } from './CacheExpiration.js'; | ||
/** | ||
* @namespace workbox.expiration | ||
* @module workbox-expiration | ||
*/ | ||
export { CacheExpiration, ExpirationPlugin, }; |
@@ -12,4 +12,4 @@ /* | ||
/** | ||
* @namespace workbox.expiration | ||
* @module workbox-expiration | ||
*/ | ||
export { CacheExpiration, ExpirationPlugin, }; |
{ | ||
"name": "workbox-expiration", | ||
"version": "5.0.0-rc.1", | ||
"version": "5.0.0-rc.2", | ||
"license": "MIT", | ||
@@ -30,5 +30,5 @@ "author": "Google's Web DevRel Team", | ||
"dependencies": { | ||
"workbox-core": "^5.0.0-rc.1" | ||
"workbox-core": "^5.0.0-rc.2" | ||
}, | ||
"gitHead": "f03f71e50507e13d82d4e0a875cc49ba4501aff3" | ||
"gitHead": "89904768b2210e59c830dd380cf88a06e1c26a2b" | ||
} |
// @ts-ignore | ||
try{self['workbox:expiration:5.0.0-rc.1']&&_()}catch(e){} | ||
try{self['workbox:expiration:5.0.0-rc.2']&&_()}catch(e){} |
@@ -29,3 +29,3 @@ /* | ||
* | ||
* @memberof workbox.expiration | ||
* @memberof module:workbox-expiration | ||
*/ | ||
@@ -32,0 +32,0 @@ class CacheExpiration { |
@@ -38,3 +38,3 @@ /* | ||
* | ||
* @memberof workbox.expiration | ||
* @memberof module:workbox-expiration | ||
*/ | ||
@@ -121,3 +121,3 @@ class ExpirationPlugin implements WorkboxPlugin { | ||
* A "lifecycle" callback that will be triggered automatically by the | ||
* `workbox.strategies` handlers when a `Response` is about to be returned | ||
* `workbox-strategies` handlers when a `Response` is about to be returned | ||
* from a [Cache](https://developer.mozilla.org/en-US/docs/Web/API/Cache) to | ||
@@ -231,3 +231,3 @@ * the handler. It allows the `Response` to be inspected for freshness and | ||
* A "lifecycle" callback that will be triggered automatically by the | ||
* `workbox.strategies` handlers when an entry is added to a cache. | ||
* `workbox-strategies` handlers when an entry is added to a cache. | ||
* | ||
@@ -234,0 +234,0 @@ * @param {Object} options |
@@ -15,3 +15,3 @@ /* | ||
/** | ||
* @namespace workbox.expiration | ||
* @module workbox-expiration | ||
*/ | ||
@@ -18,0 +18,0 @@ |
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
244681
Updatedworkbox-core@^5.0.0-rc.2