shlink-web-client/dependabot/npm_and_yarn/multi-ac08903459/service-worker.js

3 lines
30 KiB
JavaScript
Raw Normal View History

try{self["workbox:core:7.0.0"]&&_()}catch{}typeof registration<"u"&&registration.scope;function Y(){self.addEventListener("activate",()=>self.clients.claim())}try{self["workbox:core:7.0.0"]&&_()}catch{}const Z=(s,...e)=>{let t=s;return e.length>0&&(t+=` :: ${JSON.stringify(e)}`),t},ee=Z;let te=class extends Error{constructor(e,t){const n=ee(e,t);super(n),this.name=e,this.details=t}};function V(s){s.then(()=>{})}const se=(s,e)=>e.some(t=>s instanceof t);let W,B;function ne(){return W||(W=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function re(){return B||(B=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const G=new WeakMap,I=new WeakMap,J=new WeakMap,v=new WeakMap,K=new WeakMap;function ae(s){const e=new Promise((t,n)=>{const r=()=>{s.removeEventListener("success",a),s.removeEventListener("error",i)},a=()=>{t(p(s.result)),r()},i=()=>{n(s.error),r()};s.addEventListener("success",a),s.addEventListener("error",i)});return e.then(t=>{t instanceof IDBCursor&&G.set(t,s)}).catch(()=>{}),K.set(e,s),e}function ie(s){if(I.has(s))return;const e=new Promise((t,n)=>{const r=()=>{s.removeEventListener("complete",a),s.removeEventListener("error",i),s.removeEventListener("abort",i)},a=()=>{t(),r()},i=()=>{n(s.error||new DOMException("AbortError","AbortError")),r()};s.addEventListener("complete",a),s.addEventListener("error",i),s.addEventListener("abort",i)});I.set(s,e)}let A={get(s,e,t){if(s instanceof IDBTransaction){if(e==="done")return I.get(s);if(e==="objectStoreNames")return s.objectStoreNames||J.get(s);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return p(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 ce(s){A=s(A)}function oe(s){return s===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const n=s.call(D(this),e,...t);return J.set(n,e.sort?e.sort():[e]),p(n)}:re().includes(s)?function(...e){return s.apply(D(this),e),p(G.get(this))}:function(...e){return p(s.apply(D(this),e))}}function le(s){return typeof s=="function"?oe(s):(s instanceof IDBTransaction&&ie(s),se(s,ne())?new Proxy(s,A):s)}function p(s){if(s instanceof IDBRequest)return ae(s);if(v.has(s))return v.get(s);const e=le(s);return e!==s&&(v.set(s,e),K.set(e,s)),e}const D=s=>K.get(s);function he(s,e,{blocked:t,upgrade:n,blocking:r,terminated:a}={}){const i=indexedDB.open(s,e),c=p(i);return n&&i.addEventListener("upgradeneeded",o=>{n(p(i.result),o.oldVersion,o.newVersion,p(i.transaction),o)}),t&&i.addEventListener("blocked",o=>t(o.oldVersion,o.newVersion,o)),c.then(o=>{a&&o.addEventListener("close",()=>a()),r&&o.addEventListener("versionchange",l=>r(l.oldVersion,l.newVersion,l))}).catch(()=>{}),c}function ue(s,{blocked:e}={}){const t=indexedDB.deleteDatabase(s);return e&&t.addEventListener("blocked",n=>e(n.oldVersion,n)),p(t).then(()=>{})}const fe=["get","getKey","getAll","getAllKeys","count"],de=["put","add","delete","clear"],L=new Map;function $(s,e){if(!(s instanceof IDBDatabase&&!(e in s)&&typeof e=="string"))return;if(L.get(e))return L.get(e);const t=e.replace(/FromIndex$/,""),n=e!==t,r=de.includes(t);if(!(t in(n?IDBIndex:IDBObjectStore).prototype)||!(r||fe.includes(t)))return;const a=async function(i,...c){const o=this.transaction(i,r?"readwrite":"readonly");let l=o.store;return n&&(l=l.index(c.shift())),(await Promise.all([l[t](...c),r&&o.done]))[0]};return L.set(e,a),a}ce(s=>({...s,get:(e,t,n)=>$(e,t)||s.get(e,t,n),has:(e,t)=>!!$(e,t)||s.has(e,t)}));try{self["workbox:expiration:7.0.0"]&&_()}catch{}const pe="workbox-expiration",w="cache-entries",q=s=>{const e=new URL(s,location.href);return e.hash="",e.href};class ge{constructor(e){this._db=null,this._cacheName=e}_upgradeDb(e){const t=e.createObjectStore(w,{keyPath:"id"});t.createIndex("cacheName","cacheName",{unique:!1}),t.createIndex("timestamp","timestamp",{unique:!1})}_upgradeDbAndDeleteOldDbs(e){this._upgradeDb(e),this._cacheName&&ue(this._cacheName)}async setTimestamp(
This is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(c)}}}install(e){return F(e,async()=>{const t=new De;this.strategy.plugins.push(t);for(const[a,i]of this._urlsToCacheKeys){const c=this._cacheKeysToIntegrities.get(i),o=this._urlsToCacheModes.get(a),l=new Request(a,{integrity:c,cache:o,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:i},request:l,event:e}))}const{updatedURLs:n,notUpdatedURLs:r}=t;return{updatedURLs:n,notUpdatedURLs:r}})}activate(e){return F(e,async()=>{const t=await self.caches.open(this.strategy.cacheName),n=await t.keys(),r=new Set(this._urlsToCacheKeys.values()),a=[];for(const i of n)r.has(i.url)||(await t.delete(i),a.push(i.url));return{deletedURLs:a}})}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 m("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 P;const j=()=>(P||(P=new $e),P);try{self["workbox:core:7.0.0"]&&_()}catch{}const qe=(s,...e)=>{let t=s;return e.length>0&&(t+=` :: ${JSON.stringify(e)}`),t},Fe=qe;class M extends Error{constructor(e,t){const n=Fe(e,t);super(n),this.name=e,this.details=t}}try{self["workbox:routing:7.0.0"]&&_()}catch{}const X="GET",E=s=>s&&typeof s=="object"?s:{handle:s};class x{constructor(e,t,n=X){this.handler=E(t),this.match=e,this.method=n}setCatchHandler(e){this.catchHandler=E(e)}}class He extends x{constructor(e,t,n){const r=({url:a})=>{const i=e.exec(a.href);if(i&&!(a.origin!==location.origin&&i.index!==0))return i.slice(1)};super(r,t,n)}}class Ve{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 a=new Request(...r);return this.handleRequest({request:a,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:a,route:i}=this.findMatchingRoute({event:t,request:e,sameOrigin:r,url:n});let c=i&&i.handler;const o=e.method;if(!c&&this._defaultHandlerMap.has(o)&&(c=this._defaultHandlerMap.get(o)),!c)return;let l;try{l=c.handle({url:n,request:e,event:t,params:a})}catch(h){l=Promise.reject(h)}const y=i&&i.catchHandler;return l instanceof Promise&&(this._catchHandler||y)&&(l=l.catch(async h=>{if(y)try{return await y.handle({url:n,request:e,event:t,params:a})}catch(S){S instanceof Error&&(h=S)}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 a=this._routes.get(n.method)||[];for(const i of a){let c;const o=i.match({url:e,sameOrigin:t,request:n,event:r});if(o)return c=o,(Array.isArray(c)&&c.length===0||o.constructor===Object&&Object.keys(o).length===0||typeof o=="boolean")&&(c=void 0),{route:i,params:c}}return{}}setDefaultHandler(e,t=X){this._defaultHandlerMap.set(t,E(e))}setCatchHandler(e){this._catchHandler=E(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 M("unregister-route-but-not-found-with-method",{method:e.method});const t=this._routes.get(e.method).indexOf(e);if(t>-1)this._route