1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#![feature(proc_macro_hygiene)]
#![warn(anonymous_parameters)]
#![warn(bare_trait_objects)]
#![warn(elided_lifetimes_in_paths)]
#![warn(missing_debug_implementations)]
#![warn(single_use_lifetimes)]
#![warn(trivial_casts)]
#![warn(unreachable_pub)]
#![warn(unsafe_code)]
#![warn(unused_extern_crates)]
#![warn(unused_import_braces)]
#![warn(unused_qualifications)]
#![warn(unused_results)]
#![warn(variant_size_differences)]
#![feature(exclusive_range_pattern)]

use wasm_bindgen::prelude::*;

#[macro_use]
pub mod logging;

pub mod ctx;
pub mod handler;
pub mod html;
pub mod templates {
  pub mod results;
  pub mod schema;
}
pub mod ws;

mod js {
  pub(crate) fn dbui() {
    std::panic::set_hook(Box::new(console_error_panic_hook::hook));

    match crate::ctx::ClientContext::new() {
      Ok(_) => (),
      Err(e) => error!("Error starting [{}]: {:?}", dbui_core::APPNAME, e)
    };
  }

  pub(crate) fn dbui_event(msg: &str, ctx: &str) {
    info!("Post [{}]: {}", msg, ctx);
  }
}

// Imports
#[wasm_bindgen]
extern "C" {
  #[allow(unsafe_code)]
  #[wasm_bindgen(js_namespace = console)]
  fn log(s: &str, style: &str);
}

// Exports
#[wasm_bindgen]
pub fn dbui() {
  crate::js::dbui();
}

#[wasm_bindgen]
pub fn dbui_event(msg: &str, ctx: &str) {
  crate::js::dbui_event(msg, ctx);
}