mod archive;
mod async_api;
mod file;
mod memory;
mod streams;
mod writer;
pub use archive::WasmArchive;
pub use async_api::{extract_entry_async, open_archive_async};
pub use memory::WasmMemoryConfig;
pub use streams::{extract_as_stream, open_from_stream};
pub use writer::{WasmWriteOptions, WasmWriter};
use wasm_bindgen::prelude::*;
#[wasm_bindgen(start)]
pub fn init() {
}
#[wasm_bindgen(js_name = "getVersion")]
pub fn get_version() -> String {
env!("CARGO_PKG_VERSION").to_string()
}
#[wasm_bindgen(js_name = "isMethodSupported")]
pub fn is_method_supported(method: &str) -> bool {
match method.to_lowercase().as_str() {
"copy" => true,
#[cfg(feature = "lzma")]
"lzma" => true,
#[cfg(not(feature = "lzma"))]
"lzma" => false,
#[cfg(feature = "lzma2")]
"lzma2" => true,
#[cfg(not(feature = "lzma2"))]
"lzma2" => false,
#[cfg(feature = "deflate")]
"deflate" => true,
#[cfg(not(feature = "deflate"))]
"deflate" => false,
#[cfg(feature = "bzip2")]
"bzip2" => true,
#[cfg(not(feature = "bzip2"))]
"bzip2" => false,
#[cfg(feature = "ppmd")]
"ppmd" => true,
#[cfg(not(feature = "ppmd"))]
"ppmd" => false,
#[cfg(feature = "aes")]
"aes" | "aes256" => true,
#[cfg(not(feature = "aes"))]
"aes" | "aes256" => false,
_ => false,
}
}
#[wasm_bindgen(js_name = "getSupportedMethods")]
pub fn get_supported_methods() -> js_sys::Array {
let methods = js_sys::Array::new();
methods.push(&JsValue::from_str("copy"));
#[cfg(feature = "lzma")]
methods.push(&JsValue::from_str("lzma"));
#[cfg(feature = "lzma2")]
methods.push(&JsValue::from_str("lzma2"));
#[cfg(feature = "deflate")]
methods.push(&JsValue::from_str("deflate"));
#[cfg(feature = "bzip2")]
methods.push(&JsValue::from_str("bzip2"));
#[cfg(feature = "ppmd")]
methods.push(&JsValue::from_str("ppmd"));
methods
}
#[wasm_bindgen(js_name = "isEncryptionSupported")]
pub fn is_encryption_supported() -> bool {
#[cfg(feature = "aes")]
{
true
}
#[cfg(not(feature = "aes"))]
{
false
}
}