euv-cli 0.51.0

Cross-platform CLI tool for the euv native UI framework supporting run, build, check, fmt, doctor, new, and Hyperlane SSE dynamic updates across all supported platforms.
Documentation
use super::*;

/// Configuration for building the shared zero-SIMD WebAssembly host core (`euv_app.wasm` + CJS/ESM glue).
#[derive(Clone, Data, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct SharedWasmHostConfig {
    /// Root path of the `euv` workspace containing `example/`.
    pub(crate) workspace_root: PathBuf,
    /// Optional staging directory overriding `target/mobile-hosts/euv-host-wasm`.
    pub(crate) stage_dir: Option<PathBuf>,
    /// Whether to compile in release mode (`panic=abort` + optional `wasm-opt -Oz` + AI-schema check).
    #[get(type(copy))]
    pub(crate) release: bool,
    /// Whether to skip the optional `wasm-opt` pass.
    #[get(type(copy))]
    pub(crate) skip_wasm_opt: bool,
    /// Whether to reuse existing staged WASM/glue files when present on disk.
    #[get(type(copy))]
    pub(crate) reuse_existing: bool,
}

/// Output paths produced by compiling the shared zero-DOM WebAssembly host core.
#[derive(Clone, Debug, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
pub struct SharedWasmHostArtifacts {
    /// Compiled (and optionally `wasm-opt` optimized) `euv_app.wasm` path.
    pub(crate) wasm_path: PathBuf,
    /// Patched CommonJS glue path (`euv_wasm_glue.cjs.js`).
    pub(crate) glue_cjs_path: PathBuf,
    /// Patched ES Module glue path (`euv_wasm_glue.esm.js`).
    pub(crate) glue_esm_path: PathBuf,
    /// Final `euv_app.wasm` size in bytes.
    #[get(type(copy))]
    pub(crate) wasm_bytes: u64,
}

/// Configuration for generating and compiling a HarmonyOS / OpenHarmony Stage-Model project.
#[derive(Clone, Data, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct HarmonyBuildConfig {
    /// Root directory of the `euv` workspace.
    pub(crate) workspace_root: PathBuf,
    /// Target HarmonyOS device form factor (`phone`, `tablet`, `2in1`, `universal`, `foldable`, `wearable`, `tv`, `car`).
    #[get(type(copy))]
    pub(crate) device_kind: HarmonyDeviceKind,
    /// Optional explicit ABI list; empty triggers auto-selection (`[arm64-v8a, x86_64]` for PC/universal, `[arm64-v8a]` otherwise).
    pub(crate) abis: Vec<HarmonyAbi>,
    /// Optional explicit semantic version overriding workspace `Cargo.toml`.
    pub(crate) app_version: Option<String>,
    /// Optional output directory overriding `dist/harmony/<device>`.
    pub(crate) out_dir: Option<PathBuf>,
    /// Optional staging directory overriding `target/mobile-hosts/harmony-<device>`.
    pub(crate) build_dir: Option<PathBuf>,
    /// Optional OpenHarmony SDK root directory overriding `OHOS_SDK_HOME` auto-detection.
    pub(crate) ohos_sdk_root: Option<PathBuf>,
    /// When `true`, generates the Stage-Model + N-API + Rust shell without invoking OHOS NDK/hvigorw.
    #[get(type(copy))]
    pub(crate) shell_only: bool,
    /// When `true` and a `.hap` is assembled, installs it via `hdc install -r`.
    #[get(type(copy))]
    pub(crate) install_hap: bool,
}

/// Report emitted after generating or compiling a HarmonyOS / OpenHarmony project.
#[derive(Clone, Debug, Deserialize, Eq, Getter, PartialEq, Serialize)]
pub struct HarmonyBuildReport {
    /// Device form factor label (`phone`, `2in1`, `wearable`, etc.).
    pub(crate) device_kind: String,
    /// Resolved semantic version written into `oh-package.json5` and `AppScope/app.json5`.
    pub(crate) version: String,
    /// Computed HarmonyOS integer `versionCode`.
    #[get(type(copy))]
    pub(crate) version_code: u32,
    /// Generated HarmonyOS project root directory.
    pub(crate) out_dir: PathBuf,
    /// Rust staticlib host build directory.
    pub(crate) build_dir: PathBuf,
    /// Paths to compiled `libeuv_harmony_host.so` binaries (empty in `shell_only` or without OHOS NDK).
    pub(crate) compiled_so_paths: Vec<PathBuf>,
    /// Optional assembled `.hap` path when `hvigorw` was executed.
    pub(crate) hap_path: Option<PathBuf>,
    /// Whether `hdc install -r` deployed the `.hap`.
    #[get(type(copy))]
    pub(crate) installed: bool,
}

/// Configuration for generating and packaging MiniApp vendor hosts (13 ecosystems).
#[derive(Clone, Data, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct MiniAppBuildConfig {
    /// Root directory of the `euv` workspace.
    pub(crate) workspace_root: PathBuf,
    /// Target MiniApp vendors to generate (empty defaults to all 13 vendors).
    pub(crate) vendors: Vec<MiniAppVendor>,
    /// Optional explicit semantic version overriding workspace `Cargo.toml`.
    pub(crate) app_version: Option<String>,
    /// Optional output root overriding `dist/miniapp`.
    pub(crate) out_base: Option<PathBuf>,
    /// Whether to compile the shared WASM core in release profile.
    #[get(type(copy))]
    pub(crate) release: bool,
    /// When `true`, skips shared WASM core and HarmonyOS native compilation.
    #[get(type(copy))]
    pub(crate) shell_only: bool,
    /// Whether to skip optional `wasm-opt` when compiling the shared WASM core.
    #[get(type(copy))]
    pub(crate) skip_wasm_opt: bool,
}

/// Report produced after building one or more MiniApp vendor projects.
#[derive(Clone, Debug, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
pub struct MiniAppBuildReport {
    /// Resolved semantic version used in generated manifests.
    pub(crate) version: String,
    /// Generated vendor labels and output directories.
    pub(crate) generated_dirs: Vec<PathBuf>,
    /// Whether the shared zero-DOM WASM core was compiled and bundled into JS vendors.
    #[get(type(copy))]
    pub(crate) wasm_bundled: bool,
}

/// Configuration for generating and packaging QuickApp vendor projects (`alliance`, `huawei`).
#[derive(Clone, Data, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct QuickAppBuildConfig {
    /// Root directory of the `euv` workspace.
    pub(crate) workspace_root: PathBuf,
    /// Target QuickApp vendors (empty defaults to `[Alliance, Huawei]`).
    pub(crate) vendors: Vec<QuickAppVendor>,
    /// Optional explicit semantic version overriding workspace `Cargo.toml`.
    pub(crate) app_version: Option<String>,
    /// Optional output root overriding `dist/quickapp`.
    pub(crate) out_base: Option<PathBuf>,
    /// Whether to compile the shared WASM core in release profile.
    #[get(type(copy))]
    pub(crate) release: bool,
    /// When `true`, skips shared WASM core compilation and `hap release` `.rpk` packaging.
    #[get(type(copy))]
    pub(crate) shell_only: bool,
    /// Whether to skip optional `wasm-opt`.
    #[get(type(copy))]
    pub(crate) skip_wasm_opt: bool,
}

/// Report produced after building one or more QuickApp vendor projects.
#[derive(Clone, Debug, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
pub struct QuickAppBuildReport {
    /// Resolved semantic version written into `package.json` and `src/manifest.json`.
    pub(crate) version: String,
    /// Computed numeric `versionCode`.
    #[get(type(copy))]
    pub(crate) version_code: u32,
    /// Generated QuickApp vendor project directories.
    pub(crate) generated_dirs: Vec<PathBuf>,
    /// Whether the shared zero-DOM WASM core was compiled and copied.
    #[get(type(copy))]
    pub(crate) wasm_bundled: bool,
}

/// Configuration for generating and building smartwatch wearable hosts across 8 ecosystems.
#[derive(Clone, Data, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct WearableBuildConfig {
    /// Root directory of the `euv` workspace.
    pub(crate) workspace_root: PathBuf,
    /// Target wearable vendors (empty defaults to all 8 vendors).
    pub(crate) vendors: Vec<WearableVendor>,
    /// Optional explicit semantic version overriding workspace `Cargo.toml`.
    pub(crate) app_version: Option<String>,
    /// Optional output root overriding `dist/wearable`.
    pub(crate) out_base: Option<PathBuf>,
    /// Whether to compile native/WASM artifacts in release profile.
    #[get(type(copy))]
    pub(crate) release: bool,
    /// When `true`, generates project shells without invoking NDK/Xcode/OHOS/WASM compilers.
    #[get(type(copy))]
    pub(crate) shell_only: bool,
    /// When `true`, installs built Wear OS APK / HarmonyOS Watch HAP where supported.
    #[get(type(copy))]
    pub(crate) install: bool,
    /// Whether to skip optional `wasm-opt`.
    #[get(type(copy))]
    pub(crate) skip_wasm_opt: bool,
}

/// Report produced after building one or more smartwatch wearable targets.
#[derive(Clone, Debug, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
pub struct WearableBuildReport {
    /// Resolved semantic version written into wearable manifests.
    pub(crate) version: String,
    /// Computed numeric `versionCode`.
    #[get(type(copy))]
    pub(crate) version_code: u32,
    /// Generated wearable project directories or artifact paths.
    pub(crate) generated_paths: Vec<PathBuf>,
    /// Whether the shared zero-DOM WASM core was compiled and bundled into WASM watches.
    #[get(type(copy))]
    pub(crate) wasm_bundled: bool,
}