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 wasm-pack flag for development builds.
62pub const DEV_FLAG: &str = "--dev";
63
64/// The wasm-pack flag for profiling builds.
65pub const PROFILING_FLAG: &str = "--profiling";
66
67/// The euv-specific argument for specifying the crate path.
68pub const CRATE_PATH_ARG: &str = "--crate-path";
69
70/// The short form of the crate-path argument.
71pub const CRATE_PATH_ARG_SHORT: &str = "-c";
72
73/// The euv-specific argument for specifying the server port.
74pub const PORT_ARG: &str = "--port";
75
76/// The short form of the port argument.
77pub const PORT_ARG_SHORT: &str = "-p";
78
79/// The euv-specific argument for specifying the www directory.
80pub const WWW_DIR_ARG: &str = "--www-dir";
81
82/// The euv-specific argument for specifying a custom index.html template.
83pub const INDEX_HTML_ARG: &str = "--index-html";
84
85/// The euv-specific argument for removing the .gitignore file from the output directory.
86pub const NO_GITIGNORE_ARG: &str = "--no-gitignore";
87
88/// The euv-specific argument names that should not be forwarded to wasm-pack.
89pub const EUV_ARGS: &[&str] = &[
90    CRATE_PATH_ARG,
91    CRATE_PATH_ARG_SHORT,
92    PORT_ARG,
93    PORT_ARG_SHORT,
94    WWW_DIR_ARG,
95    INDEX_HTML_ARG,
96    NO_GITIGNORE_ARG,
97];
98
99/// The double-dash separator used to distinguish euv args from wasm-pack args.
100pub const DOUBLE_DASH: &str = "--";
101
102/// The `run` action name used in banner display.
103pub const ACTION_RUN: &str = "run";
104
105/// The `build` action name used in banner display.
106pub const ACTION_BUILD: &str = "build";
107
108/// The environment variable name for setting the minimum stack size of rustc threads.
109pub const RUST_MIN_STACK_ENV: &str = "RUST_MIN_STACK";
110
111/// The minimum stack size in bytes for rustc threads (16 MiB).
112pub const RUST_MIN_STACK_VALUE: &str = "16777216";
113
114/// The `index.html` template for the development profile.
115///
116/// Includes a live-reload `<script>` block that connects to the
117/// `/__euv_reload` endpoint and parses the JSON payload sent by the server.
118/// The JSON uses a tagged enum format:
119/// - `{"type":"Reload"}` — the client should reload the page.
120/// - `{"type":"Error","message":"..."}` — a build error occurred.
121///
122/// The `__OUT_NAME__` placeholder is replaced with the actual output name at runtime.
123pub const INDEX_HTML_DEV: &str = r#"<!doctype html>
124<html lang="en">
125  <head>
126    <meta charset="utf-8" />
127    <meta
128      name="viewport"
129      content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover, interactive-widget=resizes-visual"
130    />
131    <meta name="mobile-web-app-capable" content="yes" />
132    <meta name="apple-mobile-web-app-capable" content="yes" />
133    <meta
134      name="apple-mobile-web-app-status-bar-style"
135      content="black-translucent"
136    />
137    <meta
138      name="description"
139      content="A declarative, cross-platform UI framework for Rust with virtual DOM, reactive signals, and HTML macros for WebAssembly."
140    />
141    <meta
142      name="keywords"
143      content="rust, webassembly, wasm, ui-framework, virtual-dom, reactive, declarative-ui, euv"
144    />
145    <meta property="og:title" content="euv" />
146    <meta
147      property="og:description"
148      content="A declarative, cross-platform UI framework for Rust with virtual DOM, reactive signals, and HTML macros for WebAssembly."
149    />
150    <meta property="og:type" content="website" />
151    <title>Euv</title>
152    <style>
153      * {
154        -webkit-font-smoothing: antialiased;
155        -moz-osx-font-smoothing: grayscale;
156        text-rendering: optimizeLegibility;
157      }
158      canvas {
159        image-rendering: auto;
160      }
161    </style>
162  </head>
163  <body>
164    <div id="app"></div>
165  </body>
166  <script type="module">
167    import init, { main } from './pkg/euv.js';
168    await init();
169    main();
170  </script>
171  <script>
172    (function () {
173      async function connect() {
174        try {
175          const res = await fetch('/__euv_reload');
176          const data = await res.json();
177          if (data.type === 'Reload') {
178            location.reload();
179          } else if (data.type === 'Error') {
180            console.error('[euv] build error:', data.message);
181            setTimeout(connect, 1000);
182          } else {
183            setTimeout(connect, 1000);
184          }
185        } catch (_) {
186          setTimeout(connect, 2000);
187        }
188      }
189      connect();
190    })();
191  </script>
192</html>
193"#;
194
195/// The `index.html` template for the release profile.
196///
197/// A minimal `index.html` without any live-reload instrumentation.
198/// Used when building for release to produce a clean, static entry point.
199/// The `__OUT_NAME__` placeholder is replaced with the actual output name at runtime.
200pub const INDEX_HTML_RELEASE: &str = r#"<!doctype html>
201<html lang="en">
202  <head>
203    <meta charset="utf-8" />
204    <meta
205      name="viewport"
206      content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover, interactive-widget=resizes-visual"
207    />
208    <meta name="mobile-web-app-capable" content="yes" />
209    <meta name="apple-mobile-web-app-capable" content="yes" />
210    <meta
211      name="apple-mobile-web-app-status-bar-style"
212      content="black-translucent"
213    />
214    <meta
215      name="description"
216      content="A declarative, cross-platform UI framework for Rust with virtual DOM, reactive signals, and HTML macros for WebAssembly."
217    />
218    <meta
219      name="keywords"
220      content="rust, webassembly, wasm, ui-framework, virtual-dom, reactive, declarative-ui, euv"
221    />
222    <meta property="og:title" content="euv" />
223    <meta
224      property="og:description"
225      content="A declarative, cross-platform UI framework for Rust with virtual DOM, reactive signals, and HTML macros for WebAssembly."
226    />
227    <meta property="og:type" content="website" />
228    <title>Euv</title>
229    <style>
230      * {
231        -webkit-font-smoothing: antialiased;
232        -moz-osx-font-smoothing: grayscale;
233        text-rendering: optimizeLegibility;
234      }
235      canvas {
236        image-rendering: auto;
237      }
238    </style>
239  </head>
240  <body>
241    <div id="app"></div>
242  </body>
243  <script type="module">
244    import init, { main } from './pkg/euv.js';
245    await init();
246    main();
247  </script>
248</html>
249"#;