use wasm_bindgen::JsValue;
pub mod api {
#[cfg(feature = "app")]
pub mod app;
#[cfg(feature = "core")]
pub mod core;
#[cfg(feature = "dpi")]
pub mod dpi;
#[cfg(feature = "event")]
pub mod event;
#[cfg(feature = "menu")]
pub mod menu;
#[cfg(feature = "mocks")]
pub mod mocks;
#[cfg(feature = "path")]
pub mod path;
#[cfg(feature = "tray")]
pub mod tray;
#[cfg(feature = "webview")]
pub mod webview;
#[cfg(feature = "window")]
pub mod window;
}
pub mod plugin {
#[cfg(feature = "authenticator")]
pub mod authenticator;
#[cfg(feature = "autostart")]
pub mod autostart;
#[cfg(feature = "barcode-scanner")]
pub mod barcode_scanner;
#[cfg(feature = "biometric")]
pub mod biometric;
#[cfg(feature = "cli")]
pub mod cli;
#[cfg(feature = "clipboard-manager")]
pub mod clipboard_manager;
#[cfg(feature = "deep-link")]
pub mod deep_link;
#[cfg(feature = "dialog")]
pub mod dialog;
#[cfg(feature = "fs")]
pub mod fs;
#[cfg(feature = "global-shortcut")]
pub mod global_shortcut;
#[cfg(feature = "http")]
pub mod http;
#[cfg(feature = "log")]
pub mod log;
#[cfg(feature = "nfc")]
pub mod nfc;
#[cfg(feature = "notification")]
pub mod notification;
#[cfg(feature = "os")]
pub mod os;
#[cfg(feature = "positioner")]
pub mod positioner;
#[cfg(feature = "process")]
pub mod process;
#[cfg(feature = "shell")]
pub mod shell;
#[cfg(feature = "sql")]
pub mod sql;
#[cfg(feature = "store")]
pub mod store;
#[cfg(feature = "stronghold")]
pub mod stronghold;
#[cfg(feature = "updater")]
pub mod updater;
#[cfg(feature = "upload")]
pub mod upload;
#[cfg(feature = "websocket")]
pub mod websocket;
#[cfg(feature = "window-state")]
pub mod window_state;
}
pub mod js;
pub type Result<T> = core::result::Result<T, Error>;
#[derive(Clone, Eq, PartialEq, Debug, thiserror::Error)]
pub enum Error {
#[error("Command returned Error: {0}")]
Command(String),
#[error("Failed to parse JSON: {0}")]
Serde(String),
#[cfg(any(feature = "event", feature = "window"))]
#[error("Oneshot cancelled: {0}")]
OneshotCanceled(#[from] futures::channel::oneshot::Canceled),
#[cfg(feature = "fs")]
#[error("Could not convert path to string")]
Utf8(std::path::PathBuf),
}
impl From<serde_wasm_bindgen::Error> for Error {
fn from(e: serde_wasm_bindgen::Error) -> Self {
Self::Serde(e.to_string())
}
}
impl From<JsValue> for Error {
fn from(e: JsValue) -> Self {
Self::Command(format!("{:?}", e))
}
}
#[cfg(any(feature = "dialog", feature = "window"))]
pub(crate) mod utils {
pub struct ArrayIterator {
pos: u32,
arr: js_sys::Array,
}
impl ArrayIterator {
pub fn new(arr: js_sys::Array) -> Self {
Self { pos: 0, arr }
}
}
impl Iterator for ArrayIterator {
type Item = wasm_bindgen::JsValue;
fn next(&mut self) -> Option<Self::Item> {
let raw = self.arr.get(self.pos);
if raw.is_undefined() {
None
} else {
self.pos += 1;
Some(raw)
}
}
}
}