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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
use super::*;

/// Form factor metadata helpers for `HarmonyDeviceKind`.
impl HarmonyDeviceKind {
    /// Returns the canonical lowercase form factor label (`phone`, `2in1`, `wearable`, etc.).
    ///
    /// # Returns
    ///
    /// - `&'static str` - Canonical HarmonyOS device label.
    #[must_use]
    pub fn as_label(&self) -> &'static str {
        match self {
            Self::Phone => HARMONY_DEVICE_PHONE,
            Self::Tablet => HARMONY_DEVICE_TABLET,
            Self::Pc2In1 => HARMONY_DEVICE_2IN1,
            Self::Universal => HARMONY_DEVICE_UNIVERSAL,
            Self::Foldable => HARMONY_DEVICE_FOLDABLE,
            Self::Wearable => HARMONY_DEVICE_WEARABLE,
            Self::Tv => HARMONY_DEVICE_TV,
            Self::Car => HARMONY_DEVICE_CAR,
        }
    }

    /// Returns the Rust `HarmonyDeviceType` constant expression written to `host_config.rs`.
    ///
    /// # Returns
    ///
    /// - `&'static str` - Rust enum expression.
    #[must_use]
    pub fn rust_device_expr(&self) -> &'static str {
        match self {
            Self::Phone => HARMONY_EXPR_PHONE,
            Self::Tablet => HARMONY_EXPR_TABLET,
            Self::Pc2In1 | Self::Universal => HARMONY_EXPR_PC_2IN1,
            Self::Foldable => HARMONY_EXPR_FOLDABLE,
            Self::Wearable => HARMONY_EXPR_WATCH,
            Self::Tv => HARMONY_EXPR_TV,
            Self::Car => HARMONY_EXPR_AUTOMOTIVE,
        }
    }

    /// Returns whether this device profile defaults to dual-ABI (`arm64-v8a` + `x86_64`) compilation.
    ///
    /// # Returns
    ///
    /// - `bool` - `true` for `Pc2In1` and `Universal`.
    #[must_use]
    pub fn is_pc_target(&self) -> bool {
        matches!(self, Self::Pc2In1 | Self::Universal)
    }

    /// Returns the default HarmonyOS ABI list when none is explicitly configured.
    ///
    /// # Returns
    ///
    /// - `Vec<HarmonyAbi>` - Default ABI selection for this form factor.
    #[must_use]
    pub fn default_abis(&self) -> Vec<HarmonyAbi> {
        if self.is_pc_target() {
            vec![HarmonyAbi::Arm64V8a, HarmonyAbi::X86_64]
        } else {
            vec![HarmonyAbi::Arm64V8a]
        }
    }

    /// Returns the JSON array interior for `module.json5` `"deviceTypes"`.
    ///
    /// # Returns
    ///
    /// - `&'static str` - Quoted JSON device type elements.
    #[must_use]
    pub fn module_device_types_json(&self) -> &'static str {
        match self {
            Self::Phone => HARMONY_MOD_DEV_PHONE,
            Self::Tablet => HARMONY_MOD_DEV_TABLET,
            Self::Pc2In1 => HARMONY_MOD_DEV_2IN1,
            Self::Universal => HARMONY_MOD_DEV_UNIVERSAL,
            Self::Foldable => HARMONY_MOD_DEV_FOLDABLE,
            Self::Wearable => HARMONY_MOD_DEV_WEARABLE,
            Self::Tv => HARMONY_MOD_DEV_TV,
            Self::Car => HARMONY_MOD_DEV_CAR,
        }
    }

    /// Returns the JSON array string for `module.json5` `"supportWindowMode"`.
    ///
    /// # Returns
    ///
    /// - `&'static str` - JSON array literal of supported window modes.
    #[must_use]
    pub fn support_window_modes_json(&self) -> &'static str {
        match self {
            Self::Wearable | Self::Tv => HARMONY_WIN_MODE_FULLSCREEN,
            Self::Car => HARMONY_WIN_MODE_SPLIT,
            Self::Phone | Self::Tablet | Self::Pc2In1 | Self::Universal | Self::Foldable => {
                HARMONY_WIN_MODE_ALL
            }
        }
    }

    /// Returns optional `minWindowWidth` / `maxWindowHeight` properties for `module.json5`.
    ///
    /// # Returns
    ///
    /// - `&'static str` - Trailing JSON property snippet or empty string.
    #[must_use]
    pub fn window_limits_json(&self) -> &'static str {
        match self {
            Self::Tablet => HARMONY_WIN_LIMIT_TABLET,
            Self::Pc2In1 => HARMONY_WIN_LIMIT_2IN1,
            Self::Universal => HARMONY_WIN_LIMIT_UNIVERSAL,
            Self::Phone | Self::Foldable | Self::Wearable | Self::Tv | Self::Car => "",
        }
    }
}

/// Toolchain mapping helpers for `HarmonyAbi`.
impl HarmonyAbi {
    /// Returns the OpenHarmony `entry/libs/<abi>` directory name.
    ///
    /// # Returns
    ///
    /// - `&'static str` - `"arm64-v8a"` or `"x86_64"`.
    #[must_use]
    pub fn as_abi_dir(&self) -> &'static str {
        match self {
            Self::Arm64V8a => HARMONY_ABI_ARM64,
            Self::X86_64 => HARMONY_ABI_X86_64,
        }
    }

    /// Returns the Rust compilation target triple for OpenHarmony.
    ///
    /// # Returns
    ///
    /// - `&'static str` - OpenHarmony Rust target triple.
    #[must_use]
    pub fn rust_triple(&self) -> &'static str {
        match self {
            Self::Arm64V8a => HARMONY_TRIPLE_ARM64,
            Self::X86_64 => HARMONY_TRIPLE_X86_64,
        }
    }

    /// Returns the OHOS clang `--target` triple string.
    ///
    /// # Returns
    ///
    /// - `&'static str` - OHOS LLVM target triple.
    #[must_use]
    pub fn clang_triple(&self) -> &'static str {
        match self {
            Self::Arm64V8a => HARMONY_CLANG_ARM64,
            Self::X86_64 => HARMONY_CLANG_X86_64,
        }
    }

    /// Returns the lowercase underscore suffix for `CC_<triple>`.
    ///
    /// # Returns
    ///
    /// - `&'static str` - Lowercase Cargo env triple key.
    #[must_use]
    pub fn env_triple(&self) -> &'static str {
        match self {
            Self::Arm64V8a => HARMONY_ENV_ARM64,
            Self::X86_64 => HARMONY_ENV_X86_64,
        }
    }

    /// Returns the Cargo target linker environment variable name for this OHOS ABI.
    ///
    /// # Returns
    ///
    /// - `&'static str` - `CARGO_TARGET_<TRIPLE>_LINKER` variable name.
    #[must_use]
    pub fn cargo_linker_env(&self) -> &'static str {
        match self {
            Self::Arm64V8a => HARMONY_LINKER_ENV_ARM64,
            Self::X86_64 => HARMONY_LINKER_ENV_X86_64,
        }
    }
}

/// Vendor specification helpers for `MiniAppVendor`.
impl MiniAppVendor {
    /// Returns the canonical lowercase vendor directory and CLI label.
    ///
    /// # Returns
    ///
    /// - `&'static str` - Canonical MiniApp vendor name.
    #[must_use]
    pub fn as_label(&self) -> &'static str {
        match self {
            Self::Wechat => VENDOR_WECHAT,
            Self::Alipay => VENDOR_ALIPAY,
            Self::Douyin => VENDOR_DOUYIN,
            Self::Baidu => VENDOR_BAIDU,
            Self::Qq => VENDOR_QQ,
            Self::Kuaishou => VENDOR_KUAISHOU,
            Self::Jd => VENDOR_JD,
            Self::Xhs => VENDOR_XHS,
            Self::Dingtalk => VENDOR_DINGTALK,
            Self::Feishu => VENDOR_FEISHU,
            Self::Taobao => VENDOR_TAOBAO,
            Self::Meituan => VENDOR_MEITUAN,
            Self::HarmonyAtomic => VENDOR_HARMONY_ATOMIC,
        }
    }

    /// Returns the JavaScript host API namespace (`wx`, `my`, `tt`, `swan`, etc.).
    ///
    /// # Returns
    ///
    /// - `&'static str` - Host global API object name.
    #[must_use]
    pub fn api_namespace(&self) -> &'static str {
        match self {
            Self::Wechat => "wx",
            Self::Alipay | Self::Taobao => "my",
            Self::Douyin | Self::Feishu => "tt",
            Self::Baidu => NS_SWAN,
            Self::Qq => "qq",
            Self::Kuaishou => "ks",
            Self::Jd => "jd",
            Self::Xhs => NS_XHS,
            Self::Dingtalk => "dd",
            Self::Meituan => "mt",
            Self::HarmonyAtomic => "",
        }
    }

    /// Returns the vendor page markup file extension (`wxml`, `axml`, `ttml`, etc.).
    ///
    /// # Returns
    ///
    /// - `&'static str` - Markup extension without leading dot.
    #[must_use]
    pub fn markup_ext(&self) -> &'static str {
        match self {
            Self::Wechat => EXT_WXML,
            Self::Alipay | Self::Dingtalk | Self::Taobao => EXT_AXML,
            Self::Douyin | Self::Feishu => EXT_TTML,
            Self::Baidu => EXT_SWAN,
            Self::Qq => EXT_QML,
            Self::Kuaishou => EXT_KSML,
            Self::Jd => EXT_JXML,
            Self::Xhs => EXT_XHSML,
            Self::Meituan => EXT_MXML,
            Self::HarmonyAtomic => "",
        }
    }

    /// Returns the vendor stylesheet file extension (`wxss`, `acss`, `ttss`, `css`, etc.).
    ///
    /// # Returns
    ///
    /// - `&'static str` - Stylesheet extension without leading dot.
    #[must_use]
    pub fn style_ext(&self) -> &'static str {
        match self {
            Self::Wechat => EXT_WXSS,
            Self::Alipay | Self::Dingtalk | Self::Taobao => EXT_ACSS,
            Self::Douyin | Self::Feishu => EXT_TTSS,
            Self::Baidu | Self::Kuaishou | Self::Xhs => ECO_EXT_CSS,
            Self::Qq => EXT_QSS,
            Self::Jd => EXT_JXSS,
            Self::Meituan => EXT_MXSS,
            Self::HarmonyAtomic => "",
        }
    }

    /// Returns the vendor IDE project configuration filename.
    ///
    /// # Returns
    ///
    /// - `&'static str` - Config filename at project root.
    #[must_use]
    pub fn config_file(&self) -> &'static str {
        match self {
            Self::Alipay | Self::Dingtalk | Self::Taobao => MINIAPP_CFG_MINI_PROJECT,
            Self::Baidu => MINIAPP_CFG_SWAN,
            Self::HarmonyAtomic => "",
            Self::Wechat
            | Self::Douyin
            | Self::Qq
            | Self::Kuaishou
            | Self::Jd
            | Self::Xhs
            | Self::Feishu
            | Self::Meituan => MINIAPP_CFG_PROJECT_CONFIG,
        }
    }

    /// Returns whether this vendor uses Alipay-style markup events (`onTouchStart` vs `bindtouchstart`).
    ///
    /// # Returns
    ///
    /// - `bool` - `true` for Alipay, DingTalk, and Taobao.
    #[must_use]
    pub fn uses_alipay_syntax(&self) -> bool {
        matches!(self, Self::Alipay | Self::Dingtalk | Self::Taobao)
    }

    /// Returns the vendor WebAssembly global identifier (`WXWebAssembly`, `MYWebAssembly`, etc.).
    ///
    /// # Returns
    ///
    /// - `&'static str` - Vendor WebAssembly global symbol name.
    #[must_use]
    pub fn wasm_global(&self) -> &'static str {
        match self {
            Self::Wechat => WASM_GLOBAL_WX,
            Self::Alipay | Self::Dingtalk | Self::Taobao => WASM_GLOBAL_MY,
            Self::Douyin | Self::Feishu => WASM_GLOBAL_TT,
            Self::Qq => WASM_GLOBAL_QQ,
            Self::Baidu
            | Self::Kuaishou
            | Self::Jd
            | Self::Xhs
            | Self::Meituan
            | Self::HarmonyAtomic => WASM_GLOBAL_STD,
        }
    }
}

/// Vendor specification helpers for `QuickAppVendor`.
impl QuickAppVendor {
    /// Returns the canonical lowercase QuickApp vendor label (`alliance` or `huawei`).
    ///
    /// # Returns
    ///
    /// - `&'static str` - QuickApp vendor directory name.
    #[must_use]
    pub fn as_label(&self) -> &'static str {
        match self {
            Self::Alliance => VENDOR_ALLIANCE,
            Self::Huawei => VENDOR_HUAWEI,
        }
    }

    /// Returns the QuickApp application package identifier for `src/manifest.json`.
    ///
    /// # Returns
    ///
    /// - `&'static str` - QuickApp package ID.
    #[must_use]
    pub fn package_id(&self) -> &'static str {
        match self {
            Self::Alliance => QUICKAPP_ALLIANCE_PKG_ID,
            Self::Huawei => QUICKAPP_HUAWEI_PKG_ID,
        }
    }

    /// Returns the minimum QuickApp platform version integer (`1100`).
    ///
    /// # Returns
    ///
    /// - `u32` - Minimum platform version.
    #[must_use]
    pub fn min_platform_version(&self) -> u32 {
        QUICKAPP_MIN_PLATFORM_VERSION
    }
}

/// Vendor specification helpers for `WearableVendor`.
impl WearableVendor {
    /// Returns the canonical lowercase wearable vendor directory label.
    ///
    /// # Returns
    ///
    /// - `&'static str` - Wearable vendor label.
    #[must_use]
    pub fn as_label(&self) -> &'static str {
        match self {
            Self::WearOs => VENDOR_WEAROS,
            Self::WatchOs => VENDOR_WATCHOS,
            Self::HarmonyWatch => VENDOR_HARMONY_WATCH,
            Self::Vela => VENDOR_VELA,
            Self::VivoWatch => VENDOR_VIVO_WATCH,
            Self::OppoWatch => VENDOR_OPPO_WATCH,
            Self::Garmin => VENDOR_GARMIN,
            Self::ZeppOs => VENDOR_ZEPPOS,
        }
    }

    /// Returns whether this wearable target consumes the shared zero-DOM WASM core.
    ///
    /// # Returns
    ///
    /// - `bool` - `true` for `Vela`, `VivoWatch`, and `ZeppOs`.
    #[must_use]
    pub fn uses_shared_wasm_core(&self) -> bool {
        matches!(self, Self::Vela | Self::VivoWatch | Self::ZeppOs)
    }
}

/// Default configuration builder for `SharedWasmHostConfig`.
impl Default for SharedWasmHostConfig {
    /// Creates a release zero-DOM WASM host config rooted at `.`.
    ///
    /// # Returns
    ///
    /// - `Self` - Default `SharedWasmHostConfig`.
    fn default() -> Self {
        Self {
            workspace_root: PathBuf::from("."),
            stage_dir: None,
            release: true,
            skip_wasm_opt: false,
            reuse_existing: false,
        }
    }
}

/// Default configuration builder for `HarmonyBuildConfig`.
impl Default for HarmonyBuildConfig {
    /// Creates a HarmonyOS phone build configuration rooted at `.`.
    ///
    /// # Returns
    ///
    /// - `Self` - Default `HarmonyBuildConfig`.
    fn default() -> Self {
        Self {
            workspace_root: PathBuf::from("."),
            device_kind: HarmonyDeviceKind::Phone,
            abis: Vec::new(),
            app_version: None,
            out_dir: None,
            build_dir: None,
            ohos_sdk_root: None,
            shell_only: false,
            install_hap: false,
        }
    }
}

/// Default configuration builder for `MiniAppBuildConfig`.
impl Default for MiniAppBuildConfig {
    /// Creates a release MiniApp build configuration targeting all 13 vendors.
    ///
    /// # Returns
    ///
    /// - `Self` - Default `MiniAppBuildConfig`.
    fn default() -> Self {
        Self {
            workspace_root: PathBuf::from("."),
            vendors: Vec::new(),
            app_version: None,
            out_base: None,
            release: true,
            shell_only: false,
            skip_wasm_opt: false,
        }
    }
}

/// Default configuration builder for `QuickAppBuildConfig`.
impl Default for QuickAppBuildConfig {
    /// Creates a release QuickApp build configuration targeting both Alliance and Huawei.
    ///
    /// # Returns
    ///
    /// - `Self` - Default `QuickAppBuildConfig`.
    fn default() -> Self {
        Self {
            workspace_root: PathBuf::from("."),
            vendors: Vec::new(),
            app_version: None,
            out_base: None,
            release: true,
            shell_only: false,
            skip_wasm_opt: false,
        }
    }
}

/// Default configuration builder for `WearableBuildConfig`.
impl Default for WearableBuildConfig {
    /// Creates a release Wearable build configuration targeting all 8 smartwatch ecosystems.
    ///
    /// # Returns
    ///
    /// - `Self` - Default `WearableBuildConfig`.
    fn default() -> Self {
        Self {
            workspace_root: PathBuf::from("."),
            vendors: Vec::new(),
            app_version: None,
            out_base: None,
            release: true,
            shell_only: false,
            install: false,
            skip_wasm_opt: false,
        }
    }
}