workbox-precaching
Advanced tools
Comparing version 3.0.0-beta.0 to 3.0.0-beta.1
this.workbox = this.workbox || {}; | ||
this.workbox.precaching = (function (cacheNames_mjs,WorkboxError_mjs,fetchWrapper_mjs,cacheWrapper_mjs,assert_mjs,DBWrapper_mjs,logger_mjs,getFriendlyURL_mjs) { | ||
this.workbox.precaching = (function (DBWrapper_mjs,cacheNames_mjs,logger_mjs,WorkboxError_mjs,fetchWrapper_mjs,cacheWrapper_mjs,assert_mjs,getFriendlyURL_mjs) { | ||
'use strict'; | ||
try { | ||
self.workbox.v['workbox:precaching:3.0.0-beta.0'] = 1; | ||
self.workbox.v['workbox:precaching:3.0.0-beta.1'] = 1; | ||
} catch (e) {} // eslint-disable-line | ||
@@ -45,3 +45,3 @@ | ||
this._revision = revision; | ||
const requestAsCacheKey = new Request(url); | ||
const requestAsCacheKey = new Request(url, { credentials: 'same-origin' }); | ||
this._cacheRequest = requestAsCacheKey; | ||
@@ -62,3 +62,5 @@ this._networkRequest = shouldCacheBust ? this._cacheBustRequest(requestAsCacheKey) : requestAsCacheKey; | ||
let url = request.url; | ||
const requestOptions = {}; | ||
const requestOptions = { | ||
credentials: 'same-origin' | ||
}; | ||
if ('cache' in Request.prototype) { | ||
@@ -782,3 +784,2 @@ // Make use of the Request cache mode where we can. | ||
var publicAPI = Object.freeze({ | ||
@@ -989,3 +990,16 @@ PrecacheController: PrecacheController | ||
return cache.match(precachedUrl); | ||
}).then(cachedResponse => { | ||
if (cachedResponse) { | ||
return cachedResponse; | ||
} | ||
// Fall back to the network if we don't have a cached response (perhaps | ||
// due to manual cache cleanup). | ||
{ | ||
logger_mjs.logger.debug(`The precached response for ` + `${getFriendlyURL_mjs.getFriendlyURL(precachedUrl)} in ${cacheName} was not found. ` + `Falling back to the network instead.`); | ||
} | ||
return fetch(precachedUrl); | ||
}); | ||
{ | ||
@@ -992,0 +1006,0 @@ responsePromise = responsePromise.then(response => { |
@@ -1,3 +0,3 @@ | ||
this.workbox=this.workbox||{},this.workbox.precaching=function(e,t,n,r,s){"use strict";try{self.workbox.v["workbox:precaching:3.0.0-beta.0"]=1}catch(e){}class i{constructor(e,t,n,r){this.e=e,this.t=t,this.n=n;const s=new Request(t);this.r=s,this.s=r?this.i(s):s}i(e){let t=e.url;const n={};if("cache"in Request.prototype)n.cache="reload";else{const e=new URL(t,location),n=encodeURIComponent;e.search+=(e.search?"&":"")+n("_workbox-cache-bust")+"="+n(this.n),t=e.toString()}return new Request(t,n)}}const c="revision",o="url",l="precached-details-models";class u{constructor(t){this.c=e.cacheNames.getPrecacheName(t),this.o=new s.DBWrapper("workbox-precaching",2,{onupgradeneeded:this.l})}l(e){const t=e.target.result;e.oldVersion<2&&(t.objectStoreNames.contains("workbox-precaching")&&t.deleteObjectStore("workbox-precaching"),t.objectStoreNames.contains(l)&&t.deleteObjectStore(l)),t.createObjectStore(l)}u(e){var t=this;return babelHelpers.asyncToGenerator(function*(){if((yield t.a(e.t))!==e.n)return!1;return!!(yield(yield caches.open(t.c)).match(e.r))})()}h(){var e=this;return babelHelpers.asyncToGenerator(function*(){return yield e.o.getAllMatching(l,{includeKeys:!0})})()}a(e){var t=this;return babelHelpers.asyncToGenerator(function*(){const n=yield t.o.get(l,e);return n?n[c]:null})()}d(e){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.o.put(l,{[c]:e.n,[o]:e.r.url},e.t)})()}f(e){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.o.delete(l,e)})()}}const a=(()=>{var e=babelHelpers.asyncToGenerator(function*(e){const t=e.clone(),n=yield"body"in t?Promise.resolve(t.body):t.blob();return new Response(n,["headers","status","statusText"].map(function(e){return t[e]}))});return function(t){return e.apply(this,arguments)}})();class h{constructor(t){this.c=e.cacheNames.getPrecacheName(t),this.y=new Map,this.b=new u(this.c)}addToCacheList(e){e.map(e=>{this.p(this.w(e))})}w(e){switch(typeof e){case"string":return new i(e,e,e);case"object":return new i(e,e.url,e.revision||e.url,!!e.revision);default:throw new t.WorkboxError("add-to-cache-list-unexpected-type",{entry:e})}}p(e){const n=this.y.get(e.t);if(n){if(n.n!==e.n)throw new t.WorkboxError("add-to-cache-list-conflicting-entries",{firstEntry:n.e,secondEntry:e.e})}else this.y.set(e.t,e)}install(e={}){var t=this;return babelHelpers.asyncToGenerator(function*(){const n=[],r=[];for(const e of t.y.values())(yield t.b.u(e))?r.push(e):n.push(e);return yield Promise.all(n.map(function(n){return t.R(n,e.plugins)})),{updatedEntries:n,notUpdatedEntries:r}})()}R(e,t){var s=this;return babelHelpers.asyncToGenerator(function*(){let i=yield n.fetchWrapper.fetch(e.s,null,t);return i.redirected&&(i=yield a(i)),yield r.cacheWrapper.put(s.c,e.r,i,t),yield s.b.d(e),!0})()}cleanup(){var e=this;return babelHelpers.asyncToGenerator(function*(){const t=[];e.y.forEach(function(e){const n=new URL(e.r.url,location).toString();t.push(n)});const[n,r]=yield Promise.all([e.U(t),e.g(t)]);return{deletedCacheRequests:n,deletedRevisionDetails:r}})()}U(e){var t=this;return babelHelpers.asyncToGenerator(function*(){if(!(yield caches.has(t.c)))return[];const n=yield caches.open(t.c),r=(yield n.keys()).filter(function(t){return!e.includes(new URL(t.url,location).toString())});return yield Promise.all(r.map(function(e){return n.delete(e)})),r.map(function(e){return e.url})})()}g(e){var t=this;return babelHelpers.asyncToGenerator(function*(){const n=(yield t.b.h()).filter(function(t){const n=new URL(t.value.url,location).toString();return!e.includes(n)});return yield Promise.all(n.map(function(e){return t.b.f(e.primaryKey)})),n.map(function(e){return e.value.url})})()}getCachedUrls(){return Array.from(this.y.keys()).map(e=>new URL(e,location).href)}}var d=Object.freeze({PrecacheController:h});let f=!1,y=!1,b=!1,p=[];const w=e.cacheNames.getPrecacheName(),R=new h(w),v=(e,{ignoreUrlParametersMatching:t=[/^utm_/],directoryIndex:n="index.html",cleanUrls:r=!0,urlManipulation:s=null}={})=>{const i=new URL(e,location);i.hash="";const c=((e,t)=>{const n=e.search.slice(1).split("&").map(e=>e.split("=")).filter(e=>t.every(t=>!t.test(e[0]))).map(e=>e.join("=")),r=new URL(e);return r.search=n.join("&"),r})(i,t);let o=[i,c];if(n&&c.pathname.endsWith("/")){const e=new URL(c);e.pathname+=n,o.push(e)}if(r){const e=new URL(c);e.pathname+=".html",o.push(e)}if(s){const e=s({url:i});o=o.concat(e)}const l=R.getCachedUrls();for(const e of o)if(-1!==l.indexOf(e.href))return e.href;return null},U={};U.precache=(e=>{R.addToCacheList(e),f||e.length<=0||(f=!0,self.addEventListener("install",e=>{e.waitUntil(R.install({suppressWarnings:b,plugins:p}))}),self.addEventListener("activate",e=>{e.waitUntil(R.cleanup())}))}),U.addRoute=(e=>{y||(y=!0,self.addEventListener("fetch",t=>{const n=v(t.request.url,e);if(!n)return;let r=caches.open(w).then(e=>e.match(n));t.respondWith(r)}))}),U.precacheAndRoute=((e,t)=>{U.precache(e),U.addRoute(t)}),U.suppressWarnings=(e=>{b=e}),U.addPlugins=(e=>{p=p.concat(e)});return Object.assign(U,d)}(workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private); | ||
this.workbox=this.workbox||{},this.workbox.precaching=function(e,t,n,r,s){"use strict";try{self.workbox.v["workbox:precaching:3.0.0-beta.1"]=1}catch(e){}class i{constructor(e,t,n,r){this.e=e,this.t=t,this.n=n;const s=new Request(t,{credentials:"same-origin"});this.r=s,this.s=r?this.i(s):s}i(e){let t=e.url;const n={credentials:"same-origin"};if("cache"in Request.prototype)n.cache="reload";else{const e=new URL(t,location),n=encodeURIComponent;e.search+=(e.search?"&":"")+n("_workbox-cache-bust")+"="+n(this.n),t=e.toString()}return new Request(t,n)}}const c="revision",o="url",l="precached-details-models";class a{constructor(n){this.c=t.cacheNames.getPrecacheName(n),this.o=new e.DBWrapper("workbox-precaching",2,{onupgradeneeded:this.l})}l(e){const t=e.target.result;e.oldVersion<2&&(t.objectStoreNames.contains("workbox-precaching")&&t.deleteObjectStore("workbox-precaching"),t.objectStoreNames.contains(l)&&t.deleteObjectStore(l)),t.createObjectStore(l)}a(e){var t=this;return babelHelpers.asyncToGenerator(function*(){if((yield t.u(e.t))!==e.n)return!1;return!!(yield(yield caches.open(t.c)).match(e.r))})()}h(){var e=this;return babelHelpers.asyncToGenerator(function*(){return yield e.o.getAllMatching(l,{includeKeys:!0})})()}u(e){var t=this;return babelHelpers.asyncToGenerator(function*(){const n=yield t.o.get(l,e);return n?n[c]:null})()}d(e){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.o.put(l,{[c]:e.n,[o]:e.r.url},e.t)})()}f(e){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.o.delete(l,e)})()}}const u=(()=>{var e=babelHelpers.asyncToGenerator(function*(e){const t=e.clone(),n=yield"body"in t?Promise.resolve(t.body):t.blob();return new Response(n,["headers","status","statusText"].map(function(e){return t[e]}))});return function(t){return e.apply(this,arguments)}})();class h{constructor(e){this.c=t.cacheNames.getPrecacheName(e),this.y=new Map,this.b=new a(this.c)}addToCacheList(e){e.map(e=>{this.p(this.w(e))})}w(e){switch(typeof e){case"string":return new i(e,e,e);case"object":return new i(e,e.url,e.revision||e.url,!!e.revision);default:throw new n.WorkboxError("add-to-cache-list-unexpected-type",{entry:e})}}p(e){const t=this.y.get(e.t);if(t){if(t.n!==e.n)throw new n.WorkboxError("add-to-cache-list-conflicting-entries",{firstEntry:t.e,secondEntry:e.e})}else this.y.set(e.t,e)}install(e={}){var t=this;return babelHelpers.asyncToGenerator(function*(){const n=[],r=[];for(const e of t.y.values())(yield t.b.a(e))?r.push(e):n.push(e);return yield Promise.all(n.map(function(n){return t.R(n,e.plugins)})),{updatedEntries:n,notUpdatedEntries:r}})()}R(e,t){var n=this;return babelHelpers.asyncToGenerator(function*(){let i=yield r.fetchWrapper.fetch(e.s,null,t);return i.redirected&&(i=yield u(i)),yield s.cacheWrapper.put(n.c,e.r,i,t),yield n.b.d(e),!0})()}cleanup(){var e=this;return babelHelpers.asyncToGenerator(function*(){const t=[];e.y.forEach(function(e){const n=new URL(e.r.url,location).toString();t.push(n)});const[n,r]=yield Promise.all([e.g(t),e.U(t)]);return{deletedCacheRequests:n,deletedRevisionDetails:r}})()}g(e){var t=this;return babelHelpers.asyncToGenerator(function*(){if(!(yield caches.has(t.c)))return[];const n=yield caches.open(t.c),r=(yield n.keys()).filter(function(t){return!e.includes(new URL(t.url,location).toString())});return yield Promise.all(r.map(function(e){return n.delete(e)})),r.map(function(e){return e.url})})()}U(e){var t=this;return babelHelpers.asyncToGenerator(function*(){const n=(yield t.b.h()).filter(function(t){const n=new URL(t.value.url,location).toString();return!e.includes(n)});return yield Promise.all(n.map(function(e){return t.b.f(e.primaryKey)})),n.map(function(e){return e.value.url})})()}getCachedUrls(){return Array.from(this.y.keys()).map(e=>new URL(e,location).href)}}var d=Object.freeze({PrecacheController:h});let f=!1,y=!1,b=!1,p=[];const w=t.cacheNames.getPrecacheName(),R=new h(w),g=(e,{ignoreUrlParametersMatching:t=[/^utm_/],directoryIndex:n="index.html",cleanUrls:r=!0,urlManipulation:s=null}={})=>{const i=new URL(e,location);i.hash="";const c=((e,t)=>{const n=e.search.slice(1).split("&").map(e=>e.split("=")).filter(e=>t.every(t=>!t.test(e[0]))).map(e=>e.join("=")),r=new URL(e);return r.search=n.join("&"),r})(i,t);let o=[i,c];if(n&&c.pathname.endsWith("/")){const e=new URL(c);e.pathname+=n,o.push(e)}if(r){const e=new URL(c);e.pathname+=".html",o.push(e)}if(s){const e=s({url:i});o=o.concat(e)}const l=R.getCachedUrls();for(const e of o)if(-1!==l.indexOf(e.href))return e.href;return null},v={};v.precache=(e=>{R.addToCacheList(e),f||e.length<=0||(f=!0,self.addEventListener("install",e=>{e.waitUntil(R.install({suppressWarnings:b,plugins:p}))}),self.addEventListener("activate",e=>{e.waitUntil(R.cleanup())}))}),v.addRoute=(e=>{y||(y=!0,self.addEventListener("fetch",t=>{const n=g(t.request.url,e);if(!n)return;let r=caches.open(w).then(e=>e.match(n)).then(e=>e||fetch(n));t.respondWith(r)}))}),v.precacheAndRoute=((e,t)=>{v.precache(e),v.addRoute(t)}),v.suppressWarnings=(e=>{b=e}),v.addPlugins=(e=>{p=p.concat(e)});return Object.assign(v,d)}(workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private); | ||
//# sourceMappingURL=workbox-precaching.prod.js.map |
{ | ||
"name": "workbox-precaching", | ||
"version": "3.0.0-beta.0", | ||
"version": "3.0.0-beta.1", | ||
"license": "Apache-2.0", | ||
@@ -28,4 +28,4 @@ "author": "Google's Web DevRel Team", | ||
"dependencies": { | ||
"workbox-core": "^3.0.0-beta.0" | ||
"workbox-core": "^3.0.0-beta.1" | ||
} | ||
} |
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
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
Network access
Supply chain riskThis module accesses the network.
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
118880
2020
12
3
Updatedworkbox-core@^3.0.0-beta.1