62 lines
1.5 KiB
Rust
62 lines
1.5 KiB
Rust
use dioxus::prelude::*;
|
|
use marts::ClientAuth;
|
|
use mize::Mize;
|
|
use wasm_bindgen::prelude::*;
|
|
use serde::{Serialize, Deserialize};
|
|
use mize::{MizeResult, mize_part, MizePart, MizePartCreate, error::IntoMizeResultJsValue};
|
|
use mize::platform::js::JsMize;
|
|
|
|
|
|
// console_log macro
|
|
#[wasm_bindgen]
|
|
extern "C" {
|
|
#[wasm_bindgen(js_namespace = console)]
|
|
fn log(s: &str);
|
|
}
|
|
|
|
macro_rules! console_log {
|
|
// Note that this is using the `log` function imported above during
|
|
// `bare_bones`
|
|
($($t:tt)*) => ({ log(&format_args!($($t)*).to_string())})
|
|
}
|
|
|
|
#[wasm_bindgen]
|
|
pub fn test_fn(mize: &mut JsMize) {
|
|
let mize = mize.inner();
|
|
console_log!("test fn...");
|
|
|
|
if let Err(e) = try_test_fn(mize) {
|
|
console_log!("err: {:?}", e);
|
|
}
|
|
|
|
}
|
|
|
|
fn try_test_fn(mize: &mut Mize) -> MizeResult<()> {
|
|
//let auth = mize.get_part_native::<ClientAuth>("client_auth")?;
|
|
//console_log!("secrets: {:?}", auth.secrets());
|
|
|
|
let parts = mize.parts.lock().unwrap();
|
|
for part in parts.keys() {
|
|
console_log!("part: {}", part)
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[wasm_bindgen]
|
|
pub fn part_obsidian_init(mize: &mut JsMize, plugin: JsValue, app: JsValue) {
|
|
let mut mize = mize.inner();
|
|
if let Err(e) = obsidian_mize_main(&mut mize, plugin, app) {
|
|
console_log!("Failed to start the obsidian mize part: {:?}", e);
|
|
}
|
|
}
|
|
|
|
fn obsidian_mize_main(mize: &mut Mize, plugin: JsValue, app: JsValue) -> MizeResult<()> {
|
|
|
|
marts::part_obsidian(mize, plugin, app)?;
|
|
marts::part_client_auth(mize)?;
|
|
marts::spacetime(mize)?;
|
|
|
|
Ok(())
|
|
}
|