-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
workbox-0747ddb5.js
1 lines (1 loc) · 8.15 KB
/
workbox-0747ddb5.js
1
define("./workbox-0747ddb5.js",["exports"],(function(e){"use strict";try{self["workbox:core:5.0.0"]&&_()}catch(e){}const t=(e,...t)=>{let n=e;return t.length>0&&(n+=` :: ${JSON.stringify(t)}`),n};class n extends Error{constructor(e,n){super(t(e,n)),this.name=e,this.details=n}}const s={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:"undefined"!=typeof registration?registration.scope:""},i=e=>[s.prefix,e,s.suffix].filter(e=>e&&e.length>0).join("-"),c=e=>{(e=>{for(const t of Object.keys(s))e(t)})(t=>{"string"==typeof e[t]&&(s[t]=e[t])})},o=e=>e||i(s.precache);const r=e=>{const t=new URL(String(e),location.href);return t.origin===location.origin?t.pathname:t.href},a=new Set;const l=(e,t)=>e.filter(e=>t in e),u=async({cacheName:e,request:t,event:n,matchOptions:s,plugins:i=[]})=>{const c=await self.caches.open(e),o=await h({plugins:i,request:t,mode:"read"});let r=await c.match(o,s);for(const t of i)if("cachedResponseWillBeUsed"in t){const i=t.cachedResponseWillBeUsed;r=await i.call(t,{cacheName:e,event:n,matchOptions:s,cachedResponse:r,request:o})}return r},f=async({request:e,response:t,event:n,plugins:s=[]})=>{let i=t,c=!1;for(let t of s)if("cacheWillUpdate"in t){c=!0;const s=t.cacheWillUpdate;if(i=await s.call(t,{request:e,response:i,event:n}),!i)break}return c||(i=i&&200===i.status?i:void 0),i||null},h=async({request:e,mode:t,plugins:n=[]})=>{const s=l(n,"cacheKeyWillBeUsed");let i=e;for(const e of s)i=await e.cacheKeyWillBeUsed.call(e,{mode:t,request:i}),"string"==typeof i&&(i=new Request(i));return i},w=async({cacheName:e,request:t,response:s,event:i,plugins:c=[],matchOptions:o})=>{const w=await h({plugins:c,request:t,mode:"write"});if(!s)throw new n("cache-put-with-no-response",{url:r(w.url)});let d=await f({event:i,plugins:c,response:s,request:w});if(!d)return;const p=await self.caches.open(e),y=l(c,"cacheDidUpdate");let g=y.length>0?await u({cacheName:e,matchOptions:o,request:w}):null;try{await p.put(w,d)}catch(e){throw"QuotaExceededError"===e.name&&await async function(){for(const e of a)await e()}(),e}for(let t of y)await t.cacheDidUpdate.call(t,{cacheName:e,event:i,oldResponse:g,newResponse:d,request:w})},d=async({request:e,fetchOptions:t,event:s,plugins:i=[]})=>{if("string"==typeof e&&(e=new Request(e)),s instanceof FetchEvent&&s.preloadResponse){const e=await s.preloadResponse;if(e)return e}const c=l(i,"fetchDidFail"),o=c.length>0?e.clone():null;try{for(let t of i)if("requestWillFetch"in t){const n=t.requestWillFetch,i=e.clone();e=await n.call(t,{request:i,event:s})}}catch(e){throw new n("plugin-error-request-will-fetch",{thrownError:e})}let r=e.clone();try{let n;n="navigate"===e.mode?await fetch(e):await fetch(e,t);for(const e of i)"fetchDidSucceed"in e&&(n=await e.fetchDidSucceed.call(e,{event:s,request:r,response:n}));return n}catch(e){for(const t of c)await t.fetchDidFail.call(t,{error:e,event:s,originalRequest:o.clone(),request:r.clone()});throw e}};let p;async function y(e,t){const n=e.clone(),s={headers:new Headers(n.headers),status:n.status,statusText:n.statusText},i=t?t(s):s,c=function(){if(void 0===p){const e=new Response("");if("body"in e)try{new Response(e.body),p=!0}catch(e){p=!1}p=!1}return p}()?n.body:await n.blob();return new Response(c,i)}try{self["workbox:precaching:5.0.0"]&&_()}catch(e){}function g(e){if(!e)throw new n("add-to-cache-list-unexpected-type",{entry:e});if("string"==typeof e){const t=new URL(e,location.href);return{cacheKey:t.href,url:t.href}}const{revision:t,url:s}=e;if(!s)throw new n("add-to-cache-list-unexpected-type",{entry:e});if(!t){const e=new URL(s,location.href);return{cacheKey:e.href,url:e.href}}const i=new URL(s,location.href),c=new URL(s,location.href);return i.searchParams.set("__WB_REVISION__",t),{cacheKey:i.href,url:c.href}}class R{constructor(e){this.t=o(e),this.s=new Map,this.i=new Map,this.o=new Map}addToCacheList(e){const t=[];for(const s of e){"string"==typeof s?t.push(s):s&&void 0===s.revision&&t.push(s.url);const{cacheKey:e,url:i}=g(s),c="string"!=typeof s&&s.revision?"reload":"default";if(this.s.has(i)&&this.s.get(i)!==e)throw new n("add-to-cache-list-conflicting-entries",{firstEntry:this.s.get(i),secondEntry:e});if("string"!=typeof s&&s.integrity){if(this.o.has(e)&&this.o.get(e)!==s.integrity)throw new n("add-to-cache-list-conflicting-integrities",{url:i});this.o.set(e,s.integrity)}if(this.s.set(i,e),this.i.set(i,c),t.length>0){const e="Workbox is precaching URLs without revision "+`info: ${t.join(", ")}\nThis is generally NOT safe. `+"Learn more at https://bit.ly/wb-precache";console.warn(e)}}}async install({event:e,plugins:t}={}){const n=[],s=[],i=await self.caches.open(this.t),c=await i.keys(),o=new Set(c.map(e=>e.url));for(const[e,t]of this.s)o.has(t)?s.push(e):n.push({cacheKey:t,url:e});const r=n.map(({cacheKey:n,url:s})=>{const i=this.o.get(n),c=this.i.get(s);return this.l({cacheKey:n,cacheMode:c,event:e,integrity:i,plugins:t,url:s})});return await Promise.all(r),{updatedURLs:n.map(e=>e.url),notUpdatedURLs:s}}async activate(){const e=await self.caches.open(this.t),t=await e.keys(),n=new Set(this.s.values()),s=[];for(const i of t)n.has(i.url)||(await e.delete(i),s.push(i.url));return{deletedURLs:s}}async l({cacheKey:e,url:t,cacheMode:s,event:i,plugins:c,integrity:o}){const r=new Request(t,{integrity:o,cache:s,credentials:"same-origin"});let a,l=await d({event:i,plugins:c,request:r});for(const e of c||[])"cacheWillUpdate"in e&&(a=e);if(!(a?await a.cacheWillUpdate({event:i,request:r,response:l}):l.status<400))throw new n("bad-precaching-response",{url:t,status:l.status});l.redirected&&(l=await y(l)),await w({event:i,plugins:c,response:l,request:e===t?r:new Request(e),cacheName:this.t,matchOptions:{ignoreSearch:!0}})}getURLsToCacheKeys(){return this.s}getCachedURLs(){return[...this.s.keys()]}getCacheKeyForURL(e){const t=new URL(e,location.href);return this.s.get(t.href)}async matchPrecache(e){const t=e instanceof Request?e.url:e,n=this.getCacheKeyForURL(t);if(n){return(await self.caches.open(this.t)).match(n)}}createHandler(e=!0){return async({request:t})=>{try{const e=await this.matchPrecache(t);if(e)return e;throw new n("missing-precache-entry",{cacheName:this.t,url:t instanceof Request?t.url:t})}catch(n){if(e)return fetch(t);throw n}}}createHandlerBoundToURL(e,t=!0){if(!this.getCacheKeyForURL(e))throw new n("non-precached-url",{url:e});const s=this.createHandler(t),i=new Request(e);return()=>s({request:i})}}let q;const m=()=>(q||(q=new R),q);const v=(e,t)=>{const n=m().getURLsToCacheKeys();for(const s of function*(e,{ignoreURLParametersMatching:t,directoryIndex:n,cleanURLs:s,urlManipulation:i}={}){const c=new URL(e,location.href);c.hash="",yield c.href;const o=function(e,t=[]){for(const n of[...e.searchParams.keys()])t.some(e=>e.test(n))&&e.searchParams.delete(n);return e}(c,t);if(yield o.href,n&&o.pathname.endsWith("/")){const e=new URL(o.href);e.pathname+=n,yield e.href}if(s){const e=new URL(o.href);e.pathname+=".html",yield e.href}if(i){const e=i({url:c});for(const t of e)yield t.href}}(e,t)){const e=n.get(s);if(e)return e}};let U=!1;function L(e){U||((({ignoreURLParametersMatching:e=[/^utm_/],directoryIndex:t="index.html",cleanURLs:n=!0,urlManipulation:s}={})=>{const i=o();self.addEventListener("fetch",c=>{const o=v(c.request.url,{cleanURLs:n,directoryIndex:t,ignoreURLParametersMatching:e,urlManipulation:s});if(!o)return;let r=self.caches.open(i).then(e=>e.match(o)).then(e=>e||fetch(o));c.respondWith(r)})})(e),U=!0)}const x=[],K={get:()=>x,add(e){x.push(...e)}},M=e=>{const t=m(),n=K.get();e.waitUntil(t.install({event:e,plugins:n}).catch(e=>{throw e}))},b=e=>{const t=m();e.waitUntil(t.activate())};e.cleanupOutdatedCaches=function(){self.addEventListener("activate",e=>{const t=o();e.waitUntil((async(e,t="-precache-")=>{const n=(await self.caches.keys()).filter(n=>n.includes(t)&&n.includes(self.registration.scope)&&n!==e);return await Promise.all(n.map(e=>self.caches.delete(e))),n})(t).then(e=>{}))})},e.clientsClaim=function(){self.addEventListener("activate",()=>self.clients.claim())},e.precacheAndRoute=function(e,t){!function(e){m().addToCacheList(e),e.length>0&&(self.addEventListener("install",M),self.addEventListener("activate",b))}(e),L(t)},e.setCacheNameDetails=function(e){c(e)},e.skipWaiting=function(){self.addEventListener("install",()=>self.skipWaiting())}}));