shlink-web-client/dependabot/npm_and_yarn/workbox-routing-7.1.0/service-worker.js

3 lines
33 KiB
JavaScript
Raw Normal View History

try{self["workbox:core:7.0.0"]&&_()}catch{}const se=(s,...e)=>{let t=s;return e.length>0&&(t+=` :: ${JSON.stringify(e)}`),t},ne=se;let j=class extends Error{constructor(e,t){const n=ne(e,t);super(n),this.name=e,this.details=t}};typeof registration<"u"&&registration.scope;function re(){self.addEventListener("activate",()=>self.clients.claim())}try{self["workbox:core:7.0.0"]&&_()}catch{}const ie=(s,...e)=>{let t=s;return e.length>0&&(t+=` :: ${JSON.stringify(e)}`),t},ae=ie;let oe=class extends Error{constructor(e,t){const n=ae(e,t);super(n),this.name=e,this.details=t}};function J(s){s.then(()=>{})}const ce=(s,e)=>e.some(t=>s instanceof t);let $,B;function le(){return $||($=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function he(){return B||(B=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const z=new WeakMap,K=new WeakMap,Q=new WeakMap,P=new WeakMap,W=new WeakMap;function ue(s){const e=new Promise((t,n)=>{const r=()=>{s.removeEventListener("success",i),s.removeEventListener("error",a)},i=()=>{t(m(s.result)),r()},a=()=>{n(s.error),r()};s.addEventListener("success",i),s.addEventListener("error",a)});return e.then(t=>{t instanceof IDBCursor&&z.set(t,s)}).catch(()=>{}),W.set(e,s),e}function fe(s){if(K.has(s))return;const e=new Promise((t,n)=>{const r=()=>{s.removeEventListener("complete",i),s.removeEventListener("error",a),s.removeEventListener("abort",a)},i=()=>{t(),r()},a=()=>{n(s.error||new DOMException("AbortError","AbortError")),r()};s.addEventListener("complete",i),s.addEventListener("error",a),s.addEventListener("abort",a)});K.set(s,e)}let S={get(s,e,t){if(s instanceof IDBTransaction){if(e==="done")return K.get(s);if(e==="objectStoreNames")return s.objectStoreNames||Q.get(s);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return m(s[e])},set(s,e,t){return s[e]=t,!0},has(s,e){return s instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in s}};function de(s){S=s(S)}function pe(s){return s===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const n=s.call(N(this),e,...t);return Q.set(n,e.sort?e.sort():[e]),m(n)}:he().includes(s)?function(...e){return s.apply(N(this),e),m(z.get(this))}:function(...e){return m(s.apply(N(this),e))}}function ge(s){return typeof s=="function"?pe(s):(s instanceof IDBTransaction&&fe(s),ce(s,le())?new Proxy(s,S):s)}function m(s){if(s instanceof IDBRequest)return ue(s);if(P.has(s))return P.get(s);const e=ge(s);return e!==s&&(P.set(s,e),W.set(e,s)),e}const N=s=>W.get(s);function me(s,e,{blocked:t,upgrade:n,blocking:r,terminated:i}={}){const a=indexedDB.open(s,e),o=m(a);return n&&a.addEventListener("upgradeneeded",c=>{n(m(a.result),c.oldVersion,c.newVersion,m(a.transaction),c)}),t&&a.addEventListener("blocked",c=>t(c.oldVersion,c.newVersion,c)),o.then(c=>{i&&c.addEventListener("close",()=>i()),r&&c.addEventListener("versionchange",l=>r(l.oldVersion,l.newVersion,l))}).catch(()=>{}),o}function we(s,{blocked:e}={}){const t=indexedDB.deleteDatabase(s);return e&&t.addEventListener("blocked",n=>e(n.oldVersion,n)),m(t).then(()=>{})}const ye=["get","getKey","getAll","getAllKeys","count"],_e=["put","add","delete","clear"],T=new Map;function q(s,e){if(!(s instanceof IDBDatabase&&!(e in s)&&typeof e=="string"))return;if(T.get(e))return T.get(e);const t=e.replace(/FromIndex$/,""),n=e!==t,r=_e.includes(t);if(!(t in(n?IDBIndex:IDBObjectStore).prototype)||!(r||ye.includes(t)))return;const i=async function(a,...o){const c=this.transaction(a,r?"readwrite":"readonly");let l=c.store;return n&&(l=l.index(o.shift())),(await Promise.all([l[t](...o),r&&c.done]))[0]};return T.set(e,i),i}de(s=>({...s,get:(e,t,n)=>q(e,t)||s.get(e,t,n),has:(e,t)=>!!q(e,t)||s.has(e,t)}));try{self["workbox:expiration:7.0.0"]&&_()}catch{}const be="workbox-expiration",b="cache-entries",F=s=>{const e=new URL(s,location.href);return e.hash="",e.href};class Re{constructor(e){this._db=null,this._cacheName=e}_upgradeDb(e){const t=e.createObjectStore(b,{keyPath:"id"});t.createIndex("cac
This is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(o)}}}install(e){return V(e,async()=>{const t=new Me;this.strategy.plugins.push(t);for(const[i,a]of this._urlsToCacheKeys){const o=this._cacheKeysToIntegrities.get(a),c=this._urlsToCacheModes.get(i),l=new Request(i,{integrity:o,cache:c,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:a},request:l,event:e}))}const{updatedURLs:n,notUpdatedURLs:r}=t;return{updatedURLs:n,notUpdatedURLs:r}})}activate(e){return V(e,async()=>{const t=await self.caches.open(this.strategy.cacheName),n=await t.keys(),r=new Set(this._urlsToCacheKeys.values()),i=[];for(const a of n)r.has(a.url)||(await t.delete(a),i.push(a.url));return{deletedURLs:i}})}getURLsToCacheKeys(){return this._urlsToCacheKeys}getCachedURLs(){return[...this._urlsToCacheKeys.keys()]}getCacheKeyForURL(e){const t=new URL(e,location.href);return this._urlsToCacheKeys.get(t.href)}getIntegrityForCacheKey(e){return this._cacheKeysToIntegrities.get(e)}async matchPrecache(e){const t=e instanceof Request?e.url:e,n=this.getCacheKeyForURL(t);if(n)return(await self.caches.open(this.strategy.cacheName)).match(n)}createHandlerBoundToURL(e){const t=this.getCacheKeyForURL(e);if(!t)throw new u("non-precached-url",{url:e});return n=>(n.request=new Request(e),n.params=Object.assign({cacheKey:t},n.params),this.strategy.handle(n))}}let O;const H=()=>(O||(O=new Je),O);try{self["workbox:routing:7.0.0"]&&_()}catch{}const Z="GET",v=s=>s&&typeof s=="object"?s:{handle:s};let k=class{constructor(e,t,n=Z){this.handler=v(t),this.match=e,this.method=n}setCatchHandler(e){this.catchHandler=v(e)}},ze=class extends k{constructor(e,t,n){const r=({url:i})=>{const a=e.exec(i.href);if(a&&!(i.origin!==location.origin&&a.index!==0))return a.slice(1)};super(r,t,n)}},Qe=class{constructor(){this._routes=new Map,this._defaultHandlerMap=new Map}get routes(){return this._routes}addFetchListener(){self.addEventListener("fetch",e=>{const{request:t}=e,n=this.handleRequest({request:t,event:e});n&&e.respondWith(n)})}addCacheListener(){self.addEventListener("message",e=>{if(e.data&&e.data.type==="CACHE_URLS"){const{payload:t}=e.data,n=Promise.all(t.urlsToCache.map(r=>{typeof r=="string"&&(r=[r]);const i=new Request(...r);return this.handleRequest({request:i,event:e})}));e.waitUntil(n),e.ports&&e.ports[0]&&n.then(()=>e.ports[0].postMessage(!0))}})}handleRequest({request:e,event:t}){const n=new URL(e.url,location.href);if(!n.protocol.startsWith("http"))return;const r=n.origin===location.origin,{params:i,route:a}=this.findMatchingRoute({event:t,request:e,sameOrigin:r,url:n});let o=a&&a.handler;const c=e.method;if(!o&&this._defaultHandlerMap.has(c)&&(o=this._defaultHandlerMap.get(c)),!o)return;let l;try{l=o.handle({url:n,request:e,event:t,params:i})}catch(h){l=Promise.reject(h)}const f=a&&a.catchHandler;return l instanceof Promise&&(this._catchHandler||f)&&(l=l.catch(async h=>{if(f)try{return await f.handle({url:n,request:e,event:t,params:i})}catch(y){y instanceof Error&&(h=y)}if(this._catchHandler)return this._catchHandler.handle({url:n,request:e,event:t});throw h})),l}findMatchingRoute({url:e,sameOrigin:t,request:n,event:r}){const i=this._routes.get(n.method)||[];for(const a of i){let o;const c=a.match({url:e,sameOrigin:t,request:n,event:r});if(c)return o=c,(Array.isArray(o)&&o.length===0||c.constructor===Object&&Object.keys(c).length===0||typeof c=="boolean")&&(o=void 0),{route:a,params:o}}return{}}setDefaultHandler(e,t=Z){this._defaultHandlerMap.set(t,v(e))}setCatchHandler(e){this._catchHandler=v(e)}registerRoute(e){this._routes.has(e.method)||this._routes.set(e.method,[]),this._routes.get(e.method).push(e)}unregisterRoute(e){if(!this._routes.has(e.method))throw new u("unregister-route-but-not-found-with-method",{method:e.method});const t=this._routes.get(e.method).indexOf(e);if(t>-1)this._routes.get(e.method).splice(t,1);else throw new u("unregister-route-route-not-registered")}},x;const Xe=()=>(x||(x=new Qe,x.addFetchListener(),x.addCacheListener()),x);function Ye(s,e,t){let n;if(typeof s=="string"){const