-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Support WASI target. * fix: More friendly error message for wasi target. * fix: Use target_os instead of feature. * feat: Add an example for gloo-history on WASI. * fix: Avoid to use web-sys when target os is WASI. * fix: Exclude WASI example to avoid web-sys. * ci: Use static download instead of install bash. * ci: Use CLI's flag instead of exclude example. bytecodealliance/wasmtime#4312
- Loading branch information
Showing
10 changed files
with
139 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#![cfg(not(target_os = "wasi"))] | ||
|
||
use std::any::Any; | ||
use std::collections::HashMap; | ||
use std::rc::Rc; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "example-history-wasi" | ||
version = "0.1.0" | ||
authors = ["Rust and WebAssembly Working Group"] | ||
edition = "2021" | ||
publish = false | ||
rust-version = "1.64" | ||
|
||
[dependencies] | ||
gloo = { path = "../..", default-features = false, features = ["history"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# History example on WASI | ||
|
||
This is a simple example showcasing the Gloo History on WASI. | ||
|
||
You can run this example with: | ||
|
||
```bash | ||
cargo build --manifest-path examples/history-wasi/Cargo.toml --target wasm32-wasi | ||
wasmtime examples/history-wasi/target/wasm32-wasi/debug/example-history-wasi.wasm | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use gloo::history::{History, MemoryHistory}; | ||
|
||
fn main() { | ||
let history = MemoryHistory::new(); | ||
println!("Current path: {}", history.location().path()); | ||
assert_eq!(history.location().path(), "/"); | ||
|
||
history.push("/home"); | ||
println!("Current path: {}", history.location().path()); | ||
assert_eq!(history.location().path(), "/home"); | ||
|
||
history.push("/about"); | ||
println!("Current path: {}", history.location().path()); | ||
assert_eq!(history.location().path(), "/about"); | ||
|
||
history.push("/contact"); | ||
println!("Current path: {}", history.location().path()); | ||
assert_eq!(history.location().path(), "/contact"); | ||
|
||
history.go(-2); | ||
println!("Current path: {}", history.location().path()); | ||
assert_eq!(history.location().path(), "/home"); | ||
} |