fix: slotType serial + feaures

- fix slotType serialisation
- show slot images including class if no occupant
- filter/search device list
This commit is contained in:
Rachel Powers
2024-04-17 14:21:41 -07:00
parent 7e2ea652c3
commit b60cc44580
29 changed files with 326 additions and 81 deletions

View File

@@ -2,7 +2,10 @@
mod utils;
mod types;
use ic10emu::{grammar::{LogicType, SlotLogicType}, DeviceTemplate};
use ic10emu::{
grammar::{LogicType, SlotLogicType},
DeviceTemplate,
};
use serde::{Deserialize, Serialize};
use types::{Registers, Stack};
@@ -61,12 +64,20 @@ impl DeviceRef {
#[wasm_bindgen(getter, js_name = "prefabName")]
pub fn prefab_name(&self) -> Option<String> {
self.device.borrow().prefab.as_ref().map(|prefab| prefab.name.clone())
self.device
.borrow()
.prefab
.as_ref()
.map(|prefab| prefab.name.clone())
}
#[wasm_bindgen(getter, js_name = "prefabHash")]
pub fn prefab_hash(&self) -> Option<i32> {
self.device.borrow().prefab.as_ref().map(|prefab| prefab.hash)
self.device
.borrow()
.prefab
.as_ref()
.map(|prefab| prefab.hash)
}
#[wasm_bindgen(getter, skip_typescript)]
@@ -354,6 +365,10 @@ impl VM {
#[wasm_bindgen(js_name = "addDeviceFromTemplate", skip_typescript)]
pub fn add_device_from_template(&self, template: JsValue) -> Result<u32, JsError> {
let template: DeviceTemplate = serde_wasm_bindgen::from_value(template)?;
web_sys::console::log_2(
&"(wasm) adding device".into(),
&serde_wasm_bindgen::to_value(&template).unwrap(),
);
Ok(self.vm.borrow_mut().add_device_from_template(template)?)
}