euv-core 0.48.0

Core cross-platform runtime for euv featuring arena-based fine-grained reactivity, deterministic layout, flat scene graph, multi-mode rendering, and direct OS platform adapters.
Documentation
use super::*;

/// All 7 supported super-app Mini-Program and Atomic Service host ecosystems.
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum MiniAppVendor {
    /// WeChat Mini-Program (`wx`, `.wxml` / `.wxss`).
    #[default]
    WeChat,
    /// Alipay Mini-Program (`my`, `.axml` / `.acss`).
    Alipay,
    /// Douyin / ByteDance Mini-Program (`tt`, `.ttml` / `.ttss`).
    Douyin,
    /// Baidu Smart Mini-Program (`swan`, `.swan` / `.css`).
    Baidu,
    /// QQ Mini-Program (`qq`, `.qml` / `.qss`).
    Qq,
    /// Kuaishou Mini-Program (`ks`, `.ksml` / `.css`).
    Kuaishou,
    /// HarmonyOS Atomic Service (`atomic`, `installationFree: true`, ArkTS `.ets`).
    HarmonyAtomic,
}

/// Active rendering context exposed by the host Mini-Program `<canvas>` node.
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum MiniAppCanvasMode {
    /// Host 2D canvas context (`canvas.getContext('2d')` + `putImageData`).
    #[default]
    Canvas2d,
    /// Host WebGL 1.0 context (`canvas.getContext('webgl')`).
    WebGl,
    /// Host WebGL 2.0 context (`canvas.getContext('webgl2')`).
    WebGl2,
}

/// Normalized Mini-Program page and application lifecycle callbacks across all 7 vendors.
#[derive(Clone, Debug, PartialEq)]
pub enum MiniAppLifecycleHook {
    /// `App.onLaunch(options)` cold start with optional query/scene deep link.
    OnLaunch {
        /// Optional launch deep-link or query URI.
        query_uri: Option<String>,
    },
    /// `App.onShow` / `Page.onShow` foreground activation.
    OnShow {
        /// Optional warm-launch query or share URI.
        query_uri: Option<String>,
    },
    /// `App.onHide` / `Page.onHide` background suspension (0% CPU/GPU freeze).
    OnHide,
    /// `Page.onUnload` tearing down the active page surface cleanly.
    OnUnload,
    /// `onWindowResize` reporting new logical viewport dimensions and DPR.
    OnResize {
        /// Updated logical viewport width in dp.
        width: u32,
        /// Updated logical viewport height in dp.
        height: u32,
        /// Updated display pixel ratio.
        pixel_ratio: f32,
    },
    /// `onThemeChange` toggling Light/Dark appearance.
    OnThemeChange(ThemeMode),
    /// `onMemoryWarning` signaling host memory pressure level (`5`=moderate, `10`/`15`=critical).
    OnMemoryWarning(i32),
    /// `onKeyboardHeightChange` reporting soft keyboard height in logical dp.
    OnKeyboardHeightChange(f32),
    /// `onNetworkStatusChange` reporting host network status.
    OnNetworkStatusChange(NetworkStatus),
}

/// Outbound vendor-agnostic host bridge command emitted by `MiniAppPlatform` to the thin JS/ArkTS shell.
#[derive(Clone, Debug, PartialEq)]
pub enum MiniAppHostCommand {
    /// Updates host navigation bar title (`setNavigationBarTitle`).
    SetNavigationBarTitle(String),
    /// Writes text to host clipboard (`setClipboardData`).
    SetClipboardData(String),
    /// Persists key-value pair to host sandbox storage (`setStorageSync`).
    SetStorageSync {
        /// Storage key.
        key: String,
        /// Storage UTF-8 value.
        value: String,
    },
    /// Removes a key from host sandbox storage (`removeStorageSync`).
    RemoveStorageSync(String),
    /// Clears all keys from host sandbox storage (`clearStorageSync`).
    ClearStorageSync,
    /// Pushes a page onto the host Mini-Program navigation stack (`navigateTo`).
    NavigateTo(String),
    /// Pops `delta` pages from the host Mini-Program navigation stack (`navigateBack`).
    NavigateBack(u32),
    /// Opens or updates the host soft keyboard / IME (`showKeyboard`).
    ShowKeyboard {
        /// Whether keyboard input is active.
        enabled: bool,
        /// Target logical input anchor rectangle.
        rect: Rect,
    },
    /// Presents a rendered frame buffer dimensions notification to the host canvas context.
    PresentCanvas {
        /// Active canvas context mode (`Canvas2d` / `WebGl` / `WebGl2`).
        mode: MiniAppCanvasMode,
        /// Framebuffer physical width in pixels.
        width: u32,
        /// Framebuffer physical height in pixels.
        height: u32,
    },
    /// Triggers a short tactile vibration pulse (`vibrateShort`).
    VibrateShort,
}