platform::load_file_with_selected_vars, simple_vcd.fw.js
This commit is contained in:
parent
220e6d19bd
commit
54b1d0799e
9 changed files with 147 additions and 5 deletions
|
@ -67,6 +67,22 @@ pub(super) async fn pick_and_load_waveform(
|
|||
// Some(file.name())
|
||||
// }
|
||||
|
||||
// @TODO allow only supported file type (*.fw.js)
|
||||
// @TODO remove the `file` parameter once we don't have to use FileInput element
|
||||
pub async fn load_file_with_selected_vars(
|
||||
file: Option<gloo_file::File>,
|
||||
) -> Option<super::JavascriptCode> {
|
||||
let file = file.unwrap_throw();
|
||||
|
||||
let javascript_code = gloo_file::futures::read_as_text(&file).await.unwrap_throw();
|
||||
|
||||
Some(javascript_code)
|
||||
}
|
||||
|
||||
// @TODO Use alternative `load_file_with_selected_vars` version once `showOpenFilePicker` is supported by Safari and Firefox
|
||||
// https://caniuse.com/mdn-api_window_showopenfilepicker
|
||||
// (see the `pick_and_load_waveform` method above)
|
||||
|
||||
pub(super) async fn get_hierarchy() -> wellen::Hierarchy {
|
||||
let waveform = BROWSER_PLATFORM_STORE.waveform.lock().unwrap_throw();
|
||||
let hierarchy = waveform.as_ref().unwrap_throw().hierarchy();
|
||||
|
|
|
@ -13,6 +13,15 @@ pub(super) async fn pick_and_load_waveform(
|
|||
.as_string()
|
||||
}
|
||||
|
||||
pub(super) async fn load_file_with_selected_vars(
|
||||
_file: Option<gloo_file::File>,
|
||||
) -> Option<super::JavascriptCode> {
|
||||
tauri_glue::load_file_with_selected_vars()
|
||||
.await
|
||||
.unwrap_throw()
|
||||
.as_string()
|
||||
}
|
||||
|
||||
pub(super) async fn get_hierarchy() -> wellen::Hierarchy {
|
||||
serde_wasm_bindgen::from_value(tauri_glue::get_hierarchy().await.unwrap_throw()).unwrap_throw()
|
||||
}
|
||||
|
@ -59,6 +68,9 @@ mod tauri_glue {
|
|||
#[wasm_bindgen(catch)]
|
||||
pub async fn pick_and_load_waveform() -> Result<JsValue, JsValue>;
|
||||
|
||||
#[wasm_bindgen(catch)]
|
||||
pub async fn load_file_with_selected_vars() -> Result<JsValue, JsValue>;
|
||||
|
||||
#[wasm_bindgen(catch)]
|
||||
pub async fn get_hierarchy() -> Result<JsValue, JsValue>;
|
||||
|
||||
|
|
Reference in a new issue