workbox-precaching
Advanced tools
Comparing version 5.0.0-rc.0 to 5.0.0-rc.1
"use strict"; | ||
// @ts-ignore | ||
try { | ||
self['workbox:precaching:5.0.0-rc.0'] && _(); | ||
self['workbox:precaching:5.0.0-rc.1'] && _(); | ||
} | ||
catch (e) { } |
@@ -6,3 +6,3 @@ this.workbox = this.workbox || {}; | ||
try { | ||
self['workbox:precaching:5.0.0-rc.0'] && _(); | ||
self['workbox:precaching:5.0.0-rc.1'] && _(); | ||
} catch (e) {} | ||
@@ -268,3 +268,12 @@ | ||
const urlsToWarnAbout = []; | ||
for (const entry of entries) { | ||
// See https://github.com/GoogleChrome/workbox/issues/2259 | ||
if (typeof entry === 'string') { | ||
urlsToWarnAbout.push(entry); | ||
} else if (entry && entry.revision === undefined) { | ||
urlsToWarnAbout.push(entry.url); | ||
} | ||
const { | ||
@@ -296,2 +305,10 @@ cacheKey, | ||
this._urlsToCacheModes.set(url, cacheMode); | ||
if (urlsToWarnAbout.length > 0) { | ||
const warningMessage = `Workbox is precaching URLs without revision ` + `info: ${urlsToWarnAbout.join(', ')}\nThis is generally NOT safe. ` + `Learn more at https://bit.ly/wb-precache`; | ||
{ | ||
logger_js.logger.warn(warningMessage); | ||
} | ||
} | ||
} | ||
@@ -328,3 +345,3 @@ } | ||
const alreadyPrecached = []; | ||
const cache = await caches.open(this._cacheName); | ||
const cache = await self.caches.open(this._cacheName); | ||
const alreadyCachedRequests = await cache.keys(); | ||
@@ -382,3 +399,3 @@ const existingCacheKeys = new Set(alreadyCachedRequests.map(request => request.url)); | ||
async activate() { | ||
const cache = await caches.open(this._cacheName); | ||
const cache = await self.caches.open(this._cacheName); | ||
const currentlyCachedRequests = await cache.keys(); | ||
@@ -457,3 +474,3 @@ const expectedCacheKeys = new Set(this._urlsToCacheKeys.values()); | ||
// is correct. | ||
cacheWillUpdatePlugin.cacheWillUpdate({ | ||
await cacheWillUpdatePlugin.cacheWillUpdate({ | ||
event, | ||
@@ -555,3 +572,3 @@ request, | ||
if (cacheKey) { | ||
const cache = await caches.open(this._cacheName); | ||
const cache = await self.caches.open(this._cacheName); | ||
return cache.match(cacheKey); | ||
@@ -821,3 +838,3 @@ } | ||
addEventListener('fetch', event => { | ||
self.addEventListener('fetch', event => { | ||
const precachedURL = getCacheKeyForURL(event.request.url, { | ||
@@ -838,3 +855,3 @@ cleanURLs, | ||
let responsePromise = caches.open(cacheName).then(cache => { | ||
let responsePromise = self.caches.open(cacheName).then(cache => { | ||
return cache.match(precachedURL); | ||
@@ -943,7 +960,7 @@ }).then(cachedResponse => { | ||
const deleteOutdatedCaches = async (currentPrecacheName, substringToFind = SUBSTRING_TO_FIND) => { | ||
const cacheNames = await caches.keys(); | ||
const cacheNames = await self.caches.keys(); | ||
const cacheNamesToDelete = cacheNames.filter(cacheName => { | ||
return cacheName.includes(substringToFind) && cacheName.includes(self.registration.scope) && cacheName !== currentPrecacheName; | ||
}); | ||
await Promise.all(cacheNamesToDelete.map(cacheName => caches.delete(cacheName))); | ||
await Promise.all(cacheNamesToDelete.map(cacheName => self.caches.delete(cacheName))); | ||
return cacheNamesToDelete; | ||
@@ -968,3 +985,3 @@ }; | ||
// See https://github.com/Microsoft/TypeScript/issues/28357#issuecomment-436484705 | ||
addEventListener('activate', event => { | ||
self.addEventListener('activate', event => { | ||
const cacheName = cacheNames_js.cacheNames.getPrecacheName(); | ||
@@ -1157,4 +1174,4 @@ event.waitUntil(deleteOutdatedCaches(cacheName).then(cachesDeleted => { | ||
// See https://github.com/Microsoft/TypeScript/issues/28357#issuecomment-436484705 | ||
addEventListener('install', installListener); | ||
addEventListener('activate', activateListener); | ||
self.addEventListener('install', installListener); | ||
self.addEventListener('activate', activateListener); | ||
} | ||
@@ -1161,0 +1178,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
this.workbox=this.workbox||{},this.workbox.precaching=function(t,e,n,c,s,r){"use strict";try{self["workbox:precaching:5.0.0-rc.0"]&&_()}catch(t){}const i=[],a={get:()=>i,add(t){i.push(...t)}},o="__WB_REVISION__";function h(t){if(!t)throw new s.WorkboxError("add-to-cache-list-unexpected-type",{entry:t});if("string"==typeof t){const e=new URL(t,location.href);return{cacheKey:e.href,url:e.href}}const{revision:e,url:n}=t;if(!n)throw new s.WorkboxError("add-to-cache-list-unexpected-type",{entry:t});if(!e){const t=new URL(n,location.href);return{cacheKey:t.href,url:t.href}}const c=new URL(n,location.href),r=new URL(n,location.href);return c.searchParams.set(o,e),{cacheKey:c.href,url:r.href}}class u{constructor(t){this.t=e.cacheNames.getPrecacheName(t),this.s=new Map,this.i=new Map,this.o=new Map}addToCacheList(t){for(const e of t){const{cacheKey:t,url:n}=h(e),c="string"!=typeof e&&e.revision?"reload":"default";if(this.s.has(n)&&this.s.get(n)!==t)throw new s.WorkboxError("add-to-cache-list-conflicting-entries",{firstEntry:this.s.get(n),secondEntry:t});if("string"!=typeof e&&e.integrity){if(this.o.has(t)&&this.o.get(t)!==e.integrity)throw new s.WorkboxError("add-to-cache-list-conflicting-integrities",{url:n});this.o.set(t,e.integrity)}this.s.set(n,t),this.i.set(n,c)}}async install({event:t,plugins:e}={}){const n=[],c=[],s=await caches.open(this.t),r=await s.keys(),i=new Set(r.map(t=>t.url));for(const[t,e]of this.s)i.has(e)?c.push(t):n.push({cacheKey:e,url:t});const a=n.map(({cacheKey:n,url:c})=>{const s=this.o.get(n),r=this.i.get(c);return this.h({cacheKey:n,cacheMode:r,event:t,integrity:s,plugins:e,url:c})});return await Promise.all(a),{updatedURLs:n.map(t=>t.url),notUpdatedURLs:c}}async activate(){const t=await caches.open(this.t),e=await t.keys(),n=new Set(this.s.values()),c=[];for(const s of e)n.has(s.url)||(await t.delete(s),c.push(s.url));return{deletedURLs:c}}async h({cacheKey:t,url:e,cacheMode:i,event:a,plugins:o,integrity:h}){const u=new Request(e,{integrity:h,cache:i,credentials:"same-origin"});let l,d=await c.fetchWrapper.fetch({event:a,plugins:o,request:u});for(const t of o||[])"cacheWillUpdate"in t&&(l=t);if(!(l?l.cacheWillUpdate({event:a,request:u,response:d}):d.status<400))throw new s.WorkboxError("bad-precaching-response",{url:e,status:d.status});d.redirected&&(d=await r.copyResponse(d)),await n.cacheWrapper.put({event:a,plugins:o,response:d,request:t===e?u:new Request(t),cacheName:this.t,matchOptions:{ignoreSearch:!0}})}getURLsToCacheKeys(){return this.s}getCachedURLs(){return[...this.s.keys()]}getCacheKeyForURL(t){const e=new URL(t,location.href);return this.s.get(e.href)}async matchPrecache(t){const e=t instanceof Request?t.url:t,n=this.getCacheKeyForURL(e);if(n){return(await caches.open(this.t)).match(n)}}createHandler(t=!0){return async({request:e})=>{try{const n=await this.matchPrecache(e);if(n)return n;throw new s.WorkboxError("missing-precache-entry",{cacheName:this.t,url:e.url})}catch(n){if(t)return fetch(e);throw n}}}createHandlerBoundToURL(t,e=!0){if(!this.getCacheKeyForURL(t))throw new s.WorkboxError("non-precached-url",{url:t});const n=this.createHandler(e),c=new Request(t);return()=>n({request:c})}}let l;const d=()=>(l||(l=new u),l);const w=(t,e)=>{const n=d().getURLsToCacheKeys();for(const c of function*(t,{ignoreURLParametersMatching:e,directoryIndex:n,cleanURLs:c,urlManipulation:s}={}){const r=new URL(t,location.href);r.hash="",yield r.href;const i=function(t,e=[]){for(const n of[...t.searchParams.keys()])e.some(t=>t.test(n))&&t.searchParams.delete(n);return t}(r,e);if(yield i.href,n&&i.pathname.endsWith("/")){const t=new URL(i.href);t.pathname+=n,yield t.href}if(c){const t=new URL(i.href);t.pathname+=".html",yield t.href}if(s){const t=s({url:r});for(const e of t)yield e.href}}(t,e)){const t=n.get(c);if(t)return t}};let f=!1;const y=t=>{f||((({ignoreURLParametersMatching:t=[/^utm_/],directoryIndex:n="index.html",cleanURLs:c=!0,urlManipulation:s}={})=>{const r=e.cacheNames.getPrecacheName();addEventListener("fetch",e=>{const i=w(e.request.url,{cleanURLs:c,directoryIndex:n,ignoreURLParametersMatching:t,urlManipulation:s});if(!i)return;let a=caches.open(r).then(t=>t.match(i)).then(t=>t||fetch(i));e.respondWith(a)})})(t),f=!0)},p=t=>{const e=d(),n=a.get();t.waitUntil(e.install({event:t,plugins:n}).catch(t=>{throw t}))},g=t=>{const e=d();t.waitUntil(e.activate())},L=t=>{d().addToCacheList(t),t.length>0&&(addEventListener("install",p),addEventListener("activate",g))};return t.PrecacheController=u,t.addPlugins=(t=>{a.add(t)}),t.addRoute=y,t.cleanupOutdatedCaches=(()=>{addEventListener("activate",t=>{const n=e.cacheNames.getPrecacheName();t.waitUntil((async(t,e="-precache-")=>{const n=(await caches.keys()).filter(n=>n.includes(e)&&n.includes(self.registration.scope)&&n!==t);return await Promise.all(n.map(t=>caches.delete(t))),n})(n).then(t=>{}))})}),t.createHandler=((t=!0)=>{return d().createHandler(t)}),t.createHandlerBoundToURL=(t=>{return d().createHandlerBoundToURL(t)}),t.getCacheKeyForURL=(t=>{return d().getCacheKeyForURL(t)}),t.matchPrecache=(t=>{return d().matchPrecache(t)}),t.precache=L,t.precacheAndRoute=((t,e)=>{L(t),y(e)}),t}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core); | ||
this.workbox=this.workbox||{},this.workbox.precaching=function(t,e,n,s,i,r){"use strict";try{self["workbox:precaching:5.0.0-rc.1"]&&_()}catch(t){}const c=[],o={get:()=>c,add(t){c.push(...t)}},a="__WB_REVISION__";function h(t){if(!t)throw new i.WorkboxError("add-to-cache-list-unexpected-type",{entry:t});if("string"==typeof t){const e=new URL(t,location.href);return{cacheKey:e.href,url:e.href}}const{revision:e,url:n}=t;if(!n)throw new i.WorkboxError("add-to-cache-list-unexpected-type",{entry:t});if(!e){const t=new URL(n,location.href);return{cacheKey:t.href,url:t.href}}const s=new URL(n,location.href),r=new URL(n,location.href);return s.searchParams.set(a,e),{cacheKey:s.href,url:r.href}}class l{constructor(t){this.t=e.cacheNames.getPrecacheName(t),this.s=new Map,this.i=new Map,this.o=new Map}addToCacheList(t){const e=[];for(const n of t){"string"==typeof n?e.push(n):n&&void 0===n.revision&&e.push(n.url);const{cacheKey:t,url:s}=h(n),r="string"!=typeof n&&n.revision?"reload":"default";if(this.s.has(s)&&this.s.get(s)!==t)throw new i.WorkboxError("add-to-cache-list-conflicting-entries",{firstEntry:this.s.get(s),secondEntry:t});if("string"!=typeof n&&n.integrity){if(this.o.has(t)&&this.o.get(t)!==n.integrity)throw new i.WorkboxError("add-to-cache-list-conflicting-integrities",{url:s});this.o.set(t,n.integrity)}if(this.s.set(s,t),this.i.set(s,r),e.length>0){const t="Workbox is precaching URLs without revision "+`info: ${e.join(", ")}\nThis is generally NOT safe. `+"Learn more at https://bit.ly/wb-precache";console.warn(t)}}}async install({event:t,plugins:e}={}){const n=[],s=[],i=await self.caches.open(this.t),r=await i.keys(),c=new Set(r.map(t=>t.url));for(const[t,e]of this.s)c.has(e)?s.push(t):n.push({cacheKey:e,url:t});const o=n.map(({cacheKey:n,url:s})=>{const i=this.o.get(n),r=this.i.get(s);return this.h({cacheKey:n,cacheMode:r,event:t,integrity:i,plugins:e,url:s})});return await Promise.all(o),{updatedURLs:n.map(t=>t.url),notUpdatedURLs:s}}async activate(){const t=await self.caches.open(this.t),e=await t.keys(),n=new Set(this.s.values()),s=[];for(const i of e)n.has(i.url)||(await t.delete(i),s.push(i.url));return{deletedURLs:s}}async h({cacheKey:t,url:e,cacheMode:c,event:o,plugins:a,integrity:h}){const l=new Request(e,{integrity:h,cache:c,credentials:"same-origin"});let u,f=await s.fetchWrapper.fetch({event:o,plugins:a,request:l});for(const t of a||[])"cacheWillUpdate"in t&&(u=t);if(!(u?await u.cacheWillUpdate({event:o,request:l,response:f}):f.status<400))throw new i.WorkboxError("bad-precaching-response",{url:e,status:f.status});f.redirected&&(f=await r.copyResponse(f)),await n.cacheWrapper.put({event:o,plugins:a,response:f,request:t===e?l:new Request(t),cacheName:this.t,matchOptions:{ignoreSearch:!0}})}getURLsToCacheKeys(){return this.s}getCachedURLs(){return[...this.s.keys()]}getCacheKeyForURL(t){const e=new URL(t,location.href);return this.s.get(e.href)}async matchPrecache(t){const e=t instanceof Request?t.url:t,n=this.getCacheKeyForURL(e);if(n){return(await self.caches.open(this.t)).match(n)}}createHandler(t=!0){return async({request:e})=>{try{const n=await this.matchPrecache(e);if(n)return n;throw new i.WorkboxError("missing-precache-entry",{cacheName:this.t,url:e.url})}catch(n){if(t)return fetch(e);throw n}}}createHandlerBoundToURL(t,e=!0){if(!this.getCacheKeyForURL(t))throw new i.WorkboxError("non-precached-url",{url:t});const n=this.createHandler(e),s=new Request(t);return()=>n({request:s})}}let u;const f=()=>(u||(u=new l),u);const w=(t,e)=>{const n=f().getURLsToCacheKeys();for(const s of function*(t,{ignoreURLParametersMatching:e,directoryIndex:n,cleanURLs:s,urlManipulation:i}={}){const r=new URL(t,location.href);r.hash="",yield r.href;const c=function(t,e=[]){for(const n of[...t.searchParams.keys()])e.some(t=>t.test(n))&&t.searchParams.delete(n);return t}(r,e);if(yield c.href,n&&c.pathname.endsWith("/")){const t=new URL(c.href);t.pathname+=n,yield t.href}if(s){const t=new URL(c.href);t.pathname+=".html",yield t.href}if(i){const t=i({url:r});for(const e of t)yield e.href}}(t,e)){const t=n.get(s);if(t)return t}};let d=!1;const y=t=>{d||((({ignoreURLParametersMatching:t=[/^utm_/],directoryIndex:n="index.html",cleanURLs:s=!0,urlManipulation:i}={})=>{const r=e.cacheNames.getPrecacheName();self.addEventListener("fetch",e=>{const c=w(e.request.url,{cleanURLs:s,directoryIndex:n,ignoreURLParametersMatching:t,urlManipulation:i});if(!c)return;let o=self.caches.open(r).then(t=>t.match(c)).then(t=>t||fetch(c));e.respondWith(o)})})(t),d=!0)},p=t=>{const e=f(),n=o.get();t.waitUntil(e.install({event:t,plugins:n}).catch(t=>{throw t}))},g=t=>{const e=f();t.waitUntil(e.activate())},R=t=>{f().addToCacheList(t),t.length>0&&(self.addEventListener("install",p),self.addEventListener("activate",g))};return t.PrecacheController=l,t.addPlugins=(t=>{o.add(t)}),t.addRoute=y,t.cleanupOutdatedCaches=(()=>{self.addEventListener("activate",t=>{const n=e.cacheNames.getPrecacheName();t.waitUntil((async(t,e="-precache-")=>{const n=(await self.caches.keys()).filter(n=>n.includes(e)&&n.includes(self.registration.scope)&&n!==t);return await Promise.all(n.map(t=>self.caches.delete(t))),n})(n).then(t=>{}))})}),t.createHandler=((t=!0)=>{return f().createHandler(t)}),t.createHandlerBoundToURL=(t=>{return f().createHandlerBoundToURL(t)}),t.getCacheKeyForURL=(t=>{return f().getCacheKeyForURL(t)}),t.matchPrecache=(t=>{return f().matchPrecache(t)}),t.precache=R,t.precacheAndRoute=((t,e)=>{R(t),y(e)}),t}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core); | ||
//# sourceMappingURL=workbox-precaching.prod.js.map |
@@ -20,3 +20,3 @@ /* | ||
// See https://github.com/Microsoft/TypeScript/issues/28357#issuecomment-436484705 | ||
addEventListener('activate', ((event) => { | ||
self.addEventListener('activate', ((event) => { | ||
const cacheName = cacheNames.getPrecacheName(); | ||
@@ -23,0 +23,0 @@ event.waitUntil(deleteOutdatedCaches(cacheName).then((cachesDeleted) => { |
{ | ||
"name": "workbox-precaching", | ||
"version": "5.0.0-rc.0", | ||
"version": "5.0.0-rc.1", | ||
"license": "MIT", | ||
@@ -29,5 +29,5 @@ "author": "Google's Web DevRel Team", | ||
"dependencies": { | ||
"workbox-core": "^5.0.0-rc.0" | ||
"workbox-core": "^5.0.0-rc.1" | ||
}, | ||
"gitHead": "94542f92ceaec96ef59a09bda3aee1677ea5512b" | ||
"gitHead": "f03f71e50507e13d82d4e0a875cc49ba4501aff3" | ||
} |
@@ -56,5 +56,5 @@ /* | ||
// See https://github.com/Microsoft/TypeScript/issues/28357#issuecomment-436484705 | ||
addEventListener('install', installListener); | ||
addEventListener('activate', activateListener); | ||
self.addEventListener('install', installListener); | ||
self.addEventListener('activate', activateListener); | ||
} | ||
}; |
@@ -54,3 +54,11 @@ /* | ||
} | ||
const urlsToWarnAbout = []; | ||
for (const entry of entries) { | ||
// See https://github.com/GoogleChrome/workbox/issues/2259 | ||
if (typeof entry === 'string') { | ||
urlsToWarnAbout.push(entry); | ||
} | ||
else if (entry && entry.revision === undefined) { | ||
urlsToWarnAbout.push(entry.url); | ||
} | ||
const { cacheKey, url } = createCacheKey(entry); | ||
@@ -77,2 +85,15 @@ const cacheMode = (typeof entry !== 'string' && entry.revision) ? | ||
this._urlsToCacheModes.set(url, cacheMode); | ||
if (urlsToWarnAbout.length > 0) { | ||
const warningMessage = `Workbox is precaching URLs without revision ` + | ||
`info: ${urlsToWarnAbout.join(', ')}\nThis is generally NOT safe. ` + | ||
`Learn more at https://bit.ly/wb-precache`; | ||
if (process.env.NODE_ENV === 'production') { | ||
// Use console directly to display this warning without bloating | ||
// bundle sizes by pulling in all of the logger codebase in prod. | ||
console.warn(warningMessage); | ||
} | ||
else { | ||
logger.warn(warningMessage); | ||
} | ||
} | ||
} | ||
@@ -103,3 +124,3 @@ } | ||
const alreadyPrecached = []; | ||
const cache = await caches.open(this._cacheName); | ||
const cache = await self.caches.open(this._cacheName); | ||
const alreadyCachedRequests = await cache.keys(); | ||
@@ -144,3 +165,3 @@ const existingCacheKeys = new Set(alreadyCachedRequests.map((request) => request.url)); | ||
async activate() { | ||
const cache = await caches.open(this._cacheName); | ||
const cache = await self.caches.open(this._cacheName); | ||
const currentlyCachedRequests = await cache.keys(); | ||
@@ -204,3 +225,3 @@ const expectedCacheKeys = new Set(this._urlsToCacheKeys.values()); | ||
// is correct. | ||
cacheWillUpdatePlugin.cacheWillUpdate({ event, request, response }) : | ||
await cacheWillUpdatePlugin.cacheWillUpdate({ event, request, response }) : | ||
// Otherwise, default to considering any response status under 400 valid. | ||
@@ -288,3 +309,3 @@ // This includes, by default, considering opaque responses valid. | ||
if (cacheKey) { | ||
const cache = await caches.open(this._cacheName); | ||
const cache = await self.caches.open(this._cacheName); | ||
return cache.match(cacheKey); | ||
@@ -291,0 +312,0 @@ } |
// @ts-ignore | ||
try{self['workbox:precaching:5.0.0-rc.0']&&_()}catch(e){} | ||
try{self['workbox:precaching:5.0.0-rc.1']&&_()}catch(e){} |
@@ -23,3 +23,3 @@ /* | ||
// See https://github.com/Microsoft/TypeScript/issues/28357#issuecomment-436484705 | ||
addEventListener('activate', ((event: ExtendableEvent) => { | ||
self.addEventListener('activate', ((event: ExtendableEvent) => { | ||
const cacheName = cacheNames.getPrecacheName(); | ||
@@ -26,0 +26,0 @@ |
@@ -72,5 +72,5 @@ /* | ||
// See https://github.com/Microsoft/TypeScript/issues/28357#issuecomment-436484705 | ||
addEventListener('install', installListener as EventListener); | ||
addEventListener('activate', activateListener as EventListener); | ||
self.addEventListener('install', installListener as EventListener); | ||
self.addEventListener('activate', activateListener as EventListener); | ||
} | ||
}; |
@@ -69,3 +69,11 @@ /* | ||
const urlsToWarnAbout: string[] = []; | ||
for (const entry of entries) { | ||
// See https://github.com/GoogleChrome/workbox/issues/2259 | ||
if (typeof entry === 'string') { | ||
urlsToWarnAbout.push(entry); | ||
} else if (entry && entry.revision === undefined) { | ||
urlsToWarnAbout.push(entry.url); | ||
} | ||
const {cacheKey, url} = createCacheKey(entry); | ||
@@ -95,2 +103,15 @@ const cacheMode = (typeof entry !== 'string' && entry.revision) ? | ||
this._urlsToCacheModes.set(url, cacheMode); | ||
if (urlsToWarnAbout.length > 0) { | ||
const warningMessage = `Workbox is precaching URLs without revision ` + | ||
`info: ${urlsToWarnAbout.join(', ')}\nThis is generally NOT safe. ` + | ||
`Learn more at https://bit.ly/wb-precache`; | ||
if (process.env.NODE_ENV === 'production') { | ||
// Use console directly to display this warning without bloating | ||
// bundle sizes by pulling in all of the logger codebase in prod. | ||
console.warn(warningMessage); | ||
} else { | ||
logger.warn(warningMessage); | ||
} | ||
} | ||
} | ||
@@ -127,3 +148,3 @@ } | ||
const cache = await caches.open(this._cacheName); | ||
const cache = await self.caches.open(this._cacheName); | ||
const alreadyCachedRequests = await cache.keys(); | ||
@@ -174,3 +195,3 @@ const existingCacheKeys = new Set(alreadyCachedRequests.map( | ||
async activate() { | ||
const cache = await caches.open(this._cacheName); | ||
const cache = await self.caches.open(this._cacheName); | ||
const currentlyCachedRequests = await cache.keys(); | ||
@@ -248,3 +269,3 @@ const expectedCacheKeys = new Set(this._urlsToCacheKeys.values()); | ||
// is correct. | ||
cacheWillUpdatePlugin.cacheWillUpdate!({event, request, response}) : | ||
await cacheWillUpdatePlugin.cacheWillUpdate!({event, request, response}) : | ||
// Otherwise, default to considering any response status under 400 valid. | ||
@@ -339,3 +360,3 @@ // This includes, by default, considering opaque responses valid. | ||
if (cacheKey) { | ||
const cache = await caches.open(this._cacheName); | ||
const cache = await self.caches.open(this._cacheName); | ||
return cache.match(cacheKey); | ||
@@ -342,0 +363,0 @@ } |
@@ -60,3 +60,3 @@ /* | ||
// See https://github.com/Microsoft/TypeScript/issues/28357#issuecomment-436484705 | ||
addEventListener('fetch', ((event: FetchEvent) => { | ||
self.addEventListener('fetch', ((event: FetchEvent) => { | ||
const precachedURL = getCacheKeyForURL(event.request.url, { | ||
@@ -76,3 +76,3 @@ cleanURLs, | ||
let responsePromise = caches.open(cacheName).then((cache) => { | ||
let responsePromise = self.caches.open(cacheName).then((cache) => { | ||
return cache.match(precachedURL); | ||
@@ -79,0 +79,0 @@ }).then((cachedResponse) => { |
@@ -38,3 +38,3 @@ /* | ||
substringToFind:string = SUBSTRING_TO_FIND) => { | ||
const cacheNames = await caches.keys(); | ||
const cacheNames = await self.caches.keys(); | ||
@@ -48,3 +48,3 @@ const cacheNamesToDelete = cacheNames.filter((cacheName) => { | ||
await Promise.all( | ||
cacheNamesToDelete.map((cacheName) => caches.delete(cacheName))); | ||
cacheNamesToDelete.map((cacheName) => self.caches.delete(cacheName))); | ||
@@ -51,0 +51,0 @@ return cacheNamesToDelete; |
@@ -43,3 +43,3 @@ /* | ||
// See https://github.com/Microsoft/TypeScript/issues/28357#issuecomment-436484705 | ||
addEventListener('fetch', ((event) => { | ||
self.addEventListener('fetch', ((event) => { | ||
const precachedURL = getCacheKeyForURL(event.request.url, { | ||
@@ -58,3 +58,3 @@ cleanURLs, | ||
} | ||
let responsePromise = caches.open(cacheName).then((cache) => { | ||
let responsePromise = self.caches.open(cacheName).then((cache) => { | ||
return cache.match(precachedURL); | ||
@@ -61,0 +61,0 @@ }).then((cachedResponse) => { |
@@ -29,3 +29,3 @@ /* | ||
const deleteOutdatedCaches = async (currentPrecacheName, substringToFind = SUBSTRING_TO_FIND) => { | ||
const cacheNames = await caches.keys(); | ||
const cacheNames = await self.caches.keys(); | ||
const cacheNamesToDelete = cacheNames.filter((cacheName) => { | ||
@@ -36,5 +36,5 @@ return cacheName.includes(substringToFind) && | ||
}); | ||
await Promise.all(cacheNamesToDelete.map((cacheName) => caches.delete(cacheName))); | ||
await Promise.all(cacheNamesToDelete.map((cacheName) => self.caches.delete(cacheName))); | ||
return cacheNamesToDelete; | ||
}; | ||
export { deleteOutdatedCaches }; |
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
414403
3988
13
Updatedworkbox-core@^5.0.0-rc.1