waasm compilatiion lib setup

This commit is contained in:
dongho
2024-09-01 17:01:51 +09:00
parent efbcdea403
commit 5cadfc22da
10 changed files with 1237 additions and 11 deletions

BIN
.index.html.swp Normal file

Binary file not shown.

12
Cargo.lock generated
View File

@ -123,6 +123,16 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "console_log"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be8aed40e4edbf4d3b4431ab260b63fdc40f5780a4766824329ea0f1eefe3c0f"
dependencies = [
"log",
"web-sys",
]
[[package]]
name = "crc32fast"
version = "1.4.2"
@ -167,7 +177,9 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
name = "ekstrahMap"
version = "0.1.0"
dependencies = [
"console_log",
"osmpbf",
"wasm-bindgen",
"yew",
]

View File

@ -4,5 +4,10 @@ version = "0.1.0"
edition = "2021"
[dependencies]
console_log = "1.0.0"
osmpbf = "0.3.4"
wasm-bindgen = "0.2.93"
yew = { git = "https://github.com/yewstack/yew/", features = ["csr"] }
[lib]
crate-type = ["cdylib", "rlib"]

4
Trunk.toml Normal file
View File

@ -0,0 +1,4 @@
[serve]
address = "0.0.0.0"
port = 8080

View File

@ -1,17 +1,13 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Demo</title>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix-min.js"
integrity="sha512-zhHQR0/H5SEBL3Wn6yYSaTTZej12z0hVZKOv3TwCUXT1z5qeqGcXJLLrbERYRScEDDpYIJhPC1fk31gqR783iQ=="
crossorigin="anonymous"
defer></script>
<script src="webgl-demo.js" type="module"></script>
<meta charset="utf-8" />
<title>Yew App</title>
</head>
<body>
<canvas id="glcanvas" width="640" height="480"></canvas>
<script type="module">
import init from "yew-wasm/pkg/yew-wasm.js";
init();
</script>
</body>
</html>

17
index2.html Normal file
View File

@ -0,0 +1,17 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Demo</title>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix-min.js"
integrity="sha512-zhHQR0/H5SEBL3Wn6yYSaTTZej12z0hVZKOv3TwCUXT1z5qeqGcXJLLrbERYRScEDDpYIJhPC1fk31gqR783iQ=="
crossorigin="anonymous"
defer></script>
<script src="webgl-demo.js" type="module"></script>
</head>
<body>
<canvas id="glcanvas" width="640" height="480"></canvas>
</body>
</html>

View File

@ -25,7 +25,7 @@ fn App() -> Html {
}
fn main() {
yew::Render::<App>::new().render();
yew::Renderer::<App>::new().render();
}
/*

1173
yew-wasm/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

13
yew-wasm/Cargo.toml Normal file
View File

@ -0,0 +1,13 @@
[package]
name = "yew-wasm"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["cdylib"]
[dependencies]
console_error_panic_hook = "0.1.7"
console_log = "1.0.0"
wasm-bindgen = "0.2.93"
yew = { git = "https://github.com/yewstack/yew/", features = ["csr"] }

6
yew-wasm/src/lib.rs Normal file
View File

@ -0,0 +1,6 @@
use wasm_bindgen::prelude::*;
#[wasm_bindgen(start)]
fn start() {
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
}