Compare commits

..

2 Commits

Author SHA1 Message Date
Scott Richmond
808368d2b9 update worker url resolution 2025-07-01 16:30:17 -04:00
Scott Richmond
88ff5886bb fix worker path 2025-07-01 16:07:01 -04:00
2 changed files with 36 additions and 2 deletions

View File

@ -1,6 +1,7 @@
if (window) window.ludus = {run, kill, flush_stdout, stdout, p5, svg, flush_commands, commands, result, input, is_running} if (window) window.ludus = {run, kill, flush_stdout, stdout, p5, svg, flush_commands, commands, result, input, is_running}
const worker = new Worker("worker.js", {type: "module"}) const worker_url = new URL("worker.js", import.meta.url)
const worker = new Worker(worker_url, {type: "module"})
let outbox = [] let outbox = []
let ludus_console = "" let ludus_console = ""

View File

@ -1 +1,34 @@
:foobar fn inputter () -> {
if do input > unbox > empty?
then {
yield! ()
inputter ()
}
else receive {
(:get, pid) -> send (pid, (:reply, unbox (input)))
(:flush, pid) -> {
send (pid, (:reply, unbox (input)))
store! (input, "")
}
(:clear) -> store! (input, "")
}
}
fn clear_input () -> store! (input, "")
fn read_input () -> {
let reader = spawn! (inputter)
send (reader, (:get, self ()))
receive {
(:reply, msg) -> msg
}
}
fn flush_input () -> {
let reader = spawn! (inputter)
send (reader, (:flush, self ()))
receive {
(:reply, msg) -> msg
}
}