euv-core 0.47.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 HarmonyOS / OpenHarmony physical device categories unified by `HarmonyPlatform`.
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum HarmonyDeviceType {
    /// HarmonyOS smartphone (`deviceType: "phone"`).
    #[default]
    Phone,
    /// HarmonyOS tablet (`deviceType: "tablet"`).
    Tablet,
    /// HarmonyOS PC / 2-in-1 desktop (`deviceType: "2in1"`).
    Pc2In1,
    /// HarmonyOS foldable phone/tablet with dynamic hinge transitions (`"foldable"`).
    Foldable,
    /// HarmonyOS Watch / Wearable (`deviceType: "wearable"`).
    Watch,
    /// HarmonyOS Smart TV / Vision (`deviceType: "tv"`).
    Tv,
    /// HarmonyOS Automotive / Smart Cockpit (`deviceType: "car"`).
    Automotive,
}

/// Physical hinge posture state reported by HarmonyOS foldable devices (`display.FoldStatus`).
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum HarmonyFoldState {
    /// Device is closed to its compact cover screen.
    Folded,
    /// Device is partially unfolded (tent / flex laptop posture).
    HalfFolded,
    /// Device is fully unfolded to its tablet-class inner display.
    #[default]
    Expanded,
}

/// Active native rendering path bound to HarmonyOS `OHNativeWindow`.
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum HarmonyGraphicsApi {
    /// Direct GPU rendering over Khronos Vulkan (`VK_OHOS_surface`).
    Vulkan,
    /// Direct GPU rendering over EGL + OpenGL ES 3.0 (`eglCreateWindowSurface`).
    #[default]
    OpenGlEs3,
    /// Reference CPU software buffer upload via `OH_NativeWindow_NativeWindowRequestBuffer` / `FlushBuffer`.
    SoftwareBuffer,
}

/// Stage-Model HarmonyOS `UIAbility` and `WindowStage` lifecycle hooks normalized into EUV `SystemEvent`s.
#[derive(Clone, Debug, PartialEq)]
pub enum HarmonyLifecycleHook {
    /// `UIAbility.onCreate(want)` creating a fresh ability session.
    OnCreate {
        /// Optional incoming Want URI deep link.
        want_uri: Option<String>,
    },
    /// `UIAbility.onWindowStageCreate(windowStage)` attaching `OHNativeWindow` / `XComponent`.
    OnWindowStageCreate {
        /// Raw `OHNativeWindow*` pointer (`0` when deferred).
        native_window: usize,
        /// Raw `OH_NativeXComponent*` pointer (`0` when deferred).
        xcomponent: usize,
    },
    /// `UIAbility.onForeground()` resuming rendering and active interactive frame pumping.
    OnForeground,
    /// `WindowStageEventType.ACTIVE` signaling active window input focus.
    OnWindowActive,
    /// `WindowStageEventType.INACTIVE` signaling transient focus loss (control center, multi-window switch).
    OnWindowInactive,
    /// `UIAbility.onBackground()` freezing rendering, timers, and frame pumping (0% CPU/GPU).
    OnBackground,
    /// `UIAbility.onWindowStageDestroy()` detaching native surface handles safely.
    OnWindowStageDestroy,
    /// `UIAbility.onDestroy()` terminating the ability session gracefully.
    OnDestroy,
    /// `UIAbility.onMemoryLevel(level)` reporting OS memory pressure.
    OnMemoryLevel(i32),
    /// `UIAbility.onConfigurationUpdate` updating theme, locale, density, or foldable state.
    OnConfigurationUpdate {
        /// Updated OS appearance mode (`Light` / `Dark`).
        theme: ThemeMode,
        /// Updated BCP-47 locale tag.
        locale: String,
        /// Updated display density scale factor (`vp -> px`).
        density: f32,
        /// Optional updated foldable hinge posture.
        fold_state: Option<HarmonyFoldState>,
    },
    /// System gesture or hardware Back button press (`onBackPress`).
    OnBackPress,
    /// Warm-launch `UIAbility.onNewWant(want)` delivering a new deep-link URI.
    OnNewWant(String),
}