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
/// 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 `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: &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: &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>
"#;