From dc16420545758535bc00b5fb355efe1951b9fcad Mon Sep 17 00:00:00 2001 From: Scott Richmond Date: Sun, 6 Jul 2025 18:43:35 -0400 Subject: [PATCH] fix key_up bug in ludus.js --- pkg/ludus.js | 2 +- pkg/rudus_bg.wasm | 2 +- pkg/worker.js | 2 +- src/io.rs | 4 ++-- src/world.rs | 1 + 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/ludus.js b/pkg/ludus.js index 30af0be..01747fa 100644 --- a/pkg/ludus.js +++ b/pkg/ludus.js @@ -85,7 +85,7 @@ function io_poller () { outbox = [] } if (ready && running) { - if (keys_down.size > 0) bundle_keys() + bundle_keys() worker.postMessage(outbox) outbox = [] } diff --git a/pkg/rudus_bg.wasm b/pkg/rudus_bg.wasm index 26e24de..57e17fd 100644 --- a/pkg/rudus_bg.wasm +++ b/pkg/rudus_bg.wasm @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:64790ad8ac609467ec4e19b435afb38966180e1661facc949c24b9bfbc792f3c +oid sha256:b89d3c9b621f22db272bb543d120a30ded492efd48d4577595a740aabaeaa312 size 16788621 diff --git a/pkg/worker.js b/pkg/worker.js index fc935f0..6b948b7 100644 --- a/pkg/worker.js +++ b/pkg/worker.js @@ -18,7 +18,7 @@ export function io (out) { resolve(JSON.stringify(e.data)) } // cancel the response if it takes too long - setTimeout(() => reject("io took too long"), 1000) + setTimeout(() => reject(`io took too long to respond to ${out}`), 1000) }) } diff --git a/src/io.rs b/src/io.rs index cf8fbe7..a50bb3f 100644 --- a/src/io.rs +++ b/src/io.rs @@ -86,14 +86,14 @@ pub async fn do_io (msgs: Vec) -> Vec { let inbox = match inbox { Ok(msgs) => msgs, Err(errs) => { - console_log!("error receiving messages in io; {:?}", errs); + // console_log!("error receiving messages in io; {:?}", errs); return vec![]; } }; let inbox = inbox.as_string().expect("response should be a string"); let inbox: Vec = serde_json::from_str(inbox.as_str()).expect("response from js should be valid"); if !inbox.is_empty() { - console_log!("ludus received messages"); + // console_log!("ludus received messages"); for msg in inbox.iter() { console_log!("{}", msg); } diff --git a/src/world.rs b/src/world.rs index fb91c6f..5a3e85c 100644 --- a/src/world.rs +++ b/src/world.rs @@ -472,6 +472,7 @@ impl World { } fn register_keys(&mut self, keys: Value) { + // console_log!("New keys: {keys}"); let keys_down_rc = self.buffers.keys_down(); keys_down_rc.replace(keys); }