ftml_viewer/
lib.rs

1#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2
3use wasm_bindgen::prelude::*;
4
5#[wasm_bindgen]
6/// sets the server url used to the provided one; by default `https://mathhub.info`.
7pub fn set_server_url(server_url: String) {
8    console_error_panic_hook::set_once();
9    tracing::debug!("setting server url: {server_url}");
10    ftml_viewer_components::remote::set_server_url(server_url);
11}
12
13pub use ftml_viewer_components::remote::get_server_url;
14
15#[cfg(any(doc, not(feature = "ts")))]
16#[wasm_bindgen(start)]
17pub fn run() {
18    use flams_ontology::uris::DocumentURI;
19    use flams_web_utils::components::Themer;
20    use ftml_viewer_components::{FTMLDocumentSetup, FTMLGlobalSetup};
21    use leptos::prelude::*;
22    use leptos_posthoc::{DomChildrenCont, OriginalNode};
23    #[allow(unused_mut)]
24    let mut config = tracing_wasm::WASMLayerConfigBuilder::new();
25
26    console_error_panic_hook::set_once();
27    //#[cfg(not(debug_assertions))]
28    //config.set_max_level(tracing::Level::INFO);
29    tracing_wasm::set_as_global_default_with_config(config.build());
30
31    leptos_posthoc::hydrate_body(|orig| {
32        leptos_meta::provide_meta_context();
33        view!(<Themer attr:style="font-family:inherit;font-size:inherit;font-weight:inherit;line-height:inherit;background-color:inherit;color:inherit;display:contents;"><FTMLGlobalSetup><FTMLDocumentSetup uri=DocumentURI::no_doc()>
34            <DomChildrenCont orig cont=ftml_viewer_components::iterate/>
35            </FTMLDocumentSetup></FTMLGlobalSetup></Themer>
36        )
37    });
38}
39
40#[cfg(feature = "ts")]
41mod ts;
42#[cfg(feature = "ts")]
43pub use ts::*;
44
45#[cfg(all(feature = "ts", doc))]
46pub use ftml_viewer_components::components::TOCElem;