Skip to content
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
22 changes: 11 additions & 11 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
paths:
- packages/**
- examples/**

pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
Expand All @@ -22,22 +22,22 @@ env:
jobs:
# Rust fmt
fmt:
if: github.event.pull_request.draft == false
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: rustup component add rustfmt
- uses: actions/checkout@v3
- run: cargo fmt --all -- --check
if: github.event.pull_request.draft == false
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: dtolnay/rust-toolchain@1.90.0
- uses: Swatinem/rust-cache@v2
- run: rustup component add rustfmt
- uses: actions/checkout@v3
- run: cargo fmt --all -- --check
# Clippy
clippy:
if: github.event.pull_request.draft == false
name: Clippy
runs-on: windows-latest
steps:
- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/rust-toolchain@1.90.0
- uses: Swatinem/rust-cache@v2
- run: rustup target add wasm32-unknown-unknown
- run: rustup component add clippy
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
paths:
- packages/**
- examples/**

pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
Expand All @@ -26,17 +26,19 @@ jobs:
name: WASM
runs-on: ubuntu-latest
steps:
- uses: dtolnay/rust-toolchain@1.90.0
- uses: actions/checkout@v3
- run: rustup target add wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- run: cargo build --all-targets --workspace --exclude *-example --verbose --target wasm32-unknown-unknown --all-features
# need to run tests here

desktop:
if: github.event.pull_request.draft == false
name: Desktop
runs-on: windows-latest
steps:
- uses: dtolnay/rust-toolchain@1.90.0
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- run: cargo build --all-targets --workspace --verbose --all-features
Expand Down
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ package.repository = "https://github.com/DioxusLabs/sdk/"

[workspace.dependencies]
# Workspace
dioxus-sdk = { path = "packages/sdk", version = "0.7.0-alpha.1" }
dioxus-time = { path = "packages/time", version = "0.1.0-alpha.1" }
dioxus_storage = { path = "packages/storage", version = "0.1.0-alpha.1" }
dioxus-geolocation = { path = "packages/geolocation", version = "0.1.0-alpha.1" }
dioxus-notification = { path = "packages/notification", version = "0.1.0-alpha.1" }
dioxus-sync = { path = "packages/sync", version = "0.1.0-alpha.1" }
dioxus-util = { path = "packages/util", version = "0.1.0-alpha.1" }
dioxus-window = { path = "packages/window", version = "0.1.0-alpha.1" }
dioxus-sdk = { path = "packages/sdk", version = "0.7.0" }
dioxus-time = { path = "packages/time", version = "0.7.0" }
dioxus_storage = { path = "packages/storage", version = "0.7.0" }
dioxus-geolocation = { path = "packages/geolocation", version = "0.7.0" }
dioxus-notification = { path = "packages/notification", version = "0.7.0" }
dioxus-sync = { path = "packages/sync", version = "0.7.0" }
dioxus-util = { path = "packages/util", version = "0.7.0" }
dioxus-window = { path = "packages/window", version = "0.7.0" }

# Dioxus
dioxus = "0.7.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/geolocation/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dioxus-geolocation"
version = "0.1.0-alpha.1"
version = "0.7.0"

description = "Geolocation utilities and hooks for Dioxus."
readme = "./README.md"
Expand Down
2 changes: 2 additions & 0 deletions packages/geolocation/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ pub enum Error {
AccessDenied,
Poisoned,
DeviceError(String),
Unsupported,
}

impl std::error::Error for Error {}
Expand All @@ -104,6 +105,7 @@ impl fmt::Display for Error {
}
Error::Poisoned => write!(f, "the internal read/write lock has been poisioned"),
Error::DeviceError(e) => write!(f, "a device error has occurred: {}", e),
Error::Unsupported => write!(f, "the current platform is not supported"),
}
}
}
20 changes: 7 additions & 13 deletions packages/geolocation/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
//! Interact with location services.
#![allow(clippy::collapsible_if)]

cfg_if::cfg_if! {
if #[cfg(any(windows, target_family = "wasm"))] {
pub mod core;
pub mod platform;
pub mod use_geolocation;
pub use self::core::*;
pub use self::use_geolocation::*;
}
//! Interact with location services.

else {
compile_error!("the `geolocation` feature is only available on wasm and windows targets");
}
}
pub mod core;
pub mod platform;
pub mod use_geolocation;
pub use self::core::*;
pub use self::use_geolocation::*;
51 changes: 44 additions & 7 deletions packages/geolocation/src/platform/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,46 @@
cfg_if::cfg_if! {
if #[cfg(windows)] {
mod windows;
pub use self::windows::*;
} else if #[cfg(target_family = "wasm")] {
mod wasm;
pub use self::wasm::*;
#[cfg(windows)]
mod windows;
#[cfg(windows)]
pub use self::windows::*;

#[cfg(target_family = "wasm")]
mod wasm;
#[cfg(target_family = "wasm")]
pub use self::wasm::*;

#[cfg(not(any(target_family = "wasm", windows)))]
mod unsupported {
use std::sync::Arc;

use crate::{Error, Event, Geocoordinates};

pub struct Geolocator {}

impl Geolocator {
/// Create a new Geolocator for the device.
pub fn new() -> Result<Self, Error> {
Err(Error::Unsupported)
}
}

pub async fn get_coordinates(_geolocator: &Geolocator) -> Result<Geocoordinates, Error> {
Err(Error::Unsupported)
}

pub fn set_power_mode(
_geolocator: &mut Geolocator,
_power_mode: crate::PowerMode,
) -> Result<(), Error> {
Err(Error::Unsupported)
}

pub fn listen(
_geolocator: &Geolocator,
_callback: Arc<dyn Fn(Event) + Send + Sync>,
) -> Result<(), Error> {
Err(Error::Unsupported)
}
}

#[cfg(not(any(target_family = "wasm", windows)))]
pub use self::unsupported::*;
2 changes: 1 addition & 1 deletion packages/notification/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dioxus-notification"
version = "0.1.0-alpha.1"
version = "0.7.0"

description = "Send notifications from your Dioxus apps."
readme = "./README.md"
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dioxus-sdk"
version = "0.7.0-alpha.1"
version = "0.7.0"

description = "A platform agnostic library for supercharging your productivity with Dioxus."
readme = "../../README.md"
Expand Down Expand Up @@ -32,4 +32,4 @@ util = ["dep:dioxus-util"]
window = ["dep:dioxus-window"]

[package.metadata.docs.rs]
all-features = true
all-features = true
2 changes: 1 addition & 1 deletion packages/storage/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dioxus_storage"
version = "0.1.0-alpha.1"
version = "0.7.0"

description = "Local and persistent storage utilities for Dioxus."
readme = "./README.md"
Expand Down
8 changes: 5 additions & 3 deletions packages/storage/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::collapsible_if)]

//! Local and persistent storage.
//!
//! Handle local storage ergonomically.
Expand Down Expand Up @@ -165,7 +167,7 @@ where
T: Serialize + DeserializeOwned + Clone + Send + Sync + PartialEq + 'static,
S::Key: Clone,
{
let signal = {
{
let mode = StorageMode::current();

match mode {
Expand All @@ -180,8 +182,7 @@ where
*storage_entry.data()
}
}
};
signal
}
}

/// A hook that creates a StorageEntry with the latest value from storage or the init value if it doesn't exist.
Expand Down Expand Up @@ -355,6 +356,7 @@ where
S: StorageBacking + StorageSubscriber<S>,
T: Serialize + DeserializeOwned + Clone + Send + Sync + PartialEq + 'static,
{
#[allow(clippy::collapsible_if)]
fn save(&self) {
// We want to save in the following conditions
// - The value from the channel is different from the current value
Expand Down
4 changes: 2 additions & 2 deletions packages/sync/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dioxus-sync"
version = "0.1.0-alpha.1"
version = "0.7.0"

description = "Synchronization primitives for your Dioxus app."
readme = "./README.md"
Expand All @@ -17,7 +17,7 @@ repository.workspace = true
dioxus = { workspace = true }

uuid = { version = "1.3.2", features = ["v4"] }
async-broadcast = "0.5.1"
async-broadcast = "0.7.1"

[target.'cfg(target_family = "wasm")'.dependencies]
uuid = { version = "1.3.2", features = ["v4", "js"] }
2 changes: 2 additions & 0 deletions packages/sync/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
#![allow(clippy::collapsible_if)]

pub mod channel;
4 changes: 2 additions & 2 deletions packages/time/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dioxus-time"
version = "0.1.0-alpha.1"
version = "0.7.0"

description = "Timing utilities and hooks for Dioxus."
readme = "./README.md"
Expand All @@ -21,4 +21,4 @@ futures = { workspace = true }
tokio = { workspace = true, features = ["time"]}

[target.'cfg(target_family = "wasm")'.dependencies]
gloo-timers = { version = "0.3.0", features = ["futures"] }
gloo-timers = { version = "0.3.0", features = ["futures"] }
2 changes: 1 addition & 1 deletion packages/util/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dioxus-util"
version = "0.1.0-alpha.1"
version = "0.7.0"

description = "General utilities for Dioxus apps."
readme = "./README.md"
Expand Down
2 changes: 1 addition & 1 deletion packages/window/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dioxus-window"
version = "0.1.0-alpha.1"
version = "0.7.0"

description = "Window utilities and hooks for Dioxus."
readme = "./README.md"
Expand Down
Loading