sessiongraph 1.0.11 → 1.0.12
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.
- package/bin/sessiongraph.mjs +16 -6
- package/dist/assets/{external-links-CJk2OPKW.js → external-links-D0O8IeG0.js} +1 -1
- package/dist/assets/{index-JjTdnq9-.js → index-BS2Voifb.js} +1 -1
- package/dist/assets/{index-DPovJIlT.js → index-CIhs02tq.js} +5 -5
- package/dist/assets/{index-DhlS3ZId.js → index-GTrhxXlP.js} +1 -1
- package/dist/assets/{index-DOYyn-b_.js → index-Vq4WYmzW.js} +1 -1
- package/dist/assets/{publishing-CkVIjq_f.js → publishing-ofssf6d6.js} +1 -1
- package/dist/assets/{scene-BXs8B_Kk.js → scene-KCDTPCOD.js} +1 -1
- package/dist/assets/{share-jfOenMTA.js → share-DKeJCFAo.js} +3 -3
- package/dist/assets/worker-C10U_apJ.js +2 -0
- package/dist/index.html +1 -1
- package/dist-server/cli.mjs +37391 -0
- package/dist-server/server.mjs +157 -53
- package/docs/cli.md +215 -0
- package/package.json +7 -7
- package/dist/assets/worker-DwqxiDWY.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as i}from"./index-
|
|
1
|
+
import{n as i}from"./index-CIhs02tq.js";function r(e){if(e!==void 0){if(typeof e=="string")return e;if("ok"in e&&"cancel"in e)return{OkCancelCustom:[e.ok,e.cancel]};if("yes"in e&&"no"in e&&"cancel"in e)return{YesNoCancelCustom:[e.yes,e.no,e.cancel]};if("ok"in e)return{OkCustom:e.ok}}}async function f(e={}){return typeof e=="object"&&Object.freeze(e),await i("plugin:dialog|open",{options:e})}async function k(e={}){return typeof e=="object"&&Object.freeze(e),await i("plugin:dialog|save",{options:e})}async function l(e,a){return await i("plugin:dialog|message",{message:e,title:a?.title,kind:a?.kind,buttons:r(a?.buttons)})}async function s(e,a){const n=typeof a=="string"?{title:a}:a;return n&&!n.buttons&&n.okLabel&&(n.buttons={ok:n.okLabel}),l(e,n)}async function u(e,a){const n=typeof a=="string"?{title:a}:a,c=n?.okLabel||n?.cancelLabel,t=n?.okLabel??"Yes";return await l(e,{title:n?.title,kind:n?.kind,buttons:c?{ok:t,cancel:n.cancelLabel??"No"}:"YesNo"})===t}async function d(e,a){const n=typeof a=="string"?{title:a}:a,c=n?.okLabel||n?.cancelLabel,t=n?.okLabel??"Ok";return await l(e,{title:n?.title,kind:n?.kind,buttons:c?{ok:t,cancel:n.cancelLabel??"Cancel"}:"OkCancel"})===t}export{u as ask,d as confirm,s as message,f as open,k as save};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as a,R as i,C as o}from"./index-
|
|
1
|
+
import{n as a,R as i,C as o}from"./index-CIhs02tq.js";class l extends i{constructor(e){super(e.rid),this.available=!0,this.currentVersion=e.currentVersion,this.version=e.version,this.date=e.date,this.body=e.body,this.rawJson=e.rawJson}async download(e,s){const d=new o;e&&(d.onmessage=e);const r=await a("plugin:updater|download",{onEvent:d,rid:this.rid,...s,headers:t(s?.headers)});await this.downloadedBytes?.close().catch(()=>{}),this.downloadedBytes=new i(r)}async install(e){if(!this.downloadedBytes)throw new Error("Update.install called before Update.download");await a("plugin:updater|install",{updateRid:this.rid,bytesRid:this.downloadedBytes.rid,...e}),this.downloadedBytes=void 0}async downloadAndInstall(e,s){const d=new o;e&&(d.onmessage=e),await a("plugin:updater|download_and_install",{onEvent:d,rid:this.rid,...s,headers:t(s?.headers)})}async close(){await this.downloadedBytes?.close(),await super.close()}}async function w(n){const e=await a("plugin:updater|check",{...n,headers:t(n?.headers)});return e?new l(e):null}function t(n){return n?Array.from(new Headers(n).entries()):void 0}export{l as Update,w as check};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as pe,j as me,m as ge,D as be,a as ae,k as q,l as ie,t as he,P as fe,g as ye,c as we,i as V}from"./index-
|
|
1
|
+
import{h as pe,j as me,m as ge,D as be,a as ae,k as q,l as ie,t as he,P as fe,g as ye,c as we,i as V}from"./index-CIhs02tq.js";import{TimelineScene as ve}from"./scene-KCDTPCOD.js";import{s as ke,e as Se,o as Ce}from"./external-links-D0O8IeG0.js";import"./three-D_1Qt16u.js";const xe=["svg",pe,[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"}],["path",{d:"M9 18c-4.51 2-5-2-7-2"}]]],Ae={tokens:"Token counts",timestamps:"Session timestamps",messageCounts:"Message counts",messageTimestamps:"Message timestamps",model:"Model used",harness:"Harness used"},Z={tokens:!0,timestamps:!0,messageCounts:!0,messageTimestamps:!0,model:!0,harness:!0};function oe(t){const r={...Z};if(ce(t))for(const n of Object.keys(r))typeof t[n]=="boolean"&&(r[n]=t[n]);return(!r.timestamps||!r.messageCounts)&&(r.messageTimestamps=!1),r}const re=1e4,Ee=2e6,Pe=1e5,Me="Always excluded: project and session names, messages, code, paths, source IDs, and costs. Anonymous groups and recorded branch links are included. Your GitHub username identifies this profile. Your published graph will appear in Explore graphs. Selected timestamps and usage will be public.",Te=/^(?:gpt-[3-6](?:\.[0-9])?(?:-(?:turbo|mini|nano|pro|codex|astra|instant|thinking|chat|latest|preview|[0-9]{4,8}))*|o[1-4](?:-(?:mini|pro|preview|[0-9]{4,8}))*|claude-(?:(?:sonnet|opus|haiku)-[3-5](?:[.-][0-9])?|[3-5](?:-[0-9])?-(?:sonnet|opus|haiku))(?:-(?:latest|thinking|[0-9]{8}))*|gemini-[1-4](?:\.[0-9])?-(?:pro|flash)(?:-(?:lite|preview|exp|latest|[0-9]{2,4}))*|deepseek-(?:chat|reasoner|v[3-4](?:\.[0-9])?|r1)|grok-[2-5](?:\.[0-9])?(?:-(?:fast|code|reasoning|non-reasoning|[0-9]))*|kimi-k[1-3](?:\.[0-9])?(?:-thinking)?|minimax-m[1-3](?:\.[0-9])?)$/i,Le=t=>{const r=t.split("/").at(-1)||"";return r.length<=100&&Te.test(r)?r.toLowerCase():null},ce=t=>!!t&&typeof t=="object"&&!Array.isArray(t),B=(t,r)=>ce(t)&&Object.keys(t).length===r.length&&r.every(n=>Object.hasOwn(t,n)),Y=(t,r=Number.MAX_SAFE_INTEGER)=>Number.isSafeInteger(t)&&t>=0&&t<=r,W=t=>Y(t,Date.UTC(2100,0,1)),z=t=>t===null||Y(t);function de(t){const r=()=>{throw new Error("Invalid anonymous graph. Reopen the publishing preview and try again.")};if(!B(t,["version","settings","sessions"])||t.version!==1||!Array.isArray(t.sessions)||!B(t.settings,Object.keys(Z))||Object.values(t.settings).some(f=>typeof f!="boolean"))return r();const n=t.settings;if(n.messageTimestamps&&(!n.timestamps||!n.messageCounts))return r();if(t.sessions.length<1||t.sessions.length>re)throw new Error(`Choose between 1 and ${re.toLocaleString("en")} sessions to publish.`);const e=["id","group","parent","fork",...n.timestamps?["timestamps"]:[],...n.tokens?["tokens"]:[],...n.messageCounts?["messages"]:[],...n.messageTimestamps?["messageTimes"]:[],...n.model?["model"]:[],...n.harness?["harness"]:[]];let m=0;for(let f=0;f<t.sessions.length;f++){const i=t.sessions[f];if(!B(i,e)||i.id!==f||!Y(i.group,t.sessions.length-1))return r();for(const p of["parent","fork"])if(i[p]!==null&&(!Y(i[p],t.sessions.length-1)||i[p]===f))return r();if(n.timestamps&&(!B(i.timestamps,["created","lastMessageAt"])||!W(i.timestamps.created)||i.timestamps.lastMessageAt!==null&&!W(i.timestamps.lastMessageAt))||n.tokens&&!z(i.tokens)||n.messageCounts&&(!B(i.messages,["count","untimed","partial"])||!z(i.messages.count)||!z(i.messages.untimed)||typeof i.messages.partial!="boolean")||n.messageTimestamps&&(!B(i.messageTimes,["values","limited"])||!Array.isArray(i.messageTimes.values)||i.messageTimes.values.length>2e3||typeof i.messageTimes.limited!="boolean"||i.messageTimes.values.some(p=>!W(p))||(m+=i.messageTimes.values.length,m>Pe))||n.model&&i.model!==null&&(typeof i.model!="string"||Le(i.model)!==i.model)||n.harness&&i.harness!==null&&(typeof i.harness!="string"||!me(i.harness)))return r()}const o=t.sessions,l=new Uint8Array(o.length);for(let f=0;f<o.length;f++){if(l[f])continue;const i=[[f,!1]];for(;i.length;){const[p,M]=i.pop();if(M){l[p]=2;continue}if(l[p]===1)return r();if(l[p]!==2){l[p]=1,i.push([p,!0]);for(const S of[o[p].parent,o[p].fork])S!==null&&i.push([S,!1])}}}if(new TextEncoder().encode(JSON.stringify(t)).length>Ee)throw new Error("This graph is too large. Choose a smaller date range.");return t}function le(t,r){const n=de(t),e=n.sessions.filter(l=>!r||r.has(l.id)).map(l=>({id:String(l.id),projectID:String(l.group),title:`Session ${l.id+1}`,directory:"",created:l.timestamps?.created??l.id*36e5,updated:l.timestamps?.created??l.id*36e5,tokens:l.tokens??null,cost:null,archived:!1,model:l.model??"",provider:"",agent:"",source:l.harness??void 0,activity:{firstMessageAt:null,lastMessageAt:l.timestamps?.lastMessageAt??null,userMessages:0,untimedUserMessages:0},...l.parent===null?{}:{parentID:String(l.parent)},...l.fork===null?{}:{forkID:String(l.fork)}})),m=[...new Set(n.sessions.map(l=>l.group))].map(l=>({id:String(l),name:`Group ${l+1}`,directory:"",worktrees:[]})),o=ge(e.map(l=>({...l,source:void 0})),m);for(const l of o.nodes)l.session.source=n.sessions[Number(l.session.id)].harness??void 0;return o}function $e(t){const r=t.settings.tokens?t.sessions.filter(e=>typeof e.tokens=="number"):[],n=r.reduce((e,m)=>e+m.tokens,0);return{sessionCount:t.sessions.length,tokenCount:r.length&&Number.isSafeInteger(n)?n:null,tokensPartial:r.length>0&&r.length<t.sessions.length}}function ue(t){const r=$e(t),n=[`${r.sessionCount.toLocaleString()} sessions`];if(t.settings.tokens&&n.push(r.tokenCount===null?"Tokens unavailable":`${r.tokenCount.toLocaleString()} recorded tokens${r.tokensPartial?" (partial coverage)":""}`),t.settings.messageCounts){const e=t.sessions.filter(m=>m.messages?.count!=null);n.push(e.length?`${e.reduce((m,o)=>m+o.messages.count,0).toLocaleString()} recorded messages${e.length<t.sessions.length||t.sessions.some(m=>m.messages?.partial)?" (partial history)":""}`:"Message counts unavailable")}return n.join(" · ")}const Q=t=>t==null?"Unknown":t.toLocaleString(),R=t=>t===null?"Unknown":new Date(t).toLocaleString();function Ie(t,r,n={}){const e=de(r);let m=le(e);t.classList.add("public-viewer"),t.classList.toggle("public-viewer-full",!!n.fullscreen),t.innerHTML=`
|
|
2
2
|
<div class="public-canvas" aria-label="Interactive public session graph"></div>
|
|
3
3
|
<div class="public-toolbar"><button type="button" data-sessions aria-expanded="true">☷ Sessions</button><span class="public-badge">Public snapshot</span></div>
|
|
4
4
|
<nav class="public-view-controls" aria-label="Graph controls"><div class="public-view-switch"><button type="button" data-view="3d" aria-pressed="true">3D</button><button type="button" data-view="2d" aria-pressed="false">2D</button></div><button type="button" data-fit title="Fit view (F)">Fit view</button><button type="button" data-motion aria-pressed="true">Motion</button><button type="button" data-timeline aria-expanded="true">Timeline</button></nav>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{M as oe,C as L,S as ce,a as M,G,P as ae,I as ne,b as k,D as F,c as I,A as T,d as Y,e as N,B as D,F as S,f as re,g as H,W as ke,h as Pe,O as Se,i as Ae,H as Ce,E as Re,R as Fe,U as Ee,V as O,j as Ie,k as Te,l as ze,m as Be,n as Ue,o as V,p as Ge,q as g,r as De,s as ee,t as Oe,u as Le,v as j,w as te,x as ie,y as He,L as Ne,z as de,J as ue,K as Xe,N as _e}from"./three-D_1Qt16u.js";import{h as ge,o as R,c as Ve,D as $e,l as je,q as C,r as $,u as We,v as qe,w as Ye,x as se,y as fe}from"./index-
|
|
1
|
+
import{M as oe,C as L,S as ce,a as M,G,P as ae,I as ne,b as k,D as F,c as I,A as T,d as Y,e as N,B as D,F as S,f as re,g as H,W as ke,h as Pe,O as Se,i as Ae,H as Ce,E as Re,R as Fe,U as Ee,V as O,j as Ie,k as Te,l as ze,m as Be,n as Ue,o as V,p as Ge,q as g,r as De,s as ee,t as Oe,u as Le,v as j,w as te,x as ie,y as He,L as Ne,z as de,J as ue,K as Xe,N as _e}from"./three-D_1Qt16u.js";import{h as ge,o as R,c as Ve,D as $e,l as je,q as C,r as $,u as We,v as qe,w as Ye,x as se,y as fe}from"./index-CIhs02tq.js";const Ke=["svg",ge,[["path",{d:"M12 8V4H8"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}],["path",{d:"M2 14h2"}],["path",{d:"M20 14h2"}],["path",{d:"M15 13v2"}],["path",{d:"M9 13v2"}]]];const Qe=["svg",ge,[["circle",{cx:"12",cy:"8",r:"5"}],["path",{d:"M20 21a8 8 0 0 0-16 0"}]]],ye=`
|
|
2
2
|
attribute float nodeIndex;
|
|
3
3
|
uniform float uSelected;
|
|
4
4
|
uniform float uHovered;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{TimelineScene as V}from"./scene-
|
|
3
|
-
https://github.com/arvindell/sessiongraph`,be=`https://x.com/intent/tweet?text=${encodeURIComponent(I)}`,z=e=>e instanceof Error&&e.name==="AbortError";async function ve(e,l,t){const{label:s,description:i,mime:p,filename:r}=$[t];try{if(U()){const[{save:a},{writeFile:o}]=await Promise.all([G(()=>import("./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-GTrhxXlP.js","assets/index-CIhs02tq.js","assets/index-cVgPCrFV.css","assets/index-BS2Voifb.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{TimelineScene as V}from"./scene-KCDTPCOD.js";import{i as U,_ as G,c as X,S as J,p as Y,a as Z,t as K,s as Q,b as H,d as ee,e as te,f as ae,g as oe}from"./index-CIhs02tq.js";import{s as re,o as se}from"./external-links-D0O8IeG0.js";import"./three-D_1Qt16u.js";const ne="#b0e9d6",ie="#dbe7e3",L=128,le=10,ce="M102 24 86 40H36a14 14 0 0 0 0 28h40a14 14 0 0 1 0 28H22",de=[[102,24],[36,40],[22,96]],ue=10;let O;function he(e,l,t,s,i=ne){O??=new Path2D(ce),e.save(),e.translate(l,t),e.scale(s/L,s/L),e.strokeStyle=e.fillStyle=i,e.lineWidth=le,e.lineCap=e.lineJoin="round",e.stroke(O);for(const[p,r]of de)e.beginPath(),e.arc(p,r,ue,0,Math.PI*2),e.fill();e.restore()}const pe="Cosmic Wobbly Disco Sneaky Bouncy Galactic Crispy Dizzy Fuzzy Noodle Groovy Sleepy Spicy Jolly Loopy Squishy Turbo Giggly Velvet Soggy Zippy Fluffy Moonwalking Wiggly Fizzy Snazzy Goofy Jazzy Tiny Chunky Dapper Wacky".split(" "),ye="Wombat Pickle Pancake Badger Potato Narwhal Noodle Goblin Otter Turnip Hamster Comet Dumpling Goose Biscuit Llama Muffin Squid Raccoon Toaster Waffle Penguin Yeti Pudding Walrus Taco Jellybean Platypus Sloth Cactus Donut Mongoose".split(" ");function fe(e,l=()=>crypto.getRandomValues(new Uint32Array(1))[0]/2**32){const t=pe.flatMap(s=>ye.map(i=>`${s} ${i}`));for(let s=t.length-1;s>0;s--){const i=Math.floor(l()*(s+1));[t[s],t[i]]=[t[i],t[s]]}return Array.from({length:e},(s,i)=>{const p=Math.floor(i/t.length);return`Project ${"Mega".repeat(p)}${t[i%t.length]}`})}function me(e){const l=fe(e.lanes.length),t=new Map(e.nodes.map((r,a)=>[r.session.id,`session-${a}`])),s=new Map(e.lanes.flatMap((r,a)=>r.nodes.map(o=>[o.session.id,`project-${a}`]))),i=e.nodes.map(r=>{const a=r.session,o={id:t.get(a.id),title:"Session",projectID:s.get(a.id),directory:"",created:a.created,updated:a.created,activity:a.activity&&{firstMessageAt:a.activity.firstMessageAt,lastMessageAt:a.activity.lastMessageAt,userMessages:a.activity.userMessages,untimedUserMessages:a.activity.untimedUserMessages},archived:!1,model:"",provider:"",agent:"",cost:null,source:a.source==="continue"?"continue":a.source==="opencode"||!a.source?"opencode":"unknown",tokens:a.tokens};return a.parentID&&t.has(a.parentID)&&(o.parentID=t.get(a.parentID)),a.forkID&&t.has(a.forkID)&&(o.forkID=t.get(a.forkID)),{session:o,position:[...r.position],startPosition:[...r.startPosition],color:r.color,radius:r.radius}}),p=new Map(i.map(r=>[r.session.id,r]));return{start:e.start,end:e.end,timeFrame:e.timeFrame&&{...e.timeFrame},nodes:i,edges:e.edges.map(r=>({from:t.get(r.from),to:t.get(r.to),kind:r.kind})),lanes:e.lanes.map((r,a)=>({key:`project-${a}`,label:l[a],color:r.color,kind:"directory",y:r.y,z:r.z,nodes:r.nodes.map(o=>p.get(t.get(o.session.id)))}))}}const $={mp4:{label:"MP4",description:"MP4 video",mime:"video/mp4",filename:"sessiongraph-playback.mp4"}},I=`My coding sessions, visualized with SessionGraph.
|
|
3
|
+
https://github.com/arvindell/sessiongraph`,be=`https://x.com/intent/tweet?text=${encodeURIComponent(I)}`,z=e=>e instanceof Error&&e.name==="AbortError";async function ve(e,l,t){const{label:s,description:i,mime:p,filename:r}=$[t];try{if(U()){const[{save:a},{writeFile:o}]=await Promise.all([G(()=>import("./index-GTrhxXlP.js"),__vite__mapDeps([0,1,2])),G(()=>import("./index-BS2Voifb.js"),__vite__mapDeps([3,1,2]))]),c=await a({title:`Save SessionGraph ${s}`,defaultPath:r,filters:[{name:i,extensions:[t]}]});if(!c)return"cancelled";await o(c,new Uint8Array(await e.arrayBuffer()))}else{const a=window.showSaveFilePicker;if(a){const c=await(await a.call(window,{suggestedName:r,types:[{description:i,accept:{[p]:[`.${t}`]}}]})).createWritable();try{await c.write(e),await c.close()}catch(d){throw await c.abort().catch(()=>{}),d}}else{const o=document.createElement("a");return o.href=l,o.download=r,document.body.append(o),o.click(),o.remove(),"downloaded"}}return"saved"}catch(a){if(z(a))return"cancelled";throw a}}const S=960,T=600,we=e=>Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e);function ge(e,l,t,s,i,p){const o=T-122,c=Math.max(1,...s);e.save(),he(e,24,14,28),e.fillStyle=ie,e.font='600 14px "Geist Variable", sans-serif',e.textAlign="left",e.textBaseline="middle",e.fillText("SessionGraph",58,28),e.restore();for(let h=0;h<s.length;h++){const f=Math.max(2,s[h]/c*22);e.fillStyle=h/s.length<=t?"#91bfae":"#253d39",e.fillRect(260+h/s.length*440,o-f,440/s.length-2,f)}e.fillStyle="#d6f4e8",e.fillRect(260+440*t,o-27,1,31);const d=l.start+(l.end-l.start)*t,k=i.at(d,t===1).tokens;e.textAlign="center",e.fillStyle="#a0baae",e.font='12px "IBM Plex Mono", monospace',e.fillText(oe(d,l.end-l.start),S/2,o+23),e.fillStyle="#e7f5ee",e.font='36px "Geist Variable", sans-serif',e.fillText(p(d,t===1).toLocaleString("en"),S/2-105,o+66),e.fillText(i.recorded?we(k):"—",S/2+105,o+66),e.font='12px "Geist Variable", sans-serif',e.fillStyle="#92b0a3",e.fillText("Sessions",S/2-105,o+87),e.fillText("Burnt tokens",S/2+105,o+87),e.textAlign="left"}async function Se(e,l,t,s){t.throwIfAborted();const{label:i,mime:p}=$.mp4,r=Y(e.nodes.map(y=>y.session)),a=Z(e.nodes.map(y=>y.session)),o=K(e.nodes.map(y=>Q(y.session)),e.start,e.end),c=document.createElement("div");c.className="share-render-host",c.setAttribute("aria-hidden","true"),c.style.cssText=`position:fixed;left:-12000px;top:0;width:${S}px;height:${T}px;pointer-events:none;visibility:hidden`,document.body.append(c);const d=document.createElement("canvas");d.width=S,d.height=T;const k=d.getContext("2d",{willReadFrequently:!0});let h,f;try{if(!k)throw new Error("Canvas export is unavailable.");h=new V(c,{onSelect(){},onHover(){},onPlaybackInterrupt(){},onEvent(){},onEventHover(){}},{manual:!0}),h.applyPreferences({...l,quality:"balanced",motion:"on",labels:!0,focusDimming:!1,trails:l.trails==="selected"?"all":l.trails}),h.setGraph(e,!0),h.prepareCapture(),await document.fonts.ready,t.throwIfAborted(),f=new Worker(new URL("/assets/mp4-worker-Dc_1QUwS.js",import.meta.url),{type:"module"});const y=(m,C=[])=>new Promise((A,b)=>{t.throwIfAborted();const v=()=>{clearTimeout(D),t.removeEventListener("abort",w),f.onmessage=null,f.onerror=null},w=()=>{v(),b(t.reason)},D=setTimeout(()=>{v(),b(new Error(`${i} encoding timed out. Please try again.`))},6e4);t.addEventListener("abort",w,{once:!0}),f.onmessage=M=>{v(),M.data.error?b(new Error(M.data.error)):A(M.data)},f.onerror=()=>{v(),b(new Error(`Could not start the ${i} encoder.`))},f.postMessage(m,C)});await y({init:!0,width:S,height:T});for(let m=0;m<H;m++){t.throwIfAborted();const C=ee(m);h.captureFrame(C,1/te,k,ae(m)),ge(k,e,C,o,r,a);const A=k.getImageData(0,0,S,T).data.buffer;await y({rgba:A,width:S,height:T},[A]),s((m+1)/H)}const _=await y({finish:!0});return new Blob([_.bytes],{type:p})}finally{f?.terminate(),h?.dispose(),c.remove()}}function De(e,l){const t=document.createElement("dialog");t.className="share-dialog",t.setAttribute("aria-labelledby","share-title"),t.innerHTML=`<p>Create a private MP4 video. Project and session names are hidden, and nothing is uploaded.</p>
|
|
4
4
|
<div class="share-preview"><video aria-label="SessionGraph playback with hidden project and session names" muted loop playsinline controls hidden></video><div class="share-progress"><progress max="100" value="0" aria-label="Creating video"></progress><span role="status">Creating video… 0%</span></div></div>
|
|
5
5
|
<p class="share-notice" role="status" hidden></p>
|
|
6
6
|
<div class="share-actions"><button class="text-button share-close">Cancel</button><button class="secondary-button share-retry" hidden>Try again</button><a class="secondary-button share-x" target="_blank" rel="noopener noreferrer" hidden>Share in X</a><button class="secondary-button share-system" aria-label="Open share tray" aria-controls="playback-share-tray" aria-expanded="false" hidden>Share…</button><button class="primary-button share-save" hidden>Save MP4</button></div>
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(){"use strict";const ve="ENTRIES",le="KEYS",he="VALUES";class K{constructor(e,t){const n=e._tree,o=Array.from(n.keys());this.set=e,this._type=t,this._path=o.length>0?[{node:n,keys:o}]:[]}next(){const e=this.dive();return this.backtrack(),e}dive(){if(this._path.length===0)return{done:!0,value:void 0};const{node:e,keys:t}=M(this._path);if(M(t)==="")return{done:!1,value:this.result()};const n=e.get(M(t));return this._path.push({node:n,keys:Array.from(n.keys())}),this.dive()}backtrack(){if(this._path.length===0)return;const e=M(this._path).keys;e.pop(),!(e.length>0)&&(this._path.pop(),this.backtrack())}key(){return this.set._prefix+this._path.map(({keys:e})=>M(e)).filter(e=>e!=="").join("")}value(){return M(this._path).node.get("")}result(){switch(this._type){case he:return this.value();case le:return this.key();default:return[this.key(),this.value()]}}[Symbol.iterator](){return this}}const M=s=>s[s.length-1],ke=(s,e,t)=>{const n=new Map;if(e===void 0)return n;const o=e.length+1,i=o+t,r=new Uint8Array(i*o).fill(t+1);for(let c=0;c<o;++c)r[c]=c;for(let c=1;c<i;++c)r[c*o]=c;return ue(s,e,t,n,r,1,o,""),n},ue=(s,e,t,n,o,i,r,c)=>{const a=i*r;e:for(const d of s.keys())if(d===""){const h=o[a-1];h<=t&&n.set(c,[s.get(d),h])}else{let h=i;for(let _=0;_<d.length;++_,++h){const m=d[_],l=r*h,f=l-r;let p=o[l];const u=Math.max(0,h-t-1),g=Math.min(r-1,h+t);for(let w=u;w<g;++w){const O=m!==e[w],V=o[f+w]+ +O,j=o[f+w+1]+1,x=o[l+w]+1,z=o[l+w+1]=Math.min(V,j,x);z<p&&(p=z)}if(p>t)continue e}ue(s.get(d),e,t,n,o,h,r,c+d)}};class I{constructor(e=new Map,t=""){this._size=void 0,this._tree=e,this._prefix=t}atPrefix(e){if(!e.startsWith(this._prefix))throw new Error("Mismatched prefix");const[t,n]=W(this._tree,e.slice(this._prefix.length));if(t===void 0){const[o,i]=Z(n);for(const r of o.keys())if(r!==""&&r.startsWith(i)){const c=new Map;return c.set(r.slice(i.length),o.get(r)),new I(c,e)}}return new I(t,e)}clear(){this._size=void 0,this._tree.clear()}delete(e){return this._size=void 0,ze(this._tree,e)}entries(){return new K(this,ve)}forEach(e){for(const[t,n]of this)e(t,n,this)}fuzzyGet(e,t){return ke(this._tree,e,t)}get(e){const t=H(this._tree,e);return t!==void 0?t.get(""):void 0}has(e){const t=H(this._tree,e);return t!==void 0&&t.has("")}keys(){return new K(this,le)}set(e,t){if(typeof e!="string")throw new Error("key must be a string");return this._size=void 0,X(this._tree,e).set("",t),this}get size(){if(this._size)return this._size;this._size=0;const e=this.entries();for(;!e.next().done;)this._size+=1;return this._size}update(e,t){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;const n=X(this._tree,e);return n.set("",t(n.get(""))),this}fetch(e,t){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;const n=X(this._tree,e);let o=n.get("");return o===void 0&&n.set("",o=t()),o}values(){return new K(this,he)}[Symbol.iterator](){return this.entries()}static from(e){const t=new I;for(const[n,o]of e)t.set(n,o);return t}static fromObject(e){return I.from(Object.entries(e))}}const W=(s,e,t=[])=>{if(e.length===0||s==null)return[s,t];for(const n of s.keys())if(n!==""&&e.startsWith(n))return t.push([s,n]),W(s.get(n),e.slice(n.length),t);return t.push([s,e]),W(void 0,"",t)},H=(s,e)=>{if(e.length===0||s==null)return s;for(const t of s.keys())if(t!==""&&e.startsWith(t))return H(s.get(t),e.slice(t.length))},X=(s,e)=>{const t=e.length;e:for(let n=0;s&&n<t;){for(const i of s.keys())if(i!==""&&e[n]===i[0]){const r=Math.min(t-n,i.length);let c=1;for(;c<r&&e[n+c]===i[c];)++c;const a=s.get(i);if(c===i.length)s=a;else{const d=new Map;d.set(i.slice(c),a),s.set(e.slice(n,n+c),d),s.delete(i),s=d}n+=c;continue e}const o=new Map;return s.set(e.slice(n),o),o}return s},ze=(s,e)=>{const[t,n]=W(s,e);if(t!==void 0){if(t.delete(""),t.size===0)fe(n);else if(t.size===1){const[o,i]=t.entries().next().value;me(n,o,i)}}},fe=s=>{if(s.length===0)return;const[e,t]=Z(s);if(e.delete(t),e.size===0)fe(s.slice(0,-1));else if(e.size===1){const[n,o]=e.entries().next().value;n!==""&&me(s.slice(0,-1),n,o)}},me=(s,e,t)=>{if(s.length===0)return;const[n,o]=Z(s);n.set(o+e,t),n.delete(o)},Z=s=>s[s.length-1],ee="or",pe="and",Me="and_not";class C{constructor(e){if(e?.fields==null)throw new Error('MiniSearch: option "fields" must be provided');const t=e.autoVacuum==null||e.autoVacuum===!0?oe:e.autoVacuum;this._options={...se,...e,autoVacuum:t,searchOptions:{...ge,...e.searchOptions||{}},autoSuggestOptions:{...Te,...e.autoSuggestOptions||{}}},this._index=new I,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldIds={},this._fieldLength=new Map,this._avgFieldLength=[],this._nextId=0,this._storedFields=new Map,this._dirtCount=0,this._currentVacuum=null,this._enqueuedVacuum=null,this._enqueuedVacuumConditions=ie,this.addFields(this._options.fields)}add(e){const{extractField:t,stringifyField:n,tokenize:o,processTerm:i,fields:r,idField:c}=this._options,a=t(e,c);if(a==null)throw new Error(`MiniSearch: document does not have ID field "${c}"`);if(this._idToShortId.has(a))throw new Error(`MiniSearch: duplicate ID ${a}`);const d=this.addDocumentId(a);this.saveStoredFields(d,e);for(const h of r){const _=t(e,h);if(_==null)continue;const m=o(n(_,h),h),l=this._fieldIds[h],f=new Set(m).size;this.addFieldLength(d,l,this._documentCount-1,f);for(const p of m){const u=i(p,h);if(Array.isArray(u))for(const g of u)this.addTerm(l,d,g);else u&&this.addTerm(l,d,u)}}}addAll(e){for(const t of e)this.add(t)}addAllAsync(e,t={}){const{chunkSize:n=10}=t,o={chunk:[],promise:Promise.resolve()},{chunk:i,promise:r}=e.reduce(({chunk:c,promise:a},d,h)=>(c.push(d),(h+1)%n===0?{chunk:[],promise:a.then(()=>new Promise(_=>setTimeout(_,0))).then(()=>this.addAll(c))}:{chunk:c,promise:a}),o);return r.then(()=>this.addAll(i))}remove(e){const{tokenize:t,processTerm:n,extractField:o,stringifyField:i,fields:r,idField:c}=this._options,a=o(e,c);if(a==null)throw new Error(`MiniSearch: document does not have ID field "${c}"`);const d=this._idToShortId.get(a);if(d==null)throw new Error(`MiniSearch: cannot remove document with ID ${a}: it is not in the index`);for(const h of r){const _=o(e,h);if(_==null)continue;const m=t(i(_,h),h),l=this._fieldIds[h],f=new Set(m).size;this.removeFieldLength(d,l,this._documentCount,f);for(const p of m){const u=n(p,h);if(Array.isArray(u))for(const g of u)this.removeTerm(l,d,g);else u&&this.removeTerm(l,d,u)}}this._storedFields.delete(d),this._documentIds.delete(d),this._idToShortId.delete(a),this._fieldLength.delete(d),this._documentCount-=1}removeAll(e){if(e)for(const t of e)this.remove(t);else{if(arguments.length>0)throw new Error("Expected documents to be present. Omit the argument to remove all documents.");this._index=new I,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldLength=new Map,this._avgFieldLength=[],this._storedFields=new Map,this._nextId=0}}discard(e){const t=this._idToShortId.get(e);if(t==null)throw new Error(`MiniSearch: cannot discard document with ID ${e}: it is not in the index`);this._idToShortId.delete(e),this._documentIds.delete(t),this._storedFields.delete(t),(this._fieldLength.get(t)||[]).forEach((n,o)=>{this.removeFieldLength(t,o,this._documentCount,n)}),this._fieldLength.delete(t),this._documentCount-=1,this._dirtCount+=1,this.maybeAutoVacuum()}maybeAutoVacuum(){if(this._options.autoVacuum===!1)return;const{minDirtFactor:e,minDirtCount:t,batchSize:n,batchWait:o}=this._options.autoVacuum;this.conditionalVacuum({batchSize:n,batchWait:o},{minDirtCount:t,minDirtFactor:e})}discardAll(e){const t=this._options.autoVacuum;try{this._options.autoVacuum=!1;for(const n of e)this.discard(n)}finally{this._options.autoVacuum=t}this.maybeAutoVacuum()}replace(e){const{idField:t,extractField:n}=this._options,o=n(e,t);this.discard(o),this.add(e)}vacuum(e={}){return this.conditionalVacuum(e)}conditionalVacuum(e,t){return this._currentVacuum?(this._enqueuedVacuumConditions=this._enqueuedVacuumConditions&&t,this._enqueuedVacuum!=null?this._enqueuedVacuum:(this._enqueuedVacuum=this._currentVacuum.then(()=>{const n=this._enqueuedVacuumConditions;return this._enqueuedVacuumConditions=ie,this.performVacuuming(e,n)}),this._enqueuedVacuum)):this.vacuumConditionsMet(t)===!1?Promise.resolve():(this._currentVacuum=this.performVacuuming(e),this._currentVacuum)}async performVacuuming(e,t){const n=this._dirtCount;if(this.vacuumConditionsMet(t)){const o=e.batchSize||ne.batchSize,i=e.batchWait||ne.batchWait;let r=1;for(const[c,a]of this._index){for(const[d,h]of a)for(const[_]of h)this._documentIds.has(_)||(h.size<=1?a.delete(d):h.delete(_));this._index.get(c).size===0&&this._index.delete(c),r%o===0&&await new Promise(d=>setTimeout(d,i)),r+=1}this._dirtCount-=n}await null,this._currentVacuum=this._enqueuedVacuum,this._enqueuedVacuum=null}vacuumConditionsMet(e){if(e==null)return!0;let{minDirtCount:t,minDirtFactor:n}=e;return t=t||oe.minDirtCount,n=n||oe.minDirtFactor,this.dirtCount>=t&&this.dirtFactor>=n}get isVacuuming(){return this._currentVacuum!=null}get dirtCount(){return this._dirtCount}get dirtFactor(){return this._dirtCount/(1+this._documentCount+this._dirtCount)}has(e){return this._idToShortId.has(e)}getStoredFields(e){const t=this._idToShortId.get(e);if(t!=null)return this._storedFields.get(t)}search(e,t={}){const{searchOptions:n}=this._options,o={...n,...t},i=this.executeQuery(e,t),r=[];for(const[c,{score:a,terms:d,match:h}]of i){const _=d.length||1,m={id:this._documentIds.get(c),score:a*_,terms:Object.keys(h),queryTerms:d,match:h};Object.assign(m,this._storedFields.get(c)),(o.filter==null||o.filter(m))&&r.push(m)}return e===C.wildcard&&o.boostDocument==null||r.sort(we),r}autoSuggest(e,t={}){t={...this._options.autoSuggestOptions,...t};const n=new Map;for(const{score:i,terms:r}of this.search(e,t)){const c=r.join(" "),a=n.get(c);a!=null?(a.score+=i,a.count+=1):n.set(c,{score:i,terms:r,count:1})}const o=[];for(const[i,{score:r,terms:c,count:a}]of n)o.push({suggestion:i,terms:c,score:r/a});return o.sort(we),o}get documentCount(){return this._documentCount}get termCount(){return this._index.size}static loadJSON(e,t){if(t==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJS(JSON.parse(e),t)}static async loadJSONAsync(e,t){if(t==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJSAsync(JSON.parse(e),t)}static getDefault(e){if(se.hasOwnProperty(e))return te(se,e);throw new Error(`MiniSearch: unknown option "${e}"`)}static loadJS(e,t){const{index:n,documentIds:o,fieldLength:i,storedFields:r,serializationVersion:c}=e,a=this.instantiateMiniSearch(e,t);a._documentIds=P(o),a._fieldLength=P(i),a._storedFields=P(r);for(const[d,h]of a._documentIds)a._idToShortId.set(h,d);for(const[d,h]of n){const _=new Map;for(const m of Object.keys(h)){let l=h[m];c===1&&(l=l.ds),_.set(parseInt(m,10),P(l))}a._index.set(d,_)}return a}static async loadJSAsync(e,t){const{index:n,documentIds:o,fieldLength:i,storedFields:r,serializationVersion:c}=e,a=this.instantiateMiniSearch(e,t);a._documentIds=await U(o),a._fieldLength=await U(i),a._storedFields=await U(r);for(const[h,_]of a._documentIds)a._idToShortId.set(_,h);let d=0;for(const[h,_]of n){const m=new Map;for(const l of Object.keys(_)){let f=_[l];c===1&&(f=f.ds),m.set(parseInt(l,10),await U(f))}++d%1e3===0&&await xe(0),a._index.set(h,m)}return a}static instantiateMiniSearch(e,t){const{documentCount:n,nextId:o,fieldIds:i,averageFieldLength:r,dirtCount:c,serializationVersion:a}=e;if(a!==1&&a!==2)throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");const d=new C(t);return d._documentCount=n,d._nextId=o,d._idToShortId=new Map,d._fieldIds=i,d._avgFieldLength=r,d._dirtCount=c||0,d._index=new I,d}executeQuery(e,t={}){if(e===C.wildcard)return this.executeWildcardQuery(t);if(typeof e!="string"){const m={...t,...e,queries:void 0},l=e.queries.map(f=>this.executeQuery(f,m));return this.combineResults(l,m.combineWith)}const{tokenize:n,processTerm:o,searchOptions:i}=this._options,r={tokenize:n,processTerm:o,...i,...t},{tokenize:c,processTerm:a}=r,_=c(e).flatMap(m=>a(m)).filter(m=>!!m).map(De(r)).map(m=>this.executeQuerySpec(m,r));return this.combineResults(_,r.combineWith)}executeQuerySpec(e,t){const n={...this._options.searchOptions,...t},o=(n.fields||this._options.fields).reduce((p,u)=>({...p,[u]:te(n.boost,u)||1}),{}),{boostDocument:i,weights:r,maxFuzzy:c,bm25:a}=n,{fuzzy:d,prefix:h}={...ge.weights,...r},_=this._index.get(e.term),m=this.termResults(e.term,e.term,1,e.termBoost,_,o,i,a);let l,f;if(e.prefix&&(l=this._index.atPrefix(e.term)),e.fuzzy){const p=e.fuzzy===!0?.2:e.fuzzy,u=p<1?Math.min(c,Math.round(e.term.length*p)):p;u&&(f=this._index.fuzzyGet(e.term,u))}if(l)for(const[p,u]of l){const g=p.length-e.term.length;if(!g)continue;f?.delete(p);const w=h*p.length/(p.length+.3*g);this.termResults(e.term,p,w,e.termBoost,u,o,i,a,m)}if(f)for(const p of f.keys()){const[u,g]=f.get(p);if(!g)continue;const w=d*p.length/(p.length+g);this.termResults(e.term,p,w,e.termBoost,u,o,i,a,m)}return m}executeWildcardQuery(e){const t=new Map,n={...this._options.searchOptions,...e};for(const[o,i]of this._documentIds){const r=n.boostDocument?n.boostDocument(i,"",this._storedFields.get(o)):1;t.set(o,{score:r,terms:[],match:{}})}return t}combineResults(e,t=ee){if(e.length===0)return new Map;const n=t.toLowerCase(),o=Ce[n];if(!o)throw new Error(`Invalid combination operator: ${t}`);return e.reduce(o)||new Map}toJSON(){const e=[];for(const[t,n]of this._index){const o={};for(const[i,r]of n)o[i]=Object.fromEntries(r);e.push([t,o])}return{documentCount:this._documentCount,nextId:this._nextId,documentIds:Object.fromEntries(this._documentIds),fieldIds:this._fieldIds,fieldLength:Object.fromEntries(this._fieldLength),averageFieldLength:this._avgFieldLength,storedFields:Object.fromEntries(this._storedFields),dirtCount:this._dirtCount,index:e,serializationVersion:2}}termResults(e,t,n,o,i,r,c,a,d=new Map){if(i==null)return d;for(const h of Object.keys(r)){const _=r[h],m=this._fieldIds[h],l=i.get(m);if(l==null)continue;let f=l.size;const p=this._avgFieldLength[m];for(const u of l.keys()){if(!this._documentIds.has(u)){this.removeTerm(m,u,t),f-=1;continue}const g=c?c(this._documentIds.get(u),t,this._storedFields.get(u)):1;if(!g)continue;const w=l.get(u),O=this._fieldLength.get(u)[m],V=Le(w,f,this._documentCount,O,p,a),j=n*o*_*g*V,x=d.get(u);if(x){x.score+=j,Ae(x.terms,e);const z=te(x.match,t);z?z.push(h):x.match[t]=[h]}else d.set(u,{score:j,terms:[e],match:{[t]:[h]}})}}return d}addTerm(e,t,n){const o=this._index.fetch(n,ye);let i=o.get(e);if(i==null)i=new Map,i.set(t,1),o.set(e,i);else{const r=i.get(t);i.set(t,(r||0)+1)}}removeTerm(e,t,n){if(!this._index.has(n)){this.warnDocumentChanged(t,e,n);return}const o=this._index.fetch(n,ye),i=o.get(e);i==null||i.get(t)==null?this.warnDocumentChanged(t,e,n):i.get(t)<=1?i.size<=1?o.delete(e):i.delete(t):i.set(t,i.get(t)-1),this._index.get(n).size===0&&this._index.delete(n)}warnDocumentChanged(e,t,n){for(const o of Object.keys(this._fieldIds))if(this._fieldIds[o]===t){this._options.logger("warn",`MiniSearch: document with ID ${this._documentIds.get(e)} has changed before removal: term "${n}" was not present in field "${o}". Removing a document after it has changed can corrupt the index!`,"version_conflict");return}}addDocumentId(e){const t=this._nextId;return this._idToShortId.set(e,t),this._documentIds.set(t,e),this._documentCount+=1,this._nextId+=1,t}addFields(e){for(let t=0;t<e.length;t++)this._fieldIds[e[t]]=t}addFieldLength(e,t,n,o){let i=this._fieldLength.get(e);i==null&&this._fieldLength.set(e,i=[]),i[t]=o;const c=(this._avgFieldLength[t]||0)*n+o;this._avgFieldLength[t]=c/(n+1)}removeFieldLength(e,t,n,o){if(n===1){this._avgFieldLength[t]=0;return}const i=this._avgFieldLength[t]*n-o;this._avgFieldLength[t]=i/(n-1)}saveStoredFields(e,t){const{storeFields:n,extractField:o}=this._options;if(n==null||n.length===0)return;let i=this._storedFields.get(e);i==null&&this._storedFields.set(e,i={});for(const r of n){const c=o(t,r);c!==void 0&&(i[r]=c)}}}C.wildcard=Symbol("*");const te=(s,e)=>Object.prototype.hasOwnProperty.call(s,e)?s[e]:void 0,Ce={[ee]:(s,e)=>{for(const t of e.keys()){const n=s.get(t);if(n==null)s.set(t,e.get(t));else{const{score:o,terms:i,match:r}=e.get(t);n.score=n.score+o,n.match=Object.assign(n.match,r),_e(n.terms,i)}}return s},[pe]:(s,e)=>{const t=new Map;for(const n of e.keys()){const o=s.get(n);if(o==null)continue;const{score:i,terms:r,match:c}=e.get(n);_e(o.terms,r),t.set(n,{score:o.score+i,terms:o.terms,match:Object.assign(o.match,c)})}return t},[Me]:(s,e)=>{for(const t of e.keys())s.delete(t);return s}},Ee={k:1.2,b:.7,d:.5},Le=(s,e,t,n,o,i)=>{const{k:r,b:c,d:a}=i;return Math.log(1+(t-e+.5)/(e+.5))*(a+s*(r+1)/(s+r*(1-c+c*n/o)))},De=s=>(e,t,n)=>{const o=typeof s.fuzzy=="function"?s.fuzzy(e,t,n):s.fuzzy||!1,i=typeof s.prefix=="function"?s.prefix(e,t,n):s.prefix===!0,r=typeof s.boostTerm=="function"?s.boostTerm(e,t,n):1;return{term:e,fuzzy:o,prefix:i,termBoost:r}},se={idField:"id",extractField:(s,e)=>s[e],stringifyField:(s,e)=>s.toString(),tokenize:s=>s.split(Oe),processTerm:s=>s.toLowerCase(),fields:void 0,searchOptions:void 0,storeFields:[],logger:(s,e)=>{typeof console?.[s]=="function"&&console[s](e)},autoVacuum:!0},ge={combineWith:ee,prefix:!1,fuzzy:!1,maxFuzzy:6,boost:{},weights:{fuzzy:.45,prefix:.375},bm25:Ee},Te={combineWith:pe,prefix:(s,e,t)=>e===t.length-1},ne={batchSize:1e3,batchWait:10},ie={minDirtFactor:.1,minDirtCount:20},oe={...ne,...ie},Ae=(s,e)=>{s.includes(e)||s.push(e)},_e=(s,e)=>{for(const t of e)s.includes(t)||s.push(t)},we=({score:s},{score:e})=>e-s,ye=()=>new Map,P=s=>{const e=new Map;for(const t of Object.keys(s))e.set(parseInt(t,10),s[t]);return e},U=async s=>{const e=new Map;let t=0;for(const n of Object.keys(s))e.set(parseInt(n,10),s[n]),++t%1e3===0&&await xe(0);return e},xe=s=>new Promise(e=>setTimeout(e,s)),Oe=/[\n\r\p{Z}\p{P}]+/u,F=24e6,J=48e3,Ve=2,E=s=>JSON.stringify([Ve,s.revision,s.updated,s.created,s.projectID,s.directory]);function je(s,e){if(!s||!e||s.id!==e.id||s.version!==E(e)||!Number.isInteger(s.pages)||s.pages<1||s.pages>8||!Number.isInteger(s.characters)||s.characters<0||s.characters>J||typeof s.partial!="boolean"||typeof s.complete!="boolean"||typeof s.capped!="boolean"||s.cursor!==void 0&&(typeof s.cursor!="string"||!/^\d{1,9}$/.test(s.cursor))||s.complete&&(s.partial||s.capped||s.cursor)||!s.complete&&!s.capped&&(!s.cursor||s.pages>=8)||!Array.isArray(s.fragments)||s.fragments.length>J)return!1;let t=0;for(const n of s.fragments){if(!n||!["You","Assistant","Tool","File"].includes(n.kind)||typeof n.text!="string"||n.text.length>2e3||!Number.isFinite(n.time))return!1;t+=n.text.length}return t===s.characters}const b=s=>s.normalize("NFKD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase(),re=s=>b(s).match(/[\p{L}\p{N}]+/gu)||[],ce=s=>re(s).join(" ");function Ne(s){const e={text:"",terms:[],phrases:[],filters:[]},t=[];for(const n of s.slice(0,300).match(/(?:[^\s"]+|"[^"]*")+/g)||[]){const o=/^(source|project|dir|model|is|after|before|in):(.+)$/i.exec(n);if(o){const r=o[1].toLowerCase(),c=b(o[2].replace(/^"|"$/g,""));if(r==="in"){const a={title:["title"],files:["files"],messages:["body"],tools:["tools"]};e.fields=a[c],e.fields||(e.error="Use in:title, in:files, in:messages, or in:tools.")}else r==="is"&&!["fork","child","root","archived"].includes(c)?e.error="Use is:fork, is:child, is:root, or is:archived.":["after","before"].includes(r)&&(!/^\d{4}-\d{2}-\d{2}$/.test(c)||!Number.isFinite(Date.parse(c))||new Date(c).toISOString().slice(0,10)!==c)?e.error="Use a valid date in YYYY-MM-DD format.":e.filters.push([r,c]);continue}const i=n.replace(/^"|"$/g,"");n.startsWith('"')&&n.endsWith('"')&&e.phrases.push(ce(i)),t.push(i)}return e.text=t.join(" "),e.terms=re(e.text).slice(0,12),e.text=e.terms.join(" "),e}function $e(s,e,t=220){const n=b(s),o=e.reduce((r,c)=>{const a=n.indexOf(c);return a<0?r:Math.min(r,a)},1/0),i=Number.isFinite(o)?Math.max(0,o-55):0;return`${i?"…":""}${s.slice(i,i+t).replace(/\s+/g," ").trim()}${s.length>i+t?"…":""}`}class Re{index=new C({fields:["title","project","directory","model","sessionID","files","body","tools"],tokenize:re,processTerm:b,searchOptions:{combineWith:"AND",prefix:!0,boost:{title:12,files:5,project:3,directory:3,model:2,sessionID:12,body:1,tools:.6}}});entries=new Map;cache=new Map;scope=new Set;setData(e,t){const n=new Set(e.map(i=>i.id));for(const[i,r]of this.entries)n.has(i)||(this.index.remove(r.doc),this.entries.delete(i));const o=new Map(t.map(i=>[i.id,i.name]));for(const i of e){const r=this.entries.get(i.id),c=r&&E(r.session)===E(i),a={id:i.id,title:i.title,project:o.get(i.projectID)||"",directory:i.directory,model:i.model,sessionID:i.id,body:c?r.doc.body:"",files:c?r.doc.files:"",tools:c?r.doc.tools:""};if(c&&Object.keys(a).every(d=>r.doc[d]===a[d])){r.session=i;continue}this.entries.set(i.id,{session:i,doc:a,fragments:c?r.fragments:[]}),r&&this.index.remove(r.doc),this.index.add(a)}this.cache.clear()}setScope(e){this.scope=new Set(e),this.cache.clear()}content(e){return this.entries.get(e)?.fragments.slice()||[]}addContent(e,t){const n=this.entries.get(e);if(!n)return;n.fragments.push(...t);const o={...n.doc};for(const i of t){const r=i.kind==="File"?"files":i.kind==="Tool"?"tools":"body";o[r]+=`
|
|
2
|
+
${i.text}`}this.index.remove(n.doc),this.index.add(o),n.doc=o,this.cache.clear()}search(e,t=!1,n=80,o=0){const i=`${e}\0${t}\0${n}\0${o}`,r=this.cache.get(i);if(r)return r;const c=Ne(e);if(c.error)return{hits:[],total:0,error:c.error};const a=l=>{const{session:f,doc:p}=l;if(t&&!this.scope.has(f.id))return!1;for(const[u,g]of c.filters)if(u==="source"&&![f.source||"opencode",...(f.linkedSessionIDs||[]).map(w=>w.split(":")[0])].some(w=>b(w).includes(g))||u==="project"&&!b(p.project).includes(g)&&!b(f.projectID).includes(g)||u==="dir"&&!b(f.directory).includes(g)||u==="model"&&!b(f.model).includes(g)||u==="after"&&f.created<new Date(`${g}T00:00:00`).getTime()||u==="before"&&f.created>new Date(`${g}T23:59:59.999`).getTime()||u==="is"&&(g==="fork"&&!f.forkID||g==="child"&&(!f.parentID||f.forkID)||g==="root"&&(f.parentID||f.forkID)||g==="archived"&&!f.archived))return!1;if(c.phrases.length){const u=c.fields||["title","body","files","tools","project","directory","model"];if(!c.phrases.every(g=>u.some(w=>ce(p[w]).includes(g))))return!1}return!0},h=(c.terms.length?this.index.search(c.text,{fields:c.fields,fuzzy:l=>l.length<4?!1:l.length>7?2:1,filter:l=>a(this.entries.get(String(l.id)))}):[...this.entries.values()].filter(a).map(l=>({id:l.session.id,score:0,terms:[],match:{}}))).map(l=>{const f=this.entries.get(String(l.id)),p=ce(f.doc.title),u=new Set(Object.values(l.match).flat()),g=c.text?p.includes(c.text)&&(!c.fields||c.fields.includes("title"))?5:u.has("title")||u.has("sessionID")?4:u.has("files")?3:u.has("body")?2:1:0;return{match:l,entry:f,tier:g}}).sort((l,f)=>f.tier-l.tier||f.match.score-l.match.score||f.entry.session.updated-l.entry.session.updated||l.entry.session.id.localeCompare(f.entry.session.id)),m={hits:h.slice(o,o+Math.min(250,Math.max(1,n))).map(({match:l,entry:f,tier:p})=>{const u=l.terms.length?l.terms:c.terms,g=f.fragments.filter(x=>!c.fields||c.fields.includes(x.kind==="File"?"files":x.kind==="Tool"?"tools":"body"));let w,O=0;for(const x of g){const z=b(x.text),G=u.reduce((Je,qe)=>Je+Number(z.includes(qe)),0);if(G>O&&(w=x,O=G),G===u.length&&G>0)break}const V=new Set(Object.values(l.match).flat()),j=p>=4?V.has("sessionID")&&!V.has("title")?"Session ID":"Title":w?w.kind==="File"?"File":w.kind==="Tool"?"Tool":"Message":c.text?"Metadata":"Recent";return{id:f.session.id,score:l.score,source:j,excerpt:w?$e(w.text,u):"",terms:u}}),total:h.length};return this.cache.size>=30&&this.cache.delete(this.cache.keys().next().value),this.cache.set(i,m),m}}function We(s,e){let t=Math.max(0,e),n=!1;const o=[],i=[...s.fragments].sort((c,a)=>+(a.kind==="File"||a.kind==="You")-+(c.kind==="File"||c.kind==="You")),r=Math.max(160,Math.min(2e3,Math.floor(t/Math.max(1,i.length))));for(const c of i){if(t<=0){n=!0;break}const a=c.text.slice(0,Math.min(t,r));n||=a.length<c.text.length,o.push({...c,text:a}),t-=a.length}return{fragments:o,characters:Math.max(0,e)-t,partial:s.truncated||n}}class Pe{available=!0;epoch=0;async restore(e,t,n){const o=new Map(t.map(c=>[c.id,c]));let i,r=0;try{do{const c=await fetch(`/api/sessiongraph/index${i?`?after=${encodeURIComponent(i)}`:""}`);if(!c.ok)throw new Error("Index unavailable");const a=await c.json();this.epoch=a.epoch;for(const d of a.records)je(d,o.get(d.id))&&r+d.characters<=F&&(r+=d.characters,n(d));i=a.cursor}while(i);try{globalThis.indexedDB?.deleteDatabase("atlas-search")}catch{}}catch{this.available=!1}}async save(e){if(this.available)try{const t=await fetch("/api/sessiongraph/index",{method:"POST",headers:{"Content-Type":"application/json","X-SessionGraph-Action":"index"},body:JSON.stringify({record:e,epoch:this.epoch})});!t.ok&&t.status!==409&&(this.available=!1)}catch{this.available=!1}}async clear(){const e=await fetch("/api/sessiongraph/index",{method:"DELETE",headers:{"X-SessionGraph-Action":"index"}});if(this.available=e.ok,!e.ok)throw new Error("Could not clear saved index.")}}const v=new Re,q=new Pe,y=new Map,L=new Set;let D=!1,Q=0,S=0,k=0,B=!1,T,A,be=[],ae,Se=0;const Y=new Set,N=s=>postMessage(s);function $(){if(!A)return;const s=performance.now(),e=v.search(A.text,A.viewOnly,A.limit);be=e.hits.slice(0,12).map(t=>t.id),N({type:"results",request:A.request,...e,elapsed:performance.now()-s})}function R(){const s=[...y.values()];N({type:"status",status:{indexed:s.filter(e=>e.pages>0).length,complete:s.filter(e=>e.complete).length,total:y.size,characters:S,active:D&&Q>0,limited:S>=F||s.some(e=>e.partial||e.capped),failed:s.filter(e=>e.failed>0).length,restored:L.size,storage:B?T?.sourceID&&q.available?"local":"memory":"restoring"}})}function Ie(){ae||(ae=setTimeout(()=>{ae=void 0,$(),R()},200))}function Ue(){const s=t=>!!(t&&!t.inflight&&!t.complete&&!t.capped&&t.failed<1);for(const t of be){const n=y.get(t);if(s(n)&&n.pages<2)return n}let e;for(const t of y.values())s(t)&&(!e||t.pages<e.pages)&&(e=t);return e}function de(){if(!B||!D||S>=F){R();return}for(;Q<2;){const s=Ue();if(!s)break;s.inflight=!0,Q++;const e=k,t=new AbortController;Y.add(t),(async()=>{try{const n=new URLSearchParams({updated:String(s.session.updated)});s.cursor&&n.set("cursor",s.cursor);const o=await fetch(`/api/sessiongraph/session/${encodeURIComponent(s.session.id)}/content?${n}`,{signal:t.signal});if(!o.ok)throw new Error("Conversation unavailable");const i=await o.json();if(e!==k||t.signal.aborted)return;if(i.id!==s.session.id)throw new Error("Unexpected conversation");const r=Math.min(J,Math.floor(F/Math.max(1,y.size))),c=We(i,Math.min(r-s.characters,F-S));s.characters+=c.characters,S+=c.characters,v.addContent(s.session.id,c.fragments),s.pages++,s.partial||=c.partial,s.complete=!i.nextCursor&&!s.partial,s.capped=!s.complete&&(!i.nextCursor||s.characters>=r||s.pages>=8),s.cursor=i.nextCursor||void 0,Ie(),T?.sourceID&&await q.save({id:s.session.id,version:E(s.session),fragments:v.content(s.session.id),pages:s.pages,characters:s.characters,partial:s.partial,complete:s.complete,capped:s.capped,cursor:s.cursor})}catch{!t.signal.aborted&&e===k&&s.failed++}finally{s.inflight=!1,Y.delete(t),Q--,D?setTimeout(de,performance.now()-Se<150?150:35):R()}})()}R()}async function Fe(s,e=!1){const t=++k;B=!1,Y.forEach(r=>r.abort());const n=T?.sourceID===s.sourceID&&!e,o=n?new Map(y):new Map;n||(v.setData([],[]),L.clear()),T=s,y.clear(),S=0;for(const r of[...s.sessions].sort((c,a)=>a.updated-c.updated)){const c=o.get(r.id),a=c&&E(c.session)===E(r),d=a?{...c,session:r,inflight:!1}:{session:r,pages:0,characters:0,partial:!1,complete:!1,capped:!1,failed:0,inflight:!1};a||L.delete(r.id),y.set(r.id,d),S+=d.characters}for(const r of L)y.has(r)||L.delete(r);if(v.setData(s.sessions,s.projects),$(),R(),e&&await q.clear(),t!==k||(s.sourceID&&await q.restore(s.sourceID,s.sessions,r=>{if(t!==k)return;const c=y.get(r.id);!c||c.pages||S+r.characters>F||(v.addContent(r.id,r.fragments),Object.assign(c,{pages:r.pages,characters:r.characters,partial:r.partial,complete:r.complete,capped:r.capped,cursor:r.cursor}),S+=r.characters,L.add(r.id),Ie())}),t!==k))return;const i=Math.min(J,Math.floor(F/Math.max(1,y.size)));for(const r of y.values())!r.complete&&r.characters>=i&&(r.capped=!0);B=!0,$(),de()}self.onmessage=s=>{try{const e=s.data;e.type==="data"?Fe(e).catch(()=>N({type:"error",message:"Search index could not load. Reload to retry."})):e.type==="scope"?(v.setScope(e.ids),$()):e.type==="query"?(Se=performance.now(),A=e,$()):e.type==="clear-cache"?(D=!1,T&&Fe(T,!0).catch(()=>N({type:"error",message:"Search index could not reset. Reload to retry."}))):(D=e.enabled,D?y.forEach(t=>{t.failed=0}):Y.forEach(t=>t.abort()),de())}catch(e){N({type:"error",message:e instanceof Error?e.message:"Search unavailable"})}}})();
|
package/dist/index.html
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<link rel="icon" sizes="any" href="/favicon.ico" />
|
|
13
13
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
14
14
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
|
15
|
-
<script type="module" crossorigin src="/assets/index-
|
|
15
|
+
<script type="module" crossorigin src="/assets/index-CIhs02tq.js"></script>
|
|
16
16
|
<link rel="stylesheet" crossorigin href="/assets/index-cVgPCrFV.css">
|
|
17
17
|
</head>
|
|
18
18
|
<body>
|