Make tour example work on Wasm again

This commit is contained in:
Héctor Ramón Jiménez 2019-10-23 02:34:11 +02:00
parent c7ef9d0da7
commit 6145140816
3 changed files with 23 additions and 6 deletions

View file

@ -32,3 +32,6 @@ iced_web = { version = "0.1.0-alpha", path = "web" }
[dev-dependencies] [dev-dependencies]
env_logger = "0.7" env_logger = "0.7"
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen = "0.2.51"

View file

@ -6,8 +6,9 @@
</head> </head>
<body> <body>
<script type="module"> <script type="module">
import init from "./pkg/iced_tour.js"; import init from "./tour/tour.js";
init("./pkg/iced_tour_bg.wasm");
init('./tour/tour_bg.wasm');
</script> </script>
</body> </body>
</html> </html>

View file

@ -308,7 +308,7 @@ impl<'a> Step {
that can be easily implemented on top of Iced.", that can be easily implemented on top of Iced.",
)) ))
.push(Text::new( .push(Text::new(
"Iced is a renderer-agnostic GUI library for Rust focused on \ "Iced is a cross-platform GUI library for Rust focused on \
simplicity and type-safety. It is heavily inspired by Elm.", simplicity and type-safety. It is heavily inspired by Elm.",
)) ))
.push(Text::new( .push(Text::new(
@ -316,9 +316,9 @@ impl<'a> Step {
2D game engine for Rust.", 2D game engine for Rust.",
)) ))
.push(Text::new( .push(Text::new(
"Iced does not provide a built-in renderer. On native \ "On native platforms, Iced provides by default a renderer \
platforms, this example runs on a fairly simple renderer \ built on top of wgpu, a graphics library supporting Vulkan, \
built on top of ggez, another game library.", Metal, DX11, and DX12.",
)) ))
.push(Text::new( .push(Text::new(
"Additionally, this tour can also run on WebAssembly thanks \ "Additionally, this tour can also run on WebAssembly thanks \
@ -634,3 +634,16 @@ pub enum Layout {
Row, Row,
Column, Column,
} }
// This should be gracefully handled by Iced in the future. Probably using our
// own proc macro, or maybe the whole process is streamlined by `wasm-pack` at
// some point.
#[cfg(target_arch = "wasm32")]
mod wasm {
use wasm_bindgen::prelude::*;
#[wasm_bindgen(start)]
pub fn run() {
super::main()
}
}