Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joneugster committed Sep 2, 2024
1 parent ba1c042 commit ee014fa
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
11 changes: 3 additions & 8 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ function App() {
const [url, setUrl] = useState<string | null>(null)
const [codeFromUrl, setCodeFromUrl] = useState<string>('')

/** Restart the Lean client. */
function restart() {
leanMonaco?.clientProvider?.getClients().map(client => {client.restart()})
}

/** Monaco editor requires the code to be set manually. */
function setContent (code: string) {
editor?.getModel()?.setValue(code)
Expand Down Expand Up @@ -118,7 +113,7 @@ function App() {
// Update LeanMonaco options when preferences are loaded or change
useEffect(() => {
var socketUrl = ((window.location.protocol === "https:") ? "wss://" : "ws://") +
window.location.host + "/websocket" + "/" + project
window.location.host + "/websocket/" + project
console.log(`[Lean4web] socket url: ${socketUrl}`)
var _options: LeanMonacoOptions = {
websocket: {url: socketUrl},
Expand Down Expand Up @@ -155,7 +150,7 @@ function App() {
_leanMonaco.setInfoviewElement(infoviewRef.current!)
;(async () => {
await _leanMonaco.start(options)
await leanMonacoEditor.start(editorRef.current!, `/project/${project}.lean`, '')
await leanMonacoEditor.start(editorRef.current!, `/project/${project}.lean`, code)

setEditor(leanMonacoEditor.editor)
setLeanMonaco(_leanMonaco)
Expand Down Expand Up @@ -360,7 +355,7 @@ function App() {
setProject={setProject}
setUrl={setUrl}
codeFromUrl={codeFromUrl}
restart={restart}
restart={leanMonaco?.restart}
codeMirror={codeMirror}
setCodeMirror={setCodeMirror}
/>
Expand Down
2 changes: 1 addition & 1 deletion client/src/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const Menu: FC <{
setProject: Dispatch<SetStateAction<string>>,
setUrl: Dispatch<SetStateAction<string | null>>,
codeFromUrl: string,
restart: () => void,
restart?: () => void,
codeMirror: boolean,
setCodeMirror: Dispatch<SetStateAction<boolean>>,
}> = ({code, setContent, project, setProject, setUrl, codeFromUrl, restart, codeMirror, setCodeMirror}) => {
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 13 additions & 9 deletions server/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ function startServerProcess(project) {
let projectPath = __dirname + `/../Projects/` + project

let serverProcess
if (!isDevelopment) {
console.info("Running with Bubblewrap container.")
serverProcess = cp.spawn("./bubblewrap.sh", [projectPath], { cwd: __dirname })
} else {
if (isDevelopment) {
console.warn("Running without Bubblewrap container!")
serverProcess = cp.spawn("lean", ["--server"], { cwd: projectPath })
} else {
console.info("Running with Bubblewrap container.")
serverProcess = cp.spawn("./bubblewrap.sh", [projectPath], { cwd: __dirname })
}

// serverProcess.stdout.on('data', (data) => {
Expand All @@ -98,7 +98,7 @@ function startServerProcess(project) {
)

serverProcess.on('close', (code) => {
console.log(`child process exited with code ${code}`);
console.log(`lean server exited with code ${code}`);
});

return serverProcess
Expand All @@ -124,12 +124,16 @@ wss.addListener("connection", function(ws, req) {
const socketConnection = jsonrpcserver.createConnection(reader, writer, () => ws.close())
const serverConnection = jsonrpcserver.createProcessStreamConnection(ps)
socketConnection.forward(serverConnection, message => {
// console.log(`CLIENT: ${JSON.stringify(message)}`)
return message;
// if (isDevelopment) {
// console.log(`CLIENT: ${JSON.stringify(message)}`)
// }
return message;
})
serverConnection.forward(socketConnection, message => {
// console.log(`SERVER: ${JSON.stringify(message)}`)
return message;
// if (isDevelopment) {
// console.log(`SERVER: ${JSON.stringify(message)}`)
// }
return message;
});

ws.on('close', () => {
Expand Down
3 changes: 2 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export default defineConfig({
esbuildOptions: {
// @ts-ignore // TODO
plugins: [importMetaUrlPlugin]
}
},
exclude: ['Projects']
},
build: {
// Relative to the root
Expand Down

0 comments on commit ee014fa

Please sign in to comment.