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
/// 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 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 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 `__OUT_NAME__` placeholder is replaced with the actual output name at runtime.
pub const INDEX_HTML_DEV: &str = r#"<!doctype html>
<html>
<head>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<title>euv</title>
</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('__RELOAD_ROUTE__');
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 (e) {
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 `__OUT_NAME__` placeholder is replaced with the actual output name at runtime.
pub const INDEX_HTML_RELEASE: &str = r#"<!doctype html>
<html>
<head>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<title>euv</title>
</head>
<body>
<div id="app"></div>
</body>
<script type="module">
import init, { main } from '__IMPORT_PATH__';
await init();
main();
</script>
</html>
"#;