2 lines
9.1 KiB
JavaScript
2 lines
9.1 KiB
JavaScript
var T="./assets/icon.2a39c64c.png";const A=["config.json","assets/theme-element.json","index.html"],R=["assets/icon.2a39c64c.png","assets/icon-maskable.965d12c4.png","assets/download-sandbox.48a866e9.html","assets/olm.b3e0f9b4.wasm","assets/olm.92f1ccd0.js","assets/element-logo-1551909733.1d59f06a.svg","assets/chevron-down-1956489915.3389f17f.svg","assets/enable-grid-2288309723.f83895c8.svg","assets/plus-3937109722.5c243914.svg","assets/disable-grid-4240599831.c8dc25a1.svg","assets/settings-878939771.57cf3680.svg","assets/dismiss-2476348673.d0f98560.svg","assets/clear-4137897294.7b90e8df.svg","assets/search-261439583.1bffaca1.svg","assets/chevron-right-2390431650.ec9bf561.svg","assets/chevron-left-2611498805.b5555a61.svg","assets/vertical-ellipsis-487061581.e7709afd.svg","assets/paperclip-3961996319.da562307.svg","assets/send-3413346515.b0fb8626.svg","assets/room-members-3084360280.6f64aaef.svg","assets/dismiss-2743697487.2f1a17f1.svg","assets/chevron-small-4098047679.489e66cc.svg","assets/encryption-status-3449529405.c200a9bb.svg","assets/e2ee-disabled-1470792300.6863c16d.svg","assets/chevron-thin-left-3078630092.d0d143e3.svg","assets/e2ee-normal-1448349558.af8f5484.svg","assets/chevron-down-3300400168.d1a083a1.svg","assets/settings-2175246113.00804666.svg","assets/element-logo-703176763.fc54fc8d.svg","assets/plus-4190356069.084c5e3d.svg","assets/disable-grid-3304422220.8a79cfcb.svg","assets/search-3263540198.1511780c.svg","assets/clear-426756705.361f7a30.svg","assets/chevron-left-3506338632.4e437777.svg","assets/chevron-right-847198822.23380c56.svg","assets/enable-grid-2071838379.ab4f40c5.svg","assets/send-1171052351.caa5c494.svg","assets/vertical-ellipsis-3416547705.f619a721.svg","assets/chevron-small-781914114.936b4943.svg","assets/room-members-3847743605.9fcf4567.svg","assets/encryption-status-475927392.2fedc0bd.svg","assets/chevron-thin-left-3831175135.13f60c05.svg","assets/paperclip-2441131778.1f5e29f3.svg","assets/index.c4bc713f.js","assets/theme-element-runtime.8f0a458e.css","assets/theme-element-dark.4718033a.css","assets/theme-element-light.0779c91e.css","assets/chevron-down.9a7440b9.svg","assets/element-logo.86bc8565.svg","assets/enable-grid.eef43c65.svg","assets/settings.45b8e09f.svg","assets/plus.49560f96.svg","assets/disable-grid.371ceaaa.svg","assets/search.21e0fd39.svg","assets/clear.0d180c33.svg","assets/chevron-left.b8b2c5fc.svg","assets/chevron-right.885731d1.svg","assets/vertical-ellipsis.70ab5d25.svg","assets/send.7a090949.svg","assets/paperclip.ec29fd9d.svg","assets/chevron-small.dfd7e618.svg","assets/room-members.35ed0bf9.svg","assets/encryption-status.8054183e.svg","assets/e2ee-normal.bef76bd4.svg","assets/e2ee-disabled.8507165d.svg","assets/chevron-thin-left.d111869b.svg"],_=["assets/main.bdb9a925.js","assets/olm_legacy.9dc48f49.js","assets/Inter-Thin.5d8e2ac4.woff2","assets/Inter-ExtraLight.da47c335.woff2","assets/Inter-ThinItalic.6b3ded18.woff2","assets/Inter-Light.0f7dfe72.woff2","assets/Inter-ExtraLightItalic.b3f94cfe.woff2","assets/Inter-Italic.bab4e808.woff2","assets/Inter-LightItalic.125c7e6a.woff2","assets/Inter-Medium.5d308f3d.woff2","assets/Inter-Regular.89d406b0.woff2","assets/Inter-MediumItalic.76551c20.woff2","assets/Inter-SemiBold.c7c3befe.woff2","assets/Inter-Bold.6f5e9a23.woff2","assets/Inter-ExtraBold.0ef4267e.woff2","assets/Inter-SemiBoldItalic.d376ade4.woff2","assets/Inter-BoldItalic.e09dcbe1.woff2","assets/Inter-Black.7f1f5616.woff2","assets/Inter-ExtraBoldItalic.d1e1f6a0.woff2","assets/Inter-BlackItalic.72d5983b.woff2","assets/Inter-Thin.5565b01e.woff","assets/Inter-ExtraLight.d7be68a4.woff","assets/Inter-ThinItalic.c413497b.woff","assets/Inter-ExtraLightItalic.762fa4d2.woff","assets/Inter-Light.38326098.woff","assets/Inter-Italic.7b187d57.woff","assets/Inter-LightItalic.ec6c76a8.woff","assets/Inter-Medium.0fc5d904.woff","assets/Inter-Regular.5b3a854b.woff","assets/Inter-MediumItalic.1458af9d.woff","assets/Inter-SemiBold.04cd699f.woff","assets/Inter-Bold.20d46cff.woff","assets/Inter-ExtraBold.45bae435.woff","assets/Inter-BoldItalic.31a185fa.woff","assets/Inter-Black.067c82f7.woff","assets/Inter-SemiBoldItalic.420db54a.woff","assets/Inter-BlackItalic.c628a2cf.woff","assets/Inter-ExtraBoldItalic.30a1af87.woff","assets/manifest.56e72e88.json"],m=`hydrogen-assets-${"323173231"}`,l="hydrogen-assets",y="hydrogen-media-thumbnails-v2";self.addEventListener("install",function(e){e.waitUntil((async()=>{await(await caches.open(m)).addAll(A);const a=await caches.open(l);await Promise.all(R.map(async n=>{await a.match(n)||await a.add(n)}))})())});self.addEventListener("activate",e=>{self.clients.claim(),e.waitUntil(k())});async function k(){const e=await caches.keys();for(const s of e)s!==m&&s!==l&&s!==y&&await caches.delete(s);const t=await caches.open(l),a=await t.keys(),n=R.concat(_).map(s=>new URL(s,self.registration.scope).href);for(const s of a)n.some(o=>o===s.url)||t.delete(s)}self.addEventListener("fetch",e=>{e.request.method==="GET"&&e.respondWith(I(e.request))});function E(e){if(e.pathname.startsWith("/_matrix/media/r0/thumbnail/")){const t=parseInt(e.searchParams.get("width"),10),a=parseInt(e.searchParams.get("height"),10);if(t<=50&&a<=50)return!0}return!1}const f=new URL(self.registration.scope);let d=new AbortController;async function I(e){try{if(e.url.includes("config.json")||/theme-.+\.json/.test(e.url))return D(e);const t=new URL(e.url);t.origin===f.origin&&t.pathname===f.pathname&&(e=new Request(new URL("index.html",f.href)));let a=await N(e);return a||(E(t)?a=await fetch(e,{signal:d.signal,mode:"cors",credentials:"omit"}):a=await fetch(e,{signal:d.signal}),await H(e,a)),a}catch(t){throw t.name!=="TypeError"&&t.name!=="AbortError"&&console.error("error in service worker",t),t}}async function D(e){let t=await N(e);const a=O(e);return t||await a}async function O(e){const t=await fetch(e,{signal:d.signal,headers:{"Cache-Control":"no-cache"}});return H(e,t.clone()),t}async function H(e,t){if(t.status>=400)return;const a=new URL(e.url),n=self.registration.scope;if(E(a))(await caches.open(y)).put(e,t.clone());else if(e.url.startsWith(n)){let s=e.url.substr(n.length),o;_.includes(s)?o=l:A.includes(s)&&(o=m),o&&await(await caches.open(o)).put(e,t.clone())}}async function N(e){let a=await(await caches.open(m)).match(e);if(a||(a=await(await caches.open(l)).match(e),a))return a;const s=new URL(e.url);if(E(s)){const o=await caches.open(y);a=await o.match(e),(a==null?void 0:a.status)>=400&&(await o.delete(e),a=null)}return a}self.addEventListener("message",e=>{var n;const t=s=>e.source.postMessage({replyTo:e.data.id,payload:s}),{replyTo:a}=e.data;if(a){const s=g.get(a);s&&(g.delete(a),s(e.data.payload))}else switch((n=e.data)==null?void 0:n.type){case"version":t({version:"0.3.1",buildHash:"323173231"});break;case"skipWaiting":self.skipWaiting();break;case"haltRequests":e.waitUntil(M().finally(()=>t()));break;case"closeSession":e.waitUntil(W(e.data.payload.sessionId,e.source.id).finally(()=>t()));break}});const p="new_message";async function F(e){if(e.notification.tag!==p){console.log("clicked notif with tag",e.notification.tag);return}const{sessionId:t,roomId:a}=e.notification.data,s=`${`#/session/${t}`}/room/${a}`,o=await b(async i=>await w(i,"hasSessionOpen",{sessionId:t}));if(o){if(console.log("notificationclick: client has session open, showing room there"),o.postMessage({type:"openRoom",payload:{roomId:a}}),"focus"in o)try{await o.focus()}catch(i){console.error(i)}}else if(self.clients.openWindow){console.log("notificationclick: no client found with session open, opening new window");const i=new URL(`./${s}`,f).href;await self.clients.openWindow(i)}}self.addEventListener("notificationclick",e=>{e.notification.close(),e.waitUntil(F(e))});async function P(e){var n;console.log("got a push message",e);const t=e.session_id;let a=e.sender_display_name||e.sender;if(a&&e.event_id){const s=e.room_id;if(!!await b(async c=>{if(c.visibilityState==="visible"&&c.focused)return await w(c,"hasRoomOpen",{sessionId:t,roomId:s})})){console.log("client is focused, room is open, don't show notif");return}const i=Array.from(await self.registration.getNotifications({tag:p})),L=i.filter(c=>c.data.roomId===s).some(c=>c.data.multi),U=i.some(c=>!c.data.multi),r=e.room_name||e.room_alias;let C=!1,h,u;if(L){console.log("already have a multi message, don't do anything");return}else U?(console.log("showing multi message notification"),C=!0,h=r||a,u="New messages"):(console.log("showing new message notification"),r&&r!==a?h=`${a} in ${r}`:h=a,u=((n=e.content)==null?void 0:n.body)||"New message");await self.registration.showNotification(h,{body:u,data:{sessionId:t,roomId:s,multi:C},tag:p,badge:T})}}self.addEventListener("push",e=>{e.waitUntil(P(e.data.json()))});async function W(e,t){const a=await self.clients.matchAll();await Promise.all(a.map(async n=>{n.id!==t&&await w(n,"closeSession",{sessionId:e})}))}async function M(){const e=await self.clients.matchAll({type:"window"});await Promise.all(e.map(t=>w(t,"haltRequests"))),d.abort()}const g=new Map;let S=0;function w(e,t,a){S+=1;const n=S,s=new Promise(o=>{g.set(n,o)});return e.postMessage({type:t,id:n,payload:a}),s}async function b(e){const t=await self.clients.matchAll({type:"window"});for(const a of t)if(await e(a))return a}
|
|
//# sourceMappingURL=sw.js.map
|