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, viewport-fit=cover, 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="apple-mobile-web-app-status-bar-style"
138      content="black-translucent"
139    />
140    <meta
141      name="description"
142      content="A declarative, cross-platform UI framework for Rust with virtual DOM, reactive signals, and HTML macros for WebAssembly."
143    />
144    <meta
145      name="keywords"
146      content="rust, webassembly, wasm, ui-framework, virtual-dom, reactive, declarative-ui, euv"
147    />
148    <meta property="og:title" content="euv" />
149    <meta
150      property="og:description"
151      content="A declarative, cross-platform UI framework for Rust with virtual DOM, reactive signals, and HTML macros for WebAssembly."
152    />
153    <meta property="og:type" content="website" />
154    <title>Euv</title>
155    <style>
156      * {
157        -webkit-font-smoothing: antialiased;
158        -moz-osx-font-smoothing: grayscale;
159        text-rendering: optimizeLegibility;
160      }
161      canvas {
162        image-rendering: auto;
163      }
164    </style>
165  </head>
166  <body>
167    <div id="app"></div>
168  </body>
169  <script type="module">
170    import init, { main } from '__IMPORT_PATH__';
171    await init();
172    main();
173  </script>
174  <script>
175    (function () {
176      async function connect() {
177        try {
178          const res = await fetch('/__euv_reload');
179          const data = await res.json();
180          if (data.type === 'Reload') {
181            location.reload();
182          } else if (data.type === 'Error') {
183            console.error('[euv] build error:', data.message);
184            setTimeout(connect, 1000);
185          } else {
186            setTimeout(connect, 1000);
187          }
188        } catch (_) {
189          setTimeout(connect, 2000);
190        }
191      }
192      connect();
193    })();
194  </script>
195</html>
196"#;
197
198/// The `index.html` template for the release profile.
199///
200/// A minimal `index.html` without any live-reload instrumentation.
201/// Used when building for release to produce a clean, static entry point.
202/// The `__IMPORT_PATH__` placeholder is replaced with the resolved JS import path at runtime.
203pub const INDEX_HTML_RELEASE: &str = r#"<!doctype html>
204<html lang="en">
205  <head>
206    <meta charset="utf-8" />
207    <meta
208      name="viewport"
209      content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover, interactive-widget=resizes-visual"
210    />
211    <meta name="mobile-web-app-capable" content="yes" />
212    <meta name="apple-mobile-web-app-capable" content="yes" />
213    <meta
214      name="apple-mobile-web-app-status-bar-style"
215      content="black-translucent"
216    />
217    <meta
218      name="description"
219      content="A declarative, cross-platform UI framework for Rust with virtual DOM, reactive signals, and HTML macros for WebAssembly."
220    />
221    <meta
222      name="keywords"
223      content="rust, webassembly, wasm, ui-framework, virtual-dom, reactive, declarative-ui, euv"
224    />
225    <meta property="og:title" content="euv" />
226    <meta
227      property="og:description"
228      content="A declarative, cross-platform UI framework for Rust with virtual DOM, reactive signals, and HTML macros for WebAssembly."
229    />
230    <meta property="og:type" content="website" />
231    <title>Euv</title>
232    <style>
233      * {
234        -webkit-font-smoothing: antialiased;
235        -moz-osx-font-smoothing: grayscale;
236        text-rendering: optimizeLegibility;
237      }
238      canvas {
239        image-rendering: auto;
240      }
241    </style>
242  </head>
243  <body>
244    <div id="app"></div>
245  </body>
246  <script type="module">
247    import init, { main } from '__IMPORT_PATH__';
248    await init();
249    main();
250  </script>
251</html>
252"#;