Merge branch 'main' into release

This commit is contained in:
Scott Richmond 2025-07-09 14:43:10 -04:00
commit e0748d9e52

View File

@ -24,13 +24,13 @@ async function handle_messages (e) {
try {
msgs = JSON.parse(e.data)
} catch {
console.log(e.data)
// console.log(e.data)
throw Error("Main: bad json from Ludus")
}
for (const msg of msgs) {
switch (msg.verb) {
case "Complete": {
console.log("Main: ludus completed with => ", msg.data)
// console.log("Main: ludus completed with => ", msg.data)
ludus_result = msg.data
running = false
ready = false
@ -38,7 +38,7 @@ async function handle_messages (e) {
break
}
case "Error": {
console.log("Main: ludus errored with => ", msg.data)
// console.log("Main: ludus errored with => ", msg.data)
ludus_result = msg.data
running = false
ready = false
@ -49,11 +49,11 @@ async function handle_messages (e) {
case "Console": {
let new_lines = msg.data.join("\n");
ludus_console = ludus_console + new_lines
console.log("Main: ludus says => ", new_lines)
// console.log("Main: ludus says => ", new_lines)
break
}
case "Commands": {
console.log("Main: ludus commands => ", msg.data)
// console.log("Main: ludus commands => ", msg.data)
for (const command of msg.data) {
// commands will arrive asynchronously; ensure correct ordering
ludus_commands[command[1]] = command
@ -61,14 +61,14 @@ async function handle_messages (e) {
break
}
case "Fetch": {
console.log("Main: ludus requests => ", msg.data)
// console.log("Main: ludus requests => ", msg.data)
const res = await fetch(msg.data, {mode: "cors"})
const text = await res.text()
console.log("Main: js responds => ", text)
// console.log("Main: js responds => ", text)
outbox.push({verb: "Fetch", data: [msg.data, res.status, text]})
}
case "Ready": {
console.log("Main: ludus is ready")
// console.log("Main: ludus is ready")
ready = true
}
}
@ -103,7 +103,7 @@ function start_io_polling () {
// the result must be explicitly polled with `result`
export function run (source) {
if (running || ready) {
console.log("Main: received bouncy `run` call");
// console.log("Main: received bouncy `run` call");
return "TODO: handle this? should not be running"
}
// start the vm
@ -136,12 +136,12 @@ export function is_running() {
export function kill () {
running = false
outbox.push({verb: "Kill"})
console.log("Main: Killed Ludus")
// console.log("Main: Killed Ludus")
}
// sends text into ludus (status: not working)
export function input (text) {
console.log("Main: calling `input` with ", text)
// console.log("Main: calling `input` with ", text)
outbox.push({verb: "Input", data: text})
}
@ -194,7 +194,7 @@ export function key_up (key) {
export {p5} from "./p5.js"
export function svg (commands) {
console.log(`generating svg for ${code}`)
// console.log(`generating svg for ${code}`)
return svg_2(commands, code)
}