fedipod-server 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,7 +12,7 @@
12
12
  <link rel="modulepreload" crossorigin href="../assets/chunk-aKtaBQYM.js">
13
13
  <link rel="modulepreload" crossorigin href="../assets/pwa-viewport-ogKbF51K.js">
14
14
 
15
- <link rel="manifest" href="./manifest.webmanifest"></head>
15
+ <link rel="manifest" href="./manifest.webmanifest"><script id="vite-plugin-pwa:inline-sw">if('serviceWorker' in navigator) {window.addEventListener('load', () => {navigator.serviceWorker.register('./sw.js', { scope: './' })})}</script></head>
16
16
  <body>
17
17
  <div id="app-standalone"></div>
18
18
  <div id="modal-container"></div>
@@ -65,7 +65,7 @@
65
65
  <link rel="modulepreload" crossorigin href="./assets/ICONS-DIPJeU0C.js">
66
66
  <link rel="modulepreload" crossorigin href="./assets/ScheduledAtField-D-Abfo4J.js">
67
67
 
68
- <link rel="manifest" href="./manifest.webmanifest"></head>
68
+ <link rel="manifest" href="./manifest.webmanifest"><script id="vite-plugin-pwa:inline-sw">if('serviceWorker' in navigator) {window.addEventListener('load', () => {navigator.serviceWorker.register('./sw.js', { scope: './' })})}</script></head>
69
69
  <body>
70
70
  <div id="app"></div>
71
71
  <div id="modal-container"></div>
package/phanpy/dist/sw.js CHANGED
@@ -1,25 +1,2 @@
1
- // sw.js — kill-switch replacing the service worker Phanpy's build installed.
2
- //
3
- // A registered worker outlives the page that registered it and keeps answering
4
- // navigations from its precache, replaying the response headers it stored at
5
- // install time. That made a header change (the CSP script-src hash) invisible
6
- // to any browser that had already installed it, with no way for the server to
7
- // correct itself. Browsers re-fetch this file on navigation and install what
8
- // they find, so old installs land here and clean themselves up; new visitors
9
- // register nothing, because the HTML no longer calls register().
10
- //
11
- // No fetch handler on purpose: a worker without one does not intercept
12
- // requests at all, so pages go straight to the network while this runs.
13
-
14
- self.addEventListener('install', () => self.skipWaiting());
15
-
16
- self.addEventListener('activate', (event) => {
17
- event.waitUntil((async () => {
18
- for (const key of await caches.keys()) await caches.delete(key);
19
- await self.registration.unregister();
20
- // Take the open tabs off the dead worker without waiting for the user.
21
- for (const client of await self.clients.matchAll({ type: 'window' })) {
22
- try { await client.navigate(client.url); } catch { /* tab will refresh on its own */ }
23
- }
24
- })());
25
- });
1
+ try{self[`workbox:core:7.4.0`]&&_()}catch{}var e=(e,...t)=>{let n=e;return t.length>0&&(n+=` :: ${JSON.stringify(t)}`),n},t=class extends Error{constructor(t,n){let r=e(t,n);super(r),this.name=t,this.details=n}},n=e=>new URL(String(e),location.href).href.replace(RegExp(`^${location.origin}`),``);try{self[`workbox:cacheable-response:7.4.0`]&&_()}catch{}var r=class{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(t=>e.headers.get(t)===this._headers[t])),t}},i=class{constructor(e){this.cacheWillUpdate=async({response:e})=>this._cacheableResponse.isResponseCacheable(e)?e:null,this._cacheableResponse=new r(e)}};function a(e){e.then(()=>{})}var o=(e,t)=>t.some(t=>e instanceof t),s,c;function l(){return s||=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]}function u(){return c||=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey]}var d=new WeakMap,f=new WeakMap,p=new WeakMap,m=new WeakMap,h=new WeakMap;function g(e){let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener(`success`,i),e.removeEventListener(`error`,a)},i=()=>{t(b(e.result)),r()},a=()=>{n(e.error),r()};e.addEventListener(`success`,i),e.addEventListener(`error`,a)});return t.then(t=>{t instanceof IDBCursor&&d.set(t,e)}).catch(()=>{}),h.set(t,e),t}function ee(e){if(f.has(e))return;let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener(`complete`,i),e.removeEventListener(`error`,a),e.removeEventListener(`abort`,a)},i=()=>{t(),r()},a=()=>{n(e.error||new DOMException(`AbortError`,`AbortError`)),r()};e.addEventListener(`complete`,i),e.addEventListener(`error`,a),e.addEventListener(`abort`,a)});f.set(e,t)}var v={get(e,t,n){if(e instanceof IDBTransaction){if(t===`done`)return f.get(e);if(t===`objectStoreNames`)return e.objectStoreNames||p.get(e);if(t===`store`)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return b(e[t])},set(e,t,n){return e[t]=n,!0},has(e,t){return e instanceof IDBTransaction&&(t===`done`||t===`store`)?!0:t in e}};function y(e){v=e(v)}function te(e){return e===IDBDatabase.prototype.transaction&&!(`objectStoreNames`in IDBTransaction.prototype)?function(t,...n){let r=e.call(x(this),t,...n);return p.set(r,t.sort?t.sort():[t]),b(r)}:u().includes(e)?function(...t){return e.apply(x(this),t),b(d.get(this))}:function(...t){return b(e.apply(x(this),t))}}function ne(e){return typeof e==`function`?te(e):(e instanceof IDBTransaction&&ee(e),o(e,l())?new Proxy(e,v):e)}function b(e){if(e instanceof IDBRequest)return g(e);if(m.has(e))return m.get(e);let t=ne(e);return t!==e&&(m.set(e,t),h.set(t,e)),t}var x=e=>h.get(e);function S(e,t,{blocked:n,upgrade:r,blocking:i,terminated:a}={}){let o=indexedDB.open(e,t),s=b(o);return r&&o.addEventListener(`upgradeneeded`,e=>{r(b(o.result),e.oldVersion,e.newVersion,b(o.transaction),e)}),n&&o.addEventListener(`blocked`,e=>n(e.oldVersion,e.newVersion,e)),s.then(e=>{a&&e.addEventListener(`close`,()=>a()),i&&e.addEventListener(`versionchange`,e=>i(e.oldVersion,e.newVersion,e))}).catch(()=>{}),s}function re(e,{blocked:t}={}){let n=indexedDB.deleteDatabase(e);return t&&n.addEventListener(`blocked`,e=>t(e.oldVersion,e)),b(n).then(()=>void 0)}var ie=[`get`,`getKey`,`getAll`,`getAllKeys`,`count`],ae=[`put`,`add`,`delete`,`clear`],C=new Map;function w(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t==`string`))return;if(C.get(t))return C.get(t);let n=t.replace(/FromIndex$/,``),r=t!==n,i=ae.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(i||ie.includes(n)))return;let a=async function(e,...t){let a=this.transaction(e,i?`readwrite`:`readonly`),o=a.store;return r&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),i&&a.done]))[0]};return C.set(t,a),a}y(e=>({...e,get:(t,n,r)=>w(t,n)||e.get(t,n,r),has:(t,n)=>!!w(t,n)||e.has(t,n)}));try{self[`workbox:expiration:7.4.0`]&&_()}catch{}var oe=`workbox-expiration`,T=`cache-entries`,E=e=>{let t=new URL(e,location.href);return t.hash=``,t.href},se=class{constructor(e){this._db=null,this._cacheName=e}_upgradeDb(e){let t=e.createObjectStore(T,{keyPath:`id`});t.createIndex(`cacheName`,`cacheName`,{unique:!1}),t.createIndex(`timestamp`,`timestamp`,{unique:!1})}_upgradeDbAndDeleteOldDbs(e){this._upgradeDb(e),this._cacheName&&re(this._cacheName)}async setTimestamp(e,t){e=E(e);let n={url:e,timestamp:t,cacheName:this._cacheName,id:this._getId(e)},r=(await this.getDb()).transaction(T,`readwrite`,{durability:`relaxed`});await r.store.put(n),await r.done}async getTimestamp(e){return(await(await this.getDb()).get(T,this._getId(e)))?.timestamp}async expireEntries(e,t){let n=await this.getDb(),r=await n.transaction(T).store.index(`timestamp`).openCursor(null,`prev`),i=[],a=0;for(;r;){let n=r.value;n.cacheName===this._cacheName&&(e&&n.timestamp<e||t&&a>=t?i.push(r.value):a++),r=await r.continue()}let o=[];for(let e of i)await n.delete(T,e.id),o.push(e.url);return o}_getId(e){return this._cacheName+`|`+E(e)}async getDb(){return this._db||=await S(oe,1,{upgrade:this._upgradeDbAndDeleteOldDbs.bind(this)}),this._db}},ce=class{constructor(e,t={}){this._isRunning=!1,this._rerunRequested=!1,this._maxEntries=t.maxEntries,this._maxAgeSeconds=t.maxAgeSeconds,this._matchOptions=t.matchOptions,this._cacheName=e,this._timestampModel=new se(e)}async expireEntries(){if(this._isRunning){this._rerunRequested=!0;return}this._isRunning=!0;let e=this._maxAgeSeconds?Date.now()-this._maxAgeSeconds*1e3:0,t=await this._timestampModel.expireEntries(e,this._maxEntries),n=await self.caches.open(this._cacheName);for(let e of t)await n.delete(e,this._matchOptions);this._isRunning=!1,this._rerunRequested&&(this._rerunRequested=!1,a(this.expireEntries()))}async updateTimestamp(e){await this._timestampModel.setTimestamp(e,Date.now())}async isURLExpired(e){if(this._maxAgeSeconds){let t=await this._timestampModel.getTimestamp(e),n=Date.now()-this._maxAgeSeconds*1e3;return t===void 0?!0:t<n}else return!1}async delete(){this._rerunRequested=!1,await this._timestampModel.expireEntries(1/0)}},D={googleAnalytics:`googleAnalytics`,precache:`precache-v2`,prefix:`workbox`,runtime:`runtime`,suffix:typeof registration<`u`?registration.scope:``},O=e=>[D.prefix,e,D.suffix].filter(e=>e&&e.length>0).join(`-`),le=e=>{for(let t of Object.keys(D))e(t)},k={updateDetails:e=>{le(t=>{typeof e[t]==`string`&&(D[t]=e[t])})},getGoogleAnalyticsName:e=>e||O(D.googleAnalytics),getPrecacheName:e=>e||O(D.precache),getPrefix:()=>D.prefix,getRuntimeName:e=>e||O(D.runtime),getSuffix:()=>D.suffix},A=new Set;function j(e){A.add(e)}var M=class{constructor(e={}){this.cachedResponseWillBeUsed=async({event:e,request:t,cacheName:n,cachedResponse:r})=>{if(!r)return null;let i=this._isResponseDateFresh(r),o=this._getCacheExpiration(n);a(o.expireEntries());let s=o.updateTimestamp(t.url);if(e)try{e.waitUntil(s)}catch{}return i?r:null},this.cacheDidUpdate=async({cacheName:e,request:t})=>{let n=this._getCacheExpiration(e);await n.updateTimestamp(t.url),await n.expireEntries()},this._config=e,this._maxAgeSeconds=e.maxAgeSeconds,this._cacheExpirations=new Map,e.purgeOnQuotaError&&j(()=>this.deleteCacheAndMetadata())}_getCacheExpiration(e){if(e===k.getRuntimeName())throw new t(`expire-custom-caches-only`);let n=this._cacheExpirations.get(e);return n||(n=new ce(e,this._config),this._cacheExpirations.set(e,n)),n}_isResponseDateFresh(e){if(!this._maxAgeSeconds)return!0;let t=this._getDateHeaderTimestamp(e);return t===null?!0:t>=Date.now()-this._maxAgeSeconds*1e3}_getDateHeaderTimestamp(e){if(!e.headers.has(`date`))return null;let t=e.headers.get(`date`),n=new Date(t).getTime();return isNaN(n)?null:n}async deleteCacheAndMetadata(){for(let[e,t]of this._cacheExpirations)await self.caches.delete(e),await t.delete();this._cacheExpirations=new Map}};try{self[`workbox:navigation-preload:7.4.0`]&&_()}catch{}function N(){return!!(self.registration&&self.registration.navigationPreload)}function ue(e){N()&&self.addEventListener(`activate`,t=>{t.waitUntil(self.registration.navigationPreload.enable().then(()=>{e&&self.registration.navigationPreload.setHeaderValue(e)}))})}try{self[`workbox:routing:7.4.0`]&&_()}catch{}var P=e=>e&&typeof e==`object`?e:{handle:e},F=class{constructor(e,t,n=`GET`){this.handler=P(t),this.match=e,this.method=n}setCatchHandler(e){this.catchHandler=P(e)}},I=class extends F{constructor(e,t,n){super(({url:t})=>{let n=e.exec(t.href);if(n&&!(t.origin!==location.origin&&n.index!==0))return n.slice(1)},t,n)}},L=class{constructor(){this._routes=new Map,this._defaultHandlerMap=new Map}get routes(){return this._routes}addFetchListener(){self.addEventListener(`fetch`,(e=>{let{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`){let{payload:t}=e.data,n=Promise.all(t.urlsToCache.map(t=>{typeof t==`string`&&(t=[t]);let n=new Request(...t);return this.handleRequest({request:n,event:e})}));e.waitUntil(n),e.ports&&e.ports[0]&&n.then(()=>e.ports[0].postMessage(!0))}}))}handleRequest({request:e,event:t}){let n=new URL(e.url,location.href);if(!n.protocol.startsWith(`http`))return;let r=n.origin===location.origin,{params:i,route:a}=this.findMatchingRoute({event:t,request:e,sameOrigin:r,url:n}),o=a&&a.handler,s=e.method;if(!o&&this._defaultHandlerMap.has(s)&&(o=this._defaultHandlerMap.get(s)),!o)return;let c;try{c=o.handle({url:n,request:e,event:t,params:i})}catch(e){c=Promise.reject(e)}let l=a&&a.catchHandler;return c instanceof Promise&&(this._catchHandler||l)&&(c=c.catch(async r=>{if(l)try{return await l.handle({url:n,request:e,event:t,params:i})}catch(e){e instanceof Error&&(r=e)}if(this._catchHandler)return this._catchHandler.handle({url:n,request:e,event:t});throw r})),c}findMatchingRoute({url:e,sameOrigin:t,request:n,event:r}){let i=this._routes.get(n.method)||[];for(let a of i){let i,o=a.match({url:e,sameOrigin:t,request:n,event:r});if(o)return i=o,(Array.isArray(i)&&i.length===0||o.constructor===Object&&Object.keys(o).length===0||typeof o==`boolean`)&&(i=void 0),{route:a,params:i}}return{}}setDefaultHandler(e,t=`GET`){this._defaultHandlerMap.set(t,P(e))}setCatchHandler(e){this._catchHandler=P(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 t(`unregister-route-but-not-found-with-method`,{method:e.method});let n=this._routes.get(e.method).indexOf(e);if(n>-1)this._routes.get(e.method).splice(n,1);else throw new t(`unregister-route-route-not-registered`)}},R,z=()=>(R||(R=new L,R.addFetchListener(),R.addCacheListener()),R);function B(e,n,r){let i;if(typeof e==`string`){let t=new URL(e,location.href);i=new F(({url:e})=>e.href===t.href,n,r)}else if(e instanceof RegExp)i=new I(e,n,r);else if(typeof e==`function`)i=new F(e,n,r);else if(e instanceof F)i=e;else throw new t(`unsupported-route-type`,{moduleName:`workbox-routing`,funcName:`registerRoute`,paramName:`capture`});return z().registerRoute(i),i}try{self[`workbox:strategies:7.4.0`]&&_()}catch{}var V={cacheWillUpdate:async({response:e})=>e.status===200||e.status===0?e:null};function H(e,t){let n=new URL(e);for(let e of t)n.searchParams.delete(e);return n.href}async function U(e,t,n,r){let i=H(t.url,n);if(t.url===i)return e.match(t,r);let a=Object.assign(Object.assign({},r),{ignoreSearch:!0}),o=await e.keys(t,a);for(let t of o)if(i===H(t.url,n))return e.match(t,r)}var de=class{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}};async function fe(){for(let e of A)await e()}function pe(e){return new Promise(t=>setTimeout(t,e))}function W(e){return typeof e==`string`?new Request(e):e}var me=class{constructor(e,t){this._cacheKeys={},Object.assign(this,t),this.event=t.event,this._strategy=e,this._handlerDeferred=new de,this._extendLifetimePromises=[],this._plugins=[...e.plugins],this._pluginStateMap=new Map;for(let e of this._plugins)this._pluginStateMap.set(e,{});this.event.waitUntil(this._handlerDeferred.promise)}async fetch(e){let{event:n}=this,r=W(e);if(r.mode===`navigate`&&n instanceof FetchEvent&&n.preloadResponse){let e=await n.preloadResponse;if(e)return e}let i=this.hasCallback(`fetchDidFail`)?r.clone():null;try{for(let e of this.iterateCallbacks(`requestWillFetch`))r=await e({request:r.clone(),event:n})}catch(e){if(e instanceof Error)throw new t(`plugin-error-request-will-fetch`,{thrownErrorMessage:e.message})}let a=r.clone();try{let e;e=await fetch(r,r.mode===`navigate`?void 0:this._strategy.fetchOptions);for(let t of this.iterateCallbacks(`fetchDidSucceed`))e=await t({event:n,request:a,response:e});return e}catch(e){throw i&&await this.runCallbacks(`fetchDidFail`,{error:e,event:n,originalRequest:i.clone(),request:a.clone()}),e}}async fetchAndCachePut(e){let t=await this.fetch(e),n=t.clone();return this.waitUntil(this.cachePut(e,n)),t}async cacheMatch(e){let t=W(e),n,{cacheName:r,matchOptions:i}=this._strategy,a=await this.getCacheKey(t,`read`),o=Object.assign(Object.assign({},i),{cacheName:r});n=await caches.match(a,o);for(let e of this.iterateCallbacks(`cachedResponseWillBeUsed`))n=await e({cacheName:r,matchOptions:i,cachedResponse:n,request:a,event:this.event})||void 0;return n}async cachePut(e,r){let i=W(e);await pe(0);let a=await this.getCacheKey(i,`write`);if(!r)throw new t(`cache-put-with-no-response`,{url:n(a.url)});let o=await this._ensureResponseSafeToCache(r);if(!o)return!1;let{cacheName:s,matchOptions:c}=this._strategy,l=await self.caches.open(s),u=this.hasCallback(`cacheDidUpdate`),d=u?await U(l,a.clone(),[`__WB_REVISION__`],c):null;try{await l.put(a,u?o.clone():o)}catch(e){if(e instanceof Error)throw e.name===`QuotaExceededError`&&await fe(),e}for(let e of this.iterateCallbacks(`cacheDidUpdate`))await e({cacheName:s,oldResponse:d,newResponse:o.clone(),request:a,event:this.event});return!0}async getCacheKey(e,t){let n=`${e.url} | ${t}`;if(!this._cacheKeys[n]){let r=e;for(let e of this.iterateCallbacks(`cacheKeyWillBeUsed`))r=W(await e({mode:t,request:r,event:this.event,params:this.params}));this._cacheKeys[n]=r}return this._cacheKeys[n]}hasCallback(e){for(let t of this._strategy.plugins)if(e in t)return!0;return!1}async runCallbacks(e,t){for(let n of this.iterateCallbacks(e))await n(t)}*iterateCallbacks(e){for(let t of this._strategy.plugins)if(typeof t[e]==`function`){let n=this._pluginStateMap.get(t);yield r=>{let i=Object.assign(Object.assign({},r),{state:n});return t[e](i)}}}waitUntil(e){return this._extendLifetimePromises.push(e),e}async doneWaiting(){for(;this._extendLifetimePromises.length;){let e=this._extendLifetimePromises.splice(0),t=(await Promise.allSettled(e)).find(e=>e.status===`rejected`);if(t)throw t.reason}}destroy(){this._handlerDeferred.resolve(null)}async _ensureResponseSafeToCache(e){let t=e,n=!1;for(let e of this.iterateCallbacks(`cacheWillUpdate`))if(t=await e({request:this.request,response:t,event:this.event})||void 0,n=!0,!t)break;return n||t&&t.status!==200&&(t=void 0),t}},G=class{constructor(e={}){this.cacheName=k.getRuntimeName(e.cacheName),this.plugins=e.plugins||[],this.fetchOptions=e.fetchOptions,this.matchOptions=e.matchOptions}handle(e){let[t]=this.handleAll(e);return t}handleAll(e){e instanceof FetchEvent&&(e={event:e,request:e.request});let t=e.event,n=typeof e.request==`string`?new Request(e.request):e.request,r=`params`in e?e.params:void 0,i=new me(this,{event:t,request:n,params:r}),a=this._getResponse(i,n,t);return[a,this._awaitComplete(a,i,n,t)]}async _getResponse(e,n,r){await e.runCallbacks(`handlerWillStart`,{event:r,request:n});let i;try{if(i=await this._handle(n,e),!i||i.type===`error`)throw new t(`no-response`,{url:n.url})}catch(t){if(t instanceof Error){for(let a of e.iterateCallbacks(`handlerDidError`))if(i=await a({error:t,event:r,request:n}),i)break}if(!i)throw t}for(let t of e.iterateCallbacks(`handlerWillRespond`))i=await t({event:r,request:n,response:i});return i}async _awaitComplete(e,t,n,r){let i,a;try{i=await e}catch{}try{await t.runCallbacks(`handlerDidRespond`,{event:r,request:n,response:i}),await t.doneWaiting()}catch(e){e instanceof Error&&(a=e)}if(await t.runCallbacks(`handlerDidComplete`,{event:r,request:n,response:i,error:a}),t.destroy(),a)throw a}},K=class extends G{constructor(e={}){super(e),this.plugins.some(e=>`cacheWillUpdate`in e)||this.plugins.unshift(V)}async _handle(e,n){let r=n.fetchAndCachePut(e).catch(()=>{});n.waitUntil(r);let i=await n.cacheMatch(e),a;if(!i)try{i=await r}catch(e){e instanceof Error&&(a=e)}if(!i)throw new t(`no-response`,{url:e.url,error:a});return i}},q=class extends G{async _handle(e,n){let r=await n.cacheMatch(e),i;if(!r)try{r=await n.fetchAndCachePut(e)}catch(e){e instanceof Error&&(i=e)}if(!r)throw new t(`no-response`,{url:e.url,error:i});return r}};try{self[`workbox:recipes:7.4.0`]&&_()}catch{}function he(e){self.addEventListener(`install`,t=>{let n=e.urls.map(n=>e.strategy.handleAll({event:t,request:new Request(n)})[1]);t.waitUntil(Promise.all(n))})}var J=class extends G{constructor(e={}){super(e),this.plugins.some(e=>`cacheWillUpdate`in e)||this.plugins.unshift(V),this._networkTimeoutSeconds=e.networkTimeoutSeconds||0}async _handle(e,n){let r=[],i=[],a;if(this._networkTimeoutSeconds){let{id:t,promise:o}=this._getTimeoutPromise({request:e,logs:r,handler:n});a=t,i.push(o)}let o=this._getNetworkPromise({timeoutId:a,request:e,logs:r,handler:n});i.push(o);let s=await n.waitUntil((async()=>await n.waitUntil(Promise.race(i))||await o)());if(!s)throw new t(`no-response`,{url:e.url});return s}_getTimeoutPromise({request:e,logs:t,handler:n}){let r;return{promise:new Promise(t=>{r=setTimeout(async()=>{t(await n.cacheMatch(e))},this._networkTimeoutSeconds*1e3)}),id:r}}async _getNetworkPromise({timeoutId:e,request:t,logs:n,handler:r}){let i,a;try{a=await r.fetchAndCachePut(t)}catch(e){e instanceof Error&&(i=e)}return e&&clearTimeout(e),(i||!a)&&(a=await r.cacheMatch(t)),a}};function ge(e={}){let t=({request:e})=>e.mode===`navigate`,n=e.cacheName||`pages`,r=e.matchCallback||t,a=e.networkTimeoutSeconds||3,o=e.plugins||[];o.push(new i({statuses:[0,200]}));let s=new J({networkTimeoutSeconds:a,cacheName:n,plugins:o});B(r,s),e.warmCache&&he({urls:e.warmCache,strategy:s})}try{self[`workbox:precaching:7.4.0`]&&_()}catch{}var Y;function _e(){if(Y===void 0){let e=new Response(``);if(`body`in e)try{new Response(e.body),Y=!0}catch{Y=!1}Y=!1}return Y}async function ve(e,n){let r=null;if(e.url&&(r=new URL(e.url).origin),r!==self.location.origin)throw new t(`cross-origin-copy-response`,{origin:r});let i=e.clone(),a={headers:new Headers(i.headers),status:i.status,statusText:i.statusText},o=n?n(a):a,s=_e()?i.body:await i.blob();return new Response(s,o)}var X=class e extends G{constructor(t={}){t.cacheName=k.getPrecacheName(t.cacheName),super(t),this._fallbackToNetwork=t.fallbackToNetwork!==!1,this.plugins.push(e.copyRedirectedCacheableResponsesPlugin)}async _handle(e,t){return await t.cacheMatch(e)||(t.event&&t.event.type===`install`?await this._handleInstall(e,t):await this._handleFetch(e,t))}async _handleFetch(e,n){let r,i=n.params||{};if(this._fallbackToNetwork){let t=i.integrity,a=e.integrity,o=!a||a===t;r=await n.fetch(new Request(e,{integrity:e.mode===`no-cors`?void 0:a||t})),t&&o&&e.mode!==`no-cors`&&(this._useDefaultCacheabilityPluginIfNeeded(),await n.cachePut(e,r.clone()))}else throw new t(`missing-precache-entry`,{cacheName:this.cacheName,url:e.url});return r}async _handleInstall(e,n){this._useDefaultCacheabilityPluginIfNeeded();let r=await n.fetch(e);if(!await n.cachePut(e,r.clone()))throw new t(`bad-precaching-response`,{url:e.url,status:r.status});return r}_useDefaultCacheabilityPluginIfNeeded(){let t=null,n=0;for(let[r,i]of this.plugins.entries())i!==e.copyRedirectedCacheableResponsesPlugin&&(i===e.defaultPrecacheCacheabilityPlugin&&(t=r),i.cacheWillUpdate&&n++);n===0?this.plugins.push(e.defaultPrecacheCacheabilityPlugin):n>1&&t!==null&&this.plugins.splice(t,1)}};X.defaultPrecacheCacheabilityPlugin={async cacheWillUpdate({response:e}){return!e||e.status>=400?null:e}},X.copyRedirectedCacheableResponsesPlugin={async cacheWillUpdate({response:e}){return e.redirected?await ve(e):e}},ue(),self.__WB_DISABLE_DEV_LOGS=!0,self.addEventListener(`activate`,e=>{e.waitUntil(self.clients.claim())}),ge({warmCache:[`./compose/`]});var Z=class{constructor(e={}){this.maxHashes=e.maxHashes||2,this.dbName=`workbox-expiration`,this.storeName=`cache-entries`}_getBaseName(e){let t=new URL(e).pathname.split(`/`).pop().match(/^(.+?)-[A-Za-z0-9_-]{8,}\.(js|css)$/);return t?t[1]:null}async _getTimestampsFromDB(e,t){try{let n=await new Promise((e,t)=>{let n=indexedDB.open(this.dbName);n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),r=n.transaction(this.storeName,`readonly`).objectStore(this.storeName),i=await Promise.all(t.map(t=>{let n=`${e}|${t}`;return new Promise(e=>{let t=r.get(n);t.onsuccess=()=>e(t.result?.timestamp||Date.now()),t.onerror=()=>e(Date.now())})}));return n.close(),i}catch(e){return console.warn(`[AssetHashPlugin] Error reading timestamps from IndexedDB:`,e),t.map(()=>Date.now())}}cacheDidUpdate({cacheName:e,request:t}){this._cleanupOldHashes(e,t.url)}async _cleanupOldHashes(e,t){try{let n=this._getBaseName(t);if(!n)return;let r=await caches.open(e),i=await r.keys(),a=[];for(let e of i)this._getBaseName(e.url)===n&&await r.match(e)&&a.push(e);if(a.length<=this.maxHashes)return;let o=a.map(e=>e.url),s=await this._getTimestampsFromDB(e,o),c=a.map((e,t)=>({request:e,url:e.url,timestamp:s[t]}));c.sort((e,t)=>t.timestamp-e.timestamp);let l=c.slice(this.maxHashes);for(let e of l)await r.delete(e.request),console.log(`[AssetHashPlugin] Deleted old hash: ${e.url}`)}catch(e){console.warn(`[AssetHashPlugin] Error during cleanup:`,e)}}},Q={purgeOnQuotaError:!0,matchOptions:{ignoreVary:!0}};B(new F(({request:e,sameOrigin:t})=>{let n=e.url.includes(`/icons/`);return t&&n},new q({cacheName:`icons`,plugins:[new Z({maxHashes:2}),new M({maxEntries:300,maxAgeSeconds:4320*60,...Q}),new i({statuses:[0,200]})]}))),B(new F(({request:e,sameOrigin:t})=>{let n=e.destination===`style`||e.destination===`script`,r=/-[0-9a-z-]{4,}\./i.test(e.url);return t&&n&&r},new K({cacheName:`assets`,plugins:[new Z({maxHashes:2}),new M({maxEntries:40,...Q}),new i({statuses:[0,200]})]}))),B(new F(({request:e,sameOrigin:t})=>{let n=!t,r=e.destination===`image`,i=e.url.includes(`/avatars/`),a=e.url.includes(`/custom/_emojis`),o=e.url.includes(`/emoji/`);return n&&r&&(i||a||o)},new q({cacheName:`remote-images`,plugins:[new M({maxEntries:30,...Q}),new i({statuses:[0,200]})]}))),B(new I(/^https?:\/\/[^\/]+\/api\/v\d+\/(custom_emojis|lists\/\d+|announcements)$/,new K({cacheName:`api-extended`,plugins:[new M({maxAgeSeconds:720*60,...Q}),new i({statuses:[0,200]})]}))),B(new F(({request:e})=>e.headers.get(`accept`)?.includes(`application/activity+json`),new K({cacheName:`activity-json`,plugins:[new M({maxEntries:30,maxAgeSeconds:3600,...Q}),new i({statuses:[0,200]})]}))),B(new I(/^https?:\/\/[^\/]+\/api\/v\d+\/(statuses\/\d+\/context)/,new J({cacheName:`api`,networkTimeoutSeconds:5,plugins:[new M({maxEntries:30,maxAgeSeconds:300,...Q}),new i({statuses:[0,200]})]}))),self.addEventListener(`push`,e=>{let{data:t}=e;if(t){let n=t.json();console.log(`PUSH payload`,n);let{access_token:r,title:i,body:a,icon:o,notification_id:s,notification_type:c,preferred_locale:l}=n;navigator.setAppBadge&&c===`mention`&&navigator.setAppBadge(1),e.waitUntil(self.registration.showNotification(i,{body:a,icon:o,dir:`auto`,badge:`/logo-badge-72.png`,lang:l,tag:s,timestamp:Date.now(),data:{access_token:r,notification_type:c}}))}}),self.addEventListener(`notificationclick`,e=>{let t=e.notification;console.log(`NOTIFICATION CLICK payload`,t);let{badge:n,body:r,data:i,dir:a,icon:o,lang:s,tag:c,timestamp:l,title:u}=t,{access_token:d,notification_type:f}=i,p=`/#/notifications?id=${c}&access_token=${btoa(d)}`;e.waitUntil((async()=>{let t=await self.clients.matchAll({type:`window`,includeUncontrolled:!0});if(console.log(`NOTIFICATION CLICK clients 1`,t),t.length&&`navigate`in t[0]){console.log(`NOTIFICATION CLICK clients 2`,t);let e=t.find(e=>e.focused||e.visibilityState===`visible`)||t[0];console.log(`NOTIFICATION CLICK navigate`,p),e?(console.log(`NOTIFICATION CLICK postMessage`,e),e.focus(),e.postMessage?.({type:`notification`,id:c,accessToken:d})):(console.log(`NOTIFICATION CLICK openWindow`,p),await self.clients.openWindow(p))}else console.log(`NOTIFICATION CLICK openWindow`,p),await self.clients.openWindow(p);await e.notification.close()})())});var $=null;self.addEventListener(`message`,e=>{console.log(`💪 SW received event`,e,$);let t=e.data?.type===`client-ready`&&e.source;t&&$&&(t.postMessage({type:`share-target`,data:$,action:`compose-with-shared-data`}),$=null)}),B(({url:e})=>e.pathname.endsWith(`/share`),async({request:e})=>{console.log(`💪 Handling share target POST request`,e);try{let t=await e.formData();$={title:t.get(`title`)||``,text:t.get(`text`)||``,url:t.get(`url`)||``,files:t.getAll(`files`),timestamp:Date.now()}}catch(e){console.error(e)}return Response.redirect(`./`,303)},`POST`);
2
+ //# sourceMappingURL=sw.js.map