@spaceandtimelabs/makeinfinite-ui 0.16.2 → 0.16.3
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.
|
@@ -26026,8 +26026,8 @@ const AN = Wn.div`
|
|
|
26026
26026
|
}, k = async () => {
|
|
26027
26027
|
i.current && await i.current.close();
|
|
26028
26028
|
const S = localStorage.getItem("accessToken") || "", P = l.API_BASE_URL.replace(
|
|
26029
|
-
|
|
26030
|
-
"
|
|
26029
|
+
/^https?:\/\//,
|
|
26030
|
+
""
|
|
26031
26031
|
);
|
|
26032
26032
|
i.current = new WebSocket(
|
|
26033
26033
|
`ws://${P}/ws/chat/${a.projectName}?token=${S}`
|
|
@@ -598,7 +598,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
598
598
|
background-color: #5000bf;
|
|
599
599
|
color: white;
|
|
600
600
|
}
|
|
601
|
-
`,iA=e=>{let t=null;switch(e.role){case"assistant":t="assistant";break;case"user":t="user";break;default:t=null;break}if(t===null)return;const n=`message ${t}-message`;return k.jsx("div",{className:n,children:e.content},e.id)},g0=e=>e.map(t=>iA(t)).filter(Boolean).reverse(),sA=()=>{const[e,t]=oe.useState([]),[n,r]=oe.useState(""),i=oe.useRef(null),{projectMetadata:a,config:l,setSyncToken:c,selectedComponentId:f}=pr(),h=oe.useMemo(()=>!a.projectName,[a.projectName]),y=async b=>{const w=await g0(b);t(w)},m=async b=>{const w=await g0(b);t(C=>[...w,...C])},v=async()=>{const b=f;if(!b){alert("Please select a component");return}const w={type:"chat",content:{role:"user",source:"web_client",content:n.trim(),context:null,metadata:{component_id:b}}};i.current.send(JSON.stringify(w)),await m([{role:"user",content:n,id:uc()}]),r("")};return oe.useEffect(()=>{if(!(a.projectName&&a.projectURL))return;const b=new AbortController,w=b.signal,C=async()=>{await du(a.projectName,a.projectURL,l.CORS_PROXY);const S=`${window.miDir}/${a.projectName}/chat.json`,P=await window.pfs.readFile(S,"utf8"),_=JSON.parse(P);w.aborted||await y(_)},O=async()=>{i.current&&await i.current.close();const S=localStorage.getItem("accessToken")||"",P=l.API_BASE_URL.replace(
|
|
601
|
+
`,iA=e=>{let t=null;switch(e.role){case"assistant":t="assistant";break;case"user":t="user";break;default:t=null;break}if(t===null)return;const n=`message ${t}-message`;return k.jsx("div",{className:n,children:e.content},e.id)},g0=e=>e.map(t=>iA(t)).filter(Boolean).reverse(),sA=()=>{const[e,t]=oe.useState([]),[n,r]=oe.useState(""),i=oe.useRef(null),{projectMetadata:a,config:l,setSyncToken:c,selectedComponentId:f}=pr(),h=oe.useMemo(()=>!a.projectName,[a.projectName]),y=async b=>{const w=await g0(b);t(w)},m=async b=>{const w=await g0(b);t(C=>[...w,...C])},v=async()=>{const b=f;if(!b){alert("Please select a component");return}const w={type:"chat",content:{role:"user",source:"web_client",content:n.trim(),context:null,metadata:{component_id:b}}};i.current.send(JSON.stringify(w)),await m([{role:"user",content:n,id:uc()}]),r("")};return oe.useEffect(()=>{if(!(a.projectName&&a.projectURL))return;const b=new AbortController,w=b.signal,C=async()=>{await du(a.projectName,a.projectURL,l.CORS_PROXY);const S=`${window.miDir}/${a.projectName}/chat.json`,P=await window.pfs.readFile(S,"utf8"),_=JSON.parse(P);w.aborted||await y(_)},O=async()=>{i.current&&await i.current.close();const S=localStorage.getItem("accessToken")||"",P=l.API_BASE_URL.replace(/^https?:\/\//,"");i.current=new WebSocket(`ws://${P}/ws/chat/${a.projectName}?token=${S}`),i.current.onmessage=function(_){const T=JSON.parse(_.data);if(T.type)switch(T.type){case"chat":m([T.content]);break;case"signal":T.content.type==="generation_ended"&&c();break}}};return C().then(O),()=>{b.abort()}},[a.projectName]),k.jsx(k.Fragment,{children:k.jsx(oA,{children:k.jsxs("div",{className:"chat-container",children:[k.jsx("div",{className:"chat-messages",children:e}),k.jsxs("div",{className:"chat-input",children:[k.jsx("input",{type:"text",placeholder:"Type your message...",value:n,onChange:b=>r(b.target.value),disabled:h}),k.jsx("button",{onClick:v,disabled:h,children:"Send"})]})]})})})},pc=iT(xE)({fontSize:"12px",padding:"2px"}),hc=e=>k.jsx(k.Fragment,{children:k.jsx("div",{role:"tabpanel",hidden:e.activeIndex!=e.panelIndex,children:e.children})}),aA=e=>{const[t,n]=oe.useState(0),[r,i]=oe.useState(e.componentLibrary),a=(l,c)=>{n(c)};return oe.useEffect(()=>{i(e.componentLibrary)},[e.componentLibrary]),k.jsxs(k.Fragment,{children:[k.jsx(Vt,{sx:{width:"100%",position:"sticky",top:0,zIndex:1e3,backgroundColor:"LightGray"},children:k.jsx(Vt,{sx:{borderBottom:3,borderColor:"divider"},children:k.jsxs(WE,{value:t,onChange:a,children:[k.jsx(pc,{label:"Components"}),k.jsx(pc,{label:"Chatbot"}),k.jsx(pc,{label:"Projects"}),k.jsx(pc,{label:"Manage"})]})})}),k.jsx(hc,{panelIndex:0,activeIndex:t,children:k.jsx(X2,{componentLibrary:r})}),k.jsx(hc,{panelIndex:1,activeIndex:t,children:k.jsx(sA,{})}),k.jsx(hc,{panelIndex:2,activeIndex:t,children:k.jsx(Q2,{})}),k.jsx(hc,{panelIndex:3,activeIndex:t,children:k.jsx(rA,{})})]})},lA=e=>k.jsx(k.Fragment,{children:k.jsx(aA,{componentLibrary:e.componentLibrary})}),cA=e=>{const[t,n]=oe.useState(dc.EditMode),{setSyncToken:r}=pr(),i=a=>{n(Number(a.target.value))};return k.jsxs(k.Fragment,{children:[k.jsxs("select",{value:t,onChange:i,children:[k.jsx("option",{value:dc.EditMode,children:"Edit Mode"}),k.jsx("option",{value:dc.PreviewMode,children:"Preview Mode"})]}),k.jsx("button",{style:{background:"gray",margin:"0px 5px 0px"},onClick:()=>r(),children:"refresh"}),k.jsx(V2,{renderMode:t,components:e.components,componentLibrary:e.componentLibrary,layout:e.layout})]})},uA=async e=>{let t=null,n=null;try{const r=e.replace(/import.*?;\n/g,""),i=zp.transform(r,{presets:["react","typescript"],filename:"file.tsx"}).code,a=new Blob([i],{type:"text/javascript"}),f=(await import(URL.createObjectURL(a))).component;t=k.jsx(f,{})}catch(r){t=null,n=r.stack}return{compileError:n,compiledComponent:t}},fA=async e=>{let t=[];const n=await e.getComponentLibrary();if(n.status!==200)throw new Error("Could not load library components");let r=(await n.json()).components;for(const i in r)if(i==="example")for(const a of r[i]){let l=a.content["component.tsx"];l=l.replace(/import.*?;\n/g,"");let c=a.content["layout.json"];const f=zp.transform(l,{presets:["react","typescript"],filename:"file.tsx"}).code,h=new Blob([f],{type:"text/javascript"}),v=(await import(URL.createObjectURL(h))).component;t.push({class:a.name,layout:JSON.parse(c),component:k.jsx(v,{})})}return t},m0=async e=>{let t=[],n=[];const r=`${window.miDir}/${e}`,i="src/ProjectComponents";let a=await n1(`${r}/${i}`);a=a.filter(l=>!(l.includes(".gitkeep")||l.includes("index.ts")));for(const l of a){let c=`${l.replace(i,"")}`,f=`${c}/component.tsx`,h=await window.pfs.readFile(`${r}/${i}/${f}`,"utf8");const{compileError:y,compiledComponent:m}=await uA(h);let v=`${c}/layout.json`;const b=await window.pfs.readFile(`${r}/${i}/${v}`,"utf8");let w={id:l,component:m};y&&(w={...w,overrides:{compileError:{message:y}}}),t.push(w),n.push({...JSON.parse(b),i:l})}return{components:t,layout:n}},dA=kn.div`
|
|
602
602
|
.mi-container {
|
|
603
603
|
display: flex;
|
|
604
604
|
flex-direction: row;
|