phanpy-cz/sw.js

3 lines
20 KiB
JavaScript
Raw Normal View History

2024-08-02 13:18:54 +00:00
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;class u extends Error{constructor(e,t){const n=ee(e,t);super(n),this.name=e,this.details=t}}const te=s=>new URL(String(s),location.href).href.replace(new RegExp(`^${location.origin}`),"");try{self["workbox:cacheable-response:7.0.0"]&&_()}catch{}class se{constructor(e={}){this._statuses=e.statuses,this._headers=e.headers}isResponseCacheable(e){let t=!0;return this._statuses&&(t=this._statuses.includes(e.status)),this._headers&&t&&(t=Object.keys(this._headers).some(n=>e.headers.get(n)===this._headers[n])),t}}class y{constructor(e){this.cacheWillUpdate=async({response:t})=>this._cacheableResponse.isResponseCacheable(t)?t:null,this._cacheableResponse=new se(e)}}function V(s){s.then(()=>{})}const ne=(s,e)=>e.some(t=>s instanceof t);let W,F;function ae(){return W||(W=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function ie(){return F||(F=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const $=new WeakMap,M=new WeakMap,Q=new WeakMap,N=new WeakMap,L=new WeakMap;function re(s){const e=new Promise((t,n)=>{const a=()=>{s.removeEventListener("success",r),s.removeEventListener("error",i)},r=()=>{t(f(s.result)),a()},i=()=>{n(s.error),a()};s.addEventListener("success",r),s.addEventListener("error",i)});return e.then(t=>{t instanceof IDBCursor&&$.set(t,s)}).catch(()=>{}),L.set(e,s),e}function oe(s){if(M.has(s))return;const e=new Promise((t,n)=>{const a=()=>{s.removeEventListener("complete",r),s.removeEventListener("error",i),s.removeEventListener("abort",i)},r=()=>{t(),a()},i=()=>{n(s.error||new DOMException("AbortError","AbortError")),a()};s.addEventListener("complete",r),s.addEventListener("error",i),s.addEventListener("abort",i)});M.set(s,e)}let P={get(s,e,t){if(s instanceof IDBTransaction){if(e==="done")return M.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 f(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){P=s(P)}function le(s){return s===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const n=s.call(O(this),e,...t);return Q.set(n,e.sort?e.sort():[e]),f(n)}:ie().includes(s)?function(...e){return s.apply(O(this),e),f($.get(this))}:function(...e){return f(s.apply(O(this),e))}}function he(s){return typeof s=="function"?le(s):(s instanceof IDBTransaction&&oe(s),ne(s,ae())?new Proxy(s,P):s)}function f(s){if(s instanceof IDBRequest)return re(s);if(N.has(s))return N.get(s);const e=he(s);return e!==s&&(N.set(s,e),L.set(e,s)),e}const O=s=>L.get(s);function ue(s,e,{blocked:t,upgrade:n,blocking:a,terminated:r}={}){const i=indexedDB.open(s,e),o=f(i);return n&&i.addEventListener("upgradeneeded",c=>{n(f(i.result),c.oldVersion,c.newVersion,f(i.transaction),c)}),t&&i.addEventListener("blocked",c=>t(c.oldVersion,c.newVersion,c)),o.then(c=>{r&&c.addEventListener("close",()=>r()),a&&c.addEventListener("versionchange",l=>a(l.oldVersion,l.newVersion,l))}).catch(()=>{}),o}function de(s,{blocked:e}={}){const t=indexedDB.deleteDatabase(s);return e&&t.addEventListener("blocked",n=>e(n.oldVersion,n)),f(t).then(()=>{})}const fe=["get","getKey","getAll","getAllKeys","count"],pe=["put","add","delete","clear"],A=new Map;function H(s,e){if(!(s instanceof IDBDatabase&&!(e in s)&&typeof e=="string"))return;if(A.get(e))return A.get(e);const t=e.replace(/FromIndex$/,""),n=e!==t,a=pe.includes(t);if(!(t in(n?IDBIndex:IDBObjectStore).prototype)||!(a||fe.includes(t)))return;const r=async function(i,...o){const c=this.transaction(i,a?"readwrite":"readonly");let l=c.store;return n&&(l=l.index(o.shift())),(await Promise.all([l[t](...o),a&&c.done]))[0]};return A.set(e,r),r}ce(s=>({...s,get:(e,t,n)=>H(e,t)||s.get(e,t,n),has:(e,t)=>!!H(e,t)||s.has(e,t)}));try{self["workbox:expiration:7.0.0"]&&_()}catch{}const me="workbox-expirat
2024-06-16 18:14:43 +00:00
//# sourceMappingURL=sw.js.map