migration to JS engine #1

Merged
akulij merged 131 commits from dev into main 2025-05-31 08:49:52 +00:00
Showing only changes of commit 6fa398401d - Show all commits

View File

@ -127,14 +127,28 @@ impl DeserializerJS {
} }
} }
pub fn deserialize_js<'a, T: Deserialize<'a>>(value: &'a JsValue) -> ScriptResult<T> { pub fn deserialize_js<'a, T: Deserialize<'a> + Parcelable<BotFunction> + 'static>(
value: &'a JsValue,
) -> ScriptResult<T> {
let mut s = Self::new(); let mut s = Self::new();
s.inject_templates(value, "".to_string())?; s.inject_templates(value, "".to_string())?;
let res = value.js_into()?; let mut res = value.js_into()?;
// val.map_functions(s.fn_map); for (k, jsf) in s.fn_map {
let item: ParcelType<'_, BotFunction> =
match Parcelable::<BotFunction>::get_nested(&mut res, &k) {
Ok(item) => item,
Err(err) => {
log::error!("Failed to inject original functions to structs, error: {err}");
continue;
}
};
if let ParcelType::Function(f) = item {
f.set_js_function(jsf);
}
}
Ok(res) Ok(res)
} }