use super::completion_helper::{await_promise, PromiseError};
use wasm_bindgen::prelude::*;
pub const MAIN_MODULE_NAME: &str = "./ferroui.js";
#[wasm_bindgen(raw_module = "./ferroui.js")]
extern "C" {
#[wasm_bindgen(js_namespace = Caniuse, js_name = isMobile)]
pub fn is_mobile() -> bool;
#[wasm_bindgen(js_namespace = Caniuse, js_name = isTv)]
pub fn is_tv() -> bool;
#[wasm_bindgen(js_name = importStorage)]
fn import_storage_raw() -> super::JsObject;
#[wasm_bindgen(js_name = registerServiceWorker)]
fn register_service_worker_raw(path: &str, scope: Option<&str>) -> super::JsObject;
}
pub fn resolve_service_worker_path() -> &'static str {
if cfg!(target_feature = "atomics") {
"./ferroui-sw.js?coi=1"
} else {
"./ferroui-sw.js"
}
}
pub fn register_service_worker(path: &str, scope: Option<&str>) {
drop(register_service_worker_raw(path, scope));
}
pub async fn import_storage() -> Result<(), PromiseError> {
await_promise(&import_storage_raw()).await.map(|_| ())
}