Move NumberInput.svelte input processing from JS to Rust (#4274)

* Move NumberInput.svelte input processing from JS to Rust

* Fix edge cases
This commit is contained in:
Keavon Chambers
2026-06-22 14:57:11 -07:00
committed by GitHub
parent f798b48b83
commit c1fa8ba8da
9 changed files with 77 additions and 45 deletions
-1
View File
@@ -33,7 +33,6 @@ wasm-bindgen = { workspace = true }
serde-wasm-bindgen = { workspace = true }
js-sys = { workspace = true }
wasm-bindgen-futures = { workspace = true }
math-parser = { workspace = true }
wgpu = { workspace = true }
web-sys = { workspace = true }
ron = { workspace = true }
-19
View File
@@ -979,22 +979,3 @@ impl EditorWrapper {
self.dispatch(message);
}
}
// ====================================================================
// Static functions callable from JavaScript without an Editor instance
// ====================================================================
#[wasm_bindgen(js_name = evaluateMathExpression)]
pub fn evaluate_math_expression(expression: &str) -> Option<f64> {
let value = math_parser::evaluate(expression)
.inspect_err(|err| error!("Math parser error on \"{expression}\": {err}"))
.ok()?
.0
.inspect_err(|err| error!("Math evaluate error on \"{expression}\": {err} "))
.ok()?;
let Some(real) = value.as_real() else {
error!("{value} was not a real; skipping.");
return None;
};
Some(real)
}