From 26449dbf95973a91b6bb74cc8b098120b55d2557 Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Fri, 22 Aug 2025 22:35:36 -0700 Subject: [PATCH] Update vite.config.js --- vite.config.js | 82 +++++++++++++++++--------------------------------- 1 file changed, 27 insertions(+), 55 deletions(-) diff --git a/vite.config.js b/vite.config.js index 3e06d3d..541e81d 100644 --- a/vite.config.js +++ b/vite.config.js @@ -32,66 +32,38 @@ const html = createHtmlPlugin({ minify: false, inject: { tags: [ + { tag: 'meta', attrs: { charset: 'utf-8' }, injectTo: 'head' }, + { tag: 'title', children: 'Sune', injectTo: 'head' }, + { tag: 'link', attrs: { rel: 'icon', type: 'image/avif', href: 'https://sune.planetrenox.com/✺.avif' }, injectTo: 'head' }, + { tag: 'script', attrs: { src: 'https://cdn.jsdelivr.net/npm/tiny-ripple@0.2.0' }, injectTo: 'head' }, + { tag: 'style', children: ':root{--safe-bottom:env(safe-area-inset-bottom)}::-webkit-scrollbar{height:8px;width:8px}::-webkit-scrollbar-thumb{background:#e5e7eb;border-radius:999px}.no-scrollbar::-webkit-scrollbar{display:none}.no-scrollbar{-ms-overflow-style:none;scrollbar-width:none}', injectTo: 'head' }, { tag: 'script', children: `(function(){ - function h(v){try{return JSON.parse(v)}catch{return null}} - function isOR(url){try{var u=new URL(url,location.href);return /(^|\\.)openrouter\\.ai$/i.test(u.hostname)&&/\\/api\\/v1\\/chat\\/completions$/.test(u.pathname)}catch{return false}} - function hasStream(body){if(body==null)return false;try{if(typeof body==='string')return /"stream"\\s*:\\s*true/i.test(body);if(body instanceof Blob)return false;return false}catch{return false}} - function ensureHeaders(hdrs){if(hdrs instanceof Headers){return hdrs}var out=new Headers();if(Array.isArray(hdrs)){hdrs.forEach(function(p){out.append(p[0],p[1])});return out}if(hdrs&&typeof hdrs==='object'){Object.keys(hdrs).forEach(function(k){out.append(k,hdrs[k])});return out}return out} - function uid(){return 'swr-'+Math.random().toString(36).slice(2,10)} - var ofetch=window.fetch - window.fetch=function(input,init){ - try{ - var url=typeof input==='string'?input:(input&&input.url)||'' - var m=((init&&init.method)||(input&&input.method)||'GET').toUpperCase() - if(m==='POST'&&isOR(url)){ - var body=(init&&init.body)||null - if(hasStream(body)){ - var id=uid() - var hdrs=ensureHeaders(init&&init.headers) - hdrs.set('x-swr-id',id) - init=Object.assign({},init,{headers:hdrs}) - sessionStorage.setItem('swr:current',id) - sessionStorage.setItem('swr:seq:'+id,'0') - } - } - }catch{} - return ofetch.apply(this,arguments) + function r(f){if(document.readyState!=='loading')f();else document.addEventListener('DOMContentLoaded',f)} + function overlay(){ + var o=document.getElementById('sw-overlay'); if(o) return o + o=document.createElement('div'); o.id='sw-overlay' + Object.assign(o.style,{position:'fixed',top:'0',left:'0',right:'0',padding:'20px 24px',zIndex:'2147483647',background:'linear-gradient(90deg,#ff9800,#ffc107)',color:'#fff',textAlign:'center',font:'700 22px/1.2 system-ui,-apple-system,Segoe UI,Roboto,sans-serif',letterSpacing:'0.5px',boxShadow:'0 12px 28px rgba(0,0,0,.35)'}) + var s=document.createElement('span'); s.id='sw-overlay-text'; s.style.display='inline-block'; s.style.padding='4px 10px'; s.style.borderRadius='8px'; s.style.background='rgba(0,0,0,.25)' + var x=document.createElement('button'); x.textContent='×'; Object.assign(x.style,{position:'absolute',top:'8px',right:'12px',width:'36px',height:'36px',border:'0',borderRadius:'10px',background:'rgba(255,255,255,.15)',color:'#fff',fontSize:'24px',cursor:'pointer'}) + x.onclick=function(){o.remove()} + o.appendChild(s); o.appendChild(x); document.body.appendChild(o); return o } - function applyDelta(id,seq,delta){ - try{ - var list=document.querySelectorAll('.msg-bubble'); if(!list.length)return - var el=list[list.length-1] - var cur=el.__swr_text||'' - el.__swr_text=cur+String(delta||'') - if(window.markdownit){var md=window.markdownit({html:false,linkify:true,typographer:true,breaks:true});el.innerHTML=md.render(el.__swr_text)} - else{el.textContent=el.__swr_text} - sessionStorage.setItem('swr:seq:'+id,String(seq)) - }catch{} - } - function onMsg(e){ - var m=e&&e.data||{} - if(!m||!m.type)return - if(m.type==='SW_DELTA'){var id=m.id,seq=m.seq,delta=m.delta;if(id&&delta!=null)applyDelta(id,seq,delta)} - else if(m.type==='SW_DONE'){var id=m.id;if(id){sessionStorage.removeItem('swr:current')}} - } - if(navigator.serviceWorker){ - navigator.serviceWorker.addEventListener('message',onMsg) - function replay(){ - try{ - var id=sessionStorage.getItem('swr:current') - if(!id)return - var seq=sessionStorage.getItem('swr:seq:'+id)||'0' - var ctrl=navigator.serviceWorker.controller - if(ctrl) ctrl.postMessage({type:'SW_REPLAY',id,fromSeq:+seq}) - }catch{} - } - if(document.visibilityState==='visible'){ - navigator.serviceWorker.ready.then(function(){setTimeout(replay,0)}) - } - document.addEventListener('visibilitychange',function(){if(document.visibilityState==='visible') replay()},{passive:true}) + function setStatus(kind,msg){ + var o=overlay(), t=o.querySelector('#sw-overlay-text') + if(kind==='ok'){o.style.background='linear-gradient(90deg,#00c853,#00e5ff)'; t.textContent=msg||'SERVICE WORKER: ACTIVE'} + else if(kind==='fail'){o.style.background='linear-gradient(90deg,#c62828,#ad1457)'; t.textContent=msg||'SERVICE WORKER: NOT RUNNING'} + else {o.style.background='linear-gradient(90deg,#ff9800,#ffc107)'; t.textContent=msg||'SERVICE WORKER: WAITING'} } + r(function(){ + setStatus('wait','SERVICE WORKER: WAITING') + if(!('serviceWorker' in navigator)){setStatus('fail','NO SERVICE WORKER SUPPORT'); alert('NO SERVICE WORKER SUPPORT'); return} + var done=false + navigator.serviceWorker.addEventListener('message',function(){done=true; setStatus('ok','SERVICE WORKER: ACTIVE')}) + navigator.serviceWorker.ready.then(function(reg){if(reg&®.active) reg.active.postMessage({type:'PING',ts:Date.now()})}) + setTimeout(function(){if(!done){setStatus('fail','SERVICE WORKER: NOT RUNNING'); alert('SERVICE WORKER NOT RUNNING')}},3000) + }) })();`, injectTo: 'head' }