wip
This commit is contained in:
parent
227029c8f6
commit
3ff1b9f3fa
|
|
@ -58,6 +58,10 @@
|
||||||
color: var(--magenta);
|
color: var(--magenta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dark-blue {
|
||||||
|
color: var(--c64-dark-blue);
|
||||||
|
}
|
||||||
|
|
||||||
:fullscreen::backdrop {
|
:fullscreen::backdrop {
|
||||||
background: var(--background-color);
|
background: var(--background-color);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ export function setStatus(id: string, status: InputStatus) {
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case "waiting":
|
case "waiting":
|
||||||
statusEl.classList.add("yellow")
|
statusEl.classList.add("dark-blue")
|
||||||
break
|
break
|
||||||
case "streaming":
|
case "streaming":
|
||||||
statusEl.classList.add("purple")
|
statusEl.classList.add("purple")
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import color from "kleur"
|
||||||
import { NOSE_ICON, NOSE_DIR, NOSE_BIN, NOSE_WWW } from "./config"
|
import { NOSE_ICON, NOSE_DIR, NOSE_BIN, NOSE_WWW } from "./config"
|
||||||
import { transpile, isFile, tilde } from "./utils"
|
import { transpile, isFile, tilde } from "./utils"
|
||||||
import { apps, serveApp, publishDNS } from "./webapp"
|
import { apps, serveApp, publishDNS } from "./webapp"
|
||||||
|
import { runCommand } from "./shell"
|
||||||
|
import type { Message } from "./shared/message"
|
||||||
|
|
||||||
import { Layout } from "./components/layout"
|
import { Layout } from "./components/layout"
|
||||||
import { Terminal } from "./components/terminal"
|
import { Terminal } from "./components/terminal"
|
||||||
|
|
@ -54,15 +56,22 @@ app.get("/ws", upgradeWebSocket((c) => {
|
||||||
return {
|
return {
|
||||||
onMessage(event, ws) {
|
onMessage(event, ws) {
|
||||||
console.log(`Message from client: ${event.data}`)
|
console.log(`Message from client: ${event.data}`)
|
||||||
const data = JSON.parse(event.data.toString())
|
let data: Message | undefined
|
||||||
ws.send(JSON.stringify({ id: data.id, data: "Hi there!" }))
|
|
||||||
},
|
try {
|
||||||
onClose: () => {
|
data = JSON.parse(event.data.toString())
|
||||||
console.log('Connection closed')
|
} catch (e) {
|
||||||
},
|
console.error("JSON parsing error", e)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
)
|
if (!data) return
|
||||||
|
|
||||||
|
const result = runCommand(data.data)
|
||||||
|
ws.send(JSON.stringify({ id: data.id, data: result }))
|
||||||
|
},
|
||||||
|
onClose: () => console.log('Connection closed'),
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
//
|
//
|
||||||
// app routes
|
// app routes
|
||||||
|
|
|
||||||
11
src/shell.ts
Normal file
11
src/shell.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
////
|
||||||
|
// runs commands and such.
|
||||||
|
|
||||||
|
type CommandResult = {
|
||||||
|
type: "ok" | "error"
|
||||||
|
data: any
|
||||||
|
}
|
||||||
|
|
||||||
|
export function runCommand(input: string): CommandResult {
|
||||||
|
return { type: "ok", data: "command: " + input }
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user