notjs-react 0.4.6 → 0.4.7
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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -141,7 +141,7 @@ func main() {
|
|
|
141
141
|
|
|
142
142
|
fmt.Printf("Hello, %s!\\n", name)
|
|
143
143
|
}
|
|
144
|
-
`};function Zo({websocketUrl:n="ws://localhost:8080/terminal",apiBaseUrl:h="http://localhost:8080/api",initialCode:m,initialLanguage:b="java",initialVersion:A="25",initialDarkMode:B=!0,hideHeader:E=!1,editorWidthPercent:i=50}){const[o,c]=V.useState(m||et[b]||et.java),[d,a]=V.useState([]),[f,g]=V.useState(b),[S,u]=V.useState({default:null,code:"",versions:[]}),[r,s]=V.useState([]),[e,t]=V.useState(A),[l,p]=V.useState(null),[_,C]=V.useState(B),[v,w]=V.useState(!1),[k,D]=V.useState(!1),[O,L]=V.useState(
|
|
144
|
+
`};function Zo({websocketUrl:n="ws://localhost:8080/terminal",apiBaseUrl:h="http://localhost:8080/api",initialCode:m,initialLanguage:b="java",initialVersion:A="25",initialDarkMode:B=!0,hideHeader:E=!1,editorWidthPercent:i=50}){const[o,c]=V.useState(m||et[b]||et.java),[d,a]=V.useState([]),[f,g]=V.useState(b),[S,u]=V.useState({default:null,code:"",versions:[]}),[r,s]=V.useState([]),[e,t]=V.useState(A),[l,p]=V.useState(null),[_,C]=V.useState(B),[v,w]=V.useState(!1),[k,D]=V.useState(!1),[O,L]=V.useState(50),[F,H]=V.useState(!1),[j,Q]=V.useState(null),[U,y]=V.useState(""),I=V.useRef(null),R=V.useRef(null),P=V.useRef(null),N=V.useRef(""),Y=V.useRef(null);V.useEffect(()=>{(async()=>{try{const q=await fetch(`${h}/language/info/${b}`);if(!q.ok)throw new Error("Language not supported");const z=await q.json();z.availableVersions.includes(A)?Q(!0):(Q(!1),y(`${b.toUpperCase()} version ${A} is not available. Available versions: ${z.availableVersions.join(", ")}`))}catch{Q(!1),y(`Failed to connect to NotJS API at ${h}. Please ensure the Spring Boot backend is running.`)}})()},[h,b,A]),V.useEffect(()=>{fetch(`${h}/language/supported`).then(T=>T.json()).then(T=>{a(T)}).catch(T=>{console.error("Failed to fetch languages:",T)})},[h]),V.useEffect(()=>{f&&fetch(`${h}/language/info/${f}`).then(T=>T.json()).then(T=>{s(T.availableVersions),p(T.defaultVersion),t(T.defaultVersion),u({default:T.defaultVersion,versions:T.availableVersions,code:et[f]}),c(et[f])}).catch(T=>{console.error("Failed to fetch language info:",T)})},[f,h]),V.useEffect(()=>{if(!I.current||j!==!0||l===null&&r.length===0)return;const T=new As.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',theme:_?{background:"#0a0a0a",foreground:"#d4d4d4",cursor:"#ffffff"}:{background:"#ffffff",foreground:"#000000",cursor:"#000000"},scrollback:1e3,convertEol:!0});R.current=T,T.open(I.current);const q=()=>{if(I.current&&R.current){const X=I.current.getBoundingClientRect(),ee=Math.floor((X.width-20)/9),te=Math.floor((X.height-20)/17);R.current.resize(ee,te)}};setTimeout(q,100),window.addEventListener("resize",q);const z=new WebSocket(n);return P.current=z,z.onopen=()=>{console.log("WebSocket connected"),T.write(`\x1B[1;32m> Connected\x1B[0m\r
|
|
145
145
|
`);const X={language:f,code:S.code,version:S.default||e||null,arguments:[]};z.send(JSON.stringify(X)),T.write(`\x1B[1;36m> Running ${f} ${S.default||l||""}...\x1B[0m\r
|
|
146
146
|
`)},z.onmessage=X=>{const ee=X.data.replace(/\n/g,`\r
|
|
147
147
|
`);T.write(ee)},z.onerror=X=>{console.error("WebSocket error:",X),T.write(`\x1B[1;31m\r
|