forge-cw 0.1.36 → 0.1.38
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/console/assets/index-BiJ7yYR0.css +1 -0
- package/console/assets/index-D_jk3Q_f.js +31 -0
- package/console/index.html +2 -2
- package/console/shared/forge-dev-ui.js +9 -9
- package/dist/index.js +259 -91
- package/package.json +3 -3
- package/console/assets/index-CL35efIa.css +0 -1
- package/console/assets/index-NDnMxbuC.js +0 -31
package/console/index.html
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
8
|
<title>Forge Console</title>
|
|
9
9
|
<script type="importmap">{"imports":{"preact":"/shared/preact.js","preact/hooks":"/shared/preact-hooks.js","preact/jsx-runtime":"/shared/preact-jsx-runtime.js","preact/compat":"/shared/preact-compat.js","@preact/signals":"/shared/preact-signals.js","@forge-dev/ui":"/shared/forge-dev-ui.js","@forge-dev/sdk":"/shared/forge-dev-sdk.js"}}</script>
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
11
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-D_jk3Q_f.js"></script>
|
|
11
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BiJ7yYR0.css">
|
|
12
12
|
<link rel="stylesheet" href="/shared/forge-dev-ui.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import{jsx as e}from"./preact-jsx-runtime.js";import{useState as
|
|
2
|
-
\x1B[${
|
|
3
|
-
`),E==null||E.close()})),o&&!k){const
|
|
1
|
+
import{jsx as e}from"./preact-jsx-runtime.js";import{useState as F,useRef as S,useEffect as A,useLayoutEffect as Q,useCallback as re}from"./preact-hooks.js";import{signal as te}from"./preact-signals.js";import{createPortal as Y}from"./preact-compat.js";import"./preact.js";const ne={good:"var(--green)",warn:"var(--orange)",bad:"var(--red)",neutral:"var(--ink-3)"},ye=({icon:r,label:n,value:o,trend:t,status:a})=>e("div",{class:"relative overflow-hidden",style:{padding:"10px 12px",borderRadius:"13px",background:"var(--card)",border:"1px solid var(--hair)",boxShadow:"var(--shadow-s)"},children:[e("div",{class:"flex items-center gap-2",style:{fontSize:"11.5px",color:"var(--ink-2)"},children:[e("span",{children:r}),e("span",{children:n})]}),e("div",{class:"mono",style:{fontSize:"19px",fontWeight:650,marginTop:"2px"},children:o}),t&&e("div",{class:"mono",style:{fontSize:"11.5px",marginTop:"2px",color:t.startsWith("-")?"var(--red)":"var(--green)"},children:t}),e("div",{class:"absolute bottom-0 left-0 right-0 h-0.5",style:{backgroundColor:ne[a]}})]}),oe={sm:{pad:"6px 12px",primaryPad:"6px 14px",font:"12.5px",radius:"var(--r-sm)"},md:{pad:"7px 13px",primaryPad:"7px 15px",font:"13px",radius:"var(--r-sm)"},lg:{pad:"10px 18px",primaryPad:"10px 18px",font:"14px",radius:"var(--r-md)"}},q={primary:{background:"linear-gradient(180deg, var(--accent-top), var(--accent-bot))",color:"var(--on-accent)",border:"0",boxShadow:"var(--shadow-primary)",fontWeight:"600"},secondary:{background:"var(--card)",color:"var(--ink)",border:"0",boxShadow:"var(--shadow-s)",fontWeight:"500"},danger:{background:"var(--card)",color:"var(--red-ink, var(--red))",border:"0",boxShadow:"var(--shadow-s)",fontWeight:"500"},destructive:{background:"var(--red-fill, var(--red))",color:"#fff",border:"0",boxShadow:"var(--shadow-s)",fontWeight:"600"},ghost:{background:"transparent",color:"var(--blue-ink)",border:"0",boxShadow:"none",fontWeight:"600"}},ae={background:"var(--well)",color:"var(--ink-4)",border:"0",boxShadow:"var(--inset-s)",opacity:"1"},se=({label:r,icon:n,variant:o="primary",size:t="md",block:a,title:p,disabled:l,loading:d,onClick:i})=>{const[c,x]=F(!1),v=d??c,s=!!(l||v),g=async()=>{if(!s){x(!0);try{await i()}finally{x(!1)}}},m=oe[t],y=o==="primary"||o==="destructive",z=o==="ghost"?"hover:bg-elev":`hover:-translate-y-px ${y?"hover:brightness-106":"hover:shadow-m"}`,O=l&&!v?{...q[o],...ae}:q[o];return e("button",{type:"button",class:`inline-flex items-center justify-center gap-1.5 whitespace-nowrap transition-all duration-180 ease-spring ${s?"cursor-not-allowed":`cursor-pointer ${z}`}${a?" w-full":""}`,style:{...O,padding:y?m.primaryPad:m.pad,fontSize:m.font,borderRadius:m.radius},disabled:s,title:p,onClick:g,children:[v?e("span",{class:"i-lucide-loader-2 animate-spin"}):n?e("span",{class:n}):null,e("span",{children:r})]})},ie="modulepreload",le=function(r){return"/"+r},X={},I=function(n,o,t){let a=Promise.resolve();if(o&&o.length>0){let l=function(c){return Promise.all(c.map(x=>Promise.resolve(x).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),i=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));a=l(o.map(c=>{if(c=le(c),c in X)return;X[c]=!0;const x=c.endsWith(".css"),v=x?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${v}`))return;const s=document.createElement("link");if(s.rel=x?"stylesheet":ie,x||(s.as="script"),s.crossOrigin="",s.href=c,i&&s.setAttribute("nonce",i),document.head.appendChild(s),x)return new Promise((g,m)=>{s.addEventListener("load",g),s.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function p(l){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=l,window.dispatchEvent(d),!d.defaultPrevented)throw l}return a.then(l=>{for(const d of l||[])d.status==="rejected"&&p(d.reason);return n().catch(p)})};function Z(r){/^https?:\/\//i.test(r)&&window.open(r,"_blank","noopener")}const ce='ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace',j=r=>({background:r==="dark"?"#0e0e10":"#1c1c1e",foreground:"#e3e3e8",cursor:"#e3e3e8",selectionBackground:"rgba(10,132,255,0.35)"}),ke=({streamUrl:r,content:n,wsUrl:o,height:t=300,onExit:a,onGiveUp:p,onConnectionChange:l,onOutput:d,focused:i=!0,theme:c="dark",pasteRef:x})=>{const v=S(null),s=!!o,g=S(a);g.current=a;const m=S(p);m.current=p;const y=S(l);y.current=l;const z=S(d);z.current=d;const O=S(c);O.current=c;const J=S(i);J.current=i;const L=S(null);A(()=>{L.current&&(L.current.options.theme=j(c))},[c]),A(()=>{if(x)return x.current=k=>{var u,T;(u=L.current)==null||u.paste(k),(T=L.current)==null||T.focus()},()=>{x.current=null}},[x]),A(()=>{var k;s&&i&&((k=L.current)==null||k.focus())},[i,s]),A(()=>{if(!v.current)return;let k=!1,u=null,T=null,P=0;const H=[];return(async()=>{const{Terminal:D}=await I(async()=>{const{Terminal:f}=await import("./chunk-DlVFs1Kw.js").then(h=>h.x);return{Terminal:f}},[]),{FitAddon:U}=await I(async()=>{const{FitAddon:f}=await import("./chunk-BlxrFPDK.js").then(h=>h.a);return{FitAddon:f}},[]),{WebLinksAddon:ee}=await I(async()=>{const{WebLinksAddon:f}=await import("./chunk-BWjmmSgS.js");return{WebLinksAddon:f}},[]);if(k)return;const b=new D({theme:j(O.current),fontSize:13,fontFamily:ce,convertEol:!s,disableStdin:!s,cursorBlink:s,scrollback:1e4,linkHandler:{activate:(f,h)=>Z(h),allowNonHttpProtocols:!1}});L.current=b;const N=f=>{var h;b.write(f),(h=z.current)==null||h.call(z,f)},B=new U;b.loadAddon(B),b.loadAddon(new ee((f,h)=>Z(h))),b.open(v.current),setTimeout(()=>{B.fit(),s&&J.current&&b.focus()},50),n&&!s&&N(n);let E;if(r&&!s&&(E=new EventSource(r),E.addEventListener("output",f=>{const{chunk:h}=JSON.parse(f.data);N(h)}),E.addEventListener("done",f=>{const{exitCode:h}=JSON.parse(f.data);b.write(`\r
|
|
2
|
+
\x1B[${h===0?"32":"31"}m--- Exit code: ${h} ---\x1B[0m\r
|
|
3
|
+
`),E==null||E.close()})),o&&!k){const f=h=>{if(k)return;console.log("[ForgeTerminal] Connecting to:",h),u=new WebSocket(h);const C=[];u.onopen=()=>{var w;console.log("[ForgeTerminal] WebSocket OPEN"),P=0,(w=y.current)==null||w.call(y,!0),B.fit();const{cols:W,rows:$}=b;u.send(JSON.stringify({type:"resize",cols:W,rows:$})),C.push(b.onData(R=>{(u==null?void 0:u.readyState)===WebSocket.OPEN&&u.send(JSON.stringify({type:"input",data:R}))})),C.push(b.onResize(({cols:R,rows:_})=>{(u==null?void 0:u.readyState)===WebSocket.OPEN&&u.send(JSON.stringify({type:"resize",cols:R,rows:_}))}))},u.onmessage=W=>{var $;try{const w=JSON.parse(W.data);w.type==="output"||w.type==="scrollback"?N(w.data):w.type==="exit"?(b.write(`\r
|
|
4
4
|
\x1B[33m--- Session ended (code ${w.code}) ---\x1B[0m\r
|
|
5
|
-
`),(
|
|
5
|
+
`),($=g.current)==null||$.call(g,w.code)):w.type==="error"&&b.write(`\r
|
|
6
6
|
\x1B[31m--- Error: ${w.message} ---\x1B[0m\r
|
|
7
|
-
`)}catch{}},
|
|
7
|
+
`)}catch{}},u.onclose=W=>{var $,w,R;if(console.log("[ForgeTerminal] WebSocket CLOSE:",W.code,W.reason),C.forEach(_=>_.dispose()),C.length=0,($=y.current)==null||$.call(y,!1),!k)if(W.code===4404)b.write(`\r
|
|
8
8
|
\x1B[31m--- Click Restart to try again. ---\x1B[0m\r
|
|
9
|
-
`),(w=
|
|
10
|
-
\x1B[90m--- Reconnecting (attempt ${
|
|
11
|
-
`),
|
|
9
|
+
`),(w=m.current)==null||w.call(m);else if(P<5){const _=Math.min(2e3*Math.pow(2,P),16e3);P++,b.write(`\r
|
|
10
|
+
\x1B[90m--- Reconnecting (attempt ${P}/5)... ---\x1B[0m\r
|
|
11
|
+
`),T=setTimeout(()=>f(h),_)}else b.write(`\r
|
|
12
12
|
\x1B[31m--- Connection lost. Click Restart to try again. ---\x1B[0m\r
|
|
13
|
-
`),($=h.current)==null||$.call(h)},m.onerror=W=>{console.error("[ForgeTerminal] WebSocket error:",W)}};v(o)}const H=new ResizeObserver(()=>{k||M.fit()});H.observe(f.current),J.push({dispose:()=>{E==null||E.close(),H.disconnect(),F&&clearTimeout(F),m&&(k=!0,m.close()),b.dispose(),R.current=null}})})(),()=>{k=!0,J.forEach(D=>D.dispose())}},[r,n,o,p]);const K=p?{width:"100%",height:"100%"}:{width:"100%",height:`${t}px`};return e("div",{ref:f,class:"overflow-hidden",style:{...K,background:j(l).background}})},_=re([]);function ke(r,n="info"){const o=Math.random().toString(36).slice(2);_.value=[..._.value,{id:o,message:r,type:n}],setTimeout(()=>{_.value=_.value.filter(t=>t.id!==o)},4e3)}const ce={success:"var(--green)",error:"var(--red)",info:"var(--blue)"},Se=()=>e("div",{class:"fixed bottom-4 right-4 flex flex-col gap-2 z-[70]",style:{maxWidth:"calc(100vw - 32px)"},role:"status","aria-live":"polite",children:_.value.map(r=>e("div",{class:"flex items-center gap-2.5",style:{padding:"10px 14px",borderRadius:"var(--r-md)",background:"var(--card)",boxShadow:"var(--shadow-l)",fontSize:"13px",color:"var(--ink)",animation:"riseIn .3s var(--ease) both"},children:[e("span",{class:"shrink-0",style:{width:"6px",height:"6px",borderRadius:"50%",background:ce[r.type]}}),r.message]},r.id))}),de=({label:r,color:n="var(--ink-2)",variant:o="tint",dot:t})=>{const a=o==="tint"?{background:`color-mix(in srgb, ${n} var(--tint, 18%), transparent)`,color:n}:{background:"var(--well)",color:"var(--ink-2)"};return e("span",{class:"inline-flex items-center gap-1.5 whitespace-nowrap shrink-0",style:{...a,height:"20px",padding:"0 8px",borderRadius:"var(--r-pill)",fontSize:"11px",lineHeight:"20px",fontWeight:600},children:[t&&e("span",{style:{width:"6px",height:"6px",borderRadius:"50%",background:n}}),r]})},Y=({onClick:r,label:n="Close"})=>e("button",{type:"button","aria-label":n,class:"grid place-items-center shrink-0 cursor-pointer transition-all duration-180 ease-spring hover:text-ink",style:{width:"26px",height:"26px",borderRadius:"50%",border:0,background:"var(--card)",boxShadow:"var(--shadow-s)",color:"var(--ink-2)"},onClick:r,children:e("span",{class:"i-lucide-x",style:{width:"13px",height:"13px"}})}),Ee=({open:r,title:n,onClose:o,footer:t,width:a=540,children:u})=>(Z(()=>{if(!r)return;const i=d=>{d.key==="Escape"&&o()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[r,o]),r?Q(e("div",{class:"fixed inset-0 z-[55] flex items-start justify-center overflow-auto",style:{background:"var(--scrim)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",padding:"56px 16px 16px"},onClick:o,children:e("div",{role:"dialog","aria-modal":"true","aria-label":n,class:"flex flex-col overflow-hidden",style:{width:`min(${a}px, 100%)`,maxHeight:"calc(100vh - 72px)",borderRadius:"var(--r-xl)",background:"var(--bg-2)",boxShadow:"var(--shadow-l)",animation:"popIn .26s var(--ease) both"},onClick:i=>i.stopPropagation(),children:[e("div",{class:"flex items-center gap-2.5 shrink-0",style:{padding:"14px 18px",borderBottom:"1px solid var(--hair)"},children:[e("h2",{style:{fontSize:"17px",fontWeight:700,letterSpacing:"-0.02em"},children:n}),e("span",{class:"flex-1"}),e(Y,{onClick:o})]}),e("div",{class:"overflow-auto min-h-0",style:{padding:"16px 18px"},children:u}),t&&e("div",{class:"flex items-center gap-2.5 shrink-0",style:{padding:"13px 18px",borderTop:"1px solid var(--hair)"},children:t})]})}),document.body):null),We=({title:r,onClose:n,children:o})=>(Z(()=>{const t=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[n]),Q(e("div",{class:"fixed inset-0 z-50 flex justify-end",style:{background:"var(--scrim)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)"},onClick:n,children:e("aside",{role:"dialog","aria-modal":"true","aria-label":r,class:"flex flex-col h-full overflow-auto",style:{width:"min(492px, 100%)",background:"var(--bg-2)",boxShadow:"var(--shadow-l)",animation:"slideIn .3s var(--ease) both"},onClick:t=>t.stopPropagation(),children:[e("div",{class:"glass flex items-center sticky top-0 z-1",style:{gap:"10px",padding:"14px 18px",boxShadow:"var(--chrome-edge)"},children:[e("h2",{style:{fontSize:"17px",fontWeight:700,letterSpacing:"-0.02em"},children:r}),e("span",{class:"flex-1"}),e(Y,{onClick:n})]}),e("div",{class:"flex flex-col",style:{padding:"16px 18px 24px",gap:"14px"},children:o})]})}),document.body)),ze=({tabs:r,active:n,onChange:o,fill:t,size:a="md",label:u})=>{const i=a!=="md",d=a==="xs";return e("div",{role:"tablist","aria-label":u,class:`${t?"flex":"inline-flex"} max-w-full overflow-x-auto`,style:{padding:"3px",borderRadius:"var(--r-md)",background:"var(--well)",boxShadow:"var(--inset-s)"},children:r.map(s=>{const l=n===s.id;return e("button",{type:"button",role:"tab","aria-selected":l,disabled:s.disabled,"aria-label":s.icon?s.label:void 0,title:s.icon?s.label:void 0,class:`flex items-center justify-center gap-1.5 whitespace-nowrap transition-all duration-200 ease-spring ${t?"flex-1":""} ${s.disabled?"cursor-not-allowed opacity-50":"cursor-pointer"}`,style:{padding:s.icon?"5px 9px":d?"4px 0":t?i?"5px 6px":"7px 8px":i?"5px 11px":"6px 12px",border:0,borderRadius:"var(--r-sm)",fontSize:d?"11px":i?"12px":"12.5px",fontWeight:600,background:l?"var(--seg-on, var(--card))":"transparent",color:l?"var(--ink)":"var(--ink-2)",boxShadow:l?"var(--lit), var(--shadow-s)":"none"},onClick:()=>o(s.id),children:[s.icon?e("span",{class:s.icon,"aria-hidden":"true",style:{width:"14px",height:"14px"}}):s.label,s.count!==void 0&&e("span",{class:"mono num",style:{fontSize:"11px",fontWeight:400,color:"var(--ink-3)"},children:s.count})]},s.id)})})},pe=({item:r,onItemClick:n})=>{const[o,t]=C(!1);return e("div",{class:`flex items-center justify-between transition-all duration-180 ease-spring ${n?"cursor-pointer":""}`,style:{padding:"11px 15px",borderRadius:"12px",background:"var(--card)",border:`1px solid ${n&&o?"var(--hair-2)":"var(--hair)"}`,boxShadow:"var(--shadow-s)"},onMouseEnter:n?()=>t(!0):void 0,onMouseLeave:n?()=>t(!1):void 0,onClick:n?()=>n(r.id):void 0,children:[e("div",{class:"min-w-0 flex-1",children:[e("div",{class:"truncate",style:{fontSize:"14px",fontWeight:600},children:r.title}),r.subtitle&&e("div",{class:"truncate",style:{fontSize:"12px",color:"var(--ink-2)",marginTop:"2px"},children:r.subtitle})]}),e("div",{class:"flex items-center gap-2 ml-3",children:[r.badge&&e(de,{label:r.badge.label,color:r.badge.color,variant:"tint"}),r.trailing]})]})},Le=({items:r,loading:n,onItemClick:o})=>n?e("div",{class:"space-y-2",children:[1,2,3].map(t=>e("div",{class:"h-16 animate-pulse",style:{borderRadius:"12px",background:"var(--card)"}},t))}):r.length===0?null:e("div",{class:"space-y-1",children:r.map(t=>e(pe,{item:t,onItemClick:o},t.id))}),$e=({icon:r,title:n,description:o,action:t})=>e("div",{class:"flex flex-col items-center justify-center text-center mx-auto",style:{maxWidth:"520px",padding:"36px 28px",borderRadius:"16px",background:"var(--card)",border:"1px solid var(--hair)",boxShadow:"var(--shadow-m)",animation:"riseIn .34s var(--ease) both"},children:[r&&e("span",{class:r,style:{width:"28px",height:"28px",color:"var(--ink-3)",marginBottom:"14px"}}),e("h3",{style:{fontSize:"17px",fontWeight:700,letterSpacing:"-0.02em",marginBottom:"6px"},children:n}),o&&e("p",{style:{fontSize:"13px",color:"var(--ink-2)",maxWidth:"40ch",marginBottom:t?"16px":0},children:o}),t&&e(ae,{label:t.label,variant:"primary",onClick:t.onClick})]}),Re=({checked:r,onChange:n,label:o,disabled:t})=>e("button",{type:"button",role:"switch","aria-checked":r,"aria-label":o,disabled:t,class:`relative shrink-0 ${t?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,style:{width:"44px",height:"26px",borderRadius:"99px",border:0,background:r?"linear-gradient(180deg, var(--accent-top), var(--accent-bot))":"var(--well)",boxShadow:r?"none":"inset 0 0 0 1px var(--hair-2), var(--inset-s)",transition:"background .22s var(--ease)"},onClick:()=>!t&&n(!r),children:e("span",{class:"absolute pointer-events-none",style:{top:"3px",left:r?"21px":"3px",width:"20px",height:"20px",borderRadius:"50%",background:"#fff",boxShadow:"var(--shadow-s)",transition:"left .22s var(--ease)"}})}),Te=({left:r,right:n,defaultWidth:o=300,minWidth:t=200,maxWidth:a=600,storageKey:u="forge-split-width"})=>{const[i,d]=C(()=>{if(typeof localStorage<"u"&&u){const c=localStorage.getItem(u);if(c){const h=parseInt(c,10);if(!isNaN(h)&&h>=t&&h<=a)return h}}return o}),s=y(!1),l=y(0),f=y(0),p=ee(c=>{c.preventDefault(),s.current=!0,l.current=c.clientX,f.current=i,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[i]);return B(()=>{const c=g=>{if(!s.current)return;const S=g.clientX-l.current,L=Math.min(a,Math.max(t,f.current+S));d(L)},h=()=>{s.current&&(s.current=!1,document.body.style.cursor="",document.body.style.userSelect="",typeof localStorage<"u"&&u&&localStorage.setItem(u,String(i)))};return document.addEventListener("mousemove",c),document.addEventListener("mouseup",h),()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",h)}},[i,t,a,u]),e("div",{class:"flex h-full w-full overflow-hidden",children:[e("div",{class:"shrink-0 overflow-y-auto overflow-x-hidden",style:{width:`${i}px`},children:r}),e("div",{class:"shrink-0 w-1 cursor-col-resize transition-colors hover:bg-blue",style:{backgroundColor:"var(--hair)"},onMouseDown:p}),e("div",{class:"flex-1 min-w-0 overflow-hidden",children:n})]})},Pe=({title:r,defaultOpen:n=!1,children:o})=>{const[t,a]=C(n);return e("div",{style:{borderBottom:"1px solid var(--hair)"},children:[e("button",{class:"flex items-center justify-between w-full px-3 py-2.5 cursor-pointer transition-colors text-ink3 hover:text-ink",style:{fontSize:"11px",fontWeight:600,border:0,background:"none"},onClick:()=>a(!t),children:[e("span",{children:r}),e("span",{class:"transition-transform",style:{transform:t?"rotate(90deg)":"rotate(0deg)"},children:e("span",{class:"i-lucide-chevron-right"})})]}),t&&e("div",{class:"px-3 pb-3",children:o})]})},ue={normal:"--ink-2",warning:"--orange",critical:"--red"},he=({bar:r,size:n})=>{const o=ue[r.severity],t=`var(${o})`,a=n==="sm",u=Math.max(0,Math.min(100,r.percent));return e("span",{class:"flex items-center w-full",style:{gap:a?"6px":"9px"},children:[e("span",{class:"mono num shrink-0 text-right",style:{width:a?"28px":"32px",fontSize:"11px",color:"var(--ink-3)"},children:r.label}),e("span",{class:"relative block flex-1 overflow-hidden",style:{height:a?"4px":"6px",borderRadius:"99px",background:"var(--well)",boxShadow:a?"none":"var(--inset-s)"},children:e("span",{class:"block h-full",style:{width:`${u}%`,borderRadius:"99px",background:t,transition:"width .6s var(--ease)"}})}),e("span",{class:"mono num shrink-0 text-right",style:{width:a?"30px":"36px",fontSize:"11px",fontWeight:600,color:r.severity==="normal"?"var(--ink-2)":`var(${o}-ink, ${t})`},children:[Math.round(r.percent),"%"]}),!a&&e("span",{class:"shrink-0 text-right whitespace-nowrap",style:{width:"112px",fontSize:"11px",color:"var(--ink-3)"},children:r.reset??"—"})]})},_e=({bars:r,size:n="md"})=>e("span",{class:"flex flex-col w-full",style:{gap:n==="sm"?"4px":"6px"},children:r.map((o,t)=>e("span",{class:"flex flex-col w-full",style:{gap:"2px"},children:[e(he,{bar:o,size:n}),o.scope&&n==="md"&&e("span",{style:{paddingLeft:"39px",fontSize:"11px",color:"var(--ink-3)"},children:o.scope})]},t))});export{Pe as AccordionSection,ae as ActionButton,de as Badge,Y as CloseButton,Le as DataList,We as Drawer,$e as EmptyState,ye as ForgeTerminal,Ee as Modal,Te as SplitPane,we as StatusCard,ze as Tabs,Se as ToastContainer,Re as ToggleSwitch,_e as UsageMeter,ke as showToast,_ as toasts};
|
|
13
|
+
`),(R=m.current)==null||R.call(m)},u.onerror=W=>{console.error("[ForgeTerminal] WebSocket error:",W)}};f(o)}const V=new ResizeObserver(()=>{k||B.fit()});V.observe(v.current),H.push({dispose:()=>{E==null||E.close(),V.disconnect(),T&&clearTimeout(T),u&&(k=!0,u.close()),b.dispose(),L.current=null}})})(),()=>{k=!0,H.forEach(D=>D.dispose())}},[r,n,o,s]);const G=s?{width:"100%",height:"100%"}:{width:"100%",height:`${t}px`};return e("div",{ref:v,class:"overflow-hidden",style:{...G,background:j(c).background}})},M=te([]);function Se(r,n="info"){const o=Math.random().toString(36).slice(2);M.value=[...M.value,{id:o,message:r,type:n}],setTimeout(()=>{M.value=M.value.filter(t=>t.id!==o)},4e3)}const de={success:"var(--green)",error:"var(--red)",info:"var(--blue)"},Ee=()=>e("div",{class:"fixed bottom-4 right-4 flex flex-col gap-2 z-[70]",style:{maxWidth:"calc(100vw - 32px)"},role:"status","aria-live":"polite",children:M.value.map(r=>e("div",{class:"flex items-center gap-2.5",style:{padding:"10px 14px",borderRadius:"var(--r-md)",background:"var(--card)",boxShadow:"var(--shadow-l)",fontSize:"13px",color:"var(--ink)",animation:"riseIn .3s var(--ease) both"},children:[e("span",{class:"shrink-0",style:{width:"6px",height:"6px",borderRadius:"50%",background:de[r.type]}}),r.message]},r.id))}),pe=({label:r,color:n="var(--ink-2)",variant:o="tint",dot:t})=>{const a=o==="tint"?{background:`color-mix(in srgb, ${n} var(--tint, 18%), transparent)`,color:n}:{background:"var(--well)",color:"var(--ink-2)"};return e("span",{class:"inline-flex items-center gap-1.5 whitespace-nowrap shrink-0",style:{...a,height:"20px",padding:"0 8px",borderRadius:"var(--r-pill)",fontSize:"11px",lineHeight:"20px",fontWeight:600},children:[t&&e("span",{style:{width:"6px",height:"6px",borderRadius:"50%",background:n}}),r]})},K=({onClick:r,label:n="Close"})=>e("button",{type:"button","aria-label":n,class:"grid place-items-center shrink-0 cursor-pointer transition-all duration-180 ease-spring hover:text-ink",style:{width:"26px",height:"26px",borderRadius:"50%",border:0,background:"var(--card)",boxShadow:"var(--shadow-s)",color:"var(--ink-2)"},onClick:r,children:e("span",{class:"i-lucide-x",style:{width:"13px",height:"13px"}})}),We=({open:r,title:n,onClose:o,footer:t,width:a=540,children:p})=>(Q(()=>{if(!r)return;const l=d=>{d.key==="Escape"&&o()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[r,o]),r?Y(e("div",{class:"fixed inset-0 z-[55] flex items-start justify-center overflow-auto",style:{background:"var(--scrim)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",padding:"56px 16px 16px"},onClick:o,children:e("div",{role:"dialog","aria-modal":"true","aria-label":n,class:"flex flex-col overflow-hidden",style:{width:`min(${a}px, 100%)`,maxHeight:"calc(100vh - 72px)",borderRadius:"var(--r-xl)",background:"var(--bg-2)",boxShadow:"var(--shadow-l)",animation:"popIn .26s var(--ease) both"},onClick:l=>l.stopPropagation(),children:[e("div",{class:"flex items-center gap-2.5 shrink-0",style:{padding:"14px 18px",borderBottom:"1px solid var(--hair)"},children:[e("h2",{style:{fontSize:"17px",fontWeight:700,letterSpacing:"-0.02em"},children:n}),e("span",{class:"flex-1"}),e(K,{onClick:o})]}),e("div",{class:"overflow-auto min-h-0",style:{padding:"16px 18px"},children:p}),t&&e("div",{class:"flex items-center gap-2.5 shrink-0",style:{padding:"13px 18px",borderTop:"1px solid var(--hair)"},children:t})]})}),document.body):null),ze=({title:r,onClose:n,children:o})=>(Q(()=>{const t=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[n]),Y(e("div",{class:"fixed inset-0 z-50 flex justify-end",style:{background:"var(--scrim)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)"},onClick:n,children:e("aside",{role:"dialog","aria-modal":"true","aria-label":r,class:"flex flex-col h-full overflow-auto",style:{width:"min(492px, 100%)",background:"var(--bg-2)",boxShadow:"var(--shadow-l)",animation:"slideIn .3s var(--ease) both"},onClick:t=>t.stopPropagation(),children:[e("div",{class:"glass flex items-center sticky top-0 z-1",style:{gap:"10px",padding:"14px 18px",boxShadow:"var(--chrome-edge)"},children:[e("h2",{style:{fontSize:"17px",fontWeight:700,letterSpacing:"-0.02em"},children:r}),e("span",{class:"flex-1"}),e(K,{onClick:n})]}),e("div",{class:"flex flex-col",style:{padding:"16px 18px 24px",gap:"14px"},children:o})]})}),document.body)),Le=({tabs:r,active:n,onChange:o,fill:t,size:a="md",label:p})=>{const l=a!=="md",d=a==="xs";return e("div",{role:"tablist","aria-label":p,class:`${t?"flex":"inline-flex"} max-w-full overflow-x-auto`,style:{padding:"3px",borderRadius:"var(--r-md)",background:"var(--well)",boxShadow:"var(--inset-s)"},children:r.map(i=>{const c=n===i.id;return e("button",{type:"button",role:"tab","aria-selected":c,disabled:i.disabled,"aria-label":i.icon?i.label:void 0,title:i.icon?i.label:void 0,class:`flex items-center justify-center gap-1.5 whitespace-nowrap transition-all duration-200 ease-spring ${t?"flex-1":""} ${i.disabled?"cursor-not-allowed opacity-50":"cursor-pointer"}`,style:{padding:i.icon?"5px 9px":d?"4px 0":t?l?"5px 6px":"7px 8px":l?"5px 11px":"6px 12px",border:0,borderRadius:"var(--r-sm)",fontSize:d?"11px":l?"12px":"12.5px",fontWeight:600,background:c?"var(--seg-on, var(--card))":"transparent",color:c?"var(--ink)":"var(--ink-2)",boxShadow:c?"var(--lit), var(--shadow-s)":"none"},onClick:()=>o(i.id),children:[i.icon?e("span",{class:i.icon,"aria-hidden":"true",style:{width:"14px",height:"14px"}}):i.label,i.count!==void 0&&e("span",{class:"mono num",style:{fontSize:"11px",fontWeight:400,color:"var(--ink-3)"},children:i.count})]},i.id)})})},ue=({item:r,onItemClick:n})=>{const[o,t]=F(!1);return e("div",{class:`flex items-center justify-between transition-all duration-180 ease-spring ${n?"cursor-pointer":""}`,style:{padding:"11px 15px",borderRadius:"12px",background:"var(--card)",border:`1px solid ${n&&o?"var(--hair-2)":"var(--hair)"}`,boxShadow:"var(--shadow-s)"},onMouseEnter:n?()=>t(!0):void 0,onMouseLeave:n?()=>t(!1):void 0,onClick:n?()=>n(r.id):void 0,children:[e("div",{class:"min-w-0 flex-1",children:[e("div",{class:"truncate",style:{fontSize:"14px",fontWeight:600},children:r.title}),r.subtitle&&e("div",{class:"truncate",style:{fontSize:"12px",color:"var(--ink-2)",marginTop:"2px"},children:r.subtitle})]}),e("div",{class:"flex items-center gap-2 ml-3",children:[r.badge&&e(pe,{label:r.badge.label,color:r.badge.color,variant:"tint"}),r.trailing]})]})},$e=({items:r,loading:n,onItemClick:o})=>n?e("div",{class:"space-y-2",children:[1,2,3].map(t=>e("div",{class:"h-16 animate-pulse",style:{borderRadius:"12px",background:"var(--card)"}},t))}):r.length===0?null:e("div",{class:"space-y-1",children:r.map(t=>e(ue,{item:t,onItemClick:o},t.id))}),Te=({icon:r,title:n,description:o,action:t})=>e("div",{class:"flex flex-col items-center justify-center text-center mx-auto",style:{maxWidth:"520px",padding:"36px 28px",borderRadius:"16px",background:"var(--card)",border:"1px solid var(--hair)",boxShadow:"var(--shadow-m)",animation:"riseIn .34s var(--ease) both"},children:[r&&e("span",{class:r,style:{width:"28px",height:"28px",color:"var(--ink-3)",marginBottom:"14px"}}),e("h3",{style:{fontSize:"17px",fontWeight:700,letterSpacing:"-0.02em",marginBottom:"6px"},children:n}),o&&e("p",{style:{fontSize:"13px",color:"var(--ink-2)",maxWidth:"40ch",marginBottom:t?"16px":0},children:o}),t&&e(se,{label:t.label,variant:"primary",onClick:t.onClick})]}),Re=({checked:r,onChange:n,label:o,disabled:t})=>e("button",{type:"button",role:"switch","aria-checked":r,"aria-label":o,disabled:t,class:`relative shrink-0 ${t?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,style:{width:"44px",height:"26px",borderRadius:"99px",border:0,background:r?"linear-gradient(180deg, var(--accent-top), var(--accent-bot))":"var(--well)",boxShadow:r?"none":"inset 0 0 0 1px var(--hair-2), var(--inset-s)",transition:"background .22s var(--ease)"},onClick:()=>!t&&n(!r),children:e("span",{class:"absolute pointer-events-none",style:{top:"3px",left:r?"21px":"3px",width:"20px",height:"20px",borderRadius:"50%",background:"#fff",boxShadow:"var(--shadow-s)",transition:"left .22s var(--ease)"}})}),Pe=({left:r,right:n,defaultWidth:o=300,minWidth:t=200,maxWidth:a=600,storageKey:p="forge-split-width"})=>{const[l,d]=F(()=>{if(typeof localStorage<"u"&&p){const s=localStorage.getItem(p);if(s){const g=parseInt(s,10);if(!isNaN(g)&&g>=t&&g<=a)return g}}return o}),i=S(!1),c=S(0),x=S(0),v=re(s=>{s.preventDefault(),i.current=!0,c.current=s.clientX,x.current=l,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[l]);return A(()=>{const s=m=>{if(!i.current)return;const y=m.clientX-c.current,z=Math.min(a,Math.max(t,x.current+y));d(z)},g=()=>{i.current&&(i.current=!1,document.body.style.cursor="",document.body.style.userSelect="",typeof localStorage<"u"&&p&&localStorage.setItem(p,String(l)))};return document.addEventListener("mousemove",s),document.addEventListener("mouseup",g),()=>{document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",g)}},[l,t,a,p]),e("div",{class:"flex h-full w-full overflow-hidden",children:[e("div",{class:"shrink-0 overflow-y-auto overflow-x-hidden",style:{width:`${l}px`},children:r}),e("div",{class:"shrink-0 w-1 cursor-col-resize transition-colors hover:bg-blue",style:{backgroundColor:"var(--hair)"},onMouseDown:v}),e("div",{class:"flex-1 min-w-0 overflow-hidden",children:n})]})},_e=({title:r,defaultOpen:n=!1,children:o})=>{const[t,a]=F(n);return e("div",{style:{borderBottom:"1px solid var(--hair)"},children:[e("button",{class:"flex items-center justify-between w-full px-3 py-2.5 cursor-pointer transition-colors text-ink3 hover:text-ink",style:{fontSize:"11px",fontWeight:600,border:0,background:"none"},onClick:()=>a(!t),children:[e("span",{children:r}),e("span",{class:"transition-transform",style:{transform:t?"rotate(90deg)":"rotate(0deg)"},children:e("span",{class:"i-lucide-chevron-right"})})]}),t&&e("div",{class:"px-3 pb-3",children:o})]})},he={normal:"--ink-2",warning:"--orange",critical:"--red"},xe=({bar:r,size:n})=>{const o=he[r.severity],t=`var(${o})`,a=n==="sm",p=Math.max(0,Math.min(100,r.percent));return e("span",{class:"flex items-center w-full",style:{gap:a?"6px":"9px"},children:[e("span",{class:"mono num shrink-0 text-right",style:{width:a?"28px":"32px",fontSize:"11px",color:"var(--ink-3)"},children:r.label}),e("span",{class:"relative block flex-1 overflow-hidden",style:{height:a?"4px":"6px",borderRadius:"99px",background:"var(--well)",boxShadow:a?"none":"var(--inset-s)"},children:e("span",{class:"block h-full",style:{width:`${p}%`,borderRadius:"99px",background:t,transition:"width .6s var(--ease)"}})}),e("span",{class:"mono num shrink-0 text-right",style:{width:a?"30px":"36px",fontSize:"11px",fontWeight:600,color:r.severity==="normal"?"var(--ink-2)":`var(${o}-ink, ${t})`},children:[Math.round(r.percent),"%"]}),!a&&e("span",{class:"shrink-0 text-right whitespace-nowrap",style:{width:"112px",fontSize:"11px",color:"var(--ink-3)"},children:r.reset??"—"})]})},Ae=({bars:r,size:n="md"})=>e("span",{class:"flex flex-col w-full",style:{gap:n==="sm"?"4px":"6px"},children:r.map((o,t)=>e("span",{class:"flex flex-col w-full",style:{gap:"2px"},children:[e(xe,{bar:o,size:n}),o.scope&&n==="md"&&e("span",{style:{paddingLeft:"39px",fontSize:"11px",color:"var(--ink-3)"},children:o.scope})]},t))});export{_e as AccordionSection,se as ActionButton,pe as Badge,K as CloseButton,$e as DataList,ze as Drawer,Te as EmptyState,ke as ForgeTerminal,We as Modal,Pe as SplitPane,ye as StatusCard,Le as Tabs,Ee as ToastContainer,Re as ToggleSwitch,Ae as UsageMeter,Se as showToast,M as toasts};
|