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