lingxia-lxapp 0.15.0

LxApp (lightweight application) container and runtime for LingXia framework
Documentation
#![cfg_attr(not(feature = "js-appservice"), allow(dead_code, unused_imports))]

mod appservice;
mod archive;
/// Shared automation lower half for devtool handlers and `lx.automation()`.
#[cfg(feature = "automation")]
pub mod automation;
pub(crate) mod bridge;
mod cache;
mod delegate;
/// Simulated-device control shared by the devtool and `lx.automation()`.
pub mod device;
mod error;
mod executor;
pub mod host;
pub mod lifecycle;
pub mod log {
    pub use lingxia_log::{LogLevel, LogMessage, LogProvider};
}
#[cfg(feature = "js-appservice")]
pub mod lx;
mod lxapp;
mod native_component;
mod page;
pub(crate) mod plugin;
pub mod provider;
mod route;
pub mod startup;
/// Host-published terminal workspace state for trusted automation drivers.
pub mod terminal_automation;
mod update;
pub(crate) mod view_call;

/// SDK/runtime version of lingxia-lxapp.
/// This is used for update compatibility checks and can be reported to update services.
pub const SDK_RUNTIME_VERSION: &str = env!("CARGO_PKG_VERSION");

#[cfg(feature = "js-appservice")]
pub use appservice::PageSvc;
#[cfg(feature = "js-appservice")]
pub use appservice::event_bus::{
    AppHandlerUnsub, HandlerToken, app_handler_unsub, register_app_handler, register_page_handler,
    unregister_app_handler, unregister_app_handler_token, unregister_page_handler,
};
pub use appservice::event_bus::{
    BROWSER_TAB_CLOSED_EVENT, DISPLAY_LANGUAGE_CHANGE_EVENT, publish_app_event, publish_page_event,
};
pub use cache::touch_access_time;
pub use delegate::{LxAppDelegate, LxAppUiEventType};
pub use error::LxAppError;
pub use lifecycle::{
    AppServiceEvent, AppServiceEventArgs, AppServiceEventReason, AppServiceEventSource,
    PageLifecycleEvent,
};
pub use lingxia_platform::traits::ui::WindowChrome;
pub use lingxia_surface;
pub use lingxia_surface::{FloatDismiss, SurfaceInteraction};
pub use lingxia_update::host_channel;
pub use lingxia_update::{
    ReleaseType, RuntimeCompatibilityError, SemanticVersion, Version, VersionError,
};
pub use lingxia_webview::url_callback;
pub use lxapp::set_num_workers;
pub use lxapp::{
    CloseReason, CreatePageInstanceRequest, CreatedPageInstance, DisplayLanguage,
    HOST_SURFACE_OWNER_APP_ID, HostMainSurfaceRegistration, HostSurfaceMenuExecution,
    LXAPP_MORE_ACTION_LIMIT, LxApp, LxAppMoreAction, LxAppMoreActions, LxAppOpenRegion,
    LxAppRuntimeInfo, LxAppRuntimePageInfo, LxAppRuntimeSurfaceInfo, LxAppSecurityPrivilege,
    ManagedNativeSurface, PageDefinition, PageInstanceEvent, PageInstanceRuntimeInfo, PageOwner,
    PageQueryInput, PageSurface, PageSurfaceRequest, PageSurfaceTarget, PageTarget,
    PresentationKind, ResolvedPage, SceneId, SurfaceKind, SurfacePosition, SurfaceRole,
    UrlCallbackSurface, UrlCallbackWaitError, add_display_language_change_listener,
    apply_display_language_override, automation_auto_grant, bundled_lxapp_asset_available,
    close_lxapp,
    config::LxAppInfo,
    create_page_instance, display_language, dispose_page_instance, dispose_page_instance_by_id,
    ensure_builtin_lxapp, ensure_host_surface_owner, ensure_lxapp, find_page_by_instance_id,
    get_current_lxapp, get_platform, host_class, init, installed_lxapp_path, is_dev_session,
    is_public_network_address, is_pull_down_refresh_enabled, list_lxapps, mark_lxapp_active,
    navbar, notify_lxapp_host_visibility, notify_page_host_visibility, notify_page_instance,
    notify_page_instance_by_id, on_low_memory, open_lxapp, open_region, page_chrome,
    refresh_auto_appearances, register_builtin_asset_bundle, register_dev_bundle_source,
    register_surface_active_main_observer, register_surface_close_observer,
    register_surface_context_observer, register_surface_visibility_observer,
    register_synthetic_lxapp,
    registry::{
        display_icon_path as lxapp_display_icon_path, display_name as lxapp_display_name,
        display_status as lxapp_registry_status, ensure_open_allowed,
        notify_open_blocked as notify_lxapp_open_blocked,
        refresh_registry as refresh_lxapp_registry, registry_unavailable_status,
        set_open_blocked_listener as set_lxapp_open_blocked_listener,
        set_registry_change_listener as set_lxapp_registry_change_listener,
    },
    restart_lxapp, set_automation_auto_grant, set_display_language, set_display_language_in,
    tabbar, touch_page_instance_by_id, try_get, uninstall_lxapp,
};
pub use native_component::{
    NativeComponentHost, on_native_component_event, register_native_component_host,
};
pub use page::config::{OrientationConfig, PageOrientation};
pub use page::{
    NavigationType, PageAutomationState, PageInstance, PageInstanceId, ViewCallOptions,
    add_global_page_script, register_page_resolver, resolve_page_path,
};
pub use plugin::{build_plugin_page_path, parse_plugin_page_path, parse_plugin_url};
pub use provider::{
    BoxFuture, FingerprintProvider, LxAppStatus, LxAppUpdateQuery, NoOpProvider, Provider,
    ProviderError, ProviderErrorCode, ProviderErrorExt, PushNotificationProvider,
    UpdatePackageInfo, UpdateProvider, UpdateTarget, register_provider,
};
pub use startup::{
    LxAppStartupOptions, Scene, append_page_query, parse_env_release_type,
    parse_optional_env_release_type,
};
pub use update::{
    DownloadedUpdateInfo, OtaUpdateTarget, UpdateManager, ensure_first_install,
    ensure_force_update_for_installed, ensure_target_version_ready, is_force_update_downloading,
    prepare_lxapp_open, schedule_lxapp_update_check,
};

// Re-export for internal crate usage
pub(crate) use provider::get_provider;

pub fn js_appservice_supported() -> bool {
    cfg!(feature = "js-appservice")
}

pub fn js_lxapp_supported() -> bool {
    js_appservice_supported()
}

#[doc(hidden)]
pub mod __private {
    pub use lingxia_log::{LogBuilder, LogLevel, LogTag};
}

#[macro_export]
macro_rules! info {
    ($($arg:tt)*) => {
        $crate::__private::LogBuilder::new(
            $crate::__private::LogTag::Native,
            format!($($arg)*),
        )
    };
}

#[macro_export]
macro_rules! warn {
    ($($arg:tt)*) => {
        $crate::__private::LogBuilder::new(
            $crate::__private::LogTag::Native,
            format!($($arg)*),
        )
        .with_level($crate::__private::LogLevel::Warn)
    };
}

#[macro_export]
macro_rules! error {
    ($($arg:tt)*) => {
        $crate::__private::LogBuilder::new(
            $crate::__private::LogTag::Native,
            format!($($arg)*),
        )
        .with_level($crate::__private::LogLevel::Error)
    };
}

#[macro_export]
macro_rules! debug {
    ($($arg:tt)*) => {
        $crate::__private::LogBuilder::new(
            $crate::__private::LogTag::Native,
            format!($($arg)*),
        )
        .with_level($crate::__private::LogLevel::Debug)
    };
}

#[macro_export]
macro_rules! verbose {
    ($($arg:tt)*) => {
        $crate::__private::LogBuilder::new(
            $crate::__private::LogTag::Native,
            format!($($arg)*),
        )
        .with_level($crate::__private::LogLevel::Verbose)
    };
}