diff --git a/.gitignore b/.gitignore index b398d22..4f2a0d2 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,6 @@ pnpm-debug.log* lerna-debug.log* node_modules -dist dist-ssr *.local diff --git a/docs/.nojekyll b/dist/.nojekyll similarity index 100% rename from docs/.nojekyll rename to dist/.nojekyll diff --git a/docs/.well-known/assetlinks.json b/dist/.well-known/assetlinks.json similarity index 100% rename from docs/.well-known/assetlinks.json rename to dist/.well-known/assetlinks.json diff --git a/docs/CNAME b/dist/CNAME similarity index 100% rename from docs/CNAME rename to dist/CNAME diff --git a/docs/appstore_content/screenshot1.jpg b/dist/appstore_content/screenshot1.jpg similarity index 100% rename from docs/appstore_content/screenshot1.jpg rename to dist/appstore_content/screenshot1.jpg diff --git a/docs/appstore_content/screenshot2.jpg b/dist/appstore_content/screenshot2.jpg similarity index 100% rename from docs/appstore_content/screenshot2.jpg rename to dist/appstore_content/screenshot2.jpg diff --git a/docs/appstore_content/screenshot3.jpg b/dist/appstore_content/screenshot3.jpg similarity index 100% rename from docs/appstore_content/screenshot3.jpg rename to dist/appstore_content/screenshot3.jpg diff --git a/docs/appstore_content/screenshot4.jpg b/dist/appstore_content/screenshot4.jpg similarity index 100% rename from docs/appstore_content/screenshot4.jpg rename to dist/appstore_content/screenshot4.jpg diff --git a/docs/appstore_content/screenshot5.jpg b/dist/appstore_content/screenshot5.jpg similarity index 100% rename from docs/appstore_content/screenshot5.jpg rename to dist/appstore_content/screenshot5.jpg diff --git a/docs/appstore_content/screenshot6.jpg b/dist/appstore_content/screenshot6.jpg similarity index 100% rename from docs/appstore_content/screenshot6.jpg rename to dist/appstore_content/screenshot6.jpg diff --git a/docs/appstore_content/✺.png b/dist/appstore_content/✺.png similarity index 100% rename from docs/appstore_content/✺.png rename to dist/appstore_content/✺.png diff --git a/docs/index.html b/dist/index.html similarity index 99% rename from docs/index.html rename to dist/index.html index 306fc3f..7e47f6d 100644 --- a/docs/index.html +++ b/dist/index.html @@ -231,7 +231,7 @@ window.addEventListener('resize',()=>{hideHistoryMenu();hideSuneMenu()}) init() const WS_BASE='wss://orp.awww.workers.dev/ws' const buildBody=()=>{const msgs=[];if(store.masterPrompt)msgs.push({role:'system',content:[{type:'text',text:store.masterPrompt}]});if(store.system_prompt)msgs.push({role:'system',content:[{type:'text',text:store.system_prompt}]});msgs.push(...state.messages.filter(m=>m.role!=='system').map(m=>({role:m.role,content:m.content})));const b=payloadWithSampling({model:store.model,messages:msgs,stream:true});if(store.reasoning_effort&&store.reasoning_effort!=='default')b.reasoning={effort:store.reasoning_effort};if(store.verbosity)b.verbosity=store.verbosity;return b} -async function askOpenRouterStreaming(onDelta,streamId){if(!store.apiKey){const t=localDemoReply();onDelta(t,true);return {ok:true,rid:streamId||null}}const r={rid:streamId||gid(),seq:-1,done:false,signaled:false,ws:null};const signal=t=>{if(!r.signaled){r.signaled=true;onDelta(t||'',true)}};const ws=new WebSocket(WS_BASE+'?uid='+encodeURIComponent(r.rid));r.ws=ws;ws.onopen=()=>ws.send(JSON.stringify({type:'begin',rid:r.rid,provider:store.provider,apiKey:store.apiKey,or_body:buildBody()}));ws.onmessage=e=>{let m;try{m=JSON.parse(e.data)}catch{return}if(m.type==='delta'&&typeof m.seq==='number'&&m.seq>r.seq){r.seq=m.seq;onDelta(m.text||'',false)}else if(m.type==='done'){r.done=true;signal('');ws.close()}else if(m.type==='err'){r.done=true;signal('\n\n'+(m.message||'error'));ws.close()}};ws.onclose=()=>{};ws.onerror=()=>{};state.controller={abort:()=>{r.done=true;try{ws.send(JSON.stringify({type:'stop',rid:r.rid}))}catch{}try{ws.close()}catch{}signal('')}};return {ok:true,rid:r.rid}} +async function askOpenRouterStreaming(onDelta,streamId){if(!store.apiKey){const t=localDemoReply();onDelta(t,true);return {ok:true,rid:streamId||null}}const r={rid:streamId||gid(),seq:-1,done:false,signaled:false,ws:null};const signal=t=>{if(!r.signaled){r.signaled=true;onDelta(t||'',true)}};const ws=new WebSocket(WS_BASE+'?uid='+encodeURIComponent(r.rid));r.ws=ws;ws.onopen=()=>ws.send(JSON.stringify({type:'begin',rid:r.rid,provider:store.provider,apiKey:store.apiKey,or_body:buildBody()}));ws.onmessage=e=>{let m;try{m=JSON.parse(e.data)}catch{return}if(m.type==='delta'&&typeof m.seq==='number'&&m.seq>r.seq){r.seq=m.seq;onDelta(m.text||'',false)}else if(m.type==='done'){r.done=true;signal('');ws.close()}else if(m.type==='err'){r.done=true;signal('\n\n'+(m.message||'error'));ws.close()}};ws.onclose=()=>{};ws.onerror=()=>{};state.controller={abort:()=>{r.done=true;try{if(ws.readyState===1)ws.send(JSON.stringify({type:'stop',rid:r.rid}))}catch{}signal('')}};return {ok:true,rid:r.rid}} function openAccountSettings(){el.set_provider.value=store.provider||'openrouter';el.set_api_key_or.value=store.apiKeyOR||'';el.set_api_key_oai.value=store.apiKeyOAI||'';el.set_master_prompt.value=store.masterPrompt||'';el.accountSettingsModal.classList.remove('hidden')} function closeAccountSettings(){el.accountSettingsModal.classList.add('hidden')} el.accountSettingsOption.addEventListener('click',()=>{el.userMenu.classList.add('hidden');openAccountSettings()}) @@ -245,8 +245,8 @@ const lastAssistantId=()=>{const a=[...el.messages.querySelectorAll('.msg-bubble const getBubbleById=id=>el.messages.querySelector(`.msg-bubble[data-mid="${CSS.escape(id)}"]`) async function syncTranscript(){const id=lastAssistantId();if(!id)return false;const bubble=getBubbleById(id);if(!bubble)return false;const j=await fetchTranscript(id).catch(()=>null);if(!j||j.rid!==id){if(j&&j.error){setBtnSend();state.busy=false;const t=(bubble.textContent||'')+'\n\n'+j.error;renderMarkdown(bubble,t,{enhance:false});enhanceCodeBlocks(bubble,true);const i=state.messages.findIndex(m=>m.id===id);if(i>=0)state.messages[i].content=[{type:'text',text:t}];else state.messages.push({id,role:'assistant',content:[{type:'text',text:t}]});persistThread()}return false}const t=j.text||'';renderMarkdown(bubble,t,{enhance:false});if(j.error||j.done||j.phase==='done'){setBtnSend();state.busy=false;enhanceCodeBlocks(bubble,true);const i=state.messages.findIndex(m=>m.id===id);if(i>=0)state.messages[i].content=[{type:'text',text:t}];else state.messages.push({id,role:'assistant',content:[{type:'text',text:t}]});persistThread();return false}return true} let syncLoopRunning=false -const syncKick=r=>{if(document.visibilityState!=='hidden')setTimeout(()=>syncLoop(r),0)} -async function syncLoop(){if(syncLoopRunning)return;const id=lastAssistantId();if(!id)return;syncLoopRunning=true;try{for(;;){const cont=await syncTranscript().catch(()=>false);if(!cont)break;await new Promise(r=>setTimeout(r,1200))}}finally{syncLoopRunning=false}} +const syncKick=r=>{if(!state.busy||document.visibilityState==='hidden')return;setTimeout(()=>syncLoop(r),0)} +async function syncLoop(){if(!state.busy||syncLoopRunning)return;const id=lastAssistantId();if(!id)return;syncLoopRunning=true;try{for(;;){if(!state.busy)break;const cont=await syncTranscript().catch(()=>false);if(!cont)break;await new Promise(r=>setTimeout(r,1200))}}finally{syncLoopRunning=false}} ;['focus','pageshow'].forEach(ev=>window.addEventListener(ev,()=>syncKick(ev))) document.addEventListener('visibilitychange',()=>{if(document.visibilityState==='visible')syncKick('visible')}) el.copySystemPrompt.addEventListener('click',async()=>{try{await navigator.clipboard.writeText(el.set_system_prompt.value||'')}catch{}}) diff --git a/docs/manifest.webmanifest b/dist/manifest.webmanifest similarity index 100% rename from docs/manifest.webmanifest rename to dist/manifest.webmanifest diff --git a/docs/registerSW.js b/dist/registerSW.js similarity index 100% rename from docs/registerSW.js rename to dist/registerSW.js diff --git a/docs/sw.js b/dist/sw.js similarity index 80% rename from docs/sw.js rename to dist/sw.js index 80951b0..e329606 100644 --- a/docs/sw.js +++ b/dist/sw.js @@ -1 +1 @@ -if(!self.define){let e,i={};const t=(t,n)=>(t=new URL(t+".js",n).href,i[t]||new Promise(i=>{if("document"in self){const e=document.createElement("script");e.src=t,e.onload=i,document.head.appendChild(e)}else e=t,importScripts(t),i()}).then(()=>{let e=i[t];if(!e)throw new Error(`Module ${t} didn’t register its module`);return e}));self.define=(n,r)=>{const s=e||("document"in self?document.currentScript.src:"")||location.href;if(i[s])return;let o={};const c=e=>t(e,s),d={module:{uri:s},exports:o,require:c};i[s]=Promise.all(n.map(e=>d[e]||c(e))).then(e=>(r(...e),o))}}define(["./workbox-5ffe50d4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"index.html",revision:"806ca7b504dca47012ba05e0c3ddfc58"},{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"manifest.webmanifest",revision:"7a6c5c6ab9cb5d3605d21df44c6b17a2"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))}); +if(!self.define){let e,i={};const t=(t,n)=>(t=new URL(t+".js",n).href,i[t]||new Promise(i=>{if("document"in self){const e=document.createElement("script");e.src=t,e.onload=i,document.head.appendChild(e)}else e=t,importScripts(t),i()}).then(()=>{let e=i[t];if(!e)throw new Error(`Module ${t} didn’t register its module`);return e}));self.define=(n,r)=>{const s=e||("document"in self?document.currentScript.src:"")||location.href;if(i[s])return;let o={};const d=e=>t(e,s),c={module:{uri:s},exports:o,require:d};i[s]=Promise.all(n.map(e=>c[e]||d(e))).then(e=>(r(...e),o))}}define(["./workbox-5ffe50d4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"index.html",revision:"6d99841722e382c2daa63eee681189df"},{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"manifest.webmanifest",revision:"7a6c5c6ab9cb5d3605d21df44c6b17a2"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))}); diff --git a/docs/workbox-5ffe50d4.js b/dist/workbox-5ffe50d4.js similarity index 100% rename from docs/workbox-5ffe50d4.js rename to dist/workbox-5ffe50d4.js diff --git a/docs/✺.avif b/dist/✺.avif similarity index 100% rename from docs/✺.avif rename to dist/✺.avif diff --git a/index.html b/index.html index e372780..a0d1325 100644 --- a/index.html +++ b/index.html @@ -16,7 +16,7 @@ -
+Stored locally.
Stored locally.
Stored locally.