Skip to main content

euv_cli/build/
const.rs

1/// Placeholder token used in HTML templates for the JS import path.
2///
3/// Replaced at runtime with the resolved import path relative to the www directory.
4pub const IMPORT_PATH_PLACEHOLDER: &str = "__IMPORT_PATH__";
5
6/// Placeholder token used in HTML templates for the reload endpoint URL.
7///
8/// Replaced at runtime with the actual reload route path.
9pub const RELOAD_ROUTE_PLACEHOLDER: &str = "__RELOAD_ROUTE__";
10
11/// The URL path for the reload endpoint.
12///
13/// Used by the live-reload script in the HTML template and the server route registration.
14pub const RELOAD_ROUTE: &str = "/__euv_reload";
15
16/// The wasm-pack flag indicating a release build.
17pub const RELEASE_FLAG: &str = "--release";
18
19/// The CLI command name for wasm-pack.
20pub const WASM_PACK_COMMAND: &str = "wasm-pack";
21
22/// The wasm-pack subcommand for building.
23pub const WASM_PACK_BUILD_SUBCOMMAND: &str = "build";
24
25/// The wasm-pack argument for specifying the output directory.
26pub const OUT_DIR_ARG: &str = "--out-dir";
27
28/// The wasm-pack argument for specifying the output name.
29pub const OUT_NAME_ARG: &str = "--out-name";
30
31/// The wasm-pack argument for specifying the target.
32pub const TARGET_ARG: &str = "--target";
33
34/// The default wasm-pack target for browser usage.
35pub const TARGET_WEB: &str = "web";
36
37/// The default output subdirectory name for wasm-pack artifacts.
38pub const PKG_DIR_NAME: &str = "pkg";
39
40/// The JavaScript file extension.
41pub const JS_EXTENSION: &str = ".js";
42
43/// The source directory name within a Cargo project.
44pub const SRC_DIR_NAME: &str = "src";
45
46/// The name of the gitignore file.
47pub const GITIGNORE_FILE_NAME: &str = ".gitignore";
48
49/// The name of the Cargo manifest file.
50pub const CARGO_TOML_FILE_NAME: &str = "Cargo.toml";
51
52/// The index HTML file name.
53pub const INDEX_HTML_FILE_NAME: &str = "index.html";
54
55/// The relative path prefix used for import path construction.
56pub const RELATIVE_PATH_PREFIX: &str = "./";
57
58/// The path separator used for joining path components.
59pub const PATH_SEPARATOR: &str = "/";
60
61/// The parent directory indicator used in relative path computation.
62pub const PARENT_DIR: &str = "..";
63
64/// The wasm-pack flag for development builds.
65pub const DEV_FLAG: &str = "--dev";
66
67/// The wasm-pack flag for profiling builds.
68pub const PROFILING_FLAG: &str = "--profiling";
69
70/// The euv-specific argument for specifying the crate path.
71pub const CRATE_PATH_ARG: &str = "--crate-path";
72
73/// The short form of the crate-path argument.
74pub const CRATE_PATH_ARG_SHORT: &str = "-c";
75
76/// The euv-specific argument for specifying the server port.
77pub const PORT_ARG: &str = "--port";
78
79/// The short form of the port argument.
80pub const PORT_ARG_SHORT: &str = "-p";
81
82/// The euv-specific argument for specifying the www directory.
83pub const WWW_DIR_ARG: &str = "--www-dir";
84
85/// The euv-specific argument for specifying a custom index.html template.
86pub const INDEX_HTML_ARG: &str = "--index-html";
87
88/// The euv-specific argument for removing the .gitignore file from the output directory.
89pub const NO_GITIGNORE_ARG: &str = "--no-gitignore";
90
91/// The euv-specific argument names that should not be forwarded to wasm-pack.
92pub const EUV_ARGS: &[&str] = &[
93    CRATE_PATH_ARG,
94    CRATE_PATH_ARG_SHORT,
95    PORT_ARG,
96    PORT_ARG_SHORT,
97    WWW_DIR_ARG,
98    INDEX_HTML_ARG,
99    NO_GITIGNORE_ARG,
100];
101
102/// The double-dash separator used to distinguish euv args from wasm-pack args.
103pub const DOUBLE_DASH: &str = "--";
104
105/// The `run` action name used in banner display.
106pub const ACTION_RUN: &str = "run";
107
108/// The `build` action name used in banner display.
109pub const ACTION_BUILD: &str = "build";
110
111/// The environment variable name for setting the minimum stack size of rustc threads.
112pub const RUST_MIN_STACK_ENV: &str = "RUST_MIN_STACK";
113
114/// The minimum stack size in bytes for rustc threads (16 MiB).
115pub const RUST_MIN_STACK_VALUE: &str = "16777216";
116
117/// The `index.html` template for the development profile.
118///
119/// Includes a live-reload `<script>` block that connects to the
120/// `/__euv_reload` endpoint and parses the JSON payload sent by the server.
121/// The JSON uses a tagged enum format:
122/// - `{"type":"Reload"}` — the client should reload the page.
123/// - `{"type":"Error","message":"..."}` — a build error occurred.
124///
125/// The `__IMPORT_PATH__` placeholder is replaced with the resolved JS import path at runtime.
126pub const INDEX_HTML_DEV: &str = r#"<!doctype html>
127<html lang="en">
128  <head>
129    <meta charset="utf-8" />
130    <meta
131      name="viewport"
132      content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, interactive-widget=resizes-visual"
133    />
134    <meta name="mobile-web-app-capable" content="yes" />
135    <meta name="apple-mobile-web-app-capable" content="yes" />
136    <meta
137      name="description"
138      content="A declarative, cross-platform UI framework for Rust with virtual DOM, reactive signals, and HTML macros for WebAssembly."
139    />
140    <meta
141      name="keywords"
142      content="rust, webassembly, wasm, ui-framework, virtual-dom, reactive, declarative-ui, euv"
143    />
144    <meta property="og:title" content="euv" />
145    <meta
146      property="og:description"
147      content="A declarative, cross-platform UI framework for Rust with virtual DOM, reactive signals, and HTML macros for WebAssembly."
148    />
149    <meta property="og:type" content="website" />
150    <title>Euv</title>
151    <style>
152      * {
153        -webkit-font-smoothing: antialiased;
154        -moz-osx-font-smoothing: grayscale;
155        text-rendering: optimizeLegibility;
156      }
157      canvas {
158        image-rendering: auto;
159      }
160    </style>
161  </head>
162  <body>
163    <div id="app"></div>
164  </body>
165  <script type="module">
166    import init, { main } from '__IMPORT_PATH__';
167    await init();
168    main();
169  </script>
170  <script>
171    (function () {
172      async function connect() {
173        try {
174          const res = await fetch('/__euv_reload');
175          const data = await res.json();
176          if (data.type === 'Reload') {
177            location.reload();
178          } else if (data.type === 'Error') {
179            console.error('[euv] build error:', data.message);
180            setTimeout(connect, 1000);
181          } else {
182            setTimeout(connect, 1000);
183          }
184        } catch (_) {
185          setTimeout(connect, 2000);
186        }
187      }
188      connect();
189    })();
190  </script>
191</html>
192"#;
193
194/// The `index.html` template for the release profile.
195///
196/// A minimal `index.html` without any live-reload instrumentation.
197/// Used when building for release to produce a clean, static entry point.
198/// The `__IMPORT_PATH__` placeholder is replaced with the resolved JS import path at runtime.
199pub const INDEX_HTML_RELEASE: &str = r#"<!doctype html>
200<html lang="en">
201  <head>
202    <meta charset="utf-8" />
203    <meta
204      name="viewport"
205      content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, interactive-widget=resizes-visual"
206    />
207    <meta name="mobile-web-app-capable" content="yes" />
208    <meta name="apple-mobile-web-app-capable" content="yes" />
209    <meta
210      name="description"
211      content="A declarative, cross-platform UI framework for Rust with virtual DOM, reactive signals, and HTML macros for WebAssembly."
212    />
213    <meta
214      name="keywords"
215      content="rust, webassembly, wasm, ui-framework, virtual-dom, reactive, declarative-ui, euv"
216    />
217    <meta property="og:title" content="euv" />
218    <meta
219      property="og:description"
220      content="A declarative, cross-platform UI framework for Rust with virtual DOM, reactive signals, and HTML macros for WebAssembly."
221    />
222    <meta property="og:type" content="website" />
223    <title>Euv</title>
224    <style>
225      * {
226        -webkit-font-smoothing: antialiased;
227        -moz-osx-font-smoothing: grayscale;
228        text-rendering: optimizeLegibility;
229      }
230      canvas {
231        image-rendering: auto;
232      }
233    </style>
234  </head>
235  <body>
236    <div id="app"></div>
237  </body>
238  <script type="module">
239    import init, { main } from '__IMPORT_PATH__';
240    await init();
241    main();
242  </script>
243</html>
244"#;