use std::sync::OnceLock;
use crate::ui::Registry;
mod accessibility;
mod android;
mod clipboard;
mod desktop;
mod fs;
mod image;
mod net;
mod os;
mod process;
mod storage;
mod websocket;
pub const WEBSOCKETS: &str = "websocket.connections";
pub const MAX_WEBSOCKETS: usize = 32;
pub fn registries() -> &'static [Registry] {
static REGISTRIES: OnceLock<Vec<Registry>> = OnceLock::new();
REGISTRIES.get_or_init(|| {
let mut android = Registry::runtime("nsh/android");
android
.module::<android::Toast>()
.module::<android::BackHandler>();
let mut accessibility = Registry::runtime("nsh/accessibility");
accessibility.module::<accessibility::Accessibility>();
let mut image = Registry::runtime("nsh/image");
image.module::<image::Image>();
let mut clipboard = Registry::runtime("nsh/clipboard");
clipboard.module::<clipboard::Clipboard>();
let mut storage = Registry::runtime("nsh/storage");
storage.module::<storage::Storage>();
let mut desktop = Registry::runtime("nsh/desktop");
desktop.module::<desktop::Window>();
let mut os = Registry::runtime("os");
os.module::<os::Os>();
let mut process = Registry::runtime("process");
process
.module::<process::Process>()
.native_values(&["nextTick"]);
let mut net = Registry::runtime("net");
net.module::<net::Net>();
let mut fs = Registry::runtime("fs/promises");
fs.module::<fs::Fs>();
let websocket = {
let mut websocket = Registry::runtime("websocket");
websocket.module::<websocket::WebSocket>();
websocket
};
vec![
android,
accessibility,
image,
clipboard,
storage,
desktop,
os,
net,
process,
fs,
websocket,
]
})
}
#[cfg(test)]
mod tests {
#[test]
fn every_export_is_documented() {
for registry in super::registries() {
assert_eq!(
registry.undocumented(),
Vec::<String>::new(),
"{:?}",
registry.namespace()
);
}
}
}