phanpy-cz/sw.js

3 lines
20 KiB
JavaScript
Raw Permalink Normal View History

try{self["workbox:core:7.2.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.2.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 E{constructor(e){this.cacheWillUpdate=async({response:t})=>this._cacheableResponse.isResponseCacheable(t)?t:null,this._cacheableResponse=new se(e)}}function q(s){s.then(()=>{})}const ne=(s,e)=>e.some(t=>s instanceof t);let B,W;function ae(){return B||(B=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function ie(){return W||(W=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const V=new WeakMap,S=new WeakMap,Q=new WeakMap,O=new WeakMap,P=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&&V.set(t,s)}).catch(()=>{}),P.set(e,s),e}function oe(s){if(S.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)});S.set(s,e)}let M={get(s,e,t){if(s instanceof IDBTransaction){if(e==="done")return S.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){M=s(M)}function le(s){return s===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const n=s.call(T(this),e,...t);return Q.set(n,e.sort?e.sort():[e]),f(n)}:ie().includes(s)?function(...e){return s.apply(T(this),e),f(V.get(this))}:function(...e){return f(s.apply(T(this),e))}}function he(s){return typeof s=="function"?le(s):(s instanceof IDBTransaction&&oe(s),ne(s,ae())?new Proxy(s,M):s)}function f(s){if(s instanceof IDBRequest)return re(s);if(O.has(s))return O.get(s);const e=he(s);return e!==s&&(O.set(s,e),P.set(e,s)),e}const T=s=>P.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"],N=new Map;function F(s,e){if(!(s instanceof IDBDatabase&&!(e in s)&&typeof e=="string"))return;if(N.get(e))return N.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 N.set(e,r),r}ce(s=>({...s,get:(e,t,n)=>F(e,t)||s.get(e,t,n),has:(e,t)=>!!F(e,t)||s.has(e,t)}));try{self["workbox:expiration:7.2.0"]&&_()}catch{}const me="workbox-expirat
2024-06-16 18:14:43 +00:00
//# sourceMappingURL=sw.js.map