Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

The Rune host answers the synchronous net.storage.get, through raea-io-net-calls as its async net.* calls are (L1 targets suite: rune-motion and rune-signin on native listed it as unanswered once storage.ts read kept values synchronously)

shinyobjectz311b7988eeaa
diff --git a/engine/rune/js/src/lib.rs b/engine/rune/js/src/lib.rs
index b9c2a01e..69ff58c1 100644
--- a/engine/rune/js/src/lib.rs
+++ b/engine/rune/js/src/lib.rs
@@ -140,12 +140,22 @@ impl Js {
("__ui_call", push(&asks, |a, x| a.calls.push((x[0].parse::<f64>().unwrap_or(0.0) as u64, x[1].clone(), x[2].clone())))),
// synchronous host calls answer that they aren't there, as a host without them does; except sdk/ui's
// `selection.set(null)` (no selection, which a press sends): nothing is selected, so there's nothing to
- // paint (T4a). A selection to paint is refused and listed: Rune's host doesn't draw the DOM's yet
+ // paint (T4a). A selection to paint is refused and listed: Rune's host doesn't draw the DOM's yet. And
+ // localStorage's kept values, which sdk/ui's storage.ts reads before the page's code runs: answered by
+ // raea-io-net-calls, as the async net.* calls are (an error without BEVY_TSX_STORAGE, which the page
+ // takes as nothing kept)
("__ui_sync", {
let r = refused.clone();
Box::new(move |x| {
- let none = arg(x, 0) == "selection.set" && arg(x, 1).trim() == "null";
- Ok(Ret::Str(if none { json!({"ok": null}) } else { json!({"err": refuse(&r, arg(x, 0))}) }.to_string()))
+ let answer = match arg(x, 0) {
+ "selection.set" if arg(x, 1).trim() == "null" => json!({"ok": null}),
+ "net.storage.get" => match raea_io_net_calls::storage_get(&serde_json::from_str(arg(x, 1)).unwrap_or(Value::Null)) {
+ Ok(v) => json!({"ok": v}),
+ Err(e) => json!({"err": e}),
+ },
+ name => json!({"err": refuse(&r, name)}),
+ };
+ Ok(Ret::Str(answer.to_string()))
})
}),
("__ui_log", {
diff --git a/engine/rune/tests/js.rs b/engine/rune/tests/js.rs
index a6d905dd..496c36f6 100644
--- a/engine/rune/tests/js.rs
+++ b/engine/rune/tests/js.rs
@@ -39,6 +39,8 @@ fn the_counter_mounts_and_a_click_re_renders_it() {
assert_eq!(text(&app.session, "count"), "Count: 0");
assert!(app.session.tid("reset").is_none());
assert!(!app.logs.borrow().iter().any(|l| !l.starts_with("0:")), "{:?}", app.logs.borrow());
+ // sdk/ui reads localStorage's kept values before the page's code, synchronously: answered, not refused
+ assert!(!app.refused.borrow().contains_key("net.storage.get"), "{:?}", app.refused.borrow());
}
#[test]