mirror of
https://github.com/MercuryWorkshop/epoxy-tls.git
synced 2025-05-13 06:20:02 -04:00
various small changes, allow bundling the wasm in the js file
This commit is contained in:
parent
d50e6b6bec
commit
718b285907
5 changed files with 13 additions and 11 deletions
|
@ -9,5 +9,5 @@
|
|||
|
||||
### Client
|
||||
|
||||
1. Make sure you have the `wasm32-unknown-unknown` target installed, `wasm-bindgen` executable installed (and optionally `wasm-opt`), and `bash`, `python3` packages (`python3` is used for `http.server` module)
|
||||
2. Run `bash build.sh` to build without wasm-opt and start a webserver, add any argument to call wasm-opt
|
||||
1. Make sure you have the `wasm32-unknown-unknown` target installed, `wasm-bindgen` and `wasm-opt` executables installed, and `bash`, `python3` packages (`python3` is used for `http.server` module)
|
||||
2. Run `bash build.sh` to build without wasm-opt and start a webserver
|
||||
|
|
|
@ -4,11 +4,16 @@ shopt -s inherit_errexit
|
|||
|
||||
rm -rf out/ || true
|
||||
mkdir out/
|
||||
|
||||
cargo build --target wasm32-unknown-unknown --release
|
||||
wasm-bindgen --weak-refs --no-typescript --target no-modules --out-dir out/ ../target/wasm32-unknown-unknown/release/wstcp_client.wasm
|
||||
if [[ "$#" > 0 ]]; then
|
||||
|
||||
mv out/wstcp_client_bg.wasm out/wstcp_client_unoptimized.wasm
|
||||
wasm-opt -O4 out/wstcp_client_unoptimized.wasm -o out/wstcp_client_bg.wasm
|
||||
fi
|
||||
|
||||
AUTOGENERATED_SOURCE=$(<"out/wstcp_client.js")
|
||||
WASM_BASE64=$(base64 -w0 out/wstcp_client_bg.wasm)
|
||||
echo "${AUTOGENERATED_SOURCE//__wbg_init(input) \{/__wbg_init(input) \{input=\'data:application/wasm;base64,$WASM_BASE64\'}" > out/wstcp_client_bundled.js
|
||||
|
||||
cp -r src/web/* out/
|
||||
(cd out; python3 -m http.server)
|
||||
|
|
|
@ -82,7 +82,6 @@ async fn send_req(req: http::Request<HttpBody>, should_redirect: bool, io: WsTcp
|
|||
}
|
||||
let new_url = redirect_url.clone();
|
||||
*new_req.uri_mut() = redirect_url;
|
||||
new_req.headers_mut().remove("Host");
|
||||
new_req.headers_mut().insert(
|
||||
"Host",
|
||||
HeaderValue::from_str(redirect_url_authority.as_str())?,
|
||||
|
|
|
@ -5,5 +5,6 @@
|
|||
<script src="index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
running... (wait for the browser alert)
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -28,8 +28,6 @@
|
|||
console.warn(url, resp, Object.fromEntries(resp.headers));
|
||||
console.warn(await resp.text());
|
||||
}
|
||||
|
||||
alert("you can open console now");
|
||||
} else if (should_perf_test) {
|
||||
const test_mux = async (url) => {
|
||||
const t0 = performance.now();
|
||||
|
@ -62,11 +60,10 @@
|
|||
console.warn(`avg mux (10) took ${total_mux} ms or ${total_mux / 1000} s`);
|
||||
console.warn(`avg native (10) took ${total_native} ms or ${total_native / 1000} s`);
|
||||
console.warn(`mux - native: ${total_mux - total_native} ms or ${(total_mux - total_native) / 1000} s`);
|
||||
|
||||
alert("you can open console now");
|
||||
} else {
|
||||
let resp = await wstcp.fetch("https://httpbin.org/get");
|
||||
console.warn(resp, Object.fromEntries(resp.headers));
|
||||
console.warn(await resp.text());
|
||||
}
|
||||
alert("you can open console now");
|
||||
})();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue