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 subdirectory of `pkg/` that holds wasm-bindgen `inline_js` snippets.
47pub const SNIPPETS_DIR_NAME: &str = "snippets";
48
49/// The name of the gitignore file.
50pub const GITIGNORE_FILE_NAME: &str = ".gitignore";
51
52/// The glob suffix that matches wasm-bindgen snippet files (`inline0.js`,
53/// `inline1.js`, etc. — one per `#[wasm_bindgen(inline_js = ...)]` block).
54pub const SNIPPET_FILE_PREFIX: &str = "inline";
55
56/// The name of the Cargo manifest file.
57pub const CARGO_TOML_FILE_NAME: &str = "Cargo.toml";
58
59/// The index HTML file name.
60pub const INDEX_HTML_FILE_NAME: &str = "index.html";
61
62/// ASCII byte slice for the HTML comment close delimiter (`-->`).
63///
64/// Used by the inline HTML minifier to detect end-of-comment while
65/// scanning an HTML template byte stream.
66pub const HTML_COMMENT_CLOSE_BYTES: &[u8] = b"-->";
67
68/// ASCII byte slice for the HTML comment open delimiter (`<!--`).
69///
70/// Used by the inline HTML minifier to detect start-of-comment while
71/// scanning an HTML template byte stream.
72pub const HTML_COMMENT_OPEN_BYTES: &[u8] = b"<!--";
73
74/// The HTML greater-than tag delimiter (`>`) as a single ASCII byte.
75///
76/// Used by the inline HTML minifier to detect the end of an opening tag
77/// and trigger tag-gap whitespace stripping.
78pub const HTML_GT: u8 = b'>';
79
80/// The HTML less-than tag delimiter (`<`) as a single ASCII byte.
81///
82/// Used by the inline HTML minifier to detect the start of a tag and
83/// enter tag-internal whitespace collapsing.
84pub const HTML_LT: u8 = b'<';
85
86/// ASCII byte slice for the closing `</script` tag without the trailing
87/// `>` or whitespace.
88///
89/// Used by the inline HTML minifier to detect the end of an inline-JS
90/// preserve region inside the HTML template.
91pub const HTML_SCRIPT_CLOSE_PREFIX_BYTES: &[u8] = b"</script";
92
93/// ASCII byte slice for the opening `<script` tag without the trailing
94/// `>` or whitespace.
95///
96/// Used by the inline HTML minifier to detect the start of an inline-JS
97/// preserve region inside the HTML template.
98pub const HTML_SCRIPT_OPEN_PREFIX_BYTES: &[u8] = b"<script";
99
100/// The HTML forward-slash character as a single ASCII byte.
101///
102/// Used by the inline HTML minifier to detect closing tags (e.g.
103/// `</style>`) and self-closing tags (`<br/>`) while scanning the
104/// template byte stream.
105pub const HTML_SLASH: u8 = b'/';
106
107/// The ASCII space byte used as the canonical collapsed-whitespace output
108/// by the inline HTML minifier.
109///
110/// Whenever a run of whitespace characters collapses to a single space,
111/// this byte is written to the output buffer.
112pub const HTML_SPACE: u8 = b' ';
113
114/// ASCII byte slice for the closing `</style` tag without the trailing
115/// `>` or whitespace.
116///
117/// Used by the inline HTML minifier to detect the end of an inline-CSS
118/// preserve region inside the HTML template.
119pub const HTML_STYLE_CLOSE_PREFIX_BYTES: &[u8] = b"</style";
120
121/// ASCII byte slice for the opening `<style` tag without the trailing
122/// `>` or whitespace.
123///
124/// Used by the inline HTML minifier to detect the start of an inline-CSS
125/// preserve region inside the HTML template.
126pub const HTML_STYLE_OPEN_PREFIX_BYTES: &[u8] = b"<style";
127
128/// The relative path prefix used for import path construction.
129pub const RELATIVE_PATH_PREFIX: &str = "./";
130
131/// The path separator used for joining path components.
132pub const PATH_SEPARATOR: &str = "/";
133
134/// The parent directory indicator used in relative path computation.
135pub const PARENT_DIR: &str = "..";
136
137/// The wasm-pack flag for development builds.
138pub const DEV_FLAG: &str = "--dev";
139
140/// The wasm-pack flag for profiling builds.
141pub const PROFILING_FLAG: &str = "--profiling";
142
143/// The euv-specific argument for specifying the crate path.
144pub const CRATE_PATH_ARG: &str = "--crate-path";
145
146/// The short form of the crate-path argument.
147pub const CRATE_PATH_ARG_SHORT: &str = "-c";
148
149/// The euv-specific argument for specifying the server port.
150pub const PORT_ARG: &str = "--port";
151
152/// The short form of the port argument.
153pub const PORT_ARG_SHORT: &str = "-p";
154
155/// The euv-specific argument for specifying the www directory.
156pub const WWW_DIR_ARG: &str = "--www-dir";
157
158/// The euv-specific argument for specifying a custom index.html template.
159pub const INDEX_HTML_ARG: &str = "--index-html";
160
161/// The euv-specific argument for removing the .gitignore file from the output directory.
162pub const NO_GITIGNORE_ARG: &str = "--no-gitignore";
163
164/// The euv-specific argument names that should not be forwarded to wasm-pack.
165pub const EUV_ARGS: &[&str] = &[
166 CRATE_PATH_ARG,
167 CRATE_PATH_ARG_SHORT,
168 PORT_ARG,
169 PORT_ARG_SHORT,
170 WWW_DIR_ARG,
171 INDEX_HTML_ARG,
172 NO_GITIGNORE_ARG,
173];
174
175/// The double-dash separator used to distinguish euv args from wasm-pack args.
176pub const DOUBLE_DASH: &str = "--";
177
178/// The `run` action name used in banner display.
179pub const ACTION_RUN: &str = "run";
180
181/// The `build` action name used in banner display.
182pub const ACTION_BUILD: &str = "build";
183
184/// The environment variable name for setting the minimum stack size of rustc threads.
185pub const RUST_MIN_STACK_ENV: &str = "RUST_MIN_STACK";
186
187/// The minimum stack size in bytes for rustc threads (16 MiB).
188pub const RUST_MIN_STACK_VALUE: &str = "16777216";
189
190/// The `index.html` template for the development profile.
191///
192/// Includes a live-reload `<script>` block that connects to the
193/// `/__euv_reload` endpoint and parses the JSON payload sent by the server.
194/// The JSON uses a tagged enum format:
195/// - `{"type":"Reload"}` — the client should reload the page.
196/// - `{"type":"Error","message":"..."}` — a build error occurred.
197///
198/// The `__IMPORT_PATH__` placeholder is replaced with the resolved JS import path at runtime.
199pub const INDEX_HTML_DEV: &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 <script>
244 (function () {
245 async function connect() {
246 try {
247 const res = await fetch('/__euv_reload');
248 const data = await res.json();
249 if (data.type === 'Reload') {
250 location.reload();
251 } else if (data.type === 'Error') {
252 console.error('[euv] build error:', data.message);
253 setTimeout(connect, 1000);
254 } else {
255 setTimeout(connect, 1000);
256 }
257 } catch (_) {
258 setTimeout(connect, 2000);
259 }
260 }
261 connect();
262 })();
263 </script>
264</html>
265"#;
266
267/// The `index.html` template for the release profile.
268///
269/// A minimal `index.html` without any live-reload instrumentation.
270/// Used when building for release to produce a clean, static entry point.
271/// The `__IMPORT_PATH__` placeholder is replaced with the resolved JS import path at runtime.
272pub const INDEX_HTML_RELEASE: &str = r#"<!doctype html>
273<html lang="en">
274 <head>
275 <meta charset="utf-8" />
276 <meta
277 name="viewport"
278 content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, interactive-widget=resizes-visual"
279 />
280 <meta name="mobile-web-app-capable" content="yes" />
281 <meta name="apple-mobile-web-app-capable" content="yes" />
282 <meta
283 name="description"
284 content="A declarative, cross-platform UI framework for Rust with virtual DOM, reactive signals, and HTML macros for WebAssembly."
285 />
286 <meta
287 name="keywords"
288 content="rust, webassembly, wasm, ui-framework, virtual-dom, reactive, declarative-ui, euv"
289 />
290 <meta property="og:title" content="euv" />
291 <meta
292 property="og:description"
293 content="A declarative, cross-platform UI framework for Rust with virtual DOM, reactive signals, and HTML macros for WebAssembly."
294 />
295 <meta property="og:type" content="website" />
296 <title>Euv</title>
297 <style>
298 * {
299 -webkit-font-smoothing: antialiased;
300 -moz-osx-font-smoothing: grayscale;
301 text-rendering: optimizeLegibility;
302 }
303 canvas {
304 image-rendering: auto;
305 }
306 </style>
307 </head>
308 <body>
309 <div id="app"></div>
310 </body>
311 <script type="module">
312 import init, { main } from '__IMPORT_PATH__';
313 await init();
314 main();
315 </script>
316</html>
317"#;