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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
/// 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__";
/// 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 subdirectory of `pkg/` that holds wasm-bindgen `inline_js` snippets.
pub const SNIPPETS_DIR_NAME: &str = "snippets";
/// The name of the gitignore file.
pub const GITIGNORE_FILE_NAME: &str = ".gitignore";
/// The glob suffix that matches wasm-bindgen snippet files (`inline0.js`,
/// `inline1.js`, etc. — one per `#[wasm_bindgen(inline_js = ...)]` block).
pub const SNIPPET_FILE_PREFIX: &str = "inline";
/// 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";
/// ASCII byte slice for the HTML comment close delimiter (`-->`).
///
/// Used by the inline HTML minifier to detect end-of-comment while
/// scanning an HTML template byte stream.
pub const HTML_COMMENT_CLOSE_BYTES: & = b"-->";
/// ASCII byte slice for the HTML comment open delimiter (`<!--`).
///
/// Used by the inline HTML minifier to detect start-of-comment while
/// scanning an HTML template byte stream.
pub const HTML_COMMENT_OPEN_BYTES: & = b"<!--";
/// The HTML greater-than tag delimiter (`>`) as a single ASCII byte.
///
/// Used by the inline HTML minifier to detect the end of an opening tag
/// and trigger tag-gap whitespace stripping.
pub const HTML_GT: u8 = b'>';
/// The HTML less-than tag delimiter (`<`) as a single ASCII byte.
///
/// Used by the inline HTML minifier to detect the start of a tag and
/// enter tag-internal whitespace collapsing.
pub const HTML_LT: u8 = b'<';
/// ASCII byte slice for the closing `</script` tag without the trailing
/// `>` or whitespace.
///
/// Used by the inline HTML minifier to detect the end of an inline-JS
/// preserve region inside the HTML template.
pub const HTML_SCRIPT_CLOSE_PREFIX_BYTES: & = b"</script";
/// ASCII byte slice for the opening `<script` tag without the trailing
/// `>` or whitespace.
///
/// Used by the inline HTML minifier to detect the start of an inline-JS
/// preserve region inside the HTML template.
pub const HTML_SCRIPT_OPEN_PREFIX_BYTES: & = b"<script";
/// The HTML forward-slash character as a single ASCII byte.
///
/// Used by the inline HTML minifier to detect closing tags (e.g.
/// `</style>`) and self-closing tags (`<br/>`) while scanning the
/// template byte stream.
pub const HTML_SLASH: u8 = b'/';
/// The ASCII space byte used as the canonical collapsed-whitespace output
/// by the inline HTML minifier.
///
/// Whenever a run of whitespace characters collapses to a single space,
/// this byte is written to the output buffer.
pub const HTML_SPACE: u8 = b' ';
/// ASCII byte slice for the closing `</style` tag without the trailing
/// `>` or whitespace.
///
/// Used by the inline HTML minifier to detect the end of an inline-CSS
/// preserve region inside the HTML template.
pub const HTML_STYLE_CLOSE_PREFIX_BYTES: & = b"</style";
/// ASCII byte slice for the opening `<style` tag without the trailing
/// `>` or whitespace.
///
/// Used by the inline HTML minifier to detect the start of an inline-CSS
/// preserve region inside the HTML template.
pub const HTML_STYLE_OPEN_PREFIX_BYTES: & = b"<style";
/// 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 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 type="module">
import init, { main } from '__IMPORT_PATH__';
await init();
main();
</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 type="module">
import init, { main } from '__IMPORT_PATH__';
await init();
main();
</script>
</html>
"#;