workbox-expiration
Advanced tools
Comparing version 5.0.0-beta.1 to 5.0.0-rc.0
@@ -0,5 +1,6 @@ | ||
"use strict"; | ||
// @ts-ignore | ||
try { | ||
self['workbox:expiration:5.0.0-beta.1'] && _(); | ||
self['workbox:expiration:5.0.0-rc.0'] && _(); | ||
} | ||
catch (e) { } |
this.workbox = this.workbox || {}; | ||
this.workbox.expiration = (function (exports, DBWrapper_js, deleteDatabase_js, WorkboxError_js, assert_js, logger_js, cacheNames_js, getFriendlyURL_js, registerQuotaErrorCallback_js) { | ||
this.workbox.expiration = (function (exports, assert_js, dontWaitFor_js, logger_js, WorkboxError_js, DBWrapper_js, deleteDatabase_js, cacheNames_js, getFriendlyURL_js, registerQuotaErrorCallback_js) { | ||
'use strict'; | ||
// @ts-ignore | ||
try { | ||
self['workbox:expiration:5.0.0-beta.1'] && _(); | ||
self['workbox:expiration:5.0.0-rc.0'] && _(); | ||
} catch (e) {} | ||
@@ -301,3 +300,3 @@ | ||
this._rerunRequested = false; | ||
this.expireEntries(); | ||
dontWaitFor_js.dontWaitFor(this.expireEntries()); | ||
} | ||
@@ -440,3 +439,3 @@ } | ||
cacheExpiration.expireEntries(); // Update the metadata for the request URL to the current timestamp, | ||
dontWaitFor_js.dontWaitFor(cacheExpiration.expireEntries()); // Update the metadata for the request URL to the current timestamp, | ||
// but don't `await` it as we don't want to block the response. | ||
@@ -653,3 +652,3 @@ | ||
}({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core)); | ||
}({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core)); | ||
//# sourceMappingURL=workbox-expiration.dev.js.map |
@@ -1,2 +0,2 @@ | ||
this.workbox=this.workbox||{},this.workbox.expiration=function(t,s,e,i,a,n){"use strict";try{self["workbox:expiration:5.0.0-beta.1"]&&_()}catch(t){}const h="workbox-expiration",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.s=new s.DBWrapper(h,1,{onupgradeneeded:t=>this.i(t)})}i(t){const s=t.target.result.createObjectStore(r,{keyPath:"id"});s.createIndex("cacheName","cacheName",{unique:!1}),s.createIndex("timestamp","timestamp",{unique:!1}),e.deleteDatabase(this.t)}async setTimestamp(t,s){const e={url:t=c(t),timestamp:s,cacheName:this.t,id:this.h(t)};await this.s.put(r,e)}async getTimestamp(t){return(await this.s.get(r,this.h(t))).timestamp}async expireEntries(t,s){const e=await this.s.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.s.delete(r,t.id),i.push(t.url);return i}h(t){return this.t+"|"+c(t)}}class u{constructor(t,s={}){this.o=!1,this.u=!1,this.l=s.maxEntries,this.m=s.maxAgeSeconds,this.t=t,this.p=new o(t)}async expireEntries(){if(this.o)return void(this.u=!0);this.o=!0;const t=this.m?Date.now()-1e3*this.m:0,s=await this.p.expireEntries(t,this.l),e=await caches.open(this.t);for(const t of s)await e.delete(t);this.o=!1,this.u&&(this.u=!1,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=u,t.ExpirationPlugin=class{constructor(t={}){this.cachedResponseWillBeUsed=(async({event:t,request:s,cacheName:e,cachedResponse:i})=>{if(!i)return null;let a=this.k(i);const n=this.D(e);n.expireEntries();const h=n.updateTimestamp(s.url);if(t)try{t.waitUntil(h)}catch(t){}return a?i: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&&n.registerQuotaErrorCallback(()=>this.deleteCacheAndMetadata())}D(t){if(t===a.cacheNames.getRuntimeName())throw new i.WorkboxError("expire-custom-caches-only");let s=this.g.get(t);return s||(s=new u(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 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); | ||
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.0"]&&_()}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 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 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 |
@@ -8,6 +8,7 @@ /* | ||
*/ | ||
import { CacheTimestampsModel } from './models/CacheTimestampsModel.js'; | ||
import { WorkboxError } from 'workbox-core/_private/WorkboxError.js'; | ||
import { assert } from 'workbox-core/_private/assert.js'; | ||
import { dontWaitFor } from 'workbox-core/_private/dontWaitFor.js'; | ||
import { logger } from 'workbox-core/_private/logger.js'; | ||
import { WorkboxError } from 'workbox-core/_private/WorkboxError.js'; | ||
import { CacheTimestampsModel } from './models/CacheTimestampsModel.js'; | ||
import './_version.js'; | ||
@@ -109,3 +110,3 @@ /** | ||
this._rerunRequested = false; | ||
this.expireEntries(); | ||
dontWaitFor(this.expireEntries()); | ||
} | ||
@@ -112,0 +113,0 @@ } |
@@ -10,6 +10,7 @@ /* | ||
import { cacheNames } from 'workbox-core/_private/cacheNames.js'; | ||
import { dontWaitFor } from 'workbox-core/_private/dontWaitFor.js'; | ||
import { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js'; | ||
import { logger } from 'workbox-core/_private/logger.js'; | ||
import { registerQuotaErrorCallback } from 'workbox-core/registerQuotaErrorCallback.js'; | ||
import { WorkboxError } from 'workbox-core/_private/WorkboxError.js'; | ||
import { registerQuotaErrorCallback } from 'workbox-core/registerQuotaErrorCallback.js'; | ||
import { CacheExpiration } from './CacheExpiration.js'; | ||
@@ -71,3 +72,3 @@ import './_version.js'; | ||
const cacheExpiration = this._getCacheExpiration(cacheName); | ||
cacheExpiration.expireEntries(); | ||
dontWaitFor(cacheExpiration.expireEntries()); | ||
// Update the metadata for the request URL to the current timestamp, | ||
@@ -74,0 +75,0 @@ // but don't `await` it as we don't want to block the response. |
{ | ||
"name": "workbox-expiration", | ||
"version": "5.0.0-beta.1", | ||
"version": "5.0.0-rc.0", | ||
"license": "MIT", | ||
@@ -30,5 +30,5 @@ "author": "Google's Web DevRel Team", | ||
"dependencies": { | ||
"workbox-core": "^5.0.0-beta.1" | ||
"workbox-core": "^5.0.0-rc.0" | ||
}, | ||
"gitHead": "01a9e9be8291f0a592891c8e2eb8d2dd09b93caf" | ||
"gitHead": "94542f92ceaec96ef59a09bda3aee1677ea5512b" | ||
} |
// @ts-ignore | ||
try{self['workbox:expiration:5.0.0-beta.1']&&_()}catch(e){} | ||
try{self['workbox:expiration:5.0.0-rc.0']&&_()}catch(e){} |
@@ -9,7 +9,9 @@ /* | ||
import {CacheTimestampsModel} from './models/CacheTimestampsModel.js'; | ||
import {WorkboxError} from 'workbox-core/_private/WorkboxError.js'; | ||
import {assert} from 'workbox-core/_private/assert.js'; | ||
import {dontWaitFor} from 'workbox-core/_private/dontWaitFor.js'; | ||
import {logger} from 'workbox-core/_private/logger.js'; | ||
import {WorkboxError} from 'workbox-core/_private/WorkboxError.js'; | ||
import {CacheTimestampsModel} from './models/CacheTimestampsModel.js'; | ||
import './_version.js'; | ||
@@ -136,3 +138,3 @@ | ||
this._rerunRequested = false; | ||
this.expireEntries(); | ||
dontWaitFor(this.expireEntries()); | ||
} | ||
@@ -139,0 +141,0 @@ } |
@@ -11,8 +11,11 @@ /* | ||
import {cacheNames} from 'workbox-core/_private/cacheNames.js'; | ||
import {dontWaitFor} from 'workbox-core/_private/dontWaitFor.js'; | ||
import {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.js'; | ||
import {logger} from 'workbox-core/_private/logger.js'; | ||
import {registerQuotaErrorCallback} from 'workbox-core/registerQuotaErrorCallback.js'; | ||
import {WorkboxError} from 'workbox-core/_private/WorkboxError.js'; | ||
import {registerQuotaErrorCallback} from 'workbox-core/registerQuotaErrorCallback.js'; | ||
import {WorkboxPlugin} from 'workbox-core/types.js'; | ||
import {CacheExpiration} from './CacheExpiration.js'; | ||
import './_version.js'; | ||
@@ -148,3 +151,3 @@ | ||
const cacheExpiration = this._getCacheExpiration(cacheName); | ||
cacheExpiration.expireEntries(); | ||
dontWaitFor(cacheExpiration.expireEntries()); | ||
@@ -151,0 +154,0 @@ // Update the metadata for the request URL to the current timestamp, |
@@ -101,3 +101,3 @@ /* | ||
await this._db.put(OBJECT_STORE_NAME, entry); | ||
await this._db.put!(OBJECT_STORE_NAME, entry); | ||
} | ||
@@ -115,3 +115,3 @@ | ||
const entry: CacheTimestampsModelEntry = | ||
await this._db.get(OBJECT_STORE_NAME, this._getId(url)); | ||
await this._db.get!(OBJECT_STORE_NAME, this._getId(url)); | ||
@@ -178,3 +178,3 @@ return entry.timestamp; | ||
for (const entry of entriesToDelete) { | ||
await this._db.delete(OBJECT_STORE_NAME, entry.id); | ||
await this._db.delete!(OBJECT_STORE_NAME, entry.id); | ||
urlsDeleted.push(entry.url); | ||
@@ -181,0 +181,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
Mixed license
License(Experimental) Package contains multiple licenses.
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 4 instances 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
269652
2047
5
80
Updatedworkbox-core@^5.0.0-rc.0