euv_core/platform/miniapp/enum.rs
1use super::*;
2
3/// All 7 supported super-app Mini-Program and Atomic Service host ecosystems.
4#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
5pub enum MiniAppVendor {
6 /// WeChat Mini-Program (`wx`, `.wxml` / `.wxss`).
7 #[default]
8 WeChat,
9 /// Alipay Mini-Program (`my`, `.axml` / `.acss`).
10 Alipay,
11 /// Douyin / ByteDance Mini-Program (`tt`, `.ttml` / `.ttss`).
12 Douyin,
13 /// Baidu Smart Mini-Program (`swan`, `.swan` / `.css`).
14 Baidu,
15 /// QQ Mini-Program (`qq`, `.qml` / `.qss`).
16 Qq,
17 /// Kuaishou Mini-Program (`ks`, `.ksml` / `.css`).
18 Kuaishou,
19 /// HarmonyOS Atomic Service (`atomic`, `installationFree: true`, ArkTS `.ets`).
20 HarmonyAtomic,
21}
22
23/// Active rendering context exposed by the host Mini-Program `<canvas>` node.
24#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub enum MiniAppCanvasMode {
26 /// Host 2D canvas context (`canvas.getContext('2d')` + `putImageData`).
27 #[default]
28 Canvas2d,
29 /// Host WebGL 1.0 context (`canvas.getContext('webgl')`).
30 WebGl,
31 /// Host WebGL 2.0 context (`canvas.getContext('webgl2')`).
32 WebGl2,
33}
34
35/// Normalized Mini-Program page and application lifecycle callbacks across all 7 vendors.
36#[derive(Clone, Debug, PartialEq)]
37pub enum MiniAppLifecycleHook {
38 /// `App.onLaunch(options)` cold start with optional query/scene deep link.
39 OnLaunch {
40 /// Optional launch deep-link or query URI.
41 query_uri: Option<String>,
42 },
43 /// `App.onShow` / `Page.onShow` foreground activation.
44 OnShow {
45 /// Optional warm-launch query or share URI.
46 query_uri: Option<String>,
47 },
48 /// `App.onHide` / `Page.onHide` background suspension (0% CPU/GPU freeze).
49 OnHide,
50 /// `Page.onUnload` tearing down the active page surface cleanly.
51 OnUnload,
52 /// `onWindowResize` reporting new logical viewport dimensions and DPR.
53 OnResize {
54 /// Updated logical viewport width in dp.
55 width: u32,
56 /// Updated logical viewport height in dp.
57 height: u32,
58 /// Updated display pixel ratio.
59 pixel_ratio: f32,
60 },
61 /// `onThemeChange` toggling Light/Dark appearance.
62 OnThemeChange(ThemeMode),
63 /// `onMemoryWarning` signaling host memory pressure level (`5`=moderate, `10`/`15`=critical).
64 OnMemoryWarning(i32),
65 /// `onKeyboardHeightChange` reporting soft keyboard height in logical dp.
66 OnKeyboardHeightChange(f32),
67 /// `onNetworkStatusChange` reporting host network status.
68 OnNetworkStatusChange(NetworkStatus),
69}
70
71/// Outbound vendor-agnostic host bridge command emitted by `MiniAppPlatform` to the thin JS/ArkTS shell.
72#[derive(Clone, Debug, PartialEq)]
73pub enum MiniAppHostCommand {
74 /// Updates host navigation bar title (`setNavigationBarTitle`).
75 SetNavigationBarTitle(String),
76 /// Writes text to host clipboard (`setClipboardData`).
77 SetClipboardData(String),
78 /// Persists key-value pair to host sandbox storage (`setStorageSync`).
79 SetStorageSync {
80 /// Storage key.
81 key: String,
82 /// Storage UTF-8 value.
83 value: String,
84 },
85 /// Removes a key from host sandbox storage (`removeStorageSync`).
86 RemoveStorageSync(String),
87 /// Clears all keys from host sandbox storage (`clearStorageSync`).
88 ClearStorageSync,
89 /// Pushes a page onto the host Mini-Program navigation stack (`navigateTo`).
90 NavigateTo(String),
91 /// Pops `delta` pages from the host Mini-Program navigation stack (`navigateBack`).
92 NavigateBack(u32),
93 /// Opens or updates the host soft keyboard / IME (`showKeyboard`).
94 ShowKeyboard {
95 /// Whether keyboard input is active.
96 enabled: bool,
97 /// Target logical input anchor rectangle.
98 rect: Rect,
99 },
100 /// Presents a rendered frame buffer dimensions notification to the host canvas context.
101 PresentCanvas {
102 /// Active canvas context mode (`Canvas2d` / `WebGl` / `WebGl2`).
103 mode: MiniAppCanvasMode,
104 /// Framebuffer physical width in pixels.
105 width: u32,
106 /// Framebuffer physical height in pixels.
107 height: u32,
108 },
109 /// Triggers a short tactile vibration pulse (`vibrateShort`).
110 VibrateShort,
111}