notjs-react 0.6.0 → 0.6.1

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 CHANGED
@@ -151,8 +151,8 @@ func main() {
151
151
 
152
152
  fmt.Printf("Hello, %s!\\n", name)
153
153
  }
154
- `};function Ln({websocketUrl:d="ws://localhost:8080/terminal",apiBaseUrl:S="http://localhost:8080/api",initialCode:w,initialLanguage:A="java",initialVersion:O="25",initialDarkMode:T=!0,hideHeader:R=!1,editorWidthPercent:s=50}){const[n,l]=j.useState(w||xt[A]||xt.java),[v,o]=j.useState([]),[h,f]=j.useState(A),[p,c]=j.useState({default:null,code:"",versions:[]}),[r,i]=j.useState([]),[e,t]=j.useState(O),[a,g]=j.useState(null),[_,m]=j.useState(T),[u,C]=j.useState(!1),[B,I]=j.useState(!1),[M,x]=j.useState(s),[H,F]=j.useState(!1),[N,K]=j.useState(null),[z,b]=j.useState(""),k=j.useRef(null),E=j.useRef(null),L=j.useRef(null),W=j.useRef(""),G=j.useRef(null);j.useEffect(()=>{(async()=>{try{const q=await fetch(`${S}/language/info/${A}`);if(!q.ok)throw new Error("Language not supported");const U=await q.json();U.availableVersions.includes(O)?K(!0):(K(!1),b(`${A.toUpperCase()} version ${O} is not available. Available versions: ${U.availableVersions.join(", ")}`))}catch{K(!1),b(`Failed to connect to NotJS API at ${S}. Please ensure the Spring Boot backend is running.`)}})()},[S,A,O]),j.useEffect(()=>{fetch(`${S}/language/supported`).then(D=>D.json()).then(D=>{o(D)}).catch(D=>{console.error("Failed to fetch languages:",D)})},[S]),j.useEffect(()=>{h&&fetch(`${S}/language/info/${h}`).then(D=>D.json()).then(D=>{i(D.availableVersions),g(D.defaultVersion),t(D.defaultVersion),c({default:D.defaultVersion,versions:D.availableVersions,code:xt[h]}),l(xt[h])}).catch(D=>{console.error("Failed to fetch language info:",D)})},[h,S]),j.useEffect(()=>{if(!k.current||N!==!0||a===null&&r.length===0)return;const D=new _s.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});E.current=D,D.open(k.current);const q=()=>{if(k.current&&E.current){const Y=k.current.getBoundingClientRect(),ie=Math.floor((Y.width-20)/9),se=Math.floor((Y.height-20)/17);E.current.resize(ie,se)}};setTimeout(q,100),window.addEventListener("resize",q);const U=new WebSocket(d);return L.current=U,U.onopen=()=>{console.log("WebSocket connected"),D.write(`\x1B[1;32m> Connected\x1B[0m\r
155
- `);const Y={language:h,code:p.code,version:p.default||e||null,arguments:[]};U.send(JSON.stringify(Y)),D.write(`\x1B[1;36m> Running ${h} ${p.default||a||""}...\x1B[0m\r
154
+ `};function Ln({websocketUrl:d="ws://localhost:8080/terminal",apiBaseUrl:S="http://localhost:8080/api",initialCode:w,initialLanguage:A="java",initialVersion:O="25",initialDarkMode:T=!0,hideHeader:R=!1,editorWidthPercent:s=50}){const[n,l]=j.useState(w||xt[A]||xt.java),[v,o]=j.useState([]),[h,f]=j.useState(A),[p,c]=j.useState({default:null,code:"",versions:[]}),[r,i]=j.useState([]),[e,t]=j.useState(O),[a,g]=j.useState(null),[_,m]=j.useState(T),[u,C]=j.useState(!1),[B,I]=j.useState(!1),[M,x]=j.useState(s),[H,F]=j.useState(!1),[N,K]=j.useState(null),[z,b]=j.useState(""),k=j.useRef(null),E=j.useRef(null),L=j.useRef(null),W=j.useRef(""),G=j.useRef(null);j.useEffect(()=>{(async()=>{try{const q=await fetch(`${S}/language/info/${A}`);if(!q.ok)throw new Error("Language not supported");const U=await q.json();U.availableVersions.includes(O)?K(!0):(K(!1),b(`${A.toUpperCase()} version ${O} is not available. Available versions: ${U.availableVersions.join(", ")}`))}catch{K(!1),b(`Failed to connect to NotJS API at ${S}. Please ensure the Spring Boot backend is running.`)}})()},[S,A,O]),j.useEffect(()=>{fetch(`${S}/language/supported`).then(D=>D.json()).then(D=>{o(D)}).catch(D=>{console.error("Failed to fetch languages:",D)})},[S]),j.useEffect(()=>{h&&fetch(`${S}/language/info/${h}`).then(D=>D.json()).then(D=>{i(D.availableVersions),g(D.defaultVersion),t(D.defaultVersion),c({default:D.defaultVersion,versions:D.availableVersions,code:xt[h]}),l(w||xt[h])}).catch(D=>{console.error("Failed to fetch language info:",D)})},[h,S]),j.useEffect(()=>{if(!k.current||N!==!0||a===null&&r.length===0)return;const D=new _s.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});E.current=D,D.open(k.current);const q=()=>{if(k.current&&E.current){const Y=k.current.getBoundingClientRect(),ie=Math.floor((Y.width-20)/9),se=Math.floor((Y.height-20)/17);E.current.resize(ie,se)}};setTimeout(q,100),window.addEventListener("resize",q);const U=new WebSocket(d);return L.current=U,U.onopen=()=>{console.log("WebSocket connected"),D.write(`\x1B[1;32m> Connected\x1B[0m\r
155
+ `);const Y={language:h,code:w||p.code,version:p.default||e||null,arguments:[]};U.send(JSON.stringify(Y)),D.write(`\x1B[1;36m> Running ${h} ${p.default||a||""}...\x1B[0m\r
156
156
  `)},U.onmessage=Y=>{const ie=Y.data.replace(/\n/g,`\r
157
157
  `);D.write(ie)},U.onerror=Y=>{console.error("WebSocket error:",Y),D.write(`\x1B[1;31m\r
158
158
  [ERROR] WebSocket connection error\x1B[0m\r