Skip to main content

euv_cli/builder/web/
struct.rs

1use super::*;
2
3/// Resolved Cargo package metadata needed for WebAssembly compilation and version verification.
4#[derive(Clone, Data, Debug, Eq, New, PartialEq)]
5pub struct WebPackageMetadata {
6    /// Cargo package name (e.g. `euv-example`).
7    pub(crate) package_name: String,
8    /// Snake-case compiled Rust library target name (e.g. `euv_example`).
9    pub(crate) lib_name: String,
10    /// Dynamic semantic version resolved from `Cargo.toml`.
11    pub(crate) version: String,
12    /// Cargo target directory honoring `CARGO_TARGET_DIR`.
13    pub(crate) target_dir: PathBuf,
14    /// Exact `wasm-bindgen` crate version resolved in `Cargo.lock`, when present.
15    pub(crate) wasm_bindgen_version: Option<String>,
16    /// Sorted `theme-*` feature names declared on the package.
17    pub(crate) theme_features: Vec<String>,
18}
19
20/// Configuration for pure-Rust WebAssembly zero-JS, raw-WASM, and theme-variant builds.
21#[derive(Clone, Data, Debug, Deserialize, Eq, PartialEq, Serialize)]
22pub struct WebBuildConfig {
23    /// Workspace or crate root directory.
24    pub(crate) repo_root: PathBuf,
25    /// Cargo package to compile for `wasm32-unknown-unknown`.
26    pub(crate) package: String,
27    /// Destination directory for packaged web artifacts.
28    pub(crate) out_dir: PathBuf,
29    /// Normalized asset URL base prefix (default `./`).
30    pub(crate) base_url: String,
31    /// HTML document title written into `index.html` and `404.html`.
32    pub(crate) title: String,
33    /// Optional explicit version override (resolved dynamically from `Cargo.toml` when `None`).
34    pub(crate) version: Option<String>,
35    /// Optional custom source PNG icon path.
36    pub(crate) icon_path: Option<PathBuf>,
37    /// Optional destination archive path (`.tar.gz` or `.zip`).
38    pub(crate) archive_path: Option<PathBuf>,
39    /// Optional Cargo feature list passed via `--features`.
40    pub(crate) features: Vec<String>,
41    /// Whether to pass `--no-default-features` to Cargo.
42    #[get(type(copy))]
43    pub(crate) no_default_features: bool,
44    /// Whether to compile with `--release` and `CARGO_PROFILE_RELEASE_PANIC=abort`.
45    #[get(type(copy))]
46    pub(crate) release: bool,
47    /// When `true`, skips the optional binaryen `wasm-opt` optimization pass.
48    #[get(type(copy))]
49    pub(crate) skip_wasm_opt: bool,
50    /// When `true`, emits raw `.wasm` + icons + `build-plan.json` without `wasm-bindgen-cli`.
51    #[get(type(copy))]
52    pub(crate) raw_wasm: bool,
53    /// When `true`, verifies zero `.js`, zero AI schema leaks, preload links, and `euv-release.json`.
54    #[get(type(copy))]
55    pub(crate) verify: bool,
56    /// When `true`, builds `default` plus all `theme-*` variants with SHA-256 fingerprint caching.
57    #[get(type(copy))]
58    pub(crate) theme_variants: bool,
59}
60
61/// Structured summary returned by `build_web_bundle`.
62#[derive(Clone, Data, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
63pub struct WebBuildReport {
64    /// Built Cargo package name.
65    pub(crate) package: String,
66    /// Resolved semantic version written into `euv-release.json`.
67    pub(crate) version: String,
68    /// Output directory containing the packaged bundle.
69    pub(crate) out_dir: PathBuf,
70    /// Normalized asset URL base prefix used in `index.html`.
71    pub(crate) base_url: String,
72    /// Primary `.wasm` filename emitted in `out_dir`.
73    pub(crate) wasm_file: String,
74    /// Final `.wasm` byte size on disk.
75    #[get(type(copy))]
76    pub(crate) wasm_bytes: u64,
77    /// Whether `wasm-opt` optimization succeeded on the `.wasm` binary.
78    #[get(type(copy))]
79    pub(crate) wasm_opt_applied: bool,
80    /// Whether `--raw-wasm` mode was used.
81    #[get(type(copy))]
82    pub(crate) raw_wasm: bool,
83    /// Total file entries recorded in `euv-release.json` (or emitted in `--raw-wasm` mode).
84    #[get(type(copy))]
85    pub(crate) file_count: usize,
86    /// End-to-end build duration in milliseconds.
87    #[get(type(copy))]
88    pub(crate) elapsed_ms: u64,
89    /// Path to `euv-release.json` when generated.
90    pub(crate) manifest_path: Option<PathBuf>,
91    /// Path to packaged archive when `archive_path` was configured.
92    pub(crate) archive_path: Option<PathBuf>,
93}
94
95/// Structured summary returned by `build_web_theme_variants`.
96#[derive(Clone, Data, Debug, Deserialize, Eq, New, PartialEq, Serialize)]
97pub struct ThemeVariantBuildReport {
98    /// Output directory root containing `themes/<feature>/` bundles.
99    pub(crate) out_dir: PathBuf,
100    /// Resolved semantic version.
101    pub(crate) version: String,
102    /// Variant names freshly compiled during this run.
103    pub(crate) built_variants: Vec<String>,
104    /// Variant names reused from matching SHA-256 source fingerprints.
105    pub(crate) cached_variants: Vec<String>,
106    /// Total wall-clock elapsed duration in milliseconds.
107    #[get(type(copy))]
108    pub(crate) elapsed_ms: u64,
109}