Merge pull request #2076 from Nisatru/run-web
Get web examples running again
This commit is contained in:
commit
a3489e4af9
8 changed files with 43 additions and 3 deletions
|
|
@ -7,3 +7,7 @@ publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
iced.workspace = true
|
iced.workspace = true
|
||||||
|
|
||||||
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
|
iced.workspace = true
|
||||||
|
iced.features = ["webgl"]
|
||||||
|
|
|
||||||
|
|
@ -13,4 +13,12 @@ You can run it with `cargo run`:
|
||||||
cargo run --package counter
|
cargo run --package counter
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The web version can be run with [`trunk`]:
|
||||||
|
|
||||||
|
```
|
||||||
|
cd examples/counter
|
||||||
|
trunk serve
|
||||||
|
```
|
||||||
|
|
||||||
[`main`]: src/main.rs
|
[`main`]: src/main.rs
|
||||||
|
[`trunk`]: https://trunkrs.dev/
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,14 @@ iced_winit.workspace = true
|
||||||
iced_wgpu.workspace = true
|
iced_wgpu.workspace = true
|
||||||
iced_widget.workspace = true
|
iced_widget.workspace = true
|
||||||
|
|
||||||
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
tracing-subscriber = "0.3"
|
tracing-subscriber = "0.3"
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
|
iced_wgpu.workspace = true
|
||||||
|
iced_wgpu.features = ["webgl"]
|
||||||
|
|
||||||
console_error_panic_hook = "0.1"
|
console_error_panic_hook = "0.1"
|
||||||
console_log = "1.0"
|
console_log = "1.0"
|
||||||
log.workspace = true
|
|
||||||
wasm-bindgen = "0.2"
|
wasm-bindgen = "0.2"
|
||||||
web-sys = { version = "0.3", features = ["Element", "HtmlCanvasElement", "Window", "Document"] }
|
web-sys = { version = "0.3", features = ["Element", "HtmlCanvasElement", "Window", "Document"] }
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ use winit::platform::web::WindowBuilderExtWebSys;
|
||||||
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
let canvas_element = {
|
let canvas_element = {
|
||||||
console_log::init_with_level(log::Level::Debug)?;
|
console_log::init().expect("Initialize logger");
|
||||||
|
|
||||||
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
|
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,9 @@ async-std.workspace = true
|
||||||
directories-next = "2.0"
|
directories-next = "2.0"
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
|
iced.workspace = true
|
||||||
|
iced.features = ["debug", "webgl"]
|
||||||
|
|
||||||
web-sys = { workspace = true, features = ["Window", "Storage"] }
|
web-sys = { workspace = true, features = ["Window", "Storage"] }
|
||||||
wasm-timer.workspace = true
|
wasm-timer.workspace = true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,14 @@ You can run the native version with `cargo run`:
|
||||||
```
|
```
|
||||||
cargo run --package todos
|
cargo run --package todos
|
||||||
```
|
```
|
||||||
We have not yet implemented a `LocalStorage` version of the auto-save feature. Therefore, it does not work on web _yet_!
|
|
||||||
|
The web version can be run with [`trunk`]:
|
||||||
|
|
||||||
|
```
|
||||||
|
cd examples/todos
|
||||||
|
trunk serve
|
||||||
|
```
|
||||||
|
|
||||||
[`main`]: src/main.rs
|
[`main`]: src/main.rs
|
||||||
[TodoMVC]: http://todomvc.com/
|
[TodoMVC]: http://todomvc.com/
|
||||||
|
[`trunk`]: https://trunkrs.dev/
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,12 @@ publish = false
|
||||||
iced.workspace = true
|
iced.workspace = true
|
||||||
iced.features = ["image", "debug"]
|
iced.features = ["image", "debug"]
|
||||||
|
|
||||||
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
tracing-subscriber = "0.3"
|
tracing-subscriber = "0.3"
|
||||||
|
|
||||||
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
|
iced.workspace = true
|
||||||
|
iced.features = ["image", "debug", "webgl"]
|
||||||
|
|
||||||
|
console_error_panic_hook = "0.1"
|
||||||
|
console_log = "1.0"
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,13 @@ use iced::widget::{Button, Column, Container, Slider};
|
||||||
use iced::{Color, Element, Font, Length, Renderer, Sandbox, Settings};
|
use iced::{Color, Element, Font, Length, Renderer, Sandbox, Settings};
|
||||||
|
|
||||||
pub fn main() -> iced::Result {
|
pub fn main() -> iced::Result {
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
{
|
||||||
|
console_log::init().expect("Initialize logger");
|
||||||
|
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
tracing_subscriber::fmt::init();
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
Tour::run(Settings::default())
|
Tour::run(Settings::default())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue