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

SDK Reorganization, Async Callbacks, More Docs #73

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ on:
branches:
- main
paths:
- sdk/**
- packages/**
- examples/**

pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- main
paths:
- sdk/**
- packages/**
- examples/**

env:
Expand Down Expand Up @@ -42,5 +42,5 @@ jobs:
- run: rustup target add wasm32-unknown-unknown
- run: rustup component add clippy
- uses: actions/checkout@v3
- run: cargo clippy --package dioxus-sdk --target wasm32-unknown-unknown --tests --features wasm-testing -- -D warnings
- run: cargo clippy --package dioxus-sdk --tests --features desktop-testing -- -D warnings
- run: cargo clippy --workspace --all-targets --exclude *-example --target wasm32-unknown-unknown --tests --all-features -- -D warnings
- run: cargo clippy --workspace --all-targets --tests --all-features -- -D warnings
11 changes: 6 additions & 5 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ on:
branches:
- main
paths:
- sdk/**
- packages/**
- examples/**

pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- main
paths:
- sdk/**
- packages/**
- examples/**

env:
Expand All @@ -29,7 +29,7 @@ jobs:
- uses: actions/checkout@v3
- run: rustup target add wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- run: cargo build --package dioxus-sdk --verbose --target wasm32-unknown-unknown --no-default-features --features wasm-testing
- run: cargo build --all-targets --workspace --exclude *-example --verbose --target wasm32-unknown-unknown --all-features
# need to run tests here

desktop:
Expand All @@ -39,5 +39,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- run: cargo build --package dioxus-sdk --verbose --no-default-features --features desktop-testing
- run: cargo test --package dioxus-sdk --verbose --no-default-features --features desktop-testing
- run: cargo build --all-targets --workspace --verbose --all-features
- run: cargo test --all-targets --workspace --verbose --all-features
- run: cargo test --workspace --verbose --all-features --doc
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"rust-analyzer.cargo.features": "all",
"rust-analyzer.check.features": "all",
"rust-analyzer.check.allTargets": true,
//"rust-analyzer.cargo.target": "wasm32-unknown-unknown",
}
42 changes: 37 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,41 @@
[workspace]
resolver = "2"
members = ["sdk", "examples/*"]
members = ["packages/*", "examples/*"]

package.authors = [
"Dioxus Labs",
"Jonathan Kelley",
"DogeDark",
"marc2332",
"ealmloff",
]
package.edition = "2021"
package.license = "MIT OR Apache-2.0"
package.homepage = "https://dioxuslabs.com"
package.repository = "https://github.com/DioxusLabs/sdk/"

[workspace.dependencies]
dioxus-sdk = { path = "./sdk" }
dioxus = { version = "0.6.0" }
dioxus-desktop = { version = "0.6.0" }
dioxus-signals = { version = "0.6.0" }
# Workspace
dioxus-time = { path = "packages/time" }
dioxus-storage = { path = "packages/storage" }
dioxus-geolocation = { path = "packages/geolocation" }
dioxus-notification = { path = "packages/notification" }
dioxus-sync = { path = "packages/sync" }
dioxus-util = { path = "packages/util" }
dioxus-window = { path = "packages/window" }

# Dioxus
dioxus = "0.6.0"
dioxus-signals = "0.6.0"
dioxus-desktop = "0.6.0"
dioxus-config-macro = "0.6.0"

# Deps
cfg-if = "1.0.0"
tokio = "1.43.0"
futures = "0.3.31"
futures-util = "0.3.31"

wasm-bindgen = "0.2.100"
web-sys = "0.3.77"
js-sys = "0.3.77"
60 changes: 34 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align="center">
<h1>🧰 Dioxus Development Kit 🚀</h1>
<p><strong>A platform agnostic library for supercharging your productivity with Dioxus.</strong></p>
<p><strong>Cross-platform crates for supercharging your productivity with Dioxus.</strong></p>
</div>

<div align="center">
Expand All @@ -23,35 +23,40 @@

-----

<p align="center"><i>This library is still under development. Expect breaking changes!</i></p>
<p align="center"><i>These crates are still under development. Expect breaking changes!</i></p>
<br/>

`dioxus-sdk` is a development kit for Dioxus that provides abstractions for your Dioxus app. Abstractions included are notifications, clipboard, geolocation and storage with more to come!
`dioxus-sdk` is a development kit for Dioxus that provides cross-platform APIs for your Dioxus app. SDK is organized into many different crates accessible through the `dioxus-sdk` crate with the corresponding feature flags.

**Features**
- [x] Geolocation - (Web, Windows)
- [x] Storage - (Web, Desktop)
- [x] Clipboard - (Desktop)
- [x] Notifications - (Desktop)
- [x] Color Scheme - (Web)
- [x] Utility Hooks
- [x] use_channel
- [x] use_window_size
- [x] use_interval
- [x] use_debounce
- [ ] use_timeout
## Features
- `dioxus-storage`
- `dioxus-geolocation` - Web & Windows
- `dioxus-notifications` - Desktop
- `dioxus-window`
- [x] Theme - (Web, Windows, Mac)
- [x] Window Size
- `dioxus-time`
- [x] Sleep
- [x] Intervals
- [x] Debounce
- [x] Timeouts
- `dioxus-sync`
- [x] Channels
- [ ] Camera
- [ ] WiFi
- [ ] Bluetooth

Geolocation example:

```rust
// dioxus-sdk = { version = "*", features = ["geolocation"] }
use dioxus::prelude::*;
use dioxus_sdk::geolocation::{
init_geolocator, use_geolocation, PowerMode
};

fn app() -> Element {
#[component]
fn App() -> Element {
let geolocator = init_geolocator(PowerMode::High).unwrap();
let coords = use_geolocation();

Expand All @@ -69,22 +74,25 @@ fn app() -> Element {
}
```

## Platform Support
### Clipboard

On linux you need the x11 library to use the clipboard abstraction:
```
sudo apt-get install xorg-dev
```

## Usage
You can add `dioxus-sdk` to your application by adding it to your dependencies.
```toml
[dependencies]
dioxus-sdk = { version = "0.6", features = [] }
dioxus-sdk = { version = "0.7", features = [] }
```

### Dioxus Compatibility
This table represents the compatibility between this crate and Dioxus versions.
The crate version supports a Dioxus version up until the next crate version in the table.

E.g. if crate version `0.1` supported Dioxus `0.6` and crate version `0.4` supported Dioxus `0.7`, crate versions `0.1`, `0.2`, and `0.3` would support Dioxus `0.6`.

| Crate Version | Dioxus Version |
| ------------- | -------------- |
| 0.6 | 0.6 |
| 0.5 | 0.5 |

## License
This project is dual licensed under the [MIT](./LICENSE-MIT) and [Apache 2.0](./LICENSE-APACHE) licenses.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in `dioxus-sdk` by you, shall be licensed as MIT or Apache 2.0, without any additional terms or conditions.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in `dioxus-sdk` or any of it's crates, by you, shall be licensed as MIT or Apache 2.0, without any additional terms or conditions.
16 changes: 0 additions & 16 deletions examples/README.md

This file was deleted.

16 changes: 7 additions & 9 deletions examples/channel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
[package]
name = "channel"
name = "channel-example"
version = "0.1.0"
edition = "2021"

[dependencies]
dioxus-sdk = { workspace = true, features = ["channel"] }
dioxus = { workspace = true, features = ["web"] }
dioxus = { workspace = true }
dioxus-sync = { workspace = true }


log = "0.4.6"

# WebAssembly Debug
wasm-logger = "0.2.0"
console_error_panic_hook = "0.1.7"
[features]
default = ["desktop"]
web = ["dioxus/web"]
desktop = ["dioxus/desktop"]
42 changes: 0 additions & 42 deletions examples/channel/Dioxus.toml

This file was deleted.

4 changes: 2 additions & 2 deletions examples/channel/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# use_channel

Learn how to use `use_channel`.
Learn how to use `use_channel` from `dioxus-sync`.

Run:

```dioxus serve```
```dx serve```
Binary file removed examples/channel/public/favicon.ico
Binary file not shown.
17 changes: 7 additions & 10 deletions examples/channel/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
use dioxus::prelude::*;
use dioxus_sdk::utils::channel::{use_channel, use_listen_channel};
use dioxus::{logger::tracing::info, prelude::*};
use dioxus_sync::channel::{use_channel, use_listen_channel};

fn main() {
// init debug tool for WebAssembly
wasm_logger::init(wasm_logger::Config::default());
console_error_panic_hook::set_once();

launch(app);
launch(App);
}

fn app() -> Element {
#[component]
fn App() -> Element {
let channel = use_channel::<String>(5);

use_listen_channel(&channel, |message| async {
match message {
Ok(value) => log::info!("Incoming message: {value}"),
Err(err) => log::info!("Error: {err:?}"),
Ok(value) => info!("Incoming message: {value}"),
Err(err) => info!("Error: {err:?}"),
}
});

Expand Down
8 changes: 0 additions & 8 deletions examples/clipboard/Cargo.toml

This file was deleted.

43 changes: 0 additions & 43 deletions examples/clipboard/src/main.rs

This file was deleted.

Loading
Loading