mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-27 22:28:11 +08:00
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:
@@ -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 }
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user