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