Skip to content

Commit

Permalink
examples use published crates
Browse files Browse the repository at this point in the history
  • Loading branch information
StuartHarris committed Jul 26, 2024
1 parent 673f01a commit ce12b19
Show file tree
Hide file tree
Showing 19 changed files with 84 additions and 45 deletions.
1 change: 0 additions & 1 deletion examples/bridge_echo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ rust-version = "1.66"
[workspace.dependencies]
anyhow = "1.0.86"
crux_core = "0.8"
# crux_core = { path = "../../crux_core" }
serde = "1.0.203"

[workspace.metadata.bin]
Expand Down
22 changes: 16 additions & 6 deletions examples/cat_facts/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 5 additions & 10 deletions examples/cat_facts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,11 @@ rust-version = "1.66"

[workspace.dependencies]
anyhow = "1.0.86"
# crux_core = "0.8"
# crux_http = "0.9"
# crux_kv = "0.4"
# crux_platform = "0.1"
# crux_time = { version = "0.4", features = ["chrono"] }
crux_core = { path = "../../crux_core" }
crux_http = { path = "../../crux_http" }
crux_kv = { path = "../../crux_kv" }
crux_platform = { path = "../../crux_platform" }
crux_time = { path = "../../crux_time", features = ["chrono"] }
crux_core = "0.8"
crux_http = "0.9"
crux_kv = "0.4"
crux_platform = "0.1"
crux_time = { version = "0.4", features = ["chrono"] }
serde = "1.0.203"

[workspace.metadata.bin]
Expand Down
2 changes: 1 addition & 1 deletion examples/cat_facts/shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ crate-type = ["lib", "staticlib", "cdylib"]
name = "shared"

[features]
typegen = ["crux_core/typegen", "crux_http/typegen", "crux_kv/typegen"]
typegen = ["crux_core/typegen"]

[dependencies]
chrono = { version = "0.4.38", features = ["serde"] }
Expand Down
3 changes: 1 addition & 2 deletions examples/cat_facts/shared/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ pub mod platform;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

use crux_core::render::Render;
pub use crux_core::App;
use crux_core::Capability;
use crux_core::{render::Render, Capability};
use crux_http::Http;
use crux_kv::{error::KeyValueError, KeyValue};
use crux_platform::Platform;
Expand Down
16 changes: 15 additions & 1 deletion examples/cat_facts/shared_types/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ use std::path::PathBuf;

use crux_core::typegen::TypeGen;

use shared::CatFacts;
use shared::{
http::HttpError,
key_value::{error::KeyValueError, value::Value, KeyValueResponse},
CatFacts,
};

fn main() -> anyhow::Result<()> {
println!("cargo:rerun-if-changed=../shared");
Expand All @@ -11,6 +15,16 @@ fn main() -> anyhow::Result<()> {

gen.register_app::<CatFacts>()?;

// types from `crux_http` that aren't automatically discovered
// NOTE: in the next version of `crux_http`, these will be automatically registered
gen.register_type::<HttpError>()?;

// types from `crux_kv` that aren't automatically discovered
// NOTE: in the next version of `crux_kv`, these will be automatically registered
gen.register_type::<KeyValueResponse>()?;
gen.register_type::<KeyValueError>()?;
gen.register_type::<Value>()?;

let output_root = PathBuf::from("./generated");

gen.swift("SharedTypes", output_root.join("swift"))?;
Expand Down
16 changes: 10 additions & 6 deletions examples/counter/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions examples/counter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ rust-version = "1.66"

[workspace.dependencies]
anyhow = "1.0.86"
# crux_core = "0.8"
# crux_http = "0.9"
crux_core = { path = "../../crux_core" }
crux_http = { path = "../../crux_http" }
crux_core = "0.8"
crux_http = "0.9"
serde = "1.0.203"

[workspace.metadata.bin]
Expand Down
2 changes: 1 addition & 1 deletion examples/counter/shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ crate-type = ["lib", "staticlib", "cdylib"]
name = "shared"

[features]
typegen = ["crux_core/typegen", "crux_http/typegen"]
typegen = ["crux_core/typegen"]

[dependencies]
async-sse = "5.1.0"
Expand Down
6 changes: 5 additions & 1 deletion examples/counter/shared_types/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crux_core::typegen::TypeGen;
use shared::App;
use shared::{http::HttpError, App};
use std::path::PathBuf;

fn main() -> anyhow::Result<()> {
Expand All @@ -9,6 +9,10 @@ fn main() -> anyhow::Result<()> {

gen.register_app::<App>()?;

// Register the HttpError type
// NOTE: in the next version of crux_http, this will be done automatically
gen.register_type::<HttpError>()?;

let output_root = PathBuf::from("./generated");

gen.swift("SharedTypes", output_root.join("swift"))?;
Expand Down
6 changes: 6 additions & 0 deletions examples/counter/tauri/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@ tauri = { version = "1.6", features = ["shell-open"] }
# this feature is used for production builds or when `devPath` points to the filesystem
# DO NOT REMOVE!!
custom-protocol = ["tauri/custom-protocol"]

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(mobile)',
'cfg(desktop)',
] }
1 change: 0 additions & 1 deletion examples/hello_world/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ rust-version = "1.66"
[workspace.dependencies]
anyhow = "1.0.86"
crux_core = "0.8"
# crux_core = { path = "../../crux_core" }
serde = "1.0.203"

[workspace.metadata.bin]
Expand Down
15 changes: 11 additions & 4 deletions examples/notes/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions examples/notes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ rust-version = "1.66"

[workspace.dependencies]
anyhow = "1.0"
# crux_core = "0.8"
# crux_kv = "0.4"
crux_core = { path = "../../crux_core" }
crux_kv = { path = "../../crux_kv" }
crux_core = "0.8"
crux_kv = "0.4"
serde = "1.0"

[workspace.metadata.bin]
Expand Down
2 changes: 1 addition & 1 deletion examples/notes/shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ edition.workspace = true
rust-version.workspace = true

[features]
typegen = ["crux_core/typegen", "crux_kv/typegen"]
typegen = ["crux_core/typegen"]

[lib]
crate-type = ["lib", "staticlib", "cdylib"]
Expand Down
1 change: 1 addition & 0 deletions examples/notes/shared_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ rust-version.workspace = true
[build-dependencies]
anyhow.workspace = true
crux_core = { workspace = true, features = ["typegen"] }
crux_kv = { workspace = true }
shared = { path = "../shared", features = ["typegen"] }
7 changes: 7 additions & 0 deletions examples/notes/shared_types/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crux_core::typegen::TypeGen;
use crux_kv::{error::KeyValueError, value::Value, KeyValueResponse};
use shared::{NoteEditor, TextCursor};
use std::path::PathBuf;

Expand All @@ -13,6 +14,12 @@ fn main() -> anyhow::Result<()> {
// https://github.com/zefchain/serde-reflection/tree/main/serde-reflection#supported-features
gen.register_type::<TextCursor>()?;

// Register types from crux_kv
// NOTE: in the next version of crux_kv, this will not be necessary
gen.register_type::<KeyValueResponse>()?;
gen.register_type::<KeyValueError>()?;
gen.register_type::<Value>()?;

let output_root = PathBuf::from("./generated");

gen.swift("SharedTypes", output_root.join("swift"))?;
Expand Down
Loading

0 comments on commit ce12b19

Please sign in to comment.