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
/// 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 CLI command name for hyperlane-cli.
pub const HYPERLANE_CLI_COMMAND: &str = "hyperlane-cli";
/// The version flag for CLI tools.
pub const VERSION_ARG: &str = "--version";
/// The format subcommand for hyperlane-cli.
pub const FMT_SUBCOMMAND: &str = "fmt";
/// The CLI command name for cargo.
pub const CARGO_COMMAND: &str = "cargo";
/// The install subcommand for cargo.
pub const CARGO_INSTALL_SUBCOMMAND: &str = "install";
/// 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 TypeScript declaration file extension.
pub const D_TS_EXTENSION: &str = "d.ts";
/// The npm package manifest file name.
pub const PACKAGE_JSON_FILE_NAME: &str = "package.json";
/// The npm README file name.
pub const README_FILE_NAME: &str = "README.md";
/// The npm LICENSE file name.
pub const LICENSE_FILE_NAME: &str = "LICENSE";
/// 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 `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 `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>
"#;