Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix examples broken on wasm, make bevy dependency optional #22

Merged
merged 1 commit into from
Mar 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ repository = "https://github.com/johanhelsing/bevy_pkv"
[dependencies]
thiserror = "1.0"
serde = "1.0"
bevy_ecs = "0.10" # we need for deriving Resource in PkvStore
bevy_ecs = { version = "0.10", optional = true } # we need for deriving Resource in PkvStore

[features]
default = ["bevy"]
bevy = []
bevy = ["dep:bevy_ecs"]

[target.'cfg(target_arch = "wasm32")'.dependencies]
web-sys = { version = "0.3", default-features = false, features = ["Storage", "Window"] }
Expand All @@ -29,12 +29,7 @@ rmp-serde = "1.1"
directories = "4.0"

[dev-dependencies]
bevy = { version = "0.10", default-features = false, features = [
"bevy_render", # for Color
"bevy_winit", # without this, basic example will terminate immediately
# "wayland" # wayland is the future for linux (and has less deps => faster ci)
"x11", # ... but github actions public runners don't have libxkbcommon :(
] }
bevy = { version = "0.10", default-features = false }

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
console_error_panic_hook = "0.1"
Expand Down
5 changes: 3 additions & 2 deletions examples/basic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{log::LogPlugin, prelude::*};
use bevy_pkv::PkvStore;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -38,7 +38,8 @@ fn main() {

App::new()
.insert_resource(PkvStore::new("BevyPkv", "BasicExample"))
.add_plugins(DefaultPlugins)
.add_plugins(MinimalPlugins)
.add_plugin(LogPlugin::default())
.add_startup_system(setup)
.run();
}
9 changes: 5 additions & 4 deletions examples/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
//!
//! And it's also a test to show that aliases do work

use bevy::prelude::*;
use bevy::{log::LogPlugin, prelude::*};
use bevy_pkv::PkvStore;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
struct UserV1 {
nick: String,
favorite_color: Color,
favorite_color: String,
}

#[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -45,7 +45,7 @@ fn setup(mut pkv: ResMut<PkvStore>) {
// Let's pretend someone has registered with the UserV1 definition
let user_v1 = UserV1 {
nick: "old bob".to_string(),
favorite_color: Color::BEIGE,
favorite_color: "beige".to_string(),
};
pkv.set("user", &user_v1)
.expect("failed to store User struct");
Expand All @@ -64,7 +64,8 @@ fn main() {

App::new()
.insert_resource(PkvStore::new("BevyPkv", "MigrationExample"))
.add_plugins(DefaultPlugins)
.add_plugins(MinimalPlugins)
.add_plugin(LogPlugin::default())
.add_startup_system(setup)
.run();
}