remove_all_decoders
This commit is contained in:
parent
31613dbac9
commit
6c6c9a132a
|
@ -16,6 +16,7 @@ use browser as platform;
|
|||
type Filename = String;
|
||||
type JavascriptCode = String;
|
||||
type AddedDecodersCount = usize;
|
||||
type RemovedDecodersCount = usize;
|
||||
type DecoderPath = String;
|
||||
|
||||
pub async fn show_window() {
|
||||
|
@ -64,3 +65,7 @@ pub async fn unload_signal(signal_ref: wellen::SignalRef) {
|
|||
pub async fn add_decoders(decoder_paths: Vec<DecoderPath>) -> AddedDecodersCount {
|
||||
platform::add_decoders(decoder_paths).await
|
||||
}
|
||||
|
||||
pub async fn remove_all_decoders() -> RemovedDecodersCount {
|
||||
platform::remove_all_decoders().await
|
||||
}
|
||||
|
|
|
@ -128,3 +128,9 @@ pub(super) async fn add_decoders(
|
|||
eprintln!("Adding decoders is not supported in the browser.");
|
||||
0
|
||||
}
|
||||
|
||||
pub(super) async fn remove_all_decoders() -> super::RemovedDecodersCount {
|
||||
// @TODO error message for user
|
||||
eprintln!("Removing decoders is not supported in the browser.");
|
||||
0
|
||||
}
|
||||
|
|
|
@ -63,6 +63,11 @@ pub(super) async fn add_decoders(
|
|||
.unwrap_throw()
|
||||
}
|
||||
|
||||
pub(super) async fn remove_all_decoders() -> super::RemovedDecodersCount {
|
||||
serde_wasm_bindgen::from_value(tauri_glue::remove_all_decoders().await.unwrap_throw())
|
||||
.unwrap_throw()
|
||||
}
|
||||
|
||||
mod tauri_glue {
|
||||
use zoon::*;
|
||||
|
||||
|
@ -98,5 +103,8 @@ mod tauri_glue {
|
|||
pub async fn add_decoders(
|
||||
decoder_paths: Vec<super::super::DecoderPath>,
|
||||
) -> Result<JsValue, JsValue>;
|
||||
|
||||
#[wasm_bindgen(catch)]
|
||||
pub async fn remove_all_decoders() -> Result<JsValue, JsValue>;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ use zoon::*;
|
|||
|
||||
type FullVarName = String;
|
||||
type AddedDecodersCount = usize;
|
||||
type RemovedDecodersCount = usize;
|
||||
type DecoderPath = String;
|
||||
|
||||
#[wasm_bindgen(module = "/typescript/bundles/strict_eval.js")]
|
||||
|
@ -72,4 +73,9 @@ impl FW {
|
|||
pub async fn add_decoders(decoder_paths: Vec<DecoderPath>) -> AddedDecodersCount {
|
||||
platform::add_decoders(decoder_paths).await
|
||||
}
|
||||
|
||||
/// JS: `FW.remove_all_decoders()` -> `5`
|
||||
pub async fn remove_all_decoders() -> RemovedDecodersCount {
|
||||
platform::remove_all_decoders().await
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2539,12 +2539,16 @@ async function unload_signal(signal_ref_index) {
|
|||
async function add_decoders(decoder_paths) {
|
||||
return await invoke2("add_decoders", { decoder_paths });
|
||||
}
|
||||
async function remove_all_decoders() {
|
||||
return await invoke2("remove_all_decoders");
|
||||
}
|
||||
export {
|
||||
add_decoders,
|
||||
get_hierarchy,
|
||||
load_file_with_selected_vars,
|
||||
load_signal_and_get_timeline,
|
||||
pick_and_load_waveform,
|
||||
remove_all_decoders,
|
||||
show_window,
|
||||
unload_signal
|
||||
};
|
||||
|
|
|
@ -10,6 +10,7 @@ type WellenHierarchy = unknown;
|
|||
type Timeline = unknown;
|
||||
type VarFormat = unknown;
|
||||
type AddedDecodersCount = number;
|
||||
type RemovedDecodersCount = number;
|
||||
type DecoderPath = string;
|
||||
|
||||
export async function show_window(): Promise<void> {
|
||||
|
@ -53,3 +54,7 @@ export async function unload_signal(signal_ref_index: number): Promise<void> {
|
|||
export async function add_decoders(decoder_paths: Array<DecoderPath>): Promise<AddedDecodersCount> {
|
||||
return await invoke("add_decoders", { decoder_paths });
|
||||
}
|
||||
|
||||
export async function remove_all_decoders(): Promise<RemovedDecodersCount> {
|
||||
return await invoke("remove_all_decoders");
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{AddedDecodersCount, DecoderPath};
|
||||
use crate::{AddedDecodersCount, DecoderPath, RemovedDecodersCount};
|
||||
use wasmtime::component::{Component as WasmtimeComponent, *};
|
||||
use wasmtime::{Engine, Store};
|
||||
use wasmtime_wasi::{WasiCtx, WasiView};
|
||||
|
@ -25,6 +25,10 @@ impl component::decoder::host::Host for State {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn remove_all_decoders() -> RemovedDecodersCount {
|
||||
156
|
||||
}
|
||||
|
||||
// @TODO Make println work on Windows?
|
||||
// https://github.com/tauri-apps/tauri/discussions/8626
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ use wellen::simple::Waveform;
|
|||
type Filename = String;
|
||||
type JavascriptCode = String;
|
||||
type AddedDecodersCount = usize;
|
||||
type RemovedDecodersCount = usize;
|
||||
type DecoderPath = String;
|
||||
|
||||
mod component_manager;
|
||||
|
@ -100,6 +101,11 @@ async fn add_decoders(decoder_paths: Vec<DecoderPath>) -> Result<AddedDecodersCo
|
|||
Ok(component_manager::add_decoders(decoder_paths))
|
||||
}
|
||||
|
||||
#[tauri::command(rename_all = "snake_case")]
|
||||
async fn remove_all_decoders() -> Result<RemovedDecodersCount, ()> {
|
||||
Ok(component_manager::remove_all_decoders())
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
// https://github.com/tauri-apps/tauri/issues/8462
|
||||
|
@ -119,6 +125,7 @@ pub fn run() {
|
|||
load_signal_and_get_timeline,
|
||||
unload_signal,
|
||||
add_decoders,
|
||||
remove_all_decoders,
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
|
|
Loading…
Reference in a new issue