sabayon
Version:
SharedArrayBuffer always on
2 lines (1 loc) • 612 B
JavaScript
const{isArray:t}=Array,e=new Map,n=t=>{t.stopImmediatePropagation(),t.preventDefault()},o=t=>t.waitUntil(clients.claim()),s=t=>{const{request:o}=t;"POST"===o.method&&o.url===`${location.href}?sabayon`&&(n(t),t.respondWith(new Promise((async t=>{const n=await o.json(),s=n.join(",");e.set(s,t);for(const t of await clients.matchAll())t.postMessage(n)})).then((t=>new Response(`[${t.join(",")}]`,o.headers)))))},a=()=>skipWaiting(),i=o=>{const{data:s}=o;if(t(s)&&4===s.length){const[t,a,i,r]=s,c=[t,a,i].join(","),l=e.get(c);l&&(n(o),l(r),e.delete(c))}};export{o as activate,s as fetch,a as install,i as message};